about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2013-06-21 03:34:22 +0000
committerEric Wong <normalperson@yhbt.net>2013-06-25 21:33:43 +0000
commitdf50c675f127c876e8d74be522ddc858aa3795ef (patch)
tree77dc6b987ad229ce403260581598b5fa8817955d
parentd5a52618ca1f9b5d7f6998716fbfe7714f927112 (diff)
downloadcmogstored-df50c675f127c876e8d74be522ddc858aa3795ef.tar.gz
We could eventually make this a tunable parameter, as it could
be advantageous over a global aio_threads value.
-rw-r--r--cmogstored.h1
-rw-r--r--svc.c13
2 files changed, 9 insertions, 5 deletions
diff --git a/cmogstored.h b/cmogstored.h
index fd10e6d..a92b0cc 100644
--- a/cmogstored.h
+++ b/cmogstored.h
@@ -140,6 +140,7 @@ struct mog_svc {
         const char *docroot;
         size_t nmogdev;
         size_t user_set_aio_threads; /* only touched by main/notify thread */
+        size_t thr_per_dev;
 
         /* private */
         DIR *dir;
diff --git a/svc.c b/svc.c
index 834117d..cf6a083 100644
--- a/svc.c
+++ b/svc.c
@@ -11,7 +11,6 @@
 static pthread_mutex_t svc_lock = PTHREAD_MUTEX_INITIALIZER;
 static Hash_table *by_docroot; /* enforce one mog_svc per docroot: */
 static mode_t mog_umask;
-static const size_t thr_per_dev = 10;
 
 /*
  * maintain an internal queue of requests for the "server aio_threads = N"
@@ -113,6 +112,7 @@ struct mog_svc * mog_svc_new(const char *docroot)
         svc->dir = dir;
         svc->put_perms = (~mog_umask) & 0666;
         svc->mkcol_perms = (~mog_umask) & 0777;
+        svc->thr_per_dev = 10;
         svc->idle_timeout = 5;
         CHECK(int, 0, pthread_mutex_init(&svc->devstats_lock, NULL));
         CHECK(int, 0, pthread_mutex_init(&svc->by_mog_devid_lock, NULL));
@@ -172,7 +172,7 @@ void mog_svc_upgrade_prepare(void)
 /* this is only called by the main (notify) thread */
 void mog_svc_thrpool_rescale(struct mog_svc *svc, size_t ndev_new)
 {
-        size_t size = ndev_new * thr_per_dev;
+        size_t size = ndev_new * svc->thr_per_dev;
         struct mog_thrpool *tp = &svc->queue->thrpool;
 
         /* respect user-setting */
@@ -187,8 +187,8 @@ void mog_svc_thrpool_rescale(struct mog_svc *svc, size_t ndev_new)
                 return;
         }
 
-        if (size < thr_per_dev)
-                size = thr_per_dev;
+        if (size < svc->thr_per_dev)
+                size = svc->thr_per_dev;
 
         if (svc->nmogdev)
                 syslog(LOG_INFO,
@@ -205,7 +205,10 @@ bool mog_svc_start_each(void *svc_ptr, void *main_ptr)
         struct mog_accept *ac;
         size_t athr = (size_t)num_processors(NPROC_CURRENT);
         struct mog_queue *q = mog_queue_new();
-        size_t nthr = svc->nmogdev ? svc->nmogdev * thr_per_dev : thr_per_dev;
+        size_t nthr = svc->nmogdev * svc->thr_per_dev;
+
+        if (!nthr)
+                nthr = svc->thr_per_dev;
 
         /*
          * try to distribute accept() callers between workers more evenly