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 9789 3637 9789 3561 5188/5749
11 ALWAYS_EXCEPT=${ALWAYS_EXCEPT:-"42a 42b 42c 42d 45 68"}
12 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
14 [ "$SLOW" = "no" ] && EXCEPT="$EXCEPT 24o 27m 51b 51c 63 64b 71 77 101"
15 # Tests that fail on uml
16 CPU=`awk '/model/ {print $4}' /proc/cpuinfo`
17 [ "$CPU" = "UML" ] && EXCEPT="$EXCEPT 31d"
19 # Tests that always fail with mountconf -- FIXME
20 # 48a moving the working dir succeeds
23 2.4*) FSTYPE=${FSTYPE:-ext3}; ALWAYS_EXCEPT="$ALWAYS_EXCEPT 76" ;;
24 2.6*) FSTYPE=${FSTYPE:-ldiskfs}; ALWAYS_EXCEPT="$ALWAYS_EXCEPT " ;;
25 *) error "unsupported kernel" ;;
29 export PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH:/sbin
33 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
34 CREATETEST=${CREATETEST:-createtest}
36 SETSTRIPE=${SETSTRIPE:-"$LFS setstripe"}
37 GETSTRIPE=${GETSTRIPE:-"$LFS getstripe"}
38 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
40 MCREATE=${MCREATE:-mcreate}
41 OPENFILE=${OPENFILE:-openfile}
42 OPENUNLINK=${OPENUNLINK:-openunlink}
43 RANDOM_READS=${RANDOM_READS:-"random-reads"}
44 TOEXCL=${TOEXCL:-toexcl}
45 TRUNCATE=${TRUNCATE:-truncate}
46 MUNLINK=${MUNLINK:-munlink}
47 SOCKETSERVER=${SOCKETSERVER:-socketserver}
48 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
49 IOPENTEST1=${IOPENTEST1:-iopentest1}
50 IOPENTEST2=${IOPENTEST2:-iopentest2}
51 MEMHOG=${MEMHOG:-memhog}
52 DIRECTIO=${DIRECTIO:-directio}
53 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
54 UMOUNT=${UMOUNT:-"umount -d"}
56 if [ $UID -ne 0 ]; then
57 echo "Warning: running as non-root uid $UID"
61 RUNAS_ID=${RUNAS_ID:-500}
62 RUNAS=${RUNAS:-"runas -u $RUNAS_ID"}
64 # $RUNAS_ID may get set incorrectly somewhere else
65 if [ $RUNAS_ID -eq 0 ]; then
66 echo "Error: \$RUNAS_ID set to 0, but \$UID is also 0!"
71 SANITYLOG=${SANITYLOG:-/tmp/sanity.log}
73 export NAME=${NAME:-local}
77 LUSTRE=${LUSTRE:-`dirname $0`/..}
78 . $LUSTRE/tests/test-framework.sh
80 . ${CONFIG:=$LUSTRE/tests/cfg/local.sh}
82 if [ ! -z "$USING_KRB5" ]; then
83 $RUNAS krb5_login.sh || exit 1
84 $RUNAS -u $(($RUNAS_ID + 1)) krb5_login.sh || exit 1
89 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
104 $LCTL mark "$*" 2> /dev/null || true
109 strace -o $TMP/$1.strace -ttt $*
111 log "FINISHED: $*: rc $RC"
116 check_kernel_version() {
117 VERSION_FILE=$LPROC/version
119 [ ! -f $VERSION_FILE ] && echo "can't find kernel version" && return 1
120 GOT_VER=$(awk '/kernel:/ {print $2}' $VERSION_FILE)
121 [ $GOT_VER -ge $WANT_VER ] && return 0
122 log "test needs at least kernel version $WANT_VER, running $GOT_VER"
131 IFS=abcdefghijklmnopqrstuvwxyz _basetest $1
135 if ! grep -q $DIR /proc/mounts; then
141 log "== test $testnum: $message= `date +%H:%M:%S` ($BEFORE)"
142 export TESTNAME=test_$testnum
143 export tfile=f${testnum}
145 test_${testnum} || error "exit with rc=$?"
147 pass "($((`date +%s` - $BEFORE))s)"
152 build_test_filter() {
153 [ "$ALWAYS_EXCEPT$EXCEPT$SANITY_EXCEPT" ] && \
154 echo "Skipping tests: `echo $ALWAYS_EXCEPT $EXCEPT $SANITY_EXCEPT`"
159 for E in $EXCEPT $ALWAYS_EXCEPT $SANITY_EXCEPT; do
160 eval EXCEPT_${E}=true
169 IFS=abcdefghijklmnopqrstuvwxyz _basetest $1
173 export base=`basetest $1`
176 if [ ${!testname}x != x ]; then
181 if [ ${!testname}x != x ]; then
189 if [ ${!testname}x != x ]; then
190 echo "skipping excluded test $1"
193 testname=EXCEPT_$base
194 if [ ${!testname}x != x ]; then
195 echo "skipping excluded test $1 (base $base)"
202 [ "$SANITYLOG" ] && rm -f $SANITYLOG || true
205 sysctl -w lustre.fail_loc=0
206 log "FAIL: $TESTNAME $@"
207 $LCTL dk $TMP/lustre-log-$TESTNAME.log
208 if [ "$SANITYLOG" ]; then
209 echo "FAIL: $TESTNAME $@" >> $SANITYLOG
219 mounted_lustre_filesystems() {
220 awk '($3 ~ "lustre" && $1 ~ ":") { print $2 }' /proc/mounts
223 MOUNTED="`mounted_lustre_filesystems`"
224 if [ -z "$MOUNTED" ]; then
227 MOUNTED="`mounted_lustre_filesystems`"
228 [ -z "$MOUNTED" ] && error "NAME=$NAME not mounted"
232 [ `echo $MOUNT | wc -w` -gt 1 ] && error "NAME=$NAME mounted more than once"
235 [ -z "`echo $DIR | grep $MOUNT`" ] && echo "$DIR not in $MOUNT" && exit 99
237 LOVNAME=`cat $LPROC/llite/*/lov/common_name | tail -n 1`
238 OSTCOUNT=`cat $LPROC/lov/$LOVNAME/numobd`
239 STRIPECOUNT=`cat $LPROC/lov/$LOVNAME/stripecount`
240 STRIPESIZE=`cat $LPROC/lov/$LOVNAME/stripesize`
241 ORIGFREE=`cat $LPROC/lov/$LOVNAME/kbytesavail`
242 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
243 MDS=$(\ls $LPROC/mdt 2> /dev/null | grep -v num_refs | tail -n 1)
245 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
246 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
247 rm -rf $DIR/[Rdfs][1-9]*
251 echo "preparing for tests involving mounts"
252 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
254 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
255 echo # add a newline after mke2fs.
261 $CHECKSTAT -t file $DIR/$tfile || error
263 $CHECKSTAT -a $DIR/$tfile || error
265 run_test 0 "touch .../$tfile ; rm .../$tfile ====================="
268 chmod 0755 $DIR || error
269 $CHECKSTAT -p 0755 $DIR || error
271 run_test 0b "chmod 0755 $DIR ============================="
276 $CHECKSTAT -t dir $DIR/d1/d2 || error
278 run_test 1a "mkdir .../d1; mkdir .../d1/d2 ====================="
283 $CHECKSTAT -a $DIR/d1 || error
285 run_test 1b "rmdir .../d1/d2; rmdir .../d1 ====================="
290 $CHECKSTAT -t file $DIR/d2/f || error
292 run_test 2a "mkdir .../d2; touch .../d2/f ======================"
296 $CHECKSTAT -a $DIR/d2 || error
298 run_test 2b "rm -r .../d2; checkstat .../d2/f ======================"
302 $CHECKSTAT -t dir $DIR/d3 || error
304 run_test 3a "mkdir .../d3 ======================================"
307 if [ ! -d $DIR/d3 ]; then
311 $CHECKSTAT -t file $DIR/d3/f || error
313 run_test 3b "touch .../d3/f ===================================="
317 $CHECKSTAT -a $DIR/d3 || error
319 run_test 3c "rm -r .../d3 ======================================"
323 $CHECKSTAT -t dir $DIR/d4 || error
325 run_test 4a "mkdir .../d4 ======================================"
328 if [ ! -d $DIR/d4 ]; then
332 $CHECKSTAT -t dir $DIR/d4/d2 || error
334 run_test 4b "mkdir .../d4/d2 ==================================="
339 chmod 0707 $DIR/d5/d2
340 $CHECKSTAT -t dir -p 0707 $DIR/d5/d2 || error
342 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2 ============"
346 chmod 0666 $DIR/f6a || error
347 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/f6a || error
349 run_test 6a "touch .../f6a; chmod .../f6a ======================"
352 [ $RUNAS_ID -eq $UID ] && echo "skipping $TESTNAME" && return
353 if [ ! -f $DIR/f6a ]; then
357 $RUNAS chmod 0444 $DIR/f6a && error
358 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/f6a || error
360 run_test 6b "$RUNAS chmod .../f6a (should return error) =="
363 [ $RUNAS_ID -eq $UID ] && echo "skipping $TESTNAME" && return
365 chown $RUNAS_ID $DIR/f6c || error
366 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/f6c || error
368 run_test 6c "touch .../f6c; chown .../f6c ======================"
371 [ $RUNAS_ID -eq $UID ] && echo "skipping $TESTNAME" && return
372 if [ ! -f $DIR/f6c ]; then
374 chown $RUNAS_ID $DIR/f6c
376 $RUNAS chown $UID $DIR/f6c && error
377 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/f6c || error
379 run_test 6d "$RUNAS chown .../f6c (should return error) =="
382 [ $RUNAS_ID -eq $UID ] && echo "skipping $TESTNAME" && return
384 chgrp $RUNAS_ID $DIR/f6e || error
385 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/f6e || error
387 run_test 6e "touch .../f6e; chgrp .../f6e ======================"
390 [ $RUNAS_ID -eq $UID ] && echo "skipping $TESTNAME" && return
391 if [ ! -f $DIR/f6e ]; then
393 chgrp $RUNAS_ID $DIR/f6e
395 $RUNAS chgrp $UID $DIR/f6e && error
396 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/f6e || error
398 run_test 6f "$RUNAS chgrp .../f6e (should return error) =="
401 [ $RUNAS_ID -eq $UID ] && echo "skipping $TESTNAME" && return
402 mkdir $DIR/d6g || error
403 chmod 777 $DIR/d6g || error
404 $RUNAS mkdir $DIR/d6g/d || error
405 chmod g+s $DIR/d6g/d || error
406 mkdir $DIR/d6g/d/subdir
407 $CHECKSTAT -g \#$RUNAS_ID $DIR/d6g/d/subdir || error
409 run_test 6g "Is new dir in sgid dir inheriting group?"
411 test_6h() { # bug 7331
412 [ $RUNAS_ID -eq $UID ] && echo "skipping $TESTNAME" && return
413 touch $DIR/f6h || error "touch failed"
414 chown $RUNAS_ID:$RUNAS_ID $DIR/f6h || error "initial chown failed"
415 $RUNAS -G$RUNAS_ID chown $RUNAS_ID:0 $DIR/f6h && error "chown worked"
416 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_ID $DIR/f6h || error
418 run_test 6h "$RUNAS chown RUNAS_ID.0 .../f6h (should return error)"
424 $CHECKSTAT -t file -p 0666 $DIR/d7/f || error
426 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
429 if [ ! -d $DIR/d7 ]; then
433 echo -n foo > $DIR/d7/f2
434 [ "`cat $DIR/d7/f2`" = "foo" ] || error
435 $CHECKSTAT -t file -s 3 $DIR/d7/f2 || error
437 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
443 $CHECKSTAT -t file -p 0666 $DIR/d8/f || error
445 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
451 $CHECKSTAT -t dir $DIR/d9/d2/d3 || error
453 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
459 $CHECKSTAT -t file $DIR/d10/d2/f || error
461 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
466 chmod 0666 $DIR/d11/d2
467 chmod 0705 $DIR/d11/d2
468 $CHECKSTAT -t dir -p 0705 $DIR/d11/d2 || error
470 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
475 chmod 0666 $DIR/d12/f
476 chmod 0654 $DIR/d12/f
477 $CHECKSTAT -t file -p 0654 $DIR/d12/f || error
479 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
483 dd if=/dev/zero of=$DIR/d13/f count=10
485 $CHECKSTAT -t file -s 0 $DIR/d13/f || error
487 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
493 $CHECKSTAT -a $DIR/d14/f || error
495 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
500 mv $DIR/d15/f $DIR/d15/f2
501 $CHECKSTAT -t file $DIR/d15/f2 || error
503 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
509 $CHECKSTAT -a $DIR/d16/f || error
511 run_test 16 "touch .../d16/f; rm -rf .../d16/f ================="
516 ln -s $DIR/d17/f $DIR/d17/l-exist
518 $CHECKSTAT -l $DIR/d17/f $DIR/d17/l-exist || error
519 $CHECKSTAT -f -t f $DIR/d17/l-exist || error
521 $CHECKSTAT -a $DIR/l-exist || error
523 run_test 17a "symlinks: create, remove (real) =================="
527 ln -s no-such-file $DIR/d17/l-dangle
529 $CHECKSTAT -l no-such-file $DIR/d17/l-dangle || error
530 $CHECKSTAT -fa $DIR/d17/l-dangle || error
532 $CHECKSTAT -a $DIR/l-dangle || error
534 run_test 17b "symlinks: create, remove (dangling) =============="
536 test_17c() { # bug 3440 - don't save failed open RPC for replay
538 ln -s foo $DIR/d17/f17c
539 cat $DIR/d17/f17c && error "opened non-existent symlink" || true
541 run_test 17c "symlinks: open dangling (should return error) ===="
545 ln -s foo $DIR/d17/f17d
546 touch $DIR/d17/f17d || error "creating to new symlink"
548 run_test 17d "symlinks: create dangling ========================"
554 run_test 18 "touch .../f ; ls ... =============================="
560 $CHECKSTAT -a $DIR/f19 || error
562 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
565 ls -l $DIR/f19 && error || true
567 run_test 19b "ls -l .../f19 (should return error) =============="
570 [ $RUNAS_ID -eq $UID ] && echo "skipping $TESTNAME" && return
571 $RUNAS touch $DIR/f19 && error || true
573 run_test 19c "$RUNAS touch .../f19 (should return error) =="
576 cat $DIR/f19 && error || true
578 run_test 19d "cat .../f19 (should return error) =============="
590 $CHECKSTAT -a $DIR/f || error
592 run_test 20 "touch .../f ; ls -l ... ==========================="
596 [ -f $DIR/d21/dangle ] && rm -f $DIR/d21/dangle
597 ln -s dangle $DIR/d21/link
598 echo foo >> $DIR/d21/link
600 $CHECKSTAT -t link $DIR/d21/link || error
601 $CHECKSTAT -f -t file $DIR/d21/link || error
603 run_test 21 "write to dangling link ============================"
607 chown $RUNAS_ID $DIR/d22
608 # Tar gets pissy if it can't access $PWD *sigh*
610 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
611 $RUNAS tar xfC - $DIR/d22)
613 $CHECKSTAT -t dir $DIR/d22/etc || error
614 $CHECKSTAT -u \#$RUNAS_ID $DIR/d22/etc || error
616 run_test 22 "unpack tar archive as non-root user ==============="
621 $TOEXCL -e $DIR/d23/f23 || error
623 run_test 23 "O_CREAT|O_EXCL in subdir =========================="
626 echo '== rename sanity =============================================='
627 echo '-- same directory rename'
630 mv $DIR/R1/f $DIR/R1/g
631 $CHECKSTAT -t file $DIR/R1/g || error
633 run_test 24a "touch .../R1/f; rename .../R1/f .../R1/g ========="
638 mv $DIR/R2/f $DIR/R2/g
639 $CHECKSTAT -a $DIR/R2/f || error
640 $CHECKSTAT -t file $DIR/R2/g || error
642 run_test 24b "touch .../R2/{f,g}; rename .../R2/f .../R2/g ====="
647 mv $DIR/R3/f $DIR/R3/g
648 $CHECKSTAT -a $DIR/R3/f || error
649 $CHECKSTAT -t dir $DIR/R3/g || error
651 run_test 24c "mkdir .../R3/f; rename .../R3/f .../R3/g ========="
656 mrename $DIR/R4/f $DIR/R4/g
657 $CHECKSTAT -a $DIR/R4/f || error
658 $CHECKSTAT -t dir $DIR/R4/g || error
660 run_test 24d "mkdir .../R4/{f,g}; rename .../R4/f .../R4/g ====="
663 echo '-- cross directory renames --'
666 mv $DIR/R5a/f $DIR/R5b/g
667 $CHECKSTAT -a $DIR/R5a/f || error
668 $CHECKSTAT -t file $DIR/R5b/g || error
670 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
674 touch $DIR/R6a/f $DIR/R6b/g
675 mv $DIR/R6a/f $DIR/R6b/g
676 $CHECKSTAT -a $DIR/R6a/f || error
677 $CHECKSTAT -t file $DIR/R6b/g || error
679 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
684 mv $DIR/R7a/d $DIR/R7b/e
685 $CHECKSTAT -a $DIR/R7a/d || error
686 $CHECKSTAT -t dir $DIR/R7b/e || error
688 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R5b/e ======"
692 mkdir $DIR/R8a/d $DIR/R8b/e
693 mrename $DIR/R8a/d $DIR/R8b/e
694 $CHECKSTAT -a $DIR/R8a/d || error
695 $CHECKSTAT -t dir $DIR/R8b/e || error
697 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
700 echo "-- rename error cases"
704 mrename $DIR/R9/f $DIR/R9/a
705 $CHECKSTAT -t file $DIR/R9/f || error
706 $CHECKSTAT -t dir $DIR/R9/a || error
707 $CHECKSTAT -a file $DIR/R9/a/f || error
709 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
713 mrename $DIR/R10/f $DIR/R10/g
714 $CHECKSTAT -t dir $DIR/R10 || error
715 $CHECKSTAT -a $DIR/R10/f || error
716 $CHECKSTAT -a $DIR/R10/g || error
718 run_test 24j "source does not exist ============================"
721 mkdir $DIR/R11a $DIR/R11a/d
723 mv $DIR/R11a/f $DIR/R11a/d
724 $CHECKSTAT -a $DIR/R11a/f || error
725 $CHECKSTAT -t file $DIR/R11a/d/f || error
727 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
729 # bug 2429 - rename foo foo foo creates invalid file
732 multiop $f OcNs || error
734 run_test 24l "Renaming a file to itself ========================"
738 multiop $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
739 # on ext3 this does not remove either the source or target files
740 # though the "expected" operation would be to remove the source
741 $CHECKSTAT -t file ${f} || error "${f} missing"
742 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
744 run_test 24m "Renaming a file to a hard link to itself ========="
748 # this stats the old file after it was renamed, so it should fail
752 $CHECKSTAT ${f}.rename
755 run_test 24n "Statting the old file after renaming (Posix rename 2)"
758 check_kernel_version 37 || return 0
760 rename_many -s random -v -n 10 $DIR/d24o
762 run_test 24o "rename of files during htree split ==============="
766 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
767 mrename $DIR/R12a $DIR/R12b
768 $CHECKSTAT -a $DIR/R12a || error
769 $CHECKSTAT -t dir $DIR/R12b || error
770 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
771 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
773 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
777 DIRINO=`ls -lid $DIR/R13a | awk '{ print $1 }'`
778 multiop $DIR/R13b D_c &
782 mrename $DIR/R13a $DIR/R13b
783 $CHECKSTAT -a $DIR/R13a || error
784 $CHECKSTAT -t dir $DIR/R13b || error
785 DIRINO2=`ls -lid $DIR/R13b | awk '{ print $1 }'`
786 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
788 wait $MULTIPID || error "multiop close failed"
790 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
792 test_24r() { #bug 3789
793 mkdir $DIR/R14a $DIR/R14a/b
794 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
795 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
796 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
798 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
801 mkdir $DIR/R15a $DIR/R15a/b $DIR/R15a/b/c
802 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
803 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
804 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
806 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
808 mkdir $DIR/R16a $DIR/R16a/b $DIR/R16a/b/c
809 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
810 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
811 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
813 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
816 echo '== symlink sanity ============================================='
820 touch $DIR/s25/foo || error
822 run_test 25a "create file in symlinked directory ==============="
825 [ ! -d $DIR/d25 ] && test_25a
826 $CHECKSTAT -t file $DIR/s25/foo || error
828 run_test 25b "lookup file in symlinked directory ==============="
833 ln -s d26/d26-2 $DIR/s26
834 touch $DIR/s26/foo || error
836 run_test 26a "multiple component symlink ======================="
839 mkdir -p $DIR/d26b/d26-2
840 ln -s d26b/d26-2/foo $DIR/s26-2
841 touch $DIR/s26-2 || error
843 run_test 26b "multiple component symlink at end of lookup ======"
848 ln -s d26.2 $DIR/s26.2-1
849 ln -s s26.2-1 $DIR/s26.2-2
850 ln -s s26.2-2 $DIR/s26.2-3
851 chmod 0666 $DIR/s26.2-3/foo
853 run_test 26c "chain of symlinks ================================"
855 # recursive symlinks (bug 439)
857 ln -s d26-3/foo $DIR/d26-3
859 run_test 26d "create multiple component recursive symlink ======"
862 [ ! -h $DIR/d26-3 ] && test_26d
865 run_test 26e "unlink multiple component recursive symlink ======"
867 # recursive symlinks (bug 7022)
869 mkdir $DIR/$tfile || error "mkdir $DIR/$tfile failed"
870 cd $DIR/$tfile || error "cd $DIR/$tfile failed"
871 mkdir -p $tdir/bar1 || error "mkdir $tdir/bar1 failed"
872 mkdir $tfile || error "mkdir $tfile failed"
873 cd $tfile || error "cd $tfile failed"
874 ln -s .. dotdot || error "ln dotdot failed"
875 ln -s dotdot/$tdir $tdir || error "ln $tdir failed"
876 cd ../.. || error "cd ../.. failed"
877 output=`ls $tfile/$tfile/$tdir/bar1`
878 [ "$output" = bar1 ] && error "unexpected output"
879 rm -r $tfile || error "rm $tfile failed"
880 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
882 run_test 26f "rm -r of a directory which has recursive symlink ="
885 echo '== stripe sanity =============================================='
887 $SETSTRIPE $DIR/d27/f0 65536 0 1 || error "lstripe failed"
888 $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
890 log "== test_27a: write to one stripe file ========================="
891 cp /etc/hosts $DIR/d27/f0 || error
893 run_test 27a "one stripe file =================================="
896 [ "$OSTCOUNT" -lt "2" ] && echo "skipping 2-stripe test" && return
898 $SETSTRIPE $DIR/d27/f01 65536 0 2 || error "lstripe failed"
899 [ `$GETSTRIPE $DIR/d27/f01 | grep -A 10 obdidx | wc -l` -eq 4 ] ||
900 error "two-stripe file doesn't have two stripes"
902 log "== test_27d: write to two stripe file file f01 ================"
903 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
905 run_test 27c "create two stripe file f01 ======================="
909 $SETSTRIPE $DIR/d27/fdef 0 -1 0 || error "lstripe failed"
910 $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
911 dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
913 run_test 27d "create file with default settings ================"
917 $SETSTRIPE $DIR/d27/f12 65536 0 2 || error "lstripe failed"
918 $SETSTRIPE $DIR/d27/f12 65536 0 2 && error "lstripe succeeded twice"
919 $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
921 run_test 27e "lstripe existing file (should return error) ======"
925 $SETSTRIPE $DIR/d27/fbad 100 0 1 && error "lstripe failed"
926 dd if=/dev/zero of=$DIR/d27/f12 bs=4k count=4 || error "dd failed"
927 $GETSTRIPE $DIR/d27/fbad || error "lfs getstripe failed"
929 run_test 27f "lstripe with bad stripe size (should return error)"
933 $MCREATE $DIR/d27/fnone || error "mcreate failed"
935 log "== test 27h: lfs getstripe with no objects ===================="
936 $GETSTRIPE $DIR/d27/fnone 2>&1 | grep "no stripe info" || error "has object"
938 log "== test 27i: lfs getstripe with some objects =================="
939 touch $DIR/d27/fsome || error "touch failed"
940 $GETSTRIPE $DIR/d27/fsome | grep obdidx || error "missing objects"
942 run_test 27g "test lfs getstripe ==========================================="
946 $SETSTRIPE $DIR/d27/f27j 65536 $OSTCOUNT 1 && error "lstripe failed"||true
948 run_test 27j "lstripe with bad stripe offset (should return error)"
950 test_27k() { # bug 2844
953 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
954 [ ! -d $DIR/d27 ] && mkdir -p $DIR/d27
955 $SETSTRIPE $FILE 67108864 -1 0 || error "lstripe failed"
956 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
957 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
958 dd if=/dev/zero of=$FILE bs=4k count=1
959 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
960 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
962 run_test 27k "limit i_blksize for broken user apps ============="
966 mcreate $DIR/f27l || error "creating file"
967 $RUNAS $SETSTRIPE $DIR/f27l 65536 -1 1 && \
968 error "lstripe should have failed" || true
970 run_test 27l "check setstripe permissions (should return error)"
973 [ "$OSTCOUNT" -lt "2" ] && echo "skipping out-of-space test on OST0" && return
974 if [ $ORIGFREE -gt $MAXFREE ]; then
975 echo "skipping out-of-space test on OST0"
979 $SETSTRIPE $DIR/d27/f27m_1 0 0 1
980 dd if=/dev/zero of=$DIR/d27/f27m_1 bs=1024 count=$MAXFREE && \
981 error "dd should fill OST0"
983 while $SETSTRIPE $DIR/d27/f27m_$i 0 0 1 ; do
985 [ $i -gt 256 ] && break
988 touch $DIR/d27/f27m_$i
989 [ `$GETSTRIPE $DIR/d27/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] && \
990 error "OST0 was full but new created file still use it"
992 touch $DIR/d27/f27m_$i
993 [ `$GETSTRIPE $DIR/d27/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] && \
994 error "OST0 was full but new created file still use it"
997 run_test 27m "create file while OST0 was full =================="
999 # osc's keep a NOSPC stick flag that gets unset with rmdir
1001 [ "$1" ] && FAIL_LOC=$1 || FAIL_LOC=0
1002 mkdir -p $DIR/d27/nospc
1003 rmdir $DIR/d27/nospc
1004 sysctl -w lustre.fail_loc=$FAIL_LOC
1007 exhaust_precreations() {
1009 OST=$(grep ${OSTIDX}": " $LPROC/lov/${LOVNAME}/target_obd | \
1010 awk '{print $2}' | sed -e 's/_UUID$//')
1012 OSC=$(ls $LPROC/osc | grep "mdtlov-osc000${OSTIDX}")
1013 last_id=$(cat $LPROC/osc/${OSC}/prealloc_last_id)
1014 next_id=$(cat $LPROC/osc/${OSC}/prealloc_next_id)
1016 mkdir -p $DIR/d27/${OST}
1017 $SETSTRIPE $DIR/d27/${OST} 0 $OSTIDX 1
1018 #define OBD_FAIL_OST_ENOSPC 0x215
1019 sysctl -w lustre.fail_loc=0x215
1020 echo "Creating to objid $last_id on ost $OST..."
1021 createmany -o $DIR/d27/${OST}/f $next_id $((last_id - next_id + 2))
1022 grep '[0-9]' $LPROC/osc/${OSC}/prealloc*
1026 exhaust_all_precreations() {
1028 for (( i=0; i < OSTCOUNT; i++ )) ; do
1029 exhaust_precreations $i 0x215
1035 [ "$OSTCOUNT" -lt "2" -o -z "$MDS" ] && echo "skipping $TESTNAME" && return
1039 exhaust_precreations 0 0x80000215
1041 touch $DIR/d27/f27n || error
1045 run_test 27n "create file with some full OSTs =================="
1048 [ "$OSTCOUNT" -lt "2" -o -z "$MDS" ] && echo "skipping $TESTNAME" && return
1052 exhaust_all_precreations 0x215
1055 touch $DIR/d27/f27o && error "able to create $DIR/d27/f27o"
1059 run_test 27o "create file with all full OSTs (should error) ===="
1062 [ "$OSTCOUNT" -lt "2" -o -z "$MDS" ] && echo "skipping $TESTNAME" && return
1067 $MCREATE $DIR/d27/f27p || error
1068 $TRUNCATE $DIR/d27/f27p 80000000 || error
1069 $CHECKSTAT -s 80000000 $DIR/d27/f27p || error
1071 exhaust_precreations 0 0x80000215
1072 echo foo >> $DIR/d27/f27p || error
1073 $CHECKSTAT -s 80000004 $DIR/d27/f27p || error
1077 run_test 27p "append to a truncated file with some full OSTs ==="
1080 [ "$OSTCOUNT" -lt "2" -o -z "$MDS" ] && echo "skipping $TESTNAME" && return
1085 $MCREATE $DIR/d27/f27q || error
1086 $TRUNCATE $DIR/d27/f27q 80000000 || error
1087 $CHECKSTAT -s 80000000 $DIR/d27/f27q || error
1089 exhaust_all_precreations 0x215
1091 echo foo >> $DIR/d27/f27q && error
1092 $CHECKSTAT -s 80000000 $DIR/d27/f27q || error
1096 run_test 27q "append to truncated file with all OSTs full (should error) ==="
1099 [ "$OSTCOUNT" -lt "2" -o -z "$MDS" ] && echo "skipping $TESTNAME" && return
1103 exhaust_precreations 0 0x80000215
1105 $SETSTRIPE $DIR/d27/f27r 0 0 2 # && error
1109 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1113 $LSTRIPE $DIR/$tdir $((2048 * 1024 * 1024)) -1 2 && \
1114 error "stripe width >= 2^32 succeeded" || true
1116 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1118 test_27t() { # bug 10864
1123 $WLFS getstripe $tfile
1126 run_test 27t "check that utils parse path correctly"
1131 $CREATETEST $DIR/d28/ct || error
1133 run_test 28 "create/mknod/mkdir with bad file types ============"
1136 cancel_lru_locks mdc
1141 MDCDIR=${MDCDIR:-$LPROC/ldlm/namespaces/*-mdc-*}
1142 LOCKCOUNTORIG=`cat $MDCDIR/lock_count`
1143 LOCKUNUSEDCOUNTORIG=`cat $MDCDIR/lock_unused_count`
1147 LOCKCOUNTCURRENT=`cat $MDCDIR/lock_count`
1148 LOCKUNUSEDCOUNTCURRENT=`cat $MDCDIR/lock_unused_count`
1149 if [ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]; then
1150 echo > $LPROC/ldlm/dump_namespaces
1151 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
1152 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1153 log "dumped log to $TMP/test_29.dk (bug 5793)"
1155 if [ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]; then
1156 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
1157 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1158 log "dumped log to $TMP/test_29.dk (bug 5793)"
1161 run_test 29 "IT_GETATTR regression ============================"
1164 cp `which ls` $DIR || cp /bin/ls $DIR
1168 run_test 30 "run binary from Lustre (execve) ==================="
1171 $OPENUNLINK $DIR/f31 $DIR/f31 || error
1172 $CHECKSTAT -a $DIR/f31 || error
1174 run_test 31a "open-unlink file =================================="
1177 touch $DIR/f31 || error
1178 ln $DIR/f31 $DIR/f31b || error
1179 multiop $DIR/f31b Ouc || error
1180 $CHECKSTAT -t file $DIR/f31 || error
1182 run_test 31b "unlink file with multiple links while open ======="
1185 touch $DIR/f31 || error
1186 ln $DIR/f31 $DIR/f31c || error
1187 multiop $DIR/f31 O_uc &
1189 multiop $DIR/f31c Ouc
1191 kill -USR1 $MULTIPID
1194 run_test 31c "open-unlink file with multiple links ============="
1197 opendirunlink $DIR/d31d $DIR/d31d || error
1198 $CHECKSTAT -a $DIR/d31d || error
1200 run_test 31d "remove of open directory ========================="
1202 test_31e() { # bug 2904
1203 check_kernel_version 34 || return 0
1204 openfilleddirunlink $DIR/d31e || error
1206 run_test 31e "remove of open non-empty directory ==============="
1208 test_31f() { # bug 4554
1211 lfs setstripe $DIR/d31f 1048576 -1 1
1212 cp /etc/hosts $DIR/d31f
1214 lfs getstripe $DIR/d31f/hosts
1215 multiop $DIR/d31f D_c &
1220 rm -rv $DIR/d31f || error "first of $DIR/d31f"
1222 lfs setstripe $DIR/d31f 1048576 -1 1
1223 cp /etc/hosts $DIR/d31f
1225 lfs getstripe $DIR/d31f/hosts
1226 multiop $DIR/d31f D_c &
1231 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
1232 wait $MULTIPID || error "first opendir $MULTIPID failed"
1236 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
1237 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
1240 run_test 31f "remove of open directory with open-unlink file ==="
1243 echo "== more mountpoints and symlinks ================="
1244 [ -e $DIR/d32a ] && rm -fr $DIR/d32a
1245 mkdir -p $DIR/d32a/ext2-mountpoint
1246 mount -t ext2 -o loop $EXT2_DEV $DIR/d32a/ext2-mountpoint || error
1247 $CHECKSTAT -t dir $DIR/d32a/ext2-mountpoint/.. || error
1248 $UMOUNT $DIR/d32a/ext2-mountpoint || error
1250 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
1253 [ -e $DIR/d32b ] && rm -fr $DIR/d32b
1254 mkdir -p $DIR/d32b/ext2-mountpoint
1255 mount -t ext2 -o loop $EXT2_DEV $DIR/d32b/ext2-mountpoint || error
1256 ls -al $DIR/d32b/ext2-mountpoint/.. || error
1257 $UMOUNT $DIR/d32b/ext2-mountpoint || error
1259 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
1262 [ -e $DIR/d32c ] && rm -fr $DIR/d32c
1263 mkdir -p $DIR/d32c/ext2-mountpoint
1264 mount -t ext2 -o loop $EXT2_DEV $DIR/d32c/ext2-mountpoint || error
1265 mkdir -p $DIR/d32c/d2/test_dir
1266 $CHECKSTAT -t dir $DIR/d32c/ext2-mountpoint/../d2/test_dir || error
1267 $UMOUNT $DIR/d32c/ext2-mountpoint || error
1269 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
1272 [ -e $DIR/d32d ] && rm -fr $DIR/d32d
1273 mkdir -p $DIR/d32d/ext2-mountpoint
1274 mount -t ext2 -o loop $EXT2_DEV $DIR/d32d/ext2-mountpoint || error
1275 mkdir -p $DIR/d32d/d2/test_dir
1276 ls -al $DIR/d32d/ext2-mountpoint/../d2/test_dir || error
1277 $UMOUNT $DIR/d32d/ext2-mountpoint || error
1279 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
1282 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
1283 mkdir -p $DIR/d32e/tmp
1284 TMP_DIR=$DIR/d32e/tmp
1285 ln -s $DIR/d32e $TMP_DIR/symlink11
1286 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1287 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
1288 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
1290 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
1293 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
1294 mkdir -p $DIR/d32f/tmp
1295 TMP_DIR=$DIR/d32f/tmp
1296 ln -s $DIR/d32f $TMP_DIR/symlink11
1297 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1298 ls $DIR/d32f/tmp/symlink11 || error
1299 ls $DIR/d32f/symlink01 || error
1301 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
1304 TMP_DIR=$DIR/$tdir/tmp
1305 mkdir -p $TMP_DIR $DIR/${tdir}2
1306 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
1307 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1308 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
1309 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
1310 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
1311 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
1313 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
1316 rm -fr $DIR/$tdir $DIR/${tdir}2
1317 TMP_DIR=$DIR/$tdir/tmp
1318 mkdir -p $TMP_DIR $DIR/${tdir}2
1319 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
1320 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1321 ls $TMP_DIR/symlink12 || error
1322 ls $DIR/$tdir/symlink02 || error
1324 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
1327 [ -e $DIR/d32i ] && rm -fr $DIR/d32i
1328 mkdir -p $DIR/d32i/ext2-mountpoint
1329 mount -t ext2 -o loop $EXT2_DEV $DIR/d32i/ext2-mountpoint || error
1330 touch $DIR/d32i/test_file
1331 $CHECKSTAT -t file $DIR/d32i/ext2-mountpoint/../test_file || error
1332 $UMOUNT $DIR/d32i/ext2-mountpoint || error
1334 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
1337 [ -e $DIR/d32j ] && rm -fr $DIR/d32j
1338 mkdir -p $DIR/d32j/ext2-mountpoint
1339 mount -t ext2 -o loop $EXT2_DEV $DIR/d32j/ext2-mountpoint || error
1340 touch $DIR/d32j/test_file
1341 cat $DIR/d32j/ext2-mountpoint/../test_file || error
1342 $UMOUNT $DIR/d32j/ext2-mountpoint || error
1344 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
1348 mkdir -p $DIR/d32k/ext2-mountpoint
1349 mount -t ext2 -o loop $EXT2_DEV $DIR/d32k/ext2-mountpoint
1350 mkdir -p $DIR/d32k/d2
1351 touch $DIR/d32k/d2/test_file || error
1352 $CHECKSTAT -t file $DIR/d32k/ext2-mountpoint/../d2/test_file || error
1353 $UMOUNT $DIR/d32k/ext2-mountpoint || error
1355 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
1359 mkdir -p $DIR/d32l/ext2-mountpoint
1360 mount -t ext2 -o loop $EXT2_DEV $DIR/d32l/ext2-mountpoint || error
1361 mkdir -p $DIR/d32l/d2
1362 touch $DIR/d32l/d2/test_file
1363 cat $DIR/d32l/ext2-mountpoint/../d2/test_file || error
1364 $UMOUNT $DIR/d32l/ext2-mountpoint || error
1366 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
1370 mkdir -p $DIR/d32m/tmp
1371 TMP_DIR=$DIR/d32m/tmp
1372 ln -s $DIR $TMP_DIR/symlink11
1373 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1374 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
1375 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
1377 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
1381 mkdir -p $DIR/d32n/tmp
1382 TMP_DIR=$DIR/d32n/tmp
1383 ln -s $DIR $TMP_DIR/symlink11
1384 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1385 ls -l $DIR/d32n/tmp/symlink11 || error
1386 ls -l $DIR/d32n/symlink01 || error
1388 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
1391 rm -fr $DIR/d32o $DIR/$tfile
1393 mkdir -p $DIR/d32o/tmp
1394 TMP_DIR=$DIR/d32o/tmp
1395 ln -s $DIR/$tfile $TMP_DIR/symlink12
1396 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1397 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
1398 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
1399 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
1400 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
1402 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
1412 mkdir -p $DIR/d32p/tmp
1414 TMP_DIR=$DIR/d32p/tmp
1416 ln -s $DIR/$tfile $TMP_DIR/symlink12
1418 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1420 cat $DIR/d32p/tmp/symlink12 || error
1422 cat $DIR/d32p/symlink02 || error
1425 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
1428 [ -e $DIR/d32q ] && rm -fr $DIR/d32q
1430 touch $DIR/d32q/under_the_mount
1431 mount -t ext2 -o loop $EXT2_DEV $DIR/d32q
1432 ls $DIR/d32q/under_the_mount && error || true
1433 $UMOUNT $DIR/d32q || error
1435 run_test 32q "stat follows mountpoints in Lustre (should return error)"
1438 [ -e $DIR/d32r ] && rm -fr $DIR/d32r
1440 touch $DIR/d32r/under_the_mount
1441 mount -t ext2 -o loop $EXT2_DEV $DIR/d32r
1442 ls $DIR/d32r | grep -q under_the_mount && error || true
1443 $UMOUNT $DIR/d32r || error
1445 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
1450 chmod 444 $DIR/$tfile
1451 chown $RUNAS_ID $DIR/$tfile
1453 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
1456 run_test 33 "write file with mode 444 (should return error) ===="
1461 chown $RUNAS_ID $DIR/d33
1462 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
1463 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
1464 error "open RDWR" || true
1466 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
1468 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
1471 $MCREATE $DIR/f34 || error
1472 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
1473 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
1474 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
1475 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1477 run_test 34a "truncate file that has not been opened ==========="
1480 [ ! -f $DIR/f34 ] && test_34a
1481 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1482 $OPENFILE -f O_RDONLY $DIR/f34
1483 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
1484 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1486 run_test 34b "O_RDONLY opening file doesn't create objects ====="
1489 [ ! -f $DIR/f34 ] && test_34a
1490 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1491 $OPENFILE -f O_RDWR $DIR/f34
1492 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
1493 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1495 run_test 34c "O_RDWR opening file-with-size works =============="
1498 [ ! -f $DIR/f34 ] && test_34a
1499 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
1500 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1503 run_test 34d "write to sparse file ============================="
1507 $MCREATE $DIR/f34e || error
1508 $TRUNCATE $DIR/f34e 1000 || error
1509 $CHECKSTAT -s 1000 $DIR/f34e || error
1510 $OPENFILE -f O_RDWR $DIR/f34e
1511 $CHECKSTAT -s 1000 $DIR/f34e || error
1513 run_test 34e "create objects, some with size and some without =="
1515 test_34f() { # bug 6242, 6243
1518 $MCREATE $DIR/f34f || error
1519 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
1520 dd if=$DIR/f34f of=$TMP/f34f
1521 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
1522 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
1523 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
1524 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
1525 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
1527 run_test 34f "read from a file with no objects until EOF ======="
1530 cp /bin/sh $DIR/f35a
1532 chown $RUNAS_ID $DIR/f35a
1533 $RUNAS $DIR/f35a && error || true
1536 run_test 35a "exec file with mode 444 (should return and not leak) ====="
1540 utime $DIR/f36 || error
1542 run_test 36a "MDS utime check (mknod, utime) ==================="
1546 utime $DIR/f36 || error
1548 run_test 36b "OST utime check (open, utime) ===================="
1553 chown $RUNAS_ID $DIR/d36
1554 $RUNAS utime $DIR/d36/f36 || error
1556 run_test 36c "non-root MDS utime check (mknod, utime) =========="
1559 [ ! -d $DIR/d36 ] && test_36c
1560 echo "" > $DIR/d36/f36
1561 $RUNAS utime $DIR/d36/f36 || error
1563 run_test 36d "non-root OST utime check (open, utime) ==========="
1566 [ $RUNAS_ID -eq $UID ] && echo "skipping $TESTNAME" && return
1568 touch $DIR/$tdir/$tfile
1569 $RUNAS utime $DIR/$tdir/$tfile && \
1570 error "utime worked, expected failure" || true
1572 run_test 36e "utime on non-owned file (should return error) ===="
1575 export LANG=C LC_LANG=C # for date language
1577 DATESTR="Dec 20 2000"
1579 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
1580 sysctl -w lustre.fail_loc=0x80000214
1582 cp /etc/hosts $DIR/$tdir/$tfile
1583 sync & # write RPC generated with "current" inode timestamp, but delayed
1585 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
1586 LS_BEFORE="`ls -l $DIR/d36/$tfile`" # "old" timestamp from client cache
1587 cancel_lru_locks osc
1588 LS_AFTER="`ls -l $DIR/d36/$tfile`" # timestamp from OST object
1590 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
1591 echo "BEFORE: $LS_BEFORE" && \
1592 echo "AFTER : $LS_AFTER" && \
1593 echo "WANT : $DATESTR" && \
1594 error "$DIR/d36/$tfile timestamps changed" || true
1596 run_test 36f "utime on file racing with OST BRW write =========="
1598 if [ -d $LPROC/obdfilter ]; then
1599 export FMD_MAX_AGE=`cat $LPROC/obdfilter/*/client_cache_seconds | head -n 1`
1602 FMD_BEFORE="`awk '/ll_fmd_cache/ { print $2 }' /proc/slabinfo`"
1603 touch $DIR/d36/$tfile
1604 sleep $((FMD_MAX_AGE + 12))
1605 FMD_AFTER="`awk '/ll_fmd_cache/ { print $2 }' /proc/slabinfo`"
1606 [ "$FMD_AFTER" -gt "$FMD_BEFORE" ] && \
1607 echo "AFTER : $FMD_AFTER > BEFORE $FMD_BEFORE" && \
1608 error "fmd didn't expire after ping" || true
1610 run_test 36g "filter mod data cache expiry ====================="
1612 log "skipping test_36g because of non-local OST"
1613 fi # [ -d $LPROC/obdfilter ]
1616 mkdir -p $DIR/dextra
1617 echo f > $DIR/dextra/fbugfile
1618 mount -t ext2 -o loop $EXT2_DEV $DIR/dextra
1619 ls $DIR/dextra | grep "\<fbugfile\>" && error
1620 $UMOUNT $DIR/dextra || error
1621 rm -f $DIR/dextra/fbugfile || error
1623 run_test 37 "ls a mounted file system to check old content ====="
1626 o_directory $DIR/$tfile
1628 run_test 38 "open a regular file with O_DIRECTORY =============="
1632 touch $DIR/${tfile}2
1633 # ls -l $DIR/$tfile $DIR/${tfile}2
1634 # ls -lu $DIR/$tfile $DIR/${tfile}2
1635 # ls -lc $DIR/$tfile $DIR/${tfile}2
1637 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
1638 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
1640 ls -l $DIR/$tfile $DIR/${tfile}2
1642 ls -lu $DIR/$tfile $DIR/${tfile}2
1644 ls -lc $DIR/$tfile $DIR/${tfile}2
1645 error "O_TRUNC didn't change timestamps"
1648 run_test 39 "mtime changed on create ==========================="
1651 dd if=/dev/zero of=$DIR/f40 bs=4096 count=1
1652 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/f40 && error
1653 $CHECKSTAT -t file -s 4096 $DIR/f40 || error
1655 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
1659 small_write $DIR/f41 18
1661 run_test 41 "test small file write + fstat ====================="
1663 count_ost_writes() {
1664 cat $LPROC/osc/*/stats |
1665 awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }'
1673 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs
1674 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
1675 echo $WRITEBACK_SAVE > /proc/sys/vm/dirty_writeback_centisecs
1677 # if file not here, we are a 2.4 kernel
1678 kill -CONT `pidof kupdated`
1682 # setup the trap first, so someone cannot exit the test at the
1683 # exact wrong time and mess up a machine
1684 trap start_writeback EXIT
1685 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
1686 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
1687 WRITEBACK_SAVE=`cat /proc/sys/vm/dirty_writeback_centisecs`
1688 echo 0 > /proc/sys/vm/dirty_writeback_centisecs
1690 # if file not here, we are a 2.4 kernel
1691 kill -STOP `pidof kupdated`
1695 # ensure that all stripes have some grant before we test client-side cache
1697 [ "$SETUP_TEST42" ] && return
1698 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
1699 dd if=/dev/zero of=$i bs=4k count=1
1705 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
1706 # file truncation, and file removal.
1709 cancel_lru_locks osc
1711 sync; sleep 1; sync # just to be safe
1712 BEFOREWRITES=`count_ost_writes`
1713 grep "[0-9]" $LPROC/osc/*-osc-*/cur_grant_bytes
1714 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
1715 AFTERWRITES=`count_ost_writes`
1716 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
1717 error "$BEFOREWRITES < $AFTERWRITES"
1720 run_test 42a "ensure that we don't flush on close =============="
1724 cancel_lru_locks osc
1727 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
1728 BEFOREWRITES=`count_ost_writes`
1729 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
1730 AFTERWRITES=`count_ost_writes`
1731 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
1732 error "$BEFOREWRITES < $AFTERWRITES on unlink"
1734 BEFOREWRITES=`count_ost_writes`
1735 sync || error "sync: $?"
1736 AFTERWRITES=`count_ost_writes`
1737 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
1738 error "$BEFOREWRITES < $AFTERWRITES on sync"
1740 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
1744 run_test 42b "test destroy of file with cached dirty data ======"
1746 # if these tests just want to test the effect of truncation,
1747 # they have to be very careful. consider:
1748 # - the first open gets a {0,EOF}PR lock
1749 # - the first write conflicts and gets a {0, count-1}PW
1750 # - the rest of the writes are under {count,EOF}PW
1751 # - the open for truncate tries to match a {0,EOF}PR
1752 # for the filesize and cancels the PWs.
1753 # any number of fixes (don't get {0,EOF} on open, match
1754 # composite locks, do smarter file size management) fix
1755 # this, but for now we want these tests to verify that
1756 # the cancellation with truncate intent works, so we
1757 # start the file with a full-file pw lock to match against
1758 # until the truncate.
1763 cancel_lru_locks osc
1765 # prime the file with 0,EOF PW to match
1769 # now the real test..
1770 dd if=/dev/zero of=$file bs=1024 count=100
1771 BEFOREWRITES=`count_ost_writes`
1772 $TRUNCATE $file $offset
1773 cancel_lru_locks osc
1774 AFTERWRITES=`count_ost_writes`
1780 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
1781 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
1784 run_test 42c "test partial truncate of file with cached dirty data"
1788 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
1789 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
1792 run_test 42d "test complete truncate of file with cached dirty data"
1796 cp -p /bin/ls $DIR/$tdir/$tfile
1797 exec 100>> $DIR/$tdir/$tfile
1798 $DIR/$tdir/$tfile && error || true
1801 run_test 43 "execution of file opened for write should return -ETXTBSY"
1805 cp -p `which multiop` $DIR/d43/multiop || cp -p multiop $DIR/d43/multiop
1806 $DIR/d43/multiop $TMP/test43.junk O_c &
1809 multiop $DIR/d43/multiop Oc && error "expected error, got success"
1810 kill -USR1 $MULTIPID || return 2
1811 wait $MULTIPID || return 3
1814 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
1818 cp -p `which multiop` $DIR/d43/multiop || cp -p multiop $DIR/d43/multiop
1819 $DIR/d43/multiop $TMP/test43.junk O_c &
1822 truncate $DIR/d43/multiop 0 && error "expected error, got success"
1823 kill -USR1 $MULTIPID || return 2
1824 wait $MULTIPID || return 3
1827 run_test 43b "truncate of file being executed should return -ETXTBSY"
1830 local testdir="$DIR/d43c"
1833 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
1834 ( cd $testdir && md5sum -c)
1836 run_test 43c "md5sum of copy into lustre========================"
1839 [ "$OSTCOUNT" -lt "2" ] && echo "skipping 2-stripe test" && return
1840 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
1841 dd if=$DIR/f1 bs=4k count=1
1843 run_test 44 "zero length read from a sparse stripe ============="
1846 local nstripe=`$LCTL lov_getconfig $DIR | grep default_stripe_count: | \
1848 local stride=`$LCTL lov_getconfig $DIR | grep default_stripe_size: | \
1850 if [ $nstripe -eq 0 ] ; then
1851 nstripe=`$LCTL lov_getconfig $DIR | grep obd_count: | awk '{print $2}'`
1854 OFFSETS="0 $((stride/2)) $((stride-1))"
1855 for offset in $OFFSETS ; do
1856 for i in `seq 0 $((nstripe-1))`; do
1857 local GLOBALOFFSETS=""
1858 local size=$((((i + 2 * $nstripe )*$stride + $offset))) # Bytes
1859 local myfn=$DIR/d44a-$size
1860 echo "--------writing $myfn at $size"
1861 ll_sparseness_write $myfn $size || error "ll_sparseness_write"
1862 GLOBALOFFSETS="$GLOBALOFFSETS $size"
1863 ll_sparseness_verify $myfn $GLOBALOFFSETS \
1864 || error "ll_sparseness_verify $GLOBALOFFSETS"
1866 for j in `seq 0 $((nstripe-1))`; do
1867 size=$((((j + $nstripe )*$stride + $offset))) # Bytes
1868 ll_sparseness_write $myfn $size || error "ll_sparseness_write"
1869 GLOBALOFFSETS="$GLOBALOFFSETS $size"
1871 ll_sparseness_verify $myfn $GLOBALOFFSETS \
1872 || error "ll_sparseness_verify $GLOBALOFFSETS"
1877 run_test 44a "test sparse pwrite ==============================="
1881 for d in $LPROC/osc/*/cur_dirty_bytes; do
1882 tot=$(($tot + `cat $d`))
1887 before=`dirty_osc_total`
1888 echo executing "\"$*\""
1890 after=`dirty_osc_total`
1891 echo before $before, after $after
1895 # Obtain grants from OST if it supports it
1896 echo blah > ${f}_grant
1899 do_dirty_record "echo blah > $f"
1900 [ $before -eq $after ] && error "write wasn't cached"
1901 do_dirty_record "> $f"
1902 [ $before -gt $after ] || error "truncate didn't lower dirty count"
1903 do_dirty_record "echo blah > $f"
1904 [ $before -eq $after ] && error "write wasn't cached"
1905 do_dirty_record "sync"
1906 [ $before -gt $after ] || error "writeback didn't lower dirty count"
1907 do_dirty_record "echo blah > $f"
1908 [ $before -eq $after ] && error "write wasn't cached"
1909 do_dirty_record "cancel_lru_locks osc"
1910 [ $before -gt $after ] || error "lock cancellation didn't lower dirty count"
1913 run_test 45 "osc io page accounting ============================"
1919 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
1920 # test tickles a bug where re-dirtying a page was failing to be mapped to the
1921 # objects offset and an assert hit when an rpc was built with 1023's mapped
1922 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
1927 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
1929 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
1930 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
1934 run_test 46 "dirtying a previously written page ================"
1936 # Check that device nodes are created and then visible correctly (#2091)
1938 cmknod $DIR/test_47_node || error
1940 run_test 47 "Device nodes check ================================"
1942 test_48a() { # bug 2399
1943 check_kernel_version 34 || return 0
1946 mv $DIR/d48a $DIR/d48.new || error "move directory failed"
1947 mkdir $DIR/d48a || error "recreate directory failed"
1948 touch foo || error "'touch foo' failed after recreating cwd"
1949 mkdir bar || error "'mkdir foo' failed after recreating cwd"
1950 if check_kernel_version 44; then
1951 touch .foo || error "'touch .foo' failed after recreating cwd"
1952 mkdir .bar || error "'mkdir .foo' failed after recreating cwd"
1954 ls . || error "'ls .' failed after recreating cwd"
1955 ls .. || error "'ls ..' failed after removing cwd"
1956 cd . || error "'cd .' failed after recreating cwd"
1957 mkdir . && error "'mkdir .' worked after recreating cwd"
1958 rmdir . && error "'rmdir .' worked after recreating cwd"
1959 ln -s . baz || error "'ln -s .' failed after recreating cwd"
1960 cd .. || error "'cd ..' failed after recreating cwd"
1962 run_test 48a "Access renamed working dir (should return errors)="
1964 test_48b() { # bug 2399
1965 check_kernel_version 34 || return 0
1968 rmdir $DIR/d48b || error "remove cwd $DIR/d48b failed"
1969 touch foo && error "'touch foo' worked after removing cwd"
1970 mkdir foo && error "'mkdir foo' worked after removing cwd"
1971 if check_kernel_version 44; then
1972 touch .foo && error "'touch .foo' worked after removing cwd"
1973 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
1975 ls . && error "'ls .' worked after removing cwd"
1976 ls .. || error "'ls ..' failed after removing cwd"
1977 cd . && error "'cd .' worked after removing cwd"
1978 mkdir . && error "'mkdir .' worked after removing cwd"
1979 rmdir . && error "'rmdir .' worked after removing cwd"
1980 ln -s . foo && error "'ln -s .' worked after removing cwd"
1981 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
1983 run_test 48b "Access removed working dir (should return errors)="
1985 test_48c() { # bug 2350
1986 check_kernel_version 36 || return 0
1987 #sysctl -w lnet.debug=-1
1989 mkdir -p $DIR/d48c/dir
1991 $TRACE rmdir $DIR/d48c/dir || error "remove cwd $DIR/d48c/dir failed"
1992 $TRACE touch foo && error "'touch foo' worked after removing cwd"
1993 $TRACE mkdir foo && error "'mkdir foo' worked after removing cwd"
1994 if check_kernel_version 44; then
1995 touch .foo && error "'touch .foo' worked after removing cwd"
1996 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
1998 $TRACE ls . && error "'ls .' worked after removing cwd"
1999 $TRACE ls .. || error "'ls ..' failed after removing cwd"
2000 $TRACE cd . && error "'cd .' worked after removing cwd"
2001 $TRACE mkdir . && error "'mkdir .' worked after removing cwd"
2002 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
2003 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
2004 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
2006 run_test 48c "Access removed working subdir (should return errors)"
2008 test_48d() { # bug 2350
2009 check_kernel_version 36 || return 0
2010 #sysctl -w lnet.debug=-1
2012 mkdir -p $DIR/d48d/dir
2014 $TRACE rmdir $DIR/d48d/dir || error "remove cwd $DIR/d48d/dir failed"
2015 $TRACE rmdir $DIR/d48d || error "remove parent $DIR/d48d failed"
2016 $TRACE touch foo && error "'touch foo' worked after removing parent"
2017 $TRACE mkdir foo && error "'mkdir foo' worked after removing parent"
2018 if check_kernel_version 44; then
2019 touch .foo && error "'touch .foo' worked after removing parent"
2020 mkdir .foo && error "'mkdir .foo' worked after removing parent"
2022 $TRACE ls . && error "'ls .' worked after removing parent"
2023 $TRACE ls .. && error "'ls ..' worked after removing parent"
2024 $TRACE cd . && error "'cd .' worked after recreate parent"
2025 $TRACE mkdir . && error "'mkdir .' worked after removing parent"
2026 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
2027 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
2028 $TRACE cd .. && error "'cd ..' worked after removing parent" || true
2030 run_test 48d "Access removed parent subdir (should return errors)"
2032 test_48e() { # bug 4134
2033 check_kernel_version 41 || return 0
2034 #sysctl -w lnet.debug=-1
2036 mkdir -p $DIR/d48e/dir
2038 $TRACE rmdir $DIR/d48e/dir || error "remove cwd $DIR/d48e/dir failed"
2039 $TRACE rmdir $DIR/d48e || error "remove parent $DIR/d48e failed"
2040 $TRACE touch $DIR/d48e || error "'touch $DIR/d48e' failed"
2041 $TRACE chmod +x $DIR/d48e || error "'chmod +x $DIR/d48e' failed"
2042 # On a buggy kernel addition of "touch foo" after cd .. will
2043 # produce kernel oops in lookup_hash_it
2044 cd -P .. && error "'cd ..' worked after recreate parent"
2047 $TRACE rm $DIR/d48e || error "rm '$DIR/d48e' failed"
2049 run_test 48e "Access to recreated parent subdir (should return errors)"
2055 ls /proc/$$/cwd || error
2057 run_test 50 "special situations: /proc symlinks ==============="
2060 # bug 1516 - create an empty entry right after ".." then split dir
2063 $MCREATE $DIR/d51/bar
2065 createmany -m $DIR/d51/longfile 201
2067 while [ `ls -sd $DIR/d51 | awk '{ print $1 }'` -eq 4 ]; do
2068 $MCREATE $DIR/d51/longfile$FNUM
2072 ls -l $DIR/d51 > /dev/null || error
2074 run_test 51 "special situations: split htree with empty entry =="
2076 #export NUMTEST=70000
2077 # I select a relatively small number to do basic test. --huanghua
2078 # large number may give panic(). debugging on this is going on.
2081 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
2082 [ $NUMFREE -lt 21000 ] && \
2083 echo "skipping $TESTNAME, not enough free inodes ($NUMFREE)" && \
2086 check_kernel_version 40 || NUMTEST=31000
2087 [ $NUMFREE -lt $NUMTEST ] && NUMTEST=$(($NUMFREE - 50))
2090 createmany -d $DIR/d51b/t- $NUMTEST
2092 run_test 51b "mkdir .../t-0 --- .../t-$NUMTEST ===================="
2095 [ ! -d $DIR/d51b ] && echo "skipping $TESTNAME: $DIR/51b missing" && \
2098 unlinkmany -d $DIR/d51b/t- $NUMTEST
2100 run_test 51c "rmdir .../t-0 --- .../t-$NUMTEST ===================="
2103 [ "$OSTCOUNT" -lt "3" ] && echo "skipping test with few OSTs" && return
2105 createmany -o $DIR/d51d/t- 1000
2106 $LFS getstripe $DIR/d51d > $TMP/files
2107 for N in `seq 0 $((OSTCOUNT - 1))`; do
2108 OBJS[$N]=`awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}' $TMP/files`
2109 OBJS0[$N]=`grep -A 1 idx $TMP/files | awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}'`
2110 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
2112 unlinkmany $DIR/d51d/t- 1000
2115 for N in `seq 1 $((OSTCOUNT - 1))`; do
2116 [ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ] && \
2117 error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
2118 [ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ] && \
2119 error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
2121 [ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ] && \
2122 error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
2123 [ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ] && \
2124 error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
2128 run_test 51d "check object distribution ===================="
2131 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
2134 chattr =a $DIR/d52a/foo || error "chattr =a failed"
2135 echo bar >> $DIR/d52a/foo || error "append bar failed"
2136 cp /etc/hosts $DIR/d52a/foo && error "cp worked"
2137 rm -f $DIR/d52a/foo 2>/dev/null && error "rm worked"
2138 link $DIR/d52a/foo $DIR/d52a/foo_link 2>/dev/null && error "link worked"
2139 echo foo >> $DIR/d52a/foo || error "append foo failed"
2140 mrename $DIR/d52a/foo $DIR/d52a/foo_ren && error "rename worked"
2141 lsattr $DIR/d52a/foo | egrep -q "^-+a-+ $DIR/d52a/foo" || error "lsattr"
2142 chattr -a $DIR/d52a/foo || error "chattr -a failed"
2144 rm -fr $DIR/d52a || error "cleanup rm failed"
2146 run_test 52a "append-only flag test (should return errors) ====="
2149 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
2152 chattr =i $DIR/d52b/foo || error
2153 cat test > $DIR/d52b/foo && error
2154 cp /etc/hosts $DIR/d52b/foo && error
2155 rm -f $DIR/d52b/foo 2>/dev/null && error
2156 link $DIR/d52b/foo $DIR/d52b/foo_link 2>/dev/null && error
2157 echo foo >> $DIR/d52b/foo && error
2158 mrename $DIR/d52b/foo $DIR/d52b/foo_ren && error
2159 [ -f $DIR/d52b/foo ] || error
2160 [ -f $DIR/d52b/foo_ren ] && error
2161 lsattr $DIR/d52b/foo | egrep -q "^-+i-+ $DIR/d52b/foo" || error
2162 chattr -i $DIR/d52b/foo || error
2164 rm -fr $DIR/d52b || error
2166 run_test 52b "immutable flag test (should return errors) ======="
2169 for i in `ls -d $LPROC/osc/*-osc 2> /dev/null` ; do
2170 ostname=`basename $i | cut -d - -f 1-2`
2171 ost_last=`cat $LPROC/obdfilter/$ostname/last_id`
2172 mds_last=`cat $i/prealloc_last_id`
2173 echo "$ostname.last_id=$ost_last ; MDS.last_id=$mds_last"
2174 if [ $ost_last != $mds_last ]; then
2175 error "$ostname.last_id=$ost_last ; MDS.last_id=$mds_last"
2179 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
2182 $SOCKETSERVER $DIR/socket
2183 $SOCKETCLIENT $DIR/socket || error
2184 $MUNLINK $DIR/socket
2186 run_test 54a "unix domain socket test =========================="
2192 dd if=/dev/zero of=$f bs=`page_size` count=1
2194 run_test 54b "char device works in lustre ======================"
2197 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
2198 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
2199 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
2201 for i in `seq 3 7`; do
2202 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
2212 loopdev="$DIR/loop54c"
2215 [ -z "$LOOPNUM" ] && echo "couldn't find empty loop device" && return
2216 mknod $loopdev b 7 $LOOPNUM
2217 echo "make a loop file system with $tfile on $loopdev ($LOOPNUM)..."
2218 dd if=/dev/zero of=$tfile bs=`page_size` seek=1024 count=1 > /dev/null
2219 losetup $loopdev $tfile || error "can't set up $loopdev for $tfile"
2220 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
2222 mount -t ext2 $loopdev $tdir || error "error mounting $loopdev on $tdir"
2223 dd if=/dev/zero of=$tdir/tmp bs=`page_size` count=30 || error "dd write"
2225 dd if=$tdir/tmp of=/dev/zero bs=`page_size` count=30 || error "dd read"
2230 run_test 54c "block device works in lustre ====================="
2236 [ "$string" = `echo $string > $f | cat $f` ] || error
2238 run_test 54d "fifo device works in lustre ======================"
2241 check_kernel_version 46 || return 0
2245 echo $string > $f || error
2247 run_test 54e "console/tty device works in lustre ======================"
2250 grep -q $FSTYPE /proc/filesystems && return 1
2252 grep -q $FSTYPE /proc/filesystems && return 1
2253 insmod ../$FSTYPE/$FSTYPE.o
2254 grep -q $FSTYPE /proc/filesystems && return 1
2255 insmod ../$FSTYPE/$FSTYPE.ko
2256 grep -q $FSTYPE /proc/filesystems && return 1
2263 check_fstype && echo "can't find fs $FSTYPE, skipping $TESTNAME" && return
2264 mount -t $FSTYPE -o loop,iopen $EXT2_DEV $DIR/d55 || error "mounting"
2266 $IOPENTEST1 $DIR/d55/foo $DIR/d55 || error "running $IOPENTEST1"
2267 $IOPENTEST2 $DIR/d55 || error "running $IOPENTEST2"
2268 echo "check for $EXT2_DEV. Please wait..."
2270 $UMOUNT $DIR/d55 || error "unmounting"
2272 run_test 55 "check iopen_connect_dentry() ======================"
2280 NUMFILESx2=$(($NUMFILES * 2))
2281 for i in `seq 1 $NUMFILES` ; do
2282 touch $DIR/d56/file$i
2283 touch $DIR/d56/dir/file$i
2286 # test lfs getstripe with --recursive
2287 FILENUM=`$GETSTRIPE --recursive $DIR/d56 | grep -c obdidx`
2288 [ $FILENUM -eq $NUMFILESx2 ] || error \
2289 "lfs getstripe --recursive $DIR/d56 wrong: found $FILENUM, expected $NUMFILESx2"
2290 FILENUM=`$GETSTRIPE $DIR/d56 | grep -c obdidx`
2291 [ $FILENUM -eq $NUMFILES ] || error \
2292 "lfs getstripe $DIR/d56 without --recursive wrong: found $FILENUM, expected $NUMFILES"
2293 echo "lfs getstripe --recursive passed."
2295 # test lfs getstripe with file instead of dir
2296 FILENUM=`$GETSTRIPE $DIR/d56/file1 | grep -c obdidx`
2297 [ $FILENUM -eq 1 ] || error \
2298 "lfs getstripe $DIR/d56/file1 wrong:found $FILENUM, expected 1"
2299 echo "lfs getstripe file passed."
2301 #test lfs getstripe with --verbose
2302 [ `$GETSTRIPE --verbose $DIR/d56 | grep -c lmm_magic` -eq $NUMFILES ] ||\
2303 error "lfs getstripe --verbose $DIR/d56 wrong: should find $NUMFILES lmm_magic info"
2304 [ `$GETSTRIPE $DIR/d56 | grep -c lmm_magic` -eq 0 ] || error \
2305 "lfs getstripe $DIR/d56 without --verbose wrong: should not show lmm_magic info"
2306 echo "lfs getstripe --verbose passed."
2308 #test lfs getstripe with --obd
2309 $GETSTRIPE --obd wrong_uuid $DIR/d56 2>&1 | grep -q "unknown obduuid" || \
2310 error "lfs getstripe --obd wrong_uuid should return error message"
2312 [ "$OSTCOUNT" -lt 2 ] && \
2313 echo "skipping other lfs getstripe --obd test" && return
2314 FILENUM=`$GETSTRIPE --recursive $DIR/d56 | sed -n '/^[ ]*1[ ]/p' | wc -l`
2315 OBDUUID=`$GETSTRIPE --recursive $DIR/d56 | sed -n '/^[ ]*1:/p' | awk '{print $2}'`
2316 FOUND=`$GETSTRIPE -r --obd $OBDUUID $DIR/d56 | wc -l`
2317 [ $FOUND -eq $FILENUM ] || \
2318 error "lfs getstripe --obd wrong: found $FOUND, expected $FILENUM"
2319 [ `$GETSTRIPE -r -v --obd $OBDUUID $DIR/d56 | sed '/^[ ]*1[ ]/d' |\
2320 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l` -eq 0 ] || \
2321 error "lfs getstripe --obd wrong: should not show file on other obd"
2322 echo "lfs getstripe --obd passed."
2324 run_test 56 "check lfs getstripe ===================================="
2327 # note test will not do anything if MDS is not local
2328 for DEV in `cat $LPROC/mds/*/mntdev`; do
2329 dumpe2fs -h $DEV > $TMP/t57a.dump || error "can't access $DEV"
2330 DEVISIZE=`awk '/Inode size:/ { print $3 }' $TMP/t57a.dump`
2331 [ "$DEVISIZE" -gt 128 ] || error "inode size $DEVISIZE"
2335 run_test 57a "verify MDS filesystem created with large inodes =="
2338 # now we do not support large directory. I change this from 100 to 10
2339 # restore it when ready -- huanghua
2342 FILEN=$DIR/d57b/f$FILECOUNT
2343 rm -rf $DIR/d57b || error "removing $DIR/d57b"
2344 mkdir -p $DIR/d57b || error "creating $DIR/d57b"
2345 echo "mcreating $FILECOUNT files"
2346 createmany -m $DIR/d57b/f 1 $FILECOUNT || \
2347 error "creating files in $DIR/d57b"
2349 # verify that files do not have EAs yet
2350 $GETSTRIPE $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
2351 $GETSTRIPE $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
2353 MDSFREE="`cat $LPROC/mds/*/kbytesfree`"
2354 MDCFREE="`cat $LPROC/mdc/*/kbytesfree`"
2355 echo "opening files to create objects/EAs"
2356 for FILE in `seq -f $DIR/d57b/f%g 1 $FILECOUNT`; do
2357 $OPENFILE -f O_RDWR $FILE > /dev/null || error "opening $FILE"
2360 # verify that files have EAs now
2361 $GETSTRIPE $FILE1 | grep -q "obdidx" || error "$FILE1 missing EA"
2362 $GETSTRIPE $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
2364 sleep 1 # make sure we get new statfs data
2365 # MDSFREE2="`cat $LPROC/mds/*/kbytesfree`"
2366 # MDCFREE2="`cat $LPROC/mdc/*/kbytesfree`"
2367 # if [ "$MDCFREE2" -lt "$((MDCFREE - 8))" ]; then
2368 # if [ "$MDSFREE" != "$MDSFREE2" ]; then
2369 # error "MDC before $MDCFREE != after $MDCFREE2"
2371 # echo "MDC before $MDCFREE != after $MDCFREE2"
2372 # echo "unable to confirm if MDS has large inodes"
2377 run_test 57b "default LOV EAs are stored inside large inodes ==="
2380 [ -z "$(which wiretest 2>/dev/null)" ] && echo "skipping $TESTNAME (could not find wiretest)" && return
2383 run_test 58 "verify cross-platform wire constants =============="
2386 echo "touch 130 files"
2387 createmany -o $DIR/f59- 130
2389 unlinkmany $DIR/f59- 130
2392 # wait for commitment of removal
2394 run_test 59 "verify cancellation of llog records async ========="
2397 echo 60 "llog tests run from kernel mode"
2400 run_test 60 "llog sanity tests run from kernel module =========="
2402 test_60b() { # bug 6411
2404 LLOG_COUNT=`dmesg | grep -c llog_test`
2405 [ $LLOG_COUNT -gt 50 ] && error "CDEBUG_LIMIT not limiting messages"|| true
2407 run_test 60b "limit repeated messages from CERROR/CWARN ========"
2411 dd if=/dev/zero of=$f bs=`page_size` count=1
2412 cancel_lru_locks osc
2413 multiop $f OSMWUc || error
2416 run_test 61 "mmap() writes don't make sync hang ================"
2418 # bug 2330 - insufficient obd_match error checking causes LBUG
2422 cancel_lru_locks osc
2423 sysctl -w lustre.fail_loc=0x405
2424 cat $f && error "cat succeeded, expect -EIO"
2425 sysctl -w lustre.fail_loc=0
2427 run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
2429 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
2431 MAX_DIRTY_MB=`cat $LPROC/osc/*/max_dirty_mb | head -n 1`
2432 for i in $LPROC/osc/*/max_dirty_mb ; do
2435 for i in `seq 10` ; do
2436 dd if=/dev/zero of=$DIR/f63 bs=8k &
2442 for i in $LPROC/osc/*/max_dirty_mb ; do
2443 echo $MAX_DIRTY_MB > $i
2445 rm -f $DIR/f63 || true
2447 run_test 63 "Verify oig_wait interruption does not crash ======="
2449 # bug 2248 - async write errors didn't return to application on sync
2450 # bug 3677 - async write errors left page locked
2452 DBG_SAVE=`sysctl -n lnet.debug`
2453 sysctl -w lnet.debug=-1
2455 # ensure we have a grant to do async writes
2456 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
2459 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
2460 sysctl -w lustre.fail_loc=0x80000406
2461 multiop $DIR/$tfile Owy && \
2462 $LCTL dk /tmp/test63b.debug && \
2463 sysctl -w lnet.debug=$DBG_SAVE && \
2464 error "sync didn't return ENOMEM"
2465 grep -q locked $LPROC/llite/*/dump_page_cache && \
2466 $LCTL dk /tmp/test63b.debug && \
2467 sysctl -w lnet.debug=$DBG_SAVE && \
2468 error "locked page left in cache after async error" || true
2469 sysctl -w lnet.debug=$DBG_SAVE
2471 run_test 63b "async write errors should be returned to fsync ==="
2475 grep "[0-9]" $LPROC/osc/*-osc-*/cur*
2477 run_test 64a "verify filter grant calculations (in kernel) ====="
2482 run_test 64b "check out-of-space detection on client ==========="
2484 # bug 1414 - set/get directories' stripe info
2488 $LVERIFY $DIR/d65 $DIR/d65/f1 || error "lverify failed"
2490 run_test 65a "directory with no stripe info ===================="
2494 $SETSTRIPE $DIR/d65 $(($STRIPESIZE * 2)) 0 1 || error "setstripe"
2496 $LVERIFY $DIR/d65 $DIR/d65/f2 || error "lverify failed"
2498 run_test 65b "directory setstripe $(($STRIPESIZE * 2)) 0 1 ==============="
2501 if [ $OSTCOUNT -gt 1 ]; then
2503 $SETSTRIPE $DIR/d65 $(($STRIPESIZE * 4)) 1 \
2504 $(($OSTCOUNT - 1)) || error "setstripe"
2506 $LVERIFY $DIR/d65 $DIR/d65/f3 || error "lverify failed"
2509 run_test 65c "directory setstripe $(($STRIPESIZE * 4)) 1 $(($OSTCOUNT - 1))"
2511 [ $STRIPECOUNT -eq 0 ] && sc=1 || sc=$(($STRIPECOUNT - 1))
2515 $SETSTRIPE $DIR/d65 $STRIPESIZE -1 $sc || error "setstripe"
2516 touch $DIR/d65/f4 $DIR/d65/f5
2517 $LVERIFY $DIR/d65 $DIR/d65/f4 $DIR/d65/f5 || error "lverify failed"
2519 run_test 65d "directory setstripe $STRIPESIZE -1 $sc =============="
2524 $SETSTRIPE $DIR/d65 0 -1 0 || error "setstripe"
2525 $GETSTRIPE -v $DIR/d65 | grep "has no stripe info" || error "no stripe info failed"
2527 $LVERIFY $DIR/d65 $DIR/d65/f6 || error "lverify failed"
2529 run_test 65e "directory setstripe 0 -1 0 ======================="
2533 $RUNAS $SETSTRIPE $DIR/d65f 0 -1 0 && error "setstripe succeeded" || true
2535 run_test 65f "dir setstripe permission (should return error) ==="
2539 $SETSTRIPE $DIR/d65 $(($STRIPESIZE * 2)) 0 1 || error "setstripe"
2540 $SETSTRIPE -d $DIR/d65 || error "setstripe"
2541 $GETSTRIPE -v $DIR/d65 | grep "has no stripe info" || \
2542 error "delete default stripe failed"
2544 run_test 65g "directory setstripe -d ==========================="
2548 $SETSTRIPE $DIR/d65 $(($STRIPESIZE * 2)) 0 1 || error "setstripe"
2549 mkdir -p $DIR/d65/dd1
2550 [ "`$GETSTRIPE -v $DIR/d65 | grep "^count"`" == \
2551 "`$GETSTRIPE -v $DIR/d65/dd1 | grep "^count"`" ] || error "stripe info inherit failed"
2553 run_test 65h "directory stripe info inherit ===================="
2555 test_65i() { # bug6367
2556 $SETSTRIPE $MOUNT 65536 -1 -1
2558 run_test 65i "set non-default striping on root directory (bug 6367)="
2560 test_65j() { # bug6367
2562 # if we aren't already remounting for each test, do so for this test
2563 if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
2564 cleanup -f || error "failed to unmount"
2567 $SETSTRIPE -d $MOUNT
2569 run_test 65j "set default striping on root directory (bug 6367)="
2571 # bug 2543 - update blocks count on client
2574 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
2576 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
2577 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
2579 run_test 66 "update inode blocks count on client ==============="
2581 test_67() { # bug 3285 - supplementary group fails on MDS, passes on client
2582 [ "$RUNAS_ID" = "$UID" ] && echo "skipping $TESTNAME" && return
2583 check_kernel_version 35 || return 0
2586 chgrp $RUNAS_ID $DIR/d67
2587 $RUNAS -u $RUNAS_ID -g $(($RUNAS_ID + 1)) -G1,2,$RUNAS_ID ls $DIR/d67
2590 # can't tell which is correct otherwise
2591 GROUP_UPCALL=`cat $LPROC/mds/$MDS/group_upcall`
2592 [ "$GROUP_UPCALL" = "NONE" -a $RC -eq 0 ] && \
2593 error "no-upcall passed" || true
2594 [ "$GROUP_UPCALL" != "NONE" -a $RC -ne 0 ] && \
2595 error "upcall failed" || true
2598 run_test 67 "supplementary group failure (should return error) ="
2602 if [ "$LOOPDEV" ]; then
2603 swapoff $LOOPDEV || error "swapoff failed"
2604 losetup -d $LOOPDEV || error "losetup -d failed"
2605 unset LOOPDEV LOOPNUM
2611 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
2615 swapon -s | awk '($1 == "'$1'") { print $4 }'
2618 # excercise swapping to lustre by adding a high priority swapfile entry
2619 # and then consuming memory until it is used.
2621 # my UML is out of memory, so I skip it -- huanghua
2623 [ "$UID" != 0 ] && echo "skipping $TESTNAME (must run as root)" && return
2624 [ "`lsmod|grep obdfilter`" ] && echo "skipping $TESTNAME (local OST)" && \
2628 dd if=/dev/zero of=$DIR/f68 bs=64k count=1024
2630 trap cleanup_68 EXIT
2632 losetup $LOOPDEV $DIR/f68 || error "losetup $LOOPDEV failed"
2634 swapon -p 32767 $LOOPDEV || error "swapon $LOOPDEV failed"
2636 echo "before: `swapon -s | grep $LOOPDEV`"
2637 KBFREE=`meminfo MemTotal`
2638 $MEMHOG $KBFREE || error "error allocating $KBFREE kB"
2639 echo "after: `swapon -s | grep $LOOPDEV`"
2640 SWAPUSED=`swap_used $LOOPDEV`
2644 [ $SWAPUSED -eq 0 ] && echo "no swap used???" || true
2646 run_test 68 "support swapping to Lustre ========================"
2648 # bug5265, obdfilter oa2dentry return -ENOENT
2649 # #define OBD_FAIL_OST_ENOENT 0x217
2651 [ -z "`lsmod|grep obdfilter`" ] &&
2652 echo "skipping $TESTNAME (remote OST)" && return
2653 [ ! -z "$USING_KRB5" ] &&
2654 echo "skipping $TESTNAME (gss with bulk security will triger oops. re-enable this after b10091 get fixed)" && return
2659 if ! $DIRECTIO write ${f}.2 0 1; then
2660 echo "skipping $TESTNAME - O_DIRECT not implemented"
2664 sysctl -w lustre.fail_loc=0x217
2665 truncate $f 1 # vmtruncate() will ignore truncate() error.
2666 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
2668 sysctl -w lustre.fail_loc=0
2669 $DIRECTIO write $f 0 2 || error "write error"
2671 cancel_lru_locks osc
2672 $DIRECTIO read $f 0 1 || error "read error"
2674 sysctl -w lustre.fail_loc=0x217
2675 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
2677 sysctl -w lustre.fail_loc=0
2680 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
2683 DBENCH_LIB=${DBENCH_LIB:-/usr/lib/dbench}
2684 PATH=${DBENCH_LIB}:${PATH}
2685 cp `which dbench` $DIR
2687 [ ! -f $DIR/dbench ] && echo "dbench not installed, skip this test" && return 0
2690 SRC=${SRC:-$DBENCH_LIB/client.txt}
2691 [ ! -e $TGT -a -e $SRC ] && echo "copying $SRC to $TGT" && cp $SRC $TGT
2692 SRC=$DBENCH_LIB/client_plain.txt
2693 [ ! -e $TGT -a -e $SRC ] && echo "copying $SRC to $TGT" && cp $SRC $TGT
2695 echo "copying necessary lib to $DIR"
2696 [ -d /lib64 ] && LIB71=/lib64 || LIB71=/lib
2697 mkdir -p $DIR$LIB71 || error "can't create $DIR$LIB71"
2698 cp $LIB71/libc* $DIR$LIB71 || error "can't copy $LIB71/libc*"
2699 cp $LIB71/ld-* $DIR$LIB71 || error "can't create $LIB71/ld-*"
2701 echo "chroot $DIR /dbench -c client.txt 2"
2702 chroot $DIR /dbench -c client.txt 2
2705 rm -rf $DIR/dbench $TGT $DIR$LIB71
2709 run_test 71 "Running dbench on lustre (don't segment fault) ===="
2711 test_72() { # bug 5695 - Test that on 2.6 remove_suid works properly
2712 check_kernel_version 43 || return 0
2713 [ "$RUNAS_ID" = "$UID" ] && echo "skipping $TESTNAME" && return
2714 # We had better clear the $DIR to get enough space for dd
2719 $RUNAS -u $(($RUNAS_ID + 1)) dd if=/dev/zero of=$DIR/f72 bs=512 count=1 || error
2720 # See if we are still setuid/sgid
2721 test -u $DIR/f72 -o -g $DIR/f72 && error "S/gid is not dropped on write"
2722 # Now test that MDS is updated too
2723 cancel_lru_locks mdc
2724 test -u $DIR/f72 -o -g $DIR/f72 && error "S/gid is not dropped on MDS"
2727 run_test 72 "Test that remove suid works properly (bug5695) ===="
2729 # bug 3462 - multiple simultaneous MDC requests
2733 multiop $DIR/d73-1/f73-1 O_c &
2735 #give multiop a chance to open
2738 echo 0x80000129 > /proc/sys/lustre/fail_loc
2739 multiop $DIR/d73-1/f73-2 Oc &
2741 echo 0 > /proc/sys/lustre/fail_loc
2743 multiop $DIR/d73-2/f73-3 Oc &
2747 wait $pid1 || return 1
2751 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
2752 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
2753 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
2757 run_test 73 "multiple MDC requests (should not deadlock)"
2759 test_74() { # bug 6149, 6184
2760 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
2762 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
2763 # will spin in a tight reconnection loop
2764 sysctl -w lustre.fail_loc=0x8000030e
2767 sysctl -w lustre.fail_loc=0
2770 run_test 74 "ldlm_enqueue freed-export error path (shouldn't LBUG)"
2772 JOIN=${JOIN:-"lfs join"}
2779 [ $T75_PREP = "yes" ] && return
2780 echo "using F75=$F75, F128k=$F128k, FHEAD=$FHEAD, FTAIL=$FTAIL"
2782 dd if=/dev/urandom of=${F75}_128k bs=128k count=1 || error "dd failed"
2789 # skipped temporarily: we do not have join file currently
2790 # please remove this when ready - huanghua
2794 cp -p ${F128k} ${FHEAD}
2795 log "finished cp to $FHEAD"
2796 cp -p ${F128k} ${FTAIL}
2797 log "finished cp to $FTAIL"
2798 cat ${F128k} ${F128k} > ${F75}_sim_sim
2800 $JOIN ${FHEAD} ${FTAIL} || error "join ${FHEAD} ${FTAIL} error"
2801 log "finished join $FHEAD to ${F75}_sim_sim"
2802 cmp ${FHEAD} ${F75}_sim_sim || error "${FHEAD} ${F75}_sim_sim differ"
2803 log "finished cmp $FHEAD to ${F75}_sim_sim"
2804 $CHECKSTAT -a ${FTAIL} || error "tail ${FTAIL} still exist after join"
2806 run_test 75a "TEST join file ===================================="
2809 # skipped temporarily: we do not have join file currently
2810 # please remove this when ready - huanghua
2814 cp -p ${F128k} ${FTAIL}
2815 cat ${F75}_sim_sim >> ${F75}_join_sim
2816 cat ${F128k} >> ${F75}_join_sim
2817 $JOIN ${FHEAD} ${FTAIL} || error "join ${FHEAD} ${FTAIL} error"
2818 cmp ${FHEAD} ${F75}_join_sim || \
2819 error "${FHEAD} ${F75}_join_sim are different"
2820 $CHECKSTAT -a ${FTAIL} || error "tail ${FTAIL} exist after join"
2822 run_test 75b "TEST join file 2 =================================="
2825 # skipped temporarily: we do not have join file currently
2826 # please remove this when ready - huanghua
2830 cp -p ${F128k} ${FTAIL}
2831 cat ${F128k} >> ${F75}_sim_join
2832 cat ${F75}_join_sim >> ${F75}_sim_join
2833 $JOIN ${FTAIL} ${FHEAD} || error "join error"
2834 cmp ${FTAIL} ${F75}_sim_join || \
2835 error "${FTAIL} ${F75}_sim_join are different"
2836 $CHECKSTAT -a ${FHEAD} || error "tail ${FHEAD} exist after join"
2838 run_test 75c "TEST join file 3 =================================="
2841 # skipped temporarily: we do not have join file currently
2842 # please remove this when ready - huanghua
2846 cp -p ${F128k} ${FHEAD}
2847 cp -p ${F128k} ${FHEAD}_tmp
2848 cat ${F75}_sim_sim >> ${F75}_join_join
2849 cat ${F75}_sim_join >> ${F75}_join_join
2850 $JOIN ${FHEAD} ${FHEAD}_tmp || error "join ${FHEAD} ${FHEAD}_tmp error"
2851 $JOIN ${FHEAD} ${FTAIL} || error "join ${FHEAD} ${FTAIL} error"
2852 cmp ${FHEAD} ${F75}_join_join ||error "${FHEAD} ${F75}_join_join differ" $CHECKSTAT -a ${FHEAD}_tmp || error "${FHEAD}_tmp exist after join"
2853 $CHECKSTAT -a ${FTAIL} || error "tail ${FTAIL} exist after join (2)"
2855 run_test 75d "TEST join file 4 =================================="
2858 # skipped temporarily: we do not have join file currently
2859 # please remove this when ready - huanghua
2863 rm -rf ${FHEAD} || "delete join file error"
2865 run_test 75e "TEST join file 5 (remove joined file) ============="
2868 # skipped temporarily: we do not have join file currently
2869 # please remove this when ready - huanghua
2873 cp -p ${F128k} ${F75}_join_10_compare
2874 cp -p ${F128k} ${F75}_join_10
2875 for ((i = 0; i < 10; i++)); do
2876 cat ${F128k} >> ${F75}_join_10_compare
2877 cp -p ${F128k} ${FTAIL}
2878 $JOIN ${F75}_join_10 ${FTAIL} || \
2879 error "join ${F75}_join_10 ${FTAIL} error"
2880 $CHECKSTAT -a ${FTAIL} || error "tail file exist after join"
2882 cmp ${F75}_join_10 ${F75}_join_10_compare || \
2883 error "files ${F75}_join_10 ${F75}_join_10_compare differ"
2885 run_test 75f "TEST join file 6 (join 10 files) =================="
2888 # skipped temporarily: we do not have join file currently
2889 # please remove this when ready - huanghua
2891 [ ! -f ${F75}_join_10 ] && echo "${F75}_join_10 missing" && return
2892 $LFS getstripe ${F75}_join_10
2894 $OPENUNLINK ${F75}_join_10 ${F75}_join_10 || error "files unlink open"
2898 run_test 75g "TEST join file 7 (open unlink) ===================="
2901 awk '/lustre_inode_cache|^inode_cache/ {print $2; exit}' /proc/slabinfo
2904 test_76() { # bug 1443
2905 BEFORE_INODES=`num_inodes`
2906 echo "before inodes: $BEFORE_INODES"
2907 for i in `seq 1000`; do
2911 AFTER_INODES=`num_inodes`
2912 echo "after inodes: $AFTER_INODES"
2913 [ $AFTER_INODES -gt $((BEFORE_INODES + 32)) ] && \
2914 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
2917 run_test 76 "destroy duplicate inodes in client inode cache ===="
2922 run_test 77 "qos test ============================================"
2924 # on the LLNL clusters, runas will still pick up root's $TMP settings,
2925 # which will not be writable for the runas user, and then you get a CVS
2926 # error message with a corrupt path string (CVS bug) and panic.
2927 # We're not using much space, so just stick it in /tmp, which is safe.
2933 [ $RUNAS_ID -ne $UID ] && HOME=/tmp
2936 mkdir -p $DIR/d99cvsroot
2937 chown $RUNAS_ID $DIR/d99cvsroot
2938 $RUNAS cvs -d $DIR/d99cvsroot init || error
2940 run_test 99a "cvs init ========================================="
2942 # For test_99b, we will get the same error on local filesystem--ext3.
2944 [ ! -d $DIR/d99cvsroot ] && test_99a
2946 # some versions of cvs import exit(1) when asked to import links or
2947 # files they can't read. ignore those files.
2948 TOIGNORE=$(find . -type l -printf '-I %f\n' -o \
2949 ! -perm +4 -printf '-I %f\n')
2950 $RUNAS cvs -d $DIR/d99cvsroot import -m "nomesg" $TOIGNORE \
2951 d99reposname vtag rtag
2953 run_test 99b "cvs import ======================================="
2956 [ ! -d $DIR/d99cvsroot ] && test_99b
2958 mkdir -p $DIR/d99reposname
2959 chown $RUNAS_ID $DIR/d99reposname
2960 $RUNAS cvs -d $DIR/d99cvsroot co d99reposname
2962 run_test 99c "cvs checkout ====================================="
2965 [ ! -d $DIR/d99cvsroot ] && test_99c
2966 cd $DIR/d99reposname
2968 $RUNAS cvs add -m 'addmsg' foo99
2970 run_test 99d "cvs add =========================================="
2973 [ ! -d $DIR/d99cvsroot ] && test_99c
2974 cd $DIR/d99reposname
2977 run_test 99e "cvs update ======================================="
2980 [ ! -d $DIR/d99cvsroot ] && test_99d
2981 cd $DIR/d99reposname
2982 $RUNAS cvs commit -m 'nomsg' foo99
2984 run_test 99f "cvs commit ======================================="
2987 netstat -tna | while read PROT SND RCV LOCAL REMOTE STAT; do
2988 [ "$PROT" != "tcp" ] && continue
2989 RPORT=`echo $REMOTE | cut -d: -f2`
2990 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
2991 LPORT=`echo $LOCAL | cut -d: -f2`
2992 if [ $LPORT -ge 1024 ]; then
2993 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
2995 error "local: $LPORT > 1024, remote: $RPORT"
3000 run_test 100 "check local port using privileged port ==========="
3002 function get_named_value()
3011 echo $line | sed "s/^$tag//"
3018 export CACHE_MAX=`cat /proc/fs/lustre/llite/*/max_cached_mb | head -n 1`
3020 for s in $LPROC/llite/*/max_cached_mb; do
3021 echo $CACHE_MAX > $s
3030 [ "$CPU" = "UML" ] && nreads=1000
3031 local cache_limit=32
3033 for s in $LPROC/osc/*-osc*/rpc_stats; do
3036 trap cleanup_101 EXIT
3037 for s in $LPROC/llite/*; do
3038 echo 0 > $s/read_ahead_stats
3039 echo $cache_limit > $s/max_cached_mb
3043 # randomly read 10000 of 64K chunks from file 3x 32MB in size
3045 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
3046 $RANDOM_READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
3049 for s in $LPROC/llite/*; do
3050 discard=$(($discard + $(cat $s/read_ahead_stats | get_named_value 'read but discarded')))
3054 if [ $(($discard * 10)) -gt $nreads ] ;then
3055 cat $LPROC/osc/*-osc*/rpc_stats
3056 cat $LPROC/llite/*/read_ahead_stats
3057 error "too many ($discard) discarded pages"
3059 rm -f $DIR/$tfile || true
3061 run_test 101 "check read-ahead for random reads ================"
3064 local testfile=$DIR/xattr_testfile
3069 [ "$UID" != 0 ] && echo "skipping $TESTNAME (must run as root)" && return
3070 [ -z "`grep xattr $LPROC/mdc/*-mdc-*/connect_flags`" ] && echo "skipping $TESTNAME (must have user_xattr)" && return
3071 [ -z "$(which setfattr 2>/dev/null)" ] && echo "skipping $TESTNAME (could not find setfattr)" && return
3073 echo "set/get xattr..."
3074 setfattr -n trusted.name1 -v value1 $testfile || error
3075 [ "`getfattr -n trusted.name1 $testfile 2> /dev/null | \
3076 grep "trusted.name1"`" == "trusted.name1=\"value1\"" ] || error
3078 setfattr -n user.author1 -v author1 $testfile || error
3079 [ "`getfattr -n user.author1 $testfile 2> /dev/null | \
3080 grep "user.author1"`" == "user.author1=\"author1\"" ] || error
3083 setfattr -n trusted.name2 -v value2 $testfile || error
3084 setfattr -n trusted.name3 -v value3 $testfile || error
3085 [ `getfattr -d -m "^trusted" $testfile 2> /dev/null | \
3086 grep "trusted.name" | wc -l` -eq 3 ] || error
3089 setfattr -n user.author2 -v author2 $testfile || error
3090 setfattr -n user.author3 -v author3 $testfile || error
3091 [ `getfattr -d -m "^user" $testfile 2> /dev/null | \
3092 grep "user" | wc -l` -eq 3 ] || error
3094 echo "remove xattr..."
3095 setfattr -x trusted.name1 $testfile || error
3096 getfattr -d -m trusted $testfile 2> /dev/null | \
3097 grep "trusted.name1" && error || true
3099 setfattr -x user.author1 $testfile || error
3100 getfattr -d -m user $testfile 2> /dev/null | \
3101 grep "user.author1" && error || true
3103 # b10667: setting lustre special xattr be silently discarded
3104 echo "set lustre special xattr ..."
3105 setfattr -n "trusted.lov" -v "invalid value" $testfile || error
3109 run_test 102 "user xattr test =================================="
3113 $SAVE_PWD/acl/run $SAVE_PWD/acl/$1.test
3118 [ "$UID" != 0 ] && echo "skipping $TESTNAME (must run as root)" && return
3119 [ -z "$(grep acl $LPROC/mdc/*-mdc-*/connect_flags)" ] && echo "skipping $TESTNAME (must have acl enabled)" && return
3120 [ -z "$(which setfacl 2>/dev/null)" ] && echo "skipping $TESTNAME (could not find setfacl)" && return
3121 [ ! -z "$USING_KRB5" ] && echo "skipping $TESTNAME (could not run under gss)" && return
3127 echo "performing cp ..."
3128 run_acl_subtest cp || error
3129 echo "performing getfacl-noacl..."
3130 run_acl_subtest getfacl-noacl || error
3131 echo "performing misc..."
3132 run_acl_subtest misc || error
3133 # XXX add back permission test when we support supplementary groups.
3134 # echo "performing permissions..."
3135 # run_acl_subtest permissions || error
3136 echo "performing setfacl..."
3137 run_acl_subtest setfacl || error
3139 # inheritance test got from HP
3140 echo "performing inheritance..."
3141 cp $SAVE_PWD/acl/make-tree . || error
3142 chmod +x make-tree || error
3143 run_acl_subtest inheritance || error
3149 run_test 103 "acl test ========================================="
3153 lfs df || error "lfs df failed"
3154 lfs df -ih || error "lfs df -ih failed"
3155 lfs df -h $DIR || error "lfs df -h $DIR failed"
3156 lfs df -i $DIR || error "lfs df -i $DIR failed"
3157 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
3158 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
3160 OSC=`awk '/-osc-/ {print $4}' $LPROC/devices | head -n 1`
3161 lctl --device %$OSC deactivate
3162 lfs df || error "lfs df with deactivated OSC failed"
3163 lctl --device %$OSC recover
3164 lfs df || error "lfs df with reactivated OSC failed"
3166 run_test 104 "lfs df [-ih] [path] test ========================="
3172 log "cleanup: ======================================================"
3173 if [ "`mount | grep ^$NAME`" ]; then
3174 rm -rf $DIR/[Rdfs][1-9]*
3176 if [ "$I_MOUNTED" = "yes" ]; then
3177 cleanupall -f || error "cleanup failed"
3181 echo '=========================== finished ==============================='
3182 [ -f "$SANITYLOG" ] && cat $SANITYLOG && exit 1 || true