887953
From d67fddc4e6439f6aadd76da1a2058ffb7a4940d4 Mon Sep 17 00:00:00 2001
887953
From: Atin Mukherjee <amukherj@redhat.com>
887953
Date: Fri, 31 Aug 2018 20:42:21 +0530
887953
Subject: [PATCH 366/385] glusterd: fail volume stop operation if brick detach
887953
 fails
887953
887953
While sending a detach request for a brick in brick multiplexing mode,
887953
in any situation if the brick isn't connected, glusterd will fail to
887953
detach the brick but due to the missing error code handling, glusterd
887953
will mark the volume as stopped.
887953
887953
Fix is to handle the return code of send_attach_req in
887953
glusterd_volume_stop_glusterfs ()
887953
887953
>upstream patch : https://review.gluster.org/#/c/glusterfs/+/21055/
887953
887953
>Change-Id: I886202969c96eec3620f74cd7027652d6287f4be
887953
>Fixes: bz#1624440
887953
>Signed-off-by: Atin Mukherjee <amukherj@redhat.com>
887953
887953
Change-Id: I886202969c96eec3620f74cd7027652d6287f4be
887953
BUG: 1624444
887953
Signed-off-by: Atin Mukherjee <amukherj@redhat.com>
887953
Reviewed-on: https://code.engineering.redhat.com/gerrit/149873
887953
Tested-by: RHGS Build Bot <nigelb@redhat.com>
887953
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
887953
---
887953
 xlators/mgmt/glusterd/src/glusterd-utils.c | 31 +++++++++++++++++++++---------
887953
 1 file changed, 22 insertions(+), 9 deletions(-)
887953
887953
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
887953
index 7f52602..3db3a15 100644
887953
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
887953
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
887953
@@ -2496,19 +2496,32 @@ glusterd_volume_stop_glusterfs (glusterd_volinfo_t *volinfo,
887953
                  * an actual signal instead.
887953
                  */
887953
                 if (is_brick_mx_enabled ()) {
887953
-                        gf_msg_debug (this->name, 0, "About to send detach "
887953
-                                      "request for brick %s:%s",
887953
-                                      brickinfo->hostname, brickinfo->path);
887953
-
887953
-                        (void) send_attach_req (this, brickinfo->rpc,
887953
-                                                brickinfo->path, NULL, NULL,
887953
-                                                GLUSTERD_BRICK_TERMINATE);
887953
+                        ret = send_attach_req (this, brickinfo->rpc,
887953
+                                               brickinfo->path, NULL, NULL,
887953
+                                               GLUSTERD_BRICK_TERMINATE);
887953
+                        if (ret && brickinfo->status == GF_BRICK_STARTED) {
887953
+                                gf_msg (this->name, GF_LOG_ERROR, 0,
887953
+                                        GD_MSG_BRICK_STOP_FAIL, "Failed to send"
887953
+                                        " detach request for brick %s",
887953
+                                        brickinfo->path);
887953
+                                goto out;
887953
+                        }
887953
+                        gf_log (this->name, GF_LOG_INFO, "Detach request for "
887953
+                                "brick %s:%s is sent successfully",
887953
+                                brickinfo->hostname, brickinfo->path);
887953
                 } else {
887953
                         gf_msg_debug (this->name, 0, "About to stop glusterfsd"
887953
                                       " for brick %s:%s", brickinfo->hostname,
887953
                                       brickinfo->path);
887953
-                        (void) glusterd_brick_terminate (volinfo, brickinfo,
887953
-                                                         NULL, 0, &op_errstr);
887953
+                        ret = glusterd_brick_terminate (volinfo, brickinfo,
887953
+                                                        NULL, 0, &op_errstr);
887953
+                        if (ret && brickinfo->status == GF_BRICK_STARTED) {
887953
+                                gf_msg (this->name, GF_LOG_ERROR, 0,
887953
+                                        GD_MSG_BRICK_STOP_FAIL, "Failed to kill"
887953
+                                        " the brick %s", brickinfo->path);
887953
+                                goto out;
887953
+                        }
887953
+
887953
                         if (op_errstr) {
887953
                                 GF_FREE (op_errstr);
887953
                         }
887953
-- 
887953
1.8.3.1
887953