2 # -*- tab-width: 4; indent-tabs-mode: t; -*-
4 # Run select tests by setting ONLY, or as arguments to the script.
5 # Skip specific tests by setting EXCEPT.
7 # e.g. ONLY="22 23" or ONLY="`seq 32 39`" or EXCEPT="31"
11 # bug number for skipped test: 13297 2108 9789 3637 9789 3561 12622 5188
12 ALWAYS_EXCEPT=" 27u 42a 42b 42c 42d 45 51d 68b $SANITY_EXCEPT"
13 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
15 # with LOD/OSP landing
16 # bug number for skipped tests: LU-2036
17 ALWAYS_EXCEPT=" 76 $ALWAYS_EXCEPT"
20 # Tests that fail on uml
21 CPU=`awk '/model/ {print $4}' /proc/cpuinfo`
22 # buffer i/o errs sock spc runas
23 [ "$CPU" = "UML" ] && EXCEPT="$EXCEPT 27m 27n 27o 27p 27q 27r 31d 54a 64b 99a 99b 99c 99d 99e 99f 101a"
25 SRCDIR=$(cd $(dirname $0); echo $PWD)
26 export PATH=$PATH:/sbin
30 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
31 CREATETEST=${CREATETEST:-createtest}
33 LFIND=${LFIND:-"$LFS find"}
34 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
36 MCREATE=${MCREATE:-mcreate}
37 OPENFILE=${OPENFILE:-openfile}
38 OPENUNLINK=${OPENUNLINK:-openunlink}
39 export MULTIOP=${MULTIOP:-multiop}
40 READS=${READS:-"reads"}
41 MUNLINK=${MUNLINK:-munlink}
42 SOCKETSERVER=${SOCKETSERVER:-socketserver}
43 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
44 MEMHOG=${MEMHOG:-memhog}
45 DIRECTIO=${DIRECTIO:-directio}
46 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
47 UMOUNT=${UMOUNT:-"umount -d"}
49 CHECK_GRANT=${CHECK_GRANT:-"yes"}
50 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
52 export NAME=${NAME:-local}
59 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
60 . $LUSTRE/tests/test-framework.sh
62 . ${CONFIG:=$LUSTRE/tests/cfg/${NAME}.sh}
65 [ "$SLOW" = "no" ] && EXCEPT_SLOW="24o 24v 27m 36f 36g 36h 51b 60c 63 64b 68 71 73 77f 78 101a 103 115 120g 124b"
71 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
72 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
81 check_kernel_version() {
83 GOT_VER=$(lctl get_param -n version | awk '/kernel:/ {print $2}')
85 patchless|patchless_client) return 0;;
86 *) [ $GOT_VER -ge $WANT_VER ] && return 0 ;;
88 log "test needs at least kernel version $WANT_VER, running $GOT_VER"
92 if [ "$ONLY" == "cleanup" ]; then
97 check_and_setup_lustre
102 MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid | \
103 awk '{gsub(/_UUID/,""); print $1}' | head -1)
104 LOVNAME=$($LCTL get_param -n llite.*.lov.common_name | tail -n 1)
105 OSTCOUNT=$($LCTL get_param -n lov.$LOVNAME.numobd)
106 STRIPECOUNT=$($LCTL get_param -n lov.$LOVNAME.stripecount)
107 STRIPESIZE=$($LCTL get_param -n lov.$LOVNAME.stripesize)
108 ORIGFREE=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
109 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
111 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
112 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
113 rm -rf $DIR/[Rdfs][0-9]*
115 # $RUNAS_ID may get set incorrectly somewhere else
116 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
118 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
122 if [ "${ONLY}" = "MOUNT" ] ; then
123 echo "Lustre is up, please go on"
127 echo "preparing for tests involving mounts"
128 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
130 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
131 echo # add a newline after mke2fs.
135 OLDDEBUG="`lctl get_param -n debug 2> /dev/null`"
136 lctl set_param debug=-1 2> /dev/null || true
139 $CHECKSTAT -t file $DIR/$tfile || error
141 $CHECKSTAT -a $DIR/$tfile || error
143 run_test 0 "touch .../$tfile ; rm .../$tfile ====================="
146 chmod 0755 $DIR || error
147 $CHECKSTAT -p 0755 $DIR || error
149 run_test 0b "chmod 0755 $DIR ============================="
152 $LCTL get_param mdc.*.import | grep "state: FULL" || error "import not FULL"
153 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" || error "bad target"
155 run_test 0c "check import proc ============================="
160 mkdir $DIR/d1/d2 && error "we expect EEXIST, but not returned"
161 $CHECKSTAT -t dir $DIR/d1/d2 || error
163 run_test 1a "mkdir .../d1; mkdir .../d1/d2 ====================="
168 $CHECKSTAT -a $DIR/d1 || error
170 run_test 1b "rmdir .../d1/d2; rmdir .../d1 ====================="
175 $CHECKSTAT -t file $DIR/d2/f || error
177 run_test 2a "mkdir .../d2; touch .../d2/f ======================"
181 $CHECKSTAT -a $DIR/d2 || error
183 run_test 2b "rm -r .../d2; checkstat .../d2/f ======================"
187 $CHECKSTAT -t dir $DIR/d3 || error
189 run_test 3a "mkdir .../d3 ======================================"
192 if [ ! -d $DIR/d3 ]; then
196 $CHECKSTAT -t file $DIR/d3/f || error
198 run_test 3b "touch .../d3/f ===================================="
202 $CHECKSTAT -a $DIR/d3 || error
204 run_test 3c "rm -r .../d3 ======================================"
208 $CHECKSTAT -t dir $DIR/d4 || error
210 run_test 4a "mkdir .../d4 ======================================"
213 if [ ! -d $DIR/d4 ]; then
217 $CHECKSTAT -t dir $DIR/d4/d2 || error
219 run_test 4b "mkdir .../d4/d2 ==================================="
224 chmod 0707 $DIR/d5/d2
225 $CHECKSTAT -t dir -p 0707 $DIR/d5/d2 || error
227 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2 ============"
231 chmod 0666 $DIR/f6a || error
232 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/f6a || error
234 run_test 6a "touch .../f6a; chmod .../f6a ======================"
237 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
238 if [ ! -f $DIR/f6a ]; then
242 $RUNAS chmod 0444 $DIR/f6a && error
243 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/f6a || error
245 run_test 6b "$RUNAS chmod .../f6a (should return error) =="
248 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
250 chown $RUNAS_ID $DIR/f6c || error
251 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/f6c || error
253 run_test 6c "touch .../f6c; chown .../f6c ======================"
256 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
257 if [ ! -f $DIR/f6c ]; then
259 chown $RUNAS_ID $DIR/f6c
261 $RUNAS chown $UID $DIR/f6c && error
262 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/f6c || error
264 run_test 6d "$RUNAS chown .../f6c (should return error) =="
267 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
269 chgrp $RUNAS_ID $DIR/f6e || error
270 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/f6e || error
272 run_test 6e "touch .../f6e; chgrp .../f6e ======================"
275 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
276 if [ ! -f $DIR/f6e ]; then
278 chgrp $RUNAS_ID $DIR/f6e
280 $RUNAS chgrp $UID $DIR/f6e && error
281 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/f6e || error
283 run_test 6f "$RUNAS chgrp .../f6e (should return error) =="
286 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
287 mkdir $DIR/d6g || error
288 chmod 777 $DIR/d6g || error
289 $RUNAS mkdir $DIR/d6g/d || error
290 chmod g+s $DIR/d6g/d || error
291 mkdir $DIR/d6g/d/subdir
292 $CHECKSTAT -g \#$RUNAS_GID $DIR/d6g/d/subdir || error
294 run_test 6g "Is new dir in sgid dir inheriting group?"
296 test_6h() { # bug 7331
297 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
298 touch $DIR/f6h || error "touch failed"
299 chown $RUNAS_ID:$RUNAS_GID $DIR/f6h || error "initial chown failed"
300 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/f6h && error "chown worked"
301 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/f6h || error
303 run_test 6h "$RUNAS chown RUNAS_ID.0 .../f6h (should return error)"
309 $CHECKSTAT -t file -p 0666 $DIR/d7/f || error
311 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
314 if [ ! -d $DIR/d7 ]; then
318 echo -n foo > $DIR/d7/f2
319 [ "`cat $DIR/d7/f2`" = "foo" ] || error
320 $CHECKSTAT -t file -s 3 $DIR/d7/f2 || error
322 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
328 $CHECKSTAT -t file -p 0666 $DIR/d8/f || error
330 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
336 $CHECKSTAT -t dir $DIR/d9/d2/d3 || error
338 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
344 $CHECKSTAT -t file $DIR/d10/d2/f || error
346 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
351 chmod 0666 $DIR/d11/d2
352 chmod 0705 $DIR/d11/d2
353 $CHECKSTAT -t dir -p 0705 $DIR/d11/d2 || error
355 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
360 chmod 0666 $DIR/d12/f
361 chmod 0654 $DIR/d12/f
362 $CHECKSTAT -t file -p 0654 $DIR/d12/f || error
364 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
368 dd if=/dev/zero of=$DIR/d13/f count=10
370 $CHECKSTAT -t file -s 0 $DIR/d13/f || error
372 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
378 $CHECKSTAT -a $DIR/d14/f || error
380 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
385 mv $DIR/d15/f $DIR/d15/f2
386 $CHECKSTAT -t file $DIR/d15/f2 || error
388 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
394 $CHECKSTAT -a $DIR/d16/f || error
396 run_test 16 "touch .../d16/f; rm -rf .../d16/f ================="
401 ln -s $DIR/d17/f $DIR/d17/l-exist
403 $CHECKSTAT -l $DIR/d17/f $DIR/d17/l-exist || error
404 $CHECKSTAT -f -t f $DIR/d17/l-exist || error
405 rm -f $DIR/d17/l-exist
406 $CHECKSTAT -a $DIR/d17/l-exist || error
408 run_test 17a "symlinks: create, remove (real) =================="
412 ln -s no-such-file $DIR/d17/l-dangle
414 $CHECKSTAT -l no-such-file $DIR/d17/l-dangle || error
415 $CHECKSTAT -fa $DIR/d17/l-dangle || error
416 rm -f $DIR/d17/l-dangle
417 $CHECKSTAT -a $DIR/d17/l-dangle || error
419 run_test 17b "symlinks: create, remove (dangling) =============="
421 test_17c() { # bug 3440 - don't save failed open RPC for replay
423 ln -s foo $DIR/d17/f17c
424 cat $DIR/d17/f17c && error "opened non-existent symlink" || true
426 run_test 17c "symlinks: open dangling (should return error) ===="
430 ln -s foo $DIR/d17/f17d
431 touch $DIR/d17/f17d || error "creating to new symlink"
433 run_test 17d "symlinks: create dangling ========================"
437 local foo=$DIR/$tdir/$tfile
438 ln -s $foo $foo || error "create symlink failed"
439 ls -l $foo || error "ls -l failed"
440 ls $foo && error "ls not failed" || true
442 run_test 17e "symlinks: create recursive symlink (should return error) ===="
446 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/d17f/111
447 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/d17f/222
448 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/d17f/333
449 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/d17f/444
450 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/d17f/555
451 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
454 run_test 17f "symlinks: long and very long symlink name ========================"
456 # str_repeat(S, N) generate a string that is string S repeated N times
461 while [ $((n -= 1)) -ge 0 ]; do
467 # Long symlinks and LU-2241
470 local TESTS="59 60 61 4094 4095"
473 local SYMNAME=$(str_repeat 'x' $i)
474 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
475 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
478 run_test 17g "symlinks: really long symlink name and inode boundaries"
480 test_17h() { #bug 17378
481 remote_mds_nodsh && skip "remote MDS with nodsh" && return
483 $SETSTRIPE -c -1 $DIR/$tdir
484 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
485 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000141
486 touch $DIR/$tdir/$tfile || true
488 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
490 test_17i() { #bug 20018
491 remote_mds_nodsh && skip "remote MDS with nodsh" && return
493 local foo=$DIR/$tdir/$tfile
494 ln -s $foo $foo || error "create symlink failed"
495 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
496 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000143
497 ls -l $foo && error "error not detected"
500 run_test 17i "don't panic on short symlink"
502 test_17k() { #bug 22301
503 rsync --help | grep -q xattr ||
504 skip_env "$(rsync --version| head -1) does not support xattrs"
505 mkdir -p $DIR/{$tdir,$tdir.new}
506 touch $DIR/$tdir/$tfile
507 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
508 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
509 error "rsync failed with xattrs enabled"
511 run_test 17k "symlinks: rsync with xattrs enabled ========================="
515 local short_sym="0123456789"
516 local WDIR=$DIR/${tdir}m
523 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
524 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
525 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
527 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
528 skip "only for ldiskfs MDT" && return 0
532 # create a long symlink file
533 for ((i = 0; i < 4; ++i)); do
534 long_sym=${long_sym}${long_sym}
537 echo "create 512 short and long symlink files under $WDIR"
538 for ((i = 0; i < 256; ++i)); do
539 ln -sf ${long_sym}"a5a5" $WDIR/long-$i
540 ln -sf ${short_sym}"a5a5" $WDIR/short-$i
546 wait_delete_completed
548 echo "recreate the 512 symlink files with a shorter string"
549 for ((i = 0; i < 512; ++i)); do
550 # rewrite the symlink file with a shorter string
551 ln -sf ${long_sym} $WDIR/long-$i
552 ln -sf ${short_sym} $WDIR/short-$i
555 mds_index=$($LFS getstripe -M $WDIR)
556 mds_index=$((mds_index+1))
557 devname=$(mdsdevname $mds_index)
558 cmd="$E2FSCK -fnvd $devname"
560 echo "stop and checking mds${mds_index}: $cmd"
561 # e2fsck should not return error
562 stop mds${mds_index} -f
563 do_facet mds${mds_index} $cmd || rc=$?
565 start mds${mds_index} $devname $MDS_MOUNT_OPTS
566 df $MOUNT > /dev/null 2>&1
567 [ $rc -ne 0 ] && error "e2fsck should not report error upon "\
568 "short/long symlink MDT: rc=$rc"
571 run_test 17m "run e2fsck against MDT which contains short/long symlink"
577 run_test 18 "touch .../f ; ls ... =============================="
583 $CHECKSTAT -a $DIR/f19 || error
585 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
588 ls -l $DIR/f19 && error || true
590 run_test 19b "ls -l .../f19 (should return error) =============="
593 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
594 $RUNAS touch $DIR/f19 && error || true
596 run_test 19c "$RUNAS touch .../f19 (should return error) =="
599 cat $DIR/f19 && error || true
601 run_test 19d "cat .../f19 (should return error) =============="
613 $CHECKSTAT -a $DIR/f || error
615 run_test 20 "touch .../f ; ls -l ... ==========================="
619 [ -f $DIR/d21/dangle ] && rm -f $DIR/d21/dangle
620 ln -s dangle $DIR/d21/link
621 echo foo >> $DIR/d21/link
623 $CHECKSTAT -t link $DIR/d21/link || error
624 $CHECKSTAT -f -t file $DIR/d21/link || error
626 run_test 21 "write to dangling link ============================"
631 chown $RUNAS_ID:$RUNAS_GID $WDIR
632 (cd $WDIR || error "cd $WDIR failed";
633 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
635 ls -lR $WDIR/etc || error "ls -lR $WDIR/etc failed"
636 $CHECKSTAT -t dir $WDIR/etc || error "checkstat -t dir failed"
637 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $WDIR/etc || error "checkstat -u failed"
639 run_test 22 "unpack tar archive as non-root user ==============="
644 local file=$DIR/$tdir/$tfile
646 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
647 openfile -f O_CREAT:O_EXCL $file &&
648 error "$file recreate succeeded" || true
650 run_test 23a "O_CREAT|O_EXCL in subdir =========================="
652 test_23b() { # bug 18988
654 local file=$DIR/$tdir/$tfile
657 echo foo > $file || error "write filed"
658 echo bar >> $file || error "append filed"
659 $CHECKSTAT -s 8 $file || error "wrong size"
662 run_test 23b "O_APPEND check =========================="
665 echo '== rename sanity =============================================='
666 echo '-- same directory rename'
669 mv $DIR/R1/f $DIR/R1/g
670 $CHECKSTAT -t file $DIR/R1/g || error
672 run_test 24a "touch .../R1/f; rename .../R1/f .../R1/g ========="
677 mv $DIR/R2/f $DIR/R2/g
678 $CHECKSTAT -a $DIR/R2/f || error
679 $CHECKSTAT -t file $DIR/R2/g || error
681 run_test 24b "touch .../R2/{f,g}; rename .../R2/f .../R2/g ====="
686 mv $DIR/R3/f $DIR/R3/g
687 $CHECKSTAT -a $DIR/R3/f || error
688 $CHECKSTAT -t dir $DIR/R3/g || error
690 run_test 24c "mkdir .../R3/f; rename .../R3/f .../R3/g ========="
695 mrename $DIR/R4/f $DIR/R4/g
696 $CHECKSTAT -a $DIR/R4/f || error
697 $CHECKSTAT -t dir $DIR/R4/g || error
699 run_test 24d "mkdir .../R4/{f,g}; rename .../R4/f .../R4/g ====="
702 echo '-- cross directory renames --'
705 mv $DIR/R5a/f $DIR/R5b/g
706 $CHECKSTAT -a $DIR/R5a/f || error
707 $CHECKSTAT -t file $DIR/R5b/g || error
709 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
713 touch $DIR/R6a/f $DIR/R6b/g
714 mv $DIR/R6a/f $DIR/R6b/g
715 $CHECKSTAT -a $DIR/R6a/f || error
716 $CHECKSTAT -t file $DIR/R6b/g || error
718 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
723 mv $DIR/R7a/d $DIR/R7b/e
724 $CHECKSTAT -a $DIR/R7a/d || error
725 $CHECKSTAT -t dir $DIR/R7b/e || error
727 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
731 mkdir $DIR/R8a/d $DIR/R8b/e
732 mrename $DIR/R8a/d $DIR/R8b/e
733 $CHECKSTAT -a $DIR/R8a/d || error
734 $CHECKSTAT -t dir $DIR/R8b/e || error
736 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
739 echo "-- rename error cases"
743 mrename $DIR/R9/f $DIR/R9/a
744 $CHECKSTAT -t file $DIR/R9/f || error
745 $CHECKSTAT -t dir $DIR/R9/a || error
746 $CHECKSTAT -a $DIR/R9/a/f || error
748 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
752 mrename $DIR/R10/f $DIR/R10/g
753 $CHECKSTAT -t dir $DIR/R10 || error
754 $CHECKSTAT -a $DIR/R10/f || error
755 $CHECKSTAT -a $DIR/R10/g || error
757 run_test 24j "source does not exist ============================"
760 mkdir $DIR/R11a $DIR/R11a/d
762 mv $DIR/R11a/f $DIR/R11a/d
763 $CHECKSTAT -a $DIR/R11a/f || error
764 $CHECKSTAT -t file $DIR/R11a/d/f || error
766 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
768 # bug 2429 - rename foo foo foo creates invalid file
771 $MULTIOP $f OcNs || error
773 run_test 24l "Renaming a file to itself ========================"
777 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
778 # on ext3 this does not remove either the source or target files
779 # though the "expected" operation would be to remove the source
780 $CHECKSTAT -t file ${f} || error "${f} missing"
781 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
783 run_test 24m "Renaming a file to a hard link to itself ========="
787 # this stats the old file after it was renamed, so it should fail
791 $CHECKSTAT ${f}.rename
794 run_test 24n "Statting the old file after renaming (Posix rename 2)"
797 check_kernel_version 37 || return 0
799 rename_many -s random -v -n 10 $DIR/d24o
801 run_test 24o "rename of files during htree split ==============="
805 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
806 mrename $DIR/R12a $DIR/R12b
807 $CHECKSTAT -a $DIR/R12a || error
808 $CHECKSTAT -t dir $DIR/R12b || error
809 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
810 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
812 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
816 DIRINO=`ls -lid $DIR/R13a | awk '{ print $1 }'`
817 multiop_bg_pause $DIR/R13b D_c || return 1
820 mrename $DIR/R13a $DIR/R13b
821 $CHECKSTAT -a $DIR/R13a || error
822 $CHECKSTAT -t dir $DIR/R13b || error
823 DIRINO2=`ls -lid $DIR/R13b | awk '{ print $1 }'`
824 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
826 wait $MULTIPID || error "multiop close failed"
828 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
830 test_24r() { #bug 3789
831 mkdir $DIR/R14a $DIR/R14a/b
832 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
833 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
834 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
836 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
839 mkdir $DIR/R15a $DIR/R15a/b $DIR/R15a/b/c
840 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
841 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
842 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
844 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
846 mkdir $DIR/R16a $DIR/R16a/b $DIR/R16a/b/c
847 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
848 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
849 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
851 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
853 test_24u() { # bug12192
854 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error
855 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
857 run_test 24u "create stripe file"
863 simple_cleanup_common() {
866 wait_delete_completed
871 local FREE_INODES=`lfs df -i|grep "filesystem summary" | awk '{print $5}'`
872 [ $FREE_INODES -lt $NRFILES ] && \
873 skip "not enough free inodes $FREE_INODES required $NRFILES" &&
876 trap simple_cleanup_common EXIT
879 createmany -m $DIR/$tdir/$tfile $NRFILES
882 lctl set_param mdc.*.stats clear
884 ls $DIR/$tdir >/dev/null || error "error in listing large dir"
887 # DIRENT_SIZE = 32 bytes for sizeof(struct lu_dirent) +
888 # 8 bytes for name(filename is mostly 5 in this test) +
889 # 8 bytes for luda_type
890 # take into account of overhead in lu_dirpage header and end mark in
891 # each page, plus one in RPC_NUM calculation.
893 RPC_SIZE=$(($(lctl get_param -n mdc.*.max_pages_per_rpc)*$(page_size)))
894 RPC_NUM=$(((NRFILES * DIRENT_SIZE + RPC_SIZE - 1) / RPC_SIZE + 1))
895 mds_readpage=`lctl get_param mdc.*.stats | \
896 awk '/^mds_readpage/ {print $2}'`
897 [ $mds_readpage -gt $RPC_NUM ] && \
898 error "large readdir doesn't take effect"
900 simple_cleanup_common
902 run_test 24v "list directory with large files (handle hash collision, bug: 17560)"
904 test_24w() { # bug21506
906 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
907 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
908 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
909 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
910 [ "$SZ1" = "$SZ2" ] || \
911 error "Error reading at the end of the file $tfile"
913 run_test 24w "Reading a file larger than 4Gb"
916 echo '== symlink sanity ============================================='
920 touch $DIR/s25/foo || error
922 run_test 25a "create file in symlinked directory ==============="
925 [ ! -d $DIR/d25 ] && test_25a
926 $CHECKSTAT -t file $DIR/s25/foo || error
928 run_test 25b "lookup file in symlinked directory ==============="
933 ln -s d26/d26-2 $DIR/s26
934 touch $DIR/s26/foo || error
936 run_test 26a "multiple component symlink ======================="
939 mkdir -p $DIR/d26b/d26-2
940 ln -s d26b/d26-2/foo $DIR/s26-2
941 touch $DIR/s26-2 || error
943 run_test 26b "multiple component symlink at end of lookup ======"
948 ln -s d26.2 $DIR/s26.2-1
949 ln -s s26.2-1 $DIR/s26.2-2
950 ln -s s26.2-2 $DIR/s26.2-3
951 chmod 0666 $DIR/s26.2-3/foo
953 run_test 26c "chain of symlinks ================================"
955 # recursive symlinks (bug 439)
957 ln -s d26-3/foo $DIR/d26-3
959 run_test 26d "create multiple component recursive symlink ======"
962 [ ! -h $DIR/d26-3 ] && test_26d
965 run_test 26e "unlink multiple component recursive symlink ======"
967 # recursive symlinks (bug 7022)
970 mkdir $DIR/$tdir/$tfile || error "mkdir $DIR/$tdir/$tfile failed"
971 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
972 mkdir -p lndir/bar1 || error "mkdir lndir/bar1 failed"
973 mkdir $tfile || error "mkdir $tfile failed"
974 cd $tfile || error "cd $tfile failed"
975 ln -s .. dotdot || error "ln dotdot failed"
976 ln -s dotdot/lndir lndir || error "ln lndir failed"
977 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
978 output=`ls $tfile/$tfile/lndir/bar1`
979 [ "$output" = bar1 ] && error "unexpected output"
980 rm -r $tfile || error "rm $tfile failed"
981 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
983 run_test 26f "rm -r of a directory which has recursive symlink ="
986 echo '== stripe sanity =============================================='
987 mkdir -p $DIR/d27 || error "mkdir failed"
989 $SETSTRIPE -c 1 $DIR/d27/f0 || error "setstripe failed"
990 $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
992 log "== test_27a: write to one stripe file ========================="
993 cp /etc/hosts $DIR/d27/f0 || error
995 run_test 27a "one stripe file =================================="
998 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
1000 $SETSTRIPE -c 2 $DIR/d27/f01 || error "setstripe failed"
1001 $GETSTRIPE -c $DIR/d27/f01
1002 [ $($GETSTRIPE -c $DIR/d27/f01) -eq 2 ] ||
1003 error "two-stripe file doesn't have two stripes"
1005 run_test 27b "create two stripe file"
1008 [ -f $DIR/d27/f01 ] || skip "test_27b not run" && return
1010 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
1012 run_test 27c "write to two stripe file"
1016 $SETSTRIPE -c 0 -i -1 -S 0 $DIR/d27/fdef || error "setstripe failed"
1017 $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
1018 dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
1020 run_test 27d "create file with default settings ================"
1024 $SETSTRIPE -c 2 $DIR/d27/f12 || error "setstripe failed"
1025 $SETSTRIPE -c 2 $DIR/d27/f12 && error "setstripe succeeded twice"
1026 $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
1028 run_test 27e "setstripe existing file (should return error) ======"
1032 $SETSTRIPE -S 100 -i 0 -c 1 $DIR/d27/fbad && error "setstripe failed"
1033 dd if=/dev/zero of=$DIR/d27/f12 bs=4k count=4 || error "dd failed"
1034 $GETSTRIPE $DIR/d27/fbad || error "$GETSTRIPE failed"
1036 run_test 27f "setstripe with bad stripe size (should return error)"
1040 $MCREATE $DIR/d27/fnone || error "mcreate failed"
1041 $GETSTRIPE $DIR/d27/fnone 2>&1 | grep "no stripe info" ||
1042 error "$DIR/d27/fnone has object"
1044 run_test 27g "$GETSTRIPE with no objects"
1047 touch $DIR/d27/fsome || error "touch failed"
1048 [ $($GETSTRIPE -c $DIR/d27/fsome) -gt 0 ] || error "missing objects"
1050 run_test 27i "$GETSTRIPE with some objects"
1054 $SETSTRIPE -i $OSTCOUNT $DIR/d27/f27j && error "setstripe failed"||true
1056 run_test 27j "setstripe with bad stripe offset (should return error)"
1058 test_27k() { # bug 2844
1061 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
1062 [ ! -d $DIR/d27 ] && mkdir -p $DIR/d27
1063 $SETSTRIPE -S 67108864 $FILE || error "setstripe failed"
1064 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1065 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
1066 dd if=/dev/zero of=$FILE bs=4k count=1
1067 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1068 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
1070 run_test 27k "limit i_blksize for broken user apps ============="
1074 mcreate $DIR/f27l || error "creating file"
1075 $RUNAS $SETSTRIPE -c 1 $DIR/f27l && \
1076 error "setstripe should have failed" || true
1078 run_test 27l "check setstripe permissions (should return error)"
1081 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" &&
1083 if [ $ORIGFREE -gt $MAXFREE ]; then
1084 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1087 trap simple_cleanup_common EXIT
1089 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_1
1090 dd if=/dev/zero of=$DIR/$tdir/f27m_1 bs=1024 count=$MAXFREE &&
1091 error "dd should fill OST0"
1093 while $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_$i; do
1095 [ $i -gt 256 ] && break
1098 touch $DIR/$tdir/f27m_$i
1099 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1100 error "OST0 was full but new created file still use it"
1102 touch $DIR/$tdir/f27m_$i
1103 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1104 error "OST0 was full but new created file still use it"
1105 simple_cleanup_common
1107 run_test 27m "create file while OST0 was full =================="
1110 local DELAY=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage | head -n 1 | awk '{print $1 * 2}')
1114 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1115 # if the OST isn't full anymore.
1117 local OSTIDX=${1:-""}
1119 local list=$(comma_list $(osts_nodes))
1120 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1122 do_nodes $list lctl set_param fail_loc=0
1123 sync # initiate all OST_DESTROYs from MDS to OST
1127 exhaust_precreations() {
1130 local FAILIDX=${3:-$OSTIDX}
1133 local MDSIDX=$(get_mds_dir "$DIR/$tdir")
1134 echo OSTIDX=$OSTIDX MDSIDX=$MDSIDX
1136 local OST=$(ostname_from_index $OSTIDX)
1137 local MDT_INDEX=$(lfs df | grep "\[MDT:$((MDSIDX - 1))\]" | awk '{print $1}' | \
1138 sed -e 's/_UUID$//;s/^.*-//')
1141 local mdtosc_proc1=$(get_mdtosc_proc_path mds${MDSIDX} $OST)
1142 local last_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1143 osc.$mdtosc_proc1.prealloc_last_id)
1144 local next_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1145 osc.$mdtosc_proc1.prealloc_next_id)
1147 local mdtosc_proc2=$(get_mdtosc_proc_path mds${MDSIDX})
1148 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1150 mkdir -p $DIR/$tdir/${OST}
1151 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1152 #define OBD_FAIL_OST_ENOSPC 0x215
1153 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=$FAILIDX
1154 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x215
1155 echo "Creating to objid $last_id on ost $OST..."
1156 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1157 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1158 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=$FAILLOC
1162 exhaust_all_precreations() {
1164 for (( i=0; i < OSTCOUNT; i++ )) ; do
1165 exhaust_precreations $i $1 -1
1170 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1171 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1172 remote_ost_nodsh && skip "remote OST with nodsh" && return
1175 rm -f $DIR/$tdir/$tfile
1176 exhaust_precreations 0 0x80000215
1177 $SETSTRIPE -c -1 $DIR/$tdir
1178 touch $DIR/$tdir/$tfile || error
1179 $GETSTRIPE $DIR/$tdir/$tfile
1182 run_test 27n "create file with some full OSTs =================="
1185 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1186 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1187 remote_ost_nodsh && skip "remote OST with nodsh" && return
1190 rm -f $DIR/$tdir/$tfile
1191 exhaust_all_precreations 0x215
1193 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1198 run_test 27o "create file with all full OSTs (should error) ===="
1201 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1202 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1203 remote_ost_nodsh && skip "remote OST with nodsh" && return
1206 rm -f $DIR/$tdir/$tfile
1209 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1210 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1211 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1213 exhaust_precreations 0 0x80000215
1214 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1215 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1216 $GETSTRIPE $DIR/$tdir/$tfile
1220 run_test 27p "append to a truncated file with some full OSTs ==="
1223 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1224 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1225 remote_ost_nodsh && skip "remote OST with nodsh" && return
1228 rm -f $DIR/$tdir/$tfile
1231 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1232 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||error "truncate $DIR/$tdir/$tfile failed"
1233 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1235 exhaust_all_precreations 0x215
1237 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1238 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1242 run_test 27q "append to truncated file with all OSTs full (should error) ==="
1245 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1246 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1247 remote_ost_nodsh && skip "remote OST with nodsh" && return
1250 rm -f $DIR/$tdir/$tfile
1251 exhaust_precreations 0 0x80000215
1253 $SETSTRIPE -i 0 -c 2 $DIR/$tdir/$tfile # && error
1257 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1259 test_27s() { # bug 10725
1261 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1262 local stripe_count=0
1263 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1264 $SETSTRIPE -S $stripe_size -c $stripe_count $DIR/$tdir &&
1265 error "stripe width >= 2^32 succeeded" || true
1268 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1270 test_27t() { # bug 10864
1275 $WLFS getstripe $tfile
1278 run_test 27t "check that utils parse path correctly"
1280 test_27u() { # bug 4900
1281 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1282 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1284 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1285 do_facet $SINGLEMDS lctl set_param fail_loc=0x139
1287 createmany -o $DIR/$tdir/t- 1000
1288 do_facet $SINGLEMDS lctl set_param fail_loc=0
1290 TLOG=$DIR/$tfile.getstripe
1291 $GETSTRIPE $DIR/$tdir > $TLOG
1292 OBJS=`awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj;}' $TLOG`
1293 unlinkmany $DIR/$tdir/t- 1000
1294 [ $OBJS -gt 0 ] && \
1295 error "$OBJS objects created on OST-0. See $TLOG" || pass
1297 run_test 27u "skip object creation on OSC w/o objects =========="
1299 test_27v() { # bug 4900
1300 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1301 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1302 remote_ost_nodsh && skip "remote OST with nodsh" && return
1304 exhaust_all_precreations 0x215
1308 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1310 touch $DIR/$tdir/$tfile
1311 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1313 for (( i=1; i < OSTCOUNT; i++ )); do
1314 do_facet ost$i lctl set_param fail_loc=0x705
1316 local START=`date +%s`
1317 createmany -o $DIR/$tdir/$tfile 32
1319 local FINISH=`date +%s`
1320 local TIMEOUT=`lctl get_param -n timeout`
1321 local PROCESS=$((FINISH - START))
1322 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1323 error "$FINISH - $START >= $TIMEOUT / 2"
1324 sleep $((TIMEOUT / 2 - PROCESS))
1327 run_test 27v "skip object creation on slow OST ================="
1329 test_27w() { # bug 10997
1330 mkdir -p $DIR/$tdir || error "mkdir failed"
1331 $SETSTRIPE -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1332 [ $($GETSTRIPE -S $DIR/$tdir/f0) -ne 65536 ] &&
1333 error "stripe size $size != 65536" || true
1334 [ $($GETSTRIPE -d $DIR/$tdir | grep -c "stripe_count") -ne 1 ] &&
1335 error "$GETSTRIPE -d $DIR/$tdir failed" || true
1337 run_test 27w "check $SETSTRIPE -S option"
1340 [ "$OSTCOUNT" -lt "2" ] &&
1341 skip_env "skipping multiple stripe count/offset test" && return
1343 mkdir -p $DIR/$tdir || error "mkdir failed"
1344 for i in $(seq 1 $OSTCOUNT); do
1346 $SETSTRIPE -c $i -i $offset $DIR/$tdir/f$i ||
1347 error "setstripe -c $i -i $offset failed"
1348 count=$($GETSTRIPE -c $DIR/$tdir/f$i)
1349 index=$($GETSTRIPE -i $DIR/$tdir/f$i)
1350 [ $count -ne $i ] && error "stripe count $count != $i" || true
1351 [ $index -ne $offset ] &&
1352 error "stripe offset $index != $offset" || true
1355 run_test 27wa "check $SETSTRIPE -c -i options"
1358 remote_ost_nodsh && skip "remote OST with nodsh" && return
1359 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs" && return
1360 OFFSET=$(($OSTCOUNT - 1))
1362 local OST=$(ostname_from_index $OSTIDX)
1365 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe per file
1366 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1368 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1369 for i in `seq 0 $OFFSET`; do
1370 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}' | grep -w "$OSTIDX"` ] &&
1371 error "OST0 was degraded but new created file still use it"
1373 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1375 run_test 27x "create files while OST0 is degraded"
1378 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1379 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1380 remote_ost_nodsh && skip "remote OST with nodsh" && return
1382 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1383 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1384 osc.$mdtosc.prealloc_last_id)
1385 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1386 osc.$mdtosc.prealloc_next_id)
1387 local fcount=$((last_id - next_id))
1388 [ $fcount -eq 0 ] && skip "not enough space on OST0" && return
1389 [ $fcount -gt $OSTCOUNT ] && fcount=$OSTCOUNT
1391 MDS_OSCS=`do_facet $SINGLEMDS lctl dl | awk '/[oO][sS][cC].*md[ts]/ { print $4 }'`
1392 OFFSET=$(($OSTCOUNT-1))
1394 for OSC in $MDS_OSCS; do
1395 if [ $OST == -1 ]; then {
1396 OST=`osc_to_ost $OSC`
1398 echo $OSC "is Deactivate:"
1399 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1403 OSTIDX=$(index_from_ostuuid $OST)
1405 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1407 do_facet ost$((OSTIDX+1)) lctl set_param -n obdfilter.$OST.degraded 1
1409 createmany -o $DIR/$tdir/$tfile $fcount
1410 do_facet ost$((OSTIDX+1)) lctl set_param -n obdfilter.$OST.degraded 0
1412 for i in `seq 0 $OFFSET`; do
1413 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "$OSTIDX"` ] || \
1414 error "files created on deactivated OSTs instead of degraded OST"
1416 for OSC in $MDS_OSCS; do
1417 [ `osc_to_ost $OSC` != $OST ] && {
1418 echo $OSC "is activate"
1419 do_facet $SINGLEMDS lctl --device %$OSC activate
1423 run_test 27y "create files while OST0 is degraded and the rest inactive"
1429 lmm_count=$($GETSTRIPE -c $1)
1430 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1431 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1433 local old_ifs="$IFS"
1435 fid=($($LFS path2fid $1))
1438 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1439 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1441 # compare lmm_seq and lu_fid->f_seq
1442 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1443 # compare lmm_object_id and lu_fid->oid
1444 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1446 # check the trusted.fid attribute of the OST objects of the file
1447 local have_obdidx=false
1449 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1450 # skip lines up to and including "obdidx"
1451 [ -z "$obdidx" ] && break
1452 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1453 $have_obdidx || continue
1455 local ost=$((obdidx + 1))
1456 local dev=$(ostdevname $ost)
1458 if [ $(facet_fstype ost$ost) != ldiskfs ]; then
1459 echo "Currently only works with ldiskfs-based OSTs"
1463 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1465 #don't unmount/remount the OSTs if we don't need to do that
1466 #local dir=$(facet_mntpt ost$ost)
1468 #do_facet ost$dev mount -t $FSTYPE $dev $dir $OST_MOUNT_OPTS ||
1469 # { error "mounting $dev as $FSTYPE failed"; return 3; }
1470 #local obj_file=$(do_facet ost$ost find $dir/O/$seq -name $oid)
1471 #local ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID $obj_file)
1473 local obj_file="O/$seq/d$((oid %32))/$oid"
1474 local ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
1475 $dev 2>/dev/null" | grep "parent=")
1477 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
1479 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
1481 #do_facet ost$ost umount -d $dir
1482 #start ost$ost $dev $OST_MOUNT_OPTS
1484 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
1485 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
1486 local ff_parent=$(echo $ff|sed -e 's/.*parent=.//')
1487 local ff_pseq=$(echo $ff_parent | cut -d: -f1)
1488 local ff_poid=$(echo $ff_parent | cut -d: -f2)
1489 local ff_pstripe=$(echo $ff_parent | sed -e 's/.*stripe=//')
1491 # compare lmm_seq and filter_fid->ff_parent.f_seq
1492 [ $ff_pseq = $lmm_seq ] ||
1493 error "FF parent SEQ $ff_pseq != $lmm_seq"
1494 # compare lmm_object_id and filter_fid->ff_parent.f_oid
1495 [ $ff_poid = $lmm_oid ] ||
1496 error "FF parent OID $ff_poid != $lmm_oid"
1497 [ $ff_pstripe = $stripe_nr ] ||
1498 error "FF stripe $ff_pstripe != $stripe_nr"
1500 stripe_nr=$((stripe_nr + 1))
1505 remote_ost_nodsh && skip "remote OST with nodsh" && return
1508 $SETSTRIPE -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
1509 { error "setstripe -c -1 failed"; return 1; }
1510 # We need to send a write to every object to get parent FID info set.
1511 # This _should_ also work for setattr, but does not currently.
1512 # touch $DIR/$tdir/$tfile-1 ||
1513 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
1514 { error "dd $tfile-1 failed"; return 2; }
1515 $SETSTRIPE -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
1516 { error "setstripe -c -1 failed"; return 3; }
1517 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
1518 { error "dd $tfile-2 failed"; return 4; }
1520 # make sure write RPCs have been sent to OSTs
1523 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
1524 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
1526 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
1528 test_27A() { # b=19102
1529 local restore_size=$($GETSTRIPE -S $MOUNT)
1530 local restore_count=$($GETSTRIPE -c $MOUNT)
1531 local restore_offset=$($GETSTRIPE -i $MOUNT)
1532 $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
1533 local default_size=$($GETSTRIPE -S $MOUNT)
1534 local default_count=$($GETSTRIPE -c $MOUNT)
1535 local default_offset=$($GETSTRIPE -i $MOUNT)
1536 local dsize=$((1024 * 1024))
1537 [ $default_size -eq $dsize ] ||
1538 error "stripe size $default_size != $dsize"
1539 [ $default_count -eq 1 ] || error "stripe count $default_count != 1"
1540 [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
1541 $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
1543 run_test 27A "check filesystem-wide default LOV EA values"
1545 # createtest also checks that device nodes are created and
1546 # then visible correctly (#2091)
1547 test_28() { # bug 2091
1549 $CREATETEST $DIR/d28/ct || error
1551 run_test 28 "create/mknod/mkdir with bad file types ============"
1554 cancel_lru_locks mdc
1560 declare -i LOCKCOUNTORIG=0
1561 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1562 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
1564 [ $LOCKCOUNTORIG -eq 0 ] && echo "No mdc lock count" && return 1
1566 declare -i LOCKUNUSEDCOUNTORIG=0
1567 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1568 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
1575 declare -i LOCKCOUNTCURRENT=0
1576 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1577 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
1580 declare -i LOCKUNUSEDCOUNTCURRENT=0
1581 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1582 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
1585 if [ "$LOCKCOUNTCURRENT" -gt "$LOCKCOUNTORIG" ]; then
1586 lctl set_param -n ldlm.dump_namespaces ""
1587 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
1588 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1589 log "dumped log to $TMP/test_29.dk (bug 5793)"
1592 if [ "$LOCKUNUSEDCOUNTCURRENT" -gt "$LOCKUNUSEDCOUNTORIG" ]; then
1593 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
1594 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1595 log "dumped log to $TMP/test_29.dk (bug 5793)"
1599 run_test 29 "IT_GETATTR regression ============================"
1601 test_30a() { # was test_30
1602 cp `which ls` $DIR || cp /bin/ls $DIR
1606 run_test 30a "execute binary from Lustre (execve) =============="
1609 cp `which ls` $DIR || cp /bin/ls $DIR
1611 $RUNAS $DIR/ls / || error
1614 run_test 30b "execute binary from Lustre as non-root ==========="
1616 test_30c() { # b=22376
1617 cp `which ls` $DIR || cp /bin/ls $DIR
1619 cancel_lru_locks mdc
1620 cancel_lru_locks osc
1621 $RUNAS $DIR/ls / || error
1624 run_test 30c "execute binary from Lustre without read perms ===="
1627 $OPENUNLINK $DIR/f31 $DIR/f31 || error
1628 $CHECKSTAT -a $DIR/f31 || error
1630 run_test 31a "open-unlink file =================================="
1633 touch $DIR/f31 || error
1634 ln $DIR/f31 $DIR/f31b || error
1635 $MULTIOP $DIR/f31b Ouc || error
1636 $CHECKSTAT -t file $DIR/f31 || error
1638 run_test 31b "unlink file with multiple links while open ======="
1641 touch $DIR/f31 || error
1642 ln $DIR/f31 $DIR/f31c || error
1643 multiop_bg_pause $DIR/f31 O_uc || return 1
1645 $MULTIOP $DIR/f31c Ouc
1646 kill -USR1 $MULTIPID
1649 run_test 31c "open-unlink file with multiple links ============="
1652 opendirunlink $DIR/d31d $DIR/d31d || error
1653 $CHECKSTAT -a $DIR/d31d || error
1655 run_test 31d "remove of open directory ========================="
1657 test_31e() { # bug 2904
1658 check_kernel_version 34 || return 0
1659 openfilleddirunlink $DIR/d31e || error
1661 run_test 31e "remove of open non-empty directory ==============="
1663 test_31f() { # bug 4554
1666 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
1667 cp /etc/hosts $DIR/d31f
1669 $GETSTRIPE $DIR/d31f/hosts
1670 multiop_bg_pause $DIR/d31f D_c || return 1
1673 rm -rv $DIR/d31f || error "first of $DIR/d31f"
1675 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
1676 cp /etc/hosts $DIR/d31f
1678 $GETSTRIPE $DIR/d31f/hosts
1679 multiop_bg_pause $DIR/d31f D_c || return 1
1682 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
1683 wait $MULTIPID || error "first opendir $MULTIPID failed"
1687 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
1688 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
1691 run_test 31f "remove of open directory with open-unlink file ==="
1694 echo "-- cross directory link --"
1695 mkdir $DIR/d31g{a,b}
1697 ln $DIR/d31ga/f $DIR/d31gb/g
1698 $CHECKSTAT -t file $DIR/d31ga/f || error "source"
1699 [ `stat -c%h $DIR/d31ga/f` == '2' ] || error "source nlink"
1700 $CHECKSTAT -t file $DIR/d31gb/g || error "target"
1701 [ `stat -c%h $DIR/d31gb/g` == '2' ] || error "target nlink"
1703 run_test 31g "cross directory link==============="
1706 echo "-- cross directory link --"
1710 ln $DIR/d31h/f $DIR/d31h/dir/g
1711 $CHECKSTAT -t file $DIR/d31h/f || error "source"
1712 [ `stat -c%h $DIR/d31h/f` == '2' ] || error "source nlink"
1713 $CHECKSTAT -t file $DIR/d31h/dir/g || error "target"
1714 [ `stat -c%h $DIR/d31h/dir/g` == '2' ] || error "target nlink"
1716 run_test 31h "cross directory link under child==============="
1719 echo "-- cross directory link --"
1722 touch $DIR/d31i/dir/f
1723 ln $DIR/d31i/dir/f $DIR/d31i/g
1724 $CHECKSTAT -t file $DIR/d31i/dir/f || error "source"
1725 [ `stat -c%h $DIR/d31i/dir/f` == '2' ] || error "source nlink"
1726 $CHECKSTAT -t file $DIR/d31i/g || error "target"
1727 [ `stat -c%h $DIR/d31i/g` == '2' ] || error "target nlink"
1729 run_test 31i "cross directory link under parent==============="
1734 mkdir $DIR/d31j/dir1
1735 ln $DIR/d31j/dir1 $DIR/d31j/dir2 && error "ln for dir"
1736 link $DIR/d31j/dir1 $DIR/d31j/dir3 && error "link for dir"
1737 mlink $DIR/d31j/dir1 $DIR/d31j/dir4 && error "mlink for dir"
1738 mlink $DIR/d31j/dir1 $DIR/d31j/dir1 && error "mlink to the same dir"
1741 run_test 31j "link for directory==============="
1747 touch $DIR/d31k/exist
1748 mlink $DIR/d31k/s $DIR/d31k/t || error "mlink"
1749 mlink $DIR/d31k/s $DIR/d31k/exist && error "mlink to exist file"
1750 mlink $DIR/d31k/s $DIR/d31k/s && error "mlink to the same file"
1751 mlink $DIR/d31k/s $DIR/d31k && error "mlink to parent dir"
1752 mlink $DIR/d31k $DIR/d31k/s && error "mlink parent dir to target"
1753 mlink $DIR/d31k/not-exist $DIR/d31k/foo && error "mlink non-existing to new"
1754 mlink $DIR/d31k/not-exist $DIR/d31k/s && error "mlink non-existing to exist"
1757 run_test 31k "link to file: the same, non-existing, dir==============="
1763 touch $DIR/d31m2/exist
1764 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
1765 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
1766 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
1767 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
1768 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
1769 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
1772 run_test 31m "link to file: the same, non-existing, dir==============="
1774 cleanup_test32_mount() {
1776 $UMOUNT $DIR/$tdir/ext2-mountpoint
1780 echo "== more mountpoints and symlinks ================="
1781 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
1782 trap cleanup_test32_mount EXIT
1783 mkdir -p $DIR/$tdir/ext2-mountpoint
1784 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
1785 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. || error
1786 cleanup_test32_mount
1788 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
1791 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
1792 trap cleanup_test32_mount EXIT
1793 mkdir -p $DIR/$tdir/ext2-mountpoint
1794 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
1795 ls -al $DIR/$tdir/ext2-mountpoint/.. || error
1796 cleanup_test32_mount
1798 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
1801 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
1802 trap cleanup_test32_mount EXIT
1803 mkdir -p $DIR/$tdir/ext2-mountpoint
1804 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
1805 mkdir -p $DIR/$tdir/d2/test_dir
1806 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
1807 cleanup_test32_mount
1809 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
1812 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
1813 trap cleanup_test32_mount EXIT
1814 mkdir -p $DIR/$tdir/ext2-mountpoint
1815 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
1816 mkdir -p $DIR/$tdir/d2/test_dir
1817 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
1818 cleanup_test32_mount
1820 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
1823 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
1824 mkdir -p $DIR/d32e/tmp
1825 TMP_DIR=$DIR/d32e/tmp
1826 ln -s $DIR/d32e $TMP_DIR/symlink11
1827 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1828 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
1829 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
1831 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
1834 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
1835 mkdir -p $DIR/d32f/tmp
1836 TMP_DIR=$DIR/d32f/tmp
1837 ln -s $DIR/d32f $TMP_DIR/symlink11
1838 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1839 ls $DIR/d32f/tmp/symlink11 || error
1840 ls $DIR/d32f/symlink01 || error
1842 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
1845 TMP_DIR=$DIR/$tdir/tmp
1846 mkdir -p $TMP_DIR $DIR/${tdir}2
1847 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
1848 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1849 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
1850 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
1851 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
1852 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
1854 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
1857 rm -fr $DIR/$tdir $DIR/${tdir}2
1858 TMP_DIR=$DIR/$tdir/tmp
1859 mkdir -p $TMP_DIR $DIR/${tdir}2
1860 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
1861 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1862 ls $TMP_DIR/symlink12 || error
1863 ls $DIR/$tdir/symlink02 || error
1865 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
1868 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
1869 trap cleanup_test32_mount EXIT
1870 mkdir -p $DIR/$tdir/ext2-mountpoint
1871 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
1872 touch $DIR/$tdir/test_file
1873 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file || error
1874 cleanup_test32_mount
1876 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
1879 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
1880 trap cleanup_test32_mount EXIT
1881 mkdir -p $DIR/$tdir/ext2-mountpoint
1882 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
1883 touch $DIR/$tdir/test_file
1884 cat $DIR/$tdir/ext2-mountpoint/../test_file || error
1885 cleanup_test32_mount
1887 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
1891 trap cleanup_test32_mount EXIT
1892 mkdir -p $DIR/$tdir/ext2-mountpoint
1893 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
1894 mkdir -p $DIR/$tdir/d2
1895 touch $DIR/$tdir/d2/test_file || error
1896 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
1897 cleanup_test32_mount
1899 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
1903 trap cleanup_test32_mount EXIT
1904 mkdir -p $DIR/$tdir/ext2-mountpoint
1905 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
1906 mkdir -p $DIR/$tdir/d2
1907 touch $DIR/$tdir/d2/test_file
1908 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
1909 cleanup_test32_mount
1911 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
1915 mkdir -p $DIR/d32m/tmp
1916 TMP_DIR=$DIR/d32m/tmp
1917 ln -s $DIR $TMP_DIR/symlink11
1918 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1919 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
1920 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
1922 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
1926 mkdir -p $DIR/d32n/tmp
1927 TMP_DIR=$DIR/d32n/tmp
1928 ln -s $DIR $TMP_DIR/symlink11
1929 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1930 ls -l $DIR/d32n/tmp/symlink11 || error
1931 ls -l $DIR/d32n/symlink01 || error
1933 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
1936 rm -fr $DIR/d32o $DIR/$tfile
1938 mkdir -p $DIR/d32o/tmp
1939 TMP_DIR=$DIR/d32o/tmp
1940 ln -s $DIR/$tfile $TMP_DIR/symlink12
1941 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1942 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
1943 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
1944 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
1945 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
1947 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
1957 mkdir -p $DIR/d32p/tmp
1959 TMP_DIR=$DIR/d32p/tmp
1961 ln -s $DIR/$tfile $TMP_DIR/symlink12
1963 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1965 cat $DIR/d32p/tmp/symlink12 || error
1967 cat $DIR/d32p/symlink02 || error
1970 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
1972 cleanup_testdir_mount() {
1978 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
1979 trap cleanup_testdir_mount EXIT
1981 touch $DIR/$tdir/under_the_mount
1982 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
1983 ls $DIR/$tdir | grep "\<under_the_mount\>" && error
1984 cleanup_testdir_mount
1986 run_test 32q "stat follows mountpoints in Lustre (should return error)"
1989 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
1990 trap cleanup_testdir_mount EXIT
1992 touch $DIR/$tdir/under_the_mount
1993 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
1994 ls $DIR/$tdir | grep -q under_the_mount && error || true
1995 cleanup_testdir_mount
1997 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
2002 chmod 444 $DIR/$tfile
2003 chown $RUNAS_ID $DIR/$tfile
2005 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2008 run_test 33 "write file with mode 444 (should return error) ===="
2013 chown $RUNAS_ID $DIR/d33
2014 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
2015 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
2016 error "open RDWR" || true
2018 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
2023 chown $RUNAS_ID $DIR/d33
2024 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33 && error "create" || true
2026 run_test 33b "test open file with malformed flags (No panic and return error)"
2034 remote_ost_nodsh && skip "remote OST with nodsh" && return
2038 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2041 for ostnum in $(seq $OSTCOUNT); do
2042 # test-framework's OST numbering is one-based, while Lustre's
2044 ostname=$(printf "$FSNAME-OST%.4d" $((ostnum - 1)))
2045 # Parsing llobdstat's output sucks; we could grep the /proc
2046 # path, but that's likely to not be as portable as using the
2047 # llobdstat utility. So we parse lctl output instead.
2048 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2049 obdfilter/$ostname/stats |
2050 awk '/^write_bytes/ {print $7}' )
2051 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2052 if (( ${write_bytes:-0} > 0 ))
2059 $all_zeros || return 0
2062 echo foo > $DIR/d33/bar
2066 # Total up write_bytes after writing. We'd better find non-zeros.
2067 for ostnum in $(seq $OSTCOUNT); do
2068 ostname=$(printf "$FSNAME-OST%.4d" $((ostnum - 1)))
2069 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2070 obdfilter/$ostname/stats |
2071 awk '/^write_bytes/ {print $7}' )
2072 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2073 if (( ${write_bytes:-0} > 0 ))
2082 for ostnum in $(seq $OSTCOUNT); do
2083 ostname=$(printf "$FSNAME-OST%.4d" $((ostnum - 1)))
2084 echo "Check that write_bytes is present in obdfilter/*/stats:"
2085 do_facet ost$ostnum lctl get_param -n \
2086 obdfilter/$ostname/stats
2088 error "OST not keeping write_bytes stats (b22312)"
2091 run_test 33c "test llobdstat and write_bytes"
2093 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
2096 $MCREATE $DIR/f34 || error
2097 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2098 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
2099 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2100 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2102 run_test 34a "truncate file that has not been opened ==========="
2105 [ ! -f $DIR/f34 ] && test_34a
2106 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2107 $OPENFILE -f O_RDONLY $DIR/f34
2108 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2109 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2111 run_test 34b "O_RDONLY opening file doesn't create objects ====="
2114 [ ! -f $DIR/f34 ] && test_34a
2115 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2116 $OPENFILE -f O_RDWR $DIR/f34
2117 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2118 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2120 run_test 34c "O_RDWR opening file-with-size works =============="
2123 [ ! -f $DIR/f34 ] && test_34a
2124 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2125 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2128 run_test 34d "write to sparse file ============================="
2132 $MCREATE $DIR/f34e || error
2133 $TRUNCATE $DIR/f34e 1000 || error
2134 $CHECKSTAT -s 1000 $DIR/f34e || error
2135 $OPENFILE -f O_RDWR $DIR/f34e
2136 $CHECKSTAT -s 1000 $DIR/f34e || error
2138 run_test 34e "create objects, some with size and some without =="
2140 test_34f() { # bug 6242, 6243
2143 $MCREATE $DIR/f34f || error
2144 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
2145 dd if=$DIR/f34f of=$TMP/f34f
2146 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
2147 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
2148 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
2149 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
2150 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
2152 run_test 34f "read from a file with no objects until EOF ======="
2155 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
2156 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
2157 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
2158 cancel_lru_locks osc
2159 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
2160 error "wrong size after lock cancel"
2162 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
2163 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2164 error "expanding truncate failed"
2165 cancel_lru_locks osc
2166 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2167 error "wrong expanded size after lock cancel"
2169 run_test 34g "truncate long file ==============================="
2175 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
2176 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
2180 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
2181 error "Multiop blocked on ftruncate, pid=$MULTIPID"
2185 local nsz=`stat -c %s $DIR/$tfile`
2186 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
2188 run_test 34h "ftruncate file under grouplock should not block"
2191 cp /bin/sh $DIR/f35a
2193 chown $RUNAS_ID $DIR/f35a
2194 $RUNAS $DIR/f35a && error || true
2197 run_test 35a "exec file with mode 444 (should return and not leak) ====="
2201 utime $DIR/f36 || error
2203 run_test 36a "MDS utime check (mknod, utime) ==================="
2207 utime $DIR/f36 || error
2209 run_test 36b "OST utime check (open, utime) ===================="
2214 chown $RUNAS_ID $DIR/d36
2215 $RUNAS utime $DIR/d36/f36 || error
2217 run_test 36c "non-root MDS utime check (mknod, utime) =========="
2220 [ ! -d $DIR/d36 ] && test_36c
2221 echo "" > $DIR/d36/f36
2222 $RUNAS utime $DIR/d36/f36 || error
2224 run_test 36d "non-root OST utime check (open, utime) ==========="
2227 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
2229 touch $DIR/$tdir/$tfile
2230 $RUNAS utime $DIR/$tdir/$tfile && \
2231 error "utime worked, expected failure" || true
2233 run_test 36e "utime on non-owned file (should return error) ===="
2237 local LANG_SAVE=$LANG
2238 local LC_LANG_SAVE=$LC_LANG
2239 export LANG=C LC_LANG=C # for date language
2241 DATESTR="Dec 20 2000"
2243 lctl set_param fail_loc=$fl
2245 cp /etc/hosts $DIR/$tdir/$tfile
2246 sync & # write RPC generated with "current" inode timestamp, but delayed
2248 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
2249 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
2250 cancel_lru_locks osc
2251 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
2253 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
2254 echo "BEFORE: $LS_BEFORE" && \
2255 echo "AFTER : $LS_AFTER" && \
2256 echo "WANT : $DATESTR" && \
2257 error "$DIR/$tdir/$tfile timestamps changed" || true
2259 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
2263 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2264 subr_36fh "0x80000214"
2266 run_test 36f "utime on file racing with OST BRW write =========="
2269 remote_ost_nodsh && skip "remote OST with nodsh" && return
2275 fmd_max_age=$(do_facet ost1 \
2276 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
2279 fmd_before=$(do_facet ost1 \
2280 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2281 touch $DIR/$tdir/$tfile
2282 sleep $((fmd_max_age + 12))
2283 fmd_after=$(do_facet ost1 \
2284 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2286 echo "fmd_before: $fmd_before"
2287 echo "fmd_after: $fmd_after"
2288 [ "$fmd_after" -gt "$fmd_before" ] && \
2289 echo "AFTER: $fmd_after > BEFORE: $fmd_before" && \
2290 error "fmd didn't expire after ping" || true
2292 run_test 36g "filter mod data cache expiry ====================="
2295 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
2296 subr_36fh "0x80000227"
2298 run_test 36h "utime on file racing with OST BRW write =========="
2300 # test_37 - duplicate with tests 32q 32r
2303 local file=$DIR/$tfile
2305 openfile -f O_DIRECTORY $file
2308 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
2309 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
2311 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
2315 touch $DIR/${tfile}2
2316 # ls -l $DIR/$tfile $DIR/${tfile}2
2317 # ls -lu $DIR/$tfile $DIR/${tfile}2
2318 # ls -lc $DIR/$tfile $DIR/${tfile}2
2320 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
2321 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
2323 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
2325 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
2327 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
2328 error "O_TRUNC didn't change timestamps"
2331 run_test 39 "mtime changed on create ==========================="
2335 cp -p /etc/passwd $DIR/$tdir/fopen
2336 cp -p /etc/passwd $DIR/$tdir/flink
2337 cp -p /etc/passwd $DIR/$tdir/funlink
2338 cp -p /etc/passwd $DIR/$tdir/frename
2339 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
2342 echo "aaaaaa" >> $DIR/$tdir/fopen
2343 echo "aaaaaa" >> $DIR/$tdir/flink
2344 echo "aaaaaa" >> $DIR/$tdir/funlink
2345 echo "aaaaaa" >> $DIR/$tdir/frename
2347 local open_new=`stat -c %Y $DIR/$tdir/fopen`
2348 local link_new=`stat -c %Y $DIR/$tdir/flink`
2349 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
2350 local rename_new=`stat -c %Y $DIR/$tdir/frename`
2352 cat $DIR/$tdir/fopen > /dev/null
2353 ln $DIR/$tdir/flink $DIR/$tdir/flink2
2354 rm -f $DIR/$tdir/funlink2
2355 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
2357 for (( i=0; i < 2; i++ )) ; do
2358 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
2359 local link_new2=`stat -c %Y $DIR/$tdir/flink`
2360 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
2361 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
2363 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
2364 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
2365 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
2366 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
2368 cancel_lru_locks osc
2369 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2372 run_test 39b "mtime change on open, link, unlink, rename ======"
2374 # this should be set to past
2375 TEST_39_MTIME=`date -d "1 year ago" +%s`
2381 local mtime0=`stat -c %Y $DIR1/$tfile`
2383 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2384 local mtime1=`stat -c %Y $DIR1/$tfile`
2385 [ "$mtime1" = $TEST_39_MTIME ] || \
2386 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
2389 echo hello >> $DIR1/$tfile
2391 local mtime2=`stat -c %Y $DIR1/$tfile`
2392 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
2393 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
2395 mv $DIR1/$tfile $DIR1/$tfile-1
2397 for (( i=0; i < 2; i++ )) ; do
2398 local mtime3=`stat -c %Y $DIR1/$tfile-1`
2399 [ "$mtime2" = "$mtime3" ] || \
2400 error "mtime ($mtime2) changed (to $mtime3) on rename"
2402 cancel_lru_locks osc
2403 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2406 run_test 39c "mtime change on rename ==========================="
2412 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2414 for (( i=0; i < 2; i++ )) ; do
2415 local mtime=`stat -c %Y $DIR1/$tfile`
2416 [ $mtime = $TEST_39_MTIME ] || \
2417 error "mtime($mtime) is not set to $TEST_39_MTIME"
2419 cancel_lru_locks osc
2420 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2423 run_test 39d "create, utime, stat =============================="
2428 local mtime1=`stat -c %Y $DIR1/$tfile`
2430 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2432 for (( i=0; i < 2; i++ )) ; do
2433 local mtime2=`stat -c %Y $DIR1/$tfile`
2434 [ $mtime2 = $TEST_39_MTIME ] || \
2435 error "mtime($mtime2) is not set to $TEST_39_MTIME"
2437 cancel_lru_locks osc
2438 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2441 run_test 39e "create, stat, utime, stat ========================"
2446 mtime1=`stat -c %Y $DIR1/$tfile`
2449 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2451 for (( i=0; i < 2; i++ )) ; do
2452 local mtime2=`stat -c %Y $DIR1/$tfile`
2453 [ $mtime2 = $TEST_39_MTIME ] || \
2454 error "mtime($mtime2) is not set to $TEST_39_MTIME"
2456 cancel_lru_locks osc
2457 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2460 run_test 39f "create, stat, sleep, utime, stat ================="
2464 echo hello >> $DIR1/$tfile
2465 local mtime1=`stat -c %Y $DIR1/$tfile`
2468 chmod o+r $DIR1/$tfile
2470 for (( i=0; i < 2; i++ )) ; do
2471 local mtime2=`stat -c %Y $DIR1/$tfile`
2472 [ "$mtime1" = "$mtime2" ] || \
2473 error "lost mtime: $mtime2, should be $mtime1"
2475 cancel_lru_locks osc
2476 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2479 run_test 39g "write, chmod, stat ==============================="
2487 echo hello >> $DIR1/$tfile
2488 local mtime1=`stat -c %Y $DIR1/$tfile`
2490 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2492 if [ "$d1" != "$d2" ]; then
2493 echo "write and touch not within one second"
2495 for (( i=0; i < 2; i++ )) ; do
2496 local mtime2=`stat -c %Y $DIR1/$tfile`
2497 [ "$mtime2" = $TEST_39_MTIME ] || \
2498 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
2500 cancel_lru_locks osc
2501 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2505 run_test 39h "write, utime within one second, stat ============="
2511 echo hello >> $DIR1/$tfile
2512 local mtime1=`stat -c %Y $DIR1/$tfile`
2514 mv $DIR1/$tfile $DIR1/$tfile-1
2516 for (( i=0; i < 2; i++ )) ; do
2517 local mtime2=`stat -c %Y $DIR1/$tfile-1`
2519 [ "$mtime1" = "$mtime2" ] || \
2520 error "lost mtime: $mtime2, should be $mtime1"
2522 cancel_lru_locks osc
2523 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2526 run_test 39i "write, rename, stat =============================="
2529 start_full_debug_logging
2533 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
2534 lctl set_param fail_loc=0x80000412
2535 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
2536 error "multiop failed"
2538 local mtime1=`stat -c %Y $DIR1/$tfile`
2540 mv $DIR1/$tfile $DIR1/$tfile-1
2542 kill -USR1 $multipid
2543 wait $multipid || error "multiop close failed"
2545 for (( i=0; i < 2; i++ )) ; do
2546 local mtime2=`stat -c %Y $DIR1/$tfile-1`
2547 [ "$mtime1" = "$mtime2" ] ||
2548 error "mtime is lost on close: $mtime2, " \
2551 cancel_lru_locks osc
2552 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2554 lctl set_param fail_loc=0
2555 stop_full_debug_logging
2557 run_test 39j "write, rename, close, stat ======================="
2563 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
2565 local mtime1=`stat -c %Y $DIR1/$tfile`
2567 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2569 kill -USR1 $multipid
2570 wait $multipid || error "multiop close failed"
2572 for (( i=0; i < 2; i++ )) ; do
2573 local mtime2=`stat -c %Y $DIR1/$tfile`
2575 [ "$mtime2" = $TEST_39_MTIME ] || \
2576 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
2578 cancel_lru_locks osc
2579 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2582 run_test 39k "write, utime, close, stat ========================"
2584 # this should be set to future
2585 TEST_39_ATIME=`date -d "1 year" +%s`
2587 is_sles11() # LU-1783
2589 if [ -r /etc/SuSE-release ]
2591 local vers=`grep VERSION /etc/SuSE-release | awk '{print $3}'`
2592 local patchlev=`grep PATCHLEVEL /etc/SuSE-release \
2594 if [ $vers -eq 11 ] && [ $patchlev -eq 1 ]
2603 is_sles11 && skip "SLES 11 SP1" && return # LU-1783
2604 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2605 local atime_diff=$(do_facet $SINGLEMDS lctl get_param -n mdd.*.atime_diff)
2609 # test setting directory atime to future
2610 touch -a -d @$TEST_39_ATIME $DIR/$tdir
2611 local atime=$(stat -c %X $DIR/$tdir)
2612 [ "$atime" = $TEST_39_ATIME ] || \
2613 error "atime is not set to future: $atime, should be $TEST_39_ATIME"
2615 # test setting directory atime from future to now
2616 local d1=$(date +%s)
2618 local d2=$(date +%s)
2620 cancel_lru_locks mdc
2621 atime=$(stat -c %X $DIR/$tdir)
2622 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
2623 error "atime is not updated from future: $atime, should be $d1<atime<$d2"
2625 do_facet $SINGLEMDS lctl set_param -n mdd.*.atime_diff=2
2628 # test setting directory atime when now > dir atime + atime_diff
2632 cancel_lru_locks mdc
2633 atime=$(stat -c %X $DIR/$tdir)
2634 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
2635 error "atime is not updated : $atime, should be $d2"
2637 do_facet $SINGLEMDS lctl set_param -n mdd.*.atime_diff=60
2640 # test not setting directory atime when now < dir atime + atime_diff
2642 cancel_lru_locks mdc
2643 atime=$(stat -c %X $DIR/$tdir)
2644 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
2645 error "atime is updated to $atime, should remain $d1<atime<$d2"
2647 do_facet $SINGLEMDS lctl set_param -n mdd.*.atime_diff=$atime_diff
2649 run_test 39l "directory atime update ==========================="
2654 local far_past_mtime=$(date -d "May 29 1953" +%s)
2655 local far_past_atime=$(date -d "Dec 17 1903" +%s)
2657 touch -m -d @$far_past_mtime $DIR1/$tfile
2658 touch -a -d @$far_past_atime $DIR1/$tfile
2660 for (( i=0; i < 2; i++ )) ; do
2661 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
2662 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
2663 error "atime or mtime set incorrectly"
2665 cancel_lru_locks osc
2666 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2669 run_test 39m "test atime and mtime before 1970"
2672 dd if=/dev/zero of=$DIR/f40 bs=4096 count=1
2673 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/f40 && error
2674 $CHECKSTAT -t file -s 4096 $DIR/f40 || error
2676 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
2680 small_write $DIR/f41 18
2682 run_test 41 "test small file write + fstat ====================="
2684 count_ost_writes() {
2685 lctl get_param -n osc.*.stats |
2686 awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }'
2693 BG_DIRTY_RATIO_SAVE=10
2694 MAX_BG_DIRTY_RATIO=25
2698 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
2699 # dirty_ratio, dirty_background_ratio
2700 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
2701 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
2702 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
2703 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
2705 # if file not here, we are a 2.4 kernel
2706 kill -CONT `pidof kupdated`
2711 # setup the trap first, so someone cannot exit the test at the
2712 # exact wrong time and mess up a machine
2713 trap start_writeback EXIT
2714 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
2715 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
2716 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
2717 sysctl -w vm.dirty_writeback_centisecs=0
2718 sysctl -w vm.dirty_writeback_centisecs=0
2719 # save and increase /proc/sys/vm/dirty_ratio
2720 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
2721 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
2722 # save and increase /proc/sys/vm/dirty_background_ratio
2723 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
2724 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
2726 # if file not here, we are a 2.4 kernel
2727 kill -STOP `pidof kupdated`
2731 # ensure that all stripes have some grant before we test client-side cache
2733 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
2734 dd if=/dev/zero of=$i bs=4k count=1
2739 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
2740 # file truncation, and file removal.
2743 cancel_lru_locks osc
2745 sync; sleep 1; sync # just to be safe
2746 BEFOREWRITES=`count_ost_writes`
2747 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
2748 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
2749 AFTERWRITES=`count_ost_writes`
2750 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
2751 error "$BEFOREWRITES < $AFTERWRITES"
2754 run_test 42a "ensure that we don't flush on close =============="
2758 cancel_lru_locks osc
2761 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
2762 BEFOREWRITES=`count_ost_writes`
2763 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
2764 AFTERWRITES=`count_ost_writes`
2765 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
2766 error "$BEFOREWRITES < $AFTERWRITES on unlink"
2768 BEFOREWRITES=`count_ost_writes`
2769 sync || error "sync: $?"
2770 AFTERWRITES=`count_ost_writes`
2771 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
2772 error "$BEFOREWRITES < $AFTERWRITES on sync"
2774 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
2778 run_test 42b "test destroy of file with cached dirty data ======"
2780 # if these tests just want to test the effect of truncation,
2781 # they have to be very careful. consider:
2782 # - the first open gets a {0,EOF}PR lock
2783 # - the first write conflicts and gets a {0, count-1}PW
2784 # - the rest of the writes are under {count,EOF}PW
2785 # - the open for truncate tries to match a {0,EOF}PR
2786 # for the filesize and cancels the PWs.
2787 # any number of fixes (don't get {0,EOF} on open, match
2788 # composite locks, do smarter file size management) fix
2789 # this, but for now we want these tests to verify that
2790 # the cancellation with truncate intent works, so we
2791 # start the file with a full-file pw lock to match against
2792 # until the truncate.
2797 cancel_lru_locks osc
2799 # prime the file with 0,EOF PW to match
2803 # now the real test..
2804 dd if=/dev/zero of=$file bs=1024 count=100
2805 BEFOREWRITES=`count_ost_writes`
2806 $TRUNCATE $file $offset
2807 cancel_lru_locks osc
2808 AFTERWRITES=`count_ost_writes`
2814 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
2815 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
2818 run_test 42c "test partial truncate of file with cached dirty data"
2822 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
2823 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
2826 run_test 42d "test complete truncate of file with cached dirty data"
2828 test_42e() { # bug22074
2829 local TDIR=$DIR/${tdir}e
2830 local pagesz=$(page_size)
2831 local pages=16 # hardcoded 16 pages, don't change it.
2832 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
2833 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
2838 $SETSTRIPE -c 1 $TDIR
2839 createmany -o $TDIR/f $files
2841 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
2843 # we assume that with $OSTCOUNT files, at least one of them will
2844 # be allocated on OST0.
2845 warmup_files=$((OSTCOUNT * max_dirty_mb))
2846 createmany -o $TDIR/w $warmup_files
2848 # write a large amount of data into one file and sync, to get good
2849 # avail_grant number from OST.
2850 for ((i=0; i<$warmup_files; i++)); do
2851 idx=$($GETSTRIPE -i $TDIR/w$i)
2852 [ $idx -ne 0 ] && continue
2853 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
2856 [ $i -gt $warmup_files ] && error "OST0 is still cold"
2858 $LCTL get_param $proc_osc0/cur_dirty_bytes
2859 $LCTL get_param $proc_osc0/cur_grant_bytes
2861 # create as much dirty pages as we can while not to trigger the actual
2862 # RPCs directly. but depends on the env, VFS may trigger flush during this
2863 # period, hopefully we are good.
2864 for ((i=0; i<$warmup_files; i++)); do
2865 idx=$($GETSTRIPE -i $TDIR/w$i)
2866 [ $idx -ne 0 ] && continue
2867 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
2869 $LCTL get_param $proc_osc0/cur_dirty_bytes
2870 $LCTL get_param $proc_osc0/cur_grant_bytes
2872 # perform the real test
2873 $LCTL set_param $proc_osc0/rpc_stats 0
2874 for ((;i<$files; i++)); do
2875 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
2876 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
2879 $LCTL get_param $proc_osc0/rpc_stats
2882 local have_ppr=false
2883 $LCTL get_param $proc_osc0/rpc_stats |
2884 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
2885 # skip lines until we are at the RPC histogram data
2886 [ "$PPR" == "pages" ] && have_ppr=true && continue
2887 $have_ppr || continue
2889 # we only want the percent stat for < 16 pages
2890 [ $(echo $PPR | tr -d ':') -ge $pages ] && break
2892 percent=$((percent + WPCT))
2893 if [ $percent -gt 15 ]; then
2894 error "less than 16-pages write RPCs" \
2901 run_test 42e "verify sub-RPC writes are not done synchronously"
2905 cp -p /bin/ls $DIR/$tdir/$tfile
2906 $MULTIOP $DIR/$tdir/$tfile Ow_c &
2908 # give multiop a chance to open
2911 $DIR/$tdir/$tfile && error || true
2914 run_test 43 "execution of file opened for write should return -ETXTBSY"
2918 cp -p `which $MULTIOP` $DIR/d43/multiop || cp -p multiop $DIR/d43/multiop
2919 MULTIOP_PROG=$DIR/d43/multiop multiop_bg_pause $TMP/test43.junk O_c || return 1
2921 $MULTIOP $DIR/d43/multiop Oc && error "expected error, got success"
2922 kill -USR1 $MULTIOP_PID || return 2
2923 wait $MULTIOP_PID || return 3
2926 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
2930 cp -p `which $MULTIOP` $DIR/d43/multiop || cp -p multiop $DIR/d43/multiop
2931 MULTIOP_PROG=$DIR/d43/multiop multiop_bg_pause $TMP/test43.junk O_c || return 1
2933 $TRUNCATE $DIR/d43/multiop 0 && error "expected error, got success"
2934 kill -USR1 $MULTIOP_PID || return 2
2935 wait $MULTIOP_PID || return 3
2938 run_test 43b "truncate of file being executed should return -ETXTBSY"
2941 local testdir="$DIR/d43c"
2944 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
2945 ( cd $testdir && md5sum -c)
2947 run_test 43c "md5sum of copy into lustre========================"
2950 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
2951 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
2952 dd if=$DIR/f1 bs=4k count=1 > /dev/null
2954 run_test 44 "zero length read from a sparse stripe ============="
2957 local nstripe=`$LCTL lov_getconfig $DIR | grep default_stripe_count: | \
2959 [ -z "$nstripe" ] && skip "can't get stripe info" && return
2960 [ "$nstripe" -gt "$OSTCOUNT" ] && skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" && return
2961 local stride=`$LCTL lov_getconfig $DIR | grep default_stripe_size: | \
2963 if [ $nstripe -eq 0 -o $nstripe -eq -1 ] ; then
2964 nstripe=`$LCTL lov_getconfig $DIR | grep obd_count: | awk '{print $2}'`
2967 OFFSETS="0 $((stride/2)) $((stride-1))"
2968 for offset in $OFFSETS ; do
2969 for i in `seq 0 $((nstripe-1))`; do
2970 local GLOBALOFFSETS=""
2971 local size=$((((i + 2 * $nstripe )*$stride + $offset))) # Bytes
2972 local myfn=$DIR/d44a-$size
2973 echo "--------writing $myfn at $size"
2974 ll_sparseness_write $myfn $size || error "ll_sparseness_write"
2975 GLOBALOFFSETS="$GLOBALOFFSETS $size"
2976 ll_sparseness_verify $myfn $GLOBALOFFSETS \
2977 || error "ll_sparseness_verify $GLOBALOFFSETS"
2979 for j in `seq 0 $((nstripe-1))`; do
2980 size=$((((j + $nstripe )*$stride + $offset))) # Bytes
2981 ll_sparseness_write $myfn $size || error "ll_sparseness_write"
2982 GLOBALOFFSETS="$GLOBALOFFSETS $size"
2984 ll_sparseness_verify $myfn $GLOBALOFFSETS \
2985 || error "ll_sparseness_verify $GLOBALOFFSETS"
2990 run_test 44a "test sparse pwrite ==============================="
2994 for d in `lctl get_param -n osc.*.cur_dirty_bytes`; do
3000 before=`dirty_osc_total`
3001 echo executing "\"$*\""
3003 after=`dirty_osc_total`
3004 echo before $before, after $after
3008 # Obtain grants from OST if it supports it
3009 echo blah > ${f}_grant
3012 do_dirty_record "echo blah > $f"
3013 [ $before -eq $after ] && error "write wasn't cached"
3014 do_dirty_record "> $f"
3015 [ $before -gt $after ] || error "truncate didn't lower dirty count"
3016 do_dirty_record "echo blah > $f"
3017 [ $before -eq $after ] && error "write wasn't cached"
3018 do_dirty_record "sync"
3019 [ $before -gt $after ] || error "writeback didn't lower dirty count"
3020 do_dirty_record "echo blah > $f"
3021 [ $before -eq $after ] && error "write wasn't cached"
3022 do_dirty_record "cancel_lru_locks osc"
3023 [ $before -gt $after ] || error "lock cancellation didn't lower dirty count"
3026 run_test 45 "osc io page accounting ============================"
3028 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
3029 # test tickles a bug where re-dirtying a page was failing to be mapped to the
3030 # objects offset and an assert hit when an rpc was built with 1023's mapped
3031 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
3036 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3038 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
3039 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3043 run_test 46 "dirtying a previously written page ================"
3045 # test_47 is removed "Device nodes check" is moved to test_28
3047 test_48a() { # bug 2399
3048 check_kernel_version 34 || return 0
3051 mv $DIR/d48a $DIR/d48.new || error "move directory failed"
3052 mkdir $DIR/d48a || error "recreate directory failed"
3053 touch foo || error "'touch foo' failed after recreating cwd"
3054 mkdir bar || error "'mkdir foo' failed after recreating cwd"
3055 if check_kernel_version 44; then
3056 touch .foo || error "'touch .foo' failed after recreating cwd"
3057 mkdir .bar || error "'mkdir .foo' failed after recreating cwd"
3059 ls . > /dev/null || error "'ls .' failed after recreating cwd"
3060 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3061 cd . || error "'cd .' failed after recreating cwd"
3062 mkdir . && error "'mkdir .' worked after recreating cwd"
3063 rmdir . && error "'rmdir .' worked after recreating cwd"
3064 ln -s . baz || error "'ln -s .' failed after recreating cwd"
3065 cd .. || error "'cd ..' failed after recreating cwd"
3067 run_test 48a "Access renamed working dir (should return errors)="
3069 test_48b() { # bug 2399
3070 check_kernel_version 34 || return 0
3073 rmdir $DIR/d48b || error "remove cwd $DIR/d48b failed"
3074 touch foo && error "'touch foo' worked after removing cwd"
3075 mkdir foo && error "'mkdir foo' worked after removing cwd"
3076 if check_kernel_version 44; then
3077 touch .foo && error "'touch .foo' worked after removing cwd"
3078 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
3080 ls . > /dev/null && error "'ls .' worked after removing cwd"
3081 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3082 is_patchless || ( cd . && error "'cd .' worked after removing cwd" )
3083 mkdir . && error "'mkdir .' worked after removing cwd"
3084 rmdir . && error "'rmdir .' worked after removing cwd"
3085 ln -s . foo && error "'ln -s .' worked after removing cwd"
3086 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
3088 run_test 48b "Access removed working dir (should return errors)="
3090 test_48c() { # bug 2350
3091 check_kernel_version 36 || return 0
3092 #lctl set_param debug=-1
3094 mkdir -p $DIR/d48c/dir
3096 $TRACE rmdir $DIR/d48c/dir || error "remove cwd $DIR/d48c/dir failed"
3097 $TRACE touch foo && error "'touch foo' worked after removing cwd"
3098 $TRACE mkdir foo && error "'mkdir foo' worked after removing cwd"
3099 if check_kernel_version 44; then
3100 touch .foo && error "'touch .foo' worked after removing cwd"
3101 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
3103 $TRACE ls . && error "'ls .' worked after removing cwd"
3104 $TRACE ls .. || error "'ls ..' failed after removing cwd"
3105 is_patchless || ( $TRACE cd . && error "'cd .' worked after removing cwd" )
3106 $TRACE mkdir . && error "'mkdir .' worked after removing cwd"
3107 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
3108 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
3109 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
3111 run_test 48c "Access removed working subdir (should return errors)"
3113 test_48d() { # bug 2350
3114 check_kernel_version 36 || return 0
3115 #lctl set_param debug=-1
3117 mkdir -p $DIR/d48d/dir
3119 $TRACE rmdir $DIR/d48d/dir || error "remove cwd $DIR/d48d/dir failed"
3120 $TRACE rmdir $DIR/d48d || error "remove parent $DIR/d48d failed"
3121 $TRACE touch foo && error "'touch foo' worked after removing parent"
3122 $TRACE mkdir foo && error "'mkdir foo' worked after removing parent"
3123 if check_kernel_version 44; then
3124 touch .foo && error "'touch .foo' worked after removing parent"
3125 mkdir .foo && error "'mkdir .foo' worked after removing parent"
3127 $TRACE ls . && error "'ls .' worked after removing parent"
3128 $TRACE ls .. && error "'ls ..' worked after removing parent"
3129 is_patchless || ( $TRACE cd . && error "'cd .' worked after recreate parent" )
3130 $TRACE mkdir . && error "'mkdir .' worked after removing parent"
3131 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
3132 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
3133 is_patchless || ( $TRACE cd .. && error "'cd ..' worked after removing parent" || true )
3135 run_test 48d "Access removed parent subdir (should return errors)"
3137 test_48e() { # bug 4134
3138 check_kernel_version 41 || return 0
3139 #lctl set_param debug=-1
3141 mkdir -p $DIR/d48e/dir
3143 $TRACE rmdir $DIR/d48e/dir || error "remove cwd $DIR/d48e/dir failed"
3144 $TRACE rmdir $DIR/d48e || error "remove parent $DIR/d48e failed"
3145 $TRACE touch $DIR/d48e || error "'touch $DIR/d48e' failed"
3146 $TRACE chmod +x $DIR/d48e || error "'chmod +x $DIR/d48e' failed"
3147 # On a buggy kernel addition of "touch foo" after cd .. will
3148 # produce kernel oops in lookup_hash_it
3149 touch ../foo && error "'cd ..' worked after recreate parent"
3151 $TRACE rm $DIR/d48e || error "rm '$DIR/d48e' failed"
3153 run_test 48e "Access to recreated parent subdir (should return errors)"
3155 test_49() { # LU-1030
3156 # get ost1 size - lustre-OST0000
3157 ost1_size=$(do_facet ost1 lfs df |grep ${ost1_svc} |awk '{print $4}')
3158 # write 800M at maximum
3159 [ $ost1_size -gt 819200 ] && ost1_size=819200
3161 lfs setstripe -c 1 -i 0 $DIR/$tfile
3162 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
3165 # change max_pages_per_rpc while writing the file
3166 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
3167 local orig_mppc=`$LCTL get_param -n $osc1_mppc`
3168 # loop until dd process exits
3169 while ps ax -opid | grep -wq $dd_pid; do
3170 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
3171 sleep $((RANDOM % 5 + 1))
3173 # restore original max_pages_per_rpc
3174 $LCTL set_param $osc1_mppc=$orig_mppc
3175 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
3177 run_test 49 "Change max_pages_per_rpc won't break osc extent"
3183 ls /proc/$$/cwd || error
3185 run_test 50 "special situations: /proc symlinks ==============="
3187 test_51a() { # was test_51
3188 # bug 1516 - create an empty entry right after ".." then split dir
3191 $MCREATE $DIR/d51/bar
3193 createmany -m $DIR/d51/longfile 201
3195 while [ `ls -sd $DIR/d51 | awk '{ print $1 }'` -eq 4 ]; do
3196 $MCREATE $DIR/d51/longfile$FNUM
3201 ls -l $DIR/d51 > /dev/null || error
3203 run_test 51a "special situations: split htree with empty entry =="
3205 export NUMTEST=70000
3207 local BASE=$DIR/$tdir
3210 local mdtidx=$(printf "%04x" $($LFS getstripe -M $BASE))
3211 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
3212 [ $numfree -lt 21000 ] && skip "not enough free inodes ($numfree)" &&
3215 [ $numfree -lt $NUMTEST ] && NUMTEST=$(($numfree - 50)) &&
3216 echo "reduced count to $NUMTEST due to inodes"
3218 # need to check free space for the directories as well
3219 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
3220 numfree=$((blkfree / 4))
3221 [ $numfree -lt $NUMTEST ] && NUMTEST=$(($numfree - 50)) &&
3222 echo "reduced count to $NUMTEST due to blocks"
3224 createmany -d $BASE/d $NUMTEST && echo $NUMTEST > $BASE/fnum ||
3225 echo "failed" > $BASE/fnum
3227 run_test 51b "exceed 64k subdirectory nlink limit"
3229 test_51ba() { # LU-993
3230 local BASE=$DIR/$tdir
3231 # unlink all but 100 subdirectories, then check it still works
3233 [ -f $BASE/fnum ] && local NUMPREV=$(cat $BASE/fnum) && rm $BASE/fnum
3235 [ "$NUMPREV" != "failed" ] && NUMTEST=$NUMPREV
3236 local DELETE=$((NUMTEST - LEFT))
3238 # continue on to run this test even if 51b didn't finish,
3239 # just to delete the many subdirectories created.
3240 [ ! -d "${BASE}/d1" ] && skip "test_51b() not run" && return 0
3242 # for ldiskfs the nlink count should be 1, but this is OSD specific
3243 # and so this is listed for informational purposes only
3244 echo "nlink before: $(stat -c %h $BASE), created before: $NUMTEST"
3245 unlinkmany -d $BASE/d $DELETE
3248 if [ $RC -ne 0 ]; then
3249 if [ "$NUMPREV" == "failed" ]; then
3250 skip "previous setup failed"
3253 error "unlink of first $DELETE subdirs failed"
3258 echo "nlink between: $(stat -c %h $BASE)"
3259 # trim the first line of ls output
3260 local FOUND=$(($(ls -l ${BASE} | wc -l) - 1))
3261 [ $FOUND -ne $LEFT ] &&
3262 error "can't find subdirs: found only $FOUND/$LEFT"
3264 unlinkmany -d $BASE/d $DELETE $LEFT ||
3265 error "unlink of second $LEFT subdirs failed"
3266 # regardless of whether the backing filesystem tracks nlink accurately
3267 # or not, the nlink count shouldn't be more than "." and ".." here
3268 local AFTER=$(stat -c %h $BASE)
3269 [ $AFTER -gt 2 ] && error "nlink after: $AFTER > 2" ||
3270 echo "nlink after: $AFTER"
3272 run_test 51ba "verify nlink for many subdirectory cleanup"
3275 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3277 local ndirs=${TEST51BB_NDIRS:-10}
3278 local nfiles=${TEST51BB_NFILES:-100}
3280 local numfree=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
3282 [ $numfree -lt $(( ndirs * nfiles)) ] && \
3283 nfiles=$(( numfree / ndirs - 10 ))
3285 local dir=$DIR/d51bb
3287 local savePOLICY=$(lctl get_param -n lmv.*.placement)
3288 lctl set_param -n lmv.*.placement=CHAR
3291 local IUSED=$(lfs df -i $dir | grep MDT | awk '{print $3}')
3295 for ((i=0; i < $ndirs; i++)); do
3296 dirs[i]=$dir/$RANDOM
3297 echo Creating directory ${dirs[i]}
3300 echo Creating $nfiles in dir ${dirs[i]} ...
3301 echo "createmany -o ${dirs[i]}/$tfile- $nfiles"
3302 createmany -o ${dirs[i]}/$tfile- $nfiles
3308 IUSED=$(lfs df -i $dir | grep MDT | awk '{print $3}')
3312 for ((i=0; i<${#NEWUSED[@]}; i++)); do
3313 echo "mds $i: inodes count OLD ${OLDUSED[$i]} NEW ${NEWUSED[$i]}"
3314 [ ${OLDUSED[$i]} -lt ${NEWUSED[$i]} ] || rc=$((rc + 1))
3317 lctl set_param -n lmv.*.placement=$savePOLICY
3319 [ $rc -ne $MDSCOUNT ] || \
3320 error "Objects/inodes are not distributed over all mds servers"
3322 run_test 51bb "mkdir createmany CMD $MDSCOUNT ===================="
3325 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping test with few OSTs" && return
3327 createmany -o $DIR/d51d/t- 1000
3328 $GETSTRIPE $DIR/d51d > $TMP/files
3329 for N in `seq 0 $((OSTCOUNT - 1))`; do
3330 OBJS[$N]=`awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}' $TMP/files`
3331 OBJS0[$N]=`grep -A 1 idx $TMP/files | awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}'`
3332 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
3334 unlinkmany $DIR/d51d/t- 1000
3337 for N in `seq 1 $((OSTCOUNT - 1))`; do
3338 [ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ] && \
3339 error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
3340 [ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ] && \
3341 error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
3343 [ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ] && \
3344 error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
3345 [ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ] && \
3346 error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
3350 run_test 51d "check object distribution ===================="
3353 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
3356 chattr +a $DIR/d52a/foo || error "chattr +a failed"
3357 echo bar >> $DIR/d52a/foo || error "append bar failed"
3358 cp /etc/hosts $DIR/d52a/foo && error "cp worked"
3359 rm -f $DIR/d52a/foo 2>/dev/null && error "rm worked"
3360 link $DIR/d52a/foo $DIR/d52a/foo_link 2>/dev/null && error "link worked"
3361 echo foo >> $DIR/d52a/foo || error "append foo failed"
3362 mrename $DIR/d52a/foo $DIR/d52a/foo_ren && error "rename worked"
3363 lsattr $DIR/d52a/foo | egrep -q "^-+a[-e]+ $DIR/d52a/foo" || error "lsattr"
3364 chattr -a $DIR/d52a/foo || error "chattr -a failed"
3365 cp -r $DIR/d52a /tmp/
3366 rm -fr $DIR/d52a || error "cleanup rm failed"
3368 run_test 52a "append-only flag test (should return errors) ====="
3371 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
3374 chattr +i $DIR/d52b/foo || error "chattr +i failed"
3375 cat test > $DIR/d52b/foo && error "cat test worked"
3376 cp /etc/hosts $DIR/d52b/foo && error "cp worked"
3377 rm -f $DIR/d52b/foo 2>/dev/null && error "rm worked"
3378 link $DIR/d52b/foo $DIR/d52b/foo_link 2>/dev/null && error "link worked"
3379 echo foo >> $DIR/d52b/foo && error "echo worked"
3380 mrename $DIR/d52b/foo $DIR/d52b/foo_ren && error "rename worked"
3381 [ -f $DIR/d52b/foo ] || error
3382 [ -f $DIR/d52b/foo_ren ] && error
3383 lsattr $DIR/d52b/foo | egrep -q "^-+i[-e]+ $DIR/d52b/foo" || error "lsattr"
3384 chattr -i $DIR/d52b/foo || error "chattr failed"
3386 rm -fr $DIR/d52b || error
3388 run_test 52b "immutable flag test (should return errors) ======="
3391 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3392 remote_ost_nodsh && skip "remote OST with nodsh" && return
3401 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
3402 for value in $(do_facet $SINGLEMDS lctl get_param osc.$mdtosc.prealloc_last_id) ; do
3403 param=`echo ${value[0]} | cut -d "=" -f1`
3404 ostname=`echo $param | cut -d "." -f2 | cut -d - -f 1-2`
3405 mds_last=$(do_facet $SINGLEMDS lctl get_param -n $param)
3406 ostnum=$(echo $ostname | sed "s/${FSNAME}-OST//g" | awk '{print ($1+1)}' )
3407 ost_last=$(do_facet ost$ostnum lctl get_param -n obdfilter.$ostname.last_id | head -n 1)
3408 echo "$ostname.last_id=$ost_last ; MDS.last_id=$mds_last"
3409 if [ $ost_last != $mds_last ]; then
3410 error "$ostname.last_id=$ost_last ; MDS.last_id=$mds_last"
3414 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
3417 [ ! -f "$SOCKETSERVER" ] && skip_env "no socketserver, skipping" && return
3418 [ ! -f "$SOCKETCLIENT" ] && skip_env "no socketclient, skipping" && return
3419 $SOCKETSERVER $DIR/socket
3420 $SOCKETCLIENT $DIR/socket || error
3421 $MUNLINK $DIR/socket
3423 run_test 54a "unix domain socket test =========================="
3429 dd if=/dev/zero of=$f bs=`page_size` count=1
3431 run_test 54b "char device works in lustre ======================"
3434 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
3435 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
3436 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
3438 for i in `seq 3 7`; do
3439 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
3449 loopdev="$DIR/loop54c"
3452 [ -z "$LOOPNUM" ] && echo "couldn't find empty loop device" && return
3453 mknod $loopdev b 7 $LOOPNUM
3454 echo "make a loop file system with $tfile on $loopdev ($LOOPNUM)..."
3455 dd if=/dev/zero of=$tfile bs=`page_size` seek=1024 count=1 > /dev/null
3456 losetup $loopdev $tfile || error "can't set up $loopdev for $tfile"
3457 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
3459 mount -t ext2 $loopdev $tdir || error "error mounting $loopdev on $tdir"
3460 dd if=/dev/zero of=$tdir/tmp bs=`page_size` count=30 || error "dd write"
3462 dd if=$tdir/tmp of=/dev/zero bs=`page_size` count=30 || error "dd read"
3467 run_test 54c "block device works in lustre ====================="
3473 [ "$string" = `echo $string > $f | cat $f` ] || error
3475 run_test 54d "fifo device works in lustre ======================"
3478 check_kernel_version 46 || return 0
3481 cp -aL /dev/console $f
3482 echo $string > $f || error
3484 run_test 54e "console/tty device works in lustre ======================"
3486 #The test_55 used to be iopen test and it was removed by bz#24037.
3487 #run_test 55 "check iopen_connect_dentry() ======================"
3489 test_56a() { # was test_56
3495 NUMFILESx2=$(($NUMFILES * 2))
3496 for i in `seq 1 $NUMFILES` ; do
3497 touch $DIR/d56/file$i
3498 touch $DIR/d56/dir/file$i
3501 # test lfs getstripe with --recursive
3502 FILENUM=`$GETSTRIPE --recursive $DIR/d56 | grep -c obdidx`
3503 [ $FILENUM -eq $NUMFILESx2 ] ||
3504 error "$GETSTRIPE --recursive: found $FILENUM, not $NUMFILESx2"
3505 FILENUM=`$GETSTRIPE $DIR/d56 | grep -c obdidx`
3506 [ $FILENUM -eq $NUMFILES ] ||
3507 error "$GETSTRIPE $DIR/d56: found $FILENUM, not $NUMFILES"
3508 echo "$GETSTRIPE --recursive passed."
3510 # test lfs getstripe with file instead of dir
3511 FILENUM=`$GETSTRIPE $DIR/d56/file1 | grep -c obdidx`
3512 [ $FILENUM -eq 1 ] || error \
3513 "$GETSTRIPE $DIR/d56/file1: found $FILENUM, not 1"
3514 echo "$GETSTRIPE file1 passed."
3516 #test lfs getstripe with --verbose
3517 [ `$GETSTRIPE --verbose $DIR/d56 | grep -c lmm_magic` -eq $NUMFILES ] ||
3518 error "$GETSTRIPE --verbose $DIR/d56: want $NUMFILES lmm_magic"
3519 [ `$GETSTRIPE $DIR/d56 | grep -c lmm_magic` -eq 0 ] ||
3520 error "$GETSTRIPE $DIR/d56: showed lmm_magic"
3521 echo "$GETSTRIPE --verbose passed."
3523 #test lfs getstripe with --obd
3524 $GETSTRIPE --obd wrong_uuid $DIR/d56 2>&1 | grep -q "unknown obduuid" ||
3525 error "$GETSTRIPE --obd wrong_uuid should return error message"
3527 [ "$OSTCOUNT" -lt 2 ] &&
3528 skip_env "skipping other $GETSTRIPE --obd test" && return
3531 OBDUUID=$(ostuuid_from_index $OSTIDX)
3532 FILENUM=`$GETSTRIPE -ir $DIR/d56 | grep -x $OSTIDX | wc -l`
3533 FOUND=`$GETSTRIPE -r --obd $OBDUUID $DIR/d56 | grep obdidx | wc -l`
3534 [ $FOUND -eq $FILENUM ] ||
3535 error "$GETSTRIPE --obd wrong: found $FOUND, expected $FILENUM"
3536 [ `$GETSTRIPE -r -v --obd $OBDUUID $DIR/d56 |
3537 sed '/^[ ]*'${OSTIDX}'[ ]/d' |
3538 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l` -eq 0 ] ||
3539 error "$GETSTRIPE --obd: should not show file on other obd"
3540 echo "$GETSTRIPE --obd passed"
3542 run_test 56a "check $GETSTRIPE"
3547 local LOCAL_NUMFILES="$1"
3548 local LOCAL_NUMDIRS="$2"
3549 local MKDIR_PARAMS="$3"
3551 if [ ! -d "$TDIR" ] ; then
3553 [ "$MKDIR_PARAMS" ] && $SETSTRIPE $MKDIR_PARAMS $TDIR
3554 for i in `seq 1 $LOCAL_NUMFILES` ; do
3557 for i in `seq 1 $LOCAL_NUMDIRS` ; do
3559 for j in `seq 1 $LOCAL_NUMFILES` ; do
3560 touch $TDIR/dir$i/file$j
3566 setup_56_special() {
3570 if [ ! -e "$TDIR/loop1b" ] ; then
3571 for i in `seq 1 $LOCAL_NUMFILES` ; do
3572 mknod $TDIR/loop${i}b b 7 $i
3573 mknod $TDIR/null${i}c c 1 3
3574 ln -s $TDIR/file1 $TDIR/link${i}l
3576 for i in `seq 1 $LOCAL_NUMDIRS` ; do
3577 mknod $TDIR/dir$i/loop${i}b b 7 $i
3578 mknod $TDIR/dir$i/null${i}c c 1 3
3579 ln -s $TDIR/dir$i/file1 $TDIR/dir$i/link${i}l
3588 setup_56 $NUMFILES $NUMDIRS
3590 EXPECTED=$(($NUMDIRS + 2))
3591 # test lfs find with -name
3592 for i in $(seq 1 $NUMFILES) ; do
3593 NUMS=$($LFIND -name "*$i" $TDIR | wc -l)
3594 [ $NUMS -eq $EXPECTED ] ||
3595 error "lfs find -name \"*$i\" $TDIR wrong: "\
3596 "found $NUMS, expected $EXPECTED"
3599 run_test 56g "check lfs find -name ============================="
3605 setup_56 $NUMFILES $NUMDIRS
3607 EXPECTED=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
3608 # test lfs find with ! -name
3609 for i in $(seq 1 $NUMFILES) ; do
3610 NUMS=$($LFIND ! -name "*$i" $TDIR | wc -l)
3611 [ $NUMS -eq $EXPECTED ] ||
3612 error "lfs find ! -name \"*$i\" $TDIR wrong: "\
3613 "found $NUMS, expected $EXPECTED"
3616 run_test 56h "check lfs find ! -name ============================="
3621 UUID=$(ostuuid_from_index 0 $DIR/$tdir)
3622 CMD="$LFIND -ost $UUID $DIR/$tdir"
3624 [ -z "$OUT" ] || error "\"$CMD\" returned directory '$OUT'"
3626 run_test 56i "check 'lfs find -ost UUID' skips directories ======="
3630 setup_56_special $NUMFILES $NUMDIRS
3632 EXPECTED=$((NUMDIRS + 1))
3633 CMD="$LFIND -type d $TDIR"
3634 NUMS=$($CMD | wc -l)
3635 [ $NUMS -eq $EXPECTED ] ||
3636 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3638 run_test 56j "check lfs find -type d ============================="
3642 setup_56_special $NUMFILES $NUMDIRS
3644 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
3645 CMD="$LFIND -type f $TDIR"
3646 NUMS=$($CMD | wc -l)
3647 [ $NUMS -eq $EXPECTED ] ||
3648 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3650 run_test 56k "check lfs find -type f ============================="
3654 setup_56_special $NUMFILES $NUMDIRS
3656 EXPECTED=$((NUMDIRS + NUMFILES))
3657 CMD="$LFIND -type b $TDIR"
3658 NUMS=$($CMD | wc -l)
3659 [ $NUMS -eq $EXPECTED ] ||
3660 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3662 run_test 56l "check lfs find -type b ============================="
3666 setup_56_special $NUMFILES $NUMDIRS
3668 EXPECTED=$((NUMDIRS + NUMFILES))
3669 CMD="$LFIND -type c $TDIR"
3670 NUMS=$($CMD | wc -l)
3671 [ $NUMS -eq $EXPECTED ] ||
3672 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3674 run_test 56m "check lfs find -type c ============================="
3678 setup_56_special $NUMFILES $NUMDIRS
3680 EXPECTED=$((NUMDIRS + NUMFILES))
3681 CMD="$LFIND -type l $TDIR"
3682 NUMS=$($CMD | wc -l)
3683 [ $NUMS -eq $EXPECTED ] ||
3684 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3686 run_test 56n "check lfs find -type l ============================="
3690 setup_56 $NUMFILES $NUMDIRS
3692 utime $TDIR/file1 > /dev/null || error "utime (1)"
3693 utime $TDIR/file2 > /dev/null || error "utime (2)"
3694 utime $TDIR/dir1 > /dev/null || error "utime (3)"
3695 utime $TDIR/dir2 > /dev/null || error "utime (4)"
3696 utime $TDIR/dir1/file1 > /dev/null || error "utime (5)"
3697 dd if=/dev/zero count=1 >> $TDIR/dir1/file1 && sync
3700 NUMS=`$LFIND -mtime +0 $TDIR | wc -l`
3701 [ $NUMS -eq $EXPECTED ] || \
3702 error "lfs find -mtime +0 $TDIR wrong: found $NUMS, expected $EXPECTED"
3705 CMD="$LFIND -mtime 0 $TDIR"
3706 NUMS=$($CMD | wc -l)
3707 [ $NUMS -eq $EXPECTED ] ||
3708 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3710 run_test 56o "check lfs find -mtime for old files =========================="
3713 [ $RUNAS_ID -eq $UID ] &&
3714 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
3717 setup_56 $NUMFILES $NUMDIRS
3719 chown $RUNAS_ID $TDIR/file* || error "chown $DIR/${tdir}g/file$i failed"
3721 CMD="$LFIND -uid $RUNAS_ID $TDIR"
3722 NUMS=$($CMD | wc -l)
3723 [ $NUMS -eq $EXPECTED ] || \
3724 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3726 EXPECTED=$(((NUMFILES + 1) * NUMDIRS + 1))
3727 CMD="$LFIND ! -uid $RUNAS_ID $TDIR"
3728 NUMS=$($CMD | wc -l)
3729 [ $NUMS -eq $EXPECTED ] || \
3730 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3732 run_test 56p "check lfs find -uid and ! -uid ==============================="
3735 [ $RUNAS_ID -eq $UID ] &&
3736 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
3739 setup_56 $NUMFILES $NUMDIRS
3741 chgrp $RUNAS_GID $TDIR/file* || error "chown $TDIR/file$i failed"
3744 CMD="$LFIND -gid $RUNAS_GID $TDIR"
3745 NUMS=$($CMD | wc -l)
3746 [ $NUMS -eq $EXPECTED ] ||
3747 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3749 EXPECTED=$(( ($NUMFILES+1) * $NUMDIRS + 1))
3750 CMD="$LFIND ! -gid $RUNAS_GID $TDIR"
3751 NUMS=$($CMD | wc -l)
3752 [ $NUMS -eq $EXPECTED ] ||
3753 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3755 run_test 56q "check lfs find -gid and ! -gid ==============================="
3759 setup_56 $NUMFILES $NUMDIRS
3762 CMD="$LFIND -size 0 -type f $TDIR"
3763 NUMS=$($CMD | wc -l)
3764 [ $NUMS -eq $EXPECTED ] ||
3765 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3767 CMD="$LFIND ! -size 0 -type f $TDIR"
3768 NUMS=$($CMD | wc -l)
3769 [ $NUMS -eq $EXPECTED ] ||
3770 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3771 echo "test" > $TDIR/$tfile
3772 echo "test2" > $TDIR/$tfile.2 && sync
3774 CMD="$LFIND -size 5 -type f $TDIR"
3775 NUMS=$($CMD | wc -l)
3776 [ $NUMS -eq $EXPECTED ] ||
3777 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3779 CMD="$LFIND -size +5 -type f $TDIR"
3780 NUMS=$($CMD | wc -l)
3781 [ $NUMS -eq $EXPECTED ] ||
3782 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3784 CMD="$LFIND -size +0 -type f $TDIR"
3785 NUMS=$($CMD | wc -l)
3786 [ $NUMS -eq $EXPECTED ] ||
3787 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3789 CMD="$LFIND ! -size -5 -type f $TDIR"
3790 NUMS=$($CMD | wc -l)
3791 [ $NUMS -eq $EXPECTED ] ||
3792 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3794 CMD="$LFIND -size -5 -type f $TDIR"
3795 NUMS=$($CMD | wc -l)
3796 [ $NUMS -eq $EXPECTED ] ||
3797 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3799 run_test 56r "check lfs find -size works =========================="
3801 test_56s() { # LU-611
3803 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT"
3805 if [ $OSTCOUNT -gt 1 ]; then
3806 $SETSTRIPE -c 1 $TDIR/$tfile.{0,1,2,3}
3810 ONESTRIPE=$(((NUMDIRS + 1) * NUMFILES))
3814 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
3815 CMD="$LFIND -stripe-count $OSTCOUNT -type f $TDIR"
3816 NUMS=$($CMD | wc -l)
3817 [ $NUMS -eq $EXPECTED ] ||
3818 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3820 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + EXTRA))
3821 CMD="$LFIND -stripe-count +0 -type f $TDIR"
3822 NUMS=$($CMD | wc -l)
3823 [ $NUMS -eq $EXPECTED ] ||
3824 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3827 CMD="$LFIND -stripe-count 1 -type f $TDIR"
3828 NUMS=$($CMD | wc -l)
3829 [ $NUMS -eq $EXPECTED ] ||
3830 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3832 CMD="$LFIND -stripe-count -2 -type f $TDIR"
3833 NUMS=$($CMD | wc -l)
3834 [ $NUMS -eq $EXPECTED ] ||
3835 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3838 CMD="$LFIND -stripe-count $((OSTCOUNT + 1)) -type f $TDIR"
3839 NUMS=$($CMD | wc -l)
3840 [ $NUMS -eq $EXPECTED ] ||
3841 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3843 run_test 56s "check lfs find -stripe-count works"
3845 test_56t() { # LU-611
3847 setup_56 $NUMFILES $NUMDIRS "-s 512k"
3849 $SETSTRIPE -S 256k $TDIR/$tfile.{0,1,2,3}
3851 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
3852 CMD="$LFIND -stripe-size 512k -type f $TDIR"
3853 NUMS=$($CMD | wc -l)
3854 [ $NUMS -eq $EXPECTED ] ||
3855 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3857 CMD="$LFIND -stripe-size +320k -type f $TDIR"
3858 NUMS=$($CMD | wc -l)
3859 [ $NUMS -eq $EXPECTED ] ||
3860 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3862 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + 4))
3863 CMD="$LFIND -stripe-size +200k -type f $TDIR"
3864 NUMS=$($CMD | wc -l)
3865 [ $NUMS -eq $EXPECTED ] ||
3866 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3868 CMD="$LFIND -stripe-size -640k -type f $TDIR"
3869 NUMS=$($CMD | wc -l)
3870 [ $NUMS -eq $EXPECTED ] ||
3871 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3874 CMD="$LFIND -stripe-size 256k -type f $TDIR"
3875 NUMS=$($CMD | wc -l)
3876 [ $NUMS -eq $EXPECTED ] ||
3877 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3879 CMD="$LFIND -stripe-size -320k -type f $TDIR"
3880 NUMS=$($CMD | wc -l)
3881 [ $NUMS -eq $EXPECTED ] ||
3882 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3885 CMD="$LFIND -stripe-size 1024k -type f $TDIR"
3886 NUMS=$($CMD | wc -l)
3887 [ $NUMS -eq $EXPECTED ] ||
3888 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3890 run_test 56t "check lfs find -stripe-size works"
3892 test_56u() { # LU-611
3894 setup_56 $NUMFILES $NUMDIRS "-i 0"
3896 if [ $OSTCOUNT -gt 1 ]; then
3897 $SETSTRIPE -i 1 $TDIR/$tfile.{0,1,2,3}
3903 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
3904 CMD="$LFIND -stripe-index 0 -type f $TDIR"
3905 NUMS=$($CMD | wc -l)
3906 [ $NUMS -eq $EXPECTED ] ||
3907 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3910 CMD="$LFIND -stripe-index 1 -type f $TDIR"
3911 NUMS=$($CMD | wc -l)
3912 [ $NUMS -eq $EXPECTED ] ||
3913 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3915 CMD="$LFIND ! -stripe-index 0 -type f $TDIR"
3916 NUMS=$($CMD | wc -l)
3917 [ $NUMS -eq $EXPECTED ] ||
3918 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3921 # This should produce an error and not return any files
3922 CMD="$LFIND -stripe-index $OSTCOUNT -type f $TDIR"
3923 NUMS=$($CMD 2>/dev/null | wc -l)
3924 [ $NUMS -eq $EXPECTED ] ||
3925 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3927 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + ONESTRIPE))
3928 CMD="$LFIND -stripe-index 0,1 -type f $TDIR"
3929 NUMS=$($CMD | wc -l)
3930 [ $NUMS -eq $EXPECTED ] ||
3931 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3933 run_test 56u "check lfs find -stripe-index works"
3940 setup_56 $NUMFILES $NUMDIRS
3942 UUID=$(mdtuuid_from_index $MDT_IDX $TDIR)
3943 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT index $MDT_IDX"
3945 for file in $($LFIND -mdt $UUID $TDIR); do
3946 file_mdt_idx=$($GETSTRIPE -M $file)
3947 [ $file_mdt_idx -eq $MDT_IDX ] ||
3948 error "'lfind -mdt $UUID' != 'getstripe -M' ($file_mdt_idx)"
3951 run_test 56v "check 'lfs find -mdt match with lfs getstripe -M' ======="
3953 # Get and check the actual stripe count of one file.
3954 # Usage: check_stripe_count <file> <expected_stripe_count>
3955 check_stripe_count() {
3960 [[ -z "$file" || -z "$expected" ]] &&
3961 error "check_stripe_count: invalid argument!"
3963 local cmd="$GETSTRIPE -c $file"
3964 actual=$($cmd) || error "$cmd failed"
3965 actual=${actual%% *}
3967 if [[ $actual -ne $expected ]]; then
3968 [[ $expected -eq -1 ]] ||
3969 error "$cmd wrong: found $actual, expected $expected"
3970 [[ $actual -eq $OSTCOUNT ]] ||
3971 error "$cmd wrong: found $actual, expected $OSTCOUNT"
3978 rm -rf $TDIR || error "remove $TDIR failed"
3979 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT"
3982 stripe_size=$($GETSTRIPE -S -d $TDIR) ||
3983 error "$GETSTRIPE -S -d $TDIR failed"
3984 stripe_size=${stripe_size%% *}
3986 local file_size=$((stripe_size * OSTCOUNT))
3987 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
3988 local required_space=$((file_num * file_size))
3989 local free_space=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
3990 [[ $free_space -le $((required_space / 1024)) ]] &&
3991 skip_env "need at least $required_space bytes free space," \
3992 "have $free_space kbytes" && return
3995 local dd_count=$((file_size / dd_bs))
3997 # write data into the files
4001 for i in $(seq 1 $NUMFILES); do
4003 yes | dd bs=$dd_bs count=$dd_count of=$file >/dev/null 2>&1 ||
4004 error "write data into $file failed"
4006 for i in $(seq 1 $NUMDIRS); do
4007 for j in $(seq 1 $NUMFILES); do
4008 file=$TDIR/dir$i/file$j
4009 yes | dd bs=$dd_bs count=$dd_count of=$file \
4011 error "write data into $file failed"
4016 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
4019 local cmd="$LFS_MIGRATE -y -c $expected $TDIR/file1"
4021 eval $cmd || error "$cmd failed"
4023 check_stripe_count $TDIR/file1 $expected
4026 cmd="$LFS_MIGRATE -y -c $expected $TDIR/dir1"
4028 eval $cmd || error "$cmd failed"
4030 for j in $(seq 1 $NUMFILES); do
4031 check_stripe_count $TDIR/dir1/file$j $expected
4034 # lfs_migrate works with lfs find
4035 cmd="$LFIND -stripe_count $OSTCOUNT -type f $TDIR |
4036 $LFS_MIGRATE -y -c $expected"
4038 eval $cmd || error "$cmd failed"
4040 for i in $(seq 2 $NUMFILES); do
4041 check_stripe_count $TDIR/file$i $expected
4043 for i in $(seq 2 $NUMDIRS); do
4044 for j in $(seq 1 $NUMFILES); do
4045 check_stripe_count $TDIR/dir$i/file$j $expected
4049 run_test 56w "check lfs_migrate -c stripe_count works"
4052 # note test will not do anything if MDS is not local
4053 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4054 skip "Only applicable to ldiskfs-based MDTs"
4058 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4059 local MNTDEV="osd*.*MDT*.mntdev"
4060 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
4061 [ -z "$DEV" ] && error "can't access $MNTDEV"
4062 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
4063 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
4064 error "can't access $DEV"
4065 DEVISIZE=`awk '/Inode size:/ { print $3 }' $TMP/t57a.dump`
4066 [ "$DEVISIZE" -gt 128 ] || error "inode size $DEVISIZE"
4070 run_test 57a "verify MDS filesystem created with large inodes =="
4073 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4074 skip "Only applicable to ldiskfs-based MDTs"
4078 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4083 local FILEN=$dir/f$FILECOUNT
4085 rm -rf $dir || error "removing $dir"
4086 mkdir -p $dir || error "creating $dir"
4087 local num=$(get_mds_dir $dir)
4090 echo "mcreating $FILECOUNT files"
4091 createmany -m $dir/f 1 $FILECOUNT || \
4092 error "creating files in $dir"
4094 # verify that files do not have EAs yet
4095 $GETSTRIPE $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
4096 $GETSTRIPE $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
4100 df $dir #make sure we get new statfs data
4101 local MDSFREE=$(do_facet $mymds \
4102 lctl get_param -n osd*.*MDT000$((num -1)).kbytesfree)
4103 local MDCFREE=$(lctl get_param -n mdc.*MDT000$((num -1))-mdc-*.kbytesfree)
4104 echo "opening files to create objects/EAs"
4106 for FILE in `seq -f $dir/f%g 1 $FILECOUNT`; do
4107 $OPENFILE -f O_RDWR $FILE > /dev/null 2>&1 || error "opening $FILE"
4110 # verify that files have EAs now
4111 $GETSTRIPE $FILE1 | grep -q "obdidx" || error "$FILE1 missing EA"
4112 $GETSTRIPE $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
4114 sleep 1 #make sure we get new statfs data
4116 local MDSFREE2=$(do_facet $mymds \
4117 lctl get_param -n osd*.*MDT000$((num -1)).kbytesfree)
4118 local MDCFREE2=$(lctl get_param -n mdc.*MDT000$((num -1))-mdc-*.kbytesfree)
4119 if [ "$MDCFREE2" -lt "$((MDCFREE - 8))" ]; then
4120 if [ "$MDSFREE" != "$MDSFREE2" ]; then
4121 error "MDC before $MDCFREE != after $MDCFREE2"
4123 echo "MDC before $MDCFREE != after $MDCFREE2"
4124 echo "unable to confirm if MDS has large inodes"
4129 run_test 57b "default LOV EAs are stored inside large inodes ==="
4132 [ -z "$(which wiretest 2>/dev/null)" ] && skip_env "could not find wiretest" && return
4135 run_test 58 "verify cross-platform wire constants =============="
4138 echo "touch 130 files"
4139 createmany -o $DIR/f59- 130
4141 unlinkmany $DIR/f59- 130
4143 # wait for commitment of removal
4144 wait_delete_completed
4146 run_test 59 "verify cancellation of llog records async ========="
4148 TEST60_HEAD="test_60 run $RANDOM"
4150 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
4151 [ ! -f run-llog.sh ] && skip_env "missing subtest run-llog.sh" && return
4152 log "$TEST60_HEAD - from kernel mode"
4153 do_facet mgs sh run-llog.sh
4155 run_test 60a "llog sanity tests run from kernel module =========="
4157 test_60b() { # bug 6411
4159 LLOG_COUNT=`dmesg | awk "/$TEST60_HEAD/{marker = 1; from_marker = 0;}
4171 [ $LLOG_COUNT -gt 50 ] && error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)"|| true
4173 run_test 60b "limit repeated messages from CERROR/CWARN ========"
4176 echo "create 5000 files"
4177 createmany -o $DIR/f60c- 5000
4178 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
4179 lctl set_param fail_loc=0x80000137
4180 unlinkmany $DIR/f60c- 5000
4181 lctl set_param fail_loc=0
4183 run_test 60c "unlink file when mds full"
4186 SAVEPRINTK=$(lctl get_param -n printk)
4188 # verify "lctl mark" is even working"
4189 MESSAGE="test message ID $RANDOM $$"
4190 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
4191 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
4193 lctl set_param printk=0 || error "set lnet.printk failed"
4194 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
4195 MESSAGE="new test message ID $RANDOM $$"
4196 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
4197 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
4198 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
4200 lctl set_param -n printk="$SAVEPRINTK"
4202 run_test 60d "test printk console message masking"
4206 dd if=/dev/zero of=$f bs=`page_size` count=1
4207 cancel_lru_locks osc
4208 $MULTIOP $f OSMWUc || error
4211 run_test 61 "mmap() writes don't make sync hang ================"
4213 # bug 2330 - insufficient obd_match error checking causes LBUG
4217 cancel_lru_locks osc
4218 lctl set_param fail_loc=0x405
4219 cat $f && error "cat succeeded, expect -EIO"
4220 lctl set_param fail_loc=0
4222 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
4223 # match every page all of the time.
4224 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
4226 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
4227 test_63a() { # was test_63
4228 MAX_DIRTY_MB=`lctl get_param -n osc.*.max_dirty_mb | head -n 1`
4229 lctl set_param -n osc.*.max_dirty_mb 0
4230 for i in `seq 10` ; do
4231 dd if=/dev/zero of=$DIR/f63 bs=8k &
4237 lctl set_param -n osc.*.max_dirty_mb $MAX_DIRTY_MB
4238 rm -f $DIR/f63 || true
4240 run_test 63a "Verify oig_wait interruption does not crash ======="
4242 # bug 2248 - async write errors didn't return to application on sync
4243 # bug 3677 - async write errors left page locked
4246 lctl set_param debug=-1
4248 # ensure we have a grant to do async writes
4249 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
4252 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
4253 lctl set_param fail_loc=0x80000406
4254 $MULTIOP $DIR/$tfile Owy && \
4255 error "sync didn't return ENOMEM"
4256 sync; sleep 2; sync # do a real sync this time to flush page
4257 lctl get_param -n llite.*.dump_page_cache | grep locked && \
4258 error "locked page left in cache after async error" || true
4261 run_test 63b "async write errors should be returned to fsync ==="
4265 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
4267 run_test 64a "verify filter grant calculations (in kernel) ====="
4270 [ ! -f oos.sh ] && skip_env "missing subtest oos.sh" && return
4273 run_test 64b "check out-of-space detection on client ==========="
4275 # bug 1414 - set/get directories' stripe info
4279 $LVERIFY $DIR/d65 $DIR/d65/f1 || error "lverify failed"
4281 run_test 65a "directory with no stripe info ===================="
4285 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/d65||error "setstripe"
4287 $LVERIFY $DIR/d65 $DIR/d65/f2 || error "lverify failed"
4289 run_test 65b "directory setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1"
4292 if [ $OSTCOUNT -gt 1 ]; then
4294 $SETSTRIPE -S $(($STRIPESIZE * 4)) -i 1 \
4295 -c $(($OSTCOUNT - 1)) $DIR/d65 || error "setstripe"
4297 $LVERIFY $DIR/d65 $DIR/d65/f3 || error "lverify failed"
4300 run_test 65c "directory setstripe -S $((STRIPESIZE*4)) -i 1 -c $((OSTCOUNT-1))"
4304 if [ $STRIPECOUNT -le 0 ]; then
4306 elif [ $STRIPECOUNT -gt 2000 ]; then
4307 #LOV_MAX_STRIPE_COUNT is 2000
4308 [ $OSTCOUNT -gt 2000 ] && sc=2000 || sc=$(($OSTCOUNT - 1))
4310 sc=$(($STRIPECOUNT - 1))
4312 $SETSTRIPE -S $STRIPESIZE -c $sc $DIR/d65 || error "setstripe"
4313 touch $DIR/d65/f4 $DIR/d65/f5
4314 $LVERIFY $DIR/d65 $DIR/d65/f4 $DIR/d65/f5 || error "lverify failed"
4316 run_test 65d "directory setstripe -S $STRIPESIZE -c stripe_count"
4321 $SETSTRIPE $DIR/d65 || error "setstripe"
4322 $GETSTRIPE -v $DIR/d65 | grep "Default" || error "no stripe info failed"
4324 $LVERIFY $DIR/d65 $DIR/d65/f6 || error "lverify failed"
4326 run_test 65e "directory setstripe defaults ======================="
4330 $RUNAS $SETSTRIPE $DIR/d65f && error "setstripe succeeded" || true
4332 run_test 65f "dir setstripe permission (should return error) ==="
4336 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/d65 ||error "setstripe"
4337 $SETSTRIPE -d $DIR/d65 || error "setstripe"
4338 $GETSTRIPE -v $DIR/d65 | grep "Default" || \
4339 error "delete default stripe failed"
4341 run_test 65g "directory setstripe -d ==========================="
4345 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/d65 ||error "setstripe"
4346 mkdir -p $DIR/d65/dd1
4347 [ $($GETSTRIPE -c $DIR/d65) == $($GETSTRIPE -c $DIR/d65/dd1) ] ||
4348 error "stripe info inherit failed"
4350 run_test 65h "directory stripe info inherit ===================="
4352 test_65i() { # bug6367
4353 $SETSTRIPE -S 65536 -c -1 $MOUNT
4355 run_test 65i "set non-default striping on root directory (bug 6367)="
4357 test_65ia() { # bug12836
4358 $GETSTRIPE $MOUNT || error "getstripe $MOUNT failed"
4360 run_test 65ia "getstripe on -1 default directory striping"
4362 test_65ib() { # bug12836
4363 $GETSTRIPE -v $MOUNT || error "getstripe -v $MOUNT failed"
4365 run_test 65ib "getstripe -v on -1 default directory striping"
4367 test_65ic() { # bug12836
4368 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
4370 run_test 65ic "new find on -1 default directory striping"
4372 test_65j() { # bug6367
4374 # if we aren't already remounting for each test, do so for this test
4375 if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
4376 cleanup || error "failed to unmount"
4379 $SETSTRIPE -d $MOUNT || error "setstripe failed"
4381 run_test 65j "set default striping on root directory (bug 6367)="
4383 test_65k() { # bug11679
4384 [ "$OSTCOUNT" -lt 2 ] && skip_env "too few OSTs" && return
4385 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4387 echo "Check OST status: "
4388 local MDS_OSCS=`do_facet $SINGLEMDS lctl dl |
4389 awk '/[oO][sS][cC].*md[ts]/ { print $4 }'`
4391 for OSC in $MDS_OSCS; do
4392 echo $OSC "is activate"
4393 do_facet $SINGLEMDS lctl --device %$OSC activate
4396 do_facet client mkdir -p $DIR/$tdir
4397 for INACTIVE_OSC in $MDS_OSCS; do
4398 echo "Deactivate: " $INACTIVE_OSC
4399 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
4400 for STRIPE_OSC in $MDS_OSCS; do
4401 OST=`osc_to_ost $STRIPE_OSC`
4402 IDX=`do_facet $SINGLEMDS lctl get_param -n lov.*md*.target_obd |
4403 awk -F: /$OST/'{ print $1 }' | head -n 1`
4405 [ -f $DIR/$tdir/$IDX ] && continue
4406 echo "$SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX"
4407 do_facet client $SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX
4409 [ $RC -ne 0 ] && error "setstripe should have succeeded"
4411 do_facet client rm -f $DIR/$tdir/*
4412 echo $INACTIVE_OSC "is Activate."
4413 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
4416 run_test 65k "validate manual striping works properly with deactivated OSCs"
4418 test_65l() { # bug 12836
4419 mkdir -p $DIR/$tdir/test_dir
4420 $SETSTRIPE -c -1 $DIR/$tdir/test_dir
4421 $LFS find -mtime -1 $DIR/$tdir >/dev/null
4423 run_test 65l "lfs find on -1 stripe dir ========================"
4425 # bug 2543 - update blocks count on client
4428 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
4429 sync; sync_all_data; sync; sync_all_data
4430 cancel_lru_locks osc
4431 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
4432 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
4434 run_test 66 "update inode blocks count on client ==============="
4440 if [ ! -z "$LLOOP" ]; then
4441 if swapon -s | grep -q $LLOOP; then
4442 swapoff $LLOOP || error "swapoff failed"
4445 $LCTL blockdev_detach $LLOOP || error "detach failed"
4449 if [ ! -z "$LLITELOOPLOAD" ]; then
4457 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
4461 swapon -s | awk '($1 == "'$1'") { print $4 }'
4464 # test case for lloop driver, basic function
4466 [ "$UID" != 0 ] && skip_env "must run as root" && return
4467 llite_lloop_enabled || \
4468 { skip_env "llite_lloop module disabled" && return; }
4470 trap cleanup_68 EXIT
4472 if ! module_loaded llite_lloop; then
4473 if load_module llite/llite_lloop; then
4476 skip_env "can't find module llite_lloop"
4481 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
4482 dd if=/dev/zero of=$DIR/f68a bs=4k count=1024
4483 $LCTL blockdev_attach $DIR/f68a $LLOOP || error "attach failed"
4485 directio rdwr $LLOOP 0 1024 4096 || error "direct write failed"
4486 directio rdwr $LLOOP 0 1025 4096 && error "direct write should fail"
4490 run_test 68a "lloop driver - basic test ========================"
4492 # excercise swapping to lustre by adding a high priority swapfile entry
4493 # and then consuming memory until it is used.
4494 test_68b() { # was test_68
4495 [ "$UID" != 0 ] && skip_env "must run as root" && return
4496 lctl get_param -n devices | grep -q obdfilter && \
4497 skip "local OST" && return
4499 grep -q llite_lloop /proc/modules
4500 [ $? -ne 0 ] && skip "can't find module llite_lloop" && return
4502 [ -z "`$LCTL list_nids | grep -v tcp`" ] && \
4503 skip "can't reliably test swap with TCP" && return
4505 MEMTOTAL=`meminfo MemTotal`
4506 NR_BLOCKS=$((MEMTOTAL>>8))
4507 [[ $NR_BLOCKS -le 2048 ]] && NR_BLOCKS=2048
4509 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
4510 dd if=/dev/zero of=$DIR/f68b bs=64k seek=$NR_BLOCKS count=1
4513 $LCTL blockdev_attach $DIR/f68b $LLOOP || error "attach failed"
4515 trap cleanup_68 EXIT
4517 swapon -p 32767 $LLOOP || error "swapon $LLOOP failed"
4519 echo "before: `swapon -s | grep $LLOOP`"
4520 $MEMHOG $MEMTOTAL || error "error allocating $MEMTOTAL kB"
4521 echo "after: `swapon -s | grep $LLOOP`"
4522 SWAPUSED=`swap_used $LLOOP`
4526 [ $SWAPUSED -eq 0 ] && echo "no swap used???" || true
4528 run_test 68b "support swapping to Lustre ========================"
4530 # bug5265, obdfilter oa2dentry return -ENOENT
4531 # #define OBD_FAIL_OST_ENOENT 0x217
4533 remote_ost_nodsh && skip "remote OST with nodsh" && return
4536 $SETSTRIPE -c 1 -i 0 $f
4538 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
4540 do_facet ost1 lctl set_param fail_loc=0x217
4541 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
4542 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
4544 do_facet ost1 lctl set_param fail_loc=0
4545 $DIRECTIO write $f 0 2 || error "write error"
4547 cancel_lru_locks osc
4548 $DIRECTIO read $f 0 1 || error "read error"
4550 do_facet ost1 lctl set_param fail_loc=0x217
4551 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
4553 do_facet ost1 lctl set_param fail_loc=0
4556 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
4560 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
4562 run_test 71 "Running dbench on lustre (don't segment fault) ===="
4564 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
4565 check_kernel_version 43 || return 0
4566 [ "$RUNAS_ID" = "$UID" ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4568 # Check that testing environment is properly set up. Skip if not
4569 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS || {
4570 skip_env "User $RUNAS_ID does not exist - skipping"
4573 # We had better clear the $DIR to get enough space for dd
4578 $RUNAS dd if=/dev/zero of=$DIR/f72 bs=512 count=1 || error
4579 # See if we are still setuid/sgid
4580 test -u $DIR/f72 -o -g $DIR/f72 && error "S/gid is not dropped on write"
4581 # Now test that MDS is updated too
4582 cancel_lru_locks mdc
4583 test -u $DIR/f72 -o -g $DIR/f72 && error "S/gid is not dropped on MDS"
4586 run_test 72a "Test that remove suid works properly (bug5695) ===="
4588 test_72b() { # bug 24226 -- keep mode setting when size is not changing
4591 [ "$RUNAS_ID" = "$UID" ] && \
4592 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4593 [ "$RUNAS_ID" -eq 0 ] && \
4594 skip_env "RUNAS_ID = 0 -- skipping" && return
4596 # Check that testing environment is properly set up. Skip if not
4597 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS || {
4598 skip_env "User $RUNAS_ID does not exist - skipping"
4601 touch $DIR/${tfile}-f{g,u}
4602 mkdir $DIR/${tfile}-d{g,u}
4603 chmod 770 $DIR/${tfile}-{f,d}{g,u}
4604 chmod g+s $DIR/${tfile}-{f,d}g
4605 chmod u+s $DIR/${tfile}-{f,d}u
4606 for perm in 777 2777 4777; do
4607 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
4608 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
4609 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
4610 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
4614 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
4616 # bug 3462 - multiple simultaneous MDC requests
4620 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
4623 lctl set_param fail_loc=0x80000129
4624 $MULTIOP $DIR/d73-1/f73-2 Oc &
4626 lctl set_param fail_loc=0
4628 $MULTIOP $DIR/d73-2/f73-3 Oc &
4632 wait $pid1 || return 1
4636 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
4637 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
4638 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
4642 run_test 73 "multiple MDC requests (should not deadlock)"
4644 test_74a() { # bug 6149, 6184
4645 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
4647 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
4648 # will spin in a tight reconnection loop
4650 lctl set_param fail_loc=0x8000030e
4651 # get any lock that won't be difficult - lookup works.
4653 lctl set_param fail_loc=0
4657 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
4659 test_74b() { # bug 13310
4660 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
4662 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
4663 # will spin in a tight reconnection loop
4664 lctl set_param fail_loc=0x8000030e
4665 # get a "difficult" lock
4667 lctl set_param fail_loc=0
4671 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
4674 #define OBD_FAIL_LDLM_NEW_LOCK
4675 lctl set_param fail_loc=0x80000319
4676 touch $DIR/$tfile && error "Touch successful"
4679 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
4682 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
4685 get_inode_slab_tunables() {
4686 awk '/lustre_inode_cache/ {print $9," ",$10," ",$11; exit}' /proc/slabinfo
4689 set_inode_slab_tunables() {
4690 echo "lustre_inode_cache $1" > /proc/slabinfo
4693 test_76() { # Now for bug 20433, added originally in bug 1443
4694 local SLAB_SETTINGS=`get_inode_slab_tunables`
4695 local CPUS=`getconf _NPROCESSORS_ONLN`
4696 # we cannot set limit below 1 which means 1 inode in each
4697 # per-cpu cache is still allowed
4698 set_inode_slab_tunables "1 1 0"
4699 cancel_lru_locks osc
4700 BEFORE_INODES=`num_inodes`
4701 echo "before inodes: $BEFORE_INODES"
4703 [ "$SLOW" = "no" ] && COUNT=100
4704 for i in `seq $COUNT`; do
4708 cancel_lru_locks osc
4709 AFTER_INODES=`num_inodes`
4710 echo "after inodes: $AFTER_INODES"
4712 while [ $((AFTER_INODES-1*CPUS)) -gt $BEFORE_INODES ]; do
4714 AFTER_INODES=`num_inodes`
4716 echo "wait $wait seconds inodes: $AFTER_INODES"
4717 if [ $wait -gt 30 ]; then
4718 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
4721 set_inode_slab_tunables "$SLAB_SETTINGS"
4723 run_test 76 "confirm clients recycle inodes properly ===="
4729 # Note: in sptlrpc modes which enable its own bulk checksum, the
4730 # original crc32_le bulk checksum will be automatically disabled,
4731 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
4732 # will be checked by sptlrpc code against sptlrpc bulk checksum.
4733 # In this case set_checksums() will not be no-op, because sptlrpc
4734 # bulk checksum will be enabled all through the test.
4736 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
4737 lctl set_param -n osc.*.checksums $1
4741 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
4742 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
4743 CKSUM_TYPES=${CKSUM_TYPES:-"crc32 adler"}
4744 [ "$ORIG_CSUM_TYPE" = "crc32c" ] && CKSUM_TYPES="$CKSUM_TYPES crc32c"
4747 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
4748 log "set checksum type to $1"
4751 F77_TMP=$TMP/f77-temp
4754 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
4755 error "error writing to $F77_TMP"
4758 test_77a() { # bug 10889
4759 $GSS && skip "could not run with gss" && return
4760 [ ! -f $F77_TMP ] && setup_f77
4762 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
4766 run_test 77a "normal checksum read/write operation ============="
4768 test_77b() { # bug 10889
4769 $GSS && skip "could not run with gss" && return
4770 [ ! -f $F77_TMP ] && setup_f77
4771 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
4772 lctl set_param fail_loc=0x80000409
4774 dd if=$F77_TMP of=$DIR/f77b bs=1M count=$F77SZ conv=sync || \
4775 error "dd error: $?"
4776 lctl set_param fail_loc=0
4779 run_test 77b "checksum error on client write ===================="
4781 test_77c() { # bug 10889
4782 $GSS && skip "could not run with gss" && return
4783 [ ! -f $DIR/f77b ] && skip "requires 77b - skipping" && return
4785 for algo in $CKSUM_TYPES; do
4786 cancel_lru_locks osc
4787 set_checksum_type $algo
4788 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
4789 lctl set_param fail_loc=0x80000408
4790 cmp $F77_TMP $DIR/f77b || error "file compare failed"
4791 lctl set_param fail_loc=0
4794 set_checksum_type $ORIG_CSUM_TYPE
4797 run_test 77c "checksum error on client read ==================="
4799 test_77d() { # bug 10889
4800 $GSS && skip "could not run with gss" && return
4801 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
4802 lctl set_param fail_loc=0x80000409
4804 directio write $DIR/f77 0 $F77SZ $((1024 * 1024)) || \
4805 error "direct write: rc=$?"
4806 lctl set_param fail_loc=0
4809 run_test 77d "checksum error on OST direct write ==============="
4811 test_77e() { # bug 10889
4812 $GSS && skip "could not run with gss" && return
4813 [ ! -f $DIR/f77 ] && skip "requires 77d - skipping" && return
4814 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
4815 lctl set_param fail_loc=0x80000408
4817 cancel_lru_locks osc
4818 directio read $DIR/f77 0 $F77SZ $((1024 * 1024)) || \
4819 error "direct read: rc=$?"
4820 lctl set_param fail_loc=0
4823 run_test 77e "checksum error on OST direct read ================"
4825 test_77f() { # bug 10889
4826 $GSS && skip "could not run with gss" && return
4828 for algo in $CKSUM_TYPES; do
4829 cancel_lru_locks osc
4830 set_checksum_type $algo
4831 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
4832 lctl set_param fail_loc=0x409
4833 directio write $DIR/f77 0 $F77SZ $((1024 * 1024)) && \
4834 error "direct write succeeded"
4835 lctl set_param fail_loc=0
4837 set_checksum_type $ORIG_CSUM_TYPE
4840 run_test 77f "repeat checksum error on write (expect error) ===="
4842 test_77g() { # bug 10889
4843 $GSS && skip "could not run with gss" && return
4844 remote_ost_nodsh && skip "remote OST with nodsh" && return
4846 [ ! -f $F77_TMP ] && setup_f77
4848 $SETSTRIPE -c 1 -i 0 $DIR/f77g
4849 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
4850 do_facet ost1 lctl set_param fail_loc=0x8000021a
4852 dd if=$F77_TMP of=$DIR/f77g bs=1M count=$F77SZ || \
4853 error "write error: rc=$?"
4854 do_facet ost1 lctl set_param fail_loc=0
4857 run_test 77g "checksum error on OST write ======================"
4859 test_77h() { # bug 10889
4860 $GSS && skip "could not run with gss" && return
4861 remote_ost_nodsh && skip "remote OST with nodsh" && return
4863 [ ! -f $DIR/f77g ] && skip "requires 77g - skipping" && return
4864 cancel_lru_locks osc
4865 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
4866 do_facet ost1 lctl set_param fail_loc=0x8000021b
4868 cmp $F77_TMP $DIR/f77g || error "file compare failed"
4869 do_facet ost1 lctl set_param fail_loc=0
4872 run_test 77h "checksum error on OST read ======================="
4874 test_77i() { # bug 13805
4875 $GSS && skip "could not run with gss" && return
4876 #define OBD_FAIL_OSC_CONNECT_CKSUM 0x40b
4877 lctl set_param fail_loc=0x40b
4878 remount_client $MOUNT
4879 lctl set_param fail_loc=0
4880 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
4881 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
4882 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
4883 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
4885 remount_client $MOUNT
4887 run_test 77i "client not supporting OSD_CONNECT_CKSUM =========="
4889 test_77j() { # bug 13805
4890 $GSS && skip "could not run with gss" && return
4891 #define OBD_FAIL_OSC_CKSUM_ADLER_ONLY 0x40c
4892 lctl set_param fail_loc=0x40c
4893 remount_client $MOUNT
4894 lctl set_param fail_loc=0
4895 sleep 2 # wait async osc connect to finish
4896 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
4897 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
4898 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
4899 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
4901 remount_client $MOUNT
4903 run_test 77j "client only supporting ADLER32 ===================="
4905 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
4909 test_78() { # bug 10901
4910 remote_ost || { skip_env "local OST" && return; }
4913 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
4914 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
4915 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
4916 echo "MemTotal: $MEMTOTAL"
4917 # reserve 256MB of memory for the kernel and other running processes,
4918 # and then take 1/2 of the remaining memory for the read/write buffers.
4919 if [ $MEMTOTAL -gt 512 ] ;then
4920 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
4922 # for those poor memory-starved high-end clusters...
4923 MEMTOTAL=$((MEMTOTAL / 2))
4925 echo "Mem to use for directio: $MEMTOTAL"
4926 [ $F78SIZE -gt $MEMTOTAL ] && F78SIZE=$MEMTOTAL
4927 [ $F78SIZE -gt 512 ] && F78SIZE=512
4928 [ $F78SIZE -gt $((MAXFREE / 1024)) ] && F78SIZE=$((MAXFREE / 1024))
4929 SMALLESTOST=`lfs df $DIR |grep OST | awk '{print $4}' |sort -n |head -1`
4930 echo "Smallest OST: $SMALLESTOST"
4931 [ $SMALLESTOST -lt 10240 ] && \
4932 skip "too small OSTSIZE, useless to run large O_DIRECT test" && return 0
4934 [ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ] && \
4935 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
4937 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
4938 echo "File size: $F78SIZE"
4939 $SETSTRIPE -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
4940 for i in `seq 1 $NSEQ`
4942 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
4943 echo directIO rdwr round $i of $NSEQ
4944 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
4949 run_test 78 "handle large O_DIRECT writes correctly ============"
4951 test_79() { # bug 12743
4952 wait_delete_completed
4954 BKTOTAL=$(calc_osc_kbytes kbytestotal)
4955 BKFREE=$(calc_osc_kbytes kbytesfree)
4956 BKAVAIL=$(calc_osc_kbytes kbytesavail)
4958 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
4959 DFTOTAL=`echo $STRING | cut -d, -f1`
4960 DFUSED=`echo $STRING | cut -d, -f2`
4961 DFAVAIL=`echo $STRING | cut -d, -f3`
4962 DFFREE=$(($DFTOTAL - $DFUSED))
4964 ALLOWANCE=$((64 * $OSTCOUNT))
4966 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
4967 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
4968 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
4970 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
4971 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
4972 error "df free($DFFREE) mismatch OST free($BKFREE)"
4974 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
4975 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
4976 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
4979 run_test 79 "df report consistency check ======================="
4981 test_80() { # bug 10718
4982 # relax strong synchronous semantics for slow backends like ZFS
4983 local soc="obdfilter.*.sync_on_lock_cancel"
4984 local soc_old=$(do_facet ost1 lctl get_param -n $soc | head -n1)
4986 if [ "$soc_old" != "never" -a "$FSTYPE" != "ldiskfs" ]; then
4987 hosts=$(for host in $(seq -f "ost%g" 1 $OSTCOUNT); do
4988 facet_active_host $host; done | sort -u)
4989 do_nodes $hosts lctl set_param $soc=never
4992 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
4994 local BEFORE=`date +%s`
4995 cancel_lru_locks osc
4996 local AFTER=`date +%s`
4997 local DIFF=$((AFTER-BEFORE))
4998 if [ $DIFF -gt 1 ] ; then
4999 error "elapsed for 1M@1T = $DIFF"
5002 [ -n "$hosts" ] && do_nodes $hosts lctl set_param $soc=$soc_old
5006 run_test 80 "Page eviction is equally fast at high offsets too ===="
5008 test_81a() { # LU-456
5009 remote_ost_nodsh && skip "remote OST with nodsh" && return
5010 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
5011 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
5012 do_facet ost1 lctl set_param fail_loc=0x80000228
5014 # write should trigger a retry and success
5015 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
5016 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
5018 if [ $RC -ne 0 ] ; then
5019 error "write should success, but failed for $RC"
5022 run_test 81a "OST should retry write when get -ENOSPC ==============="
5024 test_81b() { # LU-456
5025 remote_ost_nodsh && skip "remote OST with nodsh" && return
5026 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
5027 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
5028 do_facet ost1 lctl set_param fail_loc=0x228
5030 # write should retry several times and return -ENOSPC finally
5031 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
5032 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
5035 if [ $RC -ne $ENOSPC ] ; then
5036 error "dd should fail for -ENOSPC, but succeed."
5039 run_test 81b "OST should return -ENOSPC when retry still fails ======="
5041 test_82() { # LU-1031
5042 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10
5046 multiop_bg_pause $DIR/$tfile OG${gid1}_g${gid1}c || return 1
5048 multiop_bg_pause $DIR/$tfile O_G${gid2}r10g${gid2}c || return 2
5050 kill -USR1 $MULTIPID2
5052 if [[ `ps h -o comm -p $MULTIPID2` == "" ]]; then
5053 error "First grouplock does not block second one"
5055 echo "Second grouplock blocks first one"
5057 kill -USR1 $MULTIPID1
5061 run_test 82 "Basic grouplock test ==============================="
5064 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && \
5066 mkdir -p $DIR/d99cvsroot
5067 chown $RUNAS_ID $DIR/d99cvsroot
5068 local oldPWD=$PWD # bug 13584, use $TMP as working dir
5071 $RUNAS cvs -d $DIR/d99cvsroot init || error
5074 run_test 99a "cvs init ========================================="
5077 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5078 [ ! -d $DIR/d99cvsroot ] && test_99a
5080 # some versions of cvs import exit(1) when asked to import links or
5081 # files they can't read. ignore those files.
5082 TOIGNORE=$(find . -type l -printf '-I %f\n' -o \
5083 ! -perm +4 -printf '-I %f\n')
5084 $RUNAS cvs -d $DIR/d99cvsroot import -m "nomesg" $TOIGNORE \
5085 d99reposname vtag rtag
5087 run_test 99b "cvs import ======================================="
5090 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5091 [ ! -d $DIR/d99cvsroot ] && test_99b
5093 mkdir -p $DIR/d99reposname
5094 chown $RUNAS_ID $DIR/d99reposname
5095 $RUNAS cvs -d $DIR/d99cvsroot co d99reposname
5097 run_test 99c "cvs checkout ====================================="
5100 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5101 [ ! -d $DIR/d99cvsroot ] && test_99c
5102 cd $DIR/d99reposname
5104 $RUNAS cvs add -m 'addmsg' foo99
5106 run_test 99d "cvs add =========================================="
5109 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5110 [ ! -d $DIR/d99cvsroot ] && test_99c
5111 cd $DIR/d99reposname
5114 run_test 99e "cvs update ======================================="
5117 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5118 [ ! -d $DIR/d99cvsroot ] && test_99d
5119 cd $DIR/d99reposname
5120 $RUNAS cvs commit -m 'nomsg' foo99
5121 rm -fr $DIR/d99cvsroot
5123 run_test 99f "cvs commit ======================================="
5126 [ "$NETTYPE" = tcp ] || \
5127 { skip "TCP secure port test, not useful for NETTYPE=$NETTYPE" && \
5130 remote_ost_nodsh && skip "remote OST with nodsh" && return
5131 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5133 { skip "useless for local single node setup" && return; }
5135 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
5136 [ "$PROT" != "tcp" ] && continue
5137 RPORT=$(echo $REMOTE | cut -d: -f2)
5138 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
5141 LPORT=`echo $LOCAL | cut -d: -f2`
5142 if [ $LPORT -ge 1024 ]; then
5143 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
5145 error_exit "local: $LPORT > 1024, remote: $RPORT"
5148 [ "$rc" = 0 ] || error_exit "privileged port not found" )
5150 run_test 100 "check local port using privileged port ==========="
5152 function get_named_value()
5161 echo $line | sed "s/^$tag[ ]*//"
5168 export CACHE_MAX=`$LCTL get_param -n llite.*.max_cached_mb | head -n 1`
5170 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
5178 [ "$CPU" = "UML" ] && nreads=1000
5179 local cache_limit=32
5181 $LCTL set_param -n osc.*-osc*.rpc_stats 0
5182 trap cleanup_101a EXIT
5183 $LCTL set_param -n llite.*.read_ahead_stats 0
5184 $LCTL set_param -n llite.*.max_cached_mb $cache_limit
5187 # randomly read 10000 of 64K chunks from file 3x 32MB in size
5189 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
5190 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
5193 for s in `$LCTL get_param -n llite.*.read_ahead_stats | \
5194 get_named_value 'read but discarded' | cut -d" " -f1`; do
5195 discard=$(($discard + $s))
5199 if [ $(($discard * 10)) -gt $nreads ] ;then
5200 $LCTL get_param osc.*-osc*.rpc_stats
5201 $LCTL get_param llite.*.read_ahead_stats
5202 error "too many ($discard) discarded pages"
5204 rm -f $DIR/$tfile || true
5206 run_test 101a "check read-ahead for random reads ================"
5211 STRIPE_COUNT=$OSTCOUNT
5214 local list=$(comma_list $(osts_nodes))
5215 do_nodes $list $LCTL set_param -n obdfilter.*.read_cache_enable=0
5216 do_nodes $list $LCTL set_param -n obdfilter.*.writethrough_cache_enable=0
5218 trap cleanup_test101bc EXIT
5219 # prepare the read-ahead file
5220 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
5222 dd if=/dev/zero of=$DIR/$tfile bs=1024k count=100 2> /dev/null
5225 cleanup_test101bc() {
5230 local list=$(comma_list $(osts_nodes))
5231 do_nodes $list $LCTL set_param -n obdfilter.*.read_cache_enable=1
5232 do_nodes $list $LCTL set_param -n obdfilter.*.writethrough_cache_enable=1
5236 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
5241 local STRIPE_SIZE=1048576
5242 local RA_INC=1048576
5243 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
5244 local FILE_LENGTH=$((64*100))
5245 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
5246 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
5247 DISCARD=`$LCTL get_param -n llite.*.read_ahead_stats | \
5248 get_named_value 'read but discarded' | \
5249 cut -d" " -f1 | calc_total`
5250 if [ $DISCARD -gt $discard_limit ]; then
5251 $LCTL get_param llite.*.read_ahead_stats
5252 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
5254 echo "Read-ahead success for size ${READ_SIZE}"
5259 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping stride IO stride-ahead test" && return
5260 local STRIPE_SIZE=1048576
5261 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
5262 local FILE_LENGTH=$((STRIPE_SIZE*100))
5263 local ITERATION=$((FILE_LENGTH/STRIDE_SIZE))
5264 # prepare the read-ahead file
5266 cancel_lru_locks osc
5267 for BIDX in 2 4 8 16 32 64 128 256
5269 local BSIZE=$((BIDX*4096))
5270 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
5271 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
5272 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
5273 $LCTL set_param -n llite.*.read_ahead_stats 0
5274 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
5275 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
5276 cancel_lru_locks osc
5282 run_test 101b "check stride-io mode read-ahead ================="
5285 local STRIPE_SIZE=1048576
5286 local FILE_LENGTH=$((STRIPE_SIZE*100))
5292 cancel_lru_locks osc
5293 $LCTL set_param osc.*.rpc_stats 0
5294 $READS -f $DIR/$tfile -s$FILE_LENGTH -b65536 -n$nreads -t 180
5295 for osc in $($LCTL get_param -N osc.*); do
5296 if [ "$osc" == "osc.num_refs" ]; then
5300 local lines=$($LCTL get_param -n ${osc}.rpc_stats | wc | awk '{print $1}')
5301 if [ $lines -le 20 ]; then
5305 local rpc4k=$($LCTL get_param -n ${osc}.rpc_stats |
5306 awk '$1 == "1:" { print $2; exit; }')
5307 local rpc8k=$($LCTL get_param -n ${osc}.rpc_stats |
5308 awk '$1 == "2:" { print $2; exit; }')
5309 local rpc16k=$($LCTL get_param -n ${osc}.rpc_stats |
5310 awk '$1 == "4:" { print $2; exit; }')
5311 local rpc32k=$($LCTL get_param -n ${osc}.rpc_stats |
5312 awk '$1 == "8:" { print $2; exit; }')
5314 [ $rpc4k != 0 ] && error "Small 4k read IO ${rpc4k}!"
5315 [ $rpc8k != 0 ] && error "Small 8k read IO ${rpc8k}!"
5316 [ $rpc16k != 0 ] && error "Small 16k read IO ${rpc16k}!"
5317 [ $rpc32k != 0 ] && error "Small 32k read IO ${rpc32k}!"
5318 echo "${osc} rpc check passed!"
5323 run_test 101c "check stripe_size aligned read-ahead ================="
5326 $LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1
5327 $LCTL set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
5331 local file=$DIR/$tfile
5332 local size=${FILESIZE_101c:-500}
5333 local ra_MB=${READAHEAD_MB:-40}
5335 local space=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
5336 [ $space -gt $((size / 1024)) ] ||
5337 { skip "Need free space ${size}M, have $space" && return; }
5339 echo Creating ${size}M test file $file
5340 dd if=/dev/zero of=$file bs=1M count=$size || error "dd failed"
5341 echo Cancel LRU locks on lustre client to flush the client cache
5342 cancel_lru_locks osc
5344 echo Disable read-ahead
5345 local old_READAHEAD=$(set_read_ahead 0)
5347 echo Reading the test file $file with read-ahead disabled
5348 time_ra_OFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$size")
5350 echo Cancel LRU locks on lustre client to flush the client cache
5351 cancel_lru_locks osc
5352 echo Enable read-ahead with ${ra_MB}MB
5353 set_read_ahead $ra_MB
5355 echo Reading the test file $file with read-ahead enabled
5356 time_ra_ON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$size")
5358 echo read-ahead disabled time read $time_ra_OFF
5359 echo read-ahead enabled time read $time_ra_ON
5361 set_read_ahead $old_READAHEAD
5363 wait_delete_completed
5365 [ $time_ra_ON -lt $time_ra_OFF ] ||
5366 error "read-ahead enabled time read (${time_ra_ON}s) is more than
5367 read-ahead disabled time read (${time_ra_OFF}s) filesize ${size}M"
5369 run_test 101d "file read with and without read-ahead enabled ================="
5372 local file=$DIR/$tfile
5377 local space=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
5378 local need_space=$((count * size))
5379 [ $space -gt $need_space ] ||
5380 { skip_env "Need free space $need_space, have $space" && return; }
5382 echo Creating $count ${size}K test files
5383 for ((i = 0; i < $count; i++)); do
5384 dd if=/dev/zero of=${file}_${i} bs=$blksize count=$size 2>/dev/null
5387 echo Cancel LRU locks on lustre client to flush the client cache
5388 cancel_lru_locks osc
5390 echo Reset readahead stats
5391 $LCTL set_param -n llite.*.read_ahead_stats 0
5393 for ((i = 0; i < $count; i++)); do
5394 dd if=${file}_${i} of=/dev/null bs=$blksize count=$size 2>/dev/null
5397 local miss=$($LCTL get_param -n llite.*.read_ahead_stats | \
5398 get_named_value 'misses' | cut -d" " -f1 | calc_total)
5400 for ((i = 0; i < $count; i++)); do
5401 rm -rf ${file}_${i} 2>/dev/null
5404 #10000 means 20% reads are missing in readahead
5405 [ $miss -lt 10000 ] || error "misses too much for small reads"
5407 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
5409 cleanup_test101f() {
5411 $LCTL set_param -n llite.*.max_read_ahead_whole_mb $MAX_WHOLE_MB
5412 rm -rf $DIR/$tfile 2>/dev/null
5416 local file=$DIR/$tfile
5419 MAX_WHOLE_MB=$($LCTL get_param -n llite.*.max_read_ahead_whole_mb)
5420 $LCTL set_param -n llite.*.max_read_ahead_whole_mb 2
5421 dd if=/dev/zero of=${file} bs=2097152 count=1 2>/dev/null
5422 trap cleanup_test101f EXIT
5424 echo Cancel LRU locks on lustre client to flush the client cache
5425 cancel_lru_locks osc
5427 echo Reset readahead stats
5428 $LCTL set_param -n llite.*.read_ahead_stats 0
5429 # Random read in a 2M file, because max_read_ahead_whole_mb = 2M,
5430 # readahead should read in 2M file on second read, so only miss
5432 echo Random 4K reads on 2M file for 1000 times
5433 $READS -f $file -s 2097152 -b 4096 -n $nreads
5435 echo checking missing pages
5436 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
5437 get_named_value 'misses' | cut -d" " -f1 | calc_total)
5439 [ $miss -lt 3 ] || error "misses too much pages!"
5442 run_test 101f "check read-ahead for max_read_ahead_whole_mb"
5446 chown $RUNAS_ID $DIR/$tdir
5449 STRIPE_COUNT=$OSTCOUNT
5450 [ $OSTCOUNT -gt 4 ] && STRIPE_COUNT=4
5452 trap cleanup_test102 EXIT
5454 $1 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
5456 for num in 1 2 3 4; do
5457 for count in $(seq 1 $STRIPE_COUNT); do
5458 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
5459 local size=`expr $STRIPE_SIZE \* $num`
5460 local file=file"$num-$idx-$count"
5461 $1 $SETSTRIPE -S $size -i $idx -c $count $file
5467 $1 $TAR cf $TMP/f102.tar $tdir --xattrs
5473 rm -rf $DIR/d0.sanity/d102
5477 local testfile=$DIR/xattr_testfile
5481 [ "$UID" != 0 ] && skip_env "must run as root" && return
5482 [ -z "`lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr`" ] &&
5483 skip_env "must have user_xattr" && return
5485 [ -z "$(which setfattr 2>/dev/null)" ] &&
5486 skip_env "could not find setfattr" && return
5488 echo "set/get xattr..."
5489 setfattr -n trusted.name1 -v value1 $testfile || error
5490 getfattr -n trusted.name1 $testfile 2> /dev/null |
5491 grep "trusted.name1=.value1" ||
5492 error "$testfile missing trusted.name1=value1"
5494 setfattr -n user.author1 -v author1 $testfile || error
5495 getfattr -n user.author1 $testfile 2> /dev/null |
5496 grep "user.author1=.author1" ||
5497 error "$testfile missing trusted.author1=author1"
5500 setfattr -n trusted.name2 -v value2 $testfile ||
5501 error "$testfile unable to set trusted.name2"
5502 setfattr -n trusted.name3 -v value3 $testfile ||
5503 error "$testfile unable to set trusted.name3"
5504 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
5505 grep "trusted.name" | wc -l) -eq 3 ] ||
5506 error "$testfile missing 3 trusted.name xattrs"
5508 setfattr -n user.author2 -v author2 $testfile ||
5509 error "$testfile unable to set user.author2"
5510 setfattr -n user.author3 -v author3 $testfile ||
5511 error "$testfile unable to set user.author3"
5512 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
5513 grep "user.author" | wc -l) -eq 3 ] ||
5514 error "$testfile missing 3 user.author xattrs"
5516 echo "remove xattr..."
5517 setfattr -x trusted.name1 $testfile ||
5518 error "$testfile error deleting trusted.name1"
5519 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
5520 error "$testfile did not delete trusted.name1 xattr"
5522 setfattr -x user.author1 $testfile ||
5523 error "$testfile error deleting user.author1"
5524 getfattr -d -m user $testfile 2> /dev/null | grep "user.author1" &&
5525 error "$testfile did not delete trusted.name1 xattr"
5527 # b10667: setting lustre special xattr be silently discarded
5528 echo "set lustre special xattr ..."
5529 setfattr -n "trusted.lov" -v "invalid value" $testfile ||
5530 error "$testfile allowed setting trusted.lov"
5532 run_test 102a "user xattr test =================================="
5535 # b10930: get/set/list trusted.lov xattr
5536 echo "get/set/list trusted.lov xattr ..."
5537 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
5538 local testfile=$DIR/$tfile
5539 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
5540 error "setstripe failed"
5541 local STRIPECOUNT=$($GETSTRIPE -c $testfile) ||
5542 error "getstripe failed"
5543 getfattr -d -m "^trusted" $testfile 2> /dev/null | \
5544 grep "trusted.lov" || error "can't get trusted.lov from $testfile"
5546 local testfile2=${testfile}2
5547 local value=`getfattr -n trusted.lov $testfile 2> /dev/null | \
5548 grep "trusted.lov" |sed -e 's/[^=]\+=//'`
5551 setfattr -n trusted.lov -v $value $testfile2
5552 local stripe_size=$($GETSTRIPE -S $testfile2)
5553 local stripe_count=$($GETSTRIPE -c $testfile2)
5554 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
5555 [ $stripe_count -eq $STRIPECOUNT ] ||
5556 error "stripe count $stripe_count != $STRIPECOUNT"
5559 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
5562 # b10930: get/set/list lustre.lov xattr
5563 echo "get/set/list lustre.lov xattr ..."
5564 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
5566 chown $RUNAS_ID $DIR/$tdir
5567 local testfile=$DIR/$tdir/$tfile
5568 $RUNAS $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
5569 error "setstripe failed"
5570 local STRIPECOUNT=$($RUNAS $GETSTRIPE -c $testfile) ||
5571 error "getstripe failed"
5572 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
5573 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
5575 local testfile2=${testfile}2
5576 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
5577 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
5579 $RUNAS $MCREATE $testfile2
5580 $RUNAS setfattr -n lustre.lov -v $value $testfile2
5581 local stripe_size=$($RUNAS $GETSTRIPE -S $testfile2)
5582 local stripe_count=$($RUNAS $GETSTRIPE -c $testfile2)
5583 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
5584 [ $stripe_count -eq $STRIPECOUNT ] ||
5585 error "stripe count $stripe_count != $STRIPECOUNT"
5587 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
5589 compare_stripe_info1() {
5590 local stripe_index_all_zero=true
5592 for num in 1 2 3 4; do
5593 for count in $(seq 1 $STRIPE_COUNT); do
5594 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
5595 local size=$((STRIPE_SIZE * num))
5596 local file=file"$num-$offset-$count"
5597 stripe_size=$(lfs getstripe -S $PWD/$file)
5598 [ $stripe_size -ne $size ] &&
5599 error "$file: size $stripe_size != $size"
5600 stripe_count=$(lfs getstripe -c $PWD/$file)
5601 # allow fewer stripes to be created, ORI-601
5602 [ $stripe_count -lt $(((3 * count + 3) / 4)) ]&&
5603 error "$file: count $stripe_count != $count"
5604 stripe_index=$(lfs getstripe -i $PWD/$file)
5605 [ $stripe_index -ne 0 ] &&
5606 stripe_index_all_zero=false
5610 $stripe_index_all_zero &&
5611 error "all files are being extracted starting from OST index 0"
5616 [ -n "$(which tar 2>/dev/null)" ] &&
5617 strings $(which tar) | grep -q "lustre" && echo tar
5621 # b10930: tar test for trusted.lov xattr
5622 TAR=$(find_lustre_tar)
5623 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
5624 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
5627 $TAR xf $TMP/f102.tar -C $DIR/d102d --xattrs
5629 compare_stripe_info1
5631 run_test 102d "tar restore stripe info from tarfile,not keep osts ==========="
5634 # b10930: tar test for trusted.lov xattr
5635 TAR=$(find_lustre_tar)
5636 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
5637 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
5641 $TAR cf - --xattrs $tdir | $TAR xf - --xattrs -C $DIR/d102f
5643 compare_stripe_info1
5645 run_test 102f "tar copy files, not keep osts ==========="
5648 local xsize=${1:-1024} # in bytes
5649 local file=$DIR/$tfile
5651 [ -z $(lctl get_param -n mdc.*.connect_flags | grep xattr) ] &&
5652 skip "must have user_xattr" && return 0
5653 [ -z "$(which setfattr 2>/dev/null)" ] &&
5654 skip_env "could not find setfattr" && return 0
5655 [ -z "$(which getfattr 2>/dev/null)" ] &&
5656 skip_env "could not find getfattr" && return 0
5660 local value="$(generate_string $xsize)"
5662 local xbig=trusted.big
5663 log "save $xbig on $file"
5664 setfattr -n $xbig -v $value $file ||
5665 error "saving $xbig on $file failed"
5667 local orig=$(get_xattr_value $xbig $file)
5668 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
5670 local xsml=trusted.sml
5671 log "save $xsml on $file"
5672 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
5674 local new=$(get_xattr_value $xbig $file)
5675 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
5677 log "grow $xsml on $file"
5678 setfattr -n $xsml -v "$value" $file ||
5679 error "growing $xsml on $file failed"
5681 new=$(get_xattr_value $xbig $file)
5682 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
5683 log "$xbig still valid after growing $xsml"
5688 test_102h() { # bug 15777
5691 run_test 102h "grow xattr from inside inode to external block"
5694 large_xattr_enabled || { skip "large_xattr disabled" && return; }
5695 grow_xattr $(max_xattr_size)
5697 run_test 102ha "grow xattr from inside inode to external inode"
5699 test_102i() { # bug 17038
5701 ln -s $DIR/$tfile $DIR/${tfile}link
5702 getfattr -n trusted.lov $DIR/$tfile || error "lgetxattr on $DIR/$tfile failed"
5703 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"
5704 rm -f $DIR/$tfile $DIR/${tfile}link
5706 run_test 102i "lgetxattr test on symbolic link ============"
5709 TAR=$(find_lustre_tar)
5710 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
5711 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
5712 setup_test102 "$RUNAS"
5714 chown $RUNAS_ID $DIR/d102j
5715 $RUNAS $TAR xf $TMP/f102.tar -C $DIR/d102j --xattrs
5717 compare_stripe_info1 "$RUNAS"
5719 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
5723 # b22187 just check that does not crash for regular file.
5724 setfattr -n trusted.lov $DIR/$tfile
5725 # b22187 'setfattr -n trusted.lov' should work as remove LOV EA for directories
5726 local test_kdir=$DIR/d102k
5728 local default_size=`$GETSTRIPE -S $test_kdir`
5729 local default_count=`$GETSTRIPE -c $test_kdir`
5730 local default_offset=`$GETSTRIPE -i $test_kdir`
5731 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $test_kdir ||
5732 error 'dir setstripe failed'
5733 setfattr -n trusted.lov $test_kdir
5734 local stripe_size=`$GETSTRIPE -S $test_kdir`
5735 local stripe_count=`$GETSTRIPE -c $test_kdir`
5736 local stripe_offset=`$GETSTRIPE -i $test_kdir`
5737 [ $stripe_size -eq $default_size ] ||
5738 error "stripe size $stripe_size != $default_size"
5739 [ $stripe_count -eq $default_count ] ||
5740 error "stripe count $stripe_count != $default_count"
5741 [ $stripe_offset -eq $default_offset ] ||
5742 error "stripe offset $stripe_offset != $default_offset"
5743 rm -rf $DIR/$tfile $test_kdir
5745 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
5748 # LU-532 trusted. xattr is invisible to non-root
5749 local testfile=$DIR/$tfile
5753 echo "listxattr as user..."
5754 chown $RUNAS_ID $testfile
5755 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
5756 grep -q "trusted" &&
5757 error "$testfile trusted xattrs are user visible"
5761 run_test 102l "listxattr filter test =================================="
5767 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
5772 [ "$UID" != 0 ] && skip_env "must run as root" && return
5773 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
5774 [ -z "$(which setfacl 2>/dev/null)" ] && skip_env "could not find setfacl" && return
5775 $GSS && skip "could not run under gss" && return
5777 declare -a identity_old
5779 for num in `seq $MDSCOUNT`; do
5780 switch_identity $num true || identity_old[$num]=$?
5787 echo "performing cp ..."
5788 run_acl_subtest cp || error
5789 echo "performing getfacl-noacl..."
5790 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
5791 echo "performing misc..."
5792 run_acl_subtest misc || error "misc test failed"
5793 echo "performing permissions..."
5794 run_acl_subtest permissions || error "permissions failed"
5795 echo "performing setfacl..."
5796 run_acl_subtest setfacl || error "setfacl test failed"
5798 # inheritance test got from HP
5799 echo "performing inheritance..."
5800 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
5801 chmod +x make-tree || error "chmod +x failed"
5802 run_acl_subtest inheritance || error "inheritance test failed"
5808 for num in `seq $MDSCOUNT`; do
5809 if [ "${identity_old[$num]}" = 1 ]; then
5810 switch_identity $num false || identity_old[$num]=$?
5814 run_test 103 "acl test ========================================="
5818 lfs df || error "lfs df failed"
5819 lfs df -ih || error "lfs df -ih failed"
5820 lfs df -h $DIR || error "lfs df -h $DIR failed"
5821 lfs df -i $DIR || error "lfs df -i $DIR failed"
5822 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
5823 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
5825 OSC=`lctl dl |grep OST0000-osc-[^M] |awk '{print $4}'`
5826 lctl --device %$OSC deactivate
5827 lfs df || error "lfs df with deactivated OSC failed"
5828 lctl --device %$OSC activate
5829 # wait the osc back to normal
5830 wait_osc_import_state client ost FULL
5832 lfs df || error "lfs df with reactivated OSC failed"
5835 run_test 104a "lfs df [-ih] [path] test ========================="
5838 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5840 denied_cnt=$((`$RUNAS $LFS check servers 2>&1 | grep "Permission denied" | wc -l`))
5841 if [ $denied_cnt -ne 0 ];
5843 error "lfs check servers test failed"
5846 run_test 104b "$RUNAS lfs check servers test ===================="
5849 # doesn't work on 2.4 kernels
5851 if [ -n "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ];
5853 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
5855 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
5859 run_test 105a "flock when mounted without -o flock test ========"
5863 if [ -n "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ];
5865 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
5867 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
5871 run_test 105b "fcntl when mounted without -o flock test ========"
5875 if [ -n "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ];
5877 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
5879 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
5883 run_test 105c "lockf when mounted without -o flock test ========"
5885 test_105d() { # bug 15924
5887 [ -z "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ] && \
5888 skip "mount w/o flock enabled" && return
5889 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
5890 $LCTL set_param fail_loc=0x80000315
5891 flocks_test 2 $DIR/$tdir
5893 run_test 105d "flock race (should not freeze) ========"
5895 test_105e() { # bug 22660 && 22040
5896 [ -z "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ] && \
5897 skip "mount w/o flock enabled" && return
5899 flocks_test 3 $DIR/$tfile
5901 run_test 105e "Two conflicting flocks from same process ======="
5903 test_106() { #bug 10921
5905 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
5906 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
5908 run_test 106 "attempt exec of dir followed by chown of that dir"
5917 local save_pattern=$(sysctl -n kernel.core_pattern)
5918 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
5919 sysctl -w kernel.core_pattern=$file
5920 sysctl -w kernel.core_uses_pid=0
5928 kill -s 11 $SLEEPPID
5930 if [ -e $file ]; then
5931 size=`stat -c%s $file`
5932 [ $size -eq 0 ] && error "Fail to create core file $file"
5934 error "Fail to create core file $file"
5937 sysctl -w kernel.core_pattern=$save_pattern
5938 sysctl -w kernel.core_uses_pid=$save_uses_pid
5941 run_test 107 "Coredump on SIG"
5945 mkdir $DIR/$tdir/$(str_repeat 'a' 255) ||
5946 error "mkdir with 255 char failed"
5947 mkdir $DIR/$tdir/$(str_repeat 'b' 256) &&
5948 error "mkdir with 256 char should fail, but did not"
5949 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
5950 error "create with 255 char failed"
5951 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
5952 error "create with 256 char should fail, but did not"
5957 run_test 110 "filename length checking"
5960 OSTIO_pre=$(ps -e|grep ll_ost_io|awk '{print $4}'|sort -n|tail -1|\
5962 [ -z "$OSTIO_pre" ] && skip "no OSS threads" && \
5964 echo "Starting with $OSTIO_pre threads"
5967 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
5968 [ $NUMFREE -lt $NUMTEST ] && NUMTEST=$(($NUMFREE - 1000))
5969 echo "$NUMTEST creates/unlinks"
5971 createmany -o $DIR/$tdir/$tfile $NUMTEST
5972 unlinkmany $DIR/$tdir/$tfile $NUMTEST
5974 OSTIO_post=$(ps -e|grep ll_ost_io|awk '{print $4}'|sort -n|tail -1|\
5977 # don't return an error
5978 [ $OSTIO_post == $OSTIO_pre ] && echo \
5979 "WARNING: No new ll_ost_io threads were created ($OSTIO_pre)" &&
5980 echo "This may be fine, depending on what ran before this test" &&
5981 echo "and how fast this system is." && return
5983 echo "Started with $OSTIO_pre threads, ended with $OSTIO_post"
5985 run_test 115 "verify dynamic thread creation===================="
5988 wait_delete_completed
5989 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
5990 echo OST kbytes available: ${AVAIL[@]}
5991 MAXI=0; MAXV=${AVAIL[0]}
5992 MINI=0; MINV=${AVAIL[0]}
5993 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
5994 #echo OST $i: ${AVAIL[i]}kb
5995 if [ ${AVAIL[i]} -gt $MAXV ]; then
5996 MAXV=${AVAIL[i]}; MAXI=$i
5998 if [ ${AVAIL[i]} -lt $MINV ]; then
5999 MINV=${AVAIL[i]}; MINI=$i
6002 echo Min free space: OST $MINI: $MINV
6003 echo Max free space: OST $MAXI: $MAXV
6006 test_116a() { # was previously test_116()
6007 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs" && return
6009 echo -n "Free space priority "
6010 lctl get_param -n lov.*-clilov-*.qos_prio_free
6013 [ $MINV -gt 960000 ] && skip "too much free space in OST$MINI, skip" &&\
6016 # generate uneven OSTs
6017 mkdir -p $DIR/$tdir/OST${MINI}
6020 echo "Filling 25% remaining space in OST${MINI} with ${FILL}Kb"
6021 $SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI}||error "setstripe failed"
6023 while [ $FILL -gt 0 ]; do
6025 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i bs=2M count=1 2>/dev/null
6026 FILL=$(($FILL - 2048))
6034 DIFF=$(($MAXV - $MINV))
6035 DIFF2=$(($DIFF * 100 / $MINV))
6036 echo -n "diff=${DIFF}=${DIFF2}% must be > 20% for QOS mode..."
6037 if [ $DIFF2 -gt 20 ]; then
6040 echo "failed - QOS mode won't be used"
6041 error_ignore "QOS imbalance criteria not met"
6045 MINI1=$MINI; MINV1=$MINV
6046 MAXI1=$MAXI; MAXV1=$MAXV
6048 # now fill using QOS
6049 echo writing a bunch of files to QOS-assigned OSTs
6050 $SETSTRIPE -c 1 $DIR/$tdir
6052 while [ $FILL -gt 0 ]; do
6054 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1024 count=200 2>/dev/null
6055 FILL=$(($FILL - 200))
6058 echo "wrote $i 200k files"
6062 echo "Note: free space may not be updated, so measurements might be off"
6064 DIFF2=$(($MAXV - $MINV))
6065 echo "free space delta: orig $DIFF final $DIFF2"
6066 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
6067 DIFF=$(($MINV1 - ${AVAIL[$MINI1]}))
6068 echo "Wrote $DIFF to smaller OST $MINI1"
6069 DIFF2=$(($MAXV1 - ${AVAIL[$MAXI1]}))
6070 echo "Wrote $DIFF2 to larger OST $MAXI1"
6071 [ $DIFF -gt 0 ] && echo "Wrote $(($DIFF2 * 100 / $DIFF - 100))% more data to larger OST $MAXI1"
6073 # Figure out which files were written where
6074 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
6075 awk '/'$MINI1': / {print $2; exit}')
6077 MINC=$($GETSTRIPE --obd $UUID $DIR/$tdir | wc -l)
6078 echo "$MINC files created on smaller OST $MINI1"
6079 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
6080 awk '/'$MAXI1': / {print $2; exit}')
6082 MAXC=$($GETSTRIPE --obd $UUID $DIR/$tdir | wc -l)
6083 echo "$MAXC files created on larger OST $MAXI1"
6084 [ $MINC -gt 0 ] && echo "Wrote $(($MAXC * 100 / $MINC - 100))% more files to larger OST $MAXI1"
6085 [ $MAXC -gt $MINC ] || error_ignore "stripe QOS didn't balance free space"
6089 run_test 116a "stripe QOS: free space balance ==================="
6091 test_116b() { # LU-2093
6092 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
6094 old_rr=$(do_facet $SINGLEMDS lctl get_param -n lov.*mdtlov*.qos_threshold_rr)
6095 do_facet $SINGLEMDS lctl set_param lov.*mdtlov*.qos_threshold_rr 0
6097 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
6098 createmany -o $DIR/$tdir/f- 20 || error "can't create"
6099 do_facet $SINGLEMDS lctl set_param fail_loc=0
6101 do_facet $SINGLEMDS lctl set_param lov.*mdtlov*.qos_threshold_rr $old_rr
6103 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
6105 test_117() # bug 10891
6107 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
6108 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
6109 lctl set_param fail_loc=0x21e
6110 > $DIR/$tfile || error "truncate failed"
6111 lctl set_param fail_loc=0
6112 echo "Truncate succeeded."
6115 run_test 117 "verify fsfilt_extend =========="
6117 export OLD_RESENDCOUNT=""
6118 set_resend_count () {
6119 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
6120 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -1)
6121 lctl set_param -n $PROC_RESENDCOUNT $1
6122 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
6125 [ "$SLOW" = "no" ] && set_resend_count 4 # for reduce test_118* time (bug 14842)
6127 # Reset async IO behavior after error case
6129 FILE=$DIR/reset_async
6131 # Ensure all OSCs are cleared
6132 $SETSTRIPE -c -1 $FILE
6133 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
6138 test_118a() #bug 11710
6142 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6143 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6144 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
6146 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6147 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6152 run_test 118a "verify O_SYNC works =========="
6156 remote_ost_nodsh && skip "remote OST with nodsh" && return
6160 #define OBD_FAIL_OST_ENOENT 0x217
6161 set_nodes_failloc "$(osts_nodes)" 0x217
6162 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6164 set_nodes_failloc "$(osts_nodes)" 0
6165 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6166 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6169 if [[ $RC -eq 0 ]]; then
6170 error "Must return error due to dropped pages, rc=$RC"
6174 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6175 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6179 echo "Dirty pages not leaked on ENOENT"
6181 # Due to the above error the OSC will issue all RPCs syncronously
6182 # until a subsequent RPC completes successfully without error.
6183 $MULTIOP $DIR/$tfile Ow4096yc
6188 run_test 118b "Reclaim dirty pages on fatal error =========="
6192 remote_ost_nodsh && skip "remote OST with nodsh" && return
6196 #define OBD_FAIL_OST_EROFS 0x216
6197 set_nodes_failloc "$(osts_nodes)" 0x216
6199 # multiop should block due to fsync until pages are written
6200 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
6204 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
6205 error "Multiop failed to block on fsync, pid=$MULTIPID"
6208 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6210 if [[ $WRITEBACK -eq 0 ]]; then
6211 error "No page in writeback, writeback=$WRITEBACK"
6214 set_nodes_failloc "$(osts_nodes)" 0
6217 if [[ $RC -ne 0 ]]; then
6218 error "Multiop fsync failed, rc=$RC"
6221 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6222 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6224 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6225 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6229 echo "Dirty pages flushed via fsync on EROFS"
6232 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
6236 remote_ost_nodsh && skip "remote OST with nodsh" && return
6240 #define OBD_FAIL_OST_BRW_PAUSE_BULK
6241 set_nodes_failloc "$(osts_nodes)" 0x214
6242 # multiop should block due to fsync until pages are written
6243 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
6247 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
6248 error "Multiop failed to block on fsync, pid=$MULTIPID"
6251 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6253 if [[ $WRITEBACK -eq 0 ]]; then
6254 error "No page in writeback, writeback=$WRITEBACK"
6257 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
6258 set_nodes_failloc "$(osts_nodes)" 0
6260 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6261 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6263 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6264 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6268 echo "Dirty pages gaurenteed flushed via fsync"
6271 run_test 118d "Fsync validation inject a delay of the bulk =========="
6276 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
6277 lctl set_param fail_loc=0x8000040a
6279 # Should simulate EINVAL error which is fatal
6280 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6282 if [[ $RC -eq 0 ]]; then
6283 error "Must return error due to dropped pages, rc=$RC"
6286 lctl set_param fail_loc=0x0
6288 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6289 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6290 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6292 if [[ $LOCKED -ne 0 ]]; then
6293 error "Locked pages remain in cache, locked=$LOCKED"
6296 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6297 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6301 echo "No pages locked after fsync"
6306 run_test 118f "Simulate unrecoverable OSC side error =========="
6311 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
6312 lctl set_param fail_loc=0x406
6314 # simulate local -ENOMEM
6315 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6318 lctl set_param fail_loc=0
6319 if [[ $RC -eq 0 ]]; then
6320 error "Must return error due to dropped pages, rc=$RC"
6323 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6324 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6325 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6327 if [[ $LOCKED -ne 0 ]]; then
6328 error "Locked pages remain in cache, locked=$LOCKED"
6331 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6332 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6336 echo "No pages locked after fsync"
6341 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
6344 remote_ost_nodsh && skip "remote OST with nodsh" && return
6348 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
6349 set_nodes_failloc "$(osts_nodes)" 0x20e
6350 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
6351 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6354 set_nodes_failloc "$(osts_nodes)" 0
6355 if [[ $RC -eq 0 ]]; then
6356 error "Must return error due to dropped pages, rc=$RC"
6359 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6360 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6361 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6363 if [[ $LOCKED -ne 0 ]]; then
6364 error "Locked pages remain in cache, locked=$LOCKED"
6367 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6368 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6372 echo "No pages locked after fsync"
6376 run_test 118h "Verify timeout in handling recoverables errors =========="
6378 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
6381 remote_ost_nodsh && skip "remote OST with nodsh" && return
6385 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
6386 set_nodes_failloc "$(osts_nodes)" 0x20e
6388 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
6389 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
6392 set_nodes_failloc "$(osts_nodes)" 0
6396 if [[ $RC -ne 0 ]]; then
6397 error "got error, but should be not, rc=$RC"
6400 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6401 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6402 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
6403 if [[ $LOCKED -ne 0 ]]; then
6404 error "Locked pages remain in cache, locked=$LOCKED"
6407 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6408 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6412 echo "No pages locked after fsync"
6416 run_test 118i "Fix error before timeout in recoverable error =========="
6418 [ "$SLOW" = "no" ] && set_resend_count 4
6421 remote_ost_nodsh && skip "remote OST with nodsh" && return
6425 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
6426 set_nodes_failloc "$(osts_nodes)" 0x220
6428 # return -EIO from OST
6429 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6431 set_nodes_failloc "$(osts_nodes)" 0x0
6432 if [[ $RC -eq 0 ]]; then
6433 error "Must return error due to dropped pages, rc=$RC"
6436 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6437 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6438 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
6439 if [[ $LOCKED -ne 0 ]]; then
6440 error "Locked pages remain in cache, locked=$LOCKED"
6443 # in recoverable error on OST we want resend and stay until it finished
6444 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6445 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6449 echo "No pages locked after fsync"
6453 run_test 118j "Simulate unrecoverable OST side error =========="
6457 remote_ost_nodsh && skip "remote OSTs with nodsh" && return
6459 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
6460 set_nodes_failloc "$(osts_nodes)" 0x20e
6463 for ((i=0;i<10;i++)); do
6464 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
6465 error "dd to $DIR/$tdir/$tfile-$i failed" )&
6472 set_nodes_failloc "$(osts_nodes)" 0
6475 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
6481 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
6484 run_test 118l "fsync dir ========="
6486 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
6488 test_119a() # bug 11737
6490 BSIZE=$((512 * 1024))
6491 directio write $DIR/$tfile 0 1 $BSIZE
6492 # We ask to read two blocks, which is more than a file size.
6493 # directio will indicate an error when requested and actual
6494 # sizes aren't equeal (a normal situation in this case) and
6495 # print actual read amount.
6496 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
6497 if [ "$NOB" != "$BSIZE" ]; then
6498 error "read $NOB bytes instead of $BSIZE"
6502 run_test 119a "Short directIO read must return actual read amount"
6504 test_119b() # bug 11737
6506 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
6508 $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
6509 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
6511 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) || \
6512 error "direct read failed"
6515 run_test 119b "Sparse directIO read must return actual read amount"
6517 test_119c() # bug 13099
6520 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
6521 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
6524 run_test 119c "Testing for direct read hitting hole"
6526 test_119d() # bug 15950
6528 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
6529 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
6531 $SETSTRIPE $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
6532 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
6533 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
6534 lctl set_param fail_loc=0x40d
6535 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
6538 cat $DIR/$tfile > /dev/null &
6539 lctl set_param fail_loc=0
6542 log "the DIO writes have completed, now wait for the reads (should not block very long)"
6544 [ -n "`ps h -p $pid_reads -o comm`" ] && \
6545 error "the read rpcs have not completed in 2s"
6547 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
6549 run_test 119d "The DIO path should try to send a new rpc once one is completed"
6553 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6554 skip "no early lock cancel on server" && return 0
6555 lru_resize_disable mdc
6556 lru_resize_disable osc
6557 cancel_lru_locks mdc
6558 stat $DIR/$tdir > /dev/null
6559 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6560 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6562 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6563 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6564 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6565 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6566 lru_resize_enable mdc
6567 lru_resize_enable osc
6569 run_test 120a "Early Lock Cancel: mkdir test"
6573 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6574 skip "no early lock cancel on server" && return 0
6575 lru_resize_disable mdc
6576 lru_resize_disable osc
6577 cancel_lru_locks mdc
6578 stat $DIR/$tdir > /dev/null
6579 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6580 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6582 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6583 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6584 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6585 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6586 lru_resize_enable mdc
6587 lru_resize_enable osc
6589 run_test 120b "Early Lock Cancel: create test"
6593 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6594 skip "no early lock cancel on server" && return 0
6595 lru_resize_disable mdc
6596 lru_resize_disable osc
6597 mkdir -p $DIR/$tdir/d1 $DIR/$tdir/d2
6598 touch $DIR/$tdir/d1/f1
6599 cancel_lru_locks mdc
6600 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
6601 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6602 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6603 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
6604 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6605 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6606 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6607 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6608 lru_resize_enable mdc
6609 lru_resize_enable osc
6611 run_test 120c "Early Lock Cancel: link test"
6615 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6616 skip "no early lock cancel on server" && return 0
6617 lru_resize_disable mdc
6618 lru_resize_disable osc
6620 cancel_lru_locks mdc
6621 stat $DIR/$tdir > /dev/null
6622 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6623 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6624 chmod a+x $DIR/$tdir
6625 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6626 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6627 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6628 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6629 lru_resize_enable mdc
6630 lru_resize_enable osc
6632 run_test 120d "Early Lock Cancel: setattr test"
6636 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6637 skip "no early lock cancel on server" && return 0
6638 lru_resize_disable mdc
6639 lru_resize_disable osc
6640 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
6641 cancel_lru_locks mdc
6642 cancel_lru_locks osc
6643 dd if=$DIR/$tdir/f1 of=/dev/null
6644 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
6645 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6646 awk '/ldlm_cancel/ {print $2}'`
6647 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6648 awk '/ldlm_bl_callback/ {print $2}'`
6649 unlink $DIR/$tdir/f1
6650 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6651 awk '/ldlm_cancel/ {print $2}'`
6652 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6653 awk '/ldlm_bl_callback/ {print $2}'`
6654 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6655 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6656 lru_resize_enable mdc
6657 lru_resize_enable osc
6659 run_test 120e "Early Lock Cancel: unlink test"
6662 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6663 skip "no early lock cancel on server" && return 0
6665 lru_resize_disable mdc
6666 lru_resize_disable osc
6667 mkdir -p $DIR/$tdir/d1 $DIR/$tdir/d2
6668 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
6669 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
6670 cancel_lru_locks mdc
6671 cancel_lru_locks osc
6672 dd if=$DIR/$tdir/d1/f1 of=/dev/null
6673 dd if=$DIR/$tdir/d2/f2 of=/dev/null
6674 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
6675 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6676 awk '/ldlm_cancel/ {print $2}'`
6677 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6678 awk '/ldlm_bl_callback/ {print $2}'`
6679 mv $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
6680 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6681 awk '/ldlm_cancel/ {print $2}'`
6682 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6683 awk '/ldlm_bl_callback/ {print $2}'`
6684 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6685 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6686 lru_resize_enable mdc
6687 lru_resize_enable osc
6689 run_test 120f "Early Lock Cancel: rename test"
6692 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6693 skip "no early lock cancel on server" && return 0
6694 lru_resize_disable mdc
6695 lru_resize_disable osc
6697 echo create $count files
6699 cancel_lru_locks mdc
6700 cancel_lru_locks osc
6703 can0=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6704 awk '/ldlm_cancel/ {print $2}'`
6705 blk0=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6706 awk '/ldlm_bl_callback/ {print $2}'`
6707 createmany -o $DIR/$tdir/f $count
6709 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6710 awk '/ldlm_cancel/ {print $2}'`
6711 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6712 awk '/ldlm_bl_callback/ {print $2}'`
6714 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
6715 echo rm $count files
6718 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6719 awk '/ldlm_cancel/ {print $2}'`
6720 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6721 awk '/ldlm_bl_callback/ {print $2}'`
6723 echo total: $count removes in $((t2-t1))
6724 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
6726 # wait for commitment of removal
6727 lru_resize_enable mdc
6728 lru_resize_enable osc
6730 run_test 120g "Early Lock Cancel: performance test"
6732 test_121() { #bug #10589
6734 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
6735 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
6736 lctl set_param fail_loc=0x310
6737 cancel_lru_locks osc > /dev/null
6738 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
6739 lctl set_param fail_loc=0
6740 [ "$reads" -eq "$writes" ] || error "read" $reads "blocks, must be" $writes
6742 run_test 121 "read cancel race ========="
6744 test_123a() { # was test 123, statahead(bug 11401)
6746 if [ -z "$(grep "processor.*: 1" /proc/cpuinfo)" ]; then
6747 log "testing on UP system. Performance may be not as good as expected."
6753 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
6754 [ $NUMFREE -gt 100000 ] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
6756 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
6757 createmany -o $DIR/$tdir/$tfile $j $((i - j))
6759 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
6760 lctl set_param -n llite.*.statahead_max 0
6761 lctl get_param llite.*.statahead_max
6762 cancel_lru_locks mdc
6763 cancel_lru_locks osc
6765 time ls -l $DIR/$tdir | wc -l
6767 delta=$((etime - stime))
6768 log "ls $i files without statahead: $delta sec"
6769 lctl set_param llite.*.statahead_max=$max
6771 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
6772 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
6773 cancel_lru_locks mdc
6774 cancel_lru_locks osc
6776 time ls -l $DIR/$tdir | wc -l
6778 delta_sa=$((etime - stime))
6779 log "ls $i files with statahead: $delta_sa sec"
6780 lctl get_param -n llite.*.statahead_stats
6781 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
6783 [ $swrong -lt $ewrong ] && log "statahead was stopped, maybe too many locks held!"
6784 [ $delta -eq 0 -o $delta_sa -eq 0 ] && continue
6786 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
6787 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
6788 lctl set_param -n llite.*.statahead_max 0
6789 lctl get_param llite.*.statahead_max
6790 cancel_lru_locks mdc
6791 cancel_lru_locks osc
6793 time ls -l $DIR/$tdir | wc -l
6795 delta=$((etime - stime))
6796 log "ls $i files again without statahead: $delta sec"
6797 lctl set_param llite.*.statahead_max=$max
6798 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
6799 if [ $SLOWOK -eq 0 ]; then
6800 error "ls $i files is slower with statahead!"
6802 log "ls $i files is slower with statahead!"
6808 [ $delta -gt 20 ] && break
6809 [ $delta -gt 8 ] && MULT=$((50 / delta))
6810 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
6818 delta=$((etime - stime))
6819 log "rm -r $DIR/$tdir/: $delta seconds"
6821 lctl get_param -n llite.*.statahead_stats
6823 run_test 123a "verify statahead work"
6825 test_123b () { # statahead(bug 15027)
6827 createmany -o $DIR/$tdir/$tfile-%d 1000
6829 cancel_lru_locks mdc
6830 cancel_lru_locks osc
6832 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
6833 lctl set_param fail_loc=0x80000803
6834 ls -lR $DIR/$tdir > /dev/null
6836 lctl set_param fail_loc=0x0
6837 lctl get_param -n llite.*.statahead_stats
6842 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
6845 [ -z "`lctl get_param -n mdc.*.connect_flags | grep lru_resize`" ] && \
6846 skip "no lru resize on server" && return 0
6848 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
6850 log "create $NR files at $DIR/$tdir"
6851 createmany -o $DIR/$tdir/f $NR ||
6852 error "failed to create $NR files in $DIR/$tdir"
6854 cancel_lru_locks mdc
6855 ls -l $DIR/$tdir > /dev/null
6859 for VALUE in `lctl get_param ldlm.namespaces.*mdc-*.lru_size`; do
6860 local PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
6861 LRU_SIZE=$(lctl get_param -n $PARAM)
6862 if [ $LRU_SIZE -gt $(default_lru_size) ]; then
6863 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
6865 log "NS=$(basename $NSDIR)"
6870 if [ -z "$NSDIR" -o $LRU_SIZE -lt $(default_lru_size) ]; then
6871 skip "Not enough cached locks created!"
6878 # We know that lru resize allows one client to hold $LIMIT locks
6879 # for 10h. After that locks begin to be killed by client.
6881 local LIMIT=`lctl get_param -n $NSDIR.pool.limit`
6884 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
6885 # killing locks. Some time was spent for creating locks. This means
6886 # that up to the moment of sleep finish we must have killed some of
6887 # them (10-100 locks). This depends on how fast ther were created.
6888 # Many of them were touched in almost the same moment and thus will
6889 # be killed in groups.
6890 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
6892 # Use $LRU_SIZE_B here to take into account real number of locks
6893 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
6894 local LRU_SIZE_B=$LRU_SIZE
6896 local OLD_LVF=`lctl get_param -n $NSDIR.pool.lock_volume_factor`
6897 log "OLD_LVF=$OLD_LVF"
6898 lctl set_param -n $NSDIR.pool.lock_volume_factor $LVF
6900 # Let's make sure that we really have some margin. Client checks
6901 # cached locks every 10 sec.
6903 log "Sleep ${SLEEP} sec"
6905 while ((SEC<$SLEEP)); do
6909 LRU_SIZE=`lctl get_param -n $NSDIR/lru_size`
6913 lctl set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
6914 local LRU_SIZE_A=`lctl get_param -n $NSDIR.lru_size`
6916 [ $LRU_SIZE_B -gt $LRU_SIZE_A ] || {
6917 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
6918 unlinkmany $DIR/$tdir/f $NR
6922 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
6923 log "unlink $NR files at $DIR/$tdir"
6924 unlinkmany $DIR/$tdir/f $NR
6926 run_test 124a "lru resize ======================================="
6928 get_max_pool_limit()
6930 local limit=`lctl get_param -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit`
6933 if test $l -gt $max; then
6941 [ -z "`lctl get_param -n mdc.*.connect_flags | grep lru_resize`" ] && \
6942 skip "no lru resize on server" && return 0
6944 LIMIT=`get_max_pool_limit`
6946 NR=$(($(default_lru_size)*20))
6947 if [ $NR -gt $LIMIT ]; then
6948 log "Limit lock number by $LIMIT locks"
6951 lru_resize_disable mdc
6952 mkdir -p $DIR/$tdir/disable_lru_resize ||
6953 error "failed to create $DIR/$tdir/disable_lru_resize"
6955 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
6956 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
6957 cancel_lru_locks mdc
6960 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
6963 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
6966 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
6970 nolruresize_delta=$((etime-stime))
6971 log "ls -la time: $nolruresize_delta seconds"
6972 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
6973 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
6975 lru_resize_enable mdc
6976 mkdir -p $DIR/$tdir/enable_lru_resize ||
6977 error "failed to create $DIR/$tdir/enable_lru_resize"
6979 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
6980 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
6981 cancel_lru_locks mdc
6984 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
6987 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
6990 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
6994 lruresize_delta=$((etime-stime))
6995 log "ls -la time: $lruresize_delta seconds"
6996 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
6998 if [ $lruresize_delta -gt $nolruresize_delta ]; then
6999 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
7000 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
7001 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
7003 log "lru resize performs the same with no lru resize"
7005 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
7007 run_test 124b "lru resize (performance test) ======================="
7009 test_125() { # 13358
7010 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
7011 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
7012 mkdir -p $DIR/d125 || error "mkdir failed"
7013 $SETSTRIPE -S 65536 -c -1 $DIR/d125 || error "setstripe failed"
7014 setfacl -R -m u:bin:rwx $DIR/d125 || error "setfacl $DIR/d125 failed"
7015 ls -ld $DIR/d125 || error "cannot access $DIR/d125"
7017 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
7019 test_126() { # bug 12829/13455
7020 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
7021 [ "$UID" != 0 ] && skip_env "skipping $TESTNAME (must run as root)" && return
7022 $GSS && skip "must run as gss disabled" && return
7024 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
7025 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
7027 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
7029 run_test 126 "check that the fsgid provided by the client is taken into account"
7031 test_127a() { # bug 15521
7032 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
7033 $LCTL set_param osc.*.stats=0
7034 FSIZE=$((2048 * 1024))
7035 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
7036 cancel_lru_locks osc
7037 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
7039 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
7040 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
7041 echo "got $COUNT $NAME"
7042 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
7043 eval $NAME=$COUNT || error "Wrong proc format"
7046 read_bytes|write_bytes)
7047 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
7048 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
7049 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
7050 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
7051 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
7052 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
7053 error "sumsquare is too small: $SUMSQ"
7054 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
7055 error "sumsquare is too big: $SUMSQ"
7059 done < $DIR/${tfile}.tmp
7061 #check that we actually got some stats
7062 [ "$read_bytes" ] || error "Missing read_bytes stats"
7063 [ "$write_bytes" ] || error "Missing write_bytes stats"
7064 [ "$read_bytes" != 0 ] || error "no read done"
7065 [ "$write_bytes" != 0 ] || error "no write done"
7067 run_test 127a "verify the client stats are sane"
7069 test_127b() { # bug LU-333
7070 $LCTL set_param llite.*.stats=0
7071 FSIZE=65536 # sized fixed to match PAGE_SIZE for most clients
7072 # perform 2 reads and writes so MAX is different from SUM.
7073 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
7074 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
7075 cancel_lru_locks osc
7076 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
7077 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
7079 $LCTL get_param llite.*.stats | grep samples > $TMP/${tfile}.tmp
7080 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
7081 echo "got $COUNT $NAME"
7082 eval $NAME=$COUNT || error "Wrong proc format"
7086 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
7087 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
7088 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
7089 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
7092 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
7093 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
7094 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
7095 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
7099 done < $TMP/${tfile}.tmp
7101 #check that we actually got some stats
7102 [ "$read_bytes" ] || error "Missing read_bytes stats"
7103 [ "$write_bytes" ] || error "Missing write_bytes stats"
7104 [ "$read_bytes" != 0 ] || error "no read done"
7105 [ "$write_bytes" != 0 ] || error "no write done"
7107 run_test 127b "verify the llite client stats are sane"
7109 test_128() { # bug 15212
7111 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
7116 result=$(grep error $TMP/$tfile.log)
7118 [ -z "$result" ] || error "consecutive find's under interactive lfs failed"
7120 run_test 128 "interactive lfs for 2 consecutive find's"
7127 local LDPROC=/proc/fs/ldiskfs
7129 for facet in $(get_facets MDS); do
7130 canondev=$(ldiskfs_canon *.$(convert_facet2label $facet).mntdev $facet)
7131 do_facet $facet "test -e $LDPROC/$canondev/max_dir_size" || LDPROC=/sys/fs/ldiskfs
7132 do_facet $facet "echo $1 >$LDPROC/$canondev/max_dir_size"
7136 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
7137 skip "Only applicable to ldiskfs-based MDTs"
7140 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7151 while [ ! $I -gt $((MAX * MDSCOUNT)) ]; do
7152 $MULTIOP $DIR/$tdir/$J Oc
7154 if [ $rc -eq $EFBIG ]; then
7156 echo "return code $rc received as expected"
7158 elif [ $rc -ne 0 ]; then
7160 error_exit "return code $rc received instead of expected $EFBIG"
7163 I=$(stat -c%s "$DIR/$tdir")
7167 error "exceeded dir size limit $MAX x $MDSCOUNT $((MAX * MDSCOUNT)) : $I bytes"
7169 run_test 129 "test directory size limit ========================"
7178 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7179 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
7182 trap cleanup_130 EXIT RETURN
7184 local fm_file=$DIR/$tfile
7185 $SETSTRIPE -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
7186 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
7187 error "dd failed for $fm_file"
7189 # LU-1795: test filefrag/FIEMAP once, even if unsupported
7190 filefrag -ves $fm_file
7192 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
7193 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
7194 [ $RC != 0 ] && error "filefrag $fm_file failed"
7196 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
7197 grep -v "ext:" | grep -v "found")
7198 lun=$($GETSTRIPE -i $fm_file)
7200 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
7203 for line in $filefrag_op
7205 frag_lun=`echo $line | cut -d: -f5`
7206 ext_len=`echo $line | cut -d: -f4`
7207 if (( $frag_lun != $lun )); then
7209 error "FIEMAP on 1-stripe file($fm_file) failed"
7212 (( tot_len += ext_len ))
7215 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
7217 error "FIEMAP on 1-stripe file($fm_file) failed;"
7223 echo "FIEMAP on single striped file succeeded"
7225 run_test 130a "FIEMAP (1-stripe file)"
7228 [ "$OSTCOUNT" -lt "2" ] &&
7229 skip_env "skipping FIEMAP on 2-stripe file test" && return
7231 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7232 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
7235 trap cleanup_130 EXIT RETURN
7237 local fm_file=$DIR/$tfile
7238 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
7239 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
7240 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
7242 dd if=/dev/zero of=$fm_file bs=1M count=2 ||
7243 error "dd failed on $fm_file"
7245 filefrag -ves $fm_file || error "filefrag $fm_file failed"
7246 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
7247 grep -v "ext:" | grep -v "found")
7249 last_lun=$(echo $filefrag_op | cut -d: -f5)
7254 for line in $filefrag_op
7256 frag_lun=`echo $line | cut -d: -f5`
7257 ext_len=`echo $line | cut -d: -f4`
7258 if (( $frag_lun != $last_lun )); then
7259 if (( tot_len != 1024 )); then
7261 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 256"
7268 (( tot_len += ext_len ))
7271 if (( num_luns != 2 || tot_len != 1024 )); then
7273 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
7279 echo "FIEMAP on 2-stripe file succeeded"
7281 run_test 130b "FIEMAP (2-stripe file)"
7284 [ "$OSTCOUNT" -lt "2" ] &&
7285 skip_env "skipping FIEMAP on 2-stripe file" && return
7287 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7288 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
7291 trap cleanup_130 EXIT RETURN
7293 local fm_file=$DIR/$tfile
7294 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
7295 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
7296 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
7298 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 || error "dd failed on $fm_file"
7300 filefrag -ves $fm_file || error "filefrag $fm_file failed"
7301 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
7303 last_lun=`echo $filefrag_op | cut -d: -f5`
7308 for line in $filefrag_op
7310 frag_lun=`echo $line | cut -d: -f5`
7311 ext_len=`echo $line | cut -d: -f4`
7312 if (( $frag_lun != $last_lun )); then
7313 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
7314 if (( logical != 512 )); then
7316 error "FIEMAP on $fm_file failed; returned logical start for lun $logical instead of 512"
7319 if (( tot_len != 512 )); then
7321 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
7328 (( tot_len += ext_len ))
7331 if (( num_luns != 2 || tot_len != 512 )); then
7333 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
7339 echo "FIEMAP on 2-stripe file with hole succeeded"
7341 run_test 130c "FIEMAP (2-stripe file with hole)"
7344 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping FIEMAP on N-stripe file test" && return
7346 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7347 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
7349 trap cleanup_130 EXIT RETURN
7351 local fm_file=$DIR/$tfile
7352 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file||error "setstripe on $fm_file"
7353 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
7354 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
7355 dd if=/dev/zero of=$fm_file bs=1M count=$OSTCOUNT || error "dd failed on $fm_file"
7357 filefrag -ves $fm_file || error "filefrag $fm_file failed"
7358 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
7360 last_lun=`echo $filefrag_op | cut -d: -f5`
7365 for line in $filefrag_op
7367 frag_lun=`echo $line | cut -d: -f5`
7368 ext_len=`echo $line | cut -d: -f4`
7369 if (( $frag_lun != $last_lun )); then
7370 if (( tot_len != 1024 )); then
7372 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
7379 (( tot_len += ext_len ))
7382 if (( num_luns != OSTCOUNT || tot_len != 1024 )); then
7384 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
7390 echo "FIEMAP on N-stripe file succeeded"
7392 run_test 130d "FIEMAP (N-stripe file)"
7395 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping continuation FIEMAP test" && return
7397 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7398 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
7400 trap cleanup_130 EXIT RETURN
7402 local fm_file=$DIR/$tfile
7403 $SETSTRIPE -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
7404 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
7405 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
7408 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
7409 for ((i = 0; i < $NUM_BLKS; i++))
7411 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
7414 filefrag -ves $fm_file || error "filefrag $fm_file failed"
7415 filefrag_op=`filefrag -ve $fm_file | grep -A 12000 "ext:" | grep -v "ext:" | grep -v "found"`
7417 last_lun=`echo $filefrag_op | cut -d: -f5`
7422 for line in $filefrag_op
7424 frag_lun=`echo $line | cut -d: -f5`
7425 ext_len=`echo $line | cut -d: -f4`
7426 if (( $frag_lun != $last_lun )); then
7427 if (( tot_len != $EXPECTED_LEN )); then
7429 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of $EXPECTED_LEN"
7436 (( tot_len += ext_len ))
7439 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
7441 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
7447 echo "FIEMAP with continuation calls succeeded"
7449 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
7451 # Test for writev/readv
7453 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 || \
7454 error "writev test failed"
7455 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 || \
7456 error "readv failed"
7459 run_test 131a "test iov's crossing stripe boundary for writev/readv"
7462 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 || \
7463 error "append writev test failed"
7464 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 || \
7465 error "append writev test failed"
7468 run_test 131b "test append writev"
7471 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
7474 run_test 131c "test read/write on file w/o objects"
7477 rwv -f $DIR/$tfile -w -n 1 1572864
7478 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
7479 if [ "$NOB" != 1572864 ]; then
7480 error "Short read filed: read $NOB bytes instead of 1572864"
7484 run_test 131d "test short read"
7487 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
7488 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
7489 error "read hitting hole failed"
7492 run_test 131e "test read hitting hole"
7497 for node in $(osts_nodes); do
7498 gl=$(do_node $node "$LCTL get_param -n ost.OSS.ost.stats" | awk '/'$token'/ {print $2}' | head -n 1)
7499 [ x$gl = x"" ] && gl=0
7500 gl_sum=$((gl_sum + gl))
7510 if [ x$som = x"enabled" ]; then
7511 [ $((gl2 - gl1)) -gt 0 ] && error "no glimpse RPC is expected"
7512 MOUNTOPT=`echo $MOUNTOPT | sed 's/som_preview//g'`
7513 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=disabled"
7515 [ $((gl2 - gl1)) -gt 0 ] || error "some glimpse RPC is expected"
7516 MOUNTOPT="$MOUNTOPT,som_preview"
7517 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=enabled"
7520 # do remount to make new mount-conf parameters actual
7527 test_132() { #1028, SOM
7528 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7529 local num=$(get_mds_dir $DIR)
7530 local mymds=mds${num}
7531 local MOUNTOPT_SAVE=$MOUNTOPT
7533 dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
7534 cancel_lru_locks osc
7536 som1=$(do_facet $mymds "$LCTL get_param mdt.*.som" | awk -F= ' {print $2}' | head -n 1)
7538 gl1=$(get_ost_param "ldlm_glimpse_enqueue")
7539 stat $DIR/$tfile >/dev/null
7540 gl2=$(get_ost_param "ldlm_glimpse_enqueue")
7541 echo "====> SOM is "$som1", "$((gl2 - gl1))" glimpse RPC occured"
7543 som_mode_switch $som1 $gl1 $gl2
7545 dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
7546 cancel_lru_locks osc
7548 som2=$(do_facet $mymds "$LCTL get_param mdt.*.som" | awk -F= ' {print $2}' | head -n 1)
7549 if [ $som1 == $som2 ]; then
7550 error "som is still "$som2
7551 if [ x$som2 = x"enabled" ]; then
7558 gl1=$(get_ost_param "ldlm_glimpse_enqueue")
7559 stat $DIR/$tfile >/dev/null
7560 gl2=$(get_ost_param "ldlm_glimpse_enqueue")
7561 echo "====> SOM is "$som2", "$((gl2 - gl1))" glimpse RPC occured"
7562 som_mode_switch $som2 $gl1 $gl2
7563 MOUNTOPT=$MOUNTOPT_SAVE
7565 run_test 132 "som avoids glimpse rpc"
7571 $SINGLEMDS) res=`do_facet $SINGLEMDS $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$2"`
7573 ost) res=`do_facet ost1 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$2"`
7575 *) error "Wrong argument $1" ;;
7578 count=`echo $res | awk '{print $2}'`
7579 [ -z "$res" ] && error "The counter for $2 on $1 was not incremented"
7580 # if the argument $3 is zero, it means any stat increment is ok.
7581 if [ $3 -gt 0 ] ; then
7582 [ $count -ne $3 ] && error "The $2 counter on $1 is wrong - expected $3"
7587 remote_ost_nodsh && skip "remote OST with nodsh" && return
7588 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7590 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
7591 { skip "MDS doesn't support rename stats"; return; }
7592 local testdir=$DIR/${tdir}/stats_testdir
7593 mkdir -p $DIR/${tdir}
7596 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
7597 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
7599 # verify mdt stats first.
7600 mkdir ${testdir} || error "mkdir failed"
7601 check_stats $SINGLEMDS "mkdir" 1
7602 touch ${testdir}/${tfile} || "touch failed"
7603 check_stats $SINGLEMDS "open" 1
7604 check_stats $SINGLEMDS "close" 1
7605 mknod ${testdir}/${tfile}-pipe p || "mknod failed"
7606 check_stats $SINGLEMDS "mknod" 1
7607 rm -f ${testdir}/${tfile}-pipe || "pipe remove failed"
7608 check_stats $SINGLEMDS "unlink" 1
7609 rm -f ${testdir}/${tfile} || error "file remove failed"
7610 check_stats $SINGLEMDS "unlink" 2
7612 # remove working dir and check mdt stats again.
7613 rmdir ${testdir} || error "rmdir failed"
7614 check_stats $SINGLEMDS "rmdir" 1
7616 local testdir1=$DIR/${tdir}/stats_testdir1
7618 mkdir -p ${testdir1}
7619 touch ${testdir1}/test1
7620 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
7621 check_stats $SINGLEMDS "crossdir_rename" 1
7623 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
7624 check_stats $SINGLEMDS "samedir_rename" 1
7628 run_test 133a "Verifying MDT stats ========================================"
7631 remote_ost_nodsh && skip "remote OST with nodsh" && return
7632 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7633 local testdir=$DIR/${tdir}/stats_testdir
7634 mkdir -p ${testdir} || error "mkdir failed"
7635 touch ${testdir}/${tfile} || "touch failed"
7636 cancel_lru_locks mdc
7639 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
7640 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
7642 # extra mdt stats verification.
7643 chmod 444 ${testdir}/${tfile} || error "chmod failed"
7644 check_stats $SINGLEMDS "setattr" 1
7645 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
7646 if [ $(lustre_version_code $SINGLEMDS) -ne $(version_code 2.2.0) ]
7648 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
7649 check_stats $SINGLEMDS "getattr" 1
7651 $LFS df || error "lfs failed"
7652 check_stats $SINGLEMDS "statfs" 1
7656 run_test 133b "Verifying extra MDT stats =================================="
7659 remote_ost_nodsh && skip "remote OST with nodsh" && return
7660 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7661 local testdir=$DIR/${tdir}/stats_testdir
7662 mkdir -p ${testdir} || error "mkdir failed"
7664 # verify obdfilter stats.
7665 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
7667 cancel_lru_locks osc
7668 wait_delete_completed
7671 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
7672 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
7674 dd if=/dev/zero of=${testdir}/${tfile} conv=notrunc bs=512k count=1 || error "dd failed"
7676 cancel_lru_locks osc
7677 check_stats ost "write" 1
7679 dd if=${testdir}/${tfile} of=/dev/null bs=1k count=1 || error "dd failed"
7680 check_stats ost "read" 1
7682 > ${testdir}/${tfile} || error "truncate failed"
7683 check_stats ost "punch" 1
7685 rm -f ${testdir}/${tfile} || error "file remove failed"
7686 wait_delete_completed
7687 check_stats ost "destroy" 1
7691 run_test 133c "Verifying OST stats ========================================"
7698 while [ $value -ge 2 ]; do
7703 if [ $orig -gt $order ]; then
7711 local size=('K' 'M' 'G' 'T');
7713 local size_string=$value
7715 while [ $value -ge 1024 ]; do
7716 if [ $i -gt 3 ]; then
7717 #T is the biggest unit we get here, if that is bigger,
7719 size_string=${value}T
7722 value=$((value >> 10))
7723 if [ $value -lt 1024 ]; then
7724 size_string=${value}${size[$i]}
7735 local context=${2:-.}
7736 local sample=$(do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats |
7738 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
7743 remote_ost_nodsh && skip "remote OST with nodsh" && return
7744 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7745 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
7746 { skip "MDS doesn't support rename stats"; return; }
7748 local testdir1=$DIR/${tdir}/stats_testdir1
7749 local testdir2=$DIR/${tdir}/stats_testdir2
7751 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
7753 mkdir -p ${testdir1} || error "mkdir failed"
7754 mkdir -p ${testdir2} || error "mkdir failed"
7756 createmany -o $testdir1/test 512 || error "createmany failed"
7758 # check samedir rename size
7759 mv ${testdir1}/test0 ${testdir1}/test_0
7761 local testdir1_size=$(ls -l $DIR/${tdir} |
7762 awk '/stats_testdir1/ {print $5}')
7763 local testdir2_size=$(ls -l $DIR/${tdir} |
7764 awk '/stats_testdir2/ {print $5}')
7766 testdir1_size=$(order_2 $testdir1_size)
7767 testdir2_size=$(order_2 $testdir2_size)
7769 testdir1_size=$(size_in_KMGT $testdir1_size)
7770 testdir2_size=$(size_in_KMGT $testdir2_size)
7772 echo "source rename dir size: ${testdir1_size}"
7773 echo "target rename dir size: ${testdir2_size}"
7775 local cmd="do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats"
7776 eval $cmd || error "$cmd failed"
7777 local samedir=$($cmd | grep 'same_dir')
7778 local same_sample=$(get_rename_size $testdir1_size)
7779 [ -z "$samedir" ] && error "samedir_rename_size count error"
7780 [ "$same_sample" -eq 1 ] || error "samedir_rename_size error $same_sample"
7781 echo "Check same dir rename stats success"
7783 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
7785 # check crossdir rename size
7786 mv ${testdir1}/test_0 ${testdir2}/test_0
7788 testdir1_size=$(ls -l $DIR/${tdir} |
7789 awk '/stats_testdir1/ {print $5}')
7790 testdir2_size=$(ls -l $DIR/${tdir} |
7791 awk '/stats_testdir2/ {print $5}')
7793 testdir1_size=$(order_2 $testdir1_size)
7794 testdir2_size=$(order_2 $testdir2_size)
7796 testdir1_size=$(size_in_KMGT $testdir1_size)
7797 testdir2_size=$(size_in_KMGT $testdir2_size)
7799 echo "source rename dir size: ${testdir1_size}"
7800 echo "target rename dir size: ${testdir2_size}"
7802 eval $cmd || error "$cmd failed"
7803 local crossdir=$($cmd | grep 'crossdir')
7804 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
7805 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
7806 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
7807 [ "$src_sample" -eq 1 ] || error "crossdir_rename_size error $src_sample"
7808 [ "$tgt_sample" -eq 1 ] || error "crossdir_rename_size error $tgt_sample"
7809 echo "Check cross dir rename stats success"
7812 run_test 133d "Verifying rename_stats ========================================"
7814 test_140() { #bug-17379
7815 mkdir -p $DIR/$tdir || error "Creating dir $DIR/$tdir"
7816 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
7817 cp /usr/bin/stat . || error "Copying stat to $DIR/$tdir"
7819 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
7820 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
7822 while i=`expr $i + 1`; do
7823 mkdir -p $i || error "Creating dir $i"
7824 cd $i || error "Changing to $i"
7825 ln -s ../stat stat || error "Creating stat symlink"
7826 # Read the symlink until ELOOP present,
7827 # not LBUGing the system is considered success,
7828 # we didn't overrun the stack.
7829 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
7831 if [ $ret -eq 40 ]; then
7834 error "Open stat symlink"
7840 echo "The symlink depth = $i"
7841 [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 -o $i -eq 40 ] ||
7842 error "Invalid symlink depth"
7844 # Test recursive symlink
7845 ln -s symlink_self symlink_self
7846 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
7847 echo "open symlink_self returns $ret"
7848 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
7850 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
7853 local TF="$TMP/$tfile"
7855 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
7857 cancel_lru_locks osc
7858 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
7859 remount_client $MOUNT
7861 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
7864 $TRUNCATE $DIR/$tfile 6000
7865 cancel_lru_locks osc
7866 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
7869 echo "12345" >>$DIR/$tfile
7870 cancel_lru_locks osc
7871 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
7874 echo "12345" >>$DIR/$tfile
7875 cancel_lru_locks osc
7876 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
7881 run_test 150 "truncate/append tests"
7883 function roc_hit() {
7884 local list=$(comma_list $(osts_nodes))
7886 echo $(get_obdfilter_param $list '' stats |
7887 awk '/'cache_hit'/ {sum+=$2} END {print sum}')
7890 function set_cache() {
7893 if [ "$2" == "off" ]; then
7896 local list=$(comma_list $(osts_nodes))
7897 set_obdfilter_param $list '' $1_cache_enable $on
7899 cancel_lru_locks osc
7903 remote_ost_nodsh && skip "remote OST with nodsh" && return
7906 local list=$(comma_list $(osts_nodes))
7908 # check whether obdfilter is cache capable at all
7909 if ! get_obdfilter_param $list '' read_cache_enable >/dev/null; then
7910 echo "not cache-capable obdfilter"
7914 # check cache is enabled on all obdfilters
7915 if get_obdfilter_param $list '' read_cache_enable | grep 0; then
7916 echo "oss cache is disabled"
7920 set_obdfilter_param $list '' writethrough_cache_enable 1
7922 # pages should be in the case right after write
7923 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES || error "dd failed"
7924 local BEFORE=`roc_hit`
7925 cancel_lru_locks osc
7926 cat $DIR/$tfile >/dev/null
7927 local AFTER=`roc_hit`
7928 if ! let "AFTER - BEFORE == CPAGES"; then
7929 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
7932 # the following read invalidates the cache
7933 cancel_lru_locks osc
7934 set_obdfilter_param $list '' read_cache_enable 0
7935 cat $DIR/$tfile >/dev/null
7937 # now data shouldn't be found in the cache
7939 cancel_lru_locks osc
7940 cat $DIR/$tfile >/dev/null
7942 if let "AFTER - BEFORE != 0"; then
7943 error "IN CACHE: before: $BEFORE, after: $AFTER"
7946 set_obdfilter_param $list '' read_cache_enable 1
7949 run_test 151 "test cache on oss and controls ==============================="
7952 local TF="$TMP/$tfile"
7954 # simulate ENOMEM during write
7955 #define OBD_FAIL_OST_NOMEM 0x226
7956 lctl set_param fail_loc=0x80000226
7957 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
7959 sync || error "sync failed"
7960 lctl set_param fail_loc=0
7962 # discard client's cache
7963 cancel_lru_locks osc
7965 # simulate ENOMEM during read
7966 lctl set_param fail_loc=0x80000226
7967 cmp $TF $DIR/$tfile || error "cmp failed"
7968 lctl set_param fail_loc=0
7972 run_test 152 "test read/write with enomem ============================"
7975 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
7977 run_test 153 "test if fdatasync does not crash ======================="
7980 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
7981 { skip "Need MDS version at least 2.2.51"; return 0; }
7983 cp /etc/hosts $DIR/$tfile
7985 fid=$($LFS path2fid $DIR/$tfile)
7987 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
7989 ffid=$DIR/.lustre/fid/$fid
7991 echo "stat fid $fid"
7992 stat $ffid > /dev/null || error "stat $ffid failed."
7993 echo "touch fid $fid"
7994 touch $ffid || error "touch $ffid failed."
7995 echo "write to fid $fid"
7996 cat /etc/hosts > $ffid || error "write $ffid failed."
7997 echo "read fid $fid"
7998 diff /etc/hosts $ffid || error "read $ffid failed."
7999 echo "append write to fid $fid"
8000 cat /etc/hosts >> $ffid || error "append write $ffid failed."
8001 echo "rename fid $fid"
8002 mv $ffid $DIR/$tfile.1 && error "rename $ffid to $tfile.1 should fail."
8004 mv $DIR/$tfile.1 $ffid && error "rename $tfile.1 to $ffid should fail."
8006 echo "truncate fid $fid"
8007 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
8008 echo "link fid $fid"
8009 ln -f $ffid $DIR/tfile.lnk || error "link $ffid failed."
8010 if [ -n $(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl) ]; then
8011 echo "setfacl fid $fid"
8012 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
8013 echo "getfacl fid $fid"
8014 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
8016 echo "unlink fid $fid"
8017 unlink $DIR/.lustre/fid/$fid && error "unlink $ffid should fail."
8018 echo "mknod fid $fid"
8019 mknod $ffid c 1 3 && error "mknod $ffid should fail."
8021 fid=[0xf00000400:0x1:0x0]
8022 ffid=$DIR/.lustre/fid/$fid
8024 echo "stat non-exist fid $fid"
8025 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
8026 echo "write to non-exist fid $fid"
8027 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
8028 echo "link new fid $fid"
8029 ln $DIR/$tfile $ffid && error "link $ffid should fail."
8032 touch $DIR/$tdir/$tfile
8033 fid=$($LFS path2fid $DIR/$tdir)
8035 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
8037 ffid=$DIR/.lustre/fid/$fid
8040 ls $ffid > /dev/null || error "ls $ffid failed."
8041 echo "touch $fid/$tfile.1"
8042 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
8044 echo "touch $DIR/.lustre/fid/$tfile"
8045 touch $DIR/.lustre/fid/$tfile && \
8046 error "touch $DIR/.lustre/fid/$tfile should fail."
8048 echo "setxattr to $DIR/.lustre/fid"
8049 setfattr -n trusted.name1 -v value1 $DIR/.lustre/fid &&
8050 error "setxattr should fail."
8052 echo "listxattr for $DIR/.lustre/fid"
8053 getfattr -d -m "^trusted" $DIR/.lustre/fid &&
8054 error "listxattr should fail."
8056 echo "delxattr from $DIR/.lustre/fid"
8057 setfattr -x trusted.name1 $DIR/.lustre/fid &&
8058 error "delxattr should fail."
8060 echo "touch invalid fid: $DIR/.lustre/fid/[0x200000400:0x2:0x3]"
8061 touch $DIR/.lustre/fid/[0x200000400:0x2:0x3] &&
8062 error "touch invalid fid should fail."
8064 echo "touch non-normal fid: $DIR/.lustre/fid/[0x1:0x2:0x0]"
8065 touch $DIR/.lustre/fid/[0x1:0x2:0x0] &&
8066 error "touch non-normal fid should fail."
8068 echo "rename $tdir to $DIR/.lustre/fid"
8069 mrename $DIR/$tdir $DIR/.lustre/fid &&
8070 error "rename to $DIR/.lustre/fid should fail."
8072 echo "rename .lustre to itself"
8073 fid=$($LFS path2fid $DIR)
8074 mrename $DIR/.lustre $DIR/.lustre/fid/$fid/.lustre &&
8075 error "rename .lustre to itself should fail."
8077 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $DIR/$tfile-2
8078 fid=$($LFS path2fid $DIR/$tfile-2)
8079 echo "cp /etc/passwd $DIR/.lustre/fid/$fid"
8080 cp /etc/passwd $DIR/.lustre/fid/$fid &&
8081 error "create lov data thru .lustre should fail."
8082 echo "cp /etc/passwd $DIR/$tfile-2"
8083 cp /etc/passwd $DIR/$tfile-2 || error "copy to $DIR/$tfile-2 failed."
8084 echo "diff /etc/passwd $DIR/.lustre/fid/$fid"
8085 diff /etc/passwd $DIR/.lustre/fid/$fid ||
8086 error "diff /etc/passwd $DIR/.lustre/fid/$fid failed."
8088 echo "Open-by-FID succeeded"
8090 run_test 154 "Open-by-FID"
8092 test_155_small_load() {
8093 local temp=$TMP/$tfile
8094 local file=$DIR/$tfile
8096 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
8097 error "dd of=$temp bs=6096 count=1 failed"
8099 cancel_lru_locks osc
8100 cmp $temp $file || error "$temp $file differ"
8102 $TRUNCATE $temp 6000
8103 $TRUNCATE $file 6000
8104 cmp $temp $file || error "$temp $file differ (truncate1)"
8106 echo "12345" >>$temp
8107 echo "12345" >>$file
8108 cmp $temp $file || error "$temp $file differ (append1)"
8110 echo "12345" >>$temp
8111 echo "12345" >>$file
8112 cmp $temp $file || error "$temp $file differ (append2)"
8118 test_155_big_load() {
8119 remote_ost_nodsh && skip "remote OST with nodsh" && return
8120 local temp=$TMP/$tfile
8121 local file=$DIR/$tfile
8124 local cache_size=$(do_facet ost$((MAXI+1)) \
8125 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
8126 local large_file_size=$((cache_size * 2))
8128 echo "OSS cache size: $cache_size KB"
8129 echo "Large file size: $large_file_size KB"
8131 [ $MAXV -le $large_file_size ] && \
8132 skip_env "max available OST size needs > $large_file_size KB" && \
8135 $SETSTRIPE $file -c 1 -i $MAXI || error "$SETSTRIPE $file failed"
8137 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k || \
8138 error "dd of=$temp bs=$large_file_size count=1k failed"
8141 cancel_lru_locks osc
8142 cmp $temp $file || error "$temp $file differ"
8150 set_cache writethrough on
8153 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
8157 set_cache writethrough off
8160 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
8164 set_cache writethrough on
8167 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
8171 set_cache writethrough off
8174 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
8178 set_cache writethrough on
8181 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
8185 set_cache writethrough off
8188 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
8192 set_cache writethrough on
8195 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
8199 set_cache writethrough off
8202 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
8208 local file="$DIR/$tfile"
8210 log "Turn on read and write cache"
8212 set_cache writethrough on
8214 log "Write data and read it back."
8215 log "Read should be satisfied from the cache."
8216 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
8218 cancel_lru_locks osc
8219 cat $file >/dev/null
8221 if ! let "AFTER - BEFORE == CPAGES"; then
8222 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
8224 log "cache hits:: before: $BEFORE, after: $AFTER"
8227 log "Read again; it should be satisfied from the cache."
8229 cancel_lru_locks osc
8230 cat $file >/dev/null
8232 if ! let "AFTER - BEFORE == CPAGES"; then
8233 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
8235 log "cache hits:: before: $BEFORE, after: $AFTER"
8239 log "Turn off the read cache and turn on the write cache"
8241 set_cache writethrough on
8243 log "Read again; it should be satisfied from the cache."
8245 cancel_lru_locks osc
8246 cat $file >/dev/null
8248 if ! let "AFTER - BEFORE == CPAGES"; then
8249 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
8251 log "cache hits:: before: $BEFORE, after: $AFTER"
8254 log "Read again; it should not be satisfied from the cache."
8256 cancel_lru_locks osc
8257 cat $file >/dev/null
8259 if ! let "AFTER - BEFORE == 0"; then
8260 error "IN CACHE: before: $BEFORE, after: $AFTER"
8262 log "cache hits:: before: $BEFORE, after: $AFTER"
8265 log "Write data and read it back."
8266 log "Read should be satisfied from the cache."
8267 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
8269 cancel_lru_locks osc
8270 cat $file >/dev/null
8272 if ! let "AFTER - BEFORE == CPAGES"; then
8273 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
8275 log "cache hits:: before: $BEFORE, after: $AFTER"
8278 log "Read again; it should not be satisfied from the cache."
8280 cancel_lru_locks osc
8281 cat $file >/dev/null
8283 if ! let "AFTER - BEFORE == 0"; then
8284 error "IN CACHE: before: $BEFORE, after: $AFTER"
8286 log "cache hits:: before: $BEFORE, after: $AFTER"
8290 log "Turn off read and write cache"
8292 set_cache writethrough off
8294 log "Write data and read it back"
8295 log "It should not be satisfied from the cache."
8297 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
8298 cancel_lru_locks osc
8300 cat $file >/dev/null
8302 if ! let "AFTER - BEFORE == 0"; then
8303 error_ignore 20762 "IN CACHE: before: $BEFORE, after: $AFTER"
8305 log "cache hits:: before: $BEFORE, after: $AFTER"
8309 log "Turn on the read cache and turn off the write cache"
8311 set_cache writethrough off
8313 log "Write data and read it back"
8314 log "It should not be satisfied from the cache."
8316 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
8318 cancel_lru_locks osc
8319 cat $file >/dev/null
8321 if ! let "AFTER - BEFORE == 0"; then
8322 error_ignore 20762 "IN CACHE: before: $BEFORE, after: $AFTER"
8324 log "cache hits:: before: $BEFORE, after: $AFTER"
8327 log "Read again; it should be satisfied from the cache."
8329 cancel_lru_locks osc
8330 cat $file >/dev/null
8332 if ! let "AFTER - BEFORE == CPAGES"; then
8333 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
8335 log "cache hits:: before: $BEFORE, after: $AFTER"
8340 run_test 156 "Verification of tunables ============================"
8344 if [ $MDSCOUNT -gt 1 ]; then
8345 error_ignore 17935 $*
8353 MASK=$(do_facet $SINGLEMDS $LCTL get_param mdd.$MDT0.changelog_mask |\
8356 if [ $MASK -eq 1 ]; then
8357 do_facet $SINGLEMDS $LCTL set_param mdd.$MDT0.changelog_mask="-$1"
8359 do_facet $SINGLEMDS $LCTL set_param mdd.$MDT0.changelog_mask="+$1"
8364 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8365 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
8366 { skip "Need MDS version at least 2.2.0"; return; }
8367 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
8368 echo "Registered as changelog user $USER"
8369 do_facet $SINGLEMDS $LCTL get_param -n mdd.$MDT0.changelog_users | \
8370 grep -q $USER || error "User $USER not found in changelog_users"
8373 mkdir -p $DIR/$tdir/pics/2008/zachy
8374 touch $DIR/$tdir/pics/2008/zachy/timestamp
8375 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
8376 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
8377 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
8378 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
8379 rm $DIR/$tdir/pics/desktop.jpg
8381 $LFS changelog $MDT0 | tail -5
8383 echo "verifying changelog mask"
8384 changelog_chmask "MKDIR"
8385 changelog_chmask "CLOSE"
8387 mkdir -p $DIR/$tdir/pics/zach/sofia
8388 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
8390 changelog_chmask "MKDIR"
8391 changelog_chmask "CLOSE"
8393 mkdir -p $DIR/$tdir/pics/2008/sofia
8394 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
8396 $LFS changelog $MDT0
8397 MKDIRS=$($LFS changelog $MDT0 | tail -5 | grep -c "MKDIR")
8398 CLOSES=$($LFS changelog $MDT0 | tail -5 | grep -c "CLOSE")
8399 [ $MKDIRS -eq 1 ] || err17935 "MKDIR changelog mask count $DIRS != 1"
8400 [ $CLOSES -eq 1 ] || err17935 "CLOSE changelog mask count $DIRS != 1"
8403 echo "verifying target fid"
8404 fidc=$($LFS changelog $MDT0 | grep timestamp | grep "CREAT" | \
8405 tail -1 | awk '{print $6}')
8406 fidf=$($LFS path2fid $DIR/$tdir/pics/zach/timestamp)
8407 [ "$fidc" == "t=$fidf" ] || \
8408 err17935 "fid in changelog $fidc != file fid $fidf"
8409 echo "verifying parent fid"
8410 fidc=$($LFS changelog $MDT0 | grep timestamp | grep "CREAT" | \
8411 tail -1 | awk '{print $7}')
8412 fidf=$($LFS path2fid $DIR/$tdir/pics/zach)
8413 [ "$fidc" == "p=$fidf" ] || \
8414 err17935 "pfid in changelog $fidc != dir fid $fidf"
8416 USER_REC1=$(do_facet $SINGLEMDS $LCTL get_param -n \
8417 mdd.$MDT0.changelog_users | grep $USER | awk '{print $2}')
8418 $LFS changelog_clear $MDT0 $USER $(($USER_REC1 + 5))
8419 USER_REC2=$(do_facet $SINGLEMDS $LCTL get_param -n \
8420 mdd.$MDT0.changelog_users | grep $USER | awk '{print $2}')
8421 echo "verifying user clear: $(( $USER_REC1 + 5 )) == $USER_REC2"
8422 [ $USER_REC2 == $(($USER_REC1 + 5)) ] || \
8423 err17935 "user index should be $(($USER_REC1 + 5)); is $USER_REC2"
8425 MIN_REC=$(do_facet $SINGLEMDS $LCTL get_param mdd.$MDT0.changelog_users | \
8426 awk 'min == "" || $2 < min {min = $2}; END {print min}')
8427 FIRST_REC=$($LFS changelog $MDT0 | head -1 | awk '{print $1}')
8428 echo "verifying min purge: $(( $MIN_REC + 1 )) == $FIRST_REC"
8429 [ $FIRST_REC == $(($MIN_REC + 1)) ] || \
8430 err17935 "first index should be $(($MIN_REC + 1)); is $FIRST_REC"
8432 echo "verifying user deregister"
8433 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
8434 do_facet $SINGLEMDS $LCTL get_param -n mdd.$MDT0.changelog_users | \
8435 grep -q $USER && error "User $USER still found in changelog_users"
8437 USERS=$(( $(do_facet $SINGLEMDS $LCTL get_param -n \
8438 mdd.$MDT0.changelog_users | wc -l) - 2 ))
8439 if [ $USERS -eq 0 ]; then
8440 LAST_REC1=$(do_facet $SINGLEMDS $LCTL get_param -n \
8441 mdd.$MDT0.changelog_users | head -1 | awk '{print $3}')
8442 touch $DIR/$tdir/chloe
8443 LAST_REC2=$(do_facet $SINGLEMDS $LCTL get_param -n \
8444 mdd.$MDT0.changelog_users | head -1 | awk '{print $3}')
8445 echo "verify changelogs are off if we were the only user: $LAST_REC1 == $LAST_REC2"
8446 [ $LAST_REC1 == $LAST_REC2 ] || error "changelogs not off"
8448 echo "$USERS other changelog users; can't verify off"
8451 run_test 160 "changelog sanity"
8455 cp /etc/hosts $DIR/$tdir/$tfile
8456 mkdir $DIR/$tdir/foo1
8457 mkdir $DIR/$tdir/foo2
8458 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
8459 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
8460 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
8461 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
8462 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[')
8463 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
8464 $LFS fid2path $DIR $FID
8465 err17935 "bad link ea"
8468 rm $DIR/$tdir/foo2/zachary
8470 rm $DIR/$tdir/foo2/thor
8472 rm $DIR/$tdir/$tfile
8474 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
8475 if [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ]
8477 $LFS fid2path $DIR $FID
8478 err17935 "bad link rename"
8480 rm $DIR/$tdir/foo2/maggie
8483 local longname=filename_avg_len_is_thirty_two_
8484 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 || \
8485 error "failed to hardlink many files"
8486 links=$($LFS fid2path $DIR $FID | wc -l)
8487 echo -n "${links}/1000 links in link EA"
8488 [ ${links} -gt 60 ] || err17935 "expected at least 60 links in link EA"
8489 unlinkmany $DIR/$tdir/foo2/$longname 1000 || \
8490 error "failed to unlink many hardlinks"
8492 run_test 161 "link ea sanity"
8499 local path=$(${LFS} fid2path $*)
8502 if [ $RC -ne 0 ]; then
8503 err17935 "path looked up of $expected failed. Error $RC"
8505 elif [ "${path}" != "${expected}" ]; then
8506 err17935 "path looked up \"${path}\" instead of \"${expected}\""
8509 echo "fid $fid resolves to path $path (expected $expected)"
8513 # Make changes to filesystem
8514 mkdir -p $DIR/$tdir/d2
8515 touch $DIR/$tdir/d2/$tfile
8516 touch $DIR/$tdir/d2/x1
8517 touch $DIR/$tdir/d2/x2
8518 mkdir -p $DIR/$tdir/d2/a/b/c
8519 mkdir -p $DIR/$tdir/d2/p/q/r
8521 FID=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
8522 check_path "$tdir/d2/$tfile" $FSNAME $FID --link 0
8525 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
8526 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
8527 check_path "$tdir/d2/p/q/r/slink" $FSNAME $FID --link 0
8529 # softlink to wrong file
8530 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
8531 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
8532 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME $FID --link 0
8535 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
8536 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
8537 FID=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
8538 # fid2path dir/fsname should both work
8539 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 1
8540 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR $FID --link 0
8542 # hardlink count: check that there are 2 links
8543 # Doesnt work with CMD yet: 17935
8544 ${LFS} fid2path $DIR $FID | wc -l | grep -q 2 || \
8545 err17935 "expected 2 links"
8547 # hardlink indexing: remove the first link
8548 rm $DIR/$tdir/d2/p/q/r/hlink
8549 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 0
8553 run_test 162 "path lookup sanity"
8556 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8557 copytool --test $FSNAME || { skip "copytool not runnable: $?" && return; }
8560 local uuid=$($LCTL get_param -n mdc.${FSNAME}-MDT0000-mdc-*.uuid)
8561 # this proc file is temporary and linux-only
8562 do_facet $SINGLEMDS lctl set_param mdt.${FSNAME}-MDT0000.mdccomm=$uuid ||\
8563 error "kernel->userspace send failed"
8566 run_test 163 "kernel <-> userspace comms"
8569 # do directio so as not to populate the page cache
8570 log "creating a 10 Mb file"
8571 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
8572 log "starting reads"
8573 dd if=$DIR/$tfile of=/dev/null bs=4096 &
8574 log "truncating the file"
8575 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
8577 kill %+ || true # reads might have finished
8578 echo "wait until dd is finished"
8580 log "removing the temporary file"
8581 rm -rf $DIR/$tfile || error "tmp file removal failed"
8583 run_test 169 "parallel read and truncate should not deadlock"
8586 $LCTL clear # bug 18514
8587 $LCTL debug_daemon start $TMP/${tfile}_log_good
8589 $LCTL debug_daemon stop
8590 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
8591 error "sed failed to read log_good"
8593 $LCTL debug_daemon start $TMP/${tfile}_log_good
8595 $LCTL debug_daemon stop
8597 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
8598 error "lctl df log_bad failed"
8600 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
8601 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
8603 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
8604 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
8606 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
8607 error "bad_line good_line1 good_line2 are empty"
8609 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
8610 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
8611 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
8613 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
8614 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
8615 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
8617 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
8618 error "bad_line_new good_line_new are empty"
8620 local expected_good=$((good_line1 + good_line2*2))
8622 rm -f $TMP/${tfile}*
8623 # LU-231, short malformed line may not be counted into bad lines
8624 if [ $bad_line -ne $bad_line_new ] &&
8625 [ $bad_line -ne $((bad_line_new - 1)) ]; then
8626 error "expected $bad_line bad lines, but got $bad_line_new"
8630 if [ $expected_good -ne $good_line_new ]; then
8631 error "expected $expected_good good lines, but got $good_line_new"
8636 run_test 170 "test lctl df to handle corrupted log ====================="
8638 test_171() { # bug20592
8639 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
8640 $LCTL set_param fail_loc=0x50e
8641 $LCTL set_param fail_val=3000
8642 multiop_bg_pause $DIR/$tfile O_s || true
8644 kill -USR1 $MULTIPID
8648 if dmesg | grep "recursive fault"; then
8649 error "caught a recursive fault"
8651 $LCTL set_param fail_loc=0
8654 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
8656 # it would be good to share it with obdfilter-survey/libecho code
8657 setup_obdecho_osc () {
8660 local obdfilter_name=$2
8661 echo "Creating new osc for $obdfilter_name on $ost_nid"
8662 # make sure we can find loopback nid
8663 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
8665 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
8666 ${obdfilter_name}_osc_UUID || rc=2; }
8667 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
8668 ${obdfilter_name}_UUID $ost_nid || rc=3; }
8672 cleanup_obdecho_osc () {
8673 local obdfilter_name=$1
8674 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
8675 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
8679 obdecho_create_test() {
8684 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
8685 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
8687 if [ $rc -eq 0 ]; then
8688 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
8689 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
8691 echo "New object id is $id"
8692 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec test_brw 10 w v 64 $id" ||
8694 [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec " \
8695 "cleanup" || rc=5; }
8696 [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec " \
8698 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
8703 remote_ost_nodsh && skip "remote OST with nodsh" && return
8707 if ! module_loaded obdecho; then
8708 load_module obdecho/obdecho
8712 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
8713 local host=$(lctl get_param -n osc.$osc.import |
8714 awk '/current_connection:/ {print $2}' )
8715 local target=$(lctl get_param -n osc.$osc.import |
8716 awk '/target:/ {print $2}' )
8717 target=${target%_UUID}
8719 [[ -n $target ]] && { setup_obdecho_osc $host $target || rc=1; } || rc=1
8720 [ $rc -eq 0 ] && { obdecho_create_test ${target}_osc client || rc=2; }
8721 [[ -n $target ]] && cleanup_obdecho_osc $target
8722 [ $rmmod_local -eq 1 ] && rmmod obdecho
8725 run_test 180a "test obdecho on osc"
8728 remote_ost_nodsh && skip "remote OST with nodsh" && return
8730 local rmmod_remote=0
8732 do_facet ost1 "lsmod | grep -q obdecho || " \
8733 "{ insmod ${LUSTRE}/obdecho/obdecho.ko || " \
8734 "modprobe obdecho; }" && rmmod_remote=1
8735 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ {print $4;exit}')
8736 [[ -n $target ]] && { obdecho_create_test $target ost1 || rc=1; }
8737 [ $rmmod_remote -eq 1 ] && do_facet ost1 "rmmod obdecho"
8740 run_test 180b "test obdecho directly on obdfilter"
8742 test_181() { # bug 22177
8743 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
8744 # create enough files to index the directory
8745 createmany -o $DIR/$tdir/foobar 4000
8746 # print attributes for debug purpose
8749 multiop_bg_pause $DIR/$tdir D_Sc || return 1
8751 # remove the files & current working dir
8752 unlinkmany $DIR/$tdir/foobar 4000
8754 kill -USR1 $MULTIPID
8756 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
8759 run_test 181 "Test open-unlinked dir ========================"
8762 # disable MDC RPC lock wouldn't crash client
8766 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
8767 #define OBD_FAIL_MDC_RPCS_SEM 0x804
8768 $LCTL set_param fail_loc=0x804
8770 for (( i=0; i < $tcount; i++ )) ; do
8772 createmany -o $DIR/$tdir/$i/f- $fcount &
8776 for (( i=0; i < $tcount; i++ )) ; do
8777 unlinkmany $DIR/$tdir/$i/f- $fcount &
8783 $LCTL set_param fail_loc=0
8785 run_test 182 "Disable MDC RPCs semaphore wouldn't crash client ================"
8788 check_file_in_pool()
8793 local res=$($GETSTRIPE $file | grep 0x | cut -f2)
8796 for t in $tlist ; do
8797 [ "$i" -eq "$t" ] && continue 2
8800 echo "pool list: $tlist"
8801 echo "striping: $res"
8802 error_noexit "$file not allocated in $pool"
8809 echo "Creating new pool"
8812 create_pool $FSNAME.$pool ||
8813 { error_noexit "No pool created, result code $?"; return 1; }
8814 [ $($LFS pool_list $FSNAME | grep -c $pool) -eq 1 ] ||
8815 { error_noexit "$pool not in lfs pool_list"; return 2; }
8818 pool_add_targets() {
8819 echo "Adding targets to pool"
8825 local list=$(seq $first $step $last)
8827 local t=$(for i in $list; do printf "$FSNAME-OST%04x_UUID " $i; done)
8828 do_facet mgs $LCTL pool_add \
8829 $FSNAME.$pool $FSNAME-OST[$first-$last/$step]
8830 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$pool \
8831 | sort -u | tr '\n' ' ' " "$t" || {
8832 error_noexit "Add to pool failed"
8835 local lfscount=$($LFS pool_list $FSNAME.$pool | grep -c "\-OST")
8836 local addcount=$(((last - first) / step + 1))
8837 [ $lfscount -eq $addcount ] || {
8838 error_noexit "lfs pool_list bad ost count" \
8839 "$lfscount != $addcount"
8847 echo "Setting pool on directory $tdir"
8849 $SETSTRIPE -c 2 -p $pool $tdir && return 0
8851 error_noexit "Cannot set pool $pool to $tdir"
8858 echo "Checking pool on directory $tdir"
8860 local res=$($GETSTRIPE --pool $tdir | sed "s/\s*$//")
8861 [ "$res" = "$pool" ] && return 0
8863 error_noexit "Pool on '$tdir' is '$res', not '$pool'"
8867 pool_dir_rel_path() {
8868 echo "Testing relative path works well"
8873 mkdir -p $root/$tdir/$tdir
8875 pool_set_dir $pool $tdir || return 1
8876 pool_set_dir $pool ./$tdir || return 2
8877 pool_set_dir $pool ../$tdir || return 3
8878 pool_set_dir $pool ../$tdir/$tdir || return 4
8879 rm -rf $tdir; cd - > /dev/null
8882 pool_alloc_files() {
8883 echo "Checking files allocation from directory pool"
8890 for i in $(seq -w 1 $count)
8892 local file=$tdir/file-$i
8894 check_file_in_pool $file $pool "$tlist" || \
8895 failed=$((failed + 1))
8897 [ "$failed" = 0 ] && return 0
8899 error_noexit "$failed files not allocated in $pool"
8903 pool_create_files() {
8904 echo "Creating files in pool"
8912 for i in $(seq -w 1 $count)
8914 local file=$tdir/spoo-$i
8915 $SETSTRIPE -p $pool $file
8916 check_file_in_pool $file $pool "$tlist" || \
8917 failed=$((failed + 1))
8919 [ "$failed" = 0 ] && return 0
8921 error_noexit "$failed files not allocated in $pool"
8926 echo "Checking 'lfs df' output"
8929 local t=$($LCTL get_param -n lov.$FSNAME-clilov-*.pools.$pool |
8931 local res=$($LFS df --pool $FSNAME.$pool |
8933 grep "$FSNAME-OST" |
8935 [ "$res" = "$t" ] && return 0
8937 error_noexit "Pools OSTs '$t' is not '$res' that lfs df reports"
8941 pool_file_rel_path() {
8942 echo "Creating files in a pool with relative pathname"
8947 { error_noexit "unable to create $tdir"; return 1 ; }
8948 local file="/..$tdir/$tfile-1"
8949 $SETSTRIPE -p $pool $file ||
8950 { error_noexit "unable to create $file" ; return 2 ; }
8953 $SETSTRIPE -p $pool $tfile-2 || {
8954 error_noexit "unable to create $tfile-2 in $tdir"
8959 pool_remove_first_target() {
8960 echo "Removing first target from a pool"
8963 local pname="lov.$FSNAME-*.pools.$pool"
8964 local t=$($LCTL get_param -n $pname | head -1)
8965 do_facet mgs $LCTL pool_remove $FSNAME.$pool $t
8966 wait_update $HOSTNAME "lctl get_param -n $pname | grep $t" "" || {
8967 error_noexit "$t not removed from $FSNAME.$pool"
8972 pool_remove_all_targets() {
8973 echo "Removing all targets from pool"
8976 local pname="lov.$FSNAME-*.pools.$pool"
8977 for t in $($LCTL get_param -n $pname | sort -u)
8979 do_facet mgs $LCTL pool_remove $FSNAME.$pool $t
8981 wait_update $HOSTNAME "lctl get_param -n $pname" "" || {
8982 error_noexit "Pool $FSNAME.$pool cannot be drained"
8985 # striping on an empty/nonexistant pool should fall back
8986 # to "pool of everything"
8988 error_noexit "failed to use fallback striping for empty pool"
8991 # setstripe on an empty pool should fail
8992 $SETSTRIPE -p $pool $file 2>/dev/null && {
8993 error_noexit "expected failure when creating file" \
9001 echo "Destroying pool"
9005 do_facet mgs $LCTL pool_destroy $FSNAME.$pool
9008 # striping on an empty/nonexistant pool should fall back
9009 # to "pool of everything"
9011 error_noexit "failed to use fallback striping for missing pool"
9014 # setstripe on an empty pool should fail
9015 $SETSTRIPE -p $pool $file 2>/dev/null && {
9016 error_noexit "expected failure when creating file" \
9021 # get param should return err once pool is gone
9022 if wait_update $HOSTNAME "lctl get_param -n \
9023 lov.$FSNAME-*.pools.$pool 2>/dev/null || echo foo" "foo"
9025 remove_pool_from_list $FSNAME.$pool
9028 error_noexit "Pool $FSNAME.$pool is not destroyed"
9033 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
9035 local POOL=${POOL:-cea1}
9036 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
9037 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
9040 local last_ost=$(($OSTCOUNT - 1))
9042 local ost_list=$(seq $first_ost $ost_step $last_ost)
9043 local ost_range="$first_ost $last_ost $ost_step"
9044 local test_path=$POOL_ROOT/$POOL_DIR_NAME
9045 local file_dir=$POOL_ROOT/file_tst
9049 # former test_200a test_200b
9050 pool_add $POOL || { rc=$? ; break; }
9051 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
9052 # former test_200c test_200d
9054 pool_set_dir $POOL $test_path || { rc=$? ; break; }
9055 pool_check_dir $POOL $test_path || { rc=$? ; break; }
9056 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
9057 || { rc=$? ; break; }
9058 # former test_200e test_200f
9059 local files=$((OSTCOUNT*3))
9060 pool_alloc_files $POOL $test_path $files "$ost_list" \
9061 || { rc=$? ; break; }
9062 pool_create_files $POOL $file_dir $files "$ost_list" \
9063 || { rc=$? ; break; }
9064 # former test_200g test_200h
9065 pool_lfs_df $POOL || { rc=$? ; break; }
9066 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
9068 # former test_201a test_201b test_201c
9069 pool_remove_first_target $POOL || { rc=$? ; break; }
9071 local f=$test_path/$tfile
9072 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
9073 pool_remove $POOL $f || { rc=$? ; break; }
9080 run_test 200 "OST pools"
9082 # usage: default_attr <count | size | offset>
9084 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
9087 # usage: check_default_stripe_attr
9088 check_default_stripe_attr() {
9089 ACTUAL=$($GETSTRIPE $* $DIR/$tdir)
9091 --stripe-count|--count)
9092 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
9093 --stripe-size|--size)
9094 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
9095 --stripe-index|--index)
9098 error "unknown getstripe attr '$1'"
9101 [ $ACTUAL != $EXPECTED ] &&
9102 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
9107 $SETSTRIPE --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
9109 check_default_stripe_attr --stripe-count
9110 check_default_stripe_attr --stripe-size
9111 check_default_stripe_attr --stripe-index
9115 run_test 204a "Print default stripe attributes ================="
9119 $SETSTRIPE --stripe-count 1 $DIR/$tdir
9121 check_default_stripe_attr --stripe-size
9122 check_default_stripe_attr --stripe-index
9126 run_test 204b "Print default stripe size and offset ==========="
9130 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
9132 check_default_stripe_attr --stripe-count
9133 check_default_stripe_attr --stripe-index
9137 run_test 204c "Print default stripe count and offset ==========="
9141 $SETSTRIPE --stripe-index 0 $DIR/$tdir
9143 check_default_stripe_attr --stripe-count
9144 check_default_stripe_attr --stripe-size
9148 run_test 204d "Print default stripe count and size ============="
9152 $SETSTRIPE -d $DIR/$tdir
9154 check_default_stripe_attr --stripe-count --raw
9155 check_default_stripe_attr --stripe-size --raw
9156 check_default_stripe_attr --stripe-index --raw
9160 run_test 204e "Print raw stripe attributes ================="
9164 $SETSTRIPE --stripe-count 1 $DIR/$tdir
9166 check_default_stripe_attr --stripe-size --raw
9167 check_default_stripe_attr --stripe-index --raw
9171 run_test 204f "Print raw stripe size and offset ==========="
9175 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
9177 check_default_stripe_attr --stripe-count --raw
9178 check_default_stripe_attr --stripe-index --raw
9182 run_test 204g "Print raw stripe count and offset ==========="
9186 $SETSTRIPE --stripe-index 0 $DIR/$tdir
9188 check_default_stripe_attr --stripe-count --raw
9189 check_default_stripe_attr --stripe-size --raw
9193 run_test 204h "Print raw stripe count and size ============="
9195 # Figure out which job scheduler is being used, if any,
9197 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
9199 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
9201 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
9203 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
9204 JOBENV=LOADL_STEP_ID
9205 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
9215 # clear old jobstats
9216 do_facet $SINGLEMDS lctl set_param mdt.*.job_stats="clear"
9217 do_facet ost1 lctl set_param obdfilter.*.job_stats="clear"
9219 # use a new JobID for this test, or we might see an old one
9220 [ "$JOBENV" = "FAKE_JOBID" ] && FAKE_JOBID=test_id.$testnum.$RANDOM
9224 log "Using JobID environment variable $JOBENV=$JOBVAL"
9226 if [ $JOBENV = "FAKE_JOBID" ]; then
9227 FAKE_JOBID=$JOBVAL $cmd
9232 if [ "$target" = "mdt" -o "$target" = "both" ]; then
9233 FACET="$SINGLEMDS" # will need to get MDS number for DNE
9234 do_facet $FACET lctl get_param mdt.*.job_stats |
9235 grep $JOBVAL || error "No job stats found on MDT $FACET"
9237 if [ "$target" = "ost" -o "$target" = "both" ]; then
9239 do_facet $FACET lctl get_param obdfilter.*.job_stats |
9240 grep $JOBVAL || error "No job stats found on OST $FACET"
9244 test_205() { # Job stats
9245 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
9246 skip "Server doesn't support jobstats" && return 0
9249 OLD_JOBENV=`$LCTL get_param -n jobid_var`
9250 if [ $OLD_JOBENV != $JOBENV ]; then
9251 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$JOBENV
9252 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" \
9257 cmd="mkdir $DIR/$tfile"
9258 verify_jobstats "$cmd" "mdt"
9260 cmd="rm -fr $DIR/$tfile"
9261 verify_jobstats "$cmd" "mdt"
9263 cmd="mknod $DIR/$tfile c 1 3"
9264 verify_jobstats "$cmd" "mdt"
9266 cmd="rm -f $DIR/$tfile"
9267 verify_jobstats "$cmd" "mdt"
9269 cmd="$SETSTRIPE -i 0 -c 1 $DIR/$tfile"
9270 verify_jobstats "$cmd" "mdt"
9272 cmd="touch $DIR/$tfile"
9273 verify_jobstats "$cmd" "both"
9275 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
9276 verify_jobstats "$cmd" "ost"
9278 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
9279 verify_jobstats "$cmd" "ost"
9281 cmd="$TRUNCATE $DIR/$tfile 0"
9282 verify_jobstats "$cmd" "both"
9284 cmd="mv -f $DIR/$tfile $DIR/jobstats_test_rename"
9285 verify_jobstats "$cmd" "mdt"
9288 rm -f $DIR/jobstats_test_rename
9290 if [ $OLD_JOBENV != $JOBENV ]; then
9291 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$OLD_JOBENV
9292 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" \
9293 $OLD_JOBENV || return 1
9296 run_test 205 "Verify job stats"
9298 # LU-1480, LU-1773 and LU-1657
9301 lfs setstripe -c -1 $DIR/$tdir
9302 #define OBD_FAIL_LOV_INIT 0x1403
9303 $LCTL set_param fail_loc=0xa0001403
9304 $LCTL set_param fail_val=1
9305 touch $DIR/$tdir/$tfile || true
9307 run_test 206 "fail lov_init_raid0() doesn't lbug"
9311 size=$((size % 8192 + 1))
9312 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
9313 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
9314 rm -f $DIR/f212 $DIR/f212.xyz
9316 run_test 212 "Sendfile test ============================================"
9319 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
9320 cancel_lru_locks osc
9321 lctl set_param fail_loc=0x8000040f
9322 # generate a read lock
9323 cat $DIR/$tfile > /dev/null
9324 # write to the file, it will try to cancel the above read lock.
9325 cat /etc/hosts >> $DIR/$tfile
9327 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
9329 test_214() { # for bug 20133
9330 mkdir -p $DIR/d214p/d214c
9331 for (( i=0; i < 340; i++ )) ; do
9332 touch $DIR/d214p/d214c/a$i
9335 ls -l $DIR/d214p || error "ls -l $DIR/d214p failed"
9336 mv $DIR/d214p/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
9337 ls $DIR/d214c || error "ls $DIR/d214c failed"
9338 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
9340 run_test 214 "hash-indexed directory test - bug 20133"
9342 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
9343 create_lnet_proc_files() {
9344 cat /proc/sys/lnet/$1 >$TMP/lnet_$1.out || error "cannot read /proc/sys/lnet/$1"
9345 sysctl lnet.$1 >$TMP/lnet_$1.sys_tmp || error "cannot read lnet.$1"
9347 sed "s/^lnet.$1\ =\ //g" "$TMP/lnet_$1.sys_tmp" >$TMP/lnet_$1.sys
9348 rm -f "$TMP/lnet_$1.sys_tmp"
9351 # counterpart of create_lnet_proc_files
9352 remove_lnet_proc_files() {
9353 rm -f $TMP/lnet_$1.out $TMP/lnet_$1.sys
9356 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
9357 # 3rd arg as regexp for body
9358 check_lnet_proc_stats() {
9359 local l=$(cat "$TMP/lnet_$1" |wc -l)
9360 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
9362 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
9365 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
9366 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
9367 # optional and can be regexp for 2nd line (lnet.routes case)
9368 check_lnet_proc_entry() {
9369 local blp=2 # blp stands for 'position of 1st line of body'
9370 [ "$5" = "" ] || blp=3 # lnet.routes case
9372 local l=$(cat "$TMP/lnet_$1" |wc -l)
9373 # subtracting one from $blp because the body can be empty
9374 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
9376 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
9377 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
9379 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
9380 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
9382 # bail out if any unexpected line happened
9383 sed -n "$blp~1 p" "$TMP/lnet_$1" |grep -Ev "$3"
9384 [ "$?" != 0 ] || error "$2 misformatted"
9387 test_215() { # for bugs 18102, 21079, 21517
9388 local N='(0|[1-9][0-9]*)' # non-negative numeric
9389 local P='[1-9][0-9]*' # positive numeric
9390 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
9391 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
9392 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
9393 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
9395 local L1 # regexp for 1st line
9396 local L2 # regexp for 2nd line (optional)
9397 local BR # regexp for the rest (body)
9399 # /proc/sys/lnet/stats should look as 11 space-separated non-negative numerics
9400 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
9401 create_lnet_proc_files "stats"
9402 check_lnet_proc_stats "stats.out" "/proc/sys/lnet/stats" "$BR"
9403 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
9404 remove_lnet_proc_files "stats"
9406 # /proc/sys/lnet/routes should look like this:
9407 # Routing disabled/enabled
9408 # net hops state router
9409 # where net is a string like tcp0, hops >= 0, state is up/down,
9410 # router is a string like 192.168.1.1@tcp2
9411 L1="^Routing (disabled|enabled)$"
9412 L2="^net +hops +state +router$"
9413 BR="^$NET +$N +(up|down) +$NID$"
9414 create_lnet_proc_files "routes"
9415 check_lnet_proc_entry "routes.out" "/proc/sys/lnet/routes" "$BR" "$L1" "$L2"
9416 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
9417 remove_lnet_proc_files "routes"
9419 # /proc/sys/lnet/routers should look like this:
9420 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
9421 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
9422 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
9423 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
9424 L1="^ref +rtr_ref +alive_cnt +state +last_ping +ping_sent +deadline +down_ni +router$"
9425 BR="^$P +$P +$N +(up|down) +$N +(0|1) +$I +$I +$NID$"
9426 create_lnet_proc_files "routers"
9427 check_lnet_proc_entry "routers.out" "/proc/sys/lnet/routers" "$BR" "$L1"
9428 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
9429 remove_lnet_proc_files "routers"
9431 # /proc/sys/lnet/peers should look like this:
9432 # nid refs state last max rtr min tx min queue
9433 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
9434 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
9435 # numeric (0 or >0 or <0), queue >= 0.
9436 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
9437 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
9438 create_lnet_proc_files "peers"
9439 check_lnet_proc_entry "peers.out" "/proc/sys/lnet/peers" "$BR" "$L1"
9440 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
9441 remove_lnet_proc_files "peers"
9443 # /proc/sys/lnet/buffers should look like this:
9444 # pages count credits min
9445 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
9446 L1="^pages +count +credits +min$"
9447 BR="^ +$N +$N +$I +$I$"
9448 create_lnet_proc_files "buffers"
9449 check_lnet_proc_entry "buffers.out" "/proc/sys/lnet/buffers" "$BR" "$L1"
9450 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
9451 remove_lnet_proc_files "buffers"
9453 # /proc/sys/lnet/nis should look like this:
9454 # nid status alive refs peer rtr max tx min
9455 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
9456 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
9457 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
9458 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
9459 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
9460 create_lnet_proc_files "nis"
9461 check_lnet_proc_entry "nis.out" "/proc/sys/lnet/nis" "$BR" "$L1"
9462 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
9463 remove_lnet_proc_files "nis"
9465 # can we successfully write to /proc/sys/lnet/stats?
9466 echo "0" >/proc/sys/lnet/stats || error "cannot write to /proc/sys/lnet/stats"
9467 sysctl -w lnet.stats=0 || error "cannot write to lnet.stats"
9469 run_test 215 "/proc/sys/lnet exists and has proper content - bugs 18102, 21079, 21517"
9471 test_216() { # bug 20317
9472 remote_ost_nodsh && skip "remote OST with nodsh" && return
9474 local p="$TMP/sanityN-$TESTNAME.parameters"
9475 save_lustre_params $HOSTNAME "osc.*.contention_seconds" > $p
9476 for node in $(osts_nodes); do
9477 save_lustre_params $node "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
9478 save_lustre_params $node "ldlm.namespaces.filter-*.contended_locks" >> $p
9479 save_lustre_params $node "ldlm.namespaces.filter-*.contention_seconds" >> $p
9483 # agressive lockless i/o settings
9484 for node in $(osts_nodes); do
9485 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'
9487 lctl set_param -n osc.*.contention_seconds 60
9489 $DIRECTIO write $DIR/$tfile 0 10 4096
9490 $CHECKSTAT -s 40960 $DIR/$tfile
9492 # disable lockless i/o
9493 for node in $(osts_nodes); do
9494 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'
9496 lctl set_param -n osc.*.contention_seconds 0
9499 dd if=/dev/zero of=$DIR/$tfile count=0
9500 $CHECKSTAT -s 0 $DIR/$tfile
9502 restore_lustre_params <$p
9506 run_test 216 "check lockless direct write works and updates file size and kms correctly"
9508 test_217() { # bug 22430
9512 for node in $(nodes_list); do
9513 nid=$(host_nids_address $node $NETTYPE)
9514 if [[ $nid = *-* ]] ; then
9515 echo "lctl ping $nid@$NETTYPE"
9516 lctl ping $nid@$NETTYPE
9518 echo "skipping $node (no hyphen detected)"
9522 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
9525 # do directio so as not to populate the page cache
9526 log "creating a 10 Mb file"
9527 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
9528 log "starting reads"
9529 dd if=$DIR/$tfile of=/dev/null bs=4096 &
9530 log "truncating the file"
9531 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
9533 kill %+ || true # reads might have finished
9534 echo "wait until dd is finished"
9536 log "removing the temporary file"
9537 rm -rf $DIR/$tfile || error "tmp file removal failed"
9539 run_test 218 "parallel read and truncate should not deadlock ======================="
9542 # write one partial page
9543 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
9544 # set no grant so vvp_io_commit_write will do sync write
9545 $LCTL set_param fail_loc=0x411
9546 # write a full page at the end of file
9547 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
9549 $LCTL set_param fail_loc=0
9550 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
9551 $LCTL set_param fail_loc=0x411
9552 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
9554 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
9556 test_220() { #LU-325
9557 remote_ost_nodsh && skip "remote OST with nodsh" && return
9561 local OST=$(lfs osts | grep ${OSTIDX}": " | \
9562 awk '{print $2}' | sed -e 's/_UUID$//')
9565 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
9566 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
9567 osc.$mdtosc_proc1.prealloc_last_id)
9568 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
9569 osc.$mdtosc_proc1.prealloc_next_id)
9573 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
9574 #define OBD_FAIL_OST_ENOINO 0x229
9575 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
9576 do_facet mgs $LCTL pool_new $FSNAME.$TESTNAME || return 1
9577 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
9579 $SETSTRIPE $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
9581 MDSOBJS=$((last_id - next_id))
9582 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
9584 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
9585 echo "OST still has $count kbytes free"
9587 echo "create $MDSOBJS files @next_id..."
9588 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
9590 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
9591 osc.$mdtosc_proc1.prealloc_last_id)
9592 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
9593 osc.$mdtosc_proc1.prealloc_next_id)
9595 echo "after creation, last_id=$last_id2, next_id=$next_id2"
9600 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
9601 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
9603 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST || return 4
9604 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME || return 5
9605 echo "unlink $MDSOBJS files @$next_id..."
9606 unlinkmany $DIR/$tdir/f $MDSOBJS || return 6
9608 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
9611 dd if=`which date` of=$MOUNT/date oflag=sync
9612 chmod +x $MOUNT/date
9614 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
9615 $LCTL set_param fail_loc=0x80001401
9617 $MOUNT/date > /dev/null
9620 run_test 221 "make sure fault and truncate race to not cause OOM"
9625 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
9626 createmany -o $DIR/$tdir/$tfile 10
9627 cancel_lru_locks mdc
9628 cancel_lru_locks osc
9629 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
9630 $LCTL set_param fail_loc=0x31a
9631 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
9632 $LCTL set_param fail_loc=0
9635 run_test 222a "AGL for ls should not trigger CLIO lock failure ================"
9640 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
9641 createmany -o $DIR/$tdir/$tfile 10
9642 cancel_lru_locks mdc
9643 cancel_lru_locks osc
9644 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
9645 $LCTL set_param fail_loc=0x31a
9646 rm -r $DIR/$tdir || "AGL for rmdir failed"
9647 $LCTL set_param fail_loc=0
9649 run_test 222b "AGL for rmdir should not trigger CLIO lock failure ============="
9654 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
9655 createmany -o $DIR/$tdir/$tfile 10
9656 cancel_lru_locks mdc
9657 cancel_lru_locks osc
9658 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
9659 $LCTL set_param fail_loc=0x31b
9660 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
9661 $LCTL set_param fail_loc=0
9664 run_test 223 "osc reenqueue if without AGL lock granted ======================="
9666 test_224a() { # LU-1039, MRP-303
9667 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
9668 $LCTL set_param fail_loc=0x508
9669 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
9670 $LCTL set_param fail_loc=0
9673 run_test 224a "Don't panic on bulk IO failure"
9675 test_224b() { # LU-1039, MRP-303
9676 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
9677 cancel_lru_locks osc
9678 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
9679 $LCTL set_param fail_loc=0x515
9680 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
9681 $LCTL set_param fail_loc=0
9684 run_test 224b "Don't panic on bulk IO failure"
9686 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
9688 if [ -z ${MDSSURVEY} ]; then
9689 skip_env "mds-survey not found" && return
9691 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
9692 { skip "Need MDS version at least 2.2.51"; return; }
9694 local mds=$(facet_host $SINGLEMDS)
9695 local target=$(do_nodes $mds 'lctl dl' | \
9696 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
9698 local cmd1="file_count=1000 thrhi=4"
9699 local cmd2="dir_count=2 layer=mdd stripe_count=0"
9700 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
9701 local cmd="$cmd1 $cmd2 $cmd3"
9703 rm -f ${TMP}/mds_survey*
9705 eval $cmd || error "mds-survey with zero-stripe failed"
9706 cat ${TMP}/mds_survey*
9707 rm -f ${TMP}/mds_survey*
9709 run_test 225a "Metadata survey sanity with zero-stripe"
9712 if [ -z ${MDSSURVEY} ]; then
9713 skip_env "mds-survey not found" && return
9715 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
9716 { skip "Need MDS version at least 2.2.51"; return; }
9718 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
9719 skip_env "Need to mount OST to test" && return
9722 local mds=$(facet_host $SINGLEMDS)
9723 local target=$(do_nodes $mds 'lctl dl' | \
9724 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
9726 local cmd1="file_count=1000 thrhi=4"
9727 local cmd2="dir_count=2 layer=mdd stripe_count=1"
9728 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
9729 local cmd="$cmd1 $cmd2 $cmd3"
9731 rm -f ${TMP}/mds_survey*
9733 eval $cmd || error "mds-survey with stripe_count failed"
9734 cat ${TMP}/mds_survey*
9735 rm -f ${TMP}/mds_survey*
9737 run_test 225b "Metadata survey sanity with stripe_count = 1"
9739 mcreate_path2fid () {
9745 local path=$DIR/$tdir/$name
9750 $MCREATE --mode=$1 --major=$2 --minor=$3 $path || \
9751 error "error: cannot create $desc"
9753 fid=$($LFS path2fid $path)
9755 [ $rc -ne 0 ] && error "error: cannot get fid of a $desc"
9757 fid_path=$($LFS fid2path $DIR $fid)
9759 [ $rc -ne 0 ] && error "error: cannot get path of a $desc by fid"
9761 [ "$path" == "$fid_path" ] || \
9762 error "error: fid2path returned \`$fid_path', expected \`$path'"
9769 mcreate_path2fid 0010666 0 0 fifo "FIFO"
9770 mcreate_path2fid 0020666 1 3 null "character special file (null)"
9771 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
9772 mcreate_path2fid 0040666 0 0 dir "directory"
9773 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
9774 mcreate_path2fid 0100666 0 0 file "regular file"
9775 mcreate_path2fid 0120666 0 0 link "symbolic link"
9776 mcreate_path2fid 0140666 0 0 sock "socket"
9778 run_test 226 "call path2fid and fid2path on files of all type"
9780 # LU-1299 Executing or running ldd on a truncated executable does not
9781 # cause an out-of-memory condition.
9783 dd if=`which date` of=$MOUNT/date bs=1k count=1
9784 chmod +x $MOUNT/date
9786 $MOUNT/date > /dev/null
9787 ldd $MOUNT/date > /dev/null
9790 run_test 227 "running truncated executable does not cause OOM"
9792 # LU-1512 try to reuse idle OI blocks
9794 [ "$FSTYPE" != "ldiskfs" ] && skip "non-ldiskfs backend" && return
9796 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
9797 local myDIR=$DIR/$tdir
9800 #define OBD_FAIL_SEQ_EXHAUST 0x1002
9801 $LCTL set_param fail_loc=0x80001002
9802 createmany -o $myDIR/t- 10000
9803 $LCTL set_param fail_loc=0
9804 # The guard is current the largest FID holder
9806 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
9808 local IDX=$(($SEQ % 64))
9810 do_facet $SINGLEMDS sync
9811 # Make sure journal flushed.
9813 local blk1=$(do_facet $SINGLEMDS \
9814 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
9815 grep Blockcount | awk '{print $4}')
9817 # Remove old files, some OI blocks will become idle.
9818 unlinkmany $myDIR/t- 10000
9819 # Create new files, idle OI blocks should be reused.
9820 createmany -o $myDIR/t- 2000
9821 do_facet $SINGLEMDS sync
9822 # Make sure journal flushed.
9824 local blk2=$(do_facet $SINGLEMDS \
9825 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
9826 grep Blockcount | awk '{print $4}')
9828 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
9830 run_test 228a "try to reuse idle OI blocks"
9833 [ "$FSTYPE" != "ldiskfs" ] && skip "non-ldiskfs backend" && return
9835 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
9836 local myDIR=$DIR/$tdir
9839 #define OBD_FAIL_SEQ_EXHAUST 0x1002
9840 $LCTL set_param fail_loc=0x80001002
9841 createmany -o $myDIR/t- 10000
9842 $LCTL set_param fail_loc=0
9843 # The guard is current the largest FID holder
9845 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
9847 local IDX=$(($SEQ % 64))
9849 do_facet $SINGLEMDS sync
9850 # Make sure journal flushed.
9852 local blk1=$(do_facet $SINGLEMDS \
9853 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
9854 grep Blockcount | awk '{print $4}')
9856 # Remove old files, some OI blocks will become idle.
9857 unlinkmany $myDIR/t- 10000
9860 stop $SINGLEMDS || error "Fail to stop MDT."
9862 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
9864 df $MOUNT || error "Fail to df."
9865 # Create new files, idle OI blocks should be reused.
9866 createmany -o $myDIR/t- 2000
9867 do_facet $SINGLEMDS sync
9868 # Make sure journal flushed.
9870 local blk2=$(do_facet $SINGLEMDS \
9871 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
9872 grep Blockcount | awk '{print $4}')
9874 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
9876 run_test 228b "idle OI blocks can be reused after MDT restart"
9880 [ "$FSTYPE" != "ldiskfs" ] && skip "non-ldiskfs backend" && return
9882 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
9883 local myDIR=$DIR/$tdir
9886 #define OBD_FAIL_SEQ_EXHAUST 0x1002
9887 $LCTL set_param fail_loc=0x80001002
9888 # 20000 files can guarantee there are index nodes in the OI file
9889 createmany -o $myDIR/t- 20000
9890 $LCTL set_param fail_loc=0
9891 # The guard is current the largest FID holder
9893 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
9895 local IDX=$(($SEQ % 64))
9897 do_facet $SINGLEMDS sync
9898 # Make sure journal flushed.
9900 local blk1=$(do_facet $SINGLEMDS \
9901 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
9902 grep Blockcount | awk '{print $4}')
9904 # Remove old files, some OI blocks will become idle.
9905 unlinkmany $myDIR/t- 20000
9907 # The OI file should become empty now
9909 # Create new files, idle OI blocks should be reused.
9910 createmany -o $myDIR/t- 2000
9911 do_facet $SINGLEMDS sync
9912 # Make sure journal flushed.
9914 local blk2=$(do_facet $SINGLEMDS \
9915 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
9916 grep Blockcount | awk '{print $4}')
9918 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
9920 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
9923 # tests that do cleanup/setup should be run at the end
9928 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
9929 $LCTL set_param fail_loc=0x903
9930 # cancel_lru_locks mgc - does not work due to lctl set_param syntax
9931 for ls in /proc/fs/lustre/ldlm/namespaces/MGC*/lru_size; do
9934 FAIL_ON_ERROR=true cleanup
9935 FAIL_ON_ERROR=true setup
9937 run_test 900 "umount should not race with any mgc requeue thread"
9940 check_and_cleanup_lustre
9941 if [ "$I_MOUNTED" != "yes" ]; then
9942 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true