From 0c721c4c046d3580f7774eb480ff139c3ef814b5 Mon Sep 17 00:00:00 2001 From: ShyamsundarR Date: Tue, 28 Jan 2014 11:09:10 +0530 Subject: cluster/dht: Set restrictive open flags for files under rebalance Files that are being rebalanced are created in the new volume and access path needs to open these files to write changing data in parallel to both the old and new locations. While opening the file in the new location, we need to restrict the open flags to not use truncate or create and fail if exist flags, to prevent open failures or inadvertently truncate the file under rebalance. Change-Id: I12130e0377adc393f1925c45585200ad991fd0d5 BUG: 1058569 Signed-off-by: ShyamsundarR Reviewed-on: http://review.gluster.org/6830 Reviewed-by: Raghavendra G Reviewed-by: Krutika Dhananjay Tested-by: Gluster Build System Reviewed-by: Raghavendra Bhat Reviewed-by: Vijay Bellur --- xlators/cluster/dht/src/dht-helper.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/xlators/cluster/dht/src/dht-helper.c b/xlators/cluster/dht/src/dht-helper.c index 381643b22bd..18a501f049a 100644 --- a/xlators/cluster/dht/src/dht-helper.c +++ b/xlators/cluster/dht/src/dht-helper.c @@ -884,8 +884,12 @@ dht_migration_complete_check_task (void *data) if (fd_is_anonymous (iter_fd)) continue; + /* flags for open are stripped down to allow following the + * new location of the file, otherwise we can get EEXIST or + * truncate the file again as rebalance is moving the data */ ret = syncop_open (dst_node, &tmp_loc, - iter_fd->flags, iter_fd); + (iter_fd->flags & + ~(O_CREAT | O_EXCL | O_TRUNC)), iter_fd); if (ret < 0) { gf_log (this->name, GF_LOG_ERROR, "failed to open " "the fd (%p, flags=0%o) on file %s @ %s", @@ -1034,8 +1038,12 @@ dht_rebalance_inprogress_task (void *data) if (fd_is_anonymous (iter_fd)) continue; + /* flags for open are stripped down to allow following the + * new location of the file, otherwise we can get EEXIST or + * truncate the file again as rebalance is moving the data */ ret = syncop_open (dst_node, &tmp_loc, - iter_fd->flags, iter_fd); + (iter_fd->flags & + ~(O_CREAT | O_EXCL | O_TRUNC)), iter_fd); if (ret < 0) { gf_log (this->name, GF_LOG_ERROR, "failed to send open " "the fd (%p, flags=0%o) on file %s @ %s", -- cgit