diff options
author | Pranith Kumar K <pkarampu@redhat.com> | 2014-11-06 10:37:06 +0530 |
---|---|---|
committer | Vijay Bellur <vbellur@redhat.com> | 2014-11-16 23:35:25 -0800 |
commit | 4bc694954190ce62953e1dfd470f621e85138ccc (patch) | |
tree | d14d38c7125cf1d051c4fa396c66624ce49c485b /libglusterfs | |
parent | 4e8901f7201ec68f30dbdf452362fcf0f3ec16bc (diff) |
features/marker: Filter internal xattrs in lookup
Backport of http://review.gluster.org/9061
Afr should ignore quota-size-key as part of self-heal
but should heal quota-limit key.
BUG: 1163569
Change-Id: I93d203002eac4fe20b70730c27c852d783c16d7f
Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
Reviewed-on: http://review.gluster.org/9110
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'libglusterfs')
-rw-r--r-- | libglusterfs/src/dict.c | 45 | ||||
-rw-r--r-- | libglusterfs/src/dict.h | 13 |
2 files changed, 58 insertions, 0 deletions
diff --git a/libglusterfs/src/dict.c b/libglusterfs/src/dict.c index cf4a3ce644c..0ebcc1ce19d 100644 --- a/libglusterfs/src/dict.c +++ b/libglusterfs/src/dict.c @@ -1139,6 +1139,51 @@ dict_foreach (dict_t *dict, +n = n number of matches */ int +dict_foreach_match (dict_t *dict, + gf_boolean_t (*match)(dict_t *this, + char *key, + data_t *value, + void *mdata), + void *match_data, + int (*action)(dict_t *this, + char *key, + data_t *value, + void *adata), + void *action_data) +{ + if (!dict || !match || !action) { + gf_log_callingfn ("dict", GF_LOG_WARNING, + "dict|match|action is NULL"); + return -1; + } + + int ret = -1; + int count = 0; + data_pair_t *pairs = NULL; + data_pair_t *next = NULL; + + pairs = dict->members_list; + while (pairs) { + next = pairs->next; + if (match (dict, pairs->key, pairs->value, match_data)) { + ret = action (dict, pairs->key, pairs->value, + action_data); + if (ret < 0) + return ret; + count++; + } + pairs = next; + } + + return count; +} + +/* return values: + -1 = failure, + 0 = no matches found, + +n = n number of matches +*/ +int dict_foreach_fnmatch (dict_t *dict, char *pattern, int (*fn)(dict_t *this, char *key, diff --git a/libglusterfs/src/dict.h b/libglusterfs/src/dict.h index a92fd2cb61a..5f9e66e51f7 100644 --- a/libglusterfs/src/dict.h +++ b/libglusterfs/src/dict.h @@ -177,6 +177,19 @@ int dict_foreach_fnmatch (dict_t *dict, char *pattern, void *data), void *data); +int +dict_foreach_match (dict_t *dict, + gf_boolean_t (*match)(dict_t *this, + char *key, + data_t *value, + void *mdata), + void *match_data, + int (*action)(dict_t *this, + char *key, + data_t *value, + void *adata), + void *action_data); + int dict_null_foreach_fn (dict_t *d, char *k, data_t *v, void *tmp); int dict_remove_foreach_fn (dict_t *d, char *k, |