Whamcloud - gitweb
LU-12275 sec: verify dir is empty when setting enc policy
[fs/lustre-release.git] / lustre / tests / sanity-selinux.sh
index 7d9ef93..0897b79 100755 (executable)
 set -e
 
 ONLY=${ONLY:-"$*"}
-# bug number for skipped test:
-ALWAYS_EXCEPT=${ALWAYS_EXCEPT:-"$SANITY_SELINUX_EXCEPT"}
-# UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
-
-SRCDIR=$(dirname $0)
-SAVE_PWD=$PWD
 
 LUSTRE=${LUSTRE:-$(dirname $0)/..}
 . $LUSTRE/tests/test-framework.sh
 init_test_env $@
-. ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
 init_logging
 
-require_dsh_mds || exit 0
+ALWAYS_EXCEPT="$SANITY_SELINUX_EXCEPT"
 
 [ "$SLOW" = "no" ] && EXCEPT_SLOW="xxx"
 
+build_test_filter
+
+require_dsh_mds || exit 0
+
 RUNAS_CMD=${RUNAS_CMD:-runas}
 # $RUNAS_ID may get set incorrectly somewhere else
 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] &&
@@ -69,8 +66,6 @@ rm -rf $DIR/[df][0-9]*
 
 check_runas_id $RUNAS_ID $RUNAS_ID $RUNAS
 
-build_test_filter
-
 umask 077
 
 check_selinux_xattr() {
@@ -468,6 +463,36 @@ test_20d() {
 }
 run_test 20d "[atomicity] avoid getxattr for security context"
 
+test_20e() {
+       [ "$CLIENT_VERSION" -lt $(version_code 2.13.54) ] &&
+               skip "Need client version >= 2.13.54"
+       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