From c87472e200c9fee74705a350ce45557bde47b946 Mon Sep 17 00:00:00 2001 From: shishir gowda Date: Thu, 14 Feb 2013 13:04:58 +0530 Subject: cluster/distribute: Reopen fds in migration internally as root:root Though linkfile_create and rebalance dst file create sent a setattr with correct ownership, there is still a race window where the linkfile open (client open due to migration) will fail, as its ownership will be root:root. Change-Id: I056092da6102319efa3bb9f1795f8c97db2a3fed BUG: 884597 Signed-off-by: shishir gowda Reviewed-on: http://review.gluster.org/4513 Tested-by: Gluster Build System Reviewed-by: Amar Tumballi Reviewed-by: Anand Avati --- xlators/cluster/dht/src/dht-helper.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'xlators/cluster/dht/src/dht-helper.c') diff --git a/xlators/cluster/dht/src/dht-helper.c b/xlators/cluster/dht/src/dht-helper.c index 9e71c6033..ecd06e394 100644 --- a/xlators/cluster/dht/src/dht-helper.c +++ b/xlators/cluster/dht/src/dht-helper.c @@ -731,6 +731,10 @@ dht_migration_complete_check_task (void *data) goto out; } + /* perform open as root:root. There is window between linkfile + * creation(root:root) and setattr with the correct uid/gid + */ + SYNCTASK_SETID(0, 0); /* if 'local->fd' (ie, fd based operation), send a 'open()' on destination if not already done */ if (local->loc.inode) { @@ -746,6 +750,7 @@ dht_migration_complete_check_task (void *data) GF_FREE (path); } + SYNCTASK_SETID (frame->root->uid, frame->root->gid); if (ret == -1) { gf_log (this->name, GF_LOG_ERROR, "%s: failed to send open() on target file at %s", @@ -853,7 +858,10 @@ dht_rebalance_inprogress_task (void *data) } ret = 0; - + /* perform open as root:root. There is window between linkfile + * creation(root:root) and setattr with the correct uid/gid + */ + SYNCTASK_SETID (0, 0); if (local->loc.inode) { ret = syncop_open (dst_node, &local->loc, local->fd->flags, local->fd); @@ -874,6 +882,7 @@ dht_rebalance_inprogress_task (void *data) goto out; } + SYNCTASK_SETID (frame->root->uid, frame->root->gid); ret = fd_ctx_set (local->fd, this, (uint64_t)(long)dst_node); if (ret) { gf_log (this->name, GF_LOG_ERROR, -- cgit