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 63 64b 71 73 77 101 107 108"
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}
42 MCREATE=${MCREATE:-mcreate}
43 OPENFILE=${OPENFILE:-openfile}
44 OPENUNLINK=${OPENUNLINK:-openunlink}
45 RANDOM_READS=${RANDOM_READS:-"random-reads"}
46 TOEXCL=${TOEXCL:-toexcl}
47 TRUNCATE=${TRUNCATE:-truncate}
48 MUNLINK=${MUNLINK:-munlink}
49 SOCKETSERVER=${SOCKETSERVER:-socketserver}
50 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
51 IOPENTEST1=${IOPENTEST1:-iopentest1}
52 IOPENTEST2=${IOPENTEST2:-iopentest2}
53 MEMHOG=${MEMHOG:-memhog}
54 DIRECTIO=${DIRECTIO:-directio}
55 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
56 UMOUNT=${UMOUNT:-"umount -d"}
58 if [ $UID -ne 0 ]; then
59 echo "Warning: running as non-root uid $UID"
63 RUNAS_ID=${RUNAS_ID:-500}
64 RUNAS=${RUNAS:-"runas -u $RUNAS_ID"}
66 # $RUNAS_ID may get set incorrectly somewhere else
67 if [ $RUNAS_ID -eq 0 ]; then
68 echo "Error: \$RUNAS_ID set to 0, but \$UID is also 0!"
73 SANITYLOG=${SANITYLOG:-/tmp/sanity.log}
75 export NAME=${NAME:-local}
79 LUSTRE=${LUSTRE:-`dirname $0`/..}
80 . $LUSTRE/tests/test-framework.sh
82 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
86 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
100 $LCTL mark "$*" 2> /dev/null || true
105 strace -o $TMP/$1.strace -ttt $*
107 log "FINISHED: $*: rc $RC"
112 check_kernel_version() {
113 VERSION_FILE=$LPROC/version
115 [ ! -f $VERSION_FILE ] && echo "can't find kernel version" && return 1
116 GOT_VER=$(awk '/kernel:/ {print $2}' $VERSION_FILE)
117 [ $GOT_VER == "patchless" ] && return 0
118 [ $GOT_VER -ge $WANT_VER ] && return 0
119 log "test needs at least kernel version $WANT_VER, running $GOT_VER"
128 IFS=abcdefghijklmnopqrstuvwxyz _basetest $1
132 if ! grep -q $DIR /proc/mounts; then
138 log "== test $testnum: $message= `date +%H:%M:%S` ($BEFORE)"
139 export TESTNAME=test_$testnum
140 export tfile=f${testnum}
142 test_${testnum} || error "exit with rc=$?"
144 pass "($((`date +%s` - $BEFORE))s)"
149 build_test_filter() {
150 [ "$ALWAYS_EXCEPT$EXCEPT$SANITY_EXCEPT" ] && \
151 echo "Skipping tests: `echo $ALWAYS_EXCEPT $EXCEPT $SANITY_EXCEPT`"
156 for E in $EXCEPT $ALWAYS_EXCEPT $SANITY_EXCEPT; do
157 eval EXCEPT_${E}=true
166 IFS=abcdefghijklmnopqrstuvwxyz _basetest $1
170 export base=`basetest $1`
173 if [ ${!testname}x != x ]; then
178 if [ ${!testname}x != x ]; then
186 if [ ${!testname}x != x ]; then
187 echo "skipping excluded test $1"
190 testname=EXCEPT_$base
191 if [ ${!testname}x != x ]; then
192 echo "skipping excluded test $1 (base $base)"
199 [ "$SANITYLOG" ] && rm -f $SANITYLOG || true
202 sysctl -w lustre.fail_loc=0
203 log "$0: FAIL: $TESTNAME $@"
204 $LCTL dk $TMP/lustre-log-$TESTNAME.log
205 if [ "$SANITYLOG" ]; then
206 echo "$0: FAIL: $TESTNAME $@" >> $SANITYLOG
210 sysctl -w lustre.fail_loc=0
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"
230 [ `echo $MOUNT | wc -w` -gt 1 ] && error "NAME=$NAME mounted more than once"
233 [ -z "`echo $DIR | grep $MOUNT`" ] && echo "$DIR not in $MOUNT" && exit 99
235 LOVNAME=`cat $LPROC/llite/*/lov/common_name | tail -n 1`
236 OSTCOUNT=`cat $LPROC/lov/$LOVNAME/numobd`
237 STRIPECOUNT=`cat $LPROC/lov/$LOVNAME/stripecount`
238 STRIPESIZE=`cat $LPROC/lov/$LOVNAME/stripesize`
239 ORIGFREE=`cat $LPROC/lov/$LOVNAME/kbytesavail`
240 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
241 MDS=$(\ls $LPROC/mds 2> /dev/null | grep -v num_refs | tail -n 1)
243 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
244 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
245 rm -rf $DIR/[Rdfs][1-9]*
249 echo "preparing for tests involving mounts"
250 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
252 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
253 echo # add a newline after mke2fs.
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 ============================"
605 chown $RUNAS_ID $DIR/d22
606 # Tar gets pissy if it can't access $PWD *sigh*
607 (cd $TMP || error "cd $TMP failed";
608 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
609 $RUNAS tar xfC - $DIR/d22)
610 ls -lR $DIR/d22/etc || error "ls -lR $DIR/d22/etc failed"
611 $CHECKSTAT -t dir $DIR/d22/etc || error "checkstat -t dir failed"
612 $CHECKSTAT -u \#$RUNAS_ID $DIR/d22/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"
1128 $CREATETEST $DIR/d28/ct || error
1130 run_test 28 "create/mknod/mkdir with bad file types ============"
1133 cancel_lru_locks mdc
1138 MDCDIR=${MDCDIR:-`find $LPROC/ldlm/namespaces | grep mdc | head -1`}
1139 LOCKCOUNTORIG=`cat $MDCDIR/lock_count`
1140 LOCKUNUSEDCOUNTORIG=`cat $MDCDIR/lock_unused_count`
1141 [ -z $"LOCKCOUNTORIG" ] && echo "No mdc lock count" && return 1
1145 LOCKCOUNTCURRENT=`cat $MDCDIR/lock_count`
1146 LOCKUNUSEDCOUNTCURRENT=`cat $MDCDIR/lock_unused_count`
1147 if [ "$LOCKCOUNTCURRENT" -gt "$LOCKCOUNTORIG" ]; then
1148 echo > $LPROC/ldlm/dump_namespaces
1149 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
1150 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1151 log "dumped log to $TMP/test_29.dk (bug 5793)"
1154 if [ "$LOCKUNUSEDCOUNTCURRENT" -gt "$LOCKUNUSEDCOUNTORIG" ]; then
1155 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
1156 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1157 log "dumped log to $TMP/test_29.dk (bug 5793)"
1161 run_test 29 "IT_GETATTR regression ============================"
1168 run_test 30 "run binary from Lustre (execve) ==================="
1171 $OPENUNLINK $DIR/f31 $DIR/f31 || error
1172 $CHECKSTAT -a $DIR/f31 || error
1174 run_test 31a "open-unlink file =================================="
1177 touch $DIR/f31 || error
1178 ln $DIR/f31 $DIR/f31b || error
1179 multiop $DIR/f31b Ouc || error
1180 $CHECKSTAT -t file $DIR/f31 || error
1182 run_test 31b "unlink file with multiple links while open ======="
1185 touch $DIR/f31 || error
1186 ln $DIR/f31 $DIR/f31c || error
1187 multiop $DIR/f31 O_uc &
1189 multiop $DIR/f31c Ouc
1191 kill -USR1 $MULTIPID
1194 run_test 31c "open-unlink file with multiple links ============="
1197 opendirunlink $DIR/d31d $DIR/d31d || error
1198 $CHECKSTAT -a $DIR/d31d || error
1200 run_test 31d "remove of open directory ========================="
1202 test_31e() { # bug 2904
1203 check_kernel_version 34 || return 0
1204 openfilleddirunlink $DIR/d31e || error
1206 run_test 31e "remove of open non-empty directory ==============="
1208 test_31f() { # bug 4554
1211 lfs setstripe $DIR/d31f 1048576 -1 1
1212 cp /etc/hosts $DIR/d31f
1214 lfs getstripe $DIR/d31f/hosts
1215 multiop $DIR/d31f D_c &
1220 rm -rv $DIR/d31f || error "first of $DIR/d31f"
1222 lfs setstripe $DIR/d31f 1048576 -1 1
1223 cp /etc/hosts $DIR/d31f
1225 lfs getstripe $DIR/d31f/hosts
1226 multiop $DIR/d31f D_c &
1231 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
1232 wait $MULTIPID || error "first opendir $MULTIPID failed"
1236 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
1237 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
1240 run_test 31f "remove of open directory with open-unlink file ==="
1243 echo "== more mountpoints and symlinks ================="
1244 [ -e $DIR/d32a ] && rm -fr $DIR/d32a
1245 mkdir -p $DIR/d32a/ext2-mountpoint
1246 mount -t ext2 -o loop $EXT2_DEV $DIR/d32a/ext2-mountpoint || error
1247 $CHECKSTAT -t dir $DIR/d32a/ext2-mountpoint/.. || error
1248 $UMOUNT $DIR/d32a/ext2-mountpoint || error
1250 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
1253 [ -e $DIR/d32b ] && rm -fr $DIR/d32b
1254 mkdir -p $DIR/d32b/ext2-mountpoint
1255 mount -t ext2 -o loop $EXT2_DEV $DIR/d32b/ext2-mountpoint || error
1256 ls -al $DIR/d32b/ext2-mountpoint/.. || error
1257 $UMOUNT $DIR/d32b/ext2-mountpoint || error
1259 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
1262 [ -e $DIR/d32c ] && rm -fr $DIR/d32c
1263 mkdir -p $DIR/d32c/ext2-mountpoint
1264 mount -t ext2 -o loop $EXT2_DEV $DIR/d32c/ext2-mountpoint || error
1265 mkdir -p $DIR/d32c/d2/test_dir
1266 $CHECKSTAT -t dir $DIR/d32c/ext2-mountpoint/../d2/test_dir || error
1267 $UMOUNT $DIR/d32c/ext2-mountpoint || error
1269 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
1272 [ -e $DIR/d32d ] && rm -fr $DIR/d32d
1273 mkdir -p $DIR/d32d/ext2-mountpoint
1274 mount -t ext2 -o loop $EXT2_DEV $DIR/d32d/ext2-mountpoint || error
1275 mkdir -p $DIR/d32d/d2/test_dir
1276 ls -al $DIR/d32d/ext2-mountpoint/../d2/test_dir || error
1277 $UMOUNT $DIR/d32d/ext2-mountpoint || error
1279 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
1282 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
1283 mkdir -p $DIR/d32e/tmp
1284 TMP_DIR=$DIR/d32e/tmp
1285 ln -s $DIR/d32e $TMP_DIR/symlink11
1286 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1287 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
1288 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
1290 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
1293 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
1294 mkdir -p $DIR/d32f/tmp
1295 TMP_DIR=$DIR/d32f/tmp
1296 ln -s $DIR/d32f $TMP_DIR/symlink11
1297 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1298 ls $DIR/d32f/tmp/symlink11 || error
1299 ls $DIR/d32f/symlink01 || error
1301 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
1304 TMP_DIR=$DIR/$tdir/tmp
1305 mkdir -p $TMP_DIR $DIR/${tdir}2
1306 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
1307 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1308 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
1309 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
1310 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
1311 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
1313 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
1316 rm -fr $DIR/$tdir $DIR/${tdir}2
1317 TMP_DIR=$DIR/$tdir/tmp
1318 mkdir -p $TMP_DIR $DIR/${tdir}2
1319 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
1320 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1321 ls $TMP_DIR/symlink12 || error
1322 ls $DIR/$tdir/symlink02 || error
1324 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
1327 [ -e $DIR/d32i ] && rm -fr $DIR/d32i
1328 mkdir -p $DIR/d32i/ext2-mountpoint
1329 mount -t ext2 -o loop $EXT2_DEV $DIR/d32i/ext2-mountpoint || error
1330 touch $DIR/d32i/test_file
1331 $CHECKSTAT -t file $DIR/d32i/ext2-mountpoint/../test_file || error
1332 $UMOUNT $DIR/d32i/ext2-mountpoint || error
1334 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
1337 [ -e $DIR/d32j ] && rm -fr $DIR/d32j
1338 mkdir -p $DIR/d32j/ext2-mountpoint
1339 mount -t ext2 -o loop $EXT2_DEV $DIR/d32j/ext2-mountpoint || error
1340 touch $DIR/d32j/test_file
1341 cat $DIR/d32j/ext2-mountpoint/../test_file || error
1342 $UMOUNT $DIR/d32j/ext2-mountpoint || error
1344 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
1348 mkdir -p $DIR/d32k/ext2-mountpoint
1349 mount -t ext2 -o loop $EXT2_DEV $DIR/d32k/ext2-mountpoint
1350 mkdir -p $DIR/d32k/d2
1351 touch $DIR/d32k/d2/test_file || error
1352 $CHECKSTAT -t file $DIR/d32k/ext2-mountpoint/../d2/test_file || error
1353 $UMOUNT $DIR/d32k/ext2-mountpoint || error
1355 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
1359 mkdir -p $DIR/d32l/ext2-mountpoint
1360 mount -t ext2 -o loop $EXT2_DEV $DIR/d32l/ext2-mountpoint || error
1361 mkdir -p $DIR/d32l/d2
1362 touch $DIR/d32l/d2/test_file
1363 cat $DIR/d32l/ext2-mountpoint/../d2/test_file || error
1364 $UMOUNT $DIR/d32l/ext2-mountpoint || error
1366 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
1370 mkdir -p $DIR/d32m/tmp
1371 TMP_DIR=$DIR/d32m/tmp
1372 ln -s $DIR $TMP_DIR/symlink11
1373 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1374 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
1375 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
1377 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
1381 mkdir -p $DIR/d32n/tmp
1382 TMP_DIR=$DIR/d32n/tmp
1383 ln -s $DIR $TMP_DIR/symlink11
1384 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1385 ls -l $DIR/d32n/tmp/symlink11 || error
1386 ls -l $DIR/d32n/symlink01 || error
1388 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
1391 rm -fr $DIR/d32o $DIR/$tfile
1393 mkdir -p $DIR/d32o/tmp
1394 TMP_DIR=$DIR/d32o/tmp
1395 ln -s $DIR/$tfile $TMP_DIR/symlink12
1396 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1397 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
1398 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
1399 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
1400 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
1402 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
1412 mkdir -p $DIR/d32p/tmp
1414 TMP_DIR=$DIR/d32p/tmp
1416 ln -s $DIR/$tfile $TMP_DIR/symlink12
1418 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1420 cat $DIR/d32p/tmp/symlink12 || error
1422 cat $DIR/d32p/symlink02 || error
1425 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
1428 [ -e $DIR/d32q ] && rm -fr $DIR/d32q
1430 touch $DIR/d32q/under_the_mount
1431 mount -t ext2 -o loop $EXT2_DEV $DIR/d32q
1432 ls $DIR/d32q/under_the_mount && error || true
1433 $UMOUNT $DIR/d32q || error
1435 run_test 32q "stat follows mountpoints in Lustre (should return error)"
1438 [ -e $DIR/d32r ] && rm -fr $DIR/d32r
1440 touch $DIR/d32r/under_the_mount
1441 mount -t ext2 -o loop $EXT2_DEV $DIR/d32r
1442 ls $DIR/d32r | grep -q under_the_mount && error || true
1443 $UMOUNT $DIR/d32r || error
1445 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
1450 chmod 444 $DIR/$tfile
1451 chown $RUNAS_ID $DIR/$tfile
1453 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
1456 run_test 33 "write file with mode 444 (should return error) ===="
1461 chown $RUNAS_ID $DIR/d33
1462 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
1463 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
1464 error "open RDWR" || true
1466 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
1468 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
1471 $MCREATE $DIR/f34 || error
1472 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
1473 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
1474 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
1475 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1477 run_test 34a "truncate file that has not been opened ==========="
1480 [ ! -f $DIR/f34 ] && test_34a
1481 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1482 $OPENFILE -f O_RDONLY $DIR/f34
1483 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
1484 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1486 run_test 34b "O_RDONLY opening file doesn't create objects ====="
1489 [ ! -f $DIR/f34 ] && test_34a
1490 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1491 $OPENFILE -f O_RDWR $DIR/f34
1492 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
1493 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1495 run_test 34c "O_RDWR opening file-with-size works =============="
1498 [ ! -f $DIR/f34 ] && test_34a
1499 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
1500 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1503 run_test 34d "write to sparse file ============================="
1507 $MCREATE $DIR/f34e || error
1508 $TRUNCATE $DIR/f34e 1000 || error
1509 $CHECKSTAT -s 1000 $DIR/f34e || error
1510 $OPENFILE -f O_RDWR $DIR/f34e
1511 $CHECKSTAT -s 1000 $DIR/f34e || error
1513 run_test 34e "create objects, some with size and some without =="
1515 test_34f() { # bug 6242, 6243
1518 $MCREATE $DIR/f34f || error
1519 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
1520 dd if=$DIR/f34f of=$TMP/f34f
1521 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
1522 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
1523 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
1524 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
1525 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
1527 run_test 34f "read from a file with no objects until EOF ======="
1530 cp /bin/sh $DIR/f35a
1532 chown $RUNAS_ID $DIR/f35a
1533 $RUNAS $DIR/f35a && error || true
1536 run_test 35a "exec file with mode 444 (should return and not leak) ====="
1540 utime $DIR/f36 || error
1542 run_test 36a "MDS utime check (mknod, utime) ==================="
1546 utime $DIR/f36 || error
1548 run_test 36b "OST utime check (open, utime) ===================="
1553 chown $RUNAS_ID $DIR/d36
1554 $RUNAS utime $DIR/d36/f36 || error
1556 run_test 36c "non-root MDS utime check (mknod, utime) =========="
1559 [ ! -d $DIR/d36 ] && test_36c
1560 echo "" > $DIR/d36/f36
1561 $RUNAS utime $DIR/d36/f36 || error
1563 run_test 36d "non-root OST utime check (open, utime) ==========="
1566 [ $RUNAS_ID -eq $UID ] && echo "skipping $TESTNAME" && return
1568 touch $DIR/$tdir/$tfile
1569 $RUNAS utime $DIR/$tdir/$tfile && \
1570 error "utime worked, expected failure" || true
1572 run_test 36e "utime on non-owned file (should return error) ===="
1575 export LANG=C LC_LANG=C # for date language
1577 DATESTR="Dec 20 2000"
1579 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
1580 sysctl -w lustre.fail_loc=0x80000214
1582 cp /etc/hosts $DIR/$tdir/$tfile
1583 sync & # write RPC generated with "current" inode timestamp, but delayed
1585 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
1586 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
1587 cancel_lru_locks osc
1588 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
1590 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
1591 echo "BEFORE: $LS_BEFORE" && \
1592 echo "AFTER : $LS_AFTER" && \
1593 echo "WANT : $DATESTR" && \
1594 error "$DIR/$tdir/$tfile timestamps changed" || true
1596 run_test 36f "utime on file racing with OST BRW write =========="
1598 export FMD_MAX_AGE=`cat $LPROC/obdfilter/*/client_cache_seconds 2> /dev/null | head -n 1`
1600 [ -z "$FMD_MAX_AGE" ] && echo "skip $TESTNAME for remote OST" && return
1601 FMD_BEFORE="`awk '/ll_fmd_cache/ { print $2 }' /proc/slabinfo`"
1602 touch $DIR/d36/$tfile
1603 sleep $((FMD_MAX_AGE + 12))
1604 FMD_AFTER="`awk '/ll_fmd_cache/ { print $2 }' /proc/slabinfo`"
1605 [ "$FMD_AFTER" -gt "$FMD_BEFORE" ] && \
1606 echo "AFTER : $FMD_AFTER > BEFORE $FMD_BEFORE" && \
1607 error "fmd didn't expire after ping" || true
1609 run_test 36g "filter mod data cache expiry ====================="
1613 echo f > $DIR/$tdir/fbugfile
1614 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
1615 ls $DIR/$tdir | grep "\<fbugfile\>" && error
1616 $UMOUNT $DIR/$tdir || error
1617 rm -f $DIR/$tdir/fbugfile || error
1619 run_test 37 "ls a mounted file system to check old content ====="
1622 o_directory $DIR/$tfile
1624 run_test 38 "open a regular file with O_DIRECTORY =============="
1628 touch $DIR/${tfile}2
1629 # ls -l $DIR/$tfile $DIR/${tfile}2
1630 # ls -lu $DIR/$tfile $DIR/${tfile}2
1631 # ls -lc $DIR/$tfile $DIR/${tfile}2
1633 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
1634 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
1636 ls -l $DIR/$tfile $DIR/${tfile}2
1638 ls -lu $DIR/$tfile $DIR/${tfile}2
1640 ls -lc $DIR/$tfile $DIR/${tfile}2
1641 error "O_TRUNC didn't change timestamps"
1644 run_test 39 "mtime changed on create ==========================="
1647 dd if=/dev/zero of=$DIR/f40 bs=4096 count=1
1648 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/f40 && error
1649 $CHECKSTAT -t file -s 4096 $DIR/f40 || error
1651 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
1655 small_write $DIR/f41 18
1657 run_test 41 "test small file write + fstat ====================="
1659 count_ost_writes() {
1660 cat $LPROC/osc/*/stats |
1661 awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }'
1669 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs
1670 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
1671 echo $WRITEBACK_SAVE > /proc/sys/vm/dirty_writeback_centisecs
1673 # if file not here, we are a 2.4 kernel
1674 kill -CONT `pidof kupdated`
1678 # setup the trap first, so someone cannot exit the test at the
1679 # exact wrong time and mess up a machine
1680 trap start_writeback EXIT
1681 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
1682 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
1683 WRITEBACK_SAVE=`cat /proc/sys/vm/dirty_writeback_centisecs`
1684 echo 0 > /proc/sys/vm/dirty_writeback_centisecs
1686 # if file not here, we are a 2.4 kernel
1687 kill -STOP `pidof kupdated`
1691 # ensure that all stripes have some grant before we test client-side cache
1693 [ "$SETUP_TEST42" ] && return
1694 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
1695 dd if=/dev/zero of=$i bs=4k count=1
1701 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
1702 # file truncation, and file removal.
1705 cancel_lru_locks osc
1707 sync; sleep 1; sync # just to be safe
1708 BEFOREWRITES=`count_ost_writes`
1709 grep "[0-9]" $LPROC/osc/*[oO][sS][cC]*/cur_grant_bytes
1710 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
1711 AFTERWRITES=`count_ost_writes`
1712 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
1713 error "$BEFOREWRITES < $AFTERWRITES"
1716 run_test 42a "ensure that we don't flush on close =============="
1720 cancel_lru_locks osc
1723 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
1724 BEFOREWRITES=`count_ost_writes`
1725 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
1726 AFTERWRITES=`count_ost_writes`
1727 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
1728 error "$BEFOREWRITES < $AFTERWRITES on unlink"
1730 BEFOREWRITES=`count_ost_writes`
1731 sync || error "sync: $?"
1732 AFTERWRITES=`count_ost_writes`
1733 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
1734 error "$BEFOREWRITES < $AFTERWRITES on sync"
1736 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
1740 run_test 42b "test destroy of file with cached dirty data ======"
1742 # if these tests just want to test the effect of truncation,
1743 # they have to be very careful. consider:
1744 # - the first open gets a {0,EOF}PR lock
1745 # - the first write conflicts and gets a {0, count-1}PW
1746 # - the rest of the writes are under {count,EOF}PW
1747 # - the open for truncate tries to match a {0,EOF}PR
1748 # for the filesize and cancels the PWs.
1749 # any number of fixes (don't get {0,EOF} on open, match
1750 # composite locks, do smarter file size management) fix
1751 # this, but for now we want these tests to verify that
1752 # the cancellation with truncate intent works, so we
1753 # start the file with a full-file pw lock to match against
1754 # until the truncate.
1759 cancel_lru_locks osc
1761 # prime the file with 0,EOF PW to match
1765 # now the real test..
1766 dd if=/dev/zero of=$file bs=1024 count=100
1767 BEFOREWRITES=`count_ost_writes`
1768 $TRUNCATE $file $offset
1769 cancel_lru_locks osc
1770 AFTERWRITES=`count_ost_writes`
1776 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
1777 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
1780 run_test 42c "test partial truncate of file with cached dirty data"
1784 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
1785 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
1788 run_test 42d "test complete truncate of file with cached dirty data"
1792 cp -p /bin/ls $DIR/$tdir/$tfile
1793 exec 100>> $DIR/$tdir/$tfile
1794 $DIR/$tdir/$tfile && error || true
1797 run_test 43 "execution of file opened for write should return -ETXTBSY"
1801 cp -p `which multiop` $DIR/d43/multiop
1802 $DIR/d43/multiop $TMP/test43.junk O_c &
1805 multiop $DIR/d43/multiop Oc && error "expected error, got success"
1806 kill -USR1 $MULTIPID || return 2
1807 wait $MULTIPID || return 3
1810 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
1814 cp -p `which multiop` $DIR/d43/multiop
1815 $DIR/d43/multiop $TMP/test43.junk O_c &
1818 truncate $DIR/d43/multiop 0 && error "expected error, got success"
1819 kill -USR1 $MULTIPID || return 2
1820 wait $MULTIPID || return 3
1823 run_test 43b "truncate of file being executed should return -ETXTBSY"
1826 local testdir="$DIR/d43c"
1829 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
1830 ( cd $testdir && md5sum -c)
1832 run_test 43c "md5sum of copy into lustre========================"
1835 [ "$OSTCOUNT" -lt "2" ] && echo "skipping 2-stripe test" && return
1836 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
1837 dd if=$DIR/f1 bs=4k count=1
1839 run_test 44 "zero length read from a sparse stripe ============="
1842 local nstripe=`$LCTL lov_getconfig $DIR | grep default_stripe_count: | \
1844 local stride=`$LCTL lov_getconfig $DIR | grep default_stripe_size: | \
1846 if [ $nstripe -eq 0 ] ; then
1847 nstripe=`$LCTL lov_getconfig $DIR | grep obd_count: | awk '{print $2}'`
1849 [ -z "$nstripe" ] && error "can't get stripe info"
1851 OFFSETS="0 $((stride/2)) $((stride-1))"
1852 for offset in $OFFSETS ; do
1853 for i in `seq 0 $((nstripe-1))`; do
1855 local GLOBALOFFSETS=""
1856 local size=$((((i + 2 * $nstripe )*$stride + $offset))) # Bytes
1857 ll_sparseness_write $DIR/d44a $size || error "ll_sparseness_write"
1858 GLOBALOFFSETS="$GLOBALOFFSETS $size"
1859 ll_sparseness_verify $DIR/d44a $GLOBALOFFSETS \
1860 || error "ll_sparseness_verify $GLOBALOFFSETS"
1862 for j in `seq 0 $((nstripe-1))`; do
1863 size=$((((j + $nstripe )*$stride + $offset))) # Bytes
1864 ll_sparseness_write $DIR/d44a $size || error "ll_sparseness_write"
1865 GLOBALOFFSETS="$GLOBALOFFSETS $size"
1867 ll_sparseness_verify $DIR/d44a $GLOBALOFFSETS \
1868 || error "ll_sparseness_verify $GLOBALOFFSETS"
1872 run_test 44a "test sparse pwrite ==============================="
1876 for d in $LPROC/osc/*/cur_dirty_bytes; do
1877 tot=$(($tot + `cat $d`))
1882 before=`dirty_osc_total`
1883 echo executing "\"$*\""
1885 after=`dirty_osc_total`
1886 echo before $before, after $after
1890 # Obtain grants from OST if it supports it
1891 echo blah > ${f}_grant
1894 do_dirty_record "echo blah > $f"
1895 [ $before -eq $after ] && error "write wasn't cached"
1896 do_dirty_record "> $f"
1897 [ $before -gt $after ] || error "truncate didn't lower dirty count"
1898 do_dirty_record "echo blah > $f"
1899 [ $before -eq $after ] && error "write wasn't cached"
1900 do_dirty_record "sync"
1901 [ $before -gt $after ] || error "writeback didn't lower dirty count"
1902 do_dirty_record "echo blah > $f"
1903 [ $before -eq $after ] && error "write wasn't cached"
1904 do_dirty_record "cancel_lru_locks osc"
1905 [ $before -gt $after ] || error "lock cancellation didn't lower dirty count"
1908 run_test 45 "osc io page accounting ============================"
1914 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
1915 # test tickles a bug where re-dirtying a page was failing to be mapped to the
1916 # objects offset and an assert hit when an rpc was built with 1023's mapped
1917 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
1922 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
1924 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
1925 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
1929 run_test 46 "dirtying a previously written page ================"
1931 # Check that device nodes are created and then visible correctly (#2091)
1933 cmknod $DIR/test_47_node || error
1935 run_test 47 "Device nodes check ================================"
1937 test_48a() { # bug 2399
1938 check_kernel_version 34 || return 0
1941 mv $DIR/d48a $DIR/d48.new || error "move directory failed"
1942 mkdir $DIR/d48a || error "recreate directory failed"
1943 touch foo || error "'touch foo' failed after recreating cwd"
1944 mkdir bar || error "'mkdir foo' failed after recreating cwd"
1945 if check_kernel_version 44; then
1946 touch .foo || error "'touch .foo' failed after recreating cwd"
1947 mkdir .bar || error "'mkdir .foo' failed after recreating cwd"
1949 ls . || error "'ls .' failed after recreating cwd"
1950 ls .. || error "'ls ..' failed after removing cwd"
1951 cd . || error "'cd .' failed after recreating cwd"
1952 mkdir . && error "'mkdir .' worked after recreating cwd"
1953 rmdir . && error "'rmdir .' worked after recreating cwd"
1954 ln -s . baz || error "'ln -s .' failed after recreating cwd"
1955 cd .. || error "'cd ..' failed after recreating cwd"
1957 run_test 48a "Access renamed working dir (should return errors)="
1959 test_48b() { # bug 2399
1960 check_kernel_version 34 || return 0
1963 rmdir $DIR/d48b || error "remove cwd $DIR/d48b failed"
1964 touch foo && error "'touch foo' worked after removing cwd"
1965 mkdir foo && error "'mkdir foo' worked after removing cwd"
1966 if check_kernel_version 44; then
1967 touch .foo && error "'touch .foo' worked after removing cwd"
1968 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
1970 ls . && error "'ls .' worked after removing cwd"
1971 ls .. || error "'ls ..' failed after removing cwd"
1972 cd . && error "'cd .' worked after removing cwd"
1973 mkdir . && error "'mkdir .' worked after removing cwd"
1974 rmdir . && error "'rmdir .' worked after removing cwd"
1975 ln -s . foo && error "'ln -s .' worked after removing cwd"
1976 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
1978 run_test 48b "Access removed working dir (should return errors)="
1980 test_48c() { # bug 2350
1981 check_kernel_version 36 || return 0
1982 #sysctl -w lnet.debug=-1
1984 mkdir -p $DIR/d48c/dir
1986 $TRACE rmdir $DIR/d48c/dir || error "remove cwd $DIR/d48c/dir failed"
1987 $TRACE touch foo && error "'touch foo' worked after removing cwd"
1988 $TRACE mkdir foo && error "'mkdir foo' worked after removing cwd"
1989 if check_kernel_version 44; then
1990 touch .foo && error "'touch .foo' worked after removing cwd"
1991 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
1993 $TRACE ls . && error "'ls .' worked after removing cwd"
1994 $TRACE ls .. || error "'ls ..' failed after removing cwd"
1995 $TRACE cd . && error "'cd .' worked after removing cwd"
1996 $TRACE mkdir . && error "'mkdir .' worked after removing cwd"
1997 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
1998 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
1999 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
2001 run_test 48c "Access removed working subdir (should return errors)"
2003 test_48d() { # bug 2350
2004 check_kernel_version 36 || return 0
2005 #sysctl -w lnet.debug=-1
2007 mkdir -p $DIR/d48d/dir
2009 $TRACE rmdir $DIR/d48d/dir || error "remove cwd $DIR/d48d/dir failed"
2010 $TRACE rmdir $DIR/d48d || error "remove parent $DIR/d48d failed"
2011 $TRACE touch foo && error "'touch foo' worked after removing parent"
2012 $TRACE mkdir foo && error "'mkdir foo' worked after removing parent"
2013 if check_kernel_version 44; then
2014 touch .foo && error "'touch .foo' worked after removing parent"
2015 mkdir .foo && error "'mkdir .foo' worked after removing parent"
2017 $TRACE ls . && error "'ls .' worked after removing parent"
2018 $TRACE ls .. && error "'ls ..' worked after removing parent"
2019 $TRACE cd . && error "'cd .' worked after recreate parent"
2020 $TRACE mkdir . && error "'mkdir .' worked after removing parent"
2021 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
2022 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
2023 $TRACE cd .. && error "'cd ..' worked after removing parent" || true
2025 run_test 48d "Access removed parent subdir (should return errors)"
2027 test_48e() { # bug 4134
2028 check_kernel_version 41 || return 0
2029 #sysctl -w lnet.debug=-1
2031 mkdir -p $DIR/d48e/dir
2033 $TRACE rmdir $DIR/d48e/dir || error "remove cwd $DIR/d48e/dir failed"
2034 $TRACE rmdir $DIR/d48e || error "remove parent $DIR/d48e failed"
2035 $TRACE touch $DIR/d48e || error "'touch $DIR/d48e' failed"
2036 $TRACE chmod +x $DIR/d48e || error "'chmod +x $DIR/d48e' failed"
2037 # On a buggy kernel addition of "touch foo" after cd .. will
2038 # produce kernel oops in lookup_hash_it
2039 touch ../foo && error "'cd ..' worked after recreate parent"
2041 $TRACE rm $DIR/d48e || error "rm '$DIR/d48e' failed"
2043 run_test 48e "Access to recreated parent subdir (should return errors)"
2049 ls /proc/$$/cwd || error
2051 run_test 50 "special situations: /proc symlinks ==============="
2054 # bug 1516 - create an empty entry right after ".." then split dir
2057 $MCREATE $DIR/d51/bar
2059 createmany -m $DIR/d51/longfile 201
2061 while [ `ls -sd $DIR/d51 | awk '{ print $1 }'` -eq 4 ]; do
2062 $MCREATE $DIR/d51/longfile$FNUM
2066 ls -l $DIR/d51 > /dev/null || error
2068 run_test 51 "special situations: split htree with empty entry =="
2070 export NUMTEST=70000
2072 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
2073 [ $NUMFREE -lt 21000 ] && \
2074 echo "skipping $TESTNAME, not enough free inodes ($NUMFREE)" && \
2077 check_kernel_version 40 || NUMTEST=31000
2078 [ $NUMFREE -lt $NUMTEST ] && NUMTEST=$(($NUMFREE - 50))
2081 createmany -d $DIR/d51b/t- $NUMTEST
2083 run_test 51b "mkdir .../t-0 --- .../t-$NUMTEST ===================="
2086 [ ! -d $DIR/d51b ] && echo "skipping $TESTNAME: $DIR/51b missing" && \
2089 unlinkmany -d $DIR/d51b/t- $NUMTEST
2091 run_test 51c "rmdir .../t-0 --- .../t-$NUMTEST ===================="
2094 [ "$OSTCOUNT" -lt "3" ] && echo "skipping test with few OSTs" && return
2096 createmany -o $DIR/d51d/t- 1000
2097 $LFS getstripe $DIR/d51d > $TMP/files
2098 for N in `seq 0 $((OSTCOUNT - 1))`; do
2099 OBJS[$N]=`awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}' $TMP/files`
2100 OBJS0[$N]=`grep -A 1 idx $TMP/files | awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}'`
2101 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
2103 unlinkmany $DIR/d51d/t- 1000
2106 for N in `seq 1 $((OSTCOUNT - 1))`; do
2107 [ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ] && \
2108 error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
2109 [ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ] && \
2110 error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
2112 [ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ] && \
2113 error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
2114 [ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ] && \
2115 error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
2119 run_test 51d "check object distribution ===================="
2122 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
2125 chattr =a $DIR/d52a/foo || error "chattr =a failed"
2126 echo bar >> $DIR/d52a/foo || error "append bar failed"
2127 cp /etc/hosts $DIR/d52a/foo && error "cp worked"
2128 rm -f $DIR/d52a/foo 2>/dev/null && error "rm worked"
2129 link $DIR/d52a/foo $DIR/d52a/foo_link 2>/dev/null && error "link worked"
2130 echo foo >> $DIR/d52a/foo || error "append foo failed"
2131 mrename $DIR/d52a/foo $DIR/d52a/foo_ren && error "rename worked"
2132 lsattr $DIR/d52a/foo | egrep -q "^-+a-+ $DIR/d52a/foo" || error "lsattr"
2133 chattr -a $DIR/d52a/foo || error "chattr -a failed"
2135 rm -fr $DIR/d52a || error "cleanup rm failed"
2137 run_test 52a "append-only flag test (should return errors) ====="
2140 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
2143 chattr =i $DIR/d52b/foo || error
2144 cat test > $DIR/d52b/foo && error
2145 cp /etc/hosts $DIR/d52b/foo && error
2146 rm -f $DIR/d52b/foo 2>/dev/null && error
2147 link $DIR/d52b/foo $DIR/d52b/foo_link 2>/dev/null && error
2148 echo foo >> $DIR/d52b/foo && error
2149 mrename $DIR/d52b/foo $DIR/d52b/foo_ren && error
2150 [ -f $DIR/d52b/foo ] || error
2151 [ -f $DIR/d52b/foo_ren ] && error
2152 lsattr $DIR/d52b/foo | egrep -q "^-+i-+ $DIR/d52b/foo" || error
2153 chattr -i $DIR/d52b/foo || error
2155 rm -fr $DIR/d52b || error
2157 run_test 52b "immutable flag test (should return errors) ======="
2160 [ -z "$MDS" ] && echo "skipping $TESTNAME with remote MDS" && return
2162 for i in `ls -d $LPROC/osc/*-osc 2> /dev/null` ; do
2163 ostname=`basename $i | cut -d - -f 1-2`
2164 ost_last=`cat $LPROC/obdfilter/$ostname/last_id`
2165 mds_last=`cat $i/prealloc_last_id`
2166 echo "$ostname.last_id=$ost_last ; MDS.last_id=$mds_last"
2167 if [ $ost_last != $mds_last ]; then
2168 error "$ostname.last_id=$ost_last ; MDS.last_id=$mds_last"
2172 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
2175 [ ! -f "$SOCKETSERVER" ] && echo "no socketserver, skipping" && return
2176 [ ! -f "$SOCKETCLIENT" ] && echo "no socketclient, skipping" && return
2177 $SOCKETSERVER $DIR/socket
2178 $SOCKETCLIENT $DIR/socket || error
2179 $MUNLINK $DIR/socket
2181 run_test 54a "unix domain socket test =========================="
2187 dd if=/dev/zero of=$f bs=`page_size` count=1
2189 run_test 54b "char device works in lustre ======================"
2192 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
2193 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
2194 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
2196 for i in `seq 3 7`; do
2197 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
2207 loopdev="$DIR/loop54c"
2210 [ -z "$LOOPNUM" ] && echo "couldn't find empty loop device" && return
2211 mknod $loopdev b 7 $LOOPNUM
2212 echo "make a loop file system with $tfile on $loopdev ($LOOPNUM)..."
2213 dd if=/dev/zero of=$tfile bs=`page_size` seek=1024 count=1 > /dev/null
2214 losetup $loopdev $tfile || error "can't set up $loopdev for $tfile"
2215 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
2217 mount -t ext2 $loopdev $tdir || error "error mounting $loopdev on $tdir"
2218 dd if=/dev/zero of=$tdir/tmp bs=`page_size` count=30 || error "dd write"
2220 dd if=$tdir/tmp of=/dev/zero bs=`page_size` count=30 || error "dd read"
2225 run_test 54c "block device works in lustre ====================="
2231 [ "$string" = `echo $string > $f | cat $f` ] || error
2233 run_test 54d "fifo device works in lustre ======================"
2236 check_kernel_version 46 || return 0
2240 echo $string > $f || error
2242 run_test 54e "console/tty device works in lustre ======================"
2245 grep -q $FSTYPE /proc/filesystems && return 1
2247 grep -q $FSTYPE /proc/filesystems && return 1
2248 insmod ../$FSTYPE/$FSTYPE.o
2249 grep -q $FSTYPE /proc/filesystems && return 1
2250 insmod ../$FSTYPE/$FSTYPE.ko
2251 grep -q $FSTYPE /proc/filesystems && return 1
2258 check_fstype && echo "can't find fs $FSTYPE, skipping $TESTNAME" && return
2259 mount -t $FSTYPE -o loop,iopen $EXT2_DEV $DIR/d55 || error "mounting"
2261 $IOPENTEST1 $DIR/d55/foo $DIR/d55 || error "running $IOPENTEST1"
2262 $IOPENTEST2 $DIR/d55 || error "running $IOPENTEST2"
2263 echo "check for $EXT2_DEV. Please wait..."
2265 $UMOUNT $DIR/d55 || error "unmounting"
2267 run_test 55 "check iopen_connect_dentry() ======================"
2275 NUMFILESx2=$(($NUMFILES * 2))
2276 for i in `seq 1 $NUMFILES` ; do
2277 touch $DIR/d56/file$i
2278 touch $DIR/d56/dir/file$i
2281 # test lfs getstripe with --recursive
2282 FILENUM=`$GETSTRIPE --recursive $DIR/d56 | grep -c obdidx`
2283 [ $FILENUM -eq $NUMFILESx2 ] || error \
2284 "lfs getstripe --recursive $DIR/d56 wrong: found $FILENUM, expected $NUMFILESx2"
2285 FILENUM=`$GETSTRIPE $DIR/d56 | grep -c obdidx`
2286 [ $FILENUM -eq $NUMFILES ] || error \
2287 "lfs getstripe $DIR/d56 without --recursive wrong: found $FILENUM, expected $NUMFILES"
2288 echo "lfs getstripe --recursive passed."
2290 # test lfs getstripe with file instead of dir
2291 FILENUM=`$GETSTRIPE $DIR/d56/file1 | grep -c obdidx`
2292 [ $FILENUM -eq 1 ] || error \
2293 "lfs getstripe $DIR/d56/file1 wrong:found $FILENUM, expected 1"
2294 echo "lfs getstripe file passed."
2296 #test lfs getstripe with --verbose
2297 [ `$GETSTRIPE --verbose $DIR/d56 | grep -c lmm_magic` -eq $NUMFILES ] ||\
2298 error "lfs getstripe --verbose $DIR/d56 wrong: should find $NUMFILES lmm_magic info"
2299 [ `$GETSTRIPE $DIR/d56 | grep -c lmm_magic` -eq 0 ] || error \
2300 "lfs getstripe $DIR/d56 without --verbose wrong: should not show lmm_magic info"
2301 echo "lfs getstripe --verbose passed."
2303 #test lfs getstripe with --obd
2304 $GETSTRIPE --obd wrong_uuid $DIR/d56 2>&1 | grep -q "unknown obduuid" || \
2305 error "lfs getstripe --obd wrong_uuid should return error message"
2307 [ "$OSTCOUNT" -lt 2 ] && \
2308 echo "skipping other lfs getstripe --obd test" && return
2309 FILENUM=`$GETSTRIPE --recursive $DIR/d56 | sed -n '/^[ ]*1[ ]/p' | wc -l`
2310 OBDUUID=`$GETSTRIPE --recursive $DIR/d56 | sed -n '/^[ ]*1:/p' | awk '{print $2}'`
2311 FOUND=`$GETSTRIPE -r --obd $OBDUUID $DIR/d56 | wc -l`
2312 [ $FOUND -eq $FILENUM ] || \
2313 error "lfs getstripe --obd wrong: found $FOUND, expected $FILENUM"
2314 [ `$GETSTRIPE -r -v --obd $OBDUUID $DIR/d56 | sed '/^[ ]*1[ ]/d' |\
2315 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l` -eq 0 ] || \
2316 error "lfs getstripe --obd wrong: should not show file on other obd"
2317 echo "lfs getstripe --obd passed."
2319 run_test 56 "check lfs getstripe ===================================="
2326 if [ ! -d "$DIR/${tdir}g" ] ; then
2327 mkdir -p $DIR/${tdir}g
2328 for i in `seq 1 $LOCAL_NUMFILES` ; do
2329 touch $DIR/${tdir}g/file$i
2331 for i in `seq 1 $LOCAL_NUMDIRS` ; do
2332 mkdir $DIR/${tdir}g/dir$i
2333 for j in `seq 1 $LOCAL_NUMFILES` ; do
2334 touch $DIR/${tdir}g/dir$i/file$j
2343 setup_56 $NUMFILES $NUMDIRS
2345 EXPECTED=$(($NUMDIRS + 2))
2346 # test lfs find with -name
2347 for i in `seq 1 $NUMFILES` ; do
2348 NUMS=`$LFIND -name "*$i" $DIR/${tdir}g | wc -l`
2349 [ $NUMS -eq $EXPECTED ] || error \
2350 "lfs find -name \"*$i\" $DIR/${tdir}g wrong: found $NUMS, expected $EXPECTED"
2352 echo "lfs find -name passed."
2354 run_test 56g "check lfs find -name ============================="
2359 setup_56 $NUMFILES $NUMDIRS
2361 EXPECTED=$((($NUMDIRS+1)*($NUMFILES-1)+$NUMFILES))
2362 # test lfs find with ! -name
2363 for i in `seq 1 $NUMFILES` ; do
2364 NUMS=`$LFIND ! -name "*$i" $DIR/${tdir}g | wc -l`
2365 [ $NUMS -eq $EXPECTED ] || error \
2366 "lfs find ! -name \"*$i\" $DIR/${tdir}g wrong: found $NUMS, expected $EXPECTED"
2368 echo "lfs find ! -name passed."
2370 run_test 56h "check lfs find ! -name ============================="
2373 [ -z "$MDS" ] && echo "skipping $TESTNAME for remote MDS" && return
2374 for DEV in `cat $LPROC/mds/*/mntdev`; do
2375 dumpe2fs -h $DEV > $TMP/t57a.dump || error "can't access $DEV"
2376 DEVISIZE=`awk '/Inode size:/ { print $3 }' $TMP/t57a.dump`
2377 [ "$DEVISIZE" -gt 128 ] || error "inode size $DEVISIZE"
2381 run_test 57a "verify MDS filesystem created with large inodes =="
2386 FILEN=$DIR/d57b/f$FILECOUNT
2387 rm -rf $DIR/d57b || error "removing $DIR/d57b"
2388 mkdir -p $DIR/d57b || error "creating $DIR/d57b"
2389 echo "mcreating $FILECOUNT files"
2390 createmany -m $DIR/d57b/f 1 $FILECOUNT || \
2391 error "creating files in $DIR/d57b"
2393 # verify that files do not have EAs yet
2394 $GETSTRIPE $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
2395 $GETSTRIPE $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
2397 MDSFREE="`cat $LPROC/mds/*/kbytesfree 2> /dev/null`"
2398 MDCFREE="`cat $LPROC/mdc/*/kbytesfree | head -n 1`"
2399 echo "opening files to create objects/EAs"
2400 for FILE in `seq -f $DIR/d57b/f%g 1 $FILECOUNT`; do
2401 $OPENFILE -f O_RDWR $FILE > /dev/null || error "opening $FILE"
2404 # verify that files have EAs now
2405 $GETSTRIPE $FILE1 | grep -q "obdidx" || error "$FILE1 missing EA"
2406 $GETSTRIPE $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
2408 sleep 1 # make sure we get new statfs data
2409 MDSFREE2="`cat $LPROC/mds/*/kbytesfree 2> /dev/null`"
2410 MDCFREE2="`cat $LPROC/mdc/*/kbytesfree | head -n 1`"
2411 if [ "$MDCFREE2" -lt "$((MDCFREE - 8))" ]; then
2412 if [ "$MDSFREE" != "$MDSFREE2" ]; then
2413 error "MDC before $MDCFREE != after $MDCFREE2"
2415 echo "MDC before $MDCFREE != after $MDCFREE2"
2416 echo "unable to confirm if MDS has large inodes"
2421 run_test 57b "default LOV EAs are stored inside large inodes ==="
2424 [ -z "$(which wiretest 2>/dev/null)" ] && echo "skipping $TESTNAME (could not find wiretest)" && return
2427 run_test 58 "verify cross-platform wire constants =============="
2430 echo "touch 130 files"
2431 createmany -o $DIR/f59- 130
2433 unlinkmany $DIR/f59- 130
2436 # wait for commitment of removal
2438 run_test 59 "verify cancellation of llog records async ========="
2440 TEST60_HEAD="test_60 run $RANDOM"
2442 [ ! -f run-llog.sh ] && echo "missing subtest, skipping" && return
2443 log "$TEST60_HEAD - from kernel mode"
2446 run_test 60 "llog sanity tests run from kernel module =========="
2448 test_60b() { # bug 6411
2450 LLOG_COUNT=`dmesg | grep -A 1000 "$TEST60_HEAD" | grep -c llog_test`
2451 [ $LLOG_COUNT -gt 50 ] && error "CDEBUG_LIMIT not limiting messages"|| true
2453 run_test 60b "limit repeated messages from CERROR/CWARN ========"
2457 dd if=/dev/zero of=$f bs=`page_size` count=1
2458 cancel_lru_locks osc
2459 multiop $f OSMWUc || error
2462 run_test 61 "mmap() writes don't make sync hang ================"
2464 # bug 2330 - insufficient obd_match error checking causes LBUG
2468 cancel_lru_locks osc
2469 sysctl -w lustre.fail_loc=0x405
2470 cat $f && error "cat succeeded, expect -EIO"
2471 sysctl -w lustre.fail_loc=0
2473 run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
2475 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
2477 MAX_DIRTY_MB=`cat $LPROC/osc/*/max_dirty_mb | head -n 1`
2478 for i in $LPROC/osc/*/max_dirty_mb ; do
2481 for i in `seq 10` ; do
2482 dd if=/dev/zero of=$DIR/f63 bs=8k &
2488 for i in $LPROC/osc/*/max_dirty_mb ; do
2489 echo $MAX_DIRTY_MB > $i
2491 rm -f $DIR/f63 || true
2493 run_test 63 "Verify oig_wait interruption does not crash ======="
2495 # bug 2248 - async write errors didn't return to application on sync
2496 # bug 3677 - async write errors left page locked
2498 DBG_SAVE="`sysctl -n lnet.debug`"
2499 sysctl -w lnet.debug=-1
2501 # ensure we have a grant to do async writes
2502 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
2505 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
2506 sysctl -w lustre.fail_loc=0x80000406
2507 multiop $DIR/$tfile Owy && \
2508 $LCTL dk /tmp/test63b.debug && \
2509 sysctl -w lnet.debug="$DBG_SAVE" && \
2510 error "sync didn't return ENOMEM"
2511 sync; sleep 2; sync # do a real sync this time to flush page
2512 grep locked $LPROC/llite/*/dump_page_cache && \
2513 $LCTL dk /tmp/test63b.debug && \
2514 sysctl -w lnet.debug="$DBG_SAVE" && \
2515 error "locked page left in cache after async error" || true
2516 sysctl -w lnet.debug="$DBG_SAVE"
2518 run_test 63b "async write errors should be returned to fsync ==="
2522 grep "[0-9]" $LPROC/osc/*[oO][sS][cC]*/cur*
2524 run_test 64a "verify filter grant calculations (in kernel) ====="
2527 [ ! -f oos.sh ] && echo "missing subtest, skipping" && return
2530 run_test 64b "check out-of-space detection on client ==========="
2532 # bug 1414 - set/get directories' stripe info
2536 $LVERIFY $DIR/d65 $DIR/d65/f1 || error "lverify failed"
2538 run_test 65a "directory with no stripe info ===================="
2542 $SETSTRIPE $DIR/d65 $(($STRIPESIZE * 2)) 0 1 || error "setstripe"
2544 $LVERIFY $DIR/d65 $DIR/d65/f2 || error "lverify failed"
2546 run_test 65b "directory setstripe $(($STRIPESIZE * 2)) 0 1 ==============="
2549 if [ $OSTCOUNT -gt 1 ]; then
2551 $SETSTRIPE $DIR/d65 $(($STRIPESIZE * 4)) 1 \
2552 $(($OSTCOUNT - 1)) || error "setstripe"
2554 $LVERIFY $DIR/d65 $DIR/d65/f3 || error "lverify failed"
2557 run_test 65c "directory setstripe $(($STRIPESIZE * 4)) 1 $(($OSTCOUNT - 1))"
2559 [ $STRIPECOUNT -eq 0 ] && sc=1 || sc=$(($STRIPECOUNT - 1))
2563 $SETSTRIPE $DIR/d65 $STRIPESIZE -1 $sc || error "setstripe"
2564 touch $DIR/d65/f4 $DIR/d65/f5
2565 $LVERIFY $DIR/d65 $DIR/d65/f4 $DIR/d65/f5 || error "lverify failed"
2567 run_test 65d "directory setstripe $STRIPESIZE -1 $sc =============="
2572 $SETSTRIPE $DIR/d65 0 -1 0 || error "setstripe"
2573 $GETSTRIPE -v $DIR/d65 | grep "has no stripe info" || error "no stripe info failed"
2575 $LVERIFY $DIR/d65 $DIR/d65/f6 || error "lverify failed"
2577 run_test 65e "directory setstripe 0 -1 0 ======================="
2581 $RUNAS $SETSTRIPE $DIR/d65f 0 -1 0 && error "setstripe succeeded" || true
2583 run_test 65f "dir setstripe permission (should return error) ==="
2587 $SETSTRIPE $DIR/d65 $(($STRIPESIZE * 2)) 0 1 || error "setstripe"
2588 $SETSTRIPE -d $DIR/d65 || error "setstripe"
2589 $GETSTRIPE -v $DIR/d65 | grep "has no stripe info" || \
2590 error "delete default stripe failed"
2592 run_test 65g "directory setstripe -d ==========================="
2596 $SETSTRIPE $DIR/d65 $(($STRIPESIZE * 2)) 0 1 || error "setstripe"
2597 mkdir -p $DIR/d65/dd1
2598 [ "`$GETSTRIPE -v $DIR/d65 | grep "^count"`" == \
2599 "`$GETSTRIPE -v $DIR/d65/dd1 | grep "^count"`" ] || error "stripe info inherit failed"
2601 run_test 65h "directory stripe info inherit ===================="
2603 test_65i() { # bug6367
2604 $SETSTRIPE $MOUNT 65536 -1 -1
2606 run_test 65i "set non-default striping on root directory (bug 6367)="
2608 test_65j() { # bug6367
2609 # if we aren't already remounting for each test, do so for this test
2610 if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
2611 cleanup -f || error "failed to unmount"
2614 $SETSTRIPE -d $MOUNT
2616 run_test 65j "set default striping on root directory (bug 6367)="
2618 # bug 2543 - update blocks count on client
2621 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
2623 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
2624 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
2626 run_test 66 "update inode blocks count on client ==============="
2628 test_67() { # bug 3285 - supplementary group fails on MDS, passes on client
2629 [ "$RUNAS_ID" = "$UID" ] && echo "skipping $TESTNAME" && return
2630 check_kernel_version 35 || return 0
2632 chmod 771 $DIR/$tdir
2633 chgrp $RUNAS_ID $DIR/$tdir
2634 $RUNAS -u $RUNAS_ID -g $(($RUNAS_ID + 1)) -G1,2,$RUNAS_ID ls $DIR/$tdir
2637 # can't tell which is correct otherwise
2638 GROUP_UPCALL=`cat $LPROC/mds/$MDS/group_upcall`
2639 [ "$GROUP_UPCALL" = "NONE" -a $RC -eq 0 ] && \
2640 error "no-upcall passed" || true
2641 [ "$GROUP_UPCALL" != "NONE" -a $RC -ne 0 ] && \
2642 error "upcall failed" || true
2645 run_test 67 "supplementary group failure (should return error) ="
2649 echo NONE > $LPROC/mds/$MDS/group_upcall
2653 test_67b() { # bug 3285 - supplementary group fails on MDS, passes on client
2654 T67_UID=${T67_UID:-1} # needs to be in /etc/groups on MDS, gid == uid
2655 [ "$UID" = "$T67_UID" ] && echo "skipping $TESTNAME" && return
2656 check_kernel_version 35 || return 0
2657 [ -z "$MDS" ] && echo "skipping $TESTNAME - no MDS" && return
2658 GROUP_UPCALL=`cat $LPROC/mds/$MDS/group_upcall`
2659 [ "$GROUP_UPCALL" != "NONE" ] && echo "skip $TESTNAME - upcall" &&return
2661 trap cleanup_67b EXIT
2663 chmod 771 $DIR/$tdir
2664 chgrp $T67_UID $DIR/$tdir
2665 echo `which l_getgroups` > $LPROC/mds/$MDS/group_upcall
2666 l_getgroups -d $T67_UID
2667 $RUNAS -u $T67_UID -g $((T67_UID + 1)) -G8,9 id
2668 $RUNAS -u $T67_UID -g 999 -G8,9,$T67_UID touch $DIR/$tdir/$tfile || \
2669 error "'touch $DIR/$tdir/$tfile' failed"
2670 [ -f $DIR/$tdir/$tfile ] || error "$DIR/$tdir/$tfile create error"
2673 run_test 67b "supplementary group test ========================="
2677 if [ "$LOOPDEV" ]; then
2678 swapoff $LOOPDEV || error "swapoff failed"
2679 losetup -d $LOOPDEV || error "losetup -d failed"
2680 unset LOOPDEV LOOPNUM
2686 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
2690 swapon -s | awk '($1 == "'$1'") { print $4 }'
2693 # excercise swapping to lustre by adding a high priority swapfile entry
2694 # and then consuming memory until it is used.
2696 [ "$UID" != 0 ] && echo "skipping $TESTNAME (must run as root)" && return
2697 [ "`lsmod|grep obdfilter`" ] && echo "skipping $TESTNAME (local OST)" && \
2701 dd if=/dev/zero of=$DIR/f68 bs=64k count=1024
2703 trap cleanup_68 EXIT
2705 losetup $LOOPDEV $DIR/f68 || error "losetup $LOOPDEV failed"
2707 swapon -p 32767 $LOOPDEV || error "swapon $LOOPDEV failed"
2709 echo "before: `swapon -s | grep $LOOPDEV`"
2710 KBFREE=`meminfo MemTotal`
2711 $MEMHOG $KBFREE || error "error allocating $KBFREE kB"
2712 echo "after: `swapon -s | grep $LOOPDEV`"
2713 SWAPUSED=`swap_used $LOOPDEV`
2717 [ $SWAPUSED -eq 0 ] && echo "no swap used???" || true
2719 run_test 68 "support swapping to Lustre ========================"
2721 # bug5265, obdfilter oa2dentry return -ENOENT
2722 # #define OBD_FAIL_OST_ENOENT 0x217
2724 [ $(grep -c obdfilter $LPROC/devices) -eq 0 ] &&
2725 echo "skipping $TESTNAME for remote OST" && return
2730 if ! $DIRECTIO write ${f}.2 0 1; then
2731 echo "skipping $TESTNAME - O_DIRECT not implemented"
2735 sysctl -w lustre.fail_loc=0x217
2736 truncate $f 1 # vmtruncate() will ignore truncate() error.
2737 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
2739 sysctl -w lustre.fail_loc=0
2740 $DIRECTIO write $f 0 2 || error "write error"
2742 cancel_lru_locks osc
2743 $DIRECTIO read $f 0 1 || error "read error"
2745 sysctl -w lustre.fail_loc=0x217
2746 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
2748 sysctl -w lustre.fail_loc=0
2751 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
2754 which dbench > /dev/null 2>&1 || echo "dbench not installed, skip this test" && return 0
2755 DBENCH_LIB=${DBENCH_LIB:-/usr/lib/dbench}
2756 PATH=${DBENCH_LIB}:${PATH}
2757 cp `which dbench` $DIR
2760 SRC=${SRC:-$DBENCH_LIB/client.txt}
2761 [ ! -e $TGT -a -e $SRC ] && echo "copying $SRC to $TGT" && cp $SRC $TGT
2762 SRC=$DBENCH_LIB/client_plain.txt
2763 [ ! -e $TGT -a -e $SRC ] && echo "copying $SRC to $TGT" && cp $SRC $TGT
2765 echo "copying necessary lib to $DIR"
2766 [ -d /lib64 ] && LIB71=/lib64 || LIB71=/lib
2767 mkdir -p $DIR$LIB71 || error "can't create $DIR$LIB71"
2768 cp $LIB71/libc* $DIR$LIB71 || error "can't copy $LIB71/libc*"
2769 cp $LIB71/ld-* $DIR$LIB71 || error "can't create $LIB71/ld-*"
2771 echo "chroot $DIR /dbench -c client.txt 2"
2772 chroot $DIR /dbench -c client.txt 2
2775 rm -rf $DIR/dbench $TGT $DIR$LIB71
2779 run_test 71 "Running dbench on lustre (don't segment fault) ===="
2781 test_72() { # bug 5695 - Test that on 2.6 remove_suid works properly
2782 check_kernel_version 43 || return 0
2783 [ "$RUNAS_ID" = "$UID" ] && echo "skipping $TESTNAME" && return
2787 $RUNAS -u $(($RUNAS_ID + 1)) dd if=/dev/zero of=$DIR/f72 bs=512 count=1 || error
2788 # See if we are still setuid/sgid
2789 test -u $DIR/f72 -o -g $DIR/f72 && error "S/gid is not dropped on write"
2790 # Now test that MDS is updated too
2791 cancel_lru_locks mdc
2792 test -u $DIR/f72 -o -g $DIR/f72 && error "S/gid is not dropped on MDS"
2795 run_test 72 "Test that remove suid works properly (bug5695) ===="
2797 # bug 3462 - multiple simultaneous MDC requests
2801 multiop $DIR/d73-1/f73-1 O_c &
2803 #give multiop a chance to open
2806 echo 0x80000129 > /proc/sys/lustre/fail_loc
2807 multiop $DIR/d73-1/f73-2 Oc &
2809 echo 0 > /proc/sys/lustre/fail_loc
2811 multiop $DIR/d73-2/f73-3 Oc &
2815 wait $pid1 || return 1
2819 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
2820 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
2821 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
2825 run_test 73 "multiple MDC requests (should not deadlock)"
2827 test_74() { # bug 6149, 6184
2828 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
2830 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
2831 # will spin in a tight reconnection loop
2832 sysctl -w lustre.fail_loc=0x8000030e
2835 sysctl -w lustre.fail_loc=0
2838 run_test 74 "ldlm_enqueue freed-export error path (shouldn't LBUG)"
2840 JOIN=${JOIN:-"lfs join"}
2847 [ $T75_PREP = "yes" ] && return
2848 echo "using F75=$F75, F128k=$F128k, FHEAD=$FHEAD, FTAIL=$FTAIL"
2850 dd if=/dev/urandom of=${F75}_128k bs=128k count=1 || error "dd failed"
2859 cp -p ${F128k} ${FHEAD}
2860 log "finished cp to $FHEAD"
2861 cp -p ${F128k} ${FTAIL}
2862 log "finished cp to $FTAIL"
2863 cat ${F128k} ${F128k} > ${F75}_sim_sim
2865 $JOIN ${FHEAD} ${FTAIL} || error "join ${FHEAD} ${FTAIL} error"
2866 log "finished join $FHEAD to ${F75}_sim_sim"
2867 cmp ${FHEAD} ${F75}_sim_sim || error "${FHEAD} ${F75}_sim_sim differ"
2868 log "finished cmp $FHEAD to ${F75}_sim_sim"
2869 $CHECKSTAT -a ${FTAIL} || error "tail ${FTAIL} still exist after join"
2871 run_test 75a "TEST join file ===================================="
2876 cp -p ${F128k} ${FTAIL}
2877 cat ${F75}_sim_sim >> ${F75}_join_sim
2878 cat ${F128k} >> ${F75}_join_sim
2879 $JOIN ${FHEAD} ${FTAIL} || error "join ${FHEAD} ${FTAIL} error"
2880 cmp ${FHEAD} ${F75}_join_sim || \
2881 error "${FHEAD} ${F75}_join_sim are different"
2882 $CHECKSTAT -a ${FTAIL} || error "tail ${FTAIL} exist after join"
2884 run_test 75b "TEST join file 2 =================================="
2889 cp -p ${F128k} ${FTAIL}
2890 cat ${F128k} >> ${F75}_sim_join
2891 cat ${F75}_join_sim >> ${F75}_sim_join
2892 $JOIN ${FTAIL} ${FHEAD} || error "join error"
2893 cmp ${FTAIL} ${F75}_sim_join || \
2894 error "${FTAIL} ${F75}_sim_join are different"
2895 $CHECKSTAT -a ${FHEAD} || error "tail ${FHEAD} exist after join"
2897 run_test 75c "TEST join file 3 =================================="
2902 cp -p ${F128k} ${FHEAD}
2903 cp -p ${F128k} ${FHEAD}_tmp
2904 cat ${F75}_sim_sim >> ${F75}_join_join
2905 cat ${F75}_sim_join >> ${F75}_join_join
2906 $JOIN ${FHEAD} ${FHEAD}_tmp || error "join ${FHEAD} ${FHEAD}_tmp error"
2907 $JOIN ${FHEAD} ${FTAIL} || error "join ${FHEAD} ${FTAIL} error"
2908 cmp ${FHEAD} ${F75}_join_join ||error "${FHEAD} ${F75}_join_join differ" $CHECKSTAT -a ${FHEAD}_tmp || error "${FHEAD}_tmp exist after join"
2909 $CHECKSTAT -a ${FTAIL} || error "tail ${FTAIL} exist after join (2)"
2911 run_test 75d "TEST join file 4 =================================="
2916 rm -rf ${FHEAD} || "delete join file error"
2918 run_test 75e "TEST join file 5 (remove joined file) ============="
2923 cp -p ${F128k} ${F75}_join_10_compare
2924 cp -p ${F128k} ${F75}_join_10
2925 for ((i = 0; i < 10; i++)); do
2926 cat ${F128k} >> ${F75}_join_10_compare
2927 cp -p ${F128k} ${FTAIL}
2928 $JOIN ${F75}_join_10 ${FTAIL} || \
2929 error "join ${F75}_join_10 ${FTAIL} error"
2930 $CHECKSTAT -a ${FTAIL} || error "tail file exist after join"
2932 cmp ${F75}_join_10 ${F75}_join_10_compare || \
2933 error "files ${F75}_join_10 ${F75}_join_10_compare differ"
2935 run_test 75f "TEST join file 6 (join 10 files) =================="
2938 [ ! -f ${F75}_join_10 ] && echo "${F75}_join_10 missing" && return
2939 $LFS getstripe ${F75}_join_10
2941 $OPENUNLINK ${F75}_join_10 ${F75}_join_10 || error "files unlink open"
2945 run_test 75g "TEST join file 7 (open unlink) ===================="
2948 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
2951 test_76() { # bug 1443
2952 BEFORE_INODES=`num_inodes`
2953 echo "before inodes: $BEFORE_INODES"
2954 for i in `seq 1000`; do
2958 AFTER_INODES=`num_inodes`
2959 echo "after inodes: $AFTER_INODES"
2960 [ $AFTER_INODES -gt $((BEFORE_INODES + 32)) ] && \
2961 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
2964 run_test 76 "destroy duplicate inodes in client inode cache ===="
2966 F77_TMP=$TMP/f77-temp
2967 test_77a() { # bug 10889
2968 for f in $LPROC/llite/${FSNAME}-*/checksum_pages ; do echo 1 >> $f ; done
2969 if [ ! -f $F77_TMP ]; then
2970 dd if=/dev/urandom of=$F77_TMP bs=1M count=8 || \
2971 error "error writing to $F77_TMP"
2973 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=8 || error "dd error"
2974 for f in $LPROC/llite/${FSNAME}-*/checksum_pages ; do echo 0 >> $f ; done
2976 run_test 77a "normal checksum read/write operation ============="
2978 test_77b() { # bug 10889
2979 [ ! -f $F77_TMP ] && echo "requires 77a" && return
2980 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
2981 sysctl -w lustre.fail_loc=0x80000409
2982 for f in $LPROC/llite/${FSNAME}-*/checksum_pages ; do echo 1 >> $f ; done
2983 dd if=$F77_TMP of=$DIR/f77b bs=8M count=1 conv=sync || \
2984 error "write error: rc=$?"
2985 sysctl -w lustre.fail_loc=0
2986 for f in $LPROC/llite/${FSNAME}-*/checksum_pages ; do echo 0 >> $f ; done
2988 run_test 77b "checksum error on client write ===================="
2990 test_77c() { # bug 10889
2991 [ ! -f $F77_TMP ] && echo "requires 77a" && return
2992 cancel_lru_locks osc
2993 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
2994 sysctl -w lustre.fail_loc=0x80000408
2995 for f in $LPROC/llite/${FSNAME}-*/checksum_pages ; do echo 1 >> $f ; done
2996 cmp $F77_TMP $DIR/f77b || error "file compare failed"
2997 sysctl -w lustre.fail_loc=0
2998 for f in $LPROC/llite/${FSNAME}-*/checksum_pages ; do echo 0 >> $f ; done
3000 run_test 77c "checksum error on client read ==================="
3002 test_77d() { # bug 10889
3003 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
3004 sysctl -w lustre.fail_loc=0x80000409
3005 for f in $LPROC/llite/${FSNAME}-*/checksum_pages ; do echo 1 >> $f ; done
3006 directio write $DIR/f77 0 1 || error "direct write: rc=$?"
3007 sysctl -w lustre.fail_loc=0
3008 for f in $LPROC/llite/${FSNAME}-*/checksum_pages ; do echo 0 >> $f ; done
3010 run_test 77d "checksum error on OST direct write ==============="
3012 test_77e() { # bug 10889
3013 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
3014 sysctl -w lustre.fail_loc=0x80000408
3015 for f in $LPROC/llite/${FSNAME}-*/checksum_pages ; do echo 1 >> $f ; done
3016 cancel_lru_locks osc
3017 directio read $DIR/f77 0 1 || error "direct read: rc=$?"
3018 sysctl -w lustre.fail_loc=0
3019 for f in $LPROC/llite/${FSNAME}-*/checksum_pages ; do echo 0 >> $f ; done
3021 run_test 77e "checksum error on OST direct read ================"
3023 test_77f() { # bug 10889
3024 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
3025 sysctl -w lustre.fail_loc=0x409
3026 for f in $LPROC/llite/${FSNAME}-*/checksum_pages ; do echo 1 >> $f ; done
3027 directio write $DIR/f77 0 1 && error "direct write succeeded"
3028 sysctl -w lustre.fail_loc=0
3029 for f in $LPROC/llite/${FSNAME}-*/checksum_pages ; do echo 0 >> $f ; done
3031 run_test 77f "repeat checksum error on write (expect error) ===="
3033 test_77g() { # bug 10889
3034 [ ! -f $F77_TMP ] && echo "requires 77a" && return
3035 [ -z "`lsmod|grep obdfilter`" ] &&
3036 echo "skipping $TESTNAME (remote OST)" && return
3037 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
3038 sysctl -w lustre.fail_loc=0x8000021a
3039 for f in $LPROC/llite/${FSNAME}-*/checksum_pages ; do echo 1 >> $f ; done
3040 dd if=$F77_TMP of=$DIR/f77 bs=8M count=1 || error "write error: rc=$?"
3041 sysctl -w lustre.fail_loc=0
3042 for f in $LPROC/llite/${FSNAME}-*/checksum_pages ; do echo 0 >> $f ; done
3044 run_test 77g "checksum error on OST write ======================"
3046 test_77h() { # bug 10889
3047 [ ! -f $DIR/f77 ] && echo "requires 77a,g" && return
3048 [ -z "`lsmod|grep obdfilter`" ] &&
3049 echo "skipping $TESTNAME (remote OST)" && return
3050 cancel_lru_locks osc
3051 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
3052 sysctl -w lustre.fail_loc=0x8000021b
3053 for f in $LPROC/llite/${FSNAME}-*/checksum_pages ; do echo 1 >> $f ; done
3054 cmp $F77_TMP $DIR/f77 || error "file compare failed"
3055 sysctl -w lustre.fail_loc=0
3056 for f in $LPROC/llite/${FSNAME}-*/checksum_pages ; do echo 0 >> $f ; done
3058 run_test 77h "checksum error on OST read ======================="
3063 test_78() { # bug 10901
3064 MEMFREE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
3065 [ $MEMFREE -gt 512 ] && MEMFREE=512
3066 $DIRECTIO rdwr $DIR/$tfile 0 $MEMFREE 1048576
3068 run_test 78 "handle large O_DIRECT writes correctly ============"
3070 # on the LLNL clusters, runas will still pick up root's $TMP settings,
3071 # which will not be writable for the runas user, and then you get a CVS
3072 # error message with a corrupt path string (CVS bug) and panic.
3073 # We're not using much space, so just stick it in /tmp, which is safe.
3079 [ $RUNAS_ID -ne $UID ] && HOME=/tmp
3082 mkdir -p $DIR/d99cvsroot
3083 chown $RUNAS_ID $DIR/d99cvsroot
3084 $RUNAS cvs -d $DIR/d99cvsroot init || error
3086 run_test 99a "cvs init ========================================="
3089 [ ! -d $DIR/d99cvsroot ] && test_99a
3091 # some versions of cvs import exit(1) when asked to import links or
3092 # files they can't read. ignore those files.
3093 TOIGNORE=$(find . -type l -printf '-I %f\n' -o \
3094 ! -perm +4 -printf '-I %f\n')
3095 $RUNAS cvs -d $DIR/d99cvsroot import -m "nomesg" $TOIGNORE \
3096 d99reposname vtag rtag
3098 run_test 99b "cvs import ======================================="
3101 [ ! -d $DIR/d99cvsroot ] && test_99b
3103 mkdir -p $DIR/d99reposname
3104 chown $RUNAS_ID $DIR/d99reposname
3105 $RUNAS cvs -d $DIR/d99cvsroot co d99reposname
3107 run_test 99c "cvs checkout ====================================="
3110 [ ! -d $DIR/d99cvsroot ] && test_99c
3111 cd $DIR/d99reposname
3113 $RUNAS cvs add -m 'addmsg' foo99
3115 run_test 99d "cvs add =========================================="
3118 [ ! -d $DIR/d99cvsroot ] && test_99c
3119 cd $DIR/d99reposname
3122 run_test 99e "cvs update ======================================="
3125 [ ! -d $DIR/d99cvsroot ] && test_99d
3126 cd $DIR/d99reposname
3127 $RUNAS cvs commit -m 'nomsg' foo99
3129 run_test 99f "cvs commit ======================================="
3132 netstat -tna | while read PROT SND RCV LOCAL REMOTE STAT; do
3133 [ "$PROT" != "tcp" ] && continue
3134 RPORT=`echo $REMOTE | cut -d: -f2`
3135 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
3136 LPORT=`echo $LOCAL | cut -d: -f2`
3137 if [ $LPORT -ge 1024 ]; then
3138 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
3140 error "local: $LPORT > 1024, remote: $RPORT"
3145 run_test 100 "check local port using privileged port ==========="
3147 function get_named_value()
3156 echo $line | sed "s/^$tag//"
3163 export CACHE_MAX=`cat /proc/fs/lustre/llite/*/max_cached_mb | head -n 1`
3165 for s in $LPROC/llite/*/max_cached_mb; do
3166 echo $CACHE_MAX > $s
3175 [ "$CPU" = "UML" ] && nreads=1000
3176 local cache_limit=32
3178 for s in $LPROC/osc/*/rpc_stats; do
3181 trap cleanup_101 EXIT
3182 for s in $LPROC/llite/*; do
3183 echo 0 > $s/read_ahead_stats
3184 echo $cache_limit > $s/max_cached_mb
3188 # randomly read 10000 of 64K chunks from file 3x 32MB in size
3190 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
3191 $RANDOM_READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
3194 for s in $LPROC/llite/*; do
3195 discard=$(($discard + $(cat $s/read_ahead_stats | get_named_value 'read but discarded')))
3199 if [ $(($discard * 10)) -gt $nreads ] ;then
3200 for s in $LPROC/osc/*/rpc_stats; do
3203 for s in $LPROC/llite/*/read_ahead_stats; do
3206 error "too many ($discard) discarded pages"
3208 rm -f $DIR/$tfile || true
3210 run_test 101 "check read-ahead for random reads ================"
3212 export SETUP_TEST102=no
3214 [ "$SETUP_TEST102" = "yes" ] && return
3220 trap cleanup_test102 EXIT
3222 $SETSTRIPE $tdir $STRIPE_SIZE $STRIPE_OFFSET $STRIPE_COUNT
3226 for count in 1 2 3 4
3228 for offset in 0 1 2 3
3230 local stripe_size=`expr $STRIPE_SIZE \* $num`
3231 local file=file"$num-$offset-$count"
3232 $SETSTRIPE $file $stripe_size $offset $count
3238 star -c f=$TMP/f102.tar $tdir
3243 [ "SETUP_TEST102" = "YES" ] || return
3251 local testfile=$DIR/xattr_testfile
3256 [ "$UID" != 0 ] && echo "skipping $TESTNAME (must run as root)" && return
3257 [ -z "`grep xattr $LPROC/mdc/*[mM][dD][cC]*/connect_flags`" ] && echo "skipping $TESTNAME (must have user_xattr)" && return
3258 [ -z "$(which setfattr 2>/dev/null)" ] && echo "skipping $TESTNAME (could not find setfattr)" && return
3260 echo "set/get xattr..."
3261 setfattr -n trusted.name1 -v value1 $testfile || error
3262 [ "`getfattr -n trusted.name1 $testfile 2> /dev/null | \
3263 grep "trusted.name1"`" == "trusted.name1=\"value1\"" ] || error
3265 setfattr -n user.author1 -v author1 $testfile || error
3266 [ "`getfattr -n user.author1 $testfile 2> /dev/null | \
3267 grep "user.author1"`" == "user.author1=\"author1\"" ] || error
3270 setfattr -n trusted.name2 -v value2 $testfile || error
3271 setfattr -n trusted.name3 -v value3 $testfile || error
3272 [ `getfattr -d -m "^trusted" $testfile 2> /dev/null | \
3273 grep "trusted.name" | wc -l` -eq 3 ] || error
3276 setfattr -n user.author2 -v author2 $testfile || error
3277 setfattr -n user.author3 -v author3 $testfile || error
3278 [ `getfattr -d -m "^user" $testfile 2> /dev/null | \
3279 grep "user" | wc -l` -eq 3 ] || error
3281 echo "remove xattr..."
3282 setfattr -x trusted.name1 $testfile || error
3283 getfattr -d -m trusted $testfile 2> /dev/null | \
3284 grep "trusted.name1" && error || true
3286 setfattr -x user.author1 $testfile || error
3287 getfattr -d -m user $testfile 2> /dev/null | \
3288 grep "user.author1" && error || true
3290 # b10667: setting lustre special xattr be silently discarded
3291 echo "set lustre special xattr ..."
3292 setfattr -n "trusted.lov" -v "invalid value" $testfile || error
3296 run_test 102a "user xattr test =================================="
3299 # b10930: get/set/list trusted.lov xattr
3300 echo "get/set/list trusted.lov xattr ..."
3301 [ "$OSTCOUNT" -lt "2" ] && echo "skipping 2-stripe test" && return
3302 local testfile=$DIR/$tfile
3303 $SETSTRIPE $testfile 65536 1 2
3304 getfattr -d -m "^trusted" $testfile 2> /dev/null | \
3305 grep "trusted.lov" || error
3307 local testfile2=${testfile}2
3308 local value=`getfattr -n trusted.lov $testfile 2> /dev/null | \
3309 grep "trusted.lov" |sed -e 's/[^=]\+=//'`
3312 setfattr -n trusted.lov -v $value $testfile2
3313 local tmp_file=${testfile}3
3314 $GETSTRIPE -v $testfile2 > $tmp_file
3315 local stripe_size=`grep "size" $tmp_file| awk '{print $2}'`
3316 local stripe_count=`grep "count" $tmp_file| awk '{print $2}'`
3317 [ $stripe_size -eq 65536 ] || error "different stripe size"
3318 [ $stripe_count -eq 2 ] || error "different stripe count"
3320 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
3323 # b10930: get/set/list trusted.lov xattr
3324 echo "get/set/list trusted.lov xattr ..."
3325 [ "$OSTCOUNT" -lt "2" ] && echo "skipping 2-stripe test" && return
3327 chown $RUNAS_ID $DIR/$tdir
3328 local testfile=$DIR/$tdir/$tfile
3329 $RUNAS $SETSTRIPE $testfile 65536 1 2
3330 $RUNAS getfattr -d -m "^trusted" $testfile 2> /dev/null | \
3331 grep "trusted.lov" || error
3333 local testfile2=${testfile}2
3334 local value=`getfattr -n trusted.lov $testfile 2> /dev/null | \
3335 grep "trusted.lov" |sed -e 's/[^=]\+=//' `
3337 $RUNAS $MCREATE $testfile2
3338 $RUNAS setfattr -n trusted.lov -v $value $testfile2
3339 local tmp_file=${testfile}3
3340 $RUNAS $GETSTRIPE -v $testfile2 > $tmp_file
3341 local stripe_size=`grep "size" $tmp_file| awk '{print $2}'`
3342 local stripe_count=`grep "count" $tmp_file| awk '{print $2}'`
3343 [ $stripe_size -eq 65536 ] || error "different stripe size"
3344 [ $stripe_count -eq 2 ] || error "different stripe count"
3346 run_test 102c "non-root getfattr/setfattr for trusted.lov EAs ==========="
3352 local lines=`sed -n '/obdidx/=' $1`
3353 stripe_size=`awk '{if($1~/size/) print $2}' $1`
3354 stripe_count=`awk '{if($1~/count/) print $2}' $1`
3355 lines=`expr $lines + 1`
3356 stripe_offset=`sed -n ${lines}p $1 |awk '{print $1}'`
3359 compare_stripe_info1() {
3362 for count in 1 2 3 4
3364 for offset in 0 1 2 3
3366 local size=`expr $STRIPE_SIZE \* $num`
3367 local file=file"$num-$offset-$count"
3369 $GETSTRIPE -v $file > $tmp_file
3370 get_stripe_info $tmp_file
3371 if test $stripe_size -ne $size
3373 error "$file: different stripe size" && return
3375 if test $stripe_count -ne $count
3377 error "$file: different stripe count" && return
3379 if test $stripe_offset -ne 0
3381 error "$file: different stripe offset" && return
3389 compare_stripe_info2() {
3392 for count in 1 2 3 4
3394 for offset in 0 1 2 3
3396 local size=`expr $STRIPE_SIZE \* $num`
3397 local file=file"$num-$offset-$count"
3399 $GETSTRIPE -v $file > $tmp_file
3400 get_stripe_info $tmp_file
3401 if test $stripe_size -ne $size
3403 error "$file: different stripe size" && return
3405 if test $stripe_count -ne $count
3407 error "$file: different stripe count" && return
3409 if test $stripe_offset -ne $offset
3411 error "$file: different stripe offset" && return
3420 # b10930: star test for trusted.lov xattr
3421 star --xhelp 2>&1 | grep -q nolustre
3424 echo "$TESTNUM being skipped because a lustre-aware star is not installed." && return
3426 [ "$OSTCOUNT" -lt "4" ] && echo "skipping 4-stripe test" && return
3429 star -x f=$TMP/f102.tar -C $DIR/d102d
3431 compare_stripe_info1
3434 run_test 102d "star restore stripe info from tarfile,not keep osts ==========="
3437 # b10930: star test for trusted.lov xattr
3438 star --xhelp 2>&1 | grep -q nolustre
3441 echo "$TESTNUM being skipped because a lustre-aware star is not installed." && return
3443 [ "$OSTCOUNT" -lt "4" ] && echo "skipping 4-stripe test" && return
3446 star -x -preserve-osts f=$TMP/f102.tar -C $DIR/d102e
3448 compare_stripe_info2
3450 run_test 102e "star restore stripe info from tarfile, keep osts ==========="
3453 # b10930: star test for trusted.lov xattr
3454 star --xhelp 2>&1 | grep -q nolustre
3457 echo "$TESTNUM being skipped because a lustre-aware star is not installed." && return
3459 [ "$OSTCOUNT" -lt "4" ] && echo "skipping 4-stripe test" && return
3463 star -copy $tdir $DIR/d102f
3465 compare_stripe_info1
3467 run_test 102f "star copy files, not keep osts ==========="
3470 # b10930: star test for trusted.lov xattr
3471 star --xhelp 2>&1 | grep -q nolustre
3474 echo "$TESTNUM being skipped because a lustre-aware star is not installed." && return
3476 [ "$OSTCOUNT" -lt "4" ] && echo "skipping 4-stripe test" && return
3480 star -copy -preserve-osts $tdir $DIR/d102g
3482 compare_stripe_info2
3485 run_test 102g "star copy files, keep osts ==========="
3489 $SAVE_PWD/acl/run $SAVE_PWD/acl/$1.test
3494 [ "$UID" != 0 ] && echo "skipping $TESTNAME (must run as root)" && return
3495 [ -z "$(grep acl $LPROC/mdc/*[mM][dD][cC]*/connect_flags)" ] && echo "skipping $TESTNAME (must have acl enabled)" && return
3496 [ -z "$(which setfacl 2>/dev/null)" ] && echo "skipping $TESTNAME (could not find setfacl)" && return
3502 echo "performing cp ..."
3503 run_acl_subtest cp || error
3504 echo "performing getfacl-noacl..."
3505 run_acl_subtest getfacl-noacl || error
3506 echo "performing misc..."
3507 run_acl_subtest misc || error
3508 # XXX add back permission test when we support supplementary groups.
3509 # echo "performing permissions..."
3510 # run_acl_subtest permissions || error
3511 echo "performing setfacl..."
3512 run_acl_subtest setfacl || error
3514 # inheritance test got from HP
3515 echo "performing inheritance..."
3516 cp $SAVE_PWD/acl/make-tree . || error
3517 chmod +x make-tree || error
3518 run_acl_subtest inheritance || error
3524 run_test 103 "acl test ========================================="
3528 lfs df || error "lfs df failed"
3529 lfs df -ih || error "lfs df -ih failed"
3530 lfs df -h $DIR || error "lfs df -h $DIR failed"
3531 lfs df -i $DIR || error "lfs df -i $DIR failed"
3532 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
3533 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
3535 OSC=`awk '/-osc-|OSC.*MNT/ {print $4}' $LPROC/devices | head -n 1`
3536 lctl --device %$OSC deactivate
3537 lfs df || error "lfs df with deactivated OSC failed"
3538 lctl --device %$OSC recover
3539 lfs df || error "lfs df with reactivated OSC failed"
3541 run_test 104 "lfs df [-ih] [path] test ========================="
3544 # doesn't work on 2.4 kernels
3546 if [ -n "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ];
3548 flocks_test on -f $DIR/$tfile || error "fail flock on"
3550 flocks_test off -f $DIR/$tfile || error "fail flock off"
3553 run_test 105a "flock when mounted without -o flock test ========"
3557 if [ -n "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ];
3559 flocks_test on -c $DIR/$tfile || error "fail flock on"
3561 flocks_test off -c $DIR/$tfile || error "fail flock off"
3564 run_test 105b "fcntl when mounted without -o flock test ========"
3568 if [ -n "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ];
3570 flocks_test on -l $DIR/$tfile || error "fail flock on"
3572 flocks_test off -l $DIR/$tfile || error "fail flock off"
3575 run_test 105c "lockf when mounted without -o flock test ========"
3580 chmod 777 $DIR/d106 || error
3582 run_test 106 "attempt exec of dir followed by chown of that dir"
3591 file=`cat /proc/sys/kernel/core_pattern`
3592 core_pid=`cat /proc/sys/kernel/core_uses_pid`
3593 [ $core_pid -eq 1 ] && file=$file.$SLEEPPID
3597 kill -s 11 $SLEEPPID
3599 if [ -e $file ]; then
3600 size=`stat -c%s $file`
3601 [ $size -eq 0 ] && error "Fail to create core file $file"
3603 error "Fail to create core file $file"
3608 run_test 107 "Coredump on SIG"
3611 OSTIO_pre=$(ps -e|grep ll_ost_io|awk '{print $4}'|sort -n|tail -1|\
3613 [ -z "$OSTIO_pre" ] && echo "skipping $TESTNAME: no OSS threads" && \
3615 echo "Starting with $OSTIO_pre threads"
3618 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
3619 [ $NUMFREE -lt $NUMTEST ] && NUMTEST=$(($NUMFREE - 1000))
3620 echo "$NUMTEST creates/unlinks"
3622 createmany -o $DIR/$tdir/$tfile $NUMTEST
3623 unlinkmany $DIR/$tdir/$tfile $NUMTEST
3625 OSTIO_post=$(ps -e|grep ll_ost_io|awk '{print $4}'|sort -n|tail -1|\
3628 # don't return an error
3629 [ $OSTIO_post -eq $OSTIO_pre ] && echo \
3630 "FAIL: No addition ll_ost_io threads were created ($OSTIO_pre)" &&\
3631 echo "This may be fine, depending on what ran before this test" &&\
3632 echo "and how fast this system is." && return
3634 echo "Started with $OSTIO_pre threads, ended with $OSTIO_post"
3636 run_test 115 "verify dynamic thread creation===================="
3639 AVAIL=($(cat $LPROC/osc/*[oO][sS][cC]-*/kbytesavail))
3640 echo OST kbytes available: ${AVAIL[@]}
3641 MAXI=0; MAXV=${AVAIL[0]}
3642 MINI=0; MINV=${AVAIL[0]}
3643 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
3644 #echo OST $i: ${AVAIL[i]}kb
3645 if [ ${AVAIL[i]} -gt $MAXV ]; then
3646 MAXV=${AVAIL[i]}; MAXI=$i
3648 if [ ${AVAIL[i]} -lt $MINV ]; then
3649 MINV=${AVAIL[i]}; MINI=$i
3652 echo Min free space: OST $MINI: $MINV
3653 echo Max free space: OST $MAXI: $MAXV
3657 [ "$OSTCOUNT" -lt "2" ] && echo "not enough OSTs" && return
3659 echo -n "Free space priority "
3660 cat $LPROC/lov/*/qos_prio_free
3661 DELAY=$(cat $LPROC/lov/*/qos_maxage | head -1 | awk '{print $1}')
3664 [ $MINV -gt 960000 ] && echo "too much free space in OST$MINI, skip" &&\
3667 # generate uneven OSTs
3668 mkdir -p $DIR/$tdir/OST${MINI}
3671 echo "Filling 25% remaining space in OST${MINI} with ${FILL}Kb"
3672 $SETSTRIPE $DIR/$tdir/OST${MINI} 0 $MINI 1
3674 while [ $FILL -gt 0 ]; do
3675 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i bs=2M count=1 2>/dev/null
3676 FILL=$(($FILL - 2048))
3685 DIFF=$(($MAXV - $MINV))
3686 DIFF2=$(($MINV * 2 / 10))
3687 echo -n "diff=$DIFF must be > 20%=$DIFF2 for QOS mode..."
3688 if [ $DIFF -gt $DIFF2 ]; then
3691 echo "failed - QOS mode won't be used"
3692 error "QOS imbalance criteria not met"
3696 MINI1=$MINI; MINV1=$MINV
3697 MAXI1=$MAXI; MAXV1=$MAXV
3699 # now fill using QOS
3700 echo writing a bunch of files to QOS-assigned OSTs
3702 while [ $FILL -gt 0 ]; do
3703 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1024 count=200 2>/dev/null
3704 FILL=$(($FILL - 200))
3708 echo "wrote $i 200k files"
3712 echo "Note: free space may not be updated, so measurements might be off"
3714 DIFF2=$(($MAXV - $MINV))
3715 echo "free space delta: orig $DIFF final $DIFF2"
3716 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
3717 DIFF=$(($MINV1 - ${AVAIL[$MINI1]}))
3718 echo "Wrote $DIFF to OST $MINI1"
3719 DIFF2=$(($MAXV1 - ${AVAIL[$MAXI1]}))
3720 echo "Wrote $DIFF2 to OST $MAXI1"
3721 echo "Wrote $(($DIFF2 * 100 / $DIFF - 100))% more to OST $MAXI1"
3723 # Figure out which files were written where
3724 UUID=$(awk '/'$MINI1': / {print $2; exit}' $LPROC/lov/${FSNAME}-clilov-*/target_obd)
3726 MINC=$($LFS getstripe --obd $UUID $DIR/$tdir | wc -l)
3727 echo "$MINC files created on smaller OST $MINI1"
3728 UUID=$(awk '/'$MAXI1': / {print $2; exit}' $LPROC/lov/${FSNAME}-clilov-*/target_obd)
3729 MAXC=$($LFS getstripe --obd $UUID $DIR/$tdir | wc -l)
3730 echo "$MAXC files created on larger OST $MAXI1"
3731 echo "Wrote $(($MAXC * 100 / $MINC - 100))% more files to OST $MAXI1"
3732 [ $MAXC -gt $MINC ] || error "stripe QOS didn't balance free space"
3734 run_test 116 "stripe QOS: free space balance ==================="
3736 test_117() # bug 10891
3738 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
3739 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
3740 sysctl -w lustre.fail_loc=0x21e
3741 > $DIR/$tfile || error "truncate failed"
3742 sysctl -w lustre.fail_loc=0
3743 echo "Truncate succeeded."
3745 run_test 117 "verify fsfilt_extend =========="
3751 log "cleanup: ======================================================"
3752 if [ "`mount | grep $MOUNT`" ]; then
3753 rm -rf $DIR/[Rdfs][1-9]*
3755 if [ "$I_MOUNTED" = "yes" ]; then
3756 cleanupall -f || error "cleanup failed"
3760 echo '=========================== finished ==============================='
3761 [ -f "$SANITYLOG" ] && cat $SANITYLOG && exit 1 || true
3762 echo "$0: completed"