From 9ddec96478d83afccec1d09266e063b2a5a0f71a Mon Sep 17 00:00:00 2001 From: wangdi Date: Fri, 27 Dec 2013 20:10:57 -0800 Subject: [PATCH] LU-2927 mdt: Not return -EREMOTE for open lock. Instead of returning -EREMOTE for open_lock, it will check the open lock by the DISP_OPEN_LOCK, otherwise it will cause transno being wrongly set to 0. Signed-off-by: wang di Change-Id: I4f3bccea87872ca191b0b6c2142e8897be3d731a Reviewed-on: http://review.whamcloud.com/5694 Tested-by: Hudson Tested-by: Maloo Reviewed-by: Fan Yong Reviewed-by: Faccini Bruno Reviewed-by: Oleg Drokin --- lustre/mdt/mdt_handler.c | 18 ++++++++++-------- lustre/mdt/mdt_open.c | 34 ++++++++++++++++++++++------------ 2 files changed, 32 insertions(+), 20 deletions(-) diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index f7ed271..ba3f24d 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -3788,14 +3788,16 @@ static int mdt_intent_reint(enum mdt_it_code opcode, if (rc != 0) mdt_set_disposition(info, rep, DISP_LOOKUP_EXECD); - /* Cross-ref case, the lock should be returned to the client */ - if (rc == -EREMOTE) { - LASSERT(lustre_handle_is_used(&lhc->mlh_reg_lh)); - rep->lock_policy_res2 = 0; - rc = mdt_intent_lock_replace(info, lockp, NULL, lhc, flags); - RETURN(rc); - } - rep->lock_policy_res2 = clear_serious(rc); + /* the open lock or the lock for cross-ref object should be + * returned to the client */ + if (rc == -EREMOTE || mdt_get_disposition(rep, DISP_OPEN_LOCK)) { + LASSERT(lustre_handle_is_used(&lhc->mlh_reg_lh)); + rep->lock_policy_res2 = 0; + rc = mdt_intent_lock_replace(info, lockp, NULL, lhc, flags); + RETURN(rc); + } + + rep->lock_policy_res2 = clear_serious(rc); if (rep->lock_policy_res2 == -ENOENT && mdt_get_disposition(rep, DISP_LOOKUP_NEG)) diff --git a/lustre/mdt/mdt_open.c b/lustre/mdt/mdt_open.c index cd14179..e1717dd 100644 --- a/lustre/mdt/mdt_open.c +++ b/lustre/mdt/mdt_open.c @@ -838,9 +838,13 @@ int mdt_finish_open(struct mdt_thread_info *info, * that looks like it was actually almost succesful and a failure at the * same time */ if (OBD_FAIL_CHECK(OBD_FAIL_MDS_NEGATIVE_POSITIVE)) { - mdt_set_disposition(info, rep, DISP_OPEN_LOCK | \ - DISP_OPEN_OPEN | DISP_LOOKUP_NEG | \ - DISP_LOOKUP_POS); + mdt_set_disposition(info, rep, DISP_OPEN_OPEN | + DISP_LOOKUP_NEG | + DISP_LOOKUP_POS); + + if (flags & MDS_OPEN_LOCK) + mdt_set_disposition(info, rep, DISP_OPEN_LOCK); + RETURN(-ENOENT); } @@ -1252,8 +1256,14 @@ static void mdt_object_open_unlock(struct mdt_thread_info *info, * if open or layout lock is granted. */ rc = 1; } - if (rc != 0) + + if (rc != 0) { + struct ldlm_reply *ldlm_rep; + + ldlm_rep = req_capsule_server_get(info->mti_pill, &RMF_DLM_REP); + mdt_clear_disposition(info, ldlm_rep, DISP_OPEN_LOCK); mdt_object_unlock(info, obj, lhc, 1); + } } int mdt_open_by_fid_lock(struct mdt_thread_info *info, struct ldlm_reply *rep, @@ -1679,12 +1689,10 @@ int mdt_reint_open(struct mdt_thread_info *info, struct mdt_lock_handle *lhc) /* get openlock if this is not replay and if a client requested it */ if (!req_is_replay(req)) { rc = mdt_object_open_lock(info, child, lhc, &ibits); - if (rc != 0) { + if (rc != 0) GOTO(out_child, result = rc); - } else if (create_flags & MDS_OPEN_LOCK) { - result = -EREMOTE; + else if (create_flags & MDS_OPEN_LOCK) mdt_set_disposition(info, ldlm_rep, DISP_OPEN_LOCK); - } } /* Try to open it now. */ @@ -1704,7 +1712,9 @@ int mdt_reint_open(struct mdt_thread_info *info, struct mdt_lock_handle *lhc) lname, &info->mti_attr, 0); if (rc != 0) - CERROR("Error in cleanup of open\n"); + CERROR("%s: "DFID" cleanup of open: rc = %d\n", + mdt_obd_name(info->mti_mdt), + PFID(mdt_object_fid(child)), rc); mdt_clear_disposition(info, ldlm_rep, DISP_OPEN_CREATE); } } @@ -1715,9 +1725,9 @@ out_child: out_parent: mdt_object_unlock_put(info, parent, lh, result || !created); out: - if (result && result != -EREMOTE) - lustre_msg_set_transno(req->rq_repmsg, 0); - return result; + if (result) + lustre_msg_set_transno(req->rq_repmsg, 0); + return result; } #define MFD_CLOSED(mode) (((mode) & ~(MDS_FMODE_EPOCH | MDS_FMODE_SOM | \ -- 1.8.3.1