summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-quota.c
diff options
context:
space:
mode:
authorvmallika <vmallika@redhat.com>2015-04-01 16:56:00 +0530
committerVijay Bellur <vbellur@redhat.com>2015-04-10 11:21:48 +0000
commitd06e6bac4b5aa6d0fbf1660b92c4100de8f79e68 (patch)
tree106e47847a88aab96c284b8e3b6aa1c2feffe3e8 /xlators/mgmt/glusterd/src/glusterd-quota.c
parentfcb55d54a62c8d4a2e8ce4596cd462c471f74dd3 (diff)
quota/cli: validate quota hard-limit option
Quota hard-limit is supported only upto: 9223372036854775807 (int 64) In CLI, it is allowed to set the value upto 16384PB (unsigned int 64), this is not a valid value as the xattrop for quota accounting and the quota enforcer operates on a signed int64 limit value. This patches fixes the problem in CLI and allows user to set the hard-limit value only from range 0 - 9223372036854775807 Change-Id: Ifce6e509e1832ef21d3278bacfa5bd71040c8cba BUG: 1206432 Signed-off-by: vmallika <vmallika@redhat.com> Reviewed-on: http://review.gluster.org/10022 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Kaushal M <kaushal@redhat.com> Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-quota.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-quota.c28
1 files changed, 12 insertions, 16 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-quota.c b/xlators/mgmt/glusterd/src/glusterd-quota.c
index 08e5d97a26b..a137e82b230 100644
--- a/xlators/mgmt/glusterd/src/glusterd-quota.c
+++ b/xlators/mgmt/glusterd/src/glusterd-quota.c
@@ -500,7 +500,7 @@ glusterd_set_quota_limit (char *volname, char *path, char *hard_limit,
new_limit.sl = hton64 (new_limit.sl);
- ret = gf_string2bytesize_uint64 (hard_limit, (uint64_t*)&new_limit.hl);
+ ret = gf_string2bytesize_int64 (hard_limit, &new_limit.hl);
if (ret)
goto out;
@@ -1370,8 +1370,8 @@ glusterd_op_stage_quota (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
glusterd_conf_t *priv = NULL;
glusterd_volinfo_t *volinfo = NULL;
char *hard_limit_str = NULL;
- uint64_t hard_limit = 0;
- gf_boolean_t get_gfid = _gf_false;
+ int64_t hard_limit = 0;
+ gf_boolean_t get_gfid = _gf_false;
this = THIS;
GF_ASSERT (this);
@@ -1460,20 +1460,16 @@ glusterd_op_stage_quota (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
"Faild to get hard-limit from dict");
goto out;
}
- ret = gf_string2bytesize_uint64 (hard_limit_str, &hard_limit);
+ ret = gf_string2bytesize_int64 (hard_limit_str, &hard_limit);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
- "Failed to convert hard-limit string to value");
- goto out;
- }
- if (hard_limit > UINT64_MAX) {
- ret = -1;
- ret = gf_asprintf (op_errstr, "Hard-limit %s is greater"
- " than %"PRId64"bytes. Please set a "
- "smaller limit.", hard_limit_str,
- INT64_MAX);
- gf_log (this->name, GF_LOG_ERROR, "hard-limit %s "
- "greater than INT64_MAX", hard_limit_str);
+ if (errno == ERANGE || hard_limit < 0)
+ gf_asprintf (op_errstr, "Hard-limit "
+ "value out of range (0 - %"PRId64
+ "): %s", hard_limit_str);
+ else
+ gf_log (this->name, GF_LOG_ERROR,
+ "Failed to convert hard-limit "
+ "from string to bytes");
goto out;
}
get_gfid = _gf_true;