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 $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 MUNLINK=${MUNLINK:-munlink}
46 SOCKETSERVER=${SOCKETSERVER:-socketserver}
47 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
48 IOPENTEST1=${IOPENTEST1:-iopentest1}
49 IOPENTEST2=${IOPENTEST2:-iopentest2}
50 MEMHOG=${MEMHOG:-memhog}
51 DIRECTIO=${DIRECTIO:-directio}
52 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
53 UMOUNT=${UMOUNT:-"umount -d"}
54 CHECK_GRANT=${CHECK_GRANT:-"yes"}
55 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
57 export NAME=${NAME:-local}
64 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
65 . $LUSTRE/tests/test-framework.sh
67 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
69 [ "$SLOW" = "no" ] && EXCEPT_SLOW="24o 27m 36f 36g 36h 51b 51c 60c 63 64b 68 71 73 77f 78 101 103 115 120g 124b"
71 FAIL_ON_ERROR=${FAIL_ON_ERROR:-false}
75 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
76 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
86 check_kernel_version() {
89 GOT_VER=$(lctl get_param -n $VERSION_FILE | awk '/kernel:/ {print $2}')
91 patchless|patchless_client) return 0;;
92 *) [ $GOT_VER -ge $WANT_VER ] && return 0 ;;
94 log "test needs at least kernel version $WANT_VER, running $GOT_VER"
98 if [ "$ONLY" == "cleanup" ]; then
103 check_and_setup_lustre
108 LOVNAME=`lctl get_param -n llite.*.lov.common_name | tail -n 1`
109 OSTCOUNT=`lctl get_param -n lov.$LOVNAME.numobd`
110 STRIPECOUNT=`lctl get_param -n lov.$LOVNAME.stripecount`
111 STRIPESIZE=`lctl get_param -n lov.$LOVNAME.stripesize`
112 ORIGFREE=`lctl get_param -n lov.$LOVNAME.kbytesavail`
113 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
115 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
116 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
117 rm -rf $DIR/[Rdfs][0-9]*
119 # $RUNAS_ID may get set incorrectly somewhere else
120 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
122 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
126 echo "preparing for tests involving mounts"
127 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
129 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
130 echo # add a newline after mke2fs.
134 OLDDEBUG="`lctl get_param -n debug 2> /dev/null`"
135 lctl set_param debug=-1 2> /dev/null || true
138 $CHECKSTAT -t file $DIR/$tfile || error
140 $CHECKSTAT -a $DIR/$tfile || error
142 run_test 0 "touch .../$tfile ; rm .../$tfile ====================="
145 chmod 0755 $DIR || error
146 $CHECKSTAT -p 0755 $DIR || error
148 run_test 0b "chmod 0755 $DIR ============================="
151 $LCTL get_param mdc.*.import | grep "state: FULL" || error "import not FULL"
152 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" || error "bad target"
154 run_test 0c "check import proc ============================="
159 $CHECKSTAT -t dir $DIR/d1/d2 || error
161 run_test 1a "mkdir .../d1; mkdir .../d1/d2 ====================="
166 $CHECKSTAT -a $DIR/d1 || error
168 run_test 1b "rmdir .../d1/d2; rmdir .../d1 ====================="
173 $CHECKSTAT -t file $DIR/d2/f || error
175 run_test 2a "mkdir .../d2; touch .../d2/f ======================"
179 $CHECKSTAT -a $DIR/d2 || error
181 run_test 2b "rm -r .../d2; checkstat .../d2/f ======================"
185 $CHECKSTAT -t dir $DIR/d3 || error
187 run_test 3a "mkdir .../d3 ======================================"
190 if [ ! -d $DIR/d3 ]; then
194 $CHECKSTAT -t file $DIR/d3/f || error
196 run_test 3b "touch .../d3/f ===================================="
200 $CHECKSTAT -a $DIR/d3 || error
202 run_test 3c "rm -r .../d3 ======================================"
206 $CHECKSTAT -t dir $DIR/d4 || error
208 run_test 4a "mkdir .../d4 ======================================"
211 if [ ! -d $DIR/d4 ]; then
215 $CHECKSTAT -t dir $DIR/d4/d2 || error
217 run_test 4b "mkdir .../d4/d2 ==================================="
222 chmod 0707 $DIR/d5/d2
223 $CHECKSTAT -t dir -p 0707 $DIR/d5/d2 || error
225 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2 ============"
229 chmod 0666 $DIR/f6a || error
230 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/f6a || error
232 run_test 6a "touch .../f6a; chmod .../f6a ======================"
235 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
236 if [ ! -f $DIR/f6a ]; then
240 $RUNAS chmod 0444 $DIR/f6a && error
241 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/f6a || error
243 run_test 6b "$RUNAS chmod .../f6a (should return error) =="
246 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
248 chown $RUNAS_ID $DIR/f6c || error
249 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/f6c || error
251 run_test 6c "touch .../f6c; chown .../f6c ======================"
254 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
255 if [ ! -f $DIR/f6c ]; then
257 chown $RUNAS_ID $DIR/f6c
259 $RUNAS chown $UID $DIR/f6c && error
260 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/f6c || error
262 run_test 6d "$RUNAS chown .../f6c (should return error) =="
265 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
267 chgrp $RUNAS_ID $DIR/f6e || error
268 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/f6e || error
270 run_test 6e "touch .../f6e; chgrp .../f6e ======================"
273 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
274 if [ ! -f $DIR/f6e ]; then
276 chgrp $RUNAS_ID $DIR/f6e
278 $RUNAS chgrp $UID $DIR/f6e && error
279 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/f6e || error
281 run_test 6f "$RUNAS chgrp .../f6e (should return error) =="
284 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
285 mkdir $DIR/d6g || error
286 chmod 777 $DIR/d6g || error
287 $RUNAS mkdir $DIR/d6g/d || error
288 chmod g+s $DIR/d6g/d || error
289 mkdir $DIR/d6g/d/subdir
290 $CHECKSTAT -g \#$RUNAS_GID $DIR/d6g/d/subdir || error
292 run_test 6g "Is new dir in sgid dir inheriting group?"
294 test_6h() { # bug 7331
295 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
296 touch $DIR/f6h || error "touch failed"
297 chown $RUNAS_ID:$RUNAS_GID $DIR/f6h || error "initial chown failed"
298 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/f6h && error "chown worked"
299 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/f6h || error
301 run_test 6h "$RUNAS chown RUNAS_ID.0 .../f6h (should return error)"
307 $CHECKSTAT -t file -p 0666 $DIR/d7/f || error
309 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
312 if [ ! -d $DIR/d7 ]; then
316 echo -n foo > $DIR/d7/f2
317 [ "`cat $DIR/d7/f2`" = "foo" ] || error
318 $CHECKSTAT -t file -s 3 $DIR/d7/f2 || error
320 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
326 $CHECKSTAT -t file -p 0666 $DIR/d8/f || error
328 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
334 $CHECKSTAT -t dir $DIR/d9/d2/d3 || error
336 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
342 $CHECKSTAT -t file $DIR/d10/d2/f || error
344 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
349 chmod 0666 $DIR/d11/d2
350 chmod 0705 $DIR/d11/d2
351 $CHECKSTAT -t dir -p 0705 $DIR/d11/d2 || error
353 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
358 chmod 0666 $DIR/d12/f
359 chmod 0654 $DIR/d12/f
360 $CHECKSTAT -t file -p 0654 $DIR/d12/f || error
362 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
366 dd if=/dev/zero of=$DIR/d13/f count=10
368 $CHECKSTAT -t file -s 0 $DIR/d13/f || error
370 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
376 $CHECKSTAT -a $DIR/d14/f || error
378 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
383 mv $DIR/d15/f $DIR/d15/f2
384 $CHECKSTAT -t file $DIR/d15/f2 || error
386 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
392 $CHECKSTAT -a $DIR/d16/f || error
394 run_test 16 "touch .../d16/f; rm -rf .../d16/f ================="
399 ln -s $DIR/d17/f $DIR/d17/l-exist
401 $CHECKSTAT -l $DIR/d17/f $DIR/d17/l-exist || error
402 $CHECKSTAT -f -t f $DIR/d17/l-exist || error
403 rm -f $DIR/d17/l-exist
404 $CHECKSTAT -a $DIR/d17/l-exist || error
406 run_test 17a "symlinks: create, remove (real) =================="
410 ln -s no-such-file $DIR/d17/l-dangle
412 $CHECKSTAT -l no-such-file $DIR/d17/l-dangle || error
413 $CHECKSTAT -fa $DIR/d17/l-dangle || error
414 rm -f $DIR/d17/l-dangle
415 $CHECKSTAT -a $DIR/d17/l-dangle || error
417 run_test 17b "symlinks: create, remove (dangling) =============="
419 test_17c() { # bug 3440 - don't save failed open RPC for replay
421 ln -s foo $DIR/d17/f17c
422 cat $DIR/d17/f17c && error "opened non-existent symlink" || true
424 run_test 17c "symlinks: open dangling (should return error) ===="
428 ln -s foo $DIR/d17/f17d
429 touch $DIR/d17/f17d || error "creating to new symlink"
431 run_test 17d "symlinks: create dangling ========================"
435 local foo=$DIR/$tdir/$tfile
436 ln -s $foo $foo || error "create symlink failed"
437 ls -l $foo || error "ls -l failed"
438 ls $foo && error "ls not failed" || true
440 run_test 17e "symlinks: create recursive symlink (should return error) ===="
444 LONGSYMLINK="$(dd if=/dev/zero bs=4095 count=1 | tr '\0' 'x')"
445 ln -s $LONGSYMLINK $DIR/$tdir/$tfile
448 run_test 17g "symlinks: really long symlink name ==============================="
450 test_17h() { #bug 17378
452 $SETSTRIPE $DIR/$tdir -c -1
453 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
454 do_facet mds lctl set_param fail_loc=0x80000141
455 touch $DIR/$tdir/$tfile || true
457 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
459 test_17i() { #bug 20018
461 local foo=$DIR/$tdir/$tfile
462 ln -s $foo $foo || error "create symlink failed"
463 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
464 do_facet mds lctl set_param fail_loc=0x80000143
465 ls -l $foo && error "error not detected"
468 run_test 17i "don't panic on short symlink"
470 test_17k() { #bug 22301
471 rsync --help | grep -q xattr ||
472 skip_env "$(rsync --version| head -1) does not support xattrs"
473 mkdir -p $DIR/{$tdir,$tdir.new}
474 touch $DIR/$tdir/$tfile
475 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
476 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
477 error "rsync failed with xattrs enabled"
479 run_test 17k "symlinks: rsync with xattrs enabled ========================="
485 run_test 18 "touch .../f ; ls ... =============================="
491 $CHECKSTAT -a $DIR/f19 || error
493 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
496 ls -l $DIR/f19 && error || true
498 run_test 19b "ls -l .../f19 (should return error) =============="
501 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
502 $RUNAS touch $DIR/f19 && error || true
504 run_test 19c "$RUNAS touch .../f19 (should return error) =="
507 cat $DIR/f19 && error || true
509 run_test 19d "cat .../f19 (should return error) =============="
521 $CHECKSTAT -a $DIR/f || error
523 run_test 20 "touch .../f ; ls -l ... ==========================="
527 [ -f $DIR/d21/dangle ] && rm -f $DIR/d21/dangle
528 ln -s dangle $DIR/d21/link
529 echo foo >> $DIR/d21/link
531 $CHECKSTAT -t link $DIR/d21/link || error
532 $CHECKSTAT -f -t file $DIR/d21/link || error
534 run_test 21 "write to dangling link ============================"
539 chown $RUNAS_ID:$RUNAS_GID $WDIR
540 (cd $WDIR || error "cd $WDIR failed";
541 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
543 ls -lR $WDIR/etc || error "ls -lR $WDIR/etc failed"
544 $CHECKSTAT -t dir $WDIR/etc || error "checkstat -t dir failed"
545 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $WDIR/etc || error "checkstat -u failed"
547 run_test 22 "unpack tar archive as non-root user ==============="
552 local file=$DIR/$tdir/$tfile
554 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
555 openfile -f O_CREAT:O_EXCL $file &&
556 error "$file recreate succeeded" || true
558 run_test 23a "O_CREAT|O_EXCL in subdir =========================="
560 test_23b() { # bug 18988
562 local file=$DIR/$tdir/$tfile
565 echo foo > $file || error "write filed"
566 echo bar >> $file || error "append filed"
567 $CHECKSTAT -s 8 $file || error "wrong size"
570 run_test 23b "O_APPEND check =========================="
573 echo '== rename sanity =============================================='
574 echo '-- same directory rename'
577 mv $DIR/R1/f $DIR/R1/g
578 $CHECKSTAT -t file $DIR/R1/g || error
580 run_test 24a "touch .../R1/f; rename .../R1/f .../R1/g ========="
585 mv $DIR/R2/f $DIR/R2/g
586 $CHECKSTAT -a $DIR/R2/f || error
587 $CHECKSTAT -t file $DIR/R2/g || error
589 run_test 24b "touch .../R2/{f,g}; rename .../R2/f .../R2/g ====="
594 mv $DIR/R3/f $DIR/R3/g
595 $CHECKSTAT -a $DIR/R3/f || error
596 $CHECKSTAT -t dir $DIR/R3/g || error
598 run_test 24c "mkdir .../R3/f; rename .../R3/f .../R3/g ========="
603 mrename $DIR/R4/f $DIR/R4/g
604 $CHECKSTAT -a $DIR/R4/f || error
605 $CHECKSTAT -t dir $DIR/R4/g || error
607 run_test 24d "mkdir .../R4/{f,g}; rename .../R4/f .../R4/g ====="
610 echo '-- cross directory renames --'
613 mv $DIR/R5a/f $DIR/R5b/g
614 $CHECKSTAT -a $DIR/R5a/f || error
615 $CHECKSTAT -t file $DIR/R5b/g || error
617 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
621 touch $DIR/R6a/f $DIR/R6b/g
622 mv $DIR/R6a/f $DIR/R6b/g
623 $CHECKSTAT -a $DIR/R6a/f || error
624 $CHECKSTAT -t file $DIR/R6b/g || error
626 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
631 mv $DIR/R7a/d $DIR/R7b/e
632 $CHECKSTAT -a $DIR/R7a/d || error
633 $CHECKSTAT -t dir $DIR/R7b/e || error
635 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R5b/e ======"
639 mkdir $DIR/R8a/d $DIR/R8b/e
640 mrename $DIR/R8a/d $DIR/R8b/e
641 $CHECKSTAT -a $DIR/R8a/d || error
642 $CHECKSTAT -t dir $DIR/R8b/e || error
644 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
647 echo "-- rename error cases"
651 mrename $DIR/R9/f $DIR/R9/a
652 $CHECKSTAT -t file $DIR/R9/f || error
653 $CHECKSTAT -t dir $DIR/R9/a || error
654 $CHECKSTAT -a $DIR/R9/a/f || error
656 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
660 mrename $DIR/R10/f $DIR/R10/g
661 $CHECKSTAT -t dir $DIR/R10 || error
662 $CHECKSTAT -a $DIR/R10/f || error
663 $CHECKSTAT -a $DIR/R10/g || error
665 run_test 24j "source does not exist ============================"
668 mkdir $DIR/R11a $DIR/R11a/d
670 mv $DIR/R11a/f $DIR/R11a/d
671 $CHECKSTAT -a $DIR/R11a/f || error
672 $CHECKSTAT -t file $DIR/R11a/d/f || error
674 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
676 # bug 2429 - rename foo foo foo creates invalid file
679 multiop $f OcNs || error
681 run_test 24l "Renaming a file to itself ========================"
685 multiop $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
686 # on ext3 this does not remove either the source or target files
687 # though the "expected" operation would be to remove the source
688 $CHECKSTAT -t file ${f} || error "${f} missing"
689 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
691 run_test 24m "Renaming a file to a hard link to itself ========="
695 # this stats the old file after it was renamed, so it should fail
699 $CHECKSTAT ${f}.rename
702 run_test 24n "Statting the old file after renaming (Posix rename 2)"
705 check_kernel_version 37 || return 0
707 rename_many -s random -v -n 10 $DIR/d24o
709 run_test 24o "rename of files during htree split ==============="
713 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
714 mrename $DIR/R12a $DIR/R12b
715 $CHECKSTAT -a $DIR/R12a || error
716 $CHECKSTAT -t dir $DIR/R12b || error
717 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
718 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
720 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
724 DIRINO=`ls -lid $DIR/R13a | awk '{ print $1 }'`
725 multiop_bg_pause $DIR/R13b D_c || return 1
728 mrename $DIR/R13a $DIR/R13b
729 $CHECKSTAT -a $DIR/R13a || error
730 $CHECKSTAT -t dir $DIR/R13b || error
731 DIRINO2=`ls -lid $DIR/R13b | awk '{ print $1 }'`
732 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
734 wait $MULTIPID || error "multiop close failed"
736 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
738 test_24r() { #bug 3789
739 mkdir $DIR/R14a $DIR/R14a/b
740 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
741 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
742 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
744 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
747 mkdir $DIR/R15a $DIR/R15a/b $DIR/R15a/b/c
748 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
749 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
750 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
752 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
754 mkdir $DIR/R16a $DIR/R16a/b $DIR/R16a/b/c
755 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
756 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
757 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
759 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
761 test_24u() { # bug12192
762 multiop $DIR/$tfile C2w$((2048 * 1024))c || error
763 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
765 run_test 24u "create stripe file"
767 test_24w() { # bug21506
769 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || \
770 error "First write failed."
771 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || \
772 error "Second write failed."
773 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || \
774 error "Reading the file failed."
775 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
776 [ "$SZ1" = "$SZ2" ] || \
777 error "Error reading at the end of the file $tfile"
779 run_test 24w "Reading a file larger than 4Gb"
782 echo '== symlink sanity ============================================='
786 touch $DIR/s25/foo || error
788 run_test 25a "create file in symlinked directory ==============="
791 [ ! -d $DIR/d25 ] && test_25a
792 $CHECKSTAT -t file $DIR/s25/foo || error
794 run_test 25b "lookup file in symlinked directory ==============="
799 ln -s d26/d26-2 $DIR/s26
800 touch $DIR/s26/foo || error
802 run_test 26a "multiple component symlink ======================="
805 mkdir -p $DIR/d26b/d26-2
806 ln -s d26b/d26-2/foo $DIR/s26-2
807 touch $DIR/s26-2 || error
809 run_test 26b "multiple component symlink at end of lookup ======"
814 ln -s d26.2 $DIR/s26.2-1
815 ln -s s26.2-1 $DIR/s26.2-2
816 ln -s s26.2-2 $DIR/s26.2-3
817 chmod 0666 $DIR/s26.2-3/foo
819 run_test 26c "chain of symlinks ================================"
821 # recursive symlinks (bug 439)
823 ln -s d26-3/foo $DIR/d26-3
825 run_test 26d "create multiple component recursive symlink ======"
828 [ ! -h $DIR/d26-3 ] && test_26d
831 run_test 26e "unlink multiple component recursive symlink ======"
833 # recursive symlinks (bug 7022)
836 mkdir $DIR/$tdir/$tfile || error "mkdir $DIR/$tdir/$tfile failed"
837 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
838 mkdir -p lndir/bar1 || error "mkdir lndir/bar1 failed"
839 mkdir $tfile || error "mkdir $tfile failed"
840 cd $tfile || error "cd $tfile failed"
841 ln -s .. dotdot || error "ln dotdot failed"
842 ln -s dotdot/lndir lndir || error "ln lndir failed"
843 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
844 output=`ls $tfile/$tfile/lndir/bar1`
845 [ "$output" = bar1 ] && error "unexpected output"
846 rm -r $tfile || error "rm $tfile failed"
847 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
849 run_test 26f "rm -r of a directory which has recursive symlink ="
852 echo '== stripe sanity =============================================='
853 mkdir -p $DIR/d27 || error "mkdir failed"
855 $SETSTRIPE $DIR/d27/f0 -c 1 || error "lstripe failed"
856 $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
858 log "== test 27b: write to one stripe file ========================="
859 cp /etc/hosts $DIR/d27/f0 || error
861 run_test 27a "one stripe file =================================="
864 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
866 $SETSTRIPE $DIR/d27/f01 -c 2 || error "lstripe failed"
867 [ `$GETSTRIPE $DIR/d27/f01 | grep -A 10 obdidx | wc -l` -eq 4 ] ||
868 error "two-stripe file doesn't have two stripes"
870 log "== test 27d: write to two stripe file file f01 ================"
871 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
873 run_test 27c "create two stripe file f01 ======================="
877 $SETSTRIPE -c0 -i-1 -s0 $DIR/d27/fdef || error "lstripe failed"
878 $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
879 dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
881 run_test 27d "create file with default settings ================"
885 $SETSTRIPE $DIR/d27/f12 -c 2 || error "lstripe failed"
886 $SETSTRIPE $DIR/d27/f12 -c 2 && error "lstripe succeeded twice"
887 $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
889 run_test 27e "setstripe existing file (should return error) ======"
893 $SETSTRIPE $DIR/d27/fbad -s 100 -i 0 -c 1 && error "lstripe failed"
894 dd if=/dev/zero of=$DIR/d27/f12 bs=4k count=4 || error "dd failed"
895 $GETSTRIPE $DIR/d27/fbad || error "lfs getstripe failed"
897 run_test 27f "setstripe with bad stripe size (should return error)"
901 $MCREATE $DIR/d27/fnone || error "mcreate failed"
903 log "== test 27h: lfs getstripe with no objects ===================="
904 $GETSTRIPE $DIR/d27/fnone 2>&1 | grep "no stripe info" || error "has object"
906 log "== test 27i: lfs getstripe with some objects =================="
907 touch $DIR/d27/fsome || error "touch failed"
908 $GETSTRIPE $DIR/d27/fsome | grep obdidx || error "missing objects"
910 run_test 27g "test lfs getstripe ==========================================="
914 $SETSTRIPE $DIR/d27/f27j -i $OSTCOUNT && error "lstripe failed"||true
916 run_test 27j "setstripe with bad stripe offset (should return error)"
918 test_27k() { # bug 2844
921 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
922 [ ! -d $DIR/d27 ] && mkdir -p $DIR/d27
923 $SETSTRIPE $FILE -s 67108864 || error "lstripe failed"
924 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
925 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
926 dd if=/dev/zero of=$FILE bs=4k count=1
927 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
928 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
930 run_test 27k "limit i_blksize for broken user apps ============="
934 mcreate $DIR/f27l || error "creating file"
935 $RUNAS $SETSTRIPE $DIR/f27l -c 1 && \
936 error "lstripe should have failed" || true
938 run_test 27l "check setstripe permissions (should return error)"
941 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
942 if [ $ORIGFREE -gt $MAXFREE ]; then
943 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
947 $SETSTRIPE $DIR/d27/f27m_1 -i 0 -c 1
948 dd if=/dev/zero of=$DIR/d27/f27m_1 bs=1024 count=$MAXFREE && \
949 error "dd should fill OST0"
951 while $SETSTRIPE $DIR/d27/f27m_$i -i 0 -c 1 ; do
953 [ $i -gt 256 ] && break
956 touch $DIR/d27/f27m_$i
957 [ `$GETSTRIPE $DIR/d27/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] && \
958 error "OST0 was full but new created file still use it"
960 touch $DIR/d27/f27m_$i
961 [ `$GETSTRIPE $DIR/d27/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] && \
962 error "OST0 was full but new created file still use it"
965 run_test 27m "create file while OST0 was full =================="
968 local DELAY=$(do_facet mds lctl get_param -n lov.*.qos_maxage | awk '{print $1 * 2}')
972 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
973 # if the OST isn't full anymore.
975 local OSTIDX=${1:-""}
977 local list=$(comma_list $(osts_nodes))
978 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
980 do_nodes $list lctl set_param fail_loc=0
984 exhaust_precreations() {
987 local FAILIDX=${3:-$OSTIDX}
989 local OST=$(lfs osts | grep ${OSTIDX}": " | \
990 awk '{print $2}' | sed -e 's/_UUID$//')
993 local mdtosc=$(get_mdtosc_proc_path $OST)
994 local last_id=$(do_facet mds lctl get_param -n osc.$mdtosc.prealloc_last_id)
995 local next_id=$(do_facet mds lctl get_param -n osc.$mdtosc.prealloc_next_id)
997 mkdir -p $DIR/$tdir/${OST}
998 $SETSTRIPE $DIR/$tdir/${OST} -i $OSTIDX -c 1
999 #define OBD_FAIL_OST_ENOSPC 0x215
1000 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=$FAILIDX
1001 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x215
1002 echo "Creating to objid $last_id on ost $OST..."
1003 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1004 do_facet mds "lctl get_param -n osc.$mdtosc.prealloc*" | grep '[0-9]'
1005 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=$FAILLOC
1009 exhaust_all_precreations() {
1011 for (( i=0; i < OSTCOUNT; i++ )) ; do
1012 exhaust_precreations $i $1 -1
1017 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1018 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1019 remote_ost_nodsh && skip "remote OST with nodsh" && return
1022 rm -f $DIR/$tdir/$tfile
1023 exhaust_precreations 0 0x80000215
1024 $SETSTRIPE -c -1 $DIR/$tdir
1025 touch $DIR/$tdir/$tfile || error
1026 $GETSTRIPE $DIR/$tdir/$tfile
1029 run_test 27n "create file with some full OSTs =================="
1032 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1033 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1034 remote_ost_nodsh && skip "remote OST with nodsh" && return
1037 rm -f $DIR/$tdir/$tfile
1038 exhaust_all_precreations 0x215
1040 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1045 run_test 27o "create file with all full OSTs (should error) ===="
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
1056 $MCREATE $DIR/$tdir/$tfile || error
1057 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error
1058 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error
1060 exhaust_precreations 0 0x80000215
1061 echo foo >> $DIR/$tdir/$tfile || error
1062 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error
1066 run_test 27p "append to a truncated file with some full OSTs ==="
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
1076 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1077 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||error "truncate $DIR/$tdir/$tfile failed"
1078 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1080 exhaust_all_precreations 0x215
1082 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1083 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1087 run_test 27q "append to truncated file with all OSTs full (should error) ==="
1090 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1091 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1092 remote_ost_nodsh && skip "remote OST with nodsh" && return
1095 rm -f $DIR/$tdir/$tfile
1096 exhaust_precreations 0 0x80000215
1098 $SETSTRIPE $DIR/$tdir/$tfile -i 0 -c 2 # && error
1102 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1104 test_27s() { # bug 10725
1106 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1107 local stripe_count=0
1108 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1109 $SETSTRIPE $DIR/$tdir -s $stripe_size -c $stripe_count && \
1110 error "stripe width >= 2^32 succeeded" || true
1112 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1114 test_27t() { # bug 10864
1119 $WLFS getstripe $tfile
1122 run_test 27t "check that utils parse path correctly"
1124 test_27u() { # bug 4900
1125 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1126 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1128 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1130 do_facet mds lctl set_param fail_loc=0x139
1132 createmany -o $DIR/$tdir/t- 1000
1133 do_facet mds lctl set_param fail_loc=0
1135 TLOG=$DIR/$tfile.getstripe
1136 $GETSTRIPE $DIR/$tdir > $TLOG
1137 OBJS=`awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj;}' $TLOG`
1138 unlinkmany $DIR/$tdir/t- 1000
1139 [ $OBJS -gt 0 ] && \
1140 error "$OBJS objects created on OST-0. See $TLOG" || pass
1142 run_test 27u "skip object creation on OSC w/o objects =========="
1144 test_27v() { # bug 4900
1145 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1146 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1147 remote_ost_nodsh && skip "remote OST with nodsh" && return
1149 exhaust_all_precreations 0x215
1153 $SETSTRIPE $DIR/$tdir -c 1 # 1 stripe / file
1155 touch $DIR/$tdir/$tfile
1156 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1158 for (( i=0; i < OSTCOUNT; i++ )) ; do
1159 do_facet ost$i lctl set_param fail_loc=0x705
1161 local START=`date +%s`
1162 createmany -o $DIR/$tdir/$tfile 32
1164 local FINISH=`date +%s`
1165 local TIMEOUT=`lctl get_param -n timeout`
1166 [ $((FINISH - START)) -ge $((TIMEOUT / 2)) ] && \
1167 error "$FINISH - $START >= $TIMEOUT / 2"
1171 run_test 27v "skip object creation on slow OST ================="
1173 test_27w() { # bug 10997
1174 mkdir -p $DIR/$tdir || error "mkdir failed"
1175 $SETSTRIPE $DIR/$tdir/f0 -s 65536 || error "lstripe failed"
1176 size=`$GETSTRIPE $DIR/$tdir/f0 -s`
1177 [ $size -ne 65536 ] && error "stripe size $size != 65536" || true
1178 gsdir=$($LFS getstripe -d $DIR/$tdir)
1179 [ $(echo $gsdir | grep -c stripe_count) -ne 1 ] && error "$LFS getstripe -d $DIR/$tdir failed"
1181 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping multiple stripe count/offset test" && return
1182 for i in `seq 1 $OSTCOUNT`; do
1184 log setstripe $DIR/$tdir/f$i -c $i -i $offset
1185 $SETSTRIPE $DIR/$tdir/f$i -c $i -i $offset || error "lstripe -c $i -i $offset failed"
1186 count=`$GETSTRIPE -c $DIR/$tdir/f$i`
1187 index=`$GETSTRIPE -o $DIR/$tdir/f$i`
1188 [ $count -ne $i ] && error "stripe count $count != $i" || true
1189 [ $index -ne $offset ] && error "stripe offset $index != $offset" || true
1192 run_test 27w "check lfs setstripe -c -s -i options ============="
1195 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs" && return
1196 OFFSET=$(($OSTCOUNT - 1))
1198 local OST=$(lfs osts | awk '/'${OSTIDX}': / { print $2 }' | sed -e 's/_UUID$//')
1201 $SETSTRIPE $DIR/$tdir -c 1 # 1 stripe per file
1202 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1204 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1205 for i in `seq 0 $OFFSET`; do
1206 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}' | grep -w "$OSTIDX"` ] &&
1207 error "OST0 was degraded but new created file still use it"
1209 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1211 run_test 27x "create files while OST0 is degraded"
1214 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1215 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1217 MDS_OSCS=`do_facet mds lctl dl | awk '/[oO][sS][cC].*md[ts]/ { print $4 }'`
1218 OFFSET=$(($OSTCOUNT-1))
1220 for OSC in $MDS_OSCS; do
1221 if [ $OST == -1 ]; then {
1222 OST=`osc_to_ost $OSC`
1224 echo $OSC "is Deactivate:"
1225 do_facet mds lctl --device %$OSC deactivate
1229 OSTIDX=$(lfs osts | grep ${OST} | awk '{print $1}' | sed -e 's/://')
1231 $SETSTRIPE $DIR/$tdir -c 1 # 1 stripe / file
1233 do_facet ost$OSTIDX lctl set_param -n obdfilter.$OST.degraded 1
1235 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1236 do_facet ost$OSTIDX lctl set_param -n obdfilter.$OST.degraded 0
1238 for i in `seq 0 $OFFSET`; do
1239 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "$OSTIDX"` ] || \
1240 error "files created on deactivated OSTs instead of degraded OST"
1242 for OSC in $MDS_OSCS; do
1243 [ `osc_to_ost $OSC` != $OST ] && {
1244 echo $OSC "is activate"
1245 do_facet mds lctl --device %$OSC activate
1249 run_test 27y "create files while OST0 is degraded and the rest inactive"
1251 test_27z() { # b=19102
1252 local restore_size=`$GETSTRIPE -s $MOUNT`
1253 local restore_count=`$GETSTRIPE -c $MOUNT`
1254 local restore_offset=`$GETSTRIPE -o $MOUNT`
1255 $SETSTRIPE -c 0 -o -1 -s 0 $MOUNT
1256 local default_size=`$GETSTRIPE -s $MOUNT`
1257 local default_count=`$GETSTRIPE -c $MOUNT`
1258 local default_offset=`$GETSTRIPE -o $MOUNT`
1259 local dsize=$((1024 * 1024))
1260 [ $default_size -eq $dsize ] || error "stripe size $default_size != $dsize"
1261 [ $default_count -eq 1 ] || error "stripe count $default_count != 1"
1262 [ $default_offset -eq -1 ] || error "stripe offset $default_offset != -1"
1263 $SETSTRIPE -c $restore_count -o $restore_offset -s $restore_size $MOUNT
1265 run_test 27z "check filesystem-wide default LOV EA values"
1267 # createtest also checks that device nodes are created and
1268 # then visible correctly (#2091)
1269 test_28() { # bug 2091
1271 $CREATETEST $DIR/d28/ct || error
1273 run_test 28 "create/mknod/mkdir with bad file types ============"
1276 cancel_lru_locks mdc
1281 LOCKCOUNTORIG=`lctl get_param -n ldlm.namespaces.*mdc*.lock_count`
1282 LOCKUNUSEDCOUNTORIG=`lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count`
1283 [ -z $"LOCKCOUNTORIG" ] && error "No mdc lock count" && return 1
1287 LOCKCOUNTCURRENT=`lctl get_param -n ldlm.namespaces.*mdc*.lock_count`
1288 LOCKUNUSEDCOUNTCURRENT=`lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count`
1289 if [ "$LOCKCOUNTCURRENT" -gt "$LOCKCOUNTORIG" ]; then
1290 lctl set_param -n ldlm.dump_namespaces ""
1291 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
1292 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1293 log "dumped log to $TMP/test_29.dk (bug 5793)"
1296 if [ "$LOCKUNUSEDCOUNTCURRENT" -gt "$LOCKUNUSEDCOUNTORIG" ]; then
1297 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
1298 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1299 log "dumped log to $TMP/test_29.dk (bug 5793)"
1303 run_test 29 "IT_GETATTR regression ============================"
1305 test_30a() { # was test_30
1310 run_test 30a "execute binary from Lustre (execve) =============="
1315 $RUNAS $DIR/ls / || error
1318 run_test 30b "execute binary from Lustre as non-root ==========="
1320 test_30c() { # b=22376
1323 cancel_lru_locks mdc
1324 cancel_lru_locks osc
1325 $RUNAS $DIR/ls / || error
1328 run_test 30c "execute binary from Lustre without read perms ===="
1331 $OPENUNLINK $DIR/f31 $DIR/f31 || error
1332 $CHECKSTAT -a $DIR/f31 || error
1334 run_test 31a "open-unlink file =================================="
1337 touch $DIR/f31 || error
1338 ln $DIR/f31 $DIR/f31b || error
1339 multiop $DIR/f31b Ouc || error
1340 $CHECKSTAT -t file $DIR/f31 || error
1342 run_test 31b "unlink file with multiple links while open ======="
1345 touch $DIR/f31 || error
1346 ln $DIR/f31 $DIR/f31c || error
1347 multiop_bg_pause $DIR/f31 O_uc || return 1
1349 multiop $DIR/f31c Ouc
1350 kill -USR1 $MULTIPID
1353 run_test 31c "open-unlink file with multiple links ============="
1356 opendirunlink $DIR/d31d $DIR/d31d || error
1357 $CHECKSTAT -a $DIR/d31d || error
1359 run_test 31d "remove of open directory ========================="
1361 test_31e() { # bug 2904
1362 check_kernel_version 34 || return 0
1363 openfilleddirunlink $DIR/d31e || error
1365 run_test 31e "remove of open non-empty directory ==============="
1367 test_31f() { # bug 4554
1370 $SETSTRIPE $DIR/d31f -s 1048576 -c 1
1371 cp /etc/hosts $DIR/d31f
1373 $GETSTRIPE $DIR/d31f/hosts
1374 multiop_bg_pause $DIR/d31f D_c || return 1
1377 rm -rv $DIR/d31f || error "first of $DIR/d31f"
1379 $SETSTRIPE $DIR/d31f -s 1048576 -c 1
1380 cp /etc/hosts $DIR/d31f
1383 multiop_bg_pause $DIR/d31f D_c || return 1
1386 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
1387 wait $MULTIPID || error "first opendir $MULTIPID failed"
1391 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
1392 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
1395 run_test 31f "remove of open directory with open-unlink file ==="
1398 echo "== more mountpoints and symlinks ================="
1399 [ -e $DIR/d32a ] && rm -fr $DIR/d32a
1400 mkdir -p $DIR/d32a/ext2-mountpoint
1401 mount -t ext2 -o loop $EXT2_DEV $DIR/d32a/ext2-mountpoint || error
1402 $CHECKSTAT -t dir $DIR/d32a/ext2-mountpoint/.. || error
1403 $UMOUNT $DIR/d32a/ext2-mountpoint || error
1405 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
1408 [ -e $DIR/d32b ] && rm -fr $DIR/d32b
1409 mkdir -p $DIR/d32b/ext2-mountpoint
1410 mount -t ext2 -o loop $EXT2_DEV $DIR/d32b/ext2-mountpoint || error
1411 ls -al $DIR/d32b/ext2-mountpoint/.. || error
1412 $UMOUNT $DIR/d32b/ext2-mountpoint || error
1414 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
1417 [ -e $DIR/d32c ] && rm -fr $DIR/d32c
1418 mkdir -p $DIR/d32c/ext2-mountpoint
1419 mount -t ext2 -o loop $EXT2_DEV $DIR/d32c/ext2-mountpoint || error
1420 mkdir -p $DIR/d32c/d2/test_dir
1421 $CHECKSTAT -t dir $DIR/d32c/ext2-mountpoint/../d2/test_dir || error
1422 $UMOUNT $DIR/d32c/ext2-mountpoint || error
1424 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
1427 [ -e $DIR/d32d ] && rm -fr $DIR/d32d
1428 mkdir -p $DIR/d32d/ext2-mountpoint
1429 mount -t ext2 -o loop $EXT2_DEV $DIR/d32d/ext2-mountpoint || error
1430 mkdir -p $DIR/d32d/d2/test_dir
1431 ls -al $DIR/d32d/ext2-mountpoint/../d2/test_dir || error
1432 $UMOUNT $DIR/d32d/ext2-mountpoint || error
1434 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
1437 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
1438 mkdir -p $DIR/d32e/tmp
1439 TMP_DIR=$DIR/d32e/tmp
1440 ln -s $DIR/d32e $TMP_DIR/symlink11
1441 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1442 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
1443 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
1445 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
1448 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
1449 mkdir -p $DIR/d32f/tmp
1450 TMP_DIR=$DIR/d32f/tmp
1451 ln -s $DIR/d32f $TMP_DIR/symlink11
1452 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1453 ls $DIR/d32f/tmp/symlink11 || error
1454 ls $DIR/d32f/symlink01 || error
1456 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
1459 TMP_DIR=$DIR/$tdir/tmp
1460 mkdir -p $TMP_DIR $DIR/${tdir}2
1461 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
1462 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1463 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
1464 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
1465 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
1466 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
1468 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
1471 rm -fr $DIR/$tdir $DIR/${tdir}2
1472 TMP_DIR=$DIR/$tdir/tmp
1473 mkdir -p $TMP_DIR $DIR/${tdir}2
1474 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
1475 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1476 ls $TMP_DIR/symlink12 || error
1477 ls $DIR/$tdir/symlink02 || error
1479 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
1482 [ -e $DIR/d32i ] && rm -fr $DIR/d32i
1483 mkdir -p $DIR/d32i/ext2-mountpoint
1484 mount -t ext2 -o loop $EXT2_DEV $DIR/d32i/ext2-mountpoint || error
1485 touch $DIR/d32i/test_file
1486 $CHECKSTAT -t file $DIR/d32i/ext2-mountpoint/../test_file || error
1487 $UMOUNT $DIR/d32i/ext2-mountpoint || error
1489 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
1492 [ -e $DIR/d32j ] && rm -fr $DIR/d32j
1493 mkdir -p $DIR/d32j/ext2-mountpoint
1494 mount -t ext2 -o loop $EXT2_DEV $DIR/d32j/ext2-mountpoint || error
1495 touch $DIR/d32j/test_file
1496 cat $DIR/d32j/ext2-mountpoint/../test_file || error
1497 $UMOUNT $DIR/d32j/ext2-mountpoint || error
1499 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
1503 mkdir -p $DIR/d32k/ext2-mountpoint
1504 mount -t ext2 -o loop $EXT2_DEV $DIR/d32k/ext2-mountpoint
1505 mkdir -p $DIR/d32k/d2
1506 touch $DIR/d32k/d2/test_file || error
1507 $CHECKSTAT -t file $DIR/d32k/ext2-mountpoint/../d2/test_file || error
1508 $UMOUNT $DIR/d32k/ext2-mountpoint || error
1510 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
1514 mkdir -p $DIR/d32l/ext2-mountpoint
1515 mount -t ext2 -o loop $EXT2_DEV $DIR/d32l/ext2-mountpoint || error
1516 mkdir -p $DIR/d32l/d2
1517 touch $DIR/d32l/d2/test_file
1518 cat $DIR/d32l/ext2-mountpoint/../d2/test_file || error
1519 $UMOUNT $DIR/d32l/ext2-mountpoint || error
1521 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
1525 mkdir -p $DIR/d32m/tmp
1526 TMP_DIR=$DIR/d32m/tmp
1527 ln -s $DIR $TMP_DIR/symlink11
1528 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1529 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
1530 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
1532 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
1536 mkdir -p $DIR/d32n/tmp
1537 TMP_DIR=$DIR/d32n/tmp
1538 ln -s $DIR $TMP_DIR/symlink11
1539 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1540 ls -l $DIR/d32n/tmp/symlink11 || error
1541 ls -l $DIR/d32n/symlink01 || error
1543 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
1546 rm -fr $DIR/d32o $DIR/$tfile
1548 mkdir -p $DIR/d32o/tmp
1549 TMP_DIR=$DIR/d32o/tmp
1550 ln -s $DIR/$tfile $TMP_DIR/symlink12
1551 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1552 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
1553 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
1554 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
1555 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
1557 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
1567 mkdir -p $DIR/d32p/tmp
1569 TMP_DIR=$DIR/d32p/tmp
1571 ln -s $DIR/$tfile $TMP_DIR/symlink12
1573 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1575 cat $DIR/d32p/tmp/symlink12 || error
1577 cat $DIR/d32p/symlink02 || error
1580 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
1583 [ -e $DIR/d32q ] && rm -fr $DIR/d32q
1585 touch $DIR/d32q/under_the_mount
1586 mount -t ext2 -o loop $EXT2_DEV $DIR/d32q
1587 ls $DIR/d32q/under_the_mount && error || true
1588 $UMOUNT $DIR/d32q || error
1590 run_test 32q "stat follows mountpoints in Lustre (should return error)"
1593 [ -e $DIR/d32r ] && rm -fr $DIR/d32r
1595 touch $DIR/d32r/under_the_mount
1596 mount -t ext2 -o loop $EXT2_DEV $DIR/d32r
1597 ls $DIR/d32r | grep -q under_the_mount && error || true
1598 $UMOUNT $DIR/d32r || error
1600 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
1605 chmod 444 $DIR/$tfile
1606 chown $RUNAS_ID $DIR/$tfile
1608 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
1611 run_test 33 "write file with mode 444 (should return error) ===="
1616 chown $RUNAS_ID $DIR/d33
1617 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
1618 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
1619 error "open RDWR" || true
1621 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
1626 chown $RUNAS_ID $DIR/d33
1627 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33 || true
1629 run_test 33b "test open file with malformed flags (No panic)"
1631 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
1634 $MCREATE $DIR/f34 || error
1635 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
1636 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
1637 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
1638 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1640 run_test 34a "truncate file that has not been opened ==========="
1643 [ ! -f $DIR/f34 ] && test_34a
1644 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1645 $OPENFILE -f O_RDONLY $DIR/f34
1646 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
1647 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1649 run_test 34b "O_RDONLY opening file doesn't create objects ====="
1652 [ ! -f $DIR/f34 ] && test_34a
1653 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1654 $OPENFILE -f O_RDWR $DIR/f34
1655 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
1656 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1658 run_test 34c "O_RDWR opening file-with-size works =============="
1661 [ ! -f $DIR/f34 ] && test_34a
1662 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
1663 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1666 run_test 34d "write to sparse file ============================="
1670 $MCREATE $DIR/f34e || error
1671 $TRUNCATE $DIR/f34e 1000 || error
1672 $CHECKSTAT -s 1000 $DIR/f34e || error
1673 $OPENFILE -f O_RDWR $DIR/f34e
1674 $CHECKSTAT -s 1000 $DIR/f34e || error
1676 run_test 34e "create objects, some with size and some without =="
1678 test_34f() { # bug 6242, 6243
1681 $MCREATE $DIR/f34f || error
1682 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
1683 dd if=$DIR/f34f of=$TMP/f34f
1684 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
1685 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
1686 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
1687 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
1688 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
1690 run_test 34f "read from a file with no objects until EOF ======="
1693 cp /bin/sh $DIR/f35a
1695 chown $RUNAS_ID $DIR/f35a
1696 $RUNAS $DIR/f35a && error || true
1699 run_test 35a "exec file with mode 444 (should return and not leak) ====="
1703 utime $DIR/f36 || error
1705 run_test 36a "MDS utime check (mknod, utime) ==================="
1709 utime $DIR/f36 || error
1711 run_test 36b "OST utime check (open, utime) ===================="
1716 chown $RUNAS_ID $DIR/d36
1717 $RUNAS utime $DIR/d36/f36 || error
1719 run_test 36c "non-root MDS utime check (mknod, utime) =========="
1722 [ ! -d $DIR/d36 ] && test_36c
1723 echo "" > $DIR/d36/f36
1724 $RUNAS utime $DIR/d36/f36 || error
1726 run_test 36d "non-root OST utime check (open, utime) ==========="
1729 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
1731 touch $DIR/$tdir/$tfile
1732 $RUNAS utime $DIR/$tdir/$tfile && \
1733 error "utime worked, expected failure" || true
1735 run_test 36e "utime on non-owned file (should return error) ===="
1739 export LANG=C LC_LANG=C # for date language
1741 DATESTR="Dec 20 2000"
1743 lctl set_param fail_loc=$fl
1745 cp /etc/hosts $DIR/$tdir/$tfile
1746 sync & # write RPC generated with "current" inode timestamp, but delayed
1748 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
1749 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
1750 cancel_lru_locks osc
1751 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
1753 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
1754 echo "BEFORE: $LS_BEFORE" && \
1755 echo "AFTER : $LS_AFTER" && \
1756 echo "WANT : $DATESTR" && \
1757 error "$DIR/$tdir/$tfile timestamps changed" || true
1761 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
1762 subr_36fh "0x80000214"
1764 run_test 36f "utime on file racing with OST BRW write =========="
1767 remote_ost_nodsh && skip "remote OST with nodsh" && return
1770 export FMD_MAX_AGE=`do_facet ost1 lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | head -n 1`
1771 FMD_BEFORE="`awk '/ll_fmd_cache/ { print $2 }' /proc/slabinfo`"
1772 touch $DIR/$tdir/$tfile
1773 sleep $((FMD_MAX_AGE + 12))
1774 FMD_AFTER="`awk '/ll_fmd_cache/ { print $2 }' /proc/slabinfo`"
1775 [ "$FMD_AFTER" -gt "$FMD_BEFORE" ] && \
1776 echo "AFTER : $FMD_AFTER > BEFORE $FMD_BEFORE" && \
1777 error "fmd didn't expire after ping" || true
1779 run_test 36g "filter mod data cache expiry ====================="
1782 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
1783 subr_36fh "0x80000227"
1785 run_test 36h "utime on file racing with OST BRW write =========="
1789 echo f > $DIR/$tdir/fbugfile
1790 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
1791 ls $DIR/$tdir | grep "\<fbugfile\>" && error
1792 $UMOUNT $DIR/$tdir || error
1793 rm -f $DIR/$tdir/fbugfile || error
1795 run_test 37 "ls a mounted file system to check old content ====="
1798 local file=$DIR/$tfile
1800 openfile -f O_DIRECTORY $file
1803 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
1804 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
1806 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
1810 touch $DIR/${tfile}2
1811 # ls -l $DIR/$tfile $DIR/${tfile}2
1812 # ls -lu $DIR/$tfile $DIR/${tfile}2
1813 # ls -lc $DIR/$tfile $DIR/${tfile}2
1815 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
1816 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
1818 ls -l $DIR/$tfile $DIR/${tfile}2
1820 ls -lu $DIR/$tfile $DIR/${tfile}2
1822 ls -lc $DIR/$tfile $DIR/${tfile}2
1823 error "O_TRUNC didn't change timestamps"
1826 run_test 39 "mtime changed on create ==========================="
1828 function get_times() {
1833 for time in `stat -c "%X %Y %Z" $FILE`; do
1834 eval "$TIME[$i]=$time"
1844 cp -p /etc/passwd $DIR/$tdir/fopen
1845 cp -p /etc/passwd $DIR/$tdir/flink
1846 cp -p /etc/passwd $DIR/$tdir/funlink
1847 cp -p /etc/passwd $DIR/$tdir/frename
1848 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
1850 get_times $DIR/$tdir/fopen OPEN_OLD
1851 get_times $DIR/$tdir/flink LINK_OLD
1852 get_times $DIR/$tdir/funlink UNLINK_OLD
1853 get_times $DIR/$tdir/frename RENAME_OLD
1856 echo "aaaaaa" >> $DIR/$tdir/fopen
1857 echo "aaaaaa" >> $DIR/$tdir/flink
1858 echo "aaaaaa" >> $DIR/$tdir/funlink
1859 echo "aaaaaa" >> $DIR/$tdir/frename
1861 get_times $DIR/$tdir/fopen OPEN_NEW
1862 get_times $DIR/$tdir/flink LINK_NEW
1863 get_times $DIR/$tdir/funlink UNLINK_NEW
1864 get_times $DIR/$tdir/frename RENAME_NEW
1866 cat $DIR/$tdir/fopen > /dev/null
1867 ln $DIR/$tdir/flink $DIR/$tdir/flink2
1868 rm -f $DIR/$tdir/funlink2
1869 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
1871 get_times $DIR/$tdir/fopen OPEN_NEW2
1872 get_times $DIR/$tdir/flink LINK_NEW2
1873 get_times $DIR/$tdir/funlink UNLINK_NEW2
1874 get_times $DIR/$tdir/frename2 RENAME_NEW2
1875 echo ${OPEN_OLD[1]},${OPEN_NEW[$MTIME]},${OPEN_NEW2[$MTIME]}
1876 echo ${LINK_OLD[1]},${LINK_NEW[$MTIME]},${LINK_NEW2[$MTIME]}
1877 echo ${UNLINK_OLD[1]},${UNLINK_NEW[$MTIME]},${UNLINK_NEW2[$MTIME]}
1878 echo ${RENAME_OLD[1]},${RENAME_NEW[$MTIME]},${RENAME_NEW2[$MTIME]}
1880 [ ${OPEN_NEW2[$MTIME]} -eq ${OPEN_NEW[$MTIME]} ] || error "open file reverses mtime"
1881 [ ${LINK_NEW2[$MTIME]} -eq ${LINK_NEW[$MTIME]} ] || error "link file reverses mtime"
1882 [ ${UNLINK_NEW2[$MTIME]} -eq ${UNLINK_NEW[$MTIME]} ] || error "unlink file reverses mtime"
1883 [ ${RENAME_NEW2[$MTIME]} -eq ${RENAME_NEW[$MTIME]} ] || error "rename file reverses mtime"
1885 run_test 39b "mtime change on close ============================"
1889 touch -m -d "10 years ago" $DIR1/$tfile
1890 local MTIME1=`stat -c %y $DIR1/$tfile`
1891 echo hello >> $DIR1/$tfile
1892 local MTIME2=`stat -c %y $DIR1/$tfile`
1893 mv $DIR1/$tfile $DIR1/$tfile-1
1894 local MTIME3=`stat -c %y $DIR1/$tfile-1`
1895 [ "$MTIME2" = "$MTIME3" ] ||
1896 error "mtime ($MTIME2) changed (to $MTIME3) on rename (BZ#11063)"
1898 run_test 39c "mtime change on rename ==========================="
1901 dd if=/dev/zero of=$DIR/f40 bs=4096 count=1
1902 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/f40 && error
1903 $CHECKSTAT -t file -s 4096 $DIR/f40 || error
1905 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
1909 small_write $DIR/f41 18
1911 run_test 41 "test small file write + fstat ====================="
1913 count_ost_writes() {
1914 lctl get_param -n osc.*.stats |
1915 awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }'
1922 BG_DIRTY_RATIO_SAVE=10
1923 MAX_BG_DIRTY_RATIO=25
1927 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
1928 # dirty_ratio, dirty_background_ratio
1929 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
1930 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
1931 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
1932 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
1934 # if file not here, we are a 2.4 kernel
1935 kill -CONT `pidof kupdated`
1940 # setup the trap first, so someone cannot exit the test at the
1941 # exact wrong time and mess up a machine
1942 trap start_writeback EXIT
1943 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
1944 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
1945 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
1946 sysctl -w vm.dirty_writeback_centisecs=0
1947 # save and increase /proc/sys/vm/dirty_ratio
1948 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
1949 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
1950 # save and increase /proc/sys/vm/dirty_background_ratio
1951 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
1952 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
1954 # if file not here, we are a 2.4 kernel
1955 kill -STOP `pidof kupdated`
1959 # ensure that all stripes have some grant before we test client-side cache
1961 [ "$SETUP_TEST42" ] && return
1962 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
1963 dd if=/dev/zero of=$i bs=4k count=1
1969 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
1970 # file truncation, and file removal.
1973 cancel_lru_locks osc
1975 sync; sleep 1; sync # just to be safe
1976 BEFOREWRITES=`count_ost_writes`
1977 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
1978 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
1979 AFTERWRITES=`count_ost_writes`
1980 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
1981 error "$BEFOREWRITES < $AFTERWRITES"
1984 run_test 42a "ensure that we don't flush on close =============="
1988 cancel_lru_locks osc
1991 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
1992 BEFOREWRITES=`count_ost_writes`
1993 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
1994 AFTERWRITES=`count_ost_writes`
1995 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
1996 error "$BEFOREWRITES < $AFTERWRITES on unlink"
1998 BEFOREWRITES=`count_ost_writes`
1999 sync || error "sync: $?"
2000 AFTERWRITES=`count_ost_writes`
2001 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
2002 error "$BEFOREWRITES < $AFTERWRITES on sync"
2004 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
2008 run_test 42b "test destroy of file with cached dirty data ======"
2010 # if these tests just want to test the effect of truncation,
2011 # they have to be very careful. consider:
2012 # - the first open gets a {0,EOF}PR lock
2013 # - the first write conflicts and gets a {0, count-1}PW
2014 # - the rest of the writes are under {count,EOF}PW
2015 # - the open for truncate tries to match a {0,EOF}PR
2016 # for the filesize and cancels the PWs.
2017 # any number of fixes (don't get {0,EOF} on open, match
2018 # composite locks, do smarter file size management) fix
2019 # this, but for now we want these tests to verify that
2020 # the cancellation with truncate intent works, so we
2021 # start the file with a full-file pw lock to match against
2022 # until the truncate.
2027 cancel_lru_locks osc
2029 # prime the file with 0,EOF PW to match
2033 # now the real test..
2034 dd if=/dev/zero of=$file bs=1024 count=100
2035 BEFOREWRITES=`count_ost_writes`
2036 $TRUNCATE $file $offset
2037 cancel_lru_locks osc
2038 AFTERWRITES=`count_ost_writes`
2044 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
2045 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
2048 run_test 42c "test partial truncate of file with cached dirty data"
2052 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
2053 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
2056 run_test 42d "test complete truncate of file with cached dirty data"
2062 test_42e() { # bug22074
2063 local TDIR=$DIR/${tdir}e
2064 local pagesz=$(page_size)
2066 local files=$((OSTCOUNT * 500))
2067 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
2072 $LFS setstripe -c 1 $TDIR
2073 createmany -o $TDIR/f $files
2075 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
2077 warmup_files=$((OSTCOUNT * max_dirty_mb))
2078 createmany -o $TDIR/w $warmup_files
2080 # write a large amount of data into one file to get good avail_grant number
2081 for ((i=0; i<$warmup_files; i++)); do
2082 idx=$($LFS getstripe -i $TDIR/w$i)
2083 [ $idx -ne 0 ] && continue
2084 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
2087 sync # write out any dirty data
2089 $LCTL get_param $proc_osc0/cur_dirty_bytes
2090 $LCTL get_param $proc_osc0/cur_grant_bytes
2092 # create as much dirty as we can while (hopefully) not triggering the
2094 for ((i=0; i<$warmup_files; i++)); do
2095 idx=$($LFS getstripe -i $TDIR/w$i)
2096 [ $idx -ne 0 ] && continue
2097 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
2099 $LCTL get_param $proc_osc0/cur_dirty_bytes
2100 $LCTL get_param $proc_osc0/cur_grant_bytes
2102 # perform the real test
2103 $LCTL set_param $proc_osc0/rpc_stats 0
2104 for ((;i<$files; i++)); do
2105 [ $($LFS getstripe -i $TDIR/f$i) -eq 0 ] || continue
2106 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
2109 $LCTL get_param $proc_osc0/rpc_stats
2111 $LCTL get_param $proc_osc0/rpc_stats |
2112 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
2113 [ "$PPR" != "16:" ] && continue
2114 [ $WPCT -lt 85 ] && error "$pages-page write RPCs only $WPCT% < 85%"
2115 break # we only want the "pages per rpc" stat
2119 run_test 42e "verify sub-RPC writes are not done synchronously"
2123 cp -p /bin/ls $DIR/$tdir/$tfile
2124 multiop $DIR/$tdir/$tfile Ow_c &
2126 # give multiop a chance to open
2129 $DIR/$tdir/$tfile && error || true
2132 run_test 43 "execution of file opened for write should return -ETXTBSY"
2136 cp -p `which multiop` $DIR/d43/multiop
2137 MULTIOP_PROG=$DIR/d43/multiop multiop_bg_pause $TMP/test43.junk O_c || return 1
2139 multiop $DIR/d43/multiop Oc && error "expected error, got success"
2140 kill -USR1 $MULTIOP_PID || return 2
2141 wait $MULTIOP_PID || return 3
2144 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
2148 cp -p `which multiop` $DIR/d43/multiop
2149 MULTIOP_PROG=$DIR/d43/multiop multiop_bg_pause $TMP/test43.junk O_c || return 1
2151 $TRUNCATE $DIR/d43/multiop 0 && error "expected error, got success"
2152 kill -USR1 $MULTIOP_PID || return 2
2153 wait $MULTIOP_PID || return 3
2156 run_test 43b "truncate of file being executed should return -ETXTBSY"
2159 local testdir="$DIR/d43c"
2162 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
2163 ( cd $testdir && md5sum -c)
2165 run_test 43c "md5sum of copy into lustre========================"
2168 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
2169 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
2170 dd if=$DIR/f1 of=/dev/null bs=4k count=1
2172 run_test 44 "zero length read from a sparse stripe ============="
2175 local nstripe=`$LCTL lov_getconfig $DIR | grep default_stripe_count: | \
2177 [ -z "$nstripe" ] && skip "can't get stripe info" && return
2178 [ "$nstripe" -gt "$OSTCOUNT" ] && skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" && return
2179 local stride=`$LCTL lov_getconfig $DIR | grep default_stripe_size: | \
2181 if [ $nstripe -eq 0 -o $nstripe -eq -1 ] ; then
2182 nstripe=`$LCTL lov_getconfig $DIR | grep obd_count: | awk '{print $2}'`
2185 OFFSETS="0 $((stride/2)) $((stride-1))"
2186 for offset in $OFFSETS ; do
2187 for i in `seq 0 $((nstripe-1))`; do
2189 local GLOBALOFFSETS=""
2190 local size=$((((i + 2 * $nstripe )*$stride + $offset))) # Bytes
2191 ll_sparseness_write $DIR/d44a $size || error "ll_sparseness_write"
2192 GLOBALOFFSETS="$GLOBALOFFSETS $size"
2193 ll_sparseness_verify $DIR/d44a $GLOBALOFFSETS \
2194 || error "ll_sparseness_verify $GLOBALOFFSETS"
2196 for j in `seq 0 $((nstripe-1))`; do
2197 size=$((((j + $nstripe )*$stride + $offset))) # Bytes
2198 ll_sparseness_write $DIR/d44a $size || error "ll_sparseness_write"
2199 GLOBALOFFSETS="$GLOBALOFFSETS $size"
2201 ll_sparseness_verify $DIR/d44a $GLOBALOFFSETS \
2202 || error "ll_sparseness_verify $GLOBALOFFSETS"
2206 run_test 44a "test sparse pwrite ==============================="
2210 for d in `lctl get_param -n osc.*.cur_dirty_bytes`; do
2216 before=`dirty_osc_total`
2217 echo executing "\"$*\""
2219 after=`dirty_osc_total`
2220 echo before $before, after $after
2224 # Obtain grants from OST if it supports it
2225 echo blah > ${f}_grant
2228 do_dirty_record "echo blah > $f"
2229 [ $before -eq $after ] && error "write wasn't cached"
2230 do_dirty_record "> $f"
2231 [ $before -gt $after ] || error "truncate didn't lower dirty count"
2232 do_dirty_record "echo blah > $f"
2233 [ $before -eq $after ] && error "write wasn't cached"
2234 do_dirty_record "sync"
2235 [ $before -gt $after ] || error "writeback didn't lower dirty count"
2236 do_dirty_record "echo blah > $f"
2237 [ $before -eq $after ] && error "write wasn't cached"
2238 do_dirty_record "cancel_lru_locks osc"
2239 [ $before -gt $after ] || error "lock cancellation didn't lower dirty count"
2242 run_test 45 "osc io page accounting ============================"
2244 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
2245 # test tickles a bug where re-dirtying a page was failing to be mapped to the
2246 # objects offset and an assert hit when an rpc was built with 1023's mapped
2247 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
2252 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
2254 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
2255 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
2259 run_test 46 "dirtying a previously written page ================"
2261 # test_47 is removed "Device nodes check" is moved to test_28
2263 test_48a() { # bug 2399
2264 check_kernel_version 34 || return 0
2267 mv $DIR/d48a $DIR/d48.new || error "move directory failed"
2268 mkdir $DIR/d48a || error "recreate directory failed"
2269 touch foo || error "'touch foo' failed after recreating cwd"
2270 mkdir bar || error "'mkdir foo' failed after recreating cwd"
2271 if check_kernel_version 44; then
2272 touch .foo || error "'touch .foo' failed after recreating cwd"
2273 mkdir .bar || error "'mkdir .foo' failed after recreating cwd"
2275 ls . > /dev/null || error "'ls .' failed after recreating cwd"
2276 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
2277 cd . || error "'cd .' failed after recreating cwd"
2278 mkdir . && error "'mkdir .' worked after recreating cwd"
2279 rmdir . && error "'rmdir .' worked after recreating cwd"
2280 ln -s . baz || error "'ln -s .' failed after recreating cwd"
2281 cd .. || error "'cd ..' failed after recreating cwd"
2283 run_test 48a "Access renamed working dir (should return errors)="
2285 test_48b() { # bug 2399
2286 check_kernel_version 34 || return 0
2289 rmdir $DIR/d48b || error "remove cwd $DIR/d48b failed"
2290 touch foo && error "'touch foo' worked after removing cwd"
2291 mkdir foo && error "'mkdir foo' worked after removing cwd"
2292 if check_kernel_version 44; then
2293 touch .foo && error "'touch .foo' worked after removing cwd"
2294 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
2296 ls . > /dev/null && error "'ls .' worked after removing cwd"
2297 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
2298 is_patchless || ( cd . && error "'cd .' worked after removing cwd" )
2299 mkdir . && error "'mkdir .' worked after removing cwd"
2300 rmdir . && error "'rmdir .' worked after removing cwd"
2301 ln -s . foo && error "'ln -s .' worked after removing cwd"
2302 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
2304 run_test 48b "Access removed working dir (should return errors)="
2306 test_48c() { # bug 2350
2307 check_kernel_version 36 || return 0
2308 #lctl set_param debug=-1
2310 mkdir -p $DIR/d48c/dir
2312 $TRACE rmdir $DIR/d48c/dir || error "remove cwd $DIR/d48c/dir failed"
2313 $TRACE touch foo && error "'touch foo' worked after removing cwd"
2314 $TRACE mkdir foo && error "'mkdir foo' worked after removing cwd"
2315 if check_kernel_version 44; then
2316 touch .foo && error "'touch .foo' worked after removing cwd"
2317 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
2319 $TRACE ls . && error "'ls .' worked after removing cwd"
2320 $TRACE ls .. || error "'ls ..' failed after removing cwd"
2321 is_patchless || ( $TRACE cd . && error "'cd .' worked after removing cwd" )
2322 $TRACE mkdir . && error "'mkdir .' worked after removing cwd"
2323 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
2324 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
2325 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
2327 run_test 48c "Access removed working subdir (should return errors)"
2329 test_48d() { # bug 2350
2330 check_kernel_version 36 || return 0
2331 #lctl set_param debug=-1
2333 mkdir -p $DIR/d48d/dir
2335 $TRACE rmdir $DIR/d48d/dir || error "remove cwd $DIR/d48d/dir failed"
2336 $TRACE rmdir $DIR/d48d || error "remove parent $DIR/d48d failed"
2337 $TRACE touch foo && error "'touch foo' worked after removing parent"
2338 $TRACE mkdir foo && error "'mkdir foo' worked after removing parent"
2339 if check_kernel_version 44; then
2340 touch .foo && error "'touch .foo' worked after removing parent"
2341 mkdir .foo && error "'mkdir .foo' worked after removing parent"
2343 $TRACE ls . && error "'ls .' worked after removing parent"
2344 $TRACE ls .. && error "'ls ..' worked after removing parent"
2345 is_patchless || ( $TRACE cd . && error "'cd .' worked after recreate parent" )
2346 $TRACE mkdir . && error "'mkdir .' worked after removing parent"
2347 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
2348 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
2349 is_patchless || ( $TRACE cd .. && error "'cd ..' worked after removing parent" || true )
2351 run_test 48d "Access removed parent subdir (should return errors)"
2353 test_48e() { # bug 4134
2354 check_kernel_version 41 || return 0
2355 #lctl set_param debug=-1
2357 mkdir -p $DIR/d48e/dir
2359 $TRACE rmdir $DIR/d48e/dir || error "remove cwd $DIR/d48e/dir failed"
2360 $TRACE rmdir $DIR/d48e || error "remove parent $DIR/d48e failed"
2361 $TRACE touch $DIR/d48e || error "'touch $DIR/d48e' failed"
2362 $TRACE chmod +x $DIR/d48e || error "'chmod +x $DIR/d48e' failed"
2363 # On a buggy kernel addition of "touch foo" after cd .. will
2364 # produce kernel oops in lookup_hash_it
2365 touch ../foo && error "'cd ..' worked after recreate parent"
2367 $TRACE rm $DIR/d48e || error "rm '$DIR/d48e' failed"
2369 run_test 48e "Access to recreated parent subdir (should return errors)"
2375 ls /proc/$$/cwd || error
2377 run_test 50 "special situations: /proc symlinks ==============="
2379 test_51a() { # was test_51
2380 # bug 1516 - create an empty entry right after ".." then split dir
2383 $MCREATE $DIR/d51/bar
2385 createmany -m $DIR/d51/longfile 201
2387 while [ `ls -sd $DIR/d51 | awk '{ print $1 }'` -eq 4 ]; do
2388 $MCREATE $DIR/d51/longfile$FNUM
2393 ls -l $DIR/d51 > /dev/null || error
2395 run_test 51a "special situations: split htree with empty entry =="
2397 export NUMTEST=70000
2399 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
2400 [ $NUMFREE -lt 21000 ] && \
2401 skip "not enough free inodes ($NUMFREE)" && \
2404 check_kernel_version 40 || NUMTEST=31000
2405 [ $NUMFREE -lt $NUMTEST ] && NUMTEST=$(($NUMFREE - 50))
2408 createmany -d $DIR/d51b/t- $NUMTEST
2410 run_test 51b "mkdir .../t-0 --- .../t-$NUMTEST ===================="
2413 [ ! -d $DIR/d51b ] && skip "$DIR/51b missing" && \
2416 unlinkmany -d $DIR/d51b/t- $NUMTEST
2418 run_test 51c "rmdir .../t-0 --- .../t-$NUMTEST ===================="
2421 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping test with few OSTs" && return
2423 createmany -o $DIR/d51d/t- 1000
2424 $LFS getstripe $DIR/d51d > $TMP/files
2425 for N in `seq 0 $((OSTCOUNT - 1))`; do
2426 OBJS[$N]=`awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}' $TMP/files`
2427 OBJS0[$N]=`grep -A 1 idx $TMP/files | awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}'`
2428 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
2430 unlinkmany $DIR/d51d/t- 1000
2433 for N in `seq 1 $((OSTCOUNT - 1))`; do
2434 [ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ] && \
2435 error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
2436 [ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ] && \
2437 error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
2439 [ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ] && \
2440 error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
2441 [ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ] && \
2442 error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
2446 run_test 51d "check object distribution ===================="
2449 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
2452 chattr +a $DIR/d52a/foo || error "chattr +a failed"
2453 echo bar >> $DIR/d52a/foo || error "append bar failed"
2454 cp /etc/hosts $DIR/d52a/foo && error "cp worked"
2455 rm -f $DIR/d52a/foo 2>/dev/null && error "rm worked"
2456 link $DIR/d52a/foo $DIR/d52a/foo_link 2>/dev/null && error "link worked"
2457 echo foo >> $DIR/d52a/foo || error "append foo failed"
2458 mrename $DIR/d52a/foo $DIR/d52a/foo_ren && error "rename worked"
2459 # new lsattr displays 'e' flag for extents
2460 lsattr $DIR/d52a/foo | egrep -q "^-+a[-e]+ $DIR/d52a/foo" || error "lsattr"
2461 chattr -a $DIR/d52a/foo || error "chattr -a failed"
2463 rm -fr $DIR/d52a || error "cleanup rm failed"
2465 run_test 52a "append-only flag test (should return errors) ====="
2468 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
2471 chattr +i $DIR/d52b/foo || error "chattr +a failed"
2472 cat test > $DIR/d52b/foo && error "cat test worked"
2473 cp /etc/hosts $DIR/d52b/foo && error "cp worked"
2474 rm -f $DIR/d52b/foo 2>/dev/null && error "rm worked"
2475 link $DIR/d52b/foo $DIR/d52b/foo_link 2>/dev/null && error "link worked"
2476 echo foo >> $DIR/d52b/foo && error "echo worked"
2477 mrename $DIR/d52b/foo $DIR/d52b/foo_ren && error "rename worked"
2478 [ -f $DIR/d52b/foo ] || error
2479 [ -f $DIR/d52b/foo_ren ] && error
2480 lsattr $DIR/d52b/foo | egrep -q "^-+i[-e]+ $DIR/d52b/foo" || error "lsattr"
2481 chattr -i $DIR/d52b/foo || error "chattr failed"
2483 rm -fr $DIR/d52b || error "remove failed"
2485 run_test 52b "immutable flag test (should return errors) ======="
2487 test_52c() { # 12848 simulating client < 1.4.7
2488 [ -f $DIR/d52c/foo ] && chattr -i $DIR/d52b/foo
2491 # skip MDS_BFLAG_EXT_FLAGS in mdc_getattr_pack
2492 #define OBD_FAIL_MDC_OLD_EXT_FLAGS 0x802
2493 lctl set_param fail_loc=0x802
2494 chattr +i $DIR/d52c/foo || error
2495 lsattr $DIR/d52c/foo | egrep -q "^-+i[-e]+ $DIR/d52c/foo" || error "lsattr failed"
2496 chattr -i $DIR/d52c/foo || error "chattr failed"
2497 lctl set_param -n fail_loc=0
2499 rm -fr $DIR/d52c || error
2501 run_test 52c "immutable flag test for client < 1.4.7 ======="
2504 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2505 remote_ost_nodsh && skip "remote OST with nodsh" && return
2513 local mdtosc=$(get_mdtosc_proc_path '*')
2514 for VALUE in $(do_facet mds lctl get_param osc.$mdtosc.prealloc_last_id); do
2515 param=`echo ${VALUE[0]} | cut -d "=" -f1`;
2516 ostname=`echo $param | cut -d "." -f2 | cut -d - -f 1-2`
2517 mds_last=$(do_facet mds lctl get_param -n $param)
2518 ostnum=$(echo $ostname | sed "s/${FSNAME}-OST//g" | awk '{print ($1+1)}' )
2519 ost_last=$(do_facet ost$ostnum lctl get_param -n obdfilter.$ostname.last_id)
2520 echo "$ostname.last_id=$ost_last ; MDS.last_id=$mds_last"
2521 if [ $ost_last != $mds_last ]; then
2522 error "$ostname.last_id=$ost_last ; MDS.last_id=$mds_last"
2526 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
2529 [ ! -f "$SOCKETSERVER" ] && skip_env "no socketserver, skipping" && return
2530 [ ! -f "$SOCKETCLIENT" ] && skip_env "no socketclient, skipping" && return
2531 $SOCKETSERVER $DIR/socket
2532 $SOCKETCLIENT $DIR/socket || error
2533 $MUNLINK $DIR/socket
2535 run_test 54a "unix domain socket test =========================="
2541 dd if=/dev/zero of=$f bs=`page_size` count=1
2543 run_test 54b "char device works in lustre ======================"
2546 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
2547 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
2548 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
2550 for i in `seq 3 7`; do
2551 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
2561 loopdev="$DIR/loop54c"
2564 [ -z "$LOOPNUM" ] && echo "couldn't find empty loop device" && return
2565 mknod $loopdev b 7 $LOOPNUM
2566 echo "make a loop file system with $tfile on $loopdev ($LOOPNUM)..."
2567 dd if=/dev/zero of=$tfile bs=`page_size` seek=1024 count=1 > /dev/null
2568 losetup $loopdev $tfile || error "can't set up $loopdev for $tfile"
2569 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
2571 mount -t ext2 $loopdev $tdir || error "error mounting $loopdev on $tdir"
2572 dd if=/dev/zero of=$tdir/tmp bs=`page_size` count=30 || error "dd write"
2574 dd if=$tdir/tmp of=/dev/zero bs=`page_size` count=30 || error "dd read"
2579 run_test 54c "block device works in lustre ====================="
2585 [ "$string" = `echo $string > $f | cat $f` ] || error
2587 run_test 54d "fifo device works in lustre ======================"
2590 check_kernel_version 46 || return 0
2593 cp -aL /dev/console $f
2594 echo $string > $f || error
2596 run_test 54e "console/tty device works in lustre ======================"
2601 client_only && skip "Not a server" && return
2602 mount -t $FSTYPE -o loop,iopen $EXT2_DEV $DIR/d55 || error "mounting"
2604 $IOPENTEST1 $DIR/d55/foo $DIR/d55 || error "running $IOPENTEST1"
2605 $IOPENTEST2 $DIR/d55 || error "running $IOPENTEST2"
2606 echo "check for $EXT2_DEV. Please wait..."
2608 $UMOUNT $DIR/d55 || error "unmounting"
2610 run_test 55 "check iopen_connect_dentry() ======================"
2612 test_56a() { # was test_56
2618 NUMFILESx2=$(($NUMFILES * 2))
2619 for i in `seq 1 $NUMFILES` ; do
2620 touch $DIR/d56/file$i
2621 touch $DIR/d56/dir/file$i
2624 # test lfs getstripe with --recursive
2625 FILENUM=`$GETSTRIPE --recursive $DIR/d56 | grep -c obdidx`
2626 [ $FILENUM -eq $NUMFILESx2 ] || error \
2627 "lfs getstripe --recursive $DIR/d56 wrong: found $FILENUM, expected $NUMFILESx2"
2628 FILENUM=`$GETSTRIPE $DIR/d56 | grep -c obdidx`
2629 [ $FILENUM -eq $NUMFILES ] || error \
2630 "lfs getstripe $DIR/d56 without --recursive wrong: found $FILENUM, expected $NUMFILES"
2631 echo "lfs getstripe --recursive passed."
2633 # test lfs getstripe with file instead of dir
2634 FILENUM=`$GETSTRIPE $DIR/d56/file1 | grep -c obdidx`
2635 [ $FILENUM -eq 1 ] || error \
2636 "lfs getstripe $DIR/d56/file1 wrong:found $FILENUM, expected 1"
2637 echo "lfs getstripe file passed."
2639 #test lfs getstripe with --verbose
2640 [ `$GETSTRIPE --verbose $DIR/d56 | grep -c lmm_magic` -eq $NUMFILES ] ||\
2641 error "lfs getstripe --verbose $DIR/d56 wrong: should find $NUMFILES lmm_magic info"
2642 [ `$GETSTRIPE $DIR/d56 | grep -c lmm_magic` -eq 0 ] || error \
2643 "lfs getstripe $DIR/d56 without --verbose wrong: should not show lmm_magic info"
2644 echo "lfs getstripe --verbose passed."
2646 #test lfs getstripe with --obd
2647 $GETSTRIPE --obd wrong_uuid $DIR/d56 2>&1 | grep -q "unknown obduuid" || \
2648 error "lfs getstripe --obd wrong_uuid should return error message"
2650 [ "$OSTCOUNT" -lt 2 ] && \
2651 skip_env "skipping other lfs getstripe --obd test" && return
2653 OBDUUID=$(lfs osts | grep ${OSTIDX}": " | awk '{print $2}')
2654 FILENUM=`$GETSTRIPE -ir $DIR/d56 | grep -x $OSTIDX | wc -l`
2655 FOUND=`$GETSTRIPE -r --obd $OBDUUID $DIR/d56 | grep obdidx | wc -l`
2656 [ $FOUND -eq $FILENUM ] || \
2657 error "lfs getstripe --obd wrong: found $FOUND, expected $FILENUM"
2658 [ `$GETSTRIPE -r -v --obd $OBDUUID $DIR/d56 | \
2659 sed '/^[ ]*'${OSTIDX}'[ ]/d' |\
2660 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l` -eq 0 ] || \
2661 error "lfs getstripe --obd wrong: should not show file on other obd"
2662 echo "lfs getstripe --obd passed."
2664 run_test 56a "check lfs getstripe ===================================="
2671 if [ ! -d "$DIR/${tdir}g" ] ; then
2672 mkdir -p $DIR/${tdir}g
2673 for i in `seq 1 $LOCAL_NUMFILES` ; do
2674 touch $DIR/${tdir}g/file$i
2676 for i in `seq 1 $LOCAL_NUMDIRS` ; do
2677 mkdir $DIR/${tdir}g/dir$i
2678 for j in `seq 1 $LOCAL_NUMFILES` ; do
2679 touch $DIR/${tdir}g/dir$i/file$j
2685 setup_56_special() {
2690 if [ ! -e "$TDIR/loop1b" ] ; then
2691 for i in `seq 1 $LOCAL_NUMFILES` ; do
2692 mknod $TDIR/loop${i}b b 7 $i
2693 mknod $TDIR/null${i}c c 1 3
2694 ln -s $TDIR/file1 $TDIR/link${i}l
2696 for i in `seq 1 $LOCAL_NUMDIRS` ; do
2697 mknod $TDIR/dir$i/loop${i}b b 7 $i
2698 mknod $TDIR/dir$i/null${i}c c 1 3
2699 ln -s $TDIR/dir$i/file1 $TDIR/dir$i/link${i}l
2707 setup_56 $NUMFILES $NUMDIRS
2709 EXPECTED=$(($NUMDIRS + 2))
2710 # test lfs find with -name
2711 for i in `seq 1 $NUMFILES` ; do
2712 NUMS=`$LFIND -name "*$i" $DIR/${tdir}g | wc -l`
2713 [ $NUMS -eq $EXPECTED ] || error \
2714 "lfs find -name \"*$i\" $DIR/${tdir}g wrong: found $NUMS, expected $EXPECTED"
2716 echo "lfs find -name passed."
2718 run_test 56g "check lfs find -name ============================="
2723 setup_56 $NUMFILES $NUMDIRS
2725 EXPECTED=$((($NUMDIRS+1)*($NUMFILES-1)+$NUMFILES))
2726 # test lfs find with ! -name
2727 for i in `seq 1 $NUMFILES` ; do
2728 NUMS=`$LFIND ! -name "*$i" $DIR/${tdir}g | wc -l`
2729 [ $NUMS -eq $EXPECTED ] || error \
2730 "lfs find ! -name \"*$i\" $DIR/${tdir}g wrong: found $NUMS, expected $EXPECTED"
2732 echo "lfs find ! -name passed."
2734 run_test 56h "check lfs find ! -name ============================="
2739 UUID=$(ostuuid_from_index 0 $DIR/$tdir)
2740 OUT=$($LFIND -obd $UUID $DIR/$tdir)
2741 [ "$OUT" ] && error "$LFIND returned directory '$OUT'" || true
2743 run_test 56i "check 'lfs find -ost UUID' skips directories ======="
2746 setup_56_special $NUMFILES $NUMDIRS
2748 EXPECTED=$((NUMDIRS+1))
2749 NUMS=`$LFIND -type d $DIR/${tdir}g | wc -l`
2750 [ $NUMS -eq $EXPECTED ] || \
2751 error "lfs find -type d $DIR/${tdir}g wrong: found $NUMS, expected $EXPECTED"
2753 run_test 56j "check lfs find -type d ============================="
2756 setup_56_special $NUMFILES $NUMDIRS
2758 EXPECTED=$(((NUMDIRS+1) * NUMFILES))
2759 NUMS=`$LFIND -type f $DIR/${tdir}g | wc -l`
2760 [ $NUMS -eq $EXPECTED ] || \
2761 error "lfs find -type f $DIR/${tdir}g wrong: found $NUMS, expected $EXPECTED"
2763 run_test 56k "check lfs find -type f ============================="
2766 setup_56_special $NUMFILES $NUMDIRS
2768 EXPECTED=$((NUMDIRS + NUMFILES))
2769 NUMS=`$LFIND -type b $DIR/${tdir}g | wc -l`
2770 [ $NUMS -eq $EXPECTED ] || \
2771 error "lfs find -type b $DIR/${tdir}g wrong: found $NUMS, expected $EXPECTED"
2773 run_test 56l "check lfs find -type b ============================="
2776 setup_56_special $NUMFILES $NUMDIRS
2778 EXPECTED=$((NUMDIRS + NUMFILES))
2779 NUMS=`$LFIND -type c $DIR/${tdir}g | wc -l`
2780 [ $NUMS -eq $EXPECTED ] || \
2781 error "lfs find -type c $DIR/${tdir}g wrong: found $NUMS, expected $EXPECTED"
2783 run_test 56m "check lfs find -type c ============================="
2786 setup_56_special $NUMFILES $NUMDIRS
2788 EXPECTED=$((NUMDIRS + NUMFILES))
2789 NUMS=`$LFIND -type l $DIR/${tdir}g | wc -l`
2790 [ $NUMS -eq $EXPECTED ] || \
2791 error "lfs find -type l $DIR/${tdir}g wrong: found $NUMS, expected $EXPECTED"
2793 run_test 56n "check lfs find -type l ============================="
2796 setup_56 $NUMFILES $NUMDIRS
2799 utime $TDIR/file1 > /dev/null || error
2800 utime $TDIR/file2 > /dev/null || error
2801 utime $TDIR/dir1 > /dev/null || error
2802 utime $TDIR/dir2 > /dev/null || error
2803 utime $TDIR/dir1/file1 > /dev/null || error
2806 NUMS=`$LFIND -mtime +1 $TDIR | wc -l`
2807 [ $NUMS -eq $EXPECTED ] || \
2808 error "lfs find -mtime $TDIR wrong: found $NUMS, expected $EXPECTED"
2810 run_test 56o "check lfs find -mtime for old files =========================="
2813 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
2818 setup_56 $NUMFILES $NUMDIRS
2820 chown $RUNAS_ID $TDIR/file* || error "chown $DIR/${tdir}g/file$i failed"
2822 NUMS="`$LFIND -uid $RUNAS_ID $TDIR | wc -l`"
2823 [ $NUMS -eq $EXPECTED ] || \
2824 error "lfs find -uid $TDIR wrong: found $NUMS, expected $EXPECTED"
2826 EXPECTED=$(( ($NUMFILES+1) * $NUMDIRS + 1))
2827 NUMS="`$LFIND ! -uid $RUNAS_ID $TDIR | wc -l`"
2828 [ $NUMS -eq $EXPECTED ] || \
2829 error "lfs find ! -uid $TDIR wrong: found $NUMS, expected $EXPECTED"
2831 echo "lfs find -uid and ! -uid passed."
2833 run_test 56p "check lfs find -uid and ! -uid ==============================="
2836 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
2841 setup_56 $NUMFILES $NUMDIRS
2843 chgrp $RUNAS_GID $TDIR/file* || error "chown $DIR/${tdir}g/file$i failed"
2845 NUMS="`$LFIND -gid $RUNAS_GID $TDIR | wc -l`"
2846 [ $NUMS -eq $EXPECTED ] || \
2847 error "lfs find -gid $TDIR wrong: found $NUMS, expected $EXPECTED"
2849 EXPECTED=$(( ($NUMFILES+1) * $NUMDIRS + 1))
2850 NUMS="`$LFIND ! -gid $RUNAS_GID $TDIR | wc -l`"
2851 [ $NUMS -eq $EXPECTED ] || \
2852 error "lfs find ! -gid $TDIR wrong: found $NUMS, expected $EXPECTED"
2854 echo "lfs find -gid and ! -gid passed."
2856 run_test 56q "check lfs find -gid and ! -gid ==============================="
2859 setup_56 $NUMFILES $NUMDIRS
2863 NUMS=`$LFIND -size 0 -t f $TDIR | wc -l`
2864 [ $NUMS -eq $EXPECTED ] || \
2865 error "lfs find $TDIR -size 0 wrong: found $NUMS, expected $EXPECTED"
2867 NUMS=`$LFIND ! -size 0 -t f $TDIR | wc -l`
2868 [ $NUMS -eq $EXPECTED ] || \
2869 error "lfs find $TDIR ! -size 0 wrong: found $NUMS, expected $EXPECTED"
2870 echo "test" > $TDIR/5chars
2872 NUMS=`$LFIND -size 5 -t f $TDIR | wc -l`
2873 [ $NUMS -eq $EXPECTED ] || \
2874 error "lfs find $TDIR -size 5 wrong: found $NUMS, expected $EXPECTED"
2876 NUMS=`$LFIND -size +5 -t f $TDIR | wc -l`
2877 [ $NUMS -eq $EXPECTED ] || \
2878 error "lfs find $TDIR -size +5 wrong: found $NUMS, expected $EXPECTED"
2880 NUMS=`$LFIND -size +0 -t f $TDIR | wc -l`
2881 [ $NUMS -eq $EXPECTED ] || \
2882 error "lfs find $TDIR -size +0 wrong: found $NUMS, expected $EXPECTED"
2884 NUMS=`$LFIND ! -size -5 -t f $TDIR | wc -l`
2885 [ $NUMS -eq $EXPECTED ] || \
2886 error "lfs find $TDIR ! -size -5 wrong: found $NUMS, expected $EXPECTED"
2889 run_test 56r "check lfs find -size works =========================="
2892 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2894 local MNTDEV=$(get_mds_mntdev_proc_path)
2895 DEV=$(do_facet mds lctl get_param -n $MNTDEV)
2896 [ -z "$DEV" ] && error "can't access $MNTDEV"
2897 for DEV in $(do_facet mds lctl get_param -n $MNTDEV); do
2898 do_facet mds $DUMPE2FS -h $DEV > $TMP/t57a.dump || error "can't access $DEV"
2899 DEVISIZE=`awk '/Inode size:/ { print $3 }' $TMP/t57a.dump`
2900 [ "$DEVISIZE" -gt 128 ] || error "inode size $DEVISIZE"
2904 run_test 57a "verify MDS filesystem created with large inodes =="
2911 local FILEN=$dir/f$FILECOUNT
2913 rm -rf $dir || error "removing $dir"
2914 mkdir -p $dir || error "creating $dir"
2916 echo "mcreating $FILECOUNT files"
2917 createmany -m $dir/f 1 $FILECOUNT || \
2918 error "creating files in $dir"
2920 # verify that files do not have EAs yet
2921 $GETSTRIPE $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
2922 $GETSTRIPE $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
2924 local fsstat_dev=$(get_mds_fsstat_proc_path)
2925 local MDSFREE=$(do_facet mds lctl get_param -n $fsstat_dev.*.kbytesfree)
2926 local MDCFREE=$(lctl get_param -n mdc.*.kbytesfree | head -n 1)
2927 echo "opening files to create objects/EAs"
2929 for FILE in `seq -f $dir/f%g 1 $FILECOUNT`; do
2930 $OPENFILE -f O_RDWR $FILE > /dev/null || error "opening $FILE"
2933 # verify that files have EAs now
2934 $GETSTRIPE $FILE1 | grep -q "obdidx" || error "$FILE1 missing EA"
2935 $GETSTRIPE $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
2937 sleep 1 # make sure we get new statfs data
2938 local MDSFREE2=$(do_facet mds lctl get_param -n $fsstat_dev.*.kbytesfree)
2939 local MDCFREE2=$(lctl get_param -n mdc.*.kbytesfree | head -n 1)
2940 if [ "$MDCFREE2" -lt "$((MDCFREE - 8))" ]; then
2941 if [ "$MDSFREE" != "$MDSFREE2" ]; then
2942 error "MDC before $MDCFREE != after $MDCFREE2"
2944 echo "MDC before $MDCFREE != after $MDCFREE2"
2945 echo "unable to confirm if MDS has large inodes"
2950 run_test 57b "default LOV EAs are stored inside large inodes ==="
2953 [ -z "$(which wiretest 2>/dev/null)" ] && skip_env "could not find wiretest" && return
2956 run_test 58 "verify cross-platform wire constants =============="
2959 echo "touch 130 files"
2960 createmany -o $DIR/f59- 130
2962 unlinkmany $DIR/f59- 130
2965 # wait for commitment of removal
2967 run_test 59 "verify cancellation of llog records async ========="
2969 TEST60_HEAD="test_60 run $RANDOM"
2970 test_60a() { # was test_60
2971 [ ! -f run-llog.sh ] && skip_env "missing subtest run-llog.sh" && return
2972 log "$TEST60_HEAD - from kernel mode"
2975 run_test 60a "llog sanity tests run from kernel module =========="
2977 test_60b() { # bug 6411
2979 LLOG_COUNT=`dmesg | awk "/$TEST60_HEAD/{marker = 1; from_marker = 0;}
2991 [ $LLOG_COUNT -gt 50 ] && error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)"|| true
2993 run_test 60b "limit repeated messages from CERROR/CWARN ========"
2996 echo "create 5000 files"
2997 createmany -o $DIR/f60c- 5000
2998 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
2999 lctl set_param fail_loc=0x80000137
3000 unlinkmany $DIR/f60c- 5000
3002 run_test 60c "unlink file when mds full"
3005 SAVEPRINTK=$(lctl get_param -n printk)
3007 # verify "lctl mark" is even working"
3008 MESSAGE="test message ID $RANDOM $$"
3009 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
3010 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
3012 lctl set_param printk=0 || error "set lnet.printk failed"
3013 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
3014 MESSAGE="new test message ID $RANDOM $$"
3015 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
3016 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
3017 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
3019 lctl set_param -n printk="$SAVEPRINTK"
3021 run_test 60d "test printk console message masking"
3025 dd if=/dev/zero of=$f bs=`page_size` count=1
3026 cancel_lru_locks osc
3027 multiop $f OSMWUc || error
3030 run_test 61 "mmap() writes don't make sync hang ================"
3032 # bug 2330 - insufficient obd_match error checking causes LBUG
3036 cancel_lru_locks osc
3037 #define OBD_FAIL_OSC_MATCH 0x405
3038 lctl set_param fail_loc=0x405
3039 cat $f && error "cat succeeded, expect -EIO"
3040 lctl set_param fail_loc=0
3042 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
3043 # match every page all of the time.
3044 run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
3046 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
3047 test_63a() { # was test_63
3048 MAX_DIRTY_MB=`lctl get_param -n osc.*.max_dirty_mb | head -n 1`
3049 lctl set_param -n osc.*.max_dirty_mb 0
3050 for i in `seq 10` ; do
3051 dd if=/dev/zero of=$DIR/f63 bs=8k &
3057 lctl set_param -n osc.*.max_dirty_mb $MAX_DIRTY_MB
3058 rm -f $DIR/f63 || true
3060 run_test 63a "Verify oig_wait interruption does not crash ======="
3062 # bug 2248 - async write errors didn't return to application on sync
3063 # bug 3677 - async write errors left page locked
3066 lctl set_param debug=-1
3068 # ensure we have a grant to do async writes
3069 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
3072 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
3073 lctl set_param fail_loc=0x80000406
3074 multiop $DIR/$tfile Owy && \
3075 error "sync didn't return ENOMEM"
3076 sync; sleep 2; sync # do a real sync this time to flush page
3077 lctl get_param -n llite.*.dump_page_cache | grep locked && \
3078 error "locked page left in cache after async error" || true
3081 run_test 63b "async write errors should be returned to fsync ==="
3085 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
3087 run_test 64a "verify filter grant calculations (in kernel) ====="
3090 [ ! -f oos.sh ] && skip_env "missing subtest oos.sh" && return
3093 run_test 64b "check out-of-space detection on client ==========="
3095 # bug 1414 - set/get directories' stripe info
3099 $LVERIFY $DIR/d65 $DIR/d65/f1 || error "lverify failed"
3101 run_test 65a "directory with no stripe info ===================="
3105 $SETSTRIPE $DIR/d65 -s $(($STRIPESIZE * 2)) -i 0 -c 1 || error "setstripe"
3107 $LVERIFY $DIR/d65 $DIR/d65/f2 || error "lverify failed"
3109 run_test 65b "directory setstripe $(($STRIPESIZE * 2)) 0 1 ==============="
3112 if [ $OSTCOUNT -gt 1 ]; then
3114 $SETSTRIPE $DIR/d65 -s $(($STRIPESIZE * 4)) -i 1 \
3115 -c $(($OSTCOUNT - 1)) || error "setstripe"
3117 $LVERIFY $DIR/d65 $DIR/d65/f3 || error "lverify failed"
3120 run_test 65c "directory setstripe $(($STRIPESIZE * 4)) 1 $(($OSTCOUNT - 1))"
3124 [ $STRIPECOUNT -le 0 ] && sc=1 || sc=$(($STRIPECOUNT - 1))
3125 $SETSTRIPE $DIR/d65 -s $STRIPESIZE -c $sc || error "setstripe"
3126 touch $DIR/d65/f4 $DIR/d65/f5
3127 $LVERIFY $DIR/d65 $DIR/d65/f4 $DIR/d65/f5 || error "lverify failed"
3129 run_test 65d "directory setstripe $STRIPESIZE -1 stripe_count =============="
3134 $SETSTRIPE $DIR/d65 || error "setstripe"
3135 $GETSTRIPE -v $DIR/d65 | grep "Default" || error "no stripe info failed"
3137 $LVERIFY $DIR/d65 $DIR/d65/f6 || error "lverify failed"
3139 run_test 65e "directory setstripe defaults ======================="
3143 $RUNAS $SETSTRIPE $DIR/d65f && error "setstripe succeeded" || true
3145 run_test 65f "dir setstripe permission (should return error) ==="
3149 $SETSTRIPE $DIR/d65 -s $(($STRIPESIZE * 2)) -i 0 -c 1 || error "setstripe"
3150 $SETSTRIPE -d $DIR/d65 || error "setstripe"
3151 $GETSTRIPE -v $DIR/d65 | grep "Default" || \
3152 error "delete default stripe failed"
3154 run_test 65g "directory setstripe -d ==========================="
3158 $SETSTRIPE $DIR/d65 -s $(($STRIPESIZE * 2)) -i 0 -c 1 || error "setstripe"
3159 mkdir -p $DIR/d65/dd1
3160 [ "`$GETSTRIPE -v $DIR/d65 | grep "^count"`" == \
3161 "`$GETSTRIPE -v $DIR/d65/dd1 | grep "^count"`" ] || error "stripe info inherit failed"
3163 run_test 65h "directory stripe info inherit ===================="
3165 test_65i() { # bug6367
3166 $SETSTRIPE $MOUNT -s 65536 -c -1
3168 run_test 65i "set non-default striping on root directory (bug 6367)="
3170 test_65j() { # bug6367
3172 # if we aren't already remounting for each test, do so for this test
3173 if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
3174 cleanup || error "failed to unmount"
3177 $SETSTRIPE -d $MOUNT || error "setstripe failed"
3179 run_test 65j "set default striping on root directory (bug 6367)="
3181 test_65k() { # bug11679
3182 [ "$OSTCOUNT" -lt 2 ] && skip_env "too few OSTs" && return
3183 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3185 echo "Check OST status: "
3186 MDS_OSCS=`do_facet mds lctl dl | awk '/[oO][sS][cC].*md[ts]/ { print $4 }'`
3187 for OSC in $MDS_OSCS; do
3188 echo $OSC "is activate"
3189 do_facet mds lctl --device %$OSC activate
3191 do_facet client mkdir -p $DIR/$tdir
3192 for INACTIVE_OSC in $MDS_OSCS; do
3193 echo $INACTIVE_OSC "is Deactivate:"
3194 do_facet mds lctl --device %$INACTIVE_OSC deactivate
3195 for STRIPE_OSC in $MDS_OSCS; do
3196 STRIPE_OST=`osc_to_ost $STRIPE_OSC`
3197 STRIPE_INDEX=`do_facet mds lctl get_param -n lov.*md*.target_obd |
3198 grep $STRIPE_OST | awk -F: '{print $1}'`
3199 echo "$SETSTRIPE $DIR/$tdir/${STRIPE_INDEX} -i ${STRIPE_INDEX} -c 1"
3200 do_facet client $SETSTRIPE $DIR/$tdir/${STRIPE_INDEX} -i ${STRIPE_INDEX} -c 1
3202 [ $RC -ne 0 ] && error "setstripe should have succeeded"
3204 do_facet client rm -f $DIR/$tdir/*
3205 echo $INACTIVE_OSC "is Activate."
3206 do_facet mds lctl --device %$INACTIVE_OSC activate
3209 run_test 65k "validate manual striping works properly with deactivated OSCs"
3211 test_65l() { # bug 12836
3212 mkdir -p $DIR/$tdir/test_dir
3213 $SETSTRIPE $DIR/$tdir/test_dir -c -1
3214 $LFS find -mtime -1 $DIR/$tdir > /dev/null
3216 run_test 65l "lfs find on -1 stripe dir ========================"
3218 # bug 2543 - update blocks count on client
3221 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
3223 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
3224 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
3226 run_test 66 "update inode blocks count on client ==============="
3228 test_67a() { # was test_67 bug 3285 - supplementary group fails on MDS, passes on client
3229 [ "$RUNAS_ID" = "$UID" ] && skip "RUNAS_ID = UID = $UID -- skipping" && return
3232 local lustre_version=$(get_lustre_version mds)
3233 if [[ $lustre_version != 1.8* ]]; then
3234 skip mds running $lustre_version, no group_upcall
3237 check_kernel_version 35 || return 0
3239 chmod 771 $DIR/$tdir
3240 chgrp $RUNAS_GID $DIR/$tdir
3241 $RUNAS -u $RUNAS_ID -g $(($RUNAS_GID + 1)) -G1,2,$RUNAS_GID ls $DIR/$tdir
3243 GROUP_UPCALL=$(do_facet mds lctl get_param -n mds.*.group_upcall)
3244 [ -z "$GROUP_UPCALL" ] && \
3245 skip "lctl get_param failed! Useless to continue the test!" && return
3246 [ "$GROUP_UPCALL" = "NONE" -a $RC -eq 0 ] && \
3247 error "no-upcall passed" || true
3248 [ "$GROUP_UPCALL" != "NONE" -a $RC -ne 0 ] && \
3249 error "upcall failed" || true
3251 run_test 67a "supplementary group failure (should return error) ="
3256 do_facet mds lctl set_param -n mds.*.group_upcall NONE
3259 test_67b() { # bug 3285 - supplementary group fails on MDS, passes on client
3261 local lustre_version=$(get_lustre_version mds)
3262 if [[ $lustre_version != 1.8* ]]; then
3263 skip mds running $lustre_version, no group_upcall
3267 # needs to be in /etc/groups on MDS, gid == uid
3268 # Let's use RUNAS_ID
3269 T67_UID=${T67_UID:-$RUNAS_ID}
3271 [ "$UID" = "$T67_UID" ] && skip "UID = T67_UID = $UID -- skipping" && return
3272 check_kernel_version 35 || return 0
3273 do_facet mds grep -q ":$T67_UID:$T67_UID" /etc/passwd || \
3274 { skip "Need gid=$T67_UID group and gid == uid on mds !" && return; }
3276 GROUP_UPCALL=$(do_facet mds lctl get_param -n mds.*.group_upcall)
3277 [ -z "$GROUP_UPCALL" ] && \
3278 skip "lctl get_param failed! Useless to continue the test!" && return
3279 [ "$GROUP_UPCALL" != "NONE" ] && \
3280 skip "skip test - upcall=$GROUP_UPCALL" && return
3282 trap cleanup_67b EXIT
3284 chmod 771 $DIR/$tdir
3285 chgrp $T67_UID $DIR/$tdir
3286 local l_getgroups=$(do_facet mds which l_getgroups)
3287 do_facet mds lctl set_param -n mds.*.group_upcall $l_getgroups
3288 do_facet mds $l_getgroups -d $T67_UID
3289 $RUNAS -u $T67_UID -g 999 -G8,9,$T67_UID touch $DIR/$tdir/$tfile || \
3290 error "'touch $DIR/$tdir/$tfile' failed"
3291 [ -f $DIR/$tdir/$tfile ] || error "$DIR/$tdir/$tfile create error"
3294 run_test 67b "supplementary group test ========================="
3299 if [ ! -z "$LLOOP" ]; then
3300 swapoff $LLOOP || error "swapoff failed"
3301 $LCTL blockdev_detach $LLOOP || error "detach failed"
3309 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
3313 swapon -s | awk '($1 == "'$1'") { print $4 }'
3317 # excercise swapping to lustre by adding a high priority swapfile entry
3318 # and then consuming memory until it is used.
3320 [ "$UID" != 0 ] && skip_env "must run as root" && return
3321 lctl get_param -n devices | grep -q obdfilter && \
3322 skip "local OST" && return
3324 grep -q llite_lloop /proc/modules
3325 [ $? -ne 0 ] && skip_env "can't find module llite_lloop" && return
3327 [ -z "`$LCTL list_nids | grep -v tcp`" ] && \
3328 skip "can't reliably test swap with TCP" && return
3330 MEMTOTAL=`meminfo MemTotal`
3331 NR_BLOCKS=$((MEMTOTAL>>8))
3332 [[ $NR_BLOCKS -le 2048 ]] && NR_BLOCKS=2048
3334 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
3335 dd if=/dev/zero of=$DIR/f68 bs=64k seek=$NR_BLOCKS count=1
3338 $LCTL blockdev_attach $DIR/f68 $LLOOP || error "attach failed"
3340 trap cleanup_68 EXIT
3342 swapon -p 32767 $LLOOP || error "swapon $LLOOP failed"
3344 echo "before: `swapon -s | grep $LLOOP`"
3345 $MEMHOG $MEMTOTAL || error "error allocating $MEMTOTAL kB"
3346 echo "after: `swapon -s | grep $LLOOP`"
3347 SWAPUSED=`swap_used $LLOOP`
3351 [ $SWAPUSED -eq 0 ] && echo "no swap used???" || true
3353 run_test 68 "support swapping to Lustre ========================"
3355 # bug5265, obdfilter oa2dentry return -ENOENT
3356 # #define OBD_FAIL_OST_ENOENT 0x217
3358 remote_ost_nodsh && skip "remote OST with nodsh" && return
3361 $SETSTRIPE $f -c 1 -i 0
3363 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
3365 #define OBD_FAIL_OST_ENOENT 0x217
3366 do_facet ost1 lctl set_param fail_loc=0x217
3367 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
3368 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
3370 do_facet ost1 lctl set_param fail_loc=0
3371 $DIRECTIO write $f 0 2 || error "write error"
3373 cancel_lru_locks osc
3374 $DIRECTIO read $f 0 1 || error "read error"
3376 #define OBD_FAIL_OST_ENOENT 0x217
3377 do_facet ost1 lctl set_param fail_loc=0x217
3378 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
3380 do_facet ost1 lctl set_param fail_loc=0
3383 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
3387 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
3389 run_test 71 "Running dbench on lustre (don't segment fault) ===="
3392 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
3393 check_kernel_version 43 || return 0
3394 [ "$RUNAS_ID" = "$UID" ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
3396 # Check that testing environment is properly set up. Skip if not
3397 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS || {
3398 skip_env "User $RUNAS_ID does not exist - skipping"
3404 $RUNAS dd if=/dev/zero of=$DIR/f72 bs=512 count=1 || error
3405 # See if we are still setuid/sgid
3406 test -u $DIR/f72 -o -g $DIR/f72 && error "S/gid is not dropped on write"
3407 # Now test that MDS is updated too
3408 cancel_lru_locks mdc
3409 test -u $DIR/f72 -o -g $DIR/f72 && error "S/gid is not dropped on MDS"
3412 run_test 72a "Test that remove suid works properly (bug5695) ===="
3414 test_72b() { # bug 24226 -- keep mode setting when size is not changing
3417 [ "$RUNAS_ID" = "$UID" ] && \
3418 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
3419 [ "$RUNAS_ID" -eq 0 ] && \
3420 skip_env "RUNAS_ID = 0 -- skipping" && return
3422 # Check that testing environment is properly set up. Skip if not
3423 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS || {
3424 skip_env "User $RUNAS_ID does not exist - skipping"
3427 touch $DIR/${tfile}-f{g,u}
3428 mkdir $DIR/${tfile}-d{g,u}
3429 chmod 770 $DIR/${tfile}-{f,d}{g,u}
3430 chmod g+s $DIR/${tfile}-{f,d}g
3431 chmod u+s $DIR/${tfile}-{f,d}u
3432 for perm in 777 2777 4777; do
3433 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
3434 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
3435 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
3436 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
3440 run_test 72b "Test that we keep mode setting when not changing size (bug 24226)"
3442 # bug 3462 - multiple simultaneous MDC requests
3446 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
3449 #define OBD_FAIL_MDS_PAUSE_OPEN 0x129
3450 lctl set_param fail_loc=0x80000129
3451 multiop $DIR/d73-1/f73-2 Oc &
3453 lctl set_param fail_loc=0
3455 multiop $DIR/d73-2/f73-3 Oc &
3459 wait $pid1 || return 1
3463 $CHECKSTAT -t file $DIR/d73-1/f73-1 || error "$DIR/d73-1/f73-1 not file"
3464 $CHECKSTAT -t file $DIR/d73-1/f73-2 || error "$DIR/d73-1/f73-2 not file"
3465 $CHECKSTAT -t file $DIR/d73-2/f73-3 || error "$DIR/d73-2/f73-3 not file"
3469 run_test 73 "multiple MDC requests (should not deadlock)"
3471 test_74a() { # bug 6149, 6184
3472 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
3474 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
3475 # will spin in a tight reconnection loop
3477 lctl set_param fail_loc=0x8000030e
3478 # get any lock that won't be difficult - lookup works.
3480 lctl set_param fail_loc=0
3483 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
3485 test_74b() { # bug 13310
3486 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
3488 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
3489 # will spin in a tight reconnection loop
3490 lctl set_param fail_loc=0x8000030e
3491 # get a "difficult" lock
3493 lctl set_param fail_loc=0
3496 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
3498 JOIN=${JOIN:-"lfs join"}
3505 [ $T75_PREP = "yes" ] && return
3506 echo "using F75=$F75, F128k=$F128k, FHEAD=$FHEAD, FTAIL=$FTAIL"
3508 dd if=/dev/urandom of=${F75}_128k bs=128k count=1 || error "dd failed"
3517 cp -p ${F128k} ${FHEAD}
3518 log "finished cp to $FHEAD"
3519 cp -p ${F128k} ${FTAIL}
3520 log "finished cp to $FTAIL"
3521 cat ${F128k} ${F128k} > ${F75}_sim_sim
3523 $JOIN ${FHEAD} ${FTAIL} || error "join ${FHEAD} ${FTAIL} error"
3524 log "finished join $FHEAD to ${F75}_sim_sim"
3525 cmp ${FHEAD} ${F75}_sim_sim || error "${FHEAD} ${F75}_sim_sim differ"
3526 log "finished cmp $FHEAD to ${F75}_sim_sim"
3527 $CHECKSTAT -a ${FTAIL} || error "tail ${FTAIL} still exist after join"
3529 run_test 75a "TEST join file ===================================="
3534 cp -p ${F128k} ${FTAIL}
3535 cat ${F75}_sim_sim >> ${F75}_join_sim
3536 cat ${F128k} >> ${F75}_join_sim
3537 $JOIN ${FHEAD} ${FTAIL} || error "join ${FHEAD} ${FTAIL} error"
3538 cmp ${FHEAD} ${F75}_join_sim || \
3539 error "${FHEAD} ${F75}_join_sim are different"
3540 $CHECKSTAT -a ${FTAIL} || error "tail ${FTAIL} exist after join"
3542 run_test 75b "TEST join file 2 =================================="
3547 cp -p ${F128k} ${FTAIL}
3548 cat ${F128k} >> ${F75}_sim_join
3549 cat ${F75}_join_sim >> ${F75}_sim_join
3550 $JOIN ${FTAIL} ${FHEAD} || error "join error"
3551 cmp ${FTAIL} ${F75}_sim_join || \
3552 error "${FTAIL} ${F75}_sim_join are different"
3553 $CHECKSTAT -a ${FHEAD} || error "tail ${FHEAD} exist after join"
3555 run_test 75c "TEST join file 3 =================================="
3560 cp -p ${F128k} ${FHEAD}
3561 cp -p ${F128k} ${FHEAD}_tmp
3562 cat ${F75}_sim_sim >> ${F75}_join_join
3563 cat ${F75}_sim_join >> ${F75}_join_join
3564 $JOIN ${FHEAD} ${FHEAD}_tmp || error "join ${FHEAD} ${FHEAD}_tmp error"
3565 $JOIN ${FHEAD} ${FTAIL} || error "join ${FHEAD} ${FTAIL} error"
3566 cmp ${FHEAD} ${F75}_join_join ||error "${FHEAD} ${F75}_join_join differ" $CHECKSTAT -a ${FHEAD}_tmp || error "${FHEAD}_tmp exist after join"
3567 $CHECKSTAT -a ${FTAIL} || error "tail ${FTAIL} exist after join (2)"
3569 run_test 75d "TEST join file 4 =================================="
3574 rm -rf ${FHEAD} || "delete join file error"
3576 run_test 75e "TEST join file 5 (remove joined file) ============="
3581 cp -p ${F128k} ${F75}_join_10_compare
3582 cp -p ${F128k} ${F75}_join_10
3583 for ((i = 0; i < 10; i++)); do
3584 cat ${F128k} >> ${F75}_join_10_compare
3585 cp -p ${F128k} ${FTAIL}
3586 $JOIN ${F75}_join_10 ${FTAIL} || \
3587 error "join ${F75}_join_10 ${FTAIL} error"
3588 $CHECKSTAT -a ${FTAIL} || error "tail file exist after join"
3590 cmp ${F75}_join_10 ${F75}_join_10_compare || \
3591 error "files ${F75}_join_10 ${F75}_join_10_compare differ"
3593 run_test 75f "TEST join file 6 (join 10 files) =================="
3596 [ ! -f ${F75}_join_10 ] && echo "${F75}_join_10 missing" && return
3597 $LFS getstripe ${F75}_join_10
3599 $OPENUNLINK ${F75}_join_10 ${F75}_join_10 || error "files unlink open"
3603 run_test 75g "TEST join file 7 (open unlink) ===================="
3606 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
3609 get_inode_slab_tunables() {
3610 awk '/lustre_inode_cache/ {print $9," ",$10," ",$11; exit}' /proc/slabinfo
3613 set_inode_slab_tunables() {
3614 echo "lustre_inode_cache $1" > /proc/slabinfo
3617 test_76() { # Now for bug 20433, added originally in bug 1443
3618 local SLAB_SETTINGS=`get_inode_slab_tunables`
3619 local CPUS=`getconf _NPROCESSORS_ONLN`
3620 # we cannot set limit below 1 which means 1 inode in each
3621 # per-cpu cache is still allowed
3622 set_inode_slab_tunables "1 1 0"
3623 cancel_lru_locks osc
3624 BEFORE_INODES=`num_inodes`
3625 echo "before inodes: $BEFORE_INODES"
3627 [ "$SLOW" = "no" ] && COUNT=100
3628 for i in `seq $COUNT`; do
3632 cancel_lru_locks osc
3633 AFTER_INODES=`num_inodes`
3634 echo "after inodes: $AFTER_INODES"
3636 while [ $((AFTER_INODES-1*CPUS)) -gt $BEFORE_INODES ]; do
3638 AFTER_INODES=`num_inodes`
3640 echo "wait $wait seconds inodes: $AFTER_INODES"
3641 if [ $wait -gt 30 ]; then
3642 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
3645 set_inode_slab_tunables "$SLAB_SETTINGS"
3647 run_test 76 "confirm clients recycle inodes properly ===="
3652 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums |
3655 lctl set_param -n osc.*.checksums=$1
3659 export ORIG_CSUM_TYPE=""
3660 CKSUM_TYPES=${CKSUM_TYPES:-"crc32 adler"}
3663 [ "$ORIG_CSUM_TYPE" ] || \
3664 ORIG_CSUM_TYPE=`lctl get_param -n osc.*osc-[^mM]*.checksum_type | sed 's/.*\[\(.*\)\].*/\1/g' \
3666 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
3667 log "set checksum type to $1"
3670 F77_TMP=$TMP/f77-temp
3673 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
3674 error "error writing to $F77_TMP"
3677 test_77a() { # bug 10889
3678 [ ! -f $F77_TMP ] && setup_f77
3680 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
3683 run_test 77a "normal checksum read/write operation ============="
3685 test_77b() { # bug 10889
3686 [ ! -f $F77_TMP ] && setup_f77
3687 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
3688 lctl set_param fail_loc=0x80000409
3690 dd if=$F77_TMP of=$DIR/f77b bs=1M count=$F77SZ conv=sync || \
3691 error "dd error: $?"
3692 lctl set_param fail_loc=0
3695 run_test 77b "checksum error on client write ===================="
3697 test_77c() { # bug 10889
3698 [ ! -f $DIR/f77b ] && skip "requires 77b - skipping" && return
3700 for algo in $CKSUM_TYPES; do
3701 cancel_lru_locks osc
3702 set_checksum_type $algo
3703 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
3704 lctl set_param fail_loc=0x80000408
3705 cmp $F77_TMP $DIR/f77b || error "file compare failed"
3706 lctl set_param fail_loc=0
3709 set_checksum_type $ORIG_CSUM_TYPE
3711 run_test 77c "checksum error on client read ==================="
3713 test_77d() { # bug 10889
3714 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
3715 lctl set_param fail_loc=0x80000409
3717 directio write $DIR/f77 0 $F77SZ $((1024 * 1024)) || \
3718 error "direct write: rc=$?"
3719 lctl set_param fail_loc=0
3722 run_test 77d "checksum error on OST direct write ==============="
3724 test_77e() { # bug 10889
3725 [ ! -f $DIR/f77 ] && skip "requires 77d - skipping" && return
3726 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
3727 lctl set_param fail_loc=0x80000408
3729 cancel_lru_locks osc
3730 directio read $DIR/f77 0 $F77SZ $((1024 * 1024)) || \
3731 error "direct read: rc=$?"
3732 lctl set_param fail_loc=0
3735 run_test 77e "checksum error on OST direct read ================"
3737 test_77f() { # bug 10889
3739 for algo in $CKSUM_TYPES; do
3740 cancel_lru_locks osc
3741 set_checksum_type $algo
3742 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
3743 lctl set_param fail_loc=0x409
3744 directio write $DIR/f77 0 $F77SZ $((1024 * 1024)) && \
3745 error "direct write succeeded"
3746 lctl set_param fail_loc=0
3748 set_checksum_type $ORIG_CSUM_TYPE
3751 run_test 77f "repeat checksum error on write (expect error) ===="
3753 test_77g() { # bug 10889
3754 remote_ost_nodsh && skip "remote OST with nodsh" && return
3756 [ ! -f $F77_TMP ] && setup_f77
3758 $SETSTRIPE $DIR/f77g -c 1 -i 0
3759 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
3760 do_facet ost1 lctl set_param fail_loc=0x8000021a
3762 dd if=$F77_TMP of=$DIR/f77g bs=1M count=$F77SZ || \
3763 error "write error: rc=$?"
3764 do_facet ost1 lctl set_param fail_loc=0
3767 run_test 77g "checksum error on OST write ======================"
3769 test_77h() { # bug 10889
3770 remote_ost_nodsh && skip "remote OST with nodsh" && return
3772 [ ! -f $DIR/f77g ] && skip "requires 77g - skipping" && return
3773 cancel_lru_locks osc
3774 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
3775 do_facet ost1 lctl set_param fail_loc=0x8000021b
3777 cmp $F77_TMP $DIR/f77g || error "file compare failed"
3778 do_facet ost1 lctl set_param fail_loc=0
3781 run_test 77h "checksum error on OST read ======================="
3783 test_77i() { # bug 13805
3784 #define OBD_FAIL_OSC_CONNECT_CKSUM 0x40b
3785 lctl set_param fail_loc=0x40b
3786 remount_client $MOUNT
3787 lctl set_param fail_loc=0
3788 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
3789 param=`echo ${VALUE[0]} | cut -d "=" -f1`
3790 algo=`lctl get_param -n $param | sed 's/.*\[\(.*\)\].*/\1/g'`
3791 [ "$algo" = "crc32" ] || error "algo set to $algo instead of crc32"
3793 remount_client $MOUNT
3795 run_test 77i "client not supporting OSD_CONNECT_CKSUM =========="
3797 test_77j() { # bug 13805
3798 #define OBD_FAIL_OSC_CKSUM_ADLER_ONLY 0x40c
3799 lctl set_param fail_loc=0x40c
3800 remount_client $MOUNT
3801 lctl set_param fail_loc=0
3802 sleep 2 # wait async osc connect to finish
3803 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
3804 param=`echo ${VALUE[0]} | cut -d "=" -f1`
3805 algo=`lctl get_param -n $param | sed 's/.*\[\(.*\)\].*/\1/g'`
3806 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
3808 remount_client $MOUNT
3810 run_test 77j "client only supporting ADLER32 ===================="
3812 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
3816 test_78() { # bug 10901
3817 remote_ost || { skip_env "local OST" && return; }
3819 cancel_lru_locks osc
3821 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
3822 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
3823 # directio allocates the buffer twice, one for writes and another
3824 # one for reads, so that it can check the data consistency
3825 F78SIZE=$((F78SIZE / 2))
3826 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
3827 echo "MemTotal: $MEMTOTAL"
3828 # reserve 256MB of memory for the kernel and other running processes,
3829 # and then take 1/2 of the remaining memory for the read/write buffers.
3830 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
3831 echo "Mem to use for directio: $MEMTOTAL"
3832 [ $F78SIZE -gt $MEMTOTAL ] && F78SIZE=$MEMTOTAL
3833 [ $F78SIZE -gt 512 ] && F78SIZE=512
3834 [ $F78SIZE -gt $((MAXFREE / 1024)) ] && F78SIZE=$((MAXFREE / 1024))
3835 SMALLESTOST=`lfs df $DIR |grep OST | awk '{print $4}' |sort -n |head -1`
3836 echo "Smallest OST: $SMALLESTOST"
3837 [ $SMALLESTOST -lt 10240 ] && \
3838 skip "too small OSTSIZE, useless to run large O_DIRECT test" && return 0
3840 [ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 5)) ] && \
3841 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 5))
3842 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
3843 echo "File size: $F78SIZE"
3844 $SETSTRIPE $DIR/$tfile -c -1 || error "setstripe failed"
3845 for i in `seq 1 $NSEQ`
3847 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
3848 echo directIO rdwr round $i of $NSEQ
3849 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
3854 run_test 78 "handle large O_DIRECT writes correctly ============"
3856 test_79() { # bug 12743
3857 wait_delete_completed
3859 BKTOTAL=$(calc_osc_kbytes kbytestotal)
3860 BKFREE=$(calc_osc_kbytes kbytesfree)
3861 BKAVAIL=$(calc_osc_kbytes kbytesavail)
3862 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
3863 DFTOTAL=`echo $STRING | cut -d, -f1`
3864 DFUSED=`echo $STRING | cut -d, -f2`
3865 DFAVAIL=`echo $STRING | cut -d, -f3`
3866 DFFREE=$(($DFTOTAL - $DFUSED))
3868 ALLOWANCE=$((64 * $OSTCOUNT))
3870 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
3871 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
3872 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
3874 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
3875 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
3876 error "df free($DFFREE) mismatch OST free($BKFREE)"
3878 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
3879 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
3880 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
3883 run_test 79 "df report consistency check ======================="
3885 test_80() { # bug 10718
3886 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
3888 local BEFORE=`date +%s`
3889 cancel_lru_locks osc
3890 local AFTER=`date +%s`
3891 local DIFF=$((AFTER-BEFORE))
3892 if [ $DIFF -gt 1 ] ; then
3893 error "elapsed for 1M@1T = $DIFF"
3897 run_test 80 "Page eviction is equally fast at high offsets too ===="
3900 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
3901 mkdir -p $DIR/d99cvsroot || error "mkdir $DIR/d99cvsroot failed"
3902 chown $RUNAS_ID $DIR/d99cvsroot || error "chown $DIR/d99cvsroot failed"
3903 local oldPWD=$PWD # bug 13584, use $TMP as working dir
3906 $RUNAS cvs -d $DIR/d99cvsroot init || error "cvs init failed"
3909 run_test 99a "cvs init ========================================="
3912 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
3913 [ ! -d $DIR/d99cvsroot ] && test_99a
3914 $RUNAS [ ! -w /tmp ] && skip "/tmp has wrong w permission -- skipping" && return
3915 cd /etc/init.d || error "cd /etc/init.d failed"
3916 # some versions of cvs import exit(1) when asked to import links or
3917 # files they can't read. ignore those files.
3918 TOIGNORE=$(find . -type l -printf '-I %f\n' -o \
3919 ! -perm +4 -printf '-I %f\n')
3920 $RUNAS cvs -d $DIR/d99cvsroot import -m "nomesg" $TOIGNORE \
3921 d99reposname vtag rtag > /dev/null || error "cvs import failed"
3923 run_test 99b "cvs import ======================================="
3926 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
3927 [ ! -d $DIR/d99cvsroot ] && test_99b
3928 cd $DIR || error "cd $DIR failed"
3929 mkdir -p $DIR/d99reposname || error "mkdir $DIR/d99reposname failed"
3930 chown $RUNAS_ID $DIR/d99reposname || \
3931 error "chown $DIR/d99reposname failed"
3932 $RUNAS cvs -d $DIR/d99cvsroot co d99reposname > /dev/null || \
3933 error "cvs co d99reposname failed"
3935 run_test 99c "cvs checkout ====================================="
3938 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
3939 [ ! -d $DIR/d99cvsroot ] && test_99c
3940 cd $DIR/d99reposname
3942 $RUNAS cvs add -m 'addmsg' foo99
3944 run_test 99d "cvs add =========================================="
3947 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
3948 [ ! -d $DIR/d99cvsroot ] && test_99c
3949 cd $DIR/d99reposname
3952 run_test 99e "cvs update ======================================="
3955 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
3956 [ ! -d $DIR/d99cvsroot ] && test_99d
3957 cd $DIR/d99reposname
3958 $RUNAS cvs commit -m 'nomsg' foo99
3960 run_test 99f "cvs commit ======================================="
3963 [ "$NETTYPE" = tcp ] || \
3964 { skip "TCP secure port test, not useful for NETTYPE=$NETTYPE" && \
3967 remote_ost_nodsh && skip "remote OST with nodsh" && return
3968 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3970 { skip "useless for local single node setup" && return; }
3972 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
3973 [ "$PROT" != "tcp" ] && continue
3974 RPORT=$(echo $REMOTE | cut -d: -f2)
3975 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
3978 LPORT=`echo $LOCAL | cut -d: -f2`
3979 if [ $LPORT -ge 1024 ]; then
3980 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
3982 error_exit "local: $LPORT > 1024, remote: $RPORT"
3985 [ "$rc" = 0 ] || error_exit "privileged port not found" )
3987 run_test 100 "check local port using privileged port ==========="
3989 function get_named_value()
3998 echo $line | sed "s/^$tag//"
4005 export CACHE_MAX=`lctl get_param -n llite/*/max_cached_mb | head -n 1`
4007 lctl set_param -n llite.*.max_cached_mb $CACHE_MAX
4015 [ "$CPU" = "UML" ] && nreads=1000
4016 local cache_limit=32
4018 lctl set_param -n osc.*.rpc_stats 0
4019 trap cleanup_101 EXIT
4021 lctl set_param -n llite.*.read_ahead_stats 0
4022 lctl set_param -n llite.*.max_cached_mb $cache_limit
4025 # randomly read 10000 of 64K chunks from file 3x 32MB in size
4027 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
4028 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
4031 for s in `lctl get_param -n llite.*.read_ahead_stats | \
4032 get_named_value 'read but discarded' | cut -d" " -f1`; do
4033 discard=$(($discard + $s))
4037 if [ $(($discard * 10)) -gt $nreads ] ;then
4038 lctl get_param osc.*.rpc_stats
4039 lctl get_param llite.*.read_ahead_stats
4040 error "too many ($discard) discarded pages"
4042 rm -f $DIR/$tfile || true
4044 run_test 101 "check read-ahead for random reads ================"
4046 export SETUP_TEST101b=no
4048 [ "$SETUP_TEST101b" = "yes" ] && return
4051 STRIPE_COUNT=$OSTCOUNT
4054 trap cleanup_101 EXIT
4055 # prepare the read-ahead file
4056 $SETSTRIPE $DIR/$tfile -s $STRIPE_SIZE -i $STRIPE_OFFSET -c $OSTCOUNT
4058 dd if=/dev/zero of=$DIR/$tfile bs=1024k count=100 2> /dev/null
4064 rm -rf $DIR/$tdir $DIR/$tfile
4069 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
4074 local STRIPE_SIZE=1048576
4075 local RA_INC=1048576
4076 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
4077 local FILE_LENGTH=$((64*100))
4078 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
4079 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
4080 DISCARD=`$LCTL get_param -n llite.*.read_ahead_stats | \
4081 get_named_value 'read but discarded' | \
4082 cut -d" " -f1 | calc_total`
4084 if [ $DISCARD -gt $discard_limit ]; then
4085 lctl get_param llite.*.read_ahead_stats
4086 error "Too many ($DISCARD) discarded pages (size ${READ_SIZE})"
4088 echo "Read-ahead success for size ${READ_SIZE}"
4093 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs for stride-read" && return
4094 local STRIPE_SIZE=1048576
4095 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
4096 local FILE_LENGTH=$((STRIPE_SIZE*100))
4097 local ITERATION=$((FILE_LENGTH/STRIDE_SIZE))
4098 # prepare the read-ahead file
4100 cancel_lru_locks osc
4101 for BIDX in 2 4 8 16 32 64 128 256; do
4102 local BSIZE=$((BIDX*4096))
4103 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
4104 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
4105 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
4106 $LCTL set_param -n llite.*.read_ahead_stats 0
4107 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
4108 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
4109 cancel_lru_locks osc
4110 ra_check_101b $BSIZE
4114 run_test 101b "check stride-io mode read-ahead ================="
4117 local STRIPE_SIZE=1048576
4118 local FILE_LENGTH=$((STRIPE_SIZE*100))
4123 cancel_lru_locks osc
4124 $LCTL set_param osc.*.rpc_stats 0
4125 $READS -f $DIR/$tfile -s$FILE_LENGTH -b65536 -n$nreads -t 180
4126 for OSC in `$LCTL get_param -N osc.*`
4128 if [ "$OSC" == "osc.num_refs" ]; then
4131 lines=`$LCTL get_param -n ${OSC}.rpc_stats | wc | awk '{print $1}'`
4132 if [ $lines -le 20 ]; then
4136 rpc4k=$($LCTL get_param -n $OSC | awk '$1 == "1:" { print $2; exit; }')
4137 rpc8k=$($LCTL get_param -n $OSC | awk '$1 == "2:" { print $2; exit; }')
4138 rpc16k=$($LCTL get_param -n $OSC | awk '$1 == "4:" { print $2; exit; }')
4139 rpc32k=$($LCTL get_param -n $OSC | awk '$1 == "8:" { print $2; exit; }')
4141 [ $rpc4k != 0 ] && error "Small 4k read IO ${rpc4k}!"
4142 [ $rpc8k != 0 ] && error "Small 8k read IO ${rpc8k}!"
4143 [ $rpc16k != 0 ] && error "Small 16k read IO ${rpc16k}!"
4144 [ $rpc32k != 0 ] && error "Small 32k read IO ${rpc32k}!"
4146 echo "Small rpc check passed!"
4147 rpc64k=$($LCTL get_param -n $OSC | awk '$1 == "16:" { print $2; exit; }')
4148 rpc128k=$($LCTL get_param -n $OSC | awk '$1 == "32:" { print $2; exit; }')
4149 rpc256k=$($LCTL get_param -n $OSC | awk '$1 == "64:" { print $2; exit; }')
4150 rpc512k=$($LCTL get_param -n $OSC | awk '$1 == "128:" { print $2; exit; }')
4151 rpc1024k=$($LCTL get_param -n $OSC | awk '$1 == "256:" { print $2; exit; }')
4153 [ $rpc64k == 0 ] && error "No 64k readahead IO ${rpc64k}"
4154 [ $rpc128k == 0 ] && error "No 128k readahead IO ${rpc128k}"
4155 [ $rpc256k == 0 ] && error "No 256k readahead IO ${rpc256k}"
4156 [ $rpc512k == 0 ] && error "No 512k readahead IO ${rpc256k}"
4157 [ $rpc1024k == 0 ] && error "No 1024k readahead IO ${rpc1024k}"
4158 echo "Big rpc check passed!"
4163 run_test 101c "check stripe_size aligned read-ahead ================="
4166 lctl get_param -n llite.*.max_read_ahead_mb | head -n 1
4167 lctl set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
4171 local file=$DIR/$tfile
4172 local size=${FILESIZE_101c:-500}
4173 local ra_MB=${READAHEAD_MB:-40}
4175 local space=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
4176 [ $space -gt $((size / 1024)) ] ||
4177 { skip "Need free space ${size}M, have $space" && return; }
4179 echo Creating ${size}M test file $file
4180 dd if=/dev/zero of=$file bs=1M count=$size
4181 echo Cancel LRU locks on lustre client to flush the client cache
4182 cancel_lru_locks osc
4184 echo Disable read-ahead
4185 local old_READAHEAD=$(set_read_ahead 0)
4187 echo Reading the test file $file with read-ahead disabled
4188 time_ra_OFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$size")
4190 echo Cancel LRU locks on lustre client to flush the client cache
4191 cancel_lru_locks osc
4192 echo Enable read-ahead with ${ra_MB}MB
4193 set_read_ahead $ra_MB
4195 echo Reading the test file $file with read-ahead enabled
4196 time_ra_ON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$size")
4198 echo read-ahead disabled time read $time_ra_OFF
4199 echo read-ahead enabled time read $time_ra_ON
4201 set_read_ahead $old_READAHEAD
4204 [ $time_ra_ON -lt $time_ra_OFF ] ||
4205 error "read-ahead enabled time read (${time_ra_ON}s) is more than
4206 read-ahead disabled time read (${time_ra_OFF}s) filesize ${size}M"
4208 run_test 101d "file read with and without read-ahead enabled ================="
4210 export SETUP_TEST102=no
4212 [ "$SETUP_TEST102" = "yes" ] && return
4214 chown $RUNAS_ID $DIR/$tdir
4217 STRIPE_COUNT=$OSTCOUNT
4218 [ $OSTCOUNT -gt 4 ] && STRIPE_COUNT=4
4220 trap cleanup_test102 EXIT
4222 $1 $SETSTRIPE $tdir -s $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT
4226 for count in `seq 1 $STRIPE_COUNT`
4228 for offset in `seq 0 $[$STRIPE_COUNT - 1]`
4230 local stripe_size=`expr $STRIPE_SIZE \* $num`
4231 local file=file"$num-$offset-$count"
4232 $1 $SETSTRIPE $file -s $stripe_size -i $offset -c $count
4238 $1 $TAR cf $TMP/f102.tar $tdir --xattrs
4244 [ "$SETUP_TEST102" = "yes" ] || return 0
4250 local testfile=$DIR/xattr_testfile
4255 [ "$UID" != 0 ] && skip_env "must run as root" && return
4256 [ -z "`lctl get_param -n mdc.*.connect_flags | grep xattr`" ] &&
4257 skip_env "must have user_xattr" && return
4258 [ -z "$(which setfattr 2>/dev/null)" ] && skip_env "could not find setfattr" && return
4260 echo "set/get xattr..."
4261 setfattr -n trusted.name1 -v value1 $testfile || error
4262 [ "`getfattr -n trusted.name1 $testfile 2> /dev/null | \
4263 grep "trusted.name1"`" == "trusted.name1=\"value1\"" ] || error
4265 setfattr -n user.author1 -v author1 $testfile || error
4266 [ "`getfattr -n user.author1 $testfile 2> /dev/null | \
4267 grep "user.author1"`" == "user.author1=\"author1\"" ] || error
4270 setfattr -n trusted.name2 -v value2 $testfile || error
4271 setfattr -n trusted.name3 -v value3 $testfile || error
4272 [ `getfattr -d -m "^trusted" $testfile 2> /dev/null | \
4273 grep "trusted.name" | wc -l` -eq 3 ] || error
4276 setfattr -n user.author2 -v author2 $testfile || error
4277 setfattr -n user.author3 -v author3 $testfile || error
4278 [ `getfattr -d -m "^user" $testfile 2> /dev/null | \
4279 grep "user" | wc -l` -eq 3 ] || error
4281 echo "remove xattr..."
4282 setfattr -x trusted.name1 $testfile || error
4283 getfattr -d -m trusted $testfile 2> /dev/null | \
4284 grep "trusted.name1" && error || true
4286 setfattr -x user.author1 $testfile || error
4287 getfattr -d -m user $testfile 2> /dev/null | \
4288 grep "user.author1" && error || true
4290 # b10667: setting lustre special xattr be silently discarded
4291 echo "set lustre special xattr ..."
4292 setfattr -n "trusted.lov" -v "invalid value" $testfile || error
4296 run_test 102a "user xattr test =================================="
4299 # b10930: get/set/list trusted.lov xattr
4300 echo "get/set/list trusted.lov xattr ..."
4301 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
4302 local testfile=$DIR/$tfile
4303 $SETSTRIPE -s 65536 -i 1 -c 2 $testfile || error "setstripe failed"
4304 getfattr -d -m "^trusted" $testfile 2> /dev/null | \
4305 grep "trusted.lov" || error "can't get trusted.lov from $testfile"
4307 local testfile2=${testfile}2
4308 local value=`getfattr -n trusted.lov $testfile 2> /dev/null | \
4309 grep "trusted.lov" |sed -e 's/[^=]\+=//'`
4312 setfattr -n trusted.lov -v $value $testfile2
4313 local tmp_file=${testfile}3
4314 $GETSTRIPE -v $testfile2 > $tmp_file
4315 local stripe_size=`grep "size" $tmp_file| awk '{print $2}'`
4316 local stripe_count=`grep "count" $tmp_file| awk '{print $2}'`
4317 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
4318 [ $stripe_count -eq 2 ] || error "stripe count $stripe_count != 2"
4320 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
4323 # b10930: get/set/list lustre.lov xattr
4324 echo "get/set/list lustre.lov xattr ..."
4325 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
4327 chown $RUNAS_ID $DIR/$tdir
4328 local testfile=$DIR/$tdir/$tfile
4329 $RUNAS $SETSTRIPE -s 65536 -i 1 -c 2 $testfile||error "setstripe failed"
4330 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
4331 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
4333 local testfile2=${testfile}2
4334 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
4335 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
4337 $RUNAS $MCREATE $testfile2
4338 $RUNAS setfattr -n lustre.lov -v $value $testfile2
4339 local tmp_file=${testfile}3
4340 $RUNAS $GETSTRIPE -v $testfile2 > $tmp_file
4341 local stripe_size=`grep "size" $tmp_file| awk '{print $2}'`
4342 local stripe_count=`grep "count" $tmp_file| awk '{print $2}'`
4343 [ "$stripe_size" -eq 65536 ] || error "stripe size $stripe_size != 65536"
4344 [ "$stripe_count" -eq 2 ] || error "stripe count $stripe_count != 2"
4346 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
4348 compare_stripe_info1() {
4349 local stripe_index_all_zero=1
4353 for count in `seq 1 $STRIPE_COUNT`
4355 for offset in `seq 0 $[$STRIPE_COUNT - 1]`
4357 local size=`expr $STRIPE_SIZE \* $num`
4358 local file=file"$num-$offset-$count"
4359 get_stripe_info client $PWD/$file "$1"
4360 if [ $stripe_size -ne $size ]; then
4361 error "$file: different stripe size $stripe_size, expected $size" && return
4363 if [ $stripe_count -ne $count ]; then
4364 error "$file: different stripe count $stripe_count, expected $count" && return
4366 if [ $stripe_index -ne 0 ]; then
4367 stripe_index_all_zero=0
4372 [ $stripe_index_all_zero -eq 1 ] && error "all files are being extracted starting from OST index 0"
4377 [ -n "$(which tar 2>/dev/null)" ] && strings $(which tar) | grep -q lustre && echo tar
4381 # b10930: tar test for trusted.lov xattr
4382 TAR=$(find_lustre_tar)
4383 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
4384 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
4387 $TAR xf $TMP/f102.tar -C $DIR/d102d --xattrs
4389 compare_stripe_info1
4391 run_test 102d "tar restore stripe info from tarfile,not keep osts ==========="
4394 # b10930: tar test for trusted.lov xattr
4395 TAR=$(find_lustre_tar)
4396 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
4397 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
4401 $TAR cf - --xattrs $tdir | $TAR xf - --xattrs -C $DIR/d102f
4403 compare_stripe_info1
4405 run_test 102f "tar copy files, not keep osts ==========="
4407 test_102h() { # bug 15777
4408 [ -z $(lctl get_param -n mdc.*.connect_flags | grep xattr) ] &&
4409 skip "must have user_xattr" && return
4410 [ -z "$(which setfattr 2>/dev/null)" ] &&
4411 skip_env "could not find setfattr" && return
4416 VALUE=datadatadatadatadatadatadatadata
4417 while [ $(echo $VALUE | wc -c) -lt $XSIZE ]; do
4418 VALUE="$VALUE$VALUE"
4420 log "save $XBIG on $DIR/$tfile"
4421 setfattr -n $XBIG -v "$VALUE" $DIR/$tfile ||
4422 error "saving $XBIG on $DIR/$tfile failed"
4423 ORIG=$(getfattr -n $XBIG $DIR/$tfile 2> /dev/null | grep $XBIG)
4424 OSIZE=$(echo $ORIG | wc -c)
4425 [ $OSIZE -lt $XSIZE ] && error "set $XBIG too small ($OSIZE < $XSIZE)"
4428 log "save $XSML on $DIR/$tfile"
4429 setfattr -n $XSML -v val $DIR/$tfile ||
4430 error "saving $XSML on $DIR/$tfile failed"
4431 NEW=$(getfattr -n $XBIG $DIR/$tfile 2> /dev/null | grep $XBIG)
4432 if [ "$NEW" != "$ORIG" ]; then
4435 error "$XBIG different after saving $XSML"
4438 log "grow $XSML on $DIR/$tfile"
4439 setfattr -n $XSML -v "$VALUE" $DIR/$tfile ||
4440 error "growing $XSML on $DIR/$tfile failed"
4441 NEW=$(getfattr -n $XBIG $DIR/$tfile 2> /dev/null | grep $XBIG)
4442 if [ "$NEW" != "$ORIG" ]; then
4445 error "$XBIG different after growing $XSML"
4447 log "$XBIG still valid after growing $XSML"
4449 run_test 102h "grow xattr from inside inode to external block"
4451 test_102i() { # bug 17038
4453 ln -s $DIR/$tfile $DIR/${tfile}link
4454 getfattr -n trusted.lov $DIR/$tfile || error "lgetxattr on $DIR/$tfile failed"
4455 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"
4456 rm -f $DIR/$tfile $DIR/${tfile}link
4458 run_test 102i "lgetxattr test on symbolic link ============"
4461 TAR=$(find_lustre_tar)
4462 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
4463 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
4464 setup_test102 "$RUNAS"
4466 chown $RUNAS_ID $DIR/d102j
4467 $RUNAS $TAR xf $TMP/f102.tar -C $DIR/d102j --xattrs
4469 compare_stripe_info1 "$RUNAS"
4471 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
4475 # b22187 just check that does not crash for regular file.
4476 setfattr -n trusted.lov $DIR/$tfile
4477 # b22187 'setfattr -n trusted.lov' should work as remove LOV EA for directories
4478 local test_kdir=$DIR/d102k
4480 local default_size=`$GETSTRIPE -s $test_kdir`
4481 local default_count=`$GETSTRIPE -c $test_kdir`
4482 local default_offset=`$GETSTRIPE -o $test_kdir`
4483 $SETSTRIPE -s 65536 -i 1 -c $OSTCOUNT $test_kdir || error 'dir setstripe failed'
4484 setfattr -n trusted.lov $test_kdir
4485 local stripe_size=`$GETSTRIPE -s $test_kdir`
4486 local stripe_count=`$GETSTRIPE -c $test_kdir`
4487 local stripe_offset=`$GETSTRIPE -o $test_kdir`
4488 [ $stripe_size -eq $default_size ] || error "stripe size $stripe_size != $default_size"
4489 [ $stripe_count -eq $default_count ] || error "stripe count $stripe_count != $default_count"
4490 [ $stripe_offset -eq $default_offset ] || error "stripe offset $stripe_offset != $default_offset"
4491 rm -rf $DIR/$tfile $test_kdir
4493 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
4499 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
4504 [ "$UID" != 0 ] && skip_env "must run as root" && return
4505 [ -z "$(lctl get_param mdc.*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
4506 [ -z "$(which setfacl 2>/dev/null)" ] && skip_env "could not find setfacl" && return
4512 echo "performing cp ..."
4513 run_acl_subtest cp || error
4514 echo "performing getfacl-noacl..."
4515 run_acl_subtest getfacl-noacl > /dev/null || error "getfacl-noacl test failed"
4516 echo "performing misc..."
4517 run_acl_subtest misc > /dev/null || error "misc test failed"
4518 # XXX add back permission test when we support supplementary groups.
4519 # echo "performing permissions..."
4520 # run_acl_subtest permissions || error
4521 echo "performing setfacl..."
4522 run_acl_subtest setfacl > /dev/null || error "setfacl test failed"
4524 # inheritance test got from HP
4525 echo "performing inheritance..."
4526 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
4527 chmod +x make-tree || error "chmod +x failed"
4528 run_acl_subtest inheritance > /dev/null || error "inheritance test failed"
4534 run_test 103 "acl test ========================================="
4538 lfs df || error "lfs df failed"
4539 lfs df -ih || error "lfs df -ih failed"
4540 lfs df -h $DIR || error "lfs df -h $DIR failed"
4541 lfs df -i $DIR || error "lfs df -i $DIR failed"
4542 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
4543 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
4545 OSC=`lctl get_param -n devices | awk '/-osc-|OSC.*MNT/ {print $4}' | head -n 1`
4546 lctl --device %$OSC deactivate
4547 lfs df || error "lfs df with deactivated OSC failed"
4548 lctl --device %$OSC recover
4549 lfs df || error "lfs df with reactivated OSC failed"
4551 run_test 104a "lfs df [-ih] [path] test ========================="
4554 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4556 denied_cnt=$((`$RUNAS $LFS check servers 2>&1 | grep "Permission denied" | wc -l`))
4557 if [ $denied_cnt -ne 0 ];
4559 error "lfs check servers test failed"
4562 run_test 104b "$RUNAS lfs check servers test ===================="
4565 # doesn't work on 2.4 kernels
4567 if [ -n "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ];
4569 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
4571 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
4574 run_test 105a "flock when mounted without -o flock test ========"
4578 if [ -n "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ];
4580 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
4582 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
4585 run_test 105b "fcntl when mounted without -o flock test ========"
4589 if [ -n "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ];
4591 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
4593 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
4596 run_test 105c "lockf when mounted without -o flock test ========"
4598 test_105d() { # bug 15924
4600 [ -z "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ] && \
4601 skip "mount w/o flock enabled" && return
4602 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
4603 $LCTL set_param fail_loc=0x80000315
4604 flocks_test 2 $DIR/$tdir
4606 run_test 105d "flock race (should not freeze) ========"
4608 test_105e() { # bug 22660
4609 [ -z "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ] && \
4610 skip "mount w/o flock enabled" && return
4612 flocks_test 3 $DIR/$tfile
4614 run_test 105e "Two conflicting flocks from same process ======="
4616 test_106() { #bug 10921
4618 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
4619 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
4621 run_test 106 "attempt exec of dir followed by chown of that dir"
4630 local save_pattern=$(sysctl -n kernel.core_pattern)
4631 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
4632 sysctl -w kernel.core_pattern=$file
4633 sysctl -w kernel.core_uses_pid=0
4641 kill -s 11 $SLEEPPID
4643 if [ -e $file ]; then
4644 size=`stat -c%s $file`
4645 [ $size -eq 0 ] && error "Zero length core file $file"
4647 error "Fail to create core file $file"
4650 sysctl -w kernel.core_pattern=$save_pattern
4651 sysctl -w kernel.core_uses_pid=$save_uses_pid
4654 run_test 107 "Coredump on SIG"
4657 OSTIO_pre=$(ps -e|grep ll_ost_io|awk '{print $4}'|sort -n|tail -1|\
4659 [ -z "$OSTIO_pre" ] && skip "no OSS threads" && \
4661 echo "Starting with $OSTIO_pre threads"
4664 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
4665 [ $NUMFREE -lt $NUMTEST ] && NUMTEST=$(($NUMFREE - 1000))
4666 echo "$NUMTEST creates/unlinks"
4668 createmany -o $DIR/$tdir/$tfile $NUMTEST
4669 unlinkmany $DIR/$tdir/$tfile $NUMTEST
4671 OSTIO_post=$(ps -e|grep ll_ost_io|awk '{print $4}'|sort -n|tail -1|\
4674 # don't return an error
4675 [ $OSTIO_post -eq $OSTIO_pre ] && echo \
4676 "WARNING: No new ll_ost_io threads were created ($OSTIO_pre)" &&\
4677 echo "This may be fine, depending on what ran before this test" &&\
4678 echo "and how fast this system is." && return
4680 echo "Started with $OSTIO_pre threads, ended with $OSTIO_post"
4682 run_test 115 "verify dynamic thread creation===================="
4685 wait_delete_completed
4686 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC][-_]*.kbytesavail))
4687 echo OST kbytes available: ${AVAIL[@]}
4688 MAXI=0; MAXV=${AVAIL[0]}
4689 MINI=0; MINV=${AVAIL[0]}
4690 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
4691 #echo OST $i: ${AVAIL[i]}kb
4692 if [ ${AVAIL[i]} -gt $MAXV ]; then
4693 MAXV=${AVAIL[i]}; MAXI=$i
4695 if [ ${AVAIL[i]} -lt $MINV ]; then
4696 MINV=${AVAIL[i]}; MINI=$i
4699 echo Min free space: OST $MINI: $MINV
4700 echo Max free space: OST $MAXI: $MAXV
4704 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
4706 echo -n "Free space priority "
4707 lctl get_param -n lov.*.qos_prio_free
4710 [ $MINV -gt 960000 ] && skip "too much free space in OST$MINI" &&\
4713 # generate uneven OSTs
4714 mkdir -p $DIR/$tdir/OST${MINI}
4717 echo "Filling 25% remaining space in OST${MINI} with ${FILL}Kb"
4718 $SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI}||error "setstripe failed"
4720 while [ $FILL -gt 0 ]; do
4721 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i bs=2M count=1 2>/dev/null
4722 FILL=$(($FILL - 2048))
4731 DIFF=$(($MAXV - $MINV))
4732 DIFF2=$(($DIFF * 100 / $MINV))
4733 echo -n "diff=${DIFF}=${DIFF2}% must be > 20% for QOS mode..."
4734 if [ $DIFF2 -gt 20 ]; then
4737 echo "failed - QOS mode won't be used"
4738 error_ignore "QOS imbalance criteria not met"
4742 MINI1=$MINI; MINV1=$MINV
4743 MAXI1=$MAXI; MAXV1=$MAXV
4745 # now fill using QOS
4746 echo writing a bunch of files to QOS-assigned OSTs
4747 $SETSTRIPE $DIR/$tdir -c 1
4749 while [ $FILL -gt 0 ]; do
4750 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1024 count=200 2>/dev/null
4751 FILL=$(($FILL - 200))
4755 echo "wrote $i 200k files"
4759 echo "Note: free space may not be updated, so measurements might be off"
4761 DIFF2=$(($MAXV - $MINV))
4762 echo "free space delta: orig $DIFF final $DIFF2"
4763 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
4764 DIFF=$(($MINV1 - ${AVAIL[$MINI1]}))
4765 echo "Wrote $DIFF to smaller OST $MINI1"
4766 DIFF2=$(($MAXV1 - ${AVAIL[$MAXI1]}))
4767 echo "Wrote $DIFF2 to larger OST $MAXI1"
4768 [ $DIFF -gt 0 ] && echo "Wrote $(($DIFF2 * 100 / $DIFF - 100))% more data to larger OST $MAXI1"
4770 # Figure out which files were written where
4771 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd | awk '/'$MINI1': / {print $2; exit}')
4773 MINC=$($GETSTRIPE --obd $UUID $DIR/$tdir | wc -l)
4774 echo "$MINC files created on smaller OST $MINI1"
4775 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd | (awk '/'$MAXI1': / {print $2; exit}'))
4776 MAXC=$($GETSTRIPE --obd $UUID $DIR/$tdir | wc -l)
4777 echo "$MAXC files created on larger OST $MAXI1"
4778 [ $MINC -gt 0 ] && echo "Wrote $(($MAXC * 100 / $MINC - 100))% more files to larger OST $MAXI1"
4779 [ $MAXC -gt $MINC ] || error_ignore "stripe QOS didn't balance free space"
4783 run_test 116 "stripe QOS: free space balance ==================="
4785 test_117() # bug 10891
4787 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
4788 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
4789 lctl set_param fail_loc=0x21e
4790 > $DIR/$tfile || error "truncate failed"
4791 lctl set_param fail_loc=0
4792 echo "Truncate succeeded."
4794 run_test 117 "verify fsfilt_extend ============================="
4796 export OLD_RESENDCOUNT=""
4797 set_resend_count () {
4798 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
4799 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -1)
4800 lctl set_param -n $PROC_RESENDCOUNT $1
4801 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
4804 [ "$SLOW" = "no" ] && set_resend_count 4 # for reduce test_118* time (bug 14842)
4806 # Reset async IO behavior after error case
4808 FILE=$DIR/reset_async
4810 # Ensure all OSCs are cleared
4811 $SETSTRIPE -c -1 $FILE
4812 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
4817 test_118a() #bug 11710
4821 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
4822 DIRTY=$(lctl get_param -n "llite.*.dump_page_cache" | grep -c dirty)
4823 WRITEBACK=$(lctl get_param "llite.*.dump_page_cache" | grep -c writeback)
4825 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
4826 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
4830 run_test 118a "verify O_SYNC works =========="
4834 remote_ost_nodsh && skip "remote OST with nodsh" && return
4838 #define OBD_FAIL_OST_ENOENT 0x217
4839 set_nodes_failloc "$(osts_nodes)" 0x217
4840 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
4842 set_nodes_failloc "$(osts_nodes)" 0
4843 DIRTY=$(lctl get_param llite.*.dump_page_cache | grep -c dirty)
4844 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
4846 if [[ $RC -eq 0 ]]; then
4847 error "Must return error due to dropped pages, rc=$RC"
4851 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
4852 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
4856 echo "Dirty pages not leaked on ENOENT"
4858 # Due to the above error the OSC will issue all RPCs syncronously
4859 # until a subsequent RPC completes successfully without error.
4860 multiop $DIR/$tfile Ow4096yc
4865 run_test 118b "Reclaim dirty pages on fatal error =========="
4869 remote_ost_nodsh && skip "remote OST with nodsh" && return
4873 #define OBD_FAIL_OST_EROFS 0x216
4874 set_nodes_failloc "$(osts_nodes)" 0x216
4876 # multiop should block due to fsync until pages are written
4877 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
4881 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
4882 error "Multiop failed to block on fsync, pid=$MULTIPID"
4885 WRITEBACK=$(lctl get_param -n llite/*/dump_page_cache | grep -c writeback)
4886 if [[ $WRITEBACK -eq 0 ]]; then
4887 error "No page in writeback, writeback=$WRITEBACK"
4890 set_nodes_failloc "$(osts_nodes)" 0
4893 if [[ $RC -ne 0 ]]; then
4894 error "Multiop fsync failed, rc=$RC"
4897 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
4898 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
4899 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
4900 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
4904 echo "Dirty pages flushed via fsync on EROFS"
4907 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
4911 remote_ost_nodsh && skip "remote OST with nodsh" && return
4915 #define OBD_FAIL_OST_BRW_PAUSE_BULK
4916 set_nodes_failloc "$(osts_nodes)" 0x214
4917 # multiop should block due to fsync until pages are written
4918 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
4922 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
4923 error "Multiop failed to block on fsync, pid=$MULTIPID"
4926 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
4927 if [[ $WRITEBACK -eq 0 ]]; then
4928 error "No page in writeback, writeback=$WRITEBACK"
4931 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
4932 set_nodes_failloc "$(osts_nodes)" 0
4934 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
4935 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
4936 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
4937 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
4941 echo "Dirty pages gaurenteed flushed via fsync"
4944 run_test 118d "Fsync validation inject a delay of the bulk =========="
4949 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
4950 lctl set_param fail_loc=0x8000040a
4952 # Should simulate EINVAL error which is fatal
4953 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
4955 if [[ $RC -eq 0 ]]; then
4956 error "Must return error due to dropped pages, rc=$RC"
4959 lctl set_param fail_loc=0x0
4961 LOCKED=$(lctl get_param -n "llite.*.dump_page_cache" | grep -c locked)
4962 DIRTY=$(lctl get_param -n "llite.*.dump_page_cache" | grep -c dirty)
4963 WRITEBACK=$(lctl get_param -n "llite.*.dump_page_cache" | grep -c writeback)
4964 if [[ $LOCKED -ne 0 ]]; then
4965 error "Locked pages remain in cache, locked=$LOCKED"
4968 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
4969 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
4973 echo "No pages locked after fsync"
4978 run_test 118f "Simulate unrecoverable OSC side error =========="
4983 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
4984 lctl set_param fail_loc=0x406
4986 # simulate local -ENOMEM
4987 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
4990 lctl set_param fail_loc=0
4991 if [[ $RC -eq 0 ]]; then
4992 error "Must return error due to dropped pages, rc=$RC"
4995 LOCKED=$(lctl get_param -n "llite.*.dump_page_cache" | grep -c locked)
4996 DIRTY=$(lctl get_param -n "llite.*.dump_page_cache" | grep -c dirty)
4997 WRITEBACK=$(lctl get_param -n "llite.*.dump_page_cache" | grep -c writeback)
4998 if [[ $LOCKED -ne 0 ]]; then
4999 error "Locked pages remain in cache, locked=$LOCKED"
5002 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
5003 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
5007 echo "No pages locked after fsync"
5012 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
5015 remote_ost_nodsh && skip "remote OST with nodsh" && return
5019 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
5020 set_nodes_failloc "$(osts_nodes)" 0x20e
5021 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
5022 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
5025 set_nodes_failloc "$(osts_nodes)" 0
5026 if [[ $RC -eq 0 ]]; then
5027 error "Must return error due to dropped pages, rc=$RC"
5030 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
5031 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
5032 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writebac)
5033 if [[ $LOCKED -ne 0 ]]; then
5034 error "Locked pages remain in cache, locked=$LOCKED"
5037 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
5038 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
5042 echo "No pages locked after fsync"
5046 run_test 118h "Verify timeout in handling recoverables errors =========="
5049 remote_ost_nodsh && skip "remote OST with nodsh" && return
5053 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
5054 set_nodes_failloc "$(osts_nodes)" 0x20e
5056 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
5057 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
5060 set_nodes_failloc "$(osts_nodes)" 0
5064 if [[ $RC -ne 0 ]]; then
5065 error "got error, but should be not, rc=$RC"
5068 LOCKED=$(lctl get_param -n "llite.*.dump_page_cache" | grep -c locked)
5069 DIRTY=$(lctl get_param -n "llite.*.dump_page_cache" | grep -c dirty)
5070 WRITEBACK=$(lctl get_param -n "llite.*.dump_page_cache" | grep -c writeback)
5071 if [[ $LOCKED -ne 0 ]]; then
5072 error "Locked pages remain in cache, locked=$LOCKED"
5075 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
5076 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
5080 echo "No pages locked after fsync"
5084 run_test 118i "Fix error before timeout in recoverable error =========="
5087 remote_ost_nodsh && skip "remote OST with nodsh" && return
5091 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
5092 set_nodes_failloc "$(osts_nodes)" 0x220
5094 # return -EIO from OST
5095 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
5097 set_nodes_failloc "$(osts_nodes)" 0x0
5098 if [[ $RC -eq 0 ]]; then
5099 error "Must return error due to dropped pages, rc=$RC"
5102 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
5103 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
5104 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
5105 if [[ $LOCKED -ne 0 ]]; then
5106 error "Locked pages remain in cache, locked=$LOCKED"
5109 # in recoverable error on OST we want resend and stay until it finished
5110 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
5111 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
5115 echo "No pages locked after fsync"
5119 run_test 118j "Simulate unrecoverable OST side error =========="
5123 remote_ost_nodsh && skip "remote OSTs with nodsh" && return
5125 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
5126 set_nodes_failloc "$(osts_nodes)" 0x20e
5129 for ((i=0;i<10;i++)); do
5130 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
5131 error "dd to $DIR/$tdir/$tfile-$i failed" )&
5138 set_nodes_failloc "$(osts_nodes)" 0
5141 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
5143 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
5145 test_119a() # bug 11737
5147 BSIZE=$((512 * 1024))
5148 directio write $DIR/$tfile 0 1 $BSIZE
5149 # We ask to read two blocks, which is more than a file size.
5150 # directio will indicate an error when requested and actual
5151 # sizes aren't equeal (a normal situation in this case) and
5152 # print actual read amount.
5153 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
5154 if [ "$NOB" != "$BSIZE" ]; then
5155 error "read $NOB bytes instead of $BSIZE"
5159 run_test 119a "Short directIO read must return actual read amount"
5161 test_119b() # bug 11737
5163 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
5165 $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
5166 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
5168 multiop $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) || \
5169 error "direct read failed"
5172 run_test 119b "Sparse directIO read must return actual read amount"
5174 test_119c() # bug 13099
5177 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
5178 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
5181 run_test 119c "Testing for direct read hitting hole"
5183 test_119d() # bug 15950
5185 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
5186 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
5188 $SETSTRIPE $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
5189 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
5190 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
5191 lctl set_param fail_loc=0x40d
5192 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
5195 cat $DIR/$tfile > /dev/null &
5196 lctl set_param fail_loc=0
5199 log "the DIO writes have completed, now wait for the reads (should not block very long)"
5201 [ -n "`ps h -p $pid_reads -o comm`" ] && \
5202 error "the read rpcs have not completed in 2s"
5204 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
5206 run_test 119d "The DIO path should try to send a new rpc once one is completed"
5210 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
5211 skip "no early lock cancel on server" && return 0
5212 lru_resize_disable mdc
5213 lru_resize_disable osc
5214 cancel_lru_locks mdc
5215 stat $DIR/$tdir > /dev/null
5216 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
5217 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
5219 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
5220 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
5221 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
5222 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
5223 lru_resize_enable mdc
5224 lru_resize_enable osc
5226 run_test 120a "Early Lock Cancel: mkdir test ==================="
5230 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
5231 skip "no early lock cancel on server" && return 0
5232 lru_resize_disable mdc
5233 lru_resize_disable osc
5234 cancel_lru_locks mdc
5235 stat $DIR/$tdir > /dev/null
5236 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
5237 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
5239 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
5240 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
5241 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
5242 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
5243 lru_resize_enable mdc
5244 lru_resize_enable osc
5246 run_test 120b "Early Lock Cancel: create test =================="
5250 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
5251 skip "no early lock cancel on server" && return 0
5252 lru_resize_disable mdc
5253 lru_resize_disable osc
5254 mkdir -p $DIR/$tdir/d1 $DIR/$tdir/d2
5255 touch $DIR/$tdir/d1/f1
5256 cancel_lru_locks mdc
5257 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
5258 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
5259 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
5260 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
5261 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
5262 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
5263 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
5264 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
5265 lru_resize_enable mdc
5266 lru_resize_enable osc
5268 run_test 120c "Early Lock Cancel: link test ===================="
5272 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
5273 skip "no early lock cancel on server" && return 0
5274 lru_resize_disable mdc
5275 lru_resize_disable osc
5277 cancel_lru_locks mdc
5278 stat $DIR/$tdir > /dev/null
5279 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
5280 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
5281 chmod a+x $DIR/$tdir
5282 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
5283 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
5284 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
5285 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
5286 lru_resize_enable mdc
5287 lru_resize_enable osc
5289 run_test 120d "Early Lock Cancel: setattr test ================="
5293 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
5294 skip "no early lock cancel on server" && return 0
5295 lru_resize_disable mdc
5296 lru_resize_disable osc
5297 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
5298 cancel_lru_locks mdc
5299 cancel_lru_locks osc
5300 dd if=$DIR/$tdir/f1 of=/dev/null
5301 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
5302 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
5303 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
5304 unlink $DIR/$tdir/f1
5305 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
5306 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
5307 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
5308 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
5309 lru_resize_enable mdc
5310 lru_resize_enable osc
5312 run_test 120e "Early Lock Cancel: unlink test =================="
5315 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
5316 skip "no early lock cancel on server" && return 0
5318 lru_resize_disable mdc
5319 lru_resize_disable osc
5320 mkdir -p $DIR/$tdir/d1 $DIR/$tdir/d2
5321 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
5322 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
5323 cancel_lru_locks mdc
5324 cancel_lru_locks osc
5325 dd if=$DIR/$tdir/d1/f1 of=/dev/null
5326 dd if=$DIR/$tdir/d2/f2 of=/dev/null
5327 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
5328 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
5329 blk1=`lctl get_param -n ldlm/services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
5330 mv $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
5331 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
5332 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
5333 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
5334 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
5335 lru_resize_enable mdc
5336 lru_resize_enable osc
5338 run_test 120f "Early Lock Cancel: rename test =================="
5341 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
5342 skip "no early lock cancel on server" && return 0
5343 lru_resize_disable mdc
5344 lru_resize_disable osc
5346 echo create $count files
5348 cancel_lru_locks mdc
5349 cancel_lru_locks osc
5352 can0=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
5353 blk0=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
5354 createmany -o $DIR/$tdir/f $count
5356 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
5357 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
5359 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
5360 echo rm $count files
5363 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
5364 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
5366 echo total: $count removes in $((t2-t1))
5367 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
5369 # wait for commitment of removal
5370 lru_resize_enable mdc
5371 lru_resize_enable osc
5373 run_test 120g "Early Lock Cancel: performance test ============="
5375 test_121() { #bug 10589
5376 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
5377 lctl set_param fail_loc=0x310
5378 cancel_lru_locks osc > /dev/null
5379 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
5380 lctl set_param fail_loc=0
5381 [ "$reads" -eq "$writes" ] || error "read" $reads "blocks, must be" $writes
5383 run_test 121 "read cancel race ================================="
5385 test_122() { #bug 11544
5386 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
5387 lctl set_param fail_loc=0x508
5388 dd if=/dev/zero of=$DIR/$tfile count=1
5390 lctl set_param fail_loc=0
5392 run_test 122 "fail client bulk callback (shouldn't LBUG) ======="
5394 test_123a() { # was test 123, statahead(bug 11401)
5396 local lustre_version=$(get_lustre_version mds)
5397 if [[ $lustre_version != 1.8* ]]; then
5398 skip mds running $lustre_version, statahead is disabled
5402 statahead_max_old=`lctl get_param -n llite.*.statahead_max | head -n 1`
5405 if [ -z "$(grep "processor.*: 1" /proc/cpuinfo)" ]; then
5406 log "testing on UP system. Performance may be not as good as expected."
5412 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
5413 [ $NUMFREE -gt 100000 ] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
5415 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
5416 createmany -o $DIR/$tdir/$tfile $j $((i - j))
5418 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
5419 [ $max -eq 0 ] && max=32
5420 lctl set_param -n llite.*.statahead_max 0
5421 lctl get_param llite.*.statahead_max
5422 cancel_lru_locks mdc
5423 cancel_lru_locks osc
5425 time ls -l $DIR/$tdir | wc -l
5427 delta=$((etime - stime))
5428 log "ls $i files without statahead: $delta sec"
5429 lctl set_param llite.*.statahead_max=$max
5431 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
5432 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
5433 cancel_lru_locks mdc
5434 cancel_lru_locks osc
5436 time ls -l $DIR/$tdir | wc -l
5438 delta_sa=$((etime - stime))
5439 log "ls $i files with statahead: $delta_sa sec"
5440 lctl get_param -n llite.*.statahead_stats
5441 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
5443 if [ $swrong -lt $ewrong ]; then
5444 log "statahead was stopped, maybe too many locks held!"
5447 [ $delta -eq 0 -o $delta_sa -eq 0 ] && continue
5449 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
5450 if [ $SLOWOK -eq 0 ]; then
5451 error "ls $i files is slower with statahead!"
5454 lctl set_param debug=-1
5455 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
5456 [ $max -eq 0 ] && max=32
5457 lctl set_param -n llite.*.statahead_max 0
5458 lctl get_param llite.*.statahead_max
5459 cancel_lru_locks mdc
5460 cancel_lru_locks osc
5463 time ls -l $DIR/$tdir | wc -l
5465 error "ls $i files (again) without statahead: $((etime - stime)) sec"
5467 lctl set_param debug=-1
5468 lctl set_param llite.*.statahead_max=$max
5469 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
5470 cancel_lru_locks mdc
5471 cancel_lru_locks osc
5474 time ls -l $DIR/$tdir | wc -l
5476 error "ls $i files (again) with statahead: $((etime - stime)) sec"
5477 lctl get_param -n llite.*.statahead_stats
5481 log "ls $i files is slower with statahead!"
5486 [ $delta -gt 20 ] && break
5487 [ $delta -gt 8 ] && MULT=$((50 / delta))
5488 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
5496 delta=$((etime - stime))
5497 log "rm -r $DIR/$tdir/: $delta seconds"
5499 # restore default value
5500 $LCTL set_param llite.*.statahead_max=$statahead_max_old
5501 $LCTL get_param -n llite.*.statahead_stats
5503 run_test 123a "verify statahead work"
5505 test_123b () { # statahead(bug 15027)
5507 local lustre_version=$(get_lustre_version mds)
5508 if [[ $lustre_version != 1.8* ]]; then
5509 skip mds running $lustre_version, statahead is disabled
5514 createmany -o $DIR/$tdir/$tfile-%d 1000
5516 cancel_lru_locks mdc
5517 cancel_lru_locks osc
5519 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
5520 lctl set_param fail_loc=0x80000803
5521 ls -lR $DIR/$tdir > /dev/null
5523 lctl set_param fail_loc=0x0
5524 lctl get_param -n llite.*.statahead_stats
5529 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
5532 [ -z "`lctl get_param -n mdc.*.connect_flags | grep lru_resize`" ] && \
5533 skip "no lru resize on server" && return 0
5535 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
5537 log "create $NR files at $DIR/$tdir"
5538 createmany -o $DIR/$tdir/f $NR ||
5539 error "failed to create $NR files in $DIR/$tdir"
5541 cancel_lru_locks mdc
5542 ls -l $DIR/$tdir > /dev/null
5546 for VALUE in `lctl get_param ldlm.namespaces.*mdc-*.lru_size`; do
5547 local PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
5548 LRU_SIZE=$(lctl get_param -n $PARAM)
5549 if [ $LRU_SIZE -gt $(default_lru_size) ]; then
5550 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
5551 log "NS=$(basename $NSDIR)"
5556 if [ -z "$NSDIR" -o $LRU_SIZE -lt $(default_lru_size) ]; then
5557 skip "Not enough cached locks created!"
5564 # We know that lru resize allows one client to hold $LIMIT locks
5565 # for 10h. After that locks begin to be killed by client.
5567 local LIMIT=`lctl get_param -n $NSDIR.pool.limit`
5569 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
5570 # killing locks. Some time was spent for creating locks. This means
5571 # that up to the moment of sleep finish we must have killed some of
5572 # them (10-100 locks). This depends on how fast ther were created.
5573 # Many of them were touched in almost the same moment and thus will
5574 # be killed in groups.
5575 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
5577 # Use $LRU_SIZE_B here to take into account real number of locks
5578 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
5579 local LRU_SIZE_B=$LRU_SIZE
5581 local OLD_LVF=`lctl get_param -n $NSDIR.pool.lock_volume_factor`
5582 lctl set_param -n $NSDIR.pool.lock_volume_factor $LVF
5584 # Let's make sure that we really have some margin. Client checks
5585 # cached locks every 10 sec.
5587 log "Sleep ${SLEEP} sec"
5589 while ((SEC<$SLEEP)); do
5593 LRU_SIZE=`lctl get_param -n $NSDIR/lru_size`
5597 lctl set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
5598 local LRU_SIZE_A=`lctl get_param -n $NSDIR/lru_size`
5600 [ $LRU_SIZE_B -gt $LRU_SIZE_A ] || {
5601 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
5602 unlinkmany $DIR/$tdir/f $NR
5606 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
5607 log "unlink $NR files at $DIR/$tdir"
5608 unlinkmany $DIR/$tdir/f $NR
5610 run_test 124a "lru resize ======================================="
5613 [ -z "`lctl get_param -n mdc.*.connect_flags | grep lru_resize`" ] && \
5614 skip "no lru resize on server" && return 0
5616 # even for cmd no matter what metadata namespace to use for getting
5617 # the limit, we use appropriate.
5618 LIMIT=`lctl get_param -n ldlm.namespaces.*mdc*.pool.limit`
5620 NR=$(($(default_lru_size)*20))
5621 if [ $NR -gt $LIMIT ]; then
5624 lru_resize_disable mdc
5625 mkdir -p $DIR/$tdir/disable_lru_resize ||
5626 error "failed to create $DIR/$tdir/disable_lru_resize"
5628 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
5629 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
5630 cancel_lru_locks mdc
5633 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
5636 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
5639 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
5643 nolruresize_delta=$((etime-stime))
5644 log "ls -la time: $nolruresize_delta seconds"
5645 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
5646 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
5648 lru_resize_enable mdc
5649 mkdir -p $DIR/$tdir/enable_lru_resize ||
5650 error "failed to create $DIR/$tdir/enable_lru_resize"
5652 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
5653 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
5654 cancel_lru_locks mdc
5657 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
5660 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
5663 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
5667 lruresize_delta=$((etime-stime))
5668 log "ls -la time: $lruresize_delta seconds"
5669 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
5671 if [ $lruresize_delta -gt $nolruresize_delta ]; then
5672 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
5673 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
5674 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
5676 log "lru resize performs the same with no lru resize"
5678 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
5680 run_test 124b "lru resize (performance test) ======================="
5682 test_125() { # 13358
5683 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
5684 mkdir -p $DIR/d125 || error "mkdir failed"
5685 $SETSTRIPE $DIR/d125 -s 65536 -c -1 || error "setstripe failed"
5686 setfacl -R -m u:bin:rwx $DIR/d125 || error "setfacl $DIR/d125 failes"
5687 ls -ld $DIR/d125 || error "cannot access $DIR/d125"
5689 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
5691 test_126() { # bug 12829/13455
5692 [ "$UID" != 0 ] && skip_env "skipping $TESTNAME (must run as root)" && return
5693 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
5694 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
5696 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
5698 run_test 126 "check that the fsgid provided by the client is taken into account"
5700 test_127() { # bug 15521
5701 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
5702 $LCTL set_param osc.*.stats=0
5703 FSIZE=$((2048 * 1024))
5704 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
5705 cancel_lru_locks osc
5706 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
5708 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
5709 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
5710 echo "got $COUNT $NAME"
5711 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
5712 eval $NAME=$COUNT || error "Wrong proc format"
5715 read_bytes|write_bytes)
5716 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
5717 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
5718 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
5719 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
5720 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
5721 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
5722 error "sumsquare is too small: $SUMSQ"
5723 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
5724 error "sumsquare is too big: $SUMSQ"
5728 done < $DIR/${tfile}.tmp
5730 #check that we actually got some stats
5731 [ "$read_bytes" ] || error "Missing read_bytes stats"
5732 [ "$write_bytes" ] || error "Missing write_bytes stats"
5733 [ "$read_bytes" != 0 ] || error "no read done"
5734 [ "$write_bytes" != 0 ] || error "no write done"
5736 run_test 127 "verify the client stats are sane"
5738 test_128() { # bug 15212
5740 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
5745 result=$(grep error $TMP/$tfile.log)
5747 [ -z "$result" ] || error "consecutive find with interactive lfs failed"
5749 run_test 128 "interactive lfs for 2 consecutive finds"
5752 [ "$FSTYPE" != "ldiskfs" ] && skip "not needed for FSTYPE=$FSTYPE" && return 0
5753 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5755 local MNTDEV=$(get_mds_mntdev_proc_path)
5756 DEV=$(ldiskfs_canon "$MNTDEV" mds)
5757 [ -z "$DEV" ] && error "can't access mds mntdev"
5759 LDPROC=/proc/fs/ldiskfs/$DEV/max_dir_size
5760 do_facet mds "test -e /sys/fs/ldiskfs/$DEV/max_dir_size" && LDPROC=/sys/fs/ldiskfs/$DEV/max_dir_size
5763 do_facet mds "echo $MAX > $LDPROC"
5769 while [ ! $I -gt $MAX ]; do
5770 multiop $DIR/$tdir/$J Oc
5772 if [ $rc -eq $EFBIG ]; then
5773 do_facet mds "echo 0 >$LDPROC"
5774 echo "return code $rc received as expected"
5776 elif [ $rc -ne 0 ]; then
5777 do_facet mds "echo 0 >$LDPROC"
5778 error_exit "error $rc instead of expected $EFBIG"
5781 I=$(stat -c%s "$DIR/$tdir")
5784 error "exceeded dir size limit: $I bytes"
5785 do_facet mds "echo 0 >$LDPROC"
5787 run_test 129 "test directory size limit ========================"
5796 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
5797 [ -n "$filefrag_op" ] && skip "filefrag has no FIEMAP support" && return
5799 trap cleanup_130 EXIT RETURN
5801 local fm_file=$DIR/$tfile
5802 lfs setstripe -s 65536 -c 1 $fm_file ||
5803 error "setstripe failed on $fm_file"
5804 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
5805 error "dd failed for $fm_file"
5807 filefrag -ves $fm_file || error "filefrag $fm_file failed"
5808 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
5810 lun=`$GETSTRIPE $fm_file | grep -A 10 obdidx | awk '{print $1}' | grep -v "obdidx"`
5812 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
5815 for line in $filefrag_op
5817 frag_lun=`echo $line | cut -d: -f5`
5818 ext_len=`echo $line | cut -d: -f4`
5819 if (( $frag_lun != $lun )); then
5821 error "FIEMAP on 1-stripe file($fm_file) failed"
5824 (( tot_len += ext_len ))
5827 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
5829 error "FIEMAP on 1-stripe file($fm_file) failed;"
5835 echo "FIEMAP on single striped file succeeded"
5837 run_test 130a "FIEMAP (1-stripe file)"
5840 [ "$OSTCOUNT" -lt "2" ] && skip_env "FIEMAP on 2-stripe file test" && return
5842 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
5843 [ -n "$filefrag_op" ] && skip "filefrag has no FIEMAP support" && return
5845 trap cleanup_130 EXIT RETURN
5847 local fm_file=$DIR/$tfile
5848 lfs setstripe -s 65536 -c 2 $fm_file ||
5849 error "setstripe failed on $fm_file"
5850 dd if=/dev/zero of=$fm_file bs=1M count=2 ||
5851 error "dd failed on $fm_file"
5853 filefrag -ves $fm_file || error "filefrag $fm_file failed"
5854 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
5856 last_lun=`echo $filefrag_op | cut -d: -f5`
5861 for line in $filefrag_op; do
5862 frag_lun=`echo $line | cut -d: -f5`
5863 ext_len=`echo $line | cut -d: -f4`
5864 if (( $frag_lun != $last_lun )); then
5865 if (( tot_len != 1024 )); then
5867 error "FIEMAP $fm_file: len $tot_len for OST $last_lun instead of 256"
5874 (( tot_len += ext_len ))
5877 if (( num_luns != 2 || tot_len != 1024 )); then
5879 error "FIEMAP $fm_file: wrong number of LUNs or wrong len for OST $last_lun"
5885 echo "FIEMAP on 2-stripe file succeeded"
5887 run_test 130b "FIEMAP (2-stripe file)"
5890 [ "$OSTCOUNT" -lt "2" ] && skip_env "FIEMAP on 2-stripe hole test" && return
5892 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
5893 [ -n "$filefrag_op" ] && skip "filefrag has no FIEMAP support" && return
5895 trap cleanup_130 EXIT RETURN
5897 local fm_file=$DIR/$tfile
5898 lfs setstripe -s 65536 -c 2 $fm_file ||
5899 error "setstripe failed on $fm_file"
5900 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 ||
5901 error "dd failed on $fm_file"
5903 filefrag -ves $fm_file || error "filefrag $fm_file failed"
5904 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
5906 last_lun=`echo $filefrag_op | cut -d: -f5`
5911 for line in $filefrag_op
5913 frag_lun=`echo $line | cut -d: -f5`
5914 ext_len=`echo $line | cut -d: -f4`
5915 if (( $frag_lun != $last_lun )); then
5916 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
5917 if (( logical != 512 )); then
5919 error "FIEMAP $fm_file: logical start for LUN $logical instead of 512"
5922 if (( tot_len != 512 )); then
5924 error "FIEMAP $fm_file: len $tot_len for OST $last_lun instead of 1024"
5931 (( tot_len += ext_len ))
5934 if (( num_luns != 2 || tot_len != 512 )); then
5936 error "FIEMAP $fm_file: wrong number of LUNs or wrong len for OST $last_lun"
5942 echo "FIEMAP on 2-stripe file with hole succeeded"
5944 run_test 130c "FIEMAP (2-stripe file with hole)"
5947 [ "$OSTCOUNT" -lt "3" ] && skip_env "FIEMAP on N-stripe file test" && return
5949 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
5950 [ -n "$filefrag_op" ] && skip "filefrag has no FIEMAP support" && return
5952 trap cleanup_130 EXIT RETURN
5954 local fm_file=$DIR/$tfile
5955 lfs setstripe -s 65536 -c $OSTCOUNT $fm_file ||
5956 error "setstripe failed on $fm_file"
5957 dd if=/dev/zero of=$fm_file bs=1M count=$OSTCOUNT ||
5958 error "dd failed on $fm_file"
5960 filefrag -ves $fm_file || error "filefrag $fm_file failed"
5961 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
5963 last_lun=`echo $filefrag_op | cut -d: -f5`
5968 for line in $filefrag_op
5970 frag_lun=`echo $line | cut -d: -f5`
5971 ext_len=`echo $line | cut -d: -f4`
5972 if (( $frag_lun != $last_lun )); then
5973 if (( tot_len != 1024 )); then
5975 error "FIEMAP $fm_file: len $tot_len for OST $last_lun instead of 1024"
5982 (( tot_len += ext_len ))
5985 if (( num_luns != OSTCOUNT || tot_len != 1024 )); then
5987 error "FIEMAP $fm_file: wrong number of LUNs or wrong len for OST $last_lun"
5993 echo "FIEMAP on N-stripe file succeeded"
5995 run_test 130d "FIEMAP (N-stripe file)"
5998 [ "$OSTCOUNT" -lt "2" ] && skip "continuation FIEMAP test" && return
6000 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
6001 [ -n "$filefrag_op" ] && skip "filefrag has no FIEMAP support" && return
6003 trap cleanup_130 EXIT RETURN
6005 local fm_file=$DIR/$tfile
6006 lfs setstripe -s 131072 -c 2 $fm_file ||
6007 error "setstripe failed on $fm_file"
6009 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
6010 for ((i = 0; i < $NUM_BLKS; i++)); do
6011 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
6014 filefrag -ves $fm_file || error "filefrag $fm_file failed"
6015 filefrag_op=`filefrag -ve $fm_file | grep -A 12000 "ext:" | grep -v "ext:" | grep -v "found"`
6017 last_lun=`echo $filefrag_op | cut -d: -f5`
6022 for line in $filefrag_op
6024 frag_lun=`echo $line | cut -d: -f5`
6025 ext_len=`echo $line | cut -d: -f4`
6026 if (( $frag_lun != $last_lun )); then
6027 if (( tot_len != $EXPECTED_LEN )); then
6029 error "FIEMAP $fm_file: len $tot_len for OST $last_lun instead of $EXPECTED_LEN"
6036 (( tot_len += ext_len ))
6039 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
6041 error "FIEMAP $fm_file: wrong number of LUNs or wrong len for OST $last_lun"
6047 echo "FIEMAP with continuation calls succeeded"
6049 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
6055 mds) local dev=$(get_mds_mdt_device_proc_path)
6056 res=`do_facet mds $LCTL get_param $dev.$FSNAME-MDT0000.stats | grep "$2"`
6058 ost) res=`do_facet ost0 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$2"`
6060 *) error "Wrong argument $1" ;;
6063 count=`echo $res | awk '{print $2}'`
6064 [ -z "$res" ] && error "The counter for $2 on $1 was not incremented"
6065 # if the argument $3 is zero, it means any stat increment is ok.
6066 if [ $3 -gt 0 ] ; then
6067 [ $count -ne $3 ] && error "The $2 counter on $1 is wrong - expected $3"
6073 local lustre_version=$(get_lustre_version mds)
6074 if [[ $lustre_version != 1.8* ]]; then
6075 skip mds running $lustre_version, no stats, bz22378
6079 local testdir=$DIR/${tdir}/stats_testdir
6080 mkdir -p $DIR/${tdir}
6083 local dev=$(get_mds_mdt_device_proc_path)
6084 do_facet mds $LCTL set_param $dev.*.stats=clear
6085 do_facet ost $LCTL set_param obdfilter.*.stats=clear
6087 # verify mdt stats first.
6088 mkdir ${testdir} || error "mkdir failed"
6089 check_stats mds "mkdir" 1
6090 touch ${testdir}/${tfile} || "touch failed"
6091 # LPROC_MDS_OPEN is incremented by 2 - in mds_open() and mds_intent_policy()
6092 check_stats mds "open" 2
6093 check_stats mds "close" 1
6094 mknod ${testdir}/${tfile}-pipe p || "mknod failed"
6095 check_stats mds "mknod" 1
6096 rm -f ${testdir}/${tfile}-pipe || "pipe remove failed"
6097 check_stats mds "unlink" 1
6098 rm -f ${testdir}/${tfile} || error "file remove failed"
6099 check_stats mds "unlink" 2
6101 # remove working dir and check mdt stats again.
6102 rmdir ${testdir} || error "rmdir failed"
6103 check_stats mds "rmdir" 1
6107 run_test 133a "Verifying MDT stats ========================================"
6111 local lustre_version=$(get_lustre_version mds)
6112 if [[ $lustre_version != 1.8* ]]; then
6113 skip mds running $lustre_version, no stats, bz22378
6117 local testdir=$DIR/${tdir}/stats_testdir
6118 mkdir -p ${testdir} || error "mkdir failed"
6119 touch ${testdir}/${tfile} || "touch failed"
6120 cancel_lru_locks mdc
6123 local dev=$(get_mds_mdt_device_proc_path)
6124 do_facet mds $LCTL set_param $dev.*.stats=clear
6125 do_facet ost $LCTL set_param obdfilter.*.stats=clear
6127 # extra mdt stats verification.
6128 stat ${testdir}/${tfile} || error "stat failed"
6129 check_stats mds "getattr" 0
6130 chmod 444 ${testdir}/${tfile} || error "chmod failed"
6131 check_stats mds "setattr" 1
6132 $LFS df || error "lfs failed"
6133 check_stats mds "statfs" 1
6137 run_test 133b "Verifying extra MDT stats =================================="
6141 local lustre_version=$(get_lustre_version mds)
6142 if [[ $lustre_version != 1.8* ]]; then
6143 skip mds running $lustre_version, no stats, bz22378
6147 local testdir=$DIR/${tdir}/stats_testdir
6148 mkdir -p ${testdir} || error "mkdir failed"
6150 # verify obdfilter stats.
6151 $LFS setstripe -c 1 -o 0 ${testdir}/${tfile}
6153 cancel_lru_locks osc
6156 local dev=$(get_mds_mdt_device_proc_path)
6157 do_facet mds $LCTL set_param $dev.*.stats=clear
6158 do_facet ost $LCTL set_param obdfilter.*.stats=clear
6160 dd if=/dev/zero of=${testdir}/${tfile} bs=1024k count=1 || error "dd failed"
6162 cancel_lru_locks osc
6163 check_stats ost "write" 1
6165 dd if=${testdir}/${tfile} of=/dev/null bs=1k count=1 || error "dd failed"
6166 check_stats ost "read" 1
6168 > ${testdir}/${tfile} || error "truncate failed"
6169 check_stats ost "punch" 1
6171 rm -f ${testdir}/${tfile} || error "file remove failed"
6172 check_stats ost "destroy" 1
6176 run_test 133c "Verifying OST stats ========================================"
6178 test_140() { #bug-17379
6179 mkdir -p $DIR/$tdir || error "Creating dir $DIR/$tdir"
6180 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
6181 cp /usr/bin/stat . || error "Copying stat to $DIR/$tdir"
6183 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
6185 while i=`expr $i + 1`; do
6186 mkdir -p $i || error "Creating dir $i"
6187 cd $i || error "Changing to $i"
6188 ln -s ../stat stat || error "Creating stat symlink"
6189 # Read the symlink until ELOOP present,
6190 # not LBUGing the system is considered success,
6191 # we didn't overrun the stack.
6192 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
6194 if [ $ret -eq 40 ]; then
6197 error "Open stat symlink"
6203 echo "The symlink depth = $i"
6204 [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 ] || error "Invalid symlink depth"
6206 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
6209 local TF="$TMP/$tfile"
6211 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
6213 cancel_lru_locks osc
6214 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
6215 remount_client $MOUNT
6217 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
6220 $TRUNCATE $DIR/$tfile 6000
6221 cancel_lru_locks osc
6222 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
6225 echo "12345" >>$DIR/$tfile
6226 cancel_lru_locks osc
6227 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
6230 echo "12345" >>$DIR/$tfile
6231 cancel_lru_locks osc
6232 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
6237 run_test 150 "truncate/append tests"
6239 function roc_hit() {
6240 local list=$(comma_list $(osts_nodes))
6242 ACCNUM=$(do_nodes $list $LCTL get_param -n obdfilter.*.stats | \
6243 awk '/'cache_hit'/ {sum+=$2} END {print sum}')
6247 function set_cache() {
6250 if [ "$2" == "off" ]; then
6253 local list=$(comma_list $(osts_nodes))
6254 do_nodes $list lctl set_param obdfilter.*.${1}_cache_enable $on
6256 cancel_lru_locks osc
6260 remote_ost_nodsh && skip "remote OST with nodsh" && return
6262 local list=$(comma_list $(osts_nodes))
6263 if ! do_nodes $list grep -q truncate_inode_pages_range /proc/kallsyms; then #b=18718
6264 skip "old RHEL4/SLES9 kernel" && return
6269 # check whether obdfilter is cache capable at all
6270 if ! do_nodes $list $LCTL get_param -n obdfilter.*.read_cache_enable > /dev/null; then
6271 echo "not cache-capable obdfilter"
6275 # make sure cache is enabled on all obdfilters
6276 do_nodes $list $LCTL set_param obdfilter.*.read_cache_enable=1
6277 do_nodes $list $LCTL set_param obdfilter.*.writethrough_cache_enable=1
6279 # pages should be in the case right after write
6280 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES || error "dd failed"
6281 local BEFORE=`roc_hit`
6282 cancel_lru_locks osc
6283 cat $DIR/$tfile >/dev/null
6284 local AFTER=`roc_hit`
6285 if let "AFTER - BEFORE != CPAGES"; then
6286 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
6289 # the following read invalidates the cache
6290 cancel_lru_locks osc
6291 do_nodes $list $LCTL set_param -n obdfilter.*.read_cache_enable 0
6292 cat $DIR/$tfile >/dev/null
6294 # now data shouldn't be found in the cache
6296 cancel_lru_locks osc
6297 cat $DIR/$tfile >/dev/null
6299 if let "AFTER - BEFORE != 0"; then
6300 error "IN CACHE: before: $BEFORE, after: $AFTER"
6303 do_nodes $list $LCTL set_param -n obdfilter.*.read_cache_enable=1
6304 do_nodes $list $LCTL set_param obdfilter.*.writethrough_cache_enable=1
6307 run_test 151 "test cache on oss and controls ==============================="
6310 local TF="$TMP/$tfile"
6312 # simulate ENOMEM during write
6313 #define OBD_FAIL_OST_NOMEM 0x226
6314 lctl set_param fail_loc=0x80000226
6315 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
6317 sync || error "sync failed"
6318 lctl set_param fail_loc=0
6320 # discard client's cache
6321 cancel_lru_locks osc
6323 # simulate ENOMEM during read
6324 lctl set_param fail_loc=0x80000226
6325 cmp $TF $DIR/$tfile || error "cmp failed"
6326 lctl set_param fail_loc=0
6330 run_test 152 "test read/write with enomem ============================"
6333 multiop $DIR/$tfile Ow4096Ycu || error "multiop failed"
6335 run_test 153 "test if fdatasync does not crash ======================="
6338 # do directio so as not to populate the page cache
6339 log "creating a 10 Mb file"
6340 multiop $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
6341 log "starting reads"
6342 dd if=$DIR/$tfile of=/dev/null bs=4096 &
6343 log "truncating the file"
6344 multiop $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
6346 kill %+ || true # reads might have finished
6347 echo "wait until dd is finished"
6349 log "removing the temporary file"
6350 rm -rf $DIR/$tfile || error "tmp file removal failed"
6352 run_test 154 "parallel read and truncate should not deadlock ==="
6355 local temp=$TMP/$tfile
6356 local file=$DIR/$tfile
6357 local list=$(comma_list $(osts_nodes))
6358 local big=$(do_nodes $list grep "cache" /proc/cpuinfo | \
6359 awk '{sum+=$4} END{print sum}')
6363 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
6364 error "dd of=$temp bs=6096 count=1 failed"
6366 cancel_lru_locks osc
6367 cmp $temp $file || error "$temp $file differ"
6369 $TRUNCATE $temp 6000
6370 $TRUNCATE $file 6000
6371 cmp $temp $file || error "$temp $file differ (truncate1)"
6373 echo "12345" >>$temp
6374 echo "12345" >>$file
6375 cmp $temp $file || error "$temp $file differ (append1)"
6377 echo "12345" >>$temp
6378 echo "12345" >>$file
6379 cmp $temp $file || error "$temp $file differ (append2)"
6381 dd if=/dev/urandom of=$temp bs=$((big*2)) count=1k || \
6382 error "dd of=$temp bs=$((big*2)) count=1k failed"
6385 cancel_lru_locks osc
6386 cmp $temp $file || error "$temp $file differ"
6394 set_cache writethrough on
6397 run_test 155a "Verification of correctness: read cache:on write_cache:on"
6401 set_cache writethrough off
6404 run_test 155b "Verification of correctness: read cache:on write_cache:off"
6408 set_cache writethrough on
6411 run_test 155c "Verification of correctness: read cache:off write_cache:on"
6415 set_cache writethrough off
6418 run_test 155d "Verification of correctness: read cache:off write_cache:off "
6424 local file="$DIR/$tfile"
6426 log "Turn on read and write cache"
6428 set_cache writethrough on
6430 log "Write data and read it back."
6431 log "Read should be satisfied from the cache."
6432 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
6434 cancel_lru_locks osc
6435 cat $file >/dev/null
6437 if ! let "AFTER - BEFORE == CPAGES"; then
6438 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
6440 log "cache hits:: before: $BEFORE, after: $AFTER"
6443 log "Read again; it should be satisfied from the cache."
6445 cancel_lru_locks osc
6446 cat $file >/dev/null
6448 if ! let "AFTER - BEFORE == CPAGES"; then
6449 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
6451 log "cache hits:: before: $BEFORE, after: $AFTER"
6455 log "Turn off the read cache and turn on the write cache"
6457 set_cache writethrough on
6459 log "Read again; it should be satisfied from the cache."
6461 cancel_lru_locks osc
6462 cat $file >/dev/null
6464 if ! let "AFTER - BEFORE == CPAGES"; then
6465 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
6467 log "cache hits:: before: $BEFORE, after: $AFTER"
6470 log "Read again; it should not be satisfied from the cache."
6472 cancel_lru_locks osc
6473 cat $file >/dev/null
6475 if ! let "AFTER - BEFORE == 0"; then
6476 error "IN CACHE: before: $BEFORE, after: $AFTER"
6478 log "cache hits:: before: $BEFORE, after: $AFTER"
6481 log "Write data and read it back."
6482 log "Read should be satisfied from the cache."
6483 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
6485 cancel_lru_locks osc
6486 cat $file >/dev/null
6488 if ! let "AFTER - BEFORE == CPAGES"; then
6489 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
6491 log "cache hits:: before: $BEFORE, after: $AFTER"
6494 log "Read again; it should not be satisfied from the cache."
6496 cancel_lru_locks osc
6497 cat $file >/dev/null
6499 if ! let "AFTER - BEFORE == 0"; then
6500 error "IN CACHE: before: $BEFORE, after: $AFTER"
6502 log "cache hits:: before: $BEFORE, after: $AFTER"
6506 log "Turn off read and write cache"
6508 set_cache writethrough off
6510 log "Write data and read it back"
6511 log "It should not be satisfied from the cache."
6513 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
6514 cancel_lru_locks osc
6516 cat $file >/dev/null
6518 if ! let "AFTER - BEFORE == 0"; then
6519 error_ignore 20762 "IN CACHE: before: $BEFORE, after: $AFTER"
6521 log "cache hits:: before: $BEFORE, after: $AFTER"
6525 log "Turn on the read cache and turn off the write cache"
6527 set_cache writethrough off
6529 log "Write data and read it back"
6530 log "It should not be satisfied from the cache."
6532 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
6534 cancel_lru_locks osc
6535 cat $file >/dev/null
6537 if ! let "AFTER - BEFORE == 0"; then
6538 error_ignore 20762 "IN CACHE: before: $BEFORE, after: $AFTER"
6540 log "cache hits:: before: $BEFORE, after: $AFTER"
6543 log "Read again; it should be satisfied from the cache."
6545 cancel_lru_locks osc
6546 cat $file >/dev/null
6548 if ! let "AFTER - BEFORE == CPAGES"; then
6549 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
6551 log "cache hits:: before: $BEFORE, after: $AFTER"
6556 run_test 156 "Verification of ROC tunables ========================"
6559 $LCTL clear # bug 18514
6560 $LCTL debug_daemon start $TMP/${tfile}_log_good
6562 $LCTL debug_daemon stop
6563 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
6564 error "sed failed to read log_good"
6566 $LCTL debug_daemon start $TMP/${tfile}_log_good
6568 $LCTL debug_daemon stop
6570 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
6571 error "lctl df log_bad failed"
6573 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
6574 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
6576 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
6577 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
6579 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
6580 error "bad_line good_line1 good_line2 are empty"
6582 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
6583 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
6584 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
6586 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
6587 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
6588 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
6590 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
6591 error "bad_line_new good_line_new are empty"
6593 local expected_good=$((good_line1 + good_line2*2))
6595 rm -f $TMP/${tfile}*
6596 if [ $bad_line -ne $bad_line_new ]; then
6597 error "expected $bad_line bad lines, but got $bad_line_new"
6601 if [ $expected_good -ne $good_line_new ]; then
6602 error "expected $expected_good good lines, but got $good_line_new"
6607 run_test 170 "test lctl df to handle corrupted log ====================="
6609 test_171() { # bug20592
6610 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
6611 $LCTL set_param fail_loc=0x50e
6612 $LCTL set_param fail_val=3000
6613 multiop_bg_pause $DIR/$tfile Os || true
6616 if dmesg | grep "recursive fault"; then
6617 error "caught a recursive fault"
6619 $LCTL set_param fail_loc=0
6622 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
6624 obdecho_create_test() {
6628 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
6629 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" || rc=2; }
6630 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec create 1" || rc=3; }
6631 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec test_brw 0 w 1" || rc=4; }
6632 [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec cleanup" || rc=5; }
6633 [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec detach" || rc=6; }
6638 local lustre_version=$(get_lustre_version mds)
6639 if [[ $lustre_version != 1.8* ]]; then
6640 skip bug22316 mds running $lustre_version
6645 local rmmod_remote=0
6647 lsmod | grep -q obdecho || { load_module obdecho/obdecho && rmmod_local=1; }
6649 OBD=`$LCTL dl | awk ' /-osc-/ { print $4; exit; }'`
6650 [ "x$OBD" != "x" ] && { obdecho_create_test $OBD client || rc=2; }
6651 [ $rmmod_local -eq 1 ] && rmmod obdecho
6652 [ $rc -ne 0 ] && return $rc
6654 do_facet ost "lsmod | grep -q obdecho || { insmod ${LUSTRE}/obdecho/obdecho.ko || modprobe obdecho; }" && rmmod_remote=1
6656 OBD=$(do_facet ost "$LCTL dl | awk '/obdfilter/ { print; exit; }'" | awk '{print $4;}')
6657 [ "x$OBD" != "x" ] && { obdecho_create_test $OBD ost || rc=3; }
6658 [ $rmmod_remote -eq 1 ] && do_facet ost "rmmod obdecho"
6659 [ $rc -ne 0 ] && return $rc
6663 run_test 180 "test obdecho ============================================"
6665 test_181() { # bug 22177
6666 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
6667 # create enough files to index the directory
6668 createmany -o $DIR/$tdir/foobar 4000
6669 # print attributes for debug purpose
6672 multiop_bg_pause $DIR/$tdir D_Sc || return 1
6674 # remove the files & current working dir
6675 unlinkmany $DIR/$tdir/foobar 4000
6677 kill -USR1 $MULTIPID
6679 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
6682 run_test 181 "Test open-unlinked dir ========================"
6687 TGTPOOL_MAX=$(($TGT_COUNT - 1))
6689 TGTPOOL_LIST=`seq $TGTPOOL_FIRST $TGTPOOL_STEP $TGTPOOL_MAX`
6690 POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
6691 POOL_DIR_NAME=dir_tst
6692 POOL_DIR=$POOL_ROOT/$POOL_DIR_NAME
6693 POOL_FILE=$POOL_ROOT/file_tst
6697 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep pools)" ] &&
6698 skip "missing pools support on server" && return 1
6699 remote_mgs_nodsh && skip "remote MGS with nodsh" && return 1
6700 [ -z "$mdtlov" ] && mdtlov=$(get_mdtlov_proc_path $FSNAME)
6704 check_file_in_pool()
6707 res=$($GETSTRIPE $file | grep 0x | cut -f2)
6710 found=$(echo :$TGTPOOL_LIST: | tr " " ":" | grep :$i:)
6711 if [[ "$found" == "" ]]
6713 echo "pool list: $TGTPOOL_LIST"
6714 echo "striping: $res"
6715 error "$file not allocated in $POOL"
6724 trap "cleanup_pools $FSNAME" EXIT
6727 test_pools || return 0
6729 create_pool $FSNAME.$POOL || return $?
6730 [ $($LFS pool_list $FSNAME | grep -c $POOL) -eq 1 ] ||
6731 error "$POOL not in lfs pool_list"
6733 run_test 200a "Create new pool =========================================="
6736 test_pools || return 0
6737 TGT=$(for i in $TGTPOOL_LIST; do printf "$FSNAME-OST%04x_UUID " $i; done)
6738 do_facet mgs $LCTL pool_add $FSNAME.$POOL \
6739 $FSNAME-OST[$TGTPOOL_FIRST-$TGTPOOL_MAX/$TGTPOOL_STEP]
6741 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL | sort -u | tr '\n' ' ' " "$TGT" ||
6742 error "Add to pool failed"
6744 run_test 200b "Add targets to a pool ===================================="
6747 test_pools || return 0
6749 $SETSTRIPE -c 2 -p $POOL $POOL_DIR
6750 [ $? = 0 ] || error "Cannot set pool $POOL to $POOL_DIR"
6751 # b-19919 test relative path works well
6752 mkdir -p $POOL_DIR/$POOL_DIR_NAME
6754 $SETSTRIPE -c 2 -p $POOL $POOL_DIR_NAME
6755 [ $? = 0 ] || error "Cannot set pool $POOL to $POOL_DIR/$POOL_DIR_NAME"
6756 $SETSTRIPE -c 2 -p $POOL ./$POOL_DIR_NAME
6757 [ $? = 0 ] || error "Cannot set pool $POOL to $POOL_DIR/./$POOL_DIR_NAME"
6758 $SETSTRIPE -c 2 -p $POOL ../$POOL_DIR_NAME
6759 [ $? = 0 ] || error "Cannot set pool $POOL to $POOL_DIR/../$POOL_DIR_NAME"
6760 $SETSTRIPE -c 2 -p $POOL ../$POOL_DIR_NAME/$POOL_DIR_NAME
6761 [ $? = 0 ] || error "Cannot set pool $POOL to $POOL_DIR/../$POOL_DIR_NAME/$POOL_DIR_NAME"
6762 rm -rf $POOL_DIR_NAME; cd -
6764 run_test 200c "Set pool on a directory ================================="
6767 test_pools || return 0
6768 res=$($GETSTRIPE --pool $POOL_DIR | awk '/^pool:/ {print $2}')
6769 [ "$res" = $POOL ] || error "Pool on $POOL_DIR is $res, not $POOL"
6771 run_test 200d "Check pool on a directory ==============================="
6774 test_pools || return 0
6776 for i in $(seq -w 1 $(($TGT_COUNT * 3))); do
6777 file=$POOL_DIR/file-$i
6779 check_file_in_pool $file
6780 if [[ $? != 0 ]]; then
6781 failed=$(($failed + 1))
6784 [ "$failed" = 0 ] || error "$failed files not allocated in $POOL"
6786 run_test 200e "Check files allocation from directory pool =============="
6789 test_pools || return 0
6792 for i in $(seq -w 1 $(($TGT_COUNT * 3))); do
6793 file=$POOL_FILE/spoo-$i
6794 $SETSTRIPE -p $POOL $file
6795 check_file_in_pool $file
6796 if [[ $? != 0 ]]; then
6797 failed=$(($failed + 1))
6800 [ "$failed" = 0 ] || error "$failed files not allocated in $POOL"
6802 run_test 200f "Create files in a pool ==================================="
6805 test_pools || return 0
6807 TGT=$($LCTL get_param -n lov.$FSNAME-clilov-*.pools.$POOL | tr '\n' ' ')
6808 res=$($LFS df --pool $FSNAME.$POOL | awk '{print $1}' | grep "$FSNAME-OST" | tr '\n' ' ')
6809 [ "$res" = "$TGT" ] || error "Pools OSTs '$TGT' is not '$res' that lfs df reports"
6811 run_test 200g "lfs df a pool ============================================"
6813 test_200h() { # b=24039
6814 test_pools || return 0
6815 mkdir -p $POOL_DIR || error "unable to create $POOL_DIR"
6817 local file="/..$POOL_DIR/$tfile-1"
6818 $SETSTRIPE -p $POOL $file || error "unable to create $file"
6821 $SETSTRIPE -p $POOL $tfile-2 || \
6822 error "unable to create $tfile-2 in $POOL_DIR"
6824 run_test 200h "Create files in a pool with relative pathname ============"
6827 test_pools || return 0
6829 TGT=$($LCTL get_param -n lov.$FSNAME-*.pools.$POOL | head -1)
6830 do_facet mgs $LCTL pool_remove $FSNAME.$POOL $TGT
6831 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL | grep $TGT" "" ||
6832 error "$TGT not removed from $FSNAME.$POOL"
6834 run_test 201a "Remove a target from a pool ============================="
6837 test_pools || return 0
6839 for TGT in $($LCTL get_param -n lov.$FSNAME-*.pools.$POOL | sort -u)
6841 do_facet mgs $LCTL pool_remove $FSNAME.$POOL $TGT
6843 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL" "" ||
6844 error "Pool $FSNAME.$POOL cannot be drained"
6845 # striping on an empty/nonexistant pool should fall back to "pool of everything"
6846 touch ${POOL_DIR}/$tfile || error "failed to use fallback striping for empty pool"
6847 # setstripe on an empty pool should fail
6848 $SETSTRIPE -p $POOL ${POOL_FILE}/$tfile 2>/dev/null && \
6849 error "expected failure when creating file with empty pool"
6852 run_test 201b "Remove all targets from a pool =========================="
6855 test_pools || return 0
6857 do_facet mgs $LCTL pool_destroy $FSNAME.$POOL
6860 # striping on an empty/nonexistant pool should fall back to "pool of everything"
6861 touch ${POOL_DIR}/$tfile || error "failed to use fallback striping for missing pool"
6862 # setstripe on an empty pool should fail
6863 $SETSTRIPE -p $POOL ${POOL_FILE}/$tfile 2>/dev/null && \
6864 error "expected failure when creating file with missing pool"
6866 # get param should return err once pool is gone
6867 if wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null ||
6868 echo foo" "foo"; then
6869 remove_pool_from_list $FSNAME.$POOL
6872 error "Pool $FSNAME.$POOL is not destroyed"
6874 run_test 201c "Remove a pool ============================================"
6876 cleanup_pools $FSNAME
6879 if [ "$NETTYPE" = "o2ib" ]; then
6880 skip "unaligned direct I/O is not supported by o2iblnd"
6883 $LFS setstripe -c 2 -s 1048576 $DIR/$tfile
6884 multiop $DIR/$tfile oO_WRONLY:O_APPEND:O_DIRECT:b1048548b130c || \
6885 error "direct write failed"
6886 multiop $DIR/${tfile}2 oO_WRONLY:O_CREAT:w1048548w130c || \
6887 error "cached write failed"
6888 cmp $DIR/$tfile $DIR/${tfile}2 || error "cmp failed"
6889 rm -f $DIR/${tfile}2
6891 run_test 202 "O_APPEND+O_DIRECT multistripe write ========================"
6894 local lustre_version=$(get_lustre_version mds)
6895 if [[ $lustre_version != 1.8* ]]; then
6896 skip bug23766 mds running $lustre_version
6900 local ATIME=`do_facet mds lctl get_param -n mds.*.atime_diff`
6901 echo "atime should be updated on the MDS when closing file" > $DIR/$tfile
6903 # reads should update atime on the client and close should update it on the MDS
6904 multiop_bg_pause $DIR/$tfile o_r20c || return 1
6909 kill -USR1 $MULTIPID || return 2
6910 echo "starting reads"
6912 cancel_lru_locks osc
6913 cancel_lru_locks mdc
6914 time2=`stat -c "%X" $DIR/$tfile`
6915 log "new atime is $time2"
6916 [ "$time2" -ge "$time1" ] || error "atime was not updated"
6918 run_test 203 " atime should be updated on the MDS when closing file ===="
6922 # tests that do cleanup/setup should be run at the end
6927 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
6928 $LCTL set_param fail_loc=0x903
6929 # cancel_lru_locks mgc - does not work due to lctl set_param syntax
6930 for ls in /proc/fs/lustre/ldlm/namespaces/MGC*/lru_size; do
6933 FAIL_ON_ERROR=true cleanup
6934 FAIL_ON_ERROR=true setup
6936 run_test 900 "umount should not race with any mgc requeue thread"
6938 complete $(basename $0) $SECONDS
6939 check_and_cleanup_lustre
6940 if [ "$I_MOUNTED" != "yes" ]; then
6941 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true