From 9cfa22f828f69c9f1f48b5e8994a4dff48d283a6 Mon Sep 17 00:00:00 2001 From: Pranith K Date: Mon, 7 Feb 2011 05:42:18 +0000 Subject: protocol/client: decrement reopen fd count in cases of re-open errors In post-client-handshake client tries to re-open files, dirs, but if those files/dirs are already deleted when the brick is down the reopens won't even get triggered. In those cases the re-open fd count needs to be decremented to make sure the child up is triggered. I have also made similar changes in all the error cases of re-open/re-open-dir cbks. Lock recovery is already handling all these errors. Signed-off-by: Pranith Kumar K Signed-off-by: Anand V. Avati BUG: 1761 (incorrect self-heal behaviour when files are deleted) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1761 --- xlators/protocol/client/src/client-handshake.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'xlators') diff --git a/xlators/protocol/client/src/client-handshake.c b/xlators/protocol/client/src/client-handshake.c index 496c4893517..4577dda5d65 100644 --- a/xlators/protocol/client/src/client-handshake.c +++ b/xlators/protocol/client/src/client-handshake.c @@ -407,13 +407,17 @@ client3_1_reopen_cbk (struct rpc_req *req, struct iovec *iov, int count, local->loc.path, rsp.fd); } - if (rsp.op_ret == -1) + if (rsp.op_ret == -1) { + ret = -1; goto out; + } fdctx = local->fdctx; - if (!fdctx) + if (!fdctx) { + ret = -1; goto out; + } pthread_mutex_lock (&conf->lock); { @@ -448,6 +452,9 @@ out: if (fdctx) client_fdctx_destroy (frame->this, fdctx); + if ((ret < 0) && frame && frame->this && conf) + decrement_reopen_fd_count (frame->this, conf); + frame->local = NULL; STACK_DESTROY (frame->root); @@ -516,11 +523,15 @@ client3_1_reopendir_cbk (struct rpc_req *req, struct iovec *iov, int count, } decrement_reopen_fd_count (frame->this, conf); + ret = 0; out: if (fdctx) client_fdctx_destroy (frame->this, fdctx); + if ((ret < 0) && frame && frame->this && conf) + decrement_reopen_fd_count (frame->this, conf); + if (frame) { frame->local = NULL; STACK_DESTROY (frame->root); @@ -555,6 +566,7 @@ protocol_client_reopendir (xlator_t *this, clnt_fd_ctx_t *fdctx) local = GF_CALLOC (1, sizeof (*local), gf_client_mt_clnt_local_t); if (!local) { + ret = -1; goto out; } @@ -564,6 +576,7 @@ protocol_client_reopendir (xlator_t *this, clnt_fd_ctx_t *fdctx) frame = create_frame (this, this->ctx->pool); if (!frame) { + ret = -1; goto out; } @@ -596,6 +609,9 @@ out: if (path) GF_FREE (path); + if ((ret < 0) && this && conf) { + decrement_reopen_fd_count (this, conf); + } return 0; @@ -625,11 +641,13 @@ protocol_client_reopen (xlator_t *this, clnt_fd_ctx_t *fdctx) frame = create_frame (this, this->ctx->pool); if (!frame) { + ret = -1; goto out; } local = GF_CALLOC (1, sizeof (*local), gf_client_mt_clnt_local_t); if (!local) { + ret = -1; goto out; } @@ -667,6 +685,10 @@ out: if (path) GF_FREE (path); + if ((ret < 0) && this && conf) { + decrement_reopen_fd_count (this, conf); + } + return 0; } -- cgit