3 # Run select tests by setting ONLY, or as arguments to the script.
4 # Skip specific tests by setting EXCEPT.
6 # e.g. ONLY="22 23" or ONLY="`seq 32 39`" or EXCEPT="31"
10 # bug number for skipped test:
11 ALWAYS_EXCEPT=${ALWAYS_EXCEPT:-""}
12 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
14 [ "$ALWAYS_EXCEPT$EXCEPT" ] && echo "Skipping tests: $ALWAYS_EXCEPT $EXCEPT"
17 export PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH
21 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
22 CREATETEST=${CREATETEST:-createtest}
24 LSTRIPE=${LSTRIPE:-"$LFS setstripe"}
25 LFIND=${LFIND:-"$LFS find"}
26 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
28 MCREATE=${MCREATE:-mcreate}
29 OPENFILE=${OPENFILE:-openfile}
30 OPENUNLINK=${OPENUNLINK:-openunlink}
31 TOEXCL=${TOEXCL:-toexcl}
32 TRUNCATE=${TRUNCATE:-truncate}
33 MUNLINK=${MUNLINK:-munlink}
34 SOCKETSERVER=${SOCKETSERVER:-socketserver}
35 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
36 IOPENTEST1=${IOPENTEST1:-iopentest1}
37 IOPENTEST2=${IOPENTEST2:-iopentest2}
39 if [ $UID -ne 0 ]; then
43 RUNAS_ID=${RUNAS_ID:-500}
44 RUNAS=${RUNAS:-"runas -u $RUNAS_ID"}
47 export NAME=${NAME:-local}
53 sh llmountcleanup.sh > /dev/null || exit 20
60 sh llrmount.sh > /dev/null || exit 10
68 lctl mark "$*" 2> /dev/null || true
72 if ! mount | grep -q $DIR; then
76 export TESTNAME=test_$1
77 test_$1 || error "test_$1: exit with rc=$?"
88 for E in $EXCEPT $ALWAYS_EXCEPT; do
98 IFS=abcdefghijklmnopqrstuvwxyz _basetest $1
105 if [ ${!testname}x != x ]; then
110 if [ ${!testname}x != x ]; then
118 if [ ${!testname}x != x ]; then
119 echo "skipping excluded test $1"
122 testname=EXCEPT_$base
123 if [ ${!testname}x != x ]; then
124 echo "skipping excluded test $1 (base $base)"
131 [ "$SANITYLOG" ] && rm -f $SANITYLOG || true
135 if [ "$SANITYLOG" ]; then
136 echo "FAIL: $TESTNAME $@" >> $SANITYLOG
146 MOUNT="`mount | awk '/^'$NAME' .* lustre_lite / { print $3 }'`"
147 if [ -z "$MOUNT" ]; then
149 MOUNT="`mount | awk '/^'$NAME' .* lustre_lite / { print $3 }'`"
150 [ -z "$MOUNT" ] && error "NAME=$NAME not mounted"
154 [ `echo $MOUNT | wc -w` -gt 1 ] && error "NAME=$NAME mounted more than once"
157 [ -z "`echo $DIR | grep $MOUNT`" ] && echo "$DIR not in $MOUNT" && exit 99
159 LOVNAME=`cat /proc/fs/lustre/llite/fs0/lov/common_name`
160 OSTCOUNT=`cat /proc/fs/lustre/lov/$LOVNAME/numobd`
161 STRIPECOUNT=`cat /proc/fs/lustre/lov/$LOVNAME/stripecount`
162 STRIPESIZE=`cat /proc/fs/lustre/lov/$LOVNAME/stripesize`
164 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
165 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
166 rm -rf $DIR/[Rdfs][1-9]*
170 echo preparing for tests involving mounts
171 EXT2_DEV=${EXT2_DEV:-/tmp/SANITY.LOOP}
173 mke2fs -F $EXT2_DEV 1000 > /dev/null
175 EXT3_DEV=${EXT3_DEV:-/tmp/SANITY_EXT3_DEV.LOOP}
177 mkfs.ext3 -F $EXT3_DEV 10000 > /dev/null
181 $CHECKSTAT -t file $DIR/f || error
183 $CHECKSTAT -a $DIR/f || error
185 run_test 0 "touch .../f ; rm .../f ============================="
190 $CHECKSTAT -t dir $DIR/d1/d2 || error
192 run_test 1a "mkdir .../d1; mkdir .../d1/d2 ====================="
197 $CHECKSTAT -a $DIR/d1 || error
199 run_test 1b "rmdir .../d1/d2; rmdir .../d1 ====================="
204 $CHECKSTAT -t file $DIR/d2/f || error
206 run_test 2a "mkdir .../d2; touch .../d2/f ======================"
210 $CHECKSTAT -a $DIR/d2 || error
212 run_test 2b "rm -r .../d2; checkstat .../d2/f ======================"
216 $CHECKSTAT -t dir $DIR/d3 || error
218 run_test 3a "mkdir .../d3 ======================================"
221 if [ ! -d $DIR/d3 ]; then
225 $CHECKSTAT -t file $DIR/d3/f || error
227 run_test 3b "touch .../d3/f ===================================="
231 $CHECKSTAT -a $DIR/d3 || error
233 run_test 3c "rm -r .../d3 ======================================"
237 $CHECKSTAT -t dir $DIR/d4 || error
239 run_test 4a "mkdir .../d4 ======================================"
242 if [ ! -d $DIR/d4 ]; then
246 $CHECKSTAT -t dir $DIR/d4/d2 || error
248 run_test 4b "mkdir .../d4/d2 ==================================="
253 chmod 0707 $DIR/d5/d2
254 $CHECKSTAT -t dir -p 0707 $DIR/d5/d2 || error
256 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2 ============"
260 chmod 0666 $DIR/f6a || error
261 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/f6a || error
263 run_test 6a "touch .../f6a; chmod .../f6a ======================"
266 [ $RUNAS_ID -eq $UID ] && echo "skipping test 6b" && return
267 if [ ! -f $DIR/f6a ]; then
271 $RUNAS chmod 0444 $DIR/f6a && error
272 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/f6a || error
274 run_test 6b "$RUNAS chmod .../f6a (should return error) =="
277 [ $RUNAS_ID -eq $UID ] && echo "skipping test 6c" && return
279 chown $RUNAS_ID $DIR/f6c || error
280 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/f6c || error
282 run_test 6c "touch .../f6c; chown .../f6c ======================"
285 [ $RUNAS_ID -eq $UID ] && echo "skipping test 6d" && return
286 if [ ! -f $DIR/f6c ]; then
288 chown $RUNAS_ID $DIR/f6c
290 $RUNAS chown $UID $DIR/f6c && error
291 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/f6c || error
293 run_test 6d "$RUNAS chown .../f6c (should return error) =="
296 [ $RUNAS_ID -eq $UID ] && echo "skipping test 6e" && return
298 chgrp $RUNAS_ID $DIR/f6e || error
299 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/f6e || error
301 run_test 6e "touch .../f6e; chgrp .../f6e ======================"
304 [ $RUNAS_ID -eq $UID ] && echo "skipping test 6f" && return
305 if [ ! -f $DIR/f6e ]; then
307 chgrp $RUNAS_ID $DIR/f6e
309 $RUNAS chgrp $UID $DIR/f6e && error
310 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/f6e || error
312 run_test 6f "$RUNAS chgrp .../f6e (should return error) =="
315 [ $RUNAS_ID -eq $UID ] && echo "skipping test 6g" && return
316 mkdir $DIR/d6g || error
317 chmod 777 $DIR/d6g || error
318 $RUNAS mkdir $DIR/d6g/d || error
319 chmod g+s $DIR/d6g/d || error
320 mkdir $DIR/d6g/d/subdir
321 $CHECKSTAT -g \#$RUNAS_ID $DIR/d6g/d/subdir || error
323 run_test 6g "Is new dir in sgid dir inheriting group?"
329 $CHECKSTAT -t file -p 0666 $DIR/d7/f || error
331 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
334 if [ ! -d $DIR/d7 ]; then
338 echo -n foo > $DIR/d7/f2
339 [ "`cat $DIR/d7/f2`" = "foo" ] || error
340 $CHECKSTAT -t file -s 3 $DIR/d7/f2 || error
342 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
348 $CHECKSTAT -t file -p 0666 $DIR/d8/f || error
350 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
356 $CHECKSTAT -t dir $DIR/d9/d2/d3 || error
358 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
364 $CHECKSTAT -t file $DIR/d10/d2/f || error
366 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
371 chmod 0666 $DIR/d11/d2
372 chmod 0705 $DIR/d11/d2
373 $CHECKSTAT -t dir -p 0705 $DIR/d11/d2 || error
375 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
380 chmod 0666 $DIR/d12/f
381 chmod 0654 $DIR/d12/f
382 $CHECKSTAT -t file -p 0654 $DIR/d12/f || error
384 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
388 dd if=/dev/zero of=$DIR/d13/f count=10
390 $CHECKSTAT -t file -s 0 $DIR/d13/f || error
392 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
398 $CHECKSTAT -a $DIR/d14/f || error
400 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
405 mv $DIR/d15/f $DIR/d15/f2
406 $CHECKSTAT -t file $DIR/d15/f2 || error
408 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
414 $CHECKSTAT -a $DIR/d16/f || error
416 run_test 16 "touch .../d16/f; rm -rf .../d16/f ================="
421 ln -s $DIR/d17/f $DIR/d17/l-exist
423 $CHECKSTAT -l $DIR/d17/f $DIR/d17/l-exist || error
424 $CHECKSTAT -f -t f $DIR/d17/l-exist || error
426 $CHECKSTAT -a $DIR/l-exist || error
428 run_test 17a "symlinks: create, remove (real) =================="
431 if [ ! -d $DIR/d17 ]; then
434 ln -s no-such-file $DIR/d17/l-dangle
436 $CHECKSTAT -l no-such-file $DIR/d17/l-dangle || error
437 $CHECKSTAT -fa $DIR/d17/l-dangle || error
439 $CHECKSTAT -a $DIR/l-dangle || error
441 run_test 17b "symlinks: create, remove (dangling) =============="
447 run_test 18 "touch .../f ; ls ... =============================="
453 $CHECKSTAT -a $DIR/f19 || error
455 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
458 ls -l $DIR/f19 && error || true
460 run_test 19b "ls -l .../f19 (should return error) =============="
463 [ $RUNAS_ID -eq $UID ] && echo "skipping test 19c" && return
464 $RUNAS touch $DIR/f19 && error || true
466 run_test 19c "$RUNAS touch .../f19 (should return error) =="
469 cat $DIR/f19 && error || true
471 run_test 19d "cat .../f19 (should return error) =============="
483 $CHECKSTAT -a $DIR/f || error
485 run_test 20 "touch .../f ; ls -l ... ==========================="
489 [ -f $DIR/d21/dangle ] && rm -f $DIR/d21/dangle
490 ln -s dangle $DIR/d21/link
491 echo foo >> $DIR/d21/link
493 $CHECKSTAT -t link $DIR/d21/link || error
494 $CHECKSTAT -f -t file $DIR/d21/link || error
496 run_test 21 "write to dangling link ============================"
500 chown $RUNAS_ID $DIR/d22
501 # Tar gets pissy if it can't access $PWD *sigh*
503 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
504 $RUNAS tar xfC - $DIR/d22)
506 $CHECKSTAT -t dir $DIR/d22/etc || error
507 $CHECKSTAT -u \#$RUNAS_ID $DIR/d22/etc || error
509 run_test 22 "unpack tar archive as non-root user ==============="
514 $TOEXCL -e $DIR/d23/f23 || error
516 run_test 23 "O_CREAT|O_EXCL in subdir =========================="
519 echo '== rename sanity =============================================='
520 echo '-- same directory rename'
523 mv $DIR/R1/f $DIR/R1/g
524 $CHECKSTAT -t file $DIR/R1/g || error
526 run_test 24a "touch .../R1/f; rename .../R1/f .../R1/g ========="
531 mv $DIR/R2/f $DIR/R2/g
532 $CHECKSTAT -a $DIR/R2/f || error
533 $CHECKSTAT -t file $DIR/R2/g || error
535 run_test 24b "touch .../R2/{f,g}; rename .../R2/f .../R2/g ====="
540 mv $DIR/R3/f $DIR/R3/g
541 $CHECKSTAT -a $DIR/R3/f || error
542 $CHECKSTAT -t dir $DIR/R3/g || error
544 run_test 24c "mkdir .../R3/f; rename .../R3/f .../R3/g ========="
549 perl -e "rename \"$DIR/R4/f\", \"$DIR/R4/g\";"
550 $CHECKSTAT -a $DIR/R4/f || error
551 $CHECKSTAT -t dir $DIR/R4/g || error
553 run_test 24d "mkdir .../R4/{f,g}; rename .../R4/f .../R4/g ====="
556 echo '-- cross directory renames --'
559 mv $DIR/R5a/f $DIR/R5b/g
560 $CHECKSTAT -a $DIR/R5a/f || error
561 $CHECKSTAT -t file $DIR/R5b/g || error
563 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
567 touch $DIR/R6a/f $DIR/R6b/g
568 mv $DIR/R6a/f $DIR/R6b/g
569 $CHECKSTAT -a $DIR/R6a/f || error
570 $CHECKSTAT -t file $DIR/R6b/g || error
572 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
577 mv $DIR/R7a/d $DIR/R7b/e
578 $CHECKSTAT -a $DIR/R7a/d || error
579 $CHECKSTAT -t dir $DIR/R7b/e || error
581 run_test 24g "mkdir .../R7a/d; rename .../R7a/d .../R5b/e ======"
585 mkdir $DIR/R8a/d $DIR/R8b/e
586 perl -e "rename \"$DIR/R8a/d\", \"$DIR/R8b/e\";"
587 $CHECKSTAT -a $DIR/R8a/d || error
588 $CHECKSTAT -t dir $DIR/R8b/e || error
590 run_test 24h "mkdir .../R8{a,b} R8a/{d,e}; mv .../R8a/d .../R8b/e"
593 echo "-- rename error cases"
597 perl -e "rename \"$DIR/R9/f\", \"$DIR/R9/a\";"
598 $CHECKSTAT -t file $DIR/R9/f || error
599 $CHECKSTAT -t dir $DIR/R9/a || error
600 $CHECKSTAT -a file $DIR/R9/a/f || error
602 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
606 perl -e "rename \"$DIR/R10/f\", \"$DIR/R10/g\""
607 $CHECKSTAT -t dir $DIR/R10 || error
608 $CHECKSTAT -a $DIR/R10/f || error
609 $CHECKSTAT -a $DIR/R10/g || error
611 run_test 24j "source does not exist ============================"
614 mkdir $DIR/R11a $DIR/R11a/d
616 mv $DIR/R11a/f $DIR/R11a/d
617 $CHECKSTAT -a $DIR/R11a/f || error
618 $CHECKSTAT -t file $DIR/R11a/d/f || error
620 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
622 # bug 2429 - rename foo foo foo creates invalid file
625 multiop $f OcNs || error
627 run_test 24l "Renaming a file to itself ========================"
631 multiop $f OcLN ${f}2 ${f}2 || error
633 run_test 24m "Renaming a file to a hard link to itself ========="
637 # this stats the old file after it was renamed, so it should fail
641 $CHECKSTAT ${f}.rename
644 run_test 24n "Statting the old file after renameing (Posix rename 2)"
647 echo '== symlink sanity ============================================='
650 touch $DIR/s25/foo || error
652 run_test 25a "create file in symlinked directory ==============="
655 [ ! -d $DIR/d25 ] && test_25a
656 $CHECKSTAT -t file $DIR/s25/foo || error
658 run_test 25b "lookup file in symlinked directory ==============="
663 ln -s d26/d26-2 $DIR/s26
664 touch $DIR/s26/foo || error
666 run_test 26a "multiple component symlink ======================="
669 mkdir -p $DIR/d26b/d26-2
670 ln -s d26b/d26-2/foo $DIR/s26-2
671 touch $DIR/s26-2 || error
673 run_test 26b "multiple component symlink at end of lookup ======"
678 ln -s d26.2 $DIR/s26.2-1
679 ln -s s26.2-1 $DIR/s26.2-2
680 ln -s s26.2-2 $DIR/s26.2-3
681 chmod 0666 $DIR/s26.2-3/foo
683 run_test 26c "chain of symlinks ================================"
685 # recursive symlinks (bug 439)
687 ln -s d26-3/foo $DIR/d26-3
689 run_test 26d "create multiple component recursive symlink ======"
692 [ ! -h $DIR/d26-3 ] && test_26d
695 run_test 26e "unlink multiple component recursive symlink ======"
698 echo '== stripe sanity =============================================='
700 $LSTRIPE $DIR/d27/f0 65536 0 1 || error
701 $CHECKSTAT -t file $DIR/d27/f0 || error
703 log "== test_27b: write to one stripe file ========================="
704 cp /etc/hosts $DIR/d27/f0 || error
706 run_test 27a "one stripe file =================================="
709 [ "$OSTCOUNT" -lt "2" ] && echo "skipping 2-stripe test" && return
710 if [ ! -d $DIR/d27 ]; then
713 $LSTRIPE $DIR/d27/f01 65536 0 2 || error
714 [ `$LFIND $DIR/d27/f01 | grep -A 10 obdidx | wc -l` -eq 4 ] ||
715 error "two-stripe file doesn't have two stripes"
717 log "== test_27d: write to two stripe file file f01 ================"
718 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error
720 run_test 27c "create two stripe file f01 ======================="
723 if [ ! -d $DIR/d27 ]; then
726 $LSTRIPE $DIR/d27/fdef 0 -1 0 || error
727 $CHECKSTAT -t file $DIR/d27/fdef || error
728 #dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
730 run_test 27d "create file with default settings ================"
733 if [ ! -d $DIR/d27 ]; then
736 $LSTRIPE $DIR/d27/f12 65536 0 2 || error
737 $LSTRIPE $DIR/d27/f12 65536 0 2 && error
738 $CHECKSTAT -t file $DIR/d27/f12 || error
740 run_test 27e "lstripe existing file (should return error) ======"
743 if [ ! -d $DIR/d27 ]; then
746 $LSTRIPE $DIR/d27/fbad 100 0 1 && error
747 dd if=/dev/zero of=$DIR/d27/f12 bs=4k count=4 || error
748 $LFIND $DIR/d27/fbad || error
750 run_test 27f "lstripe with bad stripe size (should return error)"
753 if [ ! -d $DIR/d27 ]; then
756 $MCREATE $DIR/d27/fnone || error
758 log "== test 27h: lfind with no objects ============================"
759 $LFIND $DIR/d27/fnone 2>&1 | grep "no stripe info" || error
761 log "== test 27i: lfind with some objects =========================="
762 touch $DIR/d27/fsome || error
763 $LFIND $DIR/d27/fsome | grep obdidx || error
765 run_test 27g "test lfind ======================================="
768 if [ ! -d $DIR/d27 ]; then
771 $LSTRIPE $DIR/d27/f27j 65536 $OSTCOUNT 1 && error || true
773 run_test 27j "lstripe with bad stripe offset (should return error)"
775 test_27k() { # bug 2844
777 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
778 [ ! -d $DIR/d27 ] && mkdir -p $DIR/d27
779 $LSTRIPE $FILE 67108864 -1 0 || error "lstripe failed"
780 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
781 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
782 dd if=/dev/zero of=$FILE bs=4k count=1
783 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
784 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
786 run_test 27k "limit i_blksize for broken user apps ============="
789 mcreate $DIR/f27l || error "creating file"
790 $RUNAS $LSTRIPE $DIR/f27l 65536 -1 1 && \
791 error "lstripe should have failed" || true
793 run_test 27l "check setstripe permissions (should return error)"
797 $CREATETEST $DIR/d28/ct || error
799 run_test 28 "create/mknod/mkdir with bad file types ============"
802 for d in /proc/fs/lustre/ldlm/namespaces/$1*; do
803 echo clear > $d/lru_size
805 grep [0-9] /proc/fs/lustre/ldlm/namespaces/$1*/lock_unused_count /dev/null
814 MDCDIR=${MDCDIR:-/proc/fs/lustre/ldlm/namespaces/MDC_*}
815 LOCKCOUNTORIG=`cat $MDCDIR/lock_count`
816 LOCKUNUSEDCOUNTORIG=`cat $MDCDIR/lock_unused_count`
820 LOCKCOUNTCURRENT=`cat $MDCDIR/lock_count`
821 LOCKUNUSEDCOUNTCURRENT=`cat $MDCDIR/lock_unused_count`
822 if [ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]; then
823 echo "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
826 if [ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]; then
827 echo "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
831 run_test 29 "IT_GETATTR regression ============================"
838 run_test 30 "run binary from Lustre (execve) ==================="
841 $OPENUNLINK $DIR/f31 $DIR/f31 || error
842 $CHECKSTAT -a $DIR/f31 || error
844 run_test 31a "open-unlink file =================================="
847 touch $DIR/f31 || error
848 ln $DIR/f31 $DIR/f31b || error
849 multiop $DIR/f31b Ouc || error
850 $CHECKSTAT -t file $DIR/f31 || error
852 run_test 31b "unlink file with multiple links while open ======="
855 touch $DIR/f31 || error
856 ln $DIR/f31 $DIR/f31c || error
857 multiop $DIR/f31 O_uc &
859 multiop $DIR/f31c Ouc
864 run_test 31c "open-unlink file with multiple links ============="
867 opendirunlink $DIR/d31d $DIR/d31d || error
868 $CHECKSTAT -a $DIR/d31d || error
870 run_test 31d "remove of open directory ========================="
873 echo "== more mountpoints and symlinks ================="
874 [ -e $DIR/d32a ] && rm -fr $DIR/d32a
875 mkdir -p $DIR/d32a/ext2-mountpoint
876 mount -t ext2 -o loop $EXT2_DEV $DIR/d32a/ext2-mountpoint || error
877 $CHECKSTAT -t dir $DIR/d32a/ext2-mountpoint/.. || error
878 umount $DIR/d32a/ext2-mountpoint || error
880 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
883 [ -e $DIR/d32b ] && rm -fr $DIR/d32b
884 mkdir -p $DIR/d32b/ext2-mountpoint
885 mount -t ext2 -o loop $EXT2_DEV $DIR/d32b/ext2-mountpoint || error
886 ls -al $DIR/d32b/ext2-mountpoint/.. || error
887 umount $DIR/d32b/ext2-mountpoint || error
889 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
892 [ -e $DIR/d32c ] && rm -fr $DIR/d32c
893 mkdir -p $DIR/d32c/ext2-mountpoint
894 mount -t ext2 -o loop $EXT2_DEV $DIR/d32c/ext2-mountpoint || error
895 mkdir -p $DIR/d32c/d2/test_dir
896 $CHECKSTAT -t dir $DIR/d32c/ext2-mountpoint/../d2/test_dir || error
897 umount $DIR/d32c/ext2-mountpoint || error
899 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
902 [ -e $DIR/d32d ] && rm -fr $DIR/d32d
903 mkdir -p $DIR/d32d/ext2-mountpoint
904 mount -t ext2 -o loop $EXT2_DEV $DIR/d32d/ext2-mountpoint || error
905 mkdir -p $DIR/d32d/d2/test_dir
906 ls -al $DIR/d32d/ext2-mountpoint/../d2/test_dir || error
907 umount $DIR/d32d/ext2-mountpoint || error
909 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
912 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
913 mkdir -p $DIR/d32e/tmp
914 TMP_DIR=$DIR/d32e/tmp
915 ln -s $DIR/d32e $TMP_DIR/symlink11
916 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
917 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
918 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
920 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
923 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
924 mkdir -p $DIR/d32f/tmp
925 TMP_DIR=$DIR/d32f/tmp
926 ln -s $DIR/d32f $TMP_DIR/symlink11
927 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
928 ls $DIR/d32f/tmp/symlink11 || error
929 ls $DIR/d32f/symlink01 || error
931 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
934 [ -e $DIR/d32g ] && rm -fr $DIR/d32g
935 [ -e $DIR/test_dir ] && rm -fr $DIR/test_dir
936 mkdir -p $DIR/test_dir
937 mkdir -p $DIR/d32g/tmp
938 TMP_DIR=$DIR/d32g/tmp
939 ln -s $DIR/test_dir $TMP_DIR/symlink12
940 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
941 $CHECKSTAT -t link $DIR/d32g/tmp/symlink12 || error
942 $CHECKSTAT -t link $DIR/d32g/symlink02 || error
943 $CHECKSTAT -t dir -f $DIR/d32g/tmp/symlink12 || error
944 $CHECKSTAT -t dir -f $DIR/d32g/symlink02 || error
946 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/test_dir"
949 [ -e $DIR/d32h ] && rm -fr $DIR/d32h
950 [ -e $DIR/test_dir ] && rm -fr $DIR/test_dir
951 mkdir -p $DIR/test_dir
952 mkdir -p $DIR/d32h/tmp
953 TMP_DIR=$DIR/d32h/tmp
954 ln -s $DIR/test_dir $TMP_DIR/symlink12
955 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
956 ls $DIR/d32h/tmp/symlink12 || error
957 ls $DIR/d32h/symlink02 || error
959 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/test_dir"
962 [ -e $DIR/d32i ] && rm -fr $DIR/d32i
963 mkdir -p $DIR/d32i/ext2-mountpoint
964 mount -t ext2 -o loop $EXT2_DEV $DIR/d32i/ext2-mountpoint || error
965 touch $DIR/d32i/test_file
966 $CHECKSTAT -t file $DIR/d32i/ext2-mountpoint/../test_file || error
967 umount $DIR/d32i/ext2-mountpoint || error
969 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
972 [ -e $DIR/d32j ] && rm -fr $DIR/d32j
973 mkdir -p $DIR/d32j/ext2-mountpoint
974 mount -t ext2 -o loop $EXT2_DEV $DIR/d32j/ext2-mountpoint || error
975 touch $DIR/d32j/test_file
976 cat $DIR/d32j/ext2-mountpoint/../test_file || error
977 umount $DIR/d32j/ext2-mountpoint || error
979 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
983 mkdir -p $DIR/d32k/ext2-mountpoint
984 mount -t ext2 -o loop $EXT2_DEV $DIR/d32k/ext2-mountpoint
985 mkdir -p $DIR/d32k/d2
986 touch $DIR/d32k/d2/test_file || error
987 $CHECKSTAT -t file $DIR/d32k/ext2-mountpoint/../d2/test_file || error
988 umount $DIR/d32k/ext2-mountpoint || error
990 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
994 mkdir -p $DIR/d32l/ext2-mountpoint
995 mount -t ext2 -o loop $EXT2_DEV $DIR/d32l/ext2-mountpoint || error
996 mkdir -p $DIR/d32l/d2
997 touch $DIR/d32l/d2/test_file
998 cat $DIR/d32l/ext2-mountpoint/../d2/test_file || error
999 umount $DIR/d32l/ext2-mountpoint || error
1001 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
1005 mkdir -p $DIR/d32m/tmp
1006 TMP_DIR=$DIR/d32m/tmp
1007 ln -s $DIR $TMP_DIR/symlink11
1008 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1009 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
1010 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
1012 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
1016 mkdir -p $DIR/d32n/tmp
1017 TMP_DIR=$DIR/d32n/tmp
1018 ln -s $DIR $TMP_DIR/symlink11
1019 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1020 ls -l $DIR/d32n/tmp/symlink11 || error
1021 ls -l $DIR/d32n/symlink01 || error
1023 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
1027 rm -f $DIR/test_file
1028 touch $DIR/test_file
1029 mkdir -p $DIR/d32o/tmp
1030 TMP_DIR=$DIR/d32o/tmp
1031 ln -s $DIR/test_file $TMP_DIR/symlink12
1032 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1033 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
1034 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
1035 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
1036 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
1038 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/test_file"
1044 rm -f $DIR/test_file
1046 touch $DIR/test_file
1048 mkdir -p $DIR/d32p/tmp
1050 TMP_DIR=$DIR/d32p/tmp
1052 ln -s $DIR/test_file $TMP_DIR/symlink12
1054 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1056 cat $DIR/d32p/tmp/symlink12 || error
1058 cat $DIR/d32p/symlink02 || error
1061 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/test_file"
1064 [ -e $DIR/d32q ] && rm -fr $DIR/d32q
1066 touch $DIR/d32q/under_the_mount
1067 mount -t ext2 -o loop $EXT2_DEV $DIR/d32q
1068 ls $DIR/d32q/under_the_mount && error || true
1069 umount $DIR/d32q || error
1071 run_test 32q "stat follows mountpoints in Lustre (should return error)"
1074 [ -e $DIR/d32r ] && rm -fr $DIR/d32r
1076 touch $DIR/d32r/under_the_mount
1077 mount -t ext2 -o loop $EXT2_DEV $DIR/d32r
1078 ls $DIR/d32r | grep -q under_the_mount && error || true
1079 umount $DIR/d32r || error
1081 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
1083 # chmod 444 /mnt/lustre/somefile
1084 # open(/mnt/lustre/somefile, O_RDWR)
1087 rm -f $DIR/test_33_file
1088 touch $DIR/test_33_file
1089 chmod 444 $DIR/test_33_file
1090 chown $RUNAS_ID $DIR/test_33_file
1092 $RUNAS $OPENFILE -f O_RDWR $DIR/test_33_file && error || true
1095 run_test 33 "write file with mode 444 (should return error) ===="
1100 chown $RUNAS_ID $DIR/d33
1101 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 || error
1102 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && error || true
1104 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
1106 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
1109 $MCREATE $DIR/f34 || error
1110 $LFIND $DIR/f34 2>&1 | grep -q "no stripe info" || error
1111 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
1112 $LFIND $DIR/f34 2>&1 | grep -q "no stripe info" || error
1113 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1115 run_test 34a "truncate file that has not been opened ==========="
1118 [ ! -f $DIR/f34 ] && test_34a
1119 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1120 $OPENFILE -f O_RDONLY $DIR/f34
1121 $LFIND $DIR/f34 2>&1 | grep -q "no stripe info" || error
1122 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1124 run_test 34b "O_RDONLY opening file doesn't create objects ====="
1127 [ ! -f $DIR/f34 ] && test_34a
1128 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1129 $OPENFILE -f O_RDWR $DIR/f34
1130 $LFIND $DIR/f34 2>&1 | grep -q "no stripe info" && error
1131 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1133 run_test 34c "O_RDWR opening file-with-size works =============="
1136 [ ! -f $DIR/f34 ] && test_34a
1137 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
1138 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1141 run_test 34d "write to sparse file ============================="
1145 $MCREATE $DIR/f34e || error
1146 $TRUNCATE $DIR/f34e 1000 || error
1147 $CHECKSTAT -s 1000 $DIR/f34e || error
1148 $OPENFILE -f O_RDWR $DIR/f34e
1149 $CHECKSTAT -s 1000 $DIR/f34e || error
1151 run_test 34e "create objects, some with size and some without =="
1154 cp /bin/sh $DIR/f35a
1156 chown $RUNAS_ID $DIR/f35a
1157 $RUNAS $DIR/f35a && error || true
1160 run_test 35a "exec file with mode 444 (should return and not leak) ====="
1164 utime $DIR/f36 || error
1166 run_test 36a "MDS utime check (mknod, utime) ==================="
1170 utime $DIR/f36 || error
1172 run_test 36b "OST utime check (open, utime) ===================="
1177 chown $RUNAS_ID $DIR/d36
1178 $RUNAS utime $DIR/d36/f36 || error
1180 run_test 36c "non-root MDS utime check (mknod, utime) =========="
1183 [ ! -d $DIR/d36 ] && test_36c
1184 echo "" > $DIR/d36/f36
1185 $RUNAS utime $DIR/d36/f36 || error
1187 run_test 36d "non-root OST utime check (open, utime) ==========="
1190 [ $RUNAS_ID -eq $UID ] && return
1191 [ ! -d $DIR/d36 ] && mkdir $DIR/d36
1193 $RUNAS utime $DIR/d36/f36e && error "utime worked, want failure" || true
1195 run_test 36e "utime on non-owned file (should return error) ===="
1198 mkdir -p $DIR/dextra
1199 echo f > $DIR/dextra/fbugfile
1200 mount -t ext2 -o loop $EXT2_DEV $DIR/dextra
1201 ls $DIR/dextra | grep "\<fbugfile\>" && error
1202 umount $DIR/dextra || error
1203 rm -f $DIR/dextra/fbugfile || error
1205 run_test 37 "ls a mounted file system to check old content ====="
1208 o_directory $DIR/test38
1210 run_test 38 "open a regular file with O_DIRECTORY =============="
1213 touch $DIR/test_39_file
1214 touch $DIR/test_39_file2
1215 # ls -l $DIR/test_39_file $DIR/test_39_file2
1216 # ls -lu $DIR/test_39_file $DIR/test_39_file2
1217 # ls -lc $DIR/test_39_file $DIR/test_39_file2
1219 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/test_39_file2
1220 # ls -l $DIR/test_39_file $DIR/test_39_file2
1221 # ls -lu $DIR/test_39_file $DIR/test_39_file2
1222 # ls -lc $DIR/test_39_file $DIR/test_39_file2
1223 [ $DIR/test_39_file2 -nt $DIR/test_39_file ] || error
1225 run_test 39 "mtime changed on create ==========================="
1228 dd if=/dev/zero of=$DIR/f40 bs=4096 count=1
1229 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/f40 && error
1230 $CHECKSTAT -t file -s 4096 $DIR/f40 || error
1232 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
1236 small_write $DIR/f41 18
1238 run_test 41 "test small file write + fstat ====================="
1240 count_ost_writes() {
1241 cat /proc/fs/lustre/osc/*/stats |
1242 awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }'
1249 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs
1250 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
1251 echo $WRITEBACK_SAVE > /proc/sys/vm/dirty_writeback_centisecs
1253 # if file not here, we are a 2.4 kernel
1254 kill -CONT `pidof kupdated`
1258 # setup the trap first, so someone cannot exit the test at the
1259 # exact wrong time and mess up a machine
1260 trap start_writeback EXIT
1261 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
1262 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
1263 WRITEBACK_SAVE=`cat /proc/sys/vm/dirty_writeback_centisecs`
1264 echo 0 > /proc/sys/vm/dirty_writeback_centisecs
1266 # if file not here, we are a 2.4 kernel
1267 kill -STOP `pidof kupdated`
1271 # ensure that all stripes have some grant before we test client-side cache
1273 [ "$SETUP_TEST42" ] && return
1274 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
1275 dd if=/dev/zero of=$i bs=4k count=1
1281 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
1282 # file truncation, and file removal.
1285 cancel_lru_locks OSC
1287 sync; sleep 1; sync # just to be safe
1288 BEFOREWRITES=`count_ost_writes`
1289 grep [0-9] /proc/fs/lustre/osc/OSC*MNT*/cur_grant_bytes
1290 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
1291 AFTERWRITES=`count_ost_writes`
1292 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
1293 error "$BEFOREWRITES < $AFTERWRITES"
1296 run_test 42a "ensure that we don't flush on close =============="
1300 cancel_lru_locks OSC
1303 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
1304 BEFOREWRITES=`count_ost_writes`
1305 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
1306 AFTERWRITES=`count_ost_writes`
1307 [ $BEFOREWRITES -eq $AFTERWRITES ] ||
1308 error "$BEFOREWRITES < $AFTERWRITES on unlink"
1309 BEFOREWRITES=`count_ost_writes`
1310 sync || error "sync: $?"
1311 AFTERWRITES=`count_ost_writes`
1312 [ $BEFOREWRITES -eq $AFTERWRITES ] ||
1313 error "$BEFOREWRITES < $AFTERWRITES on sync"
1314 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
1318 run_test 42b "test destroy of file with cached dirty data ======"
1320 # if these tests just want to test the effect of truncation,
1321 # they have to be very careful. consider:
1322 # - the first open gets a {0,EOF}PR lock
1323 # - the first write conflicts and gets a {0, count-1}PW
1324 # - the rest of the writes are under {count,EOF}PW
1325 # - the open for truncate tries to match a {0,EOF}PR
1326 # for the filesize and cancels the PWs.
1327 # any number of fixes (don't get {0,EOF} on open, match
1328 # composite locks, do smarter file size management) fix
1329 # this, but for now we want these tests to verify that
1330 # the cancellation with truncate intent works, so we
1331 # start the file with a full-file pw lock to match against
1332 # until the truncate.
1337 cancel_lru_locks OSC
1339 # prime the file with 0,EOF PW to match
1343 # now the real test..
1344 dd if=/dev/zero of=$file bs=1024 count=100
1345 BEFOREWRITES=`count_ost_writes`
1346 $TRUNCATE $file $offset
1347 cancel_lru_locks OSC
1348 AFTERWRITES=`count_ost_writes`
1354 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
1355 error "$BEFOREWRITES < $AFTERWRITES on truncate"
1358 run_test 42c "test partial truncate of file with cached dirty data"
1362 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
1363 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
1366 run_test 42d "test complete truncate of file with cached dirty data"
1370 cp -p /bin/ls $DIR/d43/f
1371 exec 100>> $DIR/d43/f
1372 $DIR/d43/f && error || true
1375 run_test 43 "execution of file opened for write should return -ETXTBSY"
1379 cp -p `which multiop` $DIR/d43/multiop
1380 $DIR/d43/multiop $TMP/test43.junk O_c &
1383 multiop $DIR/d43/multiop Oc && error "expected error, got success"
1384 kill -USR1 $MULTIPID || return 2
1385 wait $MULTIPID || return 3
1387 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
1391 cp -p `which multiop` $DIR/d43/multiop
1392 $DIR/d43/multiop $TMP/test43.junk O_c &
1395 truncate $DIR/d43/multiop 0 && error "expected error, got success"
1396 kill -USR1 $MULTIPID || return 2
1397 wait $MULTIPID || return 3
1399 run_test 43b "truncate of file being executed should return -ETXTBSY"
1402 local testdir="$DIR/d43c"
1405 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
1406 ( cd $testdir && md5sum -c)
1408 run_test 43c "md5sum of copy into lustre========================"
1411 [ "$OSTCOUNT" -lt "2" ] && echo "skipping 2-stripe test" && return
1412 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=127
1413 dd if=$DIR/f1 bs=4k count=1
1415 run_test 44 "zero length read from a sparse stripe ============="
1418 local nstripe=`$LCTL lov_getconfig $DIR | grep default_stripe_count: | \
1420 local stride=`$LCTL lov_getconfig $DIR | grep default_stripe_size: | \
1422 if [ $nstripe -eq 0 ] ; then
1423 nstripe=`$LCTL lov_getconfig $DIR | grep obd_count: | awk '{print $2}'`
1426 OFFSETS="0 $((stride/2)) $((stride-1))"
1427 for offset in $OFFSETS ; do
1428 for i in `seq 0 $((nstripe-1))`; do
1430 local GLOBALOFFSETS=""
1431 local size=$((((i + 2 * $nstripe )*$stride + $offset))) # Bytes
1432 ll_sparseness_write $DIR/d44a $size || error "ll_sparseness_write"
1433 GLOBALOFFSETS="$GLOBALOFFSETS $size"
1434 ll_sparseness_verify $DIR/d44a $GLOBALOFFSETS \
1435 || error "ll_sparseness_verify $GLOBALOFFSETS"
1437 for j in `seq 0 $((nstripe-1))`; do
1438 size=$((((j + $nstripe )*$stride + $offset))) # Bytes
1439 ll_sparseness_write $DIR/d44a $size || error "ll_sparseness_write"
1440 GLOBALOFFSETS="$GLOBALOFFSETS $size"
1442 ll_sparseness_verify $DIR/d44a $GLOBALOFFSETS \
1443 || error "ll_sparseness_verify $GLOBALOFFSETS"
1447 run_test 44a "test sparse pwrite ==============================="
1451 for d in /proc/fs/lustre/osc/*/cur_dirty_bytes; do
1452 tot=$(($tot + `cat $d`))
1457 before=`dirty_osc_total`
1458 echo executing "\"$*\""
1460 after=`dirty_osc_total`
1461 echo before $before, after $after
1465 # Obtain grants from OST if it supports it
1466 echo blah > ${f}_grant
1469 do_dirty_record "echo blah > $f"
1470 [ $before -eq $after ] && error "write wasn't cached"
1471 do_dirty_record "> $f"
1472 [ $before -gt $after ] || error "truncate didn't lower dirty count"
1473 do_dirty_record "echo blah > $f"
1474 [ $before -eq $after ] && error "write wasn't cached"
1475 do_dirty_record "sync"
1476 [ $before -gt $after ] || error "writeback didn't lower dirty count"
1477 do_dirty_record "echo blah > $f"
1478 [ $before -eq $after ] && error "write wasn't cached"
1479 do_dirty_record "cancel_lru_locks OSC"
1480 [ $before -gt $after ] || error "lock cancellation didn't lower dirty count"
1483 run_test 45 "osc io page accounting ============================"
1489 # in a 2 stripe file (lov.sh), page 63 maps to page 31 in its object. this
1490 # test tickles a bug where re-dirtying a page was failing to be mapped to the
1491 # objects offset and an assert hit when an rpc was built with 63's mapped
1492 # offset 31 and 31's raw 31 offset. it also found general redirtying bugs.
1497 dd if=/dev/zero of=$f bs=`page_size` seek=31 count=1
1499 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=63 count=1
1500 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=31 count=1
1504 run_test 46 "dirtying a previously written page ================"
1506 # Check that device nodes are created and then visible correctly (#2091)
1508 cmknod $DIR/test_47_node || error
1510 run_test 47 "Device nodes check ================================"
1512 test_48a() { # bug 2399
1515 mv $DIR/d48a $DIR/d48.new || error "move directory failed"
1516 mkdir $DIR/d48a || error "recreate directory failed"
1517 touch foo || error "'touch foo' failed after recreating cwd"
1518 mkdir bar || error "'mkdir foo' failed after recreating cwd"
1519 ls . || error "'ls .' failed after recreating cwd"
1520 ls .. || error "'ls ..' failed after removing cwd"
1521 cd . || error "'cd .' failed after recreating cwd"
1522 mkdir . && error "'mkdir .' worked after recreating cwd"
1523 rmdir . && error "'rmdir .' worked after recreating cwd"
1524 ln -s . baz || error "'ln -s .' failed after recreating cwd"
1526 run_test 48a "Access renamed working dir (should return errors)="
1528 test_48b() { # bug 2399
1531 rmdir $DIR/d48b || error "remove cwd $DIR/d48b failed"
1532 touch foo && error "'touch foo' worked after removing cwd"
1533 mkdir foo && error "'mkdir foo' worked after removing cwd"
1534 ls . && error "'ls .' worked after removing cwd"
1535 ls .. || error "'ls ..' failed after removing cwd"
1536 cd . && error "'cd .' worked after recreate cwd"
1537 mkdir . && error "'mkdir .' worked after removing cwd"
1538 rmdir . && error "'rmdir .' worked after removing cwd"
1539 ln -s . foo && error "'ln -s .' worked after removing cwd" || true
1541 run_test 48b "Access removed working dir (should return errors)="
1547 ls /proc/$$/cwd || error
1549 run_test 50 "special situations: /proc symlinks ==============="
1552 # bug 1516 - create an empty entry right after ".." then split dir
1555 $MCREATE $DIR/d49/bar
1557 createmany -m $DIR/d49/longfile 201
1559 while [ `ls -sd $DIR/d49 | awk '{ print $1 }'` -eq 4 ]; do
1560 $MCREATE $DIR/d49/longfile$FNUM
1564 ls -l $DIR/d49 > /dev/null || error
1566 run_test 51 "special situations: split htree with empty entry =="
1569 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
1572 chattr =a $DIR/d52a/foo || error
1573 echo bar >> $DIR/d52a/foo || error
1574 cp /etc/hosts $DIR/d52a/foo && error
1575 rm -f $DIR/d52a/foo 2>/dev/null && error
1576 link $DIR/d52a/foo $DIR/d52a/foo_link 2>/dev/null && error
1577 echo foo >> $DIR/d52a/foo || error
1578 mrename $DIR/d52a/foo $DIR/d52a/foo_ren && error
1579 lsattr $DIR/d52a/foo | egrep -q "^-+a-+ $DIR/d52a/foo" || error
1580 chattr -a $DIR/d52a/foo || error
1582 rm -fr $DIR/d52a || error
1584 run_test 52a "append-only flag test (should return errors) ====="
1587 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
1590 chattr =i $DIR/d52b/foo || error
1591 cat test > $DIR/d52b/foo && error
1592 cp /etc/hosts $DIR/d52b/foo && error
1593 rm -f $DIR/d52b/foo 2>/dev/null && error
1594 link $DIR/d52b/foo $DIR/d52b/foo_link 2>/dev/null && error
1595 echo foo >> $DIR/d52b/foo && error
1596 mrename $DIR/d52b/foo $DIR/d52b/foo_ren && error
1597 [ -f $DIR/d52b/foo ] || error
1598 [ -f $DIR/d52b/foo_ren ] && error
1599 lsattr $DIR/d52b/foo | egrep -q "^-+i-+ $DIR/d52b/foo" || error
1600 chattr -i $DIR/d52b/foo || error
1602 rm -fr $DIR/d52b || error
1604 run_test 52b "immutable flag test (should return errors) ======="
1607 for i in `ls -d /proc/fs/lustre/osc/OSC*mds1 2> /dev/null` ; do
1608 ostname=`echo $i | cut -d _ -f 3-4 | sed -e s/_mds1//`
1609 ost_last=`cat /proc/fs/lustre/obdfilter/$ostname/last_id`
1610 mds_last=`cat $i/prealloc_last_id`
1611 echo "$ostname.last_id=$ost_last ; MDS.last_id=$mds_last"
1612 if [ $ost_last != $mds_last ]; then
1613 error "$ostname.last_id=$ost_last ; MDS.last_id=$mds_last"
1617 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
1620 $SOCKETSERVER $DIR/socket
1621 $SOCKETCLIENT $DIR/socket || error
1622 $MUNLINK $DIR/socket
1624 run_test 54a "unix damain socket test =========================="
1630 dd if=/dev/zero of=$f bs=`page_size` count=1
1632 run_test 54b "char device works in lustre ======================"
1637 loopdev="$DIR/loop54c"
1639 for i in `seq 3 7`; do
1641 mknod $loopdev b 7 $i
1642 losetup $loopdev > /dev/null 2>&1 || break
1644 echo "make a loop file system with $tfile on $loopdev ($i)..."
1645 dd if=/dev/zero of=$tfile bs=`page_size` seek=1024 count=1 > /dev/null
1646 losetup $loopdev $tfile || error "can't set up $loopdev for $tfile"
1647 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
1649 mount -t ext2 $loopdev $tdir || error "error mounting $loopdev on $tdir"
1650 dd if=/dev/zero of=$tdir/tmp bs=`page_size` count=30 || error "dd write"
1652 dd if=$tdir/tmp of=/dev/zero bs=`page_size` count=30 || error "dd read"
1657 run_test 54c "block device works in lustre ====================="
1663 [ "$string" = `echo $string > $f | cat $f` ] || error
1665 run_test 54d "fifo device works in lustre ======================"
1670 mount -t ext3 -o loop,iopen $EXT3_DEV $DIR/d55 || error
1672 $IOPENTEST1 $DIR/d55/foo $DIR/d55 || error
1673 $IOPENTEST2 $DIR/d55 || error
1674 echo "check for $EXT3_DEV. Please wait..."
1676 umount $DIR/d55 || error
1678 run_test 55 "check iopen_connect_dentry() ======================"
1685 NUMFILESx2=$(($NUMFILES * 2))
1686 for i in `seq 1 $NUMFILES` ; do
1687 touch $DIR/d56/file$i
1688 touch $DIR/d56/dir/file$i
1691 # test lfs find with --recursive
1692 FILENUM=`$LFIND --recursive $DIR/d56 | grep -c obdidx`
1693 [ $FILENUM -eq $NUMFILESx2 ] || error \
1694 "lfs find --recursive $DIR/d56 wrong: found $FILENUM, expected $NUMFILESx2"
1695 FILENUM=`$LFIND $DIR/d56 | grep -c obdidx`
1696 [ $FILENUM -eq $NUMFILES ] || error \
1697 "lfs find $DIR/d56 without --recursive wrong: found $FILENUM,
1699 echo "lfs find --recursive passed."
1701 # test lfs find with file instead of dir
1702 FILENUM=`$LFIND $DIR/d56/file1 | grep -c obdidx`
1703 [ $FILENUM -eq 1 ] || error \
1704 "lfs find $DIR/d56/file1 wrong:found $FILENUM, expected 1"
1705 echo "lfs find file passed."
1707 #test lfs find with --verbose
1708 [ `$LFIND --verbose $DIR/d56 | grep -c lmm_magic` -eq $NUMFILES ] ||\
1709 error "lfs find --verbose $DIR/d56 wrong: should find $NUMFILES lmm_magic info"
1710 [ `$LFIND $DIR/d56 | grep -c lmm_magic` -eq 0 ] || error \
1711 "lfs find $DIR/d56 without --verbose wrong: should not show lmm_magic info"
1712 echo "lfs find --verbose passed."
1714 #test lfs find with --obd
1715 $LFIND --obd wrong_uuid $DIR/d56 2>&1 | grep -q "unknown obduuid" || \
1716 error "lfs find --obd wrong_uuid should return error information"
1718 [ "$OSTCOUNT" -lt 2 ] && \
1719 echo "skipping other lfs find --obd test" && return
1720 FILENUM=`$LFIND --recursive $DIR/d56 | sed -n '/^[ ]*1[ ]/p' | wc -l`
1721 OBDUUID=`$LFIND --recursive $DIR/d56 | sed -n '/^[ ]*1:/p' | awk '{print $2}'`
1722 FOUND=`$LFIND -r --obd $OBDUUID $DIR/d56 | wc -l`
1723 [ $FOUND -eq $FILENUM ] || \
1724 error "lfs find --obd wrong: found $FOUND, expected $FILENUM"
1725 [ `$LFIND -r -v --obd $OBDUUID $DIR/d56 | sed '/^[ ]*1[ ]/d' | \
1726 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l` -eq 0 ] || \
1727 error "lfs find --obd wrong: should not show file on other obd"
1728 echo "lfs find --obd passed."
1730 run_test 56 "check lfs find ===================================="
1733 # note test will not do anything if MDS is not local
1734 for DEV in `cat /proc/fs/lustre/mds/*/mntdev`; do
1735 dumpe2fs -h $DEV > $TMP/t57a.dump || error "can't access $DEV"
1736 DEVISIZE=`awk '/Inode size:/ { print $3 }' $TMP/t57a.dump`
1737 [ "$DEVISIZE" -gt 128 ] || error "inode size $DEVISIZE"
1741 run_test 57a "verify MDS filesystem created with large inodes =="
1746 FILEN=$DIR/d57b/f$FILECOUNT
1747 rm -rf $DIR/d57b || error "removing $DIR/d57b"
1748 mkdir -p $DIR/d57b || error "creating $DIR/d57b"
1749 echo "mcreating $FILECOUNT files"
1750 createmany -m $DIR/d57b/f 1 $FILECOUNT || \
1751 error "creating files in $DIR/d57b"
1753 # verify that files do not have EAs yet
1754 $LFIND $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
1755 $LFIND $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
1757 MDSFREE="`cat /proc/fs/lustre/mds/*/kbytesfree`"
1758 MDCFREE="`cat /proc/fs/lustre/mdc/*/kbytesfree`"
1759 echo "opening files to create objects/EAs"
1760 for FILE in `seq -f $DIR/d57b/f%g 1 $FILECOUNT`; do
1761 $OPENFILE -f O_RDWR $FILE > /dev/null || error "opening $FILE"
1764 # verify that files have EAs now
1765 $LFIND $FILE1 | grep -q "obdidx" || error "$FILE1 missing EA"
1766 $LFIND $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
1768 MDSFREE2="`cat /proc/fs/lustre/mds/*/kbytesfree`"
1769 MDCFREE2="`cat /proc/fs/lustre/mdc/*/kbytesfree`"
1770 if [ "$MDCFREE" != "$MDCFREE2" ]; then
1771 if [ "$MDSFREE" != "$MDSFREE2" ]; then
1772 error "MDC before $MDCFREE != after $MDCFREE2"
1774 echo "MDC before $MDCFREE != after $MDCFREE2"
1775 echo "unable to confirm if MDS has large inodes"
1780 run_test 57b "default LOV EAs are stored inside large inodes ==="
1785 run_test 58 "verify cross-platform wire constants =============="
1788 echo "touch 130 files"
1789 for i in `seq 1 130` ; do
1793 for i in `seq 1 130` ; do
1798 # wait for commitment of removal
1800 run_test 59 "verify cancellation of llog records async ========="
1803 echo 60 "llog tests run from kernel mode"
1806 run_test 60 "llog sanity tests run from kernel module =========="
1810 dd if=/dev/zero of=$f bs=`page_size` count=1
1811 cancel_lru_locks OSC
1812 multiop $f OSMWUc || error
1815 run_test 61 "mmap() writes don't make sync hang ================"
1817 # bug 2330 - insufficient obd_match error checking causes LBUG
1821 cancel_lru_locks OSC
1822 echo 0x405 > /proc/sys/lustre/fail_loc
1823 cat $f && error "cat succeeded, expect -EIO"
1824 echo 0 > /proc/sys/lustre/fail_loc
1826 run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
1828 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
1830 MAX_DIRTY_MB=`cat /proc/fs/lustre/osc/*/max_dirty_mb | head -1`
1831 for i in /proc/fs/lustre/osc/*/max_dirty_mb ; do
1834 for i in `seq 10` ; do
1835 dd if=/dev/zero of=$DIR/f63 bs=8k &
1841 for i in /proc/fs/lustre/osc/*/max_dirty_mb ; do
1842 echo $MAX_DIRTY_MB > $i
1846 run_test 63 "Verify oig_wait interruption does not crash ======"
1850 grep "[0-9]" /proc/fs/lustre/osc/OSC*MNT*/cur*
1852 run_test 64a "verify filter grant calculations (in kernel) ====="
1857 run_test 64b "check out-of-space detection on client ==========="
1859 # bug 1414 - set/get directories' stripe info
1863 $LVERIFY $DIR/d65 $DIR/d65/f1 || error "lverify failed"
1865 run_test 65a "directory with no stripe info ===================="
1869 $LSTRIPE $DIR/d65 $(($STRIPESIZE * 2)) 0 1 || error "setstripe"
1871 $LVERIFY $DIR/d65 $DIR/d65/f2 || error "lverify failed"
1873 run_test 65b "directory setstripe $(($STRIPESIZE * 2)) 0 1 ==============="
1876 if [ $OSTCOUNT -gt 1 ]; then
1878 $LSTRIPE $DIR/d65 $(($STRIPESIZE * 4)) 1 \
1879 $(($OSTCOUNT - 1)) || error "setstripe"
1881 $LVERIFY $DIR/d65 $DIR/d65/f3 || error "lverify failed"
1884 run_test 65c "directory setstripe $(($STRIPESIZE * 4)) 1 $(($OSTCOUNT - 1))"
1886 [ $STRIPECOUNT -eq 0 ] && sc=1 || sc=$(($STRIPECOUNT - 1))
1890 $LSTRIPE $DIR/d65 $STRIPESIZE -1 $sc || error "setstripe"
1891 touch $DIR/d65/f4 $DIR/d65/f5
1892 $LVERIFY $DIR/d65 $DIR/d65/f4 $DIR/d65/f5 || error "lverify failed"
1894 run_test 65d "directory setstripe $STRIPESIZE -1 $sc ======================"
1899 $LSTRIPE $DIR/d65 0 -1 0 || error "setstripe"
1901 $LVERIFY $DIR/d65 $DIR/d65/f6 || error "lverify failed"
1903 run_test 65e "directory setstripe 0 -1 0 (default) ============="
1907 $RUNAS $LSTRIPE $DIR/d65f 0 -1 0 && error "setstripe succeeded" || true
1909 run_test 65f "dir setstripe permission (should return error) ==="
1911 # bug 2543 - update blocks count on client
1914 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
1916 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
1917 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
1919 run_test 66 "update inode blocks count on client ==============="
1921 # on the LLNL clusters, runas will still pick up root's $TMP settings,
1922 # which will not be writable for the runas user, and then you get a CVS
1923 # error message with a corrupt path string (CVS bug) and panic.
1924 # We're not using much space, so just stick it in /tmp, which is safe.
1930 [ $RUNAS_ID -ne $UID ] && HOME=/tmp
1933 mkdir -p $DIR/d99cvsroot
1934 chown $RUNAS_ID $DIR/d99cvsroot
1935 $RUNAS cvs -d $DIR/d99cvsroot init || error
1937 run_test 99a "cvs init ========================================="
1940 [ ! -d $DIR/d99cvsroot ] && test_99a
1942 # some versions of cvs import exit(1) when asked to import links or
1943 # files they can't read. ignore those files.
1944 TOIGNORE=$(find . -type l -printf '-I %f\n' -o \
1945 ! -perm +4 -printf '-I %f\n')
1946 $RUNAS cvs -d $DIR/d99cvsroot import -m "nomesg" $TOIGNORE \
1947 d99reposname vtag rtag
1949 run_test 99b "cvs import ======================================="
1952 [ ! -d $DIR/d99cvsroot ] && test_99b
1954 mkdir -p $DIR/d99reposname
1955 chown $RUNAS_ID $DIR/d99reposname
1956 $RUNAS cvs -d $DIR/d99cvsroot co d99reposname
1958 run_test 99c "cvs checkout ====================================="
1961 [ ! -d $DIR/d99cvsroot ] && test_99c
1962 cd $DIR/d99reposname
1964 $RUNAS cvs add -m 'addmsg' foo99
1966 run_test 99d "cvs add =========================================="
1969 [ ! -d $DIR/d99cvsroot ] && test_99c
1970 cd $DIR/d99reposname
1973 run_test 99e "cvs update ======================================="
1976 [ ! -d $DIR/d99cvsroot ] && test_99d
1977 cd $DIR/d99reposname
1978 $RUNAS cvs commit -m 'nomsg' foo99
1980 run_test 99f "cvs commit ======================================="
1986 log "cleanup: ======================================================"
1987 if [ "`mount | grep ^$NAME`" ]; then
1988 rm -rf $DIR/[Rdfs][1-9]*
1989 if [ "$I_MOUNTED" = "yes" ]; then
1990 sh llmountcleanup.sh || error
1994 echo '=========================== finished ==============================='
1995 [ -f "$SANITYLOG" ] && cat $SANITYLOG && exit 1 || true