summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libglusterfs/src/dict.c20
-rw-r--r--libglusterfs/src/dict.h1
-rw-r--r--xlators/cluster/dht/src/dht-common.c17
3 files changed, 36 insertions, 2 deletions
diff --git a/libglusterfs/src/dict.c b/libglusterfs/src/dict.c
index c8f43e3161c..66fe31bcd59 100644
--- a/libglusterfs/src/dict.c
+++ b/libglusterfs/src/dict.c
@@ -214,6 +214,26 @@ _dict_lookup (dict_t *this, char *key)
return NULL;
}
+int32_t
+dict_lookup (dict_t *this, char *key, data_pair_t **data)
+{
+ if (!this || !key || !data) {
+ gf_log_callingfn ("dict", GF_LOG_WARNING,
+ "!this || !key || !data");
+ return -1;
+ }
+
+ LOCK (&this->lock);
+ {
+ *data = _dict_lookup (this, key);
+ }
+ UNLOCK (&this->lock);
+ if (*data)
+ return 0;
+ else
+ return -1;
+
+}
static int32_t
_dict_set (dict_t *this,
diff --git a/libglusterfs/src/dict.h b/libglusterfs/src/dict.h
index 4ddea942202..240d7d2e65d 100644
--- a/libglusterfs/src/dict.h
+++ b/libglusterfs/src/dict.h
@@ -89,6 +89,7 @@ dict_t *dict_ref (dict_t *dict);
data_t *data_ref (data_t *data);
void data_unref (data_t *data);
+int32_t dict_lookup (dict_t *this, char *key, data_pair_t **data);
/*
TODO: provide converts for differnt byte sizes, signedness, and void *
*/
diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c
index 678457a3b86..e921d9c3196 100644
--- a/xlators/cluster/dht/src/dht-common.c
+++ b/xlators/cluster/dht/src/dht-common.c
@@ -35,13 +35,13 @@
#include <sys/time.h>
#include <libgen.h>
-
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)) {