From 392fb6e4b8c471b387b6dfb6a802a88949cd9d89 Mon Sep 17 00:00:00 2001 From: Liang Zhen Date: Wed, 24 Dec 2014 13:52:43 +0800 Subject: [PATCH] LU-5934 mdt: faulty assertion in mdt_intent_reint mdt_intent_reint() may set lhc::mlh_reg_lh for resent request, which means lhc::mlh_reg_lh can be a valid lock handle when processing of resent request failed and assert(rc == 0) is faulty. Signed-off-by: Liang Zhen Change-Id: I65628d6585cfcec94b820ab631bd391fe77186f2 Reviewed-on: http://review.whamcloud.com/13179 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Li Wei Reviewed-by: Mike Pershin Reviewed-by: Oleg Drokin --- lustre/mdt/mdt_handler.c | 32 +++++++++----------------------- 1 file changed, 9 insertions(+), 23 deletions(-) diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index 8b47a57..d8c56b2 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -2367,7 +2367,7 @@ int mdt_check_resent_lock(struct mdt_thread_info *info, struct mdt_lock_handle *lhc) { /* the lock might already be gotten in ldlm_handle_enqueue() */ - if (lustre_handle_is_used(&lhc->mlh_reg_lh)) { + if (unlikely(lustre_handle_is_used(&lhc->mlh_reg_lh))) { struct ptlrpc_request *req = mdt_info_req(info); struct ldlm_lock *lock; @@ -3400,8 +3400,8 @@ static int mdt_intent_reint(enum mdt_it_code opcode, /* the open lock or the lock for cross-ref object should be * returned to the client */ - if (rc == -MDT_EREMOTE_OPEN || mdt_get_disposition(rep, DISP_OPEN_LOCK)) { - LASSERT(lustre_handle_is_used(&lhc->mlh_reg_lh)); + if (lustre_handle_is_used(&lhc->mlh_reg_lh) && + (rc == 0 || rc == -MDT_EREMOTE_OPEN)) { rep->lock_policy_res2 = 0; rc = mdt_intent_lock_replace(info, lockp, lhc, flags); RETURN(rc); @@ -3413,6 +3413,7 @@ static int mdt_intent_reint(enum mdt_it_code opcode, mdt_get_disposition(rep, DISP_LOOKUP_NEG)) rep->lock_policy_res2 = 0; + lhc->mlh_reg_lh.cookie = 0ull; if (rc == -ENOTCONN || rc == -ENODEV || rc == -EOVERFLOW) { /**< if VBR failure then return error */ /* @@ -3421,28 +3422,13 @@ static int mdt_intent_reint(enum mdt_it_code opcode, * will detect this, then disconnect, reconnect the import * immediately, instead of impacting the following the rpc. */ - lhc->mlh_reg_lh.cookie = 0ull; RETURN(rc); - } else { - /* - * For other cases, the error will be returned by intent. - * and client will retrieve the result from intent. - */ - /* - * FIXME: when open lock is finished, that should be - * checked here. - */ - if (lustre_handle_is_used(&lhc->mlh_reg_lh)) { - LASSERTF(rc == 0, "Error occurred but lock handle " - "is still in use, rc = %d\n", rc); - rep->lock_policy_res2 = 0; - rc = mdt_intent_lock_replace(info, lockp, lhc, flags); - RETURN(rc); - } else { - lhc->mlh_reg_lh.cookie = 0ull; - RETURN(ELDLM_LOCK_ABORTED); - } } + /* + * For other cases, the error will be returned by intent, and client + * will retrieve the result from intent. + */ + RETURN(ELDLM_LOCK_ABORTED); } static int mdt_intent_code(long itcode) -- 1.8.3.1