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