From 07f782635c7b5de59a13371c6d14aa2c4910d257 Mon Sep 17 00:00:00 2001 From: Jinshan Xiong Date: Tue, 1 May 2018 11:35:53 -0700 Subject: [PATCH] LU-4398 llite: do not cache write open lock for exec file This is to avoid the problem that the MDT needs an extra lock revocation to make the file be able to execute. Lustre-change: https://review.whamcloud.com/32265 Lustre-commit: 6dd9d57bc006a37731d34409ce43de13c192e0cc Signed-off-by: Jinshan Xiong Signed-off-by: Gu Zheng Change-Id: Ibb42a9a8cb56a9bf48a6e972b72d3d71ed7fbaf5 Reviewed-by: Lai Siyao Signed-off-by: Minh Diep Reviewed-on: https://review.whamcloud.com/36680 Reviewed-by: Andreas Dilger Tested-by: jenkins Tested-by: Maloo Reviewed-by: Oleg Drokin --- lustre/llite/file.c | 4 +++- lustre/tests/sanity.sh | 24 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/lustre/llite/file.c b/lustre/llite/file.c index 9d43de0..7e760b0 100644 --- a/lustre/llite/file.c +++ b/lustre/llite/file.c @@ -330,7 +330,9 @@ static int ll_md_close(struct inode *inode, struct file *file) } mutex_unlock(&lli->lli_och_mutex); - if (!md_lock_match(ll_i2mdexp(inode), flags, ll_inode2fid(inode), + /* LU-4398: do not cache write open lock if the file has exec bit */ + if ((lockmode == LCK_CW && inode->i_mode & S_IXUGO) || + !md_lock_match(ll_i2mdexp(inode), flags, ll_inode2fid(inode), LDLM_IBITS, &policy, lockmode, &lockh)) rc = ll_md_real_close(inode, fd->fd_omode); diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 1117336..2f15240 100644 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -20987,6 +20987,30 @@ test_816() { } run_test 816 "do not reset lru_resize on idle reconnect" +cleanup_817() { + umount $tmpdir + exportfs -u localhost:$DIR/nfsexp + rm -rf $DIR/nfsexp +} + +test_817() { + systemctl restart nfs-server.service || skip "failed to restart nfsd" + + mkdir -p $DIR/nfsexp + exportfs -orw,no_root_squash localhost:$DIR/nfsexp || + error "failed to export nfs" + + tmpdir=$(mktemp -d /tmp/nfs-XXXXXX) + stack_trap cleanup_817 EXIT + + mount -t nfs -orw localhost:$DIR/nfsexp $tmpdir || + error "failed to mount nfs to $tmpdir" + + cp /bin/true $tmpdir + $DIR/nfsexp/true || error "failed to execute 'true' command" +} +run_test 817 "nfsd won't cache write lock for exec file" + test_819a() { dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 cancel_lru_locks osc -- 1.8.3.1