diff options
author | Mohit Agrawal <moagrawal@redhat.com> | 2019-04-29 18:48:36 +0530 |
---|---|---|
committer | Atin Mukherjee <amukherj@redhat.com> | 2019-04-30 13:10:36 +0000 |
commit | ac70f66c5805e10b3a1072bd467918730c0aeeb4 (patch) | |
tree | e7df7e7eb40a0ec964730c828dc6a6a3b5726b47 | |
parent | cfd838c27cc88acd431549f2b8ed515c9ce3e55f (diff) |
glusterd: Fix bulkvoldict thread logic in brick multiplexing
Problem: Currently glusterd spawn bulkvoldict in brick_mux
environment while no. of volumes are less than configured
glusterd.vol_count_per_thread
Solution: Correct the logic to spawn bulkvoldict thread
1) Calculate endindex only while total thread is non zero
2) Update end index correctly to pass index for bulkvoldict
thread
Fixes: bz#1704252
Change-Id: I1def847fbdd6a605e7687bfc4e42b706bf0eb70b
Signed-off-by: Mohit Agrawal <moagrawal@redhat.com>
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-utils.c | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c index 4f0eb32ff48..4a2caa34f78 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-utils.c @@ -3357,9 +3357,19 @@ glusterd_add_bulk_volumes_create_thread(void *data) cds_list_for_each_entry(volinfo, &priv->volumes, vol_list) { count++; - if ((count < start) || (count > end)) + + /* Skip volumes if index count is less than start + index to handle volume for specific thread + */ + if (count < start) continue; + /* No need to process volume if index count is greater + than end index + */ + if (count > end) + break; + ret = glusterd_add_volume_to_dict(volinfo, dict, count, "volume"); if (ret) goto out; @@ -3420,9 +3430,11 @@ glusterd_add_volumes_to_export_dict(dict_t **peer_data) totthread = 0; } else { totthread = volcnt / vol_per_thread_limit; - endindex = volcnt % vol_per_thread_limit; - if (endindex) - totthread++; + if (totthread) { + endindex = volcnt % vol_per_thread_limit; + if (endindex) + totthread++; + } } if (totthread == 0) { @@ -3448,10 +3460,10 @@ glusterd_add_volumes_to_export_dict(dict_t **peer_data) arg->this = this; arg->voldict = dict_arr[i]; arg->start = start; - if (!endindex) { + if ((i + 1) != totthread) { arg->end = ((i + 1) * vol_per_thread_limit); } else { - arg->end = (start + endindex); + arg->end = ((i * vol_per_thread_limit) + endindex); } th_ret = gf_thread_create_detached( &th_id, glusterd_add_bulk_volumes_create_thread, arg, |