diff options
author | Eric Wong <normalperson@yhbt.net> | 2013-06-21 03:34:09 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2013-06-25 21:20:19 +0000 |
commit | 4d112de546a28b99d52435d4fed075f148455826 (patch) | |
tree | 5f40aee2c26181b7a2650ed598135827f13e2634 /thrpool.c | |
parent | 3d93bd96c92cedd583e14ea58b34bb143c4e9e87 (diff) | |
download | cmogstored-4d112de546a28b99d52435d4fed075f148455826.tar.gz |
This will help ensure availability when new devices are added, without additional user interaction to manually set aio_threads via sidechannel.
Diffstat (limited to 'thrpool.c')
-rw-r--r-- | thrpool.c | 35 |
1 files changed, 34 insertions, 1 deletions
@@ -4,6 +4,9 @@ */ #include "cmogstored.h" +/* this is set and read without a lock, but harmless if racy */ +size_t mog_user_set_aio_threads; + /* * we can lower this if we can test with lower values, NPTL minimum is 16K. * We also use syslog() and *printf() functions which take a lot of @@ -132,6 +135,36 @@ out: CHECK(int, 0, pthread_mutex_unlock(&tp->lock)); } +/* this is only called by the main (notify) thread */ +void mog_thrpool_update(struct mog_queue *q, size_t ndev_old, size_t ndev_new) +{ + size_t size = ndev_new * 10; + struct mog_thrpool *tp = &q->thrpool; + + if (mog_user_set_aio_threads) { + size_t n_threads; + + CHECK(int, 0, pthread_mutex_lock(&tp->lock)); + n_threads = tp->n_threads; + CHECK(int, 0, pthread_mutex_unlock(&tp->lock)); + + if (n_threads >= ndev_new) + return; + + syslog(LOG_WARNING, + "server aio_threads=%zu is less than devcount=%zu", + n_threads, ndev_new); + + return; + } + + if (ndev_old) + syslog(LOG_INFO, + "devcount(%zu->%zu), updating server aio_threads=%zu", + ndev_old, ndev_new, size); + thrpool_set_size(tp, size); +} + /* * fire and forget, we must run the actual thread count manipulation * in the main notify thread because we may end up terminating the @@ -171,7 +204,7 @@ void mog_thrpool_process_queue(void) if (arg == NULL) return; - syslog(LOG_INFO, "server aio_threads=%u", (unsigned)arg->size); + syslog(LOG_INFO, "server aio_threads=%zu", arg->size); thrpool_set_size(&arg->queue->thrpool, arg->size); free(arg); } |