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 12622 13310 10764
11 ALWAYS_EXCEPT=${ALWAYS_EXCEPT:-"27o 27q 42a 42b 42c 42d 45 51d 74b 75 $SANITY_EXCEPT" }
12 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
14 [ "$SLOW" = "no" ] && EXCEPT_SLOW="24o 27m 36f 36g 51b 51c 60c 63 64b 68 71 73 78 101 103 115 120g"
16 # Tests that fail on uml, maybe elsewhere, FIXME
17 CPU=`awk '/model/ {print $4}' /proc/cpuinfo`
18 # buffer i/o errs sock spc runas
19 [ "$CPU" = "UML" ] && EXCEPT="$EXCEPT 27m 27n 27o 27p 27q 27r 31d 54a 64b 99a 99b 99c 99d 99e 99f 101"
22 2.4*) FSTYPE=${FSTYPE:-ext3}; ALWAYS_EXCEPT="$ALWAYS_EXCEPT 76"
23 [ "$CPU" = "UML" ] && ALWAYS_EXCEPT="$ALWAYS_EXCEPT 105a";;
24 2.6*) FSTYPE=${FSTYPE:-ldiskfs}; ALWAYS_EXCEPT="$ALWAYS_EXCEPT " ;;
25 *) error "unsupported kernel" ;;
29 export PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH:/sbin
33 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
34 CREATETEST=${CREATETEST:-createtest}
36 SETSTRIPE=${SETSTRIPE:-"$LFS setstripe"}
37 GETSTRIPE=${GETSTRIPE:-"$LFS getstripe"}
38 LSTRIPE=${LSTRIPE:-"$LFS setstripe"}
39 LFIND=${LFIND:-"$LFS find"}
40 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
41 LSTRIPEINFO=${LSTRIPEINFO:-ll_getstripe_info}
43 MCREATE=${MCREATE:-mcreate}
44 OPENFILE=${OPENFILE:-openfile}
45 OPENUNLINK=${OPENUNLINK:-openunlink}
46 RANDOM_READS=${RANDOM_READS:-"random-reads"}
47 TOEXCL=${TOEXCL:-toexcl}
48 TRUNCATE=${TRUNCATE:-truncate}
49 MUNLINK=${MUNLINK:-munlink}
50 SOCKETSERVER=${SOCKETSERVER:-socketserver}
51 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
52 IOPENTEST1=${IOPENTEST1:-iopentest1}
53 IOPENTEST2=${IOPENTEST2:-iopentest2}
54 MEMHOG=${MEMHOG:-memhog}
55 DIRECTIO=${DIRECTIO:-directio}
56 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
57 UMOUNT=${UMOUNT:-"umount -d"}
58 CHECK_GRANT=${CHECK_GRANT:-"yes"}
59 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
61 export NAME=${NAME:-local}
68 LUSTRE=${LUSTRE:-`dirname $0`/..}
69 . $LUSTRE/tests/test-framework.sh
71 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
73 SANITYLOG=${TESTSUITELOG:-$TMP/$(basename $0 .sh).log}
78 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
79 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
89 check_kernel_version() {
90 VERSION_FILE=$LPROC/version
92 [ ! -f $VERSION_FILE ] && echo "can't find kernel version" && return 1
93 GOT_VER=$(awk '/kernel:/ {print $2}' $VERSION_FILE)
94 [ $GOT_VER == "patchless" ] && return 0
95 [ $GOT_VER -ge $WANT_VER ] && return 0
96 log "test needs at least kernel version $WANT_VER, running $GOT_VER"
100 if [ "$ONLY" == "cleanup" ]; then
105 [ "$SANITYLOG" ] && rm -f $SANITYLOG || true
107 check_and_setup_lustre
110 [ -z "`echo $DIR | grep $MOUNT`" ] && echo "$DIR not in $MOUNT" && exit 99
112 LOVNAME=`cat $LPROC/llite/*/lov/common_name | tail -n 1`
113 OSTCOUNT=`cat $LPROC/lov/$LOVNAME/numobd`
114 STRIPECOUNT=`cat $LPROC/lov/$LOVNAME/stripecount`
115 STRIPESIZE=`cat $LPROC/lov/$LOVNAME/stripesize`
116 ORIGFREE=`cat $LPROC/lov/$LOVNAME/kbytesavail`
117 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
119 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
120 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
121 rm -rf $DIR/[Rdfs][1-9]*
123 if [ $UID -ne 0 ]; then
124 log "running as non-root uid $UID"
128 RUNAS_ID=${RUNAS_ID:-500}
129 RUNAS=${RUNAS:-"runas -u $RUNAS_ID"}
131 # $RUNAS_ID may get set incorrectly somewhere else
132 [ $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
135 check_runas_id $RUNAS_ID $RUNAS
139 echo "preparing for tests involving mounts"
140 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
142 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
143 echo # add a newline after mke2fs.
147 OLDDEBUG="`sysctl lnet.debug 2> /dev/null`"
148 sysctl -w lnet.debug=-1 2> /dev/null || true
151 $CHECKSTAT -t file $DIR/$tfile || error
153 $CHECKSTAT -a $DIR/$tfile || error
155 run_test 0 "touch .../$tfile ; rm .../$tfile ====================="
158 chmod 0755 $DIR || error
159 $CHECKSTAT -p 0755 $DIR || error
161 run_test 0b "chmod 0755 $DIR ============================="
166 $CHECKSTAT -t dir $DIR/d1/d2 || error
168 run_test 1a "mkdir .../d1; mkdir .../d1/d2 ====================="
173 $CHECKSTAT -a $DIR/d1 || error
175 run_test 1b "rmdir .../d1/d2; rmdir .../d1 ====================="
180 $CHECKSTAT -t file $DIR/d2/f || error
182 run_test 2a "mkdir .../d2; touch .../d2/f ======================"
186 $CHECKSTAT -a $DIR/d2 || error
188 run_test 2b "rm -r .../d2; checkstat .../d2/f ======================"
192 $CHECKSTAT -t dir $DIR/d3 || error
194 run_test 3a "mkdir .../d3 ======================================"
197 if [ ! -d $DIR/d3 ]; then
201 $CHECKSTAT -t file $DIR/d3/f || error
203 run_test 3b "touch .../d3/f ===================================="
207 $CHECKSTAT -a $DIR/d3 || error
209 run_test 3c "rm -r .../d3 ======================================"
213 $CHECKSTAT -t dir $DIR/d4 || error
215 run_test 4a "mkdir .../d4 ======================================"
218 if [ ! -d $DIR/d4 ]; then
222 $CHECKSTAT -t dir $DIR/d4/d2 || error
224 run_test 4b "mkdir .../d4/d2 ==================================="
229 chmod 0707 $DIR/d5/d2
230 $CHECKSTAT -t dir -p 0707 $DIR/d5/d2 || error
232 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2 ============"
236 chmod 0666 $DIR/f6a || error
237 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/f6a || error
239 run_test 6a "touch .../f6a; chmod .../f6a ======================"
242 [ $RUNAS_ID -eq $UID ] && skip "RUNAS_ID = UID = $UID -- skipping" && return
243 if [ ! -f $DIR/f6a ]; then
247 $RUNAS chmod 0444 $DIR/f6a && error
248 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/f6a || error
250 run_test 6b "$RUNAS chmod .../f6a (should return error) =="
253 [ $RUNAS_ID -eq $UID ] && skip "RUNAS_ID = UID = $UID -- skipping" && return
255 chown $RUNAS_ID $DIR/f6c || error
256 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/f6c || error
258 run_test 6c "touch .../f6c; chown .../f6c ======================"
261 [ $RUNAS_ID -eq $UID ] && skip "RUNAS_ID = UID = $UID -- skipping" && return
262 if [ ! -f $DIR/f6c ]; then
264 chown $RUNAS_ID $DIR/f6c
266 $RUNAS chown $UID $DIR/f6c && error
267 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/f6c || error
269 run_test 6d "$RUNAS chown .../f6c (should return error) =="
272 [ $RUNAS_ID -eq $UID ] && skip "RUNAS_ID = UID = $UID -- skipping" && return
274 chgrp $RUNAS_ID $DIR/f6e || error
275 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/f6e || error
277 run_test 6e "touch .../f6e; chgrp .../f6e ======================"
280 [ $RUNAS_ID -eq $UID ] && skip "RUNAS_ID = UID = $UID -- skipping" && return
281 if [ ! -f $DIR/f6e ]; then
283 chgrp $RUNAS_ID $DIR/f6e
285 $RUNAS chgrp $UID $DIR/f6e && error
286 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/f6e || error
288 run_test 6f "$RUNAS chgrp .../f6e (should return error) =="
291 [ $RUNAS_ID -eq $UID ] && skip "RUNAS_ID = UID = $UID -- skipping" && return
292 mkdir $DIR/d6g || error
293 chmod 777 $DIR/d6g || error
294 $RUNAS mkdir $DIR/d6g/d || error
295 chmod g+s $DIR/d6g/d || error
296 mkdir $DIR/d6g/d/subdir
297 $CHECKSTAT -g \#$RUNAS_ID $DIR/d6g/d/subdir || error
299 run_test 6g "Is new dir in sgid dir inheriting group?"
301 test_6h() { # bug 7331
302 [ $RUNAS_ID -eq $UID ] && skip "RUNAS_ID = UID = $UID -- skipping" && return
303 touch $DIR/f6h || error "touch failed"
304 chown $RUNAS_ID:$RUNAS_ID $DIR/f6h || error "initial chown failed"
305 $RUNAS -G$RUNAS_ID chown $RUNAS_ID:0 $DIR/f6h && error "chown worked"
306 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_ID $DIR/f6h || error
308 run_test 6h "$RUNAS chown RUNAS_ID.0 .../f6h (should return error)"
314 $CHECKSTAT -t file -p 0666 $DIR/d7/f || error
316 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
319 if [ ! -d $DIR/d7 ]; then
323 echo -n foo > $DIR/d7/f2
324 [ "`cat $DIR/d7/f2`" = "foo" ] || error
325 $CHECKSTAT -t file -s 3 $DIR/d7/f2 || error
327 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
333 $CHECKSTAT -t file -p 0666 $DIR/d8/f || error
335 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
341 $CHECKSTAT -t dir $DIR/d9/d2/d3 || error
343 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
349 $CHECKSTAT -t file $DIR/d10/d2/f || error
351 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
356 chmod 0666 $DIR/d11/d2
357 chmod 0705 $DIR/d11/d2
358 $CHECKSTAT -t dir -p 0705 $DIR/d11/d2 || error
360 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
365 chmod 0666 $DIR/d12/f
366 chmod 0654 $DIR/d12/f
367 $CHECKSTAT -t file -p 0654 $DIR/d12/f || error
369 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
373 dd if=/dev/zero of=$DIR/d13/f count=10
375 $CHECKSTAT -t file -s 0 $DIR/d13/f || error
377 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
383 $CHECKSTAT -a $DIR/d14/f || error
385 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
390 mv $DIR/d15/f $DIR/d15/f2
391 $CHECKSTAT -t file $DIR/d15/f2 || error
393 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
399 $CHECKSTAT -a $DIR/d16/f || error
401 run_test 16 "touch .../d16/f; rm -rf .../d16/f ================="
406 ln -s $DIR/d17/f $DIR/d17/l-exist
408 $CHECKSTAT -l $DIR/d17/f $DIR/d17/l-exist || error
409 $CHECKSTAT -f -t f $DIR/d17/l-exist || error
410 rm -f $DIR/d17/l-exist
411 $CHECKSTAT -a $DIR/d17/l-exist || error
413 run_test 17a "symlinks: create, remove (real) =================="
417 ln -s no-such-file $DIR/d17/l-dangle
419 $CHECKSTAT -l no-such-file $DIR/d17/l-dangle || error
420 $CHECKSTAT -fa $DIR/d17/l-dangle || error
421 rm -f $DIR/d17/l-dangle
422 $CHECKSTAT -a $DIR/d17/l-dangle || error
424 run_test 17b "symlinks: create, remove (dangling) =============="
426 test_17c() { # bug 3440 - don't save failed open RPC for replay
428 ln -s foo $DIR/d17/f17c
429 cat $DIR/d17/f17c && error "opened non-existent symlink" || true
431 run_test 17c "symlinks: open dangling (should return error) ===="
435 ln -s foo $DIR/d17/f17d
436 touch $DIR/d17/f17d || error "creating to new symlink"
438 run_test 17d "symlinks: create dangling ========================"
442 local foo=$DIR/$tdir/$tfile
443 ln -s $foo $foo || error "create symlink failed"
444 ls -l $foo || error "ls -l failed"
445 ls $foo && error "ls not failed" || true
447 run_test 17e "symlinks: create recursive symlink (should return error) ===="
453 run_test 18 "touch .../f ; ls ... =============================="
459 $CHECKSTAT -a $DIR/f19 || error
461 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
464 ls -l $DIR/f19 && error || true
466 run_test 19b "ls -l .../f19 (should return error) =============="
469 [ $RUNAS_ID -eq $UID ] && skip "RUNAS_ID = UID = $UID -- skipping" && return
470 $RUNAS touch $DIR/f19 && error || true
472 run_test 19c "$RUNAS touch .../f19 (should return error) =="
475 cat $DIR/f19 && error || true
477 run_test 19d "cat .../f19 (should return error) =============="
489 $CHECKSTAT -a $DIR/f || error
491 run_test 20 "touch .../f ; ls -l ... ==========================="
495 [ -f $DIR/d21/dangle ] && rm -f $DIR/d21/dangle
496 ln -s dangle $DIR/d21/link
497 echo foo >> $DIR/d21/link
499 $CHECKSTAT -t link $DIR/d21/link || error
500 $CHECKSTAT -f -t file $DIR/d21/link || error
502 run_test 21 "write to dangling link ============================"
506 chown $RUNAS_ID $WDIR
507 (cd $WDIR || error "cd $WDIR failed";
508 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
510 ls -lR $WDIR/etc || error "ls -lR $WDIR/etc failed"
511 $CHECKSTAT -t dir $WDIR/etc || error "checkstat -t dir failed"
512 $CHECKSTAT -u \#$RUNAS_ID $WDIR/etc || error "checkstat -u failed"
514 run_test 22 "unpack tar archive as non-root user ==============="
519 $TOEXCL -e $DIR/d23/f23 || error
521 run_test 23 "O_CREAT|O_EXCL in subdir =========================="
524 echo '== rename sanity =============================================='
525 echo '-- same directory rename'
528 mv $DIR/R1/f $DIR/R1/g
529 $CHECKSTAT -t file $DIR/R1/g || error
531 run_test 24a "touch .../R1/f; rename .../R1/f .../R1/g ========="
536 mv $DIR/R2/f $DIR/R2/g
537 $CHECKSTAT -a $DIR/R2/f || error
538 $CHECKSTAT -t file $DIR/R2/g || error
540 run_test 24b "touch .../R2/{f,g}; rename .../R2/f .../R2/g ====="
545 mv $DIR/R3/f $DIR/R3/g
546 $CHECKSTAT -a $DIR/R3/f || error
547 $CHECKSTAT -t dir $DIR/R3/g || error
549 run_test 24c "mkdir .../R3/f; rename .../R3/f .../R3/g ========="
554 mrename $DIR/R4/f $DIR/R4/g
555 $CHECKSTAT -a $DIR/R4/f || error
556 $CHECKSTAT -t dir $DIR/R4/g || error
558 run_test 24d "mkdir .../R4/{f,g}; rename .../R4/f .../R4/g ====="
561 echo '-- cross directory renames --'
564 mv $DIR/R5a/f $DIR/R5b/g
565 $CHECKSTAT -a $DIR/R5a/f || error
566 $CHECKSTAT -t file $DIR/R5b/g || error
568 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
572 touch $DIR/R6a/f $DIR/R6b/g
573 mv $DIR/R6a/f $DIR/R6b/g
574 $CHECKSTAT -a $DIR/R6a/f || error
575 $CHECKSTAT -t file $DIR/R6b/g || error
577 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
582 mv $DIR/R7a/d $DIR/R7b/e
583 $CHECKSTAT -a $DIR/R7a/d || error
584 $CHECKSTAT -t dir $DIR/R7b/e || error
586 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R5b/e ======"
590 mkdir $DIR/R8a/d $DIR/R8b/e
591 mrename $DIR/R8a/d $DIR/R8b/e
592 $CHECKSTAT -a $DIR/R8a/d || error
593 $CHECKSTAT -t dir $DIR/R8b/e || error
595 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
598 echo "-- rename error cases"
602 mrename $DIR/R9/f $DIR/R9/a
603 $CHECKSTAT -t file $DIR/R9/f || error
604 $CHECKSTAT -t dir $DIR/R9/a || error
605 $CHECKSTAT -a file $DIR/R9/a/f || error
607 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
611 mrename $DIR/R10/f $DIR/R10/g
612 $CHECKSTAT -t dir $DIR/R10 || error
613 $CHECKSTAT -a $DIR/R10/f || error
614 $CHECKSTAT -a $DIR/R10/g || error
616 run_test 24j "source does not exist ============================"
619 mkdir $DIR/R11a $DIR/R11a/d
621 mv $DIR/R11a/f $DIR/R11a/d
622 $CHECKSTAT -a $DIR/R11a/f || error
623 $CHECKSTAT -t file $DIR/R11a/d/f || error
625 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
627 # bug 2429 - rename foo foo foo creates invalid file
630 multiop $f OcNs || error
632 run_test 24l "Renaming a file to itself ========================"
636 multiop $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
637 # on ext3 this does not remove either the source or target files
638 # though the "expected" operation would be to remove the source
639 $CHECKSTAT -t file ${f} || error "${f} missing"
640 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
642 run_test 24m "Renaming a file to a hard link to itself ========="
646 # this stats the old file after it was renamed, so it should fail
650 $CHECKSTAT ${f}.rename
653 run_test 24n "Statting the old file after renaming (Posix rename 2)"
656 check_kernel_version 37 || return 0
658 rename_many -s random -v -n 10 $DIR/d24o
660 run_test 24o "rename of files during htree split ==============="
664 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
665 mrename $DIR/R12a $DIR/R12b
666 $CHECKSTAT -a $DIR/R12a || error
667 $CHECKSTAT -t dir $DIR/R12b || error
668 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
669 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
671 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
675 DIRINO=`ls -lid $DIR/R13a | awk '{ print $1 }'`
676 multiop $DIR/R13b D_c &
680 mrename $DIR/R13a $DIR/R13b
681 $CHECKSTAT -a $DIR/R13a || error
682 $CHECKSTAT -t dir $DIR/R13b || error
683 DIRINO2=`ls -lid $DIR/R13b | awk '{ print $1 }'`
684 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
686 wait $MULTIPID || error "multiop close failed"
688 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
690 test_24r() { #bug 3789
691 mkdir $DIR/R14a $DIR/R14a/b
692 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
693 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
694 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
696 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
699 mkdir $DIR/R15a $DIR/R15a/b $DIR/R15a/b/c
700 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
701 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
702 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
704 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
706 mkdir $DIR/R16a $DIR/R16a/b $DIR/R16a/b/c
707 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
708 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
709 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
711 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
713 test_24u() { # bug12192
714 multiop $DIR/$tfile C2w$((2048 * 1024))c || error
715 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
717 run_test 24u "create stripe file"
720 echo '== symlink sanity ============================================='
724 touch $DIR/s25/foo || error
726 run_test 25a "create file in symlinked directory ==============="
729 [ ! -d $DIR/d25 ] && test_25a
730 $CHECKSTAT -t file $DIR/s25/foo || error
732 run_test 25b "lookup file in symlinked directory ==============="
737 ln -s d26/d26-2 $DIR/s26
738 touch $DIR/s26/foo || error
740 run_test 26a "multiple component symlink ======================="
743 mkdir -p $DIR/d26b/d26-2
744 ln -s d26b/d26-2/foo $DIR/s26-2
745 touch $DIR/s26-2 || error
747 run_test 26b "multiple component symlink at end of lookup ======"
752 ln -s d26.2 $DIR/s26.2-1
753 ln -s s26.2-1 $DIR/s26.2-2
754 ln -s s26.2-2 $DIR/s26.2-3
755 chmod 0666 $DIR/s26.2-3/foo
757 run_test 26c "chain of symlinks ================================"
759 # recursive symlinks (bug 439)
761 ln -s d26-3/foo $DIR/d26-3
763 run_test 26d "create multiple component recursive symlink ======"
766 [ ! -h $DIR/d26-3 ] && test_26d
769 run_test 26e "unlink multiple component recursive symlink ======"
771 # recursive symlinks (bug 7022)
773 mkdir $DIR/$tdir/$tfile || error "mkdir $DIR/$tdir/$tfile failed"
774 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
775 mkdir -p lndir/bar1 || error "mkdir lndir/bar1 failed"
776 mkdir $tfile || error "mkdir $tfile failed"
777 cd $tfile || error "cd $tfile failed"
778 ln -s .. dotdot || error "ln dotdot failed"
779 ln -s dotdot/lndir lndir || error "ln lndir failed"
780 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
781 output=`ls $tfile/$tfile/lndir/bar1`
782 [ "$output" = bar1 ] && error "unexpected output"
783 rm -r $tfile || error "rm $tfile failed"
784 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
786 run_test 26f "rm -r of a directory which has recursive symlink ="
789 echo '== stripe sanity =============================================='
790 mkdir -p $DIR/d27 || error "mkdir failed"
791 $SETSTRIPE $DIR/d27/f0 -c 1 || error "lstripe failed"
792 $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
794 log "== test 27b: write to one stripe file ========================="
795 cp /etc/hosts $DIR/d27/f0 || error
797 run_test 27a "one stripe file =================================="
800 [ "$OSTCOUNT" -lt "2" ] && skip "skipping 2-stripe test" && return
802 $SETSTRIPE $DIR/d27/f01 -c 2 || error "lstripe failed"
803 [ `$GETSTRIPE $DIR/d27/f01 | grep -A 10 obdidx | wc -l` -eq 4 ] ||
804 error "two-stripe file doesn't have two stripes"
806 log "== test 27d: write to two stripe file file f01 ================"
807 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
809 run_test 27c "create two stripe file f01 ======================="
813 $SETSTRIPE $DIR/d27/fdef 0 -1 0 || error "lstripe failed"
814 $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
815 dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
817 run_test 27d "create file with default settings ================"
821 $SETSTRIPE $DIR/d27/f12 -c 2 || error "lstripe failed"
822 $SETSTRIPE $DIR/d27/f12 -c 2 && error "lstripe succeeded twice"
823 $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
825 run_test 27e "lstripe existing file (should return error) ======"
829 $SETSTRIPE $DIR/d27/fbad -s 100 -i 0 -c 1 && error "lstripe failed"
830 dd if=/dev/zero of=$DIR/d27/f12 bs=4k count=4 || error "dd failed"
831 $GETSTRIPE $DIR/d27/fbad || error "lfs getstripe failed"
833 run_test 27f "lstripe with bad stripe size (should return error)"
837 $MCREATE $DIR/d27/fnone || error "mcreate failed"
839 log "== test 27h: lfs getstripe with no objects ===================="
840 $GETSTRIPE $DIR/d27/fnone 2>&1 | grep "no stripe info" || error "has object"
842 log "== test 27i: lfs getstripe with some objects =================="
843 touch $DIR/d27/fsome || error "touch failed"
844 $GETSTRIPE $DIR/d27/fsome | grep obdidx || error "missing objects"
846 run_test 27g "test lfs getstripe ==========================================="
850 $SETSTRIPE $DIR/d27/f27j -i $OSTCOUNT && error "lstripe failed"||true
852 run_test 27j "lstripe with bad stripe offset (should return error)"
854 test_27k() { # bug 2844
857 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
858 [ ! -d $DIR/d27 ] && mkdir -p $DIR/d27
859 $SETSTRIPE $FILE -s 67108864 || error "lstripe failed"
860 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
861 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
862 dd if=/dev/zero of=$FILE bs=4k count=1
863 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
864 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
866 run_test 27k "limit i_blksize for broken user apps ============="
870 mcreate $DIR/f27l || error "creating file"
871 $RUNAS $SETSTRIPE $DIR/f27l -c 1 && \
872 error "lstripe should have failed" || true
874 run_test 27l "check setstripe permissions (should return error)"
877 [ "$OSTCOUNT" -lt "2" ] && skip "$OSTCOUNT < 2 OSTs -- skipping" && return
878 if [ $ORIGFREE -gt $MAXFREE ]; then
879 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
883 $SETSTRIPE $DIR/d27/f27m_1 -i 0 -c 1
884 dd if=/dev/zero of=$DIR/d27/f27m_1 bs=1024 count=$MAXFREE && \
885 error "dd should fill OST0"
887 while $SETSTRIPE $DIR/d27/f27m_$i -i 0 -c 1 ; do
889 [ $i -gt 256 ] && break
892 touch $DIR/d27/f27m_$i
893 [ `$GETSTRIPE $DIR/d27/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] && \
894 error "OST0 was full but new created file still use it"
896 touch $DIR/d27/f27m_$i
897 [ `$GETSTRIPE $DIR/d27/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] && \
898 error "OST0 was full but new created file still use it"
901 run_test 27m "create file while OST0 was full =================="
903 # osc's keep a NOSPC stick flag that gets unset with rmdir
905 [ "$1" ] && FAIL_LOC=$1 || FAIL_LOC=0
906 mkdir -p $DIR/d27/nospc
908 sysctl -w lustre.fail_loc=$FAIL_LOC
911 exhaust_precreations() {
913 OST=$(grep ${OSTIDX}": " $LPROC/lov/${LOVNAME}/target_obd | \
914 awk '{print $2}' | sed -e 's/_UUID$//')
916 last_id=$(cat $LPROC/osc/${OST}-osc/prealloc_last_id)
917 next_id=$(cat $LPROC/osc/${OST}-osc/prealloc_next_id)
919 mkdir -p $DIR/d27/${OST}
920 $SETSTRIPE $DIR/d27/${OST} -i $OSTIDX -c 1
921 #define OBD_FAIL_OST_ENOSPC 0x215
922 sysctl -w lustre.fail_loc=0x215
923 echo "Creating to objid $last_id on ost $OST..."
924 createmany -o $DIR/d27/${OST}/f $next_id $((last_id - next_id + 2))
925 grep '[0-9]' $LPROC/osc/${OST}-osc/prealloc*
929 exhaust_all_precreations() {
931 for (( i=0; i < OSTCOUNT; i++ )) ; do
932 exhaust_precreations $i 0x215
938 [ "$OSTCOUNT" -lt "2" ] && skip "too few OSTs" && return
939 remote_mds && skip "remote MDS" && return
943 exhaust_precreations 0 0x80000215
945 touch $DIR/d27/f27n || error
949 run_test 27n "create file with some full OSTs =================="
952 [ "$OSTCOUNT" -lt "2" ] && skip "too few OSTs" && return
953 remote_mds && skip "remote MDS" && return
957 exhaust_all_precreations 0x215
960 touch $DIR/d27/f27o && error "able to create $DIR/d27/f27o"
964 run_test 27o "create file with all full OSTs (should error) ===="
967 [ "$OSTCOUNT" -lt "2" ] && skip "too few OSTs" && return
968 remote_mds && skip "remote MDS" && return
973 $MCREATE $DIR/d27/f27p || error
974 $TRUNCATE $DIR/d27/f27p 80000000 || error
975 $CHECKSTAT -s 80000000 $DIR/d27/f27p || error
977 exhaust_precreations 0 0x80000215
978 echo foo >> $DIR/d27/f27p || error
979 $CHECKSTAT -s 80000004 $DIR/d27/f27p || error
983 run_test 27p "append to a truncated file with some full OSTs ==="
986 [ "$OSTCOUNT" -lt "2" ] && skip "too few OSTs" && return
987 remote_mds && skip "remote MDS" && return
992 $MCREATE $DIR/d27/f27q || error "mcreate $DIR/d27/f27q failed"
993 $TRUNCATE $DIR/d27/f27q 80000000 ||error "truncate $DIR/d27/f27q failed"
994 $CHECKSTAT -s 80000000 $DIR/d27/f27q || error "checkstat failed"
996 exhaust_all_precreations 0x215
998 echo foo >> $DIR/d27/f27q && error "append succeeded"
999 $CHECKSTAT -s 80000000 $DIR/d27/f27q || error "checkstat 2 failed"
1003 run_test 27q "append to truncated file with all OSTs full (should error) ==="
1006 [ "$OSTCOUNT" -lt "2" ] && skip "too few OSTs" && return
1007 remote_mds && skip "remote MDS" && return
1011 exhaust_precreations 0 0x80000215
1013 $SETSTRIPE $DIR/d27/f27r -i 0 -c 2 # && error
1017 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1019 test_27s() { # bug 10725
1021 $LSTRIPE $DIR/$tdir $((2048 * 1024 * 1024)) -1 2 && \
1022 error "stripe width >= 2^32 succeeded" || true
1024 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1026 test_27t() { # bug 10864
1031 $WLFS getstripe $tfile
1034 run_test 27t "check that utils parse path correctly"
1036 test_27u() { # bug 4900
1037 [ "$OSTCOUNT" -lt "2" ] && skip "too few OSTs" && return
1038 remote_mds && skip "remote MDS" && return
1040 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1042 sysctl -w lustre.fail_loc=0x139
1044 createmany -o $DIR/d27u/t- 1000
1045 sysctl -w lustre.fail_loc=0
1047 TLOG=$DIR/$tfile.getstripe
1048 $GETSTRIPE $DIR/d27u > $TLOG
1049 OBJS=`awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj;}' $TLOG`
1050 unlinkmany $DIR/d27u/t- 1000
1051 [ $OBJS -gt 0 ] && \
1052 error "$OBJS objects created on OST-0. See $TLOG" || pass
1054 run_test 27u "skip object creation on OSC w/o objects =========="
1056 test_27v() { # bug 4900
1057 [ "$OSTCOUNT" -lt "2" ] && skip "too few OSTs" && return
1058 remote_mds && skip "remote MDS" && return
1060 exhaust_all_precreations
1063 $SETSTRIPE $DIR/$tdir -c 1 # 1 stripe / file
1065 touch $DIR/$tdir/$tfile
1066 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1067 sysctl -w lustre.fail_loc=0x705
1069 for F in `seq 1 32`; do
1070 touch $DIR/$tdir/$tfile.$F
1072 sysctl -w lustre.fail_loc=0
1075 TIMEOUT=`sysctl -n lustre.timeout`
1076 [ $((FINISH - START)) -ge $((TIMEOUT / 2)) ] && \
1077 error "$FINISH - $START >= $TIMEOUT / 2"
1081 run_test 27v "skip object creation on slow OST ================="
1083 test_27w() { # bug 10997
1084 mkdir -p $DIR/d27w || error "mkdir failed"
1085 $LSTRIPE $DIR/d27w/f0 -s 65536 || error "lstripe failed"
1086 size=`$LSTRIPEINFO $DIR/d27w/f0 | awk {'print $1'}`
1087 [ $size -ne 65536 ] && error "stripe size $size != 65536" || true
1089 [ "$OSTCOUNT" -lt "2" ] && skip "skipping multiple stripe count/offset test" && return
1090 for i in `seq 1 $OSTCOUNT`; do
1092 $LSTRIPE $DIR/d27w/f$i -c $i -i $offset || error "lstripe -c $i -i $offset failed"
1093 count=`$LSTRIPEINFO $DIR/d27w/f$i | awk {'print $2'}`
1094 index=`$LSTRIPEINFO $DIR/d27w/f$i | awk {'print $3'}`
1095 [ $count -ne $i ] && error "stripe count $count != $i" || true
1096 [ $index -ne $offset ] && error "stripe offset $index != $offset" || true
1099 run_test 27w "check lfs setstripe -c -s -i options ============="
1103 $CREATETEST $DIR/d28/ct || error
1105 run_test 28 "create/mknod/mkdir with bad file types ============"
1108 cancel_lru_locks mdc
1113 MDCDIR=${MDCDIR:-`find $LPROC/ldlm/namespaces | grep mdc | head -1`}
1114 LOCKCOUNTORIG=`cat $MDCDIR/lock_count`
1115 LOCKUNUSEDCOUNTORIG=`cat $MDCDIR/lock_unused_count`
1116 [ -z $"LOCKCOUNTORIG" ] && echo "No mdc lock count" && return 1
1120 LOCKCOUNTCURRENT=`cat $MDCDIR/lock_count`
1121 LOCKUNUSEDCOUNTCURRENT=`cat $MDCDIR/lock_unused_count`
1122 if [ "$LOCKCOUNTCURRENT" -gt "$LOCKCOUNTORIG" ]; then
1123 echo > $LPROC/ldlm/dump_namespaces
1124 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
1125 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1126 log "dumped log to $TMP/test_29.dk (bug 5793)"
1129 if [ "$LOCKUNUSEDCOUNTCURRENT" -gt "$LOCKUNUSEDCOUNTORIG" ]; then
1130 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
1131 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1132 log "dumped log to $TMP/test_29.dk (bug 5793)"
1136 run_test 29 "IT_GETATTR regression ============================"
1143 run_test 30 "run binary from Lustre (execve) ==================="
1146 $OPENUNLINK $DIR/f31 $DIR/f31 || error
1147 $CHECKSTAT -a $DIR/f31 || error
1149 run_test 31a "open-unlink file =================================="
1152 touch $DIR/f31 || error
1153 ln $DIR/f31 $DIR/f31b || error
1154 multiop $DIR/f31b Ouc || error
1155 $CHECKSTAT -t file $DIR/f31 || error
1157 run_test 31b "unlink file with multiple links while open ======="
1160 touch $DIR/f31 || error
1161 ln $DIR/f31 $DIR/f31c || error
1162 multiop $DIR/f31 O_uc &
1164 multiop $DIR/f31c Ouc
1166 kill -USR1 $MULTIPID
1169 run_test 31c "open-unlink file with multiple links ============="
1172 opendirunlink $DIR/d31d $DIR/d31d || error
1173 $CHECKSTAT -a $DIR/d31d || error
1175 run_test 31d "remove of open directory ========================="
1177 test_31e() { # bug 2904
1178 check_kernel_version 34 || return 0
1179 openfilleddirunlink $DIR/d31e || error
1181 run_test 31e "remove of open non-empty directory ==============="
1183 test_31f() { # bug 4554
1186 $SETSTRIPE $DIR/d31f -s 1048576 -c 1
1187 cp /etc/hosts $DIR/d31f
1189 $GETSTRIPE $DIR/d31f/hosts
1190 multiop $DIR/d31f D_c &
1195 rm -rv $DIR/d31f || error "first of $DIR/d31f"
1197 $SETSTRIPE $DIR/d31f -s 1048576 -c 1
1198 cp /etc/hosts $DIR/d31f
1201 multiop $DIR/d31f D_c &
1206 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
1207 wait $MULTIPID || error "first opendir $MULTIPID failed"
1211 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
1212 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
1215 run_test 31f "remove of open directory with open-unlink file ==="
1218 echo "== more mountpoints and symlinks ================="
1219 [ -e $DIR/d32a ] && rm -fr $DIR/d32a
1220 mkdir -p $DIR/d32a/ext2-mountpoint
1221 mount -t ext2 -o loop $EXT2_DEV $DIR/d32a/ext2-mountpoint || error
1222 $CHECKSTAT -t dir $DIR/d32a/ext2-mountpoint/.. || error
1223 $UMOUNT $DIR/d32a/ext2-mountpoint || error
1225 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
1228 [ -e $DIR/d32b ] && rm -fr $DIR/d32b
1229 mkdir -p $DIR/d32b/ext2-mountpoint
1230 mount -t ext2 -o loop $EXT2_DEV $DIR/d32b/ext2-mountpoint || error
1231 ls -al $DIR/d32b/ext2-mountpoint/.. || error
1232 $UMOUNT $DIR/d32b/ext2-mountpoint || error
1234 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
1237 [ -e $DIR/d32c ] && rm -fr $DIR/d32c
1238 mkdir -p $DIR/d32c/ext2-mountpoint
1239 mount -t ext2 -o loop $EXT2_DEV $DIR/d32c/ext2-mountpoint || error
1240 mkdir -p $DIR/d32c/d2/test_dir
1241 $CHECKSTAT -t dir $DIR/d32c/ext2-mountpoint/../d2/test_dir || error
1242 $UMOUNT $DIR/d32c/ext2-mountpoint || error
1244 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
1247 [ -e $DIR/d32d ] && rm -fr $DIR/d32d
1248 mkdir -p $DIR/d32d/ext2-mountpoint
1249 mount -t ext2 -o loop $EXT2_DEV $DIR/d32d/ext2-mountpoint || error
1250 mkdir -p $DIR/d32d/d2/test_dir
1251 ls -al $DIR/d32d/ext2-mountpoint/../d2/test_dir || error
1252 $UMOUNT $DIR/d32d/ext2-mountpoint || error
1254 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
1257 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
1258 mkdir -p $DIR/d32e/tmp
1259 TMP_DIR=$DIR/d32e/tmp
1260 ln -s $DIR/d32e $TMP_DIR/symlink11
1261 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1262 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
1263 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
1265 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
1268 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
1269 mkdir -p $DIR/d32f/tmp
1270 TMP_DIR=$DIR/d32f/tmp
1271 ln -s $DIR/d32f $TMP_DIR/symlink11
1272 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1273 ls $DIR/d32f/tmp/symlink11 || error
1274 ls $DIR/d32f/symlink01 || error
1276 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
1279 TMP_DIR=$DIR/$tdir/tmp
1280 mkdir -p $TMP_DIR $DIR/${tdir}2
1281 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
1282 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1283 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
1284 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
1285 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
1286 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
1288 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
1291 rm -fr $DIR/$tdir $DIR/${tdir}2
1292 TMP_DIR=$DIR/$tdir/tmp
1293 mkdir -p $TMP_DIR $DIR/${tdir}2
1294 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
1295 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1296 ls $TMP_DIR/symlink12 || error
1297 ls $DIR/$tdir/symlink02 || error
1299 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
1302 [ -e $DIR/d32i ] && rm -fr $DIR/d32i
1303 mkdir -p $DIR/d32i/ext2-mountpoint
1304 mount -t ext2 -o loop $EXT2_DEV $DIR/d32i/ext2-mountpoint || error
1305 touch $DIR/d32i/test_file
1306 $CHECKSTAT -t file $DIR/d32i/ext2-mountpoint/../test_file || error
1307 $UMOUNT $DIR/d32i/ext2-mountpoint || error
1309 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
1312 [ -e $DIR/d32j ] && rm -fr $DIR/d32j
1313 mkdir -p $DIR/d32j/ext2-mountpoint
1314 mount -t ext2 -o loop $EXT2_DEV $DIR/d32j/ext2-mountpoint || error
1315 touch $DIR/d32j/test_file
1316 cat $DIR/d32j/ext2-mountpoint/../test_file || error
1317 $UMOUNT $DIR/d32j/ext2-mountpoint || error
1319 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
1323 mkdir -p $DIR/d32k/ext2-mountpoint
1324 mount -t ext2 -o loop $EXT2_DEV $DIR/d32k/ext2-mountpoint
1325 mkdir -p $DIR/d32k/d2
1326 touch $DIR/d32k/d2/test_file || error
1327 $CHECKSTAT -t file $DIR/d32k/ext2-mountpoint/../d2/test_file || error
1328 $UMOUNT $DIR/d32k/ext2-mountpoint || error
1330 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
1334 mkdir -p $DIR/d32l/ext2-mountpoint
1335 mount -t ext2 -o loop $EXT2_DEV $DIR/d32l/ext2-mountpoint || error
1336 mkdir -p $DIR/d32l/d2
1337 touch $DIR/d32l/d2/test_file
1338 cat $DIR/d32l/ext2-mountpoint/../d2/test_file || error
1339 $UMOUNT $DIR/d32l/ext2-mountpoint || error
1341 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
1345 mkdir -p $DIR/d32m/tmp
1346 TMP_DIR=$DIR/d32m/tmp
1347 ln -s $DIR $TMP_DIR/symlink11
1348 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1349 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
1350 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
1352 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
1356 mkdir -p $DIR/d32n/tmp
1357 TMP_DIR=$DIR/d32n/tmp
1358 ln -s $DIR $TMP_DIR/symlink11
1359 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1360 ls -l $DIR/d32n/tmp/symlink11 || error
1361 ls -l $DIR/d32n/symlink01 || error
1363 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
1366 rm -fr $DIR/d32o $DIR/$tfile
1368 mkdir -p $DIR/d32o/tmp
1369 TMP_DIR=$DIR/d32o/tmp
1370 ln -s $DIR/$tfile $TMP_DIR/symlink12
1371 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1372 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
1373 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
1374 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
1375 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
1377 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
1387 mkdir -p $DIR/d32p/tmp
1389 TMP_DIR=$DIR/d32p/tmp
1391 ln -s $DIR/$tfile $TMP_DIR/symlink12
1393 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1395 cat $DIR/d32p/tmp/symlink12 || error
1397 cat $DIR/d32p/symlink02 || error
1400 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
1403 [ -e $DIR/d32q ] && rm -fr $DIR/d32q
1405 touch $DIR/d32q/under_the_mount
1406 mount -t ext2 -o loop $EXT2_DEV $DIR/d32q
1407 ls $DIR/d32q/under_the_mount && error || true
1408 $UMOUNT $DIR/d32q || error
1410 run_test 32q "stat follows mountpoints in Lustre (should return error)"
1413 [ -e $DIR/d32r ] && rm -fr $DIR/d32r
1415 touch $DIR/d32r/under_the_mount
1416 mount -t ext2 -o loop $EXT2_DEV $DIR/d32r
1417 ls $DIR/d32r | grep -q under_the_mount && error || true
1418 $UMOUNT $DIR/d32r || error
1420 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
1425 chmod 444 $DIR/$tfile
1426 chown $RUNAS_ID $DIR/$tfile
1428 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
1431 run_test 33 "write file with mode 444 (should return error) ===="
1436 chown $RUNAS_ID $DIR/d33
1437 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
1438 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
1439 error "open RDWR" || true
1441 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
1443 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
1446 $MCREATE $DIR/f34 || error
1447 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
1448 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
1449 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
1450 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1452 run_test 34a "truncate file that has not been opened ==========="
1455 [ ! -f $DIR/f34 ] && test_34a
1456 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1457 $OPENFILE -f O_RDONLY $DIR/f34
1458 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
1459 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1461 run_test 34b "O_RDONLY opening file doesn't create objects ====="
1464 [ ! -f $DIR/f34 ] && test_34a
1465 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1466 $OPENFILE -f O_RDWR $DIR/f34
1467 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
1468 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1470 run_test 34c "O_RDWR opening file-with-size works =============="
1473 [ ! -f $DIR/f34 ] && test_34a
1474 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
1475 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1478 run_test 34d "write to sparse file ============================="
1482 $MCREATE $DIR/f34e || error
1483 $TRUNCATE $DIR/f34e 1000 || error
1484 $CHECKSTAT -s 1000 $DIR/f34e || error
1485 $OPENFILE -f O_RDWR $DIR/f34e
1486 $CHECKSTAT -s 1000 $DIR/f34e || error
1488 run_test 34e "create objects, some with size and some without =="
1490 test_34f() { # bug 6242, 6243
1493 $MCREATE $DIR/f34f || error
1494 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
1495 dd if=$DIR/f34f of=$TMP/f34f
1496 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
1497 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
1498 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
1499 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
1500 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
1502 run_test 34f "read from a file with no objects until EOF ======="
1505 cp /bin/sh $DIR/f35a
1507 chown $RUNAS_ID $DIR/f35a
1508 $RUNAS $DIR/f35a && error || true
1511 run_test 35a "exec file with mode 444 (should return and not leak) ====="
1515 utime $DIR/f36 || error
1517 run_test 36a "MDS utime check (mknod, utime) ==================="
1521 utime $DIR/f36 || error
1523 run_test 36b "OST utime check (open, utime) ===================="
1528 chown $RUNAS_ID $DIR/d36
1529 $RUNAS utime $DIR/d36/f36 || error
1531 run_test 36c "non-root MDS utime check (mknod, utime) =========="
1534 [ ! -d $DIR/d36 ] && test_36c
1535 echo "" > $DIR/d36/f36
1536 $RUNAS utime $DIR/d36/f36 || error
1538 run_test 36d "non-root OST utime check (open, utime) ==========="
1541 [ $RUNAS_ID -eq $UID ] && skip "RUNAS_ID = UID = $UID -- skipping" && return
1543 touch $DIR/$tdir/$tfile
1544 $RUNAS utime $DIR/$tdir/$tfile && \
1545 error "utime worked, expected failure" || true
1547 run_test 36e "utime on non-owned file (should return error) ===="
1550 export LANG=C LC_LANG=C # for date language
1552 DATESTR="Dec 20 2000"
1554 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
1555 sysctl -w lustre.fail_loc=0x80000214
1557 cp /etc/hosts $DIR/$tdir/$tfile
1558 sync & # write RPC generated with "current" inode timestamp, but delayed
1560 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
1561 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
1562 cancel_lru_locks osc
1563 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
1565 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
1566 echo "BEFORE: $LS_BEFORE" && \
1567 echo "AFTER : $LS_AFTER" && \
1568 echo "WANT : $DATESTR" && \
1569 error "$DIR/$tdir/$tfile timestamps changed" || true
1571 run_test 36f "utime on file racing with OST BRW write =========="
1573 export FMD_MAX_AGE=`do_facet ost1 cat $LPROC/obdfilter/*/client_cache_seconds 2> /dev/null | head -n 1`
1575 [ -z "$FMD_MAX_AGE" ] && skip "skip test for remote OST" && return
1576 FMD_BEFORE="`awk '/ll_fmd_cache/ { print $2 }' /proc/slabinfo`"
1577 touch $DIR/d36/$tfile
1578 sleep $((FMD_MAX_AGE + 12))
1579 FMD_AFTER="`awk '/ll_fmd_cache/ { print $2 }' /proc/slabinfo`"
1580 [ "$FMD_AFTER" -gt "$FMD_BEFORE" ] && \
1581 echo "AFTER : $FMD_AFTER > BEFORE $FMD_BEFORE" && \
1582 error "fmd didn't expire after ping" || true
1584 run_test 36g "filter mod data cache expiry ====================="
1588 echo f > $DIR/$tdir/fbugfile
1589 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
1590 ls $DIR/$tdir | grep "\<fbugfile\>" && error
1591 $UMOUNT $DIR/$tdir || error
1592 rm -f $DIR/$tdir/fbugfile || error
1594 run_test 37 "ls a mounted file system to check old content ====="
1597 o_directory $DIR/$tfile
1599 run_test 38 "open a regular file with O_DIRECTORY =============="
1603 touch $DIR/${tfile}2
1604 # ls -l $DIR/$tfile $DIR/${tfile}2
1605 # ls -lu $DIR/$tfile $DIR/${tfile}2
1606 # ls -lc $DIR/$tfile $DIR/${tfile}2
1608 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
1609 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
1611 ls -l $DIR/$tfile $DIR/${tfile}2
1613 ls -lu $DIR/$tfile $DIR/${tfile}2
1615 ls -lc $DIR/$tfile $DIR/${tfile}2
1616 error "O_TRUNC didn't change timestamps"
1619 run_test 39 "mtime changed on create ==========================="
1622 dd if=/dev/zero of=$DIR/f40 bs=4096 count=1
1623 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/f40 && error
1624 $CHECKSTAT -t file -s 4096 $DIR/f40 || error
1626 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
1630 small_write $DIR/f41 18
1632 run_test 41 "test small file write + fstat ====================="
1634 count_ost_writes() {
1635 cat $LPROC/osc/*/stats |
1636 awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }'
1643 BG_DIRTY_RATIO_SAVE=10
1644 MAX_BG_DIRTY_RATIO=25
1648 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
1649 # dirty_ratio, dirty_background_ratio
1650 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
1651 echo $WRITEBACK_SAVE > /proc/sys/vm/dirty_writeback_centisecs
1652 echo $BG_DIRTY_RATIO_SAVE > /proc/sys/vm/dirty_background_ratio
1653 echo $DIRTY_RATIO_SAVE > /proc/sys/vm/dirty_ratio
1655 # if file not here, we are a 2.4 kernel
1656 kill -CONT `pidof kupdated`
1661 # setup the trap first, so someone cannot exit the test at the
1662 # exact wrong time and mess up a machine
1663 trap start_writeback EXIT
1664 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
1665 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
1666 WRITEBACK_SAVE=`cat /proc/sys/vm/dirty_writeback_centisecs`
1667 echo 0 > /proc/sys/vm/dirty_writeback_centisecs
1668 # save and increase /proc/sys/vm/dirty_ratio
1669 DIRTY_RATIO_SAVE=`cat /proc/sys/vm/dirty_ratio`
1670 echo $MAX_DIRTY_RATIO > /proc/sys/vm/dirty_ratio
1671 # save and increase /proc/sys/vm/dirty_background_ratio
1672 BG_DIRTY_RATIO_SAVE=`cat /proc/sys/vm/dirty_background_ratio`
1673 echo $MAX_BG_DIRTY_RATIO > /proc/sys/vm/dirty_background_ratio
1675 # if file not here, we are a 2.4 kernel
1676 kill -STOP `pidof kupdated`
1680 # ensure that all stripes have some grant before we test client-side cache
1682 [ "$SETUP_TEST42" ] && return
1683 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
1684 dd if=/dev/zero of=$i bs=4k count=1
1690 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
1691 # file truncation, and file removal.
1694 cancel_lru_locks osc
1696 sync; sleep 1; sync # just to be safe
1697 BEFOREWRITES=`count_ost_writes`
1698 grep "[0-9]" $LPROC/osc/*[oO][sS][cC][_-]*/cur_grant_bytes
1699 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
1700 AFTERWRITES=`count_ost_writes`
1701 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
1702 error "$BEFOREWRITES < $AFTERWRITES"
1705 run_test 42a "ensure that we don't flush on close =============="
1709 cancel_lru_locks osc
1712 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
1713 BEFOREWRITES=`count_ost_writes`
1714 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
1715 AFTERWRITES=`count_ost_writes`
1716 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
1717 error "$BEFOREWRITES < $AFTERWRITES on unlink"
1719 BEFOREWRITES=`count_ost_writes`
1720 sync || error "sync: $?"
1721 AFTERWRITES=`count_ost_writes`
1722 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
1723 error "$BEFOREWRITES < $AFTERWRITES on sync"
1725 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
1729 run_test 42b "test destroy of file with cached dirty data ======"
1731 # if these tests just want to test the effect of truncation,
1732 # they have to be very careful. consider:
1733 # - the first open gets a {0,EOF}PR lock
1734 # - the first write conflicts and gets a {0, count-1}PW
1735 # - the rest of the writes are under {count,EOF}PW
1736 # - the open for truncate tries to match a {0,EOF}PR
1737 # for the filesize and cancels the PWs.
1738 # any number of fixes (don't get {0,EOF} on open, match
1739 # composite locks, do smarter file size management) fix
1740 # this, but for now we want these tests to verify that
1741 # the cancellation with truncate intent works, so we
1742 # start the file with a full-file pw lock to match against
1743 # until the truncate.
1748 cancel_lru_locks osc
1750 # prime the file with 0,EOF PW to match
1754 # now the real test..
1755 dd if=/dev/zero of=$file bs=1024 count=100
1756 BEFOREWRITES=`count_ost_writes`
1757 $TRUNCATE $file $offset
1758 cancel_lru_locks osc
1759 AFTERWRITES=`count_ost_writes`
1765 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
1766 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
1769 run_test 42c "test partial truncate of file with cached dirty data"
1773 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
1774 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
1777 run_test 42d "test complete truncate of file with cached dirty data"
1780 cp -p /bin/ls $DIR/$tdir/$tfile
1781 multiop $DIR/$tdir/$tfile Ow_c &
1783 # give multiop a chance to open
1786 $DIR/$tdir/$tfile && error || true
1789 run_test 43 "execution of file opened for write should return -ETXTBSY"
1793 cp -p `which multiop` $DIR/d43/multiop
1794 $DIR/d43/multiop $TMP/test43.junk O_c &
1797 multiop $DIR/d43/multiop Oc && error "expected error, got success"
1798 kill -USR1 $MULTIPID || return 2
1799 wait $MULTIPID || return 3
1802 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
1806 cp -p `which multiop` $DIR/d43/multiop
1807 $DIR/d43/multiop $TMP/test43.junk O_c &
1810 truncate $DIR/d43/multiop 0 && error "expected error, got success"
1811 kill -USR1 $MULTIPID || return 2
1812 wait $MULTIPID || return 3
1815 run_test 43b "truncate of file being executed should return -ETXTBSY"
1818 local testdir="$DIR/d43c"
1821 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
1822 ( cd $testdir && md5sum -c)
1824 run_test 43c "md5sum of copy into lustre========================"
1827 [ "$OSTCOUNT" -lt "2" ] && skip "skipping 2-stripe test" && return
1828 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
1829 dd if=$DIR/f1 of=/dev/null bs=4k count=1
1831 run_test 44 "zero length read from a sparse stripe ============="
1834 local nstripe=`$LCTL lov_getconfig $DIR | grep default_stripe_count: | \
1836 [ -z "$nstripe" ] && skip "can't get stripe info" && return
1837 [ "$nstripe" -gt "$OSTCOUNT" ] && skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" && return
1838 local stride=`$LCTL lov_getconfig $DIR | grep default_stripe_size: | \
1840 if [ $nstripe -eq 0 ] ; then
1841 nstripe=`$LCTL lov_getconfig $DIR | grep obd_count: | awk '{print $2}'`
1844 OFFSETS="0 $((stride/2)) $((stride-1))"
1845 for offset in $OFFSETS ; do
1846 for i in `seq 0 $((nstripe-1))`; do
1848 local GLOBALOFFSETS=""
1849 local size=$((((i + 2 * $nstripe )*$stride + $offset))) # Bytes
1850 ll_sparseness_write $DIR/d44a $size || error "ll_sparseness_write"
1851 GLOBALOFFSETS="$GLOBALOFFSETS $size"
1852 ll_sparseness_verify $DIR/d44a $GLOBALOFFSETS \
1853 || error "ll_sparseness_verify $GLOBALOFFSETS"
1855 for j in `seq 0 $((nstripe-1))`; do
1856 size=$((((j + $nstripe )*$stride + $offset))) # Bytes
1857 ll_sparseness_write $DIR/d44a $size || error "ll_sparseness_write"
1858 GLOBALOFFSETS="$GLOBALOFFSETS $size"
1860 ll_sparseness_verify $DIR/d44a $GLOBALOFFSETS \
1861 || error "ll_sparseness_verify $GLOBALOFFSETS"
1865 run_test 44a "test sparse pwrite ==============================="
1869 for d in $LPROC/osc/*/cur_dirty_bytes; do
1870 tot=$(($tot + `cat $d`))
1875 before=`dirty_osc_total`
1876 echo executing "\"$*\""
1878 after=`dirty_osc_total`
1879 echo before $before, after $after
1883 # Obtain grants from OST if it supports it
1884 echo blah > ${f}_grant
1887 do_dirty_record "echo blah > $f"
1888 [ $before -eq $after ] && error "write wasn't cached"
1889 do_dirty_record "> $f"
1890 [ $before -gt $after ] || error "truncate didn't lower dirty count"
1891 do_dirty_record "echo blah > $f"
1892 [ $before -eq $after ] && error "write wasn't cached"
1893 do_dirty_record "sync"
1894 [ $before -gt $after ] || error "writeback didn't lower dirty count"
1895 do_dirty_record "echo blah > $f"
1896 [ $before -eq $after ] && error "write wasn't cached"
1897 do_dirty_record "cancel_lru_locks osc"
1898 [ $before -gt $after ] || error "lock cancellation didn't lower dirty count"
1901 run_test 45 "osc io page accounting ============================"
1907 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
1908 # test tickles a bug where re-dirtying a page was failing to be mapped to the
1909 # objects offset and an assert hit when an rpc was built with 1023's mapped
1910 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
1915 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
1917 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
1918 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
1922 run_test 46 "dirtying a previously written page ================"
1924 # Check that device nodes are created and then visible correctly (#2091)
1926 cmknod $DIR/test_47_node || error
1928 run_test 47 "Device nodes check ================================"
1930 test_48a() { # bug 2399
1931 check_kernel_version 34 || return 0
1934 mv $DIR/d48a $DIR/d48.new || error "move directory failed"
1935 mkdir $DIR/d48a || error "recreate directory failed"
1936 touch foo || error "'touch foo' failed after recreating cwd"
1937 mkdir bar || error "'mkdir foo' failed after recreating cwd"
1938 if check_kernel_version 44; then
1939 touch .foo || error "'touch .foo' failed after recreating cwd"
1940 mkdir .bar || error "'mkdir .foo' failed after recreating cwd"
1942 ls . > /dev/null || error "'ls .' failed after recreating cwd"
1943 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
1944 cd . || error "'cd .' failed after recreating cwd"
1945 mkdir . && error "'mkdir .' worked after recreating cwd"
1946 rmdir . && error "'rmdir .' worked after recreating cwd"
1947 ln -s . baz || error "'ln -s .' failed after recreating cwd"
1948 cd .. || error "'cd ..' failed after recreating cwd"
1950 run_test 48a "Access renamed working dir (should return errors)="
1952 test_48b() { # bug 2399
1953 check_kernel_version 34 || return 0
1956 rmdir $DIR/d48b || error "remove cwd $DIR/d48b failed"
1957 touch foo && error "'touch foo' worked after removing cwd"
1958 mkdir foo && error "'mkdir foo' worked after removing cwd"
1959 if check_kernel_version 44; then
1960 touch .foo && error "'touch .foo' worked after removing cwd"
1961 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
1963 ls . > /dev/null && error "'ls .' worked after removing cwd"
1964 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
1965 is_patchless || ( cd . && error "'cd .' worked after removing cwd" )
1966 mkdir . && error "'mkdir .' worked after removing cwd"
1967 rmdir . && error "'rmdir .' worked after removing cwd"
1968 ln -s . foo && error "'ln -s .' worked after removing cwd"
1969 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
1971 run_test 48b "Access removed working dir (should return errors)="
1973 test_48c() { # bug 2350
1974 check_kernel_version 36 || return 0
1975 #sysctl -w lnet.debug=-1
1977 mkdir -p $DIR/d48c/dir
1979 $TRACE rmdir $DIR/d48c/dir || error "remove cwd $DIR/d48c/dir failed"
1980 $TRACE touch foo && error "'touch foo' worked after removing cwd"
1981 $TRACE mkdir foo && error "'mkdir foo' worked after removing cwd"
1982 if check_kernel_version 44; then
1983 touch .foo && error "'touch .foo' worked after removing cwd"
1984 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
1986 $TRACE ls . && error "'ls .' worked after removing cwd"
1987 $TRACE ls .. || error "'ls ..' failed after removing cwd"
1988 is_patchless || ( $TRACE cd . && error "'cd .' worked after removing cwd" )
1989 $TRACE mkdir . && error "'mkdir .' worked after removing cwd"
1990 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
1991 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
1992 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
1994 run_test 48c "Access removed working subdir (should return errors)"
1996 test_48d() { # bug 2350
1997 check_kernel_version 36 || return 0
1998 #sysctl -w lnet.debug=-1
2000 mkdir -p $DIR/d48d/dir
2002 $TRACE rmdir $DIR/d48d/dir || error "remove cwd $DIR/d48d/dir failed"
2003 $TRACE rmdir $DIR/d48d || error "remove parent $DIR/d48d failed"
2004 $TRACE touch foo && error "'touch foo' worked after removing parent"
2005 $TRACE mkdir foo && error "'mkdir foo' worked after removing parent"
2006 if check_kernel_version 44; then
2007 touch .foo && error "'touch .foo' worked after removing parent"
2008 mkdir .foo && error "'mkdir .foo' worked after removing parent"
2010 $TRACE ls . && error "'ls .' worked after removing parent"
2011 $TRACE ls .. && error "'ls ..' worked after removing parent"
2012 is_patchless || ( $TRACE cd . && error "'cd .' worked after recreate parent" )
2013 $TRACE mkdir . && error "'mkdir .' worked after removing parent"
2014 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
2015 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
2016 is_patchless || ( $TRACE cd .. && error "'cd ..' worked after removing parent" || true )
2018 run_test 48d "Access removed parent subdir (should return errors)"
2020 test_48e() { # bug 4134
2021 check_kernel_version 41 || return 0
2022 #sysctl -w lnet.debug=-1
2024 mkdir -p $DIR/d48e/dir
2026 $TRACE rmdir $DIR/d48e/dir || error "remove cwd $DIR/d48e/dir failed"
2027 $TRACE rmdir $DIR/d48e || error "remove parent $DIR/d48e failed"
2028 $TRACE touch $DIR/d48e || error "'touch $DIR/d48e' failed"
2029 $TRACE chmod +x $DIR/d48e || error "'chmod +x $DIR/d48e' failed"
2030 # On a buggy kernel addition of "touch foo" after cd .. will
2031 # produce kernel oops in lookup_hash_it
2032 touch ../foo && error "'cd ..' worked after recreate parent"
2034 $TRACE rm $DIR/d48e || error "rm '$DIR/d48e' failed"
2036 run_test 48e "Access to recreated parent subdir (should return errors)"
2042 ls /proc/$$/cwd || error
2044 run_test 50 "special situations: /proc symlinks ==============="
2047 # bug 1516 - create an empty entry right after ".." then split dir
2050 $MCREATE $DIR/d51/bar
2052 createmany -m $DIR/d51/longfile 201
2054 while [ `ls -sd $DIR/d51 | awk '{ print $1 }'` -eq 4 ]; do
2055 $MCREATE $DIR/d51/longfile$FNUM
2060 ls -l $DIR/d51 > /dev/null || error
2062 run_test 51 "special situations: split htree with empty entry =="
2064 export NUMTEST=70000
2066 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
2067 [ $NUMFREE -lt 21000 ] && \
2068 skip "not enough free inodes ($NUMFREE)" && \
2071 check_kernel_version 40 || NUMTEST=31000
2072 [ $NUMFREE -lt $NUMTEST ] && NUMTEST=$(($NUMFREE - 50))
2075 createmany -d $DIR/d51b/t- $NUMTEST
2077 run_test 51b "mkdir .../t-0 --- .../t-$NUMTEST ===================="
2080 [ ! -d $DIR/d51b ] && skip "$DIR/51b missing" && \
2083 unlinkmany -d $DIR/d51b/t- $NUMTEST
2085 run_test 51c "rmdir .../t-0 --- .../t-$NUMTEST ===================="
2088 [ "$OSTCOUNT" -lt "3" ] && skip "skipping test with few OSTs" && return
2090 createmany -o $DIR/d51d/t- 1000
2091 $LFS getstripe $DIR/d51d > $TMP/files
2092 for N in `seq 0 $((OSTCOUNT - 1))`; do
2093 OBJS[$N]=`awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}' $TMP/files`
2094 OBJS0[$N]=`grep -A 1 idx $TMP/files | awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}'`
2095 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
2097 unlinkmany $DIR/d51d/t- 1000
2100 for N in `seq 1 $((OSTCOUNT - 1))`; do
2101 [ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ] && \
2102 error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
2103 [ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ] && \
2104 error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
2106 [ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ] && \
2107 error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
2108 [ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ] && \
2109 error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
2113 run_test 51d "check object distribution ===================="
2116 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
2119 chattr =a $DIR/d52a/foo || error "chattr =a failed"
2120 echo bar >> $DIR/d52a/foo || error "append bar failed"
2121 cp /etc/hosts $DIR/d52a/foo && error "cp worked"
2122 rm -f $DIR/d52a/foo 2>/dev/null && error "rm worked"
2123 link $DIR/d52a/foo $DIR/d52a/foo_link 2>/dev/null && error "link worked"
2124 echo foo >> $DIR/d52a/foo || error "append foo failed"
2125 mrename $DIR/d52a/foo $DIR/d52a/foo_ren && error "rename worked"
2126 lsattr $DIR/d52a/foo | egrep -q "^-+a-+ $DIR/d52a/foo" || error "lsattr"
2127 chattr -a $DIR/d52a/foo || error "chattr -a failed"
2129 rm -fr $DIR/d52a || error "cleanup rm failed"
2131 run_test 52a "append-only flag test (should return errors) ====="
2134 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
2137 chattr =i $DIR/d52b/foo || error
2138 cat test > $DIR/d52b/foo && error
2139 cp /etc/hosts $DIR/d52b/foo && error
2140 rm -f $DIR/d52b/foo 2>/dev/null && error
2141 link $DIR/d52b/foo $DIR/d52b/foo_link 2>/dev/null && error
2142 echo foo >> $DIR/d52b/foo && error
2143 mrename $DIR/d52b/foo $DIR/d52b/foo_ren && error
2144 [ -f $DIR/d52b/foo ] || error
2145 [ -f $DIR/d52b/foo_ren ] && error
2146 lsattr $DIR/d52b/foo | egrep -q "^-+i-+ $DIR/d52b/foo" || error
2147 chattr -i $DIR/d52b/foo || error
2149 rm -fr $DIR/d52b || error
2151 run_test 52b "immutable flag test (should return errors) ======="
2153 test_52c() { # 12848 simulating client < 1.4.7
2154 [ -f $DIR/d52c/foo ] && chattr -i $DIR/d52b/foo
2157 # skip MDS_BFLAG_EXT_FLAGS in mdc_getattr_pack
2158 #define OBD_FAIL_MDC_OLD_EXT_FLAGS 0x802
2159 sysctl -w lustre.fail_loc=0x802
2160 chattr =i $DIR/d52c/foo || error
2161 lsattr $DIR/d52c/foo | egrep -q "^-+i-+ $DIR/d52c/foo" || error
2162 chattr -i $DIR/d52c/foo || error
2163 sysctl -w lustre.fail_loc=0
2165 rm -fr $DIR/d52c || error
2167 run_test 52c "immutable flag test for client < 1.4.7 ======="
2170 remote_mds && skip "remote MDS" && return
2172 for i in `ls -d $LPROC/osc/*-osc 2> /dev/null` ; do
2173 ostname=`basename $i | cut -d - -f 1-2`
2174 ost_last=`cat $LPROC/obdfilter/$ostname/last_id`
2175 mds_last=`cat $i/prealloc_last_id`
2176 echo "$ostname.last_id=$ost_last ; MDS.last_id=$mds_last"
2177 if [ $ost_last != $mds_last ]; then
2178 error "$ostname.last_id=$ost_last ; MDS.last_id=$mds_last"
2182 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
2185 [ ! -f "$SOCKETSERVER" ] && skip "no socketserver, skipping" && return
2186 [ ! -f "$SOCKETCLIENT" ] && skip "no socketclient, skipping" && return
2187 $SOCKETSERVER $DIR/socket
2188 $SOCKETCLIENT $DIR/socket || error
2189 $MUNLINK $DIR/socket
2191 run_test 54a "unix domain socket test =========================="
2197 dd if=/dev/zero of=$f bs=`page_size` count=1
2199 run_test 54b "char device works in lustre ======================"
2202 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
2203 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
2204 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
2206 for i in `seq 3 7`; do
2207 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
2217 loopdev="$DIR/loop54c"
2220 [ -z "$LOOPNUM" ] && echo "couldn't find empty loop device" && return
2221 mknod $loopdev b 7 $LOOPNUM
2222 echo "make a loop file system with $tfile on $loopdev ($LOOPNUM)..."
2223 dd if=/dev/zero of=$tfile bs=`page_size` seek=1024 count=1 > /dev/null
2224 losetup $loopdev $tfile || error "can't set up $loopdev for $tfile"
2225 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
2227 mount -t ext2 $loopdev $tdir || error "error mounting $loopdev on $tdir"
2228 dd if=/dev/zero of=$tdir/tmp bs=`page_size` count=30 || error "dd write"
2230 dd if=$tdir/tmp of=/dev/zero bs=`page_size` count=30 || error "dd read"
2235 run_test 54c "block device works in lustre ====================="
2241 [ "$string" = `echo $string > $f | cat $f` ] || error
2243 run_test 54d "fifo device works in lustre ======================"
2246 check_kernel_version 46 || return 0
2249 cp -aL /dev/console $f
2250 echo $string > $f || error
2252 run_test 54e "console/tty device works in lustre ======================"
2255 grep -q $FSTYPE /proc/filesystems && return 1
2257 grep -q $FSTYPE /proc/filesystems && return 1
2258 insmod ../$FSTYPE/$FSTYPE.o
2259 grep -q $FSTYPE /proc/filesystems && return 1
2260 insmod ../$FSTYPE/$FSTYPE.ko
2261 grep -q $FSTYPE /proc/filesystems && return 1
2268 check_fstype && skip "can't find fs $FSTYPE" && return
2269 mount -t $FSTYPE -o loop,iopen $EXT2_DEV $DIR/d55 || error "mounting"
2271 $IOPENTEST1 $DIR/d55/foo $DIR/d55 || error "running $IOPENTEST1"
2272 $IOPENTEST2 $DIR/d55 || error "running $IOPENTEST2"
2273 echo "check for $EXT2_DEV. Please wait..."
2275 $UMOUNT $DIR/d55 || error "unmounting"
2277 run_test 55 "check iopen_connect_dentry() ======================"
2285 NUMFILESx2=$(($NUMFILES * 2))
2286 for i in `seq 1 $NUMFILES` ; do
2287 touch $DIR/d56/file$i
2288 touch $DIR/d56/dir/file$i
2291 # test lfs getstripe with --recursive
2292 FILENUM=`$GETSTRIPE --recursive $DIR/d56 | grep -c obdidx`
2293 [ $FILENUM -eq $NUMFILESx2 ] || error \
2294 "lfs getstripe --recursive $DIR/d56 wrong: found $FILENUM, expected $NUMFILESx2"
2295 FILENUM=`$GETSTRIPE $DIR/d56 | grep -c obdidx`
2296 [ $FILENUM -eq $NUMFILES ] || error \
2297 "lfs getstripe $DIR/d56 without --recursive wrong: found $FILENUM, expected $NUMFILES"
2298 echo "lfs getstripe --recursive passed."
2300 # test lfs getstripe with file instead of dir
2301 FILENUM=`$GETSTRIPE $DIR/d56/file1 | grep -c obdidx`
2302 [ $FILENUM -eq 1 ] || error \
2303 "lfs getstripe $DIR/d56/file1 wrong:found $FILENUM, expected 1"
2304 echo "lfs getstripe file passed."
2306 #test lfs getstripe with --verbose
2307 [ `$GETSTRIPE --verbose $DIR/d56 | grep -c lmm_magic` -eq $NUMFILES ] ||\
2308 error "lfs getstripe --verbose $DIR/d56 wrong: should find $NUMFILES lmm_magic info"
2309 [ `$GETSTRIPE $DIR/d56 | grep -c lmm_magic` -eq 0 ] || error \
2310 "lfs getstripe $DIR/d56 without --verbose wrong: should not show lmm_magic info"
2311 echo "lfs getstripe --verbose passed."
2313 #test lfs getstripe with --obd
2314 $GETSTRIPE --obd wrong_uuid $DIR/d56 2>&1 | grep -q "unknown obduuid" || \
2315 error "lfs getstripe --obd wrong_uuid should return error message"
2317 [ "$OSTCOUNT" -lt 2 ] && \
2318 skip "skipping other lfs getstripe --obd test" && return
2319 FILENUM=`$GETSTRIPE --recursive $DIR/d56 | sed -n '/^[ ]*1[ ]/p' | wc -l`
2320 OBDUUID=`$GETSTRIPE --recursive $DIR/d56 | sed -n '/^[ ]*1:/p' | awk '{print $2}'`
2321 FOUND=`$GETSTRIPE -r --obd $OBDUUID $DIR/d56 | wc -l`
2322 [ $FOUND -eq $FILENUM ] || \
2323 error "lfs getstripe --obd wrong: found $FOUND, expected $FILENUM"
2324 [ `$GETSTRIPE -r -v --obd $OBDUUID $DIR/d56 | sed '/^[ ]*1[ ]/d' |\
2325 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l` -eq 0 ] || \
2326 error "lfs getstripe --obd wrong: should not show file on other obd"
2327 echo "lfs getstripe --obd passed."
2329 run_test 56 "check lfs getstripe ===================================="
2336 if [ ! -d "$DIR/${tdir}g" ] ; then
2337 mkdir -p $DIR/${tdir}g
2338 for i in `seq 1 $LOCAL_NUMFILES` ; do
2339 touch $DIR/${tdir}g/file$i
2341 for i in `seq 1 $LOCAL_NUMDIRS` ; do
2342 mkdir $DIR/${tdir}g/dir$i
2343 for j in `seq 1 $LOCAL_NUMFILES` ; do
2344 touch $DIR/${tdir}g/dir$i/file$j
2350 setup_56_special() {
2355 if [ ! -e "$TDIR/loop1b" ] ; then
2356 for i in `seq 1 $LOCAL_NUMFILES` ; do
2357 mknod $TDIR/loop${i}b b 7 $i
2358 mknod $TDIR/null${i}c c 1 3
2359 ln -s $TDIR/file1 $TDIR/link${i}l
2361 for i in `seq 1 $LOCAL_NUMDIRS` ; do
2362 mknod $TDIR/dir$i/loop${i}b b 7 $i
2363 mknod $TDIR/dir$i/null${i}c c 1 3
2364 ln -s $TDIR/dir$i/file1 $TDIR/dir$i/link${i}l
2372 setup_56 $NUMFILES $NUMDIRS
2374 EXPECTED=$(($NUMDIRS + 2))
2375 # test lfs find with -name
2376 for i in `seq 1 $NUMFILES` ; do
2377 NUMS=`$LFIND -name "*$i" $DIR/${tdir}g | wc -l`
2378 [ $NUMS -eq $EXPECTED ] || error \
2379 "lfs find -name \"*$i\" $DIR/${tdir}g wrong: found $NUMS, expected $EXPECTED"
2381 echo "lfs find -name passed."
2383 run_test 56g "check lfs find -name ============================="
2388 setup_56 $NUMFILES $NUMDIRS
2390 EXPECTED=$((($NUMDIRS+1)*($NUMFILES-1)+$NUMFILES))
2391 # test lfs find with ! -name
2392 for i in `seq 1 $NUMFILES` ; do
2393 NUMS=`$LFIND ! -name "*$i" $DIR/${tdir}g | wc -l`
2394 [ $NUMS -eq $EXPECTED ] || error \
2395 "lfs find ! -name \"*$i\" $DIR/${tdir}g wrong: found $NUMS, expected $EXPECTED"
2397 echo "lfs find ! -name passed."
2399 run_test 56h "check lfs find ! -name ============================="
2404 UUID=`$GETSTRIPE $DIR/$tdir | awk '/0: / { print $2 }'`
2405 OUT="`$LFIND -ost $UUID $DIR/$tdir`"
2406 [ "$OUT" ] && error "$LFIND returned directory '$OUT'" || true
2408 run_test 56i "check 'lfs find -ost UUID' skips directories ======="
2411 setup_56_special $NUMFILES $NUMDIRS
2413 EXPECTED=$((NUMDIRS+1))
2414 NUMS=`$LFIND -type d $DIR/${tdir}g | wc -l`
2415 [ $NUMS -eq $EXPECTED ] || \
2416 error "lfs find -type d $DIR/${tdir}g wrong: found $NUMS, expected $EXPECTED"
2418 run_test 56j "check lfs find -type d ============================="
2421 setup_56_special $NUMFILES $NUMDIRS
2423 EXPECTED=$(((NUMDIRS+1) * NUMFILES))
2424 NUMS=`$LFIND -type f $DIR/${tdir}g | wc -l`
2425 [ $NUMS -eq $EXPECTED ] || \
2426 error "lfs find -type f $DIR/${tdir}g wrong: found $NUMS, expected $EXPECTED"
2428 run_test 56k "check lfs find -type f ============================="
2431 setup_56_special $NUMFILES $NUMDIRS
2433 EXPECTED=$((NUMDIRS + NUMFILES))
2434 NUMS=`$LFIND -type b $DIR/${tdir}g | wc -l`
2435 [ $NUMS -eq $EXPECTED ] || \
2436 error "lfs find -type b $DIR/${tdir}g wrong: found $NUMS, expected $EXPECTED"
2438 run_test 56l "check lfs find -type b ============================="
2441 setup_56_special $NUMFILES $NUMDIRS
2443 EXPECTED=$((NUMDIRS + NUMFILES))
2444 NUMS=`$LFIND -type c $DIR/${tdir}g | wc -l`
2445 [ $NUMS -eq $EXPECTED ] || \
2446 error "lfs find -type c $DIR/${tdir}g wrong: found $NUMS, expected $EXPECTED"
2448 run_test 56m "check lfs find -type c ============================="
2451 setup_56_special $NUMFILES $NUMDIRS
2453 EXPECTED=$((NUMDIRS + NUMFILES))
2454 NUMS=`$LFIND -type l $DIR/${tdir}g | wc -l`
2455 [ $NUMS -eq $EXPECTED ] || \
2456 error "lfs find -type l $DIR/${tdir}g wrong: found $NUMS, expected $EXPECTED"
2458 run_test 56n "check lfs find -type l ============================="
2461 setup_56 $NUMFILES $NUMDIRS
2464 utime $TDIR/file1 > /dev/null || error
2465 utime $TDIR/file2 > /dev/null || error
2466 utime $TDIR/dir1 > /dev/null || error
2467 utime $TDIR/dir2 > /dev/null || error
2468 utime $TDIR/dir1/file1 > /dev/null || error
2471 NUMS=`$LFIND -mtime +1 $TDIR | wc -l`
2472 [ $NUMS -eq $EXPECTED ] || \
2473 error "lfs find -mtime $TDIR wrong: found $NUMS, expected $EXPECTED"
2475 run_test 56o "check lfs find -mtime for old files =========================="
2478 remote_mds && skip "remote MDS" && return
2480 for DEV in `cat $LPROC/mds/*/mntdev`; do
2481 dumpe2fs -h $DEV > $TMP/t57a.dump || error "can't access $DEV"
2482 DEVISIZE=`awk '/Inode size:/ { print $3 }' $TMP/t57a.dump`
2483 [ "$DEVISIZE" -gt 128 ] || error "inode size $DEVISIZE"
2487 run_test 57a "verify MDS filesystem created with large inodes =="
2492 FILEN=$DIR/d57b/f$FILECOUNT
2493 rm -rf $DIR/d57b || error "removing $DIR/d57b"
2494 mkdir -p $DIR/d57b || error "creating $DIR/d57b"
2495 echo "mcreating $FILECOUNT files"
2496 createmany -m $DIR/d57b/f 1 $FILECOUNT || \
2497 error "creating files in $DIR/d57b"
2499 # verify that files do not have EAs yet
2500 $GETSTRIPE $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
2501 $GETSTRIPE $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
2503 MDSFREE="`cat $LPROC/mds/*/kbytesfree 2> /dev/null`"
2504 MDCFREE="`cat $LPROC/mdc/*/kbytesfree | head -n 1`"
2505 echo "opening files to create objects/EAs"
2506 for FILE in `seq -f $DIR/d57b/f%g 1 $FILECOUNT`; do
2507 $OPENFILE -f O_RDWR $FILE > /dev/null || error "opening $FILE"
2510 # verify that files have EAs now
2511 $GETSTRIPE $FILE1 | grep -q "obdidx" || error "$FILE1 missing EA"
2512 $GETSTRIPE $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
2514 sleep 1 # make sure we get new statfs data
2515 MDSFREE2="`cat $LPROC/mds/*/kbytesfree 2> /dev/null`"
2516 MDCFREE2="`cat $LPROC/mdc/*/kbytesfree | head -n 1`"
2517 if [ "$MDCFREE2" -lt "$((MDCFREE - 8))" ]; then
2518 if [ "$MDSFREE" != "$MDSFREE2" ]; then
2519 error "MDC before $MDCFREE != after $MDCFREE2"
2521 echo "MDC before $MDCFREE != after $MDCFREE2"
2522 echo "unable to confirm if MDS has large inodes"
2527 run_test 57b "default LOV EAs are stored inside large inodes ==="
2530 [ -z "$(which wiretest 2>/dev/null)" ] && skip "could not find wiretest" && return
2533 run_test 58 "verify cross-platform wire constants =============="
2536 echo "touch 130 files"
2537 createmany -o $DIR/f59- 130
2539 unlinkmany $DIR/f59- 130
2542 # wait for commitment of removal
2544 run_test 59 "verify cancellation of llog records async ========="
2546 TEST60_HEAD="test_60 run $RANDOM"
2548 [ ! -f run-llog.sh ] && skip "missing subtest run-llog.sh" && return
2549 log "$TEST60_HEAD - from kernel mode"
2552 run_test 60 "llog sanity tests run from kernel module =========="
2554 test_60b() { # bug 6411
2556 LLOG_COUNT=`dmesg | grep -A 1000 "$TEST60_HEAD" | grep -c llog_test`
2557 [ $LLOG_COUNT -gt 50 ] && error "CDEBUG_LIMIT not limiting messages"|| true
2559 run_test 60b "limit repeated messages from CERROR/CWARN ========"
2562 echo "create 5000 files"
2563 createmany -o $DIR/f60c- 5000
2564 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
2565 sysctl -w lustre.fail_loc=0x80000137
2566 unlinkmany $DIR/f60c- 5000
2568 run_test 60c "unlink file when mds full"
2572 dd if=/dev/zero of=$f bs=`page_size` count=1
2573 cancel_lru_locks osc
2574 multiop $f OSMWUc || error
2577 run_test 61 "mmap() writes don't make sync hang ================"
2579 # bug 2330 - insufficient obd_match error checking causes LBUG
2583 cancel_lru_locks osc
2584 #define OBD_FAIL_OSC_MATCH 0x405
2585 sysctl -w lustre.fail_loc=0x405
2586 cat $f && error "cat succeeded, expect -EIO"
2587 sysctl -w lustre.fail_loc=0
2589 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
2590 # match every page all of the time.
2591 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
2593 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
2595 MAX_DIRTY_MB=`cat $LPROC/osc/*/max_dirty_mb | head -n 1`
2596 for i in $LPROC/osc/*/max_dirty_mb ; do
2599 for i in `seq 10` ; do
2600 dd if=/dev/zero of=$DIR/f63 bs=8k &
2606 for i in $LPROC/osc/*/max_dirty_mb ; do
2607 echo $MAX_DIRTY_MB > $i
2609 rm -f $DIR/f63 || true
2611 run_test 63 "Verify oig_wait interruption does not crash ======="
2613 # bug 2248 - async write errors didn't return to application on sync
2614 # bug 3677 - async write errors left page locked
2617 sysctl -w lnet.debug=-1
2619 # ensure we have a grant to do async writes
2620 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
2623 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
2624 sysctl -w lustre.fail_loc=0x80000406
2625 multiop $DIR/$tfile Owy && \
2626 error "sync didn't return ENOMEM"
2627 sync; sleep 2; sync # do a real sync this time to flush page
2628 grep locked $LPROC/llite/*/dump_page_cache && \
2629 error "locked page left in cache after async error" || true
2632 run_test 63b "async write errors should be returned to fsync ==="
2636 grep "[0-9]" $LPROC/osc/*[oO][sS][cC][_-]*/cur*
2638 run_test 64a "verify filter grant calculations (in kernel) ====="
2641 [ ! -f oos.sh ] && skip "missing subtest oos.sh" && return
2644 run_test 64b "check out-of-space detection on client ==========="
2646 # bug 1414 - set/get directories' stripe info
2650 $LVERIFY $DIR/d65 $DIR/d65/f1 || error "lverify failed"
2652 run_test 65a "directory with no stripe info ===================="
2656 $SETSTRIPE $DIR/d65 -s $(($STRIPESIZE * 2)) -i 0 -c 1 || error "setstripe"
2658 $LVERIFY $DIR/d65 $DIR/d65/f2 || error "lverify failed"
2660 run_test 65b "directory setstripe $(($STRIPESIZE * 2)) 0 1 ==============="
2663 if [ $OSTCOUNT -gt 1 ]; then
2665 $SETSTRIPE $DIR/d65 -s $(($STRIPESIZE * 4)) -i 1 \
2666 -c $(($OSTCOUNT - 1)) || error "setstripe"
2668 $LVERIFY $DIR/d65 $DIR/d65/f3 || error "lverify failed"
2671 run_test 65c "directory setstripe $(($STRIPESIZE * 4)) 1 $(($OSTCOUNT - 1))"
2675 [ $STRIPECOUNT -le 0 ] && sc=1 || sc=$(($STRIPECOUNT - 1))
2676 $SETSTRIPE $DIR/d65 -s $STRIPESIZE -c $sc || error "setstripe"
2677 touch $DIR/d65/f4 $DIR/d65/f5
2678 $LVERIFY $DIR/d65 $DIR/d65/f4 $DIR/d65/f5 || error "lverify failed"
2680 run_test 65d "directory setstripe $STRIPESIZE -1 stripe_count =============="
2685 $SETSTRIPE $DIR/d65 || error "setstripe"
2686 $GETSTRIPE -v $DIR/d65 | grep "Default" || error "no stripe info failed"
2688 $LVERIFY $DIR/d65 $DIR/d65/f6 || error "lverify failed"
2690 run_test 65e "directory setstripe 0 -1 0 ======================="
2694 $RUNAS $SETSTRIPE $DIR/d65f && error "setstripe succeeded" || true
2696 run_test 65f "dir setstripe permission (should return error) ==="
2700 $SETSTRIPE $DIR/d65 -s $(($STRIPESIZE * 2)) -i 0 -c 1 || error "setstripe"
2701 $SETSTRIPE -d $DIR/d65 || error "setstripe"
2702 $GETSTRIPE -v $DIR/d65 | grep "Default" || \
2703 error "delete default stripe failed"
2705 run_test 65g "directory setstripe -d ==========================="
2709 $SETSTRIPE $DIR/d65 -s $(($STRIPESIZE * 2)) -i 0 -c 1 || error "setstripe"
2710 mkdir -p $DIR/d65/dd1
2711 [ "`$GETSTRIPE -v $DIR/d65 | grep "^count"`" == \
2712 "`$GETSTRIPE -v $DIR/d65/dd1 | grep "^count"`" ] || error "stripe info inherit failed"
2714 run_test 65h "directory stripe info inherit ===================="
2716 test_65i() { # bug6367
2717 $SETSTRIPE $MOUNT -s 65536 -c -1
2719 run_test 65i "set non-default striping on root directory (bug 6367)="
2721 test_65j() { # bug6367
2722 # if we aren't already remounting for each test, do so for this test
2723 if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
2724 cleanup -f || error "failed to unmount"
2727 $SETSTRIPE -d $MOUNT || error "setstripe failed"
2729 run_test 65j "set default striping on root directory (bug 6367)="
2731 test_65k() { # bug11679
2732 [ "$OSTCOUNT" -lt 2 ] && skip "too few OSTs" && return
2734 echo "Check OST status: "
2735 MDS_OSCS=`do_facet mds lctl dl | awk '/[oO][sS][cC].*md[ts]/ { print $4 }'`
2736 for OSC in $MDS_OSCS; do
2737 echo $OSC "is activate"
2738 do_facet mds lctl --device %$OSC activate
2740 do_facet client mkdir -p $DIR/$tdir
2741 for INACTIVE_OSC in $MDS_OSCS; do
2742 echo $INACTIVE_OSC "is Deactivate:"
2743 do_facet mds lctl --device %$INACTIVE_OSC deactivate
2744 for STRIPE_OSC in $MDS_OSCS; do
2745 STRIPE_OST=`osc_to_ost $STRIPE_OSC`
2746 STRIPE_INDEX=`do_facet mds cat $LPROC/lov/*md*/target_obd |
2747 grep $STRIPE_OST | awk -F: '{print $1}'`
2748 echo "$SETSTRIPE $DIR/$tdir/${STRIPE_INDEX} -i ${STRIPE_INDEX} -c 1"
2749 do_facet client $SETSTRIPE $DIR/$tdir/${STRIPE_INDEX} -i ${STRIPE_INDEX} -c 1
2751 [ $RC -ne 0 ] && error "setstripe should have succeeded"
2753 do_facet client rm -f $DIR/$tdir/*
2754 echo $INACTIVE_OSC "is Activate."
2755 do_facet mds lctl --device %$INACTIVE_OSC activate
2758 run_test 65k "validate manual striping works properly with deactivated OSCs"
2760 test_65l() { # bug 12836
2762 $SETSTRIPE $DIR/$tdir -c -1
2763 $LFS find -mtime -1 $DIR >/dev/null
2765 run_test 65l "lfs find on -1 stripe dir ========================"
2767 # bug 2543 - update blocks count on client
2770 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
2772 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
2773 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
2775 run_test 66 "update inode blocks count on client ==============="
2777 test_67() { # bug 3285 - supplementary group fails on MDS, passes on client
2778 [ "$RUNAS_ID" = "$UID" ] && skip "RUNAS_ID = UID = $UID -- skipping" && return
2779 check_kernel_version 35 || return 0
2781 chmod 771 $DIR/$tdir
2782 chgrp $RUNAS_ID $DIR/$tdir
2783 $RUNAS -u $RUNAS_ID -g $(($RUNAS_ID + 1)) -G1,2,$RUNAS_ID ls $DIR/$tdir
2785 MDS=$(\ls $LPROC/mds 2> /dev/null | grep -v num_refs | tail -n 1)
2787 # can't tell which is correct otherwise
2788 GROUP_UPCALL=`cat $LPROC/mds/$MDS/group_upcall`
2789 [ "$GROUP_UPCALL" = "NONE" -a $RC -eq 0 ] && \
2790 error "no-upcall passed" || true
2791 [ "$GROUP_UPCALL" != "NONE" -a $RC -ne 0 ] && \
2792 error "upcall failed" || true
2795 run_test 67 "supplementary group failure (should return error) ="
2800 echo NONE > $LPROC/mds/$MDS/group_upcall
2803 test_67b() { # bug 3285 - supplementary group fails on MDS, passes on client
2804 T67_UID=${T67_UID:-1} # needs to be in /etc/groups on MDS, gid == uid
2805 [ "$UID" = "$T67_UID" ] && skip "UID = T67_UID = $UID -- skipping" && return
2806 check_kernel_version 35 || return 0
2807 remote_mds && skip "remote MDS" && return
2808 GROUP_UPCALL=`cat $LPROC/mds/$MDS/group_upcall`
2809 [ "$GROUP_UPCALL" != "NONE" ] && skip "skip test - upcall" &&return
2811 trap cleanup_67b EXIT
2813 chmod 771 $DIR/$tdir
2814 chgrp $T67_UID $DIR/$tdir
2815 echo `which l_getgroups` > $LPROC/mds/$MDS/group_upcall
2816 l_getgroups -d $T67_UID
2817 $RUNAS -u $T67_UID -g 999 -G8,9,$T67_UID touch $DIR/$tdir/$tfile || \
2818 error "'touch $DIR/$tdir/$tfile' failed"
2819 [ -f $DIR/$tdir/$tfile ] || error "$DIR/$tdir/$tfile create error"
2822 run_test 67b "supplementary group test ========================="
2827 if [ ! -z "$LLOOP" ]; then
2828 swapoff $LLOOP || error "swapoff failed"
2829 $LCTL blockdev_detach $LLOOP || error "detach failed"
2837 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
2841 swapon -s | awk '($1 == "'$1'") { print $4 }'
2845 # excercise swapping to lustre by adding a high priority swapfile entry
2846 # and then consuming memory until it is used.
2848 [ "$UID" != 0 ] && skip "must run as root" && return
2849 grep -q obdfilter $LPROC/devices && \
2850 skip "local OST" && return
2852 grep -q llite_lloop /proc/modules
2853 [ $? -ne 0 ] && skip "can't find module llite_lloop" && return
2855 [ -z "`$LCTL list_nids | grep -v tcp`" ] && \
2856 skip "can't reliably test swap with TCP" && return
2858 MEMTOTAL=`meminfo MemTotal`
2859 NR_BLOCKS=$((MEMTOTAL>>8))
2860 [[ $NR_BLOCKS -le 2048 ]] && NR_BLOCKS=2048
2862 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
2863 dd if=/dev/zero of=$DIR/f68 bs=64k seek=$NR_BLOCKS count=1
2866 $LCTL blockdev_attach $DIR/f68 $LLOOP || error "attach failed"
2868 trap cleanup_68 EXIT
2870 swapon -p 32767 $LLOOP || error "swapon $LLOOP failed"
2872 echo "before: `swapon -s | grep $LLOOP`"
2873 $MEMHOG $MEMTOTAL || error "error allocating $MEMTOTAL kB"
2874 echo "after: `swapon -s | grep $LLOOP`"
2875 SWAPUSED=`swap_used $LLOOP`
2879 [ $SWAPUSED -eq 0 ] && echo "no swap used???" || true
2881 run_test 68 "support swapping to Lustre ========================"
2883 # bug5265, obdfilter oa2dentry return -ENOENT
2884 # #define OBD_FAIL_OST_ENOENT 0x217
2886 [ $(grep -c obdfilter $LPROC/devices) -eq 0 ] &&
2887 skip "skipping test for remote OST" && return
2892 if ! $DIRECTIO write ${f}.2 0 1; then
2893 skip "O_DIRECT not implemented"
2897 #define OBD_FAIL_OST_ENOENT 0x217
2898 sysctl -w lustre.fail_loc=0x217
2899 truncate $f 1 # vmtruncate() will ignore truncate() error.
2900 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
2902 sysctl -w lustre.fail_loc=0
2903 $DIRECTIO write $f 0 2 || error "write error"
2905 cancel_lru_locks osc
2906 $DIRECTIO read $f 0 1 || error "read error"
2908 #define OBD_FAIL_OST_ENOENT 0x217
2909 sysctl -w lustre.fail_loc=0x217
2910 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
2912 sysctl -w lustre.fail_loc=0
2915 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
2918 which dbench > /dev/null 2>&1 || skip "dbench not installed, skip this test" && return 0
2919 DBENCH_LIB=${DBENCH_LIB:-/usr/lib/dbench}
2920 PATH=${DBENCH_LIB}:${PATH}
2921 cp `which dbench` $DIR
2924 SRC=${SRC:-$DBENCH_LIB/client.txt}
2925 [ ! -e $TGT -a -e $SRC ] && echo "copying $SRC to $TGT" && cp $SRC $TGT
2926 SRC=$DBENCH_LIB/client_plain.txt
2927 [ ! -e $TGT -a -e $SRC ] && echo "copying $SRC to $TGT" && cp $SRC $TGT
2929 echo "copying necessary lib to $DIR"
2930 [ -d /lib64 ] && LIB71=/lib64 || LIB71=/lib
2931 mkdir -p $DIR$LIB71 || error "can't create $DIR$LIB71"
2932 cp $LIB71/libc* $DIR$LIB71 || error "can't copy $LIB71/libc*"
2933 cp $LIB71/ld-* $DIR$LIB71 || error "can't create $LIB71/ld-*"
2935 echo "chroot $DIR /dbench -c client.txt 2"
2936 chroot $DIR /dbench -c client.txt 2
2939 rm -rf $DIR/dbench $TGT $DIR$LIB71
2943 run_test 71 "Running dbench on lustre (don't segment fault) ===="
2945 test_72() { # bug 5695 - Test that on 2.6 remove_suid works properly
2946 check_kernel_version 43 || return 0
2947 [ "$RUNAS_ID" = "$UID" ] && skip "RUNAS_ID = UID = $UID -- skipping" && return
2951 $RUNAS dd if=/dev/zero of=$DIR/f72 bs=512 count=1 || error
2952 # See if we are still setuid/sgid
2953 test -u $DIR/f72 -o -g $DIR/f72 && error "S/gid is not dropped on write"
2954 # Now test that MDS is updated too
2955 cancel_lru_locks mdc
2956 test -u $DIR/f72 -o -g $DIR/f72 && error "S/gid is not dropped on MDS"
2959 run_test 72 "Test that remove suid works properly (bug5695) ===="
2961 # bug 3462 - multiple simultaneous MDC requests
2965 multiop $DIR/d73-1/f73-1 O_c &
2967 #give multiop a chance to open
2970 #define OBD_FAIL_MDS_PAUSE_OPEN 0x129
2971 sysctl -w lustre.fail_loc=0x80000129
2972 multiop $DIR/d73-1/f73-2 Oc &
2974 sysctl -w lustre.fail_loc=0
2976 multiop $DIR/d73-2/f73-3 Oc &
2980 wait $pid1 || return 1
2984 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
2985 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
2986 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
2990 run_test 73 "multiple MDC requests (should not deadlock)"
2992 test_74a() { # bug 6149, 6184
2993 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
2995 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
2996 # will spin in a tight reconnection loop
2998 sysctl -w lustre.fail_loc=0x8000030e
2999 # get any lock that won't be difficult - lookup works.
3001 sysctl -w lustre.fail_loc=0
3004 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
3006 test_74b() { # bug 13310
3007 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
3009 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
3010 # will spin in a tight reconnection loop
3011 sysctl -w lustre.fail_loc=0x8000030e
3012 # get a "difficult" lock
3014 sysctl -w lustre.fail_loc=0
3017 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
3019 JOIN=${JOIN:-"lfs join"}
3026 [ $T75_PREP = "yes" ] && return
3027 echo "using F75=$F75, F128k=$F128k, FHEAD=$FHEAD, FTAIL=$FTAIL"
3029 dd if=/dev/urandom of=${F75}_128k bs=128k count=1 || error "dd failed"
3038 cp -p ${F128k} ${FHEAD}
3039 log "finished cp to $FHEAD"
3040 cp -p ${F128k} ${FTAIL}
3041 log "finished cp to $FTAIL"
3042 cat ${F128k} ${F128k} > ${F75}_sim_sim
3044 $JOIN ${FHEAD} ${FTAIL} || error "join ${FHEAD} ${FTAIL} error"
3045 log "finished join $FHEAD to ${F75}_sim_sim"
3046 cmp ${FHEAD} ${F75}_sim_sim || error "${FHEAD} ${F75}_sim_sim differ"
3047 log "finished cmp $FHEAD to ${F75}_sim_sim"
3048 $CHECKSTAT -a ${FTAIL} || error "tail ${FTAIL} still exist after join"
3050 run_test 75a "TEST join file ===================================="
3055 cp -p ${F128k} ${FTAIL}
3056 cat ${F75}_sim_sim >> ${F75}_join_sim
3057 cat ${F128k} >> ${F75}_join_sim
3058 $JOIN ${FHEAD} ${FTAIL} || error "join ${FHEAD} ${FTAIL} error"
3059 cmp ${FHEAD} ${F75}_join_sim || \
3060 error "${FHEAD} ${F75}_join_sim are different"
3061 $CHECKSTAT -a ${FTAIL} || error "tail ${FTAIL} exist after join"
3063 run_test 75b "TEST join file 2 =================================="
3068 cp -p ${F128k} ${FTAIL}
3069 cat ${F128k} >> ${F75}_sim_join
3070 cat ${F75}_join_sim >> ${F75}_sim_join
3071 $JOIN ${FTAIL} ${FHEAD} || error "join error"
3072 cmp ${FTAIL} ${F75}_sim_join || \
3073 error "${FTAIL} ${F75}_sim_join are different"
3074 $CHECKSTAT -a ${FHEAD} || error "tail ${FHEAD} exist after join"
3076 run_test 75c "TEST join file 3 =================================="
3081 cp -p ${F128k} ${FHEAD}
3082 cp -p ${F128k} ${FHEAD}_tmp
3083 cat ${F75}_sim_sim >> ${F75}_join_join
3084 cat ${F75}_sim_join >> ${F75}_join_join
3085 $JOIN ${FHEAD} ${FHEAD}_tmp || error "join ${FHEAD} ${FHEAD}_tmp error"
3086 $JOIN ${FHEAD} ${FTAIL} || error "join ${FHEAD} ${FTAIL} error"
3087 cmp ${FHEAD} ${F75}_join_join ||error "${FHEAD} ${F75}_join_join differ" $CHECKSTAT -a ${FHEAD}_tmp || error "${FHEAD}_tmp exist after join"
3088 $CHECKSTAT -a ${FTAIL} || error "tail ${FTAIL} exist after join (2)"
3090 run_test 75d "TEST join file 4 =================================="
3095 rm -rf ${FHEAD} || "delete join file error"
3097 run_test 75e "TEST join file 5 (remove joined file) ============="
3102 cp -p ${F128k} ${F75}_join_10_compare
3103 cp -p ${F128k} ${F75}_join_10
3104 for ((i = 0; i < 10; i++)); do
3105 cat ${F128k} >> ${F75}_join_10_compare
3106 cp -p ${F128k} ${FTAIL}
3107 $JOIN ${F75}_join_10 ${FTAIL} || \
3108 error "join ${F75}_join_10 ${FTAIL} error"
3109 $CHECKSTAT -a ${FTAIL} || error "tail file exist after join"
3111 cmp ${F75}_join_10 ${F75}_join_10_compare || \
3112 error "files ${F75}_join_10 ${F75}_join_10_compare differ"
3114 run_test 75f "TEST join file 6 (join 10 files) =================="
3117 [ ! -f ${F75}_join_10 ] && echo "${F75}_join_10 missing" && return
3118 $LFS getstripe ${F75}_join_10
3120 $OPENUNLINK ${F75}_join_10 ${F75}_join_10 || error "files unlink open"
3124 run_test 75g "TEST join file 7 (open unlink) ===================="
3127 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
3130 test_76() { # bug 1443
3131 DETH=$(grep deathrow /proc/kallsyms /proc/ksyms 2> /dev/null | wc -l)
3132 [ $DETH -eq 0 ] && skip "No _iget." && return 0
3133 BEFORE_INODES=`num_inodes`
3134 echo "before inodes: $BEFORE_INODES"
3135 for i in `seq 1000`; do
3139 AFTER_INODES=`num_inodes`
3140 echo "after inodes: $AFTER_INODES"
3141 [ $AFTER_INODES -gt $((BEFORE_INODES + 32)) ] && \
3142 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
3145 run_test 76 "destroy duplicate inodes in client inode cache ===="
3150 [ "$ORIG_CSUM" ] || ORIG_CSUM=`cat $LPROC/osc/*/checksums | head -n1`
3151 for f in $LPROC/osc/*/checksums; do
3158 F77_TMP=$TMP/f77-temp
3161 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
3162 error "error writing to $F77_TMP"
3165 test_77a() { # bug 10889
3166 [ ! -f $F77_TMP ] && setup_f77
3168 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
3171 run_test 77a "normal checksum read/write operation ============="
3173 test_77b() { # bug 10889
3174 [ ! -f $F77_TMP ] && setup_f77
3175 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
3176 sysctl -w lustre.fail_loc=0x80000409
3178 dd if=$F77_TMP of=$DIR/f77b bs=1M count=$F77SZ conv=sync || \
3179 error "dd error: $?"
3180 sysctl -w lustre.fail_loc=0
3183 run_test 77b "checksum error on client write ===================="
3185 test_77c() { # bug 10889
3186 [ ! -f $DIR/f77b ] && skip "requires 77b - skipping" && return
3187 cancel_lru_locks osc
3188 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
3189 sysctl -w lustre.fail_loc=0x80000408
3191 cmp $F77_TMP $DIR/f77b || error "file compare failed"
3192 sysctl -w lustre.fail_loc=0
3195 run_test 77c "checksum error on client read ==================="
3197 test_77d() { # bug 10889
3198 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
3199 sysctl -w lustre.fail_loc=0x80000409
3201 directio write $DIR/f77 0 $F77SZ $((1024 * 1024)) || \
3202 error "direct write: rc=$?"
3203 sysctl -w lustre.fail_loc=0
3206 run_test 77d "checksum error on OST direct write ==============="
3208 test_77e() { # bug 10889
3209 [ ! -f $DIR/f77 ] && skip "requires 77d - skipping" && return
3210 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
3211 sysctl -w lustre.fail_loc=0x80000408
3213 cancel_lru_locks osc
3214 directio read $DIR/f77 0 $F77SZ $((1024 * 1024)) || \
3215 error "direct read: rc=$?"
3216 sysctl -w lustre.fail_loc=0
3219 run_test 77e "checksum error on OST direct read ================"
3221 test_77f() { # bug 10889
3222 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
3223 sysctl -w lustre.fail_loc=0x409
3225 directio write $DIR/f77 0 $F77SZ $((1024 * 1024)) && \
3226 error "direct write succeeded"
3227 sysctl -w lustre.fail_loc=0
3230 run_test 77f "repeat checksum error on write (expect error) ===="
3232 test_77g() { # bug 10889
3233 [ $(grep -c obdfilter $LPROC/devices) -eq 0 ] && \
3234 skip "remote OST" && return
3235 [ ! -f $F77_TMP ] && setup_f77
3236 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
3237 sysctl -w lustre.fail_loc=0x8000021a
3239 dd if=$F77_TMP of=$DIR/f77g bs=1M count=$F77SZ || \
3240 error "write error: rc=$?"
3241 sysctl -w lustre.fail_loc=0
3244 run_test 77g "checksum error on OST write ======================"
3246 test_77h() { # bug 10889
3247 [ $(grep -c obdfilter $LPROC/devices) -eq 0 ] && \
3248 skip "remote OST" && return
3249 [ ! -f $DIR/f77g ] && skip "requires 77g - skipping" && return
3250 cancel_lru_locks osc
3251 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
3252 sysctl -w lustre.fail_loc=0x8000021b
3254 cmp $F77_TMP $DIR/f77g || error "file compare failed"
3255 sysctl -w lustre.fail_loc=0
3258 run_test 77h "checksum error on OST read ======================="
3260 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
3264 test_78() { # bug 10901
3266 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
3267 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
3268 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 2048))
3269 echo "MemTotal: $((MEMTOTAL * 2))"
3270 [ $F78SIZE -gt $MEMTOTAL ] && F78SIZE=$MEMTOTAL
3271 [ $F78SIZE -gt 512 ] && F78SIZE=512
3272 [ $F78SIZE -gt $((MAXFREE / 1024)) ] && F78SIZE=$((MAXFREE / 1024))
3273 SMALLESTOST=`lfs df $DIR |grep OST | awk '{print $4}' |sort -n |head -1`
3274 echo "Smallest OST: $SMALLESTOST"
3275 [ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024)) ] && \
3276 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024))
3277 echo "File size: $F78SIZE"
3278 $SETSTRIPE $DIR/$tfile -c -1 || error "setstripe failed"
3279 for i in `seq 1 $NSEQ`
3281 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
3282 echo directIO rdwr round $i of $NSEQ
3283 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
3288 run_test 78 "handle large O_DIRECT writes correctly ============"
3290 test_79() { # bug 12743
3291 [ $(grep -c obdfilter $LPROC/devices) -eq 0 ] &&
3292 skip "skipping test for remote OST" && return
3294 wait_delete_completed
3296 BKTOTAL=`awk 'BEGIN{total=0}; {total+=$1}; END{print total}' \
3297 $LPROC/obdfilter/*/kbytestotal`
3298 BKFREE=`awk 'BEGIN{free=0}; {free+=$1}; END{print free}' \
3299 $LPROC/obdfilter/*/kbytesfree`
3300 BKAVAIL=`awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}' \
3301 $LPROC/obdfilter/*/kbytesavail`
3302 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
3303 DFTOTAL=`echo $STRING | cut -d, -f1`
3304 DFUSED=`echo $STRING | cut -d, -f2`
3305 DFAVAIL=`echo $STRING | cut -d, -f3`
3306 DFFREE=$(($DFTOTAL - $DFUSED))
3308 ALLOWANCE=$((64 * $OSTCOUNT))
3310 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
3311 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
3312 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
3314 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
3315 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
3316 error "df free($DFFREE) mismatch OST free($BKFREE)"
3318 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
3319 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
3320 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
3323 run_test 79 "df report consistency check ======================="
3325 test_80() { # bug 10718
3326 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
3329 cancel_lru_locks OSC
3331 DIFF=$((AFTER-BEFORE))
3332 if [ $DIFF -gt 1 ] ; then
3333 error "elapsed for 1M@1T = $DIFF"
3337 run_test 80 "Page eviction is equally fast at high offsets too ===="
3339 # on the LLNL clusters, runas will still pick up root's $TMP settings,
3340 # which will not be writable for the runas user, and then you get a CVS
3341 # error message with a corrupt path string (CVS bug) and panic.
3342 # We're not using much space, so just stick it in /tmp, which is safe.
3348 [ $RUNAS_ID -ne $UID ] && HOME=/tmp
3351 mkdir -p $DIR/d99cvsroot || error "mkdir $DIR/d99cvsroot failed"
3352 chown $RUNAS_ID $DIR/d99cvsroot || error "chown $DIR/d99cvsroot failed"
3353 $RUNAS cvs -d $DIR/d99cvsroot init || error "cvs init failed"
3355 run_test 99a "cvs init ========================================="
3358 [ ! -d $DIR/d99cvsroot ] && test_99a
3359 $RUNAS [ ! -w /tmp ] && skip "/tmp has wrong w permission -- skipping" && return
3360 cd /etc/init.d || error "cd /etc/init.d failed"
3361 # some versions of cvs import exit(1) when asked to import links or
3362 # files they can't read. ignore those files.
3363 TOIGNORE=$(find . -type l -printf '-I %f\n' -o \
3364 ! -perm +4 -printf '-I %f\n')
3365 $RUNAS cvs -d $DIR/d99cvsroot import -m "nomesg" $TOIGNORE \
3366 d99reposname vtag rtag > /dev/null || error "cvs import failed"
3368 run_test 99b "cvs import ======================================="
3371 [ ! -d $DIR/d99cvsroot ] && test_99b
3372 cd $DIR || error "cd $DIR failed"
3373 mkdir -p $DIR/d99reposname || error "mkdir $DIR/d99reposname failed"
3374 chown $RUNAS_ID $DIR/d99reposname || \
3375 error "chown $DIR/d99reposname failed"
3376 $RUNAS cvs -d $DIR/d99cvsroot co d99reposname > /dev/null || \
3377 error "cvs co d99reposname failed"
3379 run_test 99c "cvs checkout ====================================="
3382 [ ! -d $DIR/d99cvsroot ] && test_99c
3383 cd $DIR/d99reposname
3385 $RUNAS cvs add -m 'addmsg' foo99
3387 run_test 99d "cvs add =========================================="
3390 [ ! -d $DIR/d99cvsroot ] && test_99c
3391 cd $DIR/d99reposname
3394 run_test 99e "cvs update ======================================="
3397 [ ! -d $DIR/d99cvsroot ] && test_99d
3398 cd $DIR/d99reposname
3399 $RUNAS cvs commit -m 'nomsg' foo99
3401 run_test 99f "cvs commit ======================================="
3404 netstat -tna | while read PROT SND RCV LOCAL REMOTE STAT; do
3405 [ "$PROT" != "tcp" ] && continue
3406 RPORT=`echo $REMOTE | cut -d: -f2`
3407 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
3408 LPORT=`echo $LOCAL | cut -d: -f2`
3409 if [ $LPORT -ge 1024 ]; then
3410 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
3412 error "local: $LPORT > 1024, remote: $RPORT"
3417 run_test 100 "check local port using privileged port ==========="
3419 function get_named_value()
3428 echo $line | sed "s/^$tag//"
3435 export CACHE_MAX=`cat $LPROC/llite/*/max_cached_mb | head -n 1`
3437 for s in $LPROC/llite/*/max_cached_mb; do
3438 echo $CACHE_MAX > $s
3447 [ "$CPU" = "UML" ] && nreads=1000
3448 local cache_limit=32
3450 for s in $LPROC/osc/*/rpc_stats; do
3453 trap cleanup_101 EXIT
3454 for s in $LPROC/llite/*; do
3455 echo 0 > $s/read_ahead_stats
3456 echo $cache_limit > $s/max_cached_mb
3460 # randomly read 10000 of 64K chunks from file 3x 32MB in size
3462 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
3463 $RANDOM_READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
3466 for s in $LPROC/llite/*; do
3467 discard=$(($discard + $(cat $s/read_ahead_stats | get_named_value 'read but discarded')))
3471 if [ $(($discard * 10)) -gt $nreads ] ;then
3472 for s in $LPROC/osc/*/rpc_stats; do
3475 for s in $LPROC/llite/*/read_ahead_stats; do
3478 error "too many ($discard) discarded pages"
3480 rm -f $DIR/$tfile || true
3482 run_test 101 "check read-ahead for random reads ================"
3484 export SETUP_TEST102=no
3486 [ "$SETUP_TEST102" = "yes" ] && return
3492 trap cleanup_test102 EXIT
3494 $SETSTRIPE $tdir -s $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT
3498 for count in 1 2 3 4
3500 for offset in 0 1 2 3
3502 local stripe_size=`expr $STRIPE_SIZE \* $num`
3503 local file=file"$num-$offset-$count"
3504 $SETSTRIPE $file -s $stripe_size -i $offset -c $count
3510 star -c f=$TMP/f102.tar $tdir
3515 [ "$SETUP_TEST102" = "yes" ] || return
3523 local testfile=$DIR/xattr_testfile
3528 [ "$UID" != 0 ] && skip "must run as root" && return
3529 [ -z "`grep xattr $LPROC/mdc/*[mM][dD][cC]*/connect_flags`" ] && skip "must have user_xattr" && return
3530 [ -z "$(which setfattr 2>/dev/null)" ] && skip "could not find setfattr" && return
3532 echo "set/get xattr..."
3533 setfattr -n trusted.name1 -v value1 $testfile || error
3534 [ "`getfattr -n trusted.name1 $testfile 2> /dev/null | \
3535 grep "trusted.name1"`" == "trusted.name1=\"value1\"" ] || error
3537 setfattr -n user.author1 -v author1 $testfile || error
3538 [ "`getfattr -n user.author1 $testfile 2> /dev/null | \
3539 grep "user.author1"`" == "user.author1=\"author1\"" ] || error
3542 setfattr -n trusted.name2 -v value2 $testfile || error
3543 setfattr -n trusted.name3 -v value3 $testfile || error
3544 [ `getfattr -d -m "^trusted" $testfile 2> /dev/null | \
3545 grep "trusted.name" | wc -l` -eq 3 ] || error
3548 setfattr -n user.author2 -v author2 $testfile || error
3549 setfattr -n user.author3 -v author3 $testfile || error
3550 [ `getfattr -d -m "^user" $testfile 2> /dev/null | \
3551 grep "user" | wc -l` -eq 3 ] || error
3553 echo "remove xattr..."
3554 setfattr -x trusted.name1 $testfile || error
3555 getfattr -d -m trusted $testfile 2> /dev/null | \
3556 grep "trusted.name1" && error || true
3558 setfattr -x user.author1 $testfile || error
3559 getfattr -d -m user $testfile 2> /dev/null | \
3560 grep "user.author1" && error || true
3562 # b10667: setting lustre special xattr be silently discarded
3563 echo "set lustre special xattr ..."
3564 setfattr -n "trusted.lov" -v "invalid value" $testfile || error
3568 run_test 102a "user xattr test =================================="
3571 # b10930: get/set/list trusted.lov xattr
3572 echo "get/set/list trusted.lov xattr ..."
3573 [ "$OSTCOUNT" -lt "2" ] && skip "skipping 2-stripe test" && return
3574 local testfile=$DIR/$tfile
3575 $SETSTRIPE $testfile -s 65536 -i 1 -c 2
3576 getfattr -d -m "^trusted" $testfile 2> /dev/null | \
3577 grep "trusted.lov" || error "can't get trusted.lov from $testfile"
3579 local testfile2=${testfile}2
3580 local value=`getfattr -n trusted.lov $testfile 2> /dev/null | \
3581 grep "trusted.lov" |sed -e 's/[^=]\+=//'`
3584 setfattr -n trusted.lov -v $value $testfile2
3585 local tmp_file=${testfile}3
3586 $GETSTRIPE -v $testfile2 > $tmp_file
3587 local stripe_size=`grep "size" $tmp_file| awk '{print $2}'`
3588 local stripe_count=`grep "count" $tmp_file| awk '{print $2}'`
3589 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
3590 [ $stripe_count -eq 2 ] || error "stripe count $stripe_count != 2"
3592 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
3595 # b10930: get/set/list lustre.lov xattr
3596 echo "get/set/list lustre.lov xattr ..."
3597 [ "$OSTCOUNT" -lt "2" ] && skip "skipping 2-stripe test" && return
3599 chown $RUNAS_ID $DIR/$tdir
3600 local testfile=$DIR/$tdir/$tfile
3601 $RUNAS $SETSTRIPE $testfile -s 65536 -i 1 -c 2
3602 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
3603 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
3605 local testfile2=${testfile}2
3606 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
3607 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
3609 $RUNAS $MCREATE $testfile2
3610 $RUNAS setfattr -n lustre.lov -v $value $testfile2
3611 local tmp_file=${testfile}3
3612 $RUNAS $GETSTRIPE -v $testfile2 > $tmp_file
3613 local stripe_size=`grep "size" $tmp_file| awk '{print $2}'`
3614 local stripe_count=`grep "count" $tmp_file| awk '{print $2}'`
3615 [ "$stripe_size" -eq 65536 ] || error "stripe size $stripe_size != 65536"
3616 [ "$stripe_count" -eq 2 ] || error "stripe count $stripe_count != 2"
3618 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
3624 local lines=`sed -n '/obdidx/=' $1`
3625 stripe_size=`awk '{if($1~/size/) print $2}' $1`
3626 stripe_count=`awk '{if($1~/count/) print $2}' $1`
3627 lines=`expr $lines + 1`
3628 stripe_offset=`sed -n ${lines}p $1 |awk '{print $1}'`
3631 compare_stripe_info1() {
3634 for count in 1 2 3 4
3636 for offset in 0 1 2 3
3638 local size=`expr $STRIPE_SIZE \* $num`
3639 local file=file"$num-$offset-$count"
3641 $GETSTRIPE -v $file > $tmp_file
3642 get_stripe_info $tmp_file
3643 if test $stripe_size -ne $size
3645 error "$file: different stripe size" && return
3647 if test $stripe_count -ne $count
3649 error "$file: different stripe count" && return
3651 if test $stripe_offset -ne 0
3653 error "$file: different stripe offset" && return
3661 compare_stripe_info2() {
3664 for count in 1 2 3 4
3666 for offset in 0 1 2 3
3668 local size=`expr $STRIPE_SIZE \* $num`
3669 local file=file"$num-$offset-$count"
3671 $GETSTRIPE -v $file > $tmp_file
3672 get_stripe_info $tmp_file
3673 if test $stripe_size -ne $size
3675 error "$file: different stripe size" && return
3677 if test $stripe_count -ne $count
3679 error "$file: different stripe count" && return
3681 if test $stripe_offset -ne $offset
3683 error "$file: different stripe offset" && return
3692 # b10930: star test for trusted.lov xattr
3693 star --xhelp 2>&1 | grep -q nolustre
3696 skip "being skipped because a lustre-aware star is not installed." && return
3698 [ "$OSTCOUNT" -lt "4" ] && skip "skipping 4-stripe test" && return
3701 star -x f=$TMP/f102.tar -C $DIR/d102d
3703 compare_stripe_info1
3706 run_test 102d "star restore stripe info from tarfile,not keep osts ==========="
3709 # b10930: star test for trusted.lov xattr
3710 star --xhelp 2>&1 | grep -q nolustre
3713 skip "being skipped because a lustre-aware star is not installed." && return
3715 [ "$OSTCOUNT" -lt "4" ] && skip "skipping 4-stripe test" && return
3718 star -x -preserve-osts f=$TMP/f102.tar -C $DIR/d102e
3720 compare_stripe_info2
3722 run_test 102e "star restore stripe info from tarfile, keep osts ==========="
3725 # b10930: star test for trusted.lov xattr
3726 star --xhelp 2>&1 | grep -q nolustre
3729 skip "being skipped because a lustre-aware star is not installed." && return
3731 [ "$OSTCOUNT" -lt "4" ] && skip "skipping 4-stripe test" && return
3735 star -copy $tdir $DIR/d102f
3737 compare_stripe_info1
3739 run_test 102f "star copy files, not keep osts ==========="
3742 # b10930: star test for trusted.lov xattr
3743 star --xhelp 2>&1 | grep -q nolustre
3746 skip "being skipped because a lustre-aware star is not installed." && return
3748 [ "$OSTCOUNT" -lt "4" ] && skip "skipping 4-stripe test" && return
3752 star -copy -preserve-osts $tdir $DIR/d102g
3754 compare_stripe_info2
3757 run_test 102g "star copy files, keep osts ==========="
3761 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
3766 [ "$UID" != 0 ] && skip "must run as root" && return
3767 [ -z "$(grep acl $LPROC/mdc/*[mM][dD][cC]*/connect_flags)" ] && skip "must have acl enabled" && return
3768 [ -z "$(which setfacl 2>/dev/null)" ] && skip "could not find setfacl" && return
3774 echo "performing cp ..."
3775 run_acl_subtest cp || error
3776 echo "performing getfacl-noacl..."
3777 run_acl_subtest getfacl-noacl > /dev/null || error
3778 echo "performing misc..."
3779 run_acl_subtest misc > /dev/null || error
3780 # XXX add back permission test when we support supplementary groups.
3781 # echo "performing permissions..."
3782 # run_acl_subtest permissions || error
3783 echo "performing setfacl..."
3784 run_acl_subtest setfacl > /dev/null || error
3786 # inheritance test got from HP
3787 echo "performing inheritance..."
3788 cp $LUSTRE/tests/acl/make-tree . || error
3789 chmod +x make-tree || error
3790 run_acl_subtest inheritance > /dev/null || error
3796 run_test 103 "acl test ========================================="
3800 lfs df || error "lfs df failed"
3801 lfs df -ih || error "lfs df -ih failed"
3802 lfs df -h $DIR || error "lfs df -h $DIR failed"
3803 lfs df -i $DIR || error "lfs df -i $DIR failed"
3804 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
3805 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
3807 OSC=`awk '/-osc-|OSC.*MNT/ {print $4}' $LPROC/devices | head -n 1`
3808 lctl --device %$OSC deactivate
3809 lfs df || error "lfs df with deactivated OSC failed"
3810 lctl --device %$OSC recover
3811 lfs df || error "lfs df with reactivated OSC failed"
3813 run_test 104 "lfs df [-ih] [path] test ========================="
3816 # doesn't work on 2.4 kernels
3818 if [ -n "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ];
3820 flocks_test on -f $DIR/$tfile || error "fail flock on"
3822 flocks_test off -f $DIR/$tfile || error "fail flock off"
3825 run_test 105a "flock when mounted without -o flock test ========"
3829 if [ -n "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ];
3831 flocks_test on -c $DIR/$tfile || error "fail flock on"
3833 flocks_test off -c $DIR/$tfile || error "fail flock off"
3836 run_test 105b "fcntl when mounted without -o flock test ========"
3840 if [ -n "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ];
3842 flocks_test on -l $DIR/$tfile || error "fail flock on"
3844 flocks_test off -l $DIR/$tfile || error "fail flock off"
3847 run_test 105c "lockf when mounted without -o flock test ========"
3849 test_106() { #bug 10921
3850 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
3851 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
3853 run_test 106 "attempt exec of dir followed by chown of that dir"
3862 file=`cat /proc/sys/kernel/core_pattern`
3863 core_pid=`cat /proc/sys/kernel/core_uses_pid`
3864 [ $core_pid -eq 1 ] && file=$file.$SLEEPPID
3868 kill -s 11 $SLEEPPID
3870 if [ -e $file ]; then
3871 size=`stat -c%s $file`
3872 [ $size -eq 0 ] && error "Zero length core file $file"
3874 error "Fail to create core file $file"
3879 run_test 107 "Coredump on SIG"
3882 OSTIO_pre=$(ps -e|grep ll_ost_io|awk '{print $4}'|sort -n|tail -1|\
3884 [ -z "$OSTIO_pre" ] && skip "no OSS threads" && \
3886 echo "Starting with $OSTIO_pre threads"
3889 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
3890 [ $NUMFREE -lt $NUMTEST ] && NUMTEST=$(($NUMFREE - 1000))
3891 echo "$NUMTEST creates/unlinks"
3893 createmany -o $DIR/$tdir/$tfile $NUMTEST
3894 unlinkmany $DIR/$tdir/$tfile $NUMTEST
3896 OSTIO_post=$(ps -e|grep ll_ost_io|awk '{print $4}'|sort -n|tail -1|\
3899 # don't return an error
3900 [ $OSTIO_post -eq $OSTIO_pre ] && echo \
3901 "FAIL: No addition ll_ost_io threads were created ($OSTIO_pre)" &&\
3902 echo "This may be fine, depending on what ran before this test" &&\
3903 echo "and how fast this system is." && return
3905 echo "Started with $OSTIO_pre threads, ended with $OSTIO_post"
3907 run_test 115 "verify dynamic thread creation===================="
3910 wait_delete_completed
3911 AVAIL=($(cat $LPROC/osc/*[oO][sS][cC][-_]*/kbytesavail))
3912 echo OST kbytes available: ${AVAIL[@]}
3913 MAXI=0; MAXV=${AVAIL[0]}
3914 MINI=0; MINV=${AVAIL[0]}
3915 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
3916 #echo OST $i: ${AVAIL[i]}kb
3917 if [ ${AVAIL[i]} -gt $MAXV ]; then
3918 MAXV=${AVAIL[i]}; MAXI=$i
3920 if [ ${AVAIL[i]} -lt $MINV ]; then
3921 MINV=${AVAIL[i]}; MINI=$i
3924 echo Min free space: OST $MINI: $MINV
3925 echo Max free space: OST $MAXI: $MAXV
3929 [ "$OSTCOUNT" -lt "2" ] && skip "too few OSTs" && return
3930 remote_mds && skip "remote MDS" && return
3932 echo -n "Free space priority "
3933 cat $LPROC/lov/*/qos_prio_free
3934 DELAY=$(cat $LPROC/lov/*/qos_maxage | head -1 | awk '{print $1}')
3937 [ $MINV -gt 960000 ] && skip "too much free space in OST$MINI" &&\
3940 # generate uneven OSTs
3941 mkdir -p $DIR/$tdir/OST${MINI}
3944 echo "Filling 25% remaining space in OST${MINI} with ${FILL}Kb"
3945 $SETSTRIPE $DIR/$tdir/OST${MINI} -i $MINI -c 1
3947 while [ $FILL -gt 0 ]; do
3948 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i bs=2M count=1 2>/dev/null
3949 FILL=$(($FILL - 2048))
3958 DIFF=$(($MAXV - $MINV))
3959 DIFF2=$(($DIFF * 100 / $MINV))
3960 echo -n "diff=${DIFF}=${DIFF2}% must be > 20% for QOS mode..."
3961 if [ $DIFF2 -gt 20 ]; then
3964 echo "failed - QOS mode won't be used"
3965 error "QOS imbalance criteria not met"
3969 MINI1=$MINI; MINV1=$MINV
3970 MAXI1=$MAXI; MAXV1=$MAXV
3972 # now fill using QOS
3973 echo writing a bunch of files to QOS-assigned OSTs
3974 $SETSTRIPE $DIR/$tdir -c 1
3976 while [ $FILL -gt 0 ]; do
3977 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1024 count=200 2>/dev/null
3978 FILL=$(($FILL - 200))
3982 echo "wrote $i 200k files"
3986 echo "Note: free space may not be updated, so measurements might be off"
3988 DIFF2=$(($MAXV - $MINV))
3989 echo "free space delta: orig $DIFF final $DIFF2"
3990 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
3991 DIFF=$(($MINV1 - ${AVAIL[$MINI1]}))
3992 echo "Wrote $DIFF to smaller OST $MINI1"
3993 DIFF2=$(($MAXV1 - ${AVAIL[$MAXI1]}))
3994 echo "Wrote $DIFF2 to larger OST $MAXI1"
3995 [ $DIFF -gt 0 ] && echo "Wrote $(($DIFF2 * 100 / $DIFF - 100))% more data to larger OST $MAXI1"
3997 # Figure out which files were written where
3998 UUID=$(awk '/'$MINI1': / {print $2; exit}' $LPROC/lov/${FSNAME}-clilov-*/target_obd)
4000 MINC=$($GETSTRIPE --obd $UUID $DIR/$tdir | wc -l)
4001 echo "$MINC files created on smaller OST $MINI1"
4002 UUID=$(awk '/'$MAXI1': / {print $2; exit}' $LPROC/lov/${FSNAME}-clilov-*/target_obd)
4003 MAXC=$($GETSTRIPE --obd $UUID $DIR/$tdir | wc -l)
4004 echo "$MAXC files created on larger OST $MAXI1"
4005 [ $MINC -gt 0 ] && echo "Wrote $(($MAXC * 100 / $MINC - 100))% more files to larger OST $MAXI1"
4006 [ $MAXC -gt $MINC ] || error "stripe QOS didn't balance free space"
4008 run_test 116 "stripe QOS: free space balance ==================="
4010 test_117() # bug 10891
4012 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
4013 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
4014 sysctl -w lustre.fail_loc=0x21e
4015 > $DIR/$tfile || error "truncate failed"
4016 sysctl -w lustre.fail_loc=0
4017 echo "Truncate succeeded."
4019 run_test 117 "verify fsfilt_extend ============================="
4021 # Reset async IO behavior after error case
4023 FILE=$DIR/reset_async
4025 # Ensure all OSCs are cleared
4026 $LSTRIPE $FILE 0 -1 -1
4027 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
4032 test_118a() #bug 11710
4036 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
4037 DIRTY=$(grep -c dirty $LPROC/llite/*/dump_page_cache)
4038 WRITEBACK=$(grep -c writeback $LPROC/llite/*/dump_page_cache)
4040 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
4041 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
4045 run_test 118a "verify O_SYNC works =========="
4051 #define OBD_FAIL_OST_ENOENT 0x217
4052 do_facet ost sysctl -w lustre.fail_loc=0x217
4053 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
4055 do_facet ost sysctl -w lustre.fail_loc=0
4056 DIRTY=$(grep -c dirty $LPROC/llite/*/dump_page_cache)
4057 WRITEBACK=$(grep -c writeback $LPROC/llite/*/dump_page_cache)
4059 if [[ $RC -eq 0 ]]; then
4060 error "Must return error due to dropped pages, rc=$RC"
4064 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
4065 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
4069 echo "Dirty pages not leaked on ENOENT"
4071 # Due to the above error the OSC will issue all RPCs syncronously
4072 # until a subsequent RPC completes successfully without error.
4073 multiop $DIR/$tfile Ow4096yc
4078 run_test 118b "Reclaim dirty pages on fatal error =========="
4084 #define OBD_FAIL_OST_EROFS 0x216
4085 do_facet ost sysctl -w lustre.fail_loc=0x216
4087 # multiop should block due to fsync until pages are written
4088 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
4092 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
4093 error "Multiop failed to block on fsync, pid=$MULTIPID"
4096 WRITEBACK=$(grep -c writeback $LPROC/llite/*/dump_page_cache)
4097 if [[ $WRITEBACK -eq 0 ]]; then
4098 error "No page in writeback, writeback=$WRITEBACK"
4101 do_facet ost sysctl -w lustre.fail_loc=0
4104 if [[ $RC -ne 0 ]]; then
4105 error "Multiop fsync failed, rc=$RC"
4108 DIRTY=$(grep -c dirty $LPROC/llite/*/dump_page_cache)
4109 WRITEBACK=$(grep -c writeback $LPROC/llite/*/dump_page_cache)
4110 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
4111 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
4115 echo "Dirty pages flushed via fsync on EROFS"
4118 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
4124 #define OBD_FAIL_OST_BRW_PAUSE_BULK
4125 do_facet ost sysctl -w lustre.fail_loc=0x214
4126 # multiop should block due to fsync until pages are written
4127 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
4131 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
4132 error "Multiop failed to block on fsync, pid=$MULTIPID"
4135 WRITEBACK=$(grep -c writeback $LPROC/llite/*/dump_page_cache)
4136 if [[ $WRITEBACK -eq 0 ]]; then
4137 error "No page in writeback, writeback=$WRITEBACK"
4140 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
4141 do_facet ost sysctl -w lustre.fail_loc=0
4143 DIRTY=$(grep -c dirty $LPROC/llite/*/dump_page_cache)
4144 WRITEBACK=$(grep -c writeback $LPROC/llite/*/dump_page_cache)
4145 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
4146 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
4150 echo "Dirty pages gaurenteed flushed via fsync"
4153 run_test 118d "Fsync validation inject a delay of the bulk =========="
4158 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
4159 sysctl -w lustre.fail_loc=0x8000040a
4161 # Should simulate EINVAL error which is fatal
4162 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
4164 if [[ $RC -eq 0 ]]; then
4165 error "Must return error due to dropped pages, rc=$RC"
4168 sysctl -w lustre.fail_loc=0x0
4170 LOCKED=$(grep -c locked $LPROC/llite/*/dump_page_cache)
4171 DIRTY=$(grep -c dirty $LPROC/llite/*/dump_page_cache)
4172 WRITEBACK=$(grep -c writeback $LPROC/llite/*/dump_page_cache)
4173 if [[ $LOCKED -ne 0 ]]; then
4174 error "Locked pages remain in cache, locked=$LOCKED"
4177 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
4178 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
4182 echo "No pages locked after fsync"
4187 run_test 118f "Simulate unrecoverable OSC side error =========="
4192 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
4193 sysctl -w lustre.fail_loc=0x406
4195 # simulate local -ENOMEM
4196 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
4199 sysctl -w lustre.fail_loc=0
4200 if [[ $RC -eq 0 ]]; then
4201 error "Must return error due to dropped pages, rc=$RC"
4204 LOCKED=$(grep -c locked $LPROC/llite/*/dump_page_cache)
4205 DIRTY=$(grep -c dirty $LPROC/llite/*/dump_page_cache)
4206 WRITEBACK=$(grep -c writeback $LPROC/llite/*/dump_page_cache)
4207 if [[ $LOCKED -ne 0 ]]; then
4208 error "Locked pages remain in cache, locked=$LOCKED"
4211 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
4212 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
4216 echo "No pages locked after fsync"
4221 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
4226 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
4227 do_facet ost sysctl -w lustre.fail_loc=0x20e
4228 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
4229 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
4232 do_facet ost sysctl -w lustre.fail_loc=0
4233 if [[ $RC -eq 0 ]]; then
4234 error "Must return error due to dropped pages, rc=$RC"
4237 LOCKED=$(grep -c locked $LPROC/llite/*/dump_page_cache)
4238 DIRTY=$(grep -c dirty $LPROC/llite/*/dump_page_cache)
4239 WRITEBACK=$(grep -c writeback $LPROC/llite/*/dump_page_cache)
4240 if [[ $LOCKED -ne 0 ]]; then
4241 error "Locked pages remain in cache, locked=$LOCKED"
4244 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
4245 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
4249 echo "No pages locked after fsync"
4253 run_test 118h "Verify timeout in handling recoverables errors =========="
4258 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
4259 do_facet ost sysctl -w lustre.fail_loc=0x20e
4261 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
4262 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
4265 do_facet ost sysctl -w lustre.fail_loc=0
4269 if [[ $RC -ne 0 ]]; then
4270 error "got error, but should be not, rc=$RC"
4273 LOCKED=$(grep -c locked $LPROC/llite/*/dump_page_cache)
4274 DIRTY=$(grep -c dirty $LPROC/llite/*/dump_page_cache)
4275 WRITEBACK=$(grep -c writeback $LPROC/llite/*/dump_page_cache)
4276 if [[ $LOCKED -ne 0 ]]; then
4277 error "Locked pages remain in cache, locked=$LOCKED"
4280 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
4281 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
4285 echo "No pages locked after fsync"
4289 run_test 118i "Fix error before timeout in recoverable error =========="
4294 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
4295 do_facet ost sysctl -w lustre.fail_loc=0x220
4297 # return -EIO from OST
4298 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
4300 do_facet ost sysctl -w lustre.fail_loc=0x0
4301 if [[ $RC -eq 0 ]]; then
4302 error "Must return error due to dropped pages, rc=$RC"
4305 LOCKED=$(grep -c locked $LPROC/llite/*/dump_page_cache)
4306 DIRTY=$(grep -c dirty $LPROC/llite/*/dump_page_cache)
4307 WRITEBACK=$(grep -c writeback $LPROC/llite/*/dump_page_cache)
4308 if [[ $LOCKED -ne 0 ]]; then
4309 error "Locked pages remain in cache, locked=$LOCKED"
4312 # in recoverable error on OST we want resend and stay until it finished
4313 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
4314 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
4318 echo "No pages locked after fsync"
4322 run_test 118j "Simulate unrecoverable OST side error =========="
4326 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
4327 do_facet ost sysctl -w lustre.fail_loc=0x20e
4330 for ((i=0;i<10;i++)); do
4331 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
4332 error "dd to $DIR/$tdir/$tfile-$i failed" )&
4339 sysctl -w lustre.fail_loc=0
4341 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
4343 test_119a() # bug 11737
4345 BSIZE=$((512 * 1024))
4346 directio write $DIR/$tfile 0 1 $BSIZE
4347 # We ask to read two blocks, which is more than a file size.
4348 # directio will indicate an error when requested and actual
4349 # sizes aren't equeal (a normal situation in this case) and
4350 # print actual read amount.
4351 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
4352 if [ "$NOB" != "$BSIZE" ]; then
4353 error "read $NOB bytes instead of $BSIZE"
4357 run_test 119a "Short directIO read must return actual read amount"
4359 test_119b() # bug 11737
4361 [ "$OSTCOUNT" -lt "2" ] && skip "skipping 2-stripe test" && return
4363 $SETSTRIPE $DIR/$tfile -c 2
4364 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
4366 multiop $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) || \
4367 error "direct read failed"
4370 run_test 119b "Sparse directIO read must return actual read amount"
4372 test_119c() # bug 13099
4375 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
4376 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
4379 run_test 119c "Testing for direct read hitting hole"
4381 LDLM_POOL_CTL_RECALC=1
4382 LDLM_POOL_CTL_SHRINK=2
4384 disable_pool_recalc() {
4385 for NSD in $LPROC/ldlm/namespaces/*$1*; do
4386 if test -f $NSD/pool/control; then
4387 CONTROL=`cat $NSD/pool/control`
4388 CONTROL=$((CONTROL & ~LDLM_POOL_CTL_RECALC))
4389 echo "$CONTROL" > $NSD/pool/control
4394 enable_pool_recalc() {
4395 for NSD in $LPROC/ldlm/namespaces/*$1*; do
4396 if test -f $NSD/pool/control; then
4397 CONTROL=`cat $NSD/pool/control`
4398 CONTROL=$((CONTROL | LDLM_POOL_CTL_RECALC))
4399 echo "$CONTROL" > $NSD/pool/control
4404 disable_pool_shrink() {
4405 for NSD in $LPROC/ldlm/namespaces/*$1*; do
4406 if test -f $NSD/pool/control; then
4407 CONTROL=`cat $NSD/pool/control`
4408 CONTROL=$((CONTROL & ~LDLM_POOL_CTL_SHRINK))
4409 echo "$CONTROL" > $NSD/pool/control
4414 enable_pool_shrink() {
4415 for NSD in $LPROC/ldlm/namespaces/*$1*; do
4416 if test -f $NSD/pool/control; then
4417 CONTROL=`cat $NSD/pool/control`
4418 CONTROL=$((CONTROL | LDLM_POOL_CTL_SHRINK))
4419 echo "$CONTROL" > $NSD/pool/control
4425 disable_pool_shrink $1
4426 disable_pool_recalc $1
4430 enable_pool_shrink $1
4431 enable_pool_recalc $1
4437 enable_pool "filter-$FSNAME"
4439 enable_pool "mds-$FSNAME"
4442 lru_resize_disable()
4445 disable_pool "filter-$FSNAME"
4447 disable_pool "mds-$FSNAME"
4451 [ -z "`grep early_lock_cancel $LPROC/mdc/*/connect_flags`" ] && \
4452 skip "no early lock cancel on server" && return 0
4454 cancel_lru_locks mdc
4455 stat $DIR/$tdir > /dev/null
4456 can1=`awk '/ldlm_cancel/ {print $2}' $LPROC/ldlm/services/ldlm_canceld/stats`
4457 blk1=`awk '/ldlm_bl_callback/ {print $2}' $LPROC/ldlm/services/ldlm_cbd/stats`
4458 mkdir -p $DIR/$tdir/d1
4459 can2=`awk '/ldlm_cancel/ {print $2}' $LPROC/ldlm/services/ldlm_canceld/stats`
4460 blk2=`awk '/ldlm_bl_callback/ {print $2}' $LPROC/ldlm/services/ldlm_cbd/stats`
4461 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
4462 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
4465 run_test 120a "Early Lock Cancel: mkdir test ==================="
4468 [ -z "`grep early_lock_cancel $LPROC/mdc/*/connect_flags`" ] && \
4469 skip "no early lock cancel on server" && return 0
4471 cancel_lru_locks mdc
4472 stat $DIR/$tdir > /dev/null
4473 can1=`awk '/ldlm_cancel/ {print $2}' $LPROC/ldlm/services/ldlm_canceld/stats`
4474 blk1=`awk '/ldlm_bl_callback/ {print $2}' $LPROC/ldlm/services/ldlm_cbd/stats`
4476 blk2=`awk '/ldlm_bl_callback/ {print $2}' $LPROC/ldlm/services/ldlm_cbd/stats`
4477 can2=`awk '/ldlm_cancel/ {print $2}' $LPROC/ldlm/services/ldlm_canceld/stats`
4478 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
4479 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
4482 run_test 120b "Early Lock Cancel: create test =================="
4485 [ -z "`grep early_lock_cancel $LPROC/mdc/*/connect_flags`" ] && \
4486 skip "no early lock cancel on server" && return 0
4488 mkdir -p $DIR/$tdir/d1 $DIR/$tdir/d2
4489 touch $DIR/$tdir/d1/f1
4490 cancel_lru_locks mdc
4491 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
4492 can1=`awk '/ldlm_cancel/ {print $2}' $LPROC/ldlm/services/ldlm_canceld/stats`
4493 blk1=`awk '/ldlm_bl_callback/ {print $2}' $LPROC/ldlm/services/ldlm_cbd/stats`
4494 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
4495 can2=`awk '/ldlm_cancel/ {print $2}' $LPROC/ldlm/services/ldlm_canceld/stats`
4496 blk2=`awk '/ldlm_bl_callback/ {print $2}' $LPROC/ldlm/services/ldlm_cbd/stats`
4497 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
4498 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
4501 run_test 120c "Early Lock Cancel: link test ===================="
4504 [ -z "`grep early_lock_cancel $LPROC/mdc/*/connect_flags`" ] && \
4505 skip "no early lock cancel on server" && return 0
4508 cancel_lru_locks mdc
4509 stat $DIR/$tdir > /dev/null
4510 can1=`awk '/ldlm_cancel/ {print $2}' $LPROC/ldlm/services/ldlm_canceld/stats`
4511 blk1=`awk '/ldlm_bl_callback/ {print $2}' $LPROC/ldlm/services/ldlm_cbd/stats`
4512 chmod a+x $DIR/$tdir
4513 can2=`awk '/ldlm_cancel/ {print $2}' $LPROC/ldlm/services/ldlm_canceld/stats`
4514 blk2=`awk '/ldlm_bl_callback/ {print $2}' $LPROC/ldlm/services/ldlm_cbd/stats`
4515 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
4516 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
4519 run_test 120d "Early Lock Cancel: setattr test ================="
4522 [ -z "`grep early_lock_cancel $LPROC/mdc/*/connect_flags`" ] && \
4523 skip "no early lock cancel on server" && return 0
4525 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
4526 cancel_lru_locks mdc
4527 cancel_lru_locks osc
4528 dd if=$DIR/$tdir/f1 of=/dev/null
4529 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
4530 can1=`awk '/ldlm_cancel/ {print $2}' $LPROC/ldlm/services/ldlm_canceld/stats`
4531 blk1=`awk '/ldlm_bl_callback/ {print $2}' $LPROC/ldlm/services/ldlm_cbd/stats`
4532 unlink $DIR/$tdir/f1
4533 can2=`awk '/ldlm_cancel/ {print $2}' $LPROC/ldlm/services/ldlm_canceld/stats`
4534 blk2=`awk '/ldlm_bl_callback/ {print $2}' $LPROC/ldlm/services/ldlm_cbd/stats`
4535 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
4536 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
4539 run_test 120e "Early Lock Cancel: unlink test =================="
4542 [ -z "`grep early_lock_cancel $LPROC/mdc/*/connect_flags`" ] && \
4543 skip "no early lock cancel on server" && return 0
4545 mkdir -p $DIR/$tdir/d1 $DIR/$tdir/d2
4546 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
4547 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
4548 cancel_lru_locks mdc
4549 cancel_lru_locks osc
4550 dd if=$DIR/$tdir/d1/f1 of=/dev/null
4551 dd if=$DIR/$tdir/d2/f2 of=/dev/null
4552 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
4553 can1=`awk '/ldlm_cancel/ {print $2}' $LPROC/ldlm/services/ldlm_canceld/stats`
4554 blk1=`awk '/ldlm_bl_callback/ {print $2}' $LPROC/ldlm/services/ldlm_cbd/stats`
4555 mv $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
4556 can2=`awk '/ldlm_cancel/ {print $2}' $LPROC/ldlm/services/ldlm_canceld/stats`
4557 blk2=`awk '/ldlm_bl_callback/ {print $2}' $LPROC/ldlm/services/ldlm_cbd/stats`
4558 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
4559 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
4562 run_test 120f "Early Lock Cancel: rename test =================="
4565 [ -z "`grep early_lock_cancel $LPROC/mdc/*/connect_flags`" ] && \
4566 skip "no early lock cancel on server" && return 0
4569 echo create $count files
4571 cancel_lru_locks mdc
4572 cancel_lru_locks osc
4575 can0=`awk '/ldlm_cancel/ {print $2}' $LPROC/ldlm/services/ldlm_canceld/stats`
4576 blk0=`awk '/ldlm_bl_callback/ {print $2}' $LPROC/ldlm/services/ldlm_cbd/stats`
4577 createmany -o $DIR/$tdir/f $count
4579 can1=`awk '/ldlm_cancel/ {print $2}' $LPROC/ldlm/services/ldlm_canceld/stats`
4580 blk1=`awk '/ldlm_bl_callback/ {print $2}' $LPROC/ldlm/services/ldlm_cbd/stats`
4582 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
4583 echo rm $count files
4586 can2=`awk '/ldlm_cancel/ {print $2}' $LPROC/ldlm/services/ldlm_canceld/stats`
4587 blk2=`awk '/ldlm_bl_callback/ {print $2}' $LPROC/ldlm/services/ldlm_cbd/stats`
4589 echo total: $count removes in $((t2-t1))
4590 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
4592 # wait for commitment of removal
4595 run_test 120g "Early Lock Cancel: performance test ============="
4597 test_121() { #bug 10589
4598 writes=`dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk 'BEGIN { FS="+" } /out/ {print $1}'`
4599 sysctl -w lustre.fail_loc=0x310
4600 cancel_lru_locks osc > /dev/null
4601 reads=`dd if=$DIR/$tfile of=/dev/null 2>&1 | awk 'BEGIN { FS="+" } /in/ {print $1}'`
4602 sysctl -w lustre.fail_loc=0
4603 [ "$reads" -eq "$writes" ] || error "read" $reads "blocks, must be" $writes
4605 run_test 121 "read cancel race ================================="
4607 test_122() { #bug 11544
4608 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
4609 sysctl -w lustre.fail_loc=0x508
4610 dd if=/dev/zero of=$DIR/$tfile count=1
4612 sysctl -w lustre.fail_loc=0
4614 run_test 122 "fail client bulk callback (shouldn't LBUG) ======="
4616 test_123() # statahead(bug 11401)
4618 if [ -z "$(grep "processor.*: 1" /proc/cpuinfo)" ]; then
4619 log "testing on UP system. Performance may be not as good as expected."
4624 for ((i=1, j=0; i<=100000; j=$i, i=$((i * 10)) )); do
4625 createmany -o $DIR/$tdir/$tfile $j $((i - j))
4627 grep '[0-9]' $LPROC/llite/*/statahead_max
4628 cancel_lru_locks osc
4630 ls -l $DIR/$tdir > /dev/null
4632 delta_sa=$((etime - stime))
4633 log "ls $i files with statahead: $delta_sa sec"
4635 for client in $LPROC/llite/*; do
4636 max=`cat $client/statahead_max`
4637 cat $client/statahead_stats
4638 echo 0 > $client/statahead_max
4641 grep '[0-9]' $LPROC/llite/*/statahead_max
4642 cancel_lru_locks osc
4644 ls -l $DIR/$tdir > /dev/null
4646 delta=$((etime - stime))
4647 log "ls $i files without statahead: $delta sec"
4649 for client in /proc/fs/lustre/llite/*; do
4650 cat $client/statahead_stats
4651 echo $max > $client/statahead_max
4654 if [ $delta_sa -gt $delta ]; then
4655 log "ls $i files is slower with statahead!"
4658 [ $delta -gt 20 ] && break
4659 [ "$SLOW" = "no" -a $delta -gt 3 ] && break
4667 delta=$((etime - stime))
4668 log "rm -r $DIR/$tdir/: $delta seconds"
4670 cat $LPROC/llite/*/statahead_stats
4671 # wait for commitment of removal
4674 run_test 123 "verify statahead work"
4677 [ -z "`grep lru_resize $LPROC/mdc/*/connect_flags`" ] && \
4678 skip "no lru resize on server" && return 0
4679 cancel_lru_locks mdc
4681 NSDIR=`find $LPROC/ldlm/namespaces | grep mdc | head -1`
4683 # we want to test main pool functionality, that is cancel based on SLV
4684 # this is why shrinkers are disabled
4685 disable_pool_shrink "mds-$FSNAME"
4686 disable_pool_shrink mdc
4689 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
4691 LRU_SIZE=`cat $NSDIR/lru_size`
4693 # use touch to produce $NR new locks
4694 log "create $NR files at $DIR/$tdir"
4695 for ((i=0;i<$NR;i++)); do touch $DIR/$tdir/f$i; done
4697 LRU_SIZE_B=`cat $NSDIR/lru_size`
4698 if test $LRU_SIZE -ge $LRU_SIZE_B; then
4699 skip "No cached locks created!"
4700 cat $NSDIR/pool/state
4703 LRU_SIZE_B=$((LRU_SIZE_B-LRU_SIZE))
4704 log "created $LRU_SIZE_B lock(s)"
4706 # we want to sleep 30s to not make test too long
4710 # we know that lru resize allows one client to hold $LIMIT locks for 10h
4713 # get the pool limit
4714 LIMIT=`cat $NSDIR/pool/limit`
4716 # calculate lock volume factor taking into account data set size and the
4717 # rule that number of locks will be getting smaller durring sleep interval
4718 # and we need to additionally enforce LVF to take this into account.
4719 # Use $LRU_SIZE_B here to take into account real number of locks created
4720 # in the case of CMD, LRU_SIZE_B != $NR in most of cases
4721 LVF=$(($MAX_HRS * 60 * 60 * $LIMIT / $SLEEP))
4722 log "make client drop locks $LVF times faster so that ${SLEEP}s is enough to cancel $LRU_SIZE_B lock(s)"
4723 OLD_LVF=`cat $NSDIR/pool/lock_volume_factor`
4724 echo "$LVF" > $NSDIR/pool/lock_volume_factor
4725 log "sleep for $((SLEEP+SLEEP_ADD))s"
4726 sleep $((SLEEP+SLEEP_ADD))
4727 echo "$OLD_LVF" > $NSDIR/pool/lock_volume_factor
4728 LRU_SIZE_A=`cat $NSDIR/lru_size`
4730 [ $LRU_SIZE_B -gt $LRU_SIZE_A ] || {
4731 error "No locks dropped in "$((SLEEP+SLEEP_ADD))"s. LRU size: $LRU_SIZE_A"
4733 unlinkmany $DIR/$tdir/f $NR
4737 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in "$((SLEEP+SLEEP_ADD))"s"
4739 log "unlink $NR files at $DIR/$tdir"
4740 unlinkmany $DIR/$tdir/f $NR
4742 run_test 124a "lru resize ======================================="
4745 [ -z "`grep lru_resize $LPROC/mdc/*/connect_flags`" ] && \
4746 skip "no lru resize on server" && return 0
4748 NSDIR=`find $LPROC/ldlm/namespaces | grep mdc | head -1`
4749 LIMIT=`cat $NSDIR/pool/limit`
4751 #define LDLM_DEFAULT_LRU_SIZE (100 * num_online_cpus())
4752 NR_CPU=$(awk '/processor/' /proc/cpuinfo | wc -l)
4753 test $NR_CPU -gt 1 && SUFFIX="(s)" || SUFFIX=""
4754 # 100 locks here is default value for non-shrinkable lru as well
4755 # as the order to switch to static lru managing policy
4756 LDLM_DEFAULT_LRU_SIZE=$((100 * NR_CPU))
4757 log "$NR_CPU CPU${SUFFIX} detected, LDLM_DEFAULT_LRU_SIZE = $LDLM_DEFAULT_LRU_SIZE"
4759 log "disable lru resize for $(basename $NSDIR)"
4760 echo $LDLM_DEFAULT_LRU_SIZE > $NSDIR/lru_size
4762 NR=$((LIMIT-(LIMIT/3)))
4763 mkdir -p $DIR/$tdir/disable_lru_resize ||
4764 error "failed to create $DIR/$tdir/disable_lru_resize"
4766 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
4767 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
4769 ls -la $DIR/$tdir/disable_lru_resize > /dev/null
4770 ls -la $DIR/$tdir/disable_lru_resize > /dev/null
4771 ls -la $DIR/$tdir/disable_lru_resize > /dev/null
4773 nolruresize_delta=$((etime-stime))
4774 log "ls -la time: $nolruresize_delta seconds"
4775 log "lru_size = $(cat $NSDIR/lru_size)"
4777 mkdir -p $DIR/$tdir/enable_lru_resize ||
4778 error "failed to create $DIR/$tdir/enable_lru_resize"
4780 # 0 locks means here flush lru and switch to lru resize policy
4781 log "enable lru resize for $(basename $NSDIR)"
4782 echo 0 > $NSDIR/lru_size
4784 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
4785 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
4787 ls -la $DIR/$tdir/enable_lru_resize > /dev/null
4788 ls -la $DIR/$tdir/enable_lru_resize > /dev/null
4789 ls -la $DIR/$tdir/enable_lru_resize > /dev/null
4791 lruresize_delta=$((etime-stime))
4792 log "ls -la time: $lruresize_delta seconds"
4793 log "lru_size = $(cat $NSDIR/lru_size)"
4795 if test $lruresize_delta -gt $nolruresize_delta; then
4796 log "ls -la is $((lruresize_delta - $nolruresize_delta))s slower with lru resize enabled"
4797 elif test $nolruresize_delta -gt $lruresize_delta; then
4798 log "ls -la is $((nolruresize_delta - $lruresize_delta))s faster with lru resize enabled"
4800 log "lru resize performs the same with no lru resize"
4803 run_test 124b "lru resize (performance test) ======================="
4805 test_125() { # 13358
4806 [ -z "$(grep acl $LPROC/mdc/*-mdc-*/connect_flags)" ] && skip "must have acl enabled" && return
4807 mkdir -p $DIR/d125 || error "mkdir failed"
4808 $SETSTRIPE $DIR/d125 -s 65536 -c -1 || error "setstripe failed"
4809 setfacl -R -m u:bin:rwx $DIR/d125 || error "setfacl $DIR/d125 failes"
4810 ls -ld $DIR/d125 || error "cannot access $DIR/d125"
4812 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
4814 test_126() { # bug 12829/13455
4815 [ "$UID" != 0 ] && echo "skipping $TESTNAME (must run as root)" && return
4816 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
4817 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
4819 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
4821 run_test 126 "check that the fsgid provided by the client is taken into account"
4827 log "cleanup: ======================================================"
4828 check_and_cleanup_lustre
4829 if [ "$I_MOUNTED" != "yes" ]; then
4830 sysctl -w lnet.debug="$OLDDEBUG" 2> /dev/null || true
4833 echo '=========================== finished ==============================='
4834 [ -f "$SANITYLOG" ] && cat $SANITYLOG && grep -q FAIL $SANITYLOG && exit 1 || true
4835 echo "$0: completed"