From f4513b4de104f1c6f40f7bbe0a4bd698340db805 Mon Sep 17 00:00:00 2001 From: Anand Avati Date: Fri, 17 Jul 2009 15:34:14 +0000 Subject: Do not failover readdir in replicate Backport of http://patches.gluster.com/patch/561/ to release-2.0 Also, the failover version of afr_readdir_cbk is buggy and crashes when it is called after a failover inevitably Signed-off-by: Anand V. Avati BUG: 150 (AFR readdir should not failover to other subvolume) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=150 --- xlators/cluster/afr/src/afr-dir-read.c | 52 ++++++++++++---------------------- 1 file changed, 18 insertions(+), 34 deletions(-) (limited to 'xlators') diff --git a/xlators/cluster/afr/src/afr-dir-read.c b/xlators/cluster/afr/src/afr-dir-read.c index f74deab6df3..ba361cdd912 100644 --- a/xlators/cluster/afr/src/afr-dir-read.c +++ b/xlators/cluster/afr/src/afr-dir-read.c @@ -148,50 +148,34 @@ out: int32_t afr_readdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, - gf_dirent_t *buf) + gf_dirent_t *entries) { - afr_private_t * priv = NULL; - afr_local_t * local = NULL; - xlator_t ** children = NULL; + afr_private_t * priv = NULL; + afr_local_t * local = NULL; + xlator_t ** children = NULL; + + gf_dirent_t * entry = NULL; - int unwind = 1; - int last_tried = -1; - int this_try = -1; int child_index = -1; - priv = this->private; - children = priv->children; + priv = this->private; + children = priv->children; - local = frame->local; + local = frame->local; child_index = (long) cookie; - if (op_ret == -1) { - last_tried = local->cont.readdir.last_tried; - - if (all_tried (last_tried, priv->child_count)) { - goto out; - } - - this_try = ++local->cont.readdir.last_tried; - unwind = 0; - - STACK_WIND (frame, afr_readdir_cbk, - children[this_try], - children[this_try]->fops->readdir, - local->fd, local->cont.readdir.size, - local->cont.readdir.offset); - } + if (op_ret != -1) { + list_for_each_entry (entry, &entries->list, list) { + entry->d_ino = afr_itransform (entry->d_ino, + priv->child_count, + child_index); + } + } -out: - if (unwind) { - buf->d_ino = afr_itransform (buf->d_ino, priv->child_count, - child_index); - - AFR_STACK_UNWIND (frame, op_ret, op_errno, buf); - } + AFR_STACK_UNWIND (frame, op_ret, op_errno, entries); - return 0; + return 0; } -- cgit