summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
authorMohammed Rafi KC <rkavunga@redhat.com>2015-04-23 16:24:43 +0530
committerVijay Bellur <vbellur@redhat.com>2015-05-07 23:07:21 -0700
commit7c0c184be28e0cba08645c7106c6901b444651c9 (patch)
treeecb398a5d33813b5bfb4af3535f3877a195560b1 /xlators
parent9ba8963999bca431ec14a25961a163810cfe1e5b (diff)
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 <rkavunga@redhat.com> Reviewed-on: http://review.gluster.org/10349 Tested-by: Gluster Build System <jenkins@build.gluster.com> Tested-by: NetBSD Build System Reviewed-by: Krishnan Parthasarathi <kparthas@redhat.com> Tested-by: Krishnan Parthasarathi <kparthas@redhat.com>
Diffstat (limited to 'xlators')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-brick-ops.c25
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-rebalance.c9
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-replace-brick.c8
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c65
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.h4
5 files changed, 111 insertions, 0 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c
index f80b5a8078b..19ba5e5219e 100644
--- a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c
+++ b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c
@@ -511,6 +511,14 @@ __glusterd_handle_add_brick (rpcsvc_request_t *req)
goto brick_val;
}
+ ret = glusterd_disallow_op_for_tier (volinfo, GD_OP_ADD_BRICK, -1);
+ if (ret) {
+ snprintf (err_str, sizeof (err_str), "Add-brick operation is "
+ "not supported on a tiered volume %s", volname);
+ gf_log (this->name, GF_LOG_ERROR, "%s", err_str);
+ goto out;
+ }
+
if (!stripe_count && !replica_count) {
if (volinfo->type == GF_CLUSTER_TYPE_NONE)
goto brick_val;
@@ -753,6 +761,7 @@ __glusterd_handle_remove_brick (rpcsvc_request_t *req)
int32_t replica_count = 0;
char *volname = 0;
xlator_t *this = NULL;
+ int cmd = -1;
GF_ASSERT (req);
this = THIS;
@@ -818,6 +827,22 @@ __glusterd_handle_remove_brick (rpcsvc_request_t *req)
goto out;
}
+ ret = dict_get_int32 (dict, "command", &cmd);
+ if (ret) {
+ snprintf (err_str, sizeof (err_str), "Unable to get cmd "
+ "ccommand");
+ gf_log (this->name, GF_LOG_ERROR, "%s", err_str);
+ goto out;
+ }
+
+ ret = glusterd_disallow_op_for_tier (volinfo, GD_OP_REMOVE_BRICK, cmd);
+ if (ret) {
+ snprintf (err_str, sizeof (err_str),
+ "Removing brick from a Tier volume is not allowed");
+ gf_log (this->name, GF_LOG_ERROR, "%s", err_str);
+ goto out;
+ }
+
ret = dict_get_int32 (dict, "replica-count", &replica_count);
if (!ret) {
gf_log (this->name, GF_LOG_INFO,
diff --git a/xlators/mgmt/glusterd/src/glusterd-rebalance.c b/xlators/mgmt/glusterd/src/glusterd-rebalance.c
index 84d9210a105..c14bcd156b4 100644
--- a/xlators/mgmt/glusterd/src/glusterd-rebalance.c
+++ b/xlators/mgmt/glusterd/src/glusterd-rebalance.c
@@ -421,6 +421,15 @@ glusterd_rebalance_cmd_validate (int cmd, char *volname,
goto out;
}
+ ret = glusterd_disallow_op_for_tier (*volinfo, GD_OP_REBALANCE, cmd);
+ if (ret) {
+ gf_log ("glusterd", GF_LOG_ERROR, "Received rebalance command "
+ "on Tier volume %s", volname);
+ snprintf (op_errstr, len, "Rebalance operations are not "
+ "supported on a tiered volume");
+ goto out;
+ }
+
ret = 0;
out:
diff --git a/xlators/mgmt/glusterd/src/glusterd-replace-brick.c b/xlators/mgmt/glusterd/src/glusterd-replace-brick.c
index 818b58a724f..cb9c67cc7dc 100644
--- a/xlators/mgmt/glusterd/src/glusterd-replace-brick.c
+++ b/xlators/mgmt/glusterd/src/glusterd-replace-brick.c
@@ -243,6 +243,14 @@ glusterd_op_stage_replace_brick (dict_t *dict, char **op_errstr,
goto out;
}
+ ret = glusterd_disallow_op_for_tier (volinfo, GD_OP_REPLACE_BRICK, -1);
+ if (ret) {
+ snprintf (msg, sizeof (msg), "Replace brick commands are not "
+ "supported on tiered volume %s", volname);
+ *op_errstr = gf_strdup (msg);
+ goto out;
+ }
+
if (!glusterd_store_is_valid_brickpath (volname, dst_brick) ||
!glusterd_is_valid_volfpath (volname, dst_brick)) {
snprintf (msg, sizeof (msg), "brick path %s is too "
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;
+}
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.h b/xlators/mgmt/glusterd/src/glusterd-utils.h
index fcfddd5bffa..8975e53f91b 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.h
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.h
@@ -650,4 +650,8 @@ void
glusterd_list_add_order (struct cds_list_head *new, struct cds_list_head *head,
int (*compare)(struct cds_list_head *,
struct cds_list_head *));
+int
+glusterd_disallow_op_for_tier (glusterd_volinfo_t *volinfo, glusterd_op_t op,
+ int cmd);
+
#endif