'lookup-unhashed' option of distribute should be 'auto' by default.

* Added 'auto' option, older boolean options works as they used to.

* This option should make 'create' rate faster, also handles
  self-healing of linkfile properly in case of scaling to
  more servers or filesystem is getting full.

Signed-off-by: Amar Tumballi <amar@gluster.com>
Signed-off-by: Anand V. Avati <avati@dev.gluster.com>

BUG: 584 (automatically configure 'lookup-unhashed' option)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=584
This commit is contained in:
Amar Tumballi 2010-02-05 01:38:29 +00:00 committed by Anand V. Avati
parent c3005ce736
commit 137f94ed12
5 changed files with 76 additions and 22 deletions

View File

@ -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,

View File

@ -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

View File

@ -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,

View File

@ -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,
},

View File

@ -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,
},