From bd37398ae1b8dbbdd5bf8b700d061b5fc33fd8ed Mon Sep 17 00:00:00 2001 From: wang di Date: Tue, 26 Nov 2013 06:24:54 -0800 Subject: [PATCH] LU-4316 mdt: Do not grant Layout lock for remote file Do not grant layout lock for remote file, because only the MDT, where the file/dir resides, should grant the LAYOUT lock. Signed-off-by: wang di Change-Id: I174d54f3ce5b7c69cb35aa63f4322b743ea677e8 Reviewed-on: http://review.whamcloud.com/8406 Tested-by: Jenkins Reviewed-by: Andreas Dilger Tested-by: Maloo Reviewed-by: Faccini Bruno --- lustre/mdt/mdt_handler.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index 1d384e8..b0a7529 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -1309,19 +1309,20 @@ static int mdt_getattr_name_lock(struct mdt_thread_info *info, LDLM_LOCK_PUT(lock); rc = 0; } else { - mdt_lock_handle_init(lhc); - mdt_lock_reg_init(lhc, LCK_PR); + mdt_lock_handle_init(lhc); + mdt_lock_reg_init(lhc, LCK_PR); - /* - * Object's name is on another MDS, no lookup lock is - * needed here but update is. - */ - child_bits &= ~MDS_INODELOCK_LOOKUP; + /* + * Object's name is on another MDS, no lookup or layout + * lock is needed here but update lock is. + */ + child_bits &= ~(MDS_INODELOCK_LOOKUP | + MDS_INODELOCK_LAYOUT); child_bits |= MDS_INODELOCK_PERM | MDS_INODELOCK_UPDATE; rc = mdt_object_lock(info, child, lhc, child_bits, - MDT_LOCAL_LOCK); - } + MDT_LOCAL_LOCK); + } if (rc == 0) { /* Finally, we can get attr for child. */ mdt_set_capainfo(info, 0, mdt_object_fid(child), @@ -1448,7 +1449,7 @@ relock: if (!OBD_FAIL_CHECK(OBD_FAIL_MDS_NO_LL_GETATTR) && exp_connect_layout(info->mti_exp) && S_ISREG(lu_object_attr(&child->mot_obj)) && - ldlm_rep != NULL) { + !mdt_object_remote(child) && ldlm_rep != NULL) { /* try to grant layout lock for regular file. */ try_layout = true; } @@ -2280,11 +2281,13 @@ static int mdt_object_lock0(struct mdt_thread_info *info, struct mdt_object *o, if (mdt_object_remote(o)) { if (locality == MDT_CROSS_LOCK) { - ibits &= ~(MDS_INODELOCK_UPDATE | MDS_INODELOCK_PERM); + ibits &= ~(MDS_INODELOCK_UPDATE | MDS_INODELOCK_PERM | + MDS_INODELOCK_LAYOUT); ibits |= MDS_INODELOCK_LOOKUP; } else { LASSERTF(!(ibits & - (MDS_INODELOCK_UPDATE | MDS_INODELOCK_PERM)), + (MDS_INODELOCK_UPDATE | MDS_INODELOCK_PERM | + MDS_INODELOCK_LAYOUT)), "%s: wrong bit "LPX64" for remote obj "DFID"\n", mdt_obd_name(info->mti_mdt), ibits, PFID(mdt_object_fid(o))); -- 1.8.3.1