diff options
| author | krishna <krishna@gluster.com> | 2009-04-22 23:43:58 -0700 | 
|---|---|---|
| committer | Anand V. Avati <avati@amp.gluster.com> | 2009-04-23 15:19:58 +0530 | 
| commit | 99351618cd15da15ee875f143154ea7f8e28eaf4 (patch) | |
| tree | e78affcfece2f64f28ed77dd736043c00bcf6921 | |
| parent | b6f634f602559cfe0c4609f16c9f33a32243b578 (diff) | |
"option unhashed-sticky-bit on/off"
"option unhashed-sticky-bit on/off" will configure distribute to set or not
the S_ISVTX bit in the stat.st_mode of the actual file in case it is
pointed to by the link file. This can be enabled during migration.
Signed-off-by: Anand V. Avati <avati@amp.gluster.com>
| -rw-r--r-- | xlators/cluster/dht/src/dht-common.c | 21 | ||||
| -rw-r--r-- | xlators/cluster/dht/src/dht-common.h | 1 | ||||
| -rw-r--r-- | xlators/cluster/dht/src/dht.c | 8 | 
3 files changed, 25 insertions, 5 deletions
diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c index fc0e7706c8f..4bf86263d1e 100644 --- a/xlators/cluster/dht/src/dht-common.c +++ b/xlators/cluster/dht/src/dht-common.c @@ -198,12 +198,14 @@ dht_revalidate_cbk (call_frame_t *frame, void *cookie, xlator_t *this,          int           this_call_cnt = 0;          call_frame_t *prev          = NULL;  	dht_layout_t *layout        = NULL; +	dht_conf_t   *conf          = NULL;  	int           ret  = -1;  	int           is_dir = 0;  	int           is_linkfile = 0;          local = frame->local;          prev  = cookie; +	conf = this->private;          LOCK (&frame->lock);          { @@ -286,9 +288,11 @@ unlock:          if (is_last_call (this_call_cnt)) {  		if (!S_ISDIR (local->stbuf.st_mode)  		    && (local->hashed_subvol != local->cached_subvol) -		    && (local->stbuf.st_nlink == 1)) +		    && (local->stbuf.st_nlink == 1) +		    && (conf->unhashed_sticky_bit)) {  			local->stbuf.st_mode |= S_ISVTX; -		 +		} +  		if (local->layout_mismatch) {  			local->op_ret = -1;  			local->op_errno = ESTALE; @@ -310,10 +314,12 @@ dht_lookup_linkfile_create_cbk (call_frame_t *frame, void *cookie,  {  	dht_local_t  *local = NULL;  	xlator_t     *cached_subvol = NULL; +	dht_conf_t   *conf = NULL;          int           ret = -1;  	local = frame->local;  	cached_subvol = local->cached_subvol; +	conf = this->private;          ret = dht_layout_inode_set (this, local->cached_subvol, inode);          if (ret < 0) { @@ -326,8 +332,10 @@ dht_lookup_linkfile_create_cbk (call_frame_t *frame, void *cookie,          }  	local->op_ret = 0; -	if (local->stbuf.st_nlink == 1) +	if ((local->stbuf.st_nlink == 1) +	    && (conf->unhashed_sticky_bit)) {  		local->stbuf.st_mode |= S_ISVTX; +	}  unwind:  	DHT_STACK_UNWIND (frame, local->op_ret, local->op_errno, @@ -521,10 +529,11 @@ dht_lookup_linkfile_cbk (call_frame_t *frame, void *cookie,  	dht_layout_t *layout = NULL;  	xlator_t     *subvol = NULL;  	loc_t        *loc = NULL; +	dht_conf_t   *conf = NULL;          prev   = cookie;  	subvol = prev->this; - +	conf   = this->private;  	local  = frame->local;  	loc    = &local->loc; @@ -549,8 +558,10 @@ dht_lookup_linkfile_cbk (call_frame_t *frame, void *cookie,                  goto err;          } -	if (stbuf->st_nlink == 1) +	if ((stbuf->st_nlink == 1) +	    && (conf->unhashed_sticky_bit)) {  		stbuf->st_mode |= S_ISVTX; +	}          dht_itransform (this, prev->this, stbuf->st_ino, &stbuf->st_ino);  	layout = dht_layout_for_subvol (this, prev->this); diff --git a/xlators/cluster/dht/src/dht-common.h b/xlators/cluster/dht/src/dht-common.h index 6d784796271..63a8bb2131d 100644 --- a/xlators/cluster/dht/src/dht-common.h +++ b/xlators/cluster/dht/src/dht-common.h @@ -119,6 +119,7 @@ struct dht_conf {          dht_du_t      *du_stats;          uint32_t       min_free_disk;          int32_t        refresh_interval; +        gf_boolean_t   unhashed_sticky_bit;  	struct timeval last_stat_fetch;  };  typedef struct dht_conf dht_conf_t; diff --git a/xlators/cluster/dht/src/dht.c b/xlators/cluster/dht/src/dht.c index ddf95832f66..4dac7301ec9 100644 --- a/xlators/cluster/dht/src/dht.c +++ b/xlators/cluster/dht/src/dht.c @@ -110,6 +110,14 @@ init (xlator_t *this)  		gf_string2boolean (lookup_unhashed_str,  				   &conf->search_unhashed);  	} + +	conf->unhashed_sticky_bit = 0; + +	if (dict_get_str (this->options, "unhashed-sticky-bit", +			  &lookup_unhashed_str) == 0) { +	        gf_string2boolean (lookup_unhashed_str, +				   &conf->unhashed_sticky_bit); +	}          conf->min_free_disk = 10;  | 
