cb8e9e
From 07694012378770a13146b721e3493bbc56301408 Mon Sep 17 00:00:00 2001
cb8e9e
From: Gaurav Kumar Garg <ggarg@redhat.com>
cb8e9e
Date: Wed, 10 Jun 2015 15:11:39 +0530
cb8e9e
Subject: [PATCH 075/101] glusterd: subvol_count value for replicate volume should be calculate correctly
cb8e9e
cb8e9e
glusterd was crashing while trying to remove bricks from replica set
cb8e9e
after shrinking nx3 replica to nx2 replica to nx1 replica.
cb8e9e
cb8e9e
This is because volinfo->subvol_count is calculating value from old
cb8e9e
replica count value.
cb8e9e
cb8e9e
BUG: 1230101
cb8e9e
Change-Id: Id5bc5363f2d2a6e337150d1e9c4c067d8cb5bf89
cb8e9e
Signed-off-by: Gaurav Kumar Garg <ggarg@redhat.com>
cb8e9e
upstream patch url: http://review.gluster.com/#/c/11165/
cb8e9e
Reviewed-on: https://code.engineering.redhat.com/gerrit/50731
cb8e9e
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
cb8e9e
Tested-by: Atin Mukherjee <amukherj@redhat.com>
cb8e9e
---
cb8e9e
 .../bug-1230121-replica_subvol_count_correct_cal.t |   52 ++++++++++++++++++++
cb8e9e
 xlators/mgmt/glusterd/src/glusterd-brick-ops.c     |    4 +-
cb8e9e
 2 files changed, 54 insertions(+), 2 deletions(-)
cb8e9e
 create mode 100644 tests/bugs/glusterd/bug-1230121-replica_subvol_count_correct_cal.t
cb8e9e
cb8e9e
diff --git a/tests/bugs/glusterd/bug-1230121-replica_subvol_count_correct_cal.t b/tests/bugs/glusterd/bug-1230121-replica_subvol_count_correct_cal.t
cb8e9e
new file mode 100644
cb8e9e
index 0000000..71d98e1
cb8e9e
--- /dev/null
cb8e9e
+++ b/tests/bugs/glusterd/bug-1230121-replica_subvol_count_correct_cal.t
cb8e9e
@@ -0,0 +1,52 @@
cb8e9e
+#!/bin/bash
cb8e9e
+
cb8e9e
+## Test case for BZ:1230121  glusterd crashed while trying to remove a bricks
cb8e9e
+## one selected from each replica set - after shrinking nX3 to nX2 to nX1
cb8e9e
+
cb8e9e
+. $(dirname $0)/../../include.rc
cb8e9e
+. $(dirname $0)/../../volume.rc
cb8e9e
+. $(dirname $0)/../../cluster.rc
cb8e9e
+
cb8e9e
+cleanup;
cb8e9e
+
cb8e9e
+## Start a 2 node virtual cluster
cb8e9e
+TEST launch_cluster 2;
cb8e9e
+TEST pidof glusterd
cb8e9e
+
cb8e9e
+## Peer probe server 2 from server 1 cli
cb8e9e
+TEST $CLI_1 peer probe $H2;
cb8e9e
+
cb8e9e
+EXPECT_WITHIN $PROBE_TIMEOUT 1 peer_count
cb8e9e
+
cb8e9e
+## Creating a 2x3 replicate volume
cb8e9e
+TEST $CLI_1 volume create $V0 replica 3 $H1:$B1/brick1 $H2:$B2/brick2 \
cb8e9e
+                                        $H1:$B1/brick3 $H2:$B2/brick4 \
cb8e9e
+                                        $H1:$B1/brick5 $H2:$B2/brick6
cb8e9e
+
cb8e9e
+## Start the volume
cb8e9e
+TEST $CLI_1 volume start $V0
cb8e9e
+
cb8e9e
+
cb8e9e
+## Shrinking volume replica 2x3 to 2x2 by performing remove-brick operation.
cb8e9e
+TEST $CLI_1 volume remove-brick $V0 replica 2 $H1:$B1/brick1 $H2:$B2/brick6 force
cb8e9e
+
cb8e9e
+## Shrinking volume replica 2x2 to 1x2 by performing remove-brick operation
cb8e9e
+TEST $CLI_1 volume remove-brick $V0 replica 2 $H1:$B1/brick3 $H2:$B2/brick2 force
cb8e9e
+
cb8e9e
+## Shrinking volume replica from 1x2 to 1x1 by performing remove-brick operation
cb8e9e
+TEST $CLI_1 volume remove-brick $V0 replica 1 $H1:$B1/brick5 force
cb8e9e
+
cb8e9e
+
cb8e9e
+
cb8e9e
+### Expanding volume replica by performing add-brick operation.
cb8e9e
+
cb8e9e
+## Expend volume replica from 1x1 to 1x2 by performing add-brick operation
cb8e9e
+TEST $CLI_1 volume add-brick $V0 replica 2 $H1:$B1/brick5 force
cb8e9e
+
cb8e9e
+## Expend volume replica from 1x2 to 2x2 by performing add-brick operation
cb8e9e
+TEST $CLI_1 volume add-brick $V0 replica 2 $H1:$B1/brick3 $H2:$B2/brick2 force
cb8e9e
+
cb8e9e
+## Expend volume replica from 2x2 to 2x3 by performing add-brick operation
cb8e9e
+TEST $CLI_1 volume add-brick $V0 replica 3 $H1:$B1/brick1 $H2:$B2/brick6 force
cb8e9e
+
cb8e9e
+cleanup;
cb8e9e
diff --git a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c
cb8e9e
index 49bd887..b4bef6e 100644
cb8e9e
--- a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c
cb8e9e
+++ b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c
cb8e9e
@@ -2244,8 +2244,6 @@ glusterd_op_remove_brick (dict_t *dict, char **op_errstr)
cb8e9e
         if (start_remove)
cb8e9e
                 volinfo->rebal.dict = dict_ref (bricks_dict);
cb8e9e
 
cb8e9e
-        volinfo->subvol_count = (volinfo->brick_count /
cb8e9e
-                                 volinfo->dist_leaf_count);
cb8e9e
         ret = dict_get_int32 (dict, "replica-count", &replica_count);
cb8e9e
         if (!ret) {
cb8e9e
                 gf_log (this->name, GF_LOG_INFO,
cb8e9e
@@ -2274,6 +2272,8 @@ glusterd_op_remove_brick (dict_t *dict, char **op_errstr)
cb8e9e
                         }
cb8e9e
                 }
cb8e9e
         }
cb8e9e
+        volinfo->subvol_count = (volinfo->brick_count /
cb8e9e
+                                 volinfo->dist_leaf_count);
cb8e9e
 
cb8e9e
         ret = glusterd_create_volfiles_and_notify_services (volinfo);
cb8e9e
         if (ret) {
cb8e9e
-- 
cb8e9e
1.7.1
cb8e9e