From 0aba36ab99fbf537ba2e5ceddfc950528506011f Mon Sep 17 00:00:00 2001 From: Xavier Hernandez Date: Thu, 14 Jan 2016 09:36:33 +0100 Subject: cluster/ec: Handle non-existent config xattr for non regular files Since we now try to get the 'trusted.ec.config' xattr for inodes of type IA_INVAL (these inodes will be set to some valid type later), if that inode corresponds to a non regular file, the xattr won't exist and we will handle this as an error when it's not. This patch solves the problem by only considering errors for inodes that are already known to be regular files. Change-Id: Id72f314e209459236d75cf087fc51e09943756b4 BUG: 1293223 Signed-off-by: Xavier Hernandez Reviewed-on: http://review.gluster.org/13238 Smoke: Gluster Build System Reviewed-by: Ashish Pandey NetBSD-regression: NetBSD Build System CentOS-regression: Gluster Build System Reviewed-by: Jeff Darcy --- xlators/cluster/ec/src/ec-common.c | 48 ++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 23 deletions(-) (limited to 'xlators') diff --git a/xlators/cluster/ec/src/ec-common.c b/xlators/cluster/ec/src/ec-common.c index 82939f4c1c3..c8d1a3710ad 100644 --- a/xlators/cluster/ec/src/ec-common.c +++ b/xlators/cluster/ec/src/ec-common.c @@ -897,7 +897,6 @@ ec_prepare_update_cbk (call_frame_t *frame, void *cookie, ec_lock_link_t *link = fop->data; ec_lock_t *lock = NULL; ec_inode_t *ctx; - ec_config_t config = {0,}; lock = link->lock; parent = link->fop; @@ -941,37 +940,40 @@ ec_prepare_update_cbk (call_frame_t *frame, void *cookie, lock->loc.inode->ia_type == IA_INVAL) { op_errno = -ec_dict_del_number(dict, EC_XATTR_SIZE, &ctx->pre_size); if (op_errno != 0) { - gf_msg (this->name, GF_LOG_ERROR, op_errno, - EC_MSG_SIZE_XATTR_GET_FAIL, "Unable to get size xattr"); + if (lock->loc.inode->ia_type == IA_IFREG) { + gf_msg (this->name, GF_LOG_ERROR, op_errno, + EC_MSG_SIZE_XATTR_GET_FAIL, + "Unable to get size xattr"); - goto unlock; - } - ctx->post_size = ctx->pre_size; + goto unlock; + } + } else { + ctx->post_size = ctx->pre_size; - ctx->have_size = _gf_true; + ctx->have_size = _gf_true; + } op_errno = -ec_dict_del_config(dict, EC_XATTR_CONFIG, &ctx->config); if (op_errno != 0) { - gf_msg (this->name, GF_LOG_ERROR, op_errno, - EC_MSG_CONFIG_XATTR_GET_FAIL, - "Unable to get config xattr"); - - goto unlock; - } - if (!(lock->loc.inode->ia_type == IA_INVAL && - !memcmp(&config, &ctx->config, sizeof(config)))) { + if (lock->loc.inode->ia_type == IA_IFREG) { + gf_msg (this->name, GF_LOG_ERROR, op_errno, + EC_MSG_CONFIG_XATTR_GET_FAIL, + "Unable to get config xattr"); - if (!ec_config_check(parent, &ctx->config)) { - gf_msg (this->name, GF_LOG_ERROR, EINVAL, - EC_MSG_CONFIG_XATTR_INVALID, - "Invalid config xattr"); + goto unlock; + } + } else { + if (!ec_config_check(parent, &ctx->config)) { + gf_msg (this->name, GF_LOG_ERROR, EINVAL, + EC_MSG_CONFIG_XATTR_INVALID, + "Invalid config xattr"); - op_errno = EINVAL; + op_errno = EINVAL; - goto unlock; - } - ctx->have_config = _gf_true; + goto unlock; + } + ctx->have_config = _gf_true; } } -- cgit