From 8fd0a88eed39e1f70f0057efb2f92564fb135186 Mon Sep 17 00:00:00 2001 From: Pranith Kumar K Date: Wed, 7 Jan 2015 12:08:48 +0530 Subject: cluster/ec: Do not modify quota, selinux xattrs in healing Backport of http://review.gluster.org/9401 Problem: EC heal tries to heal quota-size, selinux xattrs as well. quota-size is private to the brick but since quotad accesses them using the standard interface as well, they can not be filtered in the fops. Fix: Ignore QUOTA_SIZE_KEY and SELINUX xattrs during heal. BUG: 1178590 Change-Id: Id569a49ef996e5507f4474c99b6cdc22781ad82d Signed-off-by: Pranith Kumar K Reviewed-on: http://review.gluster.org/9454 Reviewed-by: Xavier Hernandez Tested-by: Gluster Build System Reviewed-by: Raghavendra Bhat --- xlators/cluster/ec/src/ec-heal.c | 52 +++++++++++++++++++++++++++++----------- 1 file changed, 38 insertions(+), 14 deletions(-) diff --git a/xlators/cluster/ec/src/ec-heal.c b/xlators/cluster/ec/src/ec-heal.c index 625c31c1cc1..949170db495 100644 --- a/xlators/cluster/ec/src/ec-heal.c +++ b/xlators/cluster/ec/src/ec-heal.c @@ -21,6 +21,29 @@ #include "ec-mem-types.h" #include "ec-data.h" +static char *ec_ignore_xattrs[] = { + GF_SELINUX_XATTR_KEY, + QUOTA_SIZE_KEY, + NULL +}; + +static gf_boolean_t +ec_ignorable_key_match (dict_t *dict, char *key, data_t *val, void *mdata) +{ + int i = 0; + + if (!key) + goto out; + + for (i = 0; ec_ignore_xattrs[i]; i++) { + if (!strcmp (key, ec_ignore_xattrs[i])) + return _gf_true; + } + +out: + return _gf_false; +} + /* FOP: heal */ void ec_heal_exclude(ec_heal_t * heal, uintptr_t mask) @@ -864,6 +887,10 @@ void ec_heal_setxattr_others(ec_heal_t * heal) cbk = heal->lookup->answer; xdata = cbk->xdata; + if (dict_foreach_match (xdata, ec_ignorable_key_match, NULL, + dict_remove_foreach_fn, NULL) == -1) + goto out; + if ((cbk->iatt[0].ia_type == IA_IFREG) || (cbk->iatt[0].ia_type == IA_IFDIR)) { @@ -891,24 +918,21 @@ out: ec_fop_set_error(heal->fop, error); } -int32_t ec_heal_xattr_clean(dict_t * dict, char * key, data_t * data, - void * arg) +int32_t +ec_heal_xattr_clean (dict_t *dict, char *key, data_t *data, + void *arg) { - dict_t * base = arg; + dict_t *base = arg; - if (dict_get(base, key) == NULL) - { - if (dict_set_static_bin(dict, key, dict, 0) != 0) - { - return -1; + if (ec_ignorable_key_match (NULL, key, NULL, NULL)) { + dict_del (dict, key); + return 0; } - } - else - { - dict_del(dict, key); - } - return 0; + if (dict_get (base, key) != NULL) + dict_del (dict, key); + + return 0; } void ec_heal_removexattr_others(ec_heal_t * heal) -- cgit