summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVijay Bellur <vbellur@redhat.com>2013-08-19 00:10:52 +0530
committerVijay Bellur <vbellur@redhat.com>2013-08-19 00:15:17 +0530
commit5734c34be2ef046de1f717e59c931fb55e594d8a (patch)
tree6efa367fdbfe6f9cbaf5b4c95fa24c03c511f0df
parenta1faa636f17dba05377c34c5ca06f8ac95a1645e (diff)
mgmt/glusterd: Correct auto variable initialization.
Previously struct foo { int a; int b; } bar1, bar2 = {0,}; inited only members of bar2 to 0. This has been set right. Also added verification tests for soft-quota configuration. Change-Id: I9e3b4d65286e59d7dad8db8fa649b1b91a5d25bc Signed-off-by: Vijay Bellur <vbellur@redhat.com>
-rwxr-xr-xtests/basic/quota.t18
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-quota.c7
2 files changed, 18 insertions, 7 deletions
diff --git a/tests/basic/quota.t b/tests/basic/quota.t
index 999b2a23..8d222829 100755
--- a/tests/basic/quota.t
+++ b/tests/basic/quota.t
@@ -11,12 +11,18 @@ TEST $CLI volume info;
TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}{1,2,3,4};
-function limit_on()
+function hard_limit()
{
local QUOTA_PATH=$1;
$CLI volume quota $V0 list $QUOTA_PATH | grep "$QUOTA_PATH" | awk '{print $2}'
}
+function soft_limit()
+{
+ local QUOTA_PATH=$1;
+ $CLI volume quota $V0 list $QUOTA_PATH | grep "$QUOTA_PATH" | awk '{print $3}'
+}
+
function usage()
{
local QUOTA_PATH=$1;
@@ -43,14 +49,16 @@ TEST $CLI volume quota $V0 limit-usage /test_dir 100MB
TEST $CLI volume quota $V0 limit-usage /test_dir/in_test_dir 150MB
-EXPECT "150.0MB" limit_on "/test_dir/in_test_dir";
+EXPECT "150.0MB" hard_limit "/test_dir/in_test_dir";
+EXPECT "80%" soft_limit "/test_dir/in_test_dir";
TEST $CLI volume quota $V0 remove /test_dir/in_test_dir
-EXPECT "100.0MB" limit_on "/test_dir";
+EXPECT "100.0MB" hard_limit "/test_dir";
TEST $CLI volume quota $V0 limit-usage /test_dir 10MB
-EXPECT "10.0MB" limit_on "/test_dir";
+EXPECT "10.0MB" hard_limit "/test_dir";
+EXPECT "80%" soft_limit "/test_dir";
TEST $CLI volume quota $V0 soft-timeout 0
TEST $CLI volume quota $V0 hard-timeout 0
@@ -91,7 +99,7 @@ TEST $CLI volume quota $V0 limit-usage /test_dir 100MB
TEST $CLI volume quota $V0 limit-usage /test_dir/in_test_dir 150MB
-EXPECT "150.0MB" limit_on "/test_dir/in_test_dir";
+EXPECT "150.0MB" hard_limit "/test_dir/in_test_dir";
## -----------------------------
TEST $CLI volume quota $V0 disable
diff --git a/xlators/mgmt/glusterd/src/glusterd-quota.c b/xlators/mgmt/glusterd/src/glusterd-quota.c
index 0592585d..1be768af 100644
--- a/xlators/mgmt/glusterd/src/glusterd-quota.c
+++ b/xlators/mgmt/glusterd/src/glusterd-quota.c
@@ -604,10 +604,13 @@ glusterd_set_quota_limit (char *volname, char *path, char *hard_limit,
* OR
* change the data-types of hard_lim and soft_lim_percent to uint64_t
*/
- struct quota_limits {
+ typedef struct quota_limits {
uint64_t hl;
uint64_t sl;
- } __attribute__ ((__packed__)) existing_limit, new_limit = {0,};
+ } __attribute__ ((__packed__)) quota_limits_t;
+
+ quota_limits_t existing_limit = {0,};
+ quota_limits_t new_limit = {0,};
this = THIS;
GF_ASSERT (this);