From efc30e60e233164bd4fe7fc903a7c5f718b0448b Mon Sep 17 00:00:00 2001 From: Poornima G Date: Tue, 9 Jan 2018 10:32:16 +0530 Subject: 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 --- xlators/features/upcall/src/upcall-internal.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'xlators/features/upcall/src/upcall-internal.c') 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; } -- cgit