From 13deb311b2a48170489bb4f7cfd7def982281fd4 Mon Sep 17 00:00:00 2001 From: Atin Mukherjee Date: Fri, 31 Aug 2018 20:42:21 +0530 Subject: glusterd: fail volume stop operation if brick detach fails While sending a detach request for a brick in brick multiplexing mode, in any situation if the brick isn't connected, glusterd will fail to detach the brick but due to the missing error code handling, glusterd will mark the volume as stopped. Fix is to handle the return code of send_attach_req in glusterd_volume_stop_glusterfs () Change-Id: I886202969c96eec3620f74cd7027652d6287f4be Fixes: bz#1624440 Signed-off-by: Atin Mukherjee --- xlators/mgmt/glusterd/src/glusterd-utils.c | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) (limited to 'xlators') diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c index e6efe11cf5c..51c81db2f35 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-utils.c @@ -2557,19 +2557,33 @@ glusterd_volume_stop_glusterfs (glusterd_volinfo_t *volinfo, * an actual signal instead. */ if (is_brick_mx_enabled () && last_brick != 1) { - gf_msg_debug (this->name, 0, "About to send detach " - "request for brick %s:%s", - brickinfo->hostname, brickinfo->path); + ret = send_attach_req (this, brickinfo->rpc, + brickinfo->path, NULL, NULL, + GLUSTERD_BRICK_TERMINATE); + if (ret && brickinfo->status == GF_BRICK_STARTED) { + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_BRICK_STOP_FAIL, "Failed to send" + " detach request for brick %s", + brickinfo->path); + goto out; + } + gf_log (this->name, GF_LOG_INFO, "Detach request for " + "brick %s:%s is sent successfully", + brickinfo->hostname, brickinfo->path); - (void) send_attach_req (this, brickinfo->rpc, - brickinfo->path, NULL, NULL, - GLUSTERD_BRICK_TERMINATE); } else { gf_msg_debug (this->name, 0, "About to stop glusterfsd" " for brick %s:%s", brickinfo->hostname, brickinfo->path); - (void) glusterd_brick_terminate (volinfo, brickinfo, - NULL, 0, &op_errstr); + ret = glusterd_brick_terminate (volinfo, brickinfo, + NULL, 0, &op_errstr); + if (ret && brickinfo->status == GF_BRICK_STARTED) { + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_BRICK_STOP_FAIL, "Failed to kill" + " the brick %s", brickinfo->path); + goto out; + } + if (op_errstr) { GF_FREE (op_errstr); } -- cgit