From de9df2fd1623f37a2258c037706892a00159921d Mon Sep 17 00:00:00 2001 From: Mikhail Pershin Date: Wed, 23 Oct 2013 22:17:51 +0400 Subject: [PATCH] LU-4135 mdt: restore mdt_save_lock() functionality Missed updates for mti_has_trans cause mdt_save_lock() to do just decref for lock and never try to save it as intended. Patch restores updating mti_has_trans variable and fix issue with NULL req in case of mdt_export_cleanup() codepath Signed-off-by: Mikhail Pershin Change-Id: I2e4ccae018635842df1e02d72a639b0ca1fbdb04 Reviewed-on: http://review.whamcloud.com/8048 Tested-by: Hudson Reviewed-by: Andreas Dilger Tested-by: Maloo Reviewed-by: Alex Zhuravlev Reviewed-by: Oleg Drokin --- lustre/mdt/mdt_handler.c | 24 +++++++++++++++--------- lustre/mdt/mdt_recovery.c | 7 +++++++ 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index 8d4b2b5..0861208 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -2397,15 +2397,21 @@ void mdt_save_lock(struct mdt_thread_info *info, struct lustre_handle *h, LASSERTF(lock != NULL, "no lock for cookie "LPX64"\n", h->cookie); - CDEBUG(D_HA, "request = %p reply state = %p" - " transno = "LPD64"\n", - req, req->rq_reply_state, req->rq_transno); - if (mdt_cos_is_enabled(mdt)) { - no_ack = 1; - ldlm_lock_downgrade(lock, LCK_COS); - mode = LCK_COS; - } - ptlrpc_save_lock(req, h, mode, no_ack); + /* there is no request if mdt_object_unlock() is called + * from mdt_export_cleanup()->mdt_add_dirty_flag() */ + if (likely(req != NULL)) { + CDEBUG(D_HA, "request = %p reply state = %p" + " transno = "LPD64"\n", req, + req->rq_reply_state, req->rq_transno); + if (mdt_cos_is_enabled(mdt)) { + no_ack = 1; + ldlm_lock_downgrade(lock, LCK_COS); + mode = LCK_COS; + } + ptlrpc_save_lock(req, h, mode, no_ack); + } else { + ldlm_lock_decref(h, mode); + } if (mdt_is_lock_sync(lock)) { CDEBUG(D_HA, "found sync-lock," " async commit started\n"); diff --git a/lustre/mdt/mdt_recovery.c b/lustre/mdt/mdt_recovery.c index c89e418..1358c63 100644 --- a/lustre/mdt/mdt_recovery.c +++ b/lustre/mdt/mdt_recovery.c @@ -410,6 +410,13 @@ static int mdt_txn_stop_cb(const struct lu_env *env, rc = tgt_last_rcvd_update(env, tgt, obj, mti->mti_opdata, txn, mdt_info_req(mti)); + + /* This callback should notify MDT that transaction was + * done for mdt_save_lock() */ + if (mti->mti_has_trans) + CDEBUG(D_INFO, "More than one transaction\n"); + else + mti->mti_has_trans = 1; return rc; } -- 1.8.3.1