summaryrefslogtreecommitdiffstats
path: root/xlators/cluster/afr
diff options
context:
space:
mode:
authorPranith Kumar K <pkarampu@redhat.com>2015-03-31 23:07:09 +0530
committerPranith Kumar Karampuri <pkarampu@redhat.com>2015-05-08 15:03:16 -0700
commite0401209cf58a638a32e7d867ab4c6199aa0e92f (patch)
treea1ccfdd3bbc8457852976a732e80866deffe4b47 /xlators/cluster/afr
parent135e0fb4f312f59b36da8307b55c2a240d97ba05 (diff)
cluster/ec: Fix dictionary compare function
If both dicts are NULL then equal. If one of the dicts is NULL but the other has only ignorable keys then also they are equal. If both dicts are non-null then check if for each non-ignorable key, values are same or not. value_ignore function is used to skip comparing values for the keys which must be present in both the dictionaries but the value could be different. geo-rep's stime xattr doesn't need to be present in list xattr but when getxattr comes on stime xattr even if there aren't enough responses with the xattr we should still give out an answer which is maximum of the stimes available. Change-Id: I8de2ceaa2db785b797f302f585d88e73b154167d BUG: 1216303 Signed-off-by: Pranith Kumar K <pkarampu@redhat.com> Reviewed-on: http://review.gluster.org/10078 Reviewed-on: http://review.gluster.org/10690 Tested-by: Gluster Build System <jenkins@build.gluster.com> Tested-by: NetBSD Build System
Diffstat (limited to 'xlators/cluster/afr')
-rw-r--r--xlators/cluster/afr/src/afr-common.c41
1 files changed, 6 insertions, 35 deletions
diff --git a/xlators/cluster/afr/src/afr-common.c b/xlators/cluster/afr/src/afr-common.c
index c6501cda97a..8fbca0b6f42 100644
--- a/xlators/cluster/afr/src/afr-common.c
+++ b/xlators/cluster/afr/src/afr-common.c
@@ -1250,48 +1250,19 @@ afr_is_xattr_ignorable (char *key)
return _gf_false;
}
-int
-xattr_is_equal (dict_t *this, char *key1, data_t *value1, void *data)
+static gf_boolean_t
+afr_xattr_match (dict_t *this, char *key1, data_t *value1, void *data)
{
- dict_t *xattr2 = (dict_t *)data;
- data_t *value2 = NULL;
-
- if (afr_is_xattr_ignorable (key1))
- return 0;
-
- value2 = dict_get (xattr2, key1);
- if (!value2)
- return -1;
-
- if (value1->len != value2->len)
- return -1;
- if(memcmp(value1->data, value2->data, value1->len))
- return -1;
- else
- return 0;
+ if (!afr_is_xattr_ignorable (key1))
+ return _gf_true;
+ return _gf_false;
}
-/* To conclude that both dicts are equal, we need to check if
- * 1) For every key-val pair in dict1, a match is present in dict2
- * 2) For every key-val pair in dict2, a match is present in dict1
- * We need to do both because ignoring glusterfs' internal xattrs
- * happens only in xattr_is_equal().
- */
gf_boolean_t
afr_xattrs_are_equal (dict_t *dict1, dict_t *dict2)
{
- int ret = 0;
-
- ret = dict_foreach (dict1, xattr_is_equal, dict2);
- if (ret == -1)
- return _gf_false;
-
- ret = dict_foreach (dict2, xattr_is_equal, dict1);
- if (ret == -1)
- return _gf_false;
-
- return _gf_true;
+ return are_dicts_equal (dict1, dict2, afr_xattr_match, NULL);
}
static int