diff options
-rw-r--r-- | tests/bugs/quota/bug-1293601.t | 35 | ||||
-rw-r--r-- | xlators/features/marker/src/marker.c | 27 |
2 files changed, 58 insertions, 4 deletions
diff --git a/tests/bugs/quota/bug-1293601.t b/tests/bugs/quota/bug-1293601.t new file mode 100644 index 00000000000..9b8a13a61e5 --- /dev/null +++ b/tests/bugs/quota/bug-1293601.t @@ -0,0 +1,35 @@ +#!/bin/bash + +. $(dirname $0)/../../include.rc +. $(dirname $0)/../../volume.rc + +cleanup; +TESTS_EXPECTED_IN_LOOP=1044 + +TEST glusterd +TEST pidof glusterd + +TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}{1,2,3,4} +TEST $CLI volume start $V0 +TEST $CLI volume quota $V0 enable +TEST $CLI volume quota $V0 limit-usage / 2MB + +TEST glusterfs --volfile-server=$H0 --volfile-id=$V0 $M0; + +for i in {1..1024}; do + TEST_IN_LOOP dd if=/dev/zero of=$M0/f$i bs=1k count=1 +done + +EXPECT_WITHIN $MARKER_UPDATE_TIMEOUT "1.0MB" quotausage "/" + +for i in {1..10}; do + TEST_IN_LOOP $CLI volume quota $V0 disable + TEST_IN_LOOP $CLI volume quota $V0 enable +done + +TEST $CLI volume quota $V0 limit-usage / 2MB +EXPECT_WITHIN $MARKER_UPDATE_TIMEOUT "1.0MB" quotausage "/" + +TEST $CLI volume stop $V0 +TEST $CLI volume delete $V0 +cleanup; diff --git a/xlators/features/marker/src/marker.c b/xlators/features/marker/src/marker.c index 604097d2f2e..54dc395d462 100644 --- a/xlators/features/marker/src/marker.c +++ b/xlators/features/marker/src/marker.c @@ -2299,10 +2299,29 @@ out: int remove_quota_keys (dict_t *dict, char *k, data_t *v, void *data) { - call_frame_t *frame = data; - marker_local_t *local = frame->local; - xlator_t *this = frame->this; - int ret = -1; + call_frame_t *frame = data; + marker_local_t *local = frame->local; + xlator_t *this = frame->this; + marker_conf_t *priv = NULL; + char ver_str[NAME_MAX] = {0,}; + char *dot = NULL; + int ret = -1; + + priv = this->private; + + /* If quota is enabled immediately after disable. + * quota healing starts creating new xattrs + * before completing the cleanup operation. + * So we should check if the xattr is the new. + * Do not remove xattr if its xattr + * version is same as current version + */ + if ((priv->feature_enabled & GF_QUOTA) && priv->version > 0) { + snprintf (ver_str, sizeof (ver_str), ".%d", priv->version); + dot = strrchr (k, '.'); + if (dot && !strcmp(dot, ver_str)) + return 0; + } ret = syncop_removexattr (FIRST_CHILD (this), &local->loc, k, 0, NULL); if (ret) { |