3 # Run select tests by setting ONLY, or as arguments to the script.
4 # Skip specific tests by setting EXCEPT.
6 # e.g. ONLY="22 23" or ONLY="`seq 32 39`" or EXCEPT="31"
10 # bug number for skipped test: 13297 2108 9789 3637 9789 3561 12622 5188
11 ALWAYS_EXCEPT=" 27u 42a 42b 42c 42d 45 51d 68b $SANITY_EXCEPT"
12 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
14 # Tests that fail on uml
15 CPU=`awk '/model/ {print $4}' /proc/cpuinfo`
16 # buffer i/o errs sock spc runas
17 [ "$CPU" = "UML" ] && EXCEPT="$EXCEPT 27m 27n 27o 27p 27q 27r 31d 54a 64b 99a 99b 99c 99d 99e 99f 101a"
20 2.4*) FSTYPE=${FSTYPE:-ext3} ;;
21 2.6*) FSTYPE=${FSTYPE:-ldiskfs} ;;
22 *) error "unsupported kernel" ;;
25 SRCDIR=$(cd $(dirname $0); echo $PWD)
26 export PATH=$PATH:/sbin
30 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
31 CREATETEST=${CREATETEST:-createtest}
33 LFIND=${LFIND:-"$LFS find"}
34 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
36 MCREATE=${MCREATE:-mcreate}
37 OPENFILE=${OPENFILE:-openfile}
38 OPENUNLINK=${OPENUNLINK:-openunlink}
39 export MULTIOP=${MULTIOP:-multiop}
40 READS=${READS:-"reads"}
41 MUNLINK=${MUNLINK:-munlink}
42 SOCKETSERVER=${SOCKETSERVER:-socketserver}
43 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
44 MEMHOG=${MEMHOG:-memhog}
45 DIRECTIO=${DIRECTIO:-directio}
46 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
47 UMOUNT=${UMOUNT:-"umount -d"}
49 CHECK_GRANT=${CHECK_GRANT:-"yes"}
50 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
52 export NAME=${NAME:-local}
59 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
60 . $LUSTRE/tests/test-framework.sh
62 . ${CONFIG:=$LUSTRE/tests/cfg/${NAME}.sh}
65 [ "$SLOW" = "no" ] && EXCEPT_SLOW="24o 24v 27m 36f 36g 36h 51b 60c 63 64b 68 71 73 77f 78 101a 103 115 120g 124b"
71 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
72 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
81 check_kernel_version() {
83 GOT_VER=$(lctl get_param -n version | awk '/kernel:/ {print $2}')
85 patchless|patchless_client) return 0;;
86 *) [ $GOT_VER -ge $WANT_VER ] && return 0 ;;
88 log "test needs at least kernel version $WANT_VER, running $GOT_VER"
92 if [ "$ONLY" == "cleanup" ]; then
97 check_and_setup_lustre
102 MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid | \
103 awk '{gsub(/_UUID/,""); print $1}' | head -1)
104 LOVNAME=$($LCTL get_param -n llite.*.lov.common_name | tail -n 1)
105 OSTCOUNT=$($LCTL get_param -n lov.$LOVNAME.numobd)
106 STRIPECOUNT=$($LCTL get_param -n lov.$LOVNAME.stripecount)
107 STRIPESIZE=$($LCTL get_param -n lov.$LOVNAME.stripesize)
108 ORIGFREE=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
109 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
111 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
112 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
113 rm -rf $DIR/[Rdfs][0-9]*
115 # $RUNAS_ID may get set incorrectly somewhere else
116 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
118 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
122 if [ "${ONLY}" = "MOUNT" ] ; then
123 echo "Lustre is up, please go on"
127 echo "preparing for tests involving mounts"
128 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
130 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
131 echo # add a newline after mke2fs.
135 OLDDEBUG="`lctl get_param -n debug 2> /dev/null`"
136 lctl set_param debug=-1 2> /dev/null || true
139 $CHECKSTAT -t file $DIR/$tfile || error
141 $CHECKSTAT -a $DIR/$tfile || error
143 run_test 0 "touch .../$tfile ; rm .../$tfile ====================="
146 chmod 0755 $DIR || error
147 $CHECKSTAT -p 0755 $DIR || error
149 run_test 0b "chmod 0755 $DIR ============================="
152 $LCTL get_param mdc.*.import | grep "state: FULL" || error "import not FULL"
153 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" || error "bad target"
155 run_test 0c "check import proc ============================="
160 mkdir $DIR/d1/d2 && error "we expect EEXIST, but not returned"
161 $CHECKSTAT -t dir $DIR/d1/d2 || error
163 run_test 1a "mkdir .../d1; mkdir .../d1/d2 ====================="
168 $CHECKSTAT -a $DIR/d1 || error
170 run_test 1b "rmdir .../d1/d2; rmdir .../d1 ====================="
175 $CHECKSTAT -t file $DIR/d2/f || error
177 run_test 2a "mkdir .../d2; touch .../d2/f ======================"
181 $CHECKSTAT -a $DIR/d2 || error
183 run_test 2b "rm -r .../d2; checkstat .../d2/f ======================"
187 $CHECKSTAT -t dir $DIR/d3 || error
189 run_test 3a "mkdir .../d3 ======================================"
192 if [ ! -d $DIR/d3 ]; then
196 $CHECKSTAT -t file $DIR/d3/f || error
198 run_test 3b "touch .../d3/f ===================================="
202 $CHECKSTAT -a $DIR/d3 || error
204 run_test 3c "rm -r .../d3 ======================================"
208 $CHECKSTAT -t dir $DIR/d4 || error
210 run_test 4a "mkdir .../d4 ======================================"
213 if [ ! -d $DIR/d4 ]; then
217 $CHECKSTAT -t dir $DIR/d4/d2 || error
219 run_test 4b "mkdir .../d4/d2 ==================================="
224 chmod 0707 $DIR/d5/d2
225 $CHECKSTAT -t dir -p 0707 $DIR/d5/d2 || error
227 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2 ============"
231 chmod 0666 $DIR/f6a || error
232 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/f6a || error
234 run_test 6a "touch .../f6a; chmod .../f6a ======================"
237 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
238 if [ ! -f $DIR/f6a ]; then
242 $RUNAS chmod 0444 $DIR/f6a && error
243 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/f6a || error
245 run_test 6b "$RUNAS chmod .../f6a (should return error) =="
248 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
250 chown $RUNAS_ID $DIR/f6c || error
251 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/f6c || error
253 run_test 6c "touch .../f6c; chown .../f6c ======================"
256 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
257 if [ ! -f $DIR/f6c ]; then
259 chown $RUNAS_ID $DIR/f6c
261 $RUNAS chown $UID $DIR/f6c && error
262 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/f6c || error
264 run_test 6d "$RUNAS chown .../f6c (should return error) =="
267 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
269 chgrp $RUNAS_ID $DIR/f6e || error
270 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/f6e || error
272 run_test 6e "touch .../f6e; chgrp .../f6e ======================"
275 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
276 if [ ! -f $DIR/f6e ]; then
278 chgrp $RUNAS_ID $DIR/f6e
280 $RUNAS chgrp $UID $DIR/f6e && error
281 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/f6e || error
283 run_test 6f "$RUNAS chgrp .../f6e (should return error) =="
286 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
287 mkdir $DIR/d6g || error
288 chmod 777 $DIR/d6g || error
289 $RUNAS mkdir $DIR/d6g/d || error
290 chmod g+s $DIR/d6g/d || error
291 mkdir $DIR/d6g/d/subdir
292 $CHECKSTAT -g \#$RUNAS_GID $DIR/d6g/d/subdir || error
294 run_test 6g "Is new dir in sgid dir inheriting group?"
296 test_6h() { # bug 7331
297 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
298 touch $DIR/f6h || error "touch failed"
299 chown $RUNAS_ID:$RUNAS_GID $DIR/f6h || error "initial chown failed"
300 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/f6h && error "chown worked"
301 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/f6h || error
303 run_test 6h "$RUNAS chown RUNAS_ID.0 .../f6h (should return error)"
309 $CHECKSTAT -t file -p 0666 $DIR/d7/f || error
311 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
314 if [ ! -d $DIR/d7 ]; then
318 echo -n foo > $DIR/d7/f2
319 [ "`cat $DIR/d7/f2`" = "foo" ] || error
320 $CHECKSTAT -t file -s 3 $DIR/d7/f2 || error
322 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
328 $CHECKSTAT -t file -p 0666 $DIR/d8/f || error
330 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
336 $CHECKSTAT -t dir $DIR/d9/d2/d3 || error
338 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
344 $CHECKSTAT -t file $DIR/d10/d2/f || error
346 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
351 chmod 0666 $DIR/d11/d2
352 chmod 0705 $DIR/d11/d2
353 $CHECKSTAT -t dir -p 0705 $DIR/d11/d2 || error
355 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
360 chmod 0666 $DIR/d12/f
361 chmod 0654 $DIR/d12/f
362 $CHECKSTAT -t file -p 0654 $DIR/d12/f || error
364 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
368 dd if=/dev/zero of=$DIR/d13/f count=10
370 $CHECKSTAT -t file -s 0 $DIR/d13/f || error
372 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
378 $CHECKSTAT -a $DIR/d14/f || error
380 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
385 mv $DIR/d15/f $DIR/d15/f2
386 $CHECKSTAT -t file $DIR/d15/f2 || error
388 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
394 $CHECKSTAT -a $DIR/d16/f || error
396 run_test 16 "touch .../d16/f; rm -rf .../d16/f ================="
401 ln -s $DIR/d17/f $DIR/d17/l-exist
403 $CHECKSTAT -l $DIR/d17/f $DIR/d17/l-exist || error
404 $CHECKSTAT -f -t f $DIR/d17/l-exist || error
405 rm -f $DIR/d17/l-exist
406 $CHECKSTAT -a $DIR/d17/l-exist || error
408 run_test 17a "symlinks: create, remove (real) =================="
412 ln -s no-such-file $DIR/d17/l-dangle
414 $CHECKSTAT -l no-such-file $DIR/d17/l-dangle || error
415 $CHECKSTAT -fa $DIR/d17/l-dangle || error
416 rm -f $DIR/d17/l-dangle
417 $CHECKSTAT -a $DIR/d17/l-dangle || error
419 run_test 17b "symlinks: create, remove (dangling) =============="
421 test_17c() { # bug 3440 - don't save failed open RPC for replay
423 ln -s foo $DIR/d17/f17c
424 cat $DIR/d17/f17c && error "opened non-existent symlink" || true
426 run_test 17c "symlinks: open dangling (should return error) ===="
430 ln -s foo $DIR/d17/f17d
431 touch $DIR/d17/f17d || error "creating to new symlink"
433 run_test 17d "symlinks: create dangling ========================"
437 local foo=$DIR/$tdir/$tfile
438 ln -s $foo $foo || error "create symlink failed"
439 ls -l $foo || error "ls -l failed"
440 ls $foo && error "ls not failed" || true
442 run_test 17e "symlinks: create recursive symlink (should return error) ===="
446 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/d17f/111
447 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/d17f/222
448 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/d17f/333
449 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/d17f/444
450 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/d17f/555
451 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890/aaaaaaaaaa/bbbbbbbbbb/cccccccccc/dddddddddd/eeeeeeeeee/ffffffffff/ $DIR/d17f/666
454 run_test 17f "symlinks: long and very long symlink name ========================"
458 LONGSYMLINK="$(dd if=/dev/zero bs=4095 count=1 | tr '\0' 'x')"
459 ln -s $LONGSYMLINK $DIR/$tdir/$tfile
462 run_test 17g "symlinks: really long symlink name ==============================="
464 test_17h() { #bug 17378
465 remote_mds_nodsh && skip "remote MDS with nodsh" && return
467 $SETSTRIPE -c -1 $DIR/$tdir
468 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
469 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000141
470 touch $DIR/$tdir/$tfile || true
472 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
474 test_17i() { #bug 20018
475 remote_mds_nodsh && skip "remote MDS with nodsh" && return
477 local foo=$DIR/$tdir/$tfile
478 ln -s $foo $foo || error "create symlink failed"
479 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
480 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000143
481 ls -l $foo && error "error not detected"
484 run_test 17i "don't panic on short symlink"
486 test_17k() { #bug 22301
487 rsync --help | grep -q xattr ||
488 skip_env "$(rsync --version| head -1) does not support xattrs"
489 mkdir -p $DIR/{$tdir,$tdir.new}
490 touch $DIR/$tdir/$tfile
491 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
492 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
493 error "rsync failed with xattrs enabled"
495 run_test 17k "symlinks: rsync with xattrs enabled ========================="
501 run_test 18 "touch .../f ; ls ... =============================="
507 $CHECKSTAT -a $DIR/f19 || error
509 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
512 ls -l $DIR/f19 && error || true
514 run_test 19b "ls -l .../f19 (should return error) =============="
517 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
518 $RUNAS touch $DIR/f19 && error || true
520 run_test 19c "$RUNAS touch .../f19 (should return error) =="
523 cat $DIR/f19 && error || true
525 run_test 19d "cat .../f19 (should return error) =============="
537 $CHECKSTAT -a $DIR/f || error
539 run_test 20 "touch .../f ; ls -l ... ==========================="
543 [ -f $DIR/d21/dangle ] && rm -f $DIR/d21/dangle
544 ln -s dangle $DIR/d21/link
545 echo foo >> $DIR/d21/link
547 $CHECKSTAT -t link $DIR/d21/link || error
548 $CHECKSTAT -f -t file $DIR/d21/link || error
550 run_test 21 "write to dangling link ============================"
555 chown $RUNAS_ID:$RUNAS_GID $WDIR
556 (cd $WDIR || error "cd $WDIR failed";
557 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
559 ls -lR $WDIR/etc || error "ls -lR $WDIR/etc failed"
560 $CHECKSTAT -t dir $WDIR/etc || error "checkstat -t dir failed"
561 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $WDIR/etc || error "checkstat -u failed"
563 run_test 22 "unpack tar archive as non-root user ==============="
568 local file=$DIR/$tdir/$tfile
570 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
571 openfile -f O_CREAT:O_EXCL $file &&
572 error "$file recreate succeeded" || true
574 run_test 23a "O_CREAT|O_EXCL in subdir =========================="
576 test_23b() { # bug 18988
578 local file=$DIR/$tdir/$tfile
581 echo foo > $file || error "write filed"
582 echo bar >> $file || error "append filed"
583 $CHECKSTAT -s 8 $file || error "wrong size"
586 run_test 23b "O_APPEND check =========================="
589 echo '== rename sanity =============================================='
590 echo '-- same directory rename'
593 mv $DIR/R1/f $DIR/R1/g
594 $CHECKSTAT -t file $DIR/R1/g || error
596 run_test 24a "touch .../R1/f; rename .../R1/f .../R1/g ========="
601 mv $DIR/R2/f $DIR/R2/g
602 $CHECKSTAT -a $DIR/R2/f || error
603 $CHECKSTAT -t file $DIR/R2/g || error
605 run_test 24b "touch .../R2/{f,g}; rename .../R2/f .../R2/g ====="
610 mv $DIR/R3/f $DIR/R3/g
611 $CHECKSTAT -a $DIR/R3/f || error
612 $CHECKSTAT -t dir $DIR/R3/g || error
614 run_test 24c "mkdir .../R3/f; rename .../R3/f .../R3/g ========="
619 mrename $DIR/R4/f $DIR/R4/g
620 $CHECKSTAT -a $DIR/R4/f || error
621 $CHECKSTAT -t dir $DIR/R4/g || error
623 run_test 24d "mkdir .../R4/{f,g}; rename .../R4/f .../R4/g ====="
626 echo '-- cross directory renames --'
629 mv $DIR/R5a/f $DIR/R5b/g
630 $CHECKSTAT -a $DIR/R5a/f || error
631 $CHECKSTAT -t file $DIR/R5b/g || error
633 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
637 touch $DIR/R6a/f $DIR/R6b/g
638 mv $DIR/R6a/f $DIR/R6b/g
639 $CHECKSTAT -a $DIR/R6a/f || error
640 $CHECKSTAT -t file $DIR/R6b/g || error
642 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
647 mv $DIR/R7a/d $DIR/R7b/e
648 $CHECKSTAT -a $DIR/R7a/d || error
649 $CHECKSTAT -t dir $DIR/R7b/e || error
651 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
655 mkdir $DIR/R8a/d $DIR/R8b/e
656 mrename $DIR/R8a/d $DIR/R8b/e
657 $CHECKSTAT -a $DIR/R8a/d || error
658 $CHECKSTAT -t dir $DIR/R8b/e || error
660 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
663 echo "-- rename error cases"
667 mrename $DIR/R9/f $DIR/R9/a
668 $CHECKSTAT -t file $DIR/R9/f || error
669 $CHECKSTAT -t dir $DIR/R9/a || error
670 $CHECKSTAT -a $DIR/R9/a/f || error
672 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
676 mrename $DIR/R10/f $DIR/R10/g
677 $CHECKSTAT -t dir $DIR/R10 || error
678 $CHECKSTAT -a $DIR/R10/f || error
679 $CHECKSTAT -a $DIR/R10/g || error
681 run_test 24j "source does not exist ============================"
684 mkdir $DIR/R11a $DIR/R11a/d
686 mv $DIR/R11a/f $DIR/R11a/d
687 $CHECKSTAT -a $DIR/R11a/f || error
688 $CHECKSTAT -t file $DIR/R11a/d/f || error
690 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
692 # bug 2429 - rename foo foo foo creates invalid file
695 $MULTIOP $f OcNs || error
697 run_test 24l "Renaming a file to itself ========================"
701 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
702 # on ext3 this does not remove either the source or target files
703 # though the "expected" operation would be to remove the source
704 $CHECKSTAT -t file ${f} || error "${f} missing"
705 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
707 run_test 24m "Renaming a file to a hard link to itself ========="
711 # this stats the old file after it was renamed, so it should fail
715 $CHECKSTAT ${f}.rename
718 run_test 24n "Statting the old file after renaming (Posix rename 2)"
721 check_kernel_version 37 || return 0
723 rename_many -s random -v -n 10 $DIR/d24o
725 run_test 24o "rename of files during htree split ==============="
729 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
730 mrename $DIR/R12a $DIR/R12b
731 $CHECKSTAT -a $DIR/R12a || error
732 $CHECKSTAT -t dir $DIR/R12b || error
733 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
734 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
736 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
740 DIRINO=`ls -lid $DIR/R13a | awk '{ print $1 }'`
741 multiop_bg_pause $DIR/R13b D_c || return 1
744 mrename $DIR/R13a $DIR/R13b
745 $CHECKSTAT -a $DIR/R13a || error
746 $CHECKSTAT -t dir $DIR/R13b || error
747 DIRINO2=`ls -lid $DIR/R13b | awk '{ print $1 }'`
748 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
750 wait $MULTIPID || error "multiop close failed"
752 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
754 test_24r() { #bug 3789
755 mkdir $DIR/R14a $DIR/R14a/b
756 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
757 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
758 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
760 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
763 mkdir $DIR/R15a $DIR/R15a/b $DIR/R15a/b/c
764 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
765 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
766 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
768 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
770 mkdir $DIR/R16a $DIR/R16a/b $DIR/R16a/b/c
771 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
772 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
773 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
775 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
777 test_24u() { # bug12192
778 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error
779 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
781 run_test 24u "create stripe file"
789 local FREE_INODES=`lfs df -i|grep "filesystem summary" | awk '{print $5}'`
790 [ $FREE_INODES -lt $NRFILES ] && \
791 skip "not enough free inodes $FREE_INODES required $NRFILES" && \
795 createmany -m $DIR/d24v/$tfile $NRFILES
798 lctl set_param mdc.*.stats clear
800 ls $DIR/d24v >/dev/null || error "error in listing large dir"
803 # DIRENT_SIZE = 32 bytes for sizeof(struct lu_dirent) +
804 # 8 bytes for name(filename is mostly 5 in this test) +
805 # 8 bytes for luda_type
806 # take into account of overhead in lu_dirpage header and end mark in
807 # each page, plus one in RPC_NUM calculation.
809 RPC_SIZE=$(($(lctl get_param -n mdc.*.max_pages_per_rpc)*$(page_size)))
810 RPC_NUM=$(((NRFILES * DIRENT_SIZE + RPC_SIZE - 1) / RPC_SIZE + 1))
811 mds_readpage=`lctl get_param mdc.*.stats | \
812 awk '/^mds_readpage/ {print $2}'`
813 [ $mds_readpage -gt $RPC_NUM ] && \
814 error "large readdir doesn't take effect"
818 run_test 24v "list directory with large files (handle hash collision, bug: 17560)"
820 test_24w() { # bug21506
822 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
823 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
824 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
825 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
826 [ "$SZ1" = "$SZ2" ] || \
827 error "Error reading at the end of the file $tfile"
829 run_test 24w "Reading a file larger than 4Gb"
832 echo '== symlink sanity ============================================='
836 touch $DIR/s25/foo || error
838 run_test 25a "create file in symlinked directory ==============="
841 [ ! -d $DIR/d25 ] && test_25a
842 $CHECKSTAT -t file $DIR/s25/foo || error
844 run_test 25b "lookup file in symlinked directory ==============="
849 ln -s d26/d26-2 $DIR/s26
850 touch $DIR/s26/foo || error
852 run_test 26a "multiple component symlink ======================="
855 mkdir -p $DIR/d26b/d26-2
856 ln -s d26b/d26-2/foo $DIR/s26-2
857 touch $DIR/s26-2 || error
859 run_test 26b "multiple component symlink at end of lookup ======"
864 ln -s d26.2 $DIR/s26.2-1
865 ln -s s26.2-1 $DIR/s26.2-2
866 ln -s s26.2-2 $DIR/s26.2-3
867 chmod 0666 $DIR/s26.2-3/foo
869 run_test 26c "chain of symlinks ================================"
871 # recursive symlinks (bug 439)
873 ln -s d26-3/foo $DIR/d26-3
875 run_test 26d "create multiple component recursive symlink ======"
878 [ ! -h $DIR/d26-3 ] && test_26d
881 run_test 26e "unlink multiple component recursive symlink ======"
883 # recursive symlinks (bug 7022)
886 mkdir $DIR/$tdir/$tfile || error "mkdir $DIR/$tdir/$tfile failed"
887 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
888 mkdir -p lndir/bar1 || error "mkdir lndir/bar1 failed"
889 mkdir $tfile || error "mkdir $tfile failed"
890 cd $tfile || error "cd $tfile failed"
891 ln -s .. dotdot || error "ln dotdot failed"
892 ln -s dotdot/lndir lndir || error "ln lndir failed"
893 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
894 output=`ls $tfile/$tfile/lndir/bar1`
895 [ "$output" = bar1 ] && error "unexpected output"
896 rm -r $tfile || error "rm $tfile failed"
897 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
899 run_test 26f "rm -r of a directory which has recursive symlink ="
902 echo '== stripe sanity =============================================='
903 mkdir -p $DIR/d27 || error "mkdir failed"
905 $SETSTRIPE -c 1 $DIR/d27/f0 || error "setstripe failed"
906 $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
908 log "== test_27a: write to one stripe file ========================="
909 cp /etc/hosts $DIR/d27/f0 || error
911 run_test 27a "one stripe file =================================="
914 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
916 $SETSTRIPE -c 2 $DIR/d27/f01 || error "setstripe failed"
917 $GETSTRIPE -c $DIR/d27/f01
918 [ $($GETSTRIPE -c $DIR/d27/f01) -eq 2 ] ||
919 error "two-stripe file doesn't have two stripes"
921 run_test 27b "create two stripe file"
924 [ -f $DIR/d27/f01 ] || skip "test_27b not run" && return
926 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
928 run_test 27c "write to two stripe file"
932 $SETSTRIPE -c 0 -i -1 -S 0 $DIR/d27/fdef || error "setstripe failed"
933 $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
934 dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
936 run_test 27d "create file with default settings ================"
940 $SETSTRIPE -c 2 $DIR/d27/f12 || error "setstripe failed"
941 $SETSTRIPE -c 2 $DIR/d27/f12 && error "setstripe succeeded twice"
942 $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
944 run_test 27e "setstripe existing file (should return error) ======"
948 $SETSTRIPE -S 100 -i 0 -c 1 $DIR/d27/fbad && error "setstripe failed"
949 dd if=/dev/zero of=$DIR/d27/f12 bs=4k count=4 || error "dd failed"
950 $GETSTRIPE $DIR/d27/fbad || error "$GETSTRIPE failed"
952 run_test 27f "setstripe with bad stripe size (should return error)"
956 $MCREATE $DIR/d27/fnone || error "mcreate failed"
957 $GETSTRIPE $DIR/d27/fnone 2>&1 | grep "no stripe info" ||
958 error "$DIR/d27/fnone has object"
960 run_test 27g "$GETSTRIPE with no objects"
963 touch $DIR/d27/fsome || error "touch failed"
964 [ $($GETSTRIPE -c $DIR/d27/fsome) -gt 0 ] || error "missing objects"
966 run_test 27i "$GETSTRIPE with some objects"
970 $SETSTRIPE -i $OSTCOUNT $DIR/d27/f27j && error "setstripe failed"||true
972 run_test 27j "setstripe with bad stripe offset (should return error)"
974 test_27k() { # bug 2844
977 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
978 [ ! -d $DIR/d27 ] && mkdir -p $DIR/d27
979 $SETSTRIPE -S 67108864 $FILE || error "setstripe failed"
980 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
981 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
982 dd if=/dev/zero of=$FILE bs=4k count=1
983 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
984 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
986 run_test 27k "limit i_blksize for broken user apps ============="
990 mcreate $DIR/f27l || error "creating file"
991 $RUNAS $SETSTRIPE -c 1 $DIR/f27l && \
992 error "setstripe should have failed" || true
994 run_test 27l "check setstripe permissions (should return error)"
997 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
998 if [ $ORIGFREE -gt $MAXFREE ]; then
999 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1003 $SETSTRIPE -i 0 -c 1 $DIR/d27/f27m_1
1004 dd if=/dev/zero of=$DIR/d27/f27m_1 bs=1024 count=$MAXFREE &&
1005 error "dd should fill OST0"
1007 while $SETSTRIPE -i 0 -c 1 $DIR/d27/f27m_$i; do
1009 [ $i -gt 256 ] && break
1012 touch $DIR/d27/f27m_$i
1013 [ `$GETSTRIPE $DIR/d27/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] && \
1014 error "OST0 was full but new created file still use it"
1016 touch $DIR/d27/f27m_$i
1017 [ `$GETSTRIPE $DIR/d27/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] && \
1018 error "OST0 was full but new created file still use it"
1022 run_test 27m "create file while OST0 was full =================="
1025 local DELAY=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage | head -n 1 | awk '{print $1 * 2}')
1029 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1030 # if the OST isn't full anymore.
1032 local OSTIDX=${1:-""}
1034 local list=$(comma_list $(osts_nodes))
1035 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1037 do_nodes $list lctl set_param fail_loc=0
1041 exhaust_precreations() {
1044 local FAILIDX=${3:-$OSTIDX}
1047 local MDSIDX=$(get_mds_dir "$DIR/$tdir")
1048 echo OSTIDX=$OSTIDX MDSIDX=$MDSIDX
1050 local OST=$(ostname_from_index $OSTIDX)
1051 local MDT_INDEX=$(lfs df | grep "\[MDT:$((MDSIDX - 1))\]" | awk '{print $1}' | \
1052 sed -e 's/_UUID$//;s/^.*-//')
1055 local mdtosc_proc1=$(get_mdtosc_proc_path mds${MDSIDX} $OST)
1056 local last_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1057 osc.$mdtosc_proc1.prealloc_last_id)
1058 local next_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1059 osc.$mdtosc_proc1.prealloc_next_id)
1061 local mdtosc_proc2=$(get_mdtosc_proc_path mds${MDSIDX})
1062 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1064 mkdir -p $DIR/$tdir/${OST}
1065 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1066 #define OBD_FAIL_OST_ENOSPC 0x215
1067 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=$FAILIDX
1068 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x215
1069 echo "Creating to objid $last_id on ost $OST..."
1070 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1071 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1072 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=$FAILLOC
1076 exhaust_all_precreations() {
1078 for (( i=0; i < OSTCOUNT; i++ )) ; do
1079 exhaust_precreations $i $1 -1
1084 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1085 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1086 remote_ost_nodsh && skip "remote OST with nodsh" && return
1089 rm -f $DIR/$tdir/$tfile
1090 exhaust_precreations 0 0x80000215
1091 $SETSTRIPE -c -1 $DIR/$tdir
1092 touch $DIR/$tdir/$tfile || error
1093 $GETSTRIPE $DIR/$tdir/$tfile
1096 run_test 27n "create file with some full OSTs =================="
1099 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1100 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1101 remote_ost_nodsh && skip "remote OST with nodsh" && return
1104 rm -f $DIR/$tdir/$tfile
1105 exhaust_all_precreations 0x215
1107 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1112 run_test 27o "create file with all full OSTs (should error) ===="
1115 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1116 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1117 remote_ost_nodsh && skip "remote OST with nodsh" && return
1120 rm -f $DIR/$tdir/$tfile
1123 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1124 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1125 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1127 exhaust_precreations 0 0x80000215
1128 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1129 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1130 $GETSTRIPE $DIR/$tdir/$tfile
1134 run_test 27p "append to a truncated file with some full OSTs ==="
1137 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1138 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1139 remote_ost_nodsh && skip "remote OST with nodsh" && return
1142 rm -f $DIR/$tdir/$tfile
1145 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1146 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||error "truncate $DIR/$tdir/$tfile failed"
1147 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1149 exhaust_all_precreations 0x215
1151 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1152 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1156 run_test 27q "append to truncated file with all OSTs full (should error) ==="
1159 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1160 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1161 remote_ost_nodsh && skip "remote OST with nodsh" && return
1164 rm -f $DIR/$tdir/$tfile
1165 exhaust_precreations 0 0x80000215
1167 $SETSTRIPE -i 0 -c 2 $DIR/$tdir/$tfile # && error
1171 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1173 test_27s() { # bug 10725
1175 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1176 local stripe_count=0
1177 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1178 $SETSTRIPE -S $stripe_size -c $stripe_count $DIR/$tdir &&
1179 error "stripe width >= 2^32 succeeded" || true
1182 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1184 test_27t() { # bug 10864
1189 $WLFS getstripe $tfile
1192 run_test 27t "check that utils parse path correctly"
1194 test_27u() { # bug 4900
1195 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1196 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1198 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1199 do_facet $SINGLEMDS lctl set_param fail_loc=0x139
1201 createmany -o $DIR/$tdir/t- 1000
1202 do_facet $SINGLEMDS lctl set_param fail_loc=0
1204 TLOG=$DIR/$tfile.getstripe
1205 $GETSTRIPE $DIR/$tdir > $TLOG
1206 OBJS=`awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj;}' $TLOG`
1207 unlinkmany $DIR/$tdir/t- 1000
1208 [ $OBJS -gt 0 ] && \
1209 error "$OBJS objects created on OST-0. See $TLOG" || pass
1211 run_test 27u "skip object creation on OSC w/o objects =========="
1213 test_27v() { # bug 4900
1214 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1215 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1216 remote_ost_nodsh && skip "remote OST with nodsh" && return
1218 exhaust_all_precreations 0x215
1222 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1224 touch $DIR/$tdir/$tfile
1225 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1227 for (( i=1; i < OSTCOUNT; i++ )); do
1228 do_facet ost$i lctl set_param fail_loc=0x705
1230 local START=`date +%s`
1231 createmany -o $DIR/$tdir/$tfile 32
1233 local FINISH=`date +%s`
1234 local TIMEOUT=`lctl get_param -n timeout`
1235 local PROCESS=$((FINISH - START))
1236 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1237 error "$FINISH - $START >= $TIMEOUT / 2"
1238 sleep $((TIMEOUT / 2 - PROCESS))
1241 run_test 27v "skip object creation on slow OST ================="
1243 test_27w() { # bug 10997
1244 mkdir -p $DIR/$tdir || error "mkdir failed"
1245 $SETSTRIPE -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1246 [ $($GETSTRIPE -S $DIR/$tdir/f0) -ne 65536 ] &&
1247 error "stripe size $size != 65536" || true
1248 [ $($GETSTRIPE -d $DIR/$tdir | grep -c "stripe_count") -ne 1 ] &&
1249 error "$GETSTRIPE -d $DIR/$tdir failed" || true
1251 run_test 27w "check $SETSTRIPE -S option"
1254 [ "$OSTCOUNT" -lt "2" ] &&
1255 skip_env "skipping multiple stripe count/offset test" && return
1257 mkdir -p $DIR/$tdir || error "mkdir failed"
1258 for i in $(seq 1 $OSTCOUNT); do
1260 $SETSTRIPE -c $i -i $offset $DIR/$tdir/f$i ||
1261 error "setstripe -c $i -i $offset failed"
1262 count=$($GETSTRIPE -c $DIR/$tdir/f$i)
1263 index=$($GETSTRIPE -i $DIR/$tdir/f$i)
1264 [ $count -ne $i ] && error "stripe count $count != $i" || true
1265 [ $index -ne $offset ] &&
1266 error "stripe offset $index != $offset" || true
1269 run_test 27wa "check $SETSTRIPE -c -i options"
1272 remote_ost_nodsh && skip "remote OST with nodsh" && return
1273 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs" && return
1274 OFFSET=$(($OSTCOUNT - 1))
1276 local OST=$(ostname_from_index $OSTIDX)
1279 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe per file
1280 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1282 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1283 for i in `seq 0 $OFFSET`; do
1284 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}' | grep -w "$OSTIDX"` ] &&
1285 error "OST0 was degraded but new created file still use it"
1287 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1289 run_test 27x "create files while OST0 is degraded"
1292 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1293 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1294 remote_ost_nodsh && skip "remote OST with nodsh" && return
1296 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1297 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1298 osc.$mdtosc.prealloc_last_id)
1299 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1300 osc.$mdtosc.prealloc_next_id)
1301 local fcount=$((last_id - next_id))
1302 [ $fcount -eq 0 ] && skip "not enough space on OST0" && return
1303 [ $fcount -gt $OSTCOUNT ] && fcount=$OSTCOUNT
1305 MDS_OSCS=`do_facet $SINGLEMDS lctl dl | awk '/[oO][sS][cC].*md[ts]/ { print $4 }'`
1306 OFFSET=$(($OSTCOUNT-1))
1308 for OSC in $MDS_OSCS; do
1309 if [ $OST == -1 ]; then {
1310 OST=`osc_to_ost $OSC`
1312 echo $OSC "is Deactivate:"
1313 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1317 OSTIDX=$(index_from_ostuuid $OST)
1319 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1321 do_facet ost$((OSTIDX+1)) lctl set_param -n obdfilter.$OST.degraded 1
1323 createmany -o $DIR/$tdir/$tfile $fcount
1324 do_facet ost$((OSTIDX+1)) lctl set_param -n obdfilter.$OST.degraded 0
1326 for i in `seq 0 $OFFSET`; do
1327 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "$OSTIDX"` ] || \
1328 error "files created on deactivated OSTs instead of degraded OST"
1330 for OSC in $MDS_OSCS; do
1331 [ `osc_to_ost $OSC` != $OST ] && {
1332 echo $OSC "is activate"
1333 do_facet $SINGLEMDS lctl --device %$OSC activate
1337 run_test 27y "create files while OST0 is degraded and the rest inactive"
1343 lmm_count=$($GETSTRIPE -c $1)
1344 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1345 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1347 local old_ifs="$IFS"
1349 fid=($($LFS path2fid $1))
1352 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1353 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1355 # compare lmm_seq and lu_fid->f_seq
1356 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1357 # compare lmm_object_id and lu_fid->oid
1358 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1360 [ "$FSTYPE" != "ldiskfs" ] &&
1361 skip "cannot check filter fid FSTYPE=$FSTYPE" && return 0
1363 # check the trusted.fid attribute of the OST objects of the file
1364 local have_obdidx=false
1366 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1367 # skip lines up to and including "obdidx"
1368 [ -z "$obdidx" ] && break
1369 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1370 $have_obdidx || continue
1372 local ost=$((obdidx + 1))
1373 local dev=$(ostdevname $ost)
1375 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1377 #don't unmount/remount the OSTs if we don't need to do that
1378 #local dir=$(facet_mntpt ost$ost)
1380 #do_facet ost$dev mount -t $FSTYPE $dev $dir $OST_MOUNT_OPTS ||
1381 # { error "mounting $dev as $FSTYPE failed"; return 3; }
1382 #local obj_file=$(do_facet ost$ost find $dir/O/$seq -name $oid)
1383 #local ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID $obj_file)
1385 local obj_file="O/$seq/d$((oid %32))/$oid"
1386 local ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
1387 $dev 2>/dev/null" | grep "parent=")
1389 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
1391 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
1393 #do_facet ost$ost umount -d $dir
1394 #start ost$ost $dev $OST_MOUNT_OPTS
1396 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
1397 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
1398 local ff_parent=$(echo $ff|sed -e 's/.*parent=.//')
1399 local ff_pseq=$(echo $ff_parent | cut -d: -f1)
1400 local ff_poid=$(echo $ff_parent | cut -d: -f2)
1401 local ff_pstripe=$(echo $ff_parent | sed -e 's/.*stripe=//')
1403 # compare lmm_seq and filter_fid->ff_parent.f_seq
1404 [ $ff_pseq = $lmm_seq ] ||
1405 error "FF parent SEQ $ff_pseq != $lmm_seq"
1406 # compare lmm_object_id and filter_fid->ff_parent.f_oid
1407 [ $ff_poid = $lmm_oid ] ||
1408 error "FF parent OID $ff_poid != $lmm_oid"
1409 [ $ff_pstripe = $stripe_nr ] ||
1410 error "FF stripe $ff_pstripe != $stripe_nr"
1412 stripe_nr=$((stripe_nr + 1))
1417 remote_ost_nodsh && skip "remote OST with nodsh" && return
1420 $SETSTRIPE -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
1421 { error "setstripe -c -1 failed"; return 1; }
1422 # We need to send a write to every object to get parent FID info set.
1423 # This _should_ also work for setattr, but does not currently.
1424 # touch $DIR/$tdir/$tfile-1 ||
1425 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
1426 { error "dd $tfile-1 failed"; return 2; }
1427 $SETSTRIPE -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
1428 { error "setstripe -c -1 failed"; return 3; }
1429 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
1430 { error "dd $tfile-2 failed"; return 4; }
1432 # make sure write RPCs have been sent to OSTs
1435 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
1436 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
1438 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
1440 test_27A() { # b=19102
1441 local restore_size=$($GETSTRIPE -S $MOUNT)
1442 local restore_count=$($GETSTRIPE -c $MOUNT)
1443 local restore_offset=$($GETSTRIPE -i $MOUNT)
1444 $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
1445 local default_size=$($GETSTRIPE -S $MOUNT)
1446 local default_count=$($GETSTRIPE -c $MOUNT)
1447 local default_offset=$($GETSTRIPE -i $MOUNT)
1448 local dsize=$((1024 * 1024))
1449 [ $default_size -eq $dsize ] ||
1450 error "stripe size $default_size != $dsize"
1451 [ $default_count -eq 1 ] || error "stripe count $default_count != 1"
1452 [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
1453 $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
1455 run_test 27A "check filesystem-wide default LOV EA values"
1457 # createtest also checks that device nodes are created and
1458 # then visible correctly (#2091)
1459 test_28() { # bug 2091
1461 $CREATETEST $DIR/d28/ct || error
1463 run_test 28 "create/mknod/mkdir with bad file types ============"
1466 cancel_lru_locks mdc
1472 declare -i LOCKCOUNTORIG=0
1473 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1474 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
1476 [ $LOCKCOUNTORIG -eq 0 ] && echo "No mdc lock count" && return 1
1478 declare -i LOCKUNUSEDCOUNTORIG=0
1479 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1480 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
1487 declare -i LOCKCOUNTCURRENT=0
1488 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1489 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
1492 declare -i LOCKUNUSEDCOUNTCURRENT=0
1493 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1494 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
1497 if [ "$LOCKCOUNTCURRENT" -gt "$LOCKCOUNTORIG" ]; then
1498 lctl set_param -n ldlm.dump_namespaces ""
1499 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
1500 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1501 log "dumped log to $TMP/test_29.dk (bug 5793)"
1504 if [ "$LOCKUNUSEDCOUNTCURRENT" -gt "$LOCKUNUSEDCOUNTORIG" ]; then
1505 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
1506 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1507 log "dumped log to $TMP/test_29.dk (bug 5793)"
1511 run_test 29 "IT_GETATTR regression ============================"
1513 test_30a() { # was test_30
1514 cp `which ls` $DIR || cp /bin/ls $DIR
1518 run_test 30a "execute binary from Lustre (execve) =============="
1521 cp `which ls` $DIR || cp /bin/ls $DIR
1523 $RUNAS $DIR/ls / || error
1526 run_test 30b "execute binary from Lustre as non-root ==========="
1528 test_30c() { # b=22376
1529 cp `which ls` $DIR || cp /bin/ls $DIR
1531 cancel_lru_locks mdc
1532 cancel_lru_locks osc
1533 $RUNAS $DIR/ls / || error
1536 run_test 30c "execute binary from Lustre without read perms ===="
1539 $OPENUNLINK $DIR/f31 $DIR/f31 || error
1540 $CHECKSTAT -a $DIR/f31 || error
1542 run_test 31a "open-unlink file =================================="
1545 touch $DIR/f31 || error
1546 ln $DIR/f31 $DIR/f31b || error
1547 $MULTIOP $DIR/f31b Ouc || error
1548 $CHECKSTAT -t file $DIR/f31 || error
1550 run_test 31b "unlink file with multiple links while open ======="
1553 touch $DIR/f31 || error
1554 ln $DIR/f31 $DIR/f31c || error
1555 multiop_bg_pause $DIR/f31 O_uc || return 1
1557 $MULTIOP $DIR/f31c Ouc
1558 kill -USR1 $MULTIPID
1561 run_test 31c "open-unlink file with multiple links ============="
1564 opendirunlink $DIR/d31d $DIR/d31d || error
1565 $CHECKSTAT -a $DIR/d31d || error
1567 run_test 31d "remove of open directory ========================="
1569 test_31e() { # bug 2904
1570 check_kernel_version 34 || return 0
1571 openfilleddirunlink $DIR/d31e || error
1573 run_test 31e "remove of open non-empty directory ==============="
1575 test_31f() { # bug 4554
1578 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
1579 cp /etc/hosts $DIR/d31f
1581 $GETSTRIPE $DIR/d31f/hosts
1582 multiop_bg_pause $DIR/d31f D_c || return 1
1585 rm -rv $DIR/d31f || error "first of $DIR/d31f"
1587 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
1588 cp /etc/hosts $DIR/d31f
1590 $GETSTRIPE $DIR/d31f/hosts
1591 multiop_bg_pause $DIR/d31f D_c || return 1
1594 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
1595 wait $MULTIPID || error "first opendir $MULTIPID failed"
1599 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
1600 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
1603 run_test 31f "remove of open directory with open-unlink file ==="
1606 echo "-- cross directory link --"
1607 mkdir $DIR/d31g{a,b}
1609 ln $DIR/d31ga/f $DIR/d31gb/g
1610 $CHECKSTAT -t file $DIR/d31ga/f || error "source"
1611 [ `stat -c%h $DIR/d31ga/f` == '2' ] || error "source nlink"
1612 $CHECKSTAT -t file $DIR/d31gb/g || error "target"
1613 [ `stat -c%h $DIR/d31gb/g` == '2' ] || error "target nlink"
1615 run_test 31g "cross directory link==============="
1618 echo "-- cross directory link --"
1622 ln $DIR/d31h/f $DIR/d31h/dir/g
1623 $CHECKSTAT -t file $DIR/d31h/f || error "source"
1624 [ `stat -c%h $DIR/d31h/f` == '2' ] || error "source nlink"
1625 $CHECKSTAT -t file $DIR/d31h/dir/g || error "target"
1626 [ `stat -c%h $DIR/d31h/dir/g` == '2' ] || error "target nlink"
1628 run_test 31h "cross directory link under child==============="
1631 echo "-- cross directory link --"
1634 touch $DIR/d31i/dir/f
1635 ln $DIR/d31i/dir/f $DIR/d31i/g
1636 $CHECKSTAT -t file $DIR/d31i/dir/f || error "source"
1637 [ `stat -c%h $DIR/d31i/dir/f` == '2' ] || error "source nlink"
1638 $CHECKSTAT -t file $DIR/d31i/g || error "target"
1639 [ `stat -c%h $DIR/d31i/g` == '2' ] || error "target nlink"
1641 run_test 31i "cross directory link under parent==============="
1646 mkdir $DIR/d31j/dir1
1647 ln $DIR/d31j/dir1 $DIR/d31j/dir2 && error "ln for dir"
1648 link $DIR/d31j/dir1 $DIR/d31j/dir3 && error "link for dir"
1649 mlink $DIR/d31j/dir1 $DIR/d31j/dir4 && error "mlink for dir"
1650 mlink $DIR/d31j/dir1 $DIR/d31j/dir1 && error "mlink to the same dir"
1653 run_test 31j "link for directory==============="
1659 touch $DIR/d31k/exist
1660 mlink $DIR/d31k/s $DIR/d31k/t || error "mlink"
1661 mlink $DIR/d31k/s $DIR/d31k/exist && error "mlink to exist file"
1662 mlink $DIR/d31k/s $DIR/d31k/s && error "mlink to the same file"
1663 mlink $DIR/d31k/s $DIR/d31k && error "mlink to parent dir"
1664 mlink $DIR/d31k $DIR/d31k/s && error "mlink parent dir to target"
1665 mlink $DIR/d31k/not-exist $DIR/d31k/foo && error "mlink non-existing to new"
1666 mlink $DIR/d31k/not-exist $DIR/d31k/s && error "mlink non-existing to exist"
1669 run_test 31k "link to file: the same, non-existing, dir==============="
1675 touch $DIR/d31m2/exist
1676 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
1677 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
1678 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
1679 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
1680 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
1681 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
1684 run_test 31m "link to file: the same, non-existing, dir==============="
1687 echo "== more mountpoints and symlinks ================="
1688 [ -e $DIR/d32a ] && rm -fr $DIR/d32a
1689 mkdir -p $DIR/d32a/ext2-mountpoint
1690 mount -t ext2 -o loop $EXT2_DEV $DIR/d32a/ext2-mountpoint || error
1691 $CHECKSTAT -t dir $DIR/d32a/ext2-mountpoint/.. || error
1692 $UMOUNT $DIR/d32a/ext2-mountpoint || error
1694 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
1697 [ -e $DIR/d32b ] && rm -fr $DIR/d32b
1698 mkdir -p $DIR/d32b/ext2-mountpoint
1699 mount -t ext2 -o loop $EXT2_DEV $DIR/d32b/ext2-mountpoint || error
1700 ls -al $DIR/d32b/ext2-mountpoint/.. || error
1701 $UMOUNT $DIR/d32b/ext2-mountpoint || error
1703 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
1706 [ -e $DIR/d32c ] && rm -fr $DIR/d32c
1707 mkdir -p $DIR/d32c/ext2-mountpoint
1708 mount -t ext2 -o loop $EXT2_DEV $DIR/d32c/ext2-mountpoint || error
1709 mkdir -p $DIR/d32c/d2/test_dir
1710 $CHECKSTAT -t dir $DIR/d32c/ext2-mountpoint/../d2/test_dir || error
1711 $UMOUNT $DIR/d32c/ext2-mountpoint || error
1713 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
1716 [ -e $DIR/d32d ] && rm -fr $DIR/d32d
1717 mkdir -p $DIR/d32d/ext2-mountpoint
1718 mount -t ext2 -o loop $EXT2_DEV $DIR/d32d/ext2-mountpoint || error
1719 mkdir -p $DIR/d32d/d2/test_dir
1720 ls -al $DIR/d32d/ext2-mountpoint/../d2/test_dir || error
1721 $UMOUNT $DIR/d32d/ext2-mountpoint || error
1723 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
1726 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
1727 mkdir -p $DIR/d32e/tmp
1728 TMP_DIR=$DIR/d32e/tmp
1729 ln -s $DIR/d32e $TMP_DIR/symlink11
1730 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1731 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
1732 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
1734 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
1737 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
1738 mkdir -p $DIR/d32f/tmp
1739 TMP_DIR=$DIR/d32f/tmp
1740 ln -s $DIR/d32f $TMP_DIR/symlink11
1741 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1742 ls $DIR/d32f/tmp/symlink11 || error
1743 ls $DIR/d32f/symlink01 || error
1745 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
1748 TMP_DIR=$DIR/$tdir/tmp
1749 mkdir -p $TMP_DIR $DIR/${tdir}2
1750 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
1751 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1752 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
1753 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
1754 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
1755 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
1757 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
1760 rm -fr $DIR/$tdir $DIR/${tdir}2
1761 TMP_DIR=$DIR/$tdir/tmp
1762 mkdir -p $TMP_DIR $DIR/${tdir}2
1763 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
1764 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1765 ls $TMP_DIR/symlink12 || error
1766 ls $DIR/$tdir/symlink02 || error
1768 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
1771 [ -e $DIR/d32i ] && rm -fr $DIR/d32i
1772 mkdir -p $DIR/d32i/ext2-mountpoint
1773 mount -t ext2 -o loop $EXT2_DEV $DIR/d32i/ext2-mountpoint || error
1774 touch $DIR/d32i/test_file
1775 $CHECKSTAT -t file $DIR/d32i/ext2-mountpoint/../test_file || error
1776 $UMOUNT $DIR/d32i/ext2-mountpoint || error
1778 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
1781 [ -e $DIR/d32j ] && rm -fr $DIR/d32j
1782 mkdir -p $DIR/d32j/ext2-mountpoint
1783 mount -t ext2 -o loop $EXT2_DEV $DIR/d32j/ext2-mountpoint || error
1784 touch $DIR/d32j/test_file
1785 cat $DIR/d32j/ext2-mountpoint/../test_file || error
1786 $UMOUNT $DIR/d32j/ext2-mountpoint || error
1788 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
1792 mkdir -p $DIR/d32k/ext2-mountpoint
1793 mount -t ext2 -o loop $EXT2_DEV $DIR/d32k/ext2-mountpoint
1794 mkdir -p $DIR/d32k/d2
1795 touch $DIR/d32k/d2/test_file || error
1796 $CHECKSTAT -t file $DIR/d32k/ext2-mountpoint/../d2/test_file || error
1797 $UMOUNT $DIR/d32k/ext2-mountpoint || error
1799 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
1803 mkdir -p $DIR/d32l/ext2-mountpoint
1804 mount -t ext2 -o loop $EXT2_DEV $DIR/d32l/ext2-mountpoint || error
1805 mkdir -p $DIR/d32l/d2
1806 touch $DIR/d32l/d2/test_file
1807 cat $DIR/d32l/ext2-mountpoint/../d2/test_file || error
1808 $UMOUNT $DIR/d32l/ext2-mountpoint || error
1810 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
1814 mkdir -p $DIR/d32m/tmp
1815 TMP_DIR=$DIR/d32m/tmp
1816 ln -s $DIR $TMP_DIR/symlink11
1817 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1818 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
1819 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
1821 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
1825 mkdir -p $DIR/d32n/tmp
1826 TMP_DIR=$DIR/d32n/tmp
1827 ln -s $DIR $TMP_DIR/symlink11
1828 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1829 ls -l $DIR/d32n/tmp/symlink11 || error
1830 ls -l $DIR/d32n/symlink01 || error
1832 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
1835 rm -fr $DIR/d32o $DIR/$tfile
1837 mkdir -p $DIR/d32o/tmp
1838 TMP_DIR=$DIR/d32o/tmp
1839 ln -s $DIR/$tfile $TMP_DIR/symlink12
1840 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1841 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
1842 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
1843 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
1844 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
1846 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
1856 mkdir -p $DIR/d32p/tmp
1858 TMP_DIR=$DIR/d32p/tmp
1860 ln -s $DIR/$tfile $TMP_DIR/symlink12
1862 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1864 cat $DIR/d32p/tmp/symlink12 || error
1866 cat $DIR/d32p/symlink02 || error
1869 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
1872 [ -e $DIR/d32q ] && rm -fr $DIR/d32q
1874 touch $DIR/d32q/under_the_mount
1875 mount -t ext2 -o loop $EXT2_DEV $DIR/d32q
1876 ls $DIR/d32q/under_the_mount && error || true
1877 $UMOUNT $DIR/d32q || error
1879 run_test 32q "stat follows mountpoints in Lustre (should return error)"
1882 [ -e $DIR/d32r ] && rm -fr $DIR/d32r
1884 touch $DIR/d32r/under_the_mount
1885 mount -t ext2 -o loop $EXT2_DEV $DIR/d32r
1886 ls $DIR/d32r | grep -q under_the_mount && error || true
1887 $UMOUNT $DIR/d32r || error
1889 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
1894 chmod 444 $DIR/$tfile
1895 chown $RUNAS_ID $DIR/$tfile
1897 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
1900 run_test 33 "write file with mode 444 (should return error) ===="
1905 chown $RUNAS_ID $DIR/d33
1906 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
1907 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
1908 error "open RDWR" || true
1910 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
1915 chown $RUNAS_ID $DIR/d33
1916 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33 && error "create" || true
1918 run_test 33b "test open file with malformed flags (No panic and return error)"
1926 remote_ost_nodsh && skip "remote OST with nodsh" && return
1930 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
1933 for ostnum in $(seq $OSTCOUNT); do
1934 # test-framework's OST numbering is one-based, while Lustre's
1936 ostname=$(printf "$FSNAME-OST%.4d" $((ostnum - 1)))
1937 # Parsing llobdstat's output sucks; we could grep the /proc
1938 # path, but that's likely to not be as portable as using the
1939 # llobdstat utility. So we parse lctl output instead.
1940 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
1941 obdfilter/$ostname/stats |
1942 awk '/^write_bytes/ {print $7}' )
1943 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
1944 if (( ${write_bytes:-0} > 0 ))
1951 $all_zeros || return 0
1954 echo foo > $DIR/d33/bar
1958 # Total up write_bytes after writing. We'd better find non-zeros.
1959 for ostnum in $(seq $OSTCOUNT); do
1960 ostname=$(printf "$FSNAME-OST%.4d" $((ostnum - 1)))
1961 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
1962 obdfilter/$ostname/stats |
1963 awk '/^write_bytes/ {print $7}' )
1964 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
1965 if (( ${write_bytes:-0} > 0 ))
1974 for ostnum in $(seq $OSTCOUNT); do
1975 ostname=$(printf "$FSNAME-OST%.4d" $((ostnum - 1)))
1976 echo "Check that write_bytes is present in obdfilter/*/stats:"
1977 do_facet ost$ostnum lctl get_param -n \
1978 obdfilter/$ostname/stats
1980 error "OST not keeping write_bytes stats (b22312)"
1983 run_test 33c "test llobdstat and write_bytes"
1985 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
1988 $MCREATE $DIR/f34 || error
1989 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
1990 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
1991 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
1992 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1994 run_test 34a "truncate file that has not been opened ==========="
1997 [ ! -f $DIR/f34 ] && test_34a
1998 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1999 $OPENFILE -f O_RDONLY $DIR/f34
2000 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2001 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2003 run_test 34b "O_RDONLY opening file doesn't create objects ====="
2006 [ ! -f $DIR/f34 ] && test_34a
2007 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2008 $OPENFILE -f O_RDWR $DIR/f34
2009 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2010 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2012 run_test 34c "O_RDWR opening file-with-size works =============="
2015 [ ! -f $DIR/f34 ] && test_34a
2016 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2017 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2020 run_test 34d "write to sparse file ============================="
2024 $MCREATE $DIR/f34e || error
2025 $TRUNCATE $DIR/f34e 1000 || error
2026 $CHECKSTAT -s 1000 $DIR/f34e || error
2027 $OPENFILE -f O_RDWR $DIR/f34e
2028 $CHECKSTAT -s 1000 $DIR/f34e || error
2030 run_test 34e "create objects, some with size and some without =="
2032 test_34f() { # bug 6242, 6243
2035 $MCREATE $DIR/f34f || error
2036 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
2037 dd if=$DIR/f34f of=$TMP/f34f
2038 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
2039 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
2040 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
2041 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
2042 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
2044 run_test 34f "read from a file with no objects until EOF ======="
2047 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
2048 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
2049 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
2050 cancel_lru_locks osc
2051 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
2052 error "wrong size after lock cancel"
2054 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
2055 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2056 error "expanding truncate failed"
2057 cancel_lru_locks osc
2058 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2059 error "wrong expanded size after lock cancel"
2061 run_test 34g "truncate long file ==============================="
2067 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
2068 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
2072 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
2073 error "Multiop blocked on ftruncate, pid=$MULTIPID"
2077 local nsz=`stat -c %s $DIR/$tfile`
2078 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
2080 run_test 34h "ftruncate file under grouplock should not block"
2083 cp /bin/sh $DIR/f35a
2085 chown $RUNAS_ID $DIR/f35a
2086 $RUNAS $DIR/f35a && error || true
2089 run_test 35a "exec file with mode 444 (should return and not leak) ====="
2093 utime $DIR/f36 || error
2095 run_test 36a "MDS utime check (mknod, utime) ==================="
2099 utime $DIR/f36 || error
2101 run_test 36b "OST utime check (open, utime) ===================="
2106 chown $RUNAS_ID $DIR/d36
2107 $RUNAS utime $DIR/d36/f36 || error
2109 run_test 36c "non-root MDS utime check (mknod, utime) =========="
2112 [ ! -d $DIR/d36 ] && test_36c
2113 echo "" > $DIR/d36/f36
2114 $RUNAS utime $DIR/d36/f36 || error
2116 run_test 36d "non-root OST utime check (open, utime) ==========="
2119 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
2121 touch $DIR/$tdir/$tfile
2122 $RUNAS utime $DIR/$tdir/$tfile && \
2123 error "utime worked, expected failure" || true
2125 run_test 36e "utime on non-owned file (should return error) ===="
2129 local LANG_SAVE=$LANG
2130 local LC_LANG_SAVE=$LC_LANG
2131 export LANG=C LC_LANG=C # for date language
2133 DATESTR="Dec 20 2000"
2135 lctl set_param fail_loc=$fl
2137 cp /etc/hosts $DIR/$tdir/$tfile
2138 sync & # write RPC generated with "current" inode timestamp, but delayed
2140 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
2141 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
2142 cancel_lru_locks osc
2143 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
2145 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
2146 echo "BEFORE: $LS_BEFORE" && \
2147 echo "AFTER : $LS_AFTER" && \
2148 echo "WANT : $DATESTR" && \
2149 error "$DIR/$tdir/$tfile timestamps changed" || true
2151 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
2155 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2156 subr_36fh "0x80000214"
2158 run_test 36f "utime on file racing with OST BRW write =========="
2161 remote_ost_nodsh && skip "remote OST with nodsh" && return
2167 fmd_max_age=$(do_facet ost1 \
2168 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
2171 fmd_before=$(do_facet ost1 \
2172 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2173 touch $DIR/$tdir/$tfile
2174 sleep $((fmd_max_age + 12))
2175 fmd_after=$(do_facet ost1 \
2176 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2178 echo "fmd_before: $fmd_before"
2179 echo "fmd_after: $fmd_after"
2180 [ "$fmd_after" -gt "$fmd_before" ] && \
2181 echo "AFTER: $fmd_after > BEFORE: $fmd_before" && \
2182 error "fmd didn't expire after ping" || true
2184 run_test 36g "filter mod data cache expiry ====================="
2187 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
2188 subr_36fh "0x80000227"
2190 run_test 36h "utime on file racing with OST BRW write =========="
2194 echo f > $DIR/$tdir/fbugfile
2195 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2196 ls $DIR/$tdir | grep "\<fbugfile\>" && error
2197 $UMOUNT $DIR/$tdir || error
2198 rm -f $DIR/$tdir/fbugfile || error
2200 run_test 37 "ls a mounted file system to check old content ====="
2203 local file=$DIR/$tfile
2205 openfile -f O_DIRECTORY $file
2208 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
2209 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
2211 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
2215 touch $DIR/${tfile}2
2216 # ls -l $DIR/$tfile $DIR/${tfile}2
2217 # ls -lu $DIR/$tfile $DIR/${tfile}2
2218 # ls -lc $DIR/$tfile $DIR/${tfile}2
2220 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
2221 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
2223 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
2225 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
2227 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
2228 error "O_TRUNC didn't change timestamps"
2231 run_test 39 "mtime changed on create ==========================="
2235 cp -p /etc/passwd $DIR/$tdir/fopen
2236 cp -p /etc/passwd $DIR/$tdir/flink
2237 cp -p /etc/passwd $DIR/$tdir/funlink
2238 cp -p /etc/passwd $DIR/$tdir/frename
2239 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
2242 echo "aaaaaa" >> $DIR/$tdir/fopen
2243 echo "aaaaaa" >> $DIR/$tdir/flink
2244 echo "aaaaaa" >> $DIR/$tdir/funlink
2245 echo "aaaaaa" >> $DIR/$tdir/frename
2247 local open_new=`stat -c %Y $DIR/$tdir/fopen`
2248 local link_new=`stat -c %Y $DIR/$tdir/flink`
2249 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
2250 local rename_new=`stat -c %Y $DIR/$tdir/frename`
2252 cat $DIR/$tdir/fopen > /dev/null
2253 ln $DIR/$tdir/flink $DIR/$tdir/flink2
2254 rm -f $DIR/$tdir/funlink2
2255 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
2257 for (( i=0; i < 2; i++ )) ; do
2258 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
2259 local link_new2=`stat -c %Y $DIR/$tdir/flink`
2260 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
2261 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
2263 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
2264 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
2265 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
2266 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
2268 cancel_lru_locks osc
2269 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2272 run_test 39b "mtime change on open, link, unlink, rename ======"
2274 # this should be set to past
2275 TEST_39_MTIME=`date -d "1 year ago" +%s`
2281 local mtime0=`stat -c %Y $DIR1/$tfile`
2283 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2284 local mtime1=`stat -c %Y $DIR1/$tfile`
2285 [ "$mtime1" = $TEST_39_MTIME ] || \
2286 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
2289 echo hello >> $DIR1/$tfile
2291 local mtime2=`stat -c %Y $DIR1/$tfile`
2292 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
2293 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
2295 mv $DIR1/$tfile $DIR1/$tfile-1
2297 for (( i=0; i < 2; i++ )) ; do
2298 local mtime3=`stat -c %Y $DIR1/$tfile-1`
2299 [ "$mtime2" = "$mtime3" ] || \
2300 error "mtime ($mtime2) changed (to $mtime3) on rename"
2302 cancel_lru_locks osc
2303 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2306 run_test 39c "mtime change on rename ==========================="
2312 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2314 for (( i=0; i < 2; i++ )) ; do
2315 local mtime=`stat -c %Y $DIR1/$tfile`
2316 [ $mtime = $TEST_39_MTIME ] || \
2317 error "mtime($mtime) is not set to $TEST_39_MTIME"
2319 cancel_lru_locks osc
2320 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2323 run_test 39d "create, utime, stat =============================="
2328 local mtime1=`stat -c %Y $DIR1/$tfile`
2330 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2332 for (( i=0; i < 2; i++ )) ; do
2333 local mtime2=`stat -c %Y $DIR1/$tfile`
2334 [ $mtime2 = $TEST_39_MTIME ] || \
2335 error "mtime($mtime2) is not set to $TEST_39_MTIME"
2337 cancel_lru_locks osc
2338 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2341 run_test 39e "create, stat, utime, stat ========================"
2346 mtime1=`stat -c %Y $DIR1/$tfile`
2349 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2351 for (( i=0; i < 2; i++ )) ; do
2352 local mtime2=`stat -c %Y $DIR1/$tfile`
2353 [ $mtime2 = $TEST_39_MTIME ] || \
2354 error "mtime($mtime2) is not set to $TEST_39_MTIME"
2356 cancel_lru_locks osc
2357 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2360 run_test 39f "create, stat, sleep, utime, stat ================="
2364 echo hello >> $DIR1/$tfile
2365 local mtime1=`stat -c %Y $DIR1/$tfile`
2368 chmod o+r $DIR1/$tfile
2370 for (( i=0; i < 2; i++ )) ; do
2371 local mtime2=`stat -c %Y $DIR1/$tfile`
2372 [ "$mtime1" = "$mtime2" ] || \
2373 error "lost mtime: $mtime2, should be $mtime1"
2375 cancel_lru_locks osc
2376 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2379 run_test 39g "write, chmod, stat ==============================="
2387 echo hello >> $DIR1/$tfile
2388 local mtime1=`stat -c %Y $DIR1/$tfile`
2390 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2392 if [ "$d1" != "$d2" ]; then
2393 echo "write and touch not within one second"
2395 for (( i=0; i < 2; i++ )) ; do
2396 local mtime2=`stat -c %Y $DIR1/$tfile`
2397 [ "$mtime2" = $TEST_39_MTIME ] || \
2398 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
2400 cancel_lru_locks osc
2401 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2405 run_test 39h "write, utime within one second, stat ============="
2411 echo hello >> $DIR1/$tfile
2412 local mtime1=`stat -c %Y $DIR1/$tfile`
2414 mv $DIR1/$tfile $DIR1/$tfile-1
2416 for (( i=0; i < 2; i++ )) ; do
2417 local mtime2=`stat -c %Y $DIR1/$tfile-1`
2419 [ "$mtime1" = "$mtime2" ] || \
2420 error "lost mtime: $mtime2, should be $mtime1"
2422 cancel_lru_locks osc
2423 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2426 run_test 39i "write, rename, stat =============================="
2430 lctl set_param debug=-1
2434 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
2436 local mtime1=`stat -c %Y $DIR1/$tfile`
2438 mv $DIR1/$tfile $DIR1/$tfile-1
2440 kill -USR1 $multipid
2441 wait $multipid || error "multiop close failed"
2443 for (( i=0; i < 2; i++ )) ; do
2444 local mtime2=`stat -c %Y $DIR1/$tfile-1`
2445 [ "$mtime1" = "$mtime2" ] || \
2446 error "mtime is lost on close: $mtime2, should be $mtime1"
2448 cancel_lru_locks osc
2449 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2453 run_test 39j "write, rename, close, stat ======================="
2459 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
2461 local mtime1=`stat -c %Y $DIR1/$tfile`
2463 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2465 kill -USR1 $multipid
2466 wait $multipid || error "multiop close failed"
2468 for (( i=0; i < 2; i++ )) ; do
2469 local mtime2=`stat -c %Y $DIR1/$tfile`
2471 [ "$mtime2" = $TEST_39_MTIME ] || \
2472 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
2474 cancel_lru_locks osc
2475 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2478 run_test 39k "write, utime, close, stat ========================"
2480 # this should be set to future
2481 TEST_39_ATIME=`date -d "1 year" +%s`
2484 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2485 local atime_diff=$(do_facet $SINGLEMDS lctl get_param -n mdd.*.atime_diff)
2489 # test setting directory atime to future
2490 touch -a -d @$TEST_39_ATIME $DIR/$tdir
2491 local atime=$(stat -c %X $DIR/$tdir)
2492 [ "$atime" = $TEST_39_ATIME ] || \
2493 error "atime is not set to future: $atime, should be $TEST_39_ATIME"
2495 # test setting directory atime from future to now
2496 local d1=$(date +%s)
2498 local d2=$(date +%s)
2500 cancel_lru_locks mdc
2501 atime=$(stat -c %X $DIR/$tdir)
2502 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
2503 error "atime is not updated from future: $atime, should be $d1<atime<$d2"
2505 do_facet $SINGLEMDS lctl set_param -n mdd.*.atime_diff=2
2508 # test setting directory atime when now > dir atime + atime_diff
2512 cancel_lru_locks mdc
2513 atime=$(stat -c %X $DIR/$tdir)
2514 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
2515 error "atime is not updated : $atime, should be $d2"
2517 do_facet $SINGLEMDS lctl set_param -n mdd.*.atime_diff=60
2520 # test not setting directory atime when now < dir atime + atime_diff
2522 cancel_lru_locks mdc
2523 atime=$(stat -c %X $DIR/$tdir)
2524 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
2525 error "atime is updated to $atime, should remain $d1<atime<$d2"
2527 do_facet $SINGLEMDS lctl set_param -n mdd.*.atime_diff=$atime_diff
2529 run_test 39l "directory atime update ==========================="
2534 local far_past_mtime=$(date -d "May 29 1953" +%s)
2535 local far_past_atime=$(date -d "Dec 17 1903" +%s)
2537 touch -m -d @$far_past_mtime $DIR1/$tfile
2538 touch -a -d @$far_past_atime $DIR1/$tfile
2540 for (( i=0; i < 2; i++ )) ; do
2541 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
2542 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
2543 error "atime or mtime set incorrectly"
2545 cancel_lru_locks osc
2546 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2549 run_test 39m "test atime and mtime before 1970"
2552 dd if=/dev/zero of=$DIR/f40 bs=4096 count=1
2553 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/f40 && error
2554 $CHECKSTAT -t file -s 4096 $DIR/f40 || error
2556 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
2560 small_write $DIR/f41 18
2562 run_test 41 "test small file write + fstat ====================="
2564 count_ost_writes() {
2565 lctl get_param -n osc.*.stats |
2566 awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }'
2573 BG_DIRTY_RATIO_SAVE=10
2574 MAX_BG_DIRTY_RATIO=25
2578 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
2579 # dirty_ratio, dirty_background_ratio
2580 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
2581 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
2582 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
2583 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
2585 # if file not here, we are a 2.4 kernel
2586 kill -CONT `pidof kupdated`
2591 # setup the trap first, so someone cannot exit the test at the
2592 # exact wrong time and mess up a machine
2593 trap start_writeback EXIT
2594 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
2595 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
2596 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
2597 sysctl -w vm.dirty_writeback_centisecs=0
2598 sysctl -w vm.dirty_writeback_centisecs=0
2599 # save and increase /proc/sys/vm/dirty_ratio
2600 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
2601 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
2602 # save and increase /proc/sys/vm/dirty_background_ratio
2603 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
2604 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
2606 # if file not here, we are a 2.4 kernel
2607 kill -STOP `pidof kupdated`
2611 # ensure that all stripes have some grant before we test client-side cache
2613 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
2614 dd if=/dev/zero of=$i bs=4k count=1
2619 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
2620 # file truncation, and file removal.
2623 cancel_lru_locks osc
2625 sync; sleep 1; sync # just to be safe
2626 BEFOREWRITES=`count_ost_writes`
2627 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
2628 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
2629 AFTERWRITES=`count_ost_writes`
2630 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
2631 error "$BEFOREWRITES < $AFTERWRITES"
2634 run_test 42a "ensure that we don't flush on close =============="
2638 cancel_lru_locks osc
2641 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
2642 BEFOREWRITES=`count_ost_writes`
2643 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
2644 AFTERWRITES=`count_ost_writes`
2645 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
2646 error "$BEFOREWRITES < $AFTERWRITES on unlink"
2648 BEFOREWRITES=`count_ost_writes`
2649 sync || error "sync: $?"
2650 AFTERWRITES=`count_ost_writes`
2651 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
2652 error "$BEFOREWRITES < $AFTERWRITES on sync"
2654 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
2658 run_test 42b "test destroy of file with cached dirty data ======"
2660 # if these tests just want to test the effect of truncation,
2661 # they have to be very careful. consider:
2662 # - the first open gets a {0,EOF}PR lock
2663 # - the first write conflicts and gets a {0, count-1}PW
2664 # - the rest of the writes are under {count,EOF}PW
2665 # - the open for truncate tries to match a {0,EOF}PR
2666 # for the filesize and cancels the PWs.
2667 # any number of fixes (don't get {0,EOF} on open, match
2668 # composite locks, do smarter file size management) fix
2669 # this, but for now we want these tests to verify that
2670 # the cancellation with truncate intent works, so we
2671 # start the file with a full-file pw lock to match against
2672 # until the truncate.
2677 cancel_lru_locks osc
2679 # prime the file with 0,EOF PW to match
2683 # now the real test..
2684 dd if=/dev/zero of=$file bs=1024 count=100
2685 BEFOREWRITES=`count_ost_writes`
2686 $TRUNCATE $file $offset
2687 cancel_lru_locks osc
2688 AFTERWRITES=`count_ost_writes`
2694 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
2695 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
2698 run_test 42c "test partial truncate of file with cached dirty data"
2702 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
2703 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
2706 run_test 42d "test complete truncate of file with cached dirty data"
2708 test_42e() { # bug22074
2709 local TDIR=$DIR/${tdir}e
2710 local pagesz=$(page_size)
2711 local pages=16 # hardcoded 16 pages, don't change it.
2712 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
2713 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
2718 $SETSTRIPE -c 1 $TDIR
2719 createmany -o $TDIR/f $files
2721 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
2723 # we assume that with $OSTCOUNT files, at least one of them will
2724 # be allocated on OST0.
2725 warmup_files=$((OSTCOUNT * max_dirty_mb))
2726 createmany -o $TDIR/w $warmup_files
2728 # write a large amount of data into one file and sync, to get good
2729 # avail_grant number from OST.
2730 for ((i=0; i<$warmup_files; i++)); do
2731 idx=$($GETSTRIPE -i $TDIR/w$i)
2732 [ $idx -ne 0 ] && continue
2733 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
2736 [ $i -gt $warmup_files ] && error "OST0 is still cold"
2738 $LCTL get_param $proc_osc0/cur_dirty_bytes
2739 $LCTL get_param $proc_osc0/cur_grant_bytes
2741 # create as much dirty pages as we can while not to trigger the actual
2742 # RPCs directly. but depends on the env, VFS may trigger flush during this
2743 # period, hopefully we are good.
2744 for ((i=0; i<$warmup_files; i++)); do
2745 idx=$($GETSTRIPE -i $TDIR/w$i)
2746 [ $idx -ne 0 ] && continue
2747 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
2749 $LCTL get_param $proc_osc0/cur_dirty_bytes
2750 $LCTL get_param $proc_osc0/cur_grant_bytes
2752 # perform the real test
2753 $LCTL set_param $proc_osc0/rpc_stats 0
2754 for ((;i<$files; i++)); do
2755 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
2756 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
2759 $LCTL get_param $proc_osc0/rpc_stats
2762 local have_ppr=false
2763 $LCTL get_param $proc_osc0/rpc_stats |
2764 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
2765 # skip lines until we are at the RPC histogram data
2766 [ "$PPR" == "pages" ] && have_ppr=true && continue
2767 $have_ppr || continue
2769 # we only want the percent stat for < 16 pages
2770 [ $(echo $PPR | tr -d ':') -ge $pages ] && break
2772 percent=$((percent + WPCT))
2773 if [ $percent -gt 15 ]; then
2774 error "less than 16-pages write RPCs" \
2781 run_test 42e "verify sub-RPC writes are not done synchronously"
2785 cp -p /bin/ls $DIR/$tdir/$tfile
2786 $MULTIOP $DIR/$tdir/$tfile Ow_c &
2788 # give multiop a chance to open
2791 $DIR/$tdir/$tfile && error || true
2794 run_test 43 "execution of file opened for write should return -ETXTBSY"
2798 cp -p `which $MULTIOP` $DIR/d43/multiop || cp -p multiop $DIR/d43/multiop
2799 MULTIOP_PROG=$DIR/d43/multiop multiop_bg_pause $TMP/test43.junk O_c || return 1
2801 $MULTIOP $DIR/d43/multiop Oc && error "expected error, got success"
2802 kill -USR1 $MULTIOP_PID || return 2
2803 wait $MULTIOP_PID || return 3
2806 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
2810 cp -p `which $MULTIOP` $DIR/d43/multiop || cp -p multiop $DIR/d43/multiop
2811 MULTIOP_PROG=$DIR/d43/multiop multiop_bg_pause $TMP/test43.junk O_c || return 1
2813 $TRUNCATE $DIR/d43/multiop 0 && error "expected error, got success"
2814 kill -USR1 $MULTIOP_PID || return 2
2815 wait $MULTIOP_PID || return 3
2818 run_test 43b "truncate of file being executed should return -ETXTBSY"
2821 local testdir="$DIR/d43c"
2824 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
2825 ( cd $testdir && md5sum -c)
2827 run_test 43c "md5sum of copy into lustre========================"
2830 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
2831 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
2832 dd if=$DIR/f1 bs=4k count=1 > /dev/null
2834 run_test 44 "zero length read from a sparse stripe ============="
2837 local nstripe=`$LCTL lov_getconfig $DIR | grep default_stripe_count: | \
2839 [ -z "$nstripe" ] && skip "can't get stripe info" && return
2840 [ "$nstripe" -gt "$OSTCOUNT" ] && skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" && return
2841 local stride=`$LCTL lov_getconfig $DIR | grep default_stripe_size: | \
2843 if [ $nstripe -eq 0 -o $nstripe -eq -1 ] ; then
2844 nstripe=`$LCTL lov_getconfig $DIR | grep obd_count: | awk '{print $2}'`
2847 OFFSETS="0 $((stride/2)) $((stride-1))"
2848 for offset in $OFFSETS ; do
2849 for i in `seq 0 $((nstripe-1))`; do
2850 local GLOBALOFFSETS=""
2851 local size=$((((i + 2 * $nstripe )*$stride + $offset))) # Bytes
2852 local myfn=$DIR/d44a-$size
2853 echo "--------writing $myfn at $size"
2854 ll_sparseness_write $myfn $size || error "ll_sparseness_write"
2855 GLOBALOFFSETS="$GLOBALOFFSETS $size"
2856 ll_sparseness_verify $myfn $GLOBALOFFSETS \
2857 || error "ll_sparseness_verify $GLOBALOFFSETS"
2859 for j in `seq 0 $((nstripe-1))`; do
2860 size=$((((j + $nstripe )*$stride + $offset))) # Bytes
2861 ll_sparseness_write $myfn $size || error "ll_sparseness_write"
2862 GLOBALOFFSETS="$GLOBALOFFSETS $size"
2864 ll_sparseness_verify $myfn $GLOBALOFFSETS \
2865 || error "ll_sparseness_verify $GLOBALOFFSETS"
2870 run_test 44a "test sparse pwrite ==============================="
2874 for d in `lctl get_param -n osc.*.cur_dirty_bytes`; do
2880 before=`dirty_osc_total`
2881 echo executing "\"$*\""
2883 after=`dirty_osc_total`
2884 echo before $before, after $after
2888 # Obtain grants from OST if it supports it
2889 echo blah > ${f}_grant
2892 do_dirty_record "echo blah > $f"
2893 [ $before -eq $after ] && error "write wasn't cached"
2894 do_dirty_record "> $f"
2895 [ $before -gt $after ] || error "truncate didn't lower dirty count"
2896 do_dirty_record "echo blah > $f"
2897 [ $before -eq $after ] && error "write wasn't cached"
2898 do_dirty_record "sync"
2899 [ $before -gt $after ] || error "writeback didn't lower dirty count"
2900 do_dirty_record "echo blah > $f"
2901 [ $before -eq $after ] && error "write wasn't cached"
2902 do_dirty_record "cancel_lru_locks osc"
2903 [ $before -gt $after ] || error "lock cancellation didn't lower dirty count"
2906 run_test 45 "osc io page accounting ============================"
2908 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
2909 # test tickles a bug where re-dirtying a page was failing to be mapped to the
2910 # objects offset and an assert hit when an rpc was built with 1023's mapped
2911 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
2916 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
2918 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
2919 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
2923 run_test 46 "dirtying a previously written page ================"
2925 # test_47 is removed "Device nodes check" is moved to test_28
2927 test_48a() { # bug 2399
2928 check_kernel_version 34 || return 0
2931 mv $DIR/d48a $DIR/d48.new || error "move directory failed"
2932 mkdir $DIR/d48a || error "recreate directory failed"
2933 touch foo || error "'touch foo' failed after recreating cwd"
2934 mkdir bar || error "'mkdir foo' failed after recreating cwd"
2935 if check_kernel_version 44; then
2936 touch .foo || error "'touch .foo' failed after recreating cwd"
2937 mkdir .bar || error "'mkdir .foo' failed after recreating cwd"
2939 ls . > /dev/null || error "'ls .' failed after recreating cwd"
2940 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
2941 cd . || error "'cd .' failed after recreating cwd"
2942 mkdir . && error "'mkdir .' worked after recreating cwd"
2943 rmdir . && error "'rmdir .' worked after recreating cwd"
2944 ln -s . baz || error "'ln -s .' failed after recreating cwd"
2945 cd .. || error "'cd ..' failed after recreating cwd"
2947 run_test 48a "Access renamed working dir (should return errors)="
2949 test_48b() { # bug 2399
2950 check_kernel_version 34 || return 0
2953 rmdir $DIR/d48b || error "remove cwd $DIR/d48b failed"
2954 touch foo && error "'touch foo' worked after removing cwd"
2955 mkdir foo && error "'mkdir foo' worked after removing cwd"
2956 if check_kernel_version 44; then
2957 touch .foo && error "'touch .foo' worked after removing cwd"
2958 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
2960 ls . > /dev/null && error "'ls .' worked after removing cwd"
2961 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
2962 is_patchless || ( cd . && error "'cd .' worked after removing cwd" )
2963 mkdir . && error "'mkdir .' worked after removing cwd"
2964 rmdir . && error "'rmdir .' worked after removing cwd"
2965 ln -s . foo && error "'ln -s .' worked after removing cwd"
2966 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
2968 run_test 48b "Access removed working dir (should return errors)="
2970 test_48c() { # bug 2350
2971 check_kernel_version 36 || return 0
2972 #lctl set_param debug=-1
2974 mkdir -p $DIR/d48c/dir
2976 $TRACE rmdir $DIR/d48c/dir || error "remove cwd $DIR/d48c/dir failed"
2977 $TRACE touch foo && error "'touch foo' worked after removing cwd"
2978 $TRACE mkdir foo && error "'mkdir foo' worked after removing cwd"
2979 if check_kernel_version 44; then
2980 touch .foo && error "'touch .foo' worked after removing cwd"
2981 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
2983 $TRACE ls . && error "'ls .' worked after removing cwd"
2984 $TRACE ls .. || error "'ls ..' failed after removing cwd"
2985 is_patchless || ( $TRACE cd . && error "'cd .' worked after removing cwd" )
2986 $TRACE mkdir . && error "'mkdir .' worked after removing cwd"
2987 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
2988 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
2989 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
2991 run_test 48c "Access removed working subdir (should return errors)"
2993 test_48d() { # bug 2350
2994 check_kernel_version 36 || return 0
2995 #lctl set_param debug=-1
2997 mkdir -p $DIR/d48d/dir
2999 $TRACE rmdir $DIR/d48d/dir || error "remove cwd $DIR/d48d/dir failed"
3000 $TRACE rmdir $DIR/d48d || error "remove parent $DIR/d48d failed"
3001 $TRACE touch foo && error "'touch foo' worked after removing parent"
3002 $TRACE mkdir foo && error "'mkdir foo' worked after removing parent"
3003 if check_kernel_version 44; then
3004 touch .foo && error "'touch .foo' worked after removing parent"
3005 mkdir .foo && error "'mkdir .foo' worked after removing parent"
3007 $TRACE ls . && error "'ls .' worked after removing parent"
3008 $TRACE ls .. && error "'ls ..' worked after removing parent"
3009 is_patchless || ( $TRACE cd . && error "'cd .' worked after recreate parent" )
3010 $TRACE mkdir . && error "'mkdir .' worked after removing parent"
3011 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
3012 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
3013 is_patchless || ( $TRACE cd .. && error "'cd ..' worked after removing parent" || true )
3015 run_test 48d "Access removed parent subdir (should return errors)"
3017 test_48e() { # bug 4134
3018 check_kernel_version 41 || return 0
3019 #lctl set_param debug=-1
3021 mkdir -p $DIR/d48e/dir
3023 $TRACE rmdir $DIR/d48e/dir || error "remove cwd $DIR/d48e/dir failed"
3024 $TRACE rmdir $DIR/d48e || error "remove parent $DIR/d48e failed"
3025 $TRACE touch $DIR/d48e || error "'touch $DIR/d48e' failed"
3026 $TRACE chmod +x $DIR/d48e || error "'chmod +x $DIR/d48e' failed"
3027 # On a buggy kernel addition of "touch foo" after cd .. will
3028 # produce kernel oops in lookup_hash_it
3029 touch ../foo && error "'cd ..' worked after recreate parent"
3031 $TRACE rm $DIR/d48e || error "rm '$DIR/d48e' failed"
3033 run_test 48e "Access to recreated parent subdir (should return errors)"
3035 test_49() { # LU-1030
3036 # get ost1 size - lustre-OST0000
3037 ost1_size=$(do_facet ost1 lfs df |grep ${ost1_svc} |awk '{print $4}')
3038 # write 800M at maximum
3039 [ $ost1_size -gt 819200 ] && ost1_size=819200
3041 lfs setstripe -c 1 -i 0 $DIR/$tfile
3042 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
3045 # change max_pages_per_rpc while writing the file
3046 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
3047 local orig_mppc=`$LCTL get_param -n $osc1_mppc`
3048 # loop until dd process exits
3049 while ps ax -opid | grep -q $dd_pid; do
3050 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
3051 sleep $((RANDOM % 5 + 1))
3053 # restore original max_pages_per_rpc
3054 $LCTL set_param $osc1_mppc=$orig_mppc
3056 run_test 49 "Change max_pages_per_rpc won't break osc extent"
3062 ls /proc/$$/cwd || error
3064 run_test 50 "special situations: /proc symlinks ==============="
3066 test_51a() { # was test_51
3067 # bug 1516 - create an empty entry right after ".." then split dir
3070 $MCREATE $DIR/d51/bar
3072 createmany -m $DIR/d51/longfile 201
3074 while [ `ls -sd $DIR/d51 | awk '{ print $1 }'` -eq 4 ]; do
3075 $MCREATE $DIR/d51/longfile$FNUM
3080 ls -l $DIR/d51 > /dev/null || error
3082 run_test 51a "special situations: split htree with empty entry =="
3084 export NUMTEST=70000
3086 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
3087 [ $NUMFREE -lt 21000 ] && \
3088 skip "not enough free inodes ($NUMFREE)" && \
3091 [ $NUMFREE -lt $NUMTEST ] && NUMTEST=$(($NUMFREE - 50))
3094 createmany -d $DIR/d51b/t- $NUMTEST
3096 run_test 51b "mkdir .../t-0 --- .../t-$NUMTEST ===================="
3098 test_51ba() { # LU-993
3099 local BASE=$DIR/d51b
3100 # unlink all but 100 subdirectories, then check it still works
3102 local DELETE=$((NUMTEST - LEFT))
3104 ! [ -d "${BASE}/t-$DELETE" ] && skip "test_51b() not run" && return 0
3106 # for ldiskfs the nlink count should be 1, but this is OSD specific
3107 # and so this is listed for informational purposes only
3108 log "nlink before: $(stat -c %h $BASE)"
3109 unlinkmany -d $BASE/t- $DELETE ||
3110 error "unlink of first $DELETE subdirs failed"
3112 log "nlink between: $(stat -c %h $BASE)"
3113 local FOUND=$(ls -l ${BASE} | wc -l)
3114 FOUND=$((FOUND - 1)) # trim the first line of ls output
3115 [ $FOUND -ne $LEFT ] &&
3116 error "can't find subdirs: found only $FOUND/$LEFT"
3118 unlinkmany -d $BASE/t- $DELETE $LEFT ||
3119 error "unlink of second $LEFT subdirs failed"
3120 log "nlink after: $(stat -c %h $BASE)"
3122 run_test 51ba "rmdir .../t-0 --- .../t-$NUMTEST"
3125 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3127 local ndirs=${TEST51BB_NDIRS:-10}
3128 local nfiles=${TEST51BB_NFILES:-100}
3130 local numfree=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
3132 [ $numfree -lt $(( ndirs * nfiles)) ] && \
3133 nfiles=$(( numfree / ndirs - 10 ))
3135 local dir=$DIR/d51bb
3137 local savePOLICY=$(lctl get_param -n lmv.*.placement)
3138 lctl set_param -n lmv.*.placement=CHAR
3141 local IUSED=$(lfs df -i $dir | grep MDT | awk '{print $3}')
3145 for ((i=0; i < $ndirs; i++)); do
3146 dirs[i]=$dir/$RANDOM
3147 echo Creating directory ${dirs[i]}
3150 echo Creating $nfiles in dir ${dirs[i]} ...
3151 echo "createmany -o ${dirs[i]}/$tfile- $nfiles"
3152 createmany -o ${dirs[i]}/$tfile- $nfiles
3158 IUSED=$(lfs df -i $dir | grep MDT | awk '{print $3}')
3162 for ((i=0; i<${#NEWUSED[@]}; i++)); do
3163 echo "mds $i: inodes count OLD ${OLDUSED[$i]} NEW ${NEWUSED[$i]}"
3164 [ ${OLDUSED[$i]} -lt ${NEWUSED[$i]} ] || rc=$((rc + 1))
3167 lctl set_param -n lmv.*.placement=$savePOLICY
3169 [ $rc -ne $MDSCOUNT ] || \
3170 error "Objects/inodes are not distributed over all mds servers"
3172 run_test 51bb "mkdir createmany CMD $MDSCOUNT ===================="
3175 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping test with few OSTs" && return
3177 createmany -o $DIR/d51d/t- 1000
3178 $GETSTRIPE $DIR/d51d > $TMP/files
3179 for N in `seq 0 $((OSTCOUNT - 1))`; do
3180 OBJS[$N]=`awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}' $TMP/files`
3181 OBJS0[$N]=`grep -A 1 idx $TMP/files | awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}'`
3182 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
3184 unlinkmany $DIR/d51d/t- 1000
3187 for N in `seq 1 $((OSTCOUNT - 1))`; do
3188 [ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ] && \
3189 error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
3190 [ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ] && \
3191 error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
3193 [ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ] && \
3194 error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
3195 [ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ] && \
3196 error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
3200 run_test 51d "check object distribution ===================="
3203 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
3206 chattr +a $DIR/d52a/foo || error "chattr +a failed"
3207 echo bar >> $DIR/d52a/foo || error "append bar failed"
3208 cp /etc/hosts $DIR/d52a/foo && error "cp worked"
3209 rm -f $DIR/d52a/foo 2>/dev/null && error "rm worked"
3210 link $DIR/d52a/foo $DIR/d52a/foo_link 2>/dev/null && error "link worked"
3211 echo foo >> $DIR/d52a/foo || error "append foo failed"
3212 mrename $DIR/d52a/foo $DIR/d52a/foo_ren && error "rename worked"
3213 lsattr $DIR/d52a/foo | egrep -q "^-+a[-e]+ $DIR/d52a/foo" || error "lsattr"
3214 chattr -a $DIR/d52a/foo || error "chattr -a failed"
3215 cp -r $DIR/d52a /tmp/
3216 rm -fr $DIR/d52a || error "cleanup rm failed"
3218 run_test 52a "append-only flag test (should return errors) ====="
3221 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
3224 chattr +i $DIR/d52b/foo || error "chattr +i failed"
3225 cat test > $DIR/d52b/foo && error "cat test worked"
3226 cp /etc/hosts $DIR/d52b/foo && error "cp worked"
3227 rm -f $DIR/d52b/foo 2>/dev/null && error "rm worked"
3228 link $DIR/d52b/foo $DIR/d52b/foo_link 2>/dev/null && error "link worked"
3229 echo foo >> $DIR/d52b/foo && error "echo worked"
3230 mrename $DIR/d52b/foo $DIR/d52b/foo_ren && error "rename worked"
3231 [ -f $DIR/d52b/foo ] || error
3232 [ -f $DIR/d52b/foo_ren ] && error
3233 lsattr $DIR/d52b/foo | egrep -q "^-+i[-e]+ $DIR/d52b/foo" || error "lsattr"
3234 chattr -i $DIR/d52b/foo || error "chattr failed"
3236 rm -fr $DIR/d52b || error
3238 run_test 52b "immutable flag test (should return errors) ======="
3241 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3242 remote_ost_nodsh && skip "remote OST with nodsh" && return
3251 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
3252 for value in $(do_facet $SINGLEMDS lctl get_param osc.$mdtosc.prealloc_last_id) ; do
3253 param=`echo ${value[0]} | cut -d "=" -f1`
3254 ostname=`echo $param | cut -d "." -f2 | cut -d - -f 1-2`
3255 mds_last=$(do_facet $SINGLEMDS lctl get_param -n $param)
3256 ostnum=$(echo $ostname | sed "s/${FSNAME}-OST//g" | awk '{print ($1+1)}' )
3257 ost_last=$(do_facet ost$ostnum lctl get_param -n obdfilter.$ostname.last_id | head -n 1)
3258 echo "$ostname.last_id=$ost_last ; MDS.last_id=$mds_last"
3259 if [ $ost_last != $mds_last ]; then
3260 error "$ostname.last_id=$ost_last ; MDS.last_id=$mds_last"
3264 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
3267 [ ! -f "$SOCKETSERVER" ] && skip_env "no socketserver, skipping" && return
3268 [ ! -f "$SOCKETCLIENT" ] && skip_env "no socketclient, skipping" && return
3269 $SOCKETSERVER $DIR/socket
3270 $SOCKETCLIENT $DIR/socket || error
3271 $MUNLINK $DIR/socket
3273 run_test 54a "unix domain socket test =========================="
3279 dd if=/dev/zero of=$f bs=`page_size` count=1
3281 run_test 54b "char device works in lustre ======================"
3284 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
3285 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
3286 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
3288 for i in `seq 3 7`; do
3289 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
3299 loopdev="$DIR/loop54c"
3302 [ -z "$LOOPNUM" ] && echo "couldn't find empty loop device" && return
3303 mknod $loopdev b 7 $LOOPNUM
3304 echo "make a loop file system with $tfile on $loopdev ($LOOPNUM)..."
3305 dd if=/dev/zero of=$tfile bs=`page_size` seek=1024 count=1 > /dev/null
3306 losetup $loopdev $tfile || error "can't set up $loopdev for $tfile"
3307 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
3309 mount -t ext2 $loopdev $tdir || error "error mounting $loopdev on $tdir"
3310 dd if=/dev/zero of=$tdir/tmp bs=`page_size` count=30 || error "dd write"
3312 dd if=$tdir/tmp of=/dev/zero bs=`page_size` count=30 || error "dd read"
3317 run_test 54c "block device works in lustre ====================="
3323 [ "$string" = `echo $string > $f | cat $f` ] || error
3325 run_test 54d "fifo device works in lustre ======================"
3328 check_kernel_version 46 || return 0
3331 cp -aL /dev/console $f
3332 echo $string > $f || error
3334 run_test 54e "console/tty device works in lustre ======================"
3336 #The test_55 used to be iopen test and it was removed by bz#24037.
3337 #run_test 55 "check iopen_connect_dentry() ======================"
3339 test_56a() { # was test_56
3345 NUMFILESx2=$(($NUMFILES * 2))
3346 for i in `seq 1 $NUMFILES` ; do
3347 touch $DIR/d56/file$i
3348 touch $DIR/d56/dir/file$i
3351 # test lfs getstripe with --recursive
3352 FILENUM=`$GETSTRIPE --recursive $DIR/d56 | grep -c obdidx`
3353 [ $FILENUM -eq $NUMFILESx2 ] ||
3354 error "$GETSTRIPE --recursive: found $FILENUM, not $NUMFILESx2"
3355 FILENUM=`$GETSTRIPE $DIR/d56 | grep -c obdidx`
3356 [ $FILENUM -eq $NUMFILES ] ||
3357 error "$GETSTRIPE $DIR/d56: found $FILENUM, not $NUMFILES"
3358 echo "$GETSTRIPE --recursive passed."
3360 # test lfs getstripe with file instead of dir
3361 FILENUM=`$GETSTRIPE $DIR/d56/file1 | grep -c obdidx`
3362 [ $FILENUM -eq 1 ] || error \
3363 "$GETSTRIPE $DIR/d56/file1: found $FILENUM, not 1"
3364 echo "$GETSTRIPE file1 passed."
3366 #test lfs getstripe with --verbose
3367 [ `$GETSTRIPE --verbose $DIR/d56 | grep -c lmm_magic` -eq $NUMFILES ] ||
3368 error "$GETSTRIPE --verbose $DIR/d56: want $NUMFILES lmm_magic"
3369 [ `$GETSTRIPE $DIR/d56 | grep -c lmm_magic` -eq 0 ] ||
3370 error "$GETSTRIPE $DIR/d56: showed lmm_magic"
3371 echo "$GETSTRIPE --verbose passed."
3373 #test lfs getstripe with --obd
3374 $GETSTRIPE --obd wrong_uuid $DIR/d56 2>&1 | grep -q "unknown obduuid" ||
3375 error "$GETSTRIPE --obd wrong_uuid should return error message"
3377 [ "$OSTCOUNT" -lt 2 ] &&
3378 skip_env "skipping other $GETSTRIPE --obd test" && return
3381 OBDUUID=$(ostuuid_from_index $OSTIDX)
3382 FILENUM=`$GETSTRIPE -ir $DIR/d56 | grep -x $OSTIDX | wc -l`
3383 FOUND=`$GETSTRIPE -r --obd $OBDUUID $DIR/d56 | grep obdidx | wc -l`
3384 [ $FOUND -eq $FILENUM ] ||
3385 error "$GETSTRIPE --obd wrong: found $FOUND, expected $FILENUM"
3386 [ `$GETSTRIPE -r -v --obd $OBDUUID $DIR/d56 |
3387 sed '/^[ ]*'${OSTIDX}'[ ]/d' |
3388 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l` -eq 0 ] ||
3389 error "$GETSTRIPE --obd: should not show file on other obd"
3390 echo "$GETSTRIPE --obd passed"
3392 run_test 56a "check $GETSTRIPE"
3397 local LOCAL_NUMFILES="$1"
3398 local LOCAL_NUMDIRS="$2"
3399 local MKDIR_PARAMS="$3"
3401 if [ ! -d "$TDIR" ] ; then
3403 [ "$MKDIR_PARAMS" ] && $SETSTRIPE $MKDIR_PARAMS $TDIR
3404 for i in `seq 1 $LOCAL_NUMFILES` ; do
3407 for i in `seq 1 $LOCAL_NUMDIRS` ; do
3409 for j in `seq 1 $LOCAL_NUMFILES` ; do
3410 touch $TDIR/dir$i/file$j
3416 setup_56_special() {
3420 if [ ! -e "$TDIR/loop1b" ] ; then
3421 for i in `seq 1 $LOCAL_NUMFILES` ; do
3422 mknod $TDIR/loop${i}b b 7 $i
3423 mknod $TDIR/null${i}c c 1 3
3424 ln -s $TDIR/file1 $TDIR/link${i}l
3426 for i in `seq 1 $LOCAL_NUMDIRS` ; do
3427 mknod $TDIR/dir$i/loop${i}b b 7 $i
3428 mknod $TDIR/dir$i/null${i}c c 1 3
3429 ln -s $TDIR/dir$i/file1 $TDIR/dir$i/link${i}l
3438 setup_56 $NUMFILES $NUMDIRS
3440 EXPECTED=$(($NUMDIRS + 2))
3441 # test lfs find with -name
3442 for i in $(seq 1 $NUMFILES) ; do
3443 NUMS=$($LFIND -name "*$i" $TDIR | wc -l)
3444 [ $NUMS -eq $EXPECTED ] ||
3445 error "lfs find -name \"*$i\" $TDIR wrong: "\
3446 "found $NUMS, expected $EXPECTED"
3449 run_test 56g "check lfs find -name ============================="
3455 setup_56 $NUMFILES $NUMDIRS
3457 EXPECTED=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
3458 # test lfs find with ! -name
3459 for i in $(seq 1 $NUMFILES) ; do
3460 NUMS=$($LFIND ! -name "*$i" $TDIR | wc -l)
3461 [ $NUMS -eq $EXPECTED ] ||
3462 error "lfs find ! -name \"*$i\" $TDIR wrong: "\
3463 "found $NUMS, expected $EXPECTED"
3466 run_test 56h "check lfs find ! -name ============================="
3471 UUID=$(ostuuid_from_index 0 $DIR/$tdir)
3472 CMD="$LFIND -ost $UUID $DIR/$tdir"
3474 [ -z "$OUT" ] || error "\"$CMD\" returned directory '$OUT'"
3476 run_test 56i "check 'lfs find -ost UUID' skips directories ======="
3480 setup_56_special $NUMFILES $NUMDIRS
3482 EXPECTED=$((NUMDIRS + 1))
3483 CMD="$LFIND -type d $TDIR"
3484 NUMS=$($CMD | wc -l)
3485 [ $NUMS -eq $EXPECTED ] ||
3486 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3488 run_test 56j "check lfs find -type d ============================="
3492 setup_56_special $NUMFILES $NUMDIRS
3494 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
3495 CMD="$LFIND -type f $TDIR"
3496 NUMS=$($CMD | wc -l)
3497 [ $NUMS -eq $EXPECTED ] ||
3498 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3500 run_test 56k "check lfs find -type f ============================="
3504 setup_56_special $NUMFILES $NUMDIRS
3506 EXPECTED=$((NUMDIRS + NUMFILES))
3507 CMD="$LFIND -type b $TDIR"
3508 NUMS=$($CMD | wc -l)
3509 [ $NUMS -eq $EXPECTED ] ||
3510 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3512 run_test 56l "check lfs find -type b ============================="
3516 setup_56_special $NUMFILES $NUMDIRS
3518 EXPECTED=$((NUMDIRS + NUMFILES))
3519 CMD="$LFIND -type c $TDIR"
3520 NUMS=$($CMD | wc -l)
3521 [ $NUMS -eq $EXPECTED ] ||
3522 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3524 run_test 56m "check lfs find -type c ============================="
3528 setup_56_special $NUMFILES $NUMDIRS
3530 EXPECTED=$((NUMDIRS + NUMFILES))
3531 CMD="$LFIND -type l $TDIR"
3532 NUMS=$($CMD | wc -l)
3533 [ $NUMS -eq $EXPECTED ] ||
3534 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3536 run_test 56n "check lfs find -type l ============================="
3540 setup_56 $NUMFILES $NUMDIRS
3542 utime $TDIR/file1 > /dev/null || error "utime (1)"
3543 utime $TDIR/file2 > /dev/null || error "utime (2)"
3544 utime $TDIR/dir1 > /dev/null || error "utime (3)"
3545 utime $TDIR/dir2 > /dev/null || error "utime (4)"
3546 utime $TDIR/dir1/file1 > /dev/null || error "utime (5)"
3547 dd if=/dev/zero count=1 >> $TDIR/dir1/file1 && sync
3550 NUMS=`$LFIND -mtime +0 $TDIR | wc -l`
3551 [ $NUMS -eq $EXPECTED ] || \
3552 error "lfs find -mtime +0 $TDIR wrong: found $NUMS, expected $EXPECTED"
3555 CMD="$LFIND -mtime 0 $TDIR"
3556 NUMS=$($CMD | wc -l)
3557 [ $NUMS -eq $EXPECTED ] ||
3558 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3560 run_test 56o "check lfs find -mtime for old files =========================="
3563 [ $RUNAS_ID -eq $UID ] &&
3564 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
3567 setup_56 $NUMFILES $NUMDIRS
3569 chown $RUNAS_ID $TDIR/file* || error "chown $DIR/${tdir}g/file$i failed"
3571 CMD="$LFIND -uid $RUNAS_ID $TDIR"
3572 NUMS=$($CMD | wc -l)
3573 [ $NUMS -eq $EXPECTED ] || \
3574 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3576 EXPECTED=$(((NUMFILES + 1) * NUMDIRS + 1))
3577 CMD="$LFIND ! -uid $RUNAS_ID $TDIR"
3578 NUMS=$($CMD | wc -l)
3579 [ $NUMS -eq $EXPECTED ] || \
3580 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3582 run_test 56p "check lfs find -uid and ! -uid ==============================="
3585 [ $RUNAS_ID -eq $UID ] &&
3586 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
3589 setup_56 $NUMFILES $NUMDIRS
3591 chgrp $RUNAS_GID $TDIR/file* || error "chown $TDIR/file$i failed"
3594 CMD="$LFIND -gid $RUNAS_GID $TDIR"
3595 NUMS=$($CMD | wc -l)
3596 [ $NUMS -eq $EXPECTED ] ||
3597 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3599 EXPECTED=$(( ($NUMFILES+1) * $NUMDIRS + 1))
3600 CMD="$LFIND ! -gid $RUNAS_GID $TDIR"
3601 NUMS=$($CMD | wc -l)
3602 [ $NUMS -eq $EXPECTED ] ||
3603 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3605 run_test 56q "check lfs find -gid and ! -gid ==============================="
3609 setup_56 $NUMFILES $NUMDIRS
3612 CMD="$LFIND -size 0 -type f $TDIR"
3613 NUMS=$($CMD | wc -l)
3614 [ $NUMS -eq $EXPECTED ] ||
3615 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3617 CMD="$LFIND ! -size 0 -type f $TDIR"
3618 NUMS=$($CMD | wc -l)
3619 [ $NUMS -eq $EXPECTED ] ||
3620 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3621 echo "test" > $TDIR/$tfile
3622 echo "test2" > $TDIR/$tfile.2 && sync
3624 CMD="$LFIND -size 5 -type f $TDIR"
3625 NUMS=$($CMD | wc -l)
3626 [ $NUMS -eq $EXPECTED ] ||
3627 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3629 CMD="$LFIND -size +5 -type f $TDIR"
3630 NUMS=$($CMD | wc -l)
3631 [ $NUMS -eq $EXPECTED ] ||
3632 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3634 CMD="$LFIND -size +0 -type f $TDIR"
3635 NUMS=$($CMD | wc -l)
3636 [ $NUMS -eq $EXPECTED ] ||
3637 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3639 CMD="$LFIND ! -size -5 -type f $TDIR"
3640 NUMS=$($CMD | wc -l)
3641 [ $NUMS -eq $EXPECTED ] ||
3642 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3644 CMD="$LFIND -size -5 -type f $TDIR"
3645 NUMS=$($CMD | wc -l)
3646 [ $NUMS -eq $EXPECTED ] ||
3647 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3649 run_test 56r "check lfs find -size works =========================="
3651 test_56s() { # LU-611
3653 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT"
3655 if [ $OSTCOUNT -gt 1 ]; then
3656 $SETSTRIPE -c 1 $TDIR/$tfile.{0,1,2,3}
3660 ONESTRIPE=$(((NUMDIRS + 1) * NUMFILES))
3664 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
3665 CMD="$LFIND -stripe-count $OSTCOUNT -type f $TDIR"
3666 NUMS=$($CMD | wc -l)
3667 [ $NUMS -eq $EXPECTED ] ||
3668 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3670 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + EXTRA))
3671 CMD="$LFIND -stripe-count +0 -type f $TDIR"
3672 NUMS=$($CMD | wc -l)
3673 [ $NUMS -eq $EXPECTED ] ||
3674 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3677 CMD="$LFIND -stripe-count 1 -type f $TDIR"
3678 NUMS=$($CMD | wc -l)
3679 [ $NUMS -eq $EXPECTED ] ||
3680 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3682 CMD="$LFIND -stripe-count -2 -type f $TDIR"
3683 NUMS=$($CMD | wc -l)
3684 [ $NUMS -eq $EXPECTED ] ||
3685 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3688 CMD="$LFIND -stripe-count $((OSTCOUNT + 1)) -type f $TDIR"
3689 NUMS=$($CMD | wc -l)
3690 [ $NUMS -eq $EXPECTED ] ||
3691 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3693 run_test 56s "check lfs find -stripe-count works"
3695 test_56t() { # LU-611
3697 setup_56 $NUMFILES $NUMDIRS "-s 512k"
3699 $SETSTRIPE -S 256k $TDIR/$tfile.{0,1,2,3}
3701 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
3702 CMD="$LFIND -stripe-size 512k -type f $TDIR"
3703 NUMS=$($CMD | wc -l)
3704 [ $NUMS -eq $EXPECTED ] ||
3705 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3707 CMD="$LFIND -stripe-size +320k -type f $TDIR"
3708 NUMS=$($CMD | wc -l)
3709 [ $NUMS -eq $EXPECTED ] ||
3710 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3712 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + 4))
3713 CMD="$LFIND -stripe-size +200k -type f $TDIR"
3714 NUMS=$($CMD | wc -l)
3715 [ $NUMS -eq $EXPECTED ] ||
3716 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3718 CMD="$LFIND -stripe-size -640k -type f $TDIR"
3719 NUMS=$($CMD | wc -l)
3720 [ $NUMS -eq $EXPECTED ] ||
3721 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3724 CMD="$LFIND -stripe-size 256k -type f $TDIR"
3725 NUMS=$($CMD | wc -l)
3726 [ $NUMS -eq $EXPECTED ] ||
3727 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3729 CMD="$LFIND -stripe-size -320k -type f $TDIR"
3730 NUMS=$($CMD | wc -l)
3731 [ $NUMS -eq $EXPECTED ] ||
3732 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3735 CMD="$LFIND -stripe-size 1024k -type f $TDIR"
3736 NUMS=$($CMD | wc -l)
3737 [ $NUMS -eq $EXPECTED ] ||
3738 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3740 run_test 56t "check lfs find -stripe-size works"
3742 test_56u() { # LU-611
3744 setup_56 $NUMFILES $NUMDIRS "-i 0"
3746 if [ $OSTCOUNT -gt 1 ]; then
3747 $SETSTRIPE -i 1 $TDIR/$tfile.{0,1,2,3}
3753 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
3754 CMD="$LFIND -stripe-index 0 -type f $TDIR"
3755 NUMS=$($CMD | wc -l)
3756 [ $NUMS -eq $EXPECTED ] ||
3757 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3760 CMD="$LFIND -stripe-index 1 -type f $TDIR"
3761 NUMS=$($CMD | wc -l)
3762 [ $NUMS -eq $EXPECTED ] ||
3763 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3765 CMD="$LFIND ! -stripe-index 0 -type f $TDIR"
3766 NUMS=$($CMD | wc -l)
3767 [ $NUMS -eq $EXPECTED ] ||
3768 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3771 # This should produce an error and not return any files
3772 CMD="$LFIND -stripe-index $OSTCOUNT -type f $TDIR"
3773 NUMS=$($CMD 2>/dev/null | wc -l)
3774 [ $NUMS -eq $EXPECTED ] ||
3775 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3777 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + ONESTRIPE))
3778 CMD="$LFIND -stripe-index 0,1 -type f $TDIR"
3779 NUMS=$($CMD | wc -l)
3780 [ $NUMS -eq $EXPECTED ] ||
3781 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3783 run_test 56u "check lfs find -stripe-index works"
3790 setup_56 $NUMFILES $NUMDIRS
3792 UUID=$(mdtuuid_from_index $MDT_IDX $TDIR)
3793 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT index $MDT_IDX"
3795 for file in $($LFIND -mdt $UUID $TDIR); do
3796 file_mdt_idx=$($GETSTRIPE -M $file)
3797 [ $file_mdt_idx -eq $MDT_IDX ] ||
3798 error "'lfind -mdt $UUID' != 'getstripe -M' ($file_mdt_idx)"
3801 run_test 56v "check 'lfs find -mdt match with lfs getstripe -M' ======="
3803 # Get and check the actual stripe count of one file.
3804 # Usage: check_stripe_count <file> <expected_stripe_count>
3805 check_stripe_count() {
3810 [[ -z "$file" || -z "$expected" ]] &&
3811 error "check_stripe_count: invalid argument!"
3813 local cmd="$GETSTRIPE -c $file"
3814 actual=$($cmd) || error "$cmd failed"
3815 actual=${actual%% *}
3817 if [[ $actual -ne $expected ]]; then
3818 [[ $expected -eq -1 ]] ||
3819 error "$cmd wrong: found $actual, expected $expected"
3820 [[ $actual -eq $OSTCOUNT ]] ||
3821 error "$cmd wrong: found $actual, expected $OSTCOUNT"
3828 rm -rf $TDIR || error "remove $TDIR failed"
3829 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT"
3832 stripe_size=$($GETSTRIPE -S -d $TDIR) ||
3833 error "$GETSTRIPE -S -d $TDIR failed"
3834 stripe_size=${stripe_size%% *}
3836 local file_size=$((stripe_size * OSTCOUNT))
3837 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
3838 local required_space=$((file_num * file_size))
3839 local free_space=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
3840 [[ $free_space -le $((required_space / 1024)) ]] &&
3841 skip_env "need at least $required_space bytes free space," \
3842 "have $free_space kbytes" && return
3845 local dd_count=$((file_size / dd_bs))
3847 # write data into the files
3851 for i in $(seq 1 $NUMFILES); do
3853 yes | dd bs=$dd_bs count=$dd_count of=$file >/dev/null 2>&1 ||
3854 error "write data into $file failed"
3856 for i in $(seq 1 $NUMDIRS); do
3857 for j in $(seq 1 $NUMFILES); do
3858 file=$TDIR/dir$i/file$j
3859 yes | dd bs=$dd_bs count=$dd_count of=$file \
3861 error "write data into $file failed"
3866 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
3869 local cmd="$LFS_MIGRATE -y -c $expected $TDIR/file1"
3871 eval $cmd || error "$cmd failed"
3873 check_stripe_count $TDIR/file1 $expected
3876 cmd="$LFS_MIGRATE -y -c $expected $TDIR/dir1"
3878 eval $cmd || error "$cmd failed"
3880 for j in $(seq 1 $NUMFILES); do
3881 check_stripe_count $TDIR/dir1/file$j $expected
3884 # lfs_migrate works with lfs find
3885 cmd="$LFIND -stripe_count $OSTCOUNT -type f $TDIR |
3886 $LFS_MIGRATE -y -c $expected"
3888 eval $cmd || error "$cmd failed"
3890 for i in $(seq 2 $NUMFILES); do
3891 check_stripe_count $TDIR/file$i $expected
3893 for i in $(seq 2 $NUMDIRS); do
3894 for j in $(seq 1 $NUMFILES); do
3895 check_stripe_count $TDIR/dir$i/file$j $expected
3899 run_test 56w "check lfs_migrate -c stripe_count works"
3902 # note test will not do anything if MDS is not local
3903 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3904 local MNTDEV="osd*.*MDT*.mntdev"
3905 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
3906 [ -z "$DEV" ] && error "can't access $MNTDEV"
3907 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
3908 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
3909 error "can't access $DEV"
3910 DEVISIZE=`awk '/Inode size:/ { print $3 }' $TMP/t57a.dump`
3911 [ "$DEVISIZE" -gt 128 ] || error "inode size $DEVISIZE"
3915 run_test 57a "verify MDS filesystem created with large inodes =="
3918 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3923 local FILEN=$dir/f$FILECOUNT
3925 rm -rf $dir || error "removing $dir"
3926 mkdir -p $dir || error "creating $dir"
3927 local num=$(get_mds_dir $dir)
3930 echo "mcreating $FILECOUNT files"
3931 createmany -m $dir/f 1 $FILECOUNT || \
3932 error "creating files in $dir"
3934 # verify that files do not have EAs yet
3935 $GETSTRIPE $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
3936 $GETSTRIPE $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
3940 df $dir #make sure we get new statfs data
3941 local MDSFREE=$(do_facet $mymds \
3942 lctl get_param -n osd*.*MDT000$((num -1)).kbytesfree)
3943 local MDCFREE=$(lctl get_param -n mdc.*MDT000$((num -1))-mdc-*.kbytesfree)
3944 echo "opening files to create objects/EAs"
3946 for FILE in `seq -f $dir/f%g 1 $FILECOUNT`; do
3947 $OPENFILE -f O_RDWR $FILE > /dev/null 2>&1 || error "opening $FILE"
3950 # verify that files have EAs now
3951 $GETSTRIPE $FILE1 | grep -q "obdidx" || error "$FILE1 missing EA"
3952 $GETSTRIPE $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
3954 sleep 1 #make sure we get new statfs data
3956 local MDSFREE2=$(do_facet $mymds \
3957 lctl get_param -n osd*.*MDT000$((num -1)).kbytesfree)
3958 local MDCFREE2=$(lctl get_param -n mdc.*MDT000$((num -1))-mdc-*.kbytesfree)
3959 if [ "$MDCFREE2" -lt "$((MDCFREE - 8))" ]; then
3960 if [ "$MDSFREE" != "$MDSFREE2" ]; then
3961 error "MDC before $MDCFREE != after $MDCFREE2"
3963 echo "MDC before $MDCFREE != after $MDCFREE2"
3964 echo "unable to confirm if MDS has large inodes"
3969 run_test 57b "default LOV EAs are stored inside large inodes ==="
3972 [ -z "$(which wiretest 2>/dev/null)" ] && skip_env "could not find wiretest" && return
3975 run_test 58 "verify cross-platform wire constants =============="
3978 echo "touch 130 files"
3979 createmany -o $DIR/f59- 130
3981 unlinkmany $DIR/f59- 130
3984 # wait for commitment of removal
3986 run_test 59 "verify cancellation of llog records async ========="
3988 TEST60_HEAD="test_60 run $RANDOM"
3990 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
3991 [ ! -f run-llog.sh ] && skip_env "missing subtest run-llog.sh" && return
3992 log "$TEST60_HEAD - from kernel mode"
3993 do_facet mgs sh run-llog.sh
3995 run_test 60a "llog sanity tests run from kernel module =========="
3997 test_60b() { # bug 6411
3999 LLOG_COUNT=`dmesg | awk "/$TEST60_HEAD/{marker = 1; from_marker = 0;}
4011 [ $LLOG_COUNT -gt 50 ] && error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)"|| true
4013 run_test 60b "limit repeated messages from CERROR/CWARN ========"
4016 echo "create 5000 files"
4017 createmany -o $DIR/f60c- 5000
4018 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
4019 lctl set_param fail_loc=0x80000137
4020 unlinkmany $DIR/f60c- 5000
4021 lctl set_param fail_loc=0
4023 run_test 60c "unlink file when mds full"
4026 SAVEPRINTK=$(lctl get_param -n printk)
4028 # verify "lctl mark" is even working"
4029 MESSAGE="test message ID $RANDOM $$"
4030 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
4031 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
4033 lctl set_param printk=0 || error "set lnet.printk failed"
4034 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
4035 MESSAGE="new test message ID $RANDOM $$"
4036 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
4037 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
4038 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
4040 lctl set_param -n printk="$SAVEPRINTK"
4042 run_test 60d "test printk console message masking"
4046 dd if=/dev/zero of=$f bs=`page_size` count=1
4047 cancel_lru_locks osc
4048 $MULTIOP $f OSMWUc || error
4051 run_test 61 "mmap() writes don't make sync hang ================"
4053 # bug 2330 - insufficient obd_match error checking causes LBUG
4057 cancel_lru_locks osc
4058 lctl set_param fail_loc=0x405
4059 cat $f && error "cat succeeded, expect -EIO"
4060 lctl set_param fail_loc=0
4062 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
4063 # match every page all of the time.
4064 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
4066 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
4067 test_63a() { # was test_63
4068 MAX_DIRTY_MB=`lctl get_param -n osc.*.max_dirty_mb | head -n 1`
4069 lctl set_param -n osc.*.max_dirty_mb 0
4070 for i in `seq 10` ; do
4071 dd if=/dev/zero of=$DIR/f63 bs=8k &
4077 lctl set_param -n osc.*.max_dirty_mb $MAX_DIRTY_MB
4078 rm -f $DIR/f63 || true
4080 run_test 63a "Verify oig_wait interruption does not crash ======="
4082 # bug 2248 - async write errors didn't return to application on sync
4083 # bug 3677 - async write errors left page locked
4086 lctl set_param debug=-1
4088 # ensure we have a grant to do async writes
4089 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
4092 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
4093 lctl set_param fail_loc=0x80000406
4094 $MULTIOP $DIR/$tfile Owy && \
4095 error "sync didn't return ENOMEM"
4096 sync; sleep 2; sync # do a real sync this time to flush page
4097 lctl get_param -n llite.*.dump_page_cache | grep locked && \
4098 error "locked page left in cache after async error" || true
4101 run_test 63b "async write errors should be returned to fsync ==="
4105 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
4107 run_test 64a "verify filter grant calculations (in kernel) ====="
4110 [ ! -f oos.sh ] && skip_env "missing subtest oos.sh" && return
4113 run_test 64b "check out-of-space detection on client ==========="
4115 # bug 1414 - set/get directories' stripe info
4119 $LVERIFY $DIR/d65 $DIR/d65/f1 || error "lverify failed"
4121 run_test 65a "directory with no stripe info ===================="
4125 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/d65||error "setstripe"
4127 $LVERIFY $DIR/d65 $DIR/d65/f2 || error "lverify failed"
4129 run_test 65b "directory setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1"
4132 if [ $OSTCOUNT -gt 1 ]; then
4134 $SETSTRIPE -S $(($STRIPESIZE * 4)) -i 1 \
4135 -c $(($OSTCOUNT - 1)) $DIR/d65 || error "setstripe"
4137 $LVERIFY $DIR/d65 $DIR/d65/f3 || error "lverify failed"
4140 run_test 65c "directory setstripe -S $((STRIPESIZE*4)) -i 1 -c $((OSTCOUNT-1))"
4144 if [ $STRIPECOUNT -le 0 ]; then
4146 elif [ $STRIPECOUNT -gt 2000 ]; then
4147 #LOV_MAX_STRIPE_COUNT is 2000
4148 [ $OSTCOUNT -gt 2000 ] && sc=2000 || sc=$(($OSTCOUNT - 1))
4150 sc=$(($STRIPECOUNT - 1))
4152 $SETSTRIPE -S $STRIPESIZE -c $sc $DIR/d65 || error "setstripe"
4153 touch $DIR/d65/f4 $DIR/d65/f5
4154 $LVERIFY $DIR/d65 $DIR/d65/f4 $DIR/d65/f5 || error "lverify failed"
4156 run_test 65d "directory setstripe -S $STRIPESIZE -c stripe_count"
4161 $SETSTRIPE $DIR/d65 || error "setstripe"
4162 $GETSTRIPE -v $DIR/d65 | grep "Default" || error "no stripe info failed"
4164 $LVERIFY $DIR/d65 $DIR/d65/f6 || error "lverify failed"
4166 run_test 65e "directory setstripe defaults ======================="
4170 $RUNAS $SETSTRIPE $DIR/d65f && error "setstripe succeeded" || true
4172 run_test 65f "dir setstripe permission (should return error) ==="
4176 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/d65 ||error "setstripe"
4177 $SETSTRIPE -d $DIR/d65 || error "setstripe"
4178 $GETSTRIPE -v $DIR/d65 | grep "Default" || \
4179 error "delete default stripe failed"
4181 run_test 65g "directory setstripe -d ==========================="
4185 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/d65 ||error "setstripe"
4186 mkdir -p $DIR/d65/dd1
4187 [ $($GETSTRIPE -c $DIR/d65) == $($GETSTRIPE -c $DIR/d65/dd1) ] ||
4188 error "stripe info inherit failed"
4190 run_test 65h "directory stripe info inherit ===================="
4192 test_65i() { # bug6367
4193 $SETSTRIPE -S 65536 -c -1 $MOUNT
4195 run_test 65i "set non-default striping on root directory (bug 6367)="
4197 test_65ia() { # bug12836
4198 $GETSTRIPE $MOUNT || error "getstripe $MOUNT failed"
4200 run_test 65ia "getstripe on -1 default directory striping"
4202 test_65ib() { # bug12836
4203 $GETSTRIPE -v $MOUNT || error "getstripe -v $MOUNT failed"
4205 run_test 65ib "getstripe -v on -1 default directory striping"
4207 test_65ic() { # bug12836
4208 $LFS find -mtime -1 $MOUNT || error "find $MOUNT failed"
4210 run_test 65ic "new find on -1 default directory striping"
4212 test_65j() { # bug6367
4214 # if we aren't already remounting for each test, do so for this test
4215 if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
4216 cleanup || error "failed to unmount"
4219 $SETSTRIPE -d $MOUNT || error "setstripe failed"
4221 run_test 65j "set default striping on root directory (bug 6367)="
4223 test_65k() { # bug11679
4224 [ "$OSTCOUNT" -lt 2 ] && skip_env "too few OSTs" && return
4225 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4227 echo "Check OST status: "
4228 local MDS_OSCS=`do_facet $SINGLEMDS lctl dl |
4229 awk '/[oO][sS][cC].*md[ts]/ { print $4 }'`
4231 for OSC in $MDS_OSCS; do
4232 echo $OSC "is activate"
4233 do_facet $SINGLEMDS lctl --device %$OSC activate
4236 do_facet client mkdir -p $DIR/$tdir
4237 for INACTIVE_OSC in $MDS_OSCS; do
4238 echo "Deactivate: " $INACTIVE_OSC
4239 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
4240 for STRIPE_OSC in $MDS_OSCS; do
4241 OST=`osc_to_ost $STRIPE_OSC`
4242 IDX=`do_facet $SINGLEMDS lctl get_param -n lov.*md*.target_obd |
4243 awk -F: /$OST/'{ print $1 }' | head -n 1`
4245 [ -f $DIR/$tdir/$IDX ] && continue
4246 echo "$SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX"
4247 do_facet client $SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX
4249 [ $RC -ne 0 ] && error "setstripe should have succeeded"
4251 do_facet client rm -f $DIR/$tdir/*
4252 echo $INACTIVE_OSC "is Activate."
4253 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
4256 run_test 65k "validate manual striping works properly with deactivated OSCs"
4258 test_65l() { # bug 12836
4259 mkdir -p $DIR/$tdir/test_dir
4260 $SETSTRIPE -c -1 $DIR/$tdir/test_dir
4261 $LFS find -mtime -1 $DIR/$tdir >/dev/null
4263 run_test 65l "lfs find on -1 stripe dir ========================"
4265 # bug 2543 - update blocks count on client
4268 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
4270 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
4271 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
4273 run_test 66 "update inode blocks count on client ==============="
4279 if [ ! -z "$LLOOP" ]; then
4280 if swapon -s | grep -q $LLOOP; then
4281 swapoff $LLOOP || error "swapoff failed"
4284 $LCTL blockdev_detach $LLOOP || error "detach failed"
4288 if [ ! -z "$LLITELOOPLOAD" ]; then
4296 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
4300 swapon -s | awk '($1 == "'$1'") { print $4 }'
4303 # test case for lloop driver, basic function
4305 [ "$UID" != 0 ] && skip_env "must run as root" && return
4306 llite_lloop_enabled || \
4307 { skip_env "llite_lloop module disabled" && return; }
4309 trap cleanup_68 EXIT
4311 if ! module_loaded llite_lloop; then
4312 if load_module llite/llite_lloop; then
4315 skip_env "can't find module llite_lloop"
4320 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
4321 dd if=/dev/zero of=$DIR/f68a bs=4k count=1024
4322 $LCTL blockdev_attach $DIR/f68a $LLOOP || error "attach failed"
4324 directio rdwr $LLOOP 0 1024 4096 || error "direct write failed"
4325 directio rdwr $LLOOP 0 1025 4096 && error "direct write should fail"
4329 run_test 68a "lloop driver - basic test ========================"
4331 # excercise swapping to lustre by adding a high priority swapfile entry
4332 # and then consuming memory until it is used.
4333 test_68b() { # was test_68
4334 [ "$UID" != 0 ] && skip_env "must run as root" && return
4335 lctl get_param -n devices | grep -q obdfilter && \
4336 skip "local OST" && return
4338 grep -q llite_lloop /proc/modules
4339 [ $? -ne 0 ] && skip "can't find module llite_lloop" && return
4341 [ -z "`$LCTL list_nids | grep -v tcp`" ] && \
4342 skip "can't reliably test swap with TCP" && return
4344 MEMTOTAL=`meminfo MemTotal`
4345 NR_BLOCKS=$((MEMTOTAL>>8))
4346 [[ $NR_BLOCKS -le 2048 ]] && NR_BLOCKS=2048
4348 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
4349 dd if=/dev/zero of=$DIR/f68b bs=64k seek=$NR_BLOCKS count=1
4352 $LCTL blockdev_attach $DIR/f68b $LLOOP || error "attach failed"
4354 trap cleanup_68 EXIT
4356 swapon -p 32767 $LLOOP || error "swapon $LLOOP failed"
4358 echo "before: `swapon -s | grep $LLOOP`"
4359 $MEMHOG $MEMTOTAL || error "error allocating $MEMTOTAL kB"
4360 echo "after: `swapon -s | grep $LLOOP`"
4361 SWAPUSED=`swap_used $LLOOP`
4365 [ $SWAPUSED -eq 0 ] && echo "no swap used???" || true
4367 run_test 68b "support swapping to Lustre ========================"
4369 # bug5265, obdfilter oa2dentry return -ENOENT
4370 # #define OBD_FAIL_OST_ENOENT 0x217
4372 remote_ost_nodsh && skip "remote OST with nodsh" && return
4375 $SETSTRIPE -c 1 -i 0 $f
4377 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
4379 do_facet ost1 lctl set_param fail_loc=0x217
4380 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
4381 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
4383 do_facet ost1 lctl set_param fail_loc=0
4384 $DIRECTIO write $f 0 2 || error "write error"
4386 cancel_lru_locks osc
4387 $DIRECTIO read $f 0 1 || error "read error"
4389 do_facet ost1 lctl set_param fail_loc=0x217
4390 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
4392 do_facet ost1 lctl set_param fail_loc=0
4395 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
4399 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
4401 run_test 71 "Running dbench on lustre (don't segment fault) ===="
4403 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
4404 check_kernel_version 43 || return 0
4405 [ "$RUNAS_ID" = "$UID" ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4407 # Check that testing environment is properly set up. Skip if not
4408 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS || {
4409 skip_env "User $RUNAS_ID does not exist - skipping"
4412 # We had better clear the $DIR to get enough space for dd
4417 $RUNAS dd if=/dev/zero of=$DIR/f72 bs=512 count=1 || error
4418 # See if we are still setuid/sgid
4419 test -u $DIR/f72 -o -g $DIR/f72 && error "S/gid is not dropped on write"
4420 # Now test that MDS is updated too
4421 cancel_lru_locks mdc
4422 test -u $DIR/f72 -o -g $DIR/f72 && error "S/gid is not dropped on MDS"
4426 run_test 72a "Test that remove suid works properly (bug5695) ===="
4428 test_72b() { # bug 24226 -- keep mode setting when size is not changing
4431 [ "$RUNAS_ID" = "$UID" ] && \
4432 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4433 [ "$RUNAS_ID" -eq 0 ] && \
4434 skip_env "RUNAS_ID = 0 -- skipping" && return
4436 # Check that testing environment is properly set up. Skip if not
4437 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS || {
4438 skip_env "User $RUNAS_ID does not exist - skipping"
4441 touch $DIR/${tfile}-f{g,u}
4442 mkdir $DIR/${tfile}-d{g,u}
4443 chmod 770 $DIR/${tfile}-{f,d}{g,u}
4444 chmod g+s $DIR/${tfile}-{f,d}g
4445 chmod u+s $DIR/${tfile}-{f,d}u
4446 for perm in 777 2777 4777; do
4447 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
4448 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
4449 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
4450 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
4454 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
4456 # bug 3462 - multiple simultaneous MDC requests
4460 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
4463 lctl set_param fail_loc=0x80000129
4464 $MULTIOP $DIR/d73-1/f73-2 Oc &
4466 lctl set_param fail_loc=0
4468 $MULTIOP $DIR/d73-2/f73-3 Oc &
4472 wait $pid1 || return 1
4476 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
4477 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
4478 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
4482 run_test 73 "multiple MDC requests (should not deadlock)"
4484 test_74a() { # bug 6149, 6184
4485 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
4487 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
4488 # will spin in a tight reconnection loop
4490 lctl set_param fail_loc=0x8000030e
4491 # get any lock that won't be difficult - lookup works.
4493 lctl set_param fail_loc=0
4497 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
4499 test_74b() { # bug 13310
4500 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
4502 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
4503 # will spin in a tight reconnection loop
4504 lctl set_param fail_loc=0x8000030e
4505 # get a "difficult" lock
4507 lctl set_param fail_loc=0
4511 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
4514 #define OBD_FAIL_LDLM_NEW_LOCK
4515 lctl set_param fail_loc=0x80000319
4516 touch $DIR/$tfile && error "Touch successful"
4519 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
4522 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
4525 get_inode_slab_tunables() {
4526 awk '/lustre_inode_cache/ {print $9," ",$10," ",$11; exit}' /proc/slabinfo
4529 set_inode_slab_tunables() {
4530 echo "lustre_inode_cache $1" > /proc/slabinfo
4533 test_76() { # Now for bug 20433, added originally in bug 1443
4534 local SLAB_SETTINGS=`get_inode_slab_tunables`
4535 local CPUS=`getconf _NPROCESSORS_ONLN`
4536 # we cannot set limit below 1 which means 1 inode in each
4537 # per-cpu cache is still allowed
4538 set_inode_slab_tunables "1 1 0"
4539 cancel_lru_locks osc
4540 BEFORE_INODES=`num_inodes`
4541 echo "before inodes: $BEFORE_INODES"
4543 [ "$SLOW" = "no" ] && COUNT=100
4544 for i in `seq $COUNT`; do
4548 cancel_lru_locks osc
4549 AFTER_INODES=`num_inodes`
4550 echo "after inodes: $AFTER_INODES"
4552 while [ $((AFTER_INODES-1*CPUS)) -gt $BEFORE_INODES ]; do
4554 AFTER_INODES=`num_inodes`
4556 echo "wait $wait seconds inodes: $AFTER_INODES"
4557 if [ $wait -gt 30 ]; then
4558 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
4561 set_inode_slab_tunables "$SLAB_SETTINGS"
4563 run_test 76 "confirm clients recycle inodes properly ===="
4569 # Note: in sptlrpc modes which enable its own bulk checksum, the
4570 # original crc32_le bulk checksum will be automatically disabled,
4571 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
4572 # will be checked by sptlrpc code against sptlrpc bulk checksum.
4573 # In this case set_checksums() will not be no-op, because sptlrpc
4574 # bulk checksum will be enabled all through the test.
4576 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
4577 lctl set_param -n osc.*.checksums $1
4581 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
4582 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
4583 CKSUM_TYPES=${CKSUM_TYPES:-"crc32 adler"}
4584 [ "$ORIG_CSUM_TYPE" = "crc32c" ] && CKSUM_TYPES="$CKSUM_TYPES crc32c"
4587 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
4588 log "set checksum type to $1"
4591 F77_TMP=$TMP/f77-temp
4594 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
4595 error "error writing to $F77_TMP"
4598 test_77a() { # bug 10889
4599 $GSS && skip "could not run with gss" && return
4600 [ ! -f $F77_TMP ] && setup_f77
4602 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
4606 run_test 77a "normal checksum read/write operation ============="
4608 test_77b() { # bug 10889
4609 $GSS && skip "could not run with gss" && return
4610 [ ! -f $F77_TMP ] && setup_f77
4611 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
4612 lctl set_param fail_loc=0x80000409
4614 dd if=$F77_TMP of=$DIR/f77b bs=1M count=$F77SZ conv=sync || \
4615 error "dd error: $?"
4616 lctl set_param fail_loc=0
4619 run_test 77b "checksum error on client write ===================="
4621 test_77c() { # bug 10889
4622 $GSS && skip "could not run with gss" && return
4623 [ ! -f $DIR/f77b ] && skip "requires 77b - skipping" && return
4625 for algo in $CKSUM_TYPES; do
4626 cancel_lru_locks osc
4627 set_checksum_type $algo
4628 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
4629 lctl set_param fail_loc=0x80000408
4630 cmp $F77_TMP $DIR/f77b || error "file compare failed"
4631 lctl set_param fail_loc=0
4634 set_checksum_type $ORIG_CSUM_TYPE
4637 run_test 77c "checksum error on client read ==================="
4639 test_77d() { # bug 10889
4640 $GSS && skip "could not run with gss" && return
4641 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
4642 lctl set_param fail_loc=0x80000409
4644 directio write $DIR/f77 0 $F77SZ $((1024 * 1024)) || \
4645 error "direct write: rc=$?"
4646 lctl set_param fail_loc=0
4649 run_test 77d "checksum error on OST direct write ==============="
4651 test_77e() { # bug 10889
4652 $GSS && skip "could not run with gss" && return
4653 [ ! -f $DIR/f77 ] && skip "requires 77d - skipping" && return
4654 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
4655 lctl set_param fail_loc=0x80000408
4657 cancel_lru_locks osc
4658 directio read $DIR/f77 0 $F77SZ $((1024 * 1024)) || \
4659 error "direct read: rc=$?"
4660 lctl set_param fail_loc=0
4663 run_test 77e "checksum error on OST direct read ================"
4665 test_77f() { # bug 10889
4666 $GSS && skip "could not run with gss" && return
4668 for algo in $CKSUM_TYPES; do
4669 cancel_lru_locks osc
4670 set_checksum_type $algo
4671 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
4672 lctl set_param fail_loc=0x409
4673 directio write $DIR/f77 0 $F77SZ $((1024 * 1024)) && \
4674 error "direct write succeeded"
4675 lctl set_param fail_loc=0
4677 set_checksum_type $ORIG_CSUM_TYPE
4680 run_test 77f "repeat checksum error on write (expect error) ===="
4682 test_77g() { # bug 10889
4683 $GSS && skip "could not run with gss" && return
4684 remote_ost_nodsh && skip "remote OST with nodsh" && return
4686 [ ! -f $F77_TMP ] && setup_f77
4688 $SETSTRIPE -c 1 -i 0 $DIR/f77g
4689 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
4690 do_facet ost1 lctl set_param fail_loc=0x8000021a
4692 dd if=$F77_TMP of=$DIR/f77g bs=1M count=$F77SZ || \
4693 error "write error: rc=$?"
4694 do_facet ost1 lctl set_param fail_loc=0
4697 run_test 77g "checksum error on OST write ======================"
4699 test_77h() { # bug 10889
4700 $GSS && skip "could not run with gss" && return
4701 remote_ost_nodsh && skip "remote OST with nodsh" && return
4703 [ ! -f $DIR/f77g ] && skip "requires 77g - skipping" && return
4704 cancel_lru_locks osc
4705 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
4706 do_facet ost1 lctl set_param fail_loc=0x8000021b
4708 cmp $F77_TMP $DIR/f77g || error "file compare failed"
4709 do_facet ost1 lctl set_param fail_loc=0
4712 run_test 77h "checksum error on OST read ======================="
4714 test_77i() { # bug 13805
4715 $GSS && skip "could not run with gss" && return
4716 #define OBD_FAIL_OSC_CONNECT_CKSUM 0x40b
4717 lctl set_param fail_loc=0x40b
4718 remount_client $MOUNT
4719 lctl set_param fail_loc=0
4720 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
4721 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
4722 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
4723 [ "$algo" = "crc32" ] || error "algo set to $algo instead of crc32"
4725 remount_client $MOUNT
4727 run_test 77i "client not supporting OSD_CONNECT_CKSUM =========="
4729 test_77j() { # bug 13805
4730 $GSS && skip "could not run with gss" && return
4731 #define OBD_FAIL_OSC_CKSUM_ADLER_ONLY 0x40c
4732 lctl set_param fail_loc=0x40c
4733 remount_client $MOUNT
4734 lctl set_param fail_loc=0
4735 sleep 2 # wait async osc connect to finish
4736 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
4737 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
4738 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
4739 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
4741 remount_client $MOUNT
4743 run_test 77j "client only supporting ADLER32 ===================="
4745 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
4749 test_78() { # bug 10901
4750 remote_ost || { skip_env "local OST" && return; }
4753 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
4754 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
4755 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
4756 echo "MemTotal: $MEMTOTAL"
4757 # reserve 256MB of memory for the kernel and other running processes,
4758 # and then take 1/2 of the remaining memory for the read/write buffers.
4759 if [ $MEMTOTAL -gt 512 ] ;then
4760 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
4762 # for those poor memory-starved high-end clusters...
4763 MEMTOTAL=$((MEMTOTAL / 2))
4765 echo "Mem to use for directio: $MEMTOTAL"
4766 [ $F78SIZE -gt $MEMTOTAL ] && F78SIZE=$MEMTOTAL
4767 [ $F78SIZE -gt 512 ] && F78SIZE=512
4768 [ $F78SIZE -gt $((MAXFREE / 1024)) ] && F78SIZE=$((MAXFREE / 1024))
4769 SMALLESTOST=`lfs df $DIR |grep OST | awk '{print $4}' |sort -n |head -1`
4770 echo "Smallest OST: $SMALLESTOST"
4771 [ $SMALLESTOST -lt 10240 ] && \
4772 skip "too small OSTSIZE, useless to run large O_DIRECT test" && return 0
4774 [ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ] && \
4775 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
4777 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
4778 echo "File size: $F78SIZE"
4779 $SETSTRIPE -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
4780 for i in `seq 1 $NSEQ`
4782 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
4783 echo directIO rdwr round $i of $NSEQ
4784 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
4789 run_test 78 "handle large O_DIRECT writes correctly ============"
4791 test_79() { # bug 12743
4792 wait_delete_completed
4794 BKTOTAL=$(calc_osc_kbytes kbytestotal)
4795 BKFREE=$(calc_osc_kbytes kbytesfree)
4796 BKAVAIL=$(calc_osc_kbytes kbytesavail)
4798 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
4799 DFTOTAL=`echo $STRING | cut -d, -f1`
4800 DFUSED=`echo $STRING | cut -d, -f2`
4801 DFAVAIL=`echo $STRING | cut -d, -f3`
4802 DFFREE=$(($DFTOTAL - $DFUSED))
4804 ALLOWANCE=$((64 * $OSTCOUNT))
4806 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
4807 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
4808 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
4810 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
4811 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
4812 error "df free($DFFREE) mismatch OST free($BKFREE)"
4814 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
4815 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
4816 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
4819 run_test 79 "df report consistency check ======================="
4821 test_80() { # bug 10718
4822 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
4824 local BEFORE=`date +%s`
4825 cancel_lru_locks osc
4826 local AFTER=`date +%s`
4827 local DIFF=$((AFTER-BEFORE))
4828 if [ $DIFF -gt 1 ] ; then
4829 error "elapsed for 1M@1T = $DIFF"
4834 run_test 80 "Page eviction is equally fast at high offsets too ===="
4836 test_81a() { # LU-456
4837 remote_ost_nodsh && skip "remote OST with nodsh" && return
4838 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
4839 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
4840 do_facet ost0 lctl set_param fail_loc=0x80000228
4842 # write should trigger a retry and success
4843 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
4844 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
4846 if [ $RC -ne 0 ] ; then
4847 error "write should success, but failed for $RC"
4850 run_test 81a "OST should retry write when get -ENOSPC ==============="
4852 test_81b() { # LU-456
4853 remote_ost_nodsh && skip "remote OST with nodsh" && return
4854 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
4855 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
4856 do_facet ost0 lctl set_param fail_loc=0x228
4858 # write should retry several times and return -ENOSPC finally
4859 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
4860 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
4863 if [ $RC -ne $ENOSPC ] ; then
4864 error "dd should fail for -ENOSPC, but succeed."
4867 run_test 81b "OST should return -ENOSPC when retry still fails ======="
4869 test_82() { # LU-1031
4870 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10
4874 multiop_bg_pause $DIR/$tfile OG${gid1}_g${gid1}c || return 1
4876 multiop_bg_pause $DIR/$tfile O_G${gid2}r10g${gid2}c || return 2
4878 kill -USR1 $MULTIPID2
4880 if [[ `ps h -o comm -p $MULTIPID2` == "" ]]; then
4881 error "First grouplock does not block second one"
4883 echo "Second grouplock blocks first one"
4885 kill -USR1 $MULTIPID1
4889 run_test 82 "Basic grouplock test ==============================="
4892 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && \
4894 mkdir -p $DIR/d99cvsroot
4895 chown $RUNAS_ID $DIR/d99cvsroot
4896 local oldPWD=$PWD # bug 13584, use $TMP as working dir
4899 $RUNAS cvs -d $DIR/d99cvsroot init || error
4902 run_test 99a "cvs init ========================================="
4905 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
4906 [ ! -d $DIR/d99cvsroot ] && test_99a
4908 # some versions of cvs import exit(1) when asked to import links or
4909 # files they can't read. ignore those files.
4910 TOIGNORE=$(find . -type l -printf '-I %f\n' -o \
4911 ! -perm +4 -printf '-I %f\n')
4912 $RUNAS cvs -d $DIR/d99cvsroot import -m "nomesg" $TOIGNORE \
4913 d99reposname vtag rtag
4915 run_test 99b "cvs import ======================================="
4918 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
4919 [ ! -d $DIR/d99cvsroot ] && test_99b
4921 mkdir -p $DIR/d99reposname
4922 chown $RUNAS_ID $DIR/d99reposname
4923 $RUNAS cvs -d $DIR/d99cvsroot co d99reposname
4925 run_test 99c "cvs checkout ====================================="
4928 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
4929 [ ! -d $DIR/d99cvsroot ] && test_99c
4930 cd $DIR/d99reposname
4932 $RUNAS cvs add -m 'addmsg' foo99
4934 run_test 99d "cvs add =========================================="
4937 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
4938 [ ! -d $DIR/d99cvsroot ] && test_99c
4939 cd $DIR/d99reposname
4942 run_test 99e "cvs update ======================================="
4945 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
4946 [ ! -d $DIR/d99cvsroot ] && test_99d
4947 cd $DIR/d99reposname
4948 $RUNAS cvs commit -m 'nomsg' foo99
4949 rm -fr $DIR/d99cvsroot
4951 run_test 99f "cvs commit ======================================="
4954 [ "$NETTYPE" = tcp ] || \
4955 { skip "TCP secure port test, not useful for NETTYPE=$NETTYPE" && \
4958 remote_ost_nodsh && skip "remote OST with nodsh" && return
4959 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4961 { skip "useless for local single node setup" && return; }
4963 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
4964 [ "$PROT" != "tcp" ] && continue
4965 RPORT=$(echo $REMOTE | cut -d: -f2)
4966 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
4969 LPORT=`echo $LOCAL | cut -d: -f2`
4970 if [ $LPORT -ge 1024 ]; then
4971 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
4973 error_exit "local: $LPORT > 1024, remote: $RPORT"
4976 [ "$rc" = 0 ] || error_exit "privileged port not found" )
4978 run_test 100 "check local port using privileged port ==========="
4980 function get_named_value()
4989 echo $line | sed "s/^$tag[ ]*//"
4996 export CACHE_MAX=`$LCTL get_param -n llite.*.max_cached_mb | head -n 1`
4998 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
5006 [ "$CPU" = "UML" ] && nreads=1000
5007 local cache_limit=32
5009 $LCTL set_param -n osc.*-osc*.rpc_stats 0
5010 trap cleanup_101a EXIT
5011 $LCTL set_param -n llite.*.read_ahead_stats 0
5012 $LCTL set_param -n llite.*.max_cached_mb $cache_limit
5015 # randomly read 10000 of 64K chunks from file 3x 32MB in size
5017 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
5018 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
5021 for s in `$LCTL get_param -n llite.*.read_ahead_stats | \
5022 get_named_value 'read but discarded' | cut -d" " -f1`; do
5023 discard=$(($discard + $s))
5027 if [ $(($discard * 10)) -gt $nreads ] ;then
5028 $LCTL get_param osc.*-osc*.rpc_stats
5029 $LCTL get_param llite.*.read_ahead_stats
5030 error "too many ($discard) discarded pages"
5032 rm -f $DIR/$tfile || true
5034 run_test 101a "check read-ahead for random reads ================"
5039 STRIPE_COUNT=$OSTCOUNT
5042 local list=$(comma_list $(osts_nodes))
5043 do_nodes $list $LCTL set_param -n obdfilter.*.read_cache_enable=0
5044 do_nodes $list $LCTL set_param -n obdfilter.*.writethrough_cache_enable=0
5046 trap cleanup_test101bc EXIT
5047 # prepare the read-ahead file
5048 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
5050 dd if=/dev/zero of=$DIR/$tfile bs=1024k count=100 2> /dev/null
5053 cleanup_test101bc() {
5058 local list=$(comma_list $(osts_nodes))
5059 do_nodes $list $LCTL set_param -n obdfilter.*.read_cache_enable=1
5060 do_nodes $list $LCTL set_param -n obdfilter.*.writethrough_cache_enable=1
5064 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
5069 local STRIPE_SIZE=1048576
5070 local RA_INC=1048576
5071 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
5072 local FILE_LENGTH=$((64*100))
5073 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
5074 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
5075 DISCARD=`$LCTL get_param -n llite.*.read_ahead_stats | \
5076 get_named_value 'read but discarded' | \
5077 cut -d" " -f1 | calc_total`
5078 if [ $DISCARD -gt $discard_limit ]; then
5079 $LCTL get_param llite.*.read_ahead_stats
5080 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
5082 echo "Read-ahead success for size ${READ_SIZE}"
5087 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping stride IO stride-ahead test" && return
5088 local STRIPE_SIZE=1048576
5089 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
5090 local FILE_LENGTH=$((STRIPE_SIZE*100))
5091 local ITERATION=$((FILE_LENGTH/STRIDE_SIZE))
5092 # prepare the read-ahead file
5094 cancel_lru_locks osc
5095 for BIDX in 2 4 8 16 32 64 128 256
5097 local BSIZE=$((BIDX*4096))
5098 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
5099 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
5100 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
5101 $LCTL set_param -n llite.*.read_ahead_stats 0
5102 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
5103 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
5104 cancel_lru_locks osc
5110 run_test 101b "check stride-io mode read-ahead ================="
5113 local STRIPE_SIZE=1048576
5114 local FILE_LENGTH=$((STRIPE_SIZE*100))
5120 cancel_lru_locks osc
5121 $LCTL set_param osc.*.rpc_stats 0
5122 $READS -f $DIR/$tfile -s$FILE_LENGTH -b65536 -n$nreads -t 180
5123 for osc in $($LCTL get_param -N osc.*); do
5124 if [ "$osc" == "osc.num_refs" ]; then
5128 local lines=$($LCTL get_param -n ${osc}.rpc_stats | wc | awk '{print $1}')
5129 if [ $lines -le 20 ]; then
5133 local rpc4k=$($LCTL get_param -n ${osc}.rpc_stats |
5134 awk '$1 == "1:" { print $2; exit; }')
5135 local rpc8k=$($LCTL get_param -n ${osc}.rpc_stats |
5136 awk '$1 == "2:" { print $2; exit; }')
5137 local rpc16k=$($LCTL get_param -n ${osc}.rpc_stats |
5138 awk '$1 == "4:" { print $2; exit; }')
5139 local rpc32k=$($LCTL get_param -n ${osc}.rpc_stats |
5140 awk '$1 == "8:" { print $2; exit; }')
5142 [ $rpc4k != 0 ] && error "Small 4k read IO ${rpc4k}!"
5143 [ $rpc8k != 0 ] && error "Small 8k read IO ${rpc8k}!"
5144 [ $rpc16k != 0 ] && error "Small 16k read IO ${rpc16k}!"
5145 [ $rpc32k != 0 ] && error "Small 32k read IO ${rpc32k}!"
5146 echo "${osc} rpc check passed!"
5151 run_test 101c "check stripe_size aligned read-ahead ================="
5154 $LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1
5155 $LCTL set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
5159 local file=$DIR/$tfile
5160 local size=${FILESIZE_101c:-500}
5161 local ra_MB=${READAHEAD_MB:-40}
5163 local space=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
5164 [ $space -gt $((size / 1024)) ] ||
5165 { skip "Need free space ${size}M, have $space" && return; }
5167 echo Creating ${size}M test file $file
5168 dd if=/dev/zero of=$file bs=1M count=$size
5169 echo Cancel LRU locks on lustre client to flush the client cache
5170 cancel_lru_locks osc
5172 echo Disable read-ahead
5173 local old_READAHEAD=$(set_read_ahead 0)
5175 echo Reading the test file $file with read-ahead disabled
5176 time_ra_OFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$size")
5178 echo Cancel LRU locks on lustre client to flush the client cache
5179 cancel_lru_locks osc
5180 echo Enable read-ahead with ${ra_MB}MB
5181 set_read_ahead $ra_MB
5183 echo Reading the test file $file with read-ahead enabled
5184 time_ra_ON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$size")
5186 echo read-ahead disabled time read $time_ra_OFF
5187 echo read-ahead enabled time read $time_ra_ON
5189 set_read_ahead $old_READAHEAD
5192 [ $time_ra_ON -lt $time_ra_OFF ] ||
5193 error "read-ahead enabled time read (${time_ra_ON}s) is more than
5194 read-ahead disabled time read (${time_ra_OFF}s) filesize ${size}M"
5196 run_test 101d "file read with and without read-ahead enabled ================="
5199 local file=$DIR/$tfile
5204 local space=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
5205 local need_space=$((count * size))
5206 [ $space -gt $need_space ] ||
5207 { skip_env "Need free space $need_space, have $space" && return; }
5209 echo Creating $count ${size}K test files
5210 for ((i = 0; i < $count; i++)); do
5211 dd if=/dev/zero of=${file}_${i} bs=$blksize count=$size 2>/dev/null
5214 echo Cancel LRU locks on lustre client to flush the client cache
5215 cancel_lru_locks osc
5217 echo Reset readahead stats
5218 $LCTL set_param -n llite.*.read_ahead_stats 0
5220 for ((i = 0; i < $count; i++)); do
5221 dd if=${file}_${i} of=/dev/null bs=$blksize count=$size 2>/dev/null
5224 local miss=$($LCTL get_param -n llite.*.read_ahead_stats | \
5225 get_named_value 'misses' | cut -d" " -f1 | calc_total)
5227 for ((i = 0; i < $count; i++)); do
5228 rm -rf ${file}_${i} 2>/dev/null
5231 #10000 means 20% reads are missing in readahead
5232 [ $miss -lt 10000 ] || error "misses too much for small reads"
5234 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
5236 cleanup_test101f() {
5238 $LCTL set_param -n llite.*.max_read_ahead_whole_mb $MAX_WHOLE_MB
5239 rm -rf $DIR/$tfile 2>/dev/null
5243 local file=$DIR/$tfile
5246 MAX_WHOLE_MB=$($LCTL get_param -n llite.*.max_read_ahead_whole_mb)
5247 $LCTL set_param -n llite.*.max_read_ahead_whole_mb 2
5248 dd if=/dev/zero of=${file} bs=2097152 count=1 2>/dev/null
5249 trap cleanup_test101f EXIT
5251 echo Cancel LRU locks on lustre client to flush the client cache
5252 cancel_lru_locks osc
5254 echo Reset readahead stats
5255 $LCTL set_param -n llite.*.read_ahead_stats 0
5256 # Random read in a 2M file, because max_read_ahead_whole_mb = 2M,
5257 # readahead should read in 2M file on second read, so only miss
5259 echo Random 4K reads on 2M file for 1000 times
5260 $READS -f $file -s 2097152 -b 4096 -n $nreads
5262 echo checking missing pages
5263 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
5264 get_named_value 'misses' | cut -d" " -f1 | calc_total)
5266 [ $miss -lt 3 ] || error "misses too much pages!"
5269 run_test 101f "check read-ahead for max_read_ahead_whole_mb"
5273 chown $RUNAS_ID $DIR/$tdir
5276 STRIPE_COUNT=$OSTCOUNT
5277 [ $OSTCOUNT -gt 4 ] && STRIPE_COUNT=4
5279 trap cleanup_test102 EXIT
5281 $1 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
5283 for num in 1 2 3 4; do
5284 for count in $(seq 1 $STRIPE_COUNT); do
5285 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
5286 local size=`expr $STRIPE_SIZE \* $num`
5287 local file=file"$num-$idx-$count"
5288 $1 $SETSTRIPE -S $size -i $idx -c $count $file
5294 $1 $TAR cf $TMP/f102.tar $tdir --xattrs
5300 rm -rf $DIR/d0.sanity/d102
5304 local testfile=$DIR/xattr_testfile
5308 [ "$UID" != 0 ] && skip_env "must run as root" && return
5309 [ -z "`lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr`" ] &&
5310 skip_env "must have user_xattr" && return
5312 [ -z "$(which setfattr 2>/dev/null)" ] &&
5313 skip_env "could not find setfattr" && return
5315 echo "set/get xattr..."
5316 setfattr -n trusted.name1 -v value1 $testfile || error
5317 getfattr -n trusted.name1 $testfile 2> /dev/null |
5318 grep "trusted.name1=.value1" ||
5319 error "$testfile missing trusted.name1=value1"
5321 setfattr -n user.author1 -v author1 $testfile || error
5322 getfattr -n user.author1 $testfile 2> /dev/null |
5323 grep "user.author1=.author1" ||
5324 error "$testfile missing trusted.author1=author1"
5327 setfattr -n trusted.name2 -v value2 $testfile ||
5328 error "$testfile unable to set trusted.name2"
5329 setfattr -n trusted.name3 -v value3 $testfile ||
5330 error "$testfile unable to set trusted.name3"
5331 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
5332 grep "trusted.name" | wc -l) -eq 3 ] ||
5333 error "$testfile missing 3 trusted.name xattrs"
5335 setfattr -n user.author2 -v author2 $testfile ||
5336 error "$testfile unable to set user.author2"
5337 setfattr -n user.author3 -v author3 $testfile ||
5338 error "$testfile unable to set user.author3"
5339 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
5340 grep "user.author" | wc -l) -eq 3 ] ||
5341 error "$testfile missing 3 user.author xattrs"
5343 echo "remove xattr..."
5344 setfattr -x trusted.name1 $testfile ||
5345 error "$testfile error deleting trusted.name1"
5346 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
5347 error "$testfile did not delete trusted.name1 xattr"
5349 setfattr -x user.author1 $testfile ||
5350 error "$testfile error deleting user.author1"
5351 getfattr -d -m user $testfile 2> /dev/null | grep "user.author1" &&
5352 error "$testfile did not delete trusted.name1 xattr"
5354 # b10667: setting lustre special xattr be silently discarded
5355 echo "set lustre special xattr ..."
5356 setfattr -n "trusted.lov" -v "invalid value" $testfile ||
5357 error "$testfile allowed setting trusted.lov"
5359 run_test 102a "user xattr test =================================="
5362 # b10930: get/set/list trusted.lov xattr
5363 echo "get/set/list trusted.lov xattr ..."
5364 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
5365 local testfile=$DIR/$tfile
5366 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
5367 error "setstripe failed"
5368 local STRIPECOUNT=$($GETSTRIPE -c $testfile) ||
5369 error "getstripe failed"
5370 getfattr -d -m "^trusted" $testfile 2> /dev/null | \
5371 grep "trusted.lov" || error "can't get trusted.lov from $testfile"
5373 local testfile2=${testfile}2
5374 local value=`getfattr -n trusted.lov $testfile 2> /dev/null | \
5375 grep "trusted.lov" |sed -e 's/[^=]\+=//'`
5378 setfattr -n trusted.lov -v $value $testfile2
5379 local stripe_size=$($GETSTRIPE -S $testfile2)
5380 local stripe_count=$($GETSTRIPE -c $testfile2)
5381 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
5382 [ $stripe_count -eq $STRIPECOUNT ] ||
5383 error "stripe count $stripe_count != $STRIPECOUNT"
5386 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
5389 # b10930: get/set/list lustre.lov xattr
5390 echo "get/set/list lustre.lov xattr ..."
5391 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
5393 chown $RUNAS_ID $DIR/$tdir
5394 local testfile=$DIR/$tdir/$tfile
5395 $RUNAS $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
5396 error "setstripe failed"
5397 local STRIPECOUNT=$($RUNAS $GETSTRIPE -c $testfile) ||
5398 error "getstripe failed"
5399 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
5400 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
5402 local testfile2=${testfile}2
5403 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
5404 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
5406 $RUNAS $MCREATE $testfile2
5407 $RUNAS setfattr -n lustre.lov -v $value $testfile2
5408 local stripe_size=$($RUNAS $GETSTRIPE -S $testfile2)
5409 local stripe_count=$($RUNAS $GETSTRIPE -c $testfile2)
5410 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
5411 [ $stripe_count -eq $STRIPECOUNT ] ||
5412 error "stripe count $stripe_count != $STRIPECOUNT"
5414 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
5416 compare_stripe_info1() {
5417 local stripe_index_all_zero=true
5419 for num in 1 2 3 4; do
5420 for count in $(seq 1 $STRIPE_COUNT); do
5421 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
5422 local size=$((STRIPE_SIZE * num))
5423 local file=file"$num-$offset-$count"
5424 stripe_size=$(lfs getstripe -S $PWD/$file)
5425 [ $stripe_size -ne $size ] &&
5426 error "$file: size $stripe_size != $size"
5427 stripe_count=$(lfs getstripe -c $PWD/$file)
5428 # allow fewer stripes to be created, ORI-601
5429 [ $stripe_count -lt $(((3 * count + 3) / 4)) ]&&
5430 error "$file: count $stripe_count != $count"
5431 stripe_index=$(lfs getstripe -i $PWD/$file)
5432 [ $stripe_index -ne 0 ] &&
5433 stripe_index_all_zero=false
5437 $stripe_index_all_zero &&
5438 error "all files are being extracted starting from OST index 0"
5443 [ -n "$(which tar 2>/dev/null)" ] &&
5444 strings $(which tar) | grep -q "lustre" && echo tar
5448 # b10930: tar test for trusted.lov xattr
5449 TAR=$(find_lustre_tar)
5450 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
5451 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
5454 $TAR xf $TMP/f102.tar -C $DIR/d102d --xattrs
5456 compare_stripe_info1
5458 run_test 102d "tar restore stripe info from tarfile,not keep osts ==========="
5461 # b10930: tar test for trusted.lov xattr
5462 TAR=$(find_lustre_tar)
5463 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
5464 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
5468 $TAR cf - --xattrs $tdir | $TAR xf - --xattrs -C $DIR/d102f
5470 compare_stripe_info1
5472 run_test 102f "tar copy files, not keep osts ==========="
5475 local xsize=${1:-1024} # in bytes
5476 local file=$DIR/$tfile
5478 [ -z $(lctl get_param -n mdc.*.connect_flags | grep xattr) ] &&
5479 skip "must have user_xattr" && return 0
5480 [ -z "$(which setfattr 2>/dev/null)" ] &&
5481 skip_env "could not find setfattr" && return 0
5482 [ -z "$(which getfattr 2>/dev/null)" ] &&
5483 skip_env "could not find getfattr" && return 0
5487 local value="$(generate_string $xsize)"
5489 local xbig=trusted.big
5490 log "save $xbig on $file"
5491 setfattr -n $xbig -v $value $file ||
5492 error "saving $xbig on $file failed"
5494 local orig=$(get_xattr_value $xbig $file)
5495 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
5497 local xsml=trusted.sml
5498 log "save $xsml on $file"
5499 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
5501 local new=$(get_xattr_value $xbig $file)
5502 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
5504 log "grow $xsml on $file"
5505 setfattr -n $xsml -v "$value" $file ||
5506 error "growing $xsml on $file failed"
5508 new=$(get_xattr_value $xbig $file)
5509 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
5510 log "$xbig still valid after growing $xsml"
5515 test_102h() { # bug 15777
5518 run_test 102h "grow xattr from inside inode to external block"
5521 large_xattr_enabled || { skip "large_xattr disabled" && return; }
5522 grow_xattr $(max_xattr_size)
5524 run_test 102ha "grow xattr from inside inode to external inode"
5526 test_102i() { # bug 17038
5528 ln -s $DIR/$tfile $DIR/${tfile}link
5529 getfattr -n trusted.lov $DIR/$tfile || error "lgetxattr on $DIR/$tfile failed"
5530 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"
5531 rm -f $DIR/$tfile $DIR/${tfile}link
5533 run_test 102i "lgetxattr test on symbolic link ============"
5536 TAR=$(find_lustre_tar)
5537 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
5538 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
5539 setup_test102 "$RUNAS"
5541 chown $RUNAS_ID $DIR/d102j
5542 $RUNAS $TAR xf $TMP/f102.tar -C $DIR/d102j --xattrs
5544 compare_stripe_info1 "$RUNAS"
5546 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
5550 # b22187 just check that does not crash for regular file.
5551 setfattr -n trusted.lov $DIR/$tfile
5552 # b22187 'setfattr -n trusted.lov' should work as remove LOV EA for directories
5553 local test_kdir=$DIR/d102k
5555 local default_size=`$GETSTRIPE -S $test_kdir`
5556 local default_count=`$GETSTRIPE -c $test_kdir`
5557 local default_offset=`$GETSTRIPE -i $test_kdir`
5558 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $test_kdir ||
5559 error 'dir setstripe failed'
5560 setfattr -n trusted.lov $test_kdir
5561 local stripe_size=`$GETSTRIPE -S $test_kdir`
5562 local stripe_count=`$GETSTRIPE -c $test_kdir`
5563 local stripe_offset=`$GETSTRIPE -i $test_kdir`
5564 [ $stripe_size -eq $default_size ] ||
5565 error "stripe size $stripe_size != $default_size"
5566 [ $stripe_count -eq $default_count ] ||
5567 error "stripe count $stripe_count != $default_count"
5568 [ $stripe_offset -eq $default_offset ] ||
5569 error "stripe offset $stripe_offset != $default_offset"
5570 rm -rf $DIR/$tfile $test_kdir
5572 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
5575 # LU-532 trusted. xattr is invisible to non-root
5576 local testfile=$DIR/$tfile
5580 echo "listxattr as user..."
5581 chown $RUNAS_ID $testfile
5582 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
5583 grep -q "trusted" &&
5584 error "$testfile trusted xattrs are user visible"
5588 run_test 102l "listxattr filter test =================================="
5594 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
5599 [ "$UID" != 0 ] && skip_env "must run as root" && return
5600 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
5601 [ -z "$(which setfacl 2>/dev/null)" ] && skip_env "could not find setfacl" && return
5602 $GSS && skip "could not run under gss" && return
5604 declare -a identity_old
5606 for num in `seq $MDSCOUNT`; do
5607 switch_identity $num true || identity_old[$num]=$?
5614 echo "performing cp ..."
5615 run_acl_subtest cp || error
5616 echo "performing getfacl-noacl..."
5617 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
5618 echo "performing misc..."
5619 run_acl_subtest misc || error "misc test failed"
5620 echo "performing permissions..."
5621 run_acl_subtest permissions || error "permissions failed"
5622 echo "performing setfacl..."
5623 run_acl_subtest setfacl || error "setfacl test failed"
5625 # inheritance test got from HP
5626 echo "performing inheritance..."
5627 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
5628 chmod +x make-tree || error "chmod +x failed"
5629 run_acl_subtest inheritance || error "inheritance test failed"
5635 for num in `seq $MDSCOUNT`; do
5636 if [ "${identity_old[$num]}" = 1 ]; then
5637 switch_identity $num false || identity_old[$num]=$?
5641 run_test 103 "acl test ========================================="
5645 lfs df || error "lfs df failed"
5646 lfs df -ih || error "lfs df -ih failed"
5647 lfs df -h $DIR || error "lfs df -h $DIR failed"
5648 lfs df -i $DIR || error "lfs df -i $DIR failed"
5649 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
5650 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
5652 OSC=`lctl dl |grep OST0000-osc-[^M] |awk '{print $4}'`
5653 lctl --device %$OSC deactivate
5654 lfs df || error "lfs df with deactivated OSC failed"
5655 lctl --device %$OSC activate
5656 # wait the osc back to normal
5657 wait_osc_import_state client ost FULL
5659 lfs df || error "lfs df with reactivated OSC failed"
5662 run_test 104a "lfs df [-ih] [path] test ========================="
5665 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5667 denied_cnt=$((`$RUNAS $LFS check servers 2>&1 | grep "Permission denied" | wc -l`))
5668 if [ $denied_cnt -ne 0 ];
5670 error "lfs check servers test failed"
5673 run_test 104b "$RUNAS lfs check servers test ===================="
5676 # doesn't work on 2.4 kernels
5678 if [ -n "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ];
5680 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
5682 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
5686 run_test 105a "flock when mounted without -o flock test ========"
5690 if [ -n "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ];
5692 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
5694 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
5698 run_test 105b "fcntl when mounted without -o flock test ========"
5702 if [ -n "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ];
5704 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
5706 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
5710 run_test 105c "lockf when mounted without -o flock test ========"
5712 test_105d() { # bug 15924
5714 [ -z "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ] && \
5715 skip "mount w/o flock enabled" && return
5716 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
5717 $LCTL set_param fail_loc=0x80000315
5718 flocks_test 2 $DIR/$tdir
5720 run_test 105d "flock race (should not freeze) ========"
5722 test_105e() { # bug 22660 && 22040
5723 [ -z "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ] && \
5724 skip "mount w/o flock enabled" && return
5726 flocks_test 3 $DIR/$tfile
5728 run_test 105e "Two conflicting flocks from same process ======="
5730 test_106() { #bug 10921
5732 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
5733 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
5735 run_test 106 "attempt exec of dir followed by chown of that dir"
5744 local save_pattern=$(sysctl -n kernel.core_pattern)
5745 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
5746 sysctl -w kernel.core_pattern=$file
5747 sysctl -w kernel.core_uses_pid=0
5755 kill -s 11 $SLEEPPID
5757 if [ -e $file ]; then
5758 size=`stat -c%s $file`
5759 [ $size -eq 0 ] && error "Fail to create core file $file"
5761 error "Fail to create core file $file"
5764 sysctl -w kernel.core_pattern=$save_pattern
5765 sysctl -w kernel.core_uses_pid=$save_uses_pid
5768 run_test 107 "Coredump on SIG"
5772 mkdir $DIR/d110/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa || error "mkdir with 255 char fail"
5773 mkdir $DIR/d110/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb && error "mkdir with 256 char should fail, but not"
5774 touch $DIR/d110/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx || error "create with 255 char fail"
5775 touch $DIR/d110/yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy && error ""create with 256 char should fail, but not
5780 run_test 110 "filename length checking"
5783 OSTIO_pre=$(ps -e|grep ll_ost_io|awk '{print $4}'|sort -n|tail -1|\
5785 [ -z "$OSTIO_pre" ] && skip "no OSS threads" && \
5787 echo "Starting with $OSTIO_pre threads"
5790 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
5791 [ $NUMFREE -lt $NUMTEST ] && NUMTEST=$(($NUMFREE - 1000))
5792 echo "$NUMTEST creates/unlinks"
5794 createmany -o $DIR/$tdir/$tfile $NUMTEST
5795 unlinkmany $DIR/$tdir/$tfile $NUMTEST
5797 OSTIO_post=$(ps -e|grep ll_ost_io|awk '{print $4}'|sort -n|tail -1|\
5800 # don't return an error
5801 [ $OSTIO_post -eq $OSTIO_pre ] && echo \
5802 "WARNING: No new ll_ost_io threads were created ($OSTIO_pre)" &&\
5803 echo "This may be fine, depending on what ran before this test" &&\
5804 echo "and how fast this system is." && return
5806 echo "Started with $OSTIO_pre threads, ended with $OSTIO_post"
5808 run_test 115 "verify dynamic thread creation===================="
5811 wait_delete_completed
5812 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
5813 echo OST kbytes available: ${AVAIL[@]}
5814 MAXI=0; MAXV=${AVAIL[0]}
5815 MINI=0; MINV=${AVAIL[0]}
5816 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
5817 #echo OST $i: ${AVAIL[i]}kb
5818 if [ ${AVAIL[i]} -gt $MAXV ]; then
5819 MAXV=${AVAIL[i]}; MAXI=$i
5821 if [ ${AVAIL[i]} -lt $MINV ]; then
5822 MINV=${AVAIL[i]}; MINI=$i
5825 echo Min free space: OST $MINI: $MINV
5826 echo Max free space: OST $MAXI: $MAXV
5830 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs" && return
5832 echo -n "Free space priority "
5833 lctl get_param -n lov.*-clilov-*.qos_prio_free
5836 [ $MINV -gt 960000 ] && skip "too much free space in OST$MINI, skip" &&\
5839 # generate uneven OSTs
5840 mkdir -p $DIR/$tdir/OST${MINI}
5843 echo "Filling 25% remaining space in OST${MINI} with ${FILL}Kb"
5844 $SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI}||error "setstripe failed"
5846 while [ $FILL -gt 0 ]; do
5848 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i bs=2M count=1 2>/dev/null
5849 FILL=$(($FILL - 2048))
5857 DIFF=$(($MAXV - $MINV))
5858 DIFF2=$(($DIFF * 100 / $MINV))
5859 echo -n "diff=${DIFF}=${DIFF2}% must be > 20% for QOS mode..."
5860 if [ $DIFF2 -gt 20 ]; then
5863 echo "failed - QOS mode won't be used"
5864 error_ignore "QOS imbalance criteria not met"
5868 MINI1=$MINI; MINV1=$MINV
5869 MAXI1=$MAXI; MAXV1=$MAXV
5871 # now fill using QOS
5872 echo writing a bunch of files to QOS-assigned OSTs
5873 $SETSTRIPE -c 1 $DIR/$tdir
5875 while [ $FILL -gt 0 ]; do
5877 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1024 count=200 2>/dev/null
5878 FILL=$(($FILL - 200))
5881 echo "wrote $i 200k files"
5885 echo "Note: free space may not be updated, so measurements might be off"
5887 DIFF2=$(($MAXV - $MINV))
5888 echo "free space delta: orig $DIFF final $DIFF2"
5889 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
5890 DIFF=$(($MINV1 - ${AVAIL[$MINI1]}))
5891 echo "Wrote $DIFF to smaller OST $MINI1"
5892 DIFF2=$(($MAXV1 - ${AVAIL[$MAXI1]}))
5893 echo "Wrote $DIFF2 to larger OST $MAXI1"
5894 [ $DIFF -gt 0 ] && echo "Wrote $(($DIFF2 * 100 / $DIFF - 100))% more data to larger OST $MAXI1"
5896 # Figure out which files were written where
5897 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
5898 awk '/'$MINI1': / {print $2; exit}')
5900 MINC=$($GETSTRIPE --obd $UUID $DIR/$tdir | wc -l)
5901 echo "$MINC files created on smaller OST $MINI1"
5902 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
5903 awk '/'$MAXI1': / {print $2; exit}')
5905 MAXC=$($GETSTRIPE --obd $UUID $DIR/$tdir | wc -l)
5906 echo "$MAXC files created on larger OST $MAXI1"
5907 [ $MINC -gt 0 ] && echo "Wrote $(($MAXC * 100 / $MINC - 100))% more files to larger OST $MAXI1"
5908 [ $MAXC -gt $MINC ] || error_ignore "stripe QOS didn't balance free space"
5912 run_test 116 "stripe QOS: free space balance ==================="
5914 test_117() # bug 10891
5916 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
5917 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
5918 lctl set_param fail_loc=0x21e
5919 > $DIR/$tfile || error "truncate failed"
5920 lctl set_param fail_loc=0
5921 echo "Truncate succeeded."
5924 run_test 117 "verify fsfilt_extend =========="
5926 export OLD_RESENDCOUNT=""
5927 set_resend_count () {
5928 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
5929 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -1)
5930 lctl set_param -n $PROC_RESENDCOUNT $1
5931 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
5934 [ "$SLOW" = "no" ] && set_resend_count 4 # for reduce test_118* time (bug 14842)
5936 # Reset async IO behavior after error case
5938 FILE=$DIR/reset_async
5940 # Ensure all OSCs are cleared
5941 $SETSTRIPE -c -1 $FILE
5942 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
5947 test_118a() #bug 11710
5951 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
5952 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
5953 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
5955 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
5956 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
5961 run_test 118a "verify O_SYNC works =========="
5965 remote_ost_nodsh && skip "remote OST with nodsh" && return
5969 #define OBD_FAIL_OST_ENOENT 0x217
5970 set_nodes_failloc "$(osts_nodes)" 0x217
5971 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
5973 set_nodes_failloc "$(osts_nodes)" 0
5974 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
5975 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
5978 if [[ $RC -eq 0 ]]; then
5979 error "Must return error due to dropped pages, rc=$RC"
5983 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
5984 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
5988 echo "Dirty pages not leaked on ENOENT"
5990 # Due to the above error the OSC will issue all RPCs syncronously
5991 # until a subsequent RPC completes successfully without error.
5992 $MULTIOP $DIR/$tfile Ow4096yc
5997 run_test 118b "Reclaim dirty pages on fatal error =========="
6001 remote_ost_nodsh && skip "remote OST with nodsh" && return
6005 #define OBD_FAIL_OST_EROFS 0x216
6006 set_nodes_failloc "$(osts_nodes)" 0x216
6008 # multiop should block due to fsync until pages are written
6009 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
6013 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
6014 error "Multiop failed to block on fsync, pid=$MULTIPID"
6017 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6019 if [[ $WRITEBACK -eq 0 ]]; then
6020 error "No page in writeback, writeback=$WRITEBACK"
6023 set_nodes_failloc "$(osts_nodes)" 0
6026 if [[ $RC -ne 0 ]]; then
6027 error "Multiop fsync failed, rc=$RC"
6030 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6031 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6033 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6034 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6038 echo "Dirty pages flushed via fsync on EROFS"
6041 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
6045 remote_ost_nodsh && skip "remote OST with nodsh" && return
6049 #define OBD_FAIL_OST_BRW_PAUSE_BULK
6050 set_nodes_failloc "$(osts_nodes)" 0x214
6051 # multiop should block due to fsync until pages are written
6052 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
6056 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
6057 error "Multiop failed to block on fsync, pid=$MULTIPID"
6060 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6062 if [[ $WRITEBACK -eq 0 ]]; then
6063 error "No page in writeback, writeback=$WRITEBACK"
6066 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
6067 set_nodes_failloc "$(osts_nodes)" 0
6069 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6070 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6072 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6073 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6077 echo "Dirty pages gaurenteed flushed via fsync"
6080 run_test 118d "Fsync validation inject a delay of the bulk =========="
6085 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
6086 lctl set_param fail_loc=0x8000040a
6088 # Should simulate EINVAL error which is fatal
6089 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6091 if [[ $RC -eq 0 ]]; then
6092 error "Must return error due to dropped pages, rc=$RC"
6095 lctl set_param fail_loc=0x0
6097 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6098 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6099 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6101 if [[ $LOCKED -ne 0 ]]; then
6102 error "Locked pages remain in cache, locked=$LOCKED"
6105 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6106 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6110 echo "No pages locked after fsync"
6115 run_test 118f "Simulate unrecoverable OSC side error =========="
6120 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
6121 lctl set_param fail_loc=0x406
6123 # simulate local -ENOMEM
6124 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6127 lctl set_param fail_loc=0
6128 if [[ $RC -eq 0 ]]; then
6129 error "Must return error due to dropped pages, rc=$RC"
6132 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6133 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6134 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6136 if [[ $LOCKED -ne 0 ]]; then
6137 error "Locked pages remain in cache, locked=$LOCKED"
6140 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6141 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6145 echo "No pages locked after fsync"
6150 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
6153 remote_ost_nodsh && skip "remote OST with nodsh" && return
6157 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
6158 set_nodes_failloc "$(osts_nodes)" 0x20e
6159 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
6160 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6163 set_nodes_failloc "$(osts_nodes)" 0
6164 if [[ $RC -eq 0 ]]; then
6165 error "Must return error due to dropped pages, rc=$RC"
6168 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6169 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6170 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6172 if [[ $LOCKED -ne 0 ]]; then
6173 error "Locked pages remain in cache, locked=$LOCKED"
6176 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6177 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6181 echo "No pages locked after fsync"
6185 run_test 118h "Verify timeout in handling recoverables errors =========="
6188 remote_ost_nodsh && skip "remote OST with nodsh" && return
6192 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
6193 set_nodes_failloc "$(osts_nodes)" 0x20e
6195 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
6196 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
6199 set_nodes_failloc "$(osts_nodes)" 0
6203 if [[ $RC -ne 0 ]]; then
6204 error "got error, but should be not, rc=$RC"
6207 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6208 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6209 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
6210 if [[ $LOCKED -ne 0 ]]; then
6211 error "Locked pages remain in cache, locked=$LOCKED"
6214 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6215 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6219 echo "No pages locked after fsync"
6223 run_test 118i "Fix error before timeout in recoverable error =========="
6226 remote_ost_nodsh && skip "remote OST with nodsh" && return
6230 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
6231 set_nodes_failloc "$(osts_nodes)" 0x220
6233 # return -EIO from OST
6234 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6236 set_nodes_failloc "$(osts_nodes)" 0x0
6237 if [[ $RC -eq 0 ]]; then
6238 error "Must return error due to dropped pages, rc=$RC"
6241 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6242 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6243 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
6244 if [[ $LOCKED -ne 0 ]]; then
6245 error "Locked pages remain in cache, locked=$LOCKED"
6248 # in recoverable error on OST we want resend and stay until it finished
6249 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6250 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6254 echo "No pages locked after fsync"
6258 run_test 118j "Simulate unrecoverable OST side error =========="
6262 remote_ost_nodsh && skip "remote OSTs with nodsh" && return
6264 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
6265 set_nodes_failloc "$(osts_nodes)" 0x20e
6268 for ((i=0;i<10;i++)); do
6269 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
6270 error "dd to $DIR/$tdir/$tfile-$i failed" )&
6277 set_nodes_failloc "$(osts_nodes)" 0
6280 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
6286 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
6289 run_test 118l "fsync dir ========="
6291 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
6293 test_119a() # bug 11737
6295 BSIZE=$((512 * 1024))
6296 directio write $DIR/$tfile 0 1 $BSIZE
6297 # We ask to read two blocks, which is more than a file size.
6298 # directio will indicate an error when requested and actual
6299 # sizes aren't equeal (a normal situation in this case) and
6300 # print actual read amount.
6301 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
6302 if [ "$NOB" != "$BSIZE" ]; then
6303 error "read $NOB bytes instead of $BSIZE"
6307 run_test 119a "Short directIO read must return actual read amount"
6309 test_119b() # bug 11737
6311 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
6313 $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
6314 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
6316 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) || \
6317 error "direct read failed"
6320 run_test 119b "Sparse directIO read must return actual read amount"
6322 test_119c() # bug 13099
6325 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
6326 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
6329 run_test 119c "Testing for direct read hitting hole"
6331 test_119d() # bug 15950
6333 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
6334 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
6336 $SETSTRIPE $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
6337 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
6338 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
6339 lctl set_param fail_loc=0x40d
6340 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
6343 cat $DIR/$tfile > /dev/null &
6344 lctl set_param fail_loc=0
6347 log "the DIO writes have completed, now wait for the reads (should not block very long)"
6349 [ -n "`ps h -p $pid_reads -o comm`" ] && \
6350 error "the read rpcs have not completed in 2s"
6352 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
6354 run_test 119d "The DIO path should try to send a new rpc once one is completed"
6358 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6359 skip "no early lock cancel on server" && return 0
6360 lru_resize_disable mdc
6361 lru_resize_disable osc
6362 cancel_lru_locks mdc
6363 stat $DIR/$tdir > /dev/null
6364 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6365 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6367 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6368 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6369 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6370 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6371 lru_resize_enable mdc
6372 lru_resize_enable osc
6374 run_test 120a "Early Lock Cancel: mkdir test"
6378 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6379 skip "no early lock cancel on server" && return 0
6380 lru_resize_disable mdc
6381 lru_resize_disable osc
6382 cancel_lru_locks mdc
6383 stat $DIR/$tdir > /dev/null
6384 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6385 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6387 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6388 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6389 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6390 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6391 lru_resize_enable mdc
6392 lru_resize_enable osc
6394 run_test 120b "Early Lock Cancel: create test"
6398 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6399 skip "no early lock cancel on server" && return 0
6400 lru_resize_disable mdc
6401 lru_resize_disable osc
6402 mkdir -p $DIR/$tdir/d1 $DIR/$tdir/d2
6403 touch $DIR/$tdir/d1/f1
6404 cancel_lru_locks mdc
6405 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
6406 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6407 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6408 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
6409 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6410 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6411 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6412 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6413 lru_resize_enable mdc
6414 lru_resize_enable osc
6416 run_test 120c "Early Lock Cancel: link test"
6420 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6421 skip "no early lock cancel on server" && return 0
6422 lru_resize_disable mdc
6423 lru_resize_disable osc
6425 cancel_lru_locks mdc
6426 stat $DIR/$tdir > /dev/null
6427 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6428 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6429 chmod a+x $DIR/$tdir
6430 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6431 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6432 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6433 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6434 lru_resize_enable mdc
6435 lru_resize_enable osc
6437 run_test 120d "Early Lock Cancel: setattr test"
6441 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6442 skip "no early lock cancel on server" && return 0
6443 lru_resize_disable mdc
6444 lru_resize_disable osc
6445 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
6446 cancel_lru_locks mdc
6447 cancel_lru_locks osc
6448 dd if=$DIR/$tdir/f1 of=/dev/null
6449 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
6450 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6451 awk '/ldlm_cancel/ {print $2}'`
6452 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6453 awk '/ldlm_bl_callback/ {print $2}'`
6454 unlink $DIR/$tdir/f1
6455 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6456 awk '/ldlm_cancel/ {print $2}'`
6457 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6458 awk '/ldlm_bl_callback/ {print $2}'`
6459 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6460 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6461 lru_resize_enable mdc
6462 lru_resize_enable osc
6464 run_test 120e "Early Lock Cancel: unlink test"
6467 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6468 skip "no early lock cancel on server" && return 0
6470 lru_resize_disable mdc
6471 lru_resize_disable osc
6472 mkdir -p $DIR/$tdir/d1 $DIR/$tdir/d2
6473 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
6474 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
6475 cancel_lru_locks mdc
6476 cancel_lru_locks osc
6477 dd if=$DIR/$tdir/d1/f1 of=/dev/null
6478 dd if=$DIR/$tdir/d2/f2 of=/dev/null
6479 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
6480 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6481 awk '/ldlm_cancel/ {print $2}'`
6482 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6483 awk '/ldlm_bl_callback/ {print $2}'`
6484 mv $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
6485 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6486 awk '/ldlm_cancel/ {print $2}'`
6487 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6488 awk '/ldlm_bl_callback/ {print $2}'`
6489 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6490 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6491 lru_resize_enable mdc
6492 lru_resize_enable osc
6494 run_test 120f "Early Lock Cancel: rename test"
6497 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6498 skip "no early lock cancel on server" && return 0
6499 lru_resize_disable mdc
6500 lru_resize_disable osc
6502 echo create $count files
6504 cancel_lru_locks mdc
6505 cancel_lru_locks osc
6508 can0=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6509 awk '/ldlm_cancel/ {print $2}'`
6510 blk0=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6511 awk '/ldlm_bl_callback/ {print $2}'`
6512 createmany -o $DIR/$tdir/f $count
6514 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6515 awk '/ldlm_cancel/ {print $2}'`
6516 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6517 awk '/ldlm_bl_callback/ {print $2}'`
6519 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
6520 echo rm $count files
6523 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6524 awk '/ldlm_cancel/ {print $2}'`
6525 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6526 awk '/ldlm_bl_callback/ {print $2}'`
6528 echo total: $count removes in $((t2-t1))
6529 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
6531 # wait for commitment of removal
6532 lru_resize_enable mdc
6533 lru_resize_enable osc
6535 run_test 120g "Early Lock Cancel: performance test"
6537 test_121() { #bug #10589
6539 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
6540 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
6541 lctl set_param fail_loc=0x310
6542 cancel_lru_locks osc > /dev/null
6543 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
6544 lctl set_param fail_loc=0
6545 [ "$reads" -eq "$writes" ] || error "read" $reads "blocks, must be" $writes
6547 run_test 121 "read cancel race ========="
6549 test_123a() { # was test 123, statahead(bug 11401)
6551 if [ -z "$(grep "processor.*: 1" /proc/cpuinfo)" ]; then
6552 log "testing on UP system. Performance may be not as good as expected."
6558 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
6559 [ $NUMFREE -gt 100000 ] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
6561 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
6562 createmany -o $DIR/$tdir/$tfile $j $((i - j))
6564 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
6565 lctl set_param -n llite.*.statahead_max 0
6566 lctl get_param llite.*.statahead_max
6567 cancel_lru_locks mdc
6568 cancel_lru_locks osc
6570 time ls -l $DIR/$tdir | wc -l
6572 delta=$((etime - stime))
6573 log "ls $i files without statahead: $delta sec"
6574 lctl set_param llite.*.statahead_max=$max
6576 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
6577 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
6578 cancel_lru_locks mdc
6579 cancel_lru_locks osc
6581 time ls -l $DIR/$tdir | wc -l
6583 delta_sa=$((etime - stime))
6584 log "ls $i files with statahead: $delta_sa sec"
6585 lctl get_param -n llite.*.statahead_stats
6586 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
6588 [ $swrong -lt $ewrong ] && log "statahead was stopped, maybe too many locks held!"
6589 [ $delta -eq 0 -o $delta_sa -eq 0 ] && continue
6591 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
6592 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
6593 lctl set_param -n llite.*.statahead_max 0
6594 lctl get_param llite.*.statahead_max
6595 cancel_lru_locks mdc
6596 cancel_lru_locks osc
6598 time ls -l $DIR/$tdir | wc -l
6600 delta=$((etime - stime))
6601 log "ls $i files again without statahead: $delta sec"
6602 lctl set_param llite.*.statahead_max=$max
6603 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
6604 if [ $SLOWOK -eq 0 ]; then
6605 error "ls $i files is slower with statahead!"
6607 log "ls $i files is slower with statahead!"
6613 [ $delta -gt 20 ] && break
6614 [ $delta -gt 8 ] && MULT=$((50 / delta))
6615 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
6623 delta=$((etime - stime))
6624 log "rm -r $DIR/$tdir/: $delta seconds"
6626 lctl get_param -n llite.*.statahead_stats
6628 run_test 123a "verify statahead work"
6630 test_123b () { # statahead(bug 15027)
6632 createmany -o $DIR/$tdir/$tfile-%d 1000
6634 cancel_lru_locks mdc
6635 cancel_lru_locks osc
6637 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
6638 lctl set_param fail_loc=0x80000803
6639 ls -lR $DIR/$tdir > /dev/null
6641 lctl set_param fail_loc=0x0
6642 lctl get_param -n llite.*.statahead_stats
6647 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
6650 [ -z "`lctl get_param -n mdc.*.connect_flags | grep lru_resize`" ] && \
6651 skip "no lru resize on server" && return 0
6653 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
6655 log "create $NR files at $DIR/$tdir"
6656 createmany -o $DIR/$tdir/f $NR ||
6657 error "failed to create $NR files in $DIR/$tdir"
6659 cancel_lru_locks mdc
6660 ls -l $DIR/$tdir > /dev/null
6664 for VALUE in `lctl get_param ldlm.namespaces.*mdc-*.lru_size`; do
6665 local PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
6666 LRU_SIZE=$(lctl get_param -n $PARAM)
6667 if [ $LRU_SIZE -gt $(default_lru_size) ]; then
6668 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
6670 log "NS=$(basename $NSDIR)"
6675 if [ -z "$NSDIR" -o $LRU_SIZE -lt $(default_lru_size) ]; then
6676 skip "Not enough cached locks created!"
6683 # We know that lru resize allows one client to hold $LIMIT locks
6684 # for 10h. After that locks begin to be killed by client.
6686 local LIMIT=`lctl get_param -n $NSDIR.pool.limit`
6689 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
6690 # killing locks. Some time was spent for creating locks. This means
6691 # that up to the moment of sleep finish we must have killed some of
6692 # them (10-100 locks). This depends on how fast ther were created.
6693 # Many of them were touched in almost the same moment and thus will
6694 # be killed in groups.
6695 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
6697 # Use $LRU_SIZE_B here to take into account real number of locks
6698 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
6699 local LRU_SIZE_B=$LRU_SIZE
6701 local OLD_LVF=`lctl get_param -n $NSDIR.pool.lock_volume_factor`
6702 log "OLD_LVF=$OLD_LVF"
6703 lctl set_param -n $NSDIR.pool.lock_volume_factor $LVF
6705 # Let's make sure that we really have some margin. Client checks
6706 # cached locks every 10 sec.
6708 log "Sleep ${SLEEP} sec"
6710 while ((SEC<$SLEEP)); do
6714 LRU_SIZE=`lctl get_param -n $NSDIR/lru_size`
6718 lctl set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
6719 local LRU_SIZE_A=`lctl get_param -n $NSDIR.lru_size`
6721 [ $LRU_SIZE_B -gt $LRU_SIZE_A ] || {
6722 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
6723 unlinkmany $DIR/$tdir/f $NR
6727 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
6728 log "unlink $NR files at $DIR/$tdir"
6729 unlinkmany $DIR/$tdir/f $NR
6731 run_test 124a "lru resize ======================================="
6733 get_max_pool_limit()
6735 local limit=`lctl get_param -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit`
6738 if test $l -gt $max; then
6746 [ -z "`lctl get_param -n mdc.*.connect_flags | grep lru_resize`" ] && \
6747 skip "no lru resize on server" && return 0
6749 LIMIT=`get_max_pool_limit`
6751 NR=$(($(default_lru_size)*20))
6752 if [ $NR -gt $LIMIT ]; then
6753 log "Limit lock number by $LIMIT locks"
6756 lru_resize_disable mdc
6757 mkdir -p $DIR/$tdir/disable_lru_resize ||
6758 error "failed to create $DIR/$tdir/disable_lru_resize"
6760 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
6761 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
6762 cancel_lru_locks mdc
6765 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
6768 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
6771 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
6775 nolruresize_delta=$((etime-stime))
6776 log "ls -la time: $nolruresize_delta seconds"
6777 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
6778 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
6780 lru_resize_enable mdc
6781 mkdir -p $DIR/$tdir/enable_lru_resize ||
6782 error "failed to create $DIR/$tdir/enable_lru_resize"
6784 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
6785 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
6786 cancel_lru_locks mdc
6789 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
6792 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
6795 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
6799 lruresize_delta=$((etime-stime))
6800 log "ls -la time: $lruresize_delta seconds"
6801 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
6803 if [ $lruresize_delta -gt $nolruresize_delta ]; then
6804 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
6805 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
6806 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
6808 log "lru resize performs the same with no lru resize"
6810 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
6812 run_test 124b "lru resize (performance test) ======================="
6814 test_125() { # 13358
6815 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
6816 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
6817 mkdir -p $DIR/d125 || error "mkdir failed"
6818 $SETSTRIPE -S 65536 -c -1 $DIR/d125 || error "setstripe failed"
6819 setfacl -R -m u:bin:rwx $DIR/d125 || error "setfacl $DIR/d125 failed"
6820 ls -ld $DIR/d125 || error "cannot access $DIR/d125"
6822 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
6824 test_126() { # bug 12829/13455
6825 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
6826 [ "$UID" != 0 ] && skip_env "skipping $TESTNAME (must run as root)" && return
6827 $GSS && skip "must run as gss disabled" && return
6829 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
6830 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
6832 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
6834 run_test 126 "check that the fsgid provided by the client is taken into account"
6836 test_127a() { # bug 15521
6837 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
6838 $LCTL set_param osc.*.stats=0
6839 FSIZE=$((2048 * 1024))
6840 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
6841 cancel_lru_locks osc
6842 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
6844 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
6845 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
6846 echo "got $COUNT $NAME"
6847 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
6848 eval $NAME=$COUNT || error "Wrong proc format"
6851 read_bytes|write_bytes)
6852 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
6853 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
6854 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
6855 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
6856 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
6857 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
6858 error "sumsquare is too small: $SUMSQ"
6859 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
6860 error "sumsquare is too big: $SUMSQ"
6864 done < $DIR/${tfile}.tmp
6866 #check that we actually got some stats
6867 [ "$read_bytes" ] || error "Missing read_bytes stats"
6868 [ "$write_bytes" ] || error "Missing write_bytes stats"
6869 [ "$read_bytes" != 0 ] || error "no read done"
6870 [ "$write_bytes" != 0 ] || error "no write done"
6872 run_test 127a "verify the client stats are sane"
6874 test_127b() { # bug LU-333
6875 $LCTL set_param llite.*.stats=0
6876 FSIZE=65536 # sized fixed to match PAGE_SIZE for most clients
6877 # perform 2 reads and writes so MAX is different from SUM.
6878 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
6879 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
6880 cancel_lru_locks osc
6881 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
6882 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
6884 $LCTL get_param llite.*.stats | grep samples > $TMP/${tfile}.tmp
6885 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
6886 echo "got $COUNT $NAME"
6887 eval $NAME=$COUNT || error "Wrong proc format"
6891 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
6892 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
6893 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
6894 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
6897 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
6898 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
6899 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
6900 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
6904 done < $TMP/${tfile}.tmp
6906 #check that we actually got some stats
6907 [ "$read_bytes" ] || error "Missing read_bytes stats"
6908 [ "$write_bytes" ] || error "Missing write_bytes stats"
6909 [ "$read_bytes" != 0 ] || error "no read done"
6910 [ "$write_bytes" != 0 ] || error "no write done"
6912 run_test 127b "verify the llite client stats are sane"
6914 test_128() { # bug 15212
6916 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
6921 result=$(grep error $TMP/$tfile.log)
6923 [ -z "$result" ] || error "consecutive find's under interactive lfs failed"
6925 run_test 128 "interactive lfs for 2 consecutive find's"
6932 local LDPROC=/proc/fs/ldiskfs
6934 for facet in $(get_facets MDS); do
6935 canondev=$(ldiskfs_canon *.$(convert_facet2label $facet).mntdev $facet)
6936 do_facet $facet "test -e $LDPROC/$canondev/max_dir_size" || LDPROC=/sys/fs/ldiskfs
6937 do_facet $facet "echo $1 >$LDPROC/$canondev/max_dir_size"
6941 [ "$FSTYPE" != "ldiskfs" ] && skip "not needed for FSTYPE=$FSTYPE" && return 0
6942 remote_mds_nodsh && skip "remote MDS with nodsh" && return
6953 while [ ! $I -gt $((MAX * MDSCOUNT)) ]; do
6954 $MULTIOP $DIR/$tdir/$J Oc
6956 if [ $rc -eq $EFBIG ]; then
6958 echo "return code $rc received as expected"
6960 elif [ $rc -ne 0 ]; then
6962 error_exit "return code $rc received instead of expected $EFBIG"
6965 I=$(stat -c%s "$DIR/$tdir")
6969 error "exceeded dir size limit $MAX x $MDSCOUNT $((MAX * MDSCOUNT)) : $I bytes"
6971 run_test 129 "test directory size limit ========================"
6980 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
6981 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
6983 trap cleanup_130 EXIT RETURN
6985 local fm_file=$DIR/$tfile
6986 $SETSTRIPE -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
6987 dd if=/dev/zero of=$fm_file bs=65536 count=1 || error "dd failed for $fm_file"
6989 filefrag -ves $fm_file || error "filefrag $fm_file failed"
6990 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
6992 lun=$($GETSTRIPE -i $fm_file)
6994 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
6997 for line in $filefrag_op
6999 frag_lun=`echo $line | cut -d: -f5`
7000 ext_len=`echo $line | cut -d: -f4`
7001 if (( $frag_lun != $lun )); then
7003 error "FIEMAP on 1-stripe file($fm_file) failed"
7006 (( tot_len += ext_len ))
7009 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
7011 error "FIEMAP on 1-stripe file($fm_file) failed;"
7017 echo "FIEMAP on single striped file succeeded"
7019 run_test 130a "FIEMAP (1-stripe file)"
7022 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping FIEMAP on 2-stripe file test" && return
7024 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7025 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
7027 trap cleanup_130 EXIT RETURN
7029 local fm_file=$DIR/$tfile
7030 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
7031 dd if=/dev/zero of=$fm_file bs=1M count=2 || error "dd failed on $fm_file"
7033 filefrag -ves $fm_file || error "filefrag $fm_file failed"
7034 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
7036 last_lun=`echo $filefrag_op | cut -d: -f5`
7041 for line in $filefrag_op
7043 frag_lun=`echo $line | cut -d: -f5`
7044 ext_len=`echo $line | cut -d: -f4`
7045 if (( $frag_lun != $last_lun )); then
7046 if (( tot_len != 1024 )); then
7048 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 256"
7055 (( tot_len += ext_len ))
7058 if (( num_luns != 2 || tot_len != 1024 )); then
7060 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
7066 echo "FIEMAP on 2-stripe file succeeded"
7068 run_test 130b "FIEMAP (2-stripe file)"
7071 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping FIEMAP on 2-stripe file with hole test" && return
7073 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7074 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
7076 trap cleanup_130 EXIT RETURN
7078 local fm_file=$DIR/$tfile
7079 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
7080 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 || error "dd failed on $fm_file"
7082 filefrag -ves $fm_file || error "filefrag $fm_file failed"
7083 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
7085 last_lun=`echo $filefrag_op | cut -d: -f5`
7090 for line in $filefrag_op
7092 frag_lun=`echo $line | cut -d: -f5`
7093 ext_len=`echo $line | cut -d: -f4`
7094 if (( $frag_lun != $last_lun )); then
7095 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
7096 if (( logical != 512 )); then
7098 error "FIEMAP on $fm_file failed; returned logical start for lun $logical instead of 512"
7101 if (( tot_len != 512 )); then
7103 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
7110 (( tot_len += ext_len ))
7113 if (( num_luns != 2 || tot_len != 512 )); then
7115 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
7121 echo "FIEMAP on 2-stripe file with hole succeeded"
7123 run_test 130c "FIEMAP (2-stripe file with hole)"
7126 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping FIEMAP on N-stripe file test" && return
7128 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7129 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
7131 trap cleanup_130 EXIT RETURN
7133 local fm_file=$DIR/$tfile
7134 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file||error "setstripe on $fm_file"
7135 dd if=/dev/zero of=$fm_file bs=1M count=$OSTCOUNT || error "dd failed on $fm_file"
7137 filefrag -ves $fm_file || error "filefrag $fm_file failed"
7138 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
7140 last_lun=`echo $filefrag_op | cut -d: -f5`
7145 for line in $filefrag_op
7147 frag_lun=`echo $line | cut -d: -f5`
7148 ext_len=`echo $line | cut -d: -f4`
7149 if (( $frag_lun != $last_lun )); then
7150 if (( tot_len != 1024 )); then
7152 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
7159 (( tot_len += ext_len ))
7162 if (( num_luns != OSTCOUNT || tot_len != 1024 )); then
7164 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
7170 echo "FIEMAP on N-stripe file succeeded"
7172 run_test 130d "FIEMAP (N-stripe file)"
7175 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping continuation FIEMAP test" && return
7177 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7178 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
7180 trap cleanup_130 EXIT RETURN
7182 local fm_file=$DIR/$tfile
7183 $SETSTRIPE -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
7185 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
7186 for ((i = 0; i < $NUM_BLKS; i++))
7188 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
7191 filefrag -ves $fm_file || error "filefrag $fm_file failed"
7192 filefrag_op=`filefrag -ve $fm_file | grep -A 12000 "ext:" | grep -v "ext:" | grep -v "found"`
7194 last_lun=`echo $filefrag_op | cut -d: -f5`
7199 for line in $filefrag_op
7201 frag_lun=`echo $line | cut -d: -f5`
7202 ext_len=`echo $line | cut -d: -f4`
7203 if (( $frag_lun != $last_lun )); then
7204 if (( tot_len != $EXPECTED_LEN )); then
7206 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of $EXPECTED_LEN"
7213 (( tot_len += ext_len ))
7216 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
7218 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
7224 echo "FIEMAP with continuation calls succeeded"
7226 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
7228 # Test for writev/readv
7230 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 || \
7231 error "writev test failed"
7232 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 || \
7233 error "readv failed"
7236 run_test 131a "test iov's crossing stripe boundary for writev/readv"
7239 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 || \
7240 error "append writev test failed"
7241 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 || \
7242 error "append writev test failed"
7245 run_test 131b "test append writev"
7248 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
7251 run_test 131c "test read/write on file w/o objects"
7254 rwv -f $DIR/$tfile -w -n 1 1572864
7255 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
7256 if [ "$NOB" != 1572864 ]; then
7257 error "Short read filed: read $NOB bytes instead of 1572864"
7261 run_test 131d "test short read"
7264 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
7265 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
7266 error "read hitting hole failed"
7269 run_test 131e "test read hitting hole"
7274 for node in $(osts_nodes); do
7275 gl=$(do_node $node "$LCTL get_param -n ost.OSS.ost.stats" | awk '/'$token'/ {print $2}' | head -n 1)
7276 [ x$gl = x"" ] && gl=0
7277 gl_sum=$((gl_sum + gl))
7287 if [ x$som = x"enabled" ]; then
7288 [ $((gl2 - gl1)) -gt 0 ] && error "no glimpse RPC is expected"
7289 MOUNTOPT=`echo $MOUNTOPT | sed 's/som_preview//g'`
7290 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=disabled"
7292 [ $((gl2 - gl1)) -gt 0 ] || error "some glimpse RPC is expected"
7293 MOUNTOPT="$MOUNTOPT,som_preview"
7294 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=enabled"
7297 # do remount to make new mount-conf parameters actual
7304 test_132() { #1028, SOM
7305 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7306 local num=$(get_mds_dir $DIR)
7307 local mymds=mds${num}
7308 local MOUNTOPT_SAVE=$MOUNTOPT
7310 dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
7311 cancel_lru_locks osc
7313 som1=$(do_facet $mymds "$LCTL get_param mdt.*.som" | awk -F= ' {print $2}' | head -n 1)
7315 gl1=$(get_ost_param "ldlm_glimpse_enqueue")
7316 stat $DIR/$tfile >/dev/null
7317 gl2=$(get_ost_param "ldlm_glimpse_enqueue")
7318 echo "====> SOM is "$som1", "$((gl2 - gl1))" glimpse RPC occured"
7320 som_mode_switch $som1 $gl1 $gl2
7322 dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
7323 cancel_lru_locks osc
7325 som2=$(do_facet $mymds "$LCTL get_param mdt.*.som" | awk -F= ' {print $2}' | head -n 1)
7326 if [ $som1 == $som2 ]; then
7327 error "som is still "$som2
7328 if [ x$som2 = x"enabled" ]; then
7335 gl1=$(get_ost_param "ldlm_glimpse_enqueue")
7336 stat $DIR/$tfile >/dev/null
7337 gl2=$(get_ost_param "ldlm_glimpse_enqueue")
7338 echo "====> SOM is "$som2", "$((gl2 - gl1))" glimpse RPC occured"
7339 som_mode_switch $som2 $gl1 $gl2
7340 MOUNTOPT=$MOUNTOPT_SAVE
7342 run_test 132 "som avoids glimpse rpc"
7348 $SINGLEMDS) res=`do_facet $SINGLEMDS $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$2"`
7350 ost) res=`do_facet ost1 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$2"`
7352 *) error "Wrong argument $1" ;;
7355 count=`echo $res | awk '{print $2}'`
7356 [ -z "$res" ] && error "The counter for $2 on $1 was not incremented"
7357 # if the argument $3 is zero, it means any stat increment is ok.
7358 if [ $3 -gt 0 ] ; then
7359 [ $count -ne $3 ] && error "The $2 counter on $1 is wrong - expected $3"
7364 remote_ost_nodsh && skip "remote OST with nodsh" && return
7365 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7367 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
7368 { skip "MDS doesn't support rename stats"; return; }
7369 local testdir=$DIR/${tdir}/stats_testdir
7370 mkdir -p $DIR/${tdir}
7373 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
7374 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
7376 # verify mdt stats first.
7377 mkdir ${testdir} || error "mkdir failed"
7378 check_stats $SINGLEMDS "mkdir" 1
7379 touch ${testdir}/${tfile} || "touch failed"
7380 check_stats $SINGLEMDS "open" 1
7381 check_stats $SINGLEMDS "close" 1
7382 mknod ${testdir}/${tfile}-pipe p || "mknod failed"
7383 check_stats $SINGLEMDS "mknod" 1
7384 rm -f ${testdir}/${tfile}-pipe || "pipe remove failed"
7385 check_stats $SINGLEMDS "unlink" 1
7386 rm -f ${testdir}/${tfile} || error "file remove failed"
7387 check_stats $SINGLEMDS "unlink" 2
7389 # remove working dir and check mdt stats again.
7390 rmdir ${testdir} || error "rmdir failed"
7391 check_stats $SINGLEMDS "rmdir" 1
7393 local testdir1=$DIR/${tdir}/stats_testdir1
7395 mkdir -p ${testdir1}
7396 touch ${testdir1}/test1
7397 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
7398 check_stats $SINGLEMDS "crossdir_rename" 1
7400 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
7401 check_stats $SINGLEMDS "samedir_rename" 1
7405 run_test 133a "Verifying MDT stats ========================================"
7408 remote_ost_nodsh && skip "remote OST with nodsh" && return
7409 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7410 local testdir=$DIR/${tdir}/stats_testdir
7411 mkdir -p ${testdir} || error "mkdir failed"
7412 touch ${testdir}/${tfile} || "touch failed"
7413 cancel_lru_locks mdc
7416 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
7417 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
7419 # extra mdt stats verification.
7420 chmod 444 ${testdir}/${tfile} || error "chmod failed"
7421 check_stats $SINGLEMDS "setattr" 1
7422 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
7423 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
7424 check_stats $SINGLEMDS "getattr" 1
7425 $LFS df || error "lfs failed"
7426 check_stats $SINGLEMDS "statfs" 1
7430 run_test 133b "Verifying extra MDT stats =================================="
7433 remote_ost_nodsh && skip "remote OST with nodsh" && return
7434 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7435 local testdir=$DIR/${tdir}/stats_testdir
7436 mkdir -p ${testdir} || error "mkdir failed"
7438 # verify obdfilter stats.
7439 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
7441 cancel_lru_locks osc
7444 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
7445 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
7447 dd if=/dev/zero of=${testdir}/${tfile} conv=notrunc bs=512k count=1 || error "dd failed"
7449 cancel_lru_locks osc
7450 check_stats ost "write" 1
7452 dd if=${testdir}/${tfile} of=/dev/null bs=1k count=1 || error "dd failed"
7453 check_stats ost "read" 1
7455 > ${testdir}/${tfile} || error "truncate failed"
7456 check_stats ost "punch" 1
7458 rm -f ${testdir}/${tfile} || error "file remove failed"
7459 check_stats ost "destroy" 1
7463 run_test 133c "Verifying OST stats ========================================"
7470 while [ $value -ge 2 ]; do
7475 if [ $orig -gt $order ]; then
7483 local size=('K' 'M' 'G' 'T');
7485 local size_string=$value
7487 while [ $value -ge 1024 ]; do
7488 if [ $i -gt 3 ]; then
7489 #T is the biggest unit we get here, if that is bigger,
7491 size_string=${value}T
7494 value=$((value >> 10))
7495 if [ $value -lt 1024 ]; then
7496 size_string=${value}${size[$i]}
7507 local sample=$(do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats |
7508 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
7513 remote_ost_nodsh && skip "remote OST with nodsh" && return
7514 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7515 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
7516 { skip "MDS doesn't support rename stats"; return; }
7518 local testdir1=$DIR/${tdir}/stats_testdir1
7519 local testdir2=$DIR/${tdir}/stats_testdir2
7521 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
7523 mkdir -p ${testdir1} || error "mkdir failed"
7524 mkdir -p ${testdir2} || error "mkdir failed"
7526 createmany -o $testdir1/test 512 || error "createmany failed"
7527 local testdir1_size=$(ls -l $DIR/${tdir} |
7528 awk '/stats_testdir1/ {print $5}')
7529 local testdir2_size=$(ls -l $DIR/${tdir} |
7530 awk '/stats_testdir2/ {print $5}')
7532 testdir1_size=$(order_2 $testdir1_size)
7533 testdir2_size=$(order_2 $testdir2_size)
7535 testdir1_size=$(size_in_KMGT $testdir1_size)
7536 testdir2_size=$(size_in_KMGT $testdir2_size)
7538 echo "source rename dir size: ${testdir1_size}"
7539 echo "target rename dir size: ${testdir2_size}"
7541 # check samedir rename size
7542 mv ${testdir1}/test0 ${testdir1}/test_0
7543 local cmd="do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats"
7544 eval $cmd || error "$cmd failed"
7545 local samedir=$($cmd | grep 'same_dir')
7546 local same_sample=$(get_rename_size $testdir1_size)
7547 [ -z "$samedir" ] && error "samedir_rename_size count error"
7548 [ "$same_sample" -eq 1 ] || error "samedir_rename_size error $same_sample"
7549 echo "Check same dir rename stats success"
7551 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
7553 # check crossdir rename size
7554 mv ${testdir1}/test_0 ${testdir2}/test_0
7555 eval $cmd || error "$cmd failed"
7556 local crossdir=$($cmd | grep 'crossdir')
7557 local src_sample=$(get_rename_size $testdir1_size)
7558 local tgt_sample=$(get_rename_size $testdir2_size)
7559 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
7560 [ "$src_sample" -eq 1 ] || error "crossdir_rename_size error $src_sample"
7561 [ "$tgt_sample" -eq 1 ] || error "crossdir_rename_size error $tgt_sample"
7562 echo "Check cross dir rename stats success"
7565 run_test 133d "Verifying rename_stats ========================================"
7567 test_140() { #bug-17379
7568 mkdir -p $DIR/$tdir || error "Creating dir $DIR/$tdir"
7569 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
7570 cp /usr/bin/stat . || error "Copying stat to $DIR/$tdir"
7572 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
7574 while i=`expr $i + 1`; do
7575 mkdir -p $i || error "Creating dir $i"
7576 cd $i || error "Changing to $i"
7577 ln -s ../stat stat || error "Creating stat symlink"
7578 # Read the symlink until ELOOP present,
7579 # not LBUGing the system is considered success,
7580 # we didn't overrun the stack.
7581 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
7583 if [ $ret -eq 40 ]; then
7586 error "Open stat symlink"
7592 echo "The symlink depth = $i"
7593 [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 ] || error "Invalid symlink depth"
7595 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
7598 local TF="$TMP/$tfile"
7600 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
7602 cancel_lru_locks osc
7603 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
7604 remount_client $MOUNT
7606 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
7609 $TRUNCATE $DIR/$tfile 6000
7610 cancel_lru_locks osc
7611 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
7614 echo "12345" >>$DIR/$tfile
7615 cancel_lru_locks osc
7616 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
7619 echo "12345" >>$DIR/$tfile
7620 cancel_lru_locks osc
7621 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
7626 run_test 150 "truncate/append tests"
7628 function roc_hit() {
7629 local list=$(comma_list $(osts_nodes))
7631 ACCNUM=$(do_nodes $list $LCTL get_param -n obdfilter.*.stats | \
7632 awk '/'cache_hit'/ {sum+=$2} END {print sum}')
7636 function set_cache() {
7639 if [ "$2" == "off" ]; then
7642 local list=$(comma_list $(osts_nodes))
7643 do_nodes $list lctl set_param obdfilter.*.${1}_cache_enable $on
7645 cancel_lru_locks osc
7649 remote_ost_nodsh && skip "remote OST with nodsh" && return
7652 local list=$(comma_list $(osts_nodes))
7654 # check whether obdfilter is cache capable at all
7655 if ! do_nodes $list $LCTL get_param -n obdfilter.*.read_cache_enable > /dev/null; then
7656 echo "not cache-capable obdfilter"
7660 # check cache is enabled on all obdfilters
7661 if do_nodes $list $LCTL get_param -n obdfilter.*.read_cache_enable | grep 0 >&/dev/null; then
7662 echo "oss cache is disabled"
7666 do_nodes $list $LCTL set_param -n obdfilter.*.writethrough_cache_enable 1
7668 # pages should be in the case right after write
7669 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES || error "dd failed"
7670 local BEFORE=`roc_hit`
7671 cancel_lru_locks osc
7672 cat $DIR/$tfile >/dev/null
7673 local AFTER=`roc_hit`
7674 if ! let "AFTER - BEFORE == CPAGES"; then
7675 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
7678 # the following read invalidates the cache
7679 cancel_lru_locks osc
7680 do_nodes $list $LCTL set_param -n obdfilter.*.read_cache_enable 0
7681 cat $DIR/$tfile >/dev/null
7683 # now data shouldn't be found in the cache
7685 cancel_lru_locks osc
7686 cat $DIR/$tfile >/dev/null
7688 if let "AFTER - BEFORE != 0"; then
7689 error "IN CACHE: before: $BEFORE, after: $AFTER"
7692 do_nodes $list $LCTL set_param -n obdfilter.*.read_cache_enable 1
7695 run_test 151 "test cache on oss and controls ==============================="
7698 local TF="$TMP/$tfile"
7700 # simulate ENOMEM during write
7701 #define OBD_FAIL_OST_NOMEM 0x226
7702 lctl set_param fail_loc=0x80000226
7703 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
7705 sync || error "sync failed"
7706 lctl set_param fail_loc=0
7708 # discard client's cache
7709 cancel_lru_locks osc
7711 # simulate ENOMEM during read
7712 lctl set_param fail_loc=0x80000226
7713 cmp $TF $DIR/$tfile || error "cmp failed"
7714 lctl set_param fail_loc=0
7718 run_test 152 "test read/write with enomem ============================"
7721 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
7723 run_test 153 "test if fdatasync does not crash ======================="
7726 cp /etc/hosts $DIR/$tfile
7728 fid=$($LFS path2fid $DIR/$tfile)
7730 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
7732 ffid=$DIR/.lustre/fid/$fid
7734 echo "stat fid $fid"
7735 stat $ffid > /dev/null || error "stat $ffid failed."
7736 echo "touch fid $fid"
7737 touch $ffid || error "touch $ffid failed."
7738 echo "write to fid $fid"
7739 cat /etc/hosts > $ffid || error "write $ffid failed."
7740 echo "read fid $fid"
7741 diff /etc/hosts $ffid || error "read $ffid failed."
7742 echo "append write to fid $fid"
7743 cat /etc/hosts >> $ffid || error "append write $ffid failed."
7744 echo "rename fid $fid"
7745 mv $ffid $DIR/$tfile.1 && error "rename $ffid to $tfile.1 should fail."
7747 mv $DIR/$tfile.1 $ffid && error "rename $tfile.1 to $ffid should fail."
7749 echo "truncate fid $fid"
7750 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
7751 echo "link fid $fid"
7752 ln -f $ffid $DIR/tfile.lnk || error "link $ffid failed."
7753 if [ -n $(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl) ]; then
7754 echo "setfacl fid $fid"
7755 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
7756 echo "getfacl fid $fid"
7757 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
7759 echo "unlink fid $fid"
7760 unlink $DIR/.lustre/fid/$fid && error "unlink $ffid should fail."
7761 echo "mknod fid $fid"
7762 mknod $ffid c 1 3 && error "mknod $ffid should fail."
7764 fid=[0xf00000400:0x1:0x0]
7765 ffid=$DIR/.lustre/fid/$fid
7767 echo "stat non-exist fid $fid"
7768 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
7769 echo "write to non-exist fid $fid"
7770 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
7771 echo "link new fid $fid"
7772 ln $DIR/$tfile $ffid && error "link $ffid should fail."
7775 touch $DIR/$tdir/$tfile
7776 fid=$($LFS path2fid $DIR/$tdir)
7778 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
7780 ffid=$DIR/.lustre/fid/$fid
7783 ls $ffid > /dev/null || error "ls $ffid failed."
7784 echo "touch $fid/$tfile.1"
7785 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
7787 echo "touch $DIR/.lustre/fid/$tfile"
7788 touch $DIR/.lustre/fid/$tfile && \
7789 error "touch $DIR/.lustre/fid/$tfile should fail."
7791 echo "Open-by-FID succeeded"
7793 run_test 154 "Open-by-FID"
7795 test_155_small_load() {
7796 local temp=$TMP/$tfile
7797 local file=$DIR/$tfile
7799 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
7800 error "dd of=$temp bs=6096 count=1 failed"
7802 cancel_lru_locks osc
7803 cmp $temp $file || error "$temp $file differ"
7805 $TRUNCATE $temp 6000
7806 $TRUNCATE $file 6000
7807 cmp $temp $file || error "$temp $file differ (truncate1)"
7809 echo "12345" >>$temp
7810 echo "12345" >>$file
7811 cmp $temp $file || error "$temp $file differ (append1)"
7813 echo "12345" >>$temp
7814 echo "12345" >>$file
7815 cmp $temp $file || error "$temp $file differ (append2)"
7821 test_155_big_load() {
7822 remote_ost_nodsh && skip "remote OST with nodsh" && return
7823 local temp=$TMP/$tfile
7824 local file=$DIR/$tfile
7827 local cache_size=$(do_facet ost$((MAXI+1)) \
7828 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
7829 local large_file_size=$((cache_size * 2))
7831 echo "OSS cache size: $cache_size KB"
7832 echo "Large file size: $large_file_size KB"
7834 [ $MAXV -le $large_file_size ] && \
7835 skip_env "max available OST size needs > $large_file_size KB" && \
7838 $SETSTRIPE $file -c 1 -i $MAXI || error "$SETSTRIPE $file failed"
7840 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k || \
7841 error "dd of=$temp bs=$large_file_size count=1k failed"
7844 cancel_lru_locks osc
7845 cmp $temp $file || error "$temp $file differ"
7853 set_cache writethrough on
7856 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
7860 set_cache writethrough off
7863 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
7867 set_cache writethrough on
7870 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
7874 set_cache writethrough off
7877 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
7881 set_cache writethrough on
7884 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
7888 set_cache writethrough off
7891 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
7895 set_cache writethrough on
7898 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
7902 set_cache writethrough off
7905 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
7911 local file="$DIR/$tfile"
7913 log "Turn on read and write cache"
7915 set_cache writethrough on
7917 log "Write data and read it back."
7918 log "Read should be satisfied from the cache."
7919 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
7921 cancel_lru_locks osc
7922 cat $file >/dev/null
7924 if ! let "AFTER - BEFORE == CPAGES"; then
7925 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
7927 log "cache hits:: before: $BEFORE, after: $AFTER"
7930 log "Read again; it should be satisfied from the cache."
7932 cancel_lru_locks osc
7933 cat $file >/dev/null
7935 if ! let "AFTER - BEFORE == CPAGES"; then
7936 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
7938 log "cache hits:: before: $BEFORE, after: $AFTER"
7942 log "Turn off the read cache and turn on the write cache"
7944 set_cache writethrough on
7946 log "Read again; it should be satisfied from the cache."
7948 cancel_lru_locks osc
7949 cat $file >/dev/null
7951 if ! let "AFTER - BEFORE == CPAGES"; then
7952 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
7954 log "cache hits:: before: $BEFORE, after: $AFTER"
7957 log "Read again; it should not be satisfied from the cache."
7959 cancel_lru_locks osc
7960 cat $file >/dev/null
7962 if ! let "AFTER - BEFORE == 0"; then
7963 error "IN CACHE: before: $BEFORE, after: $AFTER"
7965 log "cache hits:: before: $BEFORE, after: $AFTER"
7968 log "Write data and read it back."
7969 log "Read should be satisfied from the cache."
7970 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
7972 cancel_lru_locks osc
7973 cat $file >/dev/null
7975 if ! let "AFTER - BEFORE == CPAGES"; then
7976 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
7978 log "cache hits:: before: $BEFORE, after: $AFTER"
7981 log "Read again; it should not be satisfied from the cache."
7983 cancel_lru_locks osc
7984 cat $file >/dev/null
7986 if ! let "AFTER - BEFORE == 0"; then
7987 error "IN CACHE: before: $BEFORE, after: $AFTER"
7989 log "cache hits:: before: $BEFORE, after: $AFTER"
7993 log "Turn off read and write cache"
7995 set_cache writethrough off
7997 log "Write data and read it back"
7998 log "It should not be satisfied from the cache."
8000 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
8001 cancel_lru_locks osc
8003 cat $file >/dev/null
8005 if ! let "AFTER - BEFORE == 0"; then
8006 error_ignore 20762 "IN CACHE: before: $BEFORE, after: $AFTER"
8008 log "cache hits:: before: $BEFORE, after: $AFTER"
8012 log "Turn on the read cache and turn off the write cache"
8014 set_cache writethrough off
8016 log "Write data and read it back"
8017 log "It should not be satisfied from the cache."
8019 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
8021 cancel_lru_locks osc
8022 cat $file >/dev/null
8024 if ! let "AFTER - BEFORE == 0"; then
8025 error_ignore 20762 "IN CACHE: before: $BEFORE, after: $AFTER"
8027 log "cache hits:: before: $BEFORE, after: $AFTER"
8030 log "Read again; it should be satisfied from the cache."
8032 cancel_lru_locks osc
8033 cat $file >/dev/null
8035 if ! let "AFTER - BEFORE == CPAGES"; then
8036 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
8038 log "cache hits:: before: $BEFORE, after: $AFTER"
8043 run_test 156 "Verification of tunables ============================"
8047 if [ $MDSCOUNT -gt 1 ]; then
8048 error_ignore 17935 $*
8056 MASK=$(do_facet $SINGLEMDS $LCTL get_param mdd.$MDT0.changelog_mask |\
8059 if [ $MASK -eq 1 ]; then
8060 do_facet $SINGLEMDS $LCTL set_param mdd.$MDT0.changelog_mask="-$1"
8062 do_facet $SINGLEMDS $LCTL set_param mdd.$MDT0.changelog_mask="+$1"
8067 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8068 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
8069 { skip "Need MDS version at least 2.2.0"; return; }
8070 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
8071 echo "Registered as changelog user $USER"
8072 do_facet $SINGLEMDS $LCTL get_param -n mdd.$MDT0.changelog_users | \
8073 grep -q $USER || error "User $USER not found in changelog_users"
8076 mkdir -p $DIR/$tdir/pics/2008/zachy
8077 touch $DIR/$tdir/pics/2008/zachy/timestamp
8078 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
8079 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
8080 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
8081 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
8082 rm $DIR/$tdir/pics/desktop.jpg
8084 $LFS changelog $MDT0 | tail -5
8086 echo "verifying changelog mask"
8087 changelog_chmask "MKDIR"
8088 changelog_chmask "CLOSE"
8090 mkdir -p $DIR/$tdir/pics/zach/sofia
8091 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
8093 changelog_chmask "MKDIR"
8094 changelog_chmask "CLOSE"
8096 mkdir -p $DIR/$tdir/pics/2008/sofia
8097 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
8099 $LFS changelog $MDT0
8100 MKDIRS=$($LFS changelog $MDT0 | tail -5 | grep -c "MKDIR")
8101 CLOSES=$($LFS changelog $MDT0 | tail -5 | grep -c "CLOSE")
8102 [ $MKDIRS -eq 1 ] || err17935 "MKDIR changelog mask count $DIRS != 1"
8103 [ $CLOSES -eq 1 ] || err17935 "CLOSE changelog mask count $DIRS != 1"
8106 echo "verifying target fid"
8107 fidc=$($LFS changelog $MDT0 | grep timestamp | grep "CREAT" | \
8108 tail -1 | awk '{print $6}')
8109 fidf=$($LFS path2fid $DIR/$tdir/pics/zach/timestamp)
8110 [ "$fidc" == "t=$fidf" ] || \
8111 err17935 "fid in changelog $fidc != file fid $fidf"
8112 echo "verifying parent fid"
8113 fidc=$($LFS changelog $MDT0 | grep timestamp | grep "CREAT" | \
8114 tail -1 | awk '{print $7}')
8115 fidf=$($LFS path2fid $DIR/$tdir/pics/zach)
8116 [ "$fidc" == "p=$fidf" ] || \
8117 err17935 "pfid in changelog $fidc != dir fid $fidf"
8119 USER_REC1=$(do_facet $SINGLEMDS $LCTL get_param -n \
8120 mdd.$MDT0.changelog_users | grep $USER | awk '{print $2}')
8121 $LFS changelog_clear $MDT0 $USER $(($USER_REC1 + 5))
8122 USER_REC2=$(do_facet $SINGLEMDS $LCTL get_param -n \
8123 mdd.$MDT0.changelog_users | grep $USER | awk '{print $2}')
8124 echo "verifying user clear: $(( $USER_REC1 + 5 )) == $USER_REC2"
8125 [ $USER_REC2 == $(($USER_REC1 + 5)) ] || \
8126 err17935 "user index should be $(($USER_REC1 + 5)); is $USER_REC2"
8128 MIN_REC=$(do_facet $SINGLEMDS $LCTL get_param mdd.$MDT0.changelog_users | \
8129 awk 'min == "" || $2 < min {min = $2}; END {print min}')
8130 FIRST_REC=$($LFS changelog $MDT0 | head -1 | awk '{print $1}')
8131 echo "verifying min purge: $(( $MIN_REC + 1 )) == $FIRST_REC"
8132 [ $FIRST_REC == $(($MIN_REC + 1)) ] || \
8133 err17935 "first index should be $(($MIN_REC + 1)); is $FIRST_REC"
8135 echo "verifying user deregister"
8136 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
8137 do_facet $SINGLEMDS $LCTL get_param -n mdd.$MDT0.changelog_users | \
8138 grep -q $USER && error "User $USER still found in changelog_users"
8140 USERS=$(( $(do_facet $SINGLEMDS $LCTL get_param -n \
8141 mdd.$MDT0.changelog_users | wc -l) - 2 ))
8142 if [ $USERS -eq 0 ]; then
8143 LAST_REC1=$(do_facet $SINGLEMDS $LCTL get_param -n \
8144 mdd.$MDT0.changelog_users | head -1 | awk '{print $3}')
8145 touch $DIR/$tdir/chloe
8146 LAST_REC2=$(do_facet $SINGLEMDS $LCTL get_param -n \
8147 mdd.$MDT0.changelog_users | head -1 | awk '{print $3}')
8148 echo "verify changelogs are off if we were the only user: $LAST_REC1 == $LAST_REC2"
8149 [ $LAST_REC1 == $LAST_REC2 ] || error "changelogs not off"
8151 echo "$USERS other changelog users; can't verify off"
8154 run_test 160 "changelog sanity"
8158 cp /etc/hosts $DIR/$tdir/$tfile
8159 mkdir $DIR/$tdir/foo1
8160 mkdir $DIR/$tdir/foo2
8161 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
8162 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
8163 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
8164 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
8165 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[')
8166 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
8167 $LFS fid2path $DIR $FID
8168 err17935 "bad link ea"
8171 rm $DIR/$tdir/foo2/zachary
8173 rm $DIR/$tdir/foo2/thor
8175 rm $DIR/$tdir/$tfile
8177 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
8178 if [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ]
8180 $LFS fid2path $DIR $FID
8181 err17935 "bad link rename"
8183 rm $DIR/$tdir/foo2/maggie
8186 local longname=filename_avg_len_is_thirty_two_
8187 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 || \
8188 error "failed to hardlink many files"
8189 links=$($LFS fid2path $DIR $FID | wc -l)
8190 echo -n "${links}/1000 links in link EA"
8191 [ ${links} -gt 60 ] || err17935 "expected at least 60 links in link EA"
8192 unlinkmany $DIR/$tdir/foo2/$longname 1000 || \
8193 error "failed to unlink many hardlinks"
8195 run_test 161 "link ea sanity"
8202 local path=$(${LFS} fid2path $*)
8205 if [ $RC -ne 0 ]; then
8206 err17935 "path looked up of $expected failed. Error $RC"
8208 elif [ "${path}" != "${expected}" ]; then
8209 err17935 "path looked up \"${path}\" instead of \"${expected}\""
8212 echo "fid $fid resolves to path $path (expected $expected)"
8216 # Make changes to filesystem
8217 mkdir -p $DIR/$tdir/d2
8218 touch $DIR/$tdir/d2/$tfile
8219 touch $DIR/$tdir/d2/x1
8220 touch $DIR/$tdir/d2/x2
8221 mkdir -p $DIR/$tdir/d2/a/b/c
8222 mkdir -p $DIR/$tdir/d2/p/q/r
8224 FID=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
8225 check_path "$tdir/d2/$tfile" $FSNAME $FID --link 0
8228 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
8229 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
8230 check_path "$tdir/d2/p/q/r/slink" $FSNAME $FID --link 0
8232 # softlink to wrong file
8233 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
8234 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
8235 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME $FID --link 0
8238 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
8239 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
8240 FID=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
8241 # fid2path dir/fsname should both work
8242 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 1
8243 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR $FID --link 0
8245 # hardlink count: check that there are 2 links
8246 # Doesnt work with CMD yet: 17935
8247 ${LFS} fid2path $DIR $FID | wc -l | grep -q 2 || \
8248 err17935 "expected 2 links"
8250 # hardlink indexing: remove the first link
8251 rm $DIR/$tdir/d2/p/q/r/hlink
8252 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 0
8256 run_test 162 "path lookup sanity"
8259 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8260 copytool --test $FSNAME || { skip "copytool not runnable: $?" && return; }
8263 local uuid=$($LCTL get_param -n mdc.${FSNAME}-MDT0000-mdc-*.uuid)
8264 # this proc file is temporary and linux-only
8265 do_facet $SINGLEMDS lctl set_param mdt.${FSNAME}-MDT0000.mdccomm=$uuid ||\
8266 error "kernel->userspace send failed"
8269 run_test 163 "kernel <-> userspace comms"
8272 # do directio so as not to populate the page cache
8273 log "creating a 10 Mb file"
8274 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
8275 log "starting reads"
8276 dd if=$DIR/$tfile of=/dev/null bs=4096 &
8277 log "truncating the file"
8278 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
8280 kill %+ || true # reads might have finished
8281 echo "wait until dd is finished"
8283 log "removing the temporary file"
8284 rm -rf $DIR/$tfile || error "tmp file removal failed"
8286 run_test 169 "parallel read and truncate should not deadlock"
8289 $LCTL clear # bug 18514
8290 $LCTL debug_daemon start $TMP/${tfile}_log_good
8292 $LCTL debug_daemon stop
8293 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
8294 error "sed failed to read log_good"
8296 $LCTL debug_daemon start $TMP/${tfile}_log_good
8298 $LCTL debug_daemon stop
8300 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
8301 error "lctl df log_bad failed"
8303 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
8304 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
8306 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
8307 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
8309 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
8310 error "bad_line good_line1 good_line2 are empty"
8312 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
8313 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
8314 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
8316 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
8317 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
8318 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
8320 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
8321 error "bad_line_new good_line_new are empty"
8323 local expected_good=$((good_line1 + good_line2*2))
8325 rm -f $TMP/${tfile}*
8326 # LU-231, short malformed line may not be counted into bad lines
8327 if [ $bad_line -ne $bad_line_new ] &&
8328 [ $bad_line -ne $((bad_line_new - 1)) ]; then
8329 error "expected $bad_line bad lines, but got $bad_line_new"
8333 if [ $expected_good -ne $good_line_new ]; then
8334 error "expected $expected_good good lines, but got $good_line_new"
8339 run_test 170 "test lctl df to handle corrupted log ====================="
8341 test_171() { # bug20592
8342 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
8343 $LCTL set_param fail_loc=0x50e
8344 $LCTL set_param fail_val=3000
8345 multiop_bg_pause $DIR/$tfile O_s || true
8347 kill -USR1 $MULTIPID
8351 if dmesg | grep "recursive fault"; then
8352 error "caught a recursive fault"
8354 $LCTL set_param fail_loc=0
8357 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
8359 # it would be good to share it with obdfilter-survey/libecho code
8360 setup_obdecho_osc () {
8363 local obdfilter_name=$2
8364 echo "Creating new osc for $obdfilter_name on $ost_nid"
8365 # make sure we can find loopback nid
8366 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
8368 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
8369 ${obdfilter_name}_osc_UUID || rc=2; }
8370 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
8371 ${obdfilter_name}_UUID $ost_nid || rc=3; }
8375 cleanup_obdecho_osc () {
8376 local obdfilter_name=$1
8377 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
8378 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
8382 obdecho_create_test() {
8387 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
8388 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
8390 if [ $rc -eq 0 ]; then
8391 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
8392 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
8394 echo "New object id is $id"
8395 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec test_brw 10 w v 64 $id" ||
8397 [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec " \
8398 "cleanup" || rc=5; }
8399 [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec " \
8401 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
8406 remote_ost_nodsh && skip "remote OST with nodsh" && return
8410 if ! module_loaded obdecho; then
8411 load_module obdecho/obdecho
8415 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
8416 local host=$(lctl get_param -n osc.$osc.import |
8417 awk '/current_connection:/ {print $2}' )
8418 local target=$(lctl get_param -n osc.$osc.import |
8419 awk '/target:/ {print $2}' )
8420 target=${target%_UUID}
8422 [[ -n $target ]] && { setup_obdecho_osc $host $target || rc=1; } || rc=1
8423 [ $rc -eq 0 ] && { obdecho_create_test ${target}_osc client || rc=2; }
8424 [[ -n $target ]] && cleanup_obdecho_osc $target
8425 [ $rmmod_local -eq 1 ] && rmmod obdecho
8428 run_test 180a "test obdecho on osc"
8431 remote_ost_nodsh && skip "remote OST with nodsh" && return
8433 local rmmod_remote=0
8435 do_facet ost1 "lsmod | grep -q obdecho || " \
8436 "{ insmod ${LUSTRE}/obdecho/obdecho.ko || " \
8437 "modprobe obdecho; }" && rmmod_remote=1
8438 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ {print $4;exit}')
8439 [[ -n $target ]] && { obdecho_create_test $target ost1 || rc=1; }
8440 [ $rmmod_remote -eq 1 ] && do_facet ost1 "rmmod obdecho"
8443 run_test 180b "test obdecho directly on obdfilter"
8445 test_181() { # bug 22177
8446 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
8447 # create enough files to index the directory
8448 createmany -o $DIR/$tdir/foobar 4000
8449 # print attributes for debug purpose
8452 multiop_bg_pause $DIR/$tdir D_Sc || return 1
8454 # remove the files & current working dir
8455 unlinkmany $DIR/$tdir/foobar 4000
8457 kill -USR1 $MULTIPID
8459 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
8462 run_test 181 "Test open-unlinked dir ========================"
8465 # disable MDC RPC lock wouldn't crash client
8469 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
8470 #define OBD_FAIL_MDC_RPCS_SEM 0x804
8471 $LCTL set_param fail_loc=0x804
8473 for (( i=0; i < $tcount; i++ )) ; do
8475 createmany -o $DIR/$tdir/$i/f- $fcount &
8479 for (( i=0; i < $tcount; i++ )) ; do
8480 unlinkmany $DIR/$tdir/$i/f- $fcount &
8486 $LCTL set_param fail_loc=0
8488 run_test 182 "Disable MDC RPCs semaphore wouldn't crash client ================"
8494 TGTPOOL_MAX=$(($TGT_COUNT - 1))
8496 TGTPOOL_LIST=`seq $TGTPOOL_FIRST $TGTPOOL_STEP $TGTPOOL_MAX`
8497 POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
8498 POOL_DIR_NAME=dir_tst
8499 POOL_DIR=$POOL_ROOT/$POOL_DIR_NAME
8500 POOL_FILE=$POOL_ROOT/file_tst
8502 check_file_in_pool()
8505 res=$($GETSTRIPE $file | grep 0x | cut -f2)
8508 found=$(echo :$TGTPOOL_LIST: | tr " " ":" | grep :$i:)
8509 if [[ "$found" == "" ]]
8511 echo "pool list: $TGTPOOL_LIST"
8512 echo "striping: $res"
8513 error "$file not allocated in $POOL"
8520 trap "cleanup_pools $FSNAME" EXIT
8523 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
8524 create_pool $FSNAME.$POOL || return $?
8525 [ $($LFS pool_list $FSNAME | grep -c $POOL) -eq 1 ] ||
8526 error "$POOL not in lfs pool_list"
8528 run_test 200a "Create new pool =========================================="
8531 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
8532 TGT=$(for i in $TGTPOOL_LIST; do printf "$FSNAME-OST%04x_UUID " $i; done)
8533 do_facet mgs $LCTL pool_add $FSNAME.$POOL \
8534 $FSNAME-OST[$TGTPOOL_FIRST-$TGTPOOL_MAX/$TGTPOOL_STEP]
8535 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL | sort -u | tr '\n' ' ' " "$TGT" ||
8536 error "Add to pool failed"
8537 local lfscount=$($LFS pool_list $FSNAME.$POOL | grep -c "\-OST")
8538 local addcount=$((($TGTPOOL_MAX - $TGTPOOL_FIRST) / $TGTPOOL_STEP + 1))
8539 [ $lfscount -eq $addcount ] ||
8540 error "lfs pool_list bad ost count $lfscount != $addcount"
8542 run_test 200b "Add targets to a pool ===================================="
8545 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
8547 $SETSTRIPE -c 2 -p $POOL $POOL_DIR
8548 [ $? = 0 ] || error "Cannot set pool $POOL to $POOL_DIR"
8549 # b-19919 test relative path works well
8550 mkdir -p $POOL_DIR/$POOL_DIR_NAME
8552 $SETSTRIPE -c 2 -p $POOL $POOL_DIR_NAME
8553 [ $? = 0 ] || error "Cannot set pool $POOL to $POOL_DIR/$POOL_DIR_NAME"
8554 $SETSTRIPE -c 2 -p $POOL ./$POOL_DIR_NAME
8555 [ $? = 0 ] || error "Cannot set pool $POOL to $POOL_DIR/./$POOL_DIR_NAME"
8556 $SETSTRIPE -c 2 -p $POOL ../$POOL_DIR_NAME
8557 [ $? = 0 ] || error "Cannot set pool $POOL to $POOL_DIR/../$POOL_DIR_NAME"
8558 $SETSTRIPE -c 2 -p $POOL ../$POOL_DIR_NAME/$POOL_DIR_NAME
8559 [ $? = 0 ] || error "Cannot set pool $POOL to $POOL_DIR/../$POOL_DIR_NAME/$POOL_DIR_NAME"
8560 rm -rf $POOL_DIR_NAME; cd -
8562 run_test 200c "Set pool on a directory ================================="
8565 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
8566 res=$($GETSTRIPE --pool $POOL_DIR)
8567 [ $res = $POOL ] || error "Pool on $POOL_DIR is $res, not $POOL"
8569 run_test 200d "Check pool on a directory ==============================="
8572 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
8574 for i in $(seq -w 1 $(($TGT_COUNT * 3)))
8576 file=$POOL_DIR/file-$i
8578 check_file_in_pool $file
8581 failed=$(($failed + 1))
8584 [ "$failed" = 0 ] || error "$failed files not allocated in $POOL"
8586 run_test 200e "Check files allocation from directory pool =============="
8589 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
8592 for i in $(seq -w 1 $(($TGT_COUNT * 3)))
8594 file=$POOL_FILE/spoo-$i
8595 $SETSTRIPE -p $POOL $file
8596 check_file_in_pool $file
8599 failed=$(($failed + 1))
8602 [ "$failed" = 0 ] || error "$failed files not allocated in $POOL"
8604 run_test 200f "Create files in a pool ==================================="
8607 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
8608 TGT=$($LCTL get_param -n lov.$FSNAME-clilov-*.pools.$POOL | tr '\n' ' ')
8609 res=$($LFS df --pool $FSNAME.$POOL | awk '{print $1}' | grep "$FSNAME-OST" | tr '\n' ' ')
8610 [ "$res" = "$TGT" ] || error "Pools OSTs '$TGT' is not '$res' that lfs df reports"
8612 run_test 200g "lfs df a pool ============================================"
8614 test_200h() { # b=24039
8615 mkdir -p $POOL_DIR || error "unable to create $POOL_DIR"
8617 local file="/..$POOL_DIR/$tfile-1"
8618 $SETSTRIPE -p $POOL $file || error "unable to create $file"
8621 $SETSTRIPE -p $POOL $tfile-2 || \
8622 error "unable to create $tfile-2 in $POOL_DIR"
8624 run_test 200h "Create files in a pool with relative pathname ============"
8627 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
8628 TGT=$($LCTL get_param -n lov.$FSNAME-*.pools.$POOL | head -1)
8629 do_facet mgs $LCTL pool_remove $FSNAME.$POOL $TGT
8630 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL | grep $TGT" "" ||
8631 error "$TGT not removed from $FSNAME.$POOL"
8633 run_test 201a "Remove a target from a pool ============================="
8636 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
8637 for TGT in $($LCTL get_param -n lov.$FSNAME-*.pools.$POOL | sort -u)
8639 do_facet mgs $LCTL pool_remove $FSNAME.$POOL $TGT
8641 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL" "" ||
8642 error "Pool $FSNAME.$POOL cannot be drained"
8643 # striping on an empty/nonexistant pool should fall back to "pool of everything"
8644 touch ${POOL_DIR}/$tfile || error "failed to use fallback striping for empty pool"
8645 # setstripe on an empty pool should fail
8646 $SETSTRIPE -p $POOL ${POOL_FILE}/$tfile 2>/dev/null && \
8647 error "expected failure when creating file with empty pool"
8650 run_test 201b "Remove all targets from a pool =========================="
8653 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
8654 do_facet mgs $LCTL pool_destroy $FSNAME.$POOL
8657 # striping on an empty/nonexistant pool should fall back to "pool of everything"
8658 touch ${POOL_DIR}/$tfile || error "failed to use fallback striping for missing pool"
8659 # setstripe on an empty pool should fail
8660 $SETSTRIPE -p $POOL ${POOL_FILE}/$tfile 2>/dev/null && \
8661 error "expected failure when creating file with missing pool"
8663 # get param should return err once pool is gone
8664 if wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null ||
8665 echo foo" "foo"; then
8666 remove_pool_from_list $FSNAME.$POOL
8669 error "Pool $FSNAME.$POOL is not destroyed"
8671 run_test 201c "Remove a pool ============================================"
8673 cleanup_pools $FSNAME
8675 # usage: default_attr <count | size | offset>
8677 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
8680 # usage: check_default_stripe_attr
8681 check_default_stripe_attr() {
8682 ACTUAL=$($GETSTRIPE $* $DIR/$tdir)
8684 --stripe-count|--count)
8685 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
8686 --stripe-size|--size)
8687 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
8688 --stripe-index|--index)
8691 error "unknown getstripe attr '$1'"
8694 [ $ACTUAL != $EXPECTED ] &&
8695 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
8700 $SETSTRIPE --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
8702 check_default_stripe_attr --stripe-count
8703 check_default_stripe_attr --stripe-size
8704 check_default_stripe_attr --stripe-index
8708 run_test 204a "Print default stripe attributes ================="
8712 $SETSTRIPE --stripe-count 1 $DIR/$tdir
8714 check_default_stripe_attr --stripe-size
8715 check_default_stripe_attr --stripe-index
8719 run_test 204b "Print default stripe size and offset ==========="
8723 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
8725 check_default_stripe_attr --stripe-count
8726 check_default_stripe_attr --stripe-index
8730 run_test 204c "Print default stripe count and offset ==========="
8734 $SETSTRIPE --stripe-index 0 $DIR/$tdir
8736 check_default_stripe_attr --stripe-count
8737 check_default_stripe_attr --stripe-size
8741 run_test 204d "Print default stripe count and size ============="
8745 $SETSTRIPE -d $DIR/$tdir
8747 check_default_stripe_attr --stripe-count --raw
8748 check_default_stripe_attr --stripe-size --raw
8749 check_default_stripe_attr --stripe-index --raw
8753 run_test 204e "Print raw stripe attributes ================="
8757 $SETSTRIPE --stripe-count 1 $DIR/$tdir
8759 check_default_stripe_attr --stripe-size --raw
8760 check_default_stripe_attr --stripe-index --raw
8764 run_test 204f "Print raw stripe size and offset ==========="
8768 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
8770 check_default_stripe_attr --stripe-count --raw
8771 check_default_stripe_attr --stripe-index --raw
8775 run_test 204g "Print raw stripe count and offset ==========="
8779 $SETSTRIPE --stripe-index 0 $DIR/$tdir
8781 check_default_stripe_attr --stripe-count --raw
8782 check_default_stripe_attr --stripe-size --raw
8786 run_test 204h "Print raw stripe count and size ============="
8788 # Figure out which job scheduler is being used, if any,
8790 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
8792 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
8794 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
8796 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
8797 JOBENV=LOADL_STEP_ID
8798 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
8808 # clear old jobstats
8809 do_facet $SINGLEMDS lctl set_param mdt.*.job_stats="clear"
8810 do_facet ost0 lctl set_param obdfilter.*.job_stats="clear"
8812 # use a new JobID for this test, or we might see an old one
8813 [ "$JOBENV" = "FAKE_JOBID" ] && FAKE_JOBID=test_id.$testnum.$RANDOM
8817 log "Using JobID environment variable $JOBENV=$JOBVAL"
8819 if [ $JOBENV = "FAKE_JOBID" ]; then
8820 FAKE_JOBID=$JOBVAL $cmd
8825 if [ "$target" = "mdt" -o "$target" = "both" ]; then
8826 FACET="$SINGLEMDS" # will need to get MDS number for DNE
8827 do_facet $FACET lctl get_param mdt.*.job_stats |
8828 grep $JOBVAL || error "No job stats found on MDT $FACET"
8830 if [ "$target" = "ost" -o "$target" = "both" ]; then
8832 do_facet $FACET lctl get_param obdfilter.*.job_stats |
8833 grep $JOBVAL || error "No job stats found on OST $FACET"
8837 test_205() { # Job stats
8839 OLD_JOBENV=`$LCTL get_param -n jobid_var`
8840 if [ $OLD_JOBENV != $JOBENV ]; then
8841 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$JOBENV
8842 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" \
8847 cmd="mkdir $DIR/$tfile"
8848 verify_jobstats "$cmd" "mdt"
8850 cmd="rm -fr $DIR/$tfile"
8851 verify_jobstats "$cmd" "mdt"
8853 cmd="mknod $DIR/$tfile c 1 3"
8854 verify_jobstats "$cmd" "mdt"
8856 cmd="rm -f $DIR/$tfile"
8857 verify_jobstats "$cmd" "mdt"
8859 cmd="$SETSTRIPE -i 0 -c 1 $DIR/$tfile"
8860 verify_jobstats "$cmd" "mdt"
8862 cmd="touch $DIR/$tfile"
8863 verify_jobstats "$cmd" "both"
8865 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
8866 verify_jobstats "$cmd" "ost"
8868 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
8869 verify_jobstats "$cmd" "ost"
8871 cmd="$TRUNCATE $DIR/$tfile 0"
8872 verify_jobstats "$cmd" "both"
8874 cmd="mv -f $DIR/$tfile $DIR/jobstats_test_rename"
8875 verify_jobstats "$cmd" "mdt"
8878 rm -f $DIR/jobstats_test_rename
8880 if [ $OLD_JOBENV != $JOBENV ]; then
8881 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$OLD_JOBENV
8882 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" \
8883 $OLD_JOBENV || return 1
8886 run_test 205 "Verify job stats"
8890 size=$((size % 8192 + 1))
8891 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
8892 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
8893 rm -f $DIR/f212 $DIR/f212.xyz
8895 run_test 212 "Sendfile test ============================================"
8898 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
8899 cancel_lru_locks osc
8900 lctl set_param fail_loc=0x8000040f
8901 # generate a read lock
8902 cat $DIR/$tfile > /dev/null
8903 # write to the file, it will try to cancel the above read lock.
8904 cat /etc/hosts >> $DIR/$tfile
8906 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
8908 test_214() { # for bug 20133
8909 mkdir -p $DIR/d214p/d214c
8910 for (( i=0; i < 340; i++ )) ; do
8911 touch $DIR/d214p/d214c/a$i
8914 ls -l $DIR/d214p || error "ls -l $DIR/d214p failed"
8915 mv $DIR/d214p/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
8916 ls $DIR/d214c || error "ls $DIR/d214c failed"
8917 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
8919 run_test 214 "hash-indexed directory test - bug 20133"
8921 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
8922 create_lnet_proc_files() {
8923 cat /proc/sys/lnet/$1 >$TMP/lnet_$1.out || error "cannot read /proc/sys/lnet/$1"
8924 sysctl lnet.$1 >$TMP/lnet_$1.sys_tmp || error "cannot read lnet.$1"
8926 sed "s/^lnet.$1\ =\ //g" "$TMP/lnet_$1.sys_tmp" >$TMP/lnet_$1.sys
8927 rm -f "$TMP/lnet_$1.sys_tmp"
8930 # counterpart of create_lnet_proc_files
8931 remove_lnet_proc_files() {
8932 rm -f $TMP/lnet_$1.out $TMP/lnet_$1.sys
8935 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
8936 # 3rd arg as regexp for body
8937 check_lnet_proc_stats() {
8938 local l=$(cat "$TMP/lnet_$1" |wc -l)
8939 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
8941 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
8944 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
8945 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
8946 # optional and can be regexp for 2nd line (lnet.routes case)
8947 check_lnet_proc_entry() {
8948 local blp=2 # blp stands for 'position of 1st line of body'
8949 [ "$5" = "" ] || blp=3 # lnet.routes case
8951 local l=$(cat "$TMP/lnet_$1" |wc -l)
8952 # subtracting one from $blp because the body can be empty
8953 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
8955 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
8956 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
8958 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
8959 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
8961 # bail out if any unexpected line happened
8962 sed -n "$blp~1 p" "$TMP/lnet_$1" |grep -Ev "$3"
8963 [ "$?" != 0 ] || error "$2 misformatted"
8966 test_215() { # for bugs 18102, 21079, 21517
8967 local N='(0|[1-9][0-9]*)' # non-negative numeric
8968 local P='[1-9][0-9]*' # positive numeric
8969 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
8970 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
8971 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
8972 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
8974 local L1 # regexp for 1st line
8975 local L2 # regexp for 2nd line (optional)
8976 local BR # regexp for the rest (body)
8978 # /proc/sys/lnet/stats should look as 11 space-separated non-negative numerics
8979 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
8980 create_lnet_proc_files "stats"
8981 check_lnet_proc_stats "stats.out" "/proc/sys/lnet/stats" "$BR"
8982 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
8983 remove_lnet_proc_files "stats"
8985 # /proc/sys/lnet/routes should look like this:
8986 # Routing disabled/enabled
8987 # net hops state router
8988 # where net is a string like tcp0, hops >= 0, state is up/down,
8989 # router is a string like 192.168.1.1@tcp2
8990 L1="^Routing (disabled|enabled)$"
8991 L2="^net +hops +state +router$"
8992 BR="^$NET +$N +(up|down) +$NID$"
8993 create_lnet_proc_files "routes"
8994 check_lnet_proc_entry "routes.out" "/proc/sys/lnet/routes" "$BR" "$L1" "$L2"
8995 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
8996 remove_lnet_proc_files "routes"
8998 # /proc/sys/lnet/routers should look like this:
8999 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
9000 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
9001 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
9002 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
9003 L1="^ref +rtr_ref +alive_cnt +state +last_ping +ping_sent +deadline +down_ni +router$"
9004 BR="^$P +$P +$N +(up|down) +$N +(0|1) +$I +$I +$NID$"
9005 create_lnet_proc_files "routers"
9006 check_lnet_proc_entry "routers.out" "/proc/sys/lnet/routers" "$BR" "$L1"
9007 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
9008 remove_lnet_proc_files "routers"
9010 # /proc/sys/lnet/peers should look like this:
9011 # nid refs state last max rtr min tx min queue
9012 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
9013 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
9014 # numeric (0 or >0 or <0), queue >= 0.
9015 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
9016 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
9017 create_lnet_proc_files "peers"
9018 check_lnet_proc_entry "peers.out" "/proc/sys/lnet/peers" "$BR" "$L1"
9019 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
9020 remove_lnet_proc_files "peers"
9022 # /proc/sys/lnet/buffers should look like this:
9023 # pages count credits min
9024 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
9025 L1="^pages +count +credits +min$"
9026 BR="^ +$N +$N +$I +$I$"
9027 create_lnet_proc_files "buffers"
9028 check_lnet_proc_entry "buffers.out" "/proc/sys/lnet/buffers" "$BR" "$L1"
9029 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
9030 remove_lnet_proc_files "buffers"
9032 # /proc/sys/lnet/nis should look like this:
9033 # nid status alive refs peer rtr max tx min
9034 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
9035 # alive is numeric (0 or >0 or <0), refs > 0, peer >= 0,
9036 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
9037 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
9038 BR="^$NID +(up|down) +$I +$P +$N +$N +$N +$I +$I$"
9039 create_lnet_proc_files "nis"
9040 check_lnet_proc_entry "nis.out" "/proc/sys/lnet/nis" "$BR" "$L1"
9041 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
9042 remove_lnet_proc_files "nis"
9044 # can we successfully write to /proc/sys/lnet/stats?
9045 echo "0" >/proc/sys/lnet/stats || error "cannot write to /proc/sys/lnet/stats"
9046 sysctl -w lnet.stats=0 || error "cannot write to lnet.stats"
9048 run_test 215 "/proc/sys/lnet exists and has proper content - bugs 18102, 21079, 21517"
9050 test_216() { # bug 20317
9051 remote_ost_nodsh && skip "remote OST with nodsh" && return
9053 local p="$TMP/sanityN-$TESTNAME.parameters"
9054 save_lustre_params $HOSTNAME "osc.*.contention_seconds" > $p
9055 for node in $(osts_nodes); do
9056 save_lustre_params $node "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
9057 save_lustre_params $node "ldlm.namespaces.filter-*.contended_locks" >> $p
9058 save_lustre_params $node "ldlm.namespaces.filter-*.contention_seconds" >> $p
9062 # agressive lockless i/o settings
9063 for node in $(osts_nodes); do
9064 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'
9066 lctl set_param -n osc.*.contention_seconds 60
9068 $DIRECTIO write $DIR/$tfile 0 10 4096
9069 $CHECKSTAT -s 40960 $DIR/$tfile
9071 # disable lockless i/o
9072 for node in $(osts_nodes); do
9073 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'
9075 lctl set_param -n osc.*.contention_seconds 0
9078 dd if=/dev/zero of=$DIR/$tfile count=0
9079 $CHECKSTAT -s 0 $DIR/$tfile
9081 restore_lustre_params <$p
9085 run_test 216 "check lockless direct write works and updates file size and kms correctly"
9087 test_217() { # bug 22430
9091 for node in $(nodes_list); do
9092 nid=$(host_nids_address $node $NETTYPE)
9093 if [[ $nid = *-* ]] ; then
9094 echo "lctl ping $nid@$NETTYPE"
9095 lctl ping $nid@$NETTYPE
9097 echo "skipping $node (no hyphen detected)"
9101 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
9104 # do directio so as not to populate the page cache
9105 log "creating a 10 Mb file"
9106 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
9107 log "starting reads"
9108 dd if=$DIR/$tfile of=/dev/null bs=4096 &
9109 log "truncating the file"
9110 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
9112 kill %+ || true # reads might have finished
9113 echo "wait until dd is finished"
9115 log "removing the temporary file"
9116 rm -rf $DIR/$tfile || error "tmp file removal failed"
9118 run_test 218 "parallel read and truncate should not deadlock ======================="
9121 # write one partial page
9122 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
9123 # set no grant so vvp_io_commit_write will do sync write
9124 $LCTL set_param fail_loc=0x411
9125 # write a full page at the end of file
9126 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
9128 $LCTL set_param fail_loc=0
9129 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
9130 $LCTL set_param fail_loc=0x411
9131 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
9133 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
9135 test_220() { #LU-325
9136 remote_ost_nodsh && skip "remote OST with nodsh" && return
9140 local OST=$(lfs osts | grep ${OSTIDX}": " | \
9141 awk '{print $2}' | sed -e 's/_UUID$//')
9144 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
9145 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
9146 osc.$mdtosc_proc1.prealloc_last_id)
9147 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
9148 osc.$mdtosc_proc1.prealloc_next_id)
9152 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
9153 #define OBD_FAIL_OST_ENOINO 0x229
9154 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
9155 do_facet mgs $LCTL pool_new $FSNAME.$TESTNAME || return 1
9156 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
9158 $SETSTRIPE $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
9160 MDSOBJS=$((last_id - next_id))
9161 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
9163 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
9164 echo "OST still has $count kbytes free"
9166 echo "create $MDSOBJS files @next_id..."
9167 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
9169 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
9170 osc.$mdtosc_proc1.prealloc_last_id)
9171 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
9172 osc.$mdtosc_proc1.prealloc_next_id)
9174 echo "after creation, last_id=$last_id2, next_id=$next_id2"
9179 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
9180 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
9182 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST || return 4
9183 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME || return 5
9184 echo "unlink $MDSOBJS files @$next_id..."
9185 unlinkmany $DIR/$tdir/f $MDSOBJS || return 6
9187 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
9190 dd if=`which date` of=$MOUNT/date oflag=sync
9191 chmod +x $MOUNT/date
9193 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
9194 $LCTL set_param fail_loc=0x80001401
9196 $MOUNT/date > /dev/null
9199 run_test 221 "make sure fault and truncate race to not cause OOM"
9204 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
9205 createmany -o $DIR/$tdir/$tfile 10
9206 cancel_lru_locks mdc
9207 cancel_lru_locks osc
9208 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
9209 $LCTL set_param fail_loc=0x31a
9210 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
9211 $LCTL set_param fail_loc=0
9214 run_test 222a "AGL for ls should not trigger CLIO lock failure ================"
9219 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
9220 createmany -o $DIR/$tdir/$tfile 10
9221 cancel_lru_locks mdc
9222 cancel_lru_locks osc
9223 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
9224 $LCTL set_param fail_loc=0x31a
9225 rm -r $DIR/$tdir || "AGL for rmdir failed"
9226 $LCTL set_param fail_loc=0
9228 run_test 222b "AGL for rmdir should not trigger CLIO lock failure ============="
9233 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
9234 createmany -o $DIR/$tdir/$tfile 10
9235 cancel_lru_locks mdc
9236 cancel_lru_locks osc
9237 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
9238 $LCTL set_param fail_loc=0x31b
9239 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
9240 $LCTL set_param fail_loc=0
9243 run_test 223 "osc reenqueue if without AGL lock granted ======================="
9245 test_224a() { # LU-1039, MRP-303
9246 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
9247 $LCTL set_param fail_loc=0x508
9248 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
9249 $LCTL set_param fail_loc=0
9252 run_test 224a "Don't panic on bulk IO failure"
9254 test_224b() { # LU-1039, MRP-303
9255 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
9256 cancel_lru_locks osc
9257 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
9258 $LCTL set_param fail_loc=0x515
9259 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
9260 $LCTL set_param fail_loc=0
9263 run_test 224b "Don't panic on bulk IO failure"
9265 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
9267 if [ -z ${MDSSURVEY} ]; then
9268 skip_env "mds-survey not found" && return
9270 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
9271 { skip "Need MDS version at least 2.2.51"; return; }
9273 local mds=$(facet_host $SINGLEMDS)
9274 local target=$(do_nodes $mds 'lctl dl' | \
9275 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
9277 local cmd1="file_count=1000 thrhi=4"
9278 local cmd2="dir_count=2 layer=mdd stripe_count=0"
9279 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
9280 local cmd="$cmd1 $cmd2 $cmd3"
9282 rm -f ${TMP}/mds_survey*
9284 eval $cmd || error "mds-survey with zero-stripe failed"
9285 cat ${TMP}/mds_survey*
9286 rm -f ${TMP}/mds_survey*
9288 run_test 225a "Metadata survey sanity with zero-stripe"
9291 if [ -z ${MDSSURVEY} ]; then
9292 skip_env "mds-survey not found" && return
9294 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
9295 { skip "Need MDS version at least 2.2.51"; return; }
9297 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
9298 skip_env "Need to mount OST to test" && return
9301 local mds=$(facet_host $SINGLEMDS)
9302 local target=$(do_nodes $mds 'lctl dl' | \
9303 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
9305 local cmd1="file_count=1000 thrhi=4"
9306 local cmd2="dir_count=2 layer=mdd stripe_count=1"
9307 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
9308 local cmd="$cmd1 $cmd2 $cmd3"
9310 rm -f ${TMP}/mds_survey*
9312 eval $cmd || error "mds-survey with stripe_count failed"
9313 cat ${TMP}/mds_survey*
9314 rm -f ${TMP}/mds_survey*
9316 run_test 225b "Metadata survey sanity with stripe_count = 1"
9318 mcreate_path2fid () {
9324 local path=$DIR/$tdir/$name
9329 $MCREATE --mode=$1 --major=$2 --minor=$3 $path || \
9330 error "error: cannot create $desc"
9332 fid=$($LFS path2fid $path)
9334 [ $rc -ne 0 ] && error "error: cannot get fid of a $desc"
9336 fid_path=$($LFS fid2path $DIR $fid)
9338 [ $rc -ne 0 ] && error "error: cannot get path of a $desc by fid"
9340 [ "$path" == "$fid_path" ] || \
9341 error "error: fid2path returned \`$fid_path', expected \`$path'"
9348 mcreate_path2fid 0010666 0 0 fifo "FIFO"
9349 mcreate_path2fid 0020666 1 3 null "character special file (null)"
9350 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
9351 mcreate_path2fid 0040666 0 0 dir "directory"
9352 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
9353 mcreate_path2fid 0100666 0 0 file "regular file"
9354 mcreate_path2fid 0120666 0 0 link "symbolic link"
9355 mcreate_path2fid 0140666 0 0 sock "socket"
9357 run_test 226 "call path2fid and fid2path on files of all type"
9359 # LU-1299 Executing or running ldd on a truncated executable does not
9360 # cause an out-of-memory condition.
9362 dd if=`which date` of=$MOUNT/date bs=1k count=1
9363 chmod +x $MOUNT/date
9365 $MOUNT/date > /dev/null
9366 ldd $MOUNT/date > /dev/null
9369 run_test 227 "running truncated executable does not cause OOM"
9372 # tests that do cleanup/setup should be run at the end
9377 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
9378 $LCTL set_param fail_loc=0x903
9379 # cancel_lru_locks mgc - does not work due to lctl set_param syntax
9380 for ls in /proc/fs/lustre/ldlm/namespaces/MGC*/lru_size; do
9383 FAIL_ON_ERROR=true cleanup
9384 FAIL_ON_ERROR=true setup
9386 run_test 900 "umount should not race with any mgc requeue thread"
9388 complete $(basename $0) $SECONDS
9389 check_and_cleanup_lustre
9390 if [ "$I_MOUNTED" != "yes" ]; then
9391 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true