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:-lstripe}
26 MCREATE=${MCREATE:-mcreate}
27 OPENFILE=${OPENFILE:-openfile}
28 OPENUNLINK=${OPENUNLINK:-openunlink}
29 TOEXCL=${TOEXCL:-toexcl}
30 TRUNCATE=${TRUNCATE:-truncate}
31 MUNLINK=${MUNLINK:-munlink}
32 SOCKETSERVER=${SOCKETSERVER:-socketserver}
33 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
34 IOPENTEST1=${IOPENTEST1:-iopentest1}
35 IOPENTEST2=${IOPENTEST2:-iopentest2}
37 if [ $UID -ne 0 ]; then
41 RUNAS_ID=${RUNAS_ID:-500}
42 RUNAS=${RUNAS:-"runas -u $RUNAS_ID"}
45 export NAME=${NAME:-local}
51 sh llmountcleanup.sh > /dev/null || exit 20
58 sh llrmount.sh > /dev/null || exit 10
66 lctl mark "$*" 2> /dev/null || true
70 if ! mount | grep -q $DIR; then
74 export TESTNAME=test_$1
75 test_$1 || error "test_$1: exit with rc=$?"
86 for E in $EXCEPT $ALWAYS_EXCEPT; do
96 IFS=abcdefghijklmnopqrstuvwxyz _basetest $1
103 if [ ${!testname}x != x ]; then
108 if [ ${!testname}x != x ]; then
116 if [ ${!testname}x != x ]; then
117 echo "skipping excluded test $1"
120 testname=EXCEPT_$base
121 if [ ${!testname}x != x ]; then
122 echo "skipping excluded test $1 (base $base)"
129 [ "$SANITYLOG" ] && rm -f $SANITYLOG || true
133 if [ "$SANITYLOG" ]; then
134 echo "FAIL: $TESTNAME $@" >> $SANITYLOG
144 MOUNT="`mount | awk '/^'$NAME' .* lustre_lite / { print $3 }'`"
145 if [ -z "$MOUNT" ]; then
147 MOUNT="`mount | awk '/^'$NAME' .* lustre_lite / { print $3 }'`"
148 [ -z "$MOUNT" ] && error "NAME=$NAME not mounted"
152 [ `echo $MOUNT | wc -w` -gt 1 ] && error "NAME=$NAME mounted more than once"
155 [ -z "`echo $DIR | grep $MOUNT`" ] && echo "$DIR not in $MOUNT" && exit 99
157 LOVNAME=`cat /proc/fs/lustre/llite/fs0/lov/common_name`
158 STRIPECOUNT=`cat /proc/fs/lustre/lov/$LOVNAME/numobd`
160 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
161 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
162 rm -rf $DIR/[Rdfs][1-9]*
166 echo preparing for tests involving mounts
167 EXT2_DEV=${EXT2_DEV:-/tmp/SANITY.LOOP}
169 mke2fs -F $EXT2_DEV 1000 > /dev/null
171 EXT3_DEV=${EXT3_DEV:-/tmp/SANITY_EXT3_DEV.LOOP}
173 mkfs.ext3 -F $EXT3_DEV 10000 > /dev/null
177 $CHECKSTAT -t file $DIR/f || error
179 $CHECKSTAT -a $DIR/f || error
181 run_test 0 "touch .../f ; rm .../f ============================="
186 $CHECKSTAT -t dir $DIR/d1/d2 || error
188 run_test 1a "mkdir .../d1; mkdir .../d1/d2 ====================="
193 $CHECKSTAT -a $DIR/d1 || error
195 run_test 1b "rmdir .../d1/d2; rmdir .../d1 ====================="
200 $CHECKSTAT -t file $DIR/d2/f || error
202 run_test 2a "mkdir .../d2; touch .../d2/f ======================"
206 $CHECKSTAT -a $DIR/d2 || error
208 run_test 2b "rm -r .../d2; checkstat .../d2/f ======================"
212 $CHECKSTAT -t dir $DIR/d3 || error
214 run_test 3a "mkdir .../d3 ======================================"
217 if [ ! -d $DIR/d3 ]; then
221 $CHECKSTAT -t file $DIR/d3/f || error
223 run_test 3b "touch .../d3/f ===================================="
227 $CHECKSTAT -a $DIR/d3 || error
229 run_test 3c "rm -r .../d3 ======================================"
233 $CHECKSTAT -t dir $DIR/d4 || error
235 run_test 4a "mkdir .../d4 ======================================"
238 if [ ! -d $DIR/d4 ]; then
242 $CHECKSTAT -t dir $DIR/d4/d2 || error
244 run_test 4b "mkdir .../d4/d2 ==================================="
249 chmod 0707 $DIR/d5/d2
250 $CHECKSTAT -t dir -p 0707 $DIR/d5/d2 || error
252 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2 ============"
256 chmod 0666 $DIR/f6a || error
257 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/f6a || error
259 run_test 6a "touch .../f6a; chmod .../f6a ======================"
262 [ $RUNAS_ID -eq $UID ] && echo "skipping test 6b" && return
263 if [ ! -f $DIR/f6a ]; then
267 $RUNAS chmod 0444 $DIR/f6a && error
268 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/f6a || error
270 run_test 6b "$RUNAS chmod .../f6a (should return error) =="
273 [ $RUNAS_ID -eq $UID ] && echo "skipping test 6c" && return
275 chown $RUNAS_ID $DIR/f6c || error
276 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/f6c || error
278 run_test 6c "touch .../f6c; chown .../f6c ======================"
281 [ $RUNAS_ID -eq $UID ] && echo "skipping test 6d" && return
282 if [ ! -f $DIR/f6c ]; then
284 chown $RUNAS_ID $DIR/f6c
286 $RUNAS chown $UID $DIR/f6c && error
287 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/f6c || error
289 run_test 6d "$RUNAS chown .../f6c (should return error) =="
292 [ $RUNAS_ID -eq $UID ] && echo "skipping test 6e" && return
294 chgrp $RUNAS_ID $DIR/f6e || error
295 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/f6e || error
297 run_test 6e "touch .../f6e; chgrp .../f6e ======================"
300 [ $RUNAS_ID -eq $UID ] && echo "skipping test 6f" && return
301 if [ ! -f $DIR/f6e ]; then
303 chgrp $RUNAS_ID $DIR/f6e
305 $RUNAS chgrp $UID $DIR/f6e && error
306 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/f6e || error
308 run_test 6f "$RUNAS chgrp .../f6e (should return error) =="
311 [ $RUNAS_ID -eq $UID ] && echo "skipping test 6g" && return
312 mkdir $DIR/d6g || error
313 chmod 777 $DIR/d6g || error
314 $RUNAS mkdir $DIR/d6g/d || error
315 chmod g+s $DIR/d6g/d || error
316 mkdir $DIR/d6g/d/subdir
317 $CHECKSTAT -g \#$RUNAS_ID $DIR/d6g/d/subdir || error
319 run_test 6g "Is new dir in sgid dir inheriting group?"
325 $CHECKSTAT -t file -p 0666 $DIR/d7/f || error
327 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
330 if [ ! -d $DIR/d7 ]; then
334 echo -n foo > $DIR/d7/f2
335 [ "`cat $DIR/d7/f2`" = "foo" ] || error
336 $CHECKSTAT -t file -s 3 $DIR/d7/f2 || error
338 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
344 $CHECKSTAT -t file -p 0666 $DIR/d8/f || error
346 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
352 $CHECKSTAT -t dir $DIR/d9/d2/d3 || error
354 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
360 $CHECKSTAT -t file $DIR/d10/d2/f || error
362 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
367 chmod 0666 $DIR/d11/d2
368 chmod 0705 $DIR/d11/d2
369 $CHECKSTAT -t dir -p 0705 $DIR/d11/d2 || error
371 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
376 chmod 0666 $DIR/d12/f
377 chmod 0654 $DIR/d12/f
378 $CHECKSTAT -t file -p 0654 $DIR/d12/f || error
380 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
384 dd if=/dev/zero of=$DIR/d13/f count=10
386 $CHECKSTAT -t file -s 0 $DIR/d13/f || error
388 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
394 $CHECKSTAT -a $DIR/d14/f || error
396 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
401 mv $DIR/d15/f $DIR/d15/f2
402 $CHECKSTAT -t file $DIR/d15/f2 || error
404 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
410 $CHECKSTAT -a $DIR/d16/f || error
412 run_test 16 "touch .../d16/f; rm -rf .../d16/f ================="
417 ln -s $DIR/d17/f $DIR/d17/l-exist
419 $CHECKSTAT -l $DIR/d17/f $DIR/d17/l-exist || error
420 $CHECKSTAT -f -t f $DIR/d17/l-exist || error
422 $CHECKSTAT -a $DIR/l-exist || error
424 run_test 17a "symlinks: create, remove (real) =================="
427 if [ ! -d $DIR/d17 ]; then
430 ln -s no-such-file $DIR/d17/l-dangle
432 $CHECKSTAT -l no-such-file $DIR/d17/l-dangle || error
433 $CHECKSTAT -fa $DIR/d17/l-dangle || error
435 $CHECKSTAT -a $DIR/l-dangle || error
437 run_test 17b "symlinks: create, remove (dangling) =============="
443 run_test 18 "touch .../f ; ls ... =============================="
449 $CHECKSTAT -a $DIR/f19 || error
451 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
454 ls -l $DIR/f19 && error || true
456 run_test 19b "ls -l .../f19 (should return error) =============="
459 [ $RUNAS_ID -eq $UID ] && echo "skipping test 19c" && return
460 $RUNAS touch $DIR/f19 && error || true
462 run_test 19c "$RUNAS touch .../f19 (should return error) =="
465 cat $DIR/f19 && error || true
467 run_test 19d "cat .../f19 (should return error) =============="
479 $CHECKSTAT -a $DIR/f || error
481 run_test 20 "touch .../f ; ls -l ... ==========================="
485 [ -f $DIR/d21/dangle ] && rm -f $DIR/d21/dangle
486 ln -s dangle $DIR/d21/link
487 echo foo >> $DIR/d21/link
489 $CHECKSTAT -t link $DIR/d21/link || error
490 $CHECKSTAT -f -t file $DIR/d21/link || error
492 run_test 21 "write to dangling link ============================"
496 chown $RUNAS_ID $DIR/d22
497 # Tar gets pissy if it can't access $PWD *sigh*
499 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
500 $RUNAS tar xfC - $DIR/d22)
502 $CHECKSTAT -t dir $DIR/d22/etc || error
503 $CHECKSTAT -u \#$RUNAS_ID $DIR/d22/etc || error
505 run_test 22 "unpack tar archive as non-root user ==============="
510 $TOEXCL -e $DIR/d23/f23 || error
512 run_test 23 "O_CREAT|O_EXCL in subdir =========================="
515 echo '== rename sanity =============================================='
516 echo '-- same directory rename'
519 mv $DIR/R1/f $DIR/R1/g
520 $CHECKSTAT -t file $DIR/R1/g || error
522 run_test 24a "touch .../R1/f; rename .../R1/f .../R1/g ========="
527 mv $DIR/R2/f $DIR/R2/g
528 $CHECKSTAT -a $DIR/R2/f || error
529 $CHECKSTAT -t file $DIR/R2/g || error
531 run_test 24b "touch .../R2/{f,g}; rename .../R2/f .../R2/g ====="
536 mv $DIR/R3/f $DIR/R3/g
537 $CHECKSTAT -a $DIR/R3/f || error
538 $CHECKSTAT -t dir $DIR/R3/g || error
540 run_test 24c "mkdir .../R3/f; rename .../R3/f .../R3/g ========="
545 perl -e "rename \"$DIR/R4/f\", \"$DIR/R4/g\";"
546 $CHECKSTAT -a $DIR/R4/f || error
547 $CHECKSTAT -t dir $DIR/R4/g || error
549 run_test 24d "mkdir .../R4/{f,g}; rename .../R4/f .../R4/g ====="
552 echo '-- cross directory renames --'
555 mv $DIR/R5a/f $DIR/R5b/g
556 $CHECKSTAT -a $DIR/R5a/f || error
557 $CHECKSTAT -t file $DIR/R5b/g || error
559 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
563 touch $DIR/R6a/f $DIR/R6b/g
564 mv $DIR/R6a/f $DIR/R6b/g
565 $CHECKSTAT -a $DIR/R6a/f || error
566 $CHECKSTAT -t file $DIR/R6b/g || error
568 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
573 mv $DIR/R7a/d $DIR/R7b/e
574 $CHECKSTAT -a $DIR/R7a/d || error
575 $CHECKSTAT -t dir $DIR/R7b/e || error
577 run_test 24g "mkdir .../R7a/d; rename .../R7a/d .../R5b/e ======"
581 mkdir $DIR/R8a/d $DIR/R8b/e
582 perl -e "rename \"$DIR/R8a/d\", \"$DIR/R8b/e\";"
583 $CHECKSTAT -a $DIR/R8a/d || error
584 $CHECKSTAT -t dir $DIR/R8b/e || error
586 run_test 24h "mkdir .../R8{a,b} R8a/{d,e}; mv .../R8a/d .../R8b/e"
589 echo "-- rename error cases"
593 perl -e "rename \"$DIR/R9/f\", \"$DIR/R9/a\";"
594 $CHECKSTAT -t file $DIR/R9/f || error
595 $CHECKSTAT -t dir $DIR/R9/a || error
596 $CHECKSTAT -a file $DIR/R9/a/f || error
598 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
602 perl -e "rename \"$DIR/R10/f\", \"$DIR/R10/g\""
603 $CHECKSTAT -t dir $DIR/R10 || error
604 $CHECKSTAT -a $DIR/R10/f || error
605 $CHECKSTAT -a $DIR/R10/g || error
607 run_test 24j "source does not exist ============================"
610 mkdir $DIR/R11a $DIR/R11a/d
612 mv $DIR/R11a/f $DIR/R11a/d
613 $CHECKSTAT -a $DIR/R11a/f || error
614 $CHECKSTAT -t file $DIR/R11a/d/f || error
616 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
618 # bug 2429 - rename foo foo foo creates invalid file
621 multiop $f OcNs || error
623 run_test 24l "Renaming a file to itself ========================"
627 multiop $f OcLN ${f}2 ${f}2 || error
629 run_test 24m "Renaming a file to a hard link to itself ========="
633 # this stats the old file after it was renamed, so it should fail
637 $CHECKSTAT ${f}.rename
640 run_test 24n "Statting the old file after renameing (Posix rename 2)"
643 echo '== symlink sanity ============================================='
646 touch $DIR/s25/foo || error
648 run_test 25a "create file in symlinked directory ==============="
651 [ ! -d $DIR/d25 ] && test_25a
652 $CHECKSTAT -t file $DIR/s25/foo || error
654 run_test 25b "lookup file in symlinked directory ==============="
659 ln -s d26/d26-2 $DIR/s26
660 touch $DIR/s26/foo || error
662 run_test 26a "multiple component symlink ======================="
665 mkdir -p $DIR/d26b/d26-2
666 ln -s d26b/d26-2/foo $DIR/s26-2
667 touch $DIR/s26-2 || error
669 run_test 26b "multiple component symlink at end of lookup ======"
674 ln -s d26.2 $DIR/s26.2-1
675 ln -s s26.2-1 $DIR/s26.2-2
676 ln -s s26.2-2 $DIR/s26.2-3
677 chmod 0666 $DIR/s26.2-3/foo
679 run_test 26c "chain of symlinks ================================"
681 # recursive symlinks (bug 439)
683 ln -s d26-3/foo $DIR/d26-3
685 run_test 26d "create multiple component recursive symlink ======"
688 [ ! -h $DIR/d26-3 ] && test_26d
691 run_test 26e "unlink multiple component recursive symlink ======"
694 echo '== stripe sanity =============================================='
696 $LSTRIPE $DIR/d27/f0 65536 0 1 || error
697 $CHECKSTAT -t file $DIR/d27/f0 || error
699 log "== test_27b: write to one stripe file ========================="
700 cp /etc/hosts $DIR/d27/f0 || error
702 run_test 27a "one stripe file =================================="
705 [ "$STRIPECOUNT" -lt "2" ] && echo "skipping 2-stripe test" && return
706 if [ ! -d $DIR/d27 ]; then
709 $LSTRIPE $DIR/d27/f01 65536 0 2 || error
710 [ `$LFIND $DIR/d27/f01 | grep -A 10 obdidx | wc -l` -eq 4 ] ||
711 error "two-stripe file doesn't have two stripes"
713 log "== test_27d: write to two stripe file file f01 ================"
714 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error
716 run_test 27c "create two stripe file f01 ======================="
719 if [ ! -d $DIR/d27 ]; then
722 $LSTRIPE $DIR/d27/fdef 0 -1 0 || error
723 $CHECKSTAT -t file $DIR/d27/fdef || error
724 #dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
726 run_test 27d "create file with default settings ================"
729 if [ ! -d $DIR/d27 ]; then
732 $LSTRIPE $DIR/d27/f12 65536 0 2 || error
733 $LSTRIPE $DIR/d27/f12 65536 0 2 && error
734 $CHECKSTAT -t file $DIR/d27/f12 || error
736 run_test 27e "lstripe existing file (should return error) ======"
739 if [ ! -d $DIR/d27 ]; then
742 $LSTRIPE $DIR/d27/fbad 100 0 1 && error
743 dd if=/dev/zero of=$DIR/d27/f12 bs=4k count=4 || error
744 $LFIND $DIR/d27/fbad || error
746 run_test 27f "lstripe with bad stripe size (should return error)"
749 if [ ! -d $DIR/d27 ]; then
752 $MCREATE $DIR/d27/fnone || error
754 log "== test 27h: lfind with no objects ============================"
755 $LFIND $DIR/d27/fnone 2>&1 | grep "no stripe info" || error
757 log "== test 27i: lfind with some objects =========================="
758 touch $DIR/d27/fsome || error
759 $LFIND $DIR/d27/fsome | grep obdidx || error
761 run_test 27g "test lfind ======================================="
764 if [ ! -d $DIR/d27 ]; then
767 $LSTRIPE $DIR/d27/f27j 65536 $STRIPECOUNT 1 && error || true
769 run_test 27j "lstripe with bad stripe offset (should return error)"
771 test_27k() { # bug 2844
773 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
774 [ ! -d $DIR/d27 ] && mkdir -p $DIR/d27
775 $LSTRIPE $FILE 67108864 -1 0 || error "lstripe failed"
776 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
777 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
778 dd if=/dev/zero of=$FILE bs=4k count=1
779 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
780 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
782 run_test 27k "limit i_blksize for broken user apps ============="
786 $CREATETEST $DIR/d28/ct || error
788 run_test 28 "create/mknod/mkdir with bad file types ============"
791 for d in /proc/fs/lustre/ldlm/namespaces/$1*; do
792 echo clear > $d/lru_size
794 grep [0-9] /proc/fs/lustre/ldlm/namespaces/$1*/lock_unused_count /dev/null
803 MDCDIR=${MDCDIR:-/proc/fs/lustre/ldlm/namespaces/MDC_*}
804 LOCKCOUNTORIG=`cat $MDCDIR/lock_count`
805 LOCKUNUSEDCOUNTORIG=`cat $MDCDIR/lock_unused_count`
809 LOCKCOUNTCURRENT=`cat $MDCDIR/lock_count`
810 LOCKUNUSEDCOUNTCURRENT=`cat $MDCDIR/lock_unused_count`
811 if [ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]; then
812 echo "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
815 if [ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]; then
816 echo "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
820 run_test 29 "IT_GETATTR regression ============================"
827 run_test 30 "run binary from Lustre (execve) ==================="
830 $OPENUNLINK $DIR/f31 $DIR/f31 || error
831 $CHECKSTAT -a $DIR/f31 || error
833 run_test 31a "open-unlink file =================================="
836 touch $DIR/f31 || error
837 ln $DIR/f31 $DIR/f31b || error
838 multiop $DIR/f31b Ouc || error
839 $CHECKSTAT -t file $DIR/f31 || error
841 run_test 31b "unlink file with multiple links while open ======="
844 touch $DIR/f31 || error
845 ln $DIR/f31 $DIR/f31c || error
846 multiop $DIR/f31 O_uc &
848 multiop $DIR/f31c Ouc
853 run_test 31c "open-unlink file with multiple links ============="
856 opendirunlink $DIR/d31d $DIR/d31d || error
857 $CHECKSTAT -a $DIR/d31d || error
859 run_test 31d "remove of open directory ========================="
862 echo "== more mountpoints and symlinks ================="
863 [ -e $DIR/d32a ] && rm -fr $DIR/d32a
864 mkdir -p $DIR/d32a/ext2-mountpoint
865 mount -t ext2 -o loop $EXT2_DEV $DIR/d32a/ext2-mountpoint || error
866 $CHECKSTAT -t dir $DIR/d32a/ext2-mountpoint/.. || error
867 umount $DIR/d32a/ext2-mountpoint || error
869 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
872 [ -e $DIR/d32b ] && rm -fr $DIR/d32b
873 mkdir -p $DIR/d32b/ext2-mountpoint
874 mount -t ext2 -o loop $EXT2_DEV $DIR/d32b/ext2-mountpoint || error
875 ls -al $DIR/d32b/ext2-mountpoint/.. || error
876 umount $DIR/d32b/ext2-mountpoint || error
878 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
881 [ -e $DIR/d32c ] && rm -fr $DIR/d32c
882 mkdir -p $DIR/d32c/ext2-mountpoint
883 mount -t ext2 -o loop $EXT2_DEV $DIR/d32c/ext2-mountpoint || error
884 mkdir -p $DIR/d32c/d2/test_dir
885 $CHECKSTAT -t dir $DIR/d32c/ext2-mountpoint/../d2/test_dir || error
886 umount $DIR/d32c/ext2-mountpoint || error
888 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
891 [ -e $DIR/d32d ] && rm -fr $DIR/d32d
892 mkdir -p $DIR/d32d/ext2-mountpoint
893 mount -t ext2 -o loop $EXT2_DEV $DIR/d32d/ext2-mountpoint || error
894 mkdir -p $DIR/d32d/d2/test_dir
895 ls -al $DIR/d32d/ext2-mountpoint/../d2/test_dir || error
896 umount $DIR/d32d/ext2-mountpoint || error
898 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
901 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
902 mkdir -p $DIR/d32e/tmp
903 TMP_DIR=$DIR/d32e/tmp
904 ln -s $DIR/d32e $TMP_DIR/symlink11
905 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
906 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
907 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
909 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
912 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
913 mkdir -p $DIR/d32f/tmp
914 TMP_DIR=$DIR/d32f/tmp
915 ln -s $DIR/d32f $TMP_DIR/symlink11
916 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
917 ls $DIR/d32f/tmp/symlink11 || error
918 ls $DIR/d32f/symlink01 || error
920 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
923 [ -e $DIR/d32g ] && rm -fr $DIR/d32g
924 [ -e $DIR/test_dir ] && rm -fr $DIR/test_dir
925 mkdir -p $DIR/test_dir
926 mkdir -p $DIR/d32g/tmp
927 TMP_DIR=$DIR/d32g/tmp
928 ln -s $DIR/test_dir $TMP_DIR/symlink12
929 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
930 $CHECKSTAT -t link $DIR/d32g/tmp/symlink12 || error
931 $CHECKSTAT -t link $DIR/d32g/symlink02 || error
932 $CHECKSTAT -t dir -f $DIR/d32g/tmp/symlink12 || error
933 $CHECKSTAT -t dir -f $DIR/d32g/symlink02 || error
935 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/test_dir"
938 [ -e $DIR/d32h ] && rm -fr $DIR/d32h
939 [ -e $DIR/test_dir ] && rm -fr $DIR/test_dir
940 mkdir -p $DIR/test_dir
941 mkdir -p $DIR/d32h/tmp
942 TMP_DIR=$DIR/d32h/tmp
943 ln -s $DIR/test_dir $TMP_DIR/symlink12
944 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
945 ls $DIR/d32h/tmp/symlink12 || error
946 ls $DIR/d32h/symlink02 || error
948 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/test_dir"
951 [ -e $DIR/d32i ] && rm -fr $DIR/d32i
952 mkdir -p $DIR/d32i/ext2-mountpoint
953 mount -t ext2 -o loop $EXT2_DEV $DIR/d32i/ext2-mountpoint || error
954 touch $DIR/d32i/test_file
955 $CHECKSTAT -t file $DIR/d32i/ext2-mountpoint/../test_file || error
956 umount $DIR/d32i/ext2-mountpoint || error
958 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
961 [ -e $DIR/d32j ] && rm -fr $DIR/d32j
962 mkdir -p $DIR/d32j/ext2-mountpoint
963 mount -t ext2 -o loop $EXT2_DEV $DIR/d32j/ext2-mountpoint || error
964 touch $DIR/d32j/test_file
965 cat $DIR/d32j/ext2-mountpoint/../test_file || error
966 umount $DIR/d32j/ext2-mountpoint || error
968 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
972 mkdir -p $DIR/d32k/ext2-mountpoint
973 mount -t ext2 -o loop $EXT2_DEV $DIR/d32k/ext2-mountpoint
974 mkdir -p $DIR/d32k/d2
975 touch $DIR/d32k/d2/test_file || error
976 $CHECKSTAT -t file $DIR/d32k/ext2-mountpoint/../d2/test_file || error
977 umount $DIR/d32k/ext2-mountpoint || error
979 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
983 mkdir -p $DIR/d32l/ext2-mountpoint
984 mount -t ext2 -o loop $EXT2_DEV $DIR/d32l/ext2-mountpoint || error
985 mkdir -p $DIR/d32l/d2
986 touch $DIR/d32l/d2/test_file
987 cat $DIR/d32l/ext2-mountpoint/../d2/test_file || error
988 umount $DIR/d32l/ext2-mountpoint || error
990 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
994 mkdir -p $DIR/d32m/tmp
995 TMP_DIR=$DIR/d32m/tmp
996 ln -s $DIR $TMP_DIR/symlink11
997 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
998 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
999 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
1001 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
1005 mkdir -p $DIR/d32n/tmp
1006 TMP_DIR=$DIR/d32n/tmp
1007 ln -s $DIR $TMP_DIR/symlink11
1008 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1009 ls -l $DIR/d32n/tmp/symlink11 || error
1010 ls -l $DIR/d32n/symlink01 || error
1012 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
1016 rm -f $DIR/test_file
1017 touch $DIR/test_file
1018 mkdir -p $DIR/d32o/tmp
1019 TMP_DIR=$DIR/d32o/tmp
1020 ln -s $DIR/test_file $TMP_DIR/symlink12
1021 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1022 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
1023 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
1024 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
1025 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
1027 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/test_file"
1033 rm -f $DIR/test_file
1035 touch $DIR/test_file
1037 mkdir -p $DIR/d32p/tmp
1039 TMP_DIR=$DIR/d32p/tmp
1041 ln -s $DIR/test_file $TMP_DIR/symlink12
1043 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1045 cat $DIR/d32p/tmp/symlink12 || error
1047 cat $DIR/d32p/symlink02 || error
1050 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/test_file"
1053 [ -e $DIR/d32q ] && rm -fr $DIR/d32q
1055 touch $DIR/d32q/under_the_mount
1056 mount -t ext2 -o loop $EXT2_DEV $DIR/d32q
1057 ls $DIR/d32q/under_the_mount && error || true
1058 umount $DIR/d32q || error
1060 run_test 32q "stat follows mountpoints in Lustre (should return error)"
1063 [ -e $DIR/d32r ] && rm -fr $DIR/d32r
1065 touch $DIR/d32r/under_the_mount
1066 mount -t ext2 -o loop $EXT2_DEV $DIR/d32r
1067 ls $DIR/d32r | grep -q under_the_mount && error || true
1068 umount $DIR/d32r || error
1070 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
1072 # chmod 444 /mnt/lustre/somefile
1073 # open(/mnt/lustre/somefile, O_RDWR)
1076 rm -f $DIR/test_33_file
1077 touch $DIR/test_33_file
1078 chmod 444 $DIR/test_33_file
1079 chown $RUNAS_ID $DIR/test_33_file
1081 $RUNAS $OPENFILE -f O_RDWR $DIR/test_33_file && error || true
1084 run_test 33 "write file with mode 444 (should return error) ===="
1089 chown $RUNAS_ID $DIR/d33
1090 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 || error
1091 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && error || true
1093 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
1095 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
1098 $MCREATE $DIR/f34 || error
1099 $LFIND $DIR/f34 2>&1 | grep -q "no stripe info" || error
1100 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
1101 $LFIND $DIR/f34 2>&1 | grep -q "no stripe info" || error
1102 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1104 run_test 34a "truncate file that has not been opened ==========="
1107 [ ! -f $DIR/f34 ] && test_34a
1108 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1109 $OPENFILE -f O_RDONLY $DIR/f34
1110 $LFIND $DIR/f34 2>&1 | grep -q "no stripe info" || error
1111 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1113 run_test 34b "O_RDONLY opening file doesn't create objects ====="
1116 [ ! -f $DIR/f34 ] && test_34a
1117 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1118 $OPENFILE -f O_RDWR $DIR/f34
1119 $LFIND $DIR/f34 2>&1 | grep -q "no stripe info" && error
1120 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1122 run_test 34c "O_RDWR opening file-with-size works =============="
1125 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
1126 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1129 run_test 34d "write to sparse file ============================="
1133 $MCREATE $DIR/f34e || error
1134 $TRUNCATE $DIR/f34e 1000 || error
1135 $CHECKSTAT -s 1000 $DIR/f34e || error
1136 $OPENFILE -f O_RDWR $DIR/f34e
1137 $CHECKSTAT -s 1000 $DIR/f34e || error
1139 run_test 34e "create objects, some with size and some without =="
1142 cp /bin/sh $DIR/f35a
1144 chown $RUNAS_ID $DIR/f35a
1145 $RUNAS $DIR/f35a && error || true
1148 run_test 35a "exec file with mode 444 (should return and not leak) ====="
1152 utime $DIR/f36 || error
1154 run_test 36a "MDS utime check (mknod, utime) ==================="
1158 utime $DIR/f36 || error
1160 run_test 36b "OST utime check (open, utime) ===================="
1165 chown $RUNAS_ID $DIR/d36
1166 $RUNAS utime $DIR/d36/f36 || error
1168 run_test 36c "non-root MDS utime check (mknod, utime) =========="
1171 [ ! -d $DIR/d36 ] && test_36c
1172 echo "" > $DIR/d36/f36
1173 $RUNAS utime $DIR/d36/f36 || error
1175 run_test 36d "non-root OST utime check (open, utime) ==========="
1178 [ $RUNAS_ID -eq $UID ] && return
1179 [ ! -d $DIR/d36 ] && mkdir $DIR/d36
1181 $RUNAS utime $DIR/d36/f36e && error "utime worked, want failure" || true
1183 run_test 36e "utime on non-owned file (should return error) ===="
1186 mkdir -p $DIR/dextra
1187 echo f > $DIR/dextra/fbugfile
1188 mount -t ext2 -o loop $EXT2_DEV $DIR/dextra
1189 ls $DIR/dextra | grep "\<fbugfile\>" && error
1190 umount $DIR/dextra || error
1191 rm -f $DIR/dextra/fbugfile || error
1193 run_test 37 "ls a mounted file system to check old content ====="
1196 o_directory $DIR/test38
1198 run_test 38 "open a regular file with O_DIRECTORY =============="
1201 touch $DIR/test_39_file
1202 touch $DIR/test_39_file2
1203 # ls -l $DIR/test_39_file $DIR/test_39_file2
1204 # ls -lu $DIR/test_39_file $DIR/test_39_file2
1205 # ls -lc $DIR/test_39_file $DIR/test_39_file2
1207 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/test_39_file2
1208 # ls -l $DIR/test_39_file $DIR/test_39_file2
1209 # ls -lu $DIR/test_39_file $DIR/test_39_file2
1210 # ls -lc $DIR/test_39_file $DIR/test_39_file2
1211 [ $DIR/test_39_file2 -nt $DIR/test_39_file ] || error
1213 run_test 39 "mtime changed on create ==========================="
1216 dd if=/dev/zero of=$DIR/f40 bs=4096 count=1
1217 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/f40 && error
1218 $CHECKSTAT -t file -s 4096 $DIR/f40 || error
1220 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
1224 small_write $DIR/f41 18
1226 run_test 41 "test small file write + fstat ====================="
1228 count_ost_writes() {
1229 cat /proc/fs/lustre/osc/*/stats |
1230 awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }'
1233 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs
1234 kill -CONT `pidof kupdated`
1237 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
1238 kill -STOP `pidof kupdated`
1239 trap start_kupdated EXIT
1242 # ensure that all stripes have some grant before we test client-side cache
1243 for i in `seq -f $DIR/f42-%g 1 $STRIPECOUNT`; do
1244 dd if=/dev/zero of=$i bs=4k count=1
1248 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
1249 # file truncation, and file removal.
1251 cancel_lru_locks OSC
1253 sync; sleep 1; sync # just to be safe
1254 BEFOREWRITES=`count_ost_writes`
1255 grep [0-9] /proc/fs/lustre/osc/OSC*MNT*/cur_grant_bytes
1256 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
1257 AFTERWRITES=`count_ost_writes`
1258 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
1259 error "$BEFOREWRITES < $AFTERWRITES"
1262 run_test 42a "ensure that we don't flush on close =============="
1265 cancel_lru_locks OSC
1268 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
1269 BEFOREWRITES=`count_ost_writes`
1270 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
1271 AFTERWRITES=`count_ost_writes`
1272 [ $BEFOREWRITES -eq $AFTERWRITES ] ||
1273 error "$BEFOREWRITES < $AFTERWRITES on unlink"
1274 BEFOREWRITES=`count_ost_writes`
1275 sync || error "sync: $?"
1276 AFTERWRITES=`count_ost_writes`
1277 [ $BEFOREWRITES -eq $AFTERWRITES ] ||
1278 error "$BEFOREWRITES < $AFTERWRITES on sync"
1279 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
1283 run_test 42b "test destroy of file with cached dirty data ======"
1285 # if these tests just want to test the effect of truncation,
1286 # they have to be very careful. consider:
1287 # - the first open gets a {0,EOF}PR lock
1288 # - the first write conflicts and gets a {0, count-1}PW
1289 # - the rest of the writes are under {count,EOF}PW
1290 # - the open for truncate tries to match a {0,EOF}PR
1291 # for the filesize and cancels the PWs.
1292 # any number of fixes (don't get {0,EOF} on open, match
1293 # composite locks, do smarter file size management) fix
1294 # this, but for now we want these tests to verify that
1295 # the cancellation with truncate intent works, so we
1296 # start the file with a full-file pw lock to match against
1297 # until the truncate.
1302 cancel_lru_locks OSC
1304 # prime the file with 0,EOF PW to match
1308 # now the real test..
1309 dd if=/dev/zero of=$file bs=1024 count=100
1310 BEFOREWRITES=`count_ost_writes`
1311 $TRUNCATE $file $offset
1312 cancel_lru_locks OSC
1313 AFTERWRITES=`count_ost_writes`
1319 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
1320 error "$BEFOREWRITES < $AFTERWRITES on truncate"
1323 run_test 42c "test partial truncate of file with cached dirty data"
1327 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
1328 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
1331 run_test 42d "test complete truncate of file with cached dirty data"
1335 cp -p /bin/ls $DIR/d43/f
1336 exec 100>> $DIR/d43/f
1337 $DIR/d43/f && error || true
1340 run_test 43 "execution of file opened for write should return -ETXTBSY"
1344 cp -p `which multiop` $DIR/d43/multiop
1345 $DIR/d43/multiop $TMP/test43.junk O_c &
1348 multiop $DIR/d43/multiop Oc && error "expected error, got success"
1349 kill -USR1 $MULTIPID || return 2
1350 wait $MULTIPID || return 3
1352 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
1356 cp -p `which multiop` $DIR/d43/multiop
1357 $DIR/d43/multiop $TMP/test43.junk O_c &
1360 truncate $DIR/d43/multiop 0 && error "expected error, got success"
1361 kill -USR1 $MULTIPID || return 2
1362 wait $MULTIPID || return 3
1364 run_test 43b "truncate of file being executed should return -ETXTBSY"
1367 local testdir="$DIR/d43c"
1370 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
1371 ( cd $testdir && md5sum -c)
1373 run_test 43c "md5sum of copy into lustre========================"
1376 [ "$STRIPECOUNT" -lt "2" ] && echo "skipping 2-stripe test" && return
1377 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=127
1378 dd if=$DIR/f1 bs=4k count=1
1380 run_test 44 "zero length read from a sparse stripe ============="
1383 local nstripe=`$LCTL lov_getconfig $DIR | grep default_stripe_count: | \
1385 local stride=`$LCTL lov_getconfig $DIR | grep default_stripe_size: | \
1387 if [ $nstripe -eq 0 ] ; then
1388 nstripe=`$LCTL lov_getconfig $DIR | grep obd_count: | awk '{print $2}'`
1391 OFFSETS="0 $((stride/2)) $((stride-1))"
1392 for offset in $OFFSETS ; do
1393 for i in `seq 0 $((nstripe-1))`; do
1395 local GLOBALOFFSETS=""
1396 local size=$((((i + 2 * $nstripe )*$stride + $offset))) # Bytes
1397 ll_sparseness_write $DIR/d44a $size || error "ll_sparseness_write"
1398 GLOBALOFFSETS="$GLOBALOFFSETS $size"
1399 ll_sparseness_verify $DIR/d44a $GLOBALOFFSETS \
1400 || error "ll_sparseness_verify $GLOBALOFFSETS"
1402 for j in `seq 0 $((nstripe-1))`; do
1403 size=$((((j + $nstripe )*$stride + $offset))) # Bytes
1404 ll_sparseness_write $DIR/d44a $size || error "ll_sparseness_write"
1405 GLOBALOFFSETS="$GLOBALOFFSETS $size"
1407 ll_sparseness_verify $DIR/d44a $GLOBALOFFSETS \
1408 || error "ll_sparseness_verify $GLOBALOFFSETS"
1412 run_test 44a "test sparse pwrite ==============================="
1416 for d in /proc/fs/lustre/osc/*/cur_dirty_bytes; do
1417 tot=$(($tot + `cat $d`))
1422 before=`dirty_osc_total`
1423 echo executing "\"$*\""
1425 after=`dirty_osc_total`
1426 echo before $before, after $after
1430 # Obtain grants from OST if it supports it
1431 echo blah > ${f}_grant
1434 do_dirty_record "echo blah > $f"
1435 [ $before -eq $after ] && error "write wasn't cached"
1436 do_dirty_record "> $f"
1437 [ $before -gt $after ] || error "truncate didn't lower dirty count"
1438 do_dirty_record "echo blah > $f"
1439 [ $before -eq $after ] && error "write wasn't cached"
1440 do_dirty_record "sync"
1441 [ $before -gt $after ] || error "writeback didn't lower dirty count"
1442 do_dirty_record "echo blah > $f"
1443 [ $before -eq $after ] && error "write wasn't cached"
1444 do_dirty_record "cancel_lru_locks OSC"
1445 [ $before -gt $after ] || error "lock cancellation didn't lower dirty count"
1448 run_test 45 "osc io page accounting ============================"
1454 # in a 2 stripe file (lov.sh), page 63 maps to page 31 in its object. this
1455 # test tickles a bug where re-dirtying a page was failing to be mapped to the
1456 # objects offset and an assert hit when an rpc was built with 63's mapped
1457 # offset 31 and 31's raw 31 offset. it also found general redirtying bugs.
1462 dd if=/dev/zero of=$f bs=`page_size` seek=31 count=1
1464 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=63 count=1
1465 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=31 count=1
1469 run_test 46 "dirtying a previously written page ================"
1471 # Check that device nodes are created and then visible correctly (#2091)
1473 cmknod $DIR/test_47_node || error
1475 run_test 47 "Device nodes check ================================"
1480 mv $DIR/d48 $DIR/d48.new || error "move directory failed"
1481 mkdir $DIR/d48 || error "recreate diectory failed"
1482 ls || error "can't list after recreate directory"
1484 run_test 48 "Access renamed current working directory =========="
1490 ls /proc/$$/cwd || error
1492 run_test 50 "special situations: /proc symlinks ==============="
1495 # bug 1516 - create an empty entry right after ".." then split dir
1498 $MCREATE $DIR/d49/bar
1500 createmany -m $DIR/d49/longfile 201
1502 while [ `ls -sd $DIR/d49 | awk '{ print $1 }'` -eq 4 ]; do
1503 $MCREATE $DIR/d49/longfile$FNUM
1507 ls -l $DIR/d49 > /dev/null || error
1509 run_test 51 "special situations: split htree with empty entry =="
1512 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
1515 chattr =a $DIR/d52a/foo || error
1516 echo bar >> $DIR/d52a/foo || error
1517 cp /etc/hosts $DIR/d52a/foo && error
1518 rm -f $DIR/d52a/foo 2>/dev/null && error
1519 link $DIR/d52a/foo $DIR/d52a/foo_link 2>/dev/null && error
1520 echo foo >> $DIR/d52a/foo || error
1521 mrename $DIR/d52a/foo $DIR/d52a/foo_ren && error
1522 lsattr $DIR/d52a/foo | egrep -q "^-+a-+ $DIR/d52a/foo" || error
1523 chattr -a $DIR/d52a/foo || error
1525 rm -fr $DIR/d52a || error
1527 run_test 52a "append-only flag test (should return errors) ====="
1530 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
1533 chattr =i $DIR/d52b/foo || error
1534 cat test > $DIR/d52b/foo && error
1535 cp /etc/hosts $DIR/d52b/foo && error
1536 rm -f $DIR/d52b/foo 2>/dev/null && error
1537 link $DIR/d52b/foo $DIR/d52b/foo_link 2>/dev/null && error
1538 echo foo >> $DIR/d52b/foo && error
1539 mrename $DIR/d52b/foo $DIR/d52b/foo_ren && error
1540 [ -f $DIR/d52b/foo ] || error
1541 [ -f $DIR/d52b/foo_ren ] && error
1542 lsattr $DIR/d52b/foo | egrep -q "^-+i-+ $DIR/d52b/foo" || error
1543 chattr -i $DIR/d52b/foo || error
1545 rm -fr $DIR/d52b || error
1547 run_test 52b "immutable flag test (should return errors) ======="
1550 for i in `ls -d /proc/fs/lustre/osc/OSC*mds1 2> /dev/null` ; do
1551 ostname=`echo $i | cut -d _ -f 3-4 | sed -e s/_mds1//`
1552 ost_last=`cat /proc/fs/lustre/obdfilter/$ostname/last_id`
1553 mds_last=`cat $i/prealloc_last_id`
1554 echo "$ostname.last_id=$ost_last ; MDS.last_id=$mds_last"
1555 if [ $ost_last != $mds_last ]; then
1556 error "$ostname.last_id=$ost_last ; MDS.last_id=$mds_last"
1560 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
1563 $SOCKETSERVER $DIR/socket &
1565 $SOCKETCLIENT $DIR/socket || error
1566 $MUNLINK $DIR/socket
1568 run_test 54 "unix damain socket test ==========================="
1573 mount -t ext3 -o loop,iopen $EXT3_DEV $DIR/d55 || error
1575 $IOPENTEST1 $DIR/d55/foo $DIR/d55 || error
1576 $IOPENTEST2 $DIR/d55 || error
1577 echo "check for $EXT3_DEV. Please wait..."
1579 umount $DIR/d55 || error
1581 run_test 55 "check iopen_connect_dentry()======================="
1588 NUMFILESx2=$(($NUMFILES * 2))
1589 for i in `seq 1 $NUMFILES` ; do
1590 touch $DIR/d56/file$i
1591 touch $DIR/d56/dir/file$i
1594 # test lfs find with --recursive
1595 FILENUM=`$LFIND --recursive $DIR/d56 | grep -c obdidx`
1596 [ $FILENUM -eq $NUMFILESx2 ] || error \
1597 "lfs find --recursive $DIR/d56 wrong: found $FILENUM, expected $NUMFILESx2"
1598 FILENUM=`$LFIND $DIR/d56 | grep -c obdidx`
1599 [ $FILENUM -eq $NUMFILES ] || error \
1600 "lfs find $DIR/d56 without --recursive wrong: found $FILENUM,
1602 echo "lfs find --recursive passed."
1604 # test lfs find with file instead of dir
1605 FILENUM=`$LFIND $DIR/d56/file1 | grep -c obdidx`
1606 [ $FILENUM -eq 1 ] || error \
1607 "lfs find $DIR/d56/file1 wrong:found $FILENUM, expected 1"
1608 echo "lfs find file passed."
1610 #test lfs find with --verbose
1611 [ `$LFIND --verbose $DIR/d56 | grep -c lmm_magic` -eq $NUMFILES ] ||\
1612 error "lfs find --verbose $DIR/d56 wrong: should find $NUMFILES lmm_magic info"
1613 [ `$LFIND $DIR/d56 | grep -c lmm_magic` -eq 0 ] || error \
1614 "lfs find $DIR/d56 without --verbose wrong: should not show lmm_magic info"
1615 echo "lfs find --verbose passed."
1617 #test lfs find with --obd
1618 $LFIND --obd wrong_uuid $DIR/d56 2>&1 | grep -q "unknown obduuid" || \
1619 error "lfs find --obd wrong_uuid should return error information"
1621 [ "$STRIPECOUNT" -lt 2 ] && \
1622 echo "skipping other lfs find --obd test" && return
1623 FILENUM=`$LFIND --recursive $DIR/d56 | sed -n '/^[ ]*1[ ]/p' | wc -l`
1624 OBDUUID=`$LFIND --recursive $DIR/d56 | sed -n '/^[ ]*1:/p' | awk '{print $2}'`
1625 FOUND=`$LFIND -r --obd $OBDUUID $DIR/d56 | wc -l`
1626 [ $FOUND -eq $FILENUM ] || \
1627 error "lfs find --obd wrong: found $FOUND, expected $FILENUM"
1628 [ `$LFIND -r -v --obd $OBDUUID $DIR/d56 | sed '/^[ ]*1[ ]/d' | \
1629 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l` -eq 0 ] || \
1630 error "lfs find --obd wrong: should not show file on other obd"
1631 echo "lfs find --obd passed."
1633 run_test 56 "check lfs find ===================================="
1636 # note test will not do anything if MDS is not local
1637 for DEV in `cat /proc/fs/lustre/mds/*/mntdev`; do
1638 dumpe2fs -h $DEV > $TMP/t57a.dump || error "can't access $DEV"
1639 DEVISIZE=`awk '/Inode size:/ { print $3 }' $TMP/t57a.dump`
1640 [ "$DEVISIZE" -gt 128 ] || error "inode size $DEVISIZE"
1644 run_test 57a "verify MDS filesystem created with large inodes =="
1649 FILEN=$DIR/d57b/f$FILECOUNT
1650 rm -rf $DIR/d57b || error "removing $DIR/d57b"
1651 mkdir -p $DIR/d57b || error "creating $DIR/d57b"
1652 echo "mcreating $FILECOUNT files"
1653 createmany -m $DIR/d57b/f 1 $FILECOUNT || \
1654 error "creating files in $DIR/d57b"
1656 # verify that files do not have EAs yet
1657 $LFIND $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
1658 $LFIND $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
1660 MDSFREE="`cat /proc/fs/lustre/mds/*/kbytesfree`"
1661 MDCFREE="`cat /proc/fs/lustre/mdc/*/kbytesfree`"
1662 echo "opening files to create objects/EAs"
1663 for FILE in `seq -f $DIR/d57b/f%g 1 $FILECOUNT`; do
1664 $OPENFILE -f O_RDWR $FILE > /dev/null || error "opening $FILE"
1667 # verify that files have EAs now
1668 $LFIND $FILE1 | grep -q "obdidx" || error "$FILE1 missing EA"
1669 $LFIND $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
1671 MDSFREE2="`cat /proc/fs/lustre/mds/*/kbytesfree`"
1672 MDCFREE2="`cat /proc/fs/lustre/mdc/*/kbytesfree`"
1673 if [ "$MDCFREE" != "$MDCFREE2" ]; then
1674 if [ "$MDSFREE" != "$MDSFREE2" ]; then
1675 error "MDC before $MDCFREE != after $MDCFREE2"
1677 echo "MDC before $MDCFREE != after $MDCFREE2"
1678 echo "unable to confirm if MDS has large inodes"
1683 run_test 57b "default LOV EAs are stored inside large inodes ==="
1688 run_test 58 "verify cross-platform wire constants =============="
1691 echo "touch 130 files"
1692 for i in `seq 1 130` ; do
1696 for i in `seq 1 130` ; do
1701 # wait for commitment of removal
1703 run_test 59 "verify cancellation of llog records async ========="
1706 echo 60 "llog tests run from kernel mode"
1709 run_test 60 "llog sanity tests run from kernel module =========="
1713 dd if=/dev/zero of=$f bs=`page_size` count=1
1714 cancel_lru_locks OSC
1715 multiop $f OSMWUc || error
1718 run_test 61 "mmap() writes don't make sync hang ================"
1720 # bug 2330 - insufficient obd_match error checking causes LBUG
1724 cancel_lru_locks OSC
1725 echo 0x405 > /proc/sys/lustre/fail_loc
1726 cat $f && error "cat succeeded, expect -EIO"
1727 echo 0 > /proc/sys/lustre/fail_loc
1729 run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
1731 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
1733 MAX_DIRTY_MB=`cat /proc/fs/lustre/osc/*/max_dirty_mb | head -1`
1734 for i in /proc/fs/lustre/osc/*/max_dirty_mb ; do
1737 for i in `seq 10` ; do
1738 dd if=/dev/zero of=$DIR/f63 bs=8k &
1744 for i in /proc/fs/lustre/osc/*/max_dirty_mb ; do
1745 echo $MAX_DIRTY_MB > $i
1749 run_test 63 "Verify oig_wait interruption does not crash ======"
1753 grep "[0-9]" /proc/fs/lustre/osc/OSC*MNT*/cur*
1755 run_test 64a "verify filter grant calculations (in kernel) ======"
1760 run_test 64b "check out-of-space detection on client ============"
1762 # on the LLNL clusters, runas will still pick up root's $TMP settings,
1763 # which will not be writable for the runas user, and then you get a CVS
1764 # error message with a corrupt path string (CVS bug) and panic.
1765 # We're not using much space, so just stick it in /tmp, which is safe.
1771 [ $RUNAS_ID -ne $UID ] && HOME=/tmp
1774 mkdir -p $DIR/d99cvsroot
1775 chown $RUNAS_ID $DIR/d99cvsroot
1776 $RUNAS cvs -d $DIR/d99cvsroot init || error
1778 run_test 99a "cvs init ========================================="
1781 [ ! -d $DIR/d99cvsroot ] && test_99a
1783 $RUNAS cvs -d $DIR/d99cvsroot import -m "nomesg" d99reposname vtag rtag
1785 run_test 99b "cvs import ======================================="
1788 [ ! -d $DIR/d99cvsroot ] && test_99b
1790 mkdir -p $DIR/d99reposname
1791 chown $RUNAS_ID $DIR/d99reposname
1792 $RUNAS cvs -d $DIR/d99cvsroot co d99reposname
1794 run_test 99c "cvs checkout ====================================="
1797 [ ! -d $DIR/d99cvsroot ] && test_99c
1798 cd $DIR/d99reposname
1800 $RUNAS cvs add -m 'addmsg' foo99
1802 run_test 99d "cvs add =========================================="
1805 [ ! -d $DIR/d99cvsroot ] && test_99c
1806 cd $DIR/d99reposname
1809 run_test 99e "cvs update ======================================="
1812 [ ! -d $DIR/d99cvsroot ] && test_99d
1813 cd $DIR/d99reposname
1814 $RUNAS cvs commit -m 'nomsg' foo99
1816 run_test 99f "cvs commit ======================================="
1822 log "cleanup: ======================================================"
1823 if [ "`mount | grep ^$NAME`" ]; then
1824 rm -rf $DIR/[Rdfs][1-9]*
1825 if [ "$I_MOUNTED" = "yes" ]; then
1826 sh llmountcleanup.sh || error
1830 echo '=========================== finished ==============================='
1831 [ -f "$SANITYLOG" ] && cat $SANITYLOG && exit 1 || true