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