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: LU2036
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 ========================"
457 LONGSYMLINK="$(dd if=/dev/zero bs=4095 count=1 | tr '\0' 'x')"
458 ln -s $LONGSYMLINK $DIR/$tdir/$tfile
461 run_test 17g "symlinks: really long symlink name ==============================="
463 test_17h() { #bug 17378
464 remote_mds_nodsh && skip "remote MDS with nodsh" && return
466 $SETSTRIPE -c -1 $DIR/$tdir
467 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
468 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000141
469 touch $DIR/$tdir/$tfile || true
471 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
473 test_17i() { #bug 20018
474 remote_mds_nodsh && skip "remote MDS with nodsh" && return
476 local foo=$DIR/$tdir/$tfile
477 ln -s $foo $foo || error "create symlink failed"
478 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
479 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000143
480 ls -l $foo && error "error not detected"
483 run_test 17i "don't panic on short symlink"
485 test_17k() { #bug 22301
486 rsync --help | grep -q xattr ||
487 skip_env "$(rsync --version| head -1) does not support xattrs"
488 mkdir -p $DIR/{$tdir,$tdir.new}
489 touch $DIR/$tdir/$tfile
490 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
491 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
492 error "rsync failed with xattrs enabled"
494 run_test 17k "symlinks: rsync with xattrs enabled ========================="
498 local short_sym="0123456789"
499 local WDIR=$DIR/${tdir}m
506 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
507 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
508 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
510 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
511 skip "only for ldiskfs MDT" && return 0
515 # create a long symlink file
516 for ((i = 0; i < 4; ++i)); do
517 long_sym=${long_sym}${long_sym}
520 echo "create 512 short and long symlink files under $WDIR"
521 for ((i = 0; i < 256; ++i)); do
522 ln -sf ${long_sym}"a5a5" $WDIR/long-$i
523 ln -sf ${short_sym}"a5a5" $WDIR/short-$i
531 echo "recreate the 512 symlink files with a shorter string"
532 for ((i = 0; i < 512; ++i)); do
533 # rewrite the symlink file with a shorter string
534 ln -sf ${long_sym} $WDIR/long-$i
535 ln -sf ${short_sym} $WDIR/short-$i
538 mds_index=$($LFS getstripe -M $WDIR)
539 mds_index=$((mds_index+1))
540 devname=$(mdsdevname $mds_index)
541 cmd="$E2FSCK -fnvd $devname"
543 echo "stop and checking mds${mds_index}: $cmd"
544 # e2fsck should not return error
545 stop mds${mds_index} -f
546 do_facet mds${mds_index} $cmd || rc=$?
548 start mds${mds_index} $devname $MDS_MOUNT_OPTS
549 df $MOUNT > /dev/null 2>&1
550 [ $rc -ne 0 ] && error "e2fsck should not report error upon "\
551 "short/long symlink MDT: rc=$rc"
554 run_test 17m "run e2fsck against MDT which contains short/long symlink"
560 run_test 18 "touch .../f ; ls ... =============================="
566 $CHECKSTAT -a $DIR/f19 || error
568 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
571 ls -l $DIR/f19 && error || true
573 run_test 19b "ls -l .../f19 (should return error) =============="
576 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
577 $RUNAS touch $DIR/f19 && error || true
579 run_test 19c "$RUNAS touch .../f19 (should return error) =="
582 cat $DIR/f19 && error || true
584 run_test 19d "cat .../f19 (should return error) =============="
596 $CHECKSTAT -a $DIR/f || error
598 run_test 20 "touch .../f ; ls -l ... ==========================="
602 [ -f $DIR/d21/dangle ] && rm -f $DIR/d21/dangle
603 ln -s dangle $DIR/d21/link
604 echo foo >> $DIR/d21/link
606 $CHECKSTAT -t link $DIR/d21/link || error
607 $CHECKSTAT -f -t file $DIR/d21/link || error
609 run_test 21 "write to dangling link ============================"
614 chown $RUNAS_ID:$RUNAS_GID $WDIR
615 (cd $WDIR || error "cd $WDIR failed";
616 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
618 ls -lR $WDIR/etc || error "ls -lR $WDIR/etc failed"
619 $CHECKSTAT -t dir $WDIR/etc || error "checkstat -t dir failed"
620 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $WDIR/etc || error "checkstat -u failed"
622 run_test 22 "unpack tar archive as non-root user ==============="
627 local file=$DIR/$tdir/$tfile
629 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
630 openfile -f O_CREAT:O_EXCL $file &&
631 error "$file recreate succeeded" || true
633 run_test 23a "O_CREAT|O_EXCL in subdir =========================="
635 test_23b() { # bug 18988
637 local file=$DIR/$tdir/$tfile
640 echo foo > $file || error "write filed"
641 echo bar >> $file || error "append filed"
642 $CHECKSTAT -s 8 $file || error "wrong size"
645 run_test 23b "O_APPEND check =========================="
648 echo '== rename sanity =============================================='
649 echo '-- same directory rename'
652 mv $DIR/R1/f $DIR/R1/g
653 $CHECKSTAT -t file $DIR/R1/g || error
655 run_test 24a "touch .../R1/f; rename .../R1/f .../R1/g ========="
660 mv $DIR/R2/f $DIR/R2/g
661 $CHECKSTAT -a $DIR/R2/f || error
662 $CHECKSTAT -t file $DIR/R2/g || error
664 run_test 24b "touch .../R2/{f,g}; rename .../R2/f .../R2/g ====="
669 mv $DIR/R3/f $DIR/R3/g
670 $CHECKSTAT -a $DIR/R3/f || error
671 $CHECKSTAT -t dir $DIR/R3/g || error
673 run_test 24c "mkdir .../R3/f; rename .../R3/f .../R3/g ========="
678 mrename $DIR/R4/f $DIR/R4/g
679 $CHECKSTAT -a $DIR/R4/f || error
680 $CHECKSTAT -t dir $DIR/R4/g || error
682 run_test 24d "mkdir .../R4/{f,g}; rename .../R4/f .../R4/g ====="
685 echo '-- cross directory renames --'
688 mv $DIR/R5a/f $DIR/R5b/g
689 $CHECKSTAT -a $DIR/R5a/f || error
690 $CHECKSTAT -t file $DIR/R5b/g || error
692 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
696 touch $DIR/R6a/f $DIR/R6b/g
697 mv $DIR/R6a/f $DIR/R6b/g
698 $CHECKSTAT -a $DIR/R6a/f || error
699 $CHECKSTAT -t file $DIR/R6b/g || error
701 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
706 mv $DIR/R7a/d $DIR/R7b/e
707 $CHECKSTAT -a $DIR/R7a/d || error
708 $CHECKSTAT -t dir $DIR/R7b/e || error
710 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
714 mkdir $DIR/R8a/d $DIR/R8b/e
715 mrename $DIR/R8a/d $DIR/R8b/e
716 $CHECKSTAT -a $DIR/R8a/d || error
717 $CHECKSTAT -t dir $DIR/R8b/e || error
719 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
722 echo "-- rename error cases"
726 mrename $DIR/R9/f $DIR/R9/a
727 $CHECKSTAT -t file $DIR/R9/f || error
728 $CHECKSTAT -t dir $DIR/R9/a || error
729 $CHECKSTAT -a $DIR/R9/a/f || error
731 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
735 mrename $DIR/R10/f $DIR/R10/g
736 $CHECKSTAT -t dir $DIR/R10 || error
737 $CHECKSTAT -a $DIR/R10/f || error
738 $CHECKSTAT -a $DIR/R10/g || error
740 run_test 24j "source does not exist ============================"
743 mkdir $DIR/R11a $DIR/R11a/d
745 mv $DIR/R11a/f $DIR/R11a/d
746 $CHECKSTAT -a $DIR/R11a/f || error
747 $CHECKSTAT -t file $DIR/R11a/d/f || error
749 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
751 # bug 2429 - rename foo foo foo creates invalid file
754 $MULTIOP $f OcNs || error
756 run_test 24l "Renaming a file to itself ========================"
760 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
761 # on ext3 this does not remove either the source or target files
762 # though the "expected" operation would be to remove the source
763 $CHECKSTAT -t file ${f} || error "${f} missing"
764 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
766 run_test 24m "Renaming a file to a hard link to itself ========="
770 # this stats the old file after it was renamed, so it should fail
774 $CHECKSTAT ${f}.rename
777 run_test 24n "Statting the old file after renaming (Posix rename 2)"
780 check_kernel_version 37 || return 0
782 rename_many -s random -v -n 10 $DIR/d24o
784 run_test 24o "rename of files during htree split ==============="
788 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
789 mrename $DIR/R12a $DIR/R12b
790 $CHECKSTAT -a $DIR/R12a || error
791 $CHECKSTAT -t dir $DIR/R12b || error
792 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
793 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
795 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
799 DIRINO=`ls -lid $DIR/R13a | awk '{ print $1 }'`
800 multiop_bg_pause $DIR/R13b D_c || return 1
803 mrename $DIR/R13a $DIR/R13b
804 $CHECKSTAT -a $DIR/R13a || error
805 $CHECKSTAT -t dir $DIR/R13b || error
806 DIRINO2=`ls -lid $DIR/R13b | awk '{ print $1 }'`
807 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
809 wait $MULTIPID || error "multiop close failed"
811 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
813 test_24r() { #bug 3789
814 mkdir $DIR/R14a $DIR/R14a/b
815 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
816 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
817 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
819 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
822 mkdir $DIR/R15a $DIR/R15a/b $DIR/R15a/b/c
823 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
824 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
825 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
827 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
829 mkdir $DIR/R16a $DIR/R16a/b $DIR/R16a/b/c
830 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
831 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
832 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
834 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
836 test_24u() { # bug12192
837 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error
838 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
840 run_test 24u "create stripe file"
848 local FREE_INODES=`lfs df -i|grep "filesystem summary" | awk '{print $5}'`
849 [ $FREE_INODES -lt $NRFILES ] && \
850 skip "not enough free inodes $FREE_INODES required $NRFILES" && \
854 createmany -m $DIR/d24v/$tfile $NRFILES
857 lctl set_param mdc.*.stats clear
859 ls $DIR/d24v >/dev/null || error "error in listing large dir"
862 # DIRENT_SIZE = 32 bytes for sizeof(struct lu_dirent) +
863 # 8 bytes for name(filename is mostly 5 in this test) +
864 # 8 bytes for luda_type
865 # take into account of overhead in lu_dirpage header and end mark in
866 # each page, plus one in RPC_NUM calculation.
868 RPC_SIZE=$(($(lctl get_param -n mdc.*.max_pages_per_rpc)*$(page_size)))
869 RPC_NUM=$(((NRFILES * DIRENT_SIZE + RPC_SIZE - 1) / RPC_SIZE + 1))
870 mds_readpage=`lctl get_param mdc.*.stats | \
871 awk '/^mds_readpage/ {print $2}'`
872 [ $mds_readpage -gt $RPC_NUM ] && \
873 error "large readdir doesn't take effect"
877 run_test 24v "list directory with large files (handle hash collision, bug: 17560)"
879 test_24w() { # bug21506
881 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
882 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
883 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
884 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
885 [ "$SZ1" = "$SZ2" ] || \
886 error "Error reading at the end of the file $tfile"
888 run_test 24w "Reading a file larger than 4Gb"
891 echo '== symlink sanity ============================================='
895 touch $DIR/s25/foo || error
897 run_test 25a "create file in symlinked directory ==============="
900 [ ! -d $DIR/d25 ] && test_25a
901 $CHECKSTAT -t file $DIR/s25/foo || error
903 run_test 25b "lookup file in symlinked directory ==============="
908 ln -s d26/d26-2 $DIR/s26
909 touch $DIR/s26/foo || error
911 run_test 26a "multiple component symlink ======================="
914 mkdir -p $DIR/d26b/d26-2
915 ln -s d26b/d26-2/foo $DIR/s26-2
916 touch $DIR/s26-2 || error
918 run_test 26b "multiple component symlink at end of lookup ======"
923 ln -s d26.2 $DIR/s26.2-1
924 ln -s s26.2-1 $DIR/s26.2-2
925 ln -s s26.2-2 $DIR/s26.2-3
926 chmod 0666 $DIR/s26.2-3/foo
928 run_test 26c "chain of symlinks ================================"
930 # recursive symlinks (bug 439)
932 ln -s d26-3/foo $DIR/d26-3
934 run_test 26d "create multiple component recursive symlink ======"
937 [ ! -h $DIR/d26-3 ] && test_26d
940 run_test 26e "unlink multiple component recursive symlink ======"
942 # recursive symlinks (bug 7022)
945 mkdir $DIR/$tdir/$tfile || error "mkdir $DIR/$tdir/$tfile failed"
946 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
947 mkdir -p lndir/bar1 || error "mkdir lndir/bar1 failed"
948 mkdir $tfile || error "mkdir $tfile failed"
949 cd $tfile || error "cd $tfile failed"
950 ln -s .. dotdot || error "ln dotdot failed"
951 ln -s dotdot/lndir lndir || error "ln lndir failed"
952 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
953 output=`ls $tfile/$tfile/lndir/bar1`
954 [ "$output" = bar1 ] && error "unexpected output"
955 rm -r $tfile || error "rm $tfile failed"
956 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
958 run_test 26f "rm -r of a directory which has recursive symlink ="
961 echo '== stripe sanity =============================================='
962 mkdir -p $DIR/d27 || error "mkdir failed"
964 $SETSTRIPE -c 1 $DIR/d27/f0 || error "setstripe failed"
965 $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
967 log "== test_27a: write to one stripe file ========================="
968 cp /etc/hosts $DIR/d27/f0 || error
970 run_test 27a "one stripe file =================================="
973 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
975 $SETSTRIPE -c 2 $DIR/d27/f01 || error "setstripe failed"
976 $GETSTRIPE -c $DIR/d27/f01
977 [ $($GETSTRIPE -c $DIR/d27/f01) -eq 2 ] ||
978 error "two-stripe file doesn't have two stripes"
980 run_test 27b "create two stripe file"
983 [ -f $DIR/d27/f01 ] || skip "test_27b not run" && return
985 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
987 run_test 27c "write to two stripe file"
991 $SETSTRIPE -c 0 -i -1 -S 0 $DIR/d27/fdef || error "setstripe failed"
992 $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
993 dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
995 run_test 27d "create file with default settings ================"
999 $SETSTRIPE -c 2 $DIR/d27/f12 || error "setstripe failed"
1000 $SETSTRIPE -c 2 $DIR/d27/f12 && error "setstripe succeeded twice"
1001 $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
1003 run_test 27e "setstripe existing file (should return error) ======"
1007 $SETSTRIPE -S 100 -i 0 -c 1 $DIR/d27/fbad && error "setstripe failed"
1008 dd if=/dev/zero of=$DIR/d27/f12 bs=4k count=4 || error "dd failed"
1009 $GETSTRIPE $DIR/d27/fbad || error "$GETSTRIPE failed"
1011 run_test 27f "setstripe with bad stripe size (should return error)"
1015 $MCREATE $DIR/d27/fnone || error "mcreate failed"
1016 $GETSTRIPE $DIR/d27/fnone 2>&1 | grep "no stripe info" ||
1017 error "$DIR/d27/fnone has object"
1019 run_test 27g "$GETSTRIPE with no objects"
1022 touch $DIR/d27/fsome || error "touch failed"
1023 [ $($GETSTRIPE -c $DIR/d27/fsome) -gt 0 ] || error "missing objects"
1025 run_test 27i "$GETSTRIPE with some objects"
1029 $SETSTRIPE -i $OSTCOUNT $DIR/d27/f27j && error "setstripe failed"||true
1031 run_test 27j "setstripe with bad stripe offset (should return error)"
1033 test_27k() { # bug 2844
1036 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
1037 [ ! -d $DIR/d27 ] && mkdir -p $DIR/d27
1038 $SETSTRIPE -S 67108864 $FILE || error "setstripe failed"
1039 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1040 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
1041 dd if=/dev/zero of=$FILE bs=4k count=1
1042 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1043 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
1045 run_test 27k "limit i_blksize for broken user apps ============="
1049 mcreate $DIR/f27l || error "creating file"
1050 $RUNAS $SETSTRIPE -c 1 $DIR/f27l && \
1051 error "setstripe should have failed" || true
1053 run_test 27l "check setstripe permissions (should return error)"
1056 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1057 if [ $ORIGFREE -gt $MAXFREE ]; then
1058 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1062 $SETSTRIPE -i 0 -c 1 $DIR/d27/f27m_1
1063 dd if=/dev/zero of=$DIR/d27/f27m_1 bs=1024 count=$MAXFREE &&
1064 error "dd should fill OST0"
1066 while $SETSTRIPE -i 0 -c 1 $DIR/d27/f27m_$i; do
1068 [ $i -gt 256 ] && break
1071 touch $DIR/d27/f27m_$i
1072 [ `$GETSTRIPE $DIR/d27/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] && \
1073 error "OST0 was full but new created file still use it"
1075 touch $DIR/d27/f27m_$i
1076 [ `$GETSTRIPE $DIR/d27/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] && \
1077 error "OST0 was full but new created file still use it"
1081 run_test 27m "create file while OST0 was full =================="
1084 local DELAY=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage | head -n 1 | awk '{print $1 * 2}')
1088 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1089 # if the OST isn't full anymore.
1091 local OSTIDX=${1:-""}
1093 local list=$(comma_list $(osts_nodes))
1094 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1096 do_nodes $list lctl set_param fail_loc=0
1097 sync # initiate all OST_DESTROYs from MDS to OST
1101 exhaust_precreations() {
1104 local FAILIDX=${3:-$OSTIDX}
1107 local MDSIDX=$(get_mds_dir "$DIR/$tdir")
1108 echo OSTIDX=$OSTIDX MDSIDX=$MDSIDX
1110 local OST=$(ostname_from_index $OSTIDX)
1111 local MDT_INDEX=$(lfs df | grep "\[MDT:$((MDSIDX - 1))\]" | awk '{print $1}' | \
1112 sed -e 's/_UUID$//;s/^.*-//')
1115 local mdtosc_proc1=$(get_mdtosc_proc_path mds${MDSIDX} $OST)
1116 local last_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1117 osc.$mdtosc_proc1.prealloc_last_id)
1118 local next_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1119 osc.$mdtosc_proc1.prealloc_next_id)
1121 local mdtosc_proc2=$(get_mdtosc_proc_path mds${MDSIDX})
1122 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1124 mkdir -p $DIR/$tdir/${OST}
1125 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1126 #define OBD_FAIL_OST_ENOSPC 0x215
1127 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=$FAILIDX
1128 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x215
1129 echo "Creating to objid $last_id on ost $OST..."
1130 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1131 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1132 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=$FAILLOC
1136 exhaust_all_precreations() {
1138 for (( i=0; i < OSTCOUNT; i++ )) ; do
1139 exhaust_precreations $i $1 -1
1144 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1145 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1146 remote_ost_nodsh && skip "remote OST with nodsh" && return
1149 rm -f $DIR/$tdir/$tfile
1150 exhaust_precreations 0 0x80000215
1151 $SETSTRIPE -c -1 $DIR/$tdir
1152 touch $DIR/$tdir/$tfile || error
1153 $GETSTRIPE $DIR/$tdir/$tfile
1156 run_test 27n "create file with some full OSTs =================="
1159 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1160 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1161 remote_ost_nodsh && skip "remote OST with nodsh" && return
1164 rm -f $DIR/$tdir/$tfile
1165 exhaust_all_precreations 0x215
1167 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1172 run_test 27o "create file with all full OSTs (should error) ===="
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
1183 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1184 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1185 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1187 exhaust_precreations 0 0x80000215
1188 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1189 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1190 $GETSTRIPE $DIR/$tdir/$tfile
1194 run_test 27p "append to a truncated file with some full OSTs ==="
1197 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1198 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1199 remote_ost_nodsh && skip "remote OST with nodsh" && return
1202 rm -f $DIR/$tdir/$tfile
1205 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1206 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||error "truncate $DIR/$tdir/$tfile failed"
1207 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1209 exhaust_all_precreations 0x215
1211 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1212 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1216 run_test 27q "append to truncated file with all OSTs full (should error) ==="
1219 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1220 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1221 remote_ost_nodsh && skip "remote OST with nodsh" && return
1224 rm -f $DIR/$tdir/$tfile
1225 exhaust_precreations 0 0x80000215
1227 $SETSTRIPE -i 0 -c 2 $DIR/$tdir/$tfile # && error
1231 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1233 test_27s() { # bug 10725
1235 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1236 local stripe_count=0
1237 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1238 $SETSTRIPE -S $stripe_size -c $stripe_count $DIR/$tdir &&
1239 error "stripe width >= 2^32 succeeded" || true
1242 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1244 test_27t() { # bug 10864
1249 $WLFS getstripe $tfile
1252 run_test 27t "check that utils parse path correctly"
1254 test_27u() { # bug 4900
1255 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1256 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1258 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1259 do_facet $SINGLEMDS lctl set_param fail_loc=0x139
1261 createmany -o $DIR/$tdir/t- 1000
1262 do_facet $SINGLEMDS lctl set_param fail_loc=0
1264 TLOG=$DIR/$tfile.getstripe
1265 $GETSTRIPE $DIR/$tdir > $TLOG
1266 OBJS=`awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj;}' $TLOG`
1267 unlinkmany $DIR/$tdir/t- 1000
1268 [ $OBJS -gt 0 ] && \
1269 error "$OBJS objects created on OST-0. See $TLOG" || pass
1271 run_test 27u "skip object creation on OSC w/o objects =========="
1273 test_27v() { # bug 4900
1274 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1275 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1276 remote_ost_nodsh && skip "remote OST with nodsh" && return
1278 exhaust_all_precreations 0x215
1282 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1284 touch $DIR/$tdir/$tfile
1285 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1287 for (( i=1; i < OSTCOUNT; i++ )); do
1288 do_facet ost$i lctl set_param fail_loc=0x705
1290 local START=`date +%s`
1291 createmany -o $DIR/$tdir/$tfile 32
1293 local FINISH=`date +%s`
1294 local TIMEOUT=`lctl get_param -n timeout`
1295 local PROCESS=$((FINISH - START))
1296 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1297 error "$FINISH - $START >= $TIMEOUT / 2"
1298 sleep $((TIMEOUT / 2 - PROCESS))
1301 run_test 27v "skip object creation on slow OST ================="
1303 test_27w() { # bug 10997
1304 mkdir -p $DIR/$tdir || error "mkdir failed"
1305 $SETSTRIPE -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1306 [ $($GETSTRIPE -S $DIR/$tdir/f0) -ne 65536 ] &&
1307 error "stripe size $size != 65536" || true
1308 [ $($GETSTRIPE -d $DIR/$tdir | grep -c "stripe_count") -ne 1 ] &&
1309 error "$GETSTRIPE -d $DIR/$tdir failed" || true
1311 run_test 27w "check $SETSTRIPE -S option"
1314 [ "$OSTCOUNT" -lt "2" ] &&
1315 skip_env "skipping multiple stripe count/offset test" && return
1317 mkdir -p $DIR/$tdir || error "mkdir failed"
1318 for i in $(seq 1 $OSTCOUNT); do
1320 $SETSTRIPE -c $i -i $offset $DIR/$tdir/f$i ||
1321 error "setstripe -c $i -i $offset failed"
1322 count=$($GETSTRIPE -c $DIR/$tdir/f$i)
1323 index=$($GETSTRIPE -i $DIR/$tdir/f$i)
1324 [ $count -ne $i ] && error "stripe count $count != $i" || true
1325 [ $index -ne $offset ] &&
1326 error "stripe offset $index != $offset" || true
1329 run_test 27wa "check $SETSTRIPE -c -i options"
1332 remote_ost_nodsh && skip "remote OST with nodsh" && return
1333 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs" && return
1334 OFFSET=$(($OSTCOUNT - 1))
1336 local OST=$(ostname_from_index $OSTIDX)
1339 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe per file
1340 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1342 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1343 for i in `seq 0 $OFFSET`; do
1344 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}' | grep -w "$OSTIDX"` ] &&
1345 error "OST0 was degraded but new created file still use it"
1347 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1349 run_test 27x "create files while OST0 is degraded"
1352 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1353 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1354 remote_ost_nodsh && skip "remote OST with nodsh" && return
1356 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1357 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1358 osc.$mdtosc.prealloc_last_id)
1359 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1360 osc.$mdtosc.prealloc_next_id)
1361 local fcount=$((last_id - next_id))
1362 [ $fcount -eq 0 ] && skip "not enough space on OST0" && return
1363 [ $fcount -gt $OSTCOUNT ] && fcount=$OSTCOUNT
1365 MDS_OSCS=`do_facet $SINGLEMDS lctl dl | awk '/[oO][sS][cC].*md[ts]/ { print $4 }'`
1366 OFFSET=$(($OSTCOUNT-1))
1368 for OSC in $MDS_OSCS; do
1369 if [ $OST == -1 ]; then {
1370 OST=`osc_to_ost $OSC`
1372 echo $OSC "is Deactivate:"
1373 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1377 OSTIDX=$(index_from_ostuuid $OST)
1379 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1381 do_facet ost$((OSTIDX+1)) lctl set_param -n obdfilter.$OST.degraded 1
1383 createmany -o $DIR/$tdir/$tfile $fcount
1384 do_facet ost$((OSTIDX+1)) lctl set_param -n obdfilter.$OST.degraded 0
1386 for i in `seq 0 $OFFSET`; do
1387 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "$OSTIDX"` ] || \
1388 error "files created on deactivated OSTs instead of degraded OST"
1390 for OSC in $MDS_OSCS; do
1391 [ `osc_to_ost $OSC` != $OST ] && {
1392 echo $OSC "is activate"
1393 do_facet $SINGLEMDS lctl --device %$OSC activate
1397 run_test 27y "create files while OST0 is degraded and the rest inactive"
1403 lmm_count=$($GETSTRIPE -c $1)
1404 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1405 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1407 local old_ifs="$IFS"
1409 fid=($($LFS path2fid $1))
1412 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1413 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1415 # compare lmm_seq and lu_fid->f_seq
1416 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1417 # compare lmm_object_id and lu_fid->oid
1418 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1420 # check the trusted.fid attribute of the OST objects of the file
1421 local have_obdidx=false
1423 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1424 # skip lines up to and including "obdidx"
1425 [ -z "$obdidx" ] && break
1426 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1427 $have_obdidx || continue
1429 local ost=$((obdidx + 1))
1430 local dev=$(ostdevname $ost)
1432 if [ $(facet_fstype ost$ost) != ldiskfs ]; then
1433 echo "Currently only works with ldiskfs-based OSTs"
1437 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1439 #don't unmount/remount the OSTs if we don't need to do that
1440 #local dir=$(facet_mntpt ost$ost)
1442 #do_facet ost$dev mount -t $FSTYPE $dev $dir $OST_MOUNT_OPTS ||
1443 # { error "mounting $dev as $FSTYPE failed"; return 3; }
1444 #local obj_file=$(do_facet ost$ost find $dir/O/$seq -name $oid)
1445 #local ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID $obj_file)
1447 local obj_file="O/$seq/d$((oid %32))/$oid"
1448 local ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
1449 $dev 2>/dev/null" | grep "parent=")
1451 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
1453 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
1455 #do_facet ost$ost umount -d $dir
1456 #start ost$ost $dev $OST_MOUNT_OPTS
1458 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
1459 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
1460 local ff_parent=$(echo $ff|sed -e 's/.*parent=.//')
1461 local ff_pseq=$(echo $ff_parent | cut -d: -f1)
1462 local ff_poid=$(echo $ff_parent | cut -d: -f2)
1463 local ff_pstripe=$(echo $ff_parent | sed -e 's/.*stripe=//')
1465 # compare lmm_seq and filter_fid->ff_parent.f_seq
1466 [ $ff_pseq = $lmm_seq ] ||
1467 error "FF parent SEQ $ff_pseq != $lmm_seq"
1468 # compare lmm_object_id and filter_fid->ff_parent.f_oid
1469 [ $ff_poid = $lmm_oid ] ||
1470 error "FF parent OID $ff_poid != $lmm_oid"
1471 [ $ff_pstripe = $stripe_nr ] ||
1472 error "FF stripe $ff_pstripe != $stripe_nr"
1474 stripe_nr=$((stripe_nr + 1))
1479 remote_ost_nodsh && skip "remote OST with nodsh" && return
1482 $SETSTRIPE -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
1483 { error "setstripe -c -1 failed"; return 1; }
1484 # We need to send a write to every object to get parent FID info set.
1485 # This _should_ also work for setattr, but does not currently.
1486 # touch $DIR/$tdir/$tfile-1 ||
1487 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
1488 { error "dd $tfile-1 failed"; return 2; }
1489 $SETSTRIPE -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
1490 { error "setstripe -c -1 failed"; return 3; }
1491 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
1492 { error "dd $tfile-2 failed"; return 4; }
1494 # make sure write RPCs have been sent to OSTs
1497 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
1498 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
1500 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
1502 test_27A() { # b=19102
1503 local restore_size=$($GETSTRIPE -S $MOUNT)
1504 local restore_count=$($GETSTRIPE -c $MOUNT)
1505 local restore_offset=$($GETSTRIPE -i $MOUNT)
1506 $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
1507 local default_size=$($GETSTRIPE -S $MOUNT)
1508 local default_count=$($GETSTRIPE -c $MOUNT)
1509 local default_offset=$($GETSTRIPE -i $MOUNT)
1510 local dsize=$((1024 * 1024))
1511 [ $default_size -eq $dsize ] ||
1512 error "stripe size $default_size != $dsize"
1513 [ $default_count -eq 1 ] || error "stripe count $default_count != 1"
1514 [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
1515 $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
1517 run_test 27A "check filesystem-wide default LOV EA values"
1519 # createtest also checks that device nodes are created and
1520 # then visible correctly (#2091)
1521 test_28() { # bug 2091
1523 $CREATETEST $DIR/d28/ct || error
1525 run_test 28 "create/mknod/mkdir with bad file types ============"
1528 cancel_lru_locks mdc
1534 declare -i LOCKCOUNTORIG=0
1535 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1536 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
1538 [ $LOCKCOUNTORIG -eq 0 ] && echo "No mdc lock count" && return 1
1540 declare -i LOCKUNUSEDCOUNTORIG=0
1541 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1542 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
1549 declare -i LOCKCOUNTCURRENT=0
1550 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1551 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
1554 declare -i LOCKUNUSEDCOUNTCURRENT=0
1555 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1556 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
1559 if [ "$LOCKCOUNTCURRENT" -gt "$LOCKCOUNTORIG" ]; then
1560 lctl set_param -n ldlm.dump_namespaces ""
1561 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
1562 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1563 log "dumped log to $TMP/test_29.dk (bug 5793)"
1566 if [ "$LOCKUNUSEDCOUNTCURRENT" -gt "$LOCKUNUSEDCOUNTORIG" ]; then
1567 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
1568 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1569 log "dumped log to $TMP/test_29.dk (bug 5793)"
1573 run_test 29 "IT_GETATTR regression ============================"
1575 test_30a() { # was test_30
1576 cp `which ls` $DIR || cp /bin/ls $DIR
1580 run_test 30a "execute binary from Lustre (execve) =============="
1583 cp `which ls` $DIR || cp /bin/ls $DIR
1585 $RUNAS $DIR/ls / || error
1588 run_test 30b "execute binary from Lustre as non-root ==========="
1590 test_30c() { # b=22376
1591 cp `which ls` $DIR || cp /bin/ls $DIR
1593 cancel_lru_locks mdc
1594 cancel_lru_locks osc
1595 $RUNAS $DIR/ls / || error
1598 run_test 30c "execute binary from Lustre without read perms ===="
1601 $OPENUNLINK $DIR/f31 $DIR/f31 || error
1602 $CHECKSTAT -a $DIR/f31 || error
1604 run_test 31a "open-unlink file =================================="
1607 touch $DIR/f31 || error
1608 ln $DIR/f31 $DIR/f31b || error
1609 $MULTIOP $DIR/f31b Ouc || error
1610 $CHECKSTAT -t file $DIR/f31 || error
1612 run_test 31b "unlink file with multiple links while open ======="
1615 touch $DIR/f31 || error
1616 ln $DIR/f31 $DIR/f31c || error
1617 multiop_bg_pause $DIR/f31 O_uc || return 1
1619 $MULTIOP $DIR/f31c Ouc
1620 kill -USR1 $MULTIPID
1623 run_test 31c "open-unlink file with multiple links ============="
1626 opendirunlink $DIR/d31d $DIR/d31d || error
1627 $CHECKSTAT -a $DIR/d31d || error
1629 run_test 31d "remove of open directory ========================="
1631 test_31e() { # bug 2904
1632 check_kernel_version 34 || return 0
1633 openfilleddirunlink $DIR/d31e || error
1635 run_test 31e "remove of open non-empty directory ==============="
1637 test_31f() { # bug 4554
1640 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
1641 cp /etc/hosts $DIR/d31f
1643 $GETSTRIPE $DIR/d31f/hosts
1644 multiop_bg_pause $DIR/d31f D_c || return 1
1647 rm -rv $DIR/d31f || error "first of $DIR/d31f"
1649 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
1650 cp /etc/hosts $DIR/d31f
1652 $GETSTRIPE $DIR/d31f/hosts
1653 multiop_bg_pause $DIR/d31f D_c || return 1
1656 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
1657 wait $MULTIPID || error "first opendir $MULTIPID failed"
1661 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
1662 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
1665 run_test 31f "remove of open directory with open-unlink file ==="
1668 echo "-- cross directory link --"
1669 mkdir $DIR/d31g{a,b}
1671 ln $DIR/d31ga/f $DIR/d31gb/g
1672 $CHECKSTAT -t file $DIR/d31ga/f || error "source"
1673 [ `stat -c%h $DIR/d31ga/f` == '2' ] || error "source nlink"
1674 $CHECKSTAT -t file $DIR/d31gb/g || error "target"
1675 [ `stat -c%h $DIR/d31gb/g` == '2' ] || error "target nlink"
1677 run_test 31g "cross directory link==============="
1680 echo "-- cross directory link --"
1684 ln $DIR/d31h/f $DIR/d31h/dir/g
1685 $CHECKSTAT -t file $DIR/d31h/f || error "source"
1686 [ `stat -c%h $DIR/d31h/f` == '2' ] || error "source nlink"
1687 $CHECKSTAT -t file $DIR/d31h/dir/g || error "target"
1688 [ `stat -c%h $DIR/d31h/dir/g` == '2' ] || error "target nlink"
1690 run_test 31h "cross directory link under child==============="
1693 echo "-- cross directory link --"
1696 touch $DIR/d31i/dir/f
1697 ln $DIR/d31i/dir/f $DIR/d31i/g
1698 $CHECKSTAT -t file $DIR/d31i/dir/f || error "source"
1699 [ `stat -c%h $DIR/d31i/dir/f` == '2' ] || error "source nlink"
1700 $CHECKSTAT -t file $DIR/d31i/g || error "target"
1701 [ `stat -c%h $DIR/d31i/g` == '2' ] || error "target nlink"
1703 run_test 31i "cross directory link under parent==============="
1708 mkdir $DIR/d31j/dir1
1709 ln $DIR/d31j/dir1 $DIR/d31j/dir2 && error "ln for dir"
1710 link $DIR/d31j/dir1 $DIR/d31j/dir3 && error "link for dir"
1711 mlink $DIR/d31j/dir1 $DIR/d31j/dir4 && error "mlink for dir"
1712 mlink $DIR/d31j/dir1 $DIR/d31j/dir1 && error "mlink to the same dir"
1715 run_test 31j "link for directory==============="
1721 touch $DIR/d31k/exist
1722 mlink $DIR/d31k/s $DIR/d31k/t || error "mlink"
1723 mlink $DIR/d31k/s $DIR/d31k/exist && error "mlink to exist file"
1724 mlink $DIR/d31k/s $DIR/d31k/s && error "mlink to the same file"
1725 mlink $DIR/d31k/s $DIR/d31k && error "mlink to parent dir"
1726 mlink $DIR/d31k $DIR/d31k/s && error "mlink parent dir to target"
1727 mlink $DIR/d31k/not-exist $DIR/d31k/foo && error "mlink non-existing to new"
1728 mlink $DIR/d31k/not-exist $DIR/d31k/s && error "mlink non-existing to exist"
1731 run_test 31k "link to file: the same, non-existing, dir==============="
1737 touch $DIR/d31m2/exist
1738 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
1739 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
1740 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
1741 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
1742 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
1743 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
1746 run_test 31m "link to file: the same, non-existing, dir==============="
1749 echo "== more mountpoints and symlinks ================="
1750 [ -e $DIR/d32a ] && rm -fr $DIR/d32a
1751 mkdir -p $DIR/d32a/ext2-mountpoint
1752 mount -t ext2 -o loop $EXT2_DEV $DIR/d32a/ext2-mountpoint || error
1753 $CHECKSTAT -t dir $DIR/d32a/ext2-mountpoint/.. || error
1754 $UMOUNT $DIR/d32a/ext2-mountpoint || error
1756 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
1759 [ -e $DIR/d32b ] && rm -fr $DIR/d32b
1760 mkdir -p $DIR/d32b/ext2-mountpoint
1761 mount -t ext2 -o loop $EXT2_DEV $DIR/d32b/ext2-mountpoint || error
1762 ls -al $DIR/d32b/ext2-mountpoint/.. || error
1763 $UMOUNT $DIR/d32b/ext2-mountpoint || error
1765 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
1768 [ -e $DIR/d32c ] && rm -fr $DIR/d32c
1769 mkdir -p $DIR/d32c/ext2-mountpoint
1770 mount -t ext2 -o loop $EXT2_DEV $DIR/d32c/ext2-mountpoint || error
1771 mkdir -p $DIR/d32c/d2/test_dir
1772 $CHECKSTAT -t dir $DIR/d32c/ext2-mountpoint/../d2/test_dir || error
1773 $UMOUNT $DIR/d32c/ext2-mountpoint || error
1775 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
1778 [ -e $DIR/d32d ] && rm -fr $DIR/d32d
1779 mkdir -p $DIR/d32d/ext2-mountpoint
1780 mount -t ext2 -o loop $EXT2_DEV $DIR/d32d/ext2-mountpoint || error
1781 mkdir -p $DIR/d32d/d2/test_dir
1782 ls -al $DIR/d32d/ext2-mountpoint/../d2/test_dir || error
1783 $UMOUNT $DIR/d32d/ext2-mountpoint || error
1785 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
1788 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
1789 mkdir -p $DIR/d32e/tmp
1790 TMP_DIR=$DIR/d32e/tmp
1791 ln -s $DIR/d32e $TMP_DIR/symlink11
1792 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1793 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
1794 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
1796 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
1799 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
1800 mkdir -p $DIR/d32f/tmp
1801 TMP_DIR=$DIR/d32f/tmp
1802 ln -s $DIR/d32f $TMP_DIR/symlink11
1803 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1804 ls $DIR/d32f/tmp/symlink11 || error
1805 ls $DIR/d32f/symlink01 || error
1807 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
1810 TMP_DIR=$DIR/$tdir/tmp
1811 mkdir -p $TMP_DIR $DIR/${tdir}2
1812 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
1813 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1814 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
1815 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
1816 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
1817 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
1819 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
1822 rm -fr $DIR/$tdir $DIR/${tdir}2
1823 TMP_DIR=$DIR/$tdir/tmp
1824 mkdir -p $TMP_DIR $DIR/${tdir}2
1825 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
1826 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1827 ls $TMP_DIR/symlink12 || error
1828 ls $DIR/$tdir/symlink02 || error
1830 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
1833 [ -e $DIR/d32i ] && rm -fr $DIR/d32i
1834 mkdir -p $DIR/d32i/ext2-mountpoint
1835 mount -t ext2 -o loop $EXT2_DEV $DIR/d32i/ext2-mountpoint || error
1836 touch $DIR/d32i/test_file
1837 $CHECKSTAT -t file $DIR/d32i/ext2-mountpoint/../test_file || error
1838 $UMOUNT $DIR/d32i/ext2-mountpoint || error
1840 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
1843 [ -e $DIR/d32j ] && rm -fr $DIR/d32j
1844 mkdir -p $DIR/d32j/ext2-mountpoint
1845 mount -t ext2 -o loop $EXT2_DEV $DIR/d32j/ext2-mountpoint || error
1846 touch $DIR/d32j/test_file
1847 cat $DIR/d32j/ext2-mountpoint/../test_file || error
1848 $UMOUNT $DIR/d32j/ext2-mountpoint || error
1850 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
1854 mkdir -p $DIR/d32k/ext2-mountpoint
1855 mount -t ext2 -o loop $EXT2_DEV $DIR/d32k/ext2-mountpoint
1856 mkdir -p $DIR/d32k/d2
1857 touch $DIR/d32k/d2/test_file || error
1858 $CHECKSTAT -t file $DIR/d32k/ext2-mountpoint/../d2/test_file || error
1859 $UMOUNT $DIR/d32k/ext2-mountpoint || error
1861 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
1865 mkdir -p $DIR/d32l/ext2-mountpoint
1866 mount -t ext2 -o loop $EXT2_DEV $DIR/d32l/ext2-mountpoint || error
1867 mkdir -p $DIR/d32l/d2
1868 touch $DIR/d32l/d2/test_file
1869 cat $DIR/d32l/ext2-mountpoint/../d2/test_file || error
1870 $UMOUNT $DIR/d32l/ext2-mountpoint || error
1872 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
1876 mkdir -p $DIR/d32m/tmp
1877 TMP_DIR=$DIR/d32m/tmp
1878 ln -s $DIR $TMP_DIR/symlink11
1879 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1880 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
1881 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
1883 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
1887 mkdir -p $DIR/d32n/tmp
1888 TMP_DIR=$DIR/d32n/tmp
1889 ln -s $DIR $TMP_DIR/symlink11
1890 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1891 ls -l $DIR/d32n/tmp/symlink11 || error
1892 ls -l $DIR/d32n/symlink01 || error
1894 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
1897 rm -fr $DIR/d32o $DIR/$tfile
1899 mkdir -p $DIR/d32o/tmp
1900 TMP_DIR=$DIR/d32o/tmp
1901 ln -s $DIR/$tfile $TMP_DIR/symlink12
1902 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1903 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
1904 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
1905 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
1906 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
1908 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
1918 mkdir -p $DIR/d32p/tmp
1920 TMP_DIR=$DIR/d32p/tmp
1922 ln -s $DIR/$tfile $TMP_DIR/symlink12
1924 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1926 cat $DIR/d32p/tmp/symlink12 || error
1928 cat $DIR/d32p/symlink02 || error
1931 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
1934 [ -e $DIR/d32q ] && rm -fr $DIR/d32q
1936 touch $DIR/d32q/under_the_mount
1937 mount -t ext2 -o loop $EXT2_DEV $DIR/d32q
1938 ls $DIR/d32q/under_the_mount && error || true
1939 $UMOUNT $DIR/d32q || error
1941 run_test 32q "stat follows mountpoints in Lustre (should return error)"
1944 [ -e $DIR/d32r ] && rm -fr $DIR/d32r
1946 touch $DIR/d32r/under_the_mount
1947 mount -t ext2 -o loop $EXT2_DEV $DIR/d32r
1948 ls $DIR/d32r | grep -q under_the_mount && error || true
1949 $UMOUNT $DIR/d32r || error
1951 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
1956 chmod 444 $DIR/$tfile
1957 chown $RUNAS_ID $DIR/$tfile
1959 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
1962 run_test 33 "write file with mode 444 (should return error) ===="
1967 chown $RUNAS_ID $DIR/d33
1968 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
1969 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
1970 error "open RDWR" || true
1972 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
1977 chown $RUNAS_ID $DIR/d33
1978 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33 && error "create" || true
1980 run_test 33b "test open file with malformed flags (No panic and return error)"
1988 remote_ost_nodsh && skip "remote OST with nodsh" && return
1992 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
1995 for ostnum in $(seq $OSTCOUNT); do
1996 # test-framework's OST numbering is one-based, while Lustre's
1998 ostname=$(printf "$FSNAME-OST%.4d" $((ostnum - 1)))
1999 # Parsing llobdstat's output sucks; we could grep the /proc
2000 # path, but that's likely to not be as portable as using the
2001 # llobdstat utility. So we parse lctl output instead.
2002 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2003 obdfilter/$ostname/stats |
2004 awk '/^write_bytes/ {print $7}' )
2005 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2006 if (( ${write_bytes:-0} > 0 ))
2013 $all_zeros || return 0
2016 echo foo > $DIR/d33/bar
2020 # Total up write_bytes after writing. We'd better find non-zeros.
2021 for ostnum in $(seq $OSTCOUNT); do
2022 ostname=$(printf "$FSNAME-OST%.4d" $((ostnum - 1)))
2023 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2024 obdfilter/$ostname/stats |
2025 awk '/^write_bytes/ {print $7}' )
2026 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2027 if (( ${write_bytes:-0} > 0 ))
2036 for ostnum in $(seq $OSTCOUNT); do
2037 ostname=$(printf "$FSNAME-OST%.4d" $((ostnum - 1)))
2038 echo "Check that write_bytes is present in obdfilter/*/stats:"
2039 do_facet ost$ostnum lctl get_param -n \
2040 obdfilter/$ostname/stats
2042 error "OST not keeping write_bytes stats (b22312)"
2045 run_test 33c "test llobdstat and write_bytes"
2047 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
2050 $MCREATE $DIR/f34 || error
2051 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2052 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
2053 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2054 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2056 run_test 34a "truncate file that has not been opened ==========="
2059 [ ! -f $DIR/f34 ] && test_34a
2060 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2061 $OPENFILE -f O_RDONLY $DIR/f34
2062 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2063 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2065 run_test 34b "O_RDONLY opening file doesn't create objects ====="
2068 [ ! -f $DIR/f34 ] && test_34a
2069 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2070 $OPENFILE -f O_RDWR $DIR/f34
2071 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2072 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2074 run_test 34c "O_RDWR opening file-with-size works =============="
2077 [ ! -f $DIR/f34 ] && test_34a
2078 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2079 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2082 run_test 34d "write to sparse file ============================="
2086 $MCREATE $DIR/f34e || error
2087 $TRUNCATE $DIR/f34e 1000 || error
2088 $CHECKSTAT -s 1000 $DIR/f34e || error
2089 $OPENFILE -f O_RDWR $DIR/f34e
2090 $CHECKSTAT -s 1000 $DIR/f34e || error
2092 run_test 34e "create objects, some with size and some without =="
2094 test_34f() { # bug 6242, 6243
2097 $MCREATE $DIR/f34f || error
2098 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
2099 dd if=$DIR/f34f of=$TMP/f34f
2100 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
2101 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
2102 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
2103 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
2104 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
2106 run_test 34f "read from a file with no objects until EOF ======="
2109 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
2110 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
2111 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
2112 cancel_lru_locks osc
2113 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
2114 error "wrong size after lock cancel"
2116 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
2117 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2118 error "expanding truncate failed"
2119 cancel_lru_locks osc
2120 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2121 error "wrong expanded size after lock cancel"
2123 run_test 34g "truncate long file ==============================="
2129 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
2130 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
2134 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
2135 error "Multiop blocked on ftruncate, pid=$MULTIPID"
2139 local nsz=`stat -c %s $DIR/$tfile`
2140 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
2142 run_test 34h "ftruncate file under grouplock should not block"
2145 cp /bin/sh $DIR/f35a
2147 chown $RUNAS_ID $DIR/f35a
2148 $RUNAS $DIR/f35a && error || true
2151 run_test 35a "exec file with mode 444 (should return and not leak) ====="
2155 utime $DIR/f36 || error
2157 run_test 36a "MDS utime check (mknod, utime) ==================="
2161 utime $DIR/f36 || error
2163 run_test 36b "OST utime check (open, utime) ===================="
2168 chown $RUNAS_ID $DIR/d36
2169 $RUNAS utime $DIR/d36/f36 || error
2171 run_test 36c "non-root MDS utime check (mknod, utime) =========="
2174 [ ! -d $DIR/d36 ] && test_36c
2175 echo "" > $DIR/d36/f36
2176 $RUNAS utime $DIR/d36/f36 || error
2178 run_test 36d "non-root OST utime check (open, utime) ==========="
2181 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
2183 touch $DIR/$tdir/$tfile
2184 $RUNAS utime $DIR/$tdir/$tfile && \
2185 error "utime worked, expected failure" || true
2187 run_test 36e "utime on non-owned file (should return error) ===="
2191 local LANG_SAVE=$LANG
2192 local LC_LANG_SAVE=$LC_LANG
2193 export LANG=C LC_LANG=C # for date language
2195 DATESTR="Dec 20 2000"
2197 lctl set_param fail_loc=$fl
2199 cp /etc/hosts $DIR/$tdir/$tfile
2200 sync & # write RPC generated with "current" inode timestamp, but delayed
2202 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
2203 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
2204 cancel_lru_locks osc
2205 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
2207 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
2208 echo "BEFORE: $LS_BEFORE" && \
2209 echo "AFTER : $LS_AFTER" && \
2210 echo "WANT : $DATESTR" && \
2211 error "$DIR/$tdir/$tfile timestamps changed" || true
2213 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
2217 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2218 subr_36fh "0x80000214"
2220 run_test 36f "utime on file racing with OST BRW write =========="
2223 remote_ost_nodsh && skip "remote OST with nodsh" && return
2229 fmd_max_age=$(do_facet ost1 \
2230 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
2233 fmd_before=$(do_facet ost1 \
2234 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2235 touch $DIR/$tdir/$tfile
2236 sleep $((fmd_max_age + 12))
2237 fmd_after=$(do_facet ost1 \
2238 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2240 echo "fmd_before: $fmd_before"
2241 echo "fmd_after: $fmd_after"
2242 [ "$fmd_after" -gt "$fmd_before" ] && \
2243 echo "AFTER: $fmd_after > BEFORE: $fmd_before" && \
2244 error "fmd didn't expire after ping" || true
2246 run_test 36g "filter mod data cache expiry ====================="
2249 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
2250 subr_36fh "0x80000227"
2252 run_test 36h "utime on file racing with OST BRW write =========="
2256 echo f > $DIR/$tdir/fbugfile
2257 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2258 ls $DIR/$tdir | grep "\<fbugfile\>" && error
2259 $UMOUNT $DIR/$tdir || error
2260 rm -f $DIR/$tdir/fbugfile || error
2262 run_test 37 "ls a mounted file system to check old content ====="
2265 local file=$DIR/$tfile
2267 openfile -f O_DIRECTORY $file
2270 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
2271 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
2273 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
2277 touch $DIR/${tfile}2
2278 # ls -l $DIR/$tfile $DIR/${tfile}2
2279 # ls -lu $DIR/$tfile $DIR/${tfile}2
2280 # ls -lc $DIR/$tfile $DIR/${tfile}2
2282 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
2283 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
2285 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
2287 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
2289 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
2290 error "O_TRUNC didn't change timestamps"
2293 run_test 39 "mtime changed on create ==========================="
2297 cp -p /etc/passwd $DIR/$tdir/fopen
2298 cp -p /etc/passwd $DIR/$tdir/flink
2299 cp -p /etc/passwd $DIR/$tdir/funlink
2300 cp -p /etc/passwd $DIR/$tdir/frename
2301 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
2304 echo "aaaaaa" >> $DIR/$tdir/fopen
2305 echo "aaaaaa" >> $DIR/$tdir/flink
2306 echo "aaaaaa" >> $DIR/$tdir/funlink
2307 echo "aaaaaa" >> $DIR/$tdir/frename
2309 local open_new=`stat -c %Y $DIR/$tdir/fopen`
2310 local link_new=`stat -c %Y $DIR/$tdir/flink`
2311 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
2312 local rename_new=`stat -c %Y $DIR/$tdir/frename`
2314 cat $DIR/$tdir/fopen > /dev/null
2315 ln $DIR/$tdir/flink $DIR/$tdir/flink2
2316 rm -f $DIR/$tdir/funlink2
2317 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
2319 for (( i=0; i < 2; i++ )) ; do
2320 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
2321 local link_new2=`stat -c %Y $DIR/$tdir/flink`
2322 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
2323 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
2325 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
2326 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
2327 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
2328 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
2330 cancel_lru_locks osc
2331 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2334 run_test 39b "mtime change on open, link, unlink, rename ======"
2336 # this should be set to past
2337 TEST_39_MTIME=`date -d "1 year ago" +%s`
2343 local mtime0=`stat -c %Y $DIR1/$tfile`
2345 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2346 local mtime1=`stat -c %Y $DIR1/$tfile`
2347 [ "$mtime1" = $TEST_39_MTIME ] || \
2348 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
2351 echo hello >> $DIR1/$tfile
2353 local mtime2=`stat -c %Y $DIR1/$tfile`
2354 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
2355 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
2357 mv $DIR1/$tfile $DIR1/$tfile-1
2359 for (( i=0; i < 2; i++ )) ; do
2360 local mtime3=`stat -c %Y $DIR1/$tfile-1`
2361 [ "$mtime2" = "$mtime3" ] || \
2362 error "mtime ($mtime2) changed (to $mtime3) on rename"
2364 cancel_lru_locks osc
2365 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2368 run_test 39c "mtime change on rename ==========================="
2374 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2376 for (( i=0; i < 2; i++ )) ; do
2377 local mtime=`stat -c %Y $DIR1/$tfile`
2378 [ $mtime = $TEST_39_MTIME ] || \
2379 error "mtime($mtime) is not set to $TEST_39_MTIME"
2381 cancel_lru_locks osc
2382 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2385 run_test 39d "create, utime, stat =============================="
2390 local mtime1=`stat -c %Y $DIR1/$tfile`
2392 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2394 for (( i=0; i < 2; i++ )) ; do
2395 local mtime2=`stat -c %Y $DIR1/$tfile`
2396 [ $mtime2 = $TEST_39_MTIME ] || \
2397 error "mtime($mtime2) is not set to $TEST_39_MTIME"
2399 cancel_lru_locks osc
2400 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2403 run_test 39e "create, stat, utime, stat ========================"
2408 mtime1=`stat -c %Y $DIR1/$tfile`
2411 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2413 for (( i=0; i < 2; i++ )) ; do
2414 local mtime2=`stat -c %Y $DIR1/$tfile`
2415 [ $mtime2 = $TEST_39_MTIME ] || \
2416 error "mtime($mtime2) is not set to $TEST_39_MTIME"
2418 cancel_lru_locks osc
2419 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2422 run_test 39f "create, stat, sleep, utime, stat ================="
2426 echo hello >> $DIR1/$tfile
2427 local mtime1=`stat -c %Y $DIR1/$tfile`
2430 chmod o+r $DIR1/$tfile
2432 for (( i=0; i < 2; i++ )) ; do
2433 local mtime2=`stat -c %Y $DIR1/$tfile`
2434 [ "$mtime1" = "$mtime2" ] || \
2435 error "lost mtime: $mtime2, should be $mtime1"
2437 cancel_lru_locks osc
2438 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2441 run_test 39g "write, chmod, stat ==============================="
2449 echo hello >> $DIR1/$tfile
2450 local mtime1=`stat -c %Y $DIR1/$tfile`
2452 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2454 if [ "$d1" != "$d2" ]; then
2455 echo "write and touch not within one second"
2457 for (( i=0; i < 2; i++ )) ; do
2458 local mtime2=`stat -c %Y $DIR1/$tfile`
2459 [ "$mtime2" = $TEST_39_MTIME ] || \
2460 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
2462 cancel_lru_locks osc
2463 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2467 run_test 39h "write, utime within one second, stat ============="
2473 echo hello >> $DIR1/$tfile
2474 local mtime1=`stat -c %Y $DIR1/$tfile`
2476 mv $DIR1/$tfile $DIR1/$tfile-1
2478 for (( i=0; i < 2; i++ )) ; do
2479 local mtime2=`stat -c %Y $DIR1/$tfile-1`
2481 [ "$mtime1" = "$mtime2" ] || \
2482 error "lost mtime: $mtime2, should be $mtime1"
2484 cancel_lru_locks osc
2485 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2488 run_test 39i "write, rename, stat =============================="
2491 start_full_debug_logging
2495 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
2496 lctl set_param fail_loc=0x80000412
2497 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
2498 error "multiop failed"
2500 local mtime1=`stat -c %Y $DIR1/$tfile`
2502 mv $DIR1/$tfile $DIR1/$tfile-1
2504 kill -USR1 $multipid
2505 wait $multipid || error "multiop close failed"
2507 for (( i=0; i < 2; i++ )) ; do
2508 local mtime2=`stat -c %Y $DIR1/$tfile-1`
2509 [ "$mtime1" = "$mtime2" ] ||
2510 error "mtime is lost on close: $mtime2, " \
2513 cancel_lru_locks osc
2514 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2516 lctl set_param fail_loc=0
2517 stop_full_debug_logging
2519 run_test 39j "write, rename, close, stat ======================="
2525 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
2527 local mtime1=`stat -c %Y $DIR1/$tfile`
2529 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2531 kill -USR1 $multipid
2532 wait $multipid || error "multiop close failed"
2534 for (( i=0; i < 2; i++ )) ; do
2535 local mtime2=`stat -c %Y $DIR1/$tfile`
2537 [ "$mtime2" = $TEST_39_MTIME ] || \
2538 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
2540 cancel_lru_locks osc
2541 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2544 run_test 39k "write, utime, close, stat ========================"
2546 # this should be set to future
2547 TEST_39_ATIME=`date -d "1 year" +%s`
2549 is_sles11() # LU-1783
2551 if [ -r /etc/SuSE-release ]
2553 local vers=`grep VERSION /etc/SuSE-release | awk '{print $3}'`
2554 local patchlev=`grep PATCHLEVEL /etc/SuSE-release \
2556 if [ $vers -eq 11 ] && [ $patchlev -eq 1 ]
2565 is_sles11 && skip "SLES 11 SP1" && return # LU-1783
2566 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2567 local atime_diff=$(do_facet $SINGLEMDS lctl get_param -n mdd.*.atime_diff)
2571 # test setting directory atime to future
2572 touch -a -d @$TEST_39_ATIME $DIR/$tdir
2573 local atime=$(stat -c %X $DIR/$tdir)
2574 [ "$atime" = $TEST_39_ATIME ] || \
2575 error "atime is not set to future: $atime, should be $TEST_39_ATIME"
2577 # test setting directory atime from future to now
2578 local d1=$(date +%s)
2580 local d2=$(date +%s)
2582 cancel_lru_locks mdc
2583 atime=$(stat -c %X $DIR/$tdir)
2584 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
2585 error "atime is not updated from future: $atime, should be $d1<atime<$d2"
2587 do_facet $SINGLEMDS lctl set_param -n mdd.*.atime_diff=2
2590 # test setting directory atime when now > dir atime + atime_diff
2594 cancel_lru_locks mdc
2595 atime=$(stat -c %X $DIR/$tdir)
2596 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
2597 error "atime is not updated : $atime, should be $d2"
2599 do_facet $SINGLEMDS lctl set_param -n mdd.*.atime_diff=60
2602 # test not setting directory atime when now < dir atime + atime_diff
2604 cancel_lru_locks mdc
2605 atime=$(stat -c %X $DIR/$tdir)
2606 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
2607 error "atime is updated to $atime, should remain $d1<atime<$d2"
2609 do_facet $SINGLEMDS lctl set_param -n mdd.*.atime_diff=$atime_diff
2611 run_test 39l "directory atime update ==========================="
2616 local far_past_mtime=$(date -d "May 29 1953" +%s)
2617 local far_past_atime=$(date -d "Dec 17 1903" +%s)
2619 touch -m -d @$far_past_mtime $DIR1/$tfile
2620 touch -a -d @$far_past_atime $DIR1/$tfile
2622 for (( i=0; i < 2; i++ )) ; do
2623 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
2624 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
2625 error "atime or mtime set incorrectly"
2627 cancel_lru_locks osc
2628 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2631 run_test 39m "test atime and mtime before 1970"
2634 dd if=/dev/zero of=$DIR/f40 bs=4096 count=1
2635 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/f40 && error
2636 $CHECKSTAT -t file -s 4096 $DIR/f40 || error
2638 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
2642 small_write $DIR/f41 18
2644 run_test 41 "test small file write + fstat ====================="
2646 count_ost_writes() {
2647 lctl get_param -n osc.*.stats |
2648 awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }'
2655 BG_DIRTY_RATIO_SAVE=10
2656 MAX_BG_DIRTY_RATIO=25
2660 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
2661 # dirty_ratio, dirty_background_ratio
2662 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
2663 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
2664 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
2665 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
2667 # if file not here, we are a 2.4 kernel
2668 kill -CONT `pidof kupdated`
2673 # setup the trap first, so someone cannot exit the test at the
2674 # exact wrong time and mess up a machine
2675 trap start_writeback EXIT
2676 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
2677 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
2678 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
2679 sysctl -w vm.dirty_writeback_centisecs=0
2680 sysctl -w vm.dirty_writeback_centisecs=0
2681 # save and increase /proc/sys/vm/dirty_ratio
2682 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
2683 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
2684 # save and increase /proc/sys/vm/dirty_background_ratio
2685 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
2686 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
2688 # if file not here, we are a 2.4 kernel
2689 kill -STOP `pidof kupdated`
2693 # ensure that all stripes have some grant before we test client-side cache
2695 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
2696 dd if=/dev/zero of=$i bs=4k count=1
2701 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
2702 # file truncation, and file removal.
2705 cancel_lru_locks osc
2707 sync; sleep 1; sync # just to be safe
2708 BEFOREWRITES=`count_ost_writes`
2709 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
2710 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
2711 AFTERWRITES=`count_ost_writes`
2712 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
2713 error "$BEFOREWRITES < $AFTERWRITES"
2716 run_test 42a "ensure that we don't flush on close =============="
2720 cancel_lru_locks osc
2723 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
2724 BEFOREWRITES=`count_ost_writes`
2725 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
2726 AFTERWRITES=`count_ost_writes`
2727 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
2728 error "$BEFOREWRITES < $AFTERWRITES on unlink"
2730 BEFOREWRITES=`count_ost_writes`
2731 sync || error "sync: $?"
2732 AFTERWRITES=`count_ost_writes`
2733 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
2734 error "$BEFOREWRITES < $AFTERWRITES on sync"
2736 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
2740 run_test 42b "test destroy of file with cached dirty data ======"
2742 # if these tests just want to test the effect of truncation,
2743 # they have to be very careful. consider:
2744 # - the first open gets a {0,EOF}PR lock
2745 # - the first write conflicts and gets a {0, count-1}PW
2746 # - the rest of the writes are under {count,EOF}PW
2747 # - the open for truncate tries to match a {0,EOF}PR
2748 # for the filesize and cancels the PWs.
2749 # any number of fixes (don't get {0,EOF} on open, match
2750 # composite locks, do smarter file size management) fix
2751 # this, but for now we want these tests to verify that
2752 # the cancellation with truncate intent works, so we
2753 # start the file with a full-file pw lock to match against
2754 # until the truncate.
2759 cancel_lru_locks osc
2761 # prime the file with 0,EOF PW to match
2765 # now the real test..
2766 dd if=/dev/zero of=$file bs=1024 count=100
2767 BEFOREWRITES=`count_ost_writes`
2768 $TRUNCATE $file $offset
2769 cancel_lru_locks osc
2770 AFTERWRITES=`count_ost_writes`
2776 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
2777 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
2780 run_test 42c "test partial truncate of file with cached dirty data"
2784 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
2785 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
2788 run_test 42d "test complete truncate of file with cached dirty data"
2790 test_42e() { # bug22074
2791 local TDIR=$DIR/${tdir}e
2792 local pagesz=$(page_size)
2793 local pages=16 # hardcoded 16 pages, don't change it.
2794 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
2795 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
2800 $SETSTRIPE -c 1 $TDIR
2801 createmany -o $TDIR/f $files
2803 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
2805 # we assume that with $OSTCOUNT files, at least one of them will
2806 # be allocated on OST0.
2807 warmup_files=$((OSTCOUNT * max_dirty_mb))
2808 createmany -o $TDIR/w $warmup_files
2810 # write a large amount of data into one file and sync, to get good
2811 # avail_grant number from OST.
2812 for ((i=0; i<$warmup_files; i++)); do
2813 idx=$($GETSTRIPE -i $TDIR/w$i)
2814 [ $idx -ne 0 ] && continue
2815 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
2818 [ $i -gt $warmup_files ] && error "OST0 is still cold"
2820 $LCTL get_param $proc_osc0/cur_dirty_bytes
2821 $LCTL get_param $proc_osc0/cur_grant_bytes
2823 # create as much dirty pages as we can while not to trigger the actual
2824 # RPCs directly. but depends on the env, VFS may trigger flush during this
2825 # period, hopefully we are good.
2826 for ((i=0; i<$warmup_files; i++)); do
2827 idx=$($GETSTRIPE -i $TDIR/w$i)
2828 [ $idx -ne 0 ] && continue
2829 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
2831 $LCTL get_param $proc_osc0/cur_dirty_bytes
2832 $LCTL get_param $proc_osc0/cur_grant_bytes
2834 # perform the real test
2835 $LCTL set_param $proc_osc0/rpc_stats 0
2836 for ((;i<$files; i++)); do
2837 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
2838 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
2841 $LCTL get_param $proc_osc0/rpc_stats
2844 local have_ppr=false
2845 $LCTL get_param $proc_osc0/rpc_stats |
2846 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
2847 # skip lines until we are at the RPC histogram data
2848 [ "$PPR" == "pages" ] && have_ppr=true && continue
2849 $have_ppr || continue
2851 # we only want the percent stat for < 16 pages
2852 [ $(echo $PPR | tr -d ':') -ge $pages ] && break
2854 percent=$((percent + WPCT))
2855 if [ $percent -gt 15 ]; then
2856 error "less than 16-pages write RPCs" \
2863 run_test 42e "verify sub-RPC writes are not done synchronously"
2867 cp -p /bin/ls $DIR/$tdir/$tfile
2868 $MULTIOP $DIR/$tdir/$tfile Ow_c &
2870 # give multiop a chance to open
2873 $DIR/$tdir/$tfile && error || true
2876 run_test 43 "execution of file opened for write should return -ETXTBSY"
2880 cp -p `which $MULTIOP` $DIR/d43/multiop || cp -p multiop $DIR/d43/multiop
2881 MULTIOP_PROG=$DIR/d43/multiop multiop_bg_pause $TMP/test43.junk O_c || return 1
2883 $MULTIOP $DIR/d43/multiop Oc && error "expected error, got success"
2884 kill -USR1 $MULTIOP_PID || return 2
2885 wait $MULTIOP_PID || return 3
2888 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
2892 cp -p `which $MULTIOP` $DIR/d43/multiop || cp -p multiop $DIR/d43/multiop
2893 MULTIOP_PROG=$DIR/d43/multiop multiop_bg_pause $TMP/test43.junk O_c || return 1
2895 $TRUNCATE $DIR/d43/multiop 0 && error "expected error, got success"
2896 kill -USR1 $MULTIOP_PID || return 2
2897 wait $MULTIOP_PID || return 3
2900 run_test 43b "truncate of file being executed should return -ETXTBSY"
2903 local testdir="$DIR/d43c"
2906 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
2907 ( cd $testdir && md5sum -c)
2909 run_test 43c "md5sum of copy into lustre========================"
2912 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
2913 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
2914 dd if=$DIR/f1 bs=4k count=1 > /dev/null
2916 run_test 44 "zero length read from a sparse stripe ============="
2919 local nstripe=`$LCTL lov_getconfig $DIR | grep default_stripe_count: | \
2921 [ -z "$nstripe" ] && skip "can't get stripe info" && return
2922 [ "$nstripe" -gt "$OSTCOUNT" ] && skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" && return
2923 local stride=`$LCTL lov_getconfig $DIR | grep default_stripe_size: | \
2925 if [ $nstripe -eq 0 -o $nstripe -eq -1 ] ; then
2926 nstripe=`$LCTL lov_getconfig $DIR | grep obd_count: | awk '{print $2}'`
2929 OFFSETS="0 $((stride/2)) $((stride-1))"
2930 for offset in $OFFSETS ; do
2931 for i in `seq 0 $((nstripe-1))`; do
2932 local GLOBALOFFSETS=""
2933 local size=$((((i + 2 * $nstripe )*$stride + $offset))) # Bytes
2934 local myfn=$DIR/d44a-$size
2935 echo "--------writing $myfn at $size"
2936 ll_sparseness_write $myfn $size || error "ll_sparseness_write"
2937 GLOBALOFFSETS="$GLOBALOFFSETS $size"
2938 ll_sparseness_verify $myfn $GLOBALOFFSETS \
2939 || error "ll_sparseness_verify $GLOBALOFFSETS"
2941 for j in `seq 0 $((nstripe-1))`; do
2942 size=$((((j + $nstripe )*$stride + $offset))) # Bytes
2943 ll_sparseness_write $myfn $size || error "ll_sparseness_write"
2944 GLOBALOFFSETS="$GLOBALOFFSETS $size"
2946 ll_sparseness_verify $myfn $GLOBALOFFSETS \
2947 || error "ll_sparseness_verify $GLOBALOFFSETS"
2952 run_test 44a "test sparse pwrite ==============================="
2956 for d in `lctl get_param -n osc.*.cur_dirty_bytes`; do
2962 before=`dirty_osc_total`
2963 echo executing "\"$*\""
2965 after=`dirty_osc_total`
2966 echo before $before, after $after
2970 # Obtain grants from OST if it supports it
2971 echo blah > ${f}_grant
2974 do_dirty_record "echo blah > $f"
2975 [ $before -eq $after ] && error "write wasn't cached"
2976 do_dirty_record "> $f"
2977 [ $before -gt $after ] || error "truncate didn't lower dirty count"
2978 do_dirty_record "echo blah > $f"
2979 [ $before -eq $after ] && error "write wasn't cached"
2980 do_dirty_record "sync"
2981 [ $before -gt $after ] || error "writeback didn't lower dirty count"
2982 do_dirty_record "echo blah > $f"
2983 [ $before -eq $after ] && error "write wasn't cached"
2984 do_dirty_record "cancel_lru_locks osc"
2985 [ $before -gt $after ] || error "lock cancellation didn't lower dirty count"
2988 run_test 45 "osc io page accounting ============================"
2990 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
2991 # test tickles a bug where re-dirtying a page was failing to be mapped to the
2992 # objects offset and an assert hit when an rpc was built with 1023's mapped
2993 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
2998 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3000 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
3001 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3005 run_test 46 "dirtying a previously written page ================"
3007 # test_47 is removed "Device nodes check" is moved to test_28
3009 test_48a() { # bug 2399
3010 check_kernel_version 34 || return 0
3013 mv $DIR/d48a $DIR/d48.new || error "move directory failed"
3014 mkdir $DIR/d48a || error "recreate directory failed"
3015 touch foo || error "'touch foo' failed after recreating cwd"
3016 mkdir bar || error "'mkdir foo' failed after recreating cwd"
3017 if check_kernel_version 44; then
3018 touch .foo || error "'touch .foo' failed after recreating cwd"
3019 mkdir .bar || error "'mkdir .foo' failed after recreating cwd"
3021 ls . > /dev/null || error "'ls .' failed after recreating cwd"
3022 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3023 cd . || error "'cd .' failed after recreating cwd"
3024 mkdir . && error "'mkdir .' worked after recreating cwd"
3025 rmdir . && error "'rmdir .' worked after recreating cwd"
3026 ln -s . baz || error "'ln -s .' failed after recreating cwd"
3027 cd .. || error "'cd ..' failed after recreating cwd"
3029 run_test 48a "Access renamed working dir (should return errors)="
3031 test_48b() { # bug 2399
3032 check_kernel_version 34 || return 0
3035 rmdir $DIR/d48b || error "remove cwd $DIR/d48b failed"
3036 touch foo && error "'touch foo' worked after removing cwd"
3037 mkdir foo && error "'mkdir foo' worked after removing cwd"
3038 if check_kernel_version 44; then
3039 touch .foo && error "'touch .foo' worked after removing cwd"
3040 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
3042 ls . > /dev/null && error "'ls .' worked after removing cwd"
3043 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3044 is_patchless || ( cd . && error "'cd .' worked after removing cwd" )
3045 mkdir . && error "'mkdir .' worked after removing cwd"
3046 rmdir . && error "'rmdir .' worked after removing cwd"
3047 ln -s . foo && error "'ln -s .' worked after removing cwd"
3048 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
3050 run_test 48b "Access removed working dir (should return errors)="
3052 test_48c() { # bug 2350
3053 check_kernel_version 36 || return 0
3054 #lctl set_param debug=-1
3056 mkdir -p $DIR/d48c/dir
3058 $TRACE rmdir $DIR/d48c/dir || error "remove cwd $DIR/d48c/dir failed"
3059 $TRACE touch foo && error "'touch foo' worked after removing cwd"
3060 $TRACE mkdir foo && error "'mkdir foo' worked after removing cwd"
3061 if check_kernel_version 44; then
3062 touch .foo && error "'touch .foo' worked after removing cwd"
3063 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
3065 $TRACE ls . && error "'ls .' worked after removing cwd"
3066 $TRACE ls .. || error "'ls ..' failed after removing cwd"
3067 is_patchless || ( $TRACE cd . && error "'cd .' worked after removing cwd" )
3068 $TRACE mkdir . && error "'mkdir .' worked after removing cwd"
3069 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
3070 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
3071 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
3073 run_test 48c "Access removed working subdir (should return errors)"
3075 test_48d() { # bug 2350
3076 check_kernel_version 36 || return 0
3077 #lctl set_param debug=-1
3079 mkdir -p $DIR/d48d/dir
3081 $TRACE rmdir $DIR/d48d/dir || error "remove cwd $DIR/d48d/dir failed"
3082 $TRACE rmdir $DIR/d48d || error "remove parent $DIR/d48d failed"
3083 $TRACE touch foo && error "'touch foo' worked after removing parent"
3084 $TRACE mkdir foo && error "'mkdir foo' worked after removing parent"
3085 if check_kernel_version 44; then
3086 touch .foo && error "'touch .foo' worked after removing parent"
3087 mkdir .foo && error "'mkdir .foo' worked after removing parent"
3089 $TRACE ls . && error "'ls .' worked after removing parent"
3090 $TRACE ls .. && error "'ls ..' worked after removing parent"
3091 is_patchless || ( $TRACE cd . && error "'cd .' worked after recreate parent" )
3092 $TRACE mkdir . && error "'mkdir .' worked after removing parent"
3093 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
3094 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
3095 is_patchless || ( $TRACE cd .. && error "'cd ..' worked after removing parent" || true )
3097 run_test 48d "Access removed parent subdir (should return errors)"
3099 test_48e() { # bug 4134
3100 check_kernel_version 41 || return 0
3101 #lctl set_param debug=-1
3103 mkdir -p $DIR/d48e/dir
3105 $TRACE rmdir $DIR/d48e/dir || error "remove cwd $DIR/d48e/dir failed"
3106 $TRACE rmdir $DIR/d48e || error "remove parent $DIR/d48e failed"
3107 $TRACE touch $DIR/d48e || error "'touch $DIR/d48e' failed"
3108 $TRACE chmod +x $DIR/d48e || error "'chmod +x $DIR/d48e' failed"
3109 # On a buggy kernel addition of "touch foo" after cd .. will
3110 # produce kernel oops in lookup_hash_it
3111 touch ../foo && error "'cd ..' worked after recreate parent"
3113 $TRACE rm $DIR/d48e || error "rm '$DIR/d48e' failed"
3115 run_test 48e "Access to recreated parent subdir (should return errors)"
3117 test_49() { # LU-1030
3118 # get ost1 size - lustre-OST0000
3119 ost1_size=$(do_facet ost1 lfs df |grep ${ost1_svc} |awk '{print $4}')
3120 # write 800M at maximum
3121 [ $ost1_size -gt 819200 ] && ost1_size=819200
3123 lfs setstripe -c 1 -i 0 $DIR/$tfile
3124 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
3127 # change max_pages_per_rpc while writing the file
3128 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
3129 local orig_mppc=`$LCTL get_param -n $osc1_mppc`
3130 # loop until dd process exits
3131 while ps ax -opid | grep -wq $dd_pid; do
3132 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
3133 sleep $((RANDOM % 5 + 1))
3135 # restore original max_pages_per_rpc
3136 $LCTL set_param $osc1_mppc=$orig_mppc
3137 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
3139 run_test 49 "Change max_pages_per_rpc won't break osc extent"
3145 ls /proc/$$/cwd || error
3147 run_test 50 "special situations: /proc symlinks ==============="
3149 test_51a() { # was test_51
3150 # bug 1516 - create an empty entry right after ".." then split dir
3153 $MCREATE $DIR/d51/bar
3155 createmany -m $DIR/d51/longfile 201
3157 while [ `ls -sd $DIR/d51 | awk '{ print $1 }'` -eq 4 ]; do
3158 $MCREATE $DIR/d51/longfile$FNUM
3163 ls -l $DIR/d51 > /dev/null || error
3165 run_test 51a "special situations: split htree with empty entry =="
3167 export NUMTEST=70000
3169 local BASE=$DIR/$tdir
3172 local mdtidx=$(printf "%04x" $($LFS getstripe -M $BASE))
3173 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
3174 [ $numfree -lt 21000 ] && skip "not enough free inodes ($numfree)" &&
3177 [ $numfree -lt $NUMTEST ] && NUMTEST=$(($numfree - 50)) &&
3178 echo "reduced count to $NUMTEST due to inodes"
3180 # need to check free space for the directories as well
3181 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
3182 numfree=$((blkfree / 4))
3183 [ $numfree -lt $NUMTEST ] && NUMTEST=$(($numfree - 50)) &&
3184 echo "reduced count to $NUMTEST due to blocks"
3186 createmany -d $BASE/d $NUMTEST && echo $NUMTEST > $BASE/fnum ||
3187 echo "failed" > $BASE/fnum
3189 run_test 51b "exceed 64k subdirectory nlink limit"
3191 test_51ba() { # LU-993
3192 local BASE=$DIR/$tdir
3193 # unlink all but 100 subdirectories, then check it still works
3195 [ -f $BASE/fnum ] && local NUMPREV=$(cat $BASE/fnum) && rm $BASE/fnum
3197 [ "$NUMPREV" != "failed" ] && NUMTEST=$NUMPREV
3198 local DELETE=$((NUMTEST - LEFT))
3200 # continue on to run this test even if 51b didn't finish,
3201 # just to delete the many subdirectories created.
3202 [ ! -d "${BASE}/d1" ] && skip "test_51b() not run" && return 0
3204 # for ldiskfs the nlink count should be 1, but this is OSD specific
3205 # and so this is listed for informational purposes only
3206 echo "nlink before: $(stat -c %h $BASE), created before: $NUMTEST"
3207 unlinkmany -d $BASE/d $DELETE
3210 if [ $RC -ne 0 ]; then
3211 if [ "$NUMPREV" == "failed" ]; then
3212 skip "previous setup failed"
3215 error "unlink of first $DELETE subdirs failed"
3220 echo "nlink between: $(stat -c %h $BASE)"
3221 # trim the first line of ls output
3222 local FOUND=$(($(ls -l ${BASE} | wc -l) - 1))
3223 [ $FOUND -ne $LEFT ] &&
3224 error "can't find subdirs: found only $FOUND/$LEFT"
3226 unlinkmany -d $BASE/d $DELETE $LEFT ||
3227 error "unlink of second $LEFT subdirs failed"
3228 # regardless of whether the backing filesystem tracks nlink accurately
3229 # or not, the nlink count shouldn't be more than "." and ".." here
3230 local AFTER=$(stat -c %h $BASE)
3231 [ $AFTER -gt 2 ] && error "nlink after: $AFTER > 2" ||
3232 echo "nlink after: $AFTER"
3234 run_test 51ba "verify nlink for many subdirectory cleanup"
3237 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3239 local ndirs=${TEST51BB_NDIRS:-10}
3240 local nfiles=${TEST51BB_NFILES:-100}
3242 local numfree=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
3244 [ $numfree -lt $(( ndirs * nfiles)) ] && \
3245 nfiles=$(( numfree / ndirs - 10 ))
3247 local dir=$DIR/d51bb
3249 local savePOLICY=$(lctl get_param -n lmv.*.placement)
3250 lctl set_param -n lmv.*.placement=CHAR
3253 local IUSED=$(lfs df -i $dir | grep MDT | awk '{print $3}')
3257 for ((i=0; i < $ndirs; i++)); do
3258 dirs[i]=$dir/$RANDOM
3259 echo Creating directory ${dirs[i]}
3262 echo Creating $nfiles in dir ${dirs[i]} ...
3263 echo "createmany -o ${dirs[i]}/$tfile- $nfiles"
3264 createmany -o ${dirs[i]}/$tfile- $nfiles
3270 IUSED=$(lfs df -i $dir | grep MDT | awk '{print $3}')
3274 for ((i=0; i<${#NEWUSED[@]}; i++)); do
3275 echo "mds $i: inodes count OLD ${OLDUSED[$i]} NEW ${NEWUSED[$i]}"
3276 [ ${OLDUSED[$i]} -lt ${NEWUSED[$i]} ] || rc=$((rc + 1))
3279 lctl set_param -n lmv.*.placement=$savePOLICY
3281 [ $rc -ne $MDSCOUNT ] || \
3282 error "Objects/inodes are not distributed over all mds servers"
3284 run_test 51bb "mkdir createmany CMD $MDSCOUNT ===================="
3287 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping test with few OSTs" && return
3289 createmany -o $DIR/d51d/t- 1000
3290 $GETSTRIPE $DIR/d51d > $TMP/files
3291 for N in `seq 0 $((OSTCOUNT - 1))`; do
3292 OBJS[$N]=`awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}' $TMP/files`
3293 OBJS0[$N]=`grep -A 1 idx $TMP/files | awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}'`
3294 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
3296 unlinkmany $DIR/d51d/t- 1000
3299 for N in `seq 1 $((OSTCOUNT - 1))`; do
3300 [ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ] && \
3301 error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
3302 [ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ] && \
3303 error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
3305 [ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ] && \
3306 error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
3307 [ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ] && \
3308 error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
3312 run_test 51d "check object distribution ===================="
3315 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
3318 chattr +a $DIR/d52a/foo || error "chattr +a failed"
3319 echo bar >> $DIR/d52a/foo || error "append bar failed"
3320 cp /etc/hosts $DIR/d52a/foo && error "cp worked"
3321 rm -f $DIR/d52a/foo 2>/dev/null && error "rm worked"
3322 link $DIR/d52a/foo $DIR/d52a/foo_link 2>/dev/null && error "link worked"
3323 echo foo >> $DIR/d52a/foo || error "append foo failed"
3324 mrename $DIR/d52a/foo $DIR/d52a/foo_ren && error "rename worked"
3325 lsattr $DIR/d52a/foo | egrep -q "^-+a[-e]+ $DIR/d52a/foo" || error "lsattr"
3326 chattr -a $DIR/d52a/foo || error "chattr -a failed"
3327 cp -r $DIR/d52a /tmp/
3328 rm -fr $DIR/d52a || error "cleanup rm failed"
3330 run_test 52a "append-only flag test (should return errors) ====="
3333 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
3336 chattr +i $DIR/d52b/foo || error "chattr +i failed"
3337 cat test > $DIR/d52b/foo && error "cat test worked"
3338 cp /etc/hosts $DIR/d52b/foo && error "cp worked"
3339 rm -f $DIR/d52b/foo 2>/dev/null && error "rm worked"
3340 link $DIR/d52b/foo $DIR/d52b/foo_link 2>/dev/null && error "link worked"
3341 echo foo >> $DIR/d52b/foo && error "echo worked"
3342 mrename $DIR/d52b/foo $DIR/d52b/foo_ren && error "rename worked"
3343 [ -f $DIR/d52b/foo ] || error
3344 [ -f $DIR/d52b/foo_ren ] && error
3345 lsattr $DIR/d52b/foo | egrep -q "^-+i[-e]+ $DIR/d52b/foo" || error "lsattr"
3346 chattr -i $DIR/d52b/foo || error "chattr failed"
3348 rm -fr $DIR/d52b || error
3350 run_test 52b "immutable flag test (should return errors) ======="
3353 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3354 remote_ost_nodsh && skip "remote OST with nodsh" && return
3363 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
3364 for value in $(do_facet $SINGLEMDS lctl get_param osc.$mdtosc.prealloc_last_id) ; do
3365 param=`echo ${value[0]} | cut -d "=" -f1`
3366 ostname=`echo $param | cut -d "." -f2 | cut -d - -f 1-2`
3367 mds_last=$(do_facet $SINGLEMDS lctl get_param -n $param)
3368 ostnum=$(echo $ostname | sed "s/${FSNAME}-OST//g" | awk '{print ($1+1)}' )
3369 ost_last=$(do_facet ost$ostnum lctl get_param -n obdfilter.$ostname.last_id | head -n 1)
3370 echo "$ostname.last_id=$ost_last ; MDS.last_id=$mds_last"
3371 if [ $ost_last != $mds_last ]; then
3372 error "$ostname.last_id=$ost_last ; MDS.last_id=$mds_last"
3376 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
3379 [ ! -f "$SOCKETSERVER" ] && skip_env "no socketserver, skipping" && return
3380 [ ! -f "$SOCKETCLIENT" ] && skip_env "no socketclient, skipping" && return
3381 $SOCKETSERVER $DIR/socket
3382 $SOCKETCLIENT $DIR/socket || error
3383 $MUNLINK $DIR/socket
3385 run_test 54a "unix domain socket test =========================="
3391 dd if=/dev/zero of=$f bs=`page_size` count=1
3393 run_test 54b "char device works in lustre ======================"
3396 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
3397 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
3398 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
3400 for i in `seq 3 7`; do
3401 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
3411 loopdev="$DIR/loop54c"
3414 [ -z "$LOOPNUM" ] && echo "couldn't find empty loop device" && return
3415 mknod $loopdev b 7 $LOOPNUM
3416 echo "make a loop file system with $tfile on $loopdev ($LOOPNUM)..."
3417 dd if=/dev/zero of=$tfile bs=`page_size` seek=1024 count=1 > /dev/null
3418 losetup $loopdev $tfile || error "can't set up $loopdev for $tfile"
3419 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
3421 mount -t ext2 $loopdev $tdir || error "error mounting $loopdev on $tdir"
3422 dd if=/dev/zero of=$tdir/tmp bs=`page_size` count=30 || error "dd write"
3424 dd if=$tdir/tmp of=/dev/zero bs=`page_size` count=30 || error "dd read"
3429 run_test 54c "block device works in lustre ====================="
3435 [ "$string" = `echo $string > $f | cat $f` ] || error
3437 run_test 54d "fifo device works in lustre ======================"
3440 check_kernel_version 46 || return 0
3443 cp -aL /dev/console $f
3444 echo $string > $f || error
3446 run_test 54e "console/tty device works in lustre ======================"
3448 #The test_55 used to be iopen test and it was removed by bz#24037.
3449 #run_test 55 "check iopen_connect_dentry() ======================"
3451 test_56a() { # was test_56
3457 NUMFILESx2=$(($NUMFILES * 2))
3458 for i in `seq 1 $NUMFILES` ; do
3459 touch $DIR/d56/file$i
3460 touch $DIR/d56/dir/file$i
3463 # test lfs getstripe with --recursive
3464 FILENUM=`$GETSTRIPE --recursive $DIR/d56 | grep -c obdidx`
3465 [ $FILENUM -eq $NUMFILESx2 ] ||
3466 error "$GETSTRIPE --recursive: found $FILENUM, not $NUMFILESx2"
3467 FILENUM=`$GETSTRIPE $DIR/d56 | grep -c obdidx`
3468 [ $FILENUM -eq $NUMFILES ] ||
3469 error "$GETSTRIPE $DIR/d56: found $FILENUM, not $NUMFILES"
3470 echo "$GETSTRIPE --recursive passed."
3472 # test lfs getstripe with file instead of dir
3473 FILENUM=`$GETSTRIPE $DIR/d56/file1 | grep -c obdidx`
3474 [ $FILENUM -eq 1 ] || error \
3475 "$GETSTRIPE $DIR/d56/file1: found $FILENUM, not 1"
3476 echo "$GETSTRIPE file1 passed."
3478 #test lfs getstripe with --verbose
3479 [ `$GETSTRIPE --verbose $DIR/d56 | grep -c lmm_magic` -eq $NUMFILES ] ||
3480 error "$GETSTRIPE --verbose $DIR/d56: want $NUMFILES lmm_magic"
3481 [ `$GETSTRIPE $DIR/d56 | grep -c lmm_magic` -eq 0 ] ||
3482 error "$GETSTRIPE $DIR/d56: showed lmm_magic"
3483 echo "$GETSTRIPE --verbose passed."
3485 #test lfs getstripe with --obd
3486 $GETSTRIPE --obd wrong_uuid $DIR/d56 2>&1 | grep -q "unknown obduuid" ||
3487 error "$GETSTRIPE --obd wrong_uuid should return error message"
3489 [ "$OSTCOUNT" -lt 2 ] &&
3490 skip_env "skipping other $GETSTRIPE --obd test" && return
3493 OBDUUID=$(ostuuid_from_index $OSTIDX)
3494 FILENUM=`$GETSTRIPE -ir $DIR/d56 | grep -x $OSTIDX | wc -l`
3495 FOUND=`$GETSTRIPE -r --obd $OBDUUID $DIR/d56 | grep obdidx | wc -l`
3496 [ $FOUND -eq $FILENUM ] ||
3497 error "$GETSTRIPE --obd wrong: found $FOUND, expected $FILENUM"
3498 [ `$GETSTRIPE -r -v --obd $OBDUUID $DIR/d56 |
3499 sed '/^[ ]*'${OSTIDX}'[ ]/d' |
3500 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l` -eq 0 ] ||
3501 error "$GETSTRIPE --obd: should not show file on other obd"
3502 echo "$GETSTRIPE --obd passed"
3504 run_test 56a "check $GETSTRIPE"
3509 local LOCAL_NUMFILES="$1"
3510 local LOCAL_NUMDIRS="$2"
3511 local MKDIR_PARAMS="$3"
3513 if [ ! -d "$TDIR" ] ; then
3515 [ "$MKDIR_PARAMS" ] && $SETSTRIPE $MKDIR_PARAMS $TDIR
3516 for i in `seq 1 $LOCAL_NUMFILES` ; do
3519 for i in `seq 1 $LOCAL_NUMDIRS` ; do
3521 for j in `seq 1 $LOCAL_NUMFILES` ; do
3522 touch $TDIR/dir$i/file$j
3528 setup_56_special() {
3532 if [ ! -e "$TDIR/loop1b" ] ; then
3533 for i in `seq 1 $LOCAL_NUMFILES` ; do
3534 mknod $TDIR/loop${i}b b 7 $i
3535 mknod $TDIR/null${i}c c 1 3
3536 ln -s $TDIR/file1 $TDIR/link${i}l
3538 for i in `seq 1 $LOCAL_NUMDIRS` ; do
3539 mknod $TDIR/dir$i/loop${i}b b 7 $i
3540 mknod $TDIR/dir$i/null${i}c c 1 3
3541 ln -s $TDIR/dir$i/file1 $TDIR/dir$i/link${i}l
3550 setup_56 $NUMFILES $NUMDIRS
3552 EXPECTED=$(($NUMDIRS + 2))
3553 # test lfs find with -name
3554 for i in $(seq 1 $NUMFILES) ; do
3555 NUMS=$($LFIND -name "*$i" $TDIR | wc -l)
3556 [ $NUMS -eq $EXPECTED ] ||
3557 error "lfs find -name \"*$i\" $TDIR wrong: "\
3558 "found $NUMS, expected $EXPECTED"
3561 run_test 56g "check lfs find -name ============================="
3567 setup_56 $NUMFILES $NUMDIRS
3569 EXPECTED=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
3570 # test lfs find with ! -name
3571 for i in $(seq 1 $NUMFILES) ; do
3572 NUMS=$($LFIND ! -name "*$i" $TDIR | wc -l)
3573 [ $NUMS -eq $EXPECTED ] ||
3574 error "lfs find ! -name \"*$i\" $TDIR wrong: "\
3575 "found $NUMS, expected $EXPECTED"
3578 run_test 56h "check lfs find ! -name ============================="
3583 UUID=$(ostuuid_from_index 0 $DIR/$tdir)
3584 CMD="$LFIND -ost $UUID $DIR/$tdir"
3586 [ -z "$OUT" ] || error "\"$CMD\" returned directory '$OUT'"
3588 run_test 56i "check 'lfs find -ost UUID' skips directories ======="
3592 setup_56_special $NUMFILES $NUMDIRS
3594 EXPECTED=$((NUMDIRS + 1))
3595 CMD="$LFIND -type d $TDIR"
3596 NUMS=$($CMD | wc -l)
3597 [ $NUMS -eq $EXPECTED ] ||
3598 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3600 run_test 56j "check lfs find -type d ============================="
3604 setup_56_special $NUMFILES $NUMDIRS
3606 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
3607 CMD="$LFIND -type f $TDIR"
3608 NUMS=$($CMD | wc -l)
3609 [ $NUMS -eq $EXPECTED ] ||
3610 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3612 run_test 56k "check lfs find -type f ============================="
3616 setup_56_special $NUMFILES $NUMDIRS
3618 EXPECTED=$((NUMDIRS + NUMFILES))
3619 CMD="$LFIND -type b $TDIR"
3620 NUMS=$($CMD | wc -l)
3621 [ $NUMS -eq $EXPECTED ] ||
3622 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3624 run_test 56l "check lfs find -type b ============================="
3628 setup_56_special $NUMFILES $NUMDIRS
3630 EXPECTED=$((NUMDIRS + NUMFILES))
3631 CMD="$LFIND -type c $TDIR"
3632 NUMS=$($CMD | wc -l)
3633 [ $NUMS -eq $EXPECTED ] ||
3634 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3636 run_test 56m "check lfs find -type c ============================="
3640 setup_56_special $NUMFILES $NUMDIRS
3642 EXPECTED=$((NUMDIRS + NUMFILES))
3643 CMD="$LFIND -type l $TDIR"
3644 NUMS=$($CMD | wc -l)
3645 [ $NUMS -eq $EXPECTED ] ||
3646 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3648 run_test 56n "check lfs find -type l ============================="
3652 setup_56 $NUMFILES $NUMDIRS
3654 utime $TDIR/file1 > /dev/null || error "utime (1)"
3655 utime $TDIR/file2 > /dev/null || error "utime (2)"
3656 utime $TDIR/dir1 > /dev/null || error "utime (3)"
3657 utime $TDIR/dir2 > /dev/null || error "utime (4)"
3658 utime $TDIR/dir1/file1 > /dev/null || error "utime (5)"
3659 dd if=/dev/zero count=1 >> $TDIR/dir1/file1 && sync
3662 NUMS=`$LFIND -mtime +0 $TDIR | wc -l`
3663 [ $NUMS -eq $EXPECTED ] || \
3664 error "lfs find -mtime +0 $TDIR wrong: found $NUMS, expected $EXPECTED"
3667 CMD="$LFIND -mtime 0 $TDIR"
3668 NUMS=$($CMD | wc -l)
3669 [ $NUMS -eq $EXPECTED ] ||
3670 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3672 run_test 56o "check lfs find -mtime for old files =========================="
3675 [ $RUNAS_ID -eq $UID ] &&
3676 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
3679 setup_56 $NUMFILES $NUMDIRS
3681 chown $RUNAS_ID $TDIR/file* || error "chown $DIR/${tdir}g/file$i failed"
3683 CMD="$LFIND -uid $RUNAS_ID $TDIR"
3684 NUMS=$($CMD | wc -l)
3685 [ $NUMS -eq $EXPECTED ] || \
3686 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3688 EXPECTED=$(((NUMFILES + 1) * NUMDIRS + 1))
3689 CMD="$LFIND ! -uid $RUNAS_ID $TDIR"
3690 NUMS=$($CMD | wc -l)
3691 [ $NUMS -eq $EXPECTED ] || \
3692 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3694 run_test 56p "check lfs find -uid and ! -uid ==============================="
3697 [ $RUNAS_ID -eq $UID ] &&
3698 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
3701 setup_56 $NUMFILES $NUMDIRS
3703 chgrp $RUNAS_GID $TDIR/file* || error "chown $TDIR/file$i failed"
3706 CMD="$LFIND -gid $RUNAS_GID $TDIR"
3707 NUMS=$($CMD | wc -l)
3708 [ $NUMS -eq $EXPECTED ] ||
3709 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3711 EXPECTED=$(( ($NUMFILES+1) * $NUMDIRS + 1))
3712 CMD="$LFIND ! -gid $RUNAS_GID $TDIR"
3713 NUMS=$($CMD | wc -l)
3714 [ $NUMS -eq $EXPECTED ] ||
3715 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3717 run_test 56q "check lfs find -gid and ! -gid ==============================="
3721 setup_56 $NUMFILES $NUMDIRS
3724 CMD="$LFIND -size 0 -type f $TDIR"
3725 NUMS=$($CMD | wc -l)
3726 [ $NUMS -eq $EXPECTED ] ||
3727 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3729 CMD="$LFIND ! -size 0 -type f $TDIR"
3730 NUMS=$($CMD | wc -l)
3731 [ $NUMS -eq $EXPECTED ] ||
3732 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3733 echo "test" > $TDIR/$tfile
3734 echo "test2" > $TDIR/$tfile.2 && sync
3736 CMD="$LFIND -size 5 -type f $TDIR"
3737 NUMS=$($CMD | wc -l)
3738 [ $NUMS -eq $EXPECTED ] ||
3739 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3741 CMD="$LFIND -size +5 -type f $TDIR"
3742 NUMS=$($CMD | wc -l)
3743 [ $NUMS -eq $EXPECTED ] ||
3744 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3746 CMD="$LFIND -size +0 -type f $TDIR"
3747 NUMS=$($CMD | wc -l)
3748 [ $NUMS -eq $EXPECTED ] ||
3749 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3751 CMD="$LFIND ! -size -5 -type f $TDIR"
3752 NUMS=$($CMD | wc -l)
3753 [ $NUMS -eq $EXPECTED ] ||
3754 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3756 CMD="$LFIND -size -5 -type f $TDIR"
3757 NUMS=$($CMD | wc -l)
3758 [ $NUMS -eq $EXPECTED ] ||
3759 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3761 run_test 56r "check lfs find -size works =========================="
3763 test_56s() { # LU-611
3765 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT"
3767 if [ $OSTCOUNT -gt 1 ]; then
3768 $SETSTRIPE -c 1 $TDIR/$tfile.{0,1,2,3}
3772 ONESTRIPE=$(((NUMDIRS + 1) * NUMFILES))
3776 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
3777 CMD="$LFIND -stripe-count $OSTCOUNT -type f $TDIR"
3778 NUMS=$($CMD | wc -l)
3779 [ $NUMS -eq $EXPECTED ] ||
3780 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3782 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + EXTRA))
3783 CMD="$LFIND -stripe-count +0 -type f $TDIR"
3784 NUMS=$($CMD | wc -l)
3785 [ $NUMS -eq $EXPECTED ] ||
3786 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3789 CMD="$LFIND -stripe-count 1 -type f $TDIR"
3790 NUMS=$($CMD | wc -l)
3791 [ $NUMS -eq $EXPECTED ] ||
3792 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3794 CMD="$LFIND -stripe-count -2 -type f $TDIR"
3795 NUMS=$($CMD | wc -l)
3796 [ $NUMS -eq $EXPECTED ] ||
3797 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3800 CMD="$LFIND -stripe-count $((OSTCOUNT + 1)) -type f $TDIR"
3801 NUMS=$($CMD | wc -l)
3802 [ $NUMS -eq $EXPECTED ] ||
3803 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3805 run_test 56s "check lfs find -stripe-count works"
3807 test_56t() { # LU-611
3809 setup_56 $NUMFILES $NUMDIRS "-s 512k"
3811 $SETSTRIPE -S 256k $TDIR/$tfile.{0,1,2,3}
3813 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
3814 CMD="$LFIND -stripe-size 512k -type f $TDIR"
3815 NUMS=$($CMD | wc -l)
3816 [ $NUMS -eq $EXPECTED ] ||
3817 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3819 CMD="$LFIND -stripe-size +320k -type f $TDIR"
3820 NUMS=$($CMD | wc -l)
3821 [ $NUMS -eq $EXPECTED ] ||
3822 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3824 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + 4))
3825 CMD="$LFIND -stripe-size +200k -type f $TDIR"
3826 NUMS=$($CMD | wc -l)
3827 [ $NUMS -eq $EXPECTED ] ||
3828 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3830 CMD="$LFIND -stripe-size -640k -type f $TDIR"
3831 NUMS=$($CMD | wc -l)
3832 [ $NUMS -eq $EXPECTED ] ||
3833 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3836 CMD="$LFIND -stripe-size 256k -type f $TDIR"
3837 NUMS=$($CMD | wc -l)
3838 [ $NUMS -eq $EXPECTED ] ||
3839 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3841 CMD="$LFIND -stripe-size -320k -type f $TDIR"
3842 NUMS=$($CMD | wc -l)
3843 [ $NUMS -eq $EXPECTED ] ||
3844 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3847 CMD="$LFIND -stripe-size 1024k -type f $TDIR"
3848 NUMS=$($CMD | wc -l)
3849 [ $NUMS -eq $EXPECTED ] ||
3850 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3852 run_test 56t "check lfs find -stripe-size works"
3854 test_56u() { # LU-611
3856 setup_56 $NUMFILES $NUMDIRS "-i 0"
3858 if [ $OSTCOUNT -gt 1 ]; then
3859 $SETSTRIPE -i 1 $TDIR/$tfile.{0,1,2,3}
3865 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
3866 CMD="$LFIND -stripe-index 0 -type f $TDIR"
3867 NUMS=$($CMD | wc -l)
3868 [ $NUMS -eq $EXPECTED ] ||
3869 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3872 CMD="$LFIND -stripe-index 1 -type f $TDIR"
3873 NUMS=$($CMD | wc -l)
3874 [ $NUMS -eq $EXPECTED ] ||
3875 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3877 CMD="$LFIND ! -stripe-index 0 -type f $TDIR"
3878 NUMS=$($CMD | wc -l)
3879 [ $NUMS -eq $EXPECTED ] ||
3880 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3883 # This should produce an error and not return any files
3884 CMD="$LFIND -stripe-index $OSTCOUNT -type f $TDIR"
3885 NUMS=$($CMD 2>/dev/null | wc -l)
3886 [ $NUMS -eq $EXPECTED ] ||
3887 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3889 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + ONESTRIPE))
3890 CMD="$LFIND -stripe-index 0,1 -type f $TDIR"
3891 NUMS=$($CMD | wc -l)
3892 [ $NUMS -eq $EXPECTED ] ||
3893 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3895 run_test 56u "check lfs find -stripe-index works"
3902 setup_56 $NUMFILES $NUMDIRS
3904 UUID=$(mdtuuid_from_index $MDT_IDX $TDIR)
3905 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT index $MDT_IDX"
3907 for file in $($LFIND -mdt $UUID $TDIR); do
3908 file_mdt_idx=$($GETSTRIPE -M $file)
3909 [ $file_mdt_idx -eq $MDT_IDX ] ||
3910 error "'lfind -mdt $UUID' != 'getstripe -M' ($file_mdt_idx)"
3913 run_test 56v "check 'lfs find -mdt match with lfs getstripe -M' ======="
3915 # Get and check the actual stripe count of one file.
3916 # Usage: check_stripe_count <file> <expected_stripe_count>
3917 check_stripe_count() {
3922 [[ -z "$file" || -z "$expected" ]] &&
3923 error "check_stripe_count: invalid argument!"
3925 local cmd="$GETSTRIPE -c $file"
3926 actual=$($cmd) || error "$cmd failed"
3927 actual=${actual%% *}
3929 if [[ $actual -ne $expected ]]; then
3930 [[ $expected -eq -1 ]] ||
3931 error "$cmd wrong: found $actual, expected $expected"
3932 [[ $actual -eq $OSTCOUNT ]] ||
3933 error "$cmd wrong: found $actual, expected $OSTCOUNT"
3940 rm -rf $TDIR || error "remove $TDIR failed"
3941 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT"
3944 stripe_size=$($GETSTRIPE -S -d $TDIR) ||
3945 error "$GETSTRIPE -S -d $TDIR failed"
3946 stripe_size=${stripe_size%% *}
3948 local file_size=$((stripe_size * OSTCOUNT))
3949 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
3950 local required_space=$((file_num * file_size))
3951 local free_space=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
3952 [[ $free_space -le $((required_space / 1024)) ]] &&
3953 skip_env "need at least $required_space bytes free space," \
3954 "have $free_space kbytes" && return
3957 local dd_count=$((file_size / dd_bs))
3959 # write data into the files
3963 for i in $(seq 1 $NUMFILES); do
3965 yes | dd bs=$dd_bs count=$dd_count of=$file >/dev/null 2>&1 ||
3966 error "write data into $file failed"
3968 for i in $(seq 1 $NUMDIRS); do
3969 for j in $(seq 1 $NUMFILES); do
3970 file=$TDIR/dir$i/file$j
3971 yes | dd bs=$dd_bs count=$dd_count of=$file \
3973 error "write data into $file failed"
3978 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
3981 local cmd="$LFS_MIGRATE -y -c $expected $TDIR/file1"
3983 eval $cmd || error "$cmd failed"
3985 check_stripe_count $TDIR/file1 $expected
3988 cmd="$LFS_MIGRATE -y -c $expected $TDIR/dir1"
3990 eval $cmd || error "$cmd failed"
3992 for j in $(seq 1 $NUMFILES); do
3993 check_stripe_count $TDIR/dir1/file$j $expected
3996 # lfs_migrate works with lfs find
3997 cmd="$LFIND -stripe_count $OSTCOUNT -type f $TDIR |
3998 $LFS_MIGRATE -y -c $expected"
4000 eval $cmd || error "$cmd failed"
4002 for i in $(seq 2 $NUMFILES); do
4003 check_stripe_count $TDIR/file$i $expected
4005 for i in $(seq 2 $NUMDIRS); do
4006 for j in $(seq 1 $NUMFILES); do
4007 check_stripe_count $TDIR/dir$i/file$j $expected
4011 run_test 56w "check lfs_migrate -c stripe_count works"
4014 # note test will not do anything if MDS is not local
4015 if [ "$(facet_type_fstype MDS)" != ldiskfs ]; then
4016 skip "Only applicable to ldiskfs-based MDTs"
4020 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4021 local MNTDEV="osd*.*MDT*.mntdev"
4022 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
4023 [ -z "$DEV" ] && error "can't access $MNTDEV"
4024 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
4025 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
4026 error "can't access $DEV"
4027 DEVISIZE=`awk '/Inode size:/ { print $3 }' $TMP/t57a.dump`
4028 [ "$DEVISIZE" -gt 128 ] || error "inode size $DEVISIZE"
4032 run_test 57a "verify MDS filesystem created with large inodes =="
4035 if [ "$(facet_type_fstype MDS)" != ldiskfs ]; then
4036 skip "Only applicable to ldiskfs-based MDTs"
4040 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4045 local FILEN=$dir/f$FILECOUNT
4047 rm -rf $dir || error "removing $dir"
4048 mkdir -p $dir || error "creating $dir"
4049 local num=$(get_mds_dir $dir)
4052 echo "mcreating $FILECOUNT files"
4053 createmany -m $dir/f 1 $FILECOUNT || \
4054 error "creating files in $dir"
4056 # verify that files do not have EAs yet
4057 $GETSTRIPE $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
4058 $GETSTRIPE $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
4062 df $dir #make sure we get new statfs data
4063 local MDSFREE=$(do_facet $mymds \
4064 lctl get_param -n osd*.*MDT000$((num -1)).kbytesfree)
4065 local MDCFREE=$(lctl get_param -n mdc.*MDT000$((num -1))-mdc-*.kbytesfree)
4066 echo "opening files to create objects/EAs"
4068 for FILE in `seq -f $dir/f%g 1 $FILECOUNT`; do
4069 $OPENFILE -f O_RDWR $FILE > /dev/null 2>&1 || error "opening $FILE"
4072 # verify that files have EAs now
4073 $GETSTRIPE $FILE1 | grep -q "obdidx" || error "$FILE1 missing EA"
4074 $GETSTRIPE $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
4076 sleep 1 #make sure we get new statfs data
4078 local MDSFREE2=$(do_facet $mymds \
4079 lctl get_param -n osd*.*MDT000$((num -1)).kbytesfree)
4080 local MDCFREE2=$(lctl get_param -n mdc.*MDT000$((num -1))-mdc-*.kbytesfree)
4081 if [ "$MDCFREE2" -lt "$((MDCFREE - 8))" ]; then
4082 if [ "$MDSFREE" != "$MDSFREE2" ]; then
4083 error "MDC before $MDCFREE != after $MDCFREE2"
4085 echo "MDC before $MDCFREE != after $MDCFREE2"
4086 echo "unable to confirm if MDS has large inodes"
4091 run_test 57b "default LOV EAs are stored inside large inodes ==="
4094 [ -z "$(which wiretest 2>/dev/null)" ] && skip_env "could not find wiretest" && return
4097 run_test 58 "verify cross-platform wire constants =============="
4100 echo "touch 130 files"
4101 createmany -o $DIR/f59- 130
4103 unlinkmany $DIR/f59- 130
4106 # wait for commitment of removal
4108 run_test 59 "verify cancellation of llog records async ========="
4110 TEST60_HEAD="test_60 run $RANDOM"
4112 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
4113 [ ! -f run-llog.sh ] && skip_env "missing subtest run-llog.sh" && return
4114 log "$TEST60_HEAD - from kernel mode"
4115 do_facet mgs sh run-llog.sh
4117 run_test 60a "llog sanity tests run from kernel module =========="
4119 test_60b() { # bug 6411
4121 LLOG_COUNT=`dmesg | awk "/$TEST60_HEAD/{marker = 1; from_marker = 0;}
4133 [ $LLOG_COUNT -gt 50 ] && error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)"|| true
4135 run_test 60b "limit repeated messages from CERROR/CWARN ========"
4138 echo "create 5000 files"
4139 createmany -o $DIR/f60c- 5000
4140 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
4141 lctl set_param fail_loc=0x80000137
4142 unlinkmany $DIR/f60c- 5000
4143 lctl set_param fail_loc=0
4145 run_test 60c "unlink file when mds full"
4148 SAVEPRINTK=$(lctl get_param -n printk)
4150 # verify "lctl mark" is even working"
4151 MESSAGE="test message ID $RANDOM $$"
4152 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
4153 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
4155 lctl set_param printk=0 || error "set lnet.printk failed"
4156 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
4157 MESSAGE="new test message ID $RANDOM $$"
4158 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
4159 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
4160 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
4162 lctl set_param -n printk="$SAVEPRINTK"
4164 run_test 60d "test printk console message masking"
4168 dd if=/dev/zero of=$f bs=`page_size` count=1
4169 cancel_lru_locks osc
4170 $MULTIOP $f OSMWUc || error
4173 run_test 61 "mmap() writes don't make sync hang ================"
4175 # bug 2330 - insufficient obd_match error checking causes LBUG
4179 cancel_lru_locks osc
4180 lctl set_param fail_loc=0x405
4181 cat $f && error "cat succeeded, expect -EIO"
4182 lctl set_param fail_loc=0
4184 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
4185 # match every page all of the time.
4186 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
4188 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
4189 test_63a() { # was test_63
4190 MAX_DIRTY_MB=`lctl get_param -n osc.*.max_dirty_mb | head -n 1`
4191 lctl set_param -n osc.*.max_dirty_mb 0
4192 for i in `seq 10` ; do
4193 dd if=/dev/zero of=$DIR/f63 bs=8k &
4199 lctl set_param -n osc.*.max_dirty_mb $MAX_DIRTY_MB
4200 rm -f $DIR/f63 || true
4202 run_test 63a "Verify oig_wait interruption does not crash ======="
4204 # bug 2248 - async write errors didn't return to application on sync
4205 # bug 3677 - async write errors left page locked
4208 lctl set_param debug=-1
4210 # ensure we have a grant to do async writes
4211 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
4214 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
4215 lctl set_param fail_loc=0x80000406
4216 $MULTIOP $DIR/$tfile Owy && \
4217 error "sync didn't return ENOMEM"
4218 sync; sleep 2; sync # do a real sync this time to flush page
4219 lctl get_param -n llite.*.dump_page_cache | grep locked && \
4220 error "locked page left in cache after async error" || true
4223 run_test 63b "async write errors should be returned to fsync ==="
4227 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
4229 run_test 64a "verify filter grant calculations (in kernel) ====="
4232 [ ! -f oos.sh ] && skip_env "missing subtest oos.sh" && return
4235 run_test 64b "check out-of-space detection on client ==========="
4237 # bug 1414 - set/get directories' stripe info
4241 $LVERIFY $DIR/d65 $DIR/d65/f1 || error "lverify failed"
4243 run_test 65a "directory with no stripe info ===================="
4247 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/d65||error "setstripe"
4249 $LVERIFY $DIR/d65 $DIR/d65/f2 || error "lverify failed"
4251 run_test 65b "directory setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1"
4254 if [ $OSTCOUNT -gt 1 ]; then
4256 $SETSTRIPE -S $(($STRIPESIZE * 4)) -i 1 \
4257 -c $(($OSTCOUNT - 1)) $DIR/d65 || error "setstripe"
4259 $LVERIFY $DIR/d65 $DIR/d65/f3 || error "lverify failed"
4262 run_test 65c "directory setstripe -S $((STRIPESIZE*4)) -i 1 -c $((OSTCOUNT-1))"
4266 if [ $STRIPECOUNT -le 0 ]; then
4268 elif [ $STRIPECOUNT -gt 2000 ]; then
4269 #LOV_MAX_STRIPE_COUNT is 2000
4270 [ $OSTCOUNT -gt 2000 ] && sc=2000 || sc=$(($OSTCOUNT - 1))
4272 sc=$(($STRIPECOUNT - 1))
4274 $SETSTRIPE -S $STRIPESIZE -c $sc $DIR/d65 || error "setstripe"
4275 touch $DIR/d65/f4 $DIR/d65/f5
4276 $LVERIFY $DIR/d65 $DIR/d65/f4 $DIR/d65/f5 || error "lverify failed"
4278 run_test 65d "directory setstripe -S $STRIPESIZE -c stripe_count"
4283 $SETSTRIPE $DIR/d65 || error "setstripe"
4284 $GETSTRIPE -v $DIR/d65 | grep "Default" || error "no stripe info failed"
4286 $LVERIFY $DIR/d65 $DIR/d65/f6 || error "lverify failed"
4288 run_test 65e "directory setstripe defaults ======================="
4292 $RUNAS $SETSTRIPE $DIR/d65f && error "setstripe succeeded" || true
4294 run_test 65f "dir setstripe permission (should return error) ==="
4298 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/d65 ||error "setstripe"
4299 $SETSTRIPE -d $DIR/d65 || error "setstripe"
4300 $GETSTRIPE -v $DIR/d65 | grep "Default" || \
4301 error "delete default stripe failed"
4303 run_test 65g "directory setstripe -d ==========================="
4307 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/d65 ||error "setstripe"
4308 mkdir -p $DIR/d65/dd1
4309 [ $($GETSTRIPE -c $DIR/d65) == $($GETSTRIPE -c $DIR/d65/dd1) ] ||
4310 error "stripe info inherit failed"
4312 run_test 65h "directory stripe info inherit ===================="
4314 test_65i() { # bug6367
4315 $SETSTRIPE -S 65536 -c -1 $MOUNT
4317 run_test 65i "set non-default striping on root directory (bug 6367)="
4319 test_65ia() { # bug12836
4320 $GETSTRIPE $MOUNT || error "getstripe $MOUNT failed"
4322 run_test 65ia "getstripe on -1 default directory striping"
4324 test_65ib() { # bug12836
4325 $GETSTRIPE -v $MOUNT || error "getstripe -v $MOUNT failed"
4327 run_test 65ib "getstripe -v on -1 default directory striping"
4329 test_65ic() { # bug12836
4330 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
4332 run_test 65ic "new find on -1 default directory striping"
4334 test_65j() { # bug6367
4336 # if we aren't already remounting for each test, do so for this test
4337 if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
4338 cleanup || error "failed to unmount"
4341 $SETSTRIPE -d $MOUNT || error "setstripe failed"
4343 run_test 65j "set default striping on root directory (bug 6367)="
4345 test_65k() { # bug11679
4346 [ "$OSTCOUNT" -lt 2 ] && skip_env "too few OSTs" && return
4347 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4349 echo "Check OST status: "
4350 local MDS_OSCS=`do_facet $SINGLEMDS lctl dl |
4351 awk '/[oO][sS][cC].*md[ts]/ { print $4 }'`
4353 for OSC in $MDS_OSCS; do
4354 echo $OSC "is activate"
4355 do_facet $SINGLEMDS lctl --device %$OSC activate
4358 do_facet client mkdir -p $DIR/$tdir
4359 for INACTIVE_OSC in $MDS_OSCS; do
4360 echo "Deactivate: " $INACTIVE_OSC
4361 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
4362 for STRIPE_OSC in $MDS_OSCS; do
4363 OST=`osc_to_ost $STRIPE_OSC`
4364 IDX=`do_facet $SINGLEMDS lctl get_param -n lov.*md*.target_obd |
4365 awk -F: /$OST/'{ print $1 }' | head -n 1`
4367 [ -f $DIR/$tdir/$IDX ] && continue
4368 echo "$SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX"
4369 do_facet client $SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX
4371 [ $RC -ne 0 ] && error "setstripe should have succeeded"
4373 do_facet client rm -f $DIR/$tdir/*
4374 echo $INACTIVE_OSC "is Activate."
4375 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
4378 run_test 65k "validate manual striping works properly with deactivated OSCs"
4380 test_65l() { # bug 12836
4381 mkdir -p $DIR/$tdir/test_dir
4382 $SETSTRIPE -c -1 $DIR/$tdir/test_dir
4383 $LFS find -mtime -1 $DIR/$tdir >/dev/null
4385 run_test 65l "lfs find on -1 stripe dir ========================"
4387 # bug 2543 - update blocks count on client
4390 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
4391 sync; sync_all_data; sync; sync_all_data
4392 cancel_lru_locks osc
4393 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
4394 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
4396 run_test 66 "update inode blocks count on client ==============="
4402 if [ ! -z "$LLOOP" ]; then
4403 if swapon -s | grep -q $LLOOP; then
4404 swapoff $LLOOP || error "swapoff failed"
4407 $LCTL blockdev_detach $LLOOP || error "detach failed"
4411 if [ ! -z "$LLITELOOPLOAD" ]; then
4419 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
4423 swapon -s | awk '($1 == "'$1'") { print $4 }'
4426 # test case for lloop driver, basic function
4428 [ "$UID" != 0 ] && skip_env "must run as root" && return
4429 llite_lloop_enabled || \
4430 { skip_env "llite_lloop module disabled" && return; }
4432 trap cleanup_68 EXIT
4434 if ! module_loaded llite_lloop; then
4435 if load_module llite/llite_lloop; then
4438 skip_env "can't find module llite_lloop"
4443 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
4444 dd if=/dev/zero of=$DIR/f68a bs=4k count=1024
4445 $LCTL blockdev_attach $DIR/f68a $LLOOP || error "attach failed"
4447 directio rdwr $LLOOP 0 1024 4096 || error "direct write failed"
4448 directio rdwr $LLOOP 0 1025 4096 && error "direct write should fail"
4452 run_test 68a "lloop driver - basic test ========================"
4454 # excercise swapping to lustre by adding a high priority swapfile entry
4455 # and then consuming memory until it is used.
4456 test_68b() { # was test_68
4457 [ "$UID" != 0 ] && skip_env "must run as root" && return
4458 lctl get_param -n devices | grep -q obdfilter && \
4459 skip "local OST" && return
4461 grep -q llite_lloop /proc/modules
4462 [ $? -ne 0 ] && skip "can't find module llite_lloop" && return
4464 [ -z "`$LCTL list_nids | grep -v tcp`" ] && \
4465 skip "can't reliably test swap with TCP" && return
4467 MEMTOTAL=`meminfo MemTotal`
4468 NR_BLOCKS=$((MEMTOTAL>>8))
4469 [[ $NR_BLOCKS -le 2048 ]] && NR_BLOCKS=2048
4471 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
4472 dd if=/dev/zero of=$DIR/f68b bs=64k seek=$NR_BLOCKS count=1
4475 $LCTL blockdev_attach $DIR/f68b $LLOOP || error "attach failed"
4477 trap cleanup_68 EXIT
4479 swapon -p 32767 $LLOOP || error "swapon $LLOOP failed"
4481 echo "before: `swapon -s | grep $LLOOP`"
4482 $MEMHOG $MEMTOTAL || error "error allocating $MEMTOTAL kB"
4483 echo "after: `swapon -s | grep $LLOOP`"
4484 SWAPUSED=`swap_used $LLOOP`
4488 [ $SWAPUSED -eq 0 ] && echo "no swap used???" || true
4490 run_test 68b "support swapping to Lustre ========================"
4492 # bug5265, obdfilter oa2dentry return -ENOENT
4493 # #define OBD_FAIL_OST_ENOENT 0x217
4495 remote_ost_nodsh && skip "remote OST with nodsh" && return
4498 $SETSTRIPE -c 1 -i 0 $f
4500 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
4502 do_facet ost1 lctl set_param fail_loc=0x217
4503 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
4504 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
4506 do_facet ost1 lctl set_param fail_loc=0
4507 $DIRECTIO write $f 0 2 || error "write error"
4509 cancel_lru_locks osc
4510 $DIRECTIO read $f 0 1 || error "read error"
4512 do_facet ost1 lctl set_param fail_loc=0x217
4513 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
4515 do_facet ost1 lctl set_param fail_loc=0
4518 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
4522 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
4524 run_test 71 "Running dbench on lustre (don't segment fault) ===="
4526 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
4527 check_kernel_version 43 || return 0
4528 [ "$RUNAS_ID" = "$UID" ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4530 # Check that testing environment is properly set up. Skip if not
4531 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS || {
4532 skip_env "User $RUNAS_ID does not exist - skipping"
4535 # We had better clear the $DIR to get enough space for dd
4540 $RUNAS dd if=/dev/zero of=$DIR/f72 bs=512 count=1 || error
4541 # See if we are still setuid/sgid
4542 test -u $DIR/f72 -o -g $DIR/f72 && error "S/gid is not dropped on write"
4543 # Now test that MDS is updated too
4544 cancel_lru_locks mdc
4545 test -u $DIR/f72 -o -g $DIR/f72 && error "S/gid is not dropped on MDS"
4549 run_test 72a "Test that remove suid works properly (bug5695) ===="
4551 test_72b() { # bug 24226 -- keep mode setting when size is not changing
4554 [ "$RUNAS_ID" = "$UID" ] && \
4555 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4556 [ "$RUNAS_ID" -eq 0 ] && \
4557 skip_env "RUNAS_ID = 0 -- skipping" && return
4559 # Check that testing environment is properly set up. Skip if not
4560 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS || {
4561 skip_env "User $RUNAS_ID does not exist - skipping"
4564 touch $DIR/${tfile}-f{g,u}
4565 mkdir $DIR/${tfile}-d{g,u}
4566 chmod 770 $DIR/${tfile}-{f,d}{g,u}
4567 chmod g+s $DIR/${tfile}-{f,d}g
4568 chmod u+s $DIR/${tfile}-{f,d}u
4569 for perm in 777 2777 4777; do
4570 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
4571 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
4572 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
4573 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
4577 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
4579 # bug 3462 - multiple simultaneous MDC requests
4583 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
4586 lctl set_param fail_loc=0x80000129
4587 $MULTIOP $DIR/d73-1/f73-2 Oc &
4589 lctl set_param fail_loc=0
4591 $MULTIOP $DIR/d73-2/f73-3 Oc &
4595 wait $pid1 || return 1
4599 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
4600 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
4601 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
4605 run_test 73 "multiple MDC requests (should not deadlock)"
4607 test_74a() { # bug 6149, 6184
4608 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
4610 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
4611 # will spin in a tight reconnection loop
4613 lctl set_param fail_loc=0x8000030e
4614 # get any lock that won't be difficult - lookup works.
4616 lctl set_param fail_loc=0
4620 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
4622 test_74b() { # bug 13310
4623 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
4625 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
4626 # will spin in a tight reconnection loop
4627 lctl set_param fail_loc=0x8000030e
4628 # get a "difficult" lock
4630 lctl set_param fail_loc=0
4634 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
4637 #define OBD_FAIL_LDLM_NEW_LOCK
4638 lctl set_param fail_loc=0x80000319
4639 touch $DIR/$tfile && error "Touch successful"
4642 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
4645 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
4648 get_inode_slab_tunables() {
4649 awk '/lustre_inode_cache/ {print $9," ",$10," ",$11; exit}' /proc/slabinfo
4652 set_inode_slab_tunables() {
4653 echo "lustre_inode_cache $1" > /proc/slabinfo
4656 test_76() { # Now for bug 20433, added originally in bug 1443
4657 local SLAB_SETTINGS=`get_inode_slab_tunables`
4658 local CPUS=`getconf _NPROCESSORS_ONLN`
4659 # we cannot set limit below 1 which means 1 inode in each
4660 # per-cpu cache is still allowed
4661 set_inode_slab_tunables "1 1 0"
4662 cancel_lru_locks osc
4663 BEFORE_INODES=`num_inodes`
4664 echo "before inodes: $BEFORE_INODES"
4666 [ "$SLOW" = "no" ] && COUNT=100
4667 for i in `seq $COUNT`; do
4671 cancel_lru_locks osc
4672 AFTER_INODES=`num_inodes`
4673 echo "after inodes: $AFTER_INODES"
4675 while [ $((AFTER_INODES-1*CPUS)) -gt $BEFORE_INODES ]; do
4677 AFTER_INODES=`num_inodes`
4679 echo "wait $wait seconds inodes: $AFTER_INODES"
4680 if [ $wait -gt 30 ]; then
4681 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
4684 set_inode_slab_tunables "$SLAB_SETTINGS"
4686 run_test 76 "confirm clients recycle inodes properly ===="
4692 # Note: in sptlrpc modes which enable its own bulk checksum, the
4693 # original crc32_le bulk checksum will be automatically disabled,
4694 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
4695 # will be checked by sptlrpc code against sptlrpc bulk checksum.
4696 # In this case set_checksums() will not be no-op, because sptlrpc
4697 # bulk checksum will be enabled all through the test.
4699 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
4700 lctl set_param -n osc.*.checksums $1
4704 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
4705 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
4706 CKSUM_TYPES=${CKSUM_TYPES:-"crc32 adler"}
4707 [ "$ORIG_CSUM_TYPE" = "crc32c" ] && CKSUM_TYPES="$CKSUM_TYPES crc32c"
4710 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
4711 log "set checksum type to $1"
4714 F77_TMP=$TMP/f77-temp
4717 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
4718 error "error writing to $F77_TMP"
4721 test_77a() { # bug 10889
4722 $GSS && skip "could not run with gss" && return
4723 [ ! -f $F77_TMP ] && setup_f77
4725 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
4729 run_test 77a "normal checksum read/write operation ============="
4731 test_77b() { # bug 10889
4732 $GSS && skip "could not run with gss" && return
4733 [ ! -f $F77_TMP ] && setup_f77
4734 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
4735 lctl set_param fail_loc=0x80000409
4737 dd if=$F77_TMP of=$DIR/f77b bs=1M count=$F77SZ conv=sync || \
4738 error "dd error: $?"
4739 lctl set_param fail_loc=0
4742 run_test 77b "checksum error on client write ===================="
4744 test_77c() { # bug 10889
4745 $GSS && skip "could not run with gss" && return
4746 [ ! -f $DIR/f77b ] && skip "requires 77b - skipping" && return
4748 for algo in $CKSUM_TYPES; do
4749 cancel_lru_locks osc
4750 set_checksum_type $algo
4751 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
4752 lctl set_param fail_loc=0x80000408
4753 cmp $F77_TMP $DIR/f77b || error "file compare failed"
4754 lctl set_param fail_loc=0
4757 set_checksum_type $ORIG_CSUM_TYPE
4760 run_test 77c "checksum error on client read ==================="
4762 test_77d() { # bug 10889
4763 $GSS && skip "could not run with gss" && return
4764 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
4765 lctl set_param fail_loc=0x80000409
4767 directio write $DIR/f77 0 $F77SZ $((1024 * 1024)) || \
4768 error "direct write: rc=$?"
4769 lctl set_param fail_loc=0
4772 run_test 77d "checksum error on OST direct write ==============="
4774 test_77e() { # bug 10889
4775 $GSS && skip "could not run with gss" && return
4776 [ ! -f $DIR/f77 ] && skip "requires 77d - skipping" && return
4777 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
4778 lctl set_param fail_loc=0x80000408
4780 cancel_lru_locks osc
4781 directio read $DIR/f77 0 $F77SZ $((1024 * 1024)) || \
4782 error "direct read: rc=$?"
4783 lctl set_param fail_loc=0
4786 run_test 77e "checksum error on OST direct read ================"
4788 test_77f() { # bug 10889
4789 $GSS && skip "could not run with gss" && return
4791 for algo in $CKSUM_TYPES; do
4792 cancel_lru_locks osc
4793 set_checksum_type $algo
4794 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
4795 lctl set_param fail_loc=0x409
4796 directio write $DIR/f77 0 $F77SZ $((1024 * 1024)) && \
4797 error "direct write succeeded"
4798 lctl set_param fail_loc=0
4800 set_checksum_type $ORIG_CSUM_TYPE
4803 run_test 77f "repeat checksum error on write (expect error) ===="
4805 test_77g() { # bug 10889
4806 $GSS && skip "could not run with gss" && return
4807 remote_ost_nodsh && skip "remote OST with nodsh" && return
4809 [ ! -f $F77_TMP ] && setup_f77
4811 $SETSTRIPE -c 1 -i 0 $DIR/f77g
4812 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
4813 do_facet ost1 lctl set_param fail_loc=0x8000021a
4815 dd if=$F77_TMP of=$DIR/f77g bs=1M count=$F77SZ || \
4816 error "write error: rc=$?"
4817 do_facet ost1 lctl set_param fail_loc=0
4820 run_test 77g "checksum error on OST write ======================"
4822 test_77h() { # bug 10889
4823 $GSS && skip "could not run with gss" && return
4824 remote_ost_nodsh && skip "remote OST with nodsh" && return
4826 [ ! -f $DIR/f77g ] && skip "requires 77g - skipping" && return
4827 cancel_lru_locks osc
4828 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
4829 do_facet ost1 lctl set_param fail_loc=0x8000021b
4831 cmp $F77_TMP $DIR/f77g || error "file compare failed"
4832 do_facet ost1 lctl set_param fail_loc=0
4835 run_test 77h "checksum error on OST read ======================="
4837 test_77i() { # bug 13805
4838 $GSS && skip "could not run with gss" && return
4839 #define OBD_FAIL_OSC_CONNECT_CKSUM 0x40b
4840 lctl set_param fail_loc=0x40b
4841 remount_client $MOUNT
4842 lctl set_param fail_loc=0
4843 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
4844 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
4845 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
4846 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
4848 remount_client $MOUNT
4850 run_test 77i "client not supporting OSD_CONNECT_CKSUM =========="
4852 test_77j() { # bug 13805
4853 $GSS && skip "could not run with gss" && return
4854 #define OBD_FAIL_OSC_CKSUM_ADLER_ONLY 0x40c
4855 lctl set_param fail_loc=0x40c
4856 remount_client $MOUNT
4857 lctl set_param fail_loc=0
4858 sleep 2 # wait async osc connect to finish
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 77j "client only supporting ADLER32 ===================="
4868 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
4872 test_78() { # bug 10901
4873 remote_ost || { skip_env "local OST" && return; }
4876 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
4877 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
4878 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
4879 echo "MemTotal: $MEMTOTAL"
4880 # reserve 256MB of memory for the kernel and other running processes,
4881 # and then take 1/2 of the remaining memory for the read/write buffers.
4882 if [ $MEMTOTAL -gt 512 ] ;then
4883 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
4885 # for those poor memory-starved high-end clusters...
4886 MEMTOTAL=$((MEMTOTAL / 2))
4888 echo "Mem to use for directio: $MEMTOTAL"
4889 [ $F78SIZE -gt $MEMTOTAL ] && F78SIZE=$MEMTOTAL
4890 [ $F78SIZE -gt 512 ] && F78SIZE=512
4891 [ $F78SIZE -gt $((MAXFREE / 1024)) ] && F78SIZE=$((MAXFREE / 1024))
4892 SMALLESTOST=`lfs df $DIR |grep OST | awk '{print $4}' |sort -n |head -1`
4893 echo "Smallest OST: $SMALLESTOST"
4894 [ $SMALLESTOST -lt 10240 ] && \
4895 skip "too small OSTSIZE, useless to run large O_DIRECT test" && return 0
4897 [ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ] && \
4898 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
4900 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
4901 echo "File size: $F78SIZE"
4902 $SETSTRIPE -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
4903 for i in `seq 1 $NSEQ`
4905 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
4906 echo directIO rdwr round $i of $NSEQ
4907 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
4912 run_test 78 "handle large O_DIRECT writes correctly ============"
4914 test_79() { # bug 12743
4915 wait_delete_completed
4917 BKTOTAL=$(calc_osc_kbytes kbytestotal)
4918 BKFREE=$(calc_osc_kbytes kbytesfree)
4919 BKAVAIL=$(calc_osc_kbytes kbytesavail)
4921 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
4922 DFTOTAL=`echo $STRING | cut -d, -f1`
4923 DFUSED=`echo $STRING | cut -d, -f2`
4924 DFAVAIL=`echo $STRING | cut -d, -f3`
4925 DFFREE=$(($DFTOTAL - $DFUSED))
4927 ALLOWANCE=$((64 * $OSTCOUNT))
4929 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
4930 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
4931 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
4933 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
4934 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
4935 error "df free($DFFREE) mismatch OST free($BKFREE)"
4937 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
4938 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
4939 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
4942 run_test 79 "df report consistency check ======================="
4944 test_80() { # bug 10718
4945 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
4947 local BEFORE=`date +%s`
4948 cancel_lru_locks osc
4949 local AFTER=`date +%s`
4950 local DIFF=$((AFTER-BEFORE))
4951 if [ $DIFF -gt 1 ] ; then
4952 error "elapsed for 1M@1T = $DIFF"
4957 run_test 80 "Page eviction is equally fast at high offsets too ===="
4959 test_81a() { # LU-456
4960 remote_ost_nodsh && skip "remote OST with nodsh" && return
4961 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
4962 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
4963 do_facet ost0 lctl set_param fail_loc=0x80000228
4965 # write should trigger a retry and success
4966 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
4967 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
4969 if [ $RC -ne 0 ] ; then
4970 error "write should success, but failed for $RC"
4973 run_test 81a "OST should retry write when get -ENOSPC ==============="
4975 test_81b() { # LU-456
4976 remote_ost_nodsh && skip "remote OST with nodsh" && return
4977 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
4978 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
4979 do_facet ost0 lctl set_param fail_loc=0x228
4981 # write should retry several times and return -ENOSPC finally
4982 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
4983 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
4986 if [ $RC -ne $ENOSPC ] ; then
4987 error "dd should fail for -ENOSPC, but succeed."
4990 run_test 81b "OST should return -ENOSPC when retry still fails ======="
4992 test_82() { # LU-1031
4993 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10
4997 multiop_bg_pause $DIR/$tfile OG${gid1}_g${gid1}c || return 1
4999 multiop_bg_pause $DIR/$tfile O_G${gid2}r10g${gid2}c || return 2
5001 kill -USR1 $MULTIPID2
5003 if [[ `ps h -o comm -p $MULTIPID2` == "" ]]; then
5004 error "First grouplock does not block second one"
5006 echo "Second grouplock blocks first one"
5008 kill -USR1 $MULTIPID1
5012 run_test 82 "Basic grouplock test ==============================="
5015 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && \
5017 mkdir -p $DIR/d99cvsroot
5018 chown $RUNAS_ID $DIR/d99cvsroot
5019 local oldPWD=$PWD # bug 13584, use $TMP as working dir
5022 $RUNAS cvs -d $DIR/d99cvsroot init || error
5025 run_test 99a "cvs init ========================================="
5028 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5029 [ ! -d $DIR/d99cvsroot ] && test_99a
5031 # some versions of cvs import exit(1) when asked to import links or
5032 # files they can't read. ignore those files.
5033 TOIGNORE=$(find . -type l -printf '-I %f\n' -o \
5034 ! -perm +4 -printf '-I %f\n')
5035 $RUNAS cvs -d $DIR/d99cvsroot import -m "nomesg" $TOIGNORE \
5036 d99reposname vtag rtag
5038 run_test 99b "cvs import ======================================="
5041 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5042 [ ! -d $DIR/d99cvsroot ] && test_99b
5044 mkdir -p $DIR/d99reposname
5045 chown $RUNAS_ID $DIR/d99reposname
5046 $RUNAS cvs -d $DIR/d99cvsroot co d99reposname
5048 run_test 99c "cvs checkout ====================================="
5051 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5052 [ ! -d $DIR/d99cvsroot ] && test_99c
5053 cd $DIR/d99reposname
5055 $RUNAS cvs add -m 'addmsg' foo99
5057 run_test 99d "cvs add =========================================="
5060 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5061 [ ! -d $DIR/d99cvsroot ] && test_99c
5062 cd $DIR/d99reposname
5065 run_test 99e "cvs update ======================================="
5068 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5069 [ ! -d $DIR/d99cvsroot ] && test_99d
5070 cd $DIR/d99reposname
5071 $RUNAS cvs commit -m 'nomsg' foo99
5072 rm -fr $DIR/d99cvsroot
5074 run_test 99f "cvs commit ======================================="
5077 [ "$NETTYPE" = tcp ] || \
5078 { skip "TCP secure port test, not useful for NETTYPE=$NETTYPE" && \
5081 remote_ost_nodsh && skip "remote OST with nodsh" && return
5082 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5084 { skip "useless for local single node setup" && return; }
5086 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
5087 [ "$PROT" != "tcp" ] && continue
5088 RPORT=$(echo $REMOTE | cut -d: -f2)
5089 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
5092 LPORT=`echo $LOCAL | cut -d: -f2`
5093 if [ $LPORT -ge 1024 ]; then
5094 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
5096 error_exit "local: $LPORT > 1024, remote: $RPORT"
5099 [ "$rc" = 0 ] || error_exit "privileged port not found" )
5101 run_test 100 "check local port using privileged port ==========="
5103 function get_named_value()
5112 echo $line | sed "s/^$tag[ ]*//"
5119 export CACHE_MAX=`$LCTL get_param -n llite.*.max_cached_mb | head -n 1`
5121 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
5129 [ "$CPU" = "UML" ] && nreads=1000
5130 local cache_limit=32
5132 $LCTL set_param -n osc.*-osc*.rpc_stats 0
5133 trap cleanup_101a EXIT
5134 $LCTL set_param -n llite.*.read_ahead_stats 0
5135 $LCTL set_param -n llite.*.max_cached_mb $cache_limit
5138 # randomly read 10000 of 64K chunks from file 3x 32MB in size
5140 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
5141 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
5144 for s in `$LCTL get_param -n llite.*.read_ahead_stats | \
5145 get_named_value 'read but discarded' | cut -d" " -f1`; do
5146 discard=$(($discard + $s))
5150 if [ $(($discard * 10)) -gt $nreads ] ;then
5151 $LCTL get_param osc.*-osc*.rpc_stats
5152 $LCTL get_param llite.*.read_ahead_stats
5153 error "too many ($discard) discarded pages"
5155 rm -f $DIR/$tfile || true
5157 run_test 101a "check read-ahead for random reads ================"
5162 STRIPE_COUNT=$OSTCOUNT
5165 local list=$(comma_list $(osts_nodes))
5166 do_nodes $list $LCTL set_param -n obdfilter.*.read_cache_enable=0
5167 do_nodes $list $LCTL set_param -n obdfilter.*.writethrough_cache_enable=0
5169 trap cleanup_test101bc EXIT
5170 # prepare the read-ahead file
5171 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
5173 dd if=/dev/zero of=$DIR/$tfile bs=1024k count=100 2> /dev/null
5176 cleanup_test101bc() {
5181 local list=$(comma_list $(osts_nodes))
5182 do_nodes $list $LCTL set_param -n obdfilter.*.read_cache_enable=1
5183 do_nodes $list $LCTL set_param -n obdfilter.*.writethrough_cache_enable=1
5187 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
5192 local STRIPE_SIZE=1048576
5193 local RA_INC=1048576
5194 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
5195 local FILE_LENGTH=$((64*100))
5196 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
5197 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
5198 DISCARD=`$LCTL get_param -n llite.*.read_ahead_stats | \
5199 get_named_value 'read but discarded' | \
5200 cut -d" " -f1 | calc_total`
5201 if [ $DISCARD -gt $discard_limit ]; then
5202 $LCTL get_param llite.*.read_ahead_stats
5203 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
5205 echo "Read-ahead success for size ${READ_SIZE}"
5210 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping stride IO stride-ahead test" && return
5211 local STRIPE_SIZE=1048576
5212 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
5213 local FILE_LENGTH=$((STRIPE_SIZE*100))
5214 local ITERATION=$((FILE_LENGTH/STRIDE_SIZE))
5215 # prepare the read-ahead file
5217 cancel_lru_locks osc
5218 for BIDX in 2 4 8 16 32 64 128 256
5220 local BSIZE=$((BIDX*4096))
5221 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
5222 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
5223 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
5224 $LCTL set_param -n llite.*.read_ahead_stats 0
5225 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
5226 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
5227 cancel_lru_locks osc
5233 run_test 101b "check stride-io mode read-ahead ================="
5236 local STRIPE_SIZE=1048576
5237 local FILE_LENGTH=$((STRIPE_SIZE*100))
5243 cancel_lru_locks osc
5244 $LCTL set_param osc.*.rpc_stats 0
5245 $READS -f $DIR/$tfile -s$FILE_LENGTH -b65536 -n$nreads -t 180
5246 for osc in $($LCTL get_param -N osc.*); do
5247 if [ "$osc" == "osc.num_refs" ]; then
5251 local lines=$($LCTL get_param -n ${osc}.rpc_stats | wc | awk '{print $1}')
5252 if [ $lines -le 20 ]; then
5256 local rpc4k=$($LCTL get_param -n ${osc}.rpc_stats |
5257 awk '$1 == "1:" { print $2; exit; }')
5258 local rpc8k=$($LCTL get_param -n ${osc}.rpc_stats |
5259 awk '$1 == "2:" { print $2; exit; }')
5260 local rpc16k=$($LCTL get_param -n ${osc}.rpc_stats |
5261 awk '$1 == "4:" { print $2; exit; }')
5262 local rpc32k=$($LCTL get_param -n ${osc}.rpc_stats |
5263 awk '$1 == "8:" { print $2; exit; }')
5265 [ $rpc4k != 0 ] && error "Small 4k read IO ${rpc4k}!"
5266 [ $rpc8k != 0 ] && error "Small 8k read IO ${rpc8k}!"
5267 [ $rpc16k != 0 ] && error "Small 16k read IO ${rpc16k}!"
5268 [ $rpc32k != 0 ] && error "Small 32k read IO ${rpc32k}!"
5269 echo "${osc} rpc check passed!"
5274 run_test 101c "check stripe_size aligned read-ahead ================="
5277 $LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1
5278 $LCTL set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
5282 local file=$DIR/$tfile
5283 local size=${FILESIZE_101c:-500}
5284 local ra_MB=${READAHEAD_MB:-40}
5286 local space=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
5287 [ $space -gt $((size / 1024)) ] ||
5288 { skip "Need free space ${size}M, have $space" && return; }
5290 echo Creating ${size}M test file $file
5291 dd if=/dev/zero of=$file bs=1M count=$size
5292 echo Cancel LRU locks on lustre client to flush the client cache
5293 cancel_lru_locks osc
5295 echo Disable read-ahead
5296 local old_READAHEAD=$(set_read_ahead 0)
5298 echo Reading the test file $file with read-ahead disabled
5299 time_ra_OFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$size")
5301 echo Cancel LRU locks on lustre client to flush the client cache
5302 cancel_lru_locks osc
5303 echo Enable read-ahead with ${ra_MB}MB
5304 set_read_ahead $ra_MB
5306 echo Reading the test file $file with read-ahead enabled
5307 time_ra_ON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$size")
5309 echo read-ahead disabled time read $time_ra_OFF
5310 echo read-ahead enabled time read $time_ra_ON
5312 set_read_ahead $old_READAHEAD
5314 wait_delete_completed
5316 [ $time_ra_ON -lt $time_ra_OFF ] ||
5317 error "read-ahead enabled time read (${time_ra_ON}s) is more than
5318 read-ahead disabled time read (${time_ra_OFF}s) filesize ${size}M"
5320 run_test 101d "file read with and without read-ahead enabled ================="
5323 local file=$DIR/$tfile
5328 local space=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
5329 local need_space=$((count * size))
5330 [ $space -gt $need_space ] ||
5331 { skip_env "Need free space $need_space, have $space" && return; }
5333 echo Creating $count ${size}K test files
5334 for ((i = 0; i < $count; i++)); do
5335 dd if=/dev/zero of=${file}_${i} bs=$blksize count=$size 2>/dev/null
5338 echo Cancel LRU locks on lustre client to flush the client cache
5339 cancel_lru_locks osc
5341 echo Reset readahead stats
5342 $LCTL set_param -n llite.*.read_ahead_stats 0
5344 for ((i = 0; i < $count; i++)); do
5345 dd if=${file}_${i} of=/dev/null bs=$blksize count=$size 2>/dev/null
5348 local miss=$($LCTL get_param -n llite.*.read_ahead_stats | \
5349 get_named_value 'misses' | cut -d" " -f1 | calc_total)
5351 for ((i = 0; i < $count; i++)); do
5352 rm -rf ${file}_${i} 2>/dev/null
5355 #10000 means 20% reads are missing in readahead
5356 [ $miss -lt 10000 ] || error "misses too much for small reads"
5358 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
5360 cleanup_test101f() {
5362 $LCTL set_param -n llite.*.max_read_ahead_whole_mb $MAX_WHOLE_MB
5363 rm -rf $DIR/$tfile 2>/dev/null
5367 local file=$DIR/$tfile
5370 MAX_WHOLE_MB=$($LCTL get_param -n llite.*.max_read_ahead_whole_mb)
5371 $LCTL set_param -n llite.*.max_read_ahead_whole_mb 2
5372 dd if=/dev/zero of=${file} bs=2097152 count=1 2>/dev/null
5373 trap cleanup_test101f EXIT
5375 echo Cancel LRU locks on lustre client to flush the client cache
5376 cancel_lru_locks osc
5378 echo Reset readahead stats
5379 $LCTL set_param -n llite.*.read_ahead_stats 0
5380 # Random read in a 2M file, because max_read_ahead_whole_mb = 2M,
5381 # readahead should read in 2M file on second read, so only miss
5383 echo Random 4K reads on 2M file for 1000 times
5384 $READS -f $file -s 2097152 -b 4096 -n $nreads
5386 echo checking missing pages
5387 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
5388 get_named_value 'misses' | cut -d" " -f1 | calc_total)
5390 [ $miss -lt 3 ] || error "misses too much pages!"
5393 run_test 101f "check read-ahead for max_read_ahead_whole_mb"
5397 chown $RUNAS_ID $DIR/$tdir
5400 STRIPE_COUNT=$OSTCOUNT
5401 [ $OSTCOUNT -gt 4 ] && STRIPE_COUNT=4
5403 trap cleanup_test102 EXIT
5405 $1 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
5407 for num in 1 2 3 4; do
5408 for count in $(seq 1 $STRIPE_COUNT); do
5409 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
5410 local size=`expr $STRIPE_SIZE \* $num`
5411 local file=file"$num-$idx-$count"
5412 $1 $SETSTRIPE -S $size -i $idx -c $count $file
5418 $1 $TAR cf $TMP/f102.tar $tdir --xattrs
5424 rm -rf $DIR/d0.sanity/d102
5428 local testfile=$DIR/xattr_testfile
5432 [ "$UID" != 0 ] && skip_env "must run as root" && return
5433 [ -z "`lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr`" ] &&
5434 skip_env "must have user_xattr" && return
5436 [ -z "$(which setfattr 2>/dev/null)" ] &&
5437 skip_env "could not find setfattr" && return
5439 echo "set/get xattr..."
5440 setfattr -n trusted.name1 -v value1 $testfile || error
5441 getfattr -n trusted.name1 $testfile 2> /dev/null |
5442 grep "trusted.name1=.value1" ||
5443 error "$testfile missing trusted.name1=value1"
5445 setfattr -n user.author1 -v author1 $testfile || error
5446 getfattr -n user.author1 $testfile 2> /dev/null |
5447 grep "user.author1=.author1" ||
5448 error "$testfile missing trusted.author1=author1"
5451 setfattr -n trusted.name2 -v value2 $testfile ||
5452 error "$testfile unable to set trusted.name2"
5453 setfattr -n trusted.name3 -v value3 $testfile ||
5454 error "$testfile unable to set trusted.name3"
5455 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
5456 grep "trusted.name" | wc -l) -eq 3 ] ||
5457 error "$testfile missing 3 trusted.name xattrs"
5459 setfattr -n user.author2 -v author2 $testfile ||
5460 error "$testfile unable to set user.author2"
5461 setfattr -n user.author3 -v author3 $testfile ||
5462 error "$testfile unable to set user.author3"
5463 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
5464 grep "user.author" | wc -l) -eq 3 ] ||
5465 error "$testfile missing 3 user.author xattrs"
5467 echo "remove xattr..."
5468 setfattr -x trusted.name1 $testfile ||
5469 error "$testfile error deleting trusted.name1"
5470 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
5471 error "$testfile did not delete trusted.name1 xattr"
5473 setfattr -x user.author1 $testfile ||
5474 error "$testfile error deleting user.author1"
5475 getfattr -d -m user $testfile 2> /dev/null | grep "user.author1" &&
5476 error "$testfile did not delete trusted.name1 xattr"
5478 # b10667: setting lustre special xattr be silently discarded
5479 echo "set lustre special xattr ..."
5480 setfattr -n "trusted.lov" -v "invalid value" $testfile ||
5481 error "$testfile allowed setting trusted.lov"
5483 run_test 102a "user xattr test =================================="
5486 # b10930: get/set/list trusted.lov xattr
5487 echo "get/set/list trusted.lov xattr ..."
5488 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
5489 local testfile=$DIR/$tfile
5490 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
5491 error "setstripe failed"
5492 local STRIPECOUNT=$($GETSTRIPE -c $testfile) ||
5493 error "getstripe failed"
5494 getfattr -d -m "^trusted" $testfile 2> /dev/null | \
5495 grep "trusted.lov" || error "can't get trusted.lov from $testfile"
5497 local testfile2=${testfile}2
5498 local value=`getfattr -n trusted.lov $testfile 2> /dev/null | \
5499 grep "trusted.lov" |sed -e 's/[^=]\+=//'`
5502 setfattr -n trusted.lov -v $value $testfile2
5503 local stripe_size=$($GETSTRIPE -S $testfile2)
5504 local stripe_count=$($GETSTRIPE -c $testfile2)
5505 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
5506 [ $stripe_count -eq $STRIPECOUNT ] ||
5507 error "stripe count $stripe_count != $STRIPECOUNT"
5510 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
5513 # b10930: get/set/list lustre.lov xattr
5514 echo "get/set/list lustre.lov xattr ..."
5515 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
5517 chown $RUNAS_ID $DIR/$tdir
5518 local testfile=$DIR/$tdir/$tfile
5519 $RUNAS $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
5520 error "setstripe failed"
5521 local STRIPECOUNT=$($RUNAS $GETSTRIPE -c $testfile) ||
5522 error "getstripe failed"
5523 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
5524 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
5526 local testfile2=${testfile}2
5527 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
5528 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
5530 $RUNAS $MCREATE $testfile2
5531 $RUNAS setfattr -n lustre.lov -v $value $testfile2
5532 local stripe_size=$($RUNAS $GETSTRIPE -S $testfile2)
5533 local stripe_count=$($RUNAS $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"
5538 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
5540 compare_stripe_info1() {
5541 local stripe_index_all_zero=true
5543 for num in 1 2 3 4; do
5544 for count in $(seq 1 $STRIPE_COUNT); do
5545 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
5546 local size=$((STRIPE_SIZE * num))
5547 local file=file"$num-$offset-$count"
5548 stripe_size=$(lfs getstripe -S $PWD/$file)
5549 [ $stripe_size -ne $size ] &&
5550 error "$file: size $stripe_size != $size"
5551 stripe_count=$(lfs getstripe -c $PWD/$file)
5552 # allow fewer stripes to be created, ORI-601
5553 [ $stripe_count -lt $(((3 * count + 3) / 4)) ]&&
5554 error "$file: count $stripe_count != $count"
5555 stripe_index=$(lfs getstripe -i $PWD/$file)
5556 [ $stripe_index -ne 0 ] &&
5557 stripe_index_all_zero=false
5561 $stripe_index_all_zero &&
5562 error "all files are being extracted starting from OST index 0"
5567 [ -n "$(which tar 2>/dev/null)" ] &&
5568 strings $(which tar) | grep -q "lustre" && echo tar
5572 # b10930: tar test for trusted.lov xattr
5573 TAR=$(find_lustre_tar)
5574 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
5575 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
5578 $TAR xf $TMP/f102.tar -C $DIR/d102d --xattrs
5580 compare_stripe_info1
5582 run_test 102d "tar restore stripe info from tarfile,not keep osts ==========="
5585 # b10930: tar test for trusted.lov xattr
5586 TAR=$(find_lustre_tar)
5587 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
5588 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
5592 $TAR cf - --xattrs $tdir | $TAR xf - --xattrs -C $DIR/d102f
5594 compare_stripe_info1
5596 run_test 102f "tar copy files, not keep osts ==========="
5599 local xsize=${1:-1024} # in bytes
5600 local file=$DIR/$tfile
5602 [ -z $(lctl get_param -n mdc.*.connect_flags | grep xattr) ] &&
5603 skip "must have user_xattr" && return 0
5604 [ -z "$(which setfattr 2>/dev/null)" ] &&
5605 skip_env "could not find setfattr" && return 0
5606 [ -z "$(which getfattr 2>/dev/null)" ] &&
5607 skip_env "could not find getfattr" && return 0
5611 local value="$(generate_string $xsize)"
5613 local xbig=trusted.big
5614 log "save $xbig on $file"
5615 setfattr -n $xbig -v $value $file ||
5616 error "saving $xbig on $file failed"
5618 local orig=$(get_xattr_value $xbig $file)
5619 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
5621 local xsml=trusted.sml
5622 log "save $xsml on $file"
5623 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
5625 local new=$(get_xattr_value $xbig $file)
5626 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
5628 log "grow $xsml on $file"
5629 setfattr -n $xsml -v "$value" $file ||
5630 error "growing $xsml on $file failed"
5632 new=$(get_xattr_value $xbig $file)
5633 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
5634 log "$xbig still valid after growing $xsml"
5639 test_102h() { # bug 15777
5642 run_test 102h "grow xattr from inside inode to external block"
5645 large_xattr_enabled || { skip "large_xattr disabled" && return; }
5646 grow_xattr $(max_xattr_size)
5648 run_test 102ha "grow xattr from inside inode to external inode"
5650 test_102i() { # bug 17038
5652 ln -s $DIR/$tfile $DIR/${tfile}link
5653 getfattr -n trusted.lov $DIR/$tfile || error "lgetxattr on $DIR/$tfile failed"
5654 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"
5655 rm -f $DIR/$tfile $DIR/${tfile}link
5657 run_test 102i "lgetxattr test on symbolic link ============"
5660 TAR=$(find_lustre_tar)
5661 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
5662 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
5663 setup_test102 "$RUNAS"
5665 chown $RUNAS_ID $DIR/d102j
5666 $RUNAS $TAR xf $TMP/f102.tar -C $DIR/d102j --xattrs
5668 compare_stripe_info1 "$RUNAS"
5670 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
5674 # b22187 just check that does not crash for regular file.
5675 setfattr -n trusted.lov $DIR/$tfile
5676 # b22187 'setfattr -n trusted.lov' should work as remove LOV EA for directories
5677 local test_kdir=$DIR/d102k
5679 local default_size=`$GETSTRIPE -S $test_kdir`
5680 local default_count=`$GETSTRIPE -c $test_kdir`
5681 local default_offset=`$GETSTRIPE -i $test_kdir`
5682 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $test_kdir ||
5683 error 'dir setstripe failed'
5684 setfattr -n trusted.lov $test_kdir
5685 local stripe_size=`$GETSTRIPE -S $test_kdir`
5686 local stripe_count=`$GETSTRIPE -c $test_kdir`
5687 local stripe_offset=`$GETSTRIPE -i $test_kdir`
5688 [ $stripe_size -eq $default_size ] ||
5689 error "stripe size $stripe_size != $default_size"
5690 [ $stripe_count -eq $default_count ] ||
5691 error "stripe count $stripe_count != $default_count"
5692 [ $stripe_offset -eq $default_offset ] ||
5693 error "stripe offset $stripe_offset != $default_offset"
5694 rm -rf $DIR/$tfile $test_kdir
5696 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
5699 # LU-532 trusted. xattr is invisible to non-root
5700 local testfile=$DIR/$tfile
5704 echo "listxattr as user..."
5705 chown $RUNAS_ID $testfile
5706 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
5707 grep -q "trusted" &&
5708 error "$testfile trusted xattrs are user visible"
5712 run_test 102l "listxattr filter test =================================="
5718 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
5723 [ "$UID" != 0 ] && skip_env "must run as root" && return
5724 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
5725 [ -z "$(which setfacl 2>/dev/null)" ] && skip_env "could not find setfacl" && return
5726 $GSS && skip "could not run under gss" && return
5728 declare -a identity_old
5730 for num in `seq $MDSCOUNT`; do
5731 switch_identity $num true || identity_old[$num]=$?
5738 echo "performing cp ..."
5739 run_acl_subtest cp || error
5740 echo "performing getfacl-noacl..."
5741 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
5742 echo "performing misc..."
5743 run_acl_subtest misc || error "misc test failed"
5744 echo "performing permissions..."
5745 run_acl_subtest permissions || error "permissions failed"
5746 echo "performing setfacl..."
5747 run_acl_subtest setfacl || error "setfacl test failed"
5749 # inheritance test got from HP
5750 echo "performing inheritance..."
5751 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
5752 chmod +x make-tree || error "chmod +x failed"
5753 run_acl_subtest inheritance || error "inheritance test failed"
5759 for num in `seq $MDSCOUNT`; do
5760 if [ "${identity_old[$num]}" = 1 ]; then
5761 switch_identity $num false || identity_old[$num]=$?
5765 run_test 103 "acl test ========================================="
5769 lfs df || error "lfs df failed"
5770 lfs df -ih || error "lfs df -ih failed"
5771 lfs df -h $DIR || error "lfs df -h $DIR failed"
5772 lfs df -i $DIR || error "lfs df -i $DIR failed"
5773 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
5774 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
5776 OSC=`lctl dl |grep OST0000-osc-[^M] |awk '{print $4}'`
5777 lctl --device %$OSC deactivate
5778 lfs df || error "lfs df with deactivated OSC failed"
5779 lctl --device %$OSC activate
5780 # wait the osc back to normal
5781 wait_osc_import_state client ost FULL
5783 lfs df || error "lfs df with reactivated OSC failed"
5786 run_test 104a "lfs df [-ih] [path] test ========================="
5789 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5791 denied_cnt=$((`$RUNAS $LFS check servers 2>&1 | grep "Permission denied" | wc -l`))
5792 if [ $denied_cnt -ne 0 ];
5794 error "lfs check servers test failed"
5797 run_test 104b "$RUNAS lfs check servers test ===================="
5800 # doesn't work on 2.4 kernels
5802 if [ -n "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ];
5804 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
5806 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
5810 run_test 105a "flock when mounted without -o flock test ========"
5814 if [ -n "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ];
5816 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
5818 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
5822 run_test 105b "fcntl when mounted without -o flock test ========"
5826 if [ -n "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ];
5828 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
5830 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
5834 run_test 105c "lockf when mounted without -o flock test ========"
5836 test_105d() { # bug 15924
5838 [ -z "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ] && \
5839 skip "mount w/o flock enabled" && return
5840 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
5841 $LCTL set_param fail_loc=0x80000315
5842 flocks_test 2 $DIR/$tdir
5844 run_test 105d "flock race (should not freeze) ========"
5846 test_105e() { # bug 22660 && 22040
5847 [ -z "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ] && \
5848 skip "mount w/o flock enabled" && return
5850 flocks_test 3 $DIR/$tfile
5852 run_test 105e "Two conflicting flocks from same process ======="
5854 test_106() { #bug 10921
5856 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
5857 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
5859 run_test 106 "attempt exec of dir followed by chown of that dir"
5868 local save_pattern=$(sysctl -n kernel.core_pattern)
5869 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
5870 sysctl -w kernel.core_pattern=$file
5871 sysctl -w kernel.core_uses_pid=0
5879 kill -s 11 $SLEEPPID
5881 if [ -e $file ]; then
5882 size=`stat -c%s $file`
5883 [ $size -eq 0 ] && error "Fail to create core file $file"
5885 error "Fail to create core file $file"
5888 sysctl -w kernel.core_pattern=$save_pattern
5889 sysctl -w kernel.core_uses_pid=$save_uses_pid
5892 run_test 107 "Coredump on SIG"
5896 mkdir $DIR/d110/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa || error "mkdir with 255 char fail"
5897 mkdir $DIR/d110/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb && error "mkdir with 256 char should fail, but not"
5898 touch $DIR/d110/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx || error "create with 255 char fail"
5899 touch $DIR/d110/yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy && error ""create with 256 char should fail, but not
5904 run_test 110 "filename length checking"
5907 OSTIO_pre=$(ps -e|grep ll_ost_io|awk '{print $4}'|sort -n|tail -1|\
5909 [ -z "$OSTIO_pre" ] && skip "no OSS threads" && \
5911 echo "Starting with $OSTIO_pre threads"
5914 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
5915 [ $NUMFREE -lt $NUMTEST ] && NUMTEST=$(($NUMFREE - 1000))
5916 echo "$NUMTEST creates/unlinks"
5918 createmany -o $DIR/$tdir/$tfile $NUMTEST
5919 unlinkmany $DIR/$tdir/$tfile $NUMTEST
5921 OSTIO_post=$(ps -e|grep ll_ost_io|awk '{print $4}'|sort -n|tail -1|\
5924 # don't return an error
5925 [ $OSTIO_post == $OSTIO_pre ] && echo \
5926 "WARNING: No new ll_ost_io threads were created ($OSTIO_pre)" &&
5927 echo "This may be fine, depending on what ran before this test" &&
5928 echo "and how fast this system is." && return
5930 echo "Started with $OSTIO_pre threads, ended with $OSTIO_post"
5932 run_test 115 "verify dynamic thread creation===================="
5935 wait_delete_completed
5936 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
5937 echo OST kbytes available: ${AVAIL[@]}
5938 MAXI=0; MAXV=${AVAIL[0]}
5939 MINI=0; MINV=${AVAIL[0]}
5940 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
5941 #echo OST $i: ${AVAIL[i]}kb
5942 if [ ${AVAIL[i]} -gt $MAXV ]; then
5943 MAXV=${AVAIL[i]}; MAXI=$i
5945 if [ ${AVAIL[i]} -lt $MINV ]; then
5946 MINV=${AVAIL[i]}; MINI=$i
5949 echo Min free space: OST $MINI: $MINV
5950 echo Max free space: OST $MAXI: $MAXV
5954 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs" && return
5956 echo -n "Free space priority "
5957 lctl get_param -n lov.*-clilov-*.qos_prio_free
5960 [ $MINV -gt 960000 ] && skip "too much free space in OST$MINI, skip" &&\
5963 # generate uneven OSTs
5964 mkdir -p $DIR/$tdir/OST${MINI}
5967 echo "Filling 25% remaining space in OST${MINI} with ${FILL}Kb"
5968 $SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI}||error "setstripe failed"
5970 while [ $FILL -gt 0 ]; do
5972 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i bs=2M count=1 2>/dev/null
5973 FILL=$(($FILL - 2048))
5981 DIFF=$(($MAXV - $MINV))
5982 DIFF2=$(($DIFF * 100 / $MINV))
5983 echo -n "diff=${DIFF}=${DIFF2}% must be > 20% for QOS mode..."
5984 if [ $DIFF2 -gt 20 ]; then
5987 echo "failed - QOS mode won't be used"
5988 error_ignore "QOS imbalance criteria not met"
5992 MINI1=$MINI; MINV1=$MINV
5993 MAXI1=$MAXI; MAXV1=$MAXV
5995 # now fill using QOS
5996 echo writing a bunch of files to QOS-assigned OSTs
5997 $SETSTRIPE -c 1 $DIR/$tdir
5999 while [ $FILL -gt 0 ]; do
6001 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1024 count=200 2>/dev/null
6002 FILL=$(($FILL - 200))
6005 echo "wrote $i 200k files"
6009 echo "Note: free space may not be updated, so measurements might be off"
6011 DIFF2=$(($MAXV - $MINV))
6012 echo "free space delta: orig $DIFF final $DIFF2"
6013 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
6014 DIFF=$(($MINV1 - ${AVAIL[$MINI1]}))
6015 echo "Wrote $DIFF to smaller OST $MINI1"
6016 DIFF2=$(($MAXV1 - ${AVAIL[$MAXI1]}))
6017 echo "Wrote $DIFF2 to larger OST $MAXI1"
6018 [ $DIFF -gt 0 ] && echo "Wrote $(($DIFF2 * 100 / $DIFF - 100))% more data to larger OST $MAXI1"
6020 # Figure out which files were written where
6021 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
6022 awk '/'$MINI1': / {print $2; exit}')
6024 MINC=$($GETSTRIPE --obd $UUID $DIR/$tdir | wc -l)
6025 echo "$MINC files created on smaller OST $MINI1"
6026 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
6027 awk '/'$MAXI1': / {print $2; exit}')
6029 MAXC=$($GETSTRIPE --obd $UUID $DIR/$tdir | wc -l)
6030 echo "$MAXC files created on larger OST $MAXI1"
6031 [ $MINC -gt 0 ] && echo "Wrote $(($MAXC * 100 / $MINC - 100))% more files to larger OST $MAXI1"
6032 [ $MAXC -gt $MINC ] || error_ignore "stripe QOS didn't balance free space"
6036 run_test 116 "stripe QOS: free space balance ==================="
6038 test_117() # bug 10891
6040 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
6041 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
6042 lctl set_param fail_loc=0x21e
6043 > $DIR/$tfile || error "truncate failed"
6044 lctl set_param fail_loc=0
6045 echo "Truncate succeeded."
6048 run_test 117 "verify fsfilt_extend =========="
6050 export OLD_RESENDCOUNT=""
6051 set_resend_count () {
6052 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
6053 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -1)
6054 lctl set_param -n $PROC_RESENDCOUNT $1
6055 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
6058 [ "$SLOW" = "no" ] && set_resend_count 4 # for reduce test_118* time (bug 14842)
6060 # Reset async IO behavior after error case
6062 FILE=$DIR/reset_async
6064 # Ensure all OSCs are cleared
6065 $SETSTRIPE -c -1 $FILE
6066 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
6071 test_118a() #bug 11710
6075 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6076 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6077 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
6079 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6080 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6085 run_test 118a "verify O_SYNC works =========="
6089 remote_ost_nodsh && skip "remote OST with nodsh" && return
6093 #define OBD_FAIL_OST_ENOENT 0x217
6094 set_nodes_failloc "$(osts_nodes)" 0x217
6095 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6097 set_nodes_failloc "$(osts_nodes)" 0
6098 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6099 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6102 if [[ $RC -eq 0 ]]; then
6103 error "Must return error due to dropped pages, rc=$RC"
6107 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6108 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6112 echo "Dirty pages not leaked on ENOENT"
6114 # Due to the above error the OSC will issue all RPCs syncronously
6115 # until a subsequent RPC completes successfully without error.
6116 $MULTIOP $DIR/$tfile Ow4096yc
6121 run_test 118b "Reclaim dirty pages on fatal error =========="
6125 remote_ost_nodsh && skip "remote OST with nodsh" && return
6129 #define OBD_FAIL_OST_EROFS 0x216
6130 set_nodes_failloc "$(osts_nodes)" 0x216
6132 # multiop should block due to fsync until pages are written
6133 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
6137 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
6138 error "Multiop failed to block on fsync, pid=$MULTIPID"
6141 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6143 if [[ $WRITEBACK -eq 0 ]]; then
6144 error "No page in writeback, writeback=$WRITEBACK"
6147 set_nodes_failloc "$(osts_nodes)" 0
6150 if [[ $RC -ne 0 ]]; then
6151 error "Multiop fsync failed, rc=$RC"
6154 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6155 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6157 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6158 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6162 echo "Dirty pages flushed via fsync on EROFS"
6165 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
6169 remote_ost_nodsh && skip "remote OST with nodsh" && return
6173 #define OBD_FAIL_OST_BRW_PAUSE_BULK
6174 set_nodes_failloc "$(osts_nodes)" 0x214
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 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
6191 set_nodes_failloc "$(osts_nodes)" 0
6193 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6194 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6196 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6197 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6201 echo "Dirty pages gaurenteed flushed via fsync"
6204 run_test 118d "Fsync validation inject a delay of the bulk =========="
6209 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
6210 lctl set_param fail_loc=0x8000040a
6212 # Should simulate EINVAL error which is fatal
6213 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6215 if [[ $RC -eq 0 ]]; then
6216 error "Must return error due to dropped pages, rc=$RC"
6219 lctl set_param fail_loc=0x0
6221 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6222 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6223 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6225 if [[ $LOCKED -ne 0 ]]; then
6226 error "Locked pages remain in cache, locked=$LOCKED"
6229 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6230 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6234 echo "No pages locked after fsync"
6239 run_test 118f "Simulate unrecoverable OSC side error =========="
6244 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
6245 lctl set_param fail_loc=0x406
6247 # simulate local -ENOMEM
6248 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6251 lctl set_param fail_loc=0
6252 if [[ $RC -eq 0 ]]; then
6253 error "Must return error due to dropped pages, rc=$RC"
6256 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6257 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6258 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6260 if [[ $LOCKED -ne 0 ]]; then
6261 error "Locked pages remain in cache, locked=$LOCKED"
6264 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6265 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6269 echo "No pages locked after fsync"
6274 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
6277 remote_ost_nodsh && skip "remote OST with nodsh" && return
6281 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
6282 set_nodes_failloc "$(osts_nodes)" 0x20e
6283 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
6284 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6287 set_nodes_failloc "$(osts_nodes)" 0
6288 if [[ $RC -eq 0 ]]; then
6289 error "Must return error due to dropped pages, rc=$RC"
6292 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6293 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6294 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6296 if [[ $LOCKED -ne 0 ]]; then
6297 error "Locked pages remain in cache, locked=$LOCKED"
6300 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6301 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6305 echo "No pages locked after fsync"
6309 run_test 118h "Verify timeout in handling recoverables errors =========="
6311 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
6314 remote_ost_nodsh && skip "remote OST with nodsh" && return
6318 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
6319 set_nodes_failloc "$(osts_nodes)" 0x20e
6321 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
6322 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
6325 set_nodes_failloc "$(osts_nodes)" 0
6329 if [[ $RC -ne 0 ]]; then
6330 error "got error, but should be not, rc=$RC"
6333 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6334 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6335 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
6336 if [[ $LOCKED -ne 0 ]]; then
6337 error "Locked pages remain in cache, locked=$LOCKED"
6340 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6341 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6345 echo "No pages locked after fsync"
6349 run_test 118i "Fix error before timeout in recoverable error =========="
6351 [ "$SLOW" = "no" ] && set_resend_count 4
6354 remote_ost_nodsh && skip "remote OST with nodsh" && return
6358 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
6359 set_nodes_failloc "$(osts_nodes)" 0x220
6361 # return -EIO from OST
6362 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6364 set_nodes_failloc "$(osts_nodes)" 0x0
6365 if [[ $RC -eq 0 ]]; then
6366 error "Must return error due to dropped pages, rc=$RC"
6369 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6370 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6371 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
6372 if [[ $LOCKED -ne 0 ]]; then
6373 error "Locked pages remain in cache, locked=$LOCKED"
6376 # in recoverable error on OST we want resend and stay until it finished
6377 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6378 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6382 echo "No pages locked after fsync"
6386 run_test 118j "Simulate unrecoverable OST side error =========="
6390 remote_ost_nodsh && skip "remote OSTs with nodsh" && return
6392 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
6393 set_nodes_failloc "$(osts_nodes)" 0x20e
6396 for ((i=0;i<10;i++)); do
6397 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
6398 error "dd to $DIR/$tdir/$tfile-$i failed" )&
6405 set_nodes_failloc "$(osts_nodes)" 0
6408 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
6414 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
6417 run_test 118l "fsync dir ========="
6419 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
6421 test_119a() # bug 11737
6423 BSIZE=$((512 * 1024))
6424 directio write $DIR/$tfile 0 1 $BSIZE
6425 # We ask to read two blocks, which is more than a file size.
6426 # directio will indicate an error when requested and actual
6427 # sizes aren't equeal (a normal situation in this case) and
6428 # print actual read amount.
6429 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
6430 if [ "$NOB" != "$BSIZE" ]; then
6431 error "read $NOB bytes instead of $BSIZE"
6435 run_test 119a "Short directIO read must return actual read amount"
6437 test_119b() # bug 11737
6439 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
6441 $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
6442 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
6444 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) || \
6445 error "direct read failed"
6448 run_test 119b "Sparse directIO read must return actual read amount"
6450 test_119c() # bug 13099
6453 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
6454 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
6457 run_test 119c "Testing for direct read hitting hole"
6459 test_119d() # bug 15950
6461 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
6462 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
6464 $SETSTRIPE $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
6465 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
6466 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
6467 lctl set_param fail_loc=0x40d
6468 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
6471 cat $DIR/$tfile > /dev/null &
6472 lctl set_param fail_loc=0
6475 log "the DIO writes have completed, now wait for the reads (should not block very long)"
6477 [ -n "`ps h -p $pid_reads -o comm`" ] && \
6478 error "the read rpcs have not completed in 2s"
6480 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
6482 run_test 119d "The DIO path should try to send a new rpc once one is completed"
6486 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6487 skip "no early lock cancel on server" && return 0
6488 lru_resize_disable mdc
6489 lru_resize_disable osc
6490 cancel_lru_locks mdc
6491 stat $DIR/$tdir > /dev/null
6492 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6493 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6495 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6496 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6497 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6498 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6499 lru_resize_enable mdc
6500 lru_resize_enable osc
6502 run_test 120a "Early Lock Cancel: mkdir test"
6506 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6507 skip "no early lock cancel on server" && return 0
6508 lru_resize_disable mdc
6509 lru_resize_disable osc
6510 cancel_lru_locks mdc
6511 stat $DIR/$tdir > /dev/null
6512 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6513 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6515 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6516 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6517 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6518 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6519 lru_resize_enable mdc
6520 lru_resize_enable osc
6522 run_test 120b "Early Lock Cancel: create test"
6526 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6527 skip "no early lock cancel on server" && return 0
6528 lru_resize_disable mdc
6529 lru_resize_disable osc
6530 mkdir -p $DIR/$tdir/d1 $DIR/$tdir/d2
6531 touch $DIR/$tdir/d1/f1
6532 cancel_lru_locks mdc
6533 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
6534 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6535 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6536 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
6537 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6538 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6539 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6540 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6541 lru_resize_enable mdc
6542 lru_resize_enable osc
6544 run_test 120c "Early Lock Cancel: link test"
6548 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6549 skip "no early lock cancel on server" && return 0
6550 lru_resize_disable mdc
6551 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}'`
6557 chmod a+x $DIR/$tdir
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 120d "Early Lock Cancel: setattr 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 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
6574 cancel_lru_locks mdc
6575 cancel_lru_locks osc
6576 dd if=$DIR/$tdir/f1 of=/dev/null
6577 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
6578 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6579 awk '/ldlm_cancel/ {print $2}'`
6580 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6581 awk '/ldlm_bl_callback/ {print $2}'`
6582 unlink $DIR/$tdir/f1
6583 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6584 awk '/ldlm_cancel/ {print $2}'`
6585 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6586 awk '/ldlm_bl_callback/ {print $2}'`
6587 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6588 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6589 lru_resize_enable mdc
6590 lru_resize_enable osc
6592 run_test 120e "Early Lock Cancel: unlink test"
6595 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6596 skip "no early lock cancel on server" && return 0
6598 lru_resize_disable mdc
6599 lru_resize_disable osc
6600 mkdir -p $DIR/$tdir/d1 $DIR/$tdir/d2
6601 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
6602 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
6603 cancel_lru_locks mdc
6604 cancel_lru_locks osc
6605 dd if=$DIR/$tdir/d1/f1 of=/dev/null
6606 dd if=$DIR/$tdir/d2/f2 of=/dev/null
6607 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
6608 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6609 awk '/ldlm_cancel/ {print $2}'`
6610 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6611 awk '/ldlm_bl_callback/ {print $2}'`
6612 mv $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
6613 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6614 awk '/ldlm_cancel/ {print $2}'`
6615 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6616 awk '/ldlm_bl_callback/ {print $2}'`
6617 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6618 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6619 lru_resize_enable mdc
6620 lru_resize_enable osc
6622 run_test 120f "Early Lock Cancel: rename test"
6625 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6626 skip "no early lock cancel on server" && return 0
6627 lru_resize_disable mdc
6628 lru_resize_disable osc
6630 echo create $count files
6632 cancel_lru_locks mdc
6633 cancel_lru_locks osc
6636 can0=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6637 awk '/ldlm_cancel/ {print $2}'`
6638 blk0=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6639 awk '/ldlm_bl_callback/ {print $2}'`
6640 createmany -o $DIR/$tdir/f $count
6642 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6643 awk '/ldlm_cancel/ {print $2}'`
6644 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6645 awk '/ldlm_bl_callback/ {print $2}'`
6647 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
6648 echo rm $count files
6651 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6652 awk '/ldlm_cancel/ {print $2}'`
6653 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6654 awk '/ldlm_bl_callback/ {print $2}'`
6656 echo total: $count removes in $((t2-t1))
6657 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
6659 # wait for commitment of removal
6660 lru_resize_enable mdc
6661 lru_resize_enable osc
6663 run_test 120g "Early Lock Cancel: performance test"
6665 test_121() { #bug #10589
6667 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
6668 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
6669 lctl set_param fail_loc=0x310
6670 cancel_lru_locks osc > /dev/null
6671 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
6672 lctl set_param fail_loc=0
6673 [ "$reads" -eq "$writes" ] || error "read" $reads "blocks, must be" $writes
6675 run_test 121 "read cancel race ========="
6677 test_123a() { # was test 123, statahead(bug 11401)
6679 if [ -z "$(grep "processor.*: 1" /proc/cpuinfo)" ]; then
6680 log "testing on UP system. Performance may be not as good as expected."
6686 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
6687 [ $NUMFREE -gt 100000 ] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
6689 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
6690 createmany -o $DIR/$tdir/$tfile $j $((i - j))
6692 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
6693 lctl set_param -n llite.*.statahead_max 0
6694 lctl get_param llite.*.statahead_max
6695 cancel_lru_locks mdc
6696 cancel_lru_locks osc
6698 time ls -l $DIR/$tdir | wc -l
6700 delta=$((etime - stime))
6701 log "ls $i files without statahead: $delta sec"
6702 lctl set_param llite.*.statahead_max=$max
6704 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
6705 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
6706 cancel_lru_locks mdc
6707 cancel_lru_locks osc
6709 time ls -l $DIR/$tdir | wc -l
6711 delta_sa=$((etime - stime))
6712 log "ls $i files with statahead: $delta_sa sec"
6713 lctl get_param -n llite.*.statahead_stats
6714 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
6716 [ $swrong -lt $ewrong ] && log "statahead was stopped, maybe too many locks held!"
6717 [ $delta -eq 0 -o $delta_sa -eq 0 ] && continue
6719 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
6720 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
6721 lctl set_param -n llite.*.statahead_max 0
6722 lctl get_param llite.*.statahead_max
6723 cancel_lru_locks mdc
6724 cancel_lru_locks osc
6726 time ls -l $DIR/$tdir | wc -l
6728 delta=$((etime - stime))
6729 log "ls $i files again without statahead: $delta sec"
6730 lctl set_param llite.*.statahead_max=$max
6731 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
6732 if [ $SLOWOK -eq 0 ]; then
6733 error "ls $i files is slower with statahead!"
6735 log "ls $i files is slower with statahead!"
6741 [ $delta -gt 20 ] && break
6742 [ $delta -gt 8 ] && MULT=$((50 / delta))
6743 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
6751 delta=$((etime - stime))
6752 log "rm -r $DIR/$tdir/: $delta seconds"
6754 lctl get_param -n llite.*.statahead_stats
6756 run_test 123a "verify statahead work"
6758 test_123b () { # statahead(bug 15027)
6760 createmany -o $DIR/$tdir/$tfile-%d 1000
6762 cancel_lru_locks mdc
6763 cancel_lru_locks osc
6765 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
6766 lctl set_param fail_loc=0x80000803
6767 ls -lR $DIR/$tdir > /dev/null
6769 lctl set_param fail_loc=0x0
6770 lctl get_param -n llite.*.statahead_stats
6775 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
6778 [ -z "`lctl get_param -n mdc.*.connect_flags | grep lru_resize`" ] && \
6779 skip "no lru resize on server" && return 0
6781 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
6783 log "create $NR files at $DIR/$tdir"
6784 createmany -o $DIR/$tdir/f $NR ||
6785 error "failed to create $NR files in $DIR/$tdir"
6787 cancel_lru_locks mdc
6788 ls -l $DIR/$tdir > /dev/null
6792 for VALUE in `lctl get_param ldlm.namespaces.*mdc-*.lru_size`; do
6793 local PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
6794 LRU_SIZE=$(lctl get_param -n $PARAM)
6795 if [ $LRU_SIZE -gt $(default_lru_size) ]; then
6796 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
6798 log "NS=$(basename $NSDIR)"
6803 if [ -z "$NSDIR" -o $LRU_SIZE -lt $(default_lru_size) ]; then
6804 skip "Not enough cached locks created!"
6811 # We know that lru resize allows one client to hold $LIMIT locks
6812 # for 10h. After that locks begin to be killed by client.
6814 local LIMIT=`lctl get_param -n $NSDIR.pool.limit`
6817 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
6818 # killing locks. Some time was spent for creating locks. This means
6819 # that up to the moment of sleep finish we must have killed some of
6820 # them (10-100 locks). This depends on how fast ther were created.
6821 # Many of them were touched in almost the same moment and thus will
6822 # be killed in groups.
6823 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
6825 # Use $LRU_SIZE_B here to take into account real number of locks
6826 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
6827 local LRU_SIZE_B=$LRU_SIZE
6829 local OLD_LVF=`lctl get_param -n $NSDIR.pool.lock_volume_factor`
6830 log "OLD_LVF=$OLD_LVF"
6831 lctl set_param -n $NSDIR.pool.lock_volume_factor $LVF
6833 # Let's make sure that we really have some margin. Client checks
6834 # cached locks every 10 sec.
6836 log "Sleep ${SLEEP} sec"
6838 while ((SEC<$SLEEP)); do
6842 LRU_SIZE=`lctl get_param -n $NSDIR/lru_size`
6846 lctl set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
6847 local LRU_SIZE_A=`lctl get_param -n $NSDIR.lru_size`
6849 [ $LRU_SIZE_B -gt $LRU_SIZE_A ] || {
6850 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
6851 unlinkmany $DIR/$tdir/f $NR
6855 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
6856 log "unlink $NR files at $DIR/$tdir"
6857 unlinkmany $DIR/$tdir/f $NR
6859 run_test 124a "lru resize ======================================="
6861 get_max_pool_limit()
6863 local limit=`lctl get_param -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit`
6866 if test $l -gt $max; then
6874 [ -z "`lctl get_param -n mdc.*.connect_flags | grep lru_resize`" ] && \
6875 skip "no lru resize on server" && return 0
6877 LIMIT=`get_max_pool_limit`
6879 NR=$(($(default_lru_size)*20))
6880 if [ $NR -gt $LIMIT ]; then
6881 log "Limit lock number by $LIMIT locks"
6884 lru_resize_disable mdc
6885 mkdir -p $DIR/$tdir/disable_lru_resize ||
6886 error "failed to create $DIR/$tdir/disable_lru_resize"
6888 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
6889 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
6890 cancel_lru_locks mdc
6893 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
6896 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
6899 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
6903 nolruresize_delta=$((etime-stime))
6904 log "ls -la time: $nolruresize_delta seconds"
6905 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
6906 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
6908 lru_resize_enable mdc
6909 mkdir -p $DIR/$tdir/enable_lru_resize ||
6910 error "failed to create $DIR/$tdir/enable_lru_resize"
6912 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
6913 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
6914 cancel_lru_locks mdc
6917 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
6920 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
6923 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
6927 lruresize_delta=$((etime-stime))
6928 log "ls -la time: $lruresize_delta seconds"
6929 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
6931 if [ $lruresize_delta -gt $nolruresize_delta ]; then
6932 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
6933 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
6934 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
6936 log "lru resize performs the same with no lru resize"
6938 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
6940 run_test 124b "lru resize (performance test) ======================="
6942 test_125() { # 13358
6943 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
6944 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
6945 mkdir -p $DIR/d125 || error "mkdir failed"
6946 $SETSTRIPE -S 65536 -c -1 $DIR/d125 || error "setstripe failed"
6947 setfacl -R -m u:bin:rwx $DIR/d125 || error "setfacl $DIR/d125 failed"
6948 ls -ld $DIR/d125 || error "cannot access $DIR/d125"
6950 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
6952 test_126() { # bug 12829/13455
6953 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
6954 [ "$UID" != 0 ] && skip_env "skipping $TESTNAME (must run as root)" && return
6955 $GSS && skip "must run as gss disabled" && return
6957 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
6958 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
6960 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
6962 run_test 126 "check that the fsgid provided by the client is taken into account"
6964 test_127a() { # bug 15521
6965 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
6966 $LCTL set_param osc.*.stats=0
6967 FSIZE=$((2048 * 1024))
6968 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
6969 cancel_lru_locks osc
6970 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
6972 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
6973 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
6974 echo "got $COUNT $NAME"
6975 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
6976 eval $NAME=$COUNT || error "Wrong proc format"
6979 read_bytes|write_bytes)
6980 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
6981 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
6982 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
6983 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
6984 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
6985 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
6986 error "sumsquare is too small: $SUMSQ"
6987 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
6988 error "sumsquare is too big: $SUMSQ"
6992 done < $DIR/${tfile}.tmp
6994 #check that we actually got some stats
6995 [ "$read_bytes" ] || error "Missing read_bytes stats"
6996 [ "$write_bytes" ] || error "Missing write_bytes stats"
6997 [ "$read_bytes" != 0 ] || error "no read done"
6998 [ "$write_bytes" != 0 ] || error "no write done"
7000 run_test 127a "verify the client stats are sane"
7002 test_127b() { # bug LU-333
7003 $LCTL set_param llite.*.stats=0
7004 FSIZE=65536 # sized fixed to match PAGE_SIZE for most clients
7005 # perform 2 reads and writes so MAX is different from SUM.
7006 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
7007 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
7008 cancel_lru_locks osc
7009 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
7010 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
7012 $LCTL get_param llite.*.stats | grep samples > $TMP/${tfile}.tmp
7013 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
7014 echo "got $COUNT $NAME"
7015 eval $NAME=$COUNT || error "Wrong proc format"
7019 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
7020 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
7021 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
7022 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
7025 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
7026 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
7027 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
7028 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
7032 done < $TMP/${tfile}.tmp
7034 #check that we actually got some stats
7035 [ "$read_bytes" ] || error "Missing read_bytes stats"
7036 [ "$write_bytes" ] || error "Missing write_bytes stats"
7037 [ "$read_bytes" != 0 ] || error "no read done"
7038 [ "$write_bytes" != 0 ] || error "no write done"
7040 run_test 127b "verify the llite client stats are sane"
7042 test_128() { # bug 15212
7044 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
7049 result=$(grep error $TMP/$tfile.log)
7051 [ -z "$result" ] || error "consecutive find's under interactive lfs failed"
7053 run_test 128 "interactive lfs for 2 consecutive find's"
7060 local LDPROC=/proc/fs/ldiskfs
7062 for facet in $(get_facets MDS); do
7063 canondev=$(ldiskfs_canon *.$(convert_facet2label $facet).mntdev $facet)
7064 do_facet $facet "test -e $LDPROC/$canondev/max_dir_size" || LDPROC=/sys/fs/ldiskfs
7065 do_facet $facet "echo $1 >$LDPROC/$canondev/max_dir_size"
7069 if [ "$(facet_type_fstype MDS)" != ldiskfs ]; then
7070 skip "Only applicable to ldiskfs-based MDTs"
7073 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7084 while [ ! $I -gt $((MAX * MDSCOUNT)) ]; do
7085 $MULTIOP $DIR/$tdir/$J Oc
7087 if [ $rc -eq $EFBIG ]; then
7089 echo "return code $rc received as expected"
7091 elif [ $rc -ne 0 ]; then
7093 error_exit "return code $rc received instead of expected $EFBIG"
7096 I=$(stat -c%s "$DIR/$tdir")
7100 error "exceeded dir size limit $MAX x $MDSCOUNT $((MAX * MDSCOUNT)) : $I bytes"
7102 run_test 129 "test directory size limit ========================"
7111 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7112 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
7115 trap cleanup_130 EXIT RETURN
7117 local fm_file=$DIR/$tfile
7118 $SETSTRIPE -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
7119 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
7120 error "dd failed for $fm_file"
7122 # LU-1795: test filefrag/FIEMAP once, even if unsupported
7123 filefrag -ves $fm_file
7125 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
7126 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
7127 [ $RC != 0 ] && error "filefrag $fm_file failed"
7129 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
7130 grep -v "ext:" | grep -v "found")
7131 lun=$($GETSTRIPE -i $fm_file)
7133 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
7136 for line in $filefrag_op
7138 frag_lun=`echo $line | cut -d: -f5`
7139 ext_len=`echo $line | cut -d: -f4`
7140 if (( $frag_lun != $lun )); then
7142 error "FIEMAP on 1-stripe file($fm_file) failed"
7145 (( tot_len += ext_len ))
7148 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
7150 error "FIEMAP on 1-stripe file($fm_file) failed;"
7156 echo "FIEMAP on single striped file succeeded"
7158 run_test 130a "FIEMAP (1-stripe file)"
7161 [ "$OSTCOUNT" -lt "2" ] &&
7162 skip_env "skipping FIEMAP on 2-stripe file test" && return
7164 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7165 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
7168 trap cleanup_130 EXIT RETURN
7170 local fm_file=$DIR/$tfile
7171 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
7172 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
7173 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
7175 dd if=/dev/zero of=$fm_file bs=1M count=2 ||
7176 error "dd failed on $fm_file"
7178 filefrag -ves $fm_file || error "filefrag $fm_file failed"
7179 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
7180 grep -v "ext:" | grep -v "found")
7182 last_lun=$(echo $filefrag_op | cut -d: -f5)
7187 for line in $filefrag_op
7189 frag_lun=`echo $line | cut -d: -f5`
7190 ext_len=`echo $line | cut -d: -f4`
7191 if (( $frag_lun != $last_lun )); then
7192 if (( tot_len != 1024 )); then
7194 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 256"
7201 (( tot_len += ext_len ))
7204 if (( num_luns != 2 || tot_len != 1024 )); then
7206 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
7212 echo "FIEMAP on 2-stripe file succeeded"
7214 run_test 130b "FIEMAP (2-stripe file)"
7217 [ "$OSTCOUNT" -lt "2" ] &&
7218 skip_env "skipping FIEMAP on 2-stripe file" && return
7220 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7221 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
7224 trap cleanup_130 EXIT RETURN
7226 local fm_file=$DIR/$tfile
7227 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
7228 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
7229 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
7231 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 || error "dd failed on $fm_file"
7233 filefrag -ves $fm_file || error "filefrag $fm_file failed"
7234 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
7236 last_lun=`echo $filefrag_op | cut -d: -f5`
7241 for line in $filefrag_op
7243 frag_lun=`echo $line | cut -d: -f5`
7244 ext_len=`echo $line | cut -d: -f4`
7245 if (( $frag_lun != $last_lun )); then
7246 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
7247 if (( logical != 512 )); then
7249 error "FIEMAP on $fm_file failed; returned logical start for lun $logical instead of 512"
7252 if (( tot_len != 512 )); then
7254 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
7261 (( tot_len += ext_len ))
7264 if (( num_luns != 2 || tot_len != 512 )); then
7266 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
7272 echo "FIEMAP on 2-stripe file with hole succeeded"
7274 run_test 130c "FIEMAP (2-stripe file with hole)"
7277 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping FIEMAP on N-stripe file test" && return
7279 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7280 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
7282 trap cleanup_130 EXIT RETURN
7284 local fm_file=$DIR/$tfile
7285 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file||error "setstripe on $fm_file"
7286 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
7287 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
7288 dd if=/dev/zero of=$fm_file bs=1M count=$OSTCOUNT || error "dd failed on $fm_file"
7290 filefrag -ves $fm_file || error "filefrag $fm_file failed"
7291 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
7293 last_lun=`echo $filefrag_op | cut -d: -f5`
7298 for line in $filefrag_op
7300 frag_lun=`echo $line | cut -d: -f5`
7301 ext_len=`echo $line | cut -d: -f4`
7302 if (( $frag_lun != $last_lun )); then
7303 if (( tot_len != 1024 )); then
7305 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
7312 (( tot_len += ext_len ))
7315 if (( num_luns != OSTCOUNT || tot_len != 1024 )); then
7317 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
7323 echo "FIEMAP on N-stripe file succeeded"
7325 run_test 130d "FIEMAP (N-stripe file)"
7328 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping continuation FIEMAP test" && return
7330 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7331 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
7333 trap cleanup_130 EXIT RETURN
7335 local fm_file=$DIR/$tfile
7336 $SETSTRIPE -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
7337 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
7338 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
7341 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
7342 for ((i = 0; i < $NUM_BLKS; i++))
7344 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
7347 filefrag -ves $fm_file || error "filefrag $fm_file failed"
7348 filefrag_op=`filefrag -ve $fm_file | grep -A 12000 "ext:" | grep -v "ext:" | grep -v "found"`
7350 last_lun=`echo $filefrag_op | cut -d: -f5`
7355 for line in $filefrag_op
7357 frag_lun=`echo $line | cut -d: -f5`
7358 ext_len=`echo $line | cut -d: -f4`
7359 if (( $frag_lun != $last_lun )); then
7360 if (( tot_len != $EXPECTED_LEN )); then
7362 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of $EXPECTED_LEN"
7369 (( tot_len += ext_len ))
7372 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
7374 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
7380 echo "FIEMAP with continuation calls succeeded"
7382 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
7384 # Test for writev/readv
7386 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 || \
7387 error "writev test failed"
7388 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 || \
7389 error "readv failed"
7392 run_test 131a "test iov's crossing stripe boundary for writev/readv"
7395 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 || \
7396 error "append writev test failed"
7397 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 || \
7398 error "append writev test failed"
7401 run_test 131b "test append writev"
7404 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
7407 run_test 131c "test read/write on file w/o objects"
7410 rwv -f $DIR/$tfile -w -n 1 1572864
7411 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
7412 if [ "$NOB" != 1572864 ]; then
7413 error "Short read filed: read $NOB bytes instead of 1572864"
7417 run_test 131d "test short read"
7420 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
7421 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
7422 error "read hitting hole failed"
7425 run_test 131e "test read hitting hole"
7430 for node in $(osts_nodes); do
7431 gl=$(do_node $node "$LCTL get_param -n ost.OSS.ost.stats" | awk '/'$token'/ {print $2}' | head -n 1)
7432 [ x$gl = x"" ] && gl=0
7433 gl_sum=$((gl_sum + gl))
7443 if [ x$som = x"enabled" ]; then
7444 [ $((gl2 - gl1)) -gt 0 ] && error "no glimpse RPC is expected"
7445 MOUNTOPT=`echo $MOUNTOPT | sed 's/som_preview//g'`
7446 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=disabled"
7448 [ $((gl2 - gl1)) -gt 0 ] || error "some glimpse RPC is expected"
7449 MOUNTOPT="$MOUNTOPT,som_preview"
7450 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=enabled"
7453 # do remount to make new mount-conf parameters actual
7460 test_132() { #1028, SOM
7461 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7462 local num=$(get_mds_dir $DIR)
7463 local mymds=mds${num}
7464 local MOUNTOPT_SAVE=$MOUNTOPT
7466 dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
7467 cancel_lru_locks osc
7469 som1=$(do_facet $mymds "$LCTL get_param mdt.*.som" | awk -F= ' {print $2}' | head -n 1)
7471 gl1=$(get_ost_param "ldlm_glimpse_enqueue")
7472 stat $DIR/$tfile >/dev/null
7473 gl2=$(get_ost_param "ldlm_glimpse_enqueue")
7474 echo "====> SOM is "$som1", "$((gl2 - gl1))" glimpse RPC occured"
7476 som_mode_switch $som1 $gl1 $gl2
7478 dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
7479 cancel_lru_locks osc
7481 som2=$(do_facet $mymds "$LCTL get_param mdt.*.som" | awk -F= ' {print $2}' | head -n 1)
7482 if [ $som1 == $som2 ]; then
7483 error "som is still "$som2
7484 if [ x$som2 = x"enabled" ]; then
7491 gl1=$(get_ost_param "ldlm_glimpse_enqueue")
7492 stat $DIR/$tfile >/dev/null
7493 gl2=$(get_ost_param "ldlm_glimpse_enqueue")
7494 echo "====> SOM is "$som2", "$((gl2 - gl1))" glimpse RPC occured"
7495 som_mode_switch $som2 $gl1 $gl2
7496 MOUNTOPT=$MOUNTOPT_SAVE
7498 run_test 132 "som avoids glimpse rpc"
7504 $SINGLEMDS) res=`do_facet $SINGLEMDS $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$2"`
7506 ost) res=`do_facet ost1 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$2"`
7508 *) error "Wrong argument $1" ;;
7511 count=`echo $res | awk '{print $2}'`
7512 [ -z "$res" ] && error "The counter for $2 on $1 was not incremented"
7513 # if the argument $3 is zero, it means any stat increment is ok.
7514 if [ $3 -gt 0 ] ; then
7515 [ $count -ne $3 ] && error "The $2 counter on $1 is wrong - expected $3"
7520 remote_ost_nodsh && skip "remote OST with nodsh" && return
7521 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7523 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
7524 { skip "MDS doesn't support rename stats"; return; }
7525 local testdir=$DIR/${tdir}/stats_testdir
7526 mkdir -p $DIR/${tdir}
7529 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
7530 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
7532 # verify mdt stats first.
7533 mkdir ${testdir} || error "mkdir failed"
7534 check_stats $SINGLEMDS "mkdir" 1
7535 touch ${testdir}/${tfile} || "touch failed"
7536 check_stats $SINGLEMDS "open" 1
7537 check_stats $SINGLEMDS "close" 1
7538 mknod ${testdir}/${tfile}-pipe p || "mknod failed"
7539 check_stats $SINGLEMDS "mknod" 1
7540 rm -f ${testdir}/${tfile}-pipe || "pipe remove failed"
7541 check_stats $SINGLEMDS "unlink" 1
7542 rm -f ${testdir}/${tfile} || error "file remove failed"
7543 check_stats $SINGLEMDS "unlink" 2
7545 # remove working dir and check mdt stats again.
7546 rmdir ${testdir} || error "rmdir failed"
7547 check_stats $SINGLEMDS "rmdir" 1
7549 local testdir1=$DIR/${tdir}/stats_testdir1
7551 mkdir -p ${testdir1}
7552 touch ${testdir1}/test1
7553 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
7554 check_stats $SINGLEMDS "crossdir_rename" 1
7556 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
7557 check_stats $SINGLEMDS "samedir_rename" 1
7561 run_test 133a "Verifying MDT stats ========================================"
7564 remote_ost_nodsh && skip "remote OST with nodsh" && return
7565 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7566 local testdir=$DIR/${tdir}/stats_testdir
7567 mkdir -p ${testdir} || error "mkdir failed"
7568 touch ${testdir}/${tfile} || "touch failed"
7569 cancel_lru_locks mdc
7572 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
7573 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
7575 # extra mdt stats verification.
7576 chmod 444 ${testdir}/${tfile} || error "chmod failed"
7577 check_stats $SINGLEMDS "setattr" 1
7578 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
7579 if [ $(lustre_version_code $SINGLEMDS) -ne $(version_code 2.2.0) ]
7581 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
7582 check_stats $SINGLEMDS "getattr" 1
7584 $LFS df || error "lfs failed"
7585 check_stats $SINGLEMDS "statfs" 1
7589 run_test 133b "Verifying extra MDT stats =================================="
7592 remote_ost_nodsh && skip "remote OST with nodsh" && return
7593 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7594 local testdir=$DIR/${tdir}/stats_testdir
7595 mkdir -p ${testdir} || error "mkdir failed"
7597 # verify obdfilter stats.
7598 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
7600 cancel_lru_locks osc
7601 wait_delete_completed
7604 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
7605 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
7607 dd if=/dev/zero of=${testdir}/${tfile} conv=notrunc bs=512k count=1 || error "dd failed"
7609 cancel_lru_locks osc
7610 check_stats ost "write" 1
7612 dd if=${testdir}/${tfile} of=/dev/null bs=1k count=1 || error "dd failed"
7613 check_stats ost "read" 1
7615 > ${testdir}/${tfile} || error "truncate failed"
7616 check_stats ost "punch" 1
7618 rm -f ${testdir}/${tfile} || error "file remove failed"
7619 wait_delete_completed
7620 check_stats ost "destroy" 1
7624 run_test 133c "Verifying OST stats ========================================"
7631 while [ $value -ge 2 ]; do
7636 if [ $orig -gt $order ]; then
7644 local size=('K' 'M' 'G' 'T');
7646 local size_string=$value
7648 while [ $value -ge 1024 ]; do
7649 if [ $i -gt 3 ]; then
7650 #T is the biggest unit we get here, if that is bigger,
7652 size_string=${value}T
7655 value=$((value >> 10))
7656 if [ $value -lt 1024 ]; then
7657 size_string=${value}${size[$i]}
7668 local sample=$(do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats |
7669 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
7674 remote_ost_nodsh && skip "remote OST with nodsh" && return
7675 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7676 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
7677 { skip "MDS doesn't support rename stats"; return; }
7679 local testdir1=$DIR/${tdir}/stats_testdir1
7680 local testdir2=$DIR/${tdir}/stats_testdir2
7682 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
7684 mkdir -p ${testdir1} || error "mkdir failed"
7685 mkdir -p ${testdir2} || error "mkdir failed"
7687 createmany -o $testdir1/test 512 || error "createmany failed"
7689 # check samedir rename size
7690 mv ${testdir1}/test0 ${testdir1}/test_0
7692 local testdir1_size=$(ls -l $DIR/${tdir} |
7693 awk '/stats_testdir1/ {print $5}')
7694 local testdir2_size=$(ls -l $DIR/${tdir} |
7695 awk '/stats_testdir2/ {print $5}')
7697 testdir1_size=$(order_2 $testdir1_size)
7698 testdir2_size=$(order_2 $testdir2_size)
7700 testdir1_size=$(size_in_KMGT $testdir1_size)
7701 testdir2_size=$(size_in_KMGT $testdir2_size)
7703 echo "source rename dir size: ${testdir1_size}"
7704 echo "target rename dir size: ${testdir2_size}"
7706 local cmd="do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats"
7707 eval $cmd || error "$cmd failed"
7708 local samedir=$($cmd | grep 'same_dir')
7709 local same_sample=$(get_rename_size $testdir1_size)
7710 [ -z "$samedir" ] && error "samedir_rename_size count error"
7711 [ "$same_sample" -eq 1 ] || error "samedir_rename_size error $same_sample"
7712 echo "Check same dir rename stats success"
7714 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
7716 # check crossdir rename size
7717 mv ${testdir1}/test_0 ${testdir2}/test_0
7719 testdir1_size=$(ls -l $DIR/${tdir} |
7720 awk '/stats_testdir1/ {print $5}')
7721 testdir2_size=$(ls -l $DIR/${tdir} |
7722 awk '/stats_testdir2/ {print $5}')
7724 testdir1_size=$(order_2 $testdir1_size)
7725 testdir2_size=$(order_2 $testdir2_size)
7727 testdir1_size=$(size_in_KMGT $testdir1_size)
7728 testdir2_size=$(size_in_KMGT $testdir2_size)
7730 echo "source rename dir size: ${testdir1_size}"
7731 echo "target rename dir size: ${testdir2_size}"
7733 eval $cmd || error "$cmd failed"
7734 local crossdir=$($cmd | grep 'crossdir')
7735 local src_sample=$(get_rename_size $testdir1_size)
7736 local tgt_sample=$(get_rename_size $testdir2_size)
7737 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
7738 [ "$src_sample" -eq 1 ] || error "crossdir_rename_size error $src_sample"
7739 [ "$tgt_sample" -eq 1 ] || error "crossdir_rename_size error $tgt_sample"
7740 echo "Check cross dir rename stats success"
7743 run_test 133d "Verifying rename_stats ========================================"
7745 test_140() { #bug-17379
7746 mkdir -p $DIR/$tdir || error "Creating dir $DIR/$tdir"
7747 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
7748 cp /usr/bin/stat . || error "Copying stat to $DIR/$tdir"
7750 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
7752 while i=`expr $i + 1`; do
7753 mkdir -p $i || error "Creating dir $i"
7754 cd $i || error "Changing to $i"
7755 ln -s ../stat stat || error "Creating stat symlink"
7756 # Read the symlink until ELOOP present,
7757 # not LBUGing the system is considered success,
7758 # we didn't overrun the stack.
7759 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
7761 if [ $ret -eq 40 ]; then
7764 error "Open stat symlink"
7770 echo "The symlink depth = $i"
7771 [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 ] || error "Invalid symlink depth"
7773 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
7776 local TF="$TMP/$tfile"
7778 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
7780 cancel_lru_locks osc
7781 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
7782 remount_client $MOUNT
7784 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
7787 $TRUNCATE $DIR/$tfile 6000
7788 cancel_lru_locks osc
7789 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
7792 echo "12345" >>$DIR/$tfile
7793 cancel_lru_locks osc
7794 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
7797 echo "12345" >>$DIR/$tfile
7798 cancel_lru_locks osc
7799 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
7804 run_test 150 "truncate/append tests"
7806 function roc_hit() {
7807 local list=$(comma_list $(osts_nodes))
7809 echo $(get_obdfilter_param $list '' stats |
7810 awk '/'cache_hit'/ {sum+=$2} END {print sum}')
7813 function set_cache() {
7816 if [ "$2" == "off" ]; then
7819 local list=$(comma_list $(osts_nodes))
7820 set_obdfilter_param $list '' $1_cache_enable $on
7822 cancel_lru_locks osc
7826 remote_ost_nodsh && skip "remote OST with nodsh" && return
7829 local list=$(comma_list $(osts_nodes))
7831 # check whether obdfilter is cache capable at all
7832 if ! get_obdfilter_param $list '' read_cache_enable >/dev/null; then
7833 echo "not cache-capable obdfilter"
7837 # check cache is enabled on all obdfilters
7838 if get_obdfilter_param $list '' read_cache_enable | grep 0; then
7839 echo "oss cache is disabled"
7843 set_obdfilter_param $list '' writethrough_cache_enable 1
7845 # pages should be in the case right after write
7846 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES || error "dd failed"
7847 local BEFORE=`roc_hit`
7848 cancel_lru_locks osc
7849 cat $DIR/$tfile >/dev/null
7850 local AFTER=`roc_hit`
7851 if ! let "AFTER - BEFORE == CPAGES"; then
7852 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
7855 # the following read invalidates the cache
7856 cancel_lru_locks osc
7857 set_obdfilter_param $list '' read_cache_enable 0
7858 cat $DIR/$tfile >/dev/null
7860 # now data shouldn't be found in the cache
7862 cancel_lru_locks osc
7863 cat $DIR/$tfile >/dev/null
7865 if let "AFTER - BEFORE != 0"; then
7866 error "IN CACHE: before: $BEFORE, after: $AFTER"
7869 set_obdfilter_param $list '' read_cache_enable 1
7872 run_test 151 "test cache on oss and controls ==============================="
7875 local TF="$TMP/$tfile"
7877 # simulate ENOMEM during write
7878 #define OBD_FAIL_OST_NOMEM 0x226
7879 lctl set_param fail_loc=0x80000226
7880 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
7882 sync || error "sync failed"
7883 lctl set_param fail_loc=0
7885 # discard client's cache
7886 cancel_lru_locks osc
7888 # simulate ENOMEM during read
7889 lctl set_param fail_loc=0x80000226
7890 cmp $TF $DIR/$tfile || error "cmp failed"
7891 lctl set_param fail_loc=0
7895 run_test 152 "test read/write with enomem ============================"
7898 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
7900 run_test 153 "test if fdatasync does not crash ======================="
7903 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
7904 { skip "Need MDS version at least 2.2.51"; return 0; }
7906 cp /etc/hosts $DIR/$tfile
7908 fid=$($LFS path2fid $DIR/$tfile)
7910 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
7912 ffid=$DIR/.lustre/fid/$fid
7914 echo "stat fid $fid"
7915 stat $ffid > /dev/null || error "stat $ffid failed."
7916 echo "touch fid $fid"
7917 touch $ffid || error "touch $ffid failed."
7918 echo "write to fid $fid"
7919 cat /etc/hosts > $ffid || error "write $ffid failed."
7920 echo "read fid $fid"
7921 diff /etc/hosts $ffid || error "read $ffid failed."
7922 echo "append write to fid $fid"
7923 cat /etc/hosts >> $ffid || error "append write $ffid failed."
7924 echo "rename fid $fid"
7925 mv $ffid $DIR/$tfile.1 && error "rename $ffid to $tfile.1 should fail."
7927 mv $DIR/$tfile.1 $ffid && error "rename $tfile.1 to $ffid should fail."
7929 echo "truncate fid $fid"
7930 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
7931 echo "link fid $fid"
7932 ln -f $ffid $DIR/tfile.lnk || error "link $ffid failed."
7933 if [ -n $(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl) ]; then
7934 echo "setfacl fid $fid"
7935 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
7936 echo "getfacl fid $fid"
7937 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
7939 echo "unlink fid $fid"
7940 unlink $DIR/.lustre/fid/$fid && error "unlink $ffid should fail."
7941 echo "mknod fid $fid"
7942 mknod $ffid c 1 3 && error "mknod $ffid should fail."
7944 fid=[0xf00000400:0x1:0x0]
7945 ffid=$DIR/.lustre/fid/$fid
7947 echo "stat non-exist fid $fid"
7948 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
7949 echo "write to non-exist fid $fid"
7950 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
7951 echo "link new fid $fid"
7952 ln $DIR/$tfile $ffid && error "link $ffid should fail."
7955 touch $DIR/$tdir/$tfile
7956 fid=$($LFS path2fid $DIR/$tdir)
7958 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
7960 ffid=$DIR/.lustre/fid/$fid
7963 ls $ffid > /dev/null || error "ls $ffid failed."
7964 echo "touch $fid/$tfile.1"
7965 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
7967 echo "touch $DIR/.lustre/fid/$tfile"
7968 touch $DIR/.lustre/fid/$tfile && \
7969 error "touch $DIR/.lustre/fid/$tfile should fail."
7971 echo "setxattr to $DIR/.lustre/fid"
7972 setfattr -n trusted.name1 -v value1 $DIR/.lustre/fid &&
7973 error "setxattr should fail."
7975 echo "listxattr for $DIR/.lustre/fid"
7976 getfattr -d -m "^trusted" $DIR/.lustre/fid &&
7977 error "listxattr should fail."
7979 echo "delxattr from $DIR/.lustre/fid"
7980 setfattr -x trusted.name1 $DIR/.lustre/fid &&
7981 error "delxattr should fail."
7983 echo "touch invalid fid: $DIR/.lustre/fid/[0x200000400:0x2:0x3]"
7984 touch $DIR/.lustre/fid/[0x200000400:0x2:0x3] &&
7985 error "touch invalid fid should fail."
7987 echo "touch non-normal fid: $DIR/.lustre/fid/[0x1:0x2:0x0]"
7988 touch $DIR/.lustre/fid/[0x1:0x2:0x0] &&
7989 error "touch non-normal fid should fail."
7991 echo "rename $tdir to $DIR/.lustre/fid"
7992 mrename $DIR/$tdir $DIR/.lustre/fid &&
7993 error "rename to $DIR/.lustre/fid should fail."
7995 echo "rename .lustre to itself"
7996 fid=$($LFS path2fid $DIR)
7997 mrename $DIR/.lustre $DIR/.lustre/fid/$fid/.lustre &&
7998 error "rename .lustre to itself should fail."
8000 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $DIR/$tfile-2
8001 fid=$($LFS path2fid $DIR/$tfile-2)
8002 echo "cp /etc/passwd $DIR/.lustre/fid/$fid"
8003 cp /etc/passwd $DIR/.lustre/fid/$fid &&
8004 error "create lov data thru .lustre should fail."
8005 echo "cp /etc/passwd $DIR/$tfile-2"
8006 cp /etc/passwd $DIR/$tfile-2 || error "copy to $DIR/$tfile-2 failed."
8007 echo "diff /etc/passwd $DIR/.lustre/fid/$fid"
8008 diff /etc/passwd $DIR/.lustre/fid/$fid ||
8009 error "diff /etc/passwd $DIR/.lustre/fid/$fid failed."
8011 echo "Open-by-FID succeeded"
8013 run_test 154 "Open-by-FID"
8015 test_155_small_load() {
8016 local temp=$TMP/$tfile
8017 local file=$DIR/$tfile
8019 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
8020 error "dd of=$temp bs=6096 count=1 failed"
8022 cancel_lru_locks osc
8023 cmp $temp $file || error "$temp $file differ"
8025 $TRUNCATE $temp 6000
8026 $TRUNCATE $file 6000
8027 cmp $temp $file || error "$temp $file differ (truncate1)"
8029 echo "12345" >>$temp
8030 echo "12345" >>$file
8031 cmp $temp $file || error "$temp $file differ (append1)"
8033 echo "12345" >>$temp
8034 echo "12345" >>$file
8035 cmp $temp $file || error "$temp $file differ (append2)"
8041 test_155_big_load() {
8042 remote_ost_nodsh && skip "remote OST with nodsh" && return
8043 local temp=$TMP/$tfile
8044 local file=$DIR/$tfile
8047 local cache_size=$(do_facet ost$((MAXI+1)) \
8048 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
8049 local large_file_size=$((cache_size * 2))
8051 echo "OSS cache size: $cache_size KB"
8052 echo "Large file size: $large_file_size KB"
8054 [ $MAXV -le $large_file_size ] && \
8055 skip_env "max available OST size needs > $large_file_size KB" && \
8058 $SETSTRIPE $file -c 1 -i $MAXI || error "$SETSTRIPE $file failed"
8060 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k || \
8061 error "dd of=$temp bs=$large_file_size count=1k failed"
8064 cancel_lru_locks osc
8065 cmp $temp $file || error "$temp $file differ"
8073 set_cache writethrough on
8076 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
8080 set_cache writethrough off
8083 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
8087 set_cache writethrough on
8090 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
8094 set_cache writethrough off
8097 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
8101 set_cache writethrough on
8104 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
8108 set_cache writethrough off
8111 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
8115 set_cache writethrough on
8118 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
8122 set_cache writethrough off
8125 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
8131 local file="$DIR/$tfile"
8133 log "Turn on read and write cache"
8135 set_cache writethrough on
8137 log "Write data and read it back."
8138 log "Read should be satisfied from the cache."
8139 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
8141 cancel_lru_locks osc
8142 cat $file >/dev/null
8144 if ! let "AFTER - BEFORE == CPAGES"; then
8145 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
8147 log "cache hits:: before: $BEFORE, after: $AFTER"
8150 log "Read again; it should be satisfied from the cache."
8152 cancel_lru_locks osc
8153 cat $file >/dev/null
8155 if ! let "AFTER - BEFORE == CPAGES"; then
8156 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
8158 log "cache hits:: before: $BEFORE, after: $AFTER"
8162 log "Turn off the read cache and turn on the write cache"
8164 set_cache writethrough on
8166 log "Read again; it should be satisfied from the cache."
8168 cancel_lru_locks osc
8169 cat $file >/dev/null
8171 if ! let "AFTER - BEFORE == CPAGES"; then
8172 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
8174 log "cache hits:: before: $BEFORE, after: $AFTER"
8177 log "Read again; it should not be satisfied from the cache."
8179 cancel_lru_locks osc
8180 cat $file >/dev/null
8182 if ! let "AFTER - BEFORE == 0"; then
8183 error "IN CACHE: before: $BEFORE, after: $AFTER"
8185 log "cache hits:: before: $BEFORE, after: $AFTER"
8188 log "Write data and read it back."
8189 log "Read should be satisfied from the cache."
8190 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
8192 cancel_lru_locks osc
8193 cat $file >/dev/null
8195 if ! let "AFTER - BEFORE == CPAGES"; then
8196 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
8198 log "cache hits:: before: $BEFORE, after: $AFTER"
8201 log "Read again; it should not be satisfied from the cache."
8203 cancel_lru_locks osc
8204 cat $file >/dev/null
8206 if ! let "AFTER - BEFORE == 0"; then
8207 error "IN CACHE: before: $BEFORE, after: $AFTER"
8209 log "cache hits:: before: $BEFORE, after: $AFTER"
8213 log "Turn off read and write cache"
8215 set_cache writethrough off
8217 log "Write data and read it back"
8218 log "It should not be satisfied from the cache."
8220 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
8221 cancel_lru_locks osc
8223 cat $file >/dev/null
8225 if ! let "AFTER - BEFORE == 0"; then
8226 error_ignore 20762 "IN CACHE: before: $BEFORE, after: $AFTER"
8228 log "cache hits:: before: $BEFORE, after: $AFTER"
8232 log "Turn on the read cache and turn off the write cache"
8234 set_cache writethrough off
8236 log "Write data and read it back"
8237 log "It should not be satisfied from the cache."
8239 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
8241 cancel_lru_locks osc
8242 cat $file >/dev/null
8244 if ! let "AFTER - BEFORE == 0"; then
8245 error_ignore 20762 "IN CACHE: before: $BEFORE, after: $AFTER"
8247 log "cache hits:: before: $BEFORE, after: $AFTER"
8250 log "Read again; it should be satisfied from the cache."
8252 cancel_lru_locks osc
8253 cat $file >/dev/null
8255 if ! let "AFTER - BEFORE == CPAGES"; then
8256 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
8258 log "cache hits:: before: $BEFORE, after: $AFTER"
8263 run_test 156 "Verification of tunables ============================"
8267 if [ $MDSCOUNT -gt 1 ]; then
8268 error_ignore 17935 $*
8276 MASK=$(do_facet $SINGLEMDS $LCTL get_param mdd.$MDT0.changelog_mask |\
8279 if [ $MASK -eq 1 ]; then
8280 do_facet $SINGLEMDS $LCTL set_param mdd.$MDT0.changelog_mask="-$1"
8282 do_facet $SINGLEMDS $LCTL set_param mdd.$MDT0.changelog_mask="+$1"
8287 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8288 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
8289 { skip "Need MDS version at least 2.2.0"; return; }
8290 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
8291 echo "Registered as changelog user $USER"
8292 do_facet $SINGLEMDS $LCTL get_param -n mdd.$MDT0.changelog_users | \
8293 grep -q $USER || error "User $USER not found in changelog_users"
8296 mkdir -p $DIR/$tdir/pics/2008/zachy
8297 touch $DIR/$tdir/pics/2008/zachy/timestamp
8298 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
8299 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
8300 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
8301 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
8302 rm $DIR/$tdir/pics/desktop.jpg
8304 $LFS changelog $MDT0 | tail -5
8306 echo "verifying changelog mask"
8307 changelog_chmask "MKDIR"
8308 changelog_chmask "CLOSE"
8310 mkdir -p $DIR/$tdir/pics/zach/sofia
8311 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
8313 changelog_chmask "MKDIR"
8314 changelog_chmask "CLOSE"
8316 mkdir -p $DIR/$tdir/pics/2008/sofia
8317 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
8319 $LFS changelog $MDT0
8320 MKDIRS=$($LFS changelog $MDT0 | tail -5 | grep -c "MKDIR")
8321 CLOSES=$($LFS changelog $MDT0 | tail -5 | grep -c "CLOSE")
8322 [ $MKDIRS -eq 1 ] || err17935 "MKDIR changelog mask count $DIRS != 1"
8323 [ $CLOSES -eq 1 ] || err17935 "CLOSE changelog mask count $DIRS != 1"
8326 echo "verifying target fid"
8327 fidc=$($LFS changelog $MDT0 | grep timestamp | grep "CREAT" | \
8328 tail -1 | awk '{print $6}')
8329 fidf=$($LFS path2fid $DIR/$tdir/pics/zach/timestamp)
8330 [ "$fidc" == "t=$fidf" ] || \
8331 err17935 "fid in changelog $fidc != file fid $fidf"
8332 echo "verifying parent fid"
8333 fidc=$($LFS changelog $MDT0 | grep timestamp | grep "CREAT" | \
8334 tail -1 | awk '{print $7}')
8335 fidf=$($LFS path2fid $DIR/$tdir/pics/zach)
8336 [ "$fidc" == "p=$fidf" ] || \
8337 err17935 "pfid in changelog $fidc != dir fid $fidf"
8339 USER_REC1=$(do_facet $SINGLEMDS $LCTL get_param -n \
8340 mdd.$MDT0.changelog_users | grep $USER | awk '{print $2}')
8341 $LFS changelog_clear $MDT0 $USER $(($USER_REC1 + 5))
8342 USER_REC2=$(do_facet $SINGLEMDS $LCTL get_param -n \
8343 mdd.$MDT0.changelog_users | grep $USER | awk '{print $2}')
8344 echo "verifying user clear: $(( $USER_REC1 + 5 )) == $USER_REC2"
8345 [ $USER_REC2 == $(($USER_REC1 + 5)) ] || \
8346 err17935 "user index should be $(($USER_REC1 + 5)); is $USER_REC2"
8348 MIN_REC=$(do_facet $SINGLEMDS $LCTL get_param mdd.$MDT0.changelog_users | \
8349 awk 'min == "" || $2 < min {min = $2}; END {print min}')
8350 FIRST_REC=$($LFS changelog $MDT0 | head -1 | awk '{print $1}')
8351 echo "verifying min purge: $(( $MIN_REC + 1 )) == $FIRST_REC"
8352 [ $FIRST_REC == $(($MIN_REC + 1)) ] || \
8353 err17935 "first index should be $(($MIN_REC + 1)); is $FIRST_REC"
8355 echo "verifying user deregister"
8356 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
8357 do_facet $SINGLEMDS $LCTL get_param -n mdd.$MDT0.changelog_users | \
8358 grep -q $USER && error "User $USER still found in changelog_users"
8360 USERS=$(( $(do_facet $SINGLEMDS $LCTL get_param -n \
8361 mdd.$MDT0.changelog_users | wc -l) - 2 ))
8362 if [ $USERS -eq 0 ]; then
8363 LAST_REC1=$(do_facet $SINGLEMDS $LCTL get_param -n \
8364 mdd.$MDT0.changelog_users | head -1 | awk '{print $3}')
8365 touch $DIR/$tdir/chloe
8366 LAST_REC2=$(do_facet $SINGLEMDS $LCTL get_param -n \
8367 mdd.$MDT0.changelog_users | head -1 | awk '{print $3}')
8368 echo "verify changelogs are off if we were the only user: $LAST_REC1 == $LAST_REC2"
8369 [ $LAST_REC1 == $LAST_REC2 ] || error "changelogs not off"
8371 echo "$USERS other changelog users; can't verify off"
8374 run_test 160 "changelog sanity"
8378 cp /etc/hosts $DIR/$tdir/$tfile
8379 mkdir $DIR/$tdir/foo1
8380 mkdir $DIR/$tdir/foo2
8381 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
8382 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
8383 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
8384 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
8385 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[')
8386 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
8387 $LFS fid2path $DIR $FID
8388 err17935 "bad link ea"
8391 rm $DIR/$tdir/foo2/zachary
8393 rm $DIR/$tdir/foo2/thor
8395 rm $DIR/$tdir/$tfile
8397 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
8398 if [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ]
8400 $LFS fid2path $DIR $FID
8401 err17935 "bad link rename"
8403 rm $DIR/$tdir/foo2/maggie
8406 local longname=filename_avg_len_is_thirty_two_
8407 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 || \
8408 error "failed to hardlink many files"
8409 links=$($LFS fid2path $DIR $FID | wc -l)
8410 echo -n "${links}/1000 links in link EA"
8411 [ ${links} -gt 60 ] || err17935 "expected at least 60 links in link EA"
8412 unlinkmany $DIR/$tdir/foo2/$longname 1000 || \
8413 error "failed to unlink many hardlinks"
8415 run_test 161 "link ea sanity"
8422 local path=$(${LFS} fid2path $*)
8425 if [ $RC -ne 0 ]; then
8426 err17935 "path looked up of $expected failed. Error $RC"
8428 elif [ "${path}" != "${expected}" ]; then
8429 err17935 "path looked up \"${path}\" instead of \"${expected}\""
8432 echo "fid $fid resolves to path $path (expected $expected)"
8436 # Make changes to filesystem
8437 mkdir -p $DIR/$tdir/d2
8438 touch $DIR/$tdir/d2/$tfile
8439 touch $DIR/$tdir/d2/x1
8440 touch $DIR/$tdir/d2/x2
8441 mkdir -p $DIR/$tdir/d2/a/b/c
8442 mkdir -p $DIR/$tdir/d2/p/q/r
8444 FID=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
8445 check_path "$tdir/d2/$tfile" $FSNAME $FID --link 0
8448 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
8449 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
8450 check_path "$tdir/d2/p/q/r/slink" $FSNAME $FID --link 0
8452 # softlink to wrong file
8453 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
8454 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
8455 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME $FID --link 0
8458 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
8459 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
8460 FID=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
8461 # fid2path dir/fsname should both work
8462 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 1
8463 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR $FID --link 0
8465 # hardlink count: check that there are 2 links
8466 # Doesnt work with CMD yet: 17935
8467 ${LFS} fid2path $DIR $FID | wc -l | grep -q 2 || \
8468 err17935 "expected 2 links"
8470 # hardlink indexing: remove the first link
8471 rm $DIR/$tdir/d2/p/q/r/hlink
8472 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 0
8476 run_test 162 "path lookup sanity"
8479 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8480 copytool --test $FSNAME || { skip "copytool not runnable: $?" && return; }
8483 local uuid=$($LCTL get_param -n mdc.${FSNAME}-MDT0000-mdc-*.uuid)
8484 # this proc file is temporary and linux-only
8485 do_facet $SINGLEMDS lctl set_param mdt.${FSNAME}-MDT0000.mdccomm=$uuid ||\
8486 error "kernel->userspace send failed"
8489 run_test 163 "kernel <-> userspace comms"
8492 # do directio so as not to populate the page cache
8493 log "creating a 10 Mb file"
8494 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
8495 log "starting reads"
8496 dd if=$DIR/$tfile of=/dev/null bs=4096 &
8497 log "truncating the file"
8498 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
8500 kill %+ || true # reads might have finished
8501 echo "wait until dd is finished"
8503 log "removing the temporary file"
8504 rm -rf $DIR/$tfile || error "tmp file removal failed"
8506 run_test 169 "parallel read and truncate should not deadlock"
8509 $LCTL clear # bug 18514
8510 $LCTL debug_daemon start $TMP/${tfile}_log_good
8512 $LCTL debug_daemon stop
8513 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
8514 error "sed failed to read log_good"
8516 $LCTL debug_daemon start $TMP/${tfile}_log_good
8518 $LCTL debug_daemon stop
8520 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
8521 error "lctl df log_bad failed"
8523 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
8524 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
8526 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
8527 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
8529 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
8530 error "bad_line good_line1 good_line2 are empty"
8532 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
8533 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
8534 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
8536 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
8537 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
8538 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
8540 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
8541 error "bad_line_new good_line_new are empty"
8543 local expected_good=$((good_line1 + good_line2*2))
8545 rm -f $TMP/${tfile}*
8546 # LU-231, short malformed line may not be counted into bad lines
8547 if [ $bad_line -ne $bad_line_new ] &&
8548 [ $bad_line -ne $((bad_line_new - 1)) ]; then
8549 error "expected $bad_line bad lines, but got $bad_line_new"
8553 if [ $expected_good -ne $good_line_new ]; then
8554 error "expected $expected_good good lines, but got $good_line_new"
8559 run_test 170 "test lctl df to handle corrupted log ====================="
8561 test_171() { # bug20592
8562 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
8563 $LCTL set_param fail_loc=0x50e
8564 $LCTL set_param fail_val=3000
8565 multiop_bg_pause $DIR/$tfile O_s || true
8567 kill -USR1 $MULTIPID
8571 if dmesg | grep "recursive fault"; then
8572 error "caught a recursive fault"
8574 $LCTL set_param fail_loc=0
8577 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
8579 # it would be good to share it with obdfilter-survey/libecho code
8580 setup_obdecho_osc () {
8583 local obdfilter_name=$2
8584 echo "Creating new osc for $obdfilter_name on $ost_nid"
8585 # make sure we can find loopback nid
8586 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
8588 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
8589 ${obdfilter_name}_osc_UUID || rc=2; }
8590 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
8591 ${obdfilter_name}_UUID $ost_nid || rc=3; }
8595 cleanup_obdecho_osc () {
8596 local obdfilter_name=$1
8597 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
8598 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
8602 obdecho_create_test() {
8607 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
8608 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
8610 if [ $rc -eq 0 ]; then
8611 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
8612 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
8614 echo "New object id is $id"
8615 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec test_brw 10 w v 64 $id" ||
8617 [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec " \
8618 "cleanup" || rc=5; }
8619 [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec " \
8621 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
8626 remote_ost_nodsh && skip "remote OST with nodsh" && return
8630 if ! module_loaded obdecho; then
8631 load_module obdecho/obdecho
8635 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
8636 local host=$(lctl get_param -n osc.$osc.import |
8637 awk '/current_connection:/ {print $2}' )
8638 local target=$(lctl get_param -n osc.$osc.import |
8639 awk '/target:/ {print $2}' )
8640 target=${target%_UUID}
8642 [[ -n $target ]] && { setup_obdecho_osc $host $target || rc=1; } || rc=1
8643 [ $rc -eq 0 ] && { obdecho_create_test ${target}_osc client || rc=2; }
8644 [[ -n $target ]] && cleanup_obdecho_osc $target
8645 [ $rmmod_local -eq 1 ] && rmmod obdecho
8648 run_test 180a "test obdecho on osc"
8651 remote_ost_nodsh && skip "remote OST with nodsh" && return
8653 local rmmod_remote=0
8655 do_facet ost1 "lsmod | grep -q obdecho || " \
8656 "{ insmod ${LUSTRE}/obdecho/obdecho.ko || " \
8657 "modprobe obdecho; }" && rmmod_remote=1
8658 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ {print $4;exit}')
8659 [[ -n $target ]] && { obdecho_create_test $target ost1 || rc=1; }
8660 [ $rmmod_remote -eq 1 ] && do_facet ost1 "rmmod obdecho"
8663 run_test 180b "test obdecho directly on obdfilter"
8665 test_181() { # bug 22177
8666 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
8667 # create enough files to index the directory
8668 createmany -o $DIR/$tdir/foobar 4000
8669 # print attributes for debug purpose
8672 multiop_bg_pause $DIR/$tdir D_Sc || return 1
8674 # remove the files & current working dir
8675 unlinkmany $DIR/$tdir/foobar 4000
8677 kill -USR1 $MULTIPID
8679 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
8682 run_test 181 "Test open-unlinked dir ========================"
8685 # disable MDC RPC lock wouldn't crash client
8689 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
8690 #define OBD_FAIL_MDC_RPCS_SEM 0x804
8691 $LCTL set_param fail_loc=0x804
8693 for (( i=0; i < $tcount; i++ )) ; do
8695 createmany -o $DIR/$tdir/$i/f- $fcount &
8699 for (( i=0; i < $tcount; i++ )) ; do
8700 unlinkmany $DIR/$tdir/$i/f- $fcount &
8706 $LCTL set_param fail_loc=0
8708 run_test 182 "Disable MDC RPCs semaphore wouldn't crash client ================"
8711 check_file_in_pool()
8716 local res=$($GETSTRIPE $file | grep 0x | cut -f2)
8719 for t in $tlist ; do
8720 [ "$i" -eq "$t" ] && continue 2
8723 echo "pool list: $tlist"
8724 echo "striping: $res"
8725 error_noexit "$file not allocated in $pool"
8732 echo "Creating new pool"
8735 create_pool $FSNAME.$pool ||
8736 { error_noexit "No pool created, result code $?"; return 1; }
8737 [ $($LFS pool_list $FSNAME | grep -c $pool) -eq 1 ] ||
8738 { error_noexit "$pool not in lfs pool_list"; return 2; }
8741 pool_add_targets() {
8742 echo "Adding targets to pool"
8748 local list=$(seq $first $step $last)
8750 local t=$(for i in $list; do printf "$FSNAME-OST%04x_UUID " $i; done)
8751 do_facet mgs $LCTL pool_add \
8752 $FSNAME.$pool $FSNAME-OST[$first-$last/$step]
8753 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$pool \
8754 | sort -u | tr '\n' ' ' " "$t" || {
8755 error_noexit "Add to pool failed"
8758 local lfscount=$($LFS pool_list $FSNAME.$pool | grep -c "\-OST")
8759 local addcount=$(((last - first) / step + 1))
8760 [ $lfscount -eq $addcount ] || {
8761 error_noexit "lfs pool_list bad ost count" \
8762 "$lfscount != $addcount"
8770 echo "Setting pool on directory $tdir"
8772 $SETSTRIPE -c 2 -p $pool $tdir && return 0
8774 error_noexit "Cannot set pool $pool to $tdir"
8781 echo "Checking pool on directory $tdir"
8783 local res=$($GETSTRIPE --pool $tdir | sed "s/\s*$//")
8784 [ "$res" = "$pool" ] && return 0
8786 error_noexit "Pool on '$tdir' is '$res', not '$pool'"
8790 pool_dir_rel_path() {
8791 echo "Testing relative path works well"
8796 mkdir -p $root/$tdir/$tdir
8798 pool_set_dir $pool $tdir || return 1
8799 pool_set_dir $pool ./$tdir || return 2
8800 pool_set_dir $pool ../$tdir || return 3
8801 pool_set_dir $pool ../$tdir/$tdir || return 4
8802 rm -rf $tdir; cd - > /dev/null
8805 pool_alloc_files() {
8806 echo "Checking files allocation from directory pool"
8813 for i in $(seq -w 1 $count)
8815 local file=$tdir/file-$i
8817 check_file_in_pool $file $pool "$tlist" || \
8818 failed=$((failed + 1))
8820 [ "$failed" = 0 ] && return 0
8822 error_noexit "$failed files not allocated in $pool"
8826 pool_create_files() {
8827 echo "Creating files in pool"
8835 for i in $(seq -w 1 $count)
8837 local file=$tdir/spoo-$i
8838 $SETSTRIPE -p $pool $file
8839 check_file_in_pool $file $pool "$tlist" || \
8840 failed=$((failed + 1))
8842 [ "$failed" = 0 ] && return 0
8844 error_noexit "$failed files not allocated in $pool"
8849 echo "Checking 'lfs df' output"
8852 local t=$($LCTL get_param -n lov.$FSNAME-clilov-*.pools.$pool |
8854 local res=$($LFS df --pool $FSNAME.$pool |
8856 grep "$FSNAME-OST" |
8858 [ "$res" = "$t" ] && return 0
8860 error_noexit "Pools OSTs '$t' is not '$res' that lfs df reports"
8864 pool_file_rel_path() {
8865 echo "Creating files in a pool with relative pathname"
8870 { error_noexit "unable to create $tdir"; return 1 ; }
8871 local file="/..$tdir/$tfile-1"
8872 $SETSTRIPE -p $pool $file ||
8873 { error_noexit "unable to create $file" ; return 2 ; }
8876 $SETSTRIPE -p $pool $tfile-2 || {
8877 error_noexit "unable to create $tfile-2 in $tdir"
8882 pool_remove_first_target() {
8883 echo "Removing first target from a pool"
8886 local pname="lov.$FSNAME-*.pools.$pool"
8887 local t=$($LCTL get_param -n $pname | head -1)
8888 do_facet mgs $LCTL pool_remove $FSNAME.$pool $t
8889 wait_update $HOSTNAME "lctl get_param -n $pname | grep $t" "" || {
8890 error_noexit "$t not removed from $FSNAME.$pool"
8895 pool_remove_all_targets() {
8896 echo "Removing all targets from pool"
8899 local pname="lov.$FSNAME-*.pools.$pool"
8900 for t in $($LCTL get_param -n $pname | sort -u)
8902 do_facet mgs $LCTL pool_remove $FSNAME.$pool $t
8904 wait_update $HOSTNAME "lctl get_param -n $pname" "" || {
8905 error_noexit "Pool $FSNAME.$pool cannot be drained"
8908 # striping on an empty/nonexistant pool should fall back
8909 # to "pool of everything"
8911 error_noexit "failed to use fallback striping for empty pool"
8914 # setstripe on an empty pool should fail
8915 $SETSTRIPE -p $pool $file 2>/dev/null && {
8916 error_noexit "expected failure when creating file" \
8924 echo "Destroying pool"
8928 do_facet mgs $LCTL pool_destroy $FSNAME.$pool
8931 # striping on an empty/nonexistant pool should fall back
8932 # to "pool of everything"
8934 error_noexit "failed to use fallback striping for missing pool"
8937 # setstripe on an empty pool should fail
8938 $SETSTRIPE -p $pool $file 2>/dev/null && {
8939 error_noexit "expected failure when creating file" \
8944 # get param should return err once pool is gone
8945 if wait_update $HOSTNAME "lctl get_param -n \
8946 lov.$FSNAME-*.pools.$pool 2>/dev/null || echo foo" "foo"
8948 remove_pool_from_list $FSNAME.$pool
8951 error_noexit "Pool $FSNAME.$pool is not destroyed"
8956 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
8958 local POOL=${POOL:-cea1}
8959 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
8960 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
8963 local last_ost=$(($OSTCOUNT - 1))
8965 local ost_list=$(seq $first_ost $ost_step $last_ost)
8966 local ost_range="$first_ost $last_ost $ost_step"
8967 local test_path=$POOL_ROOT/$POOL_DIR_NAME
8968 local file_dir=$POOL_ROOT/file_tst
8972 # former test_200a test_200b
8973 pool_add $POOL || { rc=$? ; break; }
8974 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
8975 # former test_200c test_200d
8977 pool_set_dir $POOL $test_path || { rc=$? ; break; }
8978 pool_check_dir $POOL $test_path || { rc=$? ; break; }
8979 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
8980 || { rc=$? ; break; }
8981 # former test_200e test_200f
8982 local files=$((OSTCOUNT*3))
8983 pool_alloc_files $POOL $test_path $files "$ost_list" \
8984 || { rc=$? ; break; }
8985 pool_create_files $POOL $file_dir $files "$ost_list" \
8986 || { rc=$? ; break; }
8987 # former test_200g test_200h
8988 pool_lfs_df $POOL || { rc=$? ; break; }
8989 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
8991 # former test_201a test_201b test_201c
8992 pool_remove_first_target $POOL || { rc=$? ; break; }
8994 local f=$test_path/$tfile
8995 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
8996 pool_remove $POOL $f || { rc=$? ; break; }
9003 run_test 200 "OST pools"
9005 # usage: default_attr <count | size | offset>
9007 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
9010 # usage: check_default_stripe_attr
9011 check_default_stripe_attr() {
9012 ACTUAL=$($GETSTRIPE $* $DIR/$tdir)
9014 --stripe-count|--count)
9015 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
9016 --stripe-size|--size)
9017 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
9018 --stripe-index|--index)
9021 error "unknown getstripe attr '$1'"
9024 [ $ACTUAL != $EXPECTED ] &&
9025 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
9030 $SETSTRIPE --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
9032 check_default_stripe_attr --stripe-count
9033 check_default_stripe_attr --stripe-size
9034 check_default_stripe_attr --stripe-index
9038 run_test 204a "Print default stripe attributes ================="
9042 $SETSTRIPE --stripe-count 1 $DIR/$tdir
9044 check_default_stripe_attr --stripe-size
9045 check_default_stripe_attr --stripe-index
9049 run_test 204b "Print default stripe size and offset ==========="
9053 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
9055 check_default_stripe_attr --stripe-count
9056 check_default_stripe_attr --stripe-index
9060 run_test 204c "Print default stripe count and offset ==========="
9064 $SETSTRIPE --stripe-index 0 $DIR/$tdir
9066 check_default_stripe_attr --stripe-count
9067 check_default_stripe_attr --stripe-size
9071 run_test 204d "Print default stripe count and size ============="
9075 $SETSTRIPE -d $DIR/$tdir
9077 check_default_stripe_attr --stripe-count --raw
9078 check_default_stripe_attr --stripe-size --raw
9079 check_default_stripe_attr --stripe-index --raw
9083 run_test 204e "Print raw stripe attributes ================="
9087 $SETSTRIPE --stripe-count 1 $DIR/$tdir
9089 check_default_stripe_attr --stripe-size --raw
9090 check_default_stripe_attr --stripe-index --raw
9094 run_test 204f "Print raw stripe size and offset ==========="
9098 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
9100 check_default_stripe_attr --stripe-count --raw
9101 check_default_stripe_attr --stripe-index --raw
9105 run_test 204g "Print raw stripe count and offset ==========="
9109 $SETSTRIPE --stripe-index 0 $DIR/$tdir
9111 check_default_stripe_attr --stripe-count --raw
9112 check_default_stripe_attr --stripe-size --raw
9116 run_test 204h "Print raw stripe count and size ============="
9118 # Figure out which job scheduler is being used, if any,
9120 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
9122 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
9124 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
9126 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
9127 JOBENV=LOADL_STEP_ID
9128 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
9138 # clear old jobstats
9139 do_facet $SINGLEMDS lctl set_param mdt.*.job_stats="clear"
9140 do_facet ost0 lctl set_param obdfilter.*.job_stats="clear"
9142 # use a new JobID for this test, or we might see an old one
9143 [ "$JOBENV" = "FAKE_JOBID" ] && FAKE_JOBID=test_id.$testnum.$RANDOM
9147 log "Using JobID environment variable $JOBENV=$JOBVAL"
9149 if [ $JOBENV = "FAKE_JOBID" ]; then
9150 FAKE_JOBID=$JOBVAL $cmd
9155 if [ "$target" = "mdt" -o "$target" = "both" ]; then
9156 FACET="$SINGLEMDS" # will need to get MDS number for DNE
9157 do_facet $FACET lctl get_param mdt.*.job_stats |
9158 grep $JOBVAL || error "No job stats found on MDT $FACET"
9160 if [ "$target" = "ost" -o "$target" = "both" ]; then
9162 do_facet $FACET lctl get_param obdfilter.*.job_stats |
9163 grep $JOBVAL || error "No job stats found on OST $FACET"
9167 test_205() { # Job stats
9168 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
9169 skip "Server doesn't support jobstats" && return 0
9172 OLD_JOBENV=`$LCTL get_param -n jobid_var`
9173 if [ $OLD_JOBENV != $JOBENV ]; then
9174 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$JOBENV
9175 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" \
9180 cmd="mkdir $DIR/$tfile"
9181 verify_jobstats "$cmd" "mdt"
9183 cmd="rm -fr $DIR/$tfile"
9184 verify_jobstats "$cmd" "mdt"
9186 cmd="mknod $DIR/$tfile c 1 3"
9187 verify_jobstats "$cmd" "mdt"
9189 cmd="rm -f $DIR/$tfile"
9190 verify_jobstats "$cmd" "mdt"
9192 cmd="$SETSTRIPE -i 0 -c 1 $DIR/$tfile"
9193 verify_jobstats "$cmd" "mdt"
9195 cmd="touch $DIR/$tfile"
9196 verify_jobstats "$cmd" "both"
9198 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
9199 verify_jobstats "$cmd" "ost"
9201 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
9202 verify_jobstats "$cmd" "ost"
9204 cmd="$TRUNCATE $DIR/$tfile 0"
9205 verify_jobstats "$cmd" "both"
9207 cmd="mv -f $DIR/$tfile $DIR/jobstats_test_rename"
9208 verify_jobstats "$cmd" "mdt"
9211 rm -f $DIR/jobstats_test_rename
9213 if [ $OLD_JOBENV != $JOBENV ]; then
9214 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$OLD_JOBENV
9215 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" \
9216 $OLD_JOBENV || return 1
9219 run_test 205 "Verify job stats"
9221 # LU-1480, LU-1773 and LU-1657
9224 lfs setstripe -c -1 $DIR/$tdir
9225 #define OBD_FAIL_LOV_INIT 0x1403
9226 $LCTL set_param fail_loc=0xa0001403
9227 $LCTL set_param fail_val=1
9228 touch $DIR/$tdir/$tfile || true
9230 run_test 206 "fail lov_init_raid0() doesn't lbug"
9234 size=$((size % 8192 + 1))
9235 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
9236 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
9237 rm -f $DIR/f212 $DIR/f212.xyz
9239 run_test 212 "Sendfile test ============================================"
9242 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
9243 cancel_lru_locks osc
9244 lctl set_param fail_loc=0x8000040f
9245 # generate a read lock
9246 cat $DIR/$tfile > /dev/null
9247 # write to the file, it will try to cancel the above read lock.
9248 cat /etc/hosts >> $DIR/$tfile
9250 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
9252 test_214() { # for bug 20133
9253 mkdir -p $DIR/d214p/d214c
9254 for (( i=0; i < 340; i++ )) ; do
9255 touch $DIR/d214p/d214c/a$i
9258 ls -l $DIR/d214p || error "ls -l $DIR/d214p failed"
9259 mv $DIR/d214p/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
9260 ls $DIR/d214c || error "ls $DIR/d214c failed"
9261 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
9263 run_test 214 "hash-indexed directory test - bug 20133"
9265 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
9266 create_lnet_proc_files() {
9267 cat /proc/sys/lnet/$1 >$TMP/lnet_$1.out || error "cannot read /proc/sys/lnet/$1"
9268 sysctl lnet.$1 >$TMP/lnet_$1.sys_tmp || error "cannot read lnet.$1"
9270 sed "s/^lnet.$1\ =\ //g" "$TMP/lnet_$1.sys_tmp" >$TMP/lnet_$1.sys
9271 rm -f "$TMP/lnet_$1.sys_tmp"
9274 # counterpart of create_lnet_proc_files
9275 remove_lnet_proc_files() {
9276 rm -f $TMP/lnet_$1.out $TMP/lnet_$1.sys
9279 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
9280 # 3rd arg as regexp for body
9281 check_lnet_proc_stats() {
9282 local l=$(cat "$TMP/lnet_$1" |wc -l)
9283 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
9285 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
9288 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
9289 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
9290 # optional and can be regexp for 2nd line (lnet.routes case)
9291 check_lnet_proc_entry() {
9292 local blp=2 # blp stands for 'position of 1st line of body'
9293 [ "$5" = "" ] || blp=3 # lnet.routes case
9295 local l=$(cat "$TMP/lnet_$1" |wc -l)
9296 # subtracting one from $blp because the body can be empty
9297 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
9299 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
9300 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
9302 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
9303 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
9305 # bail out if any unexpected line happened
9306 sed -n "$blp~1 p" "$TMP/lnet_$1" |grep -Ev "$3"
9307 [ "$?" != 0 ] || error "$2 misformatted"
9310 test_215() { # for bugs 18102, 21079, 21517
9311 local N='(0|[1-9][0-9]*)' # non-negative numeric
9312 local P='[1-9][0-9]*' # positive numeric
9313 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
9314 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
9315 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
9316 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
9318 local L1 # regexp for 1st line
9319 local L2 # regexp for 2nd line (optional)
9320 local BR # regexp for the rest (body)
9322 # /proc/sys/lnet/stats should look as 11 space-separated non-negative numerics
9323 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
9324 create_lnet_proc_files "stats"
9325 check_lnet_proc_stats "stats.out" "/proc/sys/lnet/stats" "$BR"
9326 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
9327 remove_lnet_proc_files "stats"
9329 # /proc/sys/lnet/routes should look like this:
9330 # Routing disabled/enabled
9331 # net hops state router
9332 # where net is a string like tcp0, hops >= 0, state is up/down,
9333 # router is a string like 192.168.1.1@tcp2
9334 L1="^Routing (disabled|enabled)$"
9335 L2="^net +hops +state +router$"
9336 BR="^$NET +$N +(up|down) +$NID$"
9337 create_lnet_proc_files "routes"
9338 check_lnet_proc_entry "routes.out" "/proc/sys/lnet/routes" "$BR" "$L1" "$L2"
9339 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
9340 remove_lnet_proc_files "routes"
9342 # /proc/sys/lnet/routers should look like this:
9343 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
9344 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
9345 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
9346 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
9347 L1="^ref +rtr_ref +alive_cnt +state +last_ping +ping_sent +deadline +down_ni +router$"
9348 BR="^$P +$P +$N +(up|down) +$N +(0|1) +$I +$I +$NID$"
9349 create_lnet_proc_files "routers"
9350 check_lnet_proc_entry "routers.out" "/proc/sys/lnet/routers" "$BR" "$L1"
9351 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
9352 remove_lnet_proc_files "routers"
9354 # /proc/sys/lnet/peers should look like this:
9355 # nid refs state last max rtr min tx min queue
9356 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
9357 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
9358 # numeric (0 or >0 or <0), queue >= 0.
9359 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
9360 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
9361 create_lnet_proc_files "peers"
9362 check_lnet_proc_entry "peers.out" "/proc/sys/lnet/peers" "$BR" "$L1"
9363 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
9364 remove_lnet_proc_files "peers"
9366 # /proc/sys/lnet/buffers should look like this:
9367 # pages count credits min
9368 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
9369 L1="^pages +count +credits +min$"
9370 BR="^ +$N +$N +$I +$I$"
9371 create_lnet_proc_files "buffers"
9372 check_lnet_proc_entry "buffers.out" "/proc/sys/lnet/buffers" "$BR" "$L1"
9373 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
9374 remove_lnet_proc_files "buffers"
9376 # /proc/sys/lnet/nis should look like this:
9377 # nid status alive refs peer rtr max tx min
9378 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
9379 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
9380 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
9381 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
9382 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
9383 create_lnet_proc_files "nis"
9384 check_lnet_proc_entry "nis.out" "/proc/sys/lnet/nis" "$BR" "$L1"
9385 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
9386 remove_lnet_proc_files "nis"
9388 # can we successfully write to /proc/sys/lnet/stats?
9389 echo "0" >/proc/sys/lnet/stats || error "cannot write to /proc/sys/lnet/stats"
9390 sysctl -w lnet.stats=0 || error "cannot write to lnet.stats"
9392 run_test 215 "/proc/sys/lnet exists and has proper content - bugs 18102, 21079, 21517"
9394 test_216() { # bug 20317
9395 remote_ost_nodsh && skip "remote OST with nodsh" && return
9397 local p="$TMP/sanityN-$TESTNAME.parameters"
9398 save_lustre_params $HOSTNAME "osc.*.contention_seconds" > $p
9399 for node in $(osts_nodes); do
9400 save_lustre_params $node "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
9401 save_lustre_params $node "ldlm.namespaces.filter-*.contended_locks" >> $p
9402 save_lustre_params $node "ldlm.namespaces.filter-*.contention_seconds" >> $p
9406 # agressive lockless i/o settings
9407 for node in $(osts_nodes); do
9408 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'
9410 lctl set_param -n osc.*.contention_seconds 60
9412 $DIRECTIO write $DIR/$tfile 0 10 4096
9413 $CHECKSTAT -s 40960 $DIR/$tfile
9415 # disable lockless i/o
9416 for node in $(osts_nodes); do
9417 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'
9419 lctl set_param -n osc.*.contention_seconds 0
9422 dd if=/dev/zero of=$DIR/$tfile count=0
9423 $CHECKSTAT -s 0 $DIR/$tfile
9425 restore_lustre_params <$p
9429 run_test 216 "check lockless direct write works and updates file size and kms correctly"
9431 test_217() { # bug 22430
9435 for node in $(nodes_list); do
9436 nid=$(host_nids_address $node $NETTYPE)
9437 if [[ $nid = *-* ]] ; then
9438 echo "lctl ping $nid@$NETTYPE"
9439 lctl ping $nid@$NETTYPE
9441 echo "skipping $node (no hyphen detected)"
9445 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
9448 # do directio so as not to populate the page cache
9449 log "creating a 10 Mb file"
9450 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
9451 log "starting reads"
9452 dd if=$DIR/$tfile of=/dev/null bs=4096 &
9453 log "truncating the file"
9454 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
9456 kill %+ || true # reads might have finished
9457 echo "wait until dd is finished"
9459 log "removing the temporary file"
9460 rm -rf $DIR/$tfile || error "tmp file removal failed"
9462 run_test 218 "parallel read and truncate should not deadlock ======================="
9465 # write one partial page
9466 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
9467 # set no grant so vvp_io_commit_write will do sync write
9468 $LCTL set_param fail_loc=0x411
9469 # write a full page at the end of file
9470 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
9472 $LCTL set_param fail_loc=0
9473 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
9474 $LCTL set_param fail_loc=0x411
9475 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
9477 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
9479 test_220() { #LU-325
9480 remote_ost_nodsh && skip "remote OST with nodsh" && return
9484 local OST=$(lfs osts | grep ${OSTIDX}": " | \
9485 awk '{print $2}' | sed -e 's/_UUID$//')
9488 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
9489 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
9490 osc.$mdtosc_proc1.prealloc_last_id)
9491 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
9492 osc.$mdtosc_proc1.prealloc_next_id)
9496 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
9497 #define OBD_FAIL_OST_ENOINO 0x229
9498 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
9499 do_facet mgs $LCTL pool_new $FSNAME.$TESTNAME || return 1
9500 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
9502 $SETSTRIPE $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
9504 MDSOBJS=$((last_id - next_id))
9505 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
9507 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
9508 echo "OST still has $count kbytes free"
9510 echo "create $MDSOBJS files @next_id..."
9511 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
9513 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
9514 osc.$mdtosc_proc1.prealloc_last_id)
9515 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
9516 osc.$mdtosc_proc1.prealloc_next_id)
9518 echo "after creation, last_id=$last_id2, next_id=$next_id2"
9523 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
9524 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
9526 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST || return 4
9527 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME || return 5
9528 echo "unlink $MDSOBJS files @$next_id..."
9529 unlinkmany $DIR/$tdir/f $MDSOBJS || return 6
9531 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
9534 dd if=`which date` of=$MOUNT/date oflag=sync
9535 chmod +x $MOUNT/date
9537 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
9538 $LCTL set_param fail_loc=0x80001401
9540 $MOUNT/date > /dev/null
9543 run_test 221 "make sure fault and truncate race to not cause OOM"
9548 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
9549 createmany -o $DIR/$tdir/$tfile 10
9550 cancel_lru_locks mdc
9551 cancel_lru_locks osc
9552 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
9553 $LCTL set_param fail_loc=0x31a
9554 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
9555 $LCTL set_param fail_loc=0
9558 run_test 222a "AGL for ls should not trigger CLIO lock failure ================"
9563 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
9564 createmany -o $DIR/$tdir/$tfile 10
9565 cancel_lru_locks mdc
9566 cancel_lru_locks osc
9567 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
9568 $LCTL set_param fail_loc=0x31a
9569 rm -r $DIR/$tdir || "AGL for rmdir failed"
9570 $LCTL set_param fail_loc=0
9572 run_test 222b "AGL for rmdir should not trigger CLIO lock failure ============="
9577 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
9578 createmany -o $DIR/$tdir/$tfile 10
9579 cancel_lru_locks mdc
9580 cancel_lru_locks osc
9581 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
9582 $LCTL set_param fail_loc=0x31b
9583 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
9584 $LCTL set_param fail_loc=0
9587 run_test 223 "osc reenqueue if without AGL lock granted ======================="
9589 test_224a() { # LU-1039, MRP-303
9590 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
9591 $LCTL set_param fail_loc=0x508
9592 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
9593 $LCTL set_param fail_loc=0
9596 run_test 224a "Don't panic on bulk IO failure"
9598 test_224b() { # LU-1039, MRP-303
9599 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
9600 cancel_lru_locks osc
9601 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
9602 $LCTL set_param fail_loc=0x515
9603 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
9604 $LCTL set_param fail_loc=0
9607 run_test 224b "Don't panic on bulk IO failure"
9609 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
9611 if [ -z ${MDSSURVEY} ]; then
9612 skip_env "mds-survey not found" && return
9614 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
9615 { skip "Need MDS version at least 2.2.51"; return; }
9617 local mds=$(facet_host $SINGLEMDS)
9618 local target=$(do_nodes $mds 'lctl dl' | \
9619 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
9621 local cmd1="file_count=1000 thrhi=4"
9622 local cmd2="dir_count=2 layer=mdd stripe_count=0"
9623 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
9624 local cmd="$cmd1 $cmd2 $cmd3"
9626 rm -f ${TMP}/mds_survey*
9628 eval $cmd || error "mds-survey with zero-stripe failed"
9629 cat ${TMP}/mds_survey*
9630 rm -f ${TMP}/mds_survey*
9632 run_test 225a "Metadata survey sanity with zero-stripe"
9635 if [ -z ${MDSSURVEY} ]; then
9636 skip_env "mds-survey not found" && return
9638 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
9639 { skip "Need MDS version at least 2.2.51"; return; }
9641 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
9642 skip_env "Need to mount OST to test" && return
9645 local mds=$(facet_host $SINGLEMDS)
9646 local target=$(do_nodes $mds 'lctl dl' | \
9647 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
9649 local cmd1="file_count=1000 thrhi=4"
9650 local cmd2="dir_count=2 layer=mdd stripe_count=1"
9651 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
9652 local cmd="$cmd1 $cmd2 $cmd3"
9654 rm -f ${TMP}/mds_survey*
9656 eval $cmd || error "mds-survey with stripe_count failed"
9657 cat ${TMP}/mds_survey*
9658 rm -f ${TMP}/mds_survey*
9660 run_test 225b "Metadata survey sanity with stripe_count = 1"
9662 mcreate_path2fid () {
9668 local path=$DIR/$tdir/$name
9673 $MCREATE --mode=$1 --major=$2 --minor=$3 $path || \
9674 error "error: cannot create $desc"
9676 fid=$($LFS path2fid $path)
9678 [ $rc -ne 0 ] && error "error: cannot get fid of a $desc"
9680 fid_path=$($LFS fid2path $DIR $fid)
9682 [ $rc -ne 0 ] && error "error: cannot get path of a $desc by fid"
9684 [ "$path" == "$fid_path" ] || \
9685 error "error: fid2path returned \`$fid_path', expected \`$path'"
9692 mcreate_path2fid 0010666 0 0 fifo "FIFO"
9693 mcreate_path2fid 0020666 1 3 null "character special file (null)"
9694 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
9695 mcreate_path2fid 0040666 0 0 dir "directory"
9696 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
9697 mcreate_path2fid 0100666 0 0 file "regular file"
9698 mcreate_path2fid 0120666 0 0 link "symbolic link"
9699 mcreate_path2fid 0140666 0 0 sock "socket"
9701 run_test 226 "call path2fid and fid2path on files of all type"
9703 # LU-1299 Executing or running ldd on a truncated executable does not
9704 # cause an out-of-memory condition.
9706 dd if=`which date` of=$MOUNT/date bs=1k count=1
9707 chmod +x $MOUNT/date
9709 $MOUNT/date > /dev/null
9710 ldd $MOUNT/date > /dev/null
9713 run_test 227 "running truncated executable does not cause OOM"
9715 # LU-1512 try to reuse idle OI blocks
9717 [ "$FSTYPE" != "ldiskfs" ] && skip "non-ldiskfs backend" && return
9719 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
9720 local myDIR=$DIR/$tdir
9723 #define OBD_FAIL_SEQ_EXHAUST 0x1002
9724 $LCTL set_param fail_loc=0x80001002
9725 createmany -o $myDIR/t- 10000
9726 $LCTL set_param fail_loc=0
9727 # The guard is current the largest FID holder
9729 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
9731 local IDX=$(($SEQ % 64))
9733 do_facet $SINGLEMDS sync
9734 # Make sure journal flushed.
9736 local blk1=$(do_facet $SINGLEMDS \
9737 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
9738 grep Blockcount | awk '{print $4}')
9740 # Remove old files, some OI blocks will become idle.
9741 unlinkmany $myDIR/t- 10000
9742 # Create new files, idle OI blocks should be reused.
9743 createmany -o $myDIR/t- 2000
9744 do_facet $SINGLEMDS sync
9745 # Make sure journal flushed.
9747 local blk2=$(do_facet $SINGLEMDS \
9748 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
9749 grep Blockcount | awk '{print $4}')
9751 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
9753 run_test 228a "try to reuse idle OI blocks"
9756 [ "$FSTYPE" != "ldiskfs" ] && skip "non-ldiskfs backend" && return
9758 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
9759 local myDIR=$DIR/$tdir
9762 #define OBD_FAIL_SEQ_EXHAUST 0x1002
9763 $LCTL set_param fail_loc=0x80001002
9764 createmany -o $myDIR/t- 10000
9765 $LCTL set_param fail_loc=0
9766 # The guard is current the largest FID holder
9768 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
9770 local IDX=$(($SEQ % 64))
9772 do_facet $SINGLEMDS sync
9773 # Make sure journal flushed.
9775 local blk1=$(do_facet $SINGLEMDS \
9776 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
9777 grep Blockcount | awk '{print $4}')
9779 # Remove old files, some OI blocks will become idle.
9780 unlinkmany $myDIR/t- 10000
9783 stop $SINGLEMDS || error "Fail to stop MDT."
9785 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
9787 df $MOUNT || error "Fail to df."
9788 # Create new files, idle OI blocks should be reused.
9789 createmany -o $myDIR/t- 2000
9790 do_facet $SINGLEMDS sync
9791 # Make sure journal flushed.
9793 local blk2=$(do_facet $SINGLEMDS \
9794 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
9795 grep Blockcount | awk '{print $4}')
9797 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
9799 run_test 228b "idle OI blocks can be reused after MDT restart"
9803 [ "$FSTYPE" != "ldiskfs" ] && skip "non-ldiskfs backend" && return
9805 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
9806 local myDIR=$DIR/$tdir
9809 #define OBD_FAIL_SEQ_EXHAUST 0x1002
9810 $LCTL set_param fail_loc=0x80001002
9811 # 20000 files can guarantee there are index nodes in the OI file
9812 createmany -o $myDIR/t- 20000
9813 $LCTL set_param fail_loc=0
9814 # The guard is current the largest FID holder
9816 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
9818 local IDX=$(($SEQ % 64))
9820 do_facet $SINGLEMDS sync
9821 # Make sure journal flushed.
9823 local blk1=$(do_facet $SINGLEMDS \
9824 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
9825 grep Blockcount | awk '{print $4}')
9827 # Remove old files, some OI blocks will become idle.
9828 unlinkmany $myDIR/t- 20000
9830 # The OI file should become empty now
9832 # Create new files, idle OI blocks should be reused.
9833 createmany -o $myDIR/t- 2000
9834 do_facet $SINGLEMDS sync
9835 # Make sure journal flushed.
9837 local blk2=$(do_facet $SINGLEMDS \
9838 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
9839 grep Blockcount | awk '{print $4}')
9841 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
9843 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
9846 # tests that do cleanup/setup should be run at the end
9851 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
9852 $LCTL set_param fail_loc=0x903
9853 # cancel_lru_locks mgc - does not work due to lctl set_param syntax
9854 for ls in /proc/fs/lustre/ldlm/namespaces/MGC*/lru_size; do
9857 FAIL_ON_ERROR=true cleanup
9858 FAIL_ON_ERROR=true setup
9860 run_test 900 "umount should not race with any mgc requeue thread"
9862 complete $(basename $0) $SECONDS
9863 check_and_cleanup_lustre
9864 if [ "$I_MOUNTED" != "yes" ]; then
9865 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true