From 4d713ab34b05dcb15aedc782a9c1ba14907feb48 Mon Sep 17 00:00:00 2001 From: Alexander Boyko Date: Mon, 1 Jun 2020 08:38:07 -0400 Subject: [PATCH] LU-13617 tests: check client deadlock selinux The patch adds test_20e to sanity-selinux. It checks client deadlock and MDS eviction for it. Lustre-change: https://review.whamcloud.com/38793 Lustre-commit: f519f22c8ba3a6de00af0bef77cae3b4b18acdab Test-Parameters: testlist=sanity-selinux env=ONLY=20e,ONLY_REPEAT=20 Signed-off-by: Alexander Boyko Cray-bug-id: LUS-8924 Change-Id: If7707fa14f7307fb3a3fb2228fbd1983b55cbe6b Reviewed-by: Sebastien Buisson Reviewed-by: Andrew Perepechko Signed-off-by: Etienne AUAMES Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/47034 Reviewed-by: Andreas Dilger Tested-by: jenkins Tested-by: Maloo --- lustre/include/obd_support.h | 1 + lustre/llite/namei.c | 2 ++ lustre/tests/sanity-selinux.sh | 30 ++++++++++++++++++++++++++++++ 3 files changed, 33 insertions(+) diff --git a/lustre/include/obd_support.h b/lustre/include/obd_support.h index 268f62a..6759a40 100644 --- a/lustre/include/obd_support.h +++ b/lustre/include/obd_support.h @@ -584,6 +584,7 @@ extern char obd_jobid_var[]; #define OBD_FAIL_LLITE_IMUTEX_NOSEC 0x140f #define OBD_FAIL_LLITE_OPEN_BY_NAME 0x1410 #define OBD_FAIL_LLITE_SHORT_COMMIT 0x1415 +#define OBD_FAIL_LLITE_CREATE_FILE_PAUSE2 0x1416 #define OBD_FAIL_FID_INDIR 0x1501 #define OBD_FAIL_FID_INLMA 0x1502 diff --git a/lustre/llite/namei.c b/lustre/llite/namei.c index 752a4d4..dfe6332 100644 --- a/lustre/llite/namei.c +++ b/lustre/llite/namei.c @@ -993,6 +993,8 @@ static int ll_atomic_open(struct inode *dir, struct dentry *dentry, it->it_flags = (open_flags & ~O_ACCMODE) | OPEN_FMODE(open_flags); it->it_flags &= ~MDS_OPEN_FL_INTERNAL; + OBD_FAIL_TIMEOUT(OBD_FAIL_LLITE_CREATE_FILE_PAUSE2, cfs_fail_val); + /* Dentry added to dcache tree in ll_lookup_it */ de = ll_lookup_it(dir, dentry, it, &secctx, &secctxlen); if (IS_ERR(de)) diff --git a/lustre/tests/sanity-selinux.sh b/lustre/tests/sanity-selinux.sh index 37d18fd..561184d 100755 --- a/lustre/tests/sanity-selinux.sh +++ b/lustre/tests/sanity-selinux.sh @@ -468,6 +468,36 @@ test_20d() { } run_test 20d "[atomicity] avoid getxattr for security context" +test_20e() { + [ "$CLIENT_VERSION" -lt $(version_code 2.12.8) ] && + skip "Need client version >= 2.12.8" + local filename1=$DIR/$tdir/df20e + local delay=5 + local evict + local unconctx="-u unconfined_u -r unconfined_r -t unconfined_t -l s0" + + mkdir -p $DIR/$tdir + chmod 777 $DIR/$tdir + #define OBD_FAIL_LLITE_CREATE_FILE_PAUSE2 0x1416 + do_facet client "$LCTL set_param fail_val=$delay fail_loc=0x80001416" + + # create file on first mount point + $RUNAS_CMD -u $RUNAS_ID runcon $unconctx touch $filename1 & + local touchpid=$! + sleep 1 + cancel_lru_locks mdc + sysctl -w vm.drop_caches=2 + $RUNAS_CMD -u $RUNAS_ID runcon $unconctx stat $DIR/$tdir & + + wait $touchpid + + evict=$($LCTL get_param mdc.$FSNAME-MDT*.state | + awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }') + + [ -z "$evict" ] || [[ $evict -le $before ]] || error "eviction happened" +} +run_test 20e "client deadlock and eviction form MDS" + check_nodemap() { local nm=$1 local key=$2 -- 1.8.3.1