summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-utils.c
diff options
context:
space:
mode:
authorSamikshan Bairagya <samikshan@gmail.com>2017-04-24 22:00:17 +0530
committerShyamsundar Ranganathan <srangana@redhat.com>2017-05-16 00:29:48 +0000
commitcec4c8fc25e34459c23693f2928dcaefb9a68c69 (patch)
tree1bd89fc74f5a8e1a7203dc8bd6b1f0ce49c5c9ac /xlators/mgmt/glusterd/src/glusterd-utils.c
parent9a20120790a462608a6121504bab27e4e910b471 (diff)
glusterd: Make reset-brick work correctly if brick-mux is on
Reset brick currently kills of the corresponding brick process. However, with brick multiplexing enabled, stopping the brick process would render all bricks attached to it unavailable. To handle this correctly, we need to make sure that the brick process is terminated only if brick-multiplexing is disabled. Otherwise, we should send the GLUSTERD_BRICK_TERMINATE rpc to the respective brick process to detach the brick that is to be reset. > Reviewed-on: https://review.gluster.org/17128 > Smoke: Gluster Build System <jenkins@build.gluster.org> > NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> > CentOS-regression: Gluster Build System <jenkins@build.gluster.org> > Reviewed-by: Atin Mukherjee <amukherj@redhat.com> (cherry picked from commit 74383e3ec6f8244b3de9bf14016452498c1ddcf0) Change-Id: I69002d66ffe6ec36ef48af09b66c522c6d35ac58 BUG: 1449933 Signed-off-by: Samikshan Bairagya <samikshan@gmail.com> Reviewed-on: https://review.gluster.org/17245 Smoke: Gluster Build System <jenkins@build.gluster.org> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-utils.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c44
1 files changed, 33 insertions, 11 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index 4b8eb88e7fb..b512e6673dd 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -96,8 +96,8 @@
int
send_attach_req (xlator_t *this, struct rpc_clnt *rpc, char *path, int op);
-static gf_boolean_t
-is_brick_mx_enabled ()
+gf_boolean_t
+is_brick_mx_enabled (void)
{
char *value = NULL;
int ret = 0;
@@ -1329,7 +1329,8 @@ out:
int
glusterd_validate_and_create_brickpath (glusterd_brickinfo_t *brickinfo,
uuid_t volume_id, char **op_errstr,
- gf_boolean_t is_force)
+ gf_boolean_t is_force,
+ gf_boolean_t ignore_partition)
{
int ret = -1;
char parentdir[PATH_MAX] = {0,};
@@ -1403,8 +1404,14 @@ glusterd_validate_and_create_brickpath (glusterd_brickinfo_t *brickinfo,
" Or use 'force' at the end of the command if"
" you want to override this behavior.",
brickinfo->hostname, brickinfo->path);
- ret = -1;
- goto out;
+
+ /* If --wignore-partition flag is used, ignore warnings
+ * related to bricks being on root partition when 'force'
+ * is not used */
+ if (!ignore_partition) {
+ ret = -1;
+ goto out;
+ }
}
}
@@ -2074,13 +2081,15 @@ glusterd_brick_disconnect (glusterd_brickinfo_t *brickinfo)
}
int32_t
-glusterd_volume_stop_glusterfs (glusterd_volinfo_t *volinfo,
- glusterd_brickinfo_t *brickinfo,
+glusterd_volume_stop_glusterfs (glusterd_volinfo_t *volinfo,
+ glusterd_brickinfo_t *brickinfo,
gf_boolean_t del_brick)
{
xlator_t *this = NULL;
- int ret = 0;
+ glusterd_conf_t *conf = NULL;
+ int ret = -1;
char *op_errstr = NULL;
+ char pidfile[PATH_MAX] = {0,};
GF_ASSERT (volinfo);
GF_ASSERT (brickinfo);
@@ -2088,6 +2097,11 @@ glusterd_volume_stop_glusterfs (glusterd_volinfo_t *volinfo,
this = THIS;
GF_ASSERT (this);
+ conf = this->private;
+ GF_VALIDATE_OR_GOTO (this->name, conf, out);
+
+ ret = 0;
+
if (del_brick)
cds_list_del_init (&brickinfo->brick_list);
@@ -2102,10 +2116,17 @@ glusterd_volume_stop_glusterfs (glusterd_volinfo_t *volinfo,
* an actual signal instead.
*/
if (is_brick_mx_enabled ()) {
+ gf_msg_debug (this->name, 0, "About to send detach "
+ "request for brick %s:%s",
+ brickinfo->hostname, brickinfo->path);
+
(void) send_attach_req (this, brickinfo->rpc,
brickinfo->path,
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);
if (op_errstr) {
@@ -2119,6 +2140,10 @@ glusterd_volume_stop_glusterfs (glusterd_volinfo_t *volinfo,
if (del_brick)
glusterd_delete_brick (volinfo, brickinfo);
+ GLUSTERD_GET_BRICK_PIDFILE (pidfile, volinfo, brickinfo, conf);
+ gf_msg_debug (this->name, 0, "Unlinking pidfile %s", pidfile);
+ (void) sys_unlink (pidfile);
+out:
return ret;
}
@@ -6563,9 +6588,6 @@ glusterd_brick_stop (glusterd_volinfo_t *volinfo,
goto out;
}
- gf_msg_debug (this->name, 0, "About to stop glusterfs"
- " for brick %s:%s", brickinfo->hostname,
- brickinfo->path);
ret = glusterd_volume_stop_glusterfs (volinfo, brickinfo, del_brick);
if (ret) {
gf_msg (this->name, GF_LOG_CRITICAL, 0,