From 52b02bbabaaa78061c6b223715f57853cbcfd652 Mon Sep 17 00:00:00 2001 From: Anand Avati Date: Fri, 23 Oct 2009 08:22:49 +0000 Subject: protocol/server: send fresh lookups on revalidate failures also unlink non existent dentries in lookup_cbk Signed-off-by: Anand V. Avati BUG: 315 (generation number support) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=315 --- xlators/protocol/server/src/server-protocol.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'xlators/protocol') diff --git a/xlators/protocol/server/src/server-protocol.c b/xlators/protocol/server/src/server-protocol.c index 4c222c3ff4b..415d53c9db1 100644 --- a/xlators/protocol/server/src/server-protocol.c +++ b/xlators/protocol/server/src/server-protocol.c @@ -2095,9 +2095,24 @@ server_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t gf_errno = 0; int32_t ret = -1; inode_t *link_inode = NULL; + loc_t fresh_loc = {0,}; state = CALL_STATE(frame); + if (state->is_revalidate == 1 && op_ret == -1) { + state->is_revalidate = 2; + loc_copy (&fresh_loc, &state->loc); + inode_unref (fresh_loc.inode); + fresh_loc.inode = inode_new (state->itable); + + STACK_WIND (frame, server_lookup_cbk, + BOUND_XL (frame), BOUND_XL (frame)->fops->lookup, + &fresh_loc, state->dict); + + loc_wipe (&fresh_loc); + return 0; + } + if (dict) { dict_len = dict_serialized_length (dict); if (dict_len < 0) { @@ -2146,13 +2161,18 @@ server_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this, gf_stat_from_stat (&rsp->stat, stbuf); - if (inode->ino == 0) { + if (inode->ino != 1) { link_inode = inode_link (inode, state->loc.parent, state->loc.name, stbuf); inode_lookup (link_inode); inode_unref (link_inode); } } else { + if (state->is_revalidate && op_errno == ENOENT) { + inode_unlink (state->loc.inode, state->loc.parent, + state->loc.name); + } + gf_log (this->name, (op_errno == ENOENT ? GF_LOG_TRACE : GF_LOG_DEBUG), "%"PRId64": LOOKUP %s (%"PRId64") ==> %"PRId32" (%s)", @@ -2308,6 +2328,8 @@ server_lookup_resume (call_frame_t *frame, xlator_t *bound_xl) if (!state->loc.inode) state->loc.inode = inode_new (state->itable); + else + state->is_revalidate = 1; STACK_WIND (frame, server_lookup_cbk, bound_xl, bound_xl->fops->lookup, -- cgit