From 9afe93bee897c8ead507a8dadb0e0fc32ed8abf0 Mon Sep 17 00:00:00 2001 From: Xavier Hernandez Date: Mon, 15 Feb 2016 10:59:29 +0100 Subject: cluster/ec: Fix invalid config check for directories The trusted.ec.config xattr is not defined for directories. However sometimes it could be requested because the inode type of a directory can temporarily be IA_INVAL. Requesting such xattr using the xattrop fop when it doesn't exist, returns a config value full of 0's, which is invalid and caused some fops to fail. This patch filters out this case by ignoring config xattr == 0. Change-Id: Ied51c35b313ea8c3eeae27812f9bae61d3808e92 BUG: 1293223 Signed-off-by: Xavier Hernandez Reviewed-on: http://review.gluster.org/13446 Smoke: Gluster Build System CentOS-regression: Gluster Build System Reviewed-by: Ashish Pandey NetBSD-regression: NetBSD Build System Reviewed-by: Jeff Darcy --- xlators/cluster/ec/src/ec-common.c | 3 ++- xlators/cluster/ec/src/ec-helpers.c | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) (limited to 'xlators/cluster') diff --git a/xlators/cluster/ec/src/ec-common.c b/xlators/cluster/ec/src/ec-common.c index c8d1a3710ad..c371eb6687e 100644 --- a/xlators/cluster/ec/src/ec-common.c +++ b/xlators/cluster/ec/src/ec-common.c @@ -955,7 +955,8 @@ ec_prepare_update_cbk (call_frame_t *frame, void *cookie, op_errno = -ec_dict_del_config(dict, EC_XATTR_CONFIG, &ctx->config); if (op_errno != 0) { - if (lock->loc.inode->ia_type == IA_IFREG) { + if ((lock->loc.inode->ia_type == IA_IFREG) || + (op_errno != ENODATA)) { gf_msg (this->name, GF_LOG_ERROR, op_errno, EC_MSG_CONFIG_XATTR_GET_FAIL, "Unable to get config xattr"); diff --git a/xlators/cluster/ec/src/ec-helpers.c b/xlators/cluster/ec/src/ec-helpers.c index 01e5e56a9b6..c8f904ac51d 100644 --- a/xlators/cluster/ec/src/ec-helpers.c +++ b/xlators/cluster/ec/src/ec-helpers.c @@ -321,6 +321,19 @@ int32_t ec_dict_del_config(dict_t * dict, char * key, ec_config_t * config) } data = ntoh64(*(uint64_t *)ptr); + /* Currently we need to get the config xattr for entries of type IA_INVAL. + * These entries can later become IA_DIR entries (after inode_link()), + * which don't have a config xattr. However, since the xattr is requested + * using an xattrop() fop, it will always return a config full of 0's + * instead of saying that it doesn't exist. + * + * We need to filter out this case and consider that a config xattr == 0 is + * the same than a non-existant xattr. Otherwise ec_config_check() will + * fail. + */ + if (data == 0) { + return -ENODATA; + } config->version = (data >> 56) & 0xff; if (config->version > EC_CONFIG_VERSION) -- cgit