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}
19 GETSTRIPE=${GETSTRIPE:-lfs getstripe}
20 SETSTRIPE=${SETSTRIPE:-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 LUSTRE=${LUSTRE:-`dirname $0`/..}
40 . $LUSTRE/tests/test-framework.sh
42 . ${CONFIG:=$LUSTRE/tests/cfg/local.sh}
44 if [ ! -z "$USING_KRB5" ]; then
45 $RUNAS krb5_login.sh || exit 1
50 grep " $MOUNT2 " /proc/mounts && zconf_umount `hostname` $MOUNT2 ${FORCE}
51 cleanupall ${FORCE} > /dev/null || { echo "FAILed to clean up"; exit 20; }
64 lctl mark "$*" 2> /dev/null || true
69 strace -o $TMP/$1.strace -ttt $*
71 log "FINISHED: $*: rc $RC"
79 if ! grep -q $DIR /proc/mounts; then
85 log "== test $testnum: $message= `date +%H:%M:%S` ($BEFORE)"
86 export TESTNAME=test_$testnum
87 export tfile=f${testnum}
89 test_$1 || error "exit with rc=$?"
91 pass "($((`date +%s` - $BEFORE))s)"
97 [ "$ALWAYS_EXCEPT$EXCEPT$SANITYN_EXCEPT" ] && \
98 echo "Skipping tests: `echo $ALWAYS_EXCEPT $EXCEPT $SANITYN_EXCEPT`"
103 for E in $EXCEPT $ALWAYS_EXCEPT $SANITY_EXCEPT; do
104 eval EXCEPT_${E}=true
113 IFS=abcdefghijklmnopqrstuvwxyz _basetest $1
116 build_test_filter() {
117 [ "$ALWAYS_EXCEPT$EXCEPT$SANITYN_EXCEPT" ] && \
118 echo "Skipping tests: `echo $ALWAYS_EXCEPT $EXCEPT $SANITYN_EXCEPT`"
123 for E in $EXCEPT $ALWAYS_EXCEPT $SANITYN_EXCEPT; do
124 eval EXCEPT_${E}=true
133 IFS=abcdefghijklmnopqrstuvwxyz _basetest $1
137 export base=`basetest $1`
140 if [ ${!testname}x != x ]; then
145 if [ ${!testname}x != x ]; then
153 if [ ${!testname}x != x ]; then
154 echo "skipping excluded test $1"
157 testname=EXCEPT_$base
158 if [ ${!testname}x != x ]; then
159 echo "skipping excluded test $1 (base $base)"
166 [ "$SANITYLOG" ] && rm -f $SANITYLOG || true
169 log "FAIL: $TESTNAME $@"
170 if [ "$SANITYLOG" ]; then
171 echo "FAIL: $TESTNAME $@" >> $SANITYLOG
181 mounted_lustre_filesystems() {
182 awk '($3 ~ "lustre" && $1 ~ ":") { print $2 }' /proc/mounts
184 MOUNTED="`mounted_lustre_filesystems`"
185 if [ -z "$MOUNTED" ]; then
189 MOUNTED="`mounted_lustre_filesystems`"
190 [ -z "$MOUNTED" ] && error "NAME=$NAME not mounted"
193 export MOUNT1=`mounted_lustre_filesystems | head -n 1`
194 [ -z "$MOUNT1" ] && error "NAME=$NAME not mounted once"
195 export MOUNT2=`mounted_lustre_filesystems | tail -n 1`
196 [ "$MOUNT1" = "$MOUNT2" ] && error "NAME=$NAME not mounted twice"
197 [ `mounted_lustre_filesystems | wc -l` -ne 2 ] && \
198 error "NAME=$NAME mounted more than twice"
200 export DIR1=${DIR1:-$MOUNT1}
201 export DIR2=${DIR2:-$MOUNT2}
202 [ -z "`echo $DIR1 | grep $MOUNT1`" ] && echo "$DIR1 not in $MOUNT1" && exit 96
203 [ -z "`echo $DIR2 | grep $MOUNT2`" ] && echo "$DIR2 not in $MOUNT2" && exit 95
205 rm -rf $DIR1/[df][0-9]* $DIR1/lnk
211 [ -f $DIR2/f1 ] || error
213 run_test 1a "check create on 2 mtpt's =========================="
217 $CHECKSTAT -t file -p 0777 $DIR1/f1 || error
220 run_test 1b "check attribute updates on 2 mtpt's ==============="
223 $CHECKSTAT -t file -p 0666 $DIR1/f1 || error
225 run_test 1c "check after remount attribute updates on 2 mtpt's ="
229 $CHECKSTAT -a $DIR1/f1 || error
231 run_test 1d "unlink on one mountpoint removes file on other ===="
237 $CHECKSTAT -t file -p 0777 $DIR1/f2a || error
239 run_test 2a "check cached attribute updates on 2 mtpt's ========"
245 $CHECKSTAT -t file -p 0777 $DIR2/f2b || error
247 run_test 2b "check cached attribute updates on 2 mtpt's ========"
249 # NEED TO SAVE ROOT DIR MODE
252 $CHECKSTAT -t dir -p 0777 $DIR2 || error
254 run_test 2c "check cached attribute updates on 2 mtpt's root ==="
258 $CHECKSTAT -t dir -p 0755 $DIR2 || error
260 run_test 2d "check cached attribute updates on 2 mtpt's root ==="
263 ( cd $DIR1 ; ln -s this/is/good lnk )
264 [ "this/is/good" = "`perl -e 'print readlink("'$DIR2/lnk'");'`" ] || \
267 run_test 3 "symlink on one mtpt, readlink on another ==========="
270 multifstat $DIR1/f4 $DIR2/f4
272 run_test 4 "fstat validation on multiple mount points =========="
276 truncate $DIR2/f5 100
277 $CHECKSTAT -t file -s 100 $DIR1/f5 || error
280 run_test 5 "create a file on one mount, truncate it on the other"
283 openunlink $DIR1/f6 $DIR2/f6 || error
285 run_test 6 "remove of open file on other node =================="
288 opendirunlink $DIR1/d7 $DIR2/d7 || error
290 run_test 7 "remove of open directory on other node ============="
293 opendevunlink $DIR1/dev8 $DIR2/dev8 || error
295 run_test 8 "remove of open special file on other node =========="
300 for C in a b c d e f g h i j k l; do
301 DIR=`eval echo \\$DIR$MTPT`
302 echo -n $C >> $DIR/f9
303 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
305 [ "`cat $DIR1/f9`" = "abcdefghijkl" ] || \
306 error "`od -a $DIR1/f9` != abcdefghijkl"
308 run_test 9 "append of file with sub-page size on multiple mounts"
314 for C in a b c d e f g h i j k l; do
315 DIR=`eval echo \\$DIR$MTPT`
316 echo -n $C | dd of=$DIR/f10 bs=1 seek=$OFFSET count=1
317 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
318 OFFSET=`expr $OFFSET + 1`
320 [ "`cat $DIR1/f10`" = "abcdefghijkl" ] || \
321 error "`od -a $DIR1/f10` != abcdefghijkl"
323 run_test 10a "write of file with sub-page size on multiple mounts "
326 yes "R" | dd of=$DIR1/f10b bs=3k count=1 || error "dd $DIR1"
328 truncate $DIR1/f10b 4096 || error "truncate 4096"
330 dd if=$DIR2/f10b of=$TMP/f10b-lustre bs=4k count=1 || error "dd $DIR2"
332 # create a test file locally to compare
333 yes "R" | dd of=$TMP/f10b bs=3k count=1 || error "dd random"
334 truncate $TMP/f10b 4096 || error "truncate 4096"
335 cmp $TMP/f10b $TMP/f10b-lustre || error "file miscompare"
336 rm $TMP/f10b $TMP/f10b-lustre
338 run_test 10b "write of file with sub-page size on multiple mounts "
342 multiop $DIR1/d11/f O_c &
345 cp -p /bin/ls $DIR1/d11/f
349 wait $MULTIPID || error
350 [ $RC -eq 0 ] && error || true
352 run_test 11 "execution of file opened for write should return error ===="
357 run_test 12 "test lock ordering (link, stat, unlink) ==========="
359 test_13() { # bug 2451 - directory coherency
361 mkdir $DIR1/d13 || error
362 cd $DIR1/d13 || error
364 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
366 rm -f $DIR2/d13/f13 || error
367 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (1)" || true
368 # need to run it twice
369 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
371 rm -f $DIR2/d13/f13 || error
372 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (2)" || true
374 run_test 13 "test directory page revocation ===================="
378 cp -p /bin/ls $DIR1/d14/ls
379 exec 100>> $DIR1/d14/ls
380 $DIR2/d14/ls && error || true
383 run_test 14 "execution of file open for write returns -ETXTBSY ="
387 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
388 $DIR1/d14/multiop $TMP/test14.junk O_c &
391 multiop $DIR2/d14/multiop Oc && error "expected error, got success"
392 kill -USR1 $MULTIPID || return 2
393 wait $MULTIPID || return 3
396 run_test 14a "open(RDWR) of executing file returns -ETXTBSY ===="
398 test_14b() { # bug 3192
400 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
401 $DIR1/d14/multiop $TMP/test14.junk O_c &
404 truncate $DIR2/d14/multiop 0 && error "expected error, got success"
405 kill -USR1 $MULTIPID || return 2
406 wait $MULTIPID || return 3
409 run_test 14b "truncate of executing file returns -ETXTBSY ======"
411 test_14c() { # bug 3430
413 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
414 $DIR1/d14/multiop $TMP/test14.junk O_c &
417 cp /etc/hosts $DIR2/d14/multiop && error "expected error, got success"
418 kill -USR1 $MULTIPID || return 2
419 wait $MULTIPID || return 3
420 #cmp `which multiop` $DIR1/d14/multiop || error "binary changed"
423 run_test 14c "open(O_TRUNC) of executing file return -ETXTBSY =="
425 test_15() { # bug 974 - ENOSPC
427 sh oos2.sh $MOUNT1 $MOUNT2
429 run_test 15 "test out-of-space with multiple writers ==========="
432 fsx -c 50 -p 100 -N 2500 -S 0 $MOUNT1/fsxfile $MOUNT2/fsxfile
434 run_test 16 "2500 iterations of dual-mount fsx ================="
437 for d in /proc/fs/lustre/ldlm/namespaces/*-$1-*; do
438 echo clear > $d/lru_size
440 grep "[0-9]" /proc/fs/lustre/ldlm/namespaces/*-$1-*/lock_unused_count /dev/null
443 test_17() { # bug 3513, 3667
444 [ ! -d /proc/fs/lustre/ost ] && echo "skipping OST-only test" && return
446 cp /etc/termcap $DIR1/f17
447 cancel_lru_locks osc > /dev/null
448 #define OBD_FAIL_ONCE|OBD_FAIL_LDLM_CREATE_RESOURCE 0x30a
449 echo 0x8000030a > /proc/sys/lustre/fail_loc
450 ls -ls $DIR1/f17 | awk '{ print $1,$6 }' > $DIR1/f17-1 & \
451 ls -ls $DIR2/f17 | awk '{ print $1,$6 }' > $DIR2/f17-2
453 diff -u $DIR1/f17-1 $DIR2/f17-2 || error "files are different"
455 run_test 17 "resource creation/LVB creation race ==============="
458 ./mmap_sanity -d $MOUNT1 -m $MOUNT2
461 run_test 18 "mmap sanity check ================================="
463 test_19() { # bug3811
464 [ -d /proc/fs/lustre/obdfilter ] || return 0
466 MAX=`cat /proc/fs/lustre/obdfilter/*/readcache_max_filesize | head -n 1`
467 for O in /proc/fs/lustre/obdfilter/*OST*; do
468 echo 4096 > $O/readcache_max_filesize
470 dd if=/dev/urandom of=$TMP/f19b bs=512k count=32
471 SUM=`cksum $TMP/f19b | cut -d" " -f 1,2`
472 cp $TMP/f19b $DIR1/f19b
473 for i in `seq 1 20`; do
474 [ $((i % 5)) -eq 0 ] && log "test_18 loop $i"
475 cancel_lru_locks osc > /dev/null
476 cksum $DIR1/f19b | cut -d" " -f 1,2 > $TMP/sum1 & \
477 cksum $DIR2/f19b | cut -d" " -f 1,2 > $TMP/sum2
479 [ "`cat $TMP/sum1`" = "$SUM" ] || \
480 error "$DIR1/f19b `cat $TMP/sum1` != $SUM"
481 [ "`cat $TMP/sum2`" = "$SUM" ] || \
482 error "$DIR2/f19b `cat $TMP/sum2` != $SUM"
484 for O in /proc/fs/lustre/obdfilter/*OST*; do
485 echo $MAX > $O/readcache_max_filesize
489 #run_test 19 "test concurrent uncached read races ==============="
494 CNT=$((`cat /proc/fs/lustre/llite/*/dump_page_cache | wc -l`))
495 multiop $DIR1/f20 Ow8190c
496 multiop $DIR2/f20 Oz8194w8190c
497 multiop $DIR1/f20 Oz0r8190c
499 CNTD=$((`cat /proc/fs/lustre/llite/*/dump_page_cache | wc -l` - $CNT))
501 error $CNTD" page left in cache after lock cancel" || true
503 run_test 20 "test extra readahead page left in cache ===="
510 test_21() { # Bug 5907
512 mount /etc $DIR1/d21 --bind || error "mount failed" # Poor man's mount.
514 rmdir -v $DIR1/d21 && error "Removed mounted directory"
515 rmdir -v $DIR2/d21 && echo "Removed mounted directory from another mountpoint, needs to be fixed"
516 test -d $DIR1/d21 || error "Mounted directory disappeared"
518 test -d $DIR2/d21 || test -d $DIR1/d21 && error "Removed dir still visible after umount"
521 run_test 21 " Try to remove mountpoint on another dir ===="
523 JOIN=${JOIN:-"lfs join"}
525 test_22() { # Bug 9926
527 dd if=/dev/urandom of=$DIR1/d21/128k bs=1024 count=128
528 cp -p $DIR1/d21/128k $DIR1/d21/f_head
529 for ((i=0;i<10;i++)); do
530 cp -p $DIR1/d21/128k $DIR1/d21/f_tail
531 $JOIN $DIR1/d21/f_head $DIR1/d21/f_tail || error "join error"
532 $CHECKSTAT -a $DIR1/d21/f_tail || error "tail file exist after join"
534 echo aaaaaaaaaaa >> $DIR1/d21/no_joined
536 mv $DIR2/d21/f_head $DIR2/
537 munlink $DIR2/f_head || error "unlink joined file error"
538 cat $DIR2/d21/no_joined || error "cat error"
539 rm -rf $DIR2/d21/no_joined || error "unlink normal file error"
541 run_test 22 " After joining in one dir, open/close unlink file in anther dir"
543 test_23() { # Bug 5972
544 echo "others should see updated atime while another read" > $DIR1/f23
546 # clear the lock(mode: LCK_PW) gotten from creating operation
552 multiop $DIR1/f23 or20_c &
556 time2=`stat -c "%X" $DIR2/f23`
558 if (( $time2 <= $time1 )); then
560 error "atime doesn't update among nodes"
563 kill -USR1 $MULTIPID || return 1
564 rm -f $DIR1/f23 || error "rm -f $DIR1/f23 failed"
567 run_test 23 " others should see updated atime while another read===="
571 lfs df || error "lfs df failed"
572 lfs df -ih || error "lfs df -ih failed"
573 lfs df -h $DIR1 || error "lfs df -h $DIR1 failed"
574 lfs df -i $DIR2 || error "lfs df -i $DIR2 failed"
575 lfs df $DIR1/$tfile || error "lfs df $DIR1/$tfile failed"
576 lfs df -ih $DIR2/$tfile || error "lfs df -ih $DIR2/$tfile failed"
578 OSC=`lctl dl | awk '/-osc-/ {print $4}' | head -n 1`
579 lctl --device %$OSC deactivate
580 lfs df -i || error "lfs df -i with deactivated OSC failed"
581 lctl --device %$OSC recover
582 lfs df || error "lfs df with reactivated OSC failed"
584 run_test 24 "lfs df [-ih] [path] test ========================="
587 [ `cat $LPROC/mdc/*-mdc-*/connect_flags | grep -c acl` -lt 2 ] && echo "skipping $TESTNAME (must have acl)" && return
589 mkdir $DIR1/d25 || error
590 touch $DIR1/d25/f1 || error
591 chmod 0755 $DIR1/d25/f1 || error
593 $RUNAS checkstat $DIR2/d25/f1 || error
594 setfacl -m u:$RUNAS_ID:--- $DIR1/d25 || error
595 $RUNAS checkstat $DIR2/d25/f1 && error
596 setfacl -m u:$RUNAS_ID:r-x $DIR1/d25 || error
597 $RUNAS checkstat $DIR2/d25/f1 || error
598 setfacl -m u:$RUNAS_ID:--- $DIR1/d25 || error
599 $RUNAS checkstat $DIR2/d25/f1 && error
600 setfacl -x u:$RUNAS_ID: $DIR1/d25 || error
601 $RUNAS checkstat $DIR2/d25/f1 || error
605 run_test 25 "change ACL on one mountpoint be seen on another ==="
608 utime $DIR1/f26a -s $DIR2/f26a || error
610 run_test 26a "allow mtime to get older"
615 echo "aaa" >> $DIR1/$tfile
617 chmod a+x $DIR2/$tfile
618 mt1=`stat -c %Y $DIR1/$tfile`
619 mt2=`stat -c %Y $DIR2/$tfile`
621 if [ x"$mt1" != x"$mt2" ]; then
622 error "not equal mtime, client1: "$mt1", client2: "$mt2"."
625 run_test 26b "sync mtime between ost and mds"
627 log "cleanup: ======================================================"
628 rm -rf $DIR1/[df][0-9]* $DIR1/lnk || true
629 if [ "$I_MOUNTED" = "yes" ]; then
633 echo '=========================== finished ==============================='
634 [ -f "$SANITYLOG" ] && cat $SANITYLOG && exit 1 || true