summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
authorKrutika Dhananjay <kdhananj@redhat.com>2013-08-07 18:38:17 +0530
committerKrutika Dhananjay <kdhananj@redhat.com>2013-08-09 15:20:17 +0530
commitc804a1c5ac6c5e3b50c2d4d3e092142d7a15338e (patch)
tree7c5b70a5e90babf5871ee051cab241896e8a65f7 /xlators
parentbd8e5775cf79e66dc5909f4a6a8df598f8691496 (diff)
glusterd,cli: changes to quota list <path> ...
Change-Id: Ia37020c3aa11af6eed3af09cfe390b848b028b6a Signed-off-by: Krutika Dhananjay <kdhananj@redhat.com>
Diffstat (limited to 'xlators')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-quota.c78
1 files changed, 11 insertions, 67 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-quota.c b/xlators/mgmt/glusterd/src/glusterd-quota.c
index 0db26f4b..9f0fd90c 100644
--- a/xlators/mgmt/glusterd/src/glusterd-quota.c
+++ b/xlators/mgmt/glusterd/src/glusterd-quota.c
@@ -395,84 +395,23 @@ _glusterd_quota_get_limit_usages (glusterd_volinfo_t *volinfo,
}
int32_t
-glusterd_quota_get_limit_usages (glusterd_conf_t *priv,
- glusterd_volinfo_t *volinfo, char *volname,
- dict_t *dict, char **op_errstr,
- dict_t *rsp_dict)
+glusterd_quota_get_default_soft_limit (glusterd_volinfo_t *volinfo,
+ dict_t *rsp_dict)
{
- int32_t i = 0;
int32_t ret = 0;
- int32_t count = 0;
- int entry_count = 0;
- char *path = NULL;
- char cmd_str [1024] = {0, };
- char *ret_str = NULL;
xlator_t *this = NULL;
glusterd_conf_t *conf = NULL;
char *default_limit = NULL;
char *val = NULL;
if (rsp_dict == NULL)
- return 0;
+ return -1;
this = THIS;
GF_ASSERT (this);
conf = this->private;
GF_ASSERT (conf);
- ret = dict_get_int32 (dict, "count", &count);
- if (ret < 0)
- goto out;
-
- if (count == 0) {
- ret_str = _glusterd_quota_get_limit_usages (volinfo, NULL,
- op_errstr);
- ret = dict_set_dynstr (rsp_dict, "limit_list", ret_str);
- if (ret)
- goto out;
- } else {
- i = 0;
- while (count--) {
- snprintf (cmd_str, sizeof (cmd_str), "path%d", i++);
-
- ret = dict_get_str (dict, cmd_str, &path);
- if (ret < 0)
- goto out;
- ret = gf_canonicalize_path (path);
- if (ret) {
- goto out;
- }
-
- ret_str = _glusterd_quota_get_limit_usages (volinfo,
- path,
- op_errstr);
- /* Despite quota limits being absent on @path, we go
- * ahead and place it in @rsp_dict with
- * value = "Not set". This is because after commit op,
- * as part of aggregation of @rsp_dict with @op_ctx,
- * when we copy the rsp_dict into op_ctx, op_ctx would
- * still be containing the old key (same as @cmd_str)
- * with the old value. In order to overwrite the old
- * value, we replace it with "Not set", something that
- * the cli can easily interpret as a case of quota
- * limits not having been set on the given path.
- */
- if (!ret_str) {
- ret = dict_set_str (rsp_dict, cmd_str,
- "Not set");
- } else {
- ret = dict_set_dynstr (rsp_dict, cmd_str,
- ret_str);
- entry_count = entry_count + 1;
- }
- }
- }
- ret = dict_set_int32 (rsp_dict, "entry-count", entry_count);
- if (ret)
- goto out;
-
- ret = dict_set_uint32 (rsp_dict, "op-version", conf->op_version);
-
ret = glusterd_volinfo_get (volinfo, "features.default-soft-limit",
&default_limit);
if (default_limit)
@@ -481,6 +420,13 @@ glusterd_quota_get_limit_usages (glusterd_conf_t *priv,
val = gf_strdup ("90%");
ret = dict_set_dynstr (rsp_dict, "default-soft-limit", val);
+ if (ret) {
+ gf_log (this->name, GF_LOG_ERROR, "Failed to set default "
+ "soft-limit into dict");
+ goto out;
+ }
+ ret = 0;
+
out:
return ret;
}
@@ -956,9 +902,7 @@ glusterd_op_quota (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
"quota is disabled");
goto out;
}
- ret = glusterd_quota_get_limit_usages (priv, volinfo,
- volname, dict,
- op_errstr,
+ ret = glusterd_quota_get_default_soft_limit (volinfo,
rsp_dict);
goto out;