2 # -*- mode: Bash; tab-width: 4; indent-tabs-mode: t; -*-
3 # vim:autoindent:shiftwidth=4:tabstop=4:
5 # Run select tests by setting ONLY, or as arguments to the script.
6 # Skip specific tests by setting EXCEPT.
8 # e.g. ONLY="22 23" or ONLY="`seq 32 39`" or EXCEPT="31"
12 # bug number for skipped test: 13297 2108 9789 3637 9789 3561 12622 15528/2330 5188 10764 16410
13 ALWAYS_EXCEPT=${ALWAYS_EXCEPT:-"27u 42a 42b 42c 42d 45 51d 62 68 75 76 $SANITY_EXCEPT"}
14 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
16 # Tests that fail on uml, maybe elsewhere, FIXME
17 CPU=`awk '/model/ {print $4}' /proc/cpuinfo`
18 # buffer i/o errs sock spc runas
19 [ "$CPU" = "UML" ] && EXCEPT="$EXCEPT 27m 27n 27o 27p 27q 27r 31d 54a 64b 99a 99b 99c 99d 99e 99f 101"
22 2.4*) FSTYPE=${FSTYPE:-ext3}; ALWAYS_EXCEPT="$ALWAYS_EXCEPT 76"
23 [ "$CPU" = "UML" ] && ALWAYS_EXCEPT="$ALWAYS_EXCEPT 105a";;
24 2.6*) FSTYPE=${FSTYPE:-ldiskfs}; ALWAYS_EXCEPT="$ALWAYS_EXCEPT " ;;
25 *) error "unsupported kernel" ;;
28 SRCDIR=$(cd $(dirname $0); echo $PWD)
29 export PATH=$PATH:/sbin
33 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
34 CREATETEST=${CREATETEST:-createtest}
36 SETSTRIPE=${SETSTRIPE:-"$LFS setstripe"}
37 GETSTRIPE=${GETSTRIPE:-"$LFS getstripe"}
38 LFIND=${LFIND:-"$LFS find"}
39 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
41 MCREATE=${MCREATE:-mcreate}
42 OPENFILE=${OPENFILE:-openfile}
43 OPENUNLINK=${OPENUNLINK:-openunlink}
44 READS=${READS:-"reads"}
45 TRUNCATE=${TRUNCATE:-truncate}
46 MUNLINK=${MUNLINK:-munlink}
47 SOCKETSERVER=${SOCKETSERVER:-socketserver}
48 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
49 IOPENTEST1=${IOPENTEST1:-iopentest1}
50 IOPENTEST2=${IOPENTEST2:-iopentest2}
51 MEMHOG=${MEMHOG:-memhog}
52 DIRECTIO=${DIRECTIO:-directio}
53 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
54 UMOUNT=${UMOUNT:-"umount -d"}
55 CHECK_GRANT=${CHECK_GRANT:-"yes"}
56 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
58 export NAME=${NAME:-local}
65 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
66 . $LUSTRE/tests/test-framework.sh
68 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
70 [ "$SLOW" = "no" ] && EXCEPT_SLOW="24o 27m 36f 36g 51b 51c 60c 63 64b 68 71 73 77f 78 101 103 115 120g 124b"
72 SANITYLOG=${TESTSUITELOG:-$TMP/$(basename $0 .sh).log}
73 FAIL_ON_ERROR=${FAIL_ON_ERROR:-false}
77 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
78 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
88 check_kernel_version() {
91 GOT_VER=$(lctl get_param -n $VERSION_FILE | awk '/kernel:/ {print $2}')
93 patchless|patchless_client) return 0;;
94 *) [ $GOT_VER -ge $WANT_VER ] && return 0 ;;
96 log "test needs at least kernel version $WANT_VER, running $GOT_VER"
100 if [ "$ONLY" == "cleanup" ]; then
105 [ "$SANITYLOG" ] && rm -f $SANITYLOG || true
107 check_and_setup_lustre
112 LOVNAME=`lctl get_param -n llite.*.lov.common_name | tail -n 1`
113 OSTCOUNT=`lctl get_param -n lov.$LOVNAME.numobd`
114 STRIPECOUNT=`lctl get_param -n lov.$LOVNAME.stripecount`
115 STRIPESIZE=`lctl get_param -n lov.$LOVNAME.stripesize`
116 ORIGFREE=`lctl get_param -n lov.$LOVNAME.kbytesavail`
117 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
119 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
120 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
121 rm -rf $DIR/[Rdfs][0-9]*
123 # $RUNAS_ID may get set incorrectly somewhere else
124 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
126 check_runas_id $RUNAS_ID $RUNAS_ID $RUNAS
130 echo "preparing for tests involving mounts"
131 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
133 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
134 echo # add a newline after mke2fs.
138 OLDDEBUG="`lctl get_param -n debug 2> /dev/null`"
139 lctl set_param debug=-1 2> /dev/null || true
142 $CHECKSTAT -t file $DIR/$tfile || error
144 $CHECKSTAT -a $DIR/$tfile || error
146 run_test 0 "touch .../$tfile ; rm .../$tfile ====================="
149 chmod 0755 $DIR || error
150 $CHECKSTAT -p 0755 $DIR || error
152 run_test 0b "chmod 0755 $DIR ============================="
155 $LCTL get_param mdc.*.import | grep "state: FULL" || error "import not FULL"
156 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" || error "bad target"
158 run_test 0c "check import proc ============================="
163 $CHECKSTAT -t dir $DIR/d1/d2 || error
165 run_test 1a "mkdir .../d1; mkdir .../d1/d2 ====================="
170 $CHECKSTAT -a $DIR/d1 || error
172 run_test 1b "rmdir .../d1/d2; rmdir .../d1 ====================="
177 $CHECKSTAT -t file $DIR/d2/f || error
179 run_test 2a "mkdir .../d2; touch .../d2/f ======================"
183 $CHECKSTAT -a $DIR/d2 || error
185 run_test 2b "rm -r .../d2; checkstat .../d2/f ======================"
189 $CHECKSTAT -t dir $DIR/d3 || error
191 run_test 3a "mkdir .../d3 ======================================"
194 if [ ! -d $DIR/d3 ]; then
198 $CHECKSTAT -t file $DIR/d3/f || error
200 run_test 3b "touch .../d3/f ===================================="
204 $CHECKSTAT -a $DIR/d3 || error
206 run_test 3c "rm -r .../d3 ======================================"
210 $CHECKSTAT -t dir $DIR/d4 || error
212 run_test 4a "mkdir .../d4 ======================================"
215 if [ ! -d $DIR/d4 ]; then
219 $CHECKSTAT -t dir $DIR/d4/d2 || error
221 run_test 4b "mkdir .../d4/d2 ==================================="
226 chmod 0707 $DIR/d5/d2
227 $CHECKSTAT -t dir -p 0707 $DIR/d5/d2 || error
229 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2 ============"
233 chmod 0666 $DIR/f6a || error
234 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/f6a || error
236 run_test 6a "touch .../f6a; chmod .../f6a ======================"
239 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
240 if [ ! -f $DIR/f6a ]; then
244 $RUNAS chmod 0444 $DIR/f6a && error
245 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/f6a || error
247 run_test 6b "$RUNAS chmod .../f6a (should return error) =="
250 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
252 chown $RUNAS_ID $DIR/f6c || error
253 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/f6c || error
255 run_test 6c "touch .../f6c; chown .../f6c ======================"
258 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
259 if [ ! -f $DIR/f6c ]; then
261 chown $RUNAS_ID $DIR/f6c
263 $RUNAS chown $UID $DIR/f6c && error
264 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/f6c || error
266 run_test 6d "$RUNAS chown .../f6c (should return error) =="
269 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
271 chgrp $RUNAS_ID $DIR/f6e || error
272 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/f6e || error
274 run_test 6e "touch .../f6e; chgrp .../f6e ======================"
277 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
278 if [ ! -f $DIR/f6e ]; then
280 chgrp $RUNAS_ID $DIR/f6e
282 $RUNAS chgrp $UID $DIR/f6e && error
283 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/f6e || error
285 run_test 6f "$RUNAS chgrp .../f6e (should return error) =="
288 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
289 mkdir $DIR/d6g || error
290 chmod 777 $DIR/d6g || error
291 $RUNAS mkdir $DIR/d6g/d || error
292 chmod g+s $DIR/d6g/d || error
293 mkdir $DIR/d6g/d/subdir
294 $CHECKSTAT -g \#$RUNAS_ID $DIR/d6g/d/subdir || error
296 run_test 6g "Is new dir in sgid dir inheriting group?"
298 test_6h() { # bug 7331
299 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
300 touch $DIR/f6h || error "touch failed"
301 chown $RUNAS_ID:$RUNAS_ID $DIR/f6h || error "initial chown failed"
302 $RUNAS -G$RUNAS_ID chown $RUNAS_ID:0 $DIR/f6h && error "chown worked"
303 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_ID $DIR/f6h || error
305 run_test 6h "$RUNAS chown RUNAS_ID.0 .../f6h (should return error)"
311 $CHECKSTAT -t file -p 0666 $DIR/d7/f || error
313 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
316 if [ ! -d $DIR/d7 ]; then
320 echo -n foo > $DIR/d7/f2
321 [ "`cat $DIR/d7/f2`" = "foo" ] || error
322 $CHECKSTAT -t file -s 3 $DIR/d7/f2 || error
324 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
330 $CHECKSTAT -t file -p 0666 $DIR/d8/f || error
332 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
338 $CHECKSTAT -t dir $DIR/d9/d2/d3 || error
340 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
346 $CHECKSTAT -t file $DIR/d10/d2/f || error
348 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
353 chmod 0666 $DIR/d11/d2
354 chmod 0705 $DIR/d11/d2
355 $CHECKSTAT -t dir -p 0705 $DIR/d11/d2 || error
357 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
362 chmod 0666 $DIR/d12/f
363 chmod 0654 $DIR/d12/f
364 $CHECKSTAT -t file -p 0654 $DIR/d12/f || error
366 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
370 dd if=/dev/zero of=$DIR/d13/f count=10
372 $CHECKSTAT -t file -s 0 $DIR/d13/f || error
374 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
380 $CHECKSTAT -a $DIR/d14/f || error
382 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
387 mv $DIR/d15/f $DIR/d15/f2
388 $CHECKSTAT -t file $DIR/d15/f2 || error
390 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
396 $CHECKSTAT -a $DIR/d16/f || error
398 run_test 16 "touch .../d16/f; rm -rf .../d16/f ================="
403 ln -s $DIR/d17/f $DIR/d17/l-exist
405 $CHECKSTAT -l $DIR/d17/f $DIR/d17/l-exist || error
406 $CHECKSTAT -f -t f $DIR/d17/l-exist || error
407 rm -f $DIR/d17/l-exist
408 $CHECKSTAT -a $DIR/d17/l-exist || error
410 run_test 17a "symlinks: create, remove (real) =================="
414 ln -s no-such-file $DIR/d17/l-dangle
416 $CHECKSTAT -l no-such-file $DIR/d17/l-dangle || error
417 $CHECKSTAT -fa $DIR/d17/l-dangle || error
418 rm -f $DIR/d17/l-dangle
419 $CHECKSTAT -a $DIR/d17/l-dangle || error
421 run_test 17b "symlinks: create, remove (dangling) =============="
423 test_17c() { # bug 3440 - don't save failed open RPC for replay
425 ln -s foo $DIR/d17/f17c
426 cat $DIR/d17/f17c && error "opened non-existent symlink" || true
428 run_test 17c "symlinks: open dangling (should return error) ===="
432 ln -s foo $DIR/d17/f17d
433 touch $DIR/d17/f17d || error "creating to new symlink"
435 run_test 17d "symlinks: create dangling ========================"
439 local foo=$DIR/$tdir/$tfile
440 ln -s $foo $foo || error "create symlink failed"
441 ls -l $foo || error "ls -l failed"
442 ls $foo && error "ls not failed" || true
444 run_test 17e "symlinks: create recursive symlink (should return error) ===="
448 LONGSYMLINK="$(dd if=/dev/zero bs=4095 count=1 | tr '\0' 'x')"
449 ln -s $LONGSYMLINK $DIR/$tdir/$tfile
452 run_test 17g "symlinks: really long symlink name ==============================="
454 test_17h() { #bug 17378
456 $SETSTRIPE $DIR/$tdir -c -1
457 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
458 do_facet mds lctl set_param fail_loc=0x80000141
459 touch $DIR/$tdir/$tfile || true
461 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
463 test_17i() { #bug 20018
465 local foo=$DIR/$tdir/$tfile
466 ln -s $foo $foo || error "create symlink failed"
467 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
468 do_facet mds lctl set_param fail_loc=0x80000143
469 ls -l $foo && error "error not detected"
472 run_test 17i "don't panic on short symlink"
478 run_test 18 "touch .../f ; ls ... =============================="
484 $CHECKSTAT -a $DIR/f19 || error
486 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
489 ls -l $DIR/f19 && error || true
491 run_test 19b "ls -l .../f19 (should return error) =============="
494 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
495 $RUNAS touch $DIR/f19 && error || true
497 run_test 19c "$RUNAS touch .../f19 (should return error) =="
500 cat $DIR/f19 && error || true
502 run_test 19d "cat .../f19 (should return error) =============="
514 $CHECKSTAT -a $DIR/f || error
516 run_test 20 "touch .../f ; ls -l ... ==========================="
520 [ -f $DIR/d21/dangle ] && rm -f $DIR/d21/dangle
521 ln -s dangle $DIR/d21/link
522 echo foo >> $DIR/d21/link
524 $CHECKSTAT -t link $DIR/d21/link || error
525 $CHECKSTAT -f -t file $DIR/d21/link || error
527 run_test 21 "write to dangling link ============================"
532 chown $RUNAS_ID $WDIR
533 (cd $WDIR || error "cd $WDIR failed";
534 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
536 ls -lR $WDIR/etc || error "ls -lR $WDIR/etc failed"
537 $CHECKSTAT -t dir $WDIR/etc || error "checkstat -t dir failed"
538 $CHECKSTAT -u \#$RUNAS_ID $WDIR/etc || error "checkstat -u failed"
540 run_test 22 "unpack tar archive as non-root user ==============="
545 local file=$DIR/$tdir/$tfile
547 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
548 openfile -f O_CREAT:O_EXCL $file &&
549 error "$file recreate succeeded" || true
551 run_test 23a "O_CREAT|O_EXCL in subdir =========================="
553 test_23b() { # bug 18988
555 local file=$DIR/$tdir/$tfile
558 echo foo > $file || error "write filed"
559 echo bar >> $file || error "append filed"
560 $CHECKSTAT -s 8 $file || error "wrong size"
563 run_test 23b "O_APPEND check =========================="
566 echo '== rename sanity =============================================='
567 echo '-- same directory rename'
570 mv $DIR/R1/f $DIR/R1/g
571 $CHECKSTAT -t file $DIR/R1/g || error
573 run_test 24a "touch .../R1/f; rename .../R1/f .../R1/g ========="
578 mv $DIR/R2/f $DIR/R2/g
579 $CHECKSTAT -a $DIR/R2/f || error
580 $CHECKSTAT -t file $DIR/R2/g || error
582 run_test 24b "touch .../R2/{f,g}; rename .../R2/f .../R2/g ====="
587 mv $DIR/R3/f $DIR/R3/g
588 $CHECKSTAT -a $DIR/R3/f || error
589 $CHECKSTAT -t dir $DIR/R3/g || error
591 run_test 24c "mkdir .../R3/f; rename .../R3/f .../R3/g ========="
596 mrename $DIR/R4/f $DIR/R4/g
597 $CHECKSTAT -a $DIR/R4/f || error
598 $CHECKSTAT -t dir $DIR/R4/g || error
600 run_test 24d "mkdir .../R4/{f,g}; rename .../R4/f .../R4/g ====="
603 echo '-- cross directory renames --'
606 mv $DIR/R5a/f $DIR/R5b/g
607 $CHECKSTAT -a $DIR/R5a/f || error
608 $CHECKSTAT -t file $DIR/R5b/g || error
610 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
614 touch $DIR/R6a/f $DIR/R6b/g
615 mv $DIR/R6a/f $DIR/R6b/g
616 $CHECKSTAT -a $DIR/R6a/f || error
617 $CHECKSTAT -t file $DIR/R6b/g || error
619 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
624 mv $DIR/R7a/d $DIR/R7b/e
625 $CHECKSTAT -a $DIR/R7a/d || error
626 $CHECKSTAT -t dir $DIR/R7b/e || error
628 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R5b/e ======"
632 mkdir $DIR/R8a/d $DIR/R8b/e
633 mrename $DIR/R8a/d $DIR/R8b/e
634 $CHECKSTAT -a $DIR/R8a/d || error
635 $CHECKSTAT -t dir $DIR/R8b/e || error
637 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
640 echo "-- rename error cases"
644 mrename $DIR/R9/f $DIR/R9/a
645 $CHECKSTAT -t file $DIR/R9/f || error
646 $CHECKSTAT -t dir $DIR/R9/a || error
647 $CHECKSTAT -a $DIR/R9/a/f || error
649 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
653 mrename $DIR/R10/f $DIR/R10/g
654 $CHECKSTAT -t dir $DIR/R10 || error
655 $CHECKSTAT -a $DIR/R10/f || error
656 $CHECKSTAT -a $DIR/R10/g || error
658 run_test 24j "source does not exist ============================"
661 mkdir $DIR/R11a $DIR/R11a/d
663 mv $DIR/R11a/f $DIR/R11a/d
664 $CHECKSTAT -a $DIR/R11a/f || error
665 $CHECKSTAT -t file $DIR/R11a/d/f || error
667 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
669 # bug 2429 - rename foo foo foo creates invalid file
672 multiop $f OcNs || error
674 run_test 24l "Renaming a file to itself ========================"
678 multiop $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
679 # on ext3 this does not remove either the source or target files
680 # though the "expected" operation would be to remove the source
681 $CHECKSTAT -t file ${f} || error "${f} missing"
682 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
684 run_test 24m "Renaming a file to a hard link to itself ========="
688 # this stats the old file after it was renamed, so it should fail
692 $CHECKSTAT ${f}.rename
695 run_test 24n "Statting the old file after renaming (Posix rename 2)"
698 check_kernel_version 37 || return 0
700 rename_many -s random -v -n 10 $DIR/d24o
702 run_test 24o "rename of files during htree split ==============="
706 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
707 mrename $DIR/R12a $DIR/R12b
708 $CHECKSTAT -a $DIR/R12a || error
709 $CHECKSTAT -t dir $DIR/R12b || error
710 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
711 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
713 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
717 DIRINO=`ls -lid $DIR/R13a | awk '{ print $1 }'`
718 multiop_bg_pause $DIR/R13b D_c || return 1
721 mrename $DIR/R13a $DIR/R13b
722 $CHECKSTAT -a $DIR/R13a || error
723 $CHECKSTAT -t dir $DIR/R13b || error
724 DIRINO2=`ls -lid $DIR/R13b | awk '{ print $1 }'`
725 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
727 wait $MULTIPID || error "multiop close failed"
729 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
731 test_24r() { #bug 3789
732 mkdir $DIR/R14a $DIR/R14a/b
733 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
734 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
735 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
737 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
740 mkdir $DIR/R15a $DIR/R15a/b $DIR/R15a/b/c
741 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
742 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
743 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
745 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
747 mkdir $DIR/R16a $DIR/R16a/b $DIR/R16a/b/c
748 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
749 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
750 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
752 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
754 test_24u() { # bug12192
755 multiop $DIR/$tfile C2w$((2048 * 1024))c || error
756 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
758 run_test 24u "create stripe file"
761 echo '== symlink sanity ============================================='
765 touch $DIR/s25/foo || error
767 run_test 25a "create file in symlinked directory ==============="
770 [ ! -d $DIR/d25 ] && test_25a
771 $CHECKSTAT -t file $DIR/s25/foo || error
773 run_test 25b "lookup file in symlinked directory ==============="
778 ln -s d26/d26-2 $DIR/s26
779 touch $DIR/s26/foo || error
781 run_test 26a "multiple component symlink ======================="
784 mkdir -p $DIR/d26b/d26-2
785 ln -s d26b/d26-2/foo $DIR/s26-2
786 touch $DIR/s26-2 || error
788 run_test 26b "multiple component symlink at end of lookup ======"
793 ln -s d26.2 $DIR/s26.2-1
794 ln -s s26.2-1 $DIR/s26.2-2
795 ln -s s26.2-2 $DIR/s26.2-3
796 chmod 0666 $DIR/s26.2-3/foo
798 run_test 26c "chain of symlinks ================================"
800 # recursive symlinks (bug 439)
802 ln -s d26-3/foo $DIR/d26-3
804 run_test 26d "create multiple component recursive symlink ======"
807 [ ! -h $DIR/d26-3 ] && test_26d
810 run_test 26e "unlink multiple component recursive symlink ======"
812 # recursive symlinks (bug 7022)
815 mkdir $DIR/$tdir/$tfile || error "mkdir $DIR/$tdir/$tfile failed"
816 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
817 mkdir -p lndir/bar1 || error "mkdir lndir/bar1 failed"
818 mkdir $tfile || error "mkdir $tfile failed"
819 cd $tfile || error "cd $tfile failed"
820 ln -s .. dotdot || error "ln dotdot failed"
821 ln -s dotdot/lndir lndir || error "ln lndir failed"
822 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
823 output=`ls $tfile/$tfile/lndir/bar1`
824 [ "$output" = bar1 ] && error "unexpected output"
825 rm -r $tfile || error "rm $tfile failed"
826 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
828 run_test 26f "rm -r of a directory which has recursive symlink ="
831 echo '== stripe sanity =============================================='
832 mkdir -p $DIR/d27 || error "mkdir failed"
834 $SETSTRIPE $DIR/d27/f0 -c 1 || error "lstripe failed"
835 $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
837 log "== test 27b: write to one stripe file ========================="
838 cp /etc/hosts $DIR/d27/f0 || error
840 run_test 27a "one stripe file =================================="
843 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
845 $SETSTRIPE $DIR/d27/f01 -c 2 || error "lstripe failed"
846 [ `$GETSTRIPE $DIR/d27/f01 | grep -A 10 obdidx | wc -l` -eq 4 ] ||
847 error "two-stripe file doesn't have two stripes"
849 log "== test 27d: write to two stripe file file f01 ================"
850 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
852 run_test 27c "create two stripe file f01 ======================="
856 $SETSTRIPE -c0 -i-1 -s0 $DIR/d27/fdef || error "lstripe failed"
857 $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
858 dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
860 run_test 27d "create file with default settings ================"
864 $SETSTRIPE $DIR/d27/f12 -c 2 || error "lstripe failed"
865 $SETSTRIPE $DIR/d27/f12 -c 2 && error "lstripe succeeded twice"
866 $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
868 run_test 27e "setstripe existing file (should return error) ======"
872 $SETSTRIPE $DIR/d27/fbad -s 100 -i 0 -c 1 && error "lstripe failed"
873 dd if=/dev/zero of=$DIR/d27/f12 bs=4k count=4 || error "dd failed"
874 $GETSTRIPE $DIR/d27/fbad || error "lfs getstripe failed"
876 run_test 27f "setstripe with bad stripe size (should return error)"
880 $MCREATE $DIR/d27/fnone || error "mcreate failed"
882 log "== test 27h: lfs getstripe with no objects ===================="
883 $GETSTRIPE $DIR/d27/fnone 2>&1 | grep "no stripe info" || error "has object"
885 log "== test 27i: lfs getstripe with some objects =================="
886 touch $DIR/d27/fsome || error "touch failed"
887 $GETSTRIPE $DIR/d27/fsome | grep obdidx || error "missing objects"
889 run_test 27g "test lfs getstripe ==========================================="
893 $SETSTRIPE $DIR/d27/f27j -i $OSTCOUNT && error "lstripe failed"||true
895 run_test 27j "setstripe with bad stripe offset (should return error)"
897 test_27k() { # bug 2844
900 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
901 [ ! -d $DIR/d27 ] && mkdir -p $DIR/d27
902 $SETSTRIPE $FILE -s 67108864 || error "lstripe failed"
903 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
904 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
905 dd if=/dev/zero of=$FILE bs=4k count=1
906 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
907 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
909 run_test 27k "limit i_blksize for broken user apps ============="
913 mcreate $DIR/f27l || error "creating file"
914 $RUNAS $SETSTRIPE $DIR/f27l -c 1 && \
915 error "lstripe should have failed" || true
917 run_test 27l "check setstripe permissions (should return error)"
920 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
921 if [ $ORIGFREE -gt $MAXFREE ]; then
922 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
926 $SETSTRIPE $DIR/d27/f27m_1 -i 0 -c 1
927 dd if=/dev/zero of=$DIR/d27/f27m_1 bs=1024 count=$MAXFREE && \
928 error "dd should fill OST0"
930 while $SETSTRIPE $DIR/d27/f27m_$i -i 0 -c 1 ; do
932 [ $i -gt 256 ] && break
935 touch $DIR/d27/f27m_$i
936 [ `$GETSTRIPE $DIR/d27/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] && \
937 error "OST0 was full but new created file still use it"
939 touch $DIR/d27/f27m_$i
940 [ `$GETSTRIPE $DIR/d27/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] && \
941 error "OST0 was full but new created file still use it"
944 run_test 27m "create file while OST0 was full =================="
947 local DELAY=$(do_facet mds lctl get_param -n lov.*.qos_maxage | awk '{print $1 + 2}')
951 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
952 # if the OST isn't full anymore.
954 local OSTIDX=${1:-""}
956 local list=$(comma_list $(osts_nodes))
957 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
959 do_nodes $list lctl set_param fail_loc=0
963 exhaust_precreations() {
966 local FAILIDX=${3:-$OSTIDX}
968 local OST=$(lfs osts | grep ${OSTIDX}": " | \
969 awk '{print $2}' | sed -e 's/_UUID$//')
972 local mdtosc=$(get_mdtosc_proc_path $OST)
973 local last_id=$(do_facet mds lctl get_param -n osc.$mdtosc.prealloc_last_id)
974 local next_id=$(do_facet mds lctl get_param -n osc.$mdtosc.prealloc_next_id)
976 mkdir -p $DIR/$tdir/${OST}
977 $SETSTRIPE $DIR/$tdir/${OST} -i $OSTIDX -c 1
978 #define OBD_FAIL_OST_ENOSPC 0x215
979 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=$FAILIDX
980 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x215
981 echo "Creating to objid $last_id on ost $OST..."
982 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
983 do_facet mds "lctl get_param -n osc.$mdtosc.prealloc*" | grep '[0-9]'
984 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=$FAILLOC
988 exhaust_all_precreations() {
990 for (( i=0; i < OSTCOUNT; i++ )) ; do
991 exhaust_precreations $i $1 -1
996 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
997 remote_mds_nodsh && skip "remote MDS with nodsh" && return
998 remote_ost_nodsh && skip "remote OST with nodsh" && return
1001 rm -f $DIR/$tdir/$tfile
1002 exhaust_precreations 0 0x80000215
1003 $SETSTRIPE -c -1 $DIR/$tdir
1004 touch $DIR/$tdir/$tfile || error
1005 $GETSTRIPE $DIR/$tdir/$tfile
1008 run_test 27n "create file with some full OSTs =================="
1011 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1012 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1013 remote_ost_nodsh && skip "remote OST with nodsh" && return
1016 rm -f $DIR/$tdir/$tfile
1017 exhaust_all_precreations 0x215
1019 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1024 run_test 27o "create file with all full OSTs (should error) ===="
1027 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1028 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1029 remote_ost_nodsh && skip "remote OST with nodsh" && return
1032 rm -f $DIR/$tdir/$tfile
1035 $MCREATE $DIR/$tdir/$tfile || error
1036 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error
1037 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error
1039 exhaust_precreations 0 0x80000215
1040 echo foo >> $DIR/$tdir/$tfile || error
1041 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error
1045 run_test 27p "append to a truncated file with some full OSTs ==="
1048 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1049 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1050 remote_ost_nodsh && skip "remote OST with nodsh" && return
1053 rm -f $DIR/$tdir/$tfile
1055 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1056 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||error "truncate $DIR/$tdir/$tfile failed"
1057 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1059 exhaust_all_precreations 0x215
1061 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1062 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1066 run_test 27q "append to truncated file with all OSTs full (should error) ==="
1069 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1070 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1071 remote_ost_nodsh && skip "remote OST with nodsh" && return
1074 rm -f $DIR/$tdir/$tfile
1075 exhaust_precreations 0 0x80000215
1077 $SETSTRIPE $DIR/$tdir/$tfile -i 0 -c 2 # && error
1081 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1083 test_27s() { # bug 10725
1085 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1086 local stripe_count=0
1087 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1088 $SETSTRIPE $DIR/$tdir -s $stripe_size -c $stripe_count && \
1089 error "stripe width >= 2^32 succeeded" || true
1091 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1093 test_27t() { # bug 10864
1098 $WLFS getstripe $tfile
1101 run_test 27t "check that utils parse path correctly"
1103 test_27u() { # bug 4900
1104 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1105 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1107 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1109 do_facet mds lctl set_param fail_loc=0x139
1111 createmany -o $DIR/$tdir/t- 1000
1112 do_facet mds lctl set_param fail_loc=0
1114 TLOG=$DIR/$tfile.getstripe
1115 $GETSTRIPE $DIR/$tdir > $TLOG
1116 OBJS=`awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj;}' $TLOG`
1117 unlinkmany $DIR/$tdir/t- 1000
1118 [ $OBJS -gt 0 ] && \
1119 error "$OBJS objects created on OST-0. See $TLOG" || pass
1121 run_test 27u "skip object creation on OSC w/o objects =========="
1123 test_27v() { # bug 4900
1124 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1125 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1126 remote_ost_nodsh && skip "remote OST with nodsh" && return
1128 exhaust_all_precreations 0x215
1132 $SETSTRIPE $DIR/$tdir -c 1 # 1 stripe / file
1134 touch $DIR/$tdir/$tfile
1135 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1137 for (( i=0; i < OSTCOUNT; i++ )) ; do
1138 do_facet ost$i lctl set_param fail_loc=0x705
1140 local START=`date +%s`
1141 createmany -o $DIR/$tdir/$tfile 32
1143 local FINISH=`date +%s`
1144 local TIMEOUT=`lctl get_param -n timeout`
1145 [ $((FINISH - START)) -ge $((TIMEOUT / 2)) ] && \
1146 error "$FINISH - $START >= $TIMEOUT / 2"
1150 run_test 27v "skip object creation on slow OST ================="
1152 test_27w() { # bug 10997
1153 mkdir -p $DIR/$tdir || error "mkdir failed"
1154 $SETSTRIPE $DIR/$tdir/f0 -s 65536 || error "lstripe failed"
1155 size=`$GETSTRIPE $DIR/$tdir/f0 -s`
1156 [ $size -ne 65536 ] && error "stripe size $size != 65536" || true
1158 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping multiple stripe count/offset test" && return
1159 for i in `seq 1 $OSTCOUNT`; do
1161 log setstripe $DIR/$tdir/f$i -c $i -i $offset
1162 $SETSTRIPE $DIR/$tdir/f$i -c $i -i $offset || error "lstripe -c $i -i $offset failed"
1163 count=`$GETSTRIPE -c $DIR/$tdir/f$i`
1164 index=`$GETSTRIPE -o $DIR/$tdir/f$i`
1165 [ $count -ne $i ] && error "stripe count $count != $i" || true
1166 [ $index -ne $offset ] && error "stripe offset $index != $offset" || true
1169 run_test 27w "check lfs setstripe -c -s -i options ============="
1172 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs" && return
1173 OFFSET=$(($OSTCOUNT - 1))
1175 local OST=$(lfs osts | awk '/'${OSTIDX}': / { print $2 }' | sed -e 's/_UUID$//')
1178 $SETSTRIPE $DIR/$tdir -c 1 # 1 stripe per file
1179 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1181 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1182 for i in `seq 0 $OFFSET`; do
1183 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}' | grep -w "$OSTIDX"` ] &&
1184 error "OST0 was degraded but new created file still use it"
1186 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1188 run_test 27x "create files while OST0 is degraded"
1191 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1192 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1194 MDS_OSCS=`do_facet mds lctl dl | awk '/[oO][sS][cC].*md[ts]/ { print $4 }'`
1195 OFFSET=$(($OSTCOUNT-1))
1197 for OSC in $MDS_OSCS; do
1198 if [ $OST == -1 ]; then {
1199 OST=`osc_to_ost $OSC`
1201 echo $OSC "is Deactivate:"
1202 do_facet mds lctl --device %$OSC deactivate
1206 OSTIDX=$(lfs osts | grep ${OST} | awk '{print $1}' | sed -e 's/://')
1208 $SETSTRIPE $DIR/$tdir -c 1 # 1 stripe / file
1210 do_facet ost$OSTIDX lctl set_param -n obdfilter.$OST.degraded 1
1212 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1213 do_facet ost$OSTIDX lctl set_param -n obdfilter.$OST.degraded 0
1215 for i in `seq 0 $OFFSET`; do
1216 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "$OSTIDX"` ] || \
1217 error "files created on deactivated OSTs instead of degraded OST"
1219 for OSC in $MDS_OSCS; do
1220 [ `osc_to_ost $OSC` != $OST ] && {
1221 echo $OSC "is activate"
1222 do_facet mds lctl --device %$OSC activate
1226 run_test 27y "create files while OST0 is degraded and the rest inactive"
1228 # createtest also checks that device nodes are created and
1229 # then visible correctly (#2091)
1230 test_28() { # bug 2091
1232 $CREATETEST $DIR/d28/ct || error
1234 run_test 28 "create/mknod/mkdir with bad file types ============"
1237 cancel_lru_locks mdc
1242 LOCKCOUNTORIG=`lctl get_param -n ldlm.namespaces.*mdc*.lock_count`
1243 LOCKUNUSEDCOUNTORIG=`lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count`
1244 [ -z $"LOCKCOUNTORIG" ] && error "No mdc lock count" && return 1
1248 LOCKCOUNTCURRENT=`lctl get_param -n ldlm.namespaces.*mdc*.lock_count`
1249 LOCKUNUSEDCOUNTCURRENT=`lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count`
1250 if [ "$LOCKCOUNTCURRENT" -gt "$LOCKCOUNTORIG" ]; then
1251 lctl set_param -n ldlm.dump_namespaces ""
1252 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
1253 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1254 log "dumped log to $TMP/test_29.dk (bug 5793)"
1257 if [ "$LOCKUNUSEDCOUNTCURRENT" -gt "$LOCKUNUSEDCOUNTORIG" ]; then
1258 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
1259 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1260 log "dumped log to $TMP/test_29.dk (bug 5793)"
1264 run_test 29 "IT_GETATTR regression ============================"
1271 run_test 30 "run binary from Lustre (execve) ==================="
1274 $OPENUNLINK $DIR/f31 $DIR/f31 || error
1275 $CHECKSTAT -a $DIR/f31 || error
1277 run_test 31a "open-unlink file =================================="
1280 touch $DIR/f31 || error
1281 ln $DIR/f31 $DIR/f31b || error
1282 multiop $DIR/f31b Ouc || error
1283 $CHECKSTAT -t file $DIR/f31 || error
1285 run_test 31b "unlink file with multiple links while open ======="
1288 touch $DIR/f31 || error
1289 ln $DIR/f31 $DIR/f31c || error
1290 multiop_bg_pause $DIR/f31 O_uc || return 1
1292 multiop $DIR/f31c Ouc
1293 kill -USR1 $MULTIPID
1296 run_test 31c "open-unlink file with multiple links ============="
1299 opendirunlink $DIR/d31d $DIR/d31d || error
1300 $CHECKSTAT -a $DIR/d31d || error
1302 run_test 31d "remove of open directory ========================="
1304 test_31e() { # bug 2904
1305 check_kernel_version 34 || return 0
1306 openfilleddirunlink $DIR/d31e || error
1308 run_test 31e "remove of open non-empty directory ==============="
1310 test_31f() { # bug 4554
1313 $SETSTRIPE $DIR/d31f -s 1048576 -c 1
1314 cp /etc/hosts $DIR/d31f
1316 $GETSTRIPE $DIR/d31f/hosts
1317 multiop_bg_pause $DIR/d31f D_c || return 1
1320 rm -rv $DIR/d31f || error "first of $DIR/d31f"
1322 $SETSTRIPE $DIR/d31f -s 1048576 -c 1
1323 cp /etc/hosts $DIR/d31f
1326 multiop_bg_pause $DIR/d31f D_c || return 1
1329 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
1330 wait $MULTIPID || error "first opendir $MULTIPID failed"
1334 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
1335 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
1338 run_test 31f "remove of open directory with open-unlink file ==="
1341 echo "== more mountpoints and symlinks ================="
1342 [ -e $DIR/d32a ] && rm -fr $DIR/d32a
1343 mkdir -p $DIR/d32a/ext2-mountpoint
1344 mount -t ext2 -o loop $EXT2_DEV $DIR/d32a/ext2-mountpoint || error
1345 $CHECKSTAT -t dir $DIR/d32a/ext2-mountpoint/.. || error
1346 $UMOUNT $DIR/d32a/ext2-mountpoint || error
1348 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
1351 [ -e $DIR/d32b ] && rm -fr $DIR/d32b
1352 mkdir -p $DIR/d32b/ext2-mountpoint
1353 mount -t ext2 -o loop $EXT2_DEV $DIR/d32b/ext2-mountpoint || error
1354 ls -al $DIR/d32b/ext2-mountpoint/.. || error
1355 $UMOUNT $DIR/d32b/ext2-mountpoint || error
1357 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
1360 [ -e $DIR/d32c ] && rm -fr $DIR/d32c
1361 mkdir -p $DIR/d32c/ext2-mountpoint
1362 mount -t ext2 -o loop $EXT2_DEV $DIR/d32c/ext2-mountpoint || error
1363 mkdir -p $DIR/d32c/d2/test_dir
1364 $CHECKSTAT -t dir $DIR/d32c/ext2-mountpoint/../d2/test_dir || error
1365 $UMOUNT $DIR/d32c/ext2-mountpoint || error
1367 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
1370 [ -e $DIR/d32d ] && rm -fr $DIR/d32d
1371 mkdir -p $DIR/d32d/ext2-mountpoint
1372 mount -t ext2 -o loop $EXT2_DEV $DIR/d32d/ext2-mountpoint || error
1373 mkdir -p $DIR/d32d/d2/test_dir
1374 ls -al $DIR/d32d/ext2-mountpoint/../d2/test_dir || error
1375 $UMOUNT $DIR/d32d/ext2-mountpoint || error
1377 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
1380 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
1381 mkdir -p $DIR/d32e/tmp
1382 TMP_DIR=$DIR/d32e/tmp
1383 ln -s $DIR/d32e $TMP_DIR/symlink11
1384 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1385 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
1386 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
1388 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
1391 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
1392 mkdir -p $DIR/d32f/tmp
1393 TMP_DIR=$DIR/d32f/tmp
1394 ln -s $DIR/d32f $TMP_DIR/symlink11
1395 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1396 ls $DIR/d32f/tmp/symlink11 || error
1397 ls $DIR/d32f/symlink01 || error
1399 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
1402 TMP_DIR=$DIR/$tdir/tmp
1403 mkdir -p $TMP_DIR $DIR/${tdir}2
1404 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
1405 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1406 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
1407 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
1408 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
1409 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
1411 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
1414 rm -fr $DIR/$tdir $DIR/${tdir}2
1415 TMP_DIR=$DIR/$tdir/tmp
1416 mkdir -p $TMP_DIR $DIR/${tdir}2
1417 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
1418 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1419 ls $TMP_DIR/symlink12 || error
1420 ls $DIR/$tdir/symlink02 || error
1422 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
1425 [ -e $DIR/d32i ] && rm -fr $DIR/d32i
1426 mkdir -p $DIR/d32i/ext2-mountpoint
1427 mount -t ext2 -o loop $EXT2_DEV $DIR/d32i/ext2-mountpoint || error
1428 touch $DIR/d32i/test_file
1429 $CHECKSTAT -t file $DIR/d32i/ext2-mountpoint/../test_file || error
1430 $UMOUNT $DIR/d32i/ext2-mountpoint || error
1432 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
1435 [ -e $DIR/d32j ] && rm -fr $DIR/d32j
1436 mkdir -p $DIR/d32j/ext2-mountpoint
1437 mount -t ext2 -o loop $EXT2_DEV $DIR/d32j/ext2-mountpoint || error
1438 touch $DIR/d32j/test_file
1439 cat $DIR/d32j/ext2-mountpoint/../test_file || error
1440 $UMOUNT $DIR/d32j/ext2-mountpoint || error
1442 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
1446 mkdir -p $DIR/d32k/ext2-mountpoint
1447 mount -t ext2 -o loop $EXT2_DEV $DIR/d32k/ext2-mountpoint
1448 mkdir -p $DIR/d32k/d2
1449 touch $DIR/d32k/d2/test_file || error
1450 $CHECKSTAT -t file $DIR/d32k/ext2-mountpoint/../d2/test_file || error
1451 $UMOUNT $DIR/d32k/ext2-mountpoint || error
1453 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
1457 mkdir -p $DIR/d32l/ext2-mountpoint
1458 mount -t ext2 -o loop $EXT2_DEV $DIR/d32l/ext2-mountpoint || error
1459 mkdir -p $DIR/d32l/d2
1460 touch $DIR/d32l/d2/test_file
1461 cat $DIR/d32l/ext2-mountpoint/../d2/test_file || error
1462 $UMOUNT $DIR/d32l/ext2-mountpoint || error
1464 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
1468 mkdir -p $DIR/d32m/tmp
1469 TMP_DIR=$DIR/d32m/tmp
1470 ln -s $DIR $TMP_DIR/symlink11
1471 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1472 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
1473 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
1475 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
1479 mkdir -p $DIR/d32n/tmp
1480 TMP_DIR=$DIR/d32n/tmp
1481 ln -s $DIR $TMP_DIR/symlink11
1482 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1483 ls -l $DIR/d32n/tmp/symlink11 || error
1484 ls -l $DIR/d32n/symlink01 || error
1486 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
1489 rm -fr $DIR/d32o $DIR/$tfile
1491 mkdir -p $DIR/d32o/tmp
1492 TMP_DIR=$DIR/d32o/tmp
1493 ln -s $DIR/$tfile $TMP_DIR/symlink12
1494 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1495 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
1496 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
1497 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
1498 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
1500 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
1510 mkdir -p $DIR/d32p/tmp
1512 TMP_DIR=$DIR/d32p/tmp
1514 ln -s $DIR/$tfile $TMP_DIR/symlink12
1516 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1518 cat $DIR/d32p/tmp/symlink12 || error
1520 cat $DIR/d32p/symlink02 || error
1523 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
1526 [ -e $DIR/d32q ] && rm -fr $DIR/d32q
1528 touch $DIR/d32q/under_the_mount
1529 mount -t ext2 -o loop $EXT2_DEV $DIR/d32q
1530 ls $DIR/d32q/under_the_mount && error || true
1531 $UMOUNT $DIR/d32q || error
1533 run_test 32q "stat follows mountpoints in Lustre (should return error)"
1536 [ -e $DIR/d32r ] && rm -fr $DIR/d32r
1538 touch $DIR/d32r/under_the_mount
1539 mount -t ext2 -o loop $EXT2_DEV $DIR/d32r
1540 ls $DIR/d32r | grep -q under_the_mount && error || true
1541 $UMOUNT $DIR/d32r || error
1543 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
1548 chmod 444 $DIR/$tfile
1549 chown $RUNAS_ID $DIR/$tfile
1551 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
1554 run_test 33 "write file with mode 444 (should return error) ===="
1559 chown $RUNAS_ID $DIR/d33
1560 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
1561 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
1562 error "open RDWR" || true
1564 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
1569 chown $RUNAS_ID $DIR/d33
1570 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33 || true
1572 run_test 33b "test open file with malformed flags (No panic)"
1574 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
1577 $MCREATE $DIR/f34 || error
1578 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
1579 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
1580 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
1581 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1583 run_test 34a "truncate file that has not been opened ==========="
1586 [ ! -f $DIR/f34 ] && test_34a
1587 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1588 $OPENFILE -f O_RDONLY $DIR/f34
1589 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
1590 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1592 run_test 34b "O_RDONLY opening file doesn't create objects ====="
1595 [ ! -f $DIR/f34 ] && test_34a
1596 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1597 $OPENFILE -f O_RDWR $DIR/f34
1598 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
1599 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1601 run_test 34c "O_RDWR opening file-with-size works =============="
1604 [ ! -f $DIR/f34 ] && test_34a
1605 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
1606 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1609 run_test 34d "write to sparse file ============================="
1613 $MCREATE $DIR/f34e || error
1614 $TRUNCATE $DIR/f34e 1000 || error
1615 $CHECKSTAT -s 1000 $DIR/f34e || error
1616 $OPENFILE -f O_RDWR $DIR/f34e
1617 $CHECKSTAT -s 1000 $DIR/f34e || error
1619 run_test 34e "create objects, some with size and some without =="
1621 test_34f() { # bug 6242, 6243
1624 $MCREATE $DIR/f34f || error
1625 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
1626 dd if=$DIR/f34f of=$TMP/f34f
1627 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
1628 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
1629 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
1630 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
1631 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
1633 run_test 34f "read from a file with no objects until EOF ======="
1636 cp /bin/sh $DIR/f35a
1638 chown $RUNAS_ID $DIR/f35a
1639 $RUNAS $DIR/f35a && error || true
1642 run_test 35a "exec file with mode 444 (should return and not leak) ====="
1646 utime $DIR/f36 || error
1648 run_test 36a "MDS utime check (mknod, utime) ==================="
1652 utime $DIR/f36 || error
1654 run_test 36b "OST utime check (open, utime) ===================="
1659 chown $RUNAS_ID $DIR/d36
1660 $RUNAS utime $DIR/d36/f36 || error
1662 run_test 36c "non-root MDS utime check (mknod, utime) =========="
1665 [ ! -d $DIR/d36 ] && test_36c
1666 echo "" > $DIR/d36/f36
1667 $RUNAS utime $DIR/d36/f36 || error
1669 run_test 36d "non-root OST utime check (open, utime) ==========="
1672 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
1674 touch $DIR/$tdir/$tfile
1675 $RUNAS utime $DIR/$tdir/$tfile && \
1676 error "utime worked, expected failure" || true
1678 run_test 36e "utime on non-owned file (should return error) ===="
1681 export LANG=C LC_LANG=C # for date language
1683 DATESTR="Dec 20 2000"
1685 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
1686 lctl set_param fail_loc=0x80000214
1688 cp /etc/hosts $DIR/$tdir/$tfile
1689 sync & # write RPC generated with "current" inode timestamp, but delayed
1691 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
1692 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
1693 cancel_lru_locks osc
1694 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
1696 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
1697 echo "BEFORE: $LS_BEFORE" && \
1698 echo "AFTER : $LS_AFTER" && \
1699 echo "WANT : $DATESTR" && \
1700 error "$DIR/$tdir/$tfile timestamps changed" || true
1702 run_test 36f "utime on file racing with OST BRW write =========="
1705 remote_ost_nodsh && skip "remote OST with nodsh" && return
1708 export FMD_MAX_AGE=`do_facet ost1 lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | head -n 1`
1709 FMD_BEFORE="`awk '/ll_fmd_cache/ { print $2 }' /proc/slabinfo`"
1710 touch $DIR/$tdir/$tfile
1711 sleep $((FMD_MAX_AGE + 12))
1712 FMD_AFTER="`awk '/ll_fmd_cache/ { print $2 }' /proc/slabinfo`"
1713 [ "$FMD_AFTER" -gt "$FMD_BEFORE" ] && \
1714 echo "AFTER : $FMD_AFTER > BEFORE $FMD_BEFORE" && \
1715 error "fmd didn't expire after ping" || true
1717 run_test 36g "filter mod data cache expiry ====================="
1721 echo f > $DIR/$tdir/fbugfile
1722 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
1723 ls $DIR/$tdir | grep "\<fbugfile\>" && error
1724 $UMOUNT $DIR/$tdir || error
1725 rm -f $DIR/$tdir/fbugfile || error
1727 run_test 37 "ls a mounted file system to check old content ====="
1730 local file=$DIR/$tfile
1732 openfile -f O_DIRECTORY $file
1735 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
1736 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
1738 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
1742 touch $DIR/${tfile}2
1743 # ls -l $DIR/$tfile $DIR/${tfile}2
1744 # ls -lu $DIR/$tfile $DIR/${tfile}2
1745 # ls -lc $DIR/$tfile $DIR/${tfile}2
1747 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
1748 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
1750 ls -l $DIR/$tfile $DIR/${tfile}2
1752 ls -lu $DIR/$tfile $DIR/${tfile}2
1754 ls -lc $DIR/$tfile $DIR/${tfile}2
1755 error "O_TRUNC didn't change timestamps"
1758 run_test 39 "mtime changed on create ==========================="
1760 function get_times() {
1765 for time in `stat -c "%X %Y %Z" $FILE`; do
1766 eval "$TIME[$i]=$time"
1776 cp -p /etc/passwd $DIR/$tdir/fopen
1777 cp -p /etc/passwd $DIR/$tdir/flink
1778 cp -p /etc/passwd $DIR/$tdir/funlink
1779 cp -p /etc/passwd $DIR/$tdir/frename
1780 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
1782 get_times $DIR/$tdir/fopen OPEN_OLD
1783 get_times $DIR/$tdir/flink LINK_OLD
1784 get_times $DIR/$tdir/funlink UNLINK_OLD
1785 get_times $DIR/$tdir/frename RENAME_OLD
1788 echo "aaaaaa" >> $DIR/$tdir/fopen
1789 echo "aaaaaa" >> $DIR/$tdir/flink
1790 echo "aaaaaa" >> $DIR/$tdir/funlink
1791 echo "aaaaaa" >> $DIR/$tdir/frename
1793 get_times $DIR/$tdir/fopen OPEN_NEW
1794 get_times $DIR/$tdir/flink LINK_NEW
1795 get_times $DIR/$tdir/funlink UNLINK_NEW
1796 get_times $DIR/$tdir/frename RENAME_NEW
1798 cat $DIR/$tdir/fopen > /dev/null
1799 ln $DIR/$tdir/flink $DIR/$tdir/flink2
1800 rm -f $DIR/$tdir/funlink2
1801 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
1803 get_times $DIR/$tdir/fopen OPEN_NEW2
1804 get_times $DIR/$tdir/flink LINK_NEW2
1805 get_times $DIR/$tdir/funlink UNLINK_NEW2
1806 get_times $DIR/$tdir/frename2 RENAME_NEW2
1807 echo ${OPEN_OLD[1]},${OPEN_NEW[$MTIME]},${OPEN_NEW2[$MTIME]}
1808 echo ${LINK_OLD[1]},${LINK_NEW[$MTIME]},${LINK_NEW2[$MTIME]}
1809 echo ${UNLINK_OLD[1]},${UNLINK_NEW[$MTIME]},${UNLINK_NEW2[$MTIME]}
1810 echo ${RENAME_OLD[1]},${RENAME_NEW[$MTIME]},${RENAME_NEW2[$MTIME]}
1812 [ ${OPEN_NEW2[$MTIME]} -eq ${OPEN_NEW[$MTIME]} ] || error "open file reverses mtime"
1813 [ ${LINK_NEW2[$MTIME]} -eq ${LINK_NEW[$MTIME]} ] || error "link file reverses mtime"
1814 [ ${UNLINK_NEW2[$MTIME]} -eq ${UNLINK_NEW[$MTIME]} ] || error "unlink file reverses mtime"
1815 [ ${RENAME_NEW2[$MTIME]} -eq ${RENAME_NEW[$MTIME]} ] || error "rename file reverses mtime"
1817 run_test 39b "mtime change on close ============================"
1821 touch -m -d "10 years ago" $DIR1/$tfile
1822 local MTIME1=`stat -c %y $DIR1/$tfile`
1823 echo hello >> $DIR1/$tfile
1824 local MTIME2=`stat -c %y $DIR1/$tfile`
1825 mv $DIR1/$tfile $DIR1/$tfile-1
1826 local MTIME3=`stat -c %y $DIR1/$tfile-1`
1827 [ "$MTIME2" = "$MTIME3" ] ||
1828 error "mtime ($MTIME2) changed (to $MTIME3) on rename (BZ#11063)"
1830 run_test 39c "mtime change on rename ==========================="
1833 dd if=/dev/zero of=$DIR/f40 bs=4096 count=1
1834 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/f40 && error
1835 $CHECKSTAT -t file -s 4096 $DIR/f40 || error
1837 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
1841 small_write $DIR/f41 18
1843 run_test 41 "test small file write + fstat ====================="
1845 count_ost_writes() {
1846 lctl get_param -n osc.*.stats |
1847 awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }'
1854 BG_DIRTY_RATIO_SAVE=10
1855 MAX_BG_DIRTY_RATIO=25
1859 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
1860 # dirty_ratio, dirty_background_ratio
1861 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
1862 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
1863 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
1864 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
1866 # if file not here, we are a 2.4 kernel
1867 kill -CONT `pidof kupdated`
1872 # setup the trap first, so someone cannot exit the test at the
1873 # exact wrong time and mess up a machine
1874 trap start_writeback EXIT
1875 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
1876 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
1877 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
1878 sysctl -w vm.dirty_writeback_centisecs=0
1879 # save and increase /proc/sys/vm/dirty_ratio
1880 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
1881 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
1882 # save and increase /proc/sys/vm/dirty_background_ratio
1883 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
1884 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
1886 # if file not here, we are a 2.4 kernel
1887 kill -STOP `pidof kupdated`
1891 # ensure that all stripes have some grant before we test client-side cache
1893 [ "$SETUP_TEST42" ] && return
1894 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
1895 dd if=/dev/zero of=$i bs=4k count=1
1901 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
1902 # file truncation, and file removal.
1905 cancel_lru_locks osc
1907 sync; sleep 1; sync # just to be safe
1908 BEFOREWRITES=`count_ost_writes`
1909 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
1910 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
1911 AFTERWRITES=`count_ost_writes`
1912 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
1913 error "$BEFOREWRITES < $AFTERWRITES"
1916 run_test 42a "ensure that we don't flush on close =============="
1920 cancel_lru_locks osc
1923 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
1924 BEFOREWRITES=`count_ost_writes`
1925 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
1926 AFTERWRITES=`count_ost_writes`
1927 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
1928 error "$BEFOREWRITES < $AFTERWRITES on unlink"
1930 BEFOREWRITES=`count_ost_writes`
1931 sync || error "sync: $?"
1932 AFTERWRITES=`count_ost_writes`
1933 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
1934 error "$BEFOREWRITES < $AFTERWRITES on sync"
1936 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
1940 run_test 42b "test destroy of file with cached dirty data ======"
1942 # if these tests just want to test the effect of truncation,
1943 # they have to be very careful. consider:
1944 # - the first open gets a {0,EOF}PR lock
1945 # - the first write conflicts and gets a {0, count-1}PW
1946 # - the rest of the writes are under {count,EOF}PW
1947 # - the open for truncate tries to match a {0,EOF}PR
1948 # for the filesize and cancels the PWs.
1949 # any number of fixes (don't get {0,EOF} on open, match
1950 # composite locks, do smarter file size management) fix
1951 # this, but for now we want these tests to verify that
1952 # the cancellation with truncate intent works, so we
1953 # start the file with a full-file pw lock to match against
1954 # until the truncate.
1959 cancel_lru_locks osc
1961 # prime the file with 0,EOF PW to match
1965 # now the real test..
1966 dd if=/dev/zero of=$file bs=1024 count=100
1967 BEFOREWRITES=`count_ost_writes`
1968 $TRUNCATE $file $offset
1969 cancel_lru_locks osc
1970 AFTERWRITES=`count_ost_writes`
1976 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
1977 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
1980 run_test 42c "test partial truncate of file with cached dirty data"
1984 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
1985 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
1988 run_test 42d "test complete truncate of file with cached dirty data"
1992 cp -p /bin/ls $DIR/$tdir/$tfile
1993 multiop $DIR/$tdir/$tfile Ow_c &
1995 # give multiop a chance to open
1998 $DIR/$tdir/$tfile && error || true
2001 run_test 43 "execution of file opened for write should return -ETXTBSY"
2005 cp -p `which multiop` $DIR/d43/multiop
2006 MULTIOP_PROG=$DIR/d43/multiop multiop_bg_pause $TMP/test43.junk O_c || return 1
2008 multiop $DIR/d43/multiop Oc && error "expected error, got success"
2009 kill -USR1 $MULTIOP_PID || return 2
2010 wait $MULTIOP_PID || return 3
2013 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
2017 cp -p `which multiop` $DIR/d43/multiop
2018 MULTIOP_PROG=$DIR/d43/multiop multiop_bg_pause $TMP/test43.junk O_c || return 1
2020 truncate $DIR/d43/multiop 0 && error "expected error, got success"
2021 kill -USR1 $MULTIOP_PID || return 2
2022 wait $MULTIOP_PID || return 3
2025 run_test 43b "truncate of file being executed should return -ETXTBSY"
2028 local testdir="$DIR/d43c"
2031 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
2032 ( cd $testdir && md5sum -c)
2034 run_test 43c "md5sum of copy into lustre========================"
2037 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
2038 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
2039 dd if=$DIR/f1 of=/dev/null bs=4k count=1
2041 run_test 44 "zero length read from a sparse stripe ============="
2044 local nstripe=`$LCTL lov_getconfig $DIR | grep default_stripe_count: | \
2046 [ -z "$nstripe" ] && skip "can't get stripe info" && return
2047 [ "$nstripe" -gt "$OSTCOUNT" ] && skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" && return
2048 local stride=`$LCTL lov_getconfig $DIR | grep default_stripe_size: | \
2050 if [ $nstripe -eq 0 -o $nstripe -eq -1 ] ; then
2051 nstripe=`$LCTL lov_getconfig $DIR | grep obd_count: | awk '{print $2}'`
2054 OFFSETS="0 $((stride/2)) $((stride-1))"
2055 for offset in $OFFSETS ; do
2056 for i in `seq 0 $((nstripe-1))`; do
2058 local GLOBALOFFSETS=""
2059 local size=$((((i + 2 * $nstripe )*$stride + $offset))) # Bytes
2060 ll_sparseness_write $DIR/d44a $size || error "ll_sparseness_write"
2061 GLOBALOFFSETS="$GLOBALOFFSETS $size"
2062 ll_sparseness_verify $DIR/d44a $GLOBALOFFSETS \
2063 || error "ll_sparseness_verify $GLOBALOFFSETS"
2065 for j in `seq 0 $((nstripe-1))`; do
2066 size=$((((j + $nstripe )*$stride + $offset))) # Bytes
2067 ll_sparseness_write $DIR/d44a $size || error "ll_sparseness_write"
2068 GLOBALOFFSETS="$GLOBALOFFSETS $size"
2070 ll_sparseness_verify $DIR/d44a $GLOBALOFFSETS \
2071 || error "ll_sparseness_verify $GLOBALOFFSETS"
2075 run_test 44a "test sparse pwrite ==============================="
2079 for d in `lctl get_param -n osc.*.cur_dirty_bytes`; do
2085 before=`dirty_osc_total`
2086 echo executing "\"$*\""
2088 after=`dirty_osc_total`
2089 echo before $before, after $after
2093 # Obtain grants from OST if it supports it
2094 echo blah > ${f}_grant
2097 do_dirty_record "echo blah > $f"
2098 [ $before -eq $after ] && error "write wasn't cached"
2099 do_dirty_record "> $f"
2100 [ $before -gt $after ] || error "truncate didn't lower dirty count"
2101 do_dirty_record "echo blah > $f"
2102 [ $before -eq $after ] && error "write wasn't cached"
2103 do_dirty_record "sync"
2104 [ $before -gt $after ] || error "writeback didn't lower dirty count"
2105 do_dirty_record "echo blah > $f"
2106 [ $before -eq $after ] && error "write wasn't cached"
2107 do_dirty_record "cancel_lru_locks osc"
2108 [ $before -gt $after ] || error "lock cancellation didn't lower dirty count"
2111 run_test 45 "osc io page accounting ============================"
2117 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
2118 # test tickles a bug where re-dirtying a page was failing to be mapped to the
2119 # objects offset and an assert hit when an rpc was built with 1023's mapped
2120 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
2125 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
2127 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
2128 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
2132 run_test 46 "dirtying a previously written page ================"
2134 # test_47 is removed "Device nodes check" is moved to test_28
2136 test_48a() { # bug 2399
2137 check_kernel_version 34 || return 0
2140 mv $DIR/d48a $DIR/d48.new || error "move directory failed"
2141 mkdir $DIR/d48a || error "recreate directory failed"
2142 touch foo || error "'touch foo' failed after recreating cwd"
2143 mkdir bar || error "'mkdir foo' failed after recreating cwd"
2144 if check_kernel_version 44; then
2145 touch .foo || error "'touch .foo' failed after recreating cwd"
2146 mkdir .bar || error "'mkdir .foo' failed after recreating cwd"
2148 ls . > /dev/null || error "'ls .' failed after recreating cwd"
2149 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
2150 cd . || error "'cd .' failed after recreating cwd"
2151 mkdir . && error "'mkdir .' worked after recreating cwd"
2152 rmdir . && error "'rmdir .' worked after recreating cwd"
2153 ln -s . baz || error "'ln -s .' failed after recreating cwd"
2154 cd .. || error "'cd ..' failed after recreating cwd"
2156 run_test 48a "Access renamed working dir (should return errors)="
2158 test_48b() { # bug 2399
2159 check_kernel_version 34 || return 0
2162 rmdir $DIR/d48b || error "remove cwd $DIR/d48b failed"
2163 touch foo && error "'touch foo' worked after removing cwd"
2164 mkdir foo && error "'mkdir foo' worked after removing cwd"
2165 if check_kernel_version 44; then
2166 touch .foo && error "'touch .foo' worked after removing cwd"
2167 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
2169 ls . > /dev/null && error "'ls .' worked after removing cwd"
2170 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
2171 is_patchless || ( cd . && error "'cd .' worked after removing cwd" )
2172 mkdir . && error "'mkdir .' worked after removing cwd"
2173 rmdir . && error "'rmdir .' worked after removing cwd"
2174 ln -s . foo && error "'ln -s .' worked after removing cwd"
2175 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
2177 run_test 48b "Access removed working dir (should return errors)="
2179 test_48c() { # bug 2350
2180 check_kernel_version 36 || return 0
2181 #lctl set_param debug=-1
2183 mkdir -p $DIR/d48c/dir
2185 $TRACE rmdir $DIR/d48c/dir || error "remove cwd $DIR/d48c/dir failed"
2186 $TRACE touch foo && error "'touch foo' worked after removing cwd"
2187 $TRACE mkdir foo && error "'mkdir foo' worked after removing cwd"
2188 if check_kernel_version 44; then
2189 touch .foo && error "'touch .foo' worked after removing cwd"
2190 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
2192 $TRACE ls . && error "'ls .' worked after removing cwd"
2193 $TRACE ls .. || error "'ls ..' failed after removing cwd"
2194 is_patchless || ( $TRACE cd . && error "'cd .' worked after removing cwd" )
2195 $TRACE mkdir . && error "'mkdir .' worked after removing cwd"
2196 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
2197 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
2198 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
2200 run_test 48c "Access removed working subdir (should return errors)"
2202 test_48d() { # bug 2350
2203 check_kernel_version 36 || return 0
2204 #lctl set_param debug=-1
2206 mkdir -p $DIR/d48d/dir
2208 $TRACE rmdir $DIR/d48d/dir || error "remove cwd $DIR/d48d/dir failed"
2209 $TRACE rmdir $DIR/d48d || error "remove parent $DIR/d48d failed"
2210 $TRACE touch foo && error "'touch foo' worked after removing parent"
2211 $TRACE mkdir foo && error "'mkdir foo' worked after removing parent"
2212 if check_kernel_version 44; then
2213 touch .foo && error "'touch .foo' worked after removing parent"
2214 mkdir .foo && error "'mkdir .foo' worked after removing parent"
2216 $TRACE ls . && error "'ls .' worked after removing parent"
2217 $TRACE ls .. && error "'ls ..' worked after removing parent"
2218 is_patchless || ( $TRACE cd . && error "'cd .' worked after recreate parent" )
2219 $TRACE mkdir . && error "'mkdir .' worked after removing parent"
2220 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
2221 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
2222 is_patchless || ( $TRACE cd .. && error "'cd ..' worked after removing parent" || true )
2224 run_test 48d "Access removed parent subdir (should return errors)"
2226 test_48e() { # bug 4134
2227 check_kernel_version 41 || return 0
2228 #lctl set_param debug=-1
2230 mkdir -p $DIR/d48e/dir
2232 $TRACE rmdir $DIR/d48e/dir || error "remove cwd $DIR/d48e/dir failed"
2233 $TRACE rmdir $DIR/d48e || error "remove parent $DIR/d48e failed"
2234 $TRACE touch $DIR/d48e || error "'touch $DIR/d48e' failed"
2235 $TRACE chmod +x $DIR/d48e || error "'chmod +x $DIR/d48e' failed"
2236 # On a buggy kernel addition of "touch foo" after cd .. will
2237 # produce kernel oops in lookup_hash_it
2238 touch ../foo && error "'cd ..' worked after recreate parent"
2240 $TRACE rm $DIR/d48e || error "rm '$DIR/d48e' failed"
2242 run_test 48e "Access to recreated parent subdir (should return errors)"
2248 ls /proc/$$/cwd || error
2250 run_test 50 "special situations: /proc symlinks ==============="
2252 test_51a() { # was test_51
2253 # bug 1516 - create an empty entry right after ".." then split dir
2256 $MCREATE $DIR/d51/bar
2258 createmany -m $DIR/d51/longfile 201
2260 while [ `ls -sd $DIR/d51 | awk '{ print $1 }'` -eq 4 ]; do
2261 $MCREATE $DIR/d51/longfile$FNUM
2266 ls -l $DIR/d51 > /dev/null || error
2268 run_test 51a "special situations: split htree with empty entry =="
2270 export NUMTEST=70000
2272 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
2273 [ $NUMFREE -lt 21000 ] && \
2274 skip "not enough free inodes ($NUMFREE)" && \
2277 check_kernel_version 40 || NUMTEST=31000
2278 [ $NUMFREE -lt $NUMTEST ] && NUMTEST=$(($NUMFREE - 50))
2281 createmany -d $DIR/d51b/t- $NUMTEST
2283 run_test 51b "mkdir .../t-0 --- .../t-$NUMTEST ===================="
2286 [ ! -d $DIR/d51b ] && skip "$DIR/51b missing" && \
2289 unlinkmany -d $DIR/d51b/t- $NUMTEST
2291 run_test 51c "rmdir .../t-0 --- .../t-$NUMTEST ===================="
2294 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping test with few OSTs" && return
2296 createmany -o $DIR/d51d/t- 1000
2297 $LFS getstripe $DIR/d51d > $TMP/files
2298 for N in `seq 0 $((OSTCOUNT - 1))`; do
2299 OBJS[$N]=`awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}' $TMP/files`
2300 OBJS0[$N]=`grep -A 1 idx $TMP/files | awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}'`
2301 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
2303 unlinkmany $DIR/d51d/t- 1000
2306 for N in `seq 1 $((OSTCOUNT - 1))`; do
2307 [ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ] && \
2308 error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
2309 [ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ] && \
2310 error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
2312 [ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ] && \
2313 error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
2314 [ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ] && \
2315 error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
2319 run_test 51d "check object distribution ===================="
2322 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
2325 chattr +a $DIR/d52a/foo || error "chattr +a failed"
2326 echo bar >> $DIR/d52a/foo || error "append bar failed"
2327 cp /etc/hosts $DIR/d52a/foo && error "cp worked"
2328 rm -f $DIR/d52a/foo 2>/dev/null && error "rm worked"
2329 link $DIR/d52a/foo $DIR/d52a/foo_link 2>/dev/null && error "link worked"
2330 echo foo >> $DIR/d52a/foo || error "append foo failed"
2331 mrename $DIR/d52a/foo $DIR/d52a/foo_ren && error "rename worked"
2332 # new lsattr displays 'e' flag for extents
2333 lsattr $DIR/d52a/foo | egrep -q "^-+a[-e]+ $DIR/d52a/foo" || error "lsattr"
2334 chattr -a $DIR/d52a/foo || error "chattr -a failed"
2336 rm -fr $DIR/d52a || error "cleanup rm failed"
2338 run_test 52a "append-only flag test (should return errors) ====="
2341 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
2344 chattr +i $DIR/d52b/foo || error "chattr +a failed"
2345 cat test > $DIR/d52b/foo && error "cat test worked"
2346 cp /etc/hosts $DIR/d52b/foo && error "cp worked"
2347 rm -f $DIR/d52b/foo 2>/dev/null && error "rm worked"
2348 link $DIR/d52b/foo $DIR/d52b/foo_link 2>/dev/null && error "link worked"
2349 echo foo >> $DIR/d52b/foo && error "echo worked"
2350 mrename $DIR/d52b/foo $DIR/d52b/foo_ren && error "rename worked"
2351 [ -f $DIR/d52b/foo ] || error
2352 [ -f $DIR/d52b/foo_ren ] && error
2353 lsattr $DIR/d52b/foo | egrep -q "^-+i[-e]+ $DIR/d52b/foo" || error "lsattr"
2354 chattr -i $DIR/d52b/foo || error "chattr failed"
2356 rm -fr $DIR/d52b || error "remove failed"
2358 run_test 52b "immutable flag test (should return errors) ======="
2360 test_52c() { # 12848 simulating client < 1.4.7
2361 [ -f $DIR/d52c/foo ] && chattr -i $DIR/d52b/foo
2364 # skip MDS_BFLAG_EXT_FLAGS in mdc_getattr_pack
2365 #define OBD_FAIL_MDC_OLD_EXT_FLAGS 0x802
2366 lctl set_param fail_loc=0x802
2367 chattr +i $DIR/d52c/foo || error
2368 lsattr $DIR/d52c/foo | egrep -q "^-+i[-e]+ $DIR/d52c/foo" || error "lsattr failed"
2369 chattr -i $DIR/d52c/foo || error "chattr failed"
2370 lctl set_param -n fail_loc=0
2372 rm -fr $DIR/d52c || error
2374 run_test 52c "immutable flag test for client < 1.4.7 ======="
2377 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2378 remote_ost_nodsh && skip "remote OST with nodsh" && return
2386 for VALUE in $(do_facet mds lctl get_param osc.*-osc.prealloc_last_id); do
2387 param=`echo ${VALUE[0]} | cut -d "=" -f1`;
2388 ostname=`echo $param | cut -d "." -f2 | cut -d - -f 1-2`
2389 mds_last=$(do_facet mds lctl get_param -n $param)
2390 ostnum=$(echo $ostname | sed "s/${FSNAME}-OST//g" | awk '{print ($1+1)}' )
2391 ost_last=$(do_facet ost$ostnum lctl get_param -n obdfilter.$ostname.last_id)
2392 echo "$ostname.last_id=$ost_last ; MDS.last_id=$mds_last"
2393 if [ $ost_last != $mds_last ]; then
2394 error "$ostname.last_id=$ost_last ; MDS.last_id=$mds_last"
2398 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
2401 [ ! -f "$SOCKETSERVER" ] && skip_env "no socketserver, skipping" && return
2402 [ ! -f "$SOCKETCLIENT" ] && skip_env "no socketclient, skipping" && return
2403 $SOCKETSERVER $DIR/socket
2404 $SOCKETCLIENT $DIR/socket || error
2405 $MUNLINK $DIR/socket
2407 run_test 54a "unix domain socket test =========================="
2413 dd if=/dev/zero of=$f bs=`page_size` count=1
2415 run_test 54b "char device works in lustre ======================"
2418 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
2419 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
2420 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
2422 for i in `seq 3 7`; do
2423 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
2433 loopdev="$DIR/loop54c"
2436 [ -z "$LOOPNUM" ] && echo "couldn't find empty loop device" && return
2437 mknod $loopdev b 7 $LOOPNUM
2438 echo "make a loop file system with $tfile on $loopdev ($LOOPNUM)..."
2439 dd if=/dev/zero of=$tfile bs=`page_size` seek=1024 count=1 > /dev/null
2440 losetup $loopdev $tfile || error "can't set up $loopdev for $tfile"
2441 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
2443 mount -t ext2 $loopdev $tdir || error "error mounting $loopdev on $tdir"
2444 dd if=/dev/zero of=$tdir/tmp bs=`page_size` count=30 || error "dd write"
2446 dd if=$tdir/tmp of=/dev/zero bs=`page_size` count=30 || error "dd read"
2451 run_test 54c "block device works in lustre ====================="
2457 [ "$string" = `echo $string > $f | cat $f` ] || error
2459 run_test 54d "fifo device works in lustre ======================"
2462 check_kernel_version 46 || return 0
2465 cp -aL /dev/console $f
2466 echo $string > $f || error
2468 run_test 54e "console/tty device works in lustre ======================"
2471 grep -q $FSTYPE /proc/filesystems && return 1
2473 grep -q $FSTYPE /proc/filesystems && return 1
2474 insmod ../$FSTYPE/$FSTYPE.o
2475 grep -q $FSTYPE /proc/filesystems && return 1
2476 insmod ../$FSTYPE/$FSTYPE.ko
2477 grep -q $FSTYPE /proc/filesystems && return 1
2484 client_only && skip "Not a server" && return
2485 mount -t $FSTYPE -o loop,iopen $EXT2_DEV $DIR/d55 || error "mounting"
2487 $IOPENTEST1 $DIR/d55/foo $DIR/d55 || error "running $IOPENTEST1"
2488 $IOPENTEST2 $DIR/d55 || error "running $IOPENTEST2"
2489 echo "check for $EXT2_DEV. Please wait..."
2491 $UMOUNT $DIR/d55 || error "unmounting"
2493 run_test 55 "check iopen_connect_dentry() ======================"
2495 test_56a() { # was test_56
2501 NUMFILESx2=$(($NUMFILES * 2))
2502 for i in `seq 1 $NUMFILES` ; do
2503 touch $DIR/d56/file$i
2504 touch $DIR/d56/dir/file$i
2507 # test lfs getstripe with --recursive
2508 FILENUM=`$GETSTRIPE --recursive $DIR/d56 | grep -c obdidx`
2509 [ $FILENUM -eq $NUMFILESx2 ] || error \
2510 "lfs getstripe --recursive $DIR/d56 wrong: found $FILENUM, expected $NUMFILESx2"
2511 FILENUM=`$GETSTRIPE $DIR/d56 | grep -c obdidx`
2512 [ $FILENUM -eq $NUMFILES ] || error \
2513 "lfs getstripe $DIR/d56 without --recursive wrong: found $FILENUM, expected $NUMFILES"
2514 echo "lfs getstripe --recursive passed."
2516 # test lfs getstripe with file instead of dir
2517 FILENUM=`$GETSTRIPE $DIR/d56/file1 | grep -c obdidx`
2518 [ $FILENUM -eq 1 ] || error \
2519 "lfs getstripe $DIR/d56/file1 wrong:found $FILENUM, expected 1"
2520 echo "lfs getstripe file passed."
2522 #test lfs getstripe with --verbose
2523 [ `$GETSTRIPE --verbose $DIR/d56 | grep -c lmm_magic` -eq $NUMFILES ] ||\
2524 error "lfs getstripe --verbose $DIR/d56 wrong: should find $NUMFILES lmm_magic info"
2525 [ `$GETSTRIPE $DIR/d56 | grep -c lmm_magic` -eq 0 ] || error \
2526 "lfs getstripe $DIR/d56 without --verbose wrong: should not show lmm_magic info"
2527 echo "lfs getstripe --verbose passed."
2529 #test lfs getstripe with --obd
2530 $GETSTRIPE --obd wrong_uuid $DIR/d56 2>&1 | grep -q "unknown obduuid" || \
2531 error "lfs getstripe --obd wrong_uuid should return error message"
2533 [ "$OSTCOUNT" -lt 2 ] && \
2534 skip_env "skipping other lfs getstripe --obd test" && return
2536 OBDUUID=$(lfs osts | grep ${OSTIDX}": " | awk '{print $2}')
2537 FILENUM=`$GETSTRIPE -ir $DIR/d56 | grep -x $OSTIDX | wc -l`
2538 FOUND=`$GETSTRIPE -r --obd $OBDUUID $DIR/d56 | grep obdidx | wc -l`
2539 [ $FOUND -eq $FILENUM ] || \
2540 error "lfs getstripe --obd wrong: found $FOUND, expected $FILENUM"
2541 [ `$GETSTRIPE -r -v --obd $OBDUUID $DIR/d56 | \
2542 sed '/^[ ]*'${OSTIDX}'[ ]/d' |\
2543 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l` -eq 0 ] || \
2544 error "lfs getstripe --obd wrong: should not show file on other obd"
2545 echo "lfs getstripe --obd passed."
2547 run_test 56a "check lfs getstripe ===================================="
2554 if [ ! -d "$DIR/${tdir}g" ] ; then
2555 mkdir -p $DIR/${tdir}g
2556 for i in `seq 1 $LOCAL_NUMFILES` ; do
2557 touch $DIR/${tdir}g/file$i
2559 for i in `seq 1 $LOCAL_NUMDIRS` ; do
2560 mkdir $DIR/${tdir}g/dir$i
2561 for j in `seq 1 $LOCAL_NUMFILES` ; do
2562 touch $DIR/${tdir}g/dir$i/file$j
2568 setup_56_special() {
2573 if [ ! -e "$TDIR/loop1b" ] ; then
2574 for i in `seq 1 $LOCAL_NUMFILES` ; do
2575 mknod $TDIR/loop${i}b b 7 $i
2576 mknod $TDIR/null${i}c c 1 3
2577 ln -s $TDIR/file1 $TDIR/link${i}l
2579 for i in `seq 1 $LOCAL_NUMDIRS` ; do
2580 mknod $TDIR/dir$i/loop${i}b b 7 $i
2581 mknod $TDIR/dir$i/null${i}c c 1 3
2582 ln -s $TDIR/dir$i/file1 $TDIR/dir$i/link${i}l
2590 setup_56 $NUMFILES $NUMDIRS
2592 EXPECTED=$(($NUMDIRS + 2))
2593 # test lfs find with -name
2594 for i in `seq 1 $NUMFILES` ; do
2595 NUMS=`$LFIND -name "*$i" $DIR/${tdir}g | wc -l`
2596 [ $NUMS -eq $EXPECTED ] || error \
2597 "lfs find -name \"*$i\" $DIR/${tdir}g wrong: found $NUMS, expected $EXPECTED"
2599 echo "lfs find -name passed."
2601 run_test 56g "check lfs find -name ============================="
2606 setup_56 $NUMFILES $NUMDIRS
2608 EXPECTED=$((($NUMDIRS+1)*($NUMFILES-1)+$NUMFILES))
2609 # test lfs find with ! -name
2610 for i in `seq 1 $NUMFILES` ; do
2611 NUMS=`$LFIND ! -name "*$i" $DIR/${tdir}g | wc -l`
2612 [ $NUMS -eq $EXPECTED ] || error \
2613 "lfs find ! -name \"*$i\" $DIR/${tdir}g wrong: found $NUMS, expected $EXPECTED"
2615 echo "lfs find ! -name passed."
2617 run_test 56h "check lfs find ! -name ============================="
2622 UUID=`$LFS osts $DIR/$tdir | awk '/0: / { print $2 }'`
2623 OUT="`$LFIND -ost $UUID $DIR/$tdir`"
2624 [ "$OUT" ] && error "$LFIND returned directory '$OUT'" || true
2626 run_test 56i "check 'lfs find -ost UUID' skips directories ======="
2629 setup_56_special $NUMFILES $NUMDIRS
2631 EXPECTED=$((NUMDIRS+1))
2632 NUMS=`$LFIND -type d $DIR/${tdir}g | wc -l`
2633 [ $NUMS -eq $EXPECTED ] || \
2634 error "lfs find -type d $DIR/${tdir}g wrong: found $NUMS, expected $EXPECTED"
2636 run_test 56j "check lfs find -type d ============================="
2639 setup_56_special $NUMFILES $NUMDIRS
2641 EXPECTED=$(((NUMDIRS+1) * NUMFILES))
2642 NUMS=`$LFIND -type f $DIR/${tdir}g | wc -l`
2643 [ $NUMS -eq $EXPECTED ] || \
2644 error "lfs find -type f $DIR/${tdir}g wrong: found $NUMS, expected $EXPECTED"
2646 run_test 56k "check lfs find -type f ============================="
2649 setup_56_special $NUMFILES $NUMDIRS
2651 EXPECTED=$((NUMDIRS + NUMFILES))
2652 NUMS=`$LFIND -type b $DIR/${tdir}g | wc -l`
2653 [ $NUMS -eq $EXPECTED ] || \
2654 error "lfs find -type b $DIR/${tdir}g wrong: found $NUMS, expected $EXPECTED"
2656 run_test 56l "check lfs find -type b ============================="
2659 setup_56_special $NUMFILES $NUMDIRS
2661 EXPECTED=$((NUMDIRS + NUMFILES))
2662 NUMS=`$LFIND -type c $DIR/${tdir}g | wc -l`
2663 [ $NUMS -eq $EXPECTED ] || \
2664 error "lfs find -type c $DIR/${tdir}g wrong: found $NUMS, expected $EXPECTED"
2666 run_test 56m "check lfs find -type c ============================="
2669 setup_56_special $NUMFILES $NUMDIRS
2671 EXPECTED=$((NUMDIRS + NUMFILES))
2672 NUMS=`$LFIND -type l $DIR/${tdir}g | wc -l`
2673 [ $NUMS -eq $EXPECTED ] || \
2674 error "lfs find -type l $DIR/${tdir}g wrong: found $NUMS, expected $EXPECTED"
2676 run_test 56n "check lfs find -type l ============================="
2679 setup_56 $NUMFILES $NUMDIRS
2682 utime $TDIR/file1 > /dev/null || error
2683 utime $TDIR/file2 > /dev/null || error
2684 utime $TDIR/dir1 > /dev/null || error
2685 utime $TDIR/dir2 > /dev/null || error
2686 utime $TDIR/dir1/file1 > /dev/null || error
2689 NUMS=`$LFIND -mtime +1 $TDIR | wc -l`
2690 [ $NUMS -eq $EXPECTED ] || \
2691 error "lfs find -mtime $TDIR wrong: found $NUMS, expected $EXPECTED"
2693 run_test 56o "check lfs find -mtime for old files =========================="
2696 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
2701 setup_56 $NUMFILES $NUMDIRS
2703 chown $RUNAS_ID $TDIR/file* || error "chown $DIR/${tdir}g/file$i failed"
2705 NUMS="`$LFIND -uid $RUNAS_ID $TDIR | wc -l`"
2706 [ $NUMS -eq $EXPECTED ] || \
2707 error "lfs find -uid $TDIR wrong: found $NUMS, expected $EXPECTED"
2709 EXPECTED=$(( ($NUMFILES+1) * $NUMDIRS + 1))
2710 NUMS="`$LFIND ! -uid $RUNAS_ID $TDIR | wc -l`"
2711 [ $NUMS -eq $EXPECTED ] || \
2712 error "lfs find ! -uid $TDIR wrong: found $NUMS, expected $EXPECTED"
2714 echo "lfs find -uid and ! -uid passed."
2716 run_test 56p "check lfs find -uid and ! -uid ==============================="
2719 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
2724 setup_56 $NUMFILES $NUMDIRS
2726 chgrp $RUNAS_ID $TDIR/file* || error "chown $DIR/${tdir}g/file$i failed"
2728 NUMS="`$LFIND -gid $RUNAS_ID $TDIR | wc -l`"
2729 [ $NUMS -eq $EXPECTED ] || \
2730 error "lfs find -gid $TDIR wrong: found $NUMS, expected $EXPECTED"
2732 EXPECTED=$(( ($NUMFILES+1) * $NUMDIRS + 1))
2733 NUMS="`$LFIND ! -gid $RUNAS_ID $TDIR | wc -l`"
2734 [ $NUMS -eq $EXPECTED ] || \
2735 error "lfs find ! -gid $TDIR wrong: found $NUMS, expected $EXPECTED"
2737 echo "lfs find -gid and ! -gid passed."
2739 run_test 56q "check lfs find -gid and ! -gid ==============================="
2742 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2744 local MNTDEV=$(get_mds_mntdev_proc_path)
2745 DEV=$(do_facet mds lctl get_param -n $MNTDEV)
2746 [ -z "$DEV" ] && error "can't access $MNTDEV"
2747 for DEV in $(do_facet mds lctl get_param -n $MNTDEV); do
2748 do_facet mds $DUMPE2FS -h $DEV > $TMP/t57a.dump || error "can't access $DEV"
2749 DEVISIZE=`awk '/Inode size:/ { print $3 }' $TMP/t57a.dump`
2750 [ "$DEVISIZE" -gt 128 ] || error "inode size $DEVISIZE"
2754 run_test 57a "verify MDS filesystem created with large inodes =="
2761 local FILEN=$dir/f$FILECOUNT
2763 rm -rf $dir || error "removing $dir"
2764 mkdir -p $dir || error "creating $dir"
2766 echo "mcreating $FILECOUNT files"
2767 createmany -m $dir/f 1 $FILECOUNT || \
2768 error "creating files in $dir"
2770 # verify that files do not have EAs yet
2771 $GETSTRIPE $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
2772 $GETSTRIPE $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
2774 local fsstat_dev=$(get_mds_fsstat_proc_path)
2775 local MDSFREE=$(do_facet mds lctl get_param -n $fsstat_dev.*.kbytesfree)
2776 local MDCFREE=$(lctl get_param -n mdc.*.kbytesfree | head -n 1)
2777 echo "opening files to create objects/EAs"
2779 for FILE in `seq -f $dir/f%g 1 $FILECOUNT`; do
2780 $OPENFILE -f O_RDWR $FILE > /dev/null || error "opening $FILE"
2783 # verify that files have EAs now
2784 $GETSTRIPE $FILE1 | grep -q "obdidx" || error "$FILE1 missing EA"
2785 $GETSTRIPE $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
2787 sleep 1 # make sure we get new statfs data
2788 local MDSFREE2=$(do_facet mds lctl get_param -n $fsstat_dev.*.kbytesfree)
2789 local MDCFREE2=$(lctl get_param -n mdc.*.kbytesfree | head -n 1)
2790 if [ "$MDCFREE2" -lt "$((MDCFREE - 8))" ]; then
2791 if [ "$MDSFREE" != "$MDSFREE2" ]; then
2792 error "MDC before $MDCFREE != after $MDCFREE2"
2794 echo "MDC before $MDCFREE != after $MDCFREE2"
2795 echo "unable to confirm if MDS has large inodes"
2800 run_test 57b "default LOV EAs are stored inside large inodes ==="
2803 [ -z "$(which wiretest 2>/dev/null)" ] && skip_env "could not find wiretest" && return
2806 run_test 58 "verify cross-platform wire constants =============="
2809 echo "touch 130 files"
2810 createmany -o $DIR/f59- 130
2812 unlinkmany $DIR/f59- 130
2815 # wait for commitment of removal
2817 run_test 59 "verify cancellation of llog records async ========="
2819 TEST60_HEAD="test_60 run $RANDOM"
2820 test_60a() { # was test_60
2821 [ ! -f run-llog.sh ] && skip_env "missing subtest run-llog.sh" && return
2822 log "$TEST60_HEAD - from kernel mode"
2825 run_test 60a "llog sanity tests run from kernel module =========="
2827 test_60b() { # bug 6411
2829 LLOG_COUNT=`dmesg | awk "/$TEST60_HEAD/{marker = 1; from_marker = 0;}
2841 [ $LLOG_COUNT -gt 50 ] && error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)"|| true
2843 run_test 60b "limit repeated messages from CERROR/CWARN ========"
2846 echo "create 5000 files"
2847 createmany -o $DIR/f60c- 5000
2848 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
2849 lctl set_param fail_loc=0x80000137
2850 unlinkmany $DIR/f60c- 5000
2852 run_test 60c "unlink file when mds full"
2855 SAVEPRINTK=$(lctl get_param -n printk)
2857 # verify "lctl mark" is even working"
2858 MESSAGE="test message ID $RANDOM $$"
2859 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
2860 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
2862 lctl set_param printk=0 || error "set lnet.printk failed"
2863 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
2864 MESSAGE="new test message ID $RANDOM $$"
2865 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
2866 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
2867 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
2869 lctl set_param -n printk="$SAVEPRINTK"
2871 run_test 60d "test printk console message masking"
2875 dd if=/dev/zero of=$f bs=`page_size` count=1
2876 cancel_lru_locks osc
2877 multiop $f OSMWUc || error
2880 run_test 61 "mmap() writes don't make sync hang ================"
2882 # bug 2330 - insufficient obd_match error checking causes LBUG
2886 cancel_lru_locks osc
2887 #define OBD_FAIL_OSC_MATCH 0x405
2888 lctl set_param fail_loc=0x405
2889 cat $f && error "cat succeeded, expect -EIO"
2890 lctl set_param fail_loc=0
2892 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
2893 # match every page all of the time.
2894 run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
2896 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
2897 test_63a() { # was test_63
2898 MAX_DIRTY_MB=`lctl get_param -n osc.*.max_dirty_mb | head -n 1`
2899 lctl set_param -n osc.*.max_dirty_mb 0
2900 for i in `seq 10` ; do
2901 dd if=/dev/zero of=$DIR/f63 bs=8k &
2907 lctl set_param -n osc.*.max_dirty_mb $MAX_DIRTY_MB
2908 rm -f $DIR/f63 || true
2910 run_test 63a "Verify oig_wait interruption does not crash ======="
2912 # bug 2248 - async write errors didn't return to application on sync
2913 # bug 3677 - async write errors left page locked
2916 lctl set_param debug=-1
2918 # ensure we have a grant to do async writes
2919 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
2922 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
2923 lctl set_param fail_loc=0x80000406
2924 multiop $DIR/$tfile Owy && \
2925 error "sync didn't return ENOMEM"
2926 sync; sleep 2; sync # do a real sync this time to flush page
2927 lctl get_param -n llite.*.dump_page_cache | grep locked && \
2928 error "locked page left in cache after async error" || true
2931 run_test 63b "async write errors should be returned to fsync ==="
2935 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
2937 run_test 64a "verify filter grant calculations (in kernel) ====="
2940 [ ! -f oos.sh ] && skip_env "missing subtest oos.sh" && return
2943 run_test 64b "check out-of-space detection on client ==========="
2945 # bug 1414 - set/get directories' stripe info
2949 $LVERIFY $DIR/d65 $DIR/d65/f1 || error "lverify failed"
2951 run_test 65a "directory with no stripe info ===================="
2955 $SETSTRIPE $DIR/d65 -s $(($STRIPESIZE * 2)) -i 0 -c 1 || error "setstripe"
2957 $LVERIFY $DIR/d65 $DIR/d65/f2 || error "lverify failed"
2959 run_test 65b "directory setstripe $(($STRIPESIZE * 2)) 0 1 ==============="
2962 if [ $OSTCOUNT -gt 1 ]; then
2964 $SETSTRIPE $DIR/d65 -s $(($STRIPESIZE * 4)) -i 1 \
2965 -c $(($OSTCOUNT - 1)) || error "setstripe"
2967 $LVERIFY $DIR/d65 $DIR/d65/f3 || error "lverify failed"
2970 run_test 65c "directory setstripe $(($STRIPESIZE * 4)) 1 $(($OSTCOUNT - 1))"
2974 [ $STRIPECOUNT -le 0 ] && sc=1 || sc=$(($STRIPECOUNT - 1))
2975 $SETSTRIPE $DIR/d65 -s $STRIPESIZE -c $sc || error "setstripe"
2976 touch $DIR/d65/f4 $DIR/d65/f5
2977 $LVERIFY $DIR/d65 $DIR/d65/f4 $DIR/d65/f5 || error "lverify failed"
2979 run_test 65d "directory setstripe $STRIPESIZE -1 stripe_count =============="
2984 $SETSTRIPE $DIR/d65 || error "setstripe"
2985 $GETSTRIPE -v $DIR/d65 | grep "Default" || error "no stripe info failed"
2987 $LVERIFY $DIR/d65 $DIR/d65/f6 || error "lverify failed"
2989 run_test 65e "directory setstripe defaults ======================="
2993 $RUNAS $SETSTRIPE $DIR/d65f && error "setstripe succeeded" || true
2995 run_test 65f "dir setstripe permission (should return error) ==="
2999 $SETSTRIPE $DIR/d65 -s $(($STRIPESIZE * 2)) -i 0 -c 1 || error "setstripe"
3000 $SETSTRIPE -d $DIR/d65 || error "setstripe"
3001 $GETSTRIPE -v $DIR/d65 | grep "Default" || \
3002 error "delete default stripe failed"
3004 run_test 65g "directory setstripe -d ==========================="
3008 $SETSTRIPE $DIR/d65 -s $(($STRIPESIZE * 2)) -i 0 -c 1 || error "setstripe"
3009 mkdir -p $DIR/d65/dd1
3010 [ "`$GETSTRIPE -v $DIR/d65 | grep "^count"`" == \
3011 "`$GETSTRIPE -v $DIR/d65/dd1 | grep "^count"`" ] || error "stripe info inherit failed"
3013 run_test 65h "directory stripe info inherit ===================="
3015 test_65i() { # bug6367
3016 $SETSTRIPE $MOUNT -s 65536 -c -1
3018 run_test 65i "set non-default striping on root directory (bug 6367)="
3020 test_65j() { # bug6367
3022 # if we aren't already remounting for each test, do so for this test
3023 if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
3024 cleanup || error "failed to unmount"
3027 $SETSTRIPE -d $MOUNT || error "setstripe failed"
3029 run_test 65j "set default striping on root directory (bug 6367)="
3031 test_65k() { # bug11679
3032 [ "$OSTCOUNT" -lt 2 ] && skip_env "too few OSTs" && return
3033 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3035 echo "Check OST status: "
3036 MDS_OSCS=`do_facet mds lctl dl | awk '/[oO][sS][cC].*md[ts]/ { print $4 }'`
3037 for OSC in $MDS_OSCS; do
3038 echo $OSC "is activate"
3039 do_facet mds lctl --device %$OSC activate
3041 do_facet client mkdir -p $DIR/$tdir
3042 for INACTIVE_OSC in $MDS_OSCS; do
3043 echo $INACTIVE_OSC "is Deactivate:"
3044 do_facet mds lctl --device %$INACTIVE_OSC deactivate
3045 for STRIPE_OSC in $MDS_OSCS; do
3046 STRIPE_OST=`osc_to_ost $STRIPE_OSC`
3047 STRIPE_INDEX=`do_facet mds lctl get_param -n lov.*md*.target_obd |
3048 grep $STRIPE_OST | awk -F: '{print $1}'`
3049 echo "$SETSTRIPE $DIR/$tdir/${STRIPE_INDEX} -i ${STRIPE_INDEX} -c 1"
3050 do_facet client $SETSTRIPE $DIR/$tdir/${STRIPE_INDEX} -i ${STRIPE_INDEX} -c 1
3052 [ $RC -ne 0 ] && error "setstripe should have succeeded"
3054 do_facet client rm -f $DIR/$tdir/*
3055 echo $INACTIVE_OSC "is Activate."
3056 do_facet mds lctl --device %$INACTIVE_OSC activate
3059 run_test 65k "validate manual striping works properly with deactivated OSCs"
3061 test_65l() { # bug 12836
3062 mkdir -p $DIR/$tdir/test_dir
3063 $SETSTRIPE $DIR/$tdir/test_dir -c -1
3064 $LFS find -mtime -1 $DIR/$tdir > /dev/null
3066 run_test 65l "lfs find on -1 stripe dir ========================"
3068 # bug 2543 - update blocks count on client
3071 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
3073 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
3074 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
3076 run_test 66 "update inode blocks count on client ==============="
3078 test_67a() { # was test_67 bug 3285 - supplementary group fails on MDS, passes on client
3079 [ "$RUNAS_ID" = "$UID" ] && skip "RUNAS_ID = UID = $UID -- skipping" && return
3080 check_kernel_version 35 || return 0
3082 chmod 771 $DIR/$tdir
3083 chgrp $RUNAS_ID $DIR/$tdir
3084 $RUNAS -u $RUNAS_ID -g $(($RUNAS_ID + 1)) -G1,2,$RUNAS_ID ls $DIR/$tdir
3086 GROUP_UPCALL=$(do_facet mds lctl get_param -n mds.*.group_upcall)
3087 [ -z "$GROUP_UPCALL" ] && \
3088 skip "lctl get_param failed! Useless to continue the test!" && return
3089 [ "$GROUP_UPCALL" = "NONE" -a $RC -eq 0 ] && \
3090 error "no-upcall passed" || true
3091 [ "$GROUP_UPCALL" != "NONE" -a $RC -ne 0 ] && \
3092 error "upcall failed" || true
3094 run_test 67a "supplementary group failure (should return error) ="
3099 do_facet mds lctl set_param -n mds.*.group_upcall NONE
3102 test_67b() { # bug 3285 - supplementary group fails on MDS, passes on client
3103 # needs to be in /etc/groups on MDS, gid == uid
3104 # Let's use RUNAS_ID
3105 T67_UID=${T67_UID:-$RUNAS_ID}
3107 [ "$UID" = "$T67_UID" ] && skip "UID = T67_UID = $UID -- skipping" && return
3108 check_kernel_version 35 || return 0
3109 do_facet mds grep -q ":$T67_UID:$T67_UID" /etc/passwd || \
3110 { skip "Need gid=$T67_UID group and gid == uid on mds !" && return; }
3112 GROUP_UPCALL=$(do_facet mds lctl get_param -n mds.*.group_upcall)
3113 [ -z "$GROUP_UPCALL" ] && \
3114 skip "lctl get_param failed! Useless to continue the test!" && return
3115 [ "$GROUP_UPCALL" != "NONE" ] && \
3116 skip "skip test - upcall=$GROUP_UPCALL" && return
3118 trap cleanup_67b EXIT
3120 chmod 771 $DIR/$tdir
3121 chgrp $T67_UID $DIR/$tdir
3122 local l_getgroups=$(do_facet mds which l_getgroups)
3123 do_facet mds lctl set_param -n mds.*.group_upcall $l_getgroups
3124 do_facet mds $l_getgroups -d $T67_UID
3125 $RUNAS -u $T67_UID -g 999 -G8,9,$T67_UID touch $DIR/$tdir/$tfile || \
3126 error "'touch $DIR/$tdir/$tfile' failed"
3127 [ -f $DIR/$tdir/$tfile ] || error "$DIR/$tdir/$tfile create error"
3130 run_test 67b "supplementary group test ========================="
3135 if [ ! -z "$LLOOP" ]; then
3136 swapoff $LLOOP || error "swapoff failed"
3137 $LCTL blockdev_detach $LLOOP || error "detach failed"
3145 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
3149 swapon -s | awk '($1 == "'$1'") { print $4 }'
3153 # excercise swapping to lustre by adding a high priority swapfile entry
3154 # and then consuming memory until it is used.
3156 [ "$UID" != 0 ] && skip_env "must run as root" && return
3157 lctl get_param -n devices | grep -q obdfilter && \
3158 skip "local OST" && return
3160 grep -q llite_lloop /proc/modules
3161 [ $? -ne 0 ] && skip_env "can't find module llite_lloop" && return
3163 [ -z "`$LCTL list_nids | grep -v tcp`" ] && \
3164 skip "can't reliably test swap with TCP" && return
3166 MEMTOTAL=`meminfo MemTotal`
3167 NR_BLOCKS=$((MEMTOTAL>>8))
3168 [[ $NR_BLOCKS -le 2048 ]] && NR_BLOCKS=2048
3170 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
3171 dd if=/dev/zero of=$DIR/f68 bs=64k seek=$NR_BLOCKS count=1
3174 $LCTL blockdev_attach $DIR/f68 $LLOOP || error "attach failed"
3176 trap cleanup_68 EXIT
3178 swapon -p 32767 $LLOOP || error "swapon $LLOOP failed"
3180 echo "before: `swapon -s | grep $LLOOP`"
3181 $MEMHOG $MEMTOTAL || error "error allocating $MEMTOTAL kB"
3182 echo "after: `swapon -s | grep $LLOOP`"
3183 SWAPUSED=`swap_used $LLOOP`
3187 [ $SWAPUSED -eq 0 ] && echo "no swap used???" || true
3189 run_test 68 "support swapping to Lustre ========================"
3191 # bug5265, obdfilter oa2dentry return -ENOENT
3192 # #define OBD_FAIL_OST_ENOENT 0x217
3194 remote_ost_nodsh && skip "remote OST with nodsh" && return
3197 $SETSTRIPE $f -c 1 -i 0
3199 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
3201 #define OBD_FAIL_OST_ENOENT 0x217
3202 do_facet ost1 lctl set_param fail_loc=0x217
3203 truncate $f 1 # vmtruncate() will ignore truncate() error.
3204 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
3206 do_facet ost1 lctl set_param fail_loc=0
3207 $DIRECTIO write $f 0 2 || error "write error"
3209 cancel_lru_locks osc
3210 $DIRECTIO read $f 0 1 || error "read error"
3212 #define OBD_FAIL_OST_ENOENT 0x217
3213 do_facet ost1 lctl set_param fail_loc=0x217
3214 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
3216 do_facet ost1 lctl set_param fail_loc=0
3219 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
3223 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
3225 run_test 71 "Running dbench on lustre (don't segment fault) ===="
3227 test_72() { # bug 5695 - Test that on 2.6 remove_suid works properly
3228 check_kernel_version 43 || return 0
3229 [ "$RUNAS_ID" = "$UID" ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
3231 # Check that testing environment is properly set up. Skip if not
3232 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS || {
3233 skip_env "User $RUNAS_ID does not exist - skipping"
3239 $RUNAS dd if=/dev/zero of=$DIR/f72 bs=512 count=1 || error
3240 # See if we are still setuid/sgid
3241 test -u $DIR/f72 -o -g $DIR/f72 && error "S/gid is not dropped on write"
3242 # Now test that MDS is updated too
3243 cancel_lru_locks mdc
3244 test -u $DIR/f72 -o -g $DIR/f72 && error "S/gid is not dropped on MDS"
3247 run_test 72 "Test that remove suid works properly (bug5695) ===="
3249 # bug 3462 - multiple simultaneous MDC requests
3253 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
3256 #define OBD_FAIL_MDS_PAUSE_OPEN 0x129
3257 lctl set_param fail_loc=0x80000129
3258 multiop $DIR/d73-1/f73-2 Oc &
3260 lctl set_param fail_loc=0
3262 multiop $DIR/d73-2/f73-3 Oc &
3266 wait $pid1 || return 1
3270 $CHECKSTAT -t file $DIR/d73-1/f73-1 || error "$DIR/d73-1/f73-1 not file"
3271 $CHECKSTAT -t file $DIR/d73-1/f73-2 || error "$DIR/d73-1/f73-2 not file"
3272 $CHECKSTAT -t file $DIR/d73-2/f73-3 || error "$DIR/d73-2/f73-3 not file"
3276 run_test 73 "multiple MDC requests (should not deadlock)"
3278 test_74a() { # bug 6149, 6184
3279 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
3281 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
3282 # will spin in a tight reconnection loop
3284 lctl set_param fail_loc=0x8000030e
3285 # get any lock that won't be difficult - lookup works.
3287 lctl set_param fail_loc=0
3290 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
3292 test_74b() { # bug 13310
3293 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
3295 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
3296 # will spin in a tight reconnection loop
3297 lctl set_param fail_loc=0x8000030e
3298 # get a "difficult" lock
3300 lctl set_param fail_loc=0
3303 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
3305 JOIN=${JOIN:-"lfs join"}
3312 [ $T75_PREP = "yes" ] && return
3313 echo "using F75=$F75, F128k=$F128k, FHEAD=$FHEAD, FTAIL=$FTAIL"
3315 dd if=/dev/urandom of=${F75}_128k bs=128k count=1 || error "dd failed"
3324 cp -p ${F128k} ${FHEAD}
3325 log "finished cp to $FHEAD"
3326 cp -p ${F128k} ${FTAIL}
3327 log "finished cp to $FTAIL"
3328 cat ${F128k} ${F128k} > ${F75}_sim_sim
3330 $JOIN ${FHEAD} ${FTAIL} || error "join ${FHEAD} ${FTAIL} error"
3331 log "finished join $FHEAD to ${F75}_sim_sim"
3332 cmp ${FHEAD} ${F75}_sim_sim || error "${FHEAD} ${F75}_sim_sim differ"
3333 log "finished cmp $FHEAD to ${F75}_sim_sim"
3334 $CHECKSTAT -a ${FTAIL} || error "tail ${FTAIL} still exist after join"
3336 run_test 75a "TEST join file ===================================="
3341 cp -p ${F128k} ${FTAIL}
3342 cat ${F75}_sim_sim >> ${F75}_join_sim
3343 cat ${F128k} >> ${F75}_join_sim
3344 $JOIN ${FHEAD} ${FTAIL} || error "join ${FHEAD} ${FTAIL} error"
3345 cmp ${FHEAD} ${F75}_join_sim || \
3346 error "${FHEAD} ${F75}_join_sim are different"
3347 $CHECKSTAT -a ${FTAIL} || error "tail ${FTAIL} exist after join"
3349 run_test 75b "TEST join file 2 =================================="
3354 cp -p ${F128k} ${FTAIL}
3355 cat ${F128k} >> ${F75}_sim_join
3356 cat ${F75}_join_sim >> ${F75}_sim_join
3357 $JOIN ${FTAIL} ${FHEAD} || error "join error"
3358 cmp ${FTAIL} ${F75}_sim_join || \
3359 error "${FTAIL} ${F75}_sim_join are different"
3360 $CHECKSTAT -a ${FHEAD} || error "tail ${FHEAD} exist after join"
3362 run_test 75c "TEST join file 3 =================================="
3367 cp -p ${F128k} ${FHEAD}
3368 cp -p ${F128k} ${FHEAD}_tmp
3369 cat ${F75}_sim_sim >> ${F75}_join_join
3370 cat ${F75}_sim_join >> ${F75}_join_join
3371 $JOIN ${FHEAD} ${FHEAD}_tmp || error "join ${FHEAD} ${FHEAD}_tmp error"
3372 $JOIN ${FHEAD} ${FTAIL} || error "join ${FHEAD} ${FTAIL} error"
3373 cmp ${FHEAD} ${F75}_join_join ||error "${FHEAD} ${F75}_join_join differ" $CHECKSTAT -a ${FHEAD}_tmp || error "${FHEAD}_tmp exist after join"
3374 $CHECKSTAT -a ${FTAIL} || error "tail ${FTAIL} exist after join (2)"
3376 run_test 75d "TEST join file 4 =================================="
3381 rm -rf ${FHEAD} || "delete join file error"
3383 run_test 75e "TEST join file 5 (remove joined file) ============="
3388 cp -p ${F128k} ${F75}_join_10_compare
3389 cp -p ${F128k} ${F75}_join_10
3390 for ((i = 0; i < 10; i++)); do
3391 cat ${F128k} >> ${F75}_join_10_compare
3392 cp -p ${F128k} ${FTAIL}
3393 $JOIN ${F75}_join_10 ${FTAIL} || \
3394 error "join ${F75}_join_10 ${FTAIL} error"
3395 $CHECKSTAT -a ${FTAIL} || error "tail file exist after join"
3397 cmp ${F75}_join_10 ${F75}_join_10_compare || \
3398 error "files ${F75}_join_10 ${F75}_join_10_compare differ"
3400 run_test 75f "TEST join file 6 (join 10 files) =================="
3403 [ ! -f ${F75}_join_10 ] && echo "${F75}_join_10 missing" && return
3404 $LFS getstripe ${F75}_join_10
3406 $OPENUNLINK ${F75}_join_10 ${F75}_join_10 || error "files unlink open"
3410 run_test 75g "TEST join file 7 (open unlink) ===================="
3413 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
3416 test_76() { # bug 1443
3417 DETH=$(grep deathrow /proc/kallsyms /proc/ksyms 2> /dev/null | wc -l)
3418 [ $DETH -eq 0 ] && skip "No _iget." && return 0
3419 BEFORE_INODES=`num_inodes`
3420 echo "before inodes: $BEFORE_INODES"
3422 [ "$SLOW" = "no" ] && COUNT=100
3423 for i in `seq $COUNT`; do
3427 AFTER_INODES=`num_inodes`
3428 echo "after inodes: $AFTER_INODES"
3429 [ $AFTER_INODES -gt $((BEFORE_INODES + 32)) ] && \
3430 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
3433 run_test 76 "destroy duplicate inodes in client inode cache ===="
3438 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums |
3441 lctl set_param -n osc.*.checksums=$1
3445 export ORIG_CSUM_TYPE=""
3446 CKSUM_TYPES=${CKSUM_TYPES:-"crc32 adler"}
3449 [ "$ORIG_CSUM_TYPE" ] || \
3450 ORIG_CSUM_TYPE=`lctl get_param -n osc.*osc-[^mM]*.checksum_type | sed 's/.*\[\(.*\)\].*/\1/g' \
3452 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
3453 log "set checksum type to $1"
3456 F77_TMP=$TMP/f77-temp
3459 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
3460 error "error writing to $F77_TMP"
3463 test_77a() { # bug 10889
3464 [ ! -f $F77_TMP ] && setup_f77
3466 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
3469 run_test 77a "normal checksum read/write operation ============="
3471 test_77b() { # bug 10889
3472 [ ! -f $F77_TMP ] && setup_f77
3473 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
3474 lctl set_param fail_loc=0x80000409
3476 dd if=$F77_TMP of=$DIR/f77b bs=1M count=$F77SZ conv=sync || \
3477 error "dd error: $?"
3478 lctl set_param fail_loc=0
3481 run_test 77b "checksum error on client write ===================="
3483 test_77c() { # bug 10889
3484 [ ! -f $DIR/f77b ] && skip "requires 77b - skipping" && return
3486 for algo in $CKSUM_TYPES; do
3487 cancel_lru_locks osc
3488 set_checksum_type $algo
3489 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
3490 lctl set_param fail_loc=0x80000408
3491 cmp $F77_TMP $DIR/f77b || error "file compare failed"
3492 lctl set_param fail_loc=0
3495 set_checksum_type $ORIG_CSUM_TYPE
3497 run_test 77c "checksum error on client read ==================="
3499 test_77d() { # bug 10889
3500 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
3501 lctl set_param fail_loc=0x80000409
3503 directio write $DIR/f77 0 $F77SZ $((1024 * 1024)) || \
3504 error "direct write: rc=$?"
3505 lctl set_param fail_loc=0
3508 run_test 77d "checksum error on OST direct write ==============="
3510 test_77e() { # bug 10889
3511 [ ! -f $DIR/f77 ] && skip "requires 77d - skipping" && return
3512 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
3513 lctl set_param fail_loc=0x80000408
3515 cancel_lru_locks osc
3516 directio read $DIR/f77 0 $F77SZ $((1024 * 1024)) || \
3517 error "direct read: rc=$?"
3518 lctl set_param fail_loc=0
3521 run_test 77e "checksum error on OST direct read ================"
3523 test_77f() { # bug 10889
3525 for algo in $CKSUM_TYPES; do
3526 cancel_lru_locks osc
3527 set_checksum_type $algo
3528 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
3529 lctl set_param fail_loc=0x409
3530 directio write $DIR/f77 0 $F77SZ $((1024 * 1024)) && \
3531 error "direct write succeeded"
3532 lctl set_param fail_loc=0
3534 set_checksum_type $ORIG_CSUM_TYPE
3537 run_test 77f "repeat checksum error on write (expect error) ===="
3539 test_77g() { # bug 10889
3540 remote_ost_nodsh && skip "remote OST with nodsh" && return
3542 [ ! -f $F77_TMP ] && setup_f77
3544 $SETSTRIPE $DIR/f77g -c 1 -i 0
3545 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
3546 do_facet ost1 lctl set_param fail_loc=0x8000021a
3548 dd if=$F77_TMP of=$DIR/f77g bs=1M count=$F77SZ || \
3549 error "write error: rc=$?"
3550 do_facet ost1 lctl set_param fail_loc=0
3553 run_test 77g "checksum error on OST write ======================"
3555 test_77h() { # bug 10889
3556 remote_ost_nodsh && skip "remote OST with nodsh" && return
3558 [ ! -f $DIR/f77g ] && skip "requires 77g - skipping" && return
3559 cancel_lru_locks osc
3560 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
3561 do_facet ost1 lctl set_param fail_loc=0x8000021b
3563 cmp $F77_TMP $DIR/f77g || error "file compare failed"
3564 do_facet ost1 lctl set_param fail_loc=0
3567 run_test 77h "checksum error on OST read ======================="
3569 test_77i() { # bug 13805
3570 #define OBD_FAIL_OSC_CONNECT_CKSUM 0x40b
3571 lctl set_param fail_loc=0x40b
3572 remount_client $MOUNT
3573 lctl set_param fail_loc=0
3574 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
3575 param=`echo ${VALUE[0]} | cut -d "=" -f1`
3576 algo=`lctl get_param -n $param | sed 's/.*\[\(.*\)\].*/\1/g'`
3577 [ "$algo" = "crc32" ] || error "algo set to $algo instead of crc32"
3579 remount_client $MOUNT
3581 run_test 77i "client not supporting OSD_CONNECT_CKSUM =========="
3583 test_77j() { # bug 13805
3584 #define OBD_FAIL_OSC_CKSUM_ADLER_ONLY 0x40c
3585 lctl set_param fail_loc=0x40c
3586 remount_client $MOUNT
3587 lctl set_param fail_loc=0
3588 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
3589 param=`echo ${VALUE[0]} | cut -d "=" -f1`
3590 algo=`lctl get_param -n $param | sed 's/.*\[\(.*\)\].*/\1/g'`
3591 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
3593 remount_client $MOUNT
3595 run_test 77j "client only supporting ADLER32 ===================="
3597 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
3601 test_78() { # bug 10901
3602 remote_ost || { skip_env "local OST" && return; }
3605 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
3606 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
3607 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
3608 echo "MemTotal: $MEMTOTAL"
3609 # reserve 256MB of memory for the kernel and other running processes,
3610 # and then take 1/2 of the remaining memory for the read/write buffers.
3611 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
3612 echo "Mem to use for directio: $MEMTOTAL"
3613 [ $F78SIZE -gt $MEMTOTAL ] && F78SIZE=$MEMTOTAL
3614 [ $F78SIZE -gt 512 ] && F78SIZE=512
3615 [ $F78SIZE -gt $((MAXFREE / 1024)) ] && F78SIZE=$((MAXFREE / 1024))
3616 SMALLESTOST=`lfs df $DIR |grep OST | awk '{print $4}' |sort -n |head -1`
3617 echo "Smallest OST: $SMALLESTOST"
3618 [ $SMALLESTOST -lt 10240 ] && \
3619 skip "too small OSTSIZE, useless to run large O_DIRECT test" && return 0
3621 [ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 5)) ] && \
3622 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 5))
3623 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
3624 echo "File size: $F78SIZE"
3625 $SETSTRIPE $DIR/$tfile -c -1 || error "setstripe failed"
3626 for i in `seq 1 $NSEQ`
3628 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
3629 echo directIO rdwr round $i of $NSEQ
3630 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
3635 run_test 78 "handle large O_DIRECT writes correctly ============"
3637 test_79() { # bug 12743
3638 wait_delete_completed
3640 BKTOTAL=$(calc_osc_kbytes kbytestotal)
3641 BKFREE=$(calc_osc_kbytes kbytesfree)
3642 BKAVAIL=$(calc_osc_kbytes kbytesavail)
3643 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
3644 DFTOTAL=`echo $STRING | cut -d, -f1`
3645 DFUSED=`echo $STRING | cut -d, -f2`
3646 DFAVAIL=`echo $STRING | cut -d, -f3`
3647 DFFREE=$(($DFTOTAL - $DFUSED))
3649 ALLOWANCE=$((64 * $OSTCOUNT))
3651 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
3652 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
3653 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
3655 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
3656 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
3657 error "df free($DFFREE) mismatch OST free($BKFREE)"
3659 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
3660 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
3661 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
3664 run_test 79 "df report consistency check ======================="
3666 test_80() { # bug 10718
3667 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
3669 local BEFORE=`date +%s`
3670 cancel_lru_locks osc
3671 local AFTER=`date +%s`
3672 local DIFF=$((AFTER-BEFORE))
3673 if [ $DIFF -gt 1 ] ; then
3674 error "elapsed for 1M@1T = $DIFF"
3678 run_test 80 "Page eviction is equally fast at high offsets too ===="
3681 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
3682 mkdir -p $DIR/d99cvsroot || error "mkdir $DIR/d99cvsroot failed"
3683 chown $RUNAS_ID $DIR/d99cvsroot || error "chown $DIR/d99cvsroot failed"
3684 local oldPWD=$PWD # bug 13584, use $TMP as working dir
3687 $RUNAS cvs -d $DIR/d99cvsroot init || error "cvs init failed"
3690 run_test 99a "cvs init ========================================="
3693 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
3694 [ ! -d $DIR/d99cvsroot ] && test_99a
3695 $RUNAS [ ! -w /tmp ] && skip "/tmp has wrong w permission -- skipping" && return
3696 cd /etc/init.d || error "cd /etc/init.d failed"
3697 # some versions of cvs import exit(1) when asked to import links or
3698 # files they can't read. ignore those files.
3699 TOIGNORE=$(find . -type l -printf '-I %f\n' -o \
3700 ! -perm +4 -printf '-I %f\n')
3701 $RUNAS cvs -d $DIR/d99cvsroot import -m "nomesg" $TOIGNORE \
3702 d99reposname vtag rtag > /dev/null || error "cvs import failed"
3704 run_test 99b "cvs import ======================================="
3707 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
3708 [ ! -d $DIR/d99cvsroot ] && test_99b
3709 cd $DIR || error "cd $DIR failed"
3710 mkdir -p $DIR/d99reposname || error "mkdir $DIR/d99reposname failed"
3711 chown $RUNAS_ID $DIR/d99reposname || \
3712 error "chown $DIR/d99reposname failed"
3713 $RUNAS cvs -d $DIR/d99cvsroot co d99reposname > /dev/null || \
3714 error "cvs co d99reposname failed"
3716 run_test 99c "cvs checkout ====================================="
3719 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
3720 [ ! -d $DIR/d99cvsroot ] && test_99c
3721 cd $DIR/d99reposname
3723 $RUNAS cvs add -m 'addmsg' foo99
3725 run_test 99d "cvs add =========================================="
3728 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
3729 [ ! -d $DIR/d99cvsroot ] && test_99c
3730 cd $DIR/d99reposname
3733 run_test 99e "cvs update ======================================="
3736 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
3737 [ ! -d $DIR/d99cvsroot ] && test_99d
3738 cd $DIR/d99reposname
3739 $RUNAS cvs commit -m 'nomsg' foo99
3741 run_test 99f "cvs commit ======================================="
3744 [ "$NETTYPE" = tcp ] || \
3745 { skip "TCP secure port test, not useful for NETTYPE=$NETTYPE" && \
3748 remote_ost_nodsh && skip "remote OST with nodsh" && return
3749 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3751 { skip "useless for local single node setup" && return; }
3753 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
3754 [ "$PROT" != "tcp" ] && continue
3755 RPORT=$(echo $REMOTE | cut -d: -f2)
3756 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
3759 LPORT=`echo $LOCAL | cut -d: -f2`
3760 if [ $LPORT -ge 1024 ]; then
3761 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
3763 error_exit "local: $LPORT > 1024, remote: $RPORT"
3766 [ "$rc" = 0 ] || error_exit "privileged port not found" )
3768 run_test 100 "check local port using privileged port ==========="
3770 function get_named_value()
3779 echo $line | sed "s/^$tag//"
3786 export CACHE_MAX=`lctl get_param -n llite/*/max_cached_mb | head -n 1`
3788 lctl set_param -n llite.*.max_cached_mb $CACHE_MAX
3796 [ "$CPU" = "UML" ] && nreads=1000
3797 local cache_limit=32
3799 lctl set_param -n osc.*.rpc_stats 0
3800 trap cleanup_101 EXIT
3802 lctl set_param -n llite.*.read_ahead_stats 0
3803 lctl set_param -n llite.*.max_cached_mb $cache_limit
3806 # randomly read 10000 of 64K chunks from file 3x 32MB in size
3808 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
3809 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
3812 for s in `lctl get_param -n llite.*.read_ahead_stats | \
3813 get_named_value 'read but discarded' | cut -d" " -f1`; do
3814 discard=$(($discard + $s))
3818 if [ $(($discard * 10)) -gt $nreads ] ;then
3819 lctl get_param osc.*.rpc_stats
3820 lctl get_param llite.*.read_ahead_stats
3821 error "too many ($discard) discarded pages"
3823 rm -f $DIR/$tfile || true
3825 run_test 101 "check read-ahead for random reads ================"
3827 export SETUP_TEST101b=no
3829 [ "$SETUP_TEST101b" = "yes" ] && return
3832 STRIPE_COUNT=$OSTCOUNT
3835 trap cleanup_101 EXIT
3836 # prepare the read-ahead file
3837 $SETSTRIPE $DIR/$tfile -s $STRIPE_SIZE -i $STRIPE_OFFSET -c $OSTCOUNT
3839 dd if=/dev/zero of=$DIR/$tfile bs=1024k count=100 2> /dev/null
3845 rm -rf $DIR/$tdir $DIR/$tfile
3850 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
3855 local STRIPE_SIZE=1048576
3856 local RA_INC=1048576
3857 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
3858 local FILE_LENGTH=$((64*100))
3859 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
3860 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
3861 DISCARD=`$LCTL get_param -n llite.*.read_ahead_stats | \
3862 get_named_value 'read but discarded' | \
3863 cut -d" " -f1 | calc_total`
3865 if [ $DISCARD -gt $discard_limit ]; then
3866 lctl get_param llite.*.read_ahead_stats
3867 error "Too many ($DISCARD) discarded pages (size ${READ_SIZE})"
3869 echo "Read-ahead success for size ${READ_SIZE}"
3874 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs for stride-read" && return
3875 local STRIPE_SIZE=1048576
3876 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
3877 local FILE_LENGTH=$((STRIPE_SIZE*100))
3878 local ITERATION=$((FILE_LENGTH/STRIDE_SIZE))
3879 # prepare the read-ahead file
3881 cancel_lru_locks osc
3882 for BIDX in 2 4 8 16 32 64 128 256; do
3883 local BSIZE=$((BIDX*4096))
3884 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
3885 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
3886 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
3887 $LCTL set_param -n llite.*.read_ahead_stats 0
3888 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
3889 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
3890 cancel_lru_locks osc
3891 ra_check_101b $BSIZE
3895 run_test 101b "check stride-io mode read-ahead ================="
3898 local STRIPE_SIZE=1048576
3899 local FILE_LENGTH=$((STRIPE_SIZE*100))
3904 cancel_lru_locks osc
3905 $LCTL set_param osc.*.rpc_stats 0
3906 $READS -f $DIR/$tfile -s$FILE_LENGTH -b65536 -n$nreads -t 180
3907 for OSC in `$LCTL get_param -N osc.*`
3909 if [ "$OSC" == "osc.num_refs" ]; then
3912 lines=`$LCTL get_param -n ${OSC}.rpc_stats | wc | awk '{print $1}'`
3913 if [ $lines -le 20 ]; then
3917 rpc4k=$($LCTL get_param -n $OSC | awk '$1 == "1:" { print $2; exit; }')
3918 rpc8k=$($LCTL get_param -n $OSC | awk '$1 == "2:" { print $2; exit; }')
3919 rpc16k=$($LCTL get_param -n $OSC | awk '$1 == "4:" { print $2; exit; }')
3920 rpc32k=$($LCTL get_param -n $OSC | awk '$1 == "8:" { print $2; exit; }')
3922 [ $rpc4k != 0 ] && error "Small 4k read IO ${rpc4k}!"
3923 [ $rpc8k != 0 ] && error "Small 8k read IO ${rpc8k}!"
3924 [ $rpc16k != 0 ] && error "Small 16k read IO ${rpc16k}!"
3925 [ $rpc32k != 0 ] && error "Small 32k read IO ${rpc32k}!"
3927 echo "Small rpc check passed!"
3928 rpc64k=$($LCTL get_param -n $OSC | awk '$1 == "16:" { print $2; exit; }')
3929 rpc128k=$($LCTL get_param -n $OSC | awk '$1 == "32:" { print $2; exit; }')
3930 rpc256k=$($LCTL get_param -n $OSC | awk '$1 == "64:" { print $2; exit; }')
3931 rpc512k=$($LCTL get_param -n $OSC | awk '$1 == "128:" { print $2; exit; }')
3932 rpc1024k=$($LCTL get_param -n $OSC | awk '$1 == "256:" { print $2; exit; }')
3934 [ $rpc64k == 0 ] && error "No 64k readahead IO ${rpc64k}"
3935 [ $rpc128k == 0 ] && error "No 128k readahead IO ${rpc128k}"
3936 [ $rpc256k == 0 ] && error "No 256k readahead IO ${rpc256k}"
3937 [ $rpc512k == 0 ] && error "No 512k readahead IO ${rpc256k}"
3938 [ $rpc1024k == 0 ] && error "No 1024k readahead IO ${rpc1024k}"
3939 echo "Big rpc check passed!"
3944 run_test 101c "check stripe_size aligned read-ahead ================="
3947 lctl get_param -n llite.*.max_read_ahead_mb | head -n 1
3948 lctl set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
3952 local file=$DIR/$tfile
3953 local size=${FILESIZE_101c:-500}
3954 local ra_MB=${READAHEAD_MB:-40}
3956 local space=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
3957 [ $space -gt $((size / 1024)) ] ||
3958 { skip "Need free space ${size}M, have $space" && return; }
3960 echo Creating ${size}M test file $file
3961 dd if=/dev/zero of=$file bs=1M count=$size
3962 echo Cancel LRU locks on lustre client to flush the client cache
3963 cancel_lru_locks osc
3965 echo Disable read-ahead
3966 local old_READAHEAD=$(set_read_ahead 0)
3968 echo Reading the test file $file with read-ahead disabled
3969 time_ra_OFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$size")
3971 echo Cancel LRU locks on lustre client to flush the client cache
3972 cancel_lru_locks osc
3973 echo Enable read-ahead with ${ra_MB}MB
3974 set_read_ahead $ra_MB
3976 echo Reading the test file $file with read-ahead enabled
3977 time_ra_ON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$size")
3979 echo read-ahead disabled time read $time_ra_OFF
3980 echo read-ahead enabled time read $time_ra_ON
3982 set_read_ahead $old_READAHEAD
3985 [ $time_ra_ON -lt $time_ra_OFF ] ||
3986 error "read-ahead enabled time read (${time_ra_ON}s) is more than
3987 read-ahead disabled time read (${time_ra_OFF}s) filesize ${size}M"
3989 run_test 101d "file read with and without read-ahead enabled ================="
3991 export SETUP_TEST102=no
3993 [ "$SETUP_TEST102" = "yes" ] && return
3995 chown $RUNAS_ID $DIR/$tdir
3998 STRIPE_COUNT=$OSTCOUNT
3999 [ $OSTCOUNT -gt 4 ] && STRIPE_COUNT=4
4001 trap cleanup_test102 EXIT
4003 $1 $SETSTRIPE $tdir -s $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT
4007 for count in `seq 1 $STRIPE_COUNT`
4009 for offset in `seq 0 $[$STRIPE_COUNT - 1]`
4011 local stripe_size=`expr $STRIPE_SIZE \* $num`
4012 local file=file"$num-$offset-$count"
4013 $1 $SETSTRIPE $file -s $stripe_size -i $offset -c $count
4019 $1 $TAR cf $TMP/f102.tar $tdir --xattrs
4025 [ "$SETUP_TEST102" = "yes" ] || return 0
4031 local testfile=$DIR/xattr_testfile
4036 [ "$UID" != 0 ] && skip_env "must run as root" && return
4037 [ -z "`lctl get_param -n mdc.*.connect_flags | grep xattr`" ] &&
4038 skip_env "must have user_xattr" && return
4039 [ -z "$(which setfattr 2>/dev/null)" ] && skip_env "could not find setfattr" && return
4041 echo "set/get xattr..."
4042 setfattr -n trusted.name1 -v value1 $testfile || error
4043 [ "`getfattr -n trusted.name1 $testfile 2> /dev/null | \
4044 grep "trusted.name1"`" == "trusted.name1=\"value1\"" ] || error
4046 setfattr -n user.author1 -v author1 $testfile || error
4047 [ "`getfattr -n user.author1 $testfile 2> /dev/null | \
4048 grep "user.author1"`" == "user.author1=\"author1\"" ] || error
4051 setfattr -n trusted.name2 -v value2 $testfile || error
4052 setfattr -n trusted.name3 -v value3 $testfile || error
4053 [ `getfattr -d -m "^trusted" $testfile 2> /dev/null | \
4054 grep "trusted.name" | wc -l` -eq 3 ] || error
4057 setfattr -n user.author2 -v author2 $testfile || error
4058 setfattr -n user.author3 -v author3 $testfile || error
4059 [ `getfattr -d -m "^user" $testfile 2> /dev/null | \
4060 grep "user" | wc -l` -eq 3 ] || error
4062 echo "remove xattr..."
4063 setfattr -x trusted.name1 $testfile || error
4064 getfattr -d -m trusted $testfile 2> /dev/null | \
4065 grep "trusted.name1" && error || true
4067 setfattr -x user.author1 $testfile || error
4068 getfattr -d -m user $testfile 2> /dev/null | \
4069 grep "user.author1" && error || true
4071 # b10667: setting lustre special xattr be silently discarded
4072 echo "set lustre special xattr ..."
4073 setfattr -n "trusted.lov" -v "invalid value" $testfile || error
4077 run_test 102a "user xattr test =================================="
4080 # b10930: get/set/list trusted.lov xattr
4081 echo "get/set/list trusted.lov xattr ..."
4082 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
4083 local testfile=$DIR/$tfile
4084 $SETSTRIPE -s 65536 -i 1 -c 2 $testfile || error "setstripe failed"
4085 getfattr -d -m "^trusted" $testfile 2> /dev/null | \
4086 grep "trusted.lov" || error "can't get trusted.lov from $testfile"
4088 local testfile2=${testfile}2
4089 local value=`getfattr -n trusted.lov $testfile 2> /dev/null | \
4090 grep "trusted.lov" |sed -e 's/[^=]\+=//'`
4093 setfattr -n trusted.lov -v $value $testfile2
4094 local tmp_file=${testfile}3
4095 $GETSTRIPE -v $testfile2 > $tmp_file
4096 local stripe_size=`grep "size" $tmp_file| awk '{print $2}'`
4097 local stripe_count=`grep "count" $tmp_file| awk '{print $2}'`
4098 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
4099 [ $stripe_count -eq 2 ] || error "stripe count $stripe_count != 2"
4101 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
4104 # b10930: get/set/list lustre.lov xattr
4105 echo "get/set/list lustre.lov xattr ..."
4106 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
4108 chown $RUNAS_ID $DIR/$tdir
4109 local testfile=$DIR/$tdir/$tfile
4110 $RUNAS $SETSTRIPE -s 65536 -i 1 -c 2 $testfile||error "setstripe failed"
4111 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
4112 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
4114 local testfile2=${testfile}2
4115 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
4116 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
4118 $RUNAS $MCREATE $testfile2
4119 $RUNAS setfattr -n lustre.lov -v $value $testfile2
4120 local tmp_file=${testfile}3
4121 $RUNAS $GETSTRIPE -v $testfile2 > $tmp_file
4122 local stripe_size=`grep "size" $tmp_file| awk '{print $2}'`
4123 local stripe_count=`grep "count" $tmp_file| awk '{print $2}'`
4124 [ "$stripe_size" -eq 65536 ] || error "stripe size $stripe_size != 65536"
4125 [ "$stripe_count" -eq 2 ] || error "stripe count $stripe_count != 2"
4127 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
4129 compare_stripe_info1() {
4130 local stripe_index_all_zero=1
4134 for count in `seq 1 $STRIPE_COUNT`
4136 for offset in `seq 0 $[$STRIPE_COUNT - 1]`
4138 local size=`expr $STRIPE_SIZE \* $num`
4139 local file=file"$num-$offset-$count"
4140 get_stripe_info client $PWD/$file "$1"
4141 if [ $stripe_size -ne $size ]; then
4142 error "$file: different stripe size $stripe_size, expected $size" && return
4144 if [ $stripe_count -ne $count ]; then
4145 error "$file: different stripe count $stripe_count, expected $count" && return
4147 if [ $stripe_index -ne 0 ]; then
4148 stripe_index_all_zero=0
4153 [ $stripe_index_all_zero -eq 1 ] && error "all files are being extracted starting from OST index 0"
4158 [ -n "$(which tar 2>/dev/null)" ] && strings $(which tar) | grep -q lustre && echo tar
4162 # b10930: tar test for trusted.lov xattr
4163 TAR=$(find_lustre_tar)
4164 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
4165 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
4168 $TAR xf $TMP/f102.tar -C $DIR/d102d --xattrs
4170 compare_stripe_info1
4172 run_test 102d "tar restore stripe info from tarfile,not keep osts ==========="
4175 # b10930: tar test for trusted.lov xattr
4176 TAR=$(find_lustre_tar)
4177 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
4178 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
4182 $TAR cf - --xattrs $tdir | $TAR xf - --xattrs -C $DIR/d102f
4184 compare_stripe_info1
4186 run_test 102f "tar copy files, not keep osts ==========="
4188 test_102h() { # bug 15777
4189 [ -z $(lctl get_param -n mdc.*.connect_flags | grep xattr) ] &&
4190 skip "must have user_xattr" && return
4191 [ -z "$(which setfattr 2>/dev/null)" ] &&
4192 skip_env "could not find setfattr" && return
4197 VALUE=datadatadatadatadatadatadatadata
4198 while [ $(echo $VALUE | wc -c) -lt $XSIZE ]; do
4199 VALUE="$VALUE$VALUE"
4201 log "save $XBIG on $DIR/$tfile"
4202 setfattr -n $XBIG -v "$VALUE" $DIR/$tfile ||
4203 error "saving $XBIG on $DIR/$tfile failed"
4204 ORIG=$(getfattr -n $XBIG $DIR/$tfile 2> /dev/null | grep $XBIG)
4205 OSIZE=$(echo $ORIG | wc -c)
4206 [ $OSIZE -lt $XSIZE ] && error "set $XBIG too small ($OSIZE < $XSIZE)"
4209 log "save $XSML on $DIR/$tfile"
4210 setfattr -n $XSML -v val $DIR/$tfile ||
4211 error "saving $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 saving $XSML"
4219 log "grow $XSML on $DIR/$tfile"
4220 setfattr -n $XSML -v "$VALUE" $DIR/$tfile ||
4221 error "growing $XSML on $DIR/$tfile failed"
4222 NEW=$(getfattr -n $XBIG $DIR/$tfile 2> /dev/null | grep $XBIG)
4223 if [ "$NEW" != "$ORIG" ]; then
4226 error "$XBIG different after growing $XSML"
4228 log "$XBIG still valid after growing $XSML"
4230 run_test 102h "grow xattr from inside inode to external block"
4232 test_102i() { # bug 17038
4234 ln -s $DIR/$tfile $DIR/${tfile}link
4235 getfattr -n trusted.lov $DIR/$tfile || error "lgetxattr on $DIR/$tfile failed"
4236 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"
4237 rm -f $DIR/$tfile $DIR/${tfile}link
4239 run_test 102i "lgetxattr test on symbolic link ============"
4242 TAR=$(find_lustre_tar)
4243 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
4244 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
4245 setup_test102 "$RUNAS"
4247 chown $RUNAS_ID $DIR/d102j
4248 $RUNAS $TAR xf $TMP/f102.tar -C $DIR/d102j --xattrs
4250 compare_stripe_info1 "$RUNAS"
4252 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
4258 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
4263 [ "$UID" != 0 ] && skip_env "must run as root" && return
4264 [ -z "$(lctl get_param mdc.*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
4265 [ -z "$(which setfacl 2>/dev/null)" ] && skip_env "could not find setfacl" && return
4271 echo "performing cp ..."
4272 run_acl_subtest cp || error
4273 echo "performing getfacl-noacl..."
4274 run_acl_subtest getfacl-noacl > /dev/null || error "getfacl-noacl test failed"
4275 echo "performing misc..."
4276 run_acl_subtest misc > /dev/null || error "misc test failed"
4277 # XXX add back permission test when we support supplementary groups.
4278 # echo "performing permissions..."
4279 # run_acl_subtest permissions || error
4280 echo "performing setfacl..."
4281 run_acl_subtest setfacl > /dev/null || error "setfacl test failed"
4283 # inheritance test got from HP
4284 echo "performing inheritance..."
4285 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
4286 chmod +x make-tree || error "chmod +x failed"
4287 run_acl_subtest inheritance > /dev/null || error "inheritance test failed"
4293 run_test 103 "acl test ========================================="
4297 lfs df || error "lfs df failed"
4298 lfs df -ih || error "lfs df -ih failed"
4299 lfs df -h $DIR || error "lfs df -h $DIR failed"
4300 lfs df -i $DIR || error "lfs df -i $DIR failed"
4301 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
4302 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
4304 OSC=`lctl get_param -n devices | awk '/-osc-|OSC.*MNT/ {print $4}' | head -n 1`
4305 lctl --device %$OSC deactivate
4306 lfs df || error "lfs df with deactivated OSC failed"
4307 lctl --device %$OSC recover
4308 lfs df || error "lfs df with reactivated OSC failed"
4310 run_test 104 "lfs df [-ih] [path] test ========================="
4313 # doesn't work on 2.4 kernels
4315 if [ -n "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ];
4317 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
4319 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
4322 run_test 105a "flock when mounted without -o flock test ========"
4326 if [ -n "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ];
4328 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
4330 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
4333 run_test 105b "fcntl when mounted without -o flock test ========"
4337 if [ -n "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ];
4339 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
4341 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
4344 run_test 105c "lockf when mounted without -o flock test ========"
4346 test_105d() { # bug 15924
4348 [ -z "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ] && \
4349 skip "mount w/o flock enabled" && return
4350 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
4351 $LCTL set_param fail_loc=0x80000315
4352 flocks_test 2 $DIR/$tdir
4354 run_test 105d "flock race (should not freeze) ========"
4356 test_106() { #bug 10921
4358 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
4359 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
4361 run_test 106 "attempt exec of dir followed by chown of that dir"
4370 local save_pattern=$(sysctl -n kernel.core_pattern)
4371 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
4372 sysctl -w kernel.core_pattern=$file
4373 sysctl -w kernel.core_uses_pid=0
4381 kill -s 11 $SLEEPPID
4383 if [ -e $file ]; then
4384 size=`stat -c%s $file`
4385 [ $size -eq 0 ] && error "Zero length core file $file"
4387 error "Fail to create core file $file"
4390 sysctl -w kernel.core_pattern=$save_pattern
4391 sysctl -w kernel.core_uses_pid=$save_uses_pid
4394 run_test 107 "Coredump on SIG"
4397 OSTIO_pre=$(ps -e|grep ll_ost_io|awk '{print $4}'|sort -n|tail -1|\
4399 [ -z "$OSTIO_pre" ] && skip "no OSS threads" && \
4401 echo "Starting with $OSTIO_pre threads"
4404 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
4405 [ $NUMFREE -lt $NUMTEST ] && NUMTEST=$(($NUMFREE - 1000))
4406 echo "$NUMTEST creates/unlinks"
4408 createmany -o $DIR/$tdir/$tfile $NUMTEST
4409 unlinkmany $DIR/$tdir/$tfile $NUMTEST
4411 OSTIO_post=$(ps -e|grep ll_ost_io|awk '{print $4}'|sort -n|tail -1|\
4414 # don't return an error
4415 [ $OSTIO_post -eq $OSTIO_pre ] && echo \
4416 "WARNING: No new ll_ost_io threads were created ($OSTIO_pre)" &&\
4417 echo "This may be fine, depending on what ran before this test" &&\
4418 echo "and how fast this system is." && return
4420 echo "Started with $OSTIO_pre threads, ended with $OSTIO_post"
4422 run_test 115 "verify dynamic thread creation===================="
4425 wait_delete_completed
4426 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC][-_]*.kbytesavail))
4427 echo OST kbytes available: ${AVAIL[@]}
4428 MAXI=0; MAXV=${AVAIL[0]}
4429 MINI=0; MINV=${AVAIL[0]}
4430 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
4431 #echo OST $i: ${AVAIL[i]}kb
4432 if [ ${AVAIL[i]} -gt $MAXV ]; then
4433 MAXV=${AVAIL[i]}; MAXI=$i
4435 if [ ${AVAIL[i]} -lt $MINV ]; then
4436 MINV=${AVAIL[i]}; MINI=$i
4439 echo Min free space: OST $MINI: $MINV
4440 echo Max free space: OST $MAXI: $MAXV
4444 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
4446 echo -n "Free space priority "
4447 lctl get_param -n lov.*.qos_prio_free
4450 [ $MINV -gt 960000 ] && skip "too much free space in OST$MINI" &&\
4453 # generate uneven OSTs
4454 mkdir -p $DIR/$tdir/OST${MINI}
4457 echo "Filling 25% remaining space in OST${MINI} with ${FILL}Kb"
4458 $SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI}||error "setstripe failed"
4460 while [ $FILL -gt 0 ]; do
4461 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i bs=2M count=1 2>/dev/null
4462 FILL=$(($FILL - 2048))
4471 DIFF=$(($MAXV - $MINV))
4472 DIFF2=$(($DIFF * 100 / $MINV))
4473 echo -n "diff=${DIFF}=${DIFF2}% must be > 20% for QOS mode..."
4474 if [ $DIFF2 -gt 20 ]; then
4477 echo "failed - QOS mode won't be used"
4478 error_ignore "QOS imbalance criteria not met"
4482 MINI1=$MINI; MINV1=$MINV
4483 MAXI1=$MAXI; MAXV1=$MAXV
4485 # now fill using QOS
4486 echo writing a bunch of files to QOS-assigned OSTs
4487 $SETSTRIPE $DIR/$tdir -c 1
4489 while [ $FILL -gt 0 ]; do
4490 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1024 count=200 2>/dev/null
4491 FILL=$(($FILL - 200))
4495 echo "wrote $i 200k files"
4499 echo "Note: free space may not be updated, so measurements might be off"
4501 DIFF2=$(($MAXV - $MINV))
4502 echo "free space delta: orig $DIFF final $DIFF2"
4503 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
4504 DIFF=$(($MINV1 - ${AVAIL[$MINI1]}))
4505 echo "Wrote $DIFF to smaller OST $MINI1"
4506 DIFF2=$(($MAXV1 - ${AVAIL[$MAXI1]}))
4507 echo "Wrote $DIFF2 to larger OST $MAXI1"
4508 [ $DIFF -gt 0 ] && echo "Wrote $(($DIFF2 * 100 / $DIFF - 100))% more data to larger OST $MAXI1"
4510 # Figure out which files were written where
4511 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd | awk '/'$MINI1': / {print $2; exit}')
4513 MINC=$($GETSTRIPE --obd $UUID $DIR/$tdir | wc -l)
4514 echo "$MINC files created on smaller OST $MINI1"
4515 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd | (awk '/'$MAXI1': / {print $2; exit}'))
4516 MAXC=$($GETSTRIPE --obd $UUID $DIR/$tdir | wc -l)
4517 echo "$MAXC files created on larger OST $MAXI1"
4518 [ $MINC -gt 0 ] && echo "Wrote $(($MAXC * 100 / $MINC - 100))% more files to larger OST $MAXI1"
4519 [ $MAXC -gt $MINC ] || error_ignore "stripe QOS didn't balance free space"
4521 rm -rf $DIR/$tdir/OST${MINI}
4523 run_test 116 "stripe QOS: free space balance ==================="
4525 test_117() # bug 10891
4527 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
4528 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
4529 lctl set_param fail_loc=0x21e
4530 > $DIR/$tfile || error "truncate failed"
4531 lctl set_param fail_loc=0
4532 echo "Truncate succeeded."
4534 run_test 117 "verify fsfilt_extend ============================="
4536 export OLD_RESENDCOUNT=""
4537 set_resend_count () {
4538 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
4539 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -1)
4540 lctl set_param -n $PROC_RESENDCOUNT $1
4541 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
4544 [ "$SLOW" = "no" ] && set_resend_count 4 # for reduce test_118* time (bug 14842)
4546 # Reset async IO behavior after error case
4548 FILE=$DIR/reset_async
4550 # Ensure all OSCs are cleared
4551 $SETSTRIPE -c -1 $FILE
4552 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
4557 test_118a() #bug 11710
4561 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
4562 DIRTY=$(lctl get_param -n "llite.*.dump_page_cache" | grep -c dirty)
4563 WRITEBACK=$(lctl get_param "llite.*.dump_page_cache" | grep -c writeback)
4565 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
4566 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
4570 run_test 118a "verify O_SYNC works =========="
4574 remote_ost_nodsh && skip "remote OST with nodsh" && return
4578 #define OBD_FAIL_OST_ENOENT 0x217
4579 set_nodes_failloc "$(osts_nodes)" 0x217
4580 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
4582 set_nodes_failloc "$(osts_nodes)" 0
4583 DIRTY=$(lctl get_param llite.*.dump_page_cache | grep -c dirty)
4584 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
4586 if [[ $RC -eq 0 ]]; then
4587 error "Must return error due to dropped pages, rc=$RC"
4591 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
4592 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
4596 echo "Dirty pages not leaked on ENOENT"
4598 # Due to the above error the OSC will issue all RPCs syncronously
4599 # until a subsequent RPC completes successfully without error.
4600 multiop $DIR/$tfile Ow4096yc
4605 run_test 118b "Reclaim dirty pages on fatal error =========="
4609 remote_ost_nodsh && skip "remote OST with nodsh" && return
4613 #define OBD_FAIL_OST_EROFS 0x216
4614 set_nodes_failloc "$(osts_nodes)" 0x216
4616 # multiop should block due to fsync until pages are written
4617 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
4621 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
4622 error "Multiop failed to block on fsync, pid=$MULTIPID"
4625 WRITEBACK=$(lctl get_param -n llite/*/dump_page_cache | grep -c writeback)
4626 if [[ $WRITEBACK -eq 0 ]]; then
4627 error "No page in writeback, writeback=$WRITEBACK"
4630 set_nodes_failloc "$(osts_nodes)" 0
4633 if [[ $RC -ne 0 ]]; then
4634 error "Multiop fsync failed, rc=$RC"
4637 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
4638 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
4639 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
4640 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
4644 echo "Dirty pages flushed via fsync on EROFS"
4647 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
4651 remote_ost_nodsh && skip "remote OST with nodsh" && return
4655 #define OBD_FAIL_OST_BRW_PAUSE_BULK
4656 set_nodes_failloc "$(osts_nodes)" 0x214
4657 # multiop should block due to fsync until pages are written
4658 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
4662 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
4663 error "Multiop failed to block on fsync, pid=$MULTIPID"
4666 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
4667 if [[ $WRITEBACK -eq 0 ]]; then
4668 error "No page in writeback, writeback=$WRITEBACK"
4671 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
4672 set_nodes_failloc "$(osts_nodes)" 0
4674 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
4675 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
4676 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
4677 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
4681 echo "Dirty pages gaurenteed flushed via fsync"
4684 run_test 118d "Fsync validation inject a delay of the bulk =========="
4689 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
4690 lctl set_param fail_loc=0x8000040a
4692 # Should simulate EINVAL error which is fatal
4693 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
4695 if [[ $RC -eq 0 ]]; then
4696 error "Must return error due to dropped pages, rc=$RC"
4699 lctl set_param fail_loc=0x0
4701 LOCKED=$(lctl get_param -n "llite.*.dump_page_cache" | grep -c locked)
4702 DIRTY=$(lctl get_param -n "llite.*.dump_page_cache" | grep -c dirty)
4703 WRITEBACK=$(lctl get_param -n "llite.*.dump_page_cache" | grep -c writeback)
4704 if [[ $LOCKED -ne 0 ]]; then
4705 error "Locked pages remain in cache, locked=$LOCKED"
4708 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
4709 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
4713 echo "No pages locked after fsync"
4718 run_test 118f "Simulate unrecoverable OSC side error =========="
4723 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
4724 lctl set_param fail_loc=0x406
4726 # simulate local -ENOMEM
4727 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
4730 lctl set_param fail_loc=0
4731 if [[ $RC -eq 0 ]]; then
4732 error "Must return error due to dropped pages, rc=$RC"
4735 LOCKED=$(lctl get_param -n "llite.*.dump_page_cache" | grep -c locked)
4736 DIRTY=$(lctl get_param -n "llite.*.dump_page_cache" | grep -c dirty)
4737 WRITEBACK=$(lctl get_param -n "llite.*.dump_page_cache" | grep -c writeback)
4738 if [[ $LOCKED -ne 0 ]]; then
4739 error "Locked pages remain in cache, locked=$LOCKED"
4742 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
4743 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
4747 echo "No pages locked after fsync"
4752 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
4755 remote_ost_nodsh && skip "remote OST with nodsh" && return
4759 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
4760 set_nodes_failloc "$(osts_nodes)" 0x20e
4761 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
4762 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
4765 set_nodes_failloc "$(osts_nodes)" 0
4766 if [[ $RC -eq 0 ]]; then
4767 error "Must return error due to dropped pages, rc=$RC"
4770 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
4771 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
4772 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writebac)
4773 if [[ $LOCKED -ne 0 ]]; then
4774 error "Locked pages remain in cache, locked=$LOCKED"
4777 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
4778 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
4782 echo "No pages locked after fsync"
4786 run_test 118h "Verify timeout in handling recoverables errors =========="
4789 remote_ost_nodsh && skip "remote OST with nodsh" && return
4793 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
4794 set_nodes_failloc "$(osts_nodes)" 0x20e
4796 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
4797 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
4800 set_nodes_failloc "$(osts_nodes)" 0
4804 if [[ $RC -ne 0 ]]; then
4805 error "got error, but should be not, rc=$RC"
4808 LOCKED=$(lctl get_param -n "llite.*.dump_page_cache" | grep -c locked)
4809 DIRTY=$(lctl get_param -n "llite.*.dump_page_cache" | grep -c dirty)
4810 WRITEBACK=$(lctl get_param -n "llite.*.dump_page_cache" | grep -c writeback)
4811 if [[ $LOCKED -ne 0 ]]; then
4812 error "Locked pages remain in cache, locked=$LOCKED"
4815 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
4816 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
4820 echo "No pages locked after fsync"
4824 run_test 118i "Fix error before timeout in recoverable error =========="
4827 remote_ost_nodsh && skip "remote OST with nodsh" && return
4831 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
4832 set_nodes_failloc "$(osts_nodes)" 0x220
4834 # return -EIO from OST
4835 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
4837 set_nodes_failloc "$(osts_nodes)" 0x0
4838 if [[ $RC -eq 0 ]]; then
4839 error "Must return error due to dropped pages, rc=$RC"
4842 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
4843 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
4844 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
4845 if [[ $LOCKED -ne 0 ]]; then
4846 error "Locked pages remain in cache, locked=$LOCKED"
4849 # in recoverable error on OST we want resend and stay until it finished
4850 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
4851 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
4855 echo "No pages locked after fsync"
4859 run_test 118j "Simulate unrecoverable OST side error =========="
4863 remote_ost_nodsh && skip "remote OSTs with nodsh" && return
4865 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
4866 set_nodes_failloc "$(osts_nodes)" 0x20e
4869 for ((i=0;i<10;i++)); do
4870 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
4871 error "dd to $DIR/$tdir/$tfile-$i failed" )&
4878 set_nodes_failloc "$(osts_nodes)" 0
4880 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
4882 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
4884 test_119a() # bug 11737
4886 BSIZE=$((512 * 1024))
4887 directio write $DIR/$tfile 0 1 $BSIZE
4888 # We ask to read two blocks, which is more than a file size.
4889 # directio will indicate an error when requested and actual
4890 # sizes aren't equeal (a normal situation in this case) and
4891 # print actual read amount.
4892 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
4893 if [ "$NOB" != "$BSIZE" ]; then
4894 error "read $NOB bytes instead of $BSIZE"
4898 run_test 119a "Short directIO read must return actual read amount"
4900 test_119b() # bug 11737
4902 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
4904 $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
4905 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
4907 multiop $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) || \
4908 error "direct read failed"
4911 run_test 119b "Sparse directIO read must return actual read amount"
4913 test_119c() # bug 13099
4916 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
4917 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
4920 run_test 119c "Testing for direct read hitting hole"
4922 test_119d() # bug 15950
4924 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
4925 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
4927 $SETSTRIPE $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
4928 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
4929 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
4930 lctl set_param fail_loc=0x40d
4931 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
4934 cat $DIR/$tfile > /dev/null &
4935 lctl set_param fail_loc=0
4938 log "the DIO writes have completed, now wait for the reads (should not block very long)"
4940 [ -n "`ps h -p $pid_reads -o comm`" ] && \
4941 error "the read rpcs have not completed in 2s"
4943 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
4945 run_test 119d "The DIO path should try to send a new rpc once one is completed"
4949 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
4950 skip "no early lock cancel on server" && return 0
4951 lru_resize_disable mdc
4952 lru_resize_disable osc
4953 cancel_lru_locks mdc
4954 stat $DIR/$tdir > /dev/null
4955 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
4956 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
4958 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
4959 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
4960 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
4961 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
4962 lru_resize_enable mdc
4963 lru_resize_enable osc
4965 run_test 120a "Early Lock Cancel: mkdir test ==================="
4969 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
4970 skip "no early lock cancel on server" && return 0
4971 lru_resize_disable mdc
4972 lru_resize_disable osc
4973 cancel_lru_locks mdc
4974 stat $DIR/$tdir > /dev/null
4975 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
4976 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
4978 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
4979 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
4980 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
4981 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
4982 lru_resize_enable mdc
4983 lru_resize_enable osc
4985 run_test 120b "Early Lock Cancel: create test =================="
4989 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
4990 skip "no early lock cancel on server" && return 0
4991 lru_resize_disable mdc
4992 lru_resize_disable osc
4993 mkdir -p $DIR/$tdir/d1 $DIR/$tdir/d2
4994 touch $DIR/$tdir/d1/f1
4995 cancel_lru_locks mdc
4996 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
4997 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
4998 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
4999 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
5000 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
5001 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
5002 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
5003 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
5004 lru_resize_enable mdc
5005 lru_resize_enable osc
5007 run_test 120c "Early Lock Cancel: link test ===================="
5011 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
5012 skip "no early lock cancel on server" && return 0
5013 lru_resize_disable mdc
5014 lru_resize_disable osc
5016 cancel_lru_locks mdc
5017 stat $DIR/$tdir > /dev/null
5018 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
5019 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
5020 chmod a+x $DIR/$tdir
5021 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
5022 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
5023 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
5024 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
5025 lru_resize_enable mdc
5026 lru_resize_enable osc
5028 run_test 120d "Early Lock Cancel: setattr test ================="
5032 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
5033 skip "no early lock cancel on server" && return 0
5034 lru_resize_disable mdc
5035 lru_resize_disable osc
5036 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
5037 cancel_lru_locks mdc
5038 cancel_lru_locks osc
5039 dd if=$DIR/$tdir/f1 of=/dev/null
5040 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
5041 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
5042 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
5043 unlink $DIR/$tdir/f1
5044 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
5045 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
5046 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
5047 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
5048 lru_resize_enable mdc
5049 lru_resize_enable osc
5051 run_test 120e "Early Lock Cancel: unlink test =================="
5054 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
5055 skip "no early lock cancel on server" && return 0
5057 lru_resize_disable mdc
5058 lru_resize_disable osc
5059 mkdir -p $DIR/$tdir/d1 $DIR/$tdir/d2
5060 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
5061 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
5062 cancel_lru_locks mdc
5063 cancel_lru_locks osc
5064 dd if=$DIR/$tdir/d1/f1 of=/dev/null
5065 dd if=$DIR/$tdir/d2/f2 of=/dev/null
5066 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
5067 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
5068 blk1=`lctl get_param -n ldlm/services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
5069 mv $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
5070 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
5071 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
5072 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
5073 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
5074 lru_resize_enable mdc
5075 lru_resize_enable osc
5077 run_test 120f "Early Lock Cancel: rename test =================="
5080 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
5081 skip "no early lock cancel on server" && return 0
5082 lru_resize_disable mdc
5083 lru_resize_disable osc
5085 echo create $count files
5087 cancel_lru_locks mdc
5088 cancel_lru_locks osc
5091 can0=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
5092 blk0=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
5093 createmany -o $DIR/$tdir/f $count
5095 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
5096 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
5098 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
5099 echo rm $count files
5102 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
5103 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
5105 echo total: $count removes in $((t2-t1))
5106 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
5108 # wait for commitment of removal
5109 lru_resize_enable mdc
5110 lru_resize_enable osc
5112 run_test 120g "Early Lock Cancel: performance test ============="
5114 test_121() { #bug 10589
5115 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
5116 lctl set_param fail_loc=0x310
5117 cancel_lru_locks osc > /dev/null
5118 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
5119 lctl set_param fail_loc=0
5120 [ "$reads" -eq "$writes" ] || error "read" $reads "blocks, must be" $writes
5122 run_test 121 "read cancel race ================================="
5124 test_122() { #bug 11544
5125 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
5126 lctl set_param fail_loc=0x508
5127 dd if=/dev/zero of=$DIR/$tfile count=1
5129 lctl set_param fail_loc=0
5131 run_test 122 "fail client bulk callback (shouldn't LBUG) ======="
5133 test_123a() { # was test 123, statahead(bug 11401)
5135 if [ -z "$(grep "processor.*: 1" /proc/cpuinfo)" ]; then
5136 log "testing on UP system. Performance may be not as good as expected."
5142 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
5143 [ $NUMFREE -gt 100000 ] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
5145 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
5146 createmany -o $DIR/$tdir/$tfile $j $((i - j))
5148 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
5149 lctl set_param -n llite.*.statahead_max 0
5150 lctl get_param llite.*.statahead_max
5151 cancel_lru_locks mdc
5152 cancel_lru_locks osc
5154 time ls -l $DIR/$tdir | wc -l
5156 delta=$((etime - stime))
5157 log "ls $i files without statahead: $delta sec"
5158 lctl set_param llite.*.statahead_max=$max
5160 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
5161 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
5162 cancel_lru_locks mdc
5163 cancel_lru_locks osc
5165 time ls -l $DIR/$tdir | wc -l
5167 delta_sa=$((etime - stime))
5168 log "ls $i files with statahead: $delta_sa sec"
5169 lctl get_param -n llite.*.statahead_stats
5170 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
5172 if [ $swrong -lt $ewrong ]; then
5173 log "statahead was stopped, maybe too many locks held!"
5176 [ $delta -eq 0 -o $delta_sa -eq 0 ] && continue
5178 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
5179 if [ $SLOWOK -eq 0 ]; then
5180 error "ls $i files is slower with statahead!"
5183 lctl set_param debug=-1
5184 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
5185 lctl set_param -n llite.*.statahead_max 0
5186 lctl get_param llite.*.statahead_max
5187 cancel_lru_locks mdc
5188 cancel_lru_locks osc
5191 time ls -l $DIR/$tdir | wc -l
5193 error "ls $i files (again) without statahead: $((etime - stime)) sec"
5195 lctl set_param debug=-1
5196 lctl set_param llite.*.statahead_max=$max
5197 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
5198 cancel_lru_locks mdc
5199 cancel_lru_locks osc
5202 time ls -l $DIR/$tdir | wc -l
5204 error "ls $i files (again) with statahead: $((etime - stime)) sec"
5205 lctl get_param -n llite.*.statahead_stats
5209 log "ls $i files is slower with statahead!"
5214 [ $delta -gt 20 ] && break
5215 [ $delta -gt 8 ] && MULT=$((50 / delta))
5216 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
5224 delta=$((etime - stime))
5225 log "rm -r $DIR/$tdir/: $delta seconds"
5227 lctl get_param -n llite.*.statahead_stats
5229 run_test 123a "verify statahead work"
5231 test_123b () { # statahead(bug 15027)
5233 createmany -o $DIR/$tdir/$tfile-%d 1000
5235 cancel_lru_locks mdc
5236 cancel_lru_locks osc
5238 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
5239 lctl set_param fail_loc=0x80000803
5240 ls -lR $DIR/$tdir > /dev/null
5242 lctl set_param fail_loc=0x0
5243 lctl get_param -n llite.*.statahead_stats
5248 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
5251 [ -z "`lctl get_param -n mdc.*.connect_flags | grep lru_resize`" ] && \
5252 skip "no lru resize on server" && return 0
5254 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
5256 log "create $NR files at $DIR/$tdir"
5257 createmany -o $DIR/$tdir/f $NR ||
5258 error "failed to create $NR files in $DIR/$tdir"
5260 cancel_lru_locks mdc
5261 ls -l $DIR/$tdir > /dev/null
5265 for VALUE in `lctl get_param ldlm.namespaces.*mdc-*.lru_size`; do
5266 local PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
5267 LRU_SIZE=$(lctl get_param -n $PARAM)
5268 if [ $LRU_SIZE -gt $(default_lru_size) ]; then
5269 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
5270 log "NS=$(basename $NSDIR)"
5275 if [ -z "$NSDIR" -o $LRU_SIZE -lt $(default_lru_size) ]; then
5276 skip "Not enough cached locks created!"
5283 # We know that lru resize allows one client to hold $LIMIT locks
5284 # for 10h. After that locks begin to be killed by client.
5286 local LIMIT=`lctl get_param -n $NSDIR.pool.limit`
5288 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
5289 # killing locks. Some time was spent for creating locks. This means
5290 # that up to the moment of sleep finish we must have killed some of
5291 # them (10-100 locks). This depends on how fast ther were created.
5292 # Many of them were touched in almost the same moment and thus will
5293 # be killed in groups.
5294 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
5296 # Use $LRU_SIZE_B here to take into account real number of locks
5297 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
5298 local LRU_SIZE_B=$LRU_SIZE
5300 local OLD_LVF=`lctl get_param -n $NSDIR.pool.lock_volume_factor`
5301 lctl set_param -n $NSDIR.pool.lock_volume_factor $LVF
5303 # Let's make sure that we really have some margin. Client checks
5304 # cached locks every 10 sec.
5306 log "Sleep ${SLEEP} sec"
5308 while ((SEC<$SLEEP)); do
5312 LRU_SIZE=`lctl get_param -n $NSDIR/lru_size`
5316 lctl set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
5317 local LRU_SIZE_A=`lctl get_param -n $NSDIR/lru_size`
5319 [ $LRU_SIZE_B -gt $LRU_SIZE_A ] || {
5320 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
5321 unlinkmany $DIR/$tdir/f $NR
5325 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
5326 log "unlink $NR files at $DIR/$tdir"
5327 unlinkmany $DIR/$tdir/f $NR
5329 run_test 124a "lru resize ======================================="
5332 [ -z "`lctl get_param -n mdc.*.connect_flags | grep lru_resize`" ] && \
5333 skip "no lru resize on server" && return 0
5335 # even for cmd no matter what metadata namespace to use for getting
5336 # the limit, we use appropriate.
5337 LIMIT=`lctl get_param -n ldlm.namespaces.*mdc*.pool.limit`
5339 NR=$(($(default_lru_size)*20))
5340 if [ $NR -gt $LIMIT ]; then
5343 lru_resize_disable mdc
5344 mkdir -p $DIR/$tdir/disable_lru_resize ||
5345 error "failed to create $DIR/$tdir/disable_lru_resize"
5347 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
5348 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
5349 cancel_lru_locks mdc
5352 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
5355 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
5358 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
5362 nolruresize_delta=$((etime-stime))
5363 log "ls -la time: $nolruresize_delta seconds"
5364 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
5365 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
5367 lru_resize_enable mdc
5368 mkdir -p $DIR/$tdir/enable_lru_resize ||
5369 error "failed to create $DIR/$tdir/enable_lru_resize"
5371 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
5372 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
5373 cancel_lru_locks mdc
5376 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
5379 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
5382 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
5386 lruresize_delta=$((etime-stime))
5387 log "ls -la time: $lruresize_delta seconds"
5388 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
5390 if [ $lruresize_delta -gt $nolruresize_delta ]; then
5391 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
5392 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
5393 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
5395 log "lru resize performs the same with no lru resize"
5397 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
5399 run_test 124b "lru resize (performance test) ======================="
5401 test_125() { # 13358
5402 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
5403 mkdir -p $DIR/d125 || error "mkdir failed"
5404 $SETSTRIPE $DIR/d125 -s 65536 -c -1 || error "setstripe failed"
5405 setfacl -R -m u:bin:rwx $DIR/d125 || error "setfacl $DIR/d125 failes"
5406 ls -ld $DIR/d125 || error "cannot access $DIR/d125"
5408 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
5410 test_126() { # bug 12829/13455
5411 [ "$UID" != 0 ] && skip_env "skipping $TESTNAME (must run as root)" && return
5412 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
5413 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
5415 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
5417 run_test 126 "check that the fsgid provided by the client is taken into account"
5419 test_127() { # bug 15521
5420 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
5421 $LCTL set_param osc.*.stats=0
5422 FSIZE=$((2048 * 1024))
5423 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
5424 cancel_lru_locks osc
5425 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
5427 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
5428 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
5429 echo "got $COUNT $NAME"
5430 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
5431 eval $NAME=$COUNT || error "Wrong proc format"
5434 read_bytes|write_bytes)
5435 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
5436 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
5437 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
5438 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
5439 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
5440 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
5441 error "sumsquare is too small: $SUMSQ"
5442 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
5443 error "sumsquare is too big: $SUMSQ"
5447 done < $DIR/${tfile}.tmp
5449 #check that we actually got some stats
5450 [ "$read_bytes" ] || error "Missing read_bytes stats"
5451 [ "$write_bytes" ] || error "Missing write_bytes stats"
5452 [ "$read_bytes" != 0 ] || error "no read done"
5453 [ "$write_bytes" != 0 ] || error "no write done"
5455 run_test 127 "verify the client stats are sane"
5457 test_128() { # bug 15212
5459 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
5464 result=$(grep error $TMP/$tfile.log)
5466 [ -z "$result" ] || error "consecutive find with interactive lfs failed"
5468 run_test 128 "interactive lfs for 2 consecutive finds"
5471 [ "$FSTYPE" != "ldiskfs" ] && skip "not needed for FSTYPE=$FSTYPE" && return 0
5472 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5474 local MNTDEV=$(get_mds_mntdev_proc_path)
5475 DEV=$(basename $(do_facet mds lctl get_param -n $MNTDEV))
5476 [ -z "$DEV" ] && error "can't access mds mntdev"
5478 LDPROC=/proc/fs/ldiskfs/$DEV/max_dir_size
5481 do_facet mds "echo $MAX > $LDPROC"
5487 while [ ! $I -gt $MAX ]; do
5488 multiop $DIR/$tdir/$J Oc
5490 if [ $rc -eq $EFBIG ]; then
5491 do_facet mds "echo 0 >$LDPROC"
5492 echo "return code $rc received as expected"
5494 elif [ $rc -ne 0 ]; then
5495 do_facet mds "echo 0 >$LDPROC"
5496 error_exit "error $rc instead of expected $EFBIG"
5499 I=$(stat -c%s "$DIR/$tdir")
5502 error "exceeded dir size limit: $I bytes"
5503 do_facet mds "echo 0 >$LDPROC"
5505 run_test 129 "test directory size limit ========================"
5514 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
5515 [ -n "$filefrag_op" ] && skip "filefrag has no FIEMAP support" && return
5517 trap cleanup_130 EXIT RETURN
5519 local fm_file=$DIR/$tfile
5520 lfs setstripe -s 65536 -c 1 $fm_file ||
5521 error "setstripe failed on $fm_file"
5522 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
5523 error "dd failed for $fm_file"
5525 filefrag -ves $fm_file || error "filefrag $fm_file failed"
5526 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
5528 lun=`$GETSTRIPE $fm_file | grep -A 10 obdidx | awk '{print $1}' | grep -v "obdidx"`
5530 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
5533 for line in $filefrag_op
5535 frag_lun=`echo $line | cut -d: -f5`
5536 ext_len=`echo $line | cut -d: -f4`
5537 if (( $frag_lun != $lun )); then
5539 error "FIEMAP on 1-stripe file($fm_file) failed"
5542 (( tot_len += ext_len ))
5545 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
5547 error "FIEMAP on 1-stripe file($fm_file) failed;"
5553 echo "FIEMAP on single striped file succeeded"
5555 run_test 130a "FIEMAP (1-stripe file)"
5558 [ "$OSTCOUNT" -lt "2" ] && skip_env "FIEMAP on 2-stripe file test" && return
5560 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
5561 [ -n "$filefrag_op" ] && skip "filefrag has no FIEMAP support" && return
5563 trap cleanup_130 EXIT RETURN
5565 local fm_file=$DIR/$tfile
5566 lfs setstripe -s 65536 -c 2 $fm_file ||
5567 error "setstripe failed on $fm_file"
5568 dd if=/dev/zero of=$fm_file bs=1M count=2 ||
5569 error "dd failed on $fm_file"
5571 filefrag -ves $fm_file || error "filefrag $fm_file failed"
5572 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
5574 last_lun=`echo $filefrag_op | cut -d: -f5`
5579 for line in $filefrag_op; do
5580 frag_lun=`echo $line | cut -d: -f5`
5581 ext_len=`echo $line | cut -d: -f4`
5582 if (( $frag_lun != $last_lun )); then
5583 if (( tot_len != 1024 )); then
5585 error "FIEMAP $fm_file: len $tot_len for OST $last_lun instead of 256"
5592 (( tot_len += ext_len ))
5595 if (( num_luns != 2 || tot_len != 1024 )); then
5597 error "FIEMAP $fm_file: wrong number of LUNs or wrong len for OST $last_lun"
5603 echo "FIEMAP on 2-stripe file succeeded"
5605 run_test 130b "FIEMAP (2-stripe file)"
5608 [ "$OSTCOUNT" -lt "2" ] && skip_env "FIEMAP on 2-stripe hole test" && return
5610 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
5611 [ -n "$filefrag_op" ] && skip "filefrag has no FIEMAP support" && return
5613 trap cleanup_130 EXIT RETURN
5615 local fm_file=$DIR/$tfile
5616 lfs setstripe -s 65536 -c 2 $fm_file ||
5617 error "setstripe failed on $fm_file"
5618 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 ||
5619 error "dd failed on $fm_file"
5621 filefrag -ves $fm_file || error "filefrag $fm_file failed"
5622 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
5624 last_lun=`echo $filefrag_op | cut -d: -f5`
5629 for line in $filefrag_op
5631 frag_lun=`echo $line | cut -d: -f5`
5632 ext_len=`echo $line | cut -d: -f4`
5633 if (( $frag_lun != $last_lun )); then
5634 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
5635 if (( logical != 512 )); then
5637 error "FIEMAP $fm_file: logical start for LUN $logical instead of 512"
5640 if (( tot_len != 512 )); then
5642 error "FIEMAP $fm_file: len $tot_len for OST $last_lun instead of 1024"
5649 (( tot_len += ext_len ))
5652 if (( num_luns != 2 || tot_len != 512 )); then
5654 error "FIEMAP $fm_file: wrong number of LUNs or wrong len for OST $last_lun"
5660 echo "FIEMAP on 2-stripe file with hole succeeded"
5662 run_test 130c "FIEMAP (2-stripe file with hole)"
5665 [ "$OSTCOUNT" -lt "3" ] && skip_env "FIEMAP on N-stripe file test" && return
5667 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
5668 [ -n "$filefrag_op" ] && skip "filefrag has no FIEMAP support" && return
5670 trap cleanup_130 EXIT RETURN
5672 local fm_file=$DIR/$tfile
5673 lfs setstripe -s 65536 -c $OSTCOUNT $fm_file ||
5674 error "setstripe failed on $fm_file"
5675 dd if=/dev/zero of=$fm_file bs=1M count=$OSTCOUNT ||
5676 error "dd failed on $fm_file"
5678 filefrag -ves $fm_file || error "filefrag $fm_file failed"
5679 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
5681 last_lun=`echo $filefrag_op | cut -d: -f5`
5686 for line in $filefrag_op
5688 frag_lun=`echo $line | cut -d: -f5`
5689 ext_len=`echo $line | cut -d: -f4`
5690 if (( $frag_lun != $last_lun )); then
5691 if (( tot_len != 1024 )); then
5693 error "FIEMAP $fm_file: len $tot_len for OST $last_lun instead of 1024"
5700 (( tot_len += ext_len ))
5703 if (( num_luns != OSTCOUNT || tot_len != 1024 )); then
5705 error "FIEMAP $fm_file: wrong number of LUNs or wrong len for OST $last_lun"
5711 echo "FIEMAP on N-stripe file succeeded"
5713 run_test 130d "FIEMAP (N-stripe file)"
5716 [ "$OSTCOUNT" -lt "2" ] && skip "continuation FIEMAP test" && return
5718 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
5719 [ -n "$filefrag_op" ] && skip "filefrag has no FIEMAP support" && return
5721 trap cleanup_130 EXIT RETURN
5723 local fm_file=$DIR/$tfile
5724 lfs setstripe -s 131072 -c 2 $fm_file ||
5725 error "setstripe failed on $fm_file"
5727 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
5728 for ((i = 0; i < $NUM_BLKS; i++)); do
5729 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
5732 filefrag -ves $fm_file || error "filefrag $fm_file failed"
5733 filefrag_op=`filefrag -ve $fm_file | grep -A 12000 "ext:" | grep -v "ext:" | grep -v "found"`
5735 last_lun=`echo $filefrag_op | cut -d: -f5`
5740 for line in $filefrag_op
5742 frag_lun=`echo $line | cut -d: -f5`
5743 ext_len=`echo $line | cut -d: -f4`
5744 if (( $frag_lun != $last_lun )); then
5745 if (( tot_len != $EXPECTED_LEN )); then
5747 error "FIEMAP $fm_file: len $tot_len for OST $last_lun instead of $EXPECTED_LEN"
5754 (( tot_len += ext_len ))
5757 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
5759 error "FIEMAP $fm_file: wrong number of LUNs or wrong len for OST $last_lun"
5765 echo "FIEMAP with continuation calls succeeded"
5767 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
5769 test_140() { #bug-17379
5770 mkdir -p $DIR/$tdir || error "Creating dir $DIR/$tdir"
5771 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
5772 cp /usr/bin/stat . || error "Copying stat to $DIR/$tdir"
5774 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
5776 while i=`expr $i + 1`; do
5777 mkdir -p $i || error "Creating dir $i"
5778 cd $i || error "Changing to $i"
5779 ln -s ../stat stat || error "Creating stat symlink"
5780 # Read the symlink until ELOOP present,
5781 # not LBUGing the system is considered success,
5782 # we didn't overrun the stack.
5783 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
5785 if [ $ret -eq 40 ]; then
5788 error "Open stat symlink"
5794 echo "The symlink depth = $i"
5795 [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 ] || error "Invalid symlink depth"
5797 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
5800 local TF="$TMP/$tfile"
5802 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
5804 cancel_lru_locks osc
5805 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
5806 remount_client $MOUNT
5808 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
5811 $TRUNCATE $DIR/$tfile 6000
5812 cancel_lru_locks osc
5813 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
5816 echo "12345" >>$DIR/$tfile
5817 cancel_lru_locks osc
5818 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
5821 echo "12345" >>$DIR/$tfile
5822 cancel_lru_locks osc
5823 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
5828 run_test 150 "truncate/append tests"
5830 function roc_hit() {
5831 local list=$(comma_list $(osts_nodes))
5833 ACCNUM=$(do_nodes $list $LCTL get_param -n obdfilter.*.stats | \
5834 awk '/'cache_hit'/ {sum+=$2} END {print sum}')
5838 function set_cache() {
5841 if [ "$2" == "off" ]; then
5844 local list=$(comma_list $(osts_nodes))
5845 do_nodes $list lctl set_param obdfilter.*.${1}_cache_enable $on
5847 cancel_lru_locks osc
5851 remote_ost_nodsh && skip "remote OST with nodsh" && return
5853 local list=$(comma_list $(osts_nodes))
5854 if ! do_nodes $list grep -q truncate_inode_pages_range /proc/kallsyms; then #b=18718
5855 skip "old RHEL4/SLES9 kernel" && return
5860 # check whether obdfilter is cache capable at all
5861 if ! do_nodes $list $LCTL get_param -n obdfilter.*.read_cache_enable > /dev/null; then
5862 echo "not cache-capable obdfilter"
5866 # make sure cache is enabled on all obdfilters
5867 do_nodes $list $LCTL set_param obdfilter.*.read_cache_enable=1
5868 do_nodes $list $LCTL set_param obdfilter.*.writethrough_cache_enable=1
5870 # pages should be in the case right after write
5871 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES || error "dd failed"
5872 local BEFORE=`roc_hit`
5873 cancel_lru_locks osc
5874 cat $DIR/$tfile >/dev/null
5875 local AFTER=`roc_hit`
5876 if let "AFTER - BEFORE != CPAGES"; then
5877 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
5880 # the following read invalidates the cache
5881 cancel_lru_locks osc
5882 do_nodes $list $LCTL set_param -n obdfilter.*.read_cache_enable 0
5883 cat $DIR/$tfile >/dev/null
5885 # now data shouldn't be found in the cache
5887 cancel_lru_locks osc
5888 cat $DIR/$tfile >/dev/null
5890 if let "AFTER - BEFORE != 0"; then
5891 error "IN CACHE: before: $BEFORE, after: $AFTER"
5894 do_nodes $list $LCTL set_param -n obdfilter.*.read_cache_enable=1
5895 do_nodes $list $LCTL set_param obdfilter.*.writethrough_cache_enable=1
5898 run_test 151 "test cache on oss and controls ==============================="
5901 local TF="$TMP/$tfile"
5903 # simulate ENOMEM during write
5904 #define OBD_FAIL_OST_NOMEM 0x226
5905 lctl set_param fail_loc=0x80000226
5906 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
5908 sync || error "sync failed"
5909 lctl set_param fail_loc=0
5911 # discard client's cache
5912 cancel_lru_locks osc
5914 # simulate ENOMEM during read
5915 lctl set_param fail_loc=0x80000226
5916 cmp $TF $DIR/$tfile || error "cmp failed"
5917 lctl set_param fail_loc=0
5921 run_test 152 "test read/write with enomem ============================"
5924 multiop $DIR/$tfile Ow4096Ycu || error "multiop failed"
5926 run_test 153 "test if fdatasync does not crash ======================="
5929 # do directio so as not to populate the page cache
5930 log "creating a 10 Mb file"
5931 multiop $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
5932 log "starting reads"
5933 dd if=$DIR/$tfile of=/dev/null bs=4096 &
5934 log "truncating the file"
5935 multiop $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
5937 kill %+ || true # reads might have finished
5938 echo "wait until dd is finished"
5940 log "removing the temporary file"
5941 rm -rf $DIR/$tfile || error "tmp file removal failed"
5943 run_test 154 "parallel read and truncate should not deadlock ==="
5946 local temp=$TMP/$tfile
5947 local file=$DIR/$tfile
5948 local list=$(comma_list $(osts_nodes))
5949 local big=$(do_nodes $list grep "cache" /proc/cpuinfo | \
5950 awk '{sum+=$4} END{print sum}')
5954 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
5955 error "dd of=$temp bs=6096 count=1 failed"
5957 cancel_lru_locks osc
5958 cmp $temp $file || error "$temp $file differ"
5960 $TRUNCATE $temp 6000
5961 $TRUNCATE $file 6000
5962 cmp $temp $file || error "$temp $file differ (truncate1)"
5964 echo "12345" >>$temp
5965 echo "12345" >>$file
5966 cmp $temp $file || error "$temp $file differ (append1)"
5968 echo "12345" >>$temp
5969 echo "12345" >>$file
5970 cmp $temp $file || error "$temp $file differ (append2)"
5972 dd if=/dev/urandom of=$temp bs=$((big*2)) count=1k || \
5973 error "dd of=$temp bs=$((big*2)) count=1k failed"
5976 cancel_lru_locks osc
5977 cmp $temp $file || error "$temp $file differ"
5985 set_cache writethrough on
5988 run_test 155a "Verification of correctness: read cache:on write_cache:on"
5992 set_cache writethrough off
5995 run_test 155b "Verification of correctness: read cache:on write_cache:off"
5999 set_cache writethrough on
6002 run_test 155c "Verification of correctness: read cache:off write_cache:on"
6006 set_cache writethrough off
6009 run_test 155d "Verification of correctness: read cache:off write_cache:off "
6015 local file="$DIR/$tfile"
6017 log "Turn on read and write cache"
6019 set_cache writethrough on
6021 log "Write data and read it back."
6022 log "Read should be satisfied from the cache."
6023 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
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"
6034 log "Read again; it should be satisfied from the cache."
6036 cancel_lru_locks osc
6037 cat $file >/dev/null
6039 if ! let "AFTER - BEFORE == CPAGES"; then
6040 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
6042 log "cache hits:: before: $BEFORE, after: $AFTER"
6046 log "Turn off the read cache and turn on the write cache"
6048 set_cache writethrough on
6050 log "Read again; it should be satisfied from the cache."
6052 cancel_lru_locks osc
6053 cat $file >/dev/null
6055 if ! let "AFTER - BEFORE == CPAGES"; then
6056 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
6058 log "cache hits:: before: $BEFORE, after: $AFTER"
6061 log "Read again; it should not be satisfied from the cache."
6063 cancel_lru_locks osc
6064 cat $file >/dev/null
6066 if ! let "AFTER - BEFORE == 0"; then
6067 error "IN CACHE: before: $BEFORE, after: $AFTER"
6069 log "cache hits:: before: $BEFORE, after: $AFTER"
6072 log "Write data and read it back."
6073 log "Read should be satisfied from the cache."
6074 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
6076 cancel_lru_locks osc
6077 cat $file >/dev/null
6079 if ! let "AFTER - BEFORE == CPAGES"; then
6080 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
6082 log "cache hits:: before: $BEFORE, after: $AFTER"
6085 log "Read again; it should not be satisfied from the cache."
6087 cancel_lru_locks osc
6088 cat $file >/dev/null
6090 if ! let "AFTER - BEFORE == 0"; then
6091 error "IN CACHE: before: $BEFORE, after: $AFTER"
6093 log "cache hits:: before: $BEFORE, after: $AFTER"
6097 log "Turn off read and write cache"
6099 set_cache writethrough off
6101 log "Write data and read it back"
6102 log "It should not be satisfied from the cache."
6104 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
6105 cancel_lru_locks osc
6107 cat $file >/dev/null
6109 if ! let "AFTER - BEFORE == 0"; then
6110 error_ignore 20762 "IN CACHE: before: $BEFORE, after: $AFTER"
6112 log "cache hits:: before: $BEFORE, after: $AFTER"
6116 log "Turn on the read cache and turn off the write cache"
6118 set_cache writethrough off
6120 log "Write data and read it back"
6121 log "It should not be satisfied from the cache."
6123 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
6125 cancel_lru_locks osc
6126 cat $file >/dev/null
6128 if ! let "AFTER - BEFORE == 0"; then
6129 error_ignore 20762 "IN CACHE: before: $BEFORE, after: $AFTER"
6131 log "cache hits:: before: $BEFORE, after: $AFTER"
6134 log "Read again; it should be satisfied from the cache."
6136 cancel_lru_locks osc
6137 cat $file >/dev/null
6139 if ! let "AFTER - BEFORE == CPAGES"; then
6140 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
6142 log "cache hits:: before: $BEFORE, after: $AFTER"
6147 run_test 156 "Verification of ROC tunables ========================"
6150 $LCTL clear # bug 18514
6151 $LCTL debug_daemon start $TMP/${tfile}_log_good
6153 $LCTL debug_daemon stop
6154 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
6155 error "sed failed to read log_good"
6157 $LCTL debug_daemon start $TMP/${tfile}_log_good
6159 $LCTL debug_daemon stop
6161 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
6162 error "lctl df log_bad failed"
6164 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
6165 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
6167 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
6168 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
6170 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
6171 error "bad_line good_line1 good_line2 are empty"
6173 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
6174 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
6175 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
6177 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
6178 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
6179 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
6181 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
6182 error "bad_line_new good_line_new are empty"
6184 local expected_good=$((good_line1 + good_line2*2))
6186 rm -f $TMP/${tfile}*
6187 if [ $bad_line -ne $bad_line_new ]; then
6188 error "expected $bad_line bad lines, but got $bad_line_new"
6192 if [ $expected_good -ne $good_line_new ]; then
6193 error "expected $expected_good good lines, but got $good_line_new"
6198 run_test 170 "test lctl df to handle corrupted log ====================="
6200 test_171() { # bug20592
6201 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
6202 $LCTL set_param fail_loc=0x50e
6203 $LCTL set_param fail_val=3000
6204 multiop_bg_pause $DIR/$tfile Os || true
6207 if dmesg | grep "recursive fault"; then
6208 error "caught a recursive fault"
6210 $LCTL set_param fail_loc=0
6213 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
6215 obdecho_create_test() {
6219 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
6220 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" || rc=2; }
6221 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec create 1" || rc=3; }
6222 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec test_brw 0 w 1" || rc=4; }
6223 [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec cleanup" || rc=5; }
6224 [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec detach" || rc=6; }
6231 local rmmod_remote=0
6233 lsmod | grep -q obdecho || { load_module obdecho/obdecho && rmmod_local=1; }
6235 OBD=`$LCTL dl | awk ' /-osc-/ { print $4; exit; }'`
6236 [ "x$OBD" != "x" ] && { obdecho_create_test $OBD client || rc=2; }
6237 [ $rmmod_local -eq 1 ] && rmmod obdecho
6238 [ $rc -ne 0 ] && return $rc
6240 do_facet ost "lsmod | grep -q obdecho || { insmod ${LUSTRE}/obdecho/obdecho.ko || modprobe obdecho; }" && rmmod_remote=1
6242 OBD=$(do_facet ost "$LCTL dl | awk '/obdfilter/ { print; exit; }'" | awk '{print $4;}')
6243 [ "x$OBD" != "x" ] && { obdecho_create_test $OBD ost || rc=3; }
6244 [ $rmmod_remote -eq 1 ] && do_facet ost "rmmod obdecho"
6245 [ $rc -ne 0 ] && return $rc
6249 run_test 180 "test obdecho ============================================"
6254 TGTPOOL_MAX=$(($TGT_COUNT - 1))
6256 TGTPOOL_LIST=`seq $TGTPOOL_FIRST $TGTPOOL_STEP $TGTPOOL_MAX`
6257 POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
6258 POOL_DIR=$POOL_ROOT/dir_tst
6259 POOL_FILE=$POOL_ROOT/file_tst
6263 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep pools)" ] &&
6264 skip "missing pools support on server" && return 1
6265 remote_mgs_nodsh && skip "remote MGS with nodsh" && return 1
6266 [ -z "$mdtlov" ] && mdtlov=$(get_mdtlov_proc_path $FSNAME)
6270 check_file_in_pool()
6273 res=$($GETSTRIPE $file | grep 0x | cut -f2)
6276 found=$(echo :$TGTPOOL_LIST: | tr " " ":" | grep :$i:)
6277 if [[ "$found" == "" ]]
6279 echo "pool list: $TGTPOOL_LIST"
6280 echo "striping: $res"
6281 error "$file not allocated in $POOL"
6290 trap "cleanup_pools $FSNAME" EXIT
6293 test_pools || return 0
6295 create_pool $FSNAME.$POOL || return $?
6296 [ $($LFS pool_list $FSNAME | grep -c $POOL) -eq 1 ] ||
6297 error "$POOL not in lfs pool_list"
6299 run_test 200a "Create new pool =========================================="
6302 test_pools || return 0
6303 TGT=$(for i in $TGTPOOL_LIST; do printf "$FSNAME-OST%04x_UUID " $i; done)
6304 do_facet mgs $LCTL pool_add $FSNAME.$POOL \
6305 $FSNAME-OST[$TGTPOOL_FIRST-$TGTPOOL_MAX/$TGTPOOL_STEP]
6307 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL | sort -u | tr '\n' ' ' " "$TGT" ||
6308 error "Add to pool failed"
6310 run_test 200b "Add targets to a pool ===================================="
6313 test_pools || return 0
6315 $SETSTRIPE -c 2 -p $POOL $POOL_DIR
6316 [ $? = 0 ] || error "Cannot set pool $POOL to $POOL_DIR"
6318 run_test 200c "Set pool on a directory ================================="
6321 test_pools || return 0
6322 res=$($GETSTRIPE --pool $POOL_DIR | awk '/^pool:/ {print $2}')
6323 [ "$res" = $POOL ] || error "Pool on $POOL_DIR is $res, not $POOL"
6325 run_test 200d "Check pool on a directory ==============================="
6328 test_pools || return 0
6330 for i in $(seq -w 1 $(($TGT_COUNT * 3))); do
6331 file=$POOL_DIR/file-$i
6333 check_file_in_pool $file
6334 if [[ $? != 0 ]]; then
6335 failed=$(($failed + 1))
6338 [ "$failed" = 0 ] || error "$failed files not allocated in $POOL"
6340 run_test 200e "Check files allocation from directory pool =============="
6343 test_pools || return 0
6346 for i in $(seq -w 1 $(($TGT_COUNT * 3))); do
6347 file=$POOL_FILE/spoo-$i
6348 $SETSTRIPE -p $POOL $file
6349 check_file_in_pool $file
6350 if [[ $? != 0 ]]; then
6351 failed=$(($failed + 1))
6354 [ "$failed" = 0 ] || error "$failed files not allocated in $POOL"
6356 run_test 200f "Create files in a pool ==================================="
6359 test_pools || return 0
6361 TGT=$($LCTL get_param -n lov.$FSNAME-clilov-*.pools.$POOL | tr '\n' ' ')
6362 res=$($LFS df --pool $FSNAME.$POOL | awk '{print $1}' | grep "$FSNAME-OST" | tr '\n' ' ')
6363 [ "$res" = "$TGT" ] || error "Pools OSTs '$TGT' is not '$res' that lfs df reports"
6365 run_test 200g "lfs df a pool ============================================"
6368 test_pools || return 0
6370 TGT=$($LCTL get_param -n lov.$FSNAME-*.pools.$POOL | head -1)
6371 do_facet mgs $LCTL pool_remove $FSNAME.$POOL $TGT
6372 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL | grep $TGT" "" ||
6373 error "$TGT not removed from $FSNAME.$POOL"
6375 run_test 201a "Remove a target from a pool ============================="
6378 test_pools || return 0
6380 for TGT in $($LCTL get_param -n lov.$FSNAME-*.pools.$POOL | sort -u)
6382 do_facet mgs $LCTL pool_remove $FSNAME.$POOL $TGT
6384 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL" "" ||
6385 error "Pool $FSNAME.$POOL cannot be drained"
6386 # striping on an empty/nonexistant pool should fall back to "pool of everything"
6387 touch ${POOL_DIR}/$tfile || error "failed to use fallback striping for empty pool"
6388 # setstripe on an empty pool should fail
6389 $SETSTRIPE -p $POOL ${POOL_FILE}/$tfile 2>/dev/null && \
6390 error "expected failure when creating file with empty pool"
6393 run_test 201b "Remove all targets from a pool =========================="
6396 test_pools || return 0
6398 do_facet mgs $LCTL pool_destroy $FSNAME.$POOL
6401 # striping on an empty/nonexistant pool should fall back to "pool of everything"
6402 touch ${POOL_DIR}/$tfile || error "failed to use fallback striping for missing pool"
6403 # setstripe on an empty pool should fail
6404 $SETSTRIPE -p $POOL ${POOL_FILE}/$tfile 2>/dev/null && \
6405 error "expected failure when creating file with missing pool"
6407 # get param should return err once pool is gone
6408 if wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null ||
6409 echo foo" "foo"; then
6410 remove_pool_from_list $FSNAME.$POOL
6413 error "Pool $FSNAME.$POOL is not destroyed"
6415 run_test 201c "Remove a pool ============================================"
6417 cleanup_pools $FSNAME
6420 $LFS setstripe -c 2 -s 1048576 $DIR/$tfile
6421 multiop $DIR/$tfile oO_WRONLY:O_APPEND:O_DIRECT:b1048548b130c || \
6422 error "direct write failed"
6423 multiop $DIR/${tfile}2 oO_WRONLY:O_CREAT:w1048548w130c || \
6424 error "cached write failed"
6425 cmp $DIR/$tfile $DIR/${tfile}2 || error "cmp failed"
6426 rm -f $DIR/${tfile}2
6428 run_test 202 "O_APPEND+O_DIRECT multistripe write ========================"
6431 # tests that do cleanup/setup should be run at the end
6436 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
6437 $LCTL set_param fail_loc=0x903
6438 # cancel_lru_locks mgc - does not work due to lctl set_param syntax
6439 for ls in /proc/fs/lustre/ldlm/namespaces/MGC*/lru_size; do
6442 FAIL_ON_ERROR=true cleanup
6443 FAIL_ON_ERROR=true setup
6445 run_test 900 "umount should not race with any mgc requeue thread"
6447 log "cleanup: ======================================================"
6448 check_and_cleanup_lustre
6449 if [ "$I_MOUNTED" != "yes" ]; then
6450 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true
6453 echo '=========================== finished ==============================='
6454 [ -f "$SANITYLOG" ] && cat $SANITYLOG && grep -q FAIL $SANITYLOG && exit 1 || true
6455 echo "$0: completed"