diff options
| -rw-r--r-- | xlators/cluster/dht/src/dht-common.c | 49 | ||||
| -rw-r--r-- | xlators/cluster/dht/src/dht-common.h | 3 | ||||
| -rw-r--r-- | xlators/cluster/dht/src/dht.c | 13 | ||||
| -rw-r--r-- | xlators/cluster/dht/src/nufa.c | 19 | ||||
| -rw-r--r-- | xlators/cluster/dht/src/switch.c | 14 | 
5 files changed, 76 insertions, 22 deletions
diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c index ac617380098..d677e7ee49a 100644 --- a/xlators/cluster/dht/src/dht-common.c +++ b/xlators/cluster/dht/src/dht-common.c @@ -667,6 +667,8 @@ dht_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this,          loc_t        *loc           = NULL;          call_frame_t *prev          = NULL;          int           ret           = 0; +        uint64_t      tmp_layout    = 0; +        dht_layout_t *parent_layout = NULL;          conf  = this->private; @@ -675,11 +677,21 @@ dht_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this,          loc   = &local->loc;  	if (ENTRY_MISSING (op_ret, op_errno)) { -		if (conf->search_unhashed) { +                if (conf->search_unhashed == GF_DHT_LOOKUP_UNHASHED_ON) {  			local->op_errno = ENOENT;  			dht_lookup_everywhere (frame, this, loc);  			return 0;  		} +                if ((conf->search_unhashed == GF_DHT_LOOKUP_UNHASHED_AUTO) && +                    (loc->parent)) { +                        ret = inode_ctx_get (loc->parent, this, &tmp_layout); +                        parent_layout = (dht_layout_t *)(long)tmp_layout; +                        if (parent_layout->search_unhashed) { +                                local->op_errno = ENOENT; +                                dht_lookup_everywhere (frame, this, loc); +                                return 0; +                        } +                }  	}   	if (op_ret == 0) { @@ -2096,15 +2108,20 @@ dht_readdirp_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int op_ret,  	xlator_t     *next_subvol = NULL;          off_t         next_offset = 0;  	int           count = 0; - +        dht_layout_t *layout = 0; +        dht_conf_t   *conf   = NULL; +        xlator_t     *subvol = 0;  	INIT_LIST_HEAD (&entries.list);  	prev = cookie;  	local = frame->local; +	conf  = this->private;  	if (op_ret < 0)  		goto done; +        layout = dht_layout_get (this, local->fd->inode); +  	list_for_each_entry (orig_entry, (&orig_entries->list), list) {                  next_offset = orig_entry->d_off; @@ -2121,6 +2138,16 @@ dht_readdirp_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int op_ret,                          goto unwind;                  } +                /* Do this if conf->search_unhashed is set to "auto" */ +                if (conf->search_unhashed == GF_DHT_LOOKUP_UNHASHED_AUTO) { +                        subvol = dht_layout_search (this, layout, +                                                    orig_entry->d_name); +                        if (!subvol || (subvol != prev->this)) { +                                /* TODO: Count the number of entries which need +                                   linkfile to prove its existance in fs */ +                                layout->search_unhashed++; +                        } +                }                  entry->d_stat = orig_entry->d_stat;                  dht_itransform (this, prev->this, orig_entry->d_ino, @@ -2183,15 +2210,20 @@ dht_readdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,  	xlator_t     *next_subvol = NULL;          off_t         next_offset = 0;  	int           count = 0; - +        dht_layout_t *layout = 0; +        dht_conf_t   *conf   = NULL; +        xlator_t     *subvol = 0;  	INIT_LIST_HEAD (&entries.list);  	prev = cookie;  	local = frame->local; +	conf  = this->private;  	if (op_ret < 0)  		goto done; +        layout = dht_layout_get (this, local->fd->inode); +  	list_for_each_entry (orig_entry, (&orig_entries->list), list) {                  next_offset = orig_entry->d_off; @@ -2208,6 +2240,17 @@ dht_readdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,                          goto unwind;                  } +                /* Do this if conf->search_unhashed is set to "auto" */ +                if (conf->search_unhashed == GF_DHT_LOOKUP_UNHASHED_AUTO) { +                        subvol = dht_layout_search (this, layout, +                                                    orig_entry->d_name); +                        if (!subvol || (subvol != prev->this)) { +                                /* TODO: Count the number of entries which need +                                   linkfile to prove its existance in fs */ +                                layout->search_unhashed++; +                        } +                } +                  dht_itransform (this, prev->this, orig_entry->d_ino,                                  &entry->d_ino);                  dht_itransform (this, prev->this, orig_entry->d_off, diff --git a/xlators/cluster/dht/src/dht-common.h b/xlators/cluster/dht/src/dht-common.h index f8a60b52038..ca4a1d33e10 100644 --- a/xlators/cluster/dht/src/dht-common.h +++ b/xlators/cluster/dht/src/dht-common.h @@ -25,6 +25,8 @@  #ifndef _DHT_H  #define _DHT_H +#define GF_DHT_LOOKUP_UNHASHED_ON   1 +#define GF_DHT_LOOKUP_UNHASHED_AUTO 2  typedef int (*dht_selfheal_dir_cbk_t) (call_frame_t *frame, void *cookie,  				       xlator_t *this, @@ -37,6 +39,7 @@ struct dht_layout {          int               gen;  	int               type;          int               ref;   /* use with dht_conf_t->layout_lock */ +        int               search_unhashed;          struct {  		int       err;   /* 0 = normal  				   -1 = dir exists and no xattr diff --git a/xlators/cluster/dht/src/dht.c b/xlators/cluster/dht/src/dht.c index d947ae8145b..d7f187457fc 100644 --- a/xlators/cluster/dht/src/dht.c +++ b/xlators/cluster/dht/src/dht.c @@ -259,10 +259,11 @@ init (xlator_t *this)                  goto err;          } -	conf->search_unhashed = 0; - +	conf->search_unhashed =  GF_DHT_LOOKUP_UNHASHED_AUTO;  	if (dict_get_str (this->options, "lookup-unhashed", &temp_str) == 0) { -		gf_string2boolean (temp_str, &conf->search_unhashed); +                /* If option is not "auto", other options _should_ be boolean */ +                if (strcasecmp (temp_str, "auto")) +                        gf_string2boolean (temp_str, &conf->search_unhashed);  	}  	conf->unhashed_sticky_bit = 0; @@ -409,8 +410,10 @@ struct xlator_cbks cbks = {  struct volume_options options[] = { -        { .key  = {"lookup-unhashed"},  -	  .type = GF_OPTION_TYPE_BOOL  +        { .key  = {"lookup-unhashed"}, +          .value = {"auto", "yes", "no", "enable", "disable", "1", "0", +                    "on", "off"}, +	  .type = GF_OPTION_TYPE_STR  	},          { .key  = {"min-free-disk"},            .type = GF_OPTION_TYPE_PERCENT_OR_SIZET, diff --git a/xlators/cluster/dht/src/nufa.c b/xlators/cluster/dht/src/nufa.c index 5fe233dfe6e..96cc5fe3e2e 100644 --- a/xlators/cluster/dht/src/nufa.c +++ b/xlators/cluster/dht/src/nufa.c @@ -560,12 +560,11 @@ init (xlator_t *this)                  goto err;          } -	conf->search_unhashed = 0; - -	if (dict_get_str (this->options, "lookup-unhashed", -			  &temp_str) == 0) { -		gf_string2boolean (temp_str, -				   &conf->search_unhashed); +	conf->search_unhashed =  GF_DHT_LOOKUP_UNHASHED_AUTO; +	if (dict_get_str (this->options, "lookup-unhashed", &temp_str) == 0) { +                /* If option is not "auto", other options _should_ be boolean */ +                if (strcasecmp (temp_str, "auto")) +                        gf_string2boolean (temp_str, &conf->search_unhashed);  	}          ret = dht_init_subvolumes (this, conf); @@ -734,12 +733,14 @@ struct xlator_cbks cbks = {  struct volume_options options[] = { +        { .key  = {"lookup-unhashed"}, +          .value = {"auto", "yes", "no", "enable", "disable", "1", "0", +                    "on", "off"}, +	  .type = GF_OPTION_TYPE_STR +	},  	{ .key  = {"local-volume-name"},  	  .type = GF_OPTION_TYPE_XLATOR  	}, -        { .key  = {"lookup-unhashed"}, -	  .type = GF_OPTION_TYPE_BOOL -	},          { .key  = {"min-free-disk"},            .type = GF_OPTION_TYPE_PERCENT_OR_SIZET,          }, diff --git a/xlators/cluster/dht/src/switch.c b/xlators/cluster/dht/src/switch.c index 6670f0e3b3b..5a36f8dab04 100644 --- a/xlators/cluster/dht/src/switch.c +++ b/xlators/cluster/dht/src/switch.c @@ -887,9 +887,11 @@ init (xlator_t *this)                  goto err;          } -	conf->search_unhashed = 1; +	conf->search_unhashed =  GF_DHT_LOOKUP_UNHASHED_AUTO;  	if (dict_get_str (this->options, "lookup-unhashed", &temp_str) == 0) { -		gf_string2boolean (temp_str, &conf->search_unhashed); +                /* If option is not "auto", other options _should_ be boolean */ +                if (strcasecmp (temp_str, "auto")) +                        gf_string2boolean (temp_str, &conf->search_unhashed);  	}  	conf->unhashed_sticky_bit = 0; @@ -1039,12 +1041,14 @@ struct xlator_cbks cbks = {  struct volume_options options[] = { +        { .key  = {"lookup-unhashed"}, +          .value = {"auto", "yes", "no", "enable", "disable", "1", "0", +                    "on", "off"}, +	  .type = GF_OPTION_TYPE_STR +	},  	{ .key  = {"pattern.switch.case"},  	  .type = GF_OPTION_TYPE_ANY  	}, -        { .key  = {"lookup-unhashed"}, -	  .type = GF_OPTION_TYPE_BOOL -	},          { .key  = {"min-free-disk"},            .type = GF_OPTION_TYPE_PERCENT_OR_SIZET,          },  | 
