X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Ftests%2FsanityN.sh;h=6d453920614e04c61241171ce9bf1b034be914cc;hb=ea1f4f5d0e4496c33a307cc42ee01cdcdf2661fc;hp=576712b9e478104d1a3de21846b17be92d1e97cf;hpb=87d92f4af2b977a811037033c8c7e9f89a5fc32a;p=fs%2Flustre-release.git diff --git a/lustre/tests/sanityN.sh b/lustre/tests/sanityN.sh index 576712b..6d45392 100644 --- a/lustre/tests/sanityN.sh +++ b/lustre/tests/sanityN.sh @@ -3,19 +3,28 @@ set -e ONLY=${ONLY:-"$*"} -# bug number for skipped test: 1768 3192 3192 -ALWAYS_EXCEPT=${ALWAYS_EXCEPT:-"4 14b 14c"} +# bug number for skipped test: 3192 9977 +ALWAYS_EXCEPT=${ALWAYS_EXCEPT:-"14b 28"} # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT! -[ "$ALWAYS_EXCEPT$EXCEPT" ] && echo "Skipping tests: $ALWAYS_EXCEPT $EXCEPT" +[ "$SLOW" = "no" ] && EXCEPT="$EXCEPT 16" + +# Tests that fail on uml +[ "$UML" = "true" ] && EXCEPT="$EXCEPT 7" + +# Join file feature is not supported currently. +# It will be ported soon. +EXCEPT="$EXCEPT 22" SRCDIR=`dirname $0` PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH +SIZE=${SIZE:-40960} CHECKSTAT=${CHECKSTAT:-"checkstat -v"} CREATETEST=${CREATETEST:-createtest} -LFIND=${LFIND:-lfind} -LSTRIPE=${LSTRIPE:-lstripe} +GETSTRIPE=${GETSTRIPE:-lfs getstripe} +SETSTRIPE=${SETSTRIPE:-lstripe} +LFS=${LFS:-lfs} LCTL=${LCTL:-lctl} MCREATE=${MCREATE:-mcreate} OPENFILE=${OPENFILE:-openfile} @@ -23,8 +32,8 @@ OPENUNLINK=${OPENUNLINK:-openunlink} TOEXCL=${TOEXCL:-toexcl} TRUNCATE=${TRUNCATE:-truncate} export TMP=${TMP:-/tmp} +CHECK_GRANT=${CHECK_GRANT:-"no"} -. krb5_env.sh if [ $UID -ne 0 ]; then RUNAS_ID="$UID" @@ -34,29 +43,32 @@ else RUNAS=${RUNAS:-"runas -u $RUNAS_ID"} fi -if [ `using_krb5_sec $SECURITY` == 'y' ] ; then - start_krb5_kdc || exit 1 - if [ $RUNAS_ID -ne $UID ]; then - $RUNAS ./krb5_refresh_cache.sh || exit 2 - fi -fi - SAVE_PWD=$PWD -clean() { +export NAME=${NAME:-local} + +LUSTRE=${LUSTRE:-`dirname $0`/..} +. $LUSTRE/tests/test-framework.sh +init_test_env $@ +. ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh} + +if [ ! -z "$USING_KRB5" ]; then + $RUNAS krb5_login.sh || exit 1 +fi + +cleanup() { echo -n "cln.." - sh llmountcleanup.sh > /dev/null || exit 20 + grep " $MOUNT2 " /proc/mounts && zconf_umount `hostname` $MOUNT2 ${FORCE} + cleanupall ${FORCE} > /dev/null || { echo "FAILed to clean up"; exit 20; } } +CLEANUP=${CLEANUP:-:} -CLEAN=${CLEAN:-} - -start() { +setup() { echo -n "mnt.." - sh llrmount.sh > /dev/null || exit 10 + setupall || exit 10 echo "done" } - -START=${START:-} +SETUP=${SETUP:-:} log() { echo "$*" @@ -72,48 +84,153 @@ trace() { } TRACE=${TRACE:-""} +LPROC=/proc/fs/lustre + run_one() { - if ! mount | grep -q $DIR1; then - $START + if ! grep -q $DIR /proc/mounts; then + $SETUP fi + testnum=$1 + message=$2 BEFORE=`date +%s` - log "== test $1: $2= `date +%H:%M:%S` ($BEFORE)" - export TESTNAME=test_$1 - test_$1 || error "test_$1: exit with rc=$?" + log "== test $testnum: $message= `date +%H:%M:%S` ($BEFORE)" + export TESTNAME=test_$testnum + export tfile=f${testnum} + export tdir=d${base} + test_$1 || error "exit with rc=$?" + check_grant || error "check grant fail" unset TESTNAME pass "($((`date +%s` - $BEFORE))s)" cd $SAVE_PWD - $CLEAN + $CLEANUP } -run_test() { - for O in $ONLY; do - if [ "`echo $1 | grep '\<'$O'[a-z]*\>'`" ]; then - echo "" - run_one $1 "$2" - return $? - else - echo -n "." - fi +build_test_filter() { + [ "$ALWAYS_EXCEPT$EXCEPT$SANITYN_EXCEPT" ] && \ + echo "Skipping tests: `echo $ALWAYS_EXCEPT $EXCEPT $SANITYN_EXCEPT`" + + for O in $ONLY; do + eval ONLY_${O}=true + done + for E in $EXCEPT $ALWAYS_EXCEPT $SANITY_EXCEPT; do + eval EXCEPT_${E}=true + done +} + +_basetest() { + echo $* +} + +basetest() { + IFS=abcdefghijklmnopqrstuvwxyz _basetest $1 +} + +build_test_filter() { + [ "$ALWAYS_EXCEPT$EXCEPT$SANITYN_EXCEPT" ] && \ + echo "Skipping tests: `echo $ALWAYS_EXCEPT $EXCEPT $SANITYN_EXCEPT`" + + for O in $ONLY; do + eval ONLY_${O}=true + done + for E in $EXCEPT $ALWAYS_EXCEPT $SANITYN_EXCEPT; do + eval EXCEPT_${E}=true + done +} + +_basetest() { + echo $* +} + +basetest() { + IFS=abcdefghijklmnopqrstuvwxyz _basetest $1 +} + +sync_clients() { + cd $DIR1 + sync; sleep 1; sync + cd $DIR2 + sync; sleep 1; sync + + cd $SAVE_PWD +} + +check_grant() { + [ "$CHECK_GRANT" == "no" ] && return 0 + + echo -n "checking grant......" + cd $SAVE_PWD + # write some data to sync client lost_grant + rm -f $DIR1/${tfile}_check_grant_* 2>&1 + for i in `seq $OSTCOUNT`; do + $LFS setstripe $DIR1/${tfile}_check_grant_$i 0 $(($i -1)) 1 + dd if=/dev/zero of=$DIR1/${tfile}_check_grant_$i bs=4k \ + count=1 > /dev/null 2>&1 + done + # sync all the data and make sure no pending data on server + sync_clients + + #get client grant and server grant + client_grant=0 + for d in /proc/fs/lustre/osc/*/cur_grant_bytes; do + client_grant=$(($client_grant + `cat $d`)) done - for X in $EXCEPT $ALWAYS_EXCEPT; do - if [ "`echo $1 | grep '\<'$X'[a-z]*\>'`" ]; then - echo "skipping excluded test $1" - return 0 - fi + server_grant=0 + for d in /proc/fs/lustre/obdfilter/*/tot_granted; do + server_grant=$(($server_grant + `cat $d`)) done - if [ -z "$ONLY" ]; then - run_one $1 "$2" - return $? + + # cleanup the check_grant file + for i in `seq $OSTCOUNT`; do + rm $DIR1/${tfile}_check_grant_$i + done + + #check whether client grant == server grant + if [ $client_grant != $server_grant ]; then + echo "failed: client:${client_grant} server: ${server_grant}" + return 1 + else + echo "pass" fi } +run_test() { + export base=`basetest $1` + if [ "$ONLY" ]; then + testname=ONLY_$1 + if [ ${!testname}x != x ]; then + run_one $1 "$2" + return $? + fi + testname=ONLY_$base + if [ ${!testname}x != x ]; then + run_one $1 "$2" + return $? + fi + echo -n "." + return 0 + fi + testname=EXCEPT_$1 + if [ ${!testname}x != x ]; then + echo "skipping excluded test $1" + return 0 + fi + testname=EXCEPT_$base + if [ ${!testname}x != x ]; then + echo "skipping excluded test $1 (base $base)" + return 0 + fi + run_one $1 "$2" + return $? +} + [ "$SANITYLOG" ] && rm -f $SANITYLOG || true error () { - log "FAIL: $TESTNAME $@" - if [ "$SANITYLOG" ]; then - echo "FAIL: $TESTNAME $@" >> $SANITYLOG + sysctl -w lustre.fail_loc=0 2> /dev/null || true + log "$0: FAIL: $TESTNAME $@" + $LCTL dk $TMP/lustre-log-$TESTNAME.log + if [ "$SANITYLOG" ]; then + echo "$0: FAIL: $TESTNAME $@" >> $SANITYLOG else exit 1 fi @@ -123,11 +240,23 @@ pass() { echo PASS $@ } -export MOUNT1=`mount| awk '/ lustre/ { print $3 }'| head -n 1` -export MOUNT2=`mount| awk '/ lustre/ { print $3 }'| tail -n 1` +mounted_lustre_filesystems() { + awk '($3 ~ "lustre" && $1 ~ ":") { print $2 }' /proc/mounts +} +MOUNTED="`mounted_lustre_filesystems`" +if [ -z "$MOUNTED" ]; then + formatall + setupall + mount_client $MOUNT2 + MOUNTED="`mounted_lustre_filesystems`" + [ -z "$MOUNTED" ] && error "NAME=$NAME not mounted" + I_MOUNTED=yes +fi +export MOUNT1=`mounted_lustre_filesystems | head -n 1` [ -z "$MOUNT1" ] && error "NAME=$NAME not mounted once" +export MOUNT2=`mounted_lustre_filesystems | tail -n 1` [ "$MOUNT1" = "$MOUNT2" ] && error "NAME=$NAME not mounted twice" -[ `mount| awk '/ lustre/ { print $3 }'| wc -l` -ne 2 ] && \ +[ `mounted_lustre_filesystems | wc -l` -ne 2 ] && \ error "NAME=$NAME mounted more than twice" export DIR1=${DIR1:-$MOUNT1} @@ -135,8 +264,14 @@ export DIR2=${DIR2:-$MOUNT2} [ -z "`echo $DIR1 | grep $MOUNT1`" ] && echo "$DIR1 not in $MOUNT1" && exit 96 [ -z "`echo $DIR2 | grep $MOUNT2`" ] && echo "$DIR2 not in $MOUNT2" && exit 95 +LPROC=/proc/fs/lustre +LOVNAME=`cat $LPROC/llite/*/lov/common_name | tail -n 1` +OSTCOUNT=`cat $LPROC/lov/$LOVNAME/numobd` + rm -rf $DIR1/[df][0-9]* $DIR1/lnk +build_test_filter + test_1a() { touch $DIR1/f1 [ -f $DIR2/f1 ] || error @@ -190,6 +325,15 @@ test_2d() { } run_test 2d "check cached attribute updates on 2 mtpt's root ===" +test_2e() { + chmod 755 $DIR1 + ls -l $DIR1 + ls -l $DIR2 + chmod 777 $DIR1 + $RUNAS dd if=/dev/zero of=$DIR2/$tfile count=1 || error +} +run_test 2e "check chmod on root is propagated to others" + test_3() { ( cd $DIR1 ; ln -s this/is/good lnk ) [ "this/is/good" = "`perl -e 'print readlink("'$DIR2/lnk'");'`" ] || \ @@ -211,17 +355,20 @@ test_5() { run_test 5 "create a file on one mount, truncate it on the other" test_6() { - openunlink $DIR1/f6 $DIR2/f6 || error + openunlink $DIR1/$tfile $DIR2/$tfile || \ + error "openunlink $DIR1/$tfile $DIR2/$tfile" } run_test 6 "remove of open file on other node ==================" test_7() { - opendirunlink $DIR1/d7 $DIR2/d7 || error + opendirunlink $DIR1/$tdir $DIR2/$tdir || \ + error "opendirunlink $DIR1/$tdir $DIR2/$tdir" } run_test 7 "remove of open directory on other node =============" test_8() { - opendevunlink $DIR1/dev8 $DIR2/dev8 || error + opendevunlink $DIR1/$tfile $DIR2/$tfile || \ + error "opendevunlink $DIR1/$tfile $DIR2/$tfile" } run_test 8 "remove of open special file on other node ==========" @@ -264,6 +411,7 @@ test_10b() { yes "R" | dd of=$TMP/f10b bs=3k count=1 || error "dd random" truncate $TMP/f10b 4096 || error "truncate 4096" cmp $TMP/f10b $TMP/f10b-lustre || error "file miscompare" + rm $TMP/f10b $TMP/f10b-lustre } run_test 10b "write of file with sub-page size on multiple mounts " @@ -321,63 +469,80 @@ test_14a() { multiop $DIR2/d14/multiop Oc && error "expected error, got success" kill -USR1 $MULTIPID || return 2 wait $MULTIPID || return 3 + rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop" } run_test 14a "open(RDWR) of executing file returns -ETXTBSY ====" -test_14b() { # bug 3192 +test_14b() { # bug 3192, 7040 mkdir -p $DIR1/d14 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed" $DIR1/d14/multiop $TMP/test14.junk O_c & MULTIPID=$! sleep 1 - truncate $DIR2/d14/multiop 0 && error "expected error, got success" + truncate $DIR2/d14/multiop 0 && kill -9 $MULTIPID && \ + error "expected truncate error, got success" kill -USR1 $MULTIPID || return 2 wait $MULTIPID || return 3 + cmp `which multiop` $DIR1/d14/multiop || error "binary changed" + rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop" } run_test 14b "truncate of executing file returns -ETXTBSY ======" -test_14c() { # bug 3430 - mkdir -p $DIR1/d14 - cp -p `which multiop` $DIR1/d14/multiop || error "cp failed" - $DIR1/d14/multiop $TMP/test14.junk O_c & - MULTIPID=$! - sleep 1 - cp /etc/hosts $DIR2/d14/multiop && error "expected error, got success" - kill -USR1 $MULTIPID || return 2 - wait $MULTIPID || return 3 - #cmp `which multiop` $DIR1/d14/multiop || error "binary changed" +test_14c() { # bug 3430, 7040 + mkdir -p $DIR1/d14 + cp -p `which multiop` $DIR1/d14/multiop || error "cp failed" + $DIR1/d14/multiop $TMP/test14.junk O_c & + MULTIPID=$! + sleep 1 + cp /etc/hosts $DIR2/d14/multiop && error "expected error, got success" + kill -USR1 $MULTIPID || return 2 + wait $MULTIPID || return 3 + cmp `which multiop` $DIR1/d14/multiop || error "binary changed" + rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop" } run_test 14c "open(O_TRUNC) of executing file return -ETXTBSY ==" +test_14d() { # bug 10921 + mkdir -p $DIR1/d14 + cp -p `which multiop` $DIR1/d14/multiop || error "cp failed" + $DIR1/d14/multiop $TMP/test14.junk O_c & + MULTIPID=$! + sleep 1 + log chmod + chmod 600 $DIR1/d14/multiop || error "chmod failed" + kill -USR1 $MULTIPID || return 2 + wait $MULTIPID || return 3 + cmp `which multiop` $DIR1/d14/multiop || error "binary changed" + rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop" +} +run_test 14d "chmod of executing file is still possible ========" + test_15() { # bug 974 - ENOSPC - echo $PATH + echo "PATH=$PATH" sh oos2.sh $MOUNT1 $MOUNT2 + grant_error=`dmesg | grep "> available"` + [ -z "$grant_error" ] || error "$grant_error" } run_test 15 "test out-of-space with multiple writers ===========" test_16() { - fsx -c 50 -p 100 -N 2500 $MOUNT1/fsxfile $MOUNT2/fsxfile + rm -f $MOUNT1/fsxfile + lfs setstripe $MOUNT1/fsxfile 0 -1 -1 # b=10919 + fsx -c 50 -p 100 -N 2500 -l $((SIZE * 256)) -S 0 $MOUNT1/fsxfile $MOUNT2/fsxfile } run_test 16 "2500 iterations of dual-mount fsx =================" -cancel_lru_locks() { - for d in /proc/fs/lustre/ldlm/namespaces/$1*; do - echo clear > $d/lru_size - done - grep [0-9] /proc/fs/lustre/ldlm/namespaces/$1*/lock_unused_count /dev/null -} - test_17() { # bug 3513, 3667 - [ ! -d /proc/fs/lustre/ost ] && echo "skipping OST-only test" && return + [ ! -d /proc/fs/lustre/ost ] && echo "skipping OST-only test" && return - cp /etc/termcap $DIR1/f17 - cancel_lru_locks OSC > /dev/null - #define OBD_FAIL_ONCE|OBD_FAIL_LDLM_CREATE_RESOURCE 0x30a - echo 0x8000030a > /proc/sys/lustre/fail_loc - ls -ls $DIR1/f17 | awk '{ print $1,$6 }' > $DIR1/f17-1 & \ - ls -ls $DIR2/f17 | awk '{ print $1,$6 }' > $DIR2/f17-2 - wait - diff -u $DIR1/f17-1 $DIR2/f17-2 || error "files are different" + cp /etc/termcap $DIR1/f17 + cancel_lru_locks osc > /dev/null + #define OBD_FAIL_ONCE|OBD_FAIL_LDLM_CREATE_RESOURCE 0x30a + sysctl -w lustre.fail_loc=0x8000030a + ls -ls $DIR1/f17 | awk '{ print $1,$6 }' > $DIR1/f17-1 & \ + ls -ls $DIR2/f17 | awk '{ print $1,$6 }' > $DIR2/f17-2 + wait + diff -u $DIR1/f17-1 $DIR2/f17-2 || error "files are different" } run_test 17 "resource creation/LVB creation race ===============" @@ -387,42 +552,261 @@ test_18() { } run_test 18 "mmap sanity check =================================" -test_19() { # bug 2441 - touch $DIR1/f2b - - #test set/get xattr - setfattr -n trusted.name1 -v value1 $DIR1/f2b || error - [ "`getfattr -n trusted.name1 $DIR2/f2b 2> /dev/null | \ - grep "trusted.name1"`" == "trusted.name1=\"value1\"" ] || error - - setfattr -n user.author1 -v author1 $DIR/f2b || error - [ "`getfattr -n user.author1 $DIR/f2b 2> /dev/null | \ - grep "user.author1"`" == "user.author1=\"author1\"" ] || error - - # test listxattr - setfattr -n trusted.name2 -v value2 $DIR2/f2b || error - setfattr -n trusted.name3 -v value3 $DIR1/f2b || error - [ `getfattr -d -m "^trusted" $DIR2/f2b 2> /dev/null | \ - grep "trusted" | wc -l` -eq 5 ] || error - - setfattr -n user.author2 -v author2 $DIR/f2b || error - setfattr -n user.author3 -v author3 $DIR/f2b || error - [ `getfattr -d -m "^user" $DIR/f2b 2> /dev/null | \ - grep "user" | wc -l` -eq 3 ] || error - #test removexattr - setfattr -x trusted.name1 $DIR2/f2b 2> /dev/null || error - getfattr -d -m trusted $DIR2/f2b 2> /dev/null | \ - grep "trusted.name1" && error || true - - setfattr -x user.author1 $DIR/f2b 2> /dev/null || error - getfattr -d -m user $DIR/f2b 2> /dev/null | \ - grep "user.author1" && error || true -} -run_test 19 "test set/get xattr on multiple mounts ============" +test_19() { # bug3811 + [ -d /proc/fs/lustre/obdfilter ] || return 0 + MAX=`cat /proc/fs/lustre/obdfilter/*/readcache_max_filesize | head -n 1` + for O in /proc/fs/lustre/obdfilter/*OST*; do + echo 4096 > $O/readcache_max_filesize + done + dd if=/dev/urandom of=$TMP/f19b bs=512k count=32 + SUM=`cksum $TMP/f19b | cut -d" " -f 1,2` + cp $TMP/f19b $DIR1/f19b + for i in `seq 1 20`; do + [ $((i % 5)) -eq 0 ] && log "test_18 loop $i" + cancel_lru_locks osc > /dev/null + cksum $DIR1/f19b | cut -d" " -f 1,2 > $TMP/sum1 & \ + cksum $DIR2/f19b | cut -d" " -f 1,2 > $TMP/sum2 + wait + [ "`cat $TMP/sum1`" = "$SUM" ] || \ + error "$DIR1/f19b `cat $TMP/sum1` != $SUM" + [ "`cat $TMP/sum2`" = "$SUM" ] || \ + error "$DIR2/f19b `cat $TMP/sum2` != $SUM" + done + for O in /proc/fs/lustre/obdfilter/*OST*; do + echo $MAX > $O/readcache_max_filesize + done + rm $DIR1/f19b +} +#run_test 19 "test concurrent uncached read races ===============" + +test_20() { + mkdir $DIR1/d20 + cancel_lru_locks osc + CNT=$((`cat /proc/fs/lustre/llite/*/dump_page_cache | wc -l`)) + multiop $DIR1/f20 Ow8190c + multiop $DIR2/f20 Oz8194w8190c + multiop $DIR1/f20 Oz0r8190c + cancel_lru_locks osc + CNTD=$((`cat /proc/fs/lustre/llite/*/dump_page_cache | wc -l` - $CNT)) + [ $CNTD -gt 0 ] && \ + error $CNTD" page left in cache after lock cancel" || true +} +run_test 20 "test extra readahead page left in cache ====" + +cleanup_21() { + trap 0 + umount $DIR1/d21 +} + +test_21() { # Bug 5907 + mkdir $DIR1/d21 + mount /etc $DIR1/d21 --bind || error "mount failed" # Poor man's mount. + trap cleanup_21 EXIT + rmdir -v $DIR1/d21 && error "Removed mounted directory" + rmdir -v $DIR2/d21 && echo "Removed mounted directory from another mountpoint, needs to be fixed" + test -d $DIR1/d21 || error "Mounted directory disappeared" + cleanup_21 + test -d $DIR2/d21 || test -d $DIR1/d21 && error "Removed dir still visible after umount" + true +} +run_test 21 " Try to remove mountpoint on another dir ====" + +JOIN=${JOIN:-"lfs join"} + +test_22() { # Bug 9926 + mkdir $DIR1/d21 + dd if=/dev/urandom of=$DIR1/d21/128k bs=1024 count=128 + cp -p $DIR1/d21/128k $DIR1/d21/f_head + for ((i=0;i<10;i++)); do + cp -p $DIR1/d21/128k $DIR1/d21/f_tail + $JOIN $DIR1/d21/f_head $DIR1/d21/f_tail || error "join error" + $CHECKSTAT -a $DIR1/d21/f_tail || error "tail file exist after join" + done + echo aaaaaaaaaaa >> $DIR1/d21/no_joined + + mv $DIR2/d21/f_head $DIR2/ + munlink $DIR2/f_head || error "unlink joined file error" + cat $DIR2/d21/no_joined || error "cat error" + rm -rf $DIR2/d21/no_joined || error "unlink normal file error" +} +run_test 22 " After joining in one dir, open/close unlink file in anther dir" + +test_23() { # Bug 5972 + echo "others should see updated atime while another read" > $DIR1/f23 + + # clear the lock(mode: LCK_PW) gotten from creating operation + cancel_lru_locks osc + + time1=`date +%s` + sleep 2 + + multiop $DIR1/f23 or20_c & + MULTIPID=$! + + sleep 2 + time2=`stat -c "%X" $DIR2/f23` + + if (( $time2 <= $time1 )); then + kill -USR1 $MULTIPID + error "atime doesn't update among nodes" + fi + + kill -USR1 $MULTIPID || return 1 + rm -f $DIR1/f23 || error "rm -f $DIR1/f23 failed" + true +} +run_test 23 " others should see updated atime while another read====" + +test_24() { + touch $DIR1/$tfile + lfs df || error "lfs df failed" + lfs df -ih || error "lfs df -ih failed" + lfs df -h $DIR1 || error "lfs df -h $DIR1 failed" + lfs df -i $DIR2 || error "lfs df -i $DIR2 failed" + lfs df $DIR1/$tfile || error "lfs df $DIR1/$tfile failed" + lfs df -ih $DIR2/$tfile || error "lfs df -ih $DIR2/$tfile failed" + + OSC=`lctl dl | awk '/-osc-|OSC.*MNT/ {print $4}' | head -n 1` +# OSC=`lctl dl | awk '/-osc-/ {print $4}' | head -n 1` + lctl --device %$OSC deactivate + lfs df -i || error "lfs df -i with deactivated OSC failed" + lctl --device %$OSC recover + lfs df || error "lfs df with reactivated OSC failed" +} +run_test 24 "lfs df [-ih] [path] test =========================" + +test_25() { + [ `cat $LPROC/mdc/*-mdc-*/connect_flags | grep -c acl` -lt 2 ] && echo "skipping $TESTNAME (must have acl)" && return + + mkdir $DIR1/$tdir || error "mkdir $DIR1/$tdir" + touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1" + chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1" + + $RUNAS checkstat $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1" + setfacl -m u:$RUNAS_ID:--- $DIR1/$tdir || error "setfacl $DIR2/$tdir #1" + $RUNAS checkstat $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2" + setfacl -m u:$RUNAS_ID:r-x $DIR1/$tdir || error "setfacl $DIR2/$tdir #2" + $RUNAS checkstat $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3" + setfacl -m u:$RUNAS_ID:--- $DIR1/$tdir || error "setfacl $DIR2/$tdir #3" + $RUNAS checkstat $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4" + setfacl -x u:$RUNAS_ID: $DIR1/$tdir || error "setfacl $DIR2/$tdir #4" + $RUNAS checkstat $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5" + + rm -rf $DIR1/$tdir +} +run_test 25 "change ACL on one mountpoint be seen on another ===" + +test_26a() { + utime $DIR1/f26a -s $DIR2/f26a || error +} +run_test 26a "allow mtime to get older" + +test_26b() { + touch $DIR1/$tfile + sleep 1 + echo "aaa" >> $DIR1/$tfile + sleep 1 + chmod a+x $DIR2/$tfile + mt1=`stat -c %Y $DIR1/$tfile` + mt2=`stat -c %Y $DIR2/$tfile` + + if [ x"$mt1" != x"$mt2" ]; then + error "not equal mtime, client1: "$mt1", client2: "$mt2"." + fi +} +run_test 26b "sync mtime between ost and mds" + +test_27() { + cancel_lru_locks osc + lctl clear + dd if=/dev/zero of=$DIR2/$tfile bs=$((4096+4))k conv=notrunc count=4 seek=3 & + DD2_PID=$! + usleep 50 + log "dd 1 started" + + dd if=/dev/zero of=$DIR1/$tfile bs=$((16384-1024))k conv=notrunc count=1 seek=4 & + DD1_PID=$! + log "dd 2 started" + + sleep 1 + dd if=/dev/zero of=$DIR1/$tfile bs=8k conv=notrunc count=1 seek=0 + log "dd 3 finished" + echo > $LPROC/ldlm/dump_namespaces + wait $DD1_PID $DD2_PID + [ $? -ne 0 ] && lctl dk $TMP/debug || true +} +run_test 27 "align non-overlapping extent locks from request ===" + +test_28() { # bug 9977 + ECHO_UUID="ECHO_osc1_UUID" + tOST=`$LCTL dl | | awk '/-osc-|OSC.*MNT/ { print $4 }' | head -1` + + lfs setstripe $DIR1/$tfile 1048576 0 2 + tOBJID=`lfs getstripe $DIR1/$tfile |grep "^[[:space:]]\+1" |awk '{print $2}'` + dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2 + + $LCTL <<-EOF + newdev + attach echo_client ECHO_osc1 $ECHO_UUID + setup $tOST + EOF + + tECHOID=`$LCTL dl | grep $ECHO_UUID | awk '{print $1}'` + $LCTL --device $tECHOID destroy "${tOBJID}:0" + + $LCTL <<-EOF + cfg_device ECHO_osc1 + cleanup + detach + EOF + + # reading of 1st stripe should pass + dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error + # reading of 2nd stripe should fail (this stripe was destroyed) + dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 && error + + # now, recreating test file + dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2 || error + # reading of 1st stripe should pass + dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error + # reading of 2nd stripe should pass + dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 || error +} +run_test 28 "read/write/truncate file with lost stripes" + +test_29() { # bug 10999 + touch $DIR1/$tfile + #define OBD_FAIL_LDLM_GLIMPSE 0x30f + sysctl -w lustre.fail_loc=0x8000030f + ls -l $DIR2/$tfile & + usleep 500 + dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 + wait +} +#bug 11549 - permanently turn test off in b1_5 +#run_test 29 "lock put race between glimpse and enqueue =========" + +test_30() { #bug #11110 + rm -rf $DIR1/$tdir + mkdir -p $DIR1/$tdir + cp -f /bin/bash $DIR1/$tdir/bash + /bin/sh -c 'sleep 1; rm -f $DIR2/$tdir/bash; cp /bin/bash $DIR2/$tdir' & + err=$($DIR1/$tdir/bash -c 'sleep 2; openfile -f O_RDONLY /proc/$$/exe >& /dev/null; echo $?') + wait + [ $err -ne 116 ] && error "return code ($err) != -ESTALE" && return + true +} + +run_test 30 "recreate file race =========" log "cleanup: ======================================================" rm -rf $DIR1/[df][0-9]* $DIR1/lnk || true +if [ "$I_MOUNTED" = "yes" ]; then + cleanup +fi echo '=========================== finished ===============================' [ -f "$SANITYLOG" ] && cat $SANITYLOG && exit 1 || true +echo "$0: completed" +