summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-quota.c
diff options
context:
space:
mode:
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-quota.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-quota.c83
1 files changed, 39 insertions, 44 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-quota.c b/xlators/mgmt/glusterd/src/glusterd-quota.c
index 474d24ad..5a8a2a63 100644
--- a/xlators/mgmt/glusterd/src/glusterd-quota.c
+++ b/xlators/mgmt/glusterd/src/glusterd-quota.c
@@ -744,17 +744,46 @@ out:
return ret;
}
+static int
+glusterd_remove_quota_limit (char *volname, char *path, char **op_errstr)
+{
+ int ret = -1;
+ xlator_t *this = NULL;
+ char abspath[PATH_MAX] = {0,};
+ glusterd_conf_t *priv = NULL;
+
+ this = THIS;
+ GF_ASSERT (this);
+ priv = this->private;
+ GF_ASSERT (priv);
+
+ snprintf (abspath, sizeof (abspath)-1, "/tmp/%s%s", volname, path);
+
+ ret = gf_lstat_dir (abspath, NULL);
+ if (ret) {
+ gf_asprintf (op_errstr, "Failed to find the directory %s. "
+ "Reason : %s", abspath, strerror (errno));
+ goto out;
+ }
+
+ ret = sys_lremovexattr (abspath, "trusted.glusterfs.quota.limit-set");
+ if (ret) {
+ gf_asprintf (op_errstr, "removexattr failed on %s. Reason : %s",
+ abspath, strerror (errno));
+ goto out;
+ }
+ ret = 0;
+
+out:
+ return ret;
+}
+
int32_t
glusterd_quota_remove_limits (glusterd_volinfo_t *volinfo, dict_t *dict,
char **op_errstr)
{
int32_t ret = -1;
- char str [PATH_MAX + 1024] = {0,};
- char *quota_limits = NULL;
- char *new_list = NULL;
- char *value = NULL;
char *path = NULL;
- gf_boolean_t flag = _gf_false;
xlator_t *this = NULL;
this = THIS;
@@ -771,13 +800,6 @@ glusterd_quota_remove_limits (glusterd_volinfo_t *volinfo, dict_t *dict,
goto out;
}
- ret = glusterd_volinfo_get (volinfo, VKEY_FEATURES_LIMIT_USAGE,
- &quota_limits);
- if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "failed to get quota limits");
- goto out;
- }
-
ret = dict_get_str (dict, "path", &path);
if (ret) {
gf_log (this->name, GF_LOG_ERROR, "Unable to fetch path");
@@ -788,44 +810,17 @@ glusterd_quota_remove_limits (glusterd_volinfo_t *volinfo, dict_t *dict,
if (ret)
goto out;
- ret = _glusterd_quota_remove_limits (quota_limits, path, &flag,
- &new_list, NULL);
- if (ret == -1) {
- if (flag == _gf_true)
- snprintf (str, sizeof (str), "Removing limit on %s has "
- "been unsuccessful", path);
- else
- snprintf (str, sizeof (str), "%s has no limit set",
- path);
- *op_errstr = gf_strdup (str);
- goto out;
- } else {
- if (flag == _gf_true)
- snprintf (str, sizeof (str), "Removed quota limit on "
- "%s", path);
- else
- snprintf (str, sizeof (str), "no limit set on %s",
- path);
- *op_errstr = gf_strdup (str);
- }
-
- if (new_list) {
- value = gf_strdup (new_list);
- ret = dict_set_str (volinfo->dict, VKEY_FEATURES_LIMIT_USAGE,
- value);
- if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Unable to set quota "
- "limits");
+ if (is_origin_glusterd ()) {
+ ret = glusterd_remove_quota_limit (volinfo->volname, path,
+ op_errstr);
+ if (ret)
goto out;
- }
- } else {
- dict_del (volinfo->dict, VKEY_FEATURES_LIMIT_USAGE);
}
+ gf_asprintf (op_errstr, "Removed quota limit on %s", path);
ret = 0;
out:
- GF_FREE (new_list);
return ret;
}