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 ========================="
493 local short_sym="0123456789"
494 local WDIR=$DIR/${tdir}m
503 # create a long symlink file
504 for ((i = 0; i < 4; ++i)); do
505 long_sym=${long_sym}${long_sym}
508 echo "create 512 short and long symlink files under $WDIR"
509 for ((i = 0; i < 256; ++i)); do
510 ln -sf ${long_sym}"a5a5" $WDIR/long-$i
511 ln -sf ${short_sym}"a5a5" $WDIR/short-$i
519 echo "recreate the 512 symlink files with a shorter string"
520 for ((i = 0; i < 512; ++i)); do
521 # rewrite the symlink file with a shorter string
522 ln -sf ${long_sym} $WDIR/long-$i
523 ln -sf ${short_sym} $WDIR/short-$i
526 mds_index=$($LFS getstripe -M $WDIR)
527 mds_index=$((mds_index+1))
528 devname=$(mdsdevname $mds_index)
529 cmd="$E2FSCK -fnvd $devname"
531 echo "stop and checking mds${mds_index}: $cmd"
532 # e2fsck should not return error
533 stop mds${mds_index} -f
534 do_facet mds${mds_index} $cmd || rc=$?
536 start mds${mds_index} $devname $MDS_MOUNT_OPTS
537 df $MOUNT > /dev/null 2>&1
538 [ $rc -ne 0 ] && error "e2fsck should not report error upon "\
539 "short/long symlink MDT: rc=$rc"
542 run_test 17m "run e2fsck against MDT which contains short/long symlink"
548 run_test 18 "touch .../f ; ls ... =============================="
554 $CHECKSTAT -a $DIR/f19 || error
556 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
559 ls -l $DIR/f19 && error || true
561 run_test 19b "ls -l .../f19 (should return error) =============="
564 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
565 $RUNAS touch $DIR/f19 && error || true
567 run_test 19c "$RUNAS touch .../f19 (should return error) =="
570 cat $DIR/f19 && error || true
572 run_test 19d "cat .../f19 (should return error) =============="
584 $CHECKSTAT -a $DIR/f || error
586 run_test 20 "touch .../f ; ls -l ... ==========================="
590 [ -f $DIR/d21/dangle ] && rm -f $DIR/d21/dangle
591 ln -s dangle $DIR/d21/link
592 echo foo >> $DIR/d21/link
594 $CHECKSTAT -t link $DIR/d21/link || error
595 $CHECKSTAT -f -t file $DIR/d21/link || error
597 run_test 21 "write to dangling link ============================"
602 chown $RUNAS_ID:$RUNAS_GID $WDIR
603 (cd $WDIR || error "cd $WDIR failed";
604 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
606 ls -lR $WDIR/etc || error "ls -lR $WDIR/etc failed"
607 $CHECKSTAT -t dir $WDIR/etc || error "checkstat -t dir failed"
608 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $WDIR/etc || error "checkstat -u failed"
610 run_test 22 "unpack tar archive as non-root user ==============="
615 local file=$DIR/$tdir/$tfile
617 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
618 openfile -f O_CREAT:O_EXCL $file &&
619 error "$file recreate succeeded" || true
621 run_test 23a "O_CREAT|O_EXCL in subdir =========================="
623 test_23b() { # bug 18988
625 local file=$DIR/$tdir/$tfile
628 echo foo > $file || error "write filed"
629 echo bar >> $file || error "append filed"
630 $CHECKSTAT -s 8 $file || error "wrong size"
633 run_test 23b "O_APPEND check =========================="
636 echo '== rename sanity =============================================='
637 echo '-- same directory rename'
640 mv $DIR/R1/f $DIR/R1/g
641 $CHECKSTAT -t file $DIR/R1/g || error
643 run_test 24a "touch .../R1/f; rename .../R1/f .../R1/g ========="
648 mv $DIR/R2/f $DIR/R2/g
649 $CHECKSTAT -a $DIR/R2/f || error
650 $CHECKSTAT -t file $DIR/R2/g || error
652 run_test 24b "touch .../R2/{f,g}; rename .../R2/f .../R2/g ====="
657 mv $DIR/R3/f $DIR/R3/g
658 $CHECKSTAT -a $DIR/R3/f || error
659 $CHECKSTAT -t dir $DIR/R3/g || error
661 run_test 24c "mkdir .../R3/f; rename .../R3/f .../R3/g ========="
666 mrename $DIR/R4/f $DIR/R4/g
667 $CHECKSTAT -a $DIR/R4/f || error
668 $CHECKSTAT -t dir $DIR/R4/g || error
670 run_test 24d "mkdir .../R4/{f,g}; rename .../R4/f .../R4/g ====="
673 echo '-- cross directory renames --'
676 mv $DIR/R5a/f $DIR/R5b/g
677 $CHECKSTAT -a $DIR/R5a/f || error
678 $CHECKSTAT -t file $DIR/R5b/g || error
680 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
684 touch $DIR/R6a/f $DIR/R6b/g
685 mv $DIR/R6a/f $DIR/R6b/g
686 $CHECKSTAT -a $DIR/R6a/f || error
687 $CHECKSTAT -t file $DIR/R6b/g || error
689 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
694 mv $DIR/R7a/d $DIR/R7b/e
695 $CHECKSTAT -a $DIR/R7a/d || error
696 $CHECKSTAT -t dir $DIR/R7b/e || error
698 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
702 mkdir $DIR/R8a/d $DIR/R8b/e
703 mrename $DIR/R8a/d $DIR/R8b/e
704 $CHECKSTAT -a $DIR/R8a/d || error
705 $CHECKSTAT -t dir $DIR/R8b/e || error
707 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
710 echo "-- rename error cases"
714 mrename $DIR/R9/f $DIR/R9/a
715 $CHECKSTAT -t file $DIR/R9/f || error
716 $CHECKSTAT -t dir $DIR/R9/a || error
717 $CHECKSTAT -a $DIR/R9/a/f || error
719 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
723 mrename $DIR/R10/f $DIR/R10/g
724 $CHECKSTAT -t dir $DIR/R10 || error
725 $CHECKSTAT -a $DIR/R10/f || error
726 $CHECKSTAT -a $DIR/R10/g || error
728 run_test 24j "source does not exist ============================"
731 mkdir $DIR/R11a $DIR/R11a/d
733 mv $DIR/R11a/f $DIR/R11a/d
734 $CHECKSTAT -a $DIR/R11a/f || error
735 $CHECKSTAT -t file $DIR/R11a/d/f || error
737 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
739 # bug 2429 - rename foo foo foo creates invalid file
742 $MULTIOP $f OcNs || error
744 run_test 24l "Renaming a file to itself ========================"
748 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
749 # on ext3 this does not remove either the source or target files
750 # though the "expected" operation would be to remove the source
751 $CHECKSTAT -t file ${f} || error "${f} missing"
752 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
754 run_test 24m "Renaming a file to a hard link to itself ========="
758 # this stats the old file after it was renamed, so it should fail
762 $CHECKSTAT ${f}.rename
765 run_test 24n "Statting the old file after renaming (Posix rename 2)"
768 check_kernel_version 37 || return 0
770 rename_many -s random -v -n 10 $DIR/d24o
772 run_test 24o "rename of files during htree split ==============="
776 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
777 mrename $DIR/R12a $DIR/R12b
778 $CHECKSTAT -a $DIR/R12a || error
779 $CHECKSTAT -t dir $DIR/R12b || error
780 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
781 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
783 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
787 DIRINO=`ls -lid $DIR/R13a | awk '{ print $1 }'`
788 multiop_bg_pause $DIR/R13b D_c || return 1
791 mrename $DIR/R13a $DIR/R13b
792 $CHECKSTAT -a $DIR/R13a || error
793 $CHECKSTAT -t dir $DIR/R13b || error
794 DIRINO2=`ls -lid $DIR/R13b | awk '{ print $1 }'`
795 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
797 wait $MULTIPID || error "multiop close failed"
799 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
801 test_24r() { #bug 3789
802 mkdir $DIR/R14a $DIR/R14a/b
803 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
804 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
805 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
807 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
810 mkdir $DIR/R15a $DIR/R15a/b $DIR/R15a/b/c
811 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
812 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
813 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
815 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
817 mkdir $DIR/R16a $DIR/R16a/b $DIR/R16a/b/c
818 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
819 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
820 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
822 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
824 test_24u() { # bug12192
825 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error
826 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
828 run_test 24u "create stripe file"
836 local FREE_INODES=`lfs df -i|grep "filesystem summary" | awk '{print $5}'`
837 [ $FREE_INODES -lt $NRFILES ] && \
838 skip "not enough free inodes $FREE_INODES required $NRFILES" && \
842 createmany -m $DIR/d24v/$tfile $NRFILES
845 lctl set_param mdc.*.stats clear
847 ls $DIR/d24v >/dev/null || error "error in listing large dir"
850 # DIRENT_SIZE = 32 bytes for sizeof(struct lu_dirent) +
851 # 8 bytes for name(filename is mostly 5 in this test) +
852 # 8 bytes for luda_type
853 # take into account of overhead in lu_dirpage header and end mark in
854 # each page, plus one in RPC_NUM calculation.
856 RPC_SIZE=$(($(lctl get_param -n mdc.*.max_pages_per_rpc)*$(page_size)))
857 RPC_NUM=$(((NRFILES * DIRENT_SIZE + RPC_SIZE - 1) / RPC_SIZE + 1))
858 mds_readpage=`lctl get_param mdc.*.stats | \
859 awk '/^mds_readpage/ {print $2}'`
860 [ $mds_readpage -gt $RPC_NUM ] && \
861 error "large readdir doesn't take effect"
865 run_test 24v "list directory with large files (handle hash collision, bug: 17560)"
867 test_24w() { # bug21506
869 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
870 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
871 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
872 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
873 [ "$SZ1" = "$SZ2" ] || \
874 error "Error reading at the end of the file $tfile"
876 run_test 24w "Reading a file larger than 4Gb"
879 echo '== symlink sanity ============================================='
883 touch $DIR/s25/foo || error
885 run_test 25a "create file in symlinked directory ==============="
888 [ ! -d $DIR/d25 ] && test_25a
889 $CHECKSTAT -t file $DIR/s25/foo || error
891 run_test 25b "lookup file in symlinked directory ==============="
896 ln -s d26/d26-2 $DIR/s26
897 touch $DIR/s26/foo || error
899 run_test 26a "multiple component symlink ======================="
902 mkdir -p $DIR/d26b/d26-2
903 ln -s d26b/d26-2/foo $DIR/s26-2
904 touch $DIR/s26-2 || error
906 run_test 26b "multiple component symlink at end of lookup ======"
911 ln -s d26.2 $DIR/s26.2-1
912 ln -s s26.2-1 $DIR/s26.2-2
913 ln -s s26.2-2 $DIR/s26.2-3
914 chmod 0666 $DIR/s26.2-3/foo
916 run_test 26c "chain of symlinks ================================"
918 # recursive symlinks (bug 439)
920 ln -s d26-3/foo $DIR/d26-3
922 run_test 26d "create multiple component recursive symlink ======"
925 [ ! -h $DIR/d26-3 ] && test_26d
928 run_test 26e "unlink multiple component recursive symlink ======"
930 # recursive symlinks (bug 7022)
933 mkdir $DIR/$tdir/$tfile || error "mkdir $DIR/$tdir/$tfile failed"
934 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
935 mkdir -p lndir/bar1 || error "mkdir lndir/bar1 failed"
936 mkdir $tfile || error "mkdir $tfile failed"
937 cd $tfile || error "cd $tfile failed"
938 ln -s .. dotdot || error "ln dotdot failed"
939 ln -s dotdot/lndir lndir || error "ln lndir failed"
940 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
941 output=`ls $tfile/$tfile/lndir/bar1`
942 [ "$output" = bar1 ] && error "unexpected output"
943 rm -r $tfile || error "rm $tfile failed"
944 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
946 run_test 26f "rm -r of a directory which has recursive symlink ="
949 echo '== stripe sanity =============================================='
950 mkdir -p $DIR/d27 || error "mkdir failed"
952 $SETSTRIPE -c 1 $DIR/d27/f0 || error "setstripe failed"
953 $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
955 log "== test_27a: write to one stripe file ========================="
956 cp /etc/hosts $DIR/d27/f0 || error
958 run_test 27a "one stripe file =================================="
961 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
963 $SETSTRIPE -c 2 $DIR/d27/f01 || error "setstripe failed"
964 $GETSTRIPE -c $DIR/d27/f01
965 [ $($GETSTRIPE -c $DIR/d27/f01) -eq 2 ] ||
966 error "two-stripe file doesn't have two stripes"
968 run_test 27b "create two stripe file"
971 [ -f $DIR/d27/f01 ] || skip "test_27b not run" && return
973 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
975 run_test 27c "write to two stripe file"
979 $SETSTRIPE -c 0 -i -1 -S 0 $DIR/d27/fdef || error "setstripe failed"
980 $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
981 dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
983 run_test 27d "create file with default settings ================"
987 $SETSTRIPE -c 2 $DIR/d27/f12 || error "setstripe failed"
988 $SETSTRIPE -c 2 $DIR/d27/f12 && error "setstripe succeeded twice"
989 $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
991 run_test 27e "setstripe existing file (should return error) ======"
995 $SETSTRIPE -S 100 -i 0 -c 1 $DIR/d27/fbad && error "setstripe failed"
996 dd if=/dev/zero of=$DIR/d27/f12 bs=4k count=4 || error "dd failed"
997 $GETSTRIPE $DIR/d27/fbad || error "$GETSTRIPE failed"
999 run_test 27f "setstripe with bad stripe size (should return error)"
1003 $MCREATE $DIR/d27/fnone || error "mcreate failed"
1004 $GETSTRIPE $DIR/d27/fnone 2>&1 | grep "no stripe info" ||
1005 error "$DIR/d27/fnone has object"
1007 run_test 27g "$GETSTRIPE with no objects"
1010 touch $DIR/d27/fsome || error "touch failed"
1011 [ $($GETSTRIPE -c $DIR/d27/fsome) -gt 0 ] || error "missing objects"
1013 run_test 27i "$GETSTRIPE with some objects"
1017 $SETSTRIPE -i $OSTCOUNT $DIR/d27/f27j && error "setstripe failed"||true
1019 run_test 27j "setstripe with bad stripe offset (should return error)"
1021 test_27k() { # bug 2844
1024 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
1025 [ ! -d $DIR/d27 ] && mkdir -p $DIR/d27
1026 $SETSTRIPE -S 67108864 $FILE || error "setstripe failed"
1027 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1028 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
1029 dd if=/dev/zero of=$FILE bs=4k count=1
1030 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1031 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
1033 run_test 27k "limit i_blksize for broken user apps ============="
1037 mcreate $DIR/f27l || error "creating file"
1038 $RUNAS $SETSTRIPE -c 1 $DIR/f27l && \
1039 error "setstripe should have failed" || true
1041 run_test 27l "check setstripe permissions (should return error)"
1044 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1045 if [ $ORIGFREE -gt $MAXFREE ]; then
1046 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1050 $SETSTRIPE -i 0 -c 1 $DIR/d27/f27m_1
1051 dd if=/dev/zero of=$DIR/d27/f27m_1 bs=1024 count=$MAXFREE &&
1052 error "dd should fill OST0"
1054 while $SETSTRIPE -i 0 -c 1 $DIR/d27/f27m_$i; do
1056 [ $i -gt 256 ] && break
1059 touch $DIR/d27/f27m_$i
1060 [ `$GETSTRIPE $DIR/d27/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] && \
1061 error "OST0 was full but new created file still use it"
1063 touch $DIR/d27/f27m_$i
1064 [ `$GETSTRIPE $DIR/d27/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] && \
1065 error "OST0 was full but new created file still use it"
1069 run_test 27m "create file while OST0 was full =================="
1072 local DELAY=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage | head -n 1 | awk '{print $1 * 2}')
1076 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1077 # if the OST isn't full anymore.
1079 local OSTIDX=${1:-""}
1081 local list=$(comma_list $(osts_nodes))
1082 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1084 do_nodes $list lctl set_param fail_loc=0
1088 exhaust_precreations() {
1091 local FAILIDX=${3:-$OSTIDX}
1094 local MDSIDX=$(get_mds_dir "$DIR/$tdir")
1095 echo OSTIDX=$OSTIDX MDSIDX=$MDSIDX
1097 local OST=$(ostname_from_index $OSTIDX)
1098 local MDT_INDEX=$(lfs df | grep "\[MDT:$((MDSIDX - 1))\]" | awk '{print $1}' | \
1099 sed -e 's/_UUID$//;s/^.*-//')
1102 local mdtosc_proc1=$(get_mdtosc_proc_path mds${MDSIDX} $OST)
1103 local last_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1104 osc.$mdtosc_proc1.prealloc_last_id)
1105 local next_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1106 osc.$mdtosc_proc1.prealloc_next_id)
1108 local mdtosc_proc2=$(get_mdtosc_proc_path mds${MDSIDX})
1109 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1111 mkdir -p $DIR/$tdir/${OST}
1112 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1113 #define OBD_FAIL_OST_ENOSPC 0x215
1114 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=$FAILIDX
1115 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x215
1116 echo "Creating to objid $last_id on ost $OST..."
1117 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1118 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1119 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=$FAILLOC
1123 exhaust_all_precreations() {
1125 for (( i=0; i < OSTCOUNT; i++ )) ; do
1126 exhaust_precreations $i $1 -1
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
1137 exhaust_precreations 0 0x80000215
1138 $SETSTRIPE -c -1 $DIR/$tdir
1139 touch $DIR/$tdir/$tfile || error
1140 $GETSTRIPE $DIR/$tdir/$tfile
1143 run_test 27n "create file with some full OSTs =================="
1146 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1147 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1148 remote_ost_nodsh && skip "remote OST with nodsh" && return
1151 rm -f $DIR/$tdir/$tfile
1152 exhaust_all_precreations 0x215
1154 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1159 run_test 27o "create file with all full OSTs (should error) ===="
1162 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1163 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1164 remote_ost_nodsh && skip "remote OST with nodsh" && return
1167 rm -f $DIR/$tdir/$tfile
1170 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1171 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1172 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1174 exhaust_precreations 0 0x80000215
1175 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1176 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1177 $GETSTRIPE $DIR/$tdir/$tfile
1181 run_test 27p "append to a truncated file with some full OSTs ==="
1184 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1185 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1186 remote_ost_nodsh && skip "remote OST with nodsh" && return
1189 rm -f $DIR/$tdir/$tfile
1192 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1193 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||error "truncate $DIR/$tdir/$tfile failed"
1194 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1196 exhaust_all_precreations 0x215
1198 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1199 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1203 run_test 27q "append to truncated file with all OSTs full (should error) ==="
1206 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1207 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1208 remote_ost_nodsh && skip "remote OST with nodsh" && return
1211 rm -f $DIR/$tdir/$tfile
1212 exhaust_precreations 0 0x80000215
1214 $SETSTRIPE -i 0 -c 2 $DIR/$tdir/$tfile # && error
1218 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1220 test_27s() { # bug 10725
1222 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1223 local stripe_count=0
1224 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1225 $SETSTRIPE -S $stripe_size -c $stripe_count $DIR/$tdir &&
1226 error "stripe width >= 2^32 succeeded" || true
1229 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1231 test_27t() { # bug 10864
1236 $WLFS getstripe $tfile
1239 run_test 27t "check that utils parse path correctly"
1241 test_27u() { # bug 4900
1242 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1243 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1245 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1246 do_facet $SINGLEMDS lctl set_param fail_loc=0x139
1248 createmany -o $DIR/$tdir/t- 1000
1249 do_facet $SINGLEMDS lctl set_param fail_loc=0
1251 TLOG=$DIR/$tfile.getstripe
1252 $GETSTRIPE $DIR/$tdir > $TLOG
1253 OBJS=`awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj;}' $TLOG`
1254 unlinkmany $DIR/$tdir/t- 1000
1255 [ $OBJS -gt 0 ] && \
1256 error "$OBJS objects created on OST-0. See $TLOG" || pass
1258 run_test 27u "skip object creation on OSC w/o objects =========="
1260 test_27v() { # bug 4900
1261 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1262 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1263 remote_ost_nodsh && skip "remote OST with nodsh" && return
1265 exhaust_all_precreations 0x215
1269 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1271 touch $DIR/$tdir/$tfile
1272 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1274 for (( i=1; i < OSTCOUNT; i++ )); do
1275 do_facet ost$i lctl set_param fail_loc=0x705
1277 local START=`date +%s`
1278 createmany -o $DIR/$tdir/$tfile 32
1280 local FINISH=`date +%s`
1281 local TIMEOUT=`lctl get_param -n timeout`
1282 local PROCESS=$((FINISH - START))
1283 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1284 error "$FINISH - $START >= $TIMEOUT / 2"
1285 sleep $((TIMEOUT / 2 - PROCESS))
1288 run_test 27v "skip object creation on slow OST ================="
1290 test_27w() { # bug 10997
1291 mkdir -p $DIR/$tdir || error "mkdir failed"
1292 $SETSTRIPE -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1293 [ $($GETSTRIPE -S $DIR/$tdir/f0) -ne 65536 ] &&
1294 error "stripe size $size != 65536" || true
1295 [ $($GETSTRIPE -d $DIR/$tdir | grep -c "stripe_count") -ne 1 ] &&
1296 error "$GETSTRIPE -d $DIR/$tdir failed" || true
1298 run_test 27w "check $SETSTRIPE -S option"
1301 [ "$OSTCOUNT" -lt "2" ] &&
1302 skip_env "skipping multiple stripe count/offset test" && return
1304 mkdir -p $DIR/$tdir || error "mkdir failed"
1305 for i in $(seq 1 $OSTCOUNT); do
1307 $SETSTRIPE -c $i -i $offset $DIR/$tdir/f$i ||
1308 error "setstripe -c $i -i $offset failed"
1309 count=$($GETSTRIPE -c $DIR/$tdir/f$i)
1310 index=$($GETSTRIPE -i $DIR/$tdir/f$i)
1311 [ $count -ne $i ] && error "stripe count $count != $i" || true
1312 [ $index -ne $offset ] &&
1313 error "stripe offset $index != $offset" || true
1316 run_test 27wa "check $SETSTRIPE -c -i options"
1319 remote_ost_nodsh && skip "remote OST with nodsh" && return
1320 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs" && return
1321 OFFSET=$(($OSTCOUNT - 1))
1323 local OST=$(ostname_from_index $OSTIDX)
1326 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe per file
1327 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1329 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1330 for i in `seq 0 $OFFSET`; do
1331 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}' | grep -w "$OSTIDX"` ] &&
1332 error "OST0 was degraded but new created file still use it"
1334 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1336 run_test 27x "create files while OST0 is degraded"
1339 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1340 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1341 remote_ost_nodsh && skip "remote OST with nodsh" && return
1343 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1344 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1345 osc.$mdtosc.prealloc_last_id)
1346 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1347 osc.$mdtosc.prealloc_next_id)
1348 local fcount=$((last_id - next_id))
1349 [ $fcount -eq 0 ] && skip "not enough space on OST0" && return
1350 [ $fcount -gt $OSTCOUNT ] && fcount=$OSTCOUNT
1352 MDS_OSCS=`do_facet $SINGLEMDS lctl dl | awk '/[oO][sS][cC].*md[ts]/ { print $4 }'`
1353 OFFSET=$(($OSTCOUNT-1))
1355 for OSC in $MDS_OSCS; do
1356 if [ $OST == -1 ]; then {
1357 OST=`osc_to_ost $OSC`
1359 echo $OSC "is Deactivate:"
1360 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1364 OSTIDX=$(index_from_ostuuid $OST)
1366 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1368 do_facet ost$((OSTIDX+1)) lctl set_param -n obdfilter.$OST.degraded 1
1370 createmany -o $DIR/$tdir/$tfile $fcount
1371 do_facet ost$((OSTIDX+1)) lctl set_param -n obdfilter.$OST.degraded 0
1373 for i in `seq 0 $OFFSET`; do
1374 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "$OSTIDX"` ] || \
1375 error "files created on deactivated OSTs instead of degraded OST"
1377 for OSC in $MDS_OSCS; do
1378 [ `osc_to_ost $OSC` != $OST ] && {
1379 echo $OSC "is activate"
1380 do_facet $SINGLEMDS lctl --device %$OSC activate
1384 run_test 27y "create files while OST0 is degraded and the rest inactive"
1390 lmm_count=$($GETSTRIPE -c $1)
1391 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1392 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1394 local old_ifs="$IFS"
1396 fid=($($LFS path2fid $1))
1399 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1400 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1402 # compare lmm_seq and lu_fid->f_seq
1403 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1404 # compare lmm_object_id and lu_fid->oid
1405 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1407 # check the trusted.fid attribute of the OST objects of the file
1408 local have_obdidx=false
1410 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1411 # skip lines up to and including "obdidx"
1412 [ -z "$obdidx" ] && break
1413 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1414 $have_obdidx || continue
1416 local ost=$((obdidx + 1))
1417 local dev=$(ostdevname $ost)
1419 if [ $(facet_fstype ost$ost) != ldiskfs ]; then
1420 echo "Currently only works with ldiskfs-based OSTs"
1424 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1426 #don't unmount/remount the OSTs if we don't need to do that
1427 #local dir=$(facet_mntpt ost$ost)
1429 #do_facet ost$dev mount -t $FSTYPE $dev $dir $OST_MOUNT_OPTS ||
1430 # { error "mounting $dev as $FSTYPE failed"; return 3; }
1431 #local obj_file=$(do_facet ost$ost find $dir/O/$seq -name $oid)
1432 #local ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID $obj_file)
1434 local obj_file="O/$seq/d$((oid %32))/$oid"
1435 local ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
1436 $dev 2>/dev/null" | grep "parent=")
1438 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
1440 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
1442 #do_facet ost$ost umount -d $dir
1443 #start ost$ost $dev $OST_MOUNT_OPTS
1445 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
1446 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
1447 local ff_parent=$(echo $ff|sed -e 's/.*parent=.//')
1448 local ff_pseq=$(echo $ff_parent | cut -d: -f1)
1449 local ff_poid=$(echo $ff_parent | cut -d: -f2)
1450 local ff_pstripe=$(echo $ff_parent | sed -e 's/.*stripe=//')
1452 # compare lmm_seq and filter_fid->ff_parent.f_seq
1453 [ $ff_pseq = $lmm_seq ] ||
1454 error "FF parent SEQ $ff_pseq != $lmm_seq"
1455 # compare lmm_object_id and filter_fid->ff_parent.f_oid
1456 [ $ff_poid = $lmm_oid ] ||
1457 error "FF parent OID $ff_poid != $lmm_oid"
1458 [ $ff_pstripe = $stripe_nr ] ||
1459 error "FF stripe $ff_pstripe != $stripe_nr"
1461 stripe_nr=$((stripe_nr + 1))
1466 remote_ost_nodsh && skip "remote OST with nodsh" && return
1469 $SETSTRIPE -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
1470 { error "setstripe -c -1 failed"; return 1; }
1471 # We need to send a write to every object to get parent FID info set.
1472 # This _should_ also work for setattr, but does not currently.
1473 # touch $DIR/$tdir/$tfile-1 ||
1474 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
1475 { error "dd $tfile-1 failed"; return 2; }
1476 $SETSTRIPE -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
1477 { error "setstripe -c -1 failed"; return 3; }
1478 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
1479 { error "dd $tfile-2 failed"; return 4; }
1481 # make sure write RPCs have been sent to OSTs
1484 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
1485 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
1487 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
1489 test_27A() { # b=19102
1490 local restore_size=$($GETSTRIPE -S $MOUNT)
1491 local restore_count=$($GETSTRIPE -c $MOUNT)
1492 local restore_offset=$($GETSTRIPE -i $MOUNT)
1493 $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
1494 local default_size=$($GETSTRIPE -S $MOUNT)
1495 local default_count=$($GETSTRIPE -c $MOUNT)
1496 local default_offset=$($GETSTRIPE -i $MOUNT)
1497 local dsize=$((1024 * 1024))
1498 [ $default_size -eq $dsize ] ||
1499 error "stripe size $default_size != $dsize"
1500 [ $default_count -eq 1 ] || error "stripe count $default_count != 1"
1501 [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
1502 $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
1504 run_test 27A "check filesystem-wide default LOV EA values"
1506 # createtest also checks that device nodes are created and
1507 # then visible correctly (#2091)
1508 test_28() { # bug 2091
1510 $CREATETEST $DIR/d28/ct || error
1512 run_test 28 "create/mknod/mkdir with bad file types ============"
1515 cancel_lru_locks mdc
1521 declare -i LOCKCOUNTORIG=0
1522 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1523 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
1525 [ $LOCKCOUNTORIG -eq 0 ] && echo "No mdc lock count" && return 1
1527 declare -i LOCKUNUSEDCOUNTORIG=0
1528 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1529 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
1536 declare -i LOCKCOUNTCURRENT=0
1537 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1538 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
1541 declare -i LOCKUNUSEDCOUNTCURRENT=0
1542 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1543 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
1546 if [ "$LOCKCOUNTCURRENT" -gt "$LOCKCOUNTORIG" ]; then
1547 lctl set_param -n ldlm.dump_namespaces ""
1548 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
1549 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1550 log "dumped log to $TMP/test_29.dk (bug 5793)"
1553 if [ "$LOCKUNUSEDCOUNTCURRENT" -gt "$LOCKUNUSEDCOUNTORIG" ]; then
1554 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
1555 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1556 log "dumped log to $TMP/test_29.dk (bug 5793)"
1560 run_test 29 "IT_GETATTR regression ============================"
1562 test_30a() { # was test_30
1563 cp `which ls` $DIR || cp /bin/ls $DIR
1567 run_test 30a "execute binary from Lustre (execve) =============="
1570 cp `which ls` $DIR || cp /bin/ls $DIR
1572 $RUNAS $DIR/ls / || error
1575 run_test 30b "execute binary from Lustre as non-root ==========="
1577 test_30c() { # b=22376
1578 cp `which ls` $DIR || cp /bin/ls $DIR
1580 cancel_lru_locks mdc
1581 cancel_lru_locks osc
1582 $RUNAS $DIR/ls / || error
1585 run_test 30c "execute binary from Lustre without read perms ===="
1588 $OPENUNLINK $DIR/f31 $DIR/f31 || error
1589 $CHECKSTAT -a $DIR/f31 || error
1591 run_test 31a "open-unlink file =================================="
1594 touch $DIR/f31 || error
1595 ln $DIR/f31 $DIR/f31b || error
1596 $MULTIOP $DIR/f31b Ouc || error
1597 $CHECKSTAT -t file $DIR/f31 || error
1599 run_test 31b "unlink file with multiple links while open ======="
1602 touch $DIR/f31 || error
1603 ln $DIR/f31 $DIR/f31c || error
1604 multiop_bg_pause $DIR/f31 O_uc || return 1
1606 $MULTIOP $DIR/f31c Ouc
1607 kill -USR1 $MULTIPID
1610 run_test 31c "open-unlink file with multiple links ============="
1613 opendirunlink $DIR/d31d $DIR/d31d || error
1614 $CHECKSTAT -a $DIR/d31d || error
1616 run_test 31d "remove of open directory ========================="
1618 test_31e() { # bug 2904
1619 check_kernel_version 34 || return 0
1620 openfilleddirunlink $DIR/d31e || error
1622 run_test 31e "remove of open non-empty directory ==============="
1624 test_31f() { # bug 4554
1627 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
1628 cp /etc/hosts $DIR/d31f
1630 $GETSTRIPE $DIR/d31f/hosts
1631 multiop_bg_pause $DIR/d31f D_c || return 1
1634 rm -rv $DIR/d31f || error "first of $DIR/d31f"
1636 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
1637 cp /etc/hosts $DIR/d31f
1639 $GETSTRIPE $DIR/d31f/hosts
1640 multiop_bg_pause $DIR/d31f D_c || return 1
1643 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
1644 wait $MULTIPID || error "first opendir $MULTIPID failed"
1648 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
1649 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
1652 run_test 31f "remove of open directory with open-unlink file ==="
1655 echo "-- cross directory link --"
1656 mkdir $DIR/d31g{a,b}
1658 ln $DIR/d31ga/f $DIR/d31gb/g
1659 $CHECKSTAT -t file $DIR/d31ga/f || error "source"
1660 [ `stat -c%h $DIR/d31ga/f` == '2' ] || error "source nlink"
1661 $CHECKSTAT -t file $DIR/d31gb/g || error "target"
1662 [ `stat -c%h $DIR/d31gb/g` == '2' ] || error "target nlink"
1664 run_test 31g "cross directory link==============="
1667 echo "-- cross directory link --"
1671 ln $DIR/d31h/f $DIR/d31h/dir/g
1672 $CHECKSTAT -t file $DIR/d31h/f || error "source"
1673 [ `stat -c%h $DIR/d31h/f` == '2' ] || error "source nlink"
1674 $CHECKSTAT -t file $DIR/d31h/dir/g || error "target"
1675 [ `stat -c%h $DIR/d31h/dir/g` == '2' ] || error "target nlink"
1677 run_test 31h "cross directory link under child==============="
1680 echo "-- cross directory link --"
1683 touch $DIR/d31i/dir/f
1684 ln $DIR/d31i/dir/f $DIR/d31i/g
1685 $CHECKSTAT -t file $DIR/d31i/dir/f || error "source"
1686 [ `stat -c%h $DIR/d31i/dir/f` == '2' ] || error "source nlink"
1687 $CHECKSTAT -t file $DIR/d31i/g || error "target"
1688 [ `stat -c%h $DIR/d31i/g` == '2' ] || error "target nlink"
1690 run_test 31i "cross directory link under parent==============="
1695 mkdir $DIR/d31j/dir1
1696 ln $DIR/d31j/dir1 $DIR/d31j/dir2 && error "ln for dir"
1697 link $DIR/d31j/dir1 $DIR/d31j/dir3 && error "link for dir"
1698 mlink $DIR/d31j/dir1 $DIR/d31j/dir4 && error "mlink for dir"
1699 mlink $DIR/d31j/dir1 $DIR/d31j/dir1 && error "mlink to the same dir"
1702 run_test 31j "link for directory==============="
1708 touch $DIR/d31k/exist
1709 mlink $DIR/d31k/s $DIR/d31k/t || error "mlink"
1710 mlink $DIR/d31k/s $DIR/d31k/exist && error "mlink to exist file"
1711 mlink $DIR/d31k/s $DIR/d31k/s && error "mlink to the same file"
1712 mlink $DIR/d31k/s $DIR/d31k && error "mlink to parent dir"
1713 mlink $DIR/d31k $DIR/d31k/s && error "mlink parent dir to target"
1714 mlink $DIR/d31k/not-exist $DIR/d31k/foo && error "mlink non-existing to new"
1715 mlink $DIR/d31k/not-exist $DIR/d31k/s && error "mlink non-existing to exist"
1718 run_test 31k "link to file: the same, non-existing, dir==============="
1724 touch $DIR/d31m2/exist
1725 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
1726 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
1727 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
1728 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
1729 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
1730 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
1733 run_test 31m "link to file: the same, non-existing, dir==============="
1736 echo "== more mountpoints and symlinks ================="
1737 [ -e $DIR/d32a ] && rm -fr $DIR/d32a
1738 mkdir -p $DIR/d32a/ext2-mountpoint
1739 mount -t ext2 -o loop $EXT2_DEV $DIR/d32a/ext2-mountpoint || error
1740 $CHECKSTAT -t dir $DIR/d32a/ext2-mountpoint/.. || error
1741 $UMOUNT $DIR/d32a/ext2-mountpoint || error
1743 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
1746 [ -e $DIR/d32b ] && rm -fr $DIR/d32b
1747 mkdir -p $DIR/d32b/ext2-mountpoint
1748 mount -t ext2 -o loop $EXT2_DEV $DIR/d32b/ext2-mountpoint || error
1749 ls -al $DIR/d32b/ext2-mountpoint/.. || error
1750 $UMOUNT $DIR/d32b/ext2-mountpoint || error
1752 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
1755 [ -e $DIR/d32c ] && rm -fr $DIR/d32c
1756 mkdir -p $DIR/d32c/ext2-mountpoint
1757 mount -t ext2 -o loop $EXT2_DEV $DIR/d32c/ext2-mountpoint || error
1758 mkdir -p $DIR/d32c/d2/test_dir
1759 $CHECKSTAT -t dir $DIR/d32c/ext2-mountpoint/../d2/test_dir || error
1760 $UMOUNT $DIR/d32c/ext2-mountpoint || error
1762 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
1765 [ -e $DIR/d32d ] && rm -fr $DIR/d32d
1766 mkdir -p $DIR/d32d/ext2-mountpoint
1767 mount -t ext2 -o loop $EXT2_DEV $DIR/d32d/ext2-mountpoint || error
1768 mkdir -p $DIR/d32d/d2/test_dir
1769 ls -al $DIR/d32d/ext2-mountpoint/../d2/test_dir || error
1770 $UMOUNT $DIR/d32d/ext2-mountpoint || error
1772 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
1775 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
1776 mkdir -p $DIR/d32e/tmp
1777 TMP_DIR=$DIR/d32e/tmp
1778 ln -s $DIR/d32e $TMP_DIR/symlink11
1779 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1780 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
1781 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
1783 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
1786 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
1787 mkdir -p $DIR/d32f/tmp
1788 TMP_DIR=$DIR/d32f/tmp
1789 ln -s $DIR/d32f $TMP_DIR/symlink11
1790 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1791 ls $DIR/d32f/tmp/symlink11 || error
1792 ls $DIR/d32f/symlink01 || error
1794 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
1797 TMP_DIR=$DIR/$tdir/tmp
1798 mkdir -p $TMP_DIR $DIR/${tdir}2
1799 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
1800 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1801 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
1802 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
1803 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
1804 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
1806 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
1809 rm -fr $DIR/$tdir $DIR/${tdir}2
1810 TMP_DIR=$DIR/$tdir/tmp
1811 mkdir -p $TMP_DIR $DIR/${tdir}2
1812 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
1813 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1814 ls $TMP_DIR/symlink12 || error
1815 ls $DIR/$tdir/symlink02 || error
1817 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
1820 [ -e $DIR/d32i ] && rm -fr $DIR/d32i
1821 mkdir -p $DIR/d32i/ext2-mountpoint
1822 mount -t ext2 -o loop $EXT2_DEV $DIR/d32i/ext2-mountpoint || error
1823 touch $DIR/d32i/test_file
1824 $CHECKSTAT -t file $DIR/d32i/ext2-mountpoint/../test_file || error
1825 $UMOUNT $DIR/d32i/ext2-mountpoint || error
1827 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
1830 [ -e $DIR/d32j ] && rm -fr $DIR/d32j
1831 mkdir -p $DIR/d32j/ext2-mountpoint
1832 mount -t ext2 -o loop $EXT2_DEV $DIR/d32j/ext2-mountpoint || error
1833 touch $DIR/d32j/test_file
1834 cat $DIR/d32j/ext2-mountpoint/../test_file || error
1835 $UMOUNT $DIR/d32j/ext2-mountpoint || error
1837 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
1841 mkdir -p $DIR/d32k/ext2-mountpoint
1842 mount -t ext2 -o loop $EXT2_DEV $DIR/d32k/ext2-mountpoint
1843 mkdir -p $DIR/d32k/d2
1844 touch $DIR/d32k/d2/test_file || error
1845 $CHECKSTAT -t file $DIR/d32k/ext2-mountpoint/../d2/test_file || error
1846 $UMOUNT $DIR/d32k/ext2-mountpoint || error
1848 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
1852 mkdir -p $DIR/d32l/ext2-mountpoint
1853 mount -t ext2 -o loop $EXT2_DEV $DIR/d32l/ext2-mountpoint || error
1854 mkdir -p $DIR/d32l/d2
1855 touch $DIR/d32l/d2/test_file
1856 cat $DIR/d32l/ext2-mountpoint/../d2/test_file || error
1857 $UMOUNT $DIR/d32l/ext2-mountpoint || error
1859 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
1863 mkdir -p $DIR/d32m/tmp
1864 TMP_DIR=$DIR/d32m/tmp
1865 ln -s $DIR $TMP_DIR/symlink11
1866 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1867 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
1868 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
1870 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
1874 mkdir -p $DIR/d32n/tmp
1875 TMP_DIR=$DIR/d32n/tmp
1876 ln -s $DIR $TMP_DIR/symlink11
1877 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1878 ls -l $DIR/d32n/tmp/symlink11 || error
1879 ls -l $DIR/d32n/symlink01 || error
1881 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
1884 rm -fr $DIR/d32o $DIR/$tfile
1886 mkdir -p $DIR/d32o/tmp
1887 TMP_DIR=$DIR/d32o/tmp
1888 ln -s $DIR/$tfile $TMP_DIR/symlink12
1889 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1890 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
1891 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
1892 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
1893 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
1895 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
1905 mkdir -p $DIR/d32p/tmp
1907 TMP_DIR=$DIR/d32p/tmp
1909 ln -s $DIR/$tfile $TMP_DIR/symlink12
1911 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1913 cat $DIR/d32p/tmp/symlink12 || error
1915 cat $DIR/d32p/symlink02 || error
1918 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
1921 [ -e $DIR/d32q ] && rm -fr $DIR/d32q
1923 touch $DIR/d32q/under_the_mount
1924 mount -t ext2 -o loop $EXT2_DEV $DIR/d32q
1925 ls $DIR/d32q/under_the_mount && error || true
1926 $UMOUNT $DIR/d32q || error
1928 run_test 32q "stat follows mountpoints in Lustre (should return error)"
1931 [ -e $DIR/d32r ] && rm -fr $DIR/d32r
1933 touch $DIR/d32r/under_the_mount
1934 mount -t ext2 -o loop $EXT2_DEV $DIR/d32r
1935 ls $DIR/d32r | grep -q under_the_mount && error || true
1936 $UMOUNT $DIR/d32r || error
1938 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
1943 chmod 444 $DIR/$tfile
1944 chown $RUNAS_ID $DIR/$tfile
1946 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
1949 run_test 33 "write file with mode 444 (should return error) ===="
1954 chown $RUNAS_ID $DIR/d33
1955 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
1956 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
1957 error "open RDWR" || true
1959 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
1964 chown $RUNAS_ID $DIR/d33
1965 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33 && error "create" || true
1967 run_test 33b "test open file with malformed flags (No panic and return error)"
1975 remote_ost_nodsh && skip "remote OST with nodsh" && return
1979 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
1982 for ostnum in $(seq $OSTCOUNT); do
1983 # test-framework's OST numbering is one-based, while Lustre's
1985 ostname=$(printf "$FSNAME-OST%.4d" $((ostnum - 1)))
1986 # Parsing llobdstat's output sucks; we could grep the /proc
1987 # path, but that's likely to not be as portable as using the
1988 # llobdstat utility. So we parse lctl output instead.
1989 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
1990 obdfilter/$ostname/stats |
1991 awk '/^write_bytes/ {print $7}' )
1992 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
1993 if (( ${write_bytes:-0} > 0 ))
2000 $all_zeros || return 0
2003 echo foo > $DIR/d33/bar
2007 # Total up write_bytes after writing. We'd better find non-zeros.
2008 for ostnum in $(seq $OSTCOUNT); do
2009 ostname=$(printf "$FSNAME-OST%.4d" $((ostnum - 1)))
2010 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2011 obdfilter/$ostname/stats |
2012 awk '/^write_bytes/ {print $7}' )
2013 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2014 if (( ${write_bytes:-0} > 0 ))
2023 for ostnum in $(seq $OSTCOUNT); do
2024 ostname=$(printf "$FSNAME-OST%.4d" $((ostnum - 1)))
2025 echo "Check that write_bytes is present in obdfilter/*/stats:"
2026 do_facet ost$ostnum lctl get_param -n \
2027 obdfilter/$ostname/stats
2029 error "OST not keeping write_bytes stats (b22312)"
2032 run_test 33c "test llobdstat and write_bytes"
2034 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
2037 $MCREATE $DIR/f34 || error
2038 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2039 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
2040 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2041 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2043 run_test 34a "truncate file that has not been opened ==========="
2046 [ ! -f $DIR/f34 ] && test_34a
2047 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2048 $OPENFILE -f O_RDONLY $DIR/f34
2049 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2050 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2052 run_test 34b "O_RDONLY opening file doesn't create objects ====="
2055 [ ! -f $DIR/f34 ] && test_34a
2056 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2057 $OPENFILE -f O_RDWR $DIR/f34
2058 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2059 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2061 run_test 34c "O_RDWR opening file-with-size works =============="
2064 [ ! -f $DIR/f34 ] && test_34a
2065 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2066 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2069 run_test 34d "write to sparse file ============================="
2073 $MCREATE $DIR/f34e || error
2074 $TRUNCATE $DIR/f34e 1000 || error
2075 $CHECKSTAT -s 1000 $DIR/f34e || error
2076 $OPENFILE -f O_RDWR $DIR/f34e
2077 $CHECKSTAT -s 1000 $DIR/f34e || error
2079 run_test 34e "create objects, some with size and some without =="
2081 test_34f() { # bug 6242, 6243
2084 $MCREATE $DIR/f34f || error
2085 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
2086 dd if=$DIR/f34f of=$TMP/f34f
2087 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
2088 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
2089 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
2090 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
2091 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
2093 run_test 34f "read from a file with no objects until EOF ======="
2096 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
2097 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
2098 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
2099 cancel_lru_locks osc
2100 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
2101 error "wrong size after lock cancel"
2103 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
2104 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2105 error "expanding truncate failed"
2106 cancel_lru_locks osc
2107 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2108 error "wrong expanded size after lock cancel"
2110 run_test 34g "truncate long file ==============================="
2116 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
2117 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
2121 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
2122 error "Multiop blocked on ftruncate, pid=$MULTIPID"
2126 local nsz=`stat -c %s $DIR/$tfile`
2127 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
2129 run_test 34h "ftruncate file under grouplock should not block"
2132 cp /bin/sh $DIR/f35a
2134 chown $RUNAS_ID $DIR/f35a
2135 $RUNAS $DIR/f35a && error || true
2138 run_test 35a "exec file with mode 444 (should return and not leak) ====="
2142 utime $DIR/f36 || error
2144 run_test 36a "MDS utime check (mknod, utime) ==================="
2148 utime $DIR/f36 || error
2150 run_test 36b "OST utime check (open, utime) ===================="
2155 chown $RUNAS_ID $DIR/d36
2156 $RUNAS utime $DIR/d36/f36 || error
2158 run_test 36c "non-root MDS utime check (mknod, utime) =========="
2161 [ ! -d $DIR/d36 ] && test_36c
2162 echo "" > $DIR/d36/f36
2163 $RUNAS utime $DIR/d36/f36 || error
2165 run_test 36d "non-root OST utime check (open, utime) ==========="
2168 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
2170 touch $DIR/$tdir/$tfile
2171 $RUNAS utime $DIR/$tdir/$tfile && \
2172 error "utime worked, expected failure" || true
2174 run_test 36e "utime on non-owned file (should return error) ===="
2178 local LANG_SAVE=$LANG
2179 local LC_LANG_SAVE=$LC_LANG
2180 export LANG=C LC_LANG=C # for date language
2182 DATESTR="Dec 20 2000"
2184 lctl set_param fail_loc=$fl
2186 cp /etc/hosts $DIR/$tdir/$tfile
2187 sync & # write RPC generated with "current" inode timestamp, but delayed
2189 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
2190 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
2191 cancel_lru_locks osc
2192 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
2194 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
2195 echo "BEFORE: $LS_BEFORE" && \
2196 echo "AFTER : $LS_AFTER" && \
2197 echo "WANT : $DATESTR" && \
2198 error "$DIR/$tdir/$tfile timestamps changed" || true
2200 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
2204 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2205 subr_36fh "0x80000214"
2207 run_test 36f "utime on file racing with OST BRW write =========="
2210 remote_ost_nodsh && skip "remote OST with nodsh" && return
2216 fmd_max_age=$(do_facet ost1 \
2217 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
2220 fmd_before=$(do_facet ost1 \
2221 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2222 touch $DIR/$tdir/$tfile
2223 sleep $((fmd_max_age + 12))
2224 fmd_after=$(do_facet ost1 \
2225 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2227 echo "fmd_before: $fmd_before"
2228 echo "fmd_after: $fmd_after"
2229 [ "$fmd_after" -gt "$fmd_before" ] && \
2230 echo "AFTER: $fmd_after > BEFORE: $fmd_before" && \
2231 error "fmd didn't expire after ping" || true
2233 run_test 36g "filter mod data cache expiry ====================="
2236 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
2237 subr_36fh "0x80000227"
2239 run_test 36h "utime on file racing with OST BRW write =========="
2243 echo f > $DIR/$tdir/fbugfile
2244 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2245 ls $DIR/$tdir | grep "\<fbugfile\>" && error
2246 $UMOUNT $DIR/$tdir || error
2247 rm -f $DIR/$tdir/fbugfile || error
2249 run_test 37 "ls a mounted file system to check old content ====="
2252 local file=$DIR/$tfile
2254 openfile -f O_DIRECTORY $file
2257 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
2258 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
2260 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
2264 touch $DIR/${tfile}2
2265 # ls -l $DIR/$tfile $DIR/${tfile}2
2266 # ls -lu $DIR/$tfile $DIR/${tfile}2
2267 # ls -lc $DIR/$tfile $DIR/${tfile}2
2269 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
2270 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
2272 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
2274 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
2276 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
2277 error "O_TRUNC didn't change timestamps"
2280 run_test 39 "mtime changed on create ==========================="
2284 cp -p /etc/passwd $DIR/$tdir/fopen
2285 cp -p /etc/passwd $DIR/$tdir/flink
2286 cp -p /etc/passwd $DIR/$tdir/funlink
2287 cp -p /etc/passwd $DIR/$tdir/frename
2288 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
2291 echo "aaaaaa" >> $DIR/$tdir/fopen
2292 echo "aaaaaa" >> $DIR/$tdir/flink
2293 echo "aaaaaa" >> $DIR/$tdir/funlink
2294 echo "aaaaaa" >> $DIR/$tdir/frename
2296 local open_new=`stat -c %Y $DIR/$tdir/fopen`
2297 local link_new=`stat -c %Y $DIR/$tdir/flink`
2298 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
2299 local rename_new=`stat -c %Y $DIR/$tdir/frename`
2301 cat $DIR/$tdir/fopen > /dev/null
2302 ln $DIR/$tdir/flink $DIR/$tdir/flink2
2303 rm -f $DIR/$tdir/funlink2
2304 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
2306 for (( i=0; i < 2; i++ )) ; do
2307 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
2308 local link_new2=`stat -c %Y $DIR/$tdir/flink`
2309 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
2310 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
2312 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
2313 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
2314 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
2315 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
2317 cancel_lru_locks osc
2318 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2321 run_test 39b "mtime change on open, link, unlink, rename ======"
2323 # this should be set to past
2324 TEST_39_MTIME=`date -d "1 year ago" +%s`
2330 local mtime0=`stat -c %Y $DIR1/$tfile`
2332 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2333 local mtime1=`stat -c %Y $DIR1/$tfile`
2334 [ "$mtime1" = $TEST_39_MTIME ] || \
2335 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
2338 echo hello >> $DIR1/$tfile
2340 local mtime2=`stat -c %Y $DIR1/$tfile`
2341 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
2342 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
2344 mv $DIR1/$tfile $DIR1/$tfile-1
2346 for (( i=0; i < 2; i++ )) ; do
2347 local mtime3=`stat -c %Y $DIR1/$tfile-1`
2348 [ "$mtime2" = "$mtime3" ] || \
2349 error "mtime ($mtime2) changed (to $mtime3) on rename"
2351 cancel_lru_locks osc
2352 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2355 run_test 39c "mtime change on rename ==========================="
2361 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2363 for (( i=0; i < 2; i++ )) ; do
2364 local mtime=`stat -c %Y $DIR1/$tfile`
2365 [ $mtime = $TEST_39_MTIME ] || \
2366 error "mtime($mtime) is not set to $TEST_39_MTIME"
2368 cancel_lru_locks osc
2369 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2372 run_test 39d "create, utime, stat =============================="
2377 local mtime1=`stat -c %Y $DIR1/$tfile`
2379 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2381 for (( i=0; i < 2; i++ )) ; do
2382 local mtime2=`stat -c %Y $DIR1/$tfile`
2383 [ $mtime2 = $TEST_39_MTIME ] || \
2384 error "mtime($mtime2) is not set to $TEST_39_MTIME"
2386 cancel_lru_locks osc
2387 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2390 run_test 39e "create, stat, utime, stat ========================"
2395 mtime1=`stat -c %Y $DIR1/$tfile`
2398 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2400 for (( i=0; i < 2; i++ )) ; do
2401 local mtime2=`stat -c %Y $DIR1/$tfile`
2402 [ $mtime2 = $TEST_39_MTIME ] || \
2403 error "mtime($mtime2) is not set to $TEST_39_MTIME"
2405 cancel_lru_locks osc
2406 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2409 run_test 39f "create, stat, sleep, utime, stat ================="
2413 echo hello >> $DIR1/$tfile
2414 local mtime1=`stat -c %Y $DIR1/$tfile`
2417 chmod o+r $DIR1/$tfile
2419 for (( i=0; i < 2; i++ )) ; do
2420 local mtime2=`stat -c %Y $DIR1/$tfile`
2421 [ "$mtime1" = "$mtime2" ] || \
2422 error "lost mtime: $mtime2, should be $mtime1"
2424 cancel_lru_locks osc
2425 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2428 run_test 39g "write, chmod, stat ==============================="
2436 echo hello >> $DIR1/$tfile
2437 local mtime1=`stat -c %Y $DIR1/$tfile`
2439 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2441 if [ "$d1" != "$d2" ]; then
2442 echo "write and touch not within one second"
2444 for (( i=0; i < 2; i++ )) ; do
2445 local mtime2=`stat -c %Y $DIR1/$tfile`
2446 [ "$mtime2" = $TEST_39_MTIME ] || \
2447 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
2449 cancel_lru_locks osc
2450 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2454 run_test 39h "write, utime within one second, stat ============="
2460 echo hello >> $DIR1/$tfile
2461 local mtime1=`stat -c %Y $DIR1/$tfile`
2463 mv $DIR1/$tfile $DIR1/$tfile-1
2465 for (( i=0; i < 2; i++ )) ; do
2466 local mtime2=`stat -c %Y $DIR1/$tfile-1`
2468 [ "$mtime1" = "$mtime2" ] || \
2469 error "lost mtime: $mtime2, should be $mtime1"
2471 cancel_lru_locks osc
2472 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2475 run_test 39i "write, rename, stat =============================="
2478 start_full_debug_logging
2482 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
2483 lctl set_param fail_loc=0x80000412
2484 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
2485 error "multiop failed"
2487 local mtime1=`stat -c %Y $DIR1/$tfile`
2489 mv $DIR1/$tfile $DIR1/$tfile-1
2491 kill -USR1 $multipid
2492 wait $multipid || error "multiop close failed"
2494 for (( i=0; i < 2; i++ )) ; do
2495 local mtime2=`stat -c %Y $DIR1/$tfile-1`
2496 [ "$mtime1" = "$mtime2" ] ||
2497 error "mtime is lost on close: $mtime2, " \
2500 cancel_lru_locks osc
2501 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2503 lctl set_param fail_loc=0
2504 stop_full_debug_logging
2506 run_test 39j "write, rename, close, stat ======================="
2512 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
2514 local mtime1=`stat -c %Y $DIR1/$tfile`
2516 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2518 kill -USR1 $multipid
2519 wait $multipid || error "multiop close failed"
2521 for (( i=0; i < 2; i++ )) ; do
2522 local mtime2=`stat -c %Y $DIR1/$tfile`
2524 [ "$mtime2" = $TEST_39_MTIME ] || \
2525 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
2527 cancel_lru_locks osc
2528 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2531 run_test 39k "write, utime, close, stat ========================"
2533 # this should be set to future
2534 TEST_39_ATIME=`date -d "1 year" +%s`
2537 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2538 local atime_diff=$(do_facet $SINGLEMDS lctl get_param -n mdd.*.atime_diff)
2542 # test setting directory atime to future
2543 touch -a -d @$TEST_39_ATIME $DIR/$tdir
2544 local atime=$(stat -c %X $DIR/$tdir)
2545 [ "$atime" = $TEST_39_ATIME ] || \
2546 error "atime is not set to future: $atime, should be $TEST_39_ATIME"
2548 # test setting directory atime from future to now
2549 local d1=$(date +%s)
2551 local d2=$(date +%s)
2553 cancel_lru_locks mdc
2554 atime=$(stat -c %X $DIR/$tdir)
2555 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
2556 error "atime is not updated from future: $atime, should be $d1<atime<$d2"
2558 do_facet $SINGLEMDS lctl set_param -n mdd.*.atime_diff=2
2561 # test setting directory atime when now > dir atime + atime_diff
2565 cancel_lru_locks mdc
2566 atime=$(stat -c %X $DIR/$tdir)
2567 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
2568 error "atime is not updated : $atime, should be $d2"
2570 do_facet $SINGLEMDS lctl set_param -n mdd.*.atime_diff=60
2573 # test not setting directory atime when now < dir atime + atime_diff
2575 cancel_lru_locks mdc
2576 atime=$(stat -c %X $DIR/$tdir)
2577 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
2578 error "atime is updated to $atime, should remain $d1<atime<$d2"
2580 do_facet $SINGLEMDS lctl set_param -n mdd.*.atime_diff=$atime_diff
2582 run_test 39l "directory atime update ==========================="
2587 local far_past_mtime=$(date -d "May 29 1953" +%s)
2588 local far_past_atime=$(date -d "Dec 17 1903" +%s)
2590 touch -m -d @$far_past_mtime $DIR1/$tfile
2591 touch -a -d @$far_past_atime $DIR1/$tfile
2593 for (( i=0; i < 2; i++ )) ; do
2594 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
2595 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
2596 error "atime or mtime set incorrectly"
2598 cancel_lru_locks osc
2599 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2602 run_test 39m "test atime and mtime before 1970"
2605 dd if=/dev/zero of=$DIR/f40 bs=4096 count=1
2606 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/f40 && error
2607 $CHECKSTAT -t file -s 4096 $DIR/f40 || error
2609 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
2613 small_write $DIR/f41 18
2615 run_test 41 "test small file write + fstat ====================="
2617 count_ost_writes() {
2618 lctl get_param -n osc.*.stats |
2619 awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }'
2626 BG_DIRTY_RATIO_SAVE=10
2627 MAX_BG_DIRTY_RATIO=25
2631 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
2632 # dirty_ratio, dirty_background_ratio
2633 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
2634 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
2635 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
2636 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
2638 # if file not here, we are a 2.4 kernel
2639 kill -CONT `pidof kupdated`
2644 # setup the trap first, so someone cannot exit the test at the
2645 # exact wrong time and mess up a machine
2646 trap start_writeback EXIT
2647 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
2648 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
2649 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
2650 sysctl -w vm.dirty_writeback_centisecs=0
2651 sysctl -w vm.dirty_writeback_centisecs=0
2652 # save and increase /proc/sys/vm/dirty_ratio
2653 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
2654 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
2655 # save and increase /proc/sys/vm/dirty_background_ratio
2656 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
2657 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
2659 # if file not here, we are a 2.4 kernel
2660 kill -STOP `pidof kupdated`
2664 # ensure that all stripes have some grant before we test client-side cache
2666 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
2667 dd if=/dev/zero of=$i bs=4k count=1
2672 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
2673 # file truncation, and file removal.
2676 cancel_lru_locks osc
2678 sync; sleep 1; sync # just to be safe
2679 BEFOREWRITES=`count_ost_writes`
2680 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
2681 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
2682 AFTERWRITES=`count_ost_writes`
2683 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
2684 error "$BEFOREWRITES < $AFTERWRITES"
2687 run_test 42a "ensure that we don't flush on close =============="
2691 cancel_lru_locks osc
2694 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
2695 BEFOREWRITES=`count_ost_writes`
2696 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
2697 AFTERWRITES=`count_ost_writes`
2698 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
2699 error "$BEFOREWRITES < $AFTERWRITES on unlink"
2701 BEFOREWRITES=`count_ost_writes`
2702 sync || error "sync: $?"
2703 AFTERWRITES=`count_ost_writes`
2704 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
2705 error "$BEFOREWRITES < $AFTERWRITES on sync"
2707 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
2711 run_test 42b "test destroy of file with cached dirty data ======"
2713 # if these tests just want to test the effect of truncation,
2714 # they have to be very careful. consider:
2715 # - the first open gets a {0,EOF}PR lock
2716 # - the first write conflicts and gets a {0, count-1}PW
2717 # - the rest of the writes are under {count,EOF}PW
2718 # - the open for truncate tries to match a {0,EOF}PR
2719 # for the filesize and cancels the PWs.
2720 # any number of fixes (don't get {0,EOF} on open, match
2721 # composite locks, do smarter file size management) fix
2722 # this, but for now we want these tests to verify that
2723 # the cancellation with truncate intent works, so we
2724 # start the file with a full-file pw lock to match against
2725 # until the truncate.
2730 cancel_lru_locks osc
2732 # prime the file with 0,EOF PW to match
2736 # now the real test..
2737 dd if=/dev/zero of=$file bs=1024 count=100
2738 BEFOREWRITES=`count_ost_writes`
2739 $TRUNCATE $file $offset
2740 cancel_lru_locks osc
2741 AFTERWRITES=`count_ost_writes`
2747 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
2748 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
2751 run_test 42c "test partial truncate of file with cached dirty data"
2755 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
2756 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
2759 run_test 42d "test complete truncate of file with cached dirty data"
2761 test_42e() { # bug22074
2762 local TDIR=$DIR/${tdir}e
2763 local pagesz=$(page_size)
2764 local pages=16 # hardcoded 16 pages, don't change it.
2765 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
2766 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
2771 $SETSTRIPE -c 1 $TDIR
2772 createmany -o $TDIR/f $files
2774 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
2776 # we assume that with $OSTCOUNT files, at least one of them will
2777 # be allocated on OST0.
2778 warmup_files=$((OSTCOUNT * max_dirty_mb))
2779 createmany -o $TDIR/w $warmup_files
2781 # write a large amount of data into one file and sync, to get good
2782 # avail_grant number from OST.
2783 for ((i=0; i<$warmup_files; i++)); do
2784 idx=$($GETSTRIPE -i $TDIR/w$i)
2785 [ $idx -ne 0 ] && continue
2786 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
2789 [ $i -gt $warmup_files ] && error "OST0 is still cold"
2791 $LCTL get_param $proc_osc0/cur_dirty_bytes
2792 $LCTL get_param $proc_osc0/cur_grant_bytes
2794 # create as much dirty pages as we can while not to trigger the actual
2795 # RPCs directly. but depends on the env, VFS may trigger flush during this
2796 # period, hopefully we are good.
2797 for ((i=0; i<$warmup_files; i++)); do
2798 idx=$($GETSTRIPE -i $TDIR/w$i)
2799 [ $idx -ne 0 ] && continue
2800 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
2802 $LCTL get_param $proc_osc0/cur_dirty_bytes
2803 $LCTL get_param $proc_osc0/cur_grant_bytes
2805 # perform the real test
2806 $LCTL set_param $proc_osc0/rpc_stats 0
2807 for ((;i<$files; i++)); do
2808 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
2809 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
2812 $LCTL get_param $proc_osc0/rpc_stats
2815 local have_ppr=false
2816 $LCTL get_param $proc_osc0/rpc_stats |
2817 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
2818 # skip lines until we are at the RPC histogram data
2819 [ "$PPR" == "pages" ] && have_ppr=true && continue
2820 $have_ppr || continue
2822 # we only want the percent stat for < 16 pages
2823 [ $(echo $PPR | tr -d ':') -ge $pages ] && break
2825 percent=$((percent + WPCT))
2826 if [ $percent -gt 15 ]; then
2827 error "less than 16-pages write RPCs" \
2834 run_test 42e "verify sub-RPC writes are not done synchronously"
2838 cp -p /bin/ls $DIR/$tdir/$tfile
2839 $MULTIOP $DIR/$tdir/$tfile Ow_c &
2841 # give multiop a chance to open
2844 $DIR/$tdir/$tfile && error || true
2847 run_test 43 "execution of file opened for write should return -ETXTBSY"
2851 cp -p `which $MULTIOP` $DIR/d43/multiop || cp -p multiop $DIR/d43/multiop
2852 MULTIOP_PROG=$DIR/d43/multiop multiop_bg_pause $TMP/test43.junk O_c || return 1
2854 $MULTIOP $DIR/d43/multiop Oc && error "expected error, got success"
2855 kill -USR1 $MULTIOP_PID || return 2
2856 wait $MULTIOP_PID || return 3
2859 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
2863 cp -p `which $MULTIOP` $DIR/d43/multiop || cp -p multiop $DIR/d43/multiop
2864 MULTIOP_PROG=$DIR/d43/multiop multiop_bg_pause $TMP/test43.junk O_c || return 1
2866 $TRUNCATE $DIR/d43/multiop 0 && error "expected error, got success"
2867 kill -USR1 $MULTIOP_PID || return 2
2868 wait $MULTIOP_PID || return 3
2871 run_test 43b "truncate of file being executed should return -ETXTBSY"
2874 local testdir="$DIR/d43c"
2877 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
2878 ( cd $testdir && md5sum -c)
2880 run_test 43c "md5sum of copy into lustre========================"
2883 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
2884 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
2885 dd if=$DIR/f1 bs=4k count=1 > /dev/null
2887 run_test 44 "zero length read from a sparse stripe ============="
2890 local nstripe=`$LCTL lov_getconfig $DIR | grep default_stripe_count: | \
2892 [ -z "$nstripe" ] && skip "can't get stripe info" && return
2893 [ "$nstripe" -gt "$OSTCOUNT" ] && skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" && return
2894 local stride=`$LCTL lov_getconfig $DIR | grep default_stripe_size: | \
2896 if [ $nstripe -eq 0 -o $nstripe -eq -1 ] ; then
2897 nstripe=`$LCTL lov_getconfig $DIR | grep obd_count: | awk '{print $2}'`
2900 OFFSETS="0 $((stride/2)) $((stride-1))"
2901 for offset in $OFFSETS ; do
2902 for i in `seq 0 $((nstripe-1))`; do
2903 local GLOBALOFFSETS=""
2904 local size=$((((i + 2 * $nstripe )*$stride + $offset))) # Bytes
2905 local myfn=$DIR/d44a-$size
2906 echo "--------writing $myfn at $size"
2907 ll_sparseness_write $myfn $size || error "ll_sparseness_write"
2908 GLOBALOFFSETS="$GLOBALOFFSETS $size"
2909 ll_sparseness_verify $myfn $GLOBALOFFSETS \
2910 || error "ll_sparseness_verify $GLOBALOFFSETS"
2912 for j in `seq 0 $((nstripe-1))`; do
2913 size=$((((j + $nstripe )*$stride + $offset))) # Bytes
2914 ll_sparseness_write $myfn $size || error "ll_sparseness_write"
2915 GLOBALOFFSETS="$GLOBALOFFSETS $size"
2917 ll_sparseness_verify $myfn $GLOBALOFFSETS \
2918 || error "ll_sparseness_verify $GLOBALOFFSETS"
2923 run_test 44a "test sparse pwrite ==============================="
2927 for d in `lctl get_param -n osc.*.cur_dirty_bytes`; do
2933 before=`dirty_osc_total`
2934 echo executing "\"$*\""
2936 after=`dirty_osc_total`
2937 echo before $before, after $after
2941 # Obtain grants from OST if it supports it
2942 echo blah > ${f}_grant
2945 do_dirty_record "echo blah > $f"
2946 [ $before -eq $after ] && error "write wasn't cached"
2947 do_dirty_record "> $f"
2948 [ $before -gt $after ] || error "truncate didn't lower dirty count"
2949 do_dirty_record "echo blah > $f"
2950 [ $before -eq $after ] && error "write wasn't cached"
2951 do_dirty_record "sync"
2952 [ $before -gt $after ] || error "writeback didn't lower dirty count"
2953 do_dirty_record "echo blah > $f"
2954 [ $before -eq $after ] && error "write wasn't cached"
2955 do_dirty_record "cancel_lru_locks osc"
2956 [ $before -gt $after ] || error "lock cancellation didn't lower dirty count"
2959 run_test 45 "osc io page accounting ============================"
2961 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
2962 # test tickles a bug where re-dirtying a page was failing to be mapped to the
2963 # objects offset and an assert hit when an rpc was built with 1023's mapped
2964 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
2969 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
2971 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
2972 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
2976 run_test 46 "dirtying a previously written page ================"
2978 # test_47 is removed "Device nodes check" is moved to test_28
2980 test_48a() { # bug 2399
2981 check_kernel_version 34 || return 0
2984 mv $DIR/d48a $DIR/d48.new || error "move directory failed"
2985 mkdir $DIR/d48a || error "recreate directory failed"
2986 touch foo || error "'touch foo' failed after recreating cwd"
2987 mkdir bar || error "'mkdir foo' failed after recreating cwd"
2988 if check_kernel_version 44; then
2989 touch .foo || error "'touch .foo' failed after recreating cwd"
2990 mkdir .bar || error "'mkdir .foo' failed after recreating cwd"
2992 ls . > /dev/null || error "'ls .' failed after recreating cwd"
2993 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
2994 cd . || error "'cd .' failed after recreating cwd"
2995 mkdir . && error "'mkdir .' worked after recreating cwd"
2996 rmdir . && error "'rmdir .' worked after recreating cwd"
2997 ln -s . baz || error "'ln -s .' failed after recreating cwd"
2998 cd .. || error "'cd ..' failed after recreating cwd"
3000 run_test 48a "Access renamed working dir (should return errors)="
3002 test_48b() { # bug 2399
3003 check_kernel_version 34 || return 0
3006 rmdir $DIR/d48b || error "remove cwd $DIR/d48b failed"
3007 touch foo && error "'touch foo' worked after removing cwd"
3008 mkdir foo && error "'mkdir foo' worked after removing cwd"
3009 if check_kernel_version 44; then
3010 touch .foo && error "'touch .foo' worked after removing cwd"
3011 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
3013 ls . > /dev/null && error "'ls .' worked after removing cwd"
3014 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3015 is_patchless || ( cd . && error "'cd .' worked after removing cwd" )
3016 mkdir . && error "'mkdir .' worked after removing cwd"
3017 rmdir . && error "'rmdir .' worked after removing cwd"
3018 ln -s . foo && error "'ln -s .' worked after removing cwd"
3019 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
3021 run_test 48b "Access removed working dir (should return errors)="
3023 test_48c() { # bug 2350
3024 check_kernel_version 36 || return 0
3025 #lctl set_param debug=-1
3027 mkdir -p $DIR/d48c/dir
3029 $TRACE rmdir $DIR/d48c/dir || error "remove cwd $DIR/d48c/dir failed"
3030 $TRACE touch foo && error "'touch foo' worked after removing cwd"
3031 $TRACE mkdir foo && error "'mkdir foo' worked after removing cwd"
3032 if check_kernel_version 44; then
3033 touch .foo && error "'touch .foo' worked after removing cwd"
3034 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
3036 $TRACE ls . && error "'ls .' worked after removing cwd"
3037 $TRACE ls .. || error "'ls ..' failed after removing cwd"
3038 is_patchless || ( $TRACE cd . && error "'cd .' worked after removing cwd" )
3039 $TRACE mkdir . && error "'mkdir .' worked after removing cwd"
3040 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
3041 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
3042 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
3044 run_test 48c "Access removed working subdir (should return errors)"
3046 test_48d() { # bug 2350
3047 check_kernel_version 36 || return 0
3048 #lctl set_param debug=-1
3050 mkdir -p $DIR/d48d/dir
3052 $TRACE rmdir $DIR/d48d/dir || error "remove cwd $DIR/d48d/dir failed"
3053 $TRACE rmdir $DIR/d48d || error "remove parent $DIR/d48d failed"
3054 $TRACE touch foo && error "'touch foo' worked after removing parent"
3055 $TRACE mkdir foo && error "'mkdir foo' worked after removing parent"
3056 if check_kernel_version 44; then
3057 touch .foo && error "'touch .foo' worked after removing parent"
3058 mkdir .foo && error "'mkdir .foo' worked after removing parent"
3060 $TRACE ls . && error "'ls .' worked after removing parent"
3061 $TRACE ls .. && error "'ls ..' worked after removing parent"
3062 is_patchless || ( $TRACE cd . && error "'cd .' worked after recreate parent" )
3063 $TRACE mkdir . && error "'mkdir .' worked after removing parent"
3064 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
3065 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
3066 is_patchless || ( $TRACE cd .. && error "'cd ..' worked after removing parent" || true )
3068 run_test 48d "Access removed parent subdir (should return errors)"
3070 test_48e() { # bug 4134
3071 check_kernel_version 41 || return 0
3072 #lctl set_param debug=-1
3074 mkdir -p $DIR/d48e/dir
3076 $TRACE rmdir $DIR/d48e/dir || error "remove cwd $DIR/d48e/dir failed"
3077 $TRACE rmdir $DIR/d48e || error "remove parent $DIR/d48e failed"
3078 $TRACE touch $DIR/d48e || error "'touch $DIR/d48e' failed"
3079 $TRACE chmod +x $DIR/d48e || error "'chmod +x $DIR/d48e' failed"
3080 # On a buggy kernel addition of "touch foo" after cd .. will
3081 # produce kernel oops in lookup_hash_it
3082 touch ../foo && error "'cd ..' worked after recreate parent"
3084 $TRACE rm $DIR/d48e || error "rm '$DIR/d48e' failed"
3086 run_test 48e "Access to recreated parent subdir (should return errors)"
3088 test_49() { # LU-1030
3089 # get ost1 size - lustre-OST0000
3090 ost1_size=$(do_facet ost1 lfs df |grep ${ost1_svc} |awk '{print $4}')
3091 # write 800M at maximum
3092 [ $ost1_size -gt 819200 ] && ost1_size=819200
3094 lfs setstripe -c 1 -i 0 $DIR/$tfile
3095 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
3098 # change max_pages_per_rpc while writing the file
3099 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
3100 local orig_mppc=`$LCTL get_param -n $osc1_mppc`
3101 # loop until dd process exits
3102 while ps ax -opid | grep -wq $dd_pid; do
3103 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
3104 sleep $((RANDOM % 5 + 1))
3106 # restore original max_pages_per_rpc
3107 $LCTL set_param $osc1_mppc=$orig_mppc
3108 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
3110 run_test 49 "Change max_pages_per_rpc won't break osc extent"
3116 ls /proc/$$/cwd || error
3118 run_test 50 "special situations: /proc symlinks ==============="
3120 test_51a() { # was test_51
3121 # bug 1516 - create an empty entry right after ".." then split dir
3124 $MCREATE $DIR/d51/bar
3126 createmany -m $DIR/d51/longfile 201
3128 while [ `ls -sd $DIR/d51 | awk '{ print $1 }'` -eq 4 ]; do
3129 $MCREATE $DIR/d51/longfile$FNUM
3134 ls -l $DIR/d51 > /dev/null || error
3136 run_test 51a "special situations: split htree with empty entry =="
3138 export NUMTEST=70000
3140 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
3141 [ $NUMFREE -lt 21000 ] && \
3142 skip "not enough free inodes ($NUMFREE)" && \
3145 [ $NUMFREE -lt $NUMTEST ] && NUMTEST=$(($NUMFREE - 50))
3148 createmany -d $DIR/d51b/t- $NUMTEST
3150 run_test 51b "mkdir .../t-0 --- .../t-$NUMTEST ===================="
3152 test_51ba() { # LU-993
3153 local BASE=$DIR/d51b
3154 # unlink all but 100 subdirectories, then check it still works
3156 local DELETE=$((NUMTEST - LEFT))
3158 # continue on to run this test even if 51b didn't finish,
3159 # just to delete the many subdirectories created.
3160 ! [ -d "${BASE}/t-1" ] && skip "test_51b() not run" && return 0
3162 # for ldiskfs the nlink count should be 1, but this is OSD specific
3163 # and so this is listed for informational purposes only
3164 log "nlink before: $(stat -c %h $BASE)"
3165 unlinkmany -d $BASE/t- $DELETE ||
3166 error "unlink of first $DELETE subdirs failed"
3168 log "nlink between: $(stat -c %h $BASE)"
3169 local FOUND=$(ls -l ${BASE} | wc -l)
3170 FOUND=$((FOUND - 1)) # trim the first line of ls output
3171 [ $FOUND -ne $LEFT ] &&
3172 error "can't find subdirs: found only $FOUND/$LEFT"
3174 unlinkmany -d $BASE/t- $DELETE $LEFT ||
3175 error "unlink of second $LEFT subdirs failed"
3176 log "nlink after: $(stat -c %h $BASE)"
3178 run_test 51ba "rmdir .../t-0 --- .../t-$NUMTEST"
3181 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3183 local ndirs=${TEST51BB_NDIRS:-10}
3184 local nfiles=${TEST51BB_NFILES:-100}
3186 local numfree=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
3188 [ $numfree -lt $(( ndirs * nfiles)) ] && \
3189 nfiles=$(( numfree / ndirs - 10 ))
3191 local dir=$DIR/d51bb
3193 local savePOLICY=$(lctl get_param -n lmv.*.placement)
3194 lctl set_param -n lmv.*.placement=CHAR
3197 local IUSED=$(lfs df -i $dir | grep MDT | awk '{print $3}')
3201 for ((i=0; i < $ndirs; i++)); do
3202 dirs[i]=$dir/$RANDOM
3203 echo Creating directory ${dirs[i]}
3206 echo Creating $nfiles in dir ${dirs[i]} ...
3207 echo "createmany -o ${dirs[i]}/$tfile- $nfiles"
3208 createmany -o ${dirs[i]}/$tfile- $nfiles
3214 IUSED=$(lfs df -i $dir | grep MDT | awk '{print $3}')
3218 for ((i=0; i<${#NEWUSED[@]}; i++)); do
3219 echo "mds $i: inodes count OLD ${OLDUSED[$i]} NEW ${NEWUSED[$i]}"
3220 [ ${OLDUSED[$i]} -lt ${NEWUSED[$i]} ] || rc=$((rc + 1))
3223 lctl set_param -n lmv.*.placement=$savePOLICY
3225 [ $rc -ne $MDSCOUNT ] || \
3226 error "Objects/inodes are not distributed over all mds servers"
3228 run_test 51bb "mkdir createmany CMD $MDSCOUNT ===================="
3231 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping test with few OSTs" && return
3233 createmany -o $DIR/d51d/t- 1000
3234 $GETSTRIPE $DIR/d51d > $TMP/files
3235 for N in `seq 0 $((OSTCOUNT - 1))`; do
3236 OBJS[$N]=`awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}' $TMP/files`
3237 OBJS0[$N]=`grep -A 1 idx $TMP/files | awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}'`
3238 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
3240 unlinkmany $DIR/d51d/t- 1000
3243 for N in `seq 1 $((OSTCOUNT - 1))`; do
3244 [ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ] && \
3245 error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
3246 [ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ] && \
3247 error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
3249 [ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ] && \
3250 error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
3251 [ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ] && \
3252 error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
3256 run_test 51d "check object distribution ===================="
3259 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
3262 chattr +a $DIR/d52a/foo || error "chattr +a failed"
3263 echo bar >> $DIR/d52a/foo || error "append bar failed"
3264 cp /etc/hosts $DIR/d52a/foo && error "cp worked"
3265 rm -f $DIR/d52a/foo 2>/dev/null && error "rm worked"
3266 link $DIR/d52a/foo $DIR/d52a/foo_link 2>/dev/null && error "link worked"
3267 echo foo >> $DIR/d52a/foo || error "append foo failed"
3268 mrename $DIR/d52a/foo $DIR/d52a/foo_ren && error "rename worked"
3269 lsattr $DIR/d52a/foo | egrep -q "^-+a[-e]+ $DIR/d52a/foo" || error "lsattr"
3270 chattr -a $DIR/d52a/foo || error "chattr -a failed"
3271 cp -r $DIR/d52a /tmp/
3272 rm -fr $DIR/d52a || error "cleanup rm failed"
3274 run_test 52a "append-only flag test (should return errors) ====="
3277 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
3280 chattr +i $DIR/d52b/foo || error "chattr +i failed"
3281 cat test > $DIR/d52b/foo && error "cat test worked"
3282 cp /etc/hosts $DIR/d52b/foo && error "cp worked"
3283 rm -f $DIR/d52b/foo 2>/dev/null && error "rm worked"
3284 link $DIR/d52b/foo $DIR/d52b/foo_link 2>/dev/null && error "link worked"
3285 echo foo >> $DIR/d52b/foo && error "echo worked"
3286 mrename $DIR/d52b/foo $DIR/d52b/foo_ren && error "rename worked"
3287 [ -f $DIR/d52b/foo ] || error
3288 [ -f $DIR/d52b/foo_ren ] && error
3289 lsattr $DIR/d52b/foo | egrep -q "^-+i[-e]+ $DIR/d52b/foo" || error "lsattr"
3290 chattr -i $DIR/d52b/foo || error "chattr failed"
3292 rm -fr $DIR/d52b || error
3294 run_test 52b "immutable flag test (should return errors) ======="
3297 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3298 remote_ost_nodsh && skip "remote OST with nodsh" && return
3307 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
3308 for value in $(do_facet $SINGLEMDS lctl get_param osc.$mdtosc.prealloc_last_id) ; do
3309 param=`echo ${value[0]} | cut -d "=" -f1`
3310 ostname=`echo $param | cut -d "." -f2 | cut -d - -f 1-2`
3311 mds_last=$(do_facet $SINGLEMDS lctl get_param -n $param)
3312 ostnum=$(echo $ostname | sed "s/${FSNAME}-OST//g" | awk '{print ($1+1)}' )
3313 ost_last=$(do_facet ost$ostnum lctl get_param -n obdfilter.$ostname.last_id | head -n 1)
3314 echo "$ostname.last_id=$ost_last ; MDS.last_id=$mds_last"
3315 if [ $ost_last != $mds_last ]; then
3316 error "$ostname.last_id=$ost_last ; MDS.last_id=$mds_last"
3320 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
3323 [ ! -f "$SOCKETSERVER" ] && skip_env "no socketserver, skipping" && return
3324 [ ! -f "$SOCKETCLIENT" ] && skip_env "no socketclient, skipping" && return
3325 $SOCKETSERVER $DIR/socket
3326 $SOCKETCLIENT $DIR/socket || error
3327 $MUNLINK $DIR/socket
3329 run_test 54a "unix domain socket test =========================="
3335 dd if=/dev/zero of=$f bs=`page_size` count=1
3337 run_test 54b "char device works in lustre ======================"
3340 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
3341 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
3342 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
3344 for i in `seq 3 7`; do
3345 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
3355 loopdev="$DIR/loop54c"
3358 [ -z "$LOOPNUM" ] && echo "couldn't find empty loop device" && return
3359 mknod $loopdev b 7 $LOOPNUM
3360 echo "make a loop file system with $tfile on $loopdev ($LOOPNUM)..."
3361 dd if=/dev/zero of=$tfile bs=`page_size` seek=1024 count=1 > /dev/null
3362 losetup $loopdev $tfile || error "can't set up $loopdev for $tfile"
3363 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
3365 mount -t ext2 $loopdev $tdir || error "error mounting $loopdev on $tdir"
3366 dd if=/dev/zero of=$tdir/tmp bs=`page_size` count=30 || error "dd write"
3368 dd if=$tdir/tmp of=/dev/zero bs=`page_size` count=30 || error "dd read"
3373 run_test 54c "block device works in lustre ====================="
3379 [ "$string" = `echo $string > $f | cat $f` ] || error
3381 run_test 54d "fifo device works in lustre ======================"
3384 check_kernel_version 46 || return 0
3387 cp -aL /dev/console $f
3388 echo $string > $f || error
3390 run_test 54e "console/tty device works in lustre ======================"
3392 #The test_55 used to be iopen test and it was removed by bz#24037.
3393 #run_test 55 "check iopen_connect_dentry() ======================"
3395 test_56a() { # was test_56
3401 NUMFILESx2=$(($NUMFILES * 2))
3402 for i in `seq 1 $NUMFILES` ; do
3403 touch $DIR/d56/file$i
3404 touch $DIR/d56/dir/file$i
3407 # test lfs getstripe with --recursive
3408 FILENUM=`$GETSTRIPE --recursive $DIR/d56 | grep -c obdidx`
3409 [ $FILENUM -eq $NUMFILESx2 ] ||
3410 error "$GETSTRIPE --recursive: found $FILENUM, not $NUMFILESx2"
3411 FILENUM=`$GETSTRIPE $DIR/d56 | grep -c obdidx`
3412 [ $FILENUM -eq $NUMFILES ] ||
3413 error "$GETSTRIPE $DIR/d56: found $FILENUM, not $NUMFILES"
3414 echo "$GETSTRIPE --recursive passed."
3416 # test lfs getstripe with file instead of dir
3417 FILENUM=`$GETSTRIPE $DIR/d56/file1 | grep -c obdidx`
3418 [ $FILENUM -eq 1 ] || error \
3419 "$GETSTRIPE $DIR/d56/file1: found $FILENUM, not 1"
3420 echo "$GETSTRIPE file1 passed."
3422 #test lfs getstripe with --verbose
3423 [ `$GETSTRIPE --verbose $DIR/d56 | grep -c lmm_magic` -eq $NUMFILES ] ||
3424 error "$GETSTRIPE --verbose $DIR/d56: want $NUMFILES lmm_magic"
3425 [ `$GETSTRIPE $DIR/d56 | grep -c lmm_magic` -eq 0 ] ||
3426 error "$GETSTRIPE $DIR/d56: showed lmm_magic"
3427 echo "$GETSTRIPE --verbose passed."
3429 #test lfs getstripe with --obd
3430 $GETSTRIPE --obd wrong_uuid $DIR/d56 2>&1 | grep -q "unknown obduuid" ||
3431 error "$GETSTRIPE --obd wrong_uuid should return error message"
3433 [ "$OSTCOUNT" -lt 2 ] &&
3434 skip_env "skipping other $GETSTRIPE --obd test" && return
3437 OBDUUID=$(ostuuid_from_index $OSTIDX)
3438 FILENUM=`$GETSTRIPE -ir $DIR/d56 | grep -x $OSTIDX | wc -l`
3439 FOUND=`$GETSTRIPE -r --obd $OBDUUID $DIR/d56 | grep obdidx | wc -l`
3440 [ $FOUND -eq $FILENUM ] ||
3441 error "$GETSTRIPE --obd wrong: found $FOUND, expected $FILENUM"
3442 [ `$GETSTRIPE -r -v --obd $OBDUUID $DIR/d56 |
3443 sed '/^[ ]*'${OSTIDX}'[ ]/d' |
3444 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l` -eq 0 ] ||
3445 error "$GETSTRIPE --obd: should not show file on other obd"
3446 echo "$GETSTRIPE --obd passed"
3448 run_test 56a "check $GETSTRIPE"
3453 local LOCAL_NUMFILES="$1"
3454 local LOCAL_NUMDIRS="$2"
3455 local MKDIR_PARAMS="$3"
3457 if [ ! -d "$TDIR" ] ; then
3459 [ "$MKDIR_PARAMS" ] && $SETSTRIPE $MKDIR_PARAMS $TDIR
3460 for i in `seq 1 $LOCAL_NUMFILES` ; do
3463 for i in `seq 1 $LOCAL_NUMDIRS` ; do
3465 for j in `seq 1 $LOCAL_NUMFILES` ; do
3466 touch $TDIR/dir$i/file$j
3472 setup_56_special() {
3476 if [ ! -e "$TDIR/loop1b" ] ; then
3477 for i in `seq 1 $LOCAL_NUMFILES` ; do
3478 mknod $TDIR/loop${i}b b 7 $i
3479 mknod $TDIR/null${i}c c 1 3
3480 ln -s $TDIR/file1 $TDIR/link${i}l
3482 for i in `seq 1 $LOCAL_NUMDIRS` ; do
3483 mknod $TDIR/dir$i/loop${i}b b 7 $i
3484 mknod $TDIR/dir$i/null${i}c c 1 3
3485 ln -s $TDIR/dir$i/file1 $TDIR/dir$i/link${i}l
3494 setup_56 $NUMFILES $NUMDIRS
3496 EXPECTED=$(($NUMDIRS + 2))
3497 # test lfs find with -name
3498 for i in $(seq 1 $NUMFILES) ; do
3499 NUMS=$($LFIND -name "*$i" $TDIR | wc -l)
3500 [ $NUMS -eq $EXPECTED ] ||
3501 error "lfs find -name \"*$i\" $TDIR wrong: "\
3502 "found $NUMS, expected $EXPECTED"
3505 run_test 56g "check lfs find -name ============================="
3511 setup_56 $NUMFILES $NUMDIRS
3513 EXPECTED=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
3514 # test lfs find with ! -name
3515 for i in $(seq 1 $NUMFILES) ; do
3516 NUMS=$($LFIND ! -name "*$i" $TDIR | wc -l)
3517 [ $NUMS -eq $EXPECTED ] ||
3518 error "lfs find ! -name \"*$i\" $TDIR wrong: "\
3519 "found $NUMS, expected $EXPECTED"
3522 run_test 56h "check lfs find ! -name ============================="
3527 UUID=$(ostuuid_from_index 0 $DIR/$tdir)
3528 CMD="$LFIND -ost $UUID $DIR/$tdir"
3530 [ -z "$OUT" ] || error "\"$CMD\" returned directory '$OUT'"
3532 run_test 56i "check 'lfs find -ost UUID' skips directories ======="
3536 setup_56_special $NUMFILES $NUMDIRS
3538 EXPECTED=$((NUMDIRS + 1))
3539 CMD="$LFIND -type d $TDIR"
3540 NUMS=$($CMD | wc -l)
3541 [ $NUMS -eq $EXPECTED ] ||
3542 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3544 run_test 56j "check lfs find -type d ============================="
3548 setup_56_special $NUMFILES $NUMDIRS
3550 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
3551 CMD="$LFIND -type f $TDIR"
3552 NUMS=$($CMD | wc -l)
3553 [ $NUMS -eq $EXPECTED ] ||
3554 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3556 run_test 56k "check lfs find -type f ============================="
3560 setup_56_special $NUMFILES $NUMDIRS
3562 EXPECTED=$((NUMDIRS + NUMFILES))
3563 CMD="$LFIND -type b $TDIR"
3564 NUMS=$($CMD | wc -l)
3565 [ $NUMS -eq $EXPECTED ] ||
3566 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3568 run_test 56l "check lfs find -type b ============================="
3572 setup_56_special $NUMFILES $NUMDIRS
3574 EXPECTED=$((NUMDIRS + NUMFILES))
3575 CMD="$LFIND -type c $TDIR"
3576 NUMS=$($CMD | wc -l)
3577 [ $NUMS -eq $EXPECTED ] ||
3578 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3580 run_test 56m "check lfs find -type c ============================="
3584 setup_56_special $NUMFILES $NUMDIRS
3586 EXPECTED=$((NUMDIRS + NUMFILES))
3587 CMD="$LFIND -type l $TDIR"
3588 NUMS=$($CMD | wc -l)
3589 [ $NUMS -eq $EXPECTED ] ||
3590 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3592 run_test 56n "check lfs find -type l ============================="
3596 setup_56 $NUMFILES $NUMDIRS
3598 utime $TDIR/file1 > /dev/null || error "utime (1)"
3599 utime $TDIR/file2 > /dev/null || error "utime (2)"
3600 utime $TDIR/dir1 > /dev/null || error "utime (3)"
3601 utime $TDIR/dir2 > /dev/null || error "utime (4)"
3602 utime $TDIR/dir1/file1 > /dev/null || error "utime (5)"
3603 dd if=/dev/zero count=1 >> $TDIR/dir1/file1 && sync
3606 NUMS=`$LFIND -mtime +0 $TDIR | wc -l`
3607 [ $NUMS -eq $EXPECTED ] || \
3608 error "lfs find -mtime +0 $TDIR wrong: found $NUMS, expected $EXPECTED"
3611 CMD="$LFIND -mtime 0 $TDIR"
3612 NUMS=$($CMD | wc -l)
3613 [ $NUMS -eq $EXPECTED ] ||
3614 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3616 run_test 56o "check lfs find -mtime for old files =========================="
3619 [ $RUNAS_ID -eq $UID ] &&
3620 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
3623 setup_56 $NUMFILES $NUMDIRS
3625 chown $RUNAS_ID $TDIR/file* || error "chown $DIR/${tdir}g/file$i failed"
3627 CMD="$LFIND -uid $RUNAS_ID $TDIR"
3628 NUMS=$($CMD | wc -l)
3629 [ $NUMS -eq $EXPECTED ] || \
3630 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3632 EXPECTED=$(((NUMFILES + 1) * NUMDIRS + 1))
3633 CMD="$LFIND ! -uid $RUNAS_ID $TDIR"
3634 NUMS=$($CMD | wc -l)
3635 [ $NUMS -eq $EXPECTED ] || \
3636 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3638 run_test 56p "check lfs find -uid and ! -uid ==============================="
3641 [ $RUNAS_ID -eq $UID ] &&
3642 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
3645 setup_56 $NUMFILES $NUMDIRS
3647 chgrp $RUNAS_GID $TDIR/file* || error "chown $TDIR/file$i failed"
3650 CMD="$LFIND -gid $RUNAS_GID $TDIR"
3651 NUMS=$($CMD | wc -l)
3652 [ $NUMS -eq $EXPECTED ] ||
3653 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3655 EXPECTED=$(( ($NUMFILES+1) * $NUMDIRS + 1))
3656 CMD="$LFIND ! -gid $RUNAS_GID $TDIR"
3657 NUMS=$($CMD | wc -l)
3658 [ $NUMS -eq $EXPECTED ] ||
3659 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3661 run_test 56q "check lfs find -gid and ! -gid ==============================="
3665 setup_56 $NUMFILES $NUMDIRS
3668 CMD="$LFIND -size 0 -type f $TDIR"
3669 NUMS=$($CMD | wc -l)
3670 [ $NUMS -eq $EXPECTED ] ||
3671 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3673 CMD="$LFIND ! -size 0 -type f $TDIR"
3674 NUMS=$($CMD | wc -l)
3675 [ $NUMS -eq $EXPECTED ] ||
3676 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3677 echo "test" > $TDIR/$tfile
3678 echo "test2" > $TDIR/$tfile.2 && sync
3680 CMD="$LFIND -size 5 -type f $TDIR"
3681 NUMS=$($CMD | wc -l)
3682 [ $NUMS -eq $EXPECTED ] ||
3683 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3685 CMD="$LFIND -size +5 -type f $TDIR"
3686 NUMS=$($CMD | wc -l)
3687 [ $NUMS -eq $EXPECTED ] ||
3688 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3690 CMD="$LFIND -size +0 -type f $TDIR"
3691 NUMS=$($CMD | wc -l)
3692 [ $NUMS -eq $EXPECTED ] ||
3693 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3695 CMD="$LFIND ! -size -5 -type f $TDIR"
3696 NUMS=$($CMD | wc -l)
3697 [ $NUMS -eq $EXPECTED ] ||
3698 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3700 CMD="$LFIND -size -5 -type f $TDIR"
3701 NUMS=$($CMD | wc -l)
3702 [ $NUMS -eq $EXPECTED ] ||
3703 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3705 run_test 56r "check lfs find -size works =========================="
3707 test_56s() { # LU-611
3709 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT"
3711 if [ $OSTCOUNT -gt 1 ]; then
3712 $SETSTRIPE -c 1 $TDIR/$tfile.{0,1,2,3}
3716 ONESTRIPE=$(((NUMDIRS + 1) * NUMFILES))
3720 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
3721 CMD="$LFIND -stripe-count $OSTCOUNT -type f $TDIR"
3722 NUMS=$($CMD | wc -l)
3723 [ $NUMS -eq $EXPECTED ] ||
3724 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3726 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + EXTRA))
3727 CMD="$LFIND -stripe-count +0 -type f $TDIR"
3728 NUMS=$($CMD | wc -l)
3729 [ $NUMS -eq $EXPECTED ] ||
3730 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3733 CMD="$LFIND -stripe-count 1 -type f $TDIR"
3734 NUMS=$($CMD | wc -l)
3735 [ $NUMS -eq $EXPECTED ] ||
3736 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3738 CMD="$LFIND -stripe-count -2 -type f $TDIR"
3739 NUMS=$($CMD | wc -l)
3740 [ $NUMS -eq $EXPECTED ] ||
3741 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3744 CMD="$LFIND -stripe-count $((OSTCOUNT + 1)) -type f $TDIR"
3745 NUMS=$($CMD | wc -l)
3746 [ $NUMS -eq $EXPECTED ] ||
3747 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3749 run_test 56s "check lfs find -stripe-count works"
3751 test_56t() { # LU-611
3753 setup_56 $NUMFILES $NUMDIRS "-s 512k"
3755 $SETSTRIPE -S 256k $TDIR/$tfile.{0,1,2,3}
3757 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
3758 CMD="$LFIND -stripe-size 512k -type f $TDIR"
3759 NUMS=$($CMD | wc -l)
3760 [ $NUMS -eq $EXPECTED ] ||
3761 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3763 CMD="$LFIND -stripe-size +320k -type f $TDIR"
3764 NUMS=$($CMD | wc -l)
3765 [ $NUMS -eq $EXPECTED ] ||
3766 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3768 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + 4))
3769 CMD="$LFIND -stripe-size +200k -type f $TDIR"
3770 NUMS=$($CMD | wc -l)
3771 [ $NUMS -eq $EXPECTED ] ||
3772 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3774 CMD="$LFIND -stripe-size -640k -type f $TDIR"
3775 NUMS=$($CMD | wc -l)
3776 [ $NUMS -eq $EXPECTED ] ||
3777 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3780 CMD="$LFIND -stripe-size 256k -type f $TDIR"
3781 NUMS=$($CMD | wc -l)
3782 [ $NUMS -eq $EXPECTED ] ||
3783 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3785 CMD="$LFIND -stripe-size -320k -type f $TDIR"
3786 NUMS=$($CMD | wc -l)
3787 [ $NUMS -eq $EXPECTED ] ||
3788 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3791 CMD="$LFIND -stripe-size 1024k -type f $TDIR"
3792 NUMS=$($CMD | wc -l)
3793 [ $NUMS -eq $EXPECTED ] ||
3794 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3796 run_test 56t "check lfs find -stripe-size works"
3798 test_56u() { # LU-611
3800 setup_56 $NUMFILES $NUMDIRS "-i 0"
3802 if [ $OSTCOUNT -gt 1 ]; then
3803 $SETSTRIPE -i 1 $TDIR/$tfile.{0,1,2,3}
3809 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
3810 CMD="$LFIND -stripe-index 0 -type f $TDIR"
3811 NUMS=$($CMD | wc -l)
3812 [ $NUMS -eq $EXPECTED ] ||
3813 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3816 CMD="$LFIND -stripe-index 1 -type f $TDIR"
3817 NUMS=$($CMD | wc -l)
3818 [ $NUMS -eq $EXPECTED ] ||
3819 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3821 CMD="$LFIND ! -stripe-index 0 -type f $TDIR"
3822 NUMS=$($CMD | wc -l)
3823 [ $NUMS -eq $EXPECTED ] ||
3824 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3827 # This should produce an error and not return any files
3828 CMD="$LFIND -stripe-index $OSTCOUNT -type f $TDIR"
3829 NUMS=$($CMD 2>/dev/null | wc -l)
3830 [ $NUMS -eq $EXPECTED ] ||
3831 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3833 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + ONESTRIPE))
3834 CMD="$LFIND -stripe-index 0,1 -type f $TDIR"
3835 NUMS=$($CMD | wc -l)
3836 [ $NUMS -eq $EXPECTED ] ||
3837 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3839 run_test 56u "check lfs find -stripe-index works"
3846 setup_56 $NUMFILES $NUMDIRS
3848 UUID=$(mdtuuid_from_index $MDT_IDX $TDIR)
3849 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT index $MDT_IDX"
3851 for file in $($LFIND -mdt $UUID $TDIR); do
3852 file_mdt_idx=$($GETSTRIPE -M $file)
3853 [ $file_mdt_idx -eq $MDT_IDX ] ||
3854 error "'lfind -mdt $UUID' != 'getstripe -M' ($file_mdt_idx)"
3857 run_test 56v "check 'lfs find -mdt match with lfs getstripe -M' ======="
3859 # Get and check the actual stripe count of one file.
3860 # Usage: check_stripe_count <file> <expected_stripe_count>
3861 check_stripe_count() {
3866 [[ -z "$file" || -z "$expected" ]] &&
3867 error "check_stripe_count: invalid argument!"
3869 local cmd="$GETSTRIPE -c $file"
3870 actual=$($cmd) || error "$cmd failed"
3871 actual=${actual%% *}
3873 if [[ $actual -ne $expected ]]; then
3874 [[ $expected -eq -1 ]] ||
3875 error "$cmd wrong: found $actual, expected $expected"
3876 [[ $actual -eq $OSTCOUNT ]] ||
3877 error "$cmd wrong: found $actual, expected $OSTCOUNT"
3884 rm -rf $TDIR || error "remove $TDIR failed"
3885 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT"
3888 stripe_size=$($GETSTRIPE -S -d $TDIR) ||
3889 error "$GETSTRIPE -S -d $TDIR failed"
3890 stripe_size=${stripe_size%% *}
3892 local file_size=$((stripe_size * OSTCOUNT))
3893 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
3894 local required_space=$((file_num * file_size))
3895 local free_space=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
3896 [[ $free_space -le $((required_space / 1024)) ]] &&
3897 skip_env "need at least $required_space bytes free space," \
3898 "have $free_space kbytes" && return
3901 local dd_count=$((file_size / dd_bs))
3903 # write data into the files
3907 for i in $(seq 1 $NUMFILES); do
3909 yes | dd bs=$dd_bs count=$dd_count of=$file >/dev/null 2>&1 ||
3910 error "write data into $file failed"
3912 for i in $(seq 1 $NUMDIRS); do
3913 for j in $(seq 1 $NUMFILES); do
3914 file=$TDIR/dir$i/file$j
3915 yes | dd bs=$dd_bs count=$dd_count of=$file \
3917 error "write data into $file failed"
3922 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
3925 local cmd="$LFS_MIGRATE -y -c $expected $TDIR/file1"
3927 eval $cmd || error "$cmd failed"
3929 check_stripe_count $TDIR/file1 $expected
3932 cmd="$LFS_MIGRATE -y -c $expected $TDIR/dir1"
3934 eval $cmd || error "$cmd failed"
3936 for j in $(seq 1 $NUMFILES); do
3937 check_stripe_count $TDIR/dir1/file$j $expected
3940 # lfs_migrate works with lfs find
3941 cmd="$LFIND -stripe_count $OSTCOUNT -type f $TDIR |
3942 $LFS_MIGRATE -y -c $expected"
3944 eval $cmd || error "$cmd failed"
3946 for i in $(seq 2 $NUMFILES); do
3947 check_stripe_count $TDIR/file$i $expected
3949 for i in $(seq 2 $NUMDIRS); do
3950 for j in $(seq 1 $NUMFILES); do
3951 check_stripe_count $TDIR/dir$i/file$j $expected
3955 run_test 56w "check lfs_migrate -c stripe_count works"
3958 # note test will not do anything if MDS is not local
3959 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3960 local MNTDEV="osd*.*MDT*.mntdev"
3961 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
3962 [ -z "$DEV" ] && error "can't access $MNTDEV"
3963 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
3964 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
3965 error "can't access $DEV"
3966 DEVISIZE=`awk '/Inode size:/ { print $3 }' $TMP/t57a.dump`
3967 [ "$DEVISIZE" -gt 128 ] || error "inode size $DEVISIZE"
3971 run_test 57a "verify MDS filesystem created with large inodes =="
3974 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3979 local FILEN=$dir/f$FILECOUNT
3981 rm -rf $dir || error "removing $dir"
3982 mkdir -p $dir || error "creating $dir"
3983 local num=$(get_mds_dir $dir)
3986 echo "mcreating $FILECOUNT files"
3987 createmany -m $dir/f 1 $FILECOUNT || \
3988 error "creating files in $dir"
3990 # verify that files do not have EAs yet
3991 $GETSTRIPE $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
3992 $GETSTRIPE $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
3996 df $dir #make sure we get new statfs data
3997 local MDSFREE=$(do_facet $mymds \
3998 lctl get_param -n osd*.*MDT000$((num -1)).kbytesfree)
3999 local MDCFREE=$(lctl get_param -n mdc.*MDT000$((num -1))-mdc-*.kbytesfree)
4000 echo "opening files to create objects/EAs"
4002 for FILE in `seq -f $dir/f%g 1 $FILECOUNT`; do
4003 $OPENFILE -f O_RDWR $FILE > /dev/null 2>&1 || error "opening $FILE"
4006 # verify that files have EAs now
4007 $GETSTRIPE $FILE1 | grep -q "obdidx" || error "$FILE1 missing EA"
4008 $GETSTRIPE $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
4010 sleep 1 #make sure we get new statfs data
4012 local MDSFREE2=$(do_facet $mymds \
4013 lctl get_param -n osd*.*MDT000$((num -1)).kbytesfree)
4014 local MDCFREE2=$(lctl get_param -n mdc.*MDT000$((num -1))-mdc-*.kbytesfree)
4015 if [ "$MDCFREE2" -lt "$((MDCFREE - 8))" ]; then
4016 if [ "$MDSFREE" != "$MDSFREE2" ]; then
4017 error "MDC before $MDCFREE != after $MDCFREE2"
4019 echo "MDC before $MDCFREE != after $MDCFREE2"
4020 echo "unable to confirm if MDS has large inodes"
4025 run_test 57b "default LOV EAs are stored inside large inodes ==="
4028 [ -z "$(which wiretest 2>/dev/null)" ] && skip_env "could not find wiretest" && return
4031 run_test 58 "verify cross-platform wire constants =============="
4034 echo "touch 130 files"
4035 createmany -o $DIR/f59- 130
4037 unlinkmany $DIR/f59- 130
4040 # wait for commitment of removal
4042 run_test 59 "verify cancellation of llog records async ========="
4044 TEST60_HEAD="test_60 run $RANDOM"
4046 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
4047 [ ! -f run-llog.sh ] && skip_env "missing subtest run-llog.sh" && return
4048 log "$TEST60_HEAD - from kernel mode"
4049 do_facet mgs sh run-llog.sh
4051 run_test 60a "llog sanity tests run from kernel module =========="
4053 test_60b() { # bug 6411
4055 LLOG_COUNT=`dmesg | awk "/$TEST60_HEAD/{marker = 1; from_marker = 0;}
4067 [ $LLOG_COUNT -gt 50 ] && error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)"|| true
4069 run_test 60b "limit repeated messages from CERROR/CWARN ========"
4072 echo "create 5000 files"
4073 createmany -o $DIR/f60c- 5000
4074 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
4075 lctl set_param fail_loc=0x80000137
4076 unlinkmany $DIR/f60c- 5000
4077 lctl set_param fail_loc=0
4079 run_test 60c "unlink file when mds full"
4082 SAVEPRINTK=$(lctl get_param -n printk)
4084 # verify "lctl mark" is even working"
4085 MESSAGE="test message ID $RANDOM $$"
4086 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
4087 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
4089 lctl set_param printk=0 || error "set lnet.printk failed"
4090 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
4091 MESSAGE="new test message ID $RANDOM $$"
4092 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
4093 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
4094 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
4096 lctl set_param -n printk="$SAVEPRINTK"
4098 run_test 60d "test printk console message masking"
4102 dd if=/dev/zero of=$f bs=`page_size` count=1
4103 cancel_lru_locks osc
4104 $MULTIOP $f OSMWUc || error
4107 run_test 61 "mmap() writes don't make sync hang ================"
4109 # bug 2330 - insufficient obd_match error checking causes LBUG
4113 cancel_lru_locks osc
4114 lctl set_param fail_loc=0x405
4115 cat $f && error "cat succeeded, expect -EIO"
4116 lctl set_param fail_loc=0
4118 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
4119 # match every page all of the time.
4120 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
4122 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
4123 test_63a() { # was test_63
4124 MAX_DIRTY_MB=`lctl get_param -n osc.*.max_dirty_mb | head -n 1`
4125 lctl set_param -n osc.*.max_dirty_mb 0
4126 for i in `seq 10` ; do
4127 dd if=/dev/zero of=$DIR/f63 bs=8k &
4133 lctl set_param -n osc.*.max_dirty_mb $MAX_DIRTY_MB
4134 rm -f $DIR/f63 || true
4136 run_test 63a "Verify oig_wait interruption does not crash ======="
4138 # bug 2248 - async write errors didn't return to application on sync
4139 # bug 3677 - async write errors left page locked
4142 lctl set_param debug=-1
4144 # ensure we have a grant to do async writes
4145 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
4148 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
4149 lctl set_param fail_loc=0x80000406
4150 $MULTIOP $DIR/$tfile Owy && \
4151 error "sync didn't return ENOMEM"
4152 sync; sleep 2; sync # do a real sync this time to flush page
4153 lctl get_param -n llite.*.dump_page_cache | grep locked && \
4154 error "locked page left in cache after async error" || true
4157 run_test 63b "async write errors should be returned to fsync ==="
4161 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
4163 run_test 64a "verify filter grant calculations (in kernel) ====="
4166 [ ! -f oos.sh ] && skip_env "missing subtest oos.sh" && return
4169 run_test 64b "check out-of-space detection on client ==========="
4171 # bug 1414 - set/get directories' stripe info
4175 $LVERIFY $DIR/d65 $DIR/d65/f1 || error "lverify failed"
4177 run_test 65a "directory with no stripe info ===================="
4181 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/d65||error "setstripe"
4183 $LVERIFY $DIR/d65 $DIR/d65/f2 || error "lverify failed"
4185 run_test 65b "directory setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1"
4188 if [ $OSTCOUNT -gt 1 ]; then
4190 $SETSTRIPE -S $(($STRIPESIZE * 4)) -i 1 \
4191 -c $(($OSTCOUNT - 1)) $DIR/d65 || error "setstripe"
4193 $LVERIFY $DIR/d65 $DIR/d65/f3 || error "lverify failed"
4196 run_test 65c "directory setstripe -S $((STRIPESIZE*4)) -i 1 -c $((OSTCOUNT-1))"
4200 if [ $STRIPECOUNT -le 0 ]; then
4202 elif [ $STRIPECOUNT -gt 2000 ]; then
4203 #LOV_MAX_STRIPE_COUNT is 2000
4204 [ $OSTCOUNT -gt 2000 ] && sc=2000 || sc=$(($OSTCOUNT - 1))
4206 sc=$(($STRIPECOUNT - 1))
4208 $SETSTRIPE -S $STRIPESIZE -c $sc $DIR/d65 || error "setstripe"
4209 touch $DIR/d65/f4 $DIR/d65/f5
4210 $LVERIFY $DIR/d65 $DIR/d65/f4 $DIR/d65/f5 || error "lverify failed"
4212 run_test 65d "directory setstripe -S $STRIPESIZE -c stripe_count"
4217 $SETSTRIPE $DIR/d65 || error "setstripe"
4218 $GETSTRIPE -v $DIR/d65 | grep "Default" || error "no stripe info failed"
4220 $LVERIFY $DIR/d65 $DIR/d65/f6 || error "lverify failed"
4222 run_test 65e "directory setstripe defaults ======================="
4226 $RUNAS $SETSTRIPE $DIR/d65f && error "setstripe succeeded" || true
4228 run_test 65f "dir setstripe permission (should return error) ==="
4232 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/d65 ||error "setstripe"
4233 $SETSTRIPE -d $DIR/d65 || error "setstripe"
4234 $GETSTRIPE -v $DIR/d65 | grep "Default" || \
4235 error "delete default stripe failed"
4237 run_test 65g "directory setstripe -d ==========================="
4241 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/d65 ||error "setstripe"
4242 mkdir -p $DIR/d65/dd1
4243 [ $($GETSTRIPE -c $DIR/d65) == $($GETSTRIPE -c $DIR/d65/dd1) ] ||
4244 error "stripe info inherit failed"
4246 run_test 65h "directory stripe info inherit ===================="
4248 test_65i() { # bug6367
4249 $SETSTRIPE -S 65536 -c -1 $MOUNT
4251 run_test 65i "set non-default striping on root directory (bug 6367)="
4253 test_65ia() { # bug12836
4254 $GETSTRIPE $MOUNT || error "getstripe $MOUNT failed"
4256 run_test 65ia "getstripe on -1 default directory striping"
4258 test_65ib() { # bug12836
4259 $GETSTRIPE -v $MOUNT || error "getstripe -v $MOUNT failed"
4261 run_test 65ib "getstripe -v on -1 default directory striping"
4263 test_65ic() { # bug12836
4264 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
4266 run_test 65ic "new find on -1 default directory striping"
4268 test_65j() { # bug6367
4270 # if we aren't already remounting for each test, do so for this test
4271 if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
4272 cleanup || error "failed to unmount"
4275 $SETSTRIPE -d $MOUNT || error "setstripe failed"
4277 run_test 65j "set default striping on root directory (bug 6367)="
4279 test_65k() { # bug11679
4280 [ "$OSTCOUNT" -lt 2 ] && skip_env "too few OSTs" && return
4281 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4283 echo "Check OST status: "
4284 local MDS_OSCS=`do_facet $SINGLEMDS lctl dl |
4285 awk '/[oO][sS][cC].*md[ts]/ { print $4 }'`
4287 for OSC in $MDS_OSCS; do
4288 echo $OSC "is activate"
4289 do_facet $SINGLEMDS lctl --device %$OSC activate
4292 do_facet client mkdir -p $DIR/$tdir
4293 for INACTIVE_OSC in $MDS_OSCS; do
4294 echo "Deactivate: " $INACTIVE_OSC
4295 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
4296 for STRIPE_OSC in $MDS_OSCS; do
4297 OST=`osc_to_ost $STRIPE_OSC`
4298 IDX=`do_facet $SINGLEMDS lctl get_param -n lov.*md*.target_obd |
4299 awk -F: /$OST/'{ print $1 }' | head -n 1`
4301 [ -f $DIR/$tdir/$IDX ] && continue
4302 echo "$SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX"
4303 do_facet client $SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX
4305 [ $RC -ne 0 ] && error "setstripe should have succeeded"
4307 do_facet client rm -f $DIR/$tdir/*
4308 echo $INACTIVE_OSC "is Activate."
4309 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
4312 run_test 65k "validate manual striping works properly with deactivated OSCs"
4314 test_65l() { # bug 12836
4315 mkdir -p $DIR/$tdir/test_dir
4316 $SETSTRIPE -c -1 $DIR/$tdir/test_dir
4317 $LFS find -mtime -1 $DIR/$tdir >/dev/null
4319 run_test 65l "lfs find on -1 stripe dir ========================"
4321 # bug 2543 - update blocks count on client
4324 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
4325 sync; sync_all_data; sync; sync_all_data
4326 cancel_lru_locks osc
4327 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
4328 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
4330 run_test 66 "update inode blocks count on client ==============="
4336 if [ ! -z "$LLOOP" ]; then
4337 if swapon -s | grep -q $LLOOP; then
4338 swapoff $LLOOP || error "swapoff failed"
4341 $LCTL blockdev_detach $LLOOP || error "detach failed"
4345 if [ ! -z "$LLITELOOPLOAD" ]; then
4353 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
4357 swapon -s | awk '($1 == "'$1'") { print $4 }'
4360 # test case for lloop driver, basic function
4362 [ "$UID" != 0 ] && skip_env "must run as root" && return
4363 llite_lloop_enabled || \
4364 { skip_env "llite_lloop module disabled" && return; }
4366 trap cleanup_68 EXIT
4368 if ! module_loaded llite_lloop; then
4369 if load_module llite/llite_lloop; then
4372 skip_env "can't find module llite_lloop"
4377 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
4378 dd if=/dev/zero of=$DIR/f68a bs=4k count=1024
4379 $LCTL blockdev_attach $DIR/f68a $LLOOP || error "attach failed"
4381 directio rdwr $LLOOP 0 1024 4096 || error "direct write failed"
4382 directio rdwr $LLOOP 0 1025 4096 && error "direct write should fail"
4386 run_test 68a "lloop driver - basic test ========================"
4388 # excercise swapping to lustre by adding a high priority swapfile entry
4389 # and then consuming memory until it is used.
4390 test_68b() { # was test_68
4391 [ "$UID" != 0 ] && skip_env "must run as root" && return
4392 lctl get_param -n devices | grep -q obdfilter && \
4393 skip "local OST" && return
4395 grep -q llite_lloop /proc/modules
4396 [ $? -ne 0 ] && skip "can't find module llite_lloop" && return
4398 [ -z "`$LCTL list_nids | grep -v tcp`" ] && \
4399 skip "can't reliably test swap with TCP" && return
4401 MEMTOTAL=`meminfo MemTotal`
4402 NR_BLOCKS=$((MEMTOTAL>>8))
4403 [[ $NR_BLOCKS -le 2048 ]] && NR_BLOCKS=2048
4405 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
4406 dd if=/dev/zero of=$DIR/f68b bs=64k seek=$NR_BLOCKS count=1
4409 $LCTL blockdev_attach $DIR/f68b $LLOOP || error "attach failed"
4411 trap cleanup_68 EXIT
4413 swapon -p 32767 $LLOOP || error "swapon $LLOOP failed"
4415 echo "before: `swapon -s | grep $LLOOP`"
4416 $MEMHOG $MEMTOTAL || error "error allocating $MEMTOTAL kB"
4417 echo "after: `swapon -s | grep $LLOOP`"
4418 SWAPUSED=`swap_used $LLOOP`
4422 [ $SWAPUSED -eq 0 ] && echo "no swap used???" || true
4424 run_test 68b "support swapping to Lustre ========================"
4426 # bug5265, obdfilter oa2dentry return -ENOENT
4427 # #define OBD_FAIL_OST_ENOENT 0x217
4429 remote_ost_nodsh && skip "remote OST with nodsh" && return
4432 $SETSTRIPE -c 1 -i 0 $f
4434 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
4436 do_facet ost1 lctl set_param fail_loc=0x217
4437 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
4438 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
4440 do_facet ost1 lctl set_param fail_loc=0
4441 $DIRECTIO write $f 0 2 || error "write error"
4443 cancel_lru_locks osc
4444 $DIRECTIO read $f 0 1 || error "read error"
4446 do_facet ost1 lctl set_param fail_loc=0x217
4447 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
4449 do_facet ost1 lctl set_param fail_loc=0
4452 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
4456 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
4458 run_test 71 "Running dbench on lustre (don't segment fault) ===="
4460 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
4461 check_kernel_version 43 || return 0
4462 [ "$RUNAS_ID" = "$UID" ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4464 # Check that testing environment is properly set up. Skip if not
4465 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS || {
4466 skip_env "User $RUNAS_ID does not exist - skipping"
4469 # We had better clear the $DIR to get enough space for dd
4474 $RUNAS dd if=/dev/zero of=$DIR/f72 bs=512 count=1 || error
4475 # See if we are still setuid/sgid
4476 test -u $DIR/f72 -o -g $DIR/f72 && error "S/gid is not dropped on write"
4477 # Now test that MDS is updated too
4478 cancel_lru_locks mdc
4479 test -u $DIR/f72 -o -g $DIR/f72 && error "S/gid is not dropped on MDS"
4483 run_test 72a "Test that remove suid works properly (bug5695) ===="
4485 test_72b() { # bug 24226 -- keep mode setting when size is not changing
4488 [ "$RUNAS_ID" = "$UID" ] && \
4489 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4490 [ "$RUNAS_ID" -eq 0 ] && \
4491 skip_env "RUNAS_ID = 0 -- skipping" && return
4493 # Check that testing environment is properly set up. Skip if not
4494 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS || {
4495 skip_env "User $RUNAS_ID does not exist - skipping"
4498 touch $DIR/${tfile}-f{g,u}
4499 mkdir $DIR/${tfile}-d{g,u}
4500 chmod 770 $DIR/${tfile}-{f,d}{g,u}
4501 chmod g+s $DIR/${tfile}-{f,d}g
4502 chmod u+s $DIR/${tfile}-{f,d}u
4503 for perm in 777 2777 4777; do
4504 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
4505 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
4506 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
4507 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
4511 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
4513 # bug 3462 - multiple simultaneous MDC requests
4517 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
4520 lctl set_param fail_loc=0x80000129
4521 $MULTIOP $DIR/d73-1/f73-2 Oc &
4523 lctl set_param fail_loc=0
4525 $MULTIOP $DIR/d73-2/f73-3 Oc &
4529 wait $pid1 || return 1
4533 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
4534 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
4535 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
4539 run_test 73 "multiple MDC requests (should not deadlock)"
4541 test_74a() { # bug 6149, 6184
4542 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
4544 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
4545 # will spin in a tight reconnection loop
4547 lctl set_param fail_loc=0x8000030e
4548 # get any lock that won't be difficult - lookup works.
4550 lctl set_param fail_loc=0
4554 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
4556 test_74b() { # bug 13310
4557 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
4559 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
4560 # will spin in a tight reconnection loop
4561 lctl set_param fail_loc=0x8000030e
4562 # get a "difficult" lock
4564 lctl set_param fail_loc=0
4568 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
4571 #define OBD_FAIL_LDLM_NEW_LOCK
4572 lctl set_param fail_loc=0x80000319
4573 touch $DIR/$tfile && error "Touch successful"
4576 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
4579 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
4582 get_inode_slab_tunables() {
4583 awk '/lustre_inode_cache/ {print $9," ",$10," ",$11; exit}' /proc/slabinfo
4586 set_inode_slab_tunables() {
4587 echo "lustre_inode_cache $1" > /proc/slabinfo
4590 test_76() { # Now for bug 20433, added originally in bug 1443
4591 local SLAB_SETTINGS=`get_inode_slab_tunables`
4592 local CPUS=`getconf _NPROCESSORS_ONLN`
4593 # we cannot set limit below 1 which means 1 inode in each
4594 # per-cpu cache is still allowed
4595 set_inode_slab_tunables "1 1 0"
4596 cancel_lru_locks osc
4597 BEFORE_INODES=`num_inodes`
4598 echo "before inodes: $BEFORE_INODES"
4600 [ "$SLOW" = "no" ] && COUNT=100
4601 for i in `seq $COUNT`; do
4605 cancel_lru_locks osc
4606 AFTER_INODES=`num_inodes`
4607 echo "after inodes: $AFTER_INODES"
4609 while [ $((AFTER_INODES-1*CPUS)) -gt $BEFORE_INODES ]; do
4611 AFTER_INODES=`num_inodes`
4613 echo "wait $wait seconds inodes: $AFTER_INODES"
4614 if [ $wait -gt 30 ]; then
4615 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
4618 set_inode_slab_tunables "$SLAB_SETTINGS"
4620 run_test 76 "confirm clients recycle inodes properly ===="
4626 # Note: in sptlrpc modes which enable its own bulk checksum, the
4627 # original crc32_le bulk checksum will be automatically disabled,
4628 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
4629 # will be checked by sptlrpc code against sptlrpc bulk checksum.
4630 # In this case set_checksums() will not be no-op, because sptlrpc
4631 # bulk checksum will be enabled all through the test.
4633 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
4634 lctl set_param -n osc.*.checksums $1
4638 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
4639 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
4640 CKSUM_TYPES=${CKSUM_TYPES:-"crc32 adler"}
4641 [ "$ORIG_CSUM_TYPE" = "crc32c" ] && CKSUM_TYPES="$CKSUM_TYPES crc32c"
4644 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
4645 log "set checksum type to $1"
4648 F77_TMP=$TMP/f77-temp
4651 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
4652 error "error writing to $F77_TMP"
4655 test_77a() { # bug 10889
4656 $GSS && skip "could not run with gss" && return
4657 [ ! -f $F77_TMP ] && setup_f77
4659 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
4663 run_test 77a "normal checksum read/write operation ============="
4665 test_77b() { # bug 10889
4666 $GSS && skip "could not run with gss" && return
4667 [ ! -f $F77_TMP ] && setup_f77
4668 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
4669 lctl set_param fail_loc=0x80000409
4671 dd if=$F77_TMP of=$DIR/f77b bs=1M count=$F77SZ conv=sync || \
4672 error "dd error: $?"
4673 lctl set_param fail_loc=0
4676 run_test 77b "checksum error on client write ===================="
4678 test_77c() { # bug 10889
4679 $GSS && skip "could not run with gss" && return
4680 [ ! -f $DIR/f77b ] && skip "requires 77b - skipping" && return
4682 for algo in $CKSUM_TYPES; do
4683 cancel_lru_locks osc
4684 set_checksum_type $algo
4685 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
4686 lctl set_param fail_loc=0x80000408
4687 cmp $F77_TMP $DIR/f77b || error "file compare failed"
4688 lctl set_param fail_loc=0
4691 set_checksum_type $ORIG_CSUM_TYPE
4694 run_test 77c "checksum error on client read ==================="
4696 test_77d() { # bug 10889
4697 $GSS && skip "could not run with gss" && return
4698 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
4699 lctl set_param fail_loc=0x80000409
4701 directio write $DIR/f77 0 $F77SZ $((1024 * 1024)) || \
4702 error "direct write: rc=$?"
4703 lctl set_param fail_loc=0
4706 run_test 77d "checksum error on OST direct write ==============="
4708 test_77e() { # bug 10889
4709 $GSS && skip "could not run with gss" && return
4710 [ ! -f $DIR/f77 ] && skip "requires 77d - skipping" && return
4711 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
4712 lctl set_param fail_loc=0x80000408
4714 cancel_lru_locks osc
4715 directio read $DIR/f77 0 $F77SZ $((1024 * 1024)) || \
4716 error "direct read: rc=$?"
4717 lctl set_param fail_loc=0
4720 run_test 77e "checksum error on OST direct read ================"
4722 test_77f() { # bug 10889
4723 $GSS && skip "could not run with gss" && return
4725 for algo in $CKSUM_TYPES; do
4726 cancel_lru_locks osc
4727 set_checksum_type $algo
4728 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
4729 lctl set_param fail_loc=0x409
4730 directio write $DIR/f77 0 $F77SZ $((1024 * 1024)) && \
4731 error "direct write succeeded"
4732 lctl set_param fail_loc=0
4734 set_checksum_type $ORIG_CSUM_TYPE
4737 run_test 77f "repeat checksum error on write (expect error) ===="
4739 test_77g() { # bug 10889
4740 $GSS && skip "could not run with gss" && return
4741 remote_ost_nodsh && skip "remote OST with nodsh" && return
4743 [ ! -f $F77_TMP ] && setup_f77
4745 $SETSTRIPE -c 1 -i 0 $DIR/f77g
4746 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
4747 do_facet ost1 lctl set_param fail_loc=0x8000021a
4749 dd if=$F77_TMP of=$DIR/f77g bs=1M count=$F77SZ || \
4750 error "write error: rc=$?"
4751 do_facet ost1 lctl set_param fail_loc=0
4754 run_test 77g "checksum error on OST write ======================"
4756 test_77h() { # bug 10889
4757 $GSS && skip "could not run with gss" && return
4758 remote_ost_nodsh && skip "remote OST with nodsh" && return
4760 [ ! -f $DIR/f77g ] && skip "requires 77g - skipping" && return
4761 cancel_lru_locks osc
4762 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
4763 do_facet ost1 lctl set_param fail_loc=0x8000021b
4765 cmp $F77_TMP $DIR/f77g || error "file compare failed"
4766 do_facet ost1 lctl set_param fail_loc=0
4769 run_test 77h "checksum error on OST read ======================="
4771 test_77i() { # bug 13805
4772 $GSS && skip "could not run with gss" && return
4773 #define OBD_FAIL_OSC_CONNECT_CKSUM 0x40b
4774 lctl set_param fail_loc=0x40b
4775 remount_client $MOUNT
4776 lctl set_param fail_loc=0
4777 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
4778 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
4779 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
4780 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
4782 remount_client $MOUNT
4784 run_test 77i "client not supporting OSD_CONNECT_CKSUM =========="
4786 test_77j() { # bug 13805
4787 $GSS && skip "could not run with gss" && return
4788 #define OBD_FAIL_OSC_CKSUM_ADLER_ONLY 0x40c
4789 lctl set_param fail_loc=0x40c
4790 remount_client $MOUNT
4791 lctl set_param fail_loc=0
4792 sleep 2 # wait async osc connect to finish
4793 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
4794 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
4795 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
4796 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
4798 remount_client $MOUNT
4800 run_test 77j "client only supporting ADLER32 ===================="
4802 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
4806 test_78() { # bug 10901
4807 remote_ost || { skip_env "local OST" && return; }
4810 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
4811 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
4812 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
4813 echo "MemTotal: $MEMTOTAL"
4814 # reserve 256MB of memory for the kernel and other running processes,
4815 # and then take 1/2 of the remaining memory for the read/write buffers.
4816 if [ $MEMTOTAL -gt 512 ] ;then
4817 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
4819 # for those poor memory-starved high-end clusters...
4820 MEMTOTAL=$((MEMTOTAL / 2))
4822 echo "Mem to use for directio: $MEMTOTAL"
4823 [ $F78SIZE -gt $MEMTOTAL ] && F78SIZE=$MEMTOTAL
4824 [ $F78SIZE -gt 512 ] && F78SIZE=512
4825 [ $F78SIZE -gt $((MAXFREE / 1024)) ] && F78SIZE=$((MAXFREE / 1024))
4826 SMALLESTOST=`lfs df $DIR |grep OST | awk '{print $4}' |sort -n |head -1`
4827 echo "Smallest OST: $SMALLESTOST"
4828 [ $SMALLESTOST -lt 10240 ] && \
4829 skip "too small OSTSIZE, useless to run large O_DIRECT test" && return 0
4831 [ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ] && \
4832 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
4834 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
4835 echo "File size: $F78SIZE"
4836 $SETSTRIPE -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
4837 for i in `seq 1 $NSEQ`
4839 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
4840 echo directIO rdwr round $i of $NSEQ
4841 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
4846 run_test 78 "handle large O_DIRECT writes correctly ============"
4848 test_79() { # bug 12743
4849 wait_delete_completed
4851 BKTOTAL=$(calc_osc_kbytes kbytestotal)
4852 BKFREE=$(calc_osc_kbytes kbytesfree)
4853 BKAVAIL=$(calc_osc_kbytes kbytesavail)
4855 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
4856 DFTOTAL=`echo $STRING | cut -d, -f1`
4857 DFUSED=`echo $STRING | cut -d, -f2`
4858 DFAVAIL=`echo $STRING | cut -d, -f3`
4859 DFFREE=$(($DFTOTAL - $DFUSED))
4861 ALLOWANCE=$((64 * $OSTCOUNT))
4863 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
4864 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
4865 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
4867 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
4868 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
4869 error "df free($DFFREE) mismatch OST free($BKFREE)"
4871 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
4872 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
4873 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
4876 run_test 79 "df report consistency check ======================="
4878 test_80() { # bug 10718
4879 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
4881 local BEFORE=`date +%s`
4882 cancel_lru_locks osc
4883 local AFTER=`date +%s`
4884 local DIFF=$((AFTER-BEFORE))
4885 if [ $DIFF -gt 1 ] ; then
4886 error "elapsed for 1M@1T = $DIFF"
4891 run_test 80 "Page eviction is equally fast at high offsets too ===="
4893 test_81a() { # LU-456
4894 remote_ost_nodsh && skip "remote OST with nodsh" && return
4895 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
4896 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
4897 do_facet ost0 lctl set_param fail_loc=0x80000228
4899 # write should trigger a retry and success
4900 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
4901 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
4903 if [ $RC -ne 0 ] ; then
4904 error "write should success, but failed for $RC"
4907 run_test 81a "OST should retry write when get -ENOSPC ==============="
4909 test_81b() { # LU-456
4910 remote_ost_nodsh && skip "remote OST with nodsh" && return
4911 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
4912 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
4913 do_facet ost0 lctl set_param fail_loc=0x228
4915 # write should retry several times and return -ENOSPC finally
4916 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
4917 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
4920 if [ $RC -ne $ENOSPC ] ; then
4921 error "dd should fail for -ENOSPC, but succeed."
4924 run_test 81b "OST should return -ENOSPC when retry still fails ======="
4926 test_82() { # LU-1031
4927 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10
4931 multiop_bg_pause $DIR/$tfile OG${gid1}_g${gid1}c || return 1
4933 multiop_bg_pause $DIR/$tfile O_G${gid2}r10g${gid2}c || return 2
4935 kill -USR1 $MULTIPID2
4937 if [[ `ps h -o comm -p $MULTIPID2` == "" ]]; then
4938 error "First grouplock does not block second one"
4940 echo "Second grouplock blocks first one"
4942 kill -USR1 $MULTIPID1
4946 run_test 82 "Basic grouplock test ==============================="
4949 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && \
4951 mkdir -p $DIR/d99cvsroot
4952 chown $RUNAS_ID $DIR/d99cvsroot
4953 local oldPWD=$PWD # bug 13584, use $TMP as working dir
4956 $RUNAS cvs -d $DIR/d99cvsroot init || error
4959 run_test 99a "cvs init ========================================="
4962 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
4963 [ ! -d $DIR/d99cvsroot ] && test_99a
4965 # some versions of cvs import exit(1) when asked to import links or
4966 # files they can't read. ignore those files.
4967 TOIGNORE=$(find . -type l -printf '-I %f\n' -o \
4968 ! -perm +4 -printf '-I %f\n')
4969 $RUNAS cvs -d $DIR/d99cvsroot import -m "nomesg" $TOIGNORE \
4970 d99reposname vtag rtag
4972 run_test 99b "cvs import ======================================="
4975 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
4976 [ ! -d $DIR/d99cvsroot ] && test_99b
4978 mkdir -p $DIR/d99reposname
4979 chown $RUNAS_ID $DIR/d99reposname
4980 $RUNAS cvs -d $DIR/d99cvsroot co d99reposname
4982 run_test 99c "cvs checkout ====================================="
4985 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
4986 [ ! -d $DIR/d99cvsroot ] && test_99c
4987 cd $DIR/d99reposname
4989 $RUNAS cvs add -m 'addmsg' foo99
4991 run_test 99d "cvs add =========================================="
4994 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
4995 [ ! -d $DIR/d99cvsroot ] && test_99c
4996 cd $DIR/d99reposname
4999 run_test 99e "cvs update ======================================="
5002 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5003 [ ! -d $DIR/d99cvsroot ] && test_99d
5004 cd $DIR/d99reposname
5005 $RUNAS cvs commit -m 'nomsg' foo99
5006 rm -fr $DIR/d99cvsroot
5008 run_test 99f "cvs commit ======================================="
5011 [ "$NETTYPE" = tcp ] || \
5012 { skip "TCP secure port test, not useful for NETTYPE=$NETTYPE" && \
5015 remote_ost_nodsh && skip "remote OST with nodsh" && return
5016 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5018 { skip "useless for local single node setup" && return; }
5020 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
5021 [ "$PROT" != "tcp" ] && continue
5022 RPORT=$(echo $REMOTE | cut -d: -f2)
5023 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
5026 LPORT=`echo $LOCAL | cut -d: -f2`
5027 if [ $LPORT -ge 1024 ]; then
5028 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
5030 error_exit "local: $LPORT > 1024, remote: $RPORT"
5033 [ "$rc" = 0 ] || error_exit "privileged port not found" )
5035 run_test 100 "check local port using privileged port ==========="
5037 function get_named_value()
5046 echo $line | sed "s/^$tag[ ]*//"
5053 export CACHE_MAX=`$LCTL get_param -n llite.*.max_cached_mb | head -n 1`
5055 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
5063 [ "$CPU" = "UML" ] && nreads=1000
5064 local cache_limit=32
5066 $LCTL set_param -n osc.*-osc*.rpc_stats 0
5067 trap cleanup_101a EXIT
5068 $LCTL set_param -n llite.*.read_ahead_stats 0
5069 $LCTL set_param -n llite.*.max_cached_mb $cache_limit
5072 # randomly read 10000 of 64K chunks from file 3x 32MB in size
5074 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
5075 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
5078 for s in `$LCTL get_param -n llite.*.read_ahead_stats | \
5079 get_named_value 'read but discarded' | cut -d" " -f1`; do
5080 discard=$(($discard + $s))
5084 if [ $(($discard * 10)) -gt $nreads ] ;then
5085 $LCTL get_param osc.*-osc*.rpc_stats
5086 $LCTL get_param llite.*.read_ahead_stats
5087 error "too many ($discard) discarded pages"
5089 rm -f $DIR/$tfile || true
5091 run_test 101a "check read-ahead for random reads ================"
5096 STRIPE_COUNT=$OSTCOUNT
5099 local list=$(comma_list $(osts_nodes))
5100 do_nodes $list $LCTL set_param -n obdfilter.*.read_cache_enable=0
5101 do_nodes $list $LCTL set_param -n obdfilter.*.writethrough_cache_enable=0
5103 trap cleanup_test101bc EXIT
5104 # prepare the read-ahead file
5105 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
5107 dd if=/dev/zero of=$DIR/$tfile bs=1024k count=100 2> /dev/null
5110 cleanup_test101bc() {
5115 local list=$(comma_list $(osts_nodes))
5116 do_nodes $list $LCTL set_param -n obdfilter.*.read_cache_enable=1
5117 do_nodes $list $LCTL set_param -n obdfilter.*.writethrough_cache_enable=1
5121 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
5126 local STRIPE_SIZE=1048576
5127 local RA_INC=1048576
5128 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
5129 local FILE_LENGTH=$((64*100))
5130 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
5131 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
5132 DISCARD=`$LCTL get_param -n llite.*.read_ahead_stats | \
5133 get_named_value 'read but discarded' | \
5134 cut -d" " -f1 | calc_total`
5135 if [ $DISCARD -gt $discard_limit ]; then
5136 $LCTL get_param llite.*.read_ahead_stats
5137 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
5139 echo "Read-ahead success for size ${READ_SIZE}"
5144 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping stride IO stride-ahead test" && return
5145 local STRIPE_SIZE=1048576
5146 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
5147 local FILE_LENGTH=$((STRIPE_SIZE*100))
5148 local ITERATION=$((FILE_LENGTH/STRIDE_SIZE))
5149 # prepare the read-ahead file
5151 cancel_lru_locks osc
5152 for BIDX in 2 4 8 16 32 64 128 256
5154 local BSIZE=$((BIDX*4096))
5155 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
5156 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
5157 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
5158 $LCTL set_param -n llite.*.read_ahead_stats 0
5159 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
5160 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
5161 cancel_lru_locks osc
5167 run_test 101b "check stride-io mode read-ahead ================="
5170 local STRIPE_SIZE=1048576
5171 local FILE_LENGTH=$((STRIPE_SIZE*100))
5177 cancel_lru_locks osc
5178 $LCTL set_param osc.*.rpc_stats 0
5179 $READS -f $DIR/$tfile -s$FILE_LENGTH -b65536 -n$nreads -t 180
5180 for osc in $($LCTL get_param -N osc.*); do
5181 if [ "$osc" == "osc.num_refs" ]; then
5185 local lines=$($LCTL get_param -n ${osc}.rpc_stats | wc | awk '{print $1}')
5186 if [ $lines -le 20 ]; then
5190 local rpc4k=$($LCTL get_param -n ${osc}.rpc_stats |
5191 awk '$1 == "1:" { print $2; exit; }')
5192 local rpc8k=$($LCTL get_param -n ${osc}.rpc_stats |
5193 awk '$1 == "2:" { print $2; exit; }')
5194 local rpc16k=$($LCTL get_param -n ${osc}.rpc_stats |
5195 awk '$1 == "4:" { print $2; exit; }')
5196 local rpc32k=$($LCTL get_param -n ${osc}.rpc_stats |
5197 awk '$1 == "8:" { print $2; exit; }')
5199 [ $rpc4k != 0 ] && error "Small 4k read IO ${rpc4k}!"
5200 [ $rpc8k != 0 ] && error "Small 8k read IO ${rpc8k}!"
5201 [ $rpc16k != 0 ] && error "Small 16k read IO ${rpc16k}!"
5202 [ $rpc32k != 0 ] && error "Small 32k read IO ${rpc32k}!"
5203 echo "${osc} rpc check passed!"
5208 run_test 101c "check stripe_size aligned read-ahead ================="
5211 $LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1
5212 $LCTL set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
5216 local file=$DIR/$tfile
5217 local size=${FILESIZE_101c:-500}
5218 local ra_MB=${READAHEAD_MB:-40}
5220 local space=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
5221 [ $space -gt $((size / 1024)) ] ||
5222 { skip "Need free space ${size}M, have $space" && return; }
5224 echo Creating ${size}M test file $file
5225 dd if=/dev/zero of=$file bs=1M count=$size
5226 echo Cancel LRU locks on lustre client to flush the client cache
5227 cancel_lru_locks osc
5229 echo Disable read-ahead
5230 local old_READAHEAD=$(set_read_ahead 0)
5232 echo Reading the test file $file with read-ahead disabled
5233 time_ra_OFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$size")
5235 echo Cancel LRU locks on lustre client to flush the client cache
5236 cancel_lru_locks osc
5237 echo Enable read-ahead with ${ra_MB}MB
5238 set_read_ahead $ra_MB
5240 echo Reading the test file $file with read-ahead enabled
5241 time_ra_ON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$size")
5243 echo read-ahead disabled time read $time_ra_OFF
5244 echo read-ahead enabled time read $time_ra_ON
5246 set_read_ahead $old_READAHEAD
5249 [ $time_ra_ON -lt $time_ra_OFF ] ||
5250 error "read-ahead enabled time read (${time_ra_ON}s) is more than
5251 read-ahead disabled time read (${time_ra_OFF}s) filesize ${size}M"
5253 run_test 101d "file read with and without read-ahead enabled ================="
5256 local file=$DIR/$tfile
5261 local space=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
5262 local need_space=$((count * size))
5263 [ $space -gt $need_space ] ||
5264 { skip_env "Need free space $need_space, have $space" && return; }
5266 echo Creating $count ${size}K test files
5267 for ((i = 0; i < $count; i++)); do
5268 dd if=/dev/zero of=${file}_${i} bs=$blksize count=$size 2>/dev/null
5271 echo Cancel LRU locks on lustre client to flush the client cache
5272 cancel_lru_locks osc
5274 echo Reset readahead stats
5275 $LCTL set_param -n llite.*.read_ahead_stats 0
5277 for ((i = 0; i < $count; i++)); do
5278 dd if=${file}_${i} of=/dev/null bs=$blksize count=$size 2>/dev/null
5281 local miss=$($LCTL get_param -n llite.*.read_ahead_stats | \
5282 get_named_value 'misses' | cut -d" " -f1 | calc_total)
5284 for ((i = 0; i < $count; i++)); do
5285 rm -rf ${file}_${i} 2>/dev/null
5288 #10000 means 20% reads are missing in readahead
5289 [ $miss -lt 10000 ] || error "misses too much for small reads"
5291 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
5293 cleanup_test101f() {
5295 $LCTL set_param -n llite.*.max_read_ahead_whole_mb $MAX_WHOLE_MB
5296 rm -rf $DIR/$tfile 2>/dev/null
5300 local file=$DIR/$tfile
5303 MAX_WHOLE_MB=$($LCTL get_param -n llite.*.max_read_ahead_whole_mb)
5304 $LCTL set_param -n llite.*.max_read_ahead_whole_mb 2
5305 dd if=/dev/zero of=${file} bs=2097152 count=1 2>/dev/null
5306 trap cleanup_test101f EXIT
5308 echo Cancel LRU locks on lustre client to flush the client cache
5309 cancel_lru_locks osc
5311 echo Reset readahead stats
5312 $LCTL set_param -n llite.*.read_ahead_stats 0
5313 # Random read in a 2M file, because max_read_ahead_whole_mb = 2M,
5314 # readahead should read in 2M file on second read, so only miss
5316 echo Random 4K reads on 2M file for 1000 times
5317 $READS -f $file -s 2097152 -b 4096 -n $nreads
5319 echo checking missing pages
5320 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
5321 get_named_value 'misses' | cut -d" " -f1 | calc_total)
5323 [ $miss -lt 3 ] || error "misses too much pages!"
5326 run_test 101f "check read-ahead for max_read_ahead_whole_mb"
5330 chown $RUNAS_ID $DIR/$tdir
5333 STRIPE_COUNT=$OSTCOUNT
5334 [ $OSTCOUNT -gt 4 ] && STRIPE_COUNT=4
5336 trap cleanup_test102 EXIT
5338 $1 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
5340 for num in 1 2 3 4; do
5341 for count in $(seq 1 $STRIPE_COUNT); do
5342 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
5343 local size=`expr $STRIPE_SIZE \* $num`
5344 local file=file"$num-$idx-$count"
5345 $1 $SETSTRIPE -S $size -i $idx -c $count $file
5351 $1 $TAR cf $TMP/f102.tar $tdir --xattrs
5357 rm -rf $DIR/d0.sanity/d102
5361 local testfile=$DIR/xattr_testfile
5365 [ "$UID" != 0 ] && skip_env "must run as root" && return
5366 [ -z "`lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr`" ] &&
5367 skip_env "must have user_xattr" && return
5369 [ -z "$(which setfattr 2>/dev/null)" ] &&
5370 skip_env "could not find setfattr" && return
5372 echo "set/get xattr..."
5373 setfattr -n trusted.name1 -v value1 $testfile || error
5374 getfattr -n trusted.name1 $testfile 2> /dev/null |
5375 grep "trusted.name1=.value1" ||
5376 error "$testfile missing trusted.name1=value1"
5378 setfattr -n user.author1 -v author1 $testfile || error
5379 getfattr -n user.author1 $testfile 2> /dev/null |
5380 grep "user.author1=.author1" ||
5381 error "$testfile missing trusted.author1=author1"
5384 setfattr -n trusted.name2 -v value2 $testfile ||
5385 error "$testfile unable to set trusted.name2"
5386 setfattr -n trusted.name3 -v value3 $testfile ||
5387 error "$testfile unable to set trusted.name3"
5388 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
5389 grep "trusted.name" | wc -l) -eq 3 ] ||
5390 error "$testfile missing 3 trusted.name xattrs"
5392 setfattr -n user.author2 -v author2 $testfile ||
5393 error "$testfile unable to set user.author2"
5394 setfattr -n user.author3 -v author3 $testfile ||
5395 error "$testfile unable to set user.author3"
5396 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
5397 grep "user.author" | wc -l) -eq 3 ] ||
5398 error "$testfile missing 3 user.author xattrs"
5400 echo "remove xattr..."
5401 setfattr -x trusted.name1 $testfile ||
5402 error "$testfile error deleting trusted.name1"
5403 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
5404 error "$testfile did not delete trusted.name1 xattr"
5406 setfattr -x user.author1 $testfile ||
5407 error "$testfile error deleting user.author1"
5408 getfattr -d -m user $testfile 2> /dev/null | grep "user.author1" &&
5409 error "$testfile did not delete trusted.name1 xattr"
5411 # b10667: setting lustre special xattr be silently discarded
5412 echo "set lustre special xattr ..."
5413 setfattr -n "trusted.lov" -v "invalid value" $testfile ||
5414 error "$testfile allowed setting trusted.lov"
5416 run_test 102a "user xattr test =================================="
5419 # b10930: get/set/list trusted.lov xattr
5420 echo "get/set/list trusted.lov xattr ..."
5421 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
5422 local testfile=$DIR/$tfile
5423 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
5424 error "setstripe failed"
5425 local STRIPECOUNT=$($GETSTRIPE -c $testfile) ||
5426 error "getstripe failed"
5427 getfattr -d -m "^trusted" $testfile 2> /dev/null | \
5428 grep "trusted.lov" || error "can't get trusted.lov from $testfile"
5430 local testfile2=${testfile}2
5431 local value=`getfattr -n trusted.lov $testfile 2> /dev/null | \
5432 grep "trusted.lov" |sed -e 's/[^=]\+=//'`
5435 setfattr -n trusted.lov -v $value $testfile2
5436 local stripe_size=$($GETSTRIPE -S $testfile2)
5437 local stripe_count=$($GETSTRIPE -c $testfile2)
5438 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
5439 [ $stripe_count -eq $STRIPECOUNT ] ||
5440 error "stripe count $stripe_count != $STRIPECOUNT"
5443 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
5446 # b10930: get/set/list lustre.lov xattr
5447 echo "get/set/list lustre.lov xattr ..."
5448 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
5450 chown $RUNAS_ID $DIR/$tdir
5451 local testfile=$DIR/$tdir/$tfile
5452 $RUNAS $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
5453 error "setstripe failed"
5454 local STRIPECOUNT=$($RUNAS $GETSTRIPE -c $testfile) ||
5455 error "getstripe failed"
5456 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
5457 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
5459 local testfile2=${testfile}2
5460 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
5461 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
5463 $RUNAS $MCREATE $testfile2
5464 $RUNAS setfattr -n lustre.lov -v $value $testfile2
5465 local stripe_size=$($RUNAS $GETSTRIPE -S $testfile2)
5466 local stripe_count=$($RUNAS $GETSTRIPE -c $testfile2)
5467 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
5468 [ $stripe_count -eq $STRIPECOUNT ] ||
5469 error "stripe count $stripe_count != $STRIPECOUNT"
5471 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
5473 compare_stripe_info1() {
5474 local stripe_index_all_zero=true
5476 for num in 1 2 3 4; do
5477 for count in $(seq 1 $STRIPE_COUNT); do
5478 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
5479 local size=$((STRIPE_SIZE * num))
5480 local file=file"$num-$offset-$count"
5481 stripe_size=$(lfs getstripe -S $PWD/$file)
5482 [ $stripe_size -ne $size ] &&
5483 error "$file: size $stripe_size != $size"
5484 stripe_count=$(lfs getstripe -c $PWD/$file)
5485 # allow fewer stripes to be created, ORI-601
5486 [ $stripe_count -lt $(((3 * count + 3) / 4)) ]&&
5487 error "$file: count $stripe_count != $count"
5488 stripe_index=$(lfs getstripe -i $PWD/$file)
5489 [ $stripe_index -ne 0 ] &&
5490 stripe_index_all_zero=false
5494 $stripe_index_all_zero &&
5495 error "all files are being extracted starting from OST index 0"
5500 [ -n "$(which tar 2>/dev/null)" ] &&
5501 strings $(which tar) | grep -q "lustre" && echo tar
5505 # b10930: tar test for trusted.lov xattr
5506 TAR=$(find_lustre_tar)
5507 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
5508 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
5511 $TAR xf $TMP/f102.tar -C $DIR/d102d --xattrs
5513 compare_stripe_info1
5515 run_test 102d "tar restore stripe info from tarfile,not keep osts ==========="
5518 # b10930: tar test for trusted.lov xattr
5519 TAR=$(find_lustre_tar)
5520 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
5521 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
5525 $TAR cf - --xattrs $tdir | $TAR xf - --xattrs -C $DIR/d102f
5527 compare_stripe_info1
5529 run_test 102f "tar copy files, not keep osts ==========="
5532 local xsize=${1:-1024} # in bytes
5533 local file=$DIR/$tfile
5535 [ -z $(lctl get_param -n mdc.*.connect_flags | grep xattr) ] &&
5536 skip "must have user_xattr" && return 0
5537 [ -z "$(which setfattr 2>/dev/null)" ] &&
5538 skip_env "could not find setfattr" && return 0
5539 [ -z "$(which getfattr 2>/dev/null)" ] &&
5540 skip_env "could not find getfattr" && return 0
5544 local value="$(generate_string $xsize)"
5546 local xbig=trusted.big
5547 log "save $xbig on $file"
5548 setfattr -n $xbig -v $value $file ||
5549 error "saving $xbig on $file failed"
5551 local orig=$(get_xattr_value $xbig $file)
5552 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
5554 local xsml=trusted.sml
5555 log "save $xsml on $file"
5556 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
5558 local new=$(get_xattr_value $xbig $file)
5559 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
5561 log "grow $xsml on $file"
5562 setfattr -n $xsml -v "$value" $file ||
5563 error "growing $xsml on $file failed"
5565 new=$(get_xattr_value $xbig $file)
5566 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
5567 log "$xbig still valid after growing $xsml"
5572 test_102h() { # bug 15777
5575 run_test 102h "grow xattr from inside inode to external block"
5578 large_xattr_enabled || { skip "large_xattr disabled" && return; }
5579 grow_xattr $(max_xattr_size)
5581 run_test 102ha "grow xattr from inside inode to external inode"
5583 test_102i() { # bug 17038
5585 ln -s $DIR/$tfile $DIR/${tfile}link
5586 getfattr -n trusted.lov $DIR/$tfile || error "lgetxattr on $DIR/$tfile failed"
5587 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"
5588 rm -f $DIR/$tfile $DIR/${tfile}link
5590 run_test 102i "lgetxattr test on symbolic link ============"
5593 TAR=$(find_lustre_tar)
5594 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
5595 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
5596 setup_test102 "$RUNAS"
5598 chown $RUNAS_ID $DIR/d102j
5599 $RUNAS $TAR xf $TMP/f102.tar -C $DIR/d102j --xattrs
5601 compare_stripe_info1 "$RUNAS"
5603 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
5607 # b22187 just check that does not crash for regular file.
5608 setfattr -n trusted.lov $DIR/$tfile
5609 # b22187 'setfattr -n trusted.lov' should work as remove LOV EA for directories
5610 local test_kdir=$DIR/d102k
5612 local default_size=`$GETSTRIPE -S $test_kdir`
5613 local default_count=`$GETSTRIPE -c $test_kdir`
5614 local default_offset=`$GETSTRIPE -i $test_kdir`
5615 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $test_kdir ||
5616 error 'dir setstripe failed'
5617 setfattr -n trusted.lov $test_kdir
5618 local stripe_size=`$GETSTRIPE -S $test_kdir`
5619 local stripe_count=`$GETSTRIPE -c $test_kdir`
5620 local stripe_offset=`$GETSTRIPE -i $test_kdir`
5621 [ $stripe_size -eq $default_size ] ||
5622 error "stripe size $stripe_size != $default_size"
5623 [ $stripe_count -eq $default_count ] ||
5624 error "stripe count $stripe_count != $default_count"
5625 [ $stripe_offset -eq $default_offset ] ||
5626 error "stripe offset $stripe_offset != $default_offset"
5627 rm -rf $DIR/$tfile $test_kdir
5629 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
5632 # LU-532 trusted. xattr is invisible to non-root
5633 local testfile=$DIR/$tfile
5637 echo "listxattr as user..."
5638 chown $RUNAS_ID $testfile
5639 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
5640 grep -q "trusted" &&
5641 error "$testfile trusted xattrs are user visible"
5645 run_test 102l "listxattr filter test =================================="
5651 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
5656 [ "$UID" != 0 ] && skip_env "must run as root" && return
5657 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
5658 [ -z "$(which setfacl 2>/dev/null)" ] && skip_env "could not find setfacl" && return
5659 $GSS && skip "could not run under gss" && return
5661 declare -a identity_old
5663 for num in `seq $MDSCOUNT`; do
5664 switch_identity $num true || identity_old[$num]=$?
5671 echo "performing cp ..."
5672 run_acl_subtest cp || error
5673 echo "performing getfacl-noacl..."
5674 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
5675 echo "performing misc..."
5676 run_acl_subtest misc || error "misc test failed"
5677 echo "performing permissions..."
5678 run_acl_subtest permissions || error "permissions failed"
5679 echo "performing setfacl..."
5680 run_acl_subtest setfacl || error "setfacl test failed"
5682 # inheritance test got from HP
5683 echo "performing inheritance..."
5684 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
5685 chmod +x make-tree || error "chmod +x failed"
5686 run_acl_subtest inheritance || error "inheritance test failed"
5692 for num in `seq $MDSCOUNT`; do
5693 if [ "${identity_old[$num]}" = 1 ]; then
5694 switch_identity $num false || identity_old[$num]=$?
5698 run_test 103 "acl test ========================================="
5702 lfs df || error "lfs df failed"
5703 lfs df -ih || error "lfs df -ih failed"
5704 lfs df -h $DIR || error "lfs df -h $DIR failed"
5705 lfs df -i $DIR || error "lfs df -i $DIR failed"
5706 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
5707 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
5709 OSC=`lctl dl |grep OST0000-osc-[^M] |awk '{print $4}'`
5710 lctl --device %$OSC deactivate
5711 lfs df || error "lfs df with deactivated OSC failed"
5712 lctl --device %$OSC activate
5713 # wait the osc back to normal
5714 wait_osc_import_state client ost FULL
5716 lfs df || error "lfs df with reactivated OSC failed"
5719 run_test 104a "lfs df [-ih] [path] test ========================="
5722 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5724 denied_cnt=$((`$RUNAS $LFS check servers 2>&1 | grep "Permission denied" | wc -l`))
5725 if [ $denied_cnt -ne 0 ];
5727 error "lfs check servers test failed"
5730 run_test 104b "$RUNAS lfs check servers test ===================="
5733 # doesn't work on 2.4 kernels
5735 if [ -n "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ];
5737 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
5739 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
5743 run_test 105a "flock when mounted without -o flock test ========"
5747 if [ -n "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ];
5749 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
5751 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
5755 run_test 105b "fcntl when mounted without -o flock test ========"
5759 if [ -n "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ];
5761 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
5763 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
5767 run_test 105c "lockf when mounted without -o flock test ========"
5769 test_105d() { # bug 15924
5771 [ -z "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ] && \
5772 skip "mount w/o flock enabled" && return
5773 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
5774 $LCTL set_param fail_loc=0x80000315
5775 flocks_test 2 $DIR/$tdir
5777 run_test 105d "flock race (should not freeze) ========"
5779 test_105e() { # bug 22660 && 22040
5780 [ -z "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ] && \
5781 skip "mount w/o flock enabled" && return
5783 flocks_test 3 $DIR/$tfile
5785 run_test 105e "Two conflicting flocks from same process ======="
5787 test_106() { #bug 10921
5789 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
5790 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
5792 run_test 106 "attempt exec of dir followed by chown of that dir"
5801 local save_pattern=$(sysctl -n kernel.core_pattern)
5802 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
5803 sysctl -w kernel.core_pattern=$file
5804 sysctl -w kernel.core_uses_pid=0
5812 kill -s 11 $SLEEPPID
5814 if [ -e $file ]; then
5815 size=`stat -c%s $file`
5816 [ $size -eq 0 ] && error "Fail to create core file $file"
5818 error "Fail to create core file $file"
5821 sysctl -w kernel.core_pattern=$save_pattern
5822 sysctl -w kernel.core_uses_pid=$save_uses_pid
5825 run_test 107 "Coredump on SIG"
5829 mkdir $DIR/d110/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa || error "mkdir with 255 char fail"
5830 mkdir $DIR/d110/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb && error "mkdir with 256 char should fail, but not"
5831 touch $DIR/d110/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx || error "create with 255 char fail"
5832 touch $DIR/d110/yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy && error ""create with 256 char should fail, but not
5837 run_test 110 "filename length checking"
5840 OSTIO_pre=$(ps -e|grep ll_ost_io|awk '{print $4}'|sort -n|tail -1|\
5842 [ -z "$OSTIO_pre" ] && skip "no OSS threads" && \
5844 echo "Starting with $OSTIO_pre threads"
5847 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
5848 [ $NUMFREE -lt $NUMTEST ] && NUMTEST=$(($NUMFREE - 1000))
5849 echo "$NUMTEST creates/unlinks"
5851 createmany -o $DIR/$tdir/$tfile $NUMTEST
5852 unlinkmany $DIR/$tdir/$tfile $NUMTEST
5854 OSTIO_post=$(ps -e|grep ll_ost_io|awk '{print $4}'|sort -n|tail -1|\
5857 # don't return an error
5858 [ $OSTIO_post -eq $OSTIO_pre ] && echo \
5859 "WARNING: No new ll_ost_io threads were created ($OSTIO_pre)" &&\
5860 echo "This may be fine, depending on what ran before this test" &&\
5861 echo "and how fast this system is." && return
5863 echo "Started with $OSTIO_pre threads, ended with $OSTIO_post"
5865 run_test 115 "verify dynamic thread creation===================="
5868 wait_delete_completed
5869 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
5870 echo OST kbytes available: ${AVAIL[@]}
5871 MAXI=0; MAXV=${AVAIL[0]}
5872 MINI=0; MINV=${AVAIL[0]}
5873 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
5874 #echo OST $i: ${AVAIL[i]}kb
5875 if [ ${AVAIL[i]} -gt $MAXV ]; then
5876 MAXV=${AVAIL[i]}; MAXI=$i
5878 if [ ${AVAIL[i]} -lt $MINV ]; then
5879 MINV=${AVAIL[i]}; MINI=$i
5882 echo Min free space: OST $MINI: $MINV
5883 echo Max free space: OST $MAXI: $MAXV
5887 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs" && return
5889 echo -n "Free space priority "
5890 lctl get_param -n lov.*-clilov-*.qos_prio_free
5893 [ $MINV -gt 960000 ] && skip "too much free space in OST$MINI, skip" &&\
5896 # generate uneven OSTs
5897 mkdir -p $DIR/$tdir/OST${MINI}
5900 echo "Filling 25% remaining space in OST${MINI} with ${FILL}Kb"
5901 $SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI}||error "setstripe failed"
5903 while [ $FILL -gt 0 ]; do
5905 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i bs=2M count=1 2>/dev/null
5906 FILL=$(($FILL - 2048))
5914 DIFF=$(($MAXV - $MINV))
5915 DIFF2=$(($DIFF * 100 / $MINV))
5916 echo -n "diff=${DIFF}=${DIFF2}% must be > 20% for QOS mode..."
5917 if [ $DIFF2 -gt 20 ]; then
5920 echo "failed - QOS mode won't be used"
5921 error_ignore "QOS imbalance criteria not met"
5925 MINI1=$MINI; MINV1=$MINV
5926 MAXI1=$MAXI; MAXV1=$MAXV
5928 # now fill using QOS
5929 echo writing a bunch of files to QOS-assigned OSTs
5930 $SETSTRIPE -c 1 $DIR/$tdir
5932 while [ $FILL -gt 0 ]; do
5934 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1024 count=200 2>/dev/null
5935 FILL=$(($FILL - 200))
5938 echo "wrote $i 200k files"
5942 echo "Note: free space may not be updated, so measurements might be off"
5944 DIFF2=$(($MAXV - $MINV))
5945 echo "free space delta: orig $DIFF final $DIFF2"
5946 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
5947 DIFF=$(($MINV1 - ${AVAIL[$MINI1]}))
5948 echo "Wrote $DIFF to smaller OST $MINI1"
5949 DIFF2=$(($MAXV1 - ${AVAIL[$MAXI1]}))
5950 echo "Wrote $DIFF2 to larger OST $MAXI1"
5951 [ $DIFF -gt 0 ] && echo "Wrote $(($DIFF2 * 100 / $DIFF - 100))% more data to larger OST $MAXI1"
5953 # Figure out which files were written where
5954 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
5955 awk '/'$MINI1': / {print $2; exit}')
5957 MINC=$($GETSTRIPE --obd $UUID $DIR/$tdir | wc -l)
5958 echo "$MINC files created on smaller OST $MINI1"
5959 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
5960 awk '/'$MAXI1': / {print $2; exit}')
5962 MAXC=$($GETSTRIPE --obd $UUID $DIR/$tdir | wc -l)
5963 echo "$MAXC files created on larger OST $MAXI1"
5964 [ $MINC -gt 0 ] && echo "Wrote $(($MAXC * 100 / $MINC - 100))% more files to larger OST $MAXI1"
5965 [ $MAXC -gt $MINC ] || error_ignore "stripe QOS didn't balance free space"
5969 run_test 116 "stripe QOS: free space balance ==================="
5971 test_117() # bug 10891
5973 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
5974 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
5975 lctl set_param fail_loc=0x21e
5976 > $DIR/$tfile || error "truncate failed"
5977 lctl set_param fail_loc=0
5978 echo "Truncate succeeded."
5981 run_test 117 "verify fsfilt_extend =========="
5983 export OLD_RESENDCOUNT=""
5984 set_resend_count () {
5985 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
5986 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -1)
5987 lctl set_param -n $PROC_RESENDCOUNT $1
5988 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
5991 [ "$SLOW" = "no" ] && set_resend_count 4 # for reduce test_118* time (bug 14842)
5993 # Reset async IO behavior after error case
5995 FILE=$DIR/reset_async
5997 # Ensure all OSCs are cleared
5998 $SETSTRIPE -c -1 $FILE
5999 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
6004 test_118a() #bug 11710
6008 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6009 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6010 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
6012 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6013 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6018 run_test 118a "verify O_SYNC works =========="
6022 remote_ost_nodsh && skip "remote OST with nodsh" && return
6026 #define OBD_FAIL_OST_ENOENT 0x217
6027 set_nodes_failloc "$(osts_nodes)" 0x217
6028 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6030 set_nodes_failloc "$(osts_nodes)" 0
6031 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6032 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6035 if [[ $RC -eq 0 ]]; then
6036 error "Must return error due to dropped pages, rc=$RC"
6040 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6041 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6045 echo "Dirty pages not leaked on ENOENT"
6047 # Due to the above error the OSC will issue all RPCs syncronously
6048 # until a subsequent RPC completes successfully without error.
6049 $MULTIOP $DIR/$tfile Ow4096yc
6054 run_test 118b "Reclaim dirty pages on fatal error =========="
6058 remote_ost_nodsh && skip "remote OST with nodsh" && return
6062 #define OBD_FAIL_OST_EROFS 0x216
6063 set_nodes_failloc "$(osts_nodes)" 0x216
6065 # multiop should block due to fsync until pages are written
6066 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
6070 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
6071 error "Multiop failed to block on fsync, pid=$MULTIPID"
6074 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6076 if [[ $WRITEBACK -eq 0 ]]; then
6077 error "No page in writeback, writeback=$WRITEBACK"
6080 set_nodes_failloc "$(osts_nodes)" 0
6083 if [[ $RC -ne 0 ]]; then
6084 error "Multiop fsync failed, rc=$RC"
6087 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6088 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6090 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6091 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6095 echo "Dirty pages flushed via fsync on EROFS"
6098 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
6102 remote_ost_nodsh && skip "remote OST with nodsh" && return
6106 #define OBD_FAIL_OST_BRW_PAUSE_BULK
6107 set_nodes_failloc "$(osts_nodes)" 0x214
6108 # multiop should block due to fsync until pages are written
6109 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
6113 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
6114 error "Multiop failed to block on fsync, pid=$MULTIPID"
6117 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6119 if [[ $WRITEBACK -eq 0 ]]; then
6120 error "No page in writeback, writeback=$WRITEBACK"
6123 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
6124 set_nodes_failloc "$(osts_nodes)" 0
6126 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6127 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6129 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6130 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6134 echo "Dirty pages gaurenteed flushed via fsync"
6137 run_test 118d "Fsync validation inject a delay of the bulk =========="
6142 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
6143 lctl set_param fail_loc=0x8000040a
6145 # Should simulate EINVAL error which is fatal
6146 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6148 if [[ $RC -eq 0 ]]; then
6149 error "Must return error due to dropped pages, rc=$RC"
6152 lctl set_param fail_loc=0x0
6154 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6155 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6156 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6158 if [[ $LOCKED -ne 0 ]]; then
6159 error "Locked pages remain in cache, locked=$LOCKED"
6162 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6163 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6167 echo "No pages locked after fsync"
6172 run_test 118f "Simulate unrecoverable OSC side error =========="
6177 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
6178 lctl set_param fail_loc=0x406
6180 # simulate local -ENOMEM
6181 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6184 lctl set_param fail_loc=0
6185 if [[ $RC -eq 0 ]]; then
6186 error "Must return error due to dropped pages, rc=$RC"
6189 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6190 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6191 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6193 if [[ $LOCKED -ne 0 ]]; then
6194 error "Locked pages remain in cache, locked=$LOCKED"
6197 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6198 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6202 echo "No pages locked after fsync"
6207 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
6210 remote_ost_nodsh && skip "remote OST with nodsh" && return
6214 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
6215 set_nodes_failloc "$(osts_nodes)" 0x20e
6216 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
6217 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6220 set_nodes_failloc "$(osts_nodes)" 0
6221 if [[ $RC -eq 0 ]]; then
6222 error "Must return error due to dropped pages, rc=$RC"
6225 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6226 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6227 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6229 if [[ $LOCKED -ne 0 ]]; then
6230 error "Locked pages remain in cache, locked=$LOCKED"
6233 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6234 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6238 echo "No pages locked after fsync"
6242 run_test 118h "Verify timeout in handling recoverables errors =========="
6245 remote_ost_nodsh && skip "remote OST with nodsh" && return
6249 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
6250 set_nodes_failloc "$(osts_nodes)" 0x20e
6252 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
6253 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
6256 set_nodes_failloc "$(osts_nodes)" 0
6260 if [[ $RC -ne 0 ]]; then
6261 error "got error, but should be not, rc=$RC"
6264 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6265 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6266 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
6267 if [[ $LOCKED -ne 0 ]]; then
6268 error "Locked pages remain in cache, locked=$LOCKED"
6271 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6272 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6276 echo "No pages locked after fsync"
6280 run_test 118i "Fix error before timeout in recoverable error =========="
6283 remote_ost_nodsh && skip "remote OST with nodsh" && return
6287 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
6288 set_nodes_failloc "$(osts_nodes)" 0x220
6290 # return -EIO from OST
6291 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6293 set_nodes_failloc "$(osts_nodes)" 0x0
6294 if [[ $RC -eq 0 ]]; then
6295 error "Must return error due to dropped pages, rc=$RC"
6298 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6299 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6300 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
6301 if [[ $LOCKED -ne 0 ]]; then
6302 error "Locked pages remain in cache, locked=$LOCKED"
6305 # in recoverable error on OST we want resend and stay until it finished
6306 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6307 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6311 echo "No pages locked after fsync"
6315 run_test 118j "Simulate unrecoverable OST side error =========="
6319 remote_ost_nodsh && skip "remote OSTs with nodsh" && return
6321 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
6322 set_nodes_failloc "$(osts_nodes)" 0x20e
6325 for ((i=0;i<10;i++)); do
6326 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
6327 error "dd to $DIR/$tdir/$tfile-$i failed" )&
6334 set_nodes_failloc "$(osts_nodes)" 0
6337 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
6343 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
6346 run_test 118l "fsync dir ========="
6348 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
6350 test_119a() # bug 11737
6352 BSIZE=$((512 * 1024))
6353 directio write $DIR/$tfile 0 1 $BSIZE
6354 # We ask to read two blocks, which is more than a file size.
6355 # directio will indicate an error when requested and actual
6356 # sizes aren't equeal (a normal situation in this case) and
6357 # print actual read amount.
6358 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
6359 if [ "$NOB" != "$BSIZE" ]; then
6360 error "read $NOB bytes instead of $BSIZE"
6364 run_test 119a "Short directIO read must return actual read amount"
6366 test_119b() # bug 11737
6368 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
6370 $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
6371 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
6373 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) || \
6374 error "direct read failed"
6377 run_test 119b "Sparse directIO read must return actual read amount"
6379 test_119c() # bug 13099
6382 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
6383 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
6386 run_test 119c "Testing for direct read hitting hole"
6388 test_119d() # bug 15950
6390 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
6391 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
6393 $SETSTRIPE $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
6394 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
6395 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
6396 lctl set_param fail_loc=0x40d
6397 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
6400 cat $DIR/$tfile > /dev/null &
6401 lctl set_param fail_loc=0
6404 log "the DIO writes have completed, now wait for the reads (should not block very long)"
6406 [ -n "`ps h -p $pid_reads -o comm`" ] && \
6407 error "the read rpcs have not completed in 2s"
6409 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
6411 run_test 119d "The DIO path should try to send a new rpc once one is completed"
6415 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6416 skip "no early lock cancel on server" && return 0
6417 lru_resize_disable mdc
6418 lru_resize_disable osc
6419 cancel_lru_locks mdc
6420 stat $DIR/$tdir > /dev/null
6421 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6422 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6424 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6425 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6426 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6427 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6428 lru_resize_enable mdc
6429 lru_resize_enable osc
6431 run_test 120a "Early Lock Cancel: mkdir test"
6435 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6436 skip "no early lock cancel on server" && return 0
6437 lru_resize_disable mdc
6438 lru_resize_disable osc
6439 cancel_lru_locks mdc
6440 stat $DIR/$tdir > /dev/null
6441 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6442 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6444 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6445 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6446 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6447 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6448 lru_resize_enable mdc
6449 lru_resize_enable osc
6451 run_test 120b "Early Lock Cancel: create test"
6455 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6456 skip "no early lock cancel on server" && return 0
6457 lru_resize_disable mdc
6458 lru_resize_disable osc
6459 mkdir -p $DIR/$tdir/d1 $DIR/$tdir/d2
6460 touch $DIR/$tdir/d1/f1
6461 cancel_lru_locks mdc
6462 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
6463 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6464 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6465 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
6466 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6467 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6468 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6469 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6470 lru_resize_enable mdc
6471 lru_resize_enable osc
6473 run_test 120c "Early Lock Cancel: link test"
6477 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6478 skip "no early lock cancel on server" && return 0
6479 lru_resize_disable mdc
6480 lru_resize_disable osc
6482 cancel_lru_locks mdc
6483 stat $DIR/$tdir > /dev/null
6484 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6485 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6486 chmod a+x $DIR/$tdir
6487 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6488 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6489 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6490 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6491 lru_resize_enable mdc
6492 lru_resize_enable osc
6494 run_test 120d "Early Lock Cancel: setattr test"
6498 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6499 skip "no early lock cancel on server" && return 0
6500 lru_resize_disable mdc
6501 lru_resize_disable osc
6502 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
6503 cancel_lru_locks mdc
6504 cancel_lru_locks osc
6505 dd if=$DIR/$tdir/f1 of=/dev/null
6506 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
6507 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6508 awk '/ldlm_cancel/ {print $2}'`
6509 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6510 awk '/ldlm_bl_callback/ {print $2}'`
6511 unlink $DIR/$tdir/f1
6512 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6513 awk '/ldlm_cancel/ {print $2}'`
6514 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6515 awk '/ldlm_bl_callback/ {print $2}'`
6516 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6517 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6518 lru_resize_enable mdc
6519 lru_resize_enable osc
6521 run_test 120e "Early Lock Cancel: unlink test"
6524 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6525 skip "no early lock cancel on server" && return 0
6527 lru_resize_disable mdc
6528 lru_resize_disable osc
6529 mkdir -p $DIR/$tdir/d1 $DIR/$tdir/d2
6530 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
6531 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
6532 cancel_lru_locks mdc
6533 cancel_lru_locks osc
6534 dd if=$DIR/$tdir/d1/f1 of=/dev/null
6535 dd if=$DIR/$tdir/d2/f2 of=/dev/null
6536 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
6537 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6538 awk '/ldlm_cancel/ {print $2}'`
6539 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6540 awk '/ldlm_bl_callback/ {print $2}'`
6541 mv $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
6542 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6543 awk '/ldlm_cancel/ {print $2}'`
6544 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6545 awk '/ldlm_bl_callback/ {print $2}'`
6546 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6547 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6548 lru_resize_enable mdc
6549 lru_resize_enable osc
6551 run_test 120f "Early Lock Cancel: rename test"
6554 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6555 skip "no early lock cancel on server" && return 0
6556 lru_resize_disable mdc
6557 lru_resize_disable osc
6559 echo create $count files
6561 cancel_lru_locks mdc
6562 cancel_lru_locks osc
6565 can0=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6566 awk '/ldlm_cancel/ {print $2}'`
6567 blk0=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6568 awk '/ldlm_bl_callback/ {print $2}'`
6569 createmany -o $DIR/$tdir/f $count
6571 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6572 awk '/ldlm_cancel/ {print $2}'`
6573 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6574 awk '/ldlm_bl_callback/ {print $2}'`
6576 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
6577 echo rm $count files
6580 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6581 awk '/ldlm_cancel/ {print $2}'`
6582 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6583 awk '/ldlm_bl_callback/ {print $2}'`
6585 echo total: $count removes in $((t2-t1))
6586 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
6588 # wait for commitment of removal
6589 lru_resize_enable mdc
6590 lru_resize_enable osc
6592 run_test 120g "Early Lock Cancel: performance test"
6594 test_121() { #bug #10589
6596 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
6597 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
6598 lctl set_param fail_loc=0x310
6599 cancel_lru_locks osc > /dev/null
6600 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
6601 lctl set_param fail_loc=0
6602 [ "$reads" -eq "$writes" ] || error "read" $reads "blocks, must be" $writes
6604 run_test 121 "read cancel race ========="
6606 test_123a() { # was test 123, statahead(bug 11401)
6608 if [ -z "$(grep "processor.*: 1" /proc/cpuinfo)" ]; then
6609 log "testing on UP system. Performance may be not as good as expected."
6615 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
6616 [ $NUMFREE -gt 100000 ] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
6618 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
6619 createmany -o $DIR/$tdir/$tfile $j $((i - j))
6621 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
6622 lctl set_param -n llite.*.statahead_max 0
6623 lctl get_param llite.*.statahead_max
6624 cancel_lru_locks mdc
6625 cancel_lru_locks osc
6627 time ls -l $DIR/$tdir | wc -l
6629 delta=$((etime - stime))
6630 log "ls $i files without statahead: $delta sec"
6631 lctl set_param llite.*.statahead_max=$max
6633 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
6634 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
6635 cancel_lru_locks mdc
6636 cancel_lru_locks osc
6638 time ls -l $DIR/$tdir | wc -l
6640 delta_sa=$((etime - stime))
6641 log "ls $i files with statahead: $delta_sa sec"
6642 lctl get_param -n llite.*.statahead_stats
6643 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
6645 [ $swrong -lt $ewrong ] && log "statahead was stopped, maybe too many locks held!"
6646 [ $delta -eq 0 -o $delta_sa -eq 0 ] && continue
6648 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
6649 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
6650 lctl set_param -n llite.*.statahead_max 0
6651 lctl get_param llite.*.statahead_max
6652 cancel_lru_locks mdc
6653 cancel_lru_locks osc
6655 time ls -l $DIR/$tdir | wc -l
6657 delta=$((etime - stime))
6658 log "ls $i files again without statahead: $delta sec"
6659 lctl set_param llite.*.statahead_max=$max
6660 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
6661 if [ $SLOWOK -eq 0 ]; then
6662 error "ls $i files is slower with statahead!"
6664 log "ls $i files is slower with statahead!"
6670 [ $delta -gt 20 ] && break
6671 [ $delta -gt 8 ] && MULT=$((50 / delta))
6672 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
6680 delta=$((etime - stime))
6681 log "rm -r $DIR/$tdir/: $delta seconds"
6683 lctl get_param -n llite.*.statahead_stats
6685 run_test 123a "verify statahead work"
6687 test_123b () { # statahead(bug 15027)
6689 createmany -o $DIR/$tdir/$tfile-%d 1000
6691 cancel_lru_locks mdc
6692 cancel_lru_locks osc
6694 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
6695 lctl set_param fail_loc=0x80000803
6696 ls -lR $DIR/$tdir > /dev/null
6698 lctl set_param fail_loc=0x0
6699 lctl get_param -n llite.*.statahead_stats
6704 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
6707 [ -z "`lctl get_param -n mdc.*.connect_flags | grep lru_resize`" ] && \
6708 skip "no lru resize on server" && return 0
6710 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
6712 log "create $NR files at $DIR/$tdir"
6713 createmany -o $DIR/$tdir/f $NR ||
6714 error "failed to create $NR files in $DIR/$tdir"
6716 cancel_lru_locks mdc
6717 ls -l $DIR/$tdir > /dev/null
6721 for VALUE in `lctl get_param ldlm.namespaces.*mdc-*.lru_size`; do
6722 local PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
6723 LRU_SIZE=$(lctl get_param -n $PARAM)
6724 if [ $LRU_SIZE -gt $(default_lru_size) ]; then
6725 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
6727 log "NS=$(basename $NSDIR)"
6732 if [ -z "$NSDIR" -o $LRU_SIZE -lt $(default_lru_size) ]; then
6733 skip "Not enough cached locks created!"
6740 # We know that lru resize allows one client to hold $LIMIT locks
6741 # for 10h. After that locks begin to be killed by client.
6743 local LIMIT=`lctl get_param -n $NSDIR.pool.limit`
6746 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
6747 # killing locks. Some time was spent for creating locks. This means
6748 # that up to the moment of sleep finish we must have killed some of
6749 # them (10-100 locks). This depends on how fast ther were created.
6750 # Many of them were touched in almost the same moment and thus will
6751 # be killed in groups.
6752 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
6754 # Use $LRU_SIZE_B here to take into account real number of locks
6755 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
6756 local LRU_SIZE_B=$LRU_SIZE
6758 local OLD_LVF=`lctl get_param -n $NSDIR.pool.lock_volume_factor`
6759 log "OLD_LVF=$OLD_LVF"
6760 lctl set_param -n $NSDIR.pool.lock_volume_factor $LVF
6762 # Let's make sure that we really have some margin. Client checks
6763 # cached locks every 10 sec.
6765 log "Sleep ${SLEEP} sec"
6767 while ((SEC<$SLEEP)); do
6771 LRU_SIZE=`lctl get_param -n $NSDIR/lru_size`
6775 lctl set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
6776 local LRU_SIZE_A=`lctl get_param -n $NSDIR.lru_size`
6778 [ $LRU_SIZE_B -gt $LRU_SIZE_A ] || {
6779 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
6780 unlinkmany $DIR/$tdir/f $NR
6784 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
6785 log "unlink $NR files at $DIR/$tdir"
6786 unlinkmany $DIR/$tdir/f $NR
6788 run_test 124a "lru resize ======================================="
6790 get_max_pool_limit()
6792 local limit=`lctl get_param -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit`
6795 if test $l -gt $max; then
6803 [ -z "`lctl get_param -n mdc.*.connect_flags | grep lru_resize`" ] && \
6804 skip "no lru resize on server" && return 0
6806 LIMIT=`get_max_pool_limit`
6808 NR=$(($(default_lru_size)*20))
6809 if [ $NR -gt $LIMIT ]; then
6810 log "Limit lock number by $LIMIT locks"
6813 lru_resize_disable mdc
6814 mkdir -p $DIR/$tdir/disable_lru_resize ||
6815 error "failed to create $DIR/$tdir/disable_lru_resize"
6817 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
6818 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
6819 cancel_lru_locks mdc
6822 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
6825 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
6828 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
6832 nolruresize_delta=$((etime-stime))
6833 log "ls -la time: $nolruresize_delta seconds"
6834 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
6835 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
6837 lru_resize_enable mdc
6838 mkdir -p $DIR/$tdir/enable_lru_resize ||
6839 error "failed to create $DIR/$tdir/enable_lru_resize"
6841 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
6842 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
6843 cancel_lru_locks mdc
6846 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
6849 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
6852 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
6856 lruresize_delta=$((etime-stime))
6857 log "ls -la time: $lruresize_delta seconds"
6858 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
6860 if [ $lruresize_delta -gt $nolruresize_delta ]; then
6861 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
6862 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
6863 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
6865 log "lru resize performs the same with no lru resize"
6867 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
6869 run_test 124b "lru resize (performance test) ======================="
6871 test_125() { # 13358
6872 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
6873 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
6874 mkdir -p $DIR/d125 || error "mkdir failed"
6875 $SETSTRIPE -S 65536 -c -1 $DIR/d125 || error "setstripe failed"
6876 setfacl -R -m u:bin:rwx $DIR/d125 || error "setfacl $DIR/d125 failed"
6877 ls -ld $DIR/d125 || error "cannot access $DIR/d125"
6879 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
6881 test_126() { # bug 12829/13455
6882 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
6883 [ "$UID" != 0 ] && skip_env "skipping $TESTNAME (must run as root)" && return
6884 $GSS && skip "must run as gss disabled" && return
6886 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
6887 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
6889 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
6891 run_test 126 "check that the fsgid provided by the client is taken into account"
6893 test_127a() { # bug 15521
6894 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
6895 $LCTL set_param osc.*.stats=0
6896 FSIZE=$((2048 * 1024))
6897 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
6898 cancel_lru_locks osc
6899 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
6901 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
6902 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
6903 echo "got $COUNT $NAME"
6904 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
6905 eval $NAME=$COUNT || error "Wrong proc format"
6908 read_bytes|write_bytes)
6909 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
6910 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
6911 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
6912 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
6913 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
6914 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
6915 error "sumsquare is too small: $SUMSQ"
6916 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
6917 error "sumsquare is too big: $SUMSQ"
6921 done < $DIR/${tfile}.tmp
6923 #check that we actually got some stats
6924 [ "$read_bytes" ] || error "Missing read_bytes stats"
6925 [ "$write_bytes" ] || error "Missing write_bytes stats"
6926 [ "$read_bytes" != 0 ] || error "no read done"
6927 [ "$write_bytes" != 0 ] || error "no write done"
6929 run_test 127a "verify the client stats are sane"
6931 test_127b() { # bug LU-333
6932 $LCTL set_param llite.*.stats=0
6933 FSIZE=65536 # sized fixed to match PAGE_SIZE for most clients
6934 # perform 2 reads and writes so MAX is different from SUM.
6935 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
6936 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
6937 cancel_lru_locks osc
6938 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
6939 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
6941 $LCTL get_param llite.*.stats | grep samples > $TMP/${tfile}.tmp
6942 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
6943 echo "got $COUNT $NAME"
6944 eval $NAME=$COUNT || error "Wrong proc format"
6948 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
6949 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
6950 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
6951 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
6954 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
6955 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
6956 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
6957 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
6961 done < $TMP/${tfile}.tmp
6963 #check that we actually got some stats
6964 [ "$read_bytes" ] || error "Missing read_bytes stats"
6965 [ "$write_bytes" ] || error "Missing write_bytes stats"
6966 [ "$read_bytes" != 0 ] || error "no read done"
6967 [ "$write_bytes" != 0 ] || error "no write done"
6969 run_test 127b "verify the llite client stats are sane"
6971 test_128() { # bug 15212
6973 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
6978 result=$(grep error $TMP/$tfile.log)
6980 [ -z "$result" ] || error "consecutive find's under interactive lfs failed"
6982 run_test 128 "interactive lfs for 2 consecutive find's"
6989 local LDPROC=/proc/fs/ldiskfs
6991 for facet in $(get_facets MDS); do
6992 canondev=$(ldiskfs_canon *.$(convert_facet2label $facet).mntdev $facet)
6993 do_facet $facet "test -e $LDPROC/$canondev/max_dir_size" || LDPROC=/sys/fs/ldiskfs
6994 do_facet $facet "echo $1 >$LDPROC/$canondev/max_dir_size"
6998 if [ "$(facet_type_fstype MDS)" != ldiskfs ]; then
6999 skip "Only applicable to ldiskfs-based MDTs"
7002 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7013 while [ ! $I -gt $((MAX * MDSCOUNT)) ]; do
7014 $MULTIOP $DIR/$tdir/$J Oc
7016 if [ $rc -eq $EFBIG ]; then
7018 echo "return code $rc received as expected"
7020 elif [ $rc -ne 0 ]; then
7022 error_exit "return code $rc received instead of expected $EFBIG"
7025 I=$(stat -c%s "$DIR/$tdir")
7029 error "exceeded dir size limit $MAX x $MDSCOUNT $((MAX * MDSCOUNT)) : $I bytes"
7031 run_test 129 "test directory size limit ========================"
7040 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7041 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
7043 trap cleanup_130 EXIT RETURN
7045 local fm_file=$DIR/$tfile
7046 $SETSTRIPE -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
7047 dd if=/dev/zero of=$fm_file bs=65536 count=1 || error "dd failed for $fm_file"
7049 filefrag -ves $fm_file || error "filefrag $fm_file failed"
7050 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
7052 lun=$($GETSTRIPE -i $fm_file)
7054 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
7057 for line in $filefrag_op
7059 frag_lun=`echo $line | cut -d: -f5`
7060 ext_len=`echo $line | cut -d: -f4`
7061 if (( $frag_lun != $lun )); then
7063 error "FIEMAP on 1-stripe file($fm_file) failed"
7066 (( tot_len += ext_len ))
7069 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
7071 error "FIEMAP on 1-stripe file($fm_file) failed;"
7077 echo "FIEMAP on single striped file succeeded"
7079 run_test 130a "FIEMAP (1-stripe file)"
7082 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping FIEMAP on 2-stripe file test" && return
7084 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7085 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
7087 trap cleanup_130 EXIT RETURN
7089 local fm_file=$DIR/$tfile
7090 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
7091 dd if=/dev/zero of=$fm_file bs=1M count=2 || error "dd failed on $fm_file"
7093 filefrag -ves $fm_file || error "filefrag $fm_file failed"
7094 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
7096 last_lun=`echo $filefrag_op | cut -d: -f5`
7101 for line in $filefrag_op
7103 frag_lun=`echo $line | cut -d: -f5`
7104 ext_len=`echo $line | cut -d: -f4`
7105 if (( $frag_lun != $last_lun )); then
7106 if (( tot_len != 1024 )); then
7108 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 256"
7115 (( tot_len += ext_len ))
7118 if (( num_luns != 2 || tot_len != 1024 )); then
7120 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
7126 echo "FIEMAP on 2-stripe file succeeded"
7128 run_test 130b "FIEMAP (2-stripe file)"
7131 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping FIEMAP on 2-stripe file with hole test" && return
7133 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7134 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
7136 trap cleanup_130 EXIT RETURN
7138 local fm_file=$DIR/$tfile
7139 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
7140 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 || error "dd failed on $fm_file"
7142 filefrag -ves $fm_file || error "filefrag $fm_file failed"
7143 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
7145 last_lun=`echo $filefrag_op | cut -d: -f5`
7150 for line in $filefrag_op
7152 frag_lun=`echo $line | cut -d: -f5`
7153 ext_len=`echo $line | cut -d: -f4`
7154 if (( $frag_lun != $last_lun )); then
7155 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
7156 if (( logical != 512 )); then
7158 error "FIEMAP on $fm_file failed; returned logical start for lun $logical instead of 512"
7161 if (( tot_len != 512 )); then
7163 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
7170 (( tot_len += ext_len ))
7173 if (( num_luns != 2 || tot_len != 512 )); then
7175 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
7181 echo "FIEMAP on 2-stripe file with hole succeeded"
7183 run_test 130c "FIEMAP (2-stripe file with hole)"
7186 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping FIEMAP on N-stripe file test" && return
7188 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7189 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
7191 trap cleanup_130 EXIT RETURN
7193 local fm_file=$DIR/$tfile
7194 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file||error "setstripe on $fm_file"
7195 dd if=/dev/zero of=$fm_file bs=1M count=$OSTCOUNT || error "dd failed on $fm_file"
7197 filefrag -ves $fm_file || error "filefrag $fm_file failed"
7198 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
7200 last_lun=`echo $filefrag_op | cut -d: -f5`
7205 for line in $filefrag_op
7207 frag_lun=`echo $line | cut -d: -f5`
7208 ext_len=`echo $line | cut -d: -f4`
7209 if (( $frag_lun != $last_lun )); then
7210 if (( tot_len != 1024 )); then
7212 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
7219 (( tot_len += ext_len ))
7222 if (( num_luns != OSTCOUNT || tot_len != 1024 )); then
7224 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
7230 echo "FIEMAP on N-stripe file succeeded"
7232 run_test 130d "FIEMAP (N-stripe file)"
7235 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping continuation FIEMAP test" && return
7237 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7238 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
7240 trap cleanup_130 EXIT RETURN
7242 local fm_file=$DIR/$tfile
7243 $SETSTRIPE -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
7245 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
7246 for ((i = 0; i < $NUM_BLKS; i++))
7248 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
7251 filefrag -ves $fm_file || error "filefrag $fm_file failed"
7252 filefrag_op=`filefrag -ve $fm_file | grep -A 12000 "ext:" | grep -v "ext:" | grep -v "found"`
7254 last_lun=`echo $filefrag_op | cut -d: -f5`
7259 for line in $filefrag_op
7261 frag_lun=`echo $line | cut -d: -f5`
7262 ext_len=`echo $line | cut -d: -f4`
7263 if (( $frag_lun != $last_lun )); then
7264 if (( tot_len != $EXPECTED_LEN )); then
7266 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of $EXPECTED_LEN"
7273 (( tot_len += ext_len ))
7276 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
7278 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
7284 echo "FIEMAP with continuation calls succeeded"
7286 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
7288 # Test for writev/readv
7290 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 || \
7291 error "writev test failed"
7292 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 || \
7293 error "readv failed"
7296 run_test 131a "test iov's crossing stripe boundary for writev/readv"
7299 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 || \
7300 error "append writev test failed"
7301 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 || \
7302 error "append writev test failed"
7305 run_test 131b "test append writev"
7308 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
7311 run_test 131c "test read/write on file w/o objects"
7314 rwv -f $DIR/$tfile -w -n 1 1572864
7315 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
7316 if [ "$NOB" != 1572864 ]; then
7317 error "Short read filed: read $NOB bytes instead of 1572864"
7321 run_test 131d "test short read"
7324 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
7325 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
7326 error "read hitting hole failed"
7329 run_test 131e "test read hitting hole"
7334 for node in $(osts_nodes); do
7335 gl=$(do_node $node "$LCTL get_param -n ost.OSS.ost.stats" | awk '/'$token'/ {print $2}' | head -n 1)
7336 [ x$gl = x"" ] && gl=0
7337 gl_sum=$((gl_sum + gl))
7347 if [ x$som = x"enabled" ]; then
7348 [ $((gl2 - gl1)) -gt 0 ] && error "no glimpse RPC is expected"
7349 MOUNTOPT=`echo $MOUNTOPT | sed 's/som_preview//g'`
7350 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=disabled"
7352 [ $((gl2 - gl1)) -gt 0 ] || error "some glimpse RPC is expected"
7353 MOUNTOPT="$MOUNTOPT,som_preview"
7354 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=enabled"
7357 # do remount to make new mount-conf parameters actual
7364 test_132() { #1028, SOM
7365 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7366 local num=$(get_mds_dir $DIR)
7367 local mymds=mds${num}
7368 local MOUNTOPT_SAVE=$MOUNTOPT
7370 dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
7371 cancel_lru_locks osc
7373 som1=$(do_facet $mymds "$LCTL get_param mdt.*.som" | awk -F= ' {print $2}' | head -n 1)
7375 gl1=$(get_ost_param "ldlm_glimpse_enqueue")
7376 stat $DIR/$tfile >/dev/null
7377 gl2=$(get_ost_param "ldlm_glimpse_enqueue")
7378 echo "====> SOM is "$som1", "$((gl2 - gl1))" glimpse RPC occured"
7380 som_mode_switch $som1 $gl1 $gl2
7382 dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
7383 cancel_lru_locks osc
7385 som2=$(do_facet $mymds "$LCTL get_param mdt.*.som" | awk -F= ' {print $2}' | head -n 1)
7386 if [ $som1 == $som2 ]; then
7387 error "som is still "$som2
7388 if [ x$som2 = x"enabled" ]; then
7395 gl1=$(get_ost_param "ldlm_glimpse_enqueue")
7396 stat $DIR/$tfile >/dev/null
7397 gl2=$(get_ost_param "ldlm_glimpse_enqueue")
7398 echo "====> SOM is "$som2", "$((gl2 - gl1))" glimpse RPC occured"
7399 som_mode_switch $som2 $gl1 $gl2
7400 MOUNTOPT=$MOUNTOPT_SAVE
7402 run_test 132 "som avoids glimpse rpc"
7408 $SINGLEMDS) res=`do_facet $SINGLEMDS $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$2"`
7410 ost) res=`do_facet ost1 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$2"`
7412 *) error "Wrong argument $1" ;;
7415 count=`echo $res | awk '{print $2}'`
7416 [ -z "$res" ] && error "The counter for $2 on $1 was not incremented"
7417 # if the argument $3 is zero, it means any stat increment is ok.
7418 if [ $3 -gt 0 ] ; then
7419 [ $count -ne $3 ] && error "The $2 counter on $1 is wrong - expected $3"
7424 remote_ost_nodsh && skip "remote OST with nodsh" && return
7425 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7427 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
7428 { skip "MDS doesn't support rename stats"; return; }
7429 local testdir=$DIR/${tdir}/stats_testdir
7430 mkdir -p $DIR/${tdir}
7433 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
7434 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
7436 # verify mdt stats first.
7437 mkdir ${testdir} || error "mkdir failed"
7438 check_stats $SINGLEMDS "mkdir" 1
7439 touch ${testdir}/${tfile} || "touch failed"
7440 check_stats $SINGLEMDS "open" 1
7441 check_stats $SINGLEMDS "close" 1
7442 mknod ${testdir}/${tfile}-pipe p || "mknod failed"
7443 check_stats $SINGLEMDS "mknod" 1
7444 rm -f ${testdir}/${tfile}-pipe || "pipe remove failed"
7445 check_stats $SINGLEMDS "unlink" 1
7446 rm -f ${testdir}/${tfile} || error "file remove failed"
7447 check_stats $SINGLEMDS "unlink" 2
7449 # remove working dir and check mdt stats again.
7450 rmdir ${testdir} || error "rmdir failed"
7451 check_stats $SINGLEMDS "rmdir" 1
7453 local testdir1=$DIR/${tdir}/stats_testdir1
7455 mkdir -p ${testdir1}
7456 touch ${testdir1}/test1
7457 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
7458 check_stats $SINGLEMDS "crossdir_rename" 1
7460 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
7461 check_stats $SINGLEMDS "samedir_rename" 1
7465 run_test 133a "Verifying MDT stats ========================================"
7468 remote_ost_nodsh && skip "remote OST with nodsh" && return
7469 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7470 local testdir=$DIR/${tdir}/stats_testdir
7471 mkdir -p ${testdir} || error "mkdir failed"
7472 touch ${testdir}/${tfile} || "touch failed"
7473 cancel_lru_locks mdc
7476 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
7477 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
7479 # extra mdt stats verification.
7480 chmod 444 ${testdir}/${tfile} || error "chmod failed"
7481 check_stats $SINGLEMDS "setattr" 1
7482 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
7483 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
7484 check_stats $SINGLEMDS "getattr" 1
7485 $LFS df || error "lfs failed"
7486 check_stats $SINGLEMDS "statfs" 1
7490 run_test 133b "Verifying extra MDT stats =================================="
7493 remote_ost_nodsh && skip "remote OST with nodsh" && return
7494 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7495 local testdir=$DIR/${tdir}/stats_testdir
7496 mkdir -p ${testdir} || error "mkdir failed"
7498 # verify obdfilter stats.
7499 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
7501 cancel_lru_locks osc
7504 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
7505 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
7507 dd if=/dev/zero of=${testdir}/${tfile} conv=notrunc bs=512k count=1 || error "dd failed"
7509 cancel_lru_locks osc
7510 check_stats ost "write" 1
7512 dd if=${testdir}/${tfile} of=/dev/null bs=1k count=1 || error "dd failed"
7513 check_stats ost "read" 1
7515 > ${testdir}/${tfile} || error "truncate failed"
7516 check_stats ost "punch" 1
7518 rm -f ${testdir}/${tfile} || error "file remove failed"
7519 check_stats ost "destroy" 1
7523 run_test 133c "Verifying OST stats ========================================"
7530 while [ $value -ge 2 ]; do
7535 if [ $orig -gt $order ]; then
7543 local size=('K' 'M' 'G' 'T');
7545 local size_string=$value
7547 while [ $value -ge 1024 ]; do
7548 if [ $i -gt 3 ]; then
7549 #T is the biggest unit we get here, if that is bigger,
7551 size_string=${value}T
7554 value=$((value >> 10))
7555 if [ $value -lt 1024 ]; then
7556 size_string=${value}${size[$i]}
7567 local sample=$(do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats |
7568 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
7573 remote_ost_nodsh && skip "remote OST with nodsh" && return
7574 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7575 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
7576 { skip "MDS doesn't support rename stats"; return; }
7578 local testdir1=$DIR/${tdir}/stats_testdir1
7579 local testdir2=$DIR/${tdir}/stats_testdir2
7581 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
7583 mkdir -p ${testdir1} || error "mkdir failed"
7584 mkdir -p ${testdir2} || error "mkdir failed"
7586 createmany -o $testdir1/test 512 || error "createmany failed"
7588 # check samedir rename size
7589 mv ${testdir1}/test0 ${testdir1}/test_0
7591 local testdir1_size=$(ls -l $DIR/${tdir} |
7592 awk '/stats_testdir1/ {print $5}')
7593 local testdir2_size=$(ls -l $DIR/${tdir} |
7594 awk '/stats_testdir2/ {print $5}')
7596 testdir1_size=$(order_2 $testdir1_size)
7597 testdir2_size=$(order_2 $testdir2_size)
7599 testdir1_size=$(size_in_KMGT $testdir1_size)
7600 testdir2_size=$(size_in_KMGT $testdir2_size)
7602 echo "source rename dir size: ${testdir1_size}"
7603 echo "target rename dir size: ${testdir2_size}"
7605 local cmd="do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats"
7606 eval $cmd || error "$cmd failed"
7607 local samedir=$($cmd | grep 'same_dir')
7608 local same_sample=$(get_rename_size $testdir1_size)
7609 [ -z "$samedir" ] && error "samedir_rename_size count error"
7610 [ "$same_sample" -eq 1 ] || error "samedir_rename_size error $same_sample"
7611 echo "Check same dir rename stats success"
7613 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
7615 # check crossdir rename size
7616 mv ${testdir1}/test_0 ${testdir2}/test_0
7618 testdir1_size=$(ls -l $DIR/${tdir} |
7619 awk '/stats_testdir1/ {print $5}')
7620 testdir2_size=$(ls -l $DIR/${tdir} |
7621 awk '/stats_testdir2/ {print $5}')
7623 testdir1_size=$(order_2 $testdir1_size)
7624 testdir2_size=$(order_2 $testdir2_size)
7626 testdir1_size=$(size_in_KMGT $testdir1_size)
7627 testdir2_size=$(size_in_KMGT $testdir2_size)
7629 echo "source rename dir size: ${testdir1_size}"
7630 echo "target rename dir size: ${testdir2_size}"
7632 eval $cmd || error "$cmd failed"
7633 local crossdir=$($cmd | grep 'crossdir')
7634 local src_sample=$(get_rename_size $testdir1_size)
7635 local tgt_sample=$(get_rename_size $testdir2_size)
7636 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
7637 [ "$src_sample" -eq 1 ] || error "crossdir_rename_size error $src_sample"
7638 [ "$tgt_sample" -eq 1 ] || error "crossdir_rename_size error $tgt_sample"
7639 echo "Check cross dir rename stats success"
7642 run_test 133d "Verifying rename_stats ========================================"
7644 test_140() { #bug-17379
7645 mkdir -p $DIR/$tdir || error "Creating dir $DIR/$tdir"
7646 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
7647 cp /usr/bin/stat . || error "Copying stat to $DIR/$tdir"
7649 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
7651 while i=`expr $i + 1`; do
7652 mkdir -p $i || error "Creating dir $i"
7653 cd $i || error "Changing to $i"
7654 ln -s ../stat stat || error "Creating stat symlink"
7655 # Read the symlink until ELOOP present,
7656 # not LBUGing the system is considered success,
7657 # we didn't overrun the stack.
7658 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
7660 if [ $ret -eq 40 ]; then
7663 error "Open stat symlink"
7669 echo "The symlink depth = $i"
7670 [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 ] || error "Invalid symlink depth"
7672 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
7675 local TF="$TMP/$tfile"
7677 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
7679 cancel_lru_locks osc
7680 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
7681 remount_client $MOUNT
7683 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
7686 $TRUNCATE $DIR/$tfile 6000
7687 cancel_lru_locks osc
7688 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
7691 echo "12345" >>$DIR/$tfile
7692 cancel_lru_locks osc
7693 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
7696 echo "12345" >>$DIR/$tfile
7697 cancel_lru_locks osc
7698 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
7703 run_test 150 "truncate/append tests"
7705 function roc_hit() {
7706 local list=$(comma_list $(osts_nodes))
7708 echo $(get_obdfilter_param $list '' stats |
7709 awk '/'cache_hit'/ {sum+=$2} END {print sum}')
7712 function set_cache() {
7715 if [ "$2" == "off" ]; then
7718 local list=$(comma_list $(osts_nodes))
7719 set_obdfilter_param $list '' $1_cache_enable $on
7721 cancel_lru_locks osc
7725 remote_ost_nodsh && skip "remote OST with nodsh" && return
7728 local list=$(comma_list $(osts_nodes))
7730 # check whether obdfilter is cache capable at all
7731 if ! get_obdfilter_param $list '' read_cache_enable >/dev/null; then
7732 echo "not cache-capable obdfilter"
7736 # check cache is enabled on all obdfilters
7737 if get_obdfilter_param $list '' read_cache_enable | grep 0; then
7738 echo "oss cache is disabled"
7742 set_obdfilter_param $list '' writethrough_cache_enable 1
7744 # pages should be in the case right after write
7745 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES || error "dd failed"
7746 local BEFORE=`roc_hit`
7747 cancel_lru_locks osc
7748 cat $DIR/$tfile >/dev/null
7749 local AFTER=`roc_hit`
7750 if ! let "AFTER - BEFORE == CPAGES"; then
7751 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
7754 # the following read invalidates the cache
7755 cancel_lru_locks osc
7756 set_obdfilter_param $list '' read_cache_enable 0
7757 cat $DIR/$tfile >/dev/null
7759 # now data shouldn't be found in the cache
7761 cancel_lru_locks osc
7762 cat $DIR/$tfile >/dev/null
7764 if let "AFTER - BEFORE != 0"; then
7765 error "IN CACHE: before: $BEFORE, after: $AFTER"
7768 set_obdfilter_param $list '' read_cache_enable 1
7771 run_test 151 "test cache on oss and controls ==============================="
7774 local TF="$TMP/$tfile"
7776 # simulate ENOMEM during write
7777 #define OBD_FAIL_OST_NOMEM 0x226
7778 lctl set_param fail_loc=0x80000226
7779 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
7781 sync || error "sync failed"
7782 lctl set_param fail_loc=0
7784 # discard client's cache
7785 cancel_lru_locks osc
7787 # simulate ENOMEM during read
7788 lctl set_param fail_loc=0x80000226
7789 cmp $TF $DIR/$tfile || error "cmp failed"
7790 lctl set_param fail_loc=0
7794 run_test 152 "test read/write with enomem ============================"
7797 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
7799 run_test 153 "test if fdatasync does not crash ======================="
7802 cp /etc/hosts $DIR/$tfile
7804 fid=$($LFS path2fid $DIR/$tfile)
7806 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
7808 ffid=$DIR/.lustre/fid/$fid
7810 echo "stat fid $fid"
7811 stat $ffid > /dev/null || error "stat $ffid failed."
7812 echo "touch fid $fid"
7813 touch $ffid || error "touch $ffid failed."
7814 echo "write to fid $fid"
7815 cat /etc/hosts > $ffid || error "write $ffid failed."
7816 echo "read fid $fid"
7817 diff /etc/hosts $ffid || error "read $ffid failed."
7818 echo "append write to fid $fid"
7819 cat /etc/hosts >> $ffid || error "append write $ffid failed."
7820 echo "rename fid $fid"
7821 mv $ffid $DIR/$tfile.1 && error "rename $ffid to $tfile.1 should fail."
7823 mv $DIR/$tfile.1 $ffid && error "rename $tfile.1 to $ffid should fail."
7825 echo "truncate fid $fid"
7826 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
7827 echo "link fid $fid"
7828 ln -f $ffid $DIR/tfile.lnk || error "link $ffid failed."
7829 if [ -n $(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl) ]; then
7830 echo "setfacl fid $fid"
7831 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
7832 echo "getfacl fid $fid"
7833 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
7835 echo "unlink fid $fid"
7836 unlink $DIR/.lustre/fid/$fid && error "unlink $ffid should fail."
7837 echo "mknod fid $fid"
7838 mknod $ffid c 1 3 && error "mknod $ffid should fail."
7840 fid=[0xf00000400:0x1:0x0]
7841 ffid=$DIR/.lustre/fid/$fid
7843 echo "stat non-exist fid $fid"
7844 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
7845 echo "write to non-exist fid $fid"
7846 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
7847 echo "link new fid $fid"
7848 ln $DIR/$tfile $ffid && error "link $ffid should fail."
7851 touch $DIR/$tdir/$tfile
7852 fid=$($LFS path2fid $DIR/$tdir)
7854 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
7856 ffid=$DIR/.lustre/fid/$fid
7859 ls $ffid > /dev/null || error "ls $ffid failed."
7860 echo "touch $fid/$tfile.1"
7861 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
7863 echo "touch $DIR/.lustre/fid/$tfile"
7864 touch $DIR/.lustre/fid/$tfile && \
7865 error "touch $DIR/.lustre/fid/$tfile should fail."
7867 echo "Open-by-FID succeeded"
7869 run_test 154 "Open-by-FID"
7871 test_155_small_load() {
7872 local temp=$TMP/$tfile
7873 local file=$DIR/$tfile
7875 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
7876 error "dd of=$temp bs=6096 count=1 failed"
7878 cancel_lru_locks osc
7879 cmp $temp $file || error "$temp $file differ"
7881 $TRUNCATE $temp 6000
7882 $TRUNCATE $file 6000
7883 cmp $temp $file || error "$temp $file differ (truncate1)"
7885 echo "12345" >>$temp
7886 echo "12345" >>$file
7887 cmp $temp $file || error "$temp $file differ (append1)"
7889 echo "12345" >>$temp
7890 echo "12345" >>$file
7891 cmp $temp $file || error "$temp $file differ (append2)"
7897 test_155_big_load() {
7898 remote_ost_nodsh && skip "remote OST with nodsh" && return
7899 local temp=$TMP/$tfile
7900 local file=$DIR/$tfile
7903 local cache_size=$(do_facet ost$((MAXI+1)) \
7904 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
7905 local large_file_size=$((cache_size * 2))
7907 echo "OSS cache size: $cache_size KB"
7908 echo "Large file size: $large_file_size KB"
7910 [ $MAXV -le $large_file_size ] && \
7911 skip_env "max available OST size needs > $large_file_size KB" && \
7914 $SETSTRIPE $file -c 1 -i $MAXI || error "$SETSTRIPE $file failed"
7916 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k || \
7917 error "dd of=$temp bs=$large_file_size count=1k failed"
7920 cancel_lru_locks osc
7921 cmp $temp $file || error "$temp $file differ"
7929 set_cache writethrough on
7932 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
7936 set_cache writethrough off
7939 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
7943 set_cache writethrough on
7946 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
7950 set_cache writethrough off
7953 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
7957 set_cache writethrough on
7960 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
7964 set_cache writethrough off
7967 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
7971 set_cache writethrough on
7974 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
7978 set_cache writethrough off
7981 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
7987 local file="$DIR/$tfile"
7989 log "Turn on read and write cache"
7991 set_cache writethrough on
7993 log "Write data and read it back."
7994 log "Read should be satisfied from the cache."
7995 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
7997 cancel_lru_locks osc
7998 cat $file >/dev/null
8000 if ! let "AFTER - BEFORE == CPAGES"; then
8001 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
8003 log "cache hits:: before: $BEFORE, after: $AFTER"
8006 log "Read again; it should be satisfied from the cache."
8008 cancel_lru_locks osc
8009 cat $file >/dev/null
8011 if ! let "AFTER - BEFORE == CPAGES"; then
8012 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
8014 log "cache hits:: before: $BEFORE, after: $AFTER"
8018 log "Turn off the read cache and turn on the write cache"
8020 set_cache writethrough on
8022 log "Read again; it should be satisfied from the cache."
8024 cancel_lru_locks osc
8025 cat $file >/dev/null
8027 if ! let "AFTER - BEFORE == CPAGES"; then
8028 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
8030 log "cache hits:: before: $BEFORE, after: $AFTER"
8033 log "Read again; it should not be satisfied from the cache."
8035 cancel_lru_locks osc
8036 cat $file >/dev/null
8038 if ! let "AFTER - BEFORE == 0"; then
8039 error "IN CACHE: before: $BEFORE, after: $AFTER"
8041 log "cache hits:: before: $BEFORE, after: $AFTER"
8044 log "Write data and read it back."
8045 log "Read should be satisfied from the cache."
8046 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
8048 cancel_lru_locks osc
8049 cat $file >/dev/null
8051 if ! let "AFTER - BEFORE == CPAGES"; then
8052 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
8054 log "cache hits:: before: $BEFORE, after: $AFTER"
8057 log "Read again; it should not be satisfied from the cache."
8059 cancel_lru_locks osc
8060 cat $file >/dev/null
8062 if ! let "AFTER - BEFORE == 0"; then
8063 error "IN CACHE: before: $BEFORE, after: $AFTER"
8065 log "cache hits:: before: $BEFORE, after: $AFTER"
8069 log "Turn off read and write cache"
8071 set_cache writethrough off
8073 log "Write data and read it back"
8074 log "It should not be satisfied from the cache."
8076 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
8077 cancel_lru_locks osc
8079 cat $file >/dev/null
8081 if ! let "AFTER - BEFORE == 0"; then
8082 error_ignore 20762 "IN CACHE: before: $BEFORE, after: $AFTER"
8084 log "cache hits:: before: $BEFORE, after: $AFTER"
8088 log "Turn on the read cache and turn off the write cache"
8090 set_cache writethrough off
8092 log "Write data and read it back"
8093 log "It should not be satisfied from the cache."
8095 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
8097 cancel_lru_locks osc
8098 cat $file >/dev/null
8100 if ! let "AFTER - BEFORE == 0"; then
8101 error_ignore 20762 "IN CACHE: before: $BEFORE, after: $AFTER"
8103 log "cache hits:: before: $BEFORE, after: $AFTER"
8106 log "Read again; it should be satisfied from the cache."
8108 cancel_lru_locks osc
8109 cat $file >/dev/null
8111 if ! let "AFTER - BEFORE == CPAGES"; then
8112 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
8114 log "cache hits:: before: $BEFORE, after: $AFTER"
8119 run_test 156 "Verification of tunables ============================"
8123 if [ $MDSCOUNT -gt 1 ]; then
8124 error_ignore 17935 $*
8132 MASK=$(do_facet $SINGLEMDS $LCTL get_param mdd.$MDT0.changelog_mask |\
8135 if [ $MASK -eq 1 ]; then
8136 do_facet $SINGLEMDS $LCTL set_param mdd.$MDT0.changelog_mask="-$1"
8138 do_facet $SINGLEMDS $LCTL set_param mdd.$MDT0.changelog_mask="+$1"
8143 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8144 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
8145 { skip "Need MDS version at least 2.2.0"; return; }
8146 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
8147 echo "Registered as changelog user $USER"
8148 do_facet $SINGLEMDS $LCTL get_param -n mdd.$MDT0.changelog_users | \
8149 grep -q $USER || error "User $USER not found in changelog_users"
8152 mkdir -p $DIR/$tdir/pics/2008/zachy
8153 touch $DIR/$tdir/pics/2008/zachy/timestamp
8154 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
8155 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
8156 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
8157 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
8158 rm $DIR/$tdir/pics/desktop.jpg
8160 $LFS changelog $MDT0 | tail -5
8162 echo "verifying changelog mask"
8163 changelog_chmask "MKDIR"
8164 changelog_chmask "CLOSE"
8166 mkdir -p $DIR/$tdir/pics/zach/sofia
8167 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
8169 changelog_chmask "MKDIR"
8170 changelog_chmask "CLOSE"
8172 mkdir -p $DIR/$tdir/pics/2008/sofia
8173 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
8175 $LFS changelog $MDT0
8176 MKDIRS=$($LFS changelog $MDT0 | tail -5 | grep -c "MKDIR")
8177 CLOSES=$($LFS changelog $MDT0 | tail -5 | grep -c "CLOSE")
8178 [ $MKDIRS -eq 1 ] || err17935 "MKDIR changelog mask count $DIRS != 1"
8179 [ $CLOSES -eq 1 ] || err17935 "CLOSE changelog mask count $DIRS != 1"
8182 echo "verifying target fid"
8183 fidc=$($LFS changelog $MDT0 | grep timestamp | grep "CREAT" | \
8184 tail -1 | awk '{print $6}')
8185 fidf=$($LFS path2fid $DIR/$tdir/pics/zach/timestamp)
8186 [ "$fidc" == "t=$fidf" ] || \
8187 err17935 "fid in changelog $fidc != file fid $fidf"
8188 echo "verifying parent fid"
8189 fidc=$($LFS changelog $MDT0 | grep timestamp | grep "CREAT" | \
8190 tail -1 | awk '{print $7}')
8191 fidf=$($LFS path2fid $DIR/$tdir/pics/zach)
8192 [ "$fidc" == "p=$fidf" ] || \
8193 err17935 "pfid in changelog $fidc != dir fid $fidf"
8195 USER_REC1=$(do_facet $SINGLEMDS $LCTL get_param -n \
8196 mdd.$MDT0.changelog_users | grep $USER | awk '{print $2}')
8197 $LFS changelog_clear $MDT0 $USER $(($USER_REC1 + 5))
8198 USER_REC2=$(do_facet $SINGLEMDS $LCTL get_param -n \
8199 mdd.$MDT0.changelog_users | grep $USER | awk '{print $2}')
8200 echo "verifying user clear: $(( $USER_REC1 + 5 )) == $USER_REC2"
8201 [ $USER_REC2 == $(($USER_REC1 + 5)) ] || \
8202 err17935 "user index should be $(($USER_REC1 + 5)); is $USER_REC2"
8204 MIN_REC=$(do_facet $SINGLEMDS $LCTL get_param mdd.$MDT0.changelog_users | \
8205 awk 'min == "" || $2 < min {min = $2}; END {print min}')
8206 FIRST_REC=$($LFS changelog $MDT0 | head -1 | awk '{print $1}')
8207 echo "verifying min purge: $(( $MIN_REC + 1 )) == $FIRST_REC"
8208 [ $FIRST_REC == $(($MIN_REC + 1)) ] || \
8209 err17935 "first index should be $(($MIN_REC + 1)); is $FIRST_REC"
8211 echo "verifying user deregister"
8212 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
8213 do_facet $SINGLEMDS $LCTL get_param -n mdd.$MDT0.changelog_users | \
8214 grep -q $USER && error "User $USER still found in changelog_users"
8216 USERS=$(( $(do_facet $SINGLEMDS $LCTL get_param -n \
8217 mdd.$MDT0.changelog_users | wc -l) - 2 ))
8218 if [ $USERS -eq 0 ]; then
8219 LAST_REC1=$(do_facet $SINGLEMDS $LCTL get_param -n \
8220 mdd.$MDT0.changelog_users | head -1 | awk '{print $3}')
8221 touch $DIR/$tdir/chloe
8222 LAST_REC2=$(do_facet $SINGLEMDS $LCTL get_param -n \
8223 mdd.$MDT0.changelog_users | head -1 | awk '{print $3}')
8224 echo "verify changelogs are off if we were the only user: $LAST_REC1 == $LAST_REC2"
8225 [ $LAST_REC1 == $LAST_REC2 ] || error "changelogs not off"
8227 echo "$USERS other changelog users; can't verify off"
8230 run_test 160 "changelog sanity"
8234 cp /etc/hosts $DIR/$tdir/$tfile
8235 mkdir $DIR/$tdir/foo1
8236 mkdir $DIR/$tdir/foo2
8237 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
8238 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
8239 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
8240 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
8241 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[')
8242 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
8243 $LFS fid2path $DIR $FID
8244 err17935 "bad link ea"
8247 rm $DIR/$tdir/foo2/zachary
8249 rm $DIR/$tdir/foo2/thor
8251 rm $DIR/$tdir/$tfile
8253 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
8254 if [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ]
8256 $LFS fid2path $DIR $FID
8257 err17935 "bad link rename"
8259 rm $DIR/$tdir/foo2/maggie
8262 local longname=filename_avg_len_is_thirty_two_
8263 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 || \
8264 error "failed to hardlink many files"
8265 links=$($LFS fid2path $DIR $FID | wc -l)
8266 echo -n "${links}/1000 links in link EA"
8267 [ ${links} -gt 60 ] || err17935 "expected at least 60 links in link EA"
8268 unlinkmany $DIR/$tdir/foo2/$longname 1000 || \
8269 error "failed to unlink many hardlinks"
8271 run_test 161 "link ea sanity"
8278 local path=$(${LFS} fid2path $*)
8281 if [ $RC -ne 0 ]; then
8282 err17935 "path looked up of $expected failed. Error $RC"
8284 elif [ "${path}" != "${expected}" ]; then
8285 err17935 "path looked up \"${path}\" instead of \"${expected}\""
8288 echo "fid $fid resolves to path $path (expected $expected)"
8292 # Make changes to filesystem
8293 mkdir -p $DIR/$tdir/d2
8294 touch $DIR/$tdir/d2/$tfile
8295 touch $DIR/$tdir/d2/x1
8296 touch $DIR/$tdir/d2/x2
8297 mkdir -p $DIR/$tdir/d2/a/b/c
8298 mkdir -p $DIR/$tdir/d2/p/q/r
8300 FID=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
8301 check_path "$tdir/d2/$tfile" $FSNAME $FID --link 0
8304 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
8305 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
8306 check_path "$tdir/d2/p/q/r/slink" $FSNAME $FID --link 0
8308 # softlink to wrong file
8309 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
8310 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
8311 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME $FID --link 0
8314 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
8315 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
8316 FID=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
8317 # fid2path dir/fsname should both work
8318 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 1
8319 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR $FID --link 0
8321 # hardlink count: check that there are 2 links
8322 # Doesnt work with CMD yet: 17935
8323 ${LFS} fid2path $DIR $FID | wc -l | grep -q 2 || \
8324 err17935 "expected 2 links"
8326 # hardlink indexing: remove the first link
8327 rm $DIR/$tdir/d2/p/q/r/hlink
8328 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 0
8332 run_test 162 "path lookup sanity"
8335 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8336 copytool --test $FSNAME || { skip "copytool not runnable: $?" && return; }
8339 local uuid=$($LCTL get_param -n mdc.${FSNAME}-MDT0000-mdc-*.uuid)
8340 # this proc file is temporary and linux-only
8341 do_facet $SINGLEMDS lctl set_param mdt.${FSNAME}-MDT0000.mdccomm=$uuid ||\
8342 error "kernel->userspace send failed"
8345 run_test 163 "kernel <-> userspace comms"
8348 # do directio so as not to populate the page cache
8349 log "creating a 10 Mb file"
8350 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
8351 log "starting reads"
8352 dd if=$DIR/$tfile of=/dev/null bs=4096 &
8353 log "truncating the file"
8354 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
8356 kill %+ || true # reads might have finished
8357 echo "wait until dd is finished"
8359 log "removing the temporary file"
8360 rm -rf $DIR/$tfile || error "tmp file removal failed"
8362 run_test 169 "parallel read and truncate should not deadlock"
8365 $LCTL clear # bug 18514
8366 $LCTL debug_daemon start $TMP/${tfile}_log_good
8368 $LCTL debug_daemon stop
8369 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
8370 error "sed failed to read log_good"
8372 $LCTL debug_daemon start $TMP/${tfile}_log_good
8374 $LCTL debug_daemon stop
8376 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
8377 error "lctl df log_bad failed"
8379 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
8380 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
8382 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
8383 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
8385 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
8386 error "bad_line good_line1 good_line2 are empty"
8388 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
8389 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
8390 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
8392 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
8393 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
8394 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
8396 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
8397 error "bad_line_new good_line_new are empty"
8399 local expected_good=$((good_line1 + good_line2*2))
8401 rm -f $TMP/${tfile}*
8402 # LU-231, short malformed line may not be counted into bad lines
8403 if [ $bad_line -ne $bad_line_new ] &&
8404 [ $bad_line -ne $((bad_line_new - 1)) ]; then
8405 error "expected $bad_line bad lines, but got $bad_line_new"
8409 if [ $expected_good -ne $good_line_new ]; then
8410 error "expected $expected_good good lines, but got $good_line_new"
8415 run_test 170 "test lctl df to handle corrupted log ====================="
8417 test_171() { # bug20592
8418 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
8419 $LCTL set_param fail_loc=0x50e
8420 $LCTL set_param fail_val=3000
8421 multiop_bg_pause $DIR/$tfile O_s || true
8423 kill -USR1 $MULTIPID
8427 if dmesg | grep "recursive fault"; then
8428 error "caught a recursive fault"
8430 $LCTL set_param fail_loc=0
8433 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
8435 # it would be good to share it with obdfilter-survey/libecho code
8436 setup_obdecho_osc () {
8439 local obdfilter_name=$2
8440 echo "Creating new osc for $obdfilter_name on $ost_nid"
8441 # make sure we can find loopback nid
8442 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
8444 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
8445 ${obdfilter_name}_osc_UUID || rc=2; }
8446 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
8447 ${obdfilter_name}_UUID $ost_nid || rc=3; }
8451 cleanup_obdecho_osc () {
8452 local obdfilter_name=$1
8453 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
8454 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
8458 obdecho_create_test() {
8463 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
8464 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
8466 if [ $rc -eq 0 ]; then
8467 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
8468 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
8470 echo "New object id is $id"
8471 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec test_brw 10 w v 64 $id" ||
8473 [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec " \
8474 "cleanup" || rc=5; }
8475 [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec " \
8477 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
8482 remote_ost_nodsh && skip "remote OST with nodsh" && return
8486 if ! module_loaded obdecho; then
8487 load_module obdecho/obdecho
8491 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
8492 local host=$(lctl get_param -n osc.$osc.import |
8493 awk '/current_connection:/ {print $2}' )
8494 local target=$(lctl get_param -n osc.$osc.import |
8495 awk '/target:/ {print $2}' )
8496 target=${target%_UUID}
8498 [[ -n $target ]] && { setup_obdecho_osc $host $target || rc=1; } || rc=1
8499 [ $rc -eq 0 ] && { obdecho_create_test ${target}_osc client || rc=2; }
8500 [[ -n $target ]] && cleanup_obdecho_osc $target
8501 [ $rmmod_local -eq 1 ] && rmmod obdecho
8504 run_test 180a "test obdecho on osc"
8507 remote_ost_nodsh && skip "remote OST with nodsh" && return
8509 local rmmod_remote=0
8511 do_facet ost1 "lsmod | grep -q obdecho || " \
8512 "{ insmod ${LUSTRE}/obdecho/obdecho.ko || " \
8513 "modprobe obdecho; }" && rmmod_remote=1
8514 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ {print $4;exit}')
8515 [[ -n $target ]] && { obdecho_create_test $target ost1 || rc=1; }
8516 [ $rmmod_remote -eq 1 ] && do_facet ost1 "rmmod obdecho"
8519 run_test 180b "test obdecho directly on obdfilter"
8521 test_181() { # bug 22177
8522 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
8523 # create enough files to index the directory
8524 createmany -o $DIR/$tdir/foobar 4000
8525 # print attributes for debug purpose
8528 multiop_bg_pause $DIR/$tdir D_Sc || return 1
8530 # remove the files & current working dir
8531 unlinkmany $DIR/$tdir/foobar 4000
8533 kill -USR1 $MULTIPID
8535 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
8538 run_test 181 "Test open-unlinked dir ========================"
8541 # disable MDC RPC lock wouldn't crash client
8545 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
8546 #define OBD_FAIL_MDC_RPCS_SEM 0x804
8547 $LCTL set_param fail_loc=0x804
8549 for (( i=0; i < $tcount; i++ )) ; do
8551 createmany -o $DIR/$tdir/$i/f- $fcount &
8555 for (( i=0; i < $tcount; i++ )) ; do
8556 unlinkmany $DIR/$tdir/$i/f- $fcount &
8562 $LCTL set_param fail_loc=0
8564 run_test 182 "Disable MDC RPCs semaphore wouldn't crash client ================"
8567 check_file_in_pool()
8572 local res=$($GETSTRIPE $file | grep 0x | cut -f2)
8575 for t in $tlist ; do
8576 [ "$i" -eq "$t" ] && continue 2
8579 echo "pool list: $tlist"
8580 echo "striping: $res"
8581 error_noexit "$file not allocated in $pool"
8588 echo "Creating new pool"
8591 create_pool $FSNAME.$pool ||
8592 { error_noexit "No pool created, result code $?"; return 1; }
8593 [ $($LFS pool_list $FSNAME | grep -c $pool) -eq 1 ] ||
8594 { error_noexit "$pool not in lfs pool_list"; return 2; }
8597 pool_add_targets() {
8598 echo "Adding targets to pool"
8604 local list=$(seq $first $step $last)
8606 local t=$(for i in $list; do printf "$FSNAME-OST%04x_UUID " $i; done)
8607 do_facet mgs $LCTL pool_add \
8608 $FSNAME.$pool $FSNAME-OST[$first-$last/$step]
8609 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$pool \
8610 | sort -u | tr '\n' ' ' " "$t" || {
8611 error_noexit "Add to pool failed"
8614 local lfscount=$($LFS pool_list $FSNAME.$pool | grep -c "\-OST")
8615 local addcount=$(((last - first) / step + 1))
8616 [ $lfscount -eq $addcount ] || {
8617 error_noexit "lfs pool_list bad ost count" \
8618 "$lfscount != $addcount"
8626 echo "Setting pool on directory $tdir"
8628 $SETSTRIPE -c 2 -p $pool $tdir && return 0
8630 error_noexit "Cannot set pool $pool to $tdir"
8637 echo "Checking pool on directory $tdir"
8639 local res=$($GETSTRIPE --pool $tdir | sed "s/\s*$//")
8640 [ "$res" = "$pool" ] && return 0
8642 error_noexit "Pool on '$tdir' is '$res', not '$pool'"
8646 pool_dir_rel_path() {
8647 echo "Testing relative path works well"
8652 mkdir -p $root/$tdir/$tdir
8654 pool_set_dir $pool $tdir || return 1
8655 pool_set_dir $pool ./$tdir || return 2
8656 pool_set_dir $pool ../$tdir || return 3
8657 pool_set_dir $pool ../$tdir/$tdir || return 4
8658 rm -rf $tdir; cd - > /dev/null
8661 pool_alloc_files() {
8662 echo "Checking files allocation from directory pool"
8669 for i in $(seq -w 1 $count)
8671 local file=$tdir/file-$i
8673 check_file_in_pool $file $pool "$tlist" || \
8674 failed=$((failed + 1))
8676 [ "$failed" = 0 ] && return 0
8678 error_noexit "$failed files not allocated in $pool"
8682 pool_create_files() {
8683 echo "Creating files in pool"
8691 for i in $(seq -w 1 $count)
8693 local file=$tdir/spoo-$i
8694 $SETSTRIPE -p $pool $file
8695 check_file_in_pool $file $pool "$tlist" || \
8696 failed=$((failed + 1))
8698 [ "$failed" = 0 ] && return 0
8700 error_noexit "$failed files not allocated in $pool"
8705 echo "Checking 'lfs df' output"
8708 local t=$($LCTL get_param -n lov.$FSNAME-clilov-*.pools.$pool |
8710 local res=$($LFS df --pool $FSNAME.$pool |
8712 grep "$FSNAME-OST" |
8714 [ "$res" = "$t" ] && return 0
8716 error_noexit "Pools OSTs '$t' is not '$res' that lfs df reports"
8720 pool_file_rel_path() {
8721 echo "Creating files in a pool with relative pathname"
8726 { error_noexit "unable to create $tdir"; return 1 ; }
8727 local file="/..$tdir/$tfile-1"
8728 $SETSTRIPE -p $pool $file ||
8729 { error_noexit "unable to create $file" ; return 2 ; }
8732 $SETSTRIPE -p $pool $tfile-2 || {
8733 error_noexit "unable to create $tfile-2 in $tdir"
8738 pool_remove_first_target() {
8739 echo "Removing first target from a pool"
8742 local pname="lov.$FSNAME-*.pools.$pool"
8743 local t=$($LCTL get_param -n $pname | head -1)
8744 do_facet mgs $LCTL pool_remove $FSNAME.$pool $t
8745 wait_update $HOSTNAME "lctl get_param -n $pname | grep $t" "" || {
8746 error_noexit "$t not removed from $FSNAME.$pool"
8751 pool_remove_all_targets() {
8752 echo "Removing all targets from pool"
8755 local pname="lov.$FSNAME-*.pools.$pool"
8756 for t in $($LCTL get_param -n $pname | sort -u)
8758 do_facet mgs $LCTL pool_remove $FSNAME.$pool $t
8760 wait_update $HOSTNAME "lctl get_param -n $pname" "" || {
8761 error_noexit "Pool $FSNAME.$pool cannot be drained"
8764 # striping on an empty/nonexistant pool should fall back
8765 # to "pool of everything"
8767 error_noexit "failed to use fallback striping for empty pool"
8770 # setstripe on an empty pool should fail
8771 $SETSTRIPE -p $pool $file 2>/dev/null && {
8772 error_noexit "expected failure when creating file" \
8780 echo "Destroying pool"
8784 do_facet mgs $LCTL pool_destroy $FSNAME.$pool
8787 # striping on an empty/nonexistant pool should fall back
8788 # to "pool of everything"
8790 error_noexit "failed to use fallback striping for missing pool"
8793 # setstripe on an empty pool should fail
8794 $SETSTRIPE -p $pool $file 2>/dev/null && {
8795 error_noexit "expected failure when creating file" \
8800 # get param should return err once pool is gone
8801 if wait_update $HOSTNAME "lctl get_param -n \
8802 lov.$FSNAME-*.pools.$pool 2>/dev/null || echo foo" "foo"
8804 remove_pool_from_list $FSNAME.$pool
8807 error_noexit "Pool $FSNAME.$pool is not destroyed"
8812 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
8814 local POOL=${POOL:-cea1}
8815 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
8816 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
8819 local last_ost=$(($OSTCOUNT - 1))
8821 local ost_list=$(seq $first_ost $ost_step $last_ost)
8822 local ost_range="$first_ost $last_ost $ost_step"
8823 local test_path=$POOL_ROOT/$POOL_DIR_NAME
8824 local file_dir=$POOL_ROOT/file_tst
8828 # former test_200a test_200b
8829 pool_add $POOL || { rc=$? ; break; }
8830 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
8831 # former test_200c test_200d
8833 pool_set_dir $POOL $test_path || { rc=$? ; break; }
8834 pool_check_dir $POOL $test_path || { rc=$? ; break; }
8835 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
8836 || { rc=$? ; break; }
8837 # former test_200e test_200f
8838 local files=$((OSTCOUNT*3))
8839 pool_alloc_files $POOL $test_path $files "$ost_list" \
8840 || { rc=$? ; break; }
8841 pool_create_files $POOL $file_dir $files "$ost_list" \
8842 || { rc=$? ; break; }
8843 # former test_200g test_200h
8844 pool_lfs_df $POOL || { rc=$? ; break; }
8845 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
8847 # former test_201a test_201b test_201c
8848 pool_remove_first_target $POOL || { rc=$? ; break; }
8850 local f=$test_path/$tfile
8851 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
8852 pool_remove $POOL $f || { rc=$? ; break; }
8859 run_test 200 "OST pools"
8861 # usage: default_attr <count | size | offset>
8863 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
8866 # usage: check_default_stripe_attr
8867 check_default_stripe_attr() {
8868 ACTUAL=$($GETSTRIPE $* $DIR/$tdir)
8870 --stripe-count|--count)
8871 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
8872 --stripe-size|--size)
8873 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
8874 --stripe-index|--index)
8877 error "unknown getstripe attr '$1'"
8880 [ $ACTUAL != $EXPECTED ] &&
8881 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
8886 $SETSTRIPE --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
8888 check_default_stripe_attr --stripe-count
8889 check_default_stripe_attr --stripe-size
8890 check_default_stripe_attr --stripe-index
8894 run_test 204a "Print default stripe attributes ================="
8898 $SETSTRIPE --stripe-count 1 $DIR/$tdir
8900 check_default_stripe_attr --stripe-size
8901 check_default_stripe_attr --stripe-index
8905 run_test 204b "Print default stripe size and offset ==========="
8909 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
8911 check_default_stripe_attr --stripe-count
8912 check_default_stripe_attr --stripe-index
8916 run_test 204c "Print default stripe count and offset ==========="
8920 $SETSTRIPE --stripe-index 0 $DIR/$tdir
8922 check_default_stripe_attr --stripe-count
8923 check_default_stripe_attr --stripe-size
8927 run_test 204d "Print default stripe count and size ============="
8931 $SETSTRIPE -d $DIR/$tdir
8933 check_default_stripe_attr --stripe-count --raw
8934 check_default_stripe_attr --stripe-size --raw
8935 check_default_stripe_attr --stripe-index --raw
8939 run_test 204e "Print raw stripe attributes ================="
8943 $SETSTRIPE --stripe-count 1 $DIR/$tdir
8945 check_default_stripe_attr --stripe-size --raw
8946 check_default_stripe_attr --stripe-index --raw
8950 run_test 204f "Print raw stripe size and offset ==========="
8954 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
8956 check_default_stripe_attr --stripe-count --raw
8957 check_default_stripe_attr --stripe-index --raw
8961 run_test 204g "Print raw stripe count and offset ==========="
8965 $SETSTRIPE --stripe-index 0 $DIR/$tdir
8967 check_default_stripe_attr --stripe-count --raw
8968 check_default_stripe_attr --stripe-size --raw
8972 run_test 204h "Print raw stripe count and size ============="
8974 # Figure out which job scheduler is being used, if any,
8976 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
8978 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
8980 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
8982 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
8983 JOBENV=LOADL_STEP_ID
8984 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
8994 # clear old jobstats
8995 do_facet $SINGLEMDS lctl set_param mdt.*.job_stats="clear"
8996 do_facet ost0 lctl set_param obdfilter.*.job_stats="clear"
8998 # use a new JobID for this test, or we might see an old one
8999 [ "$JOBENV" = "FAKE_JOBID" ] && FAKE_JOBID=test_id.$testnum.$RANDOM
9003 log "Using JobID environment variable $JOBENV=$JOBVAL"
9005 if [ $JOBENV = "FAKE_JOBID" ]; then
9006 FAKE_JOBID=$JOBVAL $cmd
9011 if [ "$target" = "mdt" -o "$target" = "both" ]; then
9012 FACET="$SINGLEMDS" # will need to get MDS number for DNE
9013 do_facet $FACET lctl get_param mdt.*.job_stats |
9014 grep $JOBVAL || error "No job stats found on MDT $FACET"
9016 if [ "$target" = "ost" -o "$target" = "both" ]; then
9018 do_facet $FACET lctl get_param obdfilter.*.job_stats |
9019 grep $JOBVAL || error "No job stats found on OST $FACET"
9023 test_205() { # Job stats
9025 OLD_JOBENV=`$LCTL get_param -n jobid_var`
9026 if [ $OLD_JOBENV != $JOBENV ]; then
9027 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$JOBENV
9028 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" \
9033 cmd="mkdir $DIR/$tfile"
9034 verify_jobstats "$cmd" "mdt"
9036 cmd="rm -fr $DIR/$tfile"
9037 verify_jobstats "$cmd" "mdt"
9039 cmd="mknod $DIR/$tfile c 1 3"
9040 verify_jobstats "$cmd" "mdt"
9042 cmd="rm -f $DIR/$tfile"
9043 verify_jobstats "$cmd" "mdt"
9045 cmd="$SETSTRIPE -i 0 -c 1 $DIR/$tfile"
9046 verify_jobstats "$cmd" "mdt"
9048 cmd="touch $DIR/$tfile"
9049 verify_jobstats "$cmd" "both"
9051 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
9052 verify_jobstats "$cmd" "ost"
9054 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
9055 verify_jobstats "$cmd" "ost"
9057 cmd="$TRUNCATE $DIR/$tfile 0"
9058 verify_jobstats "$cmd" "both"
9060 cmd="mv -f $DIR/$tfile $DIR/jobstats_test_rename"
9061 verify_jobstats "$cmd" "mdt"
9064 rm -f $DIR/jobstats_test_rename
9066 if [ $OLD_JOBENV != $JOBENV ]; then
9067 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$OLD_JOBENV
9068 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" \
9069 $OLD_JOBENV || return 1
9072 run_test 205 "Verify job stats"
9074 # LU-1480, LU-1773 and LU-1657
9077 lfs setstripe -c -1 $DIR/$tdir
9078 #define OBD_FAIL_LOV_INIT 0x1403
9079 $LCTL set_param fail_loc=0xa0001403
9080 $LCTL set_param fail_val=1
9081 touch $DIR/$tdir/$tfile || true
9083 run_test 206 "fail lov_init_raid0() doesn't lbug"
9087 size=$((size % 8192 + 1))
9088 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
9089 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
9090 rm -f $DIR/f212 $DIR/f212.xyz
9092 run_test 212 "Sendfile test ============================================"
9095 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
9096 cancel_lru_locks osc
9097 lctl set_param fail_loc=0x8000040f
9098 # generate a read lock
9099 cat $DIR/$tfile > /dev/null
9100 # write to the file, it will try to cancel the above read lock.
9101 cat /etc/hosts >> $DIR/$tfile
9103 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
9105 test_214() { # for bug 20133
9106 mkdir -p $DIR/d214p/d214c
9107 for (( i=0; i < 340; i++ )) ; do
9108 touch $DIR/d214p/d214c/a$i
9111 ls -l $DIR/d214p || error "ls -l $DIR/d214p failed"
9112 mv $DIR/d214p/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
9113 ls $DIR/d214c || error "ls $DIR/d214c failed"
9114 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
9116 run_test 214 "hash-indexed directory test - bug 20133"
9118 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
9119 create_lnet_proc_files() {
9120 cat /proc/sys/lnet/$1 >$TMP/lnet_$1.out || error "cannot read /proc/sys/lnet/$1"
9121 sysctl lnet.$1 >$TMP/lnet_$1.sys_tmp || error "cannot read lnet.$1"
9123 sed "s/^lnet.$1\ =\ //g" "$TMP/lnet_$1.sys_tmp" >$TMP/lnet_$1.sys
9124 rm -f "$TMP/lnet_$1.sys_tmp"
9127 # counterpart of create_lnet_proc_files
9128 remove_lnet_proc_files() {
9129 rm -f $TMP/lnet_$1.out $TMP/lnet_$1.sys
9132 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
9133 # 3rd arg as regexp for body
9134 check_lnet_proc_stats() {
9135 local l=$(cat "$TMP/lnet_$1" |wc -l)
9136 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
9138 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
9141 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
9142 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
9143 # optional and can be regexp for 2nd line (lnet.routes case)
9144 check_lnet_proc_entry() {
9145 local blp=2 # blp stands for 'position of 1st line of body'
9146 [ "$5" = "" ] || blp=3 # lnet.routes case
9148 local l=$(cat "$TMP/lnet_$1" |wc -l)
9149 # subtracting one from $blp because the body can be empty
9150 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
9152 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
9153 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
9155 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
9156 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
9158 # bail out if any unexpected line happened
9159 sed -n "$blp~1 p" "$TMP/lnet_$1" |grep -Ev "$3"
9160 [ "$?" != 0 ] || error "$2 misformatted"
9163 test_215() { # for bugs 18102, 21079, 21517
9164 local N='(0|[1-9][0-9]*)' # non-negative numeric
9165 local P='[1-9][0-9]*' # positive numeric
9166 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
9167 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
9168 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
9169 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
9171 local L1 # regexp for 1st line
9172 local L2 # regexp for 2nd line (optional)
9173 local BR # regexp for the rest (body)
9175 # /proc/sys/lnet/stats should look as 11 space-separated non-negative numerics
9176 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
9177 create_lnet_proc_files "stats"
9178 check_lnet_proc_stats "stats.out" "/proc/sys/lnet/stats" "$BR"
9179 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
9180 remove_lnet_proc_files "stats"
9182 # /proc/sys/lnet/routes should look like this:
9183 # Routing disabled/enabled
9184 # net hops state router
9185 # where net is a string like tcp0, hops >= 0, state is up/down,
9186 # router is a string like 192.168.1.1@tcp2
9187 L1="^Routing (disabled|enabled)$"
9188 L2="^net +hops +state +router$"
9189 BR="^$NET +$N +(up|down) +$NID$"
9190 create_lnet_proc_files "routes"
9191 check_lnet_proc_entry "routes.out" "/proc/sys/lnet/routes" "$BR" "$L1" "$L2"
9192 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
9193 remove_lnet_proc_files "routes"
9195 # /proc/sys/lnet/routers should look like this:
9196 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
9197 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
9198 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
9199 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
9200 L1="^ref +rtr_ref +alive_cnt +state +last_ping +ping_sent +deadline +down_ni +router$"
9201 BR="^$P +$P +$N +(up|down) +$N +(0|1) +$I +$I +$NID$"
9202 create_lnet_proc_files "routers"
9203 check_lnet_proc_entry "routers.out" "/proc/sys/lnet/routers" "$BR" "$L1"
9204 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
9205 remove_lnet_proc_files "routers"
9207 # /proc/sys/lnet/peers should look like this:
9208 # nid refs state last max rtr min tx min queue
9209 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
9210 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
9211 # numeric (0 or >0 or <0), queue >= 0.
9212 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
9213 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
9214 create_lnet_proc_files "peers"
9215 check_lnet_proc_entry "peers.out" "/proc/sys/lnet/peers" "$BR" "$L1"
9216 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
9217 remove_lnet_proc_files "peers"
9219 # /proc/sys/lnet/buffers should look like this:
9220 # pages count credits min
9221 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
9222 L1="^pages +count +credits +min$"
9223 BR="^ +$N +$N +$I +$I$"
9224 create_lnet_proc_files "buffers"
9225 check_lnet_proc_entry "buffers.out" "/proc/sys/lnet/buffers" "$BR" "$L1"
9226 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
9227 remove_lnet_proc_files "buffers"
9229 # /proc/sys/lnet/nis should look like this:
9230 # nid status alive refs peer rtr max tx min
9231 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
9232 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
9233 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
9234 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
9235 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
9236 create_lnet_proc_files "nis"
9237 check_lnet_proc_entry "nis.out" "/proc/sys/lnet/nis" "$BR" "$L1"
9238 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
9239 remove_lnet_proc_files "nis"
9241 # can we successfully write to /proc/sys/lnet/stats?
9242 echo "0" >/proc/sys/lnet/stats || error "cannot write to /proc/sys/lnet/stats"
9243 sysctl -w lnet.stats=0 || error "cannot write to lnet.stats"
9245 run_test 215 "/proc/sys/lnet exists and has proper content - bugs 18102, 21079, 21517"
9247 test_216() { # bug 20317
9248 remote_ost_nodsh && skip "remote OST with nodsh" && return
9250 local p="$TMP/sanityN-$TESTNAME.parameters"
9251 save_lustre_params $HOSTNAME "osc.*.contention_seconds" > $p
9252 for node in $(osts_nodes); do
9253 save_lustre_params $node "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
9254 save_lustre_params $node "ldlm.namespaces.filter-*.contended_locks" >> $p
9255 save_lustre_params $node "ldlm.namespaces.filter-*.contention_seconds" >> $p
9259 # agressive lockless i/o settings
9260 for node in $(osts_nodes); do
9261 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'
9263 lctl set_param -n osc.*.contention_seconds 60
9265 $DIRECTIO write $DIR/$tfile 0 10 4096
9266 $CHECKSTAT -s 40960 $DIR/$tfile
9268 # disable lockless i/o
9269 for node in $(osts_nodes); do
9270 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'
9272 lctl set_param -n osc.*.contention_seconds 0
9275 dd if=/dev/zero of=$DIR/$tfile count=0
9276 $CHECKSTAT -s 0 $DIR/$tfile
9278 restore_lustre_params <$p
9282 run_test 216 "check lockless direct write works and updates file size and kms correctly"
9284 test_217() { # bug 22430
9288 for node in $(nodes_list); do
9289 nid=$(host_nids_address $node $NETTYPE)
9290 if [[ $nid = *-* ]] ; then
9291 echo "lctl ping $nid@$NETTYPE"
9292 lctl ping $nid@$NETTYPE
9294 echo "skipping $node (no hyphen detected)"
9298 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
9301 # do directio so as not to populate the page cache
9302 log "creating a 10 Mb file"
9303 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
9304 log "starting reads"
9305 dd if=$DIR/$tfile of=/dev/null bs=4096 &
9306 log "truncating the file"
9307 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
9309 kill %+ || true # reads might have finished
9310 echo "wait until dd is finished"
9312 log "removing the temporary file"
9313 rm -rf $DIR/$tfile || error "tmp file removal failed"
9315 run_test 218 "parallel read and truncate should not deadlock ======================="
9318 # write one partial page
9319 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
9320 # set no grant so vvp_io_commit_write will do sync write
9321 $LCTL set_param fail_loc=0x411
9322 # write a full page at the end of file
9323 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
9325 $LCTL set_param fail_loc=0
9326 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
9327 $LCTL set_param fail_loc=0x411
9328 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
9330 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
9332 test_220() { #LU-325
9333 remote_ost_nodsh && skip "remote OST with nodsh" && return
9337 local OST=$(lfs osts | grep ${OSTIDX}": " | \
9338 awk '{print $2}' | sed -e 's/_UUID$//')
9341 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
9342 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
9343 osc.$mdtosc_proc1.prealloc_last_id)
9344 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
9345 osc.$mdtosc_proc1.prealloc_next_id)
9349 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
9350 #define OBD_FAIL_OST_ENOINO 0x229
9351 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
9352 do_facet mgs $LCTL pool_new $FSNAME.$TESTNAME || return 1
9353 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
9355 $SETSTRIPE $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
9357 MDSOBJS=$((last_id - next_id))
9358 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
9360 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
9361 echo "OST still has $count kbytes free"
9363 echo "create $MDSOBJS files @next_id..."
9364 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
9366 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
9367 osc.$mdtosc_proc1.prealloc_last_id)
9368 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
9369 osc.$mdtosc_proc1.prealloc_next_id)
9371 echo "after creation, last_id=$last_id2, next_id=$next_id2"
9376 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
9377 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
9379 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST || return 4
9380 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME || return 5
9381 echo "unlink $MDSOBJS files @$next_id..."
9382 unlinkmany $DIR/$tdir/f $MDSOBJS || return 6
9384 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
9387 dd if=`which date` of=$MOUNT/date oflag=sync
9388 chmod +x $MOUNT/date
9390 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
9391 $LCTL set_param fail_loc=0x80001401
9393 $MOUNT/date > /dev/null
9396 run_test 221 "make sure fault and truncate race to not cause OOM"
9401 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
9402 createmany -o $DIR/$tdir/$tfile 10
9403 cancel_lru_locks mdc
9404 cancel_lru_locks osc
9405 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
9406 $LCTL set_param fail_loc=0x31a
9407 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
9408 $LCTL set_param fail_loc=0
9411 run_test 222a "AGL for ls should not trigger CLIO lock failure ================"
9416 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
9417 createmany -o $DIR/$tdir/$tfile 10
9418 cancel_lru_locks mdc
9419 cancel_lru_locks osc
9420 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
9421 $LCTL set_param fail_loc=0x31a
9422 rm -r $DIR/$tdir || "AGL for rmdir failed"
9423 $LCTL set_param fail_loc=0
9425 run_test 222b "AGL for rmdir should not trigger CLIO lock failure ============="
9430 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
9431 createmany -o $DIR/$tdir/$tfile 10
9432 cancel_lru_locks mdc
9433 cancel_lru_locks osc
9434 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
9435 $LCTL set_param fail_loc=0x31b
9436 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
9437 $LCTL set_param fail_loc=0
9440 run_test 223 "osc reenqueue if without AGL lock granted ======================="
9442 test_224a() { # LU-1039, MRP-303
9443 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
9444 $LCTL set_param fail_loc=0x508
9445 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
9446 $LCTL set_param fail_loc=0
9449 run_test 224a "Don't panic on bulk IO failure"
9451 test_224b() { # LU-1039, MRP-303
9452 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
9453 cancel_lru_locks osc
9454 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
9455 $LCTL set_param fail_loc=0x515
9456 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
9457 $LCTL set_param fail_loc=0
9460 run_test 224b "Don't panic on bulk IO failure"
9462 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
9464 if [ -z ${MDSSURVEY} ]; then
9465 skip_env "mds-survey not found" && return
9467 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
9468 { skip "Need MDS version at least 2.2.51"; return; }
9470 local mds=$(facet_host $SINGLEMDS)
9471 local target=$(do_nodes $mds 'lctl dl' | \
9472 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
9474 local cmd1="file_count=1000 thrhi=4"
9475 local cmd2="dir_count=2 layer=mdd stripe_count=0"
9476 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
9477 local cmd="$cmd1 $cmd2 $cmd3"
9479 rm -f ${TMP}/mds_survey*
9481 eval $cmd || error "mds-survey with zero-stripe failed"
9482 cat ${TMP}/mds_survey*
9483 rm -f ${TMP}/mds_survey*
9485 run_test 225a "Metadata survey sanity with zero-stripe"
9488 if [ -z ${MDSSURVEY} ]; then
9489 skip_env "mds-survey not found" && return
9491 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
9492 { skip "Need MDS version at least 2.2.51"; return; }
9494 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
9495 skip_env "Need to mount OST to test" && return
9498 local mds=$(facet_host $SINGLEMDS)
9499 local target=$(do_nodes $mds 'lctl dl' | \
9500 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
9502 local cmd1="file_count=1000 thrhi=4"
9503 local cmd2="dir_count=2 layer=mdd stripe_count=1"
9504 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
9505 local cmd="$cmd1 $cmd2 $cmd3"
9507 rm -f ${TMP}/mds_survey*
9509 eval $cmd || error "mds-survey with stripe_count failed"
9510 cat ${TMP}/mds_survey*
9511 rm -f ${TMP}/mds_survey*
9513 run_test 225b "Metadata survey sanity with stripe_count = 1"
9515 mcreate_path2fid () {
9521 local path=$DIR/$tdir/$name
9526 $MCREATE --mode=$1 --major=$2 --minor=$3 $path || \
9527 error "error: cannot create $desc"
9529 fid=$($LFS path2fid $path)
9531 [ $rc -ne 0 ] && error "error: cannot get fid of a $desc"
9533 fid_path=$($LFS fid2path $DIR $fid)
9535 [ $rc -ne 0 ] && error "error: cannot get path of a $desc by fid"
9537 [ "$path" == "$fid_path" ] || \
9538 error "error: fid2path returned \`$fid_path', expected \`$path'"
9545 mcreate_path2fid 0010666 0 0 fifo "FIFO"
9546 mcreate_path2fid 0020666 1 3 null "character special file (null)"
9547 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
9548 mcreate_path2fid 0040666 0 0 dir "directory"
9549 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
9550 mcreate_path2fid 0100666 0 0 file "regular file"
9551 mcreate_path2fid 0120666 0 0 link "symbolic link"
9552 mcreate_path2fid 0140666 0 0 sock "socket"
9554 run_test 226 "call path2fid and fid2path on files of all type"
9556 # LU-1299 Executing or running ldd on a truncated executable does not
9557 # cause an out-of-memory condition.
9559 dd if=`which date` of=$MOUNT/date bs=1k count=1
9560 chmod +x $MOUNT/date
9562 $MOUNT/date > /dev/null
9563 ldd $MOUNT/date > /dev/null
9566 run_test 227 "running truncated executable does not cause OOM"
9569 # tests that do cleanup/setup should be run at the end
9574 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
9575 $LCTL set_param fail_loc=0x903
9576 # cancel_lru_locks mgc - does not work due to lctl set_param syntax
9577 for ls in /proc/fs/lustre/ldlm/namespaces/MGC*/lru_size; do
9580 FAIL_ON_ERROR=true cleanup
9581 FAIL_ON_ERROR=true setup
9583 run_test 900 "umount should not race with any mgc requeue thread"
9585 complete $(basename $0) $SECONDS
9586 check_and_cleanup_lustre
9587 if [ "$I_MOUNTED" != "yes" ]; then
9588 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true