about summary refs log tree commit homepage
path: root/svc_dev.c
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2013-06-21 03:34:12 +0000
committerEric Wong <normalperson@yhbt.net>2013-06-25 21:24:53 +0000
commite90b43119ff33fb591ffb3bc100cf847537ca5fb (patch)
treeef181b44f4c323aaf53df2716017982616816b69 /svc_dev.c
parent2acbe7f4001de74091282ee199e3cad50c2e3e7f (diff)
downloadcmogstored-e90b43119ff33fb591ffb3bc100cf847537ca5fb.tar.gz
This simplifies code, reduces contention, and reduces the
chances of independent MogileFS instances (with one instance
of cmogstored) stepping over each other.

Most cmogstored deployments are single docroot (for a single
instance of MogileFS), however cmogstored supports multiple
docroots for some rare configurations and we support them here.
Diffstat (limited to 'svc_dev.c')
-rw-r--r--svc_dev.c24
1 files changed, 11 insertions, 13 deletions
diff --git a/svc_dev.c b/svc_dev.c
index 8786a50..566602c 100644
--- a/svc_dev.c
+++ b/svc_dev.c
@@ -4,7 +4,6 @@
  */
 #include "cmogstored.h"
 #include "compat_memstream.h"
-static size_t ndev;
 
 /*
  * maps multiple "devXXX" directories to the device.
@@ -287,22 +286,21 @@ void mog_svc_dev_shutdown(void)
         mog_svc_each(devstats_shutdown_i, NULL);
 }
 
-static bool svc_mkusage_each(void *svc, void *nr)
+static bool svc_mkusage_each(void *svcptr, void *ignored)
 {
-        svc_scandev((struct mog_svc *)svc, nr, mog_dev_mkusage);
+        struct mog_svc *svc = svcptr;
+        size_t ndev = 0;
+
+        svc_scandev(svc, &ndev, mog_dev_mkusage);
+
+        if (svc->queue && (svc->nmogdev != ndev))
+                mog_thrpool_update(svc->queue, svc->nmogdev, ndev);
+        svc->nmogdev = ndev;
 
         return true;
 }
 
-size_t mog_mkusage_all(struct mog_queue *q)
+void mog_mkusage_all(void)
 {
-        size_t ndev_new = 0;
-
-        mog_svc_each(svc_mkusage_each, &ndev_new);
-
-        if (q && ndev_new != ndev)
-                mog_thrpool_update(q, ndev, ndev_new);
-        ndev = ndev_new;
-
-        return ndev;
+        mog_svc_each(svc_mkusage_each, NULL);
 }