6 # bug number for skipped test: 3192 9977
7 ALWAYS_EXCEPT="14b 28 $SANITYN_EXCEPT"
8 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
10 [ "$SLOW" = "no" ] && EXCEPT="$EXCEPT 16"
12 # Tests that fail on uml
13 [ "$UML" = "true" ] && EXCEPT="$EXCEPT 7"
15 # Join file feature is not supported currently.
16 # It will be ported soon.
20 PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH
23 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
24 CREATETEST=${CREATETEST:-createtest}
25 GETSTRIPE=${GETSTRIPE:-lfs getstripe}
26 SETSTRIPE=${SETSTRIPE:-lstripe}
27 MCREATE=${MCREATE:-mcreate}
28 OPENFILE=${OPENFILE:-openfile}
29 OPENUNLINK=${OPENUNLINK:-openunlink}
30 TOEXCL=${TOEXCL:-toexcl}
31 TRUNCATE=${TRUNCATE:-truncate}
32 export TMP=${TMP:-/tmp}
33 MOUNT_2=${MOUNT_2:-"yes"}
34 CHECK_GRANT=${CHECK_GRANT:-"yes"}
35 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
37 if [ $UID -ne 0 ]; then
41 RUNAS_ID=${RUNAS_ID:-500}
42 RUNAS=${RUNAS:-"runas -u $RUNAS_ID"}
47 export NAME=${NAME:-local}
49 LUSTRE=${LUSTRE:-`dirname $0`/..}
50 . $LUSTRE/tests/test-framework.sh
54 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
56 SANITYLOG=${TESTSUITELOG:-$TMP/$(basename $0 .sh).log}
60 $RUNAS krb5_login.sh || exit 1
68 [ "$SANITYLOG" ] && rm -f $SANITYLOG || true
70 check_and_setup_lustre
73 LOVNAME=`cat $LPROC/llite/*/lov/common_name | tail -n 1`
74 OSTCOUNT=`cat $LPROC/lov/$LOVNAME/numobd`
76 rm -rf $DIR1/[df][0-9]* $DIR1/lnk
82 [ -f $DIR2/f1 ] || error
84 run_test 1a "check create on 2 mtpt's =========================="
88 $CHECKSTAT -t file -p 0777 $DIR1/f1 || error
91 run_test 1b "check attribute updates on 2 mtpt's ==============="
94 $CHECKSTAT -t file -p 0666 $DIR1/f1 || error
96 run_test 1c "check after remount attribute updates on 2 mtpt's ="
100 $CHECKSTAT -a $DIR1/f1 || error
102 run_test 1d "unlink on one mountpoint removes file on other ===="
108 $CHECKSTAT -t file -p 0777 $DIR1/f2a || error
110 run_test 2a "check cached attribute updates on 2 mtpt's ========"
116 $CHECKSTAT -t file -p 0777 $DIR2/f2b || error
118 run_test 2b "check cached attribute updates on 2 mtpt's ========"
120 # NEED TO SAVE ROOT DIR MODE
123 $CHECKSTAT -t dir -p 0777 $DIR2 || error
125 run_test 2c "check cached attribute updates on 2 mtpt's root ==="
129 $CHECKSTAT -t dir -p 0755 $DIR2 || error
131 run_test 2d "check cached attribute updates on 2 mtpt's root ==="
138 $RUNAS dd if=/dev/zero of=$DIR2/$tfile count=1 || error
140 run_test 2e "check chmod on root is propagated to others"
143 ( cd $DIR1 ; ln -s this/is/good lnk )
144 [ "this/is/good" = "`perl -e 'print readlink("'$DIR2/lnk'");'`" ] || \
147 run_test 3 "symlink on one mtpt, readlink on another ==========="
150 multifstat $DIR1/f4 $DIR2/f4
152 run_test 4 "fstat validation on multiple mount points =========="
156 truncate $DIR2/f5 100
157 $CHECKSTAT -t file -s 100 $DIR1/f5 || error
160 run_test 5 "create a file on one mount, truncate it on the other"
163 openunlink $DIR1/$tfile $DIR2/$tfile || \
164 error "openunlink $DIR1/$tfile $DIR2/$tfile"
166 run_test 6 "remove of open file on other node =================="
169 opendirunlink $DIR1/$tdir $DIR2/$tdir || \
170 error "opendirunlink $DIR1/$tdir $DIR2/$tdir"
172 run_test 7 "remove of open directory on other node ============="
175 opendevunlink $DIR1/$tfile $DIR2/$tfile || \
176 error "opendevunlink $DIR1/$tfile $DIR2/$tfile"
178 run_test 8 "remove of open special file on other node =========="
183 for C in a b c d e f g h i j k l; do
184 DIR=`eval echo \\$DIR$MTPT`
185 echo -n $C >> $DIR/f9
186 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
188 [ "`cat $DIR1/f9`" = "abcdefghijkl" ] || \
189 error "`od -a $DIR1/f9` != abcdefghijkl"
191 run_test 9 "append of file with sub-page size on multiple mounts"
197 for C in a b c d e f g h i j k l; do
198 DIR=`eval echo \\$DIR$MTPT`
199 echo -n $C | dd of=$DIR/f10 bs=1 seek=$OFFSET count=1
200 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
201 OFFSET=`expr $OFFSET + 1`
203 [ "`cat $DIR1/f10`" = "abcdefghijkl" ] || \
204 error "`od -a $DIR1/f10` != abcdefghijkl"
206 run_test 10a "write of file with sub-page size on multiple mounts "
209 yes "R" | dd of=$DIR1/f10b bs=3k count=1 || error "dd $DIR1"
211 truncate $DIR1/f10b 4096 || error "truncate 4096"
213 dd if=$DIR2/f10b of=$TMP/f10b-lustre bs=4k count=1 || error "dd $DIR2"
215 # create a test file locally to compare
216 yes "R" | dd of=$TMP/f10b bs=3k count=1 || error "dd random"
217 truncate $TMP/f10b 4096 || error "truncate 4096"
218 cmp $TMP/f10b $TMP/f10b-lustre || error "file miscompare"
219 rm $TMP/f10b $TMP/f10b-lustre
221 run_test 10b "write of file with sub-page size on multiple mounts "
225 multiop $DIR1/d11/f O_c &
228 cp -p /bin/ls $DIR1/d11/f
232 wait $MULTIPID || error
233 [ $RC -eq 0 ] && error || true
235 run_test 11 "execution of file opened for write should return error ===="
240 run_test 12 "test lock ordering (link, stat, unlink) ==========="
242 test_13() { # bug 2451 - directory coherency
244 mkdir $DIR1/d13 || error
245 cd $DIR1/d13 || error
247 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
249 rm -f $DIR2/d13/f13 || error
250 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (1)" || true
251 # need to run it twice
252 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
254 rm -f $DIR2/d13/f13 || error
255 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (2)" || true
257 run_test 13 "test directory page revocation ===================="
261 cp -p /bin/ls $DIR1/d14/ls
262 exec 100>> $DIR1/d14/ls
263 $DIR2/d14/ls && error || true
266 run_test 14 "execution of file open for write returns -ETXTBSY ="
270 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
271 $DIR1/d14/multiop $TMP/test14.junk O_c &
274 multiop $DIR2/d14/multiop Oc && error "expected error, got success"
275 kill -USR1 $MULTIPID || return 2
276 wait $MULTIPID || return 3
277 rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop"
279 run_test 14a "open(RDWR) of executing file returns -ETXTBSY ===="
281 test_14b() { # bug 3192, 7040
283 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
284 $DIR1/d14/multiop $TMP/test14.junk O_c &
287 truncate $DIR2/d14/multiop 0 && kill -9 $MULTIPID && \
288 error "expected truncate error, got success"
289 kill -USR1 $MULTIPID || return 2
290 wait $MULTIPID || return 3
291 cmp `which multiop` $DIR1/d14/multiop || error "binary changed"
292 rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop"
294 run_test 14b "truncate of executing file returns -ETXTBSY ======"
296 test_14c() { # bug 3430, 7040
298 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
299 $DIR1/d14/multiop $TMP/test14.junk O_c &
302 cp /etc/hosts $DIR2/d14/multiop && error "expected error, got success"
303 kill -USR1 $MULTIPID || return 2
304 wait $MULTIPID || return 3
305 cmp `which multiop` $DIR1/d14/multiop || error "binary changed"
306 rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop"
308 run_test 14c "open(O_TRUNC) of executing file return -ETXTBSY =="
310 test_14d() { # bug 10921
312 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
313 $DIR1/d14/multiop $TMP/test14.junk O_c &
317 chmod 600 $DIR1/d14/multiop || error "chmod failed"
318 kill -USR1 $MULTIPID || return 2
319 wait $MULTIPID || return 3
320 cmp `which multiop` $DIR1/d14/multiop || error "binary changed"
321 rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop"
323 run_test 14d "chmod of executing file is still possible ========"
325 test_15() { # bug 974 - ENOSPC
327 sh oos2.sh $MOUNT1 $MOUNT2
328 grant_error=`dmesg | grep "> available"`
329 [ -z "$grant_error" ] || error "$grant_error"
331 run_test 15 "test out-of-space with multiple writers ==========="
334 rm -f $MOUNT1/fsxfile
335 lfs setstripe $MOUNT1/fsxfile 0 -1 -1 # b=10919
336 fsx -c 50 -p 100 -N 2500 -l $((SIZE * 256)) -S 0 $MOUNT1/fsxfile $MOUNT2/fsxfile
338 run_test 16 "2500 iterations of dual-mount fsx ================="
340 test_17() { # bug 3513, 3667
341 [ ! -d /proc/fs/lustre/ost ] && skip "remote OST, skipping OST-only test" && return
343 cp /etc/termcap $DIR1/f17
344 cancel_lru_locks osc > /dev/null
345 #define OBD_FAIL_ONCE|OBD_FAIL_LDLM_CREATE_RESOURCE 0x30a
346 sysctl -w lustre.fail_loc=0x8000030a
347 ls -ls $DIR1/f17 | awk '{ print $1,$6 }' > $DIR1/f17-1 & \
348 ls -ls $DIR2/f17 | awk '{ print $1,$6 }' > $DIR2/f17-2
350 diff -u $DIR1/f17-1 $DIR2/f17-2 || error "files are different"
352 run_test 17 "resource creation/LVB creation race ==============="
355 ./mmap_sanity -d $MOUNT1 -m $MOUNT2
358 run_test 18 "mmap sanity check ================================="
360 test_19() { # bug3811
361 [ -d /proc/fs/lustre/obdfilter ] || return 0
363 MAX=`cat /proc/fs/lustre/obdfilter/*/readcache_max_filesize | head -n 1`
364 for O in /proc/fs/lustre/obdfilter/*OST*; do
365 echo 4096 > $O/readcache_max_filesize
367 dd if=/dev/urandom of=$TMP/f19b bs=512k count=32
368 SUM=`cksum $TMP/f19b | cut -d" " -f 1,2`
369 cp $TMP/f19b $DIR1/f19b
370 for i in `seq 1 20`; do
371 [ $((i % 5)) -eq 0 ] && log "test_18 loop $i"
372 cancel_lru_locks osc > /dev/null
373 cksum $DIR1/f19b | cut -d" " -f 1,2 > $TMP/sum1 & \
374 cksum $DIR2/f19b | cut -d" " -f 1,2 > $TMP/sum2
376 [ "`cat $TMP/sum1`" = "$SUM" ] || \
377 error "$DIR1/f19b `cat $TMP/sum1` != $SUM"
378 [ "`cat $TMP/sum2`" = "$SUM" ] || \
379 error "$DIR2/f19b `cat $TMP/sum2` != $SUM"
381 for O in /proc/fs/lustre/obdfilter/*OST*; do
382 echo $MAX > $O/readcache_max_filesize
386 #run_test 19 "test concurrent uncached read races ==============="
391 CNT=$((`cat /proc/fs/lustre/llite/*/dump_page_cache | wc -l`))
392 multiop $DIR1/f20 Ow8190c
393 multiop $DIR2/f20 Oz8194w8190c
394 multiop $DIR1/f20 Oz0r8190c
396 CNTD=$((`cat /proc/fs/lustre/llite/*/dump_page_cache | wc -l` - $CNT))
398 error $CNTD" page left in cache after lock cancel" || true
400 run_test 20 "test extra readahead page left in cache ===="
407 test_21() { # Bug 5907
409 mount /etc $DIR1/d21 --bind || error "mount failed" # Poor man's mount.
411 rmdir -v $DIR1/d21 && error "Removed mounted directory"
412 rmdir -v $DIR2/d21 && echo "Removed mounted directory from another mountpoint, needs to be fixed"
413 test -d $DIR1/d21 || error "Mounted directory disappeared"
415 test -d $DIR2/d21 || test -d $DIR1/d21 && error "Removed dir still visible after umount"
418 run_test 21 " Try to remove mountpoint on another dir ===="
420 JOIN=${JOIN:-"lfs join"}
422 test_22() { # Bug 9926
424 dd if=/dev/urandom of=$DIR1/d21/128k bs=1024 count=128
425 cp -p $DIR1/d21/128k $DIR1/d21/f_head
426 for ((i=0;i<10;i++)); do
427 cp -p $DIR1/d21/128k $DIR1/d21/f_tail
428 $JOIN $DIR1/d21/f_head $DIR1/d21/f_tail || error "join error"
429 $CHECKSTAT -a $DIR1/d21/f_tail || error "tail file exist after join"
431 echo aaaaaaaaaaa >> $DIR1/d21/no_joined
433 mv $DIR2/d21/f_head $DIR2/
434 munlink $DIR2/f_head || error "unlink joined file error"
435 cat $DIR2/d21/no_joined || error "cat error"
436 rm -rf $DIR2/d21/no_joined || error "unlink normal file error"
438 run_test 22 " After joining in one dir, open/close unlink file in anther dir"
440 test_23() { # Bug 5972
441 echo "others should see updated atime while another read" > $DIR1/f23
443 # clear the lock(mode: LCK_PW) gotten from creating operation
449 multiop $DIR1/f23 or20_c &
453 time2=`stat -c "%X" $DIR2/f23`
455 if (( $time2 <= $time1 )); then
457 error "atime doesn't update among nodes"
460 kill -USR1 $MULTIPID || return 1
461 rm -f $DIR1/f23 || error "rm -f $DIR1/f23 failed"
464 run_test 23 " others should see updated atime while another read===="
468 lfs df || error "lfs df failed"
469 lfs df -ih || error "lfs df -ih failed"
470 lfs df -h $DIR1 || error "lfs df -h $DIR1 failed"
471 lfs df -i $DIR2 || error "lfs df -i $DIR2 failed"
472 lfs df $DIR1/$tfile || error "lfs df $DIR1/$tfile failed"
473 lfs df -ih $DIR2/$tfile || error "lfs df -ih $DIR2/$tfile failed"
475 OSC=`lctl dl | awk '/-osc-|OSC.*MNT/ {print $4}' | head -n 1`
476 # OSC=`lctl dl | awk '/-osc-/ {print $4}' | head -n 1`
477 lctl --device %$OSC deactivate
478 lfs df -i || error "lfs df -i with deactivated OSC failed"
479 lctl --device %$OSC recover
480 lfs df || error "lfs df with reactivated OSC failed"
482 run_test 24 "lfs df [-ih] [path] test ========================="
485 [ `cat $LPROC/mdc/*-mdc-*/connect_flags | grep -c acl` -lt 2 ] && \
486 skip "must have acl, skipping" && return
488 mkdir $DIR1/$tdir || error "mkdir $DIR1/$tdir"
489 touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
490 chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
492 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
493 setfacl -m u:$RUNAS_ID:--- $DIR1/$tdir || error "setfacl $DIR2/$tdir #1"
494 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
495 setfacl -m u:$RUNAS_ID:r-x $DIR1/$tdir || error "setfacl $DIR2/$tdir #2"
496 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
497 setfacl -m u:$RUNAS_ID:--- $DIR1/$tdir || error "setfacl $DIR2/$tdir #3"
498 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
499 setfacl -x u:$RUNAS_ID: $DIR1/$tdir || error "setfacl $DIR2/$tdir #4"
500 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
504 run_test 25 "change ACL on one mountpoint be seen on another ==="
507 utime $DIR1/f26a -s $DIR2/f26a || error
509 run_test 26a "allow mtime to get older"
514 echo "aaa" >> $DIR1/$tfile
516 chmod a+x $DIR2/$tfile
517 mt1=`stat -c %Y $DIR1/$tfile`
518 mt2=`stat -c %Y $DIR2/$tfile`
520 if [ x"$mt1" != x"$mt2" ]; then
521 error "not equal mtime, client1: "$mt1", client2: "$mt2"."
524 run_test 26b "sync mtime between ost and mds"
529 dd if=/dev/zero of=$DIR2/$tfile bs=$((4096+4))k conv=notrunc count=4 seek=3 &
534 dd if=/dev/zero of=$DIR1/$tfile bs=$((16384-1024))k conv=notrunc count=1 seek=4 &
539 dd if=/dev/zero of=$DIR1/$tfile bs=8k conv=notrunc count=1 seek=0
541 echo > $LPROC/ldlm/dump_namespaces
542 wait $DD1_PID $DD2_PID
543 [ $? -ne 0 ] && lctl dk $TMP/debug || true
545 run_test 27 "align non-overlapping extent locks from request ==="
547 test_28() { # bug 9977
548 ECHO_UUID="ECHO_osc1_UUID"
549 tOST=`$LCTL dl | | awk '/-osc-|OSC.*MNT/ { print $4 }' | head -1`
551 lfs setstripe $DIR1/$tfile 1048576 0 2
552 tOBJID=`lfs getstripe $DIR1/$tfile |grep "^[[:space:]]\+1" |awk '{print $2}'`
553 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2
557 attach echo_client ECHO_osc1 $ECHO_UUID
561 tECHOID=`$LCTL dl | grep $ECHO_UUID | awk '{print $1}'`
562 $LCTL --device $tECHOID destroy "${tOBJID}:0"
570 # reading of 1st stripe should pass
571 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error
572 # reading of 2nd stripe should fail (this stripe was destroyed)
573 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 && error
575 # now, recreating test file
576 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2 || error
577 # reading of 1st stripe should pass
578 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error
579 # reading of 2nd stripe should pass
580 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 || error
582 run_test 28 "read/write/truncate file with lost stripes"
584 test_29() { # bug 10999
586 #define OBD_FAIL_LDLM_GLIMPSE 0x30f
587 sysctl -w lustre.fail_loc=0x8000030f
590 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1
593 #bug 11549 - permanently turn test off in b1_5
594 #run_test 29 "lock put race between glimpse and enqueue ========="
596 test_30() { #bug #11110
599 cp -f /bin/bash $DIR1/$tdir/bash
600 /bin/sh -c 'sleep 1; rm -f $DIR2/$tdir/bash; cp /bin/bash $DIR2/$tdir' &
601 err=$($DIR1/$tdir/bash -c 'sleep 2; openfile -f O_RDONLY /proc/$$/exe >& /dev/null; echo $?')
603 [ $err -ne 116 ] && error "return code ($err) != -ESTALE" && return
607 run_test 30 "recreate file race ========="
609 log "cleanup: ======================================================"
611 check_and_cleanup_lustre
613 echo '=========================== finished ==============================='
614 [ -f "$SANITYLOG" ] && cat $SANITYLOG && grep -q FAIL $SANITYLOG && exit 1 || true