From 2a2060359a6991e310e6532376273bccb9cfbadc Mon Sep 17 00:00:00 2001 From: shishir gowda Date: Tue, 12 Apr 2011 05:19:22 +0000 Subject: DHT: check for mis-matching user xattrs Signed-off-by: shishir gowda Signed-off-by: Anand Avati BUG: 2717 (Detect user_xattr mismatches for dir's) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2717 --- xlators/cluster/dht/src/dht-common.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'xlators/cluster') diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c index 678457a3b..e921d9c31 100644 --- a/xlators/cluster/dht/src/dht-common.c +++ b/xlators/cluster/dht/src/dht-common.c @@ -35,13 +35,13 @@ #include #include - void dht_aggregate (dict_t *this, char *key, data_t *value, void *data) { dict_t *dst = NULL; int64_t *ptr = 0, *size = NULL; int32_t ret = -1; + data_pair_t *data_pair = NULL; dst = data; @@ -71,6 +71,20 @@ dht_aggregate (dict_t *this, char *key, data_t *value, void *data) } *size = hton64 (ntoh64 (*size) + ntoh64 (*ptr)); + } else { + /* compare user xattrs only */ + if (!strncmp (key, "user.", strlen ("user."))) { + ret = dict_lookup (dst, key, &data_pair); + if (!ret && data) { + ret = is_data_equal (data_pair->value, value); + if (!ret) + gf_log ("dht", GF_LOG_WARNING, + "xattr mismatch for %s", key); + } + } + ret = dict_set (dst, key, value); + if (ret) + gf_log ("dht", GF_LOG_WARNING, "xattr dict set failed"); } return; @@ -1869,7 +1883,6 @@ dht_getxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, * local->xattr. */ dht_aggregate_xattr (xattr, local->xattr); - local->xattr = dict_copy (xattr, local->xattr); } out: if (is_last_call (this_call_cnt)) { -- cgit