diff options
author | Gaurav Kumar Garg <ggarg@redhat.com> | 2015-02-15 19:22:13 +0530 |
---|---|---|
committer | Krishnan Parthasarathi <kparthas@redhat.com> | 2015-04-09 17:21:06 +0000 |
commit | 2788ddd3a0afa98f78128247cca89427a323b090 (patch) | |
tree | 4568c2a808caa62cc06516e6fd3f392250e4217f /xlators/mgmt/glusterd/src/glusterd-rebalance.c | |
parent | e405f6e419387d160f6564d15ad9fd3a43af0d10 (diff) |
glusterd: remove-brick status/stop should not show output for non-existing brick
Previously when user start remove-brick operation on a volume then by
giving non-existing brick for remove-brick status/stop command it was
showing remove-brick status/stoping remove-brick operation on a volume.
With this fix it will validate bricks which user have given for
remove-brick status/stop command and if bricks are part of volume then
it will show statistics of remove-brick operation otherwise it will show
error "Incorrect brick <brick_name> for <volume_name>".
Change-Id: I151284ef78c25f52d1b39cdbd71ebfb9eb4b8471
BUG: 1121584
Signed-off-by: Gaurav Kumar Garg <ggarg@redhat.com>
Reviewed-on: http://review.gluster.org/9681
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Krishnan Parthasarathi <kparthas@redhat.com>
Tested-by: Krishnan Parthasarathi <kparthas@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-rebalance.c')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-rebalance.c | 76 |
1 files changed, 59 insertions, 17 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-rebalance.c b/xlators/mgmt/glusterd/src/glusterd-rebalance.c index ad7038b0e51..f5bb319cb7d 100644 --- a/xlators/mgmt/glusterd/src/glusterd-rebalance.c +++ b/xlators/mgmt/glusterd/src/glusterd-rebalance.c @@ -526,19 +526,48 @@ glusterd_handle_defrag_volume (rpcsvc_request_t *req) return glusterd_big_locked_handler (req, __glusterd_handle_defrag_volume); } +static int +glusterd_brick_validation (dict_t *dict, char *key, data_t *value, + void *data) +{ + int32_t ret = -1; + xlator_t *this = NULL; + glusterd_volinfo_t *volinfo = data; + glusterd_brickinfo_t *brickinfo = NULL; + + this = THIS; + GF_ASSERT (this); + + ret = glusterd_volume_brickinfo_get_by_brick (value->data, volinfo, + &brickinfo); + if (ret) { + gf_log (this->name, GF_LOG_ERROR, "Incorrect brick %s for " + "volume %s", value->data, volinfo->volname); + return ret; + } + + if (!brickinfo->decommissioned) { + gf_log (this->name, GF_LOG_ERROR, "Incorrect brick %s for " + "volume %s", value->data, volinfo->volname); + ret = -1; + return ret; + } + + return ret; +} int glusterd_op_stage_rebalance (dict_t *dict, char **op_errstr) { - char *volname = NULL; - char *cmd_str = NULL; - int ret = 0; - int32_t cmd = 0; - char msg[2048] = {0}; - glusterd_volinfo_t *volinfo = NULL; + char *volname = NULL; + char *cmd_str = NULL; + int ret = 0; + int32_t cmd = 0; + char msg[2048] = {0}; + glusterd_volinfo_t *volinfo = NULL; char *task_id_str = NULL; - dict_t *op_ctx = NULL; - xlator_t *this = 0; + dict_t *op_ctx = NULL; + xlator_t *this = 0; this = THIS; GF_ASSERT (this); @@ -630,17 +659,31 @@ glusterd_op_stage_rebalance (dict_t *dict, char **op_errstr) ret = -1; goto out; } - if ((strstr(cmd_str,"rebalance") != NULL) && - (volinfo->rebal.op != GD_OP_REBALANCE)){ - snprintf (msg,sizeof(msg),"Rebalance not started."); + if ((strstr(cmd_str, "rebalance") != NULL) && + (volinfo->rebal.op != GD_OP_REBALANCE)) { + snprintf (msg, sizeof(msg), "Rebalance not started."); ret = -1; goto out; } - if ((strstr(cmd_str,"remove-brick")!= NULL) && - (volinfo->rebal.op != GD_OP_REMOVE_BRICK)){ - snprintf (msg,sizeof(msg),"remove-brick not started."); - ret = -1; - goto out; + if (strstr(cmd_str, "remove-brick") != NULL) { + if (volinfo->rebal.op != GD_OP_REMOVE_BRICK) { + snprintf (msg, sizeof(msg), "remove-brick not " + "started."); + ret = -1; + goto out; + } + + /* For remove-brick status/stop command check whether + * given input brick is part of volume or not.*/ + + ret = dict_foreach_fnmatch (dict, "brick*", + glusterd_brick_validation, + volinfo); + if (ret == -1) { + snprintf (msg, sizeof (msg), "Incorrect brick" + " for volume %s", volinfo->volname); + goto out; + } } break; default: @@ -655,7 +698,6 @@ out: return ret; } - int glusterd_op_rebalance (dict_t *dict, char **op_errstr, dict_t *rsp_dict) { |