2 # -*- mode: Bash; tab-width: 4; indent-tabs-mode: t; -*-
3 # vim:autoindent:shiftwidth=4:tabstop=4:
5 # Run select tests by setting ONLY, or as arguments to the script.
6 # Skip specific tests by setting EXCEPT.
8 # e.g. ONLY="22 23" or ONLY="`seq 32 39`" or EXCEPT="31"
12 # bug number for skipped test: 13297 2108 9789 3637 9789 3561 12622 5188
13 ALWAYS_EXCEPT=" 27u 42a 42b 42c 42d 45 51d 68b $SANITY_EXCEPT"
14 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
16 # Tests that fail on uml
17 CPU=`awk '/model/ {print $4}' /proc/cpuinfo`
18 # buffer i/o errs sock spc runas
19 [ "$CPU" = "UML" ] && EXCEPT="$EXCEPT 27m 27n 27o 27p 27q 27r 31d 54a 64b 99a 99b 99c 99d 99e 99f 101a"
22 2.4*) FSTYPE=${FSTYPE:-ext3} ;;
23 2.6*) FSTYPE=${FSTYPE:-ldiskfs} ;;
24 *) error "unsupported kernel" ;;
27 SRCDIR=$(cd $(dirname $0); echo $PWD)
28 export PATH=$PATH:/sbin
32 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
33 CREATETEST=${CREATETEST:-createtest}
35 LFIND=${LFIND:-"$LFS find"}
36 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
38 MCREATE=${MCREATE:-mcreate}
39 OPENFILE=${OPENFILE:-openfile}
40 OPENUNLINK=${OPENUNLINK:-openunlink}
41 READS=${READS:-"reads"}
42 MUNLINK=${MUNLINK:-munlink}
43 SOCKETSERVER=${SOCKETSERVER:-socketserver}
44 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
45 MEMHOG=${MEMHOG:-memhog}
46 DIRECTIO=${DIRECTIO:-directio}
47 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
48 UMOUNT=${UMOUNT:-"umount -d"}
50 CHECK_GRANT=${CHECK_GRANT:-"yes"}
51 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
53 export NAME=${NAME:-local}
60 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
61 . $LUSTRE/tests/test-framework.sh
63 . ${CONFIG:=$LUSTRE/tests/cfg/${NAME}.sh}
66 [ "$SLOW" = "no" ] && EXCEPT_SLOW="24o 24v 27m 36f 36g 36h 51b 60c 63 64b 68 71 73 77f 78 101a 103 115 120g 124b"
72 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
73 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
82 check_kernel_version() {
84 GOT_VER=$(lctl get_param -n version | awk '/kernel:/ {print $2}')
86 patchless|patchless_client) return 0;;
87 *) [ $GOT_VER -ge $WANT_VER ] && return 0 ;;
89 log "test needs at least kernel version $WANT_VER, running $GOT_VER"
93 if [ "$ONLY" == "cleanup" ]; then
98 check_and_setup_lustre
103 MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid | \
104 awk '{gsub(/_UUID/,""); print $1}' | head -1)
105 LOVNAME=$($LCTL get_param -n llite.*.lov.common_name | tail -n 1)
106 OSTCOUNT=$($LCTL get_param -n lov.$LOVNAME.numobd)
107 STRIPECOUNT=$($LCTL get_param -n lov.$LOVNAME.stripecount)
108 STRIPESIZE=$($LCTL get_param -n lov.$LOVNAME.stripesize)
109 ORIGFREE=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
110 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
112 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
113 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
114 rm -rf $DIR/[Rdfs][0-9]*
116 # $RUNAS_ID may get set incorrectly somewhere else
117 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
119 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
123 if [ "${ONLY}" = "MOUNT" ] ; then
124 echo "Lustre is up, please go on"
128 echo "preparing for tests involving mounts"
129 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
131 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
132 echo # add a newline after mke2fs.
136 OLDDEBUG="`lctl get_param -n debug 2> /dev/null`"
137 lctl set_param debug=-1 2> /dev/null || true
140 $CHECKSTAT -t file $DIR/$tfile || error
142 $CHECKSTAT -a $DIR/$tfile || error
144 run_test 0 "touch .../$tfile ; rm .../$tfile ====================="
147 chmod 0755 $DIR || error
148 $CHECKSTAT -p 0755 $DIR || error
150 run_test 0b "chmod 0755 $DIR ============================="
153 $LCTL get_param mdc.*.import | grep "state: FULL" || error "import not FULL"
154 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" || error "bad target"
156 run_test 0c "check import proc ============================="
161 mkdir $DIR/d1/d2 && error "we expect EEXIST, but not returned"
162 $CHECKSTAT -t dir $DIR/d1/d2 || error
164 run_test 1a "mkdir .../d1; mkdir .../d1/d2 ====================="
169 $CHECKSTAT -a $DIR/d1 || error
171 run_test 1b "rmdir .../d1/d2; rmdir .../d1 ====================="
176 $CHECKSTAT -t file $DIR/d2/f || error
178 run_test 2a "mkdir .../d2; touch .../d2/f ======================"
182 $CHECKSTAT -a $DIR/d2 || error
184 run_test 2b "rm -r .../d2; checkstat .../d2/f ======================"
188 $CHECKSTAT -t dir $DIR/d3 || error
190 run_test 3a "mkdir .../d3 ======================================"
193 if [ ! -d $DIR/d3 ]; then
197 $CHECKSTAT -t file $DIR/d3/f || error
199 run_test 3b "touch .../d3/f ===================================="
203 $CHECKSTAT -a $DIR/d3 || error
205 run_test 3c "rm -r .../d3 ======================================"
209 $CHECKSTAT -t dir $DIR/d4 || error
211 run_test 4a "mkdir .../d4 ======================================"
214 if [ ! -d $DIR/d4 ]; then
218 $CHECKSTAT -t dir $DIR/d4/d2 || error
220 run_test 4b "mkdir .../d4/d2 ==================================="
225 chmod 0707 $DIR/d5/d2
226 $CHECKSTAT -t dir -p 0707 $DIR/d5/d2 || error
228 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2 ============"
232 chmod 0666 $DIR/f6a || error
233 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/f6a || error
235 run_test 6a "touch .../f6a; chmod .../f6a ======================"
238 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
239 if [ ! -f $DIR/f6a ]; then
243 $RUNAS chmod 0444 $DIR/f6a && error
244 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/f6a || error
246 run_test 6b "$RUNAS chmod .../f6a (should return error) =="
249 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
251 chown $RUNAS_ID $DIR/f6c || error
252 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/f6c || error
254 run_test 6c "touch .../f6c; chown .../f6c ======================"
257 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
258 if [ ! -f $DIR/f6c ]; then
260 chown $RUNAS_ID $DIR/f6c
262 $RUNAS chown $UID $DIR/f6c && error
263 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/f6c || error
265 run_test 6d "$RUNAS chown .../f6c (should return error) =="
268 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
270 chgrp $RUNAS_ID $DIR/f6e || error
271 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/f6e || error
273 run_test 6e "touch .../f6e; chgrp .../f6e ======================"
276 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
277 if [ ! -f $DIR/f6e ]; then
279 chgrp $RUNAS_ID $DIR/f6e
281 $RUNAS chgrp $UID $DIR/f6e && error
282 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/f6e || error
284 run_test 6f "$RUNAS chgrp .../f6e (should return error) =="
287 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
288 mkdir $DIR/d6g || error
289 chmod 777 $DIR/d6g || error
290 $RUNAS mkdir $DIR/d6g/d || error
291 chmod g+s $DIR/d6g/d || error
292 mkdir $DIR/d6g/d/subdir
293 $CHECKSTAT -g \#$RUNAS_GID $DIR/d6g/d/subdir || error
295 run_test 6g "Is new dir in sgid dir inheriting group?"
297 test_6h() { # bug 7331
298 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
299 touch $DIR/f6h || error "touch failed"
300 chown $RUNAS_ID:$RUNAS_GID $DIR/f6h || error "initial chown failed"
301 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/f6h && error "chown worked"
302 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/f6h || error
304 run_test 6h "$RUNAS chown RUNAS_ID.0 .../f6h (should return error)"
310 $CHECKSTAT -t file -p 0666 $DIR/d7/f || error
312 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
315 if [ ! -d $DIR/d7 ]; then
319 echo -n foo > $DIR/d7/f2
320 [ "`cat $DIR/d7/f2`" = "foo" ] || error
321 $CHECKSTAT -t file -s 3 $DIR/d7/f2 || error
323 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
329 $CHECKSTAT -t file -p 0666 $DIR/d8/f || error
331 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
337 $CHECKSTAT -t dir $DIR/d9/d2/d3 || error
339 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
345 $CHECKSTAT -t file $DIR/d10/d2/f || error
347 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
352 chmod 0666 $DIR/d11/d2
353 chmod 0705 $DIR/d11/d2
354 $CHECKSTAT -t dir -p 0705 $DIR/d11/d2 || error
356 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
361 chmod 0666 $DIR/d12/f
362 chmod 0654 $DIR/d12/f
363 $CHECKSTAT -t file -p 0654 $DIR/d12/f || error
365 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
369 dd if=/dev/zero of=$DIR/d13/f count=10
371 $CHECKSTAT -t file -s 0 $DIR/d13/f || error
373 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
379 $CHECKSTAT -a $DIR/d14/f || error
381 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
386 mv $DIR/d15/f $DIR/d15/f2
387 $CHECKSTAT -t file $DIR/d15/f2 || error
389 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
395 $CHECKSTAT -a $DIR/d16/f || error
397 run_test 16 "touch .../d16/f; rm -rf .../d16/f ================="
402 ln -s $DIR/d17/f $DIR/d17/l-exist
404 $CHECKSTAT -l $DIR/d17/f $DIR/d17/l-exist || error
405 $CHECKSTAT -f -t f $DIR/d17/l-exist || error
406 rm -f $DIR/d17/l-exist
407 $CHECKSTAT -a $DIR/d17/l-exist || error
409 run_test 17a "symlinks: create, remove (real) =================="
413 ln -s no-such-file $DIR/d17/l-dangle
415 $CHECKSTAT -l no-such-file $DIR/d17/l-dangle || error
416 $CHECKSTAT -fa $DIR/d17/l-dangle || error
417 rm -f $DIR/d17/l-dangle
418 $CHECKSTAT -a $DIR/d17/l-dangle || error
420 run_test 17b "symlinks: create, remove (dangling) =============="
422 test_17c() { # bug 3440 - don't save failed open RPC for replay
424 ln -s foo $DIR/d17/f17c
425 cat $DIR/d17/f17c && error "opened non-existent symlink" || true
427 run_test 17c "symlinks: open dangling (should return error) ===="
431 ln -s foo $DIR/d17/f17d
432 touch $DIR/d17/f17d || error "creating to new symlink"
434 run_test 17d "symlinks: create dangling ========================"
438 local foo=$DIR/$tdir/$tfile
439 ln -s $foo $foo || error "create symlink failed"
440 ls -l $foo || error "ls -l failed"
441 ls $foo && error "ls not failed" || true
443 run_test 17e "symlinks: create recursive symlink (should return error) ===="
447 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/d17f/111
448 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/d17f/222
449 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/d17f/333
450 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/d17f/444
451 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/d17f/555
452 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
455 run_test 17f "symlinks: long and very long symlink name ========================"
459 LONGSYMLINK="$(dd if=/dev/zero bs=4095 count=1 | tr '\0' 'x')"
460 ln -s $LONGSYMLINK $DIR/$tdir/$tfile
463 run_test 17g "symlinks: really long symlink name ==============================="
465 test_17h() { #bug 17378
466 remote_mds_nodsh && skip "remote MDS with nodsh" && return
468 $SETSTRIPE -c -1 $DIR/$tdir
469 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
470 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000141
471 touch $DIR/$tdir/$tfile || true
473 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
475 test_17i() { #bug 20018
476 remote_mds_nodsh && skip "remote MDS with nodsh" && return
478 local foo=$DIR/$tdir/$tfile
479 ln -s $foo $foo || error "create symlink failed"
480 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
481 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000143
482 ls -l $foo && error "error not detected"
485 run_test 17i "don't panic on short symlink"
487 test_17k() { #bug 22301
488 rsync --help | grep -q xattr ||
489 skip_env "$(rsync --version| head -1) does not support xattrs"
490 mkdir -p $DIR/{$tdir,$tdir.new}
491 touch $DIR/$tdir/$tfile
492 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
493 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
494 error "rsync failed with xattrs enabled"
496 run_test 17k "symlinks: rsync with xattrs enabled ========================="
502 run_test 18 "touch .../f ; ls ... =============================="
508 $CHECKSTAT -a $DIR/f19 || error
510 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
513 ls -l $DIR/f19 && error || true
515 run_test 19b "ls -l .../f19 (should return error) =============="
518 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
519 $RUNAS touch $DIR/f19 && error || true
521 run_test 19c "$RUNAS touch .../f19 (should return error) =="
524 cat $DIR/f19 && error || true
526 run_test 19d "cat .../f19 (should return error) =============="
538 $CHECKSTAT -a $DIR/f || error
540 run_test 20 "touch .../f ; ls -l ... ==========================="
544 [ -f $DIR/d21/dangle ] && rm -f $DIR/d21/dangle
545 ln -s dangle $DIR/d21/link
546 echo foo >> $DIR/d21/link
548 $CHECKSTAT -t link $DIR/d21/link || error
549 $CHECKSTAT -f -t file $DIR/d21/link || error
551 run_test 21 "write to dangling link ============================"
556 chown $RUNAS_ID:$RUNAS_GID $WDIR
557 (cd $WDIR || error "cd $WDIR failed";
558 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
560 ls -lR $WDIR/etc || error "ls -lR $WDIR/etc failed"
561 $CHECKSTAT -t dir $WDIR/etc || error "checkstat -t dir failed"
562 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $WDIR/etc || error "checkstat -u failed"
564 run_test 22 "unpack tar archive as non-root user ==============="
569 local file=$DIR/$tdir/$tfile
571 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
572 openfile -f O_CREAT:O_EXCL $file &&
573 error "$file recreate succeeded" || true
575 run_test 23a "O_CREAT|O_EXCL in subdir =========================="
577 test_23b() { # bug 18988
579 local file=$DIR/$tdir/$tfile
582 echo foo > $file || error "write filed"
583 echo bar >> $file || error "append filed"
584 $CHECKSTAT -s 8 $file || error "wrong size"
587 run_test 23b "O_APPEND check =========================="
590 echo '== rename sanity =============================================='
591 echo '-- same directory rename'
594 mv $DIR/R1/f $DIR/R1/g
595 $CHECKSTAT -t file $DIR/R1/g || error
597 run_test 24a "touch .../R1/f; rename .../R1/f .../R1/g ========="
602 mv $DIR/R2/f $DIR/R2/g
603 $CHECKSTAT -a $DIR/R2/f || error
604 $CHECKSTAT -t file $DIR/R2/g || error
606 run_test 24b "touch .../R2/{f,g}; rename .../R2/f .../R2/g ====="
611 mv $DIR/R3/f $DIR/R3/g
612 $CHECKSTAT -a $DIR/R3/f || error
613 $CHECKSTAT -t dir $DIR/R3/g || error
615 run_test 24c "mkdir .../R3/f; rename .../R3/f .../R3/g ========="
620 mrename $DIR/R4/f $DIR/R4/g
621 $CHECKSTAT -a $DIR/R4/f || error
622 $CHECKSTAT -t dir $DIR/R4/g || error
624 run_test 24d "mkdir .../R4/{f,g}; rename .../R4/f .../R4/g ====="
627 echo '-- cross directory renames --'
630 mv $DIR/R5a/f $DIR/R5b/g
631 $CHECKSTAT -a $DIR/R5a/f || error
632 $CHECKSTAT -t file $DIR/R5b/g || error
634 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
638 touch $DIR/R6a/f $DIR/R6b/g
639 mv $DIR/R6a/f $DIR/R6b/g
640 $CHECKSTAT -a $DIR/R6a/f || error
641 $CHECKSTAT -t file $DIR/R6b/g || error
643 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
648 mv $DIR/R7a/d $DIR/R7b/e
649 $CHECKSTAT -a $DIR/R7a/d || error
650 $CHECKSTAT -t dir $DIR/R7b/e || error
652 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
656 mkdir $DIR/R8a/d $DIR/R8b/e
657 mrename $DIR/R8a/d $DIR/R8b/e
658 $CHECKSTAT -a $DIR/R8a/d || error
659 $CHECKSTAT -t dir $DIR/R8b/e || error
661 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
664 echo "-- rename error cases"
668 mrename $DIR/R9/f $DIR/R9/a
669 $CHECKSTAT -t file $DIR/R9/f || error
670 $CHECKSTAT -t dir $DIR/R9/a || error
671 $CHECKSTAT -a $DIR/R9/a/f || error
673 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
677 mrename $DIR/R10/f $DIR/R10/g
678 $CHECKSTAT -t dir $DIR/R10 || error
679 $CHECKSTAT -a $DIR/R10/f || error
680 $CHECKSTAT -a $DIR/R10/g || error
682 run_test 24j "source does not exist ============================"
685 mkdir $DIR/R11a $DIR/R11a/d
687 mv $DIR/R11a/f $DIR/R11a/d
688 $CHECKSTAT -a $DIR/R11a/f || error
689 $CHECKSTAT -t file $DIR/R11a/d/f || error
691 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
693 # bug 2429 - rename foo foo foo creates invalid file
696 multiop $f OcNs || error
698 run_test 24l "Renaming a file to itself ========================"
702 multiop $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
703 # on ext3 this does not remove either the source or target files
704 # though the "expected" operation would be to remove the source
705 $CHECKSTAT -t file ${f} || error "${f} missing"
706 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
708 run_test 24m "Renaming a file to a hard link to itself ========="
712 # this stats the old file after it was renamed, so it should fail
716 $CHECKSTAT ${f}.rename
719 run_test 24n "Statting the old file after renaming (Posix rename 2)"
722 check_kernel_version 37 || return 0
724 rename_many -s random -v -n 10 $DIR/d24o
726 run_test 24o "rename of files during htree split ==============="
730 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
731 mrename $DIR/R12a $DIR/R12b
732 $CHECKSTAT -a $DIR/R12a || error
733 $CHECKSTAT -t dir $DIR/R12b || error
734 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
735 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
737 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
741 DIRINO=`ls -lid $DIR/R13a | awk '{ print $1 }'`
742 multiop_bg_pause $DIR/R13b D_c || return 1
745 mrename $DIR/R13a $DIR/R13b
746 $CHECKSTAT -a $DIR/R13a || error
747 $CHECKSTAT -t dir $DIR/R13b || error
748 DIRINO2=`ls -lid $DIR/R13b | awk '{ print $1 }'`
749 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
751 wait $MULTIPID || error "multiop close failed"
753 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
755 test_24r() { #bug 3789
756 mkdir $DIR/R14a $DIR/R14a/b
757 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
758 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
759 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
761 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
764 mkdir $DIR/R15a $DIR/R15a/b $DIR/R15a/b/c
765 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
766 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
767 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
769 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
771 mkdir $DIR/R16a $DIR/R16a/b $DIR/R16a/b/c
772 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
773 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
774 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
776 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
778 test_24u() { # bug12192
779 multiop $DIR/$tfile C2w$((2048 * 1024))c || error
780 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
782 run_test 24u "create stripe file"
790 local FREE_INODES=`lfs df -i|grep "filesystem summary" | awk '{print $5}'`
791 [ $FREE_INODES -lt $NRFILES ] && \
792 skip "not enough free inodes $FREE_INODES required $NRFILES" && \
796 createmany -m $DIR/d24v/$tfile $NRFILES
799 lctl set_param mdc.*.stats clear
801 ls $DIR/d24v >/dev/null || error "error in listing large dir"
804 # DIRENT_SIZE = 32 bytes for sizeof(struct lu_dirent) +
805 # 8 bytes for name(filename is mostly 5 in this test) +
806 # 8 bytes for luda_type
807 # take into account of overhead in lu_dirpage header and end mark in
808 # each page, plus one in RPC_NUM calculation.
810 RPC_SIZE=$(($(lctl get_param -n mdc.*.max_pages_per_rpc)*$(page_size)))
811 RPC_NUM=$(((NRFILES * DIRENT_SIZE + RPC_SIZE - 1) / RPC_SIZE + 1))
812 mds_readpage=`lctl get_param mdc.*.stats | \
813 awk '/^mds_readpage/ {print $2}'`
814 [ $mds_readpage -gt $RPC_NUM ] && \
815 error "large readdir doesn't take effect"
819 run_test 24v "list directory with large files (handle hash collision, bug: 17560)"
821 test_24w() { # bug21506
823 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
824 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
825 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
826 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
827 [ "$SZ1" = "$SZ2" ] || \
828 error "Error reading at the end of the file $tfile"
830 run_test 24w "Reading a file larger than 4Gb"
833 echo '== symlink sanity ============================================='
837 touch $DIR/s25/foo || error
839 run_test 25a "create file in symlinked directory ==============="
842 [ ! -d $DIR/d25 ] && test_25a
843 $CHECKSTAT -t file $DIR/s25/foo || error
845 run_test 25b "lookup file in symlinked directory ==============="
850 ln -s d26/d26-2 $DIR/s26
851 touch $DIR/s26/foo || error
853 run_test 26a "multiple component symlink ======================="
856 mkdir -p $DIR/d26b/d26-2
857 ln -s d26b/d26-2/foo $DIR/s26-2
858 touch $DIR/s26-2 || error
860 run_test 26b "multiple component symlink at end of lookup ======"
865 ln -s d26.2 $DIR/s26.2-1
866 ln -s s26.2-1 $DIR/s26.2-2
867 ln -s s26.2-2 $DIR/s26.2-3
868 chmod 0666 $DIR/s26.2-3/foo
870 run_test 26c "chain of symlinks ================================"
872 # recursive symlinks (bug 439)
874 ln -s d26-3/foo $DIR/d26-3
876 run_test 26d "create multiple component recursive symlink ======"
879 [ ! -h $DIR/d26-3 ] && test_26d
882 run_test 26e "unlink multiple component recursive symlink ======"
884 # recursive symlinks (bug 7022)
887 mkdir $DIR/$tdir/$tfile || error "mkdir $DIR/$tdir/$tfile failed"
888 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
889 mkdir -p lndir/bar1 || error "mkdir lndir/bar1 failed"
890 mkdir $tfile || error "mkdir $tfile failed"
891 cd $tfile || error "cd $tfile failed"
892 ln -s .. dotdot || error "ln dotdot failed"
893 ln -s dotdot/lndir lndir || error "ln lndir failed"
894 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
895 output=`ls $tfile/$tfile/lndir/bar1`
896 [ "$output" = bar1 ] && error "unexpected output"
897 rm -r $tfile || error "rm $tfile failed"
898 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
900 run_test 26f "rm -r of a directory which has recursive symlink ="
903 echo '== stripe sanity =============================================='
904 mkdir -p $DIR/d27 || error "mkdir failed"
906 $SETSTRIPE -c 1 $DIR/d27/f0 || error "setstripe failed"
907 $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
909 log "== test_27a: write to one stripe file ========================="
910 cp /etc/hosts $DIR/d27/f0 || error
912 run_test 27a "one stripe file =================================="
915 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
917 $SETSTRIPE -c 2 $DIR/d27/f01 || error "setstripe failed"
918 $GETSTRIPE -c $DIR/d27/f01
919 [ $($GETSTRIPE -c $DIR/d27/f01) -eq 2 ] ||
920 error "two-stripe file doesn't have two stripes"
922 run_test 27b "create two stripe file"
925 [ -f $DIR/d27/f01 ] || skip "test_27b not run" && return
927 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
929 run_test 27c "write to two stripe file"
933 $SETSTRIPE -c 0 -i -1 -S 0 $DIR/d27/fdef || error "setstripe failed"
934 $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
935 dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
937 run_test 27d "create file with default settings ================"
941 $SETSTRIPE -c 2 $DIR/d27/f12 || error "setstripe failed"
942 $SETSTRIPE -c 2 $DIR/d27/f12 && error "setstripe succeeded twice"
943 $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
945 run_test 27e "setstripe existing file (should return error) ======"
949 $SETSTRIPE -S 100 -i 0 -c 1 $DIR/d27/fbad && error "setstripe failed"
950 dd if=/dev/zero of=$DIR/d27/f12 bs=4k count=4 || error "dd failed"
951 $GETSTRIPE $DIR/d27/fbad || error "$GETSTRIPE failed"
953 run_test 27f "setstripe with bad stripe size (should return error)"
957 $MCREATE $DIR/d27/fnone || error "mcreate failed"
958 $GETSTRIPE $DIR/d27/fnone 2>&1 | grep "no stripe info" ||
959 error "$DIR/d27/fnone has object"
961 run_test 27g "$GETSTRIPE with no objects"
964 touch $DIR/d27/fsome || error "touch failed"
965 [ $($GETSTRIPE -c $DIR/d27/fsome) -gt 0 ] || error "missing objects"
967 run_test 27i "$GETSTRIPE with some objects"
971 $SETSTRIPE -i $OSTCOUNT $DIR/d27/f27j && error "setstripe failed"||true
973 run_test 27j "setstripe with bad stripe offset (should return error)"
975 test_27k() { # bug 2844
978 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
979 [ ! -d $DIR/d27 ] && mkdir -p $DIR/d27
980 $SETSTRIPE -S 67108864 $FILE || error "setstripe failed"
981 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
982 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
983 dd if=/dev/zero of=$FILE bs=4k count=1
984 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
985 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
987 run_test 27k "limit i_blksize for broken user apps ============="
991 mcreate $DIR/f27l || error "creating file"
992 $RUNAS $SETSTRIPE -c 1 $DIR/f27l && \
993 error "setstripe should have failed" || true
995 run_test 27l "check setstripe permissions (should return error)"
998 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
999 if [ $ORIGFREE -gt $MAXFREE ]; then
1000 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1004 $SETSTRIPE -i 0 -c 1 $DIR/d27/f27m_1
1005 dd if=/dev/zero of=$DIR/d27/f27m_1 bs=1024 count=$MAXFREE &&
1006 error "dd should fill OST0"
1008 while $SETSTRIPE -i 0 -c 1 $DIR/d27/f27m_$i; do
1010 [ $i -gt 256 ] && break
1013 touch $DIR/d27/f27m_$i
1014 [ `$GETSTRIPE $DIR/d27/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] && \
1015 error "OST0 was full but new created file still use it"
1017 touch $DIR/d27/f27m_$i
1018 [ `$GETSTRIPE $DIR/d27/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] && \
1019 error "OST0 was full but new created file still use it"
1023 run_test 27m "create file while OST0 was full =================="
1026 local DELAY=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage | head -n 1 | awk '{print $1 * 2}')
1030 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1031 # if the OST isn't full anymore.
1033 local OSTIDX=${1:-""}
1035 local list=$(comma_list $(osts_nodes))
1036 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1038 do_nodes $list lctl set_param fail_loc=0
1042 exhaust_precreations() {
1045 local FAILIDX=${3:-$OSTIDX}
1048 local MDSIDX=$(get_mds_dir "$DIR/$tdir")
1049 echo OSTIDX=$OSTIDX MDSIDX=$MDSIDX
1051 local OST=$(ostname_from_index $OSTIDX)
1052 local MDT_INDEX=$(lfs df | grep "\[MDT:$((MDSIDX - 1))\]" | awk '{print $1}' | \
1053 sed -e 's/_UUID$//;s/^.*-//')
1056 local mdtosc_proc1=$(get_mdtosc_proc_path mds${MDSIDX} $OST)
1057 local last_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1058 osc.$mdtosc_proc1.prealloc_last_id)
1059 local next_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1060 osc.$mdtosc_proc1.prealloc_next_id)
1062 local mdtosc_proc2=$(get_mdtosc_proc_path mds${MDSIDX})
1063 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1065 mkdir -p $DIR/$tdir/${OST}
1066 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1067 #define OBD_FAIL_OST_ENOSPC 0x215
1068 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=$FAILIDX
1069 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x215
1070 echo "Creating to objid $last_id on ost $OST..."
1071 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1072 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1073 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=$FAILLOC
1077 exhaust_all_precreations() {
1079 for (( i=0; i < OSTCOUNT; i++ )) ; do
1080 exhaust_precreations $i $1 -1
1085 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1086 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1087 remote_ost_nodsh && skip "remote OST with nodsh" && return
1090 rm -f $DIR/$tdir/$tfile
1091 exhaust_precreations 0 0x80000215
1092 $SETSTRIPE -c -1 $DIR/$tdir
1093 touch $DIR/$tdir/$tfile || error
1094 $GETSTRIPE $DIR/$tdir/$tfile
1097 run_test 27n "create file with some full OSTs =================="
1100 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1101 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1102 remote_ost_nodsh && skip "remote OST with nodsh" && return
1105 rm -f $DIR/$tdir/$tfile
1106 exhaust_all_precreations 0x215
1108 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1113 run_test 27o "create file with all full OSTs (should error) ===="
1116 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1117 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1118 remote_ost_nodsh && skip "remote OST with nodsh" && return
1121 rm -f $DIR/$tdir/$tfile
1124 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1125 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1126 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1128 exhaust_precreations 0 0x80000215
1129 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1130 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1131 $GETSTRIPE $DIR/$tdir/$tfile
1135 run_test 27p "append to a truncated file with some full OSTs ==="
1138 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1139 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1140 remote_ost_nodsh && skip "remote OST with nodsh" && return
1143 rm -f $DIR/$tdir/$tfile
1146 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1147 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||error "truncate $DIR/$tdir/$tfile failed"
1148 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1150 exhaust_all_precreations 0x215
1152 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1153 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1157 run_test 27q "append to truncated file with all OSTs full (should error) ==="
1160 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1161 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1162 remote_ost_nodsh && skip "remote OST with nodsh" && return
1165 rm -f $DIR/$tdir/$tfile
1166 exhaust_precreations 0 0x80000215
1168 $SETSTRIPE -i 0 -c 2 $DIR/$tdir/$tfile # && error
1172 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1174 test_27s() { # bug 10725
1176 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1177 local stripe_count=0
1178 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1179 $SETSTRIPE -S $stripe_size -c $stripe_count $DIR/$tdir &&
1180 error "stripe width >= 2^32 succeeded" || true
1183 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1185 test_27t() { # bug 10864
1190 $WLFS getstripe $tfile
1193 run_test 27t "check that utils parse path correctly"
1195 test_27u() { # bug 4900
1196 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1197 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1199 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1200 do_facet $SINGLEMDS lctl set_param fail_loc=0x139
1202 createmany -o $DIR/$tdir/t- 1000
1203 do_facet $SINGLEMDS lctl set_param fail_loc=0
1205 TLOG=$DIR/$tfile.getstripe
1206 $GETSTRIPE $DIR/$tdir > $TLOG
1207 OBJS=`awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj;}' $TLOG`
1208 unlinkmany $DIR/$tdir/t- 1000
1209 [ $OBJS -gt 0 ] && \
1210 error "$OBJS objects created on OST-0. See $TLOG" || pass
1212 run_test 27u "skip object creation on OSC w/o objects =========="
1214 test_27v() { # bug 4900
1215 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1216 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1217 remote_ost_nodsh && skip "remote OST with nodsh" && return
1219 exhaust_all_precreations 0x215
1223 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1225 touch $DIR/$tdir/$tfile
1226 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1228 for (( i=1; i < OSTCOUNT; i++ )); do
1229 do_facet ost$i lctl set_param fail_loc=0x705
1231 local START=`date +%s`
1232 createmany -o $DIR/$tdir/$tfile 32
1234 local FINISH=`date +%s`
1235 local TIMEOUT=`lctl get_param -n timeout`
1236 local PROCESS=$((FINISH - START))
1237 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1238 error "$FINISH - $START >= $TIMEOUT / 2"
1239 sleep $((TIMEOUT / 2 - PROCESS))
1242 run_test 27v "skip object creation on slow OST ================="
1244 test_27w() { # bug 10997
1245 mkdir -p $DIR/$tdir || error "mkdir failed"
1246 $SETSTRIPE -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1247 [ $($GETSTRIPE -S $DIR/$tdir/f0) -ne 65536 ] &&
1248 error "stripe size $size != 65536" || true
1249 [ $($GETSTRIPE -d $DIR/$tdir | grep -c "stripe_count") -ne 1 ] &&
1250 error "$GETSTRIPE -d $DIR/$tdir failed" || true
1252 run_test 27w "check $SETSTRIPE -S option"
1255 [ "$OSTCOUNT" -lt "2" ] &&
1256 skip_env "skipping multiple stripe count/offset test" && return
1258 mkdir -p $DIR/$tdir || error "mkdir failed"
1259 for i in $(seq 1 $OSTCOUNT); do
1261 $SETSTRIPE -c $i -i $offset $DIR/$tdir/f$i ||
1262 error "setstripe -c $i -i $offset failed"
1263 count=$($GETSTRIPE -c $DIR/$tdir/f$i)
1264 index=$($GETSTRIPE -i $DIR/$tdir/f$i)
1265 [ $count -ne $i ] && error "stripe count $count != $i" || true
1266 [ $index -ne $offset ] &&
1267 error "stripe offset $index != $offset" || true
1270 run_test 27wa "check $SETSTRIPE -c -i options"
1273 remote_ost_nodsh && skip "remote OST with nodsh" && return
1274 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs" && return
1275 OFFSET=$(($OSTCOUNT - 1))
1277 local OST=$(ostname_from_index $OSTIDX)
1280 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe per file
1281 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1283 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1284 for i in `seq 0 $OFFSET`; do
1285 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}' | grep -w "$OSTIDX"` ] &&
1286 error "OST0 was degraded but new created file still use it"
1288 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1290 run_test 27x "create files while OST0 is degraded"
1293 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1294 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1295 remote_ost_nodsh && skip "remote OST with nodsh" && return
1297 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1298 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1299 osc.$mdtosc.prealloc_last_id)
1300 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1301 osc.$mdtosc.prealloc_next_id)
1302 local fcount=$((last_id - next_id))
1303 [ $fcount -eq 0 ] && skip "not enough space on OST0" && return
1304 [ $fcount -gt $OSTCOUNT ] && fcount=$OSTCOUNT
1306 MDS_OSCS=`do_facet $SINGLEMDS lctl dl | awk '/[oO][sS][cC].*md[ts]/ { print $4 }'`
1307 OFFSET=$(($OSTCOUNT-1))
1309 for OSC in $MDS_OSCS; do
1310 if [ $OST == -1 ]; then {
1311 OST=`osc_to_ost $OSC`
1313 echo $OSC "is Deactivate:"
1314 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1318 OSTIDX=$(index_from_ostuuid $OST)
1320 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1322 do_facet ost$((OSTIDX+1)) lctl set_param -n obdfilter.$OST.degraded 1
1324 createmany -o $DIR/$tdir/$tfile $fcount
1325 do_facet ost$((OSTIDX+1)) lctl set_param -n obdfilter.$OST.degraded 0
1327 for i in `seq 0 $OFFSET`; do
1328 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "$OSTIDX"` ] || \
1329 error "files created on deactivated OSTs instead of degraded OST"
1331 for OSC in $MDS_OSCS; do
1332 [ `osc_to_ost $OSC` != $OST ] && {
1333 echo $OSC "is activate"
1334 do_facet $SINGLEMDS lctl --device %$OSC activate
1338 run_test 27y "create files while OST0 is degraded and the rest inactive"
1344 lmm_count=$($GETSTRIPE -c $1)
1345 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1346 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1348 local old_ifs="$IFS"
1350 fid=($($LFS path2fid $1))
1353 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1354 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1356 # compare lmm_seq and lu_fid->f_seq
1357 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1358 # compare lmm_object_id and lu_fid->oid
1359 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1361 [ "$FSTYPE" != "ldiskfs" ] &&
1362 skip "cannot check filter fid FSTYPE=$FSTYPE" && return 0
1364 # check the trusted.fid attribute of the OST objects of the file
1365 local have_obdidx=false
1367 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1368 # skip lines up to and including "obdidx"
1369 [ -z "$obdidx" ] && break
1370 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1371 $have_obdidx || continue
1373 local ost=$((obdidx + 1))
1374 local dev=$(ostdevname $ost)
1376 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1378 #don't unmount/remount the OSTs if we don't need to do that
1379 #local dir=$(facet_mntpt ost$ost)
1381 #do_facet ost$dev mount -t $FSTYPE $dev $dir $OST_MOUNT_OPTS ||
1382 # { error "mounting $dev as $FSTYPE failed"; return 3; }
1383 #local obj_file=$(do_facet ost$ost find $dir/O/$seq -name $oid)
1384 #local ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID $obj_file)
1386 local obj_file="O/$seq/d$((oid %32))/$oid"
1387 local ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
1388 $dev 2>/dev/null" | grep "parent=")
1390 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
1392 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
1394 #do_facet ost$ost umount -d $dir
1395 #start ost$ost $dev $OST_MOUNT_OPTS
1397 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
1398 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
1399 local ff_parent=$(echo $ff|sed -e 's/.*parent=.//')
1400 local ff_pseq=$(echo $ff_parent | cut -d: -f1)
1401 local ff_poid=$(echo $ff_parent | cut -d: -f2)
1402 local ff_pstripe=$(echo $ff_parent | sed -e 's/.*stripe=//')
1404 # compare lmm_seq and filter_fid->ff_parent.f_seq
1405 [ $ff_pseq = $lmm_seq ] ||
1406 error "FF parent SEQ $ff_pseq != $lmm_seq"
1407 # compare lmm_object_id and filter_fid->ff_parent.f_oid
1408 [ $ff_poid = $lmm_oid ] ||
1409 error "FF parent OID $ff_poid != $lmm_oid"
1410 [ $ff_pstripe = $stripe_nr ] ||
1411 error "FF stripe $ff_pstripe != $stripe_nr"
1413 stripe_nr=$((stripe_nr + 1))
1418 remote_ost_nodsh && skip "remote OST with nodsh" && return
1421 $SETSTRIPE -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
1422 { error "setstripe -c -1 failed"; return 1; }
1423 # We need to send a write to every object to get parent FID info set.
1424 # This _should_ also work for setattr, but does not currently.
1425 # touch $DIR/$tdir/$tfile-1 ||
1426 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
1427 { error "dd $tfile-1 failed"; return 2; }
1428 $SETSTRIPE -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
1429 { error "setstripe -c -1 failed"; return 3; }
1430 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
1431 { error "dd $tfile-2 failed"; return 4; }
1433 # make sure write RPCs have been sent to OSTs
1436 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
1437 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
1439 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
1441 test_27A() { # b=19102
1442 local restore_size=$($GETSTRIPE -S $MOUNT)
1443 local restore_count=$($GETSTRIPE -c $MOUNT)
1444 local restore_offset=$($GETSTRIPE -i $MOUNT)
1445 $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
1446 local default_size=$($GETSTRIPE -S $MOUNT)
1447 local default_count=$($GETSTRIPE -c $MOUNT)
1448 local default_offset=$($GETSTRIPE -i $MOUNT)
1449 local dsize=$((1024 * 1024))
1450 [ $default_size -eq $dsize ] ||
1451 error "stripe size $default_size != $dsize"
1452 [ $default_count -eq 1 ] || error "stripe count $default_count != 1"
1453 [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
1454 $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
1456 run_test 27A "check filesystem-wide default LOV EA values"
1458 # createtest also checks that device nodes are created and
1459 # then visible correctly (#2091)
1460 test_28() { # bug 2091
1462 $CREATETEST $DIR/d28/ct || error
1464 run_test 28 "create/mknod/mkdir with bad file types ============"
1467 cancel_lru_locks mdc
1473 declare -i LOCKCOUNTORIG=0
1474 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1475 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
1477 [ $LOCKCOUNTORIG -eq 0 ] && echo "No mdc lock count" && return 1
1479 declare -i LOCKUNUSEDCOUNTORIG=0
1480 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1481 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
1488 declare -i LOCKCOUNTCURRENT=0
1489 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1490 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
1493 declare -i LOCKUNUSEDCOUNTCURRENT=0
1494 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1495 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
1498 if [ "$LOCKCOUNTCURRENT" -gt "$LOCKCOUNTORIG" ]; then
1499 lctl set_param -n ldlm.dump_namespaces ""
1500 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
1501 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1502 log "dumped log to $TMP/test_29.dk (bug 5793)"
1505 if [ "$LOCKUNUSEDCOUNTCURRENT" -gt "$LOCKUNUSEDCOUNTORIG" ]; then
1506 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
1507 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1508 log "dumped log to $TMP/test_29.dk (bug 5793)"
1512 run_test 29 "IT_GETATTR regression ============================"
1514 test_30a() { # was test_30
1515 cp `which ls` $DIR || cp /bin/ls $DIR
1519 run_test 30a "execute binary from Lustre (execve) =============="
1522 cp `which ls` $DIR || cp /bin/ls $DIR
1524 $RUNAS $DIR/ls / || error
1527 run_test 30b "execute binary from Lustre as non-root ==========="
1529 test_30c() { # b=22376
1530 cp `which ls` $DIR || cp /bin/ls $DIR
1532 cancel_lru_locks mdc
1533 cancel_lru_locks osc
1534 $RUNAS $DIR/ls / || error
1537 run_test 30c "execute binary from Lustre without read perms ===="
1540 $OPENUNLINK $DIR/f31 $DIR/f31 || error
1541 $CHECKSTAT -a $DIR/f31 || error
1543 run_test 31a "open-unlink file =================================="
1546 touch $DIR/f31 || error
1547 ln $DIR/f31 $DIR/f31b || error
1548 multiop $DIR/f31b Ouc || error
1549 $CHECKSTAT -t file $DIR/f31 || error
1551 run_test 31b "unlink file with multiple links while open ======="
1554 touch $DIR/f31 || error
1555 ln $DIR/f31 $DIR/f31c || error
1556 multiop_bg_pause $DIR/f31 O_uc || return 1
1558 multiop $DIR/f31c Ouc
1559 kill -USR1 $MULTIPID
1562 run_test 31c "open-unlink file with multiple links ============="
1565 opendirunlink $DIR/d31d $DIR/d31d || error
1566 $CHECKSTAT -a $DIR/d31d || error
1568 run_test 31d "remove of open directory ========================="
1570 test_31e() { # bug 2904
1571 check_kernel_version 34 || return 0
1572 openfilleddirunlink $DIR/d31e || error
1574 run_test 31e "remove of open non-empty directory ==============="
1576 test_31f() { # bug 4554
1579 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
1580 cp /etc/hosts $DIR/d31f
1582 $GETSTRIPE $DIR/d31f/hosts
1583 multiop_bg_pause $DIR/d31f D_c || return 1
1586 rm -rv $DIR/d31f || error "first of $DIR/d31f"
1588 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
1589 cp /etc/hosts $DIR/d31f
1591 $GETSTRIPE $DIR/d31f/hosts
1592 multiop_bg_pause $DIR/d31f D_c || return 1
1595 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
1596 wait $MULTIPID || error "first opendir $MULTIPID failed"
1600 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
1601 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
1604 run_test 31f "remove of open directory with open-unlink file ==="
1607 echo "-- cross directory link --"
1608 mkdir $DIR/d31g{a,b}
1610 ln $DIR/d31ga/f $DIR/d31gb/g
1611 $CHECKSTAT -t file $DIR/d31ga/f || error "source"
1612 [ `stat -c%h $DIR/d31ga/f` == '2' ] || error "source nlink"
1613 $CHECKSTAT -t file $DIR/d31gb/g || error "target"
1614 [ `stat -c%h $DIR/d31gb/g` == '2' ] || error "target nlink"
1616 run_test 31g "cross directory link==============="
1619 echo "-- cross directory link --"
1623 ln $DIR/d31h/f $DIR/d31h/dir/g
1624 $CHECKSTAT -t file $DIR/d31h/f || error "source"
1625 [ `stat -c%h $DIR/d31h/f` == '2' ] || error "source nlink"
1626 $CHECKSTAT -t file $DIR/d31h/dir/g || error "target"
1627 [ `stat -c%h $DIR/d31h/dir/g` == '2' ] || error "target nlink"
1629 run_test 31h "cross directory link under child==============="
1632 echo "-- cross directory link --"
1635 touch $DIR/d31i/dir/f
1636 ln $DIR/d31i/dir/f $DIR/d31i/g
1637 $CHECKSTAT -t file $DIR/d31i/dir/f || error "source"
1638 [ `stat -c%h $DIR/d31i/dir/f` == '2' ] || error "source nlink"
1639 $CHECKSTAT -t file $DIR/d31i/g || error "target"
1640 [ `stat -c%h $DIR/d31i/g` == '2' ] || error "target nlink"
1642 run_test 31i "cross directory link under parent==============="
1647 mkdir $DIR/d31j/dir1
1648 ln $DIR/d31j/dir1 $DIR/d31j/dir2 && error "ln for dir"
1649 link $DIR/d31j/dir1 $DIR/d31j/dir3 && error "link for dir"
1650 mlink $DIR/d31j/dir1 $DIR/d31j/dir4 && error "mlink for dir"
1651 mlink $DIR/d31j/dir1 $DIR/d31j/dir1 && error "mlink to the same dir"
1654 run_test 31j "link for directory==============="
1660 touch $DIR/d31k/exist
1661 mlink $DIR/d31k/s $DIR/d31k/t || error "mlink"
1662 mlink $DIR/d31k/s $DIR/d31k/exist && error "mlink to exist file"
1663 mlink $DIR/d31k/s $DIR/d31k/s && error "mlink to the same file"
1664 mlink $DIR/d31k/s $DIR/d31k && error "mlink to parent dir"
1665 mlink $DIR/d31k $DIR/d31k/s && error "mlink parent dir to target"
1666 mlink $DIR/d31k/not-exist $DIR/d31k/foo && error "mlink non-existing to new"
1667 mlink $DIR/d31k/not-exist $DIR/d31k/s && error "mlink non-existing to exist"
1670 run_test 31k "link to file: the same, non-existing, dir==============="
1676 touch $DIR/d31m2/exist
1677 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
1678 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
1679 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
1680 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
1681 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
1682 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
1685 run_test 31m "link to file: the same, non-existing, dir==============="
1688 echo "== more mountpoints and symlinks ================="
1689 [ -e $DIR/d32a ] && rm -fr $DIR/d32a
1690 mkdir -p $DIR/d32a/ext2-mountpoint
1691 mount -t ext2 -o loop $EXT2_DEV $DIR/d32a/ext2-mountpoint || error
1692 $CHECKSTAT -t dir $DIR/d32a/ext2-mountpoint/.. || error
1693 $UMOUNT $DIR/d32a/ext2-mountpoint || error
1695 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
1698 [ -e $DIR/d32b ] && rm -fr $DIR/d32b
1699 mkdir -p $DIR/d32b/ext2-mountpoint
1700 mount -t ext2 -o loop $EXT2_DEV $DIR/d32b/ext2-mountpoint || error
1701 ls -al $DIR/d32b/ext2-mountpoint/.. || error
1702 $UMOUNT $DIR/d32b/ext2-mountpoint || error
1704 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
1707 [ -e $DIR/d32c ] && rm -fr $DIR/d32c
1708 mkdir -p $DIR/d32c/ext2-mountpoint
1709 mount -t ext2 -o loop $EXT2_DEV $DIR/d32c/ext2-mountpoint || error
1710 mkdir -p $DIR/d32c/d2/test_dir
1711 $CHECKSTAT -t dir $DIR/d32c/ext2-mountpoint/../d2/test_dir || error
1712 $UMOUNT $DIR/d32c/ext2-mountpoint || error
1714 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
1717 [ -e $DIR/d32d ] && rm -fr $DIR/d32d
1718 mkdir -p $DIR/d32d/ext2-mountpoint
1719 mount -t ext2 -o loop $EXT2_DEV $DIR/d32d/ext2-mountpoint || error
1720 mkdir -p $DIR/d32d/d2/test_dir
1721 ls -al $DIR/d32d/ext2-mountpoint/../d2/test_dir || error
1722 $UMOUNT $DIR/d32d/ext2-mountpoint || error
1724 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
1727 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
1728 mkdir -p $DIR/d32e/tmp
1729 TMP_DIR=$DIR/d32e/tmp
1730 ln -s $DIR/d32e $TMP_DIR/symlink11
1731 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1732 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
1733 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
1735 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
1738 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
1739 mkdir -p $DIR/d32f/tmp
1740 TMP_DIR=$DIR/d32f/tmp
1741 ln -s $DIR/d32f $TMP_DIR/symlink11
1742 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1743 ls $DIR/d32f/tmp/symlink11 || error
1744 ls $DIR/d32f/symlink01 || error
1746 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
1749 TMP_DIR=$DIR/$tdir/tmp
1750 mkdir -p $TMP_DIR $DIR/${tdir}2
1751 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
1752 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1753 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
1754 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
1755 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
1756 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
1758 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
1761 rm -fr $DIR/$tdir $DIR/${tdir}2
1762 TMP_DIR=$DIR/$tdir/tmp
1763 mkdir -p $TMP_DIR $DIR/${tdir}2
1764 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
1765 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1766 ls $TMP_DIR/symlink12 || error
1767 ls $DIR/$tdir/symlink02 || error
1769 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
1772 [ -e $DIR/d32i ] && rm -fr $DIR/d32i
1773 mkdir -p $DIR/d32i/ext2-mountpoint
1774 mount -t ext2 -o loop $EXT2_DEV $DIR/d32i/ext2-mountpoint || error
1775 touch $DIR/d32i/test_file
1776 $CHECKSTAT -t file $DIR/d32i/ext2-mountpoint/../test_file || error
1777 $UMOUNT $DIR/d32i/ext2-mountpoint || error
1779 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
1782 [ -e $DIR/d32j ] && rm -fr $DIR/d32j
1783 mkdir -p $DIR/d32j/ext2-mountpoint
1784 mount -t ext2 -o loop $EXT2_DEV $DIR/d32j/ext2-mountpoint || error
1785 touch $DIR/d32j/test_file
1786 cat $DIR/d32j/ext2-mountpoint/../test_file || error
1787 $UMOUNT $DIR/d32j/ext2-mountpoint || error
1789 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
1793 mkdir -p $DIR/d32k/ext2-mountpoint
1794 mount -t ext2 -o loop $EXT2_DEV $DIR/d32k/ext2-mountpoint
1795 mkdir -p $DIR/d32k/d2
1796 touch $DIR/d32k/d2/test_file || error
1797 $CHECKSTAT -t file $DIR/d32k/ext2-mountpoint/../d2/test_file || error
1798 $UMOUNT $DIR/d32k/ext2-mountpoint || error
1800 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
1804 mkdir -p $DIR/d32l/ext2-mountpoint
1805 mount -t ext2 -o loop $EXT2_DEV $DIR/d32l/ext2-mountpoint || error
1806 mkdir -p $DIR/d32l/d2
1807 touch $DIR/d32l/d2/test_file
1808 cat $DIR/d32l/ext2-mountpoint/../d2/test_file || error
1809 $UMOUNT $DIR/d32l/ext2-mountpoint || error
1811 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
1815 mkdir -p $DIR/d32m/tmp
1816 TMP_DIR=$DIR/d32m/tmp
1817 ln -s $DIR $TMP_DIR/symlink11
1818 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1819 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
1820 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
1822 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
1826 mkdir -p $DIR/d32n/tmp
1827 TMP_DIR=$DIR/d32n/tmp
1828 ln -s $DIR $TMP_DIR/symlink11
1829 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1830 ls -l $DIR/d32n/tmp/symlink11 || error
1831 ls -l $DIR/d32n/symlink01 || error
1833 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
1836 rm -fr $DIR/d32o $DIR/$tfile
1838 mkdir -p $DIR/d32o/tmp
1839 TMP_DIR=$DIR/d32o/tmp
1840 ln -s $DIR/$tfile $TMP_DIR/symlink12
1841 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1842 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
1843 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
1844 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
1845 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
1847 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
1857 mkdir -p $DIR/d32p/tmp
1859 TMP_DIR=$DIR/d32p/tmp
1861 ln -s $DIR/$tfile $TMP_DIR/symlink12
1863 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1865 cat $DIR/d32p/tmp/symlink12 || error
1867 cat $DIR/d32p/symlink02 || error
1870 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
1873 [ -e $DIR/d32q ] && rm -fr $DIR/d32q
1875 touch $DIR/d32q/under_the_mount
1876 mount -t ext2 -o loop $EXT2_DEV $DIR/d32q
1877 ls $DIR/d32q/under_the_mount && error || true
1878 $UMOUNT $DIR/d32q || error
1880 run_test 32q "stat follows mountpoints in Lustre (should return error)"
1883 [ -e $DIR/d32r ] && rm -fr $DIR/d32r
1885 touch $DIR/d32r/under_the_mount
1886 mount -t ext2 -o loop $EXT2_DEV $DIR/d32r
1887 ls $DIR/d32r | grep -q under_the_mount && error || true
1888 $UMOUNT $DIR/d32r || error
1890 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
1895 chmod 444 $DIR/$tfile
1896 chown $RUNAS_ID $DIR/$tfile
1898 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
1901 run_test 33 "write file with mode 444 (should return error) ===="
1906 chown $RUNAS_ID $DIR/d33
1907 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
1908 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
1909 error "open RDWR" || true
1911 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
1916 chown $RUNAS_ID $DIR/d33
1917 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33 && error "create" || true
1919 run_test 33b "test open file with malformed flags (No panic and return error)"
1927 remote_ost_nodsh && skip "remote OST with nodsh" && return
1931 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
1934 for ostnum in $(seq $OSTCOUNT); do
1935 # test-framework's OST numbering is one-based, while Lustre's
1937 ostname=$(printf "$FSNAME-OST%.4d" $((ostnum - 1)))
1938 # Parsing llobdstat's output sucks; we could grep the /proc
1939 # path, but that's likely to not be as portable as using the
1940 # llobdstat utility. So we parse lctl output instead.
1941 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
1942 obdfilter/$ostname/stats |
1943 awk '/^write_bytes/ {print $7}' )
1944 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
1945 if (( ${write_bytes:-0} > 0 ))
1952 $all_zeros || return 0
1955 echo foo > $DIR/d33/bar
1959 # Total up write_bytes after writing. We'd better find non-zeros.
1960 for ostnum in $(seq $OSTCOUNT); do
1961 ostname=$(printf "$FSNAME-OST%.4d" $((ostnum - 1)))
1962 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
1963 obdfilter/$ostname/stats |
1964 awk '/^write_bytes/ {print $7}' )
1965 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
1966 if (( ${write_bytes:-0} > 0 ))
1975 for ostnum in $(seq $OSTCOUNT); do
1976 ostname=$(printf "$FSNAME-OST%.4d" $((ostnum - 1)))
1977 echo "Check that write_bytes is present in obdfilter/*/stats:"
1978 do_facet ost$ostnum lctl get_param -n \
1979 obdfilter/$ostname/stats
1981 error "OST not keeping write_bytes stats (b22312)"
1984 run_test 33c "test llobdstat and write_bytes"
1986 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
1989 $MCREATE $DIR/f34 || error
1990 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
1991 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
1992 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
1993 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1995 run_test 34a "truncate file that has not been opened ==========="
1998 [ ! -f $DIR/f34 ] && test_34a
1999 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2000 $OPENFILE -f O_RDONLY $DIR/f34
2001 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2002 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2004 run_test 34b "O_RDONLY opening file doesn't create objects ====="
2007 [ ! -f $DIR/f34 ] && test_34a
2008 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2009 $OPENFILE -f O_RDWR $DIR/f34
2010 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2011 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2013 run_test 34c "O_RDWR opening file-with-size works =============="
2016 [ ! -f $DIR/f34 ] && test_34a
2017 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2018 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2021 run_test 34d "write to sparse file ============================="
2025 $MCREATE $DIR/f34e || error
2026 $TRUNCATE $DIR/f34e 1000 || error
2027 $CHECKSTAT -s 1000 $DIR/f34e || error
2028 $OPENFILE -f O_RDWR $DIR/f34e
2029 $CHECKSTAT -s 1000 $DIR/f34e || error
2031 run_test 34e "create objects, some with size and some without =="
2033 test_34f() { # bug 6242, 6243
2036 $MCREATE $DIR/f34f || error
2037 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
2038 dd if=$DIR/f34f of=$TMP/f34f
2039 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
2040 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
2041 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
2042 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
2043 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
2045 run_test 34f "read from a file with no objects until EOF ======="
2048 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
2049 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
2050 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
2051 cancel_lru_locks osc
2052 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
2053 error "wrong size after lock cancel"
2055 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
2056 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2057 error "expanding truncate failed"
2058 cancel_lru_locks osc
2059 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2060 error "wrong expanded size after lock cancel"
2062 run_test 34g "truncate long file ==============================="
2068 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
2069 multiop $DIR/$tfile OG${gid}T${sz}g${gid}c &
2073 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
2074 error "Multiop blocked on ftruncate, pid=$MULTIPID"
2078 local nsz=`stat -c %s $DIR/$tfile`
2079 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
2081 run_test 34h "ftruncate file under grouplock should not block"
2084 cp /bin/sh $DIR/f35a
2086 chown $RUNAS_ID $DIR/f35a
2087 $RUNAS $DIR/f35a && error || true
2090 run_test 35a "exec file with mode 444 (should return and not leak) ====="
2094 utime $DIR/f36 || error
2096 run_test 36a "MDS utime check (mknod, utime) ==================="
2100 utime $DIR/f36 || error
2102 run_test 36b "OST utime check (open, utime) ===================="
2107 chown $RUNAS_ID $DIR/d36
2108 $RUNAS utime $DIR/d36/f36 || error
2110 run_test 36c "non-root MDS utime check (mknod, utime) =========="
2113 [ ! -d $DIR/d36 ] && test_36c
2114 echo "" > $DIR/d36/f36
2115 $RUNAS utime $DIR/d36/f36 || error
2117 run_test 36d "non-root OST utime check (open, utime) ==========="
2120 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
2122 touch $DIR/$tdir/$tfile
2123 $RUNAS utime $DIR/$tdir/$tfile && \
2124 error "utime worked, expected failure" || true
2126 run_test 36e "utime on non-owned file (should return error) ===="
2130 local LANG_SAVE=$LANG
2131 local LC_LANG_SAVE=$LC_LANG
2132 export LANG=C LC_LANG=C # for date language
2134 DATESTR="Dec 20 2000"
2136 lctl set_param fail_loc=$fl
2138 cp /etc/hosts $DIR/$tdir/$tfile
2139 sync & # write RPC generated with "current" inode timestamp, but delayed
2141 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
2142 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
2143 cancel_lru_locks osc
2144 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
2146 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
2147 echo "BEFORE: $LS_BEFORE" && \
2148 echo "AFTER : $LS_AFTER" && \
2149 echo "WANT : $DATESTR" && \
2150 error "$DIR/$tdir/$tfile timestamps changed" || true
2152 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
2156 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2157 subr_36fh "0x80000214"
2159 run_test 36f "utime on file racing with OST BRW write =========="
2162 remote_ost_nodsh && skip "remote OST with nodsh" && return
2168 fmd_max_age=$(do_facet ost1 \
2169 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
2172 fmd_before=$(do_facet ost1 \
2173 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2174 touch $DIR/$tdir/$tfile
2175 sleep $((fmd_max_age + 12))
2176 fmd_after=$(do_facet ost1 \
2177 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2179 echo "fmd_before: $fmd_before"
2180 echo "fmd_after: $fmd_after"
2181 [ "$fmd_after" -gt "$fmd_before" ] && \
2182 echo "AFTER: $fmd_after > BEFORE: $fmd_before" && \
2183 error "fmd didn't expire after ping" || true
2185 run_test 36g "filter mod data cache expiry ====================="
2188 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
2189 subr_36fh "0x80000227"
2191 run_test 36h "utime on file racing with OST BRW write =========="
2195 echo f > $DIR/$tdir/fbugfile
2196 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2197 ls $DIR/$tdir | grep "\<fbugfile\>" && error
2198 $UMOUNT $DIR/$tdir || error
2199 rm -f $DIR/$tdir/fbugfile || error
2201 run_test 37 "ls a mounted file system to check old content ====="
2204 local file=$DIR/$tfile
2206 openfile -f O_DIRECTORY $file
2209 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
2210 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
2212 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
2216 touch $DIR/${tfile}2
2217 # ls -l $DIR/$tfile $DIR/${tfile}2
2218 # ls -lu $DIR/$tfile $DIR/${tfile}2
2219 # ls -lc $DIR/$tfile $DIR/${tfile}2
2221 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
2222 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
2224 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
2226 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
2228 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
2229 error "O_TRUNC didn't change timestamps"
2232 run_test 39 "mtime changed on create ==========================="
2236 cp -p /etc/passwd $DIR/$tdir/fopen
2237 cp -p /etc/passwd $DIR/$tdir/flink
2238 cp -p /etc/passwd $DIR/$tdir/funlink
2239 cp -p /etc/passwd $DIR/$tdir/frename
2240 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
2243 echo "aaaaaa" >> $DIR/$tdir/fopen
2244 echo "aaaaaa" >> $DIR/$tdir/flink
2245 echo "aaaaaa" >> $DIR/$tdir/funlink
2246 echo "aaaaaa" >> $DIR/$tdir/frename
2248 local open_new=`stat -c %Y $DIR/$tdir/fopen`
2249 local link_new=`stat -c %Y $DIR/$tdir/flink`
2250 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
2251 local rename_new=`stat -c %Y $DIR/$tdir/frename`
2253 cat $DIR/$tdir/fopen > /dev/null
2254 ln $DIR/$tdir/flink $DIR/$tdir/flink2
2255 rm -f $DIR/$tdir/funlink2
2256 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
2258 for (( i=0; i < 2; i++ )) ; do
2259 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
2260 local link_new2=`stat -c %Y $DIR/$tdir/flink`
2261 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
2262 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
2264 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
2265 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
2266 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
2267 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
2269 cancel_lru_locks osc
2270 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2273 run_test 39b "mtime change on open, link, unlink, rename ======"
2275 # this should be set to past
2276 TEST_39_MTIME=`date -d "1 year ago" +%s`
2282 local mtime0=`stat -c %Y $DIR1/$tfile`
2284 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2285 local mtime1=`stat -c %Y $DIR1/$tfile`
2286 [ "$mtime1" = $TEST_39_MTIME ] || \
2287 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
2290 echo hello >> $DIR1/$tfile
2292 local mtime2=`stat -c %Y $DIR1/$tfile`
2293 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
2294 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
2296 mv $DIR1/$tfile $DIR1/$tfile-1
2298 for (( i=0; i < 2; i++ )) ; do
2299 local mtime3=`stat -c %Y $DIR1/$tfile-1`
2300 [ "$mtime2" = "$mtime3" ] || \
2301 error "mtime ($mtime2) changed (to $mtime3) on rename"
2303 cancel_lru_locks osc
2304 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2307 run_test 39c "mtime change on rename ==========================="
2313 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2315 for (( i=0; i < 2; i++ )) ; do
2316 local mtime=`stat -c %Y $DIR1/$tfile`
2317 [ $mtime = $TEST_39_MTIME ] || \
2318 error "mtime($mtime) is not set to $TEST_39_MTIME"
2320 cancel_lru_locks osc
2321 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2324 run_test 39d "create, utime, stat =============================="
2329 local mtime1=`stat -c %Y $DIR1/$tfile`
2331 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2333 for (( i=0; i < 2; i++ )) ; do
2334 local mtime2=`stat -c %Y $DIR1/$tfile`
2335 [ $mtime2 = $TEST_39_MTIME ] || \
2336 error "mtime($mtime2) is not set to $TEST_39_MTIME"
2338 cancel_lru_locks osc
2339 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2342 run_test 39e "create, stat, utime, stat ========================"
2347 mtime1=`stat -c %Y $DIR1/$tfile`
2350 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2352 for (( i=0; i < 2; i++ )) ; do
2353 local mtime2=`stat -c %Y $DIR1/$tfile`
2354 [ $mtime2 = $TEST_39_MTIME ] || \
2355 error "mtime($mtime2) is not set to $TEST_39_MTIME"
2357 cancel_lru_locks osc
2358 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2361 run_test 39f "create, stat, sleep, utime, stat ================="
2365 echo hello >> $DIR1/$tfile
2366 local mtime1=`stat -c %Y $DIR1/$tfile`
2369 chmod o+r $DIR1/$tfile
2371 for (( i=0; i < 2; i++ )) ; do
2372 local mtime2=`stat -c %Y $DIR1/$tfile`
2373 [ "$mtime1" = "$mtime2" ] || \
2374 error "lost mtime: $mtime2, should be $mtime1"
2376 cancel_lru_locks osc
2377 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2380 run_test 39g "write, chmod, stat ==============================="
2388 echo hello >> $DIR1/$tfile
2389 local mtime1=`stat -c %Y $DIR1/$tfile`
2391 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2393 if [ "$d1" != "$d2" ]; then
2394 echo "write and touch not within one second"
2396 for (( i=0; i < 2; i++ )) ; do
2397 local mtime2=`stat -c %Y $DIR1/$tfile`
2398 [ "$mtime2" = $TEST_39_MTIME ] || \
2399 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
2401 cancel_lru_locks osc
2402 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2406 run_test 39h "write, utime within one second, stat ============="
2412 echo hello >> $DIR1/$tfile
2413 local mtime1=`stat -c %Y $DIR1/$tfile`
2415 mv $DIR1/$tfile $DIR1/$tfile-1
2417 for (( i=0; i < 2; i++ )) ; do
2418 local mtime2=`stat -c %Y $DIR1/$tfile-1`
2420 [ "$mtime1" = "$mtime2" ] || \
2421 error "lost mtime: $mtime2, should be $mtime1"
2423 cancel_lru_locks osc
2424 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2427 run_test 39i "write, rename, stat =============================="
2433 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
2435 local mtime1=`stat -c %Y $DIR1/$tfile`
2437 mv $DIR1/$tfile $DIR1/$tfile-1
2439 kill -USR1 $multipid
2440 wait $multipid || error "multiop close failed"
2442 for (( i=0; i < 2; i++ )) ; do
2443 local mtime2=`stat -c %Y $DIR1/$tfile-1`
2444 [ "$mtime1" = "$mtime2" ] || \
2445 error "mtime is lost on close: $mtime2, should be $mtime1"
2447 cancel_lru_locks osc
2448 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2451 run_test 39j "write, rename, close, stat ======================="
2457 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
2459 local mtime1=`stat -c %Y $DIR1/$tfile`
2461 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2463 kill -USR1 $multipid
2464 wait $multipid || error "multiop close failed"
2466 for (( i=0; i < 2; i++ )) ; do
2467 local mtime2=`stat -c %Y $DIR1/$tfile`
2469 [ "$mtime2" = $TEST_39_MTIME ] || \
2470 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
2472 cancel_lru_locks osc
2473 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2476 run_test 39k "write, utime, close, stat ========================"
2478 # this should be set to future
2479 TEST_39_ATIME=`date -d "1 year" +%s`
2482 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2483 local atime_diff=$(do_facet $SINGLEMDS lctl get_param -n mdd.*.atime_diff)
2487 # test setting directory atime to future
2488 touch -a -d @$TEST_39_ATIME $DIR/$tdir
2489 local atime=$(stat -c %X $DIR/$tdir)
2490 [ "$atime" = $TEST_39_ATIME ] || \
2491 error "atime is not set to future: $atime, should be $TEST_39_ATIME"
2493 # test setting directory atime from future to now
2494 local d1=$(date +%s)
2496 local d2=$(date +%s)
2498 cancel_lru_locks mdc
2499 atime=$(stat -c %X $DIR/$tdir)
2500 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
2501 error "atime is not updated from future: $atime, should be $d1<atime<$d2"
2503 do_facet $SINGLEMDS lctl set_param -n mdd.*.atime_diff=2
2506 # test setting directory atime when now > dir atime + atime_diff
2510 cancel_lru_locks mdc
2511 atime=$(stat -c %X $DIR/$tdir)
2512 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
2513 error "atime is not updated : $atime, should be $d2"
2515 do_facet $SINGLEMDS lctl set_param -n mdd.*.atime_diff=60
2518 # test not setting directory atime when now < dir atime + atime_diff
2520 cancel_lru_locks mdc
2521 atime=$(stat -c %X $DIR/$tdir)
2522 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
2523 error "atime is updated to $atime, should remain $d1<atime<$d2"
2525 do_facet $SINGLEMDS lctl set_param -n mdd.*.atime_diff=$atime_diff
2527 run_test 39l "directory atime update ==========================="
2532 local far_past_mtime=$(date -d "May 29 1953" +%s)
2533 local far_past_atime=$(date -d "Dec 17 1903" +%s)
2535 touch -m -d @$far_past_mtime $DIR1/$tfile
2536 touch -a -d @$far_past_atime $DIR1/$tfile
2538 for (( i=0; i < 2; i++ )) ; do
2539 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
2540 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
2541 error "atime or mtime set incorrectly"
2543 cancel_lru_locks osc
2544 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2547 run_test 39m "test atime and mtime before 1970"
2550 dd if=/dev/zero of=$DIR/f40 bs=4096 count=1
2551 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/f40 && error
2552 $CHECKSTAT -t file -s 4096 $DIR/f40 || error
2554 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
2558 small_write $DIR/f41 18
2560 run_test 41 "test small file write + fstat ====================="
2562 count_ost_writes() {
2563 lctl get_param -n osc.*.stats |
2564 awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }'
2571 BG_DIRTY_RATIO_SAVE=10
2572 MAX_BG_DIRTY_RATIO=25
2576 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
2577 # dirty_ratio, dirty_background_ratio
2578 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
2579 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
2580 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
2581 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
2583 # if file not here, we are a 2.4 kernel
2584 kill -CONT `pidof kupdated`
2589 # setup the trap first, so someone cannot exit the test at the
2590 # exact wrong time and mess up a machine
2591 trap start_writeback EXIT
2592 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
2593 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
2594 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
2595 sysctl -w vm.dirty_writeback_centisecs=0
2596 sysctl -w vm.dirty_writeback_centisecs=0
2597 # save and increase /proc/sys/vm/dirty_ratio
2598 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
2599 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
2600 # save and increase /proc/sys/vm/dirty_background_ratio
2601 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
2602 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
2604 # if file not here, we are a 2.4 kernel
2605 kill -STOP `pidof kupdated`
2609 # ensure that all stripes have some grant before we test client-side cache
2611 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
2612 dd if=/dev/zero of=$i bs=4k count=1
2617 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
2618 # file truncation, and file removal.
2621 cancel_lru_locks osc
2623 sync; sleep 1; sync # just to be safe
2624 BEFOREWRITES=`count_ost_writes`
2625 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
2626 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
2627 AFTERWRITES=`count_ost_writes`
2628 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
2629 error "$BEFOREWRITES < $AFTERWRITES"
2632 run_test 42a "ensure that we don't flush on close =============="
2636 cancel_lru_locks osc
2639 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
2640 BEFOREWRITES=`count_ost_writes`
2641 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
2642 AFTERWRITES=`count_ost_writes`
2643 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
2644 error "$BEFOREWRITES < $AFTERWRITES on unlink"
2646 BEFOREWRITES=`count_ost_writes`
2647 sync || error "sync: $?"
2648 AFTERWRITES=`count_ost_writes`
2649 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
2650 error "$BEFOREWRITES < $AFTERWRITES on sync"
2652 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
2656 run_test 42b "test destroy of file with cached dirty data ======"
2658 # if these tests just want to test the effect of truncation,
2659 # they have to be very careful. consider:
2660 # - the first open gets a {0,EOF}PR lock
2661 # - the first write conflicts and gets a {0, count-1}PW
2662 # - the rest of the writes are under {count,EOF}PW
2663 # - the open for truncate tries to match a {0,EOF}PR
2664 # for the filesize and cancels the PWs.
2665 # any number of fixes (don't get {0,EOF} on open, match
2666 # composite locks, do smarter file size management) fix
2667 # this, but for now we want these tests to verify that
2668 # the cancellation with truncate intent works, so we
2669 # start the file with a full-file pw lock to match against
2670 # until the truncate.
2675 cancel_lru_locks osc
2677 # prime the file with 0,EOF PW to match
2681 # now the real test..
2682 dd if=/dev/zero of=$file bs=1024 count=100
2683 BEFOREWRITES=`count_ost_writes`
2684 $TRUNCATE $file $offset
2685 cancel_lru_locks osc
2686 AFTERWRITES=`count_ost_writes`
2692 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
2693 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
2696 run_test 42c "test partial truncate of file with cached dirty data"
2700 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
2701 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
2704 run_test 42d "test complete truncate of file with cached dirty data"
2706 test_42e() { # bug22074
2707 local TDIR=$DIR/${tdir}e
2708 local pagesz=$(page_size)
2709 local pages=16 # hardcoded 16 pages, don't change it.
2710 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
2711 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
2716 $SETSTRIPE -c 1 $TDIR
2717 createmany -o $TDIR/f $files
2719 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
2721 # we assume that with $OSTCOUNT files, at least one of them will
2722 # be allocated on OST0.
2723 warmup_files=$((OSTCOUNT * max_dirty_mb))
2724 createmany -o $TDIR/w $warmup_files
2726 # write a large amount of data into one file and sync, to get good
2727 # avail_grant number from OST.
2728 for ((i=0; i<$warmup_files; i++)); do
2729 idx=$($GETSTRIPE -i $TDIR/w$i)
2730 [ $idx -ne 0 ] && continue
2731 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
2734 [ $i -gt $warmup_files ] && error "OST0 is still cold"
2736 $LCTL get_param $proc_osc0/cur_dirty_bytes
2737 $LCTL get_param $proc_osc0/cur_grant_bytes
2739 # create as much dirty pages as we can while not to trigger the actual
2740 # RPCs directly. but depends on the env, VFS may trigger flush during this
2741 # period, hopefully we are good.
2742 for ((i=0; i<$warmup_files; i++)); do
2743 idx=$($GETSTRIPE -i $TDIR/w$i)
2744 [ $idx -ne 0 ] && continue
2745 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
2747 $LCTL get_param $proc_osc0/cur_dirty_bytes
2748 $LCTL get_param $proc_osc0/cur_grant_bytes
2750 # perform the real test
2751 $LCTL set_param $proc_osc0/rpc_stats 0
2752 for ((;i<$files; i++)); do
2753 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
2754 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
2757 $LCTL get_param $proc_osc0/rpc_stats
2760 local have_ppr=false
2761 $LCTL get_param $proc_osc0/rpc_stats |
2762 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
2763 # skip lines until we are at the RPC histogram data
2764 [ "$PPR" == "pages" ] && have_ppr=true && continue
2765 $have_ppr || continue
2767 # we only want the percent stat for < 16 pages
2768 [ $(echo $PPR | tr -d ':') -ge $pages ] && break
2770 percent=$((percent + WPCT))
2771 if [ $percent -gt 15 ]; then
2772 error "less than 16-pages write RPCs" \
2779 run_test 42e "verify sub-RPC writes are not done synchronously"
2783 cp -p /bin/ls $DIR/$tdir/$tfile
2784 multiop $DIR/$tdir/$tfile Ow_c &
2786 # give multiop a chance to open
2789 $DIR/$tdir/$tfile && error || true
2792 run_test 43 "execution of file opened for write should return -ETXTBSY"
2796 cp -p `which multiop` $DIR/d43/multiop || cp -p multiop $DIR/d43/multiop
2797 MULTIOP_PROG=$DIR/d43/multiop multiop_bg_pause $TMP/test43.junk O_c || return 1
2799 multiop $DIR/d43/multiop Oc && error "expected error, got success"
2800 kill -USR1 $MULTIOP_PID || return 2
2801 wait $MULTIOP_PID || return 3
2804 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
2808 cp -p `which multiop` $DIR/d43/multiop || cp -p multiop $DIR/d43/multiop
2809 MULTIOP_PROG=$DIR/d43/multiop multiop_bg_pause $TMP/test43.junk O_c || return 1
2811 $TRUNCATE $DIR/d43/multiop 0 && error "expected error, got success"
2812 kill -USR1 $MULTIOP_PID || return 2
2813 wait $MULTIOP_PID || return 3
2816 run_test 43b "truncate of file being executed should return -ETXTBSY"
2819 local testdir="$DIR/d43c"
2822 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
2823 ( cd $testdir && md5sum -c)
2825 run_test 43c "md5sum of copy into lustre========================"
2828 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
2829 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
2830 dd if=$DIR/f1 bs=4k count=1 > /dev/null
2832 run_test 44 "zero length read from a sparse stripe ============="
2835 local nstripe=`$LCTL lov_getconfig $DIR | grep default_stripe_count: | \
2837 [ -z "$nstripe" ] && skip "can't get stripe info" && return
2838 [ "$nstripe" -gt "$OSTCOUNT" ] && skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" && return
2839 local stride=`$LCTL lov_getconfig $DIR | grep default_stripe_size: | \
2841 if [ $nstripe -eq 0 -o $nstripe -eq -1 ] ; then
2842 nstripe=`$LCTL lov_getconfig $DIR | grep obd_count: | awk '{print $2}'`
2845 OFFSETS="0 $((stride/2)) $((stride-1))"
2846 for offset in $OFFSETS ; do
2847 for i in `seq 0 $((nstripe-1))`; do
2848 local GLOBALOFFSETS=""
2849 local size=$((((i + 2 * $nstripe )*$stride + $offset))) # Bytes
2850 local myfn=$DIR/d44a-$size
2851 echo "--------writing $myfn at $size"
2852 ll_sparseness_write $myfn $size || error "ll_sparseness_write"
2853 GLOBALOFFSETS="$GLOBALOFFSETS $size"
2854 ll_sparseness_verify $myfn $GLOBALOFFSETS \
2855 || error "ll_sparseness_verify $GLOBALOFFSETS"
2857 for j in `seq 0 $((nstripe-1))`; do
2858 size=$((((j + $nstripe )*$stride + $offset))) # Bytes
2859 ll_sparseness_write $myfn $size || error "ll_sparseness_write"
2860 GLOBALOFFSETS="$GLOBALOFFSETS $size"
2862 ll_sparseness_verify $myfn $GLOBALOFFSETS \
2863 || error "ll_sparseness_verify $GLOBALOFFSETS"
2868 run_test 44a "test sparse pwrite ==============================="
2872 for d in `lctl get_param -n osc.*.cur_dirty_bytes`; do
2878 before=`dirty_osc_total`
2879 echo executing "\"$*\""
2881 after=`dirty_osc_total`
2882 echo before $before, after $after
2886 # Obtain grants from OST if it supports it
2887 echo blah > ${f}_grant
2890 do_dirty_record "echo blah > $f"
2891 [ $before -eq $after ] && error "write wasn't cached"
2892 do_dirty_record "> $f"
2893 [ $before -gt $after ] || error "truncate didn't lower dirty count"
2894 do_dirty_record "echo blah > $f"
2895 [ $before -eq $after ] && error "write wasn't cached"
2896 do_dirty_record "sync"
2897 [ $before -gt $after ] || error "writeback didn't lower dirty count"
2898 do_dirty_record "echo blah > $f"
2899 [ $before -eq $after ] && error "write wasn't cached"
2900 do_dirty_record "cancel_lru_locks osc"
2901 [ $before -gt $after ] || error "lock cancellation didn't lower dirty count"
2904 run_test 45 "osc io page accounting ============================"
2906 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
2907 # test tickles a bug where re-dirtying a page was failing to be mapped to the
2908 # objects offset and an assert hit when an rpc was built with 1023's mapped
2909 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
2914 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
2916 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
2917 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
2921 run_test 46 "dirtying a previously written page ================"
2923 # test_47 is removed "Device nodes check" is moved to test_28
2925 test_48a() { # bug 2399
2926 check_kernel_version 34 || return 0
2929 mv $DIR/d48a $DIR/d48.new || error "move directory failed"
2930 mkdir $DIR/d48a || error "recreate directory failed"
2931 touch foo || error "'touch foo' failed after recreating cwd"
2932 mkdir bar || error "'mkdir foo' failed after recreating cwd"
2933 if check_kernel_version 44; then
2934 touch .foo || error "'touch .foo' failed after recreating cwd"
2935 mkdir .bar || error "'mkdir .foo' failed after recreating cwd"
2937 ls . > /dev/null || error "'ls .' failed after recreating cwd"
2938 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
2939 cd . || error "'cd .' failed after recreating cwd"
2940 mkdir . && error "'mkdir .' worked after recreating cwd"
2941 rmdir . && error "'rmdir .' worked after recreating cwd"
2942 ln -s . baz || error "'ln -s .' failed after recreating cwd"
2943 cd .. || error "'cd ..' failed after recreating cwd"
2945 run_test 48a "Access renamed working dir (should return errors)="
2947 test_48b() { # bug 2399
2948 check_kernel_version 34 || return 0
2951 rmdir $DIR/d48b || error "remove cwd $DIR/d48b failed"
2952 touch foo && error "'touch foo' worked after removing cwd"
2953 mkdir foo && error "'mkdir foo' worked after removing cwd"
2954 if check_kernel_version 44; then
2955 touch .foo && error "'touch .foo' worked after removing cwd"
2956 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
2958 ls . > /dev/null && error "'ls .' worked after removing cwd"
2959 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
2960 is_patchless || ( cd . && error "'cd .' worked after removing cwd" )
2961 mkdir . && error "'mkdir .' worked after removing cwd"
2962 rmdir . && error "'rmdir .' worked after removing cwd"
2963 ln -s . foo && error "'ln -s .' worked after removing cwd"
2964 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
2966 run_test 48b "Access removed working dir (should return errors)="
2968 test_48c() { # bug 2350
2969 check_kernel_version 36 || return 0
2970 #lctl set_param debug=-1
2972 mkdir -p $DIR/d48c/dir
2974 $TRACE rmdir $DIR/d48c/dir || error "remove cwd $DIR/d48c/dir failed"
2975 $TRACE touch foo && error "'touch foo' worked after removing cwd"
2976 $TRACE mkdir foo && error "'mkdir foo' worked after removing cwd"
2977 if check_kernel_version 44; then
2978 touch .foo && error "'touch .foo' worked after removing cwd"
2979 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
2981 $TRACE ls . && error "'ls .' worked after removing cwd"
2982 $TRACE ls .. || error "'ls ..' failed after removing cwd"
2983 is_patchless || ( $TRACE cd . && error "'cd .' worked after removing cwd" )
2984 $TRACE mkdir . && error "'mkdir .' worked after removing cwd"
2985 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
2986 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
2987 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
2989 run_test 48c "Access removed working subdir (should return errors)"
2991 test_48d() { # bug 2350
2992 check_kernel_version 36 || return 0
2993 #lctl set_param debug=-1
2995 mkdir -p $DIR/d48d/dir
2997 $TRACE rmdir $DIR/d48d/dir || error "remove cwd $DIR/d48d/dir failed"
2998 $TRACE rmdir $DIR/d48d || error "remove parent $DIR/d48d failed"
2999 $TRACE touch foo && error "'touch foo' worked after removing parent"
3000 $TRACE mkdir foo && error "'mkdir foo' worked after removing parent"
3001 if check_kernel_version 44; then
3002 touch .foo && error "'touch .foo' worked after removing parent"
3003 mkdir .foo && error "'mkdir .foo' worked after removing parent"
3005 $TRACE ls . && error "'ls .' worked after removing parent"
3006 $TRACE ls .. && error "'ls ..' worked after removing parent"
3007 is_patchless || ( $TRACE cd . && error "'cd .' worked after recreate parent" )
3008 $TRACE mkdir . && error "'mkdir .' worked after removing parent"
3009 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
3010 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
3011 is_patchless || ( $TRACE cd .. && error "'cd ..' worked after removing parent" || true )
3013 run_test 48d "Access removed parent subdir (should return errors)"
3015 test_48e() { # bug 4134
3016 check_kernel_version 41 || return 0
3017 #lctl set_param debug=-1
3019 mkdir -p $DIR/d48e/dir
3021 $TRACE rmdir $DIR/d48e/dir || error "remove cwd $DIR/d48e/dir failed"
3022 $TRACE rmdir $DIR/d48e || error "remove parent $DIR/d48e failed"
3023 $TRACE touch $DIR/d48e || error "'touch $DIR/d48e' failed"
3024 $TRACE chmod +x $DIR/d48e || error "'chmod +x $DIR/d48e' failed"
3025 # On a buggy kernel addition of "touch foo" after cd .. will
3026 # produce kernel oops in lookup_hash_it
3027 touch ../foo && error "'cd ..' worked after recreate parent"
3029 $TRACE rm $DIR/d48e || error "rm '$DIR/d48e' failed"
3031 run_test 48e "Access to recreated parent subdir (should return errors)"
3037 ls /proc/$$/cwd || error
3039 run_test 50 "special situations: /proc symlinks ==============="
3041 test_51a() { # was test_51
3042 # bug 1516 - create an empty entry right after ".." then split dir
3045 $MCREATE $DIR/d51/bar
3047 createmany -m $DIR/d51/longfile 201
3049 while [ `ls -sd $DIR/d51 | awk '{ print $1 }'` -eq 4 ]; do
3050 $MCREATE $DIR/d51/longfile$FNUM
3055 ls -l $DIR/d51 > /dev/null || error
3057 run_test 51a "special situations: split htree with empty entry =="
3059 export NUMTEST=70000
3061 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
3062 [ $NUMFREE -lt 21000 ] && \
3063 skip "not enough free inodes ($NUMFREE)" && \
3066 [ $NUMFREE -lt $NUMTEST ] && NUMTEST=$(($NUMFREE - 50))
3069 createmany -d $DIR/d51b/t- $NUMTEST
3071 run_test 51b "mkdir .../t-0 --- .../t-$NUMTEST ===================="
3073 test_51ba() { # LU-993
3074 local BASE=$DIR/d51b
3075 # unlink all but 100 subdirectories, then check it still works
3077 local DELETE=$((NUMTEST - LEFT))
3079 ! [ -d "${BASE}/t-$DELETE" ] && skip "test_51b() not run" && return 0
3081 # for ldiskfs the nlink count should be 1, but this is OSD specific
3082 # and so this is listed for informational purposes only
3083 log "nlink before: $(stat -c %h $BASE)"
3084 unlinkmany -d $BASE/t- $DELETE ||
3085 error "unlink of first $DELETE subdirs failed"
3087 log "nlink between: $(stat -c %h $BASE)"
3088 local FOUND=$(ls -l ${BASE} | wc -l)
3089 FOUND=$((FOUND - 1)) # trim the first line of ls output
3090 [ $FOUND -ne $LEFT ] &&
3091 error "can't find subdirs: found only $FOUND/$LEFT"
3093 unlinkmany -d $BASE/t- $DELETE $LEFT ||
3094 error "unlink of second $LEFT subdirs failed"
3095 log "nlink after: $(stat -c %h $BASE)"
3097 run_test 51ba "rmdir .../t-0 --- .../t-$NUMTEST"
3100 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3102 local ndirs=${TEST51BB_NDIRS:-10}
3103 local nfiles=${TEST51BB_NFILES:-100}
3105 local numfree=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
3107 [ $numfree -lt $(( ndirs * nfiles)) ] && \
3108 nfiles=$(( numfree / ndirs - 10 ))
3110 local dir=$DIR/d51bb
3112 local savePOLICY=$(lctl get_param -n lmv.*.placement)
3113 lctl set_param -n lmv.*.placement=CHAR
3116 local IUSED=$(lfs df -i $dir | grep MDT | awk '{print $3}')
3120 for ((i=0; i < $ndirs; i++)); do
3121 dirs[i]=$dir/$RANDOM
3122 echo Creating directory ${dirs[i]}
3125 echo Creating $nfiles in dir ${dirs[i]} ...
3126 echo "createmany -o ${dirs[i]}/$tfile- $nfiles"
3127 createmany -o ${dirs[i]}/$tfile- $nfiles
3133 IUSED=$(lfs df -i $dir | grep MDT | awk '{print $3}')
3137 for ((i=0; i<${#NEWUSED[@]}; i++)); do
3138 echo "mds $i: inodes count OLD ${OLDUSED[$i]} NEW ${NEWUSED[$i]}"
3139 [ ${OLDUSED[$i]} -lt ${NEWUSED[$i]} ] || rc=$((rc + 1))
3142 lctl set_param -n lmv.*.placement=$savePOLICY
3144 [ $rc -ne $MDSCOUNT ] || \
3145 error "Objects/inodes are not distributed over all mds servers"
3147 run_test 51bb "mkdir createmany CMD $MDSCOUNT ===================="
3150 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping test with few OSTs" && return
3152 createmany -o $DIR/d51d/t- 1000
3153 $GETSTRIPE $DIR/d51d > $TMP/files
3154 for N in `seq 0 $((OSTCOUNT - 1))`; do
3155 OBJS[$N]=`awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}' $TMP/files`
3156 OBJS0[$N]=`grep -A 1 idx $TMP/files | awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}'`
3157 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
3159 unlinkmany $DIR/d51d/t- 1000
3162 for N in `seq 1 $((OSTCOUNT - 1))`; do
3163 [ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ] && \
3164 error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
3165 [ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ] && \
3166 error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
3168 [ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ] && \
3169 error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
3170 [ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ] && \
3171 error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
3175 run_test 51d "check object distribution ===================="
3178 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
3181 chattr +a $DIR/d52a/foo || error "chattr +a failed"
3182 echo bar >> $DIR/d52a/foo || error "append bar failed"
3183 cp /etc/hosts $DIR/d52a/foo && error "cp worked"
3184 rm -f $DIR/d52a/foo 2>/dev/null && error "rm worked"
3185 link $DIR/d52a/foo $DIR/d52a/foo_link 2>/dev/null && error "link worked"
3186 echo foo >> $DIR/d52a/foo || error "append foo failed"
3187 mrename $DIR/d52a/foo $DIR/d52a/foo_ren && error "rename worked"
3188 lsattr $DIR/d52a/foo | egrep -q "^-+a[-e]+ $DIR/d52a/foo" || error "lsattr"
3189 chattr -a $DIR/d52a/foo || error "chattr -a failed"
3190 cp -r $DIR/d52a /tmp/
3191 rm -fr $DIR/d52a || error "cleanup rm failed"
3193 run_test 52a "append-only flag test (should return errors) ====="
3196 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
3199 chattr +i $DIR/d52b/foo || error "chattr +i failed"
3200 cat test > $DIR/d52b/foo && error "cat test worked"
3201 cp /etc/hosts $DIR/d52b/foo && error "cp worked"
3202 rm -f $DIR/d52b/foo 2>/dev/null && error "rm worked"
3203 link $DIR/d52b/foo $DIR/d52b/foo_link 2>/dev/null && error "link worked"
3204 echo foo >> $DIR/d52b/foo && error "echo worked"
3205 mrename $DIR/d52b/foo $DIR/d52b/foo_ren && error "rename worked"
3206 [ -f $DIR/d52b/foo ] || error
3207 [ -f $DIR/d52b/foo_ren ] && error
3208 lsattr $DIR/d52b/foo | egrep -q "^-+i[-e]+ $DIR/d52b/foo" || error "lsattr"
3209 chattr -i $DIR/d52b/foo || error "chattr failed"
3211 rm -fr $DIR/d52b || error
3213 run_test 52b "immutable flag test (should return errors) ======="
3216 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3217 remote_ost_nodsh && skip "remote OST with nodsh" && return
3226 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
3227 for value in $(do_facet $SINGLEMDS lctl get_param osc.$mdtosc.prealloc_last_id) ; do
3228 param=`echo ${value[0]} | cut -d "=" -f1`
3229 ostname=`echo $param | cut -d "." -f2 | cut -d - -f 1-2`
3230 mds_last=$(do_facet $SINGLEMDS lctl get_param -n $param)
3231 ostnum=$(echo $ostname | sed "s/${FSNAME}-OST//g" | awk '{print ($1+1)}' )
3232 ost_last=$(do_facet ost$ostnum lctl get_param -n obdfilter.$ostname.last_id | head -n 1)
3233 echo "$ostname.last_id=$ost_last ; MDS.last_id=$mds_last"
3234 if [ $ost_last != $mds_last ]; then
3235 error "$ostname.last_id=$ost_last ; MDS.last_id=$mds_last"
3239 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
3242 [ ! -f "$SOCKETSERVER" ] && skip_env "no socketserver, skipping" && return
3243 [ ! -f "$SOCKETCLIENT" ] && skip_env "no socketclient, skipping" && return
3244 $SOCKETSERVER $DIR/socket
3245 $SOCKETCLIENT $DIR/socket || error
3246 $MUNLINK $DIR/socket
3248 run_test 54a "unix domain socket test =========================="
3254 dd if=/dev/zero of=$f bs=`page_size` count=1
3256 run_test 54b "char device works in lustre ======================"
3259 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
3260 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
3261 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
3263 for i in `seq 3 7`; do
3264 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
3274 loopdev="$DIR/loop54c"
3277 [ -z "$LOOPNUM" ] && echo "couldn't find empty loop device" && return
3278 mknod $loopdev b 7 $LOOPNUM
3279 echo "make a loop file system with $tfile on $loopdev ($LOOPNUM)..."
3280 dd if=/dev/zero of=$tfile bs=`page_size` seek=1024 count=1 > /dev/null
3281 losetup $loopdev $tfile || error "can't set up $loopdev for $tfile"
3282 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
3284 mount -t ext2 $loopdev $tdir || error "error mounting $loopdev on $tdir"
3285 dd if=/dev/zero of=$tdir/tmp bs=`page_size` count=30 || error "dd write"
3287 dd if=$tdir/tmp of=/dev/zero bs=`page_size` count=30 || error "dd read"
3292 run_test 54c "block device works in lustre ====================="
3298 [ "$string" = `echo $string > $f | cat $f` ] || error
3300 run_test 54d "fifo device works in lustre ======================"
3303 check_kernel_version 46 || return 0
3306 cp -aL /dev/console $f
3307 echo $string > $f || error
3309 run_test 54e "console/tty device works in lustre ======================"
3311 #The test_55 used to be iopen test and it was removed by bz#24037.
3312 #run_test 55 "check iopen_connect_dentry() ======================"
3314 test_56a() { # was test_56
3320 NUMFILESx2=$(($NUMFILES * 2))
3321 for i in `seq 1 $NUMFILES` ; do
3322 touch $DIR/d56/file$i
3323 touch $DIR/d56/dir/file$i
3326 # test lfs getstripe with --recursive
3327 FILENUM=`$GETSTRIPE --recursive $DIR/d56 | grep -c obdidx`
3328 [ $FILENUM -eq $NUMFILESx2 ] ||
3329 error "$GETSTRIPE --recursive: found $FILENUM, not $NUMFILESx2"
3330 FILENUM=`$GETSTRIPE $DIR/d56 | grep -c obdidx`
3331 [ $FILENUM -eq $NUMFILES ] ||
3332 error "$GETSTRIPE $DIR/d56: found $FILENUM, not $NUMFILES"
3333 echo "$GETSTRIPE --recursive passed."
3335 # test lfs getstripe with file instead of dir
3336 FILENUM=`$GETSTRIPE $DIR/d56/file1 | grep -c obdidx`
3337 [ $FILENUM -eq 1 ] || error \
3338 "$GETSTRIPE $DIR/d56/file1: found $FILENUM, not 1"
3339 echo "$GETSTRIPE file1 passed."
3341 #test lfs getstripe with --verbose
3342 [ `$GETSTRIPE --verbose $DIR/d56 | grep -c lmm_magic` -eq $NUMFILES ] ||
3343 error "$GETSTRIPE --verbose $DIR/d56: want $NUMFILES lmm_magic"
3344 [ `$GETSTRIPE $DIR/d56 | grep -c lmm_magic` -eq 0 ] ||
3345 error "$GETSTRIPE $DIR/d56: showed lmm_magic"
3346 echo "$GETSTRIPE --verbose passed."
3348 #test lfs getstripe with --obd
3349 $GETSTRIPE --obd wrong_uuid $DIR/d56 2>&1 | grep -q "unknown obduuid" ||
3350 error "$GETSTRIPE --obd wrong_uuid should return error message"
3352 [ "$OSTCOUNT" -lt 2 ] &&
3353 skip_env "skipping other $GETSTRIPE --obd test" && return
3356 OBDUUID=$(ostuuid_from_index $OSTIDX)
3357 FILENUM=`$GETSTRIPE -ir $DIR/d56 | grep -x $OSTIDX | wc -l`
3358 FOUND=`$GETSTRIPE -r --obd $OBDUUID $DIR/d56 | grep obdidx | wc -l`
3359 [ $FOUND -eq $FILENUM ] ||
3360 error "$GETSTRIPE --obd wrong: found $FOUND, expected $FILENUM"
3361 [ `$GETSTRIPE -r -v --obd $OBDUUID $DIR/d56 |
3362 sed '/^[ ]*'${OSTIDX}'[ ]/d' |
3363 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l` -eq 0 ] ||
3364 error "$GETSTRIPE --obd: should not show file on other obd"
3365 echo "$GETSTRIPE --obd passed"
3367 run_test 56a "check $GETSTRIPE"
3372 local LOCAL_NUMFILES="$1"
3373 local LOCAL_NUMDIRS="$2"
3374 local MKDIR_PARAMS="$3"
3376 if [ ! -d "$TDIR" ] ; then
3378 [ "$MKDIR_PARAMS" ] && $SETSTRIPE $MKDIR_PARAMS $TDIR
3379 for i in `seq 1 $LOCAL_NUMFILES` ; do
3382 for i in `seq 1 $LOCAL_NUMDIRS` ; do
3384 for j in `seq 1 $LOCAL_NUMFILES` ; do
3385 touch $TDIR/dir$i/file$j
3391 setup_56_special() {
3395 if [ ! -e "$TDIR/loop1b" ] ; then
3396 for i in `seq 1 $LOCAL_NUMFILES` ; do
3397 mknod $TDIR/loop${i}b b 7 $i
3398 mknod $TDIR/null${i}c c 1 3
3399 ln -s $TDIR/file1 $TDIR/link${i}l
3401 for i in `seq 1 $LOCAL_NUMDIRS` ; do
3402 mknod $TDIR/dir$i/loop${i}b b 7 $i
3403 mknod $TDIR/dir$i/null${i}c c 1 3
3404 ln -s $TDIR/dir$i/file1 $TDIR/dir$i/link${i}l
3413 setup_56 $NUMFILES $NUMDIRS
3415 EXPECTED=$(($NUMDIRS + 2))
3416 # test lfs find with -name
3417 for i in $(seq 1 $NUMFILES) ; do
3418 NUMS=$($LFIND -name "*$i" $TDIR | wc -l)
3419 [ $NUMS -eq $EXPECTED ] ||
3420 error "lfs find -name \"*$i\" $TDIR wrong: "\
3421 "found $NUMS, expected $EXPECTED"
3424 run_test 56g "check lfs find -name ============================="
3430 setup_56 $NUMFILES $NUMDIRS
3432 EXPECTED=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
3433 # test lfs find with ! -name
3434 for i in $(seq 1 $NUMFILES) ; do
3435 NUMS=$($LFIND ! -name "*$i" $TDIR | wc -l)
3436 [ $NUMS -eq $EXPECTED ] ||
3437 error "lfs find ! -name \"*$i\" $TDIR wrong: "\
3438 "found $NUMS, expected $EXPECTED"
3441 run_test 56h "check lfs find ! -name ============================="
3446 UUID=$(ostuuid_from_index 0 $DIR/$tdir)
3447 CMD="$LFIND -ost $UUID $DIR/$tdir"
3449 [ -z "$OUT" ] || error "\"$CMD\" returned directory '$OUT'"
3451 run_test 56i "check 'lfs find -ost UUID' skips directories ======="
3455 setup_56_special $NUMFILES $NUMDIRS
3457 EXPECTED=$((NUMDIRS + 1))
3458 CMD="$LFIND -type d $TDIR"
3459 NUMS=$($CMD | wc -l)
3460 [ $NUMS -eq $EXPECTED ] ||
3461 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3463 run_test 56j "check lfs find -type d ============================="
3467 setup_56_special $NUMFILES $NUMDIRS
3469 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
3470 CMD="$LFIND -type f $TDIR"
3471 NUMS=$($CMD | wc -l)
3472 [ $NUMS -eq $EXPECTED ] ||
3473 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3475 run_test 56k "check lfs find -type f ============================="
3479 setup_56_special $NUMFILES $NUMDIRS
3481 EXPECTED=$((NUMDIRS + NUMFILES))
3482 CMD="$LFIND -type b $TDIR"
3483 NUMS=$($CMD | wc -l)
3484 [ $NUMS -eq $EXPECTED ] ||
3485 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3487 run_test 56l "check lfs find -type b ============================="
3491 setup_56_special $NUMFILES $NUMDIRS
3493 EXPECTED=$((NUMDIRS + NUMFILES))
3494 CMD="$LFIND -type c $TDIR"
3495 NUMS=$($CMD | wc -l)
3496 [ $NUMS -eq $EXPECTED ] ||
3497 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3499 run_test 56m "check lfs find -type c ============================="
3503 setup_56_special $NUMFILES $NUMDIRS
3505 EXPECTED=$((NUMDIRS + NUMFILES))
3506 CMD="$LFIND -type l $TDIR"
3507 NUMS=$($CMD | wc -l)
3508 [ $NUMS -eq $EXPECTED ] ||
3509 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3511 run_test 56n "check lfs find -type l ============================="
3515 setup_56 $NUMFILES $NUMDIRS
3517 utime $TDIR/file1 > /dev/null || error "utime (1)"
3518 utime $TDIR/file2 > /dev/null || error "utime (2)"
3519 utime $TDIR/dir1 > /dev/null || error "utime (3)"
3520 utime $TDIR/dir2 > /dev/null || error "utime (4)"
3521 utime $TDIR/dir1/file1 > /dev/null || error "utime (5)"
3522 dd if=/dev/zero count=1 >> $TDIR/dir1/file1 && sync
3525 NUMS=`$LFIND -mtime +0 $TDIR | wc -l`
3526 [ $NUMS -eq $EXPECTED ] || \
3527 error "lfs find -mtime +0 $TDIR wrong: found $NUMS, expected $EXPECTED"
3530 CMD="$LFIND -mtime 0 $TDIR"
3531 NUMS=$($CMD | wc -l)
3532 [ $NUMS -eq $EXPECTED ] ||
3533 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3535 run_test 56o "check lfs find -mtime for old files =========================="
3538 [ $RUNAS_ID -eq $UID ] &&
3539 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
3542 setup_56 $NUMFILES $NUMDIRS
3544 chown $RUNAS_ID $TDIR/file* || error "chown $DIR/${tdir}g/file$i failed"
3546 CMD="$LFIND -uid $RUNAS_ID $TDIR"
3547 NUMS=$($CMD | wc -l)
3548 [ $NUMS -eq $EXPECTED ] || \
3549 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3551 EXPECTED=$(((NUMFILES + 1) * NUMDIRS + 1))
3552 CMD="$LFIND ! -uid $RUNAS_ID $TDIR"
3553 NUMS=$($CMD | wc -l)
3554 [ $NUMS -eq $EXPECTED ] || \
3555 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3557 run_test 56p "check lfs find -uid and ! -uid ==============================="
3560 [ $RUNAS_ID -eq $UID ] &&
3561 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
3564 setup_56 $NUMFILES $NUMDIRS
3566 chgrp $RUNAS_GID $TDIR/file* || error "chown $TDIR/file$i failed"
3569 CMD="$LFIND -gid $RUNAS_GID $TDIR"
3570 NUMS=$($CMD | wc -l)
3571 [ $NUMS -eq $EXPECTED ] ||
3572 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3574 EXPECTED=$(( ($NUMFILES+1) * $NUMDIRS + 1))
3575 CMD="$LFIND ! -gid $RUNAS_GID $TDIR"
3576 NUMS=$($CMD | wc -l)
3577 [ $NUMS -eq $EXPECTED ] ||
3578 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3580 run_test 56q "check lfs find -gid and ! -gid ==============================="
3584 setup_56 $NUMFILES $NUMDIRS
3587 CMD="$LFIND -size 0 -type f $TDIR"
3588 NUMS=$($CMD | wc -l)
3589 [ $NUMS -eq $EXPECTED ] ||
3590 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3592 CMD="$LFIND ! -size 0 -type f $TDIR"
3593 NUMS=$($CMD | wc -l)
3594 [ $NUMS -eq $EXPECTED ] ||
3595 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3596 echo "test" > $TDIR/$tfile
3597 echo "test2" > $TDIR/$tfile.2 && sync
3599 CMD="$LFIND -size 5 -type f $TDIR"
3600 NUMS=$($CMD | wc -l)
3601 [ $NUMS -eq $EXPECTED ] ||
3602 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3604 CMD="$LFIND -size +5 -type f $TDIR"
3605 NUMS=$($CMD | wc -l)
3606 [ $NUMS -eq $EXPECTED ] ||
3607 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3609 CMD="$LFIND -size +0 -type f $TDIR"
3610 NUMS=$($CMD | wc -l)
3611 [ $NUMS -eq $EXPECTED ] ||
3612 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3614 CMD="$LFIND ! -size -5 -type f $TDIR"
3615 NUMS=$($CMD | wc -l)
3616 [ $NUMS -eq $EXPECTED ] ||
3617 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3619 CMD="$LFIND -size -5 -type f $TDIR"
3620 NUMS=$($CMD | wc -l)
3621 [ $NUMS -eq $EXPECTED ] ||
3622 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3624 run_test 56r "check lfs find -size works =========================="
3626 test_56s() { # LU-611
3628 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT"
3630 if [ $OSTCOUNT -gt 1 ]; then
3631 $SETSTRIPE -c 1 $TDIR/$tfile.{0,1,2,3}
3635 ONESTRIPE=$(((NUMDIRS + 1) * NUMFILES))
3639 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
3640 CMD="$LFIND -stripe-count $OSTCOUNT -type f $TDIR"
3641 NUMS=$($CMD | wc -l)
3642 [ $NUMS -eq $EXPECTED ] ||
3643 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3645 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + EXTRA))
3646 CMD="$LFIND -stripe-count +0 -type f $TDIR"
3647 NUMS=$($CMD | wc -l)
3648 [ $NUMS -eq $EXPECTED ] ||
3649 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3652 CMD="$LFIND -stripe-count 1 -type f $TDIR"
3653 NUMS=$($CMD | wc -l)
3654 [ $NUMS -eq $EXPECTED ] ||
3655 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3657 CMD="$LFIND -stripe-count -2 -type f $TDIR"
3658 NUMS=$($CMD | wc -l)
3659 [ $NUMS -eq $EXPECTED ] ||
3660 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3663 CMD="$LFIND -stripe-count $((OSTCOUNT + 1)) -type f $TDIR"
3664 NUMS=$($CMD | wc -l)
3665 [ $NUMS -eq $EXPECTED ] ||
3666 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3668 run_test 56s "check lfs find -stripe-count works"
3670 test_56t() { # LU-611
3672 setup_56 $NUMFILES $NUMDIRS "-s 512k"
3674 $SETSTRIPE -S 256k $TDIR/$tfile.{0,1,2,3}
3676 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
3677 CMD="$LFIND -stripe-size 512k -type f $TDIR"
3678 NUMS=$($CMD | wc -l)
3679 [ $NUMS -eq $EXPECTED ] ||
3680 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3682 CMD="$LFIND -stripe-size +320k -type f $TDIR"
3683 NUMS=$($CMD | wc -l)
3684 [ $NUMS -eq $EXPECTED ] ||
3685 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3687 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + 4))
3688 CMD="$LFIND -stripe-size +200k -type f $TDIR"
3689 NUMS=$($CMD | wc -l)
3690 [ $NUMS -eq $EXPECTED ] ||
3691 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3693 CMD="$LFIND -stripe-size -640k -type f $TDIR"
3694 NUMS=$($CMD | wc -l)
3695 [ $NUMS -eq $EXPECTED ] ||
3696 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3699 CMD="$LFIND -stripe-size 256k -type f $TDIR"
3700 NUMS=$($CMD | wc -l)
3701 [ $NUMS -eq $EXPECTED ] ||
3702 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3704 CMD="$LFIND -stripe-size -320k -type f $TDIR"
3705 NUMS=$($CMD | wc -l)
3706 [ $NUMS -eq $EXPECTED ] ||
3707 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3710 CMD="$LFIND -stripe-size 1024k -type f $TDIR"
3711 NUMS=$($CMD | wc -l)
3712 [ $NUMS -eq $EXPECTED ] ||
3713 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3715 run_test 56t "check lfs find -stripe-size works"
3717 test_56u() { # LU-611
3719 setup_56 $NUMFILES $NUMDIRS "-i 0"
3721 if [ $OSTCOUNT -gt 1 ]; then
3722 $SETSTRIPE -i 1 $TDIR/$tfile.{0,1,2,3}
3728 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
3729 CMD="$LFIND -stripe-index 0 -type f $TDIR"
3730 NUMS=$($CMD | wc -l)
3731 [ $NUMS -eq $EXPECTED ] ||
3732 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3735 CMD="$LFIND -stripe-index 1 -type f $TDIR"
3736 NUMS=$($CMD | wc -l)
3737 [ $NUMS -eq $EXPECTED ] ||
3738 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3740 CMD="$LFIND ! -stripe-index 0 -type f $TDIR"
3741 NUMS=$($CMD | wc -l)
3742 [ $NUMS -eq $EXPECTED ] ||
3743 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3746 # This should produce an error and not return any files
3747 CMD="$LFIND -stripe-index $OSTCOUNT -type f $TDIR"
3748 NUMS=$($CMD 2>/dev/null | wc -l)
3749 [ $NUMS -eq $EXPECTED ] ||
3750 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3752 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + ONESTRIPE))
3753 CMD="$LFIND -stripe-index 0,1 -type f $TDIR"
3754 NUMS=$($CMD | wc -l)
3755 [ $NUMS -eq $EXPECTED ] ||
3756 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3758 run_test 56u "check lfs find -stripe-index works"
3765 setup_56 $NUMFILES $NUMDIRS
3767 UUID=$(mdtuuid_from_index $MDT_IDX $TDIR)
3768 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT index $MDT_IDX"
3770 for file in $($LFIND -mdt $UUID $TDIR); do
3771 file_mdt_idx=$($GETSTRIPE -M $file)
3772 [ $file_mdt_idx -eq $MDT_IDX ] ||
3773 error "'lfind -mdt $UUID' != 'getstripe -M' ($file_mdt_idx)"
3776 run_test 56v "check 'lfs find -mdt match with lfs getstripe -M' ======="
3779 # note test will not do anything if MDS is not local
3780 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3781 local MNTDEV="osd*.*MDT*.mntdev"
3782 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
3783 [ -z "$DEV" ] && error "can't access $MNTDEV"
3784 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
3785 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
3786 error "can't access $DEV"
3787 DEVISIZE=`awk '/Inode size:/ { print $3 }' $TMP/t57a.dump`
3788 [ "$DEVISIZE" -gt 128 ] || error "inode size $DEVISIZE"
3792 run_test 57a "verify MDS filesystem created with large inodes =="
3795 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3800 local FILEN=$dir/f$FILECOUNT
3802 rm -rf $dir || error "removing $dir"
3803 mkdir -p $dir || error "creating $dir"
3804 local num=$(get_mds_dir $dir)
3807 echo "mcreating $FILECOUNT files"
3808 createmany -m $dir/f 1 $FILECOUNT || \
3809 error "creating files in $dir"
3811 # verify that files do not have EAs yet
3812 $GETSTRIPE $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
3813 $GETSTRIPE $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
3817 df $dir #make sure we get new statfs data
3818 local MDSFREE=$(do_facet $mymds \
3819 lctl get_param -n osd*.*MDT000$((num -1)).kbytesfree)
3820 local MDCFREE=$(lctl get_param -n mdc.*MDT000$((num -1))-mdc-*.kbytesfree)
3821 echo "opening files to create objects/EAs"
3823 for FILE in `seq -f $dir/f%g 1 $FILECOUNT`; do
3824 $OPENFILE -f O_RDWR $FILE > /dev/null 2>&1 || error "opening $FILE"
3827 # verify that files have EAs now
3828 $GETSTRIPE $FILE1 | grep -q "obdidx" || error "$FILE1 missing EA"
3829 $GETSTRIPE $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
3831 sleep 1 #make sure we get new statfs data
3833 local MDSFREE2=$(do_facet $mymds \
3834 lctl get_param -n osd*.*MDT000$((num -1)).kbytesfree)
3835 local MDCFREE2=$(lctl get_param -n mdc.*MDT000$((num -1))-mdc-*.kbytesfree)
3836 if [ "$MDCFREE2" -lt "$((MDCFREE - 8))" ]; then
3837 if [ "$MDSFREE" != "$MDSFREE2" ]; then
3838 error "MDC before $MDCFREE != after $MDCFREE2"
3840 echo "MDC before $MDCFREE != after $MDCFREE2"
3841 echo "unable to confirm if MDS has large inodes"
3846 run_test 57b "default LOV EAs are stored inside large inodes ==="
3849 [ -z "$(which wiretest 2>/dev/null)" ] && skip_env "could not find wiretest" && return
3852 run_test 58 "verify cross-platform wire constants =============="
3855 echo "touch 130 files"
3856 createmany -o $DIR/f59- 130
3858 unlinkmany $DIR/f59- 130
3861 # wait for commitment of removal
3863 run_test 59 "verify cancellation of llog records async ========="
3865 TEST60_HEAD="test_60 run $RANDOM"
3867 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
3868 [ ! -f run-llog.sh ] && skip_env "missing subtest run-llog.sh" && return
3869 log "$TEST60_HEAD - from kernel mode"
3870 do_facet mgs sh run-llog.sh
3872 run_test 60a "llog sanity tests run from kernel module =========="
3874 test_60b() { # bug 6411
3876 LLOG_COUNT=`dmesg | awk "/$TEST60_HEAD/{marker = 1; from_marker = 0;}
3888 [ $LLOG_COUNT -gt 50 ] && error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)"|| true
3890 run_test 60b "limit repeated messages from CERROR/CWARN ========"
3893 echo "create 5000 files"
3894 createmany -o $DIR/f60c- 5000
3895 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
3896 lctl set_param fail_loc=0x80000137
3897 unlinkmany $DIR/f60c- 5000
3898 lctl set_param fail_loc=0
3900 run_test 60c "unlink file when mds full"
3903 SAVEPRINTK=$(lctl get_param -n printk)
3905 # verify "lctl mark" is even working"
3906 MESSAGE="test message ID $RANDOM $$"
3907 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
3908 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
3910 lctl set_param printk=0 || error "set lnet.printk failed"
3911 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
3912 MESSAGE="new test message ID $RANDOM $$"
3913 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
3914 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
3915 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
3917 lctl set_param -n printk="$SAVEPRINTK"
3919 run_test 60d "test printk console message masking"
3923 dd if=/dev/zero of=$f bs=`page_size` count=1
3924 cancel_lru_locks osc
3925 multiop $f OSMWUc || error
3928 run_test 61 "mmap() writes don't make sync hang ================"
3930 # bug 2330 - insufficient obd_match error checking causes LBUG
3934 cancel_lru_locks osc
3935 lctl set_param fail_loc=0x405
3936 cat $f && error "cat succeeded, expect -EIO"
3937 lctl set_param fail_loc=0
3939 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
3940 # match every page all of the time.
3941 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
3943 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
3944 test_63a() { # was test_63
3945 MAX_DIRTY_MB=`lctl get_param -n osc.*.max_dirty_mb | head -n 1`
3946 lctl set_param -n osc.*.max_dirty_mb 0
3947 for i in `seq 10` ; do
3948 dd if=/dev/zero of=$DIR/f63 bs=8k &
3954 lctl set_param -n osc.*.max_dirty_mb $MAX_DIRTY_MB
3955 rm -f $DIR/f63 || true
3957 run_test 63a "Verify oig_wait interruption does not crash ======="
3959 # bug 2248 - async write errors didn't return to application on sync
3960 # bug 3677 - async write errors left page locked
3963 lctl set_param debug=-1
3965 # ensure we have a grant to do async writes
3966 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
3969 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
3970 lctl set_param fail_loc=0x80000406
3971 multiop $DIR/$tfile Owy && \
3972 error "sync didn't return ENOMEM"
3973 sync; sleep 2; sync # do a real sync this time to flush page
3974 lctl get_param -n llite.*.dump_page_cache | grep locked && \
3975 error "locked page left in cache after async error" || true
3978 run_test 63b "async write errors should be returned to fsync ==="
3982 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
3984 run_test 64a "verify filter grant calculations (in kernel) ====="
3987 [ ! -f oos.sh ] && skip_env "missing subtest oos.sh" && return
3990 run_test 64b "check out-of-space detection on client ==========="
3992 # bug 1414 - set/get directories' stripe info
3996 $LVERIFY $DIR/d65 $DIR/d65/f1 || error "lverify failed"
3998 run_test 65a "directory with no stripe info ===================="
4002 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/d65||error "setstripe"
4004 $LVERIFY $DIR/d65 $DIR/d65/f2 || error "lverify failed"
4006 run_test 65b "directory setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1"
4009 if [ $OSTCOUNT -gt 1 ]; then
4011 $SETSTRIPE -S $(($STRIPESIZE * 4)) -i 1 \
4012 -c $(($OSTCOUNT - 1)) $DIR/d65 || error "setstripe"
4014 $LVERIFY $DIR/d65 $DIR/d65/f3 || error "lverify failed"
4017 run_test 65c "directory setstripe -S $((STRIPESIZE*4)) -i 1 -c $((OSTCOUNT-1))"
4021 if [ $STRIPECOUNT -le 0 ]; then
4023 elif [ $STRIPECOUNT -gt 2000 ]; then
4024 #LOV_MAX_STRIPE_COUNT is 2000
4025 [ $OSTCOUNT -gt 2000 ] && sc=2000 || sc=$(($OSTCOUNT - 1))
4027 sc=$(($STRIPECOUNT - 1))
4029 $SETSTRIPE -S $STRIPESIZE -c $sc $DIR/d65 || error "setstripe"
4030 touch $DIR/d65/f4 $DIR/d65/f5
4031 $LVERIFY $DIR/d65 $DIR/d65/f4 $DIR/d65/f5 || error "lverify failed"
4033 run_test 65d "directory setstripe -S $STRIPESIZE -c stripe_count"
4038 $SETSTRIPE $DIR/d65 || error "setstripe"
4039 $GETSTRIPE -v $DIR/d65 | grep "Default" || error "no stripe info failed"
4041 $LVERIFY $DIR/d65 $DIR/d65/f6 || error "lverify failed"
4043 run_test 65e "directory setstripe defaults ======================="
4047 $RUNAS $SETSTRIPE $DIR/d65f && error "setstripe succeeded" || true
4049 run_test 65f "dir setstripe permission (should return error) ==="
4053 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/d65 ||error "setstripe"
4054 $SETSTRIPE -d $DIR/d65 || error "setstripe"
4055 $GETSTRIPE -v $DIR/d65 | grep "Default" || \
4056 error "delete default stripe failed"
4058 run_test 65g "directory setstripe -d ==========================="
4062 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/d65 ||error "setstripe"
4063 mkdir -p $DIR/d65/dd1
4064 [ $($GETSTRIPE -c $DIR/d65) == $($GETSTRIPE -c $DIR/d65/dd1) ] ||
4065 error "stripe info inherit failed"
4067 run_test 65h "directory stripe info inherit ===================="
4069 test_65i() { # bug6367
4070 $SETSTRIPE -S 65536 -c -1 $MOUNT
4072 run_test 65i "set non-default striping on root directory (bug 6367)="
4074 test_65ia() { # bug12836
4075 $GETSTRIPE $MOUNT || error "getstripe $MOUNT failed"
4077 run_test 65ia "getstripe on -1 default directory striping"
4079 test_65ib() { # bug12836
4080 $GETSTRIPE -v $MOUNT || error "getstripe -v $MOUNT failed"
4082 run_test 65ib "getstripe -v on -1 default directory striping"
4084 test_65ic() { # bug12836
4085 $LFS find -mtime -1 $MOUNT || error "find $MOUNT failed"
4087 run_test 65ic "new find on -1 default directory striping"
4089 test_65j() { # bug6367
4091 # if we aren't already remounting for each test, do so for this test
4092 if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
4093 cleanup || error "failed to unmount"
4096 $SETSTRIPE -d $MOUNT || error "setstripe failed"
4098 run_test 65j "set default striping on root directory (bug 6367)="
4100 test_65k() { # bug11679
4101 [ "$OSTCOUNT" -lt 2 ] && skip_env "too few OSTs" && return
4102 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4104 echo "Check OST status: "
4105 local MDS_OSCS=`do_facet $SINGLEMDS lctl dl |
4106 awk '/[oO][sS][cC].*md[ts]/ { print $4 }'`
4108 for OSC in $MDS_OSCS; do
4109 echo $OSC "is activate"
4110 do_facet $SINGLEMDS lctl --device %$OSC activate
4113 do_facet client mkdir -p $DIR/$tdir
4114 for INACTIVE_OSC in $MDS_OSCS; do
4115 echo "Deactivate: " $INACTIVE_OSC
4116 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
4117 for STRIPE_OSC in $MDS_OSCS; do
4118 OST=`osc_to_ost $STRIPE_OSC`
4119 IDX=`do_facet $SINGLEMDS lctl get_param -n lov.*md*.target_obd |
4120 awk -F: /$OST/'{ print $1 }' | head -n 1`
4122 [ -f $DIR/$tdir/$IDX ] && continue
4123 echo "$SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX"
4124 do_facet client $SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX
4126 [ $RC -ne 0 ] && error "setstripe should have succeeded"
4128 do_facet client rm -f $DIR/$tdir/*
4129 echo $INACTIVE_OSC "is Activate."
4130 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
4133 run_test 65k "validate manual striping works properly with deactivated OSCs"
4135 test_65l() { # bug 12836
4136 mkdir -p $DIR/$tdir/test_dir
4137 $SETSTRIPE -c -1 $DIR/$tdir/test_dir
4138 $LFS find -mtime -1 $DIR/$tdir >/dev/null
4140 run_test 65l "lfs find on -1 stripe dir ========================"
4142 # bug 2543 - update blocks count on client
4145 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
4147 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
4148 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
4150 run_test 66 "update inode blocks count on client ==============="
4156 if [ ! -z "$LLOOP" ]; then
4157 if swapon -s | grep -q $LLOOP; then
4158 swapoff $LLOOP || error "swapoff failed"
4161 $LCTL blockdev_detach $LLOOP || error "detach failed"
4165 if [ ! -z "$LLITELOOPLOAD" ]; then
4173 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
4177 swapon -s | awk '($1 == "'$1'") { print $4 }'
4180 # test case for lloop driver, basic function
4182 [ "$UID" != 0 ] && skip_env "must run as root" && return
4183 llite_lloop_enabled || \
4184 { skip_env "llite_lloop module disabled" && return; }
4186 trap cleanup_68 EXIT
4188 if ! module_loaded llite_lloop; then
4189 if load_module llite/llite_lloop; then
4192 skip_env "can't find module llite_lloop"
4197 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
4198 dd if=/dev/zero of=$DIR/f68a bs=4k count=1024
4199 $LCTL blockdev_attach $DIR/f68a $LLOOP || error "attach failed"
4201 directio rdwr $LLOOP 0 1024 4096 || error "direct write failed"
4202 directio rdwr $LLOOP 0 1025 4096 && error "direct write should fail"
4206 run_test 68a "lloop driver - basic test ========================"
4208 # excercise swapping to lustre by adding a high priority swapfile entry
4209 # and then consuming memory until it is used.
4210 test_68b() { # was test_68
4211 [ "$UID" != 0 ] && skip_env "must run as root" && return
4212 lctl get_param -n devices | grep -q obdfilter && \
4213 skip "local OST" && return
4215 grep -q llite_lloop /proc/modules
4216 [ $? -ne 0 ] && skip "can't find module llite_lloop" && return
4218 [ -z "`$LCTL list_nids | grep -v tcp`" ] && \
4219 skip "can't reliably test swap with TCP" && return
4221 MEMTOTAL=`meminfo MemTotal`
4222 NR_BLOCKS=$((MEMTOTAL>>8))
4223 [[ $NR_BLOCKS -le 2048 ]] && NR_BLOCKS=2048
4225 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
4226 dd if=/dev/zero of=$DIR/f68b bs=64k seek=$NR_BLOCKS count=1
4229 $LCTL blockdev_attach $DIR/f68b $LLOOP || error "attach failed"
4231 trap cleanup_68 EXIT
4233 swapon -p 32767 $LLOOP || error "swapon $LLOOP failed"
4235 echo "before: `swapon -s | grep $LLOOP`"
4236 $MEMHOG $MEMTOTAL || error "error allocating $MEMTOTAL kB"
4237 echo "after: `swapon -s | grep $LLOOP`"
4238 SWAPUSED=`swap_used $LLOOP`
4242 [ $SWAPUSED -eq 0 ] && echo "no swap used???" || true
4244 run_test 68b "support swapping to Lustre ========================"
4246 # bug5265, obdfilter oa2dentry return -ENOENT
4247 # #define OBD_FAIL_OST_ENOENT 0x217
4249 remote_ost_nodsh && skip "remote OST with nodsh" && return
4252 $SETSTRIPE -c 1 -i 0 $f
4254 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
4256 do_facet ost1 lctl set_param fail_loc=0x217
4257 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
4258 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
4260 do_facet ost1 lctl set_param fail_loc=0
4261 $DIRECTIO write $f 0 2 || error "write error"
4263 cancel_lru_locks osc
4264 $DIRECTIO read $f 0 1 || error "read error"
4266 do_facet ost1 lctl set_param fail_loc=0x217
4267 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
4269 do_facet ost1 lctl set_param fail_loc=0
4272 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
4276 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
4278 run_test 71 "Running dbench on lustre (don't segment fault) ===="
4280 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
4281 check_kernel_version 43 || return 0
4282 [ "$RUNAS_ID" = "$UID" ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4284 # Check that testing environment is properly set up. Skip if not
4285 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS || {
4286 skip_env "User $RUNAS_ID does not exist - skipping"
4289 # We had better clear the $DIR to get enough space for dd
4294 $RUNAS dd if=/dev/zero of=$DIR/f72 bs=512 count=1 || error
4295 # See if we are still setuid/sgid
4296 test -u $DIR/f72 -o -g $DIR/f72 && error "S/gid is not dropped on write"
4297 # Now test that MDS is updated too
4298 cancel_lru_locks mdc
4299 test -u $DIR/f72 -o -g $DIR/f72 && error "S/gid is not dropped on MDS"
4303 run_test 72a "Test that remove suid works properly (bug5695) ===="
4305 test_72b() { # bug 24226 -- keep mode setting when size is not changing
4308 [ "$RUNAS_ID" = "$UID" ] && \
4309 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4310 [ "$RUNAS_ID" -eq 0 ] && \
4311 skip_env "RUNAS_ID = 0 -- skipping" && return
4313 # Check that testing environment is properly set up. Skip if not
4314 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS || {
4315 skip_env "User $RUNAS_ID does not exist - skipping"
4318 touch $DIR/${tfile}-f{g,u}
4319 mkdir $DIR/${tfile}-d{g,u}
4320 chmod 770 $DIR/${tfile}-{f,d}{g,u}
4321 chmod g+s $DIR/${tfile}-{f,d}g
4322 chmod u+s $DIR/${tfile}-{f,d}u
4323 for perm in 777 2777 4777; do
4324 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
4325 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
4326 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
4327 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
4331 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
4333 # bug 3462 - multiple simultaneous MDC requests
4337 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
4340 lctl set_param fail_loc=0x80000129
4341 multiop $DIR/d73-1/f73-2 Oc &
4343 lctl set_param fail_loc=0
4345 multiop $DIR/d73-2/f73-3 Oc &
4349 wait $pid1 || return 1
4353 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
4354 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
4355 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
4359 run_test 73 "multiple MDC requests (should not deadlock)"
4361 test_74a() { # bug 6149, 6184
4362 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
4364 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
4365 # will spin in a tight reconnection loop
4367 lctl set_param fail_loc=0x8000030e
4368 # get any lock that won't be difficult - lookup works.
4370 lctl set_param fail_loc=0
4374 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
4376 test_74b() { # bug 13310
4377 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
4379 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
4380 # will spin in a tight reconnection loop
4381 lctl set_param fail_loc=0x8000030e
4382 # get a "difficult" lock
4384 lctl set_param fail_loc=0
4388 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
4391 #define OBD_FAIL_LDLM_NEW_LOCK
4392 lctl set_param fail_loc=0x80000319
4393 touch $DIR/$tfile && error "Touch successful"
4396 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
4399 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
4402 get_inode_slab_tunables() {
4403 awk '/lustre_inode_cache/ {print $9," ",$10," ",$11; exit}' /proc/slabinfo
4406 set_inode_slab_tunables() {
4407 echo "lustre_inode_cache $1" > /proc/slabinfo
4410 test_76() { # Now for bug 20433, added originally in bug 1443
4411 local SLAB_SETTINGS=`get_inode_slab_tunables`
4412 local CPUS=`getconf _NPROCESSORS_ONLN`
4413 # we cannot set limit below 1 which means 1 inode in each
4414 # per-cpu cache is still allowed
4415 set_inode_slab_tunables "1 1 0"
4416 cancel_lru_locks osc
4417 BEFORE_INODES=`num_inodes`
4418 echo "before inodes: $BEFORE_INODES"
4420 [ "$SLOW" = "no" ] && COUNT=100
4421 for i in `seq $COUNT`; do
4425 cancel_lru_locks osc
4426 AFTER_INODES=`num_inodes`
4427 echo "after inodes: $AFTER_INODES"
4429 while [ $((AFTER_INODES-1*CPUS)) -gt $BEFORE_INODES ]; do
4431 AFTER_INODES=`num_inodes`
4433 echo "wait $wait seconds inodes: $AFTER_INODES"
4434 if [ $wait -gt 30 ]; then
4435 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
4438 set_inode_slab_tunables "$SLAB_SETTINGS"
4440 run_test 76 "confirm clients recycle inodes properly ===="
4446 # Note: in sptlrpc modes which enable its own bulk checksum, the
4447 # original crc32_le bulk checksum will be automatically disabled,
4448 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
4449 # will be checked by sptlrpc code against sptlrpc bulk checksum.
4450 # In this case set_checksums() will not be no-op, because sptlrpc
4451 # bulk checksum will be enabled all through the test.
4453 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
4454 lctl set_param -n osc.*.checksums $1
4458 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
4459 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
4460 CKSUM_TYPES=${CKSUM_TYPES:-"crc32 adler"}
4461 [ "$ORIG_CSUM_TYPE" = "crc32c" ] && CKSUM_TYPES="$CKSUM_TYPES crc32c"
4464 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
4465 log "set checksum type to $1"
4468 F77_TMP=$TMP/f77-temp
4471 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
4472 error "error writing to $F77_TMP"
4475 test_77a() { # bug 10889
4476 $GSS && skip "could not run with gss" && return
4477 [ ! -f $F77_TMP ] && setup_f77
4479 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
4483 run_test 77a "normal checksum read/write operation ============="
4485 test_77b() { # bug 10889
4486 $GSS && skip "could not run with gss" && return
4487 [ ! -f $F77_TMP ] && setup_f77
4488 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
4489 lctl set_param fail_loc=0x80000409
4491 dd if=$F77_TMP of=$DIR/f77b bs=1M count=$F77SZ conv=sync || \
4492 error "dd error: $?"
4493 lctl set_param fail_loc=0
4496 run_test 77b "checksum error on client write ===================="
4498 test_77c() { # bug 10889
4499 $GSS && skip "could not run with gss" && return
4500 [ ! -f $DIR/f77b ] && skip "requires 77b - skipping" && return
4502 for algo in $CKSUM_TYPES; do
4503 cancel_lru_locks osc
4504 set_checksum_type $algo
4505 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
4506 lctl set_param fail_loc=0x80000408
4507 cmp $F77_TMP $DIR/f77b || error "file compare failed"
4508 lctl set_param fail_loc=0
4511 set_checksum_type $ORIG_CSUM_TYPE
4514 run_test 77c "checksum error on client read ==================="
4516 test_77d() { # bug 10889
4517 $GSS && skip "could not run with gss" && return
4518 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
4519 lctl set_param fail_loc=0x80000409
4521 directio write $DIR/f77 0 $F77SZ $((1024 * 1024)) || \
4522 error "direct write: rc=$?"
4523 lctl set_param fail_loc=0
4526 run_test 77d "checksum error on OST direct write ==============="
4528 test_77e() { # bug 10889
4529 $GSS && skip "could not run with gss" && return
4530 [ ! -f $DIR/f77 ] && skip "requires 77d - skipping" && return
4531 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
4532 lctl set_param fail_loc=0x80000408
4534 cancel_lru_locks osc
4535 directio read $DIR/f77 0 $F77SZ $((1024 * 1024)) || \
4536 error "direct read: rc=$?"
4537 lctl set_param fail_loc=0
4540 run_test 77e "checksum error on OST direct read ================"
4542 test_77f() { # bug 10889
4543 $GSS && skip "could not run with gss" && return
4545 for algo in $CKSUM_TYPES; do
4546 cancel_lru_locks osc
4547 set_checksum_type $algo
4548 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
4549 lctl set_param fail_loc=0x409
4550 directio write $DIR/f77 0 $F77SZ $((1024 * 1024)) && \
4551 error "direct write succeeded"
4552 lctl set_param fail_loc=0
4554 set_checksum_type $ORIG_CSUM_TYPE
4557 run_test 77f "repeat checksum error on write (expect error) ===="
4559 test_77g() { # bug 10889
4560 $GSS && skip "could not run with gss" && return
4561 remote_ost_nodsh && skip "remote OST with nodsh" && return
4563 [ ! -f $F77_TMP ] && setup_f77
4565 $SETSTRIPE -c 1 -i 0 $DIR/f77g
4566 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
4567 do_facet ost1 lctl set_param fail_loc=0x8000021a
4569 dd if=$F77_TMP of=$DIR/f77g bs=1M count=$F77SZ || \
4570 error "write error: rc=$?"
4571 do_facet ost1 lctl set_param fail_loc=0
4574 run_test 77g "checksum error on OST write ======================"
4576 test_77h() { # bug 10889
4577 $GSS && skip "could not run with gss" && return
4578 remote_ost_nodsh && skip "remote OST with nodsh" && return
4580 [ ! -f $DIR/f77g ] && skip "requires 77g - skipping" && return
4581 cancel_lru_locks osc
4582 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
4583 do_facet ost1 lctl set_param fail_loc=0x8000021b
4585 cmp $F77_TMP $DIR/f77g || error "file compare failed"
4586 do_facet ost1 lctl set_param fail_loc=0
4589 run_test 77h "checksum error on OST read ======================="
4591 test_77i() { # bug 13805
4592 $GSS && skip "could not run with gss" && return
4593 #define OBD_FAIL_OSC_CONNECT_CKSUM 0x40b
4594 lctl set_param fail_loc=0x40b
4595 remount_client $MOUNT
4596 lctl set_param fail_loc=0
4597 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
4598 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
4599 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
4600 [ "$algo" = "crc32" ] || error "algo set to $algo instead of crc32"
4602 remount_client $MOUNT
4604 run_test 77i "client not supporting OSD_CONNECT_CKSUM =========="
4606 test_77j() { # bug 13805
4607 $GSS && skip "could not run with gss" && return
4608 #define OBD_FAIL_OSC_CKSUM_ADLER_ONLY 0x40c
4609 lctl set_param fail_loc=0x40c
4610 remount_client $MOUNT
4611 lctl set_param fail_loc=0
4612 sleep 2 # wait async osc connect to finish
4613 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
4614 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
4615 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
4616 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
4618 remount_client $MOUNT
4620 run_test 77j "client only supporting ADLER32 ===================="
4622 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
4626 test_78() { # bug 10901
4627 remote_ost || { skip_env "local OST" && return; }
4630 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
4631 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
4632 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
4633 echo "MemTotal: $MEMTOTAL"
4634 # reserve 256MB of memory for the kernel and other running processes,
4635 # and then take 1/2 of the remaining memory for the read/write buffers.
4636 if [ $MEMTOTAL -gt 512 ] ;then
4637 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
4639 # for those poor memory-starved high-end clusters...
4640 MEMTOTAL=$((MEMTOTAL / 2))
4642 echo "Mem to use for directio: $MEMTOTAL"
4643 [ $F78SIZE -gt $MEMTOTAL ] && F78SIZE=$MEMTOTAL
4644 [ $F78SIZE -gt 512 ] && F78SIZE=512
4645 [ $F78SIZE -gt $((MAXFREE / 1024)) ] && F78SIZE=$((MAXFREE / 1024))
4646 SMALLESTOST=`lfs df $DIR |grep OST | awk '{print $4}' |sort -n |head -1`
4647 echo "Smallest OST: $SMALLESTOST"
4648 [ $SMALLESTOST -lt 10240 ] && \
4649 skip "too small OSTSIZE, useless to run large O_DIRECT test" && return 0
4651 [ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ] && \
4652 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
4654 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
4655 echo "File size: $F78SIZE"
4656 $SETSTRIPE -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
4657 for i in `seq 1 $NSEQ`
4659 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
4660 echo directIO rdwr round $i of $NSEQ
4661 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
4666 run_test 78 "handle large O_DIRECT writes correctly ============"
4668 test_79() { # bug 12743
4669 wait_delete_completed
4671 BKTOTAL=$(calc_osc_kbytes kbytestotal)
4672 BKFREE=$(calc_osc_kbytes kbytesfree)
4673 BKAVAIL=$(calc_osc_kbytes kbytesavail)
4675 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
4676 DFTOTAL=`echo $STRING | cut -d, -f1`
4677 DFUSED=`echo $STRING | cut -d, -f2`
4678 DFAVAIL=`echo $STRING | cut -d, -f3`
4679 DFFREE=$(($DFTOTAL - $DFUSED))
4681 ALLOWANCE=$((64 * $OSTCOUNT))
4683 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
4684 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
4685 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
4687 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
4688 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
4689 error "df free($DFFREE) mismatch OST free($BKFREE)"
4691 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
4692 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
4693 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
4696 run_test 79 "df report consistency check ======================="
4698 test_80() { # bug 10718
4699 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
4701 local BEFORE=`date +%s`
4702 cancel_lru_locks osc
4703 local AFTER=`date +%s`
4704 local DIFF=$((AFTER-BEFORE))
4705 if [ $DIFF -gt 1 ] ; then
4706 error "elapsed for 1M@1T = $DIFF"
4711 run_test 80 "Page eviction is equally fast at high offsets too ===="
4713 test_81a() { # LU-456
4714 remote_ost_nodsh && skip "remote OST with nodsh" && return
4715 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
4716 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
4717 do_facet ost0 lctl set_param fail_loc=0x80000228
4719 # write should trigger a retry and success
4720 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
4721 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
4723 if [ $RC -ne 0 ] ; then
4724 error "write should success, but failed for $RC"
4727 run_test 81a "OST should retry write when get -ENOSPC ==============="
4729 test_81b() { # LU-456
4730 remote_ost_nodsh && skip "remote OST with nodsh" && return
4731 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
4732 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
4733 do_facet ost0 lctl set_param fail_loc=0x228
4735 # write should retry several times and return -ENOSPC finally
4736 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
4737 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
4740 if [ $RC -ne $ENOSPC ] ; then
4741 error "dd should fail for -ENOSPC, but succeed."
4744 run_test 81b "OST should return -ENOSPC when retry still fails ======="
4748 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && \
4750 mkdir -p $DIR/d99cvsroot
4751 chown $RUNAS_ID $DIR/d99cvsroot
4752 local oldPWD=$PWD # bug 13584, use $TMP as working dir
4755 $RUNAS cvs -d $DIR/d99cvsroot init || error
4758 run_test 99a "cvs init ========================================="
4761 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
4762 [ ! -d $DIR/d99cvsroot ] && test_99a
4764 # some versions of cvs import exit(1) when asked to import links or
4765 # files they can't read. ignore those files.
4766 TOIGNORE=$(find . -type l -printf '-I %f\n' -o \
4767 ! -perm +4 -printf '-I %f\n')
4768 $RUNAS cvs -d $DIR/d99cvsroot import -m "nomesg" $TOIGNORE \
4769 d99reposname vtag rtag
4771 run_test 99b "cvs import ======================================="
4774 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
4775 [ ! -d $DIR/d99cvsroot ] && test_99b
4777 mkdir -p $DIR/d99reposname
4778 chown $RUNAS_ID $DIR/d99reposname
4779 $RUNAS cvs -d $DIR/d99cvsroot co d99reposname
4781 run_test 99c "cvs checkout ====================================="
4784 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
4785 [ ! -d $DIR/d99cvsroot ] && test_99c
4786 cd $DIR/d99reposname
4788 $RUNAS cvs add -m 'addmsg' foo99
4790 run_test 99d "cvs add =========================================="
4793 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
4794 [ ! -d $DIR/d99cvsroot ] && test_99c
4795 cd $DIR/d99reposname
4798 run_test 99e "cvs update ======================================="
4801 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
4802 [ ! -d $DIR/d99cvsroot ] && test_99d
4803 cd $DIR/d99reposname
4804 $RUNAS cvs commit -m 'nomsg' foo99
4805 rm -fr $DIR/d99cvsroot
4807 run_test 99f "cvs commit ======================================="
4810 [ "$NETTYPE" = tcp ] || \
4811 { skip "TCP secure port test, not useful for NETTYPE=$NETTYPE" && \
4814 remote_ost_nodsh && skip "remote OST with nodsh" && return
4815 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4817 { skip "useless for local single node setup" && return; }
4819 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
4820 [ "$PROT" != "tcp" ] && continue
4821 RPORT=$(echo $REMOTE | cut -d: -f2)
4822 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
4825 LPORT=`echo $LOCAL | cut -d: -f2`
4826 if [ $LPORT -ge 1024 ]; then
4827 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
4829 error_exit "local: $LPORT > 1024, remote: $RPORT"
4832 [ "$rc" = 0 ] || error_exit "privileged port not found" )
4834 run_test 100 "check local port using privileged port ==========="
4836 function get_named_value()
4845 echo $line | sed "s/^$tag[ ]*//"
4852 export CACHE_MAX=`$LCTL get_param -n llite.*.max_cached_mb | head -n 1`
4854 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
4862 [ "$CPU" = "UML" ] && nreads=1000
4863 local cache_limit=32
4865 $LCTL set_param -n osc.*-osc*.rpc_stats 0
4866 trap cleanup_101a EXIT
4867 $LCTL set_param -n llite.*.read_ahead_stats 0
4868 $LCTL set_param -n llite.*.max_cached_mb $cache_limit
4871 # randomly read 10000 of 64K chunks from file 3x 32MB in size
4873 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
4874 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
4877 for s in `$LCTL get_param -n llite.*.read_ahead_stats | \
4878 get_named_value 'read but discarded' | cut -d" " -f1`; do
4879 discard=$(($discard + $s))
4883 if [ $(($discard * 10)) -gt $nreads ] ;then
4884 $LCTL get_param osc.*-osc*.rpc_stats
4885 $LCTL get_param llite.*.read_ahead_stats
4886 error "too many ($discard) discarded pages"
4888 rm -f $DIR/$tfile || true
4890 run_test 101a "check read-ahead for random reads ================"
4895 STRIPE_COUNT=$OSTCOUNT
4898 local list=$(comma_list $(osts_nodes))
4899 do_nodes $list $LCTL set_param -n obdfilter.*.read_cache_enable=0
4900 do_nodes $list $LCTL set_param -n obdfilter.*.writethrough_cache_enable=0
4902 trap cleanup_test101bc EXIT
4903 # prepare the read-ahead file
4904 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
4906 dd if=/dev/zero of=$DIR/$tfile bs=1024k count=100 2> /dev/null
4909 cleanup_test101bc() {
4914 local list=$(comma_list $(osts_nodes))
4915 do_nodes $list $LCTL set_param -n obdfilter.*.read_cache_enable=1
4916 do_nodes $list $LCTL set_param -n obdfilter.*.writethrough_cache_enable=1
4920 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
4925 local STRIPE_SIZE=1048576
4926 local RA_INC=1048576
4927 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
4928 local FILE_LENGTH=$((64*100))
4929 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
4930 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
4931 DISCARD=`$LCTL get_param -n llite.*.read_ahead_stats | \
4932 get_named_value 'read but discarded' | \
4933 cut -d" " -f1 | calc_total`
4934 if [ $DISCARD -gt $discard_limit ]; then
4935 $LCTL get_param llite.*.read_ahead_stats
4936 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
4938 echo "Read-ahead success for size ${READ_SIZE}"
4943 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping stride IO stride-ahead test" && return
4944 local STRIPE_SIZE=1048576
4945 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
4946 local FILE_LENGTH=$((STRIPE_SIZE*100))
4947 local ITERATION=$((FILE_LENGTH/STRIDE_SIZE))
4948 # prepare the read-ahead file
4950 cancel_lru_locks osc
4951 for BIDX in 2 4 8 16 32 64 128 256
4953 local BSIZE=$((BIDX*4096))
4954 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
4955 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
4956 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
4957 $LCTL set_param -n llite.*.read_ahead_stats 0
4958 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
4959 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
4960 cancel_lru_locks osc
4966 run_test 101b "check stride-io mode read-ahead ================="
4969 local STRIPE_SIZE=1048576
4970 local FILE_LENGTH=$((STRIPE_SIZE*100))
4976 cancel_lru_locks osc
4977 $LCTL set_param osc.*.rpc_stats 0
4978 $READS -f $DIR/$tfile -s$FILE_LENGTH -b65536 -n$nreads -t 180
4979 for osc in $($LCTL get_param -N osc.*); do
4980 if [ "$osc" == "osc.num_refs" ]; then
4984 local lines=$($LCTL get_param -n ${osc}.rpc_stats | wc | awk '{print $1}')
4985 if [ $lines -le 20 ]; then
4989 local rpc4k=$($LCTL get_param -n ${osc}.rpc_stats |
4990 awk '$1 == "1:" { print $2; exit; }')
4991 local rpc8k=$($LCTL get_param -n ${osc}.rpc_stats |
4992 awk '$1 == "2:" { print $2; exit; }')
4993 local rpc16k=$($LCTL get_param -n ${osc}.rpc_stats |
4994 awk '$1 == "4:" { print $2; exit; }')
4995 local rpc32k=$($LCTL get_param -n ${osc}.rpc_stats |
4996 awk '$1 == "8:" { print $2; exit; }')
4998 [ $rpc4k != 0 ] && error "Small 4k read IO ${rpc4k}!"
4999 [ $rpc8k != 0 ] && error "Small 8k read IO ${rpc8k}!"
5000 [ $rpc16k != 0 ] && error "Small 16k read IO ${rpc16k}!"
5001 [ $rpc32k != 0 ] && error "Small 32k read IO ${rpc32k}!"
5002 echo "${osc} rpc check passed!"
5007 run_test 101c "check stripe_size aligned read-ahead ================="
5010 $LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1
5011 $LCTL set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
5015 local file=$DIR/$tfile
5016 local size=${FILESIZE_101c:-500}
5017 local ra_MB=${READAHEAD_MB:-40}
5019 local space=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
5020 [ $space -gt $((size / 1024)) ] ||
5021 { skip "Need free space ${size}M, have $space" && return; }
5023 echo Creating ${size}M test file $file
5024 dd if=/dev/zero of=$file bs=1M count=$size
5025 echo Cancel LRU locks on lustre client to flush the client cache
5026 cancel_lru_locks osc
5028 echo Disable read-ahead
5029 local old_READAHEAD=$(set_read_ahead 0)
5031 echo Reading the test file $file with read-ahead disabled
5032 time_ra_OFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$size")
5034 echo Cancel LRU locks on lustre client to flush the client cache
5035 cancel_lru_locks osc
5036 echo Enable read-ahead with ${ra_MB}MB
5037 set_read_ahead $ra_MB
5039 echo Reading the test file $file with read-ahead enabled
5040 time_ra_ON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$size")
5042 echo read-ahead disabled time read $time_ra_OFF
5043 echo read-ahead enabled time read $time_ra_ON
5045 set_read_ahead $old_READAHEAD
5048 [ $time_ra_ON -lt $time_ra_OFF ] ||
5049 error "read-ahead enabled time read (${time_ra_ON}s) is more than
5050 read-ahead disabled time read (${time_ra_OFF}s) filesize ${size}M"
5052 run_test 101d "file read with and without read-ahead enabled ================="
5055 local file=$DIR/$tfile
5060 local space=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
5061 local need_space=$((count * size))
5062 [ $space -gt $need_space ] ||
5063 { skip_env "Need free space $need_space, have $space" && return; }
5065 echo Creating $count ${size}K test files
5066 for ((i = 0; i < $count; i++)); do
5067 dd if=/dev/zero of=${file}_${i} bs=$blksize count=$size 2>/dev/null
5070 echo Cancel LRU locks on lustre client to flush the client cache
5071 cancel_lru_locks osc
5073 echo Reset readahead stats
5074 $LCTL set_param -n llite.*.read_ahead_stats 0
5076 for ((i = 0; i < $count; i++)); do
5077 dd if=${file}_${i} of=/dev/null bs=$blksize count=$size 2>/dev/null
5080 local miss=$($LCTL get_param -n llite.*.read_ahead_stats | \
5081 get_named_value 'misses' | cut -d" " -f1 | calc_total)
5083 for ((i = 0; i < $count; i++)); do
5084 rm -rf ${file}_${i} 2>/dev/null
5087 #10000 means 20% reads are missing in readahead
5088 [ $miss -lt 10000 ] || error "misses too much for small reads"
5090 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
5092 cleanup_test101f() {
5094 $LCTL set_param -n llite.*.max_read_ahead_whole_mb $MAX_WHOLE_MB
5095 rm -rf $DIR/$tfile 2>/dev/null
5099 local file=$DIR/$tfile
5102 MAX_WHOLE_MB=$($LCTL get_param -n llite.*.max_read_ahead_whole_mb)
5103 $LCTL set_param -n llite.*.max_read_ahead_whole_mb 2
5104 dd if=/dev/zero of=${file} bs=2097152 count=1 2>/dev/null
5105 trap cleanup_test101f EXIT
5107 echo Cancel LRU locks on lustre client to flush the client cache
5108 cancel_lru_locks osc
5110 echo Reset readahead stats
5111 $LCTL set_param -n llite.*.read_ahead_stats 0
5112 # Random read in a 2M file, because max_read_ahead_whole_mb = 2M,
5113 # readahead should read in 2M file on second read, so only miss
5115 echo Random 4K reads on 2M file for 1000 times
5116 $READS -f $file -s 2097152 -b 4096 -n $nreads
5118 echo checking missing pages
5119 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
5120 get_named_value 'misses' | cut -d" " -f1 | calc_total)
5122 [ $miss -lt 3 ] || error "misses too much pages!"
5125 run_test 101f "check read-ahead for max_read_ahead_whole_mb"
5129 chown $RUNAS_ID $DIR/$tdir
5132 STRIPE_COUNT=$OSTCOUNT
5133 [ $OSTCOUNT -gt 4 ] && STRIPE_COUNT=4
5135 trap cleanup_test102 EXIT
5137 $1 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
5139 for num in 1 2 3 4; do
5140 for count in $(seq 1 $STRIPE_COUNT); do
5141 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
5142 local size=`expr $STRIPE_SIZE \* $num`
5143 local file=file"$num-$idx-$count"
5144 $1 $SETSTRIPE -S $size -i $idx -c $count $file
5150 $1 $TAR cf $TMP/f102.tar $tdir --xattrs
5156 rm -rf $DIR/d0.sanity/d102
5160 local testfile=$DIR/xattr_testfile
5165 [ "$UID" != 0 ] && skip_env "must run as root" && return
5166 [ -z "`lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr`" ] &&
5167 skip_env "must have user_xattr" && return
5169 [ -z "$(which setfattr 2>/dev/null)" ] &&
5170 skip_env "could not find setfattr" && return
5172 echo "set/get xattr..."
5173 setfattr -n trusted.name1 -v value1 $testfile || error
5174 [ "`getfattr -n trusted.name1 $testfile 2> /dev/null | \
5175 grep "trusted.name1"`" == "trusted.name1=\"value1\"" ] || error
5177 setfattr -n user.author1 -v author1 $testfile || error
5178 [ "`getfattr -n user.author1 $testfile 2> /dev/null | \
5179 grep "user.author1"`" == "user.author1=\"author1\"" ] || error
5182 setfattr -n trusted.name2 -v value2 $testfile || error
5183 setfattr -n trusted.name3 -v value3 $testfile || error
5184 [ `getfattr -d -m "^trusted" $testfile 2> /dev/null | \
5185 grep "trusted.name" | wc -l` -eq 3 ] || error
5188 setfattr -n user.author2 -v author2 $testfile || error
5189 setfattr -n user.author3 -v author3 $testfile || error
5190 [ `getfattr -d -m "^user" $testfile 2> /dev/null | \
5191 grep "user" | wc -l` -eq 3 ] || error
5193 echo "remove xattr..."
5194 setfattr -x trusted.name1 $testfile || error
5195 getfattr -d -m trusted $testfile 2> /dev/null | \
5196 grep "trusted.name1" && error || true
5198 setfattr -x user.author1 $testfile || error
5199 getfattr -d -m user $testfile 2> /dev/null | \
5200 grep "user.author1" && error || true
5202 # b10667: setting lustre special xattr be silently discarded
5203 echo "set lustre special xattr ..."
5204 setfattr -n "trusted.lov" -v "invalid value" $testfile || error
5208 run_test 102a "user xattr test =================================="
5211 # b10930: get/set/list trusted.lov xattr
5212 echo "get/set/list trusted.lov xattr ..."
5213 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
5214 local testfile=$DIR/$tfile
5215 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
5216 error "setstripe failed"
5217 local STRIPECOUNT=$($GETSTRIPE -c $testfile) ||
5218 error "getstripe failed"
5219 getfattr -d -m "^trusted" $testfile 2> /dev/null | \
5220 grep "trusted.lov" || error "can't get trusted.lov from $testfile"
5222 local testfile2=${testfile}2
5223 local value=`getfattr -n trusted.lov $testfile 2> /dev/null | \
5224 grep "trusted.lov" |sed -e 's/[^=]\+=//'`
5227 setfattr -n trusted.lov -v $value $testfile2
5228 local stripe_size=$($GETSTRIPE -S $testfile2)
5229 local stripe_count=$($GETSTRIPE -c $testfile2)
5230 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
5231 [ $stripe_count -eq $STRIPECOUNT ] ||
5232 error "stripe count $stripe_count != $STRIPECOUNT"
5235 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
5238 # b10930: get/set/list lustre.lov xattr
5239 echo "get/set/list lustre.lov xattr ..."
5240 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
5242 chown $RUNAS_ID $DIR/$tdir
5243 local testfile=$DIR/$tdir/$tfile
5244 $RUNAS $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
5245 error "setstripe failed"
5246 local STRIPECOUNT=$($RUNAS $GETSTRIPE -c $testfile) ||
5247 error "getstripe failed"
5248 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
5249 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
5251 local testfile2=${testfile}2
5252 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
5253 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
5255 $RUNAS $MCREATE $testfile2
5256 $RUNAS setfattr -n lustre.lov -v $value $testfile2
5257 local stripe_size=$($RUNAS $GETSTRIPE -S $testfile2)
5258 local stripe_count=$($RUNAS $GETSTRIPE -c $testfile2)
5259 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
5260 [ $stripe_count -eq $STRIPECOUNT ] ||
5261 error "stripe count $stripe_count != $STRIPECOUNT"
5263 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
5265 compare_stripe_info1() {
5266 local stripe_index_all_zero=1
5270 for count in `seq 1 $STRIPE_COUNT`
5272 for offset in `seq 0 $[$STRIPE_COUNT - 1]`
5274 local size=`expr $STRIPE_SIZE \* $num`
5275 local file=file"$num-$offset-$count"
5276 get_stripe_info client $PWD/$file "$1"
5277 if [ $stripe_size -ne $size ]; then
5278 error "$file: different stripe size $stripe_size, expected $size" && return
5280 if [ $stripe_count -ne $count ]; then
5281 error "$file: different stripe count $stripe_count, expected $count" && return
5283 if [ $stripe_index -ne 0 ]; then
5284 stripe_index_all_zero=0
5289 [ $stripe_index_all_zero -eq 1 ] && error "all files are being extracted starting from OST index 0"
5293 compare_stripe_info2() {
5296 for count in `seq 1 $STRIPE_COUNT`
5298 for offset in `seq 0 $[$STRIPE_COUNT - 1]`
5300 local size=`expr $STRIPE_SIZE \* $num`
5301 local file=file"$num-$offset-$count"
5302 get_stripe_info client $PWD/$file
5303 if [ $stripe_size -ne $size ]; then
5304 error "$file: different stripe size $stripe_size, expected $size" && return
5306 if [ $stripe_count -ne $count ]; then
5307 error "$file: different stripe count $stripe_count, expected $count" && return
5309 if [ $stripe_index -ne $offset ]; then
5310 error "$file: different stripe offset $stripe_index, expected $offset" && return
5318 [ -n "$(which tar 2>/dev/null)" ] && strings $(which tar) | grep -q lustre && echo tar
5322 # b10930: tar test for trusted.lov xattr
5323 TAR=$(find_lustre_tar)
5324 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
5325 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
5328 $TAR xf $TMP/f102.tar -C $DIR/d102d --xattrs
5330 compare_stripe_info1
5332 run_test 102d "tar restore stripe info from tarfile,not keep osts ==========="
5335 # b10930: tar test for trusted.lov xattr
5336 TAR=$(find_lustre_tar)
5337 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
5338 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
5342 $TAR cf - --xattrs $tdir | $TAR xf - --xattrs -C $DIR/d102f
5344 compare_stripe_info1
5346 run_test 102f "tar copy files, not keep osts ==========="
5349 local xsize=${1:-1024} # in bytes
5350 local file=$DIR/$tfile
5352 [ -z $(lctl get_param -n mdc.*.connect_flags | grep xattr) ] &&
5353 skip "must have user_xattr" && return 0
5354 [ -z "$(which setfattr 2>/dev/null)" ] &&
5355 skip_env "could not find setfattr" && return 0
5356 [ -z "$(which getfattr 2>/dev/null)" ] &&
5357 skip_env "could not find getfattr" && return 0
5361 local value="$(generate_string $xsize)"
5363 local xbig=trusted.big
5364 log "save $xbig on $file"
5365 setfattr -n $xbig -v $value $file ||
5366 error "saving $xbig on $file failed"
5368 local orig=$(get_xattr_value $xbig $file)
5369 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
5371 local xsml=trusted.sml
5372 log "save $xsml on $file"
5373 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
5375 local new=$(get_xattr_value $xbig $file)
5376 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
5378 log "grow $xsml on $file"
5379 setfattr -n $xsml -v "$value" $file ||
5380 error "growing $xsml on $file failed"
5382 new=$(get_xattr_value $xbig $file)
5383 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
5384 log "$xbig still valid after growing $xsml"
5389 test_102h() { # bug 15777
5392 run_test 102h "grow xattr from inside inode to external block"
5395 large_xattr_enabled || { skip "large_xattr disabled" && return; }
5396 grow_xattr $(max_xattr_size)
5398 run_test 102ha "grow xattr from inside inode to external inode"
5400 test_102i() { # bug 17038
5402 ln -s $DIR/$tfile $DIR/${tfile}link
5403 getfattr -n trusted.lov $DIR/$tfile || error "lgetxattr on $DIR/$tfile failed"
5404 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"
5405 rm -f $DIR/$tfile $DIR/${tfile}link
5407 run_test 102i "lgetxattr test on symbolic link ============"
5410 TAR=$(find_lustre_tar)
5411 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
5412 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
5413 setup_test102 "$RUNAS"
5415 chown $RUNAS_ID $DIR/d102j
5416 $RUNAS $TAR xf $TMP/f102.tar -C $DIR/d102j --xattrs
5418 compare_stripe_info1 "$RUNAS"
5420 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
5424 # b22187 just check that does not crash for regular file.
5425 setfattr -n trusted.lov $DIR/$tfile
5426 # b22187 'setfattr -n trusted.lov' should work as remove LOV EA for directories
5427 local test_kdir=$DIR/d102k
5429 local default_size=`$GETSTRIPE -S $test_kdir`
5430 local default_count=`$GETSTRIPE -c $test_kdir`
5431 local default_offset=`$GETSTRIPE -i $test_kdir`
5432 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $test_kdir ||
5433 error 'dir setstripe failed'
5434 setfattr -n trusted.lov $test_kdir
5435 local stripe_size=`$GETSTRIPE -S $test_kdir`
5436 local stripe_count=`$GETSTRIPE -c $test_kdir`
5437 local stripe_offset=`$GETSTRIPE -i $test_kdir`
5438 [ $stripe_size -eq $default_size ] ||
5439 error "stripe size $stripe_size != $default_size"
5440 [ $stripe_count -eq $default_count ] ||
5441 error "stripe count $stripe_count != $default_count"
5442 [ $stripe_offset -eq $default_offset ] ||
5443 error "stripe offset $stripe_offset != $default_offset"
5444 rm -rf $DIR/$tfile $test_kdir
5446 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
5452 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
5457 [ "$UID" != 0 ] && skip_env "must run as root" && return
5458 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
5459 [ -z "$(which setfacl 2>/dev/null)" ] && skip_env "could not find setfacl" && return
5460 $GSS && skip "could not run under gss" && return
5462 declare -a identity_old
5464 for num in `seq $MDSCOUNT`; do
5465 switch_identity $num true || identity_old[$num]=$?
5472 echo "performing cp ..."
5473 run_acl_subtest cp || error
5474 echo "performing getfacl-noacl..."
5475 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
5476 echo "performing misc..."
5477 run_acl_subtest misc || error "misc test failed"
5478 echo "performing permissions..."
5479 run_acl_subtest permissions || error "permissions failed"
5480 echo "performing setfacl..."
5481 run_acl_subtest setfacl || error "setfacl test failed"
5483 # inheritance test got from HP
5484 echo "performing inheritance..."
5485 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
5486 chmod +x make-tree || error "chmod +x failed"
5487 run_acl_subtest inheritance || error "inheritance test failed"
5493 for num in `seq $MDSCOUNT`; do
5494 if [ "${identity_old[$num]}" = 1 ]; then
5495 switch_identity $num false || identity_old[$num]=$?
5499 run_test 103 "acl test ========================================="
5503 lfs df || error "lfs df failed"
5504 lfs df -ih || error "lfs df -ih failed"
5505 lfs df -h $DIR || error "lfs df -h $DIR failed"
5506 lfs df -i $DIR || error "lfs df -i $DIR failed"
5507 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
5508 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
5510 OSC=`lctl dl |grep OST0000-osc-[^M] |awk '{print $4}'`
5511 lctl --device %$OSC deactivate
5512 lfs df || error "lfs df with deactivated OSC failed"
5513 lctl --device %$OSC activate
5514 # wait the osc back to normal
5515 wait_osc_import_state client ost FULL
5517 lfs df || error "lfs df with reactivated OSC failed"
5520 run_test 104a "lfs df [-ih] [path] test ========================="
5523 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5525 denied_cnt=$((`$RUNAS $LFS check servers 2>&1 | grep "Permission denied" | wc -l`))
5526 if [ $denied_cnt -ne 0 ];
5528 error "lfs check servers test failed"
5531 run_test 104b "$RUNAS lfs check servers test ===================="
5534 # doesn't work on 2.4 kernels
5536 if [ -n "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ];
5538 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
5540 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
5544 run_test 105a "flock when mounted without -o flock test ========"
5548 if [ -n "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ];
5550 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
5552 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
5556 run_test 105b "fcntl when mounted without -o flock test ========"
5560 if [ -n "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ];
5562 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
5564 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
5568 run_test 105c "lockf when mounted without -o flock test ========"
5570 test_105d() { # bug 15924
5572 [ -z "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ] && \
5573 skip "mount w/o flock enabled" && return
5574 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
5575 $LCTL set_param fail_loc=0x80000315
5576 flocks_test 2 $DIR/$tdir
5578 run_test 105d "flock race (should not freeze) ========"
5580 test_105e() { # bug 22660 && 22040
5581 [ -z "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ] && \
5582 skip "mount w/o flock enabled" && return
5584 flocks_test 3 $DIR/$tfile
5586 run_test 105e "Two conflicting flocks from same process ======="
5588 test_106() { #bug 10921
5590 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
5591 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
5593 run_test 106 "attempt exec of dir followed by chown of that dir"
5602 local save_pattern=$(sysctl -n kernel.core_pattern)
5603 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
5604 sysctl -w kernel.core_pattern=$file
5605 sysctl -w kernel.core_uses_pid=0
5613 kill -s 11 $SLEEPPID
5615 if [ -e $file ]; then
5616 size=`stat -c%s $file`
5617 [ $size -eq 0 ] && error "Fail to create core file $file"
5619 error "Fail to create core file $file"
5622 sysctl -w kernel.core_pattern=$save_pattern
5623 sysctl -w kernel.core_uses_pid=$save_uses_pid
5626 run_test 107 "Coredump on SIG"
5630 mkdir $DIR/d110/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa || error "mkdir with 255 char fail"
5631 mkdir $DIR/d110/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb && error "mkdir with 256 char should fail, but not"
5632 touch $DIR/d110/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx || error "create with 255 char fail"
5633 touch $DIR/d110/yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy && error ""create with 256 char should fail, but not
5638 run_test 110 "filename length checking"
5641 OSTIO_pre=$(ps -e|grep ll_ost_io|awk '{print $4}'|sort -n|tail -1|\
5643 [ -z "$OSTIO_pre" ] && skip "no OSS threads" && \
5645 echo "Starting with $OSTIO_pre threads"
5648 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
5649 [ $NUMFREE -lt $NUMTEST ] && NUMTEST=$(($NUMFREE - 1000))
5650 echo "$NUMTEST creates/unlinks"
5652 createmany -o $DIR/$tdir/$tfile $NUMTEST
5653 unlinkmany $DIR/$tdir/$tfile $NUMTEST
5655 OSTIO_post=$(ps -e|grep ll_ost_io|awk '{print $4}'|sort -n|tail -1|\
5658 # don't return an error
5659 [ $OSTIO_post -eq $OSTIO_pre ] && echo \
5660 "WARNING: No new ll_ost_io threads were created ($OSTIO_pre)" &&\
5661 echo "This may be fine, depending on what ran before this test" &&\
5662 echo "and how fast this system is." && return
5664 echo "Started with $OSTIO_pre threads, ended with $OSTIO_post"
5666 run_test 115 "verify dynamic thread creation===================="
5669 wait_delete_completed
5670 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
5671 echo OST kbytes available: ${AVAIL[@]}
5672 MAXI=0; MAXV=${AVAIL[0]}
5673 MINI=0; MINV=${AVAIL[0]}
5674 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
5675 #echo OST $i: ${AVAIL[i]}kb
5676 if [ ${AVAIL[i]} -gt $MAXV ]; then
5677 MAXV=${AVAIL[i]}; MAXI=$i
5679 if [ ${AVAIL[i]} -lt $MINV ]; then
5680 MINV=${AVAIL[i]}; MINI=$i
5683 echo Min free space: OST $MINI: $MINV
5684 echo Max free space: OST $MAXI: $MAXV
5688 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs" && return
5690 echo -n "Free space priority "
5691 lctl get_param -n lov.*-clilov-*.qos_prio_free
5694 [ $MINV -gt 960000 ] && skip "too much free space in OST$MINI, skip" &&\
5697 # generate uneven OSTs
5698 mkdir -p $DIR/$tdir/OST${MINI}
5701 echo "Filling 25% remaining space in OST${MINI} with ${FILL}Kb"
5702 $SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI}||error "setstripe failed"
5704 while [ $FILL -gt 0 ]; do
5706 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i bs=2M count=1 2>/dev/null
5707 FILL=$(($FILL - 2048))
5715 DIFF=$(($MAXV - $MINV))
5716 DIFF2=$(($DIFF * 100 / $MINV))
5717 echo -n "diff=${DIFF}=${DIFF2}% must be > 20% for QOS mode..."
5718 if [ $DIFF2 -gt 20 ]; then
5721 echo "failed - QOS mode won't be used"
5722 error_ignore "QOS imbalance criteria not met"
5726 MINI1=$MINI; MINV1=$MINV
5727 MAXI1=$MAXI; MAXV1=$MAXV
5729 # now fill using QOS
5730 echo writing a bunch of files to QOS-assigned OSTs
5731 $SETSTRIPE -c 1 $DIR/$tdir
5733 while [ $FILL -gt 0 ]; do
5735 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1024 count=200 2>/dev/null
5736 FILL=$(($FILL - 200))
5739 echo "wrote $i 200k files"
5743 echo "Note: free space may not be updated, so measurements might be off"
5745 DIFF2=$(($MAXV - $MINV))
5746 echo "free space delta: orig $DIFF final $DIFF2"
5747 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
5748 DIFF=$(($MINV1 - ${AVAIL[$MINI1]}))
5749 echo "Wrote $DIFF to smaller OST $MINI1"
5750 DIFF2=$(($MAXV1 - ${AVAIL[$MAXI1]}))
5751 echo "Wrote $DIFF2 to larger OST $MAXI1"
5752 [ $DIFF -gt 0 ] && echo "Wrote $(($DIFF2 * 100 / $DIFF - 100))% more data to larger OST $MAXI1"
5754 # Figure out which files were written where
5755 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
5756 awk '/'$MINI1': / {print $2; exit}')
5758 MINC=$($GETSTRIPE --obd $UUID $DIR/$tdir | wc -l)
5759 echo "$MINC files created on smaller OST $MINI1"
5760 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
5761 awk '/'$MAXI1': / {print $2; exit}')
5763 MAXC=$($GETSTRIPE --obd $UUID $DIR/$tdir | wc -l)
5764 echo "$MAXC files created on larger OST $MAXI1"
5765 [ $MINC -gt 0 ] && echo "Wrote $(($MAXC * 100 / $MINC - 100))% more files to larger OST $MAXI1"
5766 [ $MAXC -gt $MINC ] || error_ignore "stripe QOS didn't balance free space"
5770 run_test 116 "stripe QOS: free space balance ==================="
5772 test_117() # bug 10891
5774 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
5775 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
5776 lctl set_param fail_loc=0x21e
5777 > $DIR/$tfile || error "truncate failed"
5778 lctl set_param fail_loc=0
5779 echo "Truncate succeeded."
5782 run_test 117 "verify fsfilt_extend =========="
5784 export OLD_RESENDCOUNT=""
5785 set_resend_count () {
5786 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
5787 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -1)
5788 lctl set_param -n $PROC_RESENDCOUNT $1
5789 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
5792 [ "$SLOW" = "no" ] && set_resend_count 4 # for reduce test_118* time (bug 14842)
5794 # Reset async IO behavior after error case
5796 FILE=$DIR/reset_async
5798 # Ensure all OSCs are cleared
5799 $SETSTRIPE -c -1 $FILE
5800 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
5805 test_118a() #bug 11710
5809 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
5810 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
5811 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
5813 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
5814 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
5819 run_test 118a "verify O_SYNC works =========="
5823 remote_ost_nodsh && skip "remote OST with nodsh" && return
5827 #define OBD_FAIL_OST_ENOENT 0x217
5828 set_nodes_failloc "$(osts_nodes)" 0x217
5829 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
5831 set_nodes_failloc "$(osts_nodes)" 0
5832 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
5833 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
5836 if [[ $RC -eq 0 ]]; then
5837 error "Must return error due to dropped pages, rc=$RC"
5841 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
5842 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
5846 echo "Dirty pages not leaked on ENOENT"
5848 # Due to the above error the OSC will issue all RPCs syncronously
5849 # until a subsequent RPC completes successfully without error.
5850 multiop $DIR/$tfile Ow4096yc
5855 run_test 118b "Reclaim dirty pages on fatal error =========="
5859 remote_ost_nodsh && skip "remote OST with nodsh" && return
5863 #define OBD_FAIL_OST_EROFS 0x216
5864 set_nodes_failloc "$(osts_nodes)" 0x216
5866 # multiop should block due to fsync until pages are written
5867 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
5871 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
5872 error "Multiop failed to block on fsync, pid=$MULTIPID"
5875 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
5877 if [[ $WRITEBACK -eq 0 ]]; then
5878 error "No page in writeback, writeback=$WRITEBACK"
5881 set_nodes_failloc "$(osts_nodes)" 0
5884 if [[ $RC -ne 0 ]]; then
5885 error "Multiop fsync failed, rc=$RC"
5888 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
5889 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
5891 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
5892 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
5896 echo "Dirty pages flushed via fsync on EROFS"
5899 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
5903 remote_ost_nodsh && skip "remote OST with nodsh" && return
5907 #define OBD_FAIL_OST_BRW_PAUSE_BULK
5908 set_nodes_failloc "$(osts_nodes)" 0x214
5909 # multiop should block due to fsync until pages are written
5910 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
5914 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
5915 error "Multiop failed to block on fsync, pid=$MULTIPID"
5918 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
5920 if [[ $WRITEBACK -eq 0 ]]; then
5921 error "No page in writeback, writeback=$WRITEBACK"
5924 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
5925 set_nodes_failloc "$(osts_nodes)" 0
5927 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
5928 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
5930 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
5931 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
5935 echo "Dirty pages gaurenteed flushed via fsync"
5938 run_test 118d "Fsync validation inject a delay of the bulk =========="
5943 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
5944 lctl set_param fail_loc=0x8000040a
5946 # Should simulate EINVAL error which is fatal
5947 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
5949 if [[ $RC -eq 0 ]]; then
5950 error "Must return error due to dropped pages, rc=$RC"
5953 lctl set_param fail_loc=0x0
5955 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
5956 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
5957 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
5959 if [[ $LOCKED -ne 0 ]]; then
5960 error "Locked pages remain in cache, locked=$LOCKED"
5963 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
5964 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
5968 echo "No pages locked after fsync"
5973 run_test 118f "Simulate unrecoverable OSC side error =========="
5978 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
5979 lctl set_param fail_loc=0x406
5981 # simulate local -ENOMEM
5982 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
5985 lctl set_param fail_loc=0
5986 if [[ $RC -eq 0 ]]; then
5987 error "Must return error due to dropped pages, rc=$RC"
5990 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
5991 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
5992 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
5994 if [[ $LOCKED -ne 0 ]]; then
5995 error "Locked pages remain in cache, locked=$LOCKED"
5998 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
5999 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6003 echo "No pages locked after fsync"
6008 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
6011 remote_ost_nodsh && skip "remote OST with nodsh" && return
6015 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
6016 set_nodes_failloc "$(osts_nodes)" 0x20e
6017 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
6018 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6021 set_nodes_failloc "$(osts_nodes)" 0
6022 if [[ $RC -eq 0 ]]; then
6023 error "Must return error due to dropped pages, rc=$RC"
6026 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6027 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6028 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6030 if [[ $LOCKED -ne 0 ]]; then
6031 error "Locked pages remain in cache, locked=$LOCKED"
6034 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6035 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6039 echo "No pages locked after fsync"
6043 run_test 118h "Verify timeout in handling recoverables errors =========="
6046 remote_ost_nodsh && skip "remote OST with nodsh" && return
6050 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
6051 set_nodes_failloc "$(osts_nodes)" 0x20e
6053 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
6054 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
6057 set_nodes_failloc "$(osts_nodes)" 0
6061 if [[ $RC -ne 0 ]]; then
6062 error "got error, but should be not, rc=$RC"
6065 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6066 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6067 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
6068 if [[ $LOCKED -ne 0 ]]; then
6069 error "Locked pages remain in cache, locked=$LOCKED"
6072 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6073 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6077 echo "No pages locked after fsync"
6081 run_test 118i "Fix error before timeout in recoverable error =========="
6084 remote_ost_nodsh && skip "remote OST with nodsh" && return
6088 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
6089 set_nodes_failloc "$(osts_nodes)" 0x220
6091 # return -EIO from OST
6092 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6094 set_nodes_failloc "$(osts_nodes)" 0x0
6095 if [[ $RC -eq 0 ]]; then
6096 error "Must return error due to dropped pages, rc=$RC"
6099 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6100 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6101 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
6102 if [[ $LOCKED -ne 0 ]]; then
6103 error "Locked pages remain in cache, locked=$LOCKED"
6106 # in recoverable error on OST we want resend and stay until it finished
6107 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6108 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6112 echo "No pages locked after fsync"
6116 run_test 118j "Simulate unrecoverable OST side error =========="
6120 remote_ost_nodsh && skip "remote OSTs with nodsh" && return
6122 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
6123 set_nodes_failloc "$(osts_nodes)" 0x20e
6126 for ((i=0;i<10;i++)); do
6127 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
6128 error "dd to $DIR/$tdir/$tfile-$i failed" )&
6135 set_nodes_failloc "$(osts_nodes)" 0
6138 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
6144 multiop $DIR/$tdir Dy || error "fsync dir failed"
6147 run_test 118l "fsync dir ========="
6149 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
6151 test_119a() # bug 11737
6153 BSIZE=$((512 * 1024))
6154 directio write $DIR/$tfile 0 1 $BSIZE
6155 # We ask to read two blocks, which is more than a file size.
6156 # directio will indicate an error when requested and actual
6157 # sizes aren't equeal (a normal situation in this case) and
6158 # print actual read amount.
6159 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
6160 if [ "$NOB" != "$BSIZE" ]; then
6161 error "read $NOB bytes instead of $BSIZE"
6165 run_test 119a "Short directIO read must return actual read amount"
6167 test_119b() # bug 11737
6169 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
6171 $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
6172 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
6174 multiop $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) || \
6175 error "direct read failed"
6178 run_test 119b "Sparse directIO read must return actual read amount"
6180 test_119c() # bug 13099
6183 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
6184 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
6187 run_test 119c "Testing for direct read hitting hole"
6189 test_119d() # bug 15950
6191 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
6192 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
6194 $SETSTRIPE $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
6195 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
6196 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
6197 lctl set_param fail_loc=0x40d
6198 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
6201 cat $DIR/$tfile > /dev/null &
6202 lctl set_param fail_loc=0
6205 log "the DIO writes have completed, now wait for the reads (should not block very long)"
6207 [ -n "`ps h -p $pid_reads -o comm`" ] && \
6208 error "the read rpcs have not completed in 2s"
6210 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
6212 run_test 119d "The DIO path should try to send a new rpc once one is completed"
6216 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6217 skip "no early lock cancel on server" && return 0
6218 lru_resize_disable mdc
6219 lru_resize_disable osc
6220 cancel_lru_locks mdc
6221 stat $DIR/$tdir > /dev/null
6222 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6223 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6225 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6226 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6227 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6228 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6229 lru_resize_enable mdc
6230 lru_resize_enable osc
6232 run_test 120a "Early Lock Cancel: mkdir test"
6236 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6237 skip "no early lock cancel on server" && return 0
6238 lru_resize_disable mdc
6239 lru_resize_disable osc
6240 cancel_lru_locks mdc
6241 stat $DIR/$tdir > /dev/null
6242 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6243 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6245 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6246 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6247 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6248 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6249 lru_resize_enable mdc
6250 lru_resize_enable osc
6252 run_test 120b "Early Lock Cancel: create test"
6256 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6257 skip "no early lock cancel on server" && return 0
6258 lru_resize_disable mdc
6259 lru_resize_disable osc
6260 mkdir -p $DIR/$tdir/d1 $DIR/$tdir/d2
6261 touch $DIR/$tdir/d1/f1
6262 cancel_lru_locks mdc
6263 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
6264 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6265 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6266 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
6267 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6268 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6269 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6270 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6271 lru_resize_enable mdc
6272 lru_resize_enable osc
6274 run_test 120c "Early Lock Cancel: link test"
6278 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6279 skip "no early lock cancel on server" && return 0
6280 lru_resize_disable mdc
6281 lru_resize_disable osc
6283 cancel_lru_locks mdc
6284 stat $DIR/$tdir > /dev/null
6285 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6286 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6287 chmod a+x $DIR/$tdir
6288 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6289 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6290 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6291 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6292 lru_resize_enable mdc
6293 lru_resize_enable osc
6295 run_test 120d "Early Lock Cancel: setattr test"
6299 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6300 skip "no early lock cancel on server" && return 0
6301 lru_resize_disable mdc
6302 lru_resize_disable osc
6303 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
6304 cancel_lru_locks mdc
6305 cancel_lru_locks osc
6306 dd if=$DIR/$tdir/f1 of=/dev/null
6307 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
6308 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6309 awk '/ldlm_cancel/ {print $2}'`
6310 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6311 awk '/ldlm_bl_callback/ {print $2}'`
6312 unlink $DIR/$tdir/f1
6313 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6314 awk '/ldlm_cancel/ {print $2}'`
6315 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6316 awk '/ldlm_bl_callback/ {print $2}'`
6317 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6318 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6319 lru_resize_enable mdc
6320 lru_resize_enable osc
6322 run_test 120e "Early Lock Cancel: unlink test"
6325 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6326 skip "no early lock cancel on server" && return 0
6328 lru_resize_disable mdc
6329 lru_resize_disable osc
6330 mkdir -p $DIR/$tdir/d1 $DIR/$tdir/d2
6331 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
6332 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
6333 cancel_lru_locks mdc
6334 cancel_lru_locks osc
6335 dd if=$DIR/$tdir/d1/f1 of=/dev/null
6336 dd if=$DIR/$tdir/d2/f2 of=/dev/null
6337 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
6338 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6339 awk '/ldlm_cancel/ {print $2}'`
6340 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6341 awk '/ldlm_bl_callback/ {print $2}'`
6342 mv $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
6343 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6344 awk '/ldlm_cancel/ {print $2}'`
6345 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6346 awk '/ldlm_bl_callback/ {print $2}'`
6347 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6348 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6349 lru_resize_enable mdc
6350 lru_resize_enable osc
6352 run_test 120f "Early Lock Cancel: rename test"
6355 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6356 skip "no early lock cancel on server" && return 0
6357 lru_resize_disable mdc
6358 lru_resize_disable osc
6360 echo create $count files
6362 cancel_lru_locks mdc
6363 cancel_lru_locks osc
6366 can0=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6367 awk '/ldlm_cancel/ {print $2}'`
6368 blk0=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6369 awk '/ldlm_bl_callback/ {print $2}'`
6370 createmany -o $DIR/$tdir/f $count
6372 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6373 awk '/ldlm_cancel/ {print $2}'`
6374 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6375 awk '/ldlm_bl_callback/ {print $2}'`
6377 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
6378 echo rm $count files
6381 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6382 awk '/ldlm_cancel/ {print $2}'`
6383 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6384 awk '/ldlm_bl_callback/ {print $2}'`
6386 echo total: $count removes in $((t2-t1))
6387 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
6389 # wait for commitment of removal
6390 lru_resize_enable mdc
6391 lru_resize_enable osc
6393 run_test 120g "Early Lock Cancel: performance test"
6395 test_121() { #bug #10589
6397 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
6398 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
6399 lctl set_param fail_loc=0x310
6400 cancel_lru_locks osc > /dev/null
6401 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
6402 lctl set_param fail_loc=0
6403 [ "$reads" -eq "$writes" ] || error "read" $reads "blocks, must be" $writes
6405 run_test 121 "read cancel race ========="
6407 test_123a() { # was test 123, statahead(bug 11401)
6409 if [ -z "$(grep "processor.*: 1" /proc/cpuinfo)" ]; then
6410 log "testing on UP system. Performance may be not as good as expected."
6416 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
6417 [ $NUMFREE -gt 100000 ] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
6419 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
6420 createmany -o $DIR/$tdir/$tfile $j $((i - j))
6422 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
6423 lctl set_param -n llite.*.statahead_max 0
6424 lctl get_param llite.*.statahead_max
6425 cancel_lru_locks mdc
6426 cancel_lru_locks osc
6428 time ls -l $DIR/$tdir | wc -l
6430 delta=$((etime - stime))
6431 log "ls $i files without statahead: $delta sec"
6432 lctl set_param llite.*.statahead_max=$max
6434 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
6435 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
6436 cancel_lru_locks mdc
6437 cancel_lru_locks osc
6439 time ls -l $DIR/$tdir | wc -l
6441 delta_sa=$((etime - stime))
6442 log "ls $i files with statahead: $delta_sa sec"
6443 lctl get_param -n llite.*.statahead_stats
6444 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
6446 [ $swrong -lt $ewrong ] && log "statahead was stopped, maybe too many locks held!"
6447 [ $delta -eq 0 -o $delta_sa -eq 0 ] && continue
6449 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
6450 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
6451 lctl set_param -n llite.*.statahead_max 0
6452 lctl get_param llite.*.statahead_max
6453 cancel_lru_locks mdc
6454 cancel_lru_locks osc
6456 time ls -l $DIR/$tdir | wc -l
6458 delta=$((etime - stime))
6459 log "ls $i files again without statahead: $delta sec"
6460 lctl set_param llite.*.statahead_max=$max
6461 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
6462 if [ $SLOWOK -eq 0 ]; then
6463 error "ls $i files is slower with statahead!"
6465 log "ls $i files is slower with statahead!"
6471 [ $delta -gt 20 ] && break
6472 [ $delta -gt 8 ] && MULT=$((50 / delta))
6473 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
6481 delta=$((etime - stime))
6482 log "rm -r $DIR/$tdir/: $delta seconds"
6484 lctl get_param -n llite.*.statahead_stats
6486 run_test 123a "verify statahead work"
6488 test_123b () { # statahead(bug 15027)
6490 createmany -o $DIR/$tdir/$tfile-%d 1000
6492 cancel_lru_locks mdc
6493 cancel_lru_locks osc
6495 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
6496 lctl set_param fail_loc=0x80000803
6497 ls -lR $DIR/$tdir > /dev/null
6499 lctl set_param fail_loc=0x0
6500 lctl get_param -n llite.*.statahead_stats
6505 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
6508 [ -z "`lctl get_param -n mdc.*.connect_flags | grep lru_resize`" ] && \
6509 skip "no lru resize on server" && return 0
6511 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
6513 log "create $NR files at $DIR/$tdir"
6514 createmany -o $DIR/$tdir/f $NR ||
6515 error "failed to create $NR files in $DIR/$tdir"
6517 cancel_lru_locks mdc
6518 ls -l $DIR/$tdir > /dev/null
6522 for VALUE in `lctl get_param ldlm.namespaces.*mdc-*.lru_size`; do
6523 local PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
6524 LRU_SIZE=$(lctl get_param -n $PARAM)
6525 if [ $LRU_SIZE -gt $(default_lru_size) ]; then
6526 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
6528 log "NS=$(basename $NSDIR)"
6533 if [ -z "$NSDIR" -o $LRU_SIZE -lt $(default_lru_size) ]; then
6534 skip "Not enough cached locks created!"
6541 # We know that lru resize allows one client to hold $LIMIT locks
6542 # for 10h. After that locks begin to be killed by client.
6544 local LIMIT=`lctl get_param -n $NSDIR.pool.limit`
6547 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
6548 # killing locks. Some time was spent for creating locks. This means
6549 # that up to the moment of sleep finish we must have killed some of
6550 # them (10-100 locks). This depends on how fast ther were created.
6551 # Many of them were touched in almost the same moment and thus will
6552 # be killed in groups.
6553 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
6555 # Use $LRU_SIZE_B here to take into account real number of locks
6556 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
6557 local LRU_SIZE_B=$LRU_SIZE
6559 local OLD_LVF=`lctl get_param -n $NSDIR.pool.lock_volume_factor`
6560 log "OLD_LVF=$OLD_LVF"
6561 lctl set_param -n $NSDIR.pool.lock_volume_factor $LVF
6563 # Let's make sure that we really have some margin. Client checks
6564 # cached locks every 10 sec.
6566 log "Sleep ${SLEEP} sec"
6568 while ((SEC<$SLEEP)); do
6572 LRU_SIZE=`lctl get_param -n $NSDIR/lru_size`
6576 lctl set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
6577 local LRU_SIZE_A=`lctl get_param -n $NSDIR.lru_size`
6579 [ $LRU_SIZE_B -gt $LRU_SIZE_A ] || {
6580 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
6581 unlinkmany $DIR/$tdir/f $NR
6585 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
6586 log "unlink $NR files at $DIR/$tdir"
6587 unlinkmany $DIR/$tdir/f $NR
6589 run_test 124a "lru resize ======================================="
6591 get_max_pool_limit()
6593 local limit=`lctl get_param -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit`
6596 if test $l -gt $max; then
6604 [ -z "`lctl get_param -n mdc.*.connect_flags | grep lru_resize`" ] && \
6605 skip "no lru resize on server" && return 0
6607 LIMIT=`get_max_pool_limit`
6609 NR=$(($(default_lru_size)*20))
6610 if [ $NR -gt $LIMIT ]; then
6611 log "Limit lock number by $LIMIT locks"
6614 lru_resize_disable mdc
6615 mkdir -p $DIR/$tdir/disable_lru_resize ||
6616 error "failed to create $DIR/$tdir/disable_lru_resize"
6618 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
6619 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
6620 cancel_lru_locks mdc
6623 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
6626 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
6629 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
6633 nolruresize_delta=$((etime-stime))
6634 log "ls -la time: $nolruresize_delta seconds"
6635 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
6636 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
6638 lru_resize_enable mdc
6639 mkdir -p $DIR/$tdir/enable_lru_resize ||
6640 error "failed to create $DIR/$tdir/enable_lru_resize"
6642 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
6643 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
6644 cancel_lru_locks mdc
6647 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
6650 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
6653 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
6657 lruresize_delta=$((etime-stime))
6658 log "ls -la time: $lruresize_delta seconds"
6659 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
6661 if [ $lruresize_delta -gt $nolruresize_delta ]; then
6662 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
6663 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
6664 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
6666 log "lru resize performs the same with no lru resize"
6668 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
6670 run_test 124b "lru resize (performance test) ======================="
6672 test_125() { # 13358
6673 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
6674 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
6675 mkdir -p $DIR/d125 || error "mkdir failed"
6676 $SETSTRIPE -S 65536 -c -1 $DIR/d125 || error "setstripe failed"
6677 setfacl -R -m u:bin:rwx $DIR/d125 || error "setfacl $DIR/d125 failed"
6678 ls -ld $DIR/d125 || error "cannot access $DIR/d125"
6680 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
6682 test_126() { # bug 12829/13455
6683 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
6684 [ "$UID" != 0 ] && skip_env "skipping $TESTNAME (must run as root)" && return
6685 $GSS && skip "must run as gss disabled" && return
6687 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
6688 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
6690 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
6692 run_test 126 "check that the fsgid provided by the client is taken into account"
6694 test_127a() { # bug 15521
6695 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
6696 $LCTL set_param osc.*.stats=0
6697 FSIZE=$((2048 * 1024))
6698 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
6699 cancel_lru_locks osc
6700 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
6702 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
6703 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
6704 echo "got $COUNT $NAME"
6705 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
6706 eval $NAME=$COUNT || error "Wrong proc format"
6709 read_bytes|write_bytes)
6710 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
6711 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
6712 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
6713 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
6714 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
6715 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
6716 error "sumsquare is too small: $SUMSQ"
6717 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
6718 error "sumsquare is too big: $SUMSQ"
6722 done < $DIR/${tfile}.tmp
6724 #check that we actually got some stats
6725 [ "$read_bytes" ] || error "Missing read_bytes stats"
6726 [ "$write_bytes" ] || error "Missing write_bytes stats"
6727 [ "$read_bytes" != 0 ] || error "no read done"
6728 [ "$write_bytes" != 0 ] || error "no write done"
6730 run_test 127a "verify the client stats are sane"
6732 test_127b() { # bug LU-333
6733 $LCTL set_param llite.*.stats=0
6734 FSIZE=65536 # sized fixed to match PAGE_SIZE for most clients
6735 # perform 2 reads and writes so MAX is different from SUM.
6736 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
6737 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
6738 cancel_lru_locks osc
6739 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
6740 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
6742 $LCTL get_param llite.*.stats | grep samples > $TMP/${tfile}.tmp
6743 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
6744 echo "got $COUNT $NAME"
6745 eval $NAME=$COUNT || error "Wrong proc format"
6749 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
6750 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
6751 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
6752 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
6755 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
6756 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
6757 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
6758 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
6762 done < $TMP/${tfile}.tmp
6764 #check that we actually got some stats
6765 [ "$read_bytes" ] || error "Missing read_bytes stats"
6766 [ "$write_bytes" ] || error "Missing write_bytes stats"
6767 [ "$read_bytes" != 0 ] || error "no read done"
6768 [ "$write_bytes" != 0 ] || error "no write done"
6770 run_test 127b "verify the llite client stats are sane"
6772 test_128() { # bug 15212
6774 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
6779 result=$(grep error $TMP/$tfile.log)
6781 [ -z "$result" ] || error "consecutive find's under interactive lfs failed"
6783 run_test 128 "interactive lfs for 2 consecutive find's"
6790 local LDPROC=/proc/fs/ldiskfs
6792 for facet in $(get_facets MDS); do
6793 canondev=$(ldiskfs_canon *.$(convert_facet2label $facet).mntdev $facet)
6794 do_facet $facet "test -e $LDPROC/$canondev/max_dir_size" || LDPROC=/sys/fs/ldiskfs
6795 do_facet $facet "echo $1 >$LDPROC/$canondev/max_dir_size"
6799 [ "$FSTYPE" != "ldiskfs" ] && skip "not needed for FSTYPE=$FSTYPE" && return 0
6800 remote_mds_nodsh && skip "remote MDS with nodsh" && return
6811 while [ ! $I -gt $((MAX * MDSCOUNT)) ]; do
6812 multiop $DIR/$tdir/$J Oc
6814 if [ $rc -eq $EFBIG ]; then
6816 echo "return code $rc received as expected"
6818 elif [ $rc -ne 0 ]; then
6820 error_exit "return code $rc received instead of expected $EFBIG"
6823 I=$(stat -c%s "$DIR/$tdir")
6827 error "exceeded dir size limit $MAX x $MDSCOUNT $((MAX * MDSCOUNT)) : $I bytes"
6829 run_test 129 "test directory size limit ========================"
6838 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
6839 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
6841 trap cleanup_130 EXIT RETURN
6843 local fm_file=$DIR/$tfile
6844 $SETSTRIPE -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
6845 dd if=/dev/zero of=$fm_file bs=65536 count=1 || error "dd failed for $fm_file"
6847 filefrag -ves $fm_file || error "filefrag $fm_file failed"
6848 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
6850 lun=$($GETSTRIPE -i $fm_file)
6852 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
6855 for line in $filefrag_op
6857 frag_lun=`echo $line | cut -d: -f5`
6858 ext_len=`echo $line | cut -d: -f4`
6859 if (( $frag_lun != $lun )); then
6861 error "FIEMAP on 1-stripe file($fm_file) failed"
6864 (( tot_len += ext_len ))
6867 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
6869 error "FIEMAP on 1-stripe file($fm_file) failed;"
6875 echo "FIEMAP on single striped file succeeded"
6877 run_test 130a "FIEMAP (1-stripe file)"
6880 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping FIEMAP on 2-stripe file test" && return
6882 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
6883 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
6885 trap cleanup_130 EXIT RETURN
6887 local fm_file=$DIR/$tfile
6888 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
6889 dd if=/dev/zero of=$fm_file bs=1M count=2 || error "dd failed on $fm_file"
6891 filefrag -ves $fm_file || error "filefrag $fm_file failed"
6892 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
6894 last_lun=`echo $filefrag_op | cut -d: -f5`
6899 for line in $filefrag_op
6901 frag_lun=`echo $line | cut -d: -f5`
6902 ext_len=`echo $line | cut -d: -f4`
6903 if (( $frag_lun != $last_lun )); then
6904 if (( tot_len != 1024 )); then
6906 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 256"
6913 (( tot_len += ext_len ))
6916 if (( num_luns != 2 || tot_len != 1024 )); then
6918 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
6924 echo "FIEMAP on 2-stripe file succeeded"
6926 run_test 130b "FIEMAP (2-stripe file)"
6929 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping FIEMAP on 2-stripe file with hole test" && return
6931 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
6932 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
6934 trap cleanup_130 EXIT RETURN
6936 local fm_file=$DIR/$tfile
6937 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
6938 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 || error "dd failed on $fm_file"
6940 filefrag -ves $fm_file || error "filefrag $fm_file failed"
6941 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
6943 last_lun=`echo $filefrag_op | cut -d: -f5`
6948 for line in $filefrag_op
6950 frag_lun=`echo $line | cut -d: -f5`
6951 ext_len=`echo $line | cut -d: -f4`
6952 if (( $frag_lun != $last_lun )); then
6953 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
6954 if (( logical != 512 )); then
6956 error "FIEMAP on $fm_file failed; returned logical start for lun $logical instead of 512"
6959 if (( tot_len != 512 )); then
6961 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
6968 (( tot_len += ext_len ))
6971 if (( num_luns != 2 || tot_len != 512 )); then
6973 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
6979 echo "FIEMAP on 2-stripe file with hole succeeded"
6981 run_test 130c "FIEMAP (2-stripe file with hole)"
6984 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping FIEMAP on N-stripe file test" && return
6986 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
6987 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
6989 trap cleanup_130 EXIT RETURN
6991 local fm_file=$DIR/$tfile
6992 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file||error "setstripe on $fm_file"
6993 dd if=/dev/zero of=$fm_file bs=1M count=$OSTCOUNT || error "dd failed on $fm_file"
6995 filefrag -ves $fm_file || error "filefrag $fm_file failed"
6996 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
6998 last_lun=`echo $filefrag_op | cut -d: -f5`
7003 for line in $filefrag_op
7005 frag_lun=`echo $line | cut -d: -f5`
7006 ext_len=`echo $line | cut -d: -f4`
7007 if (( $frag_lun != $last_lun )); then
7008 if (( tot_len != 1024 )); then
7010 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
7017 (( tot_len += ext_len ))
7020 if (( num_luns != OSTCOUNT || tot_len != 1024 )); then
7022 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
7028 echo "FIEMAP on N-stripe file succeeded"
7030 run_test 130d "FIEMAP (N-stripe file)"
7033 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping continuation FIEMAP test" && return
7035 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7036 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
7038 trap cleanup_130 EXIT RETURN
7040 local fm_file=$DIR/$tfile
7041 $SETSTRIPE -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
7043 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
7044 for ((i = 0; i < $NUM_BLKS; i++))
7046 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
7049 filefrag -ves $fm_file || error "filefrag $fm_file failed"
7050 filefrag_op=`filefrag -ve $fm_file | grep -A 12000 "ext:" | grep -v "ext:" | grep -v "found"`
7052 last_lun=`echo $filefrag_op | cut -d: -f5`
7057 for line in $filefrag_op
7059 frag_lun=`echo $line | cut -d: -f5`
7060 ext_len=`echo $line | cut -d: -f4`
7061 if (( $frag_lun != $last_lun )); then
7062 if (( tot_len != $EXPECTED_LEN )); then
7064 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of $EXPECTED_LEN"
7071 (( tot_len += ext_len ))
7074 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
7076 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
7082 echo "FIEMAP with continuation calls succeeded"
7084 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
7086 # Test for writev/readv
7088 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 || \
7089 error "writev test failed"
7090 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 || \
7091 error "readv failed"
7094 run_test 131a "test iov's crossing stripe boundary for writev/readv"
7097 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 || \
7098 error "append writev test failed"
7099 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 || \
7100 error "append writev test failed"
7103 run_test 131b "test append writev"
7106 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
7109 run_test 131c "test read/write on file w/o objects"
7112 rwv -f $DIR/$tfile -w -n 1 1572864
7113 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
7114 if [ "$NOB" != 1572864 ]; then
7115 error "Short read filed: read $NOB bytes instead of 1572864"
7119 run_test 131d "test short read"
7122 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
7123 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
7124 error "read hitting hole failed"
7127 run_test 131e "test read hitting hole"
7132 for node in $(osts_nodes); do
7133 gl=$(do_node $node "$LCTL get_param -n ost.OSS.ost.stats" | awk '/'$token'/ {print $2}' | head -n 1)
7134 [ x$gl = x"" ] && gl=0
7135 gl_sum=$((gl_sum + gl))
7145 if [ x$som = x"enabled" ]; then
7146 [ $((gl2 - gl1)) -gt 0 ] && error "no glimpse RPC is expected"
7147 MOUNTOPT=`echo $MOUNTOPT | sed 's/som_preview//g'`
7148 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=disabled"
7150 [ $((gl2 - gl1)) -gt 0 ] || error "some glimpse RPC is expected"
7151 MOUNTOPT="$MOUNTOPT,som_preview"
7152 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=enabled"
7155 # do remount to make new mount-conf parameters actual
7162 test_132() { #1028, SOM
7163 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7164 local num=$(get_mds_dir $DIR)
7165 local mymds=mds${num}
7166 local MOUNTOPT_SAVE=$MOUNTOPT
7168 dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
7169 cancel_lru_locks osc
7171 som1=$(do_facet $mymds "$LCTL get_param mdt.*.som" | awk -F= ' {print $2}' | head -n 1)
7173 gl1=$(get_ost_param "ldlm_glimpse_enqueue")
7174 stat $DIR/$tfile >/dev/null
7175 gl2=$(get_ost_param "ldlm_glimpse_enqueue")
7176 echo "====> SOM is "$som1", "$((gl2 - gl1))" glimpse RPC occured"
7178 som_mode_switch $som1 $gl1 $gl2
7180 dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
7181 cancel_lru_locks osc
7183 som2=$(do_facet $mymds "$LCTL get_param mdt.*.som" | awk -F= ' {print $2}' | head -n 1)
7184 if [ $som1 == $som2 ]; then
7185 error "som is still "$som2
7186 if [ x$som2 = x"enabled" ]; then
7193 gl1=$(get_ost_param "ldlm_glimpse_enqueue")
7194 stat $DIR/$tfile >/dev/null
7195 gl2=$(get_ost_param "ldlm_glimpse_enqueue")
7196 echo "====> SOM is "$som2", "$((gl2 - gl1))" glimpse RPC occured"
7197 som_mode_switch $som2 $gl1 $gl2
7198 MOUNTOPT=$MOUNTOPT_SAVE
7200 run_test 132 "som avoids glimpse rpc"
7206 $SINGLEMDS) res=`do_facet $SINGLEMDS $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$2"`
7208 ost) res=`do_facet ost1 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$2"`
7210 *) error "Wrong argument $1" ;;
7213 count=`echo $res | awk '{print $2}'`
7214 [ -z "$res" ] && error "The counter for $2 on $1 was not incremented"
7215 # if the argument $3 is zero, it means any stat increment is ok.
7216 if [ $3 -gt 0 ] ; then
7217 [ $count -ne $3 ] && error "The $2 counter on $1 is wrong - expected $3"
7222 remote_ost_nodsh && skip "remote OST with nodsh" && return
7223 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7224 local testdir=$DIR/${tdir}/stats_testdir
7225 mkdir -p $DIR/${tdir}
7228 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
7229 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
7231 # verify mdt stats first.
7232 mkdir ${testdir} || error "mkdir failed"
7233 check_stats $SINGLEMDS "mkdir" 1
7234 touch ${testdir}/${tfile} || "touch failed"
7235 check_stats $SINGLEMDS "open" 1
7236 check_stats $SINGLEMDS "close" 1
7237 mknod ${testdir}/${tfile}-pipe p || "mknod failed"
7238 check_stats $SINGLEMDS "mknod" 1
7239 rm -f ${testdir}/${tfile}-pipe || "pipe remove failed"
7240 check_stats $SINGLEMDS "unlink" 1
7241 rm -f ${testdir}/${tfile} || error "file remove failed"
7242 check_stats $SINGLEMDS "unlink" 2
7244 # remove working dir and check mdt stats again.
7245 rmdir ${testdir} || error "rmdir failed"
7246 check_stats $SINGLEMDS "rmdir" 1
7248 local testdir1=$DIR/${tdir}/stats_testdir1
7250 mkdir -p ${testdir1}
7251 touch ${testdir1}/test1
7252 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
7253 check_stats $SINGLEMDS "crossdir_rename" 1
7255 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
7256 check_stats $SINGLEMDS "samedir_rename" 1
7260 run_test 133a "Verifying MDT stats ========================================"
7263 remote_ost_nodsh && skip "remote OST with nodsh" && return
7264 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7265 local testdir=$DIR/${tdir}/stats_testdir
7266 mkdir -p ${testdir} || error "mkdir failed"
7267 touch ${testdir}/${tfile} || "touch failed"
7268 cancel_lru_locks mdc
7271 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
7272 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
7274 # extra mdt stats verification.
7275 chmod 444 ${testdir}/${tfile} || error "chmod failed"
7276 check_stats $SINGLEMDS "setattr" 1
7277 $LFS df || error "lfs failed"
7278 check_stats $SINGLEMDS "statfs" 1
7282 run_test 133b "Verifying extra MDT stats =================================="
7285 remote_ost_nodsh && skip "remote OST with nodsh" && return
7286 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7287 local testdir=$DIR/${tdir}/stats_testdir
7288 mkdir -p ${testdir} || error "mkdir failed"
7290 # verify obdfilter stats.
7291 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
7293 cancel_lru_locks osc
7296 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
7297 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
7299 dd if=/dev/zero of=${testdir}/${tfile} conv=notrunc bs=512k count=1 || error "dd failed"
7301 cancel_lru_locks osc
7302 check_stats ost "write" 1
7304 dd if=${testdir}/${tfile} of=/dev/null bs=1k count=1 || error "dd failed"
7305 check_stats ost "read" 1
7307 > ${testdir}/${tfile} || error "truncate failed"
7308 check_stats ost "punch" 1
7310 rm -f ${testdir}/${tfile} || error "file remove failed"
7311 check_stats ost "destroy" 1
7315 run_test 133c "Verifying OST stats ========================================"
7322 while [ $value -ge 2 ]; do
7327 if [ $orig -gt $order ]; then
7335 local size=('K' 'M' 'G' 'T');
7337 local size_string=$value
7339 while [ $value -ge 1024 ]; do
7340 if [ $i -gt 3 ]; then
7341 #T is the biggest unit we get here, if that is bigger,
7343 size_string=${value}T
7346 value=$((value >> 10))
7347 if [ $value -lt 1024 ]; then
7348 size_string=${value}${size[$i]}
7359 local sample=$(do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats | \
7360 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
7365 remote_ost_nodsh && skip "remote OST with nodsh" && return
7366 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7367 local testdir1=$DIR/${tdir}/stats_testdir1
7368 local testdir2=$DIR/${tdir}/stats_testdir2
7370 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
7372 mkdir -p ${testdir1} || error "mkdir failed"
7373 mkdir -p ${testdir2} || error "mkdir failed"
7375 createmany -o $testdir1/test 512 || error "createmany failed"
7376 local testdir1_size=$(ls -l $DIR/${tdir} | \
7377 awk '/stats_testdir1/ {print $5}')
7378 local testdir2_size=$(ls -l $DIR/${tdir} | \
7379 awk '/stats_testdir2/ {print $5}')
7381 testdir1_size=$(order_2 $testdir1_size)
7382 testdir2_size=$(order_2 $testdir2_size)
7384 testdir1_size=$(size_in_KMGT $testdir1_size)
7385 testdir2_size=$(size_in_KMGT $testdir2_size)
7387 # check samedir rename size
7388 mv ${testdir1}/test0 ${testdir1}/test_0
7389 local samedir=$(do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats | \
7391 local same_sample=$(get_rename_size $testdir1_size)
7392 [ -z "$samedir" ] && error "samedir_rename_size count error"
7393 [ $same_sample -eq 1 ] || error "samedir_rename_size count error"
7394 echo "Check same dir rename stats success"
7396 # check crossdir rename size
7397 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
7398 mv ${testdir1}/test_0 ${testdir2}/test_0
7399 local crossdir=$(do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats | \
7401 local src_sample=$(get_rename_size $testdir1_size)
7402 local tgt_sample=$(get_rename_size $testdir2_size)
7403 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
7404 [ $src_sample -eq 1 ] || error "crossdir_rename_size count error"
7405 [ $tgt_sample -eq 1 ] || error "crossdir_rename_size count error"
7406 echo "Check cross dir rename stats success"
7410 run_test 133d "Verifying rename_stats ========================================"
7412 test_140() { #bug-17379
7413 mkdir -p $DIR/$tdir || error "Creating dir $DIR/$tdir"
7414 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
7415 cp /usr/bin/stat . || error "Copying stat to $DIR/$tdir"
7417 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
7419 while i=`expr $i + 1`; do
7420 mkdir -p $i || error "Creating dir $i"
7421 cd $i || error "Changing to $i"
7422 ln -s ../stat stat || error "Creating stat symlink"
7423 # Read the symlink until ELOOP present,
7424 # not LBUGing the system is considered success,
7425 # we didn't overrun the stack.
7426 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
7428 if [ $ret -eq 40 ]; then
7431 error "Open stat symlink"
7437 echo "The symlink depth = $i"
7438 [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 ] || error "Invalid symlink depth"
7440 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
7443 local TF="$TMP/$tfile"
7445 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
7447 cancel_lru_locks osc
7448 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
7449 remount_client $MOUNT
7451 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
7454 $TRUNCATE $DIR/$tfile 6000
7455 cancel_lru_locks osc
7456 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
7459 echo "12345" >>$DIR/$tfile
7460 cancel_lru_locks osc
7461 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
7464 echo "12345" >>$DIR/$tfile
7465 cancel_lru_locks osc
7466 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
7471 run_test 150 "truncate/append tests"
7473 function roc_hit() {
7474 local list=$(comma_list $(osts_nodes))
7476 ACCNUM=$(do_nodes $list $LCTL get_param -n obdfilter.*.stats | \
7477 awk '/'cache_hit'/ {sum+=$2} END {print sum}')
7481 function set_cache() {
7484 if [ "$2" == "off" ]; then
7487 local list=$(comma_list $(osts_nodes))
7488 do_nodes $list lctl set_param obdfilter.*.${1}_cache_enable $on
7490 cancel_lru_locks osc
7494 remote_ost_nodsh && skip "remote OST with nodsh" && return
7497 local list=$(comma_list $(osts_nodes))
7499 # check whether obdfilter is cache capable at all
7500 if ! do_nodes $list $LCTL get_param -n obdfilter.*.read_cache_enable > /dev/null; then
7501 echo "not cache-capable obdfilter"
7505 # check cache is enabled on all obdfilters
7506 if do_nodes $list $LCTL get_param -n obdfilter.*.read_cache_enable | grep 0 >&/dev/null; then
7507 echo "oss cache is disabled"
7511 do_nodes $list $LCTL set_param -n obdfilter.*.writethrough_cache_enable 1
7513 # pages should be in the case right after write
7514 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES || error "dd failed"
7515 local BEFORE=`roc_hit`
7516 cancel_lru_locks osc
7517 cat $DIR/$tfile >/dev/null
7518 local AFTER=`roc_hit`
7519 if ! let "AFTER - BEFORE == CPAGES"; then
7520 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
7523 # the following read invalidates the cache
7524 cancel_lru_locks osc
7525 do_nodes $list $LCTL set_param -n obdfilter.*.read_cache_enable 0
7526 cat $DIR/$tfile >/dev/null
7528 # now data shouldn't be found in the cache
7530 cancel_lru_locks osc
7531 cat $DIR/$tfile >/dev/null
7533 if let "AFTER - BEFORE != 0"; then
7534 error "IN CACHE: before: $BEFORE, after: $AFTER"
7537 do_nodes $list $LCTL set_param -n obdfilter.*.read_cache_enable 1
7540 run_test 151 "test cache on oss and controls ==============================="
7543 local TF="$TMP/$tfile"
7545 # simulate ENOMEM during write
7546 #define OBD_FAIL_OST_NOMEM 0x226
7547 lctl set_param fail_loc=0x80000226
7548 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
7550 sync || error "sync failed"
7551 lctl set_param fail_loc=0
7553 # discard client's cache
7554 cancel_lru_locks osc
7556 # simulate ENOMEM during read
7557 lctl set_param fail_loc=0x80000226
7558 cmp $TF $DIR/$tfile || error "cmp failed"
7559 lctl set_param fail_loc=0
7563 run_test 152 "test read/write with enomem ============================"
7566 multiop $DIR/$tfile Ow4096Ycu || error "multiop failed"
7568 run_test 153 "test if fdatasync does not crash ======================="
7571 cp /etc/hosts $DIR/$tfile
7573 fid=$($LFS path2fid $DIR/$tfile)
7575 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
7577 ffid=$DIR/.lustre/fid/$fid
7579 echo "stat fid $fid"
7580 stat $ffid > /dev/null || error "stat $ffid failed."
7581 echo "touch fid $fid"
7582 touch $ffid || error "touch $ffid failed."
7583 echo "write to fid $fid"
7584 cat /etc/hosts > $ffid || error "write $ffid failed."
7585 echo "read fid $fid"
7586 diff /etc/hosts $ffid || error "read $ffid failed."
7587 echo "append write to fid $fid"
7588 cat /etc/hosts >> $ffid || error "append write $ffid failed."
7589 echo "rename fid $fid"
7590 mv $ffid $DIR/$tfile.1 && error "rename $ffid to $tfile.1 should fail."
7592 mv $DIR/$tfile.1 $ffid && error "rename $tfile.1 to $ffid should fail."
7594 echo "truncate fid $fid"
7595 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
7596 echo "link fid $fid"
7597 ln -f $ffid $DIR/tfile.lnk || error "link $ffid failed."
7598 if [ -n $(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl) ]; then
7599 echo "setfacl fid $fid"
7600 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
7601 echo "getfacl fid $fid"
7602 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
7604 echo "unlink fid $fid"
7605 unlink $DIR/.lustre/fid/$fid && error "unlink $ffid should fail."
7606 echo "mknod fid $fid"
7607 mknod $ffid c 1 3 && error "mknod $ffid should fail."
7609 fid=[0xf00000400:0x1:0x0]
7610 ffid=$DIR/.lustre/fid/$fid
7612 echo "stat non-exist fid $fid"
7613 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
7614 echo "write to non-exist fid $fid"
7615 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
7616 echo "link new fid $fid"
7617 ln $DIR/$tfile $ffid && error "link $ffid should fail."
7620 touch $DIR/$tdir/$tfile
7621 fid=$($LFS path2fid $DIR/$tdir)
7623 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
7625 ffid=$DIR/.lustre/fid/$fid
7628 ls $ffid > /dev/null || error "ls $ffid failed."
7629 echo "touch $fid/$tfile.1"
7630 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
7632 echo "touch $DIR/.lustre/fid/$tfile"
7633 touch $DIR/.lustre/fid/$tfile && \
7634 error "touch $DIR/.lustre/fid/$tfile should fail."
7636 echo "Open-by-FID succeeded"
7638 run_test 154 "Open-by-FID"
7640 test_155_small_load() {
7641 local temp=$TMP/$tfile
7642 local file=$DIR/$tfile
7644 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
7645 error "dd of=$temp bs=6096 count=1 failed"
7647 cancel_lru_locks osc
7648 cmp $temp $file || error "$temp $file differ"
7650 $TRUNCATE $temp 6000
7651 $TRUNCATE $file 6000
7652 cmp $temp $file || error "$temp $file differ (truncate1)"
7654 echo "12345" >>$temp
7655 echo "12345" >>$file
7656 cmp $temp $file || error "$temp $file differ (append1)"
7658 echo "12345" >>$temp
7659 echo "12345" >>$file
7660 cmp $temp $file || error "$temp $file differ (append2)"
7666 test_155_big_load() {
7667 remote_ost_nodsh && skip "remote OST with nodsh" && return
7668 local temp=$TMP/$tfile
7669 local file=$DIR/$tfile
7672 local cache_size=$(do_facet ost$((MAXI+1)) \
7673 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
7674 local large_file_size=$((cache_size * 2))
7676 echo "OSS cache size: $cache_size KB"
7677 echo "Large file size: $large_file_size KB"
7679 [ $MAXV -le $large_file_size ] && \
7680 skip_env "max available OST size needs > $large_file_size KB" && \
7683 $SETSTRIPE $file -c 1 -i $MAXI || error "$SETSTRIPE $file failed"
7685 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k || \
7686 error "dd of=$temp bs=$large_file_size count=1k failed"
7689 cancel_lru_locks osc
7690 cmp $temp $file || error "$temp $file differ"
7698 set_cache writethrough on
7701 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
7705 set_cache writethrough off
7708 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
7712 set_cache writethrough on
7715 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
7719 set_cache writethrough off
7722 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
7726 set_cache writethrough on
7729 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
7733 set_cache writethrough off
7736 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
7740 set_cache writethrough on
7743 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
7747 set_cache writethrough off
7750 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
7756 local file="$DIR/$tfile"
7758 log "Turn on read and write cache"
7760 set_cache writethrough on
7762 log "Write data and read it back."
7763 log "Read should be satisfied from the cache."
7764 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
7766 cancel_lru_locks osc
7767 cat $file >/dev/null
7769 if ! let "AFTER - BEFORE == CPAGES"; then
7770 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
7772 log "cache hits:: before: $BEFORE, after: $AFTER"
7775 log "Read again; it should be satisfied from the cache."
7777 cancel_lru_locks osc
7778 cat $file >/dev/null
7780 if ! let "AFTER - BEFORE == CPAGES"; then
7781 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
7783 log "cache hits:: before: $BEFORE, after: $AFTER"
7787 log "Turn off the read cache and turn on the write cache"
7789 set_cache writethrough on
7791 log "Read again; it should be satisfied from the cache."
7793 cancel_lru_locks osc
7794 cat $file >/dev/null
7796 if ! let "AFTER - BEFORE == CPAGES"; then
7797 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
7799 log "cache hits:: before: $BEFORE, after: $AFTER"
7802 log "Read again; it should not be satisfied from the cache."
7804 cancel_lru_locks osc
7805 cat $file >/dev/null
7807 if ! let "AFTER - BEFORE == 0"; then
7808 error "IN CACHE: before: $BEFORE, after: $AFTER"
7810 log "cache hits:: before: $BEFORE, after: $AFTER"
7813 log "Write data and read it back."
7814 log "Read should be satisfied from the cache."
7815 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
7817 cancel_lru_locks osc
7818 cat $file >/dev/null
7820 if ! let "AFTER - BEFORE == CPAGES"; then
7821 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
7823 log "cache hits:: before: $BEFORE, after: $AFTER"
7826 log "Read again; it should not be satisfied from the cache."
7828 cancel_lru_locks osc
7829 cat $file >/dev/null
7831 if ! let "AFTER - BEFORE == 0"; then
7832 error "IN CACHE: before: $BEFORE, after: $AFTER"
7834 log "cache hits:: before: $BEFORE, after: $AFTER"
7838 log "Turn off read and write cache"
7840 set_cache writethrough off
7842 log "Write data and read it back"
7843 log "It should not be satisfied from the cache."
7845 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
7846 cancel_lru_locks osc
7848 cat $file >/dev/null
7850 if ! let "AFTER - BEFORE == 0"; then
7851 error_ignore 20762 "IN CACHE: before: $BEFORE, after: $AFTER"
7853 log "cache hits:: before: $BEFORE, after: $AFTER"
7857 log "Turn on the read cache and turn off the write cache"
7859 set_cache writethrough off
7861 log "Write data and read it back"
7862 log "It should not be satisfied from the cache."
7864 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
7866 cancel_lru_locks osc
7867 cat $file >/dev/null
7869 if ! let "AFTER - BEFORE == 0"; then
7870 error_ignore 20762 "IN CACHE: before: $BEFORE, after: $AFTER"
7872 log "cache hits:: before: $BEFORE, after: $AFTER"
7875 log "Read again; it should be satisfied from the cache."
7877 cancel_lru_locks osc
7878 cat $file >/dev/null
7880 if ! let "AFTER - BEFORE == CPAGES"; then
7881 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
7883 log "cache hits:: before: $BEFORE, after: $AFTER"
7888 run_test 156 "Verification of tunables ============================"
7892 if [ $MDSCOUNT -gt 1 ]; then
7893 error_ignore 17935 $*
7901 MASK=$(do_facet $SINGLEMDS $LCTL get_param mdd.$MDT0.changelog_mask |\
7904 if [ $MASK -eq 1 ]; then
7905 do_facet $SINGLEMDS $LCTL set_param mdd.$MDT0.changelog_mask="-$1"
7907 do_facet $SINGLEMDS $LCTL set_param mdd.$MDT0.changelog_mask="+$1"
7912 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7913 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
7914 echo "Registered as changelog user $USER"
7915 do_facet $SINGLEMDS $LCTL get_param -n mdd.$MDT0.changelog_users | \
7916 grep -q $USER || error "User $USER not found in changelog_users"
7919 mkdir -p $DIR/$tdir/pics/2008/zachy
7920 touch $DIR/$tdir/pics/2008/zachy/timestamp
7921 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
7922 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
7923 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
7924 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
7925 rm $DIR/$tdir/pics/desktop.jpg
7927 $LFS changelog $MDT0 | tail -5
7929 echo "verifying changelog mask"
7930 changelog_chmask "MKDIR"
7931 changelog_chmask "CLOSE"
7933 mkdir -p $DIR/$tdir/pics/zach/sofia
7934 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
7936 changelog_chmask "MKDIR"
7937 changelog_chmask "CLOSE"
7939 mkdir -p $DIR/$tdir/pics/2008/sofia
7940 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
7942 $LFS changelog $MDT0
7943 MKDIRS=$($LFS changelog $MDT0 | tail -5 | grep -c "MKDIR")
7944 CLOSES=$($LFS changelog $MDT0 | tail -5 | grep -c "CLOSE")
7945 [ $MKDIRS -eq 1 ] || err17935 "MKDIR changelog mask count $DIRS != 1"
7946 [ $CLOSES -eq 1 ] || err17935 "CLOSE changelog mask count $DIRS != 1"
7949 echo "verifying target fid"
7950 fidc=$($LFS changelog $MDT0 | grep timestamp | grep "CREAT" | \
7951 tail -1 | awk '{print $6}')
7952 fidf=$($LFS path2fid $DIR/$tdir/pics/zach/timestamp)
7953 [ "$fidc" == "t=$fidf" ] || \
7954 err17935 "fid in changelog $fidc != file fid $fidf"
7955 echo "verifying parent fid"
7956 fidc=$($LFS changelog $MDT0 | grep timestamp | grep "CREAT" | \
7957 tail -1 | awk '{print $7}')
7958 fidf=$($LFS path2fid $DIR/$tdir/pics/zach)
7959 [ "$fidc" == "p=$fidf" ] || \
7960 err17935 "pfid in changelog $fidc != dir fid $fidf"
7962 USER_REC1=$(do_facet $SINGLEMDS $LCTL get_param -n \
7963 mdd.$MDT0.changelog_users | grep $USER | awk '{print $2}')
7964 $LFS changelog_clear $MDT0 $USER $(($USER_REC1 + 5))
7965 USER_REC2=$(do_facet $SINGLEMDS $LCTL get_param -n \
7966 mdd.$MDT0.changelog_users | grep $USER | awk '{print $2}')
7967 echo "verifying user clear: $(( $USER_REC1 + 5 )) == $USER_REC2"
7968 [ $USER_REC2 == $(($USER_REC1 + 5)) ] || \
7969 err17935 "user index should be $(($USER_REC1 + 5)); is $USER_REC2"
7971 MIN_REC=$(do_facet $SINGLEMDS $LCTL get_param mdd.$MDT0.changelog_users | \
7972 awk 'min == "" || $2 < min {min = $2}; END {print min}')
7973 FIRST_REC=$($LFS changelog $MDT0 | head -1 | awk '{print $1}')
7974 echo "verifying min purge: $(( $MIN_REC + 1 )) == $FIRST_REC"
7975 [ $FIRST_REC == $(($MIN_REC + 1)) ] || \
7976 err17935 "first index should be $(($MIN_REC + 1)); is $FIRST_REC"
7978 echo "verifying user deregister"
7979 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
7980 do_facet $SINGLEMDS $LCTL get_param -n mdd.$MDT0.changelog_users | \
7981 grep -q $USER && error "User $USER still found in changelog_users"
7983 USERS=$(( $(do_facet $SINGLEMDS $LCTL get_param -n \
7984 mdd.$MDT0.changelog_users | wc -l) - 2 ))
7985 if [ $USERS -eq 0 ]; then
7986 LAST_REC1=$(do_facet $SINGLEMDS $LCTL get_param -n \
7987 mdd.$MDT0.changelog_users | head -1 | awk '{print $3}')
7988 touch $DIR/$tdir/chloe
7989 LAST_REC2=$(do_facet $SINGLEMDS $LCTL get_param -n \
7990 mdd.$MDT0.changelog_users | head -1 | awk '{print $3}')
7991 echo "verify changelogs are off if we were the only user: $LAST_REC1 == $LAST_REC2"
7992 [ $LAST_REC1 == $LAST_REC2 ] || error "changelogs not off"
7994 echo "$USERS other changelog users; can't verify off"
7997 run_test 160 "changelog sanity"
8001 cp /etc/hosts $DIR/$tdir/$tfile
8002 mkdir $DIR/$tdir/foo1
8003 mkdir $DIR/$tdir/foo2
8004 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
8005 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
8006 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
8007 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
8008 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[')
8009 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
8010 $LFS fid2path $DIR $FID
8011 err17935 "bad link ea"
8014 rm $DIR/$tdir/foo2/zachary
8016 rm $DIR/$tdir/foo2/thor
8018 rm $DIR/$tdir/$tfile
8020 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
8021 if [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ]
8023 $LFS fid2path $DIR $FID
8024 err17935 "bad link rename"
8026 rm $DIR/$tdir/foo2/maggie
8029 local longname=filename_avg_len_is_thirty_two_
8030 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 || \
8031 error "failed to hardlink many files"
8032 links=$($LFS fid2path $DIR $FID | wc -l)
8033 echo -n "${links}/1000 links in link EA"
8034 [ ${links} -gt 60 ] || err17935 "expected at least 60 links in link EA"
8035 unlinkmany $DIR/$tdir/foo2/$longname 1000 || \
8036 error "failed to unlink many hardlinks"
8038 run_test 161 "link ea sanity"
8045 local path=$(${LFS} fid2path $*)
8048 if [ $RC -ne 0 ]; then
8049 err17935 "path looked up of $expected failed. Error $RC"
8051 elif [ "${path}" != "${expected}" ]; then
8052 err17935 "path looked up \"${path}\" instead of \"${expected}\""
8055 echo "fid $fid resolves to path $path (expected $expected)"
8059 # Make changes to filesystem
8060 mkdir -p $DIR/$tdir/d2
8061 touch $DIR/$tdir/d2/$tfile
8062 touch $DIR/$tdir/d2/x1
8063 touch $DIR/$tdir/d2/x2
8064 mkdir -p $DIR/$tdir/d2/a/b/c
8065 mkdir -p $DIR/$tdir/d2/p/q/r
8067 FID=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
8068 check_path "$tdir/d2/$tfile" $FSNAME $FID --link 0
8071 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
8072 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
8073 check_path "$tdir/d2/p/q/r/slink" $FSNAME $FID --link 0
8075 # softlink to wrong file
8076 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
8077 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
8078 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME $FID --link 0
8081 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
8082 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
8083 FID=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
8084 # fid2path dir/fsname should both work
8085 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 1
8086 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR $FID --link 0
8088 # hardlink count: check that there are 2 links
8089 # Doesnt work with CMD yet: 17935
8090 ${LFS} fid2path $DIR $FID | wc -l | grep -q 2 || \
8091 err17935 "expected 2 links"
8093 # hardlink indexing: remove the first link
8094 rm $DIR/$tdir/d2/p/q/r/hlink
8095 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 0
8099 run_test 162 "path lookup sanity"
8102 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8103 copytool --test $FSNAME || { skip "copytool not runnable: $?" && return; }
8106 local uuid=$($LCTL get_param -n mdc.${FSNAME}-MDT0000-mdc-*.uuid)
8107 # this proc file is temporary and linux-only
8108 do_facet $SINGLEMDS lctl set_param mdt.${FSNAME}-MDT0000.mdccomm=$uuid ||\
8109 error "kernel->userspace send failed"
8112 run_test 163 "kernel <-> userspace comms"
8115 # do directio so as not to populate the page cache
8116 log "creating a 10 Mb file"
8117 multiop $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
8118 log "starting reads"
8119 dd if=$DIR/$tfile of=/dev/null bs=4096 &
8120 log "truncating the file"
8121 multiop $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
8123 kill %+ || true # reads might have finished
8124 echo "wait until dd is finished"
8126 log "removing the temporary file"
8127 rm -rf $DIR/$tfile || error "tmp file removal failed"
8129 run_test 169 "parallel read and truncate should not deadlock"
8132 $LCTL clear # bug 18514
8133 $LCTL debug_daemon start $TMP/${tfile}_log_good
8135 $LCTL debug_daemon stop
8136 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
8137 error "sed failed to read log_good"
8139 $LCTL debug_daemon start $TMP/${tfile}_log_good
8141 $LCTL debug_daemon stop
8143 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
8144 error "lctl df log_bad failed"
8146 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
8147 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
8149 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
8150 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
8152 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
8153 error "bad_line good_line1 good_line2 are empty"
8155 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
8156 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
8157 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
8159 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
8160 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
8161 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
8163 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
8164 error "bad_line_new good_line_new are empty"
8166 local expected_good=$((good_line1 + good_line2*2))
8168 rm -f $TMP/${tfile}*
8169 # LU-231, short malformed line may not be counted into bad lines
8170 if [ $bad_line -ne $bad_line_new ] &&
8171 [ $bad_line -ne $((bad_line_new - 1)) ]; then
8172 error "expected $bad_line bad lines, but got $bad_line_new"
8176 if [ $expected_good -ne $good_line_new ]; then
8177 error "expected $expected_good good lines, but got $good_line_new"
8182 run_test 170 "test lctl df to handle corrupted log ====================="
8184 test_171() { # bug20592
8185 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
8186 $LCTL set_param fail_loc=0x50e
8187 $LCTL set_param fail_val=3000
8188 multiop_bg_pause $DIR/$tfile O_s || true
8190 kill -USR1 $MULTIPID
8194 if dmesg | grep "recursive fault"; then
8195 error "caught a recursive fault"
8197 $LCTL set_param fail_loc=0
8200 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
8202 # it would be good to share it with obdfilter-survey/libecho code
8203 setup_obdecho_osc () {
8206 local obdfilter_name=$2
8207 echo "Creating new osc for $obdfilter_name on $ost_nid"
8208 # make sure we can find loopback nid
8209 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
8211 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
8212 ${obdfilter_name}_osc_UUID || rc=2; }
8213 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
8214 ${obdfilter_name}_UUID $ost_nid || rc=3; }
8218 cleanup_obdecho_osc () {
8219 local obdfilter_name=$1
8220 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
8221 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
8225 obdecho_create_test() {
8230 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
8231 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
8233 if [ $rc -eq 0 ]; then
8234 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
8235 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
8237 echo "New object id is $id"
8238 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec test_brw 10 w v 64 $id" ||
8240 [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec " \
8241 "cleanup" || rc=5; }
8242 [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec " \
8244 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
8249 remote_ost_nodsh && skip "remote OST with nodsh" && return
8253 if ! module_loaded obdecho; then
8254 load_module obdecho/obdecho
8258 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
8259 local host=$(lctl get_param -n osc.$osc.import |
8260 awk '/current_connection:/ {print $2}' )
8261 local target=$(lctl get_param -n osc.$osc.import |
8262 awk '/target:/ {print $2}' )
8263 target=${target%_UUID}
8265 [[ -n $target ]] && { setup_obdecho_osc $host $target || rc=1; } || rc=1
8266 [ $rc -eq 0 ] && { obdecho_create_test ${target}_osc client || rc=2; }
8267 [[ -n $target ]] && cleanup_obdecho_osc $target
8268 [ $rmmod_local -eq 1 ] && rmmod obdecho
8271 run_test 180a "test obdecho on osc"
8274 remote_ost_nodsh && skip "remote OST with nodsh" && return
8276 local rmmod_remote=0
8278 do_facet ost1 "lsmod | grep -q obdecho || " \
8279 "{ insmod ${LUSTRE}/obdecho/obdecho.ko || " \
8280 "modprobe obdecho; }" && rmmod_remote=1
8281 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ {print $4;exit}')
8282 [[ -n $target ]] && { obdecho_create_test $target ost1 || rc=1; }
8283 [ $rmmod_remote -eq 1 ] && do_facet ost1 "rmmod obdecho"
8286 run_test 180b "test obdecho directly on obdfilter"
8288 test_181() { # bug 22177
8289 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
8290 # create enough files to index the directory
8291 createmany -o $DIR/$tdir/foobar 4000
8292 # print attributes for debug purpose
8295 multiop_bg_pause $DIR/$tdir D_Sc || return 1
8297 # remove the files & current working dir
8298 unlinkmany $DIR/$tdir/foobar 4000
8300 kill -USR1 $MULTIPID
8302 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
8305 run_test 181 "Test open-unlinked dir ========================"
8311 TGTPOOL_MAX=$(($TGT_COUNT - 1))
8313 TGTPOOL_LIST=`seq $TGTPOOL_FIRST $TGTPOOL_STEP $TGTPOOL_MAX`
8314 POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
8315 POOL_DIR_NAME=dir_tst
8316 POOL_DIR=$POOL_ROOT/$POOL_DIR_NAME
8317 POOL_FILE=$POOL_ROOT/file_tst
8319 check_file_in_pool()
8322 res=$($GETSTRIPE $file | grep 0x | cut -f2)
8325 found=$(echo :$TGTPOOL_LIST: | tr " " ":" | grep :$i:)
8326 if [[ "$found" == "" ]]
8328 echo "pool list: $TGTPOOL_LIST"
8329 echo "striping: $res"
8330 error "$file not allocated in $POOL"
8337 trap "cleanup_pools $FSNAME" EXIT
8340 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
8341 create_pool $FSNAME.$POOL || return $?
8342 [ $($LFS pool_list $FSNAME | grep -c $POOL) -eq 1 ] ||
8343 error "$POOL not in lfs pool_list"
8345 run_test 200a "Create new pool =========================================="
8348 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
8349 TGT=$(for i in $TGTPOOL_LIST; do printf "$FSNAME-OST%04x_UUID " $i; done)
8350 do_facet mgs $LCTL pool_add $FSNAME.$POOL \
8351 $FSNAME-OST[$TGTPOOL_FIRST-$TGTPOOL_MAX/$TGTPOOL_STEP]
8352 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL | sort -u | tr '\n' ' ' " "$TGT" ||
8353 error "Add to pool failed"
8354 local lfscount=$($LFS pool_list $FSNAME.$POOL | grep -c "\-OST")
8355 local addcount=$((($TGTPOOL_MAX - $TGTPOOL_FIRST) / $TGTPOOL_STEP + 1))
8356 [ $lfscount -eq $addcount ] ||
8357 error "lfs pool_list bad ost count $lfscount != $addcount"
8359 run_test 200b "Add targets to a pool ===================================="
8362 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
8364 $SETSTRIPE -c 2 -p $POOL $POOL_DIR
8365 [ $? = 0 ] || error "Cannot set pool $POOL to $POOL_DIR"
8366 # b-19919 test relative path works well
8367 mkdir -p $POOL_DIR/$POOL_DIR_NAME
8369 $SETSTRIPE -c 2 -p $POOL $POOL_DIR_NAME
8370 [ $? = 0 ] || error "Cannot set pool $POOL to $POOL_DIR/$POOL_DIR_NAME"
8371 $SETSTRIPE -c 2 -p $POOL ./$POOL_DIR_NAME
8372 [ $? = 0 ] || error "Cannot set pool $POOL to $POOL_DIR/./$POOL_DIR_NAME"
8373 $SETSTRIPE -c 2 -p $POOL ../$POOL_DIR_NAME
8374 [ $? = 0 ] || error "Cannot set pool $POOL to $POOL_DIR/../$POOL_DIR_NAME"
8375 $SETSTRIPE -c 2 -p $POOL ../$POOL_DIR_NAME/$POOL_DIR_NAME
8376 [ $? = 0 ] || error "Cannot set pool $POOL to $POOL_DIR/../$POOL_DIR_NAME/$POOL_DIR_NAME"
8377 rm -rf $POOL_DIR_NAME; cd -
8379 run_test 200c "Set pool on a directory ================================="
8382 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
8383 res=$($GETSTRIPE --pool $POOL_DIR)
8384 [ $res = $POOL ] || error "Pool on $POOL_DIR is $res, not $POOL"
8386 run_test 200d "Check pool on a directory ==============================="
8389 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
8391 for i in $(seq -w 1 $(($TGT_COUNT * 3)))
8393 file=$POOL_DIR/file-$i
8395 check_file_in_pool $file
8398 failed=$(($failed + 1))
8401 [ "$failed" = 0 ] || error "$failed files not allocated in $POOL"
8403 run_test 200e "Check files allocation from directory pool =============="
8406 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
8409 for i in $(seq -w 1 $(($TGT_COUNT * 3)))
8411 file=$POOL_FILE/spoo-$i
8412 $SETSTRIPE -p $POOL $file
8413 check_file_in_pool $file
8416 failed=$(($failed + 1))
8419 [ "$failed" = 0 ] || error "$failed files not allocated in $POOL"
8421 run_test 200f "Create files in a pool ==================================="
8424 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
8425 TGT=$($LCTL get_param -n lov.$FSNAME-clilov-*.pools.$POOL | tr '\n' ' ')
8426 res=$($LFS df --pool $FSNAME.$POOL | awk '{print $1}' | grep "$FSNAME-OST" | tr '\n' ' ')
8427 [ "$res" = "$TGT" ] || error "Pools OSTs '$TGT' is not '$res' that lfs df reports"
8429 run_test 200g "lfs df a pool ============================================"
8431 test_200h() { # b=24039
8432 mkdir -p $POOL_DIR || error "unable to create $POOL_DIR"
8434 local file="/..$POOL_DIR/$tfile-1"
8435 $SETSTRIPE -p $POOL $file || error "unable to create $file"
8438 $SETSTRIPE -p $POOL $tfile-2 || \
8439 error "unable to create $tfile-2 in $POOL_DIR"
8441 run_test 200h "Create files in a pool with relative pathname ============"
8444 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
8445 TGT=$($LCTL get_param -n lov.$FSNAME-*.pools.$POOL | head -1)
8446 do_facet mgs $LCTL pool_remove $FSNAME.$POOL $TGT
8447 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL | grep $TGT" "" ||
8448 error "$TGT not removed from $FSNAME.$POOL"
8450 run_test 201a "Remove a target from a pool ============================="
8453 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
8454 for TGT in $($LCTL get_param -n lov.$FSNAME-*.pools.$POOL | sort -u)
8456 do_facet mgs $LCTL pool_remove $FSNAME.$POOL $TGT
8458 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL" "" ||
8459 error "Pool $FSNAME.$POOL cannot be drained"
8460 # striping on an empty/nonexistant pool should fall back to "pool of everything"
8461 touch ${POOL_DIR}/$tfile || error "failed to use fallback striping for empty pool"
8462 # setstripe on an empty pool should fail
8463 $SETSTRIPE -p $POOL ${POOL_FILE}/$tfile 2>/dev/null && \
8464 error "expected failure when creating file with empty pool"
8467 run_test 201b "Remove all targets from a pool =========================="
8470 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
8471 do_facet mgs $LCTL pool_destroy $FSNAME.$POOL
8474 # striping on an empty/nonexistant pool should fall back to "pool of everything"
8475 touch ${POOL_DIR}/$tfile || error "failed to use fallback striping for missing pool"
8476 # setstripe on an empty pool should fail
8477 $SETSTRIPE -p $POOL ${POOL_FILE}/$tfile 2>/dev/null && \
8478 error "expected failure when creating file with missing pool"
8480 # get param should return err once pool is gone
8481 if wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null ||
8482 echo foo" "foo"; then
8483 remove_pool_from_list $FSNAME.$POOL
8486 error "Pool $FSNAME.$POOL is not destroyed"
8488 run_test 201c "Remove a pool ============================================"
8490 cleanup_pools $FSNAME
8492 # usage: default_attr <count | size | offset>
8494 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
8497 # usage: check_default_stripe_attr
8498 check_default_stripe_attr() {
8499 ACTUAL=$($GETSTRIPE $* $DIR/$tdir)
8501 --stripe-count|--count)
8502 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
8503 --stripe-size|--size)
8504 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
8505 --stripe-index|--index)
8508 error "unknown getstripe attr '$1'"
8511 [ $ACTUAL != $EXPECTED ] &&
8512 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
8517 $SETSTRIPE --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
8519 check_default_stripe_attr --stripe-count
8520 check_default_stripe_attr --stripe-size
8521 check_default_stripe_attr --stripe-index
8525 run_test 204a "Print default stripe attributes ================="
8529 $SETSTRIPE --stripe-count 1 $DIR/$tdir
8531 check_default_stripe_attr --stripe-size
8532 check_default_stripe_attr --stripe-index
8536 run_test 204b "Print default stripe size and offset ==========="
8540 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
8542 check_default_stripe_attr --stripe-count
8543 check_default_stripe_attr --stripe-index
8547 run_test 204c "Print default stripe count and offset ==========="
8551 $SETSTRIPE --stripe-index 0 $DIR/$tdir
8553 check_default_stripe_attr --stripe-count
8554 check_default_stripe_attr --stripe-size
8558 run_test 204d "Print default stripe count and size ============="
8562 $SETSTRIPE -d $DIR/$tdir
8564 check_default_stripe_attr --stripe-count --raw
8565 check_default_stripe_attr --stripe-size --raw
8566 check_default_stripe_attr --stripe-index --raw
8570 run_test 204e "Print raw stripe attributes ================="
8574 $SETSTRIPE --stripe-count 1 $DIR/$tdir
8576 check_default_stripe_attr --stripe-size --raw
8577 check_default_stripe_attr --stripe-index --raw
8581 run_test 204f "Print raw stripe size and offset ==========="
8585 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
8587 check_default_stripe_attr --stripe-count --raw
8588 check_default_stripe_attr --stripe-index --raw
8592 run_test 204g "Print raw stripe count and offset ==========="
8596 $SETSTRIPE --stripe-index 0 $DIR/$tdir
8598 check_default_stripe_attr --stripe-count --raw
8599 check_default_stripe_attr --stripe-size --raw
8603 run_test 204h "Print raw stripe count and size ============="
8607 size=$((size % 8192 + 1))
8608 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
8609 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
8610 rm -f $DIR/f212 $DIR/f212.xyz
8612 run_test 212 "Sendfile test ============================================"
8615 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
8616 cancel_lru_locks osc
8617 lctl set_param fail_loc=0x8000040f
8618 # generate a read lock
8619 cat $DIR/$tfile > /dev/null
8620 # write to the file, it will try to cancel the above read lock.
8621 cat /etc/hosts >> $DIR/$tfile
8623 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
8625 test_214() { # for bug 20133
8626 mkdir -p $DIR/d214p/d214c
8627 for (( i=0; i < 340; i++ )) ; do
8628 touch $DIR/d214p/d214c/a$i
8631 ls -l $DIR/d214p || error "ls -l $DIR/d214p failed"
8632 mv $DIR/d214p/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
8633 ls $DIR/d214c || error "ls $DIR/d214c failed"
8634 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
8636 run_test 214 "hash-indexed directory test - bug 20133"
8638 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
8639 create_lnet_proc_files() {
8640 cat /proc/sys/lnet/$1 >$TMP/lnet_$1.out || error "cannot read /proc/sys/lnet/$1"
8641 sysctl lnet.$1 >$TMP/lnet_$1.sys_tmp || error "cannot read lnet.$1"
8643 sed "s/^lnet.$1\ =\ //g" "$TMP/lnet_$1.sys_tmp" >$TMP/lnet_$1.sys
8644 rm -f "$TMP/lnet_$1.sys_tmp"
8647 # counterpart of create_lnet_proc_files
8648 remove_lnet_proc_files() {
8649 rm -f $TMP/lnet_$1.out $TMP/lnet_$1.sys
8652 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
8653 # 3rd arg as regexp for body
8654 check_lnet_proc_stats() {
8655 local l=$(cat "$TMP/lnet_$1" |wc -l)
8656 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
8658 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
8661 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
8662 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
8663 # optional and can be regexp for 2nd line (lnet.routes case)
8664 check_lnet_proc_entry() {
8665 local blp=2 # blp stands for 'position of 1st line of body'
8666 [ "$5" = "" ] || blp=3 # lnet.routes case
8668 local l=$(cat "$TMP/lnet_$1" |wc -l)
8669 # subtracting one from $blp because the body can be empty
8670 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
8672 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
8673 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
8675 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
8676 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
8678 # bail out if any unexpected line happened
8679 sed -n "$blp~1 p" "$TMP/lnet_$1" |grep -Ev "$3"
8680 [ "$?" != 0 ] || error "$2 misformatted"
8683 test_215() { # for bugs 18102, 21079, 21517
8684 local N='(0|[1-9][0-9]*)' # non-negative numeric
8685 local P='[1-9][0-9]*' # positive numeric
8686 local I='(0|-?[1-9][0-9]*)' # any numeric (0 | >0 | <0)
8687 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
8688 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
8689 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
8691 local L1 # regexp for 1st line
8692 local L2 # regexp for 2nd line (optional)
8693 local BR # regexp for the rest (body)
8695 # /proc/sys/lnet/stats should look as 11 space-separated non-negative numerics
8696 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
8697 create_lnet_proc_files "stats"
8698 check_lnet_proc_stats "stats.out" "/proc/sys/lnet/stats" "$BR"
8699 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
8700 remove_lnet_proc_files "stats"
8702 # /proc/sys/lnet/routes should look like this:
8703 # Routing disabled/enabled
8704 # net hops state router
8705 # where net is a string like tcp0, hops >= 0, state is up/down,
8706 # router is a string like 192.168.1.1@tcp2
8707 L1="^Routing (disabled|enabled)$"
8708 L2="^net +hops +state +router$"
8709 BR="^$NET +$N +(up|down) +$NID$"
8710 create_lnet_proc_files "routes"
8711 check_lnet_proc_entry "routes.out" "/proc/sys/lnet/routes" "$BR" "$L1" "$L2"
8712 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
8713 remove_lnet_proc_files "routes"
8715 # /proc/sys/lnet/routers should look like this:
8716 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
8717 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
8718 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
8719 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
8720 L1="^ref +rtr_ref +alive_cnt +state +last_ping +ping_sent +deadline +down_ni +router$"
8721 BR="^$P +$P +$N +(up|down) +$N +(0|1) +$I +$I +$NID$"
8722 create_lnet_proc_files "routers"
8723 check_lnet_proc_entry "routers.out" "/proc/sys/lnet/routers" "$BR" "$L1"
8724 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
8725 remove_lnet_proc_files "routers"
8727 # /proc/sys/lnet/peers should look like this:
8728 # nid refs state last max rtr min tx min queue
8729 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
8730 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
8731 # numeric (0 or >0 or <0), queue >= 0.
8732 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
8733 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
8734 create_lnet_proc_files "peers"
8735 check_lnet_proc_entry "peers.out" "/proc/sys/lnet/peers" "$BR" "$L1"
8736 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
8737 remove_lnet_proc_files "peers"
8739 # /proc/sys/lnet/buffers should look like this:
8740 # pages count credits min
8741 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
8742 L1="^pages +count +credits +min$"
8743 BR="^ +$N +$N +$I +$I$"
8744 create_lnet_proc_files "buffers"
8745 check_lnet_proc_entry "buffers.out" "/proc/sys/lnet/buffers" "$BR" "$L1"
8746 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
8747 remove_lnet_proc_files "buffers"
8749 # /proc/sys/lnet/nis should look like this:
8750 # nid status alive refs peer rtr max tx min
8751 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
8752 # alive is numeric (0 or >0 or <0), refs > 0, peer >= 0,
8753 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
8754 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
8755 BR="^$NID +(up|down) +$I +$P +$N +$N +$N +$I +$I$"
8756 create_lnet_proc_files "nis"
8757 check_lnet_proc_entry "nis.out" "/proc/sys/lnet/nis" "$BR" "$L1"
8758 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
8759 remove_lnet_proc_files "nis"
8761 # can we successfully write to /proc/sys/lnet/stats?
8762 echo "0" >/proc/sys/lnet/stats || error "cannot write to /proc/sys/lnet/stats"
8763 sysctl -w lnet.stats=0 || error "cannot write to lnet.stats"
8765 run_test 215 "/proc/sys/lnet exists and has proper content - bugs 18102, 21079, 21517"
8767 test_216() { # bug 20317
8768 remote_ost_nodsh && skip "remote OST with nodsh" && return
8770 local p="$TMP/sanityN-$TESTNAME.parameters"
8771 save_lustre_params $HOSTNAME "osc.*.contention_seconds" > $p
8772 for node in $(osts_nodes); do
8773 save_lustre_params $node "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
8774 save_lustre_params $node "ldlm.namespaces.filter-*.contended_locks" >> $p
8775 save_lustre_params $node "ldlm.namespaces.filter-*.contention_seconds" >> $p
8779 # agressive lockless i/o settings
8780 for node in $(osts_nodes); do
8781 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'
8783 lctl set_param -n osc.*.contention_seconds 60
8785 $DIRECTIO write $DIR/$tfile 0 10 4096
8786 $CHECKSTAT -s 40960 $DIR/$tfile
8788 # disable lockless i/o
8789 for node in $(osts_nodes); do
8790 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'
8792 lctl set_param -n osc.*.contention_seconds 0
8795 dd if=/dev/zero of=$DIR/$tfile count=0
8796 $CHECKSTAT -s 0 $DIR/$tfile
8798 restore_lustre_params <$p
8802 run_test 216 "check lockless direct write works and updates file size and kms correctly"
8804 test_217() { # bug 22430
8808 for node in $(nodes_list); do
8809 nid=$(host_nids_address $node $NETTYPE)
8810 if [[ $nid = *-* ]] ; then
8811 echo "lctl ping $nid@$NETTYPE"
8812 lctl ping $nid@$NETTYPE
8814 echo "skipping $node (no hyphen detected)"
8818 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
8821 # do directio so as not to populate the page cache
8822 log "creating a 10 Mb file"
8823 multiop $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
8824 log "starting reads"
8825 dd if=$DIR/$tfile of=/dev/null bs=4096 &
8826 log "truncating the file"
8827 multiop $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
8829 kill %+ || true # reads might have finished
8830 echo "wait until dd is finished"
8832 log "removing the temporary file"
8833 rm -rf $DIR/$tfile || error "tmp file removal failed"
8835 run_test 218 "parallel read and truncate should not deadlock ======================="
8838 # write one partial page
8839 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
8840 # set no grant so vvp_io_commit_write will do sync write
8841 $LCTL set_param fail_loc=0x411
8842 # write a full page at the end of file
8843 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
8845 $LCTL set_param fail_loc=0
8846 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
8847 $LCTL set_param fail_loc=0x411
8848 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
8850 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
8852 test_220() { #LU-325
8853 remote_ost_nodsh && skip "remote OST with nodsh" && return
8857 local OST=$(lfs osts | grep ${OSTIDX}": " | \
8858 awk '{print $2}' | sed -e 's/_UUID$//')
8861 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
8862 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
8863 osc.$mdtosc_proc1.prealloc_last_id)
8864 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
8865 osc.$mdtosc_proc1.prealloc_next_id)
8869 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
8870 #define OBD_FAIL_OST_ENOINO 0x229
8871 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
8872 do_facet mgs $LCTL pool_new $FSNAME.$TESTNAME || return 1
8873 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
8875 $SETSTRIPE $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
8877 MDSOBJS=$((last_id - next_id))
8878 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
8880 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
8881 echo "OST still has $count kbytes free"
8883 echo "create $MDSOBJS files @next_id..."
8884 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
8886 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
8887 osc.$mdtosc_proc1.prealloc_last_id)
8888 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
8889 osc.$mdtosc_proc1.prealloc_next_id)
8891 echo "after creation, last_id=$last_id2, next_id=$next_id2"
8896 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
8897 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
8899 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST || return 4
8900 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME || return 5
8901 echo "unlink $MDSOBJS files @$next_id..."
8902 unlinkmany $DIR/$tdir/f $MDSOBJS || return 6
8904 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
8907 dd if=`which date` of=$MOUNT/date oflag=sync
8908 chmod +x $MOUNT/date
8910 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
8911 $LCTL set_param fail_loc=0x80001401
8913 $MOUNT/date > /dev/null
8916 run_test 221 "make sure fault and truncate race to not cause OOM"
8921 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
8922 createmany -o $DIR/$tdir/$tfile 10
8923 cancel_lru_locks mdc
8924 cancel_lru_locks osc
8925 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
8926 $LCTL set_param fail_loc=0x31a
8927 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
8928 $LCTL set_param fail_loc=0
8931 run_test 222a "AGL for ls should not trigger CLIO lock failure ================"
8936 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
8937 createmany -o $DIR/$tdir/$tfile 10
8938 cancel_lru_locks mdc
8939 cancel_lru_locks osc
8940 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
8941 $LCTL set_param fail_loc=0x31a
8942 rm -r $DIR/$tdir || "AGL for rmdir failed"
8943 $LCTL set_param fail_loc=0
8945 run_test 222b "AGL for rmdir should not trigger CLIO lock failure ============="
8950 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
8951 createmany -o $DIR/$tdir/$tfile 10
8952 cancel_lru_locks mdc
8953 cancel_lru_locks osc
8954 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
8955 $LCTL set_param fail_loc=0x31b
8956 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
8957 $LCTL set_param fail_loc=0
8960 run_test 223 "osc reenqueue if without AGL lock granted ======================="
8962 test_224a() { # LU-1039, MRP-303
8963 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
8964 $LCTL set_param fail_loc=0x508
8965 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
8966 $LCTL set_param fail_loc=0
8969 run_test 224a "Don't panic on bulk IO failure"
8971 test_224b() { # LU-1039, MRP-303
8972 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
8973 cancel_lru_locks osc
8974 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
8975 $LCTL set_param fail_loc=0x515
8976 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
8977 $LCTL set_param fail_loc=0
8980 run_test 224b "Don't panic on bulk IO failure"
8982 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
8984 if [ -z ${MDSSURVEY} ]; then
8985 skip_env "mds-survey not found" && return
8988 local mds=$(facet_host $SINGLEMDS)
8989 local target=$(do_nodes $mds 'lctl dl' | \
8990 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
8992 local cmd1="file_count=1000 thrhi=4"
8993 local cmd2="dir_count=2 layer=mdd stripe_count=0"
8994 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
8995 local cmd="$cmd1 $cmd2 $cmd3"
8997 rm -f ${TMP}/mds_survey*
8999 eval $cmd || error "mds-survey with zero-stripe failed"
9000 cat ${TMP}/mds_survey*
9001 rm -f ${TMP}/mds_survey*
9003 run_test 225a "Metadata survey sanity with zero-stripe"
9006 if [ -z ${MDSSURVEY} ]; then
9007 skip_env "mds-survey not found" && return
9010 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
9011 skip_env "Need to mount OST to test" && return
9014 local mds=$(facet_host $SINGLEMDS)
9015 local target=$(do_nodes $mds 'lctl dl' | \
9016 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
9018 local cmd1="file_count=1000 thrhi=4"
9019 local cmd2="dir_count=2 layer=mdd stripe_count=1"
9020 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
9021 local cmd="$cmd1 $cmd2 $cmd3"
9023 rm -f ${TMP}/mds_survey*
9025 eval $cmd || error "mds-survey with stripe_count failed"
9026 cat ${TMP}/mds_survey*
9027 rm -f ${TMP}/mds_survey*
9029 run_test 225b "Metadata survey sanity with stripe_count = 1"
9032 # tests that do cleanup/setup should be run at the end
9037 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
9038 $LCTL set_param fail_loc=0x903
9039 # cancel_lru_locks mgc - does not work due to lctl set_param syntax
9040 for ls in /proc/fs/lustre/ldlm/namespaces/MGC*/lru_size; do
9043 FAIL_ON_ERROR=true cleanup
9044 FAIL_ON_ERROR=true setup
9046 run_test 900 "umount should not race with any mgc requeue thread"
9048 complete $(basename $0) $SECONDS
9049 check_and_cleanup_lustre
9050 if [ "$I_MOUNTED" != "yes" ]; then
9051 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true