summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXavier Hernandez <xhernandez@datalab.es>2016-02-15 10:59:29 +0100
committerPranith Kumar Karampuri <pkarampu@redhat.com>2016-03-02 03:02:49 -0800
commit6662b0a9cf19fdbe75e67f70a98df44d4852467c (patch)
tree385f270449a9c350f0468999ce2819cafe0818a8
parent793f0ffba45e9cd6d5fbfbb8ffc274794aeb4683 (diff)
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 > Reviewed-on: http://review.gluster.org/13446 > BUG: 1293223 > Signed-off-by: Xavier Hernandez <xhernandez@datalab.es> Change-Id: I42d06119d8f51c34ddb910380af7acd670f6244e BUG: 1293224 Signed-off-by: Xavier Hernandez <xhernandez@datalab.es> Reviewed-on: http://review.gluster.org/13447 Smoke: Gluster Build System <jenkins@build.gluster.com> CentOS-regression: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Ashish Pandey <aspandey@redhat.com> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
-rwxr-xr-xtests/basic/ec/quota.t2
-rw-r--r--xlators/cluster/ec/src/ec-common.c3
-rw-r--r--xlators/cluster/ec/src/ec-helpers.c13
3 files changed, 16 insertions, 2 deletions
diff --git a/tests/basic/ec/quota.t b/tests/basic/ec/quota.t
index f093085bde0..b023240b87e 100755
--- a/tests/basic/ec/quota.t
+++ b/tests/basic/ec/quota.t
@@ -15,7 +15,7 @@ EXPECT 'Created' volinfo_field $V0 'Status'
TEST $CLI volume start $V0
EXPECT_WITHIN $PROCESS_UP_TIMEOUT 'Started' volinfo_field $V0 'Status'
TEST $GFS --volfile-id=/$V0 --volfile-server=$H0 $M0
-EXPECT_WITHIN $CHILD_UP_TIMEOUT "$DISPERSE" ec_child_up_count $V0 0
+EXPECT_WITHIN $CHILD_UP_TIMEOUT "3" ec_child_up_count $V0 0
TEST mkdir -p $M0/test
diff --git a/xlators/cluster/ec/src/ec-common.c b/xlators/cluster/ec/src/ec-common.c
index bfb2294017d..8c6ff78c27e 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 d05c74e6724..28641cec5f7 100644
--- a/xlators/cluster/ec/src/ec-helpers.c
+++ b/xlators/cluster/ec/src/ec-helpers.c
@@ -307,6 +307,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)