From 795c8996c18f5e8ef5986581644374d0c5068772 Mon Sep 17 00:00:00 2001 From: Amar Tumballi Date: Fri, 30 Sep 2011 12:53:16 +0530 Subject: distribute rebalance: preserve proper mode in destination * don't set 'sticky' and 'sgid' bits to 0 without checking if the source had those bits prior to rebalance. Change-Id: Ia826cb3cfb55312cdbf00d3421f2bd06b3103ce6 BUG: 3656 Reviewed-on: http://review.gluster.com/541 Tested-by: Gluster Build System Reviewed-by: Vijay Bellur --- xlators/cluster/dht/src/dht-rebalance.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/xlators/cluster/dht/src/dht-rebalance.c b/xlators/cluster/dht/src/dht-rebalance.c index edb5c8cdc..71fd7b367 100644 --- a/xlators/cluster/dht/src/dht-rebalance.c +++ b/xlators/cluster/dht/src/dht-rebalance.c @@ -375,6 +375,7 @@ dht_migrate_file (xlator_t *this, loc_t *loc, xlator_t *from, xlator_t *to, struct iatt new_stbuf = {0,}; struct iatt stbuf = {0,}; struct iatt empty_iatt = {0,}; + ia_prot_t src_ia_prot = {0,}; fd_t *src_fd = NULL; fd_t *dst_fd = NULL; dict_t *dict = NULL; @@ -403,6 +404,9 @@ dht_migrate_file (xlator_t *this, loc_t *loc, xlator_t *from, xlator_t *to, goto out; } + /* preserve source mode, so set the same to the destination */ + src_ia_prot = stbuf.ia_prot; + /* Check if file can be migrated */ ret = __is_file_migratable (this, loc, rsp_dict, &stbuf); if (ret) @@ -490,9 +494,13 @@ dht_migrate_file (xlator_t *this, loc_t *loc, xlator_t *from, xlator_t *to, } /* source would have both sticky bit and sgid bit set, reset it to 0, - and set the source permission on destination */ - new_stbuf.ia_prot.sticky = 0; - new_stbuf.ia_prot.sgid = 0; + and set the source permission on destination, if it was not set + prior to setting rebalance-modes in source */ + if (!src_ia_prot.sticky) + new_stbuf.ia_prot.sticky = 0; + + if (!src_ia_prot.sgid) + new_stbuf.ia_prot.sgid = 0; /* TODO: if the source actually had sticky bit, or sgid bit set, we are not handling it */ -- cgit