233933
From bb39abc1dab3c7b7b725f9eefe119218e94f610b Mon Sep 17 00:00:00 2001
233933
From: Mohit Agrawal <moagrawal@redhat.com>
233933
Date: Mon, 29 Apr 2019 18:48:36 +0530
233933
Subject: [PATCH 128/141] glusterd: Fix bulkvoldict thread logic in brick
233933
 multiplexing
233933
233933
Problem: Currently glusterd spawn bulkvoldict in brick_mux
233933
         environment while no. of volumes are less than configured
233933
         glusterd.vol_count_per_thread
233933
233933
Solution: Correct the logic to spawn bulkvoldict thread
233933
          1) Calculate endindex only while total thread is non zero
233933
          2) Update end index correctly to pass index for bulkvoldict
233933
             thread
233933
233933
> Fixes: bz#1704252
233933
> Change-Id: I1def847fbdd6a605e7687bfc4e42b706bf0eb70b
233933
> (Cherry picked from commit ac70f66c5805e10b3a1072bd467918730c0aeeb4)
233933
> (Reviewed on upstream link https://review.gluster.org/#/c/glusterfs/+/22647/)
233933
233933
BUG: 1704769
233933
Change-Id: I1def847fbdd6a605e7687bfc4e42b706bf0eb70b
233933
Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
233933
Reviewed-on: https://code.engineering.redhat.com/gerrit/169091
233933
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
233933
Tested-by: RHGS Build Bot <nigelb@redhat.com>
233933
---
233933
 xlators/mgmt/glusterd/src/glusterd-utils.c | 24 ++++++++++++++++++------
233933
 1 file changed, 18 insertions(+), 6 deletions(-)
233933
233933
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
233933
index ff6102b..efa5a86 100644
233933
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
233933
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
233933
@@ -3436,9 +3436,19 @@ glusterd_add_bulk_volumes_create_thread(void *data)
233933
     cds_list_for_each_entry(volinfo, &priv->volumes, vol_list)
233933
     {
233933
         count++;
233933
-        if ((count < start) || (count > end))
233933
+
233933
+        /* Skip volumes if index count is less than start
233933
+           index to handle volume for specific thread
233933
+        */
233933
+        if (count < start)
233933
             continue;
233933
 
233933
+        /* No need to process volume if index count is greater
233933
+           than end index
233933
+        */
233933
+        if (count > end)
233933
+            break;
233933
+
233933
         ret = glusterd_add_volume_to_dict(volinfo, dict, count, "volume");
233933
         if (ret)
233933
             goto out;
233933
@@ -3499,9 +3509,11 @@ glusterd_add_volumes_to_export_dict(dict_t **peer_data)
233933
         totthread = 0;
233933
     } else {
233933
         totthread = volcnt / vol_per_thread_limit;
233933
-        endindex = volcnt % vol_per_thread_limit;
233933
-        if (endindex)
233933
-            totthread++;
233933
+        if (totthread) {
233933
+            endindex = volcnt % vol_per_thread_limit;
233933
+            if (endindex)
233933
+                totthread++;
233933
+        }
233933
     }
233933
 
233933
     if (totthread == 0) {
233933
@@ -3527,10 +3539,10 @@ glusterd_add_volumes_to_export_dict(dict_t **peer_data)
233933
             arg->this = this;
233933
             arg->voldict = dict_arr[i];
233933
             arg->start = start;
233933
-            if (!endindex) {
233933
+            if ((i + 1) != totthread) {
233933
                 arg->end = ((i + 1) * vol_per_thread_limit);
233933
             } else {
233933
-                arg->end = (start + endindex);
233933
+                arg->end = ((i * vol_per_thread_limit) + endindex);
233933
             }
233933
             th_ret = gf_thread_create_detached(
233933
                 &th_id, glusterd_add_bulk_volumes_create_thread, arg,
233933
-- 
233933
1.8.3.1
233933