e7a346
From 897f0604f34760afe585a28d9787c6ff39d3addc Mon Sep 17 00:00:00 2001
e7a346
From: Poornima G <pgurusid@redhat.com>
e7a346
Date: Tue, 9 Jan 2018 10:32:16 +0530
e7a346
Subject: [PATCH 133/139] upcall: Allow md-cache to specify invalidations on
e7a346
 xattr with wildcard
e7a346
e7a346
Currently, md-cache sends a list of xattrs, it is inttrested in recieving
e7a346
invalidations for. But, it cannot specify any wildcard in the xattr names
e7a346
Eg: user.* - invalidate on updating any xattr with user. prefix.
e7a346
e7a346
This patch, enable upcall to honor wildcard in the xattr key names
e7a346
e7a346
Updates: #297
e7a346
e7a346
> Signed-off-by: Poornima G <pgurusid@redhat.com>
e7a346
> Change-Id: I98caf0ed72f11ef10770bf2067d4428880e0a03a
e7a346
> Reviewed-on: https://review.gluster.org/19171
e7a346
> Smoke: Gluster Build System <jenkins@build.gluster.org>
e7a346
> Reviewed-by: Amar Tumballi
e7a346
> Tested-by: Poornima G <pgurusid@redhat.com>
e7a346
> CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
e7a346
> (cherry picked from commit efc30e60e233164bd4fe7fc903a7c5f718b0448b)
e7a346
e7a346
Change-Id: I98caf0ed72f11ef10770bf2067d4428880e0a03a
e7a346
BUG: 1446125
e7a346
Signed-off-by: Poornima G <pgurusid@redhat.com>
e7a346
Reviewed-on: https://code.engineering.redhat.com/gerrit/128481
e7a346
Tested-by: RHGS Build Bot <nigelb@redhat.com>
e7a346
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
e7a346
---
e7a346
 tests/bugs/md-cache/bug-1211863.t             |  0
e7a346
 xlators/features/upcall/src/upcall-internal.c | 25 +++++++++++++++++++++----
e7a346
 2 files changed, 21 insertions(+), 4 deletions(-)
e7a346
 mode change 100644 => 100755 tests/bugs/md-cache/bug-1211863.t
e7a346
e7a346
diff --git a/tests/bugs/md-cache/bug-1211863.t b/tests/bugs/md-cache/bug-1211863.t
e7a346
old mode 100644
e7a346
new mode 100755
e7a346
diff --git a/xlators/features/upcall/src/upcall-internal.c b/xlators/features/upcall/src/upcall-internal.c
e7a346
index 8b15dfc..7813940 100644
e7a346
--- a/xlators/features/upcall/src/upcall-internal.c
e7a346
+++ b/xlators/features/upcall/src/upcall-internal.c
e7a346
@@ -466,11 +466,29 @@ up_filter_afr_xattr (dict_t *xattrs, char *xattr, data_t *v)
e7a346
 }
e7a346
 
e7a346
 
e7a346
-static int
e7a346
+static gf_boolean_t
e7a346
+up_key_is_regd_xattr (dict_t *regd_xattrs, char *regd_xattr, data_t *v,
e7a346
+                      void *xattr)
e7a346
+{
e7a346
+        int ret = _gf_false;
e7a346
+        char *key = xattr;
e7a346
+
e7a346
+        if (fnmatch (regd_xattr, key, 0) == 0)
e7a346
+                ret = _gf_true;
e7a346
+
e7a346
+        return ret;
e7a346
+}
e7a346
+
e7a346
+
e7a346
+int
e7a346
 up_filter_unregd_xattr (dict_t *xattrs, char *xattr, data_t *v,
e7a346
                         void *regd_xattrs)
e7a346
 {
e7a346
-        if (dict_get ((dict_t *)regd_xattrs, xattr) == NULL) {
e7a346
+        int ret = 0;
e7a346
+
e7a346
+        ret = dict_foreach_match (regd_xattrs, up_key_is_regd_xattr, xattr,
e7a346
+                                  dict_null_foreach_fn, NULL);
e7a346
+        if (ret == 0) {
e7a346
                 /* xattr was not found in the registered xattr, hence do not
e7a346
                  * send notification for its change
e7a346
                  */
e7a346
@@ -488,9 +506,8 @@ up_filter_xattr (dict_t *xattr, dict_t *regd_xattrs)
e7a346
 {
e7a346
         int ret = 0;
e7a346
 
e7a346
-        /* Remove the xattrs from the dict, if they are not registered for
e7a346
-         * cache invalidation */
e7a346
         ret = dict_foreach (xattr, up_filter_unregd_xattr, regd_xattrs);
e7a346
+
e7a346
         return ret;
e7a346
 }
e7a346
 
e7a346
-- 
e7a346
1.8.3.1
e7a346