summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGaurav Kumar Garg <ggarg@redhat.com>2015-06-10 15:11:39 +0530
committerAtin Mukherjee <amukherj@redhat.com>2015-06-16 05:20:51 -0700
commit63a2ea7148ca58b4d2f0160d9c5b9bcf047c8c9e (patch)
treee1f448690139878ad0088ddedd67296951fb1491
parent5dcf0170254e42811d756faa5cee610186300000 (diff)
glusterd: subvol_count value for replicate volume should be calculate correctly
glusterd was crashing while trying to remove bricks from replica set after shrinking nx3 replica to nx2 replica to nx1 replica. This is because volinfo->subvol_count is calculating value from old replica count value. Change-Id: I1084a71e29c9cfa1cd85bdb4e82b943b1dc44372 BUG: 1231646 Signed-off-by: Gaurav Kumar Garg <ggarg@redhat.com> Reviewed-on: http://review.gluster.org/11165 Reviewed-by: Atin Mukherjee <amukherj@redhat.com> Reviewed-by: Ravishankar N <ravishankar@redhat.com> Tested-by: Gluster Build System <jenkins@build.gluster.com> Tested-by: NetBSD Build System <jenkins@build.gluster.org> Reviewed-by: Krishnan Parthasarathi <kparthas@redhat.com> (cherry picked from commit 3fb18451311c34aeced1054472b6f81fc13dd679) Reviewed-on: http://review.gluster.org/11224
-rw-r--r--tests/bugs/glusterd/bug-1230121-replica_subvol_count_correct_cal.t52
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-brick-ops.c4
2 files changed, 54 insertions, 2 deletions
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
new file mode 100644
index 00000000000..71d98e18491
--- /dev/null
+++ b/tests/bugs/glusterd/bug-1230121-replica_subvol_count_correct_cal.t
@@ -0,0 +1,52 @@
+#!/bin/bash
+
+## Test case for BZ:1230121 glusterd crashed while trying to remove a bricks
+## one selected from each replica set - after shrinking nX3 to nX2 to nX1
+
+. $(dirname $0)/../../include.rc
+. $(dirname $0)/../../volume.rc
+. $(dirname $0)/../../cluster.rc
+
+cleanup;
+
+## Start a 2 node virtual cluster
+TEST launch_cluster 2;
+TEST pidof glusterd
+
+## Peer probe server 2 from server 1 cli
+TEST $CLI_1 peer probe $H2;
+
+EXPECT_WITHIN $PROBE_TIMEOUT 1 peer_count
+
+## Creating a 2x3 replicate volume
+TEST $CLI_1 volume create $V0 replica 3 $H1:$B1/brick1 $H2:$B2/brick2 \
+ $H1:$B1/brick3 $H2:$B2/brick4 \
+ $H1:$B1/brick5 $H2:$B2/brick6
+
+## Start the volume
+TEST $CLI_1 volume start $V0
+
+
+## Shrinking volume replica 2x3 to 2x2 by performing remove-brick operation.
+TEST $CLI_1 volume remove-brick $V0 replica 2 $H1:$B1/brick1 $H2:$B2/brick6 force
+
+## Shrinking volume replica 2x2 to 1x2 by performing remove-brick operation
+TEST $CLI_1 volume remove-brick $V0 replica 2 $H1:$B1/brick3 $H2:$B2/brick2 force
+
+## Shrinking volume replica from 1x2 to 1x1 by performing remove-brick operation
+TEST $CLI_1 volume remove-brick $V0 replica 1 $H1:$B1/brick5 force
+
+
+
+### Expanding volume replica by performing add-brick operation.
+
+## Expend volume replica from 1x1 to 1x2 by performing add-brick operation
+TEST $CLI_1 volume add-brick $V0 replica 2 $H1:$B1/brick5 force
+
+## Expend volume replica from 1x2 to 2x2 by performing add-brick operation
+TEST $CLI_1 volume add-brick $V0 replica 2 $H1:$B1/brick3 $H2:$B2/brick2 force
+
+## Expend volume replica from 2x2 to 2x3 by performing add-brick operation
+TEST $CLI_1 volume add-brick $V0 replica 3 $H1:$B1/brick1 $H2:$B2/brick6 force
+
+cleanup;
diff --git a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c
index 0af86f56854..b0cd2c1d890 100644
--- a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c
+++ b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c
@@ -2243,8 +2243,6 @@ glusterd_op_remove_brick (dict_t *dict, char **op_errstr)
if (start_remove)
volinfo->rebal.dict = dict_ref (bricks_dict);
- volinfo->subvol_count = (volinfo->brick_count /
- volinfo->dist_leaf_count);
ret = dict_get_int32 (dict, "replica-count", &replica_count);
if (!ret) {
gf_log (this->name, GF_LOG_INFO,
@@ -2273,6 +2271,8 @@ glusterd_op_remove_brick (dict_t *dict, char **op_errstr)
}
}
}
+ volinfo->subvol_count = (volinfo->brick_count /
+ volinfo->dist_leaf_count);
ret = glusterd_create_volfiles_and_notify_services (volinfo);
if (ret) {