about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2014-05-29 07:27:56 +0000
committerEric Wong <e@80x24.org>2014-05-29 07:29:47 +0000
commitd1a90e506902150c7db1d525e71e5b6cd66744de (patch)
tree8f93c2d343c5090a2b5b86414631d9f1f2d8131d
parent19a0fde65d8905f31e4ffaea531da4cefb02c29e (diff)
downloadcmogstored-khash.tar.gz
This reduces unnecessary boilerplate due to switching khash.
-rw-r--r--cmogstored.h3
-rw-r--r--dev.c21
-rw-r--r--svc_dev.c12
3 files changed, 7 insertions, 29 deletions
diff --git a/cmogstored.h b/cmogstored.h
index 3e03fce..84da3a9 100644
--- a/cmogstored.h
+++ b/cmogstored.h
@@ -393,8 +393,7 @@ bool mog_svc_atfork_child(void *svc_ptr, void *parent);
 struct mog_dev *mog_dev_for(struct mog_svc *, uint32_t mog_devid, bool update);
 int mog_dev_mkusage(const struct mog_dev *, struct mog_svc *);
 void mog_dev_free(struct mog_dev *);
-bool mog_dev_user_rescale_i(void *devp, void *svcp);
-bool mog_dev_requeue_prepare(void *devp, void *ign);
+void mog_dev_requeue_prepare(struct mog_dev *);
 
 /* valid_path.rl */
 int mog_valid_path(const char *buf, size_t len);
diff --git a/dev.c b/dev.c
index 15f651a..401236e 100644
--- a/dev.c
+++ b/dev.c
@@ -236,27 +236,8 @@ void mog_dev_free(struct mog_dev *dev)
         free(dev);
 }
 
-/*
- * Only called by the main/notify thread as a hash iterator function
- * This increases or decreases the capacity of a given device if a
- * a sidechannel user changes the worker thread pool size.
- */
-bool mog_dev_user_rescale_i(void *devp, void *svcp)
+void mog_dev_requeue_prepare(struct mog_dev *dev)
 {
-        struct mog_dev *dev = devp;
-        struct mog_svc *svc = svcp;
-
-        mog_ioq_adjust(&dev->ioq, svc->thr_per_dev);
-
-        return true; /* continue iteration */
-}
-
-bool mog_dev_requeue_prepare(void *devp, void *ign)
-{
-        struct mog_dev *dev = devp;
-
         mog_ioq_requeue_prepare(&dev->ioq);
         mog_ioq_requeue_prepare(&dev->fsckq);
-
-        return true; /* continue iteration */
 }
diff --git a/svc_dev.c b/svc_dev.c
index 3a87800..a7e6dce 100644
--- a/svc_dev.c
+++ b/svc_dev.c
@@ -310,27 +310,25 @@ static void svc_rescale_warn_fix_capa(struct mog_svc *svc, unsigned ndev_new)
         svc->thr_per_dev = 1;
 }
 
+/* Only called by the main/notify thread */
 static void mog_svc_dev_rescale_all(struct mog_svc *svc)
 {
         struct mog_dev *dev;
-        khash_t(by_mog_devid) *h;
+        khash_t(by_mog_devid) *h = svc->by_mog_devid;
 
-        /* iterate through each device of this svc */
         CHECK(int, 0, pthread_mutex_lock(&svc->by_mog_devid_lock));
-        h = svc->by_mog_devid;
-        mog_kh_foreach_key(h, dev, mog_dev_user_rescale_i(dev, svc));
+        mog_kh_foreach_key(h, dev, mog_ioq_adjust(&dev->ioq, svc->thr_per_dev));
         CHECK(int, 0, pthread_mutex_unlock(&svc->by_mog_devid_lock));
 }
 
 void mog_svc_dev_requeue_prepare(struct mog_svc *svc)
 {
         struct mog_dev *dev;
-        khash_t(by_mog_devid) *h;
+        khash_t(by_mog_devid) *h = svc->by_mog_devid;
 
         /* iterate through each device of this svc */
         CHECK(int, 0, pthread_mutex_lock(&svc->by_mog_devid_lock));
-        h = svc->by_mog_devid;
-        mog_kh_foreach_key(h, dev, mog_dev_requeue_prepare(dev, svc));
+        mog_kh_foreach_key(h, dev, mog_dev_requeue_prepare(dev));
         CHECK(int, 0, pthread_mutex_unlock(&svc->by_mog_devid_lock));
 }