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