From ac70f66c5805e10b3a1072bd467918730c0aeeb4 Mon Sep 17 00:00:00 2001 From: Mohit Agrawal Date: Mon, 29 Apr 2019 18:48:36 +0530 Subject: 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 --- xlators/mgmt/glusterd/src/glusterd-utils.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'xlators/mgmt/glusterd/src') 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, -- cgit