From 8dfdde57b38576270dd54f610b80f1288a16f09b Mon Sep 17 00:00:00 2001 From: Vikas Gorur Date: Thu, 6 Aug 2009 07:37:17 +0000 Subject: Filter changelog xattrs in replicate The AFR changelog xattrs, "trusted.afr.*" are now filtered and prevented from being visible on the mountpoint. Signed-off-by: Anand V. Avati BUG: 9 (replicate's pending xattr's should not be visible on the mountpoint) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=9 --- xlators/cluster/afr/src/afr-inode-read.c | 65 +++++++++++++++++++++++++++++++- 1 file changed, 64 insertions(+), 1 deletion(-) diff --git a/xlators/cluster/afr/src/afr-inode-read.c b/xlators/cluster/afr/src/afr-inode-read.c index c26def93c43..2f9a6cda9fd 100644 --- a/xlators/cluster/afr/src/afr-inode-read.c +++ b/xlators/cluster/afr/src/afr-inode-read.c @@ -137,7 +137,7 @@ afr_access (call_frame_t *frame, xlator_t *this, ALLOC_OR_GOTO (local, afr_local_t, out); read_child = afr_read_child (this, loc->inode); - + if (read_child >= 0) { call_child = read_child; @@ -545,6 +545,58 @@ out: /* {{{ getxattr */ +struct _xattr_key { + char *key; + struct list_head list; +}; + + +void +__gather_xattr_keys (dict_t *dict, char *key, data_t *value, + void *data) +{ + struct list_head * list = data; + struct _xattr_key * xkey = NULL; + + if (!strncmp (key, AFR_XATTR_PREFIX, + strlen (AFR_XATTR_PREFIX))) { + + xkey = CALLOC (1, sizeof (*xkey)); + if (!xkey) + return; + + xkey->key = key; + INIT_LIST_HEAD (&xkey->list); + + list_add_tail (&xkey->list, list); + } +} + + +void +__filter_xattrs (dict_t *dict) +{ + struct list_head keys; + + struct _xattr_key *key; + struct _xattr_key *tmp; + + INIT_LIST_HEAD (&keys); + + dict_foreach (dict, __gather_xattr_keys, + (void *) &keys); + + list_for_each_entry_safe (key, tmp, &keys, list) { + dict_del (dict, key->key); + + list_del_init (&key->list); + + FREE (key); + } +} + + + int32_t afr_getxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, @@ -590,6 +642,8 @@ afr_getxattr_cbk (call_frame_t *frame, void *cookie, out: if (unwind) { + __filter_xattrs (dict); + AFR_STACK_UNWIND (frame, op_ret, op_errno, dict); } @@ -623,6 +677,15 @@ afr_getxattr (call_frame_t *frame, xlator_t *this, ALLOC_OR_GOTO (local, afr_local_t, out); frame->local = local; + if (name) { + if (!strncmp (name, AFR_XATTR_PREFIX, + strlen (AFR_XATTR_PREFIX))) { + + op_errno = ENODATA; + goto out; + } + } + read_child = afr_read_child (this, loc->inode); if (read_child >= 0) { -- cgit