diff options
-rw-r--r-- | libglusterfs/src/mem-types.h | 1 | ||||
-rw-r--r-- | xlators/cluster/dht/src/dht-rebalance.c | 17 |
2 files changed, 15 insertions, 3 deletions
diff --git a/libglusterfs/src/mem-types.h b/libglusterfs/src/mem-types.h index 958de8bc634..afa52d8bc45 100644 --- a/libglusterfs/src/mem-types.h +++ b/libglusterfs/src/mem-types.h @@ -167,6 +167,7 @@ enum gf_common_mem_types_ { gf_common_mt_tw_timer_list, /*lock migration*/ gf_common_mt_lock_mig, + gf_common_mt_pthread_t, gf_common_mt_end }; #endif diff --git a/xlators/cluster/dht/src/dht-rebalance.c b/xlators/cluster/dht/src/dht-rebalance.c index 5f3b5daf31b..77f6ec2f823 100644 --- a/xlators/cluster/dht/src/dht-rebalance.c +++ b/xlators/cluster/dht/src/dht-rebalance.c @@ -21,7 +21,6 @@ #define GF_DISK_SECTOR_SIZE 512 #define DHT_REBALANCE_PID 4242 /* Change it if required */ #define DHT_REBALANCE_BLKSIZE (128 * 1024) -#define MAX_MIGRATOR_THREAD_COUNT 40 #define MAX_MIGRATE_QUEUE_COUNT 500 #define MIN_MIGRATE_QUEUE_COUNT 200 @@ -3550,7 +3549,7 @@ gf_defrag_start_crawl (void *data) int thread_index = 0; int err = 0; int thread_spawn_count = 0; - pthread_t tid[MAX_MIGRATOR_THREAD_COUNT]; + pthread_t *tid = NULL; gf_boolean_t is_tier_detach = _gf_false; this = data; @@ -3687,7 +3686,8 @@ gf_defrag_start_crawl (void *data) gf_dht_mt_container_t); if (!defrag->queue) { - gf_log (this->name, GF_LOG_INFO, "No memory for queue"); + gf_log (this->name, GF_LOG_ERROR, "No memory for " + "queue"); ret = -1; goto out; } @@ -3699,6 +3699,15 @@ gf_defrag_start_crawl (void *data) gf_msg_debug (this->name, 0, "thread_spawn_count: %d", thread_spawn_count); + tid = GF_CALLOC (thread_spawn_count, sizeof (pthread_t), + gf_common_mt_pthread_t); + if (!tid) { + gf_log (this->name, GF_LOG_ERROR, "Insufficient memory " + "for tid"); + ret = -1; + goto out; + } + defrag->current_thread_count = thread_spawn_count; /*Spawn Threads Here*/ @@ -3788,6 +3797,8 @@ out: pthread_join (tid[i], NULL); } + GF_FREE (tid); + if (defrag->cmd == GF_DEFRAG_CMD_START_TIER) { /* Wait for the tier fixlayout to * complete if its was started.*/ |