From 79683794c2ee9c6b5c1182e2a378598c2037a9ff Mon Sep 17 00:00:00 2001 From: Susant Palai Date: Thu, 12 Dec 2013 06:20:55 +0000 Subject: quota: filter glusterfs quota xattrs Change-Id: I86ebe02735ee88598640240aa888e02b48ecc06c BUG: 1040423 Signed-off-by: Susant Palai Reviewed-on: http://review.gluster.org/6490 Tested-by: Gluster Build System Reviewed-by: Raghavendra G --- xlators/cluster/dht/src/dht-common.c | 6 ++++ xlators/features/quota/src/quota.c | 56 ++++++++++++++---------------------- 2 files changed, 28 insertions(+), 34 deletions(-) (limited to 'xlators') diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c index f59bc9667..cf4ec258d 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 5cbd9f02d..89f9958d8 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, -- cgit