summaryrefslogtreecommitdiffstats
path: root/xlators/protocol/client/src/client-handshake.c
diff options
context:
space:
mode:
authorPranith Kumar K <pranithk@gluster.com>2012-06-04 19:13:49 +0530
committerAnand Avati <avati@redhat.com>2012-06-06 12:35:44 -0700
commitb8fb6096b94905e2d304cd4219a70939495bfcc5 (patch)
treebe69ece092ed352f7d71e017c7df482df42c5e1c /xlators/protocol/client/src/client-handshake.c
parent497532ef7e5c4361ac6c2c76fe5f2d209b986953 (diff)
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 <pranithk@gluster.com> Reviewed-on: http://review.gluster.com/3517 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Amar Tumballi <amarts@redhat.com> Reviewed-by: Anand Avati <avati@redhat.com>
Diffstat (limited to 'xlators/protocol/client/src/client-handshake.c')
-rw-r--r--xlators/protocol/client/src/client-handshake.c54
1 files changed, 16 insertions, 38 deletions
diff --git a/xlators/protocol/client/src/client-handshake.c b/xlators/protocol/client/src/client-handshake.c
index 0b82ed4e8d5..d8ca8402109 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);
}