From c52f66ee096c9c4fb6384427e1b5435ba5718990 Mon Sep 17 00:00:00 2001 From: Amar Tumballi Date: Thu, 21 Apr 2011 04:20:13 +0000 Subject: cluster/distribute: corrected layout mismatch handling logic Signed-off-by: Amar Tumballi Signed-off-by: Anand Avati BUG: 2281 (I/O operations exit when add-brick is done) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2281 --- xlators/cluster/dht/src/dht-common.c | 160 +++-------------------------------- xlators/cluster/dht/src/dht-common.h | 4 + 2 files changed, 17 insertions(+), 147 deletions(-) diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c index 8a0897bd1d7..ac713384abe 100644 --- a/xlators/cluster/dht/src/dht-common.c +++ b/xlators/cluster/dht/src/dht-common.c @@ -204,138 +204,6 @@ selfheal: return 0; } -int -dht_lookup_root_dir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, - int op_ret, int op_errno, - inode_t *inode, struct iatt *stbuf, dict_t *xattr, - struct iatt *postparent) -{ - dht_conf_t *conf = NULL; - dht_local_t *local = NULL; - int this_call_cnt = 0; - call_frame_t *prev = NULL; - dht_layout_t *layout = NULL; - int ret = 0; - int is_dir = 0; - - conf = this->private; - local = frame->local; - prev = cookie; - - layout = local->layout; - - LOCK (&frame->lock); - { - ret = dht_layout_merge (this, layout, prev->this, - op_ret, op_errno, xattr); - - if (op_ret == -1) { - local->op_errno = op_errno; - gf_log (this->name, GF_LOG_ERROR, - "lookup of %s on %s returned error (%s)", - local->loc.path, prev->this->name, - strerror (op_errno)); - goto unlock; - } - - is_dir = check_is_dir (inode, stbuf, xattr); - if (!is_dir) { - gf_log (this->name, GF_LOG_CRITICAL, - "lookup of %s on %s returned non dir 0%o", - local->loc.path, prev->this->name, - stbuf->ia_type); - goto unlock; - } - - local->op_ret = 0; - if (local->xattr == NULL) - local->xattr = dict_ref (xattr); - if (local->inode == NULL) - local->inode = inode_ref (inode); - - dht_iatt_merge (this, &local->stbuf, stbuf, prev->this); - - if (prev->this == dht_first_up_subvol (this)) { - local->ia_ino = local->stbuf.ia_ino; - } - - } -unlock: - UNLOCK (&frame->lock); - - - this_call_cnt = dht_frame_return (frame); - - if (is_last_call (this_call_cnt)) { - if (local->op_ret == 0) { - ret = dht_layout_normalize (this, &local->loc, layout); - if (ret != 0) { - gf_log (this->name, GF_LOG_INFO, - "fixing assignment on %s", - local->loc.path); - } - - dht_layout_set (this, local->inode, layout); - } - - DHT_STACK_UNWIND (lookup, frame, local->op_ret, local->op_errno, - local->inode, &local->stbuf, local->xattr, - &local->postparent); - } - - return 0; -} - -static int -dht_do_fresh_lookup_on_root (xlator_t *this, call_frame_t *frame) -{ - dht_local_t *local = NULL; - dht_conf_t *conf = NULL; - int ret = -1; - int call_cnt = 0; - int i = 0; - - local = frame->local; - conf = this->private; - if (!conf) - goto err; - - if (local->layout) { - dht_layout_unref (this, local->layout); - local->layout = NULL; - } - - ret = dict_set_uint32 (local->xattr_req, - "trusted.glusterfs.dht", 4 * 4); - if (ret) - gf_log (this->name, GF_LOG_DEBUG, - "failed to set the dict entry for dht"); - - call_cnt = local->call_cnt = conf->subvolume_cnt; - - local->layout = dht_layout_new (this, - conf->subvolume_cnt); - if (!local->layout) { - local->op_errno = ENOMEM; - gf_log (this->name, GF_LOG_ERROR, - "Out of memory"); - goto err; - } - - for (i = 0; i < call_cnt; i++) { - STACK_WIND (frame, dht_lookup_root_dir_cbk, - conf->subvolumes[i], - conf->subvolumes[i]->fops->lookup, - &local->loc, local->xattr_req); - } - - return 0; -err: - DHT_STACK_UNWIND (lookup, frame, -1, local->op_errno, - local->inode, &local->stbuf, local->xattr, - &local->postparent); - return 0; -} int dht_revalidate_cbk (call_frame_t *frame, void *cookie, xlator_t *this, @@ -351,7 +219,6 @@ dht_revalidate_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int ret = -1; int is_dir = 0; int is_linkfile = 0; - unsigned char root_gfid[16] = {0,}; local = frame->local; prev = cookie; @@ -374,10 +241,10 @@ dht_revalidate_cbk (call_frame_t *frame, void *cookie, xlator_t *this, } if (op_errno == ESTALE) { - /* propogate the ESTALE to parent. - * setting local->layout_mismatch would send + /* propogate the ESTALE to parent. + * setting local->return_estale would return * ESTALE to parent. */ - local->layout_mismatch = 1; + local->return_estale = 1; } goto unlock; @@ -404,7 +271,7 @@ dht_revalidate_cbk (call_frame_t *frame, void *cookie, xlator_t *this, gf_log (this->name, GF_LOG_INFO, "linkfile found in revalidate for %s", local->loc.path); - local->layout_mismatch = 1; + local->return_estale = 1; goto unlock; } @@ -451,18 +318,17 @@ out: } if (local->layout_mismatch) { + /* Found layout mismatch in the directory, need to + fix this in the inode context */ + dht_layout_unref (this, local->layout); + local->layout = NULL; + dht_lookup_directory (frame, this, &local->loc); + return 0; + } + + if (local->return_estale) { local->op_ret = -1; local->op_errno = ESTALE; - - /* Because for 'root' inode, there is no FRESH lookup - * sent from FUSE layer upon ESTALE, we need to handle - * that one case here */ - root_gfid[15] = 1; - if (!local->loc.parent && - !uuid_compare (local->loc.inode->gfid, root_gfid)) { - dht_do_fresh_lookup_on_root (this, frame); - return 0; - } } WIPE (&local->postparent); diff --git a/xlators/cluster/dht/src/dht-common.h b/xlators/cluster/dht/src/dht-common.h index 0a39da97228..edb7f926f9a 100644 --- a/xlators/cluster/dht/src/dht-common.h +++ b/xlators/cluster/dht/src/dht-common.h @@ -132,6 +132,10 @@ struct dht_local { /*Marker Related*/ struct marker_str marker; + + /* flag used to make sure we need to return estale in + {lookup,revalidate}_cbk */ + char return_estale; }; typedef struct dht_local dht_local_t; -- cgit