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 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
3803 param=`echo ${VALUE[0]} | cut -d "=" -f1`
3804 algo=`lctl get_param -n $param | sed 's/.*\[\(.*\)\].*/\1/g'`
3805 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
3807 remount_client $MOUNT
3809 run_test 77j "client only supporting ADLER32 ===================="
3811 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
3815 test_78() { # bug 10901
3816 remote_ost || { skip_env "local OST" && return; }
3818 cancel_lru_locks osc
3820 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
3821 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
3822 # directio allocates the buffer twice, one for writes and another
3823 # one for reads, so that it can check the data consistency
3824 F78SIZE=$((F78SIZE / 2))
3825 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
3826 echo "MemTotal: $MEMTOTAL"
3827 # reserve 256MB of memory for the kernel and other running processes,
3828 # and then take 1/2 of the remaining memory for the read/write buffers.
3829 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
3830 echo "Mem to use for directio: $MEMTOTAL"
3831 [ $F78SIZE -gt $MEMTOTAL ] && F78SIZE=$MEMTOTAL
3832 [ $F78SIZE -gt 512 ] && F78SIZE=512
3833 [ $F78SIZE -gt $((MAXFREE / 1024)) ] && F78SIZE=$((MAXFREE / 1024))
3834 SMALLESTOST=`lfs df $DIR |grep OST | awk '{print $4}' |sort -n |head -1`
3835 echo "Smallest OST: $SMALLESTOST"
3836 [ $SMALLESTOST -lt 10240 ] && \
3837 skip "too small OSTSIZE, useless to run large O_DIRECT test" && return 0
3839 [ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 5)) ] && \
3840 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 5))
3841 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
3842 echo "File size: $F78SIZE"
3843 $SETSTRIPE $DIR/$tfile -c -1 || error "setstripe failed"
3844 for i in `seq 1 $NSEQ`
3846 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
3847 echo directIO rdwr round $i of $NSEQ
3848 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
3853 run_test 78 "handle large O_DIRECT writes correctly ============"
3855 test_79() { # bug 12743
3856 wait_delete_completed
3858 BKTOTAL=$(calc_osc_kbytes kbytestotal)
3859 BKFREE=$(calc_osc_kbytes kbytesfree)
3860 BKAVAIL=$(calc_osc_kbytes kbytesavail)
3861 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
3862 DFTOTAL=`echo $STRING | cut -d, -f1`
3863 DFUSED=`echo $STRING | cut -d, -f2`
3864 DFAVAIL=`echo $STRING | cut -d, -f3`
3865 DFFREE=$(($DFTOTAL - $DFUSED))
3867 ALLOWANCE=$((64 * $OSTCOUNT))
3869 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
3870 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
3871 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
3873 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
3874 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
3875 error "df free($DFFREE) mismatch OST free($BKFREE)"
3877 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
3878 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
3879 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
3882 run_test 79 "df report consistency check ======================="
3884 test_80() { # bug 10718
3885 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
3887 local BEFORE=`date +%s`
3888 cancel_lru_locks osc
3889 local AFTER=`date +%s`
3890 local DIFF=$((AFTER-BEFORE))
3891 if [ $DIFF -gt 1 ] ; then
3892 error "elapsed for 1M@1T = $DIFF"
3896 run_test 80 "Page eviction is equally fast at high offsets too ===="
3899 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
3900 mkdir -p $DIR/d99cvsroot || error "mkdir $DIR/d99cvsroot failed"
3901 chown $RUNAS_ID $DIR/d99cvsroot || error "chown $DIR/d99cvsroot failed"
3902 local oldPWD=$PWD # bug 13584, use $TMP as working dir
3905 $RUNAS cvs -d $DIR/d99cvsroot init || error "cvs init failed"
3908 run_test 99a "cvs init ========================================="
3911 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
3912 [ ! -d $DIR/d99cvsroot ] && test_99a
3913 $RUNAS [ ! -w /tmp ] && skip "/tmp has wrong w permission -- skipping" && return
3914 cd /etc/init.d || error "cd /etc/init.d failed"
3915 # some versions of cvs import exit(1) when asked to import links or
3916 # files they can't read. ignore those files.
3917 TOIGNORE=$(find . -type l -printf '-I %f\n' -o \
3918 ! -perm +4 -printf '-I %f\n')
3919 $RUNAS cvs -d $DIR/d99cvsroot import -m "nomesg" $TOIGNORE \
3920 d99reposname vtag rtag > /dev/null || error "cvs import failed"
3922 run_test 99b "cvs import ======================================="
3925 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
3926 [ ! -d $DIR/d99cvsroot ] && test_99b
3927 cd $DIR || error "cd $DIR failed"
3928 mkdir -p $DIR/d99reposname || error "mkdir $DIR/d99reposname failed"
3929 chown $RUNAS_ID $DIR/d99reposname || \
3930 error "chown $DIR/d99reposname failed"
3931 $RUNAS cvs -d $DIR/d99cvsroot co d99reposname > /dev/null || \
3932 error "cvs co d99reposname failed"
3934 run_test 99c "cvs checkout ====================================="
3937 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
3938 [ ! -d $DIR/d99cvsroot ] && test_99c
3939 cd $DIR/d99reposname
3941 $RUNAS cvs add -m 'addmsg' foo99
3943 run_test 99d "cvs add =========================================="
3946 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
3947 [ ! -d $DIR/d99cvsroot ] && test_99c
3948 cd $DIR/d99reposname
3951 run_test 99e "cvs update ======================================="
3954 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
3955 [ ! -d $DIR/d99cvsroot ] && test_99d
3956 cd $DIR/d99reposname
3957 $RUNAS cvs commit -m 'nomsg' foo99
3959 run_test 99f "cvs commit ======================================="
3962 [ "$NETTYPE" = tcp ] || \
3963 { skip "TCP secure port test, not useful for NETTYPE=$NETTYPE" && \
3966 remote_ost_nodsh && skip "remote OST with nodsh" && return
3967 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3969 { skip "useless for local single node setup" && return; }
3971 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
3972 [ "$PROT" != "tcp" ] && continue
3973 RPORT=$(echo $REMOTE | cut -d: -f2)
3974 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
3977 LPORT=`echo $LOCAL | cut -d: -f2`
3978 if [ $LPORT -ge 1024 ]; then
3979 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
3981 error_exit "local: $LPORT > 1024, remote: $RPORT"
3984 [ "$rc" = 0 ] || error_exit "privileged port not found" )
3986 run_test 100 "check local port using privileged port ==========="
3988 function get_named_value()
3997 echo $line | sed "s/^$tag//"
4004 export CACHE_MAX=`lctl get_param -n llite/*/max_cached_mb | head -n 1`
4006 lctl set_param -n llite.*.max_cached_mb $CACHE_MAX
4014 [ "$CPU" = "UML" ] && nreads=1000
4015 local cache_limit=32
4017 lctl set_param -n osc.*.rpc_stats 0
4018 trap cleanup_101 EXIT
4020 lctl set_param -n llite.*.read_ahead_stats 0
4021 lctl set_param -n llite.*.max_cached_mb $cache_limit
4024 # randomly read 10000 of 64K chunks from file 3x 32MB in size
4026 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
4027 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
4030 for s in `lctl get_param -n llite.*.read_ahead_stats | \
4031 get_named_value 'read but discarded' | cut -d" " -f1`; do
4032 discard=$(($discard + $s))
4036 if [ $(($discard * 10)) -gt $nreads ] ;then
4037 lctl get_param osc.*.rpc_stats
4038 lctl get_param llite.*.read_ahead_stats
4039 error "too many ($discard) discarded pages"
4041 rm -f $DIR/$tfile || true
4043 run_test 101 "check read-ahead for random reads ================"
4045 export SETUP_TEST101b=no
4047 [ "$SETUP_TEST101b" = "yes" ] && return
4050 STRIPE_COUNT=$OSTCOUNT
4053 trap cleanup_101 EXIT
4054 # prepare the read-ahead file
4055 $SETSTRIPE $DIR/$tfile -s $STRIPE_SIZE -i $STRIPE_OFFSET -c $OSTCOUNT
4057 dd if=/dev/zero of=$DIR/$tfile bs=1024k count=100 2> /dev/null
4063 rm -rf $DIR/$tdir $DIR/$tfile
4068 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
4073 local STRIPE_SIZE=1048576
4074 local RA_INC=1048576
4075 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
4076 local FILE_LENGTH=$((64*100))
4077 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
4078 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
4079 DISCARD=`$LCTL get_param -n llite.*.read_ahead_stats | \
4080 get_named_value 'read but discarded' | \
4081 cut -d" " -f1 | calc_total`
4083 if [ $DISCARD -gt $discard_limit ]; then
4084 lctl get_param llite.*.read_ahead_stats
4085 error "Too many ($DISCARD) discarded pages (size ${READ_SIZE})"
4087 echo "Read-ahead success for size ${READ_SIZE}"
4092 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs for stride-read" && return
4093 local STRIPE_SIZE=1048576
4094 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
4095 local FILE_LENGTH=$((STRIPE_SIZE*100))
4096 local ITERATION=$((FILE_LENGTH/STRIDE_SIZE))
4097 # prepare the read-ahead file
4099 cancel_lru_locks osc
4100 for BIDX in 2 4 8 16 32 64 128 256; do
4101 local BSIZE=$((BIDX*4096))
4102 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
4103 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
4104 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
4105 $LCTL set_param -n llite.*.read_ahead_stats 0
4106 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
4107 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
4108 cancel_lru_locks osc
4109 ra_check_101b $BSIZE
4113 run_test 101b "check stride-io mode read-ahead ================="
4116 local STRIPE_SIZE=1048576
4117 local FILE_LENGTH=$((STRIPE_SIZE*100))
4122 cancel_lru_locks osc
4123 $LCTL set_param osc.*.rpc_stats 0
4124 $READS -f $DIR/$tfile -s$FILE_LENGTH -b65536 -n$nreads -t 180
4125 for OSC in `$LCTL get_param -N osc.*`
4127 if [ "$OSC" == "osc.num_refs" ]; then
4130 lines=`$LCTL get_param -n ${OSC}.rpc_stats | wc | awk '{print $1}'`
4131 if [ $lines -le 20 ]; then
4135 rpc4k=$($LCTL get_param -n $OSC | awk '$1 == "1:" { print $2; exit; }')
4136 rpc8k=$($LCTL get_param -n $OSC | awk '$1 == "2:" { print $2; exit; }')
4137 rpc16k=$($LCTL get_param -n $OSC | awk '$1 == "4:" { print $2; exit; }')
4138 rpc32k=$($LCTL get_param -n $OSC | awk '$1 == "8:" { print $2; exit; }')
4140 [ $rpc4k != 0 ] && error "Small 4k read IO ${rpc4k}!"
4141 [ $rpc8k != 0 ] && error "Small 8k read IO ${rpc8k}!"
4142 [ $rpc16k != 0 ] && error "Small 16k read IO ${rpc16k}!"
4143 [ $rpc32k != 0 ] && error "Small 32k read IO ${rpc32k}!"
4145 echo "Small rpc check passed!"
4146 rpc64k=$($LCTL get_param -n $OSC | awk '$1 == "16:" { print $2; exit; }')
4147 rpc128k=$($LCTL get_param -n $OSC | awk '$1 == "32:" { print $2; exit; }')
4148 rpc256k=$($LCTL get_param -n $OSC | awk '$1 == "64:" { print $2; exit; }')
4149 rpc512k=$($LCTL get_param -n $OSC | awk '$1 == "128:" { print $2; exit; }')
4150 rpc1024k=$($LCTL get_param -n $OSC | awk '$1 == "256:" { print $2; exit; }')
4152 [ $rpc64k == 0 ] && error "No 64k readahead IO ${rpc64k}"
4153 [ $rpc128k == 0 ] && error "No 128k readahead IO ${rpc128k}"
4154 [ $rpc256k == 0 ] && error "No 256k readahead IO ${rpc256k}"
4155 [ $rpc512k == 0 ] && error "No 512k readahead IO ${rpc256k}"
4156 [ $rpc1024k == 0 ] && error "No 1024k readahead IO ${rpc1024k}"
4157 echo "Big rpc check passed!"
4162 run_test 101c "check stripe_size aligned read-ahead ================="
4165 lctl get_param -n llite.*.max_read_ahead_mb | head -n 1
4166 lctl set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
4170 local file=$DIR/$tfile
4171 local size=${FILESIZE_101c:-500}
4172 local ra_MB=${READAHEAD_MB:-40}
4174 local space=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
4175 [ $space -gt $((size / 1024)) ] ||
4176 { skip "Need free space ${size}M, have $space" && return; }
4178 echo Creating ${size}M test file $file
4179 dd if=/dev/zero of=$file bs=1M count=$size
4180 echo Cancel LRU locks on lustre client to flush the client cache
4181 cancel_lru_locks osc
4183 echo Disable read-ahead
4184 local old_READAHEAD=$(set_read_ahead 0)
4186 echo Reading the test file $file with read-ahead disabled
4187 time_ra_OFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$size")
4189 echo Cancel LRU locks on lustre client to flush the client cache
4190 cancel_lru_locks osc
4191 echo Enable read-ahead with ${ra_MB}MB
4192 set_read_ahead $ra_MB
4194 echo Reading the test file $file with read-ahead enabled
4195 time_ra_ON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$size")
4197 echo read-ahead disabled time read $time_ra_OFF
4198 echo read-ahead enabled time read $time_ra_ON
4200 set_read_ahead $old_READAHEAD
4203 [ $time_ra_ON -lt $time_ra_OFF ] ||
4204 error "read-ahead enabled time read (${time_ra_ON}s) is more than
4205 read-ahead disabled time read (${time_ra_OFF}s) filesize ${size}M"
4207 run_test 101d "file read with and without read-ahead enabled ================="
4209 export SETUP_TEST102=no
4211 [ "$SETUP_TEST102" = "yes" ] && return
4213 chown $RUNAS_ID $DIR/$tdir
4216 STRIPE_COUNT=$OSTCOUNT
4217 [ $OSTCOUNT -gt 4 ] && STRIPE_COUNT=4
4219 trap cleanup_test102 EXIT
4221 $1 $SETSTRIPE $tdir -s $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT
4225 for count in `seq 1 $STRIPE_COUNT`
4227 for offset in `seq 0 $[$STRIPE_COUNT - 1]`
4229 local stripe_size=`expr $STRIPE_SIZE \* $num`
4230 local file=file"$num-$offset-$count"
4231 $1 $SETSTRIPE $file -s $stripe_size -i $offset -c $count
4237 $1 $TAR cf $TMP/f102.tar $tdir --xattrs
4243 [ "$SETUP_TEST102" = "yes" ] || return 0
4249 local testfile=$DIR/xattr_testfile
4254 [ "$UID" != 0 ] && skip_env "must run as root" && return
4255 [ -z "`lctl get_param -n mdc.*.connect_flags | grep xattr`" ] &&
4256 skip_env "must have user_xattr" && return
4257 [ -z "$(which setfattr 2>/dev/null)" ] && skip_env "could not find setfattr" && return
4259 echo "set/get xattr..."
4260 setfattr -n trusted.name1 -v value1 $testfile || error
4261 [ "`getfattr -n trusted.name1 $testfile 2> /dev/null | \
4262 grep "trusted.name1"`" == "trusted.name1=\"value1\"" ] || error
4264 setfattr -n user.author1 -v author1 $testfile || error
4265 [ "`getfattr -n user.author1 $testfile 2> /dev/null | \
4266 grep "user.author1"`" == "user.author1=\"author1\"" ] || error
4269 setfattr -n trusted.name2 -v value2 $testfile || error
4270 setfattr -n trusted.name3 -v value3 $testfile || error
4271 [ `getfattr -d -m "^trusted" $testfile 2> /dev/null | \
4272 grep "trusted.name" | wc -l` -eq 3 ] || error
4275 setfattr -n user.author2 -v author2 $testfile || error
4276 setfattr -n user.author3 -v author3 $testfile || error
4277 [ `getfattr -d -m "^user" $testfile 2> /dev/null | \
4278 grep "user" | wc -l` -eq 3 ] || error
4280 echo "remove xattr..."
4281 setfattr -x trusted.name1 $testfile || error
4282 getfattr -d -m trusted $testfile 2> /dev/null | \
4283 grep "trusted.name1" && error || true
4285 setfattr -x user.author1 $testfile || error
4286 getfattr -d -m user $testfile 2> /dev/null | \
4287 grep "user.author1" && error || true
4289 # b10667: setting lustre special xattr be silently discarded
4290 echo "set lustre special xattr ..."
4291 setfattr -n "trusted.lov" -v "invalid value" $testfile || error
4295 run_test 102a "user xattr test =================================="
4298 # b10930: get/set/list trusted.lov xattr
4299 echo "get/set/list trusted.lov xattr ..."
4300 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
4301 local testfile=$DIR/$tfile
4302 $SETSTRIPE -s 65536 -i 1 -c 2 $testfile || error "setstripe failed"
4303 getfattr -d -m "^trusted" $testfile 2> /dev/null | \
4304 grep "trusted.lov" || error "can't get trusted.lov from $testfile"
4306 local testfile2=${testfile}2
4307 local value=`getfattr -n trusted.lov $testfile 2> /dev/null | \
4308 grep "trusted.lov" |sed -e 's/[^=]\+=//'`
4311 setfattr -n trusted.lov -v $value $testfile2
4312 local tmp_file=${testfile}3
4313 $GETSTRIPE -v $testfile2 > $tmp_file
4314 local stripe_size=`grep "size" $tmp_file| awk '{print $2}'`
4315 local stripe_count=`grep "count" $tmp_file| awk '{print $2}'`
4316 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
4317 [ $stripe_count -eq 2 ] || error "stripe count $stripe_count != 2"
4319 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
4322 # b10930: get/set/list lustre.lov xattr
4323 echo "get/set/list lustre.lov xattr ..."
4324 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
4326 chown $RUNAS_ID $DIR/$tdir
4327 local testfile=$DIR/$tdir/$tfile
4328 $RUNAS $SETSTRIPE -s 65536 -i 1 -c 2 $testfile||error "setstripe failed"
4329 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
4330 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
4332 local testfile2=${testfile}2
4333 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
4334 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
4336 $RUNAS $MCREATE $testfile2
4337 $RUNAS setfattr -n lustre.lov -v $value $testfile2
4338 local tmp_file=${testfile}3
4339 $RUNAS $GETSTRIPE -v $testfile2 > $tmp_file
4340 local stripe_size=`grep "size" $tmp_file| awk '{print $2}'`
4341 local stripe_count=`grep "count" $tmp_file| awk '{print $2}'`
4342 [ "$stripe_size" -eq 65536 ] || error "stripe size $stripe_size != 65536"
4343 [ "$stripe_count" -eq 2 ] || error "stripe count $stripe_count != 2"
4345 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
4347 compare_stripe_info1() {
4348 local stripe_index_all_zero=1
4352 for count in `seq 1 $STRIPE_COUNT`
4354 for offset in `seq 0 $[$STRIPE_COUNT - 1]`
4356 local size=`expr $STRIPE_SIZE \* $num`
4357 local file=file"$num-$offset-$count"
4358 get_stripe_info client $PWD/$file "$1"
4359 if [ $stripe_size -ne $size ]; then
4360 error "$file: different stripe size $stripe_size, expected $size" && return
4362 if [ $stripe_count -ne $count ]; then
4363 error "$file: different stripe count $stripe_count, expected $count" && return
4365 if [ $stripe_index -ne 0 ]; then
4366 stripe_index_all_zero=0
4371 [ $stripe_index_all_zero -eq 1 ] && error "all files are being extracted starting from OST index 0"
4376 [ -n "$(which tar 2>/dev/null)" ] && strings $(which tar) | grep -q lustre && echo tar
4380 # b10930: tar test for trusted.lov xattr
4381 TAR=$(find_lustre_tar)
4382 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
4383 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
4386 $TAR xf $TMP/f102.tar -C $DIR/d102d --xattrs
4388 compare_stripe_info1
4390 run_test 102d "tar restore stripe info from tarfile,not keep osts ==========="
4393 # b10930: tar test for trusted.lov xattr
4394 TAR=$(find_lustre_tar)
4395 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
4396 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
4400 $TAR cf - --xattrs $tdir | $TAR xf - --xattrs -C $DIR/d102f
4402 compare_stripe_info1
4404 run_test 102f "tar copy files, not keep osts ==========="
4406 test_102h() { # bug 15777
4407 [ -z $(lctl get_param -n mdc.*.connect_flags | grep xattr) ] &&
4408 skip "must have user_xattr" && return
4409 [ -z "$(which setfattr 2>/dev/null)" ] &&
4410 skip_env "could not find setfattr" && return
4415 VALUE=datadatadatadatadatadatadatadata
4416 while [ $(echo $VALUE | wc -c) -lt $XSIZE ]; do
4417 VALUE="$VALUE$VALUE"
4419 log "save $XBIG on $DIR/$tfile"
4420 setfattr -n $XBIG -v "$VALUE" $DIR/$tfile ||
4421 error "saving $XBIG on $DIR/$tfile failed"
4422 ORIG=$(getfattr -n $XBIG $DIR/$tfile 2> /dev/null | grep $XBIG)
4423 OSIZE=$(echo $ORIG | wc -c)
4424 [ $OSIZE -lt $XSIZE ] && error "set $XBIG too small ($OSIZE < $XSIZE)"
4427 log "save $XSML on $DIR/$tfile"
4428 setfattr -n $XSML -v val $DIR/$tfile ||
4429 error "saving $XSML on $DIR/$tfile failed"
4430 NEW=$(getfattr -n $XBIG $DIR/$tfile 2> /dev/null | grep $XBIG)
4431 if [ "$NEW" != "$ORIG" ]; then
4434 error "$XBIG different after saving $XSML"
4437 log "grow $XSML on $DIR/$tfile"
4438 setfattr -n $XSML -v "$VALUE" $DIR/$tfile ||
4439 error "growing $XSML on $DIR/$tfile failed"
4440 NEW=$(getfattr -n $XBIG $DIR/$tfile 2> /dev/null | grep $XBIG)
4441 if [ "$NEW" != "$ORIG" ]; then
4444 error "$XBIG different after growing $XSML"
4446 log "$XBIG still valid after growing $XSML"
4448 run_test 102h "grow xattr from inside inode to external block"
4450 test_102i() { # bug 17038
4452 ln -s $DIR/$tfile $DIR/${tfile}link
4453 getfattr -n trusted.lov $DIR/$tfile || error "lgetxattr on $DIR/$tfile failed"
4454 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"
4455 rm -f $DIR/$tfile $DIR/${tfile}link
4457 run_test 102i "lgetxattr test on symbolic link ============"
4460 TAR=$(find_lustre_tar)
4461 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
4462 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
4463 setup_test102 "$RUNAS"
4465 chown $RUNAS_ID $DIR/d102j
4466 $RUNAS $TAR xf $TMP/f102.tar -C $DIR/d102j --xattrs
4468 compare_stripe_info1 "$RUNAS"
4470 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
4474 # b22187 just check that does not crash for regular file.
4475 setfattr -n trusted.lov $DIR/$tfile
4476 # b22187 'setfattr -n trusted.lov' should work as remove LOV EA for directories
4477 local test_kdir=$DIR/d102k
4479 local default_size=`$GETSTRIPE -s $test_kdir`
4480 local default_count=`$GETSTRIPE -c $test_kdir`
4481 local default_offset=`$GETSTRIPE -o $test_kdir`
4482 $SETSTRIPE -s 65536 -i 1 -c $OSTCOUNT $test_kdir || error 'dir setstripe failed'
4483 setfattr -n trusted.lov $test_kdir
4484 local stripe_size=`$GETSTRIPE -s $test_kdir`
4485 local stripe_count=`$GETSTRIPE -c $test_kdir`
4486 local stripe_offset=`$GETSTRIPE -o $test_kdir`
4487 [ $stripe_size -eq $default_size ] || error "stripe size $stripe_size != $default_size"
4488 [ $stripe_count -eq $default_count ] || error "stripe count $stripe_count != $default_count"
4489 [ $stripe_offset -eq $default_offset ] || error "stripe offset $stripe_offset != $default_offset"
4490 rm -rf $DIR/$tfile $test_kdir
4492 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
4498 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
4503 [ "$UID" != 0 ] && skip_env "must run as root" && return
4504 [ -z "$(lctl get_param mdc.*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
4505 [ -z "$(which setfacl 2>/dev/null)" ] && skip_env "could not find setfacl" && return
4511 echo "performing cp ..."
4512 run_acl_subtest cp || error
4513 echo "performing getfacl-noacl..."
4514 run_acl_subtest getfacl-noacl > /dev/null || error "getfacl-noacl test failed"
4515 echo "performing misc..."
4516 run_acl_subtest misc > /dev/null || error "misc test failed"
4517 # XXX add back permission test when we support supplementary groups.
4518 # echo "performing permissions..."
4519 # run_acl_subtest permissions || error
4520 echo "performing setfacl..."
4521 run_acl_subtest setfacl > /dev/null || error "setfacl test failed"
4523 # inheritance test got from HP
4524 echo "performing inheritance..."
4525 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
4526 chmod +x make-tree || error "chmod +x failed"
4527 run_acl_subtest inheritance > /dev/null || error "inheritance test failed"
4533 run_test 103 "acl test ========================================="
4537 lfs df || error "lfs df failed"
4538 lfs df -ih || error "lfs df -ih failed"
4539 lfs df -h $DIR || error "lfs df -h $DIR failed"
4540 lfs df -i $DIR || error "lfs df -i $DIR failed"
4541 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
4542 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
4544 OSC=`lctl get_param -n devices | awk '/-osc-|OSC.*MNT/ {print $4}' | head -n 1`
4545 lctl --device %$OSC deactivate
4546 lfs df || error "lfs df with deactivated OSC failed"
4547 lctl --device %$OSC recover
4548 lfs df || error "lfs df with reactivated OSC failed"
4550 run_test 104a "lfs df [-ih] [path] test ========================="
4553 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4555 denied_cnt=$((`$RUNAS $LFS check servers 2>&1 | grep "Permission denied" | wc -l`))
4556 if [ $denied_cnt -ne 0 ];
4558 error "lfs check servers test failed"
4561 run_test 104b "$RUNAS lfs check servers test ===================="
4564 # doesn't work on 2.4 kernels
4566 if [ -n "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ];
4568 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
4570 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
4573 run_test 105a "flock when mounted without -o flock test ========"
4577 if [ -n "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ];
4579 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
4581 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
4584 run_test 105b "fcntl when mounted without -o flock test ========"
4588 if [ -n "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ];
4590 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
4592 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
4595 run_test 105c "lockf when mounted without -o flock test ========"
4597 test_105d() { # bug 15924
4599 [ -z "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ] && \
4600 skip "mount w/o flock enabled" && return
4601 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
4602 $LCTL set_param fail_loc=0x80000315
4603 flocks_test 2 $DIR/$tdir
4605 run_test 105d "flock race (should not freeze) ========"
4607 test_106() { #bug 10921
4609 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
4610 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
4612 run_test 106 "attempt exec of dir followed by chown of that dir"
4621 local save_pattern=$(sysctl -n kernel.core_pattern)
4622 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
4623 sysctl -w kernel.core_pattern=$file
4624 sysctl -w kernel.core_uses_pid=0
4632 kill -s 11 $SLEEPPID
4634 if [ -e $file ]; then
4635 size=`stat -c%s $file`
4636 [ $size -eq 0 ] && error "Zero length core file $file"
4638 error "Fail to create core file $file"
4641 sysctl -w kernel.core_pattern=$save_pattern
4642 sysctl -w kernel.core_uses_pid=$save_uses_pid
4645 run_test 107 "Coredump on SIG"
4648 OSTIO_pre=$(ps -e|grep ll_ost_io|awk '{print $4}'|sort -n|tail -1|\
4650 [ -z "$OSTIO_pre" ] && skip "no OSS threads" && \
4652 echo "Starting with $OSTIO_pre threads"
4655 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
4656 [ $NUMFREE -lt $NUMTEST ] && NUMTEST=$(($NUMFREE - 1000))
4657 echo "$NUMTEST creates/unlinks"
4659 createmany -o $DIR/$tdir/$tfile $NUMTEST
4660 unlinkmany $DIR/$tdir/$tfile $NUMTEST
4662 OSTIO_post=$(ps -e|grep ll_ost_io|awk '{print $4}'|sort -n|tail -1|\
4665 # don't return an error
4666 [ $OSTIO_post -eq $OSTIO_pre ] && echo \
4667 "WARNING: No new ll_ost_io threads were created ($OSTIO_pre)" &&\
4668 echo "This may be fine, depending on what ran before this test" &&\
4669 echo "and how fast this system is." && return
4671 echo "Started with $OSTIO_pre threads, ended with $OSTIO_post"
4673 run_test 115 "verify dynamic thread creation===================="
4676 wait_delete_completed
4677 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC][-_]*.kbytesavail))
4678 echo OST kbytes available: ${AVAIL[@]}
4679 MAXI=0; MAXV=${AVAIL[0]}
4680 MINI=0; MINV=${AVAIL[0]}
4681 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
4682 #echo OST $i: ${AVAIL[i]}kb
4683 if [ ${AVAIL[i]} -gt $MAXV ]; then
4684 MAXV=${AVAIL[i]}; MAXI=$i
4686 if [ ${AVAIL[i]} -lt $MINV ]; then
4687 MINV=${AVAIL[i]}; MINI=$i
4690 echo Min free space: OST $MINI: $MINV
4691 echo Max free space: OST $MAXI: $MAXV
4695 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
4697 echo -n "Free space priority "
4698 lctl get_param -n lov.*.qos_prio_free
4701 [ $MINV -gt 960000 ] && skip "too much free space in OST$MINI" &&\
4704 # generate uneven OSTs
4705 mkdir -p $DIR/$tdir/OST${MINI}
4708 echo "Filling 25% remaining space in OST${MINI} with ${FILL}Kb"
4709 $SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI}||error "setstripe failed"
4711 while [ $FILL -gt 0 ]; do
4712 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i bs=2M count=1 2>/dev/null
4713 FILL=$(($FILL - 2048))
4722 DIFF=$(($MAXV - $MINV))
4723 DIFF2=$(($DIFF * 100 / $MINV))
4724 echo -n "diff=${DIFF}=${DIFF2}% must be > 20% for QOS mode..."
4725 if [ $DIFF2 -gt 20 ]; then
4728 echo "failed - QOS mode won't be used"
4729 error_ignore "QOS imbalance criteria not met"
4733 MINI1=$MINI; MINV1=$MINV
4734 MAXI1=$MAXI; MAXV1=$MAXV
4736 # now fill using QOS
4737 echo writing a bunch of files to QOS-assigned OSTs
4738 $SETSTRIPE $DIR/$tdir -c 1
4740 while [ $FILL -gt 0 ]; do
4741 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1024 count=200 2>/dev/null
4742 FILL=$(($FILL - 200))
4746 echo "wrote $i 200k files"
4750 echo "Note: free space may not be updated, so measurements might be off"
4752 DIFF2=$(($MAXV - $MINV))
4753 echo "free space delta: orig $DIFF final $DIFF2"
4754 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
4755 DIFF=$(($MINV1 - ${AVAIL[$MINI1]}))
4756 echo "Wrote $DIFF to smaller OST $MINI1"
4757 DIFF2=$(($MAXV1 - ${AVAIL[$MAXI1]}))
4758 echo "Wrote $DIFF2 to larger OST $MAXI1"
4759 [ $DIFF -gt 0 ] && echo "Wrote $(($DIFF2 * 100 / $DIFF - 100))% more data to larger OST $MAXI1"
4761 # Figure out which files were written where
4762 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd | awk '/'$MINI1': / {print $2; exit}')
4764 MINC=$($GETSTRIPE --obd $UUID $DIR/$tdir | wc -l)
4765 echo "$MINC files created on smaller OST $MINI1"
4766 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd | (awk '/'$MAXI1': / {print $2; exit}'))
4767 MAXC=$($GETSTRIPE --obd $UUID $DIR/$tdir | wc -l)
4768 echo "$MAXC files created on larger OST $MAXI1"
4769 [ $MINC -gt 0 ] && echo "Wrote $(($MAXC * 100 / $MINC - 100))% more files to larger OST $MAXI1"
4770 [ $MAXC -gt $MINC ] || error_ignore "stripe QOS didn't balance free space"
4774 run_test 116 "stripe QOS: free space balance ==================="
4776 test_117() # bug 10891
4778 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
4779 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
4780 lctl set_param fail_loc=0x21e
4781 > $DIR/$tfile || error "truncate failed"
4782 lctl set_param fail_loc=0
4783 echo "Truncate succeeded."
4785 run_test 117 "verify fsfilt_extend ============================="
4787 export OLD_RESENDCOUNT=""
4788 set_resend_count () {
4789 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
4790 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -1)
4791 lctl set_param -n $PROC_RESENDCOUNT $1
4792 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
4795 [ "$SLOW" = "no" ] && set_resend_count 4 # for reduce test_118* time (bug 14842)
4797 # Reset async IO behavior after error case
4799 FILE=$DIR/reset_async
4801 # Ensure all OSCs are cleared
4802 $SETSTRIPE -c -1 $FILE
4803 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
4808 test_118a() #bug 11710
4812 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
4813 DIRTY=$(lctl get_param -n "llite.*.dump_page_cache" | grep -c dirty)
4814 WRITEBACK=$(lctl get_param "llite.*.dump_page_cache" | grep -c writeback)
4816 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
4817 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
4821 run_test 118a "verify O_SYNC works =========="
4825 remote_ost_nodsh && skip "remote OST with nodsh" && return
4829 #define OBD_FAIL_OST_ENOENT 0x217
4830 set_nodes_failloc "$(osts_nodes)" 0x217
4831 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
4833 set_nodes_failloc "$(osts_nodes)" 0
4834 DIRTY=$(lctl get_param llite.*.dump_page_cache | grep -c dirty)
4835 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
4837 if [[ $RC -eq 0 ]]; then
4838 error "Must return error due to dropped pages, rc=$RC"
4842 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
4843 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
4847 echo "Dirty pages not leaked on ENOENT"
4849 # Due to the above error the OSC will issue all RPCs syncronously
4850 # until a subsequent RPC completes successfully without error.
4851 multiop $DIR/$tfile Ow4096yc
4856 run_test 118b "Reclaim dirty pages on fatal error =========="
4860 remote_ost_nodsh && skip "remote OST with nodsh" && return
4864 #define OBD_FAIL_OST_EROFS 0x216
4865 set_nodes_failloc "$(osts_nodes)" 0x216
4867 # multiop should block due to fsync until pages are written
4868 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
4872 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
4873 error "Multiop failed to block on fsync, pid=$MULTIPID"
4876 WRITEBACK=$(lctl get_param -n llite/*/dump_page_cache | grep -c writeback)
4877 if [[ $WRITEBACK -eq 0 ]]; then
4878 error "No page in writeback, writeback=$WRITEBACK"
4881 set_nodes_failloc "$(osts_nodes)" 0
4884 if [[ $RC -ne 0 ]]; then
4885 error "Multiop fsync failed, rc=$RC"
4888 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
4889 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
4890 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
4891 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
4895 echo "Dirty pages flushed via fsync on EROFS"
4898 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
4902 remote_ost_nodsh && skip "remote OST with nodsh" && return
4906 #define OBD_FAIL_OST_BRW_PAUSE_BULK
4907 set_nodes_failloc "$(osts_nodes)" 0x214
4908 # multiop should block due to fsync until pages are written
4909 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
4913 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
4914 error "Multiop failed to block on fsync, pid=$MULTIPID"
4917 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
4918 if [[ $WRITEBACK -eq 0 ]]; then
4919 error "No page in writeback, writeback=$WRITEBACK"
4922 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
4923 set_nodes_failloc "$(osts_nodes)" 0
4925 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
4926 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
4927 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
4928 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
4932 echo "Dirty pages gaurenteed flushed via fsync"
4935 run_test 118d "Fsync validation inject a delay of the bulk =========="
4940 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
4941 lctl set_param fail_loc=0x8000040a
4943 # Should simulate EINVAL error which is fatal
4944 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
4946 if [[ $RC -eq 0 ]]; then
4947 error "Must return error due to dropped pages, rc=$RC"
4950 lctl set_param fail_loc=0x0
4952 LOCKED=$(lctl get_param -n "llite.*.dump_page_cache" | grep -c locked)
4953 DIRTY=$(lctl get_param -n "llite.*.dump_page_cache" | grep -c dirty)
4954 WRITEBACK=$(lctl get_param -n "llite.*.dump_page_cache" | grep -c writeback)
4955 if [[ $LOCKED -ne 0 ]]; then
4956 error "Locked pages remain in cache, locked=$LOCKED"
4959 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
4960 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
4964 echo "No pages locked after fsync"
4969 run_test 118f "Simulate unrecoverable OSC side error =========="
4974 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
4975 lctl set_param fail_loc=0x406
4977 # simulate local -ENOMEM
4978 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
4981 lctl set_param fail_loc=0
4982 if [[ $RC -eq 0 ]]; then
4983 error "Must return error due to dropped pages, rc=$RC"
4986 LOCKED=$(lctl get_param -n "llite.*.dump_page_cache" | grep -c locked)
4987 DIRTY=$(lctl get_param -n "llite.*.dump_page_cache" | grep -c dirty)
4988 WRITEBACK=$(lctl get_param -n "llite.*.dump_page_cache" | grep -c writeback)
4989 if [[ $LOCKED -ne 0 ]]; then
4990 error "Locked pages remain in cache, locked=$LOCKED"
4993 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
4994 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
4998 echo "No pages locked after fsync"
5003 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
5006 remote_ost_nodsh && skip "remote OST with nodsh" && return
5010 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
5011 set_nodes_failloc "$(osts_nodes)" 0x20e
5012 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
5013 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
5016 set_nodes_failloc "$(osts_nodes)" 0
5017 if [[ $RC -eq 0 ]]; then
5018 error "Must return error due to dropped pages, rc=$RC"
5021 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
5022 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
5023 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writebac)
5024 if [[ $LOCKED -ne 0 ]]; then
5025 error "Locked pages remain in cache, locked=$LOCKED"
5028 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
5029 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
5033 echo "No pages locked after fsync"
5037 run_test 118h "Verify timeout in handling recoverables errors =========="
5040 remote_ost_nodsh && skip "remote OST with nodsh" && return
5044 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
5045 set_nodes_failloc "$(osts_nodes)" 0x20e
5047 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
5048 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
5051 set_nodes_failloc "$(osts_nodes)" 0
5055 if [[ $RC -ne 0 ]]; then
5056 error "got error, but should be not, rc=$RC"
5059 LOCKED=$(lctl get_param -n "llite.*.dump_page_cache" | grep -c locked)
5060 DIRTY=$(lctl get_param -n "llite.*.dump_page_cache" | grep -c dirty)
5061 WRITEBACK=$(lctl get_param -n "llite.*.dump_page_cache" | grep -c writeback)
5062 if [[ $LOCKED -ne 0 ]]; then
5063 error "Locked pages remain in cache, locked=$LOCKED"
5066 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
5067 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
5071 echo "No pages locked after fsync"
5075 run_test 118i "Fix error before timeout in recoverable error =========="
5078 remote_ost_nodsh && skip "remote OST with nodsh" && return
5082 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
5083 set_nodes_failloc "$(osts_nodes)" 0x220
5085 # return -EIO from OST
5086 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
5088 set_nodes_failloc "$(osts_nodes)" 0x0
5089 if [[ $RC -eq 0 ]]; then
5090 error "Must return error due to dropped pages, rc=$RC"
5093 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
5094 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
5095 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
5096 if [[ $LOCKED -ne 0 ]]; then
5097 error "Locked pages remain in cache, locked=$LOCKED"
5100 # in recoverable error on OST we want resend and stay until it finished
5101 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
5102 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
5106 echo "No pages locked after fsync"
5110 run_test 118j "Simulate unrecoverable OST side error =========="
5114 remote_ost_nodsh && skip "remote OSTs with nodsh" && return
5116 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
5117 set_nodes_failloc "$(osts_nodes)" 0x20e
5120 for ((i=0;i<10;i++)); do
5121 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
5122 error "dd to $DIR/$tdir/$tfile-$i failed" )&
5129 set_nodes_failloc "$(osts_nodes)" 0
5132 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
5134 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
5136 test_119a() # bug 11737
5138 BSIZE=$((512 * 1024))
5139 directio write $DIR/$tfile 0 1 $BSIZE
5140 # We ask to read two blocks, which is more than a file size.
5141 # directio will indicate an error when requested and actual
5142 # sizes aren't equeal (a normal situation in this case) and
5143 # print actual read amount.
5144 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
5145 if [ "$NOB" != "$BSIZE" ]; then
5146 error "read $NOB bytes instead of $BSIZE"
5150 run_test 119a "Short directIO read must return actual read amount"
5152 test_119b() # bug 11737
5154 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
5156 $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
5157 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
5159 multiop $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) || \
5160 error "direct read failed"
5163 run_test 119b "Sparse directIO read must return actual read amount"
5165 test_119c() # bug 13099
5168 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
5169 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
5172 run_test 119c "Testing for direct read hitting hole"
5174 test_119d() # bug 15950
5176 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
5177 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
5179 $SETSTRIPE $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
5180 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
5181 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
5182 lctl set_param fail_loc=0x40d
5183 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
5186 cat $DIR/$tfile > /dev/null &
5187 lctl set_param fail_loc=0
5190 log "the DIO writes have completed, now wait for the reads (should not block very long)"
5192 [ -n "`ps h -p $pid_reads -o comm`" ] && \
5193 error "the read rpcs have not completed in 2s"
5195 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
5197 run_test 119d "The DIO path should try to send a new rpc once one is completed"
5201 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
5202 skip "no early lock cancel on server" && return 0
5203 lru_resize_disable mdc
5204 lru_resize_disable osc
5205 cancel_lru_locks mdc
5206 stat $DIR/$tdir > /dev/null
5207 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
5208 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
5210 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
5211 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
5212 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
5213 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
5214 lru_resize_enable mdc
5215 lru_resize_enable osc
5217 run_test 120a "Early Lock Cancel: mkdir test ==================="
5221 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
5222 skip "no early lock cancel on server" && return 0
5223 lru_resize_disable mdc
5224 lru_resize_disable osc
5225 cancel_lru_locks mdc
5226 stat $DIR/$tdir > /dev/null
5227 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
5228 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
5230 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
5231 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
5232 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
5233 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
5234 lru_resize_enable mdc
5235 lru_resize_enable osc
5237 run_test 120b "Early Lock Cancel: create test =================="
5241 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
5242 skip "no early lock cancel on server" && return 0
5243 lru_resize_disable mdc
5244 lru_resize_disable osc
5245 mkdir -p $DIR/$tdir/d1 $DIR/$tdir/d2
5246 touch $DIR/$tdir/d1/f1
5247 cancel_lru_locks mdc
5248 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
5249 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
5250 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
5251 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
5252 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
5253 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
5254 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
5255 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
5256 lru_resize_enable mdc
5257 lru_resize_enable osc
5259 run_test 120c "Early Lock Cancel: link test ===================="
5263 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
5264 skip "no early lock cancel on server" && return 0
5265 lru_resize_disable mdc
5266 lru_resize_disable osc
5268 cancel_lru_locks mdc
5269 stat $DIR/$tdir > /dev/null
5270 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
5271 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
5272 chmod a+x $DIR/$tdir
5273 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
5274 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
5275 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
5276 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
5277 lru_resize_enable mdc
5278 lru_resize_enable osc
5280 run_test 120d "Early Lock Cancel: setattr test ================="
5284 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
5285 skip "no early lock cancel on server" && return 0
5286 lru_resize_disable mdc
5287 lru_resize_disable osc
5288 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
5289 cancel_lru_locks mdc
5290 cancel_lru_locks osc
5291 dd if=$DIR/$tdir/f1 of=/dev/null
5292 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
5293 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
5294 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
5295 unlink $DIR/$tdir/f1
5296 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
5297 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
5298 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
5299 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
5300 lru_resize_enable mdc
5301 lru_resize_enable osc
5303 run_test 120e "Early Lock Cancel: unlink test =================="
5306 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
5307 skip "no early lock cancel on server" && return 0
5309 lru_resize_disable mdc
5310 lru_resize_disable osc
5311 mkdir -p $DIR/$tdir/d1 $DIR/$tdir/d2
5312 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
5313 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
5314 cancel_lru_locks mdc
5315 cancel_lru_locks osc
5316 dd if=$DIR/$tdir/d1/f1 of=/dev/null
5317 dd if=$DIR/$tdir/d2/f2 of=/dev/null
5318 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
5319 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
5320 blk1=`lctl get_param -n ldlm/services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
5321 mv $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
5322 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
5323 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
5324 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
5325 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
5326 lru_resize_enable mdc
5327 lru_resize_enable osc
5329 run_test 120f "Early Lock Cancel: rename test =================="
5332 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
5333 skip "no early lock cancel on server" && return 0
5334 lru_resize_disable mdc
5335 lru_resize_disable osc
5337 echo create $count files
5339 cancel_lru_locks mdc
5340 cancel_lru_locks osc
5343 can0=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
5344 blk0=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
5345 createmany -o $DIR/$tdir/f $count
5347 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
5348 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
5350 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
5351 echo rm $count files
5354 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
5355 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
5357 echo total: $count removes in $((t2-t1))
5358 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
5360 # wait for commitment of removal
5361 lru_resize_enable mdc
5362 lru_resize_enable osc
5364 run_test 120g "Early Lock Cancel: performance test ============="
5366 test_121() { #bug 10589
5367 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
5368 lctl set_param fail_loc=0x310
5369 cancel_lru_locks osc > /dev/null
5370 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
5371 lctl set_param fail_loc=0
5372 [ "$reads" -eq "$writes" ] || error "read" $reads "blocks, must be" $writes
5374 run_test 121 "read cancel race ================================="
5376 test_122() { #bug 11544
5377 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
5378 lctl set_param fail_loc=0x508
5379 dd if=/dev/zero of=$DIR/$tfile count=1
5381 lctl set_param fail_loc=0
5383 run_test 122 "fail client bulk callback (shouldn't LBUG) ======="
5385 test_123a() { # was test 123, statahead(bug 11401)
5387 local lustre_version=$(get_lustre_version mds)
5388 if [[ $lustre_version != 1.8* ]]; then
5389 skip mds running $lustre_version, statahead is disabled
5394 if [ -z "$(grep "processor.*: 1" /proc/cpuinfo)" ]; then
5395 log "testing on UP system. Performance may be not as good as expected."
5401 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
5402 [ $NUMFREE -gt 100000 ] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
5404 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
5405 createmany -o $DIR/$tdir/$tfile $j $((i - j))
5407 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
5408 lctl set_param -n llite.*.statahead_max 0
5409 lctl get_param llite.*.statahead_max
5410 cancel_lru_locks mdc
5411 cancel_lru_locks osc
5413 time ls -l $DIR/$tdir | wc -l
5415 delta=$((etime - stime))
5416 log "ls $i files without statahead: $delta sec"
5417 lctl set_param llite.*.statahead_max=$max
5419 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
5420 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
5421 cancel_lru_locks mdc
5422 cancel_lru_locks osc
5424 time ls -l $DIR/$tdir | wc -l
5426 delta_sa=$((etime - stime))
5427 log "ls $i files with statahead: $delta_sa sec"
5428 lctl get_param -n llite.*.statahead_stats
5429 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
5431 if [ $swrong -lt $ewrong ]; then
5432 log "statahead was stopped, maybe too many locks held!"
5435 [ $delta -eq 0 -o $delta_sa -eq 0 ] && continue
5437 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
5438 if [ $SLOWOK -eq 0 ]; then
5439 error "ls $i files is slower with statahead!"
5442 lctl set_param debug=-1
5443 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
5444 lctl set_param -n llite.*.statahead_max 0
5445 lctl get_param llite.*.statahead_max
5446 cancel_lru_locks mdc
5447 cancel_lru_locks osc
5450 time ls -l $DIR/$tdir | wc -l
5452 error "ls $i files (again) without statahead: $((etime - stime)) sec"
5454 lctl set_param debug=-1
5455 lctl set_param llite.*.statahead_max=$max
5456 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
5457 cancel_lru_locks mdc
5458 cancel_lru_locks osc
5461 time ls -l $DIR/$tdir | wc -l
5463 error "ls $i files (again) with statahead: $((etime - stime)) sec"
5464 lctl get_param -n llite.*.statahead_stats
5468 log "ls $i files is slower with statahead!"
5473 [ $delta -gt 20 ] && break
5474 [ $delta -gt 8 ] && MULT=$((50 / delta))
5475 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
5483 delta=$((etime - stime))
5484 log "rm -r $DIR/$tdir/: $delta seconds"
5486 lctl get_param -n llite.*.statahead_stats
5488 run_test 123a "verify statahead work"
5490 test_123b () { # statahead(bug 15027)
5492 local lustre_version=$(get_lustre_version mds)
5493 if [[ $lustre_version != 1.8* ]]; then
5494 skip mds running $lustre_version, statahead is disabled
5499 createmany -o $DIR/$tdir/$tfile-%d 1000
5501 cancel_lru_locks mdc
5502 cancel_lru_locks osc
5504 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
5505 lctl set_param fail_loc=0x80000803
5506 ls -lR $DIR/$tdir > /dev/null
5508 lctl set_param fail_loc=0x0
5509 lctl get_param -n llite.*.statahead_stats
5514 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
5517 [ -z "`lctl get_param -n mdc.*.connect_flags | grep lru_resize`" ] && \
5518 skip "no lru resize on server" && return 0
5520 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
5522 log "create $NR files at $DIR/$tdir"
5523 createmany -o $DIR/$tdir/f $NR ||
5524 error "failed to create $NR files in $DIR/$tdir"
5526 cancel_lru_locks mdc
5527 ls -l $DIR/$tdir > /dev/null
5531 for VALUE in `lctl get_param ldlm.namespaces.*mdc-*.lru_size`; do
5532 local PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
5533 LRU_SIZE=$(lctl get_param -n $PARAM)
5534 if [ $LRU_SIZE -gt $(default_lru_size) ]; then
5535 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
5536 log "NS=$(basename $NSDIR)"
5541 if [ -z "$NSDIR" -o $LRU_SIZE -lt $(default_lru_size) ]; then
5542 skip "Not enough cached locks created!"
5549 # We know that lru resize allows one client to hold $LIMIT locks
5550 # for 10h. After that locks begin to be killed by client.
5552 local LIMIT=`lctl get_param -n $NSDIR.pool.limit`
5554 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
5555 # killing locks. Some time was spent for creating locks. This means
5556 # that up to the moment of sleep finish we must have killed some of
5557 # them (10-100 locks). This depends on how fast ther were created.
5558 # Many of them were touched in almost the same moment and thus will
5559 # be killed in groups.
5560 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
5562 # Use $LRU_SIZE_B here to take into account real number of locks
5563 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
5564 local LRU_SIZE_B=$LRU_SIZE
5566 local OLD_LVF=`lctl get_param -n $NSDIR.pool.lock_volume_factor`
5567 lctl set_param -n $NSDIR.pool.lock_volume_factor $LVF
5569 # Let's make sure that we really have some margin. Client checks
5570 # cached locks every 10 sec.
5572 log "Sleep ${SLEEP} sec"
5574 while ((SEC<$SLEEP)); do
5578 LRU_SIZE=`lctl get_param -n $NSDIR/lru_size`
5582 lctl set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
5583 local LRU_SIZE_A=`lctl get_param -n $NSDIR/lru_size`
5585 [ $LRU_SIZE_B -gt $LRU_SIZE_A ] || {
5586 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
5587 unlinkmany $DIR/$tdir/f $NR
5591 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
5592 log "unlink $NR files at $DIR/$tdir"
5593 unlinkmany $DIR/$tdir/f $NR
5595 run_test 124a "lru resize ======================================="
5598 [ -z "`lctl get_param -n mdc.*.connect_flags | grep lru_resize`" ] && \
5599 skip "no lru resize on server" && return 0
5601 # even for cmd no matter what metadata namespace to use for getting
5602 # the limit, we use appropriate.
5603 LIMIT=`lctl get_param -n ldlm.namespaces.*mdc*.pool.limit`
5605 NR=$(($(default_lru_size)*20))
5606 if [ $NR -gt $LIMIT ]; then
5609 lru_resize_disable mdc
5610 mkdir -p $DIR/$tdir/disable_lru_resize ||
5611 error "failed to create $DIR/$tdir/disable_lru_resize"
5613 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
5614 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
5615 cancel_lru_locks mdc
5618 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
5621 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
5624 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
5628 nolruresize_delta=$((etime-stime))
5629 log "ls -la time: $nolruresize_delta seconds"
5630 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
5631 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
5633 lru_resize_enable mdc
5634 mkdir -p $DIR/$tdir/enable_lru_resize ||
5635 error "failed to create $DIR/$tdir/enable_lru_resize"
5637 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
5638 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
5639 cancel_lru_locks mdc
5642 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
5645 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
5648 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
5652 lruresize_delta=$((etime-stime))
5653 log "ls -la time: $lruresize_delta seconds"
5654 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
5656 if [ $lruresize_delta -gt $nolruresize_delta ]; then
5657 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
5658 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
5659 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
5661 log "lru resize performs the same with no lru resize"
5663 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
5665 run_test 124b "lru resize (performance test) ======================="
5667 test_125() { # 13358
5668 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
5669 mkdir -p $DIR/d125 || error "mkdir failed"
5670 $SETSTRIPE $DIR/d125 -s 65536 -c -1 || error "setstripe failed"
5671 setfacl -R -m u:bin:rwx $DIR/d125 || error "setfacl $DIR/d125 failes"
5672 ls -ld $DIR/d125 || error "cannot access $DIR/d125"
5674 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
5676 test_126() { # bug 12829/13455
5677 [ "$UID" != 0 ] && skip_env "skipping $TESTNAME (must run as root)" && return
5678 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
5679 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
5681 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
5683 run_test 126 "check that the fsgid provided by the client is taken into account"
5685 test_127() { # bug 15521
5686 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
5687 $LCTL set_param osc.*.stats=0
5688 FSIZE=$((2048 * 1024))
5689 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
5690 cancel_lru_locks osc
5691 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
5693 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
5694 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
5695 echo "got $COUNT $NAME"
5696 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
5697 eval $NAME=$COUNT || error "Wrong proc format"
5700 read_bytes|write_bytes)
5701 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
5702 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
5703 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
5704 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
5705 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
5706 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
5707 error "sumsquare is too small: $SUMSQ"
5708 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
5709 error "sumsquare is too big: $SUMSQ"
5713 done < $DIR/${tfile}.tmp
5715 #check that we actually got some stats
5716 [ "$read_bytes" ] || error "Missing read_bytes stats"
5717 [ "$write_bytes" ] || error "Missing write_bytes stats"
5718 [ "$read_bytes" != 0 ] || error "no read done"
5719 [ "$write_bytes" != 0 ] || error "no write done"
5721 run_test 127 "verify the client stats are sane"
5723 test_128() { # bug 15212
5725 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
5730 result=$(grep error $TMP/$tfile.log)
5732 [ -z "$result" ] || error "consecutive find with interactive lfs failed"
5734 run_test 128 "interactive lfs for 2 consecutive finds"
5737 [ "$FSTYPE" != "ldiskfs" ] && skip "not needed for FSTYPE=$FSTYPE" && return 0
5738 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5740 local MNTDEV=$(get_mds_mntdev_proc_path)
5741 DEV=$(ldiskfs_canon "$MNTDEV" mds)
5742 [ -z "$DEV" ] && error "can't access mds mntdev"
5744 LDPROC=/proc/fs/ldiskfs/$DEV/max_dir_size
5745 do_facet mds "test -e /sys/fs/ldiskfs/$DEV/max_dir_size" && LDPROC=/sys/fs/ldiskfs/$DEV/max_dir_size
5748 do_facet mds "echo $MAX > $LDPROC"
5754 while [ ! $I -gt $MAX ]; do
5755 multiop $DIR/$tdir/$J Oc
5757 if [ $rc -eq $EFBIG ]; then
5758 do_facet mds "echo 0 >$LDPROC"
5759 echo "return code $rc received as expected"
5761 elif [ $rc -ne 0 ]; then
5762 do_facet mds "echo 0 >$LDPROC"
5763 error_exit "error $rc instead of expected $EFBIG"
5766 I=$(stat -c%s "$DIR/$tdir")
5769 error "exceeded dir size limit: $I bytes"
5770 do_facet mds "echo 0 >$LDPROC"
5772 run_test 129 "test directory size limit ========================"
5781 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
5782 [ -n "$filefrag_op" ] && skip "filefrag has no FIEMAP support" && return
5784 trap cleanup_130 EXIT RETURN
5786 local fm_file=$DIR/$tfile
5787 lfs setstripe -s 65536 -c 1 $fm_file ||
5788 error "setstripe failed on $fm_file"
5789 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
5790 error "dd failed for $fm_file"
5792 filefrag -ves $fm_file || error "filefrag $fm_file failed"
5793 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
5795 lun=`$GETSTRIPE $fm_file | grep -A 10 obdidx | awk '{print $1}' | grep -v "obdidx"`
5797 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
5800 for line in $filefrag_op
5802 frag_lun=`echo $line | cut -d: -f5`
5803 ext_len=`echo $line | cut -d: -f4`
5804 if (( $frag_lun != $lun )); then
5806 error "FIEMAP on 1-stripe file($fm_file) failed"
5809 (( tot_len += ext_len ))
5812 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
5814 error "FIEMAP on 1-stripe file($fm_file) failed;"
5820 echo "FIEMAP on single striped file succeeded"
5822 run_test 130a "FIEMAP (1-stripe file)"
5825 [ "$OSTCOUNT" -lt "2" ] && skip_env "FIEMAP on 2-stripe file test" && return
5827 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
5828 [ -n "$filefrag_op" ] && skip "filefrag has no FIEMAP support" && return
5830 trap cleanup_130 EXIT RETURN
5832 local fm_file=$DIR/$tfile
5833 lfs setstripe -s 65536 -c 2 $fm_file ||
5834 error "setstripe failed on $fm_file"
5835 dd if=/dev/zero of=$fm_file bs=1M count=2 ||
5836 error "dd failed on $fm_file"
5838 filefrag -ves $fm_file || error "filefrag $fm_file failed"
5839 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
5841 last_lun=`echo $filefrag_op | cut -d: -f5`
5846 for line in $filefrag_op; do
5847 frag_lun=`echo $line | cut -d: -f5`
5848 ext_len=`echo $line | cut -d: -f4`
5849 if (( $frag_lun != $last_lun )); then
5850 if (( tot_len != 1024 )); then
5852 error "FIEMAP $fm_file: len $tot_len for OST $last_lun instead of 256"
5859 (( tot_len += ext_len ))
5862 if (( num_luns != 2 || tot_len != 1024 )); then
5864 error "FIEMAP $fm_file: wrong number of LUNs or wrong len for OST $last_lun"
5870 echo "FIEMAP on 2-stripe file succeeded"
5872 run_test 130b "FIEMAP (2-stripe file)"
5875 [ "$OSTCOUNT" -lt "2" ] && skip_env "FIEMAP on 2-stripe hole test" && return
5877 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
5878 [ -n "$filefrag_op" ] && skip "filefrag has no FIEMAP support" && return
5880 trap cleanup_130 EXIT RETURN
5882 local fm_file=$DIR/$tfile
5883 lfs setstripe -s 65536 -c 2 $fm_file ||
5884 error "setstripe failed on $fm_file"
5885 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 ||
5886 error "dd failed on $fm_file"
5888 filefrag -ves $fm_file || error "filefrag $fm_file failed"
5889 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
5891 last_lun=`echo $filefrag_op | cut -d: -f5`
5896 for line in $filefrag_op
5898 frag_lun=`echo $line | cut -d: -f5`
5899 ext_len=`echo $line | cut -d: -f4`
5900 if (( $frag_lun != $last_lun )); then
5901 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
5902 if (( logical != 512 )); then
5904 error "FIEMAP $fm_file: logical start for LUN $logical instead of 512"
5907 if (( tot_len != 512 )); then
5909 error "FIEMAP $fm_file: len $tot_len for OST $last_lun instead of 1024"
5916 (( tot_len += ext_len ))
5919 if (( num_luns != 2 || tot_len != 512 )); then
5921 error "FIEMAP $fm_file: wrong number of LUNs or wrong len for OST $last_lun"
5927 echo "FIEMAP on 2-stripe file with hole succeeded"
5929 run_test 130c "FIEMAP (2-stripe file with hole)"
5932 [ "$OSTCOUNT" -lt "3" ] && skip_env "FIEMAP on N-stripe file test" && return
5934 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
5935 [ -n "$filefrag_op" ] && skip "filefrag has no FIEMAP support" && return
5937 trap cleanup_130 EXIT RETURN
5939 local fm_file=$DIR/$tfile
5940 lfs setstripe -s 65536 -c $OSTCOUNT $fm_file ||
5941 error "setstripe failed on $fm_file"
5942 dd if=/dev/zero of=$fm_file bs=1M count=$OSTCOUNT ||
5943 error "dd failed on $fm_file"
5945 filefrag -ves $fm_file || error "filefrag $fm_file failed"
5946 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
5948 last_lun=`echo $filefrag_op | cut -d: -f5`
5953 for line in $filefrag_op
5955 frag_lun=`echo $line | cut -d: -f5`
5956 ext_len=`echo $line | cut -d: -f4`
5957 if (( $frag_lun != $last_lun )); then
5958 if (( tot_len != 1024 )); then
5960 error "FIEMAP $fm_file: len $tot_len for OST $last_lun instead of 1024"
5967 (( tot_len += ext_len ))
5970 if (( num_luns != OSTCOUNT || tot_len != 1024 )); then
5972 error "FIEMAP $fm_file: wrong number of LUNs or wrong len for OST $last_lun"
5978 echo "FIEMAP on N-stripe file succeeded"
5980 run_test 130d "FIEMAP (N-stripe file)"
5983 [ "$OSTCOUNT" -lt "2" ] && skip "continuation FIEMAP test" && return
5985 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
5986 [ -n "$filefrag_op" ] && skip "filefrag has no FIEMAP support" && return
5988 trap cleanup_130 EXIT RETURN
5990 local fm_file=$DIR/$tfile
5991 lfs setstripe -s 131072 -c 2 $fm_file ||
5992 error "setstripe failed on $fm_file"
5994 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
5995 for ((i = 0; i < $NUM_BLKS; i++)); do
5996 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
5999 filefrag -ves $fm_file || error "filefrag $fm_file failed"
6000 filefrag_op=`filefrag -ve $fm_file | grep -A 12000 "ext:" | grep -v "ext:" | grep -v "found"`
6002 last_lun=`echo $filefrag_op | cut -d: -f5`
6007 for line in $filefrag_op
6009 frag_lun=`echo $line | cut -d: -f5`
6010 ext_len=`echo $line | cut -d: -f4`
6011 if (( $frag_lun != $last_lun )); then
6012 if (( tot_len != $EXPECTED_LEN )); then
6014 error "FIEMAP $fm_file: len $tot_len for OST $last_lun instead of $EXPECTED_LEN"
6021 (( tot_len += ext_len ))
6024 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
6026 error "FIEMAP $fm_file: wrong number of LUNs or wrong len for OST $last_lun"
6032 echo "FIEMAP with continuation calls succeeded"
6034 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
6040 mds) local dev=$(get_mds_mdt_device_proc_path)
6041 res=`do_facet mds $LCTL get_param $dev.$FSNAME-MDT0000.stats | grep "$2"`
6043 ost) res=`do_facet ost0 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$2"`
6045 *) error "Wrong argument $1" ;;
6048 count=`echo $res | awk '{print $2}'`
6049 [ -z "$res" ] && error "The counter for $2 on $1 was not incremented"
6050 # if the argument $3 is zero, it means any stat increment is ok.
6051 if [ $3 -gt 0 ] ; then
6052 [ $count -ne $3 ] && error "The $2 counter on $1 is wrong - expected $3"
6058 local lustre_version=$(get_lustre_version mds)
6059 if [[ $lustre_version != 1.8* ]]; then
6060 skip mds running $lustre_version, no stats, bz22378
6064 local testdir=$DIR/${tdir}/stats_testdir
6065 mkdir -p $DIR/${tdir}
6068 local dev=$(get_mds_mdt_device_proc_path)
6069 do_facet mds $LCTL set_param $dev.*.stats=clear
6070 do_facet ost $LCTL set_param obdfilter.*.stats=clear
6072 # verify mdt stats first.
6073 mkdir ${testdir} || error "mkdir failed"
6074 check_stats mds "mkdir" 1
6075 touch ${testdir}/${tfile} || "touch failed"
6076 # LPROC_MDS_OPEN is incremented by 2 - in mds_open() and mds_intent_policy()
6077 check_stats mds "open" 2
6078 check_stats mds "close" 1
6079 mknod ${testdir}/${tfile}-pipe p || "mknod failed"
6080 check_stats mds "mknod" 1
6081 rm -f ${testdir}/${tfile}-pipe || "pipe remove failed"
6082 check_stats mds "unlink" 1
6083 rm -f ${testdir}/${tfile} || error "file remove failed"
6084 check_stats mds "unlink" 2
6086 # remove working dir and check mdt stats again.
6087 rmdir ${testdir} || error "rmdir failed"
6088 check_stats mds "rmdir" 1
6092 run_test 133a "Verifying MDT stats ========================================"
6096 local lustre_version=$(get_lustre_version mds)
6097 if [[ $lustre_version != 1.8* ]]; then
6098 skip mds running $lustre_version, no stats, bz22378
6102 local testdir=$DIR/${tdir}/stats_testdir
6103 mkdir -p ${testdir} || error "mkdir failed"
6104 touch ${testdir}/${tfile} || "touch failed"
6105 cancel_lru_locks mdc
6108 local dev=$(get_mds_mdt_device_proc_path)
6109 do_facet mds $LCTL set_param $dev.*.stats=clear
6110 do_facet ost $LCTL set_param obdfilter.*.stats=clear
6112 # extra mdt stats verification.
6113 stat ${testdir}/${tfile} || error "stat failed"
6114 check_stats mds "getattr" 0
6115 chmod 444 ${testdir}/${tfile} || error "chmod failed"
6116 check_stats mds "setattr" 1
6117 $LFS df || error "lfs failed"
6118 check_stats mds "statfs" 1
6122 run_test 133b "Verifying extra MDT stats =================================="
6126 local lustre_version=$(get_lustre_version mds)
6127 if [[ $lustre_version != 1.8* ]]; then
6128 skip mds running $lustre_version, no stats, bz22378
6132 local testdir=$DIR/${tdir}/stats_testdir
6133 mkdir -p ${testdir} || error "mkdir failed"
6135 # verify obdfilter stats.
6136 $LFS setstripe -c 1 -o 0 ${testdir}/${tfile}
6138 cancel_lru_locks osc
6141 local dev=$(get_mds_mdt_device_proc_path)
6142 do_facet mds $LCTL set_param $dev.*.stats=clear
6143 do_facet ost $LCTL set_param obdfilter.*.stats=clear
6145 dd if=/dev/zero of=${testdir}/${tfile} bs=1024k count=1 || error "dd failed"
6147 cancel_lru_locks osc
6148 check_stats ost "write" 1
6150 dd if=${testdir}/${tfile} of=/dev/null bs=1k count=1 || error "dd failed"
6151 check_stats ost "read" 1
6153 > ${testdir}/${tfile} || error "truncate failed"
6154 check_stats ost "punch" 1
6156 rm -f ${testdir}/${tfile} || error "file remove failed"
6157 check_stats ost "destroy" 1
6161 run_test 133c "Verifying OST stats ========================================"
6163 test_140() { #bug-17379
6164 mkdir -p $DIR/$tdir || error "Creating dir $DIR/$tdir"
6165 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
6166 cp /usr/bin/stat . || error "Copying stat to $DIR/$tdir"
6168 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
6170 while i=`expr $i + 1`; do
6171 mkdir -p $i || error "Creating dir $i"
6172 cd $i || error "Changing to $i"
6173 ln -s ../stat stat || error "Creating stat symlink"
6174 # Read the symlink until ELOOP present,
6175 # not LBUGing the system is considered success,
6176 # we didn't overrun the stack.
6177 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
6179 if [ $ret -eq 40 ]; then
6182 error "Open stat symlink"
6188 echo "The symlink depth = $i"
6189 [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 ] || error "Invalid symlink depth"
6191 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
6194 local TF="$TMP/$tfile"
6196 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
6198 cancel_lru_locks osc
6199 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
6200 remount_client $MOUNT
6202 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
6205 $TRUNCATE $DIR/$tfile 6000
6206 cancel_lru_locks osc
6207 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
6210 echo "12345" >>$DIR/$tfile
6211 cancel_lru_locks osc
6212 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
6215 echo "12345" >>$DIR/$tfile
6216 cancel_lru_locks osc
6217 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
6222 run_test 150 "truncate/append tests"
6224 function roc_hit() {
6225 local list=$(comma_list $(osts_nodes))
6227 ACCNUM=$(do_nodes $list $LCTL get_param -n obdfilter.*.stats | \
6228 awk '/'cache_hit'/ {sum+=$2} END {print sum}')
6232 function set_cache() {
6235 if [ "$2" == "off" ]; then
6238 local list=$(comma_list $(osts_nodes))
6239 do_nodes $list lctl set_param obdfilter.*.${1}_cache_enable $on
6241 cancel_lru_locks osc
6245 remote_ost_nodsh && skip "remote OST with nodsh" && return
6247 local list=$(comma_list $(osts_nodes))
6248 if ! do_nodes $list grep -q truncate_inode_pages_range /proc/kallsyms; then #b=18718
6249 skip "old RHEL4/SLES9 kernel" && return
6254 # check whether obdfilter is cache capable at all
6255 if ! do_nodes $list $LCTL get_param -n obdfilter.*.read_cache_enable > /dev/null; then
6256 echo "not cache-capable obdfilter"
6260 # make sure cache is enabled on all obdfilters
6261 do_nodes $list $LCTL set_param obdfilter.*.read_cache_enable=1
6262 do_nodes $list $LCTL set_param obdfilter.*.writethrough_cache_enable=1
6264 # pages should be in the case right after write
6265 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES || error "dd failed"
6266 local BEFORE=`roc_hit`
6267 cancel_lru_locks osc
6268 cat $DIR/$tfile >/dev/null
6269 local AFTER=`roc_hit`
6270 if let "AFTER - BEFORE != CPAGES"; then
6271 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
6274 # the following read invalidates the cache
6275 cancel_lru_locks osc
6276 do_nodes $list $LCTL set_param -n obdfilter.*.read_cache_enable 0
6277 cat $DIR/$tfile >/dev/null
6279 # now data shouldn't be found in the cache
6281 cancel_lru_locks osc
6282 cat $DIR/$tfile >/dev/null
6284 if let "AFTER - BEFORE != 0"; then
6285 error "IN CACHE: before: $BEFORE, after: $AFTER"
6288 do_nodes $list $LCTL set_param -n obdfilter.*.read_cache_enable=1
6289 do_nodes $list $LCTL set_param obdfilter.*.writethrough_cache_enable=1
6292 run_test 151 "test cache on oss and controls ==============================="
6295 local TF="$TMP/$tfile"
6297 # simulate ENOMEM during write
6298 #define OBD_FAIL_OST_NOMEM 0x226
6299 lctl set_param fail_loc=0x80000226
6300 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
6302 sync || error "sync failed"
6303 lctl set_param fail_loc=0
6305 # discard client's cache
6306 cancel_lru_locks osc
6308 # simulate ENOMEM during read
6309 lctl set_param fail_loc=0x80000226
6310 cmp $TF $DIR/$tfile || error "cmp failed"
6311 lctl set_param fail_loc=0
6315 run_test 152 "test read/write with enomem ============================"
6318 multiop $DIR/$tfile Ow4096Ycu || error "multiop failed"
6320 run_test 153 "test if fdatasync does not crash ======================="
6323 # do directio so as not to populate the page cache
6324 log "creating a 10 Mb file"
6325 multiop $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
6326 log "starting reads"
6327 dd if=$DIR/$tfile of=/dev/null bs=4096 &
6328 log "truncating the file"
6329 multiop $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
6331 kill %+ || true # reads might have finished
6332 echo "wait until dd is finished"
6334 log "removing the temporary file"
6335 rm -rf $DIR/$tfile || error "tmp file removal failed"
6337 run_test 154 "parallel read and truncate should not deadlock ==="
6340 local temp=$TMP/$tfile
6341 local file=$DIR/$tfile
6342 local list=$(comma_list $(osts_nodes))
6343 local big=$(do_nodes $list grep "cache" /proc/cpuinfo | \
6344 awk '{sum+=$4} END{print sum}')
6348 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
6349 error "dd of=$temp bs=6096 count=1 failed"
6351 cancel_lru_locks osc
6352 cmp $temp $file || error "$temp $file differ"
6354 $TRUNCATE $temp 6000
6355 $TRUNCATE $file 6000
6356 cmp $temp $file || error "$temp $file differ (truncate1)"
6358 echo "12345" >>$temp
6359 echo "12345" >>$file
6360 cmp $temp $file || error "$temp $file differ (append1)"
6362 echo "12345" >>$temp
6363 echo "12345" >>$file
6364 cmp $temp $file || error "$temp $file differ (append2)"
6366 dd if=/dev/urandom of=$temp bs=$((big*2)) count=1k || \
6367 error "dd of=$temp bs=$((big*2)) count=1k failed"
6370 cancel_lru_locks osc
6371 cmp $temp $file || error "$temp $file differ"
6379 set_cache writethrough on
6382 run_test 155a "Verification of correctness: read cache:on write_cache:on"
6386 set_cache writethrough off
6389 run_test 155b "Verification of correctness: read cache:on write_cache:off"
6393 set_cache writethrough on
6396 run_test 155c "Verification of correctness: read cache:off write_cache:on"
6400 set_cache writethrough off
6403 run_test 155d "Verification of correctness: read cache:off write_cache:off "
6409 local file="$DIR/$tfile"
6411 log "Turn on read and write cache"
6413 set_cache writethrough on
6415 log "Write data and read it back."
6416 log "Read should be satisfied from the cache."
6417 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
6419 cancel_lru_locks osc
6420 cat $file >/dev/null
6422 if ! let "AFTER - BEFORE == CPAGES"; then
6423 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
6425 log "cache hits:: before: $BEFORE, after: $AFTER"
6428 log "Read again; it should be satisfied from the cache."
6430 cancel_lru_locks osc
6431 cat $file >/dev/null
6433 if ! let "AFTER - BEFORE == CPAGES"; then
6434 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
6436 log "cache hits:: before: $BEFORE, after: $AFTER"
6440 log "Turn off the read cache and turn on the write cache"
6442 set_cache writethrough on
6444 log "Read again; it should be satisfied from the cache."
6446 cancel_lru_locks osc
6447 cat $file >/dev/null
6449 if ! let "AFTER - BEFORE == CPAGES"; then
6450 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
6452 log "cache hits:: before: $BEFORE, after: $AFTER"
6455 log "Read again; it should not be satisfied from the cache."
6457 cancel_lru_locks osc
6458 cat $file >/dev/null
6460 if ! let "AFTER - BEFORE == 0"; then
6461 error "IN CACHE: before: $BEFORE, after: $AFTER"
6463 log "cache hits:: before: $BEFORE, after: $AFTER"
6466 log "Write data and read it back."
6467 log "Read should be satisfied from the cache."
6468 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
6470 cancel_lru_locks osc
6471 cat $file >/dev/null
6473 if ! let "AFTER - BEFORE == CPAGES"; then
6474 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
6476 log "cache hits:: before: $BEFORE, after: $AFTER"
6479 log "Read again; it should not be satisfied from the cache."
6481 cancel_lru_locks osc
6482 cat $file >/dev/null
6484 if ! let "AFTER - BEFORE == 0"; then
6485 error "IN CACHE: before: $BEFORE, after: $AFTER"
6487 log "cache hits:: before: $BEFORE, after: $AFTER"
6491 log "Turn off read and write cache"
6493 set_cache writethrough off
6495 log "Write data and read it back"
6496 log "It should not be satisfied from the cache."
6498 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
6499 cancel_lru_locks osc
6501 cat $file >/dev/null
6503 if ! let "AFTER - BEFORE == 0"; then
6504 error_ignore 20762 "IN CACHE: before: $BEFORE, after: $AFTER"
6506 log "cache hits:: before: $BEFORE, after: $AFTER"
6510 log "Turn on the read cache and turn off the write cache"
6512 set_cache writethrough off
6514 log "Write data and read it back"
6515 log "It should not be satisfied from the cache."
6517 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
6519 cancel_lru_locks osc
6520 cat $file >/dev/null
6522 if ! let "AFTER - BEFORE == 0"; then
6523 error_ignore 20762 "IN CACHE: before: $BEFORE, after: $AFTER"
6525 log "cache hits:: before: $BEFORE, after: $AFTER"
6528 log "Read again; it should be satisfied from the cache."
6530 cancel_lru_locks osc
6531 cat $file >/dev/null
6533 if ! let "AFTER - BEFORE == CPAGES"; then
6534 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
6536 log "cache hits:: before: $BEFORE, after: $AFTER"
6541 run_test 156 "Verification of ROC tunables ========================"
6544 $LCTL clear # bug 18514
6545 $LCTL debug_daemon start $TMP/${tfile}_log_good
6547 $LCTL debug_daemon stop
6548 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
6549 error "sed failed to read log_good"
6551 $LCTL debug_daemon start $TMP/${tfile}_log_good
6553 $LCTL debug_daemon stop
6555 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
6556 error "lctl df log_bad failed"
6558 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
6559 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
6561 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
6562 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
6564 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
6565 error "bad_line good_line1 good_line2 are empty"
6567 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
6568 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
6569 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
6571 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
6572 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
6573 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
6575 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
6576 error "bad_line_new good_line_new are empty"
6578 local expected_good=$((good_line1 + good_line2*2))
6580 rm -f $TMP/${tfile}*
6581 if [ $bad_line -ne $bad_line_new ]; then
6582 error "expected $bad_line bad lines, but got $bad_line_new"
6586 if [ $expected_good -ne $good_line_new ]; then
6587 error "expected $expected_good good lines, but got $good_line_new"
6592 run_test 170 "test lctl df to handle corrupted log ====================="
6594 test_171() { # bug20592
6595 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
6596 $LCTL set_param fail_loc=0x50e
6597 $LCTL set_param fail_val=3000
6598 multiop_bg_pause $DIR/$tfile Os || true
6601 if dmesg | grep "recursive fault"; then
6602 error "caught a recursive fault"
6604 $LCTL set_param fail_loc=0
6607 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
6609 obdecho_create_test() {
6613 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
6614 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" || rc=2; }
6615 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec create 1" || rc=3; }
6616 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec test_brw 0 w 1" || rc=4; }
6617 [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec cleanup" || rc=5; }
6618 [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec detach" || rc=6; }
6623 local lustre_version=$(get_lustre_version mds)
6624 if [[ $lustre_version != 1.8* ]]; then
6625 skip bug22316 mds running $lustre_version
6630 local rmmod_remote=0
6632 lsmod | grep -q obdecho || { load_module obdecho/obdecho && rmmod_local=1; }
6634 OBD=`$LCTL dl | awk ' /-osc-/ { print $4; exit; }'`
6635 [ "x$OBD" != "x" ] && { obdecho_create_test $OBD client || rc=2; }
6636 [ $rmmod_local -eq 1 ] && rmmod obdecho
6637 [ $rc -ne 0 ] && return $rc
6639 do_facet ost "lsmod | grep -q obdecho || { insmod ${LUSTRE}/obdecho/obdecho.ko || modprobe obdecho; }" && rmmod_remote=1
6641 OBD=$(do_facet ost "$LCTL dl | awk '/obdfilter/ { print; exit; }'" | awk '{print $4;}')
6642 [ "x$OBD" != "x" ] && { obdecho_create_test $OBD ost || rc=3; }
6643 [ $rmmod_remote -eq 1 ] && do_facet ost "rmmod obdecho"
6644 [ $rc -ne 0 ] && return $rc
6648 run_test 180 "test obdecho ============================================"
6650 test_181() { # bug 22177
6651 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
6652 # create enough files to index the directory
6653 createmany -o $DIR/$tdir/foobar 4000
6654 # print attributes for debug purpose
6657 multiop_bg_pause $DIR/$tdir D_Sc || return 1
6659 # remove the files & current working dir
6660 unlinkmany $DIR/$tdir/foobar 4000
6662 kill -USR1 $MULTIPID
6664 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
6667 run_test 181 "Test open-unlinked dir ========================"
6672 TGTPOOL_MAX=$(($TGT_COUNT - 1))
6674 TGTPOOL_LIST=`seq $TGTPOOL_FIRST $TGTPOOL_STEP $TGTPOOL_MAX`
6675 POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
6676 POOL_DIR_NAME=dir_tst
6677 POOL_DIR=$POOL_ROOT/$POOL_DIR_NAME
6678 POOL_FILE=$POOL_ROOT/file_tst
6682 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep pools)" ] &&
6683 skip "missing pools support on server" && return 1
6684 remote_mgs_nodsh && skip "remote MGS with nodsh" && return 1
6685 [ -z "$mdtlov" ] && mdtlov=$(get_mdtlov_proc_path $FSNAME)
6689 check_file_in_pool()
6692 res=$($GETSTRIPE $file | grep 0x | cut -f2)
6695 found=$(echo :$TGTPOOL_LIST: | tr " " ":" | grep :$i:)
6696 if [[ "$found" == "" ]]
6698 echo "pool list: $TGTPOOL_LIST"
6699 echo "striping: $res"
6700 error "$file not allocated in $POOL"
6709 trap "cleanup_pools $FSNAME" EXIT
6712 test_pools || return 0
6714 create_pool $FSNAME.$POOL || return $?
6715 [ $($LFS pool_list $FSNAME | grep -c $POOL) -eq 1 ] ||
6716 error "$POOL not in lfs pool_list"
6718 run_test 200a "Create new pool =========================================="
6721 test_pools || return 0
6722 TGT=$(for i in $TGTPOOL_LIST; do printf "$FSNAME-OST%04x_UUID " $i; done)
6723 do_facet mgs $LCTL pool_add $FSNAME.$POOL \
6724 $FSNAME-OST[$TGTPOOL_FIRST-$TGTPOOL_MAX/$TGTPOOL_STEP]
6726 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL | sort -u | tr '\n' ' ' " "$TGT" ||
6727 error "Add to pool failed"
6729 run_test 200b "Add targets to a pool ===================================="
6732 test_pools || return 0
6734 $SETSTRIPE -c 2 -p $POOL $POOL_DIR
6735 [ $? = 0 ] || error "Cannot set pool $POOL to $POOL_DIR"
6736 # b-19919 test relative path works well
6737 mkdir -p $POOL_DIR/$POOL_DIR_NAME
6739 $SETSTRIPE -c 2 -p $POOL $POOL_DIR_NAME
6740 [ $? = 0 ] || error "Cannot set pool $POOL to $POOL_DIR/$POOL_DIR_NAME"
6741 $SETSTRIPE -c 2 -p $POOL ./$POOL_DIR_NAME
6742 [ $? = 0 ] || error "Cannot set pool $POOL to $POOL_DIR/./$POOL_DIR_NAME"
6743 $SETSTRIPE -c 2 -p $POOL ../$POOL_DIR_NAME
6744 [ $? = 0 ] || error "Cannot set pool $POOL to $POOL_DIR/../$POOL_DIR_NAME"
6745 $SETSTRIPE -c 2 -p $POOL ../$POOL_DIR_NAME/$POOL_DIR_NAME
6746 [ $? = 0 ] || error "Cannot set pool $POOL to $POOL_DIR/../$POOL_DIR_NAME/$POOL_DIR_NAME"
6747 rm -rf $POOL_DIR_NAME; cd -
6749 run_test 200c "Set pool on a directory ================================="
6752 test_pools || return 0
6753 res=$($GETSTRIPE --pool $POOL_DIR | awk '/^pool:/ {print $2}')
6754 [ "$res" = $POOL ] || error "Pool on $POOL_DIR is $res, not $POOL"
6756 run_test 200d "Check pool on a directory ==============================="
6759 test_pools || return 0
6761 for i in $(seq -w 1 $(($TGT_COUNT * 3))); do
6762 file=$POOL_DIR/file-$i
6764 check_file_in_pool $file
6765 if [[ $? != 0 ]]; then
6766 failed=$(($failed + 1))
6769 [ "$failed" = 0 ] || error "$failed files not allocated in $POOL"
6771 run_test 200e "Check files allocation from directory pool =============="
6774 test_pools || return 0
6777 for i in $(seq -w 1 $(($TGT_COUNT * 3))); do
6778 file=$POOL_FILE/spoo-$i
6779 $SETSTRIPE -p $POOL $file
6780 check_file_in_pool $file
6781 if [[ $? != 0 ]]; then
6782 failed=$(($failed + 1))
6785 [ "$failed" = 0 ] || error "$failed files not allocated in $POOL"
6787 run_test 200f "Create files in a pool ==================================="
6790 test_pools || return 0
6792 TGT=$($LCTL get_param -n lov.$FSNAME-clilov-*.pools.$POOL | tr '\n' ' ')
6793 res=$($LFS df --pool $FSNAME.$POOL | awk '{print $1}' | grep "$FSNAME-OST" | tr '\n' ' ')
6794 [ "$res" = "$TGT" ] || error "Pools OSTs '$TGT' is not '$res' that lfs df reports"
6796 run_test 200g "lfs df a pool ============================================"
6798 test_200h() { # b=24039
6799 test_pools || return 0
6800 mkdir -p $POOL_DIR || error "unable to create $POOL_DIR"
6802 local file="/..$POOL_DIR/$tfile-1"
6803 $SETSTRIPE -p $POOL $file || error "unable to create $file"
6806 $SETSTRIPE -p $POOL $tfile-2 || \
6807 error "unable to create $tfile-2 in $POOL_DIR"
6809 run_test 200h "Create files in a pool with relative pathname ============"
6812 test_pools || return 0
6814 TGT=$($LCTL get_param -n lov.$FSNAME-*.pools.$POOL | head -1)
6815 do_facet mgs $LCTL pool_remove $FSNAME.$POOL $TGT
6816 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL | grep $TGT" "" ||
6817 error "$TGT not removed from $FSNAME.$POOL"
6819 run_test 201a "Remove a target from a pool ============================="
6822 test_pools || return 0
6824 for TGT in $($LCTL get_param -n lov.$FSNAME-*.pools.$POOL | sort -u)
6826 do_facet mgs $LCTL pool_remove $FSNAME.$POOL $TGT
6828 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL" "" ||
6829 error "Pool $FSNAME.$POOL cannot be drained"
6830 # striping on an empty/nonexistant pool should fall back to "pool of everything"
6831 touch ${POOL_DIR}/$tfile || error "failed to use fallback striping for empty pool"
6832 # setstripe on an empty pool should fail
6833 $SETSTRIPE -p $POOL ${POOL_FILE}/$tfile 2>/dev/null && \
6834 error "expected failure when creating file with empty pool"
6837 run_test 201b "Remove all targets from a pool =========================="
6840 test_pools || return 0
6842 do_facet mgs $LCTL pool_destroy $FSNAME.$POOL
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 missing 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 missing pool"
6851 # get param should return err once pool is gone
6852 if wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null ||
6853 echo foo" "foo"; then
6854 remove_pool_from_list $FSNAME.$POOL
6857 error "Pool $FSNAME.$POOL is not destroyed"
6859 run_test 201c "Remove a pool ============================================"
6861 cleanup_pools $FSNAME
6864 if [ "$NETTYPE" = "o2ib" ]; then
6865 skip "unaligned direct I/O is not supported by o2iblnd"
6868 $LFS setstripe -c 2 -s 1048576 $DIR/$tfile
6869 multiop $DIR/$tfile oO_WRONLY:O_APPEND:O_DIRECT:b1048548b130c || \
6870 error "direct write failed"
6871 multiop $DIR/${tfile}2 oO_WRONLY:O_CREAT:w1048548w130c || \
6872 error "cached write failed"
6873 cmp $DIR/$tfile $DIR/${tfile}2 || error "cmp failed"
6874 rm -f $DIR/${tfile}2
6876 run_test 202 "O_APPEND+O_DIRECT multistripe write ========================"
6879 local lustre_version=$(get_lustre_version mds)
6880 if [[ $lustre_version != 1.8* ]]; then
6881 skip bug23766 mds running $lustre_version
6885 local ATIME=`do_facet mds lctl get_param -n mds.*.atime_diff`
6886 echo "atime should be updated on the MDS when closing file" > $DIR/$tfile
6888 # reads should update atime on the client and close should update it on the MDS
6889 multiop_bg_pause $DIR/$tfile o_r20c || return 1
6894 kill -USR1 $MULTIPID || return 2
6895 echo "starting reads"
6897 cancel_lru_locks osc
6898 cancel_lru_locks mdc
6899 time2=`stat -c "%X" $DIR/$tfile`
6900 log "new atime is $time2"
6901 [ "$time2" -ge "$time1" ] || error "atime was not updated"
6903 run_test 203 " atime should be updated on the MDS when closing file ===="
6907 # tests that do cleanup/setup should be run at the end
6912 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
6913 $LCTL set_param fail_loc=0x903
6914 # cancel_lru_locks mgc - does not work due to lctl set_param syntax
6915 for ls in /proc/fs/lustre/ldlm/namespaces/MGC*/lru_size; do
6918 FAIL_ON_ERROR=true cleanup
6919 FAIL_ON_ERROR=true setup
6921 run_test 900 "umount should not race with any mgc requeue thread"
6923 complete $(basename $0) $SECONDS
6924 check_and_cleanup_lustre
6925 if [ "$I_MOUNTED" != "yes" ]; then
6926 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true