--- event-epoll.c.nontunable 2014-09-05 16:27:10.261223176 -0400 +++ event-epoll.c 2014-09-05 16:33:19.818407183 -0400 @@ -612,23 +612,35 @@ } -#define GLUSTERFS_EPOLL_MAXTHREADS 2 +#define GLUSTERFS_EPOLL_MAX_THREADS 8 +#define GLUSTERFS_EPOLL_DEFAULT_THREADS 4 +int glusterfs_epoll_threads = -1; static int event_dispatch_epoll (struct event_pool *event_pool) { int i = 0; - pthread_t pollers[GLUSTERFS_EPOLL_MAXTHREADS]; + pthread_t pollers[GLUSTERFS_EPOLL_MAX_THREADS]; int ret = -1; + char * epoll_thrd_str = getenv("GLUSTERFS_EPOLL_THREADS"); - for (i = 0; i < GLUSTERFS_EPOLL_MAXTHREADS; i++) { + glusterfs_epoll_threads = + epoll_thrd_str ? atoi(epoll_thrd_str) : GLUSTERFS_EPOLL_DEFAULT_THREADS;; + + if (glusterfs_epoll_threads > GLUSTERFS_EPOLL_MAX_THREADS) { + gf_log ("epoll", GF_LOG_ERROR, + "user requested %d threads but limit is %d", + glusterfs_epoll_threads, GLUSTERFS_EPOLL_MAX_THREADS); + return EINVAL; + } + for (i = 0; i < glusterfs_epoll_threads; i++) { ret = pthread_create (&pollers[i], NULL, event_dispatch_epoll_worker, event_pool); } - for (i = 0; i < GLUSTERFS_EPOLL_MAXTHREADS; i++) + for (i = 0; i < glusterfs_epoll_threads; i++) pthread_join (pollers[i], NULL); return ret;