summaryrefslogtreecommitdiffstats
path: root/xlators/cluster/dht/src/dht-common.c
diff options
context:
space:
mode:
authorAmar Tumballi <amar@gluster.com>2010-02-05 01:38:29 +0000
committerAnand V. Avati <avati@dev.gluster.com>2010-02-06 08:44:09 -0800
commit137f94ed123b1c7c7ada541aaa599679e19888f6 (patch)
treefd1e9cc177cd77077bd516a39b8d0c8293ff72b3 /xlators/cluster/dht/src/dht-common.c
parentc3005ce736d6bb3391e5f46930d355fc6b0f4d6e (diff)
'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
Diffstat (limited to 'xlators/cluster/dht/src/dht-common.c')
-rw-r--r--xlators/cluster/dht/src/dht-common.c49
1 files changed, 46 insertions, 3 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,