From 285ecd13a73ae69e775f851df95abb4390db0b94 Mon Sep 17 00:00:00 2001 From: huanghua Date: Fri, 6 Feb 2009 02:27:56 +0000 Subject: [PATCH] Branch b1_6 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 | 55 +++++++++++-------------------------------- lustre/tests/replay-single.sh | 41 ++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 41 deletions(-) diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c index e80c7d8..e5bc0b2 100644 --- a/lustre/mdc/mdc_request.c +++ b/lustre/mdc/mdc_request.c @@ -629,36 +629,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 obdo *oa, struct obd_client_handle *och, struct ptlrpc_request **request) { @@ -671,7 +641,6 @@ int mdc_close(struct obd_export *exp, struct obdo *oa, obd->u.cli.cl_max_mds_cookiesize }; int rc; struct ptlrpc_request *req; - struct mdc_open_data *mod; ENTRY; req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_MDS_VERSION, @@ -688,17 +657,24 @@ int mdc_close(struct obd_export *exp, 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_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"); } @@ -706,9 +682,6 @@ int mdc_close(struct obd_export *exp, struct obdo *oa, mdc_close_pack(req, REQ_REC_OFF, oa, oa->o_valid, och); ptlrpc_req_set_repsize(req, 4, 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); @@ -726,7 +699,7 @@ int mdc_close(struct obd_export *exp, 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 15428fc..3a4e2bd 100755 --- a/lustre/tests/replay-single.sh +++ b/lustre/tests/replay-single.sh @@ -971,6 +971,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