From fe3d6b09a4503436a3356107a3c23e5ead4dc9fa Mon Sep 17 00:00:00 2001 From: huanghua Date: Fri, 6 Feb 2009 02:11:31 +0000 Subject: [PATCH] Branch b1_8 b=3633 i=robert.read i=oleg.drokin i=tappro clear the "hold for replay" flag for open request once a file is closed --- lustre/mdc/mdc_request.c | 58 +++++++++++-------------------------------- lustre/tests/replay-single.sh | 41 ++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 43 deletions(-) diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c index 61671bd..f29c1eb 100644 --- a/lustre/mdc/mdc_request.c +++ b/lustre/mdc/mdc_request.c @@ -627,7 +627,7 @@ static void mdc_replay_open(struct ptlrpc_request *req) EXIT; return; } - DEBUG_REQ(D_INFO, req, "mdc open data found"); + DEBUG_REQ(D_HA, req, "mdc open data found"); och = mod->mod_och; if (och != NULL) { @@ -798,36 +798,6 @@ void mdc_clear_open_replay_data(struct obd_client_handle *och) och->och_mod = NULL; } -static void mdc_commit_close(struct ptlrpc_request *req) -{ - struct mdc_open_data *mod = req->rq_cb_data; - struct ptlrpc_request *open_req; - struct obd_import *imp = req->rq_import; - - DEBUG_REQ(D_RPCTRACE, req, "close req committed"); - if (mod == NULL) - return; - - mod->mod_close_req = NULL; - req->rq_cb_data = NULL; - req->rq_commit_cb = NULL; - - open_req = mod->mod_open_req; - LASSERT(open_req != NULL); - LASSERT(open_req != LP_POISON); - LASSERT(open_req->rq_type != LI_POISON); - - DEBUG_REQ(D_RPCTRACE, open_req, "open req balanced"); - LASSERT(open_req->rq_transno != 0); - LASSERT(open_req->rq_import == imp); - - /* We no longer want to preserve this for transno-unconditional - * replay. */ - spin_lock(&open_req->rq_lock); - open_req->rq_replay = 0; - spin_unlock(&open_req->rq_lock); -} - int mdc_close(struct obd_export *exp, struct mdc_op_data *data, struct obdo *oa, struct obd_client_handle *och, struct ptlrpc_request **request) { @@ -842,7 +812,6 @@ int mdc_close(struct obd_export *exp, struct mdc_op_data *data, struct obdo *oa, sizeof(struct lustre_capa) }; int rc; struct ptlrpc_request *req; - struct mdc_open_data *mod; int bufcount = 2; ENTRY; @@ -867,18 +836,24 @@ int mdc_close(struct obd_export *exp, struct mdc_op_data *data, struct obdo *oa, /* Ensure that this close's handle is fixed up during replay. */ LASSERT(och != NULL); LASSERT(och->och_magic == OBD_CLIENT_HANDLE_MAGIC); - mod = och->och_mod; - if (likely(mod != NULL)) { - if (mod->mod_open_req->rq_type == LI_POISON) { - CERROR("LBUG POISONED open %p!\n", mod->mod_open_req); + if (likely(och->och_mod != NULL)) { + struct ptlrpc_request *open_req = och->och_mod->mod_open_req; + + if (open_req->rq_type == LI_POISON) { + CERROR("LBUG POISONED open %p!\n", open_req); LBUG(); ptlrpc_req_finished(req); req = NULL; GOTO(out, rc = -EIO); } - mod->mod_close_req = req; - DEBUG_REQ(D_RPCTRACE, mod->mod_close_req, "close req"); - DEBUG_REQ(D_RPCTRACE, mod->mod_open_req, "matched open"); + DEBUG_REQ(D_RPCTRACE, req, "close req"); + DEBUG_REQ(D_RPCTRACE, open_req, "clear open replay"); + + /* We no longer want to preserve this open for replay even + * though the open was committed. b=3632, b=3633 */ + spin_lock(&open_req->rq_lock); + open_req->rq_replay = 0; + spin_unlock(&open_req->rq_lock); } else { CDEBUG(D_RPCTRACE, "couldn't find open req; expecting error\n"); } @@ -886,9 +861,6 @@ int mdc_close(struct obd_export *exp, struct mdc_op_data *data, struct obdo *oa, mdc_close_pack(req, REQ_REC_OFF, data, oa, oa->o_valid, och); ptlrpc_req_set_repsize(req, 6, repsize); - req->rq_commit_cb = mdc_commit_close; - LASSERT(req->rq_cb_data == NULL); - req->rq_cb_data = mod; mdc_get_rpc_lock(obd->u.cli.cl_close_lock, NULL); rc = ptlrpc_queue_wait(req); @@ -906,7 +878,7 @@ int mdc_close(struct obd_export *exp, struct mdc_op_data *data, struct obdo *oa, "= %d", rc); if (rc > 0) rc = -rc; - } else if (mod == NULL) { + } else if (och->och_mod == NULL) { CERROR("Unexpected: can't find mdc_open_data, but the " "close succeeded. Please tell .\n"); } diff --git a/lustre/tests/replay-single.sh b/lustre/tests/replay-single.sh index 40e5531..09cc901 100755 --- a/lustre/tests/replay-single.sh +++ b/lustre/tests/replay-single.sh @@ -984,6 +984,47 @@ test_48() { } run_test 48 "MDS->OSC failure during precreate cleanup (2824)" +test_49a() { + multiop $DIR/$tfile O_c & + pid=$! + sleep 1 + rm -rf $DIR/$tfile + +#define OBD_FAIL_MDS_ALL_REPLY_NET 0x122 + do_facet mds "lctl set_param fail_loc=0x80000122" + kill -USR1 $pid + do_facet mds "lctl set_param fail_loc=0" + + replay_barrier_nodf mds + fail mds + + wait $pid || return 1 + $CHECKSTAT -t file $DIR/$tfile && return 2 + return 0 +} +run_test 49a "mds fail after close reply is dropped: open|create " + +test_49c() { + touch $DIR/$tfile + multiop $DIR/$tfile o_c & + pid=$! + sleep 1 + rm -rf $DIR/$tfile + +#define OBD_FAIL_MDS_ALL_REPLY_NET 0x122 + do_facet mds "lctl set_param fail_loc=0x80000122" + kill -USR1 $pid + do_facet mds "lctl set_param fail_loc=0" + + replay_barrier_nodf mds + fail mds + + wait $pid || return 1 + $CHECKSTAT -t file $DIR/$tfile && return 2 + return 0 +} +run_test 49c "mds fail after close reply is dropped: open" + test_50() { local oscdev=`do_facet mds lctl get_param -n devices | grep ${ost1_svc}-osc | awk '{print $1}' | head -1` [ "$oscdev" ] || return 1 -- 1.8.3.1