3 # Run select tests by setting ONLY, or as arguments to the script.
4 # Skip specific tests by setting EXCEPT.
6 # e.g. ONLY="22 23" or ONLY="`seq 32 39`" or EXCEPT="31"
10 # bug number for skipped test: 13297 2108 9789 3637 9789 3561 12622 5188
11 ALWAYS_EXCEPT=" 27u 42a 42b 42c 42d 45 51d 68b $SANITY_EXCEPT"
12 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
14 # with LOD/OSP landing
15 # bug number for skipped tests: LU-2036
16 ALWAYS_EXCEPT=" 76 $ALWAYS_EXCEPT"
19 # Tests that fail on uml
20 CPU=`awk '/model/ {print $4}' /proc/cpuinfo`
21 # buffer i/o errs sock spc runas
22 [ "$CPU" = "UML" ] && EXCEPT="$EXCEPT 27m 27n 27o 27p 27q 27r 31d 54a 64b 99a 99b 99c 99d 99e 99f 101a"
24 SRCDIR=$(cd $(dirname $0); echo $PWD)
25 export PATH=$PATH:/sbin
29 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
30 CREATETEST=${CREATETEST:-createtest}
32 LFIND=${LFIND:-"$LFS find"}
33 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
35 MCREATE=${MCREATE:-mcreate}
36 OPENFILE=${OPENFILE:-openfile}
37 OPENUNLINK=${OPENUNLINK:-openunlink}
38 export MULTIOP=${MULTIOP:-multiop}
39 READS=${READS:-"reads"}
40 MUNLINK=${MUNLINK:-munlink}
41 SOCKETSERVER=${SOCKETSERVER:-socketserver}
42 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
43 MEMHOG=${MEMHOG:-memhog}
44 DIRECTIO=${DIRECTIO:-directio}
45 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
46 UMOUNT=${UMOUNT:-"umount -d"}
48 CHECK_GRANT=${CHECK_GRANT:-"yes"}
49 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
51 export NAME=${NAME:-local}
58 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
59 . $LUSTRE/tests/test-framework.sh
61 . ${CONFIG:=$LUSTRE/tests/cfg/${NAME}.sh}
64 [ "$SLOW" = "no" ] && EXCEPT_SLOW="24o 24v 27m 36f 36g 36h 51b 60c 63 64b 68 71 73 77f 78 101a 103 115 120g 124b"
70 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
71 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
80 check_kernel_version() {
82 GOT_VER=$(lctl get_param -n version | awk '/kernel:/ {print $2}')
84 patchless|patchless_client) return 0;;
85 *) [ $GOT_VER -ge $WANT_VER ] && return 0 ;;
87 log "test needs at least kernel version $WANT_VER, running $GOT_VER"
91 if [ "$ONLY" == "cleanup" ]; then
96 check_and_setup_lustre
101 MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid | \
102 awk '{gsub(/_UUID/,""); print $1}' | head -1)
103 LOVNAME=$($LCTL get_param -n llite.*.lov.common_name | tail -n 1)
104 OSTCOUNT=$($LCTL get_param -n lov.$LOVNAME.numobd)
105 STRIPECOUNT=$($LCTL get_param -n lov.$LOVNAME.stripecount)
106 STRIPESIZE=$($LCTL get_param -n lov.$LOVNAME.stripesize)
107 ORIGFREE=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
108 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
110 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
111 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
112 rm -rf $DIR/[Rdfs][0-9]*
114 # $RUNAS_ID may get set incorrectly somewhere else
115 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
117 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
121 if [ "${ONLY}" = "MOUNT" ] ; then
122 echo "Lustre is up, please go on"
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 mkdir $DIR/d1/d2 && error "we expect EEXIST, but not returned"
160 $CHECKSTAT -t dir $DIR/d1/d2 || error
162 run_test 1a "mkdir .../d1; mkdir .../d1/d2 ====================="
167 $CHECKSTAT -a $DIR/d1 || error
169 run_test 1b "rmdir .../d1/d2; rmdir .../d1 ====================="
174 $CHECKSTAT -t file $DIR/d2/f || error
176 run_test 2a "mkdir .../d2; touch .../d2/f ======================"
180 $CHECKSTAT -a $DIR/d2 || error
182 run_test 2b "rm -r .../d2; checkstat .../d2/f ======================"
186 $CHECKSTAT -t dir $DIR/d3 || error
188 run_test 3a "mkdir .../d3 ======================================"
191 if [ ! -d $DIR/d3 ]; then
195 $CHECKSTAT -t file $DIR/d3/f || error
197 run_test 3b "touch .../d3/f ===================================="
201 $CHECKSTAT -a $DIR/d3 || error
203 run_test 3c "rm -r .../d3 ======================================"
207 $CHECKSTAT -t dir $DIR/d4 || error
209 run_test 4a "mkdir .../d4 ======================================"
212 if [ ! -d $DIR/d4 ]; then
216 $CHECKSTAT -t dir $DIR/d4/d2 || error
218 run_test 4b "mkdir .../d4/d2 ==================================="
223 chmod 0707 $DIR/d5/d2
224 $CHECKSTAT -t dir -p 0707 $DIR/d5/d2 || error
226 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2 ============"
230 chmod 0666 $DIR/f6a || error
231 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/f6a || error
233 run_test 6a "touch .../f6a; chmod .../f6a ======================"
236 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
237 if [ ! -f $DIR/f6a ]; then
241 $RUNAS chmod 0444 $DIR/f6a && error
242 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/f6a || error
244 run_test 6b "$RUNAS chmod .../f6a (should return error) =="
247 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
249 chown $RUNAS_ID $DIR/f6c || error
250 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/f6c || error
252 run_test 6c "touch .../f6c; chown .../f6c ======================"
255 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
256 if [ ! -f $DIR/f6c ]; then
258 chown $RUNAS_ID $DIR/f6c
260 $RUNAS chown $UID $DIR/f6c && error
261 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/f6c || error
263 run_test 6d "$RUNAS chown .../f6c (should return error) =="
266 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
268 chgrp $RUNAS_ID $DIR/f6e || error
269 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/f6e || error
271 run_test 6e "touch .../f6e; chgrp .../f6e ======================"
274 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
275 if [ ! -f $DIR/f6e ]; then
277 chgrp $RUNAS_ID $DIR/f6e
279 $RUNAS chgrp $UID $DIR/f6e && error
280 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/f6e || error
282 run_test 6f "$RUNAS chgrp .../f6e (should return error) =="
285 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
286 mkdir $DIR/d6g || error
287 chmod 777 $DIR/d6g || error
288 $RUNAS mkdir $DIR/d6g/d || error
289 chmod g+s $DIR/d6g/d || error
290 mkdir $DIR/d6g/d/subdir
291 $CHECKSTAT -g \#$RUNAS_GID $DIR/d6g/d/subdir || error
293 run_test 6g "Is new dir in sgid dir inheriting group?"
295 test_6h() { # bug 7331
296 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
297 touch $DIR/f6h || error "touch failed"
298 chown $RUNAS_ID:$RUNAS_GID $DIR/f6h || error "initial chown failed"
299 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/f6h && error "chown worked"
300 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/f6h || error
302 run_test 6h "$RUNAS chown RUNAS_ID.0 .../f6h (should return error)"
308 $CHECKSTAT -t file -p 0666 $DIR/d7/f || error
310 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
313 if [ ! -d $DIR/d7 ]; then
317 echo -n foo > $DIR/d7/f2
318 [ "`cat $DIR/d7/f2`" = "foo" ] || error
319 $CHECKSTAT -t file -s 3 $DIR/d7/f2 || error
321 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
327 $CHECKSTAT -t file -p 0666 $DIR/d8/f || error
329 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
335 $CHECKSTAT -t dir $DIR/d9/d2/d3 || error
337 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
343 $CHECKSTAT -t file $DIR/d10/d2/f || error
345 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
350 chmod 0666 $DIR/d11/d2
351 chmod 0705 $DIR/d11/d2
352 $CHECKSTAT -t dir -p 0705 $DIR/d11/d2 || error
354 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
359 chmod 0666 $DIR/d12/f
360 chmod 0654 $DIR/d12/f
361 $CHECKSTAT -t file -p 0654 $DIR/d12/f || error
363 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
367 dd if=/dev/zero of=$DIR/d13/f count=10
369 $CHECKSTAT -t file -s 0 $DIR/d13/f || error
371 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
377 $CHECKSTAT -a $DIR/d14/f || error
379 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
384 mv $DIR/d15/f $DIR/d15/f2
385 $CHECKSTAT -t file $DIR/d15/f2 || error
387 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
393 $CHECKSTAT -a $DIR/d16/f || error
395 run_test 16 "touch .../d16/f; rm -rf .../d16/f ================="
400 ln -s $DIR/d17/f $DIR/d17/l-exist
402 $CHECKSTAT -l $DIR/d17/f $DIR/d17/l-exist || error
403 $CHECKSTAT -f -t f $DIR/d17/l-exist || error
404 rm -f $DIR/d17/l-exist
405 $CHECKSTAT -a $DIR/d17/l-exist || error
407 run_test 17a "symlinks: create, remove (real) =================="
411 ln -s no-such-file $DIR/d17/l-dangle
413 $CHECKSTAT -l no-such-file $DIR/d17/l-dangle || error
414 $CHECKSTAT -fa $DIR/d17/l-dangle || error
415 rm -f $DIR/d17/l-dangle
416 $CHECKSTAT -a $DIR/d17/l-dangle || error
418 run_test 17b "symlinks: create, remove (dangling) =============="
420 test_17c() { # bug 3440 - don't save failed open RPC for replay
422 ln -s foo $DIR/d17/f17c
423 cat $DIR/d17/f17c && error "opened non-existent symlink" || true
425 run_test 17c "symlinks: open dangling (should return error) ===="
429 ln -s foo $DIR/d17/f17d
430 touch $DIR/d17/f17d || error "creating to new symlink"
432 run_test 17d "symlinks: create dangling ========================"
436 local foo=$DIR/$tdir/$tfile
437 ln -s $foo $foo || error "create symlink failed"
438 ls -l $foo || error "ls -l failed"
439 ls $foo && error "ls not failed" || true
441 run_test 17e "symlinks: create recursive symlink (should return error) ===="
445 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/d17f/111
446 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/d17f/222
447 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/d17f/333
448 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/d17f/444
449 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/d17f/555
450 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890/aaaaaaaaaa/bbbbbbbbbb/cccccccccc/dddddddddd/eeeeeeeeee/ffffffffff/ $DIR/d17f/666
453 run_test 17f "symlinks: long and very long symlink name ========================"
455 # str_repeat(S, N) generate a string that is string S repeated N times
460 while [ $((n -= 1)) -ge 0 ]; do
466 # Long symlinks and LU-2241
469 local TESTS="59 60 61 4094 4095"
472 local SYMNAME=$(str_repeat 'x' $i)
473 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
474 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
477 run_test 17g "symlinks: really long symlink name and inode boundaries"
479 test_17h() { #bug 17378
480 remote_mds_nodsh && skip "remote MDS with nodsh" && return
482 $SETSTRIPE -c -1 $DIR/$tdir
483 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
484 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000141
485 touch $DIR/$tdir/$tfile || true
487 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
489 test_17i() { #bug 20018
490 remote_mds_nodsh && skip "remote MDS with nodsh" && return
492 local foo=$DIR/$tdir/$tfile
493 ln -s $foo $foo || error "create symlink failed"
494 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
495 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000143
496 ls -l $foo && error "error not detected"
499 run_test 17i "don't panic on short symlink"
501 test_17k() { #bug 22301
502 rsync --help | grep -q xattr ||
503 skip_env "$(rsync --version| head -1) does not support xattrs"
504 mkdir -p $DIR/{$tdir,$tdir.new}
505 touch $DIR/$tdir/$tfile
506 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
507 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
508 error "rsync failed with xattrs enabled"
510 run_test 17k "symlinks: rsync with xattrs enabled ========================="
514 local short_sym="0123456789"
515 local WDIR=$DIR/${tdir}m
522 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
523 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
524 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
526 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
527 skip "only for ldiskfs MDT" && return 0
531 # create a long symlink file
532 for ((i = 0; i < 4; ++i)); do
533 long_sym=${long_sym}${long_sym}
536 echo "create 512 short and long symlink files under $WDIR"
537 for ((i = 0; i < 256; ++i)); do
538 ln -sf ${long_sym}"a5a5" $WDIR/long-$i
539 ln -sf ${short_sym}"a5a5" $WDIR/short-$i
545 wait_delete_completed
547 echo "recreate the 512 symlink files with a shorter string"
548 for ((i = 0; i < 512; ++i)); do
549 # rewrite the symlink file with a shorter string
550 ln -sf ${long_sym} $WDIR/long-$i
551 ln -sf ${short_sym} $WDIR/short-$i
554 mds_index=$($LFS getstripe -M $WDIR)
555 mds_index=$((mds_index+1))
556 devname=$(mdsdevname $mds_index)
557 cmd="$E2FSCK -fnvd $devname"
559 echo "stop and checking mds${mds_index}: $cmd"
560 # e2fsck should not return error
561 stop mds${mds_index} -f
562 do_facet mds${mds_index} $cmd || rc=$?
564 start mds${mds_index} $devname $MDS_MOUNT_OPTS
565 df $MOUNT > /dev/null 2>&1
566 [ $rc -ne 0 ] && error "e2fsck should not report error upon "\
567 "short/long symlink MDT: rc=$rc"
570 run_test 17m "run e2fsck against MDT which contains short/long symlink"
576 run_test 18 "touch .../f ; ls ... =============================="
582 $CHECKSTAT -a $DIR/f19 || error
584 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
587 ls -l $DIR/f19 && error || true
589 run_test 19b "ls -l .../f19 (should return error) =============="
592 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
593 $RUNAS touch $DIR/f19 && error || true
595 run_test 19c "$RUNAS touch .../f19 (should return error) =="
598 cat $DIR/f19 && error || true
600 run_test 19d "cat .../f19 (should return error) =============="
612 $CHECKSTAT -a $DIR/f || error
614 run_test 20 "touch .../f ; ls -l ... ==========================="
618 [ -f $DIR/d21/dangle ] && rm -f $DIR/d21/dangle
619 ln -s dangle $DIR/d21/link
620 echo foo >> $DIR/d21/link
622 $CHECKSTAT -t link $DIR/d21/link || error
623 $CHECKSTAT -f -t file $DIR/d21/link || error
625 run_test 21 "write to dangling link ============================"
630 chown $RUNAS_ID:$RUNAS_GID $WDIR
631 (cd $WDIR || error "cd $WDIR failed";
632 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
634 ls -lR $WDIR/etc || error "ls -lR $WDIR/etc failed"
635 $CHECKSTAT -t dir $WDIR/etc || error "checkstat -t dir failed"
636 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $WDIR/etc || error "checkstat -u failed"
638 run_test 22 "unpack tar archive as non-root user ==============="
643 local file=$DIR/$tdir/$tfile
645 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
646 openfile -f O_CREAT:O_EXCL $file &&
647 error "$file recreate succeeded" || true
649 run_test 23a "O_CREAT|O_EXCL in subdir =========================="
651 test_23b() { # bug 18988
653 local file=$DIR/$tdir/$tfile
656 echo foo > $file || error "write filed"
657 echo bar >> $file || error "append filed"
658 $CHECKSTAT -s 8 $file || error "wrong size"
661 run_test 23b "O_APPEND check =========================="
664 echo '== rename sanity =============================================='
665 echo '-- same directory rename'
668 mv $DIR/R1/f $DIR/R1/g
669 $CHECKSTAT -t file $DIR/R1/g || error
671 run_test 24a "touch .../R1/f; rename .../R1/f .../R1/g ========="
676 mv $DIR/R2/f $DIR/R2/g
677 $CHECKSTAT -a $DIR/R2/f || error
678 $CHECKSTAT -t file $DIR/R2/g || error
680 run_test 24b "touch .../R2/{f,g}; rename .../R2/f .../R2/g ====="
685 mv $DIR/R3/f $DIR/R3/g
686 $CHECKSTAT -a $DIR/R3/f || error
687 $CHECKSTAT -t dir $DIR/R3/g || error
689 run_test 24c "mkdir .../R3/f; rename .../R3/f .../R3/g ========="
694 mrename $DIR/R4/f $DIR/R4/g
695 $CHECKSTAT -a $DIR/R4/f || error
696 $CHECKSTAT -t dir $DIR/R4/g || error
698 run_test 24d "mkdir .../R4/{f,g}; rename .../R4/f .../R4/g ====="
701 echo '-- cross directory renames --'
704 mv $DIR/R5a/f $DIR/R5b/g
705 $CHECKSTAT -a $DIR/R5a/f || error
706 $CHECKSTAT -t file $DIR/R5b/g || error
708 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
712 touch $DIR/R6a/f $DIR/R6b/g
713 mv $DIR/R6a/f $DIR/R6b/g
714 $CHECKSTAT -a $DIR/R6a/f || error
715 $CHECKSTAT -t file $DIR/R6b/g || error
717 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
722 mv $DIR/R7a/d $DIR/R7b/e
723 $CHECKSTAT -a $DIR/R7a/d || error
724 $CHECKSTAT -t dir $DIR/R7b/e || error
726 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
730 mkdir $DIR/R8a/d $DIR/R8b/e
731 mrename $DIR/R8a/d $DIR/R8b/e
732 $CHECKSTAT -a $DIR/R8a/d || error
733 $CHECKSTAT -t dir $DIR/R8b/e || error
735 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
738 echo "-- rename error cases"
742 mrename $DIR/R9/f $DIR/R9/a
743 $CHECKSTAT -t file $DIR/R9/f || error
744 $CHECKSTAT -t dir $DIR/R9/a || error
745 $CHECKSTAT -a $DIR/R9/a/f || error
747 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
751 mrename $DIR/R10/f $DIR/R10/g
752 $CHECKSTAT -t dir $DIR/R10 || error
753 $CHECKSTAT -a $DIR/R10/f || error
754 $CHECKSTAT -a $DIR/R10/g || error
756 run_test 24j "source does not exist ============================"
759 mkdir $DIR/R11a $DIR/R11a/d
761 mv $DIR/R11a/f $DIR/R11a/d
762 $CHECKSTAT -a $DIR/R11a/f || error
763 $CHECKSTAT -t file $DIR/R11a/d/f || error
765 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
767 # bug 2429 - rename foo foo foo creates invalid file
770 $MULTIOP $f OcNs || error
772 run_test 24l "Renaming a file to itself ========================"
776 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
777 # on ext3 this does not remove either the source or target files
778 # though the "expected" operation would be to remove the source
779 $CHECKSTAT -t file ${f} || error "${f} missing"
780 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
782 run_test 24m "Renaming a file to a hard link to itself ========="
786 # this stats the old file after it was renamed, so it should fail
790 $CHECKSTAT ${f}.rename
793 run_test 24n "Statting the old file after renaming (Posix rename 2)"
796 check_kernel_version 37 || return 0
798 rename_many -s random -v -n 10 $DIR/d24o
800 run_test 24o "rename of files during htree split ==============="
804 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
805 mrename $DIR/R12a $DIR/R12b
806 $CHECKSTAT -a $DIR/R12a || error
807 $CHECKSTAT -t dir $DIR/R12b || error
808 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
809 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
811 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
815 DIRINO=`ls -lid $DIR/R13a | awk '{ print $1 }'`
816 multiop_bg_pause $DIR/R13b D_c || return 1
819 mrename $DIR/R13a $DIR/R13b
820 $CHECKSTAT -a $DIR/R13a || error
821 $CHECKSTAT -t dir $DIR/R13b || error
822 DIRINO2=`ls -lid $DIR/R13b | awk '{ print $1 }'`
823 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
825 wait $MULTIPID || error "multiop close failed"
827 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
829 test_24r() { #bug 3789
830 mkdir $DIR/R14a $DIR/R14a/b
831 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
832 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
833 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
835 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
838 mkdir $DIR/R15a $DIR/R15a/b $DIR/R15a/b/c
839 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
840 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
841 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
843 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
845 mkdir $DIR/R16a $DIR/R16a/b $DIR/R16a/b/c
846 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
847 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
848 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
850 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
852 test_24u() { # bug12192
853 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error
854 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
856 run_test 24u "create stripe file"
862 simple_cleanup_common() {
865 wait_delete_completed
870 local FREE_INODES=`lfs df -i|grep "filesystem summary" | awk '{print $5}'`
871 [ $FREE_INODES -lt $NRFILES ] && \
872 skip "not enough free inodes $FREE_INODES required $NRFILES" &&
875 trap simple_cleanup_common EXIT
878 createmany -m $DIR/$tdir/$tfile $NRFILES
881 lctl set_param mdc.*.stats clear
883 ls $DIR/$tdir >/dev/null || error "error in listing large dir"
886 # DIRENT_SIZE = 32 bytes for sizeof(struct lu_dirent) +
887 # 8 bytes for name(filename is mostly 5 in this test) +
888 # 8 bytes for luda_type
889 # take into account of overhead in lu_dirpage header and end mark in
890 # each page, plus one in RPC_NUM calculation.
892 RPC_SIZE=$(($(lctl get_param -n mdc.*.max_pages_per_rpc)*$(page_size)))
893 RPC_NUM=$(((NRFILES * DIRENT_SIZE + RPC_SIZE - 1) / RPC_SIZE + 1))
894 mds_readpage=`lctl get_param mdc.*.stats | \
895 awk '/^mds_readpage/ {print $2}'`
896 [ $mds_readpage -gt $RPC_NUM ] && \
897 error "large readdir doesn't take effect"
899 simple_cleanup_common
901 run_test 24v "list directory with large files (handle hash collision, bug: 17560)"
903 test_24w() { # bug21506
905 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
906 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
907 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
908 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
909 [ "$SZ1" = "$SZ2" ] || \
910 error "Error reading at the end of the file $tfile"
912 run_test 24w "Reading a file larger than 4Gb"
915 echo '== symlink sanity ============================================='
919 touch $DIR/s25/foo || error
921 run_test 25a "create file in symlinked directory ==============="
924 [ ! -d $DIR/d25 ] && test_25a
925 $CHECKSTAT -t file $DIR/s25/foo || error
927 run_test 25b "lookup file in symlinked directory ==============="
932 ln -s d26/d26-2 $DIR/s26
933 touch $DIR/s26/foo || error
935 run_test 26a "multiple component symlink ======================="
938 mkdir -p $DIR/d26b/d26-2
939 ln -s d26b/d26-2/foo $DIR/s26-2
940 touch $DIR/s26-2 || error
942 run_test 26b "multiple component symlink at end of lookup ======"
947 ln -s d26.2 $DIR/s26.2-1
948 ln -s s26.2-1 $DIR/s26.2-2
949 ln -s s26.2-2 $DIR/s26.2-3
950 chmod 0666 $DIR/s26.2-3/foo
952 run_test 26c "chain of symlinks ================================"
954 # recursive symlinks (bug 439)
956 ln -s d26-3/foo $DIR/d26-3
958 run_test 26d "create multiple component recursive symlink ======"
961 [ ! -h $DIR/d26-3 ] && test_26d
964 run_test 26e "unlink multiple component recursive symlink ======"
966 # recursive symlinks (bug 7022)
969 mkdir $DIR/$tdir/$tfile || error "mkdir $DIR/$tdir/$tfile failed"
970 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
971 mkdir -p lndir/bar1 || error "mkdir lndir/bar1 failed"
972 mkdir $tfile || error "mkdir $tfile failed"
973 cd $tfile || error "cd $tfile failed"
974 ln -s .. dotdot || error "ln dotdot failed"
975 ln -s dotdot/lndir lndir || error "ln lndir failed"
976 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
977 output=`ls $tfile/$tfile/lndir/bar1`
978 [ "$output" = bar1 ] && error "unexpected output"
979 rm -r $tfile || error "rm $tfile failed"
980 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
982 run_test 26f "rm -r of a directory which has recursive symlink ="
985 echo '== stripe sanity =============================================='
986 mkdir -p $DIR/d27 || error "mkdir failed"
988 $SETSTRIPE -c 1 $DIR/d27/f0 || error "setstripe failed"
989 $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
991 log "== test_27a: write to one stripe file ========================="
992 cp /etc/hosts $DIR/d27/f0 || error
994 run_test 27a "one stripe file =================================="
997 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
999 $SETSTRIPE -c 2 $DIR/d27/f01 || error "setstripe failed"
1000 $GETSTRIPE -c $DIR/d27/f01
1001 [ $($GETSTRIPE -c $DIR/d27/f01) -eq 2 ] ||
1002 error "two-stripe file doesn't have two stripes"
1004 run_test 27b "create two stripe file"
1007 [ -f $DIR/d27/f01 ] || skip "test_27b not run" && return
1009 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
1011 run_test 27c "write to two stripe file"
1015 $SETSTRIPE -c 0 -i -1 -S 0 $DIR/d27/fdef || error "setstripe failed"
1016 $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
1017 dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
1019 run_test 27d "create file with default settings ================"
1023 $SETSTRIPE -c 2 $DIR/d27/f12 || error "setstripe failed"
1024 $SETSTRIPE -c 2 $DIR/d27/f12 && error "setstripe succeeded twice"
1025 $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
1027 run_test 27e "setstripe existing file (should return error) ======"
1031 $SETSTRIPE -S 100 -i 0 -c 1 $DIR/d27/fbad && error "setstripe failed"
1032 dd if=/dev/zero of=$DIR/d27/f12 bs=4k count=4 || error "dd failed"
1033 $GETSTRIPE $DIR/d27/fbad || error "$GETSTRIPE failed"
1035 run_test 27f "setstripe with bad stripe size (should return error)"
1039 $MCREATE $DIR/d27/fnone || error "mcreate failed"
1040 $GETSTRIPE $DIR/d27/fnone 2>&1 | grep "no stripe info" ||
1041 error "$DIR/d27/fnone has object"
1043 run_test 27g "$GETSTRIPE with no objects"
1046 touch $DIR/d27/fsome || error "touch failed"
1047 [ $($GETSTRIPE -c $DIR/d27/fsome) -gt 0 ] || error "missing objects"
1049 run_test 27i "$GETSTRIPE with some objects"
1053 $SETSTRIPE -i $OSTCOUNT $DIR/d27/f27j && error "setstripe failed"||true
1055 run_test 27j "setstripe with bad stripe offset (should return error)"
1057 test_27k() { # bug 2844
1060 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
1061 [ ! -d $DIR/d27 ] && mkdir -p $DIR/d27
1062 $SETSTRIPE -S 67108864 $FILE || error "setstripe failed"
1063 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1064 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
1065 dd if=/dev/zero of=$FILE bs=4k count=1
1066 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1067 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
1069 run_test 27k "limit i_blksize for broken user apps ============="
1073 mcreate $DIR/f27l || error "creating file"
1074 $RUNAS $SETSTRIPE -c 1 $DIR/f27l && \
1075 error "setstripe should have failed" || true
1077 run_test 27l "check setstripe permissions (should return error)"
1080 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" &&
1082 if [ $ORIGFREE -gt $MAXFREE ]; then
1083 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1086 trap simple_cleanup_common EXIT
1088 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_1
1089 dd if=/dev/zero of=$DIR/$tdir/f27m_1 bs=1024 count=$MAXFREE &&
1090 error "dd should fill OST0"
1092 while $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_$i; do
1094 [ $i -gt 256 ] && break
1097 touch $DIR/$tdir/f27m_$i
1098 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1099 error "OST0 was full but new created file still use it"
1101 touch $DIR/$tdir/f27m_$i
1102 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1103 error "OST0 was full but new created file still use it"
1104 simple_cleanup_common
1106 run_test 27m "create file while OST0 was full =================="
1109 local DELAY=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage | head -n 1 | awk '{print $1 * 2}')
1113 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1114 # if the OST isn't full anymore.
1116 local OSTIDX=${1:-""}
1118 local list=$(comma_list $(osts_nodes))
1119 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1121 do_nodes $list lctl set_param fail_loc=0
1122 sync # initiate all OST_DESTROYs from MDS to OST
1126 exhaust_precreations() {
1129 local FAILIDX=${3:-$OSTIDX}
1132 local MDSIDX=$(get_mds_dir "$DIR/$tdir")
1133 echo OSTIDX=$OSTIDX MDSIDX=$MDSIDX
1135 local OST=$(ostname_from_index $OSTIDX)
1136 local MDT_INDEX=$(lfs df | grep "\[MDT:$((MDSIDX - 1))\]" | awk '{print $1}' | \
1137 sed -e 's/_UUID$//;s/^.*-//')
1140 local mdtosc_proc1=$(get_mdtosc_proc_path mds${MDSIDX} $OST)
1141 local last_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1142 osc.$mdtosc_proc1.prealloc_last_id)
1143 local next_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1144 osc.$mdtosc_proc1.prealloc_next_id)
1146 local mdtosc_proc2=$(get_mdtosc_proc_path mds${MDSIDX})
1147 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1149 mkdir -p $DIR/$tdir/${OST}
1150 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1151 #define OBD_FAIL_OST_ENOSPC 0x215
1152 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=$FAILIDX
1153 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x215
1154 echo "Creating to objid $last_id on ost $OST..."
1155 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1156 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1157 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=$FAILLOC
1161 exhaust_all_precreations() {
1163 for (( i=0; i < OSTCOUNT; i++ )) ; do
1164 exhaust_precreations $i $1 -1
1169 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1170 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1171 remote_ost_nodsh && skip "remote OST with nodsh" && return
1174 rm -f $DIR/$tdir/$tfile
1175 exhaust_precreations 0 0x80000215
1176 $SETSTRIPE -c -1 $DIR/$tdir
1177 touch $DIR/$tdir/$tfile || error
1178 $GETSTRIPE $DIR/$tdir/$tfile
1181 run_test 27n "create file with some full OSTs =================="
1184 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1185 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1186 remote_ost_nodsh && skip "remote OST with nodsh" && return
1189 rm -f $DIR/$tdir/$tfile
1190 exhaust_all_precreations 0x215
1192 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1197 run_test 27o "create file with all full OSTs (should error) ===="
1200 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1201 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1202 remote_ost_nodsh && skip "remote OST with nodsh" && return
1205 rm -f $DIR/$tdir/$tfile
1208 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1209 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1210 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1212 exhaust_precreations 0 0x80000215
1213 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1214 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1215 $GETSTRIPE $DIR/$tdir/$tfile
1219 run_test 27p "append to a truncated file with some full OSTs ==="
1222 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1223 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1224 remote_ost_nodsh && skip "remote OST with nodsh" && return
1227 rm -f $DIR/$tdir/$tfile
1230 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1231 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||error "truncate $DIR/$tdir/$tfile failed"
1232 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1234 exhaust_all_precreations 0x215
1236 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1237 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1241 run_test 27q "append to truncated file with all OSTs full (should error) ==="
1244 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1245 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1246 remote_ost_nodsh && skip "remote OST with nodsh" && return
1249 rm -f $DIR/$tdir/$tfile
1250 exhaust_precreations 0 0x80000215
1252 $SETSTRIPE -i 0 -c 2 $DIR/$tdir/$tfile # && error
1256 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1258 test_27s() { # bug 10725
1260 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1261 local stripe_count=0
1262 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1263 $SETSTRIPE -S $stripe_size -c $stripe_count $DIR/$tdir &&
1264 error "stripe width >= 2^32 succeeded" || true
1267 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1269 test_27t() { # bug 10864
1274 $WLFS getstripe $tfile
1277 run_test 27t "check that utils parse path correctly"
1279 test_27u() { # bug 4900
1280 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1281 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1283 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1284 do_facet $SINGLEMDS lctl set_param fail_loc=0x139
1286 createmany -o $DIR/$tdir/t- 1000
1287 do_facet $SINGLEMDS lctl set_param fail_loc=0
1289 TLOG=$DIR/$tfile.getstripe
1290 $GETSTRIPE $DIR/$tdir > $TLOG
1291 OBJS=`awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj;}' $TLOG`
1292 unlinkmany $DIR/$tdir/t- 1000
1293 [ $OBJS -gt 0 ] && \
1294 error "$OBJS objects created on OST-0. See $TLOG" || pass
1296 run_test 27u "skip object creation on OSC w/o objects =========="
1298 test_27v() { # bug 4900
1299 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1300 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1301 remote_ost_nodsh && skip "remote OST with nodsh" && return
1303 exhaust_all_precreations 0x215
1307 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1309 touch $DIR/$tdir/$tfile
1310 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1312 for (( i=1; i < OSTCOUNT; i++ )); do
1313 do_facet ost$i lctl set_param fail_loc=0x705
1315 local START=`date +%s`
1316 createmany -o $DIR/$tdir/$tfile 32
1318 local FINISH=`date +%s`
1319 local TIMEOUT=`lctl get_param -n timeout`
1320 local PROCESS=$((FINISH - START))
1321 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1322 error "$FINISH - $START >= $TIMEOUT / 2"
1323 sleep $((TIMEOUT / 2 - PROCESS))
1326 run_test 27v "skip object creation on slow OST ================="
1328 test_27w() { # bug 10997
1329 mkdir -p $DIR/$tdir || error "mkdir failed"
1330 $SETSTRIPE -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1331 [ $($GETSTRIPE -S $DIR/$tdir/f0) -ne 65536 ] &&
1332 error "stripe size $size != 65536" || true
1333 [ $($GETSTRIPE -d $DIR/$tdir | grep -c "stripe_count") -ne 1 ] &&
1334 error "$GETSTRIPE -d $DIR/$tdir failed" || true
1336 run_test 27w "check $SETSTRIPE -S option"
1339 [ "$OSTCOUNT" -lt "2" ] &&
1340 skip_env "skipping multiple stripe count/offset test" && return
1342 mkdir -p $DIR/$tdir || error "mkdir failed"
1343 for i in $(seq 1 $OSTCOUNT); do
1345 $SETSTRIPE -c $i -i $offset $DIR/$tdir/f$i ||
1346 error "setstripe -c $i -i $offset failed"
1347 count=$($GETSTRIPE -c $DIR/$tdir/f$i)
1348 index=$($GETSTRIPE -i $DIR/$tdir/f$i)
1349 [ $count -ne $i ] && error "stripe count $count != $i" || true
1350 [ $index -ne $offset ] &&
1351 error "stripe offset $index != $offset" || true
1354 run_test 27wa "check $SETSTRIPE -c -i options"
1357 remote_ost_nodsh && skip "remote OST with nodsh" && return
1358 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs" && return
1359 OFFSET=$(($OSTCOUNT - 1))
1361 local OST=$(ostname_from_index $OSTIDX)
1364 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe per file
1365 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1367 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1368 for i in `seq 0 $OFFSET`; do
1369 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}' | grep -w "$OSTIDX"` ] &&
1370 error "OST0 was degraded but new created file still use it"
1372 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1374 run_test 27x "create files while OST0 is degraded"
1377 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1378 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1379 remote_ost_nodsh && skip "remote OST with nodsh" && return
1381 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1382 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1383 osc.$mdtosc.prealloc_last_id)
1384 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1385 osc.$mdtosc.prealloc_next_id)
1386 local fcount=$((last_id - next_id))
1387 [ $fcount -eq 0 ] && skip "not enough space on OST0" && return
1388 [ $fcount -gt $OSTCOUNT ] && fcount=$OSTCOUNT
1390 MDS_OSCS=`do_facet $SINGLEMDS lctl dl | awk '/[oO][sS][cC].*md[ts]/ { print $4 }'`
1391 OFFSET=$(($OSTCOUNT-1))
1393 for OSC in $MDS_OSCS; do
1394 if [ $OST == -1 ]; then {
1395 OST=`osc_to_ost $OSC`
1397 echo $OSC "is Deactivate:"
1398 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1402 OSTIDX=$(index_from_ostuuid $OST)
1404 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1406 do_facet ost$((OSTIDX+1)) lctl set_param -n obdfilter.$OST.degraded 1
1408 createmany -o $DIR/$tdir/$tfile $fcount
1409 do_facet ost$((OSTIDX+1)) lctl set_param -n obdfilter.$OST.degraded 0
1411 for i in `seq 0 $OFFSET`; do
1412 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "$OSTIDX"` ] || \
1413 error "files created on deactivated OSTs instead of degraded OST"
1415 for OSC in $MDS_OSCS; do
1416 [ `osc_to_ost $OSC` != $OST ] && {
1417 echo $OSC "is activate"
1418 do_facet $SINGLEMDS lctl --device %$OSC activate
1422 run_test 27y "create files while OST0 is degraded and the rest inactive"
1428 lmm_count=$($GETSTRIPE -c $1)
1429 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1430 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1432 local old_ifs="$IFS"
1434 fid=($($LFS path2fid $1))
1437 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1438 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1440 # compare lmm_seq and lu_fid->f_seq
1441 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1442 # compare lmm_object_id and lu_fid->oid
1443 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1445 # check the trusted.fid attribute of the OST objects of the file
1446 local have_obdidx=false
1448 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1449 # skip lines up to and including "obdidx"
1450 [ -z "$obdidx" ] && break
1451 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1452 $have_obdidx || continue
1454 local ost=$((obdidx + 1))
1455 local dev=$(ostdevname $ost)
1457 if [ $(facet_fstype ost$ost) != ldiskfs ]; then
1458 echo "Currently only works with ldiskfs-based OSTs"
1462 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1464 #don't unmount/remount the OSTs if we don't need to do that
1465 #local dir=$(facet_mntpt ost$ost)
1467 #do_facet ost$dev mount -t $FSTYPE $dev $dir $OST_MOUNT_OPTS ||
1468 # { error "mounting $dev as $FSTYPE failed"; return 3; }
1469 #local obj_file=$(do_facet ost$ost find $dir/O/$seq -name $oid)
1470 #local ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID $obj_file)
1472 local obj_file="O/$seq/d$((oid %32))/$oid"
1473 local ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
1474 $dev 2>/dev/null" | grep "parent=")
1476 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
1478 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
1480 #do_facet ost$ost umount -d $dir
1481 #start ost$ost $dev $OST_MOUNT_OPTS
1483 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
1484 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
1485 local ff_parent=$(echo $ff|sed -e 's/.*parent=.//')
1486 local ff_pseq=$(echo $ff_parent | cut -d: -f1)
1487 local ff_poid=$(echo $ff_parent | cut -d: -f2)
1488 local ff_pstripe=$(echo $ff_parent | sed -e 's/.*stripe=//')
1490 # compare lmm_seq and filter_fid->ff_parent.f_seq
1491 [ $ff_pseq = $lmm_seq ] ||
1492 error "FF parent SEQ $ff_pseq != $lmm_seq"
1493 # compare lmm_object_id and filter_fid->ff_parent.f_oid
1494 [ $ff_poid = $lmm_oid ] ||
1495 error "FF parent OID $ff_poid != $lmm_oid"
1496 [ $ff_pstripe = $stripe_nr ] ||
1497 error "FF stripe $ff_pstripe != $stripe_nr"
1499 stripe_nr=$((stripe_nr + 1))
1504 remote_ost_nodsh && skip "remote OST with nodsh" && return
1507 $SETSTRIPE -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
1508 { error "setstripe -c -1 failed"; return 1; }
1509 # We need to send a write to every object to get parent FID info set.
1510 # This _should_ also work for setattr, but does not currently.
1511 # touch $DIR/$tdir/$tfile-1 ||
1512 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
1513 { error "dd $tfile-1 failed"; return 2; }
1514 $SETSTRIPE -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
1515 { error "setstripe -c -1 failed"; return 3; }
1516 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
1517 { error "dd $tfile-2 failed"; return 4; }
1519 # make sure write RPCs have been sent to OSTs
1522 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
1523 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
1525 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
1527 test_27A() { # b=19102
1528 local restore_size=$($GETSTRIPE -S $MOUNT)
1529 local restore_count=$($GETSTRIPE -c $MOUNT)
1530 local restore_offset=$($GETSTRIPE -i $MOUNT)
1531 $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
1532 local default_size=$($GETSTRIPE -S $MOUNT)
1533 local default_count=$($GETSTRIPE -c $MOUNT)
1534 local default_offset=$($GETSTRIPE -i $MOUNT)
1535 local dsize=$((1024 * 1024))
1536 [ $default_size -eq $dsize ] ||
1537 error "stripe size $default_size != $dsize"
1538 [ $default_count -eq 1 ] || error "stripe count $default_count != 1"
1539 [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
1540 $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
1542 run_test 27A "check filesystem-wide default LOV EA values"
1544 # createtest also checks that device nodes are created and
1545 # then visible correctly (#2091)
1546 test_28() { # bug 2091
1548 $CREATETEST $DIR/d28/ct || error
1550 run_test 28 "create/mknod/mkdir with bad file types ============"
1553 cancel_lru_locks mdc
1559 declare -i LOCKCOUNTORIG=0
1560 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1561 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
1563 [ $LOCKCOUNTORIG -eq 0 ] && echo "No mdc lock count" && return 1
1565 declare -i LOCKUNUSEDCOUNTORIG=0
1566 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1567 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
1574 declare -i LOCKCOUNTCURRENT=0
1575 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1576 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
1579 declare -i LOCKUNUSEDCOUNTCURRENT=0
1580 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1581 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
1584 if [ "$LOCKCOUNTCURRENT" -gt "$LOCKCOUNTORIG" ]; then
1585 lctl set_param -n ldlm.dump_namespaces ""
1586 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
1587 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1588 log "dumped log to $TMP/test_29.dk (bug 5793)"
1591 if [ "$LOCKUNUSEDCOUNTCURRENT" -gt "$LOCKUNUSEDCOUNTORIG" ]; then
1592 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
1593 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1594 log "dumped log to $TMP/test_29.dk (bug 5793)"
1598 run_test 29 "IT_GETATTR regression ============================"
1600 test_30a() { # was test_30
1601 cp `which ls` $DIR || cp /bin/ls $DIR
1605 run_test 30a "execute binary from Lustre (execve) =============="
1608 cp `which ls` $DIR || cp /bin/ls $DIR
1610 $RUNAS $DIR/ls / || error
1613 run_test 30b "execute binary from Lustre as non-root ==========="
1615 test_30c() { # b=22376
1616 cp `which ls` $DIR || cp /bin/ls $DIR
1618 cancel_lru_locks mdc
1619 cancel_lru_locks osc
1620 $RUNAS $DIR/ls / || error
1623 run_test 30c "execute binary from Lustre without read perms ===="
1626 $OPENUNLINK $DIR/f31 $DIR/f31 || error
1627 $CHECKSTAT -a $DIR/f31 || error
1629 run_test 31a "open-unlink file =================================="
1632 touch $DIR/f31 || error
1633 ln $DIR/f31 $DIR/f31b || error
1634 $MULTIOP $DIR/f31b Ouc || error
1635 $CHECKSTAT -t file $DIR/f31 || error
1637 run_test 31b "unlink file with multiple links while open ======="
1640 touch $DIR/f31 || error
1641 ln $DIR/f31 $DIR/f31c || error
1642 multiop_bg_pause $DIR/f31 O_uc || return 1
1644 $MULTIOP $DIR/f31c Ouc
1645 kill -USR1 $MULTIPID
1648 run_test 31c "open-unlink file with multiple links ============="
1651 opendirunlink $DIR/d31d $DIR/d31d || error
1652 $CHECKSTAT -a $DIR/d31d || error
1654 run_test 31d "remove of open directory ========================="
1656 test_31e() { # bug 2904
1657 check_kernel_version 34 || return 0
1658 openfilleddirunlink $DIR/d31e || error
1660 run_test 31e "remove of open non-empty directory ==============="
1662 test_31f() { # bug 4554
1665 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
1666 cp /etc/hosts $DIR/d31f
1668 $GETSTRIPE $DIR/d31f/hosts
1669 multiop_bg_pause $DIR/d31f D_c || return 1
1672 rm -rv $DIR/d31f || error "first of $DIR/d31f"
1674 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
1675 cp /etc/hosts $DIR/d31f
1677 $GETSTRIPE $DIR/d31f/hosts
1678 multiop_bg_pause $DIR/d31f D_c || return 1
1681 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
1682 wait $MULTIPID || error "first opendir $MULTIPID failed"
1686 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
1687 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
1690 run_test 31f "remove of open directory with open-unlink file ==="
1693 echo "-- cross directory link --"
1694 mkdir $DIR/d31g{a,b}
1696 ln $DIR/d31ga/f $DIR/d31gb/g
1697 $CHECKSTAT -t file $DIR/d31ga/f || error "source"
1698 [ `stat -c%h $DIR/d31ga/f` == '2' ] || error "source nlink"
1699 $CHECKSTAT -t file $DIR/d31gb/g || error "target"
1700 [ `stat -c%h $DIR/d31gb/g` == '2' ] || error "target nlink"
1702 run_test 31g "cross directory link==============="
1705 echo "-- cross directory link --"
1709 ln $DIR/d31h/f $DIR/d31h/dir/g
1710 $CHECKSTAT -t file $DIR/d31h/f || error "source"
1711 [ `stat -c%h $DIR/d31h/f` == '2' ] || error "source nlink"
1712 $CHECKSTAT -t file $DIR/d31h/dir/g || error "target"
1713 [ `stat -c%h $DIR/d31h/dir/g` == '2' ] || error "target nlink"
1715 run_test 31h "cross directory link under child==============="
1718 echo "-- cross directory link --"
1721 touch $DIR/d31i/dir/f
1722 ln $DIR/d31i/dir/f $DIR/d31i/g
1723 $CHECKSTAT -t file $DIR/d31i/dir/f || error "source"
1724 [ `stat -c%h $DIR/d31i/dir/f` == '2' ] || error "source nlink"
1725 $CHECKSTAT -t file $DIR/d31i/g || error "target"
1726 [ `stat -c%h $DIR/d31i/g` == '2' ] || error "target nlink"
1728 run_test 31i "cross directory link under parent==============="
1733 mkdir $DIR/d31j/dir1
1734 ln $DIR/d31j/dir1 $DIR/d31j/dir2 && error "ln for dir"
1735 link $DIR/d31j/dir1 $DIR/d31j/dir3 && error "link for dir"
1736 mlink $DIR/d31j/dir1 $DIR/d31j/dir4 && error "mlink for dir"
1737 mlink $DIR/d31j/dir1 $DIR/d31j/dir1 && error "mlink to the same dir"
1740 run_test 31j "link for directory==============="
1746 touch $DIR/d31k/exist
1747 mlink $DIR/d31k/s $DIR/d31k/t || error "mlink"
1748 mlink $DIR/d31k/s $DIR/d31k/exist && error "mlink to exist file"
1749 mlink $DIR/d31k/s $DIR/d31k/s && error "mlink to the same file"
1750 mlink $DIR/d31k/s $DIR/d31k && error "mlink to parent dir"
1751 mlink $DIR/d31k $DIR/d31k/s && error "mlink parent dir to target"
1752 mlink $DIR/d31k/not-exist $DIR/d31k/foo && error "mlink non-existing to new"
1753 mlink $DIR/d31k/not-exist $DIR/d31k/s && error "mlink non-existing to exist"
1756 run_test 31k "link to file: the same, non-existing, dir==============="
1762 touch $DIR/d31m2/exist
1763 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
1764 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
1765 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
1766 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
1767 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
1768 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
1771 run_test 31m "link to file: the same, non-existing, dir==============="
1773 cleanup_test32_mount() {
1775 $UMOUNT $DIR/$tdir/ext2-mountpoint
1779 echo "== more mountpoints and symlinks ================="
1780 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
1781 trap cleanup_test32_mount EXIT
1782 mkdir -p $DIR/$tdir/ext2-mountpoint
1783 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
1784 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. || error
1785 cleanup_test32_mount
1787 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
1790 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
1791 trap cleanup_test32_mount EXIT
1792 mkdir -p $DIR/$tdir/ext2-mountpoint
1793 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
1794 ls -al $DIR/$tdir/ext2-mountpoint/.. || error
1795 cleanup_test32_mount
1797 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
1800 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
1801 trap cleanup_test32_mount EXIT
1802 mkdir -p $DIR/$tdir/ext2-mountpoint
1803 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
1804 mkdir -p $DIR/$tdir/d2/test_dir
1805 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
1806 cleanup_test32_mount
1808 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
1811 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
1812 trap cleanup_test32_mount EXIT
1813 mkdir -p $DIR/$tdir/ext2-mountpoint
1814 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
1815 mkdir -p $DIR/$tdir/d2/test_dir
1816 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
1817 cleanup_test32_mount
1819 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
1822 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
1823 mkdir -p $DIR/d32e/tmp
1824 TMP_DIR=$DIR/d32e/tmp
1825 ln -s $DIR/d32e $TMP_DIR/symlink11
1826 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1827 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
1828 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
1830 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
1833 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
1834 mkdir -p $DIR/d32f/tmp
1835 TMP_DIR=$DIR/d32f/tmp
1836 ln -s $DIR/d32f $TMP_DIR/symlink11
1837 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1838 ls $DIR/d32f/tmp/symlink11 || error
1839 ls $DIR/d32f/symlink01 || error
1841 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
1844 TMP_DIR=$DIR/$tdir/tmp
1845 mkdir -p $TMP_DIR $DIR/${tdir}2
1846 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
1847 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1848 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
1849 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
1850 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
1851 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
1853 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
1856 rm -fr $DIR/$tdir $DIR/${tdir}2
1857 TMP_DIR=$DIR/$tdir/tmp
1858 mkdir -p $TMP_DIR $DIR/${tdir}2
1859 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
1860 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1861 ls $TMP_DIR/symlink12 || error
1862 ls $DIR/$tdir/symlink02 || error
1864 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
1867 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
1868 trap cleanup_test32_mount EXIT
1869 mkdir -p $DIR/$tdir/ext2-mountpoint
1870 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
1871 touch $DIR/$tdir/test_file
1872 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file || error
1873 cleanup_test32_mount
1875 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
1878 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
1879 trap cleanup_test32_mount EXIT
1880 mkdir -p $DIR/$tdir/ext2-mountpoint
1881 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
1882 touch $DIR/$tdir/test_file
1883 cat $DIR/$tdir/ext2-mountpoint/../test_file || error
1884 cleanup_test32_mount
1886 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
1890 trap cleanup_test32_mount EXIT
1891 mkdir -p $DIR/$tdir/ext2-mountpoint
1892 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
1893 mkdir -p $DIR/$tdir/d2
1894 touch $DIR/$tdir/d2/test_file || error
1895 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
1896 cleanup_test32_mount
1898 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
1902 trap cleanup_test32_mount EXIT
1903 mkdir -p $DIR/$tdir/ext2-mountpoint
1904 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
1905 mkdir -p $DIR/$tdir/d2
1906 touch $DIR/$tdir/d2/test_file
1907 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
1908 cleanup_test32_mount
1910 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
1914 mkdir -p $DIR/d32m/tmp
1915 TMP_DIR=$DIR/d32m/tmp
1916 ln -s $DIR $TMP_DIR/symlink11
1917 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1918 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
1919 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
1921 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
1925 mkdir -p $DIR/d32n/tmp
1926 TMP_DIR=$DIR/d32n/tmp
1927 ln -s $DIR $TMP_DIR/symlink11
1928 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1929 ls -l $DIR/d32n/tmp/symlink11 || error
1930 ls -l $DIR/d32n/symlink01 || error
1932 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
1935 rm -fr $DIR/d32o $DIR/$tfile
1937 mkdir -p $DIR/d32o/tmp
1938 TMP_DIR=$DIR/d32o/tmp
1939 ln -s $DIR/$tfile $TMP_DIR/symlink12
1940 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1941 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
1942 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
1943 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
1944 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
1946 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
1956 mkdir -p $DIR/d32p/tmp
1958 TMP_DIR=$DIR/d32p/tmp
1960 ln -s $DIR/$tfile $TMP_DIR/symlink12
1962 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1964 cat $DIR/d32p/tmp/symlink12 || error
1966 cat $DIR/d32p/symlink02 || error
1969 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
1971 cleanup_testdir_mount() {
1977 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
1978 trap cleanup_testdir_mount EXIT
1980 touch $DIR/$tdir/under_the_mount
1981 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
1982 ls $DIR/$tdir | grep "\<under_the_mount\>" && error
1983 cleanup_testdir_mount
1985 run_test 32q "stat follows mountpoints in Lustre (should return error)"
1988 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
1989 trap cleanup_testdir_mount EXIT
1991 touch $DIR/$tdir/under_the_mount
1992 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
1993 ls $DIR/$tdir | grep -q under_the_mount && error || true
1994 cleanup_testdir_mount
1996 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
2001 chmod 444 $DIR/$tfile
2002 chown $RUNAS_ID $DIR/$tfile
2004 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2007 run_test 33 "write file with mode 444 (should return error) ===="
2012 chown $RUNAS_ID $DIR/d33
2013 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
2014 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
2015 error "open RDWR" || true
2017 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
2022 chown $RUNAS_ID $DIR/d33
2023 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33 && error "create" || true
2025 run_test 33b "test open file with malformed flags (No panic and return error)"
2033 remote_ost_nodsh && skip "remote OST with nodsh" && return
2037 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2040 for ostnum in $(seq $OSTCOUNT); do
2041 # test-framework's OST numbering is one-based, while Lustre's
2043 ostname=$(printf "$FSNAME-OST%.4d" $((ostnum - 1)))
2044 # Parsing llobdstat's output sucks; we could grep the /proc
2045 # path, but that's likely to not be as portable as using the
2046 # llobdstat utility. So we parse lctl output instead.
2047 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2048 obdfilter/$ostname/stats |
2049 awk '/^write_bytes/ {print $7}' )
2050 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2051 if (( ${write_bytes:-0} > 0 ))
2058 $all_zeros || return 0
2061 echo foo > $DIR/d33/bar
2065 # Total up write_bytes after writing. We'd better find non-zeros.
2066 for ostnum in $(seq $OSTCOUNT); do
2067 ostname=$(printf "$FSNAME-OST%.4d" $((ostnum - 1)))
2068 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2069 obdfilter/$ostname/stats |
2070 awk '/^write_bytes/ {print $7}' )
2071 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2072 if (( ${write_bytes:-0} > 0 ))
2081 for ostnum in $(seq $OSTCOUNT); do
2082 ostname=$(printf "$FSNAME-OST%.4d" $((ostnum - 1)))
2083 echo "Check that write_bytes is present in obdfilter/*/stats:"
2084 do_facet ost$ostnum lctl get_param -n \
2085 obdfilter/$ostname/stats
2087 error "OST not keeping write_bytes stats (b22312)"
2090 run_test 33c "test llobdstat and write_bytes"
2092 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
2095 $MCREATE $DIR/f34 || error
2096 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2097 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
2098 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2099 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2101 run_test 34a "truncate file that has not been opened ==========="
2104 [ ! -f $DIR/f34 ] && test_34a
2105 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2106 $OPENFILE -f O_RDONLY $DIR/f34
2107 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2108 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2110 run_test 34b "O_RDONLY opening file doesn't create objects ====="
2113 [ ! -f $DIR/f34 ] && test_34a
2114 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2115 $OPENFILE -f O_RDWR $DIR/f34
2116 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2117 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2119 run_test 34c "O_RDWR opening file-with-size works =============="
2122 [ ! -f $DIR/f34 ] && test_34a
2123 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2124 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2127 run_test 34d "write to sparse file ============================="
2131 $MCREATE $DIR/f34e || error
2132 $TRUNCATE $DIR/f34e 1000 || error
2133 $CHECKSTAT -s 1000 $DIR/f34e || error
2134 $OPENFILE -f O_RDWR $DIR/f34e
2135 $CHECKSTAT -s 1000 $DIR/f34e || error
2137 run_test 34e "create objects, some with size and some without =="
2139 test_34f() { # bug 6242, 6243
2142 $MCREATE $DIR/f34f || error
2143 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
2144 dd if=$DIR/f34f of=$TMP/f34f
2145 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
2146 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
2147 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
2148 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
2149 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
2151 run_test 34f "read from a file with no objects until EOF ======="
2154 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
2155 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
2156 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
2157 cancel_lru_locks osc
2158 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
2159 error "wrong size after lock cancel"
2161 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
2162 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2163 error "expanding truncate failed"
2164 cancel_lru_locks osc
2165 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2166 error "wrong expanded size after lock cancel"
2168 run_test 34g "truncate long file ==============================="
2174 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
2175 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
2179 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
2180 error "Multiop blocked on ftruncate, pid=$MULTIPID"
2184 local nsz=`stat -c %s $DIR/$tfile`
2185 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
2187 run_test 34h "ftruncate file under grouplock should not block"
2190 cp /bin/sh $DIR/f35a
2192 chown $RUNAS_ID $DIR/f35a
2193 $RUNAS $DIR/f35a && error || true
2196 run_test 35a "exec file with mode 444 (should return and not leak) ====="
2200 utime $DIR/f36 || error
2202 run_test 36a "MDS utime check (mknod, utime) ==================="
2206 utime $DIR/f36 || error
2208 run_test 36b "OST utime check (open, utime) ===================="
2213 chown $RUNAS_ID $DIR/d36
2214 $RUNAS utime $DIR/d36/f36 || error
2216 run_test 36c "non-root MDS utime check (mknod, utime) =========="
2219 [ ! -d $DIR/d36 ] && test_36c
2220 echo "" > $DIR/d36/f36
2221 $RUNAS utime $DIR/d36/f36 || error
2223 run_test 36d "non-root OST utime check (open, utime) ==========="
2226 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
2228 touch $DIR/$tdir/$tfile
2229 $RUNAS utime $DIR/$tdir/$tfile && \
2230 error "utime worked, expected failure" || true
2232 run_test 36e "utime on non-owned file (should return error) ===="
2236 local LANG_SAVE=$LANG
2237 local LC_LANG_SAVE=$LC_LANG
2238 export LANG=C LC_LANG=C # for date language
2240 DATESTR="Dec 20 2000"
2242 lctl set_param fail_loc=$fl
2244 cp /etc/hosts $DIR/$tdir/$tfile
2245 sync & # write RPC generated with "current" inode timestamp, but delayed
2247 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
2248 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
2249 cancel_lru_locks osc
2250 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
2252 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
2253 echo "BEFORE: $LS_BEFORE" && \
2254 echo "AFTER : $LS_AFTER" && \
2255 echo "WANT : $DATESTR" && \
2256 error "$DIR/$tdir/$tfile timestamps changed" || true
2258 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
2262 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2263 subr_36fh "0x80000214"
2265 run_test 36f "utime on file racing with OST BRW write =========="
2268 remote_ost_nodsh && skip "remote OST with nodsh" && return
2274 fmd_max_age=$(do_facet ost1 \
2275 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
2278 fmd_before=$(do_facet ost1 \
2279 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2280 touch $DIR/$tdir/$tfile
2281 sleep $((fmd_max_age + 12))
2282 fmd_after=$(do_facet ost1 \
2283 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2285 echo "fmd_before: $fmd_before"
2286 echo "fmd_after: $fmd_after"
2287 [ "$fmd_after" -gt "$fmd_before" ] && \
2288 echo "AFTER: $fmd_after > BEFORE: $fmd_before" && \
2289 error "fmd didn't expire after ping" || true
2291 run_test 36g "filter mod data cache expiry ====================="
2294 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
2295 subr_36fh "0x80000227"
2297 run_test 36h "utime on file racing with OST BRW write =========="
2299 # test_37 - duplicate with tests 32q 32r
2302 local file=$DIR/$tfile
2304 openfile -f O_DIRECTORY $file
2307 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
2308 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
2310 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
2314 touch $DIR/${tfile}2
2315 # ls -l $DIR/$tfile $DIR/${tfile}2
2316 # ls -lu $DIR/$tfile $DIR/${tfile}2
2317 # ls -lc $DIR/$tfile $DIR/${tfile}2
2319 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
2320 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
2322 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
2324 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
2326 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
2327 error "O_TRUNC didn't change timestamps"
2330 run_test 39 "mtime changed on create ==========================="
2334 cp -p /etc/passwd $DIR/$tdir/fopen
2335 cp -p /etc/passwd $DIR/$tdir/flink
2336 cp -p /etc/passwd $DIR/$tdir/funlink
2337 cp -p /etc/passwd $DIR/$tdir/frename
2338 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
2341 echo "aaaaaa" >> $DIR/$tdir/fopen
2342 echo "aaaaaa" >> $DIR/$tdir/flink
2343 echo "aaaaaa" >> $DIR/$tdir/funlink
2344 echo "aaaaaa" >> $DIR/$tdir/frename
2346 local open_new=`stat -c %Y $DIR/$tdir/fopen`
2347 local link_new=`stat -c %Y $DIR/$tdir/flink`
2348 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
2349 local rename_new=`stat -c %Y $DIR/$tdir/frename`
2351 cat $DIR/$tdir/fopen > /dev/null
2352 ln $DIR/$tdir/flink $DIR/$tdir/flink2
2353 rm -f $DIR/$tdir/funlink2
2354 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
2356 for (( i=0; i < 2; i++ )) ; do
2357 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
2358 local link_new2=`stat -c %Y $DIR/$tdir/flink`
2359 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
2360 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
2362 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
2363 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
2364 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
2365 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
2367 cancel_lru_locks osc
2368 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2371 run_test 39b "mtime change on open, link, unlink, rename ======"
2373 # this should be set to past
2374 TEST_39_MTIME=`date -d "1 year ago" +%s`
2380 local mtime0=`stat -c %Y $DIR1/$tfile`
2382 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2383 local mtime1=`stat -c %Y $DIR1/$tfile`
2384 [ "$mtime1" = $TEST_39_MTIME ] || \
2385 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
2388 echo hello >> $DIR1/$tfile
2390 local mtime2=`stat -c %Y $DIR1/$tfile`
2391 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
2392 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
2394 mv $DIR1/$tfile $DIR1/$tfile-1
2396 for (( i=0; i < 2; i++ )) ; do
2397 local mtime3=`stat -c %Y $DIR1/$tfile-1`
2398 [ "$mtime2" = "$mtime3" ] || \
2399 error "mtime ($mtime2) changed (to $mtime3) on rename"
2401 cancel_lru_locks osc
2402 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2405 run_test 39c "mtime change on rename ==========================="
2411 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2413 for (( i=0; i < 2; i++ )) ; do
2414 local mtime=`stat -c %Y $DIR1/$tfile`
2415 [ $mtime = $TEST_39_MTIME ] || \
2416 error "mtime($mtime) is not set to $TEST_39_MTIME"
2418 cancel_lru_locks osc
2419 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2422 run_test 39d "create, utime, stat =============================="
2427 local mtime1=`stat -c %Y $DIR1/$tfile`
2429 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2431 for (( i=0; i < 2; i++ )) ; do
2432 local mtime2=`stat -c %Y $DIR1/$tfile`
2433 [ $mtime2 = $TEST_39_MTIME ] || \
2434 error "mtime($mtime2) is not set to $TEST_39_MTIME"
2436 cancel_lru_locks osc
2437 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2440 run_test 39e "create, stat, utime, stat ========================"
2445 mtime1=`stat -c %Y $DIR1/$tfile`
2448 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2450 for (( i=0; i < 2; i++ )) ; do
2451 local mtime2=`stat -c %Y $DIR1/$tfile`
2452 [ $mtime2 = $TEST_39_MTIME ] || \
2453 error "mtime($mtime2) is not set to $TEST_39_MTIME"
2455 cancel_lru_locks osc
2456 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2459 run_test 39f "create, stat, sleep, utime, stat ================="
2463 echo hello >> $DIR1/$tfile
2464 local mtime1=`stat -c %Y $DIR1/$tfile`
2467 chmod o+r $DIR1/$tfile
2469 for (( i=0; i < 2; i++ )) ; do
2470 local mtime2=`stat -c %Y $DIR1/$tfile`
2471 [ "$mtime1" = "$mtime2" ] || \
2472 error "lost mtime: $mtime2, should be $mtime1"
2474 cancel_lru_locks osc
2475 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2478 run_test 39g "write, chmod, stat ==============================="
2486 echo hello >> $DIR1/$tfile
2487 local mtime1=`stat -c %Y $DIR1/$tfile`
2489 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2491 if [ "$d1" != "$d2" ]; then
2492 echo "write and touch not within one second"
2494 for (( i=0; i < 2; i++ )) ; do
2495 local mtime2=`stat -c %Y $DIR1/$tfile`
2496 [ "$mtime2" = $TEST_39_MTIME ] || \
2497 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
2499 cancel_lru_locks osc
2500 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2504 run_test 39h "write, utime within one second, stat ============="
2510 echo hello >> $DIR1/$tfile
2511 local mtime1=`stat -c %Y $DIR1/$tfile`
2513 mv $DIR1/$tfile $DIR1/$tfile-1
2515 for (( i=0; i < 2; i++ )) ; do
2516 local mtime2=`stat -c %Y $DIR1/$tfile-1`
2518 [ "$mtime1" = "$mtime2" ] || \
2519 error "lost mtime: $mtime2, should be $mtime1"
2521 cancel_lru_locks osc
2522 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2525 run_test 39i "write, rename, stat =============================="
2528 start_full_debug_logging
2532 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
2533 lctl set_param fail_loc=0x80000412
2534 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
2535 error "multiop failed"
2537 local mtime1=`stat -c %Y $DIR1/$tfile`
2539 mv $DIR1/$tfile $DIR1/$tfile-1
2541 kill -USR1 $multipid
2542 wait $multipid || error "multiop close failed"
2544 for (( i=0; i < 2; i++ )) ; do
2545 local mtime2=`stat -c %Y $DIR1/$tfile-1`
2546 [ "$mtime1" = "$mtime2" ] ||
2547 error "mtime is lost on close: $mtime2, " \
2550 cancel_lru_locks osc
2551 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2553 lctl set_param fail_loc=0
2554 stop_full_debug_logging
2556 run_test 39j "write, rename, close, stat ======================="
2562 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
2564 local mtime1=`stat -c %Y $DIR1/$tfile`
2566 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2568 kill -USR1 $multipid
2569 wait $multipid || error "multiop close failed"
2571 for (( i=0; i < 2; i++ )) ; do
2572 local mtime2=`stat -c %Y $DIR1/$tfile`
2574 [ "$mtime2" = $TEST_39_MTIME ] || \
2575 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
2577 cancel_lru_locks osc
2578 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2581 run_test 39k "write, utime, close, stat ========================"
2583 # this should be set to future
2584 TEST_39_ATIME=`date -d "1 year" +%s`
2586 is_sles11() # LU-1783
2588 if [ -r /etc/SuSE-release ]
2590 local vers=`grep VERSION /etc/SuSE-release | awk '{print $3}'`
2591 local patchlev=`grep PATCHLEVEL /etc/SuSE-release \
2593 if [ $vers -eq 11 ] && [ $patchlev -eq 1 ]
2602 is_sles11 && skip "SLES 11 SP1" && return # LU-1783
2603 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2604 local atime_diff=$(do_facet $SINGLEMDS lctl get_param -n mdd.*.atime_diff)
2608 # test setting directory atime to future
2609 touch -a -d @$TEST_39_ATIME $DIR/$tdir
2610 local atime=$(stat -c %X $DIR/$tdir)
2611 [ "$atime" = $TEST_39_ATIME ] || \
2612 error "atime is not set to future: $atime, should be $TEST_39_ATIME"
2614 # test setting directory atime from future to now
2615 local d1=$(date +%s)
2617 local d2=$(date +%s)
2619 cancel_lru_locks mdc
2620 atime=$(stat -c %X $DIR/$tdir)
2621 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
2622 error "atime is not updated from future: $atime, should be $d1<atime<$d2"
2624 do_facet $SINGLEMDS lctl set_param -n mdd.*.atime_diff=2
2627 # test setting directory atime when now > dir atime + atime_diff
2631 cancel_lru_locks mdc
2632 atime=$(stat -c %X $DIR/$tdir)
2633 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
2634 error "atime is not updated : $atime, should be $d2"
2636 do_facet $SINGLEMDS lctl set_param -n mdd.*.atime_diff=60
2639 # test not setting directory atime when now < dir atime + atime_diff
2641 cancel_lru_locks mdc
2642 atime=$(stat -c %X $DIR/$tdir)
2643 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
2644 error "atime is updated to $atime, should remain $d1<atime<$d2"
2646 do_facet $SINGLEMDS lctl set_param -n mdd.*.atime_diff=$atime_diff
2648 run_test 39l "directory atime update ==========================="
2653 local far_past_mtime=$(date -d "May 29 1953" +%s)
2654 local far_past_atime=$(date -d "Dec 17 1903" +%s)
2656 touch -m -d @$far_past_mtime $DIR1/$tfile
2657 touch -a -d @$far_past_atime $DIR1/$tfile
2659 for (( i=0; i < 2; i++ )) ; do
2660 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
2661 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
2662 error "atime or mtime set incorrectly"
2664 cancel_lru_locks osc
2665 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2668 run_test 39m "test atime and mtime before 1970"
2671 dd if=/dev/zero of=$DIR/f40 bs=4096 count=1
2672 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/f40 && error
2673 $CHECKSTAT -t file -s 4096 $DIR/f40 || error
2675 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
2679 small_write $DIR/f41 18
2681 run_test 41 "test small file write + fstat ====================="
2683 count_ost_writes() {
2684 lctl get_param -n osc.*.stats |
2685 awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }'
2692 BG_DIRTY_RATIO_SAVE=10
2693 MAX_BG_DIRTY_RATIO=25
2697 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
2698 # dirty_ratio, dirty_background_ratio
2699 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
2700 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
2701 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
2702 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
2704 # if file not here, we are a 2.4 kernel
2705 kill -CONT `pidof kupdated`
2710 # setup the trap first, so someone cannot exit the test at the
2711 # exact wrong time and mess up a machine
2712 trap start_writeback EXIT
2713 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
2714 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
2715 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
2716 sysctl -w vm.dirty_writeback_centisecs=0
2717 sysctl -w vm.dirty_writeback_centisecs=0
2718 # save and increase /proc/sys/vm/dirty_ratio
2719 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
2720 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
2721 # save and increase /proc/sys/vm/dirty_background_ratio
2722 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
2723 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
2725 # if file not here, we are a 2.4 kernel
2726 kill -STOP `pidof kupdated`
2730 # ensure that all stripes have some grant before we test client-side cache
2732 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
2733 dd if=/dev/zero of=$i bs=4k count=1
2738 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
2739 # file truncation, and file removal.
2742 cancel_lru_locks osc
2744 sync; sleep 1; sync # just to be safe
2745 BEFOREWRITES=`count_ost_writes`
2746 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
2747 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
2748 AFTERWRITES=`count_ost_writes`
2749 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
2750 error "$BEFOREWRITES < $AFTERWRITES"
2753 run_test 42a "ensure that we don't flush on close =============="
2757 cancel_lru_locks osc
2760 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
2761 BEFOREWRITES=`count_ost_writes`
2762 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
2763 AFTERWRITES=`count_ost_writes`
2764 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
2765 error "$BEFOREWRITES < $AFTERWRITES on unlink"
2767 BEFOREWRITES=`count_ost_writes`
2768 sync || error "sync: $?"
2769 AFTERWRITES=`count_ost_writes`
2770 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
2771 error "$BEFOREWRITES < $AFTERWRITES on sync"
2773 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
2777 run_test 42b "test destroy of file with cached dirty data ======"
2779 # if these tests just want to test the effect of truncation,
2780 # they have to be very careful. consider:
2781 # - the first open gets a {0,EOF}PR lock
2782 # - the first write conflicts and gets a {0, count-1}PW
2783 # - the rest of the writes are under {count,EOF}PW
2784 # - the open for truncate tries to match a {0,EOF}PR
2785 # for the filesize and cancels the PWs.
2786 # any number of fixes (don't get {0,EOF} on open, match
2787 # composite locks, do smarter file size management) fix
2788 # this, but for now we want these tests to verify that
2789 # the cancellation with truncate intent works, so we
2790 # start the file with a full-file pw lock to match against
2791 # until the truncate.
2796 cancel_lru_locks osc
2798 # prime the file with 0,EOF PW to match
2802 # now the real test..
2803 dd if=/dev/zero of=$file bs=1024 count=100
2804 BEFOREWRITES=`count_ost_writes`
2805 $TRUNCATE $file $offset
2806 cancel_lru_locks osc
2807 AFTERWRITES=`count_ost_writes`
2813 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
2814 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
2817 run_test 42c "test partial truncate of file with cached dirty data"
2821 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
2822 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
2825 run_test 42d "test complete truncate of file with cached dirty data"
2827 test_42e() { # bug22074
2828 local TDIR=$DIR/${tdir}e
2829 local pagesz=$(page_size)
2830 local pages=16 # hardcoded 16 pages, don't change it.
2831 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
2832 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
2837 $SETSTRIPE -c 1 $TDIR
2838 createmany -o $TDIR/f $files
2840 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
2842 # we assume that with $OSTCOUNT files, at least one of them will
2843 # be allocated on OST0.
2844 warmup_files=$((OSTCOUNT * max_dirty_mb))
2845 createmany -o $TDIR/w $warmup_files
2847 # write a large amount of data into one file and sync, to get good
2848 # avail_grant number from OST.
2849 for ((i=0; i<$warmup_files; i++)); do
2850 idx=$($GETSTRIPE -i $TDIR/w$i)
2851 [ $idx -ne 0 ] && continue
2852 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
2855 [ $i -gt $warmup_files ] && error "OST0 is still cold"
2857 $LCTL get_param $proc_osc0/cur_dirty_bytes
2858 $LCTL get_param $proc_osc0/cur_grant_bytes
2860 # create as much dirty pages as we can while not to trigger the actual
2861 # RPCs directly. but depends on the env, VFS may trigger flush during this
2862 # period, hopefully we are good.
2863 for ((i=0; i<$warmup_files; i++)); do
2864 idx=$($GETSTRIPE -i $TDIR/w$i)
2865 [ $idx -ne 0 ] && continue
2866 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
2868 $LCTL get_param $proc_osc0/cur_dirty_bytes
2869 $LCTL get_param $proc_osc0/cur_grant_bytes
2871 # perform the real test
2872 $LCTL set_param $proc_osc0/rpc_stats 0
2873 for ((;i<$files; i++)); do
2874 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
2875 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
2878 $LCTL get_param $proc_osc0/rpc_stats
2881 local have_ppr=false
2882 $LCTL get_param $proc_osc0/rpc_stats |
2883 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
2884 # skip lines until we are at the RPC histogram data
2885 [ "$PPR" == "pages" ] && have_ppr=true && continue
2886 $have_ppr || continue
2888 # we only want the percent stat for < 16 pages
2889 [ $(echo $PPR | tr -d ':') -ge $pages ] && break
2891 percent=$((percent + WPCT))
2892 if [ $percent -gt 15 ]; then
2893 error "less than 16-pages write RPCs" \
2900 run_test 42e "verify sub-RPC writes are not done synchronously"
2904 cp -p /bin/ls $DIR/$tdir/$tfile
2905 $MULTIOP $DIR/$tdir/$tfile Ow_c &
2907 # give multiop a chance to open
2910 $DIR/$tdir/$tfile && error || true
2913 run_test 43 "execution of file opened for write should return -ETXTBSY"
2917 cp -p `which $MULTIOP` $DIR/d43/multiop || cp -p multiop $DIR/d43/multiop
2918 MULTIOP_PROG=$DIR/d43/multiop multiop_bg_pause $TMP/test43.junk O_c || return 1
2920 $MULTIOP $DIR/d43/multiop Oc && error "expected error, got success"
2921 kill -USR1 $MULTIOP_PID || return 2
2922 wait $MULTIOP_PID || return 3
2925 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
2929 cp -p `which $MULTIOP` $DIR/d43/multiop || cp -p multiop $DIR/d43/multiop
2930 MULTIOP_PROG=$DIR/d43/multiop multiop_bg_pause $TMP/test43.junk O_c || return 1
2932 $TRUNCATE $DIR/d43/multiop 0 && error "expected error, got success"
2933 kill -USR1 $MULTIOP_PID || return 2
2934 wait $MULTIOP_PID || return 3
2937 run_test 43b "truncate of file being executed should return -ETXTBSY"
2940 local testdir="$DIR/d43c"
2943 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
2944 ( cd $testdir && md5sum -c)
2946 run_test 43c "md5sum of copy into lustre========================"
2949 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
2950 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
2951 dd if=$DIR/f1 bs=4k count=1 > /dev/null
2953 run_test 44 "zero length read from a sparse stripe ============="
2956 local nstripe=`$LCTL lov_getconfig $DIR | grep default_stripe_count: | \
2958 [ -z "$nstripe" ] && skip "can't get stripe info" && return
2959 [ "$nstripe" -gt "$OSTCOUNT" ] && skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" && return
2960 local stride=`$LCTL lov_getconfig $DIR | grep default_stripe_size: | \
2962 if [ $nstripe -eq 0 -o $nstripe -eq -1 ] ; then
2963 nstripe=`$LCTL lov_getconfig $DIR | grep obd_count: | awk '{print $2}'`
2966 OFFSETS="0 $((stride/2)) $((stride-1))"
2967 for offset in $OFFSETS ; do
2968 for i in `seq 0 $((nstripe-1))`; do
2969 local GLOBALOFFSETS=""
2970 local size=$((((i + 2 * $nstripe )*$stride + $offset))) # Bytes
2971 local myfn=$DIR/d44a-$size
2972 echo "--------writing $myfn at $size"
2973 ll_sparseness_write $myfn $size || error "ll_sparseness_write"
2974 GLOBALOFFSETS="$GLOBALOFFSETS $size"
2975 ll_sparseness_verify $myfn $GLOBALOFFSETS \
2976 || error "ll_sparseness_verify $GLOBALOFFSETS"
2978 for j in `seq 0 $((nstripe-1))`; do
2979 size=$((((j + $nstripe )*$stride + $offset))) # Bytes
2980 ll_sparseness_write $myfn $size || error "ll_sparseness_write"
2981 GLOBALOFFSETS="$GLOBALOFFSETS $size"
2983 ll_sparseness_verify $myfn $GLOBALOFFSETS \
2984 || error "ll_sparseness_verify $GLOBALOFFSETS"
2989 run_test 44a "test sparse pwrite ==============================="
2993 for d in `lctl get_param -n osc.*.cur_dirty_bytes`; do
2999 before=`dirty_osc_total`
3000 echo executing "\"$*\""
3002 after=`dirty_osc_total`
3003 echo before $before, after $after
3007 # Obtain grants from OST if it supports it
3008 echo blah > ${f}_grant
3011 do_dirty_record "echo blah > $f"
3012 [ $before -eq $after ] && error "write wasn't cached"
3013 do_dirty_record "> $f"
3014 [ $before -gt $after ] || error "truncate didn't lower dirty count"
3015 do_dirty_record "echo blah > $f"
3016 [ $before -eq $after ] && error "write wasn't cached"
3017 do_dirty_record "sync"
3018 [ $before -gt $after ] || error "writeback didn't lower dirty count"
3019 do_dirty_record "echo blah > $f"
3020 [ $before -eq $after ] && error "write wasn't cached"
3021 do_dirty_record "cancel_lru_locks osc"
3022 [ $before -gt $after ] || error "lock cancellation didn't lower dirty count"
3025 run_test 45 "osc io page accounting ============================"
3027 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
3028 # test tickles a bug where re-dirtying a page was failing to be mapped to the
3029 # objects offset and an assert hit when an rpc was built with 1023's mapped
3030 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
3035 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3037 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
3038 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3042 run_test 46 "dirtying a previously written page ================"
3044 # test_47 is removed "Device nodes check" is moved to test_28
3046 test_48a() { # bug 2399
3047 check_kernel_version 34 || return 0
3050 mv $DIR/d48a $DIR/d48.new || error "move directory failed"
3051 mkdir $DIR/d48a || error "recreate directory failed"
3052 touch foo || error "'touch foo' failed after recreating cwd"
3053 mkdir bar || error "'mkdir foo' failed after recreating cwd"
3054 if check_kernel_version 44; then
3055 touch .foo || error "'touch .foo' failed after recreating cwd"
3056 mkdir .bar || error "'mkdir .foo' failed after recreating cwd"
3058 ls . > /dev/null || error "'ls .' failed after recreating cwd"
3059 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3060 cd . || error "'cd .' failed after recreating cwd"
3061 mkdir . && error "'mkdir .' worked after recreating cwd"
3062 rmdir . && error "'rmdir .' worked after recreating cwd"
3063 ln -s . baz || error "'ln -s .' failed after recreating cwd"
3064 cd .. || error "'cd ..' failed after recreating cwd"
3066 run_test 48a "Access renamed working dir (should return errors)="
3068 test_48b() { # bug 2399
3069 check_kernel_version 34 || return 0
3072 rmdir $DIR/d48b || error "remove cwd $DIR/d48b failed"
3073 touch foo && error "'touch foo' worked after removing cwd"
3074 mkdir foo && error "'mkdir foo' worked after removing cwd"
3075 if check_kernel_version 44; then
3076 touch .foo && error "'touch .foo' worked after removing cwd"
3077 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
3079 ls . > /dev/null && error "'ls .' worked after removing cwd"
3080 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3081 is_patchless || ( cd . && error "'cd .' worked after removing cwd" )
3082 mkdir . && error "'mkdir .' worked after removing cwd"
3083 rmdir . && error "'rmdir .' worked after removing cwd"
3084 ln -s . foo && error "'ln -s .' worked after removing cwd"
3085 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
3087 run_test 48b "Access removed working dir (should return errors)="
3089 test_48c() { # bug 2350
3090 check_kernel_version 36 || return 0
3091 #lctl set_param debug=-1
3093 mkdir -p $DIR/d48c/dir
3095 $TRACE rmdir $DIR/d48c/dir || error "remove cwd $DIR/d48c/dir failed"
3096 $TRACE touch foo && error "'touch foo' worked after removing cwd"
3097 $TRACE mkdir foo && error "'mkdir foo' worked after removing cwd"
3098 if check_kernel_version 44; then
3099 touch .foo && error "'touch .foo' worked after removing cwd"
3100 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
3102 $TRACE ls . && error "'ls .' worked after removing cwd"
3103 $TRACE ls .. || error "'ls ..' failed after removing cwd"
3104 is_patchless || ( $TRACE cd . && error "'cd .' worked after removing cwd" )
3105 $TRACE mkdir . && error "'mkdir .' worked after removing cwd"
3106 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
3107 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
3108 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
3110 run_test 48c "Access removed working subdir (should return errors)"
3112 test_48d() { # bug 2350
3113 check_kernel_version 36 || return 0
3114 #lctl set_param debug=-1
3116 mkdir -p $DIR/d48d/dir
3118 $TRACE rmdir $DIR/d48d/dir || error "remove cwd $DIR/d48d/dir failed"
3119 $TRACE rmdir $DIR/d48d || error "remove parent $DIR/d48d failed"
3120 $TRACE touch foo && error "'touch foo' worked after removing parent"
3121 $TRACE mkdir foo && error "'mkdir foo' worked after removing parent"
3122 if check_kernel_version 44; then
3123 touch .foo && error "'touch .foo' worked after removing parent"
3124 mkdir .foo && error "'mkdir .foo' worked after removing parent"
3126 $TRACE ls . && error "'ls .' worked after removing parent"
3127 $TRACE ls .. && error "'ls ..' worked after removing parent"
3128 is_patchless || ( $TRACE cd . && error "'cd .' worked after recreate parent" )
3129 $TRACE mkdir . && error "'mkdir .' worked after removing parent"
3130 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
3131 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
3132 is_patchless || ( $TRACE cd .. && error "'cd ..' worked after removing parent" || true )
3134 run_test 48d "Access removed parent subdir (should return errors)"
3136 test_48e() { # bug 4134
3137 check_kernel_version 41 || return 0
3138 #lctl set_param debug=-1
3140 mkdir -p $DIR/d48e/dir
3142 $TRACE rmdir $DIR/d48e/dir || error "remove cwd $DIR/d48e/dir failed"
3143 $TRACE rmdir $DIR/d48e || error "remove parent $DIR/d48e failed"
3144 $TRACE touch $DIR/d48e || error "'touch $DIR/d48e' failed"
3145 $TRACE chmod +x $DIR/d48e || error "'chmod +x $DIR/d48e' failed"
3146 # On a buggy kernel addition of "touch foo" after cd .. will
3147 # produce kernel oops in lookup_hash_it
3148 touch ../foo && error "'cd ..' worked after recreate parent"
3150 $TRACE rm $DIR/d48e || error "rm '$DIR/d48e' failed"
3152 run_test 48e "Access to recreated parent subdir (should return errors)"
3154 test_49() { # LU-1030
3155 # get ost1 size - lustre-OST0000
3156 ost1_size=$(do_facet ost1 lfs df |grep ${ost1_svc} |awk '{print $4}')
3157 # write 800M at maximum
3158 [ $ost1_size -gt 819200 ] && ost1_size=819200
3160 lfs setstripe -c 1 -i 0 $DIR/$tfile
3161 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
3164 # change max_pages_per_rpc while writing the file
3165 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
3166 local orig_mppc=`$LCTL get_param -n $osc1_mppc`
3167 # loop until dd process exits
3168 while ps ax -opid | grep -wq $dd_pid; do
3169 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
3170 sleep $((RANDOM % 5 + 1))
3172 # restore original max_pages_per_rpc
3173 $LCTL set_param $osc1_mppc=$orig_mppc
3174 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
3176 run_test 49 "Change max_pages_per_rpc won't break osc extent"
3182 ls /proc/$$/cwd || error
3184 run_test 50 "special situations: /proc symlinks ==============="
3186 test_51a() { # was test_51
3187 # bug 1516 - create an empty entry right after ".." then split dir
3190 $MCREATE $DIR/d51/bar
3192 createmany -m $DIR/d51/longfile 201
3194 while [ `ls -sd $DIR/d51 | awk '{ print $1 }'` -eq 4 ]; do
3195 $MCREATE $DIR/d51/longfile$FNUM
3200 ls -l $DIR/d51 > /dev/null || error
3202 run_test 51a "special situations: split htree with empty entry =="
3204 export NUMTEST=70000
3206 local BASE=$DIR/$tdir
3209 local mdtidx=$(printf "%04x" $($LFS getstripe -M $BASE))
3210 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
3211 [ $numfree -lt 21000 ] && skip "not enough free inodes ($numfree)" &&
3214 [ $numfree -lt $NUMTEST ] && NUMTEST=$(($numfree - 50)) &&
3215 echo "reduced count to $NUMTEST due to inodes"
3217 # need to check free space for the directories as well
3218 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
3219 numfree=$((blkfree / 4))
3220 [ $numfree -lt $NUMTEST ] && NUMTEST=$(($numfree - 50)) &&
3221 echo "reduced count to $NUMTEST due to blocks"
3223 createmany -d $BASE/d $NUMTEST && echo $NUMTEST > $BASE/fnum ||
3224 echo "failed" > $BASE/fnum
3226 run_test 51b "exceed 64k subdirectory nlink limit"
3228 test_51ba() { # LU-993
3229 local BASE=$DIR/$tdir
3230 # unlink all but 100 subdirectories, then check it still works
3232 [ -f $BASE/fnum ] && local NUMPREV=$(cat $BASE/fnum) && rm $BASE/fnum
3234 [ "$NUMPREV" != "failed" ] && NUMTEST=$NUMPREV
3235 local DELETE=$((NUMTEST - LEFT))
3237 # continue on to run this test even if 51b didn't finish,
3238 # just to delete the many subdirectories created.
3239 [ ! -d "${BASE}/d1" ] && skip "test_51b() not run" && return 0
3241 # for ldiskfs the nlink count should be 1, but this is OSD specific
3242 # and so this is listed for informational purposes only
3243 echo "nlink before: $(stat -c %h $BASE), created before: $NUMTEST"
3244 unlinkmany -d $BASE/d $DELETE
3247 if [ $RC -ne 0 ]; then
3248 if [ "$NUMPREV" == "failed" ]; then
3249 skip "previous setup failed"
3252 error "unlink of first $DELETE subdirs failed"
3257 echo "nlink between: $(stat -c %h $BASE)"
3258 # trim the first line of ls output
3259 local FOUND=$(($(ls -l ${BASE} | wc -l) - 1))
3260 [ $FOUND -ne $LEFT ] &&
3261 error "can't find subdirs: found only $FOUND/$LEFT"
3263 unlinkmany -d $BASE/d $DELETE $LEFT ||
3264 error "unlink of second $LEFT subdirs failed"
3265 # regardless of whether the backing filesystem tracks nlink accurately
3266 # or not, the nlink count shouldn't be more than "." and ".." here
3267 local AFTER=$(stat -c %h $BASE)
3268 [ $AFTER -gt 2 ] && error "nlink after: $AFTER > 2" ||
3269 echo "nlink after: $AFTER"
3271 run_test 51ba "verify nlink for many subdirectory cleanup"
3274 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3276 local ndirs=${TEST51BB_NDIRS:-10}
3277 local nfiles=${TEST51BB_NFILES:-100}
3279 local numfree=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
3281 [ $numfree -lt $(( ndirs * nfiles)) ] && \
3282 nfiles=$(( numfree / ndirs - 10 ))
3284 local dir=$DIR/d51bb
3286 local savePOLICY=$(lctl get_param -n lmv.*.placement)
3287 lctl set_param -n lmv.*.placement=CHAR
3290 local IUSED=$(lfs df -i $dir | grep MDT | awk '{print $3}')
3294 for ((i=0; i < $ndirs; i++)); do
3295 dirs[i]=$dir/$RANDOM
3296 echo Creating directory ${dirs[i]}
3299 echo Creating $nfiles in dir ${dirs[i]} ...
3300 echo "createmany -o ${dirs[i]}/$tfile- $nfiles"
3301 createmany -o ${dirs[i]}/$tfile- $nfiles
3307 IUSED=$(lfs df -i $dir | grep MDT | awk '{print $3}')
3311 for ((i=0; i<${#NEWUSED[@]}; i++)); do
3312 echo "mds $i: inodes count OLD ${OLDUSED[$i]} NEW ${NEWUSED[$i]}"
3313 [ ${OLDUSED[$i]} -lt ${NEWUSED[$i]} ] || rc=$((rc + 1))
3316 lctl set_param -n lmv.*.placement=$savePOLICY
3318 [ $rc -ne $MDSCOUNT ] || \
3319 error "Objects/inodes are not distributed over all mds servers"
3321 run_test 51bb "mkdir createmany CMD $MDSCOUNT ===================="
3324 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping test with few OSTs" && return
3326 createmany -o $DIR/d51d/t- 1000
3327 $GETSTRIPE $DIR/d51d > $TMP/files
3328 for N in `seq 0 $((OSTCOUNT - 1))`; do
3329 OBJS[$N]=`awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}' $TMP/files`
3330 OBJS0[$N]=`grep -A 1 idx $TMP/files | awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}'`
3331 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
3333 unlinkmany $DIR/d51d/t- 1000
3336 for N in `seq 1 $((OSTCOUNT - 1))`; do
3337 [ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ] && \
3338 error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
3339 [ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ] && \
3340 error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
3342 [ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ] && \
3343 error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
3344 [ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ] && \
3345 error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
3349 run_test 51d "check object distribution ===================="
3352 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
3355 chattr +a $DIR/d52a/foo || error "chattr +a failed"
3356 echo bar >> $DIR/d52a/foo || error "append bar failed"
3357 cp /etc/hosts $DIR/d52a/foo && error "cp worked"
3358 rm -f $DIR/d52a/foo 2>/dev/null && error "rm worked"
3359 link $DIR/d52a/foo $DIR/d52a/foo_link 2>/dev/null && error "link worked"
3360 echo foo >> $DIR/d52a/foo || error "append foo failed"
3361 mrename $DIR/d52a/foo $DIR/d52a/foo_ren && error "rename worked"
3362 lsattr $DIR/d52a/foo | egrep -q "^-+a[-e]+ $DIR/d52a/foo" || error "lsattr"
3363 chattr -a $DIR/d52a/foo || error "chattr -a failed"
3364 cp -r $DIR/d52a /tmp/
3365 rm -fr $DIR/d52a || error "cleanup rm failed"
3367 run_test 52a "append-only flag test (should return errors) ====="
3370 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
3373 chattr +i $DIR/d52b/foo || error "chattr +i failed"
3374 cat test > $DIR/d52b/foo && error "cat test worked"
3375 cp /etc/hosts $DIR/d52b/foo && error "cp worked"
3376 rm -f $DIR/d52b/foo 2>/dev/null && error "rm worked"
3377 link $DIR/d52b/foo $DIR/d52b/foo_link 2>/dev/null && error "link worked"
3378 echo foo >> $DIR/d52b/foo && error "echo worked"
3379 mrename $DIR/d52b/foo $DIR/d52b/foo_ren && error "rename worked"
3380 [ -f $DIR/d52b/foo ] || error
3381 [ -f $DIR/d52b/foo_ren ] && error
3382 lsattr $DIR/d52b/foo | egrep -q "^-+i[-e]+ $DIR/d52b/foo" || error "lsattr"
3383 chattr -i $DIR/d52b/foo || error "chattr failed"
3385 rm -fr $DIR/d52b || error
3387 run_test 52b "immutable flag test (should return errors) ======="
3390 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3391 remote_ost_nodsh && skip "remote OST with nodsh" && return
3400 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
3401 for value in $(do_facet $SINGLEMDS lctl get_param osc.$mdtosc.prealloc_last_id) ; do
3402 param=`echo ${value[0]} | cut -d "=" -f1`
3403 ostname=`echo $param | cut -d "." -f2 | cut -d - -f 1-2`
3404 mds_last=$(do_facet $SINGLEMDS lctl get_param -n $param)
3405 ostnum=$(echo $ostname | sed "s/${FSNAME}-OST//g" | awk '{print ($1+1)}' )
3406 ost_last=$(do_facet ost$ostnum lctl get_param -n obdfilter.$ostname.last_id | head -n 1)
3407 echo "$ostname.last_id=$ost_last ; MDS.last_id=$mds_last"
3408 if [ $ost_last != $mds_last ]; then
3409 error "$ostname.last_id=$ost_last ; MDS.last_id=$mds_last"
3413 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
3416 [ ! -f "$SOCKETSERVER" ] && skip_env "no socketserver, skipping" && return
3417 [ ! -f "$SOCKETCLIENT" ] && skip_env "no socketclient, skipping" && return
3418 $SOCKETSERVER $DIR/socket
3419 $SOCKETCLIENT $DIR/socket || error
3420 $MUNLINK $DIR/socket
3422 run_test 54a "unix domain socket test =========================="
3428 dd if=/dev/zero of=$f bs=`page_size` count=1
3430 run_test 54b "char device works in lustre ======================"
3433 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
3434 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
3435 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
3437 for i in `seq 3 7`; do
3438 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
3448 loopdev="$DIR/loop54c"
3451 [ -z "$LOOPNUM" ] && echo "couldn't find empty loop device" && return
3452 mknod $loopdev b 7 $LOOPNUM
3453 echo "make a loop file system with $tfile on $loopdev ($LOOPNUM)..."
3454 dd if=/dev/zero of=$tfile bs=`page_size` seek=1024 count=1 > /dev/null
3455 losetup $loopdev $tfile || error "can't set up $loopdev for $tfile"
3456 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
3458 mount -t ext2 $loopdev $tdir || error "error mounting $loopdev on $tdir"
3459 dd if=/dev/zero of=$tdir/tmp bs=`page_size` count=30 || error "dd write"
3461 dd if=$tdir/tmp of=/dev/zero bs=`page_size` count=30 || error "dd read"
3466 run_test 54c "block device works in lustre ====================="
3472 [ "$string" = `echo $string > $f | cat $f` ] || error
3474 run_test 54d "fifo device works in lustre ======================"
3477 check_kernel_version 46 || return 0
3480 cp -aL /dev/console $f
3481 echo $string > $f || error
3483 run_test 54e "console/tty device works in lustre ======================"
3485 #The test_55 used to be iopen test and it was removed by bz#24037.
3486 #run_test 55 "check iopen_connect_dentry() ======================"
3488 test_56a() { # was test_56
3494 NUMFILESx2=$(($NUMFILES * 2))
3495 for i in `seq 1 $NUMFILES` ; do
3496 touch $DIR/d56/file$i
3497 touch $DIR/d56/dir/file$i
3500 # test lfs getstripe with --recursive
3501 FILENUM=`$GETSTRIPE --recursive $DIR/d56 | grep -c obdidx`
3502 [ $FILENUM -eq $NUMFILESx2 ] ||
3503 error "$GETSTRIPE --recursive: found $FILENUM, not $NUMFILESx2"
3504 FILENUM=`$GETSTRIPE $DIR/d56 | grep -c obdidx`
3505 [ $FILENUM -eq $NUMFILES ] ||
3506 error "$GETSTRIPE $DIR/d56: found $FILENUM, not $NUMFILES"
3507 echo "$GETSTRIPE --recursive passed."
3509 # test lfs getstripe with file instead of dir
3510 FILENUM=`$GETSTRIPE $DIR/d56/file1 | grep -c obdidx`
3511 [ $FILENUM -eq 1 ] || error \
3512 "$GETSTRIPE $DIR/d56/file1: found $FILENUM, not 1"
3513 echo "$GETSTRIPE file1 passed."
3515 #test lfs getstripe with --verbose
3516 [ `$GETSTRIPE --verbose $DIR/d56 | grep -c lmm_magic` -eq $NUMFILES ] ||
3517 error "$GETSTRIPE --verbose $DIR/d56: want $NUMFILES lmm_magic"
3518 [ `$GETSTRIPE $DIR/d56 | grep -c lmm_magic` -eq 0 ] ||
3519 error "$GETSTRIPE $DIR/d56: showed lmm_magic"
3520 echo "$GETSTRIPE --verbose passed."
3522 #test lfs getstripe with --obd
3523 $GETSTRIPE --obd wrong_uuid $DIR/d56 2>&1 | grep -q "unknown obduuid" ||
3524 error "$GETSTRIPE --obd wrong_uuid should return error message"
3526 [ "$OSTCOUNT" -lt 2 ] &&
3527 skip_env "skipping other $GETSTRIPE --obd test" && return
3530 OBDUUID=$(ostuuid_from_index $OSTIDX)
3531 FILENUM=`$GETSTRIPE -ir $DIR/d56 | grep -x $OSTIDX | wc -l`
3532 FOUND=`$GETSTRIPE -r --obd $OBDUUID $DIR/d56 | grep obdidx | wc -l`
3533 [ $FOUND -eq $FILENUM ] ||
3534 error "$GETSTRIPE --obd wrong: found $FOUND, expected $FILENUM"
3535 [ `$GETSTRIPE -r -v --obd $OBDUUID $DIR/d56 |
3536 sed '/^[ ]*'${OSTIDX}'[ ]/d' |
3537 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l` -eq 0 ] ||
3538 error "$GETSTRIPE --obd: should not show file on other obd"
3539 echo "$GETSTRIPE --obd passed"
3541 run_test 56a "check $GETSTRIPE"
3546 local LOCAL_NUMFILES="$1"
3547 local LOCAL_NUMDIRS="$2"
3548 local MKDIR_PARAMS="$3"
3550 if [ ! -d "$TDIR" ] ; then
3552 [ "$MKDIR_PARAMS" ] && $SETSTRIPE $MKDIR_PARAMS $TDIR
3553 for i in `seq 1 $LOCAL_NUMFILES` ; do
3556 for i in `seq 1 $LOCAL_NUMDIRS` ; do
3558 for j in `seq 1 $LOCAL_NUMFILES` ; do
3559 touch $TDIR/dir$i/file$j
3565 setup_56_special() {
3569 if [ ! -e "$TDIR/loop1b" ] ; then
3570 for i in `seq 1 $LOCAL_NUMFILES` ; do
3571 mknod $TDIR/loop${i}b b 7 $i
3572 mknod $TDIR/null${i}c c 1 3
3573 ln -s $TDIR/file1 $TDIR/link${i}l
3575 for i in `seq 1 $LOCAL_NUMDIRS` ; do
3576 mknod $TDIR/dir$i/loop${i}b b 7 $i
3577 mknod $TDIR/dir$i/null${i}c c 1 3
3578 ln -s $TDIR/dir$i/file1 $TDIR/dir$i/link${i}l
3587 setup_56 $NUMFILES $NUMDIRS
3589 EXPECTED=$(($NUMDIRS + 2))
3590 # test lfs find with -name
3591 for i in $(seq 1 $NUMFILES) ; do
3592 NUMS=$($LFIND -name "*$i" $TDIR | wc -l)
3593 [ $NUMS -eq $EXPECTED ] ||
3594 error "lfs find -name \"*$i\" $TDIR wrong: "\
3595 "found $NUMS, expected $EXPECTED"
3598 run_test 56g "check lfs find -name ============================="
3604 setup_56 $NUMFILES $NUMDIRS
3606 EXPECTED=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
3607 # test lfs find with ! -name
3608 for i in $(seq 1 $NUMFILES) ; do
3609 NUMS=$($LFIND ! -name "*$i" $TDIR | wc -l)
3610 [ $NUMS -eq $EXPECTED ] ||
3611 error "lfs find ! -name \"*$i\" $TDIR wrong: "\
3612 "found $NUMS, expected $EXPECTED"
3615 run_test 56h "check lfs find ! -name ============================="
3620 UUID=$(ostuuid_from_index 0 $DIR/$tdir)
3621 CMD="$LFIND -ost $UUID $DIR/$tdir"
3623 [ -z "$OUT" ] || error "\"$CMD\" returned directory '$OUT'"
3625 run_test 56i "check 'lfs find -ost UUID' skips directories ======="
3629 setup_56_special $NUMFILES $NUMDIRS
3631 EXPECTED=$((NUMDIRS + 1))
3632 CMD="$LFIND -type d $TDIR"
3633 NUMS=$($CMD | wc -l)
3634 [ $NUMS -eq $EXPECTED ] ||
3635 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3637 run_test 56j "check lfs find -type d ============================="
3641 setup_56_special $NUMFILES $NUMDIRS
3643 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
3644 CMD="$LFIND -type f $TDIR"
3645 NUMS=$($CMD | wc -l)
3646 [ $NUMS -eq $EXPECTED ] ||
3647 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3649 run_test 56k "check lfs find -type f ============================="
3653 setup_56_special $NUMFILES $NUMDIRS
3655 EXPECTED=$((NUMDIRS + NUMFILES))
3656 CMD="$LFIND -type b $TDIR"
3657 NUMS=$($CMD | wc -l)
3658 [ $NUMS -eq $EXPECTED ] ||
3659 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3661 run_test 56l "check lfs find -type b ============================="
3665 setup_56_special $NUMFILES $NUMDIRS
3667 EXPECTED=$((NUMDIRS + NUMFILES))
3668 CMD="$LFIND -type c $TDIR"
3669 NUMS=$($CMD | wc -l)
3670 [ $NUMS -eq $EXPECTED ] ||
3671 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3673 run_test 56m "check lfs find -type c ============================="
3677 setup_56_special $NUMFILES $NUMDIRS
3679 EXPECTED=$((NUMDIRS + NUMFILES))
3680 CMD="$LFIND -type l $TDIR"
3681 NUMS=$($CMD | wc -l)
3682 [ $NUMS -eq $EXPECTED ] ||
3683 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3685 run_test 56n "check lfs find -type l ============================="
3689 setup_56 $NUMFILES $NUMDIRS
3691 utime $TDIR/file1 > /dev/null || error "utime (1)"
3692 utime $TDIR/file2 > /dev/null || error "utime (2)"
3693 utime $TDIR/dir1 > /dev/null || error "utime (3)"
3694 utime $TDIR/dir2 > /dev/null || error "utime (4)"
3695 utime $TDIR/dir1/file1 > /dev/null || error "utime (5)"
3696 dd if=/dev/zero count=1 >> $TDIR/dir1/file1 && sync
3699 NUMS=`$LFIND -mtime +0 $TDIR | wc -l`
3700 [ $NUMS -eq $EXPECTED ] || \
3701 error "lfs find -mtime +0 $TDIR wrong: found $NUMS, expected $EXPECTED"
3704 CMD="$LFIND -mtime 0 $TDIR"
3705 NUMS=$($CMD | wc -l)
3706 [ $NUMS -eq $EXPECTED ] ||
3707 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3709 run_test 56o "check lfs find -mtime for old files =========================="
3712 [ $RUNAS_ID -eq $UID ] &&
3713 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
3716 setup_56 $NUMFILES $NUMDIRS
3718 chown $RUNAS_ID $TDIR/file* || error "chown $DIR/${tdir}g/file$i failed"
3720 CMD="$LFIND -uid $RUNAS_ID $TDIR"
3721 NUMS=$($CMD | wc -l)
3722 [ $NUMS -eq $EXPECTED ] || \
3723 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3725 EXPECTED=$(((NUMFILES + 1) * NUMDIRS + 1))
3726 CMD="$LFIND ! -uid $RUNAS_ID $TDIR"
3727 NUMS=$($CMD | wc -l)
3728 [ $NUMS -eq $EXPECTED ] || \
3729 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3731 run_test 56p "check lfs find -uid and ! -uid ==============================="
3734 [ $RUNAS_ID -eq $UID ] &&
3735 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
3738 setup_56 $NUMFILES $NUMDIRS
3740 chgrp $RUNAS_GID $TDIR/file* || error "chown $TDIR/file$i failed"
3743 CMD="$LFIND -gid $RUNAS_GID $TDIR"
3744 NUMS=$($CMD | wc -l)
3745 [ $NUMS -eq $EXPECTED ] ||
3746 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3748 EXPECTED=$(( ($NUMFILES+1) * $NUMDIRS + 1))
3749 CMD="$LFIND ! -gid $RUNAS_GID $TDIR"
3750 NUMS=$($CMD | wc -l)
3751 [ $NUMS -eq $EXPECTED ] ||
3752 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3754 run_test 56q "check lfs find -gid and ! -gid ==============================="
3758 setup_56 $NUMFILES $NUMDIRS
3761 CMD="$LFIND -size 0 -type f $TDIR"
3762 NUMS=$($CMD | wc -l)
3763 [ $NUMS -eq $EXPECTED ] ||
3764 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3766 CMD="$LFIND ! -size 0 -type f $TDIR"
3767 NUMS=$($CMD | wc -l)
3768 [ $NUMS -eq $EXPECTED ] ||
3769 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3770 echo "test" > $TDIR/$tfile
3771 echo "test2" > $TDIR/$tfile.2 && sync
3773 CMD="$LFIND -size 5 -type f $TDIR"
3774 NUMS=$($CMD | wc -l)
3775 [ $NUMS -eq $EXPECTED ] ||
3776 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3778 CMD="$LFIND -size +5 -type f $TDIR"
3779 NUMS=$($CMD | wc -l)
3780 [ $NUMS -eq $EXPECTED ] ||
3781 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3783 CMD="$LFIND -size +0 -type f $TDIR"
3784 NUMS=$($CMD | wc -l)
3785 [ $NUMS -eq $EXPECTED ] ||
3786 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3788 CMD="$LFIND ! -size -5 -type f $TDIR"
3789 NUMS=$($CMD | wc -l)
3790 [ $NUMS -eq $EXPECTED ] ||
3791 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3793 CMD="$LFIND -size -5 -type f $TDIR"
3794 NUMS=$($CMD | wc -l)
3795 [ $NUMS -eq $EXPECTED ] ||
3796 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3798 run_test 56r "check lfs find -size works =========================="
3800 test_56s() { # LU-611
3802 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT"
3804 if [ $OSTCOUNT -gt 1 ]; then
3805 $SETSTRIPE -c 1 $TDIR/$tfile.{0,1,2,3}
3809 ONESTRIPE=$(((NUMDIRS + 1) * NUMFILES))
3813 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
3814 CMD="$LFIND -stripe-count $OSTCOUNT -type f $TDIR"
3815 NUMS=$($CMD | wc -l)
3816 [ $NUMS -eq $EXPECTED ] ||
3817 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3819 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + EXTRA))
3820 CMD="$LFIND -stripe-count +0 -type f $TDIR"
3821 NUMS=$($CMD | wc -l)
3822 [ $NUMS -eq $EXPECTED ] ||
3823 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3826 CMD="$LFIND -stripe-count 1 -type f $TDIR"
3827 NUMS=$($CMD | wc -l)
3828 [ $NUMS -eq $EXPECTED ] ||
3829 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3831 CMD="$LFIND -stripe-count -2 -type f $TDIR"
3832 NUMS=$($CMD | wc -l)
3833 [ $NUMS -eq $EXPECTED ] ||
3834 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3837 CMD="$LFIND -stripe-count $((OSTCOUNT + 1)) -type f $TDIR"
3838 NUMS=$($CMD | wc -l)
3839 [ $NUMS -eq $EXPECTED ] ||
3840 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3842 run_test 56s "check lfs find -stripe-count works"
3844 test_56t() { # LU-611
3846 setup_56 $NUMFILES $NUMDIRS "-s 512k"
3848 $SETSTRIPE -S 256k $TDIR/$tfile.{0,1,2,3}
3850 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
3851 CMD="$LFIND -stripe-size 512k -type f $TDIR"
3852 NUMS=$($CMD | wc -l)
3853 [ $NUMS -eq $EXPECTED ] ||
3854 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3856 CMD="$LFIND -stripe-size +320k -type f $TDIR"
3857 NUMS=$($CMD | wc -l)
3858 [ $NUMS -eq $EXPECTED ] ||
3859 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3861 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + 4))
3862 CMD="$LFIND -stripe-size +200k -type f $TDIR"
3863 NUMS=$($CMD | wc -l)
3864 [ $NUMS -eq $EXPECTED ] ||
3865 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3867 CMD="$LFIND -stripe-size -640k -type f $TDIR"
3868 NUMS=$($CMD | wc -l)
3869 [ $NUMS -eq $EXPECTED ] ||
3870 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3873 CMD="$LFIND -stripe-size 256k -type f $TDIR"
3874 NUMS=$($CMD | wc -l)
3875 [ $NUMS -eq $EXPECTED ] ||
3876 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3878 CMD="$LFIND -stripe-size -320k -type f $TDIR"
3879 NUMS=$($CMD | wc -l)
3880 [ $NUMS -eq $EXPECTED ] ||
3881 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3884 CMD="$LFIND -stripe-size 1024k -type f $TDIR"
3885 NUMS=$($CMD | wc -l)
3886 [ $NUMS -eq $EXPECTED ] ||
3887 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3889 run_test 56t "check lfs find -stripe-size works"
3891 test_56u() { # LU-611
3893 setup_56 $NUMFILES $NUMDIRS "-i 0"
3895 if [ $OSTCOUNT -gt 1 ]; then
3896 $SETSTRIPE -i 1 $TDIR/$tfile.{0,1,2,3}
3902 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
3903 CMD="$LFIND -stripe-index 0 -type f $TDIR"
3904 NUMS=$($CMD | wc -l)
3905 [ $NUMS -eq $EXPECTED ] ||
3906 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3909 CMD="$LFIND -stripe-index 1 -type f $TDIR"
3910 NUMS=$($CMD | wc -l)
3911 [ $NUMS -eq $EXPECTED ] ||
3912 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3914 CMD="$LFIND ! -stripe-index 0 -type f $TDIR"
3915 NUMS=$($CMD | wc -l)
3916 [ $NUMS -eq $EXPECTED ] ||
3917 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3920 # This should produce an error and not return any files
3921 CMD="$LFIND -stripe-index $OSTCOUNT -type f $TDIR"
3922 NUMS=$($CMD 2>/dev/null | wc -l)
3923 [ $NUMS -eq $EXPECTED ] ||
3924 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3926 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + ONESTRIPE))
3927 CMD="$LFIND -stripe-index 0,1 -type f $TDIR"
3928 NUMS=$($CMD | wc -l)
3929 [ $NUMS -eq $EXPECTED ] ||
3930 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3932 run_test 56u "check lfs find -stripe-index works"
3939 setup_56 $NUMFILES $NUMDIRS
3941 UUID=$(mdtuuid_from_index $MDT_IDX $TDIR)
3942 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT index $MDT_IDX"
3944 for file in $($LFIND -mdt $UUID $TDIR); do
3945 file_mdt_idx=$($GETSTRIPE -M $file)
3946 [ $file_mdt_idx -eq $MDT_IDX ] ||
3947 error "'lfind -mdt $UUID' != 'getstripe -M' ($file_mdt_idx)"
3950 run_test 56v "check 'lfs find -mdt match with lfs getstripe -M' ======="
3952 # Get and check the actual stripe count of one file.
3953 # Usage: check_stripe_count <file> <expected_stripe_count>
3954 check_stripe_count() {
3959 [[ -z "$file" || -z "$expected" ]] &&
3960 error "check_stripe_count: invalid argument!"
3962 local cmd="$GETSTRIPE -c $file"
3963 actual=$($cmd) || error "$cmd failed"
3964 actual=${actual%% *}
3966 if [[ $actual -ne $expected ]]; then
3967 [[ $expected -eq -1 ]] ||
3968 error "$cmd wrong: found $actual, expected $expected"
3969 [[ $actual -eq $OSTCOUNT ]] ||
3970 error "$cmd wrong: found $actual, expected $OSTCOUNT"
3977 rm -rf $TDIR || error "remove $TDIR failed"
3978 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT"
3981 stripe_size=$($GETSTRIPE -S -d $TDIR) ||
3982 error "$GETSTRIPE -S -d $TDIR failed"
3983 stripe_size=${stripe_size%% *}
3985 local file_size=$((stripe_size * OSTCOUNT))
3986 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
3987 local required_space=$((file_num * file_size))
3988 local free_space=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
3989 [[ $free_space -le $((required_space / 1024)) ]] &&
3990 skip_env "need at least $required_space bytes free space," \
3991 "have $free_space kbytes" && return
3994 local dd_count=$((file_size / dd_bs))
3996 # write data into the files
4000 for i in $(seq 1 $NUMFILES); do
4002 yes | dd bs=$dd_bs count=$dd_count of=$file >/dev/null 2>&1 ||
4003 error "write data into $file failed"
4005 for i in $(seq 1 $NUMDIRS); do
4006 for j in $(seq 1 $NUMFILES); do
4007 file=$TDIR/dir$i/file$j
4008 yes | dd bs=$dd_bs count=$dd_count of=$file \
4010 error "write data into $file failed"
4015 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
4018 local cmd="$LFS_MIGRATE -y -c $expected $TDIR/file1"
4020 eval $cmd || error "$cmd failed"
4022 check_stripe_count $TDIR/file1 $expected
4025 cmd="$LFS_MIGRATE -y -c $expected $TDIR/dir1"
4027 eval $cmd || error "$cmd failed"
4029 for j in $(seq 1 $NUMFILES); do
4030 check_stripe_count $TDIR/dir1/file$j $expected
4033 # lfs_migrate works with lfs find
4034 cmd="$LFIND -stripe_count $OSTCOUNT -type f $TDIR |
4035 $LFS_MIGRATE -y -c $expected"
4037 eval $cmd || error "$cmd failed"
4039 for i in $(seq 2 $NUMFILES); do
4040 check_stripe_count $TDIR/file$i $expected
4042 for i in $(seq 2 $NUMDIRS); do
4043 for j in $(seq 1 $NUMFILES); do
4044 check_stripe_count $TDIR/dir$i/file$j $expected
4048 run_test 56w "check lfs_migrate -c stripe_count works"
4051 # note test will not do anything if MDS is not local
4052 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4053 skip "Only applicable to ldiskfs-based MDTs"
4057 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4058 local MNTDEV="osd*.*MDT*.mntdev"
4059 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
4060 [ -z "$DEV" ] && error "can't access $MNTDEV"
4061 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
4062 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
4063 error "can't access $DEV"
4064 DEVISIZE=`awk '/Inode size:/ { print $3 }' $TMP/t57a.dump`
4065 [ "$DEVISIZE" -gt 128 ] || error "inode size $DEVISIZE"
4069 run_test 57a "verify MDS filesystem created with large inodes =="
4072 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4073 skip "Only applicable to ldiskfs-based MDTs"
4077 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4082 local FILEN=$dir/f$FILECOUNT
4084 rm -rf $dir || error "removing $dir"
4085 mkdir -p $dir || error "creating $dir"
4086 local num=$(get_mds_dir $dir)
4089 echo "mcreating $FILECOUNT files"
4090 createmany -m $dir/f 1 $FILECOUNT || \
4091 error "creating files in $dir"
4093 # verify that files do not have EAs yet
4094 $GETSTRIPE $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
4095 $GETSTRIPE $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
4099 df $dir #make sure we get new statfs data
4100 local MDSFREE=$(do_facet $mymds \
4101 lctl get_param -n osd*.*MDT000$((num -1)).kbytesfree)
4102 local MDCFREE=$(lctl get_param -n mdc.*MDT000$((num -1))-mdc-*.kbytesfree)
4103 echo "opening files to create objects/EAs"
4105 for FILE in `seq -f $dir/f%g 1 $FILECOUNT`; do
4106 $OPENFILE -f O_RDWR $FILE > /dev/null 2>&1 || error "opening $FILE"
4109 # verify that files have EAs now
4110 $GETSTRIPE $FILE1 | grep -q "obdidx" || error "$FILE1 missing EA"
4111 $GETSTRIPE $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
4113 sleep 1 #make sure we get new statfs data
4115 local MDSFREE2=$(do_facet $mymds \
4116 lctl get_param -n osd*.*MDT000$((num -1)).kbytesfree)
4117 local MDCFREE2=$(lctl get_param -n mdc.*MDT000$((num -1))-mdc-*.kbytesfree)
4118 if [ "$MDCFREE2" -lt "$((MDCFREE - 8))" ]; then
4119 if [ "$MDSFREE" != "$MDSFREE2" ]; then
4120 error "MDC before $MDCFREE != after $MDCFREE2"
4122 echo "MDC before $MDCFREE != after $MDCFREE2"
4123 echo "unable to confirm if MDS has large inodes"
4128 run_test 57b "default LOV EAs are stored inside large inodes ==="
4131 [ -z "$(which wiretest 2>/dev/null)" ] && skip_env "could not find wiretest" && return
4134 run_test 58 "verify cross-platform wire constants =============="
4137 echo "touch 130 files"
4138 createmany -o $DIR/f59- 130
4140 unlinkmany $DIR/f59- 130
4142 # wait for commitment of removal
4143 wait_delete_completed
4145 run_test 59 "verify cancellation of llog records async ========="
4147 TEST60_HEAD="test_60 run $RANDOM"
4149 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
4150 [ ! -f run-llog.sh ] && skip_env "missing subtest run-llog.sh" && return
4151 log "$TEST60_HEAD - from kernel mode"
4152 do_facet mgs sh run-llog.sh
4154 run_test 60a "llog sanity tests run from kernel module =========="
4156 test_60b() { # bug 6411
4158 LLOG_COUNT=`dmesg | awk "/$TEST60_HEAD/{marker = 1; from_marker = 0;}
4170 [ $LLOG_COUNT -gt 50 ] && error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)"|| true
4172 run_test 60b "limit repeated messages from CERROR/CWARN ========"
4175 echo "create 5000 files"
4176 createmany -o $DIR/f60c- 5000
4177 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
4178 lctl set_param fail_loc=0x80000137
4179 unlinkmany $DIR/f60c- 5000
4180 lctl set_param fail_loc=0
4182 run_test 60c "unlink file when mds full"
4185 SAVEPRINTK=$(lctl get_param -n printk)
4187 # verify "lctl mark" is even working"
4188 MESSAGE="test message ID $RANDOM $$"
4189 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
4190 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
4192 lctl set_param printk=0 || error "set lnet.printk failed"
4193 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
4194 MESSAGE="new test message ID $RANDOM $$"
4195 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
4196 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
4197 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
4199 lctl set_param -n printk="$SAVEPRINTK"
4201 run_test 60d "test printk console message masking"
4205 dd if=/dev/zero of=$f bs=`page_size` count=1
4206 cancel_lru_locks osc
4207 $MULTIOP $f OSMWUc || error
4210 run_test 61 "mmap() writes don't make sync hang ================"
4212 # bug 2330 - insufficient obd_match error checking causes LBUG
4216 cancel_lru_locks osc
4217 lctl set_param fail_loc=0x405
4218 cat $f && error "cat succeeded, expect -EIO"
4219 lctl set_param fail_loc=0
4221 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
4222 # match every page all of the time.
4223 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
4225 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
4226 test_63a() { # was test_63
4227 MAX_DIRTY_MB=`lctl get_param -n osc.*.max_dirty_mb | head -n 1`
4228 lctl set_param -n osc.*.max_dirty_mb 0
4229 for i in `seq 10` ; do
4230 dd if=/dev/zero of=$DIR/f63 bs=8k &
4236 lctl set_param -n osc.*.max_dirty_mb $MAX_DIRTY_MB
4237 rm -f $DIR/f63 || true
4239 run_test 63a "Verify oig_wait interruption does not crash ======="
4241 # bug 2248 - async write errors didn't return to application on sync
4242 # bug 3677 - async write errors left page locked
4245 lctl set_param debug=-1
4247 # ensure we have a grant to do async writes
4248 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
4251 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
4252 lctl set_param fail_loc=0x80000406
4253 $MULTIOP $DIR/$tfile Owy && \
4254 error "sync didn't return ENOMEM"
4255 sync; sleep 2; sync # do a real sync this time to flush page
4256 lctl get_param -n llite.*.dump_page_cache | grep locked && \
4257 error "locked page left in cache after async error" || true
4260 run_test 63b "async write errors should be returned to fsync ==="
4264 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
4266 run_test 64a "verify filter grant calculations (in kernel) ====="
4269 [ ! -f oos.sh ] && skip_env "missing subtest oos.sh" && return
4272 run_test 64b "check out-of-space detection on client ==========="
4274 # bug 1414 - set/get directories' stripe info
4278 $LVERIFY $DIR/d65 $DIR/d65/f1 || error "lverify failed"
4280 run_test 65a "directory with no stripe info ===================="
4284 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/d65||error "setstripe"
4286 $LVERIFY $DIR/d65 $DIR/d65/f2 || error "lverify failed"
4288 run_test 65b "directory setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1"
4291 if [ $OSTCOUNT -gt 1 ]; then
4293 $SETSTRIPE -S $(($STRIPESIZE * 4)) -i 1 \
4294 -c $(($OSTCOUNT - 1)) $DIR/d65 || error "setstripe"
4296 $LVERIFY $DIR/d65 $DIR/d65/f3 || error "lverify failed"
4299 run_test 65c "directory setstripe -S $((STRIPESIZE*4)) -i 1 -c $((OSTCOUNT-1))"
4303 if [ $STRIPECOUNT -le 0 ]; then
4305 elif [ $STRIPECOUNT -gt 2000 ]; then
4306 #LOV_MAX_STRIPE_COUNT is 2000
4307 [ $OSTCOUNT -gt 2000 ] && sc=2000 || sc=$(($OSTCOUNT - 1))
4309 sc=$(($STRIPECOUNT - 1))
4311 $SETSTRIPE -S $STRIPESIZE -c $sc $DIR/d65 || error "setstripe"
4312 touch $DIR/d65/f4 $DIR/d65/f5
4313 $LVERIFY $DIR/d65 $DIR/d65/f4 $DIR/d65/f5 || error "lverify failed"
4315 run_test 65d "directory setstripe -S $STRIPESIZE -c stripe_count"
4320 $SETSTRIPE $DIR/d65 || error "setstripe"
4321 $GETSTRIPE -v $DIR/d65 | grep "Default" || error "no stripe info failed"
4323 $LVERIFY $DIR/d65 $DIR/d65/f6 || error "lverify failed"
4325 run_test 65e "directory setstripe defaults ======================="
4329 $RUNAS $SETSTRIPE $DIR/d65f && error "setstripe succeeded" || true
4331 run_test 65f "dir setstripe permission (should return error) ==="
4335 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/d65 ||error "setstripe"
4336 $SETSTRIPE -d $DIR/d65 || error "setstripe"
4337 $GETSTRIPE -v $DIR/d65 | grep "Default" || \
4338 error "delete default stripe failed"
4340 run_test 65g "directory setstripe -d ==========================="
4344 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/d65 ||error "setstripe"
4345 mkdir -p $DIR/d65/dd1
4346 [ $($GETSTRIPE -c $DIR/d65) == $($GETSTRIPE -c $DIR/d65/dd1) ] ||
4347 error "stripe info inherit failed"
4349 run_test 65h "directory stripe info inherit ===================="
4351 test_65i() { # bug6367
4352 $SETSTRIPE -S 65536 -c -1 $MOUNT
4354 run_test 65i "set non-default striping on root directory (bug 6367)="
4356 test_65ia() { # bug12836
4357 $GETSTRIPE $MOUNT || error "getstripe $MOUNT failed"
4359 run_test 65ia "getstripe on -1 default directory striping"
4361 test_65ib() { # bug12836
4362 $GETSTRIPE -v $MOUNT || error "getstripe -v $MOUNT failed"
4364 run_test 65ib "getstripe -v on -1 default directory striping"
4366 test_65ic() { # bug12836
4367 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
4369 run_test 65ic "new find on -1 default directory striping"
4371 test_65j() { # bug6367
4373 # if we aren't already remounting for each test, do so for this test
4374 if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
4375 cleanup || error "failed to unmount"
4378 $SETSTRIPE -d $MOUNT || error "setstripe failed"
4380 run_test 65j "set default striping on root directory (bug 6367)="
4382 test_65k() { # bug11679
4383 [ "$OSTCOUNT" -lt 2 ] && skip_env "too few OSTs" && return
4384 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4386 echo "Check OST status: "
4387 local MDS_OSCS=`do_facet $SINGLEMDS lctl dl |
4388 awk '/[oO][sS][cC].*md[ts]/ { print $4 }'`
4390 for OSC in $MDS_OSCS; do
4391 echo $OSC "is activate"
4392 do_facet $SINGLEMDS lctl --device %$OSC activate
4395 do_facet client mkdir -p $DIR/$tdir
4396 for INACTIVE_OSC in $MDS_OSCS; do
4397 echo "Deactivate: " $INACTIVE_OSC
4398 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
4399 for STRIPE_OSC in $MDS_OSCS; do
4400 OST=`osc_to_ost $STRIPE_OSC`
4401 IDX=`do_facet $SINGLEMDS lctl get_param -n lov.*md*.target_obd |
4402 awk -F: /$OST/'{ print $1 }' | head -n 1`
4404 [ -f $DIR/$tdir/$IDX ] && continue
4405 echo "$SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX"
4406 do_facet client $SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX
4408 [ $RC -ne 0 ] && error "setstripe should have succeeded"
4410 do_facet client rm -f $DIR/$tdir/*
4411 echo $INACTIVE_OSC "is Activate."
4412 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
4415 run_test 65k "validate manual striping works properly with deactivated OSCs"
4417 test_65l() { # bug 12836
4418 mkdir -p $DIR/$tdir/test_dir
4419 $SETSTRIPE -c -1 $DIR/$tdir/test_dir
4420 $LFS find -mtime -1 $DIR/$tdir >/dev/null
4422 run_test 65l "lfs find on -1 stripe dir ========================"
4424 # bug 2543 - update blocks count on client
4427 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
4428 sync; sync_all_data; sync; sync_all_data
4429 cancel_lru_locks osc
4430 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
4431 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
4433 run_test 66 "update inode blocks count on client ==============="
4439 if [ ! -z "$LLOOP" ]; then
4440 if swapon -s | grep -q $LLOOP; then
4441 swapoff $LLOOP || error "swapoff failed"
4444 $LCTL blockdev_detach $LLOOP || error "detach failed"
4448 if [ ! -z "$LLITELOOPLOAD" ]; then
4456 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
4460 swapon -s | awk '($1 == "'$1'") { print $4 }'
4463 # test case for lloop driver, basic function
4465 [ "$UID" != 0 ] && skip_env "must run as root" && return
4466 llite_lloop_enabled || \
4467 { skip_env "llite_lloop module disabled" && return; }
4469 trap cleanup_68 EXIT
4471 if ! module_loaded llite_lloop; then
4472 if load_module llite/llite_lloop; then
4475 skip_env "can't find module llite_lloop"
4480 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
4481 dd if=/dev/zero of=$DIR/f68a bs=4k count=1024
4482 $LCTL blockdev_attach $DIR/f68a $LLOOP || error "attach failed"
4484 directio rdwr $LLOOP 0 1024 4096 || error "direct write failed"
4485 directio rdwr $LLOOP 0 1025 4096 && error "direct write should fail"
4489 run_test 68a "lloop driver - basic test ========================"
4491 # excercise swapping to lustre by adding a high priority swapfile entry
4492 # and then consuming memory until it is used.
4493 test_68b() { # was test_68
4494 [ "$UID" != 0 ] && skip_env "must run as root" && return
4495 lctl get_param -n devices | grep -q obdfilter && \
4496 skip "local OST" && return
4498 grep -q llite_lloop /proc/modules
4499 [ $? -ne 0 ] && skip "can't find module llite_lloop" && return
4501 [ -z "`$LCTL list_nids | grep -v tcp`" ] && \
4502 skip "can't reliably test swap with TCP" && return
4504 MEMTOTAL=`meminfo MemTotal`
4505 NR_BLOCKS=$((MEMTOTAL>>8))
4506 [[ $NR_BLOCKS -le 2048 ]] && NR_BLOCKS=2048
4508 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
4509 dd if=/dev/zero of=$DIR/f68b bs=64k seek=$NR_BLOCKS count=1
4512 $LCTL blockdev_attach $DIR/f68b $LLOOP || error "attach failed"
4514 trap cleanup_68 EXIT
4516 swapon -p 32767 $LLOOP || error "swapon $LLOOP failed"
4518 echo "before: `swapon -s | grep $LLOOP`"
4519 $MEMHOG $MEMTOTAL || error "error allocating $MEMTOTAL kB"
4520 echo "after: `swapon -s | grep $LLOOP`"
4521 SWAPUSED=`swap_used $LLOOP`
4525 [ $SWAPUSED -eq 0 ] && echo "no swap used???" || true
4527 run_test 68b "support swapping to Lustre ========================"
4529 # bug5265, obdfilter oa2dentry return -ENOENT
4530 # #define OBD_FAIL_OST_ENOENT 0x217
4532 remote_ost_nodsh && skip "remote OST with nodsh" && return
4535 $SETSTRIPE -c 1 -i 0 $f
4537 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
4539 do_facet ost1 lctl set_param fail_loc=0x217
4540 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
4541 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
4543 do_facet ost1 lctl set_param fail_loc=0
4544 $DIRECTIO write $f 0 2 || error "write error"
4546 cancel_lru_locks osc
4547 $DIRECTIO read $f 0 1 || error "read error"
4549 do_facet ost1 lctl set_param fail_loc=0x217
4550 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
4552 do_facet ost1 lctl set_param fail_loc=0
4555 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
4559 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
4561 run_test 71 "Running dbench on lustre (don't segment fault) ===="
4563 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
4564 check_kernel_version 43 || return 0
4565 [ "$RUNAS_ID" = "$UID" ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4567 # Check that testing environment is properly set up. Skip if not
4568 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS || {
4569 skip_env "User $RUNAS_ID does not exist - skipping"
4572 # We had better clear the $DIR to get enough space for dd
4577 $RUNAS dd if=/dev/zero of=$DIR/f72 bs=512 count=1 || error
4578 # See if we are still setuid/sgid
4579 test -u $DIR/f72 -o -g $DIR/f72 && error "S/gid is not dropped on write"
4580 # Now test that MDS is updated too
4581 cancel_lru_locks mdc
4582 test -u $DIR/f72 -o -g $DIR/f72 && error "S/gid is not dropped on MDS"
4585 run_test 72a "Test that remove suid works properly (bug5695) ===="
4587 test_72b() { # bug 24226 -- keep mode setting when size is not changing
4590 [ "$RUNAS_ID" = "$UID" ] && \
4591 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4592 [ "$RUNAS_ID" -eq 0 ] && \
4593 skip_env "RUNAS_ID = 0 -- skipping" && return
4595 # Check that testing environment is properly set up. Skip if not
4596 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS || {
4597 skip_env "User $RUNAS_ID does not exist - skipping"
4600 touch $DIR/${tfile}-f{g,u}
4601 mkdir $DIR/${tfile}-d{g,u}
4602 chmod 770 $DIR/${tfile}-{f,d}{g,u}
4603 chmod g+s $DIR/${tfile}-{f,d}g
4604 chmod u+s $DIR/${tfile}-{f,d}u
4605 for perm in 777 2777 4777; do
4606 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
4607 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
4608 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
4609 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
4613 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
4615 # bug 3462 - multiple simultaneous MDC requests
4619 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
4622 lctl set_param fail_loc=0x80000129
4623 $MULTIOP $DIR/d73-1/f73-2 Oc &
4625 lctl set_param fail_loc=0
4627 $MULTIOP $DIR/d73-2/f73-3 Oc &
4631 wait $pid1 || return 1
4635 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
4636 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
4637 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
4641 run_test 73 "multiple MDC requests (should not deadlock)"
4643 test_74a() { # bug 6149, 6184
4644 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
4646 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
4647 # will spin in a tight reconnection loop
4649 lctl set_param fail_loc=0x8000030e
4650 # get any lock that won't be difficult - lookup works.
4652 lctl set_param fail_loc=0
4656 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
4658 test_74b() { # bug 13310
4659 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
4661 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
4662 # will spin in a tight reconnection loop
4663 lctl set_param fail_loc=0x8000030e
4664 # get a "difficult" lock
4666 lctl set_param fail_loc=0
4670 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
4673 #define OBD_FAIL_LDLM_NEW_LOCK
4674 lctl set_param fail_loc=0x80000319
4675 touch $DIR/$tfile && error "Touch successful"
4678 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
4681 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
4684 get_inode_slab_tunables() {
4685 awk '/lustre_inode_cache/ {print $9," ",$10," ",$11; exit}' /proc/slabinfo
4688 set_inode_slab_tunables() {
4689 echo "lustre_inode_cache $1" > /proc/slabinfo
4692 test_76() { # Now for bug 20433, added originally in bug 1443
4693 local SLAB_SETTINGS=`get_inode_slab_tunables`
4694 local CPUS=`getconf _NPROCESSORS_ONLN`
4695 # we cannot set limit below 1 which means 1 inode in each
4696 # per-cpu cache is still allowed
4697 set_inode_slab_tunables "1 1 0"
4698 cancel_lru_locks osc
4699 BEFORE_INODES=`num_inodes`
4700 echo "before inodes: $BEFORE_INODES"
4702 [ "$SLOW" = "no" ] && COUNT=100
4703 for i in `seq $COUNT`; do
4707 cancel_lru_locks osc
4708 AFTER_INODES=`num_inodes`
4709 echo "after inodes: $AFTER_INODES"
4711 while [ $((AFTER_INODES-1*CPUS)) -gt $BEFORE_INODES ]; do
4713 AFTER_INODES=`num_inodes`
4715 echo "wait $wait seconds inodes: $AFTER_INODES"
4716 if [ $wait -gt 30 ]; then
4717 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
4720 set_inode_slab_tunables "$SLAB_SETTINGS"
4722 run_test 76 "confirm clients recycle inodes properly ===="
4728 # Note: in sptlrpc modes which enable its own bulk checksum, the
4729 # original crc32_le bulk checksum will be automatically disabled,
4730 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
4731 # will be checked by sptlrpc code against sptlrpc bulk checksum.
4732 # In this case set_checksums() will not be no-op, because sptlrpc
4733 # bulk checksum will be enabled all through the test.
4735 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
4736 lctl set_param -n osc.*.checksums $1
4740 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
4741 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
4742 CKSUM_TYPES=${CKSUM_TYPES:-"crc32 adler"}
4743 [ "$ORIG_CSUM_TYPE" = "crc32c" ] && CKSUM_TYPES="$CKSUM_TYPES crc32c"
4746 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
4747 log "set checksum type to $1"
4750 F77_TMP=$TMP/f77-temp
4753 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
4754 error "error writing to $F77_TMP"
4757 test_77a() { # bug 10889
4758 $GSS && skip "could not run with gss" && return
4759 [ ! -f $F77_TMP ] && setup_f77
4761 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
4765 run_test 77a "normal checksum read/write operation ============="
4767 test_77b() { # bug 10889
4768 $GSS && skip "could not run with gss" && return
4769 [ ! -f $F77_TMP ] && setup_f77
4770 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
4771 lctl set_param fail_loc=0x80000409
4773 dd if=$F77_TMP of=$DIR/f77b bs=1M count=$F77SZ conv=sync || \
4774 error "dd error: $?"
4775 lctl set_param fail_loc=0
4778 run_test 77b "checksum error on client write ===================="
4780 test_77c() { # bug 10889
4781 $GSS && skip "could not run with gss" && return
4782 [ ! -f $DIR/f77b ] && skip "requires 77b - skipping" && return
4784 for algo in $CKSUM_TYPES; do
4785 cancel_lru_locks osc
4786 set_checksum_type $algo
4787 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
4788 lctl set_param fail_loc=0x80000408
4789 cmp $F77_TMP $DIR/f77b || error "file compare failed"
4790 lctl set_param fail_loc=0
4793 set_checksum_type $ORIG_CSUM_TYPE
4796 run_test 77c "checksum error on client read ==================="
4798 test_77d() { # bug 10889
4799 $GSS && skip "could not run with gss" && return
4800 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
4801 lctl set_param fail_loc=0x80000409
4803 directio write $DIR/f77 0 $F77SZ $((1024 * 1024)) || \
4804 error "direct write: rc=$?"
4805 lctl set_param fail_loc=0
4808 run_test 77d "checksum error on OST direct write ==============="
4810 test_77e() { # bug 10889
4811 $GSS && skip "could not run with gss" && return
4812 [ ! -f $DIR/f77 ] && skip "requires 77d - skipping" && return
4813 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
4814 lctl set_param fail_loc=0x80000408
4816 cancel_lru_locks osc
4817 directio read $DIR/f77 0 $F77SZ $((1024 * 1024)) || \
4818 error "direct read: rc=$?"
4819 lctl set_param fail_loc=0
4822 run_test 77e "checksum error on OST direct read ================"
4824 test_77f() { # bug 10889
4825 $GSS && skip "could not run with gss" && return
4827 for algo in $CKSUM_TYPES; do
4828 cancel_lru_locks osc
4829 set_checksum_type $algo
4830 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
4831 lctl set_param fail_loc=0x409
4832 directio write $DIR/f77 0 $F77SZ $((1024 * 1024)) && \
4833 error "direct write succeeded"
4834 lctl set_param fail_loc=0
4836 set_checksum_type $ORIG_CSUM_TYPE
4839 run_test 77f "repeat checksum error on write (expect error) ===="
4841 test_77g() { # bug 10889
4842 $GSS && skip "could not run with gss" && return
4843 remote_ost_nodsh && skip "remote OST with nodsh" && return
4845 [ ! -f $F77_TMP ] && setup_f77
4847 $SETSTRIPE -c 1 -i 0 $DIR/f77g
4848 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
4849 do_facet ost1 lctl set_param fail_loc=0x8000021a
4851 dd if=$F77_TMP of=$DIR/f77g bs=1M count=$F77SZ || \
4852 error "write error: rc=$?"
4853 do_facet ost1 lctl set_param fail_loc=0
4856 run_test 77g "checksum error on OST write ======================"
4858 test_77h() { # bug 10889
4859 $GSS && skip "could not run with gss" && return
4860 remote_ost_nodsh && skip "remote OST with nodsh" && return
4862 [ ! -f $DIR/f77g ] && skip "requires 77g - skipping" && return
4863 cancel_lru_locks osc
4864 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
4865 do_facet ost1 lctl set_param fail_loc=0x8000021b
4867 cmp $F77_TMP $DIR/f77g || error "file compare failed"
4868 do_facet ost1 lctl set_param fail_loc=0
4871 run_test 77h "checksum error on OST read ======================="
4873 test_77i() { # bug 13805
4874 $GSS && skip "could not run with gss" && return
4875 #define OBD_FAIL_OSC_CONNECT_CKSUM 0x40b
4876 lctl set_param fail_loc=0x40b
4877 remount_client $MOUNT
4878 lctl set_param fail_loc=0
4879 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
4880 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
4881 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
4882 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
4884 remount_client $MOUNT
4886 run_test 77i "client not supporting OSD_CONNECT_CKSUM =========="
4888 test_77j() { # bug 13805
4889 $GSS && skip "could not run with gss" && return
4890 #define OBD_FAIL_OSC_CKSUM_ADLER_ONLY 0x40c
4891 lctl set_param fail_loc=0x40c
4892 remount_client $MOUNT
4893 lctl set_param fail_loc=0
4894 sleep 2 # wait async osc connect to finish
4895 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
4896 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
4897 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
4898 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
4900 remount_client $MOUNT
4902 run_test 77j "client only supporting ADLER32 ===================="
4904 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
4908 test_78() { # bug 10901
4909 remote_ost || { skip_env "local OST" && return; }
4912 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
4913 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
4914 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
4915 echo "MemTotal: $MEMTOTAL"
4916 # reserve 256MB of memory for the kernel and other running processes,
4917 # and then take 1/2 of the remaining memory for the read/write buffers.
4918 if [ $MEMTOTAL -gt 512 ] ;then
4919 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
4921 # for those poor memory-starved high-end clusters...
4922 MEMTOTAL=$((MEMTOTAL / 2))
4924 echo "Mem to use for directio: $MEMTOTAL"
4925 [ $F78SIZE -gt $MEMTOTAL ] && F78SIZE=$MEMTOTAL
4926 [ $F78SIZE -gt 512 ] && F78SIZE=512
4927 [ $F78SIZE -gt $((MAXFREE / 1024)) ] && F78SIZE=$((MAXFREE / 1024))
4928 SMALLESTOST=`lfs df $DIR |grep OST | awk '{print $4}' |sort -n |head -1`
4929 echo "Smallest OST: $SMALLESTOST"
4930 [ $SMALLESTOST -lt 10240 ] && \
4931 skip "too small OSTSIZE, useless to run large O_DIRECT test" && return 0
4933 [ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ] && \
4934 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
4936 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
4937 echo "File size: $F78SIZE"
4938 $SETSTRIPE -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
4939 for i in `seq 1 $NSEQ`
4941 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
4942 echo directIO rdwr round $i of $NSEQ
4943 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
4948 run_test 78 "handle large O_DIRECT writes correctly ============"
4950 test_79() { # bug 12743
4951 wait_delete_completed
4953 BKTOTAL=$(calc_osc_kbytes kbytestotal)
4954 BKFREE=$(calc_osc_kbytes kbytesfree)
4955 BKAVAIL=$(calc_osc_kbytes kbytesavail)
4957 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
4958 DFTOTAL=`echo $STRING | cut -d, -f1`
4959 DFUSED=`echo $STRING | cut -d, -f2`
4960 DFAVAIL=`echo $STRING | cut -d, -f3`
4961 DFFREE=$(($DFTOTAL - $DFUSED))
4963 ALLOWANCE=$((64 * $OSTCOUNT))
4965 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
4966 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
4967 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
4969 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
4970 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
4971 error "df free($DFFREE) mismatch OST free($BKFREE)"
4973 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
4974 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
4975 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
4978 run_test 79 "df report consistency check ======================="
4980 test_80() { # bug 10718
4981 # relax strong synchronous semantics for slow backends like ZFS
4982 local soc="obdfilter.*.sync_on_lock_cancel"
4983 local soc_old=$(do_facet ost1 lctl get_param -n $soc | head -n1)
4985 if [ "$soc_old" != "never" -a "$FSTYPE" != "ldiskfs" ]; then
4986 hosts=$(for host in $(seq -f "ost%g" 1 $OSTCOUNT); do
4987 facet_active_host $host; done | sort -u)
4988 do_nodes $hosts lctl set_param $soc=never
4991 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
4993 local BEFORE=`date +%s`
4994 cancel_lru_locks osc
4995 local AFTER=`date +%s`
4996 local DIFF=$((AFTER-BEFORE))
4997 if [ $DIFF -gt 1 ] ; then
4998 error "elapsed for 1M@1T = $DIFF"
5001 [ -n "$hosts" ] && do_nodes $hosts lctl set_param $soc=$soc_old
5005 run_test 80 "Page eviction is equally fast at high offsets too ===="
5007 test_81a() { # LU-456
5008 remote_ost_nodsh && skip "remote OST with nodsh" && return
5009 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
5010 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
5011 do_facet ost1 lctl set_param fail_loc=0x80000228
5013 # write should trigger a retry and success
5014 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
5015 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
5017 if [ $RC -ne 0 ] ; then
5018 error "write should success, but failed for $RC"
5021 run_test 81a "OST should retry write when get -ENOSPC ==============="
5023 test_81b() { # LU-456
5024 remote_ost_nodsh && skip "remote OST with nodsh" && return
5025 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
5026 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
5027 do_facet ost1 lctl set_param fail_loc=0x228
5029 # write should retry several times and return -ENOSPC finally
5030 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
5031 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
5034 if [ $RC -ne $ENOSPC ] ; then
5035 error "dd should fail for -ENOSPC, but succeed."
5038 run_test 81b "OST should return -ENOSPC when retry still fails ======="
5040 test_82() { # LU-1031
5041 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10
5045 multiop_bg_pause $DIR/$tfile OG${gid1}_g${gid1}c || return 1
5047 multiop_bg_pause $DIR/$tfile O_G${gid2}r10g${gid2}c || return 2
5049 kill -USR1 $MULTIPID2
5051 if [[ `ps h -o comm -p $MULTIPID2` == "" ]]; then
5052 error "First grouplock does not block second one"
5054 echo "Second grouplock blocks first one"
5056 kill -USR1 $MULTIPID1
5060 run_test 82 "Basic grouplock test ==============================="
5063 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && \
5065 mkdir -p $DIR/d99cvsroot
5066 chown $RUNAS_ID $DIR/d99cvsroot
5067 local oldPWD=$PWD # bug 13584, use $TMP as working dir
5070 $RUNAS cvs -d $DIR/d99cvsroot init || error
5073 run_test 99a "cvs init ========================================="
5076 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5077 [ ! -d $DIR/d99cvsroot ] && test_99a
5079 # some versions of cvs import exit(1) when asked to import links or
5080 # files they can't read. ignore those files.
5081 TOIGNORE=$(find . -type l -printf '-I %f\n' -o \
5082 ! -perm +4 -printf '-I %f\n')
5083 $RUNAS cvs -d $DIR/d99cvsroot import -m "nomesg" $TOIGNORE \
5084 d99reposname vtag rtag
5086 run_test 99b "cvs import ======================================="
5089 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5090 [ ! -d $DIR/d99cvsroot ] && test_99b
5092 mkdir -p $DIR/d99reposname
5093 chown $RUNAS_ID $DIR/d99reposname
5094 $RUNAS cvs -d $DIR/d99cvsroot co d99reposname
5096 run_test 99c "cvs checkout ====================================="
5099 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5100 [ ! -d $DIR/d99cvsroot ] && test_99c
5101 cd $DIR/d99reposname
5103 $RUNAS cvs add -m 'addmsg' foo99
5105 run_test 99d "cvs add =========================================="
5108 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5109 [ ! -d $DIR/d99cvsroot ] && test_99c
5110 cd $DIR/d99reposname
5113 run_test 99e "cvs update ======================================="
5116 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5117 [ ! -d $DIR/d99cvsroot ] && test_99d
5118 cd $DIR/d99reposname
5119 $RUNAS cvs commit -m 'nomsg' foo99
5120 rm -fr $DIR/d99cvsroot
5122 run_test 99f "cvs commit ======================================="
5125 [ "$NETTYPE" = tcp ] || \
5126 { skip "TCP secure port test, not useful for NETTYPE=$NETTYPE" && \
5129 remote_ost_nodsh && skip "remote OST with nodsh" && return
5130 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5132 { skip "useless for local single node setup" && return; }
5134 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
5135 [ "$PROT" != "tcp" ] && continue
5136 RPORT=$(echo $REMOTE | cut -d: -f2)
5137 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
5140 LPORT=`echo $LOCAL | cut -d: -f2`
5141 if [ $LPORT -ge 1024 ]; then
5142 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
5144 error_exit "local: $LPORT > 1024, remote: $RPORT"
5147 [ "$rc" = 0 ] || error_exit "privileged port not found" )
5149 run_test 100 "check local port using privileged port ==========="
5151 function get_named_value()
5160 echo $line | sed "s/^$tag[ ]*//"
5167 export CACHE_MAX=`$LCTL get_param -n llite.*.max_cached_mb | head -n 1`
5169 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
5177 [ "$CPU" = "UML" ] && nreads=1000
5178 local cache_limit=32
5180 $LCTL set_param -n osc.*-osc*.rpc_stats 0
5181 trap cleanup_101a EXIT
5182 $LCTL set_param -n llite.*.read_ahead_stats 0
5183 $LCTL set_param -n llite.*.max_cached_mb $cache_limit
5186 # randomly read 10000 of 64K chunks from file 3x 32MB in size
5188 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
5189 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
5192 for s in `$LCTL get_param -n llite.*.read_ahead_stats | \
5193 get_named_value 'read but discarded' | cut -d" " -f1`; do
5194 discard=$(($discard + $s))
5198 if [ $(($discard * 10)) -gt $nreads ] ;then
5199 $LCTL get_param osc.*-osc*.rpc_stats
5200 $LCTL get_param llite.*.read_ahead_stats
5201 error "too many ($discard) discarded pages"
5203 rm -f $DIR/$tfile || true
5205 run_test 101a "check read-ahead for random reads ================"
5210 STRIPE_COUNT=$OSTCOUNT
5213 local list=$(comma_list $(osts_nodes))
5214 do_nodes $list $LCTL set_param -n obdfilter.*.read_cache_enable=0
5215 do_nodes $list $LCTL set_param -n obdfilter.*.writethrough_cache_enable=0
5217 trap cleanup_test101bc EXIT
5218 # prepare the read-ahead file
5219 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
5221 dd if=/dev/zero of=$DIR/$tfile bs=1024k count=100 2> /dev/null
5224 cleanup_test101bc() {
5229 local list=$(comma_list $(osts_nodes))
5230 do_nodes $list $LCTL set_param -n obdfilter.*.read_cache_enable=1
5231 do_nodes $list $LCTL set_param -n obdfilter.*.writethrough_cache_enable=1
5235 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
5240 local STRIPE_SIZE=1048576
5241 local RA_INC=1048576
5242 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
5243 local FILE_LENGTH=$((64*100))
5244 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
5245 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
5246 DISCARD=`$LCTL get_param -n llite.*.read_ahead_stats | \
5247 get_named_value 'read but discarded' | \
5248 cut -d" " -f1 | calc_total`
5249 if [ $DISCARD -gt $discard_limit ]; then
5250 $LCTL get_param llite.*.read_ahead_stats
5251 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
5253 echo "Read-ahead success for size ${READ_SIZE}"
5258 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping stride IO stride-ahead test" && return
5259 local STRIPE_SIZE=1048576
5260 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
5261 local FILE_LENGTH=$((STRIPE_SIZE*100))
5262 local ITERATION=$((FILE_LENGTH/STRIDE_SIZE))
5263 # prepare the read-ahead file
5265 cancel_lru_locks osc
5266 for BIDX in 2 4 8 16 32 64 128 256
5268 local BSIZE=$((BIDX*4096))
5269 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
5270 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
5271 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
5272 $LCTL set_param -n llite.*.read_ahead_stats 0
5273 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
5274 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
5275 cancel_lru_locks osc
5281 run_test 101b "check stride-io mode read-ahead ================="
5284 local STRIPE_SIZE=1048576
5285 local FILE_LENGTH=$((STRIPE_SIZE*100))
5291 cancel_lru_locks osc
5292 $LCTL set_param osc.*.rpc_stats 0
5293 $READS -f $DIR/$tfile -s$FILE_LENGTH -b65536 -n$nreads -t 180
5294 for osc in $($LCTL get_param -N osc.*); do
5295 if [ "$osc" == "osc.num_refs" ]; then
5299 local lines=$($LCTL get_param -n ${osc}.rpc_stats | wc | awk '{print $1}')
5300 if [ $lines -le 20 ]; then
5304 local rpc4k=$($LCTL get_param -n ${osc}.rpc_stats |
5305 awk '$1 == "1:" { print $2; exit; }')
5306 local rpc8k=$($LCTL get_param -n ${osc}.rpc_stats |
5307 awk '$1 == "2:" { print $2; exit; }')
5308 local rpc16k=$($LCTL get_param -n ${osc}.rpc_stats |
5309 awk '$1 == "4:" { print $2; exit; }')
5310 local rpc32k=$($LCTL get_param -n ${osc}.rpc_stats |
5311 awk '$1 == "8:" { print $2; exit; }')
5313 [ $rpc4k != 0 ] && error "Small 4k read IO ${rpc4k}!"
5314 [ $rpc8k != 0 ] && error "Small 8k read IO ${rpc8k}!"
5315 [ $rpc16k != 0 ] && error "Small 16k read IO ${rpc16k}!"
5316 [ $rpc32k != 0 ] && error "Small 32k read IO ${rpc32k}!"
5317 echo "${osc} rpc check passed!"
5322 run_test 101c "check stripe_size aligned read-ahead ================="
5325 $LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1
5326 $LCTL set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
5330 local file=$DIR/$tfile
5331 local size=${FILESIZE_101c:-500}
5332 local ra_MB=${READAHEAD_MB:-40}
5334 local space=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
5335 [ $space -gt $((size / 1024)) ] ||
5336 { skip "Need free space ${size}M, have $space" && return; }
5338 echo Creating ${size}M test file $file
5339 dd if=/dev/zero of=$file bs=1M count=$size || error "dd failed"
5340 echo Cancel LRU locks on lustre client to flush the client cache
5341 cancel_lru_locks osc
5343 echo Disable read-ahead
5344 local old_READAHEAD=$(set_read_ahead 0)
5346 echo Reading the test file $file with read-ahead disabled
5347 time_ra_OFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$size")
5349 echo Cancel LRU locks on lustre client to flush the client cache
5350 cancel_lru_locks osc
5351 echo Enable read-ahead with ${ra_MB}MB
5352 set_read_ahead $ra_MB
5354 echo Reading the test file $file with read-ahead enabled
5355 time_ra_ON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$size")
5357 echo read-ahead disabled time read $time_ra_OFF
5358 echo read-ahead enabled time read $time_ra_ON
5360 set_read_ahead $old_READAHEAD
5362 wait_delete_completed
5364 [ $time_ra_ON -lt $time_ra_OFF ] ||
5365 error "read-ahead enabled time read (${time_ra_ON}s) is more than
5366 read-ahead disabled time read (${time_ra_OFF}s) filesize ${size}M"
5368 run_test 101d "file read with and without read-ahead enabled ================="
5371 local file=$DIR/$tfile
5376 local space=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
5377 local need_space=$((count * size))
5378 [ $space -gt $need_space ] ||
5379 { skip_env "Need free space $need_space, have $space" && return; }
5381 echo Creating $count ${size}K test files
5382 for ((i = 0; i < $count; i++)); do
5383 dd if=/dev/zero of=${file}_${i} bs=$blksize count=$size 2>/dev/null
5386 echo Cancel LRU locks on lustre client to flush the client cache
5387 cancel_lru_locks osc
5389 echo Reset readahead stats
5390 $LCTL set_param -n llite.*.read_ahead_stats 0
5392 for ((i = 0; i < $count; i++)); do
5393 dd if=${file}_${i} of=/dev/null bs=$blksize count=$size 2>/dev/null
5396 local miss=$($LCTL get_param -n llite.*.read_ahead_stats | \
5397 get_named_value 'misses' | cut -d" " -f1 | calc_total)
5399 for ((i = 0; i < $count; i++)); do
5400 rm -rf ${file}_${i} 2>/dev/null
5403 #10000 means 20% reads are missing in readahead
5404 [ $miss -lt 10000 ] || error "misses too much for small reads"
5406 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
5408 cleanup_test101f() {
5410 $LCTL set_param -n llite.*.max_read_ahead_whole_mb $MAX_WHOLE_MB
5411 rm -rf $DIR/$tfile 2>/dev/null
5415 local file=$DIR/$tfile
5418 MAX_WHOLE_MB=$($LCTL get_param -n llite.*.max_read_ahead_whole_mb)
5419 $LCTL set_param -n llite.*.max_read_ahead_whole_mb 2
5420 dd if=/dev/zero of=${file} bs=2097152 count=1 2>/dev/null
5421 trap cleanup_test101f EXIT
5423 echo Cancel LRU locks on lustre client to flush the client cache
5424 cancel_lru_locks osc
5426 echo Reset readahead stats
5427 $LCTL set_param -n llite.*.read_ahead_stats 0
5428 # Random read in a 2M file, because max_read_ahead_whole_mb = 2M,
5429 # readahead should read in 2M file on second read, so only miss
5431 echo Random 4K reads on 2M file for 1000 times
5432 $READS -f $file -s 2097152 -b 4096 -n $nreads
5434 echo checking missing pages
5435 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
5436 get_named_value 'misses' | cut -d" " -f1 | calc_total)
5438 [ $miss -lt 3 ] || error "misses too much pages!"
5441 run_test 101f "check read-ahead for max_read_ahead_whole_mb"
5445 chown $RUNAS_ID $DIR/$tdir
5448 STRIPE_COUNT=$OSTCOUNT
5449 [ $OSTCOUNT -gt 4 ] && STRIPE_COUNT=4
5451 trap cleanup_test102 EXIT
5453 $1 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
5455 for num in 1 2 3 4; do
5456 for count in $(seq 1 $STRIPE_COUNT); do
5457 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
5458 local size=`expr $STRIPE_SIZE \* $num`
5459 local file=file"$num-$idx-$count"
5460 $1 $SETSTRIPE -S $size -i $idx -c $count $file
5466 $1 $TAR cf $TMP/f102.tar $tdir --xattrs
5472 rm -rf $DIR/d0.sanity/d102
5476 local testfile=$DIR/xattr_testfile
5480 [ "$UID" != 0 ] && skip_env "must run as root" && return
5481 [ -z "`lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr`" ] &&
5482 skip_env "must have user_xattr" && return
5484 [ -z "$(which setfattr 2>/dev/null)" ] &&
5485 skip_env "could not find setfattr" && return
5487 echo "set/get xattr..."
5488 setfattr -n trusted.name1 -v value1 $testfile || error
5489 getfattr -n trusted.name1 $testfile 2> /dev/null |
5490 grep "trusted.name1=.value1" ||
5491 error "$testfile missing trusted.name1=value1"
5493 setfattr -n user.author1 -v author1 $testfile || error
5494 getfattr -n user.author1 $testfile 2> /dev/null |
5495 grep "user.author1=.author1" ||
5496 error "$testfile missing trusted.author1=author1"
5499 setfattr -n trusted.name2 -v value2 $testfile ||
5500 error "$testfile unable to set trusted.name2"
5501 setfattr -n trusted.name3 -v value3 $testfile ||
5502 error "$testfile unable to set trusted.name3"
5503 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
5504 grep "trusted.name" | wc -l) -eq 3 ] ||
5505 error "$testfile missing 3 trusted.name xattrs"
5507 setfattr -n user.author2 -v author2 $testfile ||
5508 error "$testfile unable to set user.author2"
5509 setfattr -n user.author3 -v author3 $testfile ||
5510 error "$testfile unable to set user.author3"
5511 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
5512 grep "user.author" | wc -l) -eq 3 ] ||
5513 error "$testfile missing 3 user.author xattrs"
5515 echo "remove xattr..."
5516 setfattr -x trusted.name1 $testfile ||
5517 error "$testfile error deleting trusted.name1"
5518 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
5519 error "$testfile did not delete trusted.name1 xattr"
5521 setfattr -x user.author1 $testfile ||
5522 error "$testfile error deleting user.author1"
5523 getfattr -d -m user $testfile 2> /dev/null | grep "user.author1" &&
5524 error "$testfile did not delete trusted.name1 xattr"
5526 # b10667: setting lustre special xattr be silently discarded
5527 echo "set lustre special xattr ..."
5528 setfattr -n "trusted.lov" -v "invalid value" $testfile ||
5529 error "$testfile allowed setting trusted.lov"
5531 run_test 102a "user xattr test =================================="
5534 # b10930: get/set/list trusted.lov xattr
5535 echo "get/set/list trusted.lov xattr ..."
5536 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
5537 local testfile=$DIR/$tfile
5538 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
5539 error "setstripe failed"
5540 local STRIPECOUNT=$($GETSTRIPE -c $testfile) ||
5541 error "getstripe failed"
5542 getfattr -d -m "^trusted" $testfile 2> /dev/null | \
5543 grep "trusted.lov" || error "can't get trusted.lov from $testfile"
5545 local testfile2=${testfile}2
5546 local value=`getfattr -n trusted.lov $testfile 2> /dev/null | \
5547 grep "trusted.lov" |sed -e 's/[^=]\+=//'`
5550 setfattr -n trusted.lov -v $value $testfile2
5551 local stripe_size=$($GETSTRIPE -S $testfile2)
5552 local stripe_count=$($GETSTRIPE -c $testfile2)
5553 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
5554 [ $stripe_count -eq $STRIPECOUNT ] ||
5555 error "stripe count $stripe_count != $STRIPECOUNT"
5558 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
5561 # b10930: get/set/list lustre.lov xattr
5562 echo "get/set/list lustre.lov xattr ..."
5563 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
5565 chown $RUNAS_ID $DIR/$tdir
5566 local testfile=$DIR/$tdir/$tfile
5567 $RUNAS $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
5568 error "setstripe failed"
5569 local STRIPECOUNT=$($RUNAS $GETSTRIPE -c $testfile) ||
5570 error "getstripe failed"
5571 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
5572 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
5574 local testfile2=${testfile}2
5575 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
5576 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
5578 $RUNAS $MCREATE $testfile2
5579 $RUNAS setfattr -n lustre.lov -v $value $testfile2
5580 local stripe_size=$($RUNAS $GETSTRIPE -S $testfile2)
5581 local stripe_count=$($RUNAS $GETSTRIPE -c $testfile2)
5582 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
5583 [ $stripe_count -eq $STRIPECOUNT ] ||
5584 error "stripe count $stripe_count != $STRIPECOUNT"
5586 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
5588 compare_stripe_info1() {
5589 local stripe_index_all_zero=true
5591 for num in 1 2 3 4; do
5592 for count in $(seq 1 $STRIPE_COUNT); do
5593 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
5594 local size=$((STRIPE_SIZE * num))
5595 local file=file"$num-$offset-$count"
5596 stripe_size=$(lfs getstripe -S $PWD/$file)
5597 [ $stripe_size -ne $size ] &&
5598 error "$file: size $stripe_size != $size"
5599 stripe_count=$(lfs getstripe -c $PWD/$file)
5600 # allow fewer stripes to be created, ORI-601
5601 [ $stripe_count -lt $(((3 * count + 3) / 4)) ]&&
5602 error "$file: count $stripe_count != $count"
5603 stripe_index=$(lfs getstripe -i $PWD/$file)
5604 [ $stripe_index -ne 0 ] &&
5605 stripe_index_all_zero=false
5609 $stripe_index_all_zero &&
5610 error "all files are being extracted starting from OST index 0"
5615 [ -n "$(which tar 2>/dev/null)" ] &&
5616 strings $(which tar) | grep -q "lustre" && echo tar
5620 # b10930: tar test for trusted.lov xattr
5621 TAR=$(find_lustre_tar)
5622 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
5623 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
5626 $TAR xf $TMP/f102.tar -C $DIR/d102d --xattrs
5628 compare_stripe_info1
5630 run_test 102d "tar restore stripe info from tarfile,not keep osts ==========="
5633 # b10930: tar test for trusted.lov xattr
5634 TAR=$(find_lustre_tar)
5635 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
5636 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
5640 $TAR cf - --xattrs $tdir | $TAR xf - --xattrs -C $DIR/d102f
5642 compare_stripe_info1
5644 run_test 102f "tar copy files, not keep osts ==========="
5647 local xsize=${1:-1024} # in bytes
5648 local file=$DIR/$tfile
5650 [ -z $(lctl get_param -n mdc.*.connect_flags | grep xattr) ] &&
5651 skip "must have user_xattr" && return 0
5652 [ -z "$(which setfattr 2>/dev/null)" ] &&
5653 skip_env "could not find setfattr" && return 0
5654 [ -z "$(which getfattr 2>/dev/null)" ] &&
5655 skip_env "could not find getfattr" && return 0
5659 local value="$(generate_string $xsize)"
5661 local xbig=trusted.big
5662 log "save $xbig on $file"
5663 setfattr -n $xbig -v $value $file ||
5664 error "saving $xbig on $file failed"
5666 local orig=$(get_xattr_value $xbig $file)
5667 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
5669 local xsml=trusted.sml
5670 log "save $xsml on $file"
5671 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
5673 local new=$(get_xattr_value $xbig $file)
5674 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
5676 log "grow $xsml on $file"
5677 setfattr -n $xsml -v "$value" $file ||
5678 error "growing $xsml on $file failed"
5680 new=$(get_xattr_value $xbig $file)
5681 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
5682 log "$xbig still valid after growing $xsml"
5687 test_102h() { # bug 15777
5690 run_test 102h "grow xattr from inside inode to external block"
5693 large_xattr_enabled || { skip "large_xattr disabled" && return; }
5694 grow_xattr $(max_xattr_size)
5696 run_test 102ha "grow xattr from inside inode to external inode"
5698 test_102i() { # bug 17038
5700 ln -s $DIR/$tfile $DIR/${tfile}link
5701 getfattr -n trusted.lov $DIR/$tfile || error "lgetxattr on $DIR/$tfile failed"
5702 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"
5703 rm -f $DIR/$tfile $DIR/${tfile}link
5705 run_test 102i "lgetxattr test on symbolic link ============"
5708 TAR=$(find_lustre_tar)
5709 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
5710 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
5711 setup_test102 "$RUNAS"
5713 chown $RUNAS_ID $DIR/d102j
5714 $RUNAS $TAR xf $TMP/f102.tar -C $DIR/d102j --xattrs
5716 compare_stripe_info1 "$RUNAS"
5718 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
5722 # b22187 just check that does not crash for regular file.
5723 setfattr -n trusted.lov $DIR/$tfile
5724 # b22187 'setfattr -n trusted.lov' should work as remove LOV EA for directories
5725 local test_kdir=$DIR/d102k
5727 local default_size=`$GETSTRIPE -S $test_kdir`
5728 local default_count=`$GETSTRIPE -c $test_kdir`
5729 local default_offset=`$GETSTRIPE -i $test_kdir`
5730 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $test_kdir ||
5731 error 'dir setstripe failed'
5732 setfattr -n trusted.lov $test_kdir
5733 local stripe_size=`$GETSTRIPE -S $test_kdir`
5734 local stripe_count=`$GETSTRIPE -c $test_kdir`
5735 local stripe_offset=`$GETSTRIPE -i $test_kdir`
5736 [ $stripe_size -eq $default_size ] ||
5737 error "stripe size $stripe_size != $default_size"
5738 [ $stripe_count -eq $default_count ] ||
5739 error "stripe count $stripe_count != $default_count"
5740 [ $stripe_offset -eq $default_offset ] ||
5741 error "stripe offset $stripe_offset != $default_offset"
5742 rm -rf $DIR/$tfile $test_kdir
5744 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
5747 # LU-532 trusted. xattr is invisible to non-root
5748 local testfile=$DIR/$tfile
5752 echo "listxattr as user..."
5753 chown $RUNAS_ID $testfile
5754 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
5755 grep -q "trusted" &&
5756 error "$testfile trusted xattrs are user visible"
5760 run_test 102l "listxattr filter test =================================="
5766 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
5771 [ "$UID" != 0 ] && skip_env "must run as root" && return
5772 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
5773 [ -z "$(which setfacl 2>/dev/null)" ] && skip_env "could not find setfacl" && return
5774 $GSS && skip "could not run under gss" && return
5776 declare -a identity_old
5778 for num in `seq $MDSCOUNT`; do
5779 switch_identity $num true || identity_old[$num]=$?
5786 echo "performing cp ..."
5787 run_acl_subtest cp || error
5788 echo "performing getfacl-noacl..."
5789 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
5790 echo "performing misc..."
5791 run_acl_subtest misc || error "misc test failed"
5792 echo "performing permissions..."
5793 run_acl_subtest permissions || error "permissions failed"
5794 echo "performing setfacl..."
5795 run_acl_subtest setfacl || error "setfacl test failed"
5797 # inheritance test got from HP
5798 echo "performing inheritance..."
5799 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
5800 chmod +x make-tree || error "chmod +x failed"
5801 run_acl_subtest inheritance || error "inheritance test failed"
5807 for num in `seq $MDSCOUNT`; do
5808 if [ "${identity_old[$num]}" = 1 ]; then
5809 switch_identity $num false || identity_old[$num]=$?
5813 run_test 103 "acl test ========================================="
5817 lfs df || error "lfs df failed"
5818 lfs df -ih || error "lfs df -ih failed"
5819 lfs df -h $DIR || error "lfs df -h $DIR failed"
5820 lfs df -i $DIR || error "lfs df -i $DIR failed"
5821 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
5822 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
5824 OSC=`lctl dl |grep OST0000-osc-[^M] |awk '{print $4}'`
5825 lctl --device %$OSC deactivate
5826 lfs df || error "lfs df with deactivated OSC failed"
5827 lctl --device %$OSC activate
5828 # wait the osc back to normal
5829 wait_osc_import_state client ost FULL
5831 lfs df || error "lfs df with reactivated OSC failed"
5834 run_test 104a "lfs df [-ih] [path] test ========================="
5837 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5839 denied_cnt=$((`$RUNAS $LFS check servers 2>&1 | grep "Permission denied" | wc -l`))
5840 if [ $denied_cnt -ne 0 ];
5842 error "lfs check servers test failed"
5845 run_test 104b "$RUNAS lfs check servers test ===================="
5848 # doesn't work on 2.4 kernels
5850 if [ -n "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ];
5852 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
5854 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
5858 run_test 105a "flock when mounted without -o flock test ========"
5862 if [ -n "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ];
5864 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
5866 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
5870 run_test 105b "fcntl when mounted without -o flock test ========"
5874 if [ -n "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ];
5876 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
5878 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
5882 run_test 105c "lockf when mounted without -o flock test ========"
5884 test_105d() { # bug 15924
5886 [ -z "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ] && \
5887 skip "mount w/o flock enabled" && return
5888 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
5889 $LCTL set_param fail_loc=0x80000315
5890 flocks_test 2 $DIR/$tdir
5892 run_test 105d "flock race (should not freeze) ========"
5894 test_105e() { # bug 22660 && 22040
5895 [ -z "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ] && \
5896 skip "mount w/o flock enabled" && return
5898 flocks_test 3 $DIR/$tfile
5900 run_test 105e "Two conflicting flocks from same process ======="
5902 test_106() { #bug 10921
5904 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
5905 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
5907 run_test 106 "attempt exec of dir followed by chown of that dir"
5916 local save_pattern=$(sysctl -n kernel.core_pattern)
5917 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
5918 sysctl -w kernel.core_pattern=$file
5919 sysctl -w kernel.core_uses_pid=0
5927 kill -s 11 $SLEEPPID
5929 if [ -e $file ]; then
5930 size=`stat -c%s $file`
5931 [ $size -eq 0 ] && error "Fail to create core file $file"
5933 error "Fail to create core file $file"
5936 sysctl -w kernel.core_pattern=$save_pattern
5937 sysctl -w kernel.core_uses_pid=$save_uses_pid
5940 run_test 107 "Coredump on SIG"
5944 mkdir $DIR/$tdir/$(str_repeat 'a' 255) ||
5945 error "mkdir with 255 char failed"
5946 mkdir $DIR/$tdir/$(str_repeat 'b' 256) &&
5947 error "mkdir with 256 char should fail, but did not"
5948 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
5949 error "create with 255 char failed"
5950 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
5951 error "create with 256 char should fail, but did not"
5956 run_test 110 "filename length checking"
5959 OSTIO_pre=$(ps -e|grep ll_ost_io|awk '{print $4}'|sort -n|tail -1|\
5961 [ -z "$OSTIO_pre" ] && skip "no OSS threads" && \
5963 echo "Starting with $OSTIO_pre threads"
5966 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
5967 [ $NUMFREE -lt $NUMTEST ] && NUMTEST=$(($NUMFREE - 1000))
5968 echo "$NUMTEST creates/unlinks"
5970 createmany -o $DIR/$tdir/$tfile $NUMTEST
5971 unlinkmany $DIR/$tdir/$tfile $NUMTEST
5973 OSTIO_post=$(ps -e|grep ll_ost_io|awk '{print $4}'|sort -n|tail -1|\
5976 # don't return an error
5977 [ $OSTIO_post == $OSTIO_pre ] && echo \
5978 "WARNING: No new ll_ost_io threads were created ($OSTIO_pre)" &&
5979 echo "This may be fine, depending on what ran before this test" &&
5980 echo "and how fast this system is." && return
5982 echo "Started with $OSTIO_pre threads, ended with $OSTIO_post"
5984 run_test 115 "verify dynamic thread creation===================="
5987 wait_delete_completed
5988 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
5989 echo OST kbytes available: ${AVAIL[@]}
5990 MAXI=0; MAXV=${AVAIL[0]}
5991 MINI=0; MINV=${AVAIL[0]}
5992 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
5993 #echo OST $i: ${AVAIL[i]}kb
5994 if [ ${AVAIL[i]} -gt $MAXV ]; then
5995 MAXV=${AVAIL[i]}; MAXI=$i
5997 if [ ${AVAIL[i]} -lt $MINV ]; then
5998 MINV=${AVAIL[i]}; MINI=$i
6001 echo Min free space: OST $MINI: $MINV
6002 echo Max free space: OST $MAXI: $MAXV
6005 test_116a() { # was previously test_116()
6006 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs" && return
6008 echo -n "Free space priority "
6009 lctl get_param -n lov.*-clilov-*.qos_prio_free
6012 [ $MINV -gt 960000 ] && skip "too much free space in OST$MINI, skip" &&\
6015 # generate uneven OSTs
6016 mkdir -p $DIR/$tdir/OST${MINI}
6019 echo "Filling 25% remaining space in OST${MINI} with ${FILL}Kb"
6020 $SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI}||error "setstripe failed"
6022 while [ $FILL -gt 0 ]; do
6024 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i bs=2M count=1 2>/dev/null
6025 FILL=$(($FILL - 2048))
6033 DIFF=$(($MAXV - $MINV))
6034 DIFF2=$(($DIFF * 100 / $MINV))
6035 echo -n "diff=${DIFF}=${DIFF2}% must be > 20% for QOS mode..."
6036 if [ $DIFF2 -gt 20 ]; then
6039 echo "failed - QOS mode won't be used"
6040 error_ignore "QOS imbalance criteria not met"
6044 MINI1=$MINI; MINV1=$MINV
6045 MAXI1=$MAXI; MAXV1=$MAXV
6047 # now fill using QOS
6048 echo writing a bunch of files to QOS-assigned OSTs
6049 $SETSTRIPE -c 1 $DIR/$tdir
6051 while [ $FILL -gt 0 ]; do
6053 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1024 count=200 2>/dev/null
6054 FILL=$(($FILL - 200))
6057 echo "wrote $i 200k files"
6061 echo "Note: free space may not be updated, so measurements might be off"
6063 DIFF2=$(($MAXV - $MINV))
6064 echo "free space delta: orig $DIFF final $DIFF2"
6065 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
6066 DIFF=$(($MINV1 - ${AVAIL[$MINI1]}))
6067 echo "Wrote $DIFF to smaller OST $MINI1"
6068 DIFF2=$(($MAXV1 - ${AVAIL[$MAXI1]}))
6069 echo "Wrote $DIFF2 to larger OST $MAXI1"
6070 [ $DIFF -gt 0 ] && echo "Wrote $(($DIFF2 * 100 / $DIFF - 100))% more data to larger OST $MAXI1"
6072 # Figure out which files were written where
6073 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
6074 awk '/'$MINI1': / {print $2; exit}')
6076 MINC=$($GETSTRIPE --obd $UUID $DIR/$tdir | wc -l)
6077 echo "$MINC files created on smaller OST $MINI1"
6078 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
6079 awk '/'$MAXI1': / {print $2; exit}')
6081 MAXC=$($GETSTRIPE --obd $UUID $DIR/$tdir | wc -l)
6082 echo "$MAXC files created on larger OST $MAXI1"
6083 [ $MINC -gt 0 ] && echo "Wrote $(($MAXC * 100 / $MINC - 100))% more files to larger OST $MAXI1"
6084 [ $MAXC -gt $MINC ] || error_ignore "stripe QOS didn't balance free space"
6088 run_test 116a "stripe QOS: free space balance ==================="
6090 test_116b() { # LU-2093
6091 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
6093 old_rr=$(do_facet $SINGLEMDS lctl get_param -n lov.*mdtlov*.qos_threshold_rr)
6094 do_facet $SINGLEMDS lctl set_param lov.*mdtlov*.qos_threshold_rr 0
6096 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
6097 createmany -o $DIR/$tdir/f- 20 || error "can't create"
6098 do_facet $SINGLEMDS lctl set_param fail_loc=0
6100 do_facet $SINGLEMDS lctl set_param lov.*mdtlov*.qos_threshold_rr $old_rr
6102 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
6104 test_117() # bug 10891
6106 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
6107 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
6108 lctl set_param fail_loc=0x21e
6109 > $DIR/$tfile || error "truncate failed"
6110 lctl set_param fail_loc=0
6111 echo "Truncate succeeded."
6114 run_test 117 "verify fsfilt_extend =========="
6116 export OLD_RESENDCOUNT=""
6117 set_resend_count () {
6118 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
6119 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -1)
6120 lctl set_param -n $PROC_RESENDCOUNT $1
6121 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
6124 [ "$SLOW" = "no" ] && set_resend_count 4 # for reduce test_118* time (bug 14842)
6126 # Reset async IO behavior after error case
6128 FILE=$DIR/reset_async
6130 # Ensure all OSCs are cleared
6131 $SETSTRIPE -c -1 $FILE
6132 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
6137 test_118a() #bug 11710
6141 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6142 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6143 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
6145 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6146 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6151 run_test 118a "verify O_SYNC works =========="
6155 remote_ost_nodsh && skip "remote OST with nodsh" && return
6159 #define OBD_FAIL_OST_ENOENT 0x217
6160 set_nodes_failloc "$(osts_nodes)" 0x217
6161 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6163 set_nodes_failloc "$(osts_nodes)" 0
6164 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6165 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6168 if [[ $RC -eq 0 ]]; then
6169 error "Must return error due to dropped pages, rc=$RC"
6173 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6174 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6178 echo "Dirty pages not leaked on ENOENT"
6180 # Due to the above error the OSC will issue all RPCs syncronously
6181 # until a subsequent RPC completes successfully without error.
6182 $MULTIOP $DIR/$tfile Ow4096yc
6187 run_test 118b "Reclaim dirty pages on fatal error =========="
6191 remote_ost_nodsh && skip "remote OST with nodsh" && return
6195 #define OBD_FAIL_OST_EROFS 0x216
6196 set_nodes_failloc "$(osts_nodes)" 0x216
6198 # multiop should block due to fsync until pages are written
6199 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
6203 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
6204 error "Multiop failed to block on fsync, pid=$MULTIPID"
6207 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6209 if [[ $WRITEBACK -eq 0 ]]; then
6210 error "No page in writeback, writeback=$WRITEBACK"
6213 set_nodes_failloc "$(osts_nodes)" 0
6216 if [[ $RC -ne 0 ]]; then
6217 error "Multiop fsync failed, rc=$RC"
6220 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6221 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6223 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6224 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6228 echo "Dirty pages flushed via fsync on EROFS"
6231 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
6235 remote_ost_nodsh && skip "remote OST with nodsh" && return
6239 #define OBD_FAIL_OST_BRW_PAUSE_BULK
6240 set_nodes_failloc "$(osts_nodes)" 0x214
6241 # multiop should block due to fsync until pages are written
6242 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
6246 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
6247 error "Multiop failed to block on fsync, pid=$MULTIPID"
6250 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6252 if [[ $WRITEBACK -eq 0 ]]; then
6253 error "No page in writeback, writeback=$WRITEBACK"
6256 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
6257 set_nodes_failloc "$(osts_nodes)" 0
6259 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6260 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6262 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6263 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6267 echo "Dirty pages gaurenteed flushed via fsync"
6270 run_test 118d "Fsync validation inject a delay of the bulk =========="
6275 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
6276 lctl set_param fail_loc=0x8000040a
6278 # Should simulate EINVAL error which is fatal
6279 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6281 if [[ $RC -eq 0 ]]; then
6282 error "Must return error due to dropped pages, rc=$RC"
6285 lctl set_param fail_loc=0x0
6287 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6288 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6289 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6291 if [[ $LOCKED -ne 0 ]]; then
6292 error "Locked pages remain in cache, locked=$LOCKED"
6295 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6296 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6300 echo "No pages locked after fsync"
6305 run_test 118f "Simulate unrecoverable OSC side error =========="
6310 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
6311 lctl set_param fail_loc=0x406
6313 # simulate local -ENOMEM
6314 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6317 lctl set_param fail_loc=0
6318 if [[ $RC -eq 0 ]]; then
6319 error "Must return error due to dropped pages, rc=$RC"
6322 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6323 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6324 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6326 if [[ $LOCKED -ne 0 ]]; then
6327 error "Locked pages remain in cache, locked=$LOCKED"
6330 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6331 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6335 echo "No pages locked after fsync"
6340 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
6343 remote_ost_nodsh && skip "remote OST with nodsh" && return
6347 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
6348 set_nodes_failloc "$(osts_nodes)" 0x20e
6349 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
6350 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6353 set_nodes_failloc "$(osts_nodes)" 0
6354 if [[ $RC -eq 0 ]]; then
6355 error "Must return error due to dropped pages, rc=$RC"
6358 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6359 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6360 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6362 if [[ $LOCKED -ne 0 ]]; then
6363 error "Locked pages remain in cache, locked=$LOCKED"
6366 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6367 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6371 echo "No pages locked after fsync"
6375 run_test 118h "Verify timeout in handling recoverables errors =========="
6377 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
6380 remote_ost_nodsh && skip "remote OST with nodsh" && return
6384 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
6385 set_nodes_failloc "$(osts_nodes)" 0x20e
6387 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
6388 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
6391 set_nodes_failloc "$(osts_nodes)" 0
6395 if [[ $RC -ne 0 ]]; then
6396 error "got error, but should be not, rc=$RC"
6399 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6400 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6401 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
6402 if [[ $LOCKED -ne 0 ]]; then
6403 error "Locked pages remain in cache, locked=$LOCKED"
6406 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6407 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6411 echo "No pages locked after fsync"
6415 run_test 118i "Fix error before timeout in recoverable error =========="
6417 [ "$SLOW" = "no" ] && set_resend_count 4
6420 remote_ost_nodsh && skip "remote OST with nodsh" && return
6424 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
6425 set_nodes_failloc "$(osts_nodes)" 0x220
6427 # return -EIO from OST
6428 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6430 set_nodes_failloc "$(osts_nodes)" 0x0
6431 if [[ $RC -eq 0 ]]; then
6432 error "Must return error due to dropped pages, rc=$RC"
6435 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6436 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6437 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
6438 if [[ $LOCKED -ne 0 ]]; then
6439 error "Locked pages remain in cache, locked=$LOCKED"
6442 # in recoverable error on OST we want resend and stay until it finished
6443 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6444 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6448 echo "No pages locked after fsync"
6452 run_test 118j "Simulate unrecoverable OST side error =========="
6456 remote_ost_nodsh && skip "remote OSTs with nodsh" && return
6458 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
6459 set_nodes_failloc "$(osts_nodes)" 0x20e
6462 for ((i=0;i<10;i++)); do
6463 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
6464 error "dd to $DIR/$tdir/$tfile-$i failed" )&
6471 set_nodes_failloc "$(osts_nodes)" 0
6474 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
6480 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
6483 run_test 118l "fsync dir ========="
6485 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
6487 test_119a() # bug 11737
6489 BSIZE=$((512 * 1024))
6490 directio write $DIR/$tfile 0 1 $BSIZE
6491 # We ask to read two blocks, which is more than a file size.
6492 # directio will indicate an error when requested and actual
6493 # sizes aren't equeal (a normal situation in this case) and
6494 # print actual read amount.
6495 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
6496 if [ "$NOB" != "$BSIZE" ]; then
6497 error "read $NOB bytes instead of $BSIZE"
6501 run_test 119a "Short directIO read must return actual read amount"
6503 test_119b() # bug 11737
6505 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
6507 $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
6508 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
6510 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) || \
6511 error "direct read failed"
6514 run_test 119b "Sparse directIO read must return actual read amount"
6516 test_119c() # bug 13099
6519 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
6520 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
6523 run_test 119c "Testing for direct read hitting hole"
6525 test_119d() # bug 15950
6527 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
6528 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
6530 $SETSTRIPE $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
6531 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
6532 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
6533 lctl set_param fail_loc=0x40d
6534 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
6537 cat $DIR/$tfile > /dev/null &
6538 lctl set_param fail_loc=0
6541 log "the DIO writes have completed, now wait for the reads (should not block very long)"
6543 [ -n "`ps h -p $pid_reads -o comm`" ] && \
6544 error "the read rpcs have not completed in 2s"
6546 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
6548 run_test 119d "The DIO path should try to send a new rpc once one is completed"
6552 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6553 skip "no early lock cancel on server" && return 0
6554 lru_resize_disable mdc
6555 lru_resize_disable osc
6556 cancel_lru_locks mdc
6557 stat $DIR/$tdir > /dev/null
6558 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6559 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6561 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6562 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6563 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6564 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6565 lru_resize_enable mdc
6566 lru_resize_enable osc
6568 run_test 120a "Early Lock Cancel: mkdir test"
6572 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6573 skip "no early lock cancel on server" && return 0
6574 lru_resize_disable mdc
6575 lru_resize_disable osc
6576 cancel_lru_locks mdc
6577 stat $DIR/$tdir > /dev/null
6578 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6579 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6581 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6582 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6583 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6584 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6585 lru_resize_enable mdc
6586 lru_resize_enable osc
6588 run_test 120b "Early Lock Cancel: create test"
6592 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6593 skip "no early lock cancel on server" && return 0
6594 lru_resize_disable mdc
6595 lru_resize_disable osc
6596 mkdir -p $DIR/$tdir/d1 $DIR/$tdir/d2
6597 touch $DIR/$tdir/d1/f1
6598 cancel_lru_locks mdc
6599 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
6600 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6601 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6602 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
6603 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6604 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6605 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6606 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6607 lru_resize_enable mdc
6608 lru_resize_enable osc
6610 run_test 120c "Early Lock Cancel: link test"
6614 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6615 skip "no early lock cancel on server" && return 0
6616 lru_resize_disable mdc
6617 lru_resize_disable osc
6619 cancel_lru_locks mdc
6620 stat $DIR/$tdir > /dev/null
6621 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6622 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6623 chmod a+x $DIR/$tdir
6624 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6625 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6626 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6627 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6628 lru_resize_enable mdc
6629 lru_resize_enable osc
6631 run_test 120d "Early Lock Cancel: setattr test"
6635 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6636 skip "no early lock cancel on server" && return 0
6637 lru_resize_disable mdc
6638 lru_resize_disable osc
6639 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
6640 cancel_lru_locks mdc
6641 cancel_lru_locks osc
6642 dd if=$DIR/$tdir/f1 of=/dev/null
6643 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
6644 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6645 awk '/ldlm_cancel/ {print $2}'`
6646 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6647 awk '/ldlm_bl_callback/ {print $2}'`
6648 unlink $DIR/$tdir/f1
6649 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6650 awk '/ldlm_cancel/ {print $2}'`
6651 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6652 awk '/ldlm_bl_callback/ {print $2}'`
6653 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6654 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6655 lru_resize_enable mdc
6656 lru_resize_enable osc
6658 run_test 120e "Early Lock Cancel: unlink test"
6661 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6662 skip "no early lock cancel on server" && return 0
6664 lru_resize_disable mdc
6665 lru_resize_disable osc
6666 mkdir -p $DIR/$tdir/d1 $DIR/$tdir/d2
6667 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
6668 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
6669 cancel_lru_locks mdc
6670 cancel_lru_locks osc
6671 dd if=$DIR/$tdir/d1/f1 of=/dev/null
6672 dd if=$DIR/$tdir/d2/f2 of=/dev/null
6673 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
6674 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6675 awk '/ldlm_cancel/ {print $2}'`
6676 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6677 awk '/ldlm_bl_callback/ {print $2}'`
6678 mv $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
6679 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6680 awk '/ldlm_cancel/ {print $2}'`
6681 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6682 awk '/ldlm_bl_callback/ {print $2}'`
6683 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6684 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6685 lru_resize_enable mdc
6686 lru_resize_enable osc
6688 run_test 120f "Early Lock Cancel: rename test"
6691 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6692 skip "no early lock cancel on server" && return 0
6693 lru_resize_disable mdc
6694 lru_resize_disable osc
6696 echo create $count files
6698 cancel_lru_locks mdc
6699 cancel_lru_locks osc
6702 can0=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6703 awk '/ldlm_cancel/ {print $2}'`
6704 blk0=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6705 awk '/ldlm_bl_callback/ {print $2}'`
6706 createmany -o $DIR/$tdir/f $count
6708 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6709 awk '/ldlm_cancel/ {print $2}'`
6710 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6711 awk '/ldlm_bl_callback/ {print $2}'`
6713 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
6714 echo rm $count files
6717 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6718 awk '/ldlm_cancel/ {print $2}'`
6719 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6720 awk '/ldlm_bl_callback/ {print $2}'`
6722 echo total: $count removes in $((t2-t1))
6723 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
6725 # wait for commitment of removal
6726 lru_resize_enable mdc
6727 lru_resize_enable osc
6729 run_test 120g "Early Lock Cancel: performance test"
6731 test_121() { #bug #10589
6733 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
6734 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
6735 lctl set_param fail_loc=0x310
6736 cancel_lru_locks osc > /dev/null
6737 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
6738 lctl set_param fail_loc=0
6739 [ "$reads" -eq "$writes" ] || error "read" $reads "blocks, must be" $writes
6741 run_test 121 "read cancel race ========="
6743 test_123a() { # was test 123, statahead(bug 11401)
6745 if [ -z "$(grep "processor.*: 1" /proc/cpuinfo)" ]; then
6746 log "testing on UP system. Performance may be not as good as expected."
6752 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
6753 [ $NUMFREE -gt 100000 ] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
6755 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
6756 createmany -o $DIR/$tdir/$tfile $j $((i - j))
6758 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
6759 lctl set_param -n llite.*.statahead_max 0
6760 lctl get_param llite.*.statahead_max
6761 cancel_lru_locks mdc
6762 cancel_lru_locks osc
6764 time ls -l $DIR/$tdir | wc -l
6766 delta=$((etime - stime))
6767 log "ls $i files without statahead: $delta sec"
6768 lctl set_param llite.*.statahead_max=$max
6770 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
6771 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
6772 cancel_lru_locks mdc
6773 cancel_lru_locks osc
6775 time ls -l $DIR/$tdir | wc -l
6777 delta_sa=$((etime - stime))
6778 log "ls $i files with statahead: $delta_sa sec"
6779 lctl get_param -n llite.*.statahead_stats
6780 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
6782 [ $swrong -lt $ewrong ] && log "statahead was stopped, maybe too many locks held!"
6783 [ $delta -eq 0 -o $delta_sa -eq 0 ] && continue
6785 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
6786 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
6787 lctl set_param -n llite.*.statahead_max 0
6788 lctl get_param llite.*.statahead_max
6789 cancel_lru_locks mdc
6790 cancel_lru_locks osc
6792 time ls -l $DIR/$tdir | wc -l
6794 delta=$((etime - stime))
6795 log "ls $i files again without statahead: $delta sec"
6796 lctl set_param llite.*.statahead_max=$max
6797 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
6798 if [ $SLOWOK -eq 0 ]; then
6799 error "ls $i files is slower with statahead!"
6801 log "ls $i files is slower with statahead!"
6807 [ $delta -gt 20 ] && break
6808 [ $delta -gt 8 ] && MULT=$((50 / delta))
6809 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
6817 delta=$((etime - stime))
6818 log "rm -r $DIR/$tdir/: $delta seconds"
6820 lctl get_param -n llite.*.statahead_stats
6822 run_test 123a "verify statahead work"
6824 test_123b () { # statahead(bug 15027)
6826 createmany -o $DIR/$tdir/$tfile-%d 1000
6828 cancel_lru_locks mdc
6829 cancel_lru_locks osc
6831 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
6832 lctl set_param fail_loc=0x80000803
6833 ls -lR $DIR/$tdir > /dev/null
6835 lctl set_param fail_loc=0x0
6836 lctl get_param -n llite.*.statahead_stats
6841 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
6844 [ -z "`lctl get_param -n mdc.*.connect_flags | grep lru_resize`" ] && \
6845 skip "no lru resize on server" && return 0
6847 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
6849 log "create $NR files at $DIR/$tdir"
6850 createmany -o $DIR/$tdir/f $NR ||
6851 error "failed to create $NR files in $DIR/$tdir"
6853 cancel_lru_locks mdc
6854 ls -l $DIR/$tdir > /dev/null
6858 for VALUE in `lctl get_param ldlm.namespaces.*mdc-*.lru_size`; do
6859 local PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
6860 LRU_SIZE=$(lctl get_param -n $PARAM)
6861 if [ $LRU_SIZE -gt $(default_lru_size) ]; then
6862 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
6864 log "NS=$(basename $NSDIR)"
6869 if [ -z "$NSDIR" -o $LRU_SIZE -lt $(default_lru_size) ]; then
6870 skip "Not enough cached locks created!"
6877 # We know that lru resize allows one client to hold $LIMIT locks
6878 # for 10h. After that locks begin to be killed by client.
6880 local LIMIT=`lctl get_param -n $NSDIR.pool.limit`
6883 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
6884 # killing locks. Some time was spent for creating locks. This means
6885 # that up to the moment of sleep finish we must have killed some of
6886 # them (10-100 locks). This depends on how fast ther were created.
6887 # Many of them were touched in almost the same moment and thus will
6888 # be killed in groups.
6889 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
6891 # Use $LRU_SIZE_B here to take into account real number of locks
6892 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
6893 local LRU_SIZE_B=$LRU_SIZE
6895 local OLD_LVF=`lctl get_param -n $NSDIR.pool.lock_volume_factor`
6896 log "OLD_LVF=$OLD_LVF"
6897 lctl set_param -n $NSDIR.pool.lock_volume_factor $LVF
6899 # Let's make sure that we really have some margin. Client checks
6900 # cached locks every 10 sec.
6902 log "Sleep ${SLEEP} sec"
6904 while ((SEC<$SLEEP)); do
6908 LRU_SIZE=`lctl get_param -n $NSDIR/lru_size`
6912 lctl set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
6913 local LRU_SIZE_A=`lctl get_param -n $NSDIR.lru_size`
6915 [ $LRU_SIZE_B -gt $LRU_SIZE_A ] || {
6916 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
6917 unlinkmany $DIR/$tdir/f $NR
6921 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
6922 log "unlink $NR files at $DIR/$tdir"
6923 unlinkmany $DIR/$tdir/f $NR
6925 run_test 124a "lru resize ======================================="
6927 get_max_pool_limit()
6929 local limit=`lctl get_param -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit`
6932 if test $l -gt $max; then
6940 [ -z "`lctl get_param -n mdc.*.connect_flags | grep lru_resize`" ] && \
6941 skip "no lru resize on server" && return 0
6943 LIMIT=`get_max_pool_limit`
6945 NR=$(($(default_lru_size)*20))
6946 if [ $NR -gt $LIMIT ]; then
6947 log "Limit lock number by $LIMIT locks"
6950 lru_resize_disable mdc
6951 mkdir -p $DIR/$tdir/disable_lru_resize ||
6952 error "failed to create $DIR/$tdir/disable_lru_resize"
6954 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
6955 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
6956 cancel_lru_locks mdc
6959 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
6962 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
6965 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
6969 nolruresize_delta=$((etime-stime))
6970 log "ls -la time: $nolruresize_delta seconds"
6971 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
6972 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
6974 lru_resize_enable mdc
6975 mkdir -p $DIR/$tdir/enable_lru_resize ||
6976 error "failed to create $DIR/$tdir/enable_lru_resize"
6978 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
6979 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
6980 cancel_lru_locks mdc
6983 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
6986 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
6989 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
6993 lruresize_delta=$((etime-stime))
6994 log "ls -la time: $lruresize_delta seconds"
6995 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
6997 if [ $lruresize_delta -gt $nolruresize_delta ]; then
6998 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
6999 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
7000 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
7002 log "lru resize performs the same with no lru resize"
7004 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
7006 run_test 124b "lru resize (performance test) ======================="
7008 test_125() { # 13358
7009 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
7010 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
7011 mkdir -p $DIR/d125 || error "mkdir failed"
7012 $SETSTRIPE -S 65536 -c -1 $DIR/d125 || error "setstripe failed"
7013 setfacl -R -m u:bin:rwx $DIR/d125 || error "setfacl $DIR/d125 failed"
7014 ls -ld $DIR/d125 || error "cannot access $DIR/d125"
7016 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
7018 test_126() { # bug 12829/13455
7019 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
7020 [ "$UID" != 0 ] && skip_env "skipping $TESTNAME (must run as root)" && return
7021 $GSS && skip "must run as gss disabled" && return
7023 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
7024 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
7026 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
7028 run_test 126 "check that the fsgid provided by the client is taken into account"
7030 test_127a() { # bug 15521
7031 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
7032 $LCTL set_param osc.*.stats=0
7033 FSIZE=$((2048 * 1024))
7034 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
7035 cancel_lru_locks osc
7036 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
7038 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
7039 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
7040 echo "got $COUNT $NAME"
7041 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
7042 eval $NAME=$COUNT || error "Wrong proc format"
7045 read_bytes|write_bytes)
7046 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
7047 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
7048 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
7049 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
7050 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
7051 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
7052 error "sumsquare is too small: $SUMSQ"
7053 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
7054 error "sumsquare is too big: $SUMSQ"
7058 done < $DIR/${tfile}.tmp
7060 #check that we actually got some stats
7061 [ "$read_bytes" ] || error "Missing read_bytes stats"
7062 [ "$write_bytes" ] || error "Missing write_bytes stats"
7063 [ "$read_bytes" != 0 ] || error "no read done"
7064 [ "$write_bytes" != 0 ] || error "no write done"
7066 run_test 127a "verify the client stats are sane"
7068 test_127b() { # bug LU-333
7069 $LCTL set_param llite.*.stats=0
7070 FSIZE=65536 # sized fixed to match PAGE_SIZE for most clients
7071 # perform 2 reads and writes so MAX is different from SUM.
7072 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
7073 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
7074 cancel_lru_locks osc
7075 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
7076 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
7078 $LCTL get_param llite.*.stats | grep samples > $TMP/${tfile}.tmp
7079 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
7080 echo "got $COUNT $NAME"
7081 eval $NAME=$COUNT || error "Wrong proc format"
7085 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
7086 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
7087 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
7088 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
7091 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
7092 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
7093 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
7094 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
7098 done < $TMP/${tfile}.tmp
7100 #check that we actually got some stats
7101 [ "$read_bytes" ] || error "Missing read_bytes stats"
7102 [ "$write_bytes" ] || error "Missing write_bytes stats"
7103 [ "$read_bytes" != 0 ] || error "no read done"
7104 [ "$write_bytes" != 0 ] || error "no write done"
7106 run_test 127b "verify the llite client stats are sane"
7108 test_128() { # bug 15212
7110 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
7115 result=$(grep error $TMP/$tfile.log)
7117 [ -z "$result" ] || error "consecutive find's under interactive lfs failed"
7119 run_test 128 "interactive lfs for 2 consecutive find's"
7126 local LDPROC=/proc/fs/ldiskfs
7128 for facet in $(get_facets MDS); do
7129 canondev=$(ldiskfs_canon *.$(convert_facet2label $facet).mntdev $facet)
7130 do_facet $facet "test -e $LDPROC/$canondev/max_dir_size" || LDPROC=/sys/fs/ldiskfs
7131 do_facet $facet "echo $1 >$LDPROC/$canondev/max_dir_size"
7135 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
7136 skip "Only applicable to ldiskfs-based MDTs"
7139 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7150 while [ ! $I -gt $((MAX * MDSCOUNT)) ]; do
7151 $MULTIOP $DIR/$tdir/$J Oc
7153 if [ $rc -eq $EFBIG ]; then
7155 echo "return code $rc received as expected"
7157 elif [ $rc -ne 0 ]; then
7159 error_exit "return code $rc received instead of expected $EFBIG"
7162 I=$(stat -c%s "$DIR/$tdir")
7166 error "exceeded dir size limit $MAX x $MDSCOUNT $((MAX * MDSCOUNT)) : $I bytes"
7168 run_test 129 "test directory size limit ========================"
7177 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7178 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
7181 trap cleanup_130 EXIT RETURN
7183 local fm_file=$DIR/$tfile
7184 $SETSTRIPE -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
7185 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
7186 error "dd failed for $fm_file"
7188 # LU-1795: test filefrag/FIEMAP once, even if unsupported
7189 filefrag -ves $fm_file
7191 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
7192 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
7193 [ $RC != 0 ] && error "filefrag $fm_file failed"
7195 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
7196 grep -v "ext:" | grep -v "found")
7197 lun=$($GETSTRIPE -i $fm_file)
7199 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
7202 for line in $filefrag_op
7204 frag_lun=`echo $line | cut -d: -f5`
7205 ext_len=`echo $line | cut -d: -f4`
7206 if (( $frag_lun != $lun )); then
7208 error "FIEMAP on 1-stripe file($fm_file) failed"
7211 (( tot_len += ext_len ))
7214 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
7216 error "FIEMAP on 1-stripe file($fm_file) failed;"
7222 echo "FIEMAP on single striped file succeeded"
7224 run_test 130a "FIEMAP (1-stripe file)"
7227 [ "$OSTCOUNT" -lt "2" ] &&
7228 skip_env "skipping FIEMAP on 2-stripe file test" && return
7230 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7231 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
7234 trap cleanup_130 EXIT RETURN
7236 local fm_file=$DIR/$tfile
7237 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
7238 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
7239 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
7241 dd if=/dev/zero of=$fm_file bs=1M count=2 ||
7242 error "dd failed on $fm_file"
7244 filefrag -ves $fm_file || error "filefrag $fm_file failed"
7245 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
7246 grep -v "ext:" | grep -v "found")
7248 last_lun=$(echo $filefrag_op | cut -d: -f5)
7253 for line in $filefrag_op
7255 frag_lun=`echo $line | cut -d: -f5`
7256 ext_len=`echo $line | cut -d: -f4`
7257 if (( $frag_lun != $last_lun )); then
7258 if (( tot_len != 1024 )); then
7260 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 256"
7267 (( tot_len += ext_len ))
7270 if (( num_luns != 2 || tot_len != 1024 )); then
7272 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
7278 echo "FIEMAP on 2-stripe file succeeded"
7280 run_test 130b "FIEMAP (2-stripe file)"
7283 [ "$OSTCOUNT" -lt "2" ] &&
7284 skip_env "skipping FIEMAP on 2-stripe file" && return
7286 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7287 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
7290 trap cleanup_130 EXIT RETURN
7292 local fm_file=$DIR/$tfile
7293 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
7294 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
7295 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
7297 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 || error "dd failed on $fm_file"
7299 filefrag -ves $fm_file || error "filefrag $fm_file failed"
7300 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
7302 last_lun=`echo $filefrag_op | cut -d: -f5`
7307 for line in $filefrag_op
7309 frag_lun=`echo $line | cut -d: -f5`
7310 ext_len=`echo $line | cut -d: -f4`
7311 if (( $frag_lun != $last_lun )); then
7312 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
7313 if (( logical != 512 )); then
7315 error "FIEMAP on $fm_file failed; returned logical start for lun $logical instead of 512"
7318 if (( tot_len != 512 )); then
7320 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
7327 (( tot_len += ext_len ))
7330 if (( num_luns != 2 || tot_len != 512 )); then
7332 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
7338 echo "FIEMAP on 2-stripe file with hole succeeded"
7340 run_test 130c "FIEMAP (2-stripe file with hole)"
7343 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping FIEMAP on N-stripe file test" && return
7345 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7346 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
7348 trap cleanup_130 EXIT RETURN
7350 local fm_file=$DIR/$tfile
7351 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file||error "setstripe on $fm_file"
7352 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
7353 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
7354 dd if=/dev/zero of=$fm_file bs=1M count=$OSTCOUNT || error "dd failed on $fm_file"
7356 filefrag -ves $fm_file || error "filefrag $fm_file failed"
7357 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
7359 last_lun=`echo $filefrag_op | cut -d: -f5`
7364 for line in $filefrag_op
7366 frag_lun=`echo $line | cut -d: -f5`
7367 ext_len=`echo $line | cut -d: -f4`
7368 if (( $frag_lun != $last_lun )); then
7369 if (( tot_len != 1024 )); then
7371 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
7378 (( tot_len += ext_len ))
7381 if (( num_luns != OSTCOUNT || tot_len != 1024 )); then
7383 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
7389 echo "FIEMAP on N-stripe file succeeded"
7391 run_test 130d "FIEMAP (N-stripe file)"
7394 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping continuation FIEMAP test" && return
7396 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7397 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
7399 trap cleanup_130 EXIT RETURN
7401 local fm_file=$DIR/$tfile
7402 $SETSTRIPE -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
7403 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
7404 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
7407 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
7408 for ((i = 0; i < $NUM_BLKS; i++))
7410 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
7413 filefrag -ves $fm_file || error "filefrag $fm_file failed"
7414 filefrag_op=`filefrag -ve $fm_file | grep -A 12000 "ext:" | grep -v "ext:" | grep -v "found"`
7416 last_lun=`echo $filefrag_op | cut -d: -f5`
7421 for line in $filefrag_op
7423 frag_lun=`echo $line | cut -d: -f5`
7424 ext_len=`echo $line | cut -d: -f4`
7425 if (( $frag_lun != $last_lun )); then
7426 if (( tot_len != $EXPECTED_LEN )); then
7428 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of $EXPECTED_LEN"
7435 (( tot_len += ext_len ))
7438 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
7440 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
7446 echo "FIEMAP with continuation calls succeeded"
7448 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
7450 # Test for writev/readv
7452 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 || \
7453 error "writev test failed"
7454 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 || \
7455 error "readv failed"
7458 run_test 131a "test iov's crossing stripe boundary for writev/readv"
7461 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 || \
7462 error "append writev test failed"
7463 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 || \
7464 error "append writev test failed"
7467 run_test 131b "test append writev"
7470 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
7473 run_test 131c "test read/write on file w/o objects"
7476 rwv -f $DIR/$tfile -w -n 1 1572864
7477 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
7478 if [ "$NOB" != 1572864 ]; then
7479 error "Short read filed: read $NOB bytes instead of 1572864"
7483 run_test 131d "test short read"
7486 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
7487 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
7488 error "read hitting hole failed"
7491 run_test 131e "test read hitting hole"
7496 for node in $(osts_nodes); do
7497 gl=$(do_node $node "$LCTL get_param -n ost.OSS.ost.stats" | awk '/'$token'/ {print $2}' | head -n 1)
7498 [ x$gl = x"" ] && gl=0
7499 gl_sum=$((gl_sum + gl))
7509 if [ x$som = x"enabled" ]; then
7510 [ $((gl2 - gl1)) -gt 0 ] && error "no glimpse RPC is expected"
7511 MOUNTOPT=`echo $MOUNTOPT | sed 's/som_preview//g'`
7512 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=disabled"
7514 [ $((gl2 - gl1)) -gt 0 ] || error "some glimpse RPC is expected"
7515 MOUNTOPT="$MOUNTOPT,som_preview"
7516 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=enabled"
7519 # do remount to make new mount-conf parameters actual
7526 test_132() { #1028, SOM
7527 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7528 local num=$(get_mds_dir $DIR)
7529 local mymds=mds${num}
7530 local MOUNTOPT_SAVE=$MOUNTOPT
7532 dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
7533 cancel_lru_locks osc
7535 som1=$(do_facet $mymds "$LCTL get_param mdt.*.som" | awk -F= ' {print $2}' | head -n 1)
7537 gl1=$(get_ost_param "ldlm_glimpse_enqueue")
7538 stat $DIR/$tfile >/dev/null
7539 gl2=$(get_ost_param "ldlm_glimpse_enqueue")
7540 echo "====> SOM is "$som1", "$((gl2 - gl1))" glimpse RPC occured"
7542 som_mode_switch $som1 $gl1 $gl2
7544 dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
7545 cancel_lru_locks osc
7547 som2=$(do_facet $mymds "$LCTL get_param mdt.*.som" | awk -F= ' {print $2}' | head -n 1)
7548 if [ $som1 == $som2 ]; then
7549 error "som is still "$som2
7550 if [ x$som2 = x"enabled" ]; then
7557 gl1=$(get_ost_param "ldlm_glimpse_enqueue")
7558 stat $DIR/$tfile >/dev/null
7559 gl2=$(get_ost_param "ldlm_glimpse_enqueue")
7560 echo "====> SOM is "$som2", "$((gl2 - gl1))" glimpse RPC occured"
7561 som_mode_switch $som2 $gl1 $gl2
7562 MOUNTOPT=$MOUNTOPT_SAVE
7564 run_test 132 "som avoids glimpse rpc"
7570 $SINGLEMDS) res=`do_facet $SINGLEMDS $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$2"`
7572 ost) res=`do_facet ost1 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$2"`
7574 *) error "Wrong argument $1" ;;
7577 count=`echo $res | awk '{print $2}'`
7578 [ -z "$res" ] && error "The counter for $2 on $1 was not incremented"
7579 # if the argument $3 is zero, it means any stat increment is ok.
7580 if [ $3 -gt 0 ] ; then
7581 [ $count -ne $3 ] && error "The $2 counter on $1 is wrong - expected $3"
7586 remote_ost_nodsh && skip "remote OST with nodsh" && return
7587 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7589 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
7590 { skip "MDS doesn't support rename stats"; return; }
7591 local testdir=$DIR/${tdir}/stats_testdir
7592 mkdir -p $DIR/${tdir}
7595 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
7596 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
7598 # verify mdt stats first.
7599 mkdir ${testdir} || error "mkdir failed"
7600 check_stats $SINGLEMDS "mkdir" 1
7601 touch ${testdir}/${tfile} || "touch failed"
7602 check_stats $SINGLEMDS "open" 1
7603 check_stats $SINGLEMDS "close" 1
7604 mknod ${testdir}/${tfile}-pipe p || "mknod failed"
7605 check_stats $SINGLEMDS "mknod" 1
7606 rm -f ${testdir}/${tfile}-pipe || "pipe remove failed"
7607 check_stats $SINGLEMDS "unlink" 1
7608 rm -f ${testdir}/${tfile} || error "file remove failed"
7609 check_stats $SINGLEMDS "unlink" 2
7611 # remove working dir and check mdt stats again.
7612 rmdir ${testdir} || error "rmdir failed"
7613 check_stats $SINGLEMDS "rmdir" 1
7615 local testdir1=$DIR/${tdir}/stats_testdir1
7617 mkdir -p ${testdir1}
7618 touch ${testdir1}/test1
7619 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
7620 check_stats $SINGLEMDS "crossdir_rename" 1
7622 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
7623 check_stats $SINGLEMDS "samedir_rename" 1
7627 run_test 133a "Verifying MDT stats ========================================"
7630 remote_ost_nodsh && skip "remote OST with nodsh" && return
7631 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7632 local testdir=$DIR/${tdir}/stats_testdir
7633 mkdir -p ${testdir} || error "mkdir failed"
7634 touch ${testdir}/${tfile} || "touch failed"
7635 cancel_lru_locks mdc
7638 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
7639 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
7641 # extra mdt stats verification.
7642 chmod 444 ${testdir}/${tfile} || error "chmod failed"
7643 check_stats $SINGLEMDS "setattr" 1
7644 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
7645 if [ $(lustre_version_code $SINGLEMDS) -ne $(version_code 2.2.0) ]
7647 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
7648 check_stats $SINGLEMDS "getattr" 1
7650 $LFS df || error "lfs failed"
7651 check_stats $SINGLEMDS "statfs" 1
7655 run_test 133b "Verifying extra MDT stats =================================="
7658 remote_ost_nodsh && skip "remote OST with nodsh" && return
7659 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7660 local testdir=$DIR/${tdir}/stats_testdir
7661 mkdir -p ${testdir} || error "mkdir failed"
7663 # verify obdfilter stats.
7664 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
7666 cancel_lru_locks osc
7667 wait_delete_completed
7670 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
7671 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
7673 dd if=/dev/zero of=${testdir}/${tfile} conv=notrunc bs=512k count=1 || error "dd failed"
7675 cancel_lru_locks osc
7676 check_stats ost "write" 1
7678 dd if=${testdir}/${tfile} of=/dev/null bs=1k count=1 || error "dd failed"
7679 check_stats ost "read" 1
7681 > ${testdir}/${tfile} || error "truncate failed"
7682 check_stats ost "punch" 1
7684 rm -f ${testdir}/${tfile} || error "file remove failed"
7685 wait_delete_completed
7686 check_stats ost "destroy" 1
7690 run_test 133c "Verifying OST stats ========================================"
7697 while [ $value -ge 2 ]; do
7702 if [ $orig -gt $order ]; then
7710 local size=('K' 'M' 'G' 'T');
7712 local size_string=$value
7714 while [ $value -ge 1024 ]; do
7715 if [ $i -gt 3 ]; then
7716 #T is the biggest unit we get here, if that is bigger,
7718 size_string=${value}T
7721 value=$((value >> 10))
7722 if [ $value -lt 1024 ]; then
7723 size_string=${value}${size[$i]}
7734 local sample=$(do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats |
7735 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
7740 remote_ost_nodsh && skip "remote OST with nodsh" && return
7741 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7742 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
7743 { skip "MDS doesn't support rename stats"; return; }
7745 local testdir1=$DIR/${tdir}/stats_testdir1
7746 local testdir2=$DIR/${tdir}/stats_testdir2
7748 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
7750 mkdir -p ${testdir1} || error "mkdir failed"
7751 mkdir -p ${testdir2} || error "mkdir failed"
7753 createmany -o $testdir1/test 512 || error "createmany failed"
7755 # check samedir rename size
7756 mv ${testdir1}/test0 ${testdir1}/test_0
7758 local testdir1_size=$(ls -l $DIR/${tdir} |
7759 awk '/stats_testdir1/ {print $5}')
7760 local testdir2_size=$(ls -l $DIR/${tdir} |
7761 awk '/stats_testdir2/ {print $5}')
7763 testdir1_size=$(order_2 $testdir1_size)
7764 testdir2_size=$(order_2 $testdir2_size)
7766 testdir1_size=$(size_in_KMGT $testdir1_size)
7767 testdir2_size=$(size_in_KMGT $testdir2_size)
7769 echo "source rename dir size: ${testdir1_size}"
7770 echo "target rename dir size: ${testdir2_size}"
7772 local cmd="do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats"
7773 eval $cmd || error "$cmd failed"
7774 local samedir=$($cmd | grep 'same_dir')
7775 local same_sample=$(get_rename_size $testdir1_size)
7776 [ -z "$samedir" ] && error "samedir_rename_size count error"
7777 [ "$same_sample" -eq 1 ] || error "samedir_rename_size error $same_sample"
7778 echo "Check same dir rename stats success"
7780 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
7782 # check crossdir rename size
7783 mv ${testdir1}/test_0 ${testdir2}/test_0
7785 testdir1_size=$(ls -l $DIR/${tdir} |
7786 awk '/stats_testdir1/ {print $5}')
7787 testdir2_size=$(ls -l $DIR/${tdir} |
7788 awk '/stats_testdir2/ {print $5}')
7790 testdir1_size=$(order_2 $testdir1_size)
7791 testdir2_size=$(order_2 $testdir2_size)
7793 testdir1_size=$(size_in_KMGT $testdir1_size)
7794 testdir2_size=$(size_in_KMGT $testdir2_size)
7796 echo "source rename dir size: ${testdir1_size}"
7797 echo "target rename dir size: ${testdir2_size}"
7799 eval $cmd || error "$cmd failed"
7800 local crossdir=$($cmd | grep 'crossdir')
7801 local src_sample=$(get_rename_size $testdir1_size)
7802 local tgt_sample=$(get_rename_size $testdir2_size)
7803 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
7804 [ "$src_sample" -eq 1 ] || error "crossdir_rename_size error $src_sample"
7805 [ "$tgt_sample" -eq 1 ] || error "crossdir_rename_size error $tgt_sample"
7806 echo "Check cross dir rename stats success"
7809 run_test 133d "Verifying rename_stats ========================================"
7811 test_140() { #bug-17379
7812 mkdir -p $DIR/$tdir || error "Creating dir $DIR/$tdir"
7813 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
7814 cp /usr/bin/stat . || error "Copying stat to $DIR/$tdir"
7816 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
7817 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
7819 while i=`expr $i + 1`; do
7820 mkdir -p $i || error "Creating dir $i"
7821 cd $i || error "Changing to $i"
7822 ln -s ../stat stat || error "Creating stat symlink"
7823 # Read the symlink until ELOOP present,
7824 # not LBUGing the system is considered success,
7825 # we didn't overrun the stack.
7826 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
7828 if [ $ret -eq 40 ]; then
7831 error "Open stat symlink"
7837 echo "The symlink depth = $i"
7838 [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 -o $i -eq 40 ] ||
7839 error "Invalid symlink depth"
7841 # Test recursive symlink
7842 ln -s symlink_self symlink_self
7843 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
7844 echo "open symlink_self returns $ret"
7845 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
7847 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
7850 local TF="$TMP/$tfile"
7852 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
7854 cancel_lru_locks osc
7855 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
7856 remount_client $MOUNT
7858 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
7861 $TRUNCATE $DIR/$tfile 6000
7862 cancel_lru_locks osc
7863 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
7866 echo "12345" >>$DIR/$tfile
7867 cancel_lru_locks osc
7868 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
7871 echo "12345" >>$DIR/$tfile
7872 cancel_lru_locks osc
7873 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
7878 run_test 150 "truncate/append tests"
7880 function roc_hit() {
7881 local list=$(comma_list $(osts_nodes))
7883 echo $(get_obdfilter_param $list '' stats |
7884 awk '/'cache_hit'/ {sum+=$2} END {print sum}')
7887 function set_cache() {
7890 if [ "$2" == "off" ]; then
7893 local list=$(comma_list $(osts_nodes))
7894 set_obdfilter_param $list '' $1_cache_enable $on
7896 cancel_lru_locks osc
7900 remote_ost_nodsh && skip "remote OST with nodsh" && return
7903 local list=$(comma_list $(osts_nodes))
7905 # check whether obdfilter is cache capable at all
7906 if ! get_obdfilter_param $list '' read_cache_enable >/dev/null; then
7907 echo "not cache-capable obdfilter"
7911 # check cache is enabled on all obdfilters
7912 if get_obdfilter_param $list '' read_cache_enable | grep 0; then
7913 echo "oss cache is disabled"
7917 set_obdfilter_param $list '' writethrough_cache_enable 1
7919 # pages should be in the case right after write
7920 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES || error "dd failed"
7921 local BEFORE=`roc_hit`
7922 cancel_lru_locks osc
7923 cat $DIR/$tfile >/dev/null
7924 local AFTER=`roc_hit`
7925 if ! let "AFTER - BEFORE == CPAGES"; then
7926 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
7929 # the following read invalidates the cache
7930 cancel_lru_locks osc
7931 set_obdfilter_param $list '' read_cache_enable 0
7932 cat $DIR/$tfile >/dev/null
7934 # now data shouldn't be found in the cache
7936 cancel_lru_locks osc
7937 cat $DIR/$tfile >/dev/null
7939 if let "AFTER - BEFORE != 0"; then
7940 error "IN CACHE: before: $BEFORE, after: $AFTER"
7943 set_obdfilter_param $list '' read_cache_enable 1
7946 run_test 151 "test cache on oss and controls ==============================="
7949 local TF="$TMP/$tfile"
7951 # simulate ENOMEM during write
7952 #define OBD_FAIL_OST_NOMEM 0x226
7953 lctl set_param fail_loc=0x80000226
7954 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
7956 sync || error "sync failed"
7957 lctl set_param fail_loc=0
7959 # discard client's cache
7960 cancel_lru_locks osc
7962 # simulate ENOMEM during read
7963 lctl set_param fail_loc=0x80000226
7964 cmp $TF $DIR/$tfile || error "cmp failed"
7965 lctl set_param fail_loc=0
7969 run_test 152 "test read/write with enomem ============================"
7972 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
7974 run_test 153 "test if fdatasync does not crash ======================="
7977 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
7978 { skip "Need MDS version at least 2.2.51"; return 0; }
7980 cp /etc/hosts $DIR/$tfile
7982 fid=$($LFS path2fid $DIR/$tfile)
7984 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
7986 ffid=$DIR/.lustre/fid/$fid
7988 echo "stat fid $fid"
7989 stat $ffid > /dev/null || error "stat $ffid failed."
7990 echo "touch fid $fid"
7991 touch $ffid || error "touch $ffid failed."
7992 echo "write to fid $fid"
7993 cat /etc/hosts > $ffid || error "write $ffid failed."
7994 echo "read fid $fid"
7995 diff /etc/hosts $ffid || error "read $ffid failed."
7996 echo "append write to fid $fid"
7997 cat /etc/hosts >> $ffid || error "append write $ffid failed."
7998 echo "rename fid $fid"
7999 mv $ffid $DIR/$tfile.1 && error "rename $ffid to $tfile.1 should fail."
8001 mv $DIR/$tfile.1 $ffid && error "rename $tfile.1 to $ffid should fail."
8003 echo "truncate fid $fid"
8004 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
8005 echo "link fid $fid"
8006 ln -f $ffid $DIR/tfile.lnk || error "link $ffid failed."
8007 if [ -n $(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl) ]; then
8008 echo "setfacl fid $fid"
8009 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
8010 echo "getfacl fid $fid"
8011 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
8013 echo "unlink fid $fid"
8014 unlink $DIR/.lustre/fid/$fid && error "unlink $ffid should fail."
8015 echo "mknod fid $fid"
8016 mknod $ffid c 1 3 && error "mknod $ffid should fail."
8018 fid=[0xf00000400:0x1:0x0]
8019 ffid=$DIR/.lustre/fid/$fid
8021 echo "stat non-exist fid $fid"
8022 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
8023 echo "write to non-exist fid $fid"
8024 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
8025 echo "link new fid $fid"
8026 ln $DIR/$tfile $ffid && error "link $ffid should fail."
8029 touch $DIR/$tdir/$tfile
8030 fid=$($LFS path2fid $DIR/$tdir)
8032 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
8034 ffid=$DIR/.lustre/fid/$fid
8037 ls $ffid > /dev/null || error "ls $ffid failed."
8038 echo "touch $fid/$tfile.1"
8039 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
8041 echo "touch $DIR/.lustre/fid/$tfile"
8042 touch $DIR/.lustre/fid/$tfile && \
8043 error "touch $DIR/.lustre/fid/$tfile should fail."
8045 echo "setxattr to $DIR/.lustre/fid"
8046 setfattr -n trusted.name1 -v value1 $DIR/.lustre/fid &&
8047 error "setxattr should fail."
8049 echo "listxattr for $DIR/.lustre/fid"
8050 getfattr -d -m "^trusted" $DIR/.lustre/fid &&
8051 error "listxattr should fail."
8053 echo "delxattr from $DIR/.lustre/fid"
8054 setfattr -x trusted.name1 $DIR/.lustre/fid &&
8055 error "delxattr should fail."
8057 echo "touch invalid fid: $DIR/.lustre/fid/[0x200000400:0x2:0x3]"
8058 touch $DIR/.lustre/fid/[0x200000400:0x2:0x3] &&
8059 error "touch invalid fid should fail."
8061 echo "touch non-normal fid: $DIR/.lustre/fid/[0x1:0x2:0x0]"
8062 touch $DIR/.lustre/fid/[0x1:0x2:0x0] &&
8063 error "touch non-normal fid should fail."
8065 echo "rename $tdir to $DIR/.lustre/fid"
8066 mrename $DIR/$tdir $DIR/.lustre/fid &&
8067 error "rename to $DIR/.lustre/fid should fail."
8069 echo "rename .lustre to itself"
8070 fid=$($LFS path2fid $DIR)
8071 mrename $DIR/.lustre $DIR/.lustre/fid/$fid/.lustre &&
8072 error "rename .lustre to itself should fail."
8074 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $DIR/$tfile-2
8075 fid=$($LFS path2fid $DIR/$tfile-2)
8076 echo "cp /etc/passwd $DIR/.lustre/fid/$fid"
8077 cp /etc/passwd $DIR/.lustre/fid/$fid &&
8078 error "create lov data thru .lustre should fail."
8079 echo "cp /etc/passwd $DIR/$tfile-2"
8080 cp /etc/passwd $DIR/$tfile-2 || error "copy to $DIR/$tfile-2 failed."
8081 echo "diff /etc/passwd $DIR/.lustre/fid/$fid"
8082 diff /etc/passwd $DIR/.lustre/fid/$fid ||
8083 error "diff /etc/passwd $DIR/.lustre/fid/$fid failed."
8085 echo "Open-by-FID succeeded"
8087 run_test 154 "Open-by-FID"
8089 test_155_small_load() {
8090 local temp=$TMP/$tfile
8091 local file=$DIR/$tfile
8093 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
8094 error "dd of=$temp bs=6096 count=1 failed"
8096 cancel_lru_locks osc
8097 cmp $temp $file || error "$temp $file differ"
8099 $TRUNCATE $temp 6000
8100 $TRUNCATE $file 6000
8101 cmp $temp $file || error "$temp $file differ (truncate1)"
8103 echo "12345" >>$temp
8104 echo "12345" >>$file
8105 cmp $temp $file || error "$temp $file differ (append1)"
8107 echo "12345" >>$temp
8108 echo "12345" >>$file
8109 cmp $temp $file || error "$temp $file differ (append2)"
8115 test_155_big_load() {
8116 remote_ost_nodsh && skip "remote OST with nodsh" && return
8117 local temp=$TMP/$tfile
8118 local file=$DIR/$tfile
8121 local cache_size=$(do_facet ost$((MAXI+1)) \
8122 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
8123 local large_file_size=$((cache_size * 2))
8125 echo "OSS cache size: $cache_size KB"
8126 echo "Large file size: $large_file_size KB"
8128 [ $MAXV -le $large_file_size ] && \
8129 skip_env "max available OST size needs > $large_file_size KB" && \
8132 $SETSTRIPE $file -c 1 -i $MAXI || error "$SETSTRIPE $file failed"
8134 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k || \
8135 error "dd of=$temp bs=$large_file_size count=1k failed"
8138 cancel_lru_locks osc
8139 cmp $temp $file || error "$temp $file differ"
8147 set_cache writethrough on
8150 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
8154 set_cache writethrough off
8157 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
8161 set_cache writethrough on
8164 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
8168 set_cache writethrough off
8171 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
8175 set_cache writethrough on
8178 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
8182 set_cache writethrough off
8185 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
8189 set_cache writethrough on
8192 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
8196 set_cache writethrough off
8199 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
8205 local file="$DIR/$tfile"
8207 log "Turn on read and write cache"
8209 set_cache writethrough on
8211 log "Write data and read it back."
8212 log "Read should be satisfied from the cache."
8213 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
8215 cancel_lru_locks osc
8216 cat $file >/dev/null
8218 if ! let "AFTER - BEFORE == CPAGES"; then
8219 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
8221 log "cache hits:: before: $BEFORE, after: $AFTER"
8224 log "Read again; it should be satisfied from the cache."
8226 cancel_lru_locks osc
8227 cat $file >/dev/null
8229 if ! let "AFTER - BEFORE == CPAGES"; then
8230 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
8232 log "cache hits:: before: $BEFORE, after: $AFTER"
8236 log "Turn off the read cache and turn on the write cache"
8238 set_cache writethrough on
8240 log "Read again; it should be satisfied from the cache."
8242 cancel_lru_locks osc
8243 cat $file >/dev/null
8245 if ! let "AFTER - BEFORE == CPAGES"; then
8246 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
8248 log "cache hits:: before: $BEFORE, after: $AFTER"
8251 log "Read again; it should not be satisfied from the cache."
8253 cancel_lru_locks osc
8254 cat $file >/dev/null
8256 if ! let "AFTER - BEFORE == 0"; then
8257 error "IN CACHE: before: $BEFORE, after: $AFTER"
8259 log "cache hits:: before: $BEFORE, after: $AFTER"
8262 log "Write data and read it back."
8263 log "Read should be satisfied from the cache."
8264 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
8266 cancel_lru_locks osc
8267 cat $file >/dev/null
8269 if ! let "AFTER - BEFORE == CPAGES"; then
8270 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
8272 log "cache hits:: before: $BEFORE, after: $AFTER"
8275 log "Read again; it should not be satisfied from the cache."
8277 cancel_lru_locks osc
8278 cat $file >/dev/null
8280 if ! let "AFTER - BEFORE == 0"; then
8281 error "IN CACHE: before: $BEFORE, after: $AFTER"
8283 log "cache hits:: before: $BEFORE, after: $AFTER"
8287 log "Turn off read and write cache"
8289 set_cache writethrough off
8291 log "Write data and read it back"
8292 log "It should not be satisfied from the cache."
8294 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
8295 cancel_lru_locks osc
8297 cat $file >/dev/null
8299 if ! let "AFTER - BEFORE == 0"; then
8300 error_ignore 20762 "IN CACHE: before: $BEFORE, after: $AFTER"
8302 log "cache hits:: before: $BEFORE, after: $AFTER"
8306 log "Turn on the read cache and turn off the write cache"
8308 set_cache writethrough off
8310 log "Write data and read it back"
8311 log "It should not be satisfied from the cache."
8313 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
8315 cancel_lru_locks osc
8316 cat $file >/dev/null
8318 if ! let "AFTER - BEFORE == 0"; then
8319 error_ignore 20762 "IN CACHE: before: $BEFORE, after: $AFTER"
8321 log "cache hits:: before: $BEFORE, after: $AFTER"
8324 log "Read again; it should be satisfied from the cache."
8326 cancel_lru_locks osc
8327 cat $file >/dev/null
8329 if ! let "AFTER - BEFORE == CPAGES"; then
8330 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
8332 log "cache hits:: before: $BEFORE, after: $AFTER"
8337 run_test 156 "Verification of tunables ============================"
8341 if [ $MDSCOUNT -gt 1 ]; then
8342 error_ignore 17935 $*
8350 MASK=$(do_facet $SINGLEMDS $LCTL get_param mdd.$MDT0.changelog_mask |\
8353 if [ $MASK -eq 1 ]; then
8354 do_facet $SINGLEMDS $LCTL set_param mdd.$MDT0.changelog_mask="-$1"
8356 do_facet $SINGLEMDS $LCTL set_param mdd.$MDT0.changelog_mask="+$1"
8361 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8362 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
8363 { skip "Need MDS version at least 2.2.0"; return; }
8364 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
8365 echo "Registered as changelog user $USER"
8366 do_facet $SINGLEMDS $LCTL get_param -n mdd.$MDT0.changelog_users | \
8367 grep -q $USER || error "User $USER not found in changelog_users"
8370 mkdir -p $DIR/$tdir/pics/2008/zachy
8371 touch $DIR/$tdir/pics/2008/zachy/timestamp
8372 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
8373 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
8374 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
8375 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
8376 rm $DIR/$tdir/pics/desktop.jpg
8378 $LFS changelog $MDT0 | tail -5
8380 echo "verifying changelog mask"
8381 changelog_chmask "MKDIR"
8382 changelog_chmask "CLOSE"
8384 mkdir -p $DIR/$tdir/pics/zach/sofia
8385 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
8387 changelog_chmask "MKDIR"
8388 changelog_chmask "CLOSE"
8390 mkdir -p $DIR/$tdir/pics/2008/sofia
8391 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
8393 $LFS changelog $MDT0
8394 MKDIRS=$($LFS changelog $MDT0 | tail -5 | grep -c "MKDIR")
8395 CLOSES=$($LFS changelog $MDT0 | tail -5 | grep -c "CLOSE")
8396 [ $MKDIRS -eq 1 ] || err17935 "MKDIR changelog mask count $DIRS != 1"
8397 [ $CLOSES -eq 1 ] || err17935 "CLOSE changelog mask count $DIRS != 1"
8400 echo "verifying target fid"
8401 fidc=$($LFS changelog $MDT0 | grep timestamp | grep "CREAT" | \
8402 tail -1 | awk '{print $6}')
8403 fidf=$($LFS path2fid $DIR/$tdir/pics/zach/timestamp)
8404 [ "$fidc" == "t=$fidf" ] || \
8405 err17935 "fid in changelog $fidc != file fid $fidf"
8406 echo "verifying parent fid"
8407 fidc=$($LFS changelog $MDT0 | grep timestamp | grep "CREAT" | \
8408 tail -1 | awk '{print $7}')
8409 fidf=$($LFS path2fid $DIR/$tdir/pics/zach)
8410 [ "$fidc" == "p=$fidf" ] || \
8411 err17935 "pfid in changelog $fidc != dir fid $fidf"
8413 USER_REC1=$(do_facet $SINGLEMDS $LCTL get_param -n \
8414 mdd.$MDT0.changelog_users | grep $USER | awk '{print $2}')
8415 $LFS changelog_clear $MDT0 $USER $(($USER_REC1 + 5))
8416 USER_REC2=$(do_facet $SINGLEMDS $LCTL get_param -n \
8417 mdd.$MDT0.changelog_users | grep $USER | awk '{print $2}')
8418 echo "verifying user clear: $(( $USER_REC1 + 5 )) == $USER_REC2"
8419 [ $USER_REC2 == $(($USER_REC1 + 5)) ] || \
8420 err17935 "user index should be $(($USER_REC1 + 5)); is $USER_REC2"
8422 MIN_REC=$(do_facet $SINGLEMDS $LCTL get_param mdd.$MDT0.changelog_users | \
8423 awk 'min == "" || $2 < min {min = $2}; END {print min}')
8424 FIRST_REC=$($LFS changelog $MDT0 | head -1 | awk '{print $1}')
8425 echo "verifying min purge: $(( $MIN_REC + 1 )) == $FIRST_REC"
8426 [ $FIRST_REC == $(($MIN_REC + 1)) ] || \
8427 err17935 "first index should be $(($MIN_REC + 1)); is $FIRST_REC"
8429 echo "verifying user deregister"
8430 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
8431 do_facet $SINGLEMDS $LCTL get_param -n mdd.$MDT0.changelog_users | \
8432 grep -q $USER && error "User $USER still found in changelog_users"
8434 USERS=$(( $(do_facet $SINGLEMDS $LCTL get_param -n \
8435 mdd.$MDT0.changelog_users | wc -l) - 2 ))
8436 if [ $USERS -eq 0 ]; then
8437 LAST_REC1=$(do_facet $SINGLEMDS $LCTL get_param -n \
8438 mdd.$MDT0.changelog_users | head -1 | awk '{print $3}')
8439 touch $DIR/$tdir/chloe
8440 LAST_REC2=$(do_facet $SINGLEMDS $LCTL get_param -n \
8441 mdd.$MDT0.changelog_users | head -1 | awk '{print $3}')
8442 echo "verify changelogs are off if we were the only user: $LAST_REC1 == $LAST_REC2"
8443 [ $LAST_REC1 == $LAST_REC2 ] || error "changelogs not off"
8445 echo "$USERS other changelog users; can't verify off"
8448 run_test 160 "changelog sanity"
8452 cp /etc/hosts $DIR/$tdir/$tfile
8453 mkdir $DIR/$tdir/foo1
8454 mkdir $DIR/$tdir/foo2
8455 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
8456 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
8457 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
8458 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
8459 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[')
8460 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
8461 $LFS fid2path $DIR $FID
8462 err17935 "bad link ea"
8465 rm $DIR/$tdir/foo2/zachary
8467 rm $DIR/$tdir/foo2/thor
8469 rm $DIR/$tdir/$tfile
8471 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
8472 if [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ]
8474 $LFS fid2path $DIR $FID
8475 err17935 "bad link rename"
8477 rm $DIR/$tdir/foo2/maggie
8480 local longname=filename_avg_len_is_thirty_two_
8481 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 || \
8482 error "failed to hardlink many files"
8483 links=$($LFS fid2path $DIR $FID | wc -l)
8484 echo -n "${links}/1000 links in link EA"
8485 [ ${links} -gt 60 ] || err17935 "expected at least 60 links in link EA"
8486 unlinkmany $DIR/$tdir/foo2/$longname 1000 || \
8487 error "failed to unlink many hardlinks"
8489 run_test 161 "link ea sanity"
8496 local path=$(${LFS} fid2path $*)
8499 if [ $RC -ne 0 ]; then
8500 err17935 "path looked up of $expected failed. Error $RC"
8502 elif [ "${path}" != "${expected}" ]; then
8503 err17935 "path looked up \"${path}\" instead of \"${expected}\""
8506 echo "fid $fid resolves to path $path (expected $expected)"
8510 # Make changes to filesystem
8511 mkdir -p $DIR/$tdir/d2
8512 touch $DIR/$tdir/d2/$tfile
8513 touch $DIR/$tdir/d2/x1
8514 touch $DIR/$tdir/d2/x2
8515 mkdir -p $DIR/$tdir/d2/a/b/c
8516 mkdir -p $DIR/$tdir/d2/p/q/r
8518 FID=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
8519 check_path "$tdir/d2/$tfile" $FSNAME $FID --link 0
8522 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
8523 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
8524 check_path "$tdir/d2/p/q/r/slink" $FSNAME $FID --link 0
8526 # softlink to wrong file
8527 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
8528 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
8529 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME $FID --link 0
8532 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
8533 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
8534 FID=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
8535 # fid2path dir/fsname should both work
8536 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 1
8537 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR $FID --link 0
8539 # hardlink count: check that there are 2 links
8540 # Doesnt work with CMD yet: 17935
8541 ${LFS} fid2path $DIR $FID | wc -l | grep -q 2 || \
8542 err17935 "expected 2 links"
8544 # hardlink indexing: remove the first link
8545 rm $DIR/$tdir/d2/p/q/r/hlink
8546 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 0
8550 run_test 162 "path lookup sanity"
8553 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8554 copytool --test $FSNAME || { skip "copytool not runnable: $?" && return; }
8557 local uuid=$($LCTL get_param -n mdc.${FSNAME}-MDT0000-mdc-*.uuid)
8558 # this proc file is temporary and linux-only
8559 do_facet $SINGLEMDS lctl set_param mdt.${FSNAME}-MDT0000.mdccomm=$uuid ||\
8560 error "kernel->userspace send failed"
8563 run_test 163 "kernel <-> userspace comms"
8566 # do directio so as not to populate the page cache
8567 log "creating a 10 Mb file"
8568 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
8569 log "starting reads"
8570 dd if=$DIR/$tfile of=/dev/null bs=4096 &
8571 log "truncating the file"
8572 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
8574 kill %+ || true # reads might have finished
8575 echo "wait until dd is finished"
8577 log "removing the temporary file"
8578 rm -rf $DIR/$tfile || error "tmp file removal failed"
8580 run_test 169 "parallel read and truncate should not deadlock"
8583 $LCTL clear # bug 18514
8584 $LCTL debug_daemon start $TMP/${tfile}_log_good
8586 $LCTL debug_daemon stop
8587 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
8588 error "sed failed to read log_good"
8590 $LCTL debug_daemon start $TMP/${tfile}_log_good
8592 $LCTL debug_daemon stop
8594 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
8595 error "lctl df log_bad failed"
8597 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
8598 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
8600 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
8601 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
8603 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
8604 error "bad_line good_line1 good_line2 are empty"
8606 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
8607 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
8608 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
8610 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
8611 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
8612 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
8614 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
8615 error "bad_line_new good_line_new are empty"
8617 local expected_good=$((good_line1 + good_line2*2))
8619 rm -f $TMP/${tfile}*
8620 # LU-231, short malformed line may not be counted into bad lines
8621 if [ $bad_line -ne $bad_line_new ] &&
8622 [ $bad_line -ne $((bad_line_new - 1)) ]; then
8623 error "expected $bad_line bad lines, but got $bad_line_new"
8627 if [ $expected_good -ne $good_line_new ]; then
8628 error "expected $expected_good good lines, but got $good_line_new"
8633 run_test 170 "test lctl df to handle corrupted log ====================="
8635 test_171() { # bug20592
8636 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
8637 $LCTL set_param fail_loc=0x50e
8638 $LCTL set_param fail_val=3000
8639 multiop_bg_pause $DIR/$tfile O_s || true
8641 kill -USR1 $MULTIPID
8645 if dmesg | grep "recursive fault"; then
8646 error "caught a recursive fault"
8648 $LCTL set_param fail_loc=0
8651 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
8653 # it would be good to share it with obdfilter-survey/libecho code
8654 setup_obdecho_osc () {
8657 local obdfilter_name=$2
8658 echo "Creating new osc for $obdfilter_name on $ost_nid"
8659 # make sure we can find loopback nid
8660 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
8662 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
8663 ${obdfilter_name}_osc_UUID || rc=2; }
8664 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
8665 ${obdfilter_name}_UUID $ost_nid || rc=3; }
8669 cleanup_obdecho_osc () {
8670 local obdfilter_name=$1
8671 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
8672 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
8676 obdecho_create_test() {
8681 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
8682 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
8684 if [ $rc -eq 0 ]; then
8685 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
8686 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
8688 echo "New object id is $id"
8689 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec test_brw 10 w v 64 $id" ||
8691 [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec " \
8692 "cleanup" || rc=5; }
8693 [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec " \
8695 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
8700 remote_ost_nodsh && skip "remote OST with nodsh" && return
8704 if ! module_loaded obdecho; then
8705 load_module obdecho/obdecho
8709 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
8710 local host=$(lctl get_param -n osc.$osc.import |
8711 awk '/current_connection:/ {print $2}' )
8712 local target=$(lctl get_param -n osc.$osc.import |
8713 awk '/target:/ {print $2}' )
8714 target=${target%_UUID}
8716 [[ -n $target ]] && { setup_obdecho_osc $host $target || rc=1; } || rc=1
8717 [ $rc -eq 0 ] && { obdecho_create_test ${target}_osc client || rc=2; }
8718 [[ -n $target ]] && cleanup_obdecho_osc $target
8719 [ $rmmod_local -eq 1 ] && rmmod obdecho
8722 run_test 180a "test obdecho on osc"
8725 remote_ost_nodsh && skip "remote OST with nodsh" && return
8727 local rmmod_remote=0
8729 do_facet ost1 "lsmod | grep -q obdecho || " \
8730 "{ insmod ${LUSTRE}/obdecho/obdecho.ko || " \
8731 "modprobe obdecho; }" && rmmod_remote=1
8732 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ {print $4;exit}')
8733 [[ -n $target ]] && { obdecho_create_test $target ost1 || rc=1; }
8734 [ $rmmod_remote -eq 1 ] && do_facet ost1 "rmmod obdecho"
8737 run_test 180b "test obdecho directly on obdfilter"
8739 test_181() { # bug 22177
8740 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
8741 # create enough files to index the directory
8742 createmany -o $DIR/$tdir/foobar 4000
8743 # print attributes for debug purpose
8746 multiop_bg_pause $DIR/$tdir D_Sc || return 1
8748 # remove the files & current working dir
8749 unlinkmany $DIR/$tdir/foobar 4000
8751 kill -USR1 $MULTIPID
8753 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
8756 run_test 181 "Test open-unlinked dir ========================"
8759 # disable MDC RPC lock wouldn't crash client
8763 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
8764 #define OBD_FAIL_MDC_RPCS_SEM 0x804
8765 $LCTL set_param fail_loc=0x804
8767 for (( i=0; i < $tcount; i++ )) ; do
8769 createmany -o $DIR/$tdir/$i/f- $fcount &
8773 for (( i=0; i < $tcount; i++ )) ; do
8774 unlinkmany $DIR/$tdir/$i/f- $fcount &
8780 $LCTL set_param fail_loc=0
8782 run_test 182 "Disable MDC RPCs semaphore wouldn't crash client ================"
8785 check_file_in_pool()
8790 local res=$($GETSTRIPE $file | grep 0x | cut -f2)
8793 for t in $tlist ; do
8794 [ "$i" -eq "$t" ] && continue 2
8797 echo "pool list: $tlist"
8798 echo "striping: $res"
8799 error_noexit "$file not allocated in $pool"
8806 echo "Creating new pool"
8809 create_pool $FSNAME.$pool ||
8810 { error_noexit "No pool created, result code $?"; return 1; }
8811 [ $($LFS pool_list $FSNAME | grep -c $pool) -eq 1 ] ||
8812 { error_noexit "$pool not in lfs pool_list"; return 2; }
8815 pool_add_targets() {
8816 echo "Adding targets to pool"
8822 local list=$(seq $first $step $last)
8824 local t=$(for i in $list; do printf "$FSNAME-OST%04x_UUID " $i; done)
8825 do_facet mgs $LCTL pool_add \
8826 $FSNAME.$pool $FSNAME-OST[$first-$last/$step]
8827 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$pool \
8828 | sort -u | tr '\n' ' ' " "$t" || {
8829 error_noexit "Add to pool failed"
8832 local lfscount=$($LFS pool_list $FSNAME.$pool | grep -c "\-OST")
8833 local addcount=$(((last - first) / step + 1))
8834 [ $lfscount -eq $addcount ] || {
8835 error_noexit "lfs pool_list bad ost count" \
8836 "$lfscount != $addcount"
8844 echo "Setting pool on directory $tdir"
8846 $SETSTRIPE -c 2 -p $pool $tdir && return 0
8848 error_noexit "Cannot set pool $pool to $tdir"
8855 echo "Checking pool on directory $tdir"
8857 local res=$($GETSTRIPE --pool $tdir | sed "s/\s*$//")
8858 [ "$res" = "$pool" ] && return 0
8860 error_noexit "Pool on '$tdir' is '$res', not '$pool'"
8864 pool_dir_rel_path() {
8865 echo "Testing relative path works well"
8870 mkdir -p $root/$tdir/$tdir
8872 pool_set_dir $pool $tdir || return 1
8873 pool_set_dir $pool ./$tdir || return 2
8874 pool_set_dir $pool ../$tdir || return 3
8875 pool_set_dir $pool ../$tdir/$tdir || return 4
8876 rm -rf $tdir; cd - > /dev/null
8879 pool_alloc_files() {
8880 echo "Checking files allocation from directory pool"
8887 for i in $(seq -w 1 $count)
8889 local file=$tdir/file-$i
8891 check_file_in_pool $file $pool "$tlist" || \
8892 failed=$((failed + 1))
8894 [ "$failed" = 0 ] && return 0
8896 error_noexit "$failed files not allocated in $pool"
8900 pool_create_files() {
8901 echo "Creating files in pool"
8909 for i in $(seq -w 1 $count)
8911 local file=$tdir/spoo-$i
8912 $SETSTRIPE -p $pool $file
8913 check_file_in_pool $file $pool "$tlist" || \
8914 failed=$((failed + 1))
8916 [ "$failed" = 0 ] && return 0
8918 error_noexit "$failed files not allocated in $pool"
8923 echo "Checking 'lfs df' output"
8926 local t=$($LCTL get_param -n lov.$FSNAME-clilov-*.pools.$pool |
8928 local res=$($LFS df --pool $FSNAME.$pool |
8930 grep "$FSNAME-OST" |
8932 [ "$res" = "$t" ] && return 0
8934 error_noexit "Pools OSTs '$t' is not '$res' that lfs df reports"
8938 pool_file_rel_path() {
8939 echo "Creating files in a pool with relative pathname"
8944 { error_noexit "unable to create $tdir"; return 1 ; }
8945 local file="/..$tdir/$tfile-1"
8946 $SETSTRIPE -p $pool $file ||
8947 { error_noexit "unable to create $file" ; return 2 ; }
8950 $SETSTRIPE -p $pool $tfile-2 || {
8951 error_noexit "unable to create $tfile-2 in $tdir"
8956 pool_remove_first_target() {
8957 echo "Removing first target from a pool"
8960 local pname="lov.$FSNAME-*.pools.$pool"
8961 local t=$($LCTL get_param -n $pname | head -1)
8962 do_facet mgs $LCTL pool_remove $FSNAME.$pool $t
8963 wait_update $HOSTNAME "lctl get_param -n $pname | grep $t" "" || {
8964 error_noexit "$t not removed from $FSNAME.$pool"
8969 pool_remove_all_targets() {
8970 echo "Removing all targets from pool"
8973 local pname="lov.$FSNAME-*.pools.$pool"
8974 for t in $($LCTL get_param -n $pname | sort -u)
8976 do_facet mgs $LCTL pool_remove $FSNAME.$pool $t
8978 wait_update $HOSTNAME "lctl get_param -n $pname" "" || {
8979 error_noexit "Pool $FSNAME.$pool cannot be drained"
8982 # striping on an empty/nonexistant pool should fall back
8983 # to "pool of everything"
8985 error_noexit "failed to use fallback striping for empty pool"
8988 # setstripe on an empty pool should fail
8989 $SETSTRIPE -p $pool $file 2>/dev/null && {
8990 error_noexit "expected failure when creating file" \
8998 echo "Destroying pool"
9002 do_facet mgs $LCTL pool_destroy $FSNAME.$pool
9005 # striping on an empty/nonexistant pool should fall back
9006 # to "pool of everything"
9008 error_noexit "failed to use fallback striping for missing pool"
9011 # setstripe on an empty pool should fail
9012 $SETSTRIPE -p $pool $file 2>/dev/null && {
9013 error_noexit "expected failure when creating file" \
9018 # get param should return err once pool is gone
9019 if wait_update $HOSTNAME "lctl get_param -n \
9020 lov.$FSNAME-*.pools.$pool 2>/dev/null || echo foo" "foo"
9022 remove_pool_from_list $FSNAME.$pool
9025 error_noexit "Pool $FSNAME.$pool is not destroyed"
9030 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
9032 local POOL=${POOL:-cea1}
9033 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
9034 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
9037 local last_ost=$(($OSTCOUNT - 1))
9039 local ost_list=$(seq $first_ost $ost_step $last_ost)
9040 local ost_range="$first_ost $last_ost $ost_step"
9041 local test_path=$POOL_ROOT/$POOL_DIR_NAME
9042 local file_dir=$POOL_ROOT/file_tst
9046 # former test_200a test_200b
9047 pool_add $POOL || { rc=$? ; break; }
9048 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
9049 # former test_200c test_200d
9051 pool_set_dir $POOL $test_path || { rc=$? ; break; }
9052 pool_check_dir $POOL $test_path || { rc=$? ; break; }
9053 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
9054 || { rc=$? ; break; }
9055 # former test_200e test_200f
9056 local files=$((OSTCOUNT*3))
9057 pool_alloc_files $POOL $test_path $files "$ost_list" \
9058 || { rc=$? ; break; }
9059 pool_create_files $POOL $file_dir $files "$ost_list" \
9060 || { rc=$? ; break; }
9061 # former test_200g test_200h
9062 pool_lfs_df $POOL || { rc=$? ; break; }
9063 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
9065 # former test_201a test_201b test_201c
9066 pool_remove_first_target $POOL || { rc=$? ; break; }
9068 local f=$test_path/$tfile
9069 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
9070 pool_remove $POOL $f || { rc=$? ; break; }
9077 run_test 200 "OST pools"
9079 # usage: default_attr <count | size | offset>
9081 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
9084 # usage: check_default_stripe_attr
9085 check_default_stripe_attr() {
9086 ACTUAL=$($GETSTRIPE $* $DIR/$tdir)
9088 --stripe-count|--count)
9089 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
9090 --stripe-size|--size)
9091 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
9092 --stripe-index|--index)
9095 error "unknown getstripe attr '$1'"
9098 [ $ACTUAL != $EXPECTED ] &&
9099 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
9104 $SETSTRIPE --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
9106 check_default_stripe_attr --stripe-count
9107 check_default_stripe_attr --stripe-size
9108 check_default_stripe_attr --stripe-index
9112 run_test 204a "Print default stripe attributes ================="
9116 $SETSTRIPE --stripe-count 1 $DIR/$tdir
9118 check_default_stripe_attr --stripe-size
9119 check_default_stripe_attr --stripe-index
9123 run_test 204b "Print default stripe size and offset ==========="
9127 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
9129 check_default_stripe_attr --stripe-count
9130 check_default_stripe_attr --stripe-index
9134 run_test 204c "Print default stripe count and offset ==========="
9138 $SETSTRIPE --stripe-index 0 $DIR/$tdir
9140 check_default_stripe_attr --stripe-count
9141 check_default_stripe_attr --stripe-size
9145 run_test 204d "Print default stripe count and size ============="
9149 $SETSTRIPE -d $DIR/$tdir
9151 check_default_stripe_attr --stripe-count --raw
9152 check_default_stripe_attr --stripe-size --raw
9153 check_default_stripe_attr --stripe-index --raw
9157 run_test 204e "Print raw stripe attributes ================="
9161 $SETSTRIPE --stripe-count 1 $DIR/$tdir
9163 check_default_stripe_attr --stripe-size --raw
9164 check_default_stripe_attr --stripe-index --raw
9168 run_test 204f "Print raw stripe size and offset ==========="
9172 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
9174 check_default_stripe_attr --stripe-count --raw
9175 check_default_stripe_attr --stripe-index --raw
9179 run_test 204g "Print raw stripe count and offset ==========="
9183 $SETSTRIPE --stripe-index 0 $DIR/$tdir
9185 check_default_stripe_attr --stripe-count --raw
9186 check_default_stripe_attr --stripe-size --raw
9190 run_test 204h "Print raw stripe count and size ============="
9192 # Figure out which job scheduler is being used, if any,
9194 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
9196 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
9198 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
9200 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
9201 JOBENV=LOADL_STEP_ID
9202 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
9212 # clear old jobstats
9213 do_facet $SINGLEMDS lctl set_param mdt.*.job_stats="clear"
9214 do_facet ost1 lctl set_param obdfilter.*.job_stats="clear"
9216 # use a new JobID for this test, or we might see an old one
9217 [ "$JOBENV" = "FAKE_JOBID" ] && FAKE_JOBID=test_id.$testnum.$RANDOM
9221 log "Using JobID environment variable $JOBENV=$JOBVAL"
9223 if [ $JOBENV = "FAKE_JOBID" ]; then
9224 FAKE_JOBID=$JOBVAL $cmd
9229 if [ "$target" = "mdt" -o "$target" = "both" ]; then
9230 FACET="$SINGLEMDS" # will need to get MDS number for DNE
9231 do_facet $FACET lctl get_param mdt.*.job_stats |
9232 grep $JOBVAL || error "No job stats found on MDT $FACET"
9234 if [ "$target" = "ost" -o "$target" = "both" ]; then
9236 do_facet $FACET lctl get_param obdfilter.*.job_stats |
9237 grep $JOBVAL || error "No job stats found on OST $FACET"
9241 test_205() { # Job stats
9242 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
9243 skip "Server doesn't support jobstats" && return 0
9246 OLD_JOBENV=`$LCTL get_param -n jobid_var`
9247 if [ $OLD_JOBENV != $JOBENV ]; then
9248 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$JOBENV
9249 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" \
9254 cmd="mkdir $DIR/$tfile"
9255 verify_jobstats "$cmd" "mdt"
9257 cmd="rm -fr $DIR/$tfile"
9258 verify_jobstats "$cmd" "mdt"
9260 cmd="mknod $DIR/$tfile c 1 3"
9261 verify_jobstats "$cmd" "mdt"
9263 cmd="rm -f $DIR/$tfile"
9264 verify_jobstats "$cmd" "mdt"
9266 cmd="$SETSTRIPE -i 0 -c 1 $DIR/$tfile"
9267 verify_jobstats "$cmd" "mdt"
9269 cmd="touch $DIR/$tfile"
9270 verify_jobstats "$cmd" "both"
9272 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
9273 verify_jobstats "$cmd" "ost"
9275 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
9276 verify_jobstats "$cmd" "ost"
9278 cmd="$TRUNCATE $DIR/$tfile 0"
9279 verify_jobstats "$cmd" "both"
9281 cmd="mv -f $DIR/$tfile $DIR/jobstats_test_rename"
9282 verify_jobstats "$cmd" "mdt"
9285 rm -f $DIR/jobstats_test_rename
9287 if [ $OLD_JOBENV != $JOBENV ]; then
9288 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$OLD_JOBENV
9289 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" \
9290 $OLD_JOBENV || return 1
9293 run_test 205 "Verify job stats"
9295 # LU-1480, LU-1773 and LU-1657
9298 lfs setstripe -c -1 $DIR/$tdir
9299 #define OBD_FAIL_LOV_INIT 0x1403
9300 $LCTL set_param fail_loc=0xa0001403
9301 $LCTL set_param fail_val=1
9302 touch $DIR/$tdir/$tfile || true
9304 run_test 206 "fail lov_init_raid0() doesn't lbug"
9308 size=$((size % 8192 + 1))
9309 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
9310 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
9311 rm -f $DIR/f212 $DIR/f212.xyz
9313 run_test 212 "Sendfile test ============================================"
9316 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
9317 cancel_lru_locks osc
9318 lctl set_param fail_loc=0x8000040f
9319 # generate a read lock
9320 cat $DIR/$tfile > /dev/null
9321 # write to the file, it will try to cancel the above read lock.
9322 cat /etc/hosts >> $DIR/$tfile
9324 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
9326 test_214() { # for bug 20133
9327 mkdir -p $DIR/d214p/d214c
9328 for (( i=0; i < 340; i++ )) ; do
9329 touch $DIR/d214p/d214c/a$i
9332 ls -l $DIR/d214p || error "ls -l $DIR/d214p failed"
9333 mv $DIR/d214p/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
9334 ls $DIR/d214c || error "ls $DIR/d214c failed"
9335 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
9337 run_test 214 "hash-indexed directory test - bug 20133"
9339 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
9340 create_lnet_proc_files() {
9341 cat /proc/sys/lnet/$1 >$TMP/lnet_$1.out || error "cannot read /proc/sys/lnet/$1"
9342 sysctl lnet.$1 >$TMP/lnet_$1.sys_tmp || error "cannot read lnet.$1"
9344 sed "s/^lnet.$1\ =\ //g" "$TMP/lnet_$1.sys_tmp" >$TMP/lnet_$1.sys
9345 rm -f "$TMP/lnet_$1.sys_tmp"
9348 # counterpart of create_lnet_proc_files
9349 remove_lnet_proc_files() {
9350 rm -f $TMP/lnet_$1.out $TMP/lnet_$1.sys
9353 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
9354 # 3rd arg as regexp for body
9355 check_lnet_proc_stats() {
9356 local l=$(cat "$TMP/lnet_$1" |wc -l)
9357 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
9359 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
9362 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
9363 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
9364 # optional and can be regexp for 2nd line (lnet.routes case)
9365 check_lnet_proc_entry() {
9366 local blp=2 # blp stands for 'position of 1st line of body'
9367 [ "$5" = "" ] || blp=3 # lnet.routes case
9369 local l=$(cat "$TMP/lnet_$1" |wc -l)
9370 # subtracting one from $blp because the body can be empty
9371 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
9373 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
9374 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
9376 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
9377 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
9379 # bail out if any unexpected line happened
9380 sed -n "$blp~1 p" "$TMP/lnet_$1" |grep -Ev "$3"
9381 [ "$?" != 0 ] || error "$2 misformatted"
9384 test_215() { # for bugs 18102, 21079, 21517
9385 local N='(0|[1-9][0-9]*)' # non-negative numeric
9386 local P='[1-9][0-9]*' # positive numeric
9387 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
9388 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
9389 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
9390 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
9392 local L1 # regexp for 1st line
9393 local L2 # regexp for 2nd line (optional)
9394 local BR # regexp for the rest (body)
9396 # /proc/sys/lnet/stats should look as 11 space-separated non-negative numerics
9397 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
9398 create_lnet_proc_files "stats"
9399 check_lnet_proc_stats "stats.out" "/proc/sys/lnet/stats" "$BR"
9400 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
9401 remove_lnet_proc_files "stats"
9403 # /proc/sys/lnet/routes should look like this:
9404 # Routing disabled/enabled
9405 # net hops state router
9406 # where net is a string like tcp0, hops >= 0, state is up/down,
9407 # router is a string like 192.168.1.1@tcp2
9408 L1="^Routing (disabled|enabled)$"
9409 L2="^net +hops +state +router$"
9410 BR="^$NET +$N +(up|down) +$NID$"
9411 create_lnet_proc_files "routes"
9412 check_lnet_proc_entry "routes.out" "/proc/sys/lnet/routes" "$BR" "$L1" "$L2"
9413 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
9414 remove_lnet_proc_files "routes"
9416 # /proc/sys/lnet/routers should look like this:
9417 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
9418 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
9419 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
9420 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
9421 L1="^ref +rtr_ref +alive_cnt +state +last_ping +ping_sent +deadline +down_ni +router$"
9422 BR="^$P +$P +$N +(up|down) +$N +(0|1) +$I +$I +$NID$"
9423 create_lnet_proc_files "routers"
9424 check_lnet_proc_entry "routers.out" "/proc/sys/lnet/routers" "$BR" "$L1"
9425 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
9426 remove_lnet_proc_files "routers"
9428 # /proc/sys/lnet/peers should look like this:
9429 # nid refs state last max rtr min tx min queue
9430 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
9431 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
9432 # numeric (0 or >0 or <0), queue >= 0.
9433 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
9434 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
9435 create_lnet_proc_files "peers"
9436 check_lnet_proc_entry "peers.out" "/proc/sys/lnet/peers" "$BR" "$L1"
9437 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
9438 remove_lnet_proc_files "peers"
9440 # /proc/sys/lnet/buffers should look like this:
9441 # pages count credits min
9442 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
9443 L1="^pages +count +credits +min$"
9444 BR="^ +$N +$N +$I +$I$"
9445 create_lnet_proc_files "buffers"
9446 check_lnet_proc_entry "buffers.out" "/proc/sys/lnet/buffers" "$BR" "$L1"
9447 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
9448 remove_lnet_proc_files "buffers"
9450 # /proc/sys/lnet/nis should look like this:
9451 # nid status alive refs peer rtr max tx min
9452 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
9453 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
9454 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
9455 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
9456 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
9457 create_lnet_proc_files "nis"
9458 check_lnet_proc_entry "nis.out" "/proc/sys/lnet/nis" "$BR" "$L1"
9459 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
9460 remove_lnet_proc_files "nis"
9462 # can we successfully write to /proc/sys/lnet/stats?
9463 echo "0" >/proc/sys/lnet/stats || error "cannot write to /proc/sys/lnet/stats"
9464 sysctl -w lnet.stats=0 || error "cannot write to lnet.stats"
9466 run_test 215 "/proc/sys/lnet exists and has proper content - bugs 18102, 21079, 21517"
9468 test_216() { # bug 20317
9469 remote_ost_nodsh && skip "remote OST with nodsh" && return
9471 local p="$TMP/sanityN-$TESTNAME.parameters"
9472 save_lustre_params $HOSTNAME "osc.*.contention_seconds" > $p
9473 for node in $(osts_nodes); do
9474 save_lustre_params $node "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
9475 save_lustre_params $node "ldlm.namespaces.filter-*.contended_locks" >> $p
9476 save_lustre_params $node "ldlm.namespaces.filter-*.contention_seconds" >> $p
9480 # agressive lockless i/o settings
9481 for node in $(osts_nodes); do
9482 do_node $node 'lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes 2000000; lctl set_param -n ldlm.namespaces.filter-*.contended_locks 0; lctl set_param -n ldlm.namespaces.filter-*.contention_seconds 60'
9484 lctl set_param -n osc.*.contention_seconds 60
9486 $DIRECTIO write $DIR/$tfile 0 10 4096
9487 $CHECKSTAT -s 40960 $DIR/$tfile
9489 # disable lockless i/o
9490 for node in $(osts_nodes); do
9491 do_node $node 'lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes 0; lctl set_param -n ldlm.namespaces.filter-*.contended_locks 32; lctl set_param -n ldlm.namespaces.filter-*.contention_seconds 0'
9493 lctl set_param -n osc.*.contention_seconds 0
9496 dd if=/dev/zero of=$DIR/$tfile count=0
9497 $CHECKSTAT -s 0 $DIR/$tfile
9499 restore_lustre_params <$p
9503 run_test 216 "check lockless direct write works and updates file size and kms correctly"
9505 test_217() { # bug 22430
9509 for node in $(nodes_list); do
9510 nid=$(host_nids_address $node $NETTYPE)
9511 if [[ $nid = *-* ]] ; then
9512 echo "lctl ping $nid@$NETTYPE"
9513 lctl ping $nid@$NETTYPE
9515 echo "skipping $node (no hyphen detected)"
9519 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
9522 # do directio so as not to populate the page cache
9523 log "creating a 10 Mb file"
9524 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
9525 log "starting reads"
9526 dd if=$DIR/$tfile of=/dev/null bs=4096 &
9527 log "truncating the file"
9528 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
9530 kill %+ || true # reads might have finished
9531 echo "wait until dd is finished"
9533 log "removing the temporary file"
9534 rm -rf $DIR/$tfile || error "tmp file removal failed"
9536 run_test 218 "parallel read and truncate should not deadlock ======================="
9539 # write one partial page
9540 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
9541 # set no grant so vvp_io_commit_write will do sync write
9542 $LCTL set_param fail_loc=0x411
9543 # write a full page at the end of file
9544 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
9546 $LCTL set_param fail_loc=0
9547 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
9548 $LCTL set_param fail_loc=0x411
9549 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
9551 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
9553 test_220() { #LU-325
9554 remote_ost_nodsh && skip "remote OST with nodsh" && return
9558 local OST=$(lfs osts | grep ${OSTIDX}": " | \
9559 awk '{print $2}' | sed -e 's/_UUID$//')
9562 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
9563 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
9564 osc.$mdtosc_proc1.prealloc_last_id)
9565 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
9566 osc.$mdtosc_proc1.prealloc_next_id)
9570 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
9571 #define OBD_FAIL_OST_ENOINO 0x229
9572 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
9573 do_facet mgs $LCTL pool_new $FSNAME.$TESTNAME || return 1
9574 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
9576 $SETSTRIPE $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
9578 MDSOBJS=$((last_id - next_id))
9579 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
9581 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
9582 echo "OST still has $count kbytes free"
9584 echo "create $MDSOBJS files @next_id..."
9585 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
9587 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
9588 osc.$mdtosc_proc1.prealloc_last_id)
9589 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
9590 osc.$mdtosc_proc1.prealloc_next_id)
9592 echo "after creation, last_id=$last_id2, next_id=$next_id2"
9597 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
9598 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
9600 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST || return 4
9601 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME || return 5
9602 echo "unlink $MDSOBJS files @$next_id..."
9603 unlinkmany $DIR/$tdir/f $MDSOBJS || return 6
9605 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
9608 dd if=`which date` of=$MOUNT/date oflag=sync
9609 chmod +x $MOUNT/date
9611 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
9612 $LCTL set_param fail_loc=0x80001401
9614 $MOUNT/date > /dev/null
9617 run_test 221 "make sure fault and truncate race to not cause OOM"
9622 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
9623 createmany -o $DIR/$tdir/$tfile 10
9624 cancel_lru_locks mdc
9625 cancel_lru_locks osc
9626 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
9627 $LCTL set_param fail_loc=0x31a
9628 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
9629 $LCTL set_param fail_loc=0
9632 run_test 222a "AGL for ls should not trigger CLIO lock failure ================"
9637 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
9638 createmany -o $DIR/$tdir/$tfile 10
9639 cancel_lru_locks mdc
9640 cancel_lru_locks osc
9641 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
9642 $LCTL set_param fail_loc=0x31a
9643 rm -r $DIR/$tdir || "AGL for rmdir failed"
9644 $LCTL set_param fail_loc=0
9646 run_test 222b "AGL for rmdir should not trigger CLIO lock failure ============="
9651 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
9652 createmany -o $DIR/$tdir/$tfile 10
9653 cancel_lru_locks mdc
9654 cancel_lru_locks osc
9655 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
9656 $LCTL set_param fail_loc=0x31b
9657 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
9658 $LCTL set_param fail_loc=0
9661 run_test 223 "osc reenqueue if without AGL lock granted ======================="
9663 test_224a() { # LU-1039, MRP-303
9664 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
9665 $LCTL set_param fail_loc=0x508
9666 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
9667 $LCTL set_param fail_loc=0
9670 run_test 224a "Don't panic on bulk IO failure"
9672 test_224b() { # LU-1039, MRP-303
9673 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
9674 cancel_lru_locks osc
9675 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
9676 $LCTL set_param fail_loc=0x515
9677 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
9678 $LCTL set_param fail_loc=0
9681 run_test 224b "Don't panic on bulk IO failure"
9683 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
9685 if [ -z ${MDSSURVEY} ]; then
9686 skip_env "mds-survey not found" && return
9688 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
9689 { skip "Need MDS version at least 2.2.51"; return; }
9691 local mds=$(facet_host $SINGLEMDS)
9692 local target=$(do_nodes $mds 'lctl dl' | \
9693 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
9695 local cmd1="file_count=1000 thrhi=4"
9696 local cmd2="dir_count=2 layer=mdd stripe_count=0"
9697 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
9698 local cmd="$cmd1 $cmd2 $cmd3"
9700 rm -f ${TMP}/mds_survey*
9702 eval $cmd || error "mds-survey with zero-stripe failed"
9703 cat ${TMP}/mds_survey*
9704 rm -f ${TMP}/mds_survey*
9706 run_test 225a "Metadata survey sanity with zero-stripe"
9709 if [ -z ${MDSSURVEY} ]; then
9710 skip_env "mds-survey not found" && return
9712 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
9713 { skip "Need MDS version at least 2.2.51"; return; }
9715 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
9716 skip_env "Need to mount OST to test" && return
9719 local mds=$(facet_host $SINGLEMDS)
9720 local target=$(do_nodes $mds 'lctl dl' | \
9721 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
9723 local cmd1="file_count=1000 thrhi=4"
9724 local cmd2="dir_count=2 layer=mdd stripe_count=1"
9725 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
9726 local cmd="$cmd1 $cmd2 $cmd3"
9728 rm -f ${TMP}/mds_survey*
9730 eval $cmd || error "mds-survey with stripe_count failed"
9731 cat ${TMP}/mds_survey*
9732 rm -f ${TMP}/mds_survey*
9734 run_test 225b "Metadata survey sanity with stripe_count = 1"
9736 mcreate_path2fid () {
9742 local path=$DIR/$tdir/$name
9747 $MCREATE --mode=$1 --major=$2 --minor=$3 $path || \
9748 error "error: cannot create $desc"
9750 fid=$($LFS path2fid $path)
9752 [ $rc -ne 0 ] && error "error: cannot get fid of a $desc"
9754 fid_path=$($LFS fid2path $DIR $fid)
9756 [ $rc -ne 0 ] && error "error: cannot get path of a $desc by fid"
9758 [ "$path" == "$fid_path" ] || \
9759 error "error: fid2path returned \`$fid_path', expected \`$path'"
9766 mcreate_path2fid 0010666 0 0 fifo "FIFO"
9767 mcreate_path2fid 0020666 1 3 null "character special file (null)"
9768 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
9769 mcreate_path2fid 0040666 0 0 dir "directory"
9770 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
9771 mcreate_path2fid 0100666 0 0 file "regular file"
9772 mcreate_path2fid 0120666 0 0 link "symbolic link"
9773 mcreate_path2fid 0140666 0 0 sock "socket"
9775 run_test 226 "call path2fid and fid2path on files of all type"
9777 # LU-1299 Executing or running ldd on a truncated executable does not
9778 # cause an out-of-memory condition.
9780 dd if=`which date` of=$MOUNT/date bs=1k count=1
9781 chmod +x $MOUNT/date
9783 $MOUNT/date > /dev/null
9784 ldd $MOUNT/date > /dev/null
9787 run_test 227 "running truncated executable does not cause OOM"
9789 # LU-1512 try to reuse idle OI blocks
9791 [ "$FSTYPE" != "ldiskfs" ] && skip "non-ldiskfs backend" && return
9793 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
9794 local myDIR=$DIR/$tdir
9797 #define OBD_FAIL_SEQ_EXHAUST 0x1002
9798 $LCTL set_param fail_loc=0x80001002
9799 createmany -o $myDIR/t- 10000
9800 $LCTL set_param fail_loc=0
9801 # The guard is current the largest FID holder
9803 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
9805 local IDX=$(($SEQ % 64))
9807 do_facet $SINGLEMDS sync
9808 # Make sure journal flushed.
9810 local blk1=$(do_facet $SINGLEMDS \
9811 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
9812 grep Blockcount | awk '{print $4}')
9814 # Remove old files, some OI blocks will become idle.
9815 unlinkmany $myDIR/t- 10000
9816 # Create new files, idle OI blocks should be reused.
9817 createmany -o $myDIR/t- 2000
9818 do_facet $SINGLEMDS sync
9819 # Make sure journal flushed.
9821 local blk2=$(do_facet $SINGLEMDS \
9822 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
9823 grep Blockcount | awk '{print $4}')
9825 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
9827 run_test 228a "try to reuse idle OI blocks"
9830 [ "$FSTYPE" != "ldiskfs" ] && skip "non-ldiskfs backend" && return
9832 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
9833 local myDIR=$DIR/$tdir
9836 #define OBD_FAIL_SEQ_EXHAUST 0x1002
9837 $LCTL set_param fail_loc=0x80001002
9838 createmany -o $myDIR/t- 10000
9839 $LCTL set_param fail_loc=0
9840 # The guard is current the largest FID holder
9842 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
9844 local IDX=$(($SEQ % 64))
9846 do_facet $SINGLEMDS sync
9847 # Make sure journal flushed.
9849 local blk1=$(do_facet $SINGLEMDS \
9850 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
9851 grep Blockcount | awk '{print $4}')
9853 # Remove old files, some OI blocks will become idle.
9854 unlinkmany $myDIR/t- 10000
9857 stop $SINGLEMDS || error "Fail to stop MDT."
9859 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
9861 df $MOUNT || error "Fail to df."
9862 # Create new files, idle OI blocks should be reused.
9863 createmany -o $myDIR/t- 2000
9864 do_facet $SINGLEMDS sync
9865 # Make sure journal flushed.
9867 local blk2=$(do_facet $SINGLEMDS \
9868 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
9869 grep Blockcount | awk '{print $4}')
9871 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
9873 run_test 228b "idle OI blocks can be reused after MDT restart"
9877 [ "$FSTYPE" != "ldiskfs" ] && skip "non-ldiskfs backend" && return
9879 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
9880 local myDIR=$DIR/$tdir
9883 #define OBD_FAIL_SEQ_EXHAUST 0x1002
9884 $LCTL set_param fail_loc=0x80001002
9885 # 20000 files can guarantee there are index nodes in the OI file
9886 createmany -o $myDIR/t- 20000
9887 $LCTL set_param fail_loc=0
9888 # The guard is current the largest FID holder
9890 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
9892 local IDX=$(($SEQ % 64))
9894 do_facet $SINGLEMDS sync
9895 # Make sure journal flushed.
9897 local blk1=$(do_facet $SINGLEMDS \
9898 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
9899 grep Blockcount | awk '{print $4}')
9901 # Remove old files, some OI blocks will become idle.
9902 unlinkmany $myDIR/t- 20000
9904 # The OI file should become empty now
9906 # Create new files, idle OI blocks should be reused.
9907 createmany -o $myDIR/t- 2000
9908 do_facet $SINGLEMDS sync
9909 # Make sure journal flushed.
9911 local blk2=$(do_facet $SINGLEMDS \
9912 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
9913 grep Blockcount | awk '{print $4}')
9915 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
9917 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
9920 # tests that do cleanup/setup should be run at the end
9925 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
9926 $LCTL set_param fail_loc=0x903
9927 # cancel_lru_locks mgc - does not work due to lctl set_param syntax
9928 for ls in /proc/fs/lustre/ldlm/namespaces/MGC*/lru_size; do
9931 FAIL_ON_ERROR=true cleanup
9932 FAIL_ON_ERROR=true setup
9934 run_test 900 "umount should not race with any mgc requeue thread"
9937 check_and_cleanup_lustre
9938 if [ "$I_MOUNTED" != "yes" ]; then
9939 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true