From: tappro Date: Fri, 18 Aug 2006 15:04:24 +0000 (+0000) Subject: - use obd_last_committed instead of mdt value for now X-Git-Tag: v1_8_0_110~486^2~1139 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=93744736cfb30e6a643edc92ad2f22b208aacd4f;p=fs%2Flustre-release.git - use obd_last_committed instead of mdt value for now - check result in stop callback and set transno = 0 - spin_unlock() after update the txi_transno on stop callback - fix misspelled variable name - rename mdt_update_last_transno() to the mdt_finish_reply() due to it's functionality --- diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index 19954bc..d1ebaa7 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -619,7 +619,6 @@ free_rdpg: return rc; } -//extern int mdt_reconstruct(struct mdt_thread_info *); static int mdt_reint_internal(struct mdt_thread_info *info, __u32 op) { int rc; @@ -1085,38 +1084,32 @@ static int mdt_unpack_req_pack_rep(struct mdt_thread_info *info, __u32 flags) /* FIXME: fake untill journal callback is OK.*/ struct lu_context_key mdt_txn_key; -int mdt_update_last_transno(struct mdt_thread_info *info, int rc) +static inline void mdt_finish_reply(struct mdt_thread_info *info, int rc) { struct mdt_device *mdt = info->mti_mdt; struct ptlrpc_request *req = mdt_info_req(info); struct obd_export *exp = req->rq_export; - __u64 last_transno; - __u64 last_committed; if (mdt == NULL || req == NULL || req->rq_repmsg == NULL) - return -EFAULT; - if (info->mti_trans_flags & MDT_NONEED_TANSNO) - return 0; - - last_committed = mdt->mdt_last_committed; + LBUG(); - if (rc == 0) { - last_transno = info->mti_transno; - } else { - if (info->mti_transno != 0) - CERROR("replay %s transno "LPU64" failed: rc %d\n", - libcfs_nid2str(exp->exp_connection->c_peer.nid), - info->mti_transno, rc); - last_transno = 0; + if (info->mti_trans_flags & MDT_NONEED_TRANSNO) + return; + + /*XXX: assert on this when all code will be finished */ + if (rc != 0 && info->mti_transno != 0) { + info->mti_transno = 0; + CERROR("Transno is not 0 while rc is %i!\n", rc); } + CDEBUG(D_INODE, "last_transno = %llu, last_committed = %llu\n", - last_transno, last_committed); + mdt->mdt_last_transno, exp->exp_obd->obd_last_committed); - req->rq_repmsg->transno = req->rq_transno = last_transno; + spin_lock(mdt->mdt_transno_lock); + req->rq_repmsg->transno = req->rq_transno = info->mti_transno; + req->rq_repmsg->last_committed = exp->exp_obd->obd_last_committed; + spin_unlock(mdt->mdt_transno_lock); req->rq_repmsg->last_xid = req->rq_xid; - req->rq_repmsg->last_committed = last_committed; - exp->exp_obd->obd_last_committed = last_committed; - return 0; } /* @@ -1200,7 +1193,7 @@ static int mdt_req_handle(struct mdt_thread_info *info, if (h->mh_opc != MDS_DISCONNECT && h->mh_opc != MDS_READPAGE && h->mh_opc != LDLM_ENQUEUE) { - mdt_update_last_transno(info, result); + mdt_finish_reply(info, result); } RETURN(result); } @@ -1645,8 +1638,8 @@ static int mdt_intent_reint(enum mdt_it_code opcode, rep->lock_policy_res2 = rc; intent_set_disposition(rep, DISP_IT_EXECD); - - mdt_update_last_transno(info, rep->lock_policy_res2); + + mdt_finish_reply(info, rc); RETURN(ELDLM_LOCK_ABORTED); } @@ -2289,11 +2282,14 @@ static int mdt_init0(const struct lu_context *ctx, struct mdt_device *m, LASSERT(info != NULL); obd = class_name2obd(dev); - + LASSERT(obd); + spin_lock_init(&m->mdt_transno_lock); +#if 0 /* FIXME: We need to load them from disk. But now fake it */ m->mdt_last_transno = 1; m->mdt_last_committed = 1; +#endif m->mdt_max_mdsize = MAX_MD_SIZE; m->mdt_max_cookiesize = sizeof(struct llog_cookie); @@ -2582,7 +2578,7 @@ static int mdt_obd_disconnect(struct obd_export *exp) //ldlm_cancel_locks_for_export(exp); /* complete all outstanding replies */ - spin_lock_irqsave(&exp->exp_lock, irqflags); + spin_lock(&exp->exp_lock); while (!list_empty(&exp->exp_outstanding_replies)) { struct ptlrpc_reply_state *rs = list_entry(exp->exp_outstanding_replies.next, @@ -2594,7 +2590,7 @@ static int mdt_obd_disconnect(struct obd_export *exp) ptlrpc_schedule_difficult_reply(rs); spin_unlock(&svc->srv_lock); } - spin_unlock_irqrestore(&exp->exp_lock, irqflags); + spin_unlock(&exp->exp_lock); class_export_put(exp); RETURN(rc); diff --git a/lustre/mdt/mdt_internal.h b/lustre/mdt/mdt_internal.h index 7adbc19..90cb37f 100644 --- a/lustre/mdt/mdt_internal.h +++ b/lustre/mdt/mdt_internal.h @@ -127,7 +127,6 @@ struct mdt_device { /* Transaction related stuff here */ spinlock_t mdt_transno_lock; __u64 mdt_last_transno; - __u64 mdt_last_committed; /* transaction callbacks */ struct dt_txn_callback mdt_txn_cb; @@ -191,7 +190,7 @@ enum mdt_reint_flag { }; enum { - MDT_NONEED_TANSNO = (1 << 0) /*Do not need transno for this req*/ + MDT_NONEED_TRANSNO = (1 << 0) /*Do not need transno for this req*/ }; /* * Common data shared by mdt-level handlers. This is allocated per-thread to diff --git a/lustre/mdt/mdt_open.c b/lustre/mdt/mdt_open.c index 7d5fc2f..04fd8a4 100644 --- a/lustre/mdt/mdt_open.c +++ b/lustre/mdt/mdt_open.c @@ -210,7 +210,7 @@ static int mdt_mfd_open(struct mdt_thread_info *info, */ if (islnk || (!isreg && !isdir && (req->rq_export->exp_connect_flags & OBD_CONNECT_NODEVOH))) { - info->mti_trans_flags |= MDT_NONEED_TANSNO; + info->mti_trans_flags |= MDT_NONEED_TRANSNO; RETURN(0); } /* This can't be done earlier, we need to return reply body */ diff --git a/lustre/mdt/mdt_recovery.c b/lustre/mdt/mdt_recovery.c index 4313339..54a38b9 100644 --- a/lustre/mdt/mdt_recovery.c +++ b/lustre/mdt/mdt_recovery.c @@ -305,6 +305,8 @@ static int mdt_init_server_data(const struct lu_context *ctx, GOTO(err_client, rc); spin_lock(&mdt->mdt_transno_lock); + /* obd_last_committed is used for compatibility + * with other lustre recovery code */ obd->obd_last_committed = mdt->mdt_last_transno; spin_unlock(&mdt->mdt_transno_lock); @@ -559,16 +561,22 @@ static int mdt_txn_stop_cb(const struct lu_context *ctx, /*TODO: checks for recovery cases, see mds_finish_transno */ spin_lock(&mdt->mdt_transno_lock); - if (mti->mti_transno == 0) { + if (txn->th_result != 0) { + if (mti->mti_transno != 0) { + CERROR("Replay transno "LPU64" failed: rc %i\n", + mti->mti_transno, txn->th_result); + mti->mti_transno = 0; + } + } else if (mti->mti_transno == 0) { mti->mti_transno = ++ mdt->mdt_last_transno; } else { /* replay */ if (mti->mti_transno > mdt->mdt_last_transno) mdt->mdt_last_transno = mti->mti_transno; } - spin_unlock(&mdt->mdt_transno_lock); /* save transno for the commit callback */ txi->txi_transno = mti->mti_transno; + spin_unlock(&mdt->mdt_transno_lock); return 0;//mdt_update_last_rcvd(mti, dev, txn); } @@ -583,9 +591,11 @@ static int mdt_txn_commit_cb(const struct lu_context *ctx, struct mdt_txn_info *txi; txi = lu_context_key_get(&txn->th_ctx, &mdt_txn_key); + + /* copy of obd_transno_commit_cb() but with locking */ spin_lock(&mdt->mdt_transno_lock); - if (txi->txi_transno > mdt->mdt_last_committed) { - mdt->mdt_last_committed = txi->txi_transno; + if (txi->txi_transno > obd->obd_last_committed) { + obd->obd_last_committed = txi->txi_transno; spin_unlock(&mdt->mdt_transno_lock); ptlrpc_commit_replies (obd); } else