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: 13297 2108 9789 3637 9789 3561 12622 15528/2330 5188 10764 16410
11 ALWAYS_EXCEPT=${ALWAYS_EXCEPT:-"27u 42a 42b 42c 42d 45 51d 62 68 75 76 $SANITY_EXCEPT"}
12 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
14 # Tests that fail on uml, maybe elsewhere, FIXME
15 CPU=`awk '/model/ {print $4}' /proc/cpuinfo`
16 # buffer i/o errs sock spc runas
17 [ "$CPU" = "UML" ] && EXCEPT="$EXCEPT 27m 27n 27o 27p 27q 27r 31d 54a 64b 99a 99b 99c 99d 99e 99f 101"
20 2.4*) FSTYPE=${FSTYPE:-ext3}; ALWAYS_EXCEPT="$ALWAYS_EXCEPT 76"
21 [ "$CPU" = "UML" ] && ALWAYS_EXCEPT="$ALWAYS_EXCEPT 105a";;
22 2.6*) FSTYPE=${FSTYPE:-ldiskfs}; ALWAYS_EXCEPT="$ALWAYS_EXCEPT " ;;
23 *) error "unsupported kernel" ;;
26 SRCDIR=$(cd $(dirname $0); echo $PWD)
27 export PATH=$PATH:/sbin
31 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
32 CREATETEST=${CREATETEST:-createtest}
34 SETSTRIPE=${SETSTRIPE:-"$LFS setstripe"}
35 GETSTRIPE=${GETSTRIPE:-"$LFS getstripe"}
36 LFIND=${LFIND:-"$LFS find"}
37 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
39 MCREATE=${MCREATE:-mcreate}
40 OPENFILE=${OPENFILE:-openfile}
41 OPENUNLINK=${OPENUNLINK:-openunlink}
42 READS=${READS:-"reads"}
43 TRUNCATE=${TRUNCATE:-truncate}
44 MUNLINK=${MUNLINK:-munlink}
45 SOCKETSERVER=${SOCKETSERVER:-socketserver}
46 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
47 IOPENTEST1=${IOPENTEST1:-iopentest1}
48 IOPENTEST2=${IOPENTEST2:-iopentest2}
49 MEMHOG=${MEMHOG:-memhog}
50 DIRECTIO=${DIRECTIO:-directio}
51 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
52 UMOUNT=${UMOUNT:-"umount -d"}
53 CHECK_GRANT=${CHECK_GRANT:-"yes"}
54 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
56 export NAME=${NAME:-local}
63 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
64 . $LUSTRE/tests/test-framework.sh
66 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
68 [ "$SLOW" = "no" ] && EXCEPT_SLOW="24o 27m 36f 36g 51b 51c 60c 63 64b 68 71 73 77f 78 101 103 115 120g 124b"
70 SANITYLOG=${TESTSUITELOG:-$TMP/$(basename $0 .sh).log}
71 FAIL_ON_ERROR=${FAIL_ON_ERROR:-false}
75 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
76 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
86 check_kernel_version() {
89 GOT_VER=$(lctl get_param -n $VERSION_FILE | awk '/kernel:/ {print $2}')
91 patchless|patchless_client) return 0;;
92 *) [ $GOT_VER -ge $WANT_VER ] && return 0 ;;
94 log "test needs at least kernel version $WANT_VER, running $GOT_VER"
98 if [ "$ONLY" == "cleanup" ]; then
103 [ "$SANITYLOG" ] && rm -f $SANITYLOG || true
105 check_and_setup_lustre
110 LOVNAME=`lctl get_param -n llite.*.lov.common_name | tail -n 1`
111 OSTCOUNT=`lctl get_param -n lov.$LOVNAME.numobd`
112 STRIPECOUNT=`lctl get_param -n lov.$LOVNAME.stripecount`
113 STRIPESIZE=`lctl get_param -n lov.$LOVNAME.stripesize`
114 ORIGFREE=`lctl get_param -n lov.$LOVNAME.kbytesavail`
115 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
117 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
118 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
119 rm -rf $DIR/[Rdfs][0-9]*
121 # $RUNAS_ID may get set incorrectly somewhere else
122 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
124 check_runas_id $RUNAS_ID $RUNAS_ID $RUNAS
128 echo "preparing for tests involving mounts"
129 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
131 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
132 echo # add a newline after mke2fs.
136 OLDDEBUG="`lctl get_param -n debug 2> /dev/null`"
137 lctl set_param debug=-1 2> /dev/null || true
140 $CHECKSTAT -t file $DIR/$tfile || error
142 $CHECKSTAT -a $DIR/$tfile || error
144 run_test 0 "touch .../$tfile ; rm .../$tfile ====================="
147 chmod 0755 $DIR || error
148 $CHECKSTAT -p 0755 $DIR || error
150 run_test 0b "chmod 0755 $DIR ============================="
153 $LCTL get_param mdc.*.import | grep "state: FULL" || error "import not FULL"
154 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" || error "bad target"
156 run_test 0c "check import proc ============================="
161 $CHECKSTAT -t dir $DIR/d1/d2 || error
163 run_test 1a "mkdir .../d1; mkdir .../d1/d2 ====================="
168 $CHECKSTAT -a $DIR/d1 || error
170 run_test 1b "rmdir .../d1/d2; rmdir .../d1 ====================="
175 $CHECKSTAT -t file $DIR/d2/f || error
177 run_test 2a "mkdir .../d2; touch .../d2/f ======================"
181 $CHECKSTAT -a $DIR/d2 || error
183 run_test 2b "rm -r .../d2; checkstat .../d2/f ======================"
187 $CHECKSTAT -t dir $DIR/d3 || error
189 run_test 3a "mkdir .../d3 ======================================"
192 if [ ! -d $DIR/d3 ]; then
196 $CHECKSTAT -t file $DIR/d3/f || error
198 run_test 3b "touch .../d3/f ===================================="
202 $CHECKSTAT -a $DIR/d3 || error
204 run_test 3c "rm -r .../d3 ======================================"
208 $CHECKSTAT -t dir $DIR/d4 || error
210 run_test 4a "mkdir .../d4 ======================================"
213 if [ ! -d $DIR/d4 ]; then
217 $CHECKSTAT -t dir $DIR/d4/d2 || error
219 run_test 4b "mkdir .../d4/d2 ==================================="
224 chmod 0707 $DIR/d5/d2
225 $CHECKSTAT -t dir -p 0707 $DIR/d5/d2 || error
227 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2 ============"
231 chmod 0666 $DIR/f6a || error
232 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/f6a || error
234 run_test 6a "touch .../f6a; chmod .../f6a ======================"
237 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
238 if [ ! -f $DIR/f6a ]; then
242 $RUNAS chmod 0444 $DIR/f6a && error
243 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/f6a || error
245 run_test 6b "$RUNAS chmod .../f6a (should return error) =="
248 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
250 chown $RUNAS_ID $DIR/f6c || error
251 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/f6c || error
253 run_test 6c "touch .../f6c; chown .../f6c ======================"
256 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
257 if [ ! -f $DIR/f6c ]; then
259 chown $RUNAS_ID $DIR/f6c
261 $RUNAS chown $UID $DIR/f6c && error
262 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/f6c || error
264 run_test 6d "$RUNAS chown .../f6c (should return error) =="
267 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
269 chgrp $RUNAS_ID $DIR/f6e || error
270 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/f6e || error
272 run_test 6e "touch .../f6e; chgrp .../f6e ======================"
275 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
276 if [ ! -f $DIR/f6e ]; then
278 chgrp $RUNAS_ID $DIR/f6e
280 $RUNAS chgrp $UID $DIR/f6e && error
281 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/f6e || error
283 run_test 6f "$RUNAS chgrp .../f6e (should return error) =="
286 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
287 mkdir $DIR/d6g || error
288 chmod 777 $DIR/d6g || error
289 $RUNAS mkdir $DIR/d6g/d || error
290 chmod g+s $DIR/d6g/d || error
291 mkdir $DIR/d6g/d/subdir
292 $CHECKSTAT -g \#$RUNAS_ID $DIR/d6g/d/subdir || error
294 run_test 6g "Is new dir in sgid dir inheriting group?"
296 test_6h() { # bug 7331
297 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
298 touch $DIR/f6h || error "touch failed"
299 chown $RUNAS_ID:$RUNAS_ID $DIR/f6h || error "initial chown failed"
300 $RUNAS -G$RUNAS_ID chown $RUNAS_ID:0 $DIR/f6h && error "chown worked"
301 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_ID $DIR/f6h || error
303 run_test 6h "$RUNAS chown RUNAS_ID.0 .../f6h (should return error)"
309 $CHECKSTAT -t file -p 0666 $DIR/d7/f || error
311 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
314 if [ ! -d $DIR/d7 ]; then
318 echo -n foo > $DIR/d7/f2
319 [ "`cat $DIR/d7/f2`" = "foo" ] || error
320 $CHECKSTAT -t file -s 3 $DIR/d7/f2 || error
322 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
328 $CHECKSTAT -t file -p 0666 $DIR/d8/f || error
330 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
336 $CHECKSTAT -t dir $DIR/d9/d2/d3 || error
338 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
344 $CHECKSTAT -t file $DIR/d10/d2/f || error
346 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
351 chmod 0666 $DIR/d11/d2
352 chmod 0705 $DIR/d11/d2
353 $CHECKSTAT -t dir -p 0705 $DIR/d11/d2 || error
355 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
360 chmod 0666 $DIR/d12/f
361 chmod 0654 $DIR/d12/f
362 $CHECKSTAT -t file -p 0654 $DIR/d12/f || error
364 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
368 dd if=/dev/zero of=$DIR/d13/f count=10
370 $CHECKSTAT -t file -s 0 $DIR/d13/f || error
372 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
378 $CHECKSTAT -a $DIR/d14/f || error
380 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
385 mv $DIR/d15/f $DIR/d15/f2
386 $CHECKSTAT -t file $DIR/d15/f2 || error
388 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
394 $CHECKSTAT -a $DIR/d16/f || error
396 run_test 16 "touch .../d16/f; rm -rf .../d16/f ================="
401 ln -s $DIR/d17/f $DIR/d17/l-exist
403 $CHECKSTAT -l $DIR/d17/f $DIR/d17/l-exist || error
404 $CHECKSTAT -f -t f $DIR/d17/l-exist || error
405 rm -f $DIR/d17/l-exist
406 $CHECKSTAT -a $DIR/d17/l-exist || error
408 run_test 17a "symlinks: create, remove (real) =================="
412 ln -s no-such-file $DIR/d17/l-dangle
414 $CHECKSTAT -l no-such-file $DIR/d17/l-dangle || error
415 $CHECKSTAT -fa $DIR/d17/l-dangle || error
416 rm -f $DIR/d17/l-dangle
417 $CHECKSTAT -a $DIR/d17/l-dangle || error
419 run_test 17b "symlinks: create, remove (dangling) =============="
421 test_17c() { # bug 3440 - don't save failed open RPC for replay
423 ln -s foo $DIR/d17/f17c
424 cat $DIR/d17/f17c && error "opened non-existent symlink" || true
426 run_test 17c "symlinks: open dangling (should return error) ===="
430 ln -s foo $DIR/d17/f17d
431 touch $DIR/d17/f17d || error "creating to new symlink"
433 run_test 17d "symlinks: create dangling ========================"
437 local foo=$DIR/$tdir/$tfile
438 ln -s $foo $foo || error "create symlink failed"
439 ls -l $foo || error "ls -l failed"
440 ls $foo && error "ls not failed" || true
442 run_test 17e "symlinks: create recursive symlink (should return error) ===="
446 LONGSYMLINK="$(dd if=/dev/zero bs=4095 count=1 | tr '\0' 'x')"
447 ln -s $LONGSYMLINK $DIR/$tdir/$tfile
450 run_test 17g "symlinks: really long symlink name ==============================="
452 test_17h() { #bug 17378
454 $SETSTRIPE $DIR/$tdir -c -1
455 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
456 do_facet mds lctl set_param fail_loc=0x80000141
457 touch $DIR/$tdir/$tfile || true
459 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
461 test_17i() { #bug 20018
463 local foo=$DIR/$tdir/$tfile
464 ln -s $foo $foo || error "create symlink failed"
465 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
466 do_facet mds lctl set_param fail_loc=0x80000143
467 ls -l $foo && error "error not detected"
470 run_test 17i "don't panic on short symlink"
476 run_test 18 "touch .../f ; ls ... =============================="
482 $CHECKSTAT -a $DIR/f19 || error
484 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
487 ls -l $DIR/f19 && error || true
489 run_test 19b "ls -l .../f19 (should return error) =============="
492 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
493 $RUNAS touch $DIR/f19 && error || true
495 run_test 19c "$RUNAS touch .../f19 (should return error) =="
498 cat $DIR/f19 && error || true
500 run_test 19d "cat .../f19 (should return error) =============="
512 $CHECKSTAT -a $DIR/f || error
514 run_test 20 "touch .../f ; ls -l ... ==========================="
518 [ -f $DIR/d21/dangle ] && rm -f $DIR/d21/dangle
519 ln -s dangle $DIR/d21/link
520 echo foo >> $DIR/d21/link
522 $CHECKSTAT -t link $DIR/d21/link || error
523 $CHECKSTAT -f -t file $DIR/d21/link || error
525 run_test 21 "write to dangling link ============================"
530 chown $RUNAS_ID $WDIR
531 (cd $WDIR || error "cd $WDIR failed";
532 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
534 ls -lR $WDIR/etc || error "ls -lR $WDIR/etc failed"
535 $CHECKSTAT -t dir $WDIR/etc || error "checkstat -t dir failed"
536 $CHECKSTAT -u \#$RUNAS_ID $WDIR/etc || error "checkstat -u failed"
538 run_test 22 "unpack tar archive as non-root user ==============="
543 local file=$DIR/$tdir/$tfile
545 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
546 openfile -f O_CREAT:O_EXCL $file &&
547 error "$file recreate succeeded" || true
549 run_test 23a "O_CREAT|O_EXCL in subdir =========================="
551 test_23b() { # bug 18988
553 local file=$DIR/$tdir/$tfile
556 echo foo > $file || error "write filed"
557 echo bar >> $file || error "append filed"
558 $CHECKSTAT -s 8 $file || error "wrong size"
561 run_test 23b "O_APPEND check =========================="
564 echo '== rename sanity =============================================='
565 echo '-- same directory rename'
568 mv $DIR/R1/f $DIR/R1/g
569 $CHECKSTAT -t file $DIR/R1/g || error
571 run_test 24a "touch .../R1/f; rename .../R1/f .../R1/g ========="
576 mv $DIR/R2/f $DIR/R2/g
577 $CHECKSTAT -a $DIR/R2/f || error
578 $CHECKSTAT -t file $DIR/R2/g || error
580 run_test 24b "touch .../R2/{f,g}; rename .../R2/f .../R2/g ====="
585 mv $DIR/R3/f $DIR/R3/g
586 $CHECKSTAT -a $DIR/R3/f || error
587 $CHECKSTAT -t dir $DIR/R3/g || error
589 run_test 24c "mkdir .../R3/f; rename .../R3/f .../R3/g ========="
594 mrename $DIR/R4/f $DIR/R4/g
595 $CHECKSTAT -a $DIR/R4/f || error
596 $CHECKSTAT -t dir $DIR/R4/g || error
598 run_test 24d "mkdir .../R4/{f,g}; rename .../R4/f .../R4/g ====="
601 echo '-- cross directory renames --'
604 mv $DIR/R5a/f $DIR/R5b/g
605 $CHECKSTAT -a $DIR/R5a/f || error
606 $CHECKSTAT -t file $DIR/R5b/g || error
608 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
612 touch $DIR/R6a/f $DIR/R6b/g
613 mv $DIR/R6a/f $DIR/R6b/g
614 $CHECKSTAT -a $DIR/R6a/f || error
615 $CHECKSTAT -t file $DIR/R6b/g || error
617 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
622 mv $DIR/R7a/d $DIR/R7b/e
623 $CHECKSTAT -a $DIR/R7a/d || error
624 $CHECKSTAT -t dir $DIR/R7b/e || error
626 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R5b/e ======"
630 mkdir $DIR/R8a/d $DIR/R8b/e
631 mrename $DIR/R8a/d $DIR/R8b/e
632 $CHECKSTAT -a $DIR/R8a/d || error
633 $CHECKSTAT -t dir $DIR/R8b/e || error
635 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
638 echo "-- rename error cases"
642 mrename $DIR/R9/f $DIR/R9/a
643 $CHECKSTAT -t file $DIR/R9/f || error
644 $CHECKSTAT -t dir $DIR/R9/a || error
645 $CHECKSTAT -a $DIR/R9/a/f || error
647 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
651 mrename $DIR/R10/f $DIR/R10/g
652 $CHECKSTAT -t dir $DIR/R10 || error
653 $CHECKSTAT -a $DIR/R10/f || error
654 $CHECKSTAT -a $DIR/R10/g || error
656 run_test 24j "source does not exist ============================"
659 mkdir $DIR/R11a $DIR/R11a/d
661 mv $DIR/R11a/f $DIR/R11a/d
662 $CHECKSTAT -a $DIR/R11a/f || error
663 $CHECKSTAT -t file $DIR/R11a/d/f || error
665 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
667 # bug 2429 - rename foo foo foo creates invalid file
670 multiop $f OcNs || error
672 run_test 24l "Renaming a file to itself ========================"
676 multiop $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
677 # on ext3 this does not remove either the source or target files
678 # though the "expected" operation would be to remove the source
679 $CHECKSTAT -t file ${f} || error "${f} missing"
680 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
682 run_test 24m "Renaming a file to a hard link to itself ========="
686 # this stats the old file after it was renamed, so it should fail
690 $CHECKSTAT ${f}.rename
693 run_test 24n "Statting the old file after renaming (Posix rename 2)"
696 check_kernel_version 37 || return 0
698 rename_many -s random -v -n 10 $DIR/d24o
700 run_test 24o "rename of files during htree split ==============="
704 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
705 mrename $DIR/R12a $DIR/R12b
706 $CHECKSTAT -a $DIR/R12a || error
707 $CHECKSTAT -t dir $DIR/R12b || error
708 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
709 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
711 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
715 DIRINO=`ls -lid $DIR/R13a | awk '{ print $1 }'`
716 multiop_bg_pause $DIR/R13b D_c || return 1
719 mrename $DIR/R13a $DIR/R13b
720 $CHECKSTAT -a $DIR/R13a || error
721 $CHECKSTAT -t dir $DIR/R13b || error
722 DIRINO2=`ls -lid $DIR/R13b | awk '{ print $1 }'`
723 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
725 wait $MULTIPID || error "multiop close failed"
727 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
729 test_24r() { #bug 3789
730 mkdir $DIR/R14a $DIR/R14a/b
731 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
732 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
733 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
735 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
738 mkdir $DIR/R15a $DIR/R15a/b $DIR/R15a/b/c
739 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
740 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
741 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
743 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
745 mkdir $DIR/R16a $DIR/R16a/b $DIR/R16a/b/c
746 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
747 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
748 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
750 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
752 test_24u() { # bug12192
753 multiop $DIR/$tfile C2w$((2048 * 1024))c || error
754 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
756 run_test 24u "create stripe file"
759 echo '== symlink sanity ============================================='
763 touch $DIR/s25/foo || error
765 run_test 25a "create file in symlinked directory ==============="
768 [ ! -d $DIR/d25 ] && test_25a
769 $CHECKSTAT -t file $DIR/s25/foo || error
771 run_test 25b "lookup file in symlinked directory ==============="
776 ln -s d26/d26-2 $DIR/s26
777 touch $DIR/s26/foo || error
779 run_test 26a "multiple component symlink ======================="
782 mkdir -p $DIR/d26b/d26-2
783 ln -s d26b/d26-2/foo $DIR/s26-2
784 touch $DIR/s26-2 || error
786 run_test 26b "multiple component symlink at end of lookup ======"
791 ln -s d26.2 $DIR/s26.2-1
792 ln -s s26.2-1 $DIR/s26.2-2
793 ln -s s26.2-2 $DIR/s26.2-3
794 chmod 0666 $DIR/s26.2-3/foo
796 run_test 26c "chain of symlinks ================================"
798 # recursive symlinks (bug 439)
800 ln -s d26-3/foo $DIR/d26-3
802 run_test 26d "create multiple component recursive symlink ======"
805 [ ! -h $DIR/d26-3 ] && test_26d
808 run_test 26e "unlink multiple component recursive symlink ======"
810 # recursive symlinks (bug 7022)
813 mkdir $DIR/$tdir/$tfile || error "mkdir $DIR/$tdir/$tfile failed"
814 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
815 mkdir -p lndir/bar1 || error "mkdir lndir/bar1 failed"
816 mkdir $tfile || error "mkdir $tfile failed"
817 cd $tfile || error "cd $tfile failed"
818 ln -s .. dotdot || error "ln dotdot failed"
819 ln -s dotdot/lndir lndir || error "ln lndir failed"
820 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
821 output=`ls $tfile/$tfile/lndir/bar1`
822 [ "$output" = bar1 ] && error "unexpected output"
823 rm -r $tfile || error "rm $tfile failed"
824 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
826 run_test 26f "rm -r of a directory which has recursive symlink ="
829 echo '== stripe sanity =============================================='
830 mkdir -p $DIR/d27 || error "mkdir failed"
832 $SETSTRIPE $DIR/d27/f0 -c 1 || error "lstripe failed"
833 $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
835 log "== test 27b: write to one stripe file ========================="
836 cp /etc/hosts $DIR/d27/f0 || error
838 run_test 27a "one stripe file =================================="
841 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
843 $SETSTRIPE $DIR/d27/f01 -c 2 || error "lstripe failed"
844 [ `$GETSTRIPE $DIR/d27/f01 | grep -A 10 obdidx | wc -l` -eq 4 ] ||
845 error "two-stripe file doesn't have two stripes"
847 log "== test 27d: write to two stripe file file f01 ================"
848 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
850 run_test 27c "create two stripe file f01 ======================="
854 $SETSTRIPE -c0 -i-1 -s0 $DIR/d27/fdef || error "lstripe failed"
855 $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
856 dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
858 run_test 27d "create file with default settings ================"
862 $SETSTRIPE $DIR/d27/f12 -c 2 || error "lstripe failed"
863 $SETSTRIPE $DIR/d27/f12 -c 2 && error "lstripe succeeded twice"
864 $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
866 run_test 27e "setstripe existing file (should return error) ======"
870 $SETSTRIPE $DIR/d27/fbad -s 100 -i 0 -c 1 && error "lstripe failed"
871 dd if=/dev/zero of=$DIR/d27/f12 bs=4k count=4 || error "dd failed"
872 $GETSTRIPE $DIR/d27/fbad || error "lfs getstripe failed"
874 run_test 27f "setstripe with bad stripe size (should return error)"
878 $MCREATE $DIR/d27/fnone || error "mcreate failed"
880 log "== test 27h: lfs getstripe with no objects ===================="
881 $GETSTRIPE $DIR/d27/fnone 2>&1 | grep "no stripe info" || error "has object"
883 log "== test 27i: lfs getstripe with some objects =================="
884 touch $DIR/d27/fsome || error "touch failed"
885 $GETSTRIPE $DIR/d27/fsome | grep obdidx || error "missing objects"
887 run_test 27g "test lfs getstripe ==========================================="
891 $SETSTRIPE $DIR/d27/f27j -i $OSTCOUNT && error "lstripe failed"||true
893 run_test 27j "setstripe with bad stripe offset (should return error)"
895 test_27k() { # bug 2844
898 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
899 [ ! -d $DIR/d27 ] && mkdir -p $DIR/d27
900 $SETSTRIPE $FILE -s 67108864 || error "lstripe failed"
901 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
902 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
903 dd if=/dev/zero of=$FILE bs=4k count=1
904 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
905 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
907 run_test 27k "limit i_blksize for broken user apps ============="
911 mcreate $DIR/f27l || error "creating file"
912 $RUNAS $SETSTRIPE $DIR/f27l -c 1 && \
913 error "lstripe should have failed" || true
915 run_test 27l "check setstripe permissions (should return error)"
918 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
919 if [ $ORIGFREE -gt $MAXFREE ]; then
920 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
924 $SETSTRIPE $DIR/d27/f27m_1 -i 0 -c 1
925 dd if=/dev/zero of=$DIR/d27/f27m_1 bs=1024 count=$MAXFREE && \
926 error "dd should fill OST0"
928 while $SETSTRIPE $DIR/d27/f27m_$i -i 0 -c 1 ; do
930 [ $i -gt 256 ] && break
933 touch $DIR/d27/f27m_$i
934 [ `$GETSTRIPE $DIR/d27/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] && \
935 error "OST0 was full but new created file still use it"
937 touch $DIR/d27/f27m_$i
938 [ `$GETSTRIPE $DIR/d27/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] && \
939 error "OST0 was full but new created file still use it"
942 run_test 27m "create file while OST0 was full =================="
945 local DELAY=$(do_facet mds lctl get_param -n lov.*.qos_maxage | awk '{print $1 + 2}')
949 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
950 # if the OST isn't full anymore.
952 local FAIL_LOC=${1:-0}
953 local OSTIDX=${2:-""}
955 local list=$(comma_list $(osts_nodes))
956 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
958 do_nodes $list lctl set_param fail_loc=$FAIL_LOC
962 exhaust_precreations() {
965 local OST=$(lfs osts | grep ${OSTIDX}": " | \
966 awk '{print $2}' | sed -e 's/_UUID$//')
969 local mdtosc=$(get_mdtosc_proc_path $OST)
970 local last_id=$(do_facet mds lctl get_param -n osc.$mdtosc.prealloc_last_id)
971 local next_id=$(do_facet mds lctl get_param -n osc.$mdtosc.prealloc_next_id)
973 mkdir -p $DIR/d27/${OST}
974 $SETSTRIPE $DIR/d27/${OST} -i $OSTIDX -c 1
975 #define OBD_FAIL_OST_ENOSPC 0x215
976 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x215
977 echo "Creating to objid $last_id on ost $OST..."
978 createmany -o $DIR/d27/${OST}/f $next_id $((last_id - next_id + 2))
979 do_facet mds "lctl get_param -n osc.$mdtosc.prealloc*" | grep '[0-9]'
980 reset_enospc $2 $OSTIDX
983 exhaust_all_precreations() {
985 for (( i=0; i < OSTCOUNT; i++ )) ; do
986 exhaust_precreations $i 0x215
992 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
993 remote_mds_nodsh && skip "remote MDS with nodsh" && return
994 remote_ost_nodsh && skip "remote OST with nodsh" && return
998 exhaust_precreations 0 0x80000215
999 $SETSTRIPE -c -1 $DIR/d27
1000 touch $DIR/d27/f27n || error
1001 $GETSTRIPE $DIR/d27/f27n
1004 run_test 27n "create file with some full OSTs =================="
1007 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1008 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1009 remote_ost_nodsh && skip "remote OST with nodsh" && return
1013 exhaust_all_precreations 0x215
1015 touch $DIR/d27/f27o && error "able to create $DIR/d27/f27o"
1019 run_test 27o "create file with all full OSTs (should error) ===="
1022 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1023 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1024 remote_ost_nodsh && skip "remote OST with nodsh" && return
1030 $MCREATE $DIR/d27/f27p || error
1031 $TRUNCATE $DIR/d27/f27p 80000000 || error
1032 $CHECKSTAT -s 80000000 $DIR/d27/f27p || error
1034 exhaust_precreations 0 0x80000215
1035 echo foo >> $DIR/d27/f27p || error
1036 $CHECKSTAT -s 80000004 $DIR/d27/f27p || error
1040 run_test 27p "append to a truncated file with some full OSTs ==="
1043 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1044 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1045 remote_ost_nodsh && skip "remote OST with nodsh" && return
1050 $MCREATE $DIR/d27/f27q || error "mcreate $DIR/d27/f27q failed"
1051 $TRUNCATE $DIR/d27/f27q 80000000 ||error "truncate $DIR/d27/f27q failed"
1052 $CHECKSTAT -s 80000000 $DIR/d27/f27q || error "checkstat failed"
1054 exhaust_all_precreations 0x215
1056 echo foo >> $DIR/d27/f27q && error "append succeeded"
1057 $CHECKSTAT -s 80000000 $DIR/d27/f27q || error "checkstat 2 failed"
1061 run_test 27q "append to truncated file with all OSTs full (should error) ==="
1064 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1065 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1066 remote_ost_nodsh && skip "remote OST with nodsh" && return
1070 exhaust_precreations 0 0x80000215
1072 $SETSTRIPE $DIR/d27/f27r -i 0 -c 2 # && error
1076 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1078 test_27s() { # bug 10725
1080 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1081 local stripe_count=0
1082 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1083 $SETSTRIPE $DIR/$tdir -s $stripe_size -c $stripe_count && \
1084 error "stripe width >= 2^32 succeeded" || true
1086 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1088 test_27t() { # bug 10864
1093 $WLFS getstripe $tfile
1096 run_test 27t "check that utils parse path correctly"
1098 test_27u() { # bug 4900
1099 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1100 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1102 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1104 do_facet mds lctl set_param fail_loc=0x139
1106 createmany -o $DIR/d27u/t- 1000
1107 do_facet mds lctl set_param fail_loc=0
1109 TLOG=$DIR/$tfile.getstripe
1110 $GETSTRIPE $DIR/d27u > $TLOG
1111 OBJS=`awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj;}' $TLOG`
1112 unlinkmany $DIR/d27u/t- 1000
1113 [ $OBJS -gt 0 ] && \
1114 error "$OBJS objects created on OST-0. See $TLOG" || pass
1116 run_test 27u "skip object creation on OSC w/o objects =========="
1118 test_27v() { # bug 4900
1119 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1120 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1121 remote_ost_nodsh && skip "remote OST with nodsh" && return
1123 exhaust_all_precreations
1126 $SETSTRIPE $DIR/$tdir -c 1 # 1 stripe / file
1128 touch $DIR/$tdir/$tfile
1129 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1131 for (( i=0; i < OSTCOUNT; i++ )) ; do
1132 do_facet ost$i lctl set_param fail_loc=0x705
1134 local START=`date +%s`
1135 createmany -o $DIR/$tdir/$tfile 32
1137 local FINISH=`date +%s`
1138 local TIMEOUT=`lctl get_param -n timeout`
1139 [ $((FINISH - START)) -ge $((TIMEOUT / 2)) ] && \
1140 error "$FINISH - $START >= $TIMEOUT / 2"
1144 run_test 27v "skip object creation on slow OST ================="
1146 test_27w() { # bug 10997
1147 mkdir -p $DIR/d27w || error "mkdir failed"
1148 $SETSTRIPE $DIR/d27w/f0 -s 65536 || error "lstripe failed"
1149 size=`$GETSTRIPE $DIR/d27w/f0 -qs`
1150 [ $size -ne 65536 ] && error "stripe size $size != 65536" || true
1152 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping multiple stripe count/offset test" && return
1153 for i in `seq 1 $OSTCOUNT`; do
1155 log setstripe $DIR/d27w/f$i -c $i -i $offset
1156 $SETSTRIPE $DIR/d27w/f$i -c $i -i $offset || error "lstripe -c $i -i $offset failed"
1157 count=`$GETSTRIPE -qc $DIR/d27w/f$i`
1158 index=`$GETSTRIPE -qo $DIR/d27w/f$i`
1159 [ $count -ne $i ] && error "stripe count $count != $i" || true
1160 [ $index -ne $offset ] && error "stripe offset $index != $offset" || true
1163 run_test 27w "check lfs setstripe -c -s -i options ============="
1166 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs" && return
1167 OFFSET=$(($OSTCOUNTi - 1))
1169 local OST=$(lfs osts | awk '/'${OSTIDX}': / { print $2 }' | sed -e 's/_UUID$//')
1172 $SETSTRIPE $DIR/$tdir -c 1 # 1 stripe per file
1173 do_facet ost$OSTIDX lctl set_param -n obdfilter.$OST.degraded 1
1175 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1176 for i in `seq 0 $OFFSET`; do
1177 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}' | grep -w "$OSTIDX"` ] &&
1178 error "OST0 was degraded but new created file still use it"
1180 do_facet ost$OSTIDX lctl set_param -n obdfilter.$OST.degraded 0
1182 run_test 27x "create files while OST0 is degraded"
1185 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1186 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1188 MDS_OSCS=`do_facet mds lctl dl | awk '/[oO][sS][cC].*md[ts]/ { print $4 }'`
1189 OFFSET=$(($OSTCOUNT-1))
1191 for OSC in $MDS_OSCS; do
1192 if [ $OST == -1 ]; then {
1193 OST=`osc_to_ost $OSC`
1195 echo $OSC "is Deactivate:"
1196 do_facet mds lctl --device %$OSC deactivate
1200 OSTIDX=$(lfs osts | grep ${OST} | awk '{print $1}' | sed -e 's/://')
1202 $SETSTRIPE $DIR/$tdir -c 1 # 1 stripe / file
1204 do_facet ost$OSTIDX lctl set_param -n obdfilter.$OST.degraded 1
1206 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1207 do_facet ost$OSTIDX lctl set_param -n obdfilter.$OST.degraded 0
1209 for i in `seq 0 $OFFSET`; do
1210 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "$OSTIDX"` ] || \
1211 error "files created on deactivated OSTs instead of degraded OST"
1213 for OSC in $MDS_OSCS; do
1214 [ `osc_to_ost $OSC` != $OST ] && {
1215 echo $OSC "is activate"
1216 do_facet mds lctl --device %$OSC activate
1220 run_test 27y "create files while OST0 is degraded and the rest inactive"
1222 # createtest also checks that device nodes are created and
1223 # then visible correctly (#2091)
1224 test_28() { # bug 2091
1226 $CREATETEST $DIR/d28/ct || error
1228 run_test 28 "create/mknod/mkdir with bad file types ============"
1231 cancel_lru_locks mdc
1236 LOCKCOUNTORIG=`lctl get_param -n ldlm.namespaces.*mdc*.lock_count`
1237 LOCKUNUSEDCOUNTORIG=`lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count`
1238 [ -z $"LOCKCOUNTORIG" ] && error "No mdc lock count" && return 1
1242 LOCKCOUNTCURRENT=`lctl get_param -n ldlm.namespaces.*mdc*.lock_count`
1243 LOCKUNUSEDCOUNTCURRENT=`lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count`
1244 if [ "$LOCKCOUNTCURRENT" -gt "$LOCKCOUNTORIG" ]; then
1245 lctl set_param -n ldlm.dump_namespaces ""
1246 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
1247 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1248 log "dumped log to $TMP/test_29.dk (bug 5793)"
1251 if [ "$LOCKUNUSEDCOUNTCURRENT" -gt "$LOCKUNUSEDCOUNTORIG" ]; then
1252 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
1253 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1254 log "dumped log to $TMP/test_29.dk (bug 5793)"
1258 run_test 29 "IT_GETATTR regression ============================"
1265 run_test 30 "run binary from Lustre (execve) ==================="
1268 $OPENUNLINK $DIR/f31 $DIR/f31 || error
1269 $CHECKSTAT -a $DIR/f31 || error
1271 run_test 31a "open-unlink file =================================="
1274 touch $DIR/f31 || error
1275 ln $DIR/f31 $DIR/f31b || error
1276 multiop $DIR/f31b Ouc || error
1277 $CHECKSTAT -t file $DIR/f31 || error
1279 run_test 31b "unlink file with multiple links while open ======="
1282 touch $DIR/f31 || error
1283 ln $DIR/f31 $DIR/f31c || error
1284 multiop_bg_pause $DIR/f31 O_uc || return 1
1286 multiop $DIR/f31c Ouc
1287 kill -USR1 $MULTIPID
1290 run_test 31c "open-unlink file with multiple links ============="
1293 opendirunlink $DIR/d31d $DIR/d31d || error
1294 $CHECKSTAT -a $DIR/d31d || error
1296 run_test 31d "remove of open directory ========================="
1298 test_31e() { # bug 2904
1299 check_kernel_version 34 || return 0
1300 openfilleddirunlink $DIR/d31e || error
1302 run_test 31e "remove of open non-empty directory ==============="
1304 test_31f() { # bug 4554
1307 $SETSTRIPE $DIR/d31f -s 1048576 -c 1
1308 cp /etc/hosts $DIR/d31f
1310 $GETSTRIPE $DIR/d31f/hosts
1311 multiop_bg_pause $DIR/d31f D_c || return 1
1314 rm -rv $DIR/d31f || error "first of $DIR/d31f"
1316 $SETSTRIPE $DIR/d31f -s 1048576 -c 1
1317 cp /etc/hosts $DIR/d31f
1320 multiop_bg_pause $DIR/d31f D_c || return 1
1323 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
1324 wait $MULTIPID || error "first opendir $MULTIPID failed"
1328 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
1329 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
1332 run_test 31f "remove of open directory with open-unlink file ==="
1335 echo "== more mountpoints and symlinks ================="
1336 [ -e $DIR/d32a ] && rm -fr $DIR/d32a
1337 mkdir -p $DIR/d32a/ext2-mountpoint
1338 mount -t ext2 -o loop $EXT2_DEV $DIR/d32a/ext2-mountpoint || error
1339 $CHECKSTAT -t dir $DIR/d32a/ext2-mountpoint/.. || error
1340 $UMOUNT $DIR/d32a/ext2-mountpoint || error
1342 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
1345 [ -e $DIR/d32b ] && rm -fr $DIR/d32b
1346 mkdir -p $DIR/d32b/ext2-mountpoint
1347 mount -t ext2 -o loop $EXT2_DEV $DIR/d32b/ext2-mountpoint || error
1348 ls -al $DIR/d32b/ext2-mountpoint/.. || error
1349 $UMOUNT $DIR/d32b/ext2-mountpoint || error
1351 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
1354 [ -e $DIR/d32c ] && rm -fr $DIR/d32c
1355 mkdir -p $DIR/d32c/ext2-mountpoint
1356 mount -t ext2 -o loop $EXT2_DEV $DIR/d32c/ext2-mountpoint || error
1357 mkdir -p $DIR/d32c/d2/test_dir
1358 $CHECKSTAT -t dir $DIR/d32c/ext2-mountpoint/../d2/test_dir || error
1359 $UMOUNT $DIR/d32c/ext2-mountpoint || error
1361 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
1364 [ -e $DIR/d32d ] && rm -fr $DIR/d32d
1365 mkdir -p $DIR/d32d/ext2-mountpoint
1366 mount -t ext2 -o loop $EXT2_DEV $DIR/d32d/ext2-mountpoint || error
1367 mkdir -p $DIR/d32d/d2/test_dir
1368 ls -al $DIR/d32d/ext2-mountpoint/../d2/test_dir || error
1369 $UMOUNT $DIR/d32d/ext2-mountpoint || error
1371 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
1374 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
1375 mkdir -p $DIR/d32e/tmp
1376 TMP_DIR=$DIR/d32e/tmp
1377 ln -s $DIR/d32e $TMP_DIR/symlink11
1378 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1379 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
1380 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
1382 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
1385 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
1386 mkdir -p $DIR/d32f/tmp
1387 TMP_DIR=$DIR/d32f/tmp
1388 ln -s $DIR/d32f $TMP_DIR/symlink11
1389 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1390 ls $DIR/d32f/tmp/symlink11 || error
1391 ls $DIR/d32f/symlink01 || error
1393 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
1396 TMP_DIR=$DIR/$tdir/tmp
1397 mkdir -p $TMP_DIR $DIR/${tdir}2
1398 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
1399 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1400 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
1401 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
1402 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
1403 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
1405 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
1408 rm -fr $DIR/$tdir $DIR/${tdir}2
1409 TMP_DIR=$DIR/$tdir/tmp
1410 mkdir -p $TMP_DIR $DIR/${tdir}2
1411 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
1412 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1413 ls $TMP_DIR/symlink12 || error
1414 ls $DIR/$tdir/symlink02 || error
1416 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
1419 [ -e $DIR/d32i ] && rm -fr $DIR/d32i
1420 mkdir -p $DIR/d32i/ext2-mountpoint
1421 mount -t ext2 -o loop $EXT2_DEV $DIR/d32i/ext2-mountpoint || error
1422 touch $DIR/d32i/test_file
1423 $CHECKSTAT -t file $DIR/d32i/ext2-mountpoint/../test_file || error
1424 $UMOUNT $DIR/d32i/ext2-mountpoint || error
1426 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
1429 [ -e $DIR/d32j ] && rm -fr $DIR/d32j
1430 mkdir -p $DIR/d32j/ext2-mountpoint
1431 mount -t ext2 -o loop $EXT2_DEV $DIR/d32j/ext2-mountpoint || error
1432 touch $DIR/d32j/test_file
1433 cat $DIR/d32j/ext2-mountpoint/../test_file || error
1434 $UMOUNT $DIR/d32j/ext2-mountpoint || error
1436 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
1440 mkdir -p $DIR/d32k/ext2-mountpoint
1441 mount -t ext2 -o loop $EXT2_DEV $DIR/d32k/ext2-mountpoint
1442 mkdir -p $DIR/d32k/d2
1443 touch $DIR/d32k/d2/test_file || error
1444 $CHECKSTAT -t file $DIR/d32k/ext2-mountpoint/../d2/test_file || error
1445 $UMOUNT $DIR/d32k/ext2-mountpoint || error
1447 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
1451 mkdir -p $DIR/d32l/ext2-mountpoint
1452 mount -t ext2 -o loop $EXT2_DEV $DIR/d32l/ext2-mountpoint || error
1453 mkdir -p $DIR/d32l/d2
1454 touch $DIR/d32l/d2/test_file
1455 cat $DIR/d32l/ext2-mountpoint/../d2/test_file || error
1456 $UMOUNT $DIR/d32l/ext2-mountpoint || error
1458 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
1462 mkdir -p $DIR/d32m/tmp
1463 TMP_DIR=$DIR/d32m/tmp
1464 ln -s $DIR $TMP_DIR/symlink11
1465 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1466 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
1467 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
1469 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
1473 mkdir -p $DIR/d32n/tmp
1474 TMP_DIR=$DIR/d32n/tmp
1475 ln -s $DIR $TMP_DIR/symlink11
1476 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1477 ls -l $DIR/d32n/tmp/symlink11 || error
1478 ls -l $DIR/d32n/symlink01 || error
1480 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
1483 rm -fr $DIR/d32o $DIR/$tfile
1485 mkdir -p $DIR/d32o/tmp
1486 TMP_DIR=$DIR/d32o/tmp
1487 ln -s $DIR/$tfile $TMP_DIR/symlink12
1488 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1489 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
1490 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
1491 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
1492 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
1494 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
1504 mkdir -p $DIR/d32p/tmp
1506 TMP_DIR=$DIR/d32p/tmp
1508 ln -s $DIR/$tfile $TMP_DIR/symlink12
1510 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1512 cat $DIR/d32p/tmp/symlink12 || error
1514 cat $DIR/d32p/symlink02 || error
1517 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
1520 [ -e $DIR/d32q ] && rm -fr $DIR/d32q
1522 touch $DIR/d32q/under_the_mount
1523 mount -t ext2 -o loop $EXT2_DEV $DIR/d32q
1524 ls $DIR/d32q/under_the_mount && error || true
1525 $UMOUNT $DIR/d32q || error
1527 run_test 32q "stat follows mountpoints in Lustre (should return error)"
1530 [ -e $DIR/d32r ] && rm -fr $DIR/d32r
1532 touch $DIR/d32r/under_the_mount
1533 mount -t ext2 -o loop $EXT2_DEV $DIR/d32r
1534 ls $DIR/d32r | grep -q under_the_mount && error || true
1535 $UMOUNT $DIR/d32r || error
1537 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
1542 chmod 444 $DIR/$tfile
1543 chown $RUNAS_ID $DIR/$tfile
1545 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
1548 run_test 33 "write file with mode 444 (should return error) ===="
1553 chown $RUNAS_ID $DIR/d33
1554 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
1555 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
1556 error "open RDWR" || true
1558 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
1563 chown $RUNAS_ID $DIR/d33
1564 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33 || true
1566 run_test 33b "test open file with malformed flags (No panic)"
1568 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
1571 $MCREATE $DIR/f34 || error
1572 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
1573 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
1574 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
1575 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1577 run_test 34a "truncate file that has not been opened ==========="
1580 [ ! -f $DIR/f34 ] && test_34a
1581 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1582 $OPENFILE -f O_RDONLY $DIR/f34
1583 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
1584 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1586 run_test 34b "O_RDONLY opening file doesn't create objects ====="
1589 [ ! -f $DIR/f34 ] && test_34a
1590 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1591 $OPENFILE -f O_RDWR $DIR/f34
1592 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
1593 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1595 run_test 34c "O_RDWR opening file-with-size works =============="
1598 [ ! -f $DIR/f34 ] && test_34a
1599 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
1600 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1603 run_test 34d "write to sparse file ============================="
1607 $MCREATE $DIR/f34e || error
1608 $TRUNCATE $DIR/f34e 1000 || error
1609 $CHECKSTAT -s 1000 $DIR/f34e || error
1610 $OPENFILE -f O_RDWR $DIR/f34e
1611 $CHECKSTAT -s 1000 $DIR/f34e || error
1613 run_test 34e "create objects, some with size and some without =="
1615 test_34f() { # bug 6242, 6243
1618 $MCREATE $DIR/f34f || error
1619 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
1620 dd if=$DIR/f34f of=$TMP/f34f
1621 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
1622 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
1623 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
1624 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
1625 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
1627 run_test 34f "read from a file with no objects until EOF ======="
1630 cp /bin/sh $DIR/f35a
1632 chown $RUNAS_ID $DIR/f35a
1633 $RUNAS $DIR/f35a && error || true
1636 run_test 35a "exec file with mode 444 (should return and not leak) ====="
1640 utime $DIR/f36 || error
1642 run_test 36a "MDS utime check (mknod, utime) ==================="
1646 utime $DIR/f36 || error
1648 run_test 36b "OST utime check (open, utime) ===================="
1653 chown $RUNAS_ID $DIR/d36
1654 $RUNAS utime $DIR/d36/f36 || error
1656 run_test 36c "non-root MDS utime check (mknod, utime) =========="
1659 [ ! -d $DIR/d36 ] && test_36c
1660 echo "" > $DIR/d36/f36
1661 $RUNAS utime $DIR/d36/f36 || error
1663 run_test 36d "non-root OST utime check (open, utime) ==========="
1666 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
1668 touch $DIR/$tdir/$tfile
1669 $RUNAS utime $DIR/$tdir/$tfile && \
1670 error "utime worked, expected failure" || true
1672 run_test 36e "utime on non-owned file (should return error) ===="
1675 export LANG=C LC_LANG=C # for date language
1677 DATESTR="Dec 20 2000"
1679 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
1680 lctl set_param fail_loc=0x80000214
1682 cp /etc/hosts $DIR/$tdir/$tfile
1683 sync & # write RPC generated with "current" inode timestamp, but delayed
1685 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
1686 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
1687 cancel_lru_locks osc
1688 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
1690 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
1691 echo "BEFORE: $LS_BEFORE" && \
1692 echo "AFTER : $LS_AFTER" && \
1693 echo "WANT : $DATESTR" && \
1694 error "$DIR/$tdir/$tfile timestamps changed" || true
1696 run_test 36f "utime on file racing with OST BRW write =========="
1699 remote_ost_nodsh && skip "remote OST with nodsh" && return
1702 export FMD_MAX_AGE=`do_facet ost1 lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | head -n 1`
1703 FMD_BEFORE="`awk '/ll_fmd_cache/ { print $2 }' /proc/slabinfo`"
1704 touch $DIR/$tdir/$tfile
1705 sleep $((FMD_MAX_AGE + 12))
1706 FMD_AFTER="`awk '/ll_fmd_cache/ { print $2 }' /proc/slabinfo`"
1707 [ "$FMD_AFTER" -gt "$FMD_BEFORE" ] && \
1708 echo "AFTER : $FMD_AFTER > BEFORE $FMD_BEFORE" && \
1709 error "fmd didn't expire after ping" || true
1711 run_test 36g "filter mod data cache expiry ====================="
1715 echo f > $DIR/$tdir/fbugfile
1716 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
1717 ls $DIR/$tdir | grep "\<fbugfile\>" && error
1718 $UMOUNT $DIR/$tdir || error
1719 rm -f $DIR/$tdir/fbugfile || error
1721 run_test 37 "ls a mounted file system to check old content ====="
1724 local file=$DIR/$tfile
1726 openfile -f O_DIRECTORY $file
1729 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
1730 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
1732 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
1736 touch $DIR/${tfile}2
1737 # ls -l $DIR/$tfile $DIR/${tfile}2
1738 # ls -lu $DIR/$tfile $DIR/${tfile}2
1739 # ls -lc $DIR/$tfile $DIR/${tfile}2
1741 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
1742 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
1744 ls -l $DIR/$tfile $DIR/${tfile}2
1746 ls -lu $DIR/$tfile $DIR/${tfile}2
1748 ls -lc $DIR/$tfile $DIR/${tfile}2
1749 error "O_TRUNC didn't change timestamps"
1752 run_test 39 "mtime changed on create ==========================="
1754 function get_times() {
1759 for time in `stat -c "%X %Y %Z" $FILE`; do
1760 eval "$TIME[$i]=$time"
1770 cp -p /etc/passwd $DIR/$tdir/fopen
1771 cp -p /etc/passwd $DIR/$tdir/flink
1772 cp -p /etc/passwd $DIR/$tdir/funlink
1773 cp -p /etc/passwd $DIR/$tdir/frename
1774 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
1776 get_times $DIR/$tdir/fopen OPEN_OLD
1777 get_times $DIR/$tdir/flink LINK_OLD
1778 get_times $DIR/$tdir/funlink UNLINK_OLD
1779 get_times $DIR/$tdir/frename RENAME_OLD
1782 echo "aaaaaa" >> $DIR/$tdir/fopen
1783 echo "aaaaaa" >> $DIR/$tdir/flink
1784 echo "aaaaaa" >> $DIR/$tdir/funlink
1785 echo "aaaaaa" >> $DIR/$tdir/frename
1787 get_times $DIR/$tdir/fopen OPEN_NEW
1788 get_times $DIR/$tdir/flink LINK_NEW
1789 get_times $DIR/$tdir/funlink UNLINK_NEW
1790 get_times $DIR/$tdir/frename RENAME_NEW
1792 cat $DIR/$tdir/fopen > /dev/null
1793 ln $DIR/$tdir/flink $DIR/$tdir/flink2
1794 rm -f $DIR/$tdir/funlink2
1795 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
1797 get_times $DIR/$tdir/fopen OPEN_NEW2
1798 get_times $DIR/$tdir/flink LINK_NEW2
1799 get_times $DIR/$tdir/funlink UNLINK_NEW2
1800 get_times $DIR/$tdir/frename2 RENAME_NEW2
1801 echo ${OPEN_OLD[1]},${OPEN_NEW[$MTIME]},${OPEN_NEW2[$MTIME]}
1802 echo ${LINK_OLD[1]},${LINK_NEW[$MTIME]},${LINK_NEW2[$MTIME]}
1803 echo ${UNLINK_OLD[1]},${UNLINK_NEW[$MTIME]},${UNLINK_NEW2[$MTIME]}
1804 echo ${RENAME_OLD[1]},${RENAME_NEW[$MTIME]},${RENAME_NEW2[$MTIME]}
1806 [ ${OPEN_NEW2[$MTIME]} -eq ${OPEN_NEW[$MTIME]} ] || error "open file reverses mtime"
1807 [ ${LINK_NEW2[$MTIME]} -eq ${LINK_NEW[$MTIME]} ] || error "link file reverses mtime"
1808 [ ${UNLINK_NEW2[$MTIME]} -eq ${UNLINK_NEW[$MTIME]} ] || error "unlink file reverses mtime"
1809 [ ${RENAME_NEW2[$MTIME]} -eq ${RENAME_NEW[$MTIME]} ] || error "rename file reverses mtime"
1811 run_test 39b "mtime change on close ============================"
1815 touch -m -d "10 years ago" $DIR1/$tfile
1816 local MTIME1=`stat -c %y $DIR1/$tfile`
1817 echo hello >> $DIR1/$tfile
1818 local MTIME2=`stat -c %y $DIR1/$tfile`
1819 mv $DIR1/$tfile $DIR1/$tfile-1
1820 local MTIME3=`stat -c %y $DIR1/$tfile-1`
1821 [ "$MTIME2" = "$MTIME3" ] ||
1822 error "mtime ($MTIME2) changed (to $MTIME3) on rename (BZ#11063)"
1824 run_test 39c "mtime change on rename ==========================="
1827 dd if=/dev/zero of=$DIR/f40 bs=4096 count=1
1828 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/f40 && error
1829 $CHECKSTAT -t file -s 4096 $DIR/f40 || error
1831 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
1835 small_write $DIR/f41 18
1837 run_test 41 "test small file write + fstat ====================="
1839 count_ost_writes() {
1840 lctl get_param -n osc.*.stats |
1841 awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }'
1848 BG_DIRTY_RATIO_SAVE=10
1849 MAX_BG_DIRTY_RATIO=25
1853 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
1854 # dirty_ratio, dirty_background_ratio
1855 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
1856 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
1857 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
1858 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
1860 # if file not here, we are a 2.4 kernel
1861 kill -CONT `pidof kupdated`
1866 # setup the trap first, so someone cannot exit the test at the
1867 # exact wrong time and mess up a machine
1868 trap start_writeback EXIT
1869 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
1870 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
1871 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
1872 sysctl -w vm.dirty_writeback_centisecs=0
1873 # save and increase /proc/sys/vm/dirty_ratio
1874 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
1875 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
1876 # save and increase /proc/sys/vm/dirty_background_ratio
1877 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
1878 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
1880 # if file not here, we are a 2.4 kernel
1881 kill -STOP `pidof kupdated`
1885 # ensure that all stripes have some grant before we test client-side cache
1887 [ "$SETUP_TEST42" ] && return
1888 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
1889 dd if=/dev/zero of=$i bs=4k count=1
1895 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
1896 # file truncation, and file removal.
1899 cancel_lru_locks osc
1901 sync; sleep 1; sync # just to be safe
1902 BEFOREWRITES=`count_ost_writes`
1903 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
1904 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
1905 AFTERWRITES=`count_ost_writes`
1906 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
1907 error "$BEFOREWRITES < $AFTERWRITES"
1910 run_test 42a "ensure that we don't flush on close =============="
1914 cancel_lru_locks osc
1917 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
1918 BEFOREWRITES=`count_ost_writes`
1919 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
1920 AFTERWRITES=`count_ost_writes`
1921 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
1922 error "$BEFOREWRITES < $AFTERWRITES on unlink"
1924 BEFOREWRITES=`count_ost_writes`
1925 sync || error "sync: $?"
1926 AFTERWRITES=`count_ost_writes`
1927 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
1928 error "$BEFOREWRITES < $AFTERWRITES on sync"
1930 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
1934 run_test 42b "test destroy of file with cached dirty data ======"
1936 # if these tests just want to test the effect of truncation,
1937 # they have to be very careful. consider:
1938 # - the first open gets a {0,EOF}PR lock
1939 # - the first write conflicts and gets a {0, count-1}PW
1940 # - the rest of the writes are under {count,EOF}PW
1941 # - the open for truncate tries to match a {0,EOF}PR
1942 # for the filesize and cancels the PWs.
1943 # any number of fixes (don't get {0,EOF} on open, match
1944 # composite locks, do smarter file size management) fix
1945 # this, but for now we want these tests to verify that
1946 # the cancellation with truncate intent works, so we
1947 # start the file with a full-file pw lock to match against
1948 # until the truncate.
1953 cancel_lru_locks osc
1955 # prime the file with 0,EOF PW to match
1959 # now the real test..
1960 dd if=/dev/zero of=$file bs=1024 count=100
1961 BEFOREWRITES=`count_ost_writes`
1962 $TRUNCATE $file $offset
1963 cancel_lru_locks osc
1964 AFTERWRITES=`count_ost_writes`
1970 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
1971 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
1974 run_test 42c "test partial truncate of file with cached dirty data"
1978 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
1979 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
1982 run_test 42d "test complete truncate of file with cached dirty data"
1986 cp -p /bin/ls $DIR/$tdir/$tfile
1987 multiop $DIR/$tdir/$tfile Ow_c &
1989 # give multiop a chance to open
1992 $DIR/$tdir/$tfile && error || true
1995 run_test 43 "execution of file opened for write should return -ETXTBSY"
1999 cp -p `which multiop` $DIR/d43/multiop
2000 MULTIOP_PROG=$DIR/d43/multiop multiop_bg_pause $TMP/test43.junk O_c || return 1
2002 multiop $DIR/d43/multiop Oc && error "expected error, got success"
2003 kill -USR1 $MULTIOP_PID || return 2
2004 wait $MULTIOP_PID || return 3
2007 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
2011 cp -p `which multiop` $DIR/d43/multiop
2012 MULTIOP_PROG=$DIR/d43/multiop multiop_bg_pause $TMP/test43.junk O_c || return 1
2014 truncate $DIR/d43/multiop 0 && error "expected error, got success"
2015 kill -USR1 $MULTIOP_PID || return 2
2016 wait $MULTIOP_PID || return 3
2019 run_test 43b "truncate of file being executed should return -ETXTBSY"
2022 local testdir="$DIR/d43c"
2025 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
2026 ( cd $testdir && md5sum -c)
2028 run_test 43c "md5sum of copy into lustre========================"
2031 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
2032 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
2033 dd if=$DIR/f1 of=/dev/null bs=4k count=1
2035 run_test 44 "zero length read from a sparse stripe ============="
2038 local nstripe=`$LCTL lov_getconfig $DIR | grep default_stripe_count: | \
2040 [ -z "$nstripe" ] && skip "can't get stripe info" && return
2041 [ "$nstripe" -gt "$OSTCOUNT" ] && skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" && return
2042 local stride=`$LCTL lov_getconfig $DIR | grep default_stripe_size: | \
2044 if [ $nstripe -eq 0 -o $nstripe -eq -1 ] ; then
2045 nstripe=`$LCTL lov_getconfig $DIR | grep obd_count: | awk '{print $2}'`
2048 OFFSETS="0 $((stride/2)) $((stride-1))"
2049 for offset in $OFFSETS ; do
2050 for i in `seq 0 $((nstripe-1))`; do
2052 local GLOBALOFFSETS=""
2053 local size=$((((i + 2 * $nstripe )*$stride + $offset))) # Bytes
2054 ll_sparseness_write $DIR/d44a $size || error "ll_sparseness_write"
2055 GLOBALOFFSETS="$GLOBALOFFSETS $size"
2056 ll_sparseness_verify $DIR/d44a $GLOBALOFFSETS \
2057 || error "ll_sparseness_verify $GLOBALOFFSETS"
2059 for j in `seq 0 $((nstripe-1))`; do
2060 size=$((((j + $nstripe )*$stride + $offset))) # Bytes
2061 ll_sparseness_write $DIR/d44a $size || error "ll_sparseness_write"
2062 GLOBALOFFSETS="$GLOBALOFFSETS $size"
2064 ll_sparseness_verify $DIR/d44a $GLOBALOFFSETS \
2065 || error "ll_sparseness_verify $GLOBALOFFSETS"
2069 run_test 44a "test sparse pwrite ==============================="
2073 for d in `lctl get_param -n osc.*.cur_dirty_bytes`; do
2079 before=`dirty_osc_total`
2080 echo executing "\"$*\""
2082 after=`dirty_osc_total`
2083 echo before $before, after $after
2087 # Obtain grants from OST if it supports it
2088 echo blah > ${f}_grant
2091 do_dirty_record "echo blah > $f"
2092 [ $before -eq $after ] && error "write wasn't cached"
2093 do_dirty_record "> $f"
2094 [ $before -gt $after ] || error "truncate didn't lower dirty count"
2095 do_dirty_record "echo blah > $f"
2096 [ $before -eq $after ] && error "write wasn't cached"
2097 do_dirty_record "sync"
2098 [ $before -gt $after ] || error "writeback didn't lower dirty count"
2099 do_dirty_record "echo blah > $f"
2100 [ $before -eq $after ] && error "write wasn't cached"
2101 do_dirty_record "cancel_lru_locks osc"
2102 [ $before -gt $after ] || error "lock cancellation didn't lower dirty count"
2105 run_test 45 "osc io page accounting ============================"
2111 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
2112 # test tickles a bug where re-dirtying a page was failing to be mapped to the
2113 # objects offset and an assert hit when an rpc was built with 1023's mapped
2114 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
2119 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
2121 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
2122 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
2126 run_test 46 "dirtying a previously written page ================"
2128 # test_47 is removed "Device nodes check" is moved to test_28
2130 test_48a() { # bug 2399
2131 check_kernel_version 34 || return 0
2134 mv $DIR/d48a $DIR/d48.new || error "move directory failed"
2135 mkdir $DIR/d48a || error "recreate directory failed"
2136 touch foo || error "'touch foo' failed after recreating cwd"
2137 mkdir bar || error "'mkdir foo' failed after recreating cwd"
2138 if check_kernel_version 44; then
2139 touch .foo || error "'touch .foo' failed after recreating cwd"
2140 mkdir .bar || error "'mkdir .foo' failed after recreating cwd"
2142 ls . > /dev/null || error "'ls .' failed after recreating cwd"
2143 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
2144 cd . || error "'cd .' failed after recreating cwd"
2145 mkdir . && error "'mkdir .' worked after recreating cwd"
2146 rmdir . && error "'rmdir .' worked after recreating cwd"
2147 ln -s . baz || error "'ln -s .' failed after recreating cwd"
2148 cd .. || error "'cd ..' failed after recreating cwd"
2150 run_test 48a "Access renamed working dir (should return errors)="
2152 test_48b() { # bug 2399
2153 check_kernel_version 34 || return 0
2156 rmdir $DIR/d48b || error "remove cwd $DIR/d48b failed"
2157 touch foo && error "'touch foo' worked after removing cwd"
2158 mkdir foo && error "'mkdir foo' worked after removing cwd"
2159 if check_kernel_version 44; then
2160 touch .foo && error "'touch .foo' worked after removing cwd"
2161 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
2163 ls . > /dev/null && error "'ls .' worked after removing cwd"
2164 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
2165 is_patchless || ( cd . && error "'cd .' worked after removing cwd" )
2166 mkdir . && error "'mkdir .' worked after removing cwd"
2167 rmdir . && error "'rmdir .' worked after removing cwd"
2168 ln -s . foo && error "'ln -s .' worked after removing cwd"
2169 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
2171 run_test 48b "Access removed working dir (should return errors)="
2173 test_48c() { # bug 2350
2174 check_kernel_version 36 || return 0
2175 #lctl set_param debug=-1
2177 mkdir -p $DIR/d48c/dir
2179 $TRACE rmdir $DIR/d48c/dir || error "remove cwd $DIR/d48c/dir failed"
2180 $TRACE touch foo && error "'touch foo' worked after removing cwd"
2181 $TRACE mkdir foo && error "'mkdir foo' worked after removing cwd"
2182 if check_kernel_version 44; then
2183 touch .foo && error "'touch .foo' worked after removing cwd"
2184 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
2186 $TRACE ls . && error "'ls .' worked after removing cwd"
2187 $TRACE ls .. || error "'ls ..' failed after removing cwd"
2188 is_patchless || ( $TRACE cd . && error "'cd .' worked after removing cwd" )
2189 $TRACE mkdir . && error "'mkdir .' worked after removing cwd"
2190 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
2191 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
2192 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
2194 run_test 48c "Access removed working subdir (should return errors)"
2196 test_48d() { # bug 2350
2197 check_kernel_version 36 || return 0
2198 #lctl set_param debug=-1
2200 mkdir -p $DIR/d48d/dir
2202 $TRACE rmdir $DIR/d48d/dir || error "remove cwd $DIR/d48d/dir failed"
2203 $TRACE rmdir $DIR/d48d || error "remove parent $DIR/d48d failed"
2204 $TRACE touch foo && error "'touch foo' worked after removing parent"
2205 $TRACE mkdir foo && error "'mkdir foo' worked after removing parent"
2206 if check_kernel_version 44; then
2207 touch .foo && error "'touch .foo' worked after removing parent"
2208 mkdir .foo && error "'mkdir .foo' worked after removing parent"
2210 $TRACE ls . && error "'ls .' worked after removing parent"
2211 $TRACE ls .. && error "'ls ..' worked after removing parent"
2212 is_patchless || ( $TRACE cd . && error "'cd .' worked after recreate parent" )
2213 $TRACE mkdir . && error "'mkdir .' worked after removing parent"
2214 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
2215 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
2216 is_patchless || ( $TRACE cd .. && error "'cd ..' worked after removing parent" || true )
2218 run_test 48d "Access removed parent subdir (should return errors)"
2220 test_48e() { # bug 4134
2221 check_kernel_version 41 || return 0
2222 #lctl set_param debug=-1
2224 mkdir -p $DIR/d48e/dir
2226 $TRACE rmdir $DIR/d48e/dir || error "remove cwd $DIR/d48e/dir failed"
2227 $TRACE rmdir $DIR/d48e || error "remove parent $DIR/d48e failed"
2228 $TRACE touch $DIR/d48e || error "'touch $DIR/d48e' failed"
2229 $TRACE chmod +x $DIR/d48e || error "'chmod +x $DIR/d48e' failed"
2230 # On a buggy kernel addition of "touch foo" after cd .. will
2231 # produce kernel oops in lookup_hash_it
2232 touch ../foo && error "'cd ..' worked after recreate parent"
2234 $TRACE rm $DIR/d48e || error "rm '$DIR/d48e' failed"
2236 run_test 48e "Access to recreated parent subdir (should return errors)"
2242 ls /proc/$$/cwd || error
2244 run_test 50 "special situations: /proc symlinks ==============="
2246 test_51a() { # was test_51
2247 # bug 1516 - create an empty entry right after ".." then split dir
2250 $MCREATE $DIR/d51/bar
2252 createmany -m $DIR/d51/longfile 201
2254 while [ `ls -sd $DIR/d51 | awk '{ print $1 }'` -eq 4 ]; do
2255 $MCREATE $DIR/d51/longfile$FNUM
2260 ls -l $DIR/d51 > /dev/null || error
2262 run_test 51a "special situations: split htree with empty entry =="
2264 export NUMTEST=70000
2266 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
2267 [ $NUMFREE -lt 21000 ] && \
2268 skip "not enough free inodes ($NUMFREE)" && \
2271 check_kernel_version 40 || NUMTEST=31000
2272 [ $NUMFREE -lt $NUMTEST ] && NUMTEST=$(($NUMFREE - 50))
2275 createmany -d $DIR/d51b/t- $NUMTEST
2277 run_test 51b "mkdir .../t-0 --- .../t-$NUMTEST ===================="
2280 [ ! -d $DIR/d51b ] && skip "$DIR/51b missing" && \
2283 unlinkmany -d $DIR/d51b/t- $NUMTEST
2285 run_test 51c "rmdir .../t-0 --- .../t-$NUMTEST ===================="
2288 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping test with few OSTs" && return
2290 createmany -o $DIR/d51d/t- 1000
2291 $LFS getstripe $DIR/d51d > $TMP/files
2292 for N in `seq 0 $((OSTCOUNT - 1))`; do
2293 OBJS[$N]=`awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}' $TMP/files`
2294 OBJS0[$N]=`grep -A 1 idx $TMP/files | awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}'`
2295 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
2297 unlinkmany $DIR/d51d/t- 1000
2300 for N in `seq 1 $((OSTCOUNT - 1))`; do
2301 [ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ] && \
2302 error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
2303 [ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ] && \
2304 error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
2306 [ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ] && \
2307 error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
2308 [ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ] && \
2309 error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
2313 run_test 51d "check object distribution ===================="
2316 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
2319 chattr +a $DIR/d52a/foo || error "chattr +a failed"
2320 echo bar >> $DIR/d52a/foo || error "append bar failed"
2321 cp /etc/hosts $DIR/d52a/foo && error "cp worked"
2322 rm -f $DIR/d52a/foo 2>/dev/null && error "rm worked"
2323 link $DIR/d52a/foo $DIR/d52a/foo_link 2>/dev/null && error "link worked"
2324 echo foo >> $DIR/d52a/foo || error "append foo failed"
2325 mrename $DIR/d52a/foo $DIR/d52a/foo_ren && error "rename worked"
2326 # new lsattr displays 'e' flag for extents
2327 lsattr $DIR/d52a/foo | egrep -q "^-+a[-e]+ $DIR/d52a/foo" || error "lsattr"
2328 chattr -a $DIR/d52a/foo || error "chattr -a failed"
2330 rm -fr $DIR/d52a || error "cleanup rm failed"
2332 run_test 52a "append-only flag test (should return errors) ====="
2335 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
2338 chattr +i $DIR/d52b/foo || error "chattr +a failed"
2339 cat test > $DIR/d52b/foo && error "cat test worked"
2340 cp /etc/hosts $DIR/d52b/foo && error "cp worked"
2341 rm -f $DIR/d52b/foo 2>/dev/null && error "rm worked"
2342 link $DIR/d52b/foo $DIR/d52b/foo_link 2>/dev/null && error "link worked"
2343 echo foo >> $DIR/d52b/foo && error "echo worked"
2344 mrename $DIR/d52b/foo $DIR/d52b/foo_ren && error "rename worked"
2345 [ -f $DIR/d52b/foo ] || error
2346 [ -f $DIR/d52b/foo_ren ] && error
2347 lsattr $DIR/d52b/foo | egrep -q "^-+i[-e]+ $DIR/d52b/foo" || error "lsattr"
2348 chattr -i $DIR/d52b/foo || error "chattr failed"
2350 rm -fr $DIR/d52b || error "remove failed"
2352 run_test 52b "immutable flag test (should return errors) ======="
2354 test_52c() { # 12848 simulating client < 1.4.7
2355 [ -f $DIR/d52c/foo ] && chattr -i $DIR/d52b/foo
2358 # skip MDS_BFLAG_EXT_FLAGS in mdc_getattr_pack
2359 #define OBD_FAIL_MDC_OLD_EXT_FLAGS 0x802
2360 lctl set_param fail_loc=0x802
2361 chattr +i $DIR/d52c/foo || error
2362 lsattr $DIR/d52c/foo | egrep -q "^-+i[-e]+ $DIR/d52c/foo" || error "lsattr failed"
2363 chattr -i $DIR/d52c/foo || error "chattr failed"
2364 lctl set_param -n fail_loc=0
2366 rm -fr $DIR/d52c || error
2368 run_test 52c "immutable flag test for client < 1.4.7 ======="
2371 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2372 remote_ost_nodsh && skip "remote OST with nodsh" && return
2380 for VALUE in $(do_facet mds lctl get_param osc.*-osc.prealloc_last_id); do
2381 param=`echo ${VALUE[0]} | cut -d "=" -f1`;
2382 ostname=`echo $param | cut -d "." -f2 | cut -d - -f 1-2`
2383 mds_last=$(do_facet mds lctl get_param -n $param)
2384 ostnum=$(echo $ostname | sed "s/${FSNAME}-OST//g" | awk '{print ($1+1)}' )
2385 ost_last=$(do_facet ost$ostnum lctl get_param -n obdfilter.$ostname.last_id)
2386 echo "$ostname.last_id=$ost_last ; MDS.last_id=$mds_last"
2387 if [ $ost_last != $mds_last ]; then
2388 error "$ostname.last_id=$ost_last ; MDS.last_id=$mds_last"
2392 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
2395 [ ! -f "$SOCKETSERVER" ] && skip_env "no socketserver, skipping" && return
2396 [ ! -f "$SOCKETCLIENT" ] && skip_env "no socketclient, skipping" && return
2397 $SOCKETSERVER $DIR/socket
2398 $SOCKETCLIENT $DIR/socket || error
2399 $MUNLINK $DIR/socket
2401 run_test 54a "unix domain socket test =========================="
2407 dd if=/dev/zero of=$f bs=`page_size` count=1
2409 run_test 54b "char device works in lustre ======================"
2412 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
2413 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
2414 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
2416 for i in `seq 3 7`; do
2417 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
2427 loopdev="$DIR/loop54c"
2430 [ -z "$LOOPNUM" ] && echo "couldn't find empty loop device" && return
2431 mknod $loopdev b 7 $LOOPNUM
2432 echo "make a loop file system with $tfile on $loopdev ($LOOPNUM)..."
2433 dd if=/dev/zero of=$tfile bs=`page_size` seek=1024 count=1 > /dev/null
2434 losetup $loopdev $tfile || error "can't set up $loopdev for $tfile"
2435 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
2437 mount -t ext2 $loopdev $tdir || error "error mounting $loopdev on $tdir"
2438 dd if=/dev/zero of=$tdir/tmp bs=`page_size` count=30 || error "dd write"
2440 dd if=$tdir/tmp of=/dev/zero bs=`page_size` count=30 || error "dd read"
2445 run_test 54c "block device works in lustre ====================="
2451 [ "$string" = `echo $string > $f | cat $f` ] || error
2453 run_test 54d "fifo device works in lustre ======================"
2456 check_kernel_version 46 || return 0
2459 cp -aL /dev/console $f
2460 echo $string > $f || error
2462 run_test 54e "console/tty device works in lustre ======================"
2465 grep -q $FSTYPE /proc/filesystems && return 1
2467 grep -q $FSTYPE /proc/filesystems && return 1
2468 insmod ../$FSTYPE/$FSTYPE.o
2469 grep -q $FSTYPE /proc/filesystems && return 1
2470 insmod ../$FSTYPE/$FSTYPE.ko
2471 grep -q $FSTYPE /proc/filesystems && return 1
2478 client_only && skip "Not a server" && return
2479 mount -t $FSTYPE -o loop,iopen $EXT2_DEV $DIR/d55 || error "mounting"
2481 $IOPENTEST1 $DIR/d55/foo $DIR/d55 || error "running $IOPENTEST1"
2482 $IOPENTEST2 $DIR/d55 || error "running $IOPENTEST2"
2483 echo "check for $EXT2_DEV. Please wait..."
2485 $UMOUNT $DIR/d55 || error "unmounting"
2487 run_test 55 "check iopen_connect_dentry() ======================"
2489 test_56a() { # was test_56
2495 NUMFILESx2=$(($NUMFILES * 2))
2496 for i in `seq 1 $NUMFILES` ; do
2497 touch $DIR/d56/file$i
2498 touch $DIR/d56/dir/file$i
2501 # test lfs getstripe with --recursive
2502 FILENUM=`$GETSTRIPE --recursive $DIR/d56 | grep -c obdidx`
2503 [ $FILENUM -eq $NUMFILESx2 ] || error \
2504 "lfs getstripe --recursive $DIR/d56 wrong: found $FILENUM, expected $NUMFILESx2"
2505 FILENUM=`$GETSTRIPE $DIR/d56 | grep -c obdidx`
2506 [ $FILENUM -eq $NUMFILES ] || error \
2507 "lfs getstripe $DIR/d56 without --recursive wrong: found $FILENUM, expected $NUMFILES"
2508 echo "lfs getstripe --recursive passed."
2510 # test lfs getstripe with file instead of dir
2511 FILENUM=`$GETSTRIPE $DIR/d56/file1 | grep -c obdidx`
2512 [ $FILENUM -eq 1 ] || error \
2513 "lfs getstripe $DIR/d56/file1 wrong:found $FILENUM, expected 1"
2514 echo "lfs getstripe file passed."
2516 #test lfs getstripe with --verbose
2517 [ `$GETSTRIPE --verbose $DIR/d56 | grep -c lmm_magic` -eq $NUMFILES ] ||\
2518 error "lfs getstripe --verbose $DIR/d56 wrong: should find $NUMFILES lmm_magic info"
2519 [ `$GETSTRIPE $DIR/d56 | grep -c lmm_magic` -eq 0 ] || error \
2520 "lfs getstripe $DIR/d56 without --verbose wrong: should not show lmm_magic info"
2521 echo "lfs getstripe --verbose passed."
2523 #test lfs getstripe with --obd
2524 $GETSTRIPE --obd wrong_uuid $DIR/d56 2>&1 | grep -q "unknown obduuid" || \
2525 error "lfs getstripe --obd wrong_uuid should return error message"
2527 [ "$OSTCOUNT" -lt 2 ] && \
2528 skip_env "skipping other lfs getstripe --obd test" && return
2529 FILENUM=`$GETSTRIPE --recursive $DIR/d56 | sed -n '/^[ ]*1[ ]/p' | wc -l`
2530 OBDUUID=`$GETSTRIPE --recursive $DIR/d56 | sed -n '/^[ ]*1:/p' | awk '{print $2}'`
2531 FOUND=`$GETSTRIPE -r --obd $OBDUUID $DIR/d56 | wc -l`
2532 [ $FOUND -eq $FILENUM ] || \
2533 error "lfs getstripe --obd wrong: found $FOUND, expected $FILENUM"
2534 [ `$GETSTRIPE -r -v --obd $OBDUUID $DIR/d56 | sed '/^[ ]*1[ ]/d' |\
2535 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l` -eq 0 ] || \
2536 error "lfs getstripe --obd wrong: should not show file on other obd"
2537 echo "lfs getstripe --obd passed."
2539 run_test 56a "check lfs getstripe ===================================="
2546 if [ ! -d "$DIR/${tdir}g" ] ; then
2547 mkdir -p $DIR/${tdir}g
2548 for i in `seq 1 $LOCAL_NUMFILES` ; do
2549 touch $DIR/${tdir}g/file$i
2551 for i in `seq 1 $LOCAL_NUMDIRS` ; do
2552 mkdir $DIR/${tdir}g/dir$i
2553 for j in `seq 1 $LOCAL_NUMFILES` ; do
2554 touch $DIR/${tdir}g/dir$i/file$j
2560 setup_56_special() {
2565 if [ ! -e "$TDIR/loop1b" ] ; then
2566 for i in `seq 1 $LOCAL_NUMFILES` ; do
2567 mknod $TDIR/loop${i}b b 7 $i
2568 mknod $TDIR/null${i}c c 1 3
2569 ln -s $TDIR/file1 $TDIR/link${i}l
2571 for i in `seq 1 $LOCAL_NUMDIRS` ; do
2572 mknod $TDIR/dir$i/loop${i}b b 7 $i
2573 mknod $TDIR/dir$i/null${i}c c 1 3
2574 ln -s $TDIR/dir$i/file1 $TDIR/dir$i/link${i}l
2582 setup_56 $NUMFILES $NUMDIRS
2584 EXPECTED=$(($NUMDIRS + 2))
2585 # test lfs find with -name
2586 for i in `seq 1 $NUMFILES` ; do
2587 NUMS=`$LFIND -name "*$i" $DIR/${tdir}g | wc -l`
2588 [ $NUMS -eq $EXPECTED ] || error \
2589 "lfs find -name \"*$i\" $DIR/${tdir}g wrong: found $NUMS, expected $EXPECTED"
2591 echo "lfs find -name passed."
2593 run_test 56g "check lfs find -name ============================="
2598 setup_56 $NUMFILES $NUMDIRS
2600 EXPECTED=$((($NUMDIRS+1)*($NUMFILES-1)+$NUMFILES))
2601 # test lfs find with ! -name
2602 for i in `seq 1 $NUMFILES` ; do
2603 NUMS=`$LFIND ! -name "*$i" $DIR/${tdir}g | wc -l`
2604 [ $NUMS -eq $EXPECTED ] || error \
2605 "lfs find ! -name \"*$i\" $DIR/${tdir}g wrong: found $NUMS, expected $EXPECTED"
2607 echo "lfs find ! -name passed."
2609 run_test 56h "check lfs find ! -name ============================="
2614 UUID=`$GETSTRIPE $DIR/$tdir | awk '/0: / { print $2 }'`
2615 OUT="`$LFIND -ost $UUID $DIR/$tdir`"
2616 [ "$OUT" ] && error "$LFIND returned directory '$OUT'" || true
2618 run_test 56i "check 'lfs find -ost UUID' skips directories ======="
2621 setup_56_special $NUMFILES $NUMDIRS
2623 EXPECTED=$((NUMDIRS+1))
2624 NUMS=`$LFIND -type d $DIR/${tdir}g | wc -l`
2625 [ $NUMS -eq $EXPECTED ] || \
2626 error "lfs find -type d $DIR/${tdir}g wrong: found $NUMS, expected $EXPECTED"
2628 run_test 56j "check lfs find -type d ============================="
2631 setup_56_special $NUMFILES $NUMDIRS
2633 EXPECTED=$(((NUMDIRS+1) * NUMFILES))
2634 NUMS=`$LFIND -type f $DIR/${tdir}g | wc -l`
2635 [ $NUMS -eq $EXPECTED ] || \
2636 error "lfs find -type f $DIR/${tdir}g wrong: found $NUMS, expected $EXPECTED"
2638 run_test 56k "check lfs find -type f ============================="
2641 setup_56_special $NUMFILES $NUMDIRS
2643 EXPECTED=$((NUMDIRS + NUMFILES))
2644 NUMS=`$LFIND -type b $DIR/${tdir}g | wc -l`
2645 [ $NUMS -eq $EXPECTED ] || \
2646 error "lfs find -type b $DIR/${tdir}g wrong: found $NUMS, expected $EXPECTED"
2648 run_test 56l "check lfs find -type b ============================="
2651 setup_56_special $NUMFILES $NUMDIRS
2653 EXPECTED=$((NUMDIRS + NUMFILES))
2654 NUMS=`$LFIND -type c $DIR/${tdir}g | wc -l`
2655 [ $NUMS -eq $EXPECTED ] || \
2656 error "lfs find -type c $DIR/${tdir}g wrong: found $NUMS, expected $EXPECTED"
2658 run_test 56m "check lfs find -type c ============================="
2661 setup_56_special $NUMFILES $NUMDIRS
2663 EXPECTED=$((NUMDIRS + NUMFILES))
2664 NUMS=`$LFIND -type l $DIR/${tdir}g | wc -l`
2665 [ $NUMS -eq $EXPECTED ] || \
2666 error "lfs find -type l $DIR/${tdir}g wrong: found $NUMS, expected $EXPECTED"
2668 run_test 56n "check lfs find -type l ============================="
2671 setup_56 $NUMFILES $NUMDIRS
2674 utime $TDIR/file1 > /dev/null || error
2675 utime $TDIR/file2 > /dev/null || error
2676 utime $TDIR/dir1 > /dev/null || error
2677 utime $TDIR/dir2 > /dev/null || error
2678 utime $TDIR/dir1/file1 > /dev/null || error
2681 NUMS=`$LFIND -mtime +1 $TDIR | wc -l`
2682 [ $NUMS -eq $EXPECTED ] || \
2683 error "lfs find -mtime $TDIR wrong: found $NUMS, expected $EXPECTED"
2685 run_test 56o "check lfs find -mtime for old files =========================="
2688 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
2693 setup_56 $NUMFILES $NUMDIRS
2695 chown $RUNAS_ID $TDIR/file* || error "chown $DIR/${tdir}g/file$i failed"
2697 NUMS="`$LFIND -uid $RUNAS_ID $TDIR | wc -l`"
2698 [ $NUMS -eq $EXPECTED ] || \
2699 error "lfs find -uid $TDIR wrong: found $NUMS, expected $EXPECTED"
2701 EXPECTED=$(( ($NUMFILES+1) * $NUMDIRS + 1))
2702 NUMS="`$LFIND ! -uid $RUNAS_ID $TDIR | wc -l`"
2703 [ $NUMS -eq $EXPECTED ] || \
2704 error "lfs find ! -uid $TDIR wrong: found $NUMS, expected $EXPECTED"
2706 echo "lfs find -uid and ! -uid passed."
2708 run_test 56p "check lfs find -uid and ! -uid ==============================="
2711 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
2716 setup_56 $NUMFILES $NUMDIRS
2718 chgrp $RUNAS_ID $TDIR/file* || error "chown $DIR/${tdir}g/file$i failed"
2720 NUMS="`$LFIND -gid $RUNAS_ID $TDIR | wc -l`"
2721 [ $NUMS -eq $EXPECTED ] || \
2722 error "lfs find -gid $TDIR wrong: found $NUMS, expected $EXPECTED"
2724 EXPECTED=$(( ($NUMFILES+1) * $NUMDIRS + 1))
2725 NUMS="`$LFIND ! -gid $RUNAS_ID $TDIR | wc -l`"
2726 [ $NUMS -eq $EXPECTED ] || \
2727 error "lfs find ! -gid $TDIR wrong: found $NUMS, expected $EXPECTED"
2729 echo "lfs find -gid and ! -gid passed."
2731 run_test 56q "check lfs find -gid and ! -gid ==============================="
2734 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2736 local MNTDEV=$(get_mds_mntdev_proc_path)
2737 DEV=$(do_facet mds lctl get_param -n $MNTDEV)
2738 [ -z "$DEV" ] && error "can't access $MNTDEV"
2739 for DEV in $(do_facet mds lctl get_param -n $MNTDEV); do
2740 do_facet mds $DUMPE2FS -h $DEV > $TMP/t57a.dump || error "can't access $DEV"
2741 DEVISIZE=`awk '/Inode size:/ { print $3 }' $TMP/t57a.dump`
2742 [ "$DEVISIZE" -gt 128 ] || error "inode size $DEVISIZE"
2746 run_test 57a "verify MDS filesystem created with large inodes =="
2753 local FILEN=$dir/f$FILECOUNT
2755 rm -rf $dir || error "removing $dir"
2756 mkdir -p $dir || error "creating $dir"
2758 echo "mcreating $FILECOUNT files"
2759 createmany -m $dir/f 1 $FILECOUNT || \
2760 error "creating files in $dir"
2762 # verify that files do not have EAs yet
2763 $GETSTRIPE $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
2764 $GETSTRIPE $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
2766 local fsstat_dev=$(get_mds_fsstat_proc_path)
2767 local MDSFREE=$(do_facet mds lctl get_param -n $fsstat_dev.*.kbytesfree)
2768 local MDCFREE=$(lctl get_param -n mdc.*.kbytesfree | head -n 1)
2769 echo "opening files to create objects/EAs"
2771 for FILE in `seq -f $dir/f%g 1 $FILECOUNT`; do
2772 $OPENFILE -f O_RDWR $FILE > /dev/null || error "opening $FILE"
2775 # verify that files have EAs now
2776 $GETSTRIPE $FILE1 | grep -q "obdidx" || error "$FILE1 missing EA"
2777 $GETSTRIPE $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
2779 sleep 1 # make sure we get new statfs data
2780 local MDSFREE2=$(do_facet mds lctl get_param -n $fsstat_dev.*.kbytesfree)
2781 local MDCFREE2=$(lctl get_param -n mdc.*.kbytesfree | head -n 1)
2782 if [ "$MDCFREE2" -lt "$((MDCFREE - 8))" ]; then
2783 if [ "$MDSFREE" != "$MDSFREE2" ]; then
2784 error "MDC before $MDCFREE != after $MDCFREE2"
2786 echo "MDC before $MDCFREE != after $MDCFREE2"
2787 echo "unable to confirm if MDS has large inodes"
2792 run_test 57b "default LOV EAs are stored inside large inodes ==="
2795 [ -z "$(which wiretest 2>/dev/null)" ] && skip_env "could not find wiretest" && return
2798 run_test 58 "verify cross-platform wire constants =============="
2801 echo "touch 130 files"
2802 createmany -o $DIR/f59- 130
2804 unlinkmany $DIR/f59- 130
2807 # wait for commitment of removal
2809 run_test 59 "verify cancellation of llog records async ========="
2811 TEST60_HEAD="test_60 run $RANDOM"
2812 test_60a() { # was test_60
2813 [ ! -f run-llog.sh ] && skip_env "missing subtest run-llog.sh" && return
2814 log "$TEST60_HEAD - from kernel mode"
2817 run_test 60a "llog sanity tests run from kernel module =========="
2819 test_60b() { # bug 6411
2821 LLOG_COUNT=`dmesg | awk "/$TEST60_HEAD/{marker = 1; from_marker = 0;}
2833 [ $LLOG_COUNT -gt 50 ] && error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)"|| true
2835 run_test 60b "limit repeated messages from CERROR/CWARN ========"
2838 echo "create 5000 files"
2839 createmany -o $DIR/f60c- 5000
2840 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
2841 lctl set_param fail_loc=0x80000137
2842 unlinkmany $DIR/f60c- 5000
2844 run_test 60c "unlink file when mds full"
2847 SAVEPRINTK=$(lctl get_param -n printk)
2849 # verify "lctl mark" is even working"
2850 MESSAGE="test message ID $RANDOM $$"
2851 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
2852 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
2854 lctl set_param printk=0 || error "set lnet.printk failed"
2855 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
2856 MESSAGE="new test message ID $RANDOM $$"
2857 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
2858 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
2859 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
2861 lctl set_param -n printk="$SAVEPRINTK"
2863 run_test 60d "test printk console message masking"
2867 dd if=/dev/zero of=$f bs=`page_size` count=1
2868 cancel_lru_locks osc
2869 multiop $f OSMWUc || error
2872 run_test 61 "mmap() writes don't make sync hang ================"
2874 # bug 2330 - insufficient obd_match error checking causes LBUG
2878 cancel_lru_locks osc
2879 #define OBD_FAIL_OSC_MATCH 0x405
2880 lctl set_param fail_loc=0x405
2881 cat $f && error "cat succeeded, expect -EIO"
2882 lctl set_param fail_loc=0
2884 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
2885 # match every page all of the time.
2886 run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
2888 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
2889 test_63a() { # was test_63
2890 MAX_DIRTY_MB=`lctl get_param -n osc.*.max_dirty_mb | head -n 1`
2891 lctl set_param -n osc.*.max_dirty_mb 0
2892 for i in `seq 10` ; do
2893 dd if=/dev/zero of=$DIR/f63 bs=8k &
2899 lctl set_param -n osc.*.max_dirty_mb $MAX_DIRTY_MB
2900 rm -f $DIR/f63 || true
2902 run_test 63a "Verify oig_wait interruption does not crash ======="
2904 # bug 2248 - async write errors didn't return to application on sync
2905 # bug 3677 - async write errors left page locked
2908 lctl set_param debug=-1
2910 # ensure we have a grant to do async writes
2911 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
2914 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
2915 lctl set_param fail_loc=0x80000406
2916 multiop $DIR/$tfile Owy && \
2917 error "sync didn't return ENOMEM"
2918 sync; sleep 2; sync # do a real sync this time to flush page
2919 lctl get_param -n llite.*.dump_page_cache | grep locked && \
2920 error "locked page left in cache after async error" || true
2923 run_test 63b "async write errors should be returned to fsync ==="
2927 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
2929 run_test 64a "verify filter grant calculations (in kernel) ====="
2932 [ ! -f oos.sh ] && skip_env "missing subtest oos.sh" && return
2935 run_test 64b "check out-of-space detection on client ==========="
2937 # bug 1414 - set/get directories' stripe info
2941 $LVERIFY $DIR/d65 $DIR/d65/f1 || error "lverify failed"
2943 run_test 65a "directory with no stripe info ===================="
2947 $SETSTRIPE $DIR/d65 -s $(($STRIPESIZE * 2)) -i 0 -c 1 || error "setstripe"
2949 $LVERIFY $DIR/d65 $DIR/d65/f2 || error "lverify failed"
2951 run_test 65b "directory setstripe $(($STRIPESIZE * 2)) 0 1 ==============="
2954 if [ $OSTCOUNT -gt 1 ]; then
2956 $SETSTRIPE $DIR/d65 -s $(($STRIPESIZE * 4)) -i 1 \
2957 -c $(($OSTCOUNT - 1)) || error "setstripe"
2959 $LVERIFY $DIR/d65 $DIR/d65/f3 || error "lverify failed"
2962 run_test 65c "directory setstripe $(($STRIPESIZE * 4)) 1 $(($OSTCOUNT - 1))"
2966 [ $STRIPECOUNT -le 0 ] && sc=1 || sc=$(($STRIPECOUNT - 1))
2967 $SETSTRIPE $DIR/d65 -s $STRIPESIZE -c $sc || error "setstripe"
2968 touch $DIR/d65/f4 $DIR/d65/f5
2969 $LVERIFY $DIR/d65 $DIR/d65/f4 $DIR/d65/f5 || error "lverify failed"
2971 run_test 65d "directory setstripe $STRIPESIZE -1 stripe_count =============="
2976 $SETSTRIPE $DIR/d65 || error "setstripe"
2977 $GETSTRIPE -v $DIR/d65 | grep "Default" || error "no stripe info failed"
2979 $LVERIFY $DIR/d65 $DIR/d65/f6 || error "lverify failed"
2981 run_test 65e "directory setstripe defaults ======================="
2985 $RUNAS $SETSTRIPE $DIR/d65f && error "setstripe succeeded" || true
2987 run_test 65f "dir setstripe permission (should return error) ==="
2991 $SETSTRIPE $DIR/d65 -s $(($STRIPESIZE * 2)) -i 0 -c 1 || error "setstripe"
2992 $SETSTRIPE -d $DIR/d65 || error "setstripe"
2993 $GETSTRIPE -v $DIR/d65 | grep "Default" || \
2994 error "delete default stripe failed"
2996 run_test 65g "directory setstripe -d ==========================="
3000 $SETSTRIPE $DIR/d65 -s $(($STRIPESIZE * 2)) -i 0 -c 1 || error "setstripe"
3001 mkdir -p $DIR/d65/dd1
3002 [ "`$GETSTRIPE -v $DIR/d65 | grep "^count"`" == \
3003 "`$GETSTRIPE -v $DIR/d65/dd1 | grep "^count"`" ] || error "stripe info inherit failed"
3005 run_test 65h "directory stripe info inherit ===================="
3007 test_65i() { # bug6367
3008 $SETSTRIPE $MOUNT -s 65536 -c -1
3010 run_test 65i "set non-default striping on root directory (bug 6367)="
3012 test_65j() { # bug6367
3014 # if we aren't already remounting for each test, do so for this test
3015 if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
3016 cleanup || error "failed to unmount"
3019 $SETSTRIPE -d $MOUNT || error "setstripe failed"
3021 run_test 65j "set default striping on root directory (bug 6367)="
3023 test_65k() { # bug11679
3024 [ "$OSTCOUNT" -lt 2 ] && skip_env "too few OSTs" && return
3025 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3027 echo "Check OST status: "
3028 MDS_OSCS=`do_facet mds lctl dl | awk '/[oO][sS][cC].*md[ts]/ { print $4 }'`
3029 for OSC in $MDS_OSCS; do
3030 echo $OSC "is activate"
3031 do_facet mds lctl --device %$OSC activate
3033 do_facet client mkdir -p $DIR/$tdir
3034 for INACTIVE_OSC in $MDS_OSCS; do
3035 echo $INACTIVE_OSC "is Deactivate:"
3036 do_facet mds lctl --device %$INACTIVE_OSC deactivate
3037 for STRIPE_OSC in $MDS_OSCS; do
3038 STRIPE_OST=`osc_to_ost $STRIPE_OSC`
3039 STRIPE_INDEX=`do_facet mds lctl get_param -n lov.*md*.target_obd |
3040 grep $STRIPE_OST | awk -F: '{print $1}'`
3041 echo "$SETSTRIPE $DIR/$tdir/${STRIPE_INDEX} -i ${STRIPE_INDEX} -c 1"
3042 do_facet client $SETSTRIPE $DIR/$tdir/${STRIPE_INDEX} -i ${STRIPE_INDEX} -c 1
3044 [ $RC -ne 0 ] && error "setstripe should have succeeded"
3046 do_facet client rm -f $DIR/$tdir/*
3047 echo $INACTIVE_OSC "is Activate."
3048 do_facet mds lctl --device %$INACTIVE_OSC activate
3051 run_test 65k "validate manual striping works properly with deactivated OSCs"
3053 test_65l() { # bug 12836
3054 mkdir -p $DIR/$tdir/test_dir
3055 $SETSTRIPE $DIR/$tdir/test_dir -c -1
3056 $LFS find -mtime -1 $DIR/$tdir > /dev/null
3058 run_test 65l "lfs find on -1 stripe dir ========================"
3060 # bug 2543 - update blocks count on client
3063 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
3065 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
3066 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
3068 run_test 66 "update inode blocks count on client ==============="
3070 test_67a() { # was test_67 bug 3285 - supplementary group fails on MDS, passes on client
3071 [ "$RUNAS_ID" = "$UID" ] && skip "RUNAS_ID = UID = $UID -- skipping" && return
3072 check_kernel_version 35 || return 0
3074 chmod 771 $DIR/$tdir
3075 chgrp $RUNAS_ID $DIR/$tdir
3076 $RUNAS -u $RUNAS_ID -g $(($RUNAS_ID + 1)) -G1,2,$RUNAS_ID ls $DIR/$tdir
3078 GROUP_UPCALL=$(do_facet mds lctl get_param -n mds.*.group_upcall)
3079 [ -z "$GROUP_UPCALL" ] && \
3080 skip "lctl get_param failed! Useless to continue the test!" && return
3081 [ "$GROUP_UPCALL" = "NONE" -a $RC -eq 0 ] && \
3082 error "no-upcall passed" || true
3083 [ "$GROUP_UPCALL" != "NONE" -a $RC -ne 0 ] && \
3084 error "upcall failed" || true
3086 run_test 67a "supplementary group failure (should return error) ="
3091 do_facet mds lctl set_param -n mds.*.group_upcall NONE
3094 test_67b() { # bug 3285 - supplementary group fails on MDS, passes on client
3095 # needs to be in /etc/groups on MDS, gid == uid
3096 # Let's use RUNAS_ID
3097 T67_UID=${T67_UID:-$RUNAS_ID}
3099 [ "$UID" = "$T67_UID" ] && skip "UID = T67_UID = $UID -- skipping" && return
3100 check_kernel_version 35 || return 0
3101 do_facet mds grep -q ":$T67_UID:$T67_UID" /etc/passwd || \
3102 { skip "Need gid=$T67_UID group and gid == uid on mds !" && return; }
3104 GROUP_UPCALL=$(do_facet mds lctl get_param -n mds.*.group_upcall)
3105 [ -z "$GROUP_UPCALL" ] && \
3106 skip "lctl get_param failed! Useless to continue the test!" && return
3107 [ "$GROUP_UPCALL" != "NONE" ] && \
3108 skip "skip test - upcall=$GROUP_UPCALL" && return
3110 trap cleanup_67b EXIT
3112 chmod 771 $DIR/$tdir
3113 chgrp $T67_UID $DIR/$tdir
3114 local l_getgroups=$(do_facet mds which l_getgroups)
3115 do_facet mds lctl set_param -n mds.*.group_upcall $l_getgroups
3116 do_facet mds $l_getgroups -d $T67_UID
3117 $RUNAS -u $T67_UID -g 999 -G8,9,$T67_UID touch $DIR/$tdir/$tfile || \
3118 error "'touch $DIR/$tdir/$tfile' failed"
3119 [ -f $DIR/$tdir/$tfile ] || error "$DIR/$tdir/$tfile create error"
3122 run_test 67b "supplementary group test ========================="
3127 if [ ! -z "$LLOOP" ]; then
3128 swapoff $LLOOP || error "swapoff failed"
3129 $LCTL blockdev_detach $LLOOP || error "detach failed"
3137 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
3141 swapon -s | awk '($1 == "'$1'") { print $4 }'
3145 # excercise swapping to lustre by adding a high priority swapfile entry
3146 # and then consuming memory until it is used.
3148 [ "$UID" != 0 ] && skip_env "must run as root" && return
3149 lctl get_param -n devices | grep -q obdfilter && \
3150 skip "local OST" && return
3152 grep -q llite_lloop /proc/modules
3153 [ $? -ne 0 ] && skip_env "can't find module llite_lloop" && return
3155 [ -z "`$LCTL list_nids | grep -v tcp`" ] && \
3156 skip "can't reliably test swap with TCP" && return
3158 MEMTOTAL=`meminfo MemTotal`
3159 NR_BLOCKS=$((MEMTOTAL>>8))
3160 [[ $NR_BLOCKS -le 2048 ]] && NR_BLOCKS=2048
3162 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
3163 dd if=/dev/zero of=$DIR/f68 bs=64k seek=$NR_BLOCKS count=1
3166 $LCTL blockdev_attach $DIR/f68 $LLOOP || error "attach failed"
3168 trap cleanup_68 EXIT
3170 swapon -p 32767 $LLOOP || error "swapon $LLOOP failed"
3172 echo "before: `swapon -s | grep $LLOOP`"
3173 $MEMHOG $MEMTOTAL || error "error allocating $MEMTOTAL kB"
3174 echo "after: `swapon -s | grep $LLOOP`"
3175 SWAPUSED=`swap_used $LLOOP`
3179 [ $SWAPUSED -eq 0 ] && echo "no swap used???" || true
3181 run_test 68 "support swapping to Lustre ========================"
3183 # bug5265, obdfilter oa2dentry return -ENOENT
3184 # #define OBD_FAIL_OST_ENOENT 0x217
3186 remote_ost_nodsh && skip "remote OST with nodsh" && return
3189 $SETSTRIPE $f -c 1 -i 0
3191 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
3193 #define OBD_FAIL_OST_ENOENT 0x217
3194 do_facet ost1 lctl set_param fail_loc=0x217
3195 truncate $f 1 # vmtruncate() will ignore truncate() error.
3196 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
3198 do_facet ost1 lctl set_param fail_loc=0
3199 $DIRECTIO write $f 0 2 || error "write error"
3201 cancel_lru_locks osc
3202 $DIRECTIO read $f 0 1 || error "read error"
3204 #define OBD_FAIL_OST_ENOENT 0x217
3205 do_facet ost1 lctl set_param fail_loc=0x217
3206 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
3208 do_facet ost1 lctl set_param fail_loc=0
3211 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
3215 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
3217 run_test 71 "Running dbench on lustre (don't segment fault) ===="
3219 test_72() { # bug 5695 - Test that on 2.6 remove_suid works properly
3220 check_kernel_version 43 || return 0
3221 [ "$RUNAS_ID" = "$UID" ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
3223 # Check that testing environment is properly set up. Skip if not
3224 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS || {
3225 skip_env "User $RUNAS_ID does not exist - skipping"
3231 $RUNAS dd if=/dev/zero of=$DIR/f72 bs=512 count=1 || error
3232 # See if we are still setuid/sgid
3233 test -u $DIR/f72 -o -g $DIR/f72 && error "S/gid is not dropped on write"
3234 # Now test that MDS is updated too
3235 cancel_lru_locks mdc
3236 test -u $DIR/f72 -o -g $DIR/f72 && error "S/gid is not dropped on MDS"
3239 run_test 72 "Test that remove suid works properly (bug5695) ===="
3241 # bug 3462 - multiple simultaneous MDC requests
3245 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
3248 #define OBD_FAIL_MDS_PAUSE_OPEN 0x129
3249 lctl set_param fail_loc=0x80000129
3250 multiop $DIR/d73-1/f73-2 Oc &
3252 lctl set_param fail_loc=0
3254 multiop $DIR/d73-2/f73-3 Oc &
3258 wait $pid1 || return 1
3262 $CHECKSTAT -t file $DIR/d73-1/f73-1 || error "$DIR/d73-1/f73-1 not file"
3263 $CHECKSTAT -t file $DIR/d73-1/f73-2 || error "$DIR/d73-1/f73-2 not file"
3264 $CHECKSTAT -t file $DIR/d73-2/f73-3 || error "$DIR/d73-2/f73-3 not file"
3268 run_test 73 "multiple MDC requests (should not deadlock)"
3270 test_74a() { # bug 6149, 6184
3271 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
3273 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
3274 # will spin in a tight reconnection loop
3276 lctl set_param fail_loc=0x8000030e
3277 # get any lock that won't be difficult - lookup works.
3279 lctl set_param fail_loc=0
3282 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
3284 test_74b() { # bug 13310
3285 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
3287 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
3288 # will spin in a tight reconnection loop
3289 lctl set_param fail_loc=0x8000030e
3290 # get a "difficult" lock
3292 lctl set_param fail_loc=0
3295 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
3297 JOIN=${JOIN:-"lfs join"}
3304 [ $T75_PREP = "yes" ] && return
3305 echo "using F75=$F75, F128k=$F128k, FHEAD=$FHEAD, FTAIL=$FTAIL"
3307 dd if=/dev/urandom of=${F75}_128k bs=128k count=1 || error "dd failed"
3316 cp -p ${F128k} ${FHEAD}
3317 log "finished cp to $FHEAD"
3318 cp -p ${F128k} ${FTAIL}
3319 log "finished cp to $FTAIL"
3320 cat ${F128k} ${F128k} > ${F75}_sim_sim
3322 $JOIN ${FHEAD} ${FTAIL} || error "join ${FHEAD} ${FTAIL} error"
3323 log "finished join $FHEAD to ${F75}_sim_sim"
3324 cmp ${FHEAD} ${F75}_sim_sim || error "${FHEAD} ${F75}_sim_sim differ"
3325 log "finished cmp $FHEAD to ${F75}_sim_sim"
3326 $CHECKSTAT -a ${FTAIL} || error "tail ${FTAIL} still exist after join"
3328 run_test 75a "TEST join file ===================================="
3333 cp -p ${F128k} ${FTAIL}
3334 cat ${F75}_sim_sim >> ${F75}_join_sim
3335 cat ${F128k} >> ${F75}_join_sim
3336 $JOIN ${FHEAD} ${FTAIL} || error "join ${FHEAD} ${FTAIL} error"
3337 cmp ${FHEAD} ${F75}_join_sim || \
3338 error "${FHEAD} ${F75}_join_sim are different"
3339 $CHECKSTAT -a ${FTAIL} || error "tail ${FTAIL} exist after join"
3341 run_test 75b "TEST join file 2 =================================="
3346 cp -p ${F128k} ${FTAIL}
3347 cat ${F128k} >> ${F75}_sim_join
3348 cat ${F75}_join_sim >> ${F75}_sim_join
3349 $JOIN ${FTAIL} ${FHEAD} || error "join error"
3350 cmp ${FTAIL} ${F75}_sim_join || \
3351 error "${FTAIL} ${F75}_sim_join are different"
3352 $CHECKSTAT -a ${FHEAD} || error "tail ${FHEAD} exist after join"
3354 run_test 75c "TEST join file 3 =================================="
3359 cp -p ${F128k} ${FHEAD}
3360 cp -p ${F128k} ${FHEAD}_tmp
3361 cat ${F75}_sim_sim >> ${F75}_join_join
3362 cat ${F75}_sim_join >> ${F75}_join_join
3363 $JOIN ${FHEAD} ${FHEAD}_tmp || error "join ${FHEAD} ${FHEAD}_tmp error"
3364 $JOIN ${FHEAD} ${FTAIL} || error "join ${FHEAD} ${FTAIL} error"
3365 cmp ${FHEAD} ${F75}_join_join ||error "${FHEAD} ${F75}_join_join differ" $CHECKSTAT -a ${FHEAD}_tmp || error "${FHEAD}_tmp exist after join"
3366 $CHECKSTAT -a ${FTAIL} || error "tail ${FTAIL} exist after join (2)"
3368 run_test 75d "TEST join file 4 =================================="
3373 rm -rf ${FHEAD} || "delete join file error"
3375 run_test 75e "TEST join file 5 (remove joined file) ============="
3380 cp -p ${F128k} ${F75}_join_10_compare
3381 cp -p ${F128k} ${F75}_join_10
3382 for ((i = 0; i < 10; i++)); do
3383 cat ${F128k} >> ${F75}_join_10_compare
3384 cp -p ${F128k} ${FTAIL}
3385 $JOIN ${F75}_join_10 ${FTAIL} || \
3386 error "join ${F75}_join_10 ${FTAIL} error"
3387 $CHECKSTAT -a ${FTAIL} || error "tail file exist after join"
3389 cmp ${F75}_join_10 ${F75}_join_10_compare || \
3390 error "files ${F75}_join_10 ${F75}_join_10_compare differ"
3392 run_test 75f "TEST join file 6 (join 10 files) =================="
3395 [ ! -f ${F75}_join_10 ] && echo "${F75}_join_10 missing" && return
3396 $LFS getstripe ${F75}_join_10
3398 $OPENUNLINK ${F75}_join_10 ${F75}_join_10 || error "files unlink open"
3402 run_test 75g "TEST join file 7 (open unlink) ===================="
3405 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
3408 test_76() { # bug 1443
3409 DETH=$(grep deathrow /proc/kallsyms /proc/ksyms 2> /dev/null | wc -l)
3410 [ $DETH -eq 0 ] && skip "No _iget." && return 0
3411 BEFORE_INODES=`num_inodes`
3412 echo "before inodes: $BEFORE_INODES"
3414 [ "$SLOW" = "no" ] && COUNT=100
3415 for i in `seq $COUNT`; do
3419 AFTER_INODES=`num_inodes`
3420 echo "after inodes: $AFTER_INODES"
3421 [ $AFTER_INODES -gt $((BEFORE_INODES + 32)) ] && \
3422 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
3425 run_test 76 "destroy duplicate inodes in client inode cache ===="
3430 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums |
3433 lctl set_param -n osc.*.checksums=$1
3437 export ORIG_CSUM_TYPE=""
3438 CKSUM_TYPES=${CKSUM_TYPES:-"crc32 adler"}
3441 [ "$ORIG_CSUM_TYPE" ] || \
3442 ORIG_CSUM_TYPE=`lctl get_param -n osc.*osc-[^mM]*.checksum_type | sed 's/.*\[\(.*\)\].*/\1/g' \
3444 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
3445 log "set checksum type to $1"
3448 F77_TMP=$TMP/f77-temp
3451 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
3452 error "error writing to $F77_TMP"
3455 test_77a() { # bug 10889
3456 [ ! -f $F77_TMP ] && setup_f77
3458 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
3461 run_test 77a "normal checksum read/write operation ============="
3463 test_77b() { # bug 10889
3464 [ ! -f $F77_TMP ] && setup_f77
3465 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
3466 lctl set_param fail_loc=0x80000409
3468 dd if=$F77_TMP of=$DIR/f77b bs=1M count=$F77SZ conv=sync || \
3469 error "dd error: $?"
3470 lctl set_param fail_loc=0
3473 run_test 77b "checksum error on client write ===================="
3475 test_77c() { # bug 10889
3476 [ ! -f $DIR/f77b ] && skip "requires 77b - skipping" && return
3478 for algo in $CKSUM_TYPES; do
3479 cancel_lru_locks osc
3480 set_checksum_type $algo
3481 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
3482 lctl set_param fail_loc=0x80000408
3483 cmp $F77_TMP $DIR/f77b || error "file compare failed"
3484 lctl set_param fail_loc=0
3487 set_checksum_type $ORIG_CSUM_TYPE
3489 run_test 77c "checksum error on client read ==================="
3491 test_77d() { # bug 10889
3492 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
3493 lctl set_param fail_loc=0x80000409
3495 directio write $DIR/f77 0 $F77SZ $((1024 * 1024)) || \
3496 error "direct write: rc=$?"
3497 lctl set_param fail_loc=0
3500 run_test 77d "checksum error on OST direct write ==============="
3502 test_77e() { # bug 10889
3503 [ ! -f $DIR/f77 ] && skip "requires 77d - skipping" && return
3504 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
3505 lctl set_param fail_loc=0x80000408
3507 cancel_lru_locks osc
3508 directio read $DIR/f77 0 $F77SZ $((1024 * 1024)) || \
3509 error "direct read: rc=$?"
3510 lctl set_param fail_loc=0
3513 run_test 77e "checksum error on OST direct read ================"
3515 test_77f() { # bug 10889
3517 for algo in $CKSUM_TYPES; do
3518 cancel_lru_locks osc
3519 set_checksum_type $algo
3520 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
3521 lctl set_param fail_loc=0x409
3522 directio write $DIR/f77 0 $F77SZ $((1024 * 1024)) && \
3523 error "direct write succeeded"
3524 lctl set_param fail_loc=0
3526 set_checksum_type $ORIG_CSUM_TYPE
3529 run_test 77f "repeat checksum error on write (expect error) ===="
3531 test_77g() { # bug 10889
3532 remote_ost_nodsh && skip "remote OST with nodsh" && return
3534 [ ! -f $F77_TMP ] && setup_f77
3536 $SETSTRIPE $DIR/f77g -c 1 -i 0
3537 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
3538 do_facet ost1 lctl set_param fail_loc=0x8000021a
3540 dd if=$F77_TMP of=$DIR/f77g bs=1M count=$F77SZ || \
3541 error "write error: rc=$?"
3542 do_facet ost1 lctl set_param fail_loc=0
3545 run_test 77g "checksum error on OST write ======================"
3547 test_77h() { # bug 10889
3548 remote_ost_nodsh && skip "remote OST with nodsh" && return
3550 [ ! -f $DIR/f77g ] && skip "requires 77g - skipping" && return
3551 cancel_lru_locks osc
3552 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
3553 do_facet ost1 lctl set_param fail_loc=0x8000021b
3555 cmp $F77_TMP $DIR/f77g || error "file compare failed"
3556 do_facet ost1 lctl set_param fail_loc=0
3559 run_test 77h "checksum error on OST read ======================="
3561 test_77i() { # bug 13805
3562 #define OBD_FAIL_OSC_CONNECT_CKSUM 0x40b
3563 lctl set_param fail_loc=0x40b
3564 remount_client $MOUNT
3565 lctl set_param fail_loc=0
3566 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
3567 param=`echo ${VALUE[0]} | cut -d "=" -f1`
3568 algo=`lctl get_param -n $param | sed 's/.*\[\(.*\)\].*/\1/g'`
3569 [ "$algo" = "crc32" ] || error "algo set to $algo instead of crc32"
3571 remount_client $MOUNT
3573 run_test 77i "client not supporting OSD_CONNECT_CKSUM =========="
3575 test_77j() { # bug 13805
3576 #define OBD_FAIL_OSC_CKSUM_ADLER_ONLY 0x40c
3577 lctl set_param fail_loc=0x40c
3578 remount_client $MOUNT
3579 lctl set_param fail_loc=0
3580 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
3581 param=`echo ${VALUE[0]} | cut -d "=" -f1`
3582 algo=`lctl get_param -n $param | sed 's/.*\[\(.*\)\].*/\1/g'`
3583 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
3585 remount_client $MOUNT
3587 run_test 77j "client only supporting ADLER32 ===================="
3589 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
3593 test_78() { # bug 10901
3595 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
3596 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
3597 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
3598 echo "MemTotal: $MEMTOTAL"
3599 # reserve 256MB of memory for the kernel and other running processes,
3600 # and then take 1/2 of the remaining memory for the read/write buffers.
3601 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
3602 echo "Mem to use for directio: $MEMTOTAL"
3603 [ $F78SIZE -gt $MEMTOTAL ] && F78SIZE=$MEMTOTAL
3604 [ $F78SIZE -gt 512 ] && F78SIZE=512
3605 [ $F78SIZE -gt $((MAXFREE / 1024)) ] && F78SIZE=$((MAXFREE / 1024))
3606 SMALLESTOST=`lfs df $DIR |grep OST | awk '{print $4}' |sort -n |head -1`
3607 echo "Smallest OST: $SMALLESTOST"
3608 [ $SMALLESTOST -lt 10240 ] && \
3609 skip "too small OSTSIZE, useless to run large O_DIRECT test" && return 0
3611 [ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 5)) ] && \
3612 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 5))
3613 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
3614 echo "File size: $F78SIZE"
3615 $SETSTRIPE $DIR/$tfile -c -1 || error "setstripe failed"
3616 for i in `seq 1 $NSEQ`
3618 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
3619 echo directIO rdwr round $i of $NSEQ
3620 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
3625 run_test 78 "handle large O_DIRECT writes correctly ============"
3627 test_79() { # bug 12743
3628 wait_delete_completed
3630 BKTOTAL=$(calc_osc_kbytes kbytestotal)
3631 BKFREE=$(calc_osc_kbytes kbytesfree)
3632 BKAVAIL=$(calc_osc_kbytes kbytesavail)
3633 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
3634 DFTOTAL=`echo $STRING | cut -d, -f1`
3635 DFUSED=`echo $STRING | cut -d, -f2`
3636 DFAVAIL=`echo $STRING | cut -d, -f3`
3637 DFFREE=$(($DFTOTAL - $DFUSED))
3639 ALLOWANCE=$((64 * $OSTCOUNT))
3641 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
3642 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
3643 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
3645 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
3646 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
3647 error "df free($DFFREE) mismatch OST free($BKFREE)"
3649 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
3650 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
3651 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
3654 run_test 79 "df report consistency check ======================="
3656 test_80() { # bug 10718
3657 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
3659 local BEFORE=`date +%s`
3660 cancel_lru_locks osc
3661 local AFTER=`date +%s`
3662 local DIFF=$((AFTER-BEFORE))
3663 if [ $DIFF -gt 1 ] ; then
3664 error "elapsed for 1M@1T = $DIFF"
3668 run_test 80 "Page eviction is equally fast at high offsets too ===="
3671 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
3672 mkdir -p $DIR/d99cvsroot || error "mkdir $DIR/d99cvsroot failed"
3673 chown $RUNAS_ID $DIR/d99cvsroot || error "chown $DIR/d99cvsroot failed"
3674 local oldPWD=$PWD # bug 13584, use $TMP as working dir
3677 $RUNAS cvs -d $DIR/d99cvsroot init || error "cvs init failed"
3680 run_test 99a "cvs init ========================================="
3683 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
3684 [ ! -d $DIR/d99cvsroot ] && test_99a
3685 $RUNAS [ ! -w /tmp ] && skip "/tmp has wrong w permission -- skipping" && return
3686 cd /etc/init.d || error "cd /etc/init.d failed"
3687 # some versions of cvs import exit(1) when asked to import links or
3688 # files they can't read. ignore those files.
3689 TOIGNORE=$(find . -type l -printf '-I %f\n' -o \
3690 ! -perm +4 -printf '-I %f\n')
3691 $RUNAS cvs -d $DIR/d99cvsroot import -m "nomesg" $TOIGNORE \
3692 d99reposname vtag rtag > /dev/null || error "cvs import failed"
3694 run_test 99b "cvs import ======================================="
3697 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
3698 [ ! -d $DIR/d99cvsroot ] && test_99b
3699 cd $DIR || error "cd $DIR failed"
3700 mkdir -p $DIR/d99reposname || error "mkdir $DIR/d99reposname failed"
3701 chown $RUNAS_ID $DIR/d99reposname || \
3702 error "chown $DIR/d99reposname failed"
3703 $RUNAS cvs -d $DIR/d99cvsroot co d99reposname > /dev/null || \
3704 error "cvs co d99reposname failed"
3706 run_test 99c "cvs checkout ====================================="
3709 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
3710 [ ! -d $DIR/d99cvsroot ] && test_99c
3711 cd $DIR/d99reposname
3713 $RUNAS cvs add -m 'addmsg' foo99
3715 run_test 99d "cvs add =========================================="
3718 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
3719 [ ! -d $DIR/d99cvsroot ] && test_99c
3720 cd $DIR/d99reposname
3723 run_test 99e "cvs update ======================================="
3726 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
3727 [ ! -d $DIR/d99cvsroot ] && test_99d
3728 cd $DIR/d99reposname
3729 $RUNAS cvs commit -m 'nomsg' foo99
3731 run_test 99f "cvs commit ======================================="
3734 [ "$NETTYPE" = tcp ] || \
3735 { skip "TCP secure port test, not useful for NETTYPE=$NETTYPE" && \
3738 remote_ost_nodsh && skip "remote OST with nodsh" && return
3739 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3741 { skip "useless for local single node setup" && return; }
3743 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
3744 [ "$PROT" != "tcp" ] && continue
3745 RPORT=$(echo $REMOTE | cut -d: -f2)
3746 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
3749 LPORT=`echo $LOCAL | cut -d: -f2`
3750 if [ $LPORT -ge 1024 ]; then
3751 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
3753 error_exit "local: $LPORT > 1024, remote: $RPORT"
3756 [ "$rc" = 0 ] || error_exit "privileged port not found" )
3758 run_test 100 "check local port using privileged port ==========="
3760 function get_named_value()
3769 echo $line | sed "s/^$tag//"
3776 export CACHE_MAX=`lctl get_param -n llite/*/max_cached_mb | head -n 1`
3778 lctl set_param -n llite.*.max_cached_mb $CACHE_MAX
3786 [ "$CPU" = "UML" ] && nreads=1000
3787 local cache_limit=32
3789 lctl set_param -n osc.*.rpc_stats 0
3790 trap cleanup_101 EXIT
3792 lctl set_param -n llite.*.read_ahead_stats 0
3793 lctl set_param -n llite.*.max_cached_mb $cache_limit
3796 # randomly read 10000 of 64K chunks from file 3x 32MB in size
3798 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
3799 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
3802 for s in `lctl get_param -n llite.*.read_ahead_stats | \
3803 get_named_value 'read but discarded' | cut -d" " -f1`; do
3804 discard=$(($discard + $s))
3808 if [ $(($discard * 10)) -gt $nreads ] ;then
3809 lctl get_param osc.*.rpc_stats
3810 lctl get_param llite.*.read_ahead_stats
3811 error "too many ($discard) discarded pages"
3813 rm -f $DIR/$tfile || true
3815 run_test 101 "check read-ahead for random reads ================"
3817 export SETUP_TEST101b=no
3819 [ "$SETUP_TEST101b" = "yes" ] && return
3822 STRIPE_COUNT=$OSTCOUNT
3825 trap cleanup_101 EXIT
3826 # prepare the read-ahead file
3827 $SETSTRIPE $DIR/$tfile -s $STRIPE_SIZE -i $STRIPE_OFFSET -c $OSTCOUNT
3829 dd if=/dev/zero of=$DIR/$tfile bs=1024k count=100 2> /dev/null
3835 rm -rf $DIR/$tdir $DIR/$tfile
3840 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
3845 local STRIPE_SIZE=1048576
3846 local RA_INC=1048576
3847 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
3848 local FILE_LENGTH=$((64*100))
3849 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
3850 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
3851 DISCARD=`$LCTL get_param -n llite.*.read_ahead_stats | \
3852 get_named_value 'read but discarded' | \
3853 cut -d" " -f1 | calc_total`
3855 if [ $DISCARD -gt $discard_limit ]; then
3856 lctl get_param llite.*.read_ahead_stats
3857 error "Too many ($DISCARD) discarded pages (size ${READ_SIZE})"
3859 echo "Read-ahead success for size ${READ_SIZE}"
3864 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs for stride-read" && return
3865 local STRIPE_SIZE=1048576
3866 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
3867 local FILE_LENGTH=$((STRIPE_SIZE*100))
3868 local ITERATION=$((FILE_LENGTH/STRIDE_SIZE))
3869 # prepare the read-ahead file
3871 cancel_lru_locks osc
3872 for BIDX in 2 4 8 16 32 64 128 256; do
3873 local BSIZE=$((BIDX*4096))
3874 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
3875 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
3876 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
3877 $LCTL set_param -n llite.*.read_ahead_stats 0
3878 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
3879 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
3880 cancel_lru_locks osc
3881 ra_check_101b $BSIZE
3885 run_test 101b "check stride-io mode read-ahead ================="
3888 local STRIPE_SIZE=1048576
3889 local FILE_LENGTH=$((STRIPE_SIZE*100))
3894 cancel_lru_locks osc
3895 $LCTL set_param osc.*.rpc_stats 0
3896 $READS -f $DIR/$tfile -s$FILE_LENGTH -b65536 -n$nreads -t 180
3897 for OSC in `$LCTL get_param -N osc.*`
3899 if [ "$OSC" == "osc.num_refs" ]; then
3902 lines=`$LCTL get_param -n ${OSC}.rpc_stats | wc | awk '{print $1}'`
3903 if [ $lines -le 20 ]; then
3907 rpc4k=$($LCTL get_param -n $OSC | awk '$1 == "1:" { print $2; exit; }')
3908 rpc8k=$($LCTL get_param -n $OSC | awk '$1 == "2:" { print $2; exit; }')
3909 rpc16k=$($LCTL get_param -n $OSC | awk '$1 == "4:" { print $2; exit; }')
3910 rpc32k=$($LCTL get_param -n $OSC | awk '$1 == "8:" { print $2; exit; }')
3912 [ $rpc4k != 0 ] && error "Small 4k read IO ${rpc4k}!"
3913 [ $rpc8k != 0 ] && error "Small 8k read IO ${rpc8k}!"
3914 [ $rpc16k != 0 ] && error "Small 16k read IO ${rpc16k}!"
3915 [ $rpc32k != 0 ] && error "Small 32k read IO ${rpc32k}!"
3917 echo "Small rpc check passed!"
3918 rpc64k=$($LCTL get_param -n $OSC | awk '$1 == "16:" { print $2; exit; }')
3919 rpc128k=$($LCTL get_param -n $OSC | awk '$1 == "32:" { print $2; exit; }')
3920 rpc256k=$($LCTL get_param -n $OSC | awk '$1 == "64:" { print $2; exit; }')
3921 rpc512k=$($LCTL get_param -n $OSC | awk '$1 == "128:" { print $2; exit; }')
3922 rpc1024k=$($LCTL get_param -n $OSC | awk '$1 == "256:" { print $2; exit; }')
3924 [ $rpc64k == 0 ] && error "No 64k readahead IO ${rpc64k}"
3925 [ $rpc128k == 0 ] && error "No 128k readahead IO ${rpc128k}"
3926 [ $rpc256k == 0 ] && error "No 256k readahead IO ${rpc256k}"
3927 [ $rpc512k == 0 ] && error "No 512k readahead IO ${rpc256k}"
3928 [ $rpc1024k == 0 ] && error "No 1024k readahead IO ${rpc1024k}"
3929 echo "Big rpc check passed!"
3934 run_test 101c "check stripe_size aligned read-ahead ================="
3937 lctl get_param -n llite.*.max_read_ahead_mb | head -n 1
3938 lctl set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
3942 local file=$DIR/$tfile
3943 local size=${FILESIZE_101c:-500}
3944 local ra_MB=${READAHEAD_MB:-40}
3946 local space=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
3947 [ $space -gt $((size / 1024)) ] ||
3948 { skip "Need free space ${size}M, have $space" && return; }
3950 echo Creating ${size}M test file $file
3951 dd if=/dev/zero of=$file bs=1M count=$size
3952 echo Cancel LRU locks on lustre client to flush the client cache
3953 cancel_lru_locks osc
3955 echo Disable read-ahead
3956 local old_READAHEAD=$(set_read_ahead 0)
3958 echo Reading the test file $file with read-ahead disabled
3959 time_ra_OFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$size")
3961 echo Cancel LRU locks on lustre client to flush the client cache
3962 cancel_lru_locks osc
3963 echo Enable read-ahead with ${ra_MB}MB
3964 set_read_ahead $ra_MB
3966 echo Reading the test file $file with read-ahead enabled
3967 time_ra_ON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$size")
3969 echo read-ahead disabled time read $time_ra_OFF
3970 echo read-ahead enabled time read $time_ra_ON
3972 set_read_ahead $old_READAHEAD
3975 [ $time_ra_ON -lt $time_ra_OFF ] ||
3976 error "read-ahead enabled time read (${time_ra_ON}s) is more than
3977 read-ahead disabled time read (${time_ra_OFF}s) filesize ${size}M"
3979 run_test 101d "file read with and without read-ahead enabled ================="
3981 export SETUP_TEST102=no
3983 [ "$SETUP_TEST102" = "yes" ] && return
3985 chown $RUNAS_ID $DIR/$tdir
3988 STRIPE_COUNT=$OSTCOUNT
3989 [ $OSTCOUNT -gt 4 ] && STRIPE_COUNT=4
3991 trap cleanup_test102 EXIT
3993 $1 $SETSTRIPE $tdir -s $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT
3997 for count in `seq 1 $STRIPE_COUNT`
3999 for offset in `seq 0 $[$STRIPE_COUNT - 1]`
4001 local stripe_size=`expr $STRIPE_SIZE \* $num`
4002 local file=file"$num-$offset-$count"
4003 $1 $SETSTRIPE $file -s $stripe_size -i $offset -c $count
4009 $1 $TAR cf $TMP/f102.tar $tdir --xattrs
4015 [ "$SETUP_TEST102" = "yes" ] || return 0
4021 local testfile=$DIR/xattr_testfile
4026 [ "$UID" != 0 ] && skip_env "must run as root" && return
4027 [ -z "`lctl get_param -n mdc.*.connect_flags | grep xattr`" ] &&
4028 skip_env "must have user_xattr" && return
4029 [ -z "$(which setfattr 2>/dev/null)" ] && skip_env "could not find setfattr" && return
4031 echo "set/get xattr..."
4032 setfattr -n trusted.name1 -v value1 $testfile || error
4033 [ "`getfattr -n trusted.name1 $testfile 2> /dev/null | \
4034 grep "trusted.name1"`" == "trusted.name1=\"value1\"" ] || error
4036 setfattr -n user.author1 -v author1 $testfile || error
4037 [ "`getfattr -n user.author1 $testfile 2> /dev/null | \
4038 grep "user.author1"`" == "user.author1=\"author1\"" ] || error
4041 setfattr -n trusted.name2 -v value2 $testfile || error
4042 setfattr -n trusted.name3 -v value3 $testfile || error
4043 [ `getfattr -d -m "^trusted" $testfile 2> /dev/null | \
4044 grep "trusted.name" | wc -l` -eq 3 ] || error
4047 setfattr -n user.author2 -v author2 $testfile || error
4048 setfattr -n user.author3 -v author3 $testfile || error
4049 [ `getfattr -d -m "^user" $testfile 2> /dev/null | \
4050 grep "user" | wc -l` -eq 3 ] || error
4052 echo "remove xattr..."
4053 setfattr -x trusted.name1 $testfile || error
4054 getfattr -d -m trusted $testfile 2> /dev/null | \
4055 grep "trusted.name1" && error || true
4057 setfattr -x user.author1 $testfile || error
4058 getfattr -d -m user $testfile 2> /dev/null | \
4059 grep "user.author1" && error || true
4061 # b10667: setting lustre special xattr be silently discarded
4062 echo "set lustre special xattr ..."
4063 setfattr -n "trusted.lov" -v "invalid value" $testfile || error
4067 run_test 102a "user xattr test =================================="
4070 # b10930: get/set/list trusted.lov xattr
4071 echo "get/set/list trusted.lov xattr ..."
4072 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
4073 local testfile=$DIR/$tfile
4074 $SETSTRIPE -s 65536 -i 1 -c 2 $testfile || error "setstripe failed"
4075 getfattr -d -m "^trusted" $testfile 2> /dev/null | \
4076 grep "trusted.lov" || error "can't get trusted.lov from $testfile"
4078 local testfile2=${testfile}2
4079 local value=`getfattr -n trusted.lov $testfile 2> /dev/null | \
4080 grep "trusted.lov" |sed -e 's/[^=]\+=//'`
4083 setfattr -n trusted.lov -v $value $testfile2
4084 local tmp_file=${testfile}3
4085 $GETSTRIPE -v $testfile2 > $tmp_file
4086 local stripe_size=`grep "size" $tmp_file| awk '{print $2}'`
4087 local stripe_count=`grep "count" $tmp_file| awk '{print $2}'`
4088 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
4089 [ $stripe_count -eq 2 ] || error "stripe count $stripe_count != 2"
4091 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
4094 # b10930: get/set/list lustre.lov xattr
4095 echo "get/set/list lustre.lov xattr ..."
4096 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
4098 chown $RUNAS_ID $DIR/$tdir
4099 local testfile=$DIR/$tdir/$tfile
4100 $RUNAS $SETSTRIPE -s 65536 -i 1 -c 2 $testfile||error "setstripe failed"
4101 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
4102 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
4104 local testfile2=${testfile}2
4105 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
4106 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
4108 $RUNAS $MCREATE $testfile2
4109 $RUNAS setfattr -n lustre.lov -v $value $testfile2
4110 local tmp_file=${testfile}3
4111 $RUNAS $GETSTRIPE -v $testfile2 > $tmp_file
4112 local stripe_size=`grep "size" $tmp_file| awk '{print $2}'`
4113 local stripe_count=`grep "count" $tmp_file| awk '{print $2}'`
4114 [ "$stripe_size" -eq 65536 ] || error "stripe size $stripe_size != 65536"
4115 [ "$stripe_count" -eq 2 ] || error "stripe count $stripe_count != 2"
4117 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
4119 compare_stripe_info1() {
4120 local stripe_index_all_zero=1
4124 for count in `seq 1 $STRIPE_COUNT`
4126 for offset in `seq 0 $[$STRIPE_COUNT - 1]`
4128 local size=`expr $STRIPE_SIZE \* $num`
4129 local file=file"$num-$offset-$count"
4130 get_stripe_info client $PWD/$file "$1"
4131 if [ $stripe_size -ne $size ]; then
4132 error "$file: different stripe size $stripe_size, expected $size" && return
4134 if [ $stripe_count -ne $count ]; then
4135 error "$file: different stripe count $stripe_count, expected $count" && return
4137 if [ $stripe_index -ne 0 ]; then
4138 stripe_index_all_zero=0
4143 [ $stripe_index_all_zero -eq 1 ] && error "all files are being extracted starting from OST index 0"
4148 [ -n "$(which tar 2>/dev/null)" ] && strings $(which tar) | grep -q lustre && echo tar
4152 # b10930: tar test for trusted.lov xattr
4153 TAR=$(find_lustre_tar)
4154 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
4155 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
4158 $TAR xf $TMP/f102.tar -C $DIR/d102d --xattrs
4160 compare_stripe_info1
4162 run_test 102d "tar restore stripe info from tarfile,not keep osts ==========="
4165 # b10930: tar test for trusted.lov xattr
4166 TAR=$(find_lustre_tar)
4167 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
4168 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
4172 $TAR cf - --xattrs $tdir | $TAR xf - --xattrs -C $DIR/d102f
4174 compare_stripe_info1
4176 run_test 102f "tar copy files, not keep osts ==========="
4178 test_102h() { # bug 15777
4179 [ -z $(lctl get_param -n mdc.*.connect_flags | grep xattr) ] &&
4180 skip "must have user_xattr" && return
4181 [ -z "$(which setfattr 2>/dev/null)" ] &&
4182 skip_env "could not find setfattr" && return
4187 VALUE=datadatadatadatadatadatadatadata
4188 while [ $(echo $VALUE | wc -c) -lt $XSIZE ]; do
4189 VALUE="$VALUE$VALUE"
4191 log "save $XBIG on $DIR/$tfile"
4192 setfattr -n $XBIG -v "$VALUE" $DIR/$tfile ||
4193 error "saving $XBIG on $DIR/$tfile failed"
4194 ORIG=$(getfattr -n $XBIG $DIR/$tfile 2> /dev/null | grep $XBIG)
4195 OSIZE=$(echo $ORIG | wc -c)
4196 [ $OSIZE -lt $XSIZE ] && error "set $XBIG too small ($OSIZE < $XSIZE)"
4199 log "save $XSML on $DIR/$tfile"
4200 setfattr -n $XSML -v val $DIR/$tfile ||
4201 error "saving $XSML on $DIR/$tfile failed"
4202 NEW=$(getfattr -n $XBIG $DIR/$tfile 2> /dev/null | grep $XBIG)
4203 if [ "$NEW" != "$ORIG" ]; then
4206 error "$XBIG different after saving $XSML"
4209 log "grow $XSML on $DIR/$tfile"
4210 setfattr -n $XSML -v "$VALUE" $DIR/$tfile ||
4211 error "growing $XSML on $DIR/$tfile failed"
4212 NEW=$(getfattr -n $XBIG $DIR/$tfile 2> /dev/null | grep $XBIG)
4213 if [ "$NEW" != "$ORIG" ]; then
4216 error "$XBIG different after growing $XSML"
4218 log "$XBIG still valid after growing $XSML"
4220 run_test 102h "grow xattr from inside inode to external block"
4222 test_102i() { # bug 17038
4224 ln -s $DIR/$tfile $DIR/${tfile}link
4225 getfattr -n trusted.lov $DIR/$tfile || error "lgetxattr on $DIR/$tfile failed"
4226 getfattr -h -n trusted.lov $DIR/${tfile}link 2>&1 | grep -i "no such attr" || error "error for lgetxattr on $DIR/${tfile}link is not ENODATA"
4227 rm -f $DIR/$tfile $DIR/${tfile}link
4229 run_test 102i "lgetxattr test on symbolic link ============"
4232 TAR=$(find_lustre_tar)
4233 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
4234 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
4235 setup_test102 "$RUNAS"
4237 chown $RUNAS_ID $DIR/d102j
4238 $RUNAS $TAR xf $TMP/f102.tar -C $DIR/d102j --xattrs
4240 compare_stripe_info1 "$RUNAS"
4242 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
4248 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
4253 [ "$UID" != 0 ] && skip_env "must run as root" && return
4254 [ -z "$(lctl get_param mdc.*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
4255 [ -z "$(which setfacl 2>/dev/null)" ] && skip_env "could not find setfacl" && return
4261 echo "performing cp ..."
4262 run_acl_subtest cp || error
4263 echo "performing getfacl-noacl..."
4264 run_acl_subtest getfacl-noacl > /dev/null || error "getfacl-noacl test failed"
4265 echo "performing misc..."
4266 run_acl_subtest misc > /dev/null || error "misc test failed"
4267 # XXX add back permission test when we support supplementary groups.
4268 # echo "performing permissions..."
4269 # run_acl_subtest permissions || error
4270 echo "performing setfacl..."
4271 run_acl_subtest setfacl > /dev/null || error "setfacl test failed"
4273 # inheritance test got from HP
4274 echo "performing inheritance..."
4275 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
4276 chmod +x make-tree || error "chmod +x failed"
4277 run_acl_subtest inheritance > /dev/null || error "inheritance test failed"
4283 run_test 103 "acl test ========================================="
4287 lfs df || error "lfs df failed"
4288 lfs df -ih || error "lfs df -ih failed"
4289 lfs df -h $DIR || error "lfs df -h $DIR failed"
4290 lfs df -i $DIR || error "lfs df -i $DIR failed"
4291 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
4292 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
4294 OSC=`lctl get_param -n devices | awk '/-osc-|OSC.*MNT/ {print $4}' | head -n 1`
4295 lctl --device %$OSC deactivate
4296 lfs df || error "lfs df with deactivated OSC failed"
4297 lctl --device %$OSC recover
4298 lfs df || error "lfs df with reactivated OSC failed"
4300 run_test 104 "lfs df [-ih] [path] test ========================="
4303 # doesn't work on 2.4 kernels
4305 if [ -n "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ];
4307 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
4309 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
4312 run_test 105a "flock when mounted without -o flock test ========"
4316 if [ -n "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ];
4318 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
4320 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
4323 run_test 105b "fcntl when mounted without -o flock test ========"
4327 if [ -n "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ];
4329 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
4331 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
4334 run_test 105c "lockf when mounted without -o flock test ========"
4336 test_105d() { # bug 15924
4338 [ -z "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ] && \
4339 skip "mount w/o flock enabled" && return
4340 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
4341 $LCTL set_param fail_loc=0x80000315
4342 flocks_test 2 $DIR/$tdir
4344 run_test 105d "flock race (should not freeze) ========"
4346 test_106() { #bug 10921
4348 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
4349 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
4351 run_test 106 "attempt exec of dir followed by chown of that dir"
4360 local save_pattern=$(sysctl -n kernel.core_pattern)
4361 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
4362 sysctl -w kernel.core_pattern=$file
4363 sysctl -w kernel.core_uses_pid=0
4371 kill -s 11 $SLEEPPID
4373 if [ -e $file ]; then
4374 size=`stat -c%s $file`
4375 [ $size -eq 0 ] && error "Zero length core file $file"
4377 error "Fail to create core file $file"
4380 sysctl -w kernel.core_pattern=$save_pattern
4381 sysctl -w kernel.core_uses_pid=$save_uses_pid
4384 run_test 107 "Coredump on SIG"
4387 OSTIO_pre=$(ps -e|grep ll_ost_io|awk '{print $4}'|sort -n|tail -1|\
4389 [ -z "$OSTIO_pre" ] && skip "no OSS threads" && \
4391 echo "Starting with $OSTIO_pre threads"
4394 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
4395 [ $NUMFREE -lt $NUMTEST ] && NUMTEST=$(($NUMFREE - 1000))
4396 echo "$NUMTEST creates/unlinks"
4398 createmany -o $DIR/$tdir/$tfile $NUMTEST
4399 unlinkmany $DIR/$tdir/$tfile $NUMTEST
4401 OSTIO_post=$(ps -e|grep ll_ost_io|awk '{print $4}'|sort -n|tail -1|\
4404 # don't return an error
4405 [ $OSTIO_post -eq $OSTIO_pre ] && echo \
4406 "WARNING: No new ll_ost_io threads were created ($OSTIO_pre)" &&\
4407 echo "This may be fine, depending on what ran before this test" &&\
4408 echo "and how fast this system is." && return
4410 echo "Started with $OSTIO_pre threads, ended with $OSTIO_post"
4412 run_test 115 "verify dynamic thread creation===================="
4415 wait_delete_completed
4416 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC][-_]*.kbytesavail))
4417 echo OST kbytes available: ${AVAIL[@]}
4418 MAXI=0; MAXV=${AVAIL[0]}
4419 MINI=0; MINV=${AVAIL[0]}
4420 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
4421 #echo OST $i: ${AVAIL[i]}kb
4422 if [ ${AVAIL[i]} -gt $MAXV ]; then
4423 MAXV=${AVAIL[i]}; MAXI=$i
4425 if [ ${AVAIL[i]} -lt $MINV ]; then
4426 MINV=${AVAIL[i]}; MINI=$i
4429 echo Min free space: OST $MINI: $MINV
4430 echo Max free space: OST $MAXI: $MAXV
4434 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
4436 echo -n "Free space priority "
4437 lctl get_param -n lov.*.qos_prio_free
4440 [ $MINV -gt 960000 ] && skip "too much free space in OST$MINI" &&\
4443 # generate uneven OSTs
4444 mkdir -p $DIR/$tdir/OST${MINI}
4447 echo "Filling 25% remaining space in OST${MINI} with ${FILL}Kb"
4448 $SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI}||error "setstripe failed"
4450 while [ $FILL -gt 0 ]; do
4451 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i bs=2M count=1 2>/dev/null
4452 FILL=$(($FILL - 2048))
4461 DIFF=$(($MAXV - $MINV))
4462 DIFF2=$(($DIFF * 100 / $MINV))
4463 echo -n "diff=${DIFF}=${DIFF2}% must be > 20% for QOS mode..."
4464 if [ $DIFF2 -gt 20 ]; then
4467 echo "failed - QOS mode won't be used"
4468 error_ignore "QOS imbalance criteria not met"
4472 MINI1=$MINI; MINV1=$MINV
4473 MAXI1=$MAXI; MAXV1=$MAXV
4475 # now fill using QOS
4476 echo writing a bunch of files to QOS-assigned OSTs
4477 $SETSTRIPE $DIR/$tdir -c 1
4479 while [ $FILL -gt 0 ]; do
4480 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1024 count=200 2>/dev/null
4481 FILL=$(($FILL - 200))
4485 echo "wrote $i 200k files"
4489 echo "Note: free space may not be updated, so measurements might be off"
4491 DIFF2=$(($MAXV - $MINV))
4492 echo "free space delta: orig $DIFF final $DIFF2"
4493 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
4494 DIFF=$(($MINV1 - ${AVAIL[$MINI1]}))
4495 echo "Wrote $DIFF to smaller OST $MINI1"
4496 DIFF2=$(($MAXV1 - ${AVAIL[$MAXI1]}))
4497 echo "Wrote $DIFF2 to larger OST $MAXI1"
4498 [ $DIFF -gt 0 ] && echo "Wrote $(($DIFF2 * 100 / $DIFF - 100))% more data to larger OST $MAXI1"
4500 # Figure out which files were written where
4501 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd | awk '/'$MINI1': / {print $2; exit}')
4503 MINC=$($GETSTRIPE --obd $UUID $DIR/$tdir | wc -l)
4504 echo "$MINC files created on smaller OST $MINI1"
4505 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd | (awk '/'$MAXI1': / {print $2; exit}'))
4506 MAXC=$($GETSTRIPE --obd $UUID $DIR/$tdir | wc -l)
4507 echo "$MAXC files created on larger OST $MAXI1"
4508 [ $MINC -gt 0 ] && echo "Wrote $(($MAXC * 100 / $MINC - 100))% more files to larger OST $MAXI1"
4509 [ $MAXC -gt $MINC ] || error_ignore "stripe QOS didn't balance free space"
4511 rm -rf $DIR/$tdir/OST${MINI}
4513 run_test 116 "stripe QOS: free space balance ==================="
4515 test_117() # bug 10891
4517 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
4518 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
4519 lctl set_param fail_loc=0x21e
4520 > $DIR/$tfile || error "truncate failed"
4521 lctl set_param fail_loc=0
4522 echo "Truncate succeeded."
4524 run_test 117 "verify fsfilt_extend ============================="
4526 export OLD_RESENDCOUNT=""
4527 set_resend_count () {
4528 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
4529 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -1)
4530 lctl set_param -n $PROC_RESENDCOUNT $1
4531 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
4534 [ "$SLOW" = "no" ] && set_resend_count 4 # for reduce test_118* time (bug 14842)
4536 # Reset async IO behavior after error case
4538 FILE=$DIR/reset_async
4540 # Ensure all OSCs are cleared
4541 $SETSTRIPE -c -1 $FILE
4542 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
4547 test_118a() #bug 11710
4551 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
4552 DIRTY=$(lctl get_param -n "llite.*.dump_page_cache" | grep -c dirty)
4553 WRITEBACK=$(lctl get_param "llite.*.dump_page_cache" | grep -c writeback)
4555 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
4556 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
4560 run_test 118a "verify O_SYNC works =========="
4564 remote_ost_nodsh && skip "remote OST with nodsh" && return
4568 #define OBD_FAIL_OST_ENOENT 0x217
4569 set_nodes_failloc "$(osts_nodes)" 0x217
4570 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
4572 set_nodes_failloc "$(osts_nodes)" 0
4573 DIRTY=$(lctl get_param llite.*.dump_page_cache | grep -c dirty)
4574 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
4576 if [[ $RC -eq 0 ]]; then
4577 error "Must return error due to dropped pages, rc=$RC"
4581 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
4582 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
4586 echo "Dirty pages not leaked on ENOENT"
4588 # Due to the above error the OSC will issue all RPCs syncronously
4589 # until a subsequent RPC completes successfully without error.
4590 multiop $DIR/$tfile Ow4096yc
4595 run_test 118b "Reclaim dirty pages on fatal error =========="
4599 remote_ost_nodsh && skip "remote OST with nodsh" && return
4603 #define OBD_FAIL_OST_EROFS 0x216
4604 set_nodes_failloc "$(osts_nodes)" 0x216
4606 # multiop should block due to fsync until pages are written
4607 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
4611 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
4612 error "Multiop failed to block on fsync, pid=$MULTIPID"
4615 WRITEBACK=$(lctl get_param -n llite/*/dump_page_cache | grep -c writeback)
4616 if [[ $WRITEBACK -eq 0 ]]; then
4617 error "No page in writeback, writeback=$WRITEBACK"
4620 set_nodes_failloc "$(osts_nodes)" 0
4623 if [[ $RC -ne 0 ]]; then
4624 error "Multiop fsync failed, rc=$RC"
4627 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
4628 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
4629 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
4630 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
4634 echo "Dirty pages flushed via fsync on EROFS"
4637 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
4641 remote_ost_nodsh && skip "remote OST with nodsh" && return
4645 #define OBD_FAIL_OST_BRW_PAUSE_BULK
4646 set_nodes_failloc "$(osts_nodes)" 0x214
4647 # multiop should block due to fsync until pages are written
4648 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
4652 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
4653 error "Multiop failed to block on fsync, pid=$MULTIPID"
4656 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
4657 if [[ $WRITEBACK -eq 0 ]]; then
4658 error "No page in writeback, writeback=$WRITEBACK"
4661 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
4662 set_nodes_failloc "$(osts_nodes)" 0
4664 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
4665 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
4666 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
4667 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
4671 echo "Dirty pages gaurenteed flushed via fsync"
4674 run_test 118d "Fsync validation inject a delay of the bulk =========="
4679 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
4680 lctl set_param fail_loc=0x8000040a
4682 # Should simulate EINVAL error which is fatal
4683 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
4685 if [[ $RC -eq 0 ]]; then
4686 error "Must return error due to dropped pages, rc=$RC"
4689 lctl set_param fail_loc=0x0
4691 LOCKED=$(lctl get_param -n "llite.*.dump_page_cache" | grep -c locked)
4692 DIRTY=$(lctl get_param -n "llite.*.dump_page_cache" | grep -c dirty)
4693 WRITEBACK=$(lctl get_param -n "llite.*.dump_page_cache" | grep -c writeback)
4694 if [[ $LOCKED -ne 0 ]]; then
4695 error "Locked pages remain in cache, locked=$LOCKED"
4698 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
4699 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
4703 echo "No pages locked after fsync"
4708 run_test 118f "Simulate unrecoverable OSC side error =========="
4713 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
4714 lctl set_param fail_loc=0x406
4716 # simulate local -ENOMEM
4717 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
4720 lctl set_param fail_loc=0
4721 if [[ $RC -eq 0 ]]; then
4722 error "Must return error due to dropped pages, rc=$RC"
4725 LOCKED=$(lctl get_param -n "llite.*.dump_page_cache" | grep -c locked)
4726 DIRTY=$(lctl get_param -n "llite.*.dump_page_cache" | grep -c dirty)
4727 WRITEBACK=$(lctl get_param -n "llite.*.dump_page_cache" | grep -c writeback)
4728 if [[ $LOCKED -ne 0 ]]; then
4729 error "Locked pages remain in cache, locked=$LOCKED"
4732 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
4733 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
4737 echo "No pages locked after fsync"
4742 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
4745 remote_ost_nodsh && skip "remote OST with nodsh" && return
4749 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
4750 set_nodes_failloc "$(osts_nodes)" 0x20e
4751 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
4752 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
4755 set_nodes_failloc "$(osts_nodes)" 0
4756 if [[ $RC -eq 0 ]]; then
4757 error "Must return error due to dropped pages, rc=$RC"
4760 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
4761 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
4762 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writebac)
4763 if [[ $LOCKED -ne 0 ]]; then
4764 error "Locked pages remain in cache, locked=$LOCKED"
4767 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
4768 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
4772 echo "No pages locked after fsync"
4776 run_test 118h "Verify timeout in handling recoverables errors =========="
4779 remote_ost_nodsh && skip "remote OST with nodsh" && return
4783 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
4784 set_nodes_failloc "$(osts_nodes)" 0x20e
4786 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
4787 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
4790 set_nodes_failloc "$(osts_nodes)" 0
4794 if [[ $RC -ne 0 ]]; then
4795 error "got error, but should be not, rc=$RC"
4798 LOCKED=$(lctl get_param -n "llite.*.dump_page_cache" | grep -c locked)
4799 DIRTY=$(lctl get_param -n "llite.*.dump_page_cache" | grep -c dirty)
4800 WRITEBACK=$(lctl get_param -n "llite.*.dump_page_cache" | grep -c writeback)
4801 if [[ $LOCKED -ne 0 ]]; then
4802 error "Locked pages remain in cache, locked=$LOCKED"
4805 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
4806 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
4810 echo "No pages locked after fsync"
4814 run_test 118i "Fix error before timeout in recoverable error =========="
4817 remote_ost_nodsh && skip "remote OST with nodsh" && return
4821 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
4822 set_nodes_failloc "$(osts_nodes)" 0x220
4824 # return -EIO from OST
4825 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
4827 set_nodes_failloc "$(osts_nodes)" 0x0
4828 if [[ $RC -eq 0 ]]; then
4829 error "Must return error due to dropped pages, rc=$RC"
4832 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
4833 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
4834 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
4835 if [[ $LOCKED -ne 0 ]]; then
4836 error "Locked pages remain in cache, locked=$LOCKED"
4839 # in recoverable error on OST we want resend and stay until it finished
4840 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
4841 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
4845 echo "No pages locked after fsync"
4849 run_test 118j "Simulate unrecoverable OST side error =========="
4853 remote_ost_nodsh && skip "remote OSTs with nodsh" && return
4855 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
4856 set_nodes_failloc "$(osts_nodes)" 0x20e
4859 for ((i=0;i<10;i++)); do
4860 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
4861 error "dd to $DIR/$tdir/$tfile-$i failed" )&
4868 set_nodes_failloc "$(osts_nodes)" 0
4870 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
4872 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
4874 test_119a() # bug 11737
4876 BSIZE=$((512 * 1024))
4877 directio write $DIR/$tfile 0 1 $BSIZE
4878 # We ask to read two blocks, which is more than a file size.
4879 # directio will indicate an error when requested and actual
4880 # sizes aren't equeal (a normal situation in this case) and
4881 # print actual read amount.
4882 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
4883 if [ "$NOB" != "$BSIZE" ]; then
4884 error "read $NOB bytes instead of $BSIZE"
4888 run_test 119a "Short directIO read must return actual read amount"
4890 test_119b() # bug 11737
4892 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
4894 $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
4895 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
4897 multiop $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) || \
4898 error "direct read failed"
4901 run_test 119b "Sparse directIO read must return actual read amount"
4903 test_119c() # bug 13099
4906 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
4907 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
4910 run_test 119c "Testing for direct read hitting hole"
4912 test_119d() # bug 15950
4914 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
4915 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
4917 $SETSTRIPE $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
4918 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
4919 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
4920 lctl set_param fail_loc=0x40d
4921 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
4924 cat $DIR/$tfile > /dev/null &
4925 lctl set_param fail_loc=0
4928 log "the DIO writes have completed, now wait for the reads (should not block very long)"
4930 [ -n "`ps h -p $pid_reads -o comm`" ] && \
4931 error "the read rpcs have not completed in 2s"
4933 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
4935 run_test 119d "The DIO path should try to send a new rpc once one is completed"
4939 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
4940 skip "no early lock cancel on server" && return 0
4941 lru_resize_disable mdc
4942 lru_resize_disable osc
4943 cancel_lru_locks mdc
4944 stat $DIR/$tdir > /dev/null
4945 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
4946 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
4948 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
4949 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
4950 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
4951 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
4952 lru_resize_enable mdc
4953 lru_resize_enable osc
4955 run_test 120a "Early Lock Cancel: mkdir test ==================="
4959 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
4960 skip "no early lock cancel on server" && return 0
4961 lru_resize_disable mdc
4962 lru_resize_disable osc
4963 cancel_lru_locks mdc
4964 stat $DIR/$tdir > /dev/null
4965 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
4966 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
4968 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
4969 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
4970 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
4971 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
4972 lru_resize_enable mdc
4973 lru_resize_enable osc
4975 run_test 120b "Early Lock Cancel: create test =================="
4979 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
4980 skip "no early lock cancel on server" && return 0
4981 lru_resize_disable mdc
4982 lru_resize_disable osc
4983 mkdir -p $DIR/$tdir/d1 $DIR/$tdir/d2
4984 touch $DIR/$tdir/d1/f1
4985 cancel_lru_locks mdc
4986 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
4987 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
4988 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
4989 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
4990 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
4991 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
4992 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
4993 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
4994 lru_resize_enable mdc
4995 lru_resize_enable osc
4997 run_test 120c "Early Lock Cancel: link test ===================="
5001 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
5002 skip "no early lock cancel on server" && return 0
5003 lru_resize_disable mdc
5004 lru_resize_disable osc
5006 cancel_lru_locks mdc
5007 stat $DIR/$tdir > /dev/null
5008 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
5009 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
5010 chmod a+x $DIR/$tdir
5011 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
5012 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
5013 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
5014 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
5015 lru_resize_enable mdc
5016 lru_resize_enable osc
5018 run_test 120d "Early Lock Cancel: setattr test ================="
5022 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
5023 skip "no early lock cancel on server" && return 0
5024 lru_resize_disable mdc
5025 lru_resize_disable osc
5026 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
5027 cancel_lru_locks mdc
5028 cancel_lru_locks osc
5029 dd if=$DIR/$tdir/f1 of=/dev/null
5030 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
5031 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
5032 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
5033 unlink $DIR/$tdir/f1
5034 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
5035 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
5036 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
5037 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
5038 lru_resize_enable mdc
5039 lru_resize_enable osc
5041 run_test 120e "Early Lock Cancel: unlink test =================="
5044 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
5045 skip "no early lock cancel on server" && return 0
5047 lru_resize_disable mdc
5048 lru_resize_disable osc
5049 mkdir -p $DIR/$tdir/d1 $DIR/$tdir/d2
5050 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
5051 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
5052 cancel_lru_locks mdc
5053 cancel_lru_locks osc
5054 dd if=$DIR/$tdir/d1/f1 of=/dev/null
5055 dd if=$DIR/$tdir/d2/f2 of=/dev/null
5056 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
5057 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
5058 blk1=`lctl get_param -n ldlm/services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
5059 mv $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
5060 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
5061 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
5062 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
5063 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
5064 lru_resize_enable mdc
5065 lru_resize_enable osc
5067 run_test 120f "Early Lock Cancel: rename test =================="
5070 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
5071 skip "no early lock cancel on server" && return 0
5072 lru_resize_disable mdc
5073 lru_resize_disable osc
5075 echo create $count files
5077 cancel_lru_locks mdc
5078 cancel_lru_locks osc
5081 can0=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
5082 blk0=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
5083 createmany -o $DIR/$tdir/f $count
5085 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
5086 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
5088 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
5089 echo rm $count files
5092 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
5093 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
5095 echo total: $count removes in $((t2-t1))
5096 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
5098 # wait for commitment of removal
5099 lru_resize_enable mdc
5100 lru_resize_enable osc
5102 run_test 120g "Early Lock Cancel: performance test ============="
5104 test_121() { #bug 10589
5105 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
5106 lctl set_param fail_loc=0x310
5107 cancel_lru_locks osc > /dev/null
5108 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
5109 lctl set_param fail_loc=0
5110 [ "$reads" -eq "$writes" ] || error "read" $reads "blocks, must be" $writes
5112 run_test 121 "read cancel race ================================="
5114 test_122() { #bug 11544
5115 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
5116 lctl set_param fail_loc=0x508
5117 dd if=/dev/zero of=$DIR/$tfile count=1
5119 lctl set_param fail_loc=0
5121 run_test 122 "fail client bulk callback (shouldn't LBUG) ======="
5123 test_123a() { # was test 123, statahead(bug 11401)
5125 if [ -z "$(grep "processor.*: 1" /proc/cpuinfo)" ]; then
5126 log "testing on UP system. Performance may be not as good as expected."
5132 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
5133 [ $NUMFREE -gt 100000 ] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
5135 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
5136 createmany -o $DIR/$tdir/$tfile $j $((i - j))
5138 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
5139 lctl set_param -n llite.*.statahead_max 0
5140 lctl get_param llite.*.statahead_max
5141 cancel_lru_locks mdc
5142 cancel_lru_locks osc
5144 time ls -l $DIR/$tdir | wc -l
5146 delta=$((etime - stime))
5147 log "ls $i files without statahead: $delta sec"
5148 lctl set_param llite.*.statahead_max=$max
5150 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
5151 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
5152 cancel_lru_locks mdc
5153 cancel_lru_locks osc
5155 time ls -l $DIR/$tdir | wc -l
5157 delta_sa=$((etime - stime))
5158 log "ls $i files with statahead: $delta_sa sec"
5159 lctl get_param -n llite.*.statahead_stats
5160 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
5162 if [ $swrong -lt $ewrong ]; then
5163 log "statahead was stopped, maybe too many locks held!"
5166 [ $delta -eq 0 -o $delta_sa -eq 0 ] && continue
5168 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
5169 if [ $SLOWOK -eq 0 ]; then
5170 error "ls $i files is slower with statahead!"
5173 lctl set_param debug=-1
5174 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
5175 lctl set_param -n llite.*.statahead_max 0
5176 lctl get_param llite.*.statahead_max
5177 cancel_lru_locks mdc
5178 cancel_lru_locks osc
5181 time ls -l $DIR/$tdir | wc -l
5183 error "ls $i files (again) without statahead: $((etime - stime)) sec"
5185 lctl set_param debug=-1
5186 lctl set_param llite.*.statahead_max=$max
5187 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
5188 cancel_lru_locks mdc
5189 cancel_lru_locks osc
5192 time ls -l $DIR/$tdir | wc -l
5194 error "ls $i files (again) with statahead: $((etime - stime)) sec"
5195 lctl get_param -n llite.*.statahead_stats
5199 log "ls $i files is slower with statahead!"
5204 [ $delta -gt 20 ] && break
5205 [ $delta -gt 8 ] && MULT=$((50 / delta))
5206 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
5214 delta=$((etime - stime))
5215 log "rm -r $DIR/$tdir/: $delta seconds"
5217 lctl get_param -n llite.*.statahead_stats
5219 run_test 123a "verify statahead work"
5221 test_123b () { # statahead(bug 15027)
5223 createmany -o $DIR/$tdir/$tfile-%d 1000
5225 cancel_lru_locks mdc
5226 cancel_lru_locks osc
5228 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
5229 lctl set_param fail_loc=0x80000803
5230 ls -lR $DIR/$tdir > /dev/null
5232 lctl set_param fail_loc=0x0
5233 lctl get_param -n llite.*.statahead_stats
5238 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
5241 [ -z "`lctl get_param -n mdc.*.connect_flags | grep lru_resize`" ] && \
5242 skip "no lru resize on server" && return 0
5244 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
5246 log "create $NR files at $DIR/$tdir"
5247 createmany -o $DIR/$tdir/f $NR ||
5248 error "failed to create $NR files in $DIR/$tdir"
5250 cancel_lru_locks mdc
5251 ls -l $DIR/$tdir > /dev/null
5255 for VALUE in `lctl get_param ldlm.namespaces.*mdc-*.lru_size`; do
5256 local PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
5257 LRU_SIZE=$(lctl get_param -n $PARAM)
5258 if [ $LRU_SIZE -gt $(default_lru_size) ]; then
5259 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
5260 log "NS=$(basename $NSDIR)"
5265 if [ -z "$NSDIR" -o $LRU_SIZE -lt $(default_lru_size) ]; then
5266 skip "Not enough cached locks created!"
5273 # We know that lru resize allows one client to hold $LIMIT locks
5274 # for 10h. After that locks begin to be killed by client.
5276 local LIMIT=`lctl get_param -n $NSDIR.pool.limit`
5278 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
5279 # killing locks. Some time was spent for creating locks. This means
5280 # that up to the moment of sleep finish we must have killed some of
5281 # them (10-100 locks). This depends on how fast ther were created.
5282 # Many of them were touched in almost the same moment and thus will
5283 # be killed in groups.
5284 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
5286 # Use $LRU_SIZE_B here to take into account real number of locks
5287 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
5288 local LRU_SIZE_B=$LRU_SIZE
5290 local OLD_LVF=`lctl get_param -n $NSDIR.pool.lock_volume_factor`
5291 lctl set_param -n $NSDIR.pool.lock_volume_factor $LVF
5293 # Let's make sure that we really have some margin. Client checks
5294 # cached locks every 10 sec.
5296 log "Sleep ${SLEEP} sec"
5298 while ((SEC<$SLEEP)); do
5302 LRU_SIZE=`lctl get_param -n $NSDIR/lru_size`
5306 lctl set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
5307 local LRU_SIZE_A=`lctl get_param -n $NSDIR/lru_size`
5309 [ $LRU_SIZE_B -gt $LRU_SIZE_A ] || {
5310 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
5311 unlinkmany $DIR/$tdir/f $NR
5315 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
5316 log "unlink $NR files at $DIR/$tdir"
5317 unlinkmany $DIR/$tdir/f $NR
5319 run_test 124a "lru resize ======================================="
5322 [ -z "`lctl get_param -n mdc.*.connect_flags | grep lru_resize`" ] && \
5323 skip "no lru resize on server" && return 0
5325 # even for cmd no matter what metadata namespace to use for getting
5326 # the limit, we use appropriate.
5327 LIMIT=`lctl get_param -n ldlm.namespaces.*mdc*.pool.limit`
5329 NR=$(($(default_lru_size)*20))
5330 if [ $NR -gt $LIMIT ]; then
5333 lru_resize_disable mdc
5334 mkdir -p $DIR/$tdir/disable_lru_resize ||
5335 error "failed to create $DIR/$tdir/disable_lru_resize"
5337 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
5338 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
5339 cancel_lru_locks mdc
5342 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
5345 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
5348 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
5352 nolruresize_delta=$((etime-stime))
5353 log "ls -la time: $nolruresize_delta seconds"
5354 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
5355 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
5357 lru_resize_enable mdc
5358 mkdir -p $DIR/$tdir/enable_lru_resize ||
5359 error "failed to create $DIR/$tdir/enable_lru_resize"
5361 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
5362 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
5363 cancel_lru_locks mdc
5366 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
5369 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
5372 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
5376 lruresize_delta=$((etime-stime))
5377 log "ls -la time: $lruresize_delta seconds"
5378 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
5380 if [ $lruresize_delta -gt $nolruresize_delta ]; then
5381 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
5382 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
5383 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
5385 log "lru resize performs the same with no lru resize"
5387 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
5389 run_test 124b "lru resize (performance test) ======================="
5391 test_125() { # 13358
5392 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
5393 mkdir -p $DIR/d125 || error "mkdir failed"
5394 $SETSTRIPE $DIR/d125 -s 65536 -c -1 || error "setstripe failed"
5395 setfacl -R -m u:bin:rwx $DIR/d125 || error "setfacl $DIR/d125 failes"
5396 ls -ld $DIR/d125 || error "cannot access $DIR/d125"
5398 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
5400 test_126() { # bug 12829/13455
5401 [ "$UID" != 0 ] && skip_env "skipping $TESTNAME (must run as root)" && return
5402 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
5403 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
5405 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
5407 run_test 126 "check that the fsgid provided by the client is taken into account"
5409 test_127() { # bug 15521
5410 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
5411 $LCTL set_param osc.*.stats=0
5412 FSIZE=$((2048 * 1024))
5413 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
5414 cancel_lru_locks osc
5415 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
5417 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
5418 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
5419 echo "got $COUNT $NAME"
5420 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
5421 eval $NAME=$COUNT || error "Wrong proc format"
5424 read_bytes|write_bytes)
5425 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
5426 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
5427 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
5428 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
5429 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
5430 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
5431 error "sumsquare is too small: $SUMSQ"
5432 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
5433 error "sumsquare is too big: $SUMSQ"
5437 done < $DIR/${tfile}.tmp
5439 #check that we actually got some stats
5440 [ "$read_bytes" ] || error "Missing read_bytes stats"
5441 [ "$write_bytes" ] || error "Missing write_bytes stats"
5442 [ "$read_bytes" != 0 ] || error "no read done"
5443 [ "$write_bytes" != 0 ] || error "no write done"
5445 run_test 127 "verify the client stats are sane"
5447 test_128() { # bug 15212
5449 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
5454 result=$(grep error $TMP/$tfile.log)
5456 [ -z "$result" ] || error "consecutive find with interactive lfs failed"
5458 run_test 128 "interactive lfs for 2 consecutive finds"
5461 [ "$FSTYPE" != "ldiskfs" ] && skip "not needed for FSTYPE=$FSTYPE" && return 0
5462 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5464 local MNTDEV=$(get_mds_mntdev_proc_path)
5465 DEV=$(basename $(do_facet mds lctl get_param -n $MNTDEV))
5466 [ -z "$DEV" ] && error "can't access mds mntdev"
5468 LDPROC=/proc/fs/ldiskfs/$DEV/max_dir_size
5471 do_facet mds "echo $MAX > $LDPROC"
5477 while [ ! $I -gt $MAX ]; do
5478 multiop $DIR/$tdir/$J Oc
5480 if [ $rc -eq $EFBIG ]; then
5481 do_facet mds "echo 0 >$LDPROC"
5482 echo "return code $rc received as expected"
5484 elif [ $rc -ne 0 ]; then
5485 do_facet mds "echo 0 >$LDPROC"
5486 error_exit "error $rc instead of expected $EFBIG"
5489 I=$(stat -c%s "$DIR/$tdir")
5492 error "exceeded dir size limit: $I bytes"
5493 do_facet mds "echo 0 >$LDPROC"
5495 run_test 129 "test directory size limit ========================"
5504 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
5505 [ -n "$filefrag_op" ] && skip "filefrag has no FIEMAP support" && return
5507 trap cleanup_130 EXIT RETURN
5509 local fm_file=$DIR/$tfile
5510 lfs setstripe -s 65536 -c 1 $fm_file ||
5511 error "setstripe failed on $fm_file"
5512 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
5513 error "dd failed for $fm_file"
5515 filefrag -ves $fm_file || error "filefrag $fm_file failed"
5516 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
5518 lun=`$GETSTRIPE $fm_file | grep -A 10 obdidx | awk '{print $1}' | grep -v "obdidx"`
5520 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
5523 for line in $filefrag_op
5525 frag_lun=`echo $line | cut -d: -f5`
5526 ext_len=`echo $line | cut -d: -f4`
5527 if (( $frag_lun != $lun )); then
5529 error "FIEMAP on 1-stripe file($fm_file) failed"
5532 (( tot_len += ext_len ))
5535 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
5537 error "FIEMAP on 1-stripe file($fm_file) failed;"
5543 echo "FIEMAP on single striped file succeeded"
5545 run_test 130a "FIEMAP (1-stripe file)"
5548 [ "$OSTCOUNT" -lt "2" ] && skip_env "FIEMAP on 2-stripe file test" && return
5550 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
5551 [ -n "$filefrag_op" ] && skip "filefrag has no FIEMAP support" && return
5553 trap cleanup_130 EXIT RETURN
5555 local fm_file=$DIR/$tfile
5556 lfs setstripe -s 65536 -c 2 $fm_file ||
5557 error "setstripe failed on $fm_file"
5558 dd if=/dev/zero of=$fm_file bs=1M count=2 ||
5559 error "dd failed on $fm_file"
5561 filefrag -ves $fm_file || error "filefrag $fm_file failed"
5562 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
5564 last_lun=`echo $filefrag_op | cut -d: -f5`
5569 for line in $filefrag_op; do
5570 frag_lun=`echo $line | cut -d: -f5`
5571 ext_len=`echo $line | cut -d: -f4`
5572 if (( $frag_lun != $last_lun )); then
5573 if (( tot_len != 1024 )); then
5575 error "FIEMAP $fm_file: len $tot_len for OST $last_lun instead of 256"
5582 (( tot_len += ext_len ))
5585 if (( num_luns != 2 || tot_len != 1024 )); then
5587 error "FIEMAP $fm_file: wrong number of LUNs or wrong len for OST $last_lun"
5593 echo "FIEMAP on 2-stripe file succeeded"
5595 run_test 130b "FIEMAP (2-stripe file)"
5598 [ "$OSTCOUNT" -lt "2" ] && skip_env "FIEMAP on 2-stripe hole test" && return
5600 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
5601 [ -n "$filefrag_op" ] && skip "filefrag has no FIEMAP support" && return
5603 trap cleanup_130 EXIT RETURN
5605 local fm_file=$DIR/$tfile
5606 lfs setstripe -s 65536 -c 2 $fm_file ||
5607 error "setstripe failed on $fm_file"
5608 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 ||
5609 error "dd failed on $fm_file"
5611 filefrag -ves $fm_file || error "filefrag $fm_file failed"
5612 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
5614 last_lun=`echo $filefrag_op | cut -d: -f5`
5619 for line in $filefrag_op
5621 frag_lun=`echo $line | cut -d: -f5`
5622 ext_len=`echo $line | cut -d: -f4`
5623 if (( $frag_lun != $last_lun )); then
5624 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
5625 if (( logical != 512 )); then
5627 error "FIEMAP $fm_file: logical start for LUN $logical instead of 512"
5630 if (( tot_len != 512 )); then
5632 error "FIEMAP $fm_file: len $tot_len for OST $last_lun instead of 1024"
5639 (( tot_len += ext_len ))
5642 if (( num_luns != 2 || tot_len != 512 )); then
5644 error "FIEMAP $fm_file: wrong number of LUNs or wrong len for OST $last_lun"
5650 echo "FIEMAP on 2-stripe file with hole succeeded"
5652 run_test 130c "FIEMAP (2-stripe file with hole)"
5655 [ "$OSTCOUNT" -lt "3" ] && skip_env "FIEMAP on N-stripe file test" && return
5657 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
5658 [ -n "$filefrag_op" ] && skip "filefrag has no FIEMAP support" && return
5660 trap cleanup_130 EXIT RETURN
5662 local fm_file=$DIR/$tfile
5663 lfs setstripe -s 65536 -c $OSTCOUNT $fm_file ||
5664 error "setstripe failed on $fm_file"
5665 dd if=/dev/zero of=$fm_file bs=1M count=$OSTCOUNT ||
5666 error "dd failed on $fm_file"
5668 filefrag -ves $fm_file || error "filefrag $fm_file failed"
5669 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
5671 last_lun=`echo $filefrag_op | cut -d: -f5`
5676 for line in $filefrag_op
5678 frag_lun=`echo $line | cut -d: -f5`
5679 ext_len=`echo $line | cut -d: -f4`
5680 if (( $frag_lun != $last_lun )); then
5681 if (( tot_len != 1024 )); then
5683 error "FIEMAP $fm_file: len $tot_len for OST $last_lun instead of 1024"
5690 (( tot_len += ext_len ))
5693 if (( num_luns != OSTCOUNT || tot_len != 1024 )); then
5695 error "FIEMAP $fm_file: wrong number of LUNs or wrong len for OST $last_lun"
5701 echo "FIEMAP on N-stripe file succeeded"
5703 run_test 130d "FIEMAP (N-stripe file)"
5706 [ "$OSTCOUNT" -lt "2" ] && skip "continuation FIEMAP test" && return
5708 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
5709 [ -n "$filefrag_op" ] && skip "filefrag has no FIEMAP support" && return
5711 trap cleanup_130 EXIT RETURN
5713 local fm_file=$DIR/$tfile
5714 lfs setstripe -s 131072 -c 2 $fm_file ||
5715 error "setstripe failed on $fm_file"
5717 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
5718 for ((i = 0; i < $NUM_BLKS; i++)); do
5719 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
5722 filefrag -ves $fm_file || error "filefrag $fm_file failed"
5723 filefrag_op=`filefrag -ve $fm_file | grep -A 12000 "ext:" | grep -v "ext:" | grep -v "found"`
5725 last_lun=`echo $filefrag_op | cut -d: -f5`
5730 for line in $filefrag_op
5732 frag_lun=`echo $line | cut -d: -f5`
5733 ext_len=`echo $line | cut -d: -f4`
5734 if (( $frag_lun != $last_lun )); then
5735 if (( tot_len != $EXPECTED_LEN )); then
5737 error "FIEMAP $fm_file: len $tot_len for OST $last_lun instead of $EXPECTED_LEN"
5744 (( tot_len += ext_len ))
5747 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
5749 error "FIEMAP $fm_file: wrong number of LUNs or wrong len for OST $last_lun"
5755 echo "FIEMAP with continuation calls succeeded"
5757 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
5759 test_140() { #bug-17379
5760 mkdir -p $DIR/$tdir || error "Creating dir $DIR/$tdir"
5761 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
5762 cp /usr/bin/stat . || error "Copying stat to $DIR/$tdir"
5764 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
5766 while i=`expr $i + 1`; do
5767 mkdir -p $i || error "Creating dir $i"
5768 cd $i || error "Changing to $i"
5769 ln -s ../stat stat || error "Creating stat symlink"
5770 # Read the symlink until ELOOP present,
5771 # not LBUGing the system is considered success,
5772 # we didn't overrun the stack.
5773 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
5775 if [ $ret -eq 40 ]; then
5778 error "Open stat symlink"
5784 echo "The symlink depth = $i"
5785 [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 ] || error "Invalid symlink depth"
5787 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
5790 local TF="$TMP/$tfile"
5792 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
5794 cancel_lru_locks osc
5795 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
5796 remount_client $MOUNT
5797 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
5800 $TRUNCATE $DIR/$tfile 6000
5801 cancel_lru_locks osc
5802 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
5805 echo "12345" >>$DIR/$tfile
5806 cancel_lru_locks osc
5807 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
5810 echo "12345" >>$DIR/$tfile
5811 cancel_lru_locks osc
5812 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
5817 run_test 150 "truncate/append tests"
5819 function roc_hit() {
5820 local list=$(comma_list $(osts_nodes))
5822 ACCNUM=$(do_nodes $list $LCTL get_param -n obdfilter.*.stats | \
5823 awk '/'cache_hit'/ {sum+=$2} END {print sum}')
5827 function set_cache() {
5830 if [ "$2" == "off" ]; then
5833 local list=$(comma_list $(osts_nodes))
5834 do_nodes $list lctl set_param obdfilter.*.${1}_cache_enable $on
5836 cancel_lru_locks osc
5840 remote_ost_nodsh && skip "remote OST with nodsh" && return
5842 local list=$(comma_list $(osts_nodes))
5843 if ! do_nodes $list grep -q truncate_inode_pages_range /proc/kallsyms; then #b=18718
5844 skip "old RHEL4/SLES9 kernel" && return
5849 # check whether obdfilter is cache capable at all
5850 if ! do_nodes $list $LCTL get_param -n obdfilter.*.read_cache_enable > /dev/null; then
5851 echo "not cache-capable obdfilter"
5855 # make sure cache is enabled on all obdfilters
5856 do_nodes $list $LCTL set_param obdfilter.*.read_cache_enable=1
5857 do_nodes $list $LCTL set_param obdfilter.*.writethrough_cache_enable=1
5859 # pages should be in the case right after write
5860 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES || error "dd failed"
5861 local BEFORE=`roc_hit`
5862 cancel_lru_locks osc
5863 cat $DIR/$tfile >/dev/null
5864 local AFTER=`roc_hit`
5865 if let "AFTER - BEFORE != CPAGES"; then
5866 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
5869 # the following read invalidates the cache
5870 cancel_lru_locks osc
5871 do_nodes $list $LCTL set_param -n obdfilter.*.read_cache_enable 0
5872 cat $DIR/$tfile >/dev/null
5874 # now data shouldn't be found in the cache
5876 cancel_lru_locks osc
5877 cat $DIR/$tfile >/dev/null
5879 if let "AFTER - BEFORE != 0"; then
5880 error "IN CACHE: before: $BEFORE, after: $AFTER"
5883 do_nodes $list $LCTL set_param -n obdfilter.*.read_cache_enable=1
5884 do_nodes $list $LCTL set_param obdfilter.*.writethrough_cache_enable=1
5887 run_test 151 "test cache on oss and controls ==============================="
5890 local TF="$TMP/$tfile"
5892 # simulate ENOMEM during write
5893 #define OBD_FAIL_OST_NOMEM 0x226
5894 lctl set_param fail_loc=0x80000226
5895 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
5897 sync || error "sync failed"
5898 lctl set_param fail_loc=0
5900 # discard client's cache
5901 cancel_lru_locks osc
5903 # simulate ENOMEM during read
5904 lctl set_param fail_loc=0x80000226
5905 cmp $TF $DIR/$tfile || error "cmp failed"
5906 lctl set_param fail_loc=0
5910 run_test 152 "test read/write with enomem ============================"
5913 multiop $DIR/$tfile Ow4096Ycu || error "multiop failed"
5915 run_test 153 "test if fdatasync does not crash ======================="
5918 # do directio so as not to populate the page cache
5919 log "creating a 10 Mb file"
5920 multiop $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
5921 log "starting reads"
5922 dd if=$DIR/$tfile of=/dev/null bs=4096 &
5923 log "truncating the file"
5924 multiop $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
5926 kill %+ || true # reads might have finished
5927 echo "wait until dd is finished"
5929 log "removing the temporary file"
5930 rm -rf $DIR/$tfile || error "tmp file removal failed"
5932 run_test 154 "parallel read and truncate should not deadlock ==="
5935 local temp=$TMP/$tfile
5936 local file=$DIR/$tfile
5937 local list=$(comma_list $(osts_nodes))
5938 local big=$(do_nodes $list grep "cache" /proc/cpuinfo | \
5939 awk '{sum+=$4} END{print sum}')
5943 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
5944 error "dd of=$temp bs=6096 count=1 failed"
5946 cancel_lru_locks osc
5947 cmp $temp $file || error "$temp $file differ"
5949 $TRUNCATE $temp 6000
5950 $TRUNCATE $file 6000
5951 cmp $temp $file || error "$temp $file differ (truncate1)"
5953 echo "12345" >>$temp
5954 echo "12345" >>$file
5955 cmp $temp $file || error "$temp $file differ (append1)"
5957 echo "12345" >>$temp
5958 echo "12345" >>$file
5959 cmp $temp $file || error "$temp $file differ (append2)"
5961 dd if=/dev/urandom of=$temp bs=$((big*2)) count=1k || \
5962 error "dd of=$temp bs=$((big*2)) count=1k failed"
5965 cancel_lru_locks osc
5966 cmp $temp $file || error "$temp $file differ"
5974 set_cache writethrough on
5977 run_test 155a "Verification of correctness: read cache:on write_cache:on"
5981 set_cache writethrough off
5984 run_test 155b "Verification of correctness: read cache:on write_cache:off"
5988 set_cache writethrough on
5991 run_test 155c "Verification of correctness: read cache:off write_cache:on"
5995 set_cache writethrough off
5998 run_test 155d "Verification of correctness: read cache:off write_cache:off "
6004 local file="$DIR/$tfile"
6006 log "Turn on read and write cache"
6008 set_cache writethrough on
6010 log "Write data and read it back."
6011 log "Read should be satisfied from the cache."
6012 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
6014 cancel_lru_locks osc
6015 cat $file >/dev/null
6017 if ! let "AFTER - BEFORE == CPAGES"; then
6018 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
6020 log "cache hits:: before: $BEFORE, after: $AFTER"
6023 log "Read again; it should be satisfied from the cache."
6025 cancel_lru_locks osc
6026 cat $file >/dev/null
6028 if ! let "AFTER - BEFORE == CPAGES"; then
6029 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
6031 log "cache hits:: before: $BEFORE, after: $AFTER"
6035 log "Turn off the read cache and turn on the write cache"
6037 set_cache writethrough on
6039 log "Read again; it should be satisfied from the cache."
6041 cancel_lru_locks osc
6042 cat $file >/dev/null
6044 if ! let "AFTER - BEFORE == CPAGES"; then
6045 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
6047 log "cache hits:: before: $BEFORE, after: $AFTER"
6050 log "Read again; it should not be satisfied from the cache."
6052 cancel_lru_locks osc
6053 cat $file >/dev/null
6055 if ! let "AFTER - BEFORE == 0"; then
6056 error "IN CACHE: before: $BEFORE, after: $AFTER"
6058 log "cache hits:: before: $BEFORE, after: $AFTER"
6061 log "Write data and read it back."
6062 log "Read should be satisfied from the cache."
6063 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
6065 cancel_lru_locks osc
6066 cat $file >/dev/null
6068 if ! let "AFTER - BEFORE == CPAGES"; then
6069 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
6071 log "cache hits:: before: $BEFORE, after: $AFTER"
6074 log "Read again; it should not be satisfied from the cache."
6076 cancel_lru_locks osc
6077 cat $file >/dev/null
6079 if ! let "AFTER - BEFORE == 0"; then
6080 error "IN CACHE: before: $BEFORE, after: $AFTER"
6082 log "cache hits:: before: $BEFORE, after: $AFTER"
6086 log "Turn off read and write cache"
6088 set_cache writethrough off
6090 log "Write data and read it back"
6091 log "It should not be satisfied from the cache."
6093 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
6094 cancel_lru_locks osc
6096 cat $file >/dev/null
6098 if ! let "AFTER - BEFORE == 0"; then
6099 error_ignore 20762 "IN CACHE: before: $BEFORE, after: $AFTER"
6101 log "cache hits:: before: $BEFORE, after: $AFTER"
6105 log "Turn on the read cache and turn off the write cache"
6107 set_cache writethrough off
6109 log "Write data and read it back"
6110 log "It should not be satisfied from the cache."
6112 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
6114 cancel_lru_locks osc
6115 cat $file >/dev/null
6117 if ! let "AFTER - BEFORE == 0"; then
6118 error_ignore 20762 "IN CACHE: before: $BEFORE, after: $AFTER"
6120 log "cache hits:: before: $BEFORE, after: $AFTER"
6123 log "Read again; it should be satisfied from the cache."
6125 cancel_lru_locks osc
6126 cat $file >/dev/null
6128 if ! let "AFTER - BEFORE == CPAGES"; then
6129 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
6131 log "cache hits:: before: $BEFORE, after: $AFTER"
6136 run_test 156 "Verification of ROC tunables ========================"
6139 $LCTL clear # bug 18514
6140 $LCTL debug_daemon start $TMP/${tfile}_log_good
6142 $LCTL debug_daemon stop
6143 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
6144 error "sed failed to read log_good"
6146 $LCTL debug_daemon start $TMP/${tfile}_log_good
6148 $LCTL debug_daemon stop
6150 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
6151 error "lctl df log_bad failed"
6153 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
6154 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
6156 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
6157 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
6159 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
6160 error "bad_line good_line1 good_line2 are empty"
6162 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
6163 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
6164 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
6166 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
6167 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
6168 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
6170 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
6171 error "bad_line_new good_line_new are empty"
6173 local expected_good=$((good_line1 + good_line2*2))
6175 rm -f $TMP/${tfile}*
6176 if [ $bad_line -ne $bad_line_new ]; then
6177 error "expected $bad_line bad lines, but got $bad_line_new"
6181 if [ $expected_good -ne $good_line_new ]; then
6182 error "expected $expected_good good lines, but got $good_line_new"
6187 run_test 170 "test lctl df to handle corrupted log ====================="
6189 obdecho_create_test() {
6193 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
6194 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" || rc=2; }
6195 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec create 1" || rc=3; }
6196 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec test_brw 0 w 1" || rc=4; }
6197 [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec cleanup" || rc=5; }
6198 [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec detach" || rc=6; }
6205 local rmmod_remote=0
6207 lsmod | grep -q obdecho || { load_module obdecho/obdecho && rmmod_local=1; }
6209 OBD=`$LCTL dl | awk ' /-osc-/ { print $4; exit; }'`
6210 [ "x$OBD" != "x" ] && { obdecho_create_test $OBD client || rc=2; }
6211 [ $rmmod_local -eq 1 ] && rmmod obdecho
6212 [ $rc -ne 0 ] && return $rc
6214 do_facet ost "lsmod | grep -q obdecho || { insmod ${LUSTRE}/obdecho/obdecho.ko || modprobe obdecho; }" && rmmod_remote=1
6216 OBD=$(do_facet ost "$LCTL dl | awk '/obdfilter/ { print; exit; }'" | awk '{print $4;}')
6217 [ "x$OBD" != "x" ] && { obdecho_create_test $OBD ost || rc=3; }
6218 [ $rmmod_remote -eq 1 ] && do_facet ost "rmmod obdecho"
6219 [ $rc -ne 0 ] && return $rc
6223 run_test 180 "test obdecho ============================================"
6228 TGTPOOL_MAX=$(($TGT_COUNT - 1))
6230 TGTPOOL_LIST=`seq $TGTPOOL_FIRST $TGTPOOL_STEP $TGTPOOL_MAX`
6231 POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
6232 POOL_DIR=$POOL_ROOT/dir_tst
6233 POOL_FILE=$POOL_ROOT/file_tst
6237 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep pools)" ] &&
6238 skip "missing pools support on server" && return 1
6239 remote_mgs_nodsh && skip "remote MGS with nodsh" && return 1
6240 [ -z "$mdtlov" ] && mdtlov=$(get_mdtlov_proc_path $FSNAME)
6244 check_file_in_pool()
6247 res=$($GETSTRIPE $file | grep 0x | cut -f2)
6250 found=$(echo :$TGTPOOL_LIST: | tr " " ":" | grep :$i:)
6251 if [[ "$found" == "" ]]
6253 echo "pool list: $TGTPOOL_LIST"
6254 echo "striping: $res"
6255 error "$file not allocated in $POOL"
6265 test_pools || return 0
6266 do_facet mgs $LCTL pool_new $FSNAME.$POOL
6267 # get param should return err until pool is created
6268 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null || echo foo" "" || error "Pool creation of $POOL failed"
6270 run_test 200a "Create new pool =========================================="
6273 test_pools || return 0
6274 TGT=$(for i in `seq $TGTPOOL_FIRST $TGTPOOL_STEP $TGTPOOL_MAX`; do printf "$FSNAME-OST%04x_UUID " $i; done)
6275 do_facet mgs $LCTL pool_add $FSNAME.$POOL \
6276 $FSNAME-OST[$TGTPOOL_FIRST-$TGTPOOL_MAX/$TGTPOOL_STEP]
6277 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL | sort -u | tr '\n' ' ' " "$TGT" || error "Add to pool failed"
6279 run_test 200b "Add targets to a pool ===================================="
6282 test_pools || return 0
6284 $SETSTRIPE -c 2 -p $POOL $POOL_DIR
6285 [ $? = 0 ] || error "Cannot set pool $POOL to $POOL_DIR"
6287 run_test 200c "Set pool on a directory ================================="
6290 test_pools || return 0
6291 res=$($GETSTRIPE --pool $POOL_DIR | awk '/^pool:/ {print $2}')
6292 [ "$res" = $POOL ] || error "Pool on $POOL_DIR is $res, not $POOL"
6294 run_test 200d "Check pool on a directory ==============================="
6297 test_pools || return 0
6299 for i in $(seq -w 1 $(($TGT_COUNT * 3))); do
6300 file=$POOL_DIR/file-$i
6302 check_file_in_pool $file
6303 if [[ $? != 0 ]]; then
6304 failed=$(($failed + 1))
6307 [ "$failed" = 0 ] || error "$failed files not allocated in $POOL"
6309 run_test 200e "Check files allocation from directory pool =============="
6312 test_pools || return 0
6315 for i in $(seq -w 1 $(($TGT_COUNT * 3))); do
6316 file=$POOL_FILE/spoo-$i
6317 $SETSTRIPE -p $POOL $file
6318 check_file_in_pool $file
6319 if [[ $? != 0 ]]; then
6320 failed=$(($failed + 1))
6323 [ "$failed" = 0 ] || error "$failed files not allocated in $POOL"
6325 run_test 200f "Create files in a pool ==================================="
6328 test_pools || return 0
6330 TGT=$($LCTL get_param -n lov.$FSNAME-*.pools.$POOL | head -1)
6331 res=$(lfs df --pool $FSNAME.$POOL | awk '{print $1}' | grep "$FSNAME-OST")
6332 [ "$res" = "$TGT" ] || echo "Pools OSTS $TGT is not $res that lfs df reports"
6334 run_test 200g "lfs df a pool ============================================"
6336 test_201a() { # was 200g
6337 test_pools || return 0
6338 TGT=$($LCTL get_param -n lov.$FSNAME-*.pools.$POOL | head -1)
6339 do_facet mgs $LCTL pool_remove $FSNAME.$POOL $TGT
6340 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL | grep $TGT" "" || error "$TGT not removed from $FSNAME.$POOL"
6342 run_test 201a "Remove a target from a pool ============================="
6344 test_201b() { # was 200h
6345 test_pools || return 0
6346 for TGT in $($LCTL get_param -n lov.$FSNAME-*.pools.$POOL | sort -u)
6348 do_facet mgs $LCTL pool_remove $FSNAME.$POOL $TGT
6350 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL" ""\
6351 || error "Pool $FSNAME.$POOL cannot be drained"
6352 # striping on an empty pool should fall back to "pool of everything"
6353 $SETSTRIPE -p $POOL ${POOL_FILE}/$tfile || \
6354 error "failed to create file with empty pool"
6356 run_test 201b "Remove all targets from a pool =========================="
6358 test_201c() { # was 200i
6359 test_pools || return 0
6360 do_facet mgs $LCTL pool_destroy $FSNAME.$POOL
6361 # get param should return err once pool is gone
6362 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null || echo foo" "foo" && return 0
6363 error "Pool $FSNAME.$POOL is not destroyed"
6365 run_test 201c "Remove a pool ============================================"
6368 $LFS setstripe -c 2 -s 1048576 $DIR/$tfile
6369 multiop $DIR/$tfile oO_WRONLY:O_APPEND:O_DIRECT:b1048548b130c || \
6370 error "direct write failed"
6371 multiop $DIR/${tfile}2 oO_WRONLY:O_CREAT:w1048548w130c || \
6372 error "cached write failed"
6373 cmp $DIR/$tfile $DIR/${tfile}2 || error "cmp failed"
6374 rm -f $DIR/${tfile}2
6376 run_test 202 "O_APPEND+O_DIRECT multistripe write ========================"
6379 # tests that do cleanup/setup should be run at the end
6384 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
6385 $LCTL set_param fail_loc=0x903
6386 # cancel_lru_locks mgc - does not work due to lctl set_param syntax
6387 for ls in /proc/fs/lustre/ldlm/namespaces/MGC*/lru_size; do
6390 FAIL_ON_ERROR=true cleanup
6391 FAIL_ON_ERROR=true setup
6393 run_test 900 "umount should not race with any mgc requeue thread"
6395 log "cleanup: ======================================================"
6396 check_and_cleanup_lustre
6397 if [ "$I_MOUNTED" != "yes" ]; then
6398 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true
6401 echo '=========================== finished ==============================='
6402 [ -f "$SANITYLOG" ] && cat $SANITYLOG && grep -q FAIL $SANITYLOG && exit 1 || true
6403 echo "$0: completed"