diff options
-rwxr-xr-x | tests/bugs/bug-1040423.t | 72 | ||||
-rw-r--r-- | xlators/cluster/dht/src/dht-common.c | 6 | ||||
-rw-r--r-- | xlators/features/quota/src/quota.c | 56 |
3 files changed, 100 insertions, 34 deletions
diff --git a/tests/bugs/bug-1040423.t b/tests/bugs/bug-1040423.t new file mode 100755 index 00000000000..6dae9eac6e9 --- /dev/null +++ b/tests/bugs/bug-1040423.t @@ -0,0 +1,72 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc +. $(dirname $0)/../volume.rc + +cleanup + +function _init() { +# Start glusterd +TEST glusterd; +TEST pidof glusterd; +TEST $CLI volume info; + +# Lets create volume +TEST $CLI volume create $V0 $H0:$B0/${V0}{1,2}; + +## Verify volume is created +EXPECT "$V0" volinfo_field $V0 'Volume Name'; +EXPECT 'Created' volinfo_field $V0 'Status'; + +#Start volume and verify +TEST $CLI volume start $V0; +EXPECT 'Started' volinfo_field $V0 'Status'; +TEST glusterfs --volfile-id=$V0 --volfile-server=$H0 $M0 + +#Enable Quota +TEST $CLI volume quota $V0 enable + +#As quotad consumes some time to connect to brick process we invoke sleep +sleep 10; + +#set limit of 1GB of quota on root +TEST $CLI volume quota $V0 limit-usage / 1GB +} + +function get_hardlimit() +{ + VOLUME=$1 + + $CLI volume quota $VOLUME list | tail -1 | sed "s/ \{1,\}/ /g" | + cut -d' ' -f 2 +} + +function check_fattrs { + +touch $M0/file1; + +#This confirms that pgfid is also filtered +TEST ! "getfattr -d -e hex -m . $M0/file1 | grep pgfid "; + +#just check for quota xattr are visible or not +TEST ! "getfattr -d -e hex -m . $M0 | grep quota"; + +#setfattr should fail +TEST ! setfattr -n trusted.glusterfs.quota.limit-set -v 10 $M0; + +#remove xattr should fail +TEST ! setfattr -x trusted.glusterfs.quota.limit-set $M0; + +#check if list command still shows the correct value or not + +EXPECT "1.0GB" get_hardlimit $V0 + +} + +_init; +check_fattrs; +cleanup + + + + diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c index f59bc96670c..cf4ec258d2f 100644 --- a/xlators/cluster/dht/src/dht-common.c +++ b/xlators/cluster/dht/src/dht-common.c @@ -2010,6 +2010,12 @@ dht_getxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, if (dict_get (xattr, conf->xattr_name)) { dict_del (xattr, conf->xattr_name); } + + if (frame->root->pid >= 0 ) { + GF_REMOVE_INTERNAL_XATTR("trusted.glusterfs.quota*", xattr); + GF_REMOVE_INTERNAL_XATTR("trusted.pgfid*", xattr); + } + local->op_ret = 0; if (!local->xattr) { diff --git a/xlators/features/quota/src/quota.c b/xlators/features/quota/src/quota.c index 5cbd9f02d65..89f9958d8db 100644 --- a/xlators/features/quota/src/quota.c +++ b/xlators/features/quota/src/quota.c @@ -3255,10 +3255,6 @@ quota_setxattr (call_frame_t *frame, xlator_t *this, int op_ret = -1; int64_t hard_lim = -1, soft_lim = -1; quota_local_t *local = NULL; - char *src = NULL; - char *dst = NULL; - int len = 0; - int ret = -1; priv = this->private; @@ -3268,29 +3264,11 @@ quota_setxattr (call_frame_t *frame, xlator_t *this, VALIDATE_OR_GOTO (this, err); VALIDATE_OR_GOTO (loc, err); - if (0 <= frame->root->pid) { - ret = dict_get_ptr_and_len (dict, QUOTA_LIMIT_KEY, - (void **)&src, &len); - if (ret) { - gf_log (this->name, GF_LOG_DEBUG, "dict_get on %s " - "failed", QUOTA_LIMIT_KEY); - } else { - dst = GF_CALLOC (len, sizeof (char), gf_common_mt_char); - if (dst) - memcpy (dst, src, len); - } - - GF_REMOVE_INTERNAL_XATTR ("trusted.glusterfs.quota*", - dict); - if (!ret && IA_ISDIR (loc->inode->ia_type) && dst) { - ret = dict_set_dynptr (dict, QUOTA_LIMIT_KEY, - dst, len); - if (ret) - gf_log (this->name, GF_LOG_WARNING, "setting " - "key %s failed", QUOTA_LIMIT_KEY); - else - dst = NULL; - } + if (frame->root->pid >= 0) { + GF_IF_INTERNAL_XATTR_GOTO ("trusted.glusterfs.quota*", dict, + op_errno, err); + GF_IF_INTERNAL_XATTR_GOTO ("trusted.pgfid*", dict, op_errno, + err); } quota_get_limits (this, dict, &hard_lim, &soft_lim); @@ -3367,9 +3345,12 @@ quota_fsetxattr (call_frame_t *frame, xlator_t *this, fd_t *fd, VALIDATE_OR_GOTO (this, err); VALIDATE_OR_GOTO (fd, err); - if (0 <= frame->root->pid) - GF_IF_INTERNAL_XATTR_GOTO ("trusted.glusterfs.quota*", dict, + if (0 <= frame->root->pid) { + GF_IF_INTERNAL_XATTR_GOTO ("trusted.glusterfs.quota*", + dict, op_errno, err); + GF_IF_INTERNAL_XATTR_GOTO ("trusted.pgfid*", dict, op_errno, err); + } quota_get_limits (this, dict, &hard_lim, &soft_lim); @@ -3418,8 +3399,12 @@ quota_removexattr (call_frame_t *frame, xlator_t *this, /* all quota xattrs can be cleaned up by doing setxattr on special key. * Hence its ok that we don't allow removexattr on quota keys here. */ - GF_IF_NATIVE_XATTR_GOTO ("trusted.quota*", - name, op_errno, err); + if (frame->root->pid >= 0) { + GF_IF_NATIVE_XATTR_GOTO ("trusted.glusterfs.quota*", + name, op_errno, err); + GF_IF_NATIVE_XATTR_GOTO ("trusted.pgfid*", name, + op_errno, err); + } VALIDATE_OR_GOTO (frame, err); VALIDATE_OR_GOTO (loc, err); @@ -3460,9 +3445,12 @@ quota_fremovexattr (call_frame_t *frame, xlator_t *this, VALIDATE_OR_GOTO (this, err); VALIDATE_OR_GOTO (fd, err); - GF_IF_NATIVE_XATTR_GOTO ("trusted.quota*", - name, op_errno, err); - + if (frame->root->pid >= 0) { + GF_IF_NATIVE_XATTR_GOTO ("trusted.glusterfs.quota*", + name, op_errno, err); + GF_IF_NATIVE_XATTR_GOTO ("trusted.pgfid*", name, + op_errno, err); + } wind: STACK_WIND (frame, priv->is_quota_on? quota_fremovexattr_cbk: default_fremovexattr_cbk, |