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