6 # bug number for skipped test: 3192 4035
7 ALWAYS_EXCEPT=${ALWAYS_EXCEPT:-"14b 14c"}
8 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
10 # Tests that fail on uml
11 [ "$UML" = "true" ] && EXCEPT="$EXCEPT 7"
14 PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH
17 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
18 CREATETEST=${CREATETEST:-createtest}
20 LSTRIPE=${LSTRIPE:-lstripe}
22 MCREATE=${MCREATE:-mcreate}
23 OPENFILE=${OPENFILE:-openfile}
24 OPENUNLINK=${OPENUNLINK:-openunlink}
25 TOEXCL=${TOEXCL:-toexcl}
26 TRUNCATE=${TRUNCATE:-truncate}
27 export TMP=${TMP:-/tmp}
29 if [ $UID -ne 0 ]; then
33 RUNAS_ID=${RUNAS_ID:-500}
34 RUNAS=${RUNAS:-"runas -u $RUNAS_ID"}
39 # for MCSETUP and MCCLEANUP
40 LUSTRE=${LUSTRE:-`dirname $0`/..}
41 . $LUSTRE/tests/test-framework.sh
43 . ${CONFIG:=$LUSTRE/tests/cfg/local.sh}
48 grep " $MOUNT2 " /proc/mounts && zconf_umount `hostname` $MOUNT2 ${FORCE}
49 $MCCLEANUP ${FORCE} > /dev/null || { echo "FAILed to clean up"; exit 20; }
62 lctl mark "$*" 2> /dev/null || true
67 strace -o $TMP/$1.strace -ttt $*
69 log "FINISHED: $*: rc $RC"
75 if ! grep -q $DIR /proc/mounts; then
81 log "== test $testnum: $message= `date +%H:%M:%S` ($BEFORE)"
82 export TESTNAME=test_$testnum
83 export tfile=f${testnum}
85 test_$1 || error "exit with rc=$?"
87 pass "($((`date +%s` - $BEFORE))s)"
93 [ "$ALWAYS_EXCEPT$EXCEPT$SANITYN_EXCEPT" ] && \
94 echo "Skipping tests: `echo $ALWAYS_EXCEPT $EXCEPT $SANITYN_EXCEPT`"
99 for E in $EXCEPT $ALWAYS_EXCEPT $SANITY_EXCEPT; do
100 eval EXCEPT_${E}=true
109 IFS=abcdefghijklmnopqrstuvwxyz _basetest $1
112 build_test_filter() {
113 [ "$ALWAYS_EXCEPT$EXCEPT$SANITYN_EXCEPT" ] && \
114 echo "Skipping tests: `echo $ALWAYS_EXCEPT $EXCEPT $SANITYN_EXCEPT`"
119 for E in $EXCEPT $ALWAYS_EXCEPT $SANITY_EXCEPT; do
120 eval EXCEPT_${E}=true
129 IFS=abcdefghijklmnopqrstuvwxyz _basetest $1
133 export base=`basetest $1`
136 if [ ${!testname}x != x ]; then
141 if [ ${!testname}x != x ]; then
149 if [ ${!testname}x != x ]; then
150 echo "skipping excluded test $1"
153 testname=EXCEPT_$base
154 if [ ${!testname}x != x ]; then
155 echo "skipping excluded test $1 (base $base)"
162 [ "$SANITYLOG" ] && rm -f $SANITYLOG || true
165 log "FAIL: $TESTNAME $@"
166 if [ "$SANITYLOG" ]; then
167 echo "FAIL: $TESTNAME $@" >> $SANITYLOG
177 mounted_lustre_filesystems() {
178 awk '($3 ~ "lustre" && $1 ~ ":") { print $2 }' /proc/mounts
180 MOUNTED="`mounted_lustre_filesystems`"
181 if [ -z "$MOUNTED" ]; then
185 MOUNTED="`mounted_lustre_filesystems`"
186 [ -z "$MOUNTED" ] && error "NAME=$NAME not mounted"
189 export MOUNT1=`mounted_lustre_filesystems | head -n 1`
190 [ -z "$MOUNT1" ] && error "NAME=$NAME not mounted once"
191 export MOUNT2=`mounted_lustre_filesystems | tail -n 1`
192 [ "$MOUNT1" = "$MOUNT2" ] && error "NAME=$NAME not mounted twice"
193 [ `mounted_lustre_filesystems | wc -l` -ne 2 ] && \
194 error "NAME=$NAME mounted more than twice"
196 export DIR1=${DIR1:-$MOUNT1}
197 export DIR2=${DIR2:-$MOUNT2}
198 [ -z "`echo $DIR1 | grep $MOUNT1`" ] && echo "$DIR1 not in $MOUNT1" && exit 96
199 [ -z "`echo $DIR2 | grep $MOUNT2`" ] && echo "$DIR2 not in $MOUNT2" && exit 95
201 rm -rf $DIR1/[df][0-9]* $DIR1/lnk
207 [ -f $DIR2/f1 ] || error
209 run_test 1a "check create on 2 mtpt's =========================="
213 $CHECKSTAT -t file -p 0777 $DIR1/f1 || error
216 run_test 1b "check attribute updates on 2 mtpt's ==============="
219 $CHECKSTAT -t file -p 0666 $DIR1/f1 || error
221 run_test 1c "check after remount attribute updates on 2 mtpt's ="
225 $CHECKSTAT -a $DIR1/f1 || error
227 run_test 1d "unlink on one mountpoint removes file on other ===="
233 $CHECKSTAT -t file -p 0777 $DIR1/f2a || error
235 run_test 2a "check cached attribute updates on 2 mtpt's ========"
241 $CHECKSTAT -t file -p 0777 $DIR2/f2b || error
243 run_test 2b "check cached attribute updates on 2 mtpt's ========"
245 # NEED TO SAVE ROOT DIR MODE
248 $CHECKSTAT -t dir -p 0777 $DIR2 || error
250 run_test 2c "check cached attribute updates on 2 mtpt's root ==="
254 $CHECKSTAT -t dir -p 0755 $DIR2 || error
256 run_test 2d "check cached attribute updates on 2 mtpt's root ==="
259 ( cd $DIR1 ; ln -s this/is/good lnk )
260 [ "this/is/good" = "`perl -e 'print readlink("'$DIR2/lnk'");'`" ] || \
263 run_test 3 "symlink on one mtpt, readlink on another ==========="
266 multifstat $DIR1/f4 $DIR2/f4
268 run_test 4 "fstat validation on multiple mount points =========="
272 truncate $DIR2/f5 100
273 $CHECKSTAT -t file -s 100 $DIR1/f5 || error
276 run_test 5 "create a file on one mount, truncate it on the other"
279 openunlink $DIR1/f6 $DIR2/f6 || error
281 run_test 6 "remove of open file on other node =================="
284 opendirunlink $DIR1/d7 $DIR2/d7 || error
286 run_test 7 "remove of open directory on other node ============="
289 opendevunlink $DIR1/dev8 $DIR2/dev8 || error
291 run_test 8 "remove of open special file on other node =========="
296 for C in a b c d e f g h i j k l; do
297 DIR=`eval echo \\$DIR$MTPT`
298 echo -n $C >> $DIR/f9
299 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
301 [ "`cat $DIR1/f9`" = "abcdefghijkl" ] || \
302 error "`od -a $DIR1/f9` != abcdefghijkl"
304 run_test 9 "append of file with sub-page size on multiple mounts"
310 for C in a b c d e f g h i j k l; do
311 DIR=`eval echo \\$DIR$MTPT`
312 echo -n $C | dd of=$DIR/f10 bs=1 seek=$OFFSET count=1
313 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
314 OFFSET=`expr $OFFSET + 1`
316 [ "`cat $DIR1/f10`" = "abcdefghijkl" ] || \
317 error "`od -a $DIR1/f10` != abcdefghijkl"
319 run_test 10a "write of file with sub-page size on multiple mounts "
322 yes "R" | dd of=$DIR1/f10b bs=3k count=1 || error "dd $DIR1"
324 truncate $DIR1/f10b 4096 || error "truncate 4096"
326 dd if=$DIR2/f10b of=$TMP/f10b-lustre bs=4k count=1 || error "dd $DIR2"
328 # create a test file locally to compare
329 yes "R" | dd of=$TMP/f10b bs=3k count=1 || error "dd random"
330 truncate $TMP/f10b 4096 || error "truncate 4096"
331 cmp $TMP/f10b $TMP/f10b-lustre || error "file miscompare"
332 rm $TMP/f10b $TMP/f10b-lustre
334 run_test 10b "write of file with sub-page size on multiple mounts "
338 multiop $DIR1/d11/f O_c &
341 cp -p /bin/ls $DIR1/d11/f
345 wait $MULTIPID || error
346 [ $RC -eq 0 ] && error || true
348 run_test 11 "execution of file opened for write should return error ===="
353 run_test 12 "test lock ordering (link, stat, unlink) ==========="
355 test_13() { # bug 2451 - directory coherency
357 mkdir $DIR1/d13 || error
358 cd $DIR1/d13 || error
360 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
362 rm -f $DIR2/d13/f13 || error
363 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (1)" || true
364 # need to run it twice
365 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
367 rm -f $DIR2/d13/f13 || error
368 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (2)" || true
370 run_test 13 "test directory page revocation ===================="
374 cp -p /bin/ls $DIR1/d14/ls
375 exec 100>> $DIR1/d14/ls
376 $DIR2/d14/ls && error || true
379 run_test 14 "execution of file open for write returns -ETXTBSY ="
383 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
384 $DIR1/d14/multiop $TMP/test14.junk O_c &
387 multiop $DIR2/d14/multiop Oc && error "expected error, got success"
388 kill -USR1 $MULTIPID || return 2
389 wait $MULTIPID || return 3
392 run_test 14a "open(RDWR) of executing file returns -ETXTBSY ===="
394 test_14b() { # bug 3192
396 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
397 $DIR1/d14/multiop $TMP/test14.junk O_c &
400 truncate $DIR2/d14/multiop 0 && error "expected error, got success"
401 kill -USR1 $MULTIPID || return 2
402 wait $MULTIPID || return 3
405 run_test 14b "truncate of executing file returns -ETXTBSY ======"
407 test_14c() { # bug 3430
409 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
410 $DIR1/d14/multiop $TMP/test14.junk O_c &
413 cp /etc/hosts $DIR2/d14/multiop && error "expected error, got success"
414 kill -USR1 $MULTIPID || return 2
415 wait $MULTIPID || return 3
416 #cmp `which multiop` $DIR1/d14/multiop || error "binary changed"
419 run_test 14c "open(O_TRUNC) of executing file return -ETXTBSY =="
421 test_15() { # bug 974 - ENOSPC
423 sh oos2.sh $MOUNT1 $MOUNT2
425 run_test 15 "test out-of-space with multiple writers ==========="
428 fsx -c 50 -p 100 -N 2500 -S 0 $MOUNT1/fsxfile $MOUNT2/fsxfile
430 run_test 16 "2500 iterations of dual-mount fsx ================="
433 for d in /proc/fs/lustre/ldlm/namespaces/*-$1-*; do
434 echo clear > $d/lru_size
436 grep "[0-9]" /proc/fs/lustre/ldlm/namespaces/*-$1-*/lock_unused_count /dev/null
439 test_17() { # bug 3513, 3667
440 [ ! -d /proc/fs/lustre/ost ] && echo "skipping OST-only test" && return
442 cp /etc/termcap $DIR1/f17
443 cancel_lru_locks osc > /dev/null
444 #define OBD_FAIL_ONCE|OBD_FAIL_LDLM_CREATE_RESOURCE 0x30a
445 echo 0x8000030a > /proc/sys/lustre/fail_loc
446 ls -ls $DIR1/f17 | awk '{ print $1,$6 }' > $DIR1/f17-1 & \
447 ls -ls $DIR2/f17 | awk '{ print $1,$6 }' > $DIR2/f17-2
449 diff -u $DIR1/f17-1 $DIR2/f17-2 || error "files are different"
451 run_test 17 "resource creation/LVB creation race ==============="
454 ./mmap_sanity -d $MOUNT1 -m $MOUNT2
457 run_test 18 "mmap sanity check ================================="
459 test_19() { # bug3811
460 [ -d /proc/fs/lustre/obdfilter ] || return 0
462 MAX=`cat /proc/fs/lustre/obdfilter/*/readcache_max_filesize | head -n 1`
463 for O in /proc/fs/lustre/obdfilter/*OST*; do
464 echo 4096 > $O/readcache_max_filesize
466 dd if=/dev/urandom of=$TMP/f19b bs=512k count=32
467 SUM=`cksum $TMP/f19b | cut -d" " -f 1,2`
468 cp $TMP/f19b $DIR1/f19b
469 for i in `seq 1 20`; do
470 [ $((i % 5)) -eq 0 ] && log "test_18 loop $i"
471 cancel_lru_locks osc > /dev/null
472 cksum $DIR1/f19b | cut -d" " -f 1,2 > $TMP/sum1 & \
473 cksum $DIR2/f19b | cut -d" " -f 1,2 > $TMP/sum2
475 [ "`cat $TMP/sum1`" = "$SUM" ] || \
476 error "$DIR1/f19b `cat $TMP/sum1` != $SUM"
477 [ "`cat $TMP/sum2`" = "$SUM" ] || \
478 error "$DIR2/f19b `cat $TMP/sum2` != $SUM"
480 for O in /proc/fs/lustre/obdfilter/*OST*; do
481 echo $MAX > $O/readcache_max_filesize
485 #run_test 19 "test concurrent uncached read races ==============="
490 CNT=$((`cat /proc/fs/lustre/llite/fs0/dump_page_cache | wc -l`))
491 multiop $DIR1/f20 Ow8190c
492 multiop $DIR2/f20 Oz8194w8190c
493 multiop $DIR1/f20 Oz0r8190c
495 CNTD=$((`cat /proc/fs/lustre/llite/fs0/dump_page_cache | wc -l` - $CNT))
497 error $CNTD" page left in cache after lock cancel" || true
499 run_test 20 "test extra readahead page left in cache ===="
506 test_21() { # Bug 5907
508 mount /etc $DIR1/d21 --bind || error "mount failed" # Poor man's mount.
510 rmdir -v $DIR1/d21 && error "Removed mounted directory"
511 rmdir -v $DIR2/d21 && echo "Removed mounted directory from another mountpoint, needs to be fixed"
512 test -d $DIR1/d21 || error "Mounted directory disappeared"
514 test -d $DIR2/d21 || test -d $DIR1/d21 && error "Removed dir still visible after umount"
517 run_test 21 " Try to remove mountpoint on another dir ===="
519 JOIN=${JOIN:-"lfs join"}
521 test_22() { # Bug 9926
523 dd if=/dev/urandom of=$DIR1/d21/128k bs=1024 count=128
524 cp -p $DIR1/d21/128k $DIR1/d21/f_head
525 for ((i=0;i<10;i++)); do
526 cp -p $DIR1/d21/128k $DIR1/d21/f_tail
527 $JOIN $DIR1/d21/f_head $DIR1/d21/f_tail || error "join error"
528 $CHECKSTAT -a $DIR1/d21/f_tail || error "tail file exist after join"
530 echo aaaaaaaaaaa >> $DIR1/d21/no_joined
532 mv $DIR2/d21/f_head $DIR2/
533 munlink $DIR2/f_head || error "unlink joined file error"
534 cat $DIR2/d21/no_joined || error "cat error"
535 rm -rf $DIR2/d21/no_joined || error "unlink normal file error"
537 run_test 22 " After joining in one dir, open/close unlink file in anther dir"
539 test_23() { # Bug 5972
540 echo "others should see updated atime while another read" > $DIR1/f23
542 # clear the lock(mode: LCK_PW) gotten from creating operation
548 multiop $DIR1/f23 or20_c &
552 time2=`stat -c "%X" $DIR2/f23`
554 if (( $time2 <= $time1 )); then
556 error "atime doesn't update among nodes"
559 kill -USR1 $MULTIPID || return 1
560 rm -f $DIR1/f23 || error "rm -f $DIR1/f23 failed"
563 run_test 23 " others should see updated atime while another read===="
567 lfs df || error "lfs df failed"
568 lfs df -ih || error "lfs df -ih failed"
569 lfs df -h $DIR1 || error "lfs df -h $DIR1 failed"
570 lfs df -i $DIR2 || error "lfs df -i $DIR2 failed"
571 lfs df $DIR1/$tfile || error "lfs df $DIR1/$tfile failed"
572 lfs df -ih $DIR2/$tfile || error "lfs df -ih $DIR2/$tfile failed"
574 OSC=`lctl dl | awk '/OSC.*MNT/ {print $4}' | head -n 1`
575 lctl --device %$OSC deactivate
576 lfs df -i || error "lfs df -i with deactivated OSC failed"
577 lctl --device %$OSC recover
578 lfs df || error "lfs df with reactivated OSC failed"
580 run_test 24 "lfs df [-ih] [path] test ========================="
583 [ -z "`mount | grep " $DIR1 .*\<acl\>"`" ] && echo "skipping $TESTNAME ($DIR1 must have acl)" && return
584 [ -z "`mount | grep " $DIR2 .*\<acl\>"`" ] && echo "skipping $TESTNAME ($DIR2 must have acl)" && return
586 mkdir $DIR1/d25 || error
587 touch $DIR1/d25/f1 || error
588 chmod 0755 $DIR1/d25/f1 || error
590 $RUNAS checkstat $DIR2/d25/f1 || error
591 setfacl -m u:$RUNAS_ID:--- $DIR1/d25 || error
592 $RUNAS checkstat $DIR2/d25/f1 && error
593 setfacl -m u:$RUNAS_ID:r-x $DIR1/d25 || error
594 $RUNAS checkstat $DIR2/d25/f1 || error
595 setfacl -m u:$RUNAS_ID:--- $DIR1/d25 || error
596 $RUNAS checkstat $DIR2/d25/f1 && error
597 setfacl -x u:$RUNAS_ID: $DIR1/d25 || error
598 $RUNAS checkstat $DIR2/d25/f1 || error
602 run_test 25 "change ACL on one mountpoint be seen on another ==="
604 log "cleanup: ======================================================"
605 rm -rf $DIR1/[df][0-9]* $DIR1/lnk || true
606 if [ "$I_MOUNTED" = "yes" ]; then
610 echo '=========================== finished ==============================='
611 [ -f "$SANITYLOG" ] && cat $SANITYLOG && exit 1 || true