From: tappro Date: Wed, 19 Jul 2006 23:13:22 +0000 (+0000) Subject: put transno into mdt_thread_key(), use that key in code X-Git-Tag: v1_8_0_110~486^2~1383 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=fcefe85e49f98d2323d4c4b742903824cce9e077;p=fs%2Flustre-release.git put transno into mdt_thread_key(), use that key in code --- diff --git a/lustre/mdt/mdt_fs.c b/lustre/mdt/mdt_fs.c index 8332af9..c4c0d6f 100644 --- a/lustre/mdt/mdt_fs.c +++ b/lustre/mdt/mdt_fs.c @@ -396,6 +396,7 @@ out: * last_rcvd update callbacks */ extern struct lu_context_key mdt_txn_key; +extern struct lu_context_key mdt_thread_key; #define MDT_TXN_LAST_RCVD_CREDITS 1 /* add credits for last_rcvd update */ @@ -413,23 +414,24 @@ static int mdt_txn_stop_cb(const struct lu_context *ctx, struct thandle *txn, void *cookie) { struct mdt_device *mdt = cookie; - struct mdt_txn_info *txni, *thdi; + struct mdt_txn_info *txni; + struct mdt_thread_info *mti; /* transno in two contexts - for commit_cb and for thread */ txni = lu_context_key_get(&txn->th_ctx, &mdt_txn_key); - thdi = lu_context_key_get(ctx, &mdt_txn_key); + mti = lu_context_key_get(ctx, &mdt_thread_key); /*TODO: checks for recovery cases, see mds_finish_transno */ spin_lock(&mdt->mdt_transno_lock); - if (thdi->txi_transno == 0) { - thdi->txi_transno = ++ mdt->mdt_last_transno; + if (mti->mti_transno == 0) { + mti->mti_transno = ++ mdt->mdt_last_transno; } else { /* replay */ - if (thdi->txi_transno > mdt->mdt_last_transno) - mdt->mdt_last_transno = thdi->txi_transno; + if (mti->mti_transno > mdt->mdt_last_transno) + mdt->mdt_last_transno = mti->mti_transno; } spin_unlock(&mdt->mdt_transno_lock); - - txni->txi_transno = thdi->txi_transno; + /* save transno for the commit callback */ + txni->txi_transno = mti->mti_transno; /* TODO: write last_rcvd */ diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index 064fe3a..1880287 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -121,7 +121,7 @@ static int mdt_handle (struct ptlrpc_request *req); static struct mdt_device *mdt_dev (struct lu_device *d); static int mdt_unpack_req_pack_rep(struct mdt_thread_info *info, __u32 flags); -static struct lu_context_key mdt_thread_key; +struct lu_context_key mdt_thread_key; static struct lu_object_operations mdt_obj_ops; @@ -971,7 +971,6 @@ int mdt_update_last_transno(struct mdt_thread_info *info, int rc) { struct mdt_device *mdt = info->mti_mdt; struct ptlrpc_request * req = mdt_info_req(info); - struct mdt_txn_info *txi; __u64 last_transno; __u64 last_committed; @@ -1001,9 +1000,8 @@ int mdt_update_last_transno(struct mdt_thread_info *info, int rc) /*last_committed = (mdt->mdt_last_committed);*/ last_committed = last_transno; #endif - txi = lu_context_key_get(info->mti_ctxt, &mdt_txn_key); - last_transno = txi->txi_transno; - CDEBUG(D_INFO, "last_transno = %llu, last_committed = %llu\n", + last_transno = info->mti_transno; + CDEBUG(D_INFO, "last_transno = %llu, last_committed = %llu\n", last_transno, last_committed); req->rq_repmsg->transno = req->rq_transno = last_transno; req->rq_repmsg->last_xid = req->rq_xid; @@ -2554,7 +2552,7 @@ static void mdt_thread_fini(const struct lu_context *ctx, OBD_FREE_PTR(info); } -static struct lu_context_key mdt_thread_key = { +struct lu_context_key mdt_thread_key = { .lct_tags = LCT_MD_THREAD, .lct_init = mdt_thread_init, .lct_fini = mdt_thread_fini @@ -2583,7 +2581,7 @@ static void mdt_txn_fini(const struct lu_context *ctx, } struct lu_context_key mdt_txn_key = { - .lct_tags = LCT_TX_HANDLE|LCT_MD_THREAD, + .lct_tags = LCT_TX_HANDLE, .lct_init = mdt_txn_init, .lct_fini = mdt_txn_fini }; diff --git a/lustre/mdt/mdt_internal.h b/lustre/mdt/mdt_internal.h index 3f026f9..2b8f7b3 100644 --- a/lustre/mdt/mdt_internal.h +++ b/lustre/mdt/mdt_internal.h @@ -246,6 +246,8 @@ struct mdt_thread_info { struct obd_uuid uuid; char ns_name[48]; } mti_u; + /* transaction number of current request */ + __u64 mti_transno; }; /* * Info allocated per-transaction.