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 12653 12653 5188 10764 16260
11 ALWAYS_EXCEPT=" 27u 42a 42b 42c 42d 45 51d 65a 65e 68b 75 119d $SANITY_EXCEPT"
12 # bug number for skipped test: 2108 9789 3637 9789 3561 5188/5749 1443
13 #ALWAYS_EXCEPT=${ALWAYS_EXCEPT:-"27m 42a 42b 42c 42d 45 68 76"}
14 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
16 # Tests that fail on uml
17 CPU=`awk '/model/ {print $4}' /proc/cpuinfo`
18 # buffer i/o errs sock spc runas
19 [ "$CPU" = "UML" ] && EXCEPT="$EXCEPT 27m 27n 27o 27p 27q 27r 31d 54a 64b 99a 99b 99c 99d 99e 99f 101"
21 # test76 is not valid with FIDs because inode numbers are not reused
22 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 76"
25 2.4*) FSTYPE=${FSTYPE:-ext3} ;;
26 2.6*) FSTYPE=${FSTYPE:-ldiskfs} ;;
27 *) error "unsupported kernel" ;;
30 SRCDIR=$(cd $(dirname $0); echo $PWD)
31 export PATH=$PATH:/sbin
35 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
36 CREATETEST=${CREATETEST:-createtest}
38 SETSTRIPE=${SETSTRIPE:-"$LFS setstripe"}
39 GETSTRIPE=${GETSTRIPE:-"$LFS getstripe"}
40 LSTRIPE=${LSTRIPE:-"$LFS setstripe"}
41 LFIND=${LFIND:-"$LFS find"}
42 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
43 LSTRIPEINFO=${LSTRIPEINFO:-ll_getstripe_info}
45 MCREATE=${MCREATE:-mcreate}
46 OPENFILE=${OPENFILE:-openfile}
47 OPENUNLINK=${OPENUNLINK:-openunlink}
48 READS=${READS:-"reads"}
49 TRUNCATE=${TRUNCATE:-truncate}
50 MUNLINK=${MUNLINK:-munlink}
51 SOCKETSERVER=${SOCKETSERVER:-socketserver}
52 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
53 IOPENTEST1=${IOPENTEST1:-iopentest1}
54 IOPENTEST2=${IOPENTEST2:-iopentest2}
55 MEMHOG=${MEMHOG:-memhog}
56 DIRECTIO=${DIRECTIO:-directio}
57 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
58 UMOUNT=${UMOUNT:-"umount -d"}
60 CHECK_GRANT=${CHECK_GRANT:-"yes"}
61 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
63 export NAME=${NAME:-local}
70 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
71 . $LUSTRE/tests/test-framework.sh
73 . ${CONFIG:=$LUSTRE/tests/cfg/${NAME}.sh}
75 [ "$SLOW" = "no" ] && EXCEPT_SLOW="24o 24v 27m 36f 36g 51b 51c 60c 63 64b 68 71 73 77f 78 101 103 115 120g 124b"
77 SANITYLOG=${TESTSUITELOG:-$TMP/$(basename $0 .sh).log}
82 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
83 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
92 check_kernel_version() {
94 GOT_VER=$(lctl get_param -n version | awk '/kernel:/ {print $2}')
96 patchless|patchless_client) return 0;;
97 *) [ $GOT_VER -ge $WANT_VER ] && return 0 ;;
99 log "test needs at least kernel version $WANT_VER, running $GOT_VER"
103 if [ "$ONLY" == "cleanup" ]; then
108 [ "$SANITYLOG" ] && rm -f $SANITYLOG || true
110 check_and_setup_lustre
115 MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid | \
116 awk '{gsub(/_UUID/,""); print $1}' | head -1)
117 LOVNAME=$($LCTL get_param -n llite.*.lov.common_name | tail -n 1)
118 OSTCOUNT=$($LCTL get_param -n lov.$LOVNAME.numobd)
119 STRIPECOUNT=$($LCTL get_param -n lov.$LOVNAME.stripecount)
120 STRIPESIZE=$($LCTL get_param -n lov.$LOVNAME.stripesize)
121 ORIGFREE=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
122 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
124 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
125 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
126 rm -rf $DIR/[Rdfs][0-9]*
128 # $RUNAS_ID may get set incorrectly somewhere else
129 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
131 check_runas_id $RUNAS_ID $RUNAS_ID $RUNAS
135 if [ "${ONLY}" = "MOUNT" ] ; then
136 echo "Lustre is up, please go on"
140 echo "preparing for tests involving mounts"
141 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
143 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
144 echo # add a newline after mke2fs.
148 OLDDEBUG="`lctl get_param -n debug 2> /dev/null`"
149 lctl set_param debug=-1 2> /dev/null || true
152 $CHECKSTAT -t file $DIR/$tfile || error
154 $CHECKSTAT -a $DIR/$tfile || error
156 run_test 0 "touch .../$tfile ; rm .../$tfile ====================="
159 chmod 0755 $DIR || error
160 $CHECKSTAT -p 0755 $DIR || error
162 run_test 0b "chmod 0755 $DIR ============================="
165 $LCTL get_param mdc.*.import | grep "state: FULL" || error "import not FULL"
166 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" || error "bad target"
168 run_test 0c "check import proc ============================="
173 mkdir $DIR/d1/d2 && error "we expect EEXIST, but not returned"
174 $CHECKSTAT -t dir $DIR/d1/d2 || error
176 run_test 1a "mkdir .../d1; mkdir .../d1/d2 ====================="
181 $CHECKSTAT -a $DIR/d1 || error
183 run_test 1b "rmdir .../d1/d2; rmdir .../d1 ====================="
188 $CHECKSTAT -t file $DIR/d2/f || error
190 run_test 2a "mkdir .../d2; touch .../d2/f ======================"
194 $CHECKSTAT -a $DIR/d2 || error
196 run_test 2b "rm -r .../d2; checkstat .../d2/f ======================"
200 $CHECKSTAT -t dir $DIR/d3 || error
202 run_test 3a "mkdir .../d3 ======================================"
205 if [ ! -d $DIR/d3 ]; then
209 $CHECKSTAT -t file $DIR/d3/f || error
211 run_test 3b "touch .../d3/f ===================================="
215 $CHECKSTAT -a $DIR/d3 || error
217 run_test 3c "rm -r .../d3 ======================================"
221 $CHECKSTAT -t dir $DIR/d4 || error
223 run_test 4a "mkdir .../d4 ======================================"
226 if [ ! -d $DIR/d4 ]; then
230 $CHECKSTAT -t dir $DIR/d4/d2 || error
232 run_test 4b "mkdir .../d4/d2 ==================================="
237 chmod 0707 $DIR/d5/d2
238 $CHECKSTAT -t dir -p 0707 $DIR/d5/d2 || error
240 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2 ============"
244 chmod 0666 $DIR/f6a || error
245 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/f6a || error
247 run_test 6a "touch .../f6a; chmod .../f6a ======================"
250 [ $RUNAS_ID -eq $UID ] && skip "RUNAS_ID = UID = $UID -- skipping" && return
251 if [ ! -f $DIR/f6a ]; then
255 $RUNAS chmod 0444 $DIR/f6a && error
256 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/f6a || error
258 run_test 6b "$RUNAS chmod .../f6a (should return error) =="
261 [ $RUNAS_ID -eq $UID ] && skip "RUNAS_ID = UID = $UID -- skipping" && return
263 chown $RUNAS_ID $DIR/f6c || error
264 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/f6c || error
266 run_test 6c "touch .../f6c; chown .../f6c ======================"
269 [ $RUNAS_ID -eq $UID ] && skip "RUNAS_ID = UID = $UID -- skipping" && return
270 if [ ! -f $DIR/f6c ]; then
272 chown $RUNAS_ID $DIR/f6c
274 $RUNAS chown $UID $DIR/f6c && error
275 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/f6c || error
277 run_test 6d "$RUNAS chown .../f6c (should return error) =="
280 [ $RUNAS_ID -eq $UID ] && skip "RUNAS_ID = UID = $UID -- skipping" && return
282 chgrp $RUNAS_ID $DIR/f6e || error
283 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/f6e || error
285 run_test 6e "touch .../f6e; chgrp .../f6e ======================"
288 [ $RUNAS_ID -eq $UID ] && skip "RUNAS_ID = UID = $UID -- skipping" && return
289 if [ ! -f $DIR/f6e ]; then
291 chgrp $RUNAS_ID $DIR/f6e
293 $RUNAS chgrp $UID $DIR/f6e && error
294 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/f6e || error
296 run_test 6f "$RUNAS chgrp .../f6e (should return error) =="
299 [ $RUNAS_ID -eq $UID ] && skip "RUNAS_ID = UID = $UID -- skipping" && return
300 mkdir $DIR/d6g || error
301 chmod 777 $DIR/d6g || error
302 $RUNAS mkdir $DIR/d6g/d || error
303 chmod g+s $DIR/d6g/d || error
304 mkdir $DIR/d6g/d/subdir
305 $CHECKSTAT -g \#$RUNAS_ID $DIR/d6g/d/subdir || error
307 run_test 6g "Is new dir in sgid dir inheriting group?"
309 test_6h() { # bug 7331
310 [ $RUNAS_ID -eq $UID ] && skip "RUNAS_ID = UID = $UID -- skipping" && return
311 touch $DIR/f6h || error "touch failed"
312 chown $RUNAS_ID:$RUNAS_ID $DIR/f6h || error "initial chown failed"
313 $RUNAS -G$RUNAS_ID chown $RUNAS_ID:0 $DIR/f6h && error "chown worked"
314 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_ID $DIR/f6h || error
316 run_test 6h "$RUNAS chown RUNAS_ID.0 .../f6h (should return error)"
322 $CHECKSTAT -t file -p 0666 $DIR/d7/f || error
324 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
327 if [ ! -d $DIR/d7 ]; then
331 echo -n foo > $DIR/d7/f2
332 [ "`cat $DIR/d7/f2`" = "foo" ] || error
333 $CHECKSTAT -t file -s 3 $DIR/d7/f2 || error
335 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
341 $CHECKSTAT -t file -p 0666 $DIR/d8/f || error
343 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
349 $CHECKSTAT -t dir $DIR/d9/d2/d3 || error
351 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
357 $CHECKSTAT -t file $DIR/d10/d2/f || error
359 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
364 chmod 0666 $DIR/d11/d2
365 chmod 0705 $DIR/d11/d2
366 $CHECKSTAT -t dir -p 0705 $DIR/d11/d2 || error
368 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
373 chmod 0666 $DIR/d12/f
374 chmod 0654 $DIR/d12/f
375 $CHECKSTAT -t file -p 0654 $DIR/d12/f || error
377 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
381 dd if=/dev/zero of=$DIR/d13/f count=10
383 $CHECKSTAT -t file -s 0 $DIR/d13/f || error
385 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
391 $CHECKSTAT -a $DIR/d14/f || error
393 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
398 mv $DIR/d15/f $DIR/d15/f2
399 $CHECKSTAT -t file $DIR/d15/f2 || error
401 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
407 $CHECKSTAT -a $DIR/d16/f || error
409 run_test 16 "touch .../d16/f; rm -rf .../d16/f ================="
414 ln -s $DIR/d17/f $DIR/d17/l-exist
416 $CHECKSTAT -l $DIR/d17/f $DIR/d17/l-exist || error
417 $CHECKSTAT -f -t f $DIR/d17/l-exist || error
418 rm -f $DIR/d17/l-exist
419 $CHECKSTAT -a $DIR/d17/l-exist || error
421 run_test 17a "symlinks: create, remove (real) =================="
425 ln -s no-such-file $DIR/d17/l-dangle
427 $CHECKSTAT -l no-such-file $DIR/d17/l-dangle || error
428 $CHECKSTAT -fa $DIR/d17/l-dangle || error
429 rm -f $DIR/d17/l-dangle
430 $CHECKSTAT -a $DIR/d17/l-dangle || error
432 run_test 17b "symlinks: create, remove (dangling) =============="
434 test_17c() { # bug 3440 - don't save failed open RPC for replay
436 ln -s foo $DIR/d17/f17c
437 cat $DIR/d17/f17c && error "opened non-existent symlink" || true
439 run_test 17c "symlinks: open dangling (should return error) ===="
443 ln -s foo $DIR/d17/f17d
444 touch $DIR/d17/f17d || error "creating to new symlink"
446 run_test 17d "symlinks: create dangling ========================"
450 local foo=$DIR/$tdir/$tfile
451 ln -s $foo $foo || error "create symlink failed"
452 ls -l $foo || error "ls -l failed"
453 ls $foo && error "ls not failed" || true
455 run_test 17e "symlinks: create recursive symlink (should return error) ===="
459 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/d17f/111
460 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/d17f/222
461 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/d17f/333
462 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/d17f/444
463 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/d17f/555
464 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
467 run_test 17f "symlinks: long and very long symlink name ========================"
471 LONGSYMLINK="$(dd if=/dev/zero bs=4095 count=1 | tr '\0' 'x')"
472 ln -s $LONGSYMLINK $DIR/$tdir/$tfile
475 run_test 17g "symlinks: really long symlink name ==============================="
477 test_17h() { #bug 17378
479 $SETSTRIPE $DIR/$tdir -c -1
480 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
481 do_facet mds lctl set_param fail_loc=0x80000141
482 touch $DIR/$tdir/$tfile || true
484 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
490 run_test 18 "touch .../f ; ls ... =============================="
496 $CHECKSTAT -a $DIR/f19 || error
498 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
501 ls -l $DIR/f19 && error || true
503 run_test 19b "ls -l .../f19 (should return error) =============="
506 [ $RUNAS_ID -eq $UID ] && skip "RUNAS_ID = UID = $UID -- skipping" && return
507 $RUNAS touch $DIR/f19 && error || true
509 run_test 19c "$RUNAS touch .../f19 (should return error) =="
512 cat $DIR/f19 && error || true
514 run_test 19d "cat .../f19 (should return error) =============="
526 $CHECKSTAT -a $DIR/f || error
528 run_test 20 "touch .../f ; ls -l ... ==========================="
532 [ -f $DIR/d21/dangle ] && rm -f $DIR/d21/dangle
533 ln -s dangle $DIR/d21/link
534 echo foo >> $DIR/d21/link
536 $CHECKSTAT -t link $DIR/d21/link || error
537 $CHECKSTAT -f -t file $DIR/d21/link || error
539 run_test 21 "write to dangling link ============================"
544 chown $RUNAS_ID $WDIR
545 (cd $WDIR || error "cd $WDIR failed";
546 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
548 ls -lR $WDIR/etc || error "ls -lR $WDIR/etc failed"
549 $CHECKSTAT -t dir $WDIR/etc || error "checkstat -t dir failed"
550 $CHECKSTAT -u \#$RUNAS_ID $WDIR/etc || error "checkstat -u failed"
552 run_test 22 "unpack tar archive as non-root user ==============="
557 local file=$DIR/$tdir/$tfile
559 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
560 openfile -f O_CREAT:O_EXCL $file &&
561 error "$file recreate succeeded" || true
563 run_test 23a "O_CREAT|O_EXCL in subdir =========================="
565 test_23b() { # bug 18988
567 local file=$DIR/$tdir/$tfile
570 echo foo > $file || error "write filed"
571 echo bar >> $file || error "append filed"
572 $CHECKSTAT -s 8 $file || error "wrong size"
575 run_test 23b "O_APPEND check =========================="
578 echo '== rename sanity =============================================='
579 echo '-- same directory rename'
582 mv $DIR/R1/f $DIR/R1/g
583 $CHECKSTAT -t file $DIR/R1/g || error
585 run_test 24a "touch .../R1/f; rename .../R1/f .../R1/g ========="
590 mv $DIR/R2/f $DIR/R2/g
591 $CHECKSTAT -a $DIR/R2/f || error
592 $CHECKSTAT -t file $DIR/R2/g || error
594 run_test 24b "touch .../R2/{f,g}; rename .../R2/f .../R2/g ====="
599 mv $DIR/R3/f $DIR/R3/g
600 $CHECKSTAT -a $DIR/R3/f || error
601 $CHECKSTAT -t dir $DIR/R3/g || error
603 run_test 24c "mkdir .../R3/f; rename .../R3/f .../R3/g ========="
608 mrename $DIR/R4/f $DIR/R4/g
609 $CHECKSTAT -a $DIR/R4/f || error
610 $CHECKSTAT -t dir $DIR/R4/g || error
612 run_test 24d "mkdir .../R4/{f,g}; rename .../R4/f .../R4/g ====="
615 echo '-- cross directory renames --'
618 mv $DIR/R5a/f $DIR/R5b/g
619 $CHECKSTAT -a $DIR/R5a/f || error
620 $CHECKSTAT -t file $DIR/R5b/g || error
622 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
626 touch $DIR/R6a/f $DIR/R6b/g
627 mv $DIR/R6a/f $DIR/R6b/g
628 $CHECKSTAT -a $DIR/R6a/f || error
629 $CHECKSTAT -t file $DIR/R6b/g || error
631 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
636 mv $DIR/R7a/d $DIR/R7b/e
637 $CHECKSTAT -a $DIR/R7a/d || error
638 $CHECKSTAT -t dir $DIR/R7b/e || error
640 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
644 mkdir $DIR/R8a/d $DIR/R8b/e
645 mrename $DIR/R8a/d $DIR/R8b/e
646 $CHECKSTAT -a $DIR/R8a/d || error
647 $CHECKSTAT -t dir $DIR/R8b/e || error
649 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
652 echo "-- rename error cases"
656 mrename $DIR/R9/f $DIR/R9/a
657 $CHECKSTAT -t file $DIR/R9/f || error
658 $CHECKSTAT -t dir $DIR/R9/a || error
659 $CHECKSTAT -a $DIR/R9/a/f || error
661 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
665 mrename $DIR/R10/f $DIR/R10/g
666 $CHECKSTAT -t dir $DIR/R10 || error
667 $CHECKSTAT -a $DIR/R10/f || error
668 $CHECKSTAT -a $DIR/R10/g || error
670 run_test 24j "source does not exist ============================"
673 mkdir $DIR/R11a $DIR/R11a/d
675 mv $DIR/R11a/f $DIR/R11a/d
676 $CHECKSTAT -a $DIR/R11a/f || error
677 $CHECKSTAT -t file $DIR/R11a/d/f || error
679 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
681 # bug 2429 - rename foo foo foo creates invalid file
684 multiop $f OcNs || error
686 run_test 24l "Renaming a file to itself ========================"
690 multiop $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
691 # on ext3 this does not remove either the source or target files
692 # though the "expected" operation would be to remove the source
693 $CHECKSTAT -t file ${f} || error "${f} missing"
694 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
696 run_test 24m "Renaming a file to a hard link to itself ========="
700 # this stats the old file after it was renamed, so it should fail
704 $CHECKSTAT ${f}.rename
707 run_test 24n "Statting the old file after renaming (Posix rename 2)"
710 check_kernel_version 37 || return 0
712 rename_many -s random -v -n 10 $DIR/d24o
714 run_test 24o "rename of files during htree split ==============="
718 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
719 mrename $DIR/R12a $DIR/R12b
720 $CHECKSTAT -a $DIR/R12a || error
721 $CHECKSTAT -t dir $DIR/R12b || error
722 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
723 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
725 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
729 DIRINO=`ls -lid $DIR/R13a | awk '{ print $1 }'`
730 multiop_bg_pause $DIR/R13b D_c || return 1
733 mrename $DIR/R13a $DIR/R13b
734 $CHECKSTAT -a $DIR/R13a || error
735 $CHECKSTAT -t dir $DIR/R13b || error
736 DIRINO2=`ls -lid $DIR/R13b | awk '{ print $1 }'`
737 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
739 wait $MULTIPID || error "multiop close failed"
741 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
743 test_24r() { #bug 3789
744 mkdir $DIR/R14a $DIR/R14a/b
745 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
746 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
747 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
749 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
752 mkdir $DIR/R15a $DIR/R15a/b $DIR/R15a/b/c
753 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
754 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
755 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
757 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
759 mkdir $DIR/R16a $DIR/R16a/b $DIR/R16a/b/c
760 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
761 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
762 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
764 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
766 test_24u() { # bug12192
767 multiop $DIR/$tfile C2w$((2048 * 1024))c || error
768 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
770 run_test 24u "create stripe file"
774 local FREE_INODES=`lfs df -i|grep "filesystem summary" | awk '{print $5}'`
775 [ $FREE_INODES -lt $NRFILES ] && \
776 skip "not enough free inodes $FREE_INODES required $NRFILES" && \
780 createmany -m $DIR/d24v/$tfile $NRFILES
781 ls $DIR/d24v >/dev/null || error "error in listing large dir"
785 run_test 24v "list directory with large files (handle hash collision, bug: 17560)"
788 echo '== symlink sanity ============================================='
792 touch $DIR/s25/foo || error
794 run_test 25a "create file in symlinked directory ==============="
797 [ ! -d $DIR/d25 ] && test_25a
798 $CHECKSTAT -t file $DIR/s25/foo || error
800 run_test 25b "lookup file in symlinked directory ==============="
805 ln -s d26/d26-2 $DIR/s26
806 touch $DIR/s26/foo || error
808 run_test 26a "multiple component symlink ======================="
811 mkdir -p $DIR/d26b/d26-2
812 ln -s d26b/d26-2/foo $DIR/s26-2
813 touch $DIR/s26-2 || error
815 run_test 26b "multiple component symlink at end of lookup ======"
820 ln -s d26.2 $DIR/s26.2-1
821 ln -s s26.2-1 $DIR/s26.2-2
822 ln -s s26.2-2 $DIR/s26.2-3
823 chmod 0666 $DIR/s26.2-3/foo
825 run_test 26c "chain of symlinks ================================"
827 # recursive symlinks (bug 439)
829 ln -s d26-3/foo $DIR/d26-3
831 run_test 26d "create multiple component recursive symlink ======"
834 [ ! -h $DIR/d26-3 ] && test_26d
837 run_test 26e "unlink multiple component recursive symlink ======"
839 # recursive symlinks (bug 7022)
842 mkdir $DIR/$tdir/$tfile || error "mkdir $DIR/$tdir/$tfile failed"
843 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
844 mkdir -p lndir/bar1 || error "mkdir lndir/bar1 failed"
845 mkdir $tfile || error "mkdir $tfile failed"
846 cd $tfile || error "cd $tfile failed"
847 ln -s .. dotdot || error "ln dotdot failed"
848 ln -s dotdot/lndir lndir || error "ln lndir failed"
849 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
850 output=`ls $tfile/$tfile/lndir/bar1`
851 [ "$output" = bar1 ] && error "unexpected output"
852 rm -r $tfile || error "rm $tfile failed"
853 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
855 run_test 26f "rm -r of a directory which has recursive symlink ="
858 echo '== stripe sanity =============================================='
859 mkdir -p $DIR/d27 || error "mkdir failed"
861 $SETSTRIPE $DIR/d27/f0 -c 1 || error "lstripe failed"
862 $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
864 log "== test_27a: write to one stripe file ========================="
865 cp /etc/hosts $DIR/d27/f0 || error
867 run_test 27a "one stripe file =================================="
870 [ "$OSTCOUNT" -lt "2" ] && skip "skipping 2-stripe test" && return
872 $SETSTRIPE $DIR/d27/f01 -c 2 || error "lstripe failed"
873 [ `$GETSTRIPE $DIR/d27/f01 | grep -A 10 obdidx | wc -l` -eq 4 ] ||
874 error "two-stripe file doesn't have two stripes"
876 log "== test_27c: write to two stripe file file f01 ================"
877 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
879 run_test 27c "create two stripe file f01 ======================="
883 $SETSTRIPE -c0 -i-1 -s0 $DIR/d27/fdef || error "lstripe failed"
884 $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
885 dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
887 run_test 27d "create file with default settings ================"
891 $SETSTRIPE $DIR/d27/f12 -c 2 || error "lstripe failed"
892 $SETSTRIPE $DIR/d27/f12 -c 2 && error "lstripe succeeded twice"
893 $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
895 run_test 27e "setstripe existing file (should return error) ======"
899 $SETSTRIPE $DIR/d27/fbad -s 100 -i 0 -c 1 && error "lstripe failed"
900 dd if=/dev/zero of=$DIR/d27/f12 bs=4k count=4 || error "dd failed"
901 $GETSTRIPE $DIR/d27/fbad || error "lfs getstripe failed"
903 run_test 27f "setstripe with bad stripe size (should return error)"
907 $MCREATE $DIR/d27/fnone || error "mcreate failed"
909 log "== test 27h: lfs getstripe with no objects ===================="
910 $GETSTRIPE $DIR/d27/fnone 2>&1 | grep "no stripe info" || error "has object"
912 log "== test 27i: lfs getstripe with some objects =================="
913 touch $DIR/d27/fsome || error "touch failed"
914 $GETSTRIPE $DIR/d27/fsome | grep obdidx || error "missing objects"
916 run_test 27g "test lfs getstripe ==========================================="
920 $SETSTRIPE $DIR/d27/f27j -i $OSTCOUNT && error "lstripe failed"||true
922 run_test 27j "setstripe with bad stripe offset (should return error)"
924 test_27k() { # bug 2844
927 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
928 [ ! -d $DIR/d27 ] && mkdir -p $DIR/d27
929 $SETSTRIPE $FILE -s 67108864 || error "lstripe failed"
930 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
931 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
932 dd if=/dev/zero of=$FILE bs=4k count=1
933 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
934 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
936 run_test 27k "limit i_blksize for broken user apps ============="
940 mcreate $DIR/f27l || error "creating file"
941 $RUNAS $SETSTRIPE $DIR/f27l -c 1 && \
942 error "lstripe should have failed" || true
944 run_test 27l "check setstripe permissions (should return error)"
947 [ "$OSTCOUNT" -lt "2" ] && skip "$OSTCOUNT < 2 OSTs -- skipping" && return
948 if [ $ORIGFREE -gt $MAXFREE ]; then
949 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
953 $SETSTRIPE $DIR/d27/f27m_1 -i 0 -c 1
954 dd if=/dev/zero of=$DIR/d27/f27m_1 bs=1024 count=$MAXFREE && \
955 error "dd should fill OST0"
957 while $SETSTRIPE $DIR/d27/f27m_$i -i 0 -c 1 ; do
959 [ $i -gt 256 ] && break
962 touch $DIR/d27/f27m_$i
963 [ `$GETSTRIPE $DIR/d27/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] && \
964 error "OST0 was full but new created file still use it"
966 touch $DIR/d27/f27m_$i
967 [ `$GETSTRIPE $DIR/d27/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] && \
968 error "OST0 was full but new created file still use it"
972 run_test 27m "create file while OST0 was full =================="
974 # osc's keep a NOSPC stick flag that gets unset with rmdir
976 local FAIL_LOC=${1:-0}
977 local OSTIDX=${2:-""}
979 mkdir -p $DIR/d27/nospc
981 local list=$(comma_list $(osts_nodes))
982 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
984 do_nodes $list lctl set_param fail_loc=$FAIL_LOC
987 exhaust_precreations() {
989 local MDSIDX=$(get_mds_dir "$DIR/d27")
990 echo OSTIDX=$OSTIDX MDSIDX=$MDSIDX
992 local OST=$(lfs osts | grep ${OSTIDX}": " | \
993 awk '{print $2}' | sed -e 's/_UUID$//')
994 local MDT_INDEX=$(lfs df | grep "\[MDT:$((MDSIDX - 1))\]" | awk '{print $1}' | \
995 sed -e 's/_UUID$//;s/^.*-//')
998 local last_id=$(do_facet mds${MDSIDX} lctl get_param -n osc.*${OST}-osc-${MDT_INDEX}.prealloc_last_id)
999 local next_id=$(do_facet mds${MDSIDX} lctl get_param -n osc.*${OST}-osc-${MDT_INDEX}.prealloc_next_id)
1001 echo ${OST}-osc-${MDT_INDEX}.prealloc_last_id=$last_id
1002 echo ${OST}-osc-${MDT_INDEX}.prealloc_next_id=$next_id
1005 $SETSTRIPE $DIR/d27 -i $OSTIDX -c 1
1006 #define OBD_FAIL_OST_ENOSPC 0x215
1007 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x215
1008 echo "Creating to objid $last_id on ost $OST..."
1009 createmany -o $DIR/d27/${OST}-f $next_id $((last_id - next_id + 2))
1010 do_facet mds${MDSIDX} lctl get_param osc.*${OST}-osc-${MDT_INDEX}.prealloc* | grep '[0-9]'
1011 reset_enospc $2 $OSTIDX
1014 exhaust_all_precreations() {
1016 for (( i=0; i < OSTCOUNT; i++ )) ; do
1017 exhaust_precreations $i 0x215
1023 [ "$OSTCOUNT" -lt "2" ] && skip "too few OSTs" && return
1024 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1025 remote_ost_nodsh && skip "remote OST with nodsh" && return
1029 exhaust_precreations 0 0x80000215
1030 $SETSTRIPE -c -1 $DIR/d27
1031 touch $DIR/d27/f27n || error
1032 $GETSTRIPE $DIR/d27/f27n
1035 run_test 27n "create file with some full OSTs =================="
1038 [ "$OSTCOUNT" -lt "2" ] && skip "too few OSTs" && return
1039 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1040 remote_ost_nodsh && skip "remote OST with nodsh" && return
1044 exhaust_all_precreations 0x215
1047 touch $DIR/d27/f27o && error "able to create $DIR/d27/f27o"
1052 run_test 27o "create file with all full OSTs (should error) ===="
1055 [ "$OSTCOUNT" -lt "2" ] && skip "too few OSTs" && return
1056 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1057 remote_ost_nodsh && skip "remote OST with nodsh" && return
1062 $MCREATE $DIR/d27/f27p || error "mcreate failed"
1063 $TRUNCATE $DIR/d27/f27p 80000000 || error "truncate failed"
1064 $CHECKSTAT -s 80000000 $DIR/d27/f27p || error "checkstat failed"
1066 exhaust_precreations 0 0x80000215
1067 echo foo >> $DIR/d27/f27p || error "append failed"
1068 $CHECKSTAT -s 80000004 $DIR/d27/f27p || error "checkstat failed"
1072 run_test 27p "append to a truncated file with some full OSTs ==="
1075 [ "$OSTCOUNT" -lt "2" ] && skip "too few OSTs" && return
1076 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1077 remote_ost_nodsh && skip "remote OST with nodsh" && return
1082 $MCREATE $DIR/d27/f27q || error "mcreate $DIR/d27/f27q failed"
1083 $TRUNCATE $DIR/d27/f27q 80000000 ||error "truncate $DIR/d27/f27q failed"
1084 $CHECKSTAT -s 80000000 $DIR/d27/f27q || error "checkstat failed"
1086 exhaust_all_precreations 0x215
1088 echo foo >> $DIR/d27/f27q && error "append succeeded"
1089 $CHECKSTAT -s 80000000 $DIR/d27/f27q || error "checkstat 2 failed"
1093 run_test 27q "append to truncated file with all OSTs full (should error) ==="
1096 [ "$OSTCOUNT" -lt "2" ] && skip "too few OSTs" && return
1097 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1098 remote_ost_nodsh && skip "remote OST with nodsh" && return
1102 exhaust_precreations 0 0x80000215
1104 $SETSTRIPE $DIR/d27/f27r -i 0 -c 2 # && error
1108 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1110 test_27s() { # bug 10725
1112 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1113 local stripe_count=0
1114 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1115 $SETSTRIPE $DIR/$tdir -s $stripe_size -c $stripe_count && \
1116 error "stripe width >= 2^32 succeeded" || true
1119 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1121 test_27t() { # bug 10864
1126 $WLFS getstripe $tfile
1129 run_test 27t "check that utils parse path correctly"
1131 test_27u() { # bug 4900
1132 [ "$OSTCOUNT" -lt "2" ] && skip "too few OSTs" && return
1133 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1135 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1136 do_facet $SINGLEMDS lctl set_param fail_loc=0x139
1138 createmany -o $DIR/d27u/t- 1000
1139 do_facet $SINGLEMDS lctl set_param fail_loc=0
1141 TLOG=$DIR/$tfile.getstripe
1142 $GETSTRIPE $DIR/d27u > $TLOG
1143 OBJS=`awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj;}' $TLOG`
1144 unlinkmany $DIR/d27u/t- 1000
1145 [ $OBJS -gt 0 ] && \
1146 error "$OBJS objects created on OST-0. See $TLOG" || pass
1148 run_test 27u "skip object creation on OSC w/o objects =========="
1150 test_27v() { # bug 4900
1151 [ "$OSTCOUNT" -lt "2" ] && skip "too few OSTs" && return
1152 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1153 remote_ost_nodsh && skip "remote OST with nodsh" && return
1155 exhaust_all_precreations
1158 $SETSTRIPE $DIR/$tdir -c 1 # 1 stripe / file
1160 touch $DIR/$tdir/$tfile
1161 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1163 for (( i=0; i < OSTCOUNT; i++ )) ; do
1164 do_facet ost$i lctl set_param fail_loc=0x705
1166 local START=`date +%s`
1167 createmany -o $DIR/$tdir/$tfile 32
1171 local FINISH=`date +%s`
1172 local TIMEOUT=`lctl get_param -n timeout`
1173 [ $((FINISH - START)) -ge $((TIMEOUT / 2)) ] && \
1174 error "$FINISH - $START >= $TIMEOUT / 2"
1178 run_test 27v "skip object creation on slow OST ================="
1180 test_27w() { # bug 10997
1181 mkdir -p $DIR/d27w || error "mkdir failed"
1182 $LSTRIPE $DIR/d27w/f0 -s 65536 || error "lstripe failed"
1183 size=`$LSTRIPEINFO $DIR/d27w/f0 | awk {'print $1'}`
1184 [ $size -ne 65536 ] && error "stripe size $size != 65536" || true
1186 [ "$OSTCOUNT" -lt "2" ] && skip "skipping multiple stripe count/offset test" && return
1187 for i in `seq 1 $OSTCOUNT`; do
1189 $LSTRIPE $DIR/d27w/f$i -c $i -i $offset || error "lstripe -c $i -i $offset failed"
1190 count=`$LSTRIPEINFO $DIR/d27w/f$i | awk {'print $2'}`
1191 index=`$LSTRIPEINFO $DIR/d27w/f$i | awk {'print $3'}`
1192 [ $count -ne $i ] && error "stripe count $count != $i" || true
1193 [ $index -ne $offset ] && error "stripe offset $index != $offset" || true
1196 run_test 27w "check lfs setstripe -c -s -i options ============="
1198 # createtest also checks that device nodes are created and
1199 # then visible correctly (#2091)
1200 test_28() { # bug 2091
1202 $CREATETEST $DIR/d28/ct || error
1204 run_test 28 "create/mknod/mkdir with bad file types ============"
1207 cancel_lru_locks mdc
1213 declare -i LOCKCOUNTORIG=0
1214 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1215 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
1217 [ $LOCKCOUNTORIG -eq 0 ] && echo "No mdc lock count" && return 1
1219 declare -i LOCKUNUSEDCOUNTORIG=0
1220 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1221 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
1228 declare -i LOCKCOUNTCURRENT=0
1229 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1230 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
1233 declare -i LOCKUNUSEDCOUNTCURRENT=0
1234 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1235 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
1238 if [ "$LOCKCOUNTCURRENT" -gt "$LOCKCOUNTORIG" ]; then
1239 lctl set_param -n ldlm.dump_namespaces ""
1240 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
1241 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1242 log "dumped log to $TMP/test_29.dk (bug 5793)"
1245 if [ "$LOCKUNUSEDCOUNTCURRENT" -gt "$LOCKUNUSEDCOUNTORIG" ]; then
1246 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
1247 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1248 log "dumped log to $TMP/test_29.dk (bug 5793)"
1252 run_test 29 "IT_GETATTR regression ============================"
1255 cp `which ls` $DIR || cp /bin/ls $DIR
1259 run_test 30 "run binary from Lustre (execve) ==================="
1262 $OPENUNLINK $DIR/f31 $DIR/f31 || error
1263 $CHECKSTAT -a $DIR/f31 || error
1265 run_test 31a "open-unlink file =================================="
1268 touch $DIR/f31 || error
1269 ln $DIR/f31 $DIR/f31b || error
1270 multiop $DIR/f31b Ouc || error
1271 $CHECKSTAT -t file $DIR/f31 || error
1273 run_test 31b "unlink file with multiple links while open ======="
1276 touch $DIR/f31 || error
1277 ln $DIR/f31 $DIR/f31c || error
1278 multiop_bg_pause $DIR/f31 O_uc || return 1
1280 multiop $DIR/f31c Ouc
1281 kill -USR1 $MULTIPID
1284 run_test 31c "open-unlink file with multiple links ============="
1287 opendirunlink $DIR/d31d $DIR/d31d || error
1288 $CHECKSTAT -a $DIR/d31d || error
1290 run_test 31d "remove of open directory ========================="
1292 test_31e() { # bug 2904
1293 check_kernel_version 34 || return 0
1294 openfilleddirunlink $DIR/d31e || error
1296 run_test 31e "remove of open non-empty directory ==============="
1298 test_31f() { # bug 4554
1301 $SETSTRIPE $DIR/d31f -s 1048576 -c 1
1302 cp /etc/hosts $DIR/d31f
1304 $GETSTRIPE $DIR/d31f/hosts
1305 multiop_bg_pause $DIR/d31f D_c || return 1
1308 rm -rv $DIR/d31f || error "first of $DIR/d31f"
1310 $SETSTRIPE $DIR/d31f -s 1048576 -c 1
1311 cp /etc/hosts $DIR/d31f
1314 multiop_bg_pause $DIR/d31f D_c || return 1
1317 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
1318 wait $MULTIPID || error "first opendir $MULTIPID failed"
1322 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
1323 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
1326 run_test 31f "remove of open directory with open-unlink file ==="
1329 echo "-- cross directory link --"
1330 mkdir $DIR/d31g{a,b}
1332 ln $DIR/d31ga/f $DIR/d31gb/g
1333 $CHECKSTAT -t file $DIR/d31ga/f || error "source"
1334 [ `stat -c%h $DIR/d31ga/f` == '2' ] || error "source nlink"
1335 $CHECKSTAT -t file $DIR/d31gb/g || error "target"
1336 [ `stat -c%h $DIR/d31gb/g` == '2' ] || error "target nlink"
1338 run_test 31g "cross directory link==============="
1341 echo "-- cross directory link --"
1345 ln $DIR/d31h/f $DIR/d31h/dir/g
1346 $CHECKSTAT -t file $DIR/d31h/f || error "source"
1347 [ `stat -c%h $DIR/d31h/f` == '2' ] || error "source nlink"
1348 $CHECKSTAT -t file $DIR/d31h/dir/g || error "target"
1349 [ `stat -c%h $DIR/d31h/dir/g` == '2' ] || error "target nlink"
1351 run_test 31h "cross directory link under child==============="
1354 echo "-- cross directory link --"
1357 touch $DIR/d31i/dir/f
1358 ln $DIR/d31i/dir/f $DIR/d31i/g
1359 $CHECKSTAT -t file $DIR/d31i/dir/f || error "source"
1360 [ `stat -c%h $DIR/d31i/dir/f` == '2' ] || error "source nlink"
1361 $CHECKSTAT -t file $DIR/d31i/g || error "target"
1362 [ `stat -c%h $DIR/d31i/g` == '2' ] || error "target nlink"
1364 run_test 31i "cross directory link under parent==============="
1369 mkdir $DIR/d31j/dir1
1370 ln $DIR/d31j/dir1 $DIR/d31j/dir2 && error "ln for dir"
1371 link $DIR/d31j/dir1 $DIR/d31j/dir3 && error "link for dir"
1372 mlink $DIR/d31j/dir1 $DIR/d31j/dir4 && error "mlink for dir"
1373 mlink $DIR/d31j/dir1 $DIR/d31j/dir1 && error "mlink to the same dir"
1376 run_test 31j "link for directory==============="
1382 touch $DIR/d31k/exist
1383 mlink $DIR/d31k/s $DIR/d31k/t || error "mlink"
1384 mlink $DIR/d31k/s $DIR/d31k/exist && error "mlink to exist file"
1385 mlink $DIR/d31k/s $DIR/d31k/s && error "mlink to the same file"
1386 mlink $DIR/d31k/s $DIR/d31k && error "mlink to parent dir"
1387 mlink $DIR/d31k $DIR/d31k/s && error "mlink parent dir to target"
1388 mlink $DIR/d31k/not-exist $DIR/d31k/foo && error "mlink non-existing to new"
1389 mlink $DIR/d31k/not-exist $DIR/d31k/s && error "mlink non-existing to exist"
1392 run_test 31k "link to file: the same, non-existing, dir==============="
1398 touch $DIR/d31m2/exist
1399 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
1400 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
1401 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
1402 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
1403 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
1404 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
1407 run_test 31m "link to file: the same, non-existing, dir==============="
1410 echo "== more mountpoints and symlinks ================="
1411 [ -e $DIR/d32a ] && rm -fr $DIR/d32a
1412 mkdir -p $DIR/d32a/ext2-mountpoint
1413 mount -t ext2 -o loop $EXT2_DEV $DIR/d32a/ext2-mountpoint || error
1414 $CHECKSTAT -t dir $DIR/d32a/ext2-mountpoint/.. || error
1415 $UMOUNT $DIR/d32a/ext2-mountpoint || error
1417 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
1420 [ -e $DIR/d32b ] && rm -fr $DIR/d32b
1421 mkdir -p $DIR/d32b/ext2-mountpoint
1422 mount -t ext2 -o loop $EXT2_DEV $DIR/d32b/ext2-mountpoint || error
1423 ls -al $DIR/d32b/ext2-mountpoint/.. || error
1424 $UMOUNT $DIR/d32b/ext2-mountpoint || error
1426 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
1429 [ -e $DIR/d32c ] && rm -fr $DIR/d32c
1430 mkdir -p $DIR/d32c/ext2-mountpoint
1431 mount -t ext2 -o loop $EXT2_DEV $DIR/d32c/ext2-mountpoint || error
1432 mkdir -p $DIR/d32c/d2/test_dir
1433 $CHECKSTAT -t dir $DIR/d32c/ext2-mountpoint/../d2/test_dir || error
1434 $UMOUNT $DIR/d32c/ext2-mountpoint || error
1436 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
1439 [ -e $DIR/d32d ] && rm -fr $DIR/d32d
1440 mkdir -p $DIR/d32d/ext2-mountpoint
1441 mount -t ext2 -o loop $EXT2_DEV $DIR/d32d/ext2-mountpoint || error
1442 mkdir -p $DIR/d32d/d2/test_dir
1443 ls -al $DIR/d32d/ext2-mountpoint/../d2/test_dir || error
1444 $UMOUNT $DIR/d32d/ext2-mountpoint || error
1446 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
1449 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
1450 mkdir -p $DIR/d32e/tmp
1451 TMP_DIR=$DIR/d32e/tmp
1452 ln -s $DIR/d32e $TMP_DIR/symlink11
1453 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1454 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
1455 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
1457 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
1460 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
1461 mkdir -p $DIR/d32f/tmp
1462 TMP_DIR=$DIR/d32f/tmp
1463 ln -s $DIR/d32f $TMP_DIR/symlink11
1464 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1465 ls $DIR/d32f/tmp/symlink11 || error
1466 ls $DIR/d32f/symlink01 || error
1468 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
1471 TMP_DIR=$DIR/$tdir/tmp
1472 mkdir -p $TMP_DIR $DIR/${tdir}2
1473 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
1474 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1475 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
1476 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
1477 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
1478 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
1480 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
1483 rm -fr $DIR/$tdir $DIR/${tdir}2
1484 TMP_DIR=$DIR/$tdir/tmp
1485 mkdir -p $TMP_DIR $DIR/${tdir}2
1486 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
1487 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1488 ls $TMP_DIR/symlink12 || error
1489 ls $DIR/$tdir/symlink02 || error
1491 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
1494 [ -e $DIR/d32i ] && rm -fr $DIR/d32i
1495 mkdir -p $DIR/d32i/ext2-mountpoint
1496 mount -t ext2 -o loop $EXT2_DEV $DIR/d32i/ext2-mountpoint || error
1497 touch $DIR/d32i/test_file
1498 $CHECKSTAT -t file $DIR/d32i/ext2-mountpoint/../test_file || error
1499 $UMOUNT $DIR/d32i/ext2-mountpoint || error
1501 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
1504 [ -e $DIR/d32j ] && rm -fr $DIR/d32j
1505 mkdir -p $DIR/d32j/ext2-mountpoint
1506 mount -t ext2 -o loop $EXT2_DEV $DIR/d32j/ext2-mountpoint || error
1507 touch $DIR/d32j/test_file
1508 cat $DIR/d32j/ext2-mountpoint/../test_file || error
1509 $UMOUNT $DIR/d32j/ext2-mountpoint || error
1511 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
1515 mkdir -p $DIR/d32k/ext2-mountpoint
1516 mount -t ext2 -o loop $EXT2_DEV $DIR/d32k/ext2-mountpoint
1517 mkdir -p $DIR/d32k/d2
1518 touch $DIR/d32k/d2/test_file || error
1519 $CHECKSTAT -t file $DIR/d32k/ext2-mountpoint/../d2/test_file || error
1520 $UMOUNT $DIR/d32k/ext2-mountpoint || error
1522 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
1526 mkdir -p $DIR/d32l/ext2-mountpoint
1527 mount -t ext2 -o loop $EXT2_DEV $DIR/d32l/ext2-mountpoint || error
1528 mkdir -p $DIR/d32l/d2
1529 touch $DIR/d32l/d2/test_file
1530 cat $DIR/d32l/ext2-mountpoint/../d2/test_file || error
1531 $UMOUNT $DIR/d32l/ext2-mountpoint || error
1533 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
1537 mkdir -p $DIR/d32m/tmp
1538 TMP_DIR=$DIR/d32m/tmp
1539 ln -s $DIR $TMP_DIR/symlink11
1540 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1541 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
1542 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
1544 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
1548 mkdir -p $DIR/d32n/tmp
1549 TMP_DIR=$DIR/d32n/tmp
1550 ln -s $DIR $TMP_DIR/symlink11
1551 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1552 ls -l $DIR/d32n/tmp/symlink11 || error
1553 ls -l $DIR/d32n/symlink01 || error
1555 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
1558 rm -fr $DIR/d32o $DIR/$tfile
1560 mkdir -p $DIR/d32o/tmp
1561 TMP_DIR=$DIR/d32o/tmp
1562 ln -s $DIR/$tfile $TMP_DIR/symlink12
1563 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1564 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
1565 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
1566 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
1567 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
1569 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
1579 mkdir -p $DIR/d32p/tmp
1581 TMP_DIR=$DIR/d32p/tmp
1583 ln -s $DIR/$tfile $TMP_DIR/symlink12
1585 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1587 cat $DIR/d32p/tmp/symlink12 || error
1589 cat $DIR/d32p/symlink02 || error
1592 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
1595 [ -e $DIR/d32q ] && rm -fr $DIR/d32q
1597 touch $DIR/d32q/under_the_mount
1598 mount -t ext2 -o loop $EXT2_DEV $DIR/d32q
1599 ls $DIR/d32q/under_the_mount && error || true
1600 $UMOUNT $DIR/d32q || error
1602 run_test 32q "stat follows mountpoints in Lustre (should return error)"
1605 [ -e $DIR/d32r ] && rm -fr $DIR/d32r
1607 touch $DIR/d32r/under_the_mount
1608 mount -t ext2 -o loop $EXT2_DEV $DIR/d32r
1609 ls $DIR/d32r | grep -q under_the_mount && error || true
1610 $UMOUNT $DIR/d32r || error
1612 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
1617 chmod 444 $DIR/$tfile
1618 chown $RUNAS_ID $DIR/$tfile
1620 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
1623 run_test 33 "write file with mode 444 (should return error) ===="
1628 chown $RUNAS_ID $DIR/d33
1629 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
1630 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
1631 error "open RDWR" || true
1633 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
1638 chown $RUNAS_ID $DIR/d33
1639 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33 && error "create" || true
1641 run_test 33b "test open file with malformed flags (No panic and return error)"
1643 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
1646 $MCREATE $DIR/f34 || error
1647 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
1648 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
1649 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
1650 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1652 run_test 34a "truncate file that has not been opened ==========="
1655 [ ! -f $DIR/f34 ] && test_34a
1656 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1657 $OPENFILE -f O_RDONLY $DIR/f34
1658 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
1659 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1661 run_test 34b "O_RDONLY opening file doesn't create objects ====="
1664 [ ! -f $DIR/f34 ] && test_34a
1665 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1666 $OPENFILE -f O_RDWR $DIR/f34
1667 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
1668 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1670 run_test 34c "O_RDWR opening file-with-size works =============="
1673 [ ! -f $DIR/f34 ] && test_34a
1674 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
1675 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1678 run_test 34d "write to sparse file ============================="
1682 $MCREATE $DIR/f34e || error
1683 $TRUNCATE $DIR/f34e 1000 || error
1684 $CHECKSTAT -s 1000 $DIR/f34e || error
1685 $OPENFILE -f O_RDWR $DIR/f34e
1686 $CHECKSTAT -s 1000 $DIR/f34e || error
1688 run_test 34e "create objects, some with size and some without =="
1690 test_34f() { # bug 6242, 6243
1693 $MCREATE $DIR/f34f || error
1694 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
1695 dd if=$DIR/f34f of=$TMP/f34f
1696 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
1697 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
1698 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
1699 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
1700 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
1702 run_test 34f "read from a file with no objects until EOF ======="
1705 cp /bin/sh $DIR/f35a
1707 chown $RUNAS_ID $DIR/f35a
1708 $RUNAS $DIR/f35a && error || true
1711 run_test 35a "exec file with mode 444 (should return and not leak) ====="
1715 utime $DIR/f36 || error
1717 run_test 36a "MDS utime check (mknod, utime) ==================="
1721 utime $DIR/f36 || error
1723 run_test 36b "OST utime check (open, utime) ===================="
1728 chown $RUNAS_ID $DIR/d36
1729 $RUNAS utime $DIR/d36/f36 || error
1731 run_test 36c "non-root MDS utime check (mknod, utime) =========="
1734 [ ! -d $DIR/d36 ] && test_36c
1735 echo "" > $DIR/d36/f36
1736 $RUNAS utime $DIR/d36/f36 || error
1738 run_test 36d "non-root OST utime check (open, utime) ==========="
1741 [ $RUNAS_ID -eq $UID ] && skip "RUNAS_ID = UID = $UID -- skipping" && return
1743 touch $DIR/$tdir/$tfile
1744 $RUNAS utime $DIR/$tdir/$tfile && \
1745 error "utime worked, expected failure" || true
1747 run_test 36e "utime on non-owned file (should return error) ===="
1750 export LANG=C LC_LANG=C # for date language
1752 DATESTR="Dec 20 2000"
1754 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
1755 lctl set_param fail_loc=0x80000214
1757 cp /etc/hosts $DIR/$tdir/$tfile
1758 sync & # write RPC generated with "current" inode timestamp, but delayed
1760 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
1761 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
1762 cancel_lru_locks osc
1763 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
1765 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
1766 echo "BEFORE: $LS_BEFORE" && \
1767 echo "AFTER : $LS_AFTER" && \
1768 echo "WANT : $DATESTR" && \
1769 error "$DIR/$tdir/$tfile timestamps changed" || true
1771 run_test 36f "utime on file racing with OST BRW write =========="
1774 remote_ost_nodsh && skip "remote OST with nodsh" && return
1777 export FMD_MAX_AGE=`do_facet ost1 lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | head -n 1`
1778 FMD_BEFORE="`awk '/ll_fmd_cache/ { print $2 }' /proc/slabinfo`"
1779 touch $DIR/$tdir/$tfile
1780 sleep $((FMD_MAX_AGE + 12))
1781 FMD_AFTER="`awk '/ll_fmd_cache/ { print $2 }' /proc/slabinfo`"
1782 [ "$FMD_AFTER" -gt "$FMD_BEFORE" ] && \
1783 echo "AFTER : $FMD_AFTER > BEFORE $FMD_BEFORE" && \
1784 error "fmd didn't expire after ping" || true
1786 run_test 36g "filter mod data cache expiry ====================="
1790 echo f > $DIR/$tdir/fbugfile
1791 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
1792 ls $DIR/$tdir | grep "\<fbugfile\>" && error
1793 $UMOUNT $DIR/$tdir || error
1794 rm -f $DIR/$tdir/fbugfile || error
1796 run_test 37 "ls a mounted file system to check old content ====="
1799 local file=$DIR/$tfile
1801 openfile -f O_DIRECTORY $file
1804 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
1805 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
1807 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
1811 touch $DIR/${tfile}2
1812 # ls -l $DIR/$tfile $DIR/${tfile}2
1813 # ls -lu $DIR/$tfile $DIR/${tfile}2
1814 # ls -lc $DIR/$tfile $DIR/${tfile}2
1816 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
1817 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
1819 ls -l $DIR/$tfile $DIR/${tfile}2
1821 ls -lu $DIR/$tfile $DIR/${tfile}2
1823 ls -lc $DIR/$tfile $DIR/${tfile}2
1824 error "O_TRUNC didn't change timestamps"
1827 run_test 39 "mtime changed on create ==========================="
1830 dd if=/dev/zero of=$DIR/f40 bs=4096 count=1
1831 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/f40 && error
1832 $CHECKSTAT -t file -s 4096 $DIR/f40 || error
1834 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
1838 small_write $DIR/f41 18
1840 run_test 41 "test small file write + fstat ====================="
1842 count_ost_writes() {
1843 lctl get_param -n osc.*.stats |
1844 awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }'
1851 BG_DIRTY_RATIO_SAVE=10
1852 MAX_BG_DIRTY_RATIO=25
1856 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
1857 # dirty_ratio, dirty_background_ratio
1858 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
1859 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
1860 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
1861 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
1863 # if file not here, we are a 2.4 kernel
1864 kill -CONT `pidof kupdated`
1869 # setup the trap first, so someone cannot exit the test at the
1870 # exact wrong time and mess up a machine
1871 trap start_writeback EXIT
1872 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
1873 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
1874 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
1875 sysctl -w vm.dirty_writeback_centisecs=0
1876 sysctl -w vm.dirty_writeback_centisecs=0
1877 # save and increase /proc/sys/vm/dirty_ratio
1878 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
1879 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
1880 # save and increase /proc/sys/vm/dirty_background_ratio
1881 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
1882 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
1884 # if file not here, we are a 2.4 kernel
1885 kill -STOP `pidof kupdated`
1889 # ensure that all stripes have some grant before we test client-side cache
1891 [ "$SETUP_TEST42" ] && return
1892 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
1893 dd if=/dev/zero of=$i bs=4k count=1
1899 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
1900 # file truncation, and file removal.
1903 cancel_lru_locks osc
1905 sync; sleep 1; sync # just to be safe
1906 BEFOREWRITES=`count_ost_writes`
1907 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
1908 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
1909 AFTERWRITES=`count_ost_writes`
1910 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
1911 error "$BEFOREWRITES < $AFTERWRITES"
1914 run_test 42a "ensure that we don't flush on close =============="
1918 cancel_lru_locks osc
1921 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
1922 BEFOREWRITES=`count_ost_writes`
1923 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
1924 AFTERWRITES=`count_ost_writes`
1925 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
1926 error "$BEFOREWRITES < $AFTERWRITES on unlink"
1928 BEFOREWRITES=`count_ost_writes`
1929 sync || error "sync: $?"
1930 AFTERWRITES=`count_ost_writes`
1931 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
1932 error "$BEFOREWRITES < $AFTERWRITES on sync"
1934 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
1938 run_test 42b "test destroy of file with cached dirty data ======"
1940 # if these tests just want to test the effect of truncation,
1941 # they have to be very careful. consider:
1942 # - the first open gets a {0,EOF}PR lock
1943 # - the first write conflicts and gets a {0, count-1}PW
1944 # - the rest of the writes are under {count,EOF}PW
1945 # - the open for truncate tries to match a {0,EOF}PR
1946 # for the filesize and cancels the PWs.
1947 # any number of fixes (don't get {0,EOF} on open, match
1948 # composite locks, do smarter file size management) fix
1949 # this, but for now we want these tests to verify that
1950 # the cancellation with truncate intent works, so we
1951 # start the file with a full-file pw lock to match against
1952 # until the truncate.
1957 cancel_lru_locks osc
1959 # prime the file with 0,EOF PW to match
1963 # now the real test..
1964 dd if=/dev/zero of=$file bs=1024 count=100
1965 BEFOREWRITES=`count_ost_writes`
1966 $TRUNCATE $file $offset
1967 cancel_lru_locks osc
1968 AFTERWRITES=`count_ost_writes`
1974 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
1975 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
1978 run_test 42c "test partial truncate of file with cached dirty data"
1982 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
1983 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
1986 run_test 42d "test complete truncate of file with cached dirty data"
1990 cp -p /bin/ls $DIR/$tdir/$tfile
1991 multiop $DIR/$tdir/$tfile Ow_c &
1993 # give multiop a chance to open
1996 $DIR/$tdir/$tfile && error || true
1999 run_test 43 "execution of file opened for write should return -ETXTBSY"
2003 cp -p `which multiop` $DIR/d43/multiop || cp -p multiop $DIR/d43/multiop
2004 MULTIOP_PROG=$DIR/d43/multiop multiop_bg_pause $TMP/test43.junk O_c || return 1
2006 multiop $DIR/d43/multiop Oc && error "expected error, got success"
2007 kill -USR1 $MULTIOP_PID || return 2
2008 wait $MULTIOP_PID || return 3
2011 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
2015 cp -p `which multiop` $DIR/d43/multiop || cp -p multiop $DIR/d43/multiop
2016 MULTIOP_PROG=$DIR/d43/multiop multiop_bg_pause $TMP/test43.junk O_c || return 1
2018 truncate $DIR/d43/multiop 0 && error "expected error, got success"
2019 kill -USR1 $MULTIOP_PID || return 2
2020 wait $MULTIOP_PID || return 3
2023 run_test 43b "truncate of file being executed should return -ETXTBSY"
2026 local testdir="$DIR/d43c"
2029 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
2030 ( cd $testdir && md5sum -c)
2032 run_test 43c "md5sum of copy into lustre========================"
2035 [ "$OSTCOUNT" -lt "2" ] && skip "skipping 2-stripe test" && return
2036 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
2037 dd if=$DIR/f1 bs=4k count=1 > /dev/null
2039 run_test 44 "zero length read from a sparse stripe ============="
2042 local nstripe=`$LCTL lov_getconfig $DIR | grep default_stripe_count: | \
2044 [ -z "$nstripe" ] && skip "can't get stripe info" && return
2045 [ "$nstripe" -gt "$OSTCOUNT" ] && skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" && return
2046 local stride=`$LCTL lov_getconfig $DIR | grep default_stripe_size: | \
2048 if [ $nstripe -eq 0 -o $nstripe -eq -1 ] ; then
2049 nstripe=`$LCTL lov_getconfig $DIR | grep obd_count: | awk '{print $2}'`
2052 OFFSETS="0 $((stride/2)) $((stride-1))"
2053 for offset in $OFFSETS ; do
2054 for i in `seq 0 $((nstripe-1))`; do
2055 local GLOBALOFFSETS=""
2056 local size=$((((i + 2 * $nstripe )*$stride + $offset))) # Bytes
2057 local myfn=$DIR/d44a-$size
2058 echo "--------writing $myfn at $size"
2059 ll_sparseness_write $myfn $size || error "ll_sparseness_write"
2060 GLOBALOFFSETS="$GLOBALOFFSETS $size"
2061 ll_sparseness_verify $myfn $GLOBALOFFSETS \
2062 || error "ll_sparseness_verify $GLOBALOFFSETS"
2064 for j in `seq 0 $((nstripe-1))`; do
2065 size=$((((j + $nstripe )*$stride + $offset))) # Bytes
2066 ll_sparseness_write $myfn $size || error "ll_sparseness_write"
2067 GLOBALOFFSETS="$GLOBALOFFSETS $size"
2069 ll_sparseness_verify $myfn $GLOBALOFFSETS \
2070 || error "ll_sparseness_verify $GLOBALOFFSETS"
2075 run_test 44a "test sparse pwrite ==============================="
2079 for d in `lctl get_param -n osc.*.cur_dirty_bytes`; do
2085 before=`dirty_osc_total`
2086 echo executing "\"$*\""
2088 after=`dirty_osc_total`
2089 echo before $before, after $after
2093 # Obtain grants from OST if it supports it
2094 echo blah > ${f}_grant
2097 do_dirty_record "echo blah > $f"
2098 [ $before -eq $after ] && error "write wasn't cached"
2099 do_dirty_record "> $f"
2100 [ $before -gt $after ] || error "truncate didn't lower dirty count"
2101 do_dirty_record "echo blah > $f"
2102 [ $before -eq $after ] && error "write wasn't cached"
2103 do_dirty_record "sync"
2104 [ $before -gt $after ] || error "writeback didn't lower dirty count"
2105 do_dirty_record "echo blah > $f"
2106 [ $before -eq $after ] && error "write wasn't cached"
2107 do_dirty_record "cancel_lru_locks osc"
2108 [ $before -gt $after ] || error "lock cancellation didn't lower dirty count"
2111 run_test 45 "osc io page accounting ============================"
2117 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
2118 # test tickles a bug where re-dirtying a page was failing to be mapped to the
2119 # objects offset and an assert hit when an rpc was built with 1023's mapped
2120 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
2125 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
2127 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
2128 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
2132 run_test 46 "dirtying a previously written page ================"
2134 # test_47 is removed "Device nodes check" is moved to test_28
2136 test_48a() { # bug 2399
2137 check_kernel_version 34 || return 0
2140 mv $DIR/d48a $DIR/d48.new || error "move directory failed"
2141 mkdir $DIR/d48a || error "recreate directory failed"
2142 touch foo || error "'touch foo' failed after recreating cwd"
2143 mkdir bar || error "'mkdir foo' failed after recreating cwd"
2144 if check_kernel_version 44; then
2145 touch .foo || error "'touch .foo' failed after recreating cwd"
2146 mkdir .bar || error "'mkdir .foo' failed after recreating cwd"
2148 ls . > /dev/null || error "'ls .' failed after recreating cwd"
2149 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
2150 cd . || error "'cd .' failed after recreating cwd"
2151 mkdir . && error "'mkdir .' worked after recreating cwd"
2152 rmdir . && error "'rmdir .' worked after recreating cwd"
2153 ln -s . baz || error "'ln -s .' failed after recreating cwd"
2154 cd .. || error "'cd ..' failed after recreating cwd"
2156 run_test 48a "Access renamed working dir (should return errors)="
2158 test_48b() { # bug 2399
2159 check_kernel_version 34 || return 0
2162 rmdir $DIR/d48b || error "remove cwd $DIR/d48b failed"
2163 touch foo && error "'touch foo' worked after removing cwd"
2164 mkdir foo && error "'mkdir foo' worked after removing cwd"
2165 if check_kernel_version 44; then
2166 touch .foo && error "'touch .foo' worked after removing cwd"
2167 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
2169 ls . > /dev/null && error "'ls .' worked after removing cwd"
2170 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
2171 is_patchless || ( cd . && error "'cd .' worked after removing cwd" )
2172 mkdir . && error "'mkdir .' worked after removing cwd"
2173 rmdir . && error "'rmdir .' worked after removing cwd"
2174 ln -s . foo && error "'ln -s .' worked after removing cwd"
2175 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
2177 run_test 48b "Access removed working dir (should return errors)="
2179 test_48c() { # bug 2350
2180 check_kernel_version 36 || return 0
2181 #lctl set_param debug=-1
2183 mkdir -p $DIR/d48c/dir
2185 $TRACE rmdir $DIR/d48c/dir || error "remove cwd $DIR/d48c/dir failed"
2186 $TRACE touch foo && error "'touch foo' worked after removing cwd"
2187 $TRACE mkdir foo && error "'mkdir foo' worked after removing cwd"
2188 if check_kernel_version 44; then
2189 touch .foo && error "'touch .foo' worked after removing cwd"
2190 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
2192 $TRACE ls . && error "'ls .' worked after removing cwd"
2193 $TRACE ls .. || error "'ls ..' failed after removing cwd"
2194 is_patchless || ( $TRACE cd . && error "'cd .' worked after removing cwd" )
2195 $TRACE mkdir . && error "'mkdir .' worked after removing cwd"
2196 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
2197 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
2198 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
2200 run_test 48c "Access removed working subdir (should return errors)"
2202 test_48d() { # bug 2350
2203 check_kernel_version 36 || return 0
2204 #lctl set_param debug=-1
2206 mkdir -p $DIR/d48d/dir
2208 $TRACE rmdir $DIR/d48d/dir || error "remove cwd $DIR/d48d/dir failed"
2209 $TRACE rmdir $DIR/d48d || error "remove parent $DIR/d48d failed"
2210 $TRACE touch foo && error "'touch foo' worked after removing parent"
2211 $TRACE mkdir foo && error "'mkdir foo' worked after removing parent"
2212 if check_kernel_version 44; then
2213 touch .foo && error "'touch .foo' worked after removing parent"
2214 mkdir .foo && error "'mkdir .foo' worked after removing parent"
2216 $TRACE ls . && error "'ls .' worked after removing parent"
2217 $TRACE ls .. && error "'ls ..' worked after removing parent"
2218 is_patchless || ( $TRACE cd . && error "'cd .' worked after recreate parent" )
2219 $TRACE mkdir . && error "'mkdir .' worked after removing parent"
2220 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
2221 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
2222 is_patchless || ( $TRACE cd .. && error "'cd ..' worked after removing parent" || true )
2224 run_test 48d "Access removed parent subdir (should return errors)"
2226 test_48e() { # bug 4134
2227 check_kernel_version 41 || return 0
2228 #lctl set_param debug=-1
2230 mkdir -p $DIR/d48e/dir
2232 $TRACE rmdir $DIR/d48e/dir || error "remove cwd $DIR/d48e/dir failed"
2233 $TRACE rmdir $DIR/d48e || error "remove parent $DIR/d48e failed"
2234 $TRACE touch $DIR/d48e || error "'touch $DIR/d48e' failed"
2235 $TRACE chmod +x $DIR/d48e || error "'chmod +x $DIR/d48e' failed"
2236 # On a buggy kernel addition of "touch foo" after cd .. will
2237 # produce kernel oops in lookup_hash_it
2238 touch ../foo && error "'cd ..' worked after recreate parent"
2240 $TRACE rm $DIR/d48e || error "rm '$DIR/d48e' failed"
2242 run_test 48e "Access to recreated parent subdir (should return errors)"
2248 ls /proc/$$/cwd || error
2250 run_test 50 "special situations: /proc symlinks ==============="
2252 test_51a() { # was test_51
2253 # bug 1516 - create an empty entry right after ".." then split dir
2256 $MCREATE $DIR/d51/bar
2258 createmany -m $DIR/d51/longfile 201
2260 while [ `ls -sd $DIR/d51 | awk '{ print $1 }'` -eq 4 ]; do
2261 $MCREATE $DIR/d51/longfile$FNUM
2266 ls -l $DIR/d51 > /dev/null || error
2268 run_test 51a "special situations: split htree with empty entry =="
2270 #export NUMTEST=70000
2271 # FIXME: I select a relatively small number to do basic test.
2272 # large number may give panic(). debugging on this is going on.
2275 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
2276 [ $NUMFREE -lt 21000 ] && \
2277 skip "not enough free inodes ($NUMFREE)" && \
2280 check_kernel_version 40 || NUMTEST=31000
2281 [ $NUMFREE -lt $NUMTEST ] && NUMTEST=$(($NUMFREE - 50))
2284 createmany -d $DIR/d51b/t- $NUMTEST
2286 run_test 51b "mkdir .../t-0 --- .../t-$NUMTEST ===================="
2289 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2291 local ndirs=${TEST51BB_NDIRS:-10}
2292 local nfiles=${TEST51BB_NFILES:-100}
2294 local numfree=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
2296 [ $numfree -lt $(( ndirs * nfiles)) ] && \
2297 nfiles=$(( numfree / ndirs - 10 ))
2299 local dir=$DIR/d51bb
2301 local savePOLICY=$(lctl get_param -n lmv.*.placement)
2302 lctl set_param -n lmv.*.placement=CHAR
2305 local IUSED=$(lfs df -i $dir | grep MDT | awk '{print $3}')
2309 for ((i=0; i < $ndirs; i++)); do
2310 dirs[i]=$dir/$RANDOM
2311 echo Creating directory ${dirs[i]}
2314 echo Creating $nfiles in dir ${dirs[i]} ...
2315 echo "createmany -o ${dirs[i]}/$tfile- $nfiles"
2316 createmany -o ${dirs[i]}/$tfile- $nfiles
2322 IUSED=$(lfs df -i $dir | grep MDT | awk '{print $3}')
2326 for ((i=0; i<${#NEWUSED[@]}; i++)); do
2327 echo "mds $i: inodes count OLD ${OLDUSED[$i]} NEW ${NEWUSED[$i]}"
2328 [ ${OLDUSED[$i]} -lt ${NEWUSED[$i]} ] || rc=$((rc + 1))
2331 lctl set_param -n lmv.*.placement=$savePOLICY
2333 [ $rc -ne $MDSCOUNT ] || \
2334 error "Objects/inodes are not distributed over all mds servers"
2336 run_test 51bb "mkdir createmany CMD $MDSCOUNT ===================="
2340 [ ! -d $DIR/d51b ] && skip "$DIR/51b missing" && \
2343 unlinkmany -d $DIR/d51b/t- $NUMTEST
2345 run_test 51c "rmdir .../t-0 --- .../t-$NUMTEST ===================="
2348 [ "$OSTCOUNT" -lt "3" ] && skip "skipping test with few OSTs" && return
2350 createmany -o $DIR/d51d/t- 1000
2351 $LFS getstripe $DIR/d51d > $TMP/files
2352 for N in `seq 0 $((OSTCOUNT - 1))`; do
2353 OBJS[$N]=`awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}' $TMP/files`
2354 OBJS0[$N]=`grep -A 1 idx $TMP/files | awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}'`
2355 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
2357 unlinkmany $DIR/d51d/t- 1000
2360 for N in `seq 1 $((OSTCOUNT - 1))`; do
2361 [ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ] && \
2362 error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
2363 [ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ] && \
2364 error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
2366 [ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ] && \
2367 error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
2368 [ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ] && \
2369 error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
2373 run_test 51d "check object distribution ===================="
2376 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
2379 chattr =a $DIR/d52a/foo || error "chattr =a failed"
2380 echo bar >> $DIR/d52a/foo || error "append bar failed"
2381 cp /etc/hosts $DIR/d52a/foo && error "cp worked"
2382 rm -f $DIR/d52a/foo 2>/dev/null && error "rm worked"
2383 link $DIR/d52a/foo $DIR/d52a/foo_link 2>/dev/null && error "link worked"
2384 echo foo >> $DIR/d52a/foo || error "append foo failed"
2385 mrename $DIR/d52a/foo $DIR/d52a/foo_ren && error "rename worked"
2386 lsattr $DIR/d52a/foo | egrep -q "^-+a-+ $DIR/d52a/foo" || error "lsattr"
2387 chattr -a $DIR/d52a/foo || error "chattr -a failed"
2389 rm -fr $DIR/d52a || error "cleanup rm failed"
2391 run_test 52a "append-only flag test (should return errors) ====="
2394 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
2397 chattr =i $DIR/d52b/foo || error
2398 cat test > $DIR/d52b/foo && error
2399 cp /etc/hosts $DIR/d52b/foo && error
2400 rm -f $DIR/d52b/foo 2>/dev/null && error
2401 link $DIR/d52b/foo $DIR/d52b/foo_link 2>/dev/null && error
2402 echo foo >> $DIR/d52b/foo && error
2403 mrename $DIR/d52b/foo $DIR/d52b/foo_ren && error
2404 [ -f $DIR/d52b/foo ] || error
2405 [ -f $DIR/d52b/foo_ren ] && error
2406 lsattr $DIR/d52b/foo | egrep -q "^-+i-+ $DIR/d52b/foo" || error
2407 chattr -i $DIR/d52b/foo || error
2409 rm -fr $DIR/d52b || error
2411 run_test 52b "immutable flag test (should return errors) ======="
2414 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2415 remote_ost_nodsh && skip "remote OST with nodsh" && return
2424 for value in $(do_facet $SINGLEMDS lctl get_param osc.*-osc-MDT0000.prealloc_last_id) ; do
2425 param=`echo ${value[0]} | cut -d "=" -f1`
2426 ostname=`echo $param | cut -d "." -f2 | cut -d - -f 1-2`
2427 mds_last=$(do_facet $SINGLEMDS lctl get_param -n $param)
2428 ostnum=$(echo $ostname | sed "s/${FSNAME}-OST//g" | awk '{print ($1+1)}' )
2429 ost_last=$(do_facet ost$ostnum lctl get_param -n obdfilter.$ostname.last_id | head -n 1)
2430 echo "$ostname.last_id=$ost_last ; MDS.last_id=$mds_last"
2431 if [ $ost_last != $mds_last ]; then
2432 error "$ostname.last_id=$ost_last ; MDS.last_id=$mds_last"
2436 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
2439 [ ! -f "$SOCKETSERVER" ] && skip "no socketserver, skipping" && return
2440 [ ! -f "$SOCKETCLIENT" ] && skip "no socketclient, skipping" && return
2441 $SOCKETSERVER $DIR/socket
2442 $SOCKETCLIENT $DIR/socket || error
2443 $MUNLINK $DIR/socket
2445 run_test 54a "unix domain socket test =========================="
2451 dd if=/dev/zero of=$f bs=`page_size` count=1
2453 run_test 54b "char device works in lustre ======================"
2456 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
2457 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
2458 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
2460 for i in `seq 3 7`; do
2461 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
2471 loopdev="$DIR/loop54c"
2474 [ -z "$LOOPNUM" ] && echo "couldn't find empty loop device" && return
2475 mknod $loopdev b 7 $LOOPNUM
2476 echo "make a loop file system with $tfile on $loopdev ($LOOPNUM)..."
2477 dd if=/dev/zero of=$tfile bs=`page_size` seek=1024 count=1 > /dev/null
2478 losetup $loopdev $tfile || error "can't set up $loopdev for $tfile"
2479 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
2481 mount -t ext2 $loopdev $tdir || error "error mounting $loopdev on $tdir"
2482 dd if=/dev/zero of=$tdir/tmp bs=`page_size` count=30 || error "dd write"
2484 dd if=$tdir/tmp of=/dev/zero bs=`page_size` count=30 || error "dd read"
2489 run_test 54c "block device works in lustre ====================="
2495 [ "$string" = `echo $string > $f | cat $f` ] || error
2497 run_test 54d "fifo device works in lustre ======================"
2500 check_kernel_version 46 || return 0
2503 cp -aL /dev/console $f
2504 echo $string > $f || error
2506 run_test 54e "console/tty device works in lustre ======================"
2509 grep -q $FSTYPE /proc/filesystems && return 1
2511 grep -q $FSTYPE /proc/filesystems && return 1
2512 insmod ../$FSTYPE/$FSTYPE.o
2513 grep -q $FSTYPE /proc/filesystems && return 1
2514 insmod ../$FSTYPE/$FSTYPE.ko
2515 grep -q $FSTYPE /proc/filesystems && return 1
2522 check_fstype && skip "can't find fs $FSTYPE" && return
2523 mount -t $FSTYPE -o loop,iopen $EXT2_DEV $DIR/d55 || error "mounting"
2525 $IOPENTEST1 $DIR/d55/foo $DIR/d55 || error "running $IOPENTEST1"
2526 $IOPENTEST2 $DIR/d55 || error "running $IOPENTEST2"
2527 echo "check for $EXT2_DEV. Please wait..."
2529 $UMOUNT $DIR/d55 || error "unmounting"
2531 run_test 55 "check iopen_connect_dentry() ======================"
2533 test_56a() { # was test_56
2539 NUMFILESx2=$(($NUMFILES * 2))
2540 for i in `seq 1 $NUMFILES` ; do
2541 touch $DIR/d56/file$i
2542 touch $DIR/d56/dir/file$i
2545 # test lfs getstripe with --recursive
2546 FILENUM=`$GETSTRIPE --recursive $DIR/d56 | grep -c obdidx`
2547 [ $FILENUM -eq $NUMFILESx2 ] || error \
2548 "lfs getstripe --recursive $DIR/d56 wrong: found $FILENUM, expected $NUMFILESx2"
2549 FILENUM=`$GETSTRIPE $DIR/d56 | grep -c obdidx`
2550 [ $FILENUM -eq $NUMFILES ] || error \
2551 "lfs getstripe $DIR/d56 without --recursive wrong: found $FILENUM, expected $NUMFILES"
2552 echo "lfs getstripe --recursive passed."
2554 # test lfs getstripe with file instead of dir
2555 FILENUM=`$GETSTRIPE $DIR/d56/file1 | grep -c obdidx`
2556 [ $FILENUM -eq 1 ] || error \
2557 "lfs getstripe $DIR/d56/file1 wrong:found $FILENUM, expected 1"
2558 echo "lfs getstripe file passed."
2560 #test lfs getstripe with --verbose
2561 [ `$GETSTRIPE --verbose $DIR/d56 | grep -c lmm_magic` -eq $NUMFILES ] ||\
2562 error "lfs getstripe --verbose $DIR/d56 wrong: should find $NUMFILES lmm_magic info"
2563 [ `$GETSTRIPE $DIR/d56 | grep -c lmm_magic` -eq 0 ] || error \
2564 "lfs getstripe $DIR/d56 without --verbose wrong: should not show lmm_magic info"
2565 echo "lfs getstripe --verbose passed."
2567 #test lfs getstripe with --obd
2568 $GETSTRIPE --obd wrong_uuid $DIR/d56 2>&1 | grep -q "unknown obduuid" || \
2569 error "lfs getstripe --obd wrong_uuid should return error message"
2571 [ "$OSTCOUNT" -lt 2 ] && \
2572 skip "skipping other lfs getstripe --obd test" && return
2573 FILENUM=`$GETSTRIPE --recursive $DIR/d56 | sed -n '/^[ ]*1[ ]/p' | wc -l`
2574 OBDUUID=`$GETSTRIPE --recursive $DIR/d56 | sed -n '/^[ ]*1:/p' | awk '{print $2}'`
2575 FOUND=`$GETSTRIPE -r --obd $OBDUUID $DIR/d56 | wc -l`
2576 [ $FOUND -eq $FILENUM ] || \
2577 error "lfs getstripe --obd wrong: found $FOUND, expected $FILENUM"
2578 [ `$GETSTRIPE -r -v --obd $OBDUUID $DIR/d56 | sed '/^[ ]*1[ ]/d' |\
2579 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l` -eq 0 ] || \
2580 error "lfs getstripe --obd wrong: should not show file on other obd"
2581 echo "lfs getstripe --obd passed."
2583 run_test 56a "check lfs getstripe ===================================="
2590 if [ ! -d "$DIR/${tdir}g" ] ; then
2591 mkdir -p $DIR/${tdir}g
2592 for i in `seq 1 $LOCAL_NUMFILES` ; do
2593 touch $DIR/${tdir}g/file$i
2595 for i in `seq 1 $LOCAL_NUMDIRS` ; do
2596 mkdir $DIR/${tdir}g/dir$i
2597 for j in `seq 1 $LOCAL_NUMFILES` ; do
2598 touch $DIR/${tdir}g/dir$i/file$j
2604 setup_56_special() {
2609 if [ ! -e "$TDIR/loop1b" ] ; then
2610 for i in `seq 1 $LOCAL_NUMFILES` ; do
2611 mknod $TDIR/loop${i}b b 7 $i
2612 mknod $TDIR/null${i}c c 1 3
2613 ln -s $TDIR/file1 $TDIR/link${i}l
2615 for i in `seq 1 $LOCAL_NUMDIRS` ; do
2616 mknod $TDIR/dir$i/loop${i}b b 7 $i
2617 mknod $TDIR/dir$i/null${i}c c 1 3
2618 ln -s $TDIR/dir$i/file1 $TDIR/dir$i/link${i}l
2626 setup_56 $NUMFILES $NUMDIRS
2628 EXPECTED=$(($NUMDIRS + 2))
2629 # test lfs find with -name
2630 for i in `seq 1 $NUMFILES` ; do
2631 NUMS=`$LFIND -name "*$i" $DIR/${tdir}g | wc -l`
2632 [ $NUMS -eq $EXPECTED ] || error \
2633 "lfs find -name \"*$i\" $DIR/${tdir}g wrong: found $NUMS, expected $EXPECTED"
2635 echo "lfs find -name passed."
2637 run_test 56g "check lfs find -name ============================="
2642 setup_56 $NUMFILES $NUMDIRS
2644 EXPECTED=$((($NUMDIRS+1)*($NUMFILES-1)+$NUMFILES))
2645 # test lfs find with ! -name
2646 for i in `seq 1 $NUMFILES` ; do
2647 NUMS=`$LFIND ! -name "*$i" $DIR/${tdir}g | wc -l`
2648 [ $NUMS -eq $EXPECTED ] || error \
2649 "lfs find ! -name \"*$i\" $DIR/${tdir}g wrong: found $NUMS, expected $EXPECTED"
2651 echo "lfs find ! -name passed."
2653 run_test 56h "check lfs find ! -name ============================="
2658 UUID=`$GETSTRIPE $DIR/$tdir | awk '/0: / { print $2 }'`
2659 OUT="`$LFIND -ost $UUID $DIR/$tdir`"
2660 [ "$OUT" ] && error "$LFIND returned directory '$OUT'" || true
2662 run_test 56i "check 'lfs find -ost UUID' skips directories ======="
2665 setup_56_special $NUMFILES $NUMDIRS
2667 EXPECTED=$((NUMDIRS+1))
2668 NUMS=`$LFIND -type d $DIR/${tdir}g | wc -l`
2669 [ $NUMS -eq $EXPECTED ] || \
2670 error "lfs find -type d $DIR/${tdir}g wrong: found $NUMS, expected $EXPECTED"
2672 run_test 56j "check lfs find -type d ============================="
2675 setup_56_special $NUMFILES $NUMDIRS
2677 EXPECTED=$(((NUMDIRS+1) * NUMFILES))
2678 NUMS=`$LFIND -type f $DIR/${tdir}g | wc -l`
2679 [ $NUMS -eq $EXPECTED ] || \
2680 error "lfs find -type f $DIR/${tdir}g wrong: found $NUMS, expected $EXPECTED"
2682 run_test 56k "check lfs find -type f ============================="
2685 setup_56_special $NUMFILES $NUMDIRS
2687 EXPECTED=$((NUMDIRS + NUMFILES))
2688 NUMS=`$LFIND -type b $DIR/${tdir}g | wc -l`
2689 [ $NUMS -eq $EXPECTED ] || \
2690 error "lfs find -type b $DIR/${tdir}g wrong: found $NUMS, expected $EXPECTED"
2692 run_test 56l "check lfs find -type b ============================="
2695 setup_56_special $NUMFILES $NUMDIRS
2697 EXPECTED=$((NUMDIRS + NUMFILES))
2698 NUMS=`$LFIND -type c $DIR/${tdir}g | wc -l`
2699 [ $NUMS -eq $EXPECTED ] || \
2700 error "lfs find -type c $DIR/${tdir}g wrong: found $NUMS, expected $EXPECTED"
2702 run_test 56m "check lfs find -type c ============================="
2705 setup_56_special $NUMFILES $NUMDIRS
2707 EXPECTED=$((NUMDIRS + NUMFILES))
2708 NUMS=`$LFIND -type l $DIR/${tdir}g | wc -l`
2709 [ $NUMS -eq $EXPECTED ] || \
2710 error "lfs find -type l $DIR/${tdir}g wrong: found $NUMS, expected $EXPECTED"
2712 run_test 56n "check lfs find -type l ============================="
2715 setup_56 $NUMFILES $NUMDIRS
2718 utime $TDIR/file1 > /dev/null || error "utime (1)"
2719 utime $TDIR/file2 > /dev/null || error "utime (2)"
2720 utime $TDIR/dir1 > /dev/null || error "utime (3)"
2721 utime $TDIR/dir2 > /dev/null || error "utime (4)"
2722 utime $TDIR/dir1/file1 > /dev/null || error "utime (5)"
2725 NUMS=`$LFIND -mtime +1 $TDIR | wc -l`
2726 [ $NUMS -eq $EXPECTED ] || \
2727 error "lfs find -mtime $TDIR wrong: found $NUMS, expected $EXPECTED"
2729 run_test 56o "check lfs find -mtime for old files =========================="
2732 [ $RUNAS_ID -eq $UID ] && skip "RUNAS_ID = UID = $UID -- skipping" && return
2737 setup_56 $NUMFILES $NUMDIRS
2739 chown $RUNAS_ID $TDIR/file* || error "chown $DIR/${tdir}g/file$i failed"
2741 NUMS="`$LFIND -uid $RUNAS_ID $TDIR | wc -l`"
2742 [ $NUMS -eq $EXPECTED ] || \
2743 error "lfs find -uid $TDIR wrong: found $NUMS, expected $EXPECTED"
2745 EXPECTED=$(( ($NUMFILES+1) * $NUMDIRS + 1))
2746 NUMS="`$LFIND ! -uid $RUNAS_ID $TDIR | wc -l`"
2747 [ $NUMS -eq $EXPECTED ] || \
2748 error "lfs find ! -uid $TDIR wrong: found $NUMS, expected $EXPECTED"
2750 echo "lfs find -uid and ! -uid passed."
2752 run_test 56p "check lfs find -uid and ! -uid ==============================="
2755 [ $RUNAS_ID -eq $UID ] && skip "RUNAS_ID = UID = $UID -- skipping" && return
2760 setup_56 $NUMFILES $NUMDIRS
2762 chgrp $RUNAS_ID $TDIR/file* || error "chown $DIR/${tdir}g/file$i failed"
2764 NUMS="`$LFIND -gid $RUNAS_ID $TDIR | wc -l`"
2765 [ $NUMS -eq $EXPECTED ] || \
2766 error "lfs find -gid $TDIR wrong: found $NUMS, expected $EXPECTED"
2768 EXPECTED=$(( ($NUMFILES+1) * $NUMDIRS + 1))
2769 NUMS="`$LFIND ! -gid $RUNAS_ID $TDIR | wc -l`"
2770 [ $NUMS -eq $EXPECTED ] || \
2771 error "lfs find ! -gid $TDIR wrong: found $NUMS, expected $EXPECTED"
2773 echo "lfs find -gid and ! -gid passed."
2775 run_test 56q "check lfs find -gid and ! -gid ==============================="
2778 # note test will not do anything if MDS is not local
2779 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2781 local MNTDEV="osd.*MDT*.mntdev"
2782 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
2783 [ -z "$DEV" ] && error "can't access $MNTDEV"
2784 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
2785 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump || error "can't access $DEV"
2786 DEVISIZE=`awk '/Inode size:/ { print $3 }' $TMP/t57a.dump`
2787 [ "$DEVISIZE" -gt 128 ] || error "inode size $DEVISIZE"
2791 run_test 57a "verify MDS filesystem created with large inodes =="
2798 local FILEN=$dir/f$FILECOUNT
2800 rm -rf $dir || error "removing $dir"
2801 mkdir -p $dir || error "creating $dir"
2802 local num=$(get_mds_dir $dir)
2805 echo "mcreating $FILECOUNT files"
2806 createmany -m $dir/f 1 $FILECOUNT || \
2807 error "creating files in $dir"
2809 # verify that files do not have EAs yet
2810 $GETSTRIPE $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
2811 $GETSTRIPE $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
2815 df $dir #make sure we get new statfs data
2816 local MDSFREE=$(do_facet $mymds lctl get_param -n osd.*MDT000$((num -1)).kbytesfree)
2817 local MDCFREE=$(lctl get_param -n mdc.*MDT000$((num -1))-mdc-*.kbytesfree)
2818 echo "opening files to create objects/EAs"
2820 for FILE in `seq -f $dir/f%g 1 $FILECOUNT`; do
2821 $OPENFILE -f O_RDWR $FILE > /dev/null 2>&1 || error "opening $FILE"
2824 # verify that files have EAs now
2825 $GETSTRIPE $FILE1 | grep -q "obdidx" || error "$FILE1 missing EA"
2826 $GETSTRIPE $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
2828 sleep 1 #make sure we get new statfs data
2830 local MDSFREE2=$(do_facet $mymds lctl get_param -n osd.*MDT000$((num -1)).kbytesfree)
2831 local MDCFREE2=$(lctl get_param -n mdc.*MDT000$((num -1))-mdc-*.kbytesfree)
2832 if [ "$MDCFREE2" -lt "$((MDCFREE - 8))" ]; then
2833 if [ "$MDSFREE" != "$MDSFREE2" ]; then
2834 error "MDC before $MDCFREE != after $MDCFREE2"
2836 echo "MDC before $MDCFREE != after $MDCFREE2"
2837 echo "unable to confirm if MDS has large inodes"
2842 run_test 57b "default LOV EAs are stored inside large inodes ==="
2845 [ -z "$(which wiretest 2>/dev/null)" ] && skip "could not find wiretest" && return
2848 run_test 58 "verify cross-platform wire constants =============="
2851 echo "touch 130 files"
2852 createmany -o $DIR/f59- 130
2854 unlinkmany $DIR/f59- 130
2857 # wait for commitment of removal
2859 run_test 59 "verify cancellation of llog records async ========="
2861 TEST60_HEAD="test_60 run $RANDOM"
2863 [ ! -f run-llog.sh ] && skip "missing subtest run-llog.sh" && return
2864 log "$TEST60_HEAD - from kernel mode"
2867 run_test 60a "llog sanity tests run from kernel module =========="
2869 test_60b() { # bug 6411
2871 LLOG_COUNT=`dmesg | awk "/$TEST60_HEAD/{marker = 1; from_marker = 0;}
2883 [ $LLOG_COUNT -gt 50 ] && error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)"|| true
2885 run_test 60b "limit repeated messages from CERROR/CWARN ========"
2888 echo "create 5000 files"
2889 createmany -o $DIR/f60c- 5000
2890 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
2891 lctl set_param fail_loc=0x80000137
2892 unlinkmany $DIR/f60c- 5000
2893 lctl set_param fail_loc=0
2895 run_test 60c "unlink file when mds full"
2898 SAVEPRINTK=$(lctl get_param -n printk)
2900 # verify "lctl mark" is even working"
2901 MESSAGE="test message ID $RANDOM $$"
2902 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
2903 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
2905 lctl set_param printk=0 || error "set lnet.printk failed"
2906 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
2907 MESSAGE="new test message ID $RANDOM $$"
2908 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
2909 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
2910 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
2912 lctl set_param -n printk="$SAVEPRINTK"
2914 run_test 60d "test printk console message masking"
2918 dd if=/dev/zero of=$f bs=`page_size` count=1
2919 cancel_lru_locks osc
2920 multiop $f OSMWUc || error
2923 run_test 61 "mmap() writes don't make sync hang ================"
2925 # bug 2330 - insufficient obd_match error checking causes LBUG
2929 cancel_lru_locks osc
2930 lctl set_param fail_loc=0x405
2931 cat $f && error "cat succeeded, expect -EIO"
2932 lctl set_param fail_loc=0
2934 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
2935 # match every page all of the time.
2936 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
2938 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
2939 test_63a() { # was test_63
2940 MAX_DIRTY_MB=`lctl get_param -n osc.*.max_dirty_mb | head -n 1`
2941 lctl set_param -n osc.*.max_dirty_mb 0
2942 for i in `seq 10` ; do
2943 dd if=/dev/zero of=$DIR/f63 bs=8k &
2949 lctl set_param -n osc.*.max_dirty_mb $MAX_DIRTY_MB
2950 rm -f $DIR/f63 || true
2952 run_test 63a "Verify oig_wait interruption does not crash ======="
2954 # bug 2248 - async write errors didn't return to application on sync
2955 # bug 3677 - async write errors left page locked
2958 lctl set_param debug=-1
2960 # ensure we have a grant to do async writes
2961 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
2964 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
2965 lctl set_param fail_loc=0x80000406
2966 multiop $DIR/$tfile Owy && \
2967 error "sync didn't return ENOMEM"
2968 sync; sleep 2; sync # do a real sync this time to flush page
2969 lctl get_param -n llite.*.dump_page_cache | grep locked && \
2970 error "locked page left in cache after async error" || true
2973 run_test 63b "async write errors should be returned to fsync ==="
2977 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
2979 run_test 64a "verify filter grant calculations (in kernel) ====="
2982 [ ! -f oos.sh ] && skip "missing subtest oos.sh" && return
2985 run_test 64b "check out-of-space detection on client ==========="
2987 # bug 1414 - set/get directories' stripe info
2991 $LVERIFY $DIR/d65 $DIR/d65/f1 || error "lverify failed"
2993 run_test 65a "directory with no stripe info ===================="
2997 $SETSTRIPE $DIR/d65 -s $(($STRIPESIZE * 2)) -i 0 -c 1 || error "setstripe"
2999 $LVERIFY $DIR/d65 $DIR/d65/f2 || error "lverify failed"
3001 run_test 65b "directory setstripe $(($STRIPESIZE * 2)) 0 1 ==============="
3004 if [ $OSTCOUNT -gt 1 ]; then
3006 $SETSTRIPE $DIR/d65 -s $(($STRIPESIZE * 4)) -i 1 \
3007 -c $(($OSTCOUNT - 1)) || error "setstripe"
3009 $LVERIFY $DIR/d65 $DIR/d65/f3 || error "lverify failed"
3012 run_test 65c "directory setstripe $(($STRIPESIZE * 4)) 1 $(($OSTCOUNT - 1))"
3016 if [ $STRIPECOUNT -le 0 ]; then
3018 elif [ $STRIPECOUNT -gt 160 ]; then
3019 #LOV_MAX_STRIPE_COUNT is 160
3020 [ $OSTCOUNT -gt 160 ] && sc=160 || sc=$(($OSTCOUNT - 1))
3022 sc=$(($STRIPECOUNT - 1))
3024 $SETSTRIPE $DIR/d65 -s $STRIPESIZE -c $sc || error "setstripe"
3025 touch $DIR/d65/f4 $DIR/d65/f5
3026 $LVERIFY $DIR/d65 $DIR/d65/f4 $DIR/d65/f5 || error "lverify failed"
3028 run_test 65d "directory setstripe $STRIPESIZE -1 stripe_count =============="
3033 $SETSTRIPE $DIR/d65 || error "setstripe"
3034 $GETSTRIPE -v $DIR/d65 | grep "Default" || error "no stripe info failed"
3036 $LVERIFY $DIR/d65 $DIR/d65/f6 || error "lverify failed"
3038 run_test 65e "directory setstripe defaults ======================="
3042 $RUNAS $SETSTRIPE $DIR/d65f && error "setstripe succeeded" || true
3044 run_test 65f "dir setstripe permission (should return error) ==="
3048 $SETSTRIPE $DIR/d65 -s $(($STRIPESIZE * 2)) -i 0 -c 1 || error "setstripe"
3049 $SETSTRIPE -d $DIR/d65 || error "setstripe"
3050 $GETSTRIPE -v $DIR/d65 | grep "Default" || \
3051 error "delete default stripe failed"
3053 run_test 65g "directory setstripe -d ==========================="
3057 $SETSTRIPE $DIR/d65 -s $(($STRIPESIZE * 2)) -i 0 -c 1 || error "setstripe"
3058 mkdir -p $DIR/d65/dd1
3059 [ "`$GETSTRIPE -v $DIR/d65 | grep "^count"`" == \
3060 "`$GETSTRIPE -v $DIR/d65/dd1 | grep "^count"`" ] || error "stripe info inherit failed"
3062 run_test 65h "directory stripe info inherit ===================="
3064 test_65i() { # bug6367
3065 $SETSTRIPE $MOUNT -s 65536 -c -1
3067 run_test 65i "set non-default striping on root directory (bug 6367)="
3069 test_65ia() { # bug12836
3070 $LFS getstripe $MOUNT || error "getstripe $MOUNT failed"
3072 run_test 65ia "getstripe on -1 default directory striping"
3074 test_65ib() { # bug12836
3075 $LFS getstripe -v $MOUNT || error "getstripe -v $MOUNT failed"
3077 run_test 65ib "getstripe -v on -1 default directory striping"
3079 test_65ic() { # bug12836
3080 $LFS find -mtime -1 $MOUNT || error "find $MOUNT failed"
3082 run_test 65ic "new find on -1 default directory striping"
3084 test_65j() { # bug6367
3086 # if we aren't already remounting for each test, do so for this test
3087 if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
3088 cleanup || error "failed to unmount"
3091 $SETSTRIPE -d $MOUNT || error "setstripe failed"
3093 run_test 65j "set default striping on root directory (bug 6367)="
3095 test_65k() { # bug11679
3096 [ "$OSTCOUNT" -lt 2 ] && skip "too few OSTs" && return
3097 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3099 echo "Check OST status: "
3100 MDS_OSCS=`do_facet $SINGLEMDS lctl dl | awk '/[oO][sS][cC].*md[ts]/ { print $4 }'`
3101 for OSC in $MDS_OSCS; do
3102 echo $OSC "is activate"
3103 do_facet $SINGLEMDS lctl --device %$OSC activate
3105 do_facet client mkdir -p $DIR/$tdir
3106 for INACTIVE_OSC in $MDS_OSCS; do
3107 echo $INACTIVE_OSC "is Deactivate:"
3108 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
3109 for STRIPE_OSC in $MDS_OSCS; do
3110 STRIPE_OST=`osc_to_ost $STRIPE_OSC`
3111 STRIPE_INDEX=`do_facet $SINGLEMDS lctl get_param -n lov.*md*.target_obd |
3112 grep $STRIPE_OST | awk -F: '{print $1}' | head -n 1`
3114 [ -f $DIR/$tdir/${STRIPE_INDEX} ] && continue
3115 echo "$SETSTRIPE $DIR/$tdir/${STRIPE_INDEX} -i ${STRIPE_INDEX} -c 1"
3116 do_facet client $SETSTRIPE $DIR/$tdir/${STRIPE_INDEX} -i ${STRIPE_INDEX} -c 1
3118 [ $RC -ne 0 ] && error "setstripe should have succeeded"
3120 do_facet client rm -f $DIR/$tdir/*
3121 echo $INACTIVE_OSC "is Activate."
3122 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
3125 run_test 65k "validate manual striping works properly with deactivated OSCs"
3127 test_65l() { # bug 12836
3128 mkdir -p $DIR/$tdir/test_dir
3129 $SETSTRIPE $DIR/$tdir/test_dir -c -1
3130 $LFS find -mtime -1 $DIR/$tdir >/dev/null
3132 run_test 65l "lfs find on -1 stripe dir ========================"
3134 # bug 2543 - update blocks count on client
3137 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
3139 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
3140 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
3142 run_test 66 "update inode blocks count on client ==============="
3147 if [ ! -z "$LLOOP" ]; then
3148 if swapon -s | grep -q $LLOOP; then
3149 swapoff $LLOOP || error "swapoff failed"
3152 $LCTL blockdev_detach $LLOOP || error "detach failed"
3160 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
3164 swapon -s | awk '($1 == "'$1'") { print $4 }'
3167 # test case for lloop driver, basic function
3169 [ "$UID" != 0 ] && skip "must run as root" && return
3171 grep -q llite_lloop /proc/modules
3172 [ $? -ne 0 ] && skip "can't find module llite_lloop" && return
3174 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
3175 dd if=/dev/zero of=$DIR/f68a bs=4k count=1024
3176 $LCTL blockdev_attach $DIR/f68a $LLOOP || error "attach failed"
3178 trap cleanup_68 EXIT
3180 directio rdwr $LLOOP 0 1024 4096 || error "direct write failed"
3181 directio rdwr $LLOOP 0 1025 4096 && error "direct write should fail"
3185 run_test 68a "lloop driver - basic test ========================"
3187 # excercise swapping to lustre by adding a high priority swapfile entry
3188 # and then consuming memory until it is used.
3189 test_68b() { # was test_68
3190 [ "$UID" != 0 ] && skip "must run as root" && return
3191 lctl get_param -n devices | grep -q obdfilter && \
3192 skip "local OST" && return
3194 grep -q llite_lloop /proc/modules
3195 [ $? -ne 0 ] && skip "can't find module llite_lloop" && return
3197 [ -z "`$LCTL list_nids | grep -v tcp`" ] && \
3198 skip "can't reliably test swap with TCP" && return
3200 MEMTOTAL=`meminfo MemTotal`
3201 NR_BLOCKS=$((MEMTOTAL>>8))
3202 [[ $NR_BLOCKS -le 2048 ]] && NR_BLOCKS=2048
3204 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
3205 dd if=/dev/zero of=$DIR/f68b bs=64k seek=$NR_BLOCKS count=1
3208 $LCTL blockdev_attach $DIR/f68b $LLOOP || error "attach failed"
3210 trap cleanup_68 EXIT
3212 swapon -p 32767 $LLOOP || error "swapon $LLOOP failed"
3214 echo "before: `swapon -s | grep $LLOOP`"
3215 $MEMHOG $MEMTOTAL || error "error allocating $MEMTOTAL kB"
3216 echo "after: `swapon -s | grep $LLOOP`"
3217 SWAPUSED=`swap_used $LLOOP`
3221 [ $SWAPUSED -eq 0 ] && echo "no swap used???" || true
3223 run_test 68b "support swapping to Lustre ========================"
3225 # bug5265, obdfilter oa2dentry return -ENOENT
3226 # #define OBD_FAIL_OST_ENOENT 0x217
3228 remote_ost_nodsh && skip "remote OST with nodsh" && return
3231 $SETSTRIPE $f -c 1 -i 0
3233 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
3235 do_facet ost1 lctl set_param fail_loc=0x217
3236 truncate $f 1 # vmtruncate() will ignore truncate() error.
3237 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
3239 do_facet ost1 lctl set_param fail_loc=0
3240 $DIRECTIO write $f 0 2 || error "write error"
3242 cancel_lru_locks osc
3243 $DIRECTIO read $f 0 1 || error "read error"
3245 do_facet ost1 lctl set_param fail_loc=0x217
3246 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
3248 do_facet ost1 lctl set_param fail_loc=0
3251 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
3255 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
3257 run_test 71 "Running dbench on lustre (don't segment fault) ===="
3259 test_72() { # bug 5695 - Test that on 2.6 remove_suid works properly
3260 check_kernel_version 43 || return 0
3261 [ "$RUNAS_ID" = "$UID" ] && skip "RUNAS_ID = UID = $UID -- skipping" && return
3263 # Check that testing environment is properly set up. Skip if not
3264 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS || {
3265 skip "User $RUNAS_ID does not exist - skipping"
3268 # We had better clear the $DIR to get enough space for dd
3273 $RUNAS dd if=/dev/zero of=$DIR/f72 bs=512 count=1 || error
3274 # See if we are still setuid/sgid
3275 test -u $DIR/f72 -o -g $DIR/f72 && error "S/gid is not dropped on write"
3276 # Now test that MDS is updated too
3277 cancel_lru_locks mdc
3278 test -u $DIR/f72 -o -g $DIR/f72 && error "S/gid is not dropped on MDS"
3282 run_test 72 "Test that remove suid works properly (bug5695) ===="
3284 # bug 3462 - multiple simultaneous MDC requests
3288 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
3291 lctl set_param fail_loc=0x80000129
3292 multiop $DIR/d73-1/f73-2 Oc &
3294 lctl set_param fail_loc=0
3296 multiop $DIR/d73-2/f73-3 Oc &
3300 wait $pid1 || return 1
3304 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
3305 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
3306 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
3310 run_test 73 "multiple MDC requests (should not deadlock)"
3312 test_74a() { # bug 6149, 6184
3313 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
3315 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
3316 # will spin in a tight reconnection loop
3318 lctl set_param fail_loc=0x8000030e
3319 # get any lock that won't be difficult - lookup works.
3321 lctl set_param fail_loc=0
3325 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
3327 test_74b() { # bug 13310
3328 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
3330 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
3331 # will spin in a tight reconnection loop
3332 lctl set_param fail_loc=0x8000030e
3333 # get a "difficult" lock
3335 lctl set_param fail_loc=0
3339 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
3341 JOIN=${JOIN:-"lfs join"}
3348 [ $T75_PREP = "yes" ] && return
3349 echo "using F75=$F75, F128k=$F128k, FHEAD=$FHEAD, FTAIL=$FTAIL"
3351 dd if=/dev/urandom of=${F75}_128k bs=128k count=1 || error "dd failed"
3360 cp -p ${F128k} ${FHEAD}
3361 log "finished cp to $FHEAD"
3362 cp -p ${F128k} ${FTAIL}
3363 log "finished cp to $FTAIL"
3364 cat ${F128k} ${F128k} > ${F75}_sim_sim
3366 $JOIN ${FHEAD} ${FTAIL} || error "join ${FHEAD} ${FTAIL} error"
3367 log "finished join $FHEAD to ${F75}_sim_sim"
3368 cmp ${FHEAD} ${F75}_sim_sim || error "${FHEAD} ${F75}_sim_sim differ"
3369 log "finished cmp $FHEAD to ${F75}_sim_sim"
3370 $CHECKSTAT -a ${FTAIL} || error "tail ${FTAIL} still exist after join"
3372 run_test 75a "TEST join file ===================================="
3377 cp -p ${F128k} ${FTAIL}
3378 cat ${F75}_sim_sim >> ${F75}_join_sim
3379 cat ${F128k} >> ${F75}_join_sim
3380 $JOIN ${FHEAD} ${FTAIL} || error "join ${FHEAD} ${FTAIL} error"
3381 cmp ${FHEAD} ${F75}_join_sim || \
3382 error "${FHEAD} ${F75}_join_sim are different"
3383 $CHECKSTAT -a ${FTAIL} || error "tail ${FTAIL} exist after join"
3385 run_test 75b "TEST join file 2 =================================="
3390 cp -p ${F128k} ${FTAIL}
3391 cat ${F128k} >> ${F75}_sim_join
3392 cat ${F75}_join_sim >> ${F75}_sim_join
3393 $JOIN ${FTAIL} ${FHEAD} || error "join error"
3394 cmp ${FTAIL} ${F75}_sim_join || \
3395 error "${FTAIL} ${F75}_sim_join are different"
3396 $CHECKSTAT -a ${FHEAD} || error "tail ${FHEAD} exist after join"
3398 run_test 75c "TEST join file 3 =================================="
3403 cp -p ${F128k} ${FHEAD}
3404 cp -p ${F128k} ${FHEAD}_tmp
3405 cat ${F75}_sim_sim >> ${F75}_join_join
3406 cat ${F75}_sim_join >> ${F75}_join_join
3407 $JOIN ${FHEAD} ${FHEAD}_tmp || error "join ${FHEAD} ${FHEAD}_tmp error"
3408 $JOIN ${FHEAD} ${FTAIL} || error "join ${FHEAD} ${FTAIL} error"
3409 cmp ${FHEAD} ${F75}_join_join ||error "${FHEAD} ${F75}_join_join differ" $CHECKSTAT -a ${FHEAD}_tmp || error "${FHEAD}_tmp exist after join"
3410 $CHECKSTAT -a ${FTAIL} || error "tail ${FTAIL} exist after join (2)"
3412 run_test 75d "TEST join file 4 =================================="
3417 rm -rf ${FHEAD} || "delete join file error"
3419 run_test 75e "TEST join file 5 (remove joined file) ============="
3424 cp -p ${F128k} ${F75}_join_10_compare
3425 cp -p ${F128k} ${F75}_join_10
3426 for ((i = 0; i < 10; i++)); do
3427 cat ${F128k} >> ${F75}_join_10_compare
3428 cp -p ${F128k} ${FTAIL}
3429 $JOIN ${F75}_join_10 ${FTAIL} || \
3430 error "join ${F75}_join_10 ${FTAIL} error"
3431 $CHECKSTAT -a ${FTAIL} || error "tail file exist after join"
3433 cmp ${F75}_join_10 ${F75}_join_10_compare || \
3434 error "files ${F75}_join_10 ${F75}_join_10_compare differ"
3436 run_test 75f "TEST join file 6 (join 10 files) =================="
3439 [ ! -f ${F75}_join_10 ] && echo "${F75}_join_10 missing" && return
3440 $LFS getstripe ${F75}_join_10
3442 $OPENUNLINK ${F75}_join_10 ${F75}_join_10 || error "files unlink open"
3446 run_test 75g "TEST join file 7 (open unlink) ===================="
3449 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
3452 test_76() { # bug 1443
3453 DETH=$(grep deathrow /proc/kallsyms /proc/ksyms 2> /dev/null | wc -l)
3454 [ $DETH -eq 0 ] && skip "No _iget." && return 0
3455 BEFORE_INODES=`num_inodes`
3456 echo "before inodes: $BEFORE_INODES"
3458 [ "$SLOW" = "no" ] && COUNT=100
3459 for i in `seq $COUNT`; do
3463 AFTER_INODES=`num_inodes`
3464 echo "after inodes: $AFTER_INODES"
3465 [ $AFTER_INODES -gt $((BEFORE_INODES + 32)) ] && \
3466 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
3469 run_test 76 "destroy duplicate inodes in client inode cache ===="
3474 # Note: in sptlrpc modes which enable its own bulk checksum, the
3475 # original crc32_le bulk checksum will be automatically disabled,
3476 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
3477 # will be checked by sptlrpc code against sptlrpc bulk checksum.
3478 # In this case set_checksums() will not be no-op, because sptlrpc
3479 # bulk checksum will be enabled all through the test.
3481 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
3482 lctl set_param -n osc.*.checksums $1
3486 export ORIG_CSUM_TYPE=""
3487 CKSUM_TYPES=${CKSUM_TYPES:-"crc32 adler"}
3490 [ "$ORIG_CSUM_TYPE" ] || \
3491 ORIG_CSUM_TYPE=`lctl get_param -n osc/*osc-[^mM]*/checksum_type |
3492 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`
3493 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
3494 log "set checksum type to $1"
3497 F77_TMP=$TMP/f77-temp
3500 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
3501 error "error writing to $F77_TMP"
3504 test_77a() { # bug 10889
3505 $GSS && skip "could not run with gss" && return
3506 [ ! -f $F77_TMP ] && setup_f77
3508 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
3512 run_test 77a "normal checksum read/write operation ============="
3514 test_77b() { # bug 10889
3515 $GSS && skip "could not run with gss" && return
3516 [ ! -f $F77_TMP ] && setup_f77
3517 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
3518 lctl set_param fail_loc=0x80000409
3520 dd if=$F77_TMP of=$DIR/f77b bs=1M count=$F77SZ conv=sync || \
3521 error "dd error: $?"
3522 lctl set_param fail_loc=0
3525 run_test 77b "checksum error on client write ===================="
3527 test_77c() { # bug 10889
3528 $GSS && skip "could not run with gss" && return
3529 [ ! -f $DIR/f77b ] && skip "requires 77b - skipping" && return
3531 for algo in $CKSUM_TYPES; do
3532 cancel_lru_locks osc
3533 set_checksum_type $algo
3534 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
3535 lctl set_param fail_loc=0x80000408
3536 cmp $F77_TMP $DIR/f77b || error "file compare failed"
3537 lctl set_param fail_loc=0
3540 set_checksum_type $ORIG_CSUM_TYPE
3543 run_test 77c "checksum error on client read ==================="
3545 test_77d() { # bug 10889
3546 $GSS && skip "could not run with gss" && return
3547 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
3548 lctl set_param fail_loc=0x80000409
3550 directio write $DIR/f77 0 $F77SZ $((1024 * 1024)) || \
3551 error "direct write: rc=$?"
3552 lctl set_param fail_loc=0
3555 run_test 77d "checksum error on OST direct write ==============="
3557 test_77e() { # bug 10889
3558 $GSS && skip "could not run with gss" && return
3559 [ ! -f $DIR/f77 ] && skip "requires 77d - skipping" && return
3560 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
3561 lctl set_param fail_loc=0x80000408
3563 cancel_lru_locks osc
3564 directio read $DIR/f77 0 $F77SZ $((1024 * 1024)) || \
3565 error "direct read: rc=$?"
3566 lctl set_param fail_loc=0
3569 run_test 77e "checksum error on OST direct read ================"
3571 test_77f() { # bug 10889
3572 $GSS && skip "could not run with gss" && return
3574 for algo in $CKSUM_TYPES; do
3575 cancel_lru_locks osc
3576 set_checksum_type $algo
3577 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
3578 lctl set_param fail_loc=0x409
3579 directio write $DIR/f77 0 $F77SZ $((1024 * 1024)) && \
3580 error "direct write succeeded"
3581 lctl set_param fail_loc=0
3583 set_checksum_type $ORIG_CSUM_TYPE
3586 run_test 77f "repeat checksum error on write (expect error) ===="
3588 test_77g() { # bug 10889
3589 $GSS && skip "could not run with gss" && return
3590 remote_ost_nodsh && skip "remote OST with nodsh" && return
3592 [ ! -f $F77_TMP ] && setup_f77
3594 $SETSTRIPE $DIR/f77g -c 1 -i 0
3595 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
3596 do_facet ost1 lctl set_param fail_loc=0x8000021a
3598 dd if=$F77_TMP of=$DIR/f77g bs=1M count=$F77SZ || \
3599 error "write error: rc=$?"
3600 do_facet ost1 lctl set_param fail_loc=0
3603 run_test 77g "checksum error on OST write ======================"
3605 test_77h() { # bug 10889
3606 $GSS && skip "could not run with gss" && return
3607 remote_ost_nodsh && skip "remote OST with nodsh" && return
3609 [ ! -f $DIR/f77g ] && skip "requires 77g - skipping" && return
3610 cancel_lru_locks osc
3611 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
3612 do_facet ost1 lctl set_param fail_loc=0x8000021b
3614 cmp $F77_TMP $DIR/f77g || error "file compare failed"
3615 do_facet ost1 lctl set_param fail_loc=0
3618 run_test 77h "checksum error on OST read ======================="
3620 test_77i() { # bug 13805
3621 $GSS && skip "could not run with gss" && return
3622 #define OBD_FAIL_OSC_CONNECT_CKSUM 0x40b
3623 lctl set_param fail_loc=0x40b
3624 remount_client $MOUNT
3625 lctl set_param fail_loc=0
3626 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
3627 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
3628 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
3629 [ "$algo" = "crc32" ] || error "algo set to $algo instead of crc32"
3631 remount_client $MOUNT
3633 run_test 77i "client not supporting OSD_CONNECT_CKSUM =========="
3635 test_77j() { # bug 13805
3636 $GSS && skip "could not run with gss" && return
3637 #define OBD_FAIL_OSC_CKSUM_ADLER_ONLY 0x40c
3638 lctl set_param fail_loc=0x40c
3639 remount_client $MOUNT
3640 lctl set_param fail_loc=0
3641 sleep 2 # wait async osc connect to finish
3642 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
3643 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
3644 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
3645 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
3647 remount_client $MOUNT
3649 run_test 77j "client only supporting ADLER32 ===================="
3651 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
3655 test_78() { # bug 10901
3657 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
3658 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
3659 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
3660 echo "MemTotal: $MEMTOTAL"
3661 # reserve 256MB of memory for the kernel and other running processes,
3662 # and then take 1/2 of the remaining memory for the read/write buffers.
3663 if [ $MEMTOTAL -gt 512 ] ;then
3664 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
3666 # for those poor memory-starved high-end clusters...
3667 MEMTOTAL=$((MEMTOTAL / 2))
3669 echo "Mem to use for directio: $MEMTOTAL"
3670 [ $F78SIZE -gt $MEMTOTAL ] && F78SIZE=$MEMTOTAL
3671 [ $F78SIZE -gt 512 ] && F78SIZE=512
3672 [ $F78SIZE -gt $((MAXFREE / 1024)) ] && F78SIZE=$((MAXFREE / 1024))
3673 SMALLESTOST=`lfs df $DIR |grep OST | awk '{print $4}' |sort -n |head -1`
3674 echo "Smallest OST: $SMALLESTOST"
3675 [ $SMALLESTOST -lt 10240 ] && \
3676 skip "too small OSTSIZE, useless to run large O_DIRECT test" && return 0
3678 [ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ] && \
3679 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
3681 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
3682 echo "File size: $F78SIZE"
3683 $SETSTRIPE $DIR/$tfile -c $OSTCOUNT || error "setstripe failed"
3684 for i in `seq 1 $NSEQ`
3686 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
3687 echo directIO rdwr round $i of $NSEQ
3688 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
3693 run_test 78 "handle large O_DIRECT writes correctly ============"
3695 test_79() { # bug 12743
3696 wait_delete_completed
3698 BKTOTAL=$(calc_osc_kbytes kbytestotal)
3699 BKFREE=$(calc_osc_kbytes kbytesfree)
3700 BKAVAIL=$(calc_osc_kbytes kbytesavail)
3702 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
3703 DFTOTAL=`echo $STRING | cut -d, -f1`
3704 DFUSED=`echo $STRING | cut -d, -f2`
3705 DFAVAIL=`echo $STRING | cut -d, -f3`
3706 DFFREE=$(($DFTOTAL - $DFUSED))
3708 ALLOWANCE=$((64 * $OSTCOUNT))
3710 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
3711 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
3712 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
3714 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
3715 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
3716 error "df free($DFFREE) mismatch OST free($BKFREE)"
3718 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
3719 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
3720 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
3723 run_test 79 "df report consistency check ======================="
3725 test_80() { # bug 10718
3726 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
3728 local BEFORE=`date +%s`
3729 cancel_lru_locks osc
3730 local AFTER=`date +%s`
3731 local DIFF=$((AFTER-BEFORE))
3732 if [ $DIFF -gt 1 ] ; then
3733 error "elapsed for 1M@1T = $DIFF"
3738 run_test 80 "Page eviction is equally fast at high offsets too ===="
3741 [ -z "$(which cvs 2>/dev/null)" ] && skip "could not find cvs" && \
3743 mkdir -p $DIR/d99cvsroot
3744 chown $RUNAS_ID $DIR/d99cvsroot
3745 local oldPWD=$PWD # bug 13584, use $TMP as working dir
3748 $RUNAS cvs -d $DIR/d99cvsroot init || error
3751 run_test 99a "cvs init ========================================="
3754 [ -z "$(which cvs 2>/dev/null)" ] && skip "could not find cvs" && return
3755 [ ! -d $DIR/d99cvsroot ] && test_99a
3757 # some versions of cvs import exit(1) when asked to import links or
3758 # files they can't read. ignore those files.
3759 TOIGNORE=$(find . -type l -printf '-I %f\n' -o \
3760 ! -perm +4 -printf '-I %f\n')
3761 $RUNAS cvs -d $DIR/d99cvsroot import -m "nomesg" $TOIGNORE \
3762 d99reposname vtag rtag
3764 run_test 99b "cvs import ======================================="
3767 [ -z "$(which cvs 2>/dev/null)" ] && skip "could not find cvs" && return
3768 [ ! -d $DIR/d99cvsroot ] && test_99b
3770 mkdir -p $DIR/d99reposname
3771 chown $RUNAS_ID $DIR/d99reposname
3772 $RUNAS cvs -d $DIR/d99cvsroot co d99reposname
3774 run_test 99c "cvs checkout ====================================="
3777 [ -z "$(which cvs 2>/dev/null)" ] && skip "could not find cvs" && return
3778 [ ! -d $DIR/d99cvsroot ] && test_99c
3779 cd $DIR/d99reposname
3781 $RUNAS cvs add -m 'addmsg' foo99
3783 run_test 99d "cvs add =========================================="
3786 [ -z "$(which cvs 2>/dev/null)" ] && skip "could not find cvs" && return
3787 [ ! -d $DIR/d99cvsroot ] && test_99c
3788 cd $DIR/d99reposname
3791 run_test 99e "cvs update ======================================="
3794 [ -z "$(which cvs 2>/dev/null)" ] && skip "could not find cvs" && return
3795 [ ! -d $DIR/d99cvsroot ] && test_99d
3796 cd $DIR/d99reposname
3797 $RUNAS cvs commit -m 'nomsg' foo99
3798 rm -fr $DIR/d99cvsroot
3800 run_test 99f "cvs commit ======================================="
3803 [ "$NETTYPE" = tcp ] || \
3804 { skip "TCP secure port test, not useful for NETTYPE=$NETTYPE" && \
3807 remote_ost_nodsh && skip "remote OST with nodsh" && return
3808 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3810 { skip "useless for local single node setup" && return; }
3812 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
3813 [ "$PROT" != "tcp" ] && continue
3814 RPORT=$(echo $REMOTE | cut -d: -f2)
3815 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
3818 LPORT=`echo $LOCAL | cut -d: -f2`
3819 if [ $LPORT -ge 1024 ]; then
3820 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
3822 error_exit "local: $LPORT > 1024, remote: $RPORT"
3825 [ "$rc" = 0 ] || error_exit "privileged port not found" )
3827 run_test 100 "check local port using privileged port ==========="
3829 function get_named_value()
3838 echo $line | sed "s/^$tag//"
3845 export CACHE_MAX=`lctl get_param -n llite.*.max_cached_mb | head -n 1`
3847 lctl set_param -n llite.*.max_cached_mb $CACHE_MAX
3855 [ "$CPU" = "UML" ] && nreads=1000
3856 local cache_limit=32
3858 lctl set_param -n osc.*-osc*.rpc_stats 0
3859 trap cleanup_101 EXIT
3860 lctl set_param -n llite.*.read_ahead_stats 0
3861 lctl set_param -n llite.*.max_cached_mb $cache_limit
3864 # randomly read 10000 of 64K chunks from file 3x 32MB in size
3866 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
3867 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
3870 for s in `lctl get_param -n llite.*.read_ahead_stats | \
3871 get_named_value 'read but discarded' | cut -d" " -f1`; do
3872 discard=$(($discard + $s))
3876 if [ $(($discard * 10)) -gt $nreads ] ;then
3877 lctl get_param osc.*-osc*.rpc_stats
3878 lctl get_param llite.*.read_ahead_stats
3879 error "too many ($discard) discarded pages"
3881 rm -f $DIR/$tfile || true
3883 run_test 101 "check read-ahead for random reads ================"
3885 export SETUP_TEST101=no
3887 [ "$SETUP_TEST101" = "yes" ] && return
3890 STRIPE_COUNT=$OSTCOUNT
3893 trap cleanup_test101 EXIT
3894 # prepare the read-ahead file
3895 $SETSTRIPE $DIR/$tfile -s $STRIPE_SIZE -i $STRIPE_OFFSET -c $OSTCOUNT
3897 dd if=/dev/zero of=$DIR/$tfile bs=1024k count=100 2> /dev/null
3902 [ "$SETUP_TEST101" = "yes" ] || return
3910 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
3915 local STRIPE_SIZE=1048576
3916 local RA_INC=1048576
3917 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
3918 local FILE_LENGTH=$((64*100))
3919 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
3920 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
3921 DISCARD=`$LCTL get_param -n llite.*.read_ahead_stats | \
3922 get_named_value 'read but discarded' | \
3923 cut -d" " -f1 | calc_total`
3925 if [ $DISCARD -gt $discard_limit ]; then
3926 lctl get_param llite.*.read_ahead_stats
3927 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
3929 echo "Read-ahead success for size ${READ_SIZE}"
3934 [ "$OSTCOUNT" -lt "2" ] && skip "skipping stride IO stride-ahead test" && return
3935 local STRIPE_SIZE=1048576
3936 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
3937 local FILE_LENGTH=$((STRIPE_SIZE*100))
3938 local ITERATION=$((FILE_LENGTH/STRIDE_SIZE))
3939 # prepare the read-ahead file
3941 cancel_lru_locks osc
3942 for BIDX in 2 4 8 16 32 64 128 256
3944 local BSIZE=$((BIDX*4096))
3945 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
3946 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
3947 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
3948 $LCTL set_param -n llite.*.read_ahead_stats 0
3949 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
3950 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
3951 cancel_lru_locks osc
3957 run_test 101b "check stride-io mode read-ahead ================="
3960 lctl get_param -n llite.*.max_read_ahead_mb | head -n 1
3961 lctl set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
3965 local file=$DIR/$tfile
3966 local size=${FILESIZE_101c:-500}
3967 local ra_MB=${READAHEAD_MB:-40}
3969 local space=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
3970 [ $space -gt $((size / 1024)) ] ||
3971 { skip "Need free space ${size}M, have $space" && return; }
3973 echo Creating ${size}M test file $file
3974 dd if=/dev/zero of=$file bs=1M count=$size
3975 echo Cancel LRU locks on lustre client to flush the client cache
3976 cancel_lru_locks osc
3978 echo Disable read-ahead
3979 local old_READAHEAD=$(set_read_ahead 0)
3981 echo Reading the test file $file with read-ahead disabled
3982 time_ra_OFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$size")
3984 echo Cancel LRU locks on lustre client to flush the client cache
3985 cancel_lru_locks osc
3986 echo Enable read-ahead with ${ra_MB}MB
3987 set_read_ahead $ra_MB
3989 echo Reading the test file $file with read-ahead enabled
3990 time_ra_ON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$size")
3992 echo read-ahead disabled time read $time_ra_OFF
3993 echo read-ahead enabled time read $time_ra_ON
3995 set_read_ahead $old_READAHEAD
3998 [ $time_ra_ON -lt $time_ra_OFF ] ||
3999 error "read-ahead enabled time read (${time_ra_ON}s) is more than
4000 read-ahead disabled time read (${time_ra_OFF}s) filesize ${size}M"
4002 run_test 101d "file read with and without read-ahead enabled ================="
4004 export SETUP_TEST102=no
4006 [ "$SETUP_TEST102" = "yes" ] && return
4008 chown $RUNAS_ID $DIR/$tdir
4011 STRIPE_COUNT=$OSTCOUNT
4012 [ $OSTCOUNT -gt 4 ] && STRIPE_COUNT=4
4014 trap cleanup_test102 EXIT
4016 $1 $SETSTRIPE $tdir -s $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT
4020 for count in `seq 1 $STRIPE_COUNT`
4022 for offset in `seq 0 $[$STRIPE_COUNT - 1]`
4024 local stripe_size=`expr $STRIPE_SIZE \* $num`
4025 local file=file"$num-$offset-$count"
4026 $1 $SETSTRIPE $file -s $stripe_size -i $offset -c $count
4032 $1 $TAR cf $TMP/f102.tar $tdir --xattrs
4038 [ "$SETUP_TEST102" = "yes" ] || return 0
4044 local testfile=$DIR/xattr_testfile
4049 [ "$UID" != 0 ] && skip "must run as root" && return
4050 [ -z "`lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr`" ] && skip "must have user_xattr" && return
4052 [ -z "$(which setfattr 2>/dev/null)" ] && skip "could not find setfattr" && return
4054 echo "set/get xattr..."
4055 setfattr -n trusted.name1 -v value1 $testfile || error
4056 [ "`getfattr -n trusted.name1 $testfile 2> /dev/null | \
4057 grep "trusted.name1"`" == "trusted.name1=\"value1\"" ] || error
4059 setfattr -n user.author1 -v author1 $testfile || error
4060 [ "`getfattr -n user.author1 $testfile 2> /dev/null | \
4061 grep "user.author1"`" == "user.author1=\"author1\"" ] || error
4064 setfattr -n trusted.name2 -v value2 $testfile || error
4065 setfattr -n trusted.name3 -v value3 $testfile || error
4066 [ `getfattr -d -m "^trusted" $testfile 2> /dev/null | \
4067 grep "trusted.name" | wc -l` -eq 3 ] || error
4070 setfattr -n user.author2 -v author2 $testfile || error
4071 setfattr -n user.author3 -v author3 $testfile || error
4072 [ `getfattr -d -m "^user" $testfile 2> /dev/null | \
4073 grep "user" | wc -l` -eq 3 ] || error
4075 echo "remove xattr..."
4076 setfattr -x trusted.name1 $testfile || error
4077 getfattr -d -m trusted $testfile 2> /dev/null | \
4078 grep "trusted.name1" && error || true
4080 setfattr -x user.author1 $testfile || error
4081 getfattr -d -m user $testfile 2> /dev/null | \
4082 grep "user.author1" && error || true
4084 # b10667: setting lustre special xattr be silently discarded
4085 echo "set lustre special xattr ..."
4086 setfattr -n "trusted.lov" -v "invalid value" $testfile || error
4090 run_test 102a "user xattr test =================================="
4093 # b10930: get/set/list trusted.lov xattr
4094 echo "get/set/list trusted.lov xattr ..."
4095 [ "$OSTCOUNT" -lt "2" ] && skip "skipping 2-stripe test" && return
4096 local testfile=$DIR/$tfile
4097 $SETSTRIPE -s 65536 -i 1 -c 2 $testfile || error "setstripe failed"
4098 getfattr -d -m "^trusted" $testfile 2> /dev/null | \
4099 grep "trusted.lov" || error "can't get trusted.lov from $testfile"
4101 local testfile2=${testfile}2
4102 local value=`getfattr -n trusted.lov $testfile 2> /dev/null | \
4103 grep "trusted.lov" |sed -e 's/[^=]\+=//'`
4106 setfattr -n trusted.lov -v $value $testfile2
4107 local tmp_file=${testfile}3
4108 $GETSTRIPE -v $testfile2 > $tmp_file
4109 local stripe_size=`grep "size" $tmp_file| awk '{print $2}'`
4110 local stripe_count=`grep "count" $tmp_file| awk '{print $2}'`
4111 [ "$stripe_size" -eq 65536 ] || error "stripe size $stripe_size != 65536"
4112 [ "$stripe_count" -eq 2 ] || error "stripe count $stripe_count != 2"
4115 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
4118 # b10930: get/set/list lustre.lov xattr
4119 echo "get/set/list lustre.lov xattr ..."
4120 [ "$OSTCOUNT" -lt "2" ] && skip "skipping 2-stripe test" && return
4122 chown $RUNAS_ID $DIR/$tdir
4123 local testfile=$DIR/$tdir/$tfile
4124 $RUNAS $SETSTRIPE -s 65536 -i 1 -c 2 $testfile||error "setstripe failed"
4125 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
4126 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
4128 local testfile2=${testfile}2
4129 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
4130 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
4132 $RUNAS $MCREATE $testfile2
4133 $RUNAS setfattr -n lustre.lov -v $value $testfile2
4134 local tmp_file=${testfile}3
4135 $RUNAS $GETSTRIPE -v $testfile2 > $tmp_file
4136 local stripe_size=`grep "size" $tmp_file| awk '{print $2}'`
4137 local stripe_count=`grep "count" $tmp_file| awk '{print $2}'`
4138 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
4139 [ $stripe_count -eq 2 ] || error "stripe count $stripe_count != 2"
4141 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
4143 compare_stripe_info1() {
4144 local stripe_index_all_zero=1
4148 for count in `seq 1 $STRIPE_COUNT`
4150 for offset in `seq 0 $[$STRIPE_COUNT - 1]`
4152 local size=`expr $STRIPE_SIZE \* $num`
4153 local file=file"$num-$offset-$count"
4154 get_stripe_info client $PWD/$file "$1"
4155 if [ $stripe_size -ne $size ]; then
4156 error "$file: different stripe size $stripe_size, expected $size" && return
4158 if [ $stripe_count -ne $count ]; then
4159 error "$file: different stripe count $stripe_count, expected $count" && return
4161 if [ $stripe_index -ne 0 ]; then
4162 stripe_index_all_zero=0
4167 [ $stripe_index_all_zero -eq 1 ] && error "all files are being extracted starting from OST index 0"
4171 compare_stripe_info2() {
4174 for count in `seq 1 $STRIPE_COUNT`
4176 for offset in `seq 0 $[$STRIPE_COUNT - 1]`
4178 local size=`expr $STRIPE_SIZE \* $num`
4179 local file=file"$num-$offset-$count"
4180 get_stripe_info client $PWD/$file
4181 if [ $stripe_size -ne $size ]; then
4182 error "$file: different stripe size $stripe_size, expected $size" && return
4184 if [ $stripe_count -ne $count ]; then
4185 error "$file: different stripe count $stripe_count, expected $count" && return
4187 if [ $stripe_index -ne $offset ]; then
4188 error "$file: different stripe offset $stripe_index, expected $offset" && return
4196 [ -n "$(which tar 2>/dev/null)" ] && strings $(which tar) | grep -q lustre && echo tar
4200 # b10930: tar test for trusted.lov xattr
4201 TAR=$(find_lustre_tar)
4202 [ -z "$TAR" ] && skip "lustre-aware tar is not installed" && return
4203 [ "$OSTCOUNT" -lt "2" ] && skip "skipping N-stripe test" && return
4206 $TAR xf $TMP/f102.tar -C $DIR/d102d --xattrs
4208 compare_stripe_info1
4210 run_test 102d "tar restore stripe info from tarfile,not keep osts ==========="
4213 # b10930: tar test for trusted.lov xattr
4214 TAR=$(find_lustre_tar)
4215 [ -z "$TAR" ] && skip "lustre-aware tar is not installed" && return
4216 [ "$OSTCOUNT" -lt "2" ] && skip "skipping N-stripe test" && return
4220 $TAR cf - --xattrs $tdir | $TAR xf - --xattrs -C $DIR/d102f
4222 compare_stripe_info1
4224 run_test 102f "tar copy files, not keep osts ==========="
4226 test_102h() { # bug 15777
4227 [ -z $(lctl get_param -n mdc.*.connect_flags | grep xattr) ] &&
4228 skip "must have user_xattr" && return
4229 [ -z "$(which setfattr 2>/dev/null)" ] &&
4230 skip "could not find setfattr" && return
4235 VALUE=datadatadatadatadatadatadatadata
4236 while [ $(echo $VALUE | wc -c) -lt $XSIZE ]; do
4237 VALUE="$VALUE$VALUE"
4239 log "save $XBIG on $DIR/$tfile"
4240 setfattr -n $XBIG -v "$VALUE" $DIR/$tfile ||
4241 error "saving $XBIG on $DIR/$tfile failed"
4242 ORIG=$(getfattr -n $XBIG $DIR/$tfile 2> /dev/null | grep $XBIG)
4243 OSIZE=$(echo $ORIG | wc -c)
4244 [ $OSIZE -lt $XSIZE ] && error "set $XBIG too small ($OSIZE < $XSIZE)"
4247 log "save $XSML on $DIR/$tfile"
4248 setfattr -n $XSML -v val $DIR/$tfile ||
4249 error "saving $XSML on $DIR/$tfile failed"
4250 NEW=$(getfattr -n $XBIG $DIR/$tfile 2> /dev/null | grep $XBIG)
4251 if [ "$NEW" != "$ORIG" ]; then
4254 error "$XBIG different after saving $XSML"
4257 log "grow $XSML on $DIR/$tfile"
4258 setfattr -n $XSML -v "$VALUE" $DIR/$tfile ||
4259 error "growing $XSML on $DIR/$tfile failed"
4260 NEW=$(getfattr -n $XBIG $DIR/$tfile 2> /dev/null | grep $XBIG)
4261 if [ "$NEW" != "$ORIG" ]; then
4264 error "$XBIG different after growing $XSML"
4266 log "$XBIG still valid after growing $XSML"
4269 run_test 102h "grow xattr from inside inode to external block"
4271 test_102i() { # bug 17038
4273 ln -s $DIR/$tfile $DIR/${tfile}link
4274 getfattr -n trusted.lov $DIR/$tfile || error "lgetxattr on $DIR/$tfile failed"
4275 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"
4276 rm -f $DIR/$tfile $DIR/${tfile}link
4278 run_test 102i "lgetxattr test on symbolic link ============"
4281 TAR=$(find_lustre_tar)
4282 [ -z "$TAR" ] && skip "lustre-aware tar is not installed" && return
4283 [ "$OSTCOUNT" -lt "2" ] && skip "skipping N-stripe test" && return
4284 setup_test102 "$RUNAS"
4286 chown $RUNAS_ID $DIR/d102j
4287 $RUNAS $TAR xf $TMP/f102.tar -C $DIR/d102j --xattrs
4289 compare_stripe_info1 "$RUNAS"
4291 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
4297 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
4302 [ "$UID" != 0 ] && skip "must run as root" && return
4303 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
4304 [ -z "$(which setfacl 2>/dev/null)" ] && skip "could not find setfacl" && return
4305 $GSS && skip "could not run under gss" && return
4307 declare -a identity_old
4309 for num in `seq $MDSCOUNT`; do
4310 switch_identity $num true || identity_old[$num]=$?
4317 echo "performing cp ..."
4318 run_acl_subtest cp || error
4319 echo "performing getfacl-noacl..."
4320 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
4321 echo "performing misc..."
4322 run_acl_subtest misc || error "misc test failed"
4323 echo "performing permissions..."
4324 run_acl_subtest permissions || error "permissions failed"
4325 echo "performing setfacl..."
4326 run_acl_subtest setfacl || error "setfacl test failed"
4328 # inheritance test got from HP
4329 echo "performing inheritance..."
4330 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
4331 chmod +x make-tree || error "chmod +x failed"
4332 run_acl_subtest inheritance || error "inheritance test failed"
4338 for num in `seq $MDSCOUNT`; do
4339 if [ "${identity_old[$num]}" = 1 ]; then
4340 switch_identity $num false || identity_old[$num]=$?
4344 run_test 103 "acl test ========================================="
4348 lfs df || error "lfs df failed"
4349 lfs df -ih || error "lfs df -ih failed"
4350 lfs df -h $DIR || error "lfs df -h $DIR failed"
4351 lfs df -i $DIR || error "lfs df -i $DIR failed"
4352 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
4353 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
4355 OSC=`lctl get_param -n devices | awk '/-osc-/ {print $4}' | head -n 1`
4356 lctl --device %$OSC deactivate
4357 lfs df || error "lfs df with deactivated OSC failed"
4358 lctl --device %$OSC recover
4359 lfs df || error "lfs df with reactivated OSC failed"
4362 run_test 104 "lfs df [-ih] [path] test ========================="
4365 # doesn't work on 2.4 kernels
4367 if [ -n "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ];
4369 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
4371 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
4375 run_test 105a "flock when mounted without -o flock test ========"
4379 if [ -n "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ];
4381 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
4383 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
4387 run_test 105b "fcntl when mounted without -o flock test ========"
4391 if [ -n "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ];
4393 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
4395 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
4399 run_test 105c "lockf when mounted without -o flock test ========"
4401 test_105d() { # bug 15924
4403 [ -z "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ] && \
4404 skip "mount w/o flock enabled" && return
4405 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
4406 $LCTL set_param fail_loc=0x80000315
4407 flocks_test 2 $DIR/$tdir
4409 run_test 105d "flock race (should not freeze) ========"
4411 test_106() { #bug 10921
4413 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
4414 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
4416 run_test 106 "attempt exec of dir followed by chown of that dir"
4425 local save_pattern=$(sysctl -n kernel.core_pattern)
4426 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
4427 sysctl -w kernel.core_pattern=$file
4428 sysctl -w kernel.core_uses_pid=0
4436 kill -s 11 $SLEEPPID
4438 if [ -e $file ]; then
4439 size=`stat -c%s $file`
4440 [ $size -eq 0 ] && error "Fail to create core file $file"
4442 error "Fail to create core file $file"
4445 sysctl -w kernel.core_pattern=$save_pattern
4446 sysctl -w kernel.core_uses_pid=$save_uses_pid
4449 run_test 107 "Coredump on SIG"
4453 mkdir $DIR/d110/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa || error "mkdir with 255 char fail"
4454 mkdir $DIR/d110/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb && error "mkdir with 256 char should fail, but not"
4455 touch $DIR/d110/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx || error "create with 255 char fail"
4456 touch $DIR/d110/yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy && error ""create with 256 char should fail, but not
4461 run_test 110 "filename length checking"
4464 OSTIO_pre=$(ps -e|grep ll_ost_io|awk '{print $4}'|sort -n|tail -1|\
4466 [ -z "$OSTIO_pre" ] && skip "no OSS threads" && \
4468 echo "Starting with $OSTIO_pre threads"
4471 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
4472 [ $NUMFREE -lt $NUMTEST ] && NUMTEST=$(($NUMFREE - 1000))
4473 echo "$NUMTEST creates/unlinks"
4475 createmany -o $DIR/$tdir/$tfile $NUMTEST
4476 unlinkmany $DIR/$tdir/$tfile $NUMTEST
4478 OSTIO_post=$(ps -e|grep ll_ost_io|awk '{print $4}'|sort -n|tail -1|\
4481 # don't return an error
4482 [ $OSTIO_post -eq $OSTIO_pre ] && echo \
4483 "WARNING: No new ll_ost_io threads were created ($OSTIO_pre)" &&\
4484 echo "This may be fine, depending on what ran before this test" &&\
4485 echo "and how fast this system is." && return
4487 echo "Started with $OSTIO_pre threads, ended with $OSTIO_post"
4489 run_test 115 "verify dynamic thread creation===================="
4492 wait_delete_completed
4493 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
4494 echo OST kbytes available: ${AVAIL[@]}
4495 MAXI=0; MAXV=${AVAIL[0]}
4496 MINI=0; MINV=${AVAIL[0]}
4497 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
4498 #echo OST $i: ${AVAIL[i]}kb
4499 if [ ${AVAIL[i]} -gt $MAXV ]; then
4500 MAXV=${AVAIL[i]}; MAXI=$i
4502 if [ ${AVAIL[i]} -lt $MINV ]; then
4503 MINV=${AVAIL[i]}; MINI=$i
4506 echo Min free space: OST $MINI: $MINV
4507 echo Max free space: OST $MAXI: $MAXV
4511 [ "$OSTCOUNT" -lt "2" ] && skip "$OSTCOUNT < 2 OSTs" && return
4513 echo -n "Free space priority "
4514 lctl get_param -n lov.*-clilov-*.qos_prio_free
4515 DELAY=$(lctl get_param -n lov.*-clilov-*.qos_maxage | head -1 | awk '{print $1}')
4518 [ $MINV -gt 960000 ] && skip "too much free space in OST$MINI, skip" &&\
4521 # generate uneven OSTs
4522 mkdir -p $DIR/$tdir/OST${MINI}
4525 echo "Filling 25% remaining space in OST${MINI} with ${FILL}Kb"
4526 $SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI}||error "setstripe failed"
4528 while [ $FILL -gt 0 ]; do
4530 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i bs=2M count=1 2>/dev/null
4531 FILL=$(($FILL - 2048))
4539 DIFF=$(($MAXV - $MINV))
4540 DIFF2=$(($DIFF * 100 / $MINV))
4541 echo -n "diff=${DIFF}=${DIFF2}% must be > 20% for QOS mode..."
4542 if [ $DIFF2 -gt 20 ]; then
4545 echo "failed - QOS mode won't be used"
4546 error_ignore "QOS imbalance criteria not met"
4550 MINI1=$MINI; MINV1=$MINV
4551 MAXI1=$MAXI; MAXV1=$MAXV
4553 # now fill using QOS
4554 echo writing a bunch of files to QOS-assigned OSTs
4555 $SETSTRIPE $DIR/$tdir -c 1
4557 while [ $FILL -gt 0 ]; do
4559 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1024 count=200 2>/dev/null
4560 FILL=$(($FILL - 200))
4563 echo "wrote $i 200k files"
4567 echo "Note: free space may not be updated, so measurements might be off"
4569 DIFF2=$(($MAXV - $MINV))
4570 echo "free space delta: orig $DIFF final $DIFF2"
4571 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
4572 DIFF=$(($MINV1 - ${AVAIL[$MINI1]}))
4573 echo "Wrote $DIFF to smaller OST $MINI1"
4574 DIFF2=$(($MAXV1 - ${AVAIL[$MAXI1]}))
4575 echo "Wrote $DIFF2 to larger OST $MAXI1"
4576 [ $DIFF -gt 0 ] && echo "Wrote $(($DIFF2 * 100 / $DIFF - 100))% more data to larger OST $MAXI1"
4578 # Figure out which files were written where
4579 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
4580 awk '/'$MINI1': / {print $2; exit}')
4582 MINC=$($GETSTRIPE --obd $UUID $DIR/$tdir | wc -l)
4583 echo "$MINC files created on smaller OST $MINI1"
4584 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
4585 awk '/'$MAXI1': / {print $2; exit}')
4587 MAXC=$($GETSTRIPE --obd $UUID $DIR/$tdir | wc -l)
4588 echo "$MAXC files created on larger OST $MAXI1"
4589 [ $MINC -gt 0 ] && echo "Wrote $(($MAXC * 100 / $MINC - 100))% more files to larger OST $MAXI1"
4590 [ $MAXC -gt $MINC ] || error_ignore "stripe QOS didn't balance free space"
4592 rm -rf $DIR/$tdir/OST${MINI}
4594 run_test 116 "stripe QOS: free space balance ==================="
4596 test_117() # bug 10891
4598 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
4599 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
4600 lctl set_param fail_loc=0x21e
4601 > $DIR/$tfile || error "truncate failed"
4602 lctl set_param fail_loc=0
4603 echo "Truncate succeeded."
4606 run_test 117 "verify fsfilt_extend =========="
4608 export OLD_RESENDCOUNT=""
4609 set_resend_count () {
4610 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
4611 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -1)
4612 lctl set_param -n $PROC_RESENDCOUNT $1
4613 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
4616 [ "$SLOW" = "no" ] && set_resend_count 4 # for reduce test_118* time (bug 14842)
4618 # Reset async IO behavior after error case
4620 FILE=$DIR/reset_async
4622 # Ensure all OSCs are cleared
4623 $LSTRIPE -c -1 $FILE
4624 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
4629 test_118a() #bug 11710
4633 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
4634 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
4635 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
4637 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
4638 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
4643 run_test 118a "verify O_SYNC works =========="
4647 remote_ost_nodsh && skip "remote OST with nodsh" && return
4651 #define OBD_FAIL_OST_ENOENT 0x217
4652 set_nodes_failloc "$(osts_nodes)" 0x217
4653 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
4655 set_nodes_failloc "$(osts_nodes)" 0
4656 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
4657 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
4660 if [[ $RC -eq 0 ]]; then
4661 error "Must return error due to dropped pages, rc=$RC"
4665 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
4666 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
4670 echo "Dirty pages not leaked on ENOENT"
4672 # Due to the above error the OSC will issue all RPCs syncronously
4673 # until a subsequent RPC completes successfully without error.
4674 multiop $DIR/$tfile Ow4096yc
4679 run_test 118b "Reclaim dirty pages on fatal error =========="
4683 remote_ost_nodsh && skip "remote OST with nodsh" && return
4687 #define OBD_FAIL_OST_EROFS 0x216
4688 set_nodes_failloc "$(osts_nodes)" 0x216
4690 # multiop should block due to fsync until pages are written
4691 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
4695 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
4696 error "Multiop failed to block on fsync, pid=$MULTIPID"
4699 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
4701 if [[ $WRITEBACK -eq 0 ]]; then
4702 error "No page in writeback, writeback=$WRITEBACK"
4705 set_nodes_failloc "$(osts_nodes)" 0
4708 if [[ $RC -ne 0 ]]; then
4709 error "Multiop fsync failed, rc=$RC"
4712 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
4713 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
4715 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
4716 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
4720 echo "Dirty pages flushed via fsync on EROFS"
4723 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
4727 remote_ost_nodsh && skip "remote OST with nodsh" && return
4731 #define OBD_FAIL_OST_BRW_PAUSE_BULK
4732 set_nodes_failloc "$(osts_nodes)" 0x214
4733 # multiop should block due to fsync until pages are written
4734 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
4738 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
4739 error "Multiop failed to block on fsync, pid=$MULTIPID"
4742 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
4744 if [[ $WRITEBACK -eq 0 ]]; then
4745 error "No page in writeback, writeback=$WRITEBACK"
4748 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
4749 set_nodes_failloc "$(osts_nodes)" 0
4751 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
4752 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
4754 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
4755 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
4759 echo "Dirty pages gaurenteed flushed via fsync"
4762 run_test 118d "Fsync validation inject a delay of the bulk =========="
4767 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
4768 lctl set_param fail_loc=0x8000040a
4770 # Should simulate EINVAL error which is fatal
4771 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
4773 if [[ $RC -eq 0 ]]; then
4774 error "Must return error due to dropped pages, rc=$RC"
4777 lctl set_param fail_loc=0x0
4779 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
4780 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
4781 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
4783 if [[ $LOCKED -ne 0 ]]; then
4784 error "Locked pages remain in cache, locked=$LOCKED"
4787 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
4788 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
4792 echo "No pages locked after fsync"
4797 run_test 118f "Simulate unrecoverable OSC side error =========="
4802 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
4803 lctl set_param fail_loc=0x406
4805 # simulate local -ENOMEM
4806 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
4809 lctl set_param fail_loc=0
4810 if [[ $RC -eq 0 ]]; then
4811 error "Must return error due to dropped pages, rc=$RC"
4814 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
4815 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
4816 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
4818 if [[ $LOCKED -ne 0 ]]; then
4819 error "Locked pages remain in cache, locked=$LOCKED"
4822 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
4823 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
4827 echo "No pages locked after fsync"
4832 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
4835 remote_ost_nodsh && skip "remote OST with nodsh" && return
4839 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
4840 set_nodes_failloc "$(osts_nodes)" 0x20e
4841 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
4842 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
4845 set_nodes_failloc "$(osts_nodes)" 0
4846 if [[ $RC -eq 0 ]]; then
4847 error "Must return error due to dropped pages, rc=$RC"
4850 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
4851 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
4852 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
4854 if [[ $LOCKED -ne 0 ]]; then
4855 error "Locked pages remain in cache, locked=$LOCKED"
4858 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
4859 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
4863 echo "No pages locked after fsync"
4867 run_test 118h "Verify timeout in handling recoverables errors =========="
4870 remote_ost_nodsh && skip "remote OST with nodsh" && return
4874 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
4875 set_nodes_failloc "$(osts_nodes)" 0x20e
4877 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
4878 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
4881 set_nodes_failloc "$(osts_nodes)" 0
4885 if [[ $RC -ne 0 ]]; then
4886 error "got error, but should be not, rc=$RC"
4889 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
4890 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
4891 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
4892 if [[ $LOCKED -ne 0 ]]; then
4893 error "Locked pages remain in cache, locked=$LOCKED"
4896 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
4897 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
4901 echo "No pages locked after fsync"
4905 run_test 118i "Fix error before timeout in recoverable error =========="
4908 remote_ost_nodsh && skip "remote OST with nodsh" && return
4912 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
4913 set_nodes_failloc "$(osts_nodes)" 0x220
4915 # return -EIO from OST
4916 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
4918 set_nodes_failloc "$(osts_nodes)" 0x0
4919 if [[ $RC -eq 0 ]]; then
4920 error "Must return error due to dropped pages, rc=$RC"
4923 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
4924 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
4925 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
4926 if [[ $LOCKED -ne 0 ]]; then
4927 error "Locked pages remain in cache, locked=$LOCKED"
4930 # in recoverable error on OST we want resend and stay until it finished
4931 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
4932 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
4936 echo "No pages locked after fsync"
4940 run_test 118j "Simulate unrecoverable OST side error =========="
4944 remote_ost_nodsh && skip "remote OSTs with nodsh" && return
4946 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
4947 set_nodes_failloc "$(osts_nodes)" 0x20e
4950 for ((i=0;i<10;i++)); do
4951 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
4952 error "dd to $DIR/$tdir/$tfile-$i failed" )&
4959 set_nodes_failloc "$(osts_nodes)" 0
4961 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
4963 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
4965 test_119a() # bug 11737
4967 BSIZE=$((512 * 1024))
4968 directio write $DIR/$tfile 0 1 $BSIZE
4969 # We ask to read two blocks, which is more than a file size.
4970 # directio will indicate an error when requested and actual
4971 # sizes aren't equeal (a normal situation in this case) and
4972 # print actual read amount.
4973 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
4974 if [ "$NOB" != "$BSIZE" ]; then
4975 error "read $NOB bytes instead of $BSIZE"
4979 run_test 119a "Short directIO read must return actual read amount"
4981 test_119b() # bug 11737
4983 [ "$OSTCOUNT" -lt "2" ] && skip "skipping 2-stripe test" && return
4985 $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
4986 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
4988 multiop $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) || \
4989 error "direct read failed"
4992 run_test 119b "Sparse directIO read must return actual read amount"
4994 test_119c() # bug 13099
4997 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
4998 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
5001 run_test 119c "Testing for direct read hitting hole"
5003 test_119d() # bug 15950
5005 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
5006 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
5008 $SETSTRIPE $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
5009 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
5010 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
5011 lctl set_param fail_loc=0x40d
5012 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
5015 cat $DIR/$tfile > /dev/null &
5016 lctl set_param fail_loc=0
5019 log "the DIO writes have completed, now wait for the reads (should not block very long)"
5021 [ -n "`ps h -p $pid_reads -o comm`" ] && \
5022 error "the read rpcs have not completed in 2s"
5024 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
5026 run_test 119d "The DIO path should try to send a new rpc once one is completed"
5030 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
5031 skip "no early lock cancel on server" && return 0
5032 lru_resize_disable mdc
5033 lru_resize_disable osc
5034 cancel_lru_locks mdc
5035 stat $DIR/$tdir > /dev/null
5036 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
5037 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
5039 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
5040 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
5041 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
5042 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
5043 lru_resize_enable mdc
5044 lru_resize_enable osc
5046 run_test 120a "Early Lock Cancel: mkdir test"
5050 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
5051 skip "no early lock cancel on server" && return 0
5052 lru_resize_disable mdc
5053 lru_resize_disable osc
5054 cancel_lru_locks mdc
5055 stat $DIR/$tdir > /dev/null
5056 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
5057 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
5059 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
5060 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
5061 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
5062 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
5063 lru_resize_enable mdc
5064 lru_resize_enable osc
5066 run_test 120b "Early Lock Cancel: create test"
5070 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
5071 skip "no early lock cancel on server" && return 0
5072 lru_resize_disable mdc
5073 lru_resize_disable osc
5074 mkdir -p $DIR/$tdir/d1 $DIR/$tdir/d2
5075 touch $DIR/$tdir/d1/f1
5076 cancel_lru_locks mdc
5077 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
5078 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
5079 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
5080 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
5081 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
5082 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
5083 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
5084 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
5085 lru_resize_enable mdc
5086 lru_resize_enable osc
5088 run_test 120c "Early Lock Cancel: link test"
5092 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
5093 skip "no early lock cancel on server" && return 0
5094 lru_resize_disable mdc
5095 lru_resize_disable osc
5097 cancel_lru_locks mdc
5098 stat $DIR/$tdir > /dev/null
5099 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
5100 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
5101 chmod a+x $DIR/$tdir
5102 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
5103 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
5104 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
5105 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
5106 lru_resize_enable mdc
5107 lru_resize_enable osc
5109 run_test 120d "Early Lock Cancel: setattr test"
5113 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
5114 skip "no early lock cancel on server" && return 0
5115 lru_resize_disable mdc
5116 lru_resize_disable osc
5117 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
5118 cancel_lru_locks mdc
5119 cancel_lru_locks osc
5120 dd if=$DIR/$tdir/f1 of=/dev/null
5121 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
5122 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
5123 awk '/ldlm_cancel/ {print $2}'`
5124 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
5125 awk '/ldlm_bl_callback/ {print $2}'`
5126 unlink $DIR/$tdir/f1
5127 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
5128 awk '/ldlm_cancel/ {print $2}'`
5129 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
5130 awk '/ldlm_bl_callback/ {print $2}'`
5131 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
5132 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
5133 lru_resize_enable mdc
5134 lru_resize_enable osc
5136 run_test 120e "Early Lock Cancel: unlink test"
5139 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
5140 skip "no early lock cancel on server" && return 0
5142 lru_resize_disable mdc
5143 lru_resize_disable osc
5144 mkdir -p $DIR/$tdir/d1 $DIR/$tdir/d2
5145 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
5146 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
5147 cancel_lru_locks mdc
5148 cancel_lru_locks osc
5149 dd if=$DIR/$tdir/d1/f1 of=/dev/null
5150 dd if=$DIR/$tdir/d2/f2 of=/dev/null
5151 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
5152 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
5153 awk '/ldlm_cancel/ {print $2}'`
5154 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
5155 awk '/ldlm_bl_callback/ {print $2}'`
5156 mv $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
5157 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
5158 awk '/ldlm_cancel/ {print $2}'`
5159 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
5160 awk '/ldlm_bl_callback/ {print $2}'`
5161 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
5162 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
5163 lru_resize_enable mdc
5164 lru_resize_enable osc
5166 run_test 120f "Early Lock Cancel: rename test"
5169 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
5170 skip "no early lock cancel on server" && return 0
5171 lru_resize_disable mdc
5172 lru_resize_disable osc
5174 echo create $count files
5176 cancel_lru_locks mdc
5177 cancel_lru_locks osc
5180 can0=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
5181 awk '/ldlm_cancel/ {print $2}'`
5182 blk0=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
5183 awk '/ldlm_bl_callback/ {print $2}'`
5184 createmany -o $DIR/$tdir/f $count
5186 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
5187 awk '/ldlm_cancel/ {print $2}'`
5188 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
5189 awk '/ldlm_bl_callback/ {print $2}'`
5191 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
5192 echo rm $count files
5195 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
5196 awk '/ldlm_cancel/ {print $2}'`
5197 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
5198 awk '/ldlm_bl_callback/ {print $2}'`
5200 echo total: $count removes in $((t2-t1))
5201 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
5203 # wait for commitment of removal
5204 lru_resize_enable mdc
5205 lru_resize_enable osc
5207 run_test 120g "Early Lock Cancel: performance test"
5209 test_121() { #bug #10589
5211 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out/ {print $1}')
5212 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
5213 lctl set_param fail_loc=0x310
5214 cancel_lru_locks osc > /dev/null
5215 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in/ {print $1}')
5216 lctl set_param fail_loc=0
5217 [ "$reads" -eq "$writes" ] || error "read" $reads "blocks, must be" $writes
5219 run_test 121 "read cancel race ========="
5221 test_123a() { # was test 123, statahead(bug 11401)
5223 if [ -z "$(grep "processor.*: 1" /proc/cpuinfo)" ]; then
5224 log "testing on UP system. Performance may be not as good as expected."
5230 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
5231 [ $NUMFREE -gt 100000 ] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
5233 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
5234 createmany -o $DIR/$tdir/$tfile $j $((i - j))
5236 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
5237 lctl set_param -n llite.*.statahead_max 0
5238 lctl get_param llite.*.statahead_max
5239 cancel_lru_locks mdc
5240 cancel_lru_locks osc
5242 time ls -l $DIR/$tdir | wc -l
5244 delta=$((etime - stime))
5245 log "ls $i files without statahead: $delta sec"
5246 lctl set_param llite.*.statahead_max=$max
5248 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
5249 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
5250 cancel_lru_locks mdc
5251 cancel_lru_locks osc
5253 time ls -l $DIR/$tdir | wc -l
5255 delta_sa=$((etime - stime))
5256 log "ls $i files with statahead: $delta_sa sec"
5257 lctl get_param -n llite.*.statahead_stats
5258 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
5260 if [ $swrong -lt $ewrong ]; then
5261 log "statahead was stopped, maybe too many locks held!"
5264 [ $delta -eq 0 -o $delta_sa -eq 0 ] && continue
5266 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
5267 if [ $SLOWOK -eq 0 ]; then
5268 error "ls $i files is slower with statahead!"
5271 lctl set_param debug=-1
5272 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
5273 lctl set_param -n llite.*.statahead_max 0
5274 lctl get_param llite.*.statahead_max
5275 cancel_lru_locks mdc
5276 cancel_lru_locks osc
5279 time ls -l $DIR/$tdir | wc -l
5281 error "ls $i files (again) without statahead: $((etime - stime)) sec"
5283 lctl set_param debug=-1
5284 lctl set_param llite.*.statahead_max=$max
5285 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
5286 cancel_lru_locks mdc
5287 cancel_lru_locks osc
5290 time ls -l $DIR/$tdir | wc -l
5292 error "ls $i files (again) with statahead: $((etime - stime)) sec"
5293 lctl get_param -n llite.*.statahead_stats
5297 log "ls $i files is slower with statahead!"
5302 [ $delta -gt 20 ] && break
5303 [ $delta -gt 8 ] && MULT=$((50 / delta))
5304 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
5312 delta=$((etime - stime))
5313 log "rm -r $DIR/$tdir/: $delta seconds"
5315 lctl get_param -n llite.*.statahead_stats
5317 run_test 123a "verify statahead work"
5319 test_123b () { # statahead(bug 15027)
5321 createmany -o $DIR/$tdir/$tfile-%d 1000
5323 cancel_lru_locks mdc
5324 cancel_lru_locks osc
5326 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
5327 lctl set_param fail_loc=0x80000803
5328 ls -lR $DIR/$tdir > /dev/null
5330 lctl set_param fail_loc=0x0
5331 lctl get_param -n llite.*.statahead_stats
5336 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
5339 [ -z "`lctl get_param -n mdc.*.connect_flags | grep lru_resize`" ] && \
5340 skip "no lru resize on server" && return 0
5342 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
5344 log "create $NR files at $DIR/$tdir"
5345 createmany -o $DIR/$tdir/f $NR ||
5346 error "failed to create $NR files in $DIR/$tdir"
5348 cancel_lru_locks mdc
5349 ls -l $DIR/$tdir > /dev/null
5353 for VALUE in `lctl get_param ldlm.namespaces.*mdc-*.lru_size`; do
5354 local PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
5355 LRU_SIZE=$(lctl get_param -n $PARAM)
5356 if [ $LRU_SIZE -gt $(default_lru_size) ]; then
5357 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
5358 log "NS=$(basename $NSDIR)"
5363 if [ -z "$NSDIR" -o $LRU_SIZE -lt $(default_lru_size) ]; then
5364 skip "Not enough cached locks created!"
5371 # We know that lru resize allows one client to hold $LIMIT locks
5372 # for 10h. After that locks begin to be killed by client.
5374 local LIMIT=`lctl get_param -n $NSDIR.pool.limit`
5376 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
5377 # killing locks. Some time was spent for creating locks. This means
5378 # that up to the moment of sleep finish we must have killed some of
5379 # them (10-100 locks). This depends on how fast ther were created.
5380 # Many of them were touched in almost the same moment and thus will
5381 # be killed in groups.
5382 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
5384 # Use $LRU_SIZE_B here to take into account real number of locks
5385 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
5386 local LRU_SIZE_B=$LRU_SIZE
5388 local OLD_LVF=`lctl get_param -n $NSDIR.pool.lock_volume_factor`
5389 lctl set_param -n $NSDIR.pool.lock_volume_factor $LVF
5391 # Let's make sure that we really have some margin. Client checks
5392 # cached locks every 10 sec.
5394 log "Sleep ${SLEEP} sec"
5396 while ((SEC<$SLEEP)); do
5400 LRU_SIZE=`lctl get_param -n $NSDIR/lru_size`
5404 lctl set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
5405 local LRU_SIZE_A=`lctl get_param -n $NSDIR/lru_size`
5407 [ $LRU_SIZE_B -gt $LRU_SIZE_A ] || {
5408 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
5409 unlinkmany $DIR/$tdir/f $NR
5413 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
5414 log "unlink $NR files at $DIR/$tdir"
5415 unlinkmany $DIR/$tdir/f $NR
5417 run_test 124a "lru resize ======================================="
5419 get_max_pool_limit()
5421 local limit=`lctl get_param -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit`
5424 if test $l -gt $max; then
5432 [ -z "`lctl get_param -n mdc.*.connect_flags | grep lru_resize`" ] && \
5433 skip "no lru resize on server" && return 0
5435 LIMIT=`get_max_pool_limit`
5437 NR=$(($(default_lru_size)*20))
5438 if [ $NR -gt $LIMIT ]; then
5439 log "Limit lock number by $LIMIT locks"
5442 lru_resize_disable mdc
5443 mkdir -p $DIR/$tdir/disable_lru_resize ||
5444 error "failed to create $DIR/$tdir/disable_lru_resize"
5446 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
5447 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
5448 cancel_lru_locks mdc
5451 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
5454 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
5457 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
5461 nolruresize_delta=$((etime-stime))
5462 log "ls -la time: $nolruresize_delta seconds"
5463 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
5464 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
5466 lru_resize_enable mdc
5467 mkdir -p $DIR/$tdir/enable_lru_resize ||
5468 error "failed to create $DIR/$tdir/enable_lru_resize"
5470 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
5471 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
5472 cancel_lru_locks mdc
5475 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
5478 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
5481 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
5485 lruresize_delta=$((etime-stime))
5486 log "ls -la time: $lruresize_delta seconds"
5487 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
5489 if [ $lruresize_delta -gt $nolruresize_delta ]; then
5490 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
5491 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
5492 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
5494 log "lru resize performs the same with no lru resize"
5496 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
5498 run_test 124b "lru resize (performance test) ======================="
5500 test_125() { # 13358
5501 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
5502 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
5503 mkdir -p $DIR/d125 || error "mkdir failed"
5504 $SETSTRIPE $DIR/d125 -s 65536 -c -1 || error "setstripe failed"
5505 setfacl -R -m u:bin:rwx $DIR/d125 || error "setfacl $DIR/d125 failed"
5506 ls -ld $DIR/d125 || error "cannot access $DIR/d125"
5508 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
5510 test_126() { # bug 12829/13455
5511 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
5512 [ "$UID" != 0 ] && echo "skipping $TESTNAME (must run as root)" && return
5513 $GSS && skip "must run as gss disabled" && return
5515 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
5516 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
5518 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
5520 run_test 126 "check that the fsgid provided by the client is taken into account"
5522 test_127() { # bug 15521
5523 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
5524 $LCTL set_param osc.*.stats=0
5525 FSIZE=$((2048 * 1024))
5526 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
5527 cancel_lru_locks osc
5528 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
5530 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
5531 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
5532 echo "got $COUNT $NAME"
5533 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
5534 eval $NAME=$COUNT || error "Wrong proc format"
5537 read_bytes|write_bytes)
5538 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
5539 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
5540 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
5541 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
5542 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
5543 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
5544 error "sumsquare is too small: $SUMSQ"
5545 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
5546 error "sumsquare is too big: $SUMSQ"
5550 done < $DIR/${tfile}.tmp
5552 #check that we actually got some stats
5553 [ "$read_bytes" ] || error "Missing read_bytes stats"
5554 [ "$write_bytes" ] || error "Missing write_bytes stats"
5555 [ "$read_bytes" != 0 ] || error "no read done"
5556 [ "$write_bytes" != 0 ] || error "no write done"
5558 run_test 127 "verify the client stats are sane"
5560 test_128() { # bug 15212
5562 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
5567 result=$(grep error $TMP/$tfile.log)
5569 [ -z "$result" ] || error "consecutive find's under interactive lfs failed"
5571 run_test 128 "interactive lfs for 2 consecutive find's"
5577 local LDPROC=/proc/fs/ldiskfs
5579 for node in $(mdts_nodes); do
5580 devs=$(do_node $node "lctl get_param -n devices" | awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }')
5581 for dev in $devs; do
5582 mntdev=$(do_node $node "lctl get_param -n osd.$dev.mntdev")
5583 do_node $node "echo $1 >$LDPROC/\\\$(basename $mntdev)/max_dir_size"
5588 [ "$FSTYPE" != "ldiskfs" ] && skip "not needed for FSTYPE=$FSTYPE" && return 0
5589 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5600 while [ ! $I -gt $((MAX * MDSCOUNT)) ]; do
5601 multiop $DIR/$tdir/$J Oc
5603 if [ $rc -eq $EFBIG ]; then
5605 echo "return code $rc received as expected"
5607 elif [ $rc -ne 0 ]; then
5609 error_exit "return code $rc received instead of expected $EFBIG"
5612 I=$(stat -c%s "$DIR/$tdir")
5615 error "exceeded dir size limit $MAX x $MDSCOUNT $((MAX * MDSCOUNT)) : $I bytes"
5616 do_facet $SINGLEMDS "echo 0 >$LDPROC"
5618 run_test 129 "test directory size limit ========================"
5627 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
5628 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
5630 trap cleanup_130 EXIT RETURN
5632 local fm_file=$DIR/$tfile
5633 lfs setstripe -s 65536 -c 1 $fm_file || error "setstripe failed on $fm_file"
5634 dd if=/dev/zero of=$fm_file bs=65536 count=1 || error "dd failed for $fm_file"
5636 filefrag -ves $fm_file || error "filefrag $fm_file failed"
5637 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
5639 lun=`$GETSTRIPE $fm_file | grep -A 10 obdidx | awk '{print $1}' | grep -v "obdidx"`
5641 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
5644 for line in $filefrag_op
5646 frag_lun=`echo $line | cut -d: -f5`
5647 ext_len=`echo $line | cut -d: -f4`
5648 if (( $frag_lun != $lun )); then
5650 error "FIEMAP on 1-stripe file($fm_file) failed"
5653 (( tot_len += ext_len ))
5656 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
5658 error "FIEMAP on 1-stripe file($fm_file) failed;"
5664 echo "FIEMAP on single striped file succeeded"
5666 run_test 130a "FIEMAP (1-stripe file)"
5669 [ "$OSTCOUNT" -lt "2" ] && skip "skipping FIEMAP on 2-stripe file test" && return
5671 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
5672 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
5674 trap cleanup_130 EXIT RETURN
5676 local fm_file=$DIR/$tfile
5677 lfs setstripe -s 65536 -c 2 $fm_file || error "setstripe failed on $fm_file"
5678 dd if=/dev/zero of=$fm_file bs=1M count=2 || error "dd failed on $fm_file"
5680 filefrag -ves $fm_file || error "filefrag $fm_file failed"
5681 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
5683 last_lun=`echo $filefrag_op | cut -d: -f5`
5688 for line in $filefrag_op
5690 frag_lun=`echo $line | cut -d: -f5`
5691 ext_len=`echo $line | cut -d: -f4`
5692 if (( $frag_lun != $last_lun )); then
5693 if (( tot_len != 1024 )); then
5695 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 256"
5702 (( tot_len += ext_len ))
5705 if (( num_luns != 2 || tot_len != 1024 )); then
5707 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
5713 echo "FIEMAP on 2-stripe file succeeded"
5715 run_test 130b "FIEMAP (2-stripe file)"
5718 [ "$OSTCOUNT" -lt "2" ] && skip "skipping FIEMAP on 2-stripe file with hole test" && return
5720 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
5721 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
5723 trap cleanup_130 EXIT RETURN
5725 local fm_file=$DIR/$tfile
5726 lfs setstripe -s 65536 -c 2 $fm_file || error "setstripe failed on $fm_file"
5727 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 || error "dd failed on $fm_file"
5729 filefrag -ves $fm_file || error "filefrag $fm_file failed"
5730 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
5732 last_lun=`echo $filefrag_op | cut -d: -f5`
5737 for line in $filefrag_op
5739 frag_lun=`echo $line | cut -d: -f5`
5740 ext_len=`echo $line | cut -d: -f4`
5741 if (( $frag_lun != $last_lun )); then
5742 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
5743 if (( logical != 512 )); then
5745 error "FIEMAP on $fm_file failed; returned logical start for lun $logical instead of 512"
5748 if (( tot_len != 512 )); then
5750 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
5757 (( tot_len += ext_len ))
5760 if (( num_luns != 2 || tot_len != 512 )); then
5762 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
5768 echo "FIEMAP on 2-stripe file with hole succeeded"
5770 run_test 130c "FIEMAP (2-stripe file with hole)"
5773 [ "$OSTCOUNT" -lt "3" ] && skip "skipping FIEMAP on N-stripe file test" && return
5775 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
5776 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
5778 trap cleanup_130 EXIT RETURN
5780 local fm_file=$DIR/$tfile
5781 lfs setstripe -s 65536 -c $OSTCOUNT $fm_file || error "setstripe failed on $fm_file"
5782 dd if=/dev/zero of=$fm_file bs=1M count=$OSTCOUNT || error "dd failed on $fm_file"
5784 filefrag -ves $fm_file || error "filefrag $fm_file failed"
5785 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
5787 last_lun=`echo $filefrag_op | cut -d: -f5`
5792 for line in $filefrag_op
5794 frag_lun=`echo $line | cut -d: -f5`
5795 ext_len=`echo $line | cut -d: -f4`
5796 if (( $frag_lun != $last_lun )); then
5797 if (( tot_len != 1024 )); then
5799 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
5806 (( tot_len += ext_len ))
5809 if (( num_luns != OSTCOUNT || tot_len != 1024 )); then
5811 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
5817 echo "FIEMAP on N-stripe file succeeded"
5819 run_test 130d "FIEMAP (N-stripe file)"
5822 [ "$OSTCOUNT" -lt "2" ] && skip "skipping continuation FIEMAP test" && return
5824 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
5825 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
5827 trap cleanup_130 EXIT RETURN
5829 local fm_file=$DIR/$tfile
5830 lfs setstripe -s 65536 -c 2 $fm_file || error "setstripe failed on $fm_file"
5832 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 4 ))
5833 for ((i = 0; i < $NUM_BLKS; i++))
5835 dd if=/dev/zero of=$fm_file count=1 bs=4096 seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
5838 filefrag -ves $fm_file || error "filefrag $fm_file failed"
5839 filefrag_op=`filefrag -ve $fm_file | grep -A 750 "ext:" | grep -v "ext:" | grep -v "found"`
5841 last_lun=`echo $filefrag_op | cut -d: -f5`
5846 for line in $filefrag_op
5848 frag_lun=`echo $line | cut -d: -f5`
5849 ext_len=`echo $line | cut -d: -f4`
5850 if (( $frag_lun != $last_lun )); then
5851 if (( tot_len != $EXPECTED_LEN )); then
5853 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of $EXPECTED_LEN"
5860 (( tot_len += ext_len ))
5863 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
5865 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
5871 echo "FIEMAP with continuation calls succeeded"
5873 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
5875 # Test for writev/readv
5877 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 || \
5878 error "writev test failed"
5879 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 || \
5880 error "readv failed"
5883 run_test 131a "test iov's crossing stripe boundary for writev/readv"
5886 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 || \
5887 error "append writev test failed"
5888 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 || \
5889 error "append writev test failed"
5892 run_test 131b "test append writev"
5895 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
5898 run_test 131c "test read/write on file w/o objects"
5901 rwv -f $DIR/$tfile -w -n 1 1572864
5902 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
5903 if [ "$NOB" != 1572864 ]; then
5904 error "Short read filed: read $NOB bytes instead of 1572864"
5908 run_test 131d "test short read"
5911 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
5912 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
5913 error "read hitting hole failed"
5916 run_test 131e "test read hitting hole"
5921 for node in $(osts_nodes); do
5922 gl=$(do_node $node "$LCTL get_param -n ost.OSS.ost.stats" | awk '/'$token'/ {print $2}' | head -n 1)
5923 [ x$gl = x"" ] && gl=0
5924 gl_sum=$((gl_sum + gl))
5934 if [ x$som = x"enabled" ]; then
5935 [ $((gl2 - gl1)) -gt 0 ] && error "no glimpse RPC is expected"
5936 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=disabled"
5938 [ $((gl2 - gl1)) -gt 0 ] || error "some glimpse RPC is expected"
5939 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=enabled"
5942 # do remount to make new mount-conf parameters actual
5949 test_132() { #1028, SOM
5950 local num=$(get_mds_dir $DIR)
5951 local mymds=mds${num}
5953 dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
5954 cancel_lru_locks osc
5956 som1=$(do_facet $mymds "$LCTL get_param mdt.*.som" | awk -F= ' {print $2}' | head -n 1)
5958 gl1=$(get_ost_param "ldlm_glimpse_enqueue")
5959 stat $DIR/$tfile >/dev/null
5960 gl2=$(get_ost_param "ldlm_glimpse_enqueue")
5961 echo "====> SOM is "$som1", "$((gl2 - gl1))" glimpse RPC occured"
5962 cancel_lru_locks osc
5963 som_mode_switch $som1 $gl1 $gl2
5965 som2=$(do_facet $mymds "$LCTL get_param mdt.*.som" | awk -F= ' {print $2}' | head -n 1)
5966 [ $som1 != $som2 ] || error "som is still "$som2
5968 gl1=$(get_ost_param "ldlm_glimpse_enqueue")
5969 stat $DIR/$tfile >/dev/null
5970 gl2=$(get_ost_param "ldlm_glimpse_enqueue")
5971 echo "SOM is "$som2", "$((gl2 - gl1))" glimpse RPC occured"
5972 som_mode_switch $som2 $gl1 $gl2
5974 run_test 132 "som avoids glimpse rpc"
5976 test_140() { #bug-17379
5977 mkdir -p $DIR/$tdir || error "Creating dir $DIR/$tdir"
5978 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
5979 cp /usr/bin/stat . || error "Copying stat to $DIR/$tdir"
5981 # VFS limits max symlink depth to 5(4KSTACK) or 8
5983 while i=`expr $i + 1`; do
5984 mkdir -p $i || error "Creating dir $i"
5985 cd $i || error "Changing to $i"
5986 ln -s ../stat stat || error "Creating stat symlink"
5987 # Read the symlink until ELOOP present,
5988 # not LBUGing the system is considered success,
5989 # we didn't overrun the stack.
5990 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
5992 if [ $ret -eq 40 ]; then
5995 error "Open stat symlink"
6001 echo "The symlink depth = $i"
6002 [ $i -eq 4 -o $i -eq 8 ] || error "Invalid symlink depth"
6004 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
6007 local TF="$TMP/$tfile"
6009 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
6011 cancel_lru_locks osc
6012 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
6013 remount_client $MOUNT
6014 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
6017 $TRUNCATE $DIR/$tfile 6000
6018 cancel_lru_locks osc
6019 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
6022 echo "12345" >>$DIR/$tfile
6023 cancel_lru_locks osc
6024 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
6027 echo "12345" >>$DIR/$tfile
6028 cancel_lru_locks osc
6029 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
6034 run_test 150 "truncate/append tests"
6036 function roc_access() {
6037 local list=$(comma_list $(osts_nodes))
6038 ACCNUM=`do_nodes $list $LCTL get_param -n obdfilter.*.stats | \
6039 grep 'cache_access'| awk '{print $2}' | \
6040 awk '{sum=sum+$3} END{print sum}'`
6044 function roc_hit() {
6045 local list=$(comma_list $(osts_nodes))
6046 ACCNUM=`do_nodes $list $LCTL get_param -n obdfilter.*.stats | \
6047 grep 'cache_hit'|awk '{print $2}' | \
6048 awk '{sum=sum+$1} END{print sum}'`
6053 remote_ost_nodsh && skip "remote OST with nodsh" && return
6056 local list=$(comma_list $(osts_nodes))
6058 # check whether obdfilter is cache capable at all
6059 if ! do_nodes $list $LCTL get_param -n obdfilter.*.read_cache_enable > /dev/null; then
6060 echo "not cache-capable obdfilter"
6064 # check cache is enabled on all obdfilters
6065 if do_nodes $list $LCTL get_param -n obdfilter.*.read_cache_enable | grep 0 >&/dev/null; then
6066 echo "oss cache is disabled"
6070 do_nodes $list $LCTL set_param -n obdfilter.*.writethrough_cache_enable 1
6072 # pages should be in the case right after write
6073 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES || error "dd failed"
6074 local BEFORE=`roc_hit`
6075 cancel_lru_locks osc
6076 cat $DIR/$tfile >/dev/null
6077 local AFTER=`roc_hit`
6078 if ! let "AFTER - BEFORE == CPAGES"; then
6079 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
6082 # the following read invalidates the cache
6083 cancel_lru_locks osc
6084 do_nodes $list $LCTL set_param -n obdfilter.*.read_cache_enable 0
6085 cat $DIR/$tfile >/dev/null
6087 # now data shouldn't be found in the cache
6089 cancel_lru_locks osc
6090 cat $DIR/$tfile >/dev/null
6092 if let "AFTER - BEFORE != 0"; then
6093 error "IN CACHE: before: $BEFORE, after: $AFTER"
6096 do_nodes $list $LCTL set_param -n obdfilter.*.read_cache_enable 1
6099 run_test 151 "test cache on oss and controls ==============================="
6102 local TF="$TMP/$tfile"
6104 # simulate ENOMEM during write
6105 #define OBD_FAIL_OST_NOMEM 0x226
6106 lctl set_param fail_loc=0x80000226
6107 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
6109 sync || error "sync failed"
6110 lctl set_param fail_loc=0
6112 # discard client's cache
6113 cancel_lru_locks osc
6115 # simulate ENOMEM during read
6116 lctl set_param fail_loc=0x80000226
6117 cmp $TF $DIR/$tfile || error "cmp failed"
6118 lctl set_param fail_loc=0
6122 run_test 152 "test read/write with enomem ============================"
6125 multiop $DIR/$tfile Ow4096Ycu || error "multiop failed"
6127 run_test 153 "test if fdatasync does not crash ======================="
6130 cp /etc/hosts $DIR/$tfile
6132 fid=$($LFS path2fid $DIR/$tfile)
6134 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
6136 echo "open fid $fid"
6137 diff /etc/hosts $DIR/.lustre/fid/$fid || error "open by fid failed: did not find expected data in file."
6139 echo "Opening a file by FID succeeded"
6141 run_test 154 "Opening a file by FID"
6145 if [ $MDSCOUNT -gt 1 ]; then
6146 error_ignore 17935 $*
6152 USER=$(do_facet $SINGLEMDS lctl --device $MDT0 changelog_register -n)
6153 echo "Registered as changelog user $USER"
6154 do_facet $SINGLEMDS lctl get_param -n mdd.$MDT0.changelog_users | \
6155 grep -q $USER || error "User $USER not found in changelog_users"
6158 mkdir -p $DIR/$tdir/pics/2008/zachy
6159 touch $DIR/$tdir/pics/2008/zachy/timestamp
6160 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
6161 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
6162 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
6163 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
6164 rm $DIR/$tdir/pics/desktop.jpg
6166 $LFS changelog $MDT0 | tail -5
6168 echo "verifying changelog mask"
6169 do_facet $SINGLEMDS lctl set_param mdd.$MDT0.changelog_mask="-mkdir"
6170 mkdir -p $DIR/$tdir/pics/2009/sofia
6171 do_facet $SINGLEMDS lctl set_param mdd.$MDT0.changelog_mask="+mkdir"
6172 mkdir $DIR/$tdir/pics/2009/zachary
6173 DIRS=$($LFS changelog $MDT0 | tail -5 | grep -c MKDIR)
6174 [ $DIRS -eq 1 ] || err17935 "changelog mask count $DIRS != 1"
6177 echo "verifying target fid"
6178 fidc=$($LFS changelog $MDT0 | grep timestamp | grep "CREAT" | \
6179 tail -1 | awk '{print $5}')
6180 fidf=$($LFS path2fid $DIR/$tdir/pics/zach/timestamp)
6181 [ "$fidc" == "t=$fidf" ] || \
6182 err17935 "fid in changelog $fidc != file fid $fidf"
6183 echo "verifying parent fid"
6184 fidc=$($LFS changelog $MDT0 | grep timestamp | grep "CREAT" | \
6185 tail -1 | awk '{print $6}')
6186 fidf=$($LFS path2fid $DIR/$tdir/pics/zach)
6187 [ "$fidc" == "p=$fidf" ] || \
6188 err17935 "pfid in changelog $fidc != dir fid $fidf"
6190 USER_REC1=$(do_facet $SINGLEMDS lctl get_param -n \
6191 mdd.$MDT0.changelog_users | grep $USER | awk '{print $2}')
6192 $LFS changelog_clear $MDT0 $USER $(($USER_REC1 + 5))
6193 USER_REC2=$(do_facet $SINGLEMDS lctl get_param -n \
6194 mdd.$MDT0.changelog_users | grep $USER | awk '{print $2}')
6195 echo "verifying user clear: $(( $USER_REC1 + 5 )) == $USER_REC2"
6196 [ $USER_REC2 == $(($USER_REC1 + 5)) ] || \
6197 err17935 "user index should be $(($USER_REC1 + 5)); is $USER_REC2"
6199 MIN_REC=$(do_facet $SINGLEMDS lctl get_param mdd.$MDT0.changelog_users | \
6200 awk 'min == "" || $2 < min {min = $2}; END {print min}')
6201 FIRST_REC=$($LFS changelog $MDT0 | head -1 | awk '{print $1}')
6202 echo "verifying min purge: $(( $MIN_REC + 1 )) == $FIRST_REC"
6203 [ $FIRST_REC == $(($MIN_REC + 1)) ] || \
6204 err17935 "first index should be $(($MIN_REC + 1)); is $FIRST_REC"
6206 echo "verifying user deregister"
6207 do_facet $SINGLEMDS lctl --device $MDT0 changelog_deregister $USER
6208 do_facet $SINGLEMDS lctl get_param -n mdd.$MDT0.changelog_users | \
6209 grep -q $USER && error "User $USER still found in changelog_users"
6211 USERS=$(( $(do_facet $SINGLEMDS lctl get_param -n \
6212 mdd.$MDT0.changelog_users | wc -l) - 2 ))
6213 if [ $USERS -eq 0 ]; then
6214 LAST_REC1=$(do_facet $SINGLEMDS lctl get_param -n \
6215 mdd.$MDT0.changelog_users | head -1 | awk '{print $3}')
6216 touch $DIR/$tdir/chloe
6217 LAST_REC2=$(do_facet $SINGLEMDS lctl get_param -n \
6218 mdd.$MDT0.changelog_users | head -1 | awk '{print $3}')
6219 echo "verify changelogs are off if we were the only user: $LAST_REC1 == $LAST_REC2"
6220 [ $LAST_REC1 == $LAST_REC2 ] || error "changelogs not off"
6222 echo "$USERS other changelog users; can't verify off"
6225 run_test 160 "changelog sanity"
6229 cp /etc/hosts $DIR/$tdir/$tfile
6230 mkdir $DIR/$tdir/foo1
6231 mkdir $DIR/$tdir/foo2
6232 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
6233 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
6234 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
6235 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
6236 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[')
6237 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
6238 $LFS fid2path $DIR $FID
6239 err17935 "bad link ea"
6242 rm $DIR/$tdir/foo2/zachary
6244 rm $DIR/$tdir/foo2/thor
6246 rm $DIR/$tdir/$tfile
6248 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
6249 if [ "$($LFS fid2path $DIR --link 1 $FID)" != "/$tdir/foo2/maggie" ]
6251 $LFS fid2path $DIR $FID
6252 err17935 "bad link rename"
6254 rm $DIR/$tdir/foo2/maggie
6257 local longname=filename_avg_len_is_thirty_two_
6258 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 || \
6259 error "failed to hardlink many files"
6260 links=$($LFS fid2path $DIR $FID | wc -l)
6261 echo -n "${links}/1000 links in link EA"
6262 [ ${links} -gt 60 ] || err17935 "expected at least 60 links in link EA"
6263 unlinkmany $DIR/$tdir/foo2/$longname 1000 || \
6264 error "failed to unlink many hardlinks"
6266 run_test 161 "link ea sanity"
6273 local path=$(${LFS} fid2path $*)
6276 if [ $RC -ne 0 ]; then
6277 err17935 "path looked up of $expected failed. Error $RC"
6279 elif [ "${path}" != "${expected}" ]; then
6280 err17935 "path looked up \"${path}\" instead of \"${expected}\""
6283 echo "fid $fid resolves to path $path"
6287 # Make changes to filesystem
6288 mkdir -p $DIR/$tdir/d2
6289 touch $DIR/$tdir/d2/$tfile
6290 touch $DIR/$tdir/d2/x1
6291 touch $DIR/$tdir/d2/x2
6292 mkdir -p $DIR/$tdir/d2/a/b/c
6293 mkdir -p $DIR/$tdir/d2/p/q/r
6294 FID=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[')
6295 check_path "/$tdir/d2/$tfile" $DIR $FID --link 0
6296 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
6297 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
6298 FID=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[')
6299 # fid2path dir/fsname should both work
6300 check_path "/$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 1
6301 check_path "/$tdir/d2/p/q/r/hlink" $DIR $FID --link 0
6302 # check that there are 2 links
6303 ${LFS} fid2path $DIR $FID | wc -l | grep -q 2 || \
6304 err17935 "expected 2 links"
6306 rm $DIR/$tdir/d2/p/q/r/hlink
6307 check_path "/$tdir/d2/a/b/c/new_file" $DIR $FID --link 0
6308 # Doesnt work with CMD yet: 17935
6311 run_test 162 "path lookup sanity"
6314 # do directio so as not to populate the page cache
6315 log "creating a 10 Mb file"
6316 multiop $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
6317 log "starting reads"
6318 dd if=$DIR/$tfile of=/dev/null bs=4096 &
6319 log "truncating the file"
6320 multiop $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
6322 kill %+ || true # reads might have finished
6323 echo "wait until dd is finished"
6325 log "removing the temporary file"
6326 rm -rf $DIR/$tfile || error "tmp file removal failed"
6328 run_test 169 "parallel read and truncate should not deadlock ==="
6331 $LCTL clear # bug 18514
6332 $LCTL debug_daemon start $TMP/${tfile}_log_good
6334 $LCTL debug_daemon stop
6335 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
6336 error "sed failed to read log_good"
6338 $LCTL debug_daemon start $TMP/${tfile}_log_good
6340 $LCTL debug_daemon stop
6342 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
6343 error "lctl df log_bad failed"
6345 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
6346 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
6348 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
6349 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
6351 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
6352 error "bad_line good_line1 good_line2 are empty"
6354 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
6355 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
6356 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
6358 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
6359 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
6360 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
6362 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
6363 error "bad_line_new good_line_new are empty"
6365 local expected_good=$((good_line1 + good_line2*2))
6367 rm -f $TMP/${tfile}*
6368 if [ $bad_line -ne $bad_line_new ]; then
6369 error "expected $bad_line bad lines, but got $bad_line_new"
6373 if [ $expected_good -ne $good_line_new ]; then
6374 error "expected $expected_good good lines, but got $good_line_new"
6379 run_test 170 "test lctl df to handle corrupted log ====================="
6385 TGTPOOL_MAX=$(($TGT_COUNT - 1))
6387 TGTPOOL_LIST=`seq $TGTPOOL_FIRST $TGTPOOL_STEP $TGTPOOL_MAX`
6388 POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
6389 POOL_DIR=$POOL_ROOT/dir_tst
6390 POOL_FILE=$POOL_ROOT/file_tst
6392 check_file_in_pool()
6395 res=$($GETSTRIPE $file | grep 0x | cut -f2)
6398 found=$(echo :$TGTPOOL_LIST: | tr " " ":" | grep :$i:)
6399 if [[ "$found" == "" ]]
6401 echo "pool list: $TGTPOOL_LIST"
6402 echo "striping: $res"
6403 error "$file not allocated in $POOL"
6411 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
6412 do_facet mgs $LCTL pool_new $FSNAME.$POOL
6413 # get param should return err until pool is created
6414 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null || echo foo" "" || error "Pool creation of $POOL failed"
6416 run_test 200a "Create new pool =========================================="
6419 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
6420 TGT=$(for i in `seq $TGTPOOL_FIRST $TGTPOOL_STEP $TGTPOOL_MAX`; do printf "$FSNAME-OST%04x_UUID " $i; done)
6421 do_facet mgs $LCTL pool_add $FSNAME.$POOL \
6422 $FSNAME-OST[$TGTPOOL_FIRST-$TGTPOOL_MAX/$TGTPOOL_STEP]
6423 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL | sort -u | tr '\n' ' ' " "$TGT" || error "Add to pool failed"
6425 run_test 200b "Add targets to a pool ===================================="
6428 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
6430 $SETSTRIPE -c 2 -p $POOL $POOL_DIR
6431 [ $? = 0 ] || error "Cannot set pool $POOL to $POOL_DIR"
6433 run_test 200c "Set pool on a directory ================================="
6436 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
6437 res=$($GETSTRIPE $POOL_DIR | grep pool: | cut -f8 -d " ")
6438 [ "$res" = $POOL ] || error "Pool on $POOL_DIR is not $POOL"
6440 run_test 200d "Check pool on a directory ==============================="
6443 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
6445 for i in $(seq -w 1 $(($TGT_COUNT * 3)))
6447 file=$POOL_DIR/file-$i
6449 check_file_in_pool $file
6452 failed=$(($failed + 1))
6455 [ "$failed" = 0 ] || error "$failed files not allocated in $POOL"
6457 run_test 200e "Check files allocation from directory pool =============="
6460 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
6463 for i in $(seq -w 1 $(($TGT_COUNT * 3)))
6465 file=$POOL_FILE/spoo-$i
6466 $SETSTRIPE -p $POOL $file
6467 check_file_in_pool $file
6470 failed=$(($failed + 1))
6473 [ "$failed" = 0 ] || error "$failed files not allocated in $POOL"
6475 run_test 200f "Create files in a pool ==================================="
6478 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
6479 TGT=$($LCTL get_param -n lov.$FSNAME-*.pools.$POOL | head -1)
6480 do_facet mgs $LCTL pool_remove $FSNAME.$POOL $TGT
6481 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL | grep $TGT" "" || error "$TGT not removed from $FSNAME.$POOL"
6483 run_test 200g "Remove a target from a pool ============================="
6486 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
6487 for TGT in $($LCTL get_param -n lov.$FSNAME-*.pools.$POOL | sort -u)
6489 do_facet mgs $LCTL pool_remove $FSNAME.$POOL $TGT
6491 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL" ""\
6492 || error "Pool $FSNAME.$POOL cannot be drained"
6493 # striping on an empty pool should fall back to "pool of everything"
6494 $SETSTRIPE -p $POOL ${POOL_FILE}/$tfile || error "failed to create file with empty pool"
6496 run_test 200h "Remove all targets from a pool =========================="
6499 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
6500 do_facet mgs $LCTL pool_destroy $FSNAME.$POOL
6501 # get param should return err once pool is gone
6502 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null || echo foo" "foo" && return 0
6503 error "Pool $FSNAME.$POOL is not destroyed"
6505 run_test 200i "Remove a pool ============================================"
6509 size=$((size % 8192 + 1))
6510 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
6511 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
6512 rm -f $DIR/f212 $DIR/f212.xyz
6514 run_test 212 "Sendfile test ============================================"
6517 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
6518 cancel_lru_locks osc
6519 lctl set_param fail_loc=0x8000040f
6520 # generate a read lock
6521 cat $DIR/$tfile > /dev/null
6522 # write to the file, it will try to cancel the above read lock.
6523 cat /etc/hosts >> $DIR/$tfile
6525 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
6528 # tests that do cleanup/setup should be run at the end
6533 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
6534 $LCTL set_param fail_loc=0x903
6535 # cancel_lru_locks mgc - does not work due to lctl set_param syntax
6536 for ls in /proc/fs/lustre/ldlm/namespaces/MGC*/lru_size; do
6539 FAIL_ON_ERROR=true cleanup
6540 FAIL_ON_ERROR=true setup
6542 run_test 900 "umount should not race with any mgc requeue thread"
6544 log "cleanup: ======================================================"
6545 check_and_cleanup_lustre
6546 if [ "$I_MOUNTED" != "yes" ]; then
6547 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true
6550 echo '=========================== finished ==============================='
6551 [ -f "$SANITYLOG" ] && cat $SANITYLOG && grep -q FAIL $SANITYLOG && exit 1 || true
6552 echo "$0: completed"