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
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"
864 local FREE_INODES=`lfs df -i|grep "filesystem summary" | awk '{print $5}'`
865 [ $FREE_INODES -lt $NRFILES ] && \
866 skip "not enough free inodes $FREE_INODES required $NRFILES" && \
870 createmany -m $DIR/d24v/$tfile $NRFILES
873 lctl set_param mdc.*.stats clear
875 ls $DIR/d24v >/dev/null || error "error in listing large dir"
878 # DIRENT_SIZE = 32 bytes for sizeof(struct lu_dirent) +
879 # 8 bytes for name(filename is mostly 5 in this test) +
880 # 8 bytes for luda_type
881 # take into account of overhead in lu_dirpage header and end mark in
882 # each page, plus one in RPC_NUM calculation.
884 RPC_SIZE=$(($(lctl get_param -n mdc.*.max_pages_per_rpc)*$(page_size)))
885 RPC_NUM=$(((NRFILES * DIRENT_SIZE + RPC_SIZE - 1) / RPC_SIZE + 1))
886 mds_readpage=`lctl get_param mdc.*.stats | \
887 awk '/^mds_readpage/ {print $2}'`
888 [ $mds_readpage -gt $RPC_NUM ] && \
889 error "large readdir doesn't take effect"
893 run_test 24v "list directory with large files (handle hash collision, bug: 17560)"
895 test_24w() { # bug21506
897 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
898 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
899 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
900 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
901 [ "$SZ1" = "$SZ2" ] || \
902 error "Error reading at the end of the file $tfile"
904 run_test 24w "Reading a file larger than 4Gb"
907 echo '== symlink sanity ============================================='
911 touch $DIR/s25/foo || error
913 run_test 25a "create file in symlinked directory ==============="
916 [ ! -d $DIR/d25 ] && test_25a
917 $CHECKSTAT -t file $DIR/s25/foo || error
919 run_test 25b "lookup file in symlinked directory ==============="
924 ln -s d26/d26-2 $DIR/s26
925 touch $DIR/s26/foo || error
927 run_test 26a "multiple component symlink ======================="
930 mkdir -p $DIR/d26b/d26-2
931 ln -s d26b/d26-2/foo $DIR/s26-2
932 touch $DIR/s26-2 || error
934 run_test 26b "multiple component symlink at end of lookup ======"
939 ln -s d26.2 $DIR/s26.2-1
940 ln -s s26.2-1 $DIR/s26.2-2
941 ln -s s26.2-2 $DIR/s26.2-3
942 chmod 0666 $DIR/s26.2-3/foo
944 run_test 26c "chain of symlinks ================================"
946 # recursive symlinks (bug 439)
948 ln -s d26-3/foo $DIR/d26-3
950 run_test 26d "create multiple component recursive symlink ======"
953 [ ! -h $DIR/d26-3 ] && test_26d
956 run_test 26e "unlink multiple component recursive symlink ======"
958 # recursive symlinks (bug 7022)
961 mkdir $DIR/$tdir/$tfile || error "mkdir $DIR/$tdir/$tfile failed"
962 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
963 mkdir -p lndir/bar1 || error "mkdir lndir/bar1 failed"
964 mkdir $tfile || error "mkdir $tfile failed"
965 cd $tfile || error "cd $tfile failed"
966 ln -s .. dotdot || error "ln dotdot failed"
967 ln -s dotdot/lndir lndir || error "ln lndir failed"
968 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
969 output=`ls $tfile/$tfile/lndir/bar1`
970 [ "$output" = bar1 ] && error "unexpected output"
971 rm -r $tfile || error "rm $tfile failed"
972 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
974 run_test 26f "rm -r of a directory which has recursive symlink ="
977 echo '== stripe sanity =============================================='
978 mkdir -p $DIR/d27 || error "mkdir failed"
980 $SETSTRIPE -c 1 $DIR/d27/f0 || error "setstripe failed"
981 $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
983 log "== test_27a: write to one stripe file ========================="
984 cp /etc/hosts $DIR/d27/f0 || error
986 run_test 27a "one stripe file =================================="
989 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
991 $SETSTRIPE -c 2 $DIR/d27/f01 || error "setstripe failed"
992 $GETSTRIPE -c $DIR/d27/f01
993 [ $($GETSTRIPE -c $DIR/d27/f01) -eq 2 ] ||
994 error "two-stripe file doesn't have two stripes"
996 run_test 27b "create two stripe file"
999 [ -f $DIR/d27/f01 ] || skip "test_27b not run" && return
1001 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
1003 run_test 27c "write to two stripe file"
1007 $SETSTRIPE -c 0 -i -1 -S 0 $DIR/d27/fdef || error "setstripe failed"
1008 $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
1009 dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
1011 run_test 27d "create file with default settings ================"
1015 $SETSTRIPE -c 2 $DIR/d27/f12 || error "setstripe failed"
1016 $SETSTRIPE -c 2 $DIR/d27/f12 && error "setstripe succeeded twice"
1017 $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
1019 run_test 27e "setstripe existing file (should return error) ======"
1023 $SETSTRIPE -S 100 -i 0 -c 1 $DIR/d27/fbad && error "setstripe failed"
1024 dd if=/dev/zero of=$DIR/d27/f12 bs=4k count=4 || error "dd failed"
1025 $GETSTRIPE $DIR/d27/fbad || error "$GETSTRIPE failed"
1027 run_test 27f "setstripe with bad stripe size (should return error)"
1031 $MCREATE $DIR/d27/fnone || error "mcreate failed"
1032 $GETSTRIPE $DIR/d27/fnone 2>&1 | grep "no stripe info" ||
1033 error "$DIR/d27/fnone has object"
1035 run_test 27g "$GETSTRIPE with no objects"
1038 touch $DIR/d27/fsome || error "touch failed"
1039 [ $($GETSTRIPE -c $DIR/d27/fsome) -gt 0 ] || error "missing objects"
1041 run_test 27i "$GETSTRIPE with some objects"
1045 $SETSTRIPE -i $OSTCOUNT $DIR/d27/f27j && error "setstripe failed"||true
1047 run_test 27j "setstripe with bad stripe offset (should return error)"
1049 test_27k() { # bug 2844
1052 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
1053 [ ! -d $DIR/d27 ] && mkdir -p $DIR/d27
1054 $SETSTRIPE -S 67108864 $FILE || error "setstripe failed"
1055 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1056 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
1057 dd if=/dev/zero of=$FILE bs=4k count=1
1058 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1059 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
1061 run_test 27k "limit i_blksize for broken user apps ============="
1065 mcreate $DIR/f27l || error "creating file"
1066 $RUNAS $SETSTRIPE -c 1 $DIR/f27l && \
1067 error "setstripe should have failed" || true
1069 run_test 27l "check setstripe permissions (should return error)"
1072 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1073 if [ $ORIGFREE -gt $MAXFREE ]; then
1074 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1078 $SETSTRIPE -i 0 -c 1 $DIR/d27/f27m_1
1079 dd if=/dev/zero of=$DIR/d27/f27m_1 bs=1024 count=$MAXFREE &&
1080 error "dd should fill OST0"
1082 while $SETSTRIPE -i 0 -c 1 $DIR/d27/f27m_$i; do
1084 [ $i -gt 256 ] && break
1087 touch $DIR/d27/f27m_$i
1088 [ `$GETSTRIPE $DIR/d27/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] && \
1089 error "OST0 was full but new created file still use it"
1091 touch $DIR/d27/f27m_$i
1092 [ `$GETSTRIPE $DIR/d27/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] && \
1093 error "OST0 was full but new created file still use it"
1097 run_test 27m "create file while OST0 was full =================="
1100 local DELAY=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage | head -n 1 | awk '{print $1 * 2}')
1104 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1105 # if the OST isn't full anymore.
1107 local OSTIDX=${1:-""}
1109 local list=$(comma_list $(osts_nodes))
1110 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1112 do_nodes $list lctl set_param fail_loc=0
1113 sync # initiate all OST_DESTROYs from MDS to OST
1117 exhaust_precreations() {
1120 local FAILIDX=${3:-$OSTIDX}
1123 local MDSIDX=$(get_mds_dir "$DIR/$tdir")
1124 echo OSTIDX=$OSTIDX MDSIDX=$MDSIDX
1126 local OST=$(ostname_from_index $OSTIDX)
1127 local MDT_INDEX=$(lfs df | grep "\[MDT:$((MDSIDX - 1))\]" | awk '{print $1}' | \
1128 sed -e 's/_UUID$//;s/^.*-//')
1131 local mdtosc_proc1=$(get_mdtosc_proc_path mds${MDSIDX} $OST)
1132 local last_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1133 osc.$mdtosc_proc1.prealloc_last_id)
1134 local next_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1135 osc.$mdtosc_proc1.prealloc_next_id)
1137 local mdtosc_proc2=$(get_mdtosc_proc_path mds${MDSIDX})
1138 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1140 mkdir -p $DIR/$tdir/${OST}
1141 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1142 #define OBD_FAIL_OST_ENOSPC 0x215
1143 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=$FAILIDX
1144 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x215
1145 echo "Creating to objid $last_id on ost $OST..."
1146 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1147 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1148 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=$FAILLOC
1152 exhaust_all_precreations() {
1154 for (( i=0; i < OSTCOUNT; i++ )) ; do
1155 exhaust_precreations $i $1 -1
1160 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1161 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1162 remote_ost_nodsh && skip "remote OST with nodsh" && return
1165 rm -f $DIR/$tdir/$tfile
1166 exhaust_precreations 0 0x80000215
1167 $SETSTRIPE -c -1 $DIR/$tdir
1168 touch $DIR/$tdir/$tfile || error
1169 $GETSTRIPE $DIR/$tdir/$tfile
1172 run_test 27n "create file with some full OSTs =================="
1175 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1176 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1177 remote_ost_nodsh && skip "remote OST with nodsh" && return
1180 rm -f $DIR/$tdir/$tfile
1181 exhaust_all_precreations 0x215
1183 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1188 run_test 27o "create file with all full OSTs (should error) ===="
1191 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1192 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1193 remote_ost_nodsh && skip "remote OST with nodsh" && return
1196 rm -f $DIR/$tdir/$tfile
1199 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1200 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1201 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1203 exhaust_precreations 0 0x80000215
1204 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1205 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1206 $GETSTRIPE $DIR/$tdir/$tfile
1210 run_test 27p "append to a truncated file with some full OSTs ==="
1213 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1214 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1215 remote_ost_nodsh && skip "remote OST with nodsh" && return
1218 rm -f $DIR/$tdir/$tfile
1221 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1222 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||error "truncate $DIR/$tdir/$tfile failed"
1223 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1225 exhaust_all_precreations 0x215
1227 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1228 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1232 run_test 27q "append to truncated file with all OSTs full (should error) ==="
1235 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1236 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1237 remote_ost_nodsh && skip "remote OST with nodsh" && return
1240 rm -f $DIR/$tdir/$tfile
1241 exhaust_precreations 0 0x80000215
1243 $SETSTRIPE -i 0 -c 2 $DIR/$tdir/$tfile # && error
1247 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1249 test_27s() { # bug 10725
1251 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1252 local stripe_count=0
1253 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1254 $SETSTRIPE -S $stripe_size -c $stripe_count $DIR/$tdir &&
1255 error "stripe width >= 2^32 succeeded" || true
1258 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1260 test_27t() { # bug 10864
1265 $WLFS getstripe $tfile
1268 run_test 27t "check that utils parse path correctly"
1270 test_27u() { # bug 4900
1271 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1272 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1274 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1275 do_facet $SINGLEMDS lctl set_param fail_loc=0x139
1277 createmany -o $DIR/$tdir/t- 1000
1278 do_facet $SINGLEMDS lctl set_param fail_loc=0
1280 TLOG=$DIR/$tfile.getstripe
1281 $GETSTRIPE $DIR/$tdir > $TLOG
1282 OBJS=`awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj;}' $TLOG`
1283 unlinkmany $DIR/$tdir/t- 1000
1284 [ $OBJS -gt 0 ] && \
1285 error "$OBJS objects created on OST-0. See $TLOG" || pass
1287 run_test 27u "skip object creation on OSC w/o objects =========="
1289 test_27v() { # bug 4900
1290 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1291 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1292 remote_ost_nodsh && skip "remote OST with nodsh" && return
1294 exhaust_all_precreations 0x215
1298 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1300 touch $DIR/$tdir/$tfile
1301 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1303 for (( i=1; i < OSTCOUNT; i++ )); do
1304 do_facet ost$i lctl set_param fail_loc=0x705
1306 local START=`date +%s`
1307 createmany -o $DIR/$tdir/$tfile 32
1309 local FINISH=`date +%s`
1310 local TIMEOUT=`lctl get_param -n timeout`
1311 local PROCESS=$((FINISH - START))
1312 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1313 error "$FINISH - $START >= $TIMEOUT / 2"
1314 sleep $((TIMEOUT / 2 - PROCESS))
1317 run_test 27v "skip object creation on slow OST ================="
1319 test_27w() { # bug 10997
1320 mkdir -p $DIR/$tdir || error "mkdir failed"
1321 $SETSTRIPE -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1322 [ $($GETSTRIPE -S $DIR/$tdir/f0) -ne 65536 ] &&
1323 error "stripe size $size != 65536" || true
1324 [ $($GETSTRIPE -d $DIR/$tdir | grep -c "stripe_count") -ne 1 ] &&
1325 error "$GETSTRIPE -d $DIR/$tdir failed" || true
1327 run_test 27w "check $SETSTRIPE -S option"
1330 [ "$OSTCOUNT" -lt "2" ] &&
1331 skip_env "skipping multiple stripe count/offset test" && return
1333 mkdir -p $DIR/$tdir || error "mkdir failed"
1334 for i in $(seq 1 $OSTCOUNT); do
1336 $SETSTRIPE -c $i -i $offset $DIR/$tdir/f$i ||
1337 error "setstripe -c $i -i $offset failed"
1338 count=$($GETSTRIPE -c $DIR/$tdir/f$i)
1339 index=$($GETSTRIPE -i $DIR/$tdir/f$i)
1340 [ $count -ne $i ] && error "stripe count $count != $i" || true
1341 [ $index -ne $offset ] &&
1342 error "stripe offset $index != $offset" || true
1345 run_test 27wa "check $SETSTRIPE -c -i options"
1348 remote_ost_nodsh && skip "remote OST with nodsh" && return
1349 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs" && return
1350 OFFSET=$(($OSTCOUNT - 1))
1352 local OST=$(ostname_from_index $OSTIDX)
1355 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe per file
1356 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1358 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1359 for i in `seq 0 $OFFSET`; do
1360 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}' | grep -w "$OSTIDX"` ] &&
1361 error "OST0 was degraded but new created file still use it"
1363 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1365 run_test 27x "create files while OST0 is degraded"
1368 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1369 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1370 remote_ost_nodsh && skip "remote OST with nodsh" && return
1372 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1373 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1374 osc.$mdtosc.prealloc_last_id)
1375 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1376 osc.$mdtosc.prealloc_next_id)
1377 local fcount=$((last_id - next_id))
1378 [ $fcount -eq 0 ] && skip "not enough space on OST0" && return
1379 [ $fcount -gt $OSTCOUNT ] && fcount=$OSTCOUNT
1381 MDS_OSCS=`do_facet $SINGLEMDS lctl dl | awk '/[oO][sS][cC].*md[ts]/ { print $4 }'`
1382 OFFSET=$(($OSTCOUNT-1))
1384 for OSC in $MDS_OSCS; do
1385 if [ $OST == -1 ]; then {
1386 OST=`osc_to_ost $OSC`
1388 echo $OSC "is Deactivate:"
1389 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1393 OSTIDX=$(index_from_ostuuid $OST)
1395 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1397 do_facet ost$((OSTIDX+1)) lctl set_param -n obdfilter.$OST.degraded 1
1399 createmany -o $DIR/$tdir/$tfile $fcount
1400 do_facet ost$((OSTIDX+1)) lctl set_param -n obdfilter.$OST.degraded 0
1402 for i in `seq 0 $OFFSET`; do
1403 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "$OSTIDX"` ] || \
1404 error "files created on deactivated OSTs instead of degraded OST"
1406 for OSC in $MDS_OSCS; do
1407 [ `osc_to_ost $OSC` != $OST ] && {
1408 echo $OSC "is activate"
1409 do_facet $SINGLEMDS lctl --device %$OSC activate
1413 run_test 27y "create files while OST0 is degraded and the rest inactive"
1419 lmm_count=$($GETSTRIPE -c $1)
1420 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1421 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1423 local old_ifs="$IFS"
1425 fid=($($LFS path2fid $1))
1428 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1429 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1431 # compare lmm_seq and lu_fid->f_seq
1432 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1433 # compare lmm_object_id and lu_fid->oid
1434 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1436 # check the trusted.fid attribute of the OST objects of the file
1437 local have_obdidx=false
1439 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1440 # skip lines up to and including "obdidx"
1441 [ -z "$obdidx" ] && break
1442 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1443 $have_obdidx || continue
1445 local ost=$((obdidx + 1))
1446 local dev=$(ostdevname $ost)
1448 if [ $(facet_fstype ost$ost) != ldiskfs ]; then
1449 echo "Currently only works with ldiskfs-based OSTs"
1453 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1455 #don't unmount/remount the OSTs if we don't need to do that
1456 #local dir=$(facet_mntpt ost$ost)
1458 #do_facet ost$dev mount -t $FSTYPE $dev $dir $OST_MOUNT_OPTS ||
1459 # { error "mounting $dev as $FSTYPE failed"; return 3; }
1460 #local obj_file=$(do_facet ost$ost find $dir/O/$seq -name $oid)
1461 #local ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID $obj_file)
1463 local obj_file="O/$seq/d$((oid %32))/$oid"
1464 local ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
1465 $dev 2>/dev/null" | grep "parent=")
1467 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
1469 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
1471 #do_facet ost$ost umount -d $dir
1472 #start ost$ost $dev $OST_MOUNT_OPTS
1474 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
1475 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
1476 local ff_parent=$(echo $ff|sed -e 's/.*parent=.//')
1477 local ff_pseq=$(echo $ff_parent | cut -d: -f1)
1478 local ff_poid=$(echo $ff_parent | cut -d: -f2)
1479 local ff_pstripe=$(echo $ff_parent | sed -e 's/.*stripe=//')
1481 # compare lmm_seq and filter_fid->ff_parent.f_seq
1482 [ $ff_pseq = $lmm_seq ] ||
1483 error "FF parent SEQ $ff_pseq != $lmm_seq"
1484 # compare lmm_object_id and filter_fid->ff_parent.f_oid
1485 [ $ff_poid = $lmm_oid ] ||
1486 error "FF parent OID $ff_poid != $lmm_oid"
1487 [ $ff_pstripe = $stripe_nr ] ||
1488 error "FF stripe $ff_pstripe != $stripe_nr"
1490 stripe_nr=$((stripe_nr + 1))
1495 remote_ost_nodsh && skip "remote OST with nodsh" && return
1498 $SETSTRIPE -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
1499 { error "setstripe -c -1 failed"; return 1; }
1500 # We need to send a write to every object to get parent FID info set.
1501 # This _should_ also work for setattr, but does not currently.
1502 # touch $DIR/$tdir/$tfile-1 ||
1503 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
1504 { error "dd $tfile-1 failed"; return 2; }
1505 $SETSTRIPE -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
1506 { error "setstripe -c -1 failed"; return 3; }
1507 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
1508 { error "dd $tfile-2 failed"; return 4; }
1510 # make sure write RPCs have been sent to OSTs
1513 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
1514 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
1516 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
1518 test_27A() { # b=19102
1519 local restore_size=$($GETSTRIPE -S $MOUNT)
1520 local restore_count=$($GETSTRIPE -c $MOUNT)
1521 local restore_offset=$($GETSTRIPE -i $MOUNT)
1522 $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
1523 local default_size=$($GETSTRIPE -S $MOUNT)
1524 local default_count=$($GETSTRIPE -c $MOUNT)
1525 local default_offset=$($GETSTRIPE -i $MOUNT)
1526 local dsize=$((1024 * 1024))
1527 [ $default_size -eq $dsize ] ||
1528 error "stripe size $default_size != $dsize"
1529 [ $default_count -eq 1 ] || error "stripe count $default_count != 1"
1530 [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
1531 $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
1533 run_test 27A "check filesystem-wide default LOV EA values"
1535 # createtest also checks that device nodes are created and
1536 # then visible correctly (#2091)
1537 test_28() { # bug 2091
1539 $CREATETEST $DIR/d28/ct || error
1541 run_test 28 "create/mknod/mkdir with bad file types ============"
1544 cancel_lru_locks mdc
1550 declare -i LOCKCOUNTORIG=0
1551 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1552 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
1554 [ $LOCKCOUNTORIG -eq 0 ] && echo "No mdc lock count" && return 1
1556 declare -i LOCKUNUSEDCOUNTORIG=0
1557 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1558 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
1565 declare -i LOCKCOUNTCURRENT=0
1566 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1567 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
1570 declare -i LOCKUNUSEDCOUNTCURRENT=0
1571 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1572 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
1575 if [ "$LOCKCOUNTCURRENT" -gt "$LOCKCOUNTORIG" ]; then
1576 lctl set_param -n ldlm.dump_namespaces ""
1577 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
1578 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1579 log "dumped log to $TMP/test_29.dk (bug 5793)"
1582 if [ "$LOCKUNUSEDCOUNTCURRENT" -gt "$LOCKUNUSEDCOUNTORIG" ]; then
1583 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
1584 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1585 log "dumped log to $TMP/test_29.dk (bug 5793)"
1589 run_test 29 "IT_GETATTR regression ============================"
1591 test_30a() { # was test_30
1592 cp `which ls` $DIR || cp /bin/ls $DIR
1596 run_test 30a "execute binary from Lustre (execve) =============="
1599 cp `which ls` $DIR || cp /bin/ls $DIR
1601 $RUNAS $DIR/ls / || error
1604 run_test 30b "execute binary from Lustre as non-root ==========="
1606 test_30c() { # b=22376
1607 cp `which ls` $DIR || cp /bin/ls $DIR
1609 cancel_lru_locks mdc
1610 cancel_lru_locks osc
1611 $RUNAS $DIR/ls / || error
1614 run_test 30c "execute binary from Lustre without read perms ===="
1617 $OPENUNLINK $DIR/f31 $DIR/f31 || error
1618 $CHECKSTAT -a $DIR/f31 || error
1620 run_test 31a "open-unlink file =================================="
1623 touch $DIR/f31 || error
1624 ln $DIR/f31 $DIR/f31b || error
1625 $MULTIOP $DIR/f31b Ouc || error
1626 $CHECKSTAT -t file $DIR/f31 || error
1628 run_test 31b "unlink file with multiple links while open ======="
1631 touch $DIR/f31 || error
1632 ln $DIR/f31 $DIR/f31c || error
1633 multiop_bg_pause $DIR/f31 O_uc || return 1
1635 $MULTIOP $DIR/f31c Ouc
1636 kill -USR1 $MULTIPID
1639 run_test 31c "open-unlink file with multiple links ============="
1642 opendirunlink $DIR/d31d $DIR/d31d || error
1643 $CHECKSTAT -a $DIR/d31d || error
1645 run_test 31d "remove of open directory ========================="
1647 test_31e() { # bug 2904
1648 check_kernel_version 34 || return 0
1649 openfilleddirunlink $DIR/d31e || error
1651 run_test 31e "remove of open non-empty directory ==============="
1653 test_31f() { # bug 4554
1656 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
1657 cp /etc/hosts $DIR/d31f
1659 $GETSTRIPE $DIR/d31f/hosts
1660 multiop_bg_pause $DIR/d31f D_c || return 1
1663 rm -rv $DIR/d31f || error "first of $DIR/d31f"
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 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
1673 wait $MULTIPID || error "first opendir $MULTIPID failed"
1677 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
1678 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
1681 run_test 31f "remove of open directory with open-unlink file ==="
1684 echo "-- cross directory link --"
1685 mkdir $DIR/d31g{a,b}
1687 ln $DIR/d31ga/f $DIR/d31gb/g
1688 $CHECKSTAT -t file $DIR/d31ga/f || error "source"
1689 [ `stat -c%h $DIR/d31ga/f` == '2' ] || error "source nlink"
1690 $CHECKSTAT -t file $DIR/d31gb/g || error "target"
1691 [ `stat -c%h $DIR/d31gb/g` == '2' ] || error "target nlink"
1693 run_test 31g "cross directory link==============="
1696 echo "-- cross directory link --"
1700 ln $DIR/d31h/f $DIR/d31h/dir/g
1701 $CHECKSTAT -t file $DIR/d31h/f || error "source"
1702 [ `stat -c%h $DIR/d31h/f` == '2' ] || error "source nlink"
1703 $CHECKSTAT -t file $DIR/d31h/dir/g || error "target"
1704 [ `stat -c%h $DIR/d31h/dir/g` == '2' ] || error "target nlink"
1706 run_test 31h "cross directory link under child==============="
1709 echo "-- cross directory link --"
1712 touch $DIR/d31i/dir/f
1713 ln $DIR/d31i/dir/f $DIR/d31i/g
1714 $CHECKSTAT -t file $DIR/d31i/dir/f || error "source"
1715 [ `stat -c%h $DIR/d31i/dir/f` == '2' ] || error "source nlink"
1716 $CHECKSTAT -t file $DIR/d31i/g || error "target"
1717 [ `stat -c%h $DIR/d31i/g` == '2' ] || error "target nlink"
1719 run_test 31i "cross directory link under parent==============="
1724 mkdir $DIR/d31j/dir1
1725 ln $DIR/d31j/dir1 $DIR/d31j/dir2 && error "ln for dir"
1726 link $DIR/d31j/dir1 $DIR/d31j/dir3 && error "link for dir"
1727 mlink $DIR/d31j/dir1 $DIR/d31j/dir4 && error "mlink for dir"
1728 mlink $DIR/d31j/dir1 $DIR/d31j/dir1 && error "mlink to the same dir"
1731 run_test 31j "link for directory==============="
1737 touch $DIR/d31k/exist
1738 mlink $DIR/d31k/s $DIR/d31k/t || error "mlink"
1739 mlink $DIR/d31k/s $DIR/d31k/exist && error "mlink to exist file"
1740 mlink $DIR/d31k/s $DIR/d31k/s && error "mlink to the same file"
1741 mlink $DIR/d31k/s $DIR/d31k && error "mlink to parent dir"
1742 mlink $DIR/d31k $DIR/d31k/s && error "mlink parent dir to target"
1743 mlink $DIR/d31k/not-exist $DIR/d31k/foo && error "mlink non-existing to new"
1744 mlink $DIR/d31k/not-exist $DIR/d31k/s && error "mlink non-existing to exist"
1747 run_test 31k "link to file: the same, non-existing, dir==============="
1753 touch $DIR/d31m2/exist
1754 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
1755 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
1756 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
1757 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
1758 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
1759 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
1762 run_test 31m "link to file: the same, non-existing, dir==============="
1765 echo "== more mountpoints and symlinks ================="
1766 [ -e $DIR/d32a ] && rm -fr $DIR/d32a
1767 mkdir -p $DIR/d32a/ext2-mountpoint
1768 mount -t ext2 -o loop $EXT2_DEV $DIR/d32a/ext2-mountpoint || error
1769 $CHECKSTAT -t dir $DIR/d32a/ext2-mountpoint/.. || error
1770 $UMOUNT $DIR/d32a/ext2-mountpoint || error
1772 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
1775 [ -e $DIR/d32b ] && rm -fr $DIR/d32b
1776 mkdir -p $DIR/d32b/ext2-mountpoint
1777 mount -t ext2 -o loop $EXT2_DEV $DIR/d32b/ext2-mountpoint || error
1778 ls -al $DIR/d32b/ext2-mountpoint/.. || error
1779 $UMOUNT $DIR/d32b/ext2-mountpoint || error
1781 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
1784 [ -e $DIR/d32c ] && rm -fr $DIR/d32c
1785 mkdir -p $DIR/d32c/ext2-mountpoint
1786 mount -t ext2 -o loop $EXT2_DEV $DIR/d32c/ext2-mountpoint || error
1787 mkdir -p $DIR/d32c/d2/test_dir
1788 $CHECKSTAT -t dir $DIR/d32c/ext2-mountpoint/../d2/test_dir || error
1789 $UMOUNT $DIR/d32c/ext2-mountpoint || error
1791 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
1794 [ -e $DIR/d32d ] && rm -fr $DIR/d32d
1795 mkdir -p $DIR/d32d/ext2-mountpoint
1796 mount -t ext2 -o loop $EXT2_DEV $DIR/d32d/ext2-mountpoint || error
1797 mkdir -p $DIR/d32d/d2/test_dir
1798 ls -al $DIR/d32d/ext2-mountpoint/../d2/test_dir || error
1799 $UMOUNT $DIR/d32d/ext2-mountpoint || error
1801 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
1804 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
1805 mkdir -p $DIR/d32e/tmp
1806 TMP_DIR=$DIR/d32e/tmp
1807 ln -s $DIR/d32e $TMP_DIR/symlink11
1808 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1809 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
1810 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
1812 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
1815 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
1816 mkdir -p $DIR/d32f/tmp
1817 TMP_DIR=$DIR/d32f/tmp
1818 ln -s $DIR/d32f $TMP_DIR/symlink11
1819 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1820 ls $DIR/d32f/tmp/symlink11 || error
1821 ls $DIR/d32f/symlink01 || error
1823 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
1826 TMP_DIR=$DIR/$tdir/tmp
1827 mkdir -p $TMP_DIR $DIR/${tdir}2
1828 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
1829 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1830 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
1831 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
1832 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
1833 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
1835 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
1838 rm -fr $DIR/$tdir $DIR/${tdir}2
1839 TMP_DIR=$DIR/$tdir/tmp
1840 mkdir -p $TMP_DIR $DIR/${tdir}2
1841 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
1842 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1843 ls $TMP_DIR/symlink12 || error
1844 ls $DIR/$tdir/symlink02 || error
1846 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
1849 [ -e $DIR/d32i ] && rm -fr $DIR/d32i
1850 mkdir -p $DIR/d32i/ext2-mountpoint
1851 mount -t ext2 -o loop $EXT2_DEV $DIR/d32i/ext2-mountpoint || error
1852 touch $DIR/d32i/test_file
1853 $CHECKSTAT -t file $DIR/d32i/ext2-mountpoint/../test_file || error
1854 $UMOUNT $DIR/d32i/ext2-mountpoint || error
1856 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
1859 [ -e $DIR/d32j ] && rm -fr $DIR/d32j
1860 mkdir -p $DIR/d32j/ext2-mountpoint
1861 mount -t ext2 -o loop $EXT2_DEV $DIR/d32j/ext2-mountpoint || error
1862 touch $DIR/d32j/test_file
1863 cat $DIR/d32j/ext2-mountpoint/../test_file || error
1864 $UMOUNT $DIR/d32j/ext2-mountpoint || error
1866 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
1870 mkdir -p $DIR/d32k/ext2-mountpoint
1871 mount -t ext2 -o loop $EXT2_DEV $DIR/d32k/ext2-mountpoint
1872 mkdir -p $DIR/d32k/d2
1873 touch $DIR/d32k/d2/test_file || error
1874 $CHECKSTAT -t file $DIR/d32k/ext2-mountpoint/../d2/test_file || error
1875 $UMOUNT $DIR/d32k/ext2-mountpoint || error
1877 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
1881 mkdir -p $DIR/d32l/ext2-mountpoint
1882 mount -t ext2 -o loop $EXT2_DEV $DIR/d32l/ext2-mountpoint || error
1883 mkdir -p $DIR/d32l/d2
1884 touch $DIR/d32l/d2/test_file
1885 cat $DIR/d32l/ext2-mountpoint/../d2/test_file || error
1886 $UMOUNT $DIR/d32l/ext2-mountpoint || error
1888 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
1892 mkdir -p $DIR/d32m/tmp
1893 TMP_DIR=$DIR/d32m/tmp
1894 ln -s $DIR $TMP_DIR/symlink11
1895 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1896 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
1897 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
1899 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
1903 mkdir -p $DIR/d32n/tmp
1904 TMP_DIR=$DIR/d32n/tmp
1905 ln -s $DIR $TMP_DIR/symlink11
1906 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1907 ls -l $DIR/d32n/tmp/symlink11 || error
1908 ls -l $DIR/d32n/symlink01 || error
1910 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
1913 rm -fr $DIR/d32o $DIR/$tfile
1915 mkdir -p $DIR/d32o/tmp
1916 TMP_DIR=$DIR/d32o/tmp
1917 ln -s $DIR/$tfile $TMP_DIR/symlink12
1918 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1919 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
1920 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
1921 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
1922 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
1924 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
1934 mkdir -p $DIR/d32p/tmp
1936 TMP_DIR=$DIR/d32p/tmp
1938 ln -s $DIR/$tfile $TMP_DIR/symlink12
1940 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1942 cat $DIR/d32p/tmp/symlink12 || error
1944 cat $DIR/d32p/symlink02 || error
1947 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
1950 [ -e $DIR/d32q ] && rm -fr $DIR/d32q
1952 touch $DIR/d32q/under_the_mount
1953 mount -t ext2 -o loop $EXT2_DEV $DIR/d32q
1954 ls $DIR/d32q/under_the_mount && error || true
1955 $UMOUNT $DIR/d32q || error
1957 run_test 32q "stat follows mountpoints in Lustre (should return error)"
1960 [ -e $DIR/d32r ] && rm -fr $DIR/d32r
1962 touch $DIR/d32r/under_the_mount
1963 mount -t ext2 -o loop $EXT2_DEV $DIR/d32r
1964 ls $DIR/d32r | grep -q under_the_mount && error || true
1965 $UMOUNT $DIR/d32r || error
1967 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
1972 chmod 444 $DIR/$tfile
1973 chown $RUNAS_ID $DIR/$tfile
1975 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
1978 run_test 33 "write file with mode 444 (should return error) ===="
1983 chown $RUNAS_ID $DIR/d33
1984 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
1985 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
1986 error "open RDWR" || true
1988 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
1993 chown $RUNAS_ID $DIR/d33
1994 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33 && error "create" || true
1996 run_test 33b "test open file with malformed flags (No panic and return error)"
2004 remote_ost_nodsh && skip "remote OST with nodsh" && return
2008 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2011 for ostnum in $(seq $OSTCOUNT); do
2012 # test-framework's OST numbering is one-based, while Lustre's
2014 ostname=$(printf "$FSNAME-OST%.4d" $((ostnum - 1)))
2015 # Parsing llobdstat's output sucks; we could grep the /proc
2016 # path, but that's likely to not be as portable as using the
2017 # llobdstat utility. So we parse lctl output instead.
2018 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2019 obdfilter/$ostname/stats |
2020 awk '/^write_bytes/ {print $7}' )
2021 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2022 if (( ${write_bytes:-0} > 0 ))
2029 $all_zeros || return 0
2032 echo foo > $DIR/d33/bar
2036 # Total up write_bytes after writing. We'd better find non-zeros.
2037 for ostnum in $(seq $OSTCOUNT); do
2038 ostname=$(printf "$FSNAME-OST%.4d" $((ostnum - 1)))
2039 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2040 obdfilter/$ostname/stats |
2041 awk '/^write_bytes/ {print $7}' )
2042 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2043 if (( ${write_bytes:-0} > 0 ))
2052 for ostnum in $(seq $OSTCOUNT); do
2053 ostname=$(printf "$FSNAME-OST%.4d" $((ostnum - 1)))
2054 echo "Check that write_bytes is present in obdfilter/*/stats:"
2055 do_facet ost$ostnum lctl get_param -n \
2056 obdfilter/$ostname/stats
2058 error "OST not keeping write_bytes stats (b22312)"
2061 run_test 33c "test llobdstat and write_bytes"
2063 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
2066 $MCREATE $DIR/f34 || error
2067 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2068 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
2069 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2070 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2072 run_test 34a "truncate file that has not been opened ==========="
2075 [ ! -f $DIR/f34 ] && test_34a
2076 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2077 $OPENFILE -f O_RDONLY $DIR/f34
2078 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2079 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2081 run_test 34b "O_RDONLY opening file doesn't create objects ====="
2084 [ ! -f $DIR/f34 ] && test_34a
2085 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2086 $OPENFILE -f O_RDWR $DIR/f34
2087 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2088 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2090 run_test 34c "O_RDWR opening file-with-size works =============="
2093 [ ! -f $DIR/f34 ] && test_34a
2094 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2095 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2098 run_test 34d "write to sparse file ============================="
2102 $MCREATE $DIR/f34e || error
2103 $TRUNCATE $DIR/f34e 1000 || error
2104 $CHECKSTAT -s 1000 $DIR/f34e || error
2105 $OPENFILE -f O_RDWR $DIR/f34e
2106 $CHECKSTAT -s 1000 $DIR/f34e || error
2108 run_test 34e "create objects, some with size and some without =="
2110 test_34f() { # bug 6242, 6243
2113 $MCREATE $DIR/f34f || error
2114 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
2115 dd if=$DIR/f34f of=$TMP/f34f
2116 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
2117 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
2118 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
2119 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
2120 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
2122 run_test 34f "read from a file with no objects until EOF ======="
2125 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
2126 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
2127 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
2128 cancel_lru_locks osc
2129 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
2130 error "wrong size after lock cancel"
2132 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
2133 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2134 error "expanding truncate failed"
2135 cancel_lru_locks osc
2136 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2137 error "wrong expanded size after lock cancel"
2139 run_test 34g "truncate long file ==============================="
2145 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
2146 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
2150 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
2151 error "Multiop blocked on ftruncate, pid=$MULTIPID"
2155 local nsz=`stat -c %s $DIR/$tfile`
2156 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
2158 run_test 34h "ftruncate file under grouplock should not block"
2161 cp /bin/sh $DIR/f35a
2163 chown $RUNAS_ID $DIR/f35a
2164 $RUNAS $DIR/f35a && error || true
2167 run_test 35a "exec file with mode 444 (should return and not leak) ====="
2171 utime $DIR/f36 || error
2173 run_test 36a "MDS utime check (mknod, utime) ==================="
2177 utime $DIR/f36 || error
2179 run_test 36b "OST utime check (open, utime) ===================="
2184 chown $RUNAS_ID $DIR/d36
2185 $RUNAS utime $DIR/d36/f36 || error
2187 run_test 36c "non-root MDS utime check (mknod, utime) =========="
2190 [ ! -d $DIR/d36 ] && test_36c
2191 echo "" > $DIR/d36/f36
2192 $RUNAS utime $DIR/d36/f36 || error
2194 run_test 36d "non-root OST utime check (open, utime) ==========="
2197 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
2199 touch $DIR/$tdir/$tfile
2200 $RUNAS utime $DIR/$tdir/$tfile && \
2201 error "utime worked, expected failure" || true
2203 run_test 36e "utime on non-owned file (should return error) ===="
2207 local LANG_SAVE=$LANG
2208 local LC_LANG_SAVE=$LC_LANG
2209 export LANG=C LC_LANG=C # for date language
2211 DATESTR="Dec 20 2000"
2213 lctl set_param fail_loc=$fl
2215 cp /etc/hosts $DIR/$tdir/$tfile
2216 sync & # write RPC generated with "current" inode timestamp, but delayed
2218 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
2219 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
2220 cancel_lru_locks osc
2221 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
2223 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
2224 echo "BEFORE: $LS_BEFORE" && \
2225 echo "AFTER : $LS_AFTER" && \
2226 echo "WANT : $DATESTR" && \
2227 error "$DIR/$tdir/$tfile timestamps changed" || true
2229 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
2233 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2234 subr_36fh "0x80000214"
2236 run_test 36f "utime on file racing with OST BRW write =========="
2239 remote_ost_nodsh && skip "remote OST with nodsh" && return
2245 fmd_max_age=$(do_facet ost1 \
2246 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
2249 fmd_before=$(do_facet ost1 \
2250 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2251 touch $DIR/$tdir/$tfile
2252 sleep $((fmd_max_age + 12))
2253 fmd_after=$(do_facet ost1 \
2254 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2256 echo "fmd_before: $fmd_before"
2257 echo "fmd_after: $fmd_after"
2258 [ "$fmd_after" -gt "$fmd_before" ] && \
2259 echo "AFTER: $fmd_after > BEFORE: $fmd_before" && \
2260 error "fmd didn't expire after ping" || true
2262 run_test 36g "filter mod data cache expiry ====================="
2265 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
2266 subr_36fh "0x80000227"
2268 run_test 36h "utime on file racing with OST BRW write =========="
2272 echo f > $DIR/$tdir/fbugfile
2273 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2274 ls $DIR/$tdir | grep "\<fbugfile\>" && error
2275 $UMOUNT $DIR/$tdir || error
2276 rm -f $DIR/$tdir/fbugfile || error
2278 run_test 37 "ls a mounted file system to check old content ====="
2281 local file=$DIR/$tfile
2283 openfile -f O_DIRECTORY $file
2286 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
2287 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
2289 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
2293 touch $DIR/${tfile}2
2294 # ls -l $DIR/$tfile $DIR/${tfile}2
2295 # ls -lu $DIR/$tfile $DIR/${tfile}2
2296 # ls -lc $DIR/$tfile $DIR/${tfile}2
2298 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
2299 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
2301 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
2303 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
2305 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
2306 error "O_TRUNC didn't change timestamps"
2309 run_test 39 "mtime changed on create ==========================="
2313 cp -p /etc/passwd $DIR/$tdir/fopen
2314 cp -p /etc/passwd $DIR/$tdir/flink
2315 cp -p /etc/passwd $DIR/$tdir/funlink
2316 cp -p /etc/passwd $DIR/$tdir/frename
2317 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
2320 echo "aaaaaa" >> $DIR/$tdir/fopen
2321 echo "aaaaaa" >> $DIR/$tdir/flink
2322 echo "aaaaaa" >> $DIR/$tdir/funlink
2323 echo "aaaaaa" >> $DIR/$tdir/frename
2325 local open_new=`stat -c %Y $DIR/$tdir/fopen`
2326 local link_new=`stat -c %Y $DIR/$tdir/flink`
2327 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
2328 local rename_new=`stat -c %Y $DIR/$tdir/frename`
2330 cat $DIR/$tdir/fopen > /dev/null
2331 ln $DIR/$tdir/flink $DIR/$tdir/flink2
2332 rm -f $DIR/$tdir/funlink2
2333 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
2335 for (( i=0; i < 2; i++ )) ; do
2336 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
2337 local link_new2=`stat -c %Y $DIR/$tdir/flink`
2338 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
2339 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
2341 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
2342 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
2343 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
2344 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
2346 cancel_lru_locks osc
2347 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2350 run_test 39b "mtime change on open, link, unlink, rename ======"
2352 # this should be set to past
2353 TEST_39_MTIME=`date -d "1 year ago" +%s`
2359 local mtime0=`stat -c %Y $DIR1/$tfile`
2361 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2362 local mtime1=`stat -c %Y $DIR1/$tfile`
2363 [ "$mtime1" = $TEST_39_MTIME ] || \
2364 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
2367 echo hello >> $DIR1/$tfile
2369 local mtime2=`stat -c %Y $DIR1/$tfile`
2370 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
2371 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
2373 mv $DIR1/$tfile $DIR1/$tfile-1
2375 for (( i=0; i < 2; i++ )) ; do
2376 local mtime3=`stat -c %Y $DIR1/$tfile-1`
2377 [ "$mtime2" = "$mtime3" ] || \
2378 error "mtime ($mtime2) changed (to $mtime3) on rename"
2380 cancel_lru_locks osc
2381 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2384 run_test 39c "mtime change on rename ==========================="
2390 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2392 for (( i=0; i < 2; i++ )) ; do
2393 local mtime=`stat -c %Y $DIR1/$tfile`
2394 [ $mtime = $TEST_39_MTIME ] || \
2395 error "mtime($mtime) is not set to $TEST_39_MTIME"
2397 cancel_lru_locks osc
2398 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2401 run_test 39d "create, utime, stat =============================="
2406 local mtime1=`stat -c %Y $DIR1/$tfile`
2408 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2410 for (( i=0; i < 2; i++ )) ; do
2411 local mtime2=`stat -c %Y $DIR1/$tfile`
2412 [ $mtime2 = $TEST_39_MTIME ] || \
2413 error "mtime($mtime2) is not set to $TEST_39_MTIME"
2415 cancel_lru_locks osc
2416 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2419 run_test 39e "create, stat, utime, stat ========================"
2424 mtime1=`stat -c %Y $DIR1/$tfile`
2427 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2429 for (( i=0; i < 2; i++ )) ; do
2430 local mtime2=`stat -c %Y $DIR1/$tfile`
2431 [ $mtime2 = $TEST_39_MTIME ] || \
2432 error "mtime($mtime2) is not set to $TEST_39_MTIME"
2434 cancel_lru_locks osc
2435 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2438 run_test 39f "create, stat, sleep, utime, stat ================="
2442 echo hello >> $DIR1/$tfile
2443 local mtime1=`stat -c %Y $DIR1/$tfile`
2446 chmod o+r $DIR1/$tfile
2448 for (( i=0; i < 2; i++ )) ; do
2449 local mtime2=`stat -c %Y $DIR1/$tfile`
2450 [ "$mtime1" = "$mtime2" ] || \
2451 error "lost mtime: $mtime2, should be $mtime1"
2453 cancel_lru_locks osc
2454 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2457 run_test 39g "write, chmod, stat ==============================="
2465 echo hello >> $DIR1/$tfile
2466 local mtime1=`stat -c %Y $DIR1/$tfile`
2468 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2470 if [ "$d1" != "$d2" ]; then
2471 echo "write and touch not within one second"
2473 for (( i=0; i < 2; i++ )) ; do
2474 local mtime2=`stat -c %Y $DIR1/$tfile`
2475 [ "$mtime2" = $TEST_39_MTIME ] || \
2476 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
2478 cancel_lru_locks osc
2479 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2483 run_test 39h "write, utime within one second, stat ============="
2489 echo hello >> $DIR1/$tfile
2490 local mtime1=`stat -c %Y $DIR1/$tfile`
2492 mv $DIR1/$tfile $DIR1/$tfile-1
2494 for (( i=0; i < 2; i++ )) ; do
2495 local mtime2=`stat -c %Y $DIR1/$tfile-1`
2497 [ "$mtime1" = "$mtime2" ] || \
2498 error "lost mtime: $mtime2, should be $mtime1"
2500 cancel_lru_locks osc
2501 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2504 run_test 39i "write, rename, stat =============================="
2507 start_full_debug_logging
2511 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
2512 lctl set_param fail_loc=0x80000412
2513 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
2514 error "multiop failed"
2516 local mtime1=`stat -c %Y $DIR1/$tfile`
2518 mv $DIR1/$tfile $DIR1/$tfile-1
2520 kill -USR1 $multipid
2521 wait $multipid || error "multiop close failed"
2523 for (( i=0; i < 2; i++ )) ; do
2524 local mtime2=`stat -c %Y $DIR1/$tfile-1`
2525 [ "$mtime1" = "$mtime2" ] ||
2526 error "mtime is lost on close: $mtime2, " \
2529 cancel_lru_locks osc
2530 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2532 lctl set_param fail_loc=0
2533 stop_full_debug_logging
2535 run_test 39j "write, rename, close, stat ======================="
2541 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
2543 local mtime1=`stat -c %Y $DIR1/$tfile`
2545 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2547 kill -USR1 $multipid
2548 wait $multipid || error "multiop close failed"
2550 for (( i=0; i < 2; i++ )) ; do
2551 local mtime2=`stat -c %Y $DIR1/$tfile`
2553 [ "$mtime2" = $TEST_39_MTIME ] || \
2554 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
2556 cancel_lru_locks osc
2557 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2560 run_test 39k "write, utime, close, stat ========================"
2562 # this should be set to future
2563 TEST_39_ATIME=`date -d "1 year" +%s`
2565 is_sles11() # LU-1783
2567 if [ -r /etc/SuSE-release ]
2569 local vers=`grep VERSION /etc/SuSE-release | awk '{print $3}'`
2570 local patchlev=`grep PATCHLEVEL /etc/SuSE-release \
2572 if [ $vers -eq 11 ] && [ $patchlev -eq 1 ]
2581 is_sles11 && skip "SLES 11 SP1" && return # LU-1783
2582 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2583 local atime_diff=$(do_facet $SINGLEMDS lctl get_param -n mdd.*.atime_diff)
2587 # test setting directory atime to future
2588 touch -a -d @$TEST_39_ATIME $DIR/$tdir
2589 local atime=$(stat -c %X $DIR/$tdir)
2590 [ "$atime" = $TEST_39_ATIME ] || \
2591 error "atime is not set to future: $atime, should be $TEST_39_ATIME"
2593 # test setting directory atime from future to now
2594 local d1=$(date +%s)
2596 local d2=$(date +%s)
2598 cancel_lru_locks mdc
2599 atime=$(stat -c %X $DIR/$tdir)
2600 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
2601 error "atime is not updated from future: $atime, should be $d1<atime<$d2"
2603 do_facet $SINGLEMDS lctl set_param -n mdd.*.atime_diff=2
2606 # test setting directory atime when now > dir atime + atime_diff
2610 cancel_lru_locks mdc
2611 atime=$(stat -c %X $DIR/$tdir)
2612 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
2613 error "atime is not updated : $atime, should be $d2"
2615 do_facet $SINGLEMDS lctl set_param -n mdd.*.atime_diff=60
2618 # test not setting directory atime when now < dir atime + atime_diff
2620 cancel_lru_locks mdc
2621 atime=$(stat -c %X $DIR/$tdir)
2622 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
2623 error "atime is updated to $atime, should remain $d1<atime<$d2"
2625 do_facet $SINGLEMDS lctl set_param -n mdd.*.atime_diff=$atime_diff
2627 run_test 39l "directory atime update ==========================="
2632 local far_past_mtime=$(date -d "May 29 1953" +%s)
2633 local far_past_atime=$(date -d "Dec 17 1903" +%s)
2635 touch -m -d @$far_past_mtime $DIR1/$tfile
2636 touch -a -d @$far_past_atime $DIR1/$tfile
2638 for (( i=0; i < 2; i++ )) ; do
2639 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
2640 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
2641 error "atime or mtime set incorrectly"
2643 cancel_lru_locks osc
2644 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2647 run_test 39m "test atime and mtime before 1970"
2650 dd if=/dev/zero of=$DIR/f40 bs=4096 count=1
2651 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/f40 && error
2652 $CHECKSTAT -t file -s 4096 $DIR/f40 || error
2654 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
2658 small_write $DIR/f41 18
2660 run_test 41 "test small file write + fstat ====================="
2662 count_ost_writes() {
2663 lctl get_param -n osc.*.stats |
2664 awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }'
2671 BG_DIRTY_RATIO_SAVE=10
2672 MAX_BG_DIRTY_RATIO=25
2676 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
2677 # dirty_ratio, dirty_background_ratio
2678 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
2679 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
2680 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
2681 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
2683 # if file not here, we are a 2.4 kernel
2684 kill -CONT `pidof kupdated`
2689 # setup the trap first, so someone cannot exit the test at the
2690 # exact wrong time and mess up a machine
2691 trap start_writeback EXIT
2692 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
2693 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
2694 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
2695 sysctl -w vm.dirty_writeback_centisecs=0
2696 sysctl -w vm.dirty_writeback_centisecs=0
2697 # save and increase /proc/sys/vm/dirty_ratio
2698 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
2699 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
2700 # save and increase /proc/sys/vm/dirty_background_ratio
2701 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
2702 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
2704 # if file not here, we are a 2.4 kernel
2705 kill -STOP `pidof kupdated`
2709 # ensure that all stripes have some grant before we test client-side cache
2711 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
2712 dd if=/dev/zero of=$i bs=4k count=1
2717 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
2718 # file truncation, and file removal.
2721 cancel_lru_locks osc
2723 sync; sleep 1; sync # just to be safe
2724 BEFOREWRITES=`count_ost_writes`
2725 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
2726 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
2727 AFTERWRITES=`count_ost_writes`
2728 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
2729 error "$BEFOREWRITES < $AFTERWRITES"
2732 run_test 42a "ensure that we don't flush on close =============="
2736 cancel_lru_locks osc
2739 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
2740 BEFOREWRITES=`count_ost_writes`
2741 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
2742 AFTERWRITES=`count_ost_writes`
2743 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
2744 error "$BEFOREWRITES < $AFTERWRITES on unlink"
2746 BEFOREWRITES=`count_ost_writes`
2747 sync || error "sync: $?"
2748 AFTERWRITES=`count_ost_writes`
2749 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
2750 error "$BEFOREWRITES < $AFTERWRITES on sync"
2752 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
2756 run_test 42b "test destroy of file with cached dirty data ======"
2758 # if these tests just want to test the effect of truncation,
2759 # they have to be very careful. consider:
2760 # - the first open gets a {0,EOF}PR lock
2761 # - the first write conflicts and gets a {0, count-1}PW
2762 # - the rest of the writes are under {count,EOF}PW
2763 # - the open for truncate tries to match a {0,EOF}PR
2764 # for the filesize and cancels the PWs.
2765 # any number of fixes (don't get {0,EOF} on open, match
2766 # composite locks, do smarter file size management) fix
2767 # this, but for now we want these tests to verify that
2768 # the cancellation with truncate intent works, so we
2769 # start the file with a full-file pw lock to match against
2770 # until the truncate.
2775 cancel_lru_locks osc
2777 # prime the file with 0,EOF PW to match
2781 # now the real test..
2782 dd if=/dev/zero of=$file bs=1024 count=100
2783 BEFOREWRITES=`count_ost_writes`
2784 $TRUNCATE $file $offset
2785 cancel_lru_locks osc
2786 AFTERWRITES=`count_ost_writes`
2792 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
2793 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
2796 run_test 42c "test partial truncate of file with cached dirty data"
2800 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
2801 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
2804 run_test 42d "test complete truncate of file with cached dirty data"
2806 test_42e() { # bug22074
2807 local TDIR=$DIR/${tdir}e
2808 local pagesz=$(page_size)
2809 local pages=16 # hardcoded 16 pages, don't change it.
2810 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
2811 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
2816 $SETSTRIPE -c 1 $TDIR
2817 createmany -o $TDIR/f $files
2819 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
2821 # we assume that with $OSTCOUNT files, at least one of them will
2822 # be allocated on OST0.
2823 warmup_files=$((OSTCOUNT * max_dirty_mb))
2824 createmany -o $TDIR/w $warmup_files
2826 # write a large amount of data into one file and sync, to get good
2827 # avail_grant number from OST.
2828 for ((i=0; i<$warmup_files; i++)); do
2829 idx=$($GETSTRIPE -i $TDIR/w$i)
2830 [ $idx -ne 0 ] && continue
2831 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
2834 [ $i -gt $warmup_files ] && error "OST0 is still cold"
2836 $LCTL get_param $proc_osc0/cur_dirty_bytes
2837 $LCTL get_param $proc_osc0/cur_grant_bytes
2839 # create as much dirty pages as we can while not to trigger the actual
2840 # RPCs directly. but depends on the env, VFS may trigger flush during this
2841 # period, hopefully we are good.
2842 for ((i=0; i<$warmup_files; i++)); do
2843 idx=$($GETSTRIPE -i $TDIR/w$i)
2844 [ $idx -ne 0 ] && continue
2845 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
2847 $LCTL get_param $proc_osc0/cur_dirty_bytes
2848 $LCTL get_param $proc_osc0/cur_grant_bytes
2850 # perform the real test
2851 $LCTL set_param $proc_osc0/rpc_stats 0
2852 for ((;i<$files; i++)); do
2853 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
2854 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
2857 $LCTL get_param $proc_osc0/rpc_stats
2860 local have_ppr=false
2861 $LCTL get_param $proc_osc0/rpc_stats |
2862 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
2863 # skip lines until we are at the RPC histogram data
2864 [ "$PPR" == "pages" ] && have_ppr=true && continue
2865 $have_ppr || continue
2867 # we only want the percent stat for < 16 pages
2868 [ $(echo $PPR | tr -d ':') -ge $pages ] && break
2870 percent=$((percent + WPCT))
2871 if [ $percent -gt 15 ]; then
2872 error "less than 16-pages write RPCs" \
2879 run_test 42e "verify sub-RPC writes are not done synchronously"
2883 cp -p /bin/ls $DIR/$tdir/$tfile
2884 $MULTIOP $DIR/$tdir/$tfile Ow_c &
2886 # give multiop a chance to open
2889 $DIR/$tdir/$tfile && error || true
2892 run_test 43 "execution of file opened for write should return -ETXTBSY"
2896 cp -p `which $MULTIOP` $DIR/d43/multiop || cp -p multiop $DIR/d43/multiop
2897 MULTIOP_PROG=$DIR/d43/multiop multiop_bg_pause $TMP/test43.junk O_c || return 1
2899 $MULTIOP $DIR/d43/multiop Oc && error "expected error, got success"
2900 kill -USR1 $MULTIOP_PID || return 2
2901 wait $MULTIOP_PID || return 3
2904 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
2908 cp -p `which $MULTIOP` $DIR/d43/multiop || cp -p multiop $DIR/d43/multiop
2909 MULTIOP_PROG=$DIR/d43/multiop multiop_bg_pause $TMP/test43.junk O_c || return 1
2911 $TRUNCATE $DIR/d43/multiop 0 && error "expected error, got success"
2912 kill -USR1 $MULTIOP_PID || return 2
2913 wait $MULTIOP_PID || return 3
2916 run_test 43b "truncate of file being executed should return -ETXTBSY"
2919 local testdir="$DIR/d43c"
2922 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
2923 ( cd $testdir && md5sum -c)
2925 run_test 43c "md5sum of copy into lustre========================"
2928 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
2929 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
2930 dd if=$DIR/f1 bs=4k count=1 > /dev/null
2932 run_test 44 "zero length read from a sparse stripe ============="
2935 local nstripe=`$LCTL lov_getconfig $DIR | grep default_stripe_count: | \
2937 [ -z "$nstripe" ] && skip "can't get stripe info" && return
2938 [ "$nstripe" -gt "$OSTCOUNT" ] && skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" && return
2939 local stride=`$LCTL lov_getconfig $DIR | grep default_stripe_size: | \
2941 if [ $nstripe -eq 0 -o $nstripe -eq -1 ] ; then
2942 nstripe=`$LCTL lov_getconfig $DIR | grep obd_count: | awk '{print $2}'`
2945 OFFSETS="0 $((stride/2)) $((stride-1))"
2946 for offset in $OFFSETS ; do
2947 for i in `seq 0 $((nstripe-1))`; do
2948 local GLOBALOFFSETS=""
2949 local size=$((((i + 2 * $nstripe )*$stride + $offset))) # Bytes
2950 local myfn=$DIR/d44a-$size
2951 echo "--------writing $myfn at $size"
2952 ll_sparseness_write $myfn $size || error "ll_sparseness_write"
2953 GLOBALOFFSETS="$GLOBALOFFSETS $size"
2954 ll_sparseness_verify $myfn $GLOBALOFFSETS \
2955 || error "ll_sparseness_verify $GLOBALOFFSETS"
2957 for j in `seq 0 $((nstripe-1))`; do
2958 size=$((((j + $nstripe )*$stride + $offset))) # Bytes
2959 ll_sparseness_write $myfn $size || error "ll_sparseness_write"
2960 GLOBALOFFSETS="$GLOBALOFFSETS $size"
2962 ll_sparseness_verify $myfn $GLOBALOFFSETS \
2963 || error "ll_sparseness_verify $GLOBALOFFSETS"
2968 run_test 44a "test sparse pwrite ==============================="
2972 for d in `lctl get_param -n osc.*.cur_dirty_bytes`; do
2978 before=`dirty_osc_total`
2979 echo executing "\"$*\""
2981 after=`dirty_osc_total`
2982 echo before $before, after $after
2986 # Obtain grants from OST if it supports it
2987 echo blah > ${f}_grant
2990 do_dirty_record "echo blah > $f"
2991 [ $before -eq $after ] && error "write wasn't cached"
2992 do_dirty_record "> $f"
2993 [ $before -gt $after ] || error "truncate didn't lower dirty count"
2994 do_dirty_record "echo blah > $f"
2995 [ $before -eq $after ] && error "write wasn't cached"
2996 do_dirty_record "sync"
2997 [ $before -gt $after ] || error "writeback didn't lower dirty count"
2998 do_dirty_record "echo blah > $f"
2999 [ $before -eq $after ] && error "write wasn't cached"
3000 do_dirty_record "cancel_lru_locks osc"
3001 [ $before -gt $after ] || error "lock cancellation didn't lower dirty count"
3004 run_test 45 "osc io page accounting ============================"
3006 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
3007 # test tickles a bug where re-dirtying a page was failing to be mapped to the
3008 # objects offset and an assert hit when an rpc was built with 1023's mapped
3009 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
3014 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3016 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
3017 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3021 run_test 46 "dirtying a previously written page ================"
3023 # test_47 is removed "Device nodes check" is moved to test_28
3025 test_48a() { # bug 2399
3026 check_kernel_version 34 || return 0
3029 mv $DIR/d48a $DIR/d48.new || error "move directory failed"
3030 mkdir $DIR/d48a || error "recreate directory failed"
3031 touch foo || error "'touch foo' failed after recreating cwd"
3032 mkdir bar || error "'mkdir foo' failed after recreating cwd"
3033 if check_kernel_version 44; then
3034 touch .foo || error "'touch .foo' failed after recreating cwd"
3035 mkdir .bar || error "'mkdir .foo' failed after recreating cwd"
3037 ls . > /dev/null || error "'ls .' failed after recreating cwd"
3038 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3039 cd . || error "'cd .' failed after recreating cwd"
3040 mkdir . && error "'mkdir .' worked after recreating cwd"
3041 rmdir . && error "'rmdir .' worked after recreating cwd"
3042 ln -s . baz || error "'ln -s .' failed after recreating cwd"
3043 cd .. || error "'cd ..' failed after recreating cwd"
3045 run_test 48a "Access renamed working dir (should return errors)="
3047 test_48b() { # bug 2399
3048 check_kernel_version 34 || return 0
3051 rmdir $DIR/d48b || error "remove cwd $DIR/d48b failed"
3052 touch foo && error "'touch foo' worked after removing cwd"
3053 mkdir foo && error "'mkdir foo' worked after removing cwd"
3054 if check_kernel_version 44; then
3055 touch .foo && error "'touch .foo' worked after removing cwd"
3056 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
3058 ls . > /dev/null && error "'ls .' worked after removing cwd"
3059 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3060 is_patchless || ( cd . && error "'cd .' worked after removing cwd" )
3061 mkdir . && error "'mkdir .' worked after removing cwd"
3062 rmdir . && error "'rmdir .' worked after removing cwd"
3063 ln -s . foo && error "'ln -s .' worked after removing cwd"
3064 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
3066 run_test 48b "Access removed working dir (should return errors)="
3068 test_48c() { # bug 2350
3069 check_kernel_version 36 || return 0
3070 #lctl set_param debug=-1
3072 mkdir -p $DIR/d48c/dir
3074 $TRACE rmdir $DIR/d48c/dir || error "remove cwd $DIR/d48c/dir failed"
3075 $TRACE touch foo && error "'touch foo' worked after removing cwd"
3076 $TRACE mkdir foo && error "'mkdir foo' worked after removing cwd"
3077 if check_kernel_version 44; then
3078 touch .foo && error "'touch .foo' worked after removing cwd"
3079 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
3081 $TRACE ls . && error "'ls .' worked after removing cwd"
3082 $TRACE ls .. || error "'ls ..' failed after removing cwd"
3083 is_patchless || ( $TRACE cd . && error "'cd .' worked after removing cwd" )
3084 $TRACE mkdir . && error "'mkdir .' worked after removing cwd"
3085 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
3086 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
3087 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
3089 run_test 48c "Access removed working subdir (should return errors)"
3091 test_48d() { # bug 2350
3092 check_kernel_version 36 || return 0
3093 #lctl set_param debug=-1
3095 mkdir -p $DIR/d48d/dir
3097 $TRACE rmdir $DIR/d48d/dir || error "remove cwd $DIR/d48d/dir failed"
3098 $TRACE rmdir $DIR/d48d || error "remove parent $DIR/d48d failed"
3099 $TRACE touch foo && error "'touch foo' worked after removing parent"
3100 $TRACE mkdir foo && error "'mkdir foo' worked after removing parent"
3101 if check_kernel_version 44; then
3102 touch .foo && error "'touch .foo' worked after removing parent"
3103 mkdir .foo && error "'mkdir .foo' worked after removing parent"
3105 $TRACE ls . && error "'ls .' worked after removing parent"
3106 $TRACE ls .. && error "'ls ..' worked after removing parent"
3107 is_patchless || ( $TRACE cd . && error "'cd .' worked after recreate parent" )
3108 $TRACE mkdir . && error "'mkdir .' worked after removing parent"
3109 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
3110 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
3111 is_patchless || ( $TRACE cd .. && error "'cd ..' worked after removing parent" || true )
3113 run_test 48d "Access removed parent subdir (should return errors)"
3115 test_48e() { # bug 4134
3116 check_kernel_version 41 || return 0
3117 #lctl set_param debug=-1
3119 mkdir -p $DIR/d48e/dir
3121 $TRACE rmdir $DIR/d48e/dir || error "remove cwd $DIR/d48e/dir failed"
3122 $TRACE rmdir $DIR/d48e || error "remove parent $DIR/d48e failed"
3123 $TRACE touch $DIR/d48e || error "'touch $DIR/d48e' failed"
3124 $TRACE chmod +x $DIR/d48e || error "'chmod +x $DIR/d48e' failed"
3125 # On a buggy kernel addition of "touch foo" after cd .. will
3126 # produce kernel oops in lookup_hash_it
3127 touch ../foo && error "'cd ..' worked after recreate parent"
3129 $TRACE rm $DIR/d48e || error "rm '$DIR/d48e' failed"
3131 run_test 48e "Access to recreated parent subdir (should return errors)"
3133 test_49() { # LU-1030
3134 # get ost1 size - lustre-OST0000
3135 ost1_size=$(do_facet ost1 lfs df |grep ${ost1_svc} |awk '{print $4}')
3136 # write 800M at maximum
3137 [ $ost1_size -gt 819200 ] && ost1_size=819200
3139 lfs setstripe -c 1 -i 0 $DIR/$tfile
3140 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
3143 # change max_pages_per_rpc while writing the file
3144 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
3145 local orig_mppc=`$LCTL get_param -n $osc1_mppc`
3146 # loop until dd process exits
3147 while ps ax -opid | grep -wq $dd_pid; do
3148 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
3149 sleep $((RANDOM % 5 + 1))
3151 # restore original max_pages_per_rpc
3152 $LCTL set_param $osc1_mppc=$orig_mppc
3153 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
3155 run_test 49 "Change max_pages_per_rpc won't break osc extent"
3161 ls /proc/$$/cwd || error
3163 run_test 50 "special situations: /proc symlinks ==============="
3165 test_51a() { # was test_51
3166 # bug 1516 - create an empty entry right after ".." then split dir
3169 $MCREATE $DIR/d51/bar
3171 createmany -m $DIR/d51/longfile 201
3173 while [ `ls -sd $DIR/d51 | awk '{ print $1 }'` -eq 4 ]; do
3174 $MCREATE $DIR/d51/longfile$FNUM
3179 ls -l $DIR/d51 > /dev/null || error
3181 run_test 51a "special situations: split htree with empty entry =="
3183 export NUMTEST=70000
3185 local BASE=$DIR/$tdir
3188 local mdtidx=$(printf "%04x" $($LFS getstripe -M $BASE))
3189 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
3190 [ $numfree -lt 21000 ] && skip "not enough free inodes ($numfree)" &&
3193 [ $numfree -lt $NUMTEST ] && NUMTEST=$(($numfree - 50)) &&
3194 echo "reduced count to $NUMTEST due to inodes"
3196 # need to check free space for the directories as well
3197 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
3198 numfree=$((blkfree / 4))
3199 [ $numfree -lt $NUMTEST ] && NUMTEST=$(($numfree - 50)) &&
3200 echo "reduced count to $NUMTEST due to blocks"
3202 createmany -d $BASE/d $NUMTEST && echo $NUMTEST > $BASE/fnum ||
3203 echo "failed" > $BASE/fnum
3205 run_test 51b "exceed 64k subdirectory nlink limit"
3207 test_51ba() { # LU-993
3208 local BASE=$DIR/$tdir
3209 # unlink all but 100 subdirectories, then check it still works
3211 [ -f $BASE/fnum ] && local NUMPREV=$(cat $BASE/fnum) && rm $BASE/fnum
3213 [ "$NUMPREV" != "failed" ] && NUMTEST=$NUMPREV
3214 local DELETE=$((NUMTEST - LEFT))
3216 # continue on to run this test even if 51b didn't finish,
3217 # just to delete the many subdirectories created.
3218 [ ! -d "${BASE}/d1" ] && skip "test_51b() not run" && return 0
3220 # for ldiskfs the nlink count should be 1, but this is OSD specific
3221 # and so this is listed for informational purposes only
3222 echo "nlink before: $(stat -c %h $BASE), created before: $NUMTEST"
3223 unlinkmany -d $BASE/d $DELETE
3226 if [ $RC -ne 0 ]; then
3227 if [ "$NUMPREV" == "failed" ]; then
3228 skip "previous setup failed"
3231 error "unlink of first $DELETE subdirs failed"
3236 echo "nlink between: $(stat -c %h $BASE)"
3237 # trim the first line of ls output
3238 local FOUND=$(($(ls -l ${BASE} | wc -l) - 1))
3239 [ $FOUND -ne $LEFT ] &&
3240 error "can't find subdirs: found only $FOUND/$LEFT"
3242 unlinkmany -d $BASE/d $DELETE $LEFT ||
3243 error "unlink of second $LEFT subdirs failed"
3244 # regardless of whether the backing filesystem tracks nlink accurately
3245 # or not, the nlink count shouldn't be more than "." and ".." here
3246 local AFTER=$(stat -c %h $BASE)
3247 [ $AFTER -gt 2 ] && error "nlink after: $AFTER > 2" ||
3248 echo "nlink after: $AFTER"
3250 run_test 51ba "verify nlink for many subdirectory cleanup"
3253 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3255 local ndirs=${TEST51BB_NDIRS:-10}
3256 local nfiles=${TEST51BB_NFILES:-100}
3258 local numfree=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
3260 [ $numfree -lt $(( ndirs * nfiles)) ] && \
3261 nfiles=$(( numfree / ndirs - 10 ))
3263 local dir=$DIR/d51bb
3265 local savePOLICY=$(lctl get_param -n lmv.*.placement)
3266 lctl set_param -n lmv.*.placement=CHAR
3269 local IUSED=$(lfs df -i $dir | grep MDT | awk '{print $3}')
3273 for ((i=0; i < $ndirs; i++)); do
3274 dirs[i]=$dir/$RANDOM
3275 echo Creating directory ${dirs[i]}
3278 echo Creating $nfiles in dir ${dirs[i]} ...
3279 echo "createmany -o ${dirs[i]}/$tfile- $nfiles"
3280 createmany -o ${dirs[i]}/$tfile- $nfiles
3286 IUSED=$(lfs df -i $dir | grep MDT | awk '{print $3}')
3290 for ((i=0; i<${#NEWUSED[@]}; i++)); do
3291 echo "mds $i: inodes count OLD ${OLDUSED[$i]} NEW ${NEWUSED[$i]}"
3292 [ ${OLDUSED[$i]} -lt ${NEWUSED[$i]} ] || rc=$((rc + 1))
3295 lctl set_param -n lmv.*.placement=$savePOLICY
3297 [ $rc -ne $MDSCOUNT ] || \
3298 error "Objects/inodes are not distributed over all mds servers"
3300 run_test 51bb "mkdir createmany CMD $MDSCOUNT ===================="
3303 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping test with few OSTs" && return
3305 createmany -o $DIR/d51d/t- 1000
3306 $GETSTRIPE $DIR/d51d > $TMP/files
3307 for N in `seq 0 $((OSTCOUNT - 1))`; do
3308 OBJS[$N]=`awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}' $TMP/files`
3309 OBJS0[$N]=`grep -A 1 idx $TMP/files | awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}'`
3310 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
3312 unlinkmany $DIR/d51d/t- 1000
3315 for N in `seq 1 $((OSTCOUNT - 1))`; do
3316 [ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ] && \
3317 error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
3318 [ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ] && \
3319 error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
3321 [ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ] && \
3322 error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
3323 [ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ] && \
3324 error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
3328 run_test 51d "check object distribution ===================="
3331 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
3334 chattr +a $DIR/d52a/foo || error "chattr +a failed"
3335 echo bar >> $DIR/d52a/foo || error "append bar failed"
3336 cp /etc/hosts $DIR/d52a/foo && error "cp worked"
3337 rm -f $DIR/d52a/foo 2>/dev/null && error "rm worked"
3338 link $DIR/d52a/foo $DIR/d52a/foo_link 2>/dev/null && error "link worked"
3339 echo foo >> $DIR/d52a/foo || error "append foo failed"
3340 mrename $DIR/d52a/foo $DIR/d52a/foo_ren && error "rename worked"
3341 lsattr $DIR/d52a/foo | egrep -q "^-+a[-e]+ $DIR/d52a/foo" || error "lsattr"
3342 chattr -a $DIR/d52a/foo || error "chattr -a failed"
3343 cp -r $DIR/d52a /tmp/
3344 rm -fr $DIR/d52a || error "cleanup rm failed"
3346 run_test 52a "append-only flag test (should return errors) ====="
3349 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
3352 chattr +i $DIR/d52b/foo || error "chattr +i failed"
3353 cat test > $DIR/d52b/foo && error "cat test worked"
3354 cp /etc/hosts $DIR/d52b/foo && error "cp worked"
3355 rm -f $DIR/d52b/foo 2>/dev/null && error "rm worked"
3356 link $DIR/d52b/foo $DIR/d52b/foo_link 2>/dev/null && error "link worked"
3357 echo foo >> $DIR/d52b/foo && error "echo worked"
3358 mrename $DIR/d52b/foo $DIR/d52b/foo_ren && error "rename worked"
3359 [ -f $DIR/d52b/foo ] || error
3360 [ -f $DIR/d52b/foo_ren ] && error
3361 lsattr $DIR/d52b/foo | egrep -q "^-+i[-e]+ $DIR/d52b/foo" || error "lsattr"
3362 chattr -i $DIR/d52b/foo || error "chattr failed"
3364 rm -fr $DIR/d52b || error
3366 run_test 52b "immutable flag test (should return errors) ======="
3369 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3370 remote_ost_nodsh && skip "remote OST with nodsh" && return
3379 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
3380 for value in $(do_facet $SINGLEMDS lctl get_param osc.$mdtosc.prealloc_last_id) ; do
3381 param=`echo ${value[0]} | cut -d "=" -f1`
3382 ostname=`echo $param | cut -d "." -f2 | cut -d - -f 1-2`
3383 mds_last=$(do_facet $SINGLEMDS lctl get_param -n $param)
3384 ostnum=$(echo $ostname | sed "s/${FSNAME}-OST//g" | awk '{print ($1+1)}' )
3385 ost_last=$(do_facet ost$ostnum lctl get_param -n obdfilter.$ostname.last_id | head -n 1)
3386 echo "$ostname.last_id=$ost_last ; MDS.last_id=$mds_last"
3387 if [ $ost_last != $mds_last ]; then
3388 error "$ostname.last_id=$ost_last ; MDS.last_id=$mds_last"
3392 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
3395 [ ! -f "$SOCKETSERVER" ] && skip_env "no socketserver, skipping" && return
3396 [ ! -f "$SOCKETCLIENT" ] && skip_env "no socketclient, skipping" && return
3397 $SOCKETSERVER $DIR/socket
3398 $SOCKETCLIENT $DIR/socket || error
3399 $MUNLINK $DIR/socket
3401 run_test 54a "unix domain socket test =========================="
3407 dd if=/dev/zero of=$f bs=`page_size` count=1
3409 run_test 54b "char device works in lustre ======================"
3412 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
3413 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
3414 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
3416 for i in `seq 3 7`; do
3417 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
3427 loopdev="$DIR/loop54c"
3430 [ -z "$LOOPNUM" ] && echo "couldn't find empty loop device" && return
3431 mknod $loopdev b 7 $LOOPNUM
3432 echo "make a loop file system with $tfile on $loopdev ($LOOPNUM)..."
3433 dd if=/dev/zero of=$tfile bs=`page_size` seek=1024 count=1 > /dev/null
3434 losetup $loopdev $tfile || error "can't set up $loopdev for $tfile"
3435 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
3437 mount -t ext2 $loopdev $tdir || error "error mounting $loopdev on $tdir"
3438 dd if=/dev/zero of=$tdir/tmp bs=`page_size` count=30 || error "dd write"
3440 dd if=$tdir/tmp of=/dev/zero bs=`page_size` count=30 || error "dd read"
3445 run_test 54c "block device works in lustre ====================="
3451 [ "$string" = `echo $string > $f | cat $f` ] || error
3453 run_test 54d "fifo device works in lustre ======================"
3456 check_kernel_version 46 || return 0
3459 cp -aL /dev/console $f
3460 echo $string > $f || error
3462 run_test 54e "console/tty device works in lustre ======================"
3464 #The test_55 used to be iopen test and it was removed by bz#24037.
3465 #run_test 55 "check iopen_connect_dentry() ======================"
3467 test_56a() { # was test_56
3473 NUMFILESx2=$(($NUMFILES * 2))
3474 for i in `seq 1 $NUMFILES` ; do
3475 touch $DIR/d56/file$i
3476 touch $DIR/d56/dir/file$i
3479 # test lfs getstripe with --recursive
3480 FILENUM=`$GETSTRIPE --recursive $DIR/d56 | grep -c obdidx`
3481 [ $FILENUM -eq $NUMFILESx2 ] ||
3482 error "$GETSTRIPE --recursive: found $FILENUM, not $NUMFILESx2"
3483 FILENUM=`$GETSTRIPE $DIR/d56 | grep -c obdidx`
3484 [ $FILENUM -eq $NUMFILES ] ||
3485 error "$GETSTRIPE $DIR/d56: found $FILENUM, not $NUMFILES"
3486 echo "$GETSTRIPE --recursive passed."
3488 # test lfs getstripe with file instead of dir
3489 FILENUM=`$GETSTRIPE $DIR/d56/file1 | grep -c obdidx`
3490 [ $FILENUM -eq 1 ] || error \
3491 "$GETSTRIPE $DIR/d56/file1: found $FILENUM, not 1"
3492 echo "$GETSTRIPE file1 passed."
3494 #test lfs getstripe with --verbose
3495 [ `$GETSTRIPE --verbose $DIR/d56 | grep -c lmm_magic` -eq $NUMFILES ] ||
3496 error "$GETSTRIPE --verbose $DIR/d56: want $NUMFILES lmm_magic"
3497 [ `$GETSTRIPE $DIR/d56 | grep -c lmm_magic` -eq 0 ] ||
3498 error "$GETSTRIPE $DIR/d56: showed lmm_magic"
3499 echo "$GETSTRIPE --verbose passed."
3501 #test lfs getstripe with --obd
3502 $GETSTRIPE --obd wrong_uuid $DIR/d56 2>&1 | grep -q "unknown obduuid" ||
3503 error "$GETSTRIPE --obd wrong_uuid should return error message"
3505 [ "$OSTCOUNT" -lt 2 ] &&
3506 skip_env "skipping other $GETSTRIPE --obd test" && return
3509 OBDUUID=$(ostuuid_from_index $OSTIDX)
3510 FILENUM=`$GETSTRIPE -ir $DIR/d56 | grep -x $OSTIDX | wc -l`
3511 FOUND=`$GETSTRIPE -r --obd $OBDUUID $DIR/d56 | grep obdidx | wc -l`
3512 [ $FOUND -eq $FILENUM ] ||
3513 error "$GETSTRIPE --obd wrong: found $FOUND, expected $FILENUM"
3514 [ `$GETSTRIPE -r -v --obd $OBDUUID $DIR/d56 |
3515 sed '/^[ ]*'${OSTIDX}'[ ]/d' |
3516 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l` -eq 0 ] ||
3517 error "$GETSTRIPE --obd: should not show file on other obd"
3518 echo "$GETSTRIPE --obd passed"
3520 run_test 56a "check $GETSTRIPE"
3525 local LOCAL_NUMFILES="$1"
3526 local LOCAL_NUMDIRS="$2"
3527 local MKDIR_PARAMS="$3"
3529 if [ ! -d "$TDIR" ] ; then
3531 [ "$MKDIR_PARAMS" ] && $SETSTRIPE $MKDIR_PARAMS $TDIR
3532 for i in `seq 1 $LOCAL_NUMFILES` ; do
3535 for i in `seq 1 $LOCAL_NUMDIRS` ; do
3537 for j in `seq 1 $LOCAL_NUMFILES` ; do
3538 touch $TDIR/dir$i/file$j
3544 setup_56_special() {
3548 if [ ! -e "$TDIR/loop1b" ] ; then
3549 for i in `seq 1 $LOCAL_NUMFILES` ; do
3550 mknod $TDIR/loop${i}b b 7 $i
3551 mknod $TDIR/null${i}c c 1 3
3552 ln -s $TDIR/file1 $TDIR/link${i}l
3554 for i in `seq 1 $LOCAL_NUMDIRS` ; do
3555 mknod $TDIR/dir$i/loop${i}b b 7 $i
3556 mknod $TDIR/dir$i/null${i}c c 1 3
3557 ln -s $TDIR/dir$i/file1 $TDIR/dir$i/link${i}l
3566 setup_56 $NUMFILES $NUMDIRS
3568 EXPECTED=$(($NUMDIRS + 2))
3569 # test lfs find with -name
3570 for i in $(seq 1 $NUMFILES) ; do
3571 NUMS=$($LFIND -name "*$i" $TDIR | wc -l)
3572 [ $NUMS -eq $EXPECTED ] ||
3573 error "lfs find -name \"*$i\" $TDIR wrong: "\
3574 "found $NUMS, expected $EXPECTED"
3577 run_test 56g "check lfs find -name ============================="
3583 setup_56 $NUMFILES $NUMDIRS
3585 EXPECTED=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
3586 # test lfs find with ! -name
3587 for i in $(seq 1 $NUMFILES) ; do
3588 NUMS=$($LFIND ! -name "*$i" $TDIR | wc -l)
3589 [ $NUMS -eq $EXPECTED ] ||
3590 error "lfs find ! -name \"*$i\" $TDIR wrong: "\
3591 "found $NUMS, expected $EXPECTED"
3594 run_test 56h "check lfs find ! -name ============================="
3599 UUID=$(ostuuid_from_index 0 $DIR/$tdir)
3600 CMD="$LFIND -ost $UUID $DIR/$tdir"
3602 [ -z "$OUT" ] || error "\"$CMD\" returned directory '$OUT'"
3604 run_test 56i "check 'lfs find -ost UUID' skips directories ======="
3608 setup_56_special $NUMFILES $NUMDIRS
3610 EXPECTED=$((NUMDIRS + 1))
3611 CMD="$LFIND -type d $TDIR"
3612 NUMS=$($CMD | wc -l)
3613 [ $NUMS -eq $EXPECTED ] ||
3614 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3616 run_test 56j "check lfs find -type d ============================="
3620 setup_56_special $NUMFILES $NUMDIRS
3622 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
3623 CMD="$LFIND -type f $TDIR"
3624 NUMS=$($CMD | wc -l)
3625 [ $NUMS -eq $EXPECTED ] ||
3626 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3628 run_test 56k "check lfs find -type f ============================="
3632 setup_56_special $NUMFILES $NUMDIRS
3634 EXPECTED=$((NUMDIRS + NUMFILES))
3635 CMD="$LFIND -type b $TDIR"
3636 NUMS=$($CMD | wc -l)
3637 [ $NUMS -eq $EXPECTED ] ||
3638 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3640 run_test 56l "check lfs find -type b ============================="
3644 setup_56_special $NUMFILES $NUMDIRS
3646 EXPECTED=$((NUMDIRS + NUMFILES))
3647 CMD="$LFIND -type c $TDIR"
3648 NUMS=$($CMD | wc -l)
3649 [ $NUMS -eq $EXPECTED ] ||
3650 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3652 run_test 56m "check lfs find -type c ============================="
3656 setup_56_special $NUMFILES $NUMDIRS
3658 EXPECTED=$((NUMDIRS + NUMFILES))
3659 CMD="$LFIND -type l $TDIR"
3660 NUMS=$($CMD | wc -l)
3661 [ $NUMS -eq $EXPECTED ] ||
3662 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3664 run_test 56n "check lfs find -type l ============================="
3668 setup_56 $NUMFILES $NUMDIRS
3670 utime $TDIR/file1 > /dev/null || error "utime (1)"
3671 utime $TDIR/file2 > /dev/null || error "utime (2)"
3672 utime $TDIR/dir1 > /dev/null || error "utime (3)"
3673 utime $TDIR/dir2 > /dev/null || error "utime (4)"
3674 utime $TDIR/dir1/file1 > /dev/null || error "utime (5)"
3675 dd if=/dev/zero count=1 >> $TDIR/dir1/file1 && sync
3678 NUMS=`$LFIND -mtime +0 $TDIR | wc -l`
3679 [ $NUMS -eq $EXPECTED ] || \
3680 error "lfs find -mtime +0 $TDIR wrong: found $NUMS, expected $EXPECTED"
3683 CMD="$LFIND -mtime 0 $TDIR"
3684 NUMS=$($CMD | wc -l)
3685 [ $NUMS -eq $EXPECTED ] ||
3686 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3688 run_test 56o "check lfs find -mtime for old files =========================="
3691 [ $RUNAS_ID -eq $UID ] &&
3692 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
3695 setup_56 $NUMFILES $NUMDIRS
3697 chown $RUNAS_ID $TDIR/file* || error "chown $DIR/${tdir}g/file$i failed"
3699 CMD="$LFIND -uid $RUNAS_ID $TDIR"
3700 NUMS=$($CMD | wc -l)
3701 [ $NUMS -eq $EXPECTED ] || \
3702 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3704 EXPECTED=$(((NUMFILES + 1) * NUMDIRS + 1))
3705 CMD="$LFIND ! -uid $RUNAS_ID $TDIR"
3706 NUMS=$($CMD | wc -l)
3707 [ $NUMS -eq $EXPECTED ] || \
3708 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3710 run_test 56p "check lfs find -uid and ! -uid ==============================="
3713 [ $RUNAS_ID -eq $UID ] &&
3714 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
3717 setup_56 $NUMFILES $NUMDIRS
3719 chgrp $RUNAS_GID $TDIR/file* || error "chown $TDIR/file$i failed"
3722 CMD="$LFIND -gid $RUNAS_GID $TDIR"
3723 NUMS=$($CMD | wc -l)
3724 [ $NUMS -eq $EXPECTED ] ||
3725 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3727 EXPECTED=$(( ($NUMFILES+1) * $NUMDIRS + 1))
3728 CMD="$LFIND ! -gid $RUNAS_GID $TDIR"
3729 NUMS=$($CMD | wc -l)
3730 [ $NUMS -eq $EXPECTED ] ||
3731 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3733 run_test 56q "check lfs find -gid and ! -gid ==============================="
3737 setup_56 $NUMFILES $NUMDIRS
3740 CMD="$LFIND -size 0 -type f $TDIR"
3741 NUMS=$($CMD | wc -l)
3742 [ $NUMS -eq $EXPECTED ] ||
3743 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3745 CMD="$LFIND ! -size 0 -type f $TDIR"
3746 NUMS=$($CMD | wc -l)
3747 [ $NUMS -eq $EXPECTED ] ||
3748 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3749 echo "test" > $TDIR/$tfile
3750 echo "test2" > $TDIR/$tfile.2 && sync
3752 CMD="$LFIND -size 5 -type f $TDIR"
3753 NUMS=$($CMD | wc -l)
3754 [ $NUMS -eq $EXPECTED ] ||
3755 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3757 CMD="$LFIND -size +5 -type f $TDIR"
3758 NUMS=$($CMD | wc -l)
3759 [ $NUMS -eq $EXPECTED ] ||
3760 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3762 CMD="$LFIND -size +0 -type f $TDIR"
3763 NUMS=$($CMD | wc -l)
3764 [ $NUMS -eq $EXPECTED ] ||
3765 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3767 CMD="$LFIND ! -size -5 -type f $TDIR"
3768 NUMS=$($CMD | wc -l)
3769 [ $NUMS -eq $EXPECTED ] ||
3770 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3772 CMD="$LFIND -size -5 -type f $TDIR"
3773 NUMS=$($CMD | wc -l)
3774 [ $NUMS -eq $EXPECTED ] ||
3775 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3777 run_test 56r "check lfs find -size works =========================="
3779 test_56s() { # LU-611
3781 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT"
3783 if [ $OSTCOUNT -gt 1 ]; then
3784 $SETSTRIPE -c 1 $TDIR/$tfile.{0,1,2,3}
3788 ONESTRIPE=$(((NUMDIRS + 1) * NUMFILES))
3792 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
3793 CMD="$LFIND -stripe-count $OSTCOUNT -type f $TDIR"
3794 NUMS=$($CMD | wc -l)
3795 [ $NUMS -eq $EXPECTED ] ||
3796 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3798 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + EXTRA))
3799 CMD="$LFIND -stripe-count +0 -type f $TDIR"
3800 NUMS=$($CMD | wc -l)
3801 [ $NUMS -eq $EXPECTED ] ||
3802 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3805 CMD="$LFIND -stripe-count 1 -type f $TDIR"
3806 NUMS=$($CMD | wc -l)
3807 [ $NUMS -eq $EXPECTED ] ||
3808 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3810 CMD="$LFIND -stripe-count -2 -type f $TDIR"
3811 NUMS=$($CMD | wc -l)
3812 [ $NUMS -eq $EXPECTED ] ||
3813 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3816 CMD="$LFIND -stripe-count $((OSTCOUNT + 1)) -type f $TDIR"
3817 NUMS=$($CMD | wc -l)
3818 [ $NUMS -eq $EXPECTED ] ||
3819 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3821 run_test 56s "check lfs find -stripe-count works"
3823 test_56t() { # LU-611
3825 setup_56 $NUMFILES $NUMDIRS "-s 512k"
3827 $SETSTRIPE -S 256k $TDIR/$tfile.{0,1,2,3}
3829 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
3830 CMD="$LFIND -stripe-size 512k -type f $TDIR"
3831 NUMS=$($CMD | wc -l)
3832 [ $NUMS -eq $EXPECTED ] ||
3833 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3835 CMD="$LFIND -stripe-size +320k -type f $TDIR"
3836 NUMS=$($CMD | wc -l)
3837 [ $NUMS -eq $EXPECTED ] ||
3838 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3840 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + 4))
3841 CMD="$LFIND -stripe-size +200k -type f $TDIR"
3842 NUMS=$($CMD | wc -l)
3843 [ $NUMS -eq $EXPECTED ] ||
3844 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3846 CMD="$LFIND -stripe-size -640k -type f $TDIR"
3847 NUMS=$($CMD | wc -l)
3848 [ $NUMS -eq $EXPECTED ] ||
3849 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3852 CMD="$LFIND -stripe-size 256k -type f $TDIR"
3853 NUMS=$($CMD | wc -l)
3854 [ $NUMS -eq $EXPECTED ] ||
3855 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3857 CMD="$LFIND -stripe-size -320k -type f $TDIR"
3858 NUMS=$($CMD | wc -l)
3859 [ $NUMS -eq $EXPECTED ] ||
3860 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3863 CMD="$LFIND -stripe-size 1024k -type f $TDIR"
3864 NUMS=$($CMD | wc -l)
3865 [ $NUMS -eq $EXPECTED ] ||
3866 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3868 run_test 56t "check lfs find -stripe-size works"
3870 test_56u() { # LU-611
3872 setup_56 $NUMFILES $NUMDIRS "-i 0"
3874 if [ $OSTCOUNT -gt 1 ]; then
3875 $SETSTRIPE -i 1 $TDIR/$tfile.{0,1,2,3}
3881 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
3882 CMD="$LFIND -stripe-index 0 -type f $TDIR"
3883 NUMS=$($CMD | wc -l)
3884 [ $NUMS -eq $EXPECTED ] ||
3885 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3888 CMD="$LFIND -stripe-index 1 -type f $TDIR"
3889 NUMS=$($CMD | wc -l)
3890 [ $NUMS -eq $EXPECTED ] ||
3891 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3893 CMD="$LFIND ! -stripe-index 0 -type f $TDIR"
3894 NUMS=$($CMD | wc -l)
3895 [ $NUMS -eq $EXPECTED ] ||
3896 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3899 # This should produce an error and not return any files
3900 CMD="$LFIND -stripe-index $OSTCOUNT -type f $TDIR"
3901 NUMS=$($CMD 2>/dev/null | wc -l)
3902 [ $NUMS -eq $EXPECTED ] ||
3903 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3905 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + ONESTRIPE))
3906 CMD="$LFIND -stripe-index 0,1 -type f $TDIR"
3907 NUMS=$($CMD | wc -l)
3908 [ $NUMS -eq $EXPECTED ] ||
3909 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3911 run_test 56u "check lfs find -stripe-index works"
3918 setup_56 $NUMFILES $NUMDIRS
3920 UUID=$(mdtuuid_from_index $MDT_IDX $TDIR)
3921 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT index $MDT_IDX"
3923 for file in $($LFIND -mdt $UUID $TDIR); do
3924 file_mdt_idx=$($GETSTRIPE -M $file)
3925 [ $file_mdt_idx -eq $MDT_IDX ] ||
3926 error "'lfind -mdt $UUID' != 'getstripe -M' ($file_mdt_idx)"
3929 run_test 56v "check 'lfs find -mdt match with lfs getstripe -M' ======="
3931 # Get and check the actual stripe count of one file.
3932 # Usage: check_stripe_count <file> <expected_stripe_count>
3933 check_stripe_count() {
3938 [[ -z "$file" || -z "$expected" ]] &&
3939 error "check_stripe_count: invalid argument!"
3941 local cmd="$GETSTRIPE -c $file"
3942 actual=$($cmd) || error "$cmd failed"
3943 actual=${actual%% *}
3945 if [[ $actual -ne $expected ]]; then
3946 [[ $expected -eq -1 ]] ||
3947 error "$cmd wrong: found $actual, expected $expected"
3948 [[ $actual -eq $OSTCOUNT ]] ||
3949 error "$cmd wrong: found $actual, expected $OSTCOUNT"
3956 rm -rf $TDIR || error "remove $TDIR failed"
3957 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT"
3960 stripe_size=$($GETSTRIPE -S -d $TDIR) ||
3961 error "$GETSTRIPE -S -d $TDIR failed"
3962 stripe_size=${stripe_size%% *}
3964 local file_size=$((stripe_size * OSTCOUNT))
3965 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
3966 local required_space=$((file_num * file_size))
3967 local free_space=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
3968 [[ $free_space -le $((required_space / 1024)) ]] &&
3969 skip_env "need at least $required_space bytes free space," \
3970 "have $free_space kbytes" && return
3973 local dd_count=$((file_size / dd_bs))
3975 # write data into the files
3979 for i in $(seq 1 $NUMFILES); do
3981 yes | dd bs=$dd_bs count=$dd_count of=$file >/dev/null 2>&1 ||
3982 error "write data into $file failed"
3984 for i in $(seq 1 $NUMDIRS); do
3985 for j in $(seq 1 $NUMFILES); do
3986 file=$TDIR/dir$i/file$j
3987 yes | dd bs=$dd_bs count=$dd_count of=$file \
3989 error "write data into $file failed"
3994 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
3997 local cmd="$LFS_MIGRATE -y -c $expected $TDIR/file1"
3999 eval $cmd || error "$cmd failed"
4001 check_stripe_count $TDIR/file1 $expected
4004 cmd="$LFS_MIGRATE -y -c $expected $TDIR/dir1"
4006 eval $cmd || error "$cmd failed"
4008 for j in $(seq 1 $NUMFILES); do
4009 check_stripe_count $TDIR/dir1/file$j $expected
4012 # lfs_migrate works with lfs find
4013 cmd="$LFIND -stripe_count $OSTCOUNT -type f $TDIR |
4014 $LFS_MIGRATE -y -c $expected"
4016 eval $cmd || error "$cmd failed"
4018 for i in $(seq 2 $NUMFILES); do
4019 check_stripe_count $TDIR/file$i $expected
4021 for i in $(seq 2 $NUMDIRS); do
4022 for j in $(seq 1 $NUMFILES); do
4023 check_stripe_count $TDIR/dir$i/file$j $expected
4027 run_test 56w "check lfs_migrate -c stripe_count works"
4030 # note test will not do anything if MDS is not local
4031 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4032 skip "Only applicable to ldiskfs-based MDTs"
4036 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4037 local MNTDEV="osd*.*MDT*.mntdev"
4038 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
4039 [ -z "$DEV" ] && error "can't access $MNTDEV"
4040 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
4041 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
4042 error "can't access $DEV"
4043 DEVISIZE=`awk '/Inode size:/ { print $3 }' $TMP/t57a.dump`
4044 [ "$DEVISIZE" -gt 128 ] || error "inode size $DEVISIZE"
4048 run_test 57a "verify MDS filesystem created with large inodes =="
4051 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4052 skip "Only applicable to ldiskfs-based MDTs"
4056 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4061 local FILEN=$dir/f$FILECOUNT
4063 rm -rf $dir || error "removing $dir"
4064 mkdir -p $dir || error "creating $dir"
4065 local num=$(get_mds_dir $dir)
4068 echo "mcreating $FILECOUNT files"
4069 createmany -m $dir/f 1 $FILECOUNT || \
4070 error "creating files in $dir"
4072 # verify that files do not have EAs yet
4073 $GETSTRIPE $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
4074 $GETSTRIPE $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
4078 df $dir #make sure we get new statfs data
4079 local MDSFREE=$(do_facet $mymds \
4080 lctl get_param -n osd*.*MDT000$((num -1)).kbytesfree)
4081 local MDCFREE=$(lctl get_param -n mdc.*MDT000$((num -1))-mdc-*.kbytesfree)
4082 echo "opening files to create objects/EAs"
4084 for FILE in `seq -f $dir/f%g 1 $FILECOUNT`; do
4085 $OPENFILE -f O_RDWR $FILE > /dev/null 2>&1 || error "opening $FILE"
4088 # verify that files have EAs now
4089 $GETSTRIPE $FILE1 | grep -q "obdidx" || error "$FILE1 missing EA"
4090 $GETSTRIPE $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
4092 sleep 1 #make sure we get new statfs data
4094 local MDSFREE2=$(do_facet $mymds \
4095 lctl get_param -n osd*.*MDT000$((num -1)).kbytesfree)
4096 local MDCFREE2=$(lctl get_param -n mdc.*MDT000$((num -1))-mdc-*.kbytesfree)
4097 if [ "$MDCFREE2" -lt "$((MDCFREE - 8))" ]; then
4098 if [ "$MDSFREE" != "$MDSFREE2" ]; then
4099 error "MDC before $MDCFREE != after $MDCFREE2"
4101 echo "MDC before $MDCFREE != after $MDCFREE2"
4102 echo "unable to confirm if MDS has large inodes"
4107 run_test 57b "default LOV EAs are stored inside large inodes ==="
4110 [ -z "$(which wiretest 2>/dev/null)" ] && skip_env "could not find wiretest" && return
4113 run_test 58 "verify cross-platform wire constants =============="
4116 echo "touch 130 files"
4117 createmany -o $DIR/f59- 130
4119 unlinkmany $DIR/f59- 130
4122 # wait for commitment of removal
4124 run_test 59 "verify cancellation of llog records async ========="
4126 TEST60_HEAD="test_60 run $RANDOM"
4128 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
4129 [ ! -f run-llog.sh ] && skip_env "missing subtest run-llog.sh" && return
4130 log "$TEST60_HEAD - from kernel mode"
4131 do_facet mgs sh run-llog.sh
4133 run_test 60a "llog sanity tests run from kernel module =========="
4135 test_60b() { # bug 6411
4137 LLOG_COUNT=`dmesg | awk "/$TEST60_HEAD/{marker = 1; from_marker = 0;}
4149 [ $LLOG_COUNT -gt 50 ] && error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)"|| true
4151 run_test 60b "limit repeated messages from CERROR/CWARN ========"
4154 echo "create 5000 files"
4155 createmany -o $DIR/f60c- 5000
4156 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
4157 lctl set_param fail_loc=0x80000137
4158 unlinkmany $DIR/f60c- 5000
4159 lctl set_param fail_loc=0
4161 run_test 60c "unlink file when mds full"
4164 SAVEPRINTK=$(lctl get_param -n printk)
4166 # verify "lctl mark" is even working"
4167 MESSAGE="test message ID $RANDOM $$"
4168 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
4169 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
4171 lctl set_param printk=0 || error "set lnet.printk failed"
4172 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
4173 MESSAGE="new test message ID $RANDOM $$"
4174 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
4175 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
4176 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
4178 lctl set_param -n printk="$SAVEPRINTK"
4180 run_test 60d "test printk console message masking"
4184 dd if=/dev/zero of=$f bs=`page_size` count=1
4185 cancel_lru_locks osc
4186 $MULTIOP $f OSMWUc || error
4189 run_test 61 "mmap() writes don't make sync hang ================"
4191 # bug 2330 - insufficient obd_match error checking causes LBUG
4195 cancel_lru_locks osc
4196 lctl set_param fail_loc=0x405
4197 cat $f && error "cat succeeded, expect -EIO"
4198 lctl set_param fail_loc=0
4200 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
4201 # match every page all of the time.
4202 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
4204 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
4205 test_63a() { # was test_63
4206 MAX_DIRTY_MB=`lctl get_param -n osc.*.max_dirty_mb | head -n 1`
4207 lctl set_param -n osc.*.max_dirty_mb 0
4208 for i in `seq 10` ; do
4209 dd if=/dev/zero of=$DIR/f63 bs=8k &
4215 lctl set_param -n osc.*.max_dirty_mb $MAX_DIRTY_MB
4216 rm -f $DIR/f63 || true
4218 run_test 63a "Verify oig_wait interruption does not crash ======="
4220 # bug 2248 - async write errors didn't return to application on sync
4221 # bug 3677 - async write errors left page locked
4224 lctl set_param debug=-1
4226 # ensure we have a grant to do async writes
4227 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
4230 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
4231 lctl set_param fail_loc=0x80000406
4232 $MULTIOP $DIR/$tfile Owy && \
4233 error "sync didn't return ENOMEM"
4234 sync; sleep 2; sync # do a real sync this time to flush page
4235 lctl get_param -n llite.*.dump_page_cache | grep locked && \
4236 error "locked page left in cache after async error" || true
4239 run_test 63b "async write errors should be returned to fsync ==="
4243 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
4245 run_test 64a "verify filter grant calculations (in kernel) ====="
4248 [ ! -f oos.sh ] && skip_env "missing subtest oos.sh" && return
4251 run_test 64b "check out-of-space detection on client ==========="
4253 # bug 1414 - set/get directories' stripe info
4257 $LVERIFY $DIR/d65 $DIR/d65/f1 || error "lverify failed"
4259 run_test 65a "directory with no stripe info ===================="
4263 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/d65||error "setstripe"
4265 $LVERIFY $DIR/d65 $DIR/d65/f2 || error "lverify failed"
4267 run_test 65b "directory setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1"
4270 if [ $OSTCOUNT -gt 1 ]; then
4272 $SETSTRIPE -S $(($STRIPESIZE * 4)) -i 1 \
4273 -c $(($OSTCOUNT - 1)) $DIR/d65 || error "setstripe"
4275 $LVERIFY $DIR/d65 $DIR/d65/f3 || error "lverify failed"
4278 run_test 65c "directory setstripe -S $((STRIPESIZE*4)) -i 1 -c $((OSTCOUNT-1))"
4282 if [ $STRIPECOUNT -le 0 ]; then
4284 elif [ $STRIPECOUNT -gt 2000 ]; then
4285 #LOV_MAX_STRIPE_COUNT is 2000
4286 [ $OSTCOUNT -gt 2000 ] && sc=2000 || sc=$(($OSTCOUNT - 1))
4288 sc=$(($STRIPECOUNT - 1))
4290 $SETSTRIPE -S $STRIPESIZE -c $sc $DIR/d65 || error "setstripe"
4291 touch $DIR/d65/f4 $DIR/d65/f5
4292 $LVERIFY $DIR/d65 $DIR/d65/f4 $DIR/d65/f5 || error "lverify failed"
4294 run_test 65d "directory setstripe -S $STRIPESIZE -c stripe_count"
4299 $SETSTRIPE $DIR/d65 || error "setstripe"
4300 $GETSTRIPE -v $DIR/d65 | grep "Default" || error "no stripe info failed"
4302 $LVERIFY $DIR/d65 $DIR/d65/f6 || error "lverify failed"
4304 run_test 65e "directory setstripe defaults ======================="
4308 $RUNAS $SETSTRIPE $DIR/d65f && error "setstripe succeeded" || true
4310 run_test 65f "dir setstripe permission (should return error) ==="
4314 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/d65 ||error "setstripe"
4315 $SETSTRIPE -d $DIR/d65 || error "setstripe"
4316 $GETSTRIPE -v $DIR/d65 | grep "Default" || \
4317 error "delete default stripe failed"
4319 run_test 65g "directory setstripe -d ==========================="
4323 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/d65 ||error "setstripe"
4324 mkdir -p $DIR/d65/dd1
4325 [ $($GETSTRIPE -c $DIR/d65) == $($GETSTRIPE -c $DIR/d65/dd1) ] ||
4326 error "stripe info inherit failed"
4328 run_test 65h "directory stripe info inherit ===================="
4330 test_65i() { # bug6367
4331 $SETSTRIPE -S 65536 -c -1 $MOUNT
4333 run_test 65i "set non-default striping on root directory (bug 6367)="
4335 test_65ia() { # bug12836
4336 $GETSTRIPE $MOUNT || error "getstripe $MOUNT failed"
4338 run_test 65ia "getstripe on -1 default directory striping"
4340 test_65ib() { # bug12836
4341 $GETSTRIPE -v $MOUNT || error "getstripe -v $MOUNT failed"
4343 run_test 65ib "getstripe -v on -1 default directory striping"
4345 test_65ic() { # bug12836
4346 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
4348 run_test 65ic "new find on -1 default directory striping"
4350 test_65j() { # bug6367
4352 # if we aren't already remounting for each test, do so for this test
4353 if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
4354 cleanup || error "failed to unmount"
4357 $SETSTRIPE -d $MOUNT || error "setstripe failed"
4359 run_test 65j "set default striping on root directory (bug 6367)="
4361 test_65k() { # bug11679
4362 [ "$OSTCOUNT" -lt 2 ] && skip_env "too few OSTs" && return
4363 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4365 echo "Check OST status: "
4366 local MDS_OSCS=`do_facet $SINGLEMDS lctl dl |
4367 awk '/[oO][sS][cC].*md[ts]/ { print $4 }'`
4369 for OSC in $MDS_OSCS; do
4370 echo $OSC "is activate"
4371 do_facet $SINGLEMDS lctl --device %$OSC activate
4374 do_facet client mkdir -p $DIR/$tdir
4375 for INACTIVE_OSC in $MDS_OSCS; do
4376 echo "Deactivate: " $INACTIVE_OSC
4377 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
4378 for STRIPE_OSC in $MDS_OSCS; do
4379 OST=`osc_to_ost $STRIPE_OSC`
4380 IDX=`do_facet $SINGLEMDS lctl get_param -n lov.*md*.target_obd |
4381 awk -F: /$OST/'{ print $1 }' | head -n 1`
4383 [ -f $DIR/$tdir/$IDX ] && continue
4384 echo "$SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX"
4385 do_facet client $SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX
4387 [ $RC -ne 0 ] && error "setstripe should have succeeded"
4389 do_facet client rm -f $DIR/$tdir/*
4390 echo $INACTIVE_OSC "is Activate."
4391 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
4394 run_test 65k "validate manual striping works properly with deactivated OSCs"
4396 test_65l() { # bug 12836
4397 mkdir -p $DIR/$tdir/test_dir
4398 $SETSTRIPE -c -1 $DIR/$tdir/test_dir
4399 $LFS find -mtime -1 $DIR/$tdir >/dev/null
4401 run_test 65l "lfs find on -1 stripe dir ========================"
4403 # bug 2543 - update blocks count on client
4406 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
4407 sync; sync_all_data; sync; sync_all_data
4408 cancel_lru_locks osc
4409 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
4410 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
4412 run_test 66 "update inode blocks count on client ==============="
4418 if [ ! -z "$LLOOP" ]; then
4419 if swapon -s | grep -q $LLOOP; then
4420 swapoff $LLOOP || error "swapoff failed"
4423 $LCTL blockdev_detach $LLOOP || error "detach failed"
4427 if [ ! -z "$LLITELOOPLOAD" ]; then
4435 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
4439 swapon -s | awk '($1 == "'$1'") { print $4 }'
4442 # test case for lloop driver, basic function
4444 [ "$UID" != 0 ] && skip_env "must run as root" && return
4445 llite_lloop_enabled || \
4446 { skip_env "llite_lloop module disabled" && return; }
4448 trap cleanup_68 EXIT
4450 if ! module_loaded llite_lloop; then
4451 if load_module llite/llite_lloop; then
4454 skip_env "can't find module llite_lloop"
4459 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
4460 dd if=/dev/zero of=$DIR/f68a bs=4k count=1024
4461 $LCTL blockdev_attach $DIR/f68a $LLOOP || error "attach failed"
4463 directio rdwr $LLOOP 0 1024 4096 || error "direct write failed"
4464 directio rdwr $LLOOP 0 1025 4096 && error "direct write should fail"
4468 run_test 68a "lloop driver - basic test ========================"
4470 # excercise swapping to lustre by adding a high priority swapfile entry
4471 # and then consuming memory until it is used.
4472 test_68b() { # was test_68
4473 [ "$UID" != 0 ] && skip_env "must run as root" && return
4474 lctl get_param -n devices | grep -q obdfilter && \
4475 skip "local OST" && return
4477 grep -q llite_lloop /proc/modules
4478 [ $? -ne 0 ] && skip "can't find module llite_lloop" && return
4480 [ -z "`$LCTL list_nids | grep -v tcp`" ] && \
4481 skip "can't reliably test swap with TCP" && return
4483 MEMTOTAL=`meminfo MemTotal`
4484 NR_BLOCKS=$((MEMTOTAL>>8))
4485 [[ $NR_BLOCKS -le 2048 ]] && NR_BLOCKS=2048
4487 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
4488 dd if=/dev/zero of=$DIR/f68b bs=64k seek=$NR_BLOCKS count=1
4491 $LCTL blockdev_attach $DIR/f68b $LLOOP || error "attach failed"
4493 trap cleanup_68 EXIT
4495 swapon -p 32767 $LLOOP || error "swapon $LLOOP failed"
4497 echo "before: `swapon -s | grep $LLOOP`"
4498 $MEMHOG $MEMTOTAL || error "error allocating $MEMTOTAL kB"
4499 echo "after: `swapon -s | grep $LLOOP`"
4500 SWAPUSED=`swap_used $LLOOP`
4504 [ $SWAPUSED -eq 0 ] && echo "no swap used???" || true
4506 run_test 68b "support swapping to Lustre ========================"
4508 # bug5265, obdfilter oa2dentry return -ENOENT
4509 # #define OBD_FAIL_OST_ENOENT 0x217
4511 remote_ost_nodsh && skip "remote OST with nodsh" && return
4514 $SETSTRIPE -c 1 -i 0 $f
4516 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
4518 do_facet ost1 lctl set_param fail_loc=0x217
4519 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
4520 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
4522 do_facet ost1 lctl set_param fail_loc=0
4523 $DIRECTIO write $f 0 2 || error "write error"
4525 cancel_lru_locks osc
4526 $DIRECTIO read $f 0 1 || error "read error"
4528 do_facet ost1 lctl set_param fail_loc=0x217
4529 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
4531 do_facet ost1 lctl set_param fail_loc=0
4534 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
4538 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
4540 run_test 71 "Running dbench on lustre (don't segment fault) ===="
4542 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
4543 check_kernel_version 43 || return 0
4544 [ "$RUNAS_ID" = "$UID" ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4546 # Check that testing environment is properly set up. Skip if not
4547 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS || {
4548 skip_env "User $RUNAS_ID does not exist - skipping"
4551 # We had better clear the $DIR to get enough space for dd
4556 $RUNAS dd if=/dev/zero of=$DIR/f72 bs=512 count=1 || error
4557 # See if we are still setuid/sgid
4558 test -u $DIR/f72 -o -g $DIR/f72 && error "S/gid is not dropped on write"
4559 # Now test that MDS is updated too
4560 cancel_lru_locks mdc
4561 test -u $DIR/f72 -o -g $DIR/f72 && error "S/gid is not dropped on MDS"
4565 run_test 72a "Test that remove suid works properly (bug5695) ===="
4567 test_72b() { # bug 24226 -- keep mode setting when size is not changing
4570 [ "$RUNAS_ID" = "$UID" ] && \
4571 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4572 [ "$RUNAS_ID" -eq 0 ] && \
4573 skip_env "RUNAS_ID = 0 -- skipping" && return
4575 # Check that testing environment is properly set up. Skip if not
4576 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS || {
4577 skip_env "User $RUNAS_ID does not exist - skipping"
4580 touch $DIR/${tfile}-f{g,u}
4581 mkdir $DIR/${tfile}-d{g,u}
4582 chmod 770 $DIR/${tfile}-{f,d}{g,u}
4583 chmod g+s $DIR/${tfile}-{f,d}g
4584 chmod u+s $DIR/${tfile}-{f,d}u
4585 for perm in 777 2777 4777; do
4586 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
4587 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
4588 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
4589 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
4593 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
4595 # bug 3462 - multiple simultaneous MDC requests
4599 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
4602 lctl set_param fail_loc=0x80000129
4603 $MULTIOP $DIR/d73-1/f73-2 Oc &
4605 lctl set_param fail_loc=0
4607 $MULTIOP $DIR/d73-2/f73-3 Oc &
4611 wait $pid1 || return 1
4615 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
4616 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
4617 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
4621 run_test 73 "multiple MDC requests (should not deadlock)"
4623 test_74a() { # bug 6149, 6184
4624 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
4626 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
4627 # will spin in a tight reconnection loop
4629 lctl set_param fail_loc=0x8000030e
4630 # get any lock that won't be difficult - lookup works.
4632 lctl set_param fail_loc=0
4636 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
4638 test_74b() { # bug 13310
4639 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
4641 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
4642 # will spin in a tight reconnection loop
4643 lctl set_param fail_loc=0x8000030e
4644 # get a "difficult" lock
4646 lctl set_param fail_loc=0
4650 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
4653 #define OBD_FAIL_LDLM_NEW_LOCK
4654 lctl set_param fail_loc=0x80000319
4655 touch $DIR/$tfile && error "Touch successful"
4658 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
4661 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
4664 get_inode_slab_tunables() {
4665 awk '/lustre_inode_cache/ {print $9," ",$10," ",$11; exit}' /proc/slabinfo
4668 set_inode_slab_tunables() {
4669 echo "lustre_inode_cache $1" > /proc/slabinfo
4672 test_76() { # Now for bug 20433, added originally in bug 1443
4673 local SLAB_SETTINGS=`get_inode_slab_tunables`
4674 local CPUS=`getconf _NPROCESSORS_ONLN`
4675 # we cannot set limit below 1 which means 1 inode in each
4676 # per-cpu cache is still allowed
4677 set_inode_slab_tunables "1 1 0"
4678 cancel_lru_locks osc
4679 BEFORE_INODES=`num_inodes`
4680 echo "before inodes: $BEFORE_INODES"
4682 [ "$SLOW" = "no" ] && COUNT=100
4683 for i in `seq $COUNT`; do
4687 cancel_lru_locks osc
4688 AFTER_INODES=`num_inodes`
4689 echo "after inodes: $AFTER_INODES"
4691 while [ $((AFTER_INODES-1*CPUS)) -gt $BEFORE_INODES ]; do
4693 AFTER_INODES=`num_inodes`
4695 echo "wait $wait seconds inodes: $AFTER_INODES"
4696 if [ $wait -gt 30 ]; then
4697 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
4700 set_inode_slab_tunables "$SLAB_SETTINGS"
4702 run_test 76 "confirm clients recycle inodes properly ===="
4708 # Note: in sptlrpc modes which enable its own bulk checksum, the
4709 # original crc32_le bulk checksum will be automatically disabled,
4710 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
4711 # will be checked by sptlrpc code against sptlrpc bulk checksum.
4712 # In this case set_checksums() will not be no-op, because sptlrpc
4713 # bulk checksum will be enabled all through the test.
4715 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
4716 lctl set_param -n osc.*.checksums $1
4720 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
4721 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
4722 CKSUM_TYPES=${CKSUM_TYPES:-"crc32 adler"}
4723 [ "$ORIG_CSUM_TYPE" = "crc32c" ] && CKSUM_TYPES="$CKSUM_TYPES crc32c"
4726 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
4727 log "set checksum type to $1"
4730 F77_TMP=$TMP/f77-temp
4733 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
4734 error "error writing to $F77_TMP"
4737 test_77a() { # bug 10889
4738 $GSS && skip "could not run with gss" && return
4739 [ ! -f $F77_TMP ] && setup_f77
4741 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
4745 run_test 77a "normal checksum read/write operation ============="
4747 test_77b() { # bug 10889
4748 $GSS && skip "could not run with gss" && return
4749 [ ! -f $F77_TMP ] && setup_f77
4750 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
4751 lctl set_param fail_loc=0x80000409
4753 dd if=$F77_TMP of=$DIR/f77b bs=1M count=$F77SZ conv=sync || \
4754 error "dd error: $?"
4755 lctl set_param fail_loc=0
4758 run_test 77b "checksum error on client write ===================="
4760 test_77c() { # bug 10889
4761 $GSS && skip "could not run with gss" && return
4762 [ ! -f $DIR/f77b ] && skip "requires 77b - skipping" && return
4764 for algo in $CKSUM_TYPES; do
4765 cancel_lru_locks osc
4766 set_checksum_type $algo
4767 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
4768 lctl set_param fail_loc=0x80000408
4769 cmp $F77_TMP $DIR/f77b || error "file compare failed"
4770 lctl set_param fail_loc=0
4773 set_checksum_type $ORIG_CSUM_TYPE
4776 run_test 77c "checksum error on client read ==================="
4778 test_77d() { # bug 10889
4779 $GSS && skip "could not run with gss" && return
4780 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
4781 lctl set_param fail_loc=0x80000409
4783 directio write $DIR/f77 0 $F77SZ $((1024 * 1024)) || \
4784 error "direct write: rc=$?"
4785 lctl set_param fail_loc=0
4788 run_test 77d "checksum error on OST direct write ==============="
4790 test_77e() { # bug 10889
4791 $GSS && skip "could not run with gss" && return
4792 [ ! -f $DIR/f77 ] && skip "requires 77d - skipping" && return
4793 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
4794 lctl set_param fail_loc=0x80000408
4796 cancel_lru_locks osc
4797 directio read $DIR/f77 0 $F77SZ $((1024 * 1024)) || \
4798 error "direct read: rc=$?"
4799 lctl set_param fail_loc=0
4802 run_test 77e "checksum error on OST direct read ================"
4804 test_77f() { # bug 10889
4805 $GSS && skip "could not run with gss" && return
4807 for algo in $CKSUM_TYPES; do
4808 cancel_lru_locks osc
4809 set_checksum_type $algo
4810 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
4811 lctl set_param fail_loc=0x409
4812 directio write $DIR/f77 0 $F77SZ $((1024 * 1024)) && \
4813 error "direct write succeeded"
4814 lctl set_param fail_loc=0
4816 set_checksum_type $ORIG_CSUM_TYPE
4819 run_test 77f "repeat checksum error on write (expect error) ===="
4821 test_77g() { # bug 10889
4822 $GSS && skip "could not run with gss" && return
4823 remote_ost_nodsh && skip "remote OST with nodsh" && return
4825 [ ! -f $F77_TMP ] && setup_f77
4827 $SETSTRIPE -c 1 -i 0 $DIR/f77g
4828 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
4829 do_facet ost1 lctl set_param fail_loc=0x8000021a
4831 dd if=$F77_TMP of=$DIR/f77g bs=1M count=$F77SZ || \
4832 error "write error: rc=$?"
4833 do_facet ost1 lctl set_param fail_loc=0
4836 run_test 77g "checksum error on OST write ======================"
4838 test_77h() { # bug 10889
4839 $GSS && skip "could not run with gss" && return
4840 remote_ost_nodsh && skip "remote OST with nodsh" && return
4842 [ ! -f $DIR/f77g ] && skip "requires 77g - skipping" && return
4843 cancel_lru_locks osc
4844 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
4845 do_facet ost1 lctl set_param fail_loc=0x8000021b
4847 cmp $F77_TMP $DIR/f77g || error "file compare failed"
4848 do_facet ost1 lctl set_param fail_loc=0
4851 run_test 77h "checksum error on OST read ======================="
4853 test_77i() { # bug 13805
4854 $GSS && skip "could not run with gss" && return
4855 #define OBD_FAIL_OSC_CONNECT_CKSUM 0x40b
4856 lctl set_param fail_loc=0x40b
4857 remount_client $MOUNT
4858 lctl set_param fail_loc=0
4859 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
4860 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
4861 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
4862 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
4864 remount_client $MOUNT
4866 run_test 77i "client not supporting OSD_CONNECT_CKSUM =========="
4868 test_77j() { # bug 13805
4869 $GSS && skip "could not run with gss" && return
4870 #define OBD_FAIL_OSC_CKSUM_ADLER_ONLY 0x40c
4871 lctl set_param fail_loc=0x40c
4872 remount_client $MOUNT
4873 lctl set_param fail_loc=0
4874 sleep 2 # wait async osc connect to finish
4875 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
4876 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
4877 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
4878 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
4880 remount_client $MOUNT
4882 run_test 77j "client only supporting ADLER32 ===================="
4884 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
4888 test_78() { # bug 10901
4889 remote_ost || { skip_env "local OST" && return; }
4892 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
4893 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
4894 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
4895 echo "MemTotal: $MEMTOTAL"
4896 # reserve 256MB of memory for the kernel and other running processes,
4897 # and then take 1/2 of the remaining memory for the read/write buffers.
4898 if [ $MEMTOTAL -gt 512 ] ;then
4899 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
4901 # for those poor memory-starved high-end clusters...
4902 MEMTOTAL=$((MEMTOTAL / 2))
4904 echo "Mem to use for directio: $MEMTOTAL"
4905 [ $F78SIZE -gt $MEMTOTAL ] && F78SIZE=$MEMTOTAL
4906 [ $F78SIZE -gt 512 ] && F78SIZE=512
4907 [ $F78SIZE -gt $((MAXFREE / 1024)) ] && F78SIZE=$((MAXFREE / 1024))
4908 SMALLESTOST=`lfs df $DIR |grep OST | awk '{print $4}' |sort -n |head -1`
4909 echo "Smallest OST: $SMALLESTOST"
4910 [ $SMALLESTOST -lt 10240 ] && \
4911 skip "too small OSTSIZE, useless to run large O_DIRECT test" && return 0
4913 [ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ] && \
4914 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
4916 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
4917 echo "File size: $F78SIZE"
4918 $SETSTRIPE -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
4919 for i in `seq 1 $NSEQ`
4921 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
4922 echo directIO rdwr round $i of $NSEQ
4923 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
4928 run_test 78 "handle large O_DIRECT writes correctly ============"
4930 test_79() { # bug 12743
4931 wait_delete_completed
4933 BKTOTAL=$(calc_osc_kbytes kbytestotal)
4934 BKFREE=$(calc_osc_kbytes kbytesfree)
4935 BKAVAIL=$(calc_osc_kbytes kbytesavail)
4937 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
4938 DFTOTAL=`echo $STRING | cut -d, -f1`
4939 DFUSED=`echo $STRING | cut -d, -f2`
4940 DFAVAIL=`echo $STRING | cut -d, -f3`
4941 DFFREE=$(($DFTOTAL - $DFUSED))
4943 ALLOWANCE=$((64 * $OSTCOUNT))
4945 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
4946 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
4947 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
4949 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
4950 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
4951 error "df free($DFFREE) mismatch OST free($BKFREE)"
4953 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
4954 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
4955 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
4958 run_test 79 "df report consistency check ======================="
4960 test_80() { # bug 10718
4961 # relax strong synchronous semantics for slow backends like ZFS
4962 local soc="obdfilter.*.sync_on_lock_cancel"
4963 local soc_old=$(do_facet ost1 lctl get_param -n $soc | head -n1)
4965 if [ "$soc_old" != "never" -a "$FSTYPE" != "ldiskfs" ]; then
4966 hosts=$(for host in $(seq -f "ost%g" 1 $OSTCOUNT); do
4967 facet_active_host $host; done | sort -u)
4968 do_nodes $hosts lctl set_param $soc=never
4971 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
4973 local BEFORE=`date +%s`
4974 cancel_lru_locks osc
4975 local AFTER=`date +%s`
4976 local DIFF=$((AFTER-BEFORE))
4977 if [ $DIFF -gt 1 ] ; then
4978 error "elapsed for 1M@1T = $DIFF"
4981 [ -n "$hosts" ] && do_nodes $hosts lctl set_param $soc=$soc_old
4986 run_test 80 "Page eviction is equally fast at high offsets too ===="
4988 test_81a() { # LU-456
4989 remote_ost_nodsh && skip "remote OST with nodsh" && return
4990 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
4991 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
4992 do_facet ost1 lctl set_param fail_loc=0x80000228
4994 # write should trigger a retry and success
4995 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
4996 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
4998 if [ $RC -ne 0 ] ; then
4999 error "write should success, but failed for $RC"
5002 run_test 81a "OST should retry write when get -ENOSPC ==============="
5004 test_81b() { # LU-456
5005 remote_ost_nodsh && skip "remote OST with nodsh" && return
5006 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
5007 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
5008 do_facet ost1 lctl set_param fail_loc=0x228
5010 # write should retry several times and return -ENOSPC finally
5011 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
5012 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
5015 if [ $RC -ne $ENOSPC ] ; then
5016 error "dd should fail for -ENOSPC, but succeed."
5019 run_test 81b "OST should return -ENOSPC when retry still fails ======="
5021 test_82() { # LU-1031
5022 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10
5026 multiop_bg_pause $DIR/$tfile OG${gid1}_g${gid1}c || return 1
5028 multiop_bg_pause $DIR/$tfile O_G${gid2}r10g${gid2}c || return 2
5030 kill -USR1 $MULTIPID2
5032 if [[ `ps h -o comm -p $MULTIPID2` == "" ]]; then
5033 error "First grouplock does not block second one"
5035 echo "Second grouplock blocks first one"
5037 kill -USR1 $MULTIPID1
5041 run_test 82 "Basic grouplock test ==============================="
5044 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && \
5046 mkdir -p $DIR/d99cvsroot
5047 chown $RUNAS_ID $DIR/d99cvsroot
5048 local oldPWD=$PWD # bug 13584, use $TMP as working dir
5051 $RUNAS cvs -d $DIR/d99cvsroot init || error
5054 run_test 99a "cvs init ========================================="
5057 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5058 [ ! -d $DIR/d99cvsroot ] && test_99a
5060 # some versions of cvs import exit(1) when asked to import links or
5061 # files they can't read. ignore those files.
5062 TOIGNORE=$(find . -type l -printf '-I %f\n' -o \
5063 ! -perm +4 -printf '-I %f\n')
5064 $RUNAS cvs -d $DIR/d99cvsroot import -m "nomesg" $TOIGNORE \
5065 d99reposname vtag rtag
5067 run_test 99b "cvs import ======================================="
5070 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5071 [ ! -d $DIR/d99cvsroot ] && test_99b
5073 mkdir -p $DIR/d99reposname
5074 chown $RUNAS_ID $DIR/d99reposname
5075 $RUNAS cvs -d $DIR/d99cvsroot co d99reposname
5077 run_test 99c "cvs checkout ====================================="
5080 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5081 [ ! -d $DIR/d99cvsroot ] && test_99c
5082 cd $DIR/d99reposname
5084 $RUNAS cvs add -m 'addmsg' foo99
5086 run_test 99d "cvs add =========================================="
5089 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5090 [ ! -d $DIR/d99cvsroot ] && test_99c
5091 cd $DIR/d99reposname
5094 run_test 99e "cvs update ======================================="
5097 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5098 [ ! -d $DIR/d99cvsroot ] && test_99d
5099 cd $DIR/d99reposname
5100 $RUNAS cvs commit -m 'nomsg' foo99
5101 rm -fr $DIR/d99cvsroot
5103 run_test 99f "cvs commit ======================================="
5106 [ "$NETTYPE" = tcp ] || \
5107 { skip "TCP secure port test, not useful for NETTYPE=$NETTYPE" && \
5110 remote_ost_nodsh && skip "remote OST with nodsh" && return
5111 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5113 { skip "useless for local single node setup" && return; }
5115 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
5116 [ "$PROT" != "tcp" ] && continue
5117 RPORT=$(echo $REMOTE | cut -d: -f2)
5118 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
5121 LPORT=`echo $LOCAL | cut -d: -f2`
5122 if [ $LPORT -ge 1024 ]; then
5123 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
5125 error_exit "local: $LPORT > 1024, remote: $RPORT"
5128 [ "$rc" = 0 ] || error_exit "privileged port not found" )
5130 run_test 100 "check local port using privileged port ==========="
5132 function get_named_value()
5141 echo $line | sed "s/^$tag[ ]*//"
5148 export CACHE_MAX=`$LCTL get_param -n llite.*.max_cached_mb | head -n 1`
5150 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
5158 [ "$CPU" = "UML" ] && nreads=1000
5159 local cache_limit=32
5161 $LCTL set_param -n osc.*-osc*.rpc_stats 0
5162 trap cleanup_101a EXIT
5163 $LCTL set_param -n llite.*.read_ahead_stats 0
5164 $LCTL set_param -n llite.*.max_cached_mb $cache_limit
5167 # randomly read 10000 of 64K chunks from file 3x 32MB in size
5169 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
5170 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
5173 for s in `$LCTL get_param -n llite.*.read_ahead_stats | \
5174 get_named_value 'read but discarded' | cut -d" " -f1`; do
5175 discard=$(($discard + $s))
5179 if [ $(($discard * 10)) -gt $nreads ] ;then
5180 $LCTL get_param osc.*-osc*.rpc_stats
5181 $LCTL get_param llite.*.read_ahead_stats
5182 error "too many ($discard) discarded pages"
5184 rm -f $DIR/$tfile || true
5186 run_test 101a "check read-ahead for random reads ================"
5191 STRIPE_COUNT=$OSTCOUNT
5194 local list=$(comma_list $(osts_nodes))
5195 do_nodes $list $LCTL set_param -n obdfilter.*.read_cache_enable=0
5196 do_nodes $list $LCTL set_param -n obdfilter.*.writethrough_cache_enable=0
5198 trap cleanup_test101bc EXIT
5199 # prepare the read-ahead file
5200 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
5202 dd if=/dev/zero of=$DIR/$tfile bs=1024k count=100 2> /dev/null
5205 cleanup_test101bc() {
5210 local list=$(comma_list $(osts_nodes))
5211 do_nodes $list $LCTL set_param -n obdfilter.*.read_cache_enable=1
5212 do_nodes $list $LCTL set_param -n obdfilter.*.writethrough_cache_enable=1
5216 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
5221 local STRIPE_SIZE=1048576
5222 local RA_INC=1048576
5223 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
5224 local FILE_LENGTH=$((64*100))
5225 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
5226 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
5227 DISCARD=`$LCTL get_param -n llite.*.read_ahead_stats | \
5228 get_named_value 'read but discarded' | \
5229 cut -d" " -f1 | calc_total`
5230 if [ $DISCARD -gt $discard_limit ]; then
5231 $LCTL get_param llite.*.read_ahead_stats
5232 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
5234 echo "Read-ahead success for size ${READ_SIZE}"
5239 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping stride IO stride-ahead test" && return
5240 local STRIPE_SIZE=1048576
5241 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
5242 local FILE_LENGTH=$((STRIPE_SIZE*100))
5243 local ITERATION=$((FILE_LENGTH/STRIDE_SIZE))
5244 # prepare the read-ahead file
5246 cancel_lru_locks osc
5247 for BIDX in 2 4 8 16 32 64 128 256
5249 local BSIZE=$((BIDX*4096))
5250 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
5251 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
5252 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
5253 $LCTL set_param -n llite.*.read_ahead_stats 0
5254 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
5255 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
5256 cancel_lru_locks osc
5262 run_test 101b "check stride-io mode read-ahead ================="
5265 local STRIPE_SIZE=1048576
5266 local FILE_LENGTH=$((STRIPE_SIZE*100))
5272 cancel_lru_locks osc
5273 $LCTL set_param osc.*.rpc_stats 0
5274 $READS -f $DIR/$tfile -s$FILE_LENGTH -b65536 -n$nreads -t 180
5275 for osc in $($LCTL get_param -N osc.*); do
5276 if [ "$osc" == "osc.num_refs" ]; then
5280 local lines=$($LCTL get_param -n ${osc}.rpc_stats | wc | awk '{print $1}')
5281 if [ $lines -le 20 ]; then
5285 local rpc4k=$($LCTL get_param -n ${osc}.rpc_stats |
5286 awk '$1 == "1:" { print $2; exit; }')
5287 local rpc8k=$($LCTL get_param -n ${osc}.rpc_stats |
5288 awk '$1 == "2:" { print $2; exit; }')
5289 local rpc16k=$($LCTL get_param -n ${osc}.rpc_stats |
5290 awk '$1 == "4:" { print $2; exit; }')
5291 local rpc32k=$($LCTL get_param -n ${osc}.rpc_stats |
5292 awk '$1 == "8:" { print $2; exit; }')
5294 [ $rpc4k != 0 ] && error "Small 4k read IO ${rpc4k}!"
5295 [ $rpc8k != 0 ] && error "Small 8k read IO ${rpc8k}!"
5296 [ $rpc16k != 0 ] && error "Small 16k read IO ${rpc16k}!"
5297 [ $rpc32k != 0 ] && error "Small 32k read IO ${rpc32k}!"
5298 echo "${osc} rpc check passed!"
5303 run_test 101c "check stripe_size aligned read-ahead ================="
5306 $LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1
5307 $LCTL set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
5311 local file=$DIR/$tfile
5312 local size=${FILESIZE_101c:-500}
5313 local ra_MB=${READAHEAD_MB:-40}
5315 local space=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
5316 [ $space -gt $((size / 1024)) ] ||
5317 { skip "Need free space ${size}M, have $space" && return; }
5319 echo Creating ${size}M test file $file
5320 dd if=/dev/zero of=$file bs=1M count=$size || error "dd failed"
5321 echo Cancel LRU locks on lustre client to flush the client cache
5322 cancel_lru_locks osc
5324 echo Disable read-ahead
5325 local old_READAHEAD=$(set_read_ahead 0)
5327 echo Reading the test file $file with read-ahead disabled
5328 time_ra_OFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$size")
5330 echo Cancel LRU locks on lustre client to flush the client cache
5331 cancel_lru_locks osc
5332 echo Enable read-ahead with ${ra_MB}MB
5333 set_read_ahead $ra_MB
5335 echo Reading the test file $file with read-ahead enabled
5336 time_ra_ON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$size")
5338 echo read-ahead disabled time read $time_ra_OFF
5339 echo read-ahead enabled time read $time_ra_ON
5341 set_read_ahead $old_READAHEAD
5343 wait_delete_completed
5345 [ $time_ra_ON -lt $time_ra_OFF ] ||
5346 error "read-ahead enabled time read (${time_ra_ON}s) is more than
5347 read-ahead disabled time read (${time_ra_OFF}s) filesize ${size}M"
5349 run_test 101d "file read with and without read-ahead enabled ================="
5352 local file=$DIR/$tfile
5357 local space=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
5358 local need_space=$((count * size))
5359 [ $space -gt $need_space ] ||
5360 { skip_env "Need free space $need_space, have $space" && return; }
5362 echo Creating $count ${size}K test files
5363 for ((i = 0; i < $count; i++)); do
5364 dd if=/dev/zero of=${file}_${i} bs=$blksize count=$size 2>/dev/null
5367 echo Cancel LRU locks on lustre client to flush the client cache
5368 cancel_lru_locks osc
5370 echo Reset readahead stats
5371 $LCTL set_param -n llite.*.read_ahead_stats 0
5373 for ((i = 0; i < $count; i++)); do
5374 dd if=${file}_${i} of=/dev/null bs=$blksize count=$size 2>/dev/null
5377 local miss=$($LCTL get_param -n llite.*.read_ahead_stats | \
5378 get_named_value 'misses' | cut -d" " -f1 | calc_total)
5380 for ((i = 0; i < $count; i++)); do
5381 rm -rf ${file}_${i} 2>/dev/null
5384 #10000 means 20% reads are missing in readahead
5385 [ $miss -lt 10000 ] || error "misses too much for small reads"
5387 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
5389 cleanup_test101f() {
5391 $LCTL set_param -n llite.*.max_read_ahead_whole_mb $MAX_WHOLE_MB
5392 rm -rf $DIR/$tfile 2>/dev/null
5396 local file=$DIR/$tfile
5399 MAX_WHOLE_MB=$($LCTL get_param -n llite.*.max_read_ahead_whole_mb)
5400 $LCTL set_param -n llite.*.max_read_ahead_whole_mb 2
5401 dd if=/dev/zero of=${file} bs=2097152 count=1 2>/dev/null
5402 trap cleanup_test101f EXIT
5404 echo Cancel LRU locks on lustre client to flush the client cache
5405 cancel_lru_locks osc
5407 echo Reset readahead stats
5408 $LCTL set_param -n llite.*.read_ahead_stats 0
5409 # Random read in a 2M file, because max_read_ahead_whole_mb = 2M,
5410 # readahead should read in 2M file on second read, so only miss
5412 echo Random 4K reads on 2M file for 1000 times
5413 $READS -f $file -s 2097152 -b 4096 -n $nreads
5415 echo checking missing pages
5416 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
5417 get_named_value 'misses' | cut -d" " -f1 | calc_total)
5419 [ $miss -lt 3 ] || error "misses too much pages!"
5422 run_test 101f "check read-ahead for max_read_ahead_whole_mb"
5426 chown $RUNAS_ID $DIR/$tdir
5429 STRIPE_COUNT=$OSTCOUNT
5430 [ $OSTCOUNT -gt 4 ] && STRIPE_COUNT=4
5432 trap cleanup_test102 EXIT
5434 $1 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
5436 for num in 1 2 3 4; do
5437 for count in $(seq 1 $STRIPE_COUNT); do
5438 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
5439 local size=`expr $STRIPE_SIZE \* $num`
5440 local file=file"$num-$idx-$count"
5441 $1 $SETSTRIPE -S $size -i $idx -c $count $file
5447 $1 $TAR cf $TMP/f102.tar $tdir --xattrs
5453 rm -rf $DIR/d0.sanity/d102
5457 local testfile=$DIR/xattr_testfile
5461 [ "$UID" != 0 ] && skip_env "must run as root" && return
5462 [ -z "`lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr`" ] &&
5463 skip_env "must have user_xattr" && return
5465 [ -z "$(which setfattr 2>/dev/null)" ] &&
5466 skip_env "could not find setfattr" && return
5468 echo "set/get xattr..."
5469 setfattr -n trusted.name1 -v value1 $testfile || error
5470 getfattr -n trusted.name1 $testfile 2> /dev/null |
5471 grep "trusted.name1=.value1" ||
5472 error "$testfile missing trusted.name1=value1"
5474 setfattr -n user.author1 -v author1 $testfile || error
5475 getfattr -n user.author1 $testfile 2> /dev/null |
5476 grep "user.author1=.author1" ||
5477 error "$testfile missing trusted.author1=author1"
5480 setfattr -n trusted.name2 -v value2 $testfile ||
5481 error "$testfile unable to set trusted.name2"
5482 setfattr -n trusted.name3 -v value3 $testfile ||
5483 error "$testfile unable to set trusted.name3"
5484 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
5485 grep "trusted.name" | wc -l) -eq 3 ] ||
5486 error "$testfile missing 3 trusted.name xattrs"
5488 setfattr -n user.author2 -v author2 $testfile ||
5489 error "$testfile unable to set user.author2"
5490 setfattr -n user.author3 -v author3 $testfile ||
5491 error "$testfile unable to set user.author3"
5492 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
5493 grep "user.author" | wc -l) -eq 3 ] ||
5494 error "$testfile missing 3 user.author xattrs"
5496 echo "remove xattr..."
5497 setfattr -x trusted.name1 $testfile ||
5498 error "$testfile error deleting trusted.name1"
5499 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
5500 error "$testfile did not delete trusted.name1 xattr"
5502 setfattr -x user.author1 $testfile ||
5503 error "$testfile error deleting user.author1"
5504 getfattr -d -m user $testfile 2> /dev/null | grep "user.author1" &&
5505 error "$testfile did not delete trusted.name1 xattr"
5507 # b10667: setting lustre special xattr be silently discarded
5508 echo "set lustre special xattr ..."
5509 setfattr -n "trusted.lov" -v "invalid value" $testfile ||
5510 error "$testfile allowed setting trusted.lov"
5512 run_test 102a "user xattr test =================================="
5515 # b10930: get/set/list trusted.lov xattr
5516 echo "get/set/list trusted.lov xattr ..."
5517 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
5518 local testfile=$DIR/$tfile
5519 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
5520 error "setstripe failed"
5521 local STRIPECOUNT=$($GETSTRIPE -c $testfile) ||
5522 error "getstripe failed"
5523 getfattr -d -m "^trusted" $testfile 2> /dev/null | \
5524 grep "trusted.lov" || error "can't get trusted.lov from $testfile"
5526 local testfile2=${testfile}2
5527 local value=`getfattr -n trusted.lov $testfile 2> /dev/null | \
5528 grep "trusted.lov" |sed -e 's/[^=]\+=//'`
5531 setfattr -n trusted.lov -v $value $testfile2
5532 local stripe_size=$($GETSTRIPE -S $testfile2)
5533 local stripe_count=$($GETSTRIPE -c $testfile2)
5534 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
5535 [ $stripe_count -eq $STRIPECOUNT ] ||
5536 error "stripe count $stripe_count != $STRIPECOUNT"
5539 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
5542 # b10930: get/set/list lustre.lov xattr
5543 echo "get/set/list lustre.lov xattr ..."
5544 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
5546 chown $RUNAS_ID $DIR/$tdir
5547 local testfile=$DIR/$tdir/$tfile
5548 $RUNAS $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
5549 error "setstripe failed"
5550 local STRIPECOUNT=$($RUNAS $GETSTRIPE -c $testfile) ||
5551 error "getstripe failed"
5552 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
5553 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
5555 local testfile2=${testfile}2
5556 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
5557 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
5559 $RUNAS $MCREATE $testfile2
5560 $RUNAS setfattr -n lustre.lov -v $value $testfile2
5561 local stripe_size=$($RUNAS $GETSTRIPE -S $testfile2)
5562 local stripe_count=$($RUNAS $GETSTRIPE -c $testfile2)
5563 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
5564 [ $stripe_count -eq $STRIPECOUNT ] ||
5565 error "stripe count $stripe_count != $STRIPECOUNT"
5567 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
5569 compare_stripe_info1() {
5570 local stripe_index_all_zero=true
5572 for num in 1 2 3 4; do
5573 for count in $(seq 1 $STRIPE_COUNT); do
5574 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
5575 local size=$((STRIPE_SIZE * num))
5576 local file=file"$num-$offset-$count"
5577 stripe_size=$(lfs getstripe -S $PWD/$file)
5578 [ $stripe_size -ne $size ] &&
5579 error "$file: size $stripe_size != $size"
5580 stripe_count=$(lfs getstripe -c $PWD/$file)
5581 # allow fewer stripes to be created, ORI-601
5582 [ $stripe_count -lt $(((3 * count + 3) / 4)) ]&&
5583 error "$file: count $stripe_count != $count"
5584 stripe_index=$(lfs getstripe -i $PWD/$file)
5585 [ $stripe_index -ne 0 ] &&
5586 stripe_index_all_zero=false
5590 $stripe_index_all_zero &&
5591 error "all files are being extracted starting from OST index 0"
5596 [ -n "$(which tar 2>/dev/null)" ] &&
5597 strings $(which tar) | grep -q "lustre" && echo tar
5601 # b10930: tar test for trusted.lov xattr
5602 TAR=$(find_lustre_tar)
5603 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
5604 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
5607 $TAR xf $TMP/f102.tar -C $DIR/d102d --xattrs
5609 compare_stripe_info1
5611 run_test 102d "tar restore stripe info from tarfile,not keep osts ==========="
5614 # b10930: tar test for trusted.lov xattr
5615 TAR=$(find_lustre_tar)
5616 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
5617 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
5621 $TAR cf - --xattrs $tdir | $TAR xf - --xattrs -C $DIR/d102f
5623 compare_stripe_info1
5625 run_test 102f "tar copy files, not keep osts ==========="
5628 local xsize=${1:-1024} # in bytes
5629 local file=$DIR/$tfile
5631 [ -z $(lctl get_param -n mdc.*.connect_flags | grep xattr) ] &&
5632 skip "must have user_xattr" && return 0
5633 [ -z "$(which setfattr 2>/dev/null)" ] &&
5634 skip_env "could not find setfattr" && return 0
5635 [ -z "$(which getfattr 2>/dev/null)" ] &&
5636 skip_env "could not find getfattr" && return 0
5640 local value="$(generate_string $xsize)"
5642 local xbig=trusted.big
5643 log "save $xbig on $file"
5644 setfattr -n $xbig -v $value $file ||
5645 error "saving $xbig on $file failed"
5647 local orig=$(get_xattr_value $xbig $file)
5648 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
5650 local xsml=trusted.sml
5651 log "save $xsml on $file"
5652 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
5654 local new=$(get_xattr_value $xbig $file)
5655 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
5657 log "grow $xsml on $file"
5658 setfattr -n $xsml -v "$value" $file ||
5659 error "growing $xsml on $file failed"
5661 new=$(get_xattr_value $xbig $file)
5662 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
5663 log "$xbig still valid after growing $xsml"
5668 test_102h() { # bug 15777
5671 run_test 102h "grow xattr from inside inode to external block"
5674 large_xattr_enabled || { skip "large_xattr disabled" && return; }
5675 grow_xattr $(max_xattr_size)
5677 run_test 102ha "grow xattr from inside inode to external inode"
5679 test_102i() { # bug 17038
5681 ln -s $DIR/$tfile $DIR/${tfile}link
5682 getfattr -n trusted.lov $DIR/$tfile || error "lgetxattr on $DIR/$tfile failed"
5683 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"
5684 rm -f $DIR/$tfile $DIR/${tfile}link
5686 run_test 102i "lgetxattr test on symbolic link ============"
5689 TAR=$(find_lustre_tar)
5690 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
5691 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
5692 setup_test102 "$RUNAS"
5694 chown $RUNAS_ID $DIR/d102j
5695 $RUNAS $TAR xf $TMP/f102.tar -C $DIR/d102j --xattrs
5697 compare_stripe_info1 "$RUNAS"
5699 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
5703 # b22187 just check that does not crash for regular file.
5704 setfattr -n trusted.lov $DIR/$tfile
5705 # b22187 'setfattr -n trusted.lov' should work as remove LOV EA for directories
5706 local test_kdir=$DIR/d102k
5708 local default_size=`$GETSTRIPE -S $test_kdir`
5709 local default_count=`$GETSTRIPE -c $test_kdir`
5710 local default_offset=`$GETSTRIPE -i $test_kdir`
5711 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $test_kdir ||
5712 error 'dir setstripe failed'
5713 setfattr -n trusted.lov $test_kdir
5714 local stripe_size=`$GETSTRIPE -S $test_kdir`
5715 local stripe_count=`$GETSTRIPE -c $test_kdir`
5716 local stripe_offset=`$GETSTRIPE -i $test_kdir`
5717 [ $stripe_size -eq $default_size ] ||
5718 error "stripe size $stripe_size != $default_size"
5719 [ $stripe_count -eq $default_count ] ||
5720 error "stripe count $stripe_count != $default_count"
5721 [ $stripe_offset -eq $default_offset ] ||
5722 error "stripe offset $stripe_offset != $default_offset"
5723 rm -rf $DIR/$tfile $test_kdir
5725 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
5728 # LU-532 trusted. xattr is invisible to non-root
5729 local testfile=$DIR/$tfile
5733 echo "listxattr as user..."
5734 chown $RUNAS_ID $testfile
5735 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
5736 grep -q "trusted" &&
5737 error "$testfile trusted xattrs are user visible"
5741 run_test 102l "listxattr filter test =================================="
5747 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
5752 [ "$UID" != 0 ] && skip_env "must run as root" && return
5753 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
5754 [ -z "$(which setfacl 2>/dev/null)" ] && skip_env "could not find setfacl" && return
5755 $GSS && skip "could not run under gss" && return
5757 declare -a identity_old
5759 for num in `seq $MDSCOUNT`; do
5760 switch_identity $num true || identity_old[$num]=$?
5767 echo "performing cp ..."
5768 run_acl_subtest cp || error
5769 echo "performing getfacl-noacl..."
5770 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
5771 echo "performing misc..."
5772 run_acl_subtest misc || error "misc test failed"
5773 echo "performing permissions..."
5774 run_acl_subtest permissions || error "permissions failed"
5775 echo "performing setfacl..."
5776 run_acl_subtest setfacl || error "setfacl test failed"
5778 # inheritance test got from HP
5779 echo "performing inheritance..."
5780 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
5781 chmod +x make-tree || error "chmod +x failed"
5782 run_acl_subtest inheritance || error "inheritance test failed"
5788 for num in `seq $MDSCOUNT`; do
5789 if [ "${identity_old[$num]}" = 1 ]; then
5790 switch_identity $num false || identity_old[$num]=$?
5794 run_test 103 "acl test ========================================="
5798 lfs df || error "lfs df failed"
5799 lfs df -ih || error "lfs df -ih failed"
5800 lfs df -h $DIR || error "lfs df -h $DIR failed"
5801 lfs df -i $DIR || error "lfs df -i $DIR failed"
5802 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
5803 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
5805 OSC=`lctl dl |grep OST0000-osc-[^M] |awk '{print $4}'`
5806 lctl --device %$OSC deactivate
5807 lfs df || error "lfs df with deactivated OSC failed"
5808 lctl --device %$OSC activate
5809 # wait the osc back to normal
5810 wait_osc_import_state client ost FULL
5812 lfs df || error "lfs df with reactivated OSC failed"
5815 run_test 104a "lfs df [-ih] [path] test ========================="
5818 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5820 denied_cnt=$((`$RUNAS $LFS check servers 2>&1 | grep "Permission denied" | wc -l`))
5821 if [ $denied_cnt -ne 0 ];
5823 error "lfs check servers test failed"
5826 run_test 104b "$RUNAS lfs check servers test ===================="
5829 # doesn't work on 2.4 kernels
5831 if [ -n "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ];
5833 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
5835 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
5839 run_test 105a "flock when mounted without -o flock test ========"
5843 if [ -n "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ];
5845 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
5847 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
5851 run_test 105b "fcntl when mounted without -o flock test ========"
5855 if [ -n "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ];
5857 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
5859 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
5863 run_test 105c "lockf when mounted without -o flock test ========"
5865 test_105d() { # bug 15924
5867 [ -z "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ] && \
5868 skip "mount w/o flock enabled" && return
5869 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
5870 $LCTL set_param fail_loc=0x80000315
5871 flocks_test 2 $DIR/$tdir
5873 run_test 105d "flock race (should not freeze) ========"
5875 test_105e() { # bug 22660 && 22040
5876 [ -z "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ] && \
5877 skip "mount w/o flock enabled" && return
5879 flocks_test 3 $DIR/$tfile
5881 run_test 105e "Two conflicting flocks from same process ======="
5883 test_106() { #bug 10921
5885 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
5886 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
5888 run_test 106 "attempt exec of dir followed by chown of that dir"
5897 local save_pattern=$(sysctl -n kernel.core_pattern)
5898 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
5899 sysctl -w kernel.core_pattern=$file
5900 sysctl -w kernel.core_uses_pid=0
5908 kill -s 11 $SLEEPPID
5910 if [ -e $file ]; then
5911 size=`stat -c%s $file`
5912 [ $size -eq 0 ] && error "Fail to create core file $file"
5914 error "Fail to create core file $file"
5917 sysctl -w kernel.core_pattern=$save_pattern
5918 sysctl -w kernel.core_uses_pid=$save_uses_pid
5921 run_test 107 "Coredump on SIG"
5925 mkdir $DIR/d110/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa || error "mkdir with 255 char fail"
5926 mkdir $DIR/d110/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb && error "mkdir with 256 char should fail, but not"
5927 touch $DIR/d110/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx || error "create with 255 char fail"
5928 touch $DIR/d110/yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy && error ""create with 256 char should fail, but not
5933 run_test 110 "filename length checking"
5936 OSTIO_pre=$(ps -e|grep ll_ost_io|awk '{print $4}'|sort -n|tail -1|\
5938 [ -z "$OSTIO_pre" ] && skip "no OSS threads" && \
5940 echo "Starting with $OSTIO_pre threads"
5943 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
5944 [ $NUMFREE -lt $NUMTEST ] && NUMTEST=$(($NUMFREE - 1000))
5945 echo "$NUMTEST creates/unlinks"
5947 createmany -o $DIR/$tdir/$tfile $NUMTEST
5948 unlinkmany $DIR/$tdir/$tfile $NUMTEST
5950 OSTIO_post=$(ps -e|grep ll_ost_io|awk '{print $4}'|sort -n|tail -1|\
5953 # don't return an error
5954 [ $OSTIO_post == $OSTIO_pre ] && echo \
5955 "WARNING: No new ll_ost_io threads were created ($OSTIO_pre)" &&
5956 echo "This may be fine, depending on what ran before this test" &&
5957 echo "and how fast this system is." && return
5959 echo "Started with $OSTIO_pre threads, ended with $OSTIO_post"
5961 run_test 115 "verify dynamic thread creation===================="
5964 wait_delete_completed
5965 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
5966 echo OST kbytes available: ${AVAIL[@]}
5967 MAXI=0; MAXV=${AVAIL[0]}
5968 MINI=0; MINV=${AVAIL[0]}
5969 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
5970 #echo OST $i: ${AVAIL[i]}kb
5971 if [ ${AVAIL[i]} -gt $MAXV ]; then
5972 MAXV=${AVAIL[i]}; MAXI=$i
5974 if [ ${AVAIL[i]} -lt $MINV ]; then
5975 MINV=${AVAIL[i]}; MINI=$i
5978 echo Min free space: OST $MINI: $MINV
5979 echo Max free space: OST $MAXI: $MAXV
5982 test_116a() { # was previously test_116()
5983 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs" && return
5985 echo -n "Free space priority "
5986 lctl get_param -n lov.*-clilov-*.qos_prio_free
5989 [ $MINV -gt 960000 ] && skip "too much free space in OST$MINI, skip" &&\
5992 # generate uneven OSTs
5993 mkdir -p $DIR/$tdir/OST${MINI}
5996 echo "Filling 25% remaining space in OST${MINI} with ${FILL}Kb"
5997 $SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI}||error "setstripe failed"
5999 while [ $FILL -gt 0 ]; do
6001 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i bs=2M count=1 2>/dev/null
6002 FILL=$(($FILL - 2048))
6010 DIFF=$(($MAXV - $MINV))
6011 DIFF2=$(($DIFF * 100 / $MINV))
6012 echo -n "diff=${DIFF}=${DIFF2}% must be > 20% for QOS mode..."
6013 if [ $DIFF2 -gt 20 ]; then
6016 echo "failed - QOS mode won't be used"
6017 error_ignore "QOS imbalance criteria not met"
6021 MINI1=$MINI; MINV1=$MINV
6022 MAXI1=$MAXI; MAXV1=$MAXV
6024 # now fill using QOS
6025 echo writing a bunch of files to QOS-assigned OSTs
6026 $SETSTRIPE -c 1 $DIR/$tdir
6028 while [ $FILL -gt 0 ]; do
6030 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1024 count=200 2>/dev/null
6031 FILL=$(($FILL - 200))
6034 echo "wrote $i 200k files"
6038 echo "Note: free space may not be updated, so measurements might be off"
6040 DIFF2=$(($MAXV - $MINV))
6041 echo "free space delta: orig $DIFF final $DIFF2"
6042 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
6043 DIFF=$(($MINV1 - ${AVAIL[$MINI1]}))
6044 echo "Wrote $DIFF to smaller OST $MINI1"
6045 DIFF2=$(($MAXV1 - ${AVAIL[$MAXI1]}))
6046 echo "Wrote $DIFF2 to larger OST $MAXI1"
6047 [ $DIFF -gt 0 ] && echo "Wrote $(($DIFF2 * 100 / $DIFF - 100))% more data to larger OST $MAXI1"
6049 # Figure out which files were written where
6050 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
6051 awk '/'$MINI1': / {print $2; exit}')
6053 MINC=$($GETSTRIPE --obd $UUID $DIR/$tdir | wc -l)
6054 echo "$MINC files created on smaller OST $MINI1"
6055 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
6056 awk '/'$MAXI1': / {print $2; exit}')
6058 MAXC=$($GETSTRIPE --obd $UUID $DIR/$tdir | wc -l)
6059 echo "$MAXC files created on larger OST $MAXI1"
6060 [ $MINC -gt 0 ] && echo "Wrote $(($MAXC * 100 / $MINC - 100))% more files to larger OST $MAXI1"
6061 [ $MAXC -gt $MINC ] || error_ignore "stripe QOS didn't balance free space"
6065 run_test 116a "stripe QOS: free space balance ==================="
6067 test_116b() { # LU-2093
6068 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
6070 old_rr=$(do_facet $SINGLEMDS lctl get_param -n lov.*mdtlov*.qos_threshold_rr)
6071 do_facet $SINGLEMDS lctl set_param lov.*mdtlov*.qos_threshold_rr 0
6073 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
6074 createmany -o $DIR/$tdir/f- 20 || error "can't create"
6075 do_facet $SINGLEMDS lctl set_param fail_loc=0
6077 do_facet $SINGLEMDS lctl set_param lov.*mdtlov*.qos_threshold_rr $old_rr
6079 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
6081 test_117() # bug 10891
6083 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
6084 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
6085 lctl set_param fail_loc=0x21e
6086 > $DIR/$tfile || error "truncate failed"
6087 lctl set_param fail_loc=0
6088 echo "Truncate succeeded."
6091 run_test 117 "verify fsfilt_extend =========="
6093 export OLD_RESENDCOUNT=""
6094 set_resend_count () {
6095 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
6096 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -1)
6097 lctl set_param -n $PROC_RESENDCOUNT $1
6098 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
6101 [ "$SLOW" = "no" ] && set_resend_count 4 # for reduce test_118* time (bug 14842)
6103 # Reset async IO behavior after error case
6105 FILE=$DIR/reset_async
6107 # Ensure all OSCs are cleared
6108 $SETSTRIPE -c -1 $FILE
6109 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
6114 test_118a() #bug 11710
6118 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6119 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6120 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
6122 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6123 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6128 run_test 118a "verify O_SYNC works =========="
6132 remote_ost_nodsh && skip "remote OST with nodsh" && return
6136 #define OBD_FAIL_OST_ENOENT 0x217
6137 set_nodes_failloc "$(osts_nodes)" 0x217
6138 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6140 set_nodes_failloc "$(osts_nodes)" 0
6141 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6142 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6145 if [[ $RC -eq 0 ]]; then
6146 error "Must return error due to dropped pages, rc=$RC"
6150 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6151 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6155 echo "Dirty pages not leaked on ENOENT"
6157 # Due to the above error the OSC will issue all RPCs syncronously
6158 # until a subsequent RPC completes successfully without error.
6159 $MULTIOP $DIR/$tfile Ow4096yc
6164 run_test 118b "Reclaim dirty pages on fatal error =========="
6168 remote_ost_nodsh && skip "remote OST with nodsh" && return
6172 #define OBD_FAIL_OST_EROFS 0x216
6173 set_nodes_failloc "$(osts_nodes)" 0x216
6175 # multiop should block due to fsync until pages are written
6176 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
6180 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
6181 error "Multiop failed to block on fsync, pid=$MULTIPID"
6184 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6186 if [[ $WRITEBACK -eq 0 ]]; then
6187 error "No page in writeback, writeback=$WRITEBACK"
6190 set_nodes_failloc "$(osts_nodes)" 0
6193 if [[ $RC -ne 0 ]]; then
6194 error "Multiop fsync failed, rc=$RC"
6197 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6198 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6200 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6201 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6205 echo "Dirty pages flushed via fsync on EROFS"
6208 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
6212 remote_ost_nodsh && skip "remote OST with nodsh" && return
6216 #define OBD_FAIL_OST_BRW_PAUSE_BULK
6217 set_nodes_failloc "$(osts_nodes)" 0x214
6218 # multiop should block due to fsync until pages are written
6219 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
6223 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
6224 error "Multiop failed to block on fsync, pid=$MULTIPID"
6227 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6229 if [[ $WRITEBACK -eq 0 ]]; then
6230 error "No page in writeback, writeback=$WRITEBACK"
6233 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
6234 set_nodes_failloc "$(osts_nodes)" 0
6236 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6237 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6239 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6240 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6244 echo "Dirty pages gaurenteed flushed via fsync"
6247 run_test 118d "Fsync validation inject a delay of the bulk =========="
6252 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
6253 lctl set_param fail_loc=0x8000040a
6255 # Should simulate EINVAL error which is fatal
6256 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6258 if [[ $RC -eq 0 ]]; then
6259 error "Must return error due to dropped pages, rc=$RC"
6262 lctl set_param fail_loc=0x0
6264 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6265 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6266 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6268 if [[ $LOCKED -ne 0 ]]; then
6269 error "Locked pages remain in cache, locked=$LOCKED"
6272 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6273 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6277 echo "No pages locked after fsync"
6282 run_test 118f "Simulate unrecoverable OSC side error =========="
6287 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
6288 lctl set_param fail_loc=0x406
6290 # simulate local -ENOMEM
6291 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6294 lctl set_param fail_loc=0
6295 if [[ $RC -eq 0 ]]; then
6296 error "Must return error due to dropped pages, rc=$RC"
6299 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6300 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6301 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6303 if [[ $LOCKED -ne 0 ]]; then
6304 error "Locked pages remain in cache, locked=$LOCKED"
6307 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6308 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6312 echo "No pages locked after fsync"
6317 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
6320 remote_ost_nodsh && skip "remote OST with nodsh" && return
6324 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
6325 set_nodes_failloc "$(osts_nodes)" 0x20e
6326 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
6327 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6330 set_nodes_failloc "$(osts_nodes)" 0
6331 if [[ $RC -eq 0 ]]; then
6332 error "Must return error due to dropped pages, rc=$RC"
6335 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6336 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6337 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6339 if [[ $LOCKED -ne 0 ]]; then
6340 error "Locked pages remain in cache, locked=$LOCKED"
6343 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6344 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6348 echo "No pages locked after fsync"
6352 run_test 118h "Verify timeout in handling recoverables errors =========="
6354 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
6357 remote_ost_nodsh && skip "remote OST with nodsh" && return
6361 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
6362 set_nodes_failloc "$(osts_nodes)" 0x20e
6364 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
6365 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
6368 set_nodes_failloc "$(osts_nodes)" 0
6372 if [[ $RC -ne 0 ]]; then
6373 error "got error, but should be not, rc=$RC"
6376 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6377 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6378 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
6379 if [[ $LOCKED -ne 0 ]]; then
6380 error "Locked pages remain in cache, locked=$LOCKED"
6383 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6384 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6388 echo "No pages locked after fsync"
6392 run_test 118i "Fix error before timeout in recoverable error =========="
6394 [ "$SLOW" = "no" ] && set_resend_count 4
6397 remote_ost_nodsh && skip "remote OST with nodsh" && return
6401 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
6402 set_nodes_failloc "$(osts_nodes)" 0x220
6404 # return -EIO from OST
6405 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6407 set_nodes_failloc "$(osts_nodes)" 0x0
6408 if [[ $RC -eq 0 ]]; then
6409 error "Must return error due to dropped pages, rc=$RC"
6412 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6413 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6414 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
6415 if [[ $LOCKED -ne 0 ]]; then
6416 error "Locked pages remain in cache, locked=$LOCKED"
6419 # in recoverable error on OST we want resend and stay until it finished
6420 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6421 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6425 echo "No pages locked after fsync"
6429 run_test 118j "Simulate unrecoverable OST side error =========="
6433 remote_ost_nodsh && skip "remote OSTs with nodsh" && return
6435 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
6436 set_nodes_failloc "$(osts_nodes)" 0x20e
6439 for ((i=0;i<10;i++)); do
6440 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
6441 error "dd to $DIR/$tdir/$tfile-$i failed" )&
6448 set_nodes_failloc "$(osts_nodes)" 0
6451 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
6457 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
6460 run_test 118l "fsync dir ========="
6462 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
6464 test_119a() # bug 11737
6466 BSIZE=$((512 * 1024))
6467 directio write $DIR/$tfile 0 1 $BSIZE
6468 # We ask to read two blocks, which is more than a file size.
6469 # directio will indicate an error when requested and actual
6470 # sizes aren't equeal (a normal situation in this case) and
6471 # print actual read amount.
6472 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
6473 if [ "$NOB" != "$BSIZE" ]; then
6474 error "read $NOB bytes instead of $BSIZE"
6478 run_test 119a "Short directIO read must return actual read amount"
6480 test_119b() # bug 11737
6482 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
6484 $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
6485 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
6487 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) || \
6488 error "direct read failed"
6491 run_test 119b "Sparse directIO read must return actual read amount"
6493 test_119c() # bug 13099
6496 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
6497 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
6500 run_test 119c "Testing for direct read hitting hole"
6502 test_119d() # bug 15950
6504 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
6505 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
6507 $SETSTRIPE $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
6508 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
6509 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
6510 lctl set_param fail_loc=0x40d
6511 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
6514 cat $DIR/$tfile > /dev/null &
6515 lctl set_param fail_loc=0
6518 log "the DIO writes have completed, now wait for the reads (should not block very long)"
6520 [ -n "`ps h -p $pid_reads -o comm`" ] && \
6521 error "the read rpcs have not completed in 2s"
6523 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
6525 run_test 119d "The DIO path should try to send a new rpc once one is completed"
6529 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6530 skip "no early lock cancel on server" && return 0
6531 lru_resize_disable mdc
6532 lru_resize_disable osc
6533 cancel_lru_locks mdc
6534 stat $DIR/$tdir > /dev/null
6535 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6536 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6538 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6539 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6540 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6541 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6542 lru_resize_enable mdc
6543 lru_resize_enable osc
6545 run_test 120a "Early Lock Cancel: mkdir test"
6549 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6550 skip "no early lock cancel on server" && return 0
6551 lru_resize_disable mdc
6552 lru_resize_disable osc
6553 cancel_lru_locks mdc
6554 stat $DIR/$tdir > /dev/null
6555 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6556 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6558 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6559 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6560 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6561 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6562 lru_resize_enable mdc
6563 lru_resize_enable osc
6565 run_test 120b "Early Lock Cancel: create test"
6569 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6570 skip "no early lock cancel on server" && return 0
6571 lru_resize_disable mdc
6572 lru_resize_disable osc
6573 mkdir -p $DIR/$tdir/d1 $DIR/$tdir/d2
6574 touch $DIR/$tdir/d1/f1
6575 cancel_lru_locks mdc
6576 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
6577 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6578 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6579 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
6580 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6581 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6582 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6583 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6584 lru_resize_enable mdc
6585 lru_resize_enable osc
6587 run_test 120c "Early Lock Cancel: link test"
6591 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6592 skip "no early lock cancel on server" && return 0
6593 lru_resize_disable mdc
6594 lru_resize_disable osc
6596 cancel_lru_locks mdc
6597 stat $DIR/$tdir > /dev/null
6598 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6599 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6600 chmod a+x $DIR/$tdir
6601 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6602 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6603 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6604 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6605 lru_resize_enable mdc
6606 lru_resize_enable osc
6608 run_test 120d "Early Lock Cancel: setattr test"
6612 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6613 skip "no early lock cancel on server" && return 0
6614 lru_resize_disable mdc
6615 lru_resize_disable osc
6616 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
6617 cancel_lru_locks mdc
6618 cancel_lru_locks osc
6619 dd if=$DIR/$tdir/f1 of=/dev/null
6620 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
6621 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6622 awk '/ldlm_cancel/ {print $2}'`
6623 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6624 awk '/ldlm_bl_callback/ {print $2}'`
6625 unlink $DIR/$tdir/f1
6626 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6627 awk '/ldlm_cancel/ {print $2}'`
6628 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6629 awk '/ldlm_bl_callback/ {print $2}'`
6630 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6631 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6632 lru_resize_enable mdc
6633 lru_resize_enable osc
6635 run_test 120e "Early Lock Cancel: unlink test"
6638 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6639 skip "no early lock cancel on server" && return 0
6641 lru_resize_disable mdc
6642 lru_resize_disable osc
6643 mkdir -p $DIR/$tdir/d1 $DIR/$tdir/d2
6644 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
6645 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
6646 cancel_lru_locks mdc
6647 cancel_lru_locks osc
6648 dd if=$DIR/$tdir/d1/f1 of=/dev/null
6649 dd if=$DIR/$tdir/d2/f2 of=/dev/null
6650 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
6651 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6652 awk '/ldlm_cancel/ {print $2}'`
6653 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6654 awk '/ldlm_bl_callback/ {print $2}'`
6655 mv $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
6656 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6657 awk '/ldlm_cancel/ {print $2}'`
6658 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6659 awk '/ldlm_bl_callback/ {print $2}'`
6660 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6661 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6662 lru_resize_enable mdc
6663 lru_resize_enable osc
6665 run_test 120f "Early Lock Cancel: rename test"
6668 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6669 skip "no early lock cancel on server" && return 0
6670 lru_resize_disable mdc
6671 lru_resize_disable osc
6673 echo create $count files
6675 cancel_lru_locks mdc
6676 cancel_lru_locks osc
6679 can0=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6680 awk '/ldlm_cancel/ {print $2}'`
6681 blk0=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6682 awk '/ldlm_bl_callback/ {print $2}'`
6683 createmany -o $DIR/$tdir/f $count
6685 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6686 awk '/ldlm_cancel/ {print $2}'`
6687 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6688 awk '/ldlm_bl_callback/ {print $2}'`
6690 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
6691 echo rm $count files
6694 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6695 awk '/ldlm_cancel/ {print $2}'`
6696 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6697 awk '/ldlm_bl_callback/ {print $2}'`
6699 echo total: $count removes in $((t2-t1))
6700 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
6702 # wait for commitment of removal
6703 lru_resize_enable mdc
6704 lru_resize_enable osc
6706 run_test 120g "Early Lock Cancel: performance test"
6708 test_121() { #bug #10589
6710 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
6711 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
6712 lctl set_param fail_loc=0x310
6713 cancel_lru_locks osc > /dev/null
6714 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
6715 lctl set_param fail_loc=0
6716 [ "$reads" -eq "$writes" ] || error "read" $reads "blocks, must be" $writes
6718 run_test 121 "read cancel race ========="
6720 test_123a() { # was test 123, statahead(bug 11401)
6722 if [ -z "$(grep "processor.*: 1" /proc/cpuinfo)" ]; then
6723 log "testing on UP system. Performance may be not as good as expected."
6729 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
6730 [ $NUMFREE -gt 100000 ] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
6732 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
6733 createmany -o $DIR/$tdir/$tfile $j $((i - j))
6735 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
6736 lctl set_param -n llite.*.statahead_max 0
6737 lctl get_param llite.*.statahead_max
6738 cancel_lru_locks mdc
6739 cancel_lru_locks osc
6741 time ls -l $DIR/$tdir | wc -l
6743 delta=$((etime - stime))
6744 log "ls $i files without statahead: $delta sec"
6745 lctl set_param llite.*.statahead_max=$max
6747 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
6748 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
6749 cancel_lru_locks mdc
6750 cancel_lru_locks osc
6752 time ls -l $DIR/$tdir | wc -l
6754 delta_sa=$((etime - stime))
6755 log "ls $i files with statahead: $delta_sa sec"
6756 lctl get_param -n llite.*.statahead_stats
6757 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
6759 [ $swrong -lt $ewrong ] && log "statahead was stopped, maybe too many locks held!"
6760 [ $delta -eq 0 -o $delta_sa -eq 0 ] && continue
6762 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
6763 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
6764 lctl set_param -n llite.*.statahead_max 0
6765 lctl get_param llite.*.statahead_max
6766 cancel_lru_locks mdc
6767 cancel_lru_locks osc
6769 time ls -l $DIR/$tdir | wc -l
6771 delta=$((etime - stime))
6772 log "ls $i files again without statahead: $delta sec"
6773 lctl set_param llite.*.statahead_max=$max
6774 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
6775 if [ $SLOWOK -eq 0 ]; then
6776 error "ls $i files is slower with statahead!"
6778 log "ls $i files is slower with statahead!"
6784 [ $delta -gt 20 ] && break
6785 [ $delta -gt 8 ] && MULT=$((50 / delta))
6786 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
6794 delta=$((etime - stime))
6795 log "rm -r $DIR/$tdir/: $delta seconds"
6797 lctl get_param -n llite.*.statahead_stats
6799 run_test 123a "verify statahead work"
6801 test_123b () { # statahead(bug 15027)
6803 createmany -o $DIR/$tdir/$tfile-%d 1000
6805 cancel_lru_locks mdc
6806 cancel_lru_locks osc
6808 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
6809 lctl set_param fail_loc=0x80000803
6810 ls -lR $DIR/$tdir > /dev/null
6812 lctl set_param fail_loc=0x0
6813 lctl get_param -n llite.*.statahead_stats
6818 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
6821 [ -z "`lctl get_param -n mdc.*.connect_flags | grep lru_resize`" ] && \
6822 skip "no lru resize on server" && return 0
6824 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
6826 log "create $NR files at $DIR/$tdir"
6827 createmany -o $DIR/$tdir/f $NR ||
6828 error "failed to create $NR files in $DIR/$tdir"
6830 cancel_lru_locks mdc
6831 ls -l $DIR/$tdir > /dev/null
6835 for VALUE in `lctl get_param ldlm.namespaces.*mdc-*.lru_size`; do
6836 local PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
6837 LRU_SIZE=$(lctl get_param -n $PARAM)
6838 if [ $LRU_SIZE -gt $(default_lru_size) ]; then
6839 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
6841 log "NS=$(basename $NSDIR)"
6846 if [ -z "$NSDIR" -o $LRU_SIZE -lt $(default_lru_size) ]; then
6847 skip "Not enough cached locks created!"
6854 # We know that lru resize allows one client to hold $LIMIT locks
6855 # for 10h. After that locks begin to be killed by client.
6857 local LIMIT=`lctl get_param -n $NSDIR.pool.limit`
6860 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
6861 # killing locks. Some time was spent for creating locks. This means
6862 # that up to the moment of sleep finish we must have killed some of
6863 # them (10-100 locks). This depends on how fast ther were created.
6864 # Many of them were touched in almost the same moment and thus will
6865 # be killed in groups.
6866 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
6868 # Use $LRU_SIZE_B here to take into account real number of locks
6869 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
6870 local LRU_SIZE_B=$LRU_SIZE
6872 local OLD_LVF=`lctl get_param -n $NSDIR.pool.lock_volume_factor`
6873 log "OLD_LVF=$OLD_LVF"
6874 lctl set_param -n $NSDIR.pool.lock_volume_factor $LVF
6876 # Let's make sure that we really have some margin. Client checks
6877 # cached locks every 10 sec.
6879 log "Sleep ${SLEEP} sec"
6881 while ((SEC<$SLEEP)); do
6885 LRU_SIZE=`lctl get_param -n $NSDIR/lru_size`
6889 lctl set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
6890 local LRU_SIZE_A=`lctl get_param -n $NSDIR.lru_size`
6892 [ $LRU_SIZE_B -gt $LRU_SIZE_A ] || {
6893 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
6894 unlinkmany $DIR/$tdir/f $NR
6898 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
6899 log "unlink $NR files at $DIR/$tdir"
6900 unlinkmany $DIR/$tdir/f $NR
6902 run_test 124a "lru resize ======================================="
6904 get_max_pool_limit()
6906 local limit=`lctl get_param -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit`
6909 if test $l -gt $max; then
6917 [ -z "`lctl get_param -n mdc.*.connect_flags | grep lru_resize`" ] && \
6918 skip "no lru resize on server" && return 0
6920 LIMIT=`get_max_pool_limit`
6922 NR=$(($(default_lru_size)*20))
6923 if [ $NR -gt $LIMIT ]; then
6924 log "Limit lock number by $LIMIT locks"
6927 lru_resize_disable mdc
6928 mkdir -p $DIR/$tdir/disable_lru_resize ||
6929 error "failed to create $DIR/$tdir/disable_lru_resize"
6931 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
6932 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
6933 cancel_lru_locks mdc
6936 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
6939 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
6942 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
6946 nolruresize_delta=$((etime-stime))
6947 log "ls -la time: $nolruresize_delta seconds"
6948 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
6949 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
6951 lru_resize_enable mdc
6952 mkdir -p $DIR/$tdir/enable_lru_resize ||
6953 error "failed to create $DIR/$tdir/enable_lru_resize"
6955 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
6956 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
6957 cancel_lru_locks mdc
6960 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
6963 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
6966 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
6970 lruresize_delta=$((etime-stime))
6971 log "ls -la time: $lruresize_delta seconds"
6972 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
6974 if [ $lruresize_delta -gt $nolruresize_delta ]; then
6975 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
6976 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
6977 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
6979 log "lru resize performs the same with no lru resize"
6981 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
6983 run_test 124b "lru resize (performance test) ======================="
6985 test_125() { # 13358
6986 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
6987 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
6988 mkdir -p $DIR/d125 || error "mkdir failed"
6989 $SETSTRIPE -S 65536 -c -1 $DIR/d125 || error "setstripe failed"
6990 setfacl -R -m u:bin:rwx $DIR/d125 || error "setfacl $DIR/d125 failed"
6991 ls -ld $DIR/d125 || error "cannot access $DIR/d125"
6993 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
6995 test_126() { # bug 12829/13455
6996 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
6997 [ "$UID" != 0 ] && skip_env "skipping $TESTNAME (must run as root)" && return
6998 $GSS && skip "must run as gss disabled" && return
7000 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
7001 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
7003 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
7005 run_test 126 "check that the fsgid provided by the client is taken into account"
7007 test_127a() { # bug 15521
7008 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
7009 $LCTL set_param osc.*.stats=0
7010 FSIZE=$((2048 * 1024))
7011 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
7012 cancel_lru_locks osc
7013 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
7015 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
7016 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
7017 echo "got $COUNT $NAME"
7018 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
7019 eval $NAME=$COUNT || error "Wrong proc format"
7022 read_bytes|write_bytes)
7023 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
7024 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
7025 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
7026 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
7027 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
7028 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
7029 error "sumsquare is too small: $SUMSQ"
7030 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
7031 error "sumsquare is too big: $SUMSQ"
7035 done < $DIR/${tfile}.tmp
7037 #check that we actually got some stats
7038 [ "$read_bytes" ] || error "Missing read_bytes stats"
7039 [ "$write_bytes" ] || error "Missing write_bytes stats"
7040 [ "$read_bytes" != 0 ] || error "no read done"
7041 [ "$write_bytes" != 0 ] || error "no write done"
7043 run_test 127a "verify the client stats are sane"
7045 test_127b() { # bug LU-333
7046 $LCTL set_param llite.*.stats=0
7047 FSIZE=65536 # sized fixed to match PAGE_SIZE for most clients
7048 # perform 2 reads and writes so MAX is different from SUM.
7049 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
7050 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
7051 cancel_lru_locks osc
7052 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
7053 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
7055 $LCTL get_param llite.*.stats | grep samples > $TMP/${tfile}.tmp
7056 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
7057 echo "got $COUNT $NAME"
7058 eval $NAME=$COUNT || error "Wrong proc format"
7062 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
7063 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
7064 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
7065 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
7068 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
7069 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
7070 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
7071 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
7075 done < $TMP/${tfile}.tmp
7077 #check that we actually got some stats
7078 [ "$read_bytes" ] || error "Missing read_bytes stats"
7079 [ "$write_bytes" ] || error "Missing write_bytes stats"
7080 [ "$read_bytes" != 0 ] || error "no read done"
7081 [ "$write_bytes" != 0 ] || error "no write done"
7083 run_test 127b "verify the llite client stats are sane"
7085 test_128() { # bug 15212
7087 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
7092 result=$(grep error $TMP/$tfile.log)
7094 [ -z "$result" ] || error "consecutive find's under interactive lfs failed"
7096 run_test 128 "interactive lfs for 2 consecutive find's"
7103 local LDPROC=/proc/fs/ldiskfs
7105 for facet in $(get_facets MDS); do
7106 canondev=$(ldiskfs_canon *.$(convert_facet2label $facet).mntdev $facet)
7107 do_facet $facet "test -e $LDPROC/$canondev/max_dir_size" || LDPROC=/sys/fs/ldiskfs
7108 do_facet $facet "echo $1 >$LDPROC/$canondev/max_dir_size"
7112 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
7113 skip "Only applicable to ldiskfs-based MDTs"
7116 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7127 while [ ! $I -gt $((MAX * MDSCOUNT)) ]; do
7128 $MULTIOP $DIR/$tdir/$J Oc
7130 if [ $rc -eq $EFBIG ]; then
7132 echo "return code $rc received as expected"
7134 elif [ $rc -ne 0 ]; then
7136 error_exit "return code $rc received instead of expected $EFBIG"
7139 I=$(stat -c%s "$DIR/$tdir")
7143 error "exceeded dir size limit $MAX x $MDSCOUNT $((MAX * MDSCOUNT)) : $I bytes"
7145 run_test 129 "test directory size limit ========================"
7154 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7155 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
7158 trap cleanup_130 EXIT RETURN
7160 local fm_file=$DIR/$tfile
7161 $SETSTRIPE -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
7162 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
7163 error "dd failed for $fm_file"
7165 # LU-1795: test filefrag/FIEMAP once, even if unsupported
7166 filefrag -ves $fm_file
7168 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
7169 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
7170 [ $RC != 0 ] && error "filefrag $fm_file failed"
7172 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
7173 grep -v "ext:" | grep -v "found")
7174 lun=$($GETSTRIPE -i $fm_file)
7176 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
7179 for line in $filefrag_op
7181 frag_lun=`echo $line | cut -d: -f5`
7182 ext_len=`echo $line | cut -d: -f4`
7183 if (( $frag_lun != $lun )); then
7185 error "FIEMAP on 1-stripe file($fm_file) failed"
7188 (( tot_len += ext_len ))
7191 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
7193 error "FIEMAP on 1-stripe file($fm_file) failed;"
7199 echo "FIEMAP on single striped file succeeded"
7201 run_test 130a "FIEMAP (1-stripe file)"
7204 [ "$OSTCOUNT" -lt "2" ] &&
7205 skip_env "skipping FIEMAP on 2-stripe file test" && return
7207 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7208 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
7211 trap cleanup_130 EXIT RETURN
7213 local fm_file=$DIR/$tfile
7214 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
7215 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
7216 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
7218 dd if=/dev/zero of=$fm_file bs=1M count=2 ||
7219 error "dd failed on $fm_file"
7221 filefrag -ves $fm_file || error "filefrag $fm_file failed"
7222 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
7223 grep -v "ext:" | grep -v "found")
7225 last_lun=$(echo $filefrag_op | cut -d: -f5)
7230 for line in $filefrag_op
7232 frag_lun=`echo $line | cut -d: -f5`
7233 ext_len=`echo $line | cut -d: -f4`
7234 if (( $frag_lun != $last_lun )); then
7235 if (( tot_len != 1024 )); then
7237 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 256"
7244 (( tot_len += ext_len ))
7247 if (( num_luns != 2 || tot_len != 1024 )); then
7249 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
7255 echo "FIEMAP on 2-stripe file succeeded"
7257 run_test 130b "FIEMAP (2-stripe file)"
7260 [ "$OSTCOUNT" -lt "2" ] &&
7261 skip_env "skipping FIEMAP on 2-stripe file" && return
7263 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7264 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
7267 trap cleanup_130 EXIT RETURN
7269 local fm_file=$DIR/$tfile
7270 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
7271 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
7272 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
7274 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 || error "dd failed on $fm_file"
7276 filefrag -ves $fm_file || error "filefrag $fm_file failed"
7277 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
7279 last_lun=`echo $filefrag_op | cut -d: -f5`
7284 for line in $filefrag_op
7286 frag_lun=`echo $line | cut -d: -f5`
7287 ext_len=`echo $line | cut -d: -f4`
7288 if (( $frag_lun != $last_lun )); then
7289 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
7290 if (( logical != 512 )); then
7292 error "FIEMAP on $fm_file failed; returned logical start for lun $logical instead of 512"
7295 if (( tot_len != 512 )); then
7297 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
7304 (( tot_len += ext_len ))
7307 if (( num_luns != 2 || tot_len != 512 )); then
7309 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
7315 echo "FIEMAP on 2-stripe file with hole succeeded"
7317 run_test 130c "FIEMAP (2-stripe file with hole)"
7320 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping FIEMAP on N-stripe file test" && return
7322 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7323 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
7325 trap cleanup_130 EXIT RETURN
7327 local fm_file=$DIR/$tfile
7328 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file||error "setstripe on $fm_file"
7329 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
7330 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
7331 dd if=/dev/zero of=$fm_file bs=1M count=$OSTCOUNT || error "dd failed on $fm_file"
7333 filefrag -ves $fm_file || error "filefrag $fm_file failed"
7334 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
7336 last_lun=`echo $filefrag_op | cut -d: -f5`
7341 for line in $filefrag_op
7343 frag_lun=`echo $line | cut -d: -f5`
7344 ext_len=`echo $line | cut -d: -f4`
7345 if (( $frag_lun != $last_lun )); then
7346 if (( tot_len != 1024 )); then
7348 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
7355 (( tot_len += ext_len ))
7358 if (( num_luns != OSTCOUNT || tot_len != 1024 )); then
7360 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
7366 echo "FIEMAP on N-stripe file succeeded"
7368 run_test 130d "FIEMAP (N-stripe file)"
7371 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping continuation FIEMAP test" && return
7373 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7374 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
7376 trap cleanup_130 EXIT RETURN
7378 local fm_file=$DIR/$tfile
7379 $SETSTRIPE -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
7380 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
7381 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
7384 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
7385 for ((i = 0; i < $NUM_BLKS; i++))
7387 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
7390 filefrag -ves $fm_file || error "filefrag $fm_file failed"
7391 filefrag_op=`filefrag -ve $fm_file | grep -A 12000 "ext:" | grep -v "ext:" | grep -v "found"`
7393 last_lun=`echo $filefrag_op | cut -d: -f5`
7398 for line in $filefrag_op
7400 frag_lun=`echo $line | cut -d: -f5`
7401 ext_len=`echo $line | cut -d: -f4`
7402 if (( $frag_lun != $last_lun )); then
7403 if (( tot_len != $EXPECTED_LEN )); then
7405 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of $EXPECTED_LEN"
7412 (( tot_len += ext_len ))
7415 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
7417 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
7423 echo "FIEMAP with continuation calls succeeded"
7425 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
7427 # Test for writev/readv
7429 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 || \
7430 error "writev test failed"
7431 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 || \
7432 error "readv failed"
7435 run_test 131a "test iov's crossing stripe boundary for writev/readv"
7438 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 || \
7439 error "append writev test failed"
7440 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 || \
7441 error "append writev test failed"
7444 run_test 131b "test append writev"
7447 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
7450 run_test 131c "test read/write on file w/o objects"
7453 rwv -f $DIR/$tfile -w -n 1 1572864
7454 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
7455 if [ "$NOB" != 1572864 ]; then
7456 error "Short read filed: read $NOB bytes instead of 1572864"
7460 run_test 131d "test short read"
7463 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
7464 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
7465 error "read hitting hole failed"
7468 run_test 131e "test read hitting hole"
7473 for node in $(osts_nodes); do
7474 gl=$(do_node $node "$LCTL get_param -n ost.OSS.ost.stats" | awk '/'$token'/ {print $2}' | head -n 1)
7475 [ x$gl = x"" ] && gl=0
7476 gl_sum=$((gl_sum + gl))
7486 if [ x$som = x"enabled" ]; then
7487 [ $((gl2 - gl1)) -gt 0 ] && error "no glimpse RPC is expected"
7488 MOUNTOPT=`echo $MOUNTOPT | sed 's/som_preview//g'`
7489 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=disabled"
7491 [ $((gl2 - gl1)) -gt 0 ] || error "some glimpse RPC is expected"
7492 MOUNTOPT="$MOUNTOPT,som_preview"
7493 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=enabled"
7496 # do remount to make new mount-conf parameters actual
7503 test_132() { #1028, SOM
7504 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7505 local num=$(get_mds_dir $DIR)
7506 local mymds=mds${num}
7507 local MOUNTOPT_SAVE=$MOUNTOPT
7509 dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
7510 cancel_lru_locks osc
7512 som1=$(do_facet $mymds "$LCTL get_param mdt.*.som" | awk -F= ' {print $2}' | head -n 1)
7514 gl1=$(get_ost_param "ldlm_glimpse_enqueue")
7515 stat $DIR/$tfile >/dev/null
7516 gl2=$(get_ost_param "ldlm_glimpse_enqueue")
7517 echo "====> SOM is "$som1", "$((gl2 - gl1))" glimpse RPC occured"
7519 som_mode_switch $som1 $gl1 $gl2
7521 dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
7522 cancel_lru_locks osc
7524 som2=$(do_facet $mymds "$LCTL get_param mdt.*.som" | awk -F= ' {print $2}' | head -n 1)
7525 if [ $som1 == $som2 ]; then
7526 error "som is still "$som2
7527 if [ x$som2 = x"enabled" ]; then
7534 gl1=$(get_ost_param "ldlm_glimpse_enqueue")
7535 stat $DIR/$tfile >/dev/null
7536 gl2=$(get_ost_param "ldlm_glimpse_enqueue")
7537 echo "====> SOM is "$som2", "$((gl2 - gl1))" glimpse RPC occured"
7538 som_mode_switch $som2 $gl1 $gl2
7539 MOUNTOPT=$MOUNTOPT_SAVE
7541 run_test 132 "som avoids glimpse rpc"
7547 $SINGLEMDS) res=`do_facet $SINGLEMDS $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$2"`
7549 ost) res=`do_facet ost1 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$2"`
7551 *) error "Wrong argument $1" ;;
7554 count=`echo $res | awk '{print $2}'`
7555 [ -z "$res" ] && error "The counter for $2 on $1 was not incremented"
7556 # if the argument $3 is zero, it means any stat increment is ok.
7557 if [ $3 -gt 0 ] ; then
7558 [ $count -ne $3 ] && error "The $2 counter on $1 is wrong - expected $3"
7563 remote_ost_nodsh && skip "remote OST with nodsh" && return
7564 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7566 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
7567 { skip "MDS doesn't support rename stats"; return; }
7568 local testdir=$DIR/${tdir}/stats_testdir
7569 mkdir -p $DIR/${tdir}
7572 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
7573 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
7575 # verify mdt stats first.
7576 mkdir ${testdir} || error "mkdir failed"
7577 check_stats $SINGLEMDS "mkdir" 1
7578 touch ${testdir}/${tfile} || "touch failed"
7579 check_stats $SINGLEMDS "open" 1
7580 check_stats $SINGLEMDS "close" 1
7581 mknod ${testdir}/${tfile}-pipe p || "mknod failed"
7582 check_stats $SINGLEMDS "mknod" 1
7583 rm -f ${testdir}/${tfile}-pipe || "pipe remove failed"
7584 check_stats $SINGLEMDS "unlink" 1
7585 rm -f ${testdir}/${tfile} || error "file remove failed"
7586 check_stats $SINGLEMDS "unlink" 2
7588 # remove working dir and check mdt stats again.
7589 rmdir ${testdir} || error "rmdir failed"
7590 check_stats $SINGLEMDS "rmdir" 1
7592 local testdir1=$DIR/${tdir}/stats_testdir1
7594 mkdir -p ${testdir1}
7595 touch ${testdir1}/test1
7596 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
7597 check_stats $SINGLEMDS "crossdir_rename" 1
7599 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
7600 check_stats $SINGLEMDS "samedir_rename" 1
7604 run_test 133a "Verifying MDT stats ========================================"
7607 remote_ost_nodsh && skip "remote OST with nodsh" && return
7608 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7609 local testdir=$DIR/${tdir}/stats_testdir
7610 mkdir -p ${testdir} || error "mkdir failed"
7611 touch ${testdir}/${tfile} || "touch failed"
7612 cancel_lru_locks mdc
7615 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
7616 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
7618 # extra mdt stats verification.
7619 chmod 444 ${testdir}/${tfile} || error "chmod failed"
7620 check_stats $SINGLEMDS "setattr" 1
7621 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
7622 if [ $(lustre_version_code $SINGLEMDS) -ne $(version_code 2.2.0) ]
7624 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
7625 check_stats $SINGLEMDS "getattr" 1
7627 $LFS df || error "lfs failed"
7628 check_stats $SINGLEMDS "statfs" 1
7632 run_test 133b "Verifying extra MDT stats =================================="
7635 remote_ost_nodsh && skip "remote OST with nodsh" && return
7636 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7637 local testdir=$DIR/${tdir}/stats_testdir
7638 mkdir -p ${testdir} || error "mkdir failed"
7640 # verify obdfilter stats.
7641 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
7643 cancel_lru_locks osc
7644 wait_delete_completed
7647 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
7648 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
7650 dd if=/dev/zero of=${testdir}/${tfile} conv=notrunc bs=512k count=1 || error "dd failed"
7652 cancel_lru_locks osc
7653 check_stats ost "write" 1
7655 dd if=${testdir}/${tfile} of=/dev/null bs=1k count=1 || error "dd failed"
7656 check_stats ost "read" 1
7658 > ${testdir}/${tfile} || error "truncate failed"
7659 check_stats ost "punch" 1
7661 rm -f ${testdir}/${tfile} || error "file remove failed"
7662 wait_delete_completed
7663 check_stats ost "destroy" 1
7667 run_test 133c "Verifying OST stats ========================================"
7674 while [ $value -ge 2 ]; do
7679 if [ $orig -gt $order ]; then
7687 local size=('K' 'M' 'G' 'T');
7689 local size_string=$value
7691 while [ $value -ge 1024 ]; do
7692 if [ $i -gt 3 ]; then
7693 #T is the biggest unit we get here, if that is bigger,
7695 size_string=${value}T
7698 value=$((value >> 10))
7699 if [ $value -lt 1024 ]; then
7700 size_string=${value}${size[$i]}
7711 local sample=$(do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats |
7712 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
7717 remote_ost_nodsh && skip "remote OST with nodsh" && return
7718 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7719 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
7720 { skip "MDS doesn't support rename stats"; return; }
7722 local testdir1=$DIR/${tdir}/stats_testdir1
7723 local testdir2=$DIR/${tdir}/stats_testdir2
7725 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
7727 mkdir -p ${testdir1} || error "mkdir failed"
7728 mkdir -p ${testdir2} || error "mkdir failed"
7730 createmany -o $testdir1/test 512 || error "createmany failed"
7732 # check samedir rename size
7733 mv ${testdir1}/test0 ${testdir1}/test_0
7735 local testdir1_size=$(ls -l $DIR/${tdir} |
7736 awk '/stats_testdir1/ {print $5}')
7737 local testdir2_size=$(ls -l $DIR/${tdir} |
7738 awk '/stats_testdir2/ {print $5}')
7740 testdir1_size=$(order_2 $testdir1_size)
7741 testdir2_size=$(order_2 $testdir2_size)
7743 testdir1_size=$(size_in_KMGT $testdir1_size)
7744 testdir2_size=$(size_in_KMGT $testdir2_size)
7746 echo "source rename dir size: ${testdir1_size}"
7747 echo "target rename dir size: ${testdir2_size}"
7749 local cmd="do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats"
7750 eval $cmd || error "$cmd failed"
7751 local samedir=$($cmd | grep 'same_dir')
7752 local same_sample=$(get_rename_size $testdir1_size)
7753 [ -z "$samedir" ] && error "samedir_rename_size count error"
7754 [ "$same_sample" -eq 1 ] || error "samedir_rename_size error $same_sample"
7755 echo "Check same dir rename stats success"
7757 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
7759 # check crossdir rename size
7760 mv ${testdir1}/test_0 ${testdir2}/test_0
7762 testdir1_size=$(ls -l $DIR/${tdir} |
7763 awk '/stats_testdir1/ {print $5}')
7764 testdir2_size=$(ls -l $DIR/${tdir} |
7765 awk '/stats_testdir2/ {print $5}')
7767 testdir1_size=$(order_2 $testdir1_size)
7768 testdir2_size=$(order_2 $testdir2_size)
7770 testdir1_size=$(size_in_KMGT $testdir1_size)
7771 testdir2_size=$(size_in_KMGT $testdir2_size)
7773 echo "source rename dir size: ${testdir1_size}"
7774 echo "target rename dir size: ${testdir2_size}"
7776 eval $cmd || error "$cmd failed"
7777 local crossdir=$($cmd | grep 'crossdir')
7778 local src_sample=$(get_rename_size $testdir1_size)
7779 local tgt_sample=$(get_rename_size $testdir2_size)
7780 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
7781 [ "$src_sample" -eq 1 ] || error "crossdir_rename_size error $src_sample"
7782 [ "$tgt_sample" -eq 1 ] || error "crossdir_rename_size error $tgt_sample"
7783 echo "Check cross dir rename stats success"
7786 run_test 133d "Verifying rename_stats ========================================"
7788 test_140() { #bug-17379
7789 mkdir -p $DIR/$tdir || error "Creating dir $DIR/$tdir"
7790 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
7791 cp /usr/bin/stat . || error "Copying stat to $DIR/$tdir"
7793 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
7795 while i=`expr $i + 1`; do
7796 mkdir -p $i || error "Creating dir $i"
7797 cd $i || error "Changing to $i"
7798 ln -s ../stat stat || error "Creating stat symlink"
7799 # Read the symlink until ELOOP present,
7800 # not LBUGing the system is considered success,
7801 # we didn't overrun the stack.
7802 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
7804 if [ $ret -eq 40 ]; then
7807 error "Open stat symlink"
7813 echo "The symlink depth = $i"
7814 [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 ] || error "Invalid symlink depth"
7816 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
7819 local TF="$TMP/$tfile"
7821 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
7823 cancel_lru_locks osc
7824 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
7825 remount_client $MOUNT
7827 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
7830 $TRUNCATE $DIR/$tfile 6000
7831 cancel_lru_locks osc
7832 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
7835 echo "12345" >>$DIR/$tfile
7836 cancel_lru_locks osc
7837 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
7840 echo "12345" >>$DIR/$tfile
7841 cancel_lru_locks osc
7842 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
7847 run_test 150 "truncate/append tests"
7849 function roc_hit() {
7850 local list=$(comma_list $(osts_nodes))
7852 echo $(get_obdfilter_param $list '' stats |
7853 awk '/'cache_hit'/ {sum+=$2} END {print sum}')
7856 function set_cache() {
7859 if [ "$2" == "off" ]; then
7862 local list=$(comma_list $(osts_nodes))
7863 set_obdfilter_param $list '' $1_cache_enable $on
7865 cancel_lru_locks osc
7869 remote_ost_nodsh && skip "remote OST with nodsh" && return
7872 local list=$(comma_list $(osts_nodes))
7874 # check whether obdfilter is cache capable at all
7875 if ! get_obdfilter_param $list '' read_cache_enable >/dev/null; then
7876 echo "not cache-capable obdfilter"
7880 # check cache is enabled on all obdfilters
7881 if get_obdfilter_param $list '' read_cache_enable | grep 0; then
7882 echo "oss cache is disabled"
7886 set_obdfilter_param $list '' writethrough_cache_enable 1
7888 # pages should be in the case right after write
7889 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES || error "dd failed"
7890 local BEFORE=`roc_hit`
7891 cancel_lru_locks osc
7892 cat $DIR/$tfile >/dev/null
7893 local AFTER=`roc_hit`
7894 if ! let "AFTER - BEFORE == CPAGES"; then
7895 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
7898 # the following read invalidates the cache
7899 cancel_lru_locks osc
7900 set_obdfilter_param $list '' read_cache_enable 0
7901 cat $DIR/$tfile >/dev/null
7903 # now data shouldn't be found in the cache
7905 cancel_lru_locks osc
7906 cat $DIR/$tfile >/dev/null
7908 if let "AFTER - BEFORE != 0"; then
7909 error "IN CACHE: before: $BEFORE, after: $AFTER"
7912 set_obdfilter_param $list '' read_cache_enable 1
7915 run_test 151 "test cache on oss and controls ==============================="
7918 local TF="$TMP/$tfile"
7920 # simulate ENOMEM during write
7921 #define OBD_FAIL_OST_NOMEM 0x226
7922 lctl set_param fail_loc=0x80000226
7923 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
7925 sync || error "sync failed"
7926 lctl set_param fail_loc=0
7928 # discard client's cache
7929 cancel_lru_locks osc
7931 # simulate ENOMEM during read
7932 lctl set_param fail_loc=0x80000226
7933 cmp $TF $DIR/$tfile || error "cmp failed"
7934 lctl set_param fail_loc=0
7938 run_test 152 "test read/write with enomem ============================"
7941 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
7943 run_test 153 "test if fdatasync does not crash ======================="
7946 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
7947 { skip "Need MDS version at least 2.2.51"; return 0; }
7949 cp /etc/hosts $DIR/$tfile
7951 fid=$($LFS path2fid $DIR/$tfile)
7953 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
7955 ffid=$DIR/.lustre/fid/$fid
7957 echo "stat fid $fid"
7958 stat $ffid > /dev/null || error "stat $ffid failed."
7959 echo "touch fid $fid"
7960 touch $ffid || error "touch $ffid failed."
7961 echo "write to fid $fid"
7962 cat /etc/hosts > $ffid || error "write $ffid failed."
7963 echo "read fid $fid"
7964 diff /etc/hosts $ffid || error "read $ffid failed."
7965 echo "append write to fid $fid"
7966 cat /etc/hosts >> $ffid || error "append write $ffid failed."
7967 echo "rename fid $fid"
7968 mv $ffid $DIR/$tfile.1 && error "rename $ffid to $tfile.1 should fail."
7970 mv $DIR/$tfile.1 $ffid && error "rename $tfile.1 to $ffid should fail."
7972 echo "truncate fid $fid"
7973 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
7974 echo "link fid $fid"
7975 ln -f $ffid $DIR/tfile.lnk || error "link $ffid failed."
7976 if [ -n $(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl) ]; then
7977 echo "setfacl fid $fid"
7978 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
7979 echo "getfacl fid $fid"
7980 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
7982 echo "unlink fid $fid"
7983 unlink $DIR/.lustre/fid/$fid && error "unlink $ffid should fail."
7984 echo "mknod fid $fid"
7985 mknod $ffid c 1 3 && error "mknod $ffid should fail."
7987 fid=[0xf00000400:0x1:0x0]
7988 ffid=$DIR/.lustre/fid/$fid
7990 echo "stat non-exist fid $fid"
7991 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
7992 echo "write to non-exist fid $fid"
7993 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
7994 echo "link new fid $fid"
7995 ln $DIR/$tfile $ffid && error "link $ffid should fail."
7998 touch $DIR/$tdir/$tfile
7999 fid=$($LFS path2fid $DIR/$tdir)
8001 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
8003 ffid=$DIR/.lustre/fid/$fid
8006 ls $ffid > /dev/null || error "ls $ffid failed."
8007 echo "touch $fid/$tfile.1"
8008 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
8010 echo "touch $DIR/.lustre/fid/$tfile"
8011 touch $DIR/.lustre/fid/$tfile && \
8012 error "touch $DIR/.lustre/fid/$tfile should fail."
8014 echo "setxattr to $DIR/.lustre/fid"
8015 setfattr -n trusted.name1 -v value1 $DIR/.lustre/fid &&
8016 error "setxattr should fail."
8018 echo "listxattr for $DIR/.lustre/fid"
8019 getfattr -d -m "^trusted" $DIR/.lustre/fid &&
8020 error "listxattr should fail."
8022 echo "delxattr from $DIR/.lustre/fid"
8023 setfattr -x trusted.name1 $DIR/.lustre/fid &&
8024 error "delxattr should fail."
8026 echo "touch invalid fid: $DIR/.lustre/fid/[0x200000400:0x2:0x3]"
8027 touch $DIR/.lustre/fid/[0x200000400:0x2:0x3] &&
8028 error "touch invalid fid should fail."
8030 echo "touch non-normal fid: $DIR/.lustre/fid/[0x1:0x2:0x0]"
8031 touch $DIR/.lustre/fid/[0x1:0x2:0x0] &&
8032 error "touch non-normal fid should fail."
8034 echo "rename $tdir to $DIR/.lustre/fid"
8035 mrename $DIR/$tdir $DIR/.lustre/fid &&
8036 error "rename to $DIR/.lustre/fid should fail."
8038 echo "rename .lustre to itself"
8039 fid=$($LFS path2fid $DIR)
8040 mrename $DIR/.lustre $DIR/.lustre/fid/$fid/.lustre &&
8041 error "rename .lustre to itself should fail."
8043 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $DIR/$tfile-2
8044 fid=$($LFS path2fid $DIR/$tfile-2)
8045 echo "cp /etc/passwd $DIR/.lustre/fid/$fid"
8046 cp /etc/passwd $DIR/.lustre/fid/$fid &&
8047 error "create lov data thru .lustre should fail."
8048 echo "cp /etc/passwd $DIR/$tfile-2"
8049 cp /etc/passwd $DIR/$tfile-2 || error "copy to $DIR/$tfile-2 failed."
8050 echo "diff /etc/passwd $DIR/.lustre/fid/$fid"
8051 diff /etc/passwd $DIR/.lustre/fid/$fid ||
8052 error "diff /etc/passwd $DIR/.lustre/fid/$fid failed."
8054 echo "Open-by-FID succeeded"
8056 run_test 154 "Open-by-FID"
8058 test_155_small_load() {
8059 local temp=$TMP/$tfile
8060 local file=$DIR/$tfile
8062 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
8063 error "dd of=$temp bs=6096 count=1 failed"
8065 cancel_lru_locks osc
8066 cmp $temp $file || error "$temp $file differ"
8068 $TRUNCATE $temp 6000
8069 $TRUNCATE $file 6000
8070 cmp $temp $file || error "$temp $file differ (truncate1)"
8072 echo "12345" >>$temp
8073 echo "12345" >>$file
8074 cmp $temp $file || error "$temp $file differ (append1)"
8076 echo "12345" >>$temp
8077 echo "12345" >>$file
8078 cmp $temp $file || error "$temp $file differ (append2)"
8084 test_155_big_load() {
8085 remote_ost_nodsh && skip "remote OST with nodsh" && return
8086 local temp=$TMP/$tfile
8087 local file=$DIR/$tfile
8090 local cache_size=$(do_facet ost$((MAXI+1)) \
8091 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
8092 local large_file_size=$((cache_size * 2))
8094 echo "OSS cache size: $cache_size KB"
8095 echo "Large file size: $large_file_size KB"
8097 [ $MAXV -le $large_file_size ] && \
8098 skip_env "max available OST size needs > $large_file_size KB" && \
8101 $SETSTRIPE $file -c 1 -i $MAXI || error "$SETSTRIPE $file failed"
8103 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k || \
8104 error "dd of=$temp bs=$large_file_size count=1k failed"
8107 cancel_lru_locks osc
8108 cmp $temp $file || error "$temp $file differ"
8116 set_cache writethrough on
8119 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
8123 set_cache writethrough off
8126 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
8130 set_cache writethrough on
8133 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
8137 set_cache writethrough off
8140 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
8144 set_cache writethrough on
8147 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
8151 set_cache writethrough off
8154 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
8158 set_cache writethrough on
8161 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
8165 set_cache writethrough off
8168 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
8174 local file="$DIR/$tfile"
8176 log "Turn on read and write cache"
8178 set_cache writethrough on
8180 log "Write data and read it back."
8181 log "Read should be satisfied from the cache."
8182 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
8184 cancel_lru_locks osc
8185 cat $file >/dev/null
8187 if ! let "AFTER - BEFORE == CPAGES"; then
8188 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
8190 log "cache hits:: before: $BEFORE, after: $AFTER"
8193 log "Read again; it should be satisfied from the cache."
8195 cancel_lru_locks osc
8196 cat $file >/dev/null
8198 if ! let "AFTER - BEFORE == CPAGES"; then
8199 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
8201 log "cache hits:: before: $BEFORE, after: $AFTER"
8205 log "Turn off the read cache and turn on the write cache"
8207 set_cache writethrough on
8209 log "Read again; it should be satisfied from the cache."
8211 cancel_lru_locks osc
8212 cat $file >/dev/null
8214 if ! let "AFTER - BEFORE == CPAGES"; then
8215 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
8217 log "cache hits:: before: $BEFORE, after: $AFTER"
8220 log "Read again; it should not be satisfied from the cache."
8222 cancel_lru_locks osc
8223 cat $file >/dev/null
8225 if ! let "AFTER - BEFORE == 0"; then
8226 error "IN CACHE: before: $BEFORE, after: $AFTER"
8228 log "cache hits:: before: $BEFORE, after: $AFTER"
8231 log "Write data and read it back."
8232 log "Read should be satisfied from the cache."
8233 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
8235 cancel_lru_locks osc
8236 cat $file >/dev/null
8238 if ! let "AFTER - BEFORE == CPAGES"; then
8239 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
8241 log "cache hits:: before: $BEFORE, after: $AFTER"
8244 log "Read again; it should not be satisfied from the cache."
8246 cancel_lru_locks osc
8247 cat $file >/dev/null
8249 if ! let "AFTER - BEFORE == 0"; then
8250 error "IN CACHE: before: $BEFORE, after: $AFTER"
8252 log "cache hits:: before: $BEFORE, after: $AFTER"
8256 log "Turn off read and write cache"
8258 set_cache writethrough off
8260 log "Write data and read it back"
8261 log "It should not be satisfied from the cache."
8263 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
8264 cancel_lru_locks osc
8266 cat $file >/dev/null
8268 if ! let "AFTER - BEFORE == 0"; then
8269 error_ignore 20762 "IN CACHE: before: $BEFORE, after: $AFTER"
8271 log "cache hits:: before: $BEFORE, after: $AFTER"
8275 log "Turn on the read cache and turn off the write cache"
8277 set_cache writethrough off
8279 log "Write data and read it back"
8280 log "It should not be satisfied from the cache."
8282 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
8284 cancel_lru_locks osc
8285 cat $file >/dev/null
8287 if ! let "AFTER - BEFORE == 0"; then
8288 error_ignore 20762 "IN CACHE: before: $BEFORE, after: $AFTER"
8290 log "cache hits:: before: $BEFORE, after: $AFTER"
8293 log "Read again; it should be satisfied from the cache."
8295 cancel_lru_locks osc
8296 cat $file >/dev/null
8298 if ! let "AFTER - BEFORE == CPAGES"; then
8299 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
8301 log "cache hits:: before: $BEFORE, after: $AFTER"
8306 run_test 156 "Verification of tunables ============================"
8310 if [ $MDSCOUNT -gt 1 ]; then
8311 error_ignore 17935 $*
8319 MASK=$(do_facet $SINGLEMDS $LCTL get_param mdd.$MDT0.changelog_mask |\
8322 if [ $MASK -eq 1 ]; then
8323 do_facet $SINGLEMDS $LCTL set_param mdd.$MDT0.changelog_mask="-$1"
8325 do_facet $SINGLEMDS $LCTL set_param mdd.$MDT0.changelog_mask="+$1"
8330 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8331 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
8332 { skip "Need MDS version at least 2.2.0"; return; }
8333 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
8334 echo "Registered as changelog user $USER"
8335 do_facet $SINGLEMDS $LCTL get_param -n mdd.$MDT0.changelog_users | \
8336 grep -q $USER || error "User $USER not found in changelog_users"
8339 mkdir -p $DIR/$tdir/pics/2008/zachy
8340 touch $DIR/$tdir/pics/2008/zachy/timestamp
8341 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
8342 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
8343 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
8344 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
8345 rm $DIR/$tdir/pics/desktop.jpg
8347 $LFS changelog $MDT0 | tail -5
8349 echo "verifying changelog mask"
8350 changelog_chmask "MKDIR"
8351 changelog_chmask "CLOSE"
8353 mkdir -p $DIR/$tdir/pics/zach/sofia
8354 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
8356 changelog_chmask "MKDIR"
8357 changelog_chmask "CLOSE"
8359 mkdir -p $DIR/$tdir/pics/2008/sofia
8360 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
8362 $LFS changelog $MDT0
8363 MKDIRS=$($LFS changelog $MDT0 | tail -5 | grep -c "MKDIR")
8364 CLOSES=$($LFS changelog $MDT0 | tail -5 | grep -c "CLOSE")
8365 [ $MKDIRS -eq 1 ] || err17935 "MKDIR changelog mask count $DIRS != 1"
8366 [ $CLOSES -eq 1 ] || err17935 "CLOSE changelog mask count $DIRS != 1"
8369 echo "verifying target fid"
8370 fidc=$($LFS changelog $MDT0 | grep timestamp | grep "CREAT" | \
8371 tail -1 | awk '{print $6}')
8372 fidf=$($LFS path2fid $DIR/$tdir/pics/zach/timestamp)
8373 [ "$fidc" == "t=$fidf" ] || \
8374 err17935 "fid in changelog $fidc != file fid $fidf"
8375 echo "verifying parent fid"
8376 fidc=$($LFS changelog $MDT0 | grep timestamp | grep "CREAT" | \
8377 tail -1 | awk '{print $7}')
8378 fidf=$($LFS path2fid $DIR/$tdir/pics/zach)
8379 [ "$fidc" == "p=$fidf" ] || \
8380 err17935 "pfid in changelog $fidc != dir fid $fidf"
8382 USER_REC1=$(do_facet $SINGLEMDS $LCTL get_param -n \
8383 mdd.$MDT0.changelog_users | grep $USER | awk '{print $2}')
8384 $LFS changelog_clear $MDT0 $USER $(($USER_REC1 + 5))
8385 USER_REC2=$(do_facet $SINGLEMDS $LCTL get_param -n \
8386 mdd.$MDT0.changelog_users | grep $USER | awk '{print $2}')
8387 echo "verifying user clear: $(( $USER_REC1 + 5 )) == $USER_REC2"
8388 [ $USER_REC2 == $(($USER_REC1 + 5)) ] || \
8389 err17935 "user index should be $(($USER_REC1 + 5)); is $USER_REC2"
8391 MIN_REC=$(do_facet $SINGLEMDS $LCTL get_param mdd.$MDT0.changelog_users | \
8392 awk 'min == "" || $2 < min {min = $2}; END {print min}')
8393 FIRST_REC=$($LFS changelog $MDT0 | head -1 | awk '{print $1}')
8394 echo "verifying min purge: $(( $MIN_REC + 1 )) == $FIRST_REC"
8395 [ $FIRST_REC == $(($MIN_REC + 1)) ] || \
8396 err17935 "first index should be $(($MIN_REC + 1)); is $FIRST_REC"
8398 echo "verifying user deregister"
8399 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
8400 do_facet $SINGLEMDS $LCTL get_param -n mdd.$MDT0.changelog_users | \
8401 grep -q $USER && error "User $USER still found in changelog_users"
8403 USERS=$(( $(do_facet $SINGLEMDS $LCTL get_param -n \
8404 mdd.$MDT0.changelog_users | wc -l) - 2 ))
8405 if [ $USERS -eq 0 ]; then
8406 LAST_REC1=$(do_facet $SINGLEMDS $LCTL get_param -n \
8407 mdd.$MDT0.changelog_users | head -1 | awk '{print $3}')
8408 touch $DIR/$tdir/chloe
8409 LAST_REC2=$(do_facet $SINGLEMDS $LCTL get_param -n \
8410 mdd.$MDT0.changelog_users | head -1 | awk '{print $3}')
8411 echo "verify changelogs are off if we were the only user: $LAST_REC1 == $LAST_REC2"
8412 [ $LAST_REC1 == $LAST_REC2 ] || error "changelogs not off"
8414 echo "$USERS other changelog users; can't verify off"
8417 run_test 160 "changelog sanity"
8421 cp /etc/hosts $DIR/$tdir/$tfile
8422 mkdir $DIR/$tdir/foo1
8423 mkdir $DIR/$tdir/foo2
8424 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
8425 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
8426 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
8427 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
8428 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[')
8429 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
8430 $LFS fid2path $DIR $FID
8431 err17935 "bad link ea"
8434 rm $DIR/$tdir/foo2/zachary
8436 rm $DIR/$tdir/foo2/thor
8438 rm $DIR/$tdir/$tfile
8440 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
8441 if [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ]
8443 $LFS fid2path $DIR $FID
8444 err17935 "bad link rename"
8446 rm $DIR/$tdir/foo2/maggie
8449 local longname=filename_avg_len_is_thirty_two_
8450 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 || \
8451 error "failed to hardlink many files"
8452 links=$($LFS fid2path $DIR $FID | wc -l)
8453 echo -n "${links}/1000 links in link EA"
8454 [ ${links} -gt 60 ] || err17935 "expected at least 60 links in link EA"
8455 unlinkmany $DIR/$tdir/foo2/$longname 1000 || \
8456 error "failed to unlink many hardlinks"
8458 run_test 161 "link ea sanity"
8465 local path=$(${LFS} fid2path $*)
8468 if [ $RC -ne 0 ]; then
8469 err17935 "path looked up of $expected failed. Error $RC"
8471 elif [ "${path}" != "${expected}" ]; then
8472 err17935 "path looked up \"${path}\" instead of \"${expected}\""
8475 echo "fid $fid resolves to path $path (expected $expected)"
8479 # Make changes to filesystem
8480 mkdir -p $DIR/$tdir/d2
8481 touch $DIR/$tdir/d2/$tfile
8482 touch $DIR/$tdir/d2/x1
8483 touch $DIR/$tdir/d2/x2
8484 mkdir -p $DIR/$tdir/d2/a/b/c
8485 mkdir -p $DIR/$tdir/d2/p/q/r
8487 FID=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
8488 check_path "$tdir/d2/$tfile" $FSNAME $FID --link 0
8491 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
8492 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
8493 check_path "$tdir/d2/p/q/r/slink" $FSNAME $FID --link 0
8495 # softlink to wrong file
8496 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
8497 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
8498 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME $FID --link 0
8501 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
8502 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
8503 FID=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
8504 # fid2path dir/fsname should both work
8505 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 1
8506 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR $FID --link 0
8508 # hardlink count: check that there are 2 links
8509 # Doesnt work with CMD yet: 17935
8510 ${LFS} fid2path $DIR $FID | wc -l | grep -q 2 || \
8511 err17935 "expected 2 links"
8513 # hardlink indexing: remove the first link
8514 rm $DIR/$tdir/d2/p/q/r/hlink
8515 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 0
8519 run_test 162 "path lookup sanity"
8522 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8523 copytool --test $FSNAME || { skip "copytool not runnable: $?" && return; }
8526 local uuid=$($LCTL get_param -n mdc.${FSNAME}-MDT0000-mdc-*.uuid)
8527 # this proc file is temporary and linux-only
8528 do_facet $SINGLEMDS lctl set_param mdt.${FSNAME}-MDT0000.mdccomm=$uuid ||\
8529 error "kernel->userspace send failed"
8532 run_test 163 "kernel <-> userspace comms"
8535 # do directio so as not to populate the page cache
8536 log "creating a 10 Mb file"
8537 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
8538 log "starting reads"
8539 dd if=$DIR/$tfile of=/dev/null bs=4096 &
8540 log "truncating the file"
8541 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
8543 kill %+ || true # reads might have finished
8544 echo "wait until dd is finished"
8546 log "removing the temporary file"
8547 rm -rf $DIR/$tfile || error "tmp file removal failed"
8549 run_test 169 "parallel read and truncate should not deadlock"
8552 $LCTL clear # bug 18514
8553 $LCTL debug_daemon start $TMP/${tfile}_log_good
8555 $LCTL debug_daemon stop
8556 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
8557 error "sed failed to read log_good"
8559 $LCTL debug_daemon start $TMP/${tfile}_log_good
8561 $LCTL debug_daemon stop
8563 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
8564 error "lctl df log_bad failed"
8566 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
8567 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
8569 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
8570 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
8572 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
8573 error "bad_line good_line1 good_line2 are empty"
8575 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
8576 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
8577 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
8579 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
8580 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
8581 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
8583 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
8584 error "bad_line_new good_line_new are empty"
8586 local expected_good=$((good_line1 + good_line2*2))
8588 rm -f $TMP/${tfile}*
8589 # LU-231, short malformed line may not be counted into bad lines
8590 if [ $bad_line -ne $bad_line_new ] &&
8591 [ $bad_line -ne $((bad_line_new - 1)) ]; then
8592 error "expected $bad_line bad lines, but got $bad_line_new"
8596 if [ $expected_good -ne $good_line_new ]; then
8597 error "expected $expected_good good lines, but got $good_line_new"
8602 run_test 170 "test lctl df to handle corrupted log ====================="
8604 test_171() { # bug20592
8605 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
8606 $LCTL set_param fail_loc=0x50e
8607 $LCTL set_param fail_val=3000
8608 multiop_bg_pause $DIR/$tfile O_s || true
8610 kill -USR1 $MULTIPID
8614 if dmesg | grep "recursive fault"; then
8615 error "caught a recursive fault"
8617 $LCTL set_param fail_loc=0
8620 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
8622 # it would be good to share it with obdfilter-survey/libecho code
8623 setup_obdecho_osc () {
8626 local obdfilter_name=$2
8627 echo "Creating new osc for $obdfilter_name on $ost_nid"
8628 # make sure we can find loopback nid
8629 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
8631 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
8632 ${obdfilter_name}_osc_UUID || rc=2; }
8633 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
8634 ${obdfilter_name}_UUID $ost_nid || rc=3; }
8638 cleanup_obdecho_osc () {
8639 local obdfilter_name=$1
8640 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
8641 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
8645 obdecho_create_test() {
8650 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
8651 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
8653 if [ $rc -eq 0 ]; then
8654 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
8655 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
8657 echo "New object id is $id"
8658 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec test_brw 10 w v 64 $id" ||
8660 [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec " \
8661 "cleanup" || rc=5; }
8662 [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec " \
8664 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
8669 remote_ost_nodsh && skip "remote OST with nodsh" && return
8673 if ! module_loaded obdecho; then
8674 load_module obdecho/obdecho
8678 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
8679 local host=$(lctl get_param -n osc.$osc.import |
8680 awk '/current_connection:/ {print $2}' )
8681 local target=$(lctl get_param -n osc.$osc.import |
8682 awk '/target:/ {print $2}' )
8683 target=${target%_UUID}
8685 [[ -n $target ]] && { setup_obdecho_osc $host $target || rc=1; } || rc=1
8686 [ $rc -eq 0 ] && { obdecho_create_test ${target}_osc client || rc=2; }
8687 [[ -n $target ]] && cleanup_obdecho_osc $target
8688 [ $rmmod_local -eq 1 ] && rmmod obdecho
8691 run_test 180a "test obdecho on osc"
8694 remote_ost_nodsh && skip "remote OST with nodsh" && return
8696 local rmmod_remote=0
8698 do_facet ost1 "lsmod | grep -q obdecho || " \
8699 "{ insmod ${LUSTRE}/obdecho/obdecho.ko || " \
8700 "modprobe obdecho; }" && rmmod_remote=1
8701 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ {print $4;exit}')
8702 [[ -n $target ]] && { obdecho_create_test $target ost1 || rc=1; }
8703 [ $rmmod_remote -eq 1 ] && do_facet ost1 "rmmod obdecho"
8706 run_test 180b "test obdecho directly on obdfilter"
8708 test_181() { # bug 22177
8709 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
8710 # create enough files to index the directory
8711 createmany -o $DIR/$tdir/foobar 4000
8712 # print attributes for debug purpose
8715 multiop_bg_pause $DIR/$tdir D_Sc || return 1
8717 # remove the files & current working dir
8718 unlinkmany $DIR/$tdir/foobar 4000
8720 kill -USR1 $MULTIPID
8722 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
8725 run_test 181 "Test open-unlinked dir ========================"
8728 # disable MDC RPC lock wouldn't crash client
8732 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
8733 #define OBD_FAIL_MDC_RPCS_SEM 0x804
8734 $LCTL set_param fail_loc=0x804
8736 for (( i=0; i < $tcount; i++ )) ; do
8738 createmany -o $DIR/$tdir/$i/f- $fcount &
8742 for (( i=0; i < $tcount; i++ )) ; do
8743 unlinkmany $DIR/$tdir/$i/f- $fcount &
8749 $LCTL set_param fail_loc=0
8751 run_test 182 "Disable MDC RPCs semaphore wouldn't crash client ================"
8754 check_file_in_pool()
8759 local res=$($GETSTRIPE $file | grep 0x | cut -f2)
8762 for t in $tlist ; do
8763 [ "$i" -eq "$t" ] && continue 2
8766 echo "pool list: $tlist"
8767 echo "striping: $res"
8768 error_noexit "$file not allocated in $pool"
8775 echo "Creating new pool"
8778 create_pool $FSNAME.$pool ||
8779 { error_noexit "No pool created, result code $?"; return 1; }
8780 [ $($LFS pool_list $FSNAME | grep -c $pool) -eq 1 ] ||
8781 { error_noexit "$pool not in lfs pool_list"; return 2; }
8784 pool_add_targets() {
8785 echo "Adding targets to pool"
8791 local list=$(seq $first $step $last)
8793 local t=$(for i in $list; do printf "$FSNAME-OST%04x_UUID " $i; done)
8794 do_facet mgs $LCTL pool_add \
8795 $FSNAME.$pool $FSNAME-OST[$first-$last/$step]
8796 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$pool \
8797 | sort -u | tr '\n' ' ' " "$t" || {
8798 error_noexit "Add to pool failed"
8801 local lfscount=$($LFS pool_list $FSNAME.$pool | grep -c "\-OST")
8802 local addcount=$(((last - first) / step + 1))
8803 [ $lfscount -eq $addcount ] || {
8804 error_noexit "lfs pool_list bad ost count" \
8805 "$lfscount != $addcount"
8813 echo "Setting pool on directory $tdir"
8815 $SETSTRIPE -c 2 -p $pool $tdir && return 0
8817 error_noexit "Cannot set pool $pool to $tdir"
8824 echo "Checking pool on directory $tdir"
8826 local res=$($GETSTRIPE --pool $tdir | sed "s/\s*$//")
8827 [ "$res" = "$pool" ] && return 0
8829 error_noexit "Pool on '$tdir' is '$res', not '$pool'"
8833 pool_dir_rel_path() {
8834 echo "Testing relative path works well"
8839 mkdir -p $root/$tdir/$tdir
8841 pool_set_dir $pool $tdir || return 1
8842 pool_set_dir $pool ./$tdir || return 2
8843 pool_set_dir $pool ../$tdir || return 3
8844 pool_set_dir $pool ../$tdir/$tdir || return 4
8845 rm -rf $tdir; cd - > /dev/null
8848 pool_alloc_files() {
8849 echo "Checking files allocation from directory pool"
8856 for i in $(seq -w 1 $count)
8858 local file=$tdir/file-$i
8860 check_file_in_pool $file $pool "$tlist" || \
8861 failed=$((failed + 1))
8863 [ "$failed" = 0 ] && return 0
8865 error_noexit "$failed files not allocated in $pool"
8869 pool_create_files() {
8870 echo "Creating files in pool"
8878 for i in $(seq -w 1 $count)
8880 local file=$tdir/spoo-$i
8881 $SETSTRIPE -p $pool $file
8882 check_file_in_pool $file $pool "$tlist" || \
8883 failed=$((failed + 1))
8885 [ "$failed" = 0 ] && return 0
8887 error_noexit "$failed files not allocated in $pool"
8892 echo "Checking 'lfs df' output"
8895 local t=$($LCTL get_param -n lov.$FSNAME-clilov-*.pools.$pool |
8897 local res=$($LFS df --pool $FSNAME.$pool |
8899 grep "$FSNAME-OST" |
8901 [ "$res" = "$t" ] && return 0
8903 error_noexit "Pools OSTs '$t' is not '$res' that lfs df reports"
8907 pool_file_rel_path() {
8908 echo "Creating files in a pool with relative pathname"
8913 { error_noexit "unable to create $tdir"; return 1 ; }
8914 local file="/..$tdir/$tfile-1"
8915 $SETSTRIPE -p $pool $file ||
8916 { error_noexit "unable to create $file" ; return 2 ; }
8919 $SETSTRIPE -p $pool $tfile-2 || {
8920 error_noexit "unable to create $tfile-2 in $tdir"
8925 pool_remove_first_target() {
8926 echo "Removing first target from a pool"
8929 local pname="lov.$FSNAME-*.pools.$pool"
8930 local t=$($LCTL get_param -n $pname | head -1)
8931 do_facet mgs $LCTL pool_remove $FSNAME.$pool $t
8932 wait_update $HOSTNAME "lctl get_param -n $pname | grep $t" "" || {
8933 error_noexit "$t not removed from $FSNAME.$pool"
8938 pool_remove_all_targets() {
8939 echo "Removing all targets from pool"
8942 local pname="lov.$FSNAME-*.pools.$pool"
8943 for t in $($LCTL get_param -n $pname | sort -u)
8945 do_facet mgs $LCTL pool_remove $FSNAME.$pool $t
8947 wait_update $HOSTNAME "lctl get_param -n $pname" "" || {
8948 error_noexit "Pool $FSNAME.$pool cannot be drained"
8951 # striping on an empty/nonexistant pool should fall back
8952 # to "pool of everything"
8954 error_noexit "failed to use fallback striping for empty pool"
8957 # setstripe on an empty pool should fail
8958 $SETSTRIPE -p $pool $file 2>/dev/null && {
8959 error_noexit "expected failure when creating file" \
8967 echo "Destroying pool"
8971 do_facet mgs $LCTL pool_destroy $FSNAME.$pool
8974 # striping on an empty/nonexistant pool should fall back
8975 # to "pool of everything"
8977 error_noexit "failed to use fallback striping for missing pool"
8980 # setstripe on an empty pool should fail
8981 $SETSTRIPE -p $pool $file 2>/dev/null && {
8982 error_noexit "expected failure when creating file" \
8987 # get param should return err once pool is gone
8988 if wait_update $HOSTNAME "lctl get_param -n \
8989 lov.$FSNAME-*.pools.$pool 2>/dev/null || echo foo" "foo"
8991 remove_pool_from_list $FSNAME.$pool
8994 error_noexit "Pool $FSNAME.$pool is not destroyed"
8999 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
9001 local POOL=${POOL:-cea1}
9002 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
9003 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
9006 local last_ost=$(($OSTCOUNT - 1))
9008 local ost_list=$(seq $first_ost $ost_step $last_ost)
9009 local ost_range="$first_ost $last_ost $ost_step"
9010 local test_path=$POOL_ROOT/$POOL_DIR_NAME
9011 local file_dir=$POOL_ROOT/file_tst
9015 # former test_200a test_200b
9016 pool_add $POOL || { rc=$? ; break; }
9017 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
9018 # former test_200c test_200d
9020 pool_set_dir $POOL $test_path || { rc=$? ; break; }
9021 pool_check_dir $POOL $test_path || { rc=$? ; break; }
9022 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
9023 || { rc=$? ; break; }
9024 # former test_200e test_200f
9025 local files=$((OSTCOUNT*3))
9026 pool_alloc_files $POOL $test_path $files "$ost_list" \
9027 || { rc=$? ; break; }
9028 pool_create_files $POOL $file_dir $files "$ost_list" \
9029 || { rc=$? ; break; }
9030 # former test_200g test_200h
9031 pool_lfs_df $POOL || { rc=$? ; break; }
9032 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
9034 # former test_201a test_201b test_201c
9035 pool_remove_first_target $POOL || { rc=$? ; break; }
9037 local f=$test_path/$tfile
9038 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
9039 pool_remove $POOL $f || { rc=$? ; break; }
9046 run_test 200 "OST pools"
9048 # usage: default_attr <count | size | offset>
9050 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
9053 # usage: check_default_stripe_attr
9054 check_default_stripe_attr() {
9055 ACTUAL=$($GETSTRIPE $* $DIR/$tdir)
9057 --stripe-count|--count)
9058 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
9059 --stripe-size|--size)
9060 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
9061 --stripe-index|--index)
9064 error "unknown getstripe attr '$1'"
9067 [ $ACTUAL != $EXPECTED ] &&
9068 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
9073 $SETSTRIPE --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
9075 check_default_stripe_attr --stripe-count
9076 check_default_stripe_attr --stripe-size
9077 check_default_stripe_attr --stripe-index
9081 run_test 204a "Print default stripe attributes ================="
9085 $SETSTRIPE --stripe-count 1 $DIR/$tdir
9087 check_default_stripe_attr --stripe-size
9088 check_default_stripe_attr --stripe-index
9092 run_test 204b "Print default stripe size and offset ==========="
9096 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
9098 check_default_stripe_attr --stripe-count
9099 check_default_stripe_attr --stripe-index
9103 run_test 204c "Print default stripe count and offset ==========="
9107 $SETSTRIPE --stripe-index 0 $DIR/$tdir
9109 check_default_stripe_attr --stripe-count
9110 check_default_stripe_attr --stripe-size
9114 run_test 204d "Print default stripe count and size ============="
9118 $SETSTRIPE -d $DIR/$tdir
9120 check_default_stripe_attr --stripe-count --raw
9121 check_default_stripe_attr --stripe-size --raw
9122 check_default_stripe_attr --stripe-index --raw
9126 run_test 204e "Print raw stripe attributes ================="
9130 $SETSTRIPE --stripe-count 1 $DIR/$tdir
9132 check_default_stripe_attr --stripe-size --raw
9133 check_default_stripe_attr --stripe-index --raw
9137 run_test 204f "Print raw stripe size and offset ==========="
9141 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
9143 check_default_stripe_attr --stripe-count --raw
9144 check_default_stripe_attr --stripe-index --raw
9148 run_test 204g "Print raw stripe count and offset ==========="
9152 $SETSTRIPE --stripe-index 0 $DIR/$tdir
9154 check_default_stripe_attr --stripe-count --raw
9155 check_default_stripe_attr --stripe-size --raw
9159 run_test 204h "Print raw stripe count and size ============="
9161 # Figure out which job scheduler is being used, if any,
9163 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
9165 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
9167 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
9169 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
9170 JOBENV=LOADL_STEP_ID
9171 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
9181 # clear old jobstats
9182 do_facet $SINGLEMDS lctl set_param mdt.*.job_stats="clear"
9183 do_facet ost1 lctl set_param obdfilter.*.job_stats="clear"
9185 # use a new JobID for this test, or we might see an old one
9186 [ "$JOBENV" = "FAKE_JOBID" ] && FAKE_JOBID=test_id.$testnum.$RANDOM
9190 log "Using JobID environment variable $JOBENV=$JOBVAL"
9192 if [ $JOBENV = "FAKE_JOBID" ]; then
9193 FAKE_JOBID=$JOBVAL $cmd
9198 if [ "$target" = "mdt" -o "$target" = "both" ]; then
9199 FACET="$SINGLEMDS" # will need to get MDS number for DNE
9200 do_facet $FACET lctl get_param mdt.*.job_stats |
9201 grep $JOBVAL || error "No job stats found on MDT $FACET"
9203 if [ "$target" = "ost" -o "$target" = "both" ]; then
9205 do_facet $FACET lctl get_param obdfilter.*.job_stats |
9206 grep $JOBVAL || error "No job stats found on OST $FACET"
9210 test_205() { # Job stats
9211 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
9212 skip "Server doesn't support jobstats" && return 0
9215 OLD_JOBENV=`$LCTL get_param -n jobid_var`
9216 if [ $OLD_JOBENV != $JOBENV ]; then
9217 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$JOBENV
9218 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" \
9223 cmd="mkdir $DIR/$tfile"
9224 verify_jobstats "$cmd" "mdt"
9226 cmd="rm -fr $DIR/$tfile"
9227 verify_jobstats "$cmd" "mdt"
9229 cmd="mknod $DIR/$tfile c 1 3"
9230 verify_jobstats "$cmd" "mdt"
9232 cmd="rm -f $DIR/$tfile"
9233 verify_jobstats "$cmd" "mdt"
9235 cmd="$SETSTRIPE -i 0 -c 1 $DIR/$tfile"
9236 verify_jobstats "$cmd" "mdt"
9238 cmd="touch $DIR/$tfile"
9239 verify_jobstats "$cmd" "both"
9241 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
9242 verify_jobstats "$cmd" "ost"
9244 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
9245 verify_jobstats "$cmd" "ost"
9247 cmd="$TRUNCATE $DIR/$tfile 0"
9248 verify_jobstats "$cmd" "both"
9250 cmd="mv -f $DIR/$tfile $DIR/jobstats_test_rename"
9251 verify_jobstats "$cmd" "mdt"
9254 rm -f $DIR/jobstats_test_rename
9256 if [ $OLD_JOBENV != $JOBENV ]; then
9257 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$OLD_JOBENV
9258 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" \
9259 $OLD_JOBENV || return 1
9262 run_test 205 "Verify job stats"
9264 # LU-1480, LU-1773 and LU-1657
9267 lfs setstripe -c -1 $DIR/$tdir
9268 #define OBD_FAIL_LOV_INIT 0x1403
9269 $LCTL set_param fail_loc=0xa0001403
9270 $LCTL set_param fail_val=1
9271 touch $DIR/$tdir/$tfile || true
9273 run_test 206 "fail lov_init_raid0() doesn't lbug"
9277 size=$((size % 8192 + 1))
9278 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
9279 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
9280 rm -f $DIR/f212 $DIR/f212.xyz
9282 run_test 212 "Sendfile test ============================================"
9285 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
9286 cancel_lru_locks osc
9287 lctl set_param fail_loc=0x8000040f
9288 # generate a read lock
9289 cat $DIR/$tfile > /dev/null
9290 # write to the file, it will try to cancel the above read lock.
9291 cat /etc/hosts >> $DIR/$tfile
9293 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
9295 test_214() { # for bug 20133
9296 mkdir -p $DIR/d214p/d214c
9297 for (( i=0; i < 340; i++ )) ; do
9298 touch $DIR/d214p/d214c/a$i
9301 ls -l $DIR/d214p || error "ls -l $DIR/d214p failed"
9302 mv $DIR/d214p/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
9303 ls $DIR/d214c || error "ls $DIR/d214c failed"
9304 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
9306 run_test 214 "hash-indexed directory test - bug 20133"
9308 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
9309 create_lnet_proc_files() {
9310 cat /proc/sys/lnet/$1 >$TMP/lnet_$1.out || error "cannot read /proc/sys/lnet/$1"
9311 sysctl lnet.$1 >$TMP/lnet_$1.sys_tmp || error "cannot read lnet.$1"
9313 sed "s/^lnet.$1\ =\ //g" "$TMP/lnet_$1.sys_tmp" >$TMP/lnet_$1.sys
9314 rm -f "$TMP/lnet_$1.sys_tmp"
9317 # counterpart of create_lnet_proc_files
9318 remove_lnet_proc_files() {
9319 rm -f $TMP/lnet_$1.out $TMP/lnet_$1.sys
9322 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
9323 # 3rd arg as regexp for body
9324 check_lnet_proc_stats() {
9325 local l=$(cat "$TMP/lnet_$1" |wc -l)
9326 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
9328 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
9331 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
9332 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
9333 # optional and can be regexp for 2nd line (lnet.routes case)
9334 check_lnet_proc_entry() {
9335 local blp=2 # blp stands for 'position of 1st line of body'
9336 [ "$5" = "" ] || blp=3 # lnet.routes case
9338 local l=$(cat "$TMP/lnet_$1" |wc -l)
9339 # subtracting one from $blp because the body can be empty
9340 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
9342 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
9343 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
9345 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
9346 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
9348 # bail out if any unexpected line happened
9349 sed -n "$blp~1 p" "$TMP/lnet_$1" |grep -Ev "$3"
9350 [ "$?" != 0 ] || error "$2 misformatted"
9353 test_215() { # for bugs 18102, 21079, 21517
9354 local N='(0|[1-9][0-9]*)' # non-negative numeric
9355 local P='[1-9][0-9]*' # positive numeric
9356 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
9357 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
9358 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
9359 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
9361 local L1 # regexp for 1st line
9362 local L2 # regexp for 2nd line (optional)
9363 local BR # regexp for the rest (body)
9365 # /proc/sys/lnet/stats should look as 11 space-separated non-negative numerics
9366 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
9367 create_lnet_proc_files "stats"
9368 check_lnet_proc_stats "stats.out" "/proc/sys/lnet/stats" "$BR"
9369 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
9370 remove_lnet_proc_files "stats"
9372 # /proc/sys/lnet/routes should look like this:
9373 # Routing disabled/enabled
9374 # net hops state router
9375 # where net is a string like tcp0, hops >= 0, state is up/down,
9376 # router is a string like 192.168.1.1@tcp2
9377 L1="^Routing (disabled|enabled)$"
9378 L2="^net +hops +state +router$"
9379 BR="^$NET +$N +(up|down) +$NID$"
9380 create_lnet_proc_files "routes"
9381 check_lnet_proc_entry "routes.out" "/proc/sys/lnet/routes" "$BR" "$L1" "$L2"
9382 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
9383 remove_lnet_proc_files "routes"
9385 # /proc/sys/lnet/routers should look like this:
9386 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
9387 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
9388 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
9389 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
9390 L1="^ref +rtr_ref +alive_cnt +state +last_ping +ping_sent +deadline +down_ni +router$"
9391 BR="^$P +$P +$N +(up|down) +$N +(0|1) +$I +$I +$NID$"
9392 create_lnet_proc_files "routers"
9393 check_lnet_proc_entry "routers.out" "/proc/sys/lnet/routers" "$BR" "$L1"
9394 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
9395 remove_lnet_proc_files "routers"
9397 # /proc/sys/lnet/peers should look like this:
9398 # nid refs state last max rtr min tx min queue
9399 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
9400 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
9401 # numeric (0 or >0 or <0), queue >= 0.
9402 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
9403 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
9404 create_lnet_proc_files "peers"
9405 check_lnet_proc_entry "peers.out" "/proc/sys/lnet/peers" "$BR" "$L1"
9406 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
9407 remove_lnet_proc_files "peers"
9409 # /proc/sys/lnet/buffers should look like this:
9410 # pages count credits min
9411 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
9412 L1="^pages +count +credits +min$"
9413 BR="^ +$N +$N +$I +$I$"
9414 create_lnet_proc_files "buffers"
9415 check_lnet_proc_entry "buffers.out" "/proc/sys/lnet/buffers" "$BR" "$L1"
9416 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
9417 remove_lnet_proc_files "buffers"
9419 # /proc/sys/lnet/nis should look like this:
9420 # nid status alive refs peer rtr max tx min
9421 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
9422 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
9423 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
9424 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
9425 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
9426 create_lnet_proc_files "nis"
9427 check_lnet_proc_entry "nis.out" "/proc/sys/lnet/nis" "$BR" "$L1"
9428 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
9429 remove_lnet_proc_files "nis"
9431 # can we successfully write to /proc/sys/lnet/stats?
9432 echo "0" >/proc/sys/lnet/stats || error "cannot write to /proc/sys/lnet/stats"
9433 sysctl -w lnet.stats=0 || error "cannot write to lnet.stats"
9435 run_test 215 "/proc/sys/lnet exists and has proper content - bugs 18102, 21079, 21517"
9437 test_216() { # bug 20317
9438 remote_ost_nodsh && skip "remote OST with nodsh" && return
9440 local p="$TMP/sanityN-$TESTNAME.parameters"
9441 save_lustre_params $HOSTNAME "osc.*.contention_seconds" > $p
9442 for node in $(osts_nodes); do
9443 save_lustre_params $node "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
9444 save_lustre_params $node "ldlm.namespaces.filter-*.contended_locks" >> $p
9445 save_lustre_params $node "ldlm.namespaces.filter-*.contention_seconds" >> $p
9449 # agressive lockless i/o settings
9450 for node in $(osts_nodes); do
9451 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'
9453 lctl set_param -n osc.*.contention_seconds 60
9455 $DIRECTIO write $DIR/$tfile 0 10 4096
9456 $CHECKSTAT -s 40960 $DIR/$tfile
9458 # disable lockless i/o
9459 for node in $(osts_nodes); do
9460 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'
9462 lctl set_param -n osc.*.contention_seconds 0
9465 dd if=/dev/zero of=$DIR/$tfile count=0
9466 $CHECKSTAT -s 0 $DIR/$tfile
9468 restore_lustre_params <$p
9472 run_test 216 "check lockless direct write works and updates file size and kms correctly"
9474 test_217() { # bug 22430
9478 for node in $(nodes_list); do
9479 nid=$(host_nids_address $node $NETTYPE)
9480 if [[ $nid = *-* ]] ; then
9481 echo "lctl ping $nid@$NETTYPE"
9482 lctl ping $nid@$NETTYPE
9484 echo "skipping $node (no hyphen detected)"
9488 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
9491 # do directio so as not to populate the page cache
9492 log "creating a 10 Mb file"
9493 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
9494 log "starting reads"
9495 dd if=$DIR/$tfile of=/dev/null bs=4096 &
9496 log "truncating the file"
9497 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
9499 kill %+ || true # reads might have finished
9500 echo "wait until dd is finished"
9502 log "removing the temporary file"
9503 rm -rf $DIR/$tfile || error "tmp file removal failed"
9505 run_test 218 "parallel read and truncate should not deadlock ======================="
9508 # write one partial page
9509 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
9510 # set no grant so vvp_io_commit_write will do sync write
9511 $LCTL set_param fail_loc=0x411
9512 # write a full page at the end of file
9513 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
9515 $LCTL set_param fail_loc=0
9516 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
9517 $LCTL set_param fail_loc=0x411
9518 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
9520 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
9522 test_220() { #LU-325
9523 remote_ost_nodsh && skip "remote OST with nodsh" && return
9527 local OST=$(lfs osts | grep ${OSTIDX}": " | \
9528 awk '{print $2}' | sed -e 's/_UUID$//')
9531 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
9532 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
9533 osc.$mdtosc_proc1.prealloc_last_id)
9534 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
9535 osc.$mdtosc_proc1.prealloc_next_id)
9539 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
9540 #define OBD_FAIL_OST_ENOINO 0x229
9541 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
9542 do_facet mgs $LCTL pool_new $FSNAME.$TESTNAME || return 1
9543 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
9545 $SETSTRIPE $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
9547 MDSOBJS=$((last_id - next_id))
9548 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
9550 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
9551 echo "OST still has $count kbytes free"
9553 echo "create $MDSOBJS files @next_id..."
9554 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
9556 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
9557 osc.$mdtosc_proc1.prealloc_last_id)
9558 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
9559 osc.$mdtosc_proc1.prealloc_next_id)
9561 echo "after creation, last_id=$last_id2, next_id=$next_id2"
9566 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
9567 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
9569 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST || return 4
9570 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME || return 5
9571 echo "unlink $MDSOBJS files @$next_id..."
9572 unlinkmany $DIR/$tdir/f $MDSOBJS || return 6
9574 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
9577 dd if=`which date` of=$MOUNT/date oflag=sync
9578 chmod +x $MOUNT/date
9580 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
9581 $LCTL set_param fail_loc=0x80001401
9583 $MOUNT/date > /dev/null
9586 run_test 221 "make sure fault and truncate race to not cause OOM"
9591 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
9592 createmany -o $DIR/$tdir/$tfile 10
9593 cancel_lru_locks mdc
9594 cancel_lru_locks osc
9595 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
9596 $LCTL set_param fail_loc=0x31a
9597 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
9598 $LCTL set_param fail_loc=0
9601 run_test 222a "AGL for ls should not trigger CLIO lock failure ================"
9606 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
9607 createmany -o $DIR/$tdir/$tfile 10
9608 cancel_lru_locks mdc
9609 cancel_lru_locks osc
9610 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
9611 $LCTL set_param fail_loc=0x31a
9612 rm -r $DIR/$tdir || "AGL for rmdir failed"
9613 $LCTL set_param fail_loc=0
9615 run_test 222b "AGL for rmdir should not trigger CLIO lock failure ============="
9620 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
9621 createmany -o $DIR/$tdir/$tfile 10
9622 cancel_lru_locks mdc
9623 cancel_lru_locks osc
9624 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
9625 $LCTL set_param fail_loc=0x31b
9626 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
9627 $LCTL set_param fail_loc=0
9630 run_test 223 "osc reenqueue if without AGL lock granted ======================="
9632 test_224a() { # LU-1039, MRP-303
9633 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
9634 $LCTL set_param fail_loc=0x508
9635 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
9636 $LCTL set_param fail_loc=0
9639 run_test 224a "Don't panic on bulk IO failure"
9641 test_224b() { # LU-1039, MRP-303
9642 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
9643 cancel_lru_locks osc
9644 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
9645 $LCTL set_param fail_loc=0x515
9646 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
9647 $LCTL set_param fail_loc=0
9650 run_test 224b "Don't panic on bulk IO failure"
9652 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
9654 if [ -z ${MDSSURVEY} ]; then
9655 skip_env "mds-survey not found" && return
9657 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
9658 { skip "Need MDS version at least 2.2.51"; return; }
9660 local mds=$(facet_host $SINGLEMDS)
9661 local target=$(do_nodes $mds 'lctl dl' | \
9662 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
9664 local cmd1="file_count=1000 thrhi=4"
9665 local cmd2="dir_count=2 layer=mdd stripe_count=0"
9666 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
9667 local cmd="$cmd1 $cmd2 $cmd3"
9669 rm -f ${TMP}/mds_survey*
9671 eval $cmd || error "mds-survey with zero-stripe failed"
9672 cat ${TMP}/mds_survey*
9673 rm -f ${TMP}/mds_survey*
9675 run_test 225a "Metadata survey sanity with zero-stripe"
9678 if [ -z ${MDSSURVEY} ]; then
9679 skip_env "mds-survey not found" && return
9681 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
9682 { skip "Need MDS version at least 2.2.51"; return; }
9684 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
9685 skip_env "Need to mount OST to test" && return
9688 local mds=$(facet_host $SINGLEMDS)
9689 local target=$(do_nodes $mds 'lctl dl' | \
9690 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
9692 local cmd1="file_count=1000 thrhi=4"
9693 local cmd2="dir_count=2 layer=mdd stripe_count=1"
9694 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
9695 local cmd="$cmd1 $cmd2 $cmd3"
9697 rm -f ${TMP}/mds_survey*
9699 eval $cmd || error "mds-survey with stripe_count failed"
9700 cat ${TMP}/mds_survey*
9701 rm -f ${TMP}/mds_survey*
9703 run_test 225b "Metadata survey sanity with stripe_count = 1"
9705 mcreate_path2fid () {
9711 local path=$DIR/$tdir/$name
9716 $MCREATE --mode=$1 --major=$2 --minor=$3 $path || \
9717 error "error: cannot create $desc"
9719 fid=$($LFS path2fid $path)
9721 [ $rc -ne 0 ] && error "error: cannot get fid of a $desc"
9723 fid_path=$($LFS fid2path $DIR $fid)
9725 [ $rc -ne 0 ] && error "error: cannot get path of a $desc by fid"
9727 [ "$path" == "$fid_path" ] || \
9728 error "error: fid2path returned \`$fid_path', expected \`$path'"
9735 mcreate_path2fid 0010666 0 0 fifo "FIFO"
9736 mcreate_path2fid 0020666 1 3 null "character special file (null)"
9737 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
9738 mcreate_path2fid 0040666 0 0 dir "directory"
9739 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
9740 mcreate_path2fid 0100666 0 0 file "regular file"
9741 mcreate_path2fid 0120666 0 0 link "symbolic link"
9742 mcreate_path2fid 0140666 0 0 sock "socket"
9744 run_test 226 "call path2fid and fid2path on files of all type"
9746 # LU-1299 Executing or running ldd on a truncated executable does not
9747 # cause an out-of-memory condition.
9749 dd if=`which date` of=$MOUNT/date bs=1k count=1
9750 chmod +x $MOUNT/date
9752 $MOUNT/date > /dev/null
9753 ldd $MOUNT/date > /dev/null
9756 run_test 227 "running truncated executable does not cause OOM"
9758 # LU-1512 try to reuse idle OI blocks
9760 [ "$FSTYPE" != "ldiskfs" ] && skip "non-ldiskfs backend" && return
9762 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
9763 local myDIR=$DIR/$tdir
9766 #define OBD_FAIL_SEQ_EXHAUST 0x1002
9767 $LCTL set_param fail_loc=0x80001002
9768 createmany -o $myDIR/t- 10000
9769 $LCTL set_param fail_loc=0
9770 # The guard is current the largest FID holder
9772 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
9774 local IDX=$(($SEQ % 64))
9776 do_facet $SINGLEMDS sync
9777 # Make sure journal flushed.
9779 local blk1=$(do_facet $SINGLEMDS \
9780 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
9781 grep Blockcount | awk '{print $4}')
9783 # Remove old files, some OI blocks will become idle.
9784 unlinkmany $myDIR/t- 10000
9785 # Create new files, idle OI blocks should be reused.
9786 createmany -o $myDIR/t- 2000
9787 do_facet $SINGLEMDS sync
9788 # Make sure journal flushed.
9790 local blk2=$(do_facet $SINGLEMDS \
9791 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
9792 grep Blockcount | awk '{print $4}')
9794 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
9796 run_test 228a "try to reuse idle OI blocks"
9799 [ "$FSTYPE" != "ldiskfs" ] && skip "non-ldiskfs backend" && return
9801 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
9802 local myDIR=$DIR/$tdir
9805 #define OBD_FAIL_SEQ_EXHAUST 0x1002
9806 $LCTL set_param fail_loc=0x80001002
9807 createmany -o $myDIR/t- 10000
9808 $LCTL set_param fail_loc=0
9809 # The guard is current the largest FID holder
9811 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
9813 local IDX=$(($SEQ % 64))
9815 do_facet $SINGLEMDS sync
9816 # Make sure journal flushed.
9818 local blk1=$(do_facet $SINGLEMDS \
9819 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
9820 grep Blockcount | awk '{print $4}')
9822 # Remove old files, some OI blocks will become idle.
9823 unlinkmany $myDIR/t- 10000
9826 stop $SINGLEMDS || error "Fail to stop MDT."
9828 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
9830 df $MOUNT || error "Fail to df."
9831 # Create new files, idle OI blocks should be reused.
9832 createmany -o $myDIR/t- 2000
9833 do_facet $SINGLEMDS sync
9834 # Make sure journal flushed.
9836 local blk2=$(do_facet $SINGLEMDS \
9837 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
9838 grep Blockcount | awk '{print $4}')
9840 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
9842 run_test 228b "idle OI blocks can be reused after MDT restart"
9846 [ "$FSTYPE" != "ldiskfs" ] && skip "non-ldiskfs backend" && return
9848 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
9849 local myDIR=$DIR/$tdir
9852 #define OBD_FAIL_SEQ_EXHAUST 0x1002
9853 $LCTL set_param fail_loc=0x80001002
9854 # 20000 files can guarantee there are index nodes in the OI file
9855 createmany -o $myDIR/t- 20000
9856 $LCTL set_param fail_loc=0
9857 # The guard is current the largest FID holder
9859 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
9861 local IDX=$(($SEQ % 64))
9863 do_facet $SINGLEMDS sync
9864 # Make sure journal flushed.
9866 local blk1=$(do_facet $SINGLEMDS \
9867 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
9868 grep Blockcount | awk '{print $4}')
9870 # Remove old files, some OI blocks will become idle.
9871 unlinkmany $myDIR/t- 20000
9873 # The OI file should become empty now
9875 # Create new files, idle OI blocks should be reused.
9876 createmany -o $myDIR/t- 2000
9877 do_facet $SINGLEMDS sync
9878 # Make sure journal flushed.
9880 local blk2=$(do_facet $SINGLEMDS \
9881 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
9882 grep Blockcount | awk '{print $4}')
9884 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
9886 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
9889 # tests that do cleanup/setup should be run at the end
9894 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
9895 $LCTL set_param fail_loc=0x903
9896 # cancel_lru_locks mgc - does not work due to lctl set_param syntax
9897 for ls in /proc/fs/lustre/ldlm/namespaces/MGC*/lru_size; do
9900 FAIL_ON_ERROR=true cleanup
9901 FAIL_ON_ERROR=true setup
9903 run_test 900 "umount should not race with any mgc requeue thread"
9906 check_and_cleanup_lustre
9907 if [ "$I_MOUNTED" != "yes" ]; then
9908 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true