cb8e9e
From 3eccc2118df5add1ff319b3c0568c114f8e0172d Mon Sep 17 00:00:00 2001
cb8e9e
From: Anuradha Talur <atalur@redhat.com>
cb8e9e
Date: Mon, 13 Jul 2015 23:34:17 +0530
cb8e9e
Subject: [PATCH 238/244] glusterd: Fix failure in replace-brick when src-brick is offline
cb8e9e
cb8e9e
        Backport of: http://review.gluster.org/#/c/11656/
cb8e9e
cb8e9e
Change-Id: I0fdb58e15da15c40c3fc9767f2fe4df0ea9d2350
cb8e9e
BUG: 1242543
cb8e9e
Reviewed-on: http://review.gluster.org/11651
cb8e9e
Tested-by: NetBSD Build System <jenkins@build.gluster.org>
cb8e9e
Tested-by: Gluster Build System <jenkins@build.gluster.com>
cb8e9e
Reviewed-by: Krishnan Parthasarathi <kparthas@redhat.com>
cb8e9e
Signed-off-by: Anuradha Talur <atalur@redhat.com>
cb8e9e
Reviewed-on: https://code.engineering.redhat.com/gerrit/52938
cb8e9e
Tested-by: Krishnan Parthasarathi <kparthas@redhat.com>
cb8e9e
---
cb8e9e
 tests/bugs/glusterd/bug-1242543-replace-brick.t    |   25 +++++++
cb8e9e
 xlators/mgmt/glusterd/src/glusterd-replace-brick.c |   75 --------------------
cb8e9e
 2 files changed, 25 insertions(+), 75 deletions(-)
cb8e9e
 create mode 100644 tests/bugs/glusterd/bug-1242543-replace-brick.t
cb8e9e
cb8e9e
diff --git a/tests/bugs/glusterd/bug-1242543-replace-brick.t b/tests/bugs/glusterd/bug-1242543-replace-brick.t
cb8e9e
new file mode 100644
cb8e9e
index 0000000..0b1087f
cb8e9e
--- /dev/null
cb8e9e
+++ b/tests/bugs/glusterd/bug-1242543-replace-brick.t
cb8e9e
@@ -0,0 +1,25 @@
cb8e9e
+#!/bin/bash
cb8e9e
+. $(dirname $0)/../../include.rc
cb8e9e
+. $(dirname $0)/../../volume.rc
cb8e9e
+cleanup;
cb8e9e
+
cb8e9e
+TEST glusterd
cb8e9e
+TEST pidof glusterd
cb8e9e
+TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}{0,1}
cb8e9e
+TEST $CLI volume start $V0
cb8e9e
+
cb8e9e
+TEST glusterfs --volfile-id=$V0 --volfile-server=$H0 $M0;
cb8e9e
+
cb8e9e
+# Replace brick1 without killing the brick
cb8e9e
+TEST $CLI volume replace-brick $V0 $H0:$B0/${V0}1 $H0:$B0/${V0}1_new commit force
cb8e9e
+
cb8e9e
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" afr_child_up_status $V0 1
cb8e9e
+
cb8e9e
+TEST kill_brick $V0 $H0 $B0/${V0}1_new
cb8e9e
+
cb8e9e
+# Replace brick1 after killing the brick
cb8e9e
+TEST $CLI volume replace-brick $V0 $H0:$B0/${V0}1_new $H0:$B0/${V0}1_newer commit force
cb8e9e
+
cb8e9e
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" afr_child_up_status $V0 1
cb8e9e
+
cb8e9e
+cleanup;
cb8e9e
diff --git a/xlators/mgmt/glusterd/src/glusterd-replace-brick.c b/xlators/mgmt/glusterd/src/glusterd-replace-brick.c
cb8e9e
index a6120c8..8325508 100644
cb8e9e
--- a/xlators/mgmt/glusterd/src/glusterd-replace-brick.c
cb8e9e
+++ b/xlators/mgmt/glusterd/src/glusterd-replace-brick.c
cb8e9e
@@ -550,76 +550,6 @@ rb_kill_destination_brick (glusterd_volinfo_t *volinfo,
cb8e9e
         return glusterd_service_stop ("brick", pidfile, SIGTERM, _gf_true);
cb8e9e
 }
cb8e9e
 
cb8e9e
-/* Set src-brick's port number to be used in the maintenance mount
cb8e9e
- * after all commit acks are received.
cb8e9e
- */
cb8e9e
-static int
cb8e9e
-rb_update_srcbrick_port (glusterd_volinfo_t *volinfo,
cb8e9e
-                         glusterd_brickinfo_t *src_brickinfo,
cb8e9e
-                         dict_t *rsp_dict, dict_t *req_dict, char *replace_op)
cb8e9e
-{
cb8e9e
-        xlator_t *this                  = NULL;
cb8e9e
-        int       ret                   = 0;
cb8e9e
-        int       dict_ret              = 0;
cb8e9e
-        int       src_port              = 0;
cb8e9e
-        char      brickname[PATH_MAX]   = {0,};
cb8e9e
-
cb8e9e
-        this = THIS;
cb8e9e
-        GF_ASSERT (this);
cb8e9e
-
cb8e9e
-        dict_ret = dict_get_int32 (req_dict, "src-brick-port", &src_port);
cb8e9e
-        if (src_port)
cb8e9e
-                src_brickinfo->port = src_port;
cb8e9e
-
cb8e9e
-        if (gf_is_local_addr (src_brickinfo->hostname)) {
cb8e9e
-                gf_msg (this->name, GF_LOG_INFO, 0,
cb8e9e
-                        GD_MSG_BRK_PORT_NO_ADD_INDO,
cb8e9e
-                        "adding src-brick port no");
cb8e9e
-
cb8e9e
-                if (volinfo->transport_type == GF_TRANSPORT_RDMA) {
cb8e9e
-                        snprintf (brickname, sizeof(brickname), "%s.rdma",
cb8e9e
-                                  src_brickinfo->path);
cb8e9e
-                } else
cb8e9e
-                        snprintf (brickname, sizeof(brickname), "%s",
cb8e9e
-                                  src_brickinfo->path);
cb8e9e
-
cb8e9e
-                src_brickinfo->port = pmap_registry_search (this,
cb8e9e
-                                      brickname, GF_PMAP_PORT_BRICKSERVER);
cb8e9e
-                if (!src_brickinfo->port) {
cb8e9e
-                        gf_msg (this->name, GF_LOG_ERROR, 0,
cb8e9e
-                                GD_MSG_SRC_BRICK_PORT_UNAVAIL,
cb8e9e
-                                "Src brick port not available");
cb8e9e
-                        ret = -1;
cb8e9e
-                        goto out;
cb8e9e
-                }
cb8e9e
-
cb8e9e
-                if (rsp_dict) {
cb8e9e
-                        ret = dict_set_int32 (rsp_dict, "src-brick-port",
cb8e9e
-                                              src_brickinfo->port);
cb8e9e
-                        if (ret) {
cb8e9e
-                                gf_msg_debug (this->name, 0,
cb8e9e
-                                        "Could not set src-brick port no");
cb8e9e
-                                goto out;
cb8e9e
-                        }
cb8e9e
-                }
cb8e9e
-
cb8e9e
-                if (req_dict) {
cb8e9e
-                        ret = dict_set_int32 (req_dict, "src-brick-port",
cb8e9e
-                                              src_brickinfo->port);
cb8e9e
-                        if (ret) {
cb8e9e
-                                gf_msg_debug (this->name, 0,
cb8e9e
-                                        "Could not set src-brick port no");
cb8e9e
-                                goto out;
cb8e9e
-                        }
cb8e9e
-                }
cb8e9e
-
cb8e9e
-        }
cb8e9e
-
cb8e9e
-out:
cb8e9e
-        return ret;
cb8e9e
-
cb8e9e
-}
cb8e9e
-
cb8e9e
 static int
cb8e9e
 rb_update_dstbrick_port (glusterd_brickinfo_t *dst_brickinfo, dict_t *rsp_dict,
cb8e9e
                          dict_t *req_dict, char *replace_op)
cb8e9e
@@ -834,11 +764,6 @@ glusterd_op_replace_brick (dict_t *dict, dict_t *rsp_dict)
cb8e9e
                 goto out;
cb8e9e
         }
cb8e9e
 
cb8e9e
-        ret = rb_update_srcbrick_port (volinfo, src_brickinfo, rsp_dict,
cb8e9e
-                                       dict, replace_op);
cb8e9e
-        if (ret)
cb8e9e
-                goto out;
cb8e9e
-
cb8e9e
         ret = rb_update_dstbrick_port (dst_brickinfo, rsp_dict,
cb8e9e
                                        dict, replace_op);
cb8e9e
         if (ret)
cb8e9e
-- 
cb8e9e
1.7.1
cb8e9e