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 3637 3561 5188/5749
11 ALWAYS_EXCEPT=${ALWAYS_EXCEPT:-"42a 42c 45 68"}
12 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
14 [ "$ALWAYS_EXCEPT$EXCEPT" ] && \
15 echo "Skipping tests: `echo $ALWAYS_EXCEPT $EXCEPT`"
18 export PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH:/sbin
21 FSTYPE=${FSTYPE:-ext3}
23 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
24 CREATETEST=${CREATETEST:-createtest}
26 LSTRIPE=${LSTRIPE:-"$LFS setstripe"}
27 LFIND=${LFIND:-"$LFS find"}
28 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
30 MCREATE=${MCREATE:-mcreate}
31 OPENFILE=${OPENFILE:-openfile}
32 OPENUNLINK=${OPENUNLINK:-openunlink}
33 TOEXCL=${TOEXCL:-toexcl}
34 TRUNCATE=${TRUNCATE:-truncate}
35 MUNLINK=${MUNLINK:-munlink}
36 SOCKETSERVER=${SOCKETSERVER:-socketserver}
37 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
38 IOPENTEST1=${IOPENTEST1:-iopentest1}
39 IOPENTEST2=${IOPENTEST2:-iopentest2}
40 MEMHOG=${MEMHOG:-memhog}
41 DIRECTIO=${DIRECTIO:-directio}
43 if [ $UID -ne 0 ]; then
47 RUNAS_ID=${RUNAS_ID:-500}
48 RUNAS=${RUNAS:-"runas -u $RUNAS_ID"}
51 export NAME=${NAME:-local}
57 sh llmountcleanup.sh ${FORCE} > /dev/null || exit 20
64 sh llrmount.sh > /dev/null || exit 10
72 $LCTL mark "$*" 2> /dev/null || true
77 strace -o $TMP/$1.strace -ttt $*
79 log "FINISHED: $*: rc $RC"
84 check_kernel_version() {
85 VERSION_FILE=/proc/fs/lustre/kernel_version
87 [ ! -f $VERSION_FILE ] && echo "can't find kernel version" && return 1
88 GOT_VER=`cat $VERSION_FILE`
89 [ $GOT_VER -ge $WANT_VER ] && return 0
90 log "test needs at least kernel version $WANT_VER, running $GOT_VER"
95 if ! mount | grep -q $DIR; then
99 log "== test $1: $2= `date +%H:%M:%S` ($BEFORE)"
100 export TESTNAME=test_$1
101 test_$1 || error "exit with rc=$?"
103 pass "($((`date +%s` - $BEFORE))s)"
108 build_test_filter() {
112 for E in $EXCEPT $ALWAYS_EXCEPT; do
113 eval EXCEPT_${E}=true
122 IFS=abcdefghijklmnopqrstuvwxyz _basetest $1
129 if [ ${!testname}x != x ]; then
134 if [ ${!testname}x != x ]; then
142 if [ ${!testname}x != x ]; then
143 echo "skipping excluded test $1"
146 testname=EXCEPT_$base
147 if [ ${!testname}x != x ]; then
148 echo "skipping excluded test $1 (base $base)"
155 [ "$SANITYLOG" ] && rm -f $SANITYLOG || true
158 log "FAIL: $TESTNAME $@"
159 if [ "$SANITYLOG" ]; then
160 echo "FAIL: $TESTNAME $@" >> $SANITYLOG
170 mounted_lustre_filesystems() {
171 awk '($3 ~ "lustre") { print $2 }' /proc/mounts
173 MOUNT="`mounted_lustre_filesystems`"
174 if [ -z "$MOUNT" ]; then
176 MOUNT="`mounted_lustre_filesystems`"
177 [ -z "$MOUNT" ] && error "NAME=$NAME not mounted"
181 [ `echo $MOUNT | wc -w` -gt 1 ] && error "NAME=$NAME mounted more than once"
184 [ -z "`echo $DIR | grep $MOUNT`" ] && echo "$DIR not in $MOUNT" && exit 99
186 LOVNAME=`cat /proc/fs/lustre/llite/*/lov/common_name | tail -n 1`
187 OSTCOUNT=`cat /proc/fs/lustre/lov/$LOVNAME/numobd`
188 STRIPECOUNT=`cat /proc/fs/lustre/lov/$LOVNAME/stripecount`
189 STRIPESIZE=`cat /proc/fs/lustre/lov/$LOVNAME/stripesize`
190 ORIGFREE=`cat /proc/fs/lustre/lov/$LOVNAME/kbytesavail`
191 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
193 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
194 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
195 rm -rf $DIR/[Rdfs][1-9]*
199 echo preparing for tests involving mounts
200 EXT2_DEV=${EXT2_DEV:-/tmp/SANITY.LOOP}
202 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
208 $CHECKSTAT -t file $DIR/f || error
210 $CHECKSTAT -a $DIR/f || error
212 run_test 0 "touch .../f ; rm .../f ============================="
215 chmod 0755 $DIR || error
216 $CHECKSTAT -p 0755 $DIR || error
218 run_test 0b "chmod 0755 $DIR ============================="
223 $CHECKSTAT -t dir $DIR/d1/d2 || error
225 run_test 1a "mkdir .../d1; mkdir .../d1/d2 ====================="
230 $CHECKSTAT -a $DIR/d1 || error
232 run_test 1b "rmdir .../d1/d2; rmdir .../d1 ====================="
237 $CHECKSTAT -t file $DIR/d2/f || error
239 run_test 2a "mkdir .../d2; touch .../d2/f ======================"
243 $CHECKSTAT -a $DIR/d2 || error
245 run_test 2b "rm -r .../d2; checkstat .../d2/f ======================"
249 $CHECKSTAT -t dir $DIR/d3 || error
251 run_test 3a "mkdir .../d3 ======================================"
254 if [ ! -d $DIR/d3 ]; then
258 $CHECKSTAT -t file $DIR/d3/f || error
260 run_test 3b "touch .../d3/f ===================================="
264 $CHECKSTAT -a $DIR/d3 || error
266 run_test 3c "rm -r .../d3 ======================================"
270 $CHECKSTAT -t dir $DIR/d4 || error
272 run_test 4a "mkdir .../d4 ======================================"
275 if [ ! -d $DIR/d4 ]; then
279 $CHECKSTAT -t dir $DIR/d4/d2 || error
281 run_test 4b "mkdir .../d4/d2 ==================================="
286 chmod 0707 $DIR/d5/d2
287 $CHECKSTAT -t dir -p 0707 $DIR/d5/d2 || error
289 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2 ============"
293 chmod 0666 $DIR/f6a || error
294 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/f6a || error
296 run_test 6a "touch .../f6a; chmod .../f6a ======================"
299 [ $RUNAS_ID -eq $UID ] && echo "skipping test 6b" && return
300 if [ ! -f $DIR/f6a ]; then
304 $RUNAS chmod 0444 $DIR/f6a && error
305 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/f6a || error
307 run_test 6b "$RUNAS chmod .../f6a (should return error) =="
310 [ $RUNAS_ID -eq $UID ] && echo "skipping test 6c" && return
312 chown $RUNAS_ID $DIR/f6c || error
313 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/f6c || error
315 run_test 6c "touch .../f6c; chown .../f6c ======================"
318 [ $RUNAS_ID -eq $UID ] && echo "skipping test 6d" && return
319 if [ ! -f $DIR/f6c ]; then
321 chown $RUNAS_ID $DIR/f6c
323 $RUNAS chown $UID $DIR/f6c && error
324 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/f6c || error
326 run_test 6d "$RUNAS chown .../f6c (should return error) =="
329 [ $RUNAS_ID -eq $UID ] && echo "skipping test 6e" && return
331 chgrp $RUNAS_ID $DIR/f6e || error
332 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/f6e || error
334 run_test 6e "touch .../f6e; chgrp .../f6e ======================"
337 [ $RUNAS_ID -eq $UID ] && echo "skipping test 6f" && return
338 if [ ! -f $DIR/f6e ]; then
340 chgrp $RUNAS_ID $DIR/f6e
342 $RUNAS chgrp $UID $DIR/f6e && error
343 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/f6e || error
345 run_test 6f "$RUNAS chgrp .../f6e (should return error) =="
348 [ $RUNAS_ID -eq $UID ] && echo "skipping test 6g" && return
349 mkdir $DIR/d6g || error
350 chmod 777 $DIR/d6g || error
351 $RUNAS mkdir $DIR/d6g/d || error
352 chmod g+s $DIR/d6g/d || error
353 mkdir $DIR/d6g/d/subdir
354 $CHECKSTAT -g \#$RUNAS_ID $DIR/d6g/d/subdir || error
356 run_test 6g "Is new dir in sgid dir inheriting group?"
362 $CHECKSTAT -t file -p 0666 $DIR/d7/f || error
364 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
367 if [ ! -d $DIR/d7 ]; then
371 echo -n foo > $DIR/d7/f2
372 [ "`cat $DIR/d7/f2`" = "foo" ] || error
373 $CHECKSTAT -t file -s 3 $DIR/d7/f2 || error
375 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
381 $CHECKSTAT -t file -p 0666 $DIR/d8/f || error
383 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
389 $CHECKSTAT -t dir $DIR/d9/d2/d3 || error
391 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
397 $CHECKSTAT -t file $DIR/d10/d2/f || error
399 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
404 chmod 0666 $DIR/d11/d2
405 chmod 0705 $DIR/d11/d2
406 $CHECKSTAT -t dir -p 0705 $DIR/d11/d2 || error
408 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
413 chmod 0666 $DIR/d12/f
414 chmod 0654 $DIR/d12/f
415 $CHECKSTAT -t file -p 0654 $DIR/d12/f || error
417 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
421 dd if=/dev/zero of=$DIR/d13/f count=10
423 $CHECKSTAT -t file -s 0 $DIR/d13/f || error
425 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
431 $CHECKSTAT -a $DIR/d14/f || error
433 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
438 mv $DIR/d15/f $DIR/d15/f2
439 $CHECKSTAT -t file $DIR/d15/f2 || error
441 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
447 $CHECKSTAT -a $DIR/d16/f || error
449 run_test 16 "touch .../d16/f; rm -rf .../d16/f ================="
454 ln -s $DIR/d17/f $DIR/d17/l-exist
456 $CHECKSTAT -l $DIR/d17/f $DIR/d17/l-exist || error
457 $CHECKSTAT -f -t f $DIR/d17/l-exist || error
459 $CHECKSTAT -a $DIR/l-exist || error
461 run_test 17a "symlinks: create, remove (real) =================="
465 ln -s no-such-file $DIR/d17/l-dangle
467 $CHECKSTAT -l no-such-file $DIR/d17/l-dangle || error
468 $CHECKSTAT -fa $DIR/d17/l-dangle || error
470 $CHECKSTAT -a $DIR/l-dangle || error
472 run_test 17b "symlinks: create, remove (dangling) =============="
474 test_17c() { # bug 3440 - don't save failed open RPC for replay
476 ln -s foo $DIR/d17/f17c
477 cat $DIR/d17/f17c && error "opened non-existent symlink" || true
479 run_test 17c "symlinks: open dangling (should return error) ===="
483 ln -s foo $DIR/d17/f17d
484 touch $DIR/d17/f17d || error "creating to new symlink"
486 run_test 17d "symlinks: create dangling ========================"
492 run_test 18 "touch .../f ; ls ... =============================="
498 $CHECKSTAT -a $DIR/f19 || error
500 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
503 ls -l $DIR/f19 && error || true
505 run_test 19b "ls -l .../f19 (should return error) =============="
508 [ $RUNAS_ID -eq $UID ] && echo "skipping test 19c" && return
509 $RUNAS touch $DIR/f19 && error || true
511 run_test 19c "$RUNAS touch .../f19 (should return error) =="
514 cat $DIR/f19 && error || true
516 run_test 19d "cat .../f19 (should return error) =============="
528 $CHECKSTAT -a $DIR/f || error
530 run_test 20 "touch .../f ; ls -l ... ==========================="
534 [ -f $DIR/d21/dangle ] && rm -f $DIR/d21/dangle
535 ln -s dangle $DIR/d21/link
536 echo foo >> $DIR/d21/link
538 $CHECKSTAT -t link $DIR/d21/link || error
539 $CHECKSTAT -f -t file $DIR/d21/link || error
541 run_test 21 "write to dangling link ============================"
545 chown $RUNAS_ID $DIR/d22
546 # Tar gets pissy if it can't access $PWD *sigh*
548 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
549 $RUNAS tar xfC - $DIR/d22)
551 $CHECKSTAT -t dir $DIR/d22/etc || error
552 $CHECKSTAT -u \#$RUNAS_ID $DIR/d22/etc || error
554 run_test 22 "unpack tar archive as non-root user ==============="
559 $TOEXCL -e $DIR/d23/f23 || error
561 run_test 23 "O_CREAT|O_EXCL in subdir =========================="
564 echo '== rename sanity =============================================='
565 echo '-- same directory rename'
568 mv $DIR/R1/f $DIR/R1/g
569 $CHECKSTAT -t file $DIR/R1/g || error
571 run_test 24a "touch .../R1/f; rename .../R1/f .../R1/g ========="
576 mv $DIR/R2/f $DIR/R2/g
577 $CHECKSTAT -a $DIR/R2/f || error
578 $CHECKSTAT -t file $DIR/R2/g || error
580 run_test 24b "touch .../R2/{f,g}; rename .../R2/f .../R2/g ====="
585 mv $DIR/R3/f $DIR/R3/g
586 $CHECKSTAT -a $DIR/R3/f || error
587 $CHECKSTAT -t dir $DIR/R3/g || error
589 run_test 24c "mkdir .../R3/f; rename .../R3/f .../R3/g ========="
594 mrename $DIR/R4/f $DIR/R4/g
595 $CHECKSTAT -a $DIR/R4/f || error
596 $CHECKSTAT -t dir $DIR/R4/g || error
598 run_test 24d "mkdir .../R4/{f,g}; rename .../R4/f .../R4/g ====="
601 echo '-- cross directory renames --'
604 mv $DIR/R5a/f $DIR/R5b/g
605 $CHECKSTAT -a $DIR/R5a/f || error
606 $CHECKSTAT -t file $DIR/R5b/g || error
608 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
612 touch $DIR/R6a/f $DIR/R6b/g
613 mv $DIR/R6a/f $DIR/R6b/g
614 $CHECKSTAT -a $DIR/R6a/f || error
615 $CHECKSTAT -t file $DIR/R6b/g || error
617 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
622 mv $DIR/R7a/d $DIR/R7b/e
623 $CHECKSTAT -a $DIR/R7a/d || error
624 $CHECKSTAT -t dir $DIR/R7b/e || error
626 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R5b/e ======"
630 mkdir $DIR/R8a/d $DIR/R8b/e
631 mrename $DIR/R8a/d $DIR/R8b/e
632 $CHECKSTAT -a $DIR/R8a/d || error
633 $CHECKSTAT -t dir $DIR/R8b/e || error
635 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
638 echo "-- rename error cases"
642 mrename $DIR/R9/f $DIR/R9/a
643 $CHECKSTAT -t file $DIR/R9/f || error
644 $CHECKSTAT -t dir $DIR/R9/a || error
645 $CHECKSTAT -a file $DIR/R9/a/f || error
647 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
651 mrename $DIR/R10/f $DIR/R10/g
652 $CHECKSTAT -t dir $DIR/R10 || error
653 $CHECKSTAT -a $DIR/R10/f || error
654 $CHECKSTAT -a $DIR/R10/g || error
656 run_test 24j "source does not exist ============================"
659 mkdir $DIR/R11a $DIR/R11a/d
661 mv $DIR/R11a/f $DIR/R11a/d
662 $CHECKSTAT -a $DIR/R11a/f || error
663 $CHECKSTAT -t file $DIR/R11a/d/f || error
665 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
667 # bug 2429 - rename foo foo foo creates invalid file
670 multiop $f OcNs || error
672 run_test 24l "Renaming a file to itself ========================"
676 multiop $f OcLN ${f}2 ${f}2 || error
678 run_test 24m "Renaming a file to a hard link to itself ========="
682 # this stats the old file after it was renamed, so it should fail
686 $CHECKSTAT ${f}.rename
689 run_test 24n "Statting the old file after renameing (Posix rename 2)"
692 check_kernel_version 37 || return 0
694 rename_many -s random -v -n 10 $DIR/d24o
696 run_test 24o "rename of files during htree split ==============="
700 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
701 mrename $DIR/R12a $DIR/R12b
702 $CHECKSTAT -a $DIR/R12a || error
703 $CHECKSTAT -t dir $DIR/R12b || error
704 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
705 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
707 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
711 DIRINO=`ls -lid $DIR/R13a | awk '{ print $1 }'`
712 multiop $DIR/R13b D_c &
716 mrename $DIR/R13a $DIR/R13b
717 $CHECKSTAT -a $DIR/R13a || error
718 $CHECKSTAT -t dir $DIR/R13b || error
719 DIRINO2=`ls -lid $DIR/R13b | awk '{ print $1 }'`
720 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
722 wait $MULTIPID || error "multiop close failed"
724 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
726 test_24r() { #bug 3789
727 mkdir $DIR/R14a $DIR/R14a/b
728 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
729 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
730 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
732 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
735 mkdir $DIR/R15a $DIR/R15a/b $DIR/R15a/b/c
736 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
737 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
738 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
740 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
742 mkdir $DIR/R16a $DIR/R16a/b $DIR/R16a/b/c
743 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
744 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
745 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
747 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
750 echo '== symlink sanity ============================================='
754 touch $DIR/s25/foo || error
756 run_test 25a "create file in symlinked directory ==============="
759 [ ! -d $DIR/d25 ] && test_25a
760 $CHECKSTAT -t file $DIR/s25/foo || error
762 run_test 25b "lookup file in symlinked directory ==============="
767 ln -s d26/d26-2 $DIR/s26
768 touch $DIR/s26/foo || error
770 run_test 26a "multiple component symlink ======================="
773 mkdir -p $DIR/d26b/d26-2
774 ln -s d26b/d26-2/foo $DIR/s26-2
775 touch $DIR/s26-2 || error
777 run_test 26b "multiple component symlink at end of lookup ======"
782 ln -s d26.2 $DIR/s26.2-1
783 ln -s s26.2-1 $DIR/s26.2-2
784 ln -s s26.2-2 $DIR/s26.2-3
785 chmod 0666 $DIR/s26.2-3/foo
787 run_test 26c "chain of symlinks ================================"
789 # recursive symlinks (bug 439)
791 ln -s d26-3/foo $DIR/d26-3
793 run_test 26d "create multiple component recursive symlink ======"
796 [ ! -h $DIR/d26-3 ] && test_26d
799 run_test 26e "unlink multiple component recursive symlink ======"
802 echo '== stripe sanity =============================================='
804 $LSTRIPE $DIR/d27/f0 65536 0 1 || error "lstripe failed"
805 $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
807 log "== test_27b: write to one stripe file ========================="
808 cp /etc/hosts $DIR/d27/f0 || error
810 run_test 27a "one stripe file =================================="
813 [ "$OSTCOUNT" -lt "2" ] && echo "skipping 2-stripe test" && return
815 $LSTRIPE $DIR/d27/f01 65536 0 2 || error "lstripe failed"
816 [ `$LFIND $DIR/d27/f01 | grep -A 10 obdidx | wc -l` -eq 4 ] ||
817 error "two-stripe file doesn't have two stripes"
819 log "== test_27d: write to two stripe file file f01 ================"
820 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
822 run_test 27c "create two stripe file f01 ======================="
826 $LSTRIPE $DIR/d27/fdef 0 -1 0 || error "lstripe failed"
827 $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
828 #dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
830 run_test 27d "create file with default settings ================"
834 $LSTRIPE $DIR/d27/f12 65536 0 2 || error "lstripe failed"
835 $LSTRIPE $DIR/d27/f12 65536 0 2 && error "lstripe succeeded twice"
836 $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
838 run_test 27e "lstripe existing file (should return error) ======"
842 $LSTRIPE $DIR/d27/fbad 100 0 1 && error "lstripe failed"
843 dd if=/dev/zero of=$DIR/d27/f12 bs=4k count=4 || error "dd failed"
844 $LFIND $DIR/d27/fbad || error "lfind failed"
846 run_test 27f "lstripe with bad stripe size (should return error)"
850 $MCREATE $DIR/d27/fnone || error "mcreate failed"
852 log "== test 27h: lfind with no objects ============================"
853 $LFIND $DIR/d27/fnone 2>&1 | grep "no stripe info" || error "has object"
855 log "== test 27i: lfind with some objects =========================="
856 touch $DIR/d27/fsome || error "touch failed"
857 $LFIND $DIR/d27/fsome | grep obdidx || error "missing objects"
859 run_test 27g "test lfind ======================================="
863 $LSTRIPE $DIR/d27/f27j 65536 $OSTCOUNT 1 && error "lstripe failed"||true
865 run_test 27j "lstripe with bad stripe offset (should return error)"
867 test_27k() { # bug 2844
870 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
871 [ ! -d $DIR/d27 ] && mkdir -p $DIR/d27
872 $LSTRIPE $FILE 67108864 -1 0 || error "lstripe failed"
873 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
874 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
875 dd if=/dev/zero of=$FILE bs=4k count=1
876 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
877 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
879 run_test 27k "limit i_blksize for broken user apps ============="
883 mcreate $DIR/f27l || error "creating file"
884 $RUNAS $LSTRIPE $DIR/f27l 65536 -1 1 && \
885 error "lstripe should have failed" || true
887 run_test 27l "check setstripe permissions (should return error)"
890 [ "$OSTCOUNT" -lt "2" ] && echo "skipping out-of-space test on OST0" && return
891 if [ $ORIGFREE -gt $MAXFREE ]; then
892 echo "skipping out-of-space test on OST0"
896 $LSTRIPE $DIR/d27/f27m_1 0 0 1
897 dd if=/dev/zero of=$DIR/d27/f27m_1 bs=1024 count=$MAXFREE && \
898 error "dd should fill OST0"
900 while $LSTRIPE $DIR/d27/f27m_$i 0 0 1 ; do
902 [ $i -gt 256 ] && break
905 touch $DIR/d27/f27m_$i
906 [ `$LFIND $DIR/d27/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] && \
907 error "OST0 was full but new created file still use it"
909 touch $DIR/d27/f27m_$i
910 [ `$LFIND $DIR/d27/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] && \
911 error "OST0 was full but new created file still use it"
914 run_test 27m "create file while OST0 was full =================="
918 $CREATETEST $DIR/d28/ct || error
920 run_test 28 "create/mknod/mkdir with bad file types ============"
923 for d in /proc/fs/lustre/ldlm/namespaces/$1*; do
924 echo clear > $d/lru_size
926 grep "[0-9]" /proc/fs/lustre/ldlm/namespaces/$1*/lock_unused_count /dev/null
935 MDCDIR=${MDCDIR:-/proc/fs/lustre/ldlm/namespaces/MDC_*}
936 LOCKCOUNTORIG=`cat $MDCDIR/lock_count`
937 LOCKUNUSEDCOUNTORIG=`cat $MDCDIR/lock_unused_count`
941 LOCKCOUNTCURRENT=`cat $MDCDIR/lock_count`
942 LOCKUNUSEDCOUNTCURRENT=`cat $MDCDIR/lock_unused_count`
943 if [ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]; then
944 echo > /proc/fs/lustre/ldlm/dump_namespaces
945 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
946 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
947 log "dumped log to $TMP/test_29.dk (bug 5793)"
949 if [ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]; then
950 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
951 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
952 log "dumped log to $TMP/test_29.dk (bug 5793)"
955 run_test 29 "IT_GETATTR regression ============================"
962 run_test 30 "run binary from Lustre (execve) ==================="
965 $OPENUNLINK $DIR/f31 $DIR/f31 || error
966 $CHECKSTAT -a $DIR/f31 || error
968 run_test 31a "open-unlink file =================================="
971 touch $DIR/f31 || error
972 ln $DIR/f31 $DIR/f31b || error
973 multiop $DIR/f31b Ouc || error
974 $CHECKSTAT -t file $DIR/f31 || error
976 run_test 31b "unlink file with multiple links while open ======="
979 touch $DIR/f31 || error
980 ln $DIR/f31 $DIR/f31c || error
981 multiop $DIR/f31 O_uc &
983 multiop $DIR/f31c Ouc
988 run_test 31c "open-unlink file with multiple links ============="
991 opendirunlink $DIR/d31d $DIR/d31d || error
992 $CHECKSTAT -a $DIR/d31d || error
994 run_test 31d "remove of open directory ========================="
996 test_31e() { # bug 2904
997 check_kernel_version 34 || return 0
998 openfilleddirunlink $DIR/d31e || error
1000 run_test 31e "remove of open non-empty directory ==============="
1002 test_31f() { # bug 4554
1005 lfs setstripe $DIR/d31f 1048576 -1 1
1006 cp /etc/hosts $DIR/d31f
1008 lfs getstripe $DIR/d31f/hosts
1009 multiop $DIR/d31f D_c &
1014 rm -rv $DIR/d31f || error "first of $DIR/d31f"
1016 lfs setstripe $DIR/d31f 1048576 -1 1
1017 cp /etc/hosts $DIR/d31f
1019 lfs getstripe $DIR/d31f/hosts
1020 multiop $DIR/d31f D_c &
1025 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
1026 wait $MULTIPID || error "first opendir $MULTIPID failed"
1030 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
1031 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
1034 run_test 31f "remove of open directory with open-unlink file ==="
1037 echo "== more mountpoints and symlinks ================="
1038 [ -e $DIR/d32a ] && rm -fr $DIR/d32a
1039 mkdir -p $DIR/d32a/ext2-mountpoint
1040 mount -t ext2 -o loop $EXT2_DEV $DIR/d32a/ext2-mountpoint || error
1041 $CHECKSTAT -t dir $DIR/d32a/ext2-mountpoint/.. || error
1042 umount $DIR/d32a/ext2-mountpoint || error
1044 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
1047 [ -e $DIR/d32b ] && rm -fr $DIR/d32b
1048 mkdir -p $DIR/d32b/ext2-mountpoint
1049 mount -t ext2 -o loop $EXT2_DEV $DIR/d32b/ext2-mountpoint || error
1050 ls -al $DIR/d32b/ext2-mountpoint/.. || error
1051 umount $DIR/d32b/ext2-mountpoint || error
1053 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
1056 [ -e $DIR/d32c ] && rm -fr $DIR/d32c
1057 mkdir -p $DIR/d32c/ext2-mountpoint
1058 mount -t ext2 -o loop $EXT2_DEV $DIR/d32c/ext2-mountpoint || error
1059 mkdir -p $DIR/d32c/d2/test_dir
1060 $CHECKSTAT -t dir $DIR/d32c/ext2-mountpoint/../d2/test_dir || error
1061 umount $DIR/d32c/ext2-mountpoint || error
1063 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
1066 [ -e $DIR/d32d ] && rm -fr $DIR/d32d
1067 mkdir -p $DIR/d32d/ext2-mountpoint
1068 mount -t ext2 -o loop $EXT2_DEV $DIR/d32d/ext2-mountpoint || error
1069 mkdir -p $DIR/d32d/d2/test_dir
1070 ls -al $DIR/d32d/ext2-mountpoint/../d2/test_dir || error
1071 umount $DIR/d32d/ext2-mountpoint || error
1073 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
1076 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
1077 mkdir -p $DIR/d32e/tmp
1078 TMP_DIR=$DIR/d32e/tmp
1079 ln -s $DIR/d32e $TMP_DIR/symlink11
1080 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1081 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
1082 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
1084 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
1087 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
1088 mkdir -p $DIR/d32f/tmp
1089 TMP_DIR=$DIR/d32f/tmp
1090 ln -s $DIR/d32f $TMP_DIR/symlink11
1091 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1092 ls $DIR/d32f/tmp/symlink11 || error
1093 ls $DIR/d32f/symlink01 || error
1095 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
1098 [ -e $DIR/d32g ] && rm -fr $DIR/d32g
1099 [ -e $DIR/test_dir ] && rm -fr $DIR/test_dir
1100 mkdir -p $DIR/test_dir
1101 mkdir -p $DIR/d32g/tmp
1102 TMP_DIR=$DIR/d32g/tmp
1103 ln -s $DIR/test_dir $TMP_DIR/symlink12
1104 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1105 $CHECKSTAT -t link $DIR/d32g/tmp/symlink12 || error
1106 $CHECKSTAT -t link $DIR/d32g/symlink02 || error
1107 $CHECKSTAT -t dir -f $DIR/d32g/tmp/symlink12 || error
1108 $CHECKSTAT -t dir -f $DIR/d32g/symlink02 || error
1110 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/test_dir"
1113 [ -e $DIR/d32h ] && rm -fr $DIR/d32h
1114 [ -e $DIR/test_dir ] && rm -fr $DIR/test_dir
1115 mkdir -p $DIR/test_dir
1116 mkdir -p $DIR/d32h/tmp
1117 TMP_DIR=$DIR/d32h/tmp
1118 ln -s $DIR/test_dir $TMP_DIR/symlink12
1119 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1120 ls $DIR/d32h/tmp/symlink12 || error
1121 ls $DIR/d32h/symlink02 || error
1123 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/test_dir"
1126 [ -e $DIR/d32i ] && rm -fr $DIR/d32i
1127 mkdir -p $DIR/d32i/ext2-mountpoint
1128 mount -t ext2 -o loop $EXT2_DEV $DIR/d32i/ext2-mountpoint || error
1129 touch $DIR/d32i/test_file
1130 $CHECKSTAT -t file $DIR/d32i/ext2-mountpoint/../test_file || error
1131 umount $DIR/d32i/ext2-mountpoint || error
1133 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
1136 [ -e $DIR/d32j ] && rm -fr $DIR/d32j
1137 mkdir -p $DIR/d32j/ext2-mountpoint
1138 mount -t ext2 -o loop $EXT2_DEV $DIR/d32j/ext2-mountpoint || error
1139 touch $DIR/d32j/test_file
1140 cat $DIR/d32j/ext2-mountpoint/../test_file || error
1141 umount $DIR/d32j/ext2-mountpoint || error
1143 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
1147 mkdir -p $DIR/d32k/ext2-mountpoint
1148 mount -t ext2 -o loop $EXT2_DEV $DIR/d32k/ext2-mountpoint
1149 mkdir -p $DIR/d32k/d2
1150 touch $DIR/d32k/d2/test_file || error
1151 $CHECKSTAT -t file $DIR/d32k/ext2-mountpoint/../d2/test_file || error
1152 umount $DIR/d32k/ext2-mountpoint || error
1154 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
1158 mkdir -p $DIR/d32l/ext2-mountpoint
1159 mount -t ext2 -o loop $EXT2_DEV $DIR/d32l/ext2-mountpoint || error
1160 mkdir -p $DIR/d32l/d2
1161 touch $DIR/d32l/d2/test_file
1162 cat $DIR/d32l/ext2-mountpoint/../d2/test_file || error
1163 umount $DIR/d32l/ext2-mountpoint || error
1165 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
1169 mkdir -p $DIR/d32m/tmp
1170 TMP_DIR=$DIR/d32m/tmp
1171 ln -s $DIR $TMP_DIR/symlink11
1172 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1173 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
1174 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
1176 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
1180 mkdir -p $DIR/d32n/tmp
1181 TMP_DIR=$DIR/d32n/tmp
1182 ln -s $DIR $TMP_DIR/symlink11
1183 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1184 ls -l $DIR/d32n/tmp/symlink11 || error
1185 ls -l $DIR/d32n/symlink01 || error
1187 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
1191 rm -f $DIR/test_file
1192 touch $DIR/test_file
1193 mkdir -p $DIR/d32o/tmp
1194 TMP_DIR=$DIR/d32o/tmp
1195 ln -s $DIR/test_file $TMP_DIR/symlink12
1196 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1197 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
1198 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
1199 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
1200 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
1202 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/test_file"
1208 rm -f $DIR/test_file
1210 touch $DIR/test_file
1212 mkdir -p $DIR/d32p/tmp
1214 TMP_DIR=$DIR/d32p/tmp
1216 ln -s $DIR/test_file $TMP_DIR/symlink12
1218 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1220 cat $DIR/d32p/tmp/symlink12 || error
1222 cat $DIR/d32p/symlink02 || error
1225 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/test_file"
1228 [ -e $DIR/d32q ] && rm -fr $DIR/d32q
1230 touch $DIR/d32q/under_the_mount
1231 mount -t ext2 -o loop $EXT2_DEV $DIR/d32q
1232 ls $DIR/d32q/under_the_mount && error || true
1233 umount $DIR/d32q || error
1235 run_test 32q "stat follows mountpoints in Lustre (should return error)"
1238 [ -e $DIR/d32r ] && rm -fr $DIR/d32r
1240 touch $DIR/d32r/under_the_mount
1241 mount -t ext2 -o loop $EXT2_DEV $DIR/d32r
1242 ls $DIR/d32r | grep -q under_the_mount && error || true
1243 umount $DIR/d32r || error
1245 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
1247 # chmod 444 /mnt/lustre/somefile
1248 # open(/mnt/lustre/somefile, O_RDWR)
1251 rm -f $DIR/test_33_file
1252 touch $DIR/test_33_file
1253 chmod 444 $DIR/test_33_file
1254 chown $RUNAS_ID $DIR/test_33_file
1256 $RUNAS $OPENFILE -f O_RDWR $DIR/test_33_file && error || true
1259 run_test 33 "write file with mode 444 (should return error) ===="
1264 chown $RUNAS_ID $DIR/d33
1265 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 || error
1266 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && error || true
1268 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
1270 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
1273 $MCREATE $DIR/f34 || error
1274 $LFIND $DIR/f34 2>&1 | grep -q "no stripe info" || error
1275 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
1276 $LFIND $DIR/f34 2>&1 | grep -q "no stripe info" || error
1277 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1279 run_test 34a "truncate file that has not been opened ==========="
1282 [ ! -f $DIR/f34 ] && test_34a
1283 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1284 $OPENFILE -f O_RDONLY $DIR/f34
1285 $LFIND $DIR/f34 2>&1 | grep -q "no stripe info" || error
1286 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1288 run_test 34b "O_RDONLY opening file doesn't create objects ====="
1291 [ ! -f $DIR/f34 ] && test_34a
1292 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1293 $OPENFILE -f O_RDWR $DIR/f34
1294 $LFIND $DIR/f34 2>&1 | grep -q "no stripe info" && error
1295 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1297 run_test 34c "O_RDWR opening file-with-size works =============="
1300 [ ! -f $DIR/f34 ] && test_34a
1301 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
1302 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1305 run_test 34d "write to sparse file ============================="
1309 $MCREATE $DIR/f34e || error
1310 $TRUNCATE $DIR/f34e 1000 || error
1311 $CHECKSTAT -s 1000 $DIR/f34e || error
1312 $OPENFILE -f O_RDWR $DIR/f34e
1313 $CHECKSTAT -s 1000 $DIR/f34e || error
1315 run_test 34e "create objects, some with size and some without =="
1317 test_34f() { # bug 6242, 6243
1320 $MCREATE $DIR/f34f || error
1321 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
1322 dd if=$DIR/f34f of=$TMP/f34f
1323 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
1324 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
1325 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
1326 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
1327 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
1329 run_test 34f "read from a file with no objects until EOF ======="
1332 cp /bin/sh $DIR/f35a
1334 chown $RUNAS_ID $DIR/f35a
1335 $RUNAS $DIR/f35a && error || true
1338 run_test 35a "exec file with mode 444 (should return and not leak) ====="
1342 utime $DIR/f36 || error
1344 run_test 36a "MDS utime check (mknod, utime) ==================="
1348 utime $DIR/f36 || error
1350 run_test 36b "OST utime check (open, utime) ===================="
1355 chown $RUNAS_ID $DIR/d36
1356 $RUNAS utime $DIR/d36/f36 || error
1358 run_test 36c "non-root MDS utime check (mknod, utime) =========="
1361 [ ! -d $DIR/d36 ] && test_36c
1362 echo "" > $DIR/d36/f36
1363 $RUNAS utime $DIR/d36/f36 || error
1365 run_test 36d "non-root OST utime check (open, utime) ==========="
1368 [ $RUNAS_ID -eq $UID ] && echo "skipping test 36e" && return
1369 [ ! -d $DIR/d36 ] && mkdir $DIR/d36
1371 $RUNAS utime $DIR/d36/f36e && error "utime worked, want failure" || true
1373 run_test 36e "utime on non-owned file (should return error) ===="
1376 mkdir -p $DIR/dextra
1377 echo f > $DIR/dextra/fbugfile
1378 mount -t ext2 -o loop $EXT2_DEV $DIR/dextra
1379 ls $DIR/dextra | grep "\<fbugfile\>" && error
1380 umount $DIR/dextra || error
1381 rm -f $DIR/dextra/fbugfile || error
1383 run_test 37 "ls a mounted file system to check old content ====="
1386 o_directory $DIR/test38
1388 run_test 38 "open a regular file with O_DIRECTORY =============="
1391 touch $DIR/test_39_file
1392 touch $DIR/test_39_file2
1393 # ls -l $DIR/test_39_file $DIR/test_39_file2
1394 # ls -lu $DIR/test_39_file $DIR/test_39_file2
1395 # ls -lc $DIR/test_39_file $DIR/test_39_file2
1397 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/test_39_file2
1398 # ls -l $DIR/test_39_file $DIR/test_39_file2
1399 # ls -lu $DIR/test_39_file $DIR/test_39_file2
1400 # ls -lc $DIR/test_39_file $DIR/test_39_file2
1401 [ $DIR/test_39_file2 -nt $DIR/test_39_file ] || error
1403 run_test 39 "mtime changed on create ==========================="
1406 dd if=/dev/zero of=$DIR/f40 bs=4096 count=1
1407 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/f40 && error
1408 $CHECKSTAT -t file -s 4096 $DIR/f40 || error
1410 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
1414 small_write $DIR/f41 18
1416 run_test 41 "test small file write + fstat ====================="
1418 count_ost_writes() {
1419 cat /proc/fs/lustre/osc/*/stats |
1420 awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }'
1427 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs
1428 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
1429 echo $WRITEBACK_SAVE > /proc/sys/vm/dirty_writeback_centisecs
1431 # if file not here, we are a 2.4 kernel
1432 kill -CONT `pidof kupdated`
1436 # setup the trap first, so someone cannot exit the test at the
1437 # exact wrong time and mess up a machine
1438 trap start_writeback EXIT
1439 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
1440 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
1441 WRITEBACK_SAVE=`cat /proc/sys/vm/dirty_writeback_centisecs`
1442 echo 0 > /proc/sys/vm/dirty_writeback_centisecs
1444 # if file not here, we are a 2.4 kernel
1445 kill -STOP `pidof kupdated`
1449 # ensure that all stripes have some grant before we test client-side cache
1451 [ "$SETUP_TEST42" ] && return
1452 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
1453 dd if=/dev/zero of=$i bs=4k count=1
1459 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
1460 # file truncation, and file removal.
1463 cancel_lru_locks OSC
1465 sync; sleep 1; sync # just to be safe
1466 BEFOREWRITES=`count_ost_writes`
1467 grep "[0-9]" /proc/fs/lustre/osc/OSC*MNT*/cur_grant_bytes
1468 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
1469 AFTERWRITES=`count_ost_writes`
1470 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
1471 error "$BEFOREWRITES < $AFTERWRITES"
1474 run_test 42a "ensure that we don't flush on close =============="
1478 cancel_lru_locks OSC
1481 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
1482 BEFOREWRITES=`count_ost_writes`
1483 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
1484 AFTERWRITES=`count_ost_writes`
1485 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
1486 error "$BEFOREWRITES < $AFTERWRITES on unlink"
1487 $LCTL dk | sort -k 4 -t: | gzip -9 > $TMP/debug-unlk.bug5195.gz
1488 error "please put $TMP/debug-unlk.bug5195.gz on bug 5195 once"
1490 BEFOREWRITES=`count_ost_writes`
1491 sync || error "sync: $?"
1492 AFTERWRITES=`count_ost_writes`
1493 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
1494 error "$BEFOREWRITES < $AFTERWRITES on sync"
1495 $LCTL dk | sort -k 4 -t: | gzip -9 > $TMP/debug-sync.bug5195.gz
1496 error "please put $TMP/debug-sync.bug5195.gz on bug 5195 once"
1498 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
1502 run_test 42b "test destroy of file with cached dirty data ======"
1504 # if these tests just want to test the effect of truncation,
1505 # they have to be very careful. consider:
1506 # - the first open gets a {0,EOF}PR lock
1507 # - the first write conflicts and gets a {0, count-1}PW
1508 # - the rest of the writes are under {count,EOF}PW
1509 # - the open for truncate tries to match a {0,EOF}PR
1510 # for the filesize and cancels the PWs.
1511 # any number of fixes (don't get {0,EOF} on open, match
1512 # composite locks, do smarter file size management) fix
1513 # this, but for now we want these tests to verify that
1514 # the cancellation with truncate intent works, so we
1515 # start the file with a full-file pw lock to match against
1516 # until the truncate.
1521 cancel_lru_locks OSC
1523 # prime the file with 0,EOF PW to match
1527 # now the real test..
1528 dd if=/dev/zero of=$file bs=1024 count=100
1529 BEFOREWRITES=`count_ost_writes`
1530 $TRUNCATE $file $offset
1531 cancel_lru_locks OSC
1532 AFTERWRITES=`count_ost_writes`
1538 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
1539 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
1542 run_test 42c "test partial truncate of file with cached dirty data"
1546 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
1547 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
1550 run_test 42d "test complete truncate of file with cached dirty data"
1554 cp -p /bin/ls $DIR/d43/f
1555 exec 100>> $DIR/d43/f
1556 $DIR/d43/f && error || true
1559 run_test 43 "execution of file opened for write should return -ETXTBSY"
1563 cp -p `which multiop` $DIR/d43/multiop
1564 $DIR/d43/multiop $TMP/test43.junk O_c &
1567 multiop $DIR/d43/multiop Oc && error "expected error, got success"
1568 kill -USR1 $MULTIPID || return 2
1569 wait $MULTIPID || return 3
1571 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
1575 cp -p `which multiop` $DIR/d43/multiop
1576 $DIR/d43/multiop $TMP/test43.junk O_c &
1579 truncate $DIR/d43/multiop 0 && error "expected error, got success"
1580 kill -USR1 $MULTIPID || return 2
1581 wait $MULTIPID || return 3
1583 run_test 43b "truncate of file being executed should return -ETXTBSY"
1586 local testdir="$DIR/d43c"
1589 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
1590 ( cd $testdir && md5sum -c)
1592 run_test 43c "md5sum of copy into lustre========================"
1595 [ "$OSTCOUNT" -lt "2" ] && echo "skipping 2-stripe test" && return
1596 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
1597 dd if=$DIR/f1 bs=4k count=1
1599 run_test 44 "zero length read from a sparse stripe ============="
1602 local nstripe=`$LCTL lov_getconfig $DIR | grep default_stripe_count: | \
1604 local stride=`$LCTL lov_getconfig $DIR | grep default_stripe_size: | \
1606 if [ $nstripe -eq 0 ] ; then
1607 nstripe=`$LCTL lov_getconfig $DIR | grep obd_count: | awk '{print $2}'`
1610 OFFSETS="0 $((stride/2)) $((stride-1))"
1611 for offset in $OFFSETS ; do
1612 for i in `seq 0 $((nstripe-1))`; do
1614 local GLOBALOFFSETS=""
1615 local size=$((((i + 2 * $nstripe )*$stride + $offset))) # Bytes
1616 ll_sparseness_write $DIR/d44a $size || error "ll_sparseness_write"
1617 GLOBALOFFSETS="$GLOBALOFFSETS $size"
1618 ll_sparseness_verify $DIR/d44a $GLOBALOFFSETS \
1619 || error "ll_sparseness_verify $GLOBALOFFSETS"
1621 for j in `seq 0 $((nstripe-1))`; do
1622 size=$((((j + $nstripe )*$stride + $offset))) # Bytes
1623 ll_sparseness_write $DIR/d44a $size || error "ll_sparseness_write"
1624 GLOBALOFFSETS="$GLOBALOFFSETS $size"
1626 ll_sparseness_verify $DIR/d44a $GLOBALOFFSETS \
1627 || error "ll_sparseness_verify $GLOBALOFFSETS"
1631 run_test 44a "test sparse pwrite ==============================="
1635 for d in /proc/fs/lustre/osc/*/cur_dirty_bytes; do
1636 tot=$(($tot + `cat $d`))
1641 before=`dirty_osc_total`
1642 echo executing "\"$*\""
1644 after=`dirty_osc_total`
1645 echo before $before, after $after
1649 # Obtain grants from OST if it supports it
1650 echo blah > ${f}_grant
1653 do_dirty_record "echo blah > $f"
1654 [ $before -eq $after ] && error "write wasn't cached"
1655 do_dirty_record "> $f"
1656 [ $before -gt $after ] || error "truncate didn't lower dirty count"
1657 do_dirty_record "echo blah > $f"
1658 [ $before -eq $after ] && error "write wasn't cached"
1659 do_dirty_record "sync"
1660 [ $before -gt $after ] || error "writeback didn't lower dirty count"
1661 do_dirty_record "echo blah > $f"
1662 [ $before -eq $after ] && error "write wasn't cached"
1663 do_dirty_record "cancel_lru_locks OSC"
1664 [ $before -gt $after ] || error "lock cancellation didn't lower dirty count"
1667 run_test 45 "osc io page accounting ============================"
1673 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
1674 # test tickles a bug where re-dirtying a page was failing to be mapped to the
1675 # objects offset and an assert hit when an rpc was built with 1023's mapped
1676 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
1681 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
1683 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
1684 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
1688 run_test 46 "dirtying a previously written page ================"
1690 # Check that device nodes are created and then visible correctly (#2091)
1692 cmknod $DIR/test_47_node || error
1694 run_test 47 "Device nodes check ================================"
1696 test_48a() { # bug 2399
1697 check_kernel_version 34 || return 0
1700 mv $DIR/d48a $DIR/d48.new || error "move directory failed"
1701 mkdir $DIR/d48a || error "recreate directory failed"
1702 touch foo || error "'touch foo' failed after recreating cwd"
1703 mkdir bar || error "'mkdir foo' failed after recreating cwd"
1704 if check_kernel_version 44; then
1705 touch .foo || error "'touch .foo' failed after recreating cwd"
1706 mkdir .bar || error "'mkdir .foo' failed after recreating cwd"
1708 ls . || error "'ls .' failed after recreating cwd"
1709 ls .. || error "'ls ..' failed after removing cwd"
1710 cd . || error "'cd .' failed after recreating cwd"
1711 mkdir . && error "'mkdir .' worked after recreating cwd"
1712 rmdir . && error "'rmdir .' worked after recreating cwd"
1713 ln -s . baz || error "'ln -s .' failed after recreating cwd"
1714 cd .. || error "'cd ..' failed after recreating cwd"
1716 run_test 48a "Access renamed working dir (should return errors)="
1718 test_48b() { # bug 2399
1719 check_kernel_version 34 || return 0
1722 rmdir $DIR/d48b || error "remove cwd $DIR/d48b failed"
1723 touch foo && error "'touch foo' worked after removing cwd"
1724 mkdir foo && error "'mkdir foo' worked after removing cwd"
1725 if check_kernel_version 44; then
1726 touch .foo && error "'touch .foo' worked after removing cwd"
1727 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
1729 ls . && error "'ls .' worked after removing cwd"
1730 ls .. || error "'ls ..' failed after removing cwd"
1731 cd . && error "'cd .' worked after removing cwd"
1732 mkdir . && error "'mkdir .' worked after removing cwd"
1733 rmdir . && error "'rmdir .' worked after removing cwd"
1734 ln -s . foo && error "'ln -s .' worked after removing cwd"
1735 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
1737 run_test 48b "Access removed working dir (should return errors)="
1739 test_48c() { # bug 2350
1740 check_kernel_version 36 || return 0
1741 #sysctl -w portals.debug=-1
1743 mkdir -p $DIR/d48c/dir
1745 $TRACE rmdir $DIR/d48c/dir || error "remove cwd $DIR/d48c/dir failed"
1746 $TRACE touch foo && error "'touch foo' worked after removing cwd"
1747 $TRACE mkdir foo && error "'mkdir foo' worked after removing cwd"
1748 if check_kernel_version 44; then
1749 touch .foo && error "'touch .foo' worked after removing cwd"
1750 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
1752 $TRACE ls . && error "'ls .' worked after removing cwd"
1753 $TRACE ls .. || error "'ls ..' failed after removing cwd"
1754 $TRACE cd . && error "'cd .' worked after removing cwd"
1755 $TRACE mkdir . && error "'mkdir .' worked after removing cwd"
1756 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
1757 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
1758 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
1760 run_test 48c "Access removed working subdir (should return errors)"
1762 test_48d() { # bug 2350
1763 check_kernel_version 36 || return 0
1764 #sysctl -w portals.debug=-1
1766 mkdir -p $DIR/d48d/dir
1768 $TRACE rmdir $DIR/d48d/dir || error "remove cwd $DIR/d48d/dir failed"
1769 $TRACE rmdir $DIR/d48d || error "remove parent $DIR/d48d failed"
1770 $TRACE touch foo && error "'touch foo' worked after removing parent"
1771 $TRACE mkdir foo && error "'mkdir foo' worked after removing parent"
1772 if check_kernel_version 44; then
1773 touch .foo && error "'touch .foo' worked after removing parent"
1774 mkdir .foo && error "'mkdir .foo' worked after removing parent"
1776 $TRACE ls . && error "'ls .' worked after removing parent"
1777 $TRACE ls .. && error "'ls ..' worked after removing parent"
1778 $TRACE cd . && error "'cd .' worked after recreate parent"
1779 $TRACE mkdir . && error "'mkdir .' worked after removing parent"
1780 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
1781 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
1782 $TRACE cd .. && error "'cd ..' worked after removing parent" || true
1784 run_test 48d "Access removed parent subdir (should return errors)"
1786 test_48e() { # bug 4134
1787 check_kernel_version 41 || return 0
1788 #sysctl -w portals.debug=-1
1790 mkdir -p $DIR/d48e/dir
1792 $TRACE rmdir $DIR/d48e/dir || error "remove cwd $DIR/d48e/dir failed"
1793 $TRACE rmdir $DIR/d48e || error "remove parent $DIR/d48e failed"
1794 $TRACE touch $DIR/d48e || error "'touch $DIR/d48e' failed"
1795 $TRACE chmod +x $DIR/d48e || error "'chmod +x $DIR/d48e' failed"
1796 # On a buggy kernel addition of "touch foo" after cd .. will
1797 # produce kernel oops in lookup_hash_it
1798 cd -P .. && error "'cd ..' worked after recreate parent"
1801 $TRACE rm $DIR/d48e || error "rm '$DIR/d48e' failed"
1803 run_test 48e "Access to recreated parent subdir (should return errors)"
1809 ls /proc/$$/cwd || error
1811 run_test 50 "special situations: /proc symlinks ==============="
1814 # bug 1516 - create an empty entry right after ".." then split dir
1817 $MCREATE $DIR/d49/bar
1819 createmany -m $DIR/d49/longfile 201
1821 while [ `ls -sd $DIR/d49 | awk '{ print $1 }'` -eq 4 ]; do
1822 $MCREATE $DIR/d49/longfile$FNUM
1826 ls -l $DIR/d49 > /dev/null || error
1828 run_test 51 "special situations: split htree with empty entry =="
1830 export NUMTEST=70000
1832 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
1833 [ $NUMFREE -lt 21000 ] && \
1834 echo "skipping test 51b, not enough free inodes ($NUMFREE)" && \
1837 check_kernel_version 40 || NUMTEST=31000
1838 [ $NUMFREE -lt $NUMTEST ] && NUMTEST=$(($NUMFREE - 50))
1841 createmany -d $DIR/d51b/t- $NUMTEST
1843 run_test 51b "mkdir .../t-0 --- .../t-$NUMTEST ===================="
1846 [ ! -d $DIR/d51b ] && echo "skipping test 51c: $DIR/51b missing" && \
1849 unlinkmany -d $DIR/d51b/t- $NUMTEST
1851 run_test 51c "rmdir .../t-0 --- .../t-$NUMTEST ===================="
1854 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
1857 chattr =a $DIR/d52a/foo || error
1858 echo bar >> $DIR/d52a/foo || error
1859 cp /etc/hosts $DIR/d52a/foo && error
1860 rm -f $DIR/d52a/foo 2>/dev/null && error
1861 link $DIR/d52a/foo $DIR/d52a/foo_link 2>/dev/null && error
1862 echo foo >> $DIR/d52a/foo || error
1863 mrename $DIR/d52a/foo $DIR/d52a/foo_ren && error
1864 lsattr $DIR/d52a/foo | egrep -q "^-+a-+ $DIR/d52a/foo" || error
1865 chattr -a $DIR/d52a/foo || error
1867 rm -fr $DIR/d52a || error
1869 run_test 52a "append-only flag test (should return errors) ====="
1872 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
1875 chattr =i $DIR/d52b/foo || error
1876 cat test > $DIR/d52b/foo && error
1877 cp /etc/hosts $DIR/d52b/foo && error
1878 rm -f $DIR/d52b/foo 2>/dev/null && error
1879 link $DIR/d52b/foo $DIR/d52b/foo_link 2>/dev/null && error
1880 echo foo >> $DIR/d52b/foo && error
1881 mrename $DIR/d52b/foo $DIR/d52b/foo_ren && error
1882 [ -f $DIR/d52b/foo ] || error
1883 [ -f $DIR/d52b/foo_ren ] && error
1884 lsattr $DIR/d52b/foo | egrep -q "^-+i-+ $DIR/d52b/foo" || error
1885 chattr -i $DIR/d52b/foo || error
1887 rm -fr $DIR/d52b || error
1889 run_test 52b "immutable flag test (should return errors) ======="
1892 for i in `ls -d /proc/fs/lustre/osc/OSC*mds1 2> /dev/null` ; do
1893 ostname=`echo $i | cut -d _ -f 3-4 | sed -e s/_mds1//`
1894 ost_last=`cat /proc/fs/lustre/obdfilter/$ostname/last_id`
1895 mds_last=`cat $i/prealloc_last_id`
1896 echo "$ostname.last_id=$ost_last ; MDS.last_id=$mds_last"
1897 if [ $ost_last != $mds_last ]; then
1898 error "$ostname.last_id=$ost_last ; MDS.last_id=$mds_last"
1902 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
1905 $SOCKETSERVER $DIR/socket
1906 $SOCKETCLIENT $DIR/socket || error
1907 $MUNLINK $DIR/socket
1909 run_test 54a "unix damain socket test =========================="
1915 dd if=/dev/zero of=$f bs=`page_size` count=1
1917 run_test 54b "char device works in lustre ======================"
1920 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
1921 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
1922 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
1924 for i in `seq 3 7`; do
1925 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
1935 loopdev="$DIR/loop54c"
1938 [ -z "$LOOPNUM" ] && echo "couldn't find empty loop device" && return
1939 mknod $loopdev b 7 $LOOPNUM
1940 echo "make a loop file system with $tfile on $loopdev ($LOOPNUM)..."
1941 dd if=/dev/zero of=$tfile bs=`page_size` seek=1024 count=1 > /dev/null
1942 losetup $loopdev $tfile || error "can't set up $loopdev for $tfile"
1943 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
1945 mount -t ext2 $loopdev $tdir || error "error mounting $loopdev on $tdir"
1946 dd if=/dev/zero of=$tdir/tmp bs=`page_size` count=30 || error "dd write"
1948 dd if=$tdir/tmp of=/dev/zero bs=`page_size` count=30 || error "dd read"
1953 run_test 54c "block device works in lustre ====================="
1959 [ "$string" = `echo $string > $f | cat $f` ] || error
1961 run_test 54d "fifo device works in lustre ======================"
1964 grep -q $FSTYPE /proc/filesystems && return 1
1966 grep -q $FSTYPE /proc/filesystems && return 1
1967 insmod ../$FSTYPE/$FSTYPE.o
1968 grep -q $FSTYPE /proc/filesystems && return 1
1969 insmod ../$FSTYPE/$FSTYPE.ko
1970 grep -q $FSTYPE /proc/filesystems && return 1
1977 check_fstype && echo "can't find fs $FSTYPE, skipping test 55" && return
1978 mount -t $FSTYPE -o loop,iopen $EXT2_DEV $DIR/d55 || error "mounting"
1980 $IOPENTEST1 $DIR/d55/foo $DIR/d55 || error "running $IOPENTEST1"
1981 $IOPENTEST2 $DIR/d55 || error "running $IOPENTEST2"
1982 echo "check for $EXT2_DEV. Please wait..."
1984 umount $DIR/d55 || error "unmounting"
1986 run_test 55 "check iopen_connect_dentry() ======================"
1993 NUMFILESx2=$(($NUMFILES * 2))
1994 for i in `seq 1 $NUMFILES` ; do
1995 touch $DIR/d56/file$i
1996 touch $DIR/d56/dir/file$i
1999 # test lfs find with --recursive
2000 FILENUM=`$LFIND --recursive $DIR/d56 | grep -c obdidx`
2001 [ $FILENUM -eq $NUMFILESx2 ] || error \
2002 "lfs find --recursive $DIR/d56 wrong: found $FILENUM, expected $NUMFILESx2"
2003 FILENUM=`$LFIND $DIR/d56 | grep -c obdidx`
2004 [ $FILENUM -eq $NUMFILES ] || error \
2005 "lfs find $DIR/d56 without --recursive wrong: found $FILENUM, expected $NUMFILES"
2006 echo "lfs find --recursive passed."
2008 # test lfs find with file instead of dir
2009 FILENUM=`$LFIND $DIR/d56/file1 | grep -c obdidx`
2010 [ $FILENUM -eq 1 ] || error \
2011 "lfs find $DIR/d56/file1 wrong:found $FILENUM, expected 1"
2012 echo "lfs find file passed."
2014 #test lfs find with --verbose
2015 [ `$LFIND --verbose $DIR/d56 | grep -c lmm_magic` -eq $NUMFILES ] ||\
2016 error "lfs find --verbose $DIR/d56 wrong: should find $NUMFILES lmm_magic info"
2017 [ `$LFIND $DIR/d56 | grep -c lmm_magic` -eq 0 ] || error \
2018 "lfs find $DIR/d56 without --verbose wrong: should not show lmm_magic info"
2019 echo "lfs find --verbose passed."
2021 #test lfs find with --obd
2022 $LFIND --obd wrong_uuid $DIR/d56 2>&1 | grep -q "unknown obduuid" || \
2023 error "lfs find --obd wrong_uuid should return error message"
2025 [ "$OSTCOUNT" -lt 2 ] && \
2026 echo "skipping other lfs find --obd test" && return
2027 FILENUM=`$LFIND --recursive $DIR/d56 | sed -n '/^[ ]*1[ ]/p' | wc -l`
2028 OBDUUID=`$LFIND --recursive $DIR/d56 | sed -n '/^[ ]*1:/p' | awk '{print $2}'`
2029 FOUND=`$LFIND -r --obd $OBDUUID $DIR/d56 | wc -l`
2030 [ $FOUND -eq $FILENUM ] || \
2031 error "lfs find --obd wrong: found $FOUND, expected $FILENUM"
2032 [ `$LFIND -r -v --obd $OBDUUID $DIR/d56 | sed '/^[ ]*1[ ]/d' |\
2033 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l` -eq 0 ] || \
2034 error "lfs find --obd wrong: should not show file on other obd"
2035 echo "lfs find --obd passed."
2037 run_test 56 "check lfs find ===================================="
2040 # note test will not do anything if MDS is not local
2041 for DEV in `cat /proc/fs/lustre/mds/*/mntdev`; do
2042 dumpe2fs -h $DEV > $TMP/t57a.dump || error "can't access $DEV"
2043 DEVISIZE=`awk '/Inode size:/ { print $3 }' $TMP/t57a.dump`
2044 [ "$DEVISIZE" -gt 128 ] || error "inode size $DEVISIZE"
2048 run_test 57a "verify MDS filesystem created with large inodes =="
2053 FILEN=$DIR/d57b/f$FILECOUNT
2054 rm -rf $DIR/d57b || error "removing $DIR/d57b"
2055 mkdir -p $DIR/d57b || error "creating $DIR/d57b"
2056 echo "mcreating $FILECOUNT files"
2057 createmany -m $DIR/d57b/f 1 $FILECOUNT || \
2058 error "creating files in $DIR/d57b"
2060 # verify that files do not have EAs yet
2061 $LFIND $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
2062 $LFIND $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
2064 MDSFREE="`cat /proc/fs/lustre/mds/*/kbytesfree`"
2065 MDCFREE="`cat /proc/fs/lustre/mdc/*/kbytesfree`"
2066 echo "opening files to create objects/EAs"
2067 for FILE in `seq -f $DIR/d57b/f%g 1 $FILECOUNT`; do
2068 $OPENFILE -f O_RDWR $FILE > /dev/null || error "opening $FILE"
2071 # verify that files have EAs now
2072 $LFIND $FILE1 | grep -q "obdidx" || error "$FILE1 missing EA"
2073 $LFIND $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
2075 MDSFREE2="`cat /proc/fs/lustre/mds/*/kbytesfree`"
2076 MDCFREE2="`cat /proc/fs/lustre/mdc/*/kbytesfree`"
2077 if [ "$MDCFREE" != "$MDCFREE2" ]; then
2078 if [ "$MDSFREE" != "$MDSFREE2" ]; then
2079 error "MDC before $MDCFREE != after $MDCFREE2"
2081 echo "MDC before $MDCFREE != after $MDCFREE2"
2082 echo "unable to confirm if MDS has large inodes"
2087 run_test 57b "default LOV EAs are stored inside large inodes ==="
2092 run_test 58 "verify cross-platform wire constants =============="
2095 echo "touch 130 files"
2096 for i in `seq 1 130` ; do
2100 for i in `seq 1 130` ; do
2105 # wait for commitment of removal
2107 run_test 59 "verify cancellation of llog records async ========="
2110 echo 60 "llog tests run from kernel mode"
2113 run_test 60 "llog sanity tests run from kernel module =========="
2117 dd if=/dev/zero of=$f bs=`page_size` count=1
2118 cancel_lru_locks OSC
2119 multiop $f OSMWUc || error
2122 run_test 61 "mmap() writes don't make sync hang ================"
2124 # bug 2330 - insufficient obd_match error checking causes LBUG
2128 cancel_lru_locks OSC
2129 echo 0x405 > /proc/sys/lustre/fail_loc
2130 cat $f && error "cat succeeded, expect -EIO"
2131 echo 0 > /proc/sys/lustre/fail_loc
2133 run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
2135 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
2137 MAX_DIRTY_MB=`cat /proc/fs/lustre/osc/*/max_dirty_mb | head -n 1`
2138 for i in /proc/fs/lustre/osc/*/max_dirty_mb ; do
2141 for i in `seq 10` ; do
2142 dd if=/dev/zero of=$DIR/f63 bs=8k &
2148 for i in /proc/fs/lustre/osc/*/max_dirty_mb ; do
2149 echo $MAX_DIRTY_MB > $i
2153 run_test 63 "Verify oig_wait interruption does not crash ======="
2155 # bug 2248 - async write errors didn't return to application on sync
2156 # bug 3677 - async write errors left page locked
2158 DBG_SAVE=`cat /proc/sys/portals/debug`
2159 sysctl -w portals.debug=-1
2161 # ensure we have a grant to do async writes
2162 dd if=/dev/zero of=/mnt/lustre/f63b bs=4k count=1
2165 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
2166 sysctl -w lustre.fail_loc=0x80000406
2167 multiop /mnt/lustre/f63b Owy && \
2168 $LCTL dk /tmp/test63b.debug && \
2169 sysctl -w portals.debug=$DBG_SAVE && \
2170 error "sync didn't return ENOMEM"
2171 grep -q locked /proc/fs/lustre/llite/fs*/dump_page_cache && \
2172 $LCTL dk /tmp/test63b.debug && \
2173 sysctl -w portls.debug=$DBG_SAVE && \
2174 error "locked page left in cache after async error" || true
2175 sysctl -w portals.debug=$DBG_SAVE
2177 run_test 63b "async write errors should be returned to fsync ==="
2181 grep "[0-9]" /proc/fs/lustre/osc/OSC*MNT*/cur*
2183 run_test 64a "verify filter grant calculations (in kernel) ====="
2188 run_test 64b "check out-of-space detection on client ==========="
2190 # bug 1414 - set/get directories' stripe info
2194 $LVERIFY $DIR/d65 $DIR/d65/f1 || error "lverify failed"
2196 run_test 65a "directory with no stripe info ===================="
2200 $LSTRIPE $DIR/d65 $(($STRIPESIZE * 2)) 0 1 || error "setstripe"
2202 $LVERIFY $DIR/d65 $DIR/d65/f2 || error "lverify failed"
2204 run_test 65b "directory setstripe $(($STRIPESIZE * 2)) 0 1 ==============="
2207 if [ $OSTCOUNT -gt 1 ]; then
2209 $LSTRIPE $DIR/d65 $(($STRIPESIZE * 4)) 1 \
2210 $(($OSTCOUNT - 1)) || error "setstripe"
2212 $LVERIFY $DIR/d65 $DIR/d65/f3 || error "lverify failed"
2215 run_test 65c "directory setstripe $(($STRIPESIZE * 4)) 1 $(($OSTCOUNT - 1))"
2217 [ $STRIPECOUNT -eq 0 ] && sc=1 || sc=$(($STRIPECOUNT - 1))
2221 $LSTRIPE $DIR/d65 $STRIPESIZE -1 $sc || error "setstripe"
2222 touch $DIR/d65/f4 $DIR/d65/f5
2223 $LVERIFY $DIR/d65 $DIR/d65/f4 $DIR/d65/f5 || error "lverify failed"
2225 run_test 65d "directory setstripe $STRIPESIZE -1 $sc ======================"
2230 $LSTRIPE $DIR/d65 0 -1 0 || error "setstripe"
2231 $LFS find -v $DIR/d65 | grep "$DIR/d65/ has no stripe info" || error "no stripe info failed"
2233 $LVERIFY $DIR/d65 $DIR/d65/f6 || error "lverify failed"
2235 run_test 65e "directory setstripe 0 -1 0 ============="
2239 $RUNAS $LSTRIPE $DIR/d65f 0 -1 0 && error "setstripe succeeded" || true
2241 run_test 65f "dir setstripe permission (should return error) ==="
2245 $LSTRIPE $DIR/d65 $(($STRIPESIZE * 2)) 0 1 || error "setstripe"
2246 $LSTRIPE -d $DIR/d65 || error "setstripe"
2247 $LFS find -v $DIR/d65 | grep "$DIR/d65/ has no stripe info" || error "no stripe info failed"
2249 run_test 65g "directory setstripe -d ========"
2253 $LSTRIPE $DIR/d65 $(($STRIPESIZE * 2)) 0 1 || error "setstripe"
2254 mkdir -p $DIR/d65/dd1
2255 [ "`$LFS find -v $DIR/d65 | grep "^count"`" == \
2256 "`$LFS find -v $DIR/d65/dd1 | grep "^count"`" ] || error "stripe info inherit failed"
2258 run_test 65h "directory stripe info inherit ======"
2260 # bug 2543 - update blocks count on client
2263 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
2265 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
2266 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
2268 run_test 66 "update inode blocks count on client ==============="
2270 test_67() { # bug 3285 - supplementary group fails on MDS, passes on client
2271 [ "$RUNAS_ID" = "$UID" ] && echo "skipping test 67" && return
2272 check_kernel_version 35 || return 0
2275 chgrp $RUNAS_ID $DIR/d67
2276 $RUNAS -g $(($RUNAS_ID + 1)) -G1,2,$RUNAS_ID ls $DIR/d67 && error ||true
2278 run_test 67 "supplementary group failure (should return error) ="
2281 if [ "$LOOPDEV" ]; then
2282 swapoff $LOOPDEV || error "swapoff failed"
2283 losetup -d $LOOPDEV || error "losetup -d failed"
2284 unset LOOPDEV LOOPNUM
2290 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
2294 swapon -s | awk '($1 == "'$1'") { print $4 }'
2297 # excercise swapping to lustre by adding a high priority swapfile entry
2298 # and then consuming memory until it is used.
2300 [ "$UID" != 0 ] && echo "skipping test 68 (must run as root)" && return
2301 [ "`lsmod|grep obdfilter`" ] && echo "skipping test 68 (local OST)" && \
2305 dd if=/dev/zero of=$DIR/f68 bs=64k count=1024
2307 trap cleanup_68 EXIT
2309 losetup $LOOPDEV $DIR/f68 || error "losetup $LOOPDEV failed"
2311 swapon -p 32767 $LOOPDEV || error "swapon $LOOPDEV failed"
2313 echo "before: `swapon -s | grep $LOOPDEV`"
2314 KBFREE=`meminfo MemTotal`
2315 $MEMHOG $KBFREE || error "error allocating $KBFREE kB"
2316 echo "after: `swapon -s | grep $LOOPDEV`"
2317 SWAPUSED=`swap_used $LOOPDEV`
2321 [ $SWAPUSED -eq 0 ] && echo "no swap used???" || true
2323 run_test 68 "support swapping to Lustre ========================"
2325 # bug5265, obdfilter oa2dentry return -ENOENT
2326 # #define OBD_FAIL_OST_ENOENT 0x217
2328 [ -z "`lsmod|grep obdfilter`" ] &&
2329 echo "skipping test 69 (remote OST)" && return
2334 echo 0x217 > /proc/sys/lustre/fail_loc
2335 truncate $f 1 # vmtruncate() will ignore truncate() error.
2336 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
2338 echo 0 > /proc/sys/lustre/fail_loc
2339 $DIRECTIO write $f 0 2 || error "write error"
2341 cancel_lru_locks OSC
2342 $DIRECTIO read $f 0 1 || error "read error"
2344 echo 0x217 > /proc/sys/lustre/fail_loc
2345 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
2347 echo 0 > /proc/sys/lustre/fail_loc
2350 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
2353 DBENCH_LIB=${DBENCH_LIB:-/usr/lib/dbench}
2354 PATH=${PATH}:$DBENCH_LIB
2355 cp `which dbench` $DIR
2357 [ ! -f $DIR/dbench ] && echo "dbench not installed, skip this test" && return 0
2360 SRC=${SRC:-$DBENCH_LIB/client.txt}
2361 [ ! -e $TGT -a -e $SRC ] && echo "copying $SRC to $TGT" && cp $SRC $TGT
2362 SRC=$DBENCH_LIB/client_plain.txt
2363 [ ! -e $TGT -a -e $SRC ] && echo "copying $SRC to $TGT" && cp $SRC $TGT
2365 echo "copying necessary lib to $DIR"
2366 [ -d /lib64 ] && LIB71=/lib64 || LIB71=/lib
2367 mkdir $DIR$LIB71 || error "can't create $DIR$LIB71"
2368 cp $LIB71/libc* $DIR$LIB71 || error "can't copy $LIB71/libc*"
2369 cp $LIB71/ld-* $DIR$LIB71 || error "can't create $LIB71/ld-*"
2371 echo "chroot $DIR /dbench -c client.txt 2"
2372 chroot $DIR /dbench -c client.txt 2
2381 run_test 71 "Running dbench on lustre (don't segment fault) ===="
2383 test_72() { # bug 5695 - Test that on 2.6 remove_suid works properly
2384 check_kernel_version 43 || return 0
2385 [ "$RUNAS_ID" = "$UID" ] && echo "skipping test 72" && return
2389 $RUNAS -u $(($RUNAS_ID + 1)) dd if=/dev/zero of=$DIR/f72 bs=512 count=1 || error
2390 # See if we are still setuid/sgid
2391 test -u $DIR/f72 -o -g $DIR/f72 && error "S/gid is not dropped on write"
2392 # Now test that MDS is updated too
2393 cancel_lru_locks MDC
2394 test -u $DIR/f72 -o -g $DIR/f72 && error "S/gid is not dropped on MDS"
2397 run_test 72 "Test that remove suid works properly (bug5695) ===="
2399 #b_cray run_test 73 "multiple MDC requests (should not deadlock)"
2401 test_74() { # bug 6149, 6184
2402 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
2404 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
2405 # will spin in a tight reconnection loop
2406 sysctl -w lustre.fail_loc=0x8000030e
2409 sysctl -w lustre.fail_loc=0
2412 run_test 74 "ldlm_enqueue freed-export error path (shouldn't LBUG)"
2414 # on the LLNL clusters, runas will still pick up root's $TMP settings,
2415 # which will not be writable for the runas user, and then you get a CVS
2416 # error message with a corrupt path string (CVS bug) and panic.
2417 # We're not using much space, so just stick it in /tmp, which is safe.
2423 [ $RUNAS_ID -ne $UID ] && HOME=/tmp
2426 mkdir -p $DIR/d99cvsroot
2427 chown $RUNAS_ID $DIR/d99cvsroot
2428 $RUNAS cvs -d $DIR/d99cvsroot init || error
2430 run_test 99a "cvs init ========================================="
2433 [ ! -d $DIR/d99cvsroot ] && test_99a
2435 # some versions of cvs import exit(1) when asked to import links or
2436 # files they can't read. ignore those files.
2437 TOIGNORE=$(find . -type l -printf '-I %f\n' -o \
2438 ! -perm +4 -printf '-I %f\n')
2439 $RUNAS cvs -d $DIR/d99cvsroot import -m "nomesg" $TOIGNORE \
2440 d99reposname vtag rtag
2442 run_test 99b "cvs import ======================================="
2445 [ ! -d $DIR/d99cvsroot ] && test_99b
2447 mkdir -p $DIR/d99reposname
2448 chown $RUNAS_ID $DIR/d99reposname
2449 $RUNAS cvs -d $DIR/d99cvsroot co d99reposname
2451 run_test 99c "cvs checkout ====================================="
2454 [ ! -d $DIR/d99cvsroot ] && test_99c
2455 cd $DIR/d99reposname
2457 $RUNAS cvs add -m 'addmsg' foo99
2459 run_test 99d "cvs add =========================================="
2462 [ ! -d $DIR/d99cvsroot ] && test_99c
2463 cd $DIR/d99reposname
2466 run_test 99e "cvs update ======================================="
2469 [ ! -d $DIR/d99cvsroot ] && test_99d
2470 cd $DIR/d99reposname
2471 $RUNAS cvs commit -m 'nomsg' foo99
2473 run_test 99f "cvs commit ======================================="
2476 netstat -tna | while read PROT SND RCV LOCAL REMOTE STAT; do
2477 [ "$PROT" != "tcp" ] && continue
2478 RPORT=`echo $REMOTE | cut -d: -f2`
2479 [ "$RPORT" != "988" ] && continue
2480 LPORT=`echo $LOCAL | cut -d: -f2`
2481 [ $LPORT -ge 1024 ] && error "local port: $LPORT > 1024" || true
2484 run_test 100 "check local port using privileged port ==========="
2490 log "cleanup: ======================================================"
2491 if [ "`mount | grep ^$NAME`" ]; then
2492 rm -rf $DIR/[Rdfs][1-9]*
2493 if [ "$I_MOUNTED" = "yes" ]; then
2494 sh llmountcleanup.sh || error
2498 echo '=========================== finished ==============================='
2499 [ -f "$SANITYLOG" ] && cat $SANITYLOG && exit 1 || true