3 # Run select tests by setting ONLY, or as arguments to the script.
4 # Skip specific tests by setting EXCEPT.
6 # e.g. ONLY="22 23" or ONLY="`seq 32 39`" or EXCEPT="31"
10 # bug number for skipped test: 13297 2108 9789 3637 9789 3561 12622 5188
11 ALWAYS_EXCEPT=" 27u 42a 42b 42c 42d 45 51d 68b $SANITY_EXCEPT"
12 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
14 # Tests that fail on uml
15 CPU=`awk '/model/ {print $4}' /proc/cpuinfo`
16 # buffer i/o errs sock spc runas
17 [ "$CPU" = "UML" ] && EXCEPT="$EXCEPT 27m 27n 27o 27p 27q 27r 31d 54a 64b 99a 99b 99c 99d 99e 99f 101a"
19 SRCDIR=$(cd $(dirname $0); echo $PWD)
20 export PATH=$PATH:/sbin
24 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
25 CREATETEST=${CREATETEST:-createtest}
27 LFIND=${LFIND:-"$LFS find"}
28 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
30 MCREATE=${MCREATE:-mcreate}
31 OPENFILE=${OPENFILE:-openfile}
32 OPENUNLINK=${OPENUNLINK:-openunlink}
33 export MULTIOP=${MULTIOP:-multiop}
34 READS=${READS:-"reads"}
35 MUNLINK=${MUNLINK:-munlink}
36 SOCKETSERVER=${SOCKETSERVER:-socketserver}
37 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
38 MEMHOG=${MEMHOG:-memhog}
39 DIRECTIO=${DIRECTIO:-directio}
40 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
41 UMOUNT=${UMOUNT:-"umount -d"}
43 CHECK_GRANT=${CHECK_GRANT:-"yes"}
44 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
46 export NAME=${NAME:-local}
53 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
54 . $LUSTRE/tests/test-framework.sh
56 . ${CONFIG:=$LUSTRE/tests/cfg/${NAME}.sh}
59 [ "$SLOW" = "no" ] && EXCEPT_SLOW="24o 24v 27m 36f 36g 36h 51b 60c 63 64b 68 71 73 77f 78 101a 103 115 120g 124b"
65 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
66 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
75 check_kernel_version() {
77 GOT_VER=$(lctl get_param -n version | awk '/kernel:/ {print $2}')
79 patchless|patchless_client) return 0;;
80 *) [ $GOT_VER -ge $WANT_VER ] && return 0 ;;
82 log "test needs at least kernel version $WANT_VER, running $GOT_VER"
86 if [ "$ONLY" == "cleanup" ]; then
91 check_and_setup_lustre
96 MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid | \
97 awk '{gsub(/_UUID/,""); print $1}' | head -1)
98 LOVNAME=$($LCTL get_param -n llite.*.lov.common_name | tail -n 1)
99 OSTCOUNT=$($LCTL get_param -n lov.$LOVNAME.numobd)
100 STRIPECOUNT=$($LCTL get_param -n lov.$LOVNAME.stripecount)
101 STRIPESIZE=$($LCTL get_param -n lov.$LOVNAME.stripesize)
102 ORIGFREE=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
103 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
105 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
106 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
107 rm -rf $DIR/[Rdfs][0-9]*
109 # $RUNAS_ID may get set incorrectly somewhere else
110 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
112 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
116 if [ "${ONLY}" = "MOUNT" ] ; then
117 echo "Lustre is up, please go on"
121 echo "preparing for tests involving mounts"
122 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
124 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
125 echo # add a newline after mke2fs.
129 OLDDEBUG="`lctl get_param -n debug 2> /dev/null`"
130 lctl set_param debug=-1 2> /dev/null || true
133 $CHECKSTAT -t file $DIR/$tfile || error
135 $CHECKSTAT -a $DIR/$tfile || error
137 run_test 0 "touch .../$tfile ; rm .../$tfile ====================="
140 chmod 0755 $DIR || error
141 $CHECKSTAT -p 0755 $DIR || error
143 run_test 0b "chmod 0755 $DIR ============================="
146 $LCTL get_param mdc.*.import | grep "state: FULL" || error "import not FULL"
147 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" || error "bad target"
149 run_test 0c "check import proc ============================="
154 mkdir $DIR/d1/d2 && error "we expect EEXIST, but not returned"
155 $CHECKSTAT -t dir $DIR/d1/d2 || error
157 run_test 1a "mkdir .../d1; mkdir .../d1/d2 ====================="
162 $CHECKSTAT -a $DIR/d1 || error
164 run_test 1b "rmdir .../d1/d2; rmdir .../d1 ====================="
169 $CHECKSTAT -t file $DIR/d2/f || error
171 run_test 2a "mkdir .../d2; touch .../d2/f ======================"
175 $CHECKSTAT -a $DIR/d2 || error
177 run_test 2b "rm -r .../d2; checkstat .../d2/f ======================"
181 $CHECKSTAT -t dir $DIR/d3 || error
183 run_test 3a "mkdir .../d3 ======================================"
186 if [ ! -d $DIR/d3 ]; then
190 $CHECKSTAT -t file $DIR/d3/f || error
192 run_test 3b "touch .../d3/f ===================================="
196 $CHECKSTAT -a $DIR/d3 || error
198 run_test 3c "rm -r .../d3 ======================================"
202 $CHECKSTAT -t dir $DIR/d4 || error
204 run_test 4a "mkdir .../d4 ======================================"
207 if [ ! -d $DIR/d4 ]; then
211 $CHECKSTAT -t dir $DIR/d4/d2 || error
213 run_test 4b "mkdir .../d4/d2 ==================================="
218 chmod 0707 $DIR/d5/d2
219 $CHECKSTAT -t dir -p 0707 $DIR/d5/d2 || error
221 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2 ============"
225 chmod 0666 $DIR/f6a || error
226 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/f6a || error
228 run_test 6a "touch .../f6a; chmod .../f6a ======================"
231 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
232 if [ ! -f $DIR/f6a ]; then
236 $RUNAS chmod 0444 $DIR/f6a && error
237 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/f6a || error
239 run_test 6b "$RUNAS chmod .../f6a (should return error) =="
242 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
244 chown $RUNAS_ID $DIR/f6c || error
245 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/f6c || error
247 run_test 6c "touch .../f6c; chown .../f6c ======================"
250 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
251 if [ ! -f $DIR/f6c ]; then
253 chown $RUNAS_ID $DIR/f6c
255 $RUNAS chown $UID $DIR/f6c && error
256 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/f6c || error
258 run_test 6d "$RUNAS chown .../f6c (should return error) =="
261 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
263 chgrp $RUNAS_ID $DIR/f6e || error
264 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/f6e || error
266 run_test 6e "touch .../f6e; chgrp .../f6e ======================"
269 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
270 if [ ! -f $DIR/f6e ]; then
272 chgrp $RUNAS_ID $DIR/f6e
274 $RUNAS chgrp $UID $DIR/f6e && error
275 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/f6e || error
277 run_test 6f "$RUNAS chgrp .../f6e (should return error) =="
280 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
281 mkdir $DIR/d6g || error
282 chmod 777 $DIR/d6g || error
283 $RUNAS mkdir $DIR/d6g/d || error
284 chmod g+s $DIR/d6g/d || error
285 mkdir $DIR/d6g/d/subdir
286 $CHECKSTAT -g \#$RUNAS_GID $DIR/d6g/d/subdir || error
288 run_test 6g "Is new dir in sgid dir inheriting group?"
290 test_6h() { # bug 7331
291 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
292 touch $DIR/f6h || error "touch failed"
293 chown $RUNAS_ID:$RUNAS_GID $DIR/f6h || error "initial chown failed"
294 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/f6h && error "chown worked"
295 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/f6h || error
297 run_test 6h "$RUNAS chown RUNAS_ID.0 .../f6h (should return error)"
303 $CHECKSTAT -t file -p 0666 $DIR/d7/f || error
305 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
308 if [ ! -d $DIR/d7 ]; then
312 echo -n foo > $DIR/d7/f2
313 [ "`cat $DIR/d7/f2`" = "foo" ] || error
314 $CHECKSTAT -t file -s 3 $DIR/d7/f2 || error
316 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
322 $CHECKSTAT -t file -p 0666 $DIR/d8/f || error
324 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
330 $CHECKSTAT -t dir $DIR/d9/d2/d3 || error
332 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
338 $CHECKSTAT -t file $DIR/d10/d2/f || error
340 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
345 chmod 0666 $DIR/d11/d2
346 chmod 0705 $DIR/d11/d2
347 $CHECKSTAT -t dir -p 0705 $DIR/d11/d2 || error
349 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
354 chmod 0666 $DIR/d12/f
355 chmod 0654 $DIR/d12/f
356 $CHECKSTAT -t file -p 0654 $DIR/d12/f || error
358 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
362 dd if=/dev/zero of=$DIR/d13/f count=10
364 $CHECKSTAT -t file -s 0 $DIR/d13/f || error
366 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
372 $CHECKSTAT -a $DIR/d14/f || error
374 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
379 mv $DIR/d15/f $DIR/d15/f2
380 $CHECKSTAT -t file $DIR/d15/f2 || error
382 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
388 $CHECKSTAT -a $DIR/d16/f || error
390 run_test 16 "touch .../d16/f; rm -rf .../d16/f ================="
395 ln -s $DIR/d17/f $DIR/d17/l-exist
397 $CHECKSTAT -l $DIR/d17/f $DIR/d17/l-exist || error
398 $CHECKSTAT -f -t f $DIR/d17/l-exist || error
399 rm -f $DIR/d17/l-exist
400 $CHECKSTAT -a $DIR/d17/l-exist || error
402 run_test 17a "symlinks: create, remove (real) =================="
406 ln -s no-such-file $DIR/d17/l-dangle
408 $CHECKSTAT -l no-such-file $DIR/d17/l-dangle || error
409 $CHECKSTAT -fa $DIR/d17/l-dangle || error
410 rm -f $DIR/d17/l-dangle
411 $CHECKSTAT -a $DIR/d17/l-dangle || error
413 run_test 17b "symlinks: create, remove (dangling) =============="
415 test_17c() { # bug 3440 - don't save failed open RPC for replay
417 ln -s foo $DIR/d17/f17c
418 cat $DIR/d17/f17c && error "opened non-existent symlink" || true
420 run_test 17c "symlinks: open dangling (should return error) ===="
424 ln -s foo $DIR/d17/f17d
425 touch $DIR/d17/f17d || error "creating to new symlink"
427 run_test 17d "symlinks: create dangling ========================"
431 local foo=$DIR/$tdir/$tfile
432 ln -s $foo $foo || error "create symlink failed"
433 ls -l $foo || error "ls -l failed"
434 ls $foo && error "ls not failed" || true
436 run_test 17e "symlinks: create recursive symlink (should return error) ===="
440 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/d17f/111
441 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/d17f/222
442 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/d17f/333
443 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/d17f/444
444 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/d17f/555
445 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
448 run_test 17f "symlinks: long and very long symlink name ========================"
452 LONGSYMLINK="$(dd if=/dev/zero bs=4095 count=1 | tr '\0' 'x')"
453 ln -s $LONGSYMLINK $DIR/$tdir/$tfile
456 run_test 17g "symlinks: really long symlink name ==============================="
458 test_17h() { #bug 17378
459 remote_mds_nodsh && skip "remote MDS with nodsh" && return
461 $SETSTRIPE -c -1 $DIR/$tdir
462 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
463 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000141
464 touch $DIR/$tdir/$tfile || true
466 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
468 test_17i() { #bug 20018
469 remote_mds_nodsh && skip "remote MDS with nodsh" && return
471 local foo=$DIR/$tdir/$tfile
472 ln -s $foo $foo || error "create symlink failed"
473 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
474 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000143
475 ls -l $foo && error "error not detected"
478 run_test 17i "don't panic on short symlink"
480 test_17k() { #bug 22301
481 rsync --help | grep -q xattr ||
482 skip_env "$(rsync --version| head -1) does not support xattrs"
483 mkdir -p $DIR/{$tdir,$tdir.new}
484 touch $DIR/$tdir/$tfile
485 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
486 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
487 error "rsync failed with xattrs enabled"
489 run_test 17k "symlinks: rsync with xattrs enabled ========================="
495 run_test 18 "touch .../f ; ls ... =============================="
501 $CHECKSTAT -a $DIR/f19 || error
503 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
506 ls -l $DIR/f19 && error || true
508 run_test 19b "ls -l .../f19 (should return error) =============="
511 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
512 $RUNAS touch $DIR/f19 && error || true
514 run_test 19c "$RUNAS touch .../f19 (should return error) =="
517 cat $DIR/f19 && error || true
519 run_test 19d "cat .../f19 (should return error) =============="
531 $CHECKSTAT -a $DIR/f || error
533 run_test 20 "touch .../f ; ls -l ... ==========================="
537 [ -f $DIR/d21/dangle ] && rm -f $DIR/d21/dangle
538 ln -s dangle $DIR/d21/link
539 echo foo >> $DIR/d21/link
541 $CHECKSTAT -t link $DIR/d21/link || error
542 $CHECKSTAT -f -t file $DIR/d21/link || error
544 run_test 21 "write to dangling link ============================"
549 chown $RUNAS_ID:$RUNAS_GID $WDIR
550 (cd $WDIR || error "cd $WDIR failed";
551 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
553 ls -lR $WDIR/etc || error "ls -lR $WDIR/etc failed"
554 $CHECKSTAT -t dir $WDIR/etc || error "checkstat -t dir failed"
555 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $WDIR/etc || error "checkstat -u failed"
557 run_test 22 "unpack tar archive as non-root user ==============="
562 local file=$DIR/$tdir/$tfile
564 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
565 openfile -f O_CREAT:O_EXCL $file &&
566 error "$file recreate succeeded" || true
568 run_test 23a "O_CREAT|O_EXCL in subdir =========================="
570 test_23b() { # bug 18988
572 local file=$DIR/$tdir/$tfile
575 echo foo > $file || error "write filed"
576 echo bar >> $file || error "append filed"
577 $CHECKSTAT -s 8 $file || error "wrong size"
580 run_test 23b "O_APPEND check =========================="
583 echo '== rename sanity =============================================='
584 echo '-- same directory rename'
587 mv $DIR/R1/f $DIR/R1/g
588 $CHECKSTAT -t file $DIR/R1/g || error
590 run_test 24a "touch .../R1/f; rename .../R1/f .../R1/g ========="
595 mv $DIR/R2/f $DIR/R2/g
596 $CHECKSTAT -a $DIR/R2/f || error
597 $CHECKSTAT -t file $DIR/R2/g || error
599 run_test 24b "touch .../R2/{f,g}; rename .../R2/f .../R2/g ====="
604 mv $DIR/R3/f $DIR/R3/g
605 $CHECKSTAT -a $DIR/R3/f || error
606 $CHECKSTAT -t dir $DIR/R3/g || error
608 run_test 24c "mkdir .../R3/f; rename .../R3/f .../R3/g ========="
613 mrename $DIR/R4/f $DIR/R4/g
614 $CHECKSTAT -a $DIR/R4/f || error
615 $CHECKSTAT -t dir $DIR/R4/g || error
617 run_test 24d "mkdir .../R4/{f,g}; rename .../R4/f .../R4/g ====="
620 echo '-- cross directory renames --'
623 mv $DIR/R5a/f $DIR/R5b/g
624 $CHECKSTAT -a $DIR/R5a/f || error
625 $CHECKSTAT -t file $DIR/R5b/g || error
627 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
631 touch $DIR/R6a/f $DIR/R6b/g
632 mv $DIR/R6a/f $DIR/R6b/g
633 $CHECKSTAT -a $DIR/R6a/f || error
634 $CHECKSTAT -t file $DIR/R6b/g || error
636 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
641 mv $DIR/R7a/d $DIR/R7b/e
642 $CHECKSTAT -a $DIR/R7a/d || error
643 $CHECKSTAT -t dir $DIR/R7b/e || error
645 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
649 mkdir $DIR/R8a/d $DIR/R8b/e
650 mrename $DIR/R8a/d $DIR/R8b/e
651 $CHECKSTAT -a $DIR/R8a/d || error
652 $CHECKSTAT -t dir $DIR/R8b/e || error
654 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
657 echo "-- rename error cases"
661 mrename $DIR/R9/f $DIR/R9/a
662 $CHECKSTAT -t file $DIR/R9/f || error
663 $CHECKSTAT -t dir $DIR/R9/a || error
664 $CHECKSTAT -a $DIR/R9/a/f || error
666 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
670 mrename $DIR/R10/f $DIR/R10/g
671 $CHECKSTAT -t dir $DIR/R10 || error
672 $CHECKSTAT -a $DIR/R10/f || error
673 $CHECKSTAT -a $DIR/R10/g || error
675 run_test 24j "source does not exist ============================"
678 mkdir $DIR/R11a $DIR/R11a/d
680 mv $DIR/R11a/f $DIR/R11a/d
681 $CHECKSTAT -a $DIR/R11a/f || error
682 $CHECKSTAT -t file $DIR/R11a/d/f || error
684 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
686 # bug 2429 - rename foo foo foo creates invalid file
689 $MULTIOP $f OcNs || error
691 run_test 24l "Renaming a file to itself ========================"
695 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
696 # on ext3 this does not remove either the source or target files
697 # though the "expected" operation would be to remove the source
698 $CHECKSTAT -t file ${f} || error "${f} missing"
699 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
701 run_test 24m "Renaming a file to a hard link to itself ========="
705 # this stats the old file after it was renamed, so it should fail
709 $CHECKSTAT ${f}.rename
712 run_test 24n "Statting the old file after renaming (Posix rename 2)"
715 check_kernel_version 37 || return 0
717 rename_many -s random -v -n 10 $DIR/d24o
719 run_test 24o "rename of files during htree split ==============="
723 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
724 mrename $DIR/R12a $DIR/R12b
725 $CHECKSTAT -a $DIR/R12a || error
726 $CHECKSTAT -t dir $DIR/R12b || error
727 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
728 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
730 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
734 DIRINO=`ls -lid $DIR/R13a | awk '{ print $1 }'`
735 multiop_bg_pause $DIR/R13b D_c || return 1
738 mrename $DIR/R13a $DIR/R13b
739 $CHECKSTAT -a $DIR/R13a || error
740 $CHECKSTAT -t dir $DIR/R13b || error
741 DIRINO2=`ls -lid $DIR/R13b | awk '{ print $1 }'`
742 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
744 wait $MULTIPID || error "multiop close failed"
746 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
748 test_24r() { #bug 3789
749 mkdir $DIR/R14a $DIR/R14a/b
750 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
751 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
752 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
754 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
757 mkdir $DIR/R15a $DIR/R15a/b $DIR/R15a/b/c
758 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
759 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
760 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
762 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
764 mkdir $DIR/R16a $DIR/R16a/b $DIR/R16a/b/c
765 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
766 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
767 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
769 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
771 test_24u() { # bug12192
772 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error
773 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
775 run_test 24u "create stripe file"
783 local FREE_INODES=`lfs df -i|grep "filesystem summary" | awk '{print $5}'`
784 [ $FREE_INODES -lt $NRFILES ] && \
785 skip "not enough free inodes $FREE_INODES required $NRFILES" && \
789 createmany -m $DIR/d24v/$tfile $NRFILES
792 lctl set_param mdc.*.stats clear
794 ls $DIR/d24v >/dev/null || error "error in listing large dir"
797 # DIRENT_SIZE = 32 bytes for sizeof(struct lu_dirent) +
798 # 8 bytes for name(filename is mostly 5 in this test) +
799 # 8 bytes for luda_type
800 # take into account of overhead in lu_dirpage header and end mark in
801 # each page, plus one in RPC_NUM calculation.
803 RPC_SIZE=$(($(lctl get_param -n mdc.*.max_pages_per_rpc)*$(page_size)))
804 RPC_NUM=$(((NRFILES * DIRENT_SIZE + RPC_SIZE - 1) / RPC_SIZE + 1))
805 mds_readpage=`lctl get_param mdc.*.stats | \
806 awk '/^mds_readpage/ {print $2}'`
807 [ $mds_readpage -gt $RPC_NUM ] && \
808 error "large readdir doesn't take effect"
812 run_test 24v "list directory with large files (handle hash collision, bug: 17560)"
814 test_24w() { # bug21506
816 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
817 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
818 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
819 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
820 [ "$SZ1" = "$SZ2" ] || \
821 error "Error reading at the end of the file $tfile"
823 run_test 24w "Reading a file larger than 4Gb"
826 echo '== symlink sanity ============================================='
830 touch $DIR/s25/foo || error
832 run_test 25a "create file in symlinked directory ==============="
835 [ ! -d $DIR/d25 ] && test_25a
836 $CHECKSTAT -t file $DIR/s25/foo || error
838 run_test 25b "lookup file in symlinked directory ==============="
843 ln -s d26/d26-2 $DIR/s26
844 touch $DIR/s26/foo || error
846 run_test 26a "multiple component symlink ======================="
849 mkdir -p $DIR/d26b/d26-2
850 ln -s d26b/d26-2/foo $DIR/s26-2
851 touch $DIR/s26-2 || error
853 run_test 26b "multiple component symlink at end of lookup ======"
858 ln -s d26.2 $DIR/s26.2-1
859 ln -s s26.2-1 $DIR/s26.2-2
860 ln -s s26.2-2 $DIR/s26.2-3
861 chmod 0666 $DIR/s26.2-3/foo
863 run_test 26c "chain of symlinks ================================"
865 # recursive symlinks (bug 439)
867 ln -s d26-3/foo $DIR/d26-3
869 run_test 26d "create multiple component recursive symlink ======"
872 [ ! -h $DIR/d26-3 ] && test_26d
875 run_test 26e "unlink multiple component recursive symlink ======"
877 # recursive symlinks (bug 7022)
880 mkdir $DIR/$tdir/$tfile || error "mkdir $DIR/$tdir/$tfile failed"
881 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
882 mkdir -p lndir/bar1 || error "mkdir lndir/bar1 failed"
883 mkdir $tfile || error "mkdir $tfile failed"
884 cd $tfile || error "cd $tfile failed"
885 ln -s .. dotdot || error "ln dotdot failed"
886 ln -s dotdot/lndir lndir || error "ln lndir failed"
887 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
888 output=`ls $tfile/$tfile/lndir/bar1`
889 [ "$output" = bar1 ] && error "unexpected output"
890 rm -r $tfile || error "rm $tfile failed"
891 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
893 run_test 26f "rm -r of a directory which has recursive symlink ="
896 echo '== stripe sanity =============================================='
897 mkdir -p $DIR/d27 || error "mkdir failed"
899 $SETSTRIPE -c 1 $DIR/d27/f0 || error "setstripe failed"
900 $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
902 log "== test_27a: write to one stripe file ========================="
903 cp /etc/hosts $DIR/d27/f0 || error
905 run_test 27a "one stripe file =================================="
908 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
910 $SETSTRIPE -c 2 $DIR/d27/f01 || error "setstripe failed"
911 $GETSTRIPE -c $DIR/d27/f01
912 [ $($GETSTRIPE -c $DIR/d27/f01) -eq 2 ] ||
913 error "two-stripe file doesn't have two stripes"
915 run_test 27b "create two stripe file"
918 [ -f $DIR/d27/f01 ] || skip "test_27b not run" && return
920 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
922 run_test 27c "write to two stripe file"
926 $SETSTRIPE -c 0 -i -1 -S 0 $DIR/d27/fdef || error "setstripe failed"
927 $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
928 dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
930 run_test 27d "create file with default settings ================"
934 $SETSTRIPE -c 2 $DIR/d27/f12 || error "setstripe failed"
935 $SETSTRIPE -c 2 $DIR/d27/f12 && error "setstripe succeeded twice"
936 $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
938 run_test 27e "setstripe existing file (should return error) ======"
942 $SETSTRIPE -S 100 -i 0 -c 1 $DIR/d27/fbad && error "setstripe failed"
943 dd if=/dev/zero of=$DIR/d27/f12 bs=4k count=4 || error "dd failed"
944 $GETSTRIPE $DIR/d27/fbad || error "$GETSTRIPE failed"
946 run_test 27f "setstripe with bad stripe size (should return error)"
950 $MCREATE $DIR/d27/fnone || error "mcreate failed"
951 $GETSTRIPE $DIR/d27/fnone 2>&1 | grep "no stripe info" ||
952 error "$DIR/d27/fnone has object"
954 run_test 27g "$GETSTRIPE with no objects"
957 touch $DIR/d27/fsome || error "touch failed"
958 [ $($GETSTRIPE -c $DIR/d27/fsome) -gt 0 ] || error "missing objects"
960 run_test 27i "$GETSTRIPE with some objects"
964 $SETSTRIPE -i $OSTCOUNT $DIR/d27/f27j && error "setstripe failed"||true
966 run_test 27j "setstripe with bad stripe offset (should return error)"
968 test_27k() { # bug 2844
971 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
972 [ ! -d $DIR/d27 ] && mkdir -p $DIR/d27
973 $SETSTRIPE -S 67108864 $FILE || error "setstripe failed"
974 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
975 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
976 dd if=/dev/zero of=$FILE bs=4k count=1
977 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
978 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
980 run_test 27k "limit i_blksize for broken user apps ============="
984 mcreate $DIR/f27l || error "creating file"
985 $RUNAS $SETSTRIPE -c 1 $DIR/f27l && \
986 error "setstripe should have failed" || true
988 run_test 27l "check setstripe permissions (should return error)"
991 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
992 if [ $ORIGFREE -gt $MAXFREE ]; then
993 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
997 $SETSTRIPE -i 0 -c 1 $DIR/d27/f27m_1
998 dd if=/dev/zero of=$DIR/d27/f27m_1 bs=1024 count=$MAXFREE &&
999 error "dd should fill OST0"
1001 while $SETSTRIPE -i 0 -c 1 $DIR/d27/f27m_$i; do
1003 [ $i -gt 256 ] && break
1006 touch $DIR/d27/f27m_$i
1007 [ `$GETSTRIPE $DIR/d27/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] && \
1008 error "OST0 was full but new created file still use it"
1010 touch $DIR/d27/f27m_$i
1011 [ `$GETSTRIPE $DIR/d27/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] && \
1012 error "OST0 was full but new created file still use it"
1016 run_test 27m "create file while OST0 was full =================="
1019 local DELAY=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage | head -n 1 | awk '{print $1 * 2}')
1023 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1024 # if the OST isn't full anymore.
1026 local OSTIDX=${1:-""}
1028 local list=$(comma_list $(osts_nodes))
1029 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1031 do_nodes $list lctl set_param fail_loc=0
1035 exhaust_precreations() {
1038 local FAILIDX=${3:-$OSTIDX}
1041 local MDSIDX=$(get_mds_dir "$DIR/$tdir")
1042 echo OSTIDX=$OSTIDX MDSIDX=$MDSIDX
1044 local OST=$(ostname_from_index $OSTIDX)
1045 local MDT_INDEX=$(lfs df | grep "\[MDT:$((MDSIDX - 1))\]" | awk '{print $1}' | \
1046 sed -e 's/_UUID$//;s/^.*-//')
1049 local mdtosc_proc1=$(get_mdtosc_proc_path mds${MDSIDX} $OST)
1050 local last_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1051 osc.$mdtosc_proc1.prealloc_last_id)
1052 local next_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1053 osc.$mdtosc_proc1.prealloc_next_id)
1055 local mdtosc_proc2=$(get_mdtosc_proc_path mds${MDSIDX})
1056 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1058 mkdir -p $DIR/$tdir/${OST}
1059 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1060 #define OBD_FAIL_OST_ENOSPC 0x215
1061 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=$FAILIDX
1062 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x215
1063 echo "Creating to objid $last_id on ost $OST..."
1064 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1065 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1066 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=$FAILLOC
1070 exhaust_all_precreations() {
1072 for (( i=0; i < OSTCOUNT; i++ )) ; do
1073 exhaust_precreations $i $1 -1
1078 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1079 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1080 remote_ost_nodsh && skip "remote OST with nodsh" && return
1083 rm -f $DIR/$tdir/$tfile
1084 exhaust_precreations 0 0x80000215
1085 $SETSTRIPE -c -1 $DIR/$tdir
1086 touch $DIR/$tdir/$tfile || error
1087 $GETSTRIPE $DIR/$tdir/$tfile
1090 run_test 27n "create file with some full OSTs =================="
1093 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1094 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1095 remote_ost_nodsh && skip "remote OST with nodsh" && return
1098 rm -f $DIR/$tdir/$tfile
1099 exhaust_all_precreations 0x215
1101 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1106 run_test 27o "create file with all full OSTs (should error) ===="
1109 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1110 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1111 remote_ost_nodsh && skip "remote OST with nodsh" && return
1114 rm -f $DIR/$tdir/$tfile
1117 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1118 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1119 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1121 exhaust_precreations 0 0x80000215
1122 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1123 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1124 $GETSTRIPE $DIR/$tdir/$tfile
1128 run_test 27p "append to a truncated file with some full OSTs ==="
1131 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1132 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1133 remote_ost_nodsh && skip "remote OST with nodsh" && return
1136 rm -f $DIR/$tdir/$tfile
1139 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1140 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||error "truncate $DIR/$tdir/$tfile failed"
1141 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1143 exhaust_all_precreations 0x215
1145 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1146 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1150 run_test 27q "append to truncated file with all OSTs full (should error) ==="
1153 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1154 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1155 remote_ost_nodsh && skip "remote OST with nodsh" && return
1158 rm -f $DIR/$tdir/$tfile
1159 exhaust_precreations 0 0x80000215
1161 $SETSTRIPE -i 0 -c 2 $DIR/$tdir/$tfile # && error
1165 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1167 test_27s() { # bug 10725
1169 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1170 local stripe_count=0
1171 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1172 $SETSTRIPE -S $stripe_size -c $stripe_count $DIR/$tdir &&
1173 error "stripe width >= 2^32 succeeded" || true
1176 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1178 test_27t() { # bug 10864
1183 $WLFS getstripe $tfile
1186 run_test 27t "check that utils parse path correctly"
1188 test_27u() { # bug 4900
1189 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1190 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1192 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1193 do_facet $SINGLEMDS lctl set_param fail_loc=0x139
1195 createmany -o $DIR/$tdir/t- 1000
1196 do_facet $SINGLEMDS lctl set_param fail_loc=0
1198 TLOG=$DIR/$tfile.getstripe
1199 $GETSTRIPE $DIR/$tdir > $TLOG
1200 OBJS=`awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj;}' $TLOG`
1201 unlinkmany $DIR/$tdir/t- 1000
1202 [ $OBJS -gt 0 ] && \
1203 error "$OBJS objects created on OST-0. See $TLOG" || pass
1205 run_test 27u "skip object creation on OSC w/o objects =========="
1207 test_27v() { # bug 4900
1208 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1209 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1210 remote_ost_nodsh && skip "remote OST with nodsh" && return
1212 exhaust_all_precreations 0x215
1216 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1218 touch $DIR/$tdir/$tfile
1219 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1221 for (( i=1; i < OSTCOUNT; i++ )); do
1222 do_facet ost$i lctl set_param fail_loc=0x705
1224 local START=`date +%s`
1225 createmany -o $DIR/$tdir/$tfile 32
1227 local FINISH=`date +%s`
1228 local TIMEOUT=`lctl get_param -n timeout`
1229 local PROCESS=$((FINISH - START))
1230 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1231 error "$FINISH - $START >= $TIMEOUT / 2"
1232 sleep $((TIMEOUT / 2 - PROCESS))
1235 run_test 27v "skip object creation on slow OST ================="
1237 test_27w() { # bug 10997
1238 mkdir -p $DIR/$tdir || error "mkdir failed"
1239 $SETSTRIPE -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1240 [ $($GETSTRIPE -S $DIR/$tdir/f0) -ne 65536 ] &&
1241 error "stripe size $size != 65536" || true
1242 [ $($GETSTRIPE -d $DIR/$tdir | grep -c "stripe_count") -ne 1 ] &&
1243 error "$GETSTRIPE -d $DIR/$tdir failed" || true
1245 run_test 27w "check $SETSTRIPE -S option"
1248 [ "$OSTCOUNT" -lt "2" ] &&
1249 skip_env "skipping multiple stripe count/offset test" && return
1251 mkdir -p $DIR/$tdir || error "mkdir failed"
1252 for i in $(seq 1 $OSTCOUNT); do
1254 $SETSTRIPE -c $i -i $offset $DIR/$tdir/f$i ||
1255 error "setstripe -c $i -i $offset failed"
1256 count=$($GETSTRIPE -c $DIR/$tdir/f$i)
1257 index=$($GETSTRIPE -i $DIR/$tdir/f$i)
1258 [ $count -ne $i ] && error "stripe count $count != $i" || true
1259 [ $index -ne $offset ] &&
1260 error "stripe offset $index != $offset" || true
1263 run_test 27wa "check $SETSTRIPE -c -i options"
1266 remote_ost_nodsh && skip "remote OST with nodsh" && return
1267 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs" && return
1268 OFFSET=$(($OSTCOUNT - 1))
1270 local OST=$(ostname_from_index $OSTIDX)
1273 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe per file
1274 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1276 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1277 for i in `seq 0 $OFFSET`; do
1278 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}' | grep -w "$OSTIDX"` ] &&
1279 error "OST0 was degraded but new created file still use it"
1281 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1283 run_test 27x "create files while OST0 is degraded"
1286 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1287 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1288 remote_ost_nodsh && skip "remote OST with nodsh" && return
1290 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1291 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1292 osc.$mdtosc.prealloc_last_id)
1293 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1294 osc.$mdtosc.prealloc_next_id)
1295 local fcount=$((last_id - next_id))
1296 [ $fcount -eq 0 ] && skip "not enough space on OST0" && return
1297 [ $fcount -gt $OSTCOUNT ] && fcount=$OSTCOUNT
1299 MDS_OSCS=`do_facet $SINGLEMDS lctl dl | awk '/[oO][sS][cC].*md[ts]/ { print $4 }'`
1300 OFFSET=$(($OSTCOUNT-1))
1302 for OSC in $MDS_OSCS; do
1303 if [ $OST == -1 ]; then {
1304 OST=`osc_to_ost $OSC`
1306 echo $OSC "is Deactivate:"
1307 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1311 OSTIDX=$(index_from_ostuuid $OST)
1313 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1315 do_facet ost$((OSTIDX+1)) lctl set_param -n obdfilter.$OST.degraded 1
1317 createmany -o $DIR/$tdir/$tfile $fcount
1318 do_facet ost$((OSTIDX+1)) lctl set_param -n obdfilter.$OST.degraded 0
1320 for i in `seq 0 $OFFSET`; do
1321 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "$OSTIDX"` ] || \
1322 error "files created on deactivated OSTs instead of degraded OST"
1324 for OSC in $MDS_OSCS; do
1325 [ `osc_to_ost $OSC` != $OST ] && {
1326 echo $OSC "is activate"
1327 do_facet $SINGLEMDS lctl --device %$OSC activate
1331 run_test 27y "create files while OST0 is degraded and the rest inactive"
1337 lmm_count=$($GETSTRIPE -c $1)
1338 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1339 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1341 local old_ifs="$IFS"
1343 fid=($($LFS path2fid $1))
1346 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1347 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1349 # compare lmm_seq and lu_fid->f_seq
1350 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1351 # compare lmm_object_id and lu_fid->oid
1352 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1354 # check the trusted.fid attribute of the OST objects of the file
1355 local have_obdidx=false
1357 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1358 # skip lines up to and including "obdidx"
1359 [ -z "$obdidx" ] && break
1360 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1361 $have_obdidx || continue
1363 local ost=$((obdidx + 1))
1364 local dev=$(ostdevname $ost)
1366 if [ $(facet_fstype ost$ost) != ldiskfs ]; then
1367 echo "Currently only works with ldiskfs-based OSTs"
1371 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1373 #don't unmount/remount the OSTs if we don't need to do that
1374 #local dir=$(facet_mntpt ost$ost)
1376 #do_facet ost$dev mount -t $FSTYPE $dev $dir $OST_MOUNT_OPTS ||
1377 # { error "mounting $dev as $FSTYPE failed"; return 3; }
1378 #local obj_file=$(do_facet ost$ost find $dir/O/$seq -name $oid)
1379 #local ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID $obj_file)
1381 local obj_file="O/$seq/d$((oid %32))/$oid"
1382 local ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
1383 $dev 2>/dev/null" | grep "parent=")
1385 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
1387 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
1389 #do_facet ost$ost umount -d $dir
1390 #start ost$ost $dev $OST_MOUNT_OPTS
1392 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
1393 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
1394 local ff_parent=$(echo $ff|sed -e 's/.*parent=.//')
1395 local ff_pseq=$(echo $ff_parent | cut -d: -f1)
1396 local ff_poid=$(echo $ff_parent | cut -d: -f2)
1397 local ff_pstripe=$(echo $ff_parent | sed -e 's/.*stripe=//')
1399 # compare lmm_seq and filter_fid->ff_parent.f_seq
1400 [ $ff_pseq = $lmm_seq ] ||
1401 error "FF parent SEQ $ff_pseq != $lmm_seq"
1402 # compare lmm_object_id and filter_fid->ff_parent.f_oid
1403 [ $ff_poid = $lmm_oid ] ||
1404 error "FF parent OID $ff_poid != $lmm_oid"
1405 [ $ff_pstripe = $stripe_nr ] ||
1406 error "FF stripe $ff_pstripe != $stripe_nr"
1408 stripe_nr=$((stripe_nr + 1))
1413 remote_ost_nodsh && skip "remote OST with nodsh" && return
1416 $SETSTRIPE -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
1417 { error "setstripe -c -1 failed"; return 1; }
1418 # We need to send a write to every object to get parent FID info set.
1419 # This _should_ also work for setattr, but does not currently.
1420 # touch $DIR/$tdir/$tfile-1 ||
1421 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
1422 { error "dd $tfile-1 failed"; return 2; }
1423 $SETSTRIPE -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
1424 { error "setstripe -c -1 failed"; return 3; }
1425 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
1426 { error "dd $tfile-2 failed"; return 4; }
1428 # make sure write RPCs have been sent to OSTs
1431 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
1432 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
1434 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
1436 test_27A() { # b=19102
1437 local restore_size=$($GETSTRIPE -S $MOUNT)
1438 local restore_count=$($GETSTRIPE -c $MOUNT)
1439 local restore_offset=$($GETSTRIPE -i $MOUNT)
1440 $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
1441 local default_size=$($GETSTRIPE -S $MOUNT)
1442 local default_count=$($GETSTRIPE -c $MOUNT)
1443 local default_offset=$($GETSTRIPE -i $MOUNT)
1444 local dsize=$((1024 * 1024))
1445 [ $default_size -eq $dsize ] ||
1446 error "stripe size $default_size != $dsize"
1447 [ $default_count -eq 1 ] || error "stripe count $default_count != 1"
1448 [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
1449 $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
1451 run_test 27A "check filesystem-wide default LOV EA values"
1453 # createtest also checks that device nodes are created and
1454 # then visible correctly (#2091)
1455 test_28() { # bug 2091
1457 $CREATETEST $DIR/d28/ct || error
1459 run_test 28 "create/mknod/mkdir with bad file types ============"
1462 cancel_lru_locks mdc
1468 declare -i LOCKCOUNTORIG=0
1469 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1470 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
1472 [ $LOCKCOUNTORIG -eq 0 ] && echo "No mdc lock count" && return 1
1474 declare -i LOCKUNUSEDCOUNTORIG=0
1475 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1476 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
1483 declare -i LOCKCOUNTCURRENT=0
1484 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1485 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
1488 declare -i LOCKUNUSEDCOUNTCURRENT=0
1489 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1490 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
1493 if [ "$LOCKCOUNTCURRENT" -gt "$LOCKCOUNTORIG" ]; then
1494 lctl set_param -n ldlm.dump_namespaces ""
1495 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
1496 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1497 log "dumped log to $TMP/test_29.dk (bug 5793)"
1500 if [ "$LOCKUNUSEDCOUNTCURRENT" -gt "$LOCKUNUSEDCOUNTORIG" ]; then
1501 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
1502 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1503 log "dumped log to $TMP/test_29.dk (bug 5793)"
1507 run_test 29 "IT_GETATTR regression ============================"
1509 test_30a() { # was test_30
1510 cp `which ls` $DIR || cp /bin/ls $DIR
1514 run_test 30a "execute binary from Lustre (execve) =============="
1517 cp `which ls` $DIR || cp /bin/ls $DIR
1519 $RUNAS $DIR/ls / || error
1522 run_test 30b "execute binary from Lustre as non-root ==========="
1524 test_30c() { # b=22376
1525 cp `which ls` $DIR || cp /bin/ls $DIR
1527 cancel_lru_locks mdc
1528 cancel_lru_locks osc
1529 $RUNAS $DIR/ls / || error
1532 run_test 30c "execute binary from Lustre without read perms ===="
1535 $OPENUNLINK $DIR/f31 $DIR/f31 || error
1536 $CHECKSTAT -a $DIR/f31 || error
1538 run_test 31a "open-unlink file =================================="
1541 touch $DIR/f31 || error
1542 ln $DIR/f31 $DIR/f31b || error
1543 $MULTIOP $DIR/f31b Ouc || error
1544 $CHECKSTAT -t file $DIR/f31 || error
1546 run_test 31b "unlink file with multiple links while open ======="
1549 touch $DIR/f31 || error
1550 ln $DIR/f31 $DIR/f31c || error
1551 multiop_bg_pause $DIR/f31 O_uc || return 1
1553 $MULTIOP $DIR/f31c Ouc
1554 kill -USR1 $MULTIPID
1557 run_test 31c "open-unlink file with multiple links ============="
1560 opendirunlink $DIR/d31d $DIR/d31d || error
1561 $CHECKSTAT -a $DIR/d31d || error
1563 run_test 31d "remove of open directory ========================="
1565 test_31e() { # bug 2904
1566 check_kernel_version 34 || return 0
1567 openfilleddirunlink $DIR/d31e || error
1569 run_test 31e "remove of open non-empty directory ==============="
1571 test_31f() { # bug 4554
1574 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
1575 cp /etc/hosts $DIR/d31f
1577 $GETSTRIPE $DIR/d31f/hosts
1578 multiop_bg_pause $DIR/d31f D_c || return 1
1581 rm -rv $DIR/d31f || error "first of $DIR/d31f"
1583 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
1584 cp /etc/hosts $DIR/d31f
1586 $GETSTRIPE $DIR/d31f/hosts
1587 multiop_bg_pause $DIR/d31f D_c || return 1
1590 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
1591 wait $MULTIPID || error "first opendir $MULTIPID failed"
1595 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
1596 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
1599 run_test 31f "remove of open directory with open-unlink file ==="
1602 echo "-- cross directory link --"
1603 mkdir $DIR/d31g{a,b}
1605 ln $DIR/d31ga/f $DIR/d31gb/g
1606 $CHECKSTAT -t file $DIR/d31ga/f || error "source"
1607 [ `stat -c%h $DIR/d31ga/f` == '2' ] || error "source nlink"
1608 $CHECKSTAT -t file $DIR/d31gb/g || error "target"
1609 [ `stat -c%h $DIR/d31gb/g` == '2' ] || error "target nlink"
1611 run_test 31g "cross directory link==============="
1614 echo "-- cross directory link --"
1618 ln $DIR/d31h/f $DIR/d31h/dir/g
1619 $CHECKSTAT -t file $DIR/d31h/f || error "source"
1620 [ `stat -c%h $DIR/d31h/f` == '2' ] || error "source nlink"
1621 $CHECKSTAT -t file $DIR/d31h/dir/g || error "target"
1622 [ `stat -c%h $DIR/d31h/dir/g` == '2' ] || error "target nlink"
1624 run_test 31h "cross directory link under child==============="
1627 echo "-- cross directory link --"
1630 touch $DIR/d31i/dir/f
1631 ln $DIR/d31i/dir/f $DIR/d31i/g
1632 $CHECKSTAT -t file $DIR/d31i/dir/f || error "source"
1633 [ `stat -c%h $DIR/d31i/dir/f` == '2' ] || error "source nlink"
1634 $CHECKSTAT -t file $DIR/d31i/g || error "target"
1635 [ `stat -c%h $DIR/d31i/g` == '2' ] || error "target nlink"
1637 run_test 31i "cross directory link under parent==============="
1642 mkdir $DIR/d31j/dir1
1643 ln $DIR/d31j/dir1 $DIR/d31j/dir2 && error "ln for dir"
1644 link $DIR/d31j/dir1 $DIR/d31j/dir3 && error "link for dir"
1645 mlink $DIR/d31j/dir1 $DIR/d31j/dir4 && error "mlink for dir"
1646 mlink $DIR/d31j/dir1 $DIR/d31j/dir1 && error "mlink to the same dir"
1649 run_test 31j "link for directory==============="
1655 touch $DIR/d31k/exist
1656 mlink $DIR/d31k/s $DIR/d31k/t || error "mlink"
1657 mlink $DIR/d31k/s $DIR/d31k/exist && error "mlink to exist file"
1658 mlink $DIR/d31k/s $DIR/d31k/s && error "mlink to the same file"
1659 mlink $DIR/d31k/s $DIR/d31k && error "mlink to parent dir"
1660 mlink $DIR/d31k $DIR/d31k/s && error "mlink parent dir to target"
1661 mlink $DIR/d31k/not-exist $DIR/d31k/foo && error "mlink non-existing to new"
1662 mlink $DIR/d31k/not-exist $DIR/d31k/s && error "mlink non-existing to exist"
1665 run_test 31k "link to file: the same, non-existing, dir==============="
1671 touch $DIR/d31m2/exist
1672 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
1673 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
1674 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
1675 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
1676 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
1677 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
1680 run_test 31m "link to file: the same, non-existing, dir==============="
1683 echo "== more mountpoints and symlinks ================="
1684 [ -e $DIR/d32a ] && rm -fr $DIR/d32a
1685 mkdir -p $DIR/d32a/ext2-mountpoint
1686 mount -t ext2 -o loop $EXT2_DEV $DIR/d32a/ext2-mountpoint || error
1687 $CHECKSTAT -t dir $DIR/d32a/ext2-mountpoint/.. || error
1688 $UMOUNT $DIR/d32a/ext2-mountpoint || error
1690 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
1693 [ -e $DIR/d32b ] && rm -fr $DIR/d32b
1694 mkdir -p $DIR/d32b/ext2-mountpoint
1695 mount -t ext2 -o loop $EXT2_DEV $DIR/d32b/ext2-mountpoint || error
1696 ls -al $DIR/d32b/ext2-mountpoint/.. || error
1697 $UMOUNT $DIR/d32b/ext2-mountpoint || error
1699 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
1702 [ -e $DIR/d32c ] && rm -fr $DIR/d32c
1703 mkdir -p $DIR/d32c/ext2-mountpoint
1704 mount -t ext2 -o loop $EXT2_DEV $DIR/d32c/ext2-mountpoint || error
1705 mkdir -p $DIR/d32c/d2/test_dir
1706 $CHECKSTAT -t dir $DIR/d32c/ext2-mountpoint/../d2/test_dir || error
1707 $UMOUNT $DIR/d32c/ext2-mountpoint || error
1709 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
1712 [ -e $DIR/d32d ] && rm -fr $DIR/d32d
1713 mkdir -p $DIR/d32d/ext2-mountpoint
1714 mount -t ext2 -o loop $EXT2_DEV $DIR/d32d/ext2-mountpoint || error
1715 mkdir -p $DIR/d32d/d2/test_dir
1716 ls -al $DIR/d32d/ext2-mountpoint/../d2/test_dir || error
1717 $UMOUNT $DIR/d32d/ext2-mountpoint || error
1719 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
1722 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
1723 mkdir -p $DIR/d32e/tmp
1724 TMP_DIR=$DIR/d32e/tmp
1725 ln -s $DIR/d32e $TMP_DIR/symlink11
1726 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1727 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
1728 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
1730 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
1733 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
1734 mkdir -p $DIR/d32f/tmp
1735 TMP_DIR=$DIR/d32f/tmp
1736 ln -s $DIR/d32f $TMP_DIR/symlink11
1737 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1738 ls $DIR/d32f/tmp/symlink11 || error
1739 ls $DIR/d32f/symlink01 || error
1741 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
1744 TMP_DIR=$DIR/$tdir/tmp
1745 mkdir -p $TMP_DIR $DIR/${tdir}2
1746 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
1747 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1748 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
1749 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
1750 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
1751 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
1753 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
1756 rm -fr $DIR/$tdir $DIR/${tdir}2
1757 TMP_DIR=$DIR/$tdir/tmp
1758 mkdir -p $TMP_DIR $DIR/${tdir}2
1759 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
1760 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1761 ls $TMP_DIR/symlink12 || error
1762 ls $DIR/$tdir/symlink02 || error
1764 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
1767 [ -e $DIR/d32i ] && rm -fr $DIR/d32i
1768 mkdir -p $DIR/d32i/ext2-mountpoint
1769 mount -t ext2 -o loop $EXT2_DEV $DIR/d32i/ext2-mountpoint || error
1770 touch $DIR/d32i/test_file
1771 $CHECKSTAT -t file $DIR/d32i/ext2-mountpoint/../test_file || error
1772 $UMOUNT $DIR/d32i/ext2-mountpoint || error
1774 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
1777 [ -e $DIR/d32j ] && rm -fr $DIR/d32j
1778 mkdir -p $DIR/d32j/ext2-mountpoint
1779 mount -t ext2 -o loop $EXT2_DEV $DIR/d32j/ext2-mountpoint || error
1780 touch $DIR/d32j/test_file
1781 cat $DIR/d32j/ext2-mountpoint/../test_file || error
1782 $UMOUNT $DIR/d32j/ext2-mountpoint || error
1784 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
1788 mkdir -p $DIR/d32k/ext2-mountpoint
1789 mount -t ext2 -o loop $EXT2_DEV $DIR/d32k/ext2-mountpoint
1790 mkdir -p $DIR/d32k/d2
1791 touch $DIR/d32k/d2/test_file || error
1792 $CHECKSTAT -t file $DIR/d32k/ext2-mountpoint/../d2/test_file || error
1793 $UMOUNT $DIR/d32k/ext2-mountpoint || error
1795 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
1799 mkdir -p $DIR/d32l/ext2-mountpoint
1800 mount -t ext2 -o loop $EXT2_DEV $DIR/d32l/ext2-mountpoint || error
1801 mkdir -p $DIR/d32l/d2
1802 touch $DIR/d32l/d2/test_file
1803 cat $DIR/d32l/ext2-mountpoint/../d2/test_file || error
1804 $UMOUNT $DIR/d32l/ext2-mountpoint || error
1806 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
1810 mkdir -p $DIR/d32m/tmp
1811 TMP_DIR=$DIR/d32m/tmp
1812 ln -s $DIR $TMP_DIR/symlink11
1813 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1814 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
1815 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
1817 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
1821 mkdir -p $DIR/d32n/tmp
1822 TMP_DIR=$DIR/d32n/tmp
1823 ln -s $DIR $TMP_DIR/symlink11
1824 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1825 ls -l $DIR/d32n/tmp/symlink11 || error
1826 ls -l $DIR/d32n/symlink01 || error
1828 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
1831 rm -fr $DIR/d32o $DIR/$tfile
1833 mkdir -p $DIR/d32o/tmp
1834 TMP_DIR=$DIR/d32o/tmp
1835 ln -s $DIR/$tfile $TMP_DIR/symlink12
1836 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1837 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
1838 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
1839 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
1840 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
1842 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
1852 mkdir -p $DIR/d32p/tmp
1854 TMP_DIR=$DIR/d32p/tmp
1856 ln -s $DIR/$tfile $TMP_DIR/symlink12
1858 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1860 cat $DIR/d32p/tmp/symlink12 || error
1862 cat $DIR/d32p/symlink02 || error
1865 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
1868 [ -e $DIR/d32q ] && rm -fr $DIR/d32q
1870 touch $DIR/d32q/under_the_mount
1871 mount -t ext2 -o loop $EXT2_DEV $DIR/d32q
1872 ls $DIR/d32q/under_the_mount && error || true
1873 $UMOUNT $DIR/d32q || error
1875 run_test 32q "stat follows mountpoints in Lustre (should return error)"
1878 [ -e $DIR/d32r ] && rm -fr $DIR/d32r
1880 touch $DIR/d32r/under_the_mount
1881 mount -t ext2 -o loop $EXT2_DEV $DIR/d32r
1882 ls $DIR/d32r | grep -q under_the_mount && error || true
1883 $UMOUNT $DIR/d32r || error
1885 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
1890 chmod 444 $DIR/$tfile
1891 chown $RUNAS_ID $DIR/$tfile
1893 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
1896 run_test 33 "write file with mode 444 (should return error) ===="
1901 chown $RUNAS_ID $DIR/d33
1902 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
1903 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
1904 error "open RDWR" || true
1906 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
1911 chown $RUNAS_ID $DIR/d33
1912 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33 && error "create" || true
1914 run_test 33b "test open file with malformed flags (No panic and return error)"
1922 remote_ost_nodsh && skip "remote OST with nodsh" && return
1926 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
1929 for ostnum in $(seq $OSTCOUNT); do
1930 # test-framework's OST numbering is one-based, while Lustre's
1932 ostname=$(printf "$FSNAME-OST%.4d" $((ostnum - 1)))
1933 # Parsing llobdstat's output sucks; we could grep the /proc
1934 # path, but that's likely to not be as portable as using the
1935 # llobdstat utility. So we parse lctl output instead.
1936 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
1937 obdfilter/$ostname/stats |
1938 awk '/^write_bytes/ {print $7}' )
1939 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
1940 if (( ${write_bytes:-0} > 0 ))
1947 $all_zeros || return 0
1950 echo foo > $DIR/d33/bar
1954 # Total up write_bytes after writing. We'd better find non-zeros.
1955 for ostnum in $(seq $OSTCOUNT); do
1956 ostname=$(printf "$FSNAME-OST%.4d" $((ostnum - 1)))
1957 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
1958 obdfilter/$ostname/stats |
1959 awk '/^write_bytes/ {print $7}' )
1960 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
1961 if (( ${write_bytes:-0} > 0 ))
1970 for ostnum in $(seq $OSTCOUNT); do
1971 ostname=$(printf "$FSNAME-OST%.4d" $((ostnum - 1)))
1972 echo "Check that write_bytes is present in obdfilter/*/stats:"
1973 do_facet ost$ostnum lctl get_param -n \
1974 obdfilter/$ostname/stats
1976 error "OST not keeping write_bytes stats (b22312)"
1979 run_test 33c "test llobdstat and write_bytes"
1981 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
1984 $MCREATE $DIR/f34 || error
1985 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
1986 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
1987 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
1988 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1990 run_test 34a "truncate file that has not been opened ==========="
1993 [ ! -f $DIR/f34 ] && test_34a
1994 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1995 $OPENFILE -f O_RDONLY $DIR/f34
1996 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
1997 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1999 run_test 34b "O_RDONLY opening file doesn't create objects ====="
2002 [ ! -f $DIR/f34 ] && test_34a
2003 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2004 $OPENFILE -f O_RDWR $DIR/f34
2005 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2006 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2008 run_test 34c "O_RDWR opening file-with-size works =============="
2011 [ ! -f $DIR/f34 ] && test_34a
2012 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2013 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2016 run_test 34d "write to sparse file ============================="
2020 $MCREATE $DIR/f34e || error
2021 $TRUNCATE $DIR/f34e 1000 || error
2022 $CHECKSTAT -s 1000 $DIR/f34e || error
2023 $OPENFILE -f O_RDWR $DIR/f34e
2024 $CHECKSTAT -s 1000 $DIR/f34e || error
2026 run_test 34e "create objects, some with size and some without =="
2028 test_34f() { # bug 6242, 6243
2031 $MCREATE $DIR/f34f || error
2032 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
2033 dd if=$DIR/f34f of=$TMP/f34f
2034 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
2035 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
2036 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
2037 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
2038 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
2040 run_test 34f "read from a file with no objects until EOF ======="
2043 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
2044 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
2045 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
2046 cancel_lru_locks osc
2047 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
2048 error "wrong size after lock cancel"
2050 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
2051 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2052 error "expanding truncate failed"
2053 cancel_lru_locks osc
2054 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2055 error "wrong expanded size after lock cancel"
2057 run_test 34g "truncate long file ==============================="
2063 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
2064 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
2068 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
2069 error "Multiop blocked on ftruncate, pid=$MULTIPID"
2073 local nsz=`stat -c %s $DIR/$tfile`
2074 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
2076 run_test 34h "ftruncate file under grouplock should not block"
2079 cp /bin/sh $DIR/f35a
2081 chown $RUNAS_ID $DIR/f35a
2082 $RUNAS $DIR/f35a && error || true
2085 run_test 35a "exec file with mode 444 (should return and not leak) ====="
2089 utime $DIR/f36 || error
2091 run_test 36a "MDS utime check (mknod, utime) ==================="
2095 utime $DIR/f36 || error
2097 run_test 36b "OST utime check (open, utime) ===================="
2102 chown $RUNAS_ID $DIR/d36
2103 $RUNAS utime $DIR/d36/f36 || error
2105 run_test 36c "non-root MDS utime check (mknod, utime) =========="
2108 [ ! -d $DIR/d36 ] && test_36c
2109 echo "" > $DIR/d36/f36
2110 $RUNAS utime $DIR/d36/f36 || error
2112 run_test 36d "non-root OST utime check (open, utime) ==========="
2115 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
2117 touch $DIR/$tdir/$tfile
2118 $RUNAS utime $DIR/$tdir/$tfile && \
2119 error "utime worked, expected failure" || true
2121 run_test 36e "utime on non-owned file (should return error) ===="
2125 local LANG_SAVE=$LANG
2126 local LC_LANG_SAVE=$LC_LANG
2127 export LANG=C LC_LANG=C # for date language
2129 DATESTR="Dec 20 2000"
2131 lctl set_param fail_loc=$fl
2133 cp /etc/hosts $DIR/$tdir/$tfile
2134 sync & # write RPC generated with "current" inode timestamp, but delayed
2136 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
2137 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
2138 cancel_lru_locks osc
2139 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
2141 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
2142 echo "BEFORE: $LS_BEFORE" && \
2143 echo "AFTER : $LS_AFTER" && \
2144 echo "WANT : $DATESTR" && \
2145 error "$DIR/$tdir/$tfile timestamps changed" || true
2147 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
2151 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2152 subr_36fh "0x80000214"
2154 run_test 36f "utime on file racing with OST BRW write =========="
2157 remote_ost_nodsh && skip "remote OST with nodsh" && return
2163 fmd_max_age=$(do_facet ost1 \
2164 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
2167 fmd_before=$(do_facet ost1 \
2168 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2169 touch $DIR/$tdir/$tfile
2170 sleep $((fmd_max_age + 12))
2171 fmd_after=$(do_facet ost1 \
2172 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2174 echo "fmd_before: $fmd_before"
2175 echo "fmd_after: $fmd_after"
2176 [ "$fmd_after" -gt "$fmd_before" ] && \
2177 echo "AFTER: $fmd_after > BEFORE: $fmd_before" && \
2178 error "fmd didn't expire after ping" || true
2180 run_test 36g "filter mod data cache expiry ====================="
2183 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
2184 subr_36fh "0x80000227"
2186 run_test 36h "utime on file racing with OST BRW write =========="
2190 echo f > $DIR/$tdir/fbugfile
2191 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2192 ls $DIR/$tdir | grep "\<fbugfile\>" && error
2193 $UMOUNT $DIR/$tdir || error
2194 rm -f $DIR/$tdir/fbugfile || error
2196 run_test 37 "ls a mounted file system to check old content ====="
2199 local file=$DIR/$tfile
2201 openfile -f O_DIRECTORY $file
2204 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
2205 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
2207 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
2211 touch $DIR/${tfile}2
2212 # ls -l $DIR/$tfile $DIR/${tfile}2
2213 # ls -lu $DIR/$tfile $DIR/${tfile}2
2214 # ls -lc $DIR/$tfile $DIR/${tfile}2
2216 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
2217 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
2219 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
2221 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
2223 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
2224 error "O_TRUNC didn't change timestamps"
2227 run_test 39 "mtime changed on create ==========================="
2231 cp -p /etc/passwd $DIR/$tdir/fopen
2232 cp -p /etc/passwd $DIR/$tdir/flink
2233 cp -p /etc/passwd $DIR/$tdir/funlink
2234 cp -p /etc/passwd $DIR/$tdir/frename
2235 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
2238 echo "aaaaaa" >> $DIR/$tdir/fopen
2239 echo "aaaaaa" >> $DIR/$tdir/flink
2240 echo "aaaaaa" >> $DIR/$tdir/funlink
2241 echo "aaaaaa" >> $DIR/$tdir/frename
2243 local open_new=`stat -c %Y $DIR/$tdir/fopen`
2244 local link_new=`stat -c %Y $DIR/$tdir/flink`
2245 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
2246 local rename_new=`stat -c %Y $DIR/$tdir/frename`
2248 cat $DIR/$tdir/fopen > /dev/null
2249 ln $DIR/$tdir/flink $DIR/$tdir/flink2
2250 rm -f $DIR/$tdir/funlink2
2251 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
2253 for (( i=0; i < 2; i++ )) ; do
2254 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
2255 local link_new2=`stat -c %Y $DIR/$tdir/flink`
2256 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
2257 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
2259 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
2260 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
2261 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
2262 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
2264 cancel_lru_locks osc
2265 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2268 run_test 39b "mtime change on open, link, unlink, rename ======"
2270 # this should be set to past
2271 TEST_39_MTIME=`date -d "1 year ago" +%s`
2277 local mtime0=`stat -c %Y $DIR1/$tfile`
2279 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2280 local mtime1=`stat -c %Y $DIR1/$tfile`
2281 [ "$mtime1" = $TEST_39_MTIME ] || \
2282 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
2285 echo hello >> $DIR1/$tfile
2287 local mtime2=`stat -c %Y $DIR1/$tfile`
2288 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
2289 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
2291 mv $DIR1/$tfile $DIR1/$tfile-1
2293 for (( i=0; i < 2; i++ )) ; do
2294 local mtime3=`stat -c %Y $DIR1/$tfile-1`
2295 [ "$mtime2" = "$mtime3" ] || \
2296 error "mtime ($mtime2) changed (to $mtime3) on rename"
2298 cancel_lru_locks osc
2299 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2302 run_test 39c "mtime change on rename ==========================="
2308 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2310 for (( i=0; i < 2; i++ )) ; do
2311 local mtime=`stat -c %Y $DIR1/$tfile`
2312 [ $mtime = $TEST_39_MTIME ] || \
2313 error "mtime($mtime) is not set to $TEST_39_MTIME"
2315 cancel_lru_locks osc
2316 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2319 run_test 39d "create, utime, stat =============================="
2324 local mtime1=`stat -c %Y $DIR1/$tfile`
2326 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2328 for (( i=0; i < 2; i++ )) ; do
2329 local mtime2=`stat -c %Y $DIR1/$tfile`
2330 [ $mtime2 = $TEST_39_MTIME ] || \
2331 error "mtime($mtime2) is not set to $TEST_39_MTIME"
2333 cancel_lru_locks osc
2334 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2337 run_test 39e "create, stat, utime, stat ========================"
2342 mtime1=`stat -c %Y $DIR1/$tfile`
2345 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2347 for (( i=0; i < 2; i++ )) ; do
2348 local mtime2=`stat -c %Y $DIR1/$tfile`
2349 [ $mtime2 = $TEST_39_MTIME ] || \
2350 error "mtime($mtime2) is not set to $TEST_39_MTIME"
2352 cancel_lru_locks osc
2353 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2356 run_test 39f "create, stat, sleep, utime, stat ================="
2360 echo hello >> $DIR1/$tfile
2361 local mtime1=`stat -c %Y $DIR1/$tfile`
2364 chmod o+r $DIR1/$tfile
2366 for (( i=0; i < 2; i++ )) ; do
2367 local mtime2=`stat -c %Y $DIR1/$tfile`
2368 [ "$mtime1" = "$mtime2" ] || \
2369 error "lost mtime: $mtime2, should be $mtime1"
2371 cancel_lru_locks osc
2372 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2375 run_test 39g "write, chmod, stat ==============================="
2383 echo hello >> $DIR1/$tfile
2384 local mtime1=`stat -c %Y $DIR1/$tfile`
2386 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2388 if [ "$d1" != "$d2" ]; then
2389 echo "write and touch not within one second"
2391 for (( i=0; i < 2; i++ )) ; do
2392 local mtime2=`stat -c %Y $DIR1/$tfile`
2393 [ "$mtime2" = $TEST_39_MTIME ] || \
2394 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
2396 cancel_lru_locks osc
2397 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2401 run_test 39h "write, utime within one second, stat ============="
2407 echo hello >> $DIR1/$tfile
2408 local mtime1=`stat -c %Y $DIR1/$tfile`
2410 mv $DIR1/$tfile $DIR1/$tfile-1
2412 for (( i=0; i < 2; i++ )) ; do
2413 local mtime2=`stat -c %Y $DIR1/$tfile-1`
2415 [ "$mtime1" = "$mtime2" ] || \
2416 error "lost mtime: $mtime2, should be $mtime1"
2418 cancel_lru_locks osc
2419 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2422 run_test 39i "write, rename, stat =============================="
2425 start_full_debug_logging
2429 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
2431 local mtime1=`stat -c %Y $DIR1/$tfile`
2433 mv $DIR1/$tfile $DIR1/$tfile-1
2435 kill -USR1 $multipid
2436 wait $multipid || error "multiop close failed"
2438 for (( i=0; i < 2; i++ )) ; do
2439 local mtime2=`stat -c %Y $DIR1/$tfile-1`
2440 [ "$mtime1" = "$mtime2" ] || \
2441 error "mtime is lost on close: $mtime2, should be $mtime1"
2443 cancel_lru_locks osc
2444 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2446 stop_full_debug_logging
2448 run_test 39j "write, rename, close, stat ======================="
2454 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
2456 local mtime1=`stat -c %Y $DIR1/$tfile`
2458 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2460 kill -USR1 $multipid
2461 wait $multipid || error "multiop close failed"
2463 for (( i=0; i < 2; i++ )) ; do
2464 local mtime2=`stat -c %Y $DIR1/$tfile`
2466 [ "$mtime2" = $TEST_39_MTIME ] || \
2467 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
2469 cancel_lru_locks osc
2470 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2473 run_test 39k "write, utime, close, stat ========================"
2475 # this should be set to future
2476 TEST_39_ATIME=`date -d "1 year" +%s`
2479 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2480 local atime_diff=$(do_facet $SINGLEMDS lctl get_param -n mdd.*.atime_diff)
2484 # test setting directory atime to future
2485 touch -a -d @$TEST_39_ATIME $DIR/$tdir
2486 local atime=$(stat -c %X $DIR/$tdir)
2487 [ "$atime" = $TEST_39_ATIME ] || \
2488 error "atime is not set to future: $atime, should be $TEST_39_ATIME"
2490 # test setting directory atime from future to now
2491 local d1=$(date +%s)
2493 local d2=$(date +%s)
2495 cancel_lru_locks mdc
2496 atime=$(stat -c %X $DIR/$tdir)
2497 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
2498 error "atime is not updated from future: $atime, should be $d1<atime<$d2"
2500 do_facet $SINGLEMDS lctl set_param -n mdd.*.atime_diff=2
2503 # test setting directory atime when now > dir atime + atime_diff
2507 cancel_lru_locks mdc
2508 atime=$(stat -c %X $DIR/$tdir)
2509 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
2510 error "atime is not updated : $atime, should be $d2"
2512 do_facet $SINGLEMDS lctl set_param -n mdd.*.atime_diff=60
2515 # test not setting directory atime when now < dir atime + atime_diff
2517 cancel_lru_locks mdc
2518 atime=$(stat -c %X $DIR/$tdir)
2519 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
2520 error "atime is updated to $atime, should remain $d1<atime<$d2"
2522 do_facet $SINGLEMDS lctl set_param -n mdd.*.atime_diff=$atime_diff
2524 run_test 39l "directory atime update ==========================="
2529 local far_past_mtime=$(date -d "May 29 1953" +%s)
2530 local far_past_atime=$(date -d "Dec 17 1903" +%s)
2532 touch -m -d @$far_past_mtime $DIR1/$tfile
2533 touch -a -d @$far_past_atime $DIR1/$tfile
2535 for (( i=0; i < 2; i++ )) ; do
2536 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
2537 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
2538 error "atime or mtime set incorrectly"
2540 cancel_lru_locks osc
2541 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2544 run_test 39m "test atime and mtime before 1970"
2547 dd if=/dev/zero of=$DIR/f40 bs=4096 count=1
2548 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/f40 && error
2549 $CHECKSTAT -t file -s 4096 $DIR/f40 || error
2551 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
2555 small_write $DIR/f41 18
2557 run_test 41 "test small file write + fstat ====================="
2559 count_ost_writes() {
2560 lctl get_param -n osc.*.stats |
2561 awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }'
2568 BG_DIRTY_RATIO_SAVE=10
2569 MAX_BG_DIRTY_RATIO=25
2573 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
2574 # dirty_ratio, dirty_background_ratio
2575 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
2576 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
2577 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
2578 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
2580 # if file not here, we are a 2.4 kernel
2581 kill -CONT `pidof kupdated`
2586 # setup the trap first, so someone cannot exit the test at the
2587 # exact wrong time and mess up a machine
2588 trap start_writeback EXIT
2589 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
2590 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
2591 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
2592 sysctl -w vm.dirty_writeback_centisecs=0
2593 sysctl -w vm.dirty_writeback_centisecs=0
2594 # save and increase /proc/sys/vm/dirty_ratio
2595 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
2596 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
2597 # save and increase /proc/sys/vm/dirty_background_ratio
2598 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
2599 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
2601 # if file not here, we are a 2.4 kernel
2602 kill -STOP `pidof kupdated`
2606 # ensure that all stripes have some grant before we test client-side cache
2608 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
2609 dd if=/dev/zero of=$i bs=4k count=1
2614 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
2615 # file truncation, and file removal.
2618 cancel_lru_locks osc
2620 sync; sleep 1; sync # just to be safe
2621 BEFOREWRITES=`count_ost_writes`
2622 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
2623 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
2624 AFTERWRITES=`count_ost_writes`
2625 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
2626 error "$BEFOREWRITES < $AFTERWRITES"
2629 run_test 42a "ensure that we don't flush on close =============="
2633 cancel_lru_locks osc
2636 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
2637 BEFOREWRITES=`count_ost_writes`
2638 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
2639 AFTERWRITES=`count_ost_writes`
2640 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
2641 error "$BEFOREWRITES < $AFTERWRITES on unlink"
2643 BEFOREWRITES=`count_ost_writes`
2644 sync || error "sync: $?"
2645 AFTERWRITES=`count_ost_writes`
2646 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
2647 error "$BEFOREWRITES < $AFTERWRITES on sync"
2649 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
2653 run_test 42b "test destroy of file with cached dirty data ======"
2655 # if these tests just want to test the effect of truncation,
2656 # they have to be very careful. consider:
2657 # - the first open gets a {0,EOF}PR lock
2658 # - the first write conflicts and gets a {0, count-1}PW
2659 # - the rest of the writes are under {count,EOF}PW
2660 # - the open for truncate tries to match a {0,EOF}PR
2661 # for the filesize and cancels the PWs.
2662 # any number of fixes (don't get {0,EOF} on open, match
2663 # composite locks, do smarter file size management) fix
2664 # this, but for now we want these tests to verify that
2665 # the cancellation with truncate intent works, so we
2666 # start the file with a full-file pw lock to match against
2667 # until the truncate.
2672 cancel_lru_locks osc
2674 # prime the file with 0,EOF PW to match
2678 # now the real test..
2679 dd if=/dev/zero of=$file bs=1024 count=100
2680 BEFOREWRITES=`count_ost_writes`
2681 $TRUNCATE $file $offset
2682 cancel_lru_locks osc
2683 AFTERWRITES=`count_ost_writes`
2689 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
2690 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
2693 run_test 42c "test partial truncate of file with cached dirty data"
2697 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
2698 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
2701 run_test 42d "test complete truncate of file with cached dirty data"
2703 test_42e() { # bug22074
2704 local TDIR=$DIR/${tdir}e
2705 local pagesz=$(page_size)
2706 local pages=16 # hardcoded 16 pages, don't change it.
2707 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
2708 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
2713 $SETSTRIPE -c 1 $TDIR
2714 createmany -o $TDIR/f $files
2716 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
2718 # we assume that with $OSTCOUNT files, at least one of them will
2719 # be allocated on OST0.
2720 warmup_files=$((OSTCOUNT * max_dirty_mb))
2721 createmany -o $TDIR/w $warmup_files
2723 # write a large amount of data into one file and sync, to get good
2724 # avail_grant number from OST.
2725 for ((i=0; i<$warmup_files; i++)); do
2726 idx=$($GETSTRIPE -i $TDIR/w$i)
2727 [ $idx -ne 0 ] && continue
2728 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
2731 [ $i -gt $warmup_files ] && error "OST0 is still cold"
2733 $LCTL get_param $proc_osc0/cur_dirty_bytes
2734 $LCTL get_param $proc_osc0/cur_grant_bytes
2736 # create as much dirty pages as we can while not to trigger the actual
2737 # RPCs directly. but depends on the env, VFS may trigger flush during this
2738 # period, hopefully we are good.
2739 for ((i=0; i<$warmup_files; i++)); do
2740 idx=$($GETSTRIPE -i $TDIR/w$i)
2741 [ $idx -ne 0 ] && continue
2742 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
2744 $LCTL get_param $proc_osc0/cur_dirty_bytes
2745 $LCTL get_param $proc_osc0/cur_grant_bytes
2747 # perform the real test
2748 $LCTL set_param $proc_osc0/rpc_stats 0
2749 for ((;i<$files; i++)); do
2750 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
2751 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
2754 $LCTL get_param $proc_osc0/rpc_stats
2757 local have_ppr=false
2758 $LCTL get_param $proc_osc0/rpc_stats |
2759 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
2760 # skip lines until we are at the RPC histogram data
2761 [ "$PPR" == "pages" ] && have_ppr=true && continue
2762 $have_ppr || continue
2764 # we only want the percent stat for < 16 pages
2765 [ $(echo $PPR | tr -d ':') -ge $pages ] && break
2767 percent=$((percent + WPCT))
2768 if [ $percent -gt 15 ]; then
2769 error "less than 16-pages write RPCs" \
2776 run_test 42e "verify sub-RPC writes are not done synchronously"
2780 cp -p /bin/ls $DIR/$tdir/$tfile
2781 $MULTIOP $DIR/$tdir/$tfile Ow_c &
2783 # give multiop a chance to open
2786 $DIR/$tdir/$tfile && error || true
2789 run_test 43 "execution of file opened for write should return -ETXTBSY"
2793 cp -p `which $MULTIOP` $DIR/d43/multiop || cp -p multiop $DIR/d43/multiop
2794 MULTIOP_PROG=$DIR/d43/multiop multiop_bg_pause $TMP/test43.junk O_c || return 1
2796 $MULTIOP $DIR/d43/multiop Oc && error "expected error, got success"
2797 kill -USR1 $MULTIOP_PID || return 2
2798 wait $MULTIOP_PID || return 3
2801 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
2805 cp -p `which $MULTIOP` $DIR/d43/multiop || cp -p multiop $DIR/d43/multiop
2806 MULTIOP_PROG=$DIR/d43/multiop multiop_bg_pause $TMP/test43.junk O_c || return 1
2808 $TRUNCATE $DIR/d43/multiop 0 && error "expected error, got success"
2809 kill -USR1 $MULTIOP_PID || return 2
2810 wait $MULTIOP_PID || return 3
2813 run_test 43b "truncate of file being executed should return -ETXTBSY"
2816 local testdir="$DIR/d43c"
2819 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
2820 ( cd $testdir && md5sum -c)
2822 run_test 43c "md5sum of copy into lustre========================"
2825 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
2826 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
2827 dd if=$DIR/f1 bs=4k count=1 > /dev/null
2829 run_test 44 "zero length read from a sparse stripe ============="
2832 local nstripe=`$LCTL lov_getconfig $DIR | grep default_stripe_count: | \
2834 [ -z "$nstripe" ] && skip "can't get stripe info" && return
2835 [ "$nstripe" -gt "$OSTCOUNT" ] && skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" && return
2836 local stride=`$LCTL lov_getconfig $DIR | grep default_stripe_size: | \
2838 if [ $nstripe -eq 0 -o $nstripe -eq -1 ] ; then
2839 nstripe=`$LCTL lov_getconfig $DIR | grep obd_count: | awk '{print $2}'`
2842 OFFSETS="0 $((stride/2)) $((stride-1))"
2843 for offset in $OFFSETS ; do
2844 for i in `seq 0 $((nstripe-1))`; do
2845 local GLOBALOFFSETS=""
2846 local size=$((((i + 2 * $nstripe )*$stride + $offset))) # Bytes
2847 local myfn=$DIR/d44a-$size
2848 echo "--------writing $myfn at $size"
2849 ll_sparseness_write $myfn $size || error "ll_sparseness_write"
2850 GLOBALOFFSETS="$GLOBALOFFSETS $size"
2851 ll_sparseness_verify $myfn $GLOBALOFFSETS \
2852 || error "ll_sparseness_verify $GLOBALOFFSETS"
2854 for j in `seq 0 $((nstripe-1))`; do
2855 size=$((((j + $nstripe )*$stride + $offset))) # Bytes
2856 ll_sparseness_write $myfn $size || error "ll_sparseness_write"
2857 GLOBALOFFSETS="$GLOBALOFFSETS $size"
2859 ll_sparseness_verify $myfn $GLOBALOFFSETS \
2860 || error "ll_sparseness_verify $GLOBALOFFSETS"
2865 run_test 44a "test sparse pwrite ==============================="
2869 for d in `lctl get_param -n osc.*.cur_dirty_bytes`; do
2875 before=`dirty_osc_total`
2876 echo executing "\"$*\""
2878 after=`dirty_osc_total`
2879 echo before $before, after $after
2883 # Obtain grants from OST if it supports it
2884 echo blah > ${f}_grant
2887 do_dirty_record "echo blah > $f"
2888 [ $before -eq $after ] && error "write wasn't cached"
2889 do_dirty_record "> $f"
2890 [ $before -gt $after ] || error "truncate didn't lower dirty count"
2891 do_dirty_record "echo blah > $f"
2892 [ $before -eq $after ] && error "write wasn't cached"
2893 do_dirty_record "sync"
2894 [ $before -gt $after ] || error "writeback didn't lower dirty count"
2895 do_dirty_record "echo blah > $f"
2896 [ $before -eq $after ] && error "write wasn't cached"
2897 do_dirty_record "cancel_lru_locks osc"
2898 [ $before -gt $after ] || error "lock cancellation didn't lower dirty count"
2901 run_test 45 "osc io page accounting ============================"
2903 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
2904 # test tickles a bug where re-dirtying a page was failing to be mapped to the
2905 # objects offset and an assert hit when an rpc was built with 1023's mapped
2906 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
2911 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
2913 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
2914 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
2918 run_test 46 "dirtying a previously written page ================"
2920 # test_47 is removed "Device nodes check" is moved to test_28
2922 test_48a() { # bug 2399
2923 check_kernel_version 34 || return 0
2926 mv $DIR/d48a $DIR/d48.new || error "move directory failed"
2927 mkdir $DIR/d48a || error "recreate directory failed"
2928 touch foo || error "'touch foo' failed after recreating cwd"
2929 mkdir bar || error "'mkdir foo' failed after recreating cwd"
2930 if check_kernel_version 44; then
2931 touch .foo || error "'touch .foo' failed after recreating cwd"
2932 mkdir .bar || error "'mkdir .foo' failed after recreating cwd"
2934 ls . > /dev/null || error "'ls .' failed after recreating cwd"
2935 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
2936 cd . || error "'cd .' failed after recreating cwd"
2937 mkdir . && error "'mkdir .' worked after recreating cwd"
2938 rmdir . && error "'rmdir .' worked after recreating cwd"
2939 ln -s . baz || error "'ln -s .' failed after recreating cwd"
2940 cd .. || error "'cd ..' failed after recreating cwd"
2942 run_test 48a "Access renamed working dir (should return errors)="
2944 test_48b() { # bug 2399
2945 check_kernel_version 34 || return 0
2948 rmdir $DIR/d48b || error "remove cwd $DIR/d48b failed"
2949 touch foo && error "'touch foo' worked after removing cwd"
2950 mkdir foo && error "'mkdir foo' worked after removing cwd"
2951 if check_kernel_version 44; then
2952 touch .foo && error "'touch .foo' worked after removing cwd"
2953 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
2955 ls . > /dev/null && error "'ls .' worked after removing cwd"
2956 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
2957 is_patchless || ( cd . && error "'cd .' worked after removing cwd" )
2958 mkdir . && error "'mkdir .' worked after removing cwd"
2959 rmdir . && error "'rmdir .' worked after removing cwd"
2960 ln -s . foo && error "'ln -s .' worked after removing cwd"
2961 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
2963 run_test 48b "Access removed working dir (should return errors)="
2965 test_48c() { # bug 2350
2966 check_kernel_version 36 || return 0
2967 #lctl set_param debug=-1
2969 mkdir -p $DIR/d48c/dir
2971 $TRACE rmdir $DIR/d48c/dir || error "remove cwd $DIR/d48c/dir failed"
2972 $TRACE touch foo && error "'touch foo' worked after removing cwd"
2973 $TRACE mkdir foo && error "'mkdir foo' worked after removing cwd"
2974 if check_kernel_version 44; then
2975 touch .foo && error "'touch .foo' worked after removing cwd"
2976 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
2978 $TRACE ls . && error "'ls .' worked after removing cwd"
2979 $TRACE ls .. || error "'ls ..' failed after removing cwd"
2980 is_patchless || ( $TRACE cd . && error "'cd .' worked after removing cwd" )
2981 $TRACE mkdir . && error "'mkdir .' worked after removing cwd"
2982 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
2983 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
2984 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
2986 run_test 48c "Access removed working subdir (should return errors)"
2988 test_48d() { # bug 2350
2989 check_kernel_version 36 || return 0
2990 #lctl set_param debug=-1
2992 mkdir -p $DIR/d48d/dir
2994 $TRACE rmdir $DIR/d48d/dir || error "remove cwd $DIR/d48d/dir failed"
2995 $TRACE rmdir $DIR/d48d || error "remove parent $DIR/d48d failed"
2996 $TRACE touch foo && error "'touch foo' worked after removing parent"
2997 $TRACE mkdir foo && error "'mkdir foo' worked after removing parent"
2998 if check_kernel_version 44; then
2999 touch .foo && error "'touch .foo' worked after removing parent"
3000 mkdir .foo && error "'mkdir .foo' worked after removing parent"
3002 $TRACE ls . && error "'ls .' worked after removing parent"
3003 $TRACE ls .. && error "'ls ..' worked after removing parent"
3004 is_patchless || ( $TRACE cd . && error "'cd .' worked after recreate parent" )
3005 $TRACE mkdir . && error "'mkdir .' worked after removing parent"
3006 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
3007 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
3008 is_patchless || ( $TRACE cd .. && error "'cd ..' worked after removing parent" || true )
3010 run_test 48d "Access removed parent subdir (should return errors)"
3012 test_48e() { # bug 4134
3013 check_kernel_version 41 || return 0
3014 #lctl set_param debug=-1
3016 mkdir -p $DIR/d48e/dir
3018 $TRACE rmdir $DIR/d48e/dir || error "remove cwd $DIR/d48e/dir failed"
3019 $TRACE rmdir $DIR/d48e || error "remove parent $DIR/d48e failed"
3020 $TRACE touch $DIR/d48e || error "'touch $DIR/d48e' failed"
3021 $TRACE chmod +x $DIR/d48e || error "'chmod +x $DIR/d48e' failed"
3022 # On a buggy kernel addition of "touch foo" after cd .. will
3023 # produce kernel oops in lookup_hash_it
3024 touch ../foo && error "'cd ..' worked after recreate parent"
3026 $TRACE rm $DIR/d48e || error "rm '$DIR/d48e' failed"
3028 run_test 48e "Access to recreated parent subdir (should return errors)"
3030 test_49() { # LU-1030
3031 # get ost1 size - lustre-OST0000
3032 ost1_size=$(do_facet ost1 lfs df |grep ${ost1_svc} |awk '{print $4}')
3033 # write 800M at maximum
3034 [ $ost1_size -gt 819200 ] && ost1_size=819200
3036 lfs setstripe -c 1 -i 0 $DIR/$tfile
3037 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
3040 # change max_pages_per_rpc while writing the file
3041 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
3042 local orig_mppc=`$LCTL get_param -n $osc1_mppc`
3043 # loop until dd process exits
3044 while ps ax -opid | grep -q $dd_pid; do
3045 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
3046 sleep $((RANDOM % 5 + 1))
3048 # restore original max_pages_per_rpc
3049 $LCTL set_param $osc1_mppc=$orig_mppc
3050 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
3052 run_test 49 "Change max_pages_per_rpc won't break osc extent"
3058 ls /proc/$$/cwd || error
3060 run_test 50 "special situations: /proc symlinks ==============="
3062 test_51a() { # was test_51
3063 # bug 1516 - create an empty entry right after ".." then split dir
3066 $MCREATE $DIR/d51/bar
3068 createmany -m $DIR/d51/longfile 201
3070 while [ `ls -sd $DIR/d51 | awk '{ print $1 }'` -eq 4 ]; do
3071 $MCREATE $DIR/d51/longfile$FNUM
3076 ls -l $DIR/d51 > /dev/null || error
3078 run_test 51a "special situations: split htree with empty entry =="
3080 export NUMTEST=70000
3082 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
3083 [ $NUMFREE -lt 21000 ] && \
3084 skip "not enough free inodes ($NUMFREE)" && \
3087 [ $NUMFREE -lt $NUMTEST ] && NUMTEST=$(($NUMFREE - 50))
3090 createmany -d $DIR/d51b/t- $NUMTEST
3092 run_test 51b "mkdir .../t-0 --- .../t-$NUMTEST ===================="
3094 test_51ba() { # LU-993
3095 local BASE=$DIR/d51b
3096 # unlink all but 100 subdirectories, then check it still works
3098 local DELETE=$((NUMTEST - LEFT))
3100 ! [ -d "${BASE}/t-$DELETE" ] && skip "test_51b() not run" && return 0
3102 # for ldiskfs the nlink count should be 1, but this is OSD specific
3103 # and so this is listed for informational purposes only
3104 log "nlink before: $(stat -c %h $BASE)"
3105 unlinkmany -d $BASE/t- $DELETE ||
3106 error "unlink of first $DELETE subdirs failed"
3108 log "nlink between: $(stat -c %h $BASE)"
3109 local FOUND=$(ls -l ${BASE} | wc -l)
3110 FOUND=$((FOUND - 1)) # trim the first line of ls output
3111 [ $FOUND -ne $LEFT ] &&
3112 error "can't find subdirs: found only $FOUND/$LEFT"
3114 unlinkmany -d $BASE/t- $DELETE $LEFT ||
3115 error "unlink of second $LEFT subdirs failed"
3116 log "nlink after: $(stat -c %h $BASE)"
3118 run_test 51ba "rmdir .../t-0 --- .../t-$NUMTEST"
3121 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3123 local ndirs=${TEST51BB_NDIRS:-10}
3124 local nfiles=${TEST51BB_NFILES:-100}
3126 local numfree=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
3128 [ $numfree -lt $(( ndirs * nfiles)) ] && \
3129 nfiles=$(( numfree / ndirs - 10 ))
3131 local dir=$DIR/d51bb
3133 local savePOLICY=$(lctl get_param -n lmv.*.placement)
3134 lctl set_param -n lmv.*.placement=CHAR
3137 local IUSED=$(lfs df -i $dir | grep MDT | awk '{print $3}')
3141 for ((i=0; i < $ndirs; i++)); do
3142 dirs[i]=$dir/$RANDOM
3143 echo Creating directory ${dirs[i]}
3146 echo Creating $nfiles in dir ${dirs[i]} ...
3147 echo "createmany -o ${dirs[i]}/$tfile- $nfiles"
3148 createmany -o ${dirs[i]}/$tfile- $nfiles
3154 IUSED=$(lfs df -i $dir | grep MDT | awk '{print $3}')
3158 for ((i=0; i<${#NEWUSED[@]}; i++)); do
3159 echo "mds $i: inodes count OLD ${OLDUSED[$i]} NEW ${NEWUSED[$i]}"
3160 [ ${OLDUSED[$i]} -lt ${NEWUSED[$i]} ] || rc=$((rc + 1))
3163 lctl set_param -n lmv.*.placement=$savePOLICY
3165 [ $rc -ne $MDSCOUNT ] || \
3166 error "Objects/inodes are not distributed over all mds servers"
3168 run_test 51bb "mkdir createmany CMD $MDSCOUNT ===================="
3171 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping test with few OSTs" && return
3173 createmany -o $DIR/d51d/t- 1000
3174 $GETSTRIPE $DIR/d51d > $TMP/files
3175 for N in `seq 0 $((OSTCOUNT - 1))`; do
3176 OBJS[$N]=`awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}' $TMP/files`
3177 OBJS0[$N]=`grep -A 1 idx $TMP/files | awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}'`
3178 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
3180 unlinkmany $DIR/d51d/t- 1000
3183 for N in `seq 1 $((OSTCOUNT - 1))`; do
3184 [ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ] && \
3185 error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
3186 [ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ] && \
3187 error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
3189 [ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ] && \
3190 error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
3191 [ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ] && \
3192 error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
3196 run_test 51d "check object distribution ===================="
3199 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
3202 chattr +a $DIR/d52a/foo || error "chattr +a failed"
3203 echo bar >> $DIR/d52a/foo || error "append bar failed"
3204 cp /etc/hosts $DIR/d52a/foo && error "cp worked"
3205 rm -f $DIR/d52a/foo 2>/dev/null && error "rm worked"
3206 link $DIR/d52a/foo $DIR/d52a/foo_link 2>/dev/null && error "link worked"
3207 echo foo >> $DIR/d52a/foo || error "append foo failed"
3208 mrename $DIR/d52a/foo $DIR/d52a/foo_ren && error "rename worked"
3209 lsattr $DIR/d52a/foo | egrep -q "^-+a[-e]+ $DIR/d52a/foo" || error "lsattr"
3210 chattr -a $DIR/d52a/foo || error "chattr -a failed"
3211 cp -r $DIR/d52a /tmp/
3212 rm -fr $DIR/d52a || error "cleanup rm failed"
3214 run_test 52a "append-only flag test (should return errors) ====="
3217 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
3220 chattr +i $DIR/d52b/foo || error "chattr +i failed"
3221 cat test > $DIR/d52b/foo && error "cat test worked"
3222 cp /etc/hosts $DIR/d52b/foo && error "cp worked"
3223 rm -f $DIR/d52b/foo 2>/dev/null && error "rm worked"
3224 link $DIR/d52b/foo $DIR/d52b/foo_link 2>/dev/null && error "link worked"
3225 echo foo >> $DIR/d52b/foo && error "echo worked"
3226 mrename $DIR/d52b/foo $DIR/d52b/foo_ren && error "rename worked"
3227 [ -f $DIR/d52b/foo ] || error
3228 [ -f $DIR/d52b/foo_ren ] && error
3229 lsattr $DIR/d52b/foo | egrep -q "^-+i[-e]+ $DIR/d52b/foo" || error "lsattr"
3230 chattr -i $DIR/d52b/foo || error "chattr failed"
3232 rm -fr $DIR/d52b || error
3234 run_test 52b "immutable flag test (should return errors) ======="
3237 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3238 remote_ost_nodsh && skip "remote OST with nodsh" && return
3247 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
3248 for value in $(do_facet $SINGLEMDS lctl get_param osc.$mdtosc.prealloc_last_id) ; do
3249 param=`echo ${value[0]} | cut -d "=" -f1`
3250 ostname=`echo $param | cut -d "." -f2 | cut -d - -f 1-2`
3251 mds_last=$(do_facet $SINGLEMDS lctl get_param -n $param)
3252 ostnum=$(echo $ostname | sed "s/${FSNAME}-OST//g" | awk '{print ($1+1)}' )
3253 ost_last=$(do_facet ost$ostnum lctl get_param -n obdfilter.$ostname.last_id | head -n 1)
3254 echo "$ostname.last_id=$ost_last ; MDS.last_id=$mds_last"
3255 if [ $ost_last != $mds_last ]; then
3256 error "$ostname.last_id=$ost_last ; MDS.last_id=$mds_last"
3260 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
3263 [ ! -f "$SOCKETSERVER" ] && skip_env "no socketserver, skipping" && return
3264 [ ! -f "$SOCKETCLIENT" ] && skip_env "no socketclient, skipping" && return
3265 $SOCKETSERVER $DIR/socket
3266 $SOCKETCLIENT $DIR/socket || error
3267 $MUNLINK $DIR/socket
3269 run_test 54a "unix domain socket test =========================="
3275 dd if=/dev/zero of=$f bs=`page_size` count=1
3277 run_test 54b "char device works in lustre ======================"
3280 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
3281 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
3282 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
3284 for i in `seq 3 7`; do
3285 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
3295 loopdev="$DIR/loop54c"
3298 [ -z "$LOOPNUM" ] && echo "couldn't find empty loop device" && return
3299 mknod $loopdev b 7 $LOOPNUM
3300 echo "make a loop file system with $tfile on $loopdev ($LOOPNUM)..."
3301 dd if=/dev/zero of=$tfile bs=`page_size` seek=1024 count=1 > /dev/null
3302 losetup $loopdev $tfile || error "can't set up $loopdev for $tfile"
3303 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
3305 mount -t ext2 $loopdev $tdir || error "error mounting $loopdev on $tdir"
3306 dd if=/dev/zero of=$tdir/tmp bs=`page_size` count=30 || error "dd write"
3308 dd if=$tdir/tmp of=/dev/zero bs=`page_size` count=30 || error "dd read"
3313 run_test 54c "block device works in lustre ====================="
3319 [ "$string" = `echo $string > $f | cat $f` ] || error
3321 run_test 54d "fifo device works in lustre ======================"
3324 check_kernel_version 46 || return 0
3327 cp -aL /dev/console $f
3328 echo $string > $f || error
3330 run_test 54e "console/tty device works in lustre ======================"
3332 #The test_55 used to be iopen test and it was removed by bz#24037.
3333 #run_test 55 "check iopen_connect_dentry() ======================"
3335 test_56a() { # was test_56
3341 NUMFILESx2=$(($NUMFILES * 2))
3342 for i in `seq 1 $NUMFILES` ; do
3343 touch $DIR/d56/file$i
3344 touch $DIR/d56/dir/file$i
3347 # test lfs getstripe with --recursive
3348 FILENUM=`$GETSTRIPE --recursive $DIR/d56 | grep -c obdidx`
3349 [ $FILENUM -eq $NUMFILESx2 ] ||
3350 error "$GETSTRIPE --recursive: found $FILENUM, not $NUMFILESx2"
3351 FILENUM=`$GETSTRIPE $DIR/d56 | grep -c obdidx`
3352 [ $FILENUM -eq $NUMFILES ] ||
3353 error "$GETSTRIPE $DIR/d56: found $FILENUM, not $NUMFILES"
3354 echo "$GETSTRIPE --recursive passed."
3356 # test lfs getstripe with file instead of dir
3357 FILENUM=`$GETSTRIPE $DIR/d56/file1 | grep -c obdidx`
3358 [ $FILENUM -eq 1 ] || error \
3359 "$GETSTRIPE $DIR/d56/file1: found $FILENUM, not 1"
3360 echo "$GETSTRIPE file1 passed."
3362 #test lfs getstripe with --verbose
3363 [ `$GETSTRIPE --verbose $DIR/d56 | grep -c lmm_magic` -eq $NUMFILES ] ||
3364 error "$GETSTRIPE --verbose $DIR/d56: want $NUMFILES lmm_magic"
3365 [ `$GETSTRIPE $DIR/d56 | grep -c lmm_magic` -eq 0 ] ||
3366 error "$GETSTRIPE $DIR/d56: showed lmm_magic"
3367 echo "$GETSTRIPE --verbose passed."
3369 #test lfs getstripe with --obd
3370 $GETSTRIPE --obd wrong_uuid $DIR/d56 2>&1 | grep -q "unknown obduuid" ||
3371 error "$GETSTRIPE --obd wrong_uuid should return error message"
3373 [ "$OSTCOUNT" -lt 2 ] &&
3374 skip_env "skipping other $GETSTRIPE --obd test" && return
3377 OBDUUID=$(ostuuid_from_index $OSTIDX)
3378 FILENUM=`$GETSTRIPE -ir $DIR/d56 | grep -x $OSTIDX | wc -l`
3379 FOUND=`$GETSTRIPE -r --obd $OBDUUID $DIR/d56 | grep obdidx | wc -l`
3380 [ $FOUND -eq $FILENUM ] ||
3381 error "$GETSTRIPE --obd wrong: found $FOUND, expected $FILENUM"
3382 [ `$GETSTRIPE -r -v --obd $OBDUUID $DIR/d56 |
3383 sed '/^[ ]*'${OSTIDX}'[ ]/d' |
3384 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l` -eq 0 ] ||
3385 error "$GETSTRIPE --obd: should not show file on other obd"
3386 echo "$GETSTRIPE --obd passed"
3388 run_test 56a "check $GETSTRIPE"
3393 local LOCAL_NUMFILES="$1"
3394 local LOCAL_NUMDIRS="$2"
3395 local MKDIR_PARAMS="$3"
3397 if [ ! -d "$TDIR" ] ; then
3399 [ "$MKDIR_PARAMS" ] && $SETSTRIPE $MKDIR_PARAMS $TDIR
3400 for i in `seq 1 $LOCAL_NUMFILES` ; do
3403 for i in `seq 1 $LOCAL_NUMDIRS` ; do
3405 for j in `seq 1 $LOCAL_NUMFILES` ; do
3406 touch $TDIR/dir$i/file$j
3412 setup_56_special() {
3416 if [ ! -e "$TDIR/loop1b" ] ; then
3417 for i in `seq 1 $LOCAL_NUMFILES` ; do
3418 mknod $TDIR/loop${i}b b 7 $i
3419 mknod $TDIR/null${i}c c 1 3
3420 ln -s $TDIR/file1 $TDIR/link${i}l
3422 for i in `seq 1 $LOCAL_NUMDIRS` ; do
3423 mknod $TDIR/dir$i/loop${i}b b 7 $i
3424 mknod $TDIR/dir$i/null${i}c c 1 3
3425 ln -s $TDIR/dir$i/file1 $TDIR/dir$i/link${i}l
3434 setup_56 $NUMFILES $NUMDIRS
3436 EXPECTED=$(($NUMDIRS + 2))
3437 # test lfs find with -name
3438 for i in $(seq 1 $NUMFILES) ; do
3439 NUMS=$($LFIND -name "*$i" $TDIR | wc -l)
3440 [ $NUMS -eq $EXPECTED ] ||
3441 error "lfs find -name \"*$i\" $TDIR wrong: "\
3442 "found $NUMS, expected $EXPECTED"
3445 run_test 56g "check lfs find -name ============================="
3451 setup_56 $NUMFILES $NUMDIRS
3453 EXPECTED=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
3454 # test lfs find with ! -name
3455 for i in $(seq 1 $NUMFILES) ; do
3456 NUMS=$($LFIND ! -name "*$i" $TDIR | wc -l)
3457 [ $NUMS -eq $EXPECTED ] ||
3458 error "lfs find ! -name \"*$i\" $TDIR wrong: "\
3459 "found $NUMS, expected $EXPECTED"
3462 run_test 56h "check lfs find ! -name ============================="
3467 UUID=$(ostuuid_from_index 0 $DIR/$tdir)
3468 CMD="$LFIND -ost $UUID $DIR/$tdir"
3470 [ -z "$OUT" ] || error "\"$CMD\" returned directory '$OUT'"
3472 run_test 56i "check 'lfs find -ost UUID' skips directories ======="
3476 setup_56_special $NUMFILES $NUMDIRS
3478 EXPECTED=$((NUMDIRS + 1))
3479 CMD="$LFIND -type d $TDIR"
3480 NUMS=$($CMD | wc -l)
3481 [ $NUMS -eq $EXPECTED ] ||
3482 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3484 run_test 56j "check lfs find -type d ============================="
3488 setup_56_special $NUMFILES $NUMDIRS
3490 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
3491 CMD="$LFIND -type f $TDIR"
3492 NUMS=$($CMD | wc -l)
3493 [ $NUMS -eq $EXPECTED ] ||
3494 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3496 run_test 56k "check lfs find -type f ============================="
3500 setup_56_special $NUMFILES $NUMDIRS
3502 EXPECTED=$((NUMDIRS + NUMFILES))
3503 CMD="$LFIND -type b $TDIR"
3504 NUMS=$($CMD | wc -l)
3505 [ $NUMS -eq $EXPECTED ] ||
3506 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3508 run_test 56l "check lfs find -type b ============================="
3512 setup_56_special $NUMFILES $NUMDIRS
3514 EXPECTED=$((NUMDIRS + NUMFILES))
3515 CMD="$LFIND -type c $TDIR"
3516 NUMS=$($CMD | wc -l)
3517 [ $NUMS -eq $EXPECTED ] ||
3518 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3520 run_test 56m "check lfs find -type c ============================="
3524 setup_56_special $NUMFILES $NUMDIRS
3526 EXPECTED=$((NUMDIRS + NUMFILES))
3527 CMD="$LFIND -type l $TDIR"
3528 NUMS=$($CMD | wc -l)
3529 [ $NUMS -eq $EXPECTED ] ||
3530 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3532 run_test 56n "check lfs find -type l ============================="
3536 setup_56 $NUMFILES $NUMDIRS
3538 utime $TDIR/file1 > /dev/null || error "utime (1)"
3539 utime $TDIR/file2 > /dev/null || error "utime (2)"
3540 utime $TDIR/dir1 > /dev/null || error "utime (3)"
3541 utime $TDIR/dir2 > /dev/null || error "utime (4)"
3542 utime $TDIR/dir1/file1 > /dev/null || error "utime (5)"
3543 dd if=/dev/zero count=1 >> $TDIR/dir1/file1 && sync
3546 NUMS=`$LFIND -mtime +0 $TDIR | wc -l`
3547 [ $NUMS -eq $EXPECTED ] || \
3548 error "lfs find -mtime +0 $TDIR wrong: found $NUMS, expected $EXPECTED"
3551 CMD="$LFIND -mtime 0 $TDIR"
3552 NUMS=$($CMD | wc -l)
3553 [ $NUMS -eq $EXPECTED ] ||
3554 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3556 run_test 56o "check lfs find -mtime for old files =========================="
3559 [ $RUNAS_ID -eq $UID ] &&
3560 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
3563 setup_56 $NUMFILES $NUMDIRS
3565 chown $RUNAS_ID $TDIR/file* || error "chown $DIR/${tdir}g/file$i failed"
3567 CMD="$LFIND -uid $RUNAS_ID $TDIR"
3568 NUMS=$($CMD | wc -l)
3569 [ $NUMS -eq $EXPECTED ] || \
3570 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3572 EXPECTED=$(((NUMFILES + 1) * NUMDIRS + 1))
3573 CMD="$LFIND ! -uid $RUNAS_ID $TDIR"
3574 NUMS=$($CMD | wc -l)
3575 [ $NUMS -eq $EXPECTED ] || \
3576 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3578 run_test 56p "check lfs find -uid and ! -uid ==============================="
3581 [ $RUNAS_ID -eq $UID ] &&
3582 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
3585 setup_56 $NUMFILES $NUMDIRS
3587 chgrp $RUNAS_GID $TDIR/file* || error "chown $TDIR/file$i failed"
3590 CMD="$LFIND -gid $RUNAS_GID $TDIR"
3591 NUMS=$($CMD | wc -l)
3592 [ $NUMS -eq $EXPECTED ] ||
3593 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3595 EXPECTED=$(( ($NUMFILES+1) * $NUMDIRS + 1))
3596 CMD="$LFIND ! -gid $RUNAS_GID $TDIR"
3597 NUMS=$($CMD | wc -l)
3598 [ $NUMS -eq $EXPECTED ] ||
3599 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3601 run_test 56q "check lfs find -gid and ! -gid ==============================="
3605 setup_56 $NUMFILES $NUMDIRS
3608 CMD="$LFIND -size 0 -type f $TDIR"
3609 NUMS=$($CMD | wc -l)
3610 [ $NUMS -eq $EXPECTED ] ||
3611 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3613 CMD="$LFIND ! -size 0 -type f $TDIR"
3614 NUMS=$($CMD | wc -l)
3615 [ $NUMS -eq $EXPECTED ] ||
3616 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3617 echo "test" > $TDIR/$tfile
3618 echo "test2" > $TDIR/$tfile.2 && sync
3620 CMD="$LFIND -size 5 -type f $TDIR"
3621 NUMS=$($CMD | wc -l)
3622 [ $NUMS -eq $EXPECTED ] ||
3623 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3625 CMD="$LFIND -size +5 -type f $TDIR"
3626 NUMS=$($CMD | wc -l)
3627 [ $NUMS -eq $EXPECTED ] ||
3628 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3630 CMD="$LFIND -size +0 -type f $TDIR"
3631 NUMS=$($CMD | wc -l)
3632 [ $NUMS -eq $EXPECTED ] ||
3633 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3635 CMD="$LFIND ! -size -5 -type f $TDIR"
3636 NUMS=$($CMD | wc -l)
3637 [ $NUMS -eq $EXPECTED ] ||
3638 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3640 CMD="$LFIND -size -5 -type f $TDIR"
3641 NUMS=$($CMD | wc -l)
3642 [ $NUMS -eq $EXPECTED ] ||
3643 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3645 run_test 56r "check lfs find -size works =========================="
3647 test_56s() { # LU-611
3649 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT"
3651 if [ $OSTCOUNT -gt 1 ]; then
3652 $SETSTRIPE -c 1 $TDIR/$tfile.{0,1,2,3}
3656 ONESTRIPE=$(((NUMDIRS + 1) * NUMFILES))
3660 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
3661 CMD="$LFIND -stripe-count $OSTCOUNT -type f $TDIR"
3662 NUMS=$($CMD | wc -l)
3663 [ $NUMS -eq $EXPECTED ] ||
3664 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3666 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + EXTRA))
3667 CMD="$LFIND -stripe-count +0 -type f $TDIR"
3668 NUMS=$($CMD | wc -l)
3669 [ $NUMS -eq $EXPECTED ] ||
3670 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3673 CMD="$LFIND -stripe-count 1 -type f $TDIR"
3674 NUMS=$($CMD | wc -l)
3675 [ $NUMS -eq $EXPECTED ] ||
3676 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3678 CMD="$LFIND -stripe-count -2 -type f $TDIR"
3679 NUMS=$($CMD | wc -l)
3680 [ $NUMS -eq $EXPECTED ] ||
3681 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3684 CMD="$LFIND -stripe-count $((OSTCOUNT + 1)) -type f $TDIR"
3685 NUMS=$($CMD | wc -l)
3686 [ $NUMS -eq $EXPECTED ] ||
3687 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3689 run_test 56s "check lfs find -stripe-count works"
3691 test_56t() { # LU-611
3693 setup_56 $NUMFILES $NUMDIRS "-s 512k"
3695 $SETSTRIPE -S 256k $TDIR/$tfile.{0,1,2,3}
3697 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
3698 CMD="$LFIND -stripe-size 512k -type f $TDIR"
3699 NUMS=$($CMD | wc -l)
3700 [ $NUMS -eq $EXPECTED ] ||
3701 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3703 CMD="$LFIND -stripe-size +320k -type f $TDIR"
3704 NUMS=$($CMD | wc -l)
3705 [ $NUMS -eq $EXPECTED ] ||
3706 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3708 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + 4))
3709 CMD="$LFIND -stripe-size +200k -type f $TDIR"
3710 NUMS=$($CMD | wc -l)
3711 [ $NUMS -eq $EXPECTED ] ||
3712 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3714 CMD="$LFIND -stripe-size -640k -type f $TDIR"
3715 NUMS=$($CMD | wc -l)
3716 [ $NUMS -eq $EXPECTED ] ||
3717 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3720 CMD="$LFIND -stripe-size 256k -type f $TDIR"
3721 NUMS=$($CMD | wc -l)
3722 [ $NUMS -eq $EXPECTED ] ||
3723 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3725 CMD="$LFIND -stripe-size -320k -type f $TDIR"
3726 NUMS=$($CMD | wc -l)
3727 [ $NUMS -eq $EXPECTED ] ||
3728 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3731 CMD="$LFIND -stripe-size 1024k -type f $TDIR"
3732 NUMS=$($CMD | wc -l)
3733 [ $NUMS -eq $EXPECTED ] ||
3734 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3736 run_test 56t "check lfs find -stripe-size works"
3738 test_56u() { # LU-611
3740 setup_56 $NUMFILES $NUMDIRS "-i 0"
3742 if [ $OSTCOUNT -gt 1 ]; then
3743 $SETSTRIPE -i 1 $TDIR/$tfile.{0,1,2,3}
3749 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
3750 CMD="$LFIND -stripe-index 0 -type f $TDIR"
3751 NUMS=$($CMD | wc -l)
3752 [ $NUMS -eq $EXPECTED ] ||
3753 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3756 CMD="$LFIND -stripe-index 1 -type f $TDIR"
3757 NUMS=$($CMD | wc -l)
3758 [ $NUMS -eq $EXPECTED ] ||
3759 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3761 CMD="$LFIND ! -stripe-index 0 -type f $TDIR"
3762 NUMS=$($CMD | wc -l)
3763 [ $NUMS -eq $EXPECTED ] ||
3764 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3767 # This should produce an error and not return any files
3768 CMD="$LFIND -stripe-index $OSTCOUNT -type f $TDIR"
3769 NUMS=$($CMD 2>/dev/null | wc -l)
3770 [ $NUMS -eq $EXPECTED ] ||
3771 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3773 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + ONESTRIPE))
3774 CMD="$LFIND -stripe-index 0,1 -type f $TDIR"
3775 NUMS=$($CMD | wc -l)
3776 [ $NUMS -eq $EXPECTED ] ||
3777 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3779 run_test 56u "check lfs find -stripe-index works"
3786 setup_56 $NUMFILES $NUMDIRS
3788 UUID=$(mdtuuid_from_index $MDT_IDX $TDIR)
3789 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT index $MDT_IDX"
3791 for file in $($LFIND -mdt $UUID $TDIR); do
3792 file_mdt_idx=$($GETSTRIPE -M $file)
3793 [ $file_mdt_idx -eq $MDT_IDX ] ||
3794 error "'lfind -mdt $UUID' != 'getstripe -M' ($file_mdt_idx)"
3797 run_test 56v "check 'lfs find -mdt match with lfs getstripe -M' ======="
3799 # Get and check the actual stripe count of one file.
3800 # Usage: check_stripe_count <file> <expected_stripe_count>
3801 check_stripe_count() {
3806 [[ -z "$file" || -z "$expected" ]] &&
3807 error "check_stripe_count: invalid argument!"
3809 local cmd="$GETSTRIPE -c $file"
3810 actual=$($cmd) || error "$cmd failed"
3811 actual=${actual%% *}
3813 if [[ $actual -ne $expected ]]; then
3814 [[ $expected -eq -1 ]] ||
3815 error "$cmd wrong: found $actual, expected $expected"
3816 [[ $actual -eq $OSTCOUNT ]] ||
3817 error "$cmd wrong: found $actual, expected $OSTCOUNT"
3824 rm -rf $TDIR || error "remove $TDIR failed"
3825 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT"
3828 stripe_size=$($GETSTRIPE -S -d $TDIR) ||
3829 error "$GETSTRIPE -S -d $TDIR failed"
3830 stripe_size=${stripe_size%% *}
3832 local file_size=$((stripe_size * OSTCOUNT))
3833 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
3834 local required_space=$((file_num * file_size))
3835 local free_space=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
3836 [[ $free_space -le $((required_space / 1024)) ]] &&
3837 skip_env "need at least $required_space bytes free space," \
3838 "have $free_space kbytes" && return
3841 local dd_count=$((file_size / dd_bs))
3843 # write data into the files
3847 for i in $(seq 1 $NUMFILES); do
3849 yes | dd bs=$dd_bs count=$dd_count of=$file >/dev/null 2>&1 ||
3850 error "write data into $file failed"
3852 for i in $(seq 1 $NUMDIRS); do
3853 for j in $(seq 1 $NUMFILES); do
3854 file=$TDIR/dir$i/file$j
3855 yes | dd bs=$dd_bs count=$dd_count of=$file \
3857 error "write data into $file failed"
3862 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
3865 local cmd="$LFS_MIGRATE -y -c $expected $TDIR/file1"
3867 eval $cmd || error "$cmd failed"
3869 check_stripe_count $TDIR/file1 $expected
3872 cmd="$LFS_MIGRATE -y -c $expected $TDIR/dir1"
3874 eval $cmd || error "$cmd failed"
3876 for j in $(seq 1 $NUMFILES); do
3877 check_stripe_count $TDIR/dir1/file$j $expected
3880 # lfs_migrate works with lfs find
3881 cmd="$LFIND -stripe_count $OSTCOUNT -type f $TDIR |
3882 $LFS_MIGRATE -y -c $expected"
3884 eval $cmd || error "$cmd failed"
3886 for i in $(seq 2 $NUMFILES); do
3887 check_stripe_count $TDIR/file$i $expected
3889 for i in $(seq 2 $NUMDIRS); do
3890 for j in $(seq 1 $NUMFILES); do
3891 check_stripe_count $TDIR/dir$i/file$j $expected
3895 run_test 56w "check lfs_migrate -c stripe_count works"
3898 # note test will not do anything if MDS is not local
3899 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3900 local MNTDEV="osd*.*MDT*.mntdev"
3901 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
3902 [ -z "$DEV" ] && error "can't access $MNTDEV"
3903 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
3904 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
3905 error "can't access $DEV"
3906 DEVISIZE=`awk '/Inode size:/ { print $3 }' $TMP/t57a.dump`
3907 [ "$DEVISIZE" -gt 128 ] || error "inode size $DEVISIZE"
3911 run_test 57a "verify MDS filesystem created with large inodes =="
3914 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3919 local FILEN=$dir/f$FILECOUNT
3921 rm -rf $dir || error "removing $dir"
3922 mkdir -p $dir || error "creating $dir"
3923 local num=$(get_mds_dir $dir)
3926 echo "mcreating $FILECOUNT files"
3927 createmany -m $dir/f 1 $FILECOUNT || \
3928 error "creating files in $dir"
3930 # verify that files do not have EAs yet
3931 $GETSTRIPE $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
3932 $GETSTRIPE $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
3936 df $dir #make sure we get new statfs data
3937 local MDSFREE=$(do_facet $mymds \
3938 lctl get_param -n osd*.*MDT000$((num -1)).kbytesfree)
3939 local MDCFREE=$(lctl get_param -n mdc.*MDT000$((num -1))-mdc-*.kbytesfree)
3940 echo "opening files to create objects/EAs"
3942 for FILE in `seq -f $dir/f%g 1 $FILECOUNT`; do
3943 $OPENFILE -f O_RDWR $FILE > /dev/null 2>&1 || error "opening $FILE"
3946 # verify that files have EAs now
3947 $GETSTRIPE $FILE1 | grep -q "obdidx" || error "$FILE1 missing EA"
3948 $GETSTRIPE $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
3950 sleep 1 #make sure we get new statfs data
3952 local MDSFREE2=$(do_facet $mymds \
3953 lctl get_param -n osd*.*MDT000$((num -1)).kbytesfree)
3954 local MDCFREE2=$(lctl get_param -n mdc.*MDT000$((num -1))-mdc-*.kbytesfree)
3955 if [ "$MDCFREE2" -lt "$((MDCFREE - 8))" ]; then
3956 if [ "$MDSFREE" != "$MDSFREE2" ]; then
3957 error "MDC before $MDCFREE != after $MDCFREE2"
3959 echo "MDC before $MDCFREE != after $MDCFREE2"
3960 echo "unable to confirm if MDS has large inodes"
3965 run_test 57b "default LOV EAs are stored inside large inodes ==="
3968 [ -z "$(which wiretest 2>/dev/null)" ] && skip_env "could not find wiretest" && return
3971 run_test 58 "verify cross-platform wire constants =============="
3974 echo "touch 130 files"
3975 createmany -o $DIR/f59- 130
3977 unlinkmany $DIR/f59- 130
3980 # wait for commitment of removal
3982 run_test 59 "verify cancellation of llog records async ========="
3984 TEST60_HEAD="test_60 run $RANDOM"
3986 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
3987 [ ! -f run-llog.sh ] && skip_env "missing subtest run-llog.sh" && return
3988 log "$TEST60_HEAD - from kernel mode"
3989 do_facet mgs sh run-llog.sh
3991 run_test 60a "llog sanity tests run from kernel module =========="
3993 test_60b() { # bug 6411
3995 LLOG_COUNT=`dmesg | awk "/$TEST60_HEAD/{marker = 1; from_marker = 0;}
4007 [ $LLOG_COUNT -gt 50 ] && error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)"|| true
4009 run_test 60b "limit repeated messages from CERROR/CWARN ========"
4012 echo "create 5000 files"
4013 createmany -o $DIR/f60c- 5000
4014 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
4015 lctl set_param fail_loc=0x80000137
4016 unlinkmany $DIR/f60c- 5000
4017 lctl set_param fail_loc=0
4019 run_test 60c "unlink file when mds full"
4022 SAVEPRINTK=$(lctl get_param -n printk)
4024 # verify "lctl mark" is even working"
4025 MESSAGE="test message ID $RANDOM $$"
4026 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
4027 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
4029 lctl set_param printk=0 || error "set lnet.printk failed"
4030 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
4031 MESSAGE="new test message ID $RANDOM $$"
4032 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
4033 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
4034 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
4036 lctl set_param -n printk="$SAVEPRINTK"
4038 run_test 60d "test printk console message masking"
4042 dd if=/dev/zero of=$f bs=`page_size` count=1
4043 cancel_lru_locks osc
4044 $MULTIOP $f OSMWUc || error
4047 run_test 61 "mmap() writes don't make sync hang ================"
4049 # bug 2330 - insufficient obd_match error checking causes LBUG
4053 cancel_lru_locks osc
4054 lctl set_param fail_loc=0x405
4055 cat $f && error "cat succeeded, expect -EIO"
4056 lctl set_param fail_loc=0
4058 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
4059 # match every page all of the time.
4060 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
4062 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
4063 test_63a() { # was test_63
4064 MAX_DIRTY_MB=`lctl get_param -n osc.*.max_dirty_mb | head -n 1`
4065 lctl set_param -n osc.*.max_dirty_mb 0
4066 for i in `seq 10` ; do
4067 dd if=/dev/zero of=$DIR/f63 bs=8k &
4073 lctl set_param -n osc.*.max_dirty_mb $MAX_DIRTY_MB
4074 rm -f $DIR/f63 || true
4076 run_test 63a "Verify oig_wait interruption does not crash ======="
4078 # bug 2248 - async write errors didn't return to application on sync
4079 # bug 3677 - async write errors left page locked
4082 lctl set_param debug=-1
4084 # ensure we have a grant to do async writes
4085 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
4088 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
4089 lctl set_param fail_loc=0x80000406
4090 $MULTIOP $DIR/$tfile Owy && \
4091 error "sync didn't return ENOMEM"
4092 sync; sleep 2; sync # do a real sync this time to flush page
4093 lctl get_param -n llite.*.dump_page_cache | grep locked && \
4094 error "locked page left in cache after async error" || true
4097 run_test 63b "async write errors should be returned to fsync ==="
4101 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
4103 run_test 64a "verify filter grant calculations (in kernel) ====="
4106 [ ! -f oos.sh ] && skip_env "missing subtest oos.sh" && return
4109 run_test 64b "check out-of-space detection on client ==========="
4111 # bug 1414 - set/get directories' stripe info
4115 $LVERIFY $DIR/d65 $DIR/d65/f1 || error "lverify failed"
4117 run_test 65a "directory with no stripe info ===================="
4121 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/d65||error "setstripe"
4123 $LVERIFY $DIR/d65 $DIR/d65/f2 || error "lverify failed"
4125 run_test 65b "directory setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1"
4128 if [ $OSTCOUNT -gt 1 ]; then
4130 $SETSTRIPE -S $(($STRIPESIZE * 4)) -i 1 \
4131 -c $(($OSTCOUNT - 1)) $DIR/d65 || error "setstripe"
4133 $LVERIFY $DIR/d65 $DIR/d65/f3 || error "lverify failed"
4136 run_test 65c "directory setstripe -S $((STRIPESIZE*4)) -i 1 -c $((OSTCOUNT-1))"
4140 if [ $STRIPECOUNT -le 0 ]; then
4142 elif [ $STRIPECOUNT -gt 2000 ]; then
4143 #LOV_MAX_STRIPE_COUNT is 2000
4144 [ $OSTCOUNT -gt 2000 ] && sc=2000 || sc=$(($OSTCOUNT - 1))
4146 sc=$(($STRIPECOUNT - 1))
4148 $SETSTRIPE -S $STRIPESIZE -c $sc $DIR/d65 || error "setstripe"
4149 touch $DIR/d65/f4 $DIR/d65/f5
4150 $LVERIFY $DIR/d65 $DIR/d65/f4 $DIR/d65/f5 || error "lverify failed"
4152 run_test 65d "directory setstripe -S $STRIPESIZE -c stripe_count"
4157 $SETSTRIPE $DIR/d65 || error "setstripe"
4158 $GETSTRIPE -v $DIR/d65 | grep "Default" || error "no stripe info failed"
4160 $LVERIFY $DIR/d65 $DIR/d65/f6 || error "lverify failed"
4162 run_test 65e "directory setstripe defaults ======================="
4166 $RUNAS $SETSTRIPE $DIR/d65f && error "setstripe succeeded" || true
4168 run_test 65f "dir setstripe permission (should return error) ==="
4172 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/d65 ||error "setstripe"
4173 $SETSTRIPE -d $DIR/d65 || error "setstripe"
4174 $GETSTRIPE -v $DIR/d65 | grep "Default" || \
4175 error "delete default stripe failed"
4177 run_test 65g "directory setstripe -d ==========================="
4181 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/d65 ||error "setstripe"
4182 mkdir -p $DIR/d65/dd1
4183 [ $($GETSTRIPE -c $DIR/d65) == $($GETSTRIPE -c $DIR/d65/dd1) ] ||
4184 error "stripe info inherit failed"
4186 run_test 65h "directory stripe info inherit ===================="
4188 test_65i() { # bug6367
4189 $SETSTRIPE -S 65536 -c -1 $MOUNT
4191 run_test 65i "set non-default striping on root directory (bug 6367)="
4193 test_65ia() { # bug12836
4194 $GETSTRIPE $MOUNT || error "getstripe $MOUNT failed"
4196 run_test 65ia "getstripe on -1 default directory striping"
4198 test_65ib() { # bug12836
4199 $GETSTRIPE -v $MOUNT || error "getstripe -v $MOUNT failed"
4201 run_test 65ib "getstripe -v on -1 default directory striping"
4203 test_65ic() { # bug12836
4204 $LFS find -mtime -1 $MOUNT || error "find $MOUNT failed"
4206 run_test 65ic "new find on -1 default directory striping"
4208 test_65j() { # bug6367
4210 # if we aren't already remounting for each test, do so for this test
4211 if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
4212 cleanup || error "failed to unmount"
4215 $SETSTRIPE -d $MOUNT || error "setstripe failed"
4217 run_test 65j "set default striping on root directory (bug 6367)="
4219 test_65k() { # bug11679
4220 [ "$OSTCOUNT" -lt 2 ] && skip_env "too few OSTs" && return
4221 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4223 echo "Check OST status: "
4224 local MDS_OSCS=`do_facet $SINGLEMDS lctl dl |
4225 awk '/[oO][sS][cC].*md[ts]/ { print $4 }'`
4227 for OSC in $MDS_OSCS; do
4228 echo $OSC "is activate"
4229 do_facet $SINGLEMDS lctl --device %$OSC activate
4232 do_facet client mkdir -p $DIR/$tdir
4233 for INACTIVE_OSC in $MDS_OSCS; do
4234 echo "Deactivate: " $INACTIVE_OSC
4235 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
4236 for STRIPE_OSC in $MDS_OSCS; do
4237 OST=`osc_to_ost $STRIPE_OSC`
4238 IDX=`do_facet $SINGLEMDS lctl get_param -n lov.*md*.target_obd |
4239 awk -F: /$OST/'{ print $1 }' | head -n 1`
4241 [ -f $DIR/$tdir/$IDX ] && continue
4242 echo "$SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX"
4243 do_facet client $SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX
4245 [ $RC -ne 0 ] && error "setstripe should have succeeded"
4247 do_facet client rm -f $DIR/$tdir/*
4248 echo $INACTIVE_OSC "is Activate."
4249 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
4252 run_test 65k "validate manual striping works properly with deactivated OSCs"
4254 test_65l() { # bug 12836
4255 mkdir -p $DIR/$tdir/test_dir
4256 $SETSTRIPE -c -1 $DIR/$tdir/test_dir
4257 $LFS find -mtime -1 $DIR/$tdir >/dev/null
4259 run_test 65l "lfs find on -1 stripe dir ========================"
4261 # bug 2543 - update blocks count on client
4264 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
4266 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
4267 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
4269 run_test 66 "update inode blocks count on client ==============="
4275 if [ ! -z "$LLOOP" ]; then
4276 if swapon -s | grep -q $LLOOP; then
4277 swapoff $LLOOP || error "swapoff failed"
4280 $LCTL blockdev_detach $LLOOP || error "detach failed"
4284 if [ ! -z "$LLITELOOPLOAD" ]; then
4292 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
4296 swapon -s | awk '($1 == "'$1'") { print $4 }'
4299 # test case for lloop driver, basic function
4301 [ "$UID" != 0 ] && skip_env "must run as root" && return
4302 llite_lloop_enabled || \
4303 { skip_env "llite_lloop module disabled" && return; }
4305 trap cleanup_68 EXIT
4307 if ! module_loaded llite_lloop; then
4308 if load_module llite/llite_lloop; then
4311 skip_env "can't find module llite_lloop"
4316 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
4317 dd if=/dev/zero of=$DIR/f68a bs=4k count=1024
4318 $LCTL blockdev_attach $DIR/f68a $LLOOP || error "attach failed"
4320 directio rdwr $LLOOP 0 1024 4096 || error "direct write failed"
4321 directio rdwr $LLOOP 0 1025 4096 && error "direct write should fail"
4325 run_test 68a "lloop driver - basic test ========================"
4327 # excercise swapping to lustre by adding a high priority swapfile entry
4328 # and then consuming memory until it is used.
4329 test_68b() { # was test_68
4330 [ "$UID" != 0 ] && skip_env "must run as root" && return
4331 lctl get_param -n devices | grep -q obdfilter && \
4332 skip "local OST" && return
4334 grep -q llite_lloop /proc/modules
4335 [ $? -ne 0 ] && skip "can't find module llite_lloop" && return
4337 [ -z "`$LCTL list_nids | grep -v tcp`" ] && \
4338 skip "can't reliably test swap with TCP" && return
4340 MEMTOTAL=`meminfo MemTotal`
4341 NR_BLOCKS=$((MEMTOTAL>>8))
4342 [[ $NR_BLOCKS -le 2048 ]] && NR_BLOCKS=2048
4344 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
4345 dd if=/dev/zero of=$DIR/f68b bs=64k seek=$NR_BLOCKS count=1
4348 $LCTL blockdev_attach $DIR/f68b $LLOOP || error "attach failed"
4350 trap cleanup_68 EXIT
4352 swapon -p 32767 $LLOOP || error "swapon $LLOOP failed"
4354 echo "before: `swapon -s | grep $LLOOP`"
4355 $MEMHOG $MEMTOTAL || error "error allocating $MEMTOTAL kB"
4356 echo "after: `swapon -s | grep $LLOOP`"
4357 SWAPUSED=`swap_used $LLOOP`
4361 [ $SWAPUSED -eq 0 ] && echo "no swap used???" || true
4363 run_test 68b "support swapping to Lustre ========================"
4365 # bug5265, obdfilter oa2dentry return -ENOENT
4366 # #define OBD_FAIL_OST_ENOENT 0x217
4368 remote_ost_nodsh && skip "remote OST with nodsh" && return
4371 $SETSTRIPE -c 1 -i 0 $f
4373 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
4375 do_facet ost1 lctl set_param fail_loc=0x217
4376 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
4377 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
4379 do_facet ost1 lctl set_param fail_loc=0
4380 $DIRECTIO write $f 0 2 || error "write error"
4382 cancel_lru_locks osc
4383 $DIRECTIO read $f 0 1 || error "read error"
4385 do_facet ost1 lctl set_param fail_loc=0x217
4386 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
4388 do_facet ost1 lctl set_param fail_loc=0
4391 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
4395 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
4397 run_test 71 "Running dbench on lustre (don't segment fault) ===="
4399 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
4400 check_kernel_version 43 || return 0
4401 [ "$RUNAS_ID" = "$UID" ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4403 # Check that testing environment is properly set up. Skip if not
4404 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS || {
4405 skip_env "User $RUNAS_ID does not exist - skipping"
4408 # We had better clear the $DIR to get enough space for dd
4413 $RUNAS dd if=/dev/zero of=$DIR/f72 bs=512 count=1 || error
4414 # See if we are still setuid/sgid
4415 test -u $DIR/f72 -o -g $DIR/f72 && error "S/gid is not dropped on write"
4416 # Now test that MDS is updated too
4417 cancel_lru_locks mdc
4418 test -u $DIR/f72 -o -g $DIR/f72 && error "S/gid is not dropped on MDS"
4422 run_test 72a "Test that remove suid works properly (bug5695) ===="
4424 test_72b() { # bug 24226 -- keep mode setting when size is not changing
4427 [ "$RUNAS_ID" = "$UID" ] && \
4428 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4429 [ "$RUNAS_ID" -eq 0 ] && \
4430 skip_env "RUNAS_ID = 0 -- skipping" && return
4432 # Check that testing environment is properly set up. Skip if not
4433 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS || {
4434 skip_env "User $RUNAS_ID does not exist - skipping"
4437 touch $DIR/${tfile}-f{g,u}
4438 mkdir $DIR/${tfile}-d{g,u}
4439 chmod 770 $DIR/${tfile}-{f,d}{g,u}
4440 chmod g+s $DIR/${tfile}-{f,d}g
4441 chmod u+s $DIR/${tfile}-{f,d}u
4442 for perm in 777 2777 4777; do
4443 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
4444 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
4445 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
4446 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
4450 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
4452 # bug 3462 - multiple simultaneous MDC requests
4456 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
4459 lctl set_param fail_loc=0x80000129
4460 $MULTIOP $DIR/d73-1/f73-2 Oc &
4462 lctl set_param fail_loc=0
4464 $MULTIOP $DIR/d73-2/f73-3 Oc &
4468 wait $pid1 || return 1
4472 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
4473 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
4474 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
4478 run_test 73 "multiple MDC requests (should not deadlock)"
4480 test_74a() { # bug 6149, 6184
4481 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
4483 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
4484 # will spin in a tight reconnection loop
4486 lctl set_param fail_loc=0x8000030e
4487 # get any lock that won't be difficult - lookup works.
4489 lctl set_param fail_loc=0
4493 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
4495 test_74b() { # bug 13310
4496 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
4498 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
4499 # will spin in a tight reconnection loop
4500 lctl set_param fail_loc=0x8000030e
4501 # get a "difficult" lock
4503 lctl set_param fail_loc=0
4507 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
4510 #define OBD_FAIL_LDLM_NEW_LOCK
4511 lctl set_param fail_loc=0x80000319
4512 touch $DIR/$tfile && error "Touch successful"
4515 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
4518 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
4521 get_inode_slab_tunables() {
4522 awk '/lustre_inode_cache/ {print $9," ",$10," ",$11; exit}' /proc/slabinfo
4525 set_inode_slab_tunables() {
4526 echo "lustre_inode_cache $1" > /proc/slabinfo
4529 test_76() { # Now for bug 20433, added originally in bug 1443
4530 local SLAB_SETTINGS=`get_inode_slab_tunables`
4531 local CPUS=`getconf _NPROCESSORS_ONLN`
4532 # we cannot set limit below 1 which means 1 inode in each
4533 # per-cpu cache is still allowed
4534 set_inode_slab_tunables "1 1 0"
4535 cancel_lru_locks osc
4536 BEFORE_INODES=`num_inodes`
4537 echo "before inodes: $BEFORE_INODES"
4539 [ "$SLOW" = "no" ] && COUNT=100
4540 for i in `seq $COUNT`; do
4544 cancel_lru_locks osc
4545 AFTER_INODES=`num_inodes`
4546 echo "after inodes: $AFTER_INODES"
4548 while [ $((AFTER_INODES-1*CPUS)) -gt $BEFORE_INODES ]; do
4550 AFTER_INODES=`num_inodes`
4552 echo "wait $wait seconds inodes: $AFTER_INODES"
4553 if [ $wait -gt 30 ]; then
4554 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
4557 set_inode_slab_tunables "$SLAB_SETTINGS"
4559 run_test 76 "confirm clients recycle inodes properly ===="
4565 # Note: in sptlrpc modes which enable its own bulk checksum, the
4566 # original crc32_le bulk checksum will be automatically disabled,
4567 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
4568 # will be checked by sptlrpc code against sptlrpc bulk checksum.
4569 # In this case set_checksums() will not be no-op, because sptlrpc
4570 # bulk checksum will be enabled all through the test.
4572 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
4573 lctl set_param -n osc.*.checksums $1
4577 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
4578 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
4579 CKSUM_TYPES=${CKSUM_TYPES:-"crc32 adler"}
4580 [ "$ORIG_CSUM_TYPE" = "crc32c" ] && CKSUM_TYPES="$CKSUM_TYPES crc32c"
4583 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
4584 log "set checksum type to $1"
4587 F77_TMP=$TMP/f77-temp
4590 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
4591 error "error writing to $F77_TMP"
4594 test_77a() { # bug 10889
4595 $GSS && skip "could not run with gss" && return
4596 [ ! -f $F77_TMP ] && setup_f77
4598 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
4602 run_test 77a "normal checksum read/write operation ============="
4604 test_77b() { # bug 10889
4605 $GSS && skip "could not run with gss" && return
4606 [ ! -f $F77_TMP ] && setup_f77
4607 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
4608 lctl set_param fail_loc=0x80000409
4610 dd if=$F77_TMP of=$DIR/f77b bs=1M count=$F77SZ conv=sync || \
4611 error "dd error: $?"
4612 lctl set_param fail_loc=0
4615 run_test 77b "checksum error on client write ===================="
4617 test_77c() { # bug 10889
4618 $GSS && skip "could not run with gss" && return
4619 [ ! -f $DIR/f77b ] && skip "requires 77b - skipping" && return
4621 for algo in $CKSUM_TYPES; do
4622 cancel_lru_locks osc
4623 set_checksum_type $algo
4624 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
4625 lctl set_param fail_loc=0x80000408
4626 cmp $F77_TMP $DIR/f77b || error "file compare failed"
4627 lctl set_param fail_loc=0
4630 set_checksum_type $ORIG_CSUM_TYPE
4633 run_test 77c "checksum error on client read ==================="
4635 test_77d() { # bug 10889
4636 $GSS && skip "could not run with gss" && return
4637 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
4638 lctl set_param fail_loc=0x80000409
4640 directio write $DIR/f77 0 $F77SZ $((1024 * 1024)) || \
4641 error "direct write: rc=$?"
4642 lctl set_param fail_loc=0
4645 run_test 77d "checksum error on OST direct write ==============="
4647 test_77e() { # bug 10889
4648 $GSS && skip "could not run with gss" && return
4649 [ ! -f $DIR/f77 ] && skip "requires 77d - skipping" && return
4650 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
4651 lctl set_param fail_loc=0x80000408
4653 cancel_lru_locks osc
4654 directio read $DIR/f77 0 $F77SZ $((1024 * 1024)) || \
4655 error "direct read: rc=$?"
4656 lctl set_param fail_loc=0
4659 run_test 77e "checksum error on OST direct read ================"
4661 test_77f() { # bug 10889
4662 $GSS && skip "could not run with gss" && return
4664 for algo in $CKSUM_TYPES; do
4665 cancel_lru_locks osc
4666 set_checksum_type $algo
4667 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
4668 lctl set_param fail_loc=0x409
4669 directio write $DIR/f77 0 $F77SZ $((1024 * 1024)) && \
4670 error "direct write succeeded"
4671 lctl set_param fail_loc=0
4673 set_checksum_type $ORIG_CSUM_TYPE
4676 run_test 77f "repeat checksum error on write (expect error) ===="
4678 test_77g() { # bug 10889
4679 $GSS && skip "could not run with gss" && return
4680 remote_ost_nodsh && skip "remote OST with nodsh" && return
4682 [ ! -f $F77_TMP ] && setup_f77
4684 $SETSTRIPE -c 1 -i 0 $DIR/f77g
4685 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
4686 do_facet ost1 lctl set_param fail_loc=0x8000021a
4688 dd if=$F77_TMP of=$DIR/f77g bs=1M count=$F77SZ || \
4689 error "write error: rc=$?"
4690 do_facet ost1 lctl set_param fail_loc=0
4693 run_test 77g "checksum error on OST write ======================"
4695 test_77h() { # bug 10889
4696 $GSS && skip "could not run with gss" && return
4697 remote_ost_nodsh && skip "remote OST with nodsh" && return
4699 [ ! -f $DIR/f77g ] && skip "requires 77g - skipping" && return
4700 cancel_lru_locks osc
4701 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
4702 do_facet ost1 lctl set_param fail_loc=0x8000021b
4704 cmp $F77_TMP $DIR/f77g || error "file compare failed"
4705 do_facet ost1 lctl set_param fail_loc=0
4708 run_test 77h "checksum error on OST read ======================="
4710 test_77i() { # bug 13805
4711 $GSS && skip "could not run with gss" && return
4712 #define OBD_FAIL_OSC_CONNECT_CKSUM 0x40b
4713 lctl set_param fail_loc=0x40b
4714 remount_client $MOUNT
4715 lctl set_param fail_loc=0
4716 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
4717 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
4718 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
4719 [ "$algo" = "crc32" ] || error "algo set to $algo instead of crc32"
4721 remount_client $MOUNT
4723 run_test 77i "client not supporting OSD_CONNECT_CKSUM =========="
4725 test_77j() { # bug 13805
4726 $GSS && skip "could not run with gss" && return
4727 #define OBD_FAIL_OSC_CKSUM_ADLER_ONLY 0x40c
4728 lctl set_param fail_loc=0x40c
4729 remount_client $MOUNT
4730 lctl set_param fail_loc=0
4731 sleep 2 # wait async osc connect to finish
4732 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
4733 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
4734 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
4735 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
4737 remount_client $MOUNT
4739 run_test 77j "client only supporting ADLER32 ===================="
4741 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
4745 test_78() { # bug 10901
4746 remote_ost || { skip_env "local OST" && return; }
4749 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
4750 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
4751 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
4752 echo "MemTotal: $MEMTOTAL"
4753 # reserve 256MB of memory for the kernel and other running processes,
4754 # and then take 1/2 of the remaining memory for the read/write buffers.
4755 if [ $MEMTOTAL -gt 512 ] ;then
4756 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
4758 # for those poor memory-starved high-end clusters...
4759 MEMTOTAL=$((MEMTOTAL / 2))
4761 echo "Mem to use for directio: $MEMTOTAL"
4762 [ $F78SIZE -gt $MEMTOTAL ] && F78SIZE=$MEMTOTAL
4763 [ $F78SIZE -gt 512 ] && F78SIZE=512
4764 [ $F78SIZE -gt $((MAXFREE / 1024)) ] && F78SIZE=$((MAXFREE / 1024))
4765 SMALLESTOST=`lfs df $DIR |grep OST | awk '{print $4}' |sort -n |head -1`
4766 echo "Smallest OST: $SMALLESTOST"
4767 [ $SMALLESTOST -lt 10240 ] && \
4768 skip "too small OSTSIZE, useless to run large O_DIRECT test" && return 0
4770 [ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ] && \
4771 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
4773 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
4774 echo "File size: $F78SIZE"
4775 $SETSTRIPE -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
4776 for i in `seq 1 $NSEQ`
4778 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
4779 echo directIO rdwr round $i of $NSEQ
4780 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
4785 run_test 78 "handle large O_DIRECT writes correctly ============"
4787 test_79() { # bug 12743
4788 wait_delete_completed
4790 BKTOTAL=$(calc_osc_kbytes kbytestotal)
4791 BKFREE=$(calc_osc_kbytes kbytesfree)
4792 BKAVAIL=$(calc_osc_kbytes kbytesavail)
4794 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
4795 DFTOTAL=`echo $STRING | cut -d, -f1`
4796 DFUSED=`echo $STRING | cut -d, -f2`
4797 DFAVAIL=`echo $STRING | cut -d, -f3`
4798 DFFREE=$(($DFTOTAL - $DFUSED))
4800 ALLOWANCE=$((64 * $OSTCOUNT))
4802 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
4803 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
4804 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
4806 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
4807 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
4808 error "df free($DFFREE) mismatch OST free($BKFREE)"
4810 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
4811 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
4812 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
4815 run_test 79 "df report consistency check ======================="
4817 test_80() { # bug 10718
4818 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
4820 local BEFORE=`date +%s`
4821 cancel_lru_locks osc
4822 local AFTER=`date +%s`
4823 local DIFF=$((AFTER-BEFORE))
4824 if [ $DIFF -gt 1 ] ; then
4825 error "elapsed for 1M@1T = $DIFF"
4830 run_test 80 "Page eviction is equally fast at high offsets too ===="
4832 test_81a() { # LU-456
4833 remote_ost_nodsh && skip "remote OST with nodsh" && return
4834 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
4835 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
4836 do_facet ost0 lctl set_param fail_loc=0x80000228
4838 # write should trigger a retry and success
4839 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
4840 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
4842 if [ $RC -ne 0 ] ; then
4843 error "write should success, but failed for $RC"
4846 run_test 81a "OST should retry write when get -ENOSPC ==============="
4848 test_81b() { # LU-456
4849 remote_ost_nodsh && skip "remote OST with nodsh" && return
4850 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
4851 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
4852 do_facet ost0 lctl set_param fail_loc=0x228
4854 # write should retry several times and return -ENOSPC finally
4855 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
4856 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
4859 if [ $RC -ne $ENOSPC ] ; then
4860 error "dd should fail for -ENOSPC, but succeed."
4863 run_test 81b "OST should return -ENOSPC when retry still fails ======="
4865 test_82() { # LU-1031
4866 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10
4870 multiop_bg_pause $DIR/$tfile OG${gid1}_g${gid1}c || return 1
4872 multiop_bg_pause $DIR/$tfile O_G${gid2}r10g${gid2}c || return 2
4874 kill -USR1 $MULTIPID2
4876 if [[ `ps h -o comm -p $MULTIPID2` == "" ]]; then
4877 error "First grouplock does not block second one"
4879 echo "Second grouplock blocks first one"
4881 kill -USR1 $MULTIPID1
4885 run_test 82 "Basic grouplock test ==============================="
4888 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && \
4890 mkdir -p $DIR/d99cvsroot
4891 chown $RUNAS_ID $DIR/d99cvsroot
4892 local oldPWD=$PWD # bug 13584, use $TMP as working dir
4895 $RUNAS cvs -d $DIR/d99cvsroot init || error
4898 run_test 99a "cvs init ========================================="
4901 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
4902 [ ! -d $DIR/d99cvsroot ] && test_99a
4904 # some versions of cvs import exit(1) when asked to import links or
4905 # files they can't read. ignore those files.
4906 TOIGNORE=$(find . -type l -printf '-I %f\n' -o \
4907 ! -perm +4 -printf '-I %f\n')
4908 $RUNAS cvs -d $DIR/d99cvsroot import -m "nomesg" $TOIGNORE \
4909 d99reposname vtag rtag
4911 run_test 99b "cvs import ======================================="
4914 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
4915 [ ! -d $DIR/d99cvsroot ] && test_99b
4917 mkdir -p $DIR/d99reposname
4918 chown $RUNAS_ID $DIR/d99reposname
4919 $RUNAS cvs -d $DIR/d99cvsroot co d99reposname
4921 run_test 99c "cvs checkout ====================================="
4924 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
4925 [ ! -d $DIR/d99cvsroot ] && test_99c
4926 cd $DIR/d99reposname
4928 $RUNAS cvs add -m 'addmsg' foo99
4930 run_test 99d "cvs add =========================================="
4933 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
4934 [ ! -d $DIR/d99cvsroot ] && test_99c
4935 cd $DIR/d99reposname
4938 run_test 99e "cvs update ======================================="
4941 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
4942 [ ! -d $DIR/d99cvsroot ] && test_99d
4943 cd $DIR/d99reposname
4944 $RUNAS cvs commit -m 'nomsg' foo99
4945 rm -fr $DIR/d99cvsroot
4947 run_test 99f "cvs commit ======================================="
4950 [ "$NETTYPE" = tcp ] || \
4951 { skip "TCP secure port test, not useful for NETTYPE=$NETTYPE" && \
4954 remote_ost_nodsh && skip "remote OST with nodsh" && return
4955 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4957 { skip "useless for local single node setup" && return; }
4959 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
4960 [ "$PROT" != "tcp" ] && continue
4961 RPORT=$(echo $REMOTE | cut -d: -f2)
4962 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
4965 LPORT=`echo $LOCAL | cut -d: -f2`
4966 if [ $LPORT -ge 1024 ]; then
4967 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
4969 error_exit "local: $LPORT > 1024, remote: $RPORT"
4972 [ "$rc" = 0 ] || error_exit "privileged port not found" )
4974 run_test 100 "check local port using privileged port ==========="
4976 function get_named_value()
4985 echo $line | sed "s/^$tag[ ]*//"
4992 export CACHE_MAX=`$LCTL get_param -n llite.*.max_cached_mb | head -n 1`
4994 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
5002 [ "$CPU" = "UML" ] && nreads=1000
5003 local cache_limit=32
5005 $LCTL set_param -n osc.*-osc*.rpc_stats 0
5006 trap cleanup_101a EXIT
5007 $LCTL set_param -n llite.*.read_ahead_stats 0
5008 $LCTL set_param -n llite.*.max_cached_mb $cache_limit
5011 # randomly read 10000 of 64K chunks from file 3x 32MB in size
5013 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
5014 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
5017 for s in `$LCTL get_param -n llite.*.read_ahead_stats | \
5018 get_named_value 'read but discarded' | cut -d" " -f1`; do
5019 discard=$(($discard + $s))
5023 if [ $(($discard * 10)) -gt $nreads ] ;then
5024 $LCTL get_param osc.*-osc*.rpc_stats
5025 $LCTL get_param llite.*.read_ahead_stats
5026 error "too many ($discard) discarded pages"
5028 rm -f $DIR/$tfile || true
5030 run_test 101a "check read-ahead for random reads ================"
5035 STRIPE_COUNT=$OSTCOUNT
5038 local list=$(comma_list $(osts_nodes))
5039 do_nodes $list $LCTL set_param -n obdfilter.*.read_cache_enable=0
5040 do_nodes $list $LCTL set_param -n obdfilter.*.writethrough_cache_enable=0
5042 trap cleanup_test101bc EXIT
5043 # prepare the read-ahead file
5044 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
5046 dd if=/dev/zero of=$DIR/$tfile bs=1024k count=100 2> /dev/null
5049 cleanup_test101bc() {
5054 local list=$(comma_list $(osts_nodes))
5055 do_nodes $list $LCTL set_param -n obdfilter.*.read_cache_enable=1
5056 do_nodes $list $LCTL set_param -n obdfilter.*.writethrough_cache_enable=1
5060 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
5065 local STRIPE_SIZE=1048576
5066 local RA_INC=1048576
5067 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
5068 local FILE_LENGTH=$((64*100))
5069 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
5070 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
5071 DISCARD=`$LCTL get_param -n llite.*.read_ahead_stats | \
5072 get_named_value 'read but discarded' | \
5073 cut -d" " -f1 | calc_total`
5074 if [ $DISCARD -gt $discard_limit ]; then
5075 $LCTL get_param llite.*.read_ahead_stats
5076 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
5078 echo "Read-ahead success for size ${READ_SIZE}"
5083 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping stride IO stride-ahead test" && return
5084 local STRIPE_SIZE=1048576
5085 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
5086 local FILE_LENGTH=$((STRIPE_SIZE*100))
5087 local ITERATION=$((FILE_LENGTH/STRIDE_SIZE))
5088 # prepare the read-ahead file
5090 cancel_lru_locks osc
5091 for BIDX in 2 4 8 16 32 64 128 256
5093 local BSIZE=$((BIDX*4096))
5094 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
5095 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
5096 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
5097 $LCTL set_param -n llite.*.read_ahead_stats 0
5098 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
5099 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
5100 cancel_lru_locks osc
5106 run_test 101b "check stride-io mode read-ahead ================="
5109 local STRIPE_SIZE=1048576
5110 local FILE_LENGTH=$((STRIPE_SIZE*100))
5116 cancel_lru_locks osc
5117 $LCTL set_param osc.*.rpc_stats 0
5118 $READS -f $DIR/$tfile -s$FILE_LENGTH -b65536 -n$nreads -t 180
5119 for osc in $($LCTL get_param -N osc.*); do
5120 if [ "$osc" == "osc.num_refs" ]; then
5124 local lines=$($LCTL get_param -n ${osc}.rpc_stats | wc | awk '{print $1}')
5125 if [ $lines -le 20 ]; then
5129 local rpc4k=$($LCTL get_param -n ${osc}.rpc_stats |
5130 awk '$1 == "1:" { print $2; exit; }')
5131 local rpc8k=$($LCTL get_param -n ${osc}.rpc_stats |
5132 awk '$1 == "2:" { print $2; exit; }')
5133 local rpc16k=$($LCTL get_param -n ${osc}.rpc_stats |
5134 awk '$1 == "4:" { print $2; exit; }')
5135 local rpc32k=$($LCTL get_param -n ${osc}.rpc_stats |
5136 awk '$1 == "8:" { print $2; exit; }')
5138 [ $rpc4k != 0 ] && error "Small 4k read IO ${rpc4k}!"
5139 [ $rpc8k != 0 ] && error "Small 8k read IO ${rpc8k}!"
5140 [ $rpc16k != 0 ] && error "Small 16k read IO ${rpc16k}!"
5141 [ $rpc32k != 0 ] && error "Small 32k read IO ${rpc32k}!"
5142 echo "${osc} rpc check passed!"
5147 run_test 101c "check stripe_size aligned read-ahead ================="
5150 $LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1
5151 $LCTL set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
5155 local file=$DIR/$tfile
5156 local size=${FILESIZE_101c:-500}
5157 local ra_MB=${READAHEAD_MB:-40}
5159 local space=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
5160 [ $space -gt $((size / 1024)) ] ||
5161 { skip "Need free space ${size}M, have $space" && return; }
5163 echo Creating ${size}M test file $file
5164 dd if=/dev/zero of=$file bs=1M count=$size
5165 echo Cancel LRU locks on lustre client to flush the client cache
5166 cancel_lru_locks osc
5168 echo Disable read-ahead
5169 local old_READAHEAD=$(set_read_ahead 0)
5171 echo Reading the test file $file with read-ahead disabled
5172 time_ra_OFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$size")
5174 echo Cancel LRU locks on lustre client to flush the client cache
5175 cancel_lru_locks osc
5176 echo Enable read-ahead with ${ra_MB}MB
5177 set_read_ahead $ra_MB
5179 echo Reading the test file $file with read-ahead enabled
5180 time_ra_ON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$size")
5182 echo read-ahead disabled time read $time_ra_OFF
5183 echo read-ahead enabled time read $time_ra_ON
5185 set_read_ahead $old_READAHEAD
5188 [ $time_ra_ON -lt $time_ra_OFF ] ||
5189 error "read-ahead enabled time read (${time_ra_ON}s) is more than
5190 read-ahead disabled time read (${time_ra_OFF}s) filesize ${size}M"
5192 run_test 101d "file read with and without read-ahead enabled ================="
5195 local file=$DIR/$tfile
5200 local space=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
5201 local need_space=$((count * size))
5202 [ $space -gt $need_space ] ||
5203 { skip_env "Need free space $need_space, have $space" && return; }
5205 echo Creating $count ${size}K test files
5206 for ((i = 0; i < $count; i++)); do
5207 dd if=/dev/zero of=${file}_${i} bs=$blksize count=$size 2>/dev/null
5210 echo Cancel LRU locks on lustre client to flush the client cache
5211 cancel_lru_locks osc
5213 echo Reset readahead stats
5214 $LCTL set_param -n llite.*.read_ahead_stats 0
5216 for ((i = 0; i < $count; i++)); do
5217 dd if=${file}_${i} of=/dev/null bs=$blksize count=$size 2>/dev/null
5220 local miss=$($LCTL get_param -n llite.*.read_ahead_stats | \
5221 get_named_value 'misses' | cut -d" " -f1 | calc_total)
5223 for ((i = 0; i < $count; i++)); do
5224 rm -rf ${file}_${i} 2>/dev/null
5227 #10000 means 20% reads are missing in readahead
5228 [ $miss -lt 10000 ] || error "misses too much for small reads"
5230 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
5232 cleanup_test101f() {
5234 $LCTL set_param -n llite.*.max_read_ahead_whole_mb $MAX_WHOLE_MB
5235 rm -rf $DIR/$tfile 2>/dev/null
5239 local file=$DIR/$tfile
5242 MAX_WHOLE_MB=$($LCTL get_param -n llite.*.max_read_ahead_whole_mb)
5243 $LCTL set_param -n llite.*.max_read_ahead_whole_mb 2
5244 dd if=/dev/zero of=${file} bs=2097152 count=1 2>/dev/null
5245 trap cleanup_test101f EXIT
5247 echo Cancel LRU locks on lustre client to flush the client cache
5248 cancel_lru_locks osc
5250 echo Reset readahead stats
5251 $LCTL set_param -n llite.*.read_ahead_stats 0
5252 # Random read in a 2M file, because max_read_ahead_whole_mb = 2M,
5253 # readahead should read in 2M file on second read, so only miss
5255 echo Random 4K reads on 2M file for 1000 times
5256 $READS -f $file -s 2097152 -b 4096 -n $nreads
5258 echo checking missing pages
5259 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
5260 get_named_value 'misses' | cut -d" " -f1 | calc_total)
5262 [ $miss -lt 3 ] || error "misses too much pages!"
5265 run_test 101f "check read-ahead for max_read_ahead_whole_mb"
5269 chown $RUNAS_ID $DIR/$tdir
5272 STRIPE_COUNT=$OSTCOUNT
5273 [ $OSTCOUNT -gt 4 ] && STRIPE_COUNT=4
5275 trap cleanup_test102 EXIT
5277 $1 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
5279 for num in 1 2 3 4; do
5280 for count in $(seq 1 $STRIPE_COUNT); do
5281 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
5282 local size=`expr $STRIPE_SIZE \* $num`
5283 local file=file"$num-$idx-$count"
5284 $1 $SETSTRIPE -S $size -i $idx -c $count $file
5290 $1 $TAR cf $TMP/f102.tar $tdir --xattrs
5296 rm -rf $DIR/d0.sanity/d102
5300 local testfile=$DIR/xattr_testfile
5304 [ "$UID" != 0 ] && skip_env "must run as root" && return
5305 [ -z "`lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr`" ] &&
5306 skip_env "must have user_xattr" && return
5308 [ -z "$(which setfattr 2>/dev/null)" ] &&
5309 skip_env "could not find setfattr" && return
5311 echo "set/get xattr..."
5312 setfattr -n trusted.name1 -v value1 $testfile || error
5313 getfattr -n trusted.name1 $testfile 2> /dev/null |
5314 grep "trusted.name1=.value1" ||
5315 error "$testfile missing trusted.name1=value1"
5317 setfattr -n user.author1 -v author1 $testfile || error
5318 getfattr -n user.author1 $testfile 2> /dev/null |
5319 grep "user.author1=.author1" ||
5320 error "$testfile missing trusted.author1=author1"
5323 setfattr -n trusted.name2 -v value2 $testfile ||
5324 error "$testfile unable to set trusted.name2"
5325 setfattr -n trusted.name3 -v value3 $testfile ||
5326 error "$testfile unable to set trusted.name3"
5327 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
5328 grep "trusted.name" | wc -l) -eq 3 ] ||
5329 error "$testfile missing 3 trusted.name xattrs"
5331 setfattr -n user.author2 -v author2 $testfile ||
5332 error "$testfile unable to set user.author2"
5333 setfattr -n user.author3 -v author3 $testfile ||
5334 error "$testfile unable to set user.author3"
5335 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
5336 grep "user.author" | wc -l) -eq 3 ] ||
5337 error "$testfile missing 3 user.author xattrs"
5339 echo "remove xattr..."
5340 setfattr -x trusted.name1 $testfile ||
5341 error "$testfile error deleting trusted.name1"
5342 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
5343 error "$testfile did not delete trusted.name1 xattr"
5345 setfattr -x user.author1 $testfile ||
5346 error "$testfile error deleting user.author1"
5347 getfattr -d -m user $testfile 2> /dev/null | grep "user.author1" &&
5348 error "$testfile did not delete trusted.name1 xattr"
5350 # b10667: setting lustre special xattr be silently discarded
5351 echo "set lustre special xattr ..."
5352 setfattr -n "trusted.lov" -v "invalid value" $testfile ||
5353 error "$testfile allowed setting trusted.lov"
5355 run_test 102a "user xattr test =================================="
5358 # b10930: get/set/list trusted.lov xattr
5359 echo "get/set/list trusted.lov xattr ..."
5360 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
5361 local testfile=$DIR/$tfile
5362 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
5363 error "setstripe failed"
5364 local STRIPECOUNT=$($GETSTRIPE -c $testfile) ||
5365 error "getstripe failed"
5366 getfattr -d -m "^trusted" $testfile 2> /dev/null | \
5367 grep "trusted.lov" || error "can't get trusted.lov from $testfile"
5369 local testfile2=${testfile}2
5370 local value=`getfattr -n trusted.lov $testfile 2> /dev/null | \
5371 grep "trusted.lov" |sed -e 's/[^=]\+=//'`
5374 setfattr -n trusted.lov -v $value $testfile2
5375 local stripe_size=$($GETSTRIPE -S $testfile2)
5376 local stripe_count=$($GETSTRIPE -c $testfile2)
5377 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
5378 [ $stripe_count -eq $STRIPECOUNT ] ||
5379 error "stripe count $stripe_count != $STRIPECOUNT"
5382 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
5385 # b10930: get/set/list lustre.lov xattr
5386 echo "get/set/list lustre.lov xattr ..."
5387 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
5389 chown $RUNAS_ID $DIR/$tdir
5390 local testfile=$DIR/$tdir/$tfile
5391 $RUNAS $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
5392 error "setstripe failed"
5393 local STRIPECOUNT=$($RUNAS $GETSTRIPE -c $testfile) ||
5394 error "getstripe failed"
5395 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
5396 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
5398 local testfile2=${testfile}2
5399 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
5400 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
5402 $RUNAS $MCREATE $testfile2
5403 $RUNAS setfattr -n lustre.lov -v $value $testfile2
5404 local stripe_size=$($RUNAS $GETSTRIPE -S $testfile2)
5405 local stripe_count=$($RUNAS $GETSTRIPE -c $testfile2)
5406 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
5407 [ $stripe_count -eq $STRIPECOUNT ] ||
5408 error "stripe count $stripe_count != $STRIPECOUNT"
5410 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
5412 compare_stripe_info1() {
5413 local stripe_index_all_zero=true
5415 for num in 1 2 3 4; do
5416 for count in $(seq 1 $STRIPE_COUNT); do
5417 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
5418 local size=$((STRIPE_SIZE * num))
5419 local file=file"$num-$offset-$count"
5420 stripe_size=$(lfs getstripe -S $PWD/$file)
5421 [ $stripe_size -ne $size ] &&
5422 error "$file: size $stripe_size != $size"
5423 stripe_count=$(lfs getstripe -c $PWD/$file)
5424 # allow fewer stripes to be created, ORI-601
5425 [ $stripe_count -lt $(((3 * count + 3) / 4)) ]&&
5426 error "$file: count $stripe_count != $count"
5427 stripe_index=$(lfs getstripe -i $PWD/$file)
5428 [ $stripe_index -ne 0 ] &&
5429 stripe_index_all_zero=false
5433 $stripe_index_all_zero &&
5434 error "all files are being extracted starting from OST index 0"
5439 [ -n "$(which tar 2>/dev/null)" ] &&
5440 strings $(which tar) | grep -q "lustre" && echo tar
5444 # b10930: tar test for trusted.lov xattr
5445 TAR=$(find_lustre_tar)
5446 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
5447 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
5450 $TAR xf $TMP/f102.tar -C $DIR/d102d --xattrs
5452 compare_stripe_info1
5454 run_test 102d "tar restore stripe info from tarfile,not keep osts ==========="
5457 # b10930: tar test for trusted.lov xattr
5458 TAR=$(find_lustre_tar)
5459 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
5460 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
5464 $TAR cf - --xattrs $tdir | $TAR xf - --xattrs -C $DIR/d102f
5466 compare_stripe_info1
5468 run_test 102f "tar copy files, not keep osts ==========="
5471 local xsize=${1:-1024} # in bytes
5472 local file=$DIR/$tfile
5474 [ -z $(lctl get_param -n mdc.*.connect_flags | grep xattr) ] &&
5475 skip "must have user_xattr" && return 0
5476 [ -z "$(which setfattr 2>/dev/null)" ] &&
5477 skip_env "could not find setfattr" && return 0
5478 [ -z "$(which getfattr 2>/dev/null)" ] &&
5479 skip_env "could not find getfattr" && return 0
5483 local value="$(generate_string $xsize)"
5485 local xbig=trusted.big
5486 log "save $xbig on $file"
5487 setfattr -n $xbig -v $value $file ||
5488 error "saving $xbig on $file failed"
5490 local orig=$(get_xattr_value $xbig $file)
5491 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
5493 local xsml=trusted.sml
5494 log "save $xsml on $file"
5495 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
5497 local new=$(get_xattr_value $xbig $file)
5498 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
5500 log "grow $xsml on $file"
5501 setfattr -n $xsml -v "$value" $file ||
5502 error "growing $xsml on $file failed"
5504 new=$(get_xattr_value $xbig $file)
5505 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
5506 log "$xbig still valid after growing $xsml"
5511 test_102h() { # bug 15777
5514 run_test 102h "grow xattr from inside inode to external block"
5517 large_xattr_enabled || { skip "large_xattr disabled" && return; }
5518 grow_xattr $(max_xattr_size)
5520 run_test 102ha "grow xattr from inside inode to external inode"
5522 test_102i() { # bug 17038
5524 ln -s $DIR/$tfile $DIR/${tfile}link
5525 getfattr -n trusted.lov $DIR/$tfile || error "lgetxattr on $DIR/$tfile failed"
5526 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"
5527 rm -f $DIR/$tfile $DIR/${tfile}link
5529 run_test 102i "lgetxattr test on symbolic link ============"
5532 TAR=$(find_lustre_tar)
5533 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
5534 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
5535 setup_test102 "$RUNAS"
5537 chown $RUNAS_ID $DIR/d102j
5538 $RUNAS $TAR xf $TMP/f102.tar -C $DIR/d102j --xattrs
5540 compare_stripe_info1 "$RUNAS"
5542 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
5546 # b22187 just check that does not crash for regular file.
5547 setfattr -n trusted.lov $DIR/$tfile
5548 # b22187 'setfattr -n trusted.lov' should work as remove LOV EA for directories
5549 local test_kdir=$DIR/d102k
5551 local default_size=`$GETSTRIPE -S $test_kdir`
5552 local default_count=`$GETSTRIPE -c $test_kdir`
5553 local default_offset=`$GETSTRIPE -i $test_kdir`
5554 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $test_kdir ||
5555 error 'dir setstripe failed'
5556 setfattr -n trusted.lov $test_kdir
5557 local stripe_size=`$GETSTRIPE -S $test_kdir`
5558 local stripe_count=`$GETSTRIPE -c $test_kdir`
5559 local stripe_offset=`$GETSTRIPE -i $test_kdir`
5560 [ $stripe_size -eq $default_size ] ||
5561 error "stripe size $stripe_size != $default_size"
5562 [ $stripe_count -eq $default_count ] ||
5563 error "stripe count $stripe_count != $default_count"
5564 [ $stripe_offset -eq $default_offset ] ||
5565 error "stripe offset $stripe_offset != $default_offset"
5566 rm -rf $DIR/$tfile $test_kdir
5568 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
5571 # LU-532 trusted. xattr is invisible to non-root
5572 local testfile=$DIR/$tfile
5576 echo "listxattr as user..."
5577 chown $RUNAS_ID $testfile
5578 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
5579 grep -q "trusted" &&
5580 error "$testfile trusted xattrs are user visible"
5584 run_test 102l "listxattr filter test =================================="
5590 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
5595 [ "$UID" != 0 ] && skip_env "must run as root" && return
5596 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
5597 [ -z "$(which setfacl 2>/dev/null)" ] && skip_env "could not find setfacl" && return
5598 $GSS && skip "could not run under gss" && return
5600 declare -a identity_old
5602 for num in `seq $MDSCOUNT`; do
5603 switch_identity $num true || identity_old[$num]=$?
5610 echo "performing cp ..."
5611 run_acl_subtest cp || error
5612 echo "performing getfacl-noacl..."
5613 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
5614 echo "performing misc..."
5615 run_acl_subtest misc || error "misc test failed"
5616 echo "performing permissions..."
5617 run_acl_subtest permissions || error "permissions failed"
5618 echo "performing setfacl..."
5619 run_acl_subtest setfacl || error "setfacl test failed"
5621 # inheritance test got from HP
5622 echo "performing inheritance..."
5623 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
5624 chmod +x make-tree || error "chmod +x failed"
5625 run_acl_subtest inheritance || error "inheritance test failed"
5631 for num in `seq $MDSCOUNT`; do
5632 if [ "${identity_old[$num]}" = 1 ]; then
5633 switch_identity $num false || identity_old[$num]=$?
5637 run_test 103 "acl test ========================================="
5641 lfs df || error "lfs df failed"
5642 lfs df -ih || error "lfs df -ih failed"
5643 lfs df -h $DIR || error "lfs df -h $DIR failed"
5644 lfs df -i $DIR || error "lfs df -i $DIR failed"
5645 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
5646 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
5648 OSC=`lctl dl |grep OST0000-osc-[^M] |awk '{print $4}'`
5649 lctl --device %$OSC deactivate
5650 lfs df || error "lfs df with deactivated OSC failed"
5651 lctl --device %$OSC activate
5652 # wait the osc back to normal
5653 wait_osc_import_state client ost FULL
5655 lfs df || error "lfs df with reactivated OSC failed"
5658 run_test 104a "lfs df [-ih] [path] test ========================="
5661 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5663 denied_cnt=$((`$RUNAS $LFS check servers 2>&1 | grep "Permission denied" | wc -l`))
5664 if [ $denied_cnt -ne 0 ];
5666 error "lfs check servers test failed"
5669 run_test 104b "$RUNAS lfs check servers test ===================="
5672 # doesn't work on 2.4 kernels
5674 if [ -n "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ];
5676 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
5678 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
5682 run_test 105a "flock when mounted without -o flock test ========"
5686 if [ -n "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ];
5688 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
5690 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
5694 run_test 105b "fcntl when mounted without -o flock test ========"
5698 if [ -n "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ];
5700 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
5702 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
5706 run_test 105c "lockf when mounted without -o flock test ========"
5708 test_105d() { # bug 15924
5710 [ -z "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ] && \
5711 skip "mount w/o flock enabled" && return
5712 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
5713 $LCTL set_param fail_loc=0x80000315
5714 flocks_test 2 $DIR/$tdir
5716 run_test 105d "flock race (should not freeze) ========"
5718 test_105e() { # bug 22660 && 22040
5719 [ -z "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ] && \
5720 skip "mount w/o flock enabled" && return
5722 flocks_test 3 $DIR/$tfile
5724 run_test 105e "Two conflicting flocks from same process ======="
5726 test_106() { #bug 10921
5728 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
5729 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
5731 run_test 106 "attempt exec of dir followed by chown of that dir"
5740 local save_pattern=$(sysctl -n kernel.core_pattern)
5741 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
5742 sysctl -w kernel.core_pattern=$file
5743 sysctl -w kernel.core_uses_pid=0
5751 kill -s 11 $SLEEPPID
5753 if [ -e $file ]; then
5754 size=`stat -c%s $file`
5755 [ $size -eq 0 ] && error "Fail to create core file $file"
5757 error "Fail to create core file $file"
5760 sysctl -w kernel.core_pattern=$save_pattern
5761 sysctl -w kernel.core_uses_pid=$save_uses_pid
5764 run_test 107 "Coredump on SIG"
5768 mkdir $DIR/d110/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa || error "mkdir with 255 char fail"
5769 mkdir $DIR/d110/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb && error "mkdir with 256 char should fail, but not"
5770 touch $DIR/d110/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx || error "create with 255 char fail"
5771 touch $DIR/d110/yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy && error ""create with 256 char should fail, but not
5776 run_test 110 "filename length checking"
5779 OSTIO_pre=$(ps -e|grep ll_ost_io|awk '{print $4}'|sort -n|tail -1|\
5781 [ -z "$OSTIO_pre" ] && skip "no OSS threads" && \
5783 echo "Starting with $OSTIO_pre threads"
5786 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
5787 [ $NUMFREE -lt $NUMTEST ] && NUMTEST=$(($NUMFREE - 1000))
5788 echo "$NUMTEST creates/unlinks"
5790 createmany -o $DIR/$tdir/$tfile $NUMTEST
5791 unlinkmany $DIR/$tdir/$tfile $NUMTEST
5793 OSTIO_post=$(ps -e|grep ll_ost_io|awk '{print $4}'|sort -n|tail -1|\
5796 # don't return an error
5797 [ $OSTIO_post -eq $OSTIO_pre ] && echo \
5798 "WARNING: No new ll_ost_io threads were created ($OSTIO_pre)" &&\
5799 echo "This may be fine, depending on what ran before this test" &&\
5800 echo "and how fast this system is." && return
5802 echo "Started with $OSTIO_pre threads, ended with $OSTIO_post"
5804 run_test 115 "verify dynamic thread creation===================="
5807 wait_delete_completed
5808 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
5809 echo OST kbytes available: ${AVAIL[@]}
5810 MAXI=0; MAXV=${AVAIL[0]}
5811 MINI=0; MINV=${AVAIL[0]}
5812 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
5813 #echo OST $i: ${AVAIL[i]}kb
5814 if [ ${AVAIL[i]} -gt $MAXV ]; then
5815 MAXV=${AVAIL[i]}; MAXI=$i
5817 if [ ${AVAIL[i]} -lt $MINV ]; then
5818 MINV=${AVAIL[i]}; MINI=$i
5821 echo Min free space: OST $MINI: $MINV
5822 echo Max free space: OST $MAXI: $MAXV
5826 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs" && return
5828 echo -n "Free space priority "
5829 lctl get_param -n lov.*-clilov-*.qos_prio_free
5832 [ $MINV -gt 960000 ] && skip "too much free space in OST$MINI, skip" &&\
5835 # generate uneven OSTs
5836 mkdir -p $DIR/$tdir/OST${MINI}
5839 echo "Filling 25% remaining space in OST${MINI} with ${FILL}Kb"
5840 $SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI}||error "setstripe failed"
5842 while [ $FILL -gt 0 ]; do
5844 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i bs=2M count=1 2>/dev/null
5845 FILL=$(($FILL - 2048))
5853 DIFF=$(($MAXV - $MINV))
5854 DIFF2=$(($DIFF * 100 / $MINV))
5855 echo -n "diff=${DIFF}=${DIFF2}% must be > 20% for QOS mode..."
5856 if [ $DIFF2 -gt 20 ]; then
5859 echo "failed - QOS mode won't be used"
5860 error_ignore "QOS imbalance criteria not met"
5864 MINI1=$MINI; MINV1=$MINV
5865 MAXI1=$MAXI; MAXV1=$MAXV
5867 # now fill using QOS
5868 echo writing a bunch of files to QOS-assigned OSTs
5869 $SETSTRIPE -c 1 $DIR/$tdir
5871 while [ $FILL -gt 0 ]; do
5873 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1024 count=200 2>/dev/null
5874 FILL=$(($FILL - 200))
5877 echo "wrote $i 200k files"
5881 echo "Note: free space may not be updated, so measurements might be off"
5883 DIFF2=$(($MAXV - $MINV))
5884 echo "free space delta: orig $DIFF final $DIFF2"
5885 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
5886 DIFF=$(($MINV1 - ${AVAIL[$MINI1]}))
5887 echo "Wrote $DIFF to smaller OST $MINI1"
5888 DIFF2=$(($MAXV1 - ${AVAIL[$MAXI1]}))
5889 echo "Wrote $DIFF2 to larger OST $MAXI1"
5890 [ $DIFF -gt 0 ] && echo "Wrote $(($DIFF2 * 100 / $DIFF - 100))% more data to larger OST $MAXI1"
5892 # Figure out which files were written where
5893 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
5894 awk '/'$MINI1': / {print $2; exit}')
5896 MINC=$($GETSTRIPE --obd $UUID $DIR/$tdir | wc -l)
5897 echo "$MINC files created on smaller OST $MINI1"
5898 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
5899 awk '/'$MAXI1': / {print $2; exit}')
5901 MAXC=$($GETSTRIPE --obd $UUID $DIR/$tdir | wc -l)
5902 echo "$MAXC files created on larger OST $MAXI1"
5903 [ $MINC -gt 0 ] && echo "Wrote $(($MAXC * 100 / $MINC - 100))% more files to larger OST $MAXI1"
5904 [ $MAXC -gt $MINC ] || error_ignore "stripe QOS didn't balance free space"
5908 run_test 116 "stripe QOS: free space balance ==================="
5910 test_117() # bug 10891
5912 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
5913 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
5914 lctl set_param fail_loc=0x21e
5915 > $DIR/$tfile || error "truncate failed"
5916 lctl set_param fail_loc=0
5917 echo "Truncate succeeded."
5920 run_test 117 "verify fsfilt_extend =========="
5922 export OLD_RESENDCOUNT=""
5923 set_resend_count () {
5924 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
5925 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -1)
5926 lctl set_param -n $PROC_RESENDCOUNT $1
5927 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
5930 [ "$SLOW" = "no" ] && set_resend_count 4 # for reduce test_118* time (bug 14842)
5932 # Reset async IO behavior after error case
5934 FILE=$DIR/reset_async
5936 # Ensure all OSCs are cleared
5937 $SETSTRIPE -c -1 $FILE
5938 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
5943 test_118a() #bug 11710
5947 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
5948 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
5949 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
5951 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
5952 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
5957 run_test 118a "verify O_SYNC works =========="
5961 remote_ost_nodsh && skip "remote OST with nodsh" && return
5965 #define OBD_FAIL_OST_ENOENT 0x217
5966 set_nodes_failloc "$(osts_nodes)" 0x217
5967 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
5969 set_nodes_failloc "$(osts_nodes)" 0
5970 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
5971 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
5974 if [[ $RC -eq 0 ]]; then
5975 error "Must return error due to dropped pages, rc=$RC"
5979 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
5980 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
5984 echo "Dirty pages not leaked on ENOENT"
5986 # Due to the above error the OSC will issue all RPCs syncronously
5987 # until a subsequent RPC completes successfully without error.
5988 $MULTIOP $DIR/$tfile Ow4096yc
5993 run_test 118b "Reclaim dirty pages on fatal error =========="
5997 remote_ost_nodsh && skip "remote OST with nodsh" && return
6001 #define OBD_FAIL_OST_EROFS 0x216
6002 set_nodes_failloc "$(osts_nodes)" 0x216
6004 # multiop should block due to fsync until pages are written
6005 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
6009 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
6010 error "Multiop failed to block on fsync, pid=$MULTIPID"
6013 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6015 if [[ $WRITEBACK -eq 0 ]]; then
6016 error "No page in writeback, writeback=$WRITEBACK"
6019 set_nodes_failloc "$(osts_nodes)" 0
6022 if [[ $RC -ne 0 ]]; then
6023 error "Multiop fsync failed, rc=$RC"
6026 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6027 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6029 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6030 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6034 echo "Dirty pages flushed via fsync on EROFS"
6037 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
6041 remote_ost_nodsh && skip "remote OST with nodsh" && return
6045 #define OBD_FAIL_OST_BRW_PAUSE_BULK
6046 set_nodes_failloc "$(osts_nodes)" 0x214
6047 # multiop should block due to fsync until pages are written
6048 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
6052 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
6053 error "Multiop failed to block on fsync, pid=$MULTIPID"
6056 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6058 if [[ $WRITEBACK -eq 0 ]]; then
6059 error "No page in writeback, writeback=$WRITEBACK"
6062 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
6063 set_nodes_failloc "$(osts_nodes)" 0
6065 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6066 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6068 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6069 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6073 echo "Dirty pages gaurenteed flushed via fsync"
6076 run_test 118d "Fsync validation inject a delay of the bulk =========="
6081 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
6082 lctl set_param fail_loc=0x8000040a
6084 # Should simulate EINVAL error which is fatal
6085 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6087 if [[ $RC -eq 0 ]]; then
6088 error "Must return error due to dropped pages, rc=$RC"
6091 lctl set_param fail_loc=0x0
6093 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6094 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6095 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6097 if [[ $LOCKED -ne 0 ]]; then
6098 error "Locked pages remain in cache, locked=$LOCKED"
6101 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6102 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6106 echo "No pages locked after fsync"
6111 run_test 118f "Simulate unrecoverable OSC side error =========="
6116 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
6117 lctl set_param fail_loc=0x406
6119 # simulate local -ENOMEM
6120 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6123 lctl set_param fail_loc=0
6124 if [[ $RC -eq 0 ]]; then
6125 error "Must return error due to dropped pages, rc=$RC"
6128 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6129 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6130 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6132 if [[ $LOCKED -ne 0 ]]; then
6133 error "Locked pages remain in cache, locked=$LOCKED"
6136 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6137 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6141 echo "No pages locked after fsync"
6146 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
6149 remote_ost_nodsh && skip "remote OST with nodsh" && return
6153 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
6154 set_nodes_failloc "$(osts_nodes)" 0x20e
6155 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
6156 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6159 set_nodes_failloc "$(osts_nodes)" 0
6160 if [[ $RC -eq 0 ]]; then
6161 error "Must return error due to dropped pages, rc=$RC"
6164 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6165 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6166 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6168 if [[ $LOCKED -ne 0 ]]; then
6169 error "Locked pages remain in cache, locked=$LOCKED"
6172 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6173 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6177 echo "No pages locked after fsync"
6181 run_test 118h "Verify timeout in handling recoverables errors =========="
6184 remote_ost_nodsh && skip "remote OST with nodsh" && return
6188 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
6189 set_nodes_failloc "$(osts_nodes)" 0x20e
6191 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
6192 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
6195 set_nodes_failloc "$(osts_nodes)" 0
6199 if [[ $RC -ne 0 ]]; then
6200 error "got error, but should be not, rc=$RC"
6203 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6204 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6205 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
6206 if [[ $LOCKED -ne 0 ]]; then
6207 error "Locked pages remain in cache, locked=$LOCKED"
6210 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6211 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6215 echo "No pages locked after fsync"
6219 run_test 118i "Fix error before timeout in recoverable error =========="
6222 remote_ost_nodsh && skip "remote OST with nodsh" && return
6226 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
6227 set_nodes_failloc "$(osts_nodes)" 0x220
6229 # return -EIO from OST
6230 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6232 set_nodes_failloc "$(osts_nodes)" 0x0
6233 if [[ $RC -eq 0 ]]; then
6234 error "Must return error due to dropped pages, rc=$RC"
6237 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6238 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6239 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
6240 if [[ $LOCKED -ne 0 ]]; then
6241 error "Locked pages remain in cache, locked=$LOCKED"
6244 # in recoverable error on OST we want resend and stay until it finished
6245 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6246 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6250 echo "No pages locked after fsync"
6254 run_test 118j "Simulate unrecoverable OST side error =========="
6258 remote_ost_nodsh && skip "remote OSTs with nodsh" && return
6260 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
6261 set_nodes_failloc "$(osts_nodes)" 0x20e
6264 for ((i=0;i<10;i++)); do
6265 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
6266 error "dd to $DIR/$tdir/$tfile-$i failed" )&
6273 set_nodes_failloc "$(osts_nodes)" 0
6276 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
6282 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
6285 run_test 118l "fsync dir ========="
6287 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
6289 test_119a() # bug 11737
6291 BSIZE=$((512 * 1024))
6292 directio write $DIR/$tfile 0 1 $BSIZE
6293 # We ask to read two blocks, which is more than a file size.
6294 # directio will indicate an error when requested and actual
6295 # sizes aren't equeal (a normal situation in this case) and
6296 # print actual read amount.
6297 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
6298 if [ "$NOB" != "$BSIZE" ]; then
6299 error "read $NOB bytes instead of $BSIZE"
6303 run_test 119a "Short directIO read must return actual read amount"
6305 test_119b() # bug 11737
6307 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
6309 $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
6310 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
6312 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) || \
6313 error "direct read failed"
6316 run_test 119b "Sparse directIO read must return actual read amount"
6318 test_119c() # bug 13099
6321 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
6322 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
6325 run_test 119c "Testing for direct read hitting hole"
6327 test_119d() # bug 15950
6329 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
6330 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
6332 $SETSTRIPE $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
6333 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
6334 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
6335 lctl set_param fail_loc=0x40d
6336 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
6339 cat $DIR/$tfile > /dev/null &
6340 lctl set_param fail_loc=0
6343 log "the DIO writes have completed, now wait for the reads (should not block very long)"
6345 [ -n "`ps h -p $pid_reads -o comm`" ] && \
6346 error "the read rpcs have not completed in 2s"
6348 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
6350 run_test 119d "The DIO path should try to send a new rpc once one is completed"
6354 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6355 skip "no early lock cancel on server" && return 0
6356 lru_resize_disable mdc
6357 lru_resize_disable osc
6358 cancel_lru_locks mdc
6359 stat $DIR/$tdir > /dev/null
6360 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6361 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6363 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6364 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6365 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6366 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6367 lru_resize_enable mdc
6368 lru_resize_enable osc
6370 run_test 120a "Early Lock Cancel: mkdir test"
6374 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6375 skip "no early lock cancel on server" && return 0
6376 lru_resize_disable mdc
6377 lru_resize_disable osc
6378 cancel_lru_locks mdc
6379 stat $DIR/$tdir > /dev/null
6380 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6381 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6383 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6384 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6385 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6386 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6387 lru_resize_enable mdc
6388 lru_resize_enable osc
6390 run_test 120b "Early Lock Cancel: create test"
6394 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6395 skip "no early lock cancel on server" && return 0
6396 lru_resize_disable mdc
6397 lru_resize_disable osc
6398 mkdir -p $DIR/$tdir/d1 $DIR/$tdir/d2
6399 touch $DIR/$tdir/d1/f1
6400 cancel_lru_locks mdc
6401 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
6402 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6403 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6404 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
6405 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6406 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6407 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6408 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6409 lru_resize_enable mdc
6410 lru_resize_enable osc
6412 run_test 120c "Early Lock Cancel: link test"
6416 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6417 skip "no early lock cancel on server" && return 0
6418 lru_resize_disable mdc
6419 lru_resize_disable osc
6421 cancel_lru_locks mdc
6422 stat $DIR/$tdir > /dev/null
6423 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6424 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6425 chmod a+x $DIR/$tdir
6426 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6427 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6428 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6429 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6430 lru_resize_enable mdc
6431 lru_resize_enable osc
6433 run_test 120d "Early Lock Cancel: setattr test"
6437 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6438 skip "no early lock cancel on server" && return 0
6439 lru_resize_disable mdc
6440 lru_resize_disable osc
6441 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
6442 cancel_lru_locks mdc
6443 cancel_lru_locks osc
6444 dd if=$DIR/$tdir/f1 of=/dev/null
6445 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
6446 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6447 awk '/ldlm_cancel/ {print $2}'`
6448 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6449 awk '/ldlm_bl_callback/ {print $2}'`
6450 unlink $DIR/$tdir/f1
6451 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6452 awk '/ldlm_cancel/ {print $2}'`
6453 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6454 awk '/ldlm_bl_callback/ {print $2}'`
6455 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6456 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6457 lru_resize_enable mdc
6458 lru_resize_enable osc
6460 run_test 120e "Early Lock Cancel: unlink test"
6463 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6464 skip "no early lock cancel on server" && return 0
6466 lru_resize_disable mdc
6467 lru_resize_disable osc
6468 mkdir -p $DIR/$tdir/d1 $DIR/$tdir/d2
6469 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
6470 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
6471 cancel_lru_locks mdc
6472 cancel_lru_locks osc
6473 dd if=$DIR/$tdir/d1/f1 of=/dev/null
6474 dd if=$DIR/$tdir/d2/f2 of=/dev/null
6475 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
6476 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6477 awk '/ldlm_cancel/ {print $2}'`
6478 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6479 awk '/ldlm_bl_callback/ {print $2}'`
6480 mv $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
6481 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6482 awk '/ldlm_cancel/ {print $2}'`
6483 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6484 awk '/ldlm_bl_callback/ {print $2}'`
6485 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6486 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6487 lru_resize_enable mdc
6488 lru_resize_enable osc
6490 run_test 120f "Early Lock Cancel: rename test"
6493 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6494 skip "no early lock cancel on server" && return 0
6495 lru_resize_disable mdc
6496 lru_resize_disable osc
6498 echo create $count files
6500 cancel_lru_locks mdc
6501 cancel_lru_locks osc
6504 can0=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6505 awk '/ldlm_cancel/ {print $2}'`
6506 blk0=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6507 awk '/ldlm_bl_callback/ {print $2}'`
6508 createmany -o $DIR/$tdir/f $count
6510 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6511 awk '/ldlm_cancel/ {print $2}'`
6512 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6513 awk '/ldlm_bl_callback/ {print $2}'`
6515 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
6516 echo rm $count files
6519 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6520 awk '/ldlm_cancel/ {print $2}'`
6521 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6522 awk '/ldlm_bl_callback/ {print $2}'`
6524 echo total: $count removes in $((t2-t1))
6525 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
6527 # wait for commitment of removal
6528 lru_resize_enable mdc
6529 lru_resize_enable osc
6531 run_test 120g "Early Lock Cancel: performance test"
6533 test_121() { #bug #10589
6535 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
6536 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
6537 lctl set_param fail_loc=0x310
6538 cancel_lru_locks osc > /dev/null
6539 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
6540 lctl set_param fail_loc=0
6541 [ "$reads" -eq "$writes" ] || error "read" $reads "blocks, must be" $writes
6543 run_test 121 "read cancel race ========="
6545 test_123a() { # was test 123, statahead(bug 11401)
6547 if [ -z "$(grep "processor.*: 1" /proc/cpuinfo)" ]; then
6548 log "testing on UP system. Performance may be not as good as expected."
6554 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
6555 [ $NUMFREE -gt 100000 ] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
6557 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
6558 createmany -o $DIR/$tdir/$tfile $j $((i - j))
6560 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
6561 lctl set_param -n llite.*.statahead_max 0
6562 lctl get_param llite.*.statahead_max
6563 cancel_lru_locks mdc
6564 cancel_lru_locks osc
6566 time ls -l $DIR/$tdir | wc -l
6568 delta=$((etime - stime))
6569 log "ls $i files without statahead: $delta sec"
6570 lctl set_param llite.*.statahead_max=$max
6572 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
6573 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
6574 cancel_lru_locks mdc
6575 cancel_lru_locks osc
6577 time ls -l $DIR/$tdir | wc -l
6579 delta_sa=$((etime - stime))
6580 log "ls $i files with statahead: $delta_sa sec"
6581 lctl get_param -n llite.*.statahead_stats
6582 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
6584 [ $swrong -lt $ewrong ] && log "statahead was stopped, maybe too many locks held!"
6585 [ $delta -eq 0 -o $delta_sa -eq 0 ] && continue
6587 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
6588 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
6589 lctl set_param -n llite.*.statahead_max 0
6590 lctl get_param llite.*.statahead_max
6591 cancel_lru_locks mdc
6592 cancel_lru_locks osc
6594 time ls -l $DIR/$tdir | wc -l
6596 delta=$((etime - stime))
6597 log "ls $i files again without statahead: $delta sec"
6598 lctl set_param llite.*.statahead_max=$max
6599 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
6600 if [ $SLOWOK -eq 0 ]; then
6601 error "ls $i files is slower with statahead!"
6603 log "ls $i files is slower with statahead!"
6609 [ $delta -gt 20 ] && break
6610 [ $delta -gt 8 ] && MULT=$((50 / delta))
6611 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
6619 delta=$((etime - stime))
6620 log "rm -r $DIR/$tdir/: $delta seconds"
6622 lctl get_param -n llite.*.statahead_stats
6624 run_test 123a "verify statahead work"
6626 test_123b () { # statahead(bug 15027)
6628 createmany -o $DIR/$tdir/$tfile-%d 1000
6630 cancel_lru_locks mdc
6631 cancel_lru_locks osc
6633 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
6634 lctl set_param fail_loc=0x80000803
6635 ls -lR $DIR/$tdir > /dev/null
6637 lctl set_param fail_loc=0x0
6638 lctl get_param -n llite.*.statahead_stats
6643 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
6646 [ -z "`lctl get_param -n mdc.*.connect_flags | grep lru_resize`" ] && \
6647 skip "no lru resize on server" && return 0
6649 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
6651 log "create $NR files at $DIR/$tdir"
6652 createmany -o $DIR/$tdir/f $NR ||
6653 error "failed to create $NR files in $DIR/$tdir"
6655 cancel_lru_locks mdc
6656 ls -l $DIR/$tdir > /dev/null
6660 for VALUE in `lctl get_param ldlm.namespaces.*mdc-*.lru_size`; do
6661 local PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
6662 LRU_SIZE=$(lctl get_param -n $PARAM)
6663 if [ $LRU_SIZE -gt $(default_lru_size) ]; then
6664 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
6666 log "NS=$(basename $NSDIR)"
6671 if [ -z "$NSDIR" -o $LRU_SIZE -lt $(default_lru_size) ]; then
6672 skip "Not enough cached locks created!"
6679 # We know that lru resize allows one client to hold $LIMIT locks
6680 # for 10h. After that locks begin to be killed by client.
6682 local LIMIT=`lctl get_param -n $NSDIR.pool.limit`
6685 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
6686 # killing locks. Some time was spent for creating locks. This means
6687 # that up to the moment of sleep finish we must have killed some of
6688 # them (10-100 locks). This depends on how fast ther were created.
6689 # Many of them were touched in almost the same moment and thus will
6690 # be killed in groups.
6691 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
6693 # Use $LRU_SIZE_B here to take into account real number of locks
6694 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
6695 local LRU_SIZE_B=$LRU_SIZE
6697 local OLD_LVF=`lctl get_param -n $NSDIR.pool.lock_volume_factor`
6698 log "OLD_LVF=$OLD_LVF"
6699 lctl set_param -n $NSDIR.pool.lock_volume_factor $LVF
6701 # Let's make sure that we really have some margin. Client checks
6702 # cached locks every 10 sec.
6704 log "Sleep ${SLEEP} sec"
6706 while ((SEC<$SLEEP)); do
6710 LRU_SIZE=`lctl get_param -n $NSDIR/lru_size`
6714 lctl set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
6715 local LRU_SIZE_A=`lctl get_param -n $NSDIR.lru_size`
6717 [ $LRU_SIZE_B -gt $LRU_SIZE_A ] || {
6718 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
6719 unlinkmany $DIR/$tdir/f $NR
6723 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
6724 log "unlink $NR files at $DIR/$tdir"
6725 unlinkmany $DIR/$tdir/f $NR
6727 run_test 124a "lru resize ======================================="
6729 get_max_pool_limit()
6731 local limit=`lctl get_param -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit`
6734 if test $l -gt $max; then
6742 [ -z "`lctl get_param -n mdc.*.connect_flags | grep lru_resize`" ] && \
6743 skip "no lru resize on server" && return 0
6745 LIMIT=`get_max_pool_limit`
6747 NR=$(($(default_lru_size)*20))
6748 if [ $NR -gt $LIMIT ]; then
6749 log "Limit lock number by $LIMIT locks"
6752 lru_resize_disable mdc
6753 mkdir -p $DIR/$tdir/disable_lru_resize ||
6754 error "failed to create $DIR/$tdir/disable_lru_resize"
6756 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
6757 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
6758 cancel_lru_locks mdc
6761 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
6764 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
6767 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
6771 nolruresize_delta=$((etime-stime))
6772 log "ls -la time: $nolruresize_delta seconds"
6773 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
6774 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
6776 lru_resize_enable mdc
6777 mkdir -p $DIR/$tdir/enable_lru_resize ||
6778 error "failed to create $DIR/$tdir/enable_lru_resize"
6780 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
6781 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
6782 cancel_lru_locks mdc
6785 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
6788 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
6791 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
6795 lruresize_delta=$((etime-stime))
6796 log "ls -la time: $lruresize_delta seconds"
6797 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
6799 if [ $lruresize_delta -gt $nolruresize_delta ]; then
6800 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
6801 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
6802 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
6804 log "lru resize performs the same with no lru resize"
6806 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
6808 run_test 124b "lru resize (performance test) ======================="
6810 test_125() { # 13358
6811 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
6812 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
6813 mkdir -p $DIR/d125 || error "mkdir failed"
6814 $SETSTRIPE -S 65536 -c -1 $DIR/d125 || error "setstripe failed"
6815 setfacl -R -m u:bin:rwx $DIR/d125 || error "setfacl $DIR/d125 failed"
6816 ls -ld $DIR/d125 || error "cannot access $DIR/d125"
6818 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
6820 test_126() { # bug 12829/13455
6821 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
6822 [ "$UID" != 0 ] && skip_env "skipping $TESTNAME (must run as root)" && return
6823 $GSS && skip "must run as gss disabled" && return
6825 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
6826 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
6828 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
6830 run_test 126 "check that the fsgid provided by the client is taken into account"
6832 test_127a() { # bug 15521
6833 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
6834 $LCTL set_param osc.*.stats=0
6835 FSIZE=$((2048 * 1024))
6836 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
6837 cancel_lru_locks osc
6838 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
6840 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
6841 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
6842 echo "got $COUNT $NAME"
6843 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
6844 eval $NAME=$COUNT || error "Wrong proc format"
6847 read_bytes|write_bytes)
6848 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
6849 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
6850 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
6851 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
6852 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
6853 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
6854 error "sumsquare is too small: $SUMSQ"
6855 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
6856 error "sumsquare is too big: $SUMSQ"
6860 done < $DIR/${tfile}.tmp
6862 #check that we actually got some stats
6863 [ "$read_bytes" ] || error "Missing read_bytes stats"
6864 [ "$write_bytes" ] || error "Missing write_bytes stats"
6865 [ "$read_bytes" != 0 ] || error "no read done"
6866 [ "$write_bytes" != 0 ] || error "no write done"
6868 run_test 127a "verify the client stats are sane"
6870 test_127b() { # bug LU-333
6871 $LCTL set_param llite.*.stats=0
6872 FSIZE=65536 # sized fixed to match PAGE_SIZE for most clients
6873 # perform 2 reads and writes so MAX is different from SUM.
6874 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
6875 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
6876 cancel_lru_locks osc
6877 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
6878 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
6880 $LCTL get_param llite.*.stats | grep samples > $TMP/${tfile}.tmp
6881 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
6882 echo "got $COUNT $NAME"
6883 eval $NAME=$COUNT || error "Wrong proc format"
6887 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
6888 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
6889 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
6890 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
6893 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
6894 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
6895 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
6896 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
6900 done < $TMP/${tfile}.tmp
6902 #check that we actually got some stats
6903 [ "$read_bytes" ] || error "Missing read_bytes stats"
6904 [ "$write_bytes" ] || error "Missing write_bytes stats"
6905 [ "$read_bytes" != 0 ] || error "no read done"
6906 [ "$write_bytes" != 0 ] || error "no write done"
6908 run_test 127b "verify the llite client stats are sane"
6910 test_128() { # bug 15212
6912 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
6917 result=$(grep error $TMP/$tfile.log)
6919 [ -z "$result" ] || error "consecutive find's under interactive lfs failed"
6921 run_test 128 "interactive lfs for 2 consecutive find's"
6928 local LDPROC=/proc/fs/ldiskfs
6930 for facet in $(get_facets MDS); do
6931 canondev=$(ldiskfs_canon *.$(convert_facet2label $facet).mntdev $facet)
6932 do_facet $facet "test -e $LDPROC/$canondev/max_dir_size" || LDPROC=/sys/fs/ldiskfs
6933 do_facet $facet "echo $1 >$LDPROC/$canondev/max_dir_size"
6937 if [ "$(facet_type_fstype MDS)" != ldiskfs ]; then
6938 skip "Only applicable to ldiskfs-based MDTs"
6941 remote_mds_nodsh && skip "remote MDS with nodsh" && return
6952 while [ ! $I -gt $((MAX * MDSCOUNT)) ]; do
6953 $MULTIOP $DIR/$tdir/$J Oc
6955 if [ $rc -eq $EFBIG ]; then
6957 echo "return code $rc received as expected"
6959 elif [ $rc -ne 0 ]; then
6961 error_exit "return code $rc received instead of expected $EFBIG"
6964 I=$(stat -c%s "$DIR/$tdir")
6968 error "exceeded dir size limit $MAX x $MDSCOUNT $((MAX * MDSCOUNT)) : $I bytes"
6970 run_test 129 "test directory size limit ========================"
6979 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
6980 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
6982 trap cleanup_130 EXIT RETURN
6984 local fm_file=$DIR/$tfile
6985 $SETSTRIPE -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
6986 dd if=/dev/zero of=$fm_file bs=65536 count=1 || error "dd failed for $fm_file"
6988 filefrag -ves $fm_file || error "filefrag $fm_file failed"
6989 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
6991 lun=$($GETSTRIPE -i $fm_file)
6993 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
6996 for line in $filefrag_op
6998 frag_lun=`echo $line | cut -d: -f5`
6999 ext_len=`echo $line | cut -d: -f4`
7000 if (( $frag_lun != $lun )); then
7002 error "FIEMAP on 1-stripe file($fm_file) failed"
7005 (( tot_len += ext_len ))
7008 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
7010 error "FIEMAP on 1-stripe file($fm_file) failed;"
7016 echo "FIEMAP on single striped file succeeded"
7018 run_test 130a "FIEMAP (1-stripe file)"
7021 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping FIEMAP on 2-stripe file test" && return
7023 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7024 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
7026 trap cleanup_130 EXIT RETURN
7028 local fm_file=$DIR/$tfile
7029 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
7030 dd if=/dev/zero of=$fm_file bs=1M count=2 || error "dd failed on $fm_file"
7032 filefrag -ves $fm_file || error "filefrag $fm_file failed"
7033 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
7035 last_lun=`echo $filefrag_op | cut -d: -f5`
7040 for line in $filefrag_op
7042 frag_lun=`echo $line | cut -d: -f5`
7043 ext_len=`echo $line | cut -d: -f4`
7044 if (( $frag_lun != $last_lun )); then
7045 if (( tot_len != 1024 )); then
7047 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 256"
7054 (( tot_len += ext_len ))
7057 if (( num_luns != 2 || tot_len != 1024 )); then
7059 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
7065 echo "FIEMAP on 2-stripe file succeeded"
7067 run_test 130b "FIEMAP (2-stripe file)"
7070 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping FIEMAP on 2-stripe file with hole test" && return
7072 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7073 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
7075 trap cleanup_130 EXIT RETURN
7077 local fm_file=$DIR/$tfile
7078 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
7079 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 || error "dd failed on $fm_file"
7081 filefrag -ves $fm_file || error "filefrag $fm_file failed"
7082 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
7084 last_lun=`echo $filefrag_op | cut -d: -f5`
7089 for line in $filefrag_op
7091 frag_lun=`echo $line | cut -d: -f5`
7092 ext_len=`echo $line | cut -d: -f4`
7093 if (( $frag_lun != $last_lun )); then
7094 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
7095 if (( logical != 512 )); then
7097 error "FIEMAP on $fm_file failed; returned logical start for lun $logical instead of 512"
7100 if (( tot_len != 512 )); then
7102 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
7109 (( tot_len += ext_len ))
7112 if (( num_luns != 2 || tot_len != 512 )); then
7114 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
7120 echo "FIEMAP on 2-stripe file with hole succeeded"
7122 run_test 130c "FIEMAP (2-stripe file with hole)"
7125 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping FIEMAP on N-stripe file test" && return
7127 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7128 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
7130 trap cleanup_130 EXIT RETURN
7132 local fm_file=$DIR/$tfile
7133 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file||error "setstripe on $fm_file"
7134 dd if=/dev/zero of=$fm_file bs=1M count=$OSTCOUNT || error "dd failed on $fm_file"
7136 filefrag -ves $fm_file || error "filefrag $fm_file failed"
7137 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
7139 last_lun=`echo $filefrag_op | cut -d: -f5`
7144 for line in $filefrag_op
7146 frag_lun=`echo $line | cut -d: -f5`
7147 ext_len=`echo $line | cut -d: -f4`
7148 if (( $frag_lun != $last_lun )); then
7149 if (( tot_len != 1024 )); then
7151 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
7158 (( tot_len += ext_len ))
7161 if (( num_luns != OSTCOUNT || tot_len != 1024 )); then
7163 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
7169 echo "FIEMAP on N-stripe file succeeded"
7171 run_test 130d "FIEMAP (N-stripe file)"
7174 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping continuation FIEMAP test" && return
7176 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7177 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
7179 trap cleanup_130 EXIT RETURN
7181 local fm_file=$DIR/$tfile
7182 $SETSTRIPE -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
7184 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
7185 for ((i = 0; i < $NUM_BLKS; i++))
7187 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
7190 filefrag -ves $fm_file || error "filefrag $fm_file failed"
7191 filefrag_op=`filefrag -ve $fm_file | grep -A 12000 "ext:" | grep -v "ext:" | grep -v "found"`
7193 last_lun=`echo $filefrag_op | cut -d: -f5`
7198 for line in $filefrag_op
7200 frag_lun=`echo $line | cut -d: -f5`
7201 ext_len=`echo $line | cut -d: -f4`
7202 if (( $frag_lun != $last_lun )); then
7203 if (( tot_len != $EXPECTED_LEN )); then
7205 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of $EXPECTED_LEN"
7212 (( tot_len += ext_len ))
7215 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
7217 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
7223 echo "FIEMAP with continuation calls succeeded"
7225 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
7227 # Test for writev/readv
7229 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 || \
7230 error "writev test failed"
7231 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 || \
7232 error "readv failed"
7235 run_test 131a "test iov's crossing stripe boundary for writev/readv"
7238 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 || \
7239 error "append writev test failed"
7240 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 || \
7241 error "append writev test failed"
7244 run_test 131b "test append writev"
7247 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
7250 run_test 131c "test read/write on file w/o objects"
7253 rwv -f $DIR/$tfile -w -n 1 1572864
7254 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
7255 if [ "$NOB" != 1572864 ]; then
7256 error "Short read filed: read $NOB bytes instead of 1572864"
7260 run_test 131d "test short read"
7263 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
7264 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
7265 error "read hitting hole failed"
7268 run_test 131e "test read hitting hole"
7273 for node in $(osts_nodes); do
7274 gl=$(do_node $node "$LCTL get_param -n ost.OSS.ost.stats" | awk '/'$token'/ {print $2}' | head -n 1)
7275 [ x$gl = x"" ] && gl=0
7276 gl_sum=$((gl_sum + gl))
7286 if [ x$som = x"enabled" ]; then
7287 [ $((gl2 - gl1)) -gt 0 ] && error "no glimpse RPC is expected"
7288 MOUNTOPT=`echo $MOUNTOPT | sed 's/som_preview//g'`
7289 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=disabled"
7291 [ $((gl2 - gl1)) -gt 0 ] || error "some glimpse RPC is expected"
7292 MOUNTOPT="$MOUNTOPT,som_preview"
7293 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=enabled"
7296 # do remount to make new mount-conf parameters actual
7303 test_132() { #1028, SOM
7304 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7305 local num=$(get_mds_dir $DIR)
7306 local mymds=mds${num}
7307 local MOUNTOPT_SAVE=$MOUNTOPT
7309 dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
7310 cancel_lru_locks osc
7312 som1=$(do_facet $mymds "$LCTL get_param mdt.*.som" | awk -F= ' {print $2}' | head -n 1)
7314 gl1=$(get_ost_param "ldlm_glimpse_enqueue")
7315 stat $DIR/$tfile >/dev/null
7316 gl2=$(get_ost_param "ldlm_glimpse_enqueue")
7317 echo "====> SOM is "$som1", "$((gl2 - gl1))" glimpse RPC occured"
7319 som_mode_switch $som1 $gl1 $gl2
7321 dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
7322 cancel_lru_locks osc
7324 som2=$(do_facet $mymds "$LCTL get_param mdt.*.som" | awk -F= ' {print $2}' | head -n 1)
7325 if [ $som1 == $som2 ]; then
7326 error "som is still "$som2
7327 if [ x$som2 = x"enabled" ]; then
7334 gl1=$(get_ost_param "ldlm_glimpse_enqueue")
7335 stat $DIR/$tfile >/dev/null
7336 gl2=$(get_ost_param "ldlm_glimpse_enqueue")
7337 echo "====> SOM is "$som2", "$((gl2 - gl1))" glimpse RPC occured"
7338 som_mode_switch $som2 $gl1 $gl2
7339 MOUNTOPT=$MOUNTOPT_SAVE
7341 run_test 132 "som avoids glimpse rpc"
7347 $SINGLEMDS) res=`do_facet $SINGLEMDS $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$2"`
7349 ost) res=`do_facet ost1 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$2"`
7351 *) error "Wrong argument $1" ;;
7354 count=`echo $res | awk '{print $2}'`
7355 [ -z "$res" ] && error "The counter for $2 on $1 was not incremented"
7356 # if the argument $3 is zero, it means any stat increment is ok.
7357 if [ $3 -gt 0 ] ; then
7358 [ $count -ne $3 ] && error "The $2 counter on $1 is wrong - expected $3"
7363 remote_ost_nodsh && skip "remote OST with nodsh" && return
7364 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7366 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
7367 { skip "MDS doesn't support rename stats"; return; }
7368 local testdir=$DIR/${tdir}/stats_testdir
7369 mkdir -p $DIR/${tdir}
7372 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
7373 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
7375 # verify mdt stats first.
7376 mkdir ${testdir} || error "mkdir failed"
7377 check_stats $SINGLEMDS "mkdir" 1
7378 touch ${testdir}/${tfile} || "touch failed"
7379 check_stats $SINGLEMDS "open" 1
7380 check_stats $SINGLEMDS "close" 1
7381 mknod ${testdir}/${tfile}-pipe p || "mknod failed"
7382 check_stats $SINGLEMDS "mknod" 1
7383 rm -f ${testdir}/${tfile}-pipe || "pipe remove failed"
7384 check_stats $SINGLEMDS "unlink" 1
7385 rm -f ${testdir}/${tfile} || error "file remove failed"
7386 check_stats $SINGLEMDS "unlink" 2
7388 # remove working dir and check mdt stats again.
7389 rmdir ${testdir} || error "rmdir failed"
7390 check_stats $SINGLEMDS "rmdir" 1
7392 local testdir1=$DIR/${tdir}/stats_testdir1
7394 mkdir -p ${testdir1}
7395 touch ${testdir1}/test1
7396 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
7397 check_stats $SINGLEMDS "crossdir_rename" 1
7399 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
7400 check_stats $SINGLEMDS "samedir_rename" 1
7404 run_test 133a "Verifying MDT stats ========================================"
7407 remote_ost_nodsh && skip "remote OST with nodsh" && return
7408 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7409 local testdir=$DIR/${tdir}/stats_testdir
7410 mkdir -p ${testdir} || error "mkdir failed"
7411 touch ${testdir}/${tfile} || "touch failed"
7412 cancel_lru_locks mdc
7415 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
7416 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
7418 # extra mdt stats verification.
7419 chmod 444 ${testdir}/${tfile} || error "chmod failed"
7420 check_stats $SINGLEMDS "setattr" 1
7421 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
7422 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
7423 check_stats $SINGLEMDS "getattr" 1
7424 $LFS df || error "lfs failed"
7425 check_stats $SINGLEMDS "statfs" 1
7429 run_test 133b "Verifying extra MDT stats =================================="
7432 remote_ost_nodsh && skip "remote OST with nodsh" && return
7433 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7434 local testdir=$DIR/${tdir}/stats_testdir
7435 mkdir -p ${testdir} || error "mkdir failed"
7437 # verify obdfilter stats.
7438 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
7440 cancel_lru_locks osc
7443 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
7444 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
7446 dd if=/dev/zero of=${testdir}/${tfile} conv=notrunc bs=512k count=1 || error "dd failed"
7448 cancel_lru_locks osc
7449 check_stats ost "write" 1
7451 dd if=${testdir}/${tfile} of=/dev/null bs=1k count=1 || error "dd failed"
7452 check_stats ost "read" 1
7454 > ${testdir}/${tfile} || error "truncate failed"
7455 check_stats ost "punch" 1
7457 rm -f ${testdir}/${tfile} || error "file remove failed"
7458 check_stats ost "destroy" 1
7462 run_test 133c "Verifying OST stats ========================================"
7469 while [ $value -ge 2 ]; do
7474 if [ $orig -gt $order ]; then
7482 local size=('K' 'M' 'G' 'T');
7484 local size_string=$value
7486 while [ $value -ge 1024 ]; do
7487 if [ $i -gt 3 ]; then
7488 #T is the biggest unit we get here, if that is bigger,
7490 size_string=${value}T
7493 value=$((value >> 10))
7494 if [ $value -lt 1024 ]; then
7495 size_string=${value}${size[$i]}
7506 local sample=$(do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats |
7507 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
7512 remote_ost_nodsh && skip "remote OST with nodsh" && return
7513 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7514 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
7515 { skip "MDS doesn't support rename stats"; return; }
7517 local testdir1=$DIR/${tdir}/stats_testdir1
7518 local testdir2=$DIR/${tdir}/stats_testdir2
7520 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
7522 mkdir -p ${testdir1} || error "mkdir failed"
7523 mkdir -p ${testdir2} || error "mkdir failed"
7525 createmany -o $testdir1/test 512 || error "createmany failed"
7526 local testdir1_size=$(ls -l $DIR/${tdir} |
7527 awk '/stats_testdir1/ {print $5}')
7528 local testdir2_size=$(ls -l $DIR/${tdir} |
7529 awk '/stats_testdir2/ {print $5}')
7531 testdir1_size=$(order_2 $testdir1_size)
7532 testdir2_size=$(order_2 $testdir2_size)
7534 testdir1_size=$(size_in_KMGT $testdir1_size)
7535 testdir2_size=$(size_in_KMGT $testdir2_size)
7537 echo "source rename dir size: ${testdir1_size}"
7538 echo "target rename dir size: ${testdir2_size}"
7540 # check samedir rename size
7541 mv ${testdir1}/test0 ${testdir1}/test_0
7542 local cmd="do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats"
7543 eval $cmd || error "$cmd failed"
7544 local samedir=$($cmd | grep 'same_dir')
7545 local same_sample=$(get_rename_size $testdir1_size)
7546 [ -z "$samedir" ] && error "samedir_rename_size count error"
7547 [ "$same_sample" -eq 1 ] || error "samedir_rename_size error $same_sample"
7548 echo "Check same dir rename stats success"
7550 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
7552 # check crossdir rename size
7553 mv ${testdir1}/test_0 ${testdir2}/test_0
7554 eval $cmd || error "$cmd failed"
7555 local crossdir=$($cmd | grep 'crossdir')
7556 local src_sample=$(get_rename_size $testdir1_size)
7557 local tgt_sample=$(get_rename_size $testdir2_size)
7558 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
7559 [ "$src_sample" -eq 1 ] || error "crossdir_rename_size error $src_sample"
7560 [ "$tgt_sample" -eq 1 ] || error "crossdir_rename_size error $tgt_sample"
7561 echo "Check cross dir rename stats success"
7564 run_test 133d "Verifying rename_stats ========================================"
7566 test_140() { #bug-17379
7567 mkdir -p $DIR/$tdir || error "Creating dir $DIR/$tdir"
7568 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
7569 cp /usr/bin/stat . || error "Copying stat to $DIR/$tdir"
7571 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
7573 while i=`expr $i + 1`; do
7574 mkdir -p $i || error "Creating dir $i"
7575 cd $i || error "Changing to $i"
7576 ln -s ../stat stat || error "Creating stat symlink"
7577 # Read the symlink until ELOOP present,
7578 # not LBUGing the system is considered success,
7579 # we didn't overrun the stack.
7580 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
7582 if [ $ret -eq 40 ]; then
7585 error "Open stat symlink"
7591 echo "The symlink depth = $i"
7592 [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 ] || error "Invalid symlink depth"
7594 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
7597 local TF="$TMP/$tfile"
7599 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
7601 cancel_lru_locks osc
7602 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
7603 remount_client $MOUNT
7605 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
7608 $TRUNCATE $DIR/$tfile 6000
7609 cancel_lru_locks osc
7610 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
7613 echo "12345" >>$DIR/$tfile
7614 cancel_lru_locks osc
7615 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
7618 echo "12345" >>$DIR/$tfile
7619 cancel_lru_locks osc
7620 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
7625 run_test 150 "truncate/append tests"
7627 function roc_hit() {
7628 local list=$(comma_list $(osts_nodes))
7630 ACCNUM=$(do_nodes $list $LCTL get_param -n obdfilter.*.stats | \
7631 awk '/'cache_hit'/ {sum+=$2} END {print sum}')
7635 function set_cache() {
7638 if [ "$2" == "off" ]; then
7641 local list=$(comma_list $(osts_nodes))
7642 do_nodes $list lctl set_param obdfilter.*.${1}_cache_enable $on
7644 cancel_lru_locks osc
7648 remote_ost_nodsh && skip "remote OST with nodsh" && return
7651 local list=$(comma_list $(osts_nodes))
7653 # check whether obdfilter is cache capable at all
7654 if ! do_nodes $list $LCTL get_param -n obdfilter.*.read_cache_enable > /dev/null; then
7655 echo "not cache-capable obdfilter"
7659 # check cache is enabled on all obdfilters
7660 if do_nodes $list $LCTL get_param -n obdfilter.*.read_cache_enable | grep 0 >&/dev/null; then
7661 echo "oss cache is disabled"
7665 do_nodes $list $LCTL set_param -n obdfilter.*.writethrough_cache_enable 1
7667 # pages should be in the case right after write
7668 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES || error "dd failed"
7669 local BEFORE=`roc_hit`
7670 cancel_lru_locks osc
7671 cat $DIR/$tfile >/dev/null
7672 local AFTER=`roc_hit`
7673 if ! let "AFTER - BEFORE == CPAGES"; then
7674 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
7677 # the following read invalidates the cache
7678 cancel_lru_locks osc
7679 do_nodes $list $LCTL set_param -n obdfilter.*.read_cache_enable 0
7680 cat $DIR/$tfile >/dev/null
7682 # now data shouldn't be found in the cache
7684 cancel_lru_locks osc
7685 cat $DIR/$tfile >/dev/null
7687 if let "AFTER - BEFORE != 0"; then
7688 error "IN CACHE: before: $BEFORE, after: $AFTER"
7691 do_nodes $list $LCTL set_param -n obdfilter.*.read_cache_enable 1
7694 run_test 151 "test cache on oss and controls ==============================="
7697 local TF="$TMP/$tfile"
7699 # simulate ENOMEM during write
7700 #define OBD_FAIL_OST_NOMEM 0x226
7701 lctl set_param fail_loc=0x80000226
7702 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
7704 sync || error "sync failed"
7705 lctl set_param fail_loc=0
7707 # discard client's cache
7708 cancel_lru_locks osc
7710 # simulate ENOMEM during read
7711 lctl set_param fail_loc=0x80000226
7712 cmp $TF $DIR/$tfile || error "cmp failed"
7713 lctl set_param fail_loc=0
7717 run_test 152 "test read/write with enomem ============================"
7720 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
7722 run_test 153 "test if fdatasync does not crash ======================="
7725 cp /etc/hosts $DIR/$tfile
7727 fid=$($LFS path2fid $DIR/$tfile)
7729 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
7731 ffid=$DIR/.lustre/fid/$fid
7733 echo "stat fid $fid"
7734 stat $ffid > /dev/null || error "stat $ffid failed."
7735 echo "touch fid $fid"
7736 touch $ffid || error "touch $ffid failed."
7737 echo "write to fid $fid"
7738 cat /etc/hosts > $ffid || error "write $ffid failed."
7739 echo "read fid $fid"
7740 diff /etc/hosts $ffid || error "read $ffid failed."
7741 echo "append write to fid $fid"
7742 cat /etc/hosts >> $ffid || error "append write $ffid failed."
7743 echo "rename fid $fid"
7744 mv $ffid $DIR/$tfile.1 && error "rename $ffid to $tfile.1 should fail."
7746 mv $DIR/$tfile.1 $ffid && error "rename $tfile.1 to $ffid should fail."
7748 echo "truncate fid $fid"
7749 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
7750 echo "link fid $fid"
7751 ln -f $ffid $DIR/tfile.lnk || error "link $ffid failed."
7752 if [ -n $(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl) ]; then
7753 echo "setfacl fid $fid"
7754 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
7755 echo "getfacl fid $fid"
7756 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
7758 echo "unlink fid $fid"
7759 unlink $DIR/.lustre/fid/$fid && error "unlink $ffid should fail."
7760 echo "mknod fid $fid"
7761 mknod $ffid c 1 3 && error "mknod $ffid should fail."
7763 fid=[0xf00000400:0x1:0x0]
7764 ffid=$DIR/.lustre/fid/$fid
7766 echo "stat non-exist fid $fid"
7767 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
7768 echo "write to non-exist fid $fid"
7769 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
7770 echo "link new fid $fid"
7771 ln $DIR/$tfile $ffid && error "link $ffid should fail."
7774 touch $DIR/$tdir/$tfile
7775 fid=$($LFS path2fid $DIR/$tdir)
7777 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
7779 ffid=$DIR/.lustre/fid/$fid
7782 ls $ffid > /dev/null || error "ls $ffid failed."
7783 echo "touch $fid/$tfile.1"
7784 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
7786 echo "touch $DIR/.lustre/fid/$tfile"
7787 touch $DIR/.lustre/fid/$tfile && \
7788 error "touch $DIR/.lustre/fid/$tfile should fail."
7790 echo "Open-by-FID succeeded"
7792 run_test 154 "Open-by-FID"
7794 test_155_small_load() {
7795 local temp=$TMP/$tfile
7796 local file=$DIR/$tfile
7798 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
7799 error "dd of=$temp bs=6096 count=1 failed"
7801 cancel_lru_locks osc
7802 cmp $temp $file || error "$temp $file differ"
7804 $TRUNCATE $temp 6000
7805 $TRUNCATE $file 6000
7806 cmp $temp $file || error "$temp $file differ (truncate1)"
7808 echo "12345" >>$temp
7809 echo "12345" >>$file
7810 cmp $temp $file || error "$temp $file differ (append1)"
7812 echo "12345" >>$temp
7813 echo "12345" >>$file
7814 cmp $temp $file || error "$temp $file differ (append2)"
7820 test_155_big_load() {
7821 remote_ost_nodsh && skip "remote OST with nodsh" && return
7822 local temp=$TMP/$tfile
7823 local file=$DIR/$tfile
7826 local cache_size=$(do_facet ost$((MAXI+1)) \
7827 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
7828 local large_file_size=$((cache_size * 2))
7830 echo "OSS cache size: $cache_size KB"
7831 echo "Large file size: $large_file_size KB"
7833 [ $MAXV -le $large_file_size ] && \
7834 skip_env "max available OST size needs > $large_file_size KB" && \
7837 $SETSTRIPE $file -c 1 -i $MAXI || error "$SETSTRIPE $file failed"
7839 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k || \
7840 error "dd of=$temp bs=$large_file_size count=1k failed"
7843 cancel_lru_locks osc
7844 cmp $temp $file || error "$temp $file differ"
7852 set_cache writethrough on
7855 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
7859 set_cache writethrough off
7862 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
7866 set_cache writethrough on
7869 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
7873 set_cache writethrough off
7876 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
7880 set_cache writethrough on
7883 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
7887 set_cache writethrough off
7890 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
7894 set_cache writethrough on
7897 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
7901 set_cache writethrough off
7904 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
7910 local file="$DIR/$tfile"
7912 log "Turn on read and write cache"
7914 set_cache writethrough on
7916 log "Write data and read it back."
7917 log "Read should be satisfied from the cache."
7918 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
7920 cancel_lru_locks osc
7921 cat $file >/dev/null
7923 if ! let "AFTER - BEFORE == CPAGES"; then
7924 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
7926 log "cache hits:: before: $BEFORE, after: $AFTER"
7929 log "Read again; it should be satisfied from the cache."
7931 cancel_lru_locks osc
7932 cat $file >/dev/null
7934 if ! let "AFTER - BEFORE == CPAGES"; then
7935 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
7937 log "cache hits:: before: $BEFORE, after: $AFTER"
7941 log "Turn off the read cache and turn on the write cache"
7943 set_cache writethrough on
7945 log "Read again; it should be satisfied from the cache."
7947 cancel_lru_locks osc
7948 cat $file >/dev/null
7950 if ! let "AFTER - BEFORE == CPAGES"; then
7951 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
7953 log "cache hits:: before: $BEFORE, after: $AFTER"
7956 log "Read again; it should not be satisfied from the cache."
7958 cancel_lru_locks osc
7959 cat $file >/dev/null
7961 if ! let "AFTER - BEFORE == 0"; then
7962 error "IN CACHE: before: $BEFORE, after: $AFTER"
7964 log "cache hits:: before: $BEFORE, after: $AFTER"
7967 log "Write data and read it back."
7968 log "Read should be satisfied from the cache."
7969 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
7971 cancel_lru_locks osc
7972 cat $file >/dev/null
7974 if ! let "AFTER - BEFORE == CPAGES"; then
7975 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
7977 log "cache hits:: before: $BEFORE, after: $AFTER"
7980 log "Read again; it should not be satisfied from the cache."
7982 cancel_lru_locks osc
7983 cat $file >/dev/null
7985 if ! let "AFTER - BEFORE == 0"; then
7986 error "IN CACHE: before: $BEFORE, after: $AFTER"
7988 log "cache hits:: before: $BEFORE, after: $AFTER"
7992 log "Turn off read and write cache"
7994 set_cache writethrough off
7996 log "Write data and read it back"
7997 log "It should not be satisfied from the cache."
7999 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
8000 cancel_lru_locks osc
8002 cat $file >/dev/null
8004 if ! let "AFTER - BEFORE == 0"; then
8005 error_ignore 20762 "IN CACHE: before: $BEFORE, after: $AFTER"
8007 log "cache hits:: before: $BEFORE, after: $AFTER"
8011 log "Turn on the read cache and turn off the write cache"
8013 set_cache writethrough off
8015 log "Write data and read it back"
8016 log "It should not be satisfied from the cache."
8018 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
8020 cancel_lru_locks osc
8021 cat $file >/dev/null
8023 if ! let "AFTER - BEFORE == 0"; then
8024 error_ignore 20762 "IN CACHE: before: $BEFORE, after: $AFTER"
8026 log "cache hits:: before: $BEFORE, after: $AFTER"
8029 log "Read again; it should be satisfied from the cache."
8031 cancel_lru_locks osc
8032 cat $file >/dev/null
8034 if ! let "AFTER - BEFORE == CPAGES"; then
8035 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
8037 log "cache hits:: before: $BEFORE, after: $AFTER"
8042 run_test 156 "Verification of tunables ============================"
8046 if [ $MDSCOUNT -gt 1 ]; then
8047 error_ignore 17935 $*
8055 MASK=$(do_facet $SINGLEMDS $LCTL get_param mdd.$MDT0.changelog_mask |\
8058 if [ $MASK -eq 1 ]; then
8059 do_facet $SINGLEMDS $LCTL set_param mdd.$MDT0.changelog_mask="-$1"
8061 do_facet $SINGLEMDS $LCTL set_param mdd.$MDT0.changelog_mask="+$1"
8066 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8067 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
8068 { skip "Need MDS version at least 2.2.0"; return; }
8069 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
8070 echo "Registered as changelog user $USER"
8071 do_facet $SINGLEMDS $LCTL get_param -n mdd.$MDT0.changelog_users | \
8072 grep -q $USER || error "User $USER not found in changelog_users"
8075 mkdir -p $DIR/$tdir/pics/2008/zachy
8076 touch $DIR/$tdir/pics/2008/zachy/timestamp
8077 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
8078 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
8079 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
8080 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
8081 rm $DIR/$tdir/pics/desktop.jpg
8083 $LFS changelog $MDT0 | tail -5
8085 echo "verifying changelog mask"
8086 changelog_chmask "MKDIR"
8087 changelog_chmask "CLOSE"
8089 mkdir -p $DIR/$tdir/pics/zach/sofia
8090 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
8092 changelog_chmask "MKDIR"
8093 changelog_chmask "CLOSE"
8095 mkdir -p $DIR/$tdir/pics/2008/sofia
8096 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
8098 $LFS changelog $MDT0
8099 MKDIRS=$($LFS changelog $MDT0 | tail -5 | grep -c "MKDIR")
8100 CLOSES=$($LFS changelog $MDT0 | tail -5 | grep -c "CLOSE")
8101 [ $MKDIRS -eq 1 ] || err17935 "MKDIR changelog mask count $DIRS != 1"
8102 [ $CLOSES -eq 1 ] || err17935 "CLOSE changelog mask count $DIRS != 1"
8105 echo "verifying target fid"
8106 fidc=$($LFS changelog $MDT0 | grep timestamp | grep "CREAT" | \
8107 tail -1 | awk '{print $6}')
8108 fidf=$($LFS path2fid $DIR/$tdir/pics/zach/timestamp)
8109 [ "$fidc" == "t=$fidf" ] || \
8110 err17935 "fid in changelog $fidc != file fid $fidf"
8111 echo "verifying parent fid"
8112 fidc=$($LFS changelog $MDT0 | grep timestamp | grep "CREAT" | \
8113 tail -1 | awk '{print $7}')
8114 fidf=$($LFS path2fid $DIR/$tdir/pics/zach)
8115 [ "$fidc" == "p=$fidf" ] || \
8116 err17935 "pfid in changelog $fidc != dir fid $fidf"
8118 USER_REC1=$(do_facet $SINGLEMDS $LCTL get_param -n \
8119 mdd.$MDT0.changelog_users | grep $USER | awk '{print $2}')
8120 $LFS changelog_clear $MDT0 $USER $(($USER_REC1 + 5))
8121 USER_REC2=$(do_facet $SINGLEMDS $LCTL get_param -n \
8122 mdd.$MDT0.changelog_users | grep $USER | awk '{print $2}')
8123 echo "verifying user clear: $(( $USER_REC1 + 5 )) == $USER_REC2"
8124 [ $USER_REC2 == $(($USER_REC1 + 5)) ] || \
8125 err17935 "user index should be $(($USER_REC1 + 5)); is $USER_REC2"
8127 MIN_REC=$(do_facet $SINGLEMDS $LCTL get_param mdd.$MDT0.changelog_users | \
8128 awk 'min == "" || $2 < min {min = $2}; END {print min}')
8129 FIRST_REC=$($LFS changelog $MDT0 | head -1 | awk '{print $1}')
8130 echo "verifying min purge: $(( $MIN_REC + 1 )) == $FIRST_REC"
8131 [ $FIRST_REC == $(($MIN_REC + 1)) ] || \
8132 err17935 "first index should be $(($MIN_REC + 1)); is $FIRST_REC"
8134 echo "verifying user deregister"
8135 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
8136 do_facet $SINGLEMDS $LCTL get_param -n mdd.$MDT0.changelog_users | \
8137 grep -q $USER && error "User $USER still found in changelog_users"
8139 USERS=$(( $(do_facet $SINGLEMDS $LCTL get_param -n \
8140 mdd.$MDT0.changelog_users | wc -l) - 2 ))
8141 if [ $USERS -eq 0 ]; then
8142 LAST_REC1=$(do_facet $SINGLEMDS $LCTL get_param -n \
8143 mdd.$MDT0.changelog_users | head -1 | awk '{print $3}')
8144 touch $DIR/$tdir/chloe
8145 LAST_REC2=$(do_facet $SINGLEMDS $LCTL get_param -n \
8146 mdd.$MDT0.changelog_users | head -1 | awk '{print $3}')
8147 echo "verify changelogs are off if we were the only user: $LAST_REC1 == $LAST_REC2"
8148 [ $LAST_REC1 == $LAST_REC2 ] || error "changelogs not off"
8150 echo "$USERS other changelog users; can't verify off"
8153 run_test 160 "changelog sanity"
8157 cp /etc/hosts $DIR/$tdir/$tfile
8158 mkdir $DIR/$tdir/foo1
8159 mkdir $DIR/$tdir/foo2
8160 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
8161 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
8162 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
8163 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
8164 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[')
8165 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
8166 $LFS fid2path $DIR $FID
8167 err17935 "bad link ea"
8170 rm $DIR/$tdir/foo2/zachary
8172 rm $DIR/$tdir/foo2/thor
8174 rm $DIR/$tdir/$tfile
8176 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
8177 if [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ]
8179 $LFS fid2path $DIR $FID
8180 err17935 "bad link rename"
8182 rm $DIR/$tdir/foo2/maggie
8185 local longname=filename_avg_len_is_thirty_two_
8186 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 || \
8187 error "failed to hardlink many files"
8188 links=$($LFS fid2path $DIR $FID | wc -l)
8189 echo -n "${links}/1000 links in link EA"
8190 [ ${links} -gt 60 ] || err17935 "expected at least 60 links in link EA"
8191 unlinkmany $DIR/$tdir/foo2/$longname 1000 || \
8192 error "failed to unlink many hardlinks"
8194 run_test 161 "link ea sanity"
8201 local path=$(${LFS} fid2path $*)
8204 if [ $RC -ne 0 ]; then
8205 err17935 "path looked up of $expected failed. Error $RC"
8207 elif [ "${path}" != "${expected}" ]; then
8208 err17935 "path looked up \"${path}\" instead of \"${expected}\""
8211 echo "fid $fid resolves to path $path (expected $expected)"
8215 # Make changes to filesystem
8216 mkdir -p $DIR/$tdir/d2
8217 touch $DIR/$tdir/d2/$tfile
8218 touch $DIR/$tdir/d2/x1
8219 touch $DIR/$tdir/d2/x2
8220 mkdir -p $DIR/$tdir/d2/a/b/c
8221 mkdir -p $DIR/$tdir/d2/p/q/r
8223 FID=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
8224 check_path "$tdir/d2/$tfile" $FSNAME $FID --link 0
8227 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
8228 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
8229 check_path "$tdir/d2/p/q/r/slink" $FSNAME $FID --link 0
8231 # softlink to wrong file
8232 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
8233 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
8234 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME $FID --link 0
8237 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
8238 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
8239 FID=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
8240 # fid2path dir/fsname should both work
8241 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 1
8242 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR $FID --link 0
8244 # hardlink count: check that there are 2 links
8245 # Doesnt work with CMD yet: 17935
8246 ${LFS} fid2path $DIR $FID | wc -l | grep -q 2 || \
8247 err17935 "expected 2 links"
8249 # hardlink indexing: remove the first link
8250 rm $DIR/$tdir/d2/p/q/r/hlink
8251 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 0
8255 run_test 162 "path lookup sanity"
8258 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8259 copytool --test $FSNAME || { skip "copytool not runnable: $?" && return; }
8262 local uuid=$($LCTL get_param -n mdc.${FSNAME}-MDT0000-mdc-*.uuid)
8263 # this proc file is temporary and linux-only
8264 do_facet $SINGLEMDS lctl set_param mdt.${FSNAME}-MDT0000.mdccomm=$uuid ||\
8265 error "kernel->userspace send failed"
8268 run_test 163 "kernel <-> userspace comms"
8271 # do directio so as not to populate the page cache
8272 log "creating a 10 Mb file"
8273 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
8274 log "starting reads"
8275 dd if=$DIR/$tfile of=/dev/null bs=4096 &
8276 log "truncating the file"
8277 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
8279 kill %+ || true # reads might have finished
8280 echo "wait until dd is finished"
8282 log "removing the temporary file"
8283 rm -rf $DIR/$tfile || error "tmp file removal failed"
8285 run_test 169 "parallel read and truncate should not deadlock"
8288 $LCTL clear # bug 18514
8289 $LCTL debug_daemon start $TMP/${tfile}_log_good
8291 $LCTL debug_daemon stop
8292 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
8293 error "sed failed to read log_good"
8295 $LCTL debug_daemon start $TMP/${tfile}_log_good
8297 $LCTL debug_daemon stop
8299 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
8300 error "lctl df log_bad failed"
8302 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
8303 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
8305 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
8306 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
8308 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
8309 error "bad_line good_line1 good_line2 are empty"
8311 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
8312 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
8313 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
8315 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
8316 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
8317 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
8319 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
8320 error "bad_line_new good_line_new are empty"
8322 local expected_good=$((good_line1 + good_line2*2))
8324 rm -f $TMP/${tfile}*
8325 # LU-231, short malformed line may not be counted into bad lines
8326 if [ $bad_line -ne $bad_line_new ] &&
8327 [ $bad_line -ne $((bad_line_new - 1)) ]; then
8328 error "expected $bad_line bad lines, but got $bad_line_new"
8332 if [ $expected_good -ne $good_line_new ]; then
8333 error "expected $expected_good good lines, but got $good_line_new"
8338 run_test 170 "test lctl df to handle corrupted log ====================="
8340 test_171() { # bug20592
8341 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
8342 $LCTL set_param fail_loc=0x50e
8343 $LCTL set_param fail_val=3000
8344 multiop_bg_pause $DIR/$tfile O_s || true
8346 kill -USR1 $MULTIPID
8350 if dmesg | grep "recursive fault"; then
8351 error "caught a recursive fault"
8353 $LCTL set_param fail_loc=0
8356 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
8358 # it would be good to share it with obdfilter-survey/libecho code
8359 setup_obdecho_osc () {
8362 local obdfilter_name=$2
8363 echo "Creating new osc for $obdfilter_name on $ost_nid"
8364 # make sure we can find loopback nid
8365 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
8367 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
8368 ${obdfilter_name}_osc_UUID || rc=2; }
8369 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
8370 ${obdfilter_name}_UUID $ost_nid || rc=3; }
8374 cleanup_obdecho_osc () {
8375 local obdfilter_name=$1
8376 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
8377 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
8381 obdecho_create_test() {
8386 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
8387 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
8389 if [ $rc -eq 0 ]; then
8390 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
8391 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
8393 echo "New object id is $id"
8394 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec test_brw 10 w v 64 $id" ||
8396 [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec " \
8397 "cleanup" || rc=5; }
8398 [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec " \
8400 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
8405 remote_ost_nodsh && skip "remote OST with nodsh" && return
8409 if ! module_loaded obdecho; then
8410 load_module obdecho/obdecho
8414 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
8415 local host=$(lctl get_param -n osc.$osc.import |
8416 awk '/current_connection:/ {print $2}' )
8417 local target=$(lctl get_param -n osc.$osc.import |
8418 awk '/target:/ {print $2}' )
8419 target=${target%_UUID}
8421 [[ -n $target ]] && { setup_obdecho_osc $host $target || rc=1; } || rc=1
8422 [ $rc -eq 0 ] && { obdecho_create_test ${target}_osc client || rc=2; }
8423 [[ -n $target ]] && cleanup_obdecho_osc $target
8424 [ $rmmod_local -eq 1 ] && rmmod obdecho
8427 run_test 180a "test obdecho on osc"
8430 remote_ost_nodsh && skip "remote OST with nodsh" && return
8432 local rmmod_remote=0
8434 do_facet ost1 "lsmod | grep -q obdecho || " \
8435 "{ insmod ${LUSTRE}/obdecho/obdecho.ko || " \
8436 "modprobe obdecho; }" && rmmod_remote=1
8437 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ {print $4;exit}')
8438 [[ -n $target ]] && { obdecho_create_test $target ost1 || rc=1; }
8439 [ $rmmod_remote -eq 1 ] && do_facet ost1 "rmmod obdecho"
8442 run_test 180b "test obdecho directly on obdfilter"
8444 test_181() { # bug 22177
8445 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
8446 # create enough files to index the directory
8447 createmany -o $DIR/$tdir/foobar 4000
8448 # print attributes for debug purpose
8451 multiop_bg_pause $DIR/$tdir D_Sc || return 1
8453 # remove the files & current working dir
8454 unlinkmany $DIR/$tdir/foobar 4000
8456 kill -USR1 $MULTIPID
8458 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
8461 run_test 181 "Test open-unlinked dir ========================"
8464 # disable MDC RPC lock wouldn't crash client
8468 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
8469 #define OBD_FAIL_MDC_RPCS_SEM 0x804
8470 $LCTL set_param fail_loc=0x804
8472 for (( i=0; i < $tcount; i++ )) ; do
8474 createmany -o $DIR/$tdir/$i/f- $fcount &
8478 for (( i=0; i < $tcount; i++ )) ; do
8479 unlinkmany $DIR/$tdir/$i/f- $fcount &
8485 $LCTL set_param fail_loc=0
8487 run_test 182 "Disable MDC RPCs semaphore wouldn't crash client ================"
8493 TGTPOOL_MAX=$(($TGT_COUNT - 1))
8495 TGTPOOL_LIST=`seq $TGTPOOL_FIRST $TGTPOOL_STEP $TGTPOOL_MAX`
8496 POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
8497 POOL_DIR_NAME=dir_tst
8498 POOL_DIR=$POOL_ROOT/$POOL_DIR_NAME
8499 POOL_FILE=$POOL_ROOT/file_tst
8501 check_file_in_pool()
8504 res=$($GETSTRIPE $file | grep 0x | cut -f2)
8507 found=$(echo :$TGTPOOL_LIST: | tr " " ":" | grep :$i:)
8508 if [[ "$found" == "" ]]
8510 echo "pool list: $TGTPOOL_LIST"
8511 echo "striping: $res"
8512 error "$file not allocated in $POOL"
8519 trap "cleanup_pools $FSNAME" EXIT
8522 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
8523 create_pool $FSNAME.$POOL || return $?
8524 [ $($LFS pool_list $FSNAME | grep -c $POOL) -eq 1 ] ||
8525 error "$POOL not in lfs pool_list"
8527 run_test 200a "Create new pool =========================================="
8530 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
8531 TGT=$(for i in $TGTPOOL_LIST; do printf "$FSNAME-OST%04x_UUID " $i; done)
8532 do_facet mgs $LCTL pool_add $FSNAME.$POOL \
8533 $FSNAME-OST[$TGTPOOL_FIRST-$TGTPOOL_MAX/$TGTPOOL_STEP]
8534 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL | sort -u | tr '\n' ' ' " "$TGT" ||
8535 error "Add to pool failed"
8536 local lfscount=$($LFS pool_list $FSNAME.$POOL | grep -c "\-OST")
8537 local addcount=$((($TGTPOOL_MAX - $TGTPOOL_FIRST) / $TGTPOOL_STEP + 1))
8538 [ $lfscount -eq $addcount ] ||
8539 error "lfs pool_list bad ost count $lfscount != $addcount"
8541 run_test 200b "Add targets to a pool ===================================="
8544 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
8546 $SETSTRIPE -c 2 -p $POOL $POOL_DIR
8547 [ $? = 0 ] || error "Cannot set pool $POOL to $POOL_DIR"
8548 # b-19919 test relative path works well
8549 mkdir -p $POOL_DIR/$POOL_DIR_NAME
8551 $SETSTRIPE -c 2 -p $POOL $POOL_DIR_NAME
8552 [ $? = 0 ] || error "Cannot set pool $POOL to $POOL_DIR/$POOL_DIR_NAME"
8553 $SETSTRIPE -c 2 -p $POOL ./$POOL_DIR_NAME
8554 [ $? = 0 ] || error "Cannot set pool $POOL to $POOL_DIR/./$POOL_DIR_NAME"
8555 $SETSTRIPE -c 2 -p $POOL ../$POOL_DIR_NAME
8556 [ $? = 0 ] || error "Cannot set pool $POOL to $POOL_DIR/../$POOL_DIR_NAME"
8557 $SETSTRIPE -c 2 -p $POOL ../$POOL_DIR_NAME/$POOL_DIR_NAME
8558 [ $? = 0 ] || error "Cannot set pool $POOL to $POOL_DIR/../$POOL_DIR_NAME/$POOL_DIR_NAME"
8559 rm -rf $POOL_DIR_NAME; cd -
8561 run_test 200c "Set pool on a directory ================================="
8564 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
8565 res=$($GETSTRIPE --pool $POOL_DIR)
8566 [ $res = $POOL ] || error "Pool on $POOL_DIR is $res, not $POOL"
8568 run_test 200d "Check pool on a directory ==============================="
8571 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
8573 for i in $(seq -w 1 $(($TGT_COUNT * 3)))
8575 file=$POOL_DIR/file-$i
8577 check_file_in_pool $file
8580 failed=$(($failed + 1))
8583 [ "$failed" = 0 ] || error "$failed files not allocated in $POOL"
8585 run_test 200e "Check files allocation from directory pool =============="
8588 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
8591 for i in $(seq -w 1 $(($TGT_COUNT * 3)))
8593 file=$POOL_FILE/spoo-$i
8594 $SETSTRIPE -p $POOL $file
8595 check_file_in_pool $file
8598 failed=$(($failed + 1))
8601 [ "$failed" = 0 ] || error "$failed files not allocated in $POOL"
8603 run_test 200f "Create files in a pool ==================================="
8606 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
8607 TGT=$($LCTL get_param -n lov.$FSNAME-clilov-*.pools.$POOL | tr '\n' ' ')
8608 res=$($LFS df --pool $FSNAME.$POOL | awk '{print $1}' | grep "$FSNAME-OST" | tr '\n' ' ')
8609 [ "$res" = "$TGT" ] || error "Pools OSTs '$TGT' is not '$res' that lfs df reports"
8611 run_test 200g "lfs df a pool ============================================"
8613 test_200h() { # b=24039
8614 mkdir -p $POOL_DIR || error "unable to create $POOL_DIR"
8616 local file="/..$POOL_DIR/$tfile-1"
8617 $SETSTRIPE -p $POOL $file || error "unable to create $file"
8620 $SETSTRIPE -p $POOL $tfile-2 || \
8621 error "unable to create $tfile-2 in $POOL_DIR"
8623 run_test 200h "Create files in a pool with relative pathname ============"
8626 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
8627 TGT=$($LCTL get_param -n lov.$FSNAME-*.pools.$POOL | head -1)
8628 do_facet mgs $LCTL pool_remove $FSNAME.$POOL $TGT
8629 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL | grep $TGT" "" ||
8630 error "$TGT not removed from $FSNAME.$POOL"
8632 run_test 201a "Remove a target from a pool ============================="
8635 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
8636 for TGT in $($LCTL get_param -n lov.$FSNAME-*.pools.$POOL | sort -u)
8638 do_facet mgs $LCTL pool_remove $FSNAME.$POOL $TGT
8640 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL" "" ||
8641 error "Pool $FSNAME.$POOL cannot be drained"
8642 # striping on an empty/nonexistant pool should fall back to "pool of everything"
8643 touch ${POOL_DIR}/$tfile || error "failed to use fallback striping for empty pool"
8644 # setstripe on an empty pool should fail
8645 $SETSTRIPE -p $POOL ${POOL_FILE}/$tfile 2>/dev/null && \
8646 error "expected failure when creating file with empty pool"
8649 run_test 201b "Remove all targets from a pool =========================="
8652 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
8653 do_facet mgs $LCTL pool_destroy $FSNAME.$POOL
8656 # striping on an empty/nonexistant pool should fall back to "pool of everything"
8657 touch ${POOL_DIR}/$tfile || error "failed to use fallback striping for missing pool"
8658 # setstripe on an empty pool should fail
8659 $SETSTRIPE -p $POOL ${POOL_FILE}/$tfile 2>/dev/null && \
8660 error "expected failure when creating file with missing pool"
8662 # get param should return err once pool is gone
8663 if wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null ||
8664 echo foo" "foo"; then
8665 remove_pool_from_list $FSNAME.$POOL
8668 error "Pool $FSNAME.$POOL is not destroyed"
8670 run_test 201c "Remove a pool ============================================"
8672 cleanup_pools $FSNAME
8674 # usage: default_attr <count | size | offset>
8676 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
8679 # usage: check_default_stripe_attr
8680 check_default_stripe_attr() {
8681 ACTUAL=$($GETSTRIPE $* $DIR/$tdir)
8683 --stripe-count|--count)
8684 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
8685 --stripe-size|--size)
8686 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
8687 --stripe-index|--index)
8690 error "unknown getstripe attr '$1'"
8693 [ $ACTUAL != $EXPECTED ] &&
8694 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
8699 $SETSTRIPE --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
8701 check_default_stripe_attr --stripe-count
8702 check_default_stripe_attr --stripe-size
8703 check_default_stripe_attr --stripe-index
8707 run_test 204a "Print default stripe attributes ================="
8711 $SETSTRIPE --stripe-count 1 $DIR/$tdir
8713 check_default_stripe_attr --stripe-size
8714 check_default_stripe_attr --stripe-index
8718 run_test 204b "Print default stripe size and offset ==========="
8722 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
8724 check_default_stripe_attr --stripe-count
8725 check_default_stripe_attr --stripe-index
8729 run_test 204c "Print default stripe count and offset ==========="
8733 $SETSTRIPE --stripe-index 0 $DIR/$tdir
8735 check_default_stripe_attr --stripe-count
8736 check_default_stripe_attr --stripe-size
8740 run_test 204d "Print default stripe count and size ============="
8744 $SETSTRIPE -d $DIR/$tdir
8746 check_default_stripe_attr --stripe-count --raw
8747 check_default_stripe_attr --stripe-size --raw
8748 check_default_stripe_attr --stripe-index --raw
8752 run_test 204e "Print raw stripe attributes ================="
8756 $SETSTRIPE --stripe-count 1 $DIR/$tdir
8758 check_default_stripe_attr --stripe-size --raw
8759 check_default_stripe_attr --stripe-index --raw
8763 run_test 204f "Print raw stripe size and offset ==========="
8767 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
8769 check_default_stripe_attr --stripe-count --raw
8770 check_default_stripe_attr --stripe-index --raw
8774 run_test 204g "Print raw stripe count and offset ==========="
8778 $SETSTRIPE --stripe-index 0 $DIR/$tdir
8780 check_default_stripe_attr --stripe-count --raw
8781 check_default_stripe_attr --stripe-size --raw
8785 run_test 204h "Print raw stripe count and size ============="
8787 # Figure out which job scheduler is being used, if any,
8789 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
8791 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
8793 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
8795 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
8796 JOBENV=LOADL_STEP_ID
8797 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
8807 # clear old jobstats
8808 do_facet $SINGLEMDS lctl set_param mdt.*.job_stats="clear"
8809 do_facet ost0 lctl set_param obdfilter.*.job_stats="clear"
8811 # use a new JobID for this test, or we might see an old one
8812 [ "$JOBENV" = "FAKE_JOBID" ] && FAKE_JOBID=test_id.$testnum.$RANDOM
8816 log "Using JobID environment variable $JOBENV=$JOBVAL"
8818 if [ $JOBENV = "FAKE_JOBID" ]; then
8819 FAKE_JOBID=$JOBVAL $cmd
8824 if [ "$target" = "mdt" -o "$target" = "both" ]; then
8825 FACET="$SINGLEMDS" # will need to get MDS number for DNE
8826 do_facet $FACET lctl get_param mdt.*.job_stats |
8827 grep $JOBVAL || error "No job stats found on MDT $FACET"
8829 if [ "$target" = "ost" -o "$target" = "both" ]; then
8831 do_facet $FACET lctl get_param obdfilter.*.job_stats |
8832 grep $JOBVAL || error "No job stats found on OST $FACET"
8836 test_205() { # Job stats
8838 OLD_JOBENV=`$LCTL get_param -n jobid_var`
8839 if [ $OLD_JOBENV != $JOBENV ]; then
8840 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$JOBENV
8841 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" \
8846 cmd="mkdir $DIR/$tfile"
8847 verify_jobstats "$cmd" "mdt"
8849 cmd="rm -fr $DIR/$tfile"
8850 verify_jobstats "$cmd" "mdt"
8852 cmd="mknod $DIR/$tfile c 1 3"
8853 verify_jobstats "$cmd" "mdt"
8855 cmd="rm -f $DIR/$tfile"
8856 verify_jobstats "$cmd" "mdt"
8858 cmd="$SETSTRIPE -i 0 -c 1 $DIR/$tfile"
8859 verify_jobstats "$cmd" "mdt"
8861 cmd="touch $DIR/$tfile"
8862 verify_jobstats "$cmd" "both"
8864 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
8865 verify_jobstats "$cmd" "ost"
8867 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
8868 verify_jobstats "$cmd" "ost"
8870 cmd="$TRUNCATE $DIR/$tfile 0"
8871 verify_jobstats "$cmd" "both"
8873 cmd="mv -f $DIR/$tfile $DIR/jobstats_test_rename"
8874 verify_jobstats "$cmd" "mdt"
8877 rm -f $DIR/jobstats_test_rename
8879 if [ $OLD_JOBENV != $JOBENV ]; then
8880 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$OLD_JOBENV
8881 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" \
8882 $OLD_JOBENV || return 1
8885 run_test 205 "Verify job stats"
8889 size=$((size % 8192 + 1))
8890 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
8891 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
8892 rm -f $DIR/f212 $DIR/f212.xyz
8894 run_test 212 "Sendfile test ============================================"
8897 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
8898 cancel_lru_locks osc
8899 lctl set_param fail_loc=0x8000040f
8900 # generate a read lock
8901 cat $DIR/$tfile > /dev/null
8902 # write to the file, it will try to cancel the above read lock.
8903 cat /etc/hosts >> $DIR/$tfile
8905 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
8907 test_214() { # for bug 20133
8908 mkdir -p $DIR/d214p/d214c
8909 for (( i=0; i < 340; i++ )) ; do
8910 touch $DIR/d214p/d214c/a$i
8913 ls -l $DIR/d214p || error "ls -l $DIR/d214p failed"
8914 mv $DIR/d214p/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
8915 ls $DIR/d214c || error "ls $DIR/d214c failed"
8916 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
8918 run_test 214 "hash-indexed directory test - bug 20133"
8920 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
8921 create_lnet_proc_files() {
8922 cat /proc/sys/lnet/$1 >$TMP/lnet_$1.out || error "cannot read /proc/sys/lnet/$1"
8923 sysctl lnet.$1 >$TMP/lnet_$1.sys_tmp || error "cannot read lnet.$1"
8925 sed "s/^lnet.$1\ =\ //g" "$TMP/lnet_$1.sys_tmp" >$TMP/lnet_$1.sys
8926 rm -f "$TMP/lnet_$1.sys_tmp"
8929 # counterpart of create_lnet_proc_files
8930 remove_lnet_proc_files() {
8931 rm -f $TMP/lnet_$1.out $TMP/lnet_$1.sys
8934 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
8935 # 3rd arg as regexp for body
8936 check_lnet_proc_stats() {
8937 local l=$(cat "$TMP/lnet_$1" |wc -l)
8938 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
8940 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
8943 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
8944 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
8945 # optional and can be regexp for 2nd line (lnet.routes case)
8946 check_lnet_proc_entry() {
8947 local blp=2 # blp stands for 'position of 1st line of body'
8948 [ "$5" = "" ] || blp=3 # lnet.routes case
8950 local l=$(cat "$TMP/lnet_$1" |wc -l)
8951 # subtracting one from $blp because the body can be empty
8952 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
8954 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
8955 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
8957 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
8958 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
8960 # bail out if any unexpected line happened
8961 sed -n "$blp~1 p" "$TMP/lnet_$1" |grep -Ev "$3"
8962 [ "$?" != 0 ] || error "$2 misformatted"
8965 test_215() { # for bugs 18102, 21079, 21517
8966 local N='(0|[1-9][0-9]*)' # non-negative numeric
8967 local P='[1-9][0-9]*' # positive numeric
8968 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
8969 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
8970 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
8971 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
8973 local L1 # regexp for 1st line
8974 local L2 # regexp for 2nd line (optional)
8975 local BR # regexp for the rest (body)
8977 # /proc/sys/lnet/stats should look as 11 space-separated non-negative numerics
8978 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
8979 create_lnet_proc_files "stats"
8980 check_lnet_proc_stats "stats.out" "/proc/sys/lnet/stats" "$BR"
8981 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
8982 remove_lnet_proc_files "stats"
8984 # /proc/sys/lnet/routes should look like this:
8985 # Routing disabled/enabled
8986 # net hops state router
8987 # where net is a string like tcp0, hops >= 0, state is up/down,
8988 # router is a string like 192.168.1.1@tcp2
8989 L1="^Routing (disabled|enabled)$"
8990 L2="^net +hops +state +router$"
8991 BR="^$NET +$N +(up|down) +$NID$"
8992 create_lnet_proc_files "routes"
8993 check_lnet_proc_entry "routes.out" "/proc/sys/lnet/routes" "$BR" "$L1" "$L2"
8994 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
8995 remove_lnet_proc_files "routes"
8997 # /proc/sys/lnet/routers should look like this:
8998 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
8999 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
9000 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
9001 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
9002 L1="^ref +rtr_ref +alive_cnt +state +last_ping +ping_sent +deadline +down_ni +router$"
9003 BR="^$P +$P +$N +(up|down) +$N +(0|1) +$I +$I +$NID$"
9004 create_lnet_proc_files "routers"
9005 check_lnet_proc_entry "routers.out" "/proc/sys/lnet/routers" "$BR" "$L1"
9006 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
9007 remove_lnet_proc_files "routers"
9009 # /proc/sys/lnet/peers should look like this:
9010 # nid refs state last max rtr min tx min queue
9011 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
9012 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
9013 # numeric (0 or >0 or <0), queue >= 0.
9014 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
9015 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
9016 create_lnet_proc_files "peers"
9017 check_lnet_proc_entry "peers.out" "/proc/sys/lnet/peers" "$BR" "$L1"
9018 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
9019 remove_lnet_proc_files "peers"
9021 # /proc/sys/lnet/buffers should look like this:
9022 # pages count credits min
9023 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
9024 L1="^pages +count +credits +min$"
9025 BR="^ +$N +$N +$I +$I$"
9026 create_lnet_proc_files "buffers"
9027 check_lnet_proc_entry "buffers.out" "/proc/sys/lnet/buffers" "$BR" "$L1"
9028 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
9029 remove_lnet_proc_files "buffers"
9031 # /proc/sys/lnet/nis should look like this:
9032 # nid status alive refs peer rtr max tx min
9033 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
9034 # alive is numeric (0 or >0 or <0), refs > 0, peer >= 0,
9035 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
9036 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
9037 BR="^$NID +(up|down) +$I +$P +$N +$N +$N +$I +$I$"
9038 create_lnet_proc_files "nis"
9039 check_lnet_proc_entry "nis.out" "/proc/sys/lnet/nis" "$BR" "$L1"
9040 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
9041 remove_lnet_proc_files "nis"
9043 # can we successfully write to /proc/sys/lnet/stats?
9044 echo "0" >/proc/sys/lnet/stats || error "cannot write to /proc/sys/lnet/stats"
9045 sysctl -w lnet.stats=0 || error "cannot write to lnet.stats"
9047 run_test 215 "/proc/sys/lnet exists and has proper content - bugs 18102, 21079, 21517"
9049 test_216() { # bug 20317
9050 remote_ost_nodsh && skip "remote OST with nodsh" && return
9052 local p="$TMP/sanityN-$TESTNAME.parameters"
9053 save_lustre_params $HOSTNAME "osc.*.contention_seconds" > $p
9054 for node in $(osts_nodes); do
9055 save_lustre_params $node "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
9056 save_lustre_params $node "ldlm.namespaces.filter-*.contended_locks" >> $p
9057 save_lustre_params $node "ldlm.namespaces.filter-*.contention_seconds" >> $p
9061 # agressive lockless i/o settings
9062 for node in $(osts_nodes); do
9063 do_node $node 'lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes 2000000; lctl set_param -n ldlm.namespaces.filter-*.contended_locks 0; lctl set_param -n ldlm.namespaces.filter-*.contention_seconds 60'
9065 lctl set_param -n osc.*.contention_seconds 60
9067 $DIRECTIO write $DIR/$tfile 0 10 4096
9068 $CHECKSTAT -s 40960 $DIR/$tfile
9070 # disable lockless i/o
9071 for node in $(osts_nodes); do
9072 do_node $node 'lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes 0; lctl set_param -n ldlm.namespaces.filter-*.contended_locks 32; lctl set_param -n ldlm.namespaces.filter-*.contention_seconds 0'
9074 lctl set_param -n osc.*.contention_seconds 0
9077 dd if=/dev/zero of=$DIR/$tfile count=0
9078 $CHECKSTAT -s 0 $DIR/$tfile
9080 restore_lustre_params <$p
9084 run_test 216 "check lockless direct write works and updates file size and kms correctly"
9086 test_217() { # bug 22430
9090 for node in $(nodes_list); do
9091 nid=$(host_nids_address $node $NETTYPE)
9092 if [[ $nid = *-* ]] ; then
9093 echo "lctl ping $nid@$NETTYPE"
9094 lctl ping $nid@$NETTYPE
9096 echo "skipping $node (no hyphen detected)"
9100 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
9103 # do directio so as not to populate the page cache
9104 log "creating a 10 Mb file"
9105 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
9106 log "starting reads"
9107 dd if=$DIR/$tfile of=/dev/null bs=4096 &
9108 log "truncating the file"
9109 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
9111 kill %+ || true # reads might have finished
9112 echo "wait until dd is finished"
9114 log "removing the temporary file"
9115 rm -rf $DIR/$tfile || error "tmp file removal failed"
9117 run_test 218 "parallel read and truncate should not deadlock ======================="
9120 # write one partial page
9121 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
9122 # set no grant so vvp_io_commit_write will do sync write
9123 $LCTL set_param fail_loc=0x411
9124 # write a full page at the end of file
9125 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
9127 $LCTL set_param fail_loc=0
9128 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
9129 $LCTL set_param fail_loc=0x411
9130 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
9132 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
9134 test_220() { #LU-325
9135 remote_ost_nodsh && skip "remote OST with nodsh" && return
9139 local OST=$(lfs osts | grep ${OSTIDX}": " | \
9140 awk '{print $2}' | sed -e 's/_UUID$//')
9143 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
9144 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
9145 osc.$mdtosc_proc1.prealloc_last_id)
9146 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
9147 osc.$mdtosc_proc1.prealloc_next_id)
9151 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
9152 #define OBD_FAIL_OST_ENOINO 0x229
9153 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
9154 do_facet mgs $LCTL pool_new $FSNAME.$TESTNAME || return 1
9155 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
9157 $SETSTRIPE $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
9159 MDSOBJS=$((last_id - next_id))
9160 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
9162 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
9163 echo "OST still has $count kbytes free"
9165 echo "create $MDSOBJS files @next_id..."
9166 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
9168 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
9169 osc.$mdtosc_proc1.prealloc_last_id)
9170 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
9171 osc.$mdtosc_proc1.prealloc_next_id)
9173 echo "after creation, last_id=$last_id2, next_id=$next_id2"
9178 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
9179 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
9181 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST || return 4
9182 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME || return 5
9183 echo "unlink $MDSOBJS files @$next_id..."
9184 unlinkmany $DIR/$tdir/f $MDSOBJS || return 6
9186 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
9189 dd if=`which date` of=$MOUNT/date oflag=sync
9190 chmod +x $MOUNT/date
9192 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
9193 $LCTL set_param fail_loc=0x80001401
9195 $MOUNT/date > /dev/null
9198 run_test 221 "make sure fault and truncate race to not cause OOM"
9203 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
9204 createmany -o $DIR/$tdir/$tfile 10
9205 cancel_lru_locks mdc
9206 cancel_lru_locks osc
9207 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
9208 $LCTL set_param fail_loc=0x31a
9209 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
9210 $LCTL set_param fail_loc=0
9213 run_test 222a "AGL for ls should not trigger CLIO lock failure ================"
9218 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
9219 createmany -o $DIR/$tdir/$tfile 10
9220 cancel_lru_locks mdc
9221 cancel_lru_locks osc
9222 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
9223 $LCTL set_param fail_loc=0x31a
9224 rm -r $DIR/$tdir || "AGL for rmdir failed"
9225 $LCTL set_param fail_loc=0
9227 run_test 222b "AGL for rmdir should not trigger CLIO lock failure ============="
9232 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
9233 createmany -o $DIR/$tdir/$tfile 10
9234 cancel_lru_locks mdc
9235 cancel_lru_locks osc
9236 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
9237 $LCTL set_param fail_loc=0x31b
9238 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
9239 $LCTL set_param fail_loc=0
9242 run_test 223 "osc reenqueue if without AGL lock granted ======================="
9244 test_224a() { # LU-1039, MRP-303
9245 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
9246 $LCTL set_param fail_loc=0x508
9247 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
9248 $LCTL set_param fail_loc=0
9251 run_test 224a "Don't panic on bulk IO failure"
9253 test_224b() { # LU-1039, MRP-303
9254 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
9255 cancel_lru_locks osc
9256 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
9257 $LCTL set_param fail_loc=0x515
9258 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
9259 $LCTL set_param fail_loc=0
9262 run_test 224b "Don't panic on bulk IO failure"
9264 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
9266 if [ -z ${MDSSURVEY} ]; then
9267 skip_env "mds-survey not found" && return
9269 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
9270 { skip "Need MDS version at least 2.2.51"; return; }
9272 local mds=$(facet_host $SINGLEMDS)
9273 local target=$(do_nodes $mds 'lctl dl' | \
9274 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
9276 local cmd1="file_count=1000 thrhi=4"
9277 local cmd2="dir_count=2 layer=mdd stripe_count=0"
9278 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
9279 local cmd="$cmd1 $cmd2 $cmd3"
9281 rm -f ${TMP}/mds_survey*
9283 eval $cmd || error "mds-survey with zero-stripe failed"
9284 cat ${TMP}/mds_survey*
9285 rm -f ${TMP}/mds_survey*
9287 run_test 225a "Metadata survey sanity with zero-stripe"
9290 if [ -z ${MDSSURVEY} ]; then
9291 skip_env "mds-survey not found" && return
9293 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
9294 { skip "Need MDS version at least 2.2.51"; return; }
9296 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
9297 skip_env "Need to mount OST to test" && return
9300 local mds=$(facet_host $SINGLEMDS)
9301 local target=$(do_nodes $mds 'lctl dl' | \
9302 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
9304 local cmd1="file_count=1000 thrhi=4"
9305 local cmd2="dir_count=2 layer=mdd stripe_count=1"
9306 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
9307 local cmd="$cmd1 $cmd2 $cmd3"
9309 rm -f ${TMP}/mds_survey*
9311 eval $cmd || error "mds-survey with stripe_count failed"
9312 cat ${TMP}/mds_survey*
9313 rm -f ${TMP}/mds_survey*
9315 run_test 225b "Metadata survey sanity with stripe_count = 1"
9317 mcreate_path2fid () {
9323 local path=$DIR/$tdir/$name
9328 $MCREATE --mode=$1 --major=$2 --minor=$3 $path || \
9329 error "error: cannot create $desc"
9331 fid=$($LFS path2fid $path)
9333 [ $rc -ne 0 ] && error "error: cannot get fid of a $desc"
9335 fid_path=$($LFS fid2path $DIR $fid)
9337 [ $rc -ne 0 ] && error "error: cannot get path of a $desc by fid"
9339 [ "$path" == "$fid_path" ] || \
9340 error "error: fid2path returned \`$fid_path', expected \`$path'"
9347 mcreate_path2fid 0010666 0 0 fifo "FIFO"
9348 mcreate_path2fid 0020666 1 3 null "character special file (null)"
9349 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
9350 mcreate_path2fid 0040666 0 0 dir "directory"
9351 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
9352 mcreate_path2fid 0100666 0 0 file "regular file"
9353 mcreate_path2fid 0120666 0 0 link "symbolic link"
9354 mcreate_path2fid 0140666 0 0 sock "socket"
9356 run_test 226 "call path2fid and fid2path on files of all type"
9358 # LU-1299 Executing or running ldd on a truncated executable does not
9359 # cause an out-of-memory condition.
9361 dd if=`which date` of=$MOUNT/date bs=1k count=1
9362 chmod +x $MOUNT/date
9364 $MOUNT/date > /dev/null
9365 ldd $MOUNT/date > /dev/null
9368 run_test 227 "running truncated executable does not cause OOM"
9371 # tests that do cleanup/setup should be run at the end
9376 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
9377 $LCTL set_param fail_loc=0x903
9378 # cancel_lru_locks mgc - does not work due to lctl set_param syntax
9379 for ls in /proc/fs/lustre/ldlm/namespaces/MGC*/lru_size; do
9382 FAIL_ON_ERROR=true cleanup
9383 FAIL_ON_ERROR=true setup
9385 run_test 900 "umount should not race with any mgc requeue thread"
9387 complete $(basename $0) $SECONDS
9388 check_and_cleanup_lustre
9389 if [ "$I_MOUNTED" != "yes" ]; then
9390 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true