diff options
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-mgmt.c')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-mgmt.c | 62 |
1 files changed, 60 insertions, 2 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-mgmt.c b/xlators/mgmt/glusterd/src/glusterd-mgmt.c index 2814bb05430..ab706ce6cd5 100644 --- a/xlators/mgmt/glusterd/src/glusterd-mgmt.c +++ b/xlators/mgmt/glusterd/src/glusterd-mgmt.c @@ -24,6 +24,7 @@ #include "glusterd-snapshot-utils.h" #include "glusterd-messages.h" #include "glusterd-errno.h" +#include "glusterd-hooks.h" extern struct rpc_clnt_program gd_mgmt_v3_prog; @@ -184,7 +185,17 @@ gd_mgmt_v3_pre_validate_fn (glusterd_op_t op, dict_t *dict, if (ret) { gf_msg (this->name, GF_LOG_WARNING, 0, GD_MSG_PRE_VALIDATION_FAIL, - "Replace-brick prevalidation failed."); + "ADD-brick prevalidation failed."); + goto out; + } + break; + case GD_OP_START_VOLUME: + ret = glusterd_op_stage_start_volume (dict, op_errstr, + rsp_dict); + if (ret) { + gf_msg (this->name, GF_LOG_WARNING, 0, + GD_MSG_PRE_VALIDATION_FAIL, + "Volume start prevalidation failed."); goto out; } break; @@ -249,6 +260,7 @@ gd_mgmt_v3_commit_fn (glusterd_op_t op, dict_t *dict, GF_VALIDATE_OR_GOTO (this->name, op_errno, out); GF_ASSERT (rsp_dict); + glusterd_op_commit_hook (op, dict, GD_COMMIT_HOOK_PRE); switch (op) { case GD_OP_SNAP: { @@ -285,6 +297,19 @@ gd_mgmt_v3_commit_fn (glusterd_op_t op, dict_t *dict, break; } + case GD_OP_START_VOLUME: + { + ret = glusterd_op_start_volume (dict, op_errstr); + if (ret) { + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_COMMIT_OP_FAIL, + "Volume start commit failed."); + goto out; + } + break; + + } + default: break; } @@ -311,6 +336,9 @@ gd_mgmt_v3_post_validate_fn (glusterd_op_t op, int32_t op_ret, dict_t *dict, GF_ASSERT (op_errstr); GF_ASSERT (rsp_dict); + if (op_ret == 0) + glusterd_op_commit_hook (op, dict, GD_COMMIT_HOOK_POST); + switch (op) { case GD_OP_SNAP: { @@ -329,7 +357,7 @@ gd_mgmt_v3_post_validate_fn (glusterd_op_t op, int32_t op_ret, dict_t *dict, { ret = dict_get_str (dict, "volname", &volname); if (ret) { - gf_msg ("glusterd", GF_LOG_ERROR, errno, + gf_msg ("glusterd", GF_LOG_ERROR, 0, GD_MSG_DICT_GET_FAILED, "Unable to get" " volume name"); goto out; @@ -353,6 +381,34 @@ gd_mgmt_v3_post_validate_fn (glusterd_op_t op, int32_t op_ret, dict_t *dict, break; } + case GD_OP_START_VOLUME: + { + ret = dict_get_str (dict, "volname", &volname); + if (ret) { + gf_msg ("glusterd", GF_LOG_ERROR, 0, + GD_MSG_DICT_GET_FAILED, "Unable to get" + " volume name"); + goto out; + } + + ret = glusterd_volinfo_find (volname, &volinfo); + if (ret) { + gf_msg ("glusterd", GF_LOG_ERROR, EINVAL, + GD_MSG_VOL_NOT_FOUND, "Unable to " + "allocate memory"); + goto out; + } + + if (volinfo->type == GF_CLUSTER_TYPE_TIER) { + glusterd_defrag_info_set (volinfo, dict, + GF_DEFRAG_CMD_START_TIER, + GF_DEFRAG_CMD_START, + GD_OP_REBALANCE); + glusterd_restart_rebalance_for_volume (volinfo); + } + break; + } + default: break; } @@ -611,6 +667,7 @@ glusterd_pre_validate_aggr_rsp_dict (glusterd_op_t op, goto out; } break; + case GD_OP_START_VOLUME: case GD_OP_ADD_BRICK: ret = glusterd_aggr_brick_mount_dirs (aggr, rsp); if (ret) { @@ -918,6 +975,7 @@ glusterd_mgmt_v3_build_payload (dict_t **req, char **op_errstr, dict_t *dict, case GD_OP_SNAP: dict_copy (dict, req_dict); break; + case GD_OP_START_VOLUME: case GD_OP_ADD_BRICK: case GD_OP_REPLACE_BRICK: { |