From b8fb6096b94905e2d304cd4219a70939495bfcc5 Mon Sep 17 00:00:00 2001 From: Pranith Kumar K Date: Mon, 4 Jun 2012 19:13:49 +0530 Subject: protocol/client: Remember the gfid of opened fd This is needed when the fresh lookup triggers self-heal, gfid won't be present in inode yet. Similar situation happens with Rebalance as it does not perform inode_link. Added similar fix for re-opendir. Removed inode from fdctx and removed some duplication of code. Change-Id: Ic94e5738c8585ed86801d2eed9ddab1015246710 BUG: 826080 Signed-off-by: Pranith Kumar K Reviewed-on: http://review.gluster.com/3517 Tested-by: Gluster Build System Reviewed-by: Amar Tumballi Reviewed-by: Anand Avati --- xlators/protocol/client/src/client-handshake.c | 54 ++++++++------------------ 1 file changed, 16 insertions(+), 38 deletions(-) (limited to 'xlators/protocol/client/src/client-handshake.c') diff --git a/xlators/protocol/client/src/client-handshake.c b/xlators/protocol/client/src/client-handshake.c index 0b82ed4e8..d8ca84021 100644 --- a/xlators/protocol/client/src/client-handshake.c +++ b/xlators/protocol/client/src/client-handshake.c @@ -747,7 +747,7 @@ client_reacquire_lock_cbk (struct rpc_req *req, struct iovec *iov, gf_log (this->name, GF_LOG_DEBUG, "%s type lock reacquired on file " "with gfid %s from %"PRIu64 " to %"PRIu64, - get_lk_type (lock.l_type), uuid_utoa (fdctx->inode->gfid), + get_lk_type (lock.l_type), uuid_utoa (fdctx->gfid), lock.l_start, lock.l_start + lock.l_len); if (!clnt_fd_lk_local_error_status (this, local) && @@ -799,7 +799,7 @@ _client_reacquire_lock (xlator_t *this, clnt_fd_ctx_t *fdctx) if (!local) { gf_log (this->name, GF_LOG_WARNING, "clnt_fd_lk_local_create " "failed, aborting reacquring of locks on %s.", - uuid_utoa (fdctx->inode->gfid)); + uuid_utoa (fdctx->gfid)); clnt_reacquire_lock_error (this, fdctx, conf); goto out; } @@ -825,7 +825,7 @@ _client_reacquire_lock (xlator_t *this, clnt_fd_ctx_t *fdctx) (void) gf_proto_flock_from_flock (&req.flock, &flock); - memcpy (req.gfid, fdctx->inode->gfid, 16); + memcpy (req.gfid, fdctx->gfid, 16); frame = create_frame (this, this->ctx->pool); if (!frame) { @@ -844,7 +844,7 @@ _client_reacquire_lock (xlator_t *this, clnt_fd_ctx_t *fdctx) if (ret) { gf_log (this->name, GF_LOG_WARNING, "reacquiring locks failed on file with gfid %s", - uuid_utoa (fdctx->inode->gfid)); + uuid_utoa (fdctx->gfid)); break; } @@ -1090,34 +1090,25 @@ protocol_client_reopendir (xlator_t *this, clnt_fd_ctx_t *fdctx) int ret = -1; gfs3_opendir_req req = {{0,},}; clnt_local_t *local = NULL; - inode_t *inode = NULL; - char *path = NULL; call_frame_t *frame = NULL; clnt_conf_t *conf = NULL; if (!this || !fdctx) goto out; - inode = fdctx->inode; conf = this->private; - ret = inode_path (inode, NULL, &path); - if (ret < 0) { - gf_log (this->name, GF_LOG_WARNING, - "couldn't build path from inode %s", - uuid_utoa (inode->gfid)); - goto out; - } - local = mem_get0 (this->local_pool); if (!local) { ret = -1; goto out; } - local->fdctx = fdctx; - local->loc.path = path; - path = NULL; + + uuid_copy (local->loc.gfid, fdctx->gfid); + ret = loc_path (&local->loc, NULL); + if (ret < 0) + goto out; frame = create_frame (this, this->ctx->pool); if (!frame) { @@ -1125,7 +1116,7 @@ protocol_client_reopendir (xlator_t *this, clnt_fd_ctx_t *fdctx) goto out; } - memcpy (req.gfid, inode->gfid, 16); + memcpy (req.gfid, fdctx->gfid, 16); gf_log (frame->this->name, GF_LOG_DEBUG, "attempting reopen on %s", local->loc.path); @@ -1153,8 +1144,6 @@ out: if (local) client_local_wipe (local); - if (path) - GF_FREE (path); if ((ret < 0) && this && conf) { decrement_reopen_fd_count (this, conf); } @@ -1169,25 +1158,14 @@ protocol_client_reopen (xlator_t *this, clnt_fd_ctx_t *fdctx) int ret = -1; gfs3_open_req req = {{0,},}; clnt_local_t *local = NULL; - inode_t *inode = NULL; - char *path = NULL; call_frame_t *frame = NULL; clnt_conf_t *conf = NULL; if (!this || !fdctx) goto out; - inode = fdctx->inode; conf = this->private; - ret = inode_path (inode, NULL, &path); - if (ret < 0) { - gf_log (this->name, GF_LOG_WARNING, - "couldn't build path from inode %s", - uuid_utoa (inode->gfid)); - goto out; - } - frame = create_frame (this, this->ctx->pool); if (!frame) { ret = -1; @@ -1201,11 +1179,14 @@ protocol_client_reopen (xlator_t *this, clnt_fd_ctx_t *fdctx) } local->fdctx = fdctx; - local->loc.path = path; - path = NULL; + uuid_copy (local->loc.gfid, fdctx->gfid); + ret = loc_path (&local->loc, NULL); + if (ret < 0) + goto out; + frame->local = local; - memcpy (req.gfid, inode->gfid, 16); + memcpy (req.gfid, fdctx->gfid, 16); req.flags = gf_flags_from_flags (fdctx->flags); gf_log (frame->this->name, GF_LOG_DEBUG, @@ -1232,9 +1213,6 @@ out: if (local) client_local_wipe (local); - if (path) - GF_FREE (path); - if ((ret < 0) && this && conf) { decrement_reopen_fd_count (this, conf); } -- cgit