summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPoornima G <pgurusid@redhat.com>2018-01-09 10:32:16 +0530
committerAmar Tumballi <amarts@redhat.com>2018-01-19 03:59:30 +0000
commitefc30e60e233164bd4fe7fc903a7c5f718b0448b (patch)
tree5153453a7231e3b4c1127ced280fe10969713133
parent890078423b4b720dd124f07c975e834695bcc915 (diff)
upcall: Allow md-cache to specify invalidations on xattr with wildcard
Currently, md-cache sends a list of xattrs, it is inttrested in recieving invalidations for. But, it cannot specify any wildcard in the xattr names Eg: user.* - invalidate on updating any xattr with user. prefix. This patch, enable upcall to honor wildcard in the xattr key names Updates: #297 Change-Id: I98caf0ed72f11ef10770bf2067d4428880e0a03a Signed-off-by: Poornima G <pgurusid@redhat.com>
-rwxr-xr-x[-rw-r--r--]tests/bugs/md-cache/bug-1211863.t0
-rw-r--r--xlators/features/upcall/src/upcall-internal.c25
2 files changed, 21 insertions, 4 deletions
diff --git a/tests/bugs/md-cache/bug-1211863.t b/tests/bugs/md-cache/bug-1211863.t
index ece42fe8d81..ece42fe8d81 100644..100755
--- a/tests/bugs/md-cache/bug-1211863.t
+++ b/tests/bugs/md-cache/bug-1211863.t
diff --git a/xlators/features/upcall/src/upcall-internal.c b/xlators/features/upcall/src/upcall-internal.c
index 867b2901cb6..d8131a9f2ab 100644
--- a/xlators/features/upcall/src/upcall-internal.c
+++ b/xlators/features/upcall/src/upcall-internal.c
@@ -465,11 +465,29 @@ up_filter_afr_xattr (dict_t *xattrs, char *xattr, data_t *v)
}
-static int
+static gf_boolean_t
+up_key_is_regd_xattr (dict_t *regd_xattrs, char *regd_xattr, data_t *v,
+ void *xattr)
+{
+ int ret = _gf_false;
+ char *key = xattr;
+
+ if (fnmatch (regd_xattr, key, 0) == 0)
+ ret = _gf_true;
+
+ return ret;
+}
+
+
+int
up_filter_unregd_xattr (dict_t *xattrs, char *xattr, data_t *v,
void *regd_xattrs)
{
- if (dict_get ((dict_t *)regd_xattrs, xattr) == NULL) {
+ int ret = 0;
+
+ ret = dict_foreach_match (regd_xattrs, up_key_is_regd_xattr, xattr,
+ dict_null_foreach_fn, NULL);
+ if (ret == 0) {
/* xattr was not found in the registered xattr, hence do not
* send notification for its change
*/
@@ -487,9 +505,8 @@ up_filter_xattr (dict_t *xattr, dict_t *regd_xattrs)
{
int ret = 0;
- /* Remove the xattrs from the dict, if they are not registered for
- * cache invalidation */
ret = dict_foreach (xattr, up_filter_unregd_xattr, regd_xattrs);
+
return ret;
}