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: 4900 4900 2108 9789 3637 9789 3561 5188/5749 10764
11 ALWAYS_EXCEPT=${ALWAYS_EXCEPT:-"27o 27q 42a 42b 42c 42d 45 68 75"}
12 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
14 [ "$SLOW" = "no" ] && EXCEPT="$EXCEPT 24o 27m 36f 36g 51b 51c 60c 63 64b 71 73 101 103 115 120g"
16 # Tests that fail on uml, maybe elsewhere, FIXME
17 CPU=`awk '/model/ {print $4}' /proc/cpuinfo`
18 # buffer i/o errs sock spc runas
19 [ "$CPU" = "UML" ] && EXCEPT="$EXCEPT 27m 27n 27o 27p 27q 27r 31d 54a 64b 99a 99b 99c 99d 99e 99f 101"
22 2.4*) FSTYPE=${FSTYPE:-ext3}; ALWAYS_EXCEPT="$ALWAYS_EXCEPT 76"
23 [ "$CPU" = "UML" ] && ALWAYS_EXCEPT="$ALWAYS_EXCEPT 105a";;
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 LSTRIPE=${LSTRIPE:-"$LFS setstripe"}
39 LFIND=${LFIND:-"$LFS find"}
40 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
41 LSTRIPEINFO=${LSTRIPEINFO:-ll_getstripe_info}
43 MCREATE=${MCREATE:-mcreate}
44 OPENFILE=${OPENFILE:-openfile}
45 OPENUNLINK=${OPENUNLINK:-openunlink}
46 RANDOM_READS=${RANDOM_READS:-"random-reads"}
47 TOEXCL=${TOEXCL:-toexcl}
48 TRUNCATE=${TRUNCATE:-truncate}
49 MUNLINK=${MUNLINK:-munlink}
50 SOCKETSERVER=${SOCKETSERVER:-socketserver}
51 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
52 IOPENTEST1=${IOPENTEST1:-iopentest1}
53 IOPENTEST2=${IOPENTEST2:-iopentest2}
54 MEMHOG=${MEMHOG:-memhog}
55 DIRECTIO=${DIRECTIO:-directio}
56 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
57 UMOUNT=${UMOUNT:-"umount -d"}
59 if [ $UID -ne 0 ]; then
60 echo "Warning: running as non-root uid $UID"
64 RUNAS_ID=${RUNAS_ID:-500}
65 RUNAS=${RUNAS:-"runas -u $RUNAS_ID"}
67 # $RUNAS_ID may get set incorrectly somewhere else
68 if [ $RUNAS_ID -eq 0 ]; then
69 echo "Error: \$RUNAS_ID set to 0, but \$UID is also 0!"
74 SANITYLOG=${SANITYLOG:-$TMP/sanity.log}
76 export NAME=${NAME:-local}
80 LUSTRE=${LUSTRE:-`dirname $0`/..}
81 . $LUSTRE/tests/test-framework.sh
83 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
87 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
101 $LCTL mark "$*" 2> /dev/null || true
106 strace -o $TMP/$1.strace -ttt $*
108 log "FINISHED: $*: rc $RC"
113 check_kernel_version() {
114 VERSION_FILE=$LPROC/version
116 [ ! -f $VERSION_FILE ] && echo "can't find kernel version" && return 1
117 GOT_VER=$(awk '/kernel:/ {print $2}' $VERSION_FILE)
118 [ $GOT_VER == "patchless" ] && return 0
119 [ $GOT_VER -ge $WANT_VER ] && return 0
120 log "test needs at least kernel version $WANT_VER, running $GOT_VER"
129 IFS=abcdefghijklmnopqrstuvwxyz _basetest $1
133 if ! grep -q $DIR /proc/mounts; then
139 log "== test $testnum: $message= `date +%H:%M:%S` ($BEFORE)"
140 export TESTNAME=test_$testnum
141 export tfile=f${testnum}
143 test_${testnum} || error "exit with rc=$?"
145 pass "($((`date +%s` - $BEFORE))s)"
150 build_test_filter() {
151 [ "$ALWAYS_EXCEPT$EXCEPT$SANITY_EXCEPT" ] && \
152 echo "Skipping tests: `echo $ALWAYS_EXCEPT $EXCEPT $SANITY_EXCEPT`"
157 for E in $EXCEPT $ALWAYS_EXCEPT $SANITY_EXCEPT; do
158 eval EXCEPT_${E}=true
167 IFS=abcdefghijklmnopqrstuvwxyz _basetest $1
171 export base=`basetest $1`
174 if [ ${!testname}x != x ]; then
179 if [ ${!testname}x != x ]; then
187 if [ ${!testname}x != x ]; then
188 echo "skipping excluded test $1"
191 testname=EXCEPT_$base
192 if [ ${!testname}x != x ]; then
193 echo "skipping excluded test $1 (base $base)"
200 [ "$SANITYLOG" ] && rm -f $SANITYLOG || true
203 sysctl -w lustre.fail_loc=0
204 log "$0: FAIL: $TESTNAME $@"
205 $LCTL dk $TMP/lustre-log-$TESTNAME.log
206 if [ "$SANITYLOG" ]; then
207 echo "$0: FAIL: $TESTNAME $@" >> $SANITYLOG
217 mounted_lustre_filesystems() {
218 awk '($3 ~ "lustre" && $1 ~ ":") { print $2 }' /proc/mounts
221 MOUNTED="`mounted_lustre_filesystems`"
222 if [ -z "$MOUNTED" ]; then
225 MOUNTED="`mounted_lustre_filesystems`"
226 [ -z "$MOUNTED" ] && error "NAME=$NAME not mounted"
231 [ -z "`echo $DIR | grep $MOUNT`" ] && echo "$DIR not in $MOUNT" && exit 99
233 LOVNAME=`cat $LPROC/llite/*/lov/common_name | tail -n 1`
234 OSTCOUNT=`cat $LPROC/lov/$LOVNAME/numobd`
235 STRIPECOUNT=`cat $LPROC/lov/$LOVNAME/stripecount`
236 STRIPESIZE=`cat $LPROC/lov/$LOVNAME/stripesize`
237 ORIGFREE=`cat $LPROC/lov/$LOVNAME/kbytesavail`
238 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
239 MDS=$(\ls $LPROC/mds 2> /dev/null | grep -v num_refs | tail -n 1)
241 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
242 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
243 rm -rf $DIR/[Rdfs][1-9]*
247 echo "preparing for tests involving mounts"
248 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
250 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
251 echo # add a newline after mke2fs.
255 OLDDEBUG="`sysctl lnet.debug 2> /dev/null`"
256 sysctl -w lnet.debug=-1 2> /dev/null || true
259 $CHECKSTAT -t file $DIR/$tfile || error
261 $CHECKSTAT -a $DIR/$tfile || error
263 run_test 0 "touch .../$tfile ; rm .../$tfile ====================="
266 chmod 0755 $DIR || error
267 $CHECKSTAT -p 0755 $DIR || error
269 run_test 0b "chmod 0755 $DIR ============================="
274 $CHECKSTAT -t dir $DIR/d1/d2 || error
276 run_test 1a "mkdir .../d1; mkdir .../d1/d2 ====================="
281 $CHECKSTAT -a $DIR/d1 || error
283 run_test 1b "rmdir .../d1/d2; rmdir .../d1 ====================="
288 $CHECKSTAT -t file $DIR/d2/f || error
290 run_test 2a "mkdir .../d2; touch .../d2/f ======================"
294 $CHECKSTAT -a $DIR/d2 || error
296 run_test 2b "rm -r .../d2; checkstat .../d2/f ======================"
300 $CHECKSTAT -t dir $DIR/d3 || error
302 run_test 3a "mkdir .../d3 ======================================"
305 if [ ! -d $DIR/d3 ]; then
309 $CHECKSTAT -t file $DIR/d3/f || error
311 run_test 3b "touch .../d3/f ===================================="
315 $CHECKSTAT -a $DIR/d3 || error
317 run_test 3c "rm -r .../d3 ======================================"
321 $CHECKSTAT -t dir $DIR/d4 || error
323 run_test 4a "mkdir .../d4 ======================================"
326 if [ ! -d $DIR/d4 ]; then
330 $CHECKSTAT -t dir $DIR/d4/d2 || error
332 run_test 4b "mkdir .../d4/d2 ==================================="
337 chmod 0707 $DIR/d5/d2
338 $CHECKSTAT -t dir -p 0707 $DIR/d5/d2 || error
340 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2 ============"
344 chmod 0666 $DIR/f6a || error
345 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/f6a || error
347 run_test 6a "touch .../f6a; chmod .../f6a ======================"
350 [ $RUNAS_ID -eq $UID ] && echo "skipping $TESTNAME" && return
351 if [ ! -f $DIR/f6a ]; then
355 $RUNAS chmod 0444 $DIR/f6a && error
356 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/f6a || error
358 run_test 6b "$RUNAS chmod .../f6a (should return error) =="
361 [ $RUNAS_ID -eq $UID ] && echo "skipping $TESTNAME" && return
363 chown $RUNAS_ID $DIR/f6c || error
364 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/f6c || error
366 run_test 6c "touch .../f6c; chown .../f6c ======================"
369 [ $RUNAS_ID -eq $UID ] && echo "skipping $TESTNAME" && return
370 if [ ! -f $DIR/f6c ]; then
372 chown $RUNAS_ID $DIR/f6c
374 $RUNAS chown $UID $DIR/f6c && error
375 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/f6c || error
377 run_test 6d "$RUNAS chown .../f6c (should return error) =="
380 [ $RUNAS_ID -eq $UID ] && echo "skipping $TESTNAME" && return
382 chgrp $RUNAS_ID $DIR/f6e || error
383 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/f6e || error
385 run_test 6e "touch .../f6e; chgrp .../f6e ======================"
388 [ $RUNAS_ID -eq $UID ] && echo "skipping $TESTNAME" && return
389 if [ ! -f $DIR/f6e ]; then
391 chgrp $RUNAS_ID $DIR/f6e
393 $RUNAS chgrp $UID $DIR/f6e && error
394 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/f6e || error
396 run_test 6f "$RUNAS chgrp .../f6e (should return error) =="
399 [ $RUNAS_ID -eq $UID ] && echo "skipping $TESTNAME" && return
400 mkdir $DIR/d6g || error
401 chmod 777 $DIR/d6g || error
402 $RUNAS mkdir $DIR/d6g/d || error
403 chmod g+s $DIR/d6g/d || error
404 mkdir $DIR/d6g/d/subdir
405 $CHECKSTAT -g \#$RUNAS_ID $DIR/d6g/d/subdir || error
407 run_test 6g "Is new dir in sgid dir inheriting group?"
409 test_6h() { # bug 7331
410 [ $RUNAS_ID -eq $UID ] && echo "skipping $TESTNAME" && return
411 touch $DIR/f6h || error "touch failed"
412 chown $RUNAS_ID:$RUNAS_ID $DIR/f6h || error "initial chown failed"
413 $RUNAS -G$RUNAS_ID chown $RUNAS_ID:0 $DIR/f6h && error "chown worked"
414 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_ID $DIR/f6h || error
416 run_test 6h "$RUNAS chown RUNAS_ID.0 .../f6h (should return error)"
422 $CHECKSTAT -t file -p 0666 $DIR/d7/f || error
424 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
427 if [ ! -d $DIR/d7 ]; then
431 echo -n foo > $DIR/d7/f2
432 [ "`cat $DIR/d7/f2`" = "foo" ] || error
433 $CHECKSTAT -t file -s 3 $DIR/d7/f2 || error
435 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
441 $CHECKSTAT -t file -p 0666 $DIR/d8/f || error
443 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
449 $CHECKSTAT -t dir $DIR/d9/d2/d3 || error
451 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
457 $CHECKSTAT -t file $DIR/d10/d2/f || error
459 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
464 chmod 0666 $DIR/d11/d2
465 chmod 0705 $DIR/d11/d2
466 $CHECKSTAT -t dir -p 0705 $DIR/d11/d2 || error
468 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
473 chmod 0666 $DIR/d12/f
474 chmod 0654 $DIR/d12/f
475 $CHECKSTAT -t file -p 0654 $DIR/d12/f || error
477 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
481 dd if=/dev/zero of=$DIR/d13/f count=10
483 $CHECKSTAT -t file -s 0 $DIR/d13/f || error
485 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
491 $CHECKSTAT -a $DIR/d14/f || error
493 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
498 mv $DIR/d15/f $DIR/d15/f2
499 $CHECKSTAT -t file $DIR/d15/f2 || error
501 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
507 $CHECKSTAT -a $DIR/d16/f || error
509 run_test 16 "touch .../d16/f; rm -rf .../d16/f ================="
514 ln -s $DIR/d17/f $DIR/d17/l-exist
516 $CHECKSTAT -l $DIR/d17/f $DIR/d17/l-exist || error
517 $CHECKSTAT -f -t f $DIR/d17/l-exist || error
518 rm -f $DIR/d17/l-exist
519 $CHECKSTAT -a $DIR/d17/l-exist || error
521 run_test 17a "symlinks: create, remove (real) =================="
525 ln -s no-such-file $DIR/d17/l-dangle
527 $CHECKSTAT -l no-such-file $DIR/d17/l-dangle || error
528 $CHECKSTAT -fa $DIR/d17/l-dangle || error
529 rm -f $DIR/d17/l-dangle
530 $CHECKSTAT -a $DIR/d17/l-dangle || error
532 run_test 17b "symlinks: create, remove (dangling) =============="
534 test_17c() { # bug 3440 - don't save failed open RPC for replay
536 ln -s foo $DIR/d17/f17c
537 cat $DIR/d17/f17c && error "opened non-existent symlink" || true
539 run_test 17c "symlinks: open dangling (should return error) ===="
543 ln -s foo $DIR/d17/f17d
544 touch $DIR/d17/f17d || error "creating to new symlink"
546 run_test 17d "symlinks: create dangling ========================"
552 run_test 18 "touch .../f ; ls ... =============================="
558 $CHECKSTAT -a $DIR/f19 || error
560 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
563 ls -l $DIR/f19 && error || true
565 run_test 19b "ls -l .../f19 (should return error) =============="
568 [ $RUNAS_ID -eq $UID ] && echo "skipping $TESTNAME" && return
569 $RUNAS touch $DIR/f19 && error || true
571 run_test 19c "$RUNAS touch .../f19 (should return error) =="
574 cat $DIR/f19 && error || true
576 run_test 19d "cat .../f19 (should return error) =============="
588 $CHECKSTAT -a $DIR/f || error
590 run_test 20 "touch .../f ; ls -l ... ==========================="
594 [ -f $DIR/d21/dangle ] && rm -f $DIR/d21/dangle
595 ln -s dangle $DIR/d21/link
596 echo foo >> $DIR/d21/link
598 $CHECKSTAT -t link $DIR/d21/link || error
599 $CHECKSTAT -f -t file $DIR/d21/link || error
601 run_test 21 "write to dangling link ============================"
606 chown $RUNAS_ID $WDIR
607 (cd $WDIR || error "cd $WDIR failed";
608 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
610 ls -lR $WDIR/etc || error "ls -lR $WDIR/etc failed"
611 $CHECKSTAT -t dir $WDIR/etc || error "checkstat -t dir failed"
612 $CHECKSTAT -u \#$RUNAS_ID $WDIR/etc || error "checkstat -u failed"
614 run_test 22 "unpack tar archive as non-root user ==============="
619 $TOEXCL -e $DIR/d23/f23 || error
621 run_test 23 "O_CREAT|O_EXCL in subdir =========================="
624 echo '== rename sanity =============================================='
625 echo '-- same directory rename'
628 mv $DIR/R1/f $DIR/R1/g
629 $CHECKSTAT -t file $DIR/R1/g || error
631 run_test 24a "touch .../R1/f; rename .../R1/f .../R1/g ========="
636 mv $DIR/R2/f $DIR/R2/g
637 $CHECKSTAT -a $DIR/R2/f || error
638 $CHECKSTAT -t file $DIR/R2/g || error
640 run_test 24b "touch .../R2/{f,g}; rename .../R2/f .../R2/g ====="
645 mv $DIR/R3/f $DIR/R3/g
646 $CHECKSTAT -a $DIR/R3/f || error
647 $CHECKSTAT -t dir $DIR/R3/g || error
649 run_test 24c "mkdir .../R3/f; rename .../R3/f .../R3/g ========="
654 mrename $DIR/R4/f $DIR/R4/g
655 $CHECKSTAT -a $DIR/R4/f || error
656 $CHECKSTAT -t dir $DIR/R4/g || error
658 run_test 24d "mkdir .../R4/{f,g}; rename .../R4/f .../R4/g ====="
661 echo '-- cross directory renames --'
664 mv $DIR/R5a/f $DIR/R5b/g
665 $CHECKSTAT -a $DIR/R5a/f || error
666 $CHECKSTAT -t file $DIR/R5b/g || error
668 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
672 touch $DIR/R6a/f $DIR/R6b/g
673 mv $DIR/R6a/f $DIR/R6b/g
674 $CHECKSTAT -a $DIR/R6a/f || error
675 $CHECKSTAT -t file $DIR/R6b/g || error
677 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
682 mv $DIR/R7a/d $DIR/R7b/e
683 $CHECKSTAT -a $DIR/R7a/d || error
684 $CHECKSTAT -t dir $DIR/R7b/e || error
686 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R5b/e ======"
690 mkdir $DIR/R8a/d $DIR/R8b/e
691 mrename $DIR/R8a/d $DIR/R8b/e
692 $CHECKSTAT -a $DIR/R8a/d || error
693 $CHECKSTAT -t dir $DIR/R8b/e || error
695 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
698 echo "-- rename error cases"
702 mrename $DIR/R9/f $DIR/R9/a
703 $CHECKSTAT -t file $DIR/R9/f || error
704 $CHECKSTAT -t dir $DIR/R9/a || error
705 $CHECKSTAT -a file $DIR/R9/a/f || error
707 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
711 mrename $DIR/R10/f $DIR/R10/g
712 $CHECKSTAT -t dir $DIR/R10 || error
713 $CHECKSTAT -a $DIR/R10/f || error
714 $CHECKSTAT -a $DIR/R10/g || error
716 run_test 24j "source does not exist ============================"
719 mkdir $DIR/R11a $DIR/R11a/d
721 mv $DIR/R11a/f $DIR/R11a/d
722 $CHECKSTAT -a $DIR/R11a/f || error
723 $CHECKSTAT -t file $DIR/R11a/d/f || error
725 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
727 # bug 2429 - rename foo foo foo creates invalid file
730 multiop $f OcNs || error
732 run_test 24l "Renaming a file to itself ========================"
736 multiop $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
737 # on ext3 this does not remove either the source or target files
738 # though the "expected" operation would be to remove the source
739 $CHECKSTAT -t file ${f} || error "${f} missing"
740 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
742 run_test 24m "Renaming a file to a hard link to itself ========="
746 # this stats the old file after it was renamed, so it should fail
750 $CHECKSTAT ${f}.rename
753 run_test 24n "Statting the old file after renaming (Posix rename 2)"
756 check_kernel_version 37 || return 0
758 rename_many -s random -v -n 10 $DIR/d24o
760 run_test 24o "rename of files during htree split ==============="
764 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
765 mrename $DIR/R12a $DIR/R12b
766 $CHECKSTAT -a $DIR/R12a || error
767 $CHECKSTAT -t dir $DIR/R12b || error
768 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
769 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
771 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
775 DIRINO=`ls -lid $DIR/R13a | awk '{ print $1 }'`
776 multiop $DIR/R13b D_c &
780 mrename $DIR/R13a $DIR/R13b
781 $CHECKSTAT -a $DIR/R13a || error
782 $CHECKSTAT -t dir $DIR/R13b || error
783 DIRINO2=`ls -lid $DIR/R13b | awk '{ print $1 }'`
784 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
786 wait $MULTIPID || error "multiop close failed"
788 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
790 test_24r() { #bug 3789
791 mkdir $DIR/R14a $DIR/R14a/b
792 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
793 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
794 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
796 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
799 mkdir $DIR/R15a $DIR/R15a/b $DIR/R15a/b/c
800 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
801 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
802 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
804 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
806 mkdir $DIR/R16a $DIR/R16a/b $DIR/R16a/b/c
807 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
808 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
809 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
811 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
814 echo '== symlink sanity ============================================='
818 touch $DIR/s25/foo || error
820 run_test 25a "create file in symlinked directory ==============="
823 [ ! -d $DIR/d25 ] && test_25a
824 $CHECKSTAT -t file $DIR/s25/foo || error
826 run_test 25b "lookup file in symlinked directory ==============="
831 ln -s d26/d26-2 $DIR/s26
832 touch $DIR/s26/foo || error
834 run_test 26a "multiple component symlink ======================="
837 mkdir -p $DIR/d26b/d26-2
838 ln -s d26b/d26-2/foo $DIR/s26-2
839 touch $DIR/s26-2 || error
841 run_test 26b "multiple component symlink at end of lookup ======"
846 ln -s d26.2 $DIR/s26.2-1
847 ln -s s26.2-1 $DIR/s26.2-2
848 ln -s s26.2-2 $DIR/s26.2-3
849 chmod 0666 $DIR/s26.2-3/foo
851 run_test 26c "chain of symlinks ================================"
853 # recursive symlinks (bug 439)
855 ln -s d26-3/foo $DIR/d26-3
857 run_test 26d "create multiple component recursive symlink ======"
860 [ ! -h $DIR/d26-3 ] && test_26d
863 run_test 26e "unlink multiple component recursive symlink ======"
865 # recursive symlinks (bug 7022)
867 mkdir $DIR/$tfile || error "mkdir $DIR/$tfile failed"
868 cd $DIR/$tfile || error "cd $DIR/$tfile failed"
869 mkdir -p $tdir/bar1 || error "mkdir $tdir/bar1 failed"
870 mkdir $tfile || error "mkdir $tfile failed"
871 cd $tfile || error "cd $tfile failed"
872 ln -s .. dotdot || error "ln dotdot failed"
873 ln -s dotdot/$tdir $tdir || error "ln $tdir failed"
874 cd ../.. || error "cd ../.. failed"
875 output=`ls $tfile/$tfile/$tdir/bar1`
876 [ "$output" = bar1 ] && error "unexpected output"
877 rm -r $tfile || error "rm $tfile failed"
878 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
880 run_test 26f "rm -r of a directory which has recursive symlink ="
883 echo '== stripe sanity =============================================='
884 mkdir -p $DIR/d27 || error "mkdir failed"
885 $SETSTRIPE $DIR/d27/f0 65536 0 1 || error "lstripe failed"
886 $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
888 log "== test_27b: write to one stripe file ========================="
889 cp /etc/hosts $DIR/d27/f0 || error
891 run_test 27a "one stripe file =================================="
894 [ "$OSTCOUNT" -lt "2" ] && echo "skipping 2-stripe test" && return
896 $SETSTRIPE $DIR/d27/f01 65536 0 2 || error "lstripe failed"
897 [ `$GETSTRIPE $DIR/d27/f01 | grep -A 10 obdidx | wc -l` -eq 4 ] ||
898 error "two-stripe file doesn't have two stripes"
900 log "== test_27d: write to two stripe file file f01 ================"
901 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
903 run_test 27c "create two stripe file f01 ======================="
907 $SETSTRIPE $DIR/d27/fdef 0 -1 0 || error "lstripe failed"
908 $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
909 dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
911 run_test 27d "create file with default settings ================"
915 $SETSTRIPE $DIR/d27/f12 65536 0 2 || error "lstripe failed"
916 $SETSTRIPE $DIR/d27/f12 65536 0 2 && error "lstripe succeeded twice"
917 $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
919 run_test 27e "lstripe existing file (should return error) ======"
923 $SETSTRIPE $DIR/d27/fbad 100 0 1 && error "lstripe failed"
924 dd if=/dev/zero of=$DIR/d27/f12 bs=4k count=4 || error "dd failed"
925 $GETSTRIPE $DIR/d27/fbad || error "lfs getstripe failed"
927 run_test 27f "lstripe with bad stripe size (should return error)"
931 $MCREATE $DIR/d27/fnone || error "mcreate failed"
933 log "== test 27h: lfs getstripe with no objects ===================="
934 $GETSTRIPE $DIR/d27/fnone 2>&1 | grep "no stripe info" || error "has object"
936 log "== test 27i: lfs getstripe with some objects =================="
937 touch $DIR/d27/fsome || error "touch failed"
938 $GETSTRIPE $DIR/d27/fsome | grep obdidx || error "missing objects"
940 run_test 27g "test lfs getstripe ==========================================="
944 $SETSTRIPE $DIR/d27/f27j 65536 $OSTCOUNT 1 && error "lstripe failed"||true
946 run_test 27j "lstripe with bad stripe offset (should return error)"
948 test_27k() { # bug 2844
951 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
952 [ ! -d $DIR/d27 ] && mkdir -p $DIR/d27
953 $SETSTRIPE $FILE 67108864 -1 0 || error "lstripe failed"
954 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
955 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
956 dd if=/dev/zero of=$FILE bs=4k count=1
957 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
958 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
960 run_test 27k "limit i_blksize for broken user apps ============="
964 mcreate $DIR/f27l || error "creating file"
965 $RUNAS $SETSTRIPE $DIR/f27l 65536 -1 1 && \
966 error "lstripe should have failed" || true
968 run_test 27l "check setstripe permissions (should return error)"
971 [ "$OSTCOUNT" -lt "2" ] && echo "skipping out-of-space test on OST0" && return
972 if [ $ORIGFREE -gt $MAXFREE ]; then
973 echo "skipping out-of-space test on OST0"
977 $SETSTRIPE $DIR/d27/f27m_1 0 0 1
978 dd if=/dev/zero of=$DIR/d27/f27m_1 bs=1024 count=$MAXFREE && \
979 error "dd should fill OST0"
981 while $SETSTRIPE $DIR/d27/f27m_$i 0 0 1 ; do
983 [ $i -gt 256 ] && break
986 touch $DIR/d27/f27m_$i
987 [ `$GETSTRIPE $DIR/d27/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] && \
988 error "OST0 was full but new created file still use it"
990 touch $DIR/d27/f27m_$i
991 [ `$GETSTRIPE $DIR/d27/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] && \
992 error "OST0 was full but new created file still use it"
995 run_test 27m "create file while OST0 was full =================="
997 # osc's keep a NOSPC stick flag that gets unset with rmdir
999 [ "$1" ] && FAIL_LOC=$1 || FAIL_LOC=0
1000 mkdir -p $DIR/d27/nospc
1001 rmdir $DIR/d27/nospc
1002 sysctl -w lustre.fail_loc=$FAIL_LOC
1005 exhaust_precreations() {
1007 OST=$(grep ${OSTIDX}": " $LPROC/lov/${LOVNAME}/target_obd | \
1008 awk '{print $2}' | sed -e 's/_UUID$//')
1010 last_id=$(cat $LPROC/osc/${OST}-osc/prealloc_last_id)
1011 next_id=$(cat $LPROC/osc/${OST}-osc/prealloc_next_id)
1013 mkdir -p $DIR/d27/${OST}
1014 $SETSTRIPE $DIR/d27/${OST} 0 $OSTIDX 1
1015 #define OBD_FAIL_OST_ENOSPC 0x215
1016 sysctl -w lustre.fail_loc=0x215
1017 echo "Creating to objid $last_id on ost $OST..."
1018 createmany -o $DIR/d27/${OST}/f $next_id $((last_id - next_id + 2))
1019 grep '[0-9]' $LPROC/osc/${OST}-osc/prealloc*
1023 exhaust_all_precreations() {
1025 for (( i=0; i < OSTCOUNT; i++ )) ; do
1026 exhaust_precreations $i 0x215
1032 [ "$OSTCOUNT" -lt "2" -o -z "$MDS" ] && \
1033 echo "skip $TESTNAME for remote MDS or OST count" && return
1037 exhaust_precreations 0 0x80000215
1039 touch $DIR/d27/f27n || error
1043 run_test 27n "create file with some full OSTs =================="
1046 [ "$OSTCOUNT" -lt "2" -o -z "$MDS" ] && echo "skipping $TESTNAME" && return
1050 exhaust_all_precreations 0x215
1053 touch $DIR/d27/f27o && error "able to create $DIR/d27/f27o"
1057 run_test 27o "create file with all full OSTs (should error) ===="
1060 [ "$OSTCOUNT" -lt "2" -o -z "$MDS" ] && echo "skipping $TESTNAME" && return
1065 $MCREATE $DIR/d27/f27p || error
1066 $TRUNCATE $DIR/d27/f27p 80000000 || error
1067 $CHECKSTAT -s 80000000 $DIR/d27/f27p || error
1069 exhaust_precreations 0 0x80000215
1070 echo foo >> $DIR/d27/f27p || error
1071 $CHECKSTAT -s 80000004 $DIR/d27/f27p || error
1075 run_test 27p "append to a truncated file with some full OSTs ==="
1078 [ "$OSTCOUNT" -lt "2" -o -z "$MDS" ] && echo "skipping $TESTNAME" && return
1083 $MCREATE $DIR/d27/f27q || error "mcreate $DIR/d27/f27q failed"
1084 $TRUNCATE $DIR/d27/f27q 80000000 ||error "truncate $DIR/d27/f27q failed"
1085 $CHECKSTAT -s 80000000 $DIR/d27/f27q || error "checkstat failed"
1087 exhaust_all_precreations 0x215
1089 echo foo >> $DIR/d27/f27q && error "append succeeded"
1090 $CHECKSTAT -s 80000000 $DIR/d27/f27q || error "checkstat 2 failed"
1094 run_test 27q "append to truncated file with all OSTs full (should error) ==="
1097 [ "$OSTCOUNT" -lt "2" -o -z "$MDS" ] && echo "skipping $TESTNAME" && return
1101 exhaust_precreations 0 0x80000215
1103 $SETSTRIPE $DIR/d27/f27r 0 0 2 # && error
1107 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1109 test_27s() { # bug 10725
1111 $LSTRIPE $DIR/$tdir $((2048 * 1024 * 1024)) -1 2 && \
1112 error "stripe width >= 2^32 succeeded" || true
1114 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1116 test_27t() { # bug 10864
1121 $WLFS getstripe $tfile
1124 run_test 27t "check that utils parse path correctly"
1126 test_27x() { # bug 10997
1127 mkdir -p $DIR/d27w || error "mkdir failed"
1128 $LSTRIPE $DIR/d27w/f0 -s 65536 || error "lstripe failed"
1129 size=`$LSTRIPEINFO $DIR/d27w/f0 | awk {'print $1'}`
1130 [ $size -ne 65536 ] && error "stripe size $size != 65536" || true
1132 [ "$OSTCOUNT" -lt "2" ] && echo "skipping multiple stripe count/offset test" && return
1133 for i in `seq 1 $OSTCOUNT`; do
1135 $LSTRIPE $DIR/d27w/f$i -c $i -i $offset || error "lstripe -c $i -i $offset failed"
1136 count=`$LSTRIPEINFO $DIR/d27w/f$i | awk {'print $2'}`
1137 index=`$LSTRIPEINFO $DIR/d27w/f$i | awk {'print $3'}`
1138 [ $count -ne $i ] && error "stripe count $count != $i" || true
1139 [ $index -ne $offset ] && error "stripe offset $index != $offset" || true
1142 run_test 27x "check lfs setstripe -c -s -i options ============="
1146 $CREATETEST $DIR/d28/ct || error
1148 run_test 28 "create/mknod/mkdir with bad file types ============"
1151 cancel_lru_locks mdc
1156 MDCDIR=${MDCDIR:-`find $LPROC/ldlm/namespaces | grep mdc | head -1`}
1157 LOCKCOUNTORIG=`cat $MDCDIR/lock_count`
1158 LOCKUNUSEDCOUNTORIG=`cat $MDCDIR/lock_unused_count`
1159 [ -z $"LOCKCOUNTORIG" ] && echo "No mdc lock count" && return 1
1163 LOCKCOUNTCURRENT=`cat $MDCDIR/lock_count`
1164 LOCKUNUSEDCOUNTCURRENT=`cat $MDCDIR/lock_unused_count`
1165 if [ "$LOCKCOUNTCURRENT" -gt "$LOCKCOUNTORIG" ]; then
1166 echo > $LPROC/ldlm/dump_namespaces
1167 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
1168 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1169 log "dumped log to $TMP/test_29.dk (bug 5793)"
1172 if [ "$LOCKUNUSEDCOUNTCURRENT" -gt "$LOCKUNUSEDCOUNTORIG" ]; then
1173 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
1174 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1175 log "dumped log to $TMP/test_29.dk (bug 5793)"
1179 run_test 29 "IT_GETATTR regression ============================"
1186 run_test 30 "run binary from Lustre (execve) ==================="
1189 $OPENUNLINK $DIR/f31 $DIR/f31 || error
1190 $CHECKSTAT -a $DIR/f31 || error
1192 run_test 31a "open-unlink file =================================="
1195 touch $DIR/f31 || error
1196 ln $DIR/f31 $DIR/f31b || error
1197 multiop $DIR/f31b Ouc || error
1198 $CHECKSTAT -t file $DIR/f31 || error
1200 run_test 31b "unlink file with multiple links while open ======="
1203 touch $DIR/f31 || error
1204 ln $DIR/f31 $DIR/f31c || error
1205 multiop $DIR/f31 O_uc &
1207 multiop $DIR/f31c Ouc
1209 kill -USR1 $MULTIPID
1212 run_test 31c "open-unlink file with multiple links ============="
1215 opendirunlink $DIR/d31d $DIR/d31d || error
1216 $CHECKSTAT -a $DIR/d31d || error
1218 run_test 31d "remove of open directory ========================="
1220 test_31e() { # bug 2904
1221 check_kernel_version 34 || return 0
1222 openfilleddirunlink $DIR/d31e || error
1224 run_test 31e "remove of open non-empty directory ==============="
1226 test_31f() { # bug 4554
1229 lfs setstripe $DIR/d31f 1048576 -1 1
1230 cp /etc/hosts $DIR/d31f
1232 lfs getstripe $DIR/d31f/hosts
1233 multiop $DIR/d31f D_c &
1238 rm -rv $DIR/d31f || error "first of $DIR/d31f"
1240 lfs setstripe $DIR/d31f 1048576 -1 1
1241 cp /etc/hosts $DIR/d31f
1243 lfs getstripe $DIR/d31f/hosts
1244 multiop $DIR/d31f D_c &
1249 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
1250 wait $MULTIPID || error "first opendir $MULTIPID failed"
1254 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
1255 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
1258 run_test 31f "remove of open directory with open-unlink file ==="
1261 echo "== more mountpoints and symlinks ================="
1262 [ -e $DIR/d32a ] && rm -fr $DIR/d32a
1263 mkdir -p $DIR/d32a/ext2-mountpoint
1264 mount -t ext2 -o loop $EXT2_DEV $DIR/d32a/ext2-mountpoint || error
1265 $CHECKSTAT -t dir $DIR/d32a/ext2-mountpoint/.. || error
1266 $UMOUNT $DIR/d32a/ext2-mountpoint || error
1268 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
1271 [ -e $DIR/d32b ] && rm -fr $DIR/d32b
1272 mkdir -p $DIR/d32b/ext2-mountpoint
1273 mount -t ext2 -o loop $EXT2_DEV $DIR/d32b/ext2-mountpoint || error
1274 ls -al $DIR/d32b/ext2-mountpoint/.. || error
1275 $UMOUNT $DIR/d32b/ext2-mountpoint || error
1277 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
1280 [ -e $DIR/d32c ] && rm -fr $DIR/d32c
1281 mkdir -p $DIR/d32c/ext2-mountpoint
1282 mount -t ext2 -o loop $EXT2_DEV $DIR/d32c/ext2-mountpoint || error
1283 mkdir -p $DIR/d32c/d2/test_dir
1284 $CHECKSTAT -t dir $DIR/d32c/ext2-mountpoint/../d2/test_dir || error
1285 $UMOUNT $DIR/d32c/ext2-mountpoint || error
1287 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
1290 [ -e $DIR/d32d ] && rm -fr $DIR/d32d
1291 mkdir -p $DIR/d32d/ext2-mountpoint
1292 mount -t ext2 -o loop $EXT2_DEV $DIR/d32d/ext2-mountpoint || error
1293 mkdir -p $DIR/d32d/d2/test_dir
1294 ls -al $DIR/d32d/ext2-mountpoint/../d2/test_dir || error
1295 $UMOUNT $DIR/d32d/ext2-mountpoint || error
1297 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
1300 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
1301 mkdir -p $DIR/d32e/tmp
1302 TMP_DIR=$DIR/d32e/tmp
1303 ln -s $DIR/d32e $TMP_DIR/symlink11
1304 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1305 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
1306 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
1308 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
1311 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
1312 mkdir -p $DIR/d32f/tmp
1313 TMP_DIR=$DIR/d32f/tmp
1314 ln -s $DIR/d32f $TMP_DIR/symlink11
1315 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1316 ls $DIR/d32f/tmp/symlink11 || error
1317 ls $DIR/d32f/symlink01 || error
1319 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
1322 TMP_DIR=$DIR/$tdir/tmp
1323 mkdir -p $TMP_DIR $DIR/${tdir}2
1324 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
1325 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1326 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
1327 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
1328 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
1329 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
1331 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
1334 rm -fr $DIR/$tdir $DIR/${tdir}2
1335 TMP_DIR=$DIR/$tdir/tmp
1336 mkdir -p $TMP_DIR $DIR/${tdir}2
1337 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
1338 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1339 ls $TMP_DIR/symlink12 || error
1340 ls $DIR/$tdir/symlink02 || error
1342 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
1345 [ -e $DIR/d32i ] && rm -fr $DIR/d32i
1346 mkdir -p $DIR/d32i/ext2-mountpoint
1347 mount -t ext2 -o loop $EXT2_DEV $DIR/d32i/ext2-mountpoint || error
1348 touch $DIR/d32i/test_file
1349 $CHECKSTAT -t file $DIR/d32i/ext2-mountpoint/../test_file || error
1350 $UMOUNT $DIR/d32i/ext2-mountpoint || error
1352 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
1355 [ -e $DIR/d32j ] && rm -fr $DIR/d32j
1356 mkdir -p $DIR/d32j/ext2-mountpoint
1357 mount -t ext2 -o loop $EXT2_DEV $DIR/d32j/ext2-mountpoint || error
1358 touch $DIR/d32j/test_file
1359 cat $DIR/d32j/ext2-mountpoint/../test_file || error
1360 $UMOUNT $DIR/d32j/ext2-mountpoint || error
1362 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
1366 mkdir -p $DIR/d32k/ext2-mountpoint
1367 mount -t ext2 -o loop $EXT2_DEV $DIR/d32k/ext2-mountpoint
1368 mkdir -p $DIR/d32k/d2
1369 touch $DIR/d32k/d2/test_file || error
1370 $CHECKSTAT -t file $DIR/d32k/ext2-mountpoint/../d2/test_file || error
1371 $UMOUNT $DIR/d32k/ext2-mountpoint || error
1373 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
1377 mkdir -p $DIR/d32l/ext2-mountpoint
1378 mount -t ext2 -o loop $EXT2_DEV $DIR/d32l/ext2-mountpoint || error
1379 mkdir -p $DIR/d32l/d2
1380 touch $DIR/d32l/d2/test_file
1381 cat $DIR/d32l/ext2-mountpoint/../d2/test_file || error
1382 $UMOUNT $DIR/d32l/ext2-mountpoint || error
1384 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
1388 mkdir -p $DIR/d32m/tmp
1389 TMP_DIR=$DIR/d32m/tmp
1390 ln -s $DIR $TMP_DIR/symlink11
1391 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1392 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
1393 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
1395 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
1399 mkdir -p $DIR/d32n/tmp
1400 TMP_DIR=$DIR/d32n/tmp
1401 ln -s $DIR $TMP_DIR/symlink11
1402 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1403 ls -l $DIR/d32n/tmp/symlink11 || error
1404 ls -l $DIR/d32n/symlink01 || error
1406 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
1409 rm -fr $DIR/d32o $DIR/$tfile
1411 mkdir -p $DIR/d32o/tmp
1412 TMP_DIR=$DIR/d32o/tmp
1413 ln -s $DIR/$tfile $TMP_DIR/symlink12
1414 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1415 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
1416 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
1417 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
1418 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
1420 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
1430 mkdir -p $DIR/d32p/tmp
1432 TMP_DIR=$DIR/d32p/tmp
1434 ln -s $DIR/$tfile $TMP_DIR/symlink12
1436 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1438 cat $DIR/d32p/tmp/symlink12 || error
1440 cat $DIR/d32p/symlink02 || error
1443 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
1446 [ -e $DIR/d32q ] && rm -fr $DIR/d32q
1448 touch $DIR/d32q/under_the_mount
1449 mount -t ext2 -o loop $EXT2_DEV $DIR/d32q
1450 ls $DIR/d32q/under_the_mount && error || true
1451 $UMOUNT $DIR/d32q || error
1453 run_test 32q "stat follows mountpoints in Lustre (should return error)"
1456 [ -e $DIR/d32r ] && rm -fr $DIR/d32r
1458 touch $DIR/d32r/under_the_mount
1459 mount -t ext2 -o loop $EXT2_DEV $DIR/d32r
1460 ls $DIR/d32r | grep -q under_the_mount && error || true
1461 $UMOUNT $DIR/d32r || error
1463 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
1468 chmod 444 $DIR/$tfile
1469 chown $RUNAS_ID $DIR/$tfile
1471 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
1474 run_test 33 "write file with mode 444 (should return error) ===="
1479 chown $RUNAS_ID $DIR/d33
1480 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
1481 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
1482 error "open RDWR" || true
1484 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
1486 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
1489 $MCREATE $DIR/f34 || error
1490 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
1491 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
1492 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
1493 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1495 run_test 34a "truncate file that has not been opened ==========="
1498 [ ! -f $DIR/f34 ] && test_34a
1499 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1500 $OPENFILE -f O_RDONLY $DIR/f34
1501 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
1502 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1504 run_test 34b "O_RDONLY opening file doesn't create objects ====="
1507 [ ! -f $DIR/f34 ] && test_34a
1508 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1509 $OPENFILE -f O_RDWR $DIR/f34
1510 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
1511 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1513 run_test 34c "O_RDWR opening file-with-size works =============="
1516 [ ! -f $DIR/f34 ] && test_34a
1517 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
1518 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1521 run_test 34d "write to sparse file ============================="
1525 $MCREATE $DIR/f34e || error
1526 $TRUNCATE $DIR/f34e 1000 || error
1527 $CHECKSTAT -s 1000 $DIR/f34e || error
1528 $OPENFILE -f O_RDWR $DIR/f34e
1529 $CHECKSTAT -s 1000 $DIR/f34e || error
1531 run_test 34e "create objects, some with size and some without =="
1533 test_34f() { # bug 6242, 6243
1536 $MCREATE $DIR/f34f || error
1537 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
1538 dd if=$DIR/f34f of=$TMP/f34f
1539 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
1540 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
1541 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
1542 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
1543 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
1545 run_test 34f "read from a file with no objects until EOF ======="
1548 cp /bin/sh $DIR/f35a
1550 chown $RUNAS_ID $DIR/f35a
1551 $RUNAS $DIR/f35a && error || true
1554 run_test 35a "exec file with mode 444 (should return and not leak) ====="
1558 utime $DIR/f36 || error
1560 run_test 36a "MDS utime check (mknod, utime) ==================="
1564 utime $DIR/f36 || error
1566 run_test 36b "OST utime check (open, utime) ===================="
1571 chown $RUNAS_ID $DIR/d36
1572 $RUNAS utime $DIR/d36/f36 || error
1574 run_test 36c "non-root MDS utime check (mknod, utime) =========="
1577 [ ! -d $DIR/d36 ] && test_36c
1578 echo "" > $DIR/d36/f36
1579 $RUNAS utime $DIR/d36/f36 || error
1581 run_test 36d "non-root OST utime check (open, utime) ==========="
1584 [ $RUNAS_ID -eq $UID ] && echo "skipping $TESTNAME" && return
1586 touch $DIR/$tdir/$tfile
1587 $RUNAS utime $DIR/$tdir/$tfile && \
1588 error "utime worked, expected failure" || true
1590 run_test 36e "utime on non-owned file (should return error) ===="
1593 export LANG=C LC_LANG=C # for date language
1595 DATESTR="Dec 20 2000"
1597 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
1598 sysctl -w lustre.fail_loc=0x80000214
1600 cp /etc/hosts $DIR/$tdir/$tfile
1601 sync & # write RPC generated with "current" inode timestamp, but delayed
1603 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
1604 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
1605 cancel_lru_locks osc
1606 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
1608 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
1609 echo "BEFORE: $LS_BEFORE" && \
1610 echo "AFTER : $LS_AFTER" && \
1611 echo "WANT : $DATESTR" && \
1612 error "$DIR/$tdir/$tfile timestamps changed" || true
1614 run_test 36f "utime on file racing with OST BRW write =========="
1616 export FMD_MAX_AGE=`cat $LPROC/obdfilter/*/client_cache_seconds 2> /dev/null | head -n 1`
1618 [ -z "$FMD_MAX_AGE" ] && echo "skip $TESTNAME for remote OST" && return
1619 FMD_BEFORE="`awk '/ll_fmd_cache/ { print $2 }' /proc/slabinfo`"
1620 touch $DIR/d36/$tfile
1621 sleep $((FMD_MAX_AGE + 12))
1622 FMD_AFTER="`awk '/ll_fmd_cache/ { print $2 }' /proc/slabinfo`"
1623 [ "$FMD_AFTER" -gt "$FMD_BEFORE" ] && \
1624 echo "AFTER : $FMD_AFTER > BEFORE $FMD_BEFORE" && \
1625 error "fmd didn't expire after ping" || true
1627 run_test 36g "filter mod data cache expiry ====================="
1631 echo f > $DIR/$tdir/fbugfile
1632 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
1633 ls $DIR/$tdir | grep "\<fbugfile\>" && error
1634 $UMOUNT $DIR/$tdir || error
1635 rm -f $DIR/$tdir/fbugfile || error
1637 run_test 37 "ls a mounted file system to check old content ====="
1640 o_directory $DIR/$tfile
1642 run_test 38 "open a regular file with O_DIRECTORY =============="
1646 touch $DIR/${tfile}2
1647 # ls -l $DIR/$tfile $DIR/${tfile}2
1648 # ls -lu $DIR/$tfile $DIR/${tfile}2
1649 # ls -lc $DIR/$tfile $DIR/${tfile}2
1651 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
1652 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
1654 ls -l $DIR/$tfile $DIR/${tfile}2
1656 ls -lu $DIR/$tfile $DIR/${tfile}2
1658 ls -lc $DIR/$tfile $DIR/${tfile}2
1659 error "O_TRUNC didn't change timestamps"
1662 run_test 39 "mtime changed on create ==========================="
1665 dd if=/dev/zero of=$DIR/f40 bs=4096 count=1
1666 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/f40 && error
1667 $CHECKSTAT -t file -s 4096 $DIR/f40 || error
1669 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
1673 small_write $DIR/f41 18
1675 run_test 41 "test small file write + fstat ====================="
1677 count_ost_writes() {
1678 cat $LPROC/osc/*/stats |
1679 awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }'
1686 BG_DIRTY_RATIO_SAVE=10
1687 MAX_BG_DIRTY_RATIO=25
1691 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
1692 # dirty_ratio, dirty_background_ratio
1693 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
1694 echo $WRITEBACK_SAVE > /proc/sys/vm/dirty_writeback_centisecs
1695 echo $BG_DIRTY_RATIO_SAVE > /proc/sys/vm/dirty_background_ratio
1696 echo $DIRTY_RATIO_SAVE > /proc/sys/vm/dirty_ratio
1698 # if file not here, we are a 2.4 kernel
1699 kill -CONT `pidof kupdated`
1704 # setup the trap first, so someone cannot exit the test at the
1705 # exact wrong time and mess up a machine
1706 trap start_writeback EXIT
1707 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
1708 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
1709 WRITEBACK_SAVE=`cat /proc/sys/vm/dirty_writeback_centisecs`
1710 echo 0 > /proc/sys/vm/dirty_writeback_centisecs
1711 # save and increase /proc/sys/vm/dirty_ratio
1712 DIRTY_RATIO_SAVE=`cat /proc/sys/vm/dirty_ratio`
1713 echo $MAX_DIRTY_RATIO > /proc/sys/vm/dirty_ratio
1714 # save and increase /proc/sys/vm/dirty_background_ratio
1715 BG_DIRTY_RATIO_SAVE=`cat /proc/sys/vm/dirty_background_ratio`
1716 echo $MAX_BG_DIRTY_RATIO > /proc/sys/vm/dirty_background_ratio
1718 # if file not here, we are a 2.4 kernel
1719 kill -STOP `pidof kupdated`
1723 # ensure that all stripes have some grant before we test client-side cache
1725 [ "$SETUP_TEST42" ] && return
1726 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
1727 dd if=/dev/zero of=$i bs=4k count=1
1733 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
1734 # file truncation, and file removal.
1737 cancel_lru_locks osc
1739 sync; sleep 1; sync # just to be safe
1740 BEFOREWRITES=`count_ost_writes`
1741 grep "[0-9]" $LPROC/osc/*[oO][sS][cC][_-]*/cur_grant_bytes
1742 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
1743 AFTERWRITES=`count_ost_writes`
1744 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
1745 error "$BEFOREWRITES < $AFTERWRITES"
1748 run_test 42a "ensure that we don't flush on close =============="
1752 cancel_lru_locks osc
1755 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
1756 BEFOREWRITES=`count_ost_writes`
1757 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
1758 AFTERWRITES=`count_ost_writes`
1759 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
1760 error "$BEFOREWRITES < $AFTERWRITES on unlink"
1762 BEFOREWRITES=`count_ost_writes`
1763 sync || error "sync: $?"
1764 AFTERWRITES=`count_ost_writes`
1765 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
1766 error "$BEFOREWRITES < $AFTERWRITES on sync"
1768 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
1772 run_test 42b "test destroy of file with cached dirty data ======"
1774 # if these tests just want to test the effect of truncation,
1775 # they have to be very careful. consider:
1776 # - the first open gets a {0,EOF}PR lock
1777 # - the first write conflicts and gets a {0, count-1}PW
1778 # - the rest of the writes are under {count,EOF}PW
1779 # - the open for truncate tries to match a {0,EOF}PR
1780 # for the filesize and cancels the PWs.
1781 # any number of fixes (don't get {0,EOF} on open, match
1782 # composite locks, do smarter file size management) fix
1783 # this, but for now we want these tests to verify that
1784 # the cancellation with truncate intent works, so we
1785 # start the file with a full-file pw lock to match against
1786 # until the truncate.
1791 cancel_lru_locks osc
1793 # prime the file with 0,EOF PW to match
1797 # now the real test..
1798 dd if=/dev/zero of=$file bs=1024 count=100
1799 BEFOREWRITES=`count_ost_writes`
1800 $TRUNCATE $file $offset
1801 cancel_lru_locks osc
1802 AFTERWRITES=`count_ost_writes`
1808 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
1809 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
1812 run_test 42c "test partial truncate of file with cached dirty data"
1816 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
1817 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
1820 run_test 42d "test complete truncate of file with cached dirty data"
1824 cp -p /bin/ls $DIR/$tdir/$tfile
1825 exec 100>> $DIR/$tdir/$tfile
1826 $DIR/$tdir/$tfile && error || true
1829 run_test 43 "execution of file opened for write should return -ETXTBSY"
1833 cp -p `which multiop` $DIR/d43/multiop
1834 $DIR/d43/multiop $TMP/test43.junk O_c &
1837 multiop $DIR/d43/multiop Oc && error "expected error, got success"
1838 kill -USR1 $MULTIPID || return 2
1839 wait $MULTIPID || return 3
1842 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
1846 cp -p `which multiop` $DIR/d43/multiop
1847 $DIR/d43/multiop $TMP/test43.junk O_c &
1850 truncate $DIR/d43/multiop 0 && error "expected error, got success"
1851 kill -USR1 $MULTIPID || return 2
1852 wait $MULTIPID || return 3
1855 run_test 43b "truncate of file being executed should return -ETXTBSY"
1858 local testdir="$DIR/d43c"
1861 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
1862 ( cd $testdir && md5sum -c)
1864 run_test 43c "md5sum of copy into lustre========================"
1867 [ "$OSTCOUNT" -lt "2" ] && echo "skipping 2-stripe test" && return
1868 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
1869 dd if=$DIR/f1 of=/dev/null bs=4k count=1
1871 run_test 44 "zero length read from a sparse stripe ============="
1874 local nstripe=`$LCTL lov_getconfig $DIR | grep default_stripe_count: | \
1876 local stride=`$LCTL lov_getconfig $DIR | grep default_stripe_size: | \
1878 if [ $nstripe -eq 0 ] ; then
1879 nstripe=`$LCTL lov_getconfig $DIR | grep obd_count: | awk '{print $2}'`
1881 [ -z "$nstripe" ] && error "can't get stripe info"
1883 OFFSETS="0 $((stride/2)) $((stride-1))"
1884 for offset in $OFFSETS ; do
1885 for i in `seq 0 $((nstripe-1))`; do
1887 local GLOBALOFFSETS=""
1888 local size=$((((i + 2 * $nstripe )*$stride + $offset))) # Bytes
1889 ll_sparseness_write $DIR/d44a $size || error "ll_sparseness_write"
1890 GLOBALOFFSETS="$GLOBALOFFSETS $size"
1891 ll_sparseness_verify $DIR/d44a $GLOBALOFFSETS \
1892 || error "ll_sparseness_verify $GLOBALOFFSETS"
1894 for j in `seq 0 $((nstripe-1))`; do
1895 size=$((((j + $nstripe )*$stride + $offset))) # Bytes
1896 ll_sparseness_write $DIR/d44a $size || error "ll_sparseness_write"
1897 GLOBALOFFSETS="$GLOBALOFFSETS $size"
1899 ll_sparseness_verify $DIR/d44a $GLOBALOFFSETS \
1900 || error "ll_sparseness_verify $GLOBALOFFSETS"
1904 run_test 44a "test sparse pwrite ==============================="
1908 for d in $LPROC/osc/*/cur_dirty_bytes; do
1909 tot=$(($tot + `cat $d`))
1914 before=`dirty_osc_total`
1915 echo executing "\"$*\""
1917 after=`dirty_osc_total`
1918 echo before $before, after $after
1922 # Obtain grants from OST if it supports it
1923 echo blah > ${f}_grant
1926 do_dirty_record "echo blah > $f"
1927 [ $before -eq $after ] && error "write wasn't cached"
1928 do_dirty_record "> $f"
1929 [ $before -gt $after ] || error "truncate didn't lower dirty count"
1930 do_dirty_record "echo blah > $f"
1931 [ $before -eq $after ] && error "write wasn't cached"
1932 do_dirty_record "sync"
1933 [ $before -gt $after ] || error "writeback didn't lower dirty count"
1934 do_dirty_record "echo blah > $f"
1935 [ $before -eq $after ] && error "write wasn't cached"
1936 do_dirty_record "cancel_lru_locks osc"
1937 [ $before -gt $after ] || error "lock cancellation didn't lower dirty count"
1940 run_test 45 "osc io page accounting ============================"
1946 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
1947 # test tickles a bug where re-dirtying a page was failing to be mapped to the
1948 # objects offset and an assert hit when an rpc was built with 1023's mapped
1949 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
1954 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
1956 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
1957 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
1961 run_test 46 "dirtying a previously written page ================"
1963 # Check that device nodes are created and then visible correctly (#2091)
1965 cmknod $DIR/test_47_node || error
1967 run_test 47 "Device nodes check ================================"
1969 test_48a() { # bug 2399
1970 check_kernel_version 34 || return 0
1973 mv $DIR/d48a $DIR/d48.new || error "move directory failed"
1974 mkdir $DIR/d48a || error "recreate directory failed"
1975 touch foo || error "'touch foo' failed after recreating cwd"
1976 mkdir bar || error "'mkdir foo' failed after recreating cwd"
1977 if check_kernel_version 44; then
1978 touch .foo || error "'touch .foo' failed after recreating cwd"
1979 mkdir .bar || error "'mkdir .foo' failed after recreating cwd"
1981 ls . || error "'ls .' failed after recreating cwd"
1982 ls .. || error "'ls ..' failed after removing cwd"
1983 cd . || error "'cd .' failed after recreating cwd"
1984 mkdir . && error "'mkdir .' worked after recreating cwd"
1985 rmdir . && error "'rmdir .' worked after recreating cwd"
1986 ln -s . baz || error "'ln -s .' failed after recreating cwd"
1987 cd .. || error "'cd ..' failed after recreating cwd"
1989 run_test 48a "Access renamed working dir (should return errors)="
1991 test_48b() { # bug 2399
1992 check_kernel_version 34 || return 0
1995 rmdir $DIR/d48b || error "remove cwd $DIR/d48b failed"
1996 touch foo && error "'touch foo' worked after removing cwd"
1997 mkdir foo && error "'mkdir foo' worked after removing cwd"
1998 if check_kernel_version 44; then
1999 touch .foo && error "'touch .foo' worked after removing cwd"
2000 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
2002 ls . && error "'ls .' worked after removing cwd"
2003 ls .. || error "'ls ..' failed after removing cwd"
2004 cd . && error "'cd .' worked after removing cwd"
2005 mkdir . && error "'mkdir .' worked after removing cwd"
2006 rmdir . && error "'rmdir .' worked after removing cwd"
2007 ln -s . foo && error "'ln -s .' worked after removing cwd"
2008 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
2010 run_test 48b "Access removed working dir (should return errors)="
2012 test_48c() { # bug 2350
2013 check_kernel_version 36 || return 0
2014 #sysctl -w lnet.debug=-1
2016 mkdir -p $DIR/d48c/dir
2018 $TRACE rmdir $DIR/d48c/dir || error "remove cwd $DIR/d48c/dir failed"
2019 $TRACE touch foo && error "'touch foo' worked after removing cwd"
2020 $TRACE mkdir foo && error "'mkdir foo' worked after removing cwd"
2021 if check_kernel_version 44; then
2022 touch .foo && error "'touch .foo' worked after removing cwd"
2023 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
2025 $TRACE ls . && error "'ls .' worked after removing cwd"
2026 $TRACE ls .. || error "'ls ..' failed after removing cwd"
2027 $TRACE cd . && error "'cd .' worked after removing cwd"
2028 $TRACE mkdir . && error "'mkdir .' worked after removing cwd"
2029 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
2030 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
2031 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
2033 run_test 48c "Access removed working subdir (should return errors)"
2035 test_48d() { # bug 2350
2036 check_kernel_version 36 || return 0
2037 #sysctl -w lnet.debug=-1
2039 mkdir -p $DIR/d48d/dir
2041 $TRACE rmdir $DIR/d48d/dir || error "remove cwd $DIR/d48d/dir failed"
2042 $TRACE rmdir $DIR/d48d || error "remove parent $DIR/d48d failed"
2043 $TRACE touch foo && error "'touch foo' worked after removing parent"
2044 $TRACE mkdir foo && error "'mkdir foo' worked after removing parent"
2045 if check_kernel_version 44; then
2046 touch .foo && error "'touch .foo' worked after removing parent"
2047 mkdir .foo && error "'mkdir .foo' worked after removing parent"
2049 $TRACE ls . && error "'ls .' worked after removing parent"
2050 $TRACE ls .. && error "'ls ..' worked after removing parent"
2051 $TRACE cd . && error "'cd .' worked after recreate parent"
2052 $TRACE mkdir . && error "'mkdir .' worked after removing parent"
2053 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
2054 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
2055 $TRACE cd .. && error "'cd ..' worked after removing parent" || true
2057 run_test 48d "Access removed parent subdir (should return errors)"
2059 test_48e() { # bug 4134
2060 check_kernel_version 41 || return 0
2061 #sysctl -w lnet.debug=-1
2063 mkdir -p $DIR/d48e/dir
2065 $TRACE rmdir $DIR/d48e/dir || error "remove cwd $DIR/d48e/dir failed"
2066 $TRACE rmdir $DIR/d48e || error "remove parent $DIR/d48e failed"
2067 $TRACE touch $DIR/d48e || error "'touch $DIR/d48e' failed"
2068 $TRACE chmod +x $DIR/d48e || error "'chmod +x $DIR/d48e' failed"
2069 # On a buggy kernel addition of "touch foo" after cd .. will
2070 # produce kernel oops in lookup_hash_it
2071 touch ../foo && error "'cd ..' worked after recreate parent"
2073 $TRACE rm $DIR/d48e || error "rm '$DIR/d48e' failed"
2075 run_test 48e "Access to recreated parent subdir (should return errors)"
2081 ls /proc/$$/cwd || error
2083 run_test 50 "special situations: /proc symlinks ==============="
2086 # bug 1516 - create an empty entry right after ".." then split dir
2089 $MCREATE $DIR/d51/bar
2091 createmany -m $DIR/d51/longfile 201
2093 while [ `ls -sd $DIR/d51 | awk '{ print $1 }'` -eq 4 ]; do
2094 $MCREATE $DIR/d51/longfile$FNUM
2098 ls -l $DIR/d51 > /dev/null || error
2100 run_test 51 "special situations: split htree with empty entry =="
2102 export NUMTEST=70000
2104 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
2105 [ $NUMFREE -lt 21000 ] && \
2106 echo "skipping $TESTNAME, not enough free inodes ($NUMFREE)" && \
2109 check_kernel_version 40 || NUMTEST=31000
2110 [ $NUMFREE -lt $NUMTEST ] && NUMTEST=$(($NUMFREE - 50))
2113 createmany -d $DIR/d51b/t- $NUMTEST
2115 run_test 51b "mkdir .../t-0 --- .../t-$NUMTEST ===================="
2118 [ ! -d $DIR/d51b ] && echo "skipping $TESTNAME: $DIR/51b missing" && \
2121 unlinkmany -d $DIR/d51b/t- $NUMTEST
2123 run_test 51c "rmdir .../t-0 --- .../t-$NUMTEST ===================="
2126 [ "$OSTCOUNT" -lt "3" ] && echo "skipping test with few OSTs" && return
2128 createmany -o $DIR/d51d/t- 1000
2129 $LFS getstripe $DIR/d51d > $TMP/files
2130 for N in `seq 0 $((OSTCOUNT - 1))`; do
2131 OBJS[$N]=`awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}' $TMP/files`
2132 OBJS0[$N]=`grep -A 1 idx $TMP/files | awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}'`
2133 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
2135 unlinkmany $DIR/d51d/t- 1000
2138 for N in `seq 1 $((OSTCOUNT - 1))`; do
2139 [ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ] && \
2140 error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
2141 [ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ] && \
2142 error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
2144 [ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ] && \
2145 error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
2146 [ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ] && \
2147 error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
2151 run_test 51d "check object distribution ===================="
2154 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
2157 chattr =a $DIR/d52a/foo || error "chattr =a failed"
2158 echo bar >> $DIR/d52a/foo || error "append bar failed"
2159 cp /etc/hosts $DIR/d52a/foo && error "cp worked"
2160 rm -f $DIR/d52a/foo 2>/dev/null && error "rm worked"
2161 link $DIR/d52a/foo $DIR/d52a/foo_link 2>/dev/null && error "link worked"
2162 echo foo >> $DIR/d52a/foo || error "append foo failed"
2163 mrename $DIR/d52a/foo $DIR/d52a/foo_ren && error "rename worked"
2164 lsattr $DIR/d52a/foo | egrep -q "^-+a-+ $DIR/d52a/foo" || error "lsattr"
2165 chattr -a $DIR/d52a/foo || error "chattr -a failed"
2167 rm -fr $DIR/d52a || error "cleanup rm failed"
2169 run_test 52a "append-only flag test (should return errors) ====="
2172 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
2175 chattr =i $DIR/d52b/foo || error
2176 cat test > $DIR/d52b/foo && error
2177 cp /etc/hosts $DIR/d52b/foo && error
2178 rm -f $DIR/d52b/foo 2>/dev/null && error
2179 link $DIR/d52b/foo $DIR/d52b/foo_link 2>/dev/null && error
2180 echo foo >> $DIR/d52b/foo && error
2181 mrename $DIR/d52b/foo $DIR/d52b/foo_ren && error
2182 [ -f $DIR/d52b/foo ] || error
2183 [ -f $DIR/d52b/foo_ren ] && error
2184 lsattr $DIR/d52b/foo | egrep -q "^-+i-+ $DIR/d52b/foo" || error
2185 chattr -i $DIR/d52b/foo || error
2187 rm -fr $DIR/d52b || error
2189 run_test 52b "immutable flag test (should return errors) ======="
2191 test_52c() { # 12848 simulating client < 1.4.7
2192 [ -f $DIR/d52c/foo ] && chattr -i $DIR/d52b/foo
2195 # skip MDS_BFLAG_EXT_FLAGS in mdc_getattr_pack
2196 #define OBD_FAIL_MDC_OLD_EXT_FLAGS 0x802
2197 sysctl -w lustre.fail_loc=0x802
2198 chattr =i $DIR/d52c/foo || error
2199 lsattr $DIR/d52c/foo | egrep -q "^-+i-+ $DIR/d52c/foo" || error
2200 chattr -i $DIR/d52c/foo || error
2201 sysctl -w lustre.fail_loc=0
2203 rm -fr $DIR/d52c || error
2205 run_test 52c "immutable flag test for client < 1.4.7 ======="
2208 [ -z "$MDS" ] && echo "skipping $TESTNAME with remote MDS" && return
2210 for i in `ls -d $LPROC/osc/*-osc 2> /dev/null` ; do
2211 ostname=`basename $i | cut -d - -f 1-2`
2212 ost_last=`cat $LPROC/obdfilter/$ostname/last_id`
2213 mds_last=`cat $i/prealloc_last_id`
2214 echo "$ostname.last_id=$ost_last ; MDS.last_id=$mds_last"
2215 if [ $ost_last != $mds_last ]; then
2216 error "$ostname.last_id=$ost_last ; MDS.last_id=$mds_last"
2220 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
2223 [ ! -f "$SOCKETSERVER" ] && echo "no socketserver, skipping" && return
2224 [ ! -f "$SOCKETCLIENT" ] && echo "no socketclient, skipping" && return
2225 $SOCKETSERVER $DIR/socket
2226 $SOCKETCLIENT $DIR/socket || error
2227 $MUNLINK $DIR/socket
2229 run_test 54a "unix domain socket test =========================="
2235 dd if=/dev/zero of=$f bs=`page_size` count=1
2237 run_test 54b "char device works in lustre ======================"
2240 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
2241 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
2242 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
2244 for i in `seq 3 7`; do
2245 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
2255 loopdev="$DIR/loop54c"
2258 [ -z "$LOOPNUM" ] && echo "couldn't find empty loop device" && return
2259 mknod $loopdev b 7 $LOOPNUM
2260 echo "make a loop file system with $tfile on $loopdev ($LOOPNUM)..."
2261 dd if=/dev/zero of=$tfile bs=`page_size` seek=1024 count=1 > /dev/null
2262 losetup $loopdev $tfile || error "can't set up $loopdev for $tfile"
2263 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
2265 mount -t ext2 $loopdev $tdir || error "error mounting $loopdev on $tdir"
2266 dd if=/dev/zero of=$tdir/tmp bs=`page_size` count=30 || error "dd write"
2268 dd if=$tdir/tmp of=/dev/zero bs=`page_size` count=30 || error "dd read"
2273 run_test 54c "block device works in lustre ====================="
2279 [ "$string" = `echo $string > $f | cat $f` ] || error
2281 run_test 54d "fifo device works in lustre ======================"
2284 check_kernel_version 46 || return 0
2288 echo $string > $f || error
2290 run_test 54e "console/tty device works in lustre ======================"
2293 grep -q $FSTYPE /proc/filesystems && return 1
2295 grep -q $FSTYPE /proc/filesystems && return 1
2296 insmod ../$FSTYPE/$FSTYPE.o
2297 grep -q $FSTYPE /proc/filesystems && return 1
2298 insmod ../$FSTYPE/$FSTYPE.ko
2299 grep -q $FSTYPE /proc/filesystems && return 1
2306 check_fstype && echo "can't find fs $FSTYPE, skipping $TESTNAME" && return
2307 mount -t $FSTYPE -o loop,iopen $EXT2_DEV $DIR/d55 || error "mounting"
2309 $IOPENTEST1 $DIR/d55/foo $DIR/d55 || error "running $IOPENTEST1"
2310 $IOPENTEST2 $DIR/d55 || error "running $IOPENTEST2"
2311 echo "check for $EXT2_DEV. Please wait..."
2313 $UMOUNT $DIR/d55 || error "unmounting"
2315 run_test 55 "check iopen_connect_dentry() ======================"
2323 NUMFILESx2=$(($NUMFILES * 2))
2324 for i in `seq 1 $NUMFILES` ; do
2325 touch $DIR/d56/file$i
2326 touch $DIR/d56/dir/file$i
2329 # test lfs getstripe with --recursive
2330 FILENUM=`$GETSTRIPE --recursive $DIR/d56 | grep -c obdidx`
2331 [ $FILENUM -eq $NUMFILESx2 ] || error \
2332 "lfs getstripe --recursive $DIR/d56 wrong: found $FILENUM, expected $NUMFILESx2"
2333 FILENUM=`$GETSTRIPE $DIR/d56 | grep -c obdidx`
2334 [ $FILENUM -eq $NUMFILES ] || error \
2335 "lfs getstripe $DIR/d56 without --recursive wrong: found $FILENUM, expected $NUMFILES"
2336 echo "lfs getstripe --recursive passed."
2338 # test lfs getstripe with file instead of dir
2339 FILENUM=`$GETSTRIPE $DIR/d56/file1 | grep -c obdidx`
2340 [ $FILENUM -eq 1 ] || error \
2341 "lfs getstripe $DIR/d56/file1 wrong:found $FILENUM, expected 1"
2342 echo "lfs getstripe file passed."
2344 #test lfs getstripe with --verbose
2345 [ `$GETSTRIPE --verbose $DIR/d56 | grep -c lmm_magic` -eq $NUMFILES ] ||\
2346 error "lfs getstripe --verbose $DIR/d56 wrong: should find $NUMFILES lmm_magic info"
2347 [ `$GETSTRIPE $DIR/d56 | grep -c lmm_magic` -eq 0 ] || error \
2348 "lfs getstripe $DIR/d56 without --verbose wrong: should not show lmm_magic info"
2349 echo "lfs getstripe --verbose passed."
2351 #test lfs getstripe with --obd
2352 $GETSTRIPE --obd wrong_uuid $DIR/d56 2>&1 | grep -q "unknown obduuid" || \
2353 error "lfs getstripe --obd wrong_uuid should return error message"
2355 [ "$OSTCOUNT" -lt 2 ] && \
2356 echo "skipping other lfs getstripe --obd test" && return
2357 FILENUM=`$GETSTRIPE --recursive $DIR/d56 | sed -n '/^[ ]*1[ ]/p' | wc -l`
2358 OBDUUID=`$GETSTRIPE --recursive $DIR/d56 | sed -n '/^[ ]*1:/p' | awk '{print $2}'`
2359 FOUND=`$GETSTRIPE -r --obd $OBDUUID $DIR/d56 | wc -l`
2360 [ $FOUND -eq $FILENUM ] || \
2361 error "lfs getstripe --obd wrong: found $FOUND, expected $FILENUM"
2362 [ `$GETSTRIPE -r -v --obd $OBDUUID $DIR/d56 | sed '/^[ ]*1[ ]/d' |\
2363 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l` -eq 0 ] || \
2364 error "lfs getstripe --obd wrong: should not show file on other obd"
2365 echo "lfs getstripe --obd passed."
2367 run_test 56 "check lfs getstripe ===================================="
2374 if [ ! -d "$DIR/${tdir}g" ] ; then
2375 mkdir -p $DIR/${tdir}g
2376 for i in `seq 1 $LOCAL_NUMFILES` ; do
2377 touch $DIR/${tdir}g/file$i
2379 for i in `seq 1 $LOCAL_NUMDIRS` ; do
2380 mkdir $DIR/${tdir}g/dir$i
2381 for j in `seq 1 $LOCAL_NUMFILES` ; do
2382 touch $DIR/${tdir}g/dir$i/file$j
2391 setup_56 $NUMFILES $NUMDIRS
2393 EXPECTED=$(($NUMDIRS + 2))
2394 # test lfs find with -name
2395 for i in `seq 1 $NUMFILES` ; do
2396 NUMS=`$LFIND -name "*$i" $DIR/${tdir}g | wc -l`
2397 [ $NUMS -eq $EXPECTED ] || error \
2398 "lfs find -name \"*$i\" $DIR/${tdir}g wrong: found $NUMS, expected $EXPECTED"
2400 echo "lfs find -name passed."
2402 run_test 56g "check lfs find -name ============================="
2407 setup_56 $NUMFILES $NUMDIRS
2409 EXPECTED=$((($NUMDIRS+1)*($NUMFILES-1)+$NUMFILES))
2410 # test lfs find with ! -name
2411 for i in `seq 1 $NUMFILES` ; do
2412 NUMS=`$LFIND ! -name "*$i" $DIR/${tdir}g | wc -l`
2413 [ $NUMS -eq $EXPECTED ] || error \
2414 "lfs find ! -name \"*$i\" $DIR/${tdir}g wrong: found $NUMS, expected $EXPECTED"
2416 echo "lfs find ! -name passed."
2418 run_test 56h "check lfs find ! -name ============================="
2421 [ -z "$MDS" ] && echo "skipping $TESTNAME for remote MDS" && return
2422 for DEV in `cat $LPROC/mds/*/mntdev`; do
2423 dumpe2fs -h $DEV > $TMP/t57a.dump || error "can't access $DEV"
2424 DEVISIZE=`awk '/Inode size:/ { print $3 }' $TMP/t57a.dump`
2425 [ "$DEVISIZE" -gt 128 ] || error "inode size $DEVISIZE"
2429 run_test 57a "verify MDS filesystem created with large inodes =="
2434 FILEN=$DIR/d57b/f$FILECOUNT
2435 rm -rf $DIR/d57b || error "removing $DIR/d57b"
2436 mkdir -p $DIR/d57b || error "creating $DIR/d57b"
2437 echo "mcreating $FILECOUNT files"
2438 createmany -m $DIR/d57b/f 1 $FILECOUNT || \
2439 error "creating files in $DIR/d57b"
2441 # verify that files do not have EAs yet
2442 $GETSTRIPE $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
2443 $GETSTRIPE $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
2445 MDSFREE="`cat $LPROC/mds/*/kbytesfree 2> /dev/null`"
2446 MDCFREE="`cat $LPROC/mdc/*/kbytesfree | head -n 1`"
2447 echo "opening files to create objects/EAs"
2448 for FILE in `seq -f $DIR/d57b/f%g 1 $FILECOUNT`; do
2449 $OPENFILE -f O_RDWR $FILE > /dev/null || error "opening $FILE"
2452 # verify that files have EAs now
2453 $GETSTRIPE $FILE1 | grep -q "obdidx" || error "$FILE1 missing EA"
2454 $GETSTRIPE $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
2456 sleep 1 # make sure we get new statfs data
2457 MDSFREE2="`cat $LPROC/mds/*/kbytesfree 2> /dev/null`"
2458 MDCFREE2="`cat $LPROC/mdc/*/kbytesfree | head -n 1`"
2459 if [ "$MDCFREE2" -lt "$((MDCFREE - 8))" ]; then
2460 if [ "$MDSFREE" != "$MDSFREE2" ]; then
2461 error "MDC before $MDCFREE != after $MDCFREE2"
2463 echo "MDC before $MDCFREE != after $MDCFREE2"
2464 echo "unable to confirm if MDS has large inodes"
2469 run_test 57b "default LOV EAs are stored inside large inodes ==="
2472 [ -z "$(which wiretest 2>/dev/null)" ] && echo "skipping $TESTNAME (could not find wiretest)" && return
2475 run_test 58 "verify cross-platform wire constants =============="
2478 echo "touch 130 files"
2479 createmany -o $DIR/f59- 130
2481 unlinkmany $DIR/f59- 130
2484 # wait for commitment of removal
2486 run_test 59 "verify cancellation of llog records async ========="
2488 TEST60_HEAD="test_60 run $RANDOM"
2490 [ ! -f run-llog.sh ] && echo "missing subtest, skipping" && return
2491 log "$TEST60_HEAD - from kernel mode"
2494 run_test 60 "llog sanity tests run from kernel module =========="
2496 test_60b() { # bug 6411
2498 LLOG_COUNT=`dmesg | grep -A 1000 "$TEST60_HEAD" | grep -c llog_test`
2499 [ $LLOG_COUNT -gt 50 ] && error "CDEBUG_LIMIT not limiting messages"|| true
2501 run_test 60b "limit repeated messages from CERROR/CWARN ========"
2504 echo "create 5000 files"
2505 createmany -o $DIR/f60c- 5000
2506 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
2507 sysctl -w lustre.fail_loc=0x80000137
2508 unlinkmany $DIR/f60c- 5000
2510 run_test 60c "unlink file when mds full"
2514 dd if=/dev/zero of=$f bs=`page_size` count=1
2515 cancel_lru_locks osc
2516 multiop $f OSMWUc || error
2519 run_test 61 "mmap() writes don't make sync hang ================"
2521 # bug 2330 - insufficient obd_match error checking causes LBUG
2525 cancel_lru_locks osc
2526 #define OBD_FAIL_OSC_MATCH 0x405
2527 sysctl -w lustre.fail_loc=0x405
2528 cat $f && error "cat succeeded, expect -EIO"
2529 sysctl -w lustre.fail_loc=0
2531 run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
2533 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
2535 MAX_DIRTY_MB=`cat $LPROC/osc/*/max_dirty_mb | head -n 1`
2536 for i in $LPROC/osc/*/max_dirty_mb ; do
2539 for i in `seq 10` ; do
2540 dd if=/dev/zero of=$DIR/f63 bs=8k &
2546 for i in $LPROC/osc/*/max_dirty_mb ; do
2547 echo $MAX_DIRTY_MB > $i
2549 rm -f $DIR/f63 || true
2551 run_test 63 "Verify oig_wait interruption does not crash ======="
2553 # bug 2248 - async write errors didn't return to application on sync
2554 # bug 3677 - async write errors left page locked
2556 DBG_SAVE="`sysctl -n lnet.debug`"
2557 sysctl -w lnet.debug=-1
2559 # ensure we have a grant to do async writes
2560 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
2563 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
2564 sysctl -w lustre.fail_loc=0x80000406
2565 multiop $DIR/$tfile Owy && \
2566 $LCTL dk /tmp/test63b.debug && \
2567 sysctl -w lnet.debug="$DBG_SAVE" && \
2568 error "sync didn't return ENOMEM"
2569 sync; sleep 2; sync # do a real sync this time to flush page
2570 grep locked $LPROC/llite/*/dump_page_cache && \
2571 $LCTL dk /tmp/test63b.debug && \
2572 sysctl -w lnet.debug="$DBG_SAVE" && \
2573 error "locked page left in cache after async error" || true
2574 sysctl -w lnet.debug="$DBG_SAVE"
2576 run_test 63b "async write errors should be returned to fsync ==="
2580 grep "[0-9]" $LPROC/osc/*[oO][sS][cC][_-]*/cur*
2582 run_test 64a "verify filter grant calculations (in kernel) ====="
2585 [ ! -f oos.sh ] && echo "missing subtest, skipping" && return
2588 run_test 64b "check out-of-space detection on client ==========="
2590 # bug 1414 - set/get directories' stripe info
2594 $LVERIFY $DIR/d65 $DIR/d65/f1 || error "lverify failed"
2596 run_test 65a "directory with no stripe info ===================="
2600 $SETSTRIPE $DIR/d65 $(($STRIPESIZE * 2)) 0 1 || error "setstripe"
2602 $LVERIFY $DIR/d65 $DIR/d65/f2 || error "lverify failed"
2604 run_test 65b "directory setstripe $(($STRIPESIZE * 2)) 0 1 ==============="
2607 if [ $OSTCOUNT -gt 1 ]; then
2609 $SETSTRIPE $DIR/d65 $(($STRIPESIZE * 4)) 1 \
2610 $(($OSTCOUNT - 1)) || error "setstripe"
2612 $LVERIFY $DIR/d65 $DIR/d65/f3 || error "lverify failed"
2615 run_test 65c "directory setstripe $(($STRIPESIZE * 4)) 1 $(($OSTCOUNT - 1))"
2617 [ $STRIPECOUNT -eq 0 ] && sc=1 || sc=$(($STRIPECOUNT - 1))
2621 $SETSTRIPE $DIR/d65 $STRIPESIZE -1 $sc || error "setstripe"
2622 touch $DIR/d65/f4 $DIR/d65/f5
2623 $LVERIFY $DIR/d65 $DIR/d65/f4 $DIR/d65/f5 || error "lverify failed"
2625 run_test 65d "directory setstripe $STRIPESIZE -1 $sc =============="
2630 $SETSTRIPE $DIR/d65 0 -1 0 || error "setstripe"
2631 $GETSTRIPE -v $DIR/d65 | grep "has no stripe info" || error "no stripe info failed"
2633 $LVERIFY $DIR/d65 $DIR/d65/f6 || error "lverify failed"
2635 run_test 65e "directory setstripe 0 -1 0 ======================="
2639 $RUNAS $SETSTRIPE $DIR/d65f 0 -1 0 && error "setstripe succeeded" || true
2641 run_test 65f "dir setstripe permission (should return error) ==="
2645 $SETSTRIPE $DIR/d65 $(($STRIPESIZE * 2)) 0 1 || error "setstripe"
2646 $SETSTRIPE -d $DIR/d65 || error "setstripe"
2647 $GETSTRIPE -v $DIR/d65 | grep "has no stripe info" || \
2648 error "delete default stripe failed"
2650 run_test 65g "directory setstripe -d ==========================="
2654 $SETSTRIPE $DIR/d65 $(($STRIPESIZE * 2)) 0 1 || error "setstripe"
2655 mkdir -p $DIR/d65/dd1
2656 [ "`$GETSTRIPE -v $DIR/d65 | grep "^count"`" == \
2657 "`$GETSTRIPE -v $DIR/d65/dd1 | grep "^count"`" ] || error "stripe info inherit failed"
2659 run_test 65h "directory stripe info inherit ===================="
2661 test_65i() { # bug6367
2662 $SETSTRIPE $MOUNT 65536 -1 -1
2664 run_test 65i "set non-default striping on root directory (bug 6367)="
2666 test_65j() { # bug6367
2667 # if we aren't already remounting for each test, do so for this test
2668 if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
2669 cleanup -f || error "failed to unmount"
2672 $SETSTRIPE -d $MOUNT
2674 run_test 65j "set default striping on root directory (bug 6367)="
2676 # bug 2543 - update blocks count on client
2679 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
2681 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
2682 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
2684 run_test 66 "update inode blocks count on client ==============="
2686 test_67() { # bug 3285 - supplementary group fails on MDS, passes on client
2687 [ "$RUNAS_ID" = "$UID" ] && echo "skipping $TESTNAME" && return
2688 check_kernel_version 35 || return 0
2690 chmod 771 $DIR/$tdir
2691 chgrp $RUNAS_ID $DIR/$tdir
2692 $RUNAS -u $RUNAS_ID -g $(($RUNAS_ID + 1)) -G1,2,$RUNAS_ID ls $DIR/$tdir
2695 # can't tell which is correct otherwise
2696 GROUP_UPCALL=`cat $LPROC/mds/$MDS/group_upcall`
2697 [ "$GROUP_UPCALL" = "NONE" -a $RC -eq 0 ] && \
2698 error "no-upcall passed" || true
2699 [ "$GROUP_UPCALL" != "NONE" -a $RC -ne 0 ] && \
2700 error "upcall failed" || true
2703 run_test 67 "supplementary group failure (should return error) ="
2708 echo NONE > $LPROC/mds/$MDS/group_upcall
2711 test_67b() { # bug 3285 - supplementary group fails on MDS, passes on client
2712 T67_UID=${T67_UID:-1} # needs to be in /etc/groups on MDS, gid == uid
2713 [ "$UID" = "$T67_UID" ] && echo "skipping $TESTNAME" && return
2714 check_kernel_version 35 || return 0
2715 [ -z "$MDS" ] && echo "skipping $TESTNAME - no MDS" && return
2716 GROUP_UPCALL=`cat $LPROC/mds/$MDS/group_upcall`
2717 [ "$GROUP_UPCALL" != "NONE" ] && echo "skip $TESTNAME - upcall" &&return
2719 trap cleanup_67b EXIT
2721 chmod 771 $DIR/$tdir
2722 chgrp $T67_UID $DIR/$tdir
2723 echo `which l_getgroups` > $LPROC/mds/$MDS/group_upcall
2724 l_getgroups -d $T67_UID
2725 $RUNAS -u $T67_UID -g 999 -G8,9,$T67_UID touch $DIR/$tdir/$tfile || \
2726 error "'touch $DIR/$tdir/$tfile' failed"
2727 [ -f $DIR/$tdir/$tfile ] || error "$DIR/$tdir/$tfile create error"
2730 run_test 67b "supplementary group test ========================="
2734 if [ "$LOOPDEV" ]; then
2735 swapoff $LOOPDEV || error "swapoff failed"
2736 losetup -d $LOOPDEV || error "losetup -d failed"
2737 unset LOOPDEV LOOPNUM
2743 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
2747 swapon -s | awk '($1 == "'$1'") { print $4 }'
2750 # excercise swapping to lustre by adding a high priority swapfile entry
2751 # and then consuming memory until it is used.
2753 [ "$UID" != 0 ] && echo "skipping $TESTNAME (must run as root)" && return
2754 grep -q obdfilter $LPROC/devices && \
2755 echo "skip $TESTNAME (local OST)" && return
2758 dd if=/dev/zero of=$DIR/f68 bs=64k count=1024
2760 trap cleanup_68 EXIT
2762 losetup $LOOPDEV $DIR/f68 || error "losetup $LOOPDEV failed"
2764 swapon -p 32767 $LOOPDEV || error "swapon $LOOPDEV failed"
2766 echo "before: `swapon -s | grep $LOOPDEV`"
2767 KBFREE=`meminfo MemTotal`
2768 $MEMHOG $KBFREE || error "error allocating $KBFREE kB"
2769 echo "after: `swapon -s | grep $LOOPDEV`"
2770 SWAPUSED=`swap_used $LOOPDEV`
2774 [ $SWAPUSED -eq 0 ] && echo "no swap used???" || true
2776 run_test 68 "support swapping to Lustre ========================"
2778 # bug5265, obdfilter oa2dentry return -ENOENT
2779 # #define OBD_FAIL_OST_ENOENT 0x217
2781 [ $(grep -c obdfilter $LPROC/devices) -eq 0 ] &&
2782 echo "skipping $TESTNAME for remote OST" && return
2787 if ! $DIRECTIO write ${f}.2 0 1; then
2788 echo "skipping $TESTNAME - O_DIRECT not implemented"
2792 #define OBD_FAIL_OST_ENOENT 0x217
2793 sysctl -w lustre.fail_loc=0x217
2794 truncate $f 1 # vmtruncate() will ignore truncate() error.
2795 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
2797 sysctl -w lustre.fail_loc=0
2798 $DIRECTIO write $f 0 2 || error "write error"
2800 cancel_lru_locks osc
2801 $DIRECTIO read $f 0 1 || error "read error"
2803 #define OBD_FAIL_OST_ENOENT 0x217
2804 sysctl -w lustre.fail_loc=0x217
2805 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
2807 sysctl -w lustre.fail_loc=0
2810 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
2813 which dbench > /dev/null 2>&1 || echo "dbench not installed, skip this test" && return 0
2814 DBENCH_LIB=${DBENCH_LIB:-/usr/lib/dbench}
2815 PATH=${DBENCH_LIB}:${PATH}
2816 cp `which dbench` $DIR
2819 SRC=${SRC:-$DBENCH_LIB/client.txt}
2820 [ ! -e $TGT -a -e $SRC ] && echo "copying $SRC to $TGT" && cp $SRC $TGT
2821 SRC=$DBENCH_LIB/client_plain.txt
2822 [ ! -e $TGT -a -e $SRC ] && echo "copying $SRC to $TGT" && cp $SRC $TGT
2824 echo "copying necessary lib to $DIR"
2825 [ -d /lib64 ] && LIB71=/lib64 || LIB71=/lib
2826 mkdir -p $DIR$LIB71 || error "can't create $DIR$LIB71"
2827 cp $LIB71/libc* $DIR$LIB71 || error "can't copy $LIB71/libc*"
2828 cp $LIB71/ld-* $DIR$LIB71 || error "can't create $LIB71/ld-*"
2830 echo "chroot $DIR /dbench -c client.txt 2"
2831 chroot $DIR /dbench -c client.txt 2
2834 rm -rf $DIR/dbench $TGT $DIR$LIB71
2838 run_test 71 "Running dbench on lustre (don't segment fault) ===="
2840 test_72() { # bug 5695 - Test that on 2.6 remove_suid works properly
2841 check_kernel_version 43 || return 0
2842 [ "$RUNAS_ID" = "$UID" ] && echo "skipping $TESTNAME" && return
2846 $RUNAS -u $(($RUNAS_ID + 1)) dd if=/dev/zero of=$DIR/f72 bs=512 count=1 || error
2847 # See if we are still setuid/sgid
2848 test -u $DIR/f72 -o -g $DIR/f72 && error "S/gid is not dropped on write"
2849 # Now test that MDS is updated too
2850 cancel_lru_locks mdc
2851 test -u $DIR/f72 -o -g $DIR/f72 && error "S/gid is not dropped on MDS"
2854 run_test 72 "Test that remove suid works properly (bug5695) ===="
2856 # bug 3462 - multiple simultaneous MDC requests
2860 multiop $DIR/d73-1/f73-1 O_c &
2862 #give multiop a chance to open
2865 #define OBD_FAIL_MDS_PAUSE_OPEN 0x129
2866 sysctl -w lustre.fail_loc=0x80000129
2867 multiop $DIR/d73-1/f73-2 Oc &
2869 sysctl -w lustre.fail_loc=0
2871 multiop $DIR/d73-2/f73-3 Oc &
2875 wait $pid1 || return 1
2879 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
2880 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
2881 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
2885 run_test 73 "multiple MDC requests (should not deadlock)"
2887 test_74() { # bug 6149, 6184
2888 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
2890 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
2891 # will spin in a tight reconnection loop
2892 sysctl -w lustre.fail_loc=0x8000030e
2895 sysctl -w lustre.fail_loc=0
2898 run_test 74 "ldlm_enqueue freed-export error path (shouldn't LBUG)"
2900 JOIN=${JOIN:-"lfs join"}
2907 [ $T75_PREP = "yes" ] && return
2908 echo "using F75=$F75, F128k=$F128k, FHEAD=$FHEAD, FTAIL=$FTAIL"
2910 dd if=/dev/urandom of=${F75}_128k bs=128k count=1 || error "dd failed"
2919 cp -p ${F128k} ${FHEAD}
2920 log "finished cp to $FHEAD"
2921 cp -p ${F128k} ${FTAIL}
2922 log "finished cp to $FTAIL"
2923 cat ${F128k} ${F128k} > ${F75}_sim_sim
2925 $JOIN ${FHEAD} ${FTAIL} || error "join ${FHEAD} ${FTAIL} error"
2926 log "finished join $FHEAD to ${F75}_sim_sim"
2927 cmp ${FHEAD} ${F75}_sim_sim || error "${FHEAD} ${F75}_sim_sim differ"
2928 log "finished cmp $FHEAD to ${F75}_sim_sim"
2929 $CHECKSTAT -a ${FTAIL} || error "tail ${FTAIL} still exist after join"
2931 run_test 75a "TEST join file ===================================="
2936 cp -p ${F128k} ${FTAIL}
2937 cat ${F75}_sim_sim >> ${F75}_join_sim
2938 cat ${F128k} >> ${F75}_join_sim
2939 $JOIN ${FHEAD} ${FTAIL} || error "join ${FHEAD} ${FTAIL} error"
2940 cmp ${FHEAD} ${F75}_join_sim || \
2941 error "${FHEAD} ${F75}_join_sim are different"
2942 $CHECKSTAT -a ${FTAIL} || error "tail ${FTAIL} exist after join"
2944 run_test 75b "TEST join file 2 =================================="
2949 cp -p ${F128k} ${FTAIL}
2950 cat ${F128k} >> ${F75}_sim_join
2951 cat ${F75}_join_sim >> ${F75}_sim_join
2952 $JOIN ${FTAIL} ${FHEAD} || error "join error"
2953 cmp ${FTAIL} ${F75}_sim_join || \
2954 error "${FTAIL} ${F75}_sim_join are different"
2955 $CHECKSTAT -a ${FHEAD} || error "tail ${FHEAD} exist after join"
2957 run_test 75c "TEST join file 3 =================================="
2962 cp -p ${F128k} ${FHEAD}
2963 cp -p ${F128k} ${FHEAD}_tmp
2964 cat ${F75}_sim_sim >> ${F75}_join_join
2965 cat ${F75}_sim_join >> ${F75}_join_join
2966 $JOIN ${FHEAD} ${FHEAD}_tmp || error "join ${FHEAD} ${FHEAD}_tmp error"
2967 $JOIN ${FHEAD} ${FTAIL} || error "join ${FHEAD} ${FTAIL} error"
2968 cmp ${FHEAD} ${F75}_join_join ||error "${FHEAD} ${F75}_join_join differ" $CHECKSTAT -a ${FHEAD}_tmp || error "${FHEAD}_tmp exist after join"
2969 $CHECKSTAT -a ${FTAIL} || error "tail ${FTAIL} exist after join (2)"
2971 run_test 75d "TEST join file 4 =================================="
2976 rm -rf ${FHEAD} || "delete join file error"
2978 run_test 75e "TEST join file 5 (remove joined file) ============="
2983 cp -p ${F128k} ${F75}_join_10_compare
2984 cp -p ${F128k} ${F75}_join_10
2985 for ((i = 0; i < 10; i++)); do
2986 cat ${F128k} >> ${F75}_join_10_compare
2987 cp -p ${F128k} ${FTAIL}
2988 $JOIN ${F75}_join_10 ${FTAIL} || \
2989 error "join ${F75}_join_10 ${FTAIL} error"
2990 $CHECKSTAT -a ${FTAIL} || error "tail file exist after join"
2992 cmp ${F75}_join_10 ${F75}_join_10_compare || \
2993 error "files ${F75}_join_10 ${F75}_join_10_compare differ"
2995 run_test 75f "TEST join file 6 (join 10 files) =================="
2998 [ ! -f ${F75}_join_10 ] && echo "${F75}_join_10 missing" && return
2999 $LFS getstripe ${F75}_join_10
3001 $OPENUNLINK ${F75}_join_10 ${F75}_join_10 || error "files unlink open"
3005 run_test 75g "TEST join file 7 (open unlink) ===================="
3008 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
3011 test_76() { # bug 1443
3012 DETH=$(grep deathrow /proc/kallsyms /proc/ksyms 2> /dev/null | wc -l)
3013 [ $DETH -eq 0 ] && echo "No _iget, skipping" && return 0
3014 BEFORE_INODES=`num_inodes`
3015 echo "before inodes: $BEFORE_INODES"
3016 for i in `seq 1000`; do
3020 AFTER_INODES=`num_inodes`
3021 echo "after inodes: $AFTER_INODES"
3022 [ $AFTER_INODES -gt $((BEFORE_INODES + 32)) ] && \
3023 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
3026 run_test 76 "destroy duplicate inodes in client inode cache ===="
3031 [ "$ORIG_CSUM" ]||ORIG_CSUM=`cat $LPROC/llite/*/checksum_pages|head -n1`
3032 for f in $LPROC/llite/*/checksum_pages; do
3039 F77_TMP=$TMP/f77-temp
3042 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
3043 error "error writing to $F77_TMP"
3046 test_77a() { # bug 10889
3047 [ ! -f $F77_TMP ] && setup_f77
3049 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
3052 run_test 77a "normal checksum read/write operation ============="
3054 test_77b() { # bug 10889
3055 [ ! -f $F77_TMP ] && setup_f77
3056 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
3057 sysctl -w lustre.fail_loc=0x80000409
3059 dd if=$F77_TMP of=$DIR/f77b bs=1M count=$F77SZ conv=sync || \
3060 error "dd error: $?"
3061 sysctl -w lustre.fail_loc=0
3064 run_test 77b "checksum error on client write ===================="
3066 test_77c() { # bug 10889
3067 [ ! -f $DIR/f77b ] && log "requires 77b - skipping" && return
3068 cancel_lru_locks osc
3069 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
3070 sysctl -w lustre.fail_loc=0x80000408
3072 cmp $F77_TMP $DIR/f77b || error "file compare failed"
3073 sysctl -w lustre.fail_loc=0
3076 run_test 77c "checksum error on client read ==================="
3078 test_77d() { # bug 10889
3079 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
3080 sysctl -w lustre.fail_loc=0x80000409
3082 directio write $DIR/f77 0 $F77SZ $((1024 * 1024)) || \
3083 error "direct write: rc=$?"
3084 sysctl -w lustre.fail_loc=0
3087 run_test 77d "checksum error on OST direct write ==============="
3089 test_77e() { # bug 10889
3090 [ ! -f $DIR/f77 ] && log "requires 77d - skipping" && return
3091 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
3092 sysctl -w lustre.fail_loc=0x80000408
3094 cancel_lru_locks osc
3095 directio read $DIR/f77 0 $F77SZ $((1024 * 1024)) || \
3096 error "direct read: rc=$?"
3097 sysctl -w lustre.fail_loc=0
3100 run_test 77e "checksum error on OST direct read ================"
3102 test_77f() { # bug 10889
3103 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
3104 sysctl -w lustre.fail_loc=0x409
3106 directio write $DIR/f77 0 $F77SZ $((1024 * 1024)) && \
3107 error "direct write succeeded"
3108 sysctl -w lustre.fail_loc=0
3111 run_test 77f "repeat checksum error on write (expect error) ===="
3113 test_77g() { # bug 10889
3114 [ $(grep -c obdfilter $LPROC/devices) -eq 0 ] && \
3115 echo "skipping $TESTNAME (remote OST)" && return
3116 [ ! -f $F77_TMP ] && setup_f77
3117 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
3118 sysctl -w lustre.fail_loc=0x8000021a
3120 dd if=$F77_TMP of=$DIR/f77g bs=1M count=$F77SZ || \
3121 error "write error: rc=$?"
3122 sysctl -w lustre.fail_loc=0
3125 run_test 77g "checksum error on OST write ======================"
3127 test_77h() { # bug 10889
3128 [ $(grep -c obdfilter $LPROC/devices) -eq 0 ] && \
3129 echo "skipping $TESTNAME (remote OST)" && return
3130 [ ! -f $DIR/f77g ] && log "requires 77g - skipping" && return
3131 cancel_lru_locks osc
3132 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
3133 sysctl -w lustre.fail_loc=0x8000021b
3135 cmp $F77_TMP $DIR/f77g || error "file compare failed"
3136 sysctl -w lustre.fail_loc=0
3139 run_test 77h "checksum error on OST read ======================="
3141 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
3145 test_78() { # bug 10901
3147 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
3148 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
3149 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 2048))
3150 echo "MemTotal: $((MEMTOTAL * 2))"
3151 [ $F78SIZE -gt $MEMTOTAL ] && F78SIZE=$MEMTOTAL
3152 [ $F78SIZE -gt 512 ] && F78SIZE=512
3153 [ $F78SIZE -gt $((MAXFREE / 1024)) ] && F78SIZE=$((MAXFREE / 1024))
3154 SMALLESTOST=`lfs df $DIR |grep OST | awk '{print $4}' |sort -n |head -1`
3155 echo "Smallest OST: $SMALLESTOST"
3156 [ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024)) ] && \
3157 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024))
3158 echo "File size: $F78SIZE"
3159 $SETSTRIPE $DIR/$tfile 0 -1 -1 || error "setstripe failed"
3160 for i in `seq 1 $NSEQ`
3162 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
3163 echo directIO rdwr round $i of $NSEQ
3164 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
3169 run_test 78 "handle large O_DIRECT writes correctly ============"
3171 # on the LLNL clusters, runas will still pick up root's $TMP settings,
3172 # which will not be writable for the runas user, and then you get a CVS
3173 # error message with a corrupt path string (CVS bug) and panic.
3174 # We're not using much space, so just stick it in /tmp, which is safe.
3180 [ $RUNAS_ID -ne $UID ] && HOME=/tmp
3183 mkdir -p $DIR/d99cvsroot || error "mkdir $DIR/d99cvsroot failed"
3184 chown $RUNAS_ID $DIR/d99cvsroot || error "chown $DIR/d99cvsroot failed"
3185 $RUNAS cvs -d $DIR/d99cvsroot init || error "cvs init failed"
3187 run_test 99a "cvs init ========================================="
3190 [ ! -d $DIR/d99cvsroot ] && test_99a
3191 cd /etc/init.d || error "cd /etc/init.d failed"
3192 # some versions of cvs import exit(1) when asked to import links or
3193 # files they can't read. ignore those files.
3194 TOIGNORE=$(find . -type l -printf '-I %f\n' -o \
3195 ! -perm +4 -printf '-I %f\n')
3196 $RUNAS cvs -d $DIR/d99cvsroot import -m "nomesg" $TOIGNORE \
3197 d99reposname vtag rtag || error "cvs import failed"
3199 run_test 99b "cvs import ======================================="
3202 [ ! -d $DIR/d99cvsroot ] && test_99b
3203 cd $DIR || error "cd $DIR failed"
3204 mkdir -p $DIR/d99reposname || error "mkdir $DIR/d99reposname failed"
3205 chown $RUNAS_ID $DIR/d99reposname || \
3206 error "chown $DIR/d99reposname failed"
3207 $RUNAS cvs -d $DIR/d99cvsroot co d99reposname || \
3208 error "cvs co d99reposname failed"
3210 run_test 99c "cvs checkout ====================================="
3213 [ ! -d $DIR/d99cvsroot ] && test_99c
3214 cd $DIR/d99reposname
3216 $RUNAS cvs add -m 'addmsg' foo99
3218 run_test 99d "cvs add =========================================="
3221 [ ! -d $DIR/d99cvsroot ] && test_99c
3222 cd $DIR/d99reposname
3225 run_test 99e "cvs update ======================================="
3228 [ ! -d $DIR/d99cvsroot ] && test_99d
3229 cd $DIR/d99reposname
3230 $RUNAS cvs commit -m 'nomsg' foo99
3232 run_test 99f "cvs commit ======================================="
3235 netstat -tna | while read PROT SND RCV LOCAL REMOTE STAT; do
3236 [ "$PROT" != "tcp" ] && continue
3237 RPORT=`echo $REMOTE | cut -d: -f2`
3238 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
3239 LPORT=`echo $LOCAL | cut -d: -f2`
3240 if [ $LPORT -ge 1024 ]; then
3241 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
3243 error "local: $LPORT > 1024, remote: $RPORT"
3248 run_test 100 "check local port using privileged port ==========="
3250 function get_named_value()
3259 echo $line | sed "s/^$tag//"
3266 export CACHE_MAX=`cat $LPROC/llite/*/max_cached_mb | head -n 1`
3268 for s in $LPROC/llite/*/max_cached_mb; do
3269 echo $CACHE_MAX > $s
3278 [ "$CPU" = "UML" ] && nreads=1000
3279 local cache_limit=32
3281 for s in $LPROC/osc/*/rpc_stats; do
3284 trap cleanup_101 EXIT
3285 for s in $LPROC/llite/*; do
3286 echo 0 > $s/read_ahead_stats
3287 echo $cache_limit > $s/max_cached_mb
3291 # randomly read 10000 of 64K chunks from file 3x 32MB in size
3293 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
3294 $RANDOM_READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
3297 for s in $LPROC/llite/*; do
3298 discard=$(($discard + $(cat $s/read_ahead_stats | get_named_value 'read but discarded')))
3302 if [ $(($discard * 10)) -gt $nreads ] ;then
3303 for s in $LPROC/osc/*/rpc_stats; do
3306 for s in $LPROC/llite/*/read_ahead_stats; do
3309 error "too many ($discard) discarded pages"
3311 rm -f $DIR/$tfile || true
3313 run_test 101 "check read-ahead for random reads ================"
3315 export SETUP_TEST102=no
3317 [ "$SETUP_TEST102" = "yes" ] && return
3323 trap cleanup_test102 EXIT
3325 $SETSTRIPE $tdir $STRIPE_SIZE $STRIPE_OFFSET $STRIPE_COUNT
3329 for count in 1 2 3 4
3331 for offset in 0 1 2 3
3333 local stripe_size=`expr $STRIPE_SIZE \* $num`
3334 local file=file"$num-$offset-$count"
3335 $SETSTRIPE $file $stripe_size $offset $count
3341 star -c f=$TMP/f102.tar $tdir
3346 [ "$SETUP_TEST102" = "yes" ] || return
3354 local testfile=$DIR/xattr_testfile
3359 [ "$UID" != 0 ] && echo "skipping $TESTNAME (must run as root)" && return
3360 [ -z "`grep xattr $LPROC/mdc/*[mM][dD][cC]*/connect_flags`" ] && echo "skipping $TESTNAME (must have user_xattr)" && return
3361 [ -z "$(which setfattr 2>/dev/null)" ] && echo "skipping $TESTNAME (could not find setfattr)" && return
3363 echo "set/get xattr..."
3364 setfattr -n trusted.name1 -v value1 $testfile || error
3365 [ "`getfattr -n trusted.name1 $testfile 2> /dev/null | \
3366 grep "trusted.name1"`" == "trusted.name1=\"value1\"" ] || error
3368 setfattr -n user.author1 -v author1 $testfile || error
3369 [ "`getfattr -n user.author1 $testfile 2> /dev/null | \
3370 grep "user.author1"`" == "user.author1=\"author1\"" ] || error
3373 setfattr -n trusted.name2 -v value2 $testfile || error
3374 setfattr -n trusted.name3 -v value3 $testfile || error
3375 [ `getfattr -d -m "^trusted" $testfile 2> /dev/null | \
3376 grep "trusted.name" | wc -l` -eq 3 ] || error
3379 setfattr -n user.author2 -v author2 $testfile || error
3380 setfattr -n user.author3 -v author3 $testfile || error
3381 [ `getfattr -d -m "^user" $testfile 2> /dev/null | \
3382 grep "user" | wc -l` -eq 3 ] || error
3384 echo "remove xattr..."
3385 setfattr -x trusted.name1 $testfile || error
3386 getfattr -d -m trusted $testfile 2> /dev/null | \
3387 grep "trusted.name1" && error || true
3389 setfattr -x user.author1 $testfile || error
3390 getfattr -d -m user $testfile 2> /dev/null | \
3391 grep "user.author1" && error || true
3393 # b10667: setting lustre special xattr be silently discarded
3394 echo "set lustre special xattr ..."
3395 setfattr -n "trusted.lov" -v "invalid value" $testfile || error
3399 run_test 102a "user xattr test =================================="
3402 # b10930: get/set/list trusted.lov xattr
3403 echo "get/set/list trusted.lov xattr ..."
3404 [ "$OSTCOUNT" -lt "2" ] && echo "skipping 2-stripe test" && return
3405 local testfile=$DIR/$tfile
3406 $SETSTRIPE $testfile 65536 1 2
3407 getfattr -d -m "^trusted" $testfile 2> /dev/null | \
3408 grep "trusted.lov" || error "can't get trusted.lov from $testfile"
3410 local testfile2=${testfile}2
3411 local value=`getfattr -n trusted.lov $testfile 2> /dev/null | \
3412 grep "trusted.lov" |sed -e 's/[^=]\+=//'`
3415 setfattr -n trusted.lov -v $value $testfile2
3416 local tmp_file=${testfile}3
3417 $GETSTRIPE -v $testfile2 > $tmp_file
3418 local stripe_size=`grep "size" $tmp_file| awk '{print $2}'`
3419 local stripe_count=`grep "count" $tmp_file| awk '{print $2}'`
3420 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
3421 [ $stripe_count -eq 2 ] || error "stripe count $stripe_count != 2"
3423 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
3426 # b10930: get/set/list trusted.lov xattr
3427 echo "get/set/list trusted.lov xattr ..."
3428 [ "$OSTCOUNT" -lt "2" ] && echo "skipping 2-stripe test" && return
3430 chown $RUNAS_ID $DIR/$tdir
3431 local testfile=$DIR/$tdir/$tfile
3432 $RUNAS $SETSTRIPE $testfile 65536 1 2
3433 $RUNAS getfattr -d -m "^trusted" $testfile 2> /dev/null | \
3434 grep "trusted.lov" || error "can't get trusted.lov from $testfile"
3436 local testfile2=${testfile}2
3437 local value=`getfattr -n trusted.lov $testfile 2> /dev/null | \
3438 grep "trusted.lov" |sed -e 's/[^=]\+=//' `
3440 $RUNAS $MCREATE $testfile2
3441 $RUNAS setfattr -n trusted.lov -v $value $testfile2
3442 local tmp_file=${testfile}3
3443 $RUNAS $GETSTRIPE -v $testfile2 > $tmp_file
3444 local stripe_size=`grep "size" $tmp_file| awk '{print $2}'`
3445 local stripe_count=`grep "count" $tmp_file| awk '{print $2}'`
3446 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
3447 [ $stripe_count -eq 2 ] || error "stripe count $stripe_count != 2"
3449 run_test 102c "non-root getfattr/setfattr for trusted.lov EAs ==========="
3455 local lines=`sed -n '/obdidx/=' $1`
3456 stripe_size=`awk '{if($1~/size/) print $2}' $1`
3457 stripe_count=`awk '{if($1~/count/) print $2}' $1`
3458 lines=`expr $lines + 1`
3459 stripe_offset=`sed -n ${lines}p $1 |awk '{print $1}'`
3462 compare_stripe_info1() {
3465 for count in 1 2 3 4
3467 for offset in 0 1 2 3
3469 local size=`expr $STRIPE_SIZE \* $num`
3470 local file=file"$num-$offset-$count"
3472 $GETSTRIPE -v $file > $tmp_file
3473 get_stripe_info $tmp_file
3474 if test $stripe_size -ne $size
3476 error "$file: different stripe size" && return
3478 if test $stripe_count -ne $count
3480 error "$file: different stripe count" && return
3482 if test $stripe_offset -ne 0
3484 error "$file: different stripe offset" && return
3492 compare_stripe_info2() {
3495 for count in 1 2 3 4
3497 for offset in 0 1 2 3
3499 local size=`expr $STRIPE_SIZE \* $num`
3500 local file=file"$num-$offset-$count"
3502 $GETSTRIPE -v $file > $tmp_file
3503 get_stripe_info $tmp_file
3504 if test $stripe_size -ne $size
3506 error "$file: different stripe size" && return
3508 if test $stripe_count -ne $count
3510 error "$file: different stripe count" && return
3512 if test $stripe_offset -ne $offset
3514 error "$file: different stripe offset" && return
3523 # b10930: star test for trusted.lov xattr
3524 star --xhelp 2>&1 | grep -q nolustre
3527 echo "$TESTNUM being skipped because a lustre-aware star is not installed." && return
3529 [ "$OSTCOUNT" -lt "4" ] && echo "skipping 4-stripe test" && return
3532 star -x f=$TMP/f102.tar -C $DIR/d102d
3534 compare_stripe_info1
3537 run_test 102d "star restore stripe info from tarfile,not keep osts ==========="
3540 # b10930: star test for trusted.lov xattr
3541 star --xhelp 2>&1 | grep -q nolustre
3544 echo "$TESTNUM being skipped because a lustre-aware star is not installed." && return
3546 [ "$OSTCOUNT" -lt "4" ] && echo "skipping 4-stripe test" && return
3549 star -x -preserve-osts f=$TMP/f102.tar -C $DIR/d102e
3551 compare_stripe_info2
3553 run_test 102e "star restore stripe info from tarfile, keep osts ==========="
3556 # b10930: star test for trusted.lov xattr
3557 star --xhelp 2>&1 | grep -q nolustre
3560 echo "$TESTNUM being skipped because a lustre-aware star is not installed." && return
3562 [ "$OSTCOUNT" -lt "4" ] && echo "skipping 4-stripe test" && return
3566 star -copy $tdir $DIR/d102f
3568 compare_stripe_info1
3570 run_test 102f "star copy files, not keep osts ==========="
3573 # b10930: star test for trusted.lov xattr
3574 star --xhelp 2>&1 | grep -q nolustre
3577 echo "$TESTNUM being skipped because a lustre-aware star is not installed." && return
3579 [ "$OSTCOUNT" -lt "4" ] && echo "skipping 4-stripe test" && return
3583 star -copy -preserve-osts $tdir $DIR/d102g
3585 compare_stripe_info2
3588 run_test 102g "star copy files, keep osts ==========="
3592 $SAVE_PWD/acl/run $SAVE_PWD/acl/$1.test
3597 [ "$UID" != 0 ] && echo "skipping $TESTNAME (must run as root)" && return
3598 [ -z "$(grep acl $LPROC/mdc/*[mM][dD][cC]*/connect_flags)" ] && echo "skipping $TESTNAME (must have acl enabled)" && return
3599 [ -z "$(which setfacl 2>/dev/null)" ] && echo "skipping $TESTNAME (could not find setfacl)" && return
3605 echo "performing cp ..."
3606 run_acl_subtest cp || error
3607 echo "performing getfacl-noacl..."
3608 run_acl_subtest getfacl-noacl || error
3609 echo "performing misc..."
3610 run_acl_subtest misc || error
3611 # XXX add back permission test when we support supplementary groups.
3612 # echo "performing permissions..."
3613 # run_acl_subtest permissions || error
3614 echo "performing setfacl..."
3615 run_acl_subtest setfacl || error
3617 # inheritance test got from HP
3618 echo "performing inheritance..."
3619 cp $SAVE_PWD/acl/make-tree . || error
3620 chmod +x make-tree || error
3621 run_acl_subtest inheritance || error
3627 run_test 103 "acl test ========================================="
3631 lfs df || error "lfs df failed"
3632 lfs df -ih || error "lfs df -ih failed"
3633 lfs df -h $DIR || error "lfs df -h $DIR failed"
3634 lfs df -i $DIR || error "lfs df -i $DIR failed"
3635 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
3636 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
3638 OSC=`awk '/-osc-|OSC.*MNT/ {print $4}' $LPROC/devices | head -n 1`
3639 lctl --device %$OSC deactivate
3640 lfs df || error "lfs df with deactivated OSC failed"
3641 lctl --device %$OSC recover
3642 lfs df || error "lfs df with reactivated OSC failed"
3644 run_test 104 "lfs df [-ih] [path] test ========================="
3647 # doesn't work on 2.4 kernels
3649 if [ -n "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ];
3651 flocks_test on -f $DIR/$tfile || error "fail flock on"
3653 flocks_test off -f $DIR/$tfile || error "fail flock off"
3656 run_test 105a "flock when mounted without -o flock test ========"
3660 if [ -n "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ];
3662 flocks_test on -c $DIR/$tfile || error "fail flock on"
3664 flocks_test off -c $DIR/$tfile || error "fail flock off"
3667 run_test 105b "fcntl when mounted without -o flock test ========"
3671 if [ -n "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ];
3673 flocks_test on -l $DIR/$tfile || error "fail flock on"
3675 flocks_test off -l $DIR/$tfile || error "fail flock off"
3678 run_test 105c "lockf when mounted without -o flock test ========"
3680 test_106() { #bug 10921
3681 mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3682 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
3683 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
3685 run_test 106 "attempt exec of dir followed by chown of that dir"
3694 file=`cat /proc/sys/kernel/core_pattern`
3695 core_pid=`cat /proc/sys/kernel/core_uses_pid`
3696 [ $core_pid -eq 1 ] && file=$file.$SLEEPPID
3700 kill -s 11 $SLEEPPID
3702 if [ -e $file ]; then
3703 size=`stat -c%s $file`
3704 [ $size -eq 0 ] && error "Zero length core file $file"
3706 error "Fail to create core file $file"
3711 run_test 107 "Coredump on SIG"
3714 OSTIO_pre=$(ps -e|grep ll_ost_io|awk '{print $4}'|sort -n|tail -1|\
3716 [ -z "$OSTIO_pre" ] && echo "skipping $TESTNAME: no OSS threads" && \
3718 echo "Starting with $OSTIO_pre threads"
3721 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
3722 [ $NUMFREE -lt $NUMTEST ] && NUMTEST=$(($NUMFREE - 1000))
3723 echo "$NUMTEST creates/unlinks"
3725 createmany -o $DIR/$tdir/$tfile $NUMTEST
3726 unlinkmany $DIR/$tdir/$tfile $NUMTEST
3728 OSTIO_post=$(ps -e|grep ll_ost_io|awk '{print $4}'|sort -n|tail -1|\
3731 # don't return an error
3732 [ $OSTIO_post -eq $OSTIO_pre ] && echo \
3733 "FAIL: No addition ll_ost_io threads were created ($OSTIO_pre)" &&\
3734 echo "This may be fine, depending on what ran before this test" &&\
3735 echo "and how fast this system is." && return
3737 echo "Started with $OSTIO_pre threads, ended with $OSTIO_post"
3739 run_test 115 "verify dynamic thread creation===================="
3742 AVAIL=($(cat $LPROC/osc/*[oO][sS][cC][-_]*/kbytesavail))
3743 echo OST kbytes available: ${AVAIL[@]}
3744 MAXI=0; MAXV=${AVAIL[0]}
3745 MINI=0; MINV=${AVAIL[0]}
3746 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
3747 #echo OST $i: ${AVAIL[i]}kb
3748 if [ ${AVAIL[i]} -gt $MAXV ]; then
3749 MAXV=${AVAIL[i]}; MAXI=$i
3751 if [ ${AVAIL[i]} -lt $MINV ]; then
3752 MINV=${AVAIL[i]}; MINI=$i
3755 echo Min free space: OST $MINI: $MINV
3756 echo Max free space: OST $MAXI: $MAXV
3760 [ "$OSTCOUNT" -lt "2" ] && echo "not enough OSTs" && return
3761 [ $(grep -c obdfilter $LPROC/devices) -eq 0 ] &&
3762 echo "remote MDS, skipping test" && return
3764 echo -n "Free space priority "
3765 cat $LPROC/lov/*/qos_prio_free
3766 DELAY=$(cat $LPROC/lov/*/qos_maxage | head -1 | awk '{print $1}')
3769 [ $MINV -gt 960000 ] && echo "too much free space in OST$MINI, skip" &&\
3772 # generate uneven OSTs
3773 mkdir -p $DIR/$tdir/OST${MINI}
3776 echo "Filling 25% remaining space in OST${MINI} with ${FILL}Kb"
3777 $SETSTRIPE $DIR/$tdir/OST${MINI} 0 $MINI 1
3779 while [ $FILL -gt 0 ]; do
3780 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i bs=2M count=1 2>/dev/null
3781 FILL=$(($FILL - 2048))
3790 DIFF=$(($MAXV - $MINV))
3791 DIFF2=$(($DIFF * 100 / $MINV))
3792 echo -n "diff=${DIFF}=${DIFF2}% must be > 20% for QOS mode..."
3793 if [ $DIFF2 -gt 20 ]; then
3796 echo "failed - QOS mode won't be used"
3797 error "QOS imbalance criteria not met"
3801 MINI1=$MINI; MINV1=$MINV
3802 MAXI1=$MAXI; MAXV1=$MAXV
3804 # now fill using QOS
3805 echo writing a bunch of files to QOS-assigned OSTs
3807 while [ $FILL -gt 0 ]; do
3808 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1024 count=200 2>/dev/null
3809 FILL=$(($FILL - 200))
3813 echo "wrote $i 200k files"
3817 echo "Note: free space may not be updated, so measurements might be off"
3819 DIFF2=$(($MAXV - $MINV))
3820 echo "free space delta: orig $DIFF final $DIFF2"
3821 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
3822 DIFF=$(($MINV1 - ${AVAIL[$MINI1]}))
3823 echo "Wrote $DIFF to smaller OST $MINI1"
3824 DIFF2=$(($MAXV1 - ${AVAIL[$MAXI1]}))
3825 echo "Wrote $DIFF2 to larger OST $MAXI1"
3826 [ $DIFF -gt 0 ] && echo "Wrote $(($DIFF2 * 100 / $DIFF - 100))% more data to larger OST $MAXI1"
3828 # Figure out which files were written where
3829 UUID=$(awk '/'$MINI1': / {print $2; exit}' $LPROC/lov/${FSNAME}-clilov-*/target_obd)
3831 MINC=$($LFS getstripe --obd $UUID $DIR/$tdir | wc -l)
3832 echo "$MINC files created on smaller OST $MINI1"
3833 UUID=$(awk '/'$MAXI1': / {print $2; exit}' $LPROC/lov/${FSNAME}-clilov-*/target_obd)
3834 MAXC=$($LFS getstripe --obd $UUID $DIR/$tdir | wc -l)
3835 echo "$MAXC files created on larger OST $MAXI1"
3836 [ $MINC -gt 0 ] && echo "Wrote $(($MAXC * 100 / $MINC - 100))% more files to larger OST $MAXI1"
3837 [ $MAXC -gt $MINC ] || error "stripe QOS didn't balance free space"
3839 run_test 116 "stripe QOS: free space balance ==================="
3841 test_117() # bug 10891
3843 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
3844 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
3845 sysctl -w lustre.fail_loc=0x21e
3846 > $DIR/$tfile || error "truncate failed"
3847 sysctl -w lustre.fail_loc=0
3848 echo "Truncate succeeded."
3850 run_test 117 "verify fsfilt_extend ============================="
3852 # Reset async IO behavior after error case
3854 FILE=$DIR/reset_async
3856 # Ensure all OSCs are cleared
3857 $LSTRIPE $FILE 0 -1 -1
3858 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
3863 test_118a() #bug 11710
3867 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
3868 DIRTY=$(grep -c dirty $LPROC/llite/*/dump_page_cache)
3869 WRITEBACK=$(grep -c writeback $LPROC/llite/*/dump_page_cache)
3871 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
3872 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
3876 run_test 118a "verify O_SYNC works ============================="
3882 #define OBD_FAIL_OST_ENOENT 0x217
3883 do_facet ost sysctl -w lustre.fail_loc=0x217
3884 multiop $DIR/$tfile Ow4096yc
3886 do_facet ost sysctl -w lustre.fail_loc=0
3887 DIRTY=$(grep -c dirty $LPROC/llite/*/dump_page_cache)
3888 WRITEBACK=$(grep -c writeback $LPROC/llite/*/dump_page_cache)
3890 if [[ $RC -eq 0 ]]; then
3891 error "Must return error due to dropped pages, rc=$RC"
3895 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
3896 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
3900 echo "Dirty pages not leaked on ENOENT"
3902 # Due to the above error the OSC will issue all RPCs syncronously
3903 # until a subsequent RPC completes successfully without error.
3904 multiop $DIR/$tfile Ow4096yc
3909 run_test 118b "Reclaim dirty pages on fatal error =============="
3915 #define OBD_FAIL_OST_EROFS 0x216
3916 do_facet ost sysctl -w lustre.fail_loc=0x216
3918 # multiop should block due to fsync until pages are written
3919 multiop $DIR/$tfile Ow4096yc &
3923 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
3924 error "Multiop failed to block on fsync, pid=$MULTIPID"
3927 WRITEBACK=$(grep -c writeback $LPROC/llite/*/dump_page_cache)
3928 if [[ $WRITEBACK -eq 0 ]]; then
3929 error "No page in writeback, writeback=$WRITEBACK"
3932 do_facet ost sysctl -w lustre.fail_loc=0
3935 if [[ $RC -ne 0 ]]; then
3936 error "Multiop fsync failed, rc=$RC"
3939 DIRTY=$(grep -c dirty $LPROC/llite/*/dump_page_cache)
3940 WRITEBACK=$(grep -c writeback $LPROC/llite/*/dump_page_cache)
3941 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
3942 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
3946 echo "Dirty pages flushed via fsync on EROFS"
3949 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed"
3955 #define OBD_FAIL_OST_BRW_PAUSE_BULK
3956 do_facet ost sysctl -w lustre.fail_loc=0x214
3958 echo "10" > $LPROC/osc/resend_timeout
3959 # multiop should block due to fsync until pages are written
3960 multiop $DIR/$tfile Ow4096yc &
3963 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
3964 error "Multiop failed to block on fsync, pid=$MULTIPID"
3967 WRITEBACK=$(grep -c writeback $LPROC/llite/*/dump_page_cache)
3968 if [[ $WRITEBACK -eq 0 ]]; then
3969 error "No page in writeback, writeback=$WRITEBACK"
3972 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
3973 do_facet ost sysctl -w lustre.fail_loc=0
3975 DIRTY=$(grep -c dirty $LPROC/llite/*/dump_page_cache)
3976 WRITEBACK=$(grep -c writeback $LPROC/llite/*/dump_page_cache)
3977 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
3978 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
3982 echo "Dirty pages gaurenteed flushed via fsync"
3985 run_test 118d "Fsync validation inject a delay of the bulk ====="
3990 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
3991 sysctl -w lustre.fail_loc=0x8000040a
3993 # Should simulate EINVAL error which is fatal
3994 multiop $DIR/$tfile Owy
3996 if [[ $RC -eq 0 ]]; then
3997 error "Must return error due to dropped pages, rc=$RC"
4000 sysctl -w lustre.fail_loc=0x0
4002 LOCKED=$(grep -c locked $LPROC/llite/*/dump_page_cache)
4003 DIRTY=$(grep -c dirty $LPROC/llite/*/dump_page_cache)
4004 WRITEBACK=$(grep -c writeback $LPROC/llite/*/dump_page_cache)
4005 if [[ $LOCKED -ne 0 ]]; then
4006 error "Locked pages remain in cache, locked=$LOCKED"
4009 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
4010 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
4014 echo "No pages locked after fsync"
4019 run_test 118f "Simulate unrecoverable OSC side error ==========="
4024 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
4025 sysctl -w lustre.fail_loc=0x406
4027 # simulate local -ENOMEM
4028 multiop $DIR/$tfile Owy
4031 sysctl -w lustre.fail_loc=0
4032 if [[ $RC -eq 0 ]]; then
4033 error "Must return error due to dropped pages, rc=$RC"
4036 LOCKED=$(grep -c locked $LPROC/llite/*/dump_page_cache)
4037 DIRTY=$(grep -c dirty $LPROC/llite/*/dump_page_cache)
4038 WRITEBACK=$(grep -c writeback $LPROC/llite/*/dump_page_cache)
4039 if [[ $LOCKED -ne 0 ]]; then
4040 error "Locked pages remain in cache, locked=$LOCKED"
4043 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
4044 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
4048 echo "No pages locked after fsync"
4053 run_test 118g "Don't stay in wait if we got local -ENOMEM ======"
4058 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
4059 do_facet ost sysctl -w lustre.fail_loc=0x20e
4061 echo "10" > $LPROC/osc/resend_timeout
4062 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
4063 multiop $DIR/$tfile Owy
4066 do_facet ost sysctl -w lustre.fail_loc=0
4067 if [[ $RC -eq 0 ]]; then
4068 error "Must return error due to dropped pages, rc=$RC"
4071 LOCKED=$(grep -c locked $LPROC/llite/*/dump_page_cache)
4072 DIRTY=$(grep -c dirty $LPROC/llite/*/dump_page_cache)
4073 WRITEBACK=$(grep -c writeback $LPROC/llite/*/dump_page_cache)
4074 if [[ $LOCKED -ne 0 ]]; then
4075 error "Locked pages remain in cache, locked=$LOCKED"
4078 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
4079 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
4083 echo "No pages locked after fsync"
4088 run_test 118h "Verify timeout in handling recoverables errors =="
4093 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
4094 do_facet ost sysctl -w lustre.fail_loc=0x20e
4097 echo "10" > $LPROC/osc/resend_timeout
4098 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
4099 multiop $DIR/$tfile Owy &
4102 do_facet ost sysctl -w lustre.fail_loc=0
4106 if [[ $RC -ne 0 ]]; then
4107 error "got error, but should be not, rc=$RC"
4110 LOCKED=$(grep -c locked $LPROC/llite/*/dump_page_cache)
4111 DIRTY=$(grep -c dirty $LPROC/llite/*/dump_page_cache)
4112 WRITEBACK=$(grep -c writeback $LPROC/llite/*/dump_page_cache)
4113 if [[ $LOCKED -ne 0 ]]; then
4114 error "Locked pages remain in cache, locked=$LOCKED"
4117 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
4118 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
4122 echo "No pages locked after fsync"
4127 run_test 118i "Fix error before timeout in recoverable error ==="
4132 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
4133 do_facet ost sysctl -w lustre.fail_loc=0x220
4135 # return -EIO from OST
4136 multiop $DIR/$tfile Owy
4138 do_facet ost sysctl -w lustre.fail_loc=0x0
4139 if [[ $RC -eq 0 ]]; then
4140 error "Must return error due to dropped pages, rc=$RC"
4143 LOCKED=$(grep -c locked $LPROC/llite/*/dump_page_cache)
4144 DIRTY=$(grep -c dirty $LPROC/llite/*/dump_page_cache)
4145 WRITEBACK=$(grep -c writeback $LPROC/llite/*/dump_page_cache)
4146 if [[ $LOCKED -ne 0 ]]; then
4147 error "Locked pages remain in cache, locked=$LOCKED"
4150 # in recoverable error on OST we want resend and stay until it finished
4151 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
4152 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
4157 echo "No pages locked after fsync"
4162 run_test 118j "Simulate unrecoverable OST side error ==========="
4164 test_119a() # bug 11737
4166 BSIZE=$((512 * 1024))
4167 directio write $DIR/$tfile 0 1 $BSIZE
4168 # We ask to read two blocks, which is more than a file size.
4169 # directio will indicate an error when requested and actual
4170 # sizes aren't equeal (a normal situation in this case) and
4171 # print actual read amount.
4172 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
4173 if [ "$NOB" != "$BSIZE" ]; then
4174 error "read $NOB bytes instead of $BSIZE"
4178 run_test 119a "Short directIO read must return actual read amount"
4180 test_119b() # bug 11737
4182 [ "$OSTCOUNT" -lt "2" ] && echo "skipping 2-stripe test" && return
4184 lfs setstripe $DIR/$tfile 0 -1 2
4185 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
4187 multiop $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) || \
4188 error "direct read failed"
4190 run_test 119b "Sparse directIO read must return actual read amount"
4194 cancel_lru_locks mdc
4195 stat $DIR/$tdir > /dev/null
4196 can1=`awk '/ldlm_cancel/ {print $2}' $LPROC/ldlm/services/ldlm_canceld/stats`
4197 blk1=`awk '/ldlm_bl_callback/ {print $2}' $LPROC/ldlm/services/ldlm_cbd/stats`
4199 can2=`awk '/ldlm_cancel/ {print $2}' $LPROC/ldlm/services/ldlm_canceld/stats`
4200 blk2=`awk '/ldlm_bl_callback/ {print $2}' $LPROC/ldlm/services/ldlm_cbd/stats`
4201 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
4202 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
4204 run_test 120a "Early Lock Cancel: mkdir test ==================="
4208 cancel_lru_locks mdc
4209 stat $DIR/$tdir > /dev/null
4210 can1=`awk '/ldlm_cancel/ {print $2}' $LPROC/ldlm/services/ldlm_canceld/stats`
4211 blk1=`awk '/ldlm_bl_callback/ {print $2}' $LPROC/ldlm/services/ldlm_cbd/stats`
4213 blk2=`awk '/ldlm_bl_callback/ {print $2}' $LPROC/ldlm/services/ldlm_cbd/stats`
4214 can2=`awk '/ldlm_cancel/ {print $2}' $LPROC/ldlm/services/ldlm_canceld/stats`
4215 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
4216 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
4218 run_test 120b "Early Lock Cancel: create test =================="
4221 mkdir -p $DIR/$tdir/d1 $DIR/$tdir/d2
4222 touch $DIR/$tdir/d1/f1
4223 cancel_lru_locks mdc
4224 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
4225 can1=`awk '/ldlm_cancel/ {print $2}' $LPROC/ldlm/services/ldlm_canceld/stats`
4226 blk1=`awk '/ldlm_bl_callback/ {print $2}' $LPROC/ldlm/services/ldlm_cbd/stats`
4227 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
4228 can2=`awk '/ldlm_cancel/ {print $2}' $LPROC/ldlm/services/ldlm_canceld/stats`
4229 blk2=`awk '/ldlm_bl_callback/ {print $2}' $LPROC/ldlm/services/ldlm_cbd/stats`
4230 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
4231 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
4233 run_test 120c "Early Lock Cancel: link test ===================="
4237 cancel_lru_locks mdc
4238 stat $DIR/$tdir > /dev/null
4239 can1=`awk '/ldlm_cancel/ {print $2}' $LPROC/ldlm/services/ldlm_canceld/stats`
4240 blk1=`awk '/ldlm_bl_callback/ {print $2}' $LPROC/ldlm/services/ldlm_cbd/stats`
4241 chmod a+x $DIR/$tdir
4242 can2=`awk '/ldlm_cancel/ {print $2}' $LPROC/ldlm/services/ldlm_canceld/stats`
4243 blk2=`awk '/ldlm_bl_callback/ {print $2}' $LPROC/ldlm/services/ldlm_cbd/stats`
4244 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
4245 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
4247 run_test 120d "Early Lock Cancel: setattr test ================="
4251 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
4252 cancel_lru_locks mdc
4253 cancel_lru_locks osc
4254 dd if=$DIR/$tdir/f1 of=/dev/null
4255 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
4256 can1=`awk '/ldlm_cancel/ {print $2}' $LPROC/ldlm/services/ldlm_canceld/stats`
4257 blk1=`awk '/ldlm_bl_callback/ {print $2}' $LPROC/ldlm/services/ldlm_cbd/stats`
4258 unlink $DIR/$tdir/f1
4259 can2=`awk '/ldlm_cancel/ {print $2}' $LPROC/ldlm/services/ldlm_canceld/stats`
4260 blk2=`awk '/ldlm_bl_callback/ {print $2}' $LPROC/ldlm/services/ldlm_cbd/stats`
4261 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
4262 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
4264 run_test 120e "Early Lock Cancel: unlink test =================="
4267 mkdir -p $DIR/$tdir/d1 $DIR/$tdir/d2
4268 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
4269 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
4270 cancel_lru_locks mdc
4271 cancel_lru_locks osc
4272 dd if=$DIR/$tdir/d1/f1 of=/dev/null
4273 dd if=$DIR/$tdir/d2/f2 of=/dev/null
4274 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
4275 can1=`awk '/ldlm_cancel/ {print $2}' $LPROC/ldlm/services/ldlm_canceld/stats`
4276 blk1=`awk '/ldlm_bl_callback/ {print $2}' $LPROC/ldlm/services/ldlm_cbd/stats`
4277 mv $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
4278 can2=`awk '/ldlm_cancel/ {print $2}' $LPROC/ldlm/services/ldlm_canceld/stats`
4279 blk2=`awk '/ldlm_bl_callback/ {print $2}' $LPROC/ldlm/services/ldlm_cbd/stats`
4280 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
4281 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
4283 run_test 120f "Early Lock Cancel: rename test =================="
4287 echo create $count files
4289 cancel_lru_locks mdc
4290 cancel_lru_locks osc
4293 can0=`awk '/ldlm_cancel/ {print $2}' $LPROC/ldlm/services/ldlm_canceld/stats`
4294 blk0=`awk '/ldlm_bl_callback/ {print $2}' $LPROC/ldlm/services/ldlm_cbd/stats`
4295 createmany -o $DIR/$tdir/f $count
4297 can1=`awk '/ldlm_cancel/ {print $2}' $LPROC/ldlm/services/ldlm_canceld/stats`
4298 blk1=`awk '/ldlm_bl_callback/ {print $2}' $LPROC/ldlm/services/ldlm_cbd/stats`
4300 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
4301 echo rm $count files
4304 can2=`awk '/ldlm_cancel/ {print $2}' $LPROC/ldlm/services/ldlm_canceld/stats`
4305 blk2=`awk '/ldlm_bl_callback/ {print $2}' $LPROC/ldlm/services/ldlm_cbd/stats`
4307 echo total: $count removes in $((t2-t1))
4308 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
4310 # wait for commitment of removal
4312 run_test 120g "Early Lock Cancel: performance test ============="
4314 test_121() { #bug #10589
4316 writes=`dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk 'BEGIN { FS="+" } /out/ {print $1}'`
4317 sysctl -w lustre.fail_loc=0x310
4318 cancel_lru_locks osc > /dev/null
4319 reads=`dd if=$DIR/$tfile of=/dev/null 2>&1 | awk 'BEGIN { FS="+" } /in/ {print $1}'`
4320 sysctl -w lustre.fail_loc=0
4321 [ $reads -eq $writes ] || error "read" $reads "blocks, must be" $writes
4323 run_test 121 "read cancel race ================================="
4325 test_122() { #bug #11544
4326 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
4327 sysctl -w lustre.fail_loc=0x508
4328 dd if=/dev/zero of=$DIR/$tfile count=1
4330 sysctl -w lustre.fail_loc=0
4332 run_test 122 "fail client bulk callback (shouldn't LBUG) ======="
4338 log "cleanup: ======================================================"
4339 if [ "`mount | grep $MOUNT`" ]; then
4340 rm -rf $DIR/[Rdfs][1-9]*
4342 if [ "$I_MOUNTED" = "yes" ]; then
4343 cleanupall -f || error "cleanup failed"
4345 sysctl -w lnet.debug="$OLDDEBUG" 2> /dev/null || true
4349 echo '=========================== finished ==============================='
4350 [ -f "$SANITYLOG" ] && cat $SANITYLOG && exit 1 || true
4351 echo "$0: completed"