about summary refs log tree commit homepage
path: root/svc_dev.c
diff options
context:
space:
mode:
Diffstat (limited to 'svc_dev.c')
-rw-r--r--svc_dev.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/svc_dev.c b/svc_dev.c
index 6fe3396..e66ca26 100644
--- a/svc_dev.c
+++ b/svc_dev.c
@@ -293,3 +293,35 @@ void mog_mkusage_all(void)
 {
         mog_svc_each(svc_mkusage_each, NULL);
 }
+
+/* we should never set ioq_max == 0 */
+static void svc_rescale_warn_fix_capa(struct mog_svc *svc, size_t ndev_new)
+{
+        if (svc->thr_per_dev != 0)
+                return;
+
+        syslog(LOG_WARNING,
+               "serving %s with fewer aio_threads(%zu) than devices(%zu)",
+               svc->docroot, svc->user_set_aio_threads, ndev_new);
+        syslog(LOG_WARNING,
+               "set \"server aio_threads = %zu\" or higher via sidechannel",
+               ndev_new);
+
+        svc->thr_per_dev = 1;
+}
+
+/* rescaling only happens in the main thread */
+void mog_svc_dev_user_rescale(struct mog_svc *svc, size_t ndev_new)
+{
+        assert(svc->user_set_aio_threads &&
+               "user did not set aio_threads via sidechannel");
+
+        svc->thr_per_dev = svc->user_set_aio_threads / ndev_new;
+
+        svc_rescale_warn_fix_capa(svc, ndev_new);
+
+        /* iterate through each device of this svc */
+        CHECK(int, 0, pthread_mutex_lock(&svc->by_mog_devid_lock));
+        hash_do_for_each(svc->by_mog_devid, mog_dev_user_rescale_i, svc);
+        CHECK(int, 0, pthread_mutex_unlock(&svc->by_mog_devid_lock));
+}