From 7c0c184be28e0cba08645c7106c6901b444651c9 Mon Sep 17 00:00:00 2001 From: Mohammed Rafi KC Date: Thu, 23 Apr 2015 16:24:43 +0530 Subject: tiering: Do not allow some operations on tiered volume Some operations like add-brick,remove-brick,rebalance, replace-brick are not supported on tiered volume. But there is no code level check for this. This patch will allow to do the same Change-Id: I12689f4e902cf0cceaf6f7f29c71057305024977 BUG: 1205624 Signed-off-by: Mohammed Rafi KC Reviewed-on: http://review.gluster.org/10349 Tested-by: Gluster Build System Tested-by: NetBSD Build System Reviewed-by: Krishnan Parthasarathi Tested-by: Krishnan Parthasarathi --- xlators/mgmt/glusterd/src/glusterd-utils.c | 65 ++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) (limited to 'xlators/mgmt/glusterd/src/glusterd-utils.c') diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c index 8209e779c52..431db7d8785 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-utils.c @@ -9404,3 +9404,68 @@ glusterd_list_add_order (struct cds_list_head *new, struct cds_list_head *head, cds_list_add_rcu (new, rcu_dereference (pos->prev)); } + + +int +glusterd_disallow_op_for_tier (glusterd_volinfo_t *volinfo, glusterd_op_t op, + int cmd) +{ + + xlator_t *this = NULL; + int ret = 0; + + this = THIS; + GF_VALIDATE_OR_GOTO (this->name, volinfo, out); + + if (volinfo->type != GF_CLUSTER_TYPE_TIER) + goto out; + + switch (op) { + case GD_OP_ADD_BRICK: + case GD_OP_REPLACE_BRICK: + ret = -1; + gf_log (this->name, GF_LOG_DEBUG, "Operation not " + "permitted on tiered volume %s", + volinfo->volname); + break; + case GD_OP_REBALANCE: + switch (cmd) { + case GF_DEFRAG_CMD_START_TIER: + case GF_DEFRAG_CMD_STATUS_TIER: + case GF_DEFRAG_CMD_START_DETACH_TIER: + case GF_DEFRAG_CMD_STOP_DETACH_TIER: + case GF_DEFRAG_CMD_STATUS: + ret = 0; + break; + default: + gf_log (this->name, GF_LOG_DEBUG, + "Rebalance Operation not permitted" + " on tiered volume %s", + volinfo->volname); + ret = -1; + break; + } + break; + case GD_OP_REMOVE_BRICK: + switch (cmd) { + case GF_OP_CMD_DETACH_COMMIT_FORCE: + case GF_OP_CMD_DETACH_COMMIT: + case GF_OP_CMD_DETACH_START: + case GF_DEFRAG_CMD_STOP_DETACH_TIER: + ret = 0; + break; + default: + gf_log (this->name, GF_LOG_DEBUG, + "Remove brick operation not " + "permitted on tiered volume %s", + volinfo->volname); + ret = -1; + break; + } + break; + default: + break; + } +out: + return ret; +} -- cgit