summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--xlators/features/marker/src/marker-quota.c30
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-quota.c88
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-store.c8
3 files changed, 99 insertions, 27 deletions
diff --git a/xlators/features/marker/src/marker-quota.c b/xlators/features/marker/src/marker-quota.c
index bcec2969..26ad0fa5 100644
--- a/xlators/features/marker/src/marker-quota.c
+++ b/xlators/features/marker/src/marker-quota.c
@@ -1040,8 +1040,10 @@ mq_create_xattr (xlator_t *this, call_frame_t *frame)
}
if ((local->loc.path && strcmp (local->loc.path, "/") != 0)
- || (local->loc.parent && !__is_root_gfid (local->loc.parent->gfid))
- || (!__is_root_gfid (local->loc.pargfid))) {
+ || (local->loc.inode && !uuid_is_null (local->loc.inode->gfid) &&
+ !__is_root_gfid (local->loc.inode->gfid))
+ || (!uuid_is_null (local->loc.gfid)
+ && !__is_root_gfid (local->loc.gfid))) {
contri = mq_add_new_contribution_node (this, ctx, &local->loc);
if (contri == NULL)
goto err;
@@ -1111,11 +1113,11 @@ mq_check_n_set_inode_xattr (call_frame_t *frame, void *cookie,
//check contribution xattr if not root
if ((local->loc.path && strcmp (local->loc.path, "/") != 0)
- || (!uuid_is_null (local->loc.pargfid)
- && !__is_root_gfid (local->loc.pargfid))
- || (local->loc.parent
- && !uuid_is_null (local->loc.parent->gfid)
- && !__is_root_gfid (local->loc.parent->gfid))) {
+ || (!uuid_is_null (local->loc.gfid)
+ && !__is_root_gfid (local->loc.gfid))
+ || (local->loc.inode
+ && !uuid_is_null (local->loc.inode->gfid)
+ && !__is_root_gfid (local->loc.inode->gfid))) {
GET_CONTRI_KEY (contri_key, local->loc.parent->gfid, ret);
if (ret < 0)
goto out;
@@ -2044,10 +2046,10 @@ mq_initiate_quota_txn (xlator_t *this, loc_t *loc)
contribution = mq_get_contribution_node (loc->parent, ctx);
if (!contribution) {
if ((loc->path && strcmp (loc->path, "/"))
- || (!uuid_is_null (loc->pargfid)
- && !__is_root_gfid (loc->pargfid))
- || (loc->parent && !uuid_is_null (loc->parent->gfid)
- && !__is_root_gfid (loc->parent->gfid)))
+ || (!uuid_is_null (loc->gfid)
+ && !__is_root_gfid (loc->gfid))
+ || (loc->inode && !uuid_is_null (loc->inode->gfid)
+ && !__is_root_gfid (loc->inode->gfid)))
gf_log_callingfn (this->name, GF_LOG_TRACE,
"contribution node for the "
"path (%s) with parent (%s) "
@@ -2139,9 +2141,9 @@ mq_inspect_directory_xattr (xlator_t *this,
goto out;
if ((loc->path && strcmp (loc->path, "/") != 0)
- || (!uuid_is_null (loc->pargfid) && !__is_root_gfid (loc->pargfid))
- || (loc->parent && !uuid_is_null (loc->parent->gfid) &&
- !__is_root_gfid (loc->parent->gfid))) {
+ || (!uuid_is_null (loc->gfid) && !__is_root_gfid (loc->gfid))
+ || (loc->inode && !uuid_is_null (loc->inode->gfid) &&
+ !__is_root_gfid (loc->inode->gfid))) {
not_root = _gf_true;
GET_CONTRI_KEY (contri_key, contribution->gfid, ret);
diff --git a/xlators/mgmt/glusterd/src/glusterd-quota.c b/xlators/mgmt/glusterd/src/glusterd-quota.c
index e4c654b9..c2d37b03 100644
--- a/xlators/mgmt/glusterd/src/glusterd-quota.c
+++ b/xlators/mgmt/glusterd/src/glusterd-quota.c
@@ -105,8 +105,8 @@ __glusterd_handle_quota (rpcsvc_request_t *req)
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 1. Executing command "
- "%s is disallowed in this state",
+ "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;
@@ -1109,8 +1109,8 @@ glusterd_op_quota (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
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. Option %s "
- "is disallowed in this state.",
+ "operating at version %d. Quota command"
+ " %s is unavailable in this version.",
priv->op_version,
gd_quota_op_list[type]);
ret = -1;
@@ -1321,14 +1321,28 @@ int
glusterd_op_stage_quota (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
{
int ret = 0;
+ int type = 0;
+ int i = 0;
char *volname = NULL;
+ char *value = NULL;
gf_boolean_t exists = _gf_false;
- int type = 0;
dict_t *ctx = NULL;
+ dict_t *tmp_dict = NULL;
xlator_t *this = NULL;
glusterd_conf_t *priv = NULL;
glusterd_volinfo_t *volinfo = NULL;
+ struct {
+ int opcode;
+ char *key;
+ } optable[] = {
+ {GF_QUOTA_OPTION_TYPE_ALERT_TIME,
+ "features.alert-time"},
+ {GF_QUOTA_OPTION_TYPE_SOFT_TIMEOUT, "features.soft-timeout"},
+ {GF_QUOTA_OPTION_TYPE_HARD_TIMEOUT, "features.hard-timeout"},
+ {GF_QUOTA_OPTION_TYPE_NONE, NULL}
+ };
+
this = THIS;
GF_ASSERT (this);
priv = this->private;
@@ -1337,6 +1351,10 @@ glusterd_op_stage_quota (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
GF_ASSERT (dict);
GF_ASSERT (op_errstr);
+ tmp_dict = dict_new ();
+ if (!tmp_dict)
+ goto out;
+
ret = dict_get_str (dict, "volname", &volname);
if (ret) {
gf_log (this->name, GF_LOG_ERROR, "Unable to get volume name");
@@ -1355,6 +1373,12 @@ glusterd_op_stage_quota (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
goto out;
}
+ if (!glusterd_is_volume_started (volinfo)) {
+ *op_errstr = gf_strdup ("Volume is stopped, start volume "
+ "before executing quota command.");
+ ret = -1;
+ goto out;
+ }
ret = dict_get_int32 (dict, "type", &type);
if (ret) {
@@ -1363,11 +1387,19 @@ glusterd_op_stage_quota (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
goto out;
}
+ if ((!glusterd_is_volume_quota_enabled (volinfo)) &&
+ (type != GF_QUOTA_OPTION_TYPE_ENABLE)) {
+ *op_errstr = gf_strdup ("Quota is disabled, please enable "
+ "quota");
+ ret = -1;
+ 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. Option %s "
- "is disallowed in this state.",
+ "operating at version %d. Quota command"
+ " %s is unavailable in this version.",
priv->op_version,
gd_quota_op_list[type]);
ret = -1;
@@ -1385,16 +1417,46 @@ glusterd_op_stage_quota (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
}
}
- if (type == GF_QUOTA_OPTION_TYPE_LIMIT_USAGE ||
- type == GF_QUOTA_OPTION_TYPE_REMOVE) {
- ret = glusterd_get_gfid_from_brick (dict, volinfo, rsp_dict,
- op_errstr);
- if (ret)
- goto out;
+ switch (type) {
+ case GF_QUOTA_OPTION_TYPE_LIMIT_USAGE:
+ case GF_QUOTA_OPTION_TYPE_REMOVE:
+ ret = glusterd_get_gfid_from_brick (dict, volinfo,
+ rsp_dict,
+ op_errstr);
+ if (ret)
+ goto out;
+ break;
+
+ case GF_QUOTA_OPTION_TYPE_ALERT_TIME:
+ case GF_QUOTA_OPTION_TYPE_SOFT_TIMEOUT:
+ case GF_QUOTA_OPTION_TYPE_HARD_TIMEOUT:
+ ret = dict_get_str (dict, "value", &value);
+ if (ret)
+ goto out;
+
+ for (i = 0; optable[i].key; i++) {
+ if (type == optable[i].opcode)
+ break;
+ }
+ ret = dict_set_str (tmp_dict, optable[i].key, value);
+ if (ret)
+ goto out;
+
+ ret = glusterd_validate_reconfopts (volinfo, tmp_dict,
+ op_errstr);
+ if (ret)
+ goto out;
+ break;
+
+ default:
+ ret = 0;
}
+
ret = 0;
out:
+ if (tmp_dict)
+ dict_unref (tmp_dict);
if (ret && op_errstr && *op_errstr)
gf_log (this->name, GF_LOG_ERROR, "%s", *op_errstr);
gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret);
diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c
index db0829bb..591aba68 100644
--- a/xlators/mgmt/glusterd/src/glusterd-store.c
+++ b/xlators/mgmt/glusterd/src/glusterd-store.c
@@ -1906,6 +1906,14 @@ glusterd_store_retrieve_volume (char *volname)
break;
case 1:
+ /*The following strcmp check is to ensure that
+ * glusterd does not restore the quota limits
+ * into volinfo->dict post upgradation from 3.3
+ * to 3.4 as the same limits will now be stored
+ * in xattrs on the respective directories.
+ */
+ if (!strcmp (key, "features.limit-usage"))
+ break;
ret = dict_set_str(volinfo->dict, key,
gf_strdup (value));
if (ret) {