summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src
diff options
context:
space:
mode:
Diffstat (limited to 'xlators/mgmt/glusterd/src')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-op-sm.c54
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-quota.c106
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c7
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.h3
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-volgen.h1
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-volume-set.c8
6 files changed, 150 insertions, 29 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
index cb8080693c6..e55e6793f4a 100644
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
@@ -423,23 +423,49 @@ glusterd_check_quota_cmd (char *key, char *value, char *errstr, size_t size)
if (ret)
goto out;
if (b) {
- snprintf (errstr, size," 'gluster "
- "volume set <VOLNAME> %s %s' is "
- "deprecated. Use 'gluster volume "
- "quota <VOLNAME> enable' instead.",
- key, value);
- ret = -1;
- goto out;
+ snprintf (errstr, size, " 'gluster "
+ "volume set <VOLNAME> %s %s' is "
+ "deprecated. Use 'gluster volume "
+ "quota <VOLNAME> enable' instead.",
+ key, value);
+ ret = -1;
+ goto out;
+ } else {
+ snprintf (errstr, size, " 'gluster "
+ "volume set <VOLNAME> %s %s' is "
+ "deprecated. Use 'gluster volume "
+ "quota <VOLNAME> disable' instead.",
+ key, value);
+ ret = -1;
+ goto out;
+ }
+ } else if ((strcmp (key, "inode-quota") == 0) ||
+ (strcmp (key, "features.inode-quota") == 0)) {
+ ret = gf_string2boolean (value, &b);
+ if (ret)
+ goto out;
+ if (b) {
+ snprintf (errstr, size, " 'gluster "
+ "volume set <VOLNAME> %s %s' is "
+ "deprecated. Use 'gluster volume "
+ "inode-quota <VOLNAME> enable' instead.",
+ key, value);
+ ret = -1;
+ goto out;
} else {
- snprintf (errstr, size, " 'gluster "
- "volume set <VOLNAME> %s %s' is "
- "deprecated. Use 'gluster volume "
- "quota <VOLNAME> disable' instead.",
- key, value);
- ret = -1;
- goto out;
+ /* inode-quota disable not supported,
+ * use quota disable
+ */
+ snprintf (errstr, size, " 'gluster "
+ "volume set <VOLNAME> %s %s' is "
+ "deprecated. Use 'gluster volume "
+ "quota <VOLNAME> disable' instead.",
+ key, value);
+ ret = -1;
+ goto out;
}
}
+
ret = 0;
out:
return ret;
diff --git a/xlators/mgmt/glusterd/src/glusterd-quota.c b/xlators/mgmt/glusterd/src/glusterd-quota.c
index 9f2aa8ec9de..adf6662afae 100644
--- a/xlators/mgmt/glusterd/src/glusterd-quota.c
+++ b/xlators/mgmt/glusterd/src/glusterd-quota.c
@@ -58,6 +58,7 @@ const char *gd_quota_op_list[GF_QUOTA_OPTION_TYPE_MAX + 1] = {
[GF_QUOTA_OPTION_TYPE_LIMIT_OBJECTS] = "limit-objects",
[GF_QUOTA_OPTION_TYPE_LIST_OBJECTS] = "list-objects",
[GF_QUOTA_OPTION_TYPE_REMOVE_OBJECTS] = "remove-objects",
+ [GF_QUOTA_OPTION_TYPE_ENABLE_OBJECTS] = "enable-objects",
[GF_QUOTA_OPTION_TYPE_MAX] = NULL
};
@@ -266,7 +267,8 @@ glusterd_quota_initiate_fs_crawl (glusterd_conf_t *priv, char *volname,
}
runinit (&runner);
- if (type == GF_QUOTA_OPTION_TYPE_ENABLE)
+ if (type == GF_QUOTA_OPTION_TYPE_ENABLE ||
+ type == GF_QUOTA_OPTION_TYPE_ENABLE_OBJECTS)
runner_add_args (&runner, "/usr/bin/find", ".",
"-exec", "/usr/bin/stat",
"{}", "\\", ";", NULL);
@@ -348,11 +350,66 @@ out:
}
int32_t
+glusterd_inode_quota_enable (glusterd_volinfo_t *volinfo, char **op_errstr,
+ gf_boolean_t *crawl)
+{
+ int32_t ret = -1;
+ xlator_t *this = NULL;
+
+ this = THIS;
+ GF_ASSERT (this);
+
+ GF_VALIDATE_OR_GOTO (this->name, volinfo, out);
+ GF_VALIDATE_OR_GOTO (this->name, crawl, out);
+ GF_VALIDATE_OR_GOTO (this->name, op_errstr, out);
+
+ if (glusterd_is_volume_started (volinfo) == 0) {
+ *op_errstr = gf_strdup ("Volume is stopped, start volume "
+ "to enable inode quota.");
+ ret = -1;
+ goto out;
+ }
+
+ ret = glusterd_check_if_quota_trans_enabled (volinfo);
+ if (ret != 0) {
+ *op_errstr = gf_strdup ("Quota is disabled. Enabling quota "
+ "will enable inode quota");
+ ret = -1;
+ goto out;
+ }
+
+ if (glusterd_is_volume_inode_quota_enabled (volinfo)) {
+ *op_errstr = gf_strdup ("Inode Quota is already enabled");
+ ret = -1;
+ goto out;
+ }
+
+ ret = dict_set_dynstr_with_alloc (volinfo->dict,
+ VKEY_FEATURES_INODE_QUOTA, "on");
+ if (ret) {
+ gf_log (this->name, GF_LOG_ERROR, "dict set failed");
+ goto out;
+ }
+
+ *crawl = _gf_true;
+
+ ret = glusterd_store_quota_config (volinfo, NULL, NULL,
+ GF_QUOTA_OPTION_TYPE_ENABLE_OBJECTS,
+ op_errstr);
+
+ ret = 0;
+out:
+ if (ret && op_errstr && !*op_errstr)
+ gf_asprintf (op_errstr, "Enabling inode quota on volume %s has "
+ "been unsuccessful", volinfo->volname);
+ return ret;
+}
+
+int32_t
glusterd_quota_enable (glusterd_volinfo_t *volinfo, char **op_errstr,
gf_boolean_t *crawl)
{
int32_t ret = -1;
- char *quota_status = NULL;
xlator_t *this = NULL;
this = THIS;
@@ -376,15 +433,15 @@ glusterd_quota_enable (glusterd_volinfo_t *volinfo, char **op_errstr,
goto out;
}
- quota_status = gf_strdup ("on");
- if (!quota_status) {
- gf_log (this->name, GF_LOG_ERROR, "memory allocation failed");
- ret = -1;
+ ret = dict_set_dynstr_with_alloc (volinfo->dict, VKEY_FEATURES_QUOTA,
+ "on");
+ if (ret) {
+ gf_log (this->name, GF_LOG_ERROR, "dict set failed");
goto out;
}
- ret = dict_set_dynstr (volinfo->dict, VKEY_FEATURES_QUOTA,
- quota_status);
+ ret = dict_set_dynstr_with_alloc (volinfo->dict,
+ VKEY_FEATURES_INODE_QUOTA, "on");
if (ret) {
gf_log (this->name, GF_LOG_ERROR, "dict set failed");
goto out;
@@ -410,7 +467,6 @@ glusterd_quota_disable (glusterd_volinfo_t *volinfo, char **op_errstr,
{
int32_t ret = -1;
int i = 0;
- char *quota_status = NULL;
char *value = NULL;
xlator_t *this = NULL;
glusterd_conf_t *conf = NULL;
@@ -435,14 +491,15 @@ glusterd_quota_disable (glusterd_volinfo_t *volinfo, char **op_errstr,
goto out;
}
- quota_status = gf_strdup ("off");
- if (!quota_status) {
- gf_log (this->name, GF_LOG_ERROR, "memory allocation failed");
- ret = -1;
+ ret = dict_set_dynstr_with_alloc (volinfo->dict, VKEY_FEATURES_QUOTA,
+ "off");
+ if (ret) {
+ gf_log (this->name, GF_LOG_ERROR, "dict set failed");
goto out;
}
- ret = dict_set_dynstr (volinfo->dict, VKEY_FEATURES_QUOTA, quota_status);
+ ret = dict_set_dynstr_with_alloc (volinfo->dict,
+ VKEY_FEATURES_INODE_QUOTA, "off");
if (ret) {
gf_log (this->name, GF_LOG_ERROR, "dict set failed");
goto out;
@@ -793,7 +850,8 @@ glusterd_store_quota_config (glusterd_volinfo_t *volinfo, char *path,
goto out;
/* Just create empty quota.conf file if create */
- if (GF_QUOTA_OPTION_TYPE_ENABLE == opcode) {
+ if (GF_QUOTA_OPTION_TYPE_ENABLE == opcode ||
+ GF_QUOTA_OPTION_TYPE_ENABLE_OBJECTS == opcode) {
modified = _gf_true;
goto out;
}
@@ -1251,6 +1309,13 @@ glusterd_op_quota (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
goto out;
break;
+ case GF_QUOTA_OPTION_TYPE_ENABLE_OBJECTS:
+ ret = glusterd_inode_quota_enable (volinfo, op_errstr,
+ &start_crawl);
+ if (ret < 0)
+ goto out;
+ break;
+
case GF_QUOTA_OPTION_TYPE_DISABLE:
ret = glusterd_quota_disable (volinfo, op_errstr,
&start_crawl);
@@ -1563,6 +1628,16 @@ glusterd_op_stage_quota (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
goto out;
}
+ if (type > GF_QUOTA_OPTION_TYPE_VERSION_OBJECTS) {
+ if (!glusterd_is_volume_inode_quota_enabled (volinfo) &&
+ type != GF_QUOTA_OPTION_TYPE_ENABLE_OBJECTS) {
+ *op_errstr = gf_strdup ("Inode Quota is disabled, "
+ "please enable inode quota");
+ ret = -1;
+ goto out;
+ }
+ }
+
if (!glusterd_is_quota_supported (type, op_errstr)) {
ret = -1;
goto out;
@@ -1578,6 +1653,7 @@ glusterd_op_stage_quota (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
switch (type) {
case GF_QUOTA_OPTION_TYPE_ENABLE:
+ case GF_QUOTA_OPTION_TYPE_ENABLE_OBJECTS:
case GF_QUOTA_OPTION_TYPE_LIST:
case GF_QUOTA_OPTION_TYPE_LIST_OBJECTS:
/* Fuse mount req. only for enable & list-usage options*/
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index 29032e2d679..f532a9c4714 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -8641,6 +8641,13 @@ glusterd_is_volume_quota_enabled (glusterd_volinfo_t *volinfo)
}
int
+glusterd_is_volume_inode_quota_enabled (glusterd_volinfo_t *volinfo)
+{
+ return (glusterd_volinfo_get_boolean (volinfo,
+ VKEY_FEATURES_INODE_QUOTA));
+}
+
+int
glusterd_is_bitrot_enabled (glusterd_volinfo_t *volinfo)
{
return glusterd_volinfo_get_boolean (volinfo, VKEY_FEATURES_BITROT);
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.h b/xlators/mgmt/glusterd/src/glusterd-utils.h
index e70a793363c..689ba9ae751 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.h
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.h
@@ -514,6 +514,9 @@ int
glusterd_is_volume_quota_enabled (glusterd_volinfo_t *volinfo);
int
+glusterd_is_volume_inode_quota_enabled (glusterd_volinfo_t *volinfo);
+
+int
glusterd_is_bitrot_enabled (glusterd_volinfo_t *volinfo);
gf_boolean_t
diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.h b/xlators/mgmt/glusterd/src/glusterd-volgen.h
index 4575049ada9..571a13c02f4 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volgen.h
+++ b/xlators/mgmt/glusterd/src/glusterd-volgen.h
@@ -32,6 +32,7 @@
#define VKEY_MARKER_XTIME_FORCE GEOREP".ignore-pid-check"
#define VKEY_CHANGELOG "changelog.changelog"
#define VKEY_FEATURES_QUOTA "features.quota"
+#define VKEY_FEATURES_INODE_QUOTA "features.inode-quota"
#define VKEY_FEATURES_TRASH "features.trash"
#define VKEY_FEATURES_BITROT "features.bitrot"
#define VKEY_FEATURES_SCRUB "features.scrub"
diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-set.c b/xlators/mgmt/glusterd/src/glusterd-volume-set.c
index b5e65f00a0b..02d59eddf5d 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volume-set.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volume-set.c
@@ -1300,6 +1300,14 @@ struct volopt_map_entry glusterd_volopt_map[] = {
.flags = OPT_FLAG_FORCE,
.op_version = 1
},
+ { .key = VKEY_FEATURES_INODE_QUOTA,
+ .voltype = "features/marker",
+ .option = "inode-quota",
+ .value = "off",
+ .type = NO_DOC,
+ .flags = OPT_FLAG_FORCE,
+ .op_version = 1
+ },
{ .key = VKEY_FEATURES_BITROT,
.voltype = "features/bitrot",