about summary refs log tree commit homepage
path: root/svc_dev.c
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2013-07-12 00:54:57 +0000
committerEric Wong <normalperson@yhbt.net>2013-07-12 00:54:57 +0000
commit1c9fe8380f14e2b67bed99d16ef465db8d379b41 (patch)
tree148046a743f73f244bc1295c4ca7f71432391618 /svc_dev.c
parent56d4a65df3fc011086648563b2235eac49b7ba60 (diff)
downloadcmogstored-1c9fe8380f14e2b67bed99d16ef465db8d379b41.tar.gz
By reducing the capacity of each ioq, we force each running worker
thread to yield the current client and hit an exit point
(epoll_wait/kqueue) sooner.
Diffstat (limited to 'svc_dev.c')
-rw-r--r--svc_dev.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/svc_dev.c b/svc_dev.c
index e66ca26..93e3c43 100644
--- a/svc_dev.c
+++ b/svc_dev.c
@@ -310,6 +310,14 @@ static void svc_rescale_warn_fix_capa(struct mog_svc *svc, size_t ndev_new)
         svc->thr_per_dev = 1;
 }
 
+static void mog_svc_dev_rescale_all(struct mog_svc *svc)
+{
+        /* 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));
+}
+
 /* rescaling only happens in the main thread */
 void mog_svc_dev_user_rescale(struct mog_svc *svc, size_t ndev_new)
 {
@@ -319,9 +327,15 @@ void mog_svc_dev_user_rescale(struct mog_svc *svc, size_t ndev_new)
         svc->thr_per_dev = svc->user_set_aio_threads / ndev_new;
 
         svc_rescale_warn_fix_capa(svc, ndev_new);
+        mog_svc_dev_rescale_all(svc);
+}
 
-        /* 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));
+/*
+ * this forces ioqs to detect contention and yield,
+ * leading to quicker shutdown
+ */
+void mog_svc_dev_quit_prepare(struct mog_svc *svc)
+{
+        svc->thr_per_dev = 1;
+        mog_svc_dev_rescale_all(svc);
 }