summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKrishnan Parthasarathi <kparthas@redhat.com>2012-10-10 17:57:20 +0530
committerAnand Avati <avati@redhat.com>2012-10-10 19:10:50 -0700
commit15396f490d23c665d51a64a049679cb40472ab05 (patch)
treea57e6d50918c9a7d546e1a8bdabcff4eaac5272d
parent144db7f39f35a51c24558c81faea3f49c237312f (diff)
glusterd: glusterd_brick_stop should be race free wrt pmap
This is important for the effort to make glusterd use synctask framework. Change-Id: I0affb10a342df99df8daccfd6eef8fa6dd63928c BUG: 862834 Signed-off-by: Krishnan Parthasarathi <kparthas@redhat.com> Reviewed-on: http://review.gluster.org/4057 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Anand Avati <avati@redhat.com>
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-brick-ops.c5
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-op-sm.c4
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-replace-brick.c3
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c27
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.h6
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-volume-ops.c2
6 files changed, 29 insertions, 18 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c
index b32c9872ac3..5d59fadf3e1 100644
--- a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c
+++ b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c
@@ -980,14 +980,14 @@ glusterd_op_perform_remove_brick (glusterd_volinfo_t *volinfo, char *brick,
if (force) {
if (GLUSTERD_STATUS_STARTED == volinfo->status) {
- ret = glusterd_brick_stop (volinfo, brickinfo);
+ ret = glusterd_brick_stop (volinfo, brickinfo,
+ _gf_true);
if (ret) {
gf_log (THIS->name, GF_LOG_ERROR, "Unable to stop "
"glusterfs, ret: %d", ret);
goto out;
}
}
- glusterd_delete_brick (volinfo, brickinfo);
goto out;
}
@@ -1290,6 +1290,7 @@ glusterd_remove_brick_migrate_cbk (glusterd_volinfo_t *volinfo,
brickinfo->path);
brickinfo->decommissioned = 0;
if (GLUSTERD_STATUS_STARTED == volinfo->status) {
+ /*TODO: use the 'atomic' flavour of brick_stop*/
ret = glusterd_brick_stop (volinfo, brickinfo);
if (ret) {
gf_log (THIS->name, GF_LOG_ERROR,
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
index da1f818f50b..04b9cfe462d 100644
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
@@ -1007,7 +1007,9 @@ glusterd_stop_bricks (glusterd_volinfo_t *volinfo)
glusterd_brickinfo_t *brickinfo = NULL;
list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) {
- if (glusterd_brick_stop (volinfo, brickinfo))
+ /*TODO: Need to change @del_brick in brick_stop to _gf_true
+ * once we enable synctask in peer rpc prog */
+ if (glusterd_brick_stop (volinfo, brickinfo, _gf_false))
return -1;
}
diff --git a/xlators/mgmt/glusterd/src/glusterd-replace-brick.c b/xlators/mgmt/glusterd/src/glusterd-replace-brick.c
index 5fcbb84e5d3..5c6e26d3570 100644
--- a/xlators/mgmt/glusterd/src/glusterd-replace-brick.c
+++ b/xlators/mgmt/glusterd/src/glusterd-replace-brick.c
@@ -578,7 +578,8 @@ rb_src_brick_restart (glusterd_volinfo_t *volinfo,
ret);
}
- ret = glusterd_volume_stop_glusterfs (volinfo, src_brickinfo);
+ ret = glusterd_volume_stop_glusterfs (volinfo, src_brickinfo,
+ _gf_false);
if (ret) {
gf_log ("", GF_LOG_ERROR, "Unable to stop "
"glusterfs, ret: %d", ret);
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index 0722255ce4d..46b43215b7c 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -1376,7 +1376,8 @@ glusterd_brick_disconnect (glusterd_brickinfo_t *brickinfo)
int32_t
glusterd_volume_stop_glusterfs (glusterd_volinfo_t *volinfo,
- glusterd_brickinfo_t *brickinfo)
+ glusterd_brickinfo_t *brickinfo,
+ gf_boolean_t del_brick)
{
xlator_t *this = NULL;
glusterd_conf_t *priv = NULL;
@@ -1391,6 +1392,9 @@ glusterd_volume_stop_glusterfs (glusterd_volinfo_t *volinfo,
GF_ASSERT (this);
priv = this->private;
+ if (del_brick)
+ list_del_init (&brickinfo->brick_list);
+
(void) glusterd_brick_disconnect (brickinfo);
GLUSTERD_GET_VOLUME_DIR (path, volinfo, priv);
@@ -1402,6 +1406,9 @@ glusterd_volume_stop_glusterfs (glusterd_volinfo_t *volinfo,
glusterd_set_brick_status (brickinfo, GF_BRICK_STOPPED);
(void) glusterd_brick_unlink_socket_file (volinfo, brickinfo);
}
+
+ if (del_brick)
+ glusterd_delete_brick (volinfo, brickinfo);
return ret;
}
@@ -2456,7 +2463,11 @@ glusterd_volinfo_stop_stale_bricks (glusterd_volinfo_t *new_volinfo,
old_brickinfo->path,
new_volinfo, &new_brickinfo);
if (ret) {
- ret = glusterd_brick_stop (old_volinfo, old_brickinfo);
+ /*TODO: may need to switch to 'atomic' flavour of
+ * brick_stop, once we make peer rpc program also
+ * synctask enabled*/
+ ret = glusterd_brick_stop (old_volinfo, old_brickinfo,
+ _gf_false);
if (ret)
gf_log ("glusterd", GF_LOG_ERROR, "Failed to "
"stop brick %s:%s", old_brickinfo->hostname,
@@ -4255,7 +4266,8 @@ out:
int
glusterd_brick_stop (glusterd_volinfo_t *volinfo,
- glusterd_brickinfo_t *brickinfo)
+ glusterd_brickinfo_t *brickinfo,
+ gf_boolean_t del_brick)
{
int ret = -1;
xlator_t *this = NULL;
@@ -4287,7 +4299,7 @@ glusterd_brick_stop (glusterd_volinfo_t *volinfo,
gf_log ("", GF_LOG_INFO, "About to stop glusterfs"
" for brick %s:%s", brickinfo->hostname,
brickinfo->path);
- ret = glusterd_volume_stop_glusterfs (volinfo, brickinfo);
+ ret = glusterd_volume_stop_glusterfs (volinfo, brickinfo, del_brick);
if (ret) {
gf_log ("", GF_LOG_CRITICAL, "Unable to remove"
" brick: %s:%s", brickinfo->hostname,
@@ -4905,13 +4917,6 @@ glusterd_delete_brick (glusterd_volinfo_t* volinfo,
GF_ASSERT (volinfo);
GF_ASSERT (brickinfo);
-#ifdef DEBUG
- ret = glusterd_volume_brickinfo_get (brickinfo->uuid,
- brickinfo->hostname,
- brickinfo->path, volinfo,
- NULL);
- GF_ASSERT (0 == ret);
-#endif
glusterd_delete_volfile (volinfo, brickinfo);
glusterd_store_delete_brick (volinfo, brickinfo);
glusterd_brickinfo_delete (brickinfo);
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.h b/xlators/mgmt/glusterd/src/glusterd-utils.h
index 167bffaac71..4aea17311a6 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.h
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.h
@@ -128,7 +128,8 @@ glusterd_volume_start_glusterfs (glusterd_volinfo_t *volinfo,
int32_t
glusterd_volume_stop_glusterfs (glusterd_volinfo_t *volinfo,
- glusterd_brickinfo_t *brickinfo);
+ glusterd_brickinfo_t *brickinfo,
+ gf_boolean_t del_brick);
int32_t
glusterd_volinfo_delete (glusterd_volinfo_t *volinfo);
@@ -269,7 +270,8 @@ glusterd_brick_start (glusterd_volinfo_t *volinfo,
glusterd_brickinfo_t *brickinfo);
int
glusterd_brick_stop (glusterd_volinfo_t *volinfo,
- glusterd_brickinfo_t *brickinfo);
+ glusterd_brickinfo_t *brickinfo,
+ gf_boolean_t del_brick);
int
glusterd_is_defrag_on (glusterd_volinfo_t *volinfo);
diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
index 8e6b2e9269d..d167ed10022 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
@@ -1453,7 +1453,7 @@ glusterd_op_stop_volume (dict_t *dict)
goto out;
list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) {
- ret = glusterd_brick_stop (volinfo, brickinfo);
+ ret = glusterd_brick_stop (volinfo, brickinfo, _gf_false);
if (ret)
goto out;
}