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 lu-983
13 ALWAYS_EXCEPT=${ALWAYS_EXCEPT:-"27u 42a 42b 42c 42d 45 51d 62 68 75 101a $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"
21 case `uname -r` in #bug number 16410
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 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=$(ostname_from_index $OSTIDX)
992 local mdtosc=$(get_mdtosc_proc_path $OST)
993 local last_id=$(do_facet mds lctl get_param -n osc.$mdtosc.prealloc_last_id)
994 local next_id=$(do_facet mds lctl get_param -n osc.$mdtosc.prealloc_next_id)
996 mkdir -p $DIR/$tdir/${OST}
997 $SETSTRIPE $DIR/$tdir/${OST} -i $OSTIDX -c 1
998 #define OBD_FAIL_OST_ENOSPC 0x215
999 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=$FAILIDX
1000 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x215
1001 echo "Creating to objid $last_id on ost $OST..."
1002 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1003 do_facet mds "lctl get_param -n osc.$mdtosc.prealloc*" | grep '[0-9]'
1004 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=$FAILLOC
1008 exhaust_all_precreations() {
1010 for (( i=0; i < OSTCOUNT; i++ )) ; do
1011 exhaust_precreations $i $1 -1
1016 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1017 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1018 remote_ost_nodsh && skip "remote OST with nodsh" && return
1021 rm -f $DIR/$tdir/$tfile
1022 exhaust_precreations 0 0x80000215
1023 $SETSTRIPE -c -1 $DIR/$tdir
1024 touch $DIR/$tdir/$tfile || error
1025 $GETSTRIPE $DIR/$tdir/$tfile
1028 run_test 27n "create file with some full OSTs =================="
1031 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1032 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1033 remote_ost_nodsh && skip "remote OST with nodsh" && return
1036 rm -f $DIR/$tdir/$tfile
1037 exhaust_all_precreations 0x215
1039 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1044 run_test 27o "create file with all full OSTs (should error) ===="
1047 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1048 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1049 remote_ost_nodsh && skip "remote OST with nodsh" && return
1052 rm -f $DIR/$tdir/$tfile
1055 $MCREATE $DIR/$tdir/$tfile || error
1056 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error
1057 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error
1059 exhaust_precreations 0 0x80000215
1060 echo foo >> $DIR/$tdir/$tfile || error
1061 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error
1065 run_test 27p "append to a truncated file with some full OSTs ==="
1068 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1069 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1070 remote_ost_nodsh && skip "remote OST with nodsh" && return
1073 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=1; 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 local PROCESS=$((FINISH - START))
1167 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1168 error "$FINISH - $START >= $TIMEOUT / 2"
1169 sleep $((TIMEOUT / 2 - PROCESS))
1172 run_test 27v "skip object creation on slow OST ================="
1174 test_27w() { # bug 10997
1175 mkdir -p $DIR/$tdir || error "mkdir failed"
1176 $SETSTRIPE $DIR/$tdir/f0 -s 65536 || error "lstripe failed"
1177 size=`$GETSTRIPE $DIR/$tdir/f0 -s`
1178 [ $size -ne 65536 ] && error "stripe size $size != 65536" || true
1179 gsdir=$($LFS getstripe -d $DIR/$tdir)
1180 [ $(echo $gsdir | grep -c stripe_count) -ne 1 ] && error "$LFS getstripe -d $DIR/$tdir failed"
1182 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping multiple stripe count/offset test" && return
1183 for i in `seq 1 $OSTCOUNT`; do
1185 log setstripe $DIR/$tdir/f$i -c $i -i $offset
1186 $SETSTRIPE $DIR/$tdir/f$i -c $i -i $offset || error "lstripe -c $i -i $offset failed"
1187 count=`$GETSTRIPE -c $DIR/$tdir/f$i`
1188 index=`$GETSTRIPE -o $DIR/$tdir/f$i`
1189 [ $count -ne $i ] && error "stripe count $count != $i" || true
1190 [ $index -ne $offset ] && error "stripe offset $index != $offset" || true
1193 run_test 27w "check lfs setstripe -c -s -i options ============="
1196 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs" && return
1197 OFFSET=$(($OSTCOUNT - 1))
1199 local OST=$(ostname_from_index $OSTIDX)
1202 $SETSTRIPE $DIR/$tdir -c 1 # 1 stripe per file
1203 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1205 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1206 for i in `seq 0 $OFFSET`; do
1207 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}' | grep -w "$OSTIDX"` ] &&
1208 error "OST0 was degraded but new created file still use it"
1210 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1212 run_test 27x "create files while OST0 is degraded"
1215 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1216 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1218 MDS_OSCS=`do_facet mds lctl dl | awk '/[oO][sS][cC].*md[ts]/ { print $4 }'`
1219 OFFSET=$(($OSTCOUNT-1))
1221 for OSC in $MDS_OSCS; do
1222 if [ $OST == -1 ]; then {
1223 OST=`osc_to_ost $OSC`
1225 echo $OSC "is Deactivate:"
1226 do_facet mds lctl --device %$OSC deactivate
1230 OSTIDX=$(index_from_ostuuid $OST)
1232 $SETSTRIPE $DIR/$tdir -c 1 # 1 stripe / file
1234 do_facet ost$((OSTIDX+1)) lctl set_param -n obdfilter.$OST.degraded 1
1236 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1237 do_facet ost$((OSTIDX+1)) lctl set_param -n obdfilter.$OST.degraded 0
1239 for i in `seq 0 $OFFSET`; do
1240 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "$OSTIDX"` ] || \
1241 error "files created on deactivated OSTs instead of degraded OST"
1243 for OSC in $MDS_OSCS; do
1244 [ `osc_to_ost $OSC` != $OST ] && {
1245 echo $OSC "is activate"
1246 do_facet mds lctl --device %$OSC activate
1250 run_test 27y "create files while OST0 is degraded and the rest inactive"
1252 test_27z() { # b=19102
1253 local restore_size=`$GETSTRIPE -s $MOUNT`
1254 local restore_count=`$GETSTRIPE -c $MOUNT`
1255 local restore_offset=`$GETSTRIPE -o $MOUNT`
1256 $SETSTRIPE -c 0 -o -1 -s 0 $MOUNT
1257 local default_size=`$GETSTRIPE -s $MOUNT`
1258 local default_count=`$GETSTRIPE -c $MOUNT`
1259 local default_offset=`$GETSTRIPE -o $MOUNT`
1260 local dsize=$((1024 * 1024))
1261 [ $default_size -eq $dsize ] || error "stripe size $default_size != $dsize"
1262 [ $default_count -eq 1 ] || error "stripe count $default_count != 1"
1263 [ $default_offset -eq -1 ] || error "stripe offset $default_offset != -1"
1264 $SETSTRIPE -c $restore_count -o $restore_offset -s $restore_size $MOUNT
1266 run_test 27z "check filesystem-wide default LOV EA values"
1268 # createtest also checks that device nodes are created and
1269 # then visible correctly (#2091)
1270 test_28() { # bug 2091
1272 $CREATETEST $DIR/d28/ct || error
1274 run_test 28 "create/mknod/mkdir with bad file types ============"
1277 cancel_lru_locks mdc
1282 LOCKCOUNTORIG=`lctl get_param -n ldlm.namespaces.*mdc*.lock_count`
1283 LOCKUNUSEDCOUNTORIG=`lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count`
1284 [ -z $"LOCKCOUNTORIG" ] && error "No mdc lock count" && return 1
1288 LOCKCOUNTCURRENT=`lctl get_param -n ldlm.namespaces.*mdc*.lock_count`
1289 LOCKUNUSEDCOUNTCURRENT=`lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count`
1290 if [ "$LOCKCOUNTCURRENT" -gt "$LOCKCOUNTORIG" ]; then
1291 lctl set_param -n ldlm.dump_namespaces ""
1292 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
1293 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1294 log "dumped log to $TMP/test_29.dk (bug 5793)"
1297 if [ "$LOCKUNUSEDCOUNTCURRENT" -gt "$LOCKUNUSEDCOUNTORIG" ]; then
1298 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
1299 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1300 log "dumped log to $TMP/test_29.dk (bug 5793)"
1304 run_test 29 "IT_GETATTR regression ============================"
1306 test_30a() { # was test_30
1311 run_test 30a "execute binary from Lustre (execve) =============="
1316 $RUNAS $DIR/ls / || error
1319 run_test 30b "execute binary from Lustre as non-root ==========="
1321 test_30c() { # b=22376
1324 cancel_lru_locks mdc
1325 cancel_lru_locks osc
1326 $RUNAS $DIR/ls / || error
1329 run_test 30c "execute binary from Lustre without read perms ===="
1332 $OPENUNLINK $DIR/f31 $DIR/f31 || error
1333 $CHECKSTAT -a $DIR/f31 || error
1335 run_test 31a "open-unlink file =================================="
1338 touch $DIR/f31 || error
1339 ln $DIR/f31 $DIR/f31b || error
1340 multiop $DIR/f31b Ouc || error
1341 $CHECKSTAT -t file $DIR/f31 || error
1343 run_test 31b "unlink file with multiple links while open ======="
1346 touch $DIR/f31 || error
1347 ln $DIR/f31 $DIR/f31c || error
1348 multiop_bg_pause $DIR/f31 O_uc || return 1
1350 multiop $DIR/f31c Ouc
1351 kill -USR1 $MULTIPID
1354 run_test 31c "open-unlink file with multiple links ============="
1357 opendirunlink $DIR/d31d $DIR/d31d || error
1358 $CHECKSTAT -a $DIR/d31d || error
1360 run_test 31d "remove of open directory ========================="
1362 test_31e() { # bug 2904
1363 check_kernel_version 34 || return 0
1364 openfilleddirunlink $DIR/d31e || error
1366 run_test 31e "remove of open non-empty directory ==============="
1368 test_31f() { # bug 4554
1371 $SETSTRIPE $DIR/d31f -s 1048576 -c 1
1372 cp /etc/hosts $DIR/d31f
1374 $GETSTRIPE $DIR/d31f/hosts
1375 multiop_bg_pause $DIR/d31f D_c || return 1
1378 rm -rv $DIR/d31f || error "first of $DIR/d31f"
1380 $SETSTRIPE $DIR/d31f -s 1048576 -c 1
1381 cp /etc/hosts $DIR/d31f
1384 multiop_bg_pause $DIR/d31f D_c || return 1
1387 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
1388 wait $MULTIPID || error "first opendir $MULTIPID failed"
1392 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
1393 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
1396 run_test 31f "remove of open directory with open-unlink file ==="
1399 echo "== more mountpoints and symlinks ================="
1400 [ -e $DIR/d32a ] && rm -fr $DIR/d32a
1401 mkdir -p $DIR/d32a/ext2-mountpoint
1402 mount -t ext2 -o loop $EXT2_DEV $DIR/d32a/ext2-mountpoint || error
1403 $CHECKSTAT -t dir $DIR/d32a/ext2-mountpoint/.. || error
1404 $UMOUNT $DIR/d32a/ext2-mountpoint || error
1406 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
1409 [ -e $DIR/d32b ] && rm -fr $DIR/d32b
1410 mkdir -p $DIR/d32b/ext2-mountpoint
1411 mount -t ext2 -o loop $EXT2_DEV $DIR/d32b/ext2-mountpoint || error
1412 ls -al $DIR/d32b/ext2-mountpoint/.. || error
1413 $UMOUNT $DIR/d32b/ext2-mountpoint || error
1415 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
1418 [ -e $DIR/d32c ] && rm -fr $DIR/d32c
1419 mkdir -p $DIR/d32c/ext2-mountpoint
1420 mount -t ext2 -o loop $EXT2_DEV $DIR/d32c/ext2-mountpoint || error
1421 mkdir -p $DIR/d32c/d2/test_dir
1422 $CHECKSTAT -t dir $DIR/d32c/ext2-mountpoint/../d2/test_dir || error
1423 $UMOUNT $DIR/d32c/ext2-mountpoint || error
1425 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
1428 [ -e $DIR/d32d ] && rm -fr $DIR/d32d
1429 mkdir -p $DIR/d32d/ext2-mountpoint
1430 mount -t ext2 -o loop $EXT2_DEV $DIR/d32d/ext2-mountpoint || error
1431 mkdir -p $DIR/d32d/d2/test_dir
1432 ls -al $DIR/d32d/ext2-mountpoint/../d2/test_dir || error
1433 $UMOUNT $DIR/d32d/ext2-mountpoint || error
1435 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
1438 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
1439 mkdir -p $DIR/d32e/tmp
1440 TMP_DIR=$DIR/d32e/tmp
1441 ln -s $DIR/d32e $TMP_DIR/symlink11
1442 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1443 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
1444 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
1446 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
1449 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
1450 mkdir -p $DIR/d32f/tmp
1451 TMP_DIR=$DIR/d32f/tmp
1452 ln -s $DIR/d32f $TMP_DIR/symlink11
1453 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1454 ls $DIR/d32f/tmp/symlink11 || error
1455 ls $DIR/d32f/symlink01 || error
1457 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
1460 TMP_DIR=$DIR/$tdir/tmp
1461 mkdir -p $TMP_DIR $DIR/${tdir}2
1462 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
1463 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1464 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
1465 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
1466 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
1467 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
1469 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
1472 rm -fr $DIR/$tdir $DIR/${tdir}2
1473 TMP_DIR=$DIR/$tdir/tmp
1474 mkdir -p $TMP_DIR $DIR/${tdir}2
1475 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
1476 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1477 ls $TMP_DIR/symlink12 || error
1478 ls $DIR/$tdir/symlink02 || error
1480 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
1483 [ -e $DIR/d32i ] && rm -fr $DIR/d32i
1484 mkdir -p $DIR/d32i/ext2-mountpoint
1485 mount -t ext2 -o loop $EXT2_DEV $DIR/d32i/ext2-mountpoint || error
1486 touch $DIR/d32i/test_file
1487 $CHECKSTAT -t file $DIR/d32i/ext2-mountpoint/../test_file || error
1488 $UMOUNT $DIR/d32i/ext2-mountpoint || error
1490 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
1493 [ -e $DIR/d32j ] && rm -fr $DIR/d32j
1494 mkdir -p $DIR/d32j/ext2-mountpoint
1495 mount -t ext2 -o loop $EXT2_DEV $DIR/d32j/ext2-mountpoint || error
1496 touch $DIR/d32j/test_file
1497 cat $DIR/d32j/ext2-mountpoint/../test_file || error
1498 $UMOUNT $DIR/d32j/ext2-mountpoint || error
1500 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
1504 mkdir -p $DIR/d32k/ext2-mountpoint
1505 mount -t ext2 -o loop $EXT2_DEV $DIR/d32k/ext2-mountpoint
1506 mkdir -p $DIR/d32k/d2
1507 touch $DIR/d32k/d2/test_file || error
1508 $CHECKSTAT -t file $DIR/d32k/ext2-mountpoint/../d2/test_file || error
1509 $UMOUNT $DIR/d32k/ext2-mountpoint || error
1511 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
1515 mkdir -p $DIR/d32l/ext2-mountpoint
1516 mount -t ext2 -o loop $EXT2_DEV $DIR/d32l/ext2-mountpoint || error
1517 mkdir -p $DIR/d32l/d2
1518 touch $DIR/d32l/d2/test_file
1519 cat $DIR/d32l/ext2-mountpoint/../d2/test_file || error
1520 $UMOUNT $DIR/d32l/ext2-mountpoint || error
1522 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
1526 mkdir -p $DIR/d32m/tmp
1527 TMP_DIR=$DIR/d32m/tmp
1528 ln -s $DIR $TMP_DIR/symlink11
1529 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1530 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
1531 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
1533 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
1537 mkdir -p $DIR/d32n/tmp
1538 TMP_DIR=$DIR/d32n/tmp
1539 ln -s $DIR $TMP_DIR/symlink11
1540 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1541 ls -l $DIR/d32n/tmp/symlink11 || error
1542 ls -l $DIR/d32n/symlink01 || error
1544 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
1547 rm -fr $DIR/d32o $DIR/$tfile
1549 mkdir -p $DIR/d32o/tmp
1550 TMP_DIR=$DIR/d32o/tmp
1551 ln -s $DIR/$tfile $TMP_DIR/symlink12
1552 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1553 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
1554 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
1555 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
1556 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
1558 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
1568 mkdir -p $DIR/d32p/tmp
1570 TMP_DIR=$DIR/d32p/tmp
1572 ln -s $DIR/$tfile $TMP_DIR/symlink12
1574 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1576 cat $DIR/d32p/tmp/symlink12 || error
1578 cat $DIR/d32p/symlink02 || error
1581 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
1584 [ -e $DIR/d32q ] && rm -fr $DIR/d32q
1586 touch $DIR/d32q/under_the_mount
1587 mount -t ext2 -o loop $EXT2_DEV $DIR/d32q
1588 ls $DIR/d32q/under_the_mount && error || true
1589 $UMOUNT $DIR/d32q || error
1591 run_test 32q "stat follows mountpoints in Lustre (should return error)"
1594 [ -e $DIR/d32r ] && rm -fr $DIR/d32r
1596 touch $DIR/d32r/under_the_mount
1597 mount -t ext2 -o loop $EXT2_DEV $DIR/d32r
1598 ls $DIR/d32r | grep -q under_the_mount && error || true
1599 $UMOUNT $DIR/d32r || error
1601 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
1606 chmod 444 $DIR/$tfile
1607 chown $RUNAS_ID $DIR/$tfile
1609 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
1612 run_test 33 "write file with mode 444 (should return error) ===="
1617 chown $RUNAS_ID $DIR/d33
1618 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
1619 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
1620 error "open RDWR" || true
1622 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
1627 chown $RUNAS_ID $DIR/d33
1628 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33 || true
1630 run_test 33b "test open file with malformed flags (No panic)"
1632 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
1635 $MCREATE $DIR/f34 || error
1636 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
1637 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
1638 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
1639 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1641 run_test 34a "truncate file that has not been opened ==========="
1644 [ ! -f $DIR/f34 ] && test_34a
1645 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1646 $OPENFILE -f O_RDONLY $DIR/f34
1647 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
1648 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1650 run_test 34b "O_RDONLY opening file doesn't create objects ====="
1653 [ ! -f $DIR/f34 ] && test_34a
1654 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1655 $OPENFILE -f O_RDWR $DIR/f34
1656 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
1657 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1659 run_test 34c "O_RDWR opening file-with-size works =============="
1662 [ ! -f $DIR/f34 ] && test_34a
1663 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
1664 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1667 run_test 34d "write to sparse file ============================="
1671 $MCREATE $DIR/f34e || error
1672 $TRUNCATE $DIR/f34e 1000 || error
1673 $CHECKSTAT -s 1000 $DIR/f34e || error
1674 $OPENFILE -f O_RDWR $DIR/f34e
1675 $CHECKSTAT -s 1000 $DIR/f34e || error
1677 run_test 34e "create objects, some with size and some without =="
1679 test_34f() { # bug 6242, 6243
1682 $MCREATE $DIR/f34f || error
1683 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
1684 dd if=$DIR/f34f of=$TMP/f34f
1685 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
1686 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
1687 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
1688 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
1689 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
1691 run_test 34f "read from a file with no objects until EOF ======="
1694 cp /bin/sh $DIR/f35a
1696 chown $RUNAS_ID $DIR/f35a
1697 $RUNAS $DIR/f35a && error || true
1700 run_test 35a "exec file with mode 444 (should return and not leak) ====="
1704 utime $DIR/f36 || error
1706 run_test 36a "MDS utime check (mknod, utime) ==================="
1710 utime $DIR/f36 || error
1712 run_test 36b "OST utime check (open, utime) ===================="
1717 chown $RUNAS_ID $DIR/d36
1718 $RUNAS utime $DIR/d36/f36 || error
1720 run_test 36c "non-root MDS utime check (mknod, utime) =========="
1723 [ ! -d $DIR/d36 ] && test_36c
1724 echo "" > $DIR/d36/f36
1725 $RUNAS utime $DIR/d36/f36 || error
1727 run_test 36d "non-root OST utime check (open, utime) ==========="
1730 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
1732 touch $DIR/$tdir/$tfile
1733 $RUNAS utime $DIR/$tdir/$tfile && \
1734 error "utime worked, expected failure" || true
1736 run_test 36e "utime on non-owned file (should return error) ===="
1740 export LANG=C LC_LANG=C # for date language
1742 DATESTR="Dec 20 2000"
1744 lctl set_param fail_loc=$fl
1746 cp /etc/hosts $DIR/$tdir/$tfile
1747 sync & # write RPC generated with "current" inode timestamp, but delayed
1749 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
1750 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
1751 cancel_lru_locks osc
1752 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
1754 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
1755 echo "BEFORE: $LS_BEFORE" && \
1756 echo "AFTER : $LS_AFTER" && \
1757 echo "WANT : $DATESTR" && \
1758 error "$DIR/$tdir/$tfile timestamps changed" || true
1762 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
1763 subr_36fh "0x80000214"
1765 run_test 36f "utime on file racing with OST BRW write =========="
1768 remote_ost_nodsh && skip "remote OST with nodsh" && return
1774 fmd_max_age=$(do_facet ost1 \
1775 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
1778 fmd_before=$(do_facet ost1 \
1779 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
1780 touch $DIR/$tdir/$tfile
1781 sleep $((fmd_max_age + 12))
1782 fmd_after=$(do_facet ost1 \
1783 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
1785 echo "fmd_before: $fmd_before"
1786 echo "fmd_after: $fmd_after"
1787 [ "$fmd_after" -gt "$fmd_before" ] && \
1788 echo "AFTER: $fmd_after > BEFORE: $fmd_before" && \
1789 error "fmd didn't expire after ping" || true
1791 run_test 36g "filter mod data cache expiry ====================="
1794 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
1795 subr_36fh "0x80000227"
1797 run_test 36h "utime on file racing with OST BRW write =========="
1801 echo f > $DIR/$tdir/fbugfile
1802 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
1803 ls $DIR/$tdir | grep "\<fbugfile\>" && error
1804 $UMOUNT $DIR/$tdir || error
1805 rm -f $DIR/$tdir/fbugfile || error
1807 run_test 37 "ls a mounted file system to check old content ====="
1810 local file=$DIR/$tfile
1812 openfile -f O_DIRECTORY $file
1815 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
1816 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
1818 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
1822 touch $DIR/${tfile}2
1823 # ls -l $DIR/$tfile $DIR/${tfile}2
1824 # ls -lu $DIR/$tfile $DIR/${tfile}2
1825 # ls -lc $DIR/$tfile $DIR/${tfile}2
1827 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
1828 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
1830 ls -l $DIR/$tfile $DIR/${tfile}2
1832 ls -lu $DIR/$tfile $DIR/${tfile}2
1834 ls -lc $DIR/$tfile $DIR/${tfile}2
1835 error "O_TRUNC didn't change timestamps"
1838 run_test 39 "mtime changed on create ==========================="
1840 function get_times() {
1845 for time in `stat -c "%X %Y %Z" $FILE`; do
1846 eval "$TIME[$i]=$time"
1856 cp -p /etc/passwd $DIR/$tdir/fopen
1857 cp -p /etc/passwd $DIR/$tdir/flink
1858 cp -p /etc/passwd $DIR/$tdir/funlink
1859 cp -p /etc/passwd $DIR/$tdir/frename
1860 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
1862 get_times $DIR/$tdir/fopen OPEN_OLD
1863 get_times $DIR/$tdir/flink LINK_OLD
1864 get_times $DIR/$tdir/funlink UNLINK_OLD
1865 get_times $DIR/$tdir/frename RENAME_OLD
1868 echo "aaaaaa" >> $DIR/$tdir/fopen
1869 echo "aaaaaa" >> $DIR/$tdir/flink
1870 echo "aaaaaa" >> $DIR/$tdir/funlink
1871 echo "aaaaaa" >> $DIR/$tdir/frename
1873 get_times $DIR/$tdir/fopen OPEN_NEW
1874 get_times $DIR/$tdir/flink LINK_NEW
1875 get_times $DIR/$tdir/funlink UNLINK_NEW
1876 get_times $DIR/$tdir/frename RENAME_NEW
1878 cat $DIR/$tdir/fopen > /dev/null
1879 ln $DIR/$tdir/flink $DIR/$tdir/flink2
1880 rm -f $DIR/$tdir/funlink2
1881 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
1883 get_times $DIR/$tdir/fopen OPEN_NEW2
1884 get_times $DIR/$tdir/flink LINK_NEW2
1885 get_times $DIR/$tdir/funlink UNLINK_NEW2
1886 get_times $DIR/$tdir/frename2 RENAME_NEW2
1887 echo ${OPEN_OLD[1]},${OPEN_NEW[$MTIME]},${OPEN_NEW2[$MTIME]}
1888 echo ${LINK_OLD[1]},${LINK_NEW[$MTIME]},${LINK_NEW2[$MTIME]}
1889 echo ${UNLINK_OLD[1]},${UNLINK_NEW[$MTIME]},${UNLINK_NEW2[$MTIME]}
1890 echo ${RENAME_OLD[1]},${RENAME_NEW[$MTIME]},${RENAME_NEW2[$MTIME]}
1892 [ ${OPEN_NEW2[$MTIME]} -eq ${OPEN_NEW[$MTIME]} ] || error "open file reverses mtime"
1893 [ ${LINK_NEW2[$MTIME]} -eq ${LINK_NEW[$MTIME]} ] || error "link file reverses mtime"
1894 [ ${UNLINK_NEW2[$MTIME]} -eq ${UNLINK_NEW[$MTIME]} ] || error "unlink file reverses mtime"
1895 [ ${RENAME_NEW2[$MTIME]} -eq ${RENAME_NEW[$MTIME]} ] || error "rename file reverses mtime"
1897 run_test 39b "mtime change on close ============================"
1901 touch -m -d "10 years ago" $DIR1/$tfile
1902 local MTIME1=`stat -c %y $DIR1/$tfile`
1903 echo hello >> $DIR1/$tfile
1904 local MTIME2=`stat -c %y $DIR1/$tfile`
1905 mv $DIR1/$tfile $DIR1/$tfile-1
1906 local MTIME3=`stat -c %y $DIR1/$tfile-1`
1907 [ "$MTIME2" = "$MTIME3" ] ||
1908 error "mtime ($MTIME2) changed (to $MTIME3) on rename (BZ#11063)"
1910 run_test 39c "mtime change on rename ==========================="
1913 dd if=/dev/zero of=$DIR/f40 bs=4096 count=1
1914 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/f40 && error
1915 $CHECKSTAT -t file -s 4096 $DIR/f40 || error
1917 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
1921 small_write $DIR/f41 18
1923 run_test 41 "test small file write + fstat ====================="
1925 count_ost_writes() {
1926 lctl get_param -n osc.*.stats |
1927 awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }'
1934 BG_DIRTY_RATIO_SAVE=10
1935 MAX_BG_DIRTY_RATIO=25
1939 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
1940 # dirty_ratio, dirty_background_ratio
1941 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
1942 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
1943 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
1944 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
1946 # if file not here, we are a 2.4 kernel
1947 kill -CONT `pidof kupdated`
1952 # setup the trap first, so someone cannot exit the test at the
1953 # exact wrong time and mess up a machine
1954 trap start_writeback EXIT
1955 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
1956 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
1957 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
1958 sysctl -w vm.dirty_writeback_centisecs=0
1959 # save and increase /proc/sys/vm/dirty_ratio
1960 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
1961 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
1962 # save and increase /proc/sys/vm/dirty_background_ratio
1963 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
1964 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
1966 # if file not here, we are a 2.4 kernel
1967 kill -STOP `pidof kupdated`
1971 # ensure that all stripes have some grant before we test client-side cache
1973 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
1974 dd if=/dev/zero of=$i bs=4k count=1
1979 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
1980 # file truncation, and file removal.
1983 cancel_lru_locks osc
1985 sync; sleep 1; sync # just to be safe
1986 BEFOREWRITES=`count_ost_writes`
1987 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
1988 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
1989 AFTERWRITES=`count_ost_writes`
1990 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
1991 error "$BEFOREWRITES < $AFTERWRITES"
1994 run_test 42a "ensure that we don't flush on close =============="
1998 cancel_lru_locks osc
2001 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
2002 BEFOREWRITES=`count_ost_writes`
2003 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
2004 AFTERWRITES=`count_ost_writes`
2005 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
2006 error "$BEFOREWRITES < $AFTERWRITES on unlink"
2008 BEFOREWRITES=`count_ost_writes`
2009 sync || error "sync: $?"
2010 AFTERWRITES=`count_ost_writes`
2011 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
2012 error "$BEFOREWRITES < $AFTERWRITES on sync"
2014 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
2018 run_test 42b "test destroy of file with cached dirty data ======"
2020 # if these tests just want to test the effect of truncation,
2021 # they have to be very careful. consider:
2022 # - the first open gets a {0,EOF}PR lock
2023 # - the first write conflicts and gets a {0, count-1}PW
2024 # - the rest of the writes are under {count,EOF}PW
2025 # - the open for truncate tries to match a {0,EOF}PR
2026 # for the filesize and cancels the PWs.
2027 # any number of fixes (don't get {0,EOF} on open, match
2028 # composite locks, do smarter file size management) fix
2029 # this, but for now we want these tests to verify that
2030 # the cancellation with truncate intent works, so we
2031 # start the file with a full-file pw lock to match against
2032 # until the truncate.
2037 cancel_lru_locks osc
2039 # prime the file with 0,EOF PW to match
2043 # now the real test..
2044 dd if=/dev/zero of=$file bs=1024 count=100
2045 BEFOREWRITES=`count_ost_writes`
2046 $TRUNCATE $file $offset
2047 cancel_lru_locks osc
2048 AFTERWRITES=`count_ost_writes`
2054 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
2055 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
2058 run_test 42c "test partial truncate of file with cached dirty data"
2062 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
2063 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
2066 run_test 42d "test complete truncate of file with cached dirty data"
2072 test_42e() { # bug22074
2073 local TDIR=$DIR/${tdir}e
2074 local pagesz=$(page_size)
2076 local files=$((OSTCOUNT * 500))
2077 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
2082 $LFS setstripe -c 1 $TDIR
2083 createmany -o $TDIR/f $files
2085 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
2087 warmup_files=$((OSTCOUNT * max_dirty_mb))
2088 createmany -o $TDIR/w $warmup_files
2090 # write a large amount of data into one file to get good avail_grant number
2091 for ((i=0; i<$warmup_files; i++)); do
2092 idx=$($LFS getstripe -i $TDIR/w$i)
2093 [ $idx -ne 0 ] && continue
2094 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
2097 sync # write out any dirty data
2099 $LCTL get_param $proc_osc0/cur_dirty_bytes
2100 $LCTL get_param $proc_osc0/cur_grant_bytes
2102 # create as much dirty as we can while (hopefully) not triggering the
2104 for ((i=0; i<$warmup_files; i++)); do
2105 idx=$($LFS getstripe -i $TDIR/w$i)
2106 [ $idx -ne 0 ] && continue
2107 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
2109 $LCTL get_param $proc_osc0/cur_dirty_bytes
2110 $LCTL get_param $proc_osc0/cur_grant_bytes
2112 # perform the real test
2113 $LCTL set_param $proc_osc0/rpc_stats 0
2114 for ((;i<$files; i++)); do
2115 [ $($LFS getstripe -i $TDIR/f$i) -eq 0 ] || continue
2116 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
2119 $LCTL get_param $proc_osc0/rpc_stats
2121 $LCTL get_param $proc_osc0/rpc_stats |
2122 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
2123 [ "$PPR" != "16:" ] && continue
2124 [ $WPCT -lt 85 ] && error "$pages-page write RPCs only $WPCT% < 85%"
2125 break # we only want the "pages per rpc" stat
2129 run_test 42e "verify sub-RPC writes are not done synchronously"
2133 cp -p /bin/ls $DIR/$tdir/$tfile
2134 multiop $DIR/$tdir/$tfile Ow_c &
2136 # give multiop a chance to open
2139 $DIR/$tdir/$tfile && error || true
2142 run_test 43 "execution of file opened for write should return -ETXTBSY"
2146 cp -p `which multiop` $DIR/d43/multiop
2147 MULTIOP_PROG=$DIR/d43/multiop multiop_bg_pause $TMP/test43.junk O_c || return 1
2149 multiop $DIR/d43/multiop Oc && error "expected error, got success"
2150 kill -USR1 $MULTIOP_PID || return 2
2151 wait $MULTIOP_PID || return 3
2154 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
2158 cp -p `which multiop` $DIR/d43/multiop
2159 MULTIOP_PROG=$DIR/d43/multiop multiop_bg_pause $TMP/test43.junk O_c || return 1
2161 $TRUNCATE $DIR/d43/multiop 0 && error "expected error, got success"
2162 kill -USR1 $MULTIOP_PID || return 2
2163 wait $MULTIOP_PID || return 3
2166 run_test 43b "truncate of file being executed should return -ETXTBSY"
2169 local testdir="$DIR/d43c"
2172 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
2173 ( cd $testdir && md5sum -c)
2175 run_test 43c "md5sum of copy into lustre========================"
2178 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
2179 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
2180 dd if=$DIR/f1 of=/dev/null bs=4k count=1
2182 run_test 44 "zero length read from a sparse stripe ============="
2185 local nstripe=`$LCTL lov_getconfig $DIR | grep default_stripe_count: | \
2187 [ -z "$nstripe" ] && skip "can't get stripe info" && return
2188 [ "$nstripe" -gt "$OSTCOUNT" ] && skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" && return
2189 local stride=`$LCTL lov_getconfig $DIR | grep default_stripe_size: | \
2191 if [ $nstripe -eq 0 -o $nstripe -eq -1 ] ; then
2192 nstripe=`$LCTL lov_getconfig $DIR | grep obd_count: | awk '{print $2}'`
2195 OFFSETS="0 $((stride/2)) $((stride-1))"
2196 for offset in $OFFSETS ; do
2197 for i in `seq 0 $((nstripe-1))`; do
2199 local GLOBALOFFSETS=""
2200 local size=$((((i + 2 * $nstripe )*$stride + $offset))) # Bytes
2201 ll_sparseness_write $DIR/d44a $size || error "ll_sparseness_write"
2202 GLOBALOFFSETS="$GLOBALOFFSETS $size"
2203 ll_sparseness_verify $DIR/d44a $GLOBALOFFSETS \
2204 || error "ll_sparseness_verify $GLOBALOFFSETS"
2206 for j in `seq 0 $((nstripe-1))`; do
2207 size=$((((j + $nstripe )*$stride + $offset))) # Bytes
2208 ll_sparseness_write $DIR/d44a $size || error "ll_sparseness_write"
2209 GLOBALOFFSETS="$GLOBALOFFSETS $size"
2211 ll_sparseness_verify $DIR/d44a $GLOBALOFFSETS \
2212 || error "ll_sparseness_verify $GLOBALOFFSETS"
2216 run_test 44a "test sparse pwrite ==============================="
2220 for d in `lctl get_param -n osc.*.cur_dirty_bytes`; do
2226 before=`dirty_osc_total`
2227 echo executing "\"$*\""
2229 after=`dirty_osc_total`
2230 echo before $before, after $after
2234 # Obtain grants from OST if it supports it
2235 echo blah > ${f}_grant
2238 do_dirty_record "echo blah > $f"
2239 [ $before -eq $after ] && error "write wasn't cached"
2240 do_dirty_record "> $f"
2241 [ $before -gt $after ] || error "truncate didn't lower dirty count"
2242 do_dirty_record "echo blah > $f"
2243 [ $before -eq $after ] && error "write wasn't cached"
2244 do_dirty_record "sync"
2245 [ $before -gt $after ] || error "writeback didn't lower dirty count"
2246 do_dirty_record "echo blah > $f"
2247 [ $before -eq $after ] && error "write wasn't cached"
2248 do_dirty_record "cancel_lru_locks osc"
2249 [ $before -gt $after ] || error "lock cancellation didn't lower dirty count"
2252 run_test 45 "osc io page accounting ============================"
2254 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
2255 # test tickles a bug where re-dirtying a page was failing to be mapped to the
2256 # objects offset and an assert hit when an rpc was built with 1023's mapped
2257 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
2262 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
2264 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
2265 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
2269 run_test 46 "dirtying a previously written page ================"
2271 # test_47 is removed "Device nodes check" is moved to test_28
2273 test_48a() { # bug 2399
2274 check_kernel_version 34 || return 0
2277 mv $DIR/d48a $DIR/d48.new || error "move directory failed"
2278 mkdir $DIR/d48a || error "recreate directory failed"
2279 touch foo || error "'touch foo' failed after recreating cwd"
2280 mkdir bar || error "'mkdir foo' failed after recreating cwd"
2281 if check_kernel_version 44; then
2282 touch .foo || error "'touch .foo' failed after recreating cwd"
2283 mkdir .bar || error "'mkdir .foo' failed after recreating cwd"
2285 ls . > /dev/null || error "'ls .' failed after recreating cwd"
2286 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
2287 cd . || error "'cd .' failed after recreating cwd"
2288 mkdir . && error "'mkdir .' worked after recreating cwd"
2289 rmdir . && error "'rmdir .' worked after recreating cwd"
2290 ln -s . baz || error "'ln -s .' failed after recreating cwd"
2291 cd .. || error "'cd ..' failed after recreating cwd"
2293 run_test 48a "Access renamed working dir (should return errors)="
2295 test_48b() { # bug 2399
2296 check_kernel_version 34 || return 0
2299 rmdir $DIR/d48b || error "remove cwd $DIR/d48b failed"
2300 touch foo && error "'touch foo' worked after removing cwd"
2301 mkdir foo && error "'mkdir foo' worked after removing cwd"
2302 if check_kernel_version 44; then
2303 touch .foo && error "'touch .foo' worked after removing cwd"
2304 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
2306 ls . > /dev/null && error "'ls .' worked after removing cwd"
2307 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
2308 is_patchless || ( cd . && error "'cd .' worked after removing cwd" )
2309 mkdir . && error "'mkdir .' worked after removing cwd"
2310 rmdir . && error "'rmdir .' worked after removing cwd"
2311 ln -s . foo && error "'ln -s .' worked after removing cwd"
2312 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
2314 run_test 48b "Access removed working dir (should return errors)="
2316 test_48c() { # bug 2350
2317 check_kernel_version 36 || return 0
2318 #lctl set_param debug=-1
2320 mkdir -p $DIR/d48c/dir
2322 $TRACE rmdir $DIR/d48c/dir || error "remove cwd $DIR/d48c/dir failed"
2323 $TRACE touch foo && error "'touch foo' worked after removing cwd"
2324 $TRACE mkdir foo && error "'mkdir foo' worked after removing cwd"
2325 if check_kernel_version 44; then
2326 touch .foo && error "'touch .foo' worked after removing cwd"
2327 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
2329 $TRACE ls . && error "'ls .' worked after removing cwd"
2330 $TRACE ls .. || error "'ls ..' failed after removing cwd"
2331 is_patchless || ( $TRACE cd . && error "'cd .' worked after removing cwd" )
2332 $TRACE mkdir . && error "'mkdir .' worked after removing cwd"
2333 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
2334 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
2335 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
2337 run_test 48c "Access removed working subdir (should return errors)"
2339 test_48d() { # bug 2350
2340 check_kernel_version 36 || return 0
2341 #lctl set_param debug=-1
2343 mkdir -p $DIR/d48d/dir
2345 $TRACE rmdir $DIR/d48d/dir || error "remove cwd $DIR/d48d/dir failed"
2346 $TRACE rmdir $DIR/d48d || error "remove parent $DIR/d48d failed"
2347 $TRACE touch foo && error "'touch foo' worked after removing parent"
2348 $TRACE mkdir foo && error "'mkdir foo' worked after removing parent"
2349 if check_kernel_version 44; then
2350 touch .foo && error "'touch .foo' worked after removing parent"
2351 mkdir .foo && error "'mkdir .foo' worked after removing parent"
2353 $TRACE ls . && error "'ls .' worked after removing parent"
2354 $TRACE ls .. && error "'ls ..' worked after removing parent"
2355 is_patchless || ( $TRACE cd . && error "'cd .' worked after recreate parent" )
2356 $TRACE mkdir . && error "'mkdir .' worked after removing parent"
2357 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
2358 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
2359 is_patchless || ( $TRACE cd .. && error "'cd ..' worked after removing parent" || true )
2361 run_test 48d "Access removed parent subdir (should return errors)"
2363 test_48e() { # bug 4134
2364 check_kernel_version 41 || return 0
2365 #lctl set_param debug=-1
2367 mkdir -p $DIR/d48e/dir
2369 $TRACE rmdir $DIR/d48e/dir || error "remove cwd $DIR/d48e/dir failed"
2370 $TRACE rmdir $DIR/d48e || error "remove parent $DIR/d48e failed"
2371 $TRACE touch $DIR/d48e || error "'touch $DIR/d48e' failed"
2372 $TRACE chmod +x $DIR/d48e || error "'chmod +x $DIR/d48e' failed"
2373 # On a buggy kernel addition of "touch foo" after cd .. will
2374 # produce kernel oops in lookup_hash_it
2375 touch ../foo && error "'cd ..' worked after recreate parent"
2377 $TRACE rm $DIR/d48e || error "rm '$DIR/d48e' failed"
2379 run_test 48e "Access to recreated parent subdir (should return errors)"
2385 ls /proc/$$/cwd || error
2387 run_test 50 "special situations: /proc symlinks ==============="
2389 test_51a() { # was test_51
2390 # bug 1516 - create an empty entry right after ".." then split dir
2393 $MCREATE $DIR/d51/bar
2395 createmany -m $DIR/d51/longfile 201
2397 while [ `ls -sd $DIR/d51 | awk '{ print $1 }'` -eq 4 ]; do
2398 $MCREATE $DIR/d51/longfile$FNUM
2403 ls -l $DIR/d51 > /dev/null || error
2405 run_test 51a "special situations: split htree with empty entry =="
2407 export NUMTEST=70000
2409 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
2410 [ $NUMFREE -lt 21000 ] && \
2411 skip "not enough free inodes ($NUMFREE)" && \
2414 check_kernel_version 40 || NUMTEST=31000
2415 [ $NUMFREE -lt $NUMTEST ] && NUMTEST=$(($NUMFREE - 50))
2418 createmany -d $DIR/d51b/t- $NUMTEST
2420 run_test 51b "mkdir .../t-0 --- .../t-$NUMTEST ===================="
2423 [ ! -d $DIR/d51b ] && skip "$DIR/51b missing" && \
2426 unlinkmany -d $DIR/d51b/t- $NUMTEST
2428 run_test 51c "rmdir .../t-0 --- .../t-$NUMTEST ===================="
2431 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping test with few OSTs" && return
2433 createmany -o $DIR/d51d/t- 1000
2434 $LFS getstripe $DIR/d51d > $TMP/files
2435 for N in `seq 0 $((OSTCOUNT - 1))`; do
2436 OBJS[$N]=`awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}' $TMP/files`
2437 OBJS0[$N]=`grep -A 1 idx $TMP/files | awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}'`
2438 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
2440 unlinkmany $DIR/d51d/t- 1000
2443 for N in `seq 1 $((OSTCOUNT - 1))`; do
2444 [ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ] && \
2445 error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
2446 [ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ] && \
2447 error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
2449 [ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ] && \
2450 error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
2451 [ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ] && \
2452 error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
2456 run_test 51d "check object distribution ===================="
2459 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
2462 chattr +a $DIR/d52a/foo || error "chattr +a failed"
2463 echo bar >> $DIR/d52a/foo || error "append bar failed"
2464 cp /etc/hosts $DIR/d52a/foo && error "cp worked"
2465 rm -f $DIR/d52a/foo 2>/dev/null && error "rm worked"
2466 link $DIR/d52a/foo $DIR/d52a/foo_link 2>/dev/null && error "link worked"
2467 echo foo >> $DIR/d52a/foo || error "append foo failed"
2468 mrename $DIR/d52a/foo $DIR/d52a/foo_ren && error "rename worked"
2469 # new lsattr displays 'e' flag for extents
2470 lsattr $DIR/d52a/foo | egrep -q "^-+a[-e]+ $DIR/d52a/foo" || error "lsattr"
2471 chattr -a $DIR/d52a/foo || error "chattr -a failed"
2473 rm -fr $DIR/d52a || error "cleanup rm failed"
2475 run_test 52a "append-only flag test (should return errors) ====="
2478 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
2481 chattr +i $DIR/d52b/foo || error "chattr +a failed"
2482 cat test > $DIR/d52b/foo && error "cat test worked"
2483 cp /etc/hosts $DIR/d52b/foo && error "cp worked"
2484 rm -f $DIR/d52b/foo 2>/dev/null && error "rm worked"
2485 link $DIR/d52b/foo $DIR/d52b/foo_link 2>/dev/null && error "link worked"
2486 echo foo >> $DIR/d52b/foo && error "echo worked"
2487 mrename $DIR/d52b/foo $DIR/d52b/foo_ren && error "rename worked"
2488 [ -f $DIR/d52b/foo ] || error
2489 [ -f $DIR/d52b/foo_ren ] && error
2490 lsattr $DIR/d52b/foo | egrep -q "^-+i[-e]+ $DIR/d52b/foo" || error "lsattr"
2491 chattr -i $DIR/d52b/foo || error "chattr failed"
2493 rm -fr $DIR/d52b || error "remove failed"
2495 run_test 52b "immutable flag test (should return errors) ======="
2497 test_52c() { # 12848 simulating client < 1.4.7
2498 [ -f $DIR/d52c/foo ] && chattr -i $DIR/d52b/foo
2501 # skip MDS_BFLAG_EXT_FLAGS in mdc_getattr_pack
2502 #define OBD_FAIL_MDC_OLD_EXT_FLAGS 0x802
2503 lctl set_param fail_loc=0x802
2504 chattr +i $DIR/d52c/foo || error
2505 lsattr $DIR/d52c/foo | egrep -q "^-+i[-e]+ $DIR/d52c/foo" || error "lsattr failed"
2506 chattr -i $DIR/d52c/foo || error "chattr failed"
2507 lctl set_param -n fail_loc=0
2509 rm -fr $DIR/d52c || error
2511 run_test 52c "immutable flag test for client < 1.4.7 ======="
2514 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2515 remote_ost_nodsh && skip "remote OST with nodsh" && return
2523 local mdtosc=$(get_mdtosc_proc_path '*')
2524 for VALUE in $(do_facet mds lctl get_param osc.$mdtosc.prealloc_last_id); do
2525 param=`echo ${VALUE[0]} | cut -d "=" -f1`;
2526 ostname=`echo $param | cut -d "." -f2 | cut -d - -f 1-2`
2527 mds_last=$(do_facet mds lctl get_param -n $param)
2528 ostnum=$(echo $ostname | sed "s/${FSNAME}-OST//g" | awk '{print ($1+1)}' )
2529 ost_last=$(do_facet ost$ostnum lctl get_param -n obdfilter.$ostname.last_id)
2530 echo "$ostname.last_id=$ost_last ; MDS.last_id=$mds_last"
2531 if [ $ost_last != $mds_last ]; then
2532 error "$ostname.last_id=$ost_last ; MDS.last_id=$mds_last"
2536 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
2539 [ ! -f "$SOCKETSERVER" ] && skip_env "no socketserver, skipping" && return
2540 [ ! -f "$SOCKETCLIENT" ] && skip_env "no socketclient, skipping" && return
2541 $SOCKETSERVER $DIR/socket
2542 $SOCKETCLIENT $DIR/socket || error
2543 $MUNLINK $DIR/socket
2545 run_test 54a "unix domain socket test =========================="
2551 dd if=/dev/zero of=$f bs=`page_size` count=1
2553 run_test 54b "char device works in lustre ======================"
2556 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
2557 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
2558 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
2560 for i in `seq 3 7`; do
2561 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
2571 loopdev="$DIR/loop54c"
2574 [ -z "$LOOPNUM" ] && echo "couldn't find empty loop device" && return
2575 mknod $loopdev b 7 $LOOPNUM
2576 echo "make a loop file system with $tfile on $loopdev ($LOOPNUM)..."
2577 dd if=/dev/zero of=$tfile bs=`page_size` seek=1024 count=1 > /dev/null
2578 losetup $loopdev $tfile || error "can't set up $loopdev for $tfile"
2579 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
2581 mount -t ext2 $loopdev $tdir || error "error mounting $loopdev on $tdir"
2582 dd if=/dev/zero of=$tdir/tmp bs=`page_size` count=30 || error "dd write"
2584 dd if=$tdir/tmp of=/dev/zero bs=`page_size` count=30 || error "dd read"
2589 run_test 54c "block device works in lustre ====================="
2595 [ "$string" = `echo $string > $f | cat $f` ] || error
2597 run_test 54d "fifo device works in lustre ======================"
2600 check_kernel_version 46 || return 0
2603 cp -aL /dev/console $f
2604 echo $string > $f || error
2606 run_test 54e "console/tty device works in lustre ======================"
2611 client_only && skip "Not a server" && return
2612 mount -t $FSTYPE -o loop,iopen $EXT2_DEV $DIR/d55 || error "mounting"
2614 $IOPENTEST1 $DIR/d55/foo $DIR/d55 || error "running $IOPENTEST1"
2615 $IOPENTEST2 $DIR/d55 || error "running $IOPENTEST2"
2616 echo "check for $EXT2_DEV. Please wait..."
2618 $UMOUNT $DIR/d55 || error "unmounting"
2620 run_test 55 "check iopen_connect_dentry() ======================"
2622 test_56a() { # was test_56
2628 NUMFILESx2=$(($NUMFILES * 2))
2629 for i in `seq 1 $NUMFILES` ; do
2630 touch $DIR/d56/file$i
2631 touch $DIR/d56/dir/file$i
2634 # test lfs getstripe with --recursive
2635 FILENUM=`$GETSTRIPE --recursive $DIR/d56 | grep -c obdidx`
2636 [ $FILENUM -eq $NUMFILESx2 ] || error \
2637 "lfs getstripe --recursive $DIR/d56 wrong: found $FILENUM, expected $NUMFILESx2"
2638 FILENUM=`$GETSTRIPE $DIR/d56 | grep -c obdidx`
2639 [ $FILENUM -eq $NUMFILES ] || error \
2640 "lfs getstripe $DIR/d56 without --recursive wrong: found $FILENUM, expected $NUMFILES"
2641 echo "lfs getstripe --recursive passed."
2643 # test lfs getstripe with file instead of dir
2644 FILENUM=`$GETSTRIPE $DIR/d56/file1 | grep -c obdidx`
2645 [ $FILENUM -eq 1 ] || error \
2646 "lfs getstripe $DIR/d56/file1 wrong:found $FILENUM, expected 1"
2647 echo "lfs getstripe file passed."
2649 #test lfs getstripe with --verbose
2650 [ `$GETSTRIPE --verbose $DIR/d56 | grep -c lmm_magic` -eq $NUMFILES ] ||\
2651 error "lfs getstripe --verbose $DIR/d56 wrong: should find $NUMFILES lmm_magic info"
2652 [ `$GETSTRIPE $DIR/d56 | grep -c lmm_magic` -eq 0 ] || error \
2653 "lfs getstripe $DIR/d56 without --verbose wrong: should not show lmm_magic info"
2654 echo "lfs getstripe --verbose passed."
2656 #test lfs getstripe with --obd
2657 $GETSTRIPE --obd wrong_uuid $DIR/d56 2>&1 | grep -q "unknown obduuid" || \
2658 error "lfs getstripe --obd wrong_uuid should return error message"
2660 [ "$OSTCOUNT" -lt 2 ] && \
2661 skip_env "skipping other lfs getstripe --obd test" && return
2663 OBDUUID=$(ostuuid_from_index $OSTIDX)
2664 FILENUM=`$GETSTRIPE -ir $DIR/d56 | grep -x $OSTIDX | wc -l`
2665 FOUND=`$GETSTRIPE -r --obd $OBDUUID $DIR/d56 | grep obdidx | wc -l`
2666 [ $FOUND -eq $FILENUM ] || \
2667 error "lfs getstripe --obd wrong: found $FOUND, expected $FILENUM"
2668 [ `$GETSTRIPE -r -v --obd $OBDUUID $DIR/d56 | \
2669 sed '/^[ ]*'${OSTIDX}'[ ]/d' |\
2670 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l` -eq 0 ] || \
2671 error "lfs getstripe --obd wrong: should not show file on other obd"
2672 echo "lfs getstripe --obd passed."
2674 run_test 56a "check lfs getstripe ===================================="
2681 if [ ! -d "$DIR/${tdir}g" ] ; then
2682 mkdir -p $DIR/${tdir}g
2683 for i in `seq 1 $LOCAL_NUMFILES` ; do
2684 touch $DIR/${tdir}g/file$i
2686 for i in `seq 1 $LOCAL_NUMDIRS` ; do
2687 mkdir $DIR/${tdir}g/dir$i
2688 for j in `seq 1 $LOCAL_NUMFILES` ; do
2689 touch $DIR/${tdir}g/dir$i/file$j
2695 setup_56_special() {
2700 if [ ! -e "$TDIR/loop1b" ] ; then
2701 for i in `seq 1 $LOCAL_NUMFILES` ; do
2702 mknod $TDIR/loop${i}b b 7 $i
2703 mknod $TDIR/null${i}c c 1 3
2704 ln -s $TDIR/file1 $TDIR/link${i}l
2706 for i in `seq 1 $LOCAL_NUMDIRS` ; do
2707 mknod $TDIR/dir$i/loop${i}b b 7 $i
2708 mknod $TDIR/dir$i/null${i}c c 1 3
2709 ln -s $TDIR/dir$i/file1 $TDIR/dir$i/link${i}l
2717 setup_56 $NUMFILES $NUMDIRS
2719 EXPECTED=$(($NUMDIRS + 2))
2720 # test lfs find with -name
2721 for i in `seq 1 $NUMFILES` ; do
2722 NUMS=`$LFIND -name "*$i" $DIR/${tdir}g | wc -l`
2723 [ $NUMS -eq $EXPECTED ] || error \
2724 "lfs find -name \"*$i\" $DIR/${tdir}g wrong: found $NUMS, expected $EXPECTED"
2726 echo "lfs find -name passed."
2728 run_test 56g "check lfs find -name ============================="
2733 setup_56 $NUMFILES $NUMDIRS
2735 EXPECTED=$((($NUMDIRS+1)*($NUMFILES-1)+$NUMFILES))
2736 # test lfs find with ! -name
2737 for i in `seq 1 $NUMFILES` ; do
2738 NUMS=`$LFIND ! -name "*$i" $DIR/${tdir}g | wc -l`
2739 [ $NUMS -eq $EXPECTED ] || error \
2740 "lfs find ! -name \"*$i\" $DIR/${tdir}g wrong: found $NUMS, expected $EXPECTED"
2742 echo "lfs find ! -name passed."
2744 run_test 56h "check lfs find ! -name ============================="
2749 UUID=$(ostuuid_from_index 0 $DIR/$tdir)
2750 OUT=$($LFIND -obd $UUID $DIR/$tdir)
2751 [ "$OUT" ] && error "$LFIND returned directory '$OUT'" || true
2753 run_test 56i "check 'lfs find -ost UUID' skips directories ======="
2756 setup_56_special $NUMFILES $NUMDIRS
2758 EXPECTED=$((NUMDIRS+1))
2759 NUMS=`$LFIND -type d $DIR/${tdir}g | wc -l`
2760 [ $NUMS -eq $EXPECTED ] || \
2761 error "lfs find -type d $DIR/${tdir}g wrong: found $NUMS, expected $EXPECTED"
2763 run_test 56j "check lfs find -type d ============================="
2766 setup_56_special $NUMFILES $NUMDIRS
2768 EXPECTED=$(((NUMDIRS+1) * NUMFILES))
2769 NUMS=`$LFIND -type f $DIR/${tdir}g | wc -l`
2770 [ $NUMS -eq $EXPECTED ] || \
2771 error "lfs find -type f $DIR/${tdir}g wrong: found $NUMS, expected $EXPECTED"
2773 run_test 56k "check lfs find -type f ============================="
2776 setup_56_special $NUMFILES $NUMDIRS
2778 EXPECTED=$((NUMDIRS + NUMFILES))
2779 NUMS=`$LFIND -type b $DIR/${tdir}g | wc -l`
2780 [ $NUMS -eq $EXPECTED ] || \
2781 error "lfs find -type b $DIR/${tdir}g wrong: found $NUMS, expected $EXPECTED"
2783 run_test 56l "check lfs find -type b ============================="
2786 setup_56_special $NUMFILES $NUMDIRS
2788 EXPECTED=$((NUMDIRS + NUMFILES))
2789 NUMS=`$LFIND -type c $DIR/${tdir}g | wc -l`
2790 [ $NUMS -eq $EXPECTED ] || \
2791 error "lfs find -type c $DIR/${tdir}g wrong: found $NUMS, expected $EXPECTED"
2793 run_test 56m "check lfs find -type c ============================="
2796 setup_56_special $NUMFILES $NUMDIRS
2798 EXPECTED=$((NUMDIRS + NUMFILES))
2799 NUMS=`$LFIND -type l $DIR/${tdir}g | wc -l`
2800 [ $NUMS -eq $EXPECTED ] || \
2801 error "lfs find -type l $DIR/${tdir}g wrong: found $NUMS, expected $EXPECTED"
2803 run_test 56n "check lfs find -type l ============================="
2806 setup_56 $NUMFILES $NUMDIRS
2809 utime $TDIR/file1 > /dev/null || error
2810 utime $TDIR/file2 > /dev/null || error
2811 utime $TDIR/dir1 > /dev/null || error
2812 utime $TDIR/dir2 > /dev/null || error
2813 utime $TDIR/dir1/file1 > /dev/null || error
2816 NUMS=`$LFIND -mtime +1 $TDIR | wc -l`
2817 [ $NUMS -eq $EXPECTED ] || \
2818 error "lfs find -mtime $TDIR wrong: found $NUMS, expected $EXPECTED"
2820 run_test 56o "check lfs find -mtime for old files =========================="
2823 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
2828 setup_56 $NUMFILES $NUMDIRS
2830 chown $RUNAS_ID $TDIR/file* || error "chown $DIR/${tdir}g/file$i failed"
2832 NUMS="`$LFIND -uid $RUNAS_ID $TDIR | wc -l`"
2833 [ $NUMS -eq $EXPECTED ] || \
2834 error "lfs find -uid $TDIR wrong: found $NUMS, expected $EXPECTED"
2836 EXPECTED=$(( ($NUMFILES+1) * $NUMDIRS + 1))
2837 NUMS="`$LFIND ! -uid $RUNAS_ID $TDIR | wc -l`"
2838 [ $NUMS -eq $EXPECTED ] || \
2839 error "lfs find ! -uid $TDIR wrong: found $NUMS, expected $EXPECTED"
2841 echo "lfs find -uid and ! -uid passed."
2843 run_test 56p "check lfs find -uid and ! -uid ==============================="
2846 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
2851 setup_56 $NUMFILES $NUMDIRS
2853 chgrp $RUNAS_GID $TDIR/file* || error "chown $DIR/${tdir}g/file$i failed"
2855 NUMS="`$LFIND -gid $RUNAS_GID $TDIR | wc -l`"
2856 [ $NUMS -eq $EXPECTED ] || \
2857 error "lfs find -gid $TDIR wrong: found $NUMS, expected $EXPECTED"
2859 EXPECTED=$(( ($NUMFILES+1) * $NUMDIRS + 1))
2860 NUMS="`$LFIND ! -gid $RUNAS_GID $TDIR | wc -l`"
2861 [ $NUMS -eq $EXPECTED ] || \
2862 error "lfs find ! -gid $TDIR wrong: found $NUMS, expected $EXPECTED"
2864 echo "lfs find -gid and ! -gid passed."
2866 run_test 56q "check lfs find -gid and ! -gid ==============================="
2869 setup_56 $NUMFILES $NUMDIRS
2873 NUMS=`$LFIND -size 0 -t f $TDIR | wc -l`
2874 [ $NUMS -eq $EXPECTED ] || \
2875 error "lfs find $TDIR -size 0 wrong: found $NUMS, expected $EXPECTED"
2877 NUMS=`$LFIND ! -size 0 -t f $TDIR | wc -l`
2878 [ $NUMS -eq $EXPECTED ] || \
2879 error "lfs find $TDIR ! -size 0 wrong: found $NUMS, expected $EXPECTED"
2880 echo "test" > $TDIR/5chars
2882 NUMS=`$LFIND -size 5 -t f $TDIR | wc -l`
2883 [ $NUMS -eq $EXPECTED ] || \
2884 error "lfs find $TDIR -size 5 wrong: found $NUMS, expected $EXPECTED"
2886 NUMS=`$LFIND -size +5 -t f $TDIR | wc -l`
2887 [ $NUMS -eq $EXPECTED ] || \
2888 error "lfs find $TDIR -size +5 wrong: found $NUMS, expected $EXPECTED"
2890 NUMS=`$LFIND -size +0 -t f $TDIR | wc -l`
2891 [ $NUMS -eq $EXPECTED ] || \
2892 error "lfs find $TDIR -size +0 wrong: found $NUMS, expected $EXPECTED"
2894 NUMS=`$LFIND ! -size -5 -t f $TDIR | wc -l`
2895 [ $NUMS -eq $EXPECTED ] || \
2896 error "lfs find $TDIR ! -size -5 wrong: found $NUMS, expected $EXPECTED"
2899 run_test 56r "check lfs find -size works =========================="
2902 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2904 local MNTDEV=$(get_mds_mntdev_proc_path)
2905 DEV=$(do_facet mds lctl get_param -n $MNTDEV)
2906 [ -z "$DEV" ] && error "can't access $MNTDEV"
2907 for DEV in $(do_facet mds lctl get_param -n $MNTDEV); do
2908 do_facet mds $DUMPE2FS -h $DEV > $TMP/t57a.dump || error "can't access $DEV"
2909 DEVISIZE=`awk '/Inode size:/ { print $3 }' $TMP/t57a.dump`
2910 [ "$DEVISIZE" -gt 128 ] || error "inode size $DEVISIZE"
2914 run_test 57a "verify MDS filesystem created with large inodes =="
2921 local FILEN=$dir/f$FILECOUNT
2923 rm -rf $dir || error "removing $dir"
2924 mkdir -p $dir || error "creating $dir"
2926 echo "mcreating $FILECOUNT files"
2927 createmany -m $dir/f 1 $FILECOUNT || \
2928 error "creating files in $dir"
2930 # verify that files do not have EAs yet
2931 $GETSTRIPE $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
2932 $GETSTRIPE $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
2934 local fsstat_dev=$(get_mds_fsstat_proc_path)
2935 local MDSFREE=$(do_facet mds lctl get_param -n $fsstat_dev.*.kbytesfree)
2936 local MDCFREE=$(lctl get_param -n mdc.*.kbytesfree | head -n 1)
2937 echo "opening files to create objects/EAs"
2939 for FILE in `seq -f $dir/f%g 1 $FILECOUNT`; do
2940 $OPENFILE -f O_RDWR $FILE > /dev/null || error "opening $FILE"
2943 # verify that files have EAs now
2944 $GETSTRIPE $FILE1 | grep -q "obdidx" || error "$FILE1 missing EA"
2945 $GETSTRIPE $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
2947 sleep 1 # make sure we get new statfs data
2948 local MDSFREE2=$(do_facet mds lctl get_param -n $fsstat_dev.*.kbytesfree)
2949 local MDCFREE2=$(lctl get_param -n mdc.*.kbytesfree | head -n 1)
2950 if [ "$MDCFREE2" -lt "$((MDCFREE - 8))" ]; then
2951 if [ "$MDSFREE" != "$MDSFREE2" ]; then
2952 error "MDC before $MDCFREE != after $MDCFREE2"
2954 echo "MDC before $MDCFREE != after $MDCFREE2"
2955 echo "unable to confirm if MDS has large inodes"
2960 run_test 57b "default LOV EAs are stored inside large inodes ==="
2963 [ -z "$(which wiretest 2>/dev/null)" ] && skip_env "could not find wiretest" && return
2966 run_test 58 "verify cross-platform wire constants =============="
2969 echo "touch 130 files"
2970 createmany -o $DIR/f59- 130
2972 unlinkmany $DIR/f59- 130
2975 # wait for commitment of removal
2977 run_test 59 "verify cancellation of llog records async ========="
2979 TEST60_HEAD="test_60 run $RANDOM"
2980 test_60a() { # was test_60
2981 [ ! -f run-llog.sh ] && skip_env "missing subtest run-llog.sh" && return
2982 log "$TEST60_HEAD - from kernel mode"
2985 run_test 60a "llog sanity tests run from kernel module =========="
2987 test_60b() { # bug 6411
2989 LLOG_COUNT=`dmesg | awk "/$TEST60_HEAD/{marker = 1; from_marker = 0;}
3001 [ $LLOG_COUNT -gt 50 ] && error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)"|| true
3003 run_test 60b "limit repeated messages from CERROR/CWARN ========"
3006 echo "create 5000 files"
3007 createmany -o $DIR/f60c- 5000
3008 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
3009 lctl set_param fail_loc=0x80000137
3010 unlinkmany $DIR/f60c- 5000
3012 run_test 60c "unlink file when mds full"
3015 SAVEPRINTK=$(lctl get_param -n printk)
3017 # verify "lctl mark" is even working"
3018 MESSAGE="test message ID $RANDOM $$"
3019 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
3020 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
3022 lctl set_param printk=0 || error "set lnet.printk failed"
3023 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
3024 MESSAGE="new test message ID $RANDOM $$"
3025 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
3026 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
3027 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
3029 lctl set_param -n printk="$SAVEPRINTK"
3031 run_test 60d "test printk console message masking"
3035 dd if=/dev/zero of=$f bs=`page_size` count=1
3036 cancel_lru_locks osc
3037 multiop $f OSMWUc || error
3040 run_test 61 "mmap() writes don't make sync hang ================"
3042 # bug 2330 - insufficient obd_match error checking causes LBUG
3046 cancel_lru_locks osc
3047 #define OBD_FAIL_OSC_MATCH 0x405
3048 lctl set_param fail_loc=0x405
3049 cat $f && error "cat succeeded, expect -EIO"
3050 lctl set_param fail_loc=0
3052 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
3053 # match every page all of the time.
3054 run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
3056 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
3057 test_63a() { # was test_63
3058 MAX_DIRTY_MB=`lctl get_param -n osc.*.max_dirty_mb | head -n 1`
3059 lctl set_param -n osc.*.max_dirty_mb 0
3060 for i in `seq 10` ; do
3061 dd if=/dev/zero of=$DIR/f63 bs=8k &
3067 lctl set_param -n osc.*.max_dirty_mb $MAX_DIRTY_MB
3068 rm -f $DIR/f63 || true
3070 run_test 63a "Verify oig_wait interruption does not crash ======="
3072 # bug 2248 - async write errors didn't return to application on sync
3073 # bug 3677 - async write errors left page locked
3076 lctl set_param debug=-1
3078 # ensure we have a grant to do async writes
3079 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
3082 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
3083 lctl set_param fail_loc=0x80000406
3084 multiop $DIR/$tfile Owy && \
3085 error "sync didn't return ENOMEM"
3086 sync; sleep 2; sync # do a real sync this time to flush page
3087 lctl get_param -n llite.*.dump_page_cache | grep locked && \
3088 error "locked page left in cache after async error" || true
3091 run_test 63b "async write errors should be returned to fsync ==="
3095 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
3097 run_test 64a "verify filter grant calculations (in kernel) ====="
3100 [ ! -f oos.sh ] && skip_env "missing subtest oos.sh" && return
3103 run_test 64b "check out-of-space detection on client ==========="
3105 # bug 1414 - set/get directories' stripe info
3109 $LVERIFY $DIR/d65 $DIR/d65/f1 || error "lverify failed"
3111 run_test 65a "directory with no stripe info ===================="
3115 $SETSTRIPE $DIR/d65 -s $(($STRIPESIZE * 2)) -i 0 -c 1 || error "setstripe"
3117 $LVERIFY $DIR/d65 $DIR/d65/f2 || error "lverify failed"
3119 run_test 65b "directory setstripe $(($STRIPESIZE * 2)) 0 1 ==============="
3122 if [ $OSTCOUNT -gt 1 ]; then
3124 $SETSTRIPE $DIR/d65 -s $(($STRIPESIZE * 4)) -i 1 \
3125 -c $(($OSTCOUNT - 1)) || error "setstripe"
3127 $LVERIFY $DIR/d65 $DIR/d65/f3 || error "lverify failed"
3130 run_test 65c "directory setstripe $(($STRIPESIZE * 4)) 1 $(($OSTCOUNT - 1))"
3134 [ $STRIPECOUNT -le 0 ] && sc=1 || sc=$(($STRIPECOUNT - 1))
3135 $SETSTRIPE $DIR/d65 -s $STRIPESIZE -c $sc || error "setstripe"
3136 touch $DIR/d65/f4 $DIR/d65/f5
3137 $LVERIFY $DIR/d65 $DIR/d65/f4 $DIR/d65/f5 || error "lverify failed"
3139 run_test 65d "directory setstripe $STRIPESIZE -1 stripe_count =============="
3144 $SETSTRIPE $DIR/d65 || error "setstripe"
3145 $GETSTRIPE -v $DIR/d65 | grep "Default" || error "no stripe info failed"
3147 $LVERIFY $DIR/d65 $DIR/d65/f6 || error "lverify failed"
3149 run_test 65e "directory setstripe defaults ======================="
3153 $RUNAS $SETSTRIPE $DIR/d65f && error "setstripe succeeded" || true
3155 run_test 65f "dir setstripe permission (should return error) ==="
3159 $SETSTRIPE $DIR/d65 -s $(($STRIPESIZE * 2)) -i 0 -c 1 || error "setstripe"
3160 $SETSTRIPE -d $DIR/d65 || error "setstripe"
3161 $GETSTRIPE -v $DIR/d65 | grep "Default" || \
3162 error "delete default stripe failed"
3164 run_test 65g "directory setstripe -d ==========================="
3168 $SETSTRIPE $DIR/d65 -s $(($STRIPESIZE * 2)) -i 0 -c 1 || error "setstripe"
3169 mkdir -p $DIR/d65/dd1
3170 [ "`$GETSTRIPE -v $DIR/d65 | grep "^count"`" == \
3171 "`$GETSTRIPE -v $DIR/d65/dd1 | grep "^count"`" ] || error "stripe info inherit failed"
3173 run_test 65h "directory stripe info inherit ===================="
3175 test_65i() { # bug6367
3176 $SETSTRIPE $MOUNT -s 65536 -c -1
3178 run_test 65i "set non-default striping on root directory (bug 6367)="
3180 test_65j() { # bug6367
3182 # if we aren't already remounting for each test, do so for this test
3183 if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
3184 cleanup || error "failed to unmount"
3187 $SETSTRIPE -d $MOUNT || error "setstripe failed"
3189 run_test 65j "set default striping on root directory (bug 6367)="
3191 test_65k() { # bug11679
3192 [ "$OSTCOUNT" -lt 2 ] && skip_env "too few OSTs" && return
3193 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3195 echo "Check OST status: "
3196 MDS_OSCS=`do_facet mds lctl dl | awk '/[oO][sS][cC].*md[ts]/ { print $4 }'`
3197 for OSC in $MDS_OSCS; do
3198 echo $OSC "is activate"
3199 do_facet mds lctl --device %$OSC activate
3201 do_facet client mkdir -p $DIR/$tdir
3202 for INACTIVE_OSC in $MDS_OSCS; do
3203 echo $INACTIVE_OSC "is Deactivate:"
3204 do_facet mds lctl --device %$INACTIVE_OSC deactivate
3205 for STRIPE_OSC in $MDS_OSCS; do
3206 STRIPE_OST=`osc_to_ost $STRIPE_OSC`
3207 STRIPE_INDEX=`do_facet mds lctl get_param -n lov.*md*.target_obd |
3208 grep $STRIPE_OST | awk -F: '{print $1}'`
3209 echo "$SETSTRIPE $DIR/$tdir/${STRIPE_INDEX} -i ${STRIPE_INDEX} -c 1"
3210 do_facet client $SETSTRIPE $DIR/$tdir/${STRIPE_INDEX} -i ${STRIPE_INDEX} -c 1
3212 [ $RC -ne 0 ] && error "setstripe should have succeeded"
3214 do_facet client rm -f $DIR/$tdir/*
3215 echo $INACTIVE_OSC "is Activate."
3216 do_facet mds lctl --device %$INACTIVE_OSC activate
3219 run_test 65k "validate manual striping works properly with deactivated OSCs"
3221 test_65l() { # bug 12836
3222 mkdir -p $DIR/$tdir/test_dir
3223 $SETSTRIPE $DIR/$tdir/test_dir -c -1
3224 $LFS find -mtime -1 $DIR/$tdir > /dev/null
3226 run_test 65l "lfs find on -1 stripe dir ========================"
3228 # bug 2543 - update blocks count on client
3231 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
3233 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
3234 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
3236 run_test 66 "update inode blocks count on client ==============="
3238 test_67a() { # was test_67 bug 3285 - supplementary group fails on MDS, passes on client
3239 [ "$RUNAS_ID" = "$UID" ] && skip "RUNAS_ID = UID = $UID -- skipping" && return
3242 local lustre_version=$(get_lustre_version mds)
3243 if [[ $lustre_version != 1.8* ]]; then
3244 skip mds running $lustre_version, no group_upcall
3247 check_kernel_version 35 || return 0
3249 chmod 771 $DIR/$tdir
3250 chgrp $RUNAS_GID $DIR/$tdir
3251 $RUNAS -u $RUNAS_ID -g $(($RUNAS_GID + 1)) -G1,2,$RUNAS_GID ls $DIR/$tdir
3253 GROUP_UPCALL=$(do_facet mds lctl get_param -n mds.*.group_upcall)
3254 [ -z "$GROUP_UPCALL" ] && \
3255 skip "lctl get_param failed! Useless to continue the test!" && return
3256 [ "$GROUP_UPCALL" = "NONE" -a $RC -eq 0 ] && \
3257 error "no-upcall passed" || true
3258 [ "$GROUP_UPCALL" != "NONE" -a $RC -ne 0 ] && \
3259 error "upcall failed" || true
3261 run_test 67a "supplementary group failure (should return error) ="
3266 do_facet mds lctl set_param -n mds.*.group_upcall NONE
3269 test_67b() { # bug 3285 - supplementary group fails on MDS, passes on client
3271 local lustre_version=$(get_lustre_version mds)
3272 if [[ $lustre_version != 1.8* ]]; then
3273 skip mds running $lustre_version, no group_upcall
3277 # needs to be in /etc/groups on MDS, gid == uid
3278 # Let's use RUNAS_ID
3279 T67_UID=${T67_UID:-$RUNAS_ID}
3281 [ "$UID" = "$T67_UID" ] && skip "UID = T67_UID = $UID -- skipping" && return
3282 check_kernel_version 35 || return 0
3283 do_facet mds grep -q ":$T67_UID:$T67_UID" /etc/passwd || \
3284 { skip "Need gid=$T67_UID group and gid == uid on mds !" && return; }
3286 GROUP_UPCALL=$(do_facet mds lctl get_param -n mds.*.group_upcall)
3287 [ -z "$GROUP_UPCALL" ] && \
3288 skip "lctl get_param failed! Useless to continue the test!" && return
3289 [ "$GROUP_UPCALL" != "NONE" ] && \
3290 skip "skip test - upcall=$GROUP_UPCALL" && return
3292 trap cleanup_67b EXIT
3294 chmod 771 $DIR/$tdir
3295 chgrp $T67_UID $DIR/$tdir
3296 local l_getgroups=$(do_facet mds which l_getgroups)
3297 do_facet mds lctl set_param -n mds.*.group_upcall $l_getgroups
3298 do_facet mds $l_getgroups -d $T67_UID
3299 $RUNAS -u $T67_UID -g 999 -G8,9,$T67_UID touch $DIR/$tdir/$tfile || \
3300 error "'touch $DIR/$tdir/$tfile' failed"
3301 [ -f $DIR/$tdir/$tfile ] || error "$DIR/$tdir/$tfile create error"
3304 run_test 67b "supplementary group test ========================="
3309 if [ ! -z "$LLOOP" ]; then
3310 swapoff $LLOOP || error "swapoff failed"
3311 $LCTL blockdev_detach $LLOOP || error "detach failed"
3319 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
3323 swapon -s | awk '($1 == "'$1'") { print $4 }'
3327 # excercise swapping to lustre by adding a high priority swapfile entry
3328 # and then consuming memory until it is used.
3330 [ "$UID" != 0 ] && skip_env "must run as root" && return
3331 lctl get_param -n devices | grep -q obdfilter && \
3332 skip "local OST" && return
3334 grep -q llite_lloop /proc/modules
3335 [ $? -ne 0 ] && skip_env "can't find module llite_lloop" && return
3337 [ -z "`$LCTL list_nids | grep -v tcp`" ] && \
3338 skip "can't reliably test swap with TCP" && return
3340 MEMTOTAL=`meminfo MemTotal`
3341 NR_BLOCKS=$((MEMTOTAL>>8))
3342 [[ $NR_BLOCKS -le 2048 ]] && NR_BLOCKS=2048
3344 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
3345 dd if=/dev/zero of=$DIR/f68 bs=64k seek=$NR_BLOCKS count=1
3348 $LCTL blockdev_attach $DIR/f68 $LLOOP || error "attach failed"
3350 trap cleanup_68 EXIT
3352 swapon -p 32767 $LLOOP || error "swapon $LLOOP failed"
3354 echo "before: `swapon -s | grep $LLOOP`"
3355 $MEMHOG $MEMTOTAL || error "error allocating $MEMTOTAL kB"
3356 echo "after: `swapon -s | grep $LLOOP`"
3357 SWAPUSED=`swap_used $LLOOP`
3361 [ $SWAPUSED -eq 0 ] && echo "no swap used???" || true
3363 run_test 68 "support swapping to Lustre ========================"
3365 # bug5265, obdfilter oa2dentry return -ENOENT
3366 # #define OBD_FAIL_OST_ENOENT 0x217
3368 remote_ost_nodsh && skip "remote OST with nodsh" && return
3371 $SETSTRIPE $f -c 1 -i 0
3373 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
3375 #define OBD_FAIL_OST_ENOENT 0x217
3376 do_facet ost1 lctl set_param fail_loc=0x217
3377 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
3378 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
3380 do_facet ost1 lctl set_param fail_loc=0
3381 $DIRECTIO write $f 0 2 || error "write error"
3383 cancel_lru_locks osc
3384 $DIRECTIO read $f 0 1 || error "read error"
3386 #define OBD_FAIL_OST_ENOENT 0x217
3387 do_facet ost1 lctl set_param fail_loc=0x217
3388 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
3390 do_facet ost1 lctl set_param fail_loc=0
3393 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
3397 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
3399 run_test 71 "Running dbench on lustre (don't segment fault) ===="
3402 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
3403 check_kernel_version 43 || return 0
3404 [ "$RUNAS_ID" = "$UID" ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
3406 # Check that testing environment is properly set up. Skip if not
3407 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS || {
3408 skip_env "User $RUNAS_ID does not exist - skipping"
3414 $RUNAS dd if=/dev/zero of=$DIR/f72 bs=512 count=1 || error
3415 # See if we are still setuid/sgid
3416 test -u $DIR/f72 -o -g $DIR/f72 && error "S/gid is not dropped on write"
3417 # Now test that MDS is updated too
3418 cancel_lru_locks mdc
3419 test -u $DIR/f72 -o -g $DIR/f72 && error "S/gid is not dropped on MDS"
3422 run_test 72a "Test that remove suid works properly (bug5695) ===="
3424 test_72b() { # bug 24226 -- keep mode setting when size is not changing
3427 [ "$RUNAS_ID" = "$UID" ] && \
3428 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
3429 [ "$RUNAS_ID" -eq 0 ] && \
3430 skip_env "RUNAS_ID = 0 -- skipping" && return
3432 # Check that testing environment is properly set up. Skip if not
3433 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS || {
3434 skip_env "User $RUNAS_ID does not exist - skipping"
3437 touch $DIR/${tfile}-f{g,u}
3438 mkdir $DIR/${tfile}-d{g,u}
3439 chmod 770 $DIR/${tfile}-{f,d}{g,u}
3440 chmod g+s $DIR/${tfile}-{f,d}g
3441 chmod u+s $DIR/${tfile}-{f,d}u
3442 for perm in 777 2777 4777; do
3443 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
3444 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
3445 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
3446 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
3450 run_test 72b "Test that we keep mode setting when not changing size (bug 24226)"
3452 # bug 3462 - multiple simultaneous MDC requests
3456 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
3459 #define OBD_FAIL_MDS_PAUSE_OPEN 0x129
3460 lctl set_param fail_loc=0x80000129
3461 multiop $DIR/d73-1/f73-2 Oc &
3463 lctl set_param fail_loc=0
3465 multiop $DIR/d73-2/f73-3 Oc &
3469 wait $pid1 || return 1
3473 $CHECKSTAT -t file $DIR/d73-1/f73-1 || error "$DIR/d73-1/f73-1 not file"
3474 $CHECKSTAT -t file $DIR/d73-1/f73-2 || error "$DIR/d73-1/f73-2 not file"
3475 $CHECKSTAT -t file $DIR/d73-2/f73-3 || error "$DIR/d73-2/f73-3 not file"
3479 run_test 73 "multiple MDC requests (should not deadlock)"
3481 test_74a() { # bug 6149, 6184
3482 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
3484 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
3485 # will spin in a tight reconnection loop
3487 lctl set_param fail_loc=0x8000030e
3488 # get any lock that won't be difficult - lookup works.
3490 lctl set_param fail_loc=0
3493 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
3495 test_74b() { # bug 13310
3496 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
3498 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
3499 # will spin in a tight reconnection loop
3500 lctl set_param fail_loc=0x8000030e
3501 # get a "difficult" lock
3503 lctl set_param fail_loc=0
3506 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
3508 JOIN=${JOIN:-"lfs join"}
3515 [ $T75_PREP = "yes" ] && return
3516 echo "using F75=$F75, F128k=$F128k, FHEAD=$FHEAD, FTAIL=$FTAIL"
3518 dd if=/dev/urandom of=${F75}_128k bs=128k count=1 || error "dd failed"
3527 cp -p ${F128k} ${FHEAD}
3528 log "finished cp to $FHEAD"
3529 cp -p ${F128k} ${FTAIL}
3530 log "finished cp to $FTAIL"
3531 cat ${F128k} ${F128k} > ${F75}_sim_sim
3533 $JOIN ${FHEAD} ${FTAIL} || error "join ${FHEAD} ${FTAIL} error"
3534 log "finished join $FHEAD to ${F75}_sim_sim"
3535 cmp ${FHEAD} ${F75}_sim_sim || error "${FHEAD} ${F75}_sim_sim differ"
3536 log "finished cmp $FHEAD to ${F75}_sim_sim"
3537 $CHECKSTAT -a ${FTAIL} || error "tail ${FTAIL} still exist after join"
3539 run_test 75a "TEST join file ===================================="
3544 cp -p ${F128k} ${FTAIL}
3545 cat ${F75}_sim_sim >> ${F75}_join_sim
3546 cat ${F128k} >> ${F75}_join_sim
3547 $JOIN ${FHEAD} ${FTAIL} || error "join ${FHEAD} ${FTAIL} error"
3548 cmp ${FHEAD} ${F75}_join_sim || \
3549 error "${FHEAD} ${F75}_join_sim are different"
3550 $CHECKSTAT -a ${FTAIL} || error "tail ${FTAIL} exist after join"
3552 run_test 75b "TEST join file 2 =================================="
3557 cp -p ${F128k} ${FTAIL}
3558 cat ${F128k} >> ${F75}_sim_join
3559 cat ${F75}_join_sim >> ${F75}_sim_join
3560 $JOIN ${FTAIL} ${FHEAD} || error "join error"
3561 cmp ${FTAIL} ${F75}_sim_join || \
3562 error "${FTAIL} ${F75}_sim_join are different"
3563 $CHECKSTAT -a ${FHEAD} || error "tail ${FHEAD} exist after join"
3565 run_test 75c "TEST join file 3 =================================="
3570 cp -p ${F128k} ${FHEAD}
3571 cp -p ${F128k} ${FHEAD}_tmp
3572 cat ${F75}_sim_sim >> ${F75}_join_join
3573 cat ${F75}_sim_join >> ${F75}_join_join
3574 $JOIN ${FHEAD} ${FHEAD}_tmp || error "join ${FHEAD} ${FHEAD}_tmp error"
3575 $JOIN ${FHEAD} ${FTAIL} || error "join ${FHEAD} ${FTAIL} error"
3576 cmp ${FHEAD} ${F75}_join_join ||error "${FHEAD} ${F75}_join_join differ" $CHECKSTAT -a ${FHEAD}_tmp || error "${FHEAD}_tmp exist after join"
3577 $CHECKSTAT -a ${FTAIL} || error "tail ${FTAIL} exist after join (2)"
3579 run_test 75d "TEST join file 4 =================================="
3584 rm -rf ${FHEAD} || "delete join file error"
3586 run_test 75e "TEST join file 5 (remove joined file) ============="
3591 cp -p ${F128k} ${F75}_join_10_compare
3592 cp -p ${F128k} ${F75}_join_10
3593 for ((i = 0; i < 10; i++)); do
3594 cat ${F128k} >> ${F75}_join_10_compare
3595 cp -p ${F128k} ${FTAIL}
3596 $JOIN ${F75}_join_10 ${FTAIL} || \
3597 error "join ${F75}_join_10 ${FTAIL} error"
3598 $CHECKSTAT -a ${FTAIL} || error "tail file exist after join"
3600 cmp ${F75}_join_10 ${F75}_join_10_compare || \
3601 error "files ${F75}_join_10 ${F75}_join_10_compare differ"
3603 run_test 75f "TEST join file 6 (join 10 files) =================="
3606 [ ! -f ${F75}_join_10 ] && echo "${F75}_join_10 missing" && return
3607 $LFS getstripe ${F75}_join_10
3609 $OPENUNLINK ${F75}_join_10 ${F75}_join_10 || error "files unlink open"
3613 run_test 75g "TEST join file 7 (open unlink) ===================="
3616 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
3619 get_inode_slab_tunables() {
3620 awk '/lustre_inode_cache/ {print $9," ",$10," ",$11; exit}' /proc/slabinfo
3623 set_inode_slab_tunables() {
3624 echo "lustre_inode_cache $1" > /proc/slabinfo
3627 test_76() { # Now for bug 20433, added originally in bug 1443
3628 local SLAB_SETTINGS=`get_inode_slab_tunables`
3629 local CPUS=`getconf _NPROCESSORS_ONLN`
3630 # we cannot set limit below 1 which means 1 inode in each
3631 # per-cpu cache is still allowed
3632 set_inode_slab_tunables "1 1 0"
3633 cancel_lru_locks osc
3634 BEFORE_INODES=`num_inodes`
3635 echo "before inodes: $BEFORE_INODES"
3637 [ "$SLOW" = "no" ] && COUNT=100
3638 for i in `seq $COUNT`; do
3642 cancel_lru_locks osc
3643 AFTER_INODES=`num_inodes`
3644 echo "after inodes: $AFTER_INODES"
3646 while [ $((AFTER_INODES-1*CPUS)) -gt $BEFORE_INODES ]; do
3648 AFTER_INODES=`num_inodes`
3650 echo "wait $wait seconds inodes: $AFTER_INODES"
3651 if [ $wait -gt 30 ]; then
3652 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
3655 set_inode_slab_tunables "$SLAB_SETTINGS"
3657 run_test 76 "confirm clients recycle inodes properly ===="
3662 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums |
3665 lctl set_param -n osc.*.checksums=$1
3669 export ORIG_CSUM_TYPE=""
3670 CKSUM_TYPES=${CKSUM_TYPES:-"crc32 adler"}
3673 [ "$ORIG_CSUM_TYPE" ] || \
3674 ORIG_CSUM_TYPE=`lctl get_param -n osc.*osc-[^mM]*.checksum_type | sed 's/.*\[\(.*\)\].*/\1/g' \
3676 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
3677 log "set checksum type to $1"
3680 F77_TMP=$TMP/f77-temp
3683 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
3684 error "error writing to $F77_TMP"
3687 test_77a() { # bug 10889
3688 [ ! -f $F77_TMP ] && setup_f77
3690 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
3693 run_test 77a "normal checksum read/write operation ============="
3695 test_77b() { # bug 10889
3696 [ ! -f $F77_TMP ] && setup_f77
3697 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
3698 lctl set_param fail_loc=0x80000409
3700 dd if=$F77_TMP of=$DIR/f77b bs=1M count=$F77SZ conv=sync || \
3701 error "dd error: $?"
3702 lctl set_param fail_loc=0
3705 run_test 77b "checksum error on client write ===================="
3707 test_77c() { # bug 10889
3708 [ ! -f $DIR/f77b ] && skip "requires 77b - skipping" && return
3710 for algo in $CKSUM_TYPES; do
3711 cancel_lru_locks osc
3712 set_checksum_type $algo
3713 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
3714 lctl set_param fail_loc=0x80000408
3715 cmp $F77_TMP $DIR/f77b || error "file compare failed"
3716 lctl set_param fail_loc=0
3719 set_checksum_type $ORIG_CSUM_TYPE
3721 run_test 77c "checksum error on client read ==================="
3723 test_77d() { # bug 10889
3724 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
3725 lctl set_param fail_loc=0x80000409
3727 directio write $DIR/f77 0 $F77SZ $((1024 * 1024)) || \
3728 error "direct write: rc=$?"
3729 lctl set_param fail_loc=0
3732 run_test 77d "checksum error on OST direct write ==============="
3734 test_77e() { # bug 10889
3735 [ ! -f $DIR/f77 ] && skip "requires 77d - skipping" && return
3736 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
3737 lctl set_param fail_loc=0x80000408
3739 cancel_lru_locks osc
3740 directio read $DIR/f77 0 $F77SZ $((1024 * 1024)) || \
3741 error "direct read: rc=$?"
3742 lctl set_param fail_loc=0
3745 run_test 77e "checksum error on OST direct read ================"
3747 test_77f() { # bug 10889
3749 for algo in $CKSUM_TYPES; do
3750 cancel_lru_locks osc
3751 set_checksum_type $algo
3752 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
3753 lctl set_param fail_loc=0x409
3754 directio write $DIR/f77 0 $F77SZ $((1024 * 1024)) && \
3755 error "direct write succeeded"
3756 lctl set_param fail_loc=0
3758 set_checksum_type $ORIG_CSUM_TYPE
3761 run_test 77f "repeat checksum error on write (expect error) ===="
3763 test_77g() { # bug 10889
3764 remote_ost_nodsh && skip "remote OST with nodsh" && return
3766 [ ! -f $F77_TMP ] && setup_f77
3768 $SETSTRIPE $DIR/f77g -c 1 -i 0
3769 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
3770 do_facet ost1 lctl set_param fail_loc=0x8000021a
3772 dd if=$F77_TMP of=$DIR/f77g bs=1M count=$F77SZ || \
3773 error "write error: rc=$?"
3774 do_facet ost1 lctl set_param fail_loc=0
3777 run_test 77g "checksum error on OST write ======================"
3779 test_77h() { # bug 10889
3780 remote_ost_nodsh && skip "remote OST with nodsh" && return
3782 [ ! -f $DIR/f77g ] && skip "requires 77g - skipping" && return
3783 cancel_lru_locks osc
3784 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
3785 do_facet ost1 lctl set_param fail_loc=0x8000021b
3787 cmp $F77_TMP $DIR/f77g || error "file compare failed"
3788 do_facet ost1 lctl set_param fail_loc=0
3791 run_test 77h "checksum error on OST read ======================="
3793 test_77i() { # bug 13805
3794 #define OBD_FAIL_OSC_CONNECT_CKSUM 0x40b
3795 lctl set_param fail_loc=0x40b
3796 remount_client $MOUNT
3797 lctl set_param fail_loc=0
3798 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
3799 param=`echo ${VALUE[0]} | cut -d "=" -f1`
3800 algo=`lctl get_param -n $param | sed 's/.*\[\(.*\)\].*/\1/g'`
3801 [ "$algo" = "crc32" ] || error "algo set to $algo instead of crc32"
3803 remount_client $MOUNT
3805 run_test 77i "client not supporting OSD_CONNECT_CKSUM =========="
3807 test_77j() { # bug 13805
3808 #define OBD_FAIL_OSC_CKSUM_ADLER_ONLY 0x40c
3809 lctl set_param fail_loc=0x40c
3810 remount_client $MOUNT
3811 lctl set_param fail_loc=0
3812 sleep 2 # wait async osc connect to finish
3813 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
3814 param=`echo ${VALUE[0]} | cut -d "=" -f1`
3815 algo=`lctl get_param -n $param | sed 's/.*\[\(.*\)\].*/\1/g'`
3816 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
3818 remount_client $MOUNT
3820 run_test 77j "client only supporting ADLER32 ===================="
3822 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
3826 test_78() { # bug 10901
3827 remote_ost || { skip_env "local OST" && return; }
3829 cancel_lru_locks osc
3831 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
3832 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
3833 # directio allocates the buffer twice, one for writes and another
3834 # one for reads, so that it can check the data consistency
3835 F78SIZE=$((F78SIZE / 2))
3836 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
3837 echo "MemTotal: $MEMTOTAL"
3838 # reserve 256MB of memory for the kernel and other running processes,
3839 # and then take 1/2 of the remaining memory for the read/write buffers.
3840 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
3841 echo "Mem to use for directio: $MEMTOTAL"
3842 [ $F78SIZE -gt $MEMTOTAL ] && F78SIZE=$MEMTOTAL
3843 [ $F78SIZE -gt 512 ] && F78SIZE=512
3844 [ $F78SIZE -gt $((MAXFREE / 1024)) ] && F78SIZE=$((MAXFREE / 1024))
3845 SMALLESTOST=`lfs df $DIR |grep OST | awk '{print $4}' |sort -n |head -1`
3846 echo "Smallest OST: $SMALLESTOST"
3847 [ $SMALLESTOST -lt 10240 ] && \
3848 skip "too small OSTSIZE, useless to run large O_DIRECT test" && return 0
3850 [ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 5)) ] && \
3851 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 5))
3852 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
3853 echo "File size: $F78SIZE"
3854 $SETSTRIPE $DIR/$tfile -c -1 || error "setstripe failed"
3855 for i in `seq 1 $NSEQ`
3857 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
3858 echo directIO rdwr round $i of $NSEQ
3859 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
3864 run_test 78 "handle large O_DIRECT writes correctly ============"
3866 test_79() { # bug 12743
3867 wait_delete_completed
3869 BKTOTAL=$(calc_osc_kbytes kbytestotal)
3870 BKFREE=$(calc_osc_kbytes kbytesfree)
3871 BKAVAIL=$(calc_osc_kbytes kbytesavail)
3872 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
3873 DFTOTAL=`echo $STRING | cut -d, -f1`
3874 DFUSED=`echo $STRING | cut -d, -f2`
3875 DFAVAIL=`echo $STRING | cut -d, -f3`
3876 DFFREE=$(($DFTOTAL - $DFUSED))
3878 ALLOWANCE=$((64 * $OSTCOUNT))
3880 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
3881 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
3882 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
3884 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
3885 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
3886 error "df free($DFFREE) mismatch OST free($BKFREE)"
3888 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
3889 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
3890 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
3893 run_test 79 "df report consistency check ======================="
3895 test_80() { # bug 10718
3896 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
3898 local BEFORE=`date +%s`
3899 cancel_lru_locks osc
3900 local AFTER=`date +%s`
3901 local DIFF=$((AFTER-BEFORE))
3902 if [ $DIFF -gt 1 ] ; then
3903 error "elapsed for 1M@1T = $DIFF"
3907 run_test 80 "Page eviction is equally fast at high offsets too ===="
3909 test_81a() { # LU-456
3910 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
3911 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
3912 do_facet ost0 lctl set_param fail_loc=0x80000228
3914 # write should trigger a retry and success
3915 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
3916 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
3918 if [ $RC -ne 0 ] ; then
3919 error "write should success, but failed for $RC"
3922 run_test 81a "OST should retry write when get -ENOSPC ==============="
3924 test_81b() { # LU-456
3925 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
3926 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
3927 do_facet ost0 lctl set_param fail_loc=0x228
3929 # write should retry several times and return -ENOSPC finally
3930 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
3931 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
3934 if [ $RC -ne $ENOSPC ] ; then
3935 error "write should fail for -ENOSPC, but succeed."
3938 run_test 81b "OST should return -ENOSPC when retry still fails ======="
3941 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
3942 mkdir -p $DIR/d99cvsroot || error "mkdir $DIR/d99cvsroot failed"
3943 chown $RUNAS_ID $DIR/d99cvsroot || error "chown $DIR/d99cvsroot failed"
3944 local oldPWD=$PWD # bug 13584, use $TMP as working dir
3947 $RUNAS cvs -d $DIR/d99cvsroot init || error "cvs init failed"
3950 run_test 99a "cvs init ========================================="
3953 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
3954 [ ! -d $DIR/d99cvsroot ] && test_99a
3955 $RUNAS [ ! -w /tmp ] && skip "/tmp has wrong w permission -- skipping" && return
3956 cd /etc/init.d || error "cd /etc/init.d failed"
3957 # some versions of cvs import exit(1) when asked to import links or
3958 # files they can't read. ignore those files.
3959 TOIGNORE=$(find . -type l -printf '-I %f\n' -o \
3960 ! -perm +4 -printf '-I %f\n')
3961 $RUNAS cvs -d $DIR/d99cvsroot import -m "nomesg" $TOIGNORE \
3962 d99reposname vtag rtag > /dev/null || error "cvs import failed"
3964 run_test 99b "cvs import ======================================="
3967 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
3968 [ ! -d $DIR/d99cvsroot ] && test_99b
3969 cd $DIR || error "cd $DIR failed"
3970 mkdir -p $DIR/d99reposname || error "mkdir $DIR/d99reposname failed"
3971 chown $RUNAS_ID $DIR/d99reposname || \
3972 error "chown $DIR/d99reposname failed"
3973 $RUNAS cvs -d $DIR/d99cvsroot co d99reposname > /dev/null || \
3974 error "cvs co d99reposname failed"
3976 run_test 99c "cvs checkout ====================================="
3979 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
3980 [ ! -d $DIR/d99cvsroot ] && test_99c
3981 cd $DIR/d99reposname
3983 $RUNAS cvs add -m 'addmsg' foo99
3985 run_test 99d "cvs add =========================================="
3988 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
3989 [ ! -d $DIR/d99cvsroot ] && test_99c
3990 cd $DIR/d99reposname
3993 run_test 99e "cvs update ======================================="
3996 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
3997 [ ! -d $DIR/d99cvsroot ] && test_99d
3998 cd $DIR/d99reposname
3999 $RUNAS cvs commit -m 'nomsg' foo99
4001 run_test 99f "cvs commit ======================================="
4004 [ "$NETTYPE" = tcp ] || \
4005 { skip "TCP secure port test, not useful for NETTYPE=$NETTYPE" && \
4008 remote_ost_nodsh && skip "remote OST with nodsh" && return
4009 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4011 { skip "useless for local single node setup" && return; }
4013 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
4014 [ "$PROT" != "tcp" ] && continue
4015 RPORT=$(echo $REMOTE | cut -d: -f2)
4016 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
4019 LPORT=`echo $LOCAL | cut -d: -f2`
4020 if [ $LPORT -ge 1024 ]; then
4021 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
4023 error_exit "local: $LPORT > 1024, remote: $RPORT"
4026 [ "$rc" = 0 ] || error_exit "privileged port not found" )
4028 run_test 100 "check local port using privileged port ==========="
4030 function get_named_value()
4039 echo $line | sed "s/^$tag[ ]*//"
4046 export CACHE_MAX=`$LCTL get_param -n llite/*/max_cached_mb | head -n 1`
4048 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
4056 [ "$CPU" = "UML" ] && nreads=1000
4057 local cache_limit=32
4059 $LCTL set_param -n osc.*.rpc_stats 0
4060 trap cleanup_101a EXIT
4062 $LCTL set_param -n llite.*.read_ahead_stats 0
4063 $LCTL set_param -n llite.*.max_cached_mb $cache_limit
4066 # randomly read 10000 of 64K chunks from file 3x 32MB in size
4068 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
4069 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
4072 for s in `$LCTL get_param -n llite.*.read_ahead_stats | \
4073 get_named_value 'read but discarded' | cut -d" " -f1`; do
4074 discard=$(($discard + $s))
4079 if [ $(($discard * 10)) -gt $nreads ] ;then
4080 $LCTL get_param osc.*.rpc_stats
4081 $LCTL get_param llite.*.read_ahead_stats
4082 error "too many ($discard) discarded pages"
4084 rm -f $DIR/$tfile || true
4086 run_test 101a "check read-ahead for random reads ================"
4091 STRIPE_COUNT=$OSTCOUNT
4094 $LCTL set_param -n obdfilter.*.read_cache_enable=0
4095 $LCTL set_param -n obdfilter.*.writethrough_cache_enable=0
4096 trap cleanup_test101bc EXIT
4097 # prepare the read-ahead file
4098 $SETSTRIPE $DIR/$tfile -s $STRIPE_SIZE -i $STRIPE_OFFSET -c $OSTCOUNT
4100 dd if=/dev/zero of=$DIR/$tfile bs=1024k count=100 2> /dev/null
4103 cleanup_test101bc() {
4107 $LCTL set_param -n obdfilter.*.read_cache_enable=1
4108 $LCTL set_param -n obdfilter.*.writethrough_cache_enable=1
4112 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
4117 local STRIPE_SIZE=1048576
4118 local RA_INC=1048576
4119 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
4120 local FILE_LENGTH=$((64*100))
4121 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
4122 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
4124 DISCARD=`$LCTL get_param -n llite.*.read_ahead_stats | \
4125 get_named_value 'read but discarded' | \
4126 cut -d" " -f1 | calc_total`
4128 if [ $DISCARD -gt $discard_limit ]; then
4129 $LCTL get_param llite.*.read_ahead_stats
4130 error "Too many ($DISCARD) discarded pages with size $READ_SIZE"
4132 echo "Read-ahead success for size ${READ_SIZE}"
4137 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs for stride-read" && return
4138 local STRIPE_SIZE=1048576
4139 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
4140 local FILE_LENGTH=$((STRIPE_SIZE*100))
4141 local ITERATION=$((FILE_LENGTH/STRIDE_SIZE))
4142 # prepare the read-ahead file
4144 cancel_lru_locks osc
4145 for BIDX in 2 4 8 16 32 64 128 256; do
4146 local BSIZE=$((BIDX*4096))
4147 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
4148 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
4149 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
4150 $LCTL set_param -n llite.*.read_ahead_stats 0
4151 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
4152 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
4153 cancel_lru_locks osc
4154 ra_check_101b $BSIZE
4159 run_test 101b "check stride-io mode read-ahead ================="
4162 local STRIPE_SIZE=1048576
4163 local FILE_LENGTH=$((STRIPE_SIZE*100))
4167 cancel_lru_locks osc
4168 $LCTL set_param osc.*.rpc_stats 0
4169 $READS -f $DIR/$tfile -s$FILE_LENGTH -b65536 -n$nreads -t 180
4170 for OSC in `$LCTL get_param -N osc.*`; do
4171 if [ "$OSC" == "osc.num_refs" ]; then
4175 lines=`$LCTL get_param -n ${OSC}.rpc_stats | wc | awk '{print $1}'`
4176 if [ $lines -le 20 ]; then
4180 rpc4k=$($LCTL get_param -n ${OSC}.rpc_stats | awk '$1 == "1:" { print $2; exit; }')
4181 rpc8k=$($LCTL get_param -n ${OSC}.rpc_stats | awk '$1 == "2:" { print $2; exit; }')
4182 rpc16k=$($LCTL get_param -n ${OSC}.rpc_stats | awk '$1 == "4:" { print $2; exit; }')
4183 rpc32k=$($LCTL get_param -n ${OSC}.rpc_stats | awk '$1 == "8:" { print $2; exit; }')
4185 [ $rpc4k != 0 ] && error "Small 4k read IO ${rpc4k}!"
4186 [ $rpc8k != 0 ] && error "Small 8k read IO ${rpc8k}!"
4187 [ $rpc16k != 0 ] && error "Small 16k read IO ${rpc16k}!"
4188 [ $rpc32k != 0 ] && error "Small 32k read IO ${rpc32k}!"
4190 echo "${OSC} RPC check passed!"
4195 run_test 101c "check stripe_size aligned read-ahead ================="
4198 $LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1
4199 $LCTL set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
4203 local file=$DIR/$tfile
4204 local size=${FILESIZE_101c:-500}
4205 local ra_MB=${READAHEAD_MB:-40}
4207 local space=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
4208 [ $space -gt $((size / 1024)) ] ||
4209 { skip "Need free space ${size}M, have $space" && return; }
4211 echo Creating ${size}M test file $file
4212 dd if=/dev/zero of=$file bs=1M count=$size
4213 echo Cancel LRU locks on lustre client to flush the client cache
4214 cancel_lru_locks osc
4216 echo Disable read-ahead
4217 local old_READAHEAD=$(set_read_ahead 0)
4219 echo Reading the test file $file with read-ahead disabled
4220 time_ra_OFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$size")
4222 echo Cancel LRU locks on lustre client to flush the client cache
4223 cancel_lru_locks osc
4224 echo Enable read-ahead with ${ra_MB}MB
4225 set_read_ahead $ra_MB
4227 echo Reading the test file $file with read-ahead enabled
4228 time_ra_ON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$size")
4230 echo read-ahead disabled time read $time_ra_OFF
4231 echo read-ahead enabled time read $time_ra_ON
4233 set_read_ahead $old_READAHEAD
4236 [ $time_ra_ON -lt $time_ra_OFF ] ||
4237 error "read-ahead enabled time read (${time_ra_ON}s) is more than
4238 read-ahead disabled time read (${time_ra_OFF}s) filesize ${size}M"
4240 run_test 101d "file read with and without read-ahead enabled ================="
4243 local file=$DIR/$tfile
4248 local space=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
4249 local need_space=$((count * size))
4250 [ $space -gt $need_space ] ||
4251 { skip "Need free space $need_space, have $space" && return; }
4253 echo Creating $count ${size}K test files
4254 for ((i=0;i<$count;i++)); do
4255 dd if=/dev/zero of=${file}_${i} bs=$blksize count=$size 2>/dev/null
4258 echo Cancel LRU locks on lustre client to flush the client cache
4259 cancel_lru_locks osc
4261 echo Reset readahead stats
4262 $LCTL set_param -n llite.*.read_ahead_stats 0
4264 for ((i=0;i<$count;i++)); do
4265 dd if=${file}_${i} of=/dev/null bs=$blksize count=$size 2>/dev/null
4268 MISS=`$LCTL get_param -n llite.*.read_ahead_stats | \
4269 get_named_value 'misses' | cut -d" " -f1 | calc_total`
4271 for ((i=0;i<$count;i++)); do
4272 rm -rf ${file}_${i} 2>/dev/null
4275 #10000 means 20% reads are missing in readahead
4276 [ $MISS -lt 10000 ] || error "misses too much for small reads"
4278 run_test 101e "check read-ahead for small read(1k) for small files(500k) ============"
4282 chown $RUNAS_ID $DIR/$tdir
4285 STRIPE_COUNT=$OSTCOUNT
4286 [ $OSTCOUNT -gt 4 ] && STRIPE_COUNT=4
4288 trap cleanup_test102 EXIT
4290 $1 $SETSTRIPE $tdir -s $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT
4294 for count in `seq 1 $STRIPE_COUNT`
4296 for offset in `seq 0 $[$STRIPE_COUNT - 1]`
4298 local stripe_size=`expr $STRIPE_SIZE \* $num`
4299 local file=file"$num-$offset-$count"
4300 $1 $SETSTRIPE $file -s $stripe_size -i $offset -c $count
4306 $1 $TAR cf $TMP/f102.tar $tdir --xattrs
4311 rm -f $TMP/f102.tar $DIR/f102*
4312 rm -rf $DIR/d0.$TESTSUITE/d102 $DIR/d102*
4316 local testfile=$DIR/xattr_testfile
4321 [ "$UID" != 0 ] && skip_env "must run as root" && return
4322 [ -z "`lctl get_param -n mdc.*.connect_flags | grep xattr`" ] &&
4323 skip_env "must have user_xattr" && return
4324 [ -z "$(which setfattr 2>/dev/null)" ] && skip_env "could not find setfattr" && return
4326 echo "set/get xattr..."
4327 setfattr -n trusted.name1 -v value1 $testfile || error
4328 [ "`getfattr -n trusted.name1 $testfile 2> /dev/null | \
4329 grep "trusted.name1"`" == "trusted.name1=\"value1\"" ] || error
4331 setfattr -n user.author1 -v author1 $testfile || error
4332 [ "`getfattr -n user.author1 $testfile 2> /dev/null | \
4333 grep "user.author1"`" == "user.author1=\"author1\"" ] || error
4336 setfattr -n trusted.name2 -v value2 $testfile || error
4337 setfattr -n trusted.name3 -v value3 $testfile || error
4338 [ `getfattr -d -m "^trusted" $testfile 2> /dev/null | \
4339 grep "trusted.name" | wc -l` -eq 3 ] || error
4342 setfattr -n user.author2 -v author2 $testfile || error
4343 setfattr -n user.author3 -v author3 $testfile || error
4344 [ `getfattr -d -m "^user" $testfile 2> /dev/null | \
4345 grep "user" | wc -l` -eq 3 ] || error
4347 echo "remove xattr..."
4348 setfattr -x trusted.name1 $testfile || error
4349 getfattr -d -m trusted $testfile 2> /dev/null | \
4350 grep "trusted.name1" && error || true
4352 setfattr -x user.author1 $testfile || error
4353 getfattr -d -m user $testfile 2> /dev/null | \
4354 grep "user.author1" && error || true
4356 # b10667: setting lustre special xattr be silently discarded
4357 echo "set lustre special xattr ..."
4358 setfattr -n "trusted.lov" -v "invalid value" $testfile || error
4362 run_test 102a "user xattr test =================================="
4365 # b10930: get/set/list trusted.lov xattr
4366 echo "get/set/list trusted.lov xattr ..."
4367 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
4368 local testfile=$DIR/$tfile
4369 $SETSTRIPE -s 65536 -i 1 -c 2 $testfile || error "setstripe failed"
4370 getfattr -d -m "^trusted" $testfile 2> /dev/null | \
4371 grep "trusted.lov" || error "can't get trusted.lov from $testfile"
4373 local testfile2=${testfile}2
4374 local value=`getfattr -n trusted.lov $testfile 2> /dev/null | \
4375 grep "trusted.lov" |sed -e 's/[^=]\+=//'`
4378 setfattr -n trusted.lov -v $value $testfile2
4379 local tmp_file=${testfile}3
4380 $GETSTRIPE -v $testfile2 > $tmp_file
4381 local stripe_size=`grep "size" $tmp_file| awk '{print $2}'`
4382 local stripe_count=`grep "count" $tmp_file| awk '{print $2}'`
4383 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
4384 [ $stripe_count -eq 2 ] || error "stripe count $stripe_count != 2"
4386 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
4389 # b10930: get/set/list lustre.lov xattr
4390 echo "get/set/list lustre.lov xattr ..."
4391 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
4393 chown $RUNAS_ID $DIR/$tdir
4394 local testfile=$DIR/$tdir/$tfile
4395 $RUNAS $SETSTRIPE -s 65536 -i 1 -c 2 $testfile||error "setstripe failed"
4396 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
4397 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
4399 local testfile2=${testfile}2
4400 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
4401 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
4403 $RUNAS $MCREATE $testfile2
4404 $RUNAS setfattr -n lustre.lov -v $value $testfile2
4405 local tmp_file=${testfile}3
4406 $RUNAS $GETSTRIPE -v $testfile2 > $tmp_file
4407 local stripe_size=`grep "size" $tmp_file| awk '{print $2}'`
4408 local stripe_count=`grep "count" $tmp_file| awk '{print $2}'`
4409 [ "$stripe_size" -eq 65536 ] || error "stripe size $stripe_size != 65536"
4410 [ "$stripe_count" -eq 2 ] || error "stripe count $stripe_count != 2"
4412 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
4414 compare_stripe_info1() {
4415 local stripe_index_all_zero=1
4419 for count in `seq 1 $STRIPE_COUNT`
4421 for offset in `seq 0 $[$STRIPE_COUNT - 1]`
4423 local size=`expr $STRIPE_SIZE \* $num`
4424 local file=file"$num-$offset-$count"
4425 get_stripe_info client $PWD/$file "$1"
4426 if [ $stripe_size -ne $size ]; then
4427 error "$file: different stripe size $stripe_size, expected $size" && return
4429 if [ $stripe_count -ne $count ]; then
4430 error "$file: different stripe count $stripe_count, expected $count" && return
4432 if [ $stripe_index -ne 0 ]; then
4433 stripe_index_all_zero=0
4438 [ $stripe_index_all_zero -eq 1 ] && error "all files are being extracted starting from OST index 0"
4443 [ -n "$(which tar 2>/dev/null)" ] && strings $(which tar) | grep -q lustre && echo tar
4447 # b10930: tar test for trusted.lov xattr
4448 TAR=$(find_lustre_tar)
4449 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
4450 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
4453 $TAR xf $TMP/f102.tar -C $DIR/d102d --xattrs
4455 compare_stripe_info1
4457 run_test 102d "tar restore stripe info from tarfile,not keep osts ==========="
4460 # b10930: tar test for trusted.lov xattr
4461 TAR=$(find_lustre_tar)
4462 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
4463 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
4467 $TAR cf - --xattrs $tdir | $TAR xf - --xattrs -C $DIR/d102f
4469 compare_stripe_info1
4471 run_test 102f "tar copy files, not keep osts ==========="
4473 test_102h() { # bug 15777
4474 [ -z $(lctl get_param -n mdc.*.connect_flags | grep xattr) ] &&
4475 skip "must have user_xattr" && return
4476 [ -z "$(which setfattr 2>/dev/null)" ] &&
4477 skip_env "could not find setfattr" && return
4482 VALUE=datadatadatadatadatadatadatadata
4483 while [ $(echo $VALUE | wc -c) -lt $XSIZE ]; do
4484 VALUE="$VALUE$VALUE"
4486 log "save $XBIG on $DIR/$tfile"
4487 setfattr -n $XBIG -v "$VALUE" $DIR/$tfile ||
4488 error "saving $XBIG on $DIR/$tfile failed"
4489 ORIG=$(getfattr -n $XBIG $DIR/$tfile 2> /dev/null | grep $XBIG)
4490 OSIZE=$(echo $ORIG | wc -c)
4491 [ $OSIZE -lt $XSIZE ] && error "set $XBIG too small ($OSIZE < $XSIZE)"
4494 log "save $XSML on $DIR/$tfile"
4495 setfattr -n $XSML -v val $DIR/$tfile ||
4496 error "saving $XSML on $DIR/$tfile failed"
4497 NEW=$(getfattr -n $XBIG $DIR/$tfile 2> /dev/null | grep $XBIG)
4498 if [ "$NEW" != "$ORIG" ]; then
4501 error "$XBIG different after saving $XSML"
4504 log "grow $XSML on $DIR/$tfile"
4505 setfattr -n $XSML -v "$VALUE" $DIR/$tfile ||
4506 error "growing $XSML on $DIR/$tfile failed"
4507 NEW=$(getfattr -n $XBIG $DIR/$tfile 2> /dev/null | grep $XBIG)
4508 if [ "$NEW" != "$ORIG" ]; then
4511 error "$XBIG different after growing $XSML"
4513 log "$XBIG still valid after growing $XSML"
4515 run_test 102h "grow xattr from inside inode to external block"
4517 test_102i() { # bug 17038
4519 ln -s $DIR/$tfile $DIR/${tfile}link
4520 getfattr -n trusted.lov $DIR/$tfile || error "lgetxattr on $DIR/$tfile failed"
4521 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"
4522 rm -f $DIR/$tfile $DIR/${tfile}link
4524 run_test 102i "lgetxattr test on symbolic link ============"
4527 TAR=$(find_lustre_tar)
4528 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
4529 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
4530 setup_test102 "$RUNAS"
4532 chown $RUNAS_ID $DIR/d102j
4533 $RUNAS $TAR xf $TMP/f102.tar -C $DIR/d102j --xattrs
4535 compare_stripe_info1 "$RUNAS"
4537 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
4541 # b22187 just check that does not crash for regular file.
4542 setfattr -n trusted.lov $DIR/$tfile
4543 # b22187 'setfattr -n trusted.lov' should work as remove LOV EA for directories
4544 local test_kdir=$DIR/d102k
4546 local default_size=`$GETSTRIPE -s $test_kdir`
4547 local default_count=`$GETSTRIPE -c $test_kdir`
4548 local default_offset=`$GETSTRIPE -o $test_kdir`
4549 $SETSTRIPE -s 65536 -i 1 -c $OSTCOUNT $test_kdir || error 'dir setstripe failed'
4550 setfattr -n trusted.lov $test_kdir
4551 local stripe_size=`$GETSTRIPE -s $test_kdir`
4552 local stripe_count=`$GETSTRIPE -c $test_kdir`
4553 local stripe_offset=`$GETSTRIPE -o $test_kdir`
4554 [ $stripe_size -eq $default_size ] || error "stripe size $stripe_size != $default_size"
4555 [ $stripe_count -eq $default_count ] || error "stripe count $stripe_count != $default_count"
4556 [ $stripe_offset -eq $default_offset ] || error "stripe offset $stripe_offset != $default_offset"
4557 rm -rf $DIR/$tfile $test_kdir
4559 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
4562 # LU-1838 trusted. xattr is invisible to non-root
4563 local testfile=$DIR/$tfile
4567 echo "listxattr as user..."
4568 chown $RUNAS_ID $testfile
4569 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
4570 grep -q "trusted" &&
4571 error "$testfile trusted xattrs are user visible"
4575 run_test 102l "listxattr filter test =================================="
4581 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
4586 [ "$UID" != 0 ] && skip_env "must run as root" && return
4587 [ -z "$(lctl get_param mdc.*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
4588 [ -z "$(which setfacl 2>/dev/null)" ] && skip_env "could not find setfacl" && return
4594 echo "performing cp ..."
4595 run_acl_subtest cp || error
4596 echo "performing getfacl-noacl..."
4597 run_acl_subtest getfacl-noacl > /dev/null || error "getfacl-noacl test failed"
4598 echo "performing misc..."
4599 run_acl_subtest misc > /dev/null || error "misc test failed"
4600 # XXX add back permission test when we support supplementary groups.
4601 # echo "performing permissions..."
4602 # run_acl_subtest permissions || error
4603 echo "performing setfacl..."
4604 run_acl_subtest setfacl > /dev/null || error "setfacl test failed"
4606 # inheritance test got from HP
4607 echo "performing inheritance..."
4608 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
4609 chmod +x make-tree || error "chmod +x failed"
4610 run_acl_subtest inheritance > /dev/null || error "inheritance test failed"
4616 run_test 103 "acl test ========================================="
4620 lfs df || error "lfs df failed"
4621 lfs df -ih || error "lfs df -ih failed"
4622 lfs df -h $DIR || error "lfs df -h $DIR failed"
4623 lfs df -i $DIR || error "lfs df -i $DIR failed"
4624 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
4625 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
4627 OSC=`lctl get_param -n devices | awk '/-osc-|OSC.*MNT/ {print $4}' | head -n 1`
4628 lctl --device %$OSC deactivate
4629 lfs df || error "lfs df with deactivated OSC failed"
4630 lctl --device %$OSC recover
4631 lfs df || error "lfs df with reactivated OSC failed"
4633 run_test 104a "lfs df [-ih] [path] test ========================="
4636 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4638 denied_cnt=$((`$RUNAS $LFS check servers 2>&1 | grep "Permission denied" | wc -l`))
4639 if [ $denied_cnt -ne 0 ];
4641 error "lfs check servers test failed"
4644 run_test 104b "$RUNAS lfs check servers test ===================="
4647 # doesn't work on 2.4 kernels
4649 if [ -n "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ];
4651 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
4653 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
4656 run_test 105a "flock when mounted without -o flock test ========"
4660 if [ -n "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ];
4662 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
4664 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
4667 run_test 105b "fcntl when mounted without -o flock test ========"
4671 if [ -n "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ];
4673 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
4675 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
4678 run_test 105c "lockf when mounted without -o flock test ========"
4680 test_105d() { # bug 15924
4682 [ -z "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ] && \
4683 skip "mount w/o flock enabled" && return
4684 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
4685 $LCTL set_param fail_loc=0x80000315
4686 flocks_test 2 $DIR/$tdir
4688 run_test 105d "flock race (should not freeze) ========"
4690 test_105e() { # bug 22660
4691 [ -z "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ] && \
4692 skip "mount w/o flock enabled" && return
4694 flocks_test 3 $DIR/$tfile
4696 run_test 105e "Two conflicting flocks from same process ======="
4698 test_106() { #bug 10921
4700 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
4701 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
4703 run_test 106 "attempt exec of dir followed by chown of that dir"
4712 local save_pattern=$(sysctl -n kernel.core_pattern)
4713 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
4714 sysctl -w kernel.core_pattern=$file
4715 sysctl -w kernel.core_uses_pid=0
4723 kill -s 11 $SLEEPPID
4725 if [ -e $file ]; then
4726 size=`stat -c%s $file`
4727 [ $size -eq 0 ] && error "Zero length core file $file"
4729 error "Fail to create core file $file"
4732 sysctl -w kernel.core_pattern=$save_pattern
4733 sysctl -w kernel.core_uses_pid=$save_uses_pid
4736 run_test 107 "Coredump on SIG"
4739 OSTIO_pre=$(ps -e|grep ll_ost_io|awk '{print $4}'|sort -n|tail -1|\
4741 [ -z "$OSTIO_pre" ] && skip "no OSS threads" && \
4743 echo "Starting with $OSTIO_pre threads"
4746 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
4747 [ $NUMFREE -lt $NUMTEST ] && NUMTEST=$(($NUMFREE - 1000))
4748 echo "$NUMTEST creates/unlinks"
4750 createmany -o $DIR/$tdir/$tfile $NUMTEST
4751 unlinkmany $DIR/$tdir/$tfile $NUMTEST
4753 OSTIO_post=$(ps -e|grep ll_ost_io|awk '{print $4}'|sort -n|tail -1|\
4756 # don't return an error
4757 [ $OSTIO_post -eq $OSTIO_pre ] && echo \
4758 "WARNING: No new ll_ost_io threads were created ($OSTIO_pre)" &&\
4759 echo "This may be fine, depending on what ran before this test" &&\
4760 echo "and how fast this system is." && return
4762 echo "Started with $OSTIO_pre threads, ended with $OSTIO_post"
4764 run_test 115 "verify dynamic thread creation===================="
4767 wait_delete_completed
4768 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC][-_]*.kbytesavail))
4769 echo OST kbytes available: ${AVAIL[@]}
4770 MAXI=0; MAXV=${AVAIL[0]}
4771 MINI=0; MINV=${AVAIL[0]}
4772 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
4773 #echo OST $i: ${AVAIL[i]}kb
4774 if [ ${AVAIL[i]} -gt $MAXV ]; then
4775 MAXV=${AVAIL[i]}; MAXI=$i
4777 if [ ${AVAIL[i]} -lt $MINV ]; then
4778 MINV=${AVAIL[i]}; MINI=$i
4781 echo Min free space: OST $MINI: $MINV
4782 echo Max free space: OST $MAXI: $MAXV
4786 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
4788 echo -n "Free space priority "
4789 lctl get_param -n lov.*.qos_prio_free
4792 [ $MINV -gt 960000 ] && skip "too much free space in OST$MINI" &&\
4795 # generate uneven OSTs
4796 mkdir -p $DIR/$tdir/OST${MINI}
4799 echo "Filling 25% remaining space in OST${MINI} with ${FILL}Kb"
4800 $SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI}||error "setstripe failed"
4802 while [ $FILL -gt 0 ]; do
4803 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i bs=2M count=1 2>/dev/null
4804 FILL=$(($FILL - 2048))
4813 DIFF=$(($MAXV - $MINV))
4814 DIFF2=$(($DIFF * 100 / $MINV))
4815 echo -n "diff=${DIFF}=${DIFF2}% must be > 20% for QOS mode..."
4816 if [ $DIFF2 -gt 20 ]; then
4819 echo "failed - QOS mode won't be used"
4820 error_ignore "QOS imbalance criteria not met"
4824 MINI1=$MINI; MINV1=$MINV
4825 MAXI1=$MAXI; MAXV1=$MAXV
4827 # now fill using QOS
4828 echo writing a bunch of files to QOS-assigned OSTs
4829 $SETSTRIPE $DIR/$tdir -c 1
4831 while [ $FILL -gt 0 ]; do
4832 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1024 count=200 2>/dev/null
4833 FILL=$(($FILL - 200))
4837 echo "wrote $i 200k files"
4841 echo "Note: free space may not be updated, so measurements might be off"
4843 DIFF2=$(($MAXV - $MINV))
4844 echo "free space delta: orig $DIFF final $DIFF2"
4845 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
4846 DIFF=$(($MINV1 - ${AVAIL[$MINI1]}))
4847 echo "Wrote $DIFF to smaller OST $MINI1"
4848 DIFF2=$(($MAXV1 - ${AVAIL[$MAXI1]}))
4849 echo "Wrote $DIFF2 to larger OST $MAXI1"
4850 [ $DIFF -gt 0 ] && echo "Wrote $(($DIFF2 * 100 / $DIFF - 100))% more data to larger OST $MAXI1"
4852 # Figure out which files were written where
4853 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd | awk '/'$MINI1': / {print $2; exit}')
4855 MINC=$($GETSTRIPE --obd $UUID $DIR/$tdir | wc -l)
4856 echo "$MINC files created on smaller OST $MINI1"
4857 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd | (awk '/'$MAXI1': / {print $2; exit}'))
4858 MAXC=$($GETSTRIPE --obd $UUID $DIR/$tdir | wc -l)
4859 echo "$MAXC files created on larger OST $MAXI1"
4860 [ $MINC -gt 0 ] && echo "Wrote $(($MAXC * 100 / $MINC - 100))% more files to larger OST $MAXI1"
4861 [ $MAXC -gt $MINC ] || error_ignore "stripe QOS didn't balance free space"
4865 run_test 116 "stripe QOS: free space balance ==================="
4867 test_117() # bug 10891
4869 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
4870 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
4871 lctl set_param fail_loc=0x21e
4872 > $DIR/$tfile || error "truncate failed"
4873 lctl set_param fail_loc=0
4874 echo "Truncate succeeded."
4876 run_test 117 "verify fsfilt_extend ============================="
4878 export OLD_RESENDCOUNT=""
4879 set_resend_count () {
4880 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
4881 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -1)
4882 lctl set_param -n $PROC_RESENDCOUNT $1
4883 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
4886 [ "$SLOW" = "no" ] && set_resend_count 4 # for reduce test_118* time (bug 14842)
4888 # Reset async IO behavior after error case
4890 FILE=$DIR/reset_async
4892 # Ensure all OSCs are cleared
4893 $SETSTRIPE -c -1 $FILE
4894 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
4899 test_118a() #bug 11710
4903 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
4904 DIRTY=$(lctl get_param -n "llite.*.dump_page_cache" | grep -c dirty)
4905 WRITEBACK=$(lctl get_param "llite.*.dump_page_cache" | grep -c writeback)
4907 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
4908 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
4912 run_test 118a "verify O_SYNC works =========="
4916 remote_ost_nodsh && skip "remote OST with nodsh" && return
4920 #define OBD_FAIL_OST_ENOENT 0x217
4921 set_nodes_failloc "$(osts_nodes)" 0x217
4922 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
4924 set_nodes_failloc "$(osts_nodes)" 0
4925 DIRTY=$(lctl get_param llite.*.dump_page_cache | grep -c dirty)
4926 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
4928 if [[ $RC -eq 0 ]]; then
4929 error "Must return error due to dropped pages, rc=$RC"
4933 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
4934 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
4938 echo "Dirty pages not leaked on ENOENT"
4940 # Due to the above error the OSC will issue all RPCs syncronously
4941 # until a subsequent RPC completes successfully without error.
4942 multiop $DIR/$tfile Ow4096yc
4947 run_test 118b "Reclaim dirty pages on fatal error =========="
4951 remote_ost_nodsh && skip "remote OST with nodsh" && return
4955 #define OBD_FAIL_OST_EROFS 0x216
4956 set_nodes_failloc "$(osts_nodes)" 0x216
4958 # multiop should block due to fsync until pages are written
4959 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
4963 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
4964 error "Multiop failed to block on fsync, pid=$MULTIPID"
4967 WRITEBACK=$(lctl get_param -n llite/*/dump_page_cache | grep -c writeback)
4968 if [[ $WRITEBACK -eq 0 ]]; then
4969 error "No page in writeback, writeback=$WRITEBACK"
4972 set_nodes_failloc "$(osts_nodes)" 0
4975 if [[ $RC -ne 0 ]]; then
4976 error "Multiop fsync failed, rc=$RC"
4979 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
4980 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
4981 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
4982 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
4986 echo "Dirty pages flushed via fsync on EROFS"
4989 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
4993 remote_ost_nodsh && skip "remote OST with nodsh" && return
4997 #define OBD_FAIL_OST_BRW_PAUSE_BULK
4998 set_nodes_failloc "$(osts_nodes)" 0x214
4999 # multiop should block due to fsync until pages are written
5000 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
5004 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
5005 error "Multiop failed to block on fsync, pid=$MULTIPID"
5008 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
5009 if [[ $WRITEBACK -eq 0 ]]; then
5010 error "No page in writeback, writeback=$WRITEBACK"
5013 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
5014 set_nodes_failloc "$(osts_nodes)" 0
5016 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
5017 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
5018 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
5019 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
5023 echo "Dirty pages gaurenteed flushed via fsync"
5026 run_test 118d "Fsync validation inject a delay of the bulk =========="
5031 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
5032 lctl set_param fail_loc=0x8000040a
5034 # Should simulate EINVAL error which is fatal
5035 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
5037 if [[ $RC -eq 0 ]]; then
5038 error "Must return error due to dropped pages, rc=$RC"
5041 lctl set_param fail_loc=0x0
5043 LOCKED=$(lctl get_param -n "llite.*.dump_page_cache" | grep -c locked)
5044 DIRTY=$(lctl get_param -n "llite.*.dump_page_cache" | grep -c dirty)
5045 WRITEBACK=$(lctl get_param -n "llite.*.dump_page_cache" | grep -c writeback)
5046 if [[ $LOCKED -ne 0 ]]; then
5047 error "Locked pages remain in cache, locked=$LOCKED"
5050 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
5051 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
5055 echo "No pages locked after fsync"
5060 run_test 118f "Simulate unrecoverable OSC side error =========="
5065 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
5066 lctl set_param fail_loc=0x406
5068 # simulate local -ENOMEM
5069 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
5072 lctl set_param fail_loc=0
5073 if [[ $RC -eq 0 ]]; then
5074 error "Must return error due to dropped pages, rc=$RC"
5077 LOCKED=$(lctl get_param -n "llite.*.dump_page_cache" | grep -c locked)
5078 DIRTY=$(lctl get_param -n "llite.*.dump_page_cache" | grep -c dirty)
5079 WRITEBACK=$(lctl get_param -n "llite.*.dump_page_cache" | grep -c writeback)
5080 if [[ $LOCKED -ne 0 ]]; then
5081 error "Locked pages remain in cache, locked=$LOCKED"
5084 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
5085 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
5089 echo "No pages locked after fsync"
5094 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
5097 remote_ost_nodsh && skip "remote OST with nodsh" && return
5101 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
5102 set_nodes_failloc "$(osts_nodes)" 0x20e
5103 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
5104 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
5107 set_nodes_failloc "$(osts_nodes)" 0
5108 if [[ $RC -eq 0 ]]; then
5109 error "Must return error due to dropped pages, rc=$RC"
5112 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
5113 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
5114 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writebac)
5115 if [[ $LOCKED -ne 0 ]]; then
5116 error "Locked pages remain in cache, locked=$LOCKED"
5119 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
5120 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
5124 echo "No pages locked after fsync"
5128 run_test 118h "Verify timeout in handling recoverables errors =========="
5131 remote_ost_nodsh && skip "remote OST with nodsh" && return
5135 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
5136 set_nodes_failloc "$(osts_nodes)" 0x20e
5138 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
5139 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
5142 set_nodes_failloc "$(osts_nodes)" 0
5146 if [[ $RC -ne 0 ]]; then
5147 error "got error, but should be not, rc=$RC"
5150 LOCKED=$(lctl get_param -n "llite.*.dump_page_cache" | grep -c locked)
5151 DIRTY=$(lctl get_param -n "llite.*.dump_page_cache" | grep -c dirty)
5152 WRITEBACK=$(lctl get_param -n "llite.*.dump_page_cache" | grep -c writeback)
5153 if [[ $LOCKED -ne 0 ]]; then
5154 error "Locked pages remain in cache, locked=$LOCKED"
5157 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
5158 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
5162 echo "No pages locked after fsync"
5166 run_test 118i "Fix error before timeout in recoverable error =========="
5169 remote_ost_nodsh && skip "remote OST with nodsh" && return
5173 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
5174 set_nodes_failloc "$(osts_nodes)" 0x220
5176 # return -EIO from OST
5177 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
5179 set_nodes_failloc "$(osts_nodes)" 0x0
5180 if [[ $RC -eq 0 ]]; then
5181 error "Must return error due to dropped pages, rc=$RC"
5184 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
5185 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
5186 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
5187 if [[ $LOCKED -ne 0 ]]; then
5188 error "Locked pages remain in cache, locked=$LOCKED"
5191 # in recoverable error on OST we want resend and stay until it finished
5192 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
5193 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
5197 echo "No pages locked after fsync"
5201 run_test 118j "Simulate unrecoverable OST side error =========="
5205 remote_ost_nodsh && skip "remote OSTs with nodsh" && return
5207 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
5208 set_nodes_failloc "$(osts_nodes)" 0x20e
5211 for ((i=0;i<10;i++)); do
5212 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
5213 error "dd to $DIR/$tdir/$tfile-$i failed" )&
5220 set_nodes_failloc "$(osts_nodes)" 0
5223 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
5229 multiop $DIR/$tdir Dy || error "fsync dir failed"
5232 run_test 118l "fsync dir ========="
5234 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
5236 test_119a() # bug 11737
5238 BSIZE=$((512 * 1024))
5239 directio write $DIR/$tfile 0 1 $BSIZE
5240 # We ask to read two blocks, which is more than a file size.
5241 # directio will indicate an error when requested and actual
5242 # sizes aren't equeal (a normal situation in this case) and
5243 # print actual read amount.
5244 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
5245 if [ "$NOB" != "$BSIZE" ]; then
5246 error "read $NOB bytes instead of $BSIZE"
5250 run_test 119a "Short directIO read must return actual read amount"
5252 test_119b() # bug 11737
5254 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
5256 $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
5257 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
5259 multiop $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) || \
5260 error "direct read failed"
5263 run_test 119b "Sparse directIO read must return actual read amount"
5265 test_119c() # bug 13099
5268 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
5269 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
5272 run_test 119c "Testing for direct read hitting hole"
5274 test_119d() # bug 15950
5276 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
5277 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
5279 $SETSTRIPE $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
5280 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
5281 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
5282 lctl set_param fail_loc=0x40d
5283 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
5286 cat $DIR/$tfile > /dev/null &
5287 lctl set_param fail_loc=0
5290 log "the DIO writes have completed, now wait for the reads (should not block very long)"
5292 [ -n "`ps h -p $pid_reads -o comm`" ] && \
5293 error "the read rpcs have not completed in 2s"
5295 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
5297 run_test 119d "The DIO path should try to send a new rpc once one is completed"
5301 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
5302 skip "no early lock cancel on server" && return 0
5303 lru_resize_disable mdc
5304 lru_resize_disable osc
5305 cancel_lru_locks mdc
5306 stat $DIR/$tdir > /dev/null
5307 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
5308 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
5310 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
5311 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
5312 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
5313 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
5314 lru_resize_enable mdc
5315 lru_resize_enable osc
5317 run_test 120a "Early Lock Cancel: mkdir test ==================="
5321 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
5322 skip "no early lock cancel on server" && return 0
5323 lru_resize_disable mdc
5324 lru_resize_disable osc
5325 cancel_lru_locks mdc
5326 stat $DIR/$tdir > /dev/null
5327 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
5328 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
5330 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
5331 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
5332 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
5333 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
5334 lru_resize_enable mdc
5335 lru_resize_enable osc
5337 run_test 120b "Early Lock Cancel: create test =================="
5341 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
5342 skip "no early lock cancel on server" && return 0
5343 lru_resize_disable mdc
5344 lru_resize_disable osc
5345 mkdir -p $DIR/$tdir/d1 $DIR/$tdir/d2
5346 touch $DIR/$tdir/d1/f1
5347 cancel_lru_locks mdc
5348 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
5349 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
5350 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
5351 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
5352 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
5353 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
5354 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
5355 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
5356 lru_resize_enable mdc
5357 lru_resize_enable osc
5359 run_test 120c "Early Lock Cancel: link test ===================="
5363 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
5364 skip "no early lock cancel on server" && return 0
5365 lru_resize_disable mdc
5366 lru_resize_disable osc
5368 cancel_lru_locks mdc
5369 stat $DIR/$tdir > /dev/null
5370 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
5371 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
5372 chmod a+x $DIR/$tdir
5373 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
5374 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
5375 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
5376 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
5377 lru_resize_enable mdc
5378 lru_resize_enable osc
5380 run_test 120d "Early Lock Cancel: setattr test ================="
5384 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
5385 skip "no early lock cancel on server" && return 0
5386 lru_resize_disable mdc
5387 lru_resize_disable osc
5388 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
5389 cancel_lru_locks mdc
5390 cancel_lru_locks osc
5391 dd if=$DIR/$tdir/f1 of=/dev/null
5392 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
5393 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
5394 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
5395 unlink $DIR/$tdir/f1
5396 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
5397 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
5398 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
5399 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
5400 lru_resize_enable mdc
5401 lru_resize_enable osc
5403 run_test 120e "Early Lock Cancel: unlink test =================="
5406 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
5407 skip "no early lock cancel on server" && return 0
5409 lru_resize_disable mdc
5410 lru_resize_disable osc
5411 mkdir -p $DIR/$tdir/d1 $DIR/$tdir/d2
5412 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
5413 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
5414 cancel_lru_locks mdc
5415 cancel_lru_locks osc
5416 dd if=$DIR/$tdir/d1/f1 of=/dev/null
5417 dd if=$DIR/$tdir/d2/f2 of=/dev/null
5418 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
5419 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
5420 blk1=`lctl get_param -n ldlm/services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
5421 mv $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
5422 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
5423 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
5424 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
5425 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
5426 lru_resize_enable mdc
5427 lru_resize_enable osc
5429 run_test 120f "Early Lock Cancel: rename test =================="
5432 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
5433 skip "no early lock cancel on server" && return 0
5434 lru_resize_disable mdc
5435 lru_resize_disable osc
5437 echo create $count files
5439 cancel_lru_locks mdc
5440 cancel_lru_locks osc
5443 can0=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
5444 blk0=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
5445 createmany -o $DIR/$tdir/f $count
5447 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
5448 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
5450 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
5451 echo rm $count files
5454 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
5455 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
5457 echo total: $count removes in $((t2-t1))
5458 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
5460 # wait for commitment of removal
5461 lru_resize_enable mdc
5462 lru_resize_enable osc
5464 run_test 120g "Early Lock Cancel: performance test ============="
5466 test_121() { #bug 10589
5467 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
5468 lctl set_param fail_loc=0x310
5469 cancel_lru_locks osc > /dev/null
5470 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
5471 lctl set_param fail_loc=0
5472 [ "$reads" -eq "$writes" ] || error "read" $reads "blocks, must be" $writes
5474 run_test 121 "read cancel race ================================="
5476 test_122() { #bug 11544
5477 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
5478 lctl set_param fail_loc=0x508
5479 dd if=/dev/zero of=$DIR/$tfile count=1
5481 lctl set_param fail_loc=0
5483 run_test 122 "fail client bulk callback (shouldn't LBUG) ======="
5485 test_123a() { # was test 123, statahead(bug 11401)
5487 local lustre_version=$(get_lustre_version mds)
5488 if [[ $lustre_version != 1.8* ]]; then
5489 skip mds running $lustre_version, statahead is disabled
5493 statahead_max_old=`lctl get_param -n llite.*.statahead_max | head -n 1`
5496 if [ -z "$(grep "processor.*: 1" /proc/cpuinfo)" ]; then
5497 log "testing on UP system. Performance may be not as good as expected."
5503 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
5504 [ $NUMFREE -gt 100000 ] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
5506 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
5507 createmany -o $DIR/$tdir/$tfile $j $((i - j))
5509 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
5510 [ $max -eq 0 ] && max=32
5511 lctl set_param -n llite.*.statahead_max 0
5512 lctl get_param llite.*.statahead_max
5513 cancel_lru_locks mdc
5514 cancel_lru_locks osc
5516 time ls -l $DIR/$tdir | wc -l
5518 delta=$((etime - stime))
5519 log "ls $i files without statahead: $delta sec"
5520 lctl set_param llite.*.statahead_max=$max
5522 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
5523 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
5524 cancel_lru_locks mdc
5525 cancel_lru_locks osc
5527 time ls -l $DIR/$tdir | wc -l
5529 delta_sa=$((etime - stime))
5530 log "ls $i files with statahead: $delta_sa sec"
5531 lctl get_param -n llite.*.statahead_stats
5532 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
5534 if [ $swrong -lt $ewrong ]; then
5535 log "statahead was stopped, maybe too many locks held!"
5538 [ $delta -eq 0 -o $delta_sa -eq 0 ] && continue
5540 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
5541 if [ $SLOWOK -eq 0 ]; then
5542 error "ls $i files is slower with statahead!"
5545 lctl set_param debug=-1
5546 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
5547 [ $max -eq 0 ] && max=32
5548 lctl set_param -n llite.*.statahead_max 0
5549 lctl get_param llite.*.statahead_max
5550 cancel_lru_locks mdc
5551 cancel_lru_locks osc
5554 time ls -l $DIR/$tdir | wc -l
5556 error "ls $i files (again) without statahead: $((etime - stime)) sec"
5558 lctl set_param debug=-1
5559 lctl set_param llite.*.statahead_max=$max
5560 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
5561 cancel_lru_locks mdc
5562 cancel_lru_locks osc
5565 time ls -l $DIR/$tdir | wc -l
5567 error "ls $i files (again) with statahead: $((etime - stime)) sec"
5568 lctl get_param -n llite.*.statahead_stats
5572 log "ls $i files is slower with statahead!"
5577 [ $delta -gt 20 ] && break
5578 [ $delta -gt 8 ] && MULT=$((50 / delta))
5579 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
5587 delta=$((etime - stime))
5588 log "rm -r $DIR/$tdir/: $delta seconds"
5590 # restore default value
5591 $LCTL set_param llite.*.statahead_max=$statahead_max_old
5592 $LCTL get_param -n llite.*.statahead_stats
5594 run_test 123a "verify statahead work"
5596 test_123b () { # statahead(bug 15027)
5598 local lustre_version=$(get_lustre_version mds)
5599 if [[ $lustre_version != 1.8* ]]; then
5600 skip mds running $lustre_version, statahead is disabled
5605 createmany -o $DIR/$tdir/$tfile-%d 1000
5607 cancel_lru_locks mdc
5608 cancel_lru_locks osc
5610 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
5611 lctl set_param fail_loc=0x80000803
5612 ls -lR $DIR/$tdir > /dev/null
5614 lctl set_param fail_loc=0x0
5615 lctl get_param -n llite.*.statahead_stats
5620 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
5623 [ -z "`lctl get_param -n mdc.*.connect_flags | grep lru_resize`" ] && \
5624 skip "no lru resize on server" && return 0
5626 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
5628 log "create $NR files at $DIR/$tdir"
5629 createmany -o $DIR/$tdir/f $NR ||
5630 error "failed to create $NR files in $DIR/$tdir"
5632 cancel_lru_locks mdc
5633 ls -l $DIR/$tdir > /dev/null
5637 for VALUE in `lctl get_param ldlm.namespaces.*mdc-*.lru_size`; do
5638 local PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
5639 LRU_SIZE=$(lctl get_param -n $PARAM)
5640 if [ $LRU_SIZE -gt $(default_lru_size) ]; then
5641 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
5642 log "NS=$(basename $NSDIR)"
5647 if [ -z "$NSDIR" -o $LRU_SIZE -lt $(default_lru_size) ]; then
5648 skip "Not enough cached locks created!"
5655 # We know that lru resize allows one client to hold $LIMIT locks
5656 # for 10h. After that locks begin to be killed by client.
5658 local LIMIT=`lctl get_param -n $NSDIR.pool.limit`
5660 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
5661 # killing locks. Some time was spent for creating locks. This means
5662 # that up to the moment of sleep finish we must have killed some of
5663 # them (10-100 locks). This depends on how fast ther were created.
5664 # Many of them were touched in almost the same moment and thus will
5665 # be killed in groups.
5666 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
5668 # Use $LRU_SIZE_B here to take into account real number of locks
5669 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
5670 local LRU_SIZE_B=$LRU_SIZE
5672 local OLD_LVF=`lctl get_param -n $NSDIR.pool.lock_volume_factor`
5673 lctl set_param -n $NSDIR.pool.lock_volume_factor $LVF
5675 # Let's make sure that we really have some margin. Client checks
5676 # cached locks every 10 sec.
5678 log "Sleep ${SLEEP} sec"
5680 while ((SEC<$SLEEP)); do
5684 LRU_SIZE=`lctl get_param -n $NSDIR/lru_size`
5688 lctl set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
5689 local LRU_SIZE_A=`lctl get_param -n $NSDIR/lru_size`
5691 [ $LRU_SIZE_B -gt $LRU_SIZE_A ] || {
5692 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
5693 unlinkmany $DIR/$tdir/f $NR
5697 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
5698 log "unlink $NR files at $DIR/$tdir"
5699 unlinkmany $DIR/$tdir/f $NR
5701 run_test 124a "lru resize ======================================="
5704 [ -z "`lctl get_param -n mdc.*.connect_flags | grep lru_resize`" ] && \
5705 skip "no lru resize on server" && return 0
5707 # even for cmd no matter what metadata namespace to use for getting
5708 # the limit, we use appropriate.
5709 LIMIT=`lctl get_param -n ldlm.namespaces.*mdc*.pool.limit`
5711 NR=$(($(default_lru_size)*20))
5712 if [ $NR -gt $LIMIT ]; then
5715 lru_resize_disable mdc
5716 mkdir -p $DIR/$tdir/disable_lru_resize ||
5717 error "failed to create $DIR/$tdir/disable_lru_resize"
5719 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
5720 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
5721 cancel_lru_locks mdc
5724 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
5727 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
5730 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
5734 nolruresize_delta=$((etime-stime))
5735 log "ls -la time: $nolruresize_delta seconds"
5736 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
5737 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
5739 lru_resize_enable mdc
5740 mkdir -p $DIR/$tdir/enable_lru_resize ||
5741 error "failed to create $DIR/$tdir/enable_lru_resize"
5743 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
5744 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
5745 cancel_lru_locks mdc
5748 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
5751 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
5754 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
5758 lruresize_delta=$((etime-stime))
5759 log "ls -la time: $lruresize_delta seconds"
5760 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
5762 if [ $lruresize_delta -gt $nolruresize_delta ]; then
5763 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
5764 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
5765 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
5767 log "lru resize performs the same with no lru resize"
5769 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
5771 run_test 124b "lru resize (performance test) ======================="
5773 test_125() { # 13358
5774 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
5775 mkdir -p $DIR/d125 || error "mkdir failed"
5776 $SETSTRIPE $DIR/d125 -s 65536 -c -1 || error "setstripe failed"
5777 setfacl -R -m u:bin:rwx $DIR/d125 || error "setfacl $DIR/d125 failes"
5778 ls -ld $DIR/d125 || error "cannot access $DIR/d125"
5780 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
5782 test_126() { # bug 12829/13455
5783 [ "$UID" != 0 ] && skip_env "skipping $TESTNAME (must run as root)" && return
5784 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
5785 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
5787 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
5789 run_test 126 "check that the fsgid provided by the client is taken into account"
5791 test_127() { # bug 15521
5792 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
5793 $LCTL set_param osc.*.stats=0
5794 FSIZE=$((2048 * 1024))
5795 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
5796 cancel_lru_locks osc
5797 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
5799 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
5800 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
5801 echo "got $COUNT $NAME"
5802 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
5803 eval $NAME=$COUNT || error "Wrong proc format"
5806 read_bytes|write_bytes)
5807 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
5808 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
5809 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
5810 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
5811 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
5812 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
5813 error "sumsquare is too small: $SUMSQ"
5814 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
5815 error "sumsquare is too big: $SUMSQ"
5819 done < $DIR/${tfile}.tmp
5821 #check that we actually got some stats
5822 [ "$read_bytes" ] || error "Missing read_bytes stats"
5823 [ "$write_bytes" ] || error "Missing write_bytes stats"
5824 [ "$read_bytes" != 0 ] || error "no read done"
5825 [ "$write_bytes" != 0 ] || error "no write done"
5827 run_test 127 "verify the client stats are sane"
5829 test_128() { # bug 15212
5831 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
5836 result=$(grep error $TMP/$tfile.log)
5838 [ -z "$result" ] || error "consecutive find with interactive lfs failed"
5840 run_test 128 "interactive lfs for 2 consecutive finds"
5843 [ "$FSTYPE" != "ldiskfs" ] && skip "not needed for FSTYPE=$FSTYPE" && return 0
5844 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5846 local MNTDEV=$(get_mds_mntdev_proc_path)
5847 DEV=$(ldiskfs_canon "$MNTDEV" mds)
5848 [ -z "$DEV" ] && error "can't access mds mntdev"
5850 LDPROC=/proc/fs/ldiskfs/$DEV/max_dir_size
5851 do_facet mds "test -e /sys/fs/ldiskfs/$DEV/max_dir_size" && LDPROC=/sys/fs/ldiskfs/$DEV/max_dir_size
5854 do_facet mds "echo $MAX > $LDPROC"
5860 while [ ! $I -gt $MAX ]; do
5861 multiop $DIR/$tdir/$J Oc
5863 if [ $rc -eq $EFBIG ]; then
5864 do_facet mds "echo 0 >$LDPROC"
5865 echo "return code $rc received as expected"
5867 elif [ $rc -ne 0 ]; then
5868 do_facet mds "echo 0 >$LDPROC"
5869 error_exit "error $rc instead of expected $EFBIG"
5872 I=$(stat -c%s "$DIR/$tdir")
5875 error "exceeded dir size limit: $I bytes"
5876 do_facet mds "echo 0 >$LDPROC"
5878 run_test 129 "test directory size limit ========================"
5887 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
5888 [ -n "$filefrag_op" ] && skip "filefrag has no FIEMAP support" && return
5890 trap cleanup_130 EXIT RETURN
5892 local fm_file=$DIR/$tfile
5893 lfs setstripe -s 65536 -c 1 $fm_file ||
5894 error "setstripe failed on $fm_file"
5895 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
5896 error "dd failed for $fm_file"
5898 filefrag -ves $fm_file || error "filefrag $fm_file failed"
5899 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
5901 lun=`$GETSTRIPE $fm_file | grep -A 10 obdidx | awk '{print $1}' | grep -v "obdidx"`
5903 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
5906 for line in $filefrag_op
5908 frag_lun=`echo $line | cut -d: -f5`
5909 ext_len=`echo $line | cut -d: -f4`
5910 if (( $frag_lun != $lun )); then
5912 error "FIEMAP on 1-stripe file($fm_file) failed"
5915 (( tot_len += ext_len ))
5918 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
5920 error "FIEMAP on 1-stripe file($fm_file) failed;"
5926 echo "FIEMAP on single striped file succeeded"
5928 run_test 130a "FIEMAP (1-stripe file)"
5931 [ "$OSTCOUNT" -lt "2" ] && skip_env "FIEMAP on 2-stripe file test" && return
5933 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
5934 [ -n "$filefrag_op" ] && skip "filefrag has no FIEMAP support" && return
5936 trap cleanup_130 EXIT RETURN
5938 local fm_file=$DIR/$tfile
5939 lfs setstripe -s 65536 -c 2 $fm_file ||
5940 error "setstripe failed on $fm_file"
5941 dd if=/dev/zero of=$fm_file bs=1M count=2 ||
5942 error "dd failed on $fm_file"
5944 filefrag -ves $fm_file || error "filefrag $fm_file failed"
5945 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
5947 last_lun=`echo $filefrag_op | cut -d: -f5`
5952 for line in $filefrag_op; do
5953 frag_lun=`echo $line | cut -d: -f5`
5954 ext_len=`echo $line | cut -d: -f4`
5955 if (( $frag_lun != $last_lun )); then
5956 if (( tot_len != 1024 )); then
5958 error "FIEMAP $fm_file: len $tot_len for OST $last_lun instead of 256"
5965 (( tot_len += ext_len ))
5968 if (( num_luns != 2 || tot_len != 1024 )); then
5970 error "FIEMAP $fm_file: wrong number of LUNs or wrong len for OST $last_lun"
5976 echo "FIEMAP on 2-stripe file succeeded"
5978 run_test 130b "FIEMAP (2-stripe file)"
5981 [ "$OSTCOUNT" -lt "2" ] && skip_env "FIEMAP on 2-stripe hole test" && return
5983 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
5984 [ -n "$filefrag_op" ] && skip "filefrag has no FIEMAP support" && return
5986 trap cleanup_130 EXIT RETURN
5988 local fm_file=$DIR/$tfile
5989 lfs setstripe -s 65536 -c 2 $fm_file ||
5990 error "setstripe failed on $fm_file"
5991 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 ||
5992 error "dd failed on $fm_file"
5994 filefrag -ves $fm_file || error "filefrag $fm_file failed"
5995 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
5997 last_lun=`echo $filefrag_op | cut -d: -f5`
6002 for line in $filefrag_op
6004 frag_lun=`echo $line | cut -d: -f5`
6005 ext_len=`echo $line | cut -d: -f4`
6006 if (( $frag_lun != $last_lun )); then
6007 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
6008 if (( logical != 512 )); then
6010 error "FIEMAP $fm_file: logical start for LUN $logical instead of 512"
6013 if (( tot_len != 512 )); then
6015 error "FIEMAP $fm_file: len $tot_len for OST $last_lun instead of 1024"
6022 (( tot_len += ext_len ))
6025 if (( num_luns != 2 || tot_len != 512 )); then
6027 error "FIEMAP $fm_file: wrong number of LUNs or wrong len for OST $last_lun"
6033 echo "FIEMAP on 2-stripe file with hole succeeded"
6035 run_test 130c "FIEMAP (2-stripe file with hole)"
6038 [ "$OSTCOUNT" -lt "3" ] && skip_env "FIEMAP on N-stripe file test" && return
6040 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
6041 [ -n "$filefrag_op" ] && skip "filefrag has no FIEMAP support" && return
6043 trap cleanup_130 EXIT RETURN
6045 local fm_file=$DIR/$tfile
6046 lfs setstripe -s 65536 -c $OSTCOUNT $fm_file ||
6047 error "setstripe failed on $fm_file"
6048 dd if=/dev/zero of=$fm_file bs=1M count=$OSTCOUNT ||
6049 error "dd failed on $fm_file"
6051 filefrag -ves $fm_file || error "filefrag $fm_file failed"
6052 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
6054 last_lun=`echo $filefrag_op | cut -d: -f5`
6059 for line in $filefrag_op
6061 frag_lun=`echo $line | cut -d: -f5`
6062 ext_len=`echo $line | cut -d: -f4`
6063 if (( $frag_lun != $last_lun )); then
6064 if (( tot_len != 1024 )); then
6066 error "FIEMAP $fm_file: len $tot_len for OST $last_lun instead of 1024"
6073 (( tot_len += ext_len ))
6076 if (( num_luns != OSTCOUNT || tot_len != 1024 )); then
6078 error "FIEMAP $fm_file: wrong number of LUNs or wrong len for OST $last_lun"
6084 echo "FIEMAP on N-stripe file succeeded"
6086 run_test 130d "FIEMAP (N-stripe file)"
6089 [ "$OSTCOUNT" -lt "2" ] && skip "continuation FIEMAP test" && return
6091 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
6092 [ -n "$filefrag_op" ] && skip "filefrag has no FIEMAP support" && return
6094 trap cleanup_130 EXIT RETURN
6096 local fm_file=$DIR/$tfile
6097 lfs setstripe -s 131072 -c 2 $fm_file ||
6098 error "setstripe failed on $fm_file"
6100 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
6101 for ((i = 0; i < $NUM_BLKS; i++)); do
6102 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
6105 filefrag -ves $fm_file || error "filefrag $fm_file failed"
6106 filefrag_op=`filefrag -ve $fm_file | grep -A 12000 "ext:" | grep -v "ext:" | grep -v "found"`
6108 last_lun=`echo $filefrag_op | cut -d: -f5`
6113 for line in $filefrag_op
6115 frag_lun=`echo $line | cut -d: -f5`
6116 ext_len=`echo $line | cut -d: -f4`
6117 if (( $frag_lun != $last_lun )); then
6118 if (( tot_len != $EXPECTED_LEN )); then
6120 error "FIEMAP $fm_file: len $tot_len for OST $last_lun instead of $EXPECTED_LEN"
6127 (( tot_len += ext_len ))
6130 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
6132 error "FIEMAP $fm_file: wrong number of LUNs or wrong len for OST $last_lun"
6138 echo "FIEMAP with continuation calls succeeded"
6140 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
6142 check_stats_facet() {
6146 local svc=${facet}_svc
6150 [[ $facet = mds ]] && dev=$(get_mds_mdt_device_proc_path)
6151 param=$dev.${!svc}.stats
6153 res=$(do_facet $facet $LCTL get_param $param | grep "$2")
6155 count=`echo $res | awk '{print $2}'`
6156 [ -z "$res" ] && error "The counter for $2 on $1 was not incremented"
6157 # if the argument $3 is zero, it means any stat increment is ok.
6158 if [ $3 -gt 0 ] ; then
6159 [ $count -ne $3 ] && error "The $2 counter on $1 is wrong - expected $3"
6165 local lustre_version=$(get_lustre_version mds)
6166 if [[ $lustre_version != 1.8* ]]; then
6167 skip mds running $lustre_version, no stats, bz22378
6171 local testdir=$DIR/${tdir}/stats_testdir
6172 mkdir -p $DIR/${tdir}
6175 local dev=$(get_mds_mdt_device_proc_path)
6176 do_facet mds $LCTL set_param $dev.*.stats=clear
6177 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
6179 # verify mdt stats first.
6180 mkdir ${testdir} || error "mkdir failed"
6181 check_stats_facet mds "mkdir" 1
6182 touch ${testdir}/${tfile} || "touch failed"
6183 # LPROC_MDS_OPEN is incremented by 2 - in mds_open() and mds_intent_policy()
6184 check_stats_facet mds "open" 1
6185 check_stats_facet mds "close" 1
6186 mknod ${testdir}/${tfile}-pipe p || "mknod failed"
6187 check_stats_facet mds "mknod" 1
6188 rm -f ${testdir}/${tfile}-pipe || "pipe remove failed"
6189 check_stats_facet mds "unlink" 1
6190 rm -f ${testdir}/${tfile} || error "file remove failed"
6191 check_stats_facet mds "unlink" 2
6193 # remove working dir and check mdt stats again.
6194 rmdir ${testdir} || error "rmdir failed"
6195 check_stats_facet mds "rmdir" 1
6199 run_test 133a "Verifying MDT stats ========================================"
6203 local lustre_version=$(get_lustre_version mds)
6204 if [[ $lustre_version != 1.8* ]]; then
6205 skip mds running $lustre_version, no stats, bz22378
6209 local testdir=$DIR/${tdir}/stats_testdir
6210 mkdir -p ${testdir} || error "mkdir failed"
6211 touch ${testdir}/${tfile} || "touch failed"
6212 cancel_lru_locks mdc
6215 local dev=$(get_mds_mdt_device_proc_path)
6216 do_facet mds $LCTL set_param $dev.*.stats=clear
6217 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
6219 # extra mdt stats verification.
6220 stat ${testdir}/${tfile} || error "stat failed"
6221 check_stats_facet mds "getattr" 0
6222 chmod 444 ${testdir}/${tfile} || error "chmod failed"
6223 check_stats_facet mds "setattr" 1
6224 $LFS df || error "lfs failed"
6225 check_stats_facet mds "statfs" 1
6229 run_test 133b "Verifying extra MDT stats =================================="
6233 local lustre_version=$(get_lustre_version mds)
6234 if [[ $lustre_version != 1.8* ]]; then
6235 skip mds running $lustre_version, no stats, bz22378
6239 local testdir=$DIR/${tdir}/stats_testdir
6240 mkdir -p ${testdir} || error "mkdir failed"
6242 # verify obdfilter stats.
6243 $LFS setstripe -c 1 -o 0 ${testdir}/${tfile}
6245 cancel_lru_locks osc
6248 local dev=$(get_mds_mdt_device_proc_path)
6249 do_facet mds $LCTL set_param $dev.*.stats=clear
6250 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
6252 dd if=/dev/zero of=${testdir}/${tfile} bs=1024k count=1 || error "dd failed"
6254 cancel_lru_locks osc
6255 check_stats_facet ost1 "write" 1
6257 dd if=${testdir}/${tfile} of=/dev/null bs=1k count=1 || error "dd failed"
6258 check_stats_facet ost1 "read" 1
6260 > ${testdir}/${tfile} || error "truncate failed"
6261 check_stats_facet ost1 "punch" 1
6263 rm -f ${testdir}/${tfile} || error "file remove failed"
6264 check_stats_facet ost1 "destroy" 1
6268 run_test 133c "Verifying OST stats ========================================"
6270 test_140() { #bug-17379
6271 mkdir -p $DIR/$tdir || error "Creating dir $DIR/$tdir"
6272 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
6273 cp /usr/bin/stat . || error "Copying stat to $DIR/$tdir"
6275 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
6277 while i=`expr $i + 1`; do
6278 mkdir -p $i || error "Creating dir $i"
6279 cd $i || error "Changing to $i"
6280 ln -s ../stat stat || error "Creating stat symlink"
6281 # Read the symlink until ELOOP present,
6282 # not LBUGing the system is considered success,
6283 # we didn't overrun the stack.
6284 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
6286 if [ $ret -eq 40 ]; then
6289 error "Open stat symlink"
6295 echo "The symlink depth = $i"
6296 [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 ] || error "Invalid symlink depth"
6298 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
6301 local TF="$TMP/$tfile"
6303 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
6305 cancel_lru_locks osc
6306 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
6307 remount_client $MOUNT
6309 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
6312 $TRUNCATE $DIR/$tfile 6000
6313 cancel_lru_locks osc
6314 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
6317 echo "12345" >>$DIR/$tfile
6318 cancel_lru_locks osc
6319 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
6322 echo "12345" >>$DIR/$tfile
6323 cancel_lru_locks osc
6324 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
6329 run_test 150 "truncate/append tests"
6331 function roc_hit() {
6332 local list=$(comma_list $(osts_nodes))
6334 ACCNUM=$(do_nodes $list $LCTL get_param -n obdfilter.*.stats | \
6335 awk '/'cache_hit'/ {sum+=$2} END {print sum}')
6339 function set_cache() {
6342 if [ "$2" == "off" ]; then
6345 local list=$(comma_list $(osts_nodes))
6346 do_nodes $list lctl set_param obdfilter.*.${1}_cache_enable $on
6348 cancel_lru_locks osc
6352 remote_ost_nodsh && skip "remote OST with nodsh" && return
6354 local list=$(comma_list $(osts_nodes))
6355 if ! do_nodes $list grep -q truncate_inode_pages_range /proc/kallsyms; then #b=18718
6356 skip "old RHEL4/SLES9 kernel" && return
6361 # check whether obdfilter is cache capable at all
6362 if ! do_nodes $list $LCTL get_param -n obdfilter.*.read_cache_enable > /dev/null; then
6363 echo "not cache-capable obdfilter"
6367 # make sure cache is enabled on all obdfilters
6368 do_nodes $list $LCTL set_param obdfilter.*.read_cache_enable=1
6369 do_nodes $list $LCTL set_param obdfilter.*.writethrough_cache_enable=1
6371 # pages should be in the case right after write
6372 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES || error "dd failed"
6373 local BEFORE=`roc_hit`
6374 cancel_lru_locks osc
6375 cat $DIR/$tfile >/dev/null
6376 local AFTER=`roc_hit`
6377 if let "AFTER - BEFORE != CPAGES"; then
6378 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
6381 # the following read invalidates the cache
6382 cancel_lru_locks osc
6383 do_nodes $list $LCTL set_param -n obdfilter.*.read_cache_enable 0
6384 cat $DIR/$tfile >/dev/null
6386 # now data shouldn't be found in the cache
6388 cancel_lru_locks osc
6389 cat $DIR/$tfile >/dev/null
6391 if let "AFTER - BEFORE != 0"; then
6392 error "IN CACHE: before: $BEFORE, after: $AFTER"
6395 do_nodes $list $LCTL set_param -n obdfilter.*.read_cache_enable=1
6396 do_nodes $list $LCTL set_param obdfilter.*.writethrough_cache_enable=1
6399 run_test 151 "test cache on oss and controls ==============================="
6402 local TF="$TMP/$tfile"
6404 # simulate ENOMEM during write
6405 #define OBD_FAIL_OST_NOMEM 0x226
6406 lctl set_param fail_loc=0x80000226
6407 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
6409 sync || error "sync failed"
6410 lctl set_param fail_loc=0
6412 # discard client's cache
6413 cancel_lru_locks osc
6415 # simulate ENOMEM during read
6416 lctl set_param fail_loc=0x80000226
6417 cmp $TF $DIR/$tfile || error "cmp failed"
6418 lctl set_param fail_loc=0
6422 run_test 152 "test read/write with enomem ============================"
6425 multiop $DIR/$tfile Ow4096Ycu || error "multiop failed"
6427 run_test 153 "test if fdatasync does not crash ======================="
6430 # do directio so as not to populate the page cache
6431 log "creating a 10 Mb file"
6432 multiop $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
6433 log "starting reads"
6434 dd if=$DIR/$tfile of=/dev/null bs=4096 &
6435 log "truncating the file"
6436 multiop $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
6438 kill %+ || true # reads might have finished
6439 echo "wait until dd is finished"
6441 log "removing the temporary file"
6442 rm -rf $DIR/$tfile || error "tmp file removal failed"
6444 run_test 154 "parallel read and truncate should not deadlock ==="
6447 local temp=$TMP/$tfile
6448 local file=$DIR/$tfile
6449 local list=$(comma_list $(osts_nodes))
6450 local big=$(do_nodes $list grep "cache" /proc/cpuinfo | \
6451 awk '{sum+=$4} END{print sum}')
6455 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
6456 error "dd of=$temp bs=6096 count=1 failed"
6458 cancel_lru_locks osc
6459 cmp $temp $file || error "$temp $file differ"
6461 $TRUNCATE $temp 6000
6462 $TRUNCATE $file 6000
6463 cmp $temp $file || error "$temp $file differ (truncate1)"
6465 echo "12345" >>$temp
6466 echo "12345" >>$file
6467 cmp $temp $file || error "$temp $file differ (append1)"
6469 echo "12345" >>$temp
6470 echo "12345" >>$file
6471 cmp $temp $file || error "$temp $file differ (append2)"
6473 dd if=/dev/urandom of=$temp bs=$((big*2)) count=1k || \
6474 error "dd of=$temp bs=$((big*2)) count=1k failed"
6477 cancel_lru_locks osc
6478 cmp $temp $file || error "$temp $file differ"
6486 set_cache writethrough on
6489 run_test 155a "Verification of correctness: read cache:on write_cache:on"
6493 set_cache writethrough off
6496 run_test 155b "Verification of correctness: read cache:on write_cache:off"
6500 set_cache writethrough on
6503 run_test 155c "Verification of correctness: read cache:off write_cache:on"
6507 set_cache writethrough off
6510 run_test 155d "Verification of correctness: read cache:off write_cache:off "
6516 local file="$DIR/$tfile"
6518 log "Turn on read and write cache"
6520 set_cache writethrough on
6522 log "Write data and read it back."
6523 log "Read should be satisfied from the cache."
6524 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
6526 cancel_lru_locks osc
6527 cat $file >/dev/null
6529 if ! let "AFTER - BEFORE == CPAGES"; then
6530 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
6532 log "cache hits:: before: $BEFORE, after: $AFTER"
6535 log "Read again; it should be satisfied from the cache."
6537 cancel_lru_locks osc
6538 cat $file >/dev/null
6540 if ! let "AFTER - BEFORE == CPAGES"; then
6541 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
6543 log "cache hits:: before: $BEFORE, after: $AFTER"
6547 log "Turn off the read cache and turn on the write cache"
6549 set_cache writethrough on
6551 log "Read again; it should be satisfied from the cache."
6553 cancel_lru_locks osc
6554 cat $file >/dev/null
6556 if ! let "AFTER - BEFORE == CPAGES"; then
6557 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
6559 log "cache hits:: before: $BEFORE, after: $AFTER"
6562 log "Read again; it should not be satisfied from the cache."
6564 cancel_lru_locks osc
6565 cat $file >/dev/null
6567 if ! let "AFTER - BEFORE == 0"; then
6568 error "IN CACHE: before: $BEFORE, after: $AFTER"
6570 log "cache hits:: before: $BEFORE, after: $AFTER"
6573 log "Write data and read it back."
6574 log "Read should be satisfied from the cache."
6575 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
6577 cancel_lru_locks osc
6578 cat $file >/dev/null
6580 if ! let "AFTER - BEFORE == CPAGES"; then
6581 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
6583 log "cache hits:: before: $BEFORE, after: $AFTER"
6586 log "Read again; it should not be satisfied from the cache."
6588 cancel_lru_locks osc
6589 cat $file >/dev/null
6591 if ! let "AFTER - BEFORE == 0"; then
6592 error "IN CACHE: before: $BEFORE, after: $AFTER"
6594 log "cache hits:: before: $BEFORE, after: $AFTER"
6598 log "Turn off read and write cache"
6600 set_cache writethrough off
6602 log "Write data and read it back"
6603 log "It should not be satisfied from the cache."
6605 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
6606 cancel_lru_locks osc
6608 cat $file >/dev/null
6610 if ! let "AFTER - BEFORE == 0"; then
6611 error_ignore 20762 "IN CACHE: before: $BEFORE, after: $AFTER"
6613 log "cache hits:: before: $BEFORE, after: $AFTER"
6617 log "Turn on the read cache and turn off the write cache"
6619 set_cache writethrough off
6621 log "Write data and read it back"
6622 log "It should not be satisfied from the cache."
6624 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
6626 cancel_lru_locks osc
6627 cat $file >/dev/null
6629 if ! let "AFTER - BEFORE == 0"; then
6630 error_ignore 20762 "IN CACHE: before: $BEFORE, after: $AFTER"
6632 log "cache hits:: before: $BEFORE, after: $AFTER"
6635 log "Read again; it should be satisfied from the cache."
6637 cancel_lru_locks osc
6638 cat $file >/dev/null
6640 if ! let "AFTER - BEFORE == CPAGES"; then
6641 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
6643 log "cache hits:: before: $BEFORE, after: $AFTER"
6648 run_test 156 "Verification of ROC tunables ========================"
6651 $LCTL clear # bug 18514
6652 $LCTL debug_daemon start $TMP/${tfile}_log_good
6654 $LCTL debug_daemon stop
6655 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
6656 error "sed failed to read log_good"
6658 $LCTL debug_daemon start $TMP/${tfile}_log_good
6660 $LCTL debug_daemon stop
6662 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
6663 error "lctl df log_bad failed"
6665 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
6666 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
6668 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
6669 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
6671 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
6672 error "bad_line good_line1 good_line2 are empty"
6674 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
6675 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
6676 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
6678 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
6679 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
6680 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
6682 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
6683 error "bad_line_new good_line_new are empty"
6685 local expected_good=$((good_line1 + good_line2*2))
6687 rm -f $TMP/${tfile}*
6688 # LU-231, short malformed line may not be counted into bad lines
6689 if [ $bad_line -ne $bad_line_new ] &&
6690 [ $bad_line -ne $((bad_line_new - 1)) ]; then
6691 error "expected $bad_line bad lines, but got $bad_line_new"
6695 if [ $expected_good -ne $good_line_new ]; then
6696 error "expected $expected_good good lines, but got $good_line_new"
6701 run_test 170 "test lctl df to handle corrupted log ====================="
6703 test_171() { # bug20592
6704 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
6705 $LCTL set_param fail_loc=0x50e
6706 $LCTL set_param fail_val=3000
6707 multiop_bg_pause $DIR/$tfile O_s || true
6709 kill -USR1 $MULTIPID
6713 if dmesg | grep "recursive fault"; then
6714 error "caught a recursive fault"
6716 $LCTL set_param fail_loc=0
6719 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
6721 obdecho_create_test() {
6725 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
6726 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" || rc=2; }
6727 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec create 1" || rc=3; }
6728 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec test_brw 0 w 1" || rc=4; }
6729 [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec cleanup" || rc=5; }
6730 [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec detach" || rc=6; }
6735 local lustre_version=$(get_lustre_version mds)
6736 if [[ $lustre_version != 1.8* ]]; then
6737 skip bug22316 mds running $lustre_version
6742 local rmmod_remote=0
6744 lsmod | grep -q obdecho || { load_module obdecho/obdecho && rmmod_local=1; }
6746 OBD=`$LCTL dl | awk ' /-osc-/ { print $4; exit; }'`
6747 [ "x$OBD" != "x" ] && { obdecho_create_test $OBD client || rc=2; }
6748 [ $rmmod_local -eq 1 ] && rmmod obdecho
6749 [ $rc -ne 0 ] && return $rc
6751 do_facet ost1 "lsmod | grep -q obdecho || \
6752 { insmod $LUSTRE/obdecho/obdecho.ko || modprobe obdecho; }" && \
6755 OBD=$(do_facet ost1 "$LCTL dl | awk '/obdfilter/ { print; exit; }'" | \
6757 [ "x$OBD" != "x" ] && { obdecho_create_test $OBD ost1 || rc=3; }
6758 [ $rmmod_remote -eq 1 ] && do_facet ost1 "rmmod obdecho"
6759 [ $rc -ne 0 ] && return $rc
6763 run_test 180 "test obdecho ============================================"
6765 test_181() { # bug 22177
6766 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
6767 # create enough files to index the directory
6768 createmany -o $DIR/$tdir/foobar 4000
6769 # print attributes for debug purpose
6772 multiop_bg_pause $DIR/$tdir D_Sc || return 1
6774 # remove the files & current working dir
6775 unlinkmany $DIR/$tdir/foobar 4000
6777 kill -USR1 $MULTIPID
6779 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
6782 run_test 181 "Test open-unlinked dir ========================"
6787 TGTPOOL_MAX=$(($TGT_COUNT - 1))
6789 TGTPOOL_LIST=`seq $TGTPOOL_FIRST $TGTPOOL_STEP $TGTPOOL_MAX`
6790 POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
6791 POOL_DIR_NAME=dir_tst
6792 POOL_DIR=$POOL_ROOT/$POOL_DIR_NAME
6793 POOL_FILE=$POOL_ROOT/file_tst
6797 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep pools)" ] &&
6798 skip "missing pools support on server" && return 1
6799 remote_mgs_nodsh && skip "remote MGS with nodsh" && return 1
6800 [ -z "$mdtlov" ] && mdtlov=$(get_mdtlov_proc_path $FSNAME)
6804 check_file_in_pool()
6807 res=$($GETSTRIPE $file | grep 0x | cut -f2)
6810 found=$(echo :$TGTPOOL_LIST: | tr " " ":" | grep :$i:)
6811 if [[ "$found" == "" ]]
6813 echo "pool list: $TGTPOOL_LIST"
6814 echo "striping: $res"
6815 error "$file not allocated in $POOL"
6824 trap "cleanup_pools $FSNAME" EXIT
6827 test_pools || return 0
6829 create_pool $FSNAME.$POOL || return $?
6830 [ $($LFS pool_list $FSNAME | grep -c $POOL) -eq 1 ] ||
6831 error "$POOL not in lfs pool_list"
6833 run_test 200a "Create new pool =========================================="
6836 test_pools || return 0
6837 TGT=$(for i in $TGTPOOL_LIST; do printf "$FSNAME-OST%04x_UUID " $i; done)
6838 do_facet mgs $LCTL pool_add $FSNAME.$POOL \
6839 $FSNAME-OST[$TGTPOOL_FIRST-$TGTPOOL_MAX/$TGTPOOL_STEP]
6841 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL | sort -u | tr '\n' ' ' " "$TGT" ||
6842 error "Add to pool failed"
6844 run_test 200b "Add targets to a pool ===================================="
6847 test_pools || return 0
6849 $SETSTRIPE -c 2 -p $POOL $POOL_DIR
6850 [ $? = 0 ] || error "Cannot set pool $POOL to $POOL_DIR"
6851 # b-19919 test relative path works well
6852 mkdir -p $POOL_DIR/$POOL_DIR_NAME
6854 $SETSTRIPE -c 2 -p $POOL $POOL_DIR_NAME
6855 [ $? = 0 ] || error "Cannot set pool $POOL to $POOL_DIR/$POOL_DIR_NAME"
6856 $SETSTRIPE -c 2 -p $POOL ./$POOL_DIR_NAME
6857 [ $? = 0 ] || error "Cannot set pool $POOL to $POOL_DIR/./$POOL_DIR_NAME"
6858 $SETSTRIPE -c 2 -p $POOL ../$POOL_DIR_NAME
6859 [ $? = 0 ] || error "Cannot set pool $POOL to $POOL_DIR/../$POOL_DIR_NAME"
6860 $SETSTRIPE -c 2 -p $POOL ../$POOL_DIR_NAME/$POOL_DIR_NAME
6861 [ $? = 0 ] || error "Cannot set pool $POOL to $POOL_DIR/../$POOL_DIR_NAME/$POOL_DIR_NAME"
6862 rm -rf $POOL_DIR_NAME; cd -
6864 run_test 200c "Set pool on a directory ================================="
6867 test_pools || return 0
6868 res=$($GETSTRIPE --pool $POOL_DIR | awk '/^pool:/ {print $2}')
6869 [ "$res" = $POOL ] || error "Pool on $POOL_DIR is $res, not $POOL"
6871 run_test 200d "Check pool on a directory ==============================="
6874 test_pools || return 0
6876 for i in $(seq -w 1 $(($TGT_COUNT * 3))); do
6877 file=$POOL_DIR/file-$i
6879 check_file_in_pool $file
6880 if [[ $? != 0 ]]; then
6881 failed=$(($failed + 1))
6884 [ "$failed" = 0 ] || error "$failed files not allocated in $POOL"
6886 run_test 200e "Check files allocation from directory pool =============="
6889 test_pools || return 0
6892 for i in $(seq -w 1 $(($TGT_COUNT * 3))); do
6893 file=$POOL_FILE/spoo-$i
6894 $SETSTRIPE -p $POOL $file
6895 check_file_in_pool $file
6896 if [[ $? != 0 ]]; then
6897 failed=$(($failed + 1))
6900 [ "$failed" = 0 ] || error "$failed files not allocated in $POOL"
6902 run_test 200f "Create files in a pool ==================================="
6905 test_pools || return 0
6907 TGT=$($LCTL get_param -n lov.$FSNAME-clilov-*.pools.$POOL | tr '\n' ' ')
6908 res=$($LFS df --pool $FSNAME.$POOL | awk '{print $1}' | grep "$FSNAME-OST" | tr '\n' ' ')
6909 [ "$res" = "$TGT" ] || error "Pools OSTs '$TGT' is not '$res' that lfs df reports"
6911 run_test 200g "lfs df a pool ============================================"
6913 test_200h() { # b=24039
6914 test_pools || return 0
6915 mkdir -p $POOL_DIR || error "unable to create $POOL_DIR"
6917 local file="/..$POOL_DIR/$tfile-1"
6918 $SETSTRIPE -p $POOL $file || error "unable to create $file"
6921 $SETSTRIPE -p $POOL $tfile-2 || \
6922 error "unable to create $tfile-2 in $POOL_DIR"
6924 run_test 200h "Create files in a pool with relative pathname ============"
6927 test_pools || return 0
6929 TGT=$($LCTL get_param -n lov.$FSNAME-*.pools.$POOL | head -1)
6930 do_facet mgs $LCTL pool_remove $FSNAME.$POOL $TGT
6931 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL | grep $TGT" "" ||
6932 error "$TGT not removed from $FSNAME.$POOL"
6934 run_test 201a "Remove a target from a pool ============================="
6937 test_pools || return 0
6939 for TGT in $($LCTL get_param -n lov.$FSNAME-*.pools.$POOL | sort -u)
6941 do_facet mgs $LCTL pool_remove $FSNAME.$POOL $TGT
6943 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL" "" ||
6944 error "Pool $FSNAME.$POOL cannot be drained"
6945 # striping on an empty/nonexistant pool should fall back to "pool of everything"
6946 touch ${POOL_DIR}/$tfile || error "failed to use fallback striping for empty pool"
6947 # setstripe on an empty pool should fail
6948 $SETSTRIPE -p $POOL ${POOL_FILE}/$tfile 2>/dev/null && \
6949 error "expected failure when creating file with empty pool"
6952 run_test 201b "Remove all targets from a pool =========================="
6955 test_pools || return 0
6957 do_facet mgs $LCTL pool_destroy $FSNAME.$POOL
6960 # striping on an empty/nonexistant pool should fall back to "pool of everything"
6961 touch ${POOL_DIR}/$tfile || error "failed to use fallback striping for missing pool"
6962 # setstripe on an empty pool should fail
6963 $SETSTRIPE -p $POOL ${POOL_FILE}/$tfile 2>/dev/null && \
6964 error "expected failure when creating file with missing pool"
6966 # get param should return err once pool is gone
6967 if wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null ||
6968 echo foo" "foo"; then
6969 remove_pool_from_list $FSNAME.$POOL
6972 error "Pool $FSNAME.$POOL is not destroyed"
6974 run_test 201c "Remove a pool ============================================"
6976 cleanup_pools $FSNAME
6979 if [ "$NETTYPE" = "o2ib" ]; then
6980 skip "unaligned direct I/O is not supported by o2iblnd"
6983 $LFS setstripe -c 2 -s 1048576 $DIR/$tfile
6984 multiop $DIR/$tfile oO_WRONLY:O_APPEND:O_DIRECT:b1048548b130c || \
6985 error "direct write failed"
6986 multiop $DIR/${tfile}2 oO_WRONLY:O_CREAT:w1048548w130c || \
6987 error "cached write failed"
6988 cmp $DIR/$tfile $DIR/${tfile}2 || error "cmp failed"
6989 rm -f $DIR/${tfile}2
6991 run_test 202 "O_APPEND+O_DIRECT multistripe write ========================"
6994 local lustre_version=$(get_lustre_version mds)
6995 if [[ $lustre_version != 1.8* ]]; then
6996 skip bug23766 mds running $lustre_version
7000 local ATIME=`do_facet mds lctl get_param -n mds.*.atime_diff`
7001 echo "atime should be updated on the MDS when closing file" > $DIR/$tfile
7003 # reads should update atime on the client and close should update it on the MDS
7004 multiop_bg_pause $DIR/$tfile o_r20c || return 1
7009 kill -USR1 $MULTIPID || return 2
7010 echo "starting reads"
7012 cancel_lru_locks osc
7013 cancel_lru_locks mdc
7014 time2=`stat -c "%X" $DIR/$tfile`
7015 log "new atime is $time2"
7016 [ "$time2" -ge "$time1" ] || error "atime was not updated"
7018 run_test 203 " atime should be updated on the MDS when closing file ===="
7020 # usage: default_attr <count | size | offset>
7022 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
7025 # if there are two arguments, the second must be "--raw"
7026 check_default_stripe_attr() {
7027 ACTUAL=$($GETSTRIPE $* $DIR/$tdir)
7030 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
7032 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
7036 error "unknown getstripe attr '$1'"
7039 [ $ACTUAL != $EXPECTED ] &&
7040 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
7046 $SETSTRIPE --count 0 --size 0 --index -1 $DIR/$tdir
7048 check_default_stripe_attr --count
7049 check_default_stripe_attr --size
7050 check_default_stripe_attr --index
7054 run_test 204a "Print default stripe attributes ================="
7058 $SETSTRIPE --count 1 $DIR/$tdir
7060 check_default_stripe_attr --size
7061 check_default_stripe_attr --index
7065 run_test 204b "Print default stripe size and index ==========="
7069 $SETSTRIPE --size 65536 $DIR/$tdir
7071 check_default_stripe_attr --count
7072 check_default_stripe_attr --index
7076 run_test 204c "Print default stripe count and index ==========="
7080 $SETSTRIPE --index 0 $DIR/$tdir
7082 check_default_stripe_attr --count
7083 check_default_stripe_attr --size
7087 run_test 204d "Print default stripe count and size ============="
7091 $SETSTRIPE --count 1 $DIR/$tdir
7093 check_default_stripe_attr --size --raw
7094 check_default_stripe_attr --index --raw
7098 run_test 204f "Print raw stripe size and index ==========="
7102 $SETSTRIPE --size 65536 $DIR/$tdir
7104 check_default_stripe_attr --count --raw
7105 check_default_stripe_attr --index --raw
7109 run_test 204g "Print raw stripe count and index ==========="
7113 $SETSTRIPE --index 0 $DIR/$tdir
7115 check_default_stripe_attr --count --raw
7116 check_default_stripe_attr --size --raw
7120 run_test 204h "Print raw stripe count and size ============="
7123 # tests that do cleanup/setup should be run at the end
7128 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
7129 $LCTL set_param fail_loc=0x903
7130 # cancel_lru_locks mgc - does not work due to lctl set_param syntax
7131 for ls in /proc/fs/lustre/ldlm/namespaces/MGC*/lru_size; do
7134 FAIL_ON_ERROR=true cleanup
7135 FAIL_ON_ERROR=true setup
7137 run_test 900 "umount should not race with any mgc requeue thread"
7139 complete $(basename $0) $SECONDS
7140 check_and_cleanup_lustre
7141 if [ "$I_MOUNTED" != "yes" ]; then
7142 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true