summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
Diffstat (limited to 'xlators')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-replace-brick.c24
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c14
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.h3
3 files changed, 39 insertions, 2 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-replace-brick.c b/xlators/mgmt/glusterd/src/glusterd-replace-brick.c
index 93b6430d173..dfa9b5dd317 100644
--- a/xlators/mgmt/glusterd/src/glusterd-replace-brick.c
+++ b/xlators/mgmt/glusterd/src/glusterd-replace-brick.c
@@ -378,8 +378,24 @@ glusterd_op_stage_replace_brick (dict_t *dict, char **op_errstr,
break;
case GF_REPLACE_OP_COMMIT_FORCE: break;
+
case GF_REPLACE_OP_STATUS:
+
+ if (glusterd_is_rb_ongoing (volinfo) == _gf_false) {
+ ret = gf_asprintf (op_errstr, "replace-brick not"
+ " started on volume %s",
+ volinfo->volname);
+ if (ret < 0) {
+ *op_errstr = NULL;
+ goto out;
+ }
+
+ gf_log (THIS->name, GF_LOG_ERROR, "%s", *op_errstr);
+ ret = -1;
+ goto out;
+ }
break;
+
default:
ret = -1;
goto out;
@@ -472,11 +488,15 @@ glusterd_op_stage_replace_brick (dict_t *dict, char **op_errstr,
}
if (glusterd_rb_check_bricks (volinfo, src_brickinfo, dst_brickinfo)) {
- gf_log ("", GF_LOG_ERROR, "replace brick: incorrect source or"
- " destination bricks specified");
+
ret = -1;
+ *op_errstr = gf_strdup ("incorrect source or "
+ "destination brick");
+ if (*op_errstr)
+ gf_log (THIS->name, GF_LOG_ERROR, "%s", *op_errstr);
goto out;
}
+
if (!glusterd_is_local_addr (host)) {
ret = glusterd_brick_create_path (host, path,
volinfo->volume_id, 0777,
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index b2d0bcdd7ad..ccb7e8b4be9 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -3727,6 +3727,20 @@ glusterd_is_defrag_on (glusterd_volinfo_t *volinfo)
return (volinfo->defrag != NULL);
}
+gf_boolean_t
+glusterd_is_rb_ongoing (glusterd_volinfo_t *volinfo)
+{
+ gf_boolean_t ret = _gf_false;
+
+ GF_ASSERT (volinfo);
+
+ if (glusterd_is_rb_started (volinfo) ||
+ glusterd_is_rb_paused (volinfo))
+ ret = _gf_true;
+
+ return ret;
+}
+
int
glusterd_is_replace_running (glusterd_volinfo_t *volinfo, glusterd_brickinfo_t *brickinfo)
{
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.h b/xlators/mgmt/glusterd/src/glusterd-utils.h
index 0ce17450284..13ac026018f 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.h
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.h
@@ -291,6 +291,9 @@ glusterd_is_rb_paused (glusterd_volinfo_t *volinfo);
int
glusterd_set_rb_status (glusterd_volinfo_t *volinfo, gf_rb_status_t status);
+gf_boolean_t
+glusterd_is_rb_ongoing (glusterd_volinfo_t *volinfo);
+
int
glusterd_is_replace_running (glusterd_volinfo_t *volinfo, glusterd_brickinfo_t *brickinfo);