diff options
Diffstat (limited to 'xlators')
-rw-r--r-- | xlators/performance/io-threads/src/io-threads.c | 76 | ||||
-rw-r--r-- | xlators/performance/io-threads/src/io-threads.h | 3 |
2 files changed, 51 insertions, 28 deletions
diff --git a/xlators/performance/io-threads/src/io-threads.c b/xlators/performance/io-threads/src/io-threads.c index ce42a98348f..6a30184aaa3 100644 --- a/xlators/performance/io-threads/src/io-threads.c +++ b/xlators/performance/io-threads/src/io-threads.c @@ -41,16 +41,16 @@ iot_schedule (iot_conf_t *conf, iot_file_t *file, ino_t ino) { - int32_t cnt = (ino % conf->thread_count); - iot_worker_t *trav = conf->workers.next; + int32_t idx = 0; + iot_worker_t *selected_worker = NULL; + + idx = (ino % conf->thread_count); + selected_worker = conf->workers[idx]; - for (; cnt; cnt--) - trav = trav->next; - if (file) - file->worker = trav; - trav->fd_count++; - return trav; + file->worker = selected_worker; + + return selected_worker; } int32_t @@ -1078,33 +1078,57 @@ iot_worker (void *arg) } } -static void -workers_init (iot_conf_t *conf) +static iot_worker_t ** +allocate_worker_array (int count) { - int i; + iot_worker_t ** warr = NULL; - conf->workers.next = &conf->workers; - conf->workers.prev = &conf->workers; + warr = CALLOC (count, sizeof(iot_worker_t *)); + ERR_ABORT (warr); - for (i=0; i<conf->thread_count; i++) { + return warr; +} - iot_worker_t *worker = CALLOC (1, sizeof (*worker)); - ERR_ABORT (worker); +static iot_worker_t * +allocate_worker (iot_conf_t * conf) +{ + iot_worker_t *wrk = NULL; - worker->next = &conf->workers; - worker->prev = conf->workers.prev; - worker->next->prev = worker; - worker->prev->next = worker; + wrk = CALLOC (1, sizeof (iot_worker_t)); + ERR_ABORT (wrk); - INIT_LIST_HEAD (&worker->rqlist); - pthread_mutex_init (&worker->qlock, NULL); - pthread_cond_init (&worker->dq_cond, NULL); - worker->conf = conf; + INIT_LIST_HEAD (&wrk->rqlist); + wrk->conf = conf; + pthread_cond_init (&wrk->dq_cond, NULL); + pthread_mutex_init (&wrk->qlock, NULL); - pthread_create (&worker->thread, NULL, iot_worker, worker); - } + return wrk; } +static void +allocate_workers (iot_conf_t *conf, + int count, + int start_alloc_idx) +{ + int i, end_count; + + end_count = count + start_alloc_idx; + for (i = start_alloc_idx; i < end_count; i++) { + conf->workers[i] = allocate_worker (conf); + pthread_create (&conf->workers[i]->thread, NULL, iot_worker, + conf->workers[i]); + } +} + +static void +workers_init (iot_conf_t *conf) +{ + conf->workers = allocate_worker_array (conf->thread_count); + allocate_workers (conf, conf->thread_count, 0); +} + + + int32_t init (xlator_t *this) { diff --git a/xlators/performance/io-threads/src/io-threads.h b/xlators/performance/io-threads/src/io-threads.h index 73a76fa8fe2..9798a09ed1d 100644 --- a/xlators/performance/io-threads/src/io-threads.h +++ b/xlators/performance/io-threads/src/io-threads.h @@ -56,7 +56,6 @@ struct iot_request { }; struct iot_worker { - struct iot_worker *next, *prev; struct list_head rqlist; /* List of requests assigned to me. */ struct iot_conf *conf; int64_t q,dq; @@ -77,7 +76,7 @@ struct iot_file { struct iot_conf { int32_t thread_count; int32_t misc_thread_index; /* Used to schedule the miscellaneous calls like checksum */ - struct iot_worker workers; + struct iot_worker ** workers; struct iot_file files; pthread_mutex_t files_lock; |