summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt
diff options
context:
space:
mode:
authorvmallika <vmallika@redhat.com>2015-04-16 08:10:01 +0530
committerVijay Bellur <vbellur@redhat.com>2015-04-27 21:57:48 -0700
commit1adf231fc425ac35eb91a5b771ea0c5c97b1f6c3 (patch)
tree1b88f72d998785d2e6b3ee41f9901f281b6e4115 /xlators/mgmt
parentb4d909003851e327d2cf448f9409cf5e31893579 (diff)
quota: display error when inode-quota cmds executed with cluster ver < 3.7
In a heterogeneous cluster with op_version less than 3.7, inode quotas will be accounted on those bricks which has glusterfs version 3.7 and this is not available in older version. This will have incorrect values displayed when user queries inode count from CLI. This patch will display error when inode-quota commands are executed with cluster version less than 3.7 Change-Id: Ia0e6d5635d1d8e7b2e2cfc3daa7b7f9e314a263a BUG: 1212253 Signed-off-by: vmallika <vmallika@redhat.com> Reviewed-on: http://review.gluster.org/10261 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Atin Mukherjee <amukherj@redhat.com> Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'xlators/mgmt')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-quota.c67
1 files changed, 44 insertions, 23 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-quota.c b/xlators/mgmt/glusterd/src/glusterd-quota.c
index a137e82b230..97fa4380656 100644
--- a/xlators/mgmt/glusterd/src/glusterd-quota.c
+++ b/xlators/mgmt/glusterd/src/glusterd-quota.c
@@ -57,13 +57,47 @@ const char *gd_quota_op_list[GF_QUOTA_OPTION_TYPE_MAX + 1] = {
[GF_QUOTA_OPTION_TYPE_DEFAULT_SOFT_LIMIT] = "default-soft-limit",
[GF_QUOTA_OPTION_TYPE_LIMIT_OBJECTS] = "limit-objects",
[GF_QUOTA_OPTION_TYPE_LIST_OBJECTS] = "list-objects",
- [GF_QUOTA_OPTION_TYPE_REMOVE_OBJECTS] = "remove-objetcs",
+ [GF_QUOTA_OPTION_TYPE_REMOVE_OBJECTS] = "remove-objects",
[GF_QUOTA_OPTION_TYPE_MAX] = NULL
};
int
glusterd_store_quota_config (glusterd_volinfo_t *volinfo, char *path,
char *gfid_str, int opcode, char **op_errstr);
+
+gf_boolean_t
+glusterd_is_quota_supported (int32_t type, char **op_errstr)
+{
+ xlator_t *this = NULL;
+ glusterd_conf_t *conf = NULL;
+ gf_boolean_t supported = _gf_false;
+
+ this = THIS;
+ GF_VALIDATE_OR_GOTO ("glusterd", this, out);
+
+ conf = this->private;
+ GF_VALIDATE_OR_GOTO (this->name, conf, out);
+
+ if ((conf->op_version == GD_OP_VERSION_MIN) &&
+ (type > GF_QUOTA_OPTION_TYPE_VERSION))
+ goto out;
+
+ if ((conf->op_version < GD_OP_VERSION_3_7_0) &&
+ (type > GF_QUOTA_OPTION_TYPE_VERSION_OBJECTS))
+ goto out;
+
+ supported = _gf_true;
+
+out:
+ if (!supported && op_errstr != NULL && conf)
+ gf_asprintf (op_errstr, "Volume quota failed. The cluster is "
+ "operating at version %d. Quota command"
+ " %s is unavailable in this version.",
+ conf->op_version, gd_quota_op_list[type]);
+
+ return supported;
+}
+
int
__glusterd_handle_quota (rpcsvc_request_t *req)
{
@@ -121,18 +155,17 @@ __glusterd_handle_quota (rpcsvc_request_t *req)
snprintf (msg, sizeof (msg), "Unable to get type of command");
gf_log (this->name, GF_LOG_ERROR, "Unable to get type of cmd, "
"while handling quota command");
- goto out;
+ goto out;
}
- if ((conf->op_version == GD_OP_VERSION_MIN) &&
- (type > GF_QUOTA_OPTION_TYPE_VERSION)) {
- snprintf (msg, sizeof (msg), "Cannot execute command. The "
- "cluster is operating at version %d. Quota command %s "
- "is unavailable in this version", conf->op_version,
- gd_quota_op_list[type]);
+ if (!glusterd_is_quota_supported (type, NULL)) {
+ snprintf (msg, sizeof (msg), "Volume quota failed. The cluster "
+ "is operating at version %d. Quota command"
+ " %s is unavailable in this version.",
+ conf->op_version, gd_quota_op_list[type]);
ret = -1;
goto out;
- }
+ }
ret = glusterd_op_begin_synctask (req, GD_OP_QUOTA, dict);
@@ -1090,13 +1123,7 @@ glusterd_op_quota (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
ret = dict_get_int32 (dict, "type", &type);
- if ((priv->op_version == GD_OP_VERSION_MIN) &&
- (type > GF_QUOTA_OPTION_TYPE_VERSION)) {
- gf_asprintf (op_errstr, "Volume quota failed. The cluster is "
- "operating at version %d. Quota command"
- " %s is unavailable in this version.",
- priv->op_version,
- gd_quota_op_list[type]);
+ if (!glusterd_is_quota_supported (type, op_errstr)) {
ret = -1;
goto out;
}
@@ -1421,13 +1448,7 @@ glusterd_op_stage_quota (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
goto out;
}
- if ((priv->op_version == GD_OP_VERSION_MIN) &&
- (type > GF_QUOTA_OPTION_TYPE_VERSION)) {
- gf_asprintf (op_errstr, "Volume quota failed. The cluster is "
- "operating at version %d. Quota command"
- " %s is unavailable in this version.",
- priv->op_version,
- gd_quota_op_list[type]);
+ if (!glusterd_is_quota_supported (type, op_errstr)) {
ret = -1;
goto out;
}