From b9c730f3960efd454c8363ee39dc144e4c0dc835 Mon Sep 17 00:00:00 2001 From: Nithya Balachandran Date: Thu, 27 Aug 2015 13:10:18 +0530 Subject: cluster/dht: Don't set posix acls on linkto files Posix acls on a linkto file change the file's permission bits and cause DHT to treat it as a non-linkto file.This happens on the migration failure of a file on which posix acls were set. The fix prevents posix acls from being set on a linkto file and copies them across only after a file has been successfully migrated. Change-Id: Iccf7ff6fba49fe05d691d9b83bf76a240848b212 BUG: 1247563 Signed-off-by: Nithya Balachandran Signed-off-by: N Balachandran Reviewed-on: http://review.gluster.org/12025 Tested-by: NetBSD Build System Reviewed-by: Raghavendra G Reviewed-by: Pranith Kumar Karampuri --- xlators/cluster/dht/src/dht-rebalance.c | 34 +++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'xlators/cluster/dht/src/dht-rebalance.c') diff --git a/xlators/cluster/dht/src/dht-rebalance.c b/xlators/cluster/dht/src/dht-rebalance.c index 7c91d176ff3..6b3299c4990 100644 --- a/xlators/cluster/dht/src/dht-rebalance.c +++ b/xlators/cluster/dht/src/dht-rebalance.c @@ -1277,6 +1277,40 @@ dht_migrate_file (xlator_t *this, loc_t *loc, xlator_t *from, xlator_t *to, ret = -1; } + /* Posix acls are not set on DHT linkto files as part of the initial + * initial xattrs set on the dst file, so these need + * to be set on the dst file after the linkto attrs are removed. + * TODO: Optimize this. + */ + if (xattr) { + dict_unref (xattr); + xattr = NULL; + } + + ret = syncop_listxattr (from, loc, &xattr, NULL, NULL); + if (ret < 0) { + gf_msg (this->name, GF_LOG_WARNING, 0, + DHT_MSG_MIGRATE_FILE_FAILED, + "Migrate file failed:" + "%s: failed to get xattr from %s (%s)", + loc->path, from->name, strerror (-ret)); + ret = -1; + } else { + ret = syncop_setxattr (to, loc, xattr, 0, NULL, NULL); + if (ret < 0) { + /* Potential problem here where Posix ACLs will + * not be set on the target file */ + + gf_msg (this->name, GF_LOG_WARNING, 0, + DHT_MSG_MIGRATE_FILE_FAILED, + "Migrate file failed:" + "%s: failed to set xattr on %s (%s)", + loc->path, to->name, strerror (-ret)); + ret = -1; + } + } + + /* The src file is being unlinked after this so we don't need to clean it up */ clean_src = _gf_false; -- cgit