|
|
cb8e9e |
From 27a3fd3e46dcfd46f81a5989789313e1bc78da19 Mon Sep 17 00:00:00 2001
|
|
|
cb8e9e |
From: Mohammed Rafi KC <rkavunga@redhat.com>
|
|
|
cb8e9e |
Date: Mon, 11 May 2015 14:43:23 +0530
|
|
|
cb8e9e |
Subject: [PATCH 119/129] tier/volume set: Validate volume set option for tier
|
|
|
cb8e9e |
|
|
|
cb8e9e |
Backport of http://review.gluster.org/#/c/10751/
|
|
|
cb8e9e |
|
|
|
cb8e9e |
Volume set option related to tier volume can only be set
|
|
|
cb8e9e |
for tier volume, also currently all volume set i for tier
|
|
|
cb8e9e |
option accepts a non-negative integer. This patch validate
|
|
|
cb8e9e |
both condition.
|
|
|
cb8e9e |
|
|
|
cb8e9e |
Change-Id: I3611af048ff4ab193544058cace8db205ea92336
|
|
|
cb8e9e |
BUG: 1216960
|
|
|
cb8e9e |
Signed-off-by: Joseph Fernandes <josferna@redhat.com>
|
|
|
cb8e9e |
Reviewed-on: https://code.engineering.redhat.com/gerrit/50617
|
|
|
cb8e9e |
Reviewed-by: Dan Lambright <dlambrig@redhat.com>
|
|
|
cb8e9e |
Tested-by: Dan Lambright <dlambrig@redhat.com>
|
|
|
cb8e9e |
---
|
|
|
cb8e9e |
tests/basic/tier/tier.t | 21 ++++--
|
|
|
cb8e9e |
xlators/mgmt/glusterd/src/glusterd-volume-set.c | 82 +++++++++++++++++++++-
|
|
|
cb8e9e |
2 files changed, 93 insertions(+), 10 deletions(-)
|
|
|
cb8e9e |
|
|
|
cb8e9e |
diff --git a/tests/basic/tier/tier.t b/tests/basic/tier/tier.t
|
|
|
cb8e9e |
index 2a5f748..bec34ef 100755
|
|
|
cb8e9e |
--- a/tests/basic/tier/tier.t
|
|
|
cb8e9e |
+++ b/tests/basic/tier/tier.t
|
|
|
cb8e9e |
@@ -52,8 +52,6 @@ function confirm_vol_stopped {
|
|
|
cb8e9e |
fi
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
-LAST_BRICK=1
|
|
|
cb8e9e |
-CACHE_BRICK=2
|
|
|
cb8e9e |
DEMOTE_TIMEOUT=12
|
|
|
cb8e9e |
PROMOTE_TIMEOUT=5
|
|
|
cb8e9e |
MIGRATION_TIMEOUT=10
|
|
|
cb8e9e |
@@ -67,16 +65,27 @@ TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}{0..$LAST_BRICK}
|
|
|
cb8e9e |
TEST ! $CLI volume attach-tier $V0 replica 5 $H0:$B0/${V0}$CACHE_BRICK_FIRST $H0:$B0/${V0}$CACHE_BRICK_LAST
|
|
|
cb8e9e |
|
|
|
cb8e9e |
TEST $CLI volume start $V0
|
|
|
cb8e9e |
-TEST $CLI volume set $V0 cluster.tier-demote-frequency 4
|
|
|
cb8e9e |
-TEST $CLI volume set $V0 cluster.tier-promote-frequency 4
|
|
|
cb8e9e |
-TEST $CLI volume set $V0 cluster.read-freq-threshold 0
|
|
|
cb8e9e |
-TEST $CLI volume set $V0 cluster.write-freq-threshold 0
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
TEST $CLI volume set $V0 performance.quick-read off
|
|
|
cb8e9e |
TEST $CLI volume set $V0 performance.io-cache off
|
|
|
cb8e9e |
TEST $CLI volume set $V0 features.ctr-enabled on
|
|
|
cb8e9e |
|
|
|
cb8e9e |
+#Not a tier volume
|
|
|
cb8e9e |
+TEST ! $CLI volume set $V0 cluster.tier-demote-frequency 4
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
TEST $CLI volume attach-tier $V0 replica 2 $H0:$B0/${V0}$CACHE_BRICK_FIRST $H0:$B0/${V0}$CACHE_BRICK_LAST
|
|
|
cb8e9e |
|
|
|
cb8e9e |
+#Tier options expect non-negative value
|
|
|
cb8e9e |
+TEST ! $CLI volume set $V0 cluster.tier-promote-frequency -1
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+#Tier options expect non-negative value
|
|
|
cb8e9e |
+TEST ! $CLI volume set $V0 cluster.read-freq-threshold qwerty
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+TEST $CLI volume set $V0 cluster.tier-demote-frequency 4
|
|
|
cb8e9e |
+TEST $CLI volume set $V0 cluster.tier-promote-frequency 4
|
|
|
cb8e9e |
+TEST $CLI volume set $V0 cluster.read-freq-threshold 0
|
|
|
cb8e9e |
+TEST $CLI volume set $V0 cluster.write-freq-threshold 0
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
TEST $GFS --volfile-id=/$V0 --volfile-server=$H0 $M0;
|
|
|
cb8e9e |
|
|
|
cb8e9e |
# Basic operations.
|
|
|
cb8e9e |
diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-set.c b/xlators/mgmt/glusterd/src/glusterd-volume-set.c
|
|
|
cb8e9e |
index 415bc01..34c9fc5 100644
|
|
|
cb8e9e |
--- a/xlators/mgmt/glusterd/src/glusterd-volume-set.c
|
|
|
cb8e9e |
+++ b/xlators/mgmt/glusterd/src/glusterd-volume-set.c
|
|
|
cb8e9e |
@@ -17,6 +17,76 @@
|
|
|
cb8e9e |
#include "glusterd-utils.h"
|
|
|
cb8e9e |
|
|
|
cb8e9e |
static int
|
|
|
cb8e9e |
+validate_tier (glusterd_volinfo_t *volinfo, dict_t *dict, char *key,
|
|
|
cb8e9e |
+ char *value, char **op_errstr)
|
|
|
cb8e9e |
+{
|
|
|
cb8e9e |
+ char errstr[2048] = "";
|
|
|
cb8e9e |
+ int ret = 0;
|
|
|
cb8e9e |
+ xlator_t *this = NULL;
|
|
|
cb8e9e |
+ int origin_val = -1;
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+ this = THIS;
|
|
|
cb8e9e |
+ GF_ASSERT (this);
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+ if (volinfo->type != GF_CLUSTER_TYPE_TIER) {
|
|
|
cb8e9e |
+ snprintf (errstr, sizeof (errstr), "Volume %s is not a tier "
|
|
|
cb8e9e |
+ "volume. Option %s is only valid for tier volume.",
|
|
|
cb8e9e |
+ volinfo->volname, key);
|
|
|
cb8e9e |
+ gf_log (this->name, GF_LOG_ERROR, "%s", errstr);
|
|
|
cb8e9e |
+ *op_errstr = gf_strdup (errstr);
|
|
|
cb8e9e |
+ ret = -1;
|
|
|
cb8e9e |
+ goto out;
|
|
|
cb8e9e |
+ }
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+ /*
|
|
|
cb8e9e |
+ * All the volume set options for tier are expecting a positive
|
|
|
cb8e9e |
+ * Integer. Change the function accordingly if this constraint is
|
|
|
cb8e9e |
+ * changed.
|
|
|
cb8e9e |
+ */
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+ ret = gf_string2int (value, &origin_val);
|
|
|
cb8e9e |
+ if (ret) {
|
|
|
cb8e9e |
+ snprintf (errstr, sizeof (errstr), "%s is not a compatible "
|
|
|
cb8e9e |
+ "value. %s expects an integer value.",
|
|
|
cb8e9e |
+ value, key);
|
|
|
cb8e9e |
+ gf_log (this->name, GF_LOG_ERROR, "%s", errstr);
|
|
|
cb8e9e |
+ *op_errstr = gf_strdup (errstr);
|
|
|
cb8e9e |
+ ret = -1;
|
|
|
cb8e9e |
+ goto out;
|
|
|
cb8e9e |
+ }
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+ if (strstr ("cluster.tier-promote-frequency", key) ||
|
|
|
cb8e9e |
+ strstr ("cluster.tier-demote-frequency", key)) {
|
|
|
cb8e9e |
+ if (origin_val < 1) {
|
|
|
cb8e9e |
+ snprintf (errstr, sizeof (errstr), "%s is not a "
|
|
|
cb8e9e |
+ "compatible value. %s expects a positive "
|
|
|
cb8e9e |
+ "integer value.",
|
|
|
cb8e9e |
+ value, key);
|
|
|
cb8e9e |
+ gf_log (this->name, GF_LOG_ERROR, "%s", errstr);
|
|
|
cb8e9e |
+ *op_errstr = gf_strdup (errstr);
|
|
|
cb8e9e |
+ ret = -1;
|
|
|
cb8e9e |
+ goto out;
|
|
|
cb8e9e |
+ }
|
|
|
cb8e9e |
+ } else {
|
|
|
cb8e9e |
+ if (origin_val < 0) {
|
|
|
cb8e9e |
+ snprintf (errstr, sizeof (errstr), "%s is not a "
|
|
|
cb8e9e |
+ "compatible value. %s expects a non-negative"
|
|
|
cb8e9e |
+ " integer value.",
|
|
|
cb8e9e |
+ value, key);
|
|
|
cb8e9e |
+ gf_log (this->name, GF_LOG_ERROR, "%s", errstr);
|
|
|
cb8e9e |
+ *op_errstr = gf_strdup (errstr);
|
|
|
cb8e9e |
+ ret = -1;
|
|
|
cb8e9e |
+ goto out;
|
|
|
cb8e9e |
+ }
|
|
|
cb8e9e |
+ }
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+out:
|
|
|
cb8e9e |
+ gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret);
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+ return ret;
|
|
|
cb8e9e |
+}
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+static int
|
|
|
cb8e9e |
validate_cache_max_min_size (glusterd_volinfo_t *volinfo, dict_t *dict,
|
|
|
cb8e9e |
char *key, char *value, char **op_errstr)
|
|
|
cb8e9e |
{
|
|
|
cb8e9e |
@@ -1764,25 +1834,29 @@ struct volopt_map_entry glusterd_volopt_map[] = {
|
|
|
cb8e9e |
.voltype = "cluster/tier",
|
|
|
cb8e9e |
.option = "write-freq-threshold",
|
|
|
cb8e9e |
.op_version = GD_OP_VERSION_3_7_0,
|
|
|
cb8e9e |
- .flags = OPT_FLAG_CLIENT_OPT
|
|
|
cb8e9e |
+ .flags = OPT_FLAG_CLIENT_OPT,
|
|
|
cb8e9e |
+ .validate_fn = validate_tier
|
|
|
cb8e9e |
},
|
|
|
cb8e9e |
{ .key = "cluster.read-freq-threshold",
|
|
|
cb8e9e |
.voltype = "cluster/tier",
|
|
|
cb8e9e |
.option = "read-freq-threshold",
|
|
|
cb8e9e |
.op_version = GD_OP_VERSION_3_7_0,
|
|
|
cb8e9e |
- .flags = OPT_FLAG_CLIENT_OPT
|
|
|
cb8e9e |
+ .flags = OPT_FLAG_CLIENT_OPT,
|
|
|
cb8e9e |
+ .validate_fn = validate_tier
|
|
|
cb8e9e |
},
|
|
|
cb8e9e |
{ .key = "cluster.tier-promote-frequency",
|
|
|
cb8e9e |
.voltype = "cluster/tier",
|
|
|
cb8e9e |
.option = "tier-promote-frequency",
|
|
|
cb8e9e |
.op_version = GD_OP_VERSION_3_7_0,
|
|
|
cb8e9e |
- .flags = OPT_FLAG_CLIENT_OPT
|
|
|
cb8e9e |
+ .flags = OPT_FLAG_CLIENT_OPT,
|
|
|
cb8e9e |
+ .validate_fn = validate_tier
|
|
|
cb8e9e |
},
|
|
|
cb8e9e |
{ .key = "cluster.tier-demote-frequency",
|
|
|
cb8e9e |
.voltype = "cluster/tier",
|
|
|
cb8e9e |
.option = "tier-demote-frequency",
|
|
|
cb8e9e |
.op_version = GD_OP_VERSION_3_7_0,
|
|
|
cb8e9e |
- .flags = OPT_FLAG_CLIENT_OPT
|
|
|
cb8e9e |
+ .flags = OPT_FLAG_CLIENT_OPT,
|
|
|
cb8e9e |
+ .validate_fn = validate_tier
|
|
|
cb8e9e |
},
|
|
|
cb8e9e |
{ .key = "features.ctr-enabled",
|
|
|
cb8e9e |
.voltype = "features/changetimerecorder",
|
|
|
cb8e9e |
--
|
|
|
cb8e9e |
1.7.1
|
|
|
cb8e9e |
|