21ab4e
From 35dc7423a0e11dfc7ead2c87007601fe757a1ca1 Mon Sep 17 00:00:00 2001
21ab4e
From: Samikshan Bairagya <samikshan@gmail.com>
21ab4e
Date: Mon, 15 May 2017 12:19:02 +0530
21ab4e
Subject: [PATCH 430/473] glusterd: Make reset-brick work correctly if
21ab4e
 brick-mux is on
21ab4e
21ab4e
Reset brick currently kills of the corresponding brick process.
21ab4e
However, with brick multiplexing enabled, stopping the brick
21ab4e
process would render all bricks attached to it unavailable. To
21ab4e
handle this correctly, we need to make sure that the brick process
21ab4e
is terminated only if brick-multiplexing is disabled. Otherwise,
21ab4e
we should send the GLUSTERD_BRICK_TERMINATE rpc to the respective
21ab4e
brick process to detach the brick that is to be reset.
21ab4e
21ab4e
> Reviewed-on: https://review.gluster.org/17128
21ab4e
> Smoke: Gluster Build System <jenkins@build.gluster.org>
21ab4e
> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
21ab4e
> CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
21ab4e
> Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
21ab4e
21ab4e
Change-Id: I69002d66ffe6ec36ef48af09b66c522c6d35ac58
21ab4e
BUG: 1443843
21ab4e
Signed-off-by: Samikshan Bairagya <sbairagy@redhat.com>
21ab4e
Reviewed-on: https://code.engineering.redhat.com/gerrit/106048
21ab4e
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
21ab4e
---
21ab4e
 cli/src/cli-cmd-volume.c                           | 10 +++
21ab4e
 cli/src/cli.c                                      |  5 ++
21ab4e
 cli/src/cli.h                                      |  9 +--
21ab4e
 .../glusterd/bug-1446172-brick-mux-reset-brick.t   | 79 +++++++++++++++++++++
21ab4e
 tests/include.rc                                   |  7 +-
21ab4e
 xlators/mgmt/glusterd/src/glusterd-brick-ops.c     |  3 +-
21ab4e
 xlators/mgmt/glusterd/src/glusterd-messages.h      | 13 +++-
21ab4e
 xlators/mgmt/glusterd/src/glusterd-op-sm.c         | 14 ----
21ab4e
 xlators/mgmt/glusterd/src/glusterd-replace-brick.c |  3 +-
21ab4e
 xlators/mgmt/glusterd/src/glusterd-reset-brick.c   | 82 +++++++++-------------
21ab4e
 xlators/mgmt/glusterd/src/glusterd-snapshot.c      |  2 -
21ab4e
 xlators/mgmt/glusterd/src/glusterd-utils.c         | 44 +++++++++---
21ab4e
 xlators/mgmt/glusterd/src/glusterd-utils.h         | 12 +++-
21ab4e
 xlators/mgmt/glusterd/src/glusterd-volume-ops.c    |  2 +-
21ab4e
 14 files changed, 197 insertions(+), 88 deletions(-)
21ab4e
 create mode 100644 tests/bugs/glusterd/bug-1446172-brick-mux-reset-brick.t
21ab4e
21ab4e
diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c
21ab4e
index 6737ffd..86d6b4b 100644
21ab4e
--- a/cli/src/cli-cmd-volume.c
21ab4e
+++ b/cli/src/cli-cmd-volume.c
21ab4e
@@ -2092,6 +2092,7 @@ cli_cmd_volume_reset_brick_cbk (struct cli_state *state,
21ab4e
         if (!frame)
21ab4e
                 goto out;
21ab4e
 
21ab4e
+
21ab4e
         ret = cli_cmd_volume_reset_brick_parse (words, wordcount, &options);
21ab4e
 
21ab4e
         if (ret) {
21ab4e
@@ -2100,6 +2101,15 @@ cli_cmd_volume_reset_brick_cbk (struct cli_state *state,
21ab4e
                 goto out;
21ab4e
         }
21ab4e
 
21ab4e
+        if (state->mode & GLUSTER_MODE_WIGNORE_PARTITION) {
21ab4e
+                ret = dict_set_int32 (options, "ignore-partition", _gf_true);
21ab4e
+                if (ret) {
21ab4e
+                        gf_log ("cli", GF_LOG_ERROR, "Failed to set ignore-"
21ab4e
+                                "partition option");
21ab4e
+                        goto out;
21ab4e
+                }
21ab4e
+        }
21ab4e
+
21ab4e
         CLI_LOCAL_INIT (local, words, frame, options);
21ab4e
 
21ab4e
         if (proc->fn) {
21ab4e
diff --git a/cli/src/cli.c b/cli/src/cli.c
21ab4e
index add10d2..e0d6b3e 100644
21ab4e
--- a/cli/src/cli.c
21ab4e
+++ b/cli/src/cli.c
21ab4e
@@ -351,6 +351,11 @@ cli_opt_parse (char *opt, struct cli_state *state)
21ab4e
                 return 0;
21ab4e
         }
21ab4e
 
21ab4e
+        if (strcmp (opt, "wignore-partition") == 0) {
21ab4e
+                state->mode |= GLUSTER_MODE_WIGNORE_PARTITION;
21ab4e
+                return 0;
21ab4e
+        }
21ab4e
+
21ab4e
         if (strcmp (opt, "wignore") == 0) {
21ab4e
                 state->mode |= GLUSTER_MODE_WIGNORE;
21ab4e
                 return 0;
21ab4e
diff --git a/cli/src/cli.h b/cli/src/cli.h
21ab4e
index d61d170..d271a8d 100644
21ab4e
--- a/cli/src/cli.h
21ab4e
+++ b/cli/src/cli.h
21ab4e
@@ -56,10 +56,11 @@ typedef enum {
21ab4e
         MAX
21ab4e
 } values;
21ab4e
 
21ab4e
-#define GLUSTER_MODE_SCRIPT    (1 << 0)
21ab4e
-#define GLUSTER_MODE_ERR_FATAL (1 << 1)
21ab4e
-#define GLUSTER_MODE_XML       (1 << 2)
21ab4e
-#define GLUSTER_MODE_WIGNORE   (1 << 3)
21ab4e
+#define GLUSTER_MODE_SCRIPT             (1 << 0)
21ab4e
+#define GLUSTER_MODE_ERR_FATAL          (1 << 1)
21ab4e
+#define GLUSTER_MODE_XML                (1 << 2)
21ab4e
+#define GLUSTER_MODE_WIGNORE            (1 << 3)
21ab4e
+#define GLUSTER_MODE_WIGNORE_PARTITION  (1 << 4)
21ab4e
 
21ab4e
 
21ab4e
 #define GLUSTERD_GET_QUOTA_LIST_MOUNT_PATH(abspath, volname, path) do {       \
21ab4e
diff --git a/tests/bugs/glusterd/bug-1446172-brick-mux-reset-brick.t b/tests/bugs/glusterd/bug-1446172-brick-mux-reset-brick.t
21ab4e
new file mode 100644
21ab4e
index 0000000..e6aaaa4
21ab4e
--- /dev/null
21ab4e
+++ b/tests/bugs/glusterd/bug-1446172-brick-mux-reset-brick.t
21ab4e
@@ -0,0 +1,79 @@
21ab4e
+#!/bin/bash
21ab4e
+
21ab4e
+. $(dirname $0)/../../include.rc
21ab4e
+. $(dirname $0)/../../traps.rc
21ab4e
+. $(dirname $0)/../../volume.rc
21ab4e
+
21ab4e
+cleanup;
21ab4e
+
21ab4e
+function count_up_bricks {
21ab4e
+        $CLI --xml volume status | grep '<status>1' | wc -l
21ab4e
+}
21ab4e
+
21ab4e
+function count_brick_processes {
21ab4e
+	pgrep glusterfsd | wc -l
21ab4e
+}
21ab4e
+
21ab4e
+TEST glusterd
21ab4e
+
21ab4e
+TEST $CLI volume set all cluster.brick-multiplex on
21ab4e
+push_trapfunc "$CLI volume set all cluster.brick-multiplex off"
21ab4e
+push_trapfunc "cleanup"
21ab4e
+
21ab4e
+TEST $CLI volume create $V0 $H0:$B0/${V0}{0,1}
21ab4e
+TEST $CLI volume create $V1 $H0:$B0/${V1}{0,1}
21ab4e
+
21ab4e
+TEST $CLI volume start $V0
21ab4e
+TEST $CLI volume start $V1
21ab4e
+
21ab4e
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT 4 count_up_bricks
21ab4e
+EXPECT 1 count_brick_processes
21ab4e
+
21ab4e
+TEST glusterfs --volfile-id=$V0 --volfile-server=$H0 $M0;
21ab4e
+# Create files
21ab4e
+for i in {1..5}
21ab4e
+do
21ab4e
+        echo $i > $M0/file$i.txt
21ab4e
+done
21ab4e
+
21ab4e
+TEST $CLI volume reset-brick $V0 $H0:$B0/${V0}1 start
21ab4e
+
21ab4e
+EXPECT_WITHIN $PROCESS_DOWN_TIMEOUT 3 count_up_bricks
21ab4e
+EXPECT 1 count_brick_processes
21ab4e
+
21ab4e
+# Negative case with brick killed but volume-id xattr present
21ab4e
+TEST ! $CLI volume reset-brick $V0 $H0:$B0/${V0}1 $H0:$B0/${V0}1 commit
21ab4e
+
21ab4e
+# reset-brick commit force should work and should bring up the brick
21ab4e
+TEST $CLI volume reset-brick $V0 $H0:$B0/${V0}1 $H0:$B0/${V0}1 commit force
21ab4e
+
21ab4e
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT 4 count_up_bricks
21ab4e
+EXPECT 1 count_brick_processes
21ab4e
+
21ab4e
+TEST glusterfs --volfile-id=$V1 --volfile-server=$H0 $M1;
21ab4e
+# Create files
21ab4e
+for i in {1..5}
21ab4e
+do
21ab4e
+        echo $i > $M1/file$i.txt
21ab4e
+done
21ab4e
+
21ab4e
+TEST $CLI volume reset-brick $V1 $H0:$B0/${V1}1 start
21ab4e
+
21ab4e
+EXPECT_WITHIN $PROCESS_DOWN_TIMEOUT 3 count_up_bricks
21ab4e
+EXPECT 1 count_brick_processes
21ab4e
+
21ab4e
+# Simulate reset disk
21ab4e
+for i in {1..5}
21ab4e
+do
21ab4e
+        rm -rf $B0/${V1}1/file$i.txt
21ab4e
+done
21ab4e
+
21ab4e
+setfattr -x trusted.glusterfs.volume-id $B0/${V1}1
21ab4e
+setfattr -x trusted.gfid $B0/${V1}1
21ab4e
+
21ab4e
+# Test reset-brick commit. Using CLI_IGNORE_PARTITION since normal CLI  uses
21ab4e
+# the --wignore flag that essentially makes the command act like "commit force"
21ab4e
+TEST $CLI_IGNORE_PARTITION volume reset-brick $V1 $H0:$B0/${V1}1 $H0:$B0/${V1}1 commit
21ab4e
+
21ab4e
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT 4 count_up_bricks
21ab4e
+EXPECT 1 count_brick_processes
21ab4e
diff --git a/tests/include.rc b/tests/include.rc
21ab4e
index a87171c..ce2085f 100644
21ab4e
--- a/tests/include.rc
21ab4e
+++ b/tests/include.rc
21ab4e
@@ -84,7 +84,12 @@ LOGDIR=$(gluster --print-logdir)
21ab4e
 statedumpdir=`gluster --print-statedumpdir`; # Default directory for statedump
21ab4e
 
21ab4e
 CLI="gluster --mode=script --wignore";
21ab4e
-CLI_NO_FORCE="gluster --mode-script";
21ab4e
+CLI_NO_FORCE="gluster --mode=script";
21ab4e
+
21ab4e
+# CLI_IGNORE_PARTITION makes sure that the warning related to bricks being on
21ab4e
+# root partition is ignored while running the command in a "no force" mode
21ab4e
+CLI_IGNORE_PARTITION="gluster --mode=script --wignore-partition"
21ab4e
+
21ab4e
 _GFS () {
21ab4e
 	glusterfs "$@"
21ab4e
 	local mount_ret=$?
21ab4e
diff --git a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c
21ab4e
index 04add60..f4cd927 100644
21ab4e
--- a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c
21ab4e
+++ b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c
21ab4e
@@ -1873,7 +1873,8 @@ glusterd_op_stage_add_brick (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
21ab4e
 
21ab4e
                         ret = glusterd_validate_and_create_brickpath (brickinfo,
21ab4e
                                                           volinfo->volume_id,
21ab4e
-                                                          op_errstr, is_force);
21ab4e
+                                                          op_errstr, is_force,
21ab4e
+                                                          _gf_false);
21ab4e
                         if (ret)
21ab4e
                                 goto out;
21ab4e
 
21ab4e
diff --git a/xlators/mgmt/glusterd/src/glusterd-messages.h b/xlators/mgmt/glusterd/src/glusterd-messages.h
21ab4e
index a093d33..3d0f48c 100644
21ab4e
--- a/xlators/mgmt/glusterd/src/glusterd-messages.h
21ab4e
+++ b/xlators/mgmt/glusterd/src/glusterd-messages.h
21ab4e
@@ -41,7 +41,7 @@
21ab4e
 
21ab4e
 #define GLUSTERD_COMP_BASE      GLFS_MSGID_GLUSTERD
21ab4e
 
21ab4e
-#define GLFS_NUM_MESSAGES       598
21ab4e
+#define GLFS_NUM_MESSAGES       601
21ab4e
 
21ab4e
 #define GLFS_MSGID_END          (GLUSTERD_COMP_BASE + GLFS_NUM_MESSAGES + 1)
21ab4e
 /* Messaged with message IDs */
21ab4e
@@ -4799,6 +4799,17 @@
21ab4e
  * @recommendedaction
21ab4e
  *
21ab4e
  */
21ab4e
+#define GD_MSG_GNFS_XLATOR_NOT_INSTALLED           (GLUSTERD_COMP_BASE + 600)
21ab4e
+
21ab4e
+/*!
21ab4e
+ * @messageid
21ab4e
+ * @diagnosis
21ab4e
+ * @recommendedaction
21ab4e
+ *
21ab4e
+ */
21ab4e
+#define GD_MSG_PIDFILE_UNLINKING                   (GLUSTERD_COMP_BASE + 601)
21ab4e
+
21ab4e
+/*------------*/
21ab4e
 
21ab4e
 #define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages"
21ab4e
 #endif /* !_GLUSTERD_MESSAGES_H_ */
21ab4e
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
21ab4e
index 015f79c..8ebece6 100644
21ab4e
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
21ab4e
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
21ab4e
@@ -6176,8 +6176,6 @@ glusterd_bricks_select_stop_volume (dict_t *dict, char **op_errstr,
21ab4e
         glusterd_volinfo_t                      *volinfo = NULL;
21ab4e
         glusterd_brickinfo_t                    *brickinfo = NULL;
21ab4e
         glusterd_pending_node_t                 *pending_node = NULL;
21ab4e
-        glusterd_conf_t                         *conf = THIS->private;
21ab4e
-        char                                    pidfile[PATH_MAX] = {0,};
21ab4e
 
21ab4e
         ret = glusterd_op_stop_volume_args_get (dict, &volname, &flags);
21ab4e
         if (ret)
21ab4e
@@ -6213,11 +6211,6 @@ glusterd_bricks_select_stop_volume (dict_t *dict, char **op_errstr,
21ab4e
                          */
21ab4e
                         brickinfo->status = GF_BRICK_STOPPED;
21ab4e
                         brickinfo->started_here = _gf_false;
21ab4e
-                        GLUSTERD_GET_BRICK_PIDFILE (pidfile, volinfo,
21ab4e
-                                                    brickinfo, conf);
21ab4e
-                        gf_log (THIS->name, GF_LOG_INFO,
21ab4e
-                                "unlinking pidfile %s", pidfile);
21ab4e
-                        (void) sys_unlink (pidfile);
21ab4e
                 }
21ab4e
         }
21ab4e
 
21ab4e
@@ -6240,8 +6233,6 @@ glusterd_bricks_select_remove_brick (dict_t *dict, char **op_errstr,
21ab4e
         glusterd_pending_node_t                 *pending_node = NULL;
21ab4e
         int32_t                                 command = 0;
21ab4e
         int32_t                                 force = 0;
21ab4e
-        glusterd_conf_t                         *conf = THIS->private;
21ab4e
-        char                                    pidfile[PATH_MAX] = {0,};
21ab4e
 
21ab4e
         ret = dict_get_str (dict, "volname", &volname);
21ab4e
 
21ab4e
@@ -6321,11 +6312,6 @@ glusterd_bricks_select_remove_brick (dict_t *dict, char **op_errstr,
21ab4e
                          */
21ab4e
                         brickinfo->status = GF_BRICK_STOPPED;
21ab4e
                         brickinfo->started_here = _gf_false;
21ab4e
-                        GLUSTERD_GET_BRICK_PIDFILE (pidfile, volinfo,
21ab4e
-                                                    brickinfo, conf);
21ab4e
-                        gf_log (THIS->name, GF_LOG_INFO,
21ab4e
-                                "unlinking pidfile %s", pidfile);
21ab4e
-                        (void) sys_unlink (pidfile);
21ab4e
                 }
21ab4e
                 i++;
21ab4e
         }
21ab4e
diff --git a/xlators/mgmt/glusterd/src/glusterd-replace-brick.c b/xlators/mgmt/glusterd/src/glusterd-replace-brick.c
21ab4e
index f658790..1b9b828 100644
21ab4e
--- a/xlators/mgmt/glusterd/src/glusterd-replace-brick.c
21ab4e
+++ b/xlators/mgmt/glusterd/src/glusterd-replace-brick.c
21ab4e
@@ -259,7 +259,8 @@ glusterd_op_stage_replace_brick (dict_t *dict, char **op_errstr,
21ab4e
         if (gf_is_local_addr (host)) {
21ab4e
                 ret = glusterd_validate_and_create_brickpath (dst_brickinfo,
21ab4e
                                                   volinfo->volume_id,
21ab4e
-                                                  op_errstr, is_force);
21ab4e
+                                                  op_errstr, is_force,
21ab4e
+                                                  _gf_false);
21ab4e
                 if (ret)
21ab4e
                         goto out;
21ab4e
         }
21ab4e
diff --git a/xlators/mgmt/glusterd/src/glusterd-reset-brick.c b/xlators/mgmt/glusterd/src/glusterd-reset-brick.c
21ab4e
index d1efe06..a187d1d 100644
21ab4e
--- a/xlators/mgmt/glusterd/src/glusterd-reset-brick.c
21ab4e
+++ b/xlators/mgmt/glusterd/src/glusterd-reset-brick.c
21ab4e
@@ -51,7 +51,7 @@ glusterd_reset_brick_prevalidate (dict_t *dict, char **op_errstr,
21ab4e
         char                                    *task_id_str        = NULL;
21ab4e
         xlator_t                                *this               = NULL;
21ab4e
         gf_boolean_t                             is_force           = _gf_false;
21ab4e
-        gsync_status_param_t                     param              = {0,};
21ab4e
+        int32_t                                  ignore_partition   = 0;
21ab4e
         pid_t                                    pid                = -1;
21ab4e
         uuid_t                                   volume_id          = {0,};
21ab4e
         char                                    *dup_dstbrick       = NULL;
21ab4e
@@ -158,11 +158,14 @@ glusterd_reset_brick_prevalidate (dict_t *dict, char **op_errstr,
21ab4e
         volinfo->rep_brick.src_brick = src_brickinfo;
21ab4e
         volinfo->rep_brick.dst_brick = dst_brickinfo;
21ab4e
 
21ab4e
+        ret = dict_get_int32 (dict, "ignore-partition", &ignore_partition);
21ab4e
+        ret = 0;
21ab4e
         if (gf_is_local_addr (host)) {
21ab4e
                 ret = glusterd_validate_and_create_brickpath
21ab4e
                                                   (dst_brickinfo,
21ab4e
                                                   volinfo->volume_id,
21ab4e
-                                                  op_errstr, is_force);
21ab4e
+                                                  op_errstr, is_force,
21ab4e
+                                                  ignore_partition);
21ab4e
                 if (ret)
21ab4e
                         goto out;
21ab4e
         } else {
21ab4e
@@ -239,19 +242,16 @@ out:
21ab4e
 int
21ab4e
 glusterd_op_reset_brick (dict_t *dict, dict_t *rsp_dict)
21ab4e
 {
21ab4e
-        int                                      ret           = 0;
21ab4e
-        dict_t                                  *ctx           = NULL;
21ab4e
-        char                                    *op            = NULL;
21ab4e
-        glusterd_volinfo_t                      *volinfo       = NULL;
21ab4e
-        char                                    *volname       = NULL;
21ab4e
-        xlator_t                                *this          = NULL;
21ab4e
-        glusterd_conf_t                         *priv          = NULL;
21ab4e
-        char                                    *src_brick     = NULL;
21ab4e
-        char                                    *dst_brick     = NULL;
21ab4e
-        glusterd_brickinfo_t                    *src_brickinfo = NULL;
21ab4e
-        glusterd_brickinfo_t                    *dst_brickinfo = NULL;
21ab4e
-        char                                    *task_id_str   = NULL;
21ab4e
-        char                                    pidfile[PATH_MAX] = {0,};
21ab4e
+        int                              ret           = 0;
21ab4e
+        char                            *op            = NULL;
21ab4e
+        glusterd_volinfo_t              *volinfo       = NULL;
21ab4e
+        char                            *volname       = NULL;
21ab4e
+        xlator_t                        *this          = NULL;
21ab4e
+        glusterd_conf_t                 *priv          = NULL;
21ab4e
+        char                            *src_brick     = NULL;
21ab4e
+        char                            *dst_brick     = NULL;
21ab4e
+        glusterd_brickinfo_t            *src_brickinfo = NULL;
21ab4e
+        glusterd_brickinfo_t            *dst_brickinfo = NULL;
21ab4e
 
21ab4e
         this = THIS;
21ab4e
         GF_ASSERT (this);
21ab4e
@@ -296,26 +296,18 @@ glusterd_op_reset_brick (dict_t *dict, dict_t *rsp_dict)
21ab4e
         }
21ab4e
 
21ab4e
         if (!strcmp (op, "GF_RESET_OP_START")) {
21ab4e
-                (void) glusterd_brick_disconnect (src_brickinfo);
21ab4e
-                GLUSTERD_GET_BRICK_PIDFILE (pidfile, volinfo,
21ab4e
-                                            src_brickinfo, priv);
21ab4e
-                ret = glusterd_service_stop ("brick", pidfile,
21ab4e
-                                             SIGTERM, _gf_false);
21ab4e
-                if (ret == 0) {
21ab4e
-                        glusterd_set_brick_status (src_brickinfo,
21ab4e
-                                                GF_BRICK_STOPPED);
21ab4e
-                        (void) glusterd_brick_unlink_socket_file
21ab4e
-                                        (volinfo, src_brickinfo);
21ab4e
-                        gf_msg (this->name, GF_LOG_INFO, 0,
21ab4e
-                        GD_MSG_BRICK_CLEANUP_SUCCESS,
21ab4e
-                        "Brick cleanup successful.");
21ab4e
-                } else {
21ab4e
+                ret = glusterd_volume_stop_glusterfs (volinfo,
21ab4e
+                                                      src_brickinfo,
21ab4e
+                                                      _gf_false);
21ab4e
+                if (ret) {
21ab4e
                         gf_msg (this->name, GF_LOG_CRITICAL, 0,
21ab4e
-                                GD_MSG_BRK_CLEANUP_FAIL,
21ab4e
-                                "Unable to cleanup src brick");
21ab4e
-                        goto out;
21ab4e
+                                GD_MSG_BRICK_STOP_FAIL, "Unable to stop"
21ab4e
+                                " brick: %s:%s", src_brickinfo->hostname,
21ab4e
+                                src_brickinfo->path);
21ab4e
                 }
21ab4e
+
21ab4e
                 goto out;
21ab4e
+
21ab4e
         } else if (!strcmp (op, "GF_RESET_OP_COMMIT") ||
21ab4e
                    !strcmp (op, "GF_RESET_OP_COMMIT_FORCE")) {
21ab4e
                 ret = dict_get_str (dict, "dst-brick", &dst_brick);
21ab4e
@@ -351,25 +343,17 @@ glusterd_op_reset_brick (dict_t *dict, dict_t *rsp_dict)
21ab4e
                 if (ret)
21ab4e
                         goto out;
21ab4e
 
21ab4e
-                if (gf_is_local_addr (dst_brickinfo->hostname)) {
21ab4e
+                if (gf_uuid_compare (dst_brickinfo->uuid, MY_UUID)) {
21ab4e
                         gf_msg_debug (this->name, 0, "I AM THE DESTINATION HOST");
21ab4e
-                        (void) glusterd_brick_disconnect (src_brickinfo);
21ab4e
-                        GLUSTERD_GET_BRICK_PIDFILE (pidfile, volinfo,
21ab4e
-                                                    src_brickinfo, priv);
21ab4e
-                        ret = glusterd_service_stop ("brick", pidfile,
21ab4e
-                                                     SIGTERM, _gf_false);
21ab4e
-                        if (ret == 0) {
21ab4e
-                                glusterd_set_brick_status
21ab4e
-                                        (src_brickinfo, GF_BRICK_STOPPED);
21ab4e
-                                (void) glusterd_brick_unlink_socket_file
21ab4e
-                                                (volinfo, src_brickinfo);
21ab4e
-                                gf_msg (this->name, GF_LOG_INFO, 0,
21ab4e
-                                GD_MSG_BRICK_CLEANUP_SUCCESS,
21ab4e
-                                "Brick cleanup successful.");
21ab4e
-                        } else {
21ab4e
+                        ret = glusterd_volume_stop_glusterfs (volinfo,
21ab4e
+                                                              src_brickinfo,
21ab4e
+                                                              _gf_true);
21ab4e
+                        if (ret) {
21ab4e
                                 gf_msg (this->name, GF_LOG_CRITICAL, 0,
21ab4e
-                                        GD_MSG_BRK_CLEANUP_FAIL,
21ab4e
-                                        "Unable to cleanup src brick");
21ab4e
+                                        GD_MSG_BRICK_STOP_FAIL,
21ab4e
+                                        "Unable to stop brick: %s:%s",
21ab4e
+                                        src_brickinfo->hostname,
21ab4e
+                                        src_brickinfo->path);
21ab4e
                                 goto out;
21ab4e
                         }
21ab4e
                 }
21ab4e
diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot.c b/xlators/mgmt/glusterd/src/glusterd-snapshot.c
21ab4e
index d3e9b99..639282e 100644
21ab4e
--- a/xlators/mgmt/glusterd/src/glusterd-snapshot.c
21ab4e
+++ b/xlators/mgmt/glusterd/src/glusterd-snapshot.c
21ab4e
@@ -2826,8 +2826,6 @@ glusterd_do_lvm_snapshot_remove (glusterd_volinfo_t *snap_vol,
21ab4e
 
21ab4e
         GLUSTERD_GET_BRICK_PIDFILE (pidfile, snap_vol, brickinfo, priv);
21ab4e
         if (gf_is_service_running (pidfile, &pid)) {
21ab4e
-                int send_attach_req (xlator_t *this, struct rpc_clnt *rpc,
21ab4e
-                                     char *path, int op);
21ab4e
                 (void) send_attach_req (this, brickinfo->rpc,
21ab4e
                                         brickinfo->path,
21ab4e
                                         GLUSTERD_BRICK_TERMINATE);
21ab4e
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
21ab4e
index 85b4607..8af9fb1 100644
21ab4e
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
21ab4e
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
21ab4e
@@ -95,8 +95,8 @@
21ab4e
 int
21ab4e
 send_attach_req (xlator_t *this, struct rpc_clnt *rpc, char *path, int op);
21ab4e
 
21ab4e
-static gf_boolean_t
21ab4e
-is_brick_mx_enabled ()
21ab4e
+gf_boolean_t
21ab4e
+is_brick_mx_enabled (void)
21ab4e
 {
21ab4e
         char            *value = NULL;
21ab4e
         int             ret = 0;
21ab4e
@@ -1319,7 +1319,8 @@ out:
21ab4e
 int
21ab4e
 glusterd_validate_and_create_brickpath (glusterd_brickinfo_t *brickinfo,
21ab4e
                                         uuid_t volume_id, char **op_errstr,
21ab4e
-                                        gf_boolean_t is_force)
21ab4e
+                                        gf_boolean_t is_force,
21ab4e
+                                        gf_boolean_t ignore_partition)
21ab4e
 {
21ab4e
         int          ret                 = -1;
21ab4e
         char         parentdir[PATH_MAX] = {0,};
21ab4e
@@ -1393,8 +1394,14 @@ glusterd_validate_and_create_brickpath (glusterd_brickinfo_t *brickinfo,
21ab4e
                                   " Or use 'force' at the end of the command if"
21ab4e
                                   " you want to override this behavior.",
21ab4e
                                   brickinfo->hostname, brickinfo->path);
21ab4e
-                        ret = -1;
21ab4e
-                        goto out;
21ab4e
+
21ab4e
+                        /* If --wignore-partition flag is used, ignore warnings
21ab4e
+                         * related to bricks being on root partition when 'force'
21ab4e
+                         * is not used */
21ab4e
+                        if (!ignore_partition) {
21ab4e
+                                ret = -1;
21ab4e
+                                goto out;
21ab4e
+                        }
21ab4e
                 }
21ab4e
         }
21ab4e
 
21ab4e
@@ -2064,13 +2071,15 @@ glusterd_brick_disconnect (glusterd_brickinfo_t *brickinfo)
21ab4e
 }
21ab4e
 
21ab4e
 int32_t
21ab4e
-glusterd_volume_stop_glusterfs (glusterd_volinfo_t  *volinfo,
21ab4e
-                                glusterd_brickinfo_t   *brickinfo,
21ab4e
+glusterd_volume_stop_glusterfs (glusterd_volinfo_t *volinfo,
21ab4e
+                                glusterd_brickinfo_t *brickinfo,
21ab4e
                                 gf_boolean_t del_brick)
21ab4e
 {
21ab4e
         xlator_t        *this                   = NULL;
21ab4e
-        int             ret                     = 0;
21ab4e
+        glusterd_conf_t *conf                   = NULL;
21ab4e
+        int             ret                     = -1;
21ab4e
         char            *op_errstr              = NULL;
21ab4e
+        char            pidfile[PATH_MAX]       = {0,};
21ab4e
 
21ab4e
         GF_ASSERT (volinfo);
21ab4e
         GF_ASSERT (brickinfo);
21ab4e
@@ -2078,6 +2087,11 @@ glusterd_volume_stop_glusterfs (glusterd_volinfo_t  *volinfo,
21ab4e
         this = THIS;
21ab4e
         GF_ASSERT (this);
21ab4e
 
21ab4e
+        conf = this->private;
21ab4e
+        GF_VALIDATE_OR_GOTO (this->name, conf, out);
21ab4e
+
21ab4e
+        ret = 0;
21ab4e
+
21ab4e
         if (del_brick)
21ab4e
                 cds_list_del_init (&brickinfo->brick_list);
21ab4e
 
21ab4e
@@ -2092,10 +2106,17 @@ glusterd_volume_stop_glusterfs (glusterd_volinfo_t  *volinfo,
21ab4e
                  * an actual signal instead.
21ab4e
                  */
21ab4e
                 if (is_brick_mx_enabled ()) {
21ab4e
+                        gf_msg_debug (this->name, 0, "About to send detach "
21ab4e
+                                      "request for brick %s:%s",
21ab4e
+                                      brickinfo->hostname, brickinfo->path);
21ab4e
+
21ab4e
                         (void) send_attach_req (this, brickinfo->rpc,
21ab4e
                                                 brickinfo->path,
21ab4e
                                                 GLUSTERD_BRICK_TERMINATE);
21ab4e
                 } else {
21ab4e
+                        gf_msg_debug (this->name, 0, "About to stop glusterfsd"
21ab4e
+                                      " for brick %s:%s", brickinfo->hostname,
21ab4e
+                                      brickinfo->path);
21ab4e
                         (void) glusterd_brick_terminate (volinfo, brickinfo,
21ab4e
                                                          NULL, 0, &op_errstr);
21ab4e
                         if (op_errstr) {
21ab4e
@@ -2109,6 +2130,10 @@ glusterd_volume_stop_glusterfs (glusterd_volinfo_t  *volinfo,
21ab4e
         if (del_brick)
21ab4e
                 glusterd_delete_brick (volinfo, brickinfo);
21ab4e
 
21ab4e
+        GLUSTERD_GET_BRICK_PIDFILE (pidfile, volinfo, brickinfo, conf);
21ab4e
+        gf_msg_debug (this->name,  0, "Unlinking pidfile %s", pidfile);
21ab4e
+        (void) sys_unlink (pidfile);
21ab4e
+out:
21ab4e
         return ret;
21ab4e
 }
21ab4e
 
21ab4e
@@ -6539,9 +6564,6 @@ glusterd_brick_stop (glusterd_volinfo_t *volinfo,
21ab4e
                 goto out;
21ab4e
         }
21ab4e
 
21ab4e
-        gf_msg_debug (this->name, 0, "About to stop glusterfs"
21ab4e
-                " for brick %s:%s", brickinfo->hostname,
21ab4e
-                brickinfo->path);
21ab4e
         ret = glusterd_volume_stop_glusterfs (volinfo, brickinfo, del_brick);
21ab4e
         if (ret) {
21ab4e
                 gf_msg (this->name, GF_LOG_CRITICAL, 0,
21ab4e
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.h b/xlators/mgmt/glusterd/src/glusterd-utils.h
21ab4e
index aab6a29..c8e1667 100644
21ab4e
--- a/xlators/mgmt/glusterd/src/glusterd-utils.h
21ab4e
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.h
21ab4e
@@ -78,6 +78,8 @@ typedef struct glusterd_dict_ctx_ {
21ab4e
         char    *prefix;
21ab4e
 } glusterd_dict_ctx_t;
21ab4e
 
21ab4e
+gf_boolean_t is_brick_mx_enabled (void);
21ab4e
+
21ab4e
 int
21ab4e
 glusterd_compare_lines (const void *a, const void *b);
21ab4e
 
21ab4e
@@ -177,10 +179,13 @@ glusterd_volume_start_glusterfs (glusterd_volinfo_t  *volinfo,
21ab4e
                                  gf_boolean_t wait);
21ab4e
 
21ab4e
 int32_t
21ab4e
-glusterd_volume_stop_glusterfs (glusterd_volinfo_t  *volinfo,
21ab4e
-                                glusterd_brickinfo_t   *brickinfo,
21ab4e
+glusterd_volume_stop_glusterfs (glusterd_volinfo_t *volinfo,
21ab4e
+                                glusterd_brickinfo_t *brickinfo,
21ab4e
                                 gf_boolean_t del_brick);
21ab4e
 
21ab4e
+int
21ab4e
+send_attach_req (xlator_t *this, struct rpc_clnt *rpc, char *path, int op);
21ab4e
+
21ab4e
 glusterd_volinfo_t *
21ab4e
 glusterd_volinfo_ref (glusterd_volinfo_t *volinfo);
21ab4e
 
21ab4e
@@ -301,7 +306,8 @@ glusterd_check_and_set_brick_xattr (char *host, char *path, uuid_t uuid,
21ab4e
 int
21ab4e
 glusterd_validate_and_create_brickpath (glusterd_brickinfo_t *brickinfo,
21ab4e
                                         uuid_t volume_id, char **op_errstr,
21ab4e
-                                        gf_boolean_t is_force);
21ab4e
+                                        gf_boolean_t is_force,
21ab4e
+                                        gf_boolean_t ignore_partition);
21ab4e
 int
21ab4e
 glusterd_sm_tr_log_transition_add (glusterd_sm_tr_log_t *log,
21ab4e
                                            int old_state, int new_state,
21ab4e
diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
21ab4e
index f6dec07..cd9c9d9 100644
21ab4e
--- a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
21ab4e
+++ b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
21ab4e
@@ -1314,7 +1314,7 @@ glusterd_op_stage_create_volume (dict_t *dict, char **op_errstr,
21ab4e
 #endif
21ab4e
                         ret = glusterd_validate_and_create_brickpath (brick_info,
21ab4e
                                                           volume_uuid, op_errstr,
21ab4e
-                                                          is_force);
21ab4e
+                                                          is_force, _gf_false);
21ab4e
                         if (ret)
21ab4e
                                 goto out;
21ab4e
 
21ab4e
-- 
21ab4e
1.8.3.1
21ab4e