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 ========================="
513 test_17l() { # LU-279
515 touch $DIR/$tdir/$tfile
516 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
517 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
518 # -h to not follow symlinks. -m '' to list all the xattrs.
519 # grep to remove first line: '# file: $path'.
520 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
522 lgetxattr_size_check $path $xattr ||
523 error "lgetxattr_size_check $path $xattr failed"
527 run_test 17l "Ensure lgetxattr's returned xattr size is consistent ========"
531 local short_sym="0123456789"
532 local WDIR=$DIR/${tdir}m
539 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
540 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
541 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
543 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
544 skip "only for ldiskfs MDT" && return 0
548 # create a long symlink file
549 for ((i = 0; i < 4; ++i)); do
550 long_sym=${long_sym}${long_sym}
553 echo "create 512 short and long symlink files under $WDIR"
554 for ((i = 0; i < 256; ++i)); do
555 ln -sf ${long_sym}"a5a5" $WDIR/long-$i
556 ln -sf ${short_sym}"a5a5" $WDIR/short-$i
562 wait_delete_completed
564 echo "recreate the 512 symlink files with a shorter string"
565 for ((i = 0; i < 512; ++i)); do
566 # rewrite the symlink file with a shorter string
567 ln -sf ${long_sym} $WDIR/long-$i
568 ln -sf ${short_sym} $WDIR/short-$i
571 mds_index=$($LFS getstripe -M $WDIR)
572 mds_index=$((mds_index+1))
573 devname=$(mdsdevname $mds_index)
574 cmd="$E2FSCK -fnvd $devname"
576 echo "stop and checking mds${mds_index}: $cmd"
577 # e2fsck should not return error
578 stop mds${mds_index} -f
579 do_facet mds${mds_index} $cmd || rc=$?
581 start mds${mds_index} $devname $MDS_MOUNT_OPTS
582 df $MOUNT > /dev/null 2>&1
583 [ $rc -ne 0 ] && error "e2fsck should not report error upon "\
584 "short/long symlink MDT: rc=$rc"
587 run_test 17m "run e2fsck against MDT which contains short/long symlink"
593 run_test 18 "touch .../f ; ls ... =============================="
599 $CHECKSTAT -a $DIR/f19 || error
601 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
604 ls -l $DIR/f19 && error || true
606 run_test 19b "ls -l .../f19 (should return error) =============="
609 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
610 $RUNAS touch $DIR/f19 && error || true
612 run_test 19c "$RUNAS touch .../f19 (should return error) =="
615 cat $DIR/f19 && error || true
617 run_test 19d "cat .../f19 (should return error) =============="
629 $CHECKSTAT -a $DIR/f || error
631 run_test 20 "touch .../f ; ls -l ... ==========================="
635 [ -f $DIR/d21/dangle ] && rm -f $DIR/d21/dangle
636 ln -s dangle $DIR/d21/link
637 echo foo >> $DIR/d21/link
639 $CHECKSTAT -t link $DIR/d21/link || error
640 $CHECKSTAT -f -t file $DIR/d21/link || error
642 run_test 21 "write to dangling link ============================"
647 chown $RUNAS_ID:$RUNAS_GID $WDIR
648 (cd $WDIR || error "cd $WDIR failed";
649 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
651 ls -lR $WDIR/etc || error "ls -lR $WDIR/etc failed"
652 $CHECKSTAT -t dir $WDIR/etc || error "checkstat -t dir failed"
653 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $WDIR/etc || error "checkstat -u failed"
655 run_test 22 "unpack tar archive as non-root user ==============="
660 local file=$DIR/$tdir/$tfile
662 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
663 openfile -f O_CREAT:O_EXCL $file &&
664 error "$file recreate succeeded" || true
666 run_test 23a "O_CREAT|O_EXCL in subdir =========================="
668 test_23b() { # bug 18988
670 local file=$DIR/$tdir/$tfile
673 echo foo > $file || error "write filed"
674 echo bar >> $file || error "append filed"
675 $CHECKSTAT -s 8 $file || error "wrong size"
678 run_test 23b "O_APPEND check =========================="
681 echo '== rename sanity =============================================='
682 echo '-- same directory rename'
685 mv $DIR/R1/f $DIR/R1/g
686 $CHECKSTAT -t file $DIR/R1/g || error
688 run_test 24a "touch .../R1/f; rename .../R1/f .../R1/g ========="
693 mv $DIR/R2/f $DIR/R2/g
694 $CHECKSTAT -a $DIR/R2/f || error
695 $CHECKSTAT -t file $DIR/R2/g || error
697 run_test 24b "touch .../R2/{f,g}; rename .../R2/f .../R2/g ====="
702 mv $DIR/R3/f $DIR/R3/g
703 $CHECKSTAT -a $DIR/R3/f || error
704 $CHECKSTAT -t dir $DIR/R3/g || error
706 run_test 24c "mkdir .../R3/f; rename .../R3/f .../R3/g ========="
711 mrename $DIR/R4/f $DIR/R4/g
712 $CHECKSTAT -a $DIR/R4/f || error
713 $CHECKSTAT -t dir $DIR/R4/g || error
715 run_test 24d "mkdir .../R4/{f,g}; rename .../R4/f .../R4/g ====="
718 echo '-- cross directory renames --'
721 mv $DIR/R5a/f $DIR/R5b/g
722 $CHECKSTAT -a $DIR/R5a/f || error
723 $CHECKSTAT -t file $DIR/R5b/g || error
725 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
729 touch $DIR/R6a/f $DIR/R6b/g
730 mv $DIR/R6a/f $DIR/R6b/g
731 $CHECKSTAT -a $DIR/R6a/f || error
732 $CHECKSTAT -t file $DIR/R6b/g || error
734 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
739 mv $DIR/R7a/d $DIR/R7b/e
740 $CHECKSTAT -a $DIR/R7a/d || error
741 $CHECKSTAT -t dir $DIR/R7b/e || error
743 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
747 mkdir $DIR/R8a/d $DIR/R8b/e
748 mrename $DIR/R8a/d $DIR/R8b/e
749 $CHECKSTAT -a $DIR/R8a/d || error
750 $CHECKSTAT -t dir $DIR/R8b/e || error
752 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
755 echo "-- rename error cases"
759 mrename $DIR/R9/f $DIR/R9/a
760 $CHECKSTAT -t file $DIR/R9/f || error
761 $CHECKSTAT -t dir $DIR/R9/a || error
762 $CHECKSTAT -a $DIR/R9/a/f || error
764 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
768 mrename $DIR/R10/f $DIR/R10/g
769 $CHECKSTAT -t dir $DIR/R10 || error
770 $CHECKSTAT -a $DIR/R10/f || error
771 $CHECKSTAT -a $DIR/R10/g || error
773 run_test 24j "source does not exist ============================"
776 mkdir $DIR/R11a $DIR/R11a/d
778 mv $DIR/R11a/f $DIR/R11a/d
779 $CHECKSTAT -a $DIR/R11a/f || error
780 $CHECKSTAT -t file $DIR/R11a/d/f || error
782 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
784 # bug 2429 - rename foo foo foo creates invalid file
787 $MULTIOP $f OcNs || error
789 run_test 24l "Renaming a file to itself ========================"
793 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
794 # on ext3 this does not remove either the source or target files
795 # though the "expected" operation would be to remove the source
796 $CHECKSTAT -t file ${f} || error "${f} missing"
797 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
799 run_test 24m "Renaming a file to a hard link to itself ========="
803 # this stats the old file after it was renamed, so it should fail
807 $CHECKSTAT ${f}.rename
810 run_test 24n "Statting the old file after renaming (Posix rename 2)"
813 check_kernel_version 37 || return 0
815 rename_many -s random -v -n 10 $DIR/d24o
817 run_test 24o "rename of files during htree split ==============="
821 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
822 mrename $DIR/R12a $DIR/R12b
823 $CHECKSTAT -a $DIR/R12a || error
824 $CHECKSTAT -t dir $DIR/R12b || error
825 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
826 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
828 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
832 DIRINO=`ls -lid $DIR/R13a | awk '{ print $1 }'`
833 multiop_bg_pause $DIR/R13b D_c || return 1
836 mrename $DIR/R13a $DIR/R13b
837 $CHECKSTAT -a $DIR/R13a || error
838 $CHECKSTAT -t dir $DIR/R13b || error
839 DIRINO2=`ls -lid $DIR/R13b | awk '{ print $1 }'`
840 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
842 wait $MULTIPID || error "multiop close failed"
844 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
846 test_24r() { #bug 3789
847 mkdir $DIR/R14a $DIR/R14a/b
848 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
849 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
850 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
852 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
855 mkdir $DIR/R15a $DIR/R15a/b $DIR/R15a/b/c
856 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
857 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
858 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
860 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
862 mkdir $DIR/R16a $DIR/R16a/b $DIR/R16a/b/c
863 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
864 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
865 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
867 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
869 test_24u() { # bug12192
870 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error
871 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
873 run_test 24u "create stripe file"
879 simple_cleanup_common() {
882 wait_delete_completed
887 local FREE_INODES=$(lfs_df -i | grep "summary" | awk '{print $4}')
888 [ $FREE_INODES -lt $NRFILES ] && \
889 skip "not enough free inodes $FREE_INODES required $NRFILES" &&
892 trap simple_cleanup_common EXIT
895 createmany -m $DIR/$tdir/$tfile $NRFILES
898 lctl set_param mdc.*.stats clear
900 ls $DIR/$tdir >/dev/null || error "error in listing large dir"
903 # DIRENT_SIZE = 32 bytes for sizeof(struct lu_dirent) +
904 # 8 bytes for name(filename is mostly 5 in this test) +
905 # 8 bytes for luda_type
906 # take into account of overhead in lu_dirpage header and end mark in
907 # each page, plus one in RPC_NUM calculation.
909 RPC_SIZE=$(($(lctl get_param -n mdc.*.max_pages_per_rpc)*$(page_size)))
910 RPC_NUM=$(((NRFILES * DIRENT_SIZE + RPC_SIZE - 1) / RPC_SIZE + 1))
911 mds_readpage=`lctl get_param mdc.*.stats | \
912 awk '/^mds_readpage/ {print $2}'`
913 [ $mds_readpage -gt $RPC_NUM ] && \
914 error "large readdir doesn't take effect"
916 simple_cleanup_common
918 run_test 24v "list directory with large files (handle hash collision, bug: 17560)"
920 test_24w() { # bug21506
922 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
923 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
924 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
925 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
926 [ "$SZ1" = "$SZ2" ] || \
927 error "Error reading at the end of the file $tfile"
929 run_test 24w "Reading a file larger than 4Gb"
932 echo '== symlink sanity ============================================='
936 touch $DIR/s25/foo || error
938 run_test 25a "create file in symlinked directory ==============="
941 [ ! -d $DIR/d25 ] && test_25a
942 $CHECKSTAT -t file $DIR/s25/foo || error
944 run_test 25b "lookup file in symlinked directory ==============="
949 ln -s d26/d26-2 $DIR/s26
950 touch $DIR/s26/foo || error
952 run_test 26a "multiple component symlink ======================="
955 mkdir -p $DIR/d26b/d26-2
956 ln -s d26b/d26-2/foo $DIR/s26-2
957 touch $DIR/s26-2 || error
959 run_test 26b "multiple component symlink at end of lookup ======"
964 ln -s d26.2 $DIR/s26.2-1
965 ln -s s26.2-1 $DIR/s26.2-2
966 ln -s s26.2-2 $DIR/s26.2-3
967 chmod 0666 $DIR/s26.2-3/foo
969 run_test 26c "chain of symlinks ================================"
971 # recursive symlinks (bug 439)
973 ln -s d26-3/foo $DIR/d26-3
975 run_test 26d "create multiple component recursive symlink ======"
978 [ ! -h $DIR/d26-3 ] && test_26d
981 run_test 26e "unlink multiple component recursive symlink ======"
983 # recursive symlinks (bug 7022)
986 mkdir $DIR/$tdir/$tfile || error "mkdir $DIR/$tdir/$tfile failed"
987 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
988 mkdir -p lndir/bar1 || error "mkdir lndir/bar1 failed"
989 mkdir $tfile || error "mkdir $tfile failed"
990 cd $tfile || error "cd $tfile failed"
991 ln -s .. dotdot || error "ln dotdot failed"
992 ln -s dotdot/lndir lndir || error "ln lndir failed"
993 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
994 output=`ls $tfile/$tfile/lndir/bar1`
995 [ "$output" = bar1 ] && error "unexpected output"
996 rm -r $tfile || error "rm $tfile failed"
997 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
999 run_test 26f "rm -r of a directory which has recursive symlink ="
1002 echo '== stripe sanity =============================================='
1003 mkdir -p $DIR/d27 || error "mkdir failed"
1005 $SETSTRIPE -c 1 $DIR/d27/f0 || error "setstripe failed"
1006 $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
1008 log "== test_27a: write to one stripe file ========================="
1009 cp /etc/hosts $DIR/d27/f0 || error
1011 run_test 27a "one stripe file =================================="
1014 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
1016 $SETSTRIPE -c 2 $DIR/d27/f01 || error "setstripe failed"
1017 $GETSTRIPE -c $DIR/d27/f01
1018 [ $($GETSTRIPE -c $DIR/d27/f01) -eq 2 ] ||
1019 error "two-stripe file doesn't have two stripes"
1021 run_test 27b "create two stripe file"
1024 [ -f $DIR/d27/f01 ] || skip "test_27b not run" && return
1026 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
1028 run_test 27c "write to two stripe file"
1032 $SETSTRIPE -c 0 -i -1 -S 0 $DIR/d27/fdef || error "setstripe failed"
1033 $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
1034 dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
1036 run_test 27d "create file with default settings ================"
1040 $SETSTRIPE -c 2 $DIR/d27/f12 || error "setstripe failed"
1041 $SETSTRIPE -c 2 $DIR/d27/f12 && error "setstripe succeeded twice"
1042 $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
1044 run_test 27e "setstripe existing file (should return error) ======"
1048 $SETSTRIPE -S 100 -i 0 -c 1 $DIR/d27/fbad && error "setstripe failed"
1049 dd if=/dev/zero of=$DIR/d27/f12 bs=4k count=4 || error "dd failed"
1050 $GETSTRIPE $DIR/d27/fbad || error "$GETSTRIPE failed"
1052 run_test 27f "setstripe with bad stripe size (should return error)"
1056 $MCREATE $DIR/d27/fnone || error "mcreate failed"
1057 $GETSTRIPE $DIR/d27/fnone 2>&1 | grep "no stripe info" ||
1058 error "$DIR/d27/fnone has object"
1060 run_test 27g "$GETSTRIPE with no objects"
1063 touch $DIR/d27/fsome || error "touch failed"
1064 [ $($GETSTRIPE -c $DIR/d27/fsome) -gt 0 ] || error "missing objects"
1066 run_test 27i "$GETSTRIPE with some objects"
1070 $SETSTRIPE -i $OSTCOUNT $DIR/d27/f27j && error "setstripe failed"||true
1072 run_test 27j "setstripe with bad stripe offset (should return error)"
1074 test_27k() { # bug 2844
1077 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
1078 [ ! -d $DIR/d27 ] && mkdir -p $DIR/d27
1079 $SETSTRIPE -S 67108864 $FILE || error "setstripe failed"
1080 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1081 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
1082 dd if=/dev/zero of=$FILE bs=4k count=1
1083 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1084 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
1086 run_test 27k "limit i_blksize for broken user apps ============="
1090 mcreate $DIR/f27l || error "creating file"
1091 $RUNAS $SETSTRIPE -c 1 $DIR/f27l && \
1092 error "setstripe should have failed" || true
1094 run_test 27l "check setstripe permissions (should return error)"
1097 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" &&
1099 if [ $ORIGFREE -gt $MAXFREE ]; then
1100 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1103 trap simple_cleanup_common EXIT
1105 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_1
1106 dd if=/dev/zero of=$DIR/$tdir/f27m_1 bs=1024 count=$MAXFREE &&
1107 error "dd should fill OST0"
1109 while $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_$i; do
1111 [ $i -gt 256 ] && break
1114 touch $DIR/$tdir/f27m_$i
1115 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1116 error "OST0 was full but new created file still use it"
1118 touch $DIR/$tdir/f27m_$i
1119 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1120 error "OST0 was full but new created file still use it"
1121 simple_cleanup_common
1123 run_test 27m "create file while OST0 was full =================="
1126 local DELAY=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage | head -n 1 | awk '{print $1 * 2}')
1130 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1131 # if the OST isn't full anymore.
1133 local OSTIDX=${1:-""}
1135 local list=$(comma_list $(osts_nodes))
1136 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1138 do_nodes $list lctl set_param fail_loc=0
1139 sync # initiate all OST_DESTROYs from MDS to OST
1143 exhaust_precreations() {
1146 local FAILIDX=${3:-$OSTIDX}
1149 local MDSIDX=$(get_mds_dir "$DIR/$tdir")
1150 echo OSTIDX=$OSTIDX MDSIDX=$MDSIDX
1152 local OST=$(ostname_from_index $OSTIDX)
1153 local MDT_INDEX=$(lfs df | grep "\[MDT:$((MDSIDX - 1))\]" | awk '{print $1}' | \
1154 sed -e 's/_UUID$//;s/^.*-//')
1157 local mdtosc_proc1=$(get_mdtosc_proc_path mds${MDSIDX} $OST)
1158 local last_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1159 osc.$mdtosc_proc1.prealloc_last_id)
1160 local next_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1161 osc.$mdtosc_proc1.prealloc_next_id)
1163 local mdtosc_proc2=$(get_mdtosc_proc_path mds${MDSIDX})
1164 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1166 mkdir -p $DIR/$tdir/${OST}
1167 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1168 #define OBD_FAIL_OST_ENOSPC 0x215
1169 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=$FAILIDX
1170 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x215
1171 echo "Creating to objid $last_id on ost $OST..."
1172 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1173 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1174 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=$FAILLOC
1178 exhaust_all_precreations() {
1180 for (( i=0; i < OSTCOUNT; i++ )) ; do
1181 exhaust_precreations $i $1 -1
1186 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1187 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1188 remote_ost_nodsh && skip "remote OST with nodsh" && return
1191 rm -f $DIR/$tdir/$tfile
1192 exhaust_precreations 0 0x80000215
1193 $SETSTRIPE -c -1 $DIR/$tdir
1194 touch $DIR/$tdir/$tfile || error
1195 $GETSTRIPE $DIR/$tdir/$tfile
1198 run_test 27n "create file with some full OSTs =================="
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
1207 exhaust_all_precreations 0x215
1209 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1214 run_test 27o "create file with all full OSTs (should error) ===="
1217 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1218 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1219 remote_ost_nodsh && skip "remote OST with nodsh" && return
1222 rm -f $DIR/$tdir/$tfile
1225 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1226 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1227 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1229 exhaust_precreations 0 0x80000215
1230 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1231 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1232 $GETSTRIPE $DIR/$tdir/$tfile
1236 run_test 27p "append to a truncated file with some full OSTs ==="
1239 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1240 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1241 remote_ost_nodsh && skip "remote OST with nodsh" && return
1244 rm -f $DIR/$tdir/$tfile
1247 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1248 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||error "truncate $DIR/$tdir/$tfile failed"
1249 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1251 exhaust_all_precreations 0x215
1253 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1254 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1258 run_test 27q "append to truncated file with all OSTs full (should error) ==="
1261 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1262 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1263 remote_ost_nodsh && skip "remote OST with nodsh" && return
1266 rm -f $DIR/$tdir/$tfile
1267 exhaust_precreations 0 0x80000215
1269 $SETSTRIPE -i 0 -c 2 $DIR/$tdir/$tfile # && error
1273 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1275 test_27s() { # bug 10725
1277 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1278 local stripe_count=0
1279 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1280 $SETSTRIPE -S $stripe_size -c $stripe_count $DIR/$tdir &&
1281 error "stripe width >= 2^32 succeeded" || true
1284 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1286 test_27t() { # bug 10864
1291 $WLFS getstripe $tfile
1294 run_test 27t "check that utils parse path correctly"
1296 test_27u() { # bug 4900
1297 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1298 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1300 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1301 do_facet $SINGLEMDS lctl set_param fail_loc=0x139
1303 createmany -o $DIR/$tdir/t- 1000
1304 do_facet $SINGLEMDS lctl set_param fail_loc=0
1306 TLOG=$DIR/$tfile.getstripe
1307 $GETSTRIPE $DIR/$tdir > $TLOG
1308 OBJS=`awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj;}' $TLOG`
1309 unlinkmany $DIR/$tdir/t- 1000
1310 [ $OBJS -gt 0 ] && \
1311 error "$OBJS objects created on OST-0. See $TLOG" || pass
1313 run_test 27u "skip object creation on OSC w/o objects =========="
1315 test_27v() { # bug 4900
1316 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1317 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1318 remote_ost_nodsh && skip "remote OST with nodsh" && return
1320 exhaust_all_precreations 0x215
1324 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1326 touch $DIR/$tdir/$tfile
1327 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1329 for (( i=1; i < OSTCOUNT; i++ )); do
1330 do_facet ost$i lctl set_param fail_loc=0x705
1332 local START=`date +%s`
1333 createmany -o $DIR/$tdir/$tfile 32
1335 local FINISH=`date +%s`
1336 local TIMEOUT=`lctl get_param -n timeout`
1337 local PROCESS=$((FINISH - START))
1338 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1339 error "$FINISH - $START >= $TIMEOUT / 2"
1340 sleep $((TIMEOUT / 2 - PROCESS))
1343 run_test 27v "skip object creation on slow OST ================="
1345 test_27w() { # bug 10997
1346 mkdir -p $DIR/$tdir || error "mkdir failed"
1347 $SETSTRIPE -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1348 [ $($GETSTRIPE -S $DIR/$tdir/f0) -ne 65536 ] &&
1349 error "stripe size $size != 65536" || true
1350 [ $($GETSTRIPE -d $DIR/$tdir | grep -c "stripe_count") -ne 1 ] &&
1351 error "$GETSTRIPE -d $DIR/$tdir failed" || true
1353 run_test 27w "check $SETSTRIPE -S option"
1356 [ "$OSTCOUNT" -lt "2" ] &&
1357 skip_env "skipping multiple stripe count/offset test" && return
1359 mkdir -p $DIR/$tdir || error "mkdir failed"
1360 for i in $(seq 1 $OSTCOUNT); do
1362 $SETSTRIPE -c $i -i $offset $DIR/$tdir/f$i ||
1363 error "setstripe -c $i -i $offset failed"
1364 count=$($GETSTRIPE -c $DIR/$tdir/f$i)
1365 index=$($GETSTRIPE -i $DIR/$tdir/f$i)
1366 [ $count -ne $i ] && error "stripe count $count != $i" || true
1367 [ $index -ne $offset ] &&
1368 error "stripe offset $index != $offset" || true
1371 run_test 27wa "check $SETSTRIPE -c -i options"
1374 remote_ost_nodsh && skip "remote OST with nodsh" && return
1375 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs" && return
1376 OFFSET=$(($OSTCOUNT - 1))
1378 local OST=$(ostname_from_index $OSTIDX)
1381 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe per file
1382 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1384 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1385 for i in `seq 0 $OFFSET`; do
1386 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}' | grep -w "$OSTIDX"` ] &&
1387 error "OST0 was degraded but new created file still use it"
1389 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1391 run_test 27x "create files while OST0 is degraded"
1394 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1395 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1396 remote_ost_nodsh && skip "remote OST with nodsh" && return
1398 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1399 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1400 osc.$mdtosc.prealloc_last_id)
1401 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1402 osc.$mdtosc.prealloc_next_id)
1403 local fcount=$((last_id - next_id))
1404 [ $fcount -eq 0 ] && skip "not enough space on OST0" && return
1405 [ $fcount -gt $OSTCOUNT ] && fcount=$OSTCOUNT
1407 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
1408 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
1409 local OST_DEACTIVE_IDX=-1
1414 for OSC in $MDS_OSCS; do
1415 OST=$(osc_to_ost $OSC)
1416 OSTIDX=$(index_from_ostuuid $OST)
1417 if [ $OST_DEACTIVE_IDX == -1 ]; then
1418 OST_DEACTIVE_IDX=$OSTIDX
1420 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
1421 echo $OSC "is Deactivated:"
1422 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1426 OSTIDX=$(index_from_ostuuid $OST)
1428 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1430 for OSC in $MDS_OSCS; do
1431 OST=$(osc_to_ost $OSC)
1432 OSTIDX=$(index_from_ostuuid $OST)
1433 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1434 echo $OST "is degraded:"
1435 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1436 obdfilter.$OST.degraded=1
1441 createmany -o $DIR/$tdir/$tfile $fcount
1443 for OSC in $MDS_OSCS; do
1444 OST=$(osc_to_ost $OSC)
1445 OSTIDX=$(index_from_ostuuid $OST)
1446 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1447 echo $OST "is recovered from degraded:"
1448 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1449 obdfilter.$OST.degraded=0
1451 do_facet $SINGLEMDS lctl --device %$OSC activate
1455 run_test 27y "create files while OST0 is degraded and the rest inactive"
1461 lmm_count=$($GETSTRIPE -c $1)
1462 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1463 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1465 local old_ifs="$IFS"
1467 fid=($($LFS path2fid $1))
1470 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1471 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1473 # compare lmm_seq and lu_fid->f_seq
1474 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1475 # compare lmm_object_id and lu_fid->oid
1476 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1478 # check the trusted.fid attribute of the OST objects of the file
1479 local have_obdidx=false
1481 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1482 # skip lines up to and including "obdidx"
1483 [ -z "$obdidx" ] && break
1484 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1485 $have_obdidx || continue
1487 local ost=$((obdidx + 1))
1488 local dev=$(ostdevname $ost)
1490 if [ $(facet_fstype ost$ost) != ldiskfs ]; then
1491 echo "Currently only works with ldiskfs-based OSTs"
1495 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1497 #don't unmount/remount the OSTs if we don't need to do that
1498 #local dir=$(facet_mntpt ost$ost)
1500 #do_facet ost$dev mount -t $FSTYPE $dev $dir $OST_MOUNT_OPTS ||
1501 # { error "mounting $dev as $FSTYPE failed"; return 3; }
1502 #local obj_file=$(do_facet ost$ost find $dir/O/$seq -name $oid)
1503 #local ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID $obj_file)
1505 local obj_file="O/$seq/d$((oid %32))/$oid"
1506 local ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
1507 $dev 2>/dev/null" | grep "parent=")
1509 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
1511 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
1513 #do_facet ost$ost umount -d $dir
1514 #start ost$ost $dev $OST_MOUNT_OPTS
1516 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
1517 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
1518 local ff_parent=$(echo $ff|sed -e 's/.*parent=.//')
1519 local ff_pseq=$(echo $ff_parent | cut -d: -f1)
1520 local ff_poid=$(echo $ff_parent | cut -d: -f2)
1521 local ff_pstripe=$(echo $ff_parent | sed -e 's/.*stripe=//')
1523 # compare lmm_seq and filter_fid->ff_parent.f_seq
1524 [ $ff_pseq = $lmm_seq ] ||
1525 error "FF parent SEQ $ff_pseq != $lmm_seq"
1526 # compare lmm_object_id and filter_fid->ff_parent.f_oid
1527 [ $ff_poid = $lmm_oid ] ||
1528 error "FF parent OID $ff_poid != $lmm_oid"
1529 [ $ff_pstripe = $stripe_nr ] ||
1530 error "FF stripe $ff_pstripe != $stripe_nr"
1532 stripe_nr=$((stripe_nr + 1))
1537 remote_ost_nodsh && skip "remote OST with nodsh" && return
1540 $SETSTRIPE -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
1541 { error "setstripe -c -1 failed"; return 1; }
1542 # We need to send a write to every object to get parent FID info set.
1543 # This _should_ also work for setattr, but does not currently.
1544 # touch $DIR/$tdir/$tfile-1 ||
1545 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
1546 { error "dd $tfile-1 failed"; return 2; }
1547 $SETSTRIPE -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
1548 { error "setstripe -c -1 failed"; return 3; }
1549 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
1550 { error "dd $tfile-2 failed"; return 4; }
1552 # make sure write RPCs have been sent to OSTs
1555 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
1556 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
1558 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
1560 test_27A() { # b=19102
1561 local restore_size=$($GETSTRIPE -S $MOUNT)
1562 local restore_count=$($GETSTRIPE -c $MOUNT)
1563 local restore_offset=$($GETSTRIPE -i $MOUNT)
1564 $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
1565 local default_size=$($GETSTRIPE -S $MOUNT)
1566 local default_count=$($GETSTRIPE -c $MOUNT)
1567 local default_offset=$($GETSTRIPE -i $MOUNT)
1568 local dsize=$((1024 * 1024))
1569 [ $default_size -eq $dsize ] ||
1570 error "stripe size $default_size != $dsize"
1571 [ $default_count -eq 1 ] || error "stripe count $default_count != 1"
1572 [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
1573 $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
1575 run_test 27A "check filesystem-wide default LOV EA values"
1577 # createtest also checks that device nodes are created and
1578 # then visible correctly (#2091)
1579 test_28() { # bug 2091
1581 $CREATETEST $DIR/d28/ct || error
1583 run_test 28 "create/mknod/mkdir with bad file types ============"
1586 cancel_lru_locks mdc
1592 declare -i LOCKCOUNTORIG=0
1593 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1594 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
1596 [ $LOCKCOUNTORIG -eq 0 ] && echo "No mdc lock count" && return 1
1598 declare -i LOCKUNUSEDCOUNTORIG=0
1599 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1600 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
1607 declare -i LOCKCOUNTCURRENT=0
1608 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1609 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
1612 declare -i LOCKUNUSEDCOUNTCURRENT=0
1613 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1614 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
1617 if [ "$LOCKCOUNTCURRENT" -gt "$LOCKCOUNTORIG" ]; then
1618 lctl set_param -n ldlm.dump_namespaces ""
1619 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
1620 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1621 log "dumped log to $TMP/test_29.dk (bug 5793)"
1624 if [ "$LOCKUNUSEDCOUNTCURRENT" -gt "$LOCKUNUSEDCOUNTORIG" ]; then
1625 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
1626 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1627 log "dumped log to $TMP/test_29.dk (bug 5793)"
1631 run_test 29 "IT_GETATTR regression ============================"
1633 test_30a() { # was test_30
1634 cp `which ls` $DIR || cp /bin/ls $DIR
1638 run_test 30a "execute binary from Lustre (execve) =============="
1641 cp `which ls` $DIR || cp /bin/ls $DIR
1643 $RUNAS $DIR/ls / || error
1646 run_test 30b "execute binary from Lustre as non-root ==========="
1648 test_30c() { # b=22376
1649 cp `which ls` $DIR || cp /bin/ls $DIR
1651 cancel_lru_locks mdc
1652 cancel_lru_locks osc
1653 $RUNAS $DIR/ls / || error
1656 run_test 30c "execute binary from Lustre without read perms ===="
1659 $OPENUNLINK $DIR/f31 $DIR/f31 || error
1660 $CHECKSTAT -a $DIR/f31 || error
1662 run_test 31a "open-unlink file =================================="
1665 touch $DIR/f31 || error
1666 ln $DIR/f31 $DIR/f31b || error
1667 $MULTIOP $DIR/f31b Ouc || error
1668 $CHECKSTAT -t file $DIR/f31 || error
1670 run_test 31b "unlink file with multiple links while open ======="
1673 touch $DIR/f31 || error
1674 ln $DIR/f31 $DIR/f31c || error
1675 multiop_bg_pause $DIR/f31 O_uc || return 1
1677 $MULTIOP $DIR/f31c Ouc
1678 kill -USR1 $MULTIPID
1681 run_test 31c "open-unlink file with multiple links ============="
1684 opendirunlink $DIR/d31d $DIR/d31d || error
1685 $CHECKSTAT -a $DIR/d31d || error
1687 run_test 31d "remove of open directory ========================="
1689 test_31e() { # bug 2904
1690 check_kernel_version 34 || return 0
1691 openfilleddirunlink $DIR/d31e || error
1693 run_test 31e "remove of open non-empty directory ==============="
1695 test_31f() { # bug 4554
1698 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
1699 cp /etc/hosts $DIR/d31f
1701 $GETSTRIPE $DIR/d31f/hosts
1702 multiop_bg_pause $DIR/d31f D_c || return 1
1705 rm -rv $DIR/d31f || error "first of $DIR/d31f"
1707 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
1708 cp /etc/hosts $DIR/d31f
1710 $GETSTRIPE $DIR/d31f/hosts
1711 multiop_bg_pause $DIR/d31f D_c || return 1
1714 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
1715 wait $MULTIPID || error "first opendir $MULTIPID failed"
1719 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
1720 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
1723 run_test 31f "remove of open directory with open-unlink file ==="
1726 echo "-- cross directory link --"
1727 mkdir $DIR/d31g{a,b}
1729 ln $DIR/d31ga/f $DIR/d31gb/g
1730 $CHECKSTAT -t file $DIR/d31ga/f || error "source"
1731 [ `stat -c%h $DIR/d31ga/f` == '2' ] || error "source nlink"
1732 $CHECKSTAT -t file $DIR/d31gb/g || error "target"
1733 [ `stat -c%h $DIR/d31gb/g` == '2' ] || error "target nlink"
1735 run_test 31g "cross directory link==============="
1738 echo "-- cross directory link --"
1742 ln $DIR/d31h/f $DIR/d31h/dir/g
1743 $CHECKSTAT -t file $DIR/d31h/f || error "source"
1744 [ `stat -c%h $DIR/d31h/f` == '2' ] || error "source nlink"
1745 $CHECKSTAT -t file $DIR/d31h/dir/g || error "target"
1746 [ `stat -c%h $DIR/d31h/dir/g` == '2' ] || error "target nlink"
1748 run_test 31h "cross directory link under child==============="
1751 echo "-- cross directory link --"
1754 touch $DIR/d31i/dir/f
1755 ln $DIR/d31i/dir/f $DIR/d31i/g
1756 $CHECKSTAT -t file $DIR/d31i/dir/f || error "source"
1757 [ `stat -c%h $DIR/d31i/dir/f` == '2' ] || error "source nlink"
1758 $CHECKSTAT -t file $DIR/d31i/g || error "target"
1759 [ `stat -c%h $DIR/d31i/g` == '2' ] || error "target nlink"
1761 run_test 31i "cross directory link under parent==============="
1766 mkdir $DIR/d31j/dir1
1767 ln $DIR/d31j/dir1 $DIR/d31j/dir2 && error "ln for dir"
1768 link $DIR/d31j/dir1 $DIR/d31j/dir3 && error "link for dir"
1769 mlink $DIR/d31j/dir1 $DIR/d31j/dir4 && error "mlink for dir"
1770 mlink $DIR/d31j/dir1 $DIR/d31j/dir1 && error "mlink to the same dir"
1773 run_test 31j "link for directory==============="
1779 touch $DIR/d31k/exist
1780 mlink $DIR/d31k/s $DIR/d31k/t || error "mlink"
1781 mlink $DIR/d31k/s $DIR/d31k/exist && error "mlink to exist file"
1782 mlink $DIR/d31k/s $DIR/d31k/s && error "mlink to the same file"
1783 mlink $DIR/d31k/s $DIR/d31k && error "mlink to parent dir"
1784 mlink $DIR/d31k $DIR/d31k/s && error "mlink parent dir to target"
1785 mlink $DIR/d31k/not-exist $DIR/d31k/foo && error "mlink non-existing to new"
1786 mlink $DIR/d31k/not-exist $DIR/d31k/s && error "mlink non-existing to exist"
1789 run_test 31k "link to file: the same, non-existing, dir==============="
1795 touch $DIR/d31m2/exist
1796 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
1797 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
1798 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
1799 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
1800 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
1801 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
1804 run_test 31m "link to file: the same, non-existing, dir==============="
1806 cleanup_test32_mount() {
1808 $UMOUNT $DIR/$tdir/ext2-mountpoint
1812 echo "== more mountpoints and symlinks ================="
1813 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
1814 trap cleanup_test32_mount EXIT
1815 mkdir -p $DIR/$tdir/ext2-mountpoint
1816 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
1817 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. || error
1818 cleanup_test32_mount
1820 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
1823 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
1824 trap cleanup_test32_mount EXIT
1825 mkdir -p $DIR/$tdir/ext2-mountpoint
1826 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
1827 ls -al $DIR/$tdir/ext2-mountpoint/.. || error
1828 cleanup_test32_mount
1830 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
1833 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
1834 trap cleanup_test32_mount EXIT
1835 mkdir -p $DIR/$tdir/ext2-mountpoint
1836 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
1837 mkdir -p $DIR/$tdir/d2/test_dir
1838 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
1839 cleanup_test32_mount
1841 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
1844 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
1845 trap cleanup_test32_mount EXIT
1846 mkdir -p $DIR/$tdir/ext2-mountpoint
1847 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
1848 mkdir -p $DIR/$tdir/d2/test_dir
1849 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
1850 cleanup_test32_mount
1852 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
1855 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
1856 mkdir -p $DIR/d32e/tmp
1857 TMP_DIR=$DIR/d32e/tmp
1858 ln -s $DIR/d32e $TMP_DIR/symlink11
1859 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1860 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
1861 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
1863 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
1866 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
1867 mkdir -p $DIR/d32f/tmp
1868 TMP_DIR=$DIR/d32f/tmp
1869 ln -s $DIR/d32f $TMP_DIR/symlink11
1870 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1871 ls $DIR/d32f/tmp/symlink11 || error
1872 ls $DIR/d32f/symlink01 || error
1874 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
1877 TMP_DIR=$DIR/$tdir/tmp
1878 mkdir -p $TMP_DIR $DIR/${tdir}2
1879 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
1880 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1881 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
1882 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
1883 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
1884 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
1886 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
1889 rm -fr $DIR/$tdir $DIR/${tdir}2
1890 TMP_DIR=$DIR/$tdir/tmp
1891 mkdir -p $TMP_DIR $DIR/${tdir}2
1892 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
1893 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1894 ls $TMP_DIR/symlink12 || error
1895 ls $DIR/$tdir/symlink02 || error
1897 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
1900 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
1901 trap cleanup_test32_mount EXIT
1902 mkdir -p $DIR/$tdir/ext2-mountpoint
1903 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
1904 touch $DIR/$tdir/test_file
1905 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file || error
1906 cleanup_test32_mount
1908 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
1911 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
1912 trap cleanup_test32_mount EXIT
1913 mkdir -p $DIR/$tdir/ext2-mountpoint
1914 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
1915 touch $DIR/$tdir/test_file
1916 cat $DIR/$tdir/ext2-mountpoint/../test_file || error
1917 cleanup_test32_mount
1919 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
1923 trap cleanup_test32_mount EXIT
1924 mkdir -p $DIR/$tdir/ext2-mountpoint
1925 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
1926 mkdir -p $DIR/$tdir/d2
1927 touch $DIR/$tdir/d2/test_file || error
1928 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
1929 cleanup_test32_mount
1931 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
1935 trap cleanup_test32_mount EXIT
1936 mkdir -p $DIR/$tdir/ext2-mountpoint
1937 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
1938 mkdir -p $DIR/$tdir/d2
1939 touch $DIR/$tdir/d2/test_file
1940 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
1941 cleanup_test32_mount
1943 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
1947 mkdir -p $DIR/d32m/tmp
1948 TMP_DIR=$DIR/d32m/tmp
1949 ln -s $DIR $TMP_DIR/symlink11
1950 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1951 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
1952 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
1954 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
1958 mkdir -p $DIR/d32n/tmp
1959 TMP_DIR=$DIR/d32n/tmp
1960 ln -s $DIR $TMP_DIR/symlink11
1961 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1962 ls -l $DIR/d32n/tmp/symlink11 || error
1963 ls -l $DIR/d32n/symlink01 || error
1965 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
1968 rm -fr $DIR/d32o $DIR/$tfile
1970 mkdir -p $DIR/d32o/tmp
1971 TMP_DIR=$DIR/d32o/tmp
1972 ln -s $DIR/$tfile $TMP_DIR/symlink12
1973 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1974 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
1975 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
1976 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
1977 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
1979 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
1989 mkdir -p $DIR/d32p/tmp
1991 TMP_DIR=$DIR/d32p/tmp
1993 ln -s $DIR/$tfile $TMP_DIR/symlink12
1995 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1997 cat $DIR/d32p/tmp/symlink12 || error
1999 cat $DIR/d32p/symlink02 || error
2002 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
2004 cleanup_testdir_mount() {
2010 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2011 trap cleanup_testdir_mount EXIT
2013 touch $DIR/$tdir/under_the_mount
2014 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2015 ls $DIR/$tdir | grep "\<under_the_mount\>" && error
2016 cleanup_testdir_mount
2018 run_test 32q "stat follows mountpoints in Lustre (should return error)"
2021 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2022 trap cleanup_testdir_mount EXIT
2024 touch $DIR/$tdir/under_the_mount
2025 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2026 ls $DIR/$tdir | grep -q under_the_mount && error || true
2027 cleanup_testdir_mount
2029 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
2034 chmod 444 $DIR/$tfile
2035 chown $RUNAS_ID $DIR/$tfile
2037 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2040 run_test 33 "write file with mode 444 (should return error) ===="
2045 chown $RUNAS_ID $DIR/d33
2046 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
2047 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
2048 error "open RDWR" || true
2050 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
2055 chown $RUNAS_ID $DIR/d33
2056 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33 && error "create" || true
2058 run_test 33b "test open file with malformed flags (No panic and return error)"
2066 remote_ost_nodsh && skip "remote OST with nodsh" && return
2070 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2073 for ostnum in $(seq $OSTCOUNT); do
2074 # test-framework's OST numbering is one-based, while Lustre's
2076 ostname=$(printf "$FSNAME-OST%.4d" $((ostnum - 1)))
2077 # Parsing llobdstat's output sucks; we could grep the /proc
2078 # path, but that's likely to not be as portable as using the
2079 # llobdstat utility. So we parse lctl output instead.
2080 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2081 obdfilter/$ostname/stats |
2082 awk '/^write_bytes/ {print $7}' )
2083 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2084 if (( ${write_bytes:-0} > 0 ))
2091 $all_zeros || return 0
2094 echo foo > $DIR/d33/bar
2098 # Total up write_bytes after writing. We'd better find non-zeros.
2099 for ostnum in $(seq $OSTCOUNT); do
2100 ostname=$(printf "$FSNAME-OST%.4d" $((ostnum - 1)))
2101 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2102 obdfilter/$ostname/stats |
2103 awk '/^write_bytes/ {print $7}' )
2104 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2105 if (( ${write_bytes:-0} > 0 ))
2114 for ostnum in $(seq $OSTCOUNT); do
2115 ostname=$(printf "$FSNAME-OST%.4d" $((ostnum - 1)))
2116 echo "Check that write_bytes is present in obdfilter/*/stats:"
2117 do_facet ost$ostnum lctl get_param -n \
2118 obdfilter/$ostname/stats
2120 error "OST not keeping write_bytes stats (b22312)"
2123 run_test 33c "test llobdstat and write_bytes"
2125 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
2128 $MCREATE $DIR/f34 || error
2129 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2130 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
2131 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2132 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2134 run_test 34a "truncate file that has not been opened ==========="
2137 [ ! -f $DIR/f34 ] && test_34a
2138 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2139 $OPENFILE -f O_RDONLY $DIR/f34
2140 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2141 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2143 run_test 34b "O_RDONLY opening file doesn't create objects ====="
2146 [ ! -f $DIR/f34 ] && test_34a
2147 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2148 $OPENFILE -f O_RDWR $DIR/f34
2149 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2150 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2152 run_test 34c "O_RDWR opening file-with-size works =============="
2155 [ ! -f $DIR/f34 ] && test_34a
2156 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2157 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2160 run_test 34d "write to sparse file ============================="
2164 $MCREATE $DIR/f34e || error
2165 $TRUNCATE $DIR/f34e 1000 || error
2166 $CHECKSTAT -s 1000 $DIR/f34e || error
2167 $OPENFILE -f O_RDWR $DIR/f34e
2168 $CHECKSTAT -s 1000 $DIR/f34e || error
2170 run_test 34e "create objects, some with size and some without =="
2172 test_34f() { # bug 6242, 6243
2175 $MCREATE $DIR/f34f || error
2176 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
2177 dd if=$DIR/f34f of=$TMP/f34f
2178 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
2179 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
2180 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
2181 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
2182 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
2184 run_test 34f "read from a file with no objects until EOF ======="
2187 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
2188 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
2189 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
2190 cancel_lru_locks osc
2191 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
2192 error "wrong size after lock cancel"
2194 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
2195 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2196 error "expanding truncate failed"
2197 cancel_lru_locks osc
2198 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2199 error "wrong expanded size after lock cancel"
2201 run_test 34g "truncate long file ==============================="
2207 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
2208 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
2212 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
2213 error "Multiop blocked on ftruncate, pid=$MULTIPID"
2217 local nsz=`stat -c %s $DIR/$tfile`
2218 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
2220 run_test 34h "ftruncate file under grouplock should not block"
2223 cp /bin/sh $DIR/f35a
2225 chown $RUNAS_ID $DIR/f35a
2226 $RUNAS $DIR/f35a && error || true
2229 run_test 35a "exec file with mode 444 (should return and not leak) ====="
2233 utime $DIR/f36 || error
2235 run_test 36a "MDS utime check (mknod, utime) ==================="
2239 utime $DIR/f36 || error
2241 run_test 36b "OST utime check (open, utime) ===================="
2246 chown $RUNAS_ID $DIR/d36
2247 $RUNAS utime $DIR/d36/f36 || error
2249 run_test 36c "non-root MDS utime check (mknod, utime) =========="
2252 [ ! -d $DIR/d36 ] && test_36c
2253 echo "" > $DIR/d36/f36
2254 $RUNAS utime $DIR/d36/f36 || error
2256 run_test 36d "non-root OST utime check (open, utime) ==========="
2259 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
2261 touch $DIR/$tdir/$tfile
2262 $RUNAS utime $DIR/$tdir/$tfile && \
2263 error "utime worked, expected failure" || true
2265 run_test 36e "utime on non-owned file (should return error) ===="
2269 local LANG_SAVE=$LANG
2270 local LC_LANG_SAVE=$LC_LANG
2271 export LANG=C LC_LANG=C # for date language
2273 DATESTR="Dec 20 2000"
2275 lctl set_param fail_loc=$fl
2277 cp /etc/hosts $DIR/$tdir/$tfile
2278 sync & # write RPC generated with "current" inode timestamp, but delayed
2280 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
2281 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
2282 cancel_lru_locks osc
2283 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
2285 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
2286 echo "BEFORE: $LS_BEFORE" && \
2287 echo "AFTER : $LS_AFTER" && \
2288 echo "WANT : $DATESTR" && \
2289 error "$DIR/$tdir/$tfile timestamps changed" || true
2291 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
2295 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2296 subr_36fh "0x80000214"
2298 run_test 36f "utime on file racing with OST BRW write =========="
2301 remote_ost_nodsh && skip "remote OST with nodsh" && return
2307 fmd_max_age=$(do_facet ost1 \
2308 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
2311 fmd_before=$(do_facet ost1 \
2312 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2313 touch $DIR/$tdir/$tfile
2314 sleep $((fmd_max_age + 12))
2315 fmd_after=$(do_facet ost1 \
2316 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2318 echo "fmd_before: $fmd_before"
2319 echo "fmd_after: $fmd_after"
2320 [ "$fmd_after" -gt "$fmd_before" ] && \
2321 echo "AFTER: $fmd_after > BEFORE: $fmd_before" && \
2322 error "fmd didn't expire after ping" || true
2324 run_test 36g "filter mod data cache expiry ====================="
2327 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
2328 subr_36fh "0x80000227"
2330 run_test 36h "utime on file racing with OST BRW write =========="
2332 # test_37 - duplicate with tests 32q 32r
2335 local file=$DIR/$tfile
2337 openfile -f O_DIRECTORY $file
2340 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
2341 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
2343 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
2347 touch $DIR/${tfile}2
2348 # ls -l $DIR/$tfile $DIR/${tfile}2
2349 # ls -lu $DIR/$tfile $DIR/${tfile}2
2350 # ls -lc $DIR/$tfile $DIR/${tfile}2
2352 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
2353 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
2355 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
2357 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
2359 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
2360 error "O_TRUNC didn't change timestamps"
2363 run_test 39 "mtime changed on create ==========================="
2367 cp -p /etc/passwd $DIR/$tdir/fopen
2368 cp -p /etc/passwd $DIR/$tdir/flink
2369 cp -p /etc/passwd $DIR/$tdir/funlink
2370 cp -p /etc/passwd $DIR/$tdir/frename
2371 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
2374 echo "aaaaaa" >> $DIR/$tdir/fopen
2375 echo "aaaaaa" >> $DIR/$tdir/flink
2376 echo "aaaaaa" >> $DIR/$tdir/funlink
2377 echo "aaaaaa" >> $DIR/$tdir/frename
2379 local open_new=`stat -c %Y $DIR/$tdir/fopen`
2380 local link_new=`stat -c %Y $DIR/$tdir/flink`
2381 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
2382 local rename_new=`stat -c %Y $DIR/$tdir/frename`
2384 cat $DIR/$tdir/fopen > /dev/null
2385 ln $DIR/$tdir/flink $DIR/$tdir/flink2
2386 rm -f $DIR/$tdir/funlink2
2387 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
2389 for (( i=0; i < 2; i++ )) ; do
2390 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
2391 local link_new2=`stat -c %Y $DIR/$tdir/flink`
2392 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
2393 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
2395 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
2396 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
2397 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
2398 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
2400 cancel_lru_locks osc
2401 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2404 run_test 39b "mtime change on open, link, unlink, rename ======"
2406 # this should be set to past
2407 TEST_39_MTIME=`date -d "1 year ago" +%s`
2413 local mtime0=`stat -c %Y $DIR1/$tfile`
2415 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2416 local mtime1=`stat -c %Y $DIR1/$tfile`
2417 [ "$mtime1" = $TEST_39_MTIME ] || \
2418 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
2421 echo hello >> $DIR1/$tfile
2423 local mtime2=`stat -c %Y $DIR1/$tfile`
2424 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
2425 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
2427 mv $DIR1/$tfile $DIR1/$tfile-1
2429 for (( i=0; i < 2; i++ )) ; do
2430 local mtime3=`stat -c %Y $DIR1/$tfile-1`
2431 [ "$mtime2" = "$mtime3" ] || \
2432 error "mtime ($mtime2) changed (to $mtime3) on rename"
2434 cancel_lru_locks osc
2435 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2438 run_test 39c "mtime change on rename ==========================="
2444 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2446 for (( i=0; i < 2; i++ )) ; do
2447 local mtime=`stat -c %Y $DIR1/$tfile`
2448 [ $mtime = $TEST_39_MTIME ] || \
2449 error "mtime($mtime) is not set to $TEST_39_MTIME"
2451 cancel_lru_locks osc
2452 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2455 run_test 39d "create, utime, stat =============================="
2460 local mtime1=`stat -c %Y $DIR1/$tfile`
2462 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2464 for (( i=0; i < 2; i++ )) ; do
2465 local mtime2=`stat -c %Y $DIR1/$tfile`
2466 [ $mtime2 = $TEST_39_MTIME ] || \
2467 error "mtime($mtime2) is not set to $TEST_39_MTIME"
2469 cancel_lru_locks osc
2470 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2473 run_test 39e "create, stat, utime, stat ========================"
2478 mtime1=`stat -c %Y $DIR1/$tfile`
2481 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2483 for (( i=0; i < 2; i++ )) ; do
2484 local mtime2=`stat -c %Y $DIR1/$tfile`
2485 [ $mtime2 = $TEST_39_MTIME ] || \
2486 error "mtime($mtime2) is not set to $TEST_39_MTIME"
2488 cancel_lru_locks osc
2489 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2492 run_test 39f "create, stat, sleep, utime, stat ================="
2496 echo hello >> $DIR1/$tfile
2497 local mtime1=`stat -c %Y $DIR1/$tfile`
2500 chmod o+r $DIR1/$tfile
2502 for (( i=0; i < 2; i++ )) ; do
2503 local mtime2=`stat -c %Y $DIR1/$tfile`
2504 [ "$mtime1" = "$mtime2" ] || \
2505 error "lost mtime: $mtime2, should be $mtime1"
2507 cancel_lru_locks osc
2508 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2511 run_test 39g "write, chmod, stat ==============================="
2519 echo hello >> $DIR1/$tfile
2520 local mtime1=`stat -c %Y $DIR1/$tfile`
2522 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2524 if [ "$d1" != "$d2" ]; then
2525 echo "write and touch not within one second"
2527 for (( i=0; i < 2; i++ )) ; do
2528 local mtime2=`stat -c %Y $DIR1/$tfile`
2529 [ "$mtime2" = $TEST_39_MTIME ] || \
2530 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
2532 cancel_lru_locks osc
2533 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2537 run_test 39h "write, utime within one second, stat ============="
2543 echo hello >> $DIR1/$tfile
2544 local mtime1=`stat -c %Y $DIR1/$tfile`
2546 mv $DIR1/$tfile $DIR1/$tfile-1
2548 for (( i=0; i < 2; i++ )) ; do
2549 local mtime2=`stat -c %Y $DIR1/$tfile-1`
2551 [ "$mtime1" = "$mtime2" ] || \
2552 error "lost mtime: $mtime2, should be $mtime1"
2554 cancel_lru_locks osc
2555 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2558 run_test 39i "write, rename, stat =============================="
2561 start_full_debug_logging
2565 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
2566 lctl set_param fail_loc=0x80000412
2567 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
2568 error "multiop failed"
2570 local mtime1=`stat -c %Y $DIR1/$tfile`
2572 mv $DIR1/$tfile $DIR1/$tfile-1
2574 kill -USR1 $multipid
2575 wait $multipid || error "multiop close failed"
2577 for (( i=0; i < 2; i++ )) ; do
2578 local mtime2=`stat -c %Y $DIR1/$tfile-1`
2579 [ "$mtime1" = "$mtime2" ] ||
2580 error "mtime is lost on close: $mtime2, " \
2583 cancel_lru_locks osc
2584 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2586 lctl set_param fail_loc=0
2587 stop_full_debug_logging
2589 run_test 39j "write, rename, close, stat ======================="
2595 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
2597 local mtime1=`stat -c %Y $DIR1/$tfile`
2599 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2601 kill -USR1 $multipid
2602 wait $multipid || error "multiop close failed"
2604 for (( i=0; i < 2; i++ )) ; do
2605 local mtime2=`stat -c %Y $DIR1/$tfile`
2607 [ "$mtime2" = $TEST_39_MTIME ] || \
2608 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
2610 cancel_lru_locks osc
2611 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2614 run_test 39k "write, utime, close, stat ========================"
2616 # this should be set to future
2617 TEST_39_ATIME=`date -d "1 year" +%s`
2620 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2621 local atime_diff=$(do_facet $SINGLEMDS \
2622 lctl get_param -n mdd.*MDT0000*.atime_diff)
2625 # test setting directory atime to future
2626 touch -a -d @$TEST_39_ATIME $DIR/$tdir
2627 local atime=$(stat -c %X $DIR/$tdir)
2628 [ "$atime" = $TEST_39_ATIME ] || \
2629 error "atime is not set to future: $atime, $TEST_39_ATIME"
2631 # test setting directory atime from future to now
2632 local d1=$(date +%s)
2634 local d2=$(date +%s)
2636 cancel_lru_locks mdc
2637 atime=$(stat -c %X $DIR/$tdir)
2638 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
2639 error "atime is not updated from future: $atime, $d1<atime<$d2"
2641 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
2644 # test setting directory atime when now > dir atime + atime_diff
2648 cancel_lru_locks mdc
2649 atime=$(stat -c %X $DIR/$tdir)
2650 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
2651 error "atime is not updated : $atime, should be $d2"
2653 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
2656 # test not setting directory atime when now < dir atime + atime_diff
2658 cancel_lru_locks mdc
2659 atime=$(stat -c %X $DIR/$tdir)
2660 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
2661 error "atime is updated to $atime, should remain $d1<atime<$d2"
2663 do_facet $SINGLEMDS \
2664 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
2666 run_test 39l "directory atime update ==========================="
2671 local far_past_mtime=$(date -d "May 29 1953" +%s)
2672 local far_past_atime=$(date -d "Dec 17 1903" +%s)
2674 touch -m -d @$far_past_mtime $DIR1/$tfile
2675 touch -a -d @$far_past_atime $DIR1/$tfile
2677 for (( i=0; i < 2; i++ )) ; do
2678 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
2679 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
2680 error "atime or mtime set incorrectly"
2682 cancel_lru_locks osc
2683 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2686 run_test 39m "test atime and mtime before 1970"
2689 dd if=/dev/zero of=$DIR/f40 bs=4096 count=1
2690 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/f40 && error
2691 $CHECKSTAT -t file -s 4096 $DIR/f40 || error
2693 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
2697 small_write $DIR/f41 18
2699 run_test 41 "test small file write + fstat ====================="
2701 count_ost_writes() {
2702 lctl get_param -n osc.*.stats |
2703 awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }'
2710 BG_DIRTY_RATIO_SAVE=10
2711 MAX_BG_DIRTY_RATIO=25
2715 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
2716 # dirty_ratio, dirty_background_ratio
2717 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
2718 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
2719 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
2720 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
2722 # if file not here, we are a 2.4 kernel
2723 kill -CONT `pidof kupdated`
2728 # setup the trap first, so someone cannot exit the test at the
2729 # exact wrong time and mess up a machine
2730 trap start_writeback EXIT
2731 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
2732 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
2733 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
2734 sysctl -w vm.dirty_writeback_centisecs=0
2735 sysctl -w vm.dirty_writeback_centisecs=0
2736 # save and increase /proc/sys/vm/dirty_ratio
2737 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
2738 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
2739 # save and increase /proc/sys/vm/dirty_background_ratio
2740 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
2741 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
2743 # if file not here, we are a 2.4 kernel
2744 kill -STOP `pidof kupdated`
2748 # ensure that all stripes have some grant before we test client-side cache
2750 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
2751 dd if=/dev/zero of=$i bs=4k count=1
2756 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
2757 # file truncation, and file removal.
2760 cancel_lru_locks osc
2762 sync; sleep 1; sync # just to be safe
2763 BEFOREWRITES=`count_ost_writes`
2764 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
2765 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
2766 AFTERWRITES=`count_ost_writes`
2767 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
2768 error "$BEFOREWRITES < $AFTERWRITES"
2771 run_test 42a "ensure that we don't flush on close =============="
2775 cancel_lru_locks osc
2778 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
2779 BEFOREWRITES=`count_ost_writes`
2780 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
2781 AFTERWRITES=`count_ost_writes`
2782 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
2783 error "$BEFOREWRITES < $AFTERWRITES on unlink"
2785 BEFOREWRITES=`count_ost_writes`
2786 sync || error "sync: $?"
2787 AFTERWRITES=`count_ost_writes`
2788 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
2789 error "$BEFOREWRITES < $AFTERWRITES on sync"
2791 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
2795 run_test 42b "test destroy of file with cached dirty data ======"
2797 # if these tests just want to test the effect of truncation,
2798 # they have to be very careful. consider:
2799 # - the first open gets a {0,EOF}PR lock
2800 # - the first write conflicts and gets a {0, count-1}PW
2801 # - the rest of the writes are under {count,EOF}PW
2802 # - the open for truncate tries to match a {0,EOF}PR
2803 # for the filesize and cancels the PWs.
2804 # any number of fixes (don't get {0,EOF} on open, match
2805 # composite locks, do smarter file size management) fix
2806 # this, but for now we want these tests to verify that
2807 # the cancellation with truncate intent works, so we
2808 # start the file with a full-file pw lock to match against
2809 # until the truncate.
2814 cancel_lru_locks osc
2816 # prime the file with 0,EOF PW to match
2820 # now the real test..
2821 dd if=/dev/zero of=$file bs=1024 count=100
2822 BEFOREWRITES=`count_ost_writes`
2823 $TRUNCATE $file $offset
2824 cancel_lru_locks osc
2825 AFTERWRITES=`count_ost_writes`
2831 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
2832 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
2835 run_test 42c "test partial truncate of file with cached dirty data"
2839 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
2840 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
2843 run_test 42d "test complete truncate of file with cached dirty data"
2845 test_42e() { # bug22074
2846 local TDIR=$DIR/${tdir}e
2847 local pagesz=$(page_size)
2848 local pages=16 # hardcoded 16 pages, don't change it.
2849 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
2850 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
2855 $SETSTRIPE -c 1 $TDIR
2856 createmany -o $TDIR/f $files
2858 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
2860 # we assume that with $OSTCOUNT files, at least one of them will
2861 # be allocated on OST0.
2862 warmup_files=$((OSTCOUNT * max_dirty_mb))
2863 createmany -o $TDIR/w $warmup_files
2865 # write a large amount of data into one file and sync, to get good
2866 # avail_grant number from OST.
2867 for ((i=0; i<$warmup_files; i++)); do
2868 idx=$($GETSTRIPE -i $TDIR/w$i)
2869 [ $idx -ne 0 ] && continue
2870 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
2873 [ $i -gt $warmup_files ] && error "OST0 is still cold"
2875 $LCTL get_param $proc_osc0/cur_dirty_bytes
2876 $LCTL get_param $proc_osc0/cur_grant_bytes
2878 # create as much dirty pages as we can while not to trigger the actual
2879 # RPCs directly. but depends on the env, VFS may trigger flush during this
2880 # period, hopefully we are good.
2881 for ((i=0; i<$warmup_files; i++)); do
2882 idx=$($GETSTRIPE -i $TDIR/w$i)
2883 [ $idx -ne 0 ] && continue
2884 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
2886 $LCTL get_param $proc_osc0/cur_dirty_bytes
2887 $LCTL get_param $proc_osc0/cur_grant_bytes
2889 # perform the real test
2890 $LCTL set_param $proc_osc0/rpc_stats 0
2891 for ((;i<$files; i++)); do
2892 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
2893 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
2896 $LCTL get_param $proc_osc0/rpc_stats
2899 local have_ppr=false
2900 $LCTL get_param $proc_osc0/rpc_stats |
2901 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
2902 # skip lines until we are at the RPC histogram data
2903 [ "$PPR" == "pages" ] && have_ppr=true && continue
2904 $have_ppr || continue
2906 # we only want the percent stat for < 16 pages
2907 [ $(echo $PPR | tr -d ':') -ge $pages ] && break
2909 percent=$((percent + WPCT))
2910 if [ $percent -gt 15 ]; then
2911 error "less than 16-pages write RPCs" \
2918 run_test 42e "verify sub-RPC writes are not done synchronously"
2922 cp -p /bin/ls $DIR/$tdir/$tfile
2923 $MULTIOP $DIR/$tdir/$tfile Ow_c &
2925 # give multiop a chance to open
2928 $DIR/$tdir/$tfile && error || true
2931 run_test 43 "execution of file opened for write should return -ETXTBSY"
2935 cp -p `which $MULTIOP` $DIR/d43/multiop || cp -p multiop $DIR/d43/multiop
2936 MULTIOP_PROG=$DIR/d43/multiop multiop_bg_pause $TMP/test43.junk O_c || return 1
2938 $MULTIOP $DIR/d43/multiop Oc && error "expected error, got success"
2939 kill -USR1 $MULTIOP_PID || return 2
2940 wait $MULTIOP_PID || return 3
2943 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
2947 cp -p `which $MULTIOP` $DIR/d43/multiop || cp -p multiop $DIR/d43/multiop
2948 MULTIOP_PROG=$DIR/d43/multiop multiop_bg_pause $TMP/test43.junk O_c || return 1
2950 $TRUNCATE $DIR/d43/multiop 0 && error "expected error, got success"
2951 kill -USR1 $MULTIOP_PID || return 2
2952 wait $MULTIOP_PID || return 3
2955 run_test 43b "truncate of file being executed should return -ETXTBSY"
2958 local testdir="$DIR/d43c"
2961 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
2962 ( cd $testdir && md5sum -c)
2964 run_test 43c "md5sum of copy into lustre========================"
2967 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
2968 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
2969 dd if=$DIR/f1 bs=4k count=1 > /dev/null
2971 run_test 44 "zero length read from a sparse stripe ============="
2974 local nstripe=`$LCTL lov_getconfig $DIR | grep default_stripe_count: | \
2976 [ -z "$nstripe" ] && skip "can't get stripe info" && return
2977 [ "$nstripe" -gt "$OSTCOUNT" ] && skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" && return
2978 local stride=`$LCTL lov_getconfig $DIR | grep default_stripe_size: | \
2980 if [ $nstripe -eq 0 -o $nstripe -eq -1 ] ; then
2981 nstripe=`$LCTL lov_getconfig $DIR | grep obd_count: | awk '{print $2}'`
2984 OFFSETS="0 $((stride/2)) $((stride-1))"
2985 for offset in $OFFSETS ; do
2986 for i in `seq 0 $((nstripe-1))`; do
2987 local GLOBALOFFSETS=""
2988 local size=$((((i + 2 * $nstripe )*$stride + $offset))) # Bytes
2989 local myfn=$DIR/d44a-$size
2990 echo "--------writing $myfn at $size"
2991 ll_sparseness_write $myfn $size || error "ll_sparseness_write"
2992 GLOBALOFFSETS="$GLOBALOFFSETS $size"
2993 ll_sparseness_verify $myfn $GLOBALOFFSETS \
2994 || error "ll_sparseness_verify $GLOBALOFFSETS"
2996 for j in `seq 0 $((nstripe-1))`; do
2997 size=$((((j + $nstripe )*$stride + $offset))) # Bytes
2998 ll_sparseness_write $myfn $size || error "ll_sparseness_write"
2999 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3001 ll_sparseness_verify $myfn $GLOBALOFFSETS \
3002 || error "ll_sparseness_verify $GLOBALOFFSETS"
3007 run_test 44a "test sparse pwrite ==============================="
3011 for d in `lctl get_param -n osc.*.cur_dirty_bytes`; do
3017 before=`dirty_osc_total`
3018 echo executing "\"$*\""
3020 after=`dirty_osc_total`
3021 echo before $before, after $after
3025 # Obtain grants from OST if it supports it
3026 echo blah > ${f}_grant
3029 do_dirty_record "echo blah > $f"
3030 [ $before -eq $after ] && error "write wasn't cached"
3031 do_dirty_record "> $f"
3032 [ $before -gt $after ] || error "truncate didn't lower dirty count"
3033 do_dirty_record "echo blah > $f"
3034 [ $before -eq $after ] && error "write wasn't cached"
3035 do_dirty_record "sync"
3036 [ $before -gt $after ] || error "writeback didn't lower dirty count"
3037 do_dirty_record "echo blah > $f"
3038 [ $before -eq $after ] && error "write wasn't cached"
3039 do_dirty_record "cancel_lru_locks osc"
3040 [ $before -gt $after ] || error "lock cancellation didn't lower dirty count"
3043 run_test 45 "osc io page accounting ============================"
3045 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
3046 # test tickles a bug where re-dirtying a page was failing to be mapped to the
3047 # objects offset and an assert hit when an rpc was built with 1023's mapped
3048 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
3053 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3055 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
3056 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3060 run_test 46 "dirtying a previously written page ================"
3062 # test_47 is removed "Device nodes check" is moved to test_28
3064 test_48a() { # bug 2399
3065 check_kernel_version 34 || return 0
3068 mv $DIR/d48a $DIR/d48.new || error "move directory failed"
3069 mkdir $DIR/d48a || error "recreate directory failed"
3070 touch foo || error "'touch foo' failed after recreating cwd"
3071 mkdir bar || error "'mkdir foo' failed after recreating cwd"
3072 if check_kernel_version 44; then
3073 touch .foo || error "'touch .foo' failed after recreating cwd"
3074 mkdir .bar || error "'mkdir .foo' failed after recreating cwd"
3076 ls . > /dev/null || error "'ls .' failed after recreating cwd"
3077 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3078 cd . || error "'cd .' failed after recreating cwd"
3079 mkdir . && error "'mkdir .' worked after recreating cwd"
3080 rmdir . && error "'rmdir .' worked after recreating cwd"
3081 ln -s . baz || error "'ln -s .' failed after recreating cwd"
3082 cd .. || error "'cd ..' failed after recreating cwd"
3084 run_test 48a "Access renamed working dir (should return errors)="
3086 test_48b() { # bug 2399
3087 check_kernel_version 34 || return 0
3090 rmdir $DIR/d48b || error "remove cwd $DIR/d48b failed"
3091 touch foo && error "'touch foo' worked after removing cwd"
3092 mkdir foo && error "'mkdir foo' worked after removing cwd"
3093 if check_kernel_version 44; then
3094 touch .foo && error "'touch .foo' worked after removing cwd"
3095 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
3097 ls . > /dev/null && error "'ls .' worked after removing cwd"
3098 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3099 is_patchless || ( cd . && error "'cd .' worked after removing cwd" )
3100 mkdir . && error "'mkdir .' worked after removing cwd"
3101 rmdir . && error "'rmdir .' worked after removing cwd"
3102 ln -s . foo && error "'ln -s .' worked after removing cwd"
3103 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
3105 run_test 48b "Access removed working dir (should return errors)="
3107 test_48c() { # bug 2350
3108 check_kernel_version 36 || return 0
3109 #lctl set_param debug=-1
3111 mkdir -p $DIR/d48c/dir
3113 $TRACE rmdir $DIR/d48c/dir || error "remove cwd $DIR/d48c/dir failed"
3114 $TRACE touch foo && error "'touch foo' worked after removing cwd"
3115 $TRACE mkdir foo && error "'mkdir foo' worked after removing cwd"
3116 if check_kernel_version 44; then
3117 touch .foo && error "'touch .foo' worked after removing cwd"
3118 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
3120 $TRACE ls . && error "'ls .' worked after removing cwd"
3121 $TRACE ls .. || error "'ls ..' failed after removing cwd"
3122 is_patchless || ( $TRACE cd . && error "'cd .' worked after removing cwd" )
3123 $TRACE mkdir . && error "'mkdir .' worked after removing cwd"
3124 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
3125 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
3126 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
3128 run_test 48c "Access removed working subdir (should return errors)"
3130 test_48d() { # bug 2350
3131 check_kernel_version 36 || return 0
3132 #lctl set_param debug=-1
3134 mkdir -p $DIR/d48d/dir
3136 $TRACE rmdir $DIR/d48d/dir || error "remove cwd $DIR/d48d/dir failed"
3137 $TRACE rmdir $DIR/d48d || error "remove parent $DIR/d48d failed"
3138 $TRACE touch foo && error "'touch foo' worked after removing parent"
3139 $TRACE mkdir foo && error "'mkdir foo' worked after removing parent"
3140 if check_kernel_version 44; then
3141 touch .foo && error "'touch .foo' worked after removing parent"
3142 mkdir .foo && error "'mkdir .foo' worked after removing parent"
3144 $TRACE ls . && error "'ls .' worked after removing parent"
3145 $TRACE ls .. && error "'ls ..' worked after removing parent"
3146 is_patchless || ( $TRACE cd . && error "'cd .' worked after recreate parent" )
3147 $TRACE mkdir . && error "'mkdir .' worked after removing parent"
3148 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
3149 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
3150 is_patchless || ( $TRACE cd .. && error "'cd ..' worked after removing parent" || true )
3152 run_test 48d "Access removed parent subdir (should return errors)"
3154 test_48e() { # bug 4134
3155 check_kernel_version 41 || return 0
3156 #lctl set_param debug=-1
3158 mkdir -p $DIR/d48e/dir
3160 $TRACE rmdir $DIR/d48e/dir || error "remove cwd $DIR/d48e/dir failed"
3161 $TRACE rmdir $DIR/d48e || error "remove parent $DIR/d48e failed"
3162 $TRACE touch $DIR/d48e || error "'touch $DIR/d48e' failed"
3163 $TRACE chmod +x $DIR/d48e || error "'chmod +x $DIR/d48e' failed"
3164 # On a buggy kernel addition of "touch foo" after cd .. will
3165 # produce kernel oops in lookup_hash_it
3166 touch ../foo && error "'cd ..' worked after recreate parent"
3168 $TRACE rm $DIR/d48e || error "rm '$DIR/d48e' failed"
3170 run_test 48e "Access to recreated parent subdir (should return errors)"
3172 test_49() { # LU-1030
3173 # get ost1 size - lustre-OST0000
3174 ost1_size=$(do_facet ost1 lfs df |grep ${ost1_svc} |awk '{print $4}')
3175 # write 800M at maximum
3176 [ $ost1_size -gt 819200 ] && ost1_size=819200
3178 lfs setstripe -c 1 -i 0 $DIR/$tfile
3179 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
3182 # change max_pages_per_rpc while writing the file
3183 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
3184 local orig_mppc=`$LCTL get_param -n $osc1_mppc`
3185 # loop until dd process exits
3186 while ps ax -opid | grep -wq $dd_pid; do
3187 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
3188 sleep $((RANDOM % 5 + 1))
3190 # restore original max_pages_per_rpc
3191 $LCTL set_param $osc1_mppc=$orig_mppc
3192 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
3194 run_test 49 "Change max_pages_per_rpc won't break osc extent"
3200 ls /proc/$$/cwd || error
3202 run_test 50 "special situations: /proc symlinks ==============="
3204 test_51a() { # was test_51
3205 # bug 1516 - create an empty entry right after ".." then split dir
3208 $MCREATE $DIR/d51/bar
3210 createmany -m $DIR/d51/longfile 201
3212 while [ `ls -sd $DIR/d51 | awk '{ print $1 }'` -eq 4 ]; do
3213 $MCREATE $DIR/d51/longfile$FNUM
3218 ls -l $DIR/d51 > /dev/null || error
3220 run_test 51a "special situations: split htree with empty entry =="
3222 export NUMTEST=70000
3224 local BASE=$DIR/$tdir
3227 local mdtidx=$(printf "%04x" $($LFS getstripe -M $BASE))
3228 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
3229 [ $numfree -lt 21000 ] && skip "not enough free inodes ($numfree)" &&
3232 [ $numfree -lt $NUMTEST ] && NUMTEST=$(($numfree - 50)) &&
3233 echo "reduced count to $NUMTEST due to inodes"
3235 # need to check free space for the directories as well
3236 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
3237 numfree=$((blkfree / 4))
3238 [ $numfree -lt $NUMTEST ] && NUMTEST=$(($numfree - 50)) &&
3239 echo "reduced count to $NUMTEST due to blocks"
3241 createmany -d $BASE/d $NUMTEST && echo $NUMTEST > $BASE/fnum ||
3242 echo "failed" > $BASE/fnum
3244 run_test 51b "exceed 64k subdirectory nlink limit"
3246 test_51ba() { # LU-993
3247 local BASE=$DIR/$tdir
3248 # unlink all but 100 subdirectories, then check it still works
3250 [ -f $BASE/fnum ] && local NUMPREV=$(cat $BASE/fnum) && rm $BASE/fnum
3252 [ "$NUMPREV" != "failed" ] && NUMTEST=$NUMPREV
3253 local DELETE=$((NUMTEST - LEFT))
3255 # continue on to run this test even if 51b didn't finish,
3256 # just to delete the many subdirectories created.
3257 [ ! -d "${BASE}/d1" ] && skip "test_51b() not run" && return 0
3259 # for ldiskfs the nlink count should be 1, but this is OSD specific
3260 # and so this is listed for informational purposes only
3261 echo "nlink before: $(stat -c %h $BASE), created before: $NUMTEST"
3262 unlinkmany -d $BASE/d $DELETE
3265 if [ $RC -ne 0 ]; then
3266 if [ "$NUMPREV" == "failed" ]; then
3267 skip "previous setup failed"
3270 error "unlink of first $DELETE subdirs failed"
3275 echo "nlink between: $(stat -c %h $BASE)"
3276 # trim the first line of ls output
3277 local FOUND=$(($(ls -l ${BASE} | wc -l) - 1))
3278 [ $FOUND -ne $LEFT ] &&
3279 error "can't find subdirs: found only $FOUND/$LEFT"
3281 unlinkmany -d $BASE/d $DELETE $LEFT ||
3282 error "unlink of second $LEFT subdirs failed"
3283 # regardless of whether the backing filesystem tracks nlink accurately
3284 # or not, the nlink count shouldn't be more than "." and ".." here
3285 local AFTER=$(stat -c %h $BASE)
3286 [ $AFTER -gt 2 ] && error "nlink after: $AFTER > 2" ||
3287 echo "nlink after: $AFTER"
3289 run_test 51ba "verify nlink for many subdirectory cleanup"
3292 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping test with few OSTs" && return
3294 createmany -o $DIR/d51d/t- 1000
3295 $GETSTRIPE $DIR/d51d > $TMP/files
3296 for N in `seq 0 $((OSTCOUNT - 1))`; do
3297 OBJS[$N]=`awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}' $TMP/files`
3298 OBJS0[$N]=`grep -A 1 idx $TMP/files | awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}'`
3299 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
3301 unlinkmany $DIR/d51d/t- 1000
3304 for N in `seq 1 $((OSTCOUNT - 1))`; do
3305 [ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ] && \
3306 error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
3307 [ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ] && \
3308 error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
3310 [ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ] && \
3311 error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
3312 [ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ] && \
3313 error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
3317 run_test 51d "check object distribution ===================="
3320 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
3323 chattr +a $DIR/d52a/foo || error "chattr +a failed"
3324 echo bar >> $DIR/d52a/foo || error "append bar failed"
3325 cp /etc/hosts $DIR/d52a/foo && error "cp worked"
3326 rm -f $DIR/d52a/foo 2>/dev/null && error "rm worked"
3327 link $DIR/d52a/foo $DIR/d52a/foo_link 2>/dev/null && error "link worked"
3328 echo foo >> $DIR/d52a/foo || error "append foo failed"
3329 mrename $DIR/d52a/foo $DIR/d52a/foo_ren && error "rename worked"
3330 lsattr $DIR/d52a/foo | egrep -q "^-+a[-e]+ $DIR/d52a/foo" || error "lsattr"
3331 chattr -a $DIR/d52a/foo || error "chattr -a failed"
3332 cp -r $DIR/d52a /tmp/
3333 rm -fr $DIR/d52a || error "cleanup rm failed"
3335 run_test 52a "append-only flag test (should return errors) ====="
3338 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
3341 chattr +i $DIR/d52b/foo || error "chattr +i failed"
3342 cat test > $DIR/d52b/foo && error "cat test worked"
3343 cp /etc/hosts $DIR/d52b/foo && error "cp worked"
3344 rm -f $DIR/d52b/foo 2>/dev/null && error "rm worked"
3345 link $DIR/d52b/foo $DIR/d52b/foo_link 2>/dev/null && error "link worked"
3346 echo foo >> $DIR/d52b/foo && error "echo worked"
3347 mrename $DIR/d52b/foo $DIR/d52b/foo_ren && error "rename worked"
3348 [ -f $DIR/d52b/foo ] || error
3349 [ -f $DIR/d52b/foo_ren ] && error
3350 lsattr $DIR/d52b/foo | egrep -q "^-+i[-e]+ $DIR/d52b/foo" || error "lsattr"
3351 chattr -i $DIR/d52b/foo || error "chattr failed"
3353 rm -fr $DIR/d52b || error
3355 run_test 52b "immutable flag test (should return errors) ======="
3358 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3359 remote_ost_nodsh && skip "remote OST with nodsh" && return
3368 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
3369 for value in $(do_facet $SINGLEMDS lctl get_param osc.$mdtosc.prealloc_last_id) ; do
3370 param=`echo ${value[0]} | cut -d "=" -f1`
3371 ostname=`echo $param | cut -d "." -f2 | cut -d - -f 1-2`
3372 mds_last=$(do_facet $SINGLEMDS lctl get_param -n $param)
3373 ostnum=$(echo $ostname | sed "s/${FSNAME}-OST//g" | awk '{print ($1+1)}' )
3374 ost_last=$(do_facet ost$ostnum lctl get_param -n obdfilter.$ostname.last_id | head -n 1)
3375 echo "$ostname.last_id=$ost_last ; MDS.last_id=$mds_last"
3376 if [ $ost_last != $mds_last ]; then
3377 error "$ostname.last_id=$ost_last ; MDS.last_id=$mds_last"
3381 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
3384 [ ! -f "$SOCKETSERVER" ] && skip_env "no socketserver, skipping" && return
3385 [ ! -f "$SOCKETCLIENT" ] && skip_env "no socketclient, skipping" && return
3386 $SOCKETSERVER $DIR/socket
3387 $SOCKETCLIENT $DIR/socket || error
3388 $MUNLINK $DIR/socket
3390 run_test 54a "unix domain socket test =========================="
3396 dd if=/dev/zero of=$f bs=`page_size` count=1
3398 run_test 54b "char device works in lustre ======================"
3401 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
3402 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
3403 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
3405 for i in `seq 3 7`; do
3406 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
3416 loopdev="$DIR/loop54c"
3419 [ -z "$LOOPNUM" ] && echo "couldn't find empty loop device" && return
3420 mknod $loopdev b 7 $LOOPNUM
3421 echo "make a loop file system with $tfile on $loopdev ($LOOPNUM)..."
3422 dd if=/dev/zero of=$tfile bs=`page_size` seek=1024 count=1 > /dev/null
3423 losetup $loopdev $tfile || error "can't set up $loopdev for $tfile"
3424 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
3426 mount -t ext2 $loopdev $tdir || error "error mounting $loopdev on $tdir"
3427 dd if=/dev/zero of=$tdir/tmp bs=`page_size` count=30 || error "dd write"
3429 dd if=$tdir/tmp of=/dev/zero bs=`page_size` count=30 || error "dd read"
3434 run_test 54c "block device works in lustre ====================="
3440 [ "$string" = `echo $string > $f | cat $f` ] || error
3442 run_test 54d "fifo device works in lustre ======================"
3445 check_kernel_version 46 || return 0
3448 cp -aL /dev/console $f
3449 echo $string > $f || error
3451 run_test 54e "console/tty device works in lustre ======================"
3453 #The test_55 used to be iopen test and it was removed by bz#24037.
3454 #run_test 55 "check iopen_connect_dentry() ======================"
3456 test_56a() { # was test_56
3462 NUMFILESx2=$(($NUMFILES * 2))
3463 for i in `seq 1 $NUMFILES` ; do
3464 touch $DIR/d56/file$i
3465 touch $DIR/d56/dir/file$i
3468 # test lfs getstripe with --recursive
3469 FILENUM=`$GETSTRIPE --recursive $DIR/d56 | grep -c obdidx`
3470 [ $FILENUM -eq $NUMFILESx2 ] ||
3471 error "$GETSTRIPE --recursive: found $FILENUM, not $NUMFILESx2"
3472 FILENUM=`$GETSTRIPE $DIR/d56 | grep -c obdidx`
3473 [ $FILENUM -eq $NUMFILES ] ||
3474 error "$GETSTRIPE $DIR/d56: found $FILENUM, not $NUMFILES"
3475 echo "$GETSTRIPE --recursive passed."
3477 # test lfs getstripe with file instead of dir
3478 FILENUM=`$GETSTRIPE $DIR/d56/file1 | grep -c obdidx`
3479 [ $FILENUM -eq 1 ] || error \
3480 "$GETSTRIPE $DIR/d56/file1: found $FILENUM, not 1"
3481 echo "$GETSTRIPE file1 passed."
3483 #test lfs getstripe with --verbose
3484 [ `$GETSTRIPE --verbose $DIR/d56 | grep -c lmm_magic` -eq $NUMFILES ] ||
3485 error "$GETSTRIPE --verbose $DIR/d56: want $NUMFILES lmm_magic"
3486 [ `$GETSTRIPE $DIR/d56 | grep -c lmm_magic` -eq 0 ] ||
3487 error "$GETSTRIPE $DIR/d56: showed lmm_magic"
3488 echo "$GETSTRIPE --verbose passed."
3490 #test lfs getstripe with --obd
3491 $GETSTRIPE --obd wrong_uuid $DIR/d56 2>&1 | grep -q "unknown obduuid" ||
3492 error "$GETSTRIPE --obd wrong_uuid should return error message"
3494 [ "$OSTCOUNT" -lt 2 ] &&
3495 skip_env "skipping other $GETSTRIPE --obd test" && return
3498 OBDUUID=$(ostuuid_from_index $OSTIDX)
3499 FILENUM=`$GETSTRIPE -ir $DIR/d56 | grep -x $OSTIDX | wc -l`
3500 FOUND=`$GETSTRIPE -r --obd $OBDUUID $DIR/d56 | grep obdidx | wc -l`
3501 [ $FOUND -eq $FILENUM ] ||
3502 error "$GETSTRIPE --obd wrong: found $FOUND, expected $FILENUM"
3503 [ `$GETSTRIPE -r -v --obd $OBDUUID $DIR/d56 |
3504 sed '/^[ ]*'${OSTIDX}'[ ]/d' |
3505 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l` -eq 0 ] ||
3506 error "$GETSTRIPE --obd: should not show file on other obd"
3507 echo "$GETSTRIPE --obd passed"
3509 run_test 56a "check $GETSTRIPE"
3514 local LOCAL_NUMFILES="$1"
3515 local LOCAL_NUMDIRS="$2"
3516 local MKDIR_PARAMS="$3"
3518 if [ ! -d "$TDIR" ] ; then
3520 [ "$MKDIR_PARAMS" ] && $SETSTRIPE $MKDIR_PARAMS $TDIR
3521 for i in `seq 1 $LOCAL_NUMFILES` ; do
3524 for i in `seq 1 $LOCAL_NUMDIRS` ; do
3526 for j in `seq 1 $LOCAL_NUMFILES` ; do
3527 touch $TDIR/dir$i/file$j
3533 setup_56_special() {
3537 if [ ! -e "$TDIR/loop1b" ] ; then
3538 for i in `seq 1 $LOCAL_NUMFILES` ; do
3539 mknod $TDIR/loop${i}b b 7 $i
3540 mknod $TDIR/null${i}c c 1 3
3541 ln -s $TDIR/file1 $TDIR/link${i}l
3543 for i in `seq 1 $LOCAL_NUMDIRS` ; do
3544 mknod $TDIR/dir$i/loop${i}b b 7 $i
3545 mknod $TDIR/dir$i/null${i}c c 1 3
3546 ln -s $TDIR/dir$i/file1 $TDIR/dir$i/link${i}l
3555 setup_56 $NUMFILES $NUMDIRS
3557 EXPECTED=$(($NUMDIRS + 2))
3558 # test lfs find with -name
3559 for i in $(seq 1 $NUMFILES) ; do
3560 NUMS=$($LFIND -name "*$i" $TDIR | wc -l)
3561 [ $NUMS -eq $EXPECTED ] ||
3562 error "lfs find -name \"*$i\" $TDIR wrong: "\
3563 "found $NUMS, expected $EXPECTED"
3566 run_test 56g "check lfs find -name ============================="
3572 setup_56 $NUMFILES $NUMDIRS
3574 EXPECTED=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
3575 # test lfs find with ! -name
3576 for i in $(seq 1 $NUMFILES) ; do
3577 NUMS=$($LFIND ! -name "*$i" $TDIR | wc -l)
3578 [ $NUMS -eq $EXPECTED ] ||
3579 error "lfs find ! -name \"*$i\" $TDIR wrong: "\
3580 "found $NUMS, expected $EXPECTED"
3583 run_test 56h "check lfs find ! -name ============================="
3588 UUID=$(ostuuid_from_index 0 $DIR/$tdir)
3589 CMD="$LFIND -ost $UUID $DIR/$tdir"
3591 [ -z "$OUT" ] || error "\"$CMD\" returned directory '$OUT'"
3593 run_test 56i "check 'lfs find -ost UUID' skips directories ======="
3597 setup_56_special $NUMFILES $NUMDIRS
3599 EXPECTED=$((NUMDIRS + 1))
3600 CMD="$LFIND -type d $TDIR"
3601 NUMS=$($CMD | wc -l)
3602 [ $NUMS -eq $EXPECTED ] ||
3603 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3605 run_test 56j "check lfs find -type d ============================="
3609 setup_56_special $NUMFILES $NUMDIRS
3611 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
3612 CMD="$LFIND -type f $TDIR"
3613 NUMS=$($CMD | wc -l)
3614 [ $NUMS -eq $EXPECTED ] ||
3615 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3617 run_test 56k "check lfs find -type f ============================="
3621 setup_56_special $NUMFILES $NUMDIRS
3623 EXPECTED=$((NUMDIRS + NUMFILES))
3624 CMD="$LFIND -type b $TDIR"
3625 NUMS=$($CMD | wc -l)
3626 [ $NUMS -eq $EXPECTED ] ||
3627 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3629 run_test 56l "check lfs find -type b ============================="
3633 setup_56_special $NUMFILES $NUMDIRS
3635 EXPECTED=$((NUMDIRS + NUMFILES))
3636 CMD="$LFIND -type c $TDIR"
3637 NUMS=$($CMD | wc -l)
3638 [ $NUMS -eq $EXPECTED ] ||
3639 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3641 run_test 56m "check lfs find -type c ============================="
3645 setup_56_special $NUMFILES $NUMDIRS
3647 EXPECTED=$((NUMDIRS + NUMFILES))
3648 CMD="$LFIND -type l $TDIR"
3649 NUMS=$($CMD | wc -l)
3650 [ $NUMS -eq $EXPECTED ] ||
3651 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3653 run_test 56n "check lfs find -type l ============================="
3657 setup_56 $NUMFILES $NUMDIRS
3659 utime $TDIR/file1 > /dev/null || error "utime (1)"
3660 utime $TDIR/file2 > /dev/null || error "utime (2)"
3661 utime $TDIR/dir1 > /dev/null || error "utime (3)"
3662 utime $TDIR/dir2 > /dev/null || error "utime (4)"
3663 utime $TDIR/dir1/file1 > /dev/null || error "utime (5)"
3664 dd if=/dev/zero count=1 >> $TDIR/dir1/file1 && sync
3667 NUMS=`$LFIND -mtime +0 $TDIR | wc -l`
3668 [ $NUMS -eq $EXPECTED ] || \
3669 error "lfs find -mtime +0 $TDIR wrong: found $NUMS, expected $EXPECTED"
3672 CMD="$LFIND -mtime 0 $TDIR"
3673 NUMS=$($CMD | wc -l)
3674 [ $NUMS -eq $EXPECTED ] ||
3675 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3677 run_test 56o "check lfs find -mtime for old files =========================="
3680 [ $RUNAS_ID -eq $UID ] &&
3681 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
3684 setup_56 $NUMFILES $NUMDIRS
3686 chown $RUNAS_ID $TDIR/file* || error "chown $DIR/${tdir}g/file$i failed"
3688 CMD="$LFIND -uid $RUNAS_ID $TDIR"
3689 NUMS=$($CMD | wc -l)
3690 [ $NUMS -eq $EXPECTED ] || \
3691 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3693 EXPECTED=$(((NUMFILES + 1) * NUMDIRS + 1))
3694 CMD="$LFIND ! -uid $RUNAS_ID $TDIR"
3695 NUMS=$($CMD | wc -l)
3696 [ $NUMS -eq $EXPECTED ] || \
3697 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3699 run_test 56p "check lfs find -uid and ! -uid ==============================="
3702 [ $RUNAS_ID -eq $UID ] &&
3703 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
3706 setup_56 $NUMFILES $NUMDIRS
3708 chgrp $RUNAS_GID $TDIR/file* || error "chown $TDIR/file$i failed"
3711 CMD="$LFIND -gid $RUNAS_GID $TDIR"
3712 NUMS=$($CMD | wc -l)
3713 [ $NUMS -eq $EXPECTED ] ||
3714 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3716 EXPECTED=$(( ($NUMFILES+1) * $NUMDIRS + 1))
3717 CMD="$LFIND ! -gid $RUNAS_GID $TDIR"
3718 NUMS=$($CMD | wc -l)
3719 [ $NUMS -eq $EXPECTED ] ||
3720 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3722 run_test 56q "check lfs find -gid and ! -gid ==============================="
3726 setup_56 $NUMFILES $NUMDIRS
3729 CMD="$LFIND -size 0 -type f $TDIR"
3730 NUMS=$($CMD | wc -l)
3731 [ $NUMS -eq $EXPECTED ] ||
3732 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3734 CMD="$LFIND ! -size 0 -type f $TDIR"
3735 NUMS=$($CMD | wc -l)
3736 [ $NUMS -eq $EXPECTED ] ||
3737 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3738 echo "test" > $TDIR/$tfile
3739 echo "test2" > $TDIR/$tfile.2 && sync
3741 CMD="$LFIND -size 5 -type f $TDIR"
3742 NUMS=$($CMD | wc -l)
3743 [ $NUMS -eq $EXPECTED ] ||
3744 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3746 CMD="$LFIND -size +5 -type f $TDIR"
3747 NUMS=$($CMD | wc -l)
3748 [ $NUMS -eq $EXPECTED ] ||
3749 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3751 CMD="$LFIND -size +0 -type f $TDIR"
3752 NUMS=$($CMD | wc -l)
3753 [ $NUMS -eq $EXPECTED ] ||
3754 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3756 CMD="$LFIND ! -size -5 -type f $TDIR"
3757 NUMS=$($CMD | wc -l)
3758 [ $NUMS -eq $EXPECTED ] ||
3759 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3761 CMD="$LFIND -size -5 -type f $TDIR"
3762 NUMS=$($CMD | wc -l)
3763 [ $NUMS -eq $EXPECTED ] ||
3764 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3766 run_test 56r "check lfs find -size works =========================="
3768 test_56s() { # LU-611
3770 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT"
3772 if [ $OSTCOUNT -gt 1 ]; then
3773 $SETSTRIPE -c 1 $TDIR/$tfile.{0,1,2,3}
3777 ONESTRIPE=$(((NUMDIRS + 1) * NUMFILES))
3781 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
3782 CMD="$LFIND -stripe-count $OSTCOUNT -type f $TDIR"
3783 NUMS=$($CMD | wc -l)
3784 [ $NUMS -eq $EXPECTED ] ||
3785 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3787 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + EXTRA))
3788 CMD="$LFIND -stripe-count +0 -type f $TDIR"
3789 NUMS=$($CMD | wc -l)
3790 [ $NUMS -eq $EXPECTED ] ||
3791 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3794 CMD="$LFIND -stripe-count 1 -type f $TDIR"
3795 NUMS=$($CMD | wc -l)
3796 [ $NUMS -eq $EXPECTED ] ||
3797 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3799 CMD="$LFIND -stripe-count -2 -type f $TDIR"
3800 NUMS=$($CMD | wc -l)
3801 [ $NUMS -eq $EXPECTED ] ||
3802 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3805 CMD="$LFIND -stripe-count $((OSTCOUNT + 1)) -type f $TDIR"
3806 NUMS=$($CMD | wc -l)
3807 [ $NUMS -eq $EXPECTED ] ||
3808 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3810 run_test 56s "check lfs find -stripe-count works"
3812 test_56t() { # LU-611
3814 setup_56 $NUMFILES $NUMDIRS "-s 512k"
3816 $SETSTRIPE -S 256k $TDIR/$tfile.{0,1,2,3}
3818 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
3819 CMD="$LFIND -stripe-size 512k -type f $TDIR"
3820 NUMS=$($CMD | wc -l)
3821 [ $NUMS -eq $EXPECTED ] ||
3822 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3824 CMD="$LFIND -stripe-size +320k -type f $TDIR"
3825 NUMS=$($CMD | wc -l)
3826 [ $NUMS -eq $EXPECTED ] ||
3827 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3829 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + 4))
3830 CMD="$LFIND -stripe-size +200k -type f $TDIR"
3831 NUMS=$($CMD | wc -l)
3832 [ $NUMS -eq $EXPECTED ] ||
3833 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3835 CMD="$LFIND -stripe-size -640k -type f $TDIR"
3836 NUMS=$($CMD | wc -l)
3837 [ $NUMS -eq $EXPECTED ] ||
3838 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3841 CMD="$LFIND -stripe-size 256k -type f $TDIR"
3842 NUMS=$($CMD | wc -l)
3843 [ $NUMS -eq $EXPECTED ] ||
3844 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3846 CMD="$LFIND -stripe-size -320k -type f $TDIR"
3847 NUMS=$($CMD | wc -l)
3848 [ $NUMS -eq $EXPECTED ] ||
3849 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3852 CMD="$LFIND -stripe-size 1024k -type f $TDIR"
3853 NUMS=$($CMD | wc -l)
3854 [ $NUMS -eq $EXPECTED ] ||
3855 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3857 run_test 56t "check lfs find -stripe-size works"
3859 test_56u() { # LU-611
3861 setup_56 $NUMFILES $NUMDIRS "-i 0"
3863 if [ $OSTCOUNT -gt 1 ]; then
3864 $SETSTRIPE -i 1 $TDIR/$tfile.{0,1,2,3}
3870 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
3871 CMD="$LFIND -stripe-index 0 -type f $TDIR"
3872 NUMS=$($CMD | wc -l)
3873 [ $NUMS -eq $EXPECTED ] ||
3874 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3877 CMD="$LFIND -stripe-index 1 -type f $TDIR"
3878 NUMS=$($CMD | wc -l)
3879 [ $NUMS -eq $EXPECTED ] ||
3880 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3882 CMD="$LFIND ! -stripe-index 0 -type f $TDIR"
3883 NUMS=$($CMD | wc -l)
3884 [ $NUMS -eq $EXPECTED ] ||
3885 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3888 # This should produce an error and not return any files
3889 CMD="$LFIND -stripe-index $OSTCOUNT -type f $TDIR"
3890 NUMS=$($CMD 2>/dev/null | wc -l)
3891 [ $NUMS -eq $EXPECTED ] ||
3892 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3894 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + ONESTRIPE))
3895 CMD="$LFIND -stripe-index 0,1 -type f $TDIR"
3896 NUMS=$($CMD | wc -l)
3897 [ $NUMS -eq $EXPECTED ] ||
3898 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3900 run_test 56u "check lfs find -stripe-index works"
3907 setup_56 $NUMFILES $NUMDIRS
3909 UUID=$(mdtuuid_from_index $MDT_IDX $TDIR)
3910 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT index $MDT_IDX"
3912 for file in $($LFIND -mdt $UUID $TDIR); do
3913 file_mdt_idx=$($GETSTRIPE -M $file)
3914 [ $file_mdt_idx -eq $MDT_IDX ] ||
3915 error "'lfind -mdt $UUID' != 'getstripe -M' ($file_mdt_idx)"
3918 run_test 56v "check 'lfs find -mdt match with lfs getstripe -M' ======="
3920 # Get and check the actual stripe count of one file.
3921 # Usage: check_stripe_count <file> <expected_stripe_count>
3922 check_stripe_count() {
3927 [[ -z "$file" || -z "$expected" ]] &&
3928 error "check_stripe_count: invalid argument!"
3930 local cmd="$GETSTRIPE -c $file"
3931 actual=$($cmd) || error "$cmd failed"
3932 actual=${actual%% *}
3934 if [[ $actual -ne $expected ]]; then
3935 [[ $expected -eq -1 ]] ||
3936 error "$cmd wrong: found $actual, expected $expected"
3937 [[ $actual -eq $OSTCOUNT ]] ||
3938 error "$cmd wrong: found $actual, expected $OSTCOUNT"
3945 rm -rf $TDIR || error "remove $TDIR failed"
3946 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT"
3949 stripe_size=$($GETSTRIPE -S -d $TDIR) ||
3950 error "$GETSTRIPE -S -d $TDIR failed"
3951 stripe_size=${stripe_size%% *}
3953 local file_size=$((stripe_size * OSTCOUNT))
3954 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
3955 local required_space=$((file_num * file_size))
3956 local free_space=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
3957 [[ $free_space -le $((required_space / 1024)) ]] &&
3958 skip_env "need at least $required_space bytes free space," \
3959 "have $free_space kbytes" && return
3962 local dd_count=$((file_size / dd_bs))
3964 # write data into the files
3968 for i in $(seq 1 $NUMFILES); do
3970 yes | dd bs=$dd_bs count=$dd_count of=$file >/dev/null 2>&1 ||
3971 error "write data into $file failed"
3973 for i in $(seq 1 $NUMDIRS); do
3974 for j in $(seq 1 $NUMFILES); do
3975 file=$TDIR/dir$i/file$j
3976 yes | dd bs=$dd_bs count=$dd_count of=$file \
3978 error "write data into $file failed"
3983 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
3986 local cmd="$LFS_MIGRATE -y -c $expected $TDIR/file1"
3988 eval $cmd || error "$cmd failed"
3990 check_stripe_count $TDIR/file1 $expected
3993 cmd="$LFS_MIGRATE -y -c $expected $TDIR/dir1"
3995 eval $cmd || error "$cmd failed"
3997 for j in $(seq 1 $NUMFILES); do
3998 check_stripe_count $TDIR/dir1/file$j $expected
4001 # lfs_migrate works with lfs find
4002 cmd="$LFIND -stripe_count $OSTCOUNT -type f $TDIR |
4003 $LFS_MIGRATE -y -c $expected"
4005 eval $cmd || error "$cmd failed"
4007 for i in $(seq 2 $NUMFILES); do
4008 check_stripe_count $TDIR/file$i $expected
4010 for i in $(seq 2 $NUMDIRS); do
4011 for j in $(seq 1 $NUMFILES); do
4012 check_stripe_count $TDIR/dir$i/file$j $expected
4016 run_test 56w "check lfs_migrate -c stripe_count works"
4019 # note test will not do anything if MDS is not local
4020 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4021 skip "Only applicable to ldiskfs-based MDTs"
4025 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4026 local MNTDEV="osd*.*MDT*.mntdev"
4027 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
4028 [ -z "$DEV" ] && error "can't access $MNTDEV"
4029 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
4030 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
4031 error "can't access $DEV"
4032 DEVISIZE=`awk '/Inode size:/ { print $3 }' $TMP/t57a.dump`
4033 [ "$DEVISIZE" -gt 128 ] || error "inode size $DEVISIZE"
4037 run_test 57a "verify MDS filesystem created with large inodes =="
4040 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4041 skip "Only applicable to ldiskfs-based MDTs"
4045 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4050 local FILEN=$dir/f$FILECOUNT
4052 rm -rf $dir || error "removing $dir"
4053 mkdir -p $dir || error "creating $dir"
4054 local num=$(get_mds_dir $dir)
4057 echo "mcreating $FILECOUNT files"
4058 createmany -m $dir/f 1 $FILECOUNT || \
4059 error "creating files in $dir"
4061 # verify that files do not have EAs yet
4062 $GETSTRIPE $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
4063 $GETSTRIPE $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
4067 df $dir #make sure we get new statfs data
4068 local MDSFREE=$(do_facet $mymds \
4069 lctl get_param -n osd*.*MDT000$((num -1)).kbytesfree)
4070 local MDCFREE=$(lctl get_param -n mdc.*MDT000$((num -1))-mdc-*.kbytesfree)
4071 echo "opening files to create objects/EAs"
4073 for FILE in `seq -f $dir/f%g 1 $FILECOUNT`; do
4074 $OPENFILE -f O_RDWR $FILE > /dev/null 2>&1 || error "opening $FILE"
4077 # verify that files have EAs now
4078 $GETSTRIPE $FILE1 | grep -q "obdidx" || error "$FILE1 missing EA"
4079 $GETSTRIPE $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
4081 sleep 1 #make sure we get new statfs data
4083 local MDSFREE2=$(do_facet $mymds \
4084 lctl get_param -n osd*.*MDT000$((num -1)).kbytesfree)
4085 local MDCFREE2=$(lctl get_param -n mdc.*MDT000$((num -1))-mdc-*.kbytesfree)
4086 if [ "$MDCFREE2" -lt "$((MDCFREE - 8))" ]; then
4087 if [ "$MDSFREE" != "$MDSFREE2" ]; then
4088 error "MDC before $MDCFREE != after $MDCFREE2"
4090 echo "MDC before $MDCFREE != after $MDCFREE2"
4091 echo "unable to confirm if MDS has large inodes"
4096 run_test 57b "default LOV EAs are stored inside large inodes ==="
4099 [ -z "$(which wiretest 2>/dev/null)" ] && skip_env "could not find wiretest" && return
4102 run_test 58 "verify cross-platform wire constants =============="
4105 echo "touch 130 files"
4106 createmany -o $DIR/f59- 130
4108 unlinkmany $DIR/f59- 130
4110 # wait for commitment of removal
4111 wait_delete_completed
4113 run_test 59 "verify cancellation of llog records async ========="
4115 TEST60_HEAD="test_60 run $RANDOM"
4117 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
4118 [ ! -f run-llog.sh ] && skip_env "missing subtest run-llog.sh" && return
4119 log "$TEST60_HEAD - from kernel mode"
4120 do_facet mgs sh run-llog.sh
4122 run_test 60a "llog sanity tests run from kernel module =========="
4124 test_60b() { # bug 6411
4126 LLOG_COUNT=`dmesg | awk "/$TEST60_HEAD/{marker = 1; from_marker = 0;}
4138 [ $LLOG_COUNT -gt 50 ] && error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)"|| true
4140 run_test 60b "limit repeated messages from CERROR/CWARN ========"
4143 echo "create 5000 files"
4144 createmany -o $DIR/f60c- 5000
4145 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
4146 lctl set_param fail_loc=0x80000137
4147 unlinkmany $DIR/f60c- 5000
4148 lctl set_param fail_loc=0
4150 run_test 60c "unlink file when mds full"
4153 SAVEPRINTK=$(lctl get_param -n printk)
4155 # verify "lctl mark" is even working"
4156 MESSAGE="test message ID $RANDOM $$"
4157 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
4158 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
4160 lctl set_param printk=0 || error "set lnet.printk failed"
4161 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
4162 MESSAGE="new test message ID $RANDOM $$"
4163 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
4164 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
4165 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
4167 lctl set_param -n printk="$SAVEPRINTK"
4169 run_test 60d "test printk console message masking"
4173 dd if=/dev/zero of=$f bs=`page_size` count=1
4174 cancel_lru_locks osc
4175 $MULTIOP $f OSMWUc || error
4178 run_test 61 "mmap() writes don't make sync hang ================"
4180 # bug 2330 - insufficient obd_match error checking causes LBUG
4184 cancel_lru_locks osc
4185 lctl set_param fail_loc=0x405
4186 cat $f && error "cat succeeded, expect -EIO"
4187 lctl set_param fail_loc=0
4189 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
4190 # match every page all of the time.
4191 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
4193 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
4194 test_63a() { # was test_63
4195 MAX_DIRTY_MB=`lctl get_param -n osc.*.max_dirty_mb | head -n 1`
4196 lctl set_param -n osc.*.max_dirty_mb 0
4197 for i in `seq 10` ; do
4198 dd if=/dev/zero of=$DIR/f63 bs=8k &
4204 lctl set_param -n osc.*.max_dirty_mb $MAX_DIRTY_MB
4205 rm -f $DIR/f63 || true
4207 run_test 63a "Verify oig_wait interruption does not crash ======="
4209 # bug 2248 - async write errors didn't return to application on sync
4210 # bug 3677 - async write errors left page locked
4213 lctl set_param debug=-1
4215 # ensure we have a grant to do async writes
4216 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
4219 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
4220 lctl set_param fail_loc=0x80000406
4221 $MULTIOP $DIR/$tfile Owy && \
4222 error "sync didn't return ENOMEM"
4223 sync; sleep 2; sync # do a real sync this time to flush page
4224 lctl get_param -n llite.*.dump_page_cache | grep locked && \
4225 error "locked page left in cache after async error" || true
4228 run_test 63b "async write errors should be returned to fsync ==="
4232 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
4234 run_test 64a "verify filter grant calculations (in kernel) ====="
4237 [ ! -f oos.sh ] && skip_env "missing subtest oos.sh" && return
4240 run_test 64b "check out-of-space detection on client ==========="
4243 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
4245 run_test 64c "verify grant shrink ========================------"
4247 # bug 1414 - set/get directories' stripe info
4251 $LVERIFY $DIR/d65 $DIR/d65/f1 || error "lverify failed"
4253 run_test 65a "directory with no stripe info ===================="
4257 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/d65||error "setstripe"
4259 $LVERIFY $DIR/d65 $DIR/d65/f2 || error "lverify failed"
4261 run_test 65b "directory setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1"
4264 if [ $OSTCOUNT -gt 1 ]; then
4266 $SETSTRIPE -S $(($STRIPESIZE * 4)) -i 1 \
4267 -c $(($OSTCOUNT - 1)) $DIR/d65 || error "setstripe"
4269 $LVERIFY $DIR/d65 $DIR/d65/f3 || error "lverify failed"
4272 run_test 65c "directory setstripe -S $((STRIPESIZE*4)) -i 1 -c $((OSTCOUNT-1))"
4276 if [ $STRIPECOUNT -le 0 ]; then
4278 elif [ $STRIPECOUNT -gt 2000 ]; then
4279 #LOV_MAX_STRIPE_COUNT is 2000
4280 [ $OSTCOUNT -gt 2000 ] && sc=2000 || sc=$(($OSTCOUNT - 1))
4282 sc=$(($STRIPECOUNT - 1))
4284 $SETSTRIPE -S $STRIPESIZE -c $sc $DIR/d65 || error "setstripe"
4285 touch $DIR/d65/f4 $DIR/d65/f5
4286 $LVERIFY $DIR/d65 $DIR/d65/f4 $DIR/d65/f5 || error "lverify failed"
4288 run_test 65d "directory setstripe -S $STRIPESIZE -c stripe_count"
4293 $SETSTRIPE $DIR/d65 || error "setstripe"
4294 $GETSTRIPE -v $DIR/d65 | grep "Default" || error "no stripe info failed"
4296 $LVERIFY $DIR/d65 $DIR/d65/f6 || error "lverify failed"
4298 run_test 65e "directory setstripe defaults ======================="
4302 $RUNAS $SETSTRIPE $DIR/d65f && error "setstripe succeeded" || true
4304 run_test 65f "dir setstripe permission (should return error) ==="
4308 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/d65 ||error "setstripe"
4309 $SETSTRIPE -d $DIR/d65 || error "setstripe"
4310 $GETSTRIPE -v $DIR/d65 | grep "Default" || \
4311 error "delete default stripe failed"
4313 run_test 65g "directory setstripe -d ==========================="
4317 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/d65 ||error "setstripe"
4318 mkdir -p $DIR/d65/dd1
4319 [ $($GETSTRIPE -c $DIR/d65) == $($GETSTRIPE -c $DIR/d65/dd1) ] ||
4320 error "stripe info inherit failed"
4322 run_test 65h "directory stripe info inherit ===================="
4324 test_65i() { # bug6367
4325 $SETSTRIPE -S 65536 -c -1 $MOUNT
4327 run_test 65i "set non-default striping on root directory (bug 6367)="
4329 test_65ia() { # bug12836
4330 $GETSTRIPE $MOUNT || error "getstripe $MOUNT failed"
4332 run_test 65ia "getstripe on -1 default directory striping"
4334 test_65ib() { # bug12836
4335 $GETSTRIPE -v $MOUNT || error "getstripe -v $MOUNT failed"
4337 run_test 65ib "getstripe -v on -1 default directory striping"
4339 test_65ic() { # bug12836
4340 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
4342 run_test 65ic "new find on -1 default directory striping"
4344 test_65j() { # bug6367
4346 # if we aren't already remounting for each test, do so for this test
4347 if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
4348 cleanup || error "failed to unmount"
4351 $SETSTRIPE -d $MOUNT || error "setstripe failed"
4353 run_test 65j "set default striping on root directory (bug 6367)="
4355 test_65k() { # bug11679
4356 [ "$OSTCOUNT" -lt 2 ] && skip_env "too few OSTs" && return
4357 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4359 echo "Check OST status: "
4360 local MDS_OSCS=`do_facet $SINGLEMDS lctl dl |
4361 awk '/[oO][sS][cC].*md[ts]/ { print $4 }'`
4363 for OSC in $MDS_OSCS; do
4364 echo $OSC "is activate"
4365 do_facet $SINGLEMDS lctl --device %$OSC activate
4368 do_facet client mkdir -p $DIR/$tdir
4369 for INACTIVE_OSC in $MDS_OSCS; do
4370 echo "Deactivate: " $INACTIVE_OSC
4371 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
4372 for STRIPE_OSC in $MDS_OSCS; do
4373 OST=`osc_to_ost $STRIPE_OSC`
4374 IDX=`do_facet $SINGLEMDS lctl get_param -n lov.*md*.target_obd |
4375 awk -F: /$OST/'{ print $1 }' | head -n 1`
4377 [ -f $DIR/$tdir/$IDX ] && continue
4378 echo "$SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX"
4379 do_facet client $SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX
4381 [ $RC -ne 0 ] && error "setstripe should have succeeded"
4383 do_facet client rm -f $DIR/$tdir/*
4384 echo $INACTIVE_OSC "is Activate."
4385 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
4388 run_test 65k "validate manual striping works properly with deactivated OSCs"
4390 test_65l() { # bug 12836
4391 mkdir -p $DIR/$tdir/test_dir
4392 $SETSTRIPE -c -1 $DIR/$tdir/test_dir
4393 $LFS find -mtime -1 $DIR/$tdir >/dev/null
4395 run_test 65l "lfs find on -1 stripe dir ========================"
4397 # bug 2543 - update blocks count on client
4400 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
4401 sync; sync_all_data; sync; sync_all_data
4402 cancel_lru_locks osc
4403 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
4404 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
4406 run_test 66 "update inode blocks count on client ==============="
4412 if [ ! -z "$LLOOP" ]; then
4413 if swapon -s | grep -q $LLOOP; then
4414 swapoff $LLOOP || error "swapoff failed"
4417 $LCTL blockdev_detach $LLOOP || error "detach failed"
4421 if [ ! -z "$LLITELOOPLOAD" ]; then
4429 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
4433 swapon -s | awk '($1 == "'$1'") { print $4 }'
4436 # test case for lloop driver, basic function
4438 [ "$UID" != 0 ] && skip_env "must run as root" && return
4439 llite_lloop_enabled || \
4440 { skip_env "llite_lloop module disabled" && return; }
4442 trap cleanup_68 EXIT
4444 if ! module_loaded llite_lloop; then
4445 if load_module llite/llite_lloop; then
4448 skip_env "can't find module llite_lloop"
4453 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
4454 dd if=/dev/zero of=$DIR/f68a bs=4k count=1024
4455 $LCTL blockdev_attach $DIR/f68a $LLOOP || error "attach failed"
4457 directio rdwr $LLOOP 0 1024 4096 || error "direct write failed"
4458 directio rdwr $LLOOP 0 1025 4096 && error "direct write should fail"
4462 run_test 68a "lloop driver - basic test ========================"
4464 # excercise swapping to lustre by adding a high priority swapfile entry
4465 # and then consuming memory until it is used.
4466 test_68b() { # was test_68
4467 [ "$UID" != 0 ] && skip_env "must run as root" && return
4468 lctl get_param -n devices | grep -q obdfilter && \
4469 skip "local OST" && return
4471 grep -q llite_lloop /proc/modules
4472 [ $? -ne 0 ] && skip "can't find module llite_lloop" && return
4474 [ -z "`$LCTL list_nids | grep -v tcp`" ] && \
4475 skip "can't reliably test swap with TCP" && return
4477 MEMTOTAL=`meminfo MemTotal`
4478 NR_BLOCKS=$((MEMTOTAL>>8))
4479 [[ $NR_BLOCKS -le 2048 ]] && NR_BLOCKS=2048
4481 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
4482 dd if=/dev/zero of=$DIR/f68b bs=64k seek=$NR_BLOCKS count=1
4485 $LCTL blockdev_attach $DIR/f68b $LLOOP || error "attach failed"
4487 trap cleanup_68 EXIT
4489 swapon -p 32767 $LLOOP || error "swapon $LLOOP failed"
4491 echo "before: `swapon -s | grep $LLOOP`"
4492 $MEMHOG $MEMTOTAL || error "error allocating $MEMTOTAL kB"
4493 echo "after: `swapon -s | grep $LLOOP`"
4494 SWAPUSED=`swap_used $LLOOP`
4498 [ $SWAPUSED -eq 0 ] && echo "no swap used???" || true
4500 run_test 68b "support swapping to Lustre ========================"
4502 # bug5265, obdfilter oa2dentry return -ENOENT
4503 # #define OBD_FAIL_OST_ENOENT 0x217
4505 remote_ost_nodsh && skip "remote OST with nodsh" && return
4508 $SETSTRIPE -c 1 -i 0 $f
4510 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
4512 do_facet ost1 lctl set_param fail_loc=0x217
4513 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
4514 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
4516 do_facet ost1 lctl set_param fail_loc=0
4517 $DIRECTIO write $f 0 2 || error "write error"
4519 cancel_lru_locks osc
4520 $DIRECTIO read $f 0 1 || error "read error"
4522 do_facet ost1 lctl set_param fail_loc=0x217
4523 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
4525 do_facet ost1 lctl set_param fail_loc=0
4528 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
4532 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
4534 run_test 71 "Running dbench on lustre (don't segment fault) ===="
4536 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
4537 check_kernel_version 43 || return 0
4538 [ "$RUNAS_ID" = "$UID" ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4540 # Check that testing environment is properly set up. Skip if not
4541 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS || {
4542 skip_env "User $RUNAS_ID does not exist - skipping"
4545 # We had better clear the $DIR to get enough space for dd
4550 $RUNAS dd if=/dev/zero of=$DIR/f72 bs=512 count=1 || error
4551 # See if we are still setuid/sgid
4552 test -u $DIR/f72 -o -g $DIR/f72 && error "S/gid is not dropped on write"
4553 # Now test that MDS is updated too
4554 cancel_lru_locks mdc
4555 test -u $DIR/f72 -o -g $DIR/f72 && error "S/gid is not dropped on MDS"
4558 run_test 72a "Test that remove suid works properly (bug5695) ===="
4560 test_72b() { # bug 24226 -- keep mode setting when size is not changing
4563 [ "$RUNAS_ID" = "$UID" ] && \
4564 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4565 [ "$RUNAS_ID" -eq 0 ] && \
4566 skip_env "RUNAS_ID = 0 -- 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_ID $RUNAS || {
4570 skip_env "User $RUNAS_ID does not exist - skipping"
4573 touch $DIR/${tfile}-f{g,u}
4574 mkdir $DIR/${tfile}-d{g,u}
4575 chmod 770 $DIR/${tfile}-{f,d}{g,u}
4576 chmod g+s $DIR/${tfile}-{f,d}g
4577 chmod u+s $DIR/${tfile}-{f,d}u
4578 for perm in 777 2777 4777; do
4579 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
4580 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
4581 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
4582 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
4586 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
4588 # bug 3462 - multiple simultaneous MDC requests
4592 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
4595 lctl set_param fail_loc=0x80000129
4596 $MULTIOP $DIR/d73-1/f73-2 Oc &
4598 lctl set_param fail_loc=0
4600 $MULTIOP $DIR/d73-2/f73-3 Oc &
4604 wait $pid1 || return 1
4608 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
4609 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
4610 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
4614 run_test 73 "multiple MDC requests (should not deadlock)"
4616 test_74a() { # bug 6149, 6184
4617 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
4619 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
4620 # will spin in a tight reconnection loop
4622 lctl set_param fail_loc=0x8000030e
4623 # get any lock that won't be difficult - lookup works.
4625 lctl set_param fail_loc=0
4629 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
4631 test_74b() { # bug 13310
4632 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
4634 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
4635 # will spin in a tight reconnection loop
4636 lctl set_param fail_loc=0x8000030e
4637 # get a "difficult" lock
4639 lctl set_param fail_loc=0
4643 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
4646 #define OBD_FAIL_LDLM_NEW_LOCK
4647 lctl set_param fail_loc=0x80000319
4648 touch $DIR/$tfile && error "Touch successful"
4651 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
4654 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
4657 get_inode_slab_tunables() {
4658 awk '/lustre_inode_cache/ {print $9," ",$10," ",$11; exit}' /proc/slabinfo
4661 set_inode_slab_tunables() {
4662 echo "lustre_inode_cache $1" > /proc/slabinfo
4665 test_76() { # Now for bug 20433, added originally in bug 1443
4666 local SLAB_SETTINGS=`get_inode_slab_tunables`
4667 local CPUS=`getconf _NPROCESSORS_ONLN`
4668 # we cannot set limit below 1 which means 1 inode in each
4669 # per-cpu cache is still allowed
4670 set_inode_slab_tunables "1 1 0"
4671 cancel_lru_locks osc
4672 BEFORE_INODES=`num_inodes`
4673 echo "before inodes: $BEFORE_INODES"
4675 [ "$SLOW" = "no" ] && COUNT=100
4676 for i in `seq $COUNT`; do
4680 cancel_lru_locks osc
4681 AFTER_INODES=`num_inodes`
4682 echo "after inodes: $AFTER_INODES"
4684 while [ $((AFTER_INODES-1*CPUS)) -gt $BEFORE_INODES ]; do
4686 AFTER_INODES=`num_inodes`
4688 echo "wait $wait seconds inodes: $AFTER_INODES"
4689 if [ $wait -gt 30 ]; then
4690 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
4693 set_inode_slab_tunables "$SLAB_SETTINGS"
4695 run_test 76 "confirm clients recycle inodes properly ===="
4701 # Note: in sptlrpc modes which enable its own bulk checksum, the
4702 # original crc32_le bulk checksum will be automatically disabled,
4703 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
4704 # will be checked by sptlrpc code against sptlrpc bulk checksum.
4705 # In this case set_checksums() will not be no-op, because sptlrpc
4706 # bulk checksum will be enabled all through the test.
4708 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
4709 lctl set_param -n osc.*.checksums $1
4713 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
4714 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
4715 CKSUM_TYPES=${CKSUM_TYPES:-"crc32 adler"}
4716 [ "$ORIG_CSUM_TYPE" = "crc32c" ] && CKSUM_TYPES="$CKSUM_TYPES crc32c"
4719 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
4720 log "set checksum type to $1"
4723 F77_TMP=$TMP/f77-temp
4726 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
4727 error "error writing to $F77_TMP"
4730 test_77a() { # bug 10889
4731 $GSS && skip "could not run with gss" && return
4732 [ ! -f $F77_TMP ] && setup_f77
4734 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
4738 run_test 77a "normal checksum read/write operation ============="
4740 test_77b() { # bug 10889
4741 $GSS && skip "could not run with gss" && return
4742 [ ! -f $F77_TMP ] && setup_f77
4743 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
4744 lctl set_param fail_loc=0x80000409
4746 dd if=$F77_TMP of=$DIR/f77b bs=1M count=$F77SZ conv=sync || \
4747 error "dd error: $?"
4748 lctl set_param fail_loc=0
4751 run_test 77b "checksum error on client write ===================="
4753 test_77c() { # bug 10889
4754 $GSS && skip "could not run with gss" && return
4755 [ ! -f $DIR/f77b ] && skip "requires 77b - skipping" && return
4757 for algo in $CKSUM_TYPES; do
4758 cancel_lru_locks osc
4759 set_checksum_type $algo
4760 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
4761 lctl set_param fail_loc=0x80000408
4762 cmp $F77_TMP $DIR/f77b || error "file compare failed"
4763 lctl set_param fail_loc=0
4766 set_checksum_type $ORIG_CSUM_TYPE
4769 run_test 77c "checksum error on client read ==================="
4771 test_77d() { # bug 10889
4772 $GSS && skip "could not run with gss" && return
4773 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
4774 lctl set_param fail_loc=0x80000409
4776 directio write $DIR/f77 0 $F77SZ $((1024 * 1024)) || \
4777 error "direct write: rc=$?"
4778 lctl set_param fail_loc=0
4781 run_test 77d "checksum error on OST direct write ==============="
4783 test_77e() { # bug 10889
4784 $GSS && skip "could not run with gss" && return
4785 [ ! -f $DIR/f77 ] && skip "requires 77d - skipping" && return
4786 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
4787 lctl set_param fail_loc=0x80000408
4789 cancel_lru_locks osc
4790 directio read $DIR/f77 0 $F77SZ $((1024 * 1024)) || \
4791 error "direct read: rc=$?"
4792 lctl set_param fail_loc=0
4795 run_test 77e "checksum error on OST direct read ================"
4797 test_77f() { # bug 10889
4798 $GSS && skip "could not run with gss" && return
4800 for algo in $CKSUM_TYPES; do
4801 cancel_lru_locks osc
4802 set_checksum_type $algo
4803 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
4804 lctl set_param fail_loc=0x409
4805 directio write $DIR/f77 0 $F77SZ $((1024 * 1024)) && \
4806 error "direct write succeeded"
4807 lctl set_param fail_loc=0
4809 set_checksum_type $ORIG_CSUM_TYPE
4812 run_test 77f "repeat checksum error on write (expect error) ===="
4814 test_77g() { # bug 10889
4815 $GSS && skip "could not run with gss" && return
4816 remote_ost_nodsh && skip "remote OST with nodsh" && return
4818 [ ! -f $F77_TMP ] && setup_f77
4820 $SETSTRIPE -c 1 -i 0 $DIR/f77g
4821 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
4822 do_facet ost1 lctl set_param fail_loc=0x8000021a
4824 dd if=$F77_TMP of=$DIR/f77g bs=1M count=$F77SZ || \
4825 error "write error: rc=$?"
4826 do_facet ost1 lctl set_param fail_loc=0
4829 run_test 77g "checksum error on OST write ======================"
4831 test_77h() { # bug 10889
4832 $GSS && skip "could not run with gss" && return
4833 remote_ost_nodsh && skip "remote OST with nodsh" && return
4835 [ ! -f $DIR/f77g ] && skip "requires 77g - skipping" && return
4836 cancel_lru_locks osc
4837 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
4838 do_facet ost1 lctl set_param fail_loc=0x8000021b
4840 cmp $F77_TMP $DIR/f77g || error "file compare failed"
4841 do_facet ost1 lctl set_param fail_loc=0
4844 run_test 77h "checksum error on OST read ======================="
4846 test_77i() { # bug 13805
4847 $GSS && skip "could not run with gss" && return
4848 #define OBD_FAIL_OSC_CONNECT_CKSUM 0x40b
4849 lctl set_param fail_loc=0x40b
4850 remount_client $MOUNT
4851 lctl set_param fail_loc=0
4852 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
4853 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
4854 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
4855 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
4857 remount_client $MOUNT
4859 run_test 77i "client not supporting OSD_CONNECT_CKSUM =========="
4861 test_77j() { # bug 13805
4862 $GSS && skip "could not run with gss" && return
4863 #define OBD_FAIL_OSC_CKSUM_ADLER_ONLY 0x40c
4864 lctl set_param fail_loc=0x40c
4865 remount_client $MOUNT
4866 lctl set_param fail_loc=0
4867 sleep 2 # wait async osc connect to finish
4868 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
4869 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
4870 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
4871 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
4873 remount_client $MOUNT
4875 run_test 77j "client only supporting ADLER32 ===================="
4877 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
4881 test_78() { # bug 10901
4882 remote_ost || { skip_env "local OST" && return; }
4885 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
4886 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
4887 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
4888 echo "MemTotal: $MEMTOTAL"
4889 # reserve 256MB of memory for the kernel and other running processes,
4890 # and then take 1/2 of the remaining memory for the read/write buffers.
4891 if [ $MEMTOTAL -gt 512 ] ;then
4892 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
4894 # for those poor memory-starved high-end clusters...
4895 MEMTOTAL=$((MEMTOTAL / 2))
4897 echo "Mem to use for directio: $MEMTOTAL"
4898 [ $F78SIZE -gt $MEMTOTAL ] && F78SIZE=$MEMTOTAL
4899 [ $F78SIZE -gt 512 ] && F78SIZE=512
4900 [ $F78SIZE -gt $((MAXFREE / 1024)) ] && F78SIZE=$((MAXFREE / 1024))
4901 SMALLESTOST=`lfs df $DIR |grep OST | awk '{print $4}' |sort -n |head -1`
4902 echo "Smallest OST: $SMALLESTOST"
4903 [ $SMALLESTOST -lt 10240 ] && \
4904 skip "too small OSTSIZE, useless to run large O_DIRECT test" && return 0
4906 [ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ] && \
4907 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
4909 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
4910 echo "File size: $F78SIZE"
4911 $SETSTRIPE -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
4912 for i in `seq 1 $NSEQ`
4914 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
4915 echo directIO rdwr round $i of $NSEQ
4916 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
4921 run_test 78 "handle large O_DIRECT writes correctly ============"
4923 test_79() { # bug 12743
4924 wait_delete_completed
4926 BKTOTAL=$(calc_osc_kbytes kbytestotal)
4927 BKFREE=$(calc_osc_kbytes kbytesfree)
4928 BKAVAIL=$(calc_osc_kbytes kbytesavail)
4930 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
4931 DFTOTAL=`echo $STRING | cut -d, -f1`
4932 DFUSED=`echo $STRING | cut -d, -f2`
4933 DFAVAIL=`echo $STRING | cut -d, -f3`
4934 DFFREE=$(($DFTOTAL - $DFUSED))
4936 ALLOWANCE=$((64 * $OSTCOUNT))
4938 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
4939 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
4940 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
4942 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
4943 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
4944 error "df free($DFFREE) mismatch OST free($BKFREE)"
4946 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
4947 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
4948 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
4951 run_test 79 "df report consistency check ======================="
4953 test_80() { # bug 10718
4954 # relax strong synchronous semantics for slow backends like ZFS
4955 local soc="obdfilter.*.sync_on_lock_cancel"
4956 local soc_old=$(do_facet ost1 lctl get_param -n $soc | head -n1)
4958 if [ "$soc_old" != "never" -a "$(facet_fstype ost1)" != "ldiskfs" ]; then
4959 hosts=$(for host in $(seq -f "ost%g" 1 $OSTCOUNT); do
4960 facet_active_host $host; done | sort -u)
4961 do_nodes $hosts lctl set_param $soc=never
4964 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
4966 local BEFORE=`date +%s`
4967 cancel_lru_locks osc
4968 local AFTER=`date +%s`
4969 local DIFF=$((AFTER-BEFORE))
4970 if [ $DIFF -gt 1 ] ; then
4971 error "elapsed for 1M@1T = $DIFF"
4974 [ -n "$hosts" ] && do_nodes $hosts lctl set_param $soc=$soc_old
4978 run_test 80 "Page eviction is equally fast at high offsets too ===="
4980 test_81a() { # LU-456
4981 remote_ost_nodsh && skip "remote OST with nodsh" && return
4982 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
4983 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
4984 do_facet ost1 lctl set_param fail_loc=0x80000228
4986 # write should trigger a retry and success
4987 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
4988 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
4990 if [ $RC -ne 0 ] ; then
4991 error "write should success, but failed for $RC"
4994 run_test 81a "OST should retry write when get -ENOSPC ==============="
4996 test_81b() { # LU-456
4997 remote_ost_nodsh && skip "remote OST with nodsh" && return
4998 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
4999 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
5000 do_facet ost1 lctl set_param fail_loc=0x228
5002 # write should retry several times and return -ENOSPC finally
5003 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
5004 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
5007 if [ $RC -ne $ENOSPC ] ; then
5008 error "dd should fail for -ENOSPC, but succeed."
5011 run_test 81b "OST should return -ENOSPC when retry still fails ======="
5013 test_82() { # LU-1031
5014 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10
5018 multiop_bg_pause $DIR/$tfile OG${gid1}_g${gid1}c || return 1
5020 multiop_bg_pause $DIR/$tfile O_G${gid2}r10g${gid2}c || return 2
5022 kill -USR1 $MULTIPID2
5024 if [[ `ps h -o comm -p $MULTIPID2` == "" ]]; then
5025 error "First grouplock does not block second one"
5027 echo "Second grouplock blocks first one"
5029 kill -USR1 $MULTIPID1
5033 run_test 82 "Basic grouplock test ==============================="
5036 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && \
5038 mkdir -p $DIR/d99cvsroot
5039 chown $RUNAS_ID $DIR/d99cvsroot
5040 local oldPWD=$PWD # bug 13584, use $TMP as working dir
5043 $RUNAS cvs -d $DIR/d99cvsroot init || error
5046 run_test 99a "cvs init ========================================="
5049 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5050 [ ! -d $DIR/d99cvsroot ] && test_99a
5052 # some versions of cvs import exit(1) when asked to import links or
5053 # files they can't read. ignore those files.
5054 TOIGNORE=$(find . -type l -printf '-I %f\n' -o \
5055 ! -perm +4 -printf '-I %f\n')
5056 $RUNAS cvs -d $DIR/d99cvsroot import -m "nomesg" $TOIGNORE \
5057 d99reposname vtag rtag
5059 run_test 99b "cvs import ======================================="
5062 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5063 [ ! -d $DIR/d99cvsroot ] && test_99b
5065 mkdir -p $DIR/d99reposname
5066 chown $RUNAS_ID $DIR/d99reposname
5067 $RUNAS cvs -d $DIR/d99cvsroot co d99reposname
5069 run_test 99c "cvs checkout ====================================="
5072 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5073 [ ! -d $DIR/d99cvsroot ] && test_99c
5074 cd $DIR/d99reposname
5076 $RUNAS cvs add -m 'addmsg' foo99
5078 run_test 99d "cvs add =========================================="
5081 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5082 [ ! -d $DIR/d99cvsroot ] && test_99c
5083 cd $DIR/d99reposname
5086 run_test 99e "cvs update ======================================="
5089 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5090 [ ! -d $DIR/d99cvsroot ] && test_99d
5091 cd $DIR/d99reposname
5092 $RUNAS cvs commit -m 'nomsg' foo99
5093 rm -fr $DIR/d99cvsroot
5095 run_test 99f "cvs commit ======================================="
5098 [ "$NETTYPE" = tcp ] || \
5099 { skip "TCP secure port test, not useful for NETTYPE=$NETTYPE" && \
5102 remote_ost_nodsh && skip "remote OST with nodsh" && return
5103 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5105 { skip "useless for local single node setup" && return; }
5107 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
5108 [ "$PROT" != "tcp" ] && continue
5109 RPORT=$(echo $REMOTE | cut -d: -f2)
5110 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
5113 LPORT=`echo $LOCAL | cut -d: -f2`
5114 if [ $LPORT -ge 1024 ]; then
5115 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
5117 error_exit "local: $LPORT > 1024, remote: $RPORT"
5120 [ "$rc" = 0 ] || error_exit "privileged port not found" )
5122 run_test 100 "check local port using privileged port ==========="
5124 function get_named_value()
5133 echo $line | sed "s/^$tag[ ]*//"
5140 export CACHE_MAX=`$LCTL get_param -n llite.*.max_cached_mb | head -n 1`
5142 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
5150 [ "$CPU" = "UML" ] && nreads=1000
5151 local cache_limit=32
5153 $LCTL set_param -n osc.*-osc*.rpc_stats 0
5154 trap cleanup_101a EXIT
5155 $LCTL set_param -n llite.*.read_ahead_stats 0
5156 $LCTL set_param -n llite.*.max_cached_mb $cache_limit
5159 # randomly read 10000 of 64K chunks from file 3x 32MB in size
5161 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
5162 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
5165 for s in `$LCTL get_param -n llite.*.read_ahead_stats | \
5166 get_named_value 'read but discarded' | cut -d" " -f1`; do
5167 discard=$(($discard + $s))
5171 if [ $(($discard * 10)) -gt $nreads ] ;then
5172 $LCTL get_param osc.*-osc*.rpc_stats
5173 $LCTL get_param llite.*.read_ahead_stats
5174 error "too many ($discard) discarded pages"
5176 rm -f $DIR/$tfile || true
5178 run_test 101a "check read-ahead for random reads ================"
5183 STRIPE_COUNT=$OSTCOUNT
5186 local list=$(comma_list $(osts_nodes))
5187 do_nodes $list $LCTL set_param -n obdfilter.*.read_cache_enable=0
5188 do_nodes $list $LCTL set_param -n obdfilter.*.writethrough_cache_enable=0
5190 trap cleanup_test101bc EXIT
5191 # prepare the read-ahead file
5192 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
5194 dd if=/dev/zero of=$DIR/$tfile bs=1024k count=100 2> /dev/null
5197 cleanup_test101bc() {
5202 local list=$(comma_list $(osts_nodes))
5203 do_nodes $list $LCTL set_param -n obdfilter.*.read_cache_enable=1
5204 do_nodes $list $LCTL set_param -n obdfilter.*.writethrough_cache_enable=1
5208 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
5213 local STRIPE_SIZE=1048576
5214 local RA_INC=1048576
5215 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
5216 local FILE_LENGTH=$((64*100))
5217 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
5218 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
5219 DISCARD=`$LCTL get_param -n llite.*.read_ahead_stats | \
5220 get_named_value 'read but discarded' | \
5221 cut -d" " -f1 | calc_total`
5222 if [ $DISCARD -gt $discard_limit ]; then
5223 $LCTL get_param llite.*.read_ahead_stats
5224 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
5226 echo "Read-ahead success for size ${READ_SIZE}"
5231 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping stride IO stride-ahead test" && return
5232 local STRIPE_SIZE=1048576
5233 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
5234 local FILE_LENGTH=$((STRIPE_SIZE*100))
5235 local ITERATION=$((FILE_LENGTH/STRIDE_SIZE))
5236 # prepare the read-ahead file
5238 cancel_lru_locks osc
5239 for BIDX in 2 4 8 16 32 64 128 256
5241 local BSIZE=$((BIDX*4096))
5242 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
5243 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
5244 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
5245 $LCTL set_param -n llite.*.read_ahead_stats 0
5246 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
5247 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
5248 cancel_lru_locks osc
5254 run_test 101b "check stride-io mode read-ahead ================="
5257 local STRIPE_SIZE=1048576
5258 local FILE_LENGTH=$((STRIPE_SIZE*100))
5264 cancel_lru_locks osc
5265 $LCTL set_param osc.*.rpc_stats 0
5266 $READS -f $DIR/$tfile -s$FILE_LENGTH -b65536 -n$nreads -t 180
5267 for osc in $($LCTL get_param -N osc.*); do
5268 if [ "$osc" == "osc.num_refs" ]; then
5272 local lines=$($LCTL get_param -n ${osc}.rpc_stats | wc | awk '{print $1}')
5273 if [ $lines -le 20 ]; then
5277 local rpc4k=$($LCTL get_param -n ${osc}.rpc_stats |
5278 awk '$1 == "1:" { print $2; exit; }')
5279 local rpc8k=$($LCTL get_param -n ${osc}.rpc_stats |
5280 awk '$1 == "2:" { print $2; exit; }')
5281 local rpc16k=$($LCTL get_param -n ${osc}.rpc_stats |
5282 awk '$1 == "4:" { print $2; exit; }')
5283 local rpc32k=$($LCTL get_param -n ${osc}.rpc_stats |
5284 awk '$1 == "8:" { print $2; exit; }')
5286 [ $rpc4k != 0 ] && error "Small 4k read IO ${rpc4k}!"
5287 [ $rpc8k != 0 ] && error "Small 8k read IO ${rpc8k}!"
5288 [ $rpc16k != 0 ] && error "Small 16k read IO ${rpc16k}!"
5289 [ $rpc32k != 0 ] && error "Small 32k read IO ${rpc32k}!"
5290 echo "${osc} rpc check passed!"
5295 run_test 101c "check stripe_size aligned read-ahead ================="
5298 $LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1
5299 $LCTL set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
5303 local file=$DIR/$tfile
5304 local size=${FILESIZE_101c:-500}
5305 local ra_MB=${READAHEAD_MB:-40}
5307 local space=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
5308 [ $space -gt $((size / 1024)) ] ||
5309 { skip "Need free space ${size}M, have $space" && return; }
5311 echo Creating ${size}M test file $file
5312 dd if=/dev/zero of=$file bs=1M count=$size || error "dd failed"
5313 echo Cancel LRU locks on lustre client to flush the client cache
5314 cancel_lru_locks osc
5316 echo Disable read-ahead
5317 local old_READAHEAD=$(set_read_ahead 0)
5319 echo Reading the test file $file with read-ahead disabled
5320 time_ra_OFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$size")
5322 echo Cancel LRU locks on lustre client to flush the client cache
5323 cancel_lru_locks osc
5324 echo Enable read-ahead with ${ra_MB}MB
5325 set_read_ahead $ra_MB
5327 echo Reading the test file $file with read-ahead enabled
5328 time_ra_ON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$size")
5330 echo read-ahead disabled time read $time_ra_OFF
5331 echo read-ahead enabled time read $time_ra_ON
5333 set_read_ahead $old_READAHEAD
5335 wait_delete_completed
5337 [ $time_ra_ON -lt $time_ra_OFF ] ||
5338 error "read-ahead enabled time read (${time_ra_ON}s) is more than
5339 read-ahead disabled time read (${time_ra_OFF}s) filesize ${size}M"
5341 run_test 101d "file read with and without read-ahead enabled ================="
5344 local file=$DIR/$tfile
5349 local space=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
5350 local need_space=$((count * size))
5351 [ $space -gt $need_space ] ||
5352 { skip_env "Need free space $need_space, have $space" && return; }
5354 echo Creating $count ${size}K test files
5355 for ((i = 0; i < $count; i++)); do
5356 dd if=/dev/zero of=${file}_${i} bs=$blksize count=$size 2>/dev/null
5359 echo Cancel LRU locks on lustre client to flush the client cache
5360 cancel_lru_locks osc
5362 echo Reset readahead stats
5363 $LCTL set_param -n llite.*.read_ahead_stats 0
5365 for ((i = 0; i < $count; i++)); do
5366 dd if=${file}_${i} of=/dev/null bs=$blksize count=$size 2>/dev/null
5369 local miss=$($LCTL get_param -n llite.*.read_ahead_stats | \
5370 get_named_value 'misses' | cut -d" " -f1 | calc_total)
5372 for ((i = 0; i < $count; i++)); do
5373 rm -rf ${file}_${i} 2>/dev/null
5376 #10000 means 20% reads are missing in readahead
5377 [ $miss -lt 10000 ] || error "misses too much for small reads"
5379 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
5381 cleanup_test101f() {
5383 $LCTL set_param -n llite.*.max_read_ahead_whole_mb $MAX_WHOLE_MB
5384 rm -rf $DIR/$tfile 2>/dev/null
5388 local file=$DIR/$tfile
5391 MAX_WHOLE_MB=$($LCTL get_param -n llite.*.max_read_ahead_whole_mb)
5392 $LCTL set_param -n llite.*.max_read_ahead_whole_mb 2
5393 dd if=/dev/zero of=${file} bs=2097152 count=1 2>/dev/null
5394 trap cleanup_test101f EXIT
5396 echo Cancel LRU locks on lustre client to flush the client cache
5397 cancel_lru_locks osc
5399 echo Reset readahead stats
5400 $LCTL set_param -n llite.*.read_ahead_stats 0
5401 # Random read in a 2M file, because max_read_ahead_whole_mb = 2M,
5402 # readahead should read in 2M file on second read, so only miss
5404 echo Random 4K reads on 2M file for 1000 times
5405 $READS -f $file -s 2097152 -b 4096 -n $nreads
5407 echo checking missing pages
5408 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
5409 get_named_value 'misses' | cut -d" " -f1 | calc_total)
5411 [ $miss -lt 3 ] || error "misses too much pages!"
5414 run_test 101f "check read-ahead for max_read_ahead_whole_mb"
5418 chown $RUNAS_ID $DIR/$tdir
5421 STRIPE_COUNT=$OSTCOUNT
5422 [ $OSTCOUNT -gt 4 ] && STRIPE_COUNT=4
5424 trap cleanup_test102 EXIT
5426 $1 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
5428 for num in 1 2 3 4; do
5429 for count in $(seq 1 $STRIPE_COUNT); do
5430 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
5431 local size=`expr $STRIPE_SIZE \* $num`
5432 local file=file"$num-$idx-$count"
5433 $1 $SETSTRIPE -S $size -i $idx -c $count $file
5439 $1 $TAR cf $TMP/f102.tar $tdir --xattrs
5445 rm -rf $DIR/d0.sanity/d102
5449 local testfile=$DIR/xattr_testfile
5453 [ "$UID" != 0 ] && skip_env "must run as root" && return
5454 [ -z "`lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr`" ] &&
5455 skip_env "must have user_xattr" && return
5457 [ -z "$(which setfattr 2>/dev/null)" ] &&
5458 skip_env "could not find setfattr" && return
5460 echo "set/get xattr..."
5461 setfattr -n trusted.name1 -v value1 $testfile || error
5462 getfattr -n trusted.name1 $testfile 2> /dev/null |
5463 grep "trusted.name1=.value1" ||
5464 error "$testfile missing trusted.name1=value1"
5466 setfattr -n user.author1 -v author1 $testfile || error
5467 getfattr -n user.author1 $testfile 2> /dev/null |
5468 grep "user.author1=.author1" ||
5469 error "$testfile missing trusted.author1=author1"
5472 setfattr -n trusted.name2 -v value2 $testfile ||
5473 error "$testfile unable to set trusted.name2"
5474 setfattr -n trusted.name3 -v value3 $testfile ||
5475 error "$testfile unable to set trusted.name3"
5476 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
5477 grep "trusted.name" | wc -l) -eq 3 ] ||
5478 error "$testfile missing 3 trusted.name xattrs"
5480 setfattr -n user.author2 -v author2 $testfile ||
5481 error "$testfile unable to set user.author2"
5482 setfattr -n user.author3 -v author3 $testfile ||
5483 error "$testfile unable to set user.author3"
5484 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
5485 grep "user.author" | wc -l) -eq 3 ] ||
5486 error "$testfile missing 3 user.author xattrs"
5488 echo "remove xattr..."
5489 setfattr -x trusted.name1 $testfile ||
5490 error "$testfile error deleting trusted.name1"
5491 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
5492 error "$testfile did not delete trusted.name1 xattr"
5494 setfattr -x user.author1 $testfile ||
5495 error "$testfile error deleting user.author1"
5496 getfattr -d -m user $testfile 2> /dev/null | grep "user.author1" &&
5497 error "$testfile did not delete trusted.name1 xattr"
5499 # b10667: setting lustre special xattr be silently discarded
5500 echo "set lustre special xattr ..."
5501 setfattr -n "trusted.lov" -v "invalid value" $testfile ||
5502 error "$testfile allowed setting trusted.lov"
5504 run_test 102a "user xattr test =================================="
5507 # b10930: get/set/list trusted.lov xattr
5508 echo "get/set/list trusted.lov xattr ..."
5509 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
5510 local testfile=$DIR/$tfile
5511 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
5512 error "setstripe failed"
5513 local STRIPECOUNT=$($GETSTRIPE -c $testfile) ||
5514 error "getstripe failed"
5515 getfattr -d -m "^trusted" $testfile 2> /dev/null | \
5516 grep "trusted.lov" || error "can't get trusted.lov from $testfile"
5518 local testfile2=${testfile}2
5519 local value=`getfattr -n trusted.lov $testfile 2> /dev/null | \
5520 grep "trusted.lov" |sed -e 's/[^=]\+=//'`
5523 setfattr -n trusted.lov -v $value $testfile2
5524 local stripe_size=$($GETSTRIPE -S $testfile2)
5525 local stripe_count=$($GETSTRIPE -c $testfile2)
5526 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
5527 [ $stripe_count -eq $STRIPECOUNT ] ||
5528 error "stripe count $stripe_count != $STRIPECOUNT"
5531 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
5534 # b10930: get/set/list lustre.lov xattr
5535 echo "get/set/list lustre.lov xattr ..."
5536 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
5538 chown $RUNAS_ID $DIR/$tdir
5539 local testfile=$DIR/$tdir/$tfile
5540 $RUNAS $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
5541 error "setstripe failed"
5542 local STRIPECOUNT=$($RUNAS $GETSTRIPE -c $testfile) ||
5543 error "getstripe failed"
5544 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
5545 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
5547 local testfile2=${testfile}2
5548 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
5549 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
5551 $RUNAS $MCREATE $testfile2
5552 $RUNAS setfattr -n lustre.lov -v $value $testfile2
5553 local stripe_size=$($RUNAS $GETSTRIPE -S $testfile2)
5554 local stripe_count=$($RUNAS $GETSTRIPE -c $testfile2)
5555 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
5556 [ $stripe_count -eq $STRIPECOUNT ] ||
5557 error "stripe count $stripe_count != $STRIPECOUNT"
5559 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
5561 compare_stripe_info1() {
5562 local stripe_index_all_zero=true
5564 for num in 1 2 3 4; do
5565 for count in $(seq 1 $STRIPE_COUNT); do
5566 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
5567 local size=$((STRIPE_SIZE * num))
5568 local file=file"$num-$offset-$count"
5569 stripe_size=$(lfs getstripe -S $PWD/$file)
5570 [ $stripe_size -ne $size ] &&
5571 error "$file: size $stripe_size != $size"
5572 stripe_count=$(lfs getstripe -c $PWD/$file)
5573 # allow fewer stripes to be created, ORI-601
5574 [ $stripe_count -lt $(((3 * count + 3) / 4)) ]&&
5575 error "$file: count $stripe_count != $count"
5576 stripe_index=$(lfs getstripe -i $PWD/$file)
5577 [ $stripe_index -ne 0 ] &&
5578 stripe_index_all_zero=false
5582 $stripe_index_all_zero &&
5583 error "all files are being extracted starting from OST index 0"
5588 [ -n "$(which tar 2>/dev/null)" ] &&
5589 strings $(which tar) | grep -q "lustre" && echo tar
5593 # b10930: tar test for trusted.lov xattr
5594 TAR=$(find_lustre_tar)
5595 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
5596 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
5599 $TAR xf $TMP/f102.tar -C $DIR/d102d --xattrs
5601 compare_stripe_info1
5603 run_test 102d "tar restore stripe info from tarfile,not keep osts ==========="
5606 # b10930: tar test for trusted.lov xattr
5607 TAR=$(find_lustre_tar)
5608 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
5609 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
5613 $TAR cf - --xattrs $tdir | $TAR xf - --xattrs -C $DIR/d102f
5615 compare_stripe_info1
5617 run_test 102f "tar copy files, not keep osts ==========="
5620 local xsize=${1:-1024} # in bytes
5621 local file=$DIR/$tfile
5623 [ -z $(lctl get_param -n mdc.*.connect_flags | grep xattr) ] &&
5624 skip "must have user_xattr" && return 0
5625 [ -z "$(which setfattr 2>/dev/null)" ] &&
5626 skip_env "could not find setfattr" && return 0
5627 [ -z "$(which getfattr 2>/dev/null)" ] &&
5628 skip_env "could not find getfattr" && return 0
5632 local value="$(generate_string $xsize)"
5634 local xbig=trusted.big
5635 log "save $xbig on $file"
5636 setfattr -n $xbig -v $value $file ||
5637 error "saving $xbig on $file failed"
5639 local orig=$(get_xattr_value $xbig $file)
5640 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
5642 local xsml=trusted.sml
5643 log "save $xsml on $file"
5644 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
5646 local new=$(get_xattr_value $xbig $file)
5647 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
5649 log "grow $xsml on $file"
5650 setfattr -n $xsml -v "$value" $file ||
5651 error "growing $xsml on $file failed"
5653 new=$(get_xattr_value $xbig $file)
5654 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
5655 log "$xbig still valid after growing $xsml"
5660 test_102h() { # bug 15777
5663 run_test 102h "grow xattr from inside inode to external block"
5666 large_xattr_enabled || { skip "large_xattr disabled" && return; }
5667 grow_xattr $(max_xattr_size)
5669 run_test 102ha "grow xattr from inside inode to external inode"
5671 test_102i() { # bug 17038
5673 ln -s $DIR/$tfile $DIR/${tfile}link
5674 getfattr -n trusted.lov $DIR/$tfile || error "lgetxattr on $DIR/$tfile failed"
5675 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"
5676 rm -f $DIR/$tfile $DIR/${tfile}link
5678 run_test 102i "lgetxattr test on symbolic link ============"
5681 TAR=$(find_lustre_tar)
5682 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
5683 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
5684 setup_test102 "$RUNAS"
5686 chown $RUNAS_ID $DIR/d102j
5687 $RUNAS $TAR xf $TMP/f102.tar -C $DIR/d102j --xattrs
5689 compare_stripe_info1 "$RUNAS"
5691 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
5695 # b22187 just check that does not crash for regular file.
5696 setfattr -n trusted.lov $DIR/$tfile
5697 # b22187 'setfattr -n trusted.lov' should work as remove LOV EA for directories
5698 local test_kdir=$DIR/d102k
5700 local default_size=`$GETSTRIPE -S $test_kdir`
5701 local default_count=`$GETSTRIPE -c $test_kdir`
5702 local default_offset=`$GETSTRIPE -i $test_kdir`
5703 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $test_kdir ||
5704 error 'dir setstripe failed'
5705 setfattr -n trusted.lov $test_kdir
5706 local stripe_size=`$GETSTRIPE -S $test_kdir`
5707 local stripe_count=`$GETSTRIPE -c $test_kdir`
5708 local stripe_offset=`$GETSTRIPE -i $test_kdir`
5709 [ $stripe_size -eq $default_size ] ||
5710 error "stripe size $stripe_size != $default_size"
5711 [ $stripe_count -eq $default_count ] ||
5712 error "stripe count $stripe_count != $default_count"
5713 [ $stripe_offset -eq $default_offset ] ||
5714 error "stripe offset $stripe_offset != $default_offset"
5715 rm -rf $DIR/$tfile $test_kdir
5717 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
5720 # LU-532 trusted. xattr is invisible to non-root
5721 local testfile=$DIR/$tfile
5725 echo "listxattr as user..."
5726 chown $RUNAS_ID $testfile
5727 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
5728 grep -q "trusted" &&
5729 error "$testfile trusted xattrs are user visible"
5733 run_test 102l "listxattr filter test =================================="
5739 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
5744 [ "$UID" != 0 ] && skip_env "must run as root" && return
5745 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
5746 [ -z "$(which setfacl 2>/dev/null)" ] && skip_env "could not find setfacl" && return
5747 $GSS && skip "could not run under gss" && return
5749 declare -a identity_old
5751 for num in $(seq $MDSCOUNT); do
5752 switch_identity $num true || identity_old[$num]=$?
5759 echo "performing cp ..."
5760 run_acl_subtest cp || error
5761 echo "performing getfacl-noacl..."
5762 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
5763 echo "performing misc..."
5764 run_acl_subtest misc || error "misc test failed"
5765 echo "performing permissions..."
5766 run_acl_subtest permissions || error "permissions failed"
5767 echo "performing setfacl..."
5768 run_acl_subtest setfacl || error "setfacl test failed"
5770 # inheritance test got from HP
5771 echo "performing inheritance..."
5772 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
5773 chmod +x make-tree || error "chmod +x failed"
5774 run_acl_subtest inheritance || error "inheritance test failed"
5777 echo "LU-974 ignore umask when acl is enabled..."
5780 run_acl_subtest 974 || error "LU-974 test failed"
5786 for num in $(seq $MDSCOUNT); do
5787 if [ "${identity_old[$num]}" = 1 ]; then
5788 switch_identity $num false || identity_old[$num]=$?
5792 run_test 103 "acl test ========================================="
5796 lfs df || error "lfs df failed"
5797 lfs df -ih || error "lfs df -ih failed"
5798 lfs df -h $DIR || error "lfs df -h $DIR failed"
5799 lfs df -i $DIR || error "lfs df -i $DIR failed"
5800 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
5801 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
5803 OSC=`lctl dl |grep OST0000-osc-[^M] |awk '{print $4}'`
5804 lctl --device %$OSC deactivate
5805 lfs df || error "lfs df with deactivated OSC failed"
5806 lctl --device %$OSC activate
5807 # wait the osc back to normal
5808 wait_osc_import_state client ost FULL
5810 lfs df || error "lfs df with reactivated OSC failed"
5813 run_test 104a "lfs df [-ih] [path] test ========================="
5816 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5818 denied_cnt=$((`$RUNAS $LFS check servers 2>&1 | grep "Permission denied" | wc -l`))
5819 if [ $denied_cnt -ne 0 ];
5821 error "lfs check servers test failed"
5824 run_test 104b "$RUNAS lfs check servers test ===================="
5827 # doesn't work on 2.4 kernels
5829 if [ -n "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ];
5831 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
5833 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
5837 run_test 105a "flock when mounted without -o flock test ========"
5841 if [ -n "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ];
5843 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
5845 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
5849 run_test 105b "fcntl when mounted without -o flock test ========"
5853 if [ -n "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ];
5855 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
5857 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
5861 run_test 105c "lockf when mounted without -o flock test ========"
5863 test_105d() { # bug 15924
5865 [ -z "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ] && \
5866 skip "mount w/o flock enabled" && return
5867 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
5868 $LCTL set_param fail_loc=0x80000315
5869 flocks_test 2 $DIR/$tdir
5871 run_test 105d "flock race (should not freeze) ========"
5873 test_105e() { # bug 22660 && 22040
5874 [ -z "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ] && \
5875 skip "mount w/o flock enabled" && return
5877 flocks_test 3 $DIR/$tfile
5879 run_test 105e "Two conflicting flocks from same process ======="
5881 test_106() { #bug 10921
5883 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
5884 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
5886 run_test 106 "attempt exec of dir followed by chown of that dir"
5895 local save_pattern=$(sysctl -n kernel.core_pattern)
5896 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
5897 sysctl -w kernel.core_pattern=$file
5898 sysctl -w kernel.core_uses_pid=0
5906 kill -s 11 $SLEEPPID
5908 if [ -e $file ]; then
5909 size=`stat -c%s $file`
5910 [ $size -eq 0 ] && error "Fail to create core file $file"
5912 error "Fail to create core file $file"
5915 sysctl -w kernel.core_pattern=$save_pattern
5916 sysctl -w kernel.core_uses_pid=$save_uses_pid
5919 run_test 107 "Coredump on SIG"
5923 mkdir $DIR/$tdir/$(str_repeat 'a' 255) ||
5924 error "mkdir with 255 char failed"
5925 mkdir $DIR/$tdir/$(str_repeat 'b' 256) &&
5926 error "mkdir with 256 char should fail, but did not"
5927 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
5928 error "create with 255 char failed"
5929 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
5930 error "create with 256 char should fail, but did not"
5935 run_test 110 "filename length checking"
5938 OSTIO_pre=$(ps -e|grep ll_ost_io|awk '{print $4}'|sort -n|tail -1|\
5940 [ -z "$OSTIO_pre" ] && skip "no OSS threads" && \
5942 echo "Starting with $OSTIO_pre threads"
5945 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
5946 [ $NUMFREE -lt $NUMTEST ] && NUMTEST=$(($NUMFREE - 1000))
5947 echo "$NUMTEST creates/unlinks"
5949 createmany -o $DIR/$tdir/$tfile $NUMTEST
5950 unlinkmany $DIR/$tdir/$tfile $NUMTEST
5952 OSTIO_post=$(ps -e|grep ll_ost_io|awk '{print $4}'|sort -n|tail -1|\
5955 # don't return an error
5956 [ $OSTIO_post == $OSTIO_pre ] && echo \
5957 "WARNING: No new ll_ost_io threads were created ($OSTIO_pre)" &&
5958 echo "This may be fine, depending on what ran before this test" &&
5959 echo "and how fast this system is." && return
5961 echo "Started with $OSTIO_pre threads, ended with $OSTIO_post"
5963 run_test 115 "verify dynamic thread creation===================="
5966 wait_delete_completed
5967 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
5968 echo OST kbytes available: ${AVAIL[@]}
5969 MAXI=0; MAXV=${AVAIL[0]}
5970 MINI=0; MINV=${AVAIL[0]}
5971 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
5972 #echo OST $i: ${AVAIL[i]}kb
5973 if [ ${AVAIL[i]} -gt $MAXV ]; then
5974 MAXV=${AVAIL[i]}; MAXI=$i
5976 if [ ${AVAIL[i]} -lt $MINV ]; then
5977 MINV=${AVAIL[i]}; MINI=$i
5980 echo Min free space: OST $MINI: $MINV
5981 echo Max free space: OST $MAXI: $MAXV
5984 test_116a() { # was previously test_116()
5985 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs" && return
5987 echo -n "Free space priority "
5988 lctl get_param -n lov.*-clilov-*.qos_prio_free
5991 [ $MINV -gt 960000 ] && skip "too much free space in OST$MINI, skip" &&\
5994 # generate uneven OSTs
5995 mkdir -p $DIR/$tdir/OST${MINI}
5998 echo "Filling 25% remaining space in OST${MINI} with ${FILL}Kb"
5999 $SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI}||error "setstripe failed"
6001 while [ $FILL -gt 0 ]; do
6003 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i bs=2M count=1 2>/dev/null
6004 FILL=$(($FILL - 2048))
6012 DIFF=$(($MAXV - $MINV))
6013 DIFF2=$(($DIFF * 100 / $MINV))
6014 echo -n "diff=${DIFF}=${DIFF2}% must be > 20% for QOS mode..."
6015 if [ $DIFF2 -gt 20 ]; then
6018 echo "failed - QOS mode won't be used"
6019 error_ignore "QOS imbalance criteria not met"
6023 MINI1=$MINI; MINV1=$MINV
6024 MAXI1=$MAXI; MAXV1=$MAXV
6026 # now fill using QOS
6027 echo writing a bunch of files to QOS-assigned OSTs
6028 $SETSTRIPE -c 1 $DIR/$tdir
6030 while [ $FILL -gt 0 ]; do
6032 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1024 count=200 2>/dev/null
6033 FILL=$(($FILL - 200))
6036 echo "wrote $i 200k files"
6040 echo "Note: free space may not be updated, so measurements might be off"
6042 DIFF2=$(($MAXV - $MINV))
6043 echo "free space delta: orig $DIFF final $DIFF2"
6044 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
6045 DIFF=$(($MINV1 - ${AVAIL[$MINI1]}))
6046 echo "Wrote $DIFF to smaller OST $MINI1"
6047 DIFF2=$(($MAXV1 - ${AVAIL[$MAXI1]}))
6048 echo "Wrote $DIFF2 to larger OST $MAXI1"
6049 [ $DIFF -gt 0 ] && echo "Wrote $(($DIFF2 * 100 / $DIFF - 100))% more data to larger OST $MAXI1"
6051 # Figure out which files were written where
6052 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
6053 awk '/'$MINI1': / {print $2; exit}')
6055 MINC=$($GETSTRIPE --obd $UUID $DIR/$tdir | wc -l)
6056 echo "$MINC files created on smaller OST $MINI1"
6057 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
6058 awk '/'$MAXI1': / {print $2; exit}')
6060 MAXC=$($GETSTRIPE --obd $UUID $DIR/$tdir | wc -l)
6061 echo "$MAXC files created on larger OST $MAXI1"
6062 [ $MINC -gt 0 ] && echo "Wrote $(($MAXC * 100 / $MINC - 100))% more files to larger OST $MAXI1"
6063 [ $MAXC -gt $MINC ] || error_ignore "stripe QOS didn't balance free space"
6067 run_test 116a "stripe QOS: free space balance ==================="
6069 test_116b() { # LU-2093
6070 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
6072 old_rr=$(do_facet $SINGLEMDS lctl get_param -n lov.*mdtlov*.qos_threshold_rr)
6073 do_facet $SINGLEMDS lctl set_param lov.*mdtlov*.qos_threshold_rr 0
6075 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
6076 createmany -o $DIR/$tdir/f- 20 || error "can't create"
6077 do_facet $SINGLEMDS lctl set_param fail_loc=0
6079 do_facet $SINGLEMDS lctl set_param lov.*mdtlov*.qos_threshold_rr $old_rr
6081 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
6083 test_117() # bug 10891
6085 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
6086 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
6087 lctl set_param fail_loc=0x21e
6088 > $DIR/$tfile || error "truncate failed"
6089 lctl set_param fail_loc=0
6090 echo "Truncate succeeded."
6093 run_test 117 "verify fsfilt_extend =========="
6095 export OLD_RESENDCOUNT=""
6096 set_resend_count () {
6097 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
6098 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -1)
6099 lctl set_param -n $PROC_RESENDCOUNT $1
6100 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
6103 [ "$SLOW" = "no" ] && set_resend_count 4 # for reduce test_118* time (bug 14842)
6105 # Reset async IO behavior after error case
6107 FILE=$DIR/reset_async
6109 # Ensure all OSCs are cleared
6110 $SETSTRIPE -c -1 $FILE
6111 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
6116 test_118a() #bug 11710
6120 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6121 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6122 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
6124 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6125 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6130 run_test 118a "verify O_SYNC works =========="
6134 remote_ost_nodsh && skip "remote OST with nodsh" && return
6138 #define OBD_FAIL_OST_ENOENT 0x217
6139 set_nodes_failloc "$(osts_nodes)" 0x217
6140 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6142 set_nodes_failloc "$(osts_nodes)" 0
6143 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6144 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6147 if [[ $RC -eq 0 ]]; then
6148 error "Must return error due to dropped pages, rc=$RC"
6152 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6153 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6157 echo "Dirty pages not leaked on ENOENT"
6159 # Due to the above error the OSC will issue all RPCs syncronously
6160 # until a subsequent RPC completes successfully without error.
6161 $MULTIOP $DIR/$tfile Ow4096yc
6166 run_test 118b "Reclaim dirty pages on fatal error =========="
6170 remote_ost_nodsh && skip "remote OST with nodsh" && return
6174 #define OBD_FAIL_OST_EROFS 0x216
6175 set_nodes_failloc "$(osts_nodes)" 0x216
6177 # multiop should block due to fsync until pages are written
6178 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
6182 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
6183 error "Multiop failed to block on fsync, pid=$MULTIPID"
6186 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6188 if [[ $WRITEBACK -eq 0 ]]; then
6189 error "No page in writeback, writeback=$WRITEBACK"
6192 set_nodes_failloc "$(osts_nodes)" 0
6195 if [[ $RC -ne 0 ]]; then
6196 error "Multiop fsync failed, rc=$RC"
6199 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6200 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6202 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6203 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6207 echo "Dirty pages flushed via fsync on EROFS"
6210 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
6214 remote_ost_nodsh && skip "remote OST with nodsh" && return
6218 #define OBD_FAIL_OST_BRW_PAUSE_BULK
6219 set_nodes_failloc "$(osts_nodes)" 0x214
6220 # multiop should block due to fsync until pages are written
6221 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
6225 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
6226 error "Multiop failed to block on fsync, pid=$MULTIPID"
6229 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6231 if [[ $WRITEBACK -eq 0 ]]; then
6232 error "No page in writeback, writeback=$WRITEBACK"
6235 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
6236 set_nodes_failloc "$(osts_nodes)" 0
6238 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6239 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6241 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6242 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6246 echo "Dirty pages gaurenteed flushed via fsync"
6249 run_test 118d "Fsync validation inject a delay of the bulk =========="
6254 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
6255 lctl set_param fail_loc=0x8000040a
6257 # Should simulate EINVAL error which is fatal
6258 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6260 if [[ $RC -eq 0 ]]; then
6261 error "Must return error due to dropped pages, rc=$RC"
6264 lctl set_param fail_loc=0x0
6266 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6267 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6268 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6270 if [[ $LOCKED -ne 0 ]]; then
6271 error "Locked pages remain in cache, locked=$LOCKED"
6274 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6275 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6279 echo "No pages locked after fsync"
6284 run_test 118f "Simulate unrecoverable OSC side error =========="
6289 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
6290 lctl set_param fail_loc=0x406
6292 # simulate local -ENOMEM
6293 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6296 lctl set_param fail_loc=0
6297 if [[ $RC -eq 0 ]]; then
6298 error "Must return error due to dropped pages, rc=$RC"
6301 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6302 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6303 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6305 if [[ $LOCKED -ne 0 ]]; then
6306 error "Locked pages remain in cache, locked=$LOCKED"
6309 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6310 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6314 echo "No pages locked after fsync"
6319 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
6322 remote_ost_nodsh && skip "remote OST with nodsh" && return
6326 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
6327 set_nodes_failloc "$(osts_nodes)" 0x20e
6328 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
6329 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6332 set_nodes_failloc "$(osts_nodes)" 0
6333 if [[ $RC -eq 0 ]]; then
6334 error "Must return error due to dropped pages, rc=$RC"
6337 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6338 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6339 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6341 if [[ $LOCKED -ne 0 ]]; then
6342 error "Locked pages remain in cache, locked=$LOCKED"
6345 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6346 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6350 echo "No pages locked after fsync"
6354 run_test 118h "Verify timeout in handling recoverables errors =========="
6356 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
6359 remote_ost_nodsh && skip "remote OST with nodsh" && return
6363 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
6364 set_nodes_failloc "$(osts_nodes)" 0x20e
6366 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
6367 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
6370 set_nodes_failloc "$(osts_nodes)" 0
6374 if [[ $RC -ne 0 ]]; then
6375 error "got error, but should be not, rc=$RC"
6378 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6379 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6380 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
6381 if [[ $LOCKED -ne 0 ]]; then
6382 error "Locked pages remain in cache, locked=$LOCKED"
6385 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6386 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6390 echo "No pages locked after fsync"
6394 run_test 118i "Fix error before timeout in recoverable error =========="
6396 [ "$SLOW" = "no" ] && set_resend_count 4
6399 remote_ost_nodsh && skip "remote OST with nodsh" && return
6403 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
6404 set_nodes_failloc "$(osts_nodes)" 0x220
6406 # return -EIO from OST
6407 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6409 set_nodes_failloc "$(osts_nodes)" 0x0
6410 if [[ $RC -eq 0 ]]; then
6411 error "Must return error due to dropped pages, rc=$RC"
6414 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6415 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6416 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
6417 if [[ $LOCKED -ne 0 ]]; then
6418 error "Locked pages remain in cache, locked=$LOCKED"
6421 # in recoverable error on OST we want resend and stay until it finished
6422 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6423 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6427 echo "No pages locked after fsync"
6431 run_test 118j "Simulate unrecoverable OST side error =========="
6435 remote_ost_nodsh && skip "remote OSTs with nodsh" && return
6437 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
6438 set_nodes_failloc "$(osts_nodes)" 0x20e
6441 for ((i=0;i<10;i++)); do
6442 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
6443 error "dd to $DIR/$tdir/$tfile-$i failed" )&
6450 set_nodes_failloc "$(osts_nodes)" 0
6453 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
6459 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
6462 run_test 118l "fsync dir ========="
6464 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
6466 test_119a() # bug 11737
6468 BSIZE=$((512 * 1024))
6469 directio write $DIR/$tfile 0 1 $BSIZE
6470 # We ask to read two blocks, which is more than a file size.
6471 # directio will indicate an error when requested and actual
6472 # sizes aren't equeal (a normal situation in this case) and
6473 # print actual read amount.
6474 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
6475 if [ "$NOB" != "$BSIZE" ]; then
6476 error "read $NOB bytes instead of $BSIZE"
6480 run_test 119a "Short directIO read must return actual read amount"
6482 test_119b() # bug 11737
6484 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
6486 $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
6487 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
6489 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) || \
6490 error "direct read failed"
6493 run_test 119b "Sparse directIO read must return actual read amount"
6495 test_119c() # bug 13099
6498 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
6499 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
6502 run_test 119c "Testing for direct read hitting hole"
6504 test_119d() # bug 15950
6506 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
6507 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
6509 $SETSTRIPE $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
6510 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
6511 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
6512 lctl set_param fail_loc=0x40d
6513 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
6516 cat $DIR/$tfile > /dev/null &
6517 lctl set_param fail_loc=0
6520 log "the DIO writes have completed, now wait for the reads (should not block very long)"
6522 [ -n "`ps h -p $pid_reads -o comm`" ] && \
6523 error "the read rpcs have not completed in 2s"
6525 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
6527 run_test 119d "The DIO path should try to send a new rpc once one is completed"
6531 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6532 skip "no early lock cancel on server" && return 0
6533 lru_resize_disable mdc
6534 lru_resize_disable osc
6535 cancel_lru_locks mdc
6536 stat $DIR/$tdir > /dev/null
6537 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6538 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6540 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6541 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6542 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6543 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6544 lru_resize_enable mdc
6545 lru_resize_enable osc
6547 run_test 120a "Early Lock Cancel: mkdir test"
6551 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6552 skip "no early lock cancel on server" && return 0
6553 lru_resize_disable mdc
6554 lru_resize_disable osc
6555 cancel_lru_locks mdc
6556 stat $DIR/$tdir > /dev/null
6557 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6558 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6560 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6561 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6562 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6563 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6564 lru_resize_enable mdc
6565 lru_resize_enable osc
6567 run_test 120b "Early Lock Cancel: create test"
6571 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6572 skip "no early lock cancel on server" && return 0
6573 lru_resize_disable mdc
6574 lru_resize_disable osc
6575 mkdir -p $DIR/$tdir/d1 $DIR/$tdir/d2
6576 touch $DIR/$tdir/d1/f1
6577 cancel_lru_locks mdc
6578 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /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}'`
6581 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
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 120c "Early Lock Cancel: link 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
6598 cancel_lru_locks mdc
6599 stat $DIR/$tdir > /dev/null
6600 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6601 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6602 chmod a+x $DIR/$tdir
6603 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6604 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6605 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6606 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6607 lru_resize_enable mdc
6608 lru_resize_enable osc
6610 run_test 120d "Early Lock Cancel: setattr test"
6614 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6615 skip "no early lock cancel on server" && return 0
6616 lru_resize_disable mdc
6617 lru_resize_disable osc
6618 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
6619 cancel_lru_locks mdc
6620 cancel_lru_locks osc
6621 dd if=$DIR/$tdir/f1 of=/dev/null
6622 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
6623 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6624 awk '/ldlm_cancel/ {print $2}'`
6625 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6626 awk '/ldlm_bl_callback/ {print $2}'`
6627 unlink $DIR/$tdir/f1
6628 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6629 awk '/ldlm_cancel/ {print $2}'`
6630 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6631 awk '/ldlm_bl_callback/ {print $2}'`
6632 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6633 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6634 lru_resize_enable mdc
6635 lru_resize_enable osc
6637 run_test 120e "Early Lock Cancel: unlink test"
6640 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6641 skip "no early lock cancel on server" && return 0
6643 lru_resize_disable mdc
6644 lru_resize_disable osc
6645 mkdir -p $DIR/$tdir/d1 $DIR/$tdir/d2
6646 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
6647 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
6648 cancel_lru_locks mdc
6649 cancel_lru_locks osc
6650 dd if=$DIR/$tdir/d1/f1 of=/dev/null
6651 dd if=$DIR/$tdir/d2/f2 of=/dev/null
6652 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
6653 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6654 awk '/ldlm_cancel/ {print $2}'`
6655 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6656 awk '/ldlm_bl_callback/ {print $2}'`
6657 mv $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
6658 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6659 awk '/ldlm_cancel/ {print $2}'`
6660 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6661 awk '/ldlm_bl_callback/ {print $2}'`
6662 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6663 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6664 lru_resize_enable mdc
6665 lru_resize_enable osc
6667 run_test 120f "Early Lock Cancel: rename test"
6670 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6671 skip "no early lock cancel on server" && return 0
6672 lru_resize_disable mdc
6673 lru_resize_disable osc
6675 echo create $count files
6677 cancel_lru_locks mdc
6678 cancel_lru_locks osc
6681 can0=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6682 awk '/ldlm_cancel/ {print $2}'`
6683 blk0=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6684 awk '/ldlm_bl_callback/ {print $2}'`
6685 createmany -o $DIR/$tdir/f $count
6687 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6688 awk '/ldlm_cancel/ {print $2}'`
6689 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6690 awk '/ldlm_bl_callback/ {print $2}'`
6692 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
6693 echo rm $count files
6696 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6697 awk '/ldlm_cancel/ {print $2}'`
6698 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6699 awk '/ldlm_bl_callback/ {print $2}'`
6701 echo total: $count removes in $((t2-t1))
6702 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
6704 # wait for commitment of removal
6705 lru_resize_enable mdc
6706 lru_resize_enable osc
6708 run_test 120g "Early Lock Cancel: performance test"
6710 test_121() { #bug #10589
6712 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
6713 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
6714 lctl set_param fail_loc=0x310
6715 cancel_lru_locks osc > /dev/null
6716 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
6717 lctl set_param fail_loc=0
6718 [ "$reads" -eq "$writes" ] || error "read" $reads "blocks, must be" $writes
6720 run_test 121 "read cancel race ========="
6722 test_123a() { # was test 123, statahead(bug 11401)
6724 if [ -z "$(grep "processor.*: 1" /proc/cpuinfo)" ]; then
6725 log "testing on UP system. Performance may be not as good as expected."
6731 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
6732 [ $NUMFREE -gt 100000 ] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
6734 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
6735 createmany -o $DIR/$tdir/$tfile $j $((i - j))
6737 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
6738 lctl set_param -n llite.*.statahead_max 0
6739 lctl get_param llite.*.statahead_max
6740 cancel_lru_locks mdc
6741 cancel_lru_locks osc
6743 time ls -l $DIR/$tdir | wc -l
6745 delta=$((etime - stime))
6746 log "ls $i files without statahead: $delta sec"
6747 lctl set_param llite.*.statahead_max=$max
6749 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
6750 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
6751 cancel_lru_locks mdc
6752 cancel_lru_locks osc
6754 time ls -l $DIR/$tdir | wc -l
6756 delta_sa=$((etime - stime))
6757 log "ls $i files with statahead: $delta_sa sec"
6758 lctl get_param -n llite.*.statahead_stats
6759 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
6761 [ $swrong -lt $ewrong ] && log "statahead was stopped, maybe too many locks held!"
6762 [ $delta -eq 0 -o $delta_sa -eq 0 ] && continue
6764 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
6765 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
6766 lctl set_param -n llite.*.statahead_max 0
6767 lctl get_param llite.*.statahead_max
6768 cancel_lru_locks mdc
6769 cancel_lru_locks osc
6771 time ls -l $DIR/$tdir | wc -l
6773 delta=$((etime - stime))
6774 log "ls $i files again without statahead: $delta sec"
6775 lctl set_param llite.*.statahead_max=$max
6776 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
6777 if [ $SLOWOK -eq 0 ]; then
6778 error "ls $i files is slower with statahead!"
6780 log "ls $i files is slower with statahead!"
6786 [ $delta -gt 20 ] && break
6787 [ $delta -gt 8 ] && MULT=$((50 / delta))
6788 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
6796 delta=$((etime - stime))
6797 log "rm -r $DIR/$tdir/: $delta seconds"
6799 lctl get_param -n llite.*.statahead_stats
6801 run_test 123a "verify statahead work"
6803 test_123b () { # statahead(bug 15027)
6805 createmany -o $DIR/$tdir/$tfile-%d 1000
6807 cancel_lru_locks mdc
6808 cancel_lru_locks osc
6810 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
6811 lctl set_param fail_loc=0x80000803
6812 ls -lR $DIR/$tdir > /dev/null
6814 lctl set_param fail_loc=0x0
6815 lctl get_param -n llite.*.statahead_stats
6820 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
6823 [ -z "`lctl get_param -n mdc.*.connect_flags | grep lru_resize`" ] && \
6824 skip "no lru resize on server" && return 0
6826 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
6828 log "create $NR files at $DIR/$tdir"
6829 createmany -o $DIR/$tdir/f $NR ||
6830 error "failed to create $NR files in $DIR/$tdir"
6832 cancel_lru_locks mdc
6833 ls -l $DIR/$tdir > /dev/null
6837 for VALUE in `lctl get_param ldlm.namespaces.*mdc-*.lru_size`; do
6838 local PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
6839 LRU_SIZE=$(lctl get_param -n $PARAM)
6840 if [ $LRU_SIZE -gt $(default_lru_size) ]; then
6841 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
6843 log "NS=$(basename $NSDIR)"
6848 if [ -z "$NSDIR" -o $LRU_SIZE -lt $(default_lru_size) ]; then
6849 skip "Not enough cached locks created!"
6856 # We know that lru resize allows one client to hold $LIMIT locks
6857 # for 10h. After that locks begin to be killed by client.
6859 local LIMIT=`lctl get_param -n $NSDIR.pool.limit`
6862 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
6863 # killing locks. Some time was spent for creating locks. This means
6864 # that up to the moment of sleep finish we must have killed some of
6865 # them (10-100 locks). This depends on how fast ther were created.
6866 # Many of them were touched in almost the same moment and thus will
6867 # be killed in groups.
6868 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
6870 # Use $LRU_SIZE_B here to take into account real number of locks
6871 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
6872 local LRU_SIZE_B=$LRU_SIZE
6874 local OLD_LVF=`lctl get_param -n $NSDIR.pool.lock_volume_factor`
6875 log "OLD_LVF=$OLD_LVF"
6876 lctl set_param -n $NSDIR.pool.lock_volume_factor $LVF
6878 # Let's make sure that we really have some margin. Client checks
6879 # cached locks every 10 sec.
6881 log "Sleep ${SLEEP} sec"
6883 while ((SEC<$SLEEP)); do
6887 LRU_SIZE=`lctl get_param -n $NSDIR/lru_size`
6891 lctl set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
6892 local LRU_SIZE_A=`lctl get_param -n $NSDIR.lru_size`
6894 [ $LRU_SIZE_B -gt $LRU_SIZE_A ] || {
6895 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
6896 unlinkmany $DIR/$tdir/f $NR
6900 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
6901 log "unlink $NR files at $DIR/$tdir"
6902 unlinkmany $DIR/$tdir/f $NR
6904 run_test 124a "lru resize ======================================="
6906 get_max_pool_limit()
6908 local limit=`lctl get_param -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit`
6911 if test $l -gt $max; then
6919 [ -z "`lctl get_param -n mdc.*.connect_flags | grep lru_resize`" ] && \
6920 skip "no lru resize on server" && return 0
6922 LIMIT=`get_max_pool_limit`
6924 NR=$(($(default_lru_size)*20))
6925 if [ $NR -gt $LIMIT ]; then
6926 log "Limit lock number by $LIMIT locks"
6929 lru_resize_disable mdc
6930 mkdir -p $DIR/$tdir/disable_lru_resize ||
6931 error "failed to create $DIR/$tdir/disable_lru_resize"
6933 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
6934 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
6935 cancel_lru_locks mdc
6938 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
6941 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
6944 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
6948 nolruresize_delta=$((etime-stime))
6949 log "ls -la time: $nolruresize_delta seconds"
6950 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
6951 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
6953 lru_resize_enable mdc
6954 mkdir -p $DIR/$tdir/enable_lru_resize ||
6955 error "failed to create $DIR/$tdir/enable_lru_resize"
6957 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
6958 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
6959 cancel_lru_locks mdc
6962 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
6965 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
6968 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
6972 lruresize_delta=$((etime-stime))
6973 log "ls -la time: $lruresize_delta seconds"
6974 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
6976 if [ $lruresize_delta -gt $nolruresize_delta ]; then
6977 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
6978 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
6979 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
6981 log "lru resize performs the same with no lru resize"
6983 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
6985 run_test 124b "lru resize (performance test) ======================="
6987 test_125() { # 13358
6988 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
6989 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
6990 mkdir -p $DIR/d125 || error "mkdir failed"
6991 $SETSTRIPE -S 65536 -c -1 $DIR/d125 || error "setstripe failed"
6992 setfacl -R -m u:bin:rwx $DIR/d125 || error "setfacl $DIR/d125 failed"
6993 ls -ld $DIR/d125 || error "cannot access $DIR/d125"
6995 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
6997 test_126() { # bug 12829/13455
6998 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
6999 [ "$UID" != 0 ] && skip_env "skipping $TESTNAME (must run as root)" && return
7000 $GSS && skip "must run as gss disabled" && return
7002 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
7003 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
7005 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
7007 run_test 126 "check that the fsgid provided by the client is taken into account"
7009 test_127a() { # bug 15521
7010 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
7011 $LCTL set_param osc.*.stats=0
7012 FSIZE=$((2048 * 1024))
7013 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
7014 cancel_lru_locks osc
7015 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
7017 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
7018 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
7019 echo "got $COUNT $NAME"
7020 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
7021 eval $NAME=$COUNT || error "Wrong proc format"
7024 read_bytes|write_bytes)
7025 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
7026 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
7027 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
7028 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
7029 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
7030 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
7031 error "sumsquare is too small: $SUMSQ"
7032 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
7033 error "sumsquare is too big: $SUMSQ"
7037 done < $DIR/${tfile}.tmp
7039 #check that we actually got some stats
7040 [ "$read_bytes" ] || error "Missing read_bytes stats"
7041 [ "$write_bytes" ] || error "Missing write_bytes stats"
7042 [ "$read_bytes" != 0 ] || error "no read done"
7043 [ "$write_bytes" != 0 ] || error "no write done"
7045 run_test 127a "verify the client stats are sane"
7047 test_127b() { # bug LU-333
7048 $LCTL set_param llite.*.stats=0
7049 FSIZE=65536 # sized fixed to match PAGE_SIZE for most clients
7050 # perform 2 reads and writes so MAX is different from SUM.
7051 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
7052 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
7053 cancel_lru_locks osc
7054 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
7055 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
7057 $LCTL get_param llite.*.stats | grep samples > $TMP/${tfile}.tmp
7058 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
7059 echo "got $COUNT $NAME"
7060 eval $NAME=$COUNT || error "Wrong proc format"
7064 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
7065 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
7066 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
7067 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
7070 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
7071 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
7072 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
7073 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
7077 done < $TMP/${tfile}.tmp
7079 #check that we actually got some stats
7080 [ "$read_bytes" ] || error "Missing read_bytes stats"
7081 [ "$write_bytes" ] || error "Missing write_bytes stats"
7082 [ "$read_bytes" != 0 ] || error "no read done"
7083 [ "$write_bytes" != 0 ] || error "no write done"
7085 run_test 127b "verify the llite client stats are sane"
7087 test_128() { # bug 15212
7089 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
7094 result=$(grep error $TMP/$tfile.log)
7096 [ -z "$result" ] || error "consecutive find's under interactive lfs failed"
7098 run_test 128 "interactive lfs for 2 consecutive find's"
7105 local LDPROC=/proc/fs/ldiskfs
7106 local facets=$(get_facets MDS)
7108 for facet in ${facets//,/ }; do
7109 canondev=$(ldiskfs_canon \
7110 *.$(convert_facet2label $facet).mntdev $facet)
7111 do_facet $facet "test -e $LDPROC/$canondev/max_dir_size" ||
7112 LDPROC=/sys/fs/ldiskfs
7113 do_facet $facet "echo $1 >$LDPROC/$canondev/max_dir_size"
7117 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
7118 skip "Only applicable to ldiskfs-based MDTs"
7121 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7131 while [ ! $I -gt $((MAX * MDSCOUNT)) ]; do
7132 $MULTIOP $DIR/$tdir/$J Oc
7134 if [ $rc -eq $EFBIG ]; then
7136 echo "return code $rc received as expected"
7138 elif [ $rc -ne 0 ]; then
7140 error_exit "return code $rc received instead of expected $EFBIG"
7143 I=$(stat -c%s "$DIR/$tdir")
7147 error "exceeded dir size limit $MAX x $MDSCOUNT $((MAX * MDSCOUNT)) : $I bytes"
7149 run_test 129 "test directory size limit ========================"
7158 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7159 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
7162 trap cleanup_130 EXIT RETURN
7164 local fm_file=$DIR/$tfile
7165 $SETSTRIPE -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
7166 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
7167 error "dd failed for $fm_file"
7169 # LU-1795: test filefrag/FIEMAP once, even if unsupported
7170 filefrag -ves $fm_file
7172 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
7173 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
7174 [ $RC != 0 ] && error "filefrag $fm_file failed"
7176 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
7177 grep -v "ext:" | grep -v "found")
7178 lun=$($GETSTRIPE -i $fm_file)
7180 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
7183 for line in $filefrag_op
7185 frag_lun=`echo $line | cut -d: -f5`
7186 ext_len=`echo $line | cut -d: -f4`
7187 if (( $frag_lun != $lun )); then
7189 error "FIEMAP on 1-stripe file($fm_file) failed"
7192 (( tot_len += ext_len ))
7195 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
7197 error "FIEMAP on 1-stripe file($fm_file) failed;"
7203 echo "FIEMAP on single striped file succeeded"
7205 run_test 130a "FIEMAP (1-stripe file)"
7208 [ "$OSTCOUNT" -lt "2" ] &&
7209 skip_env "skipping FIEMAP on 2-stripe file test" && return
7211 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7212 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
7215 trap cleanup_130 EXIT RETURN
7217 local fm_file=$DIR/$tfile
7218 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
7219 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
7220 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
7222 dd if=/dev/zero of=$fm_file bs=1M count=2 ||
7223 error "dd failed on $fm_file"
7225 filefrag -ves $fm_file || error "filefrag $fm_file failed"
7226 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
7227 grep -v "ext:" | grep -v "found")
7229 last_lun=$(echo $filefrag_op | cut -d: -f5)
7234 for line in $filefrag_op
7236 frag_lun=`echo $line | cut -d: -f5`
7237 ext_len=`echo $line | cut -d: -f4`
7238 if (( $frag_lun != $last_lun )); then
7239 if (( tot_len != 1024 )); then
7241 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 256"
7248 (( tot_len += ext_len ))
7251 if (( num_luns != 2 || tot_len != 1024 )); then
7253 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
7259 echo "FIEMAP on 2-stripe file succeeded"
7261 run_test 130b "FIEMAP (2-stripe file)"
7264 [ "$OSTCOUNT" -lt "2" ] &&
7265 skip_env "skipping FIEMAP on 2-stripe file" && return
7267 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7268 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
7271 trap cleanup_130 EXIT RETURN
7273 local fm_file=$DIR/$tfile
7274 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
7275 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
7276 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
7278 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 || error "dd failed on $fm_file"
7280 filefrag -ves $fm_file || error "filefrag $fm_file failed"
7281 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
7283 last_lun=`echo $filefrag_op | cut -d: -f5`
7288 for line in $filefrag_op
7290 frag_lun=`echo $line | cut -d: -f5`
7291 ext_len=`echo $line | cut -d: -f4`
7292 if (( $frag_lun != $last_lun )); then
7293 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
7294 if (( logical != 512 )); then
7296 error "FIEMAP on $fm_file failed; returned logical start for lun $logical instead of 512"
7299 if (( tot_len != 512 )); then
7301 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
7308 (( tot_len += ext_len ))
7311 if (( num_luns != 2 || tot_len != 512 )); then
7313 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
7319 echo "FIEMAP on 2-stripe file with hole succeeded"
7321 run_test 130c "FIEMAP (2-stripe file with hole)"
7324 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping FIEMAP on N-stripe file test" && return
7326 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7327 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
7329 trap cleanup_130 EXIT RETURN
7331 local fm_file=$DIR/$tfile
7332 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file||error "setstripe on $fm_file"
7333 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
7334 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
7335 dd if=/dev/zero of=$fm_file bs=1M count=$OSTCOUNT || error "dd failed on $fm_file"
7337 filefrag -ves $fm_file || error "filefrag $fm_file failed"
7338 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
7340 last_lun=`echo $filefrag_op | cut -d: -f5`
7345 for line in $filefrag_op
7347 frag_lun=`echo $line | cut -d: -f5`
7348 ext_len=`echo $line | cut -d: -f4`
7349 if (( $frag_lun != $last_lun )); then
7350 if (( tot_len != 1024 )); then
7352 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
7359 (( tot_len += ext_len ))
7362 if (( num_luns != OSTCOUNT || tot_len != 1024 )); then
7364 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
7370 echo "FIEMAP on N-stripe file succeeded"
7372 run_test 130d "FIEMAP (N-stripe file)"
7375 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping continuation FIEMAP test" && return
7377 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7378 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
7380 trap cleanup_130 EXIT RETURN
7382 local fm_file=$DIR/$tfile
7383 $SETSTRIPE -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
7384 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
7385 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
7388 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
7389 for ((i = 0; i < $NUM_BLKS; i++))
7391 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
7394 filefrag -ves $fm_file || error "filefrag $fm_file failed"
7395 filefrag_op=`filefrag -ve $fm_file | grep -A 12000 "ext:" | grep -v "ext:" | grep -v "found"`
7397 last_lun=`echo $filefrag_op | cut -d: -f5`
7402 for line in $filefrag_op
7404 frag_lun=`echo $line | cut -d: -f5`
7405 ext_len=`echo $line | cut -d: -f4`
7406 if (( $frag_lun != $last_lun )); then
7407 if (( tot_len != $EXPECTED_LEN )); then
7409 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of $EXPECTED_LEN"
7416 (( tot_len += ext_len ))
7419 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
7421 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
7427 echo "FIEMAP with continuation calls succeeded"
7429 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
7431 # Test for writev/readv
7433 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 || \
7434 error "writev test failed"
7435 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 || \
7436 error "readv failed"
7439 run_test 131a "test iov's crossing stripe boundary for writev/readv"
7442 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 || \
7443 error "append writev test failed"
7444 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 || \
7445 error "append writev test failed"
7448 run_test 131b "test append writev"
7451 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
7454 run_test 131c "test read/write on file w/o objects"
7457 rwv -f $DIR/$tfile -w -n 1 1572864
7458 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
7459 if [ "$NOB" != 1572864 ]; then
7460 error "Short read filed: read $NOB bytes instead of 1572864"
7464 run_test 131d "test short read"
7467 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
7468 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
7469 error "read hitting hole failed"
7472 run_test 131e "test read hitting hole"
7477 for node in $(osts_nodes); do
7478 gl=$(do_node $node "$LCTL get_param -n ost.OSS.ost.stats" | awk '/'$token'/ {print $2}' | head -n 1)
7479 [ x$gl = x"" ] && gl=0
7480 gl_sum=$((gl_sum + gl))
7490 if [ x$som = x"enabled" ]; then
7491 [ $((gl2 - gl1)) -gt 0 ] && error "no glimpse RPC is expected"
7492 MOUNTOPT=`echo $MOUNTOPT | sed 's/som_preview//g'`
7493 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=disabled"
7495 [ $((gl2 - gl1)) -gt 0 ] || error "some glimpse RPC is expected"
7496 MOUNTOPT="$MOUNTOPT,som_preview"
7497 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=enabled"
7500 # do remount to make new mount-conf parameters actual
7507 test_132() { #1028, SOM
7508 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7509 local num=$(get_mds_dir $DIR)
7510 local mymds=mds${num}
7511 local MOUNTOPT_SAVE=$MOUNTOPT
7513 dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
7514 cancel_lru_locks osc
7516 som1=$(do_facet $mymds "$LCTL get_param mdt.*.som" | awk -F= ' {print $2}' | head -n 1)
7518 gl1=$(get_ost_param "ldlm_glimpse_enqueue")
7519 stat $DIR/$tfile >/dev/null
7520 gl2=$(get_ost_param "ldlm_glimpse_enqueue")
7521 echo "====> SOM is "$som1", "$((gl2 - gl1))" glimpse RPC occured"
7523 som_mode_switch $som1 $gl1 $gl2
7525 dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
7526 cancel_lru_locks osc
7528 som2=$(do_facet $mymds "$LCTL get_param mdt.*.som" | awk -F= ' {print $2}' | head -n 1)
7529 if [ $som1 == $som2 ]; then
7530 error "som is still "$som2
7531 if [ x$som2 = x"enabled" ]; then
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 "$som2", "$((gl2 - gl1))" glimpse RPC occured"
7542 som_mode_switch $som2 $gl1 $gl2
7543 MOUNTOPT=$MOUNTOPT_SAVE
7545 run_test 132 "som avoids glimpse rpc"
7551 $SINGLEMDS) res=`do_facet $SINGLEMDS $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$2"`
7553 ost) res=`do_facet ost1 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$2"`
7555 *) error "Wrong argument $1" ;;
7558 count=`echo $res | awk '{print $2}'`
7559 [ -z "$res" ] && error "The counter for $2 on $1 was not incremented"
7560 # if the argument $3 is zero, it means any stat increment is ok.
7561 if [ $3 -gt 0 ] ; then
7562 [ $count -ne $3 ] && error "The $2 counter on $1 is wrong - expected $3"
7567 remote_ost_nodsh && skip "remote OST with nodsh" && return
7568 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7570 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
7571 { skip "MDS doesn't support rename stats"; return; }
7572 local testdir=$DIR/${tdir}/stats_testdir
7573 mkdir -p $DIR/${tdir}
7576 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
7577 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
7579 # verify mdt stats first.
7580 mkdir ${testdir} || error "mkdir failed"
7581 check_stats $SINGLEMDS "mkdir" 1
7582 touch ${testdir}/${tfile} || "touch failed"
7583 check_stats $SINGLEMDS "open" 1
7584 check_stats $SINGLEMDS "close" 1
7585 mknod ${testdir}/${tfile}-pipe p || "mknod failed"
7586 check_stats $SINGLEMDS "mknod" 1
7587 rm -f ${testdir}/${tfile}-pipe || "pipe remove failed"
7588 check_stats $SINGLEMDS "unlink" 1
7589 rm -f ${testdir}/${tfile} || error "file remove failed"
7590 check_stats $SINGLEMDS "unlink" 2
7592 # remove working dir and check mdt stats again.
7593 rmdir ${testdir} || error "rmdir failed"
7594 check_stats $SINGLEMDS "rmdir" 1
7596 local testdir1=$DIR/${tdir}/stats_testdir1
7598 mkdir -p ${testdir1}
7599 touch ${testdir1}/test1
7600 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
7601 check_stats $SINGLEMDS "crossdir_rename" 1
7603 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
7604 check_stats $SINGLEMDS "samedir_rename" 1
7608 run_test 133a "Verifying MDT stats ========================================"
7611 remote_ost_nodsh && skip "remote OST with nodsh" && return
7612 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7613 local testdir=$DIR/${tdir}/stats_testdir
7614 mkdir -p ${testdir} || error "mkdir failed"
7615 touch ${testdir}/${tfile} || "touch failed"
7616 cancel_lru_locks mdc
7619 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
7620 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
7622 # extra mdt stats verification.
7623 chmod 444 ${testdir}/${tfile} || error "chmod failed"
7624 check_stats $SINGLEMDS "setattr" 1
7625 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
7626 if [ $(lustre_version_code $SINGLEMDS) -ne $(version_code 2.2.0) ]
7628 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
7629 check_stats $SINGLEMDS "getattr" 1
7631 $LFS df || error "lfs failed"
7632 check_stats $SINGLEMDS "statfs" 1
7636 run_test 133b "Verifying extra MDT stats =================================="
7639 remote_ost_nodsh && skip "remote OST with nodsh" && return
7640 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7641 local testdir=$DIR/${tdir}/stats_testdir
7642 mkdir -p ${testdir} || error "mkdir failed"
7644 # verify obdfilter stats.
7645 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
7647 cancel_lru_locks osc
7648 wait_delete_completed
7651 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
7652 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
7654 dd if=/dev/zero of=${testdir}/${tfile} conv=notrunc bs=512k count=1 || error "dd failed"
7656 cancel_lru_locks osc
7657 check_stats ost "write" 1
7659 dd if=${testdir}/${tfile} of=/dev/null bs=1k count=1 || error "dd failed"
7660 check_stats ost "read" 1
7662 > ${testdir}/${tfile} || error "truncate failed"
7663 check_stats ost "punch" 1
7665 rm -f ${testdir}/${tfile} || error "file remove failed"
7666 wait_delete_completed
7667 check_stats ost "destroy" 1
7671 run_test 133c "Verifying OST stats ========================================"
7678 while [ $value -ge 2 ]; do
7683 if [ $orig -gt $order ]; then
7691 local size=('K' 'M' 'G' 'T');
7693 local size_string=$value
7695 while [ $value -ge 1024 ]; do
7696 if [ $i -gt 3 ]; then
7697 #T is the biggest unit we get here, if that is bigger,
7699 size_string=${value}T
7702 value=$((value >> 10))
7703 if [ $value -lt 1024 ]; then
7704 size_string=${value}${size[$i]}
7715 local context=${2:-.}
7716 local sample=$(do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats |
7718 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
7723 remote_ost_nodsh && skip "remote OST with nodsh" && return
7724 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7725 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
7726 { skip "MDS doesn't support rename stats"; return; }
7728 local testdir1=$DIR/${tdir}/stats_testdir1
7729 local testdir2=$DIR/${tdir}/stats_testdir2
7731 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
7733 mkdir -p ${testdir1} || error "mkdir failed"
7734 mkdir -p ${testdir2} || error "mkdir failed"
7736 createmany -o $testdir1/test 512 || error "createmany failed"
7738 # check samedir rename size
7739 mv ${testdir1}/test0 ${testdir1}/test_0
7741 local testdir1_size=$(ls -l $DIR/${tdir} |
7742 awk '/stats_testdir1/ {print $5}')
7743 local testdir2_size=$(ls -l $DIR/${tdir} |
7744 awk '/stats_testdir2/ {print $5}')
7746 testdir1_size=$(order_2 $testdir1_size)
7747 testdir2_size=$(order_2 $testdir2_size)
7749 testdir1_size=$(size_in_KMGT $testdir1_size)
7750 testdir2_size=$(size_in_KMGT $testdir2_size)
7752 echo "source rename dir size: ${testdir1_size}"
7753 echo "target rename dir size: ${testdir2_size}"
7755 local cmd="do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats"
7756 eval $cmd || error "$cmd failed"
7757 local samedir=$($cmd | grep 'same_dir')
7758 local same_sample=$(get_rename_size $testdir1_size)
7759 [ -z "$samedir" ] && error "samedir_rename_size count error"
7760 [ "$same_sample" -eq 1 ] || error "samedir_rename_size error $same_sample"
7761 echo "Check same dir rename stats success"
7763 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
7765 # check crossdir rename size
7766 mv ${testdir1}/test_0 ${testdir2}/test_0
7768 testdir1_size=$(ls -l $DIR/${tdir} |
7769 awk '/stats_testdir1/ {print $5}')
7770 testdir2_size=$(ls -l $DIR/${tdir} |
7771 awk '/stats_testdir2/ {print $5}')
7773 testdir1_size=$(order_2 $testdir1_size)
7774 testdir2_size=$(order_2 $testdir2_size)
7776 testdir1_size=$(size_in_KMGT $testdir1_size)
7777 testdir2_size=$(size_in_KMGT $testdir2_size)
7779 echo "source rename dir size: ${testdir1_size}"
7780 echo "target rename dir size: ${testdir2_size}"
7782 eval $cmd || error "$cmd failed"
7783 local crossdir=$($cmd | grep 'crossdir')
7784 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
7785 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
7786 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
7787 [ "$src_sample" -eq 1 ] || error "crossdir_rename_size error $src_sample"
7788 [ "$tgt_sample" -eq 1 ] || error "crossdir_rename_size error $tgt_sample"
7789 echo "Check cross dir rename stats success"
7792 run_test 133d "Verifying rename_stats ========================================"
7794 test_140() { #bug-17379
7795 mkdir -p $DIR/$tdir || error "Creating dir $DIR/$tdir"
7796 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
7797 cp /usr/bin/stat . || error "Copying stat to $DIR/$tdir"
7799 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
7800 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
7802 while i=`expr $i + 1`; do
7803 mkdir -p $i || error "Creating dir $i"
7804 cd $i || error "Changing to $i"
7805 ln -s ../stat stat || error "Creating stat symlink"
7806 # Read the symlink until ELOOP present,
7807 # not LBUGing the system is considered success,
7808 # we didn't overrun the stack.
7809 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
7811 if [ $ret -eq 40 ]; then
7814 error "Open stat symlink"
7820 echo "The symlink depth = $i"
7821 [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 -o $i -eq 40 ] ||
7822 error "Invalid symlink depth"
7824 # Test recursive symlink
7825 ln -s symlink_self symlink_self
7826 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
7827 echo "open symlink_self returns $ret"
7828 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
7830 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
7833 local TF="$TMP/$tfile"
7835 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
7837 cancel_lru_locks osc
7838 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
7839 remount_client $MOUNT
7841 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
7844 $TRUNCATE $DIR/$tfile 6000
7845 cancel_lru_locks osc
7846 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
7849 echo "12345" >>$DIR/$tfile
7850 cancel_lru_locks osc
7851 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
7854 echo "12345" >>$DIR/$tfile
7855 cancel_lru_locks osc
7856 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
7861 run_test 150 "truncate/append tests"
7863 function roc_hit() {
7864 local list=$(comma_list $(osts_nodes))
7866 echo $(get_obdfilter_param $list '' stats |
7867 awk '/'cache_hit'/ {sum+=$2} END {print sum}')
7870 function set_cache() {
7873 if [ "$2" == "off" ]; then
7876 local list=$(comma_list $(osts_nodes))
7877 set_obdfilter_param $list '' $1_cache_enable $on
7879 cancel_lru_locks osc
7883 remote_ost_nodsh && skip "remote OST with nodsh" && return
7886 local list=$(comma_list $(osts_nodes))
7888 # check whether obdfilter is cache capable at all
7889 if ! get_obdfilter_param $list '' read_cache_enable >/dev/null; then
7890 echo "not cache-capable obdfilter"
7894 # check cache is enabled on all obdfilters
7895 if get_obdfilter_param $list '' read_cache_enable | grep 0; then
7896 echo "oss cache is disabled"
7900 set_obdfilter_param $list '' writethrough_cache_enable 1
7902 # pages should be in the case right after write
7903 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES || error "dd failed"
7904 local BEFORE=`roc_hit`
7905 cancel_lru_locks osc
7906 cat $DIR/$tfile >/dev/null
7907 local AFTER=`roc_hit`
7908 if ! let "AFTER - BEFORE == CPAGES"; then
7909 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
7912 # the following read invalidates the cache
7913 cancel_lru_locks osc
7914 set_obdfilter_param $list '' read_cache_enable 0
7915 cat $DIR/$tfile >/dev/null
7917 # now data shouldn't be found in the cache
7919 cancel_lru_locks osc
7920 cat $DIR/$tfile >/dev/null
7922 if let "AFTER - BEFORE != 0"; then
7923 error "IN CACHE: before: $BEFORE, after: $AFTER"
7926 set_obdfilter_param $list '' read_cache_enable 1
7929 run_test 151 "test cache on oss and controls ==============================="
7932 local TF="$TMP/$tfile"
7934 # simulate ENOMEM during write
7935 #define OBD_FAIL_OST_NOMEM 0x226
7936 lctl set_param fail_loc=0x80000226
7937 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
7939 sync || error "sync failed"
7940 lctl set_param fail_loc=0
7942 # discard client's cache
7943 cancel_lru_locks osc
7945 # simulate ENOMEM during read
7946 lctl set_param fail_loc=0x80000226
7947 cmp $TF $DIR/$tfile || error "cmp failed"
7948 lctl set_param fail_loc=0
7952 run_test 152 "test read/write with enomem ============================"
7955 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
7957 run_test 153 "test if fdatasync does not crash ======================="
7960 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
7961 { skip "Need MDS version at least 2.2.51"; return 0; }
7963 cp /etc/hosts $DIR/$tfile
7965 fid=$($LFS path2fid $DIR/$tfile)
7967 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
7969 ffid=$DIR/.lustre/fid/$fid
7971 echo "stat fid $fid"
7972 stat $ffid > /dev/null || error "stat $ffid failed."
7973 echo "touch fid $fid"
7974 touch $ffid || error "touch $ffid failed."
7975 echo "write to fid $fid"
7976 cat /etc/hosts > $ffid || error "write $ffid failed."
7977 echo "read fid $fid"
7978 diff /etc/hosts $ffid || error "read $ffid failed."
7979 echo "append write to fid $fid"
7980 cat /etc/hosts >> $ffid || error "append write $ffid failed."
7981 echo "rename fid $fid"
7982 mv $ffid $DIR/$tfile.1 && error "rename $ffid to $tfile.1 should fail."
7984 mv $DIR/$tfile.1 $ffid && error "rename $tfile.1 to $ffid should fail."
7986 echo "truncate fid $fid"
7987 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
7988 echo "link fid $fid"
7989 ln -f $ffid $DIR/tfile.lnk || error "link $ffid failed."
7990 if [ -n $(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl) ]; then
7991 echo "setfacl fid $fid"
7992 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
7993 echo "getfacl fid $fid"
7994 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
7996 echo "unlink fid $fid"
7997 unlink $DIR/.lustre/fid/$fid && error "unlink $ffid should fail."
7998 echo "mknod fid $fid"
7999 mknod $ffid c 1 3 && error "mknod $ffid should fail."
8001 fid=[0xf00000400:0x1:0x0]
8002 ffid=$DIR/.lustre/fid/$fid
8004 echo "stat non-exist fid $fid"
8005 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
8006 echo "write to non-exist fid $fid"
8007 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
8008 echo "link new fid $fid"
8009 ln $DIR/$tfile $ffid && error "link $ffid should fail."
8012 touch $DIR/$tdir/$tfile
8013 fid=$($LFS path2fid $DIR/$tdir)
8015 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
8017 ffid=$DIR/.lustre/fid/$fid
8020 ls $ffid > /dev/null || error "ls $ffid failed."
8021 echo "touch $fid/$tfile.1"
8022 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
8024 echo "touch $DIR/.lustre/fid/$tfile"
8025 touch $DIR/.lustre/fid/$tfile && \
8026 error "touch $DIR/.lustre/fid/$tfile should fail."
8028 echo "setxattr to $DIR/.lustre/fid"
8029 setfattr -n trusted.name1 -v value1 $DIR/.lustre/fid &&
8030 error "setxattr should fail."
8032 echo "listxattr for $DIR/.lustre/fid"
8033 getfattr -d -m "^trusted" $DIR/.lustre/fid &&
8034 error "listxattr should fail."
8036 echo "delxattr from $DIR/.lustre/fid"
8037 setfattr -x trusted.name1 $DIR/.lustre/fid &&
8038 error "delxattr should fail."
8040 echo "touch invalid fid: $DIR/.lustre/fid/[0x200000400:0x2:0x3]"
8041 touch $DIR/.lustre/fid/[0x200000400:0x2:0x3] &&
8042 error "touch invalid fid should fail."
8044 echo "touch non-normal fid: $DIR/.lustre/fid/[0x1:0x2:0x0]"
8045 touch $DIR/.lustre/fid/[0x1:0x2:0x0] &&
8046 error "touch non-normal fid should fail."
8048 echo "rename $tdir to $DIR/.lustre/fid"
8049 mrename $DIR/$tdir $DIR/.lustre/fid &&
8050 error "rename to $DIR/.lustre/fid should fail."
8052 echo "rename .lustre to itself"
8053 fid=$($LFS path2fid $DIR)
8054 mrename $DIR/.lustre $DIR/.lustre/fid/$fid/.lustre &&
8055 error "rename .lustre to itself should fail."
8057 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $DIR/$tfile-2
8058 fid=$($LFS path2fid $DIR/$tfile-2)
8059 echo "cp /etc/passwd $DIR/.lustre/fid/$fid"
8060 cp /etc/passwd $DIR/.lustre/fid/$fid &&
8061 error "create lov data thru .lustre should fail."
8062 echo "cp /etc/passwd $DIR/$tfile-2"
8063 cp /etc/passwd $DIR/$tfile-2 || error "copy to $DIR/$tfile-2 failed."
8064 echo "diff /etc/passwd $DIR/.lustre/fid/$fid"
8065 diff /etc/passwd $DIR/.lustre/fid/$fid ||
8066 error "diff /etc/passwd $DIR/.lustre/fid/$fid failed."
8068 echo "Open-by-FID succeeded"
8070 run_test 154 "Open-by-FID"
8072 test_155_small_load() {
8073 local temp=$TMP/$tfile
8074 local file=$DIR/$tfile
8076 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
8077 error "dd of=$temp bs=6096 count=1 failed"
8079 cancel_lru_locks osc
8080 cmp $temp $file || error "$temp $file differ"
8082 $TRUNCATE $temp 6000
8083 $TRUNCATE $file 6000
8084 cmp $temp $file || error "$temp $file differ (truncate1)"
8086 echo "12345" >>$temp
8087 echo "12345" >>$file
8088 cmp $temp $file || error "$temp $file differ (append1)"
8090 echo "12345" >>$temp
8091 echo "12345" >>$file
8092 cmp $temp $file || error "$temp $file differ (append2)"
8098 test_155_big_load() {
8099 remote_ost_nodsh && skip "remote OST with nodsh" && return
8100 local temp=$TMP/$tfile
8101 local file=$DIR/$tfile
8104 local cache_size=$(do_facet ost$((MAXI+1)) \
8105 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
8106 local large_file_size=$((cache_size * 2))
8108 echo "OSS cache size: $cache_size KB"
8109 echo "Large file size: $large_file_size KB"
8111 [ $MAXV -le $large_file_size ] && \
8112 skip_env "max available OST size needs > $large_file_size KB" && \
8115 $SETSTRIPE $file -c 1 -i $MAXI || error "$SETSTRIPE $file failed"
8117 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k || \
8118 error "dd of=$temp bs=$large_file_size count=1k failed"
8121 cancel_lru_locks osc
8122 cmp $temp $file || error "$temp $file differ"
8130 set_cache writethrough on
8133 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
8137 set_cache writethrough off
8140 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
8144 set_cache writethrough on
8147 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
8151 set_cache writethrough off
8154 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
8158 set_cache writethrough on
8161 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
8165 set_cache writethrough off
8168 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
8172 set_cache writethrough on
8175 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
8179 set_cache writethrough off
8182 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
8188 local file="$DIR/$tfile"
8190 [ "$(facet_fstype ost1)" = "zfs" ] &&
8191 skip "LU-1956/LU-2261: stats unimplemented on OSD ZFS" &&
8194 log "Turn on read and write cache"
8196 set_cache writethrough on
8198 log "Write data and read it back."
8199 log "Read should be satisfied from the cache."
8200 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
8202 cancel_lru_locks osc
8203 cat $file >/dev/null
8205 if ! let "AFTER - BEFORE == CPAGES"; then
8206 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
8208 log "cache hits:: before: $BEFORE, after: $AFTER"
8211 log "Read again; it should be satisfied from the cache."
8213 cancel_lru_locks osc
8214 cat $file >/dev/null
8216 if ! let "AFTER - BEFORE == CPAGES"; then
8217 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
8219 log "cache hits:: before: $BEFORE, after: $AFTER"
8223 log "Turn off the read cache and turn on the write cache"
8225 set_cache writethrough on
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"
8238 log "Read again; it should not be satisfied from the cache."
8240 cancel_lru_locks osc
8241 cat $file >/dev/null
8243 if ! let "AFTER - BEFORE == 0"; then
8244 error "IN CACHE: before: $BEFORE, after: $AFTER"
8246 log "cache hits:: before: $BEFORE, after: $AFTER"
8249 log "Write data and read it back."
8250 log "Read should be satisfied from the cache."
8251 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
8253 cancel_lru_locks osc
8254 cat $file >/dev/null
8256 if ! let "AFTER - BEFORE == CPAGES"; then
8257 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
8259 log "cache hits:: before: $BEFORE, after: $AFTER"
8262 log "Read again; it should not be satisfied from the cache."
8264 cancel_lru_locks osc
8265 cat $file >/dev/null
8267 if ! let "AFTER - BEFORE == 0"; then
8268 error "IN CACHE: before: $BEFORE, after: $AFTER"
8270 log "cache hits:: before: $BEFORE, after: $AFTER"
8274 log "Turn off read and write cache"
8276 set_cache writethrough off
8278 log "Write data and read it back"
8279 log "It should not be satisfied from the cache."
8281 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
8282 cancel_lru_locks osc
8284 cat $file >/dev/null
8286 if ! let "AFTER - BEFORE == 0"; then
8287 error_ignore 20762 "IN CACHE: before: $BEFORE, after: $AFTER"
8289 log "cache hits:: before: $BEFORE, after: $AFTER"
8293 log "Turn on the read cache and turn off the write cache"
8295 set_cache writethrough off
8297 log "Write data and read it back"
8298 log "It should not be satisfied from the cache."
8300 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
8302 cancel_lru_locks osc
8303 cat $file >/dev/null
8305 if ! let "AFTER - BEFORE == 0"; then
8306 error_ignore 20762 "IN CACHE: before: $BEFORE, after: $AFTER"
8308 log "cache hits:: before: $BEFORE, after: $AFTER"
8311 log "Read again; it should be satisfied from the cache."
8313 cancel_lru_locks osc
8314 cat $file >/dev/null
8316 if ! let "AFTER - BEFORE == CPAGES"; then
8317 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
8319 log "cache hits:: before: $BEFORE, after: $AFTER"
8324 run_test 156 "Verification of tunables ============================"
8328 if [ $MDSCOUNT -gt 1 ]; then
8329 error_ignore 17935 $*
8337 MASK=$(do_facet $SINGLEMDS $LCTL get_param mdd.$MDT0.changelog_mask |\
8340 if [ $MASK -eq 1 ]; then
8341 do_facet $SINGLEMDS $LCTL set_param mdd.$MDT0.changelog_mask="-$1"
8343 do_facet $SINGLEMDS $LCTL set_param mdd.$MDT0.changelog_mask="+$1"
8348 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8349 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
8350 { skip "Need MDS version at least 2.2.0"; return; }
8351 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
8352 echo "Registered as changelog user $USER"
8353 do_facet $SINGLEMDS $LCTL get_param -n mdd.$MDT0.changelog_users | \
8354 grep -q $USER || error "User $USER not found in changelog_users"
8357 mkdir -p $DIR/$tdir/pics/2008/zachy
8358 touch $DIR/$tdir/pics/2008/zachy/timestamp
8359 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
8360 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
8361 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
8362 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
8363 rm $DIR/$tdir/pics/desktop.jpg
8365 $LFS changelog $MDT0 | tail -5
8367 echo "verifying changelog mask"
8368 changelog_chmask "MKDIR"
8369 changelog_chmask "CLOSE"
8371 mkdir -p $DIR/$tdir/pics/zach/sofia
8372 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
8374 changelog_chmask "MKDIR"
8375 changelog_chmask "CLOSE"
8377 mkdir -p $DIR/$tdir/pics/2008/sofia
8378 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
8380 $LFS changelog $MDT0
8381 MKDIRS=$($LFS changelog $MDT0 | tail -5 | grep -c "MKDIR")
8382 CLOSES=$($LFS changelog $MDT0 | tail -5 | grep -c "CLOSE")
8383 [ $MKDIRS -eq 1 ] || err17935 "MKDIR changelog mask count $DIRS != 1"
8384 [ $CLOSES -eq 1 ] || err17935 "CLOSE changelog mask count $DIRS != 1"
8387 echo "verifying target fid"
8388 fidc=$($LFS changelog $MDT0 | grep timestamp | grep "CREAT" | \
8389 tail -1 | awk '{print $6}')
8390 fidf=$($LFS path2fid $DIR/$tdir/pics/zach/timestamp)
8391 [ "$fidc" == "t=$fidf" ] || \
8392 err17935 "fid in changelog $fidc != file fid $fidf"
8393 echo "verifying parent fid"
8394 fidc=$($LFS changelog $MDT0 | grep timestamp | grep "CREAT" | \
8395 tail -1 | awk '{print $7}')
8396 fidf=$($LFS path2fid $DIR/$tdir/pics/zach)
8397 [ "$fidc" == "p=$fidf" ] || \
8398 err17935 "pfid in changelog $fidc != dir fid $fidf"
8400 USER_REC1=$(do_facet $SINGLEMDS $LCTL get_param -n \
8401 mdd.$MDT0.changelog_users | grep $USER | awk '{print $2}')
8402 $LFS changelog_clear $MDT0 $USER $(($USER_REC1 + 5))
8403 USER_REC2=$(do_facet $SINGLEMDS $LCTL get_param -n \
8404 mdd.$MDT0.changelog_users | grep $USER | awk '{print $2}')
8405 echo "verifying user clear: $(( $USER_REC1 + 5 )) == $USER_REC2"
8406 [ $USER_REC2 == $(($USER_REC1 + 5)) ] || \
8407 err17935 "user index should be $(($USER_REC1 + 5)); is $USER_REC2"
8409 MIN_REC=$(do_facet $SINGLEMDS $LCTL get_param mdd.$MDT0.changelog_users | \
8410 awk 'min == "" || $2 < min {min = $2}; END {print min}')
8411 FIRST_REC=$($LFS changelog $MDT0 | head -1 | awk '{print $1}')
8412 echo "verifying min purge: $(( $MIN_REC + 1 )) == $FIRST_REC"
8413 [ $FIRST_REC == $(($MIN_REC + 1)) ] || \
8414 err17935 "first index should be $(($MIN_REC + 1)); is $FIRST_REC"
8416 echo "verifying user deregister"
8417 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
8418 do_facet $SINGLEMDS $LCTL get_param -n mdd.$MDT0.changelog_users | \
8419 grep -q $USER && error "User $USER still found in changelog_users"
8421 USERS=$(( $(do_facet $SINGLEMDS $LCTL get_param -n \
8422 mdd.$MDT0.changelog_users | wc -l) - 2 ))
8423 if [ $USERS -eq 0 ]; then
8424 LAST_REC1=$(do_facet $SINGLEMDS $LCTL get_param -n \
8425 mdd.$MDT0.changelog_users | head -1 | awk '{print $3}')
8426 touch $DIR/$tdir/chloe
8427 LAST_REC2=$(do_facet $SINGLEMDS $LCTL get_param -n \
8428 mdd.$MDT0.changelog_users | head -1 | awk '{print $3}')
8429 echo "verify changelogs are off if we were the only user: $LAST_REC1 == $LAST_REC2"
8430 [ $LAST_REC1 == $LAST_REC2 ] || error "changelogs not off"
8432 echo "$USERS other changelog users; can't verify off"
8435 run_test 160 "changelog sanity"
8439 cp /etc/hosts $DIR/$tdir/$tfile
8440 mkdir $DIR/$tdir/foo1
8441 mkdir $DIR/$tdir/foo2
8442 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
8443 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
8444 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
8445 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
8446 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[')
8447 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
8448 $LFS fid2path $DIR $FID
8449 err17935 "bad link ea"
8452 rm $DIR/$tdir/foo2/zachary
8454 rm $DIR/$tdir/foo2/thor
8456 rm $DIR/$tdir/$tfile
8458 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
8459 if [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ]
8461 $LFS fid2path $DIR $FID
8462 err17935 "bad link rename"
8464 rm $DIR/$tdir/foo2/maggie
8467 local longname=filename_avg_len_is_thirty_two_
8468 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 || \
8469 error "failed to hardlink many files"
8470 links=$($LFS fid2path $DIR $FID | wc -l)
8471 echo -n "${links}/1000 links in link EA"
8472 [ ${links} -gt 60 ] || err17935 "expected at least 60 links in link EA"
8473 unlinkmany $DIR/$tdir/foo2/$longname 1000 || \
8474 error "failed to unlink many hardlinks"
8476 run_test 161 "link ea sanity"
8483 local path=$(${LFS} fid2path $*)
8486 if [ $RC -ne 0 ]; then
8487 err17935 "path looked up of $expected failed. Error $RC"
8489 elif [ "${path}" != "${expected}" ]; then
8490 err17935 "path looked up \"${path}\" instead of \"${expected}\""
8493 echo "fid $fid resolves to path $path (expected $expected)"
8497 # Make changes to filesystem
8498 mkdir -p $DIR/$tdir/d2
8499 touch $DIR/$tdir/d2/$tfile
8500 touch $DIR/$tdir/d2/x1
8501 touch $DIR/$tdir/d2/x2
8502 mkdir -p $DIR/$tdir/d2/a/b/c
8503 mkdir -p $DIR/$tdir/d2/p/q/r
8505 FID=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
8506 check_path "$tdir/d2/$tfile" $FSNAME $FID --link 0
8509 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
8510 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
8511 check_path "$tdir/d2/p/q/r/slink" $FSNAME $FID --link 0
8513 # softlink to wrong file
8514 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
8515 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
8516 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME $FID --link 0
8519 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
8520 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
8521 FID=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
8522 # fid2path dir/fsname should both work
8523 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 1
8524 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR $FID --link 0
8526 # hardlink count: check that there are 2 links
8527 # Doesnt work with CMD yet: 17935
8528 ${LFS} fid2path $DIR $FID | wc -l | grep -q 2 || \
8529 err17935 "expected 2 links"
8531 # hardlink indexing: remove the first link
8532 rm $DIR/$tdir/d2/p/q/r/hlink
8533 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 0
8537 run_test 162 "path lookup sanity"
8540 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8541 copytool --test $FSNAME || { skip "copytool not runnable: $?" && return; }
8544 local uuid=$($LCTL get_param -n mdc.${FSNAME}-MDT0000-mdc-*.uuid)
8545 # this proc file is temporary and linux-only
8546 do_facet $SINGLEMDS lctl set_param mdt.${FSNAME}-MDT0000.mdccomm=$uuid ||\
8547 error "kernel->userspace send failed"
8550 run_test 163 "kernel <-> userspace comms"
8553 # do directio so as not to populate the page cache
8554 log "creating a 10 Mb file"
8555 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
8556 log "starting reads"
8557 dd if=$DIR/$tfile of=/dev/null bs=4096 &
8558 log "truncating the file"
8559 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
8561 kill %+ || true # reads might have finished
8562 echo "wait until dd is finished"
8564 log "removing the temporary file"
8565 rm -rf $DIR/$tfile || error "tmp file removal failed"
8567 run_test 169 "parallel read and truncate should not deadlock"
8570 $LCTL clear # bug 18514
8571 $LCTL debug_daemon start $TMP/${tfile}_log_good
8573 $LCTL debug_daemon stop
8574 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
8575 error "sed failed to read log_good"
8577 $LCTL debug_daemon start $TMP/${tfile}_log_good
8579 $LCTL debug_daemon stop
8581 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
8582 error "lctl df log_bad failed"
8584 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
8585 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
8587 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
8588 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
8590 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
8591 error "bad_line good_line1 good_line2 are empty"
8593 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
8594 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
8595 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
8597 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
8598 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
8599 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
8601 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
8602 error "bad_line_new good_line_new are empty"
8604 local expected_good=$((good_line1 + good_line2*2))
8606 rm -f $TMP/${tfile}*
8607 # LU-231, short malformed line may not be counted into bad lines
8608 if [ $bad_line -ne $bad_line_new ] &&
8609 [ $bad_line -ne $((bad_line_new - 1)) ]; then
8610 error "expected $bad_line bad lines, but got $bad_line_new"
8614 if [ $expected_good -ne $good_line_new ]; then
8615 error "expected $expected_good good lines, but got $good_line_new"
8620 run_test 170 "test lctl df to handle corrupted log ====================="
8622 test_171() { # bug20592
8623 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
8624 $LCTL set_param fail_loc=0x50e
8625 $LCTL set_param fail_val=3000
8626 multiop_bg_pause $DIR/$tfile O_s || true
8628 kill -USR1 $MULTIPID
8632 if dmesg | grep "recursive fault"; then
8633 error "caught a recursive fault"
8635 $LCTL set_param fail_loc=0
8638 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
8640 # it would be good to share it with obdfilter-survey/libecho code
8641 setup_obdecho_osc () {
8644 local obdfilter_name=$2
8645 echo "Creating new osc for $obdfilter_name on $ost_nid"
8646 # make sure we can find loopback nid
8647 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
8649 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
8650 ${obdfilter_name}_osc_UUID || rc=2; }
8651 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
8652 ${obdfilter_name}_UUID $ost_nid || rc=3; }
8656 cleanup_obdecho_osc () {
8657 local obdfilter_name=$1
8658 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
8659 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
8663 obdecho_create_test() {
8668 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
8669 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
8671 if [ $rc -eq 0 ]; then
8672 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
8673 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
8675 echo "New object id is $id"
8676 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec test_brw 10 w v 64 $id" ||
8678 [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec " \
8679 "cleanup" || rc=5; }
8680 [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec " \
8682 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
8687 remote_ost_nodsh && skip "remote OST with nodsh" && return
8691 if ! module_loaded obdecho; then
8692 load_module obdecho/obdecho
8696 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
8697 local host=$(lctl get_param -n osc.$osc.import |
8698 awk '/current_connection:/ {print $2}' )
8699 local target=$(lctl get_param -n osc.$osc.import |
8700 awk '/target:/ {print $2}' )
8701 target=${target%_UUID}
8703 [[ -n $target ]] && { setup_obdecho_osc $host $target || rc=1; } || rc=1
8704 [ $rc -eq 0 ] && { obdecho_create_test ${target}_osc client || rc=2; }
8705 [[ -n $target ]] && cleanup_obdecho_osc $target
8706 [ $rmmod_local -eq 1 ] && rmmod obdecho
8709 run_test 180a "test obdecho on osc"
8712 remote_ost_nodsh && skip "remote OST with nodsh" && return
8714 local rmmod_remote=0
8716 do_facet ost1 "lsmod | grep -q obdecho || " \
8717 "{ insmod ${LUSTRE}/obdecho/obdecho.ko || " \
8718 "modprobe obdecho; }" && rmmod_remote=1
8719 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ {print $4;exit}')
8720 [[ -n $target ]] && { obdecho_create_test $target ost1 || rc=1; }
8721 [ $rmmod_remote -eq 1 ] && do_facet ost1 "rmmod obdecho"
8724 run_test 180b "test obdecho directly on obdfilter"
8726 test_181() { # bug 22177
8727 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
8728 # create enough files to index the directory
8729 createmany -o $DIR/$tdir/foobar 4000
8730 # print attributes for debug purpose
8733 multiop_bg_pause $DIR/$tdir D_Sc || return 1
8735 # remove the files & current working dir
8736 unlinkmany $DIR/$tdir/foobar 4000
8738 kill -USR1 $MULTIPID
8740 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
8743 run_test 181 "Test open-unlinked dir ========================"
8746 # disable MDC RPC lock wouldn't crash client
8750 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
8751 #define OBD_FAIL_MDC_RPCS_SEM 0x804
8752 $LCTL set_param fail_loc=0x804
8754 for (( i=0; i < $tcount; i++ )) ; do
8756 createmany -o $DIR/$tdir/$i/f- $fcount &
8760 for (( i=0; i < $tcount; i++ )) ; do
8761 unlinkmany $DIR/$tdir/$i/f- $fcount &
8767 $LCTL set_param fail_loc=0
8769 run_test 182 "Disable MDC RPCs semaphore wouldn't crash client ================"
8771 test_183() { # LU-2275
8772 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
8773 echo aaa > $DIR/$tdir/$tfile
8775 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
8776 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
8778 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
8779 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
8781 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
8783 # Flush negative dentry cache
8784 touch $DIR/$tdir/$tfile
8786 # We are not checking for any leaked references here, they'll
8787 # become evident next time we do cleanup with module unload.
8790 run_test 183 "No crash or request leak in case of strange dispositions ========"
8793 check_file_in_pool()
8798 local res=$($GETSTRIPE $file | grep 0x | cut -f2)
8801 for t in $tlist ; do
8802 [ "$i" -eq "$t" ] && continue 2
8805 echo "pool list: $tlist"
8806 echo "striping: $res"
8807 error_noexit "$file not allocated in $pool"
8814 echo "Creating new pool"
8817 create_pool $FSNAME.$pool ||
8818 { error_noexit "No pool created, result code $?"; return 1; }
8819 [ $($LFS pool_list $FSNAME | grep -c $pool) -eq 1 ] ||
8820 { error_noexit "$pool not in lfs pool_list"; return 2; }
8823 pool_add_targets() {
8824 echo "Adding targets to pool"
8830 local list=$(seq $first $step $last)
8832 local t=$(for i in $list; do printf "$FSNAME-OST%04x_UUID " $i; done)
8833 do_facet mgs $LCTL pool_add \
8834 $FSNAME.$pool $FSNAME-OST[$first-$last/$step]
8835 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$pool \
8836 | sort -u | tr '\n' ' ' " "$t" || {
8837 error_noexit "Add to pool failed"
8840 local lfscount=$($LFS pool_list $FSNAME.$pool | grep -c "\-OST")
8841 local addcount=$(((last - first) / step + 1))
8842 [ $lfscount -eq $addcount ] || {
8843 error_noexit "lfs pool_list bad ost count" \
8844 "$lfscount != $addcount"
8852 echo "Setting pool on directory $tdir"
8854 $SETSTRIPE -c 2 -p $pool $tdir && return 0
8856 error_noexit "Cannot set pool $pool to $tdir"
8863 echo "Checking pool on directory $tdir"
8865 local res=$($GETSTRIPE --pool $tdir | sed "s/\s*$//")
8866 [ "$res" = "$pool" ] && return 0
8868 error_noexit "Pool on '$tdir' is '$res', not '$pool'"
8872 pool_dir_rel_path() {
8873 echo "Testing relative path works well"
8878 mkdir -p $root/$tdir/$tdir
8880 pool_set_dir $pool $tdir || return 1
8881 pool_set_dir $pool ./$tdir || return 2
8882 pool_set_dir $pool ../$tdir || return 3
8883 pool_set_dir $pool ../$tdir/$tdir || return 4
8884 rm -rf $tdir; cd - > /dev/null
8887 pool_alloc_files() {
8888 echo "Checking files allocation from directory pool"
8895 for i in $(seq -w 1 $count)
8897 local file=$tdir/file-$i
8899 check_file_in_pool $file $pool "$tlist" || \
8900 failed=$((failed + 1))
8902 [ "$failed" = 0 ] && return 0
8904 error_noexit "$failed files not allocated in $pool"
8908 pool_create_files() {
8909 echo "Creating files in pool"
8917 for i in $(seq -w 1 $count)
8919 local file=$tdir/spoo-$i
8920 $SETSTRIPE -p $pool $file
8921 check_file_in_pool $file $pool "$tlist" || \
8922 failed=$((failed + 1))
8924 [ "$failed" = 0 ] && return 0
8926 error_noexit "$failed files not allocated in $pool"
8931 echo "Checking 'lfs df' output"
8934 local t=$($LCTL get_param -n lov.$FSNAME-clilov-*.pools.$pool |
8936 local res=$($LFS df --pool $FSNAME.$pool |
8938 grep "$FSNAME-OST" |
8940 [ "$res" = "$t" ] && return 0
8942 error_noexit "Pools OSTs '$t' is not '$res' that lfs df reports"
8946 pool_file_rel_path() {
8947 echo "Creating files in a pool with relative pathname"
8952 { error_noexit "unable to create $tdir"; return 1 ; }
8953 local file="/..$tdir/$tfile-1"
8954 $SETSTRIPE -p $pool $file ||
8955 { error_noexit "unable to create $file" ; return 2 ; }
8958 $SETSTRIPE -p $pool $tfile-2 || {
8959 error_noexit "unable to create $tfile-2 in $tdir"
8964 pool_remove_first_target() {
8965 echo "Removing first target from a pool"
8968 local pname="lov.$FSNAME-*.pools.$pool"
8969 local t=$($LCTL get_param -n $pname | head -1)
8970 do_facet mgs $LCTL pool_remove $FSNAME.$pool $t
8971 wait_update $HOSTNAME "lctl get_param -n $pname | grep $t" "" || {
8972 error_noexit "$t not removed from $FSNAME.$pool"
8977 pool_remove_all_targets() {
8978 echo "Removing all targets from pool"
8981 local pname="lov.$FSNAME-*.pools.$pool"
8982 for t in $($LCTL get_param -n $pname | sort -u)
8984 do_facet mgs $LCTL pool_remove $FSNAME.$pool $t
8986 wait_update $HOSTNAME "lctl get_param -n $pname" "" || {
8987 error_noexit "Pool $FSNAME.$pool cannot be drained"
8990 # striping on an empty/nonexistant pool should fall back
8991 # to "pool of everything"
8993 error_noexit "failed to use fallback striping for empty pool"
8996 # setstripe on an empty pool should fail
8997 $SETSTRIPE -p $pool $file 2>/dev/null && {
8998 error_noexit "expected failure when creating file" \
9006 echo "Destroying pool"
9010 do_facet mgs $LCTL pool_destroy $FSNAME.$pool
9013 # striping on an empty/nonexistant pool should fall back
9014 # to "pool of everything"
9016 error_noexit "failed to use fallback striping for missing pool"
9019 # setstripe on an empty pool should fail
9020 $SETSTRIPE -p $pool $file 2>/dev/null && {
9021 error_noexit "expected failure when creating file" \
9026 # get param should return err once pool is gone
9027 if wait_update $HOSTNAME "lctl get_param -n \
9028 lov.$FSNAME-*.pools.$pool 2>/dev/null || echo foo" "foo"
9030 remove_pool_from_list $FSNAME.$pool
9033 error_noexit "Pool $FSNAME.$pool is not destroyed"
9038 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
9040 local POOL=${POOL:-cea1}
9041 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
9042 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
9045 local last_ost=$(($OSTCOUNT - 1))
9047 local ost_list=$(seq $first_ost $ost_step $last_ost)
9048 local ost_range="$first_ost $last_ost $ost_step"
9049 local test_path=$POOL_ROOT/$POOL_DIR_NAME
9050 local file_dir=$POOL_ROOT/file_tst
9054 # former test_200a test_200b
9055 pool_add $POOL || { rc=$? ; break; }
9056 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
9057 # former test_200c test_200d
9059 pool_set_dir $POOL $test_path || { rc=$? ; break; }
9060 pool_check_dir $POOL $test_path || { rc=$? ; break; }
9061 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
9062 || { rc=$? ; break; }
9063 # former test_200e test_200f
9064 local files=$((OSTCOUNT*3))
9065 pool_alloc_files $POOL $test_path $files "$ost_list" \
9066 || { rc=$? ; break; }
9067 pool_create_files $POOL $file_dir $files "$ost_list" \
9068 || { rc=$? ; break; }
9069 # former test_200g test_200h
9070 pool_lfs_df $POOL || { rc=$? ; break; }
9071 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
9073 # former test_201a test_201b test_201c
9074 pool_remove_first_target $POOL || { rc=$? ; break; }
9076 local f=$test_path/$tfile
9077 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
9078 pool_remove $POOL $f || { rc=$? ; break; }
9085 run_test 200 "OST pools"
9087 # usage: default_attr <count | size | offset>
9089 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
9092 # usage: check_default_stripe_attr
9093 check_default_stripe_attr() {
9094 ACTUAL=$($GETSTRIPE $* $DIR/$tdir)
9096 --stripe-count|--count)
9097 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
9098 --stripe-size|--size)
9099 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
9100 --stripe-index|--index)
9103 error "unknown getstripe attr '$1'"
9106 [ $ACTUAL != $EXPECTED ] &&
9107 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
9112 $SETSTRIPE --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
9114 check_default_stripe_attr --stripe-count
9115 check_default_stripe_attr --stripe-size
9116 check_default_stripe_attr --stripe-index
9120 run_test 204a "Print default stripe attributes ================="
9124 $SETSTRIPE --stripe-count 1 $DIR/$tdir
9126 check_default_stripe_attr --stripe-size
9127 check_default_stripe_attr --stripe-index
9131 run_test 204b "Print default stripe size and offset ==========="
9135 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
9137 check_default_stripe_attr --stripe-count
9138 check_default_stripe_attr --stripe-index
9142 run_test 204c "Print default stripe count and offset ==========="
9146 $SETSTRIPE --stripe-index 0 $DIR/$tdir
9148 check_default_stripe_attr --stripe-count
9149 check_default_stripe_attr --stripe-size
9153 run_test 204d "Print default stripe count and size ============="
9157 $SETSTRIPE -d $DIR/$tdir
9159 check_default_stripe_attr --stripe-count --raw
9160 check_default_stripe_attr --stripe-size --raw
9161 check_default_stripe_attr --stripe-index --raw
9165 run_test 204e "Print raw stripe attributes ================="
9169 $SETSTRIPE --stripe-count 1 $DIR/$tdir
9171 check_default_stripe_attr --stripe-size --raw
9172 check_default_stripe_attr --stripe-index --raw
9176 run_test 204f "Print raw stripe size and offset ==========="
9180 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
9182 check_default_stripe_attr --stripe-count --raw
9183 check_default_stripe_attr --stripe-index --raw
9187 run_test 204g "Print raw stripe count and offset ==========="
9191 $SETSTRIPE --stripe-index 0 $DIR/$tdir
9193 check_default_stripe_attr --stripe-count --raw
9194 check_default_stripe_attr --stripe-size --raw
9198 run_test 204h "Print raw stripe count and size ============="
9200 # Figure out which job scheduler is being used, if any,
9202 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
9204 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
9206 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
9208 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
9209 JOBENV=LOADL_STEP_ID
9210 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
9220 # clear old jobstats
9221 do_facet $SINGLEMDS lctl set_param mdt.*.job_stats="clear"
9222 do_facet ost1 lctl set_param obdfilter.*.job_stats="clear"
9224 # use a new JobID for this test, or we might see an old one
9225 [ "$JOBENV" = "FAKE_JOBID" ] && FAKE_JOBID=test_id.$testnum.$RANDOM
9229 log "Using JobID environment variable $JOBENV=$JOBVAL"
9231 if [ $JOBENV = "FAKE_JOBID" ]; then
9232 FAKE_JOBID=$JOBVAL $cmd
9237 if [ "$target" = "mdt" -o "$target" = "both" ]; then
9238 FACET="$SINGLEMDS" # will need to get MDS number for DNE
9239 do_facet $FACET lctl get_param mdt.*.job_stats |
9240 grep $JOBVAL || error "No job stats found on MDT $FACET"
9242 if [ "$target" = "ost" -o "$target" = "both" ]; then
9244 do_facet $FACET lctl get_param obdfilter.*.job_stats |
9245 grep $JOBVAL || error "No job stats found on OST $FACET"
9249 test_205() { # Job stats
9250 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
9251 skip "Server doesn't support jobstats" && return 0
9254 OLD_JOBENV=`$LCTL get_param -n jobid_var`
9255 if [ $OLD_JOBENV != $JOBENV ]; then
9256 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$JOBENV
9257 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" \
9262 cmd="mkdir $DIR/$tfile"
9263 verify_jobstats "$cmd" "mdt"
9265 cmd="rm -fr $DIR/$tfile"
9266 verify_jobstats "$cmd" "mdt"
9268 cmd="mknod $DIR/$tfile c 1 3"
9269 verify_jobstats "$cmd" "mdt"
9271 cmd="rm -f $DIR/$tfile"
9272 verify_jobstats "$cmd" "mdt"
9274 cmd="$SETSTRIPE -i 0 -c 1 $DIR/$tfile"
9275 verify_jobstats "$cmd" "mdt"
9277 cmd="touch $DIR/$tfile"
9278 verify_jobstats "$cmd" "both"
9280 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
9281 verify_jobstats "$cmd" "ost"
9283 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
9284 verify_jobstats "$cmd" "ost"
9286 cmd="$TRUNCATE $DIR/$tfile 0"
9287 verify_jobstats "$cmd" "both"
9289 cmd="mv -f $DIR/$tfile $DIR/jobstats_test_rename"
9290 verify_jobstats "$cmd" "mdt"
9293 rm -f $DIR/jobstats_test_rename
9295 if [ $OLD_JOBENV != $JOBENV ]; then
9296 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$OLD_JOBENV
9297 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" \
9298 $OLD_JOBENV || return 1
9301 run_test 205 "Verify job stats"
9303 # LU-1480, LU-1773 and LU-1657
9306 lfs setstripe -c -1 $DIR/$tdir
9307 #define OBD_FAIL_LOV_INIT 0x1403
9308 $LCTL set_param fail_loc=0xa0001403
9309 $LCTL set_param fail_val=1
9310 touch $DIR/$tdir/$tfile || true
9312 run_test 206 "fail lov_init_raid0() doesn't lbug"
9316 size=$((size % 8192 + 1))
9317 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
9318 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
9319 rm -f $DIR/f212 $DIR/f212.xyz
9321 run_test 212 "Sendfile test ============================================"
9324 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
9325 cancel_lru_locks osc
9326 lctl set_param fail_loc=0x8000040f
9327 # generate a read lock
9328 cat $DIR/$tfile > /dev/null
9329 # write to the file, it will try to cancel the above read lock.
9330 cat /etc/hosts >> $DIR/$tfile
9332 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
9334 test_214() { # for bug 20133
9335 mkdir -p $DIR/d214p/d214c
9336 for (( i=0; i < 340; i++ )) ; do
9337 touch $DIR/d214p/d214c/a$i
9340 ls -l $DIR/d214p || error "ls -l $DIR/d214p failed"
9341 mv $DIR/d214p/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
9342 ls $DIR/d214c || error "ls $DIR/d214c failed"
9343 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
9345 run_test 214 "hash-indexed directory test - bug 20133"
9347 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
9348 create_lnet_proc_files() {
9349 cat /proc/sys/lnet/$1 >$TMP/lnet_$1.out || error "cannot read /proc/sys/lnet/$1"
9350 sysctl lnet.$1 >$TMP/lnet_$1.sys_tmp || error "cannot read lnet.$1"
9352 sed "s/^lnet.$1\ =\ //g" "$TMP/lnet_$1.sys_tmp" >$TMP/lnet_$1.sys
9353 rm -f "$TMP/lnet_$1.sys_tmp"
9356 # counterpart of create_lnet_proc_files
9357 remove_lnet_proc_files() {
9358 rm -f $TMP/lnet_$1.out $TMP/lnet_$1.sys
9361 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
9362 # 3rd arg as regexp for body
9363 check_lnet_proc_stats() {
9364 local l=$(cat "$TMP/lnet_$1" |wc -l)
9365 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
9367 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
9370 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
9371 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
9372 # optional and can be regexp for 2nd line (lnet.routes case)
9373 check_lnet_proc_entry() {
9374 local blp=2 # blp stands for 'position of 1st line of body'
9375 [ "$5" = "" ] || blp=3 # lnet.routes case
9377 local l=$(cat "$TMP/lnet_$1" |wc -l)
9378 # subtracting one from $blp because the body can be empty
9379 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
9381 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
9382 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
9384 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
9385 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
9387 # bail out if any unexpected line happened
9388 sed -n "$blp~1 p" "$TMP/lnet_$1" |grep -Ev "$3"
9389 [ "$?" != 0 ] || error "$2 misformatted"
9392 test_215() { # for bugs 18102, 21079, 21517
9393 local N='(0|[1-9][0-9]*)' # non-negative numeric
9394 local P='[1-9][0-9]*' # positive numeric
9395 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
9396 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
9397 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
9398 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
9400 local L1 # regexp for 1st line
9401 local L2 # regexp for 2nd line (optional)
9402 local BR # regexp for the rest (body)
9404 # /proc/sys/lnet/stats should look as 11 space-separated non-negative numerics
9405 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
9406 create_lnet_proc_files "stats"
9407 check_lnet_proc_stats "stats.out" "/proc/sys/lnet/stats" "$BR"
9408 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
9409 remove_lnet_proc_files "stats"
9411 # /proc/sys/lnet/routes should look like this:
9412 # Routing disabled/enabled
9413 # net hops state router
9414 # where net is a string like tcp0, hops >= 0, state is up/down,
9415 # router is a string like 192.168.1.1@tcp2
9416 L1="^Routing (disabled|enabled)$"
9417 L2="^net +hops +state +router$"
9418 BR="^$NET +$N +(up|down) +$NID$"
9419 create_lnet_proc_files "routes"
9420 check_lnet_proc_entry "routes.out" "/proc/sys/lnet/routes" "$BR" "$L1" "$L2"
9421 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
9422 remove_lnet_proc_files "routes"
9424 # /proc/sys/lnet/routers should look like this:
9425 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
9426 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
9427 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
9428 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
9429 L1="^ref +rtr_ref +alive_cnt +state +last_ping +ping_sent +deadline +down_ni +router$"
9430 BR="^$P +$P +$N +(up|down) +$N +(0|1) +$I +$I +$NID$"
9431 create_lnet_proc_files "routers"
9432 check_lnet_proc_entry "routers.out" "/proc/sys/lnet/routers" "$BR" "$L1"
9433 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
9434 remove_lnet_proc_files "routers"
9436 # /proc/sys/lnet/peers should look like this:
9437 # nid refs state last max rtr min tx min queue
9438 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
9439 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
9440 # numeric (0 or >0 or <0), queue >= 0.
9441 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
9442 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
9443 create_lnet_proc_files "peers"
9444 check_lnet_proc_entry "peers.out" "/proc/sys/lnet/peers" "$BR" "$L1"
9445 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
9446 remove_lnet_proc_files "peers"
9448 # /proc/sys/lnet/buffers should look like this:
9449 # pages count credits min
9450 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
9451 L1="^pages +count +credits +min$"
9452 BR="^ +$N +$N +$I +$I$"
9453 create_lnet_proc_files "buffers"
9454 check_lnet_proc_entry "buffers.out" "/proc/sys/lnet/buffers" "$BR" "$L1"
9455 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
9456 remove_lnet_proc_files "buffers"
9458 # /proc/sys/lnet/nis should look like this:
9459 # nid status alive refs peer rtr max tx min
9460 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
9461 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
9462 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
9463 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
9464 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
9465 create_lnet_proc_files "nis"
9466 check_lnet_proc_entry "nis.out" "/proc/sys/lnet/nis" "$BR" "$L1"
9467 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
9468 remove_lnet_proc_files "nis"
9470 # can we successfully write to /proc/sys/lnet/stats?
9471 echo "0" >/proc/sys/lnet/stats || error "cannot write to /proc/sys/lnet/stats"
9472 sysctl -w lnet.stats=0 || error "cannot write to lnet.stats"
9474 run_test 215 "/proc/sys/lnet exists and has proper content - bugs 18102, 21079, 21517"
9476 test_216() { # bug 20317
9477 remote_ost_nodsh && skip "remote OST with nodsh" && return
9479 local p="$TMP/sanityN-$TESTNAME.parameters"
9480 save_lustre_params $HOSTNAME "osc.*.contention_seconds" > $p
9481 for node in $(osts_nodes); do
9482 save_lustre_params $node "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
9483 save_lustre_params $node "ldlm.namespaces.filter-*.contended_locks" >> $p
9484 save_lustre_params $node "ldlm.namespaces.filter-*.contention_seconds" >> $p
9488 # agressive lockless i/o settings
9489 for node in $(osts_nodes); do
9490 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'
9492 lctl set_param -n osc.*.contention_seconds 60
9494 $DIRECTIO write $DIR/$tfile 0 10 4096
9495 $CHECKSTAT -s 40960 $DIR/$tfile
9497 # disable lockless i/o
9498 for node in $(osts_nodes); do
9499 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'
9501 lctl set_param -n osc.*.contention_seconds 0
9504 dd if=/dev/zero of=$DIR/$tfile count=0
9505 $CHECKSTAT -s 0 $DIR/$tfile
9507 restore_lustre_params <$p
9511 run_test 216 "check lockless direct write works and updates file size and kms correctly"
9513 test_217() { # bug 22430
9517 for node in $(nodes_list); do
9518 nid=$(host_nids_address $node $NETTYPE)
9519 if [[ $nid = *-* ]] ; then
9520 echo "lctl ping $nid@$NETTYPE"
9521 lctl ping $nid@$NETTYPE
9523 echo "skipping $node (no hyphen detected)"
9527 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
9530 # do directio so as not to populate the page cache
9531 log "creating a 10 Mb file"
9532 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
9533 log "starting reads"
9534 dd if=$DIR/$tfile of=/dev/null bs=4096 &
9535 log "truncating the file"
9536 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
9538 kill %+ || true # reads might have finished
9539 echo "wait until dd is finished"
9541 log "removing the temporary file"
9542 rm -rf $DIR/$tfile || error "tmp file removal failed"
9544 run_test 218 "parallel read and truncate should not deadlock ======================="
9547 # write one partial page
9548 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
9549 # set no grant so vvp_io_commit_write will do sync write
9550 $LCTL set_param fail_loc=0x411
9551 # write a full page at the end of file
9552 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
9554 $LCTL set_param fail_loc=0
9555 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
9556 $LCTL set_param fail_loc=0x411
9557 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
9559 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
9561 test_220() { #LU-325
9562 remote_ost_nodsh && skip "remote OST with nodsh" && return
9566 local OST=$(lfs osts | grep ${OSTIDX}": " | \
9567 awk '{print $2}' | sed -e 's/_UUID$//')
9570 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
9571 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
9572 osc.$mdtosc_proc1.prealloc_last_id)
9573 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
9574 osc.$mdtosc_proc1.prealloc_next_id)
9578 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
9579 #define OBD_FAIL_OST_ENOINO 0x229
9580 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
9581 do_facet mgs $LCTL pool_new $FSNAME.$TESTNAME || return 1
9582 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
9584 $SETSTRIPE $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
9586 MDSOBJS=$((last_id - next_id))
9587 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
9589 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
9590 echo "OST still has $count kbytes free"
9592 echo "create $MDSOBJS files @next_id..."
9593 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
9595 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
9596 osc.$mdtosc_proc1.prealloc_last_id)
9597 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
9598 osc.$mdtosc_proc1.prealloc_next_id)
9600 echo "after creation, last_id=$last_id2, next_id=$next_id2"
9605 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
9606 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
9608 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST || return 4
9609 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME || return 5
9610 echo "unlink $MDSOBJS files @$next_id..."
9611 unlinkmany $DIR/$tdir/f $MDSOBJS || return 6
9613 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
9616 dd if=`which date` of=$MOUNT/date oflag=sync
9617 chmod +x $MOUNT/date
9619 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
9620 $LCTL set_param fail_loc=0x80001401
9622 $MOUNT/date > /dev/null
9625 run_test 221 "make sure fault and truncate race to not cause OOM"
9630 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
9631 createmany -o $DIR/$tdir/$tfile 10
9632 cancel_lru_locks mdc
9633 cancel_lru_locks osc
9634 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
9635 $LCTL set_param fail_loc=0x31a
9636 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
9637 $LCTL set_param fail_loc=0
9640 run_test 222a "AGL for ls should not trigger CLIO lock failure ================"
9645 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
9646 createmany -o $DIR/$tdir/$tfile 10
9647 cancel_lru_locks mdc
9648 cancel_lru_locks osc
9649 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
9650 $LCTL set_param fail_loc=0x31a
9651 rm -r $DIR/$tdir || "AGL for rmdir failed"
9652 $LCTL set_param fail_loc=0
9654 run_test 222b "AGL for rmdir should not trigger CLIO lock failure ============="
9659 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
9660 createmany -o $DIR/$tdir/$tfile 10
9661 cancel_lru_locks mdc
9662 cancel_lru_locks osc
9663 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
9664 $LCTL set_param fail_loc=0x31b
9665 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
9666 $LCTL set_param fail_loc=0
9669 run_test 223 "osc reenqueue if without AGL lock granted ======================="
9671 test_224a() { # LU-1039, MRP-303
9672 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
9673 $LCTL set_param fail_loc=0x508
9674 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
9675 $LCTL set_param fail_loc=0
9678 run_test 224a "Don't panic on bulk IO failure"
9680 test_224b() { # LU-1039, MRP-303
9681 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
9682 cancel_lru_locks osc
9683 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
9684 $LCTL set_param fail_loc=0x515
9685 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
9686 $LCTL set_param fail_loc=0
9689 run_test 224b "Don't panic on bulk IO failure"
9691 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
9693 if [ -z ${MDSSURVEY} ]; then
9694 skip_env "mds-survey not found" && return
9696 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
9697 { skip "Need MDS version at least 2.2.51"; return; }
9699 local mds=$(facet_host $SINGLEMDS)
9700 local target=$(do_nodes $mds 'lctl dl' | \
9701 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
9703 local cmd1="file_count=1000 thrhi=4"
9704 local cmd2="dir_count=2 layer=mdd stripe_count=0"
9705 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
9706 local cmd="$cmd1 $cmd2 $cmd3"
9708 rm -f ${TMP}/mds_survey*
9710 eval $cmd || error "mds-survey with zero-stripe failed"
9711 cat ${TMP}/mds_survey*
9712 rm -f ${TMP}/mds_survey*
9714 run_test 225a "Metadata survey sanity with zero-stripe"
9717 if [ -z ${MDSSURVEY} ]; then
9718 skip_env "mds-survey not found" && return
9720 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
9721 { skip "Need MDS version at least 2.2.51"; return; }
9723 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
9724 skip_env "Need to mount OST to test" && return
9727 local mds=$(facet_host $SINGLEMDS)
9728 local target=$(do_nodes $mds 'lctl dl' | \
9729 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
9731 local cmd1="file_count=1000 thrhi=4"
9732 local cmd2="dir_count=2 layer=mdd stripe_count=1"
9733 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
9734 local cmd="$cmd1 $cmd2 $cmd3"
9736 rm -f ${TMP}/mds_survey*
9738 eval $cmd || error "mds-survey with stripe_count failed"
9739 cat ${TMP}/mds_survey*
9740 rm -f ${TMP}/mds_survey*
9742 run_test 225b "Metadata survey sanity with stripe_count = 1"
9744 mcreate_path2fid () {
9750 local path=$DIR/$tdir/$name
9755 $MCREATE --mode=$1 --major=$2 --minor=$3 $path || \
9756 error "error: cannot create $desc"
9758 fid=$($LFS path2fid $path)
9760 [ $rc -ne 0 ] && error "error: cannot get fid of a $desc"
9762 fid_path=$($LFS fid2path $DIR $fid)
9764 [ $rc -ne 0 ] && error "error: cannot get path of a $desc by fid"
9766 [ "$path" == "$fid_path" ] || \
9767 error "error: fid2path returned \`$fid_path', expected \`$path'"
9774 mcreate_path2fid 0010666 0 0 fifo "FIFO"
9775 mcreate_path2fid 0020666 1 3 null "character special file (null)"
9776 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
9777 mcreate_path2fid 0040666 0 0 dir "directory"
9778 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
9779 mcreate_path2fid 0100666 0 0 file "regular file"
9780 mcreate_path2fid 0120666 0 0 link "symbolic link"
9781 mcreate_path2fid 0140666 0 0 sock "socket"
9783 run_test 226 "call path2fid and fid2path on files of all type"
9785 # LU-1299 Executing or running ldd on a truncated executable does not
9786 # cause an out-of-memory condition.
9788 dd if=`which date` of=$MOUNT/date bs=1k count=1
9789 chmod +x $MOUNT/date
9791 $MOUNT/date > /dev/null
9792 ldd $MOUNT/date > /dev/null
9795 run_test 227 "running truncated executable does not cause OOM"
9797 # LU-1512 try to reuse idle OI blocks
9799 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
9800 skip "non-ldiskfs backend" && return
9802 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
9803 local myDIR=$DIR/$tdir
9806 #define OBD_FAIL_SEQ_EXHAUST 0x1002
9807 $LCTL set_param fail_loc=0x80001002
9808 createmany -o $myDIR/t- 10000
9809 $LCTL set_param fail_loc=0
9810 # The guard is current the largest FID holder
9812 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
9814 local IDX=$(($SEQ % 64))
9816 do_facet $SINGLEMDS sync
9817 # Make sure journal flushed.
9819 local blk1=$(do_facet $SINGLEMDS \
9820 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
9821 grep Blockcount | awk '{print $4}')
9823 # Remove old files, some OI blocks will become idle.
9824 unlinkmany $myDIR/t- 10000
9825 # Create new files, idle OI blocks should be reused.
9826 createmany -o $myDIR/t- 2000
9827 do_facet $SINGLEMDS sync
9828 # Make sure journal flushed.
9830 local blk2=$(do_facet $SINGLEMDS \
9831 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
9832 grep Blockcount | awk '{print $4}')
9834 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
9836 run_test 228a "try to reuse idle OI blocks"
9839 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
9840 skip "non-ldiskfs backend" && return
9842 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
9843 local myDIR=$DIR/$tdir
9846 #define OBD_FAIL_SEQ_EXHAUST 0x1002
9847 $LCTL set_param fail_loc=0x80001002
9848 createmany -o $myDIR/t- 10000
9849 $LCTL set_param fail_loc=0
9850 # The guard is current the largest FID holder
9852 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
9854 local IDX=$(($SEQ % 64))
9856 do_facet $SINGLEMDS sync
9857 # Make sure journal flushed.
9859 local blk1=$(do_facet $SINGLEMDS \
9860 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
9861 grep Blockcount | awk '{print $4}')
9863 # Remove old files, some OI blocks will become idle.
9864 unlinkmany $myDIR/t- 10000
9867 stop $SINGLEMDS || error "Fail to stop MDT."
9869 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
9871 df $MOUNT || error "Fail to df."
9872 # Create new files, idle OI blocks should be reused.
9873 createmany -o $myDIR/t- 2000
9874 do_facet $SINGLEMDS sync
9875 # Make sure journal flushed.
9877 local blk2=$(do_facet $SINGLEMDS \
9878 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
9879 grep Blockcount | awk '{print $4}')
9881 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
9883 run_test 228b "idle OI blocks can be reused after MDT restart"
9887 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
9888 skip "non-ldiskfs backend" && return
9890 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
9891 local myDIR=$DIR/$tdir
9894 #define OBD_FAIL_SEQ_EXHAUST 0x1002
9895 $LCTL set_param fail_loc=0x80001002
9896 # 20000 files can guarantee there are index nodes in the OI file
9897 createmany -o $myDIR/t- 20000
9898 $LCTL set_param fail_loc=0
9899 # The guard is current the largest FID holder
9901 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
9903 local IDX=$(($SEQ % 64))
9905 do_facet $SINGLEMDS sync
9906 # Make sure journal flushed.
9908 local blk1=$(do_facet $SINGLEMDS \
9909 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
9910 grep Blockcount | awk '{print $4}')
9912 # Remove old files, some OI blocks will become idle.
9913 unlinkmany $myDIR/t- 20000
9915 # The OI file should become empty now
9917 # Create new files, idle OI blocks should be reused.
9918 createmany -o $myDIR/t- 2000
9919 do_facet $SINGLEMDS sync
9920 # Make sure journal flushed.
9922 local blk2=$(do_facet $SINGLEMDS \
9923 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
9924 grep Blockcount | awk '{print $4}')
9926 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
9928 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
9931 # tests that do cleanup/setup should be run at the end
9936 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
9937 $LCTL set_param fail_loc=0x903
9938 # cancel_lru_locks mgc - does not work due to lctl set_param syntax
9939 for ls in /proc/fs/lustre/ldlm/namespaces/MGC*/lru_size; do
9942 FAIL_ON_ERROR=true cleanup
9943 FAIL_ON_ERROR=true setup
9945 run_test 900 "umount should not race with any mgc requeue thread"
9948 check_and_cleanup_lustre
9949 if [ "$I_MOUNTED" != "yes" ]; then
9950 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true