Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- commit 8b17c5ac48677b03a2ce5706455a3d3e6f8d993d
- Author: Andrew Perepechko <andrew.perepechko@seagate.com>
- Date: Tue May 17 16:54:36 2016 +0300
- MRP-3322 mdt: acquire an open lock for write or execute
- In mdt_object_open_lock() opens for write or execute will always
- acquire an open lock of the appropriate mode so that any conflicting
- cached open locks on other clients will be canceled.
- Also, do not drop LOOKUP from the original ibits mask if
- the nonblocking lock request fails.
- Change-Id: I14775c5519b57d4ba8f3d74e2cc0060c503a19fe
- Signed-off-by: Andrew Perepechko <andrew.perepechko@seagate.com>
- diff --git a/lustre/mdt/mdt_open.c b/lustre/mdt/mdt_open.c
- index 1ae07248a7..d36e70c5e9 100644
- --- a/lustre/mdt/mdt_open.c
- +++ b/lustre/mdt/mdt_open.c
- @@ -1182,6 +1182,16 @@ static int mdt_open_by_fid(struct mdt_thread_info *info, struct ldlm_reply *rep)
- RETURN(rc);
- }
- +static ldlm_mode_t open_flags_to_lock_mode(__u64 open_flags)
- +{
- + if (open_flags & FMODE_WRITE)
- + return LCK_CW;
- + else if (open_flags & MDS_FMODE_EXEC)
- + return LCK_PR;
- +
- + return LCK_CR;
- +}
- +
- /* lock object for open */
- static int mdt_object_open_lock(struct mdt_thread_info *info,
- struct mdt_object *obj,
- @@ -1242,26 +1252,33 @@ static int mdt_object_open_lock(struct mdt_thread_info *info,
- down_read(&obj->mot_open_sem);
- if (open_flags & MDS_OPEN_LOCK) {
- - if (open_flags & FMODE_WRITE)
- - lm = LCK_CW;
- - else if (open_flags & MDS_FMODE_EXEC)
- - lm = LCK_PR;
- - else
- - lm = LCK_CR;
- -
- + lm = open_flags_to_lock_mode(open_flags);
- *ibits = MDS_INODELOCK_LOOKUP | MDS_INODELOCK_OPEN;
- } else if (atomic_read(&obj->mot_lease_count) > 0) {
- - if (open_flags & FMODE_WRITE)
- - lm = LCK_CW;
- - else
- - lm = LCK_CR;
- -
- /* revoke lease */
- + lm = open_flags_to_lock_mode(open_flags);
- *ibits = MDS_INODELOCK_OPEN;
- try_layout = false;
- lhc = &info->mti_lh[MDT_LH_LOCAL];
- + } else if (S_ISREG(lu_object_attr(&obj->mot_obj)) &&
- + open_flags & (FMODE_WRITE | MDS_FMODE_EXEC)) {
- + /*
- + * We need to flush open handles for proper ETXTBUSY
- + * reporting, but the client is not interested in an
- + * open lock, so lock and unlock immediately.
- + */
- + CDEBUG(D_INODE, "open lock and unlock "DFID"\n",
- + PFID(mdt_object_fid(obj)));
- + mdt_lock_reg_init(lhc,
- + open_flags_to_lock_mode(open_flags));
- + rc = mdt_object_lock(info, obj, lhc, MDS_INODELOCK_OPEN,
- + MDT_CROSS_LOCK);
- + if (rc < 0)
- + GOTO(out, rc);
- + mdt_object_unlock(info, obj, lhc, 1);
- }
- +
- CDEBUG(D_INODE, "normal open:"DFID" lease count: %d, lm: %d\n",
- PFID(mdt_object_fid(obj)),
- atomic_read(&obj->mot_open_count), lm);
- @@ -1277,13 +1294,15 @@ static int mdt_object_open_lock(struct mdt_thread_info *info,
- * lock for each open.
- * However this is a double-edged sword because changing
- * permission will revoke huge # of LOOKUP locks. */
- - *ibits |= MDS_INODELOCK_LAYOUT | MDS_INODELOCK_LOOKUP;
- - if (!mdt_object_lock_try(info, obj, lhc, *ibits,
- + if (!mdt_object_lock_try(info, obj, lhc,
- + *ibits | MDS_INODELOCK_LAYOUT |
- + MDS_INODELOCK_LOOKUP,
- MDT_CROSS_LOCK)) {
- - *ibits &= ~(MDS_INODELOCK_LAYOUT|MDS_INODELOCK_LOOKUP);
- if (*ibits != 0)
- rc = mdt_object_lock(info, obj, lhc, *ibits,
- MDT_CROSS_LOCK);
- + } else {
- + *ibits |= MDS_INODELOCK_LAYOUT | MDS_INODELOCK_LOOKUP;
- }
- } else if (*ibits != 0) {
- rc = mdt_object_lock(info, obj, lhc, *ibits, MDT_CROSS_LOCK);
- commit 1d02d0af9638789ff4907cb3a6c9c1f5bd295c84
- Author: Andrew Perepechko <andrew.perepechko@seagate.com>
- Date: Fri Feb 19 19:49:26 2016 +0300
- MRP-3322 tests: conflicting locks are not flushed properly
- This patch adds a new test, sanityn.sh 14e. The test attempts
- to cache an open lock (via NFS) on the client by writing to a
- new file, then executes that file. If the MDS does not flush
- conflicting locks, the execution will fail with -ETXTBSY.
- This tests replaces the original reproducer from LU-4398
- which hasn't been working ever since LU-4367 landing.
- Change-Id: Ie1b3418fb2178d5f369a6734539cc51148200543
- Signed-off-by: Andrew Perepechko <andrew.perepechko@seagate.com>
- diff --git a/lustre/tests/sanityn.sh b/lustre/tests/sanityn.sh
- index f677f26e14..f20b20d581 100644
- --- a/lustre/tests/sanityn.sh
- +++ b/lustre/tests/sanityn.sh
- @@ -39,6 +39,8 @@ init_test_env $@
- . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
- init_logging
- +. $LUSTRE/tests/setup-nfs.sh
- +
- if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then
- # bug number for skipped test: LU-2189 LU-2776
- ALWAYS_EXCEPT="$ALWAYS_EXCEPT 36 51a"
- @@ -357,6 +359,31 @@ test_14d() { # bug 10921
- }
- run_test 14d "chmod of executing file is still possible ========"
- +test_14e() { # LU-4398/MRP-3322
- + local rc=0
- +
- + test_mkdir -p $DIR1/$tdir
- + rm -f $DIR1/$tdir/$tfile
- +
- + setup_nfs 4 $DIR1 $HOSTNAME $HOSTNAME $DIR2 ||
- + error "nfs setup failed!"
- +
- + touch $DIR2/$tdir/$tfile
- + chmod +x $DIR2/$tdir/$tfile
- + printf '#!/bin/bash' > $DIR2/$tdir/$tfile
- +
- + $DIR1/$tdir/$tfile || rc=1
- +
- + # always cleanup
- + cleanup_nfs $DIR2 $HOSTNAME $HOSTNAME ||
- + error_noexit false "failed to cleanup nfs"
- +
- + [ $rc -ne 0 ] && echo "failed to execute"
- +
- + return $rc
- +}
- +run_test 14e "conflicting locks should be flushed on open ======"
- +
- test_15() { # bug 974 - ENOSPC
- echo "PATH=$PATH"
- sh oos2.sh $MOUNT1 $MOUNT2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement