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