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: 2108
11 RENAME_TESTS="24a 24b 24c 24d 24e 24f 24g 24h 24i 24j 24k 24l 24m 24n 24o 48a 48d"
12 ALWAYS_EXCEPT=${ALWAYS_EXCEPT:-"$RENAME_TESTS 58"}
13 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
15 2.6.*) ALWAYS_EXCEPT="$ALWAYS_EXCEPT 54c 55" # bug 3117
18 [ "$ALWAYS_EXCEPT$EXCEPT" ] && echo "Skipping tests: $ALWAYS_EXCEPT $EXCEPT"
21 export PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH
24 FSTYPE=${FSTYPE:-ext3}
26 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
27 CREATETEST=${CREATETEST:-createtest}
29 LSTRIPE=${LSTRIPE:-"$LFS setstripe"}
30 LFIND=${LFIND:-"$LFS find"}
31 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
33 MCREATE=${MCREATE:-mcreate}
34 OPENFILE=${OPENFILE:-openfile}
35 OPENUNLINK=${OPENUNLINK:-openunlink}
36 TOEXCL=${TOEXCL:-toexcl}
37 TRUNCATE=${TRUNCATE:-truncate}
38 MUNLINK=${MUNLINK:-munlink}
39 SOCKETSERVER=${SOCKETSERVER:-socketserver}
40 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
41 IOPENTEST1=${IOPENTEST1:-iopentest1}
42 IOPENTEST2=${IOPENTEST2:-iopentest2}
44 if [ $UID -ne 0 ]; then
48 RUNAS_ID=${RUNAS_ID:-500}
49 RUNAS=${RUNAS:-"runas -u $RUNAS_ID"}
52 export NAME=${NAME:-local}
58 sh llmountcleanup.sh > /dev/null || exit 20
65 sh llrmount.sh > /dev/null || exit 10
73 lctl mark "$*" 2> /dev/null || true
78 strace -o $TMP/$1.strace -ttt $*
80 log "FINISHED: $*: rc $RC"
85 check_kernel_version() {
86 VERSION_FILE=/proc/fs/lustre/kernel_version
88 [ ! -f $VERSION_FILE ] && echo "can't find kernel version" && return 1
89 GOT_VER=`cat $VERSION_FILE`
90 [ $GOT_VER -ge $WANT_VER ] && return 0
91 log "test needs at least kernel version $WANT_VER, running $GOT_VER"
96 if ! mount | grep -q $DIR; then
99 echo -1 >/proc/sys/portals/debug
101 export TESTNAME=test_$1
102 test_$1 || error "test_$1: exit with rc=$?"
109 build_test_filter() {
113 for E in $EXCEPT $ALWAYS_EXCEPT; do
114 eval EXCEPT_${E}=true
123 IFS=abcdefghijklmnopqrstuvwxyz _basetest $1
130 if [ ${!testname}x != x ]; then
135 if [ ${!testname}x != x ]; then
143 if [ ${!testname}x != x ]; then
144 echo "skipping excluded test $1"
147 testname=EXCEPT_$base
148 if [ ${!testname}x != x ]; then
149 echo "skipping excluded test $1 (base $base)"
156 [ "$SANITYLOG" ] && rm -f $SANITYLOG || true
160 if [ "$SANITYLOG" ]; then
161 echo "FAIL: $TESTNAME $@" >> $SANITYLOG
171 MOUNT="`mount | awk '/^'$NAME' .* lustre_lite / { print $3 }'`"
172 if [ -z "$MOUNT" ]; then
174 MOUNT="`mount | awk '/^'$NAME' .* lustre_lite / { print $3 }'`"
175 [ -z "$MOUNT" ] && error "NAME=$NAME not mounted"
179 [ `echo $MOUNT | wc -w` -gt 1 ] && error "NAME=$NAME mounted more than once"
182 [ -z "`echo $DIR | grep $MOUNT`" ] && echo "$DIR not in $MOUNT" && exit 99
184 OSTCOUNT=`cat /proc/fs/lustre/llite/fs0/lov/numobd`
185 STRIPECOUNT=`cat /proc/fs/lustre/llite/fs0/lov/stripecount`
186 STRIPESIZE=`cat /proc/fs/lustre/llite/fs0/lov/stripesize`
188 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
189 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
190 rm -rf $DIR/[Rdfs][1-9]*
194 echo preparing for tests involving mounts
195 EXT2_DEV=${EXT2_DEV:-/tmp/SANITY.LOOP}
197 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
201 $CHECKSTAT -t file $DIR/f || error
203 $CHECKSTAT -a $DIR/f || error
205 run_test 0 "touch .../f ; rm .../f ============================="
210 $CHECKSTAT -t dir $DIR/d1/d2 || error
212 run_test 1a "mkdir .../d1; mkdir .../d1/d2 ====================="
217 $CHECKSTAT -a $DIR/d1 || error
219 run_test 1b "rmdir .../d1/d2; rmdir .../d1 ====================="
224 $CHECKSTAT -t file $DIR/d2/f || error
226 run_test 2a "mkdir .../d2; touch .../d2/f ======================"
230 $CHECKSTAT -a $DIR/d2 || error
232 run_test 2b "rm -r .../d2; checkstat .../d2/f ======================"
236 $CHECKSTAT -t dir $DIR/d3 || error
238 run_test 3a "mkdir .../d3 ======================================"
241 if [ ! -d $DIR/d3 ]; then
245 $CHECKSTAT -t file $DIR/d3/f || error
247 run_test 3b "touch .../d3/f ===================================="
251 $CHECKSTAT -a $DIR/d3 || error
253 run_test 3c "rm -r .../d3 ======================================"
257 $CHECKSTAT -t dir $DIR/d4 || error
259 run_test 4a "mkdir .../d4 ======================================"
262 if [ ! -d $DIR/d4 ]; then
266 $CHECKSTAT -t dir $DIR/d4/d2 || error
268 run_test 4b "mkdir .../d4/d2 ==================================="
273 chmod 0707 $DIR/d5/d2
274 $CHECKSTAT -t dir -p 0707 $DIR/d5/d2 || error
276 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2 ============"
280 chmod 0666 $DIR/f6a || error
281 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/f6a || error
283 run_test 6a "touch .../f6a; chmod .../f6a ======================"
286 [ $RUNAS_ID -eq $UID ] && echo "skipping test 6b" && return
287 if [ ! -f $DIR/f6a ]; then
291 $RUNAS chmod 0444 $DIR/f6a && error
292 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/f6a || error
294 run_test 6b "$RUNAS chmod .../f6a (should return error) =="
297 [ $RUNAS_ID -eq $UID ] && echo "skipping test 6c" && return
299 chown $RUNAS_ID $DIR/f6c || error
300 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/f6c || error
302 run_test 6c "touch .../f6c; chown .../f6c ======================"
305 [ $RUNAS_ID -eq $UID ] && echo "skipping test 6d" && return
306 if [ ! -f $DIR/f6c ]; then
308 chown $RUNAS_ID $DIR/f6c
310 $RUNAS chown $UID $DIR/f6c && error
311 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/f6c || error
313 run_test 6d "$RUNAS chown .../f6c (should return error) =="
316 [ $RUNAS_ID -eq $UID ] && echo "skipping test 6e" && return
318 chgrp $RUNAS_ID $DIR/f6e || error
319 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/f6e || error
321 run_test 6e "touch .../f6e; chgrp .../f6e ======================"
324 [ $RUNAS_ID -eq $UID ] && echo "skipping test 6f" && return
325 if [ ! -f $DIR/f6e ]; then
327 chgrp $RUNAS_ID $DIR/f6e
329 $RUNAS chgrp $UID $DIR/f6e && error
330 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/f6e || error
332 run_test 6f "$RUNAS chgrp .../f6e (should return error) =="
335 [ $RUNAS_ID -eq $UID ] && echo "skipping test 6g" && return
336 mkdir $DIR/d6g || error
337 chmod 777 $DIR/d6g || error
338 $RUNAS mkdir $DIR/d6g/d || error
339 chmod g+s $DIR/d6g/d || error
340 mkdir $DIR/d6g/d/subdir
341 $CHECKSTAT -g \#$RUNAS_ID $DIR/d6g/d/subdir || error
343 run_test 6g "Is new dir in sgid dir inheriting group?"
349 $CHECKSTAT -t file -p 0666 $DIR/d7/f || error
351 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
354 if [ ! -d $DIR/d7 ]; then
358 echo -n foo > $DIR/d7/f2
359 [ "`cat $DIR/d7/f2`" = "foo" ] || error
360 $CHECKSTAT -t file -s 3 $DIR/d7/f2 || error
362 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
368 $CHECKSTAT -t file -p 0666 $DIR/d8/f || error
370 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
376 $CHECKSTAT -t dir $DIR/d9/d2/d3 || error
378 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
384 $CHECKSTAT -t file $DIR/d10/d2/f || error
386 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
391 chmod 0666 $DIR/d11/d2
392 chmod 0705 $DIR/d11/d2
393 $CHECKSTAT -t dir -p 0705 $DIR/d11/d2 || error
395 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
400 chmod 0666 $DIR/d12/f
401 chmod 0654 $DIR/d12/f
402 $CHECKSTAT -t file -p 0654 $DIR/d12/f || error
404 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
408 dd if=/dev/zero of=$DIR/d13/f count=10
410 $CHECKSTAT -t file -s 0 $DIR/d13/f || error
412 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
418 $CHECKSTAT -a $DIR/d14/f || error
420 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
425 mv $DIR/d15/f $DIR/d15/f2
426 $CHECKSTAT -t file $DIR/d15/f2 || error
428 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
434 $CHECKSTAT -a $DIR/d16/f || error
436 run_test 16 "touch .../d16/f; rm -rf .../d16/f ================="
441 ln -s $DIR/d17/f $DIR/d17/l-exist
443 $CHECKSTAT -l $DIR/d17/f $DIR/d17/l-exist || error
444 $CHECKSTAT -f -t f $DIR/d17/l-exist || error
446 $CHECKSTAT -a $DIR/l-exist || error
448 run_test 17a "symlinks: create, remove (real) =================="
451 if [ ! -d $DIR/d17 ]; then
454 ln -s no-such-file $DIR/d17/l-dangle
456 $CHECKSTAT -l no-such-file $DIR/d17/l-dangle || error
457 $CHECKSTAT -fa $DIR/d17/l-dangle || error
459 $CHECKSTAT -a $DIR/l-dangle || error
461 run_test 17b "symlinks: create, remove (dangling) =============="
467 run_test 18 "touch .../f ; ls ... =============================="
473 $CHECKSTAT -a $DIR/f19 || error
475 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
478 ls -l $DIR/f19 && error || true
480 run_test 19b "ls -l .../f19 (should return error) =============="
483 [ $RUNAS_ID -eq $UID ] && echo "skipping test 19c" && return
484 $RUNAS touch $DIR/f19 && error || true
486 run_test 19c "$RUNAS touch .../f19 (should return error) =="
489 cat $DIR/f19 && error || true
491 run_test 19d "cat .../f19 (should return error) =============="
503 $CHECKSTAT -a $DIR/f || error
505 run_test 20 "touch .../f ; ls -l ... ==========================="
509 [ -f $DIR/d21/dangle ] && rm -f $DIR/d21/dangle
510 ln -s dangle $DIR/d21/link
511 echo foo >> $DIR/d21/link
513 $CHECKSTAT -t link $DIR/d21/link || error
514 $CHECKSTAT -f -t file $DIR/d21/link || error
516 run_test 21 "write to dangling link ============================"
520 chown $RUNAS_ID $DIR/d22
521 # Tar gets pissy if it can't access $PWD *sigh*
523 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
524 $RUNAS tar xfC - $DIR/d22)
526 $CHECKSTAT -t dir $DIR/d22/etc || error
527 $CHECKSTAT -u \#$RUNAS_ID $DIR/d22/etc || error
529 run_test 22 "unpack tar archive as non-root user ==============="
534 $TOEXCL -e $DIR/d23/f23 || error
536 run_test 23 "O_CREAT|O_EXCL in subdir =========================="
539 echo '== rename sanity =============================================='
540 echo '-- same directory rename'
543 mv $DIR/R1/f $DIR/R1/g
544 $CHECKSTAT -t file $DIR/R1/g || error
546 run_test 24a "touch .../R1/f; rename .../R1/f .../R1/g ========="
551 mv $DIR/R2/f $DIR/R2/g
552 $CHECKSTAT -a $DIR/R2/f || error
553 $CHECKSTAT -t file $DIR/R2/g || error
555 run_test 24b "touch .../R2/{f,g}; rename .../R2/f .../R2/g ====="
560 mv $DIR/R3/f $DIR/R3/g
561 $CHECKSTAT -a $DIR/R3/f || error
562 $CHECKSTAT -t dir $DIR/R3/g || error
564 run_test 24c "mkdir .../R3/f; rename .../R3/f .../R3/g ========="
569 perl -e "rename \"$DIR/R4/f\", \"$DIR/R4/g\";"
570 $CHECKSTAT -a $DIR/R4/f || error
571 $CHECKSTAT -t dir $DIR/R4/g || error
573 run_test 24d "mkdir .../R4/{f,g}; rename .../R4/f .../R4/g ====="
576 echo '-- cross directory renames --'
579 mv $DIR/R5a/f $DIR/R5b/g
580 $CHECKSTAT -a $DIR/R5a/f || error
581 $CHECKSTAT -t file $DIR/R5b/g || error
583 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
587 touch $DIR/R6a/f $DIR/R6b/g
588 mv $DIR/R6a/f $DIR/R6b/g
589 $CHECKSTAT -a $DIR/R6a/f || error
590 $CHECKSTAT -t file $DIR/R6b/g || error
592 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
597 mv $DIR/R7a/d $DIR/R7b/e
598 $CHECKSTAT -a $DIR/R7a/d || error
599 $CHECKSTAT -t dir $DIR/R7b/e || error
601 run_test 24g "mkdir .../R7a/d; rename .../R7a/d .../R5b/e ======"
605 mkdir $DIR/R8a/d $DIR/R8b/e
606 perl -e "rename \"$DIR/R8a/d\", \"$DIR/R8b/e\";"
607 $CHECKSTAT -a $DIR/R8a/d || error
608 $CHECKSTAT -t dir $DIR/R8b/e || error
610 run_test 24h "mkdir .../R8{a,b} R8a/{d,e}; mv .../R8a/d .../R8b/e"
613 echo "-- rename error cases"
617 perl -e "rename \"$DIR/R9/f\", \"$DIR/R9/a\";"
618 $CHECKSTAT -t file $DIR/R9/f || error
619 $CHECKSTAT -t dir $DIR/R9/a || error
620 $CHECKSTAT -a file $DIR/R9/a/f || error
622 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
626 perl -e "rename \"$DIR/R10/f\", \"$DIR/R10/g\""
627 $CHECKSTAT -t dir $DIR/R10 || error
628 $CHECKSTAT -a $DIR/R10/f || error
629 $CHECKSTAT -a $DIR/R10/g || error
631 run_test 24j "source does not exist ============================"
634 mkdir $DIR/R11a $DIR/R11a/d
636 mv $DIR/R11a/f $DIR/R11a/d
637 $CHECKSTAT -a $DIR/R11a/f || error
638 $CHECKSTAT -t file $DIR/R11a/d/f || error
640 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
642 # bug 2429 - rename foo foo foo creates invalid file
645 multiop $f OcNs || error
647 run_test 24l "Renaming a file to itself ========================"
651 multiop $f OcLN ${f}2 ${f}2 || error
653 run_test 24m "Renaming a file to a hard link to itself ========="
657 # this stats the old file after it was renamed, so it should fail
661 $CHECKSTAT ${f}.rename
664 run_test 24n "Statting the old file after renameing (Posix rename 2)"
667 check_kernel_version 37 || return 0
668 rename_many -s 3287 -v -n 10 $DIR
670 run_test 24o "rename of files during htree split ==============="
673 echo '== symlink sanity ============================================='
676 touch $DIR/s25/foo || error
678 run_test 25a "create file in symlinked directory ==============="
681 [ ! -d $DIR/d25 ] && test_25a
682 $CHECKSTAT -t file $DIR/s25/foo || error
684 run_test 25b "lookup file in symlinked directory ==============="
689 ln -s d26/d26-2 $DIR/s26
690 touch $DIR/s26/foo || error
692 run_test 26a "multiple component symlink ======================="
695 mkdir -p $DIR/d26b/d26-2
696 ln -s d26b/d26-2/foo $DIR/s26-2
697 touch $DIR/s26-2 || error
699 run_test 26b "multiple component symlink at end of lookup ======"
704 ln -s d26.2 $DIR/s26.2-1
705 ln -s s26.2-1 $DIR/s26.2-2
706 ln -s s26.2-2 $DIR/s26.2-3
707 chmod 0666 $DIR/s26.2-3/foo
709 run_test 26c "chain of symlinks ================================"
711 # recursive symlinks (bug 439)
713 ln -s d26-3/foo $DIR/d26-3
715 run_test 26d "create multiple component recursive symlink ======"
718 [ ! -h $DIR/d26-3 ] && test_26d
721 run_test 26e "unlink multiple component recursive symlink ======"
724 echo '== stripe sanity =============================================='
726 $LSTRIPE $DIR/d27/f0 65536 0 1 || error
727 $CHECKSTAT -t file $DIR/d27/f0 || error
729 log "== test_27b: write to one stripe file ========================="
730 cp /etc/hosts $DIR/d27/f0 || error
732 run_test 27a "one stripe file =================================="
735 [ "$OSTCOUNT" -lt "2" ] && echo "skipping 2-stripe test" && return
736 if [ ! -d $DIR/d27 ]; then
739 $LSTRIPE $DIR/d27/f01 65536 0 2 || error
740 [ `$LFIND $DIR/d27/f01 | grep -A 10 obdidx | wc -l` -eq 4 ] ||
741 error "two-stripe file doesn't have two stripes"
743 log "== test_27d: write to two stripe file file f01 ================"
744 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error
746 run_test 27c "create two stripe file f01 ======================="
749 if [ ! -d $DIR/d27 ]; then
752 $LSTRIPE $DIR/d27/fdef 0 -1 0 || error
753 $CHECKSTAT -t file $DIR/d27/fdef || error
754 #dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
756 run_test 27d "create file with default settings ================"
759 if [ ! -d $DIR/d27 ]; then
762 $LSTRIPE $DIR/d27/f12 65536 0 2 || error
763 $LSTRIPE $DIR/d27/f12 65536 0 2 && error
764 $CHECKSTAT -t file $DIR/d27/f12 || error
766 run_test 27e "lstripe existing file (should return error) ======"
769 if [ ! -d $DIR/d27 ]; then
772 $LSTRIPE $DIR/d27/fbad 100 0 1 && error
773 dd if=/dev/zero of=$DIR/d27/f12 bs=4k count=4 || error
774 $LFIND $DIR/d27/fbad || error
776 run_test 27f "lstripe with bad stripe size (should return error)"
779 if [ ! -d $DIR/d27 ]; then
782 $MCREATE $DIR/d27/fnone || error
784 log "== test 27h: lfind with no objects ============================"
785 $LFIND $DIR/d27/fnone 2>&1 | grep "no stripe info" || error
787 log "== test 27i: lfind with some objects =========================="
788 touch $DIR/d27/fsome || error
789 $LFIND $DIR/d27/fsome | grep obdidx || error
791 run_test 27g "test lfind ======================================="
794 if [ ! -d $DIR/d27 ]; then
797 $LSTRIPE $DIR/d27/f27j 65536 $OSTCOUNT 1 && error || true
799 run_test 27j "lstripe with bad stripe offset (should return error)"
801 test_27k() { # bug 2844
803 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
804 [ ! -d $DIR/d27 ] && mkdir -p $DIR/d27
805 $LSTRIPE $FILE 67108864 -1 0 || error "lstripe failed"
806 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
807 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
808 dd if=/dev/zero of=$FILE bs=4k count=1
809 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
810 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
812 run_test 27k "limit i_blksize for broken user apps ============="
815 mcreate $DIR/f27l || error "creating file"
816 $RUNAS $LSTRIPE $DIR/f27l 65536 -1 1 && \
817 error "lstripe should have failed" || true
819 run_test 27l "check setstripe permissions (should return error)"
823 $CREATETEST $DIR/d28/ct || error
825 run_test 28 "create/mknod/mkdir with bad file types ============"
828 for d in /proc/fs/lustre/ldlm/namespaces/$1*; do
829 echo clear > $d/lru_size
831 grep [0-9] /proc/fs/lustre/ldlm/namespaces/$1*/lock_unused_count /dev/null
840 MDCDIR=${MDCDIR:-/proc/fs/lustre/ldlm/namespaces/MDC_*}
841 LOCKCOUNTORIG=`cat $MDCDIR/lock_count`
842 LOCKUNUSEDCOUNTORIG=`cat $MDCDIR/lock_unused_count`
846 LOCKCOUNTCURRENT=`cat $MDCDIR/lock_count`
847 LOCKUNUSEDCOUNTCURRENT=`cat $MDCDIR/lock_unused_count`
848 if [ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]; then
849 echo "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
852 if [ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]; then
853 echo "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
857 run_test 29 "IT_GETATTR regression ============================"
864 run_test 30 "run binary from Lustre (execve) ==================="
867 $OPENUNLINK $DIR/f31 $DIR/f31 || error
868 $CHECKSTAT -a $DIR/f31 || error
870 run_test 31a "open-unlink file =================================="
873 touch $DIR/f31 || error
874 ln $DIR/f31 $DIR/f31b || error
875 multiop $DIR/f31b Ouc || error
876 $CHECKSTAT -t file $DIR/f31 || error
878 run_test 31b "unlink file with multiple links while open ======="
881 touch $DIR/f31 || error
882 ln $DIR/f31 $DIR/f31c || error
883 multiop $DIR/f31 O_uc &
885 multiop $DIR/f31c Ouc
890 run_test 31c "open-unlink file with multiple links ============="
893 opendirunlink $DIR/d31d $DIR/d31d || error
894 $CHECKSTAT -a $DIR/d31d || error
896 run_test 31d "remove of open directory ========================="
899 check_kernel_version 34 || return 0
900 openfilleddirunlink $DIR/d31e || error
902 run_test 31e "remove of open non-empty directory ==============="
905 echo "== more mountpoints and symlinks ================="
906 [ -e $DIR/d32a ] && rm -fr $DIR/d32a
907 mkdir -p $DIR/d32a/ext2-mountpoint
908 mount -t ext2 -o loop $EXT2_DEV $DIR/d32a/ext2-mountpoint || error
909 $CHECKSTAT -t dir $DIR/d32a/ext2-mountpoint/.. || error
910 umount $DIR/d32a/ext2-mountpoint || error
912 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
915 [ -e $DIR/d32b ] && rm -fr $DIR/d32b
916 mkdir -p $DIR/d32b/ext2-mountpoint
917 mount -t ext2 -o loop $EXT2_DEV $DIR/d32b/ext2-mountpoint || error
918 ls -al $DIR/d32b/ext2-mountpoint/.. || error
919 umount $DIR/d32b/ext2-mountpoint || error
921 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
924 [ -e $DIR/d32c ] && rm -fr $DIR/d32c
925 mkdir -p $DIR/d32c/ext2-mountpoint
926 mount -t ext2 -o loop $EXT2_DEV $DIR/d32c/ext2-mountpoint || error
927 mkdir -p $DIR/d32c/d2/test_dir
928 $CHECKSTAT -t dir $DIR/d32c/ext2-mountpoint/../d2/test_dir || error
929 umount $DIR/d32c/ext2-mountpoint || error
931 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
934 [ -e $DIR/d32d ] && rm -fr $DIR/d32d
935 mkdir -p $DIR/d32d/ext2-mountpoint
936 mount -t ext2 -o loop $EXT2_DEV $DIR/d32d/ext2-mountpoint || error
937 mkdir -p $DIR/d32d/d2/test_dir
938 ls -al $DIR/d32d/ext2-mountpoint/../d2/test_dir || error
939 umount $DIR/d32d/ext2-mountpoint || error
941 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
944 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
945 mkdir -p $DIR/d32e/tmp
946 TMP_DIR=$DIR/d32e/tmp
947 ln -s $DIR/d32e $TMP_DIR/symlink11
948 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
949 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
950 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
952 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
955 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
956 mkdir -p $DIR/d32f/tmp
957 TMP_DIR=$DIR/d32f/tmp
958 ln -s $DIR/d32f $TMP_DIR/symlink11
959 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
960 ls $DIR/d32f/tmp/symlink11 || error
961 ls $DIR/d32f/symlink01 || error
963 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
966 [ -e $DIR/d32g ] && rm -fr $DIR/d32g
967 [ -e $DIR/test_dir ] && rm -fr $DIR/test_dir
968 mkdir -p $DIR/test_dir
969 mkdir -p $DIR/d32g/tmp
970 TMP_DIR=$DIR/d32g/tmp
971 ln -s $DIR/test_dir $TMP_DIR/symlink12
972 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
973 $CHECKSTAT -t link $DIR/d32g/tmp/symlink12 || error
974 $CHECKSTAT -t link $DIR/d32g/symlink02 || error
975 $CHECKSTAT -t dir -f $DIR/d32g/tmp/symlink12 || error
976 $CHECKSTAT -t dir -f $DIR/d32g/symlink02 || error
978 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/test_dir"
981 [ -e $DIR/d32h ] && rm -fr $DIR/d32h
982 [ -e $DIR/test_dir ] && rm -fr $DIR/test_dir
983 mkdir -p $DIR/test_dir
984 mkdir -p $DIR/d32h/tmp
985 TMP_DIR=$DIR/d32h/tmp
986 ln -s $DIR/test_dir $TMP_DIR/symlink12
987 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
988 ls $DIR/d32h/tmp/symlink12 || error
989 ls $DIR/d32h/symlink02 || error
991 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/test_dir"
994 [ -e $DIR/d32i ] && rm -fr $DIR/d32i
995 mkdir -p $DIR/d32i/ext2-mountpoint
996 mount -t ext2 -o loop $EXT2_DEV $DIR/d32i/ext2-mountpoint || error
997 touch $DIR/d32i/test_file
998 $CHECKSTAT -t file $DIR/d32i/ext2-mountpoint/../test_file || error
999 umount $DIR/d32i/ext2-mountpoint || error
1001 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
1004 [ -e $DIR/d32j ] && rm -fr $DIR/d32j
1005 mkdir -p $DIR/d32j/ext2-mountpoint
1006 mount -t ext2 -o loop $EXT2_DEV $DIR/d32j/ext2-mountpoint || error
1007 touch $DIR/d32j/test_file
1008 cat $DIR/d32j/ext2-mountpoint/../test_file || error
1009 umount $DIR/d32j/ext2-mountpoint || error
1011 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
1015 mkdir -p $DIR/d32k/ext2-mountpoint
1016 mount -t ext2 -o loop $EXT2_DEV $DIR/d32k/ext2-mountpoint
1017 mkdir -p $DIR/d32k/d2
1018 touch $DIR/d32k/d2/test_file || error
1019 $CHECKSTAT -t file $DIR/d32k/ext2-mountpoint/../d2/test_file || error
1020 umount $DIR/d32k/ext2-mountpoint || error
1022 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
1026 mkdir -p $DIR/d32l/ext2-mountpoint
1027 mount -t ext2 -o loop $EXT2_DEV $DIR/d32l/ext2-mountpoint || error
1028 mkdir -p $DIR/d32l/d2
1029 touch $DIR/d32l/d2/test_file
1030 cat $DIR/d32l/ext2-mountpoint/../d2/test_file || error
1031 umount $DIR/d32l/ext2-mountpoint || error
1033 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
1037 mkdir -p $DIR/d32m/tmp
1038 TMP_DIR=$DIR/d32m/tmp
1039 ln -s $DIR $TMP_DIR/symlink11
1040 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1041 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
1042 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
1044 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
1048 mkdir -p $DIR/d32n/tmp
1049 TMP_DIR=$DIR/d32n/tmp
1050 ln -s $DIR $TMP_DIR/symlink11
1051 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1052 ls -l $DIR/d32n/tmp/symlink11 || error
1053 ls -l $DIR/d32n/symlink01 || error
1055 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
1059 rm -f $DIR/test_file
1060 touch $DIR/test_file
1061 mkdir -p $DIR/d32o/tmp
1062 TMP_DIR=$DIR/d32o/tmp
1063 ln -s $DIR/test_file $TMP_DIR/symlink12
1064 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1065 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
1066 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
1067 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
1068 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
1070 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/test_file"
1076 rm -f $DIR/test_file
1078 touch $DIR/test_file
1080 mkdir -p $DIR/d32p/tmp
1082 TMP_DIR=$DIR/d32p/tmp
1084 ln -s $DIR/test_file $TMP_DIR/symlink12
1086 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1088 cat $DIR/d32p/tmp/symlink12 || error
1090 cat $DIR/d32p/symlink02 || error
1093 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/test_file"
1096 [ -e $DIR/d32q ] && rm -fr $DIR/d32q
1098 touch $DIR/d32q/under_the_mount
1099 mount -t ext2 -o loop $EXT2_DEV $DIR/d32q
1100 ls $DIR/d32q/under_the_mount && error || true
1101 umount $DIR/d32q || error
1103 run_test 32q "stat follows mountpoints in Lustre (should return error)"
1106 [ -e $DIR/d32r ] && rm -fr $DIR/d32r
1108 touch $DIR/d32r/under_the_mount
1109 mount -t ext2 -o loop $EXT2_DEV $DIR/d32r
1110 ls $DIR/d32r | grep -q under_the_mount && error || true
1111 umount $DIR/d32r || error
1113 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
1115 # chmod 444 /mnt/lustre/somefile
1116 # open(/mnt/lustre/somefile, O_RDWR)
1119 rm -f $DIR/test_33_file
1120 touch $DIR/test_33_file
1121 chmod 444 $DIR/test_33_file
1122 chown $RUNAS_ID $DIR/test_33_file
1124 $RUNAS $OPENFILE -f O_RDWR $DIR/test_33_file && error || true
1127 run_test 33 "write file with mode 444 (should return error) ===="
1132 chown $RUNAS_ID $DIR/d33
1133 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 || error
1134 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && error || true
1136 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
1138 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
1141 $MCREATE $DIR/f34 || error
1142 $LFIND $DIR/f34 2>&1 | grep -q "no stripe info" || error
1143 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
1144 $LFIND $DIR/f34 2>&1 | grep -q "no stripe info" || error
1145 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1147 run_test 34a "truncate file that has not been opened ==========="
1150 [ ! -f $DIR/f34 ] && test_34a
1151 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1152 $OPENFILE -f O_RDONLY $DIR/f34
1153 $LFIND $DIR/f34 2>&1 | grep -q "no stripe info" || error
1154 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1156 run_test 34b "O_RDONLY opening file doesn't create objects ====="
1159 [ ! -f $DIR/f34 ] && test_34a
1160 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1161 $OPENFILE -f O_RDWR $DIR/f34
1162 $LFIND $DIR/f34 2>&1 | grep -q "no stripe info" && error
1163 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1165 run_test 34c "O_RDWR opening file-with-size works =============="
1168 [ ! -f $DIR/f34 ] && test_34a
1169 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
1170 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1173 run_test 34d "write to sparse file ============================="
1177 $MCREATE $DIR/f34e || error
1178 $TRUNCATE $DIR/f34e 1000 || error
1179 $CHECKSTAT -s 1000 $DIR/f34e || error
1180 $OPENFILE -f O_RDWR $DIR/f34e
1181 $CHECKSTAT -s 1000 $DIR/f34e || error
1183 run_test 34e "create objects, some with size and some without =="
1186 cp /bin/sh $DIR/f35a
1188 chown $RUNAS_ID $DIR/f35a
1189 $RUNAS $DIR/f35a && error || true
1192 run_test 35a "exec file with mode 444 (should return and not leak) ====="
1196 utime $DIR/f36 || error
1198 run_test 36a "MDS utime check (mknod, utime) ==================="
1202 utime $DIR/f36 || error
1204 run_test 36b "OST utime check (open, utime) ===================="
1209 chown $RUNAS_ID $DIR/d36
1210 $RUNAS utime $DIR/d36/f36 || error
1212 run_test 36c "non-root MDS utime check (mknod, utime) =========="
1215 [ ! -d $DIR/d36 ] && test_36c
1216 echo "" > $DIR/d36/f36
1217 $RUNAS utime $DIR/d36/f36 || error
1219 run_test 36d "non-root OST utime check (open, utime) ==========="
1222 [ $RUNAS_ID -eq $UID ] && echo "skipping test 36e" && return
1223 [ ! -d $DIR/d36 ] && mkdir $DIR/d36
1225 $RUNAS utime $DIR/d36/f36e && error "utime worked, want failure" || true
1227 run_test 36e "utime on non-owned file (should return error) ===="
1230 mkdir -p $DIR/dextra
1231 echo f > $DIR/dextra/fbugfile
1232 mount -t ext2 -o loop $EXT2_DEV $DIR/dextra
1233 ls $DIR/dextra | grep "\<fbugfile\>" && error
1234 umount $DIR/dextra || error
1235 rm -f $DIR/dextra/fbugfile || error
1237 run_test 37 "ls a mounted file system to check old content ====="
1240 o_directory $DIR/test38
1242 run_test 38 "open a regular file with O_DIRECTORY =============="
1245 touch $DIR/test_39_file
1246 touch $DIR/test_39_file2
1247 # ls -l $DIR/test_39_file $DIR/test_39_file2
1248 # ls -lu $DIR/test_39_file $DIR/test_39_file2
1249 # ls -lc $DIR/test_39_file $DIR/test_39_file2
1251 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/test_39_file2
1252 # ls -l $DIR/test_39_file $DIR/test_39_file2
1253 # ls -lu $DIR/test_39_file $DIR/test_39_file2
1254 # ls -lc $DIR/test_39_file $DIR/test_39_file2
1255 [ $DIR/test_39_file2 -nt $DIR/test_39_file ] || error
1257 run_test 39 "mtime changed on create ==========================="
1260 dd if=/dev/zero of=$DIR/f40 bs=4096 count=1
1261 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/f40 && error
1262 $CHECKSTAT -t file -s 4096 $DIR/f40 || error
1264 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
1268 small_write $DIR/f41 18
1270 run_test 41 "test small file write + fstat ====================="
1272 count_ost_writes() {
1273 cat /proc/fs/lustre/osc/*/stats |
1274 awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }'
1281 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs
1282 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
1283 echo $WRITEBACK_SAVE > /proc/sys/vm/dirty_writeback_centisecs
1285 # if file not here, we are a 2.4 kernel
1286 kill -CONT `pidof kupdated`
1290 # setup the trap first, so someone cannot exit the test at the
1291 # exact wrong time and mess up a machine
1292 trap start_writeback EXIT
1293 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
1294 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
1295 WRITEBACK_SAVE=`cat /proc/sys/vm/dirty_writeback_centisecs`
1296 echo 0 > /proc/sys/vm/dirty_writeback_centisecs
1298 # if file not here, we are a 2.4 kernel
1299 kill -STOP `pidof kupdated`
1303 # ensure that all stripes have some grant before we test client-side cache
1305 [ "$SETUP_TEST42" ] && return
1306 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
1307 dd if=/dev/zero of=$i bs=4k count=1
1313 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
1314 # file truncation, and file removal.
1317 cancel_lru_locks OSC
1319 sync; sleep 1; sync # just to be safe
1320 BEFOREWRITES=`count_ost_writes`
1321 grep [0-9] /proc/fs/lustre/osc/OSC*MNT*/cur_grant_bytes
1322 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
1323 AFTERWRITES=`count_ost_writes`
1324 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
1325 error "$BEFOREWRITES < $AFTERWRITES"
1328 run_test 42a "ensure that we don't flush on close =============="
1332 cancel_lru_locks OSC
1335 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
1336 BEFOREWRITES=`count_ost_writes`
1337 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
1338 AFTERWRITES=`count_ost_writes`
1339 [ $BEFOREWRITES -eq $AFTERWRITES ] ||
1340 error "$BEFOREWRITES < $AFTERWRITES on unlink"
1341 BEFOREWRITES=`count_ost_writes`
1342 sync || error "sync: $?"
1343 AFTERWRITES=`count_ost_writes`
1344 [ $BEFOREWRITES -eq $AFTERWRITES ] ||
1345 error "$BEFOREWRITES < $AFTERWRITES on sync"
1346 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
1350 run_test 42b "test destroy of file with cached dirty data ======"
1352 # if these tests just want to test the effect of truncation,
1353 # they have to be very careful. consider:
1354 # - the first open gets a {0,EOF}PR lock
1355 # - the first write conflicts and gets a {0, count-1}PW
1356 # - the rest of the writes are under {count,EOF}PW
1357 # - the open for truncate tries to match a {0,EOF}PR
1358 # for the filesize and cancels the PWs.
1359 # any number of fixes (don't get {0,EOF} on open, match
1360 # composite locks, do smarter file size management) fix
1361 # this, but for now we want these tests to verify that
1362 # the cancellation with truncate intent works, so we
1363 # start the file with a full-file pw lock to match against
1364 # until the truncate.
1369 cancel_lru_locks OSC
1371 # prime the file with 0,EOF PW to match
1375 # now the real test..
1376 dd if=/dev/zero of=$file bs=1024 count=100
1377 BEFOREWRITES=`count_ost_writes`
1378 $TRUNCATE $file $offset
1379 cancel_lru_locks OSC
1380 AFTERWRITES=`count_ost_writes`
1386 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
1387 error "$BEFOREWRITES < $AFTERWRITES on truncate"
1390 run_test 42c "test partial truncate of file with cached dirty data"
1394 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
1395 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
1398 run_test 42d "test complete truncate of file with cached dirty data"
1402 cp -p /bin/ls $DIR/d43/f
1403 exec 100>> $DIR/d43/f
1404 $DIR/d43/f && error || true
1407 run_test 43 "execution of file opened for write should return -ETXTBSY"
1411 cp -p `which multiop` $DIR/d43/multiop
1412 $DIR/d43/multiop $TMP/test43.junk O_c &
1415 multiop $DIR/d43/multiop Oc && error "expected error, got success"
1416 kill -USR1 $MULTIPID || return 2
1417 wait $MULTIPID || return 3
1419 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
1423 cp -p `which multiop` $DIR/d43/multiop
1424 $DIR/d43/multiop $TMP/test43.junk O_c &
1427 truncate $DIR/d43/multiop 0 && error "expected error, got success"
1428 kill -USR1 $MULTIPID || return 2
1429 wait $MULTIPID || return 3
1431 run_test 43b "truncate of file being executed should return -ETXTBSY"
1434 local testdir="$DIR/d43c"
1437 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
1438 ( cd $testdir && md5sum -c)
1440 run_test 43c "md5sum of copy into lustre========================"
1443 [ "$OSTCOUNT" -lt "2" ] && echo "skipping 2-stripe test" && return
1444 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
1445 dd if=$DIR/f1 bs=4k count=1
1447 run_test 44 "zero length read from a sparse stripe ============="
1450 local nstripe=`$LCTL lov_getconfig $DIR | grep default_stripe_count: | \
1452 local stride=`$LCTL lov_getconfig $DIR | grep default_stripe_size: | \
1454 if [ $nstripe -eq 0 ] ; then
1455 nstripe=`$LCTL lov_getconfig $DIR | grep obd_count: | awk '{print $2}'`
1458 OFFSETS="0 $((stride/2)) $((stride-1))"
1459 for offset in $OFFSETS ; do
1460 for i in `seq 0 $((nstripe-1))`; do
1462 local GLOBALOFFSETS=""
1463 local size=$((((i + 2 * $nstripe )*$stride + $offset))) # Bytes
1464 ll_sparseness_write $DIR/d44a $size || error "ll_sparseness_write"
1465 GLOBALOFFSETS="$GLOBALOFFSETS $size"
1466 ll_sparseness_verify $DIR/d44a $GLOBALOFFSETS \
1467 || error "ll_sparseness_verify $GLOBALOFFSETS"
1469 for j in `seq 0 $((nstripe-1))`; do
1470 size=$((((j + $nstripe )*$stride + $offset))) # Bytes
1471 ll_sparseness_write $DIR/d44a $size || error "ll_sparseness_write"
1472 GLOBALOFFSETS="$GLOBALOFFSETS $size"
1474 ll_sparseness_verify $DIR/d44a $GLOBALOFFSETS \
1475 || error "ll_sparseness_verify $GLOBALOFFSETS"
1479 run_test 44a "test sparse pwrite ==============================="
1483 for d in /proc/fs/lustre/osc/*/cur_dirty_bytes; do
1484 tot=$(($tot + `cat $d`))
1489 before=`dirty_osc_total`
1490 echo executing "\"$*\""
1492 after=`dirty_osc_total`
1493 echo before $before, after $after
1497 # Obtain grants from OST if it supports it
1498 echo blah > ${f}_grant
1501 do_dirty_record "echo blah > $f"
1502 [ $before -eq $after ] && error "write wasn't cached"
1503 do_dirty_record "> $f"
1504 [ $before -gt $after ] || error "truncate didn't lower dirty count"
1505 do_dirty_record "echo blah > $f"
1506 [ $before -eq $after ] && error "write wasn't cached"
1507 do_dirty_record "sync"
1508 [ $before -gt $after ] || error "writeback didn't lower dirty count"
1509 do_dirty_record "echo blah > $f"
1510 [ $before -eq $after ] && error "write wasn't cached"
1511 do_dirty_record "cancel_lru_locks OSC"
1512 [ $before -gt $after ] || error "lock cancellation didn't lower dirty count"
1515 run_test 45 "osc io page accounting ============================"
1521 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
1522 # test tickles a bug where re-dirtying a page was failing to be mapped to the
1523 # objects offset and an assert hit when an rpc was built with 1023's mapped
1524 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
1529 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
1531 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
1532 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
1536 run_test 46 "dirtying a previously written page ================"
1538 # Check that device nodes are created and then visible correctly (#2091)
1540 cmknod $DIR/test_47_node || error
1542 run_test 47 "Device nodes check ================================"
1544 test_48a() { # bug 2399
1545 check_kernel_version 34 || return 0
1548 mv $DIR/d48a $DIR/d48.new || error "move directory failed"
1549 mkdir $DIR/d48a || error "recreate directory failed"
1550 touch foo || error "'touch foo' failed after recreating cwd"
1551 mkdir bar || error "'mkdir foo' failed after recreating cwd"
1552 ls . || error "'ls .' failed after recreating cwd"
1553 ls .. || error "'ls ..' failed after removing cwd"
1554 cd . || error "'cd .' failed after recreating cwd"
1555 mkdir . && error "'mkdir .' worked after recreating cwd"
1556 rmdir . && error "'rmdir .' worked after recreating cwd"
1557 ln -s . baz || error "'ln -s .' failed after recreating cwd"
1558 cd .. || error "'cd ..' failed after recreating cwd"
1560 run_test 48a "Access renamed working dir (should return errors)="
1562 test_48b() { # bug 2399
1563 check_kernel_version 34 || return 0
1566 rmdir $DIR/d48b || error "remove cwd $DIR/d48b failed"
1567 touch foo && error "'touch foo' worked after removing cwd"
1568 mkdir foo && error "'mkdir foo' worked after removing cwd"
1569 ls . && error "'ls .' worked after removing cwd"
1570 ls .. || error "'ls ..' failed after removing cwd"
1571 cd . && error "'cd .' worked after removing cwd"
1572 mkdir . && error "'mkdir .' worked after removing cwd"
1573 rmdir . && error "'rmdir .' worked after removing cwd"
1574 ln -s . foo && error "'ln -s .' worked after removing cwd" || true
1575 #cd .. || error "'cd ..' failed after removing cwd"
1577 run_test 48b "Access removed working dir (should return errors)="
1579 test_48c() { # bug 2350
1580 check_kernel_version 36 || return 0
1581 #sysctl -w portals.debug=-1
1583 mkdir -p $DIR/d48c/dir
1585 $TRACE rmdir $DIR/d48c/dir || error "remove cwd $DIR/d48c/dir failed"
1586 $TRACE touch foo && error "'touch foo' worked after removing cwd"
1587 $TRACE mkdir foo && error "'mkdir foo' worked after removing cwd"
1588 $TRACE ls . && error "'ls .' worked after removing cwd"
1589 $TRACE ls .. || error "'ls ..' failed after removing cwd"
1590 $TRACE cd . && error "'cd .' worked after recreate cwd"
1591 $TRACE mkdir . && error "'mkdir .' worked after removing cwd"
1592 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
1593 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd" ||true
1594 $TRACE cd .. || echo "'cd ..' failed after removing cwd (`pwd)`"
1596 run_test 48c "Access removed working subdir (should return errors)"
1598 test_48d() { # bug 2350
1599 check_kernel_version 36 || return 0
1600 #sysctl -w portals.debug=-1
1602 mkdir -p $DIR/d48d/dir
1606 $TRACE rm -vr $DIR/d48d || error "remove cwd+parent $DIR/d48d failed"
1607 $TRACE touch foo && error "'touch foo' worked after removing cwd"
1608 $TRACE mkdir foo && error "'mkdir foo' worked after removing cwd"
1609 $TRACE ls . && error "'ls .' worked after removing cwd"
1610 $TRACE ls .. && echo "'ls ..' worked after removing cwd" # bug 3415
1611 $TRACE cd . && error "'cd .' worked after recreate cwd"
1612 $TRACE mkdir . && error "'mkdir .' worked after removing cwd"
1613 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
1614 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd" ||true
1615 $TRACE cd .. && error "'cd ..' worked after removing cwd" || true
1617 run_test 48d "Access removed parent subdir (should return errors)"
1623 ls /proc/$$/cwd || error
1625 run_test 50 "special situations: /proc symlinks ==============="
1628 # bug 1516 - create an empty entry right after ".." then split dir
1631 $MCREATE $DIR/d49/bar
1633 createmany -m $DIR/d49/longfile 201
1635 while [ `ls -sd $DIR/d49 | awk '{ print $1 }'` -eq 4 ]; do
1636 $MCREATE $DIR/d49/longfile$FNUM
1640 ls -l $DIR/d49 > /dev/null || error
1642 run_test 51 "special situations: split htree with empty entry =="
1645 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
1648 chattr =a $DIR/d52a/foo || error
1649 echo bar >> $DIR/d52a/foo || error
1650 cp /etc/hosts $DIR/d52a/foo && error
1651 rm -f $DIR/d52a/foo 2>/dev/null && error
1652 link $DIR/d52a/foo $DIR/d52a/foo_link 2>/dev/null && error
1653 echo foo >> $DIR/d52a/foo || error
1654 mrename $DIR/d52a/foo $DIR/d52a/foo_ren && error
1655 lsattr $DIR/d52a/foo | egrep -q "^-+a-+ $DIR/d52a/foo" || error
1656 chattr -a $DIR/d52a/foo || error
1658 rm -fr $DIR/d52a || error
1660 run_test 52a "append-only flag test (should return errors) ====="
1663 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
1666 chattr =i $DIR/d52b/foo || error
1667 cat test > $DIR/d52b/foo && error
1668 cp /etc/hosts $DIR/d52b/foo && error
1669 rm -f $DIR/d52b/foo 2>/dev/null && error
1670 link $DIR/d52b/foo $DIR/d52b/foo_link 2>/dev/null && error
1671 echo foo >> $DIR/d52b/foo && error
1672 mrename $DIR/d52b/foo $DIR/d52b/foo_ren && error
1673 [ -f $DIR/d52b/foo ] || error
1674 [ -f $DIR/d52b/foo_ren ] && error
1675 lsattr $DIR/d52b/foo | egrep -q "^-+i-+ $DIR/d52b/foo" || error
1676 chattr -i $DIR/d52b/foo || error
1678 rm -fr $DIR/d52b || error
1680 run_test 52b "immutable flag test (should return errors) ======="
1683 for i in `ls -d /proc/fs/lustre/osc/OSC*mds1 2> /dev/null` ; do
1684 ostname=`echo $i | cut -d _ -f 3-4 | sed -e s/_mds1//`
1685 ost_last=`cat /proc/fs/lustre/obdfilter/$ostname/last_id`
1686 mds_last=`cat $i/prealloc_last_id`
1687 echo "$ostname.last_id=$ost_last ; MDS.last_id=$mds_last"
1688 if [ $ost_last != $mds_last ]; then
1689 error "$ostname.last_id=$ost_last ; MDS.last_id=$mds_last"
1693 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
1696 $SOCKETSERVER $DIR/socket
1697 $SOCKETCLIENT $DIR/socket || error
1698 $MUNLINK $DIR/socket
1700 run_test 54a "unix damain socket test =========================="
1706 dd if=/dev/zero of=$f bs=`page_size` count=1
1708 run_test 54b "char device works in lustre ======================"
1713 loopdev="$DIR/loop54c"
1715 for i in `seq 3 7`; do
1717 mknod $loopdev b 7 $i
1718 losetup $loopdev > /dev/null 2>&1 || break
1720 echo "make a loop file system with $tfile on $loopdev ($i)..."
1721 dd if=/dev/zero of=$tfile bs=`page_size` seek=1024 count=1 > /dev/null
1722 losetup $loopdev $tfile || error "can't set up $loopdev for $tfile"
1723 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
1725 mount -t ext2 $loopdev $tdir || error "error mounting $loopdev on $tdir"
1726 dd if=/dev/zero of=$tdir/tmp bs=`page_size` count=30 || error "dd write"
1728 dd if=$tdir/tmp of=/dev/zero bs=`page_size` count=30 || error "dd read"
1733 run_test 54c "block device works in lustre ====================="
1739 [ "$string" = `echo $string > $f | cat $f` ] || error
1741 run_test 54d "fifo device works in lustre ======================"
1746 mount -t $FSTYPE -o loop,iopen $EXT2_DEV $DIR/d55 || error
1748 $IOPENTEST1 $DIR/d55/foo $DIR/d55 || error
1749 $IOPENTEST2 $DIR/d55 || error
1750 echo "check for $EXT2_DEV. Please wait..."
1752 umount $DIR/d55 || error
1754 run_test 55 "check iopen_connect_dentry() ======================"
1761 NUMFILESx2=$(($NUMFILES * 2))
1762 for i in `seq 1 $NUMFILES` ; do
1763 touch $DIR/d56/file$i
1764 touch $DIR/d56/dir/file$i
1767 # test lfs find with --recursive
1768 FILENUM=`$LFIND --recursive $DIR/d56 | grep -c obdidx`
1769 [ $FILENUM -eq $NUMFILESx2 ] || error \
1770 "lfs find --recursive $DIR/d56 wrong: found $FILENUM, expected $NUMFILESx2"
1771 FILENUM=`$LFIND $DIR/d56 | grep -c obdidx`
1772 [ $FILENUM -eq $NUMFILES ] || error \
1773 "lfs find $DIR/d56 without --recursive wrong: found $FILENUM,
1775 echo "lfs find --recursive passed."
1777 # test lfs find with file instead of dir
1778 FILENUM=`$LFIND $DIR/d56/file1 | grep -c obdidx`
1779 [ $FILENUM -eq 1 ] || error \
1780 "lfs find $DIR/d56/file1 wrong:found $FILENUM, expected 1"
1781 echo "lfs find file passed."
1783 #test lfs find with --verbose
1784 [ `$LFIND --verbose $DIR/d56 | grep -c lmm_magic` -eq $NUMFILES ] ||\
1785 error "lfs find --verbose $DIR/d56 wrong: should find $NUMFILES lmm_magic info"
1786 [ `$LFIND $DIR/d56 | grep -c lmm_magic` -eq 0 ] || error \
1787 "lfs find $DIR/d56 without --verbose wrong: should not show lmm_magic info"
1788 echo "lfs find --verbose passed."
1790 #test lfs find with --obd
1791 $LFIND --obd wrong_uuid $DIR/d56 2>&1 | grep -q "unknown obduuid" || \
1792 error "lfs find --obd wrong_uuid should return error information"
1794 [ "$OSTCOUNT" -lt 2 ] && \
1795 echo "skipping other lfs find --obd test" && return
1796 FILENUM=`$LFIND --recursive $DIR/d56 | sed -n '/^[ ]*1[ ]/p' | wc -l`
1797 OBDUUID=`$LFIND --recursive $DIR/d56 | sed -n '/^[ ]*1:/p' | awk '{print $2}'`
1798 FOUND=`$LFIND -r --obd $OBDUUID $DIR/d56 | wc -l`
1799 [ $FOUND -eq $FILENUM ] || \
1800 error "lfs find --obd wrong: found $FOUND, expected $FILENUM"
1801 [ `$LFIND -r -v --obd $OBDUUID $DIR/d56 | sed '/^[ ]*1[ ]/d' | \
1802 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l` -eq 0 ] || \
1803 error "lfs find --obd wrong: should not show file on other obd"
1804 echo "lfs find --obd passed."
1806 run_test 56 "check lfs find ===================================="
1809 # note test will not do anything if MDS is not local
1810 for DEV in `cat /proc/fs/lustre/mds/*/mntdev`; do
1811 dumpe2fs -h $DEV > $TMP/t57a.dump || error "can't access $DEV"
1812 DEVISIZE=`awk '/Inode size:/ { print $3 }' $TMP/t57a.dump`
1813 [ "$DEVISIZE" -gt 128 ] || error "inode size $DEVISIZE"
1817 run_test 57a "verify MDS filesystem created with large inodes =="
1822 FILEN=$DIR/d57b/f$FILECOUNT
1823 rm -rf $DIR/d57b || error "removing $DIR/d57b"
1824 mkdir -p $DIR/d57b || error "creating $DIR/d57b"
1825 echo "mcreating $FILECOUNT files"
1826 createmany -m $DIR/d57b/f 1 $FILECOUNT || \
1827 error "creating files in $DIR/d57b"
1829 # verify that files do not have EAs yet
1830 $LFIND $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
1831 $LFIND $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
1833 MDSFREE="`cat /proc/fs/lustre/mds/*/kbytesfree`"
1834 MDCFREE="`cat /proc/fs/lustre/mdc/*/kbytesfree`"
1835 echo "opening files to create objects/EAs"
1836 for FILE in `seq -f $DIR/d57b/f%g 1 $FILECOUNT`; do
1837 $OPENFILE -f O_RDWR $FILE > /dev/null || error "opening $FILE"
1840 # verify that files have EAs now
1841 $LFIND $FILE1 | grep -q "obdidx" || error "$FILE1 missing EA"
1842 $LFIND $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
1844 MDSFREE2="`cat /proc/fs/lustre/mds/*/kbytesfree`"
1845 MDCFREE2="`cat /proc/fs/lustre/mdc/*/kbytesfree`"
1846 if [ "$MDCFREE" != "$MDCFREE2" ]; then
1847 if [ "$MDSFREE" != "$MDSFREE2" ]; then
1848 error "MDC before $MDCFREE != after $MDCFREE2"
1850 echo "MDC before $MDCFREE != after $MDCFREE2"
1851 echo "unable to confirm if MDS has large inodes"
1856 run_test 57b "default LOV EAs are stored inside large inodes ==="
1861 run_test 58 "verify cross-platform wire constants =============="
1864 echo "touch 130 files"
1865 for i in `seq 1 130` ; do
1869 for i in `seq 1 130` ; do
1874 # wait for commitment of removal
1876 run_test 59 "verify cancellation of llog records async ========="
1879 echo 60 "llog tests run from kernel mode"
1882 run_test 60 "llog sanity tests run from kernel module =========="
1886 dd if=/dev/zero of=$f bs=`page_size` count=1
1887 cancel_lru_locks OSC
1888 multiop $f OSMWUc || error
1891 run_test 61 "mmap() writes don't make sync hang ================"
1893 # bug 2330 - insufficient obd_match error checking causes LBUG
1897 cancel_lru_locks OSC
1898 echo 0x405 > /proc/sys/lustre/fail_loc
1899 cat $f && error "cat succeeded, expect -EIO"
1900 echo 0 > /proc/sys/lustre/fail_loc
1902 run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
1904 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
1906 MAX_DIRTY_MB=`cat /proc/fs/lustre/osc/*/max_dirty_mb | head -n 1`
1907 for i in /proc/fs/lustre/osc/*/max_dirty_mb ; do
1910 for i in `seq 10` ; do
1911 dd if=/dev/zero of=$DIR/f63 bs=8k &
1917 for i in /proc/fs/lustre/osc/*/max_dirty_mb ; do
1918 echo $MAX_DIRTY_MB > $i
1922 run_test 63 "Verify oig_wait interruption does not crash ======"
1926 grep "[0-9]" /proc/fs/lustre/osc/OSC*MNT*/cur*
1928 run_test 64a "verify filter grant calculations (in kernel) ====="
1933 run_test 64b "check out-of-space detection on client ==========="
1935 # bug 1414 - set/get directories' stripe info
1939 $LVERIFY $DIR/d65 $DIR/d65/f1 || error "lverify failed"
1941 run_test 65a "directory with no stripe info ===================="
1945 $LSTRIPE $DIR/d65 $(($STRIPESIZE * 2)) 0 1 || error "setstripe"
1947 $LVERIFY $DIR/d65 $DIR/d65/f2 || error "lverify failed"
1949 run_test 65b "directory setstripe $(($STRIPESIZE * 2)) 0 1 ==============="
1952 if [ $OSTCOUNT -gt 1 ]; then
1954 $LSTRIPE $DIR/d65 $(($STRIPESIZE * 4)) 1 \
1955 $(($OSTCOUNT - 1)) || error "setstripe"
1957 $LVERIFY $DIR/d65 $DIR/d65/f3 || error "lverify failed"
1960 run_test 65c "directory setstripe $(($STRIPESIZE * 4)) 1 $(($OSTCOUNT - 1))"
1962 [ $STRIPECOUNT -eq 0 ] && sc=1 || sc=$(($STRIPECOUNT - 1))
1966 $LSTRIPE $DIR/d65 $STRIPESIZE -1 $sc || error "setstripe"
1967 touch $DIR/d65/f4 $DIR/d65/f5
1968 $LVERIFY $DIR/d65 $DIR/d65/f4 $DIR/d65/f5 || error "lverify failed"
1970 run_test 65d "directory setstripe $STRIPESIZE -1 $sc ======================"
1975 $LSTRIPE $DIR/d65 0 -1 0 || error "setstripe"
1977 $LVERIFY $DIR/d65 $DIR/d65/f6 || error "lverify failed"
1979 run_test 65e "directory setstripe 0 -1 0 (default) ============="
1983 $RUNAS $LSTRIPE $DIR/d65f 0 -1 0 && error "setstripe succeeded" || true
1985 run_test 65f "dir setstripe permission (should return error) ==="
1987 # bug 2543 - update blocks count on client
1990 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
1992 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
1993 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
1995 run_test 66 "update inode blocks count on client ==============="
1997 test_67() { # bug 3285 - supplementary group fails on MDS, passes on client
1998 [ "$RUNAS_ID" = "$UID" ] && echo "skipping test 67" && return
1999 check_kernel_version 35 || return 0
2002 chgrp $RUNAS_ID $DIR/d67
2003 $RUNAS -g $((RUNAS_ID + 1)) -G1,2,$RUNAS_ID ls $DIR/d67 && error || true
2005 run_test 67 "supplementary group failure (should return error) ="
2007 # on the LLNL clusters, runas will still pick up root's $TMP settings,
2008 # which will not be writable for the runas user, and then you get a CVS
2009 # error message with a corrupt path string (CVS bug) and panic.
2010 # We're not using much space, so just stick it in /tmp, which is safe.
2016 [ $RUNAS_ID -ne $UID ] && HOME=/tmp
2019 mkdir -p $DIR/d99cvsroot
2020 chown $RUNAS_ID $DIR/d99cvsroot
2021 $RUNAS cvs -d $DIR/d99cvsroot init || error
2023 run_test 99a "cvs init ========================================="
2026 [ ! -d $DIR/d99cvsroot ] && test_99a
2028 # some versions of cvs import exit(1) when asked to import links or
2029 # files they can't read. ignore those files.
2030 TOIGNORE=$(find . -type l -printf '-I %f\n' -o \
2031 ! -perm +4 -printf '-I %f\n')
2032 $RUNAS cvs -d $DIR/d99cvsroot import -m "nomesg" $TOIGNORE \
2033 d99reposname vtag rtag
2035 run_test 99b "cvs import ======================================="
2038 [ ! -d $DIR/d99cvsroot ] && test_99b
2040 mkdir -p $DIR/d99reposname
2041 chown $RUNAS_ID $DIR/d99reposname
2042 $RUNAS cvs -d $DIR/d99cvsroot co d99reposname
2044 run_test 99c "cvs checkout ====================================="
2047 [ ! -d $DIR/d99cvsroot ] && test_99c
2048 cd $DIR/d99reposname
2050 $RUNAS cvs add -m 'addmsg' foo99
2052 run_test 99d "cvs add =========================================="
2055 [ ! -d $DIR/d99cvsroot ] && test_99c
2056 cd $DIR/d99reposname
2059 run_test 99e "cvs update ======================================="
2062 [ ! -d $DIR/d99cvsroot ] && test_99d
2063 cd $DIR/d99reposname
2064 $RUNAS cvs commit -m 'nomsg' foo99
2066 run_test 99f "cvs commit ======================================="
2072 log "cleanup: ======================================================"
2073 if [ "`mount | grep ^$NAME`" ]; then
2074 rm -rf $DIR/[Rdfs][1-9]*
2075 if [ "$I_MOUNTED" = "yes" ]; then
2076 sh llmountcleanup.sh || error
2080 echo '=========================== finished ==============================='
2081 [ -f "$SANITYLOG" ] && cat $SANITYLOG && exit 1 || true