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