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
501 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
502 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
503 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
506 # create a long symlink file
507 for ((i = 0; i < 4; ++i)); do
508 long_sym=${long_sym}${long_sym}
511 echo "create 512 short and long symlink files under $WDIR"
512 for ((i = 0; i < 256; ++i)); do
513 ln -sf ${long_sym}"a5a5" $WDIR/long-$i
514 ln -sf ${short_sym}"a5a5" $WDIR/short-$i
522 echo "recreate the 512 symlink files with a shorter string"
523 for ((i = 0; i < 512; ++i)); do
524 # rewrite the symlink file with a shorter string
525 ln -sf ${long_sym} $WDIR/long-$i
526 ln -sf ${short_sym} $WDIR/short-$i
529 mds_index=$($LFS getstripe -M $WDIR)
530 mds_index=$((mds_index+1))
531 devname=$(mdsdevname $mds_index)
532 cmd="$E2FSCK -fnvd $devname"
534 echo "stop and checking mds${mds_index}: $cmd"
535 # e2fsck should not return error
536 stop mds${mds_index} -f
537 do_facet mds${mds_index} $cmd || rc=$?
539 start mds${mds_index} $devname $MDS_MOUNT_OPTS
540 df $MOUNT > /dev/null 2>&1
541 [ $rc -ne 0 ] && error "e2fsck should not report error upon "\
542 "short/long symlink MDT: rc=$rc"
545 run_test 17m "run e2fsck against MDT which contains short/long symlink"
551 run_test 18 "touch .../f ; ls ... =============================="
557 $CHECKSTAT -a $DIR/f19 || error
559 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
562 ls -l $DIR/f19 && error || true
564 run_test 19b "ls -l .../f19 (should return error) =============="
567 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
568 $RUNAS touch $DIR/f19 && error || true
570 run_test 19c "$RUNAS touch .../f19 (should return error) =="
573 cat $DIR/f19 && error || true
575 run_test 19d "cat .../f19 (should return error) =============="
587 $CHECKSTAT -a $DIR/f || error
589 run_test 20 "touch .../f ; ls -l ... ==========================="
593 [ -f $DIR/d21/dangle ] && rm -f $DIR/d21/dangle
594 ln -s dangle $DIR/d21/link
595 echo foo >> $DIR/d21/link
597 $CHECKSTAT -t link $DIR/d21/link || error
598 $CHECKSTAT -f -t file $DIR/d21/link || error
600 run_test 21 "write to dangling link ============================"
605 chown $RUNAS_ID:$RUNAS_GID $WDIR
606 (cd $WDIR || error "cd $WDIR failed";
607 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
609 ls -lR $WDIR/etc || error "ls -lR $WDIR/etc failed"
610 $CHECKSTAT -t dir $WDIR/etc || error "checkstat -t dir failed"
611 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $WDIR/etc || error "checkstat -u failed"
613 run_test 22 "unpack tar archive as non-root user ==============="
618 local file=$DIR/$tdir/$tfile
620 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
621 openfile -f O_CREAT:O_EXCL $file &&
622 error "$file recreate succeeded" || true
624 run_test 23a "O_CREAT|O_EXCL in subdir =========================="
626 test_23b() { # bug 18988
628 local file=$DIR/$tdir/$tfile
631 echo foo > $file || error "write filed"
632 echo bar >> $file || error "append filed"
633 $CHECKSTAT -s 8 $file || error "wrong size"
636 run_test 23b "O_APPEND check =========================="
639 echo '== rename sanity =============================================='
640 echo '-- same directory rename'
643 mv $DIR/R1/f $DIR/R1/g
644 $CHECKSTAT -t file $DIR/R1/g || error
646 run_test 24a "touch .../R1/f; rename .../R1/f .../R1/g ========="
651 mv $DIR/R2/f $DIR/R2/g
652 $CHECKSTAT -a $DIR/R2/f || error
653 $CHECKSTAT -t file $DIR/R2/g || error
655 run_test 24b "touch .../R2/{f,g}; rename .../R2/f .../R2/g ====="
660 mv $DIR/R3/f $DIR/R3/g
661 $CHECKSTAT -a $DIR/R3/f || error
662 $CHECKSTAT -t dir $DIR/R3/g || error
664 run_test 24c "mkdir .../R3/f; rename .../R3/f .../R3/g ========="
669 mrename $DIR/R4/f $DIR/R4/g
670 $CHECKSTAT -a $DIR/R4/f || error
671 $CHECKSTAT -t dir $DIR/R4/g || error
673 run_test 24d "mkdir .../R4/{f,g}; rename .../R4/f .../R4/g ====="
676 echo '-- cross directory renames --'
679 mv $DIR/R5a/f $DIR/R5b/g
680 $CHECKSTAT -a $DIR/R5a/f || error
681 $CHECKSTAT -t file $DIR/R5b/g || error
683 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
687 touch $DIR/R6a/f $DIR/R6b/g
688 mv $DIR/R6a/f $DIR/R6b/g
689 $CHECKSTAT -a $DIR/R6a/f || error
690 $CHECKSTAT -t file $DIR/R6b/g || error
692 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
697 mv $DIR/R7a/d $DIR/R7b/e
698 $CHECKSTAT -a $DIR/R7a/d || error
699 $CHECKSTAT -t dir $DIR/R7b/e || error
701 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
705 mkdir $DIR/R8a/d $DIR/R8b/e
706 mrename $DIR/R8a/d $DIR/R8b/e
707 $CHECKSTAT -a $DIR/R8a/d || error
708 $CHECKSTAT -t dir $DIR/R8b/e || error
710 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
713 echo "-- rename error cases"
717 mrename $DIR/R9/f $DIR/R9/a
718 $CHECKSTAT -t file $DIR/R9/f || error
719 $CHECKSTAT -t dir $DIR/R9/a || error
720 $CHECKSTAT -a $DIR/R9/a/f || error
722 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
726 mrename $DIR/R10/f $DIR/R10/g
727 $CHECKSTAT -t dir $DIR/R10 || error
728 $CHECKSTAT -a $DIR/R10/f || error
729 $CHECKSTAT -a $DIR/R10/g || error
731 run_test 24j "source does not exist ============================"
734 mkdir $DIR/R11a $DIR/R11a/d
736 mv $DIR/R11a/f $DIR/R11a/d
737 $CHECKSTAT -a $DIR/R11a/f || error
738 $CHECKSTAT -t file $DIR/R11a/d/f || error
740 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
742 # bug 2429 - rename foo foo foo creates invalid file
745 $MULTIOP $f OcNs || error
747 run_test 24l "Renaming a file to itself ========================"
751 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
752 # on ext3 this does not remove either the source or target files
753 # though the "expected" operation would be to remove the source
754 $CHECKSTAT -t file ${f} || error "${f} missing"
755 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
757 run_test 24m "Renaming a file to a hard link to itself ========="
761 # this stats the old file after it was renamed, so it should fail
765 $CHECKSTAT ${f}.rename
768 run_test 24n "Statting the old file after renaming (Posix rename 2)"
771 check_kernel_version 37 || return 0
773 rename_many -s random -v -n 10 $DIR/d24o
775 run_test 24o "rename of files during htree split ==============="
779 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
780 mrename $DIR/R12a $DIR/R12b
781 $CHECKSTAT -a $DIR/R12a || error
782 $CHECKSTAT -t dir $DIR/R12b || error
783 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
784 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
786 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
790 DIRINO=`ls -lid $DIR/R13a | awk '{ print $1 }'`
791 multiop_bg_pause $DIR/R13b D_c || return 1
794 mrename $DIR/R13a $DIR/R13b
795 $CHECKSTAT -a $DIR/R13a || error
796 $CHECKSTAT -t dir $DIR/R13b || error
797 DIRINO2=`ls -lid $DIR/R13b | awk '{ print $1 }'`
798 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
800 wait $MULTIPID || error "multiop close failed"
802 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
804 test_24r() { #bug 3789
805 mkdir $DIR/R14a $DIR/R14a/b
806 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
807 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
808 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
810 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
813 mkdir $DIR/R15a $DIR/R15a/b $DIR/R15a/b/c
814 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
815 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
816 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
818 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
820 mkdir $DIR/R16a $DIR/R16a/b $DIR/R16a/b/c
821 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
822 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
823 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
825 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
827 test_24u() { # bug12192
828 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error
829 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
831 run_test 24u "create stripe file"
839 local FREE_INODES=`lfs df -i|grep "filesystem summary" | awk '{print $5}'`
840 [ $FREE_INODES -lt $NRFILES ] && \
841 skip "not enough free inodes $FREE_INODES required $NRFILES" && \
845 createmany -m $DIR/d24v/$tfile $NRFILES
848 lctl set_param mdc.*.stats clear
850 ls $DIR/d24v >/dev/null || error "error in listing large dir"
853 # DIRENT_SIZE = 32 bytes for sizeof(struct lu_dirent) +
854 # 8 bytes for name(filename is mostly 5 in this test) +
855 # 8 bytes for luda_type
856 # take into account of overhead in lu_dirpage header and end mark in
857 # each page, plus one in RPC_NUM calculation.
859 RPC_SIZE=$(($(lctl get_param -n mdc.*.max_pages_per_rpc)*$(page_size)))
860 RPC_NUM=$(((NRFILES * DIRENT_SIZE + RPC_SIZE - 1) / RPC_SIZE + 1))
861 mds_readpage=`lctl get_param mdc.*.stats | \
862 awk '/^mds_readpage/ {print $2}'`
863 [ $mds_readpage -gt $RPC_NUM ] && \
864 error "large readdir doesn't take effect"
868 run_test 24v "list directory with large files (handle hash collision, bug: 17560)"
870 test_24w() { # bug21506
872 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
873 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
874 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
875 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
876 [ "$SZ1" = "$SZ2" ] || \
877 error "Error reading at the end of the file $tfile"
879 run_test 24w "Reading a file larger than 4Gb"
882 echo '== symlink sanity ============================================='
886 touch $DIR/s25/foo || error
888 run_test 25a "create file in symlinked directory ==============="
891 [ ! -d $DIR/d25 ] && test_25a
892 $CHECKSTAT -t file $DIR/s25/foo || error
894 run_test 25b "lookup file in symlinked directory ==============="
899 ln -s d26/d26-2 $DIR/s26
900 touch $DIR/s26/foo || error
902 run_test 26a "multiple component symlink ======================="
905 mkdir -p $DIR/d26b/d26-2
906 ln -s d26b/d26-2/foo $DIR/s26-2
907 touch $DIR/s26-2 || error
909 run_test 26b "multiple component symlink at end of lookup ======"
914 ln -s d26.2 $DIR/s26.2-1
915 ln -s s26.2-1 $DIR/s26.2-2
916 ln -s s26.2-2 $DIR/s26.2-3
917 chmod 0666 $DIR/s26.2-3/foo
919 run_test 26c "chain of symlinks ================================"
921 # recursive symlinks (bug 439)
923 ln -s d26-3/foo $DIR/d26-3
925 run_test 26d "create multiple component recursive symlink ======"
928 [ ! -h $DIR/d26-3 ] && test_26d
931 run_test 26e "unlink multiple component recursive symlink ======"
933 # recursive symlinks (bug 7022)
936 mkdir $DIR/$tdir/$tfile || error "mkdir $DIR/$tdir/$tfile failed"
937 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
938 mkdir -p lndir/bar1 || error "mkdir lndir/bar1 failed"
939 mkdir $tfile || error "mkdir $tfile failed"
940 cd $tfile || error "cd $tfile failed"
941 ln -s .. dotdot || error "ln dotdot failed"
942 ln -s dotdot/lndir lndir || error "ln lndir failed"
943 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
944 output=`ls $tfile/$tfile/lndir/bar1`
945 [ "$output" = bar1 ] && error "unexpected output"
946 rm -r $tfile || error "rm $tfile failed"
947 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
949 run_test 26f "rm -r of a directory which has recursive symlink ="
952 echo '== stripe sanity =============================================='
953 mkdir -p $DIR/d27 || error "mkdir failed"
955 $SETSTRIPE -c 1 $DIR/d27/f0 || error "setstripe failed"
956 $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
958 log "== test_27a: write to one stripe file ========================="
959 cp /etc/hosts $DIR/d27/f0 || error
961 run_test 27a "one stripe file =================================="
964 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
966 $SETSTRIPE -c 2 $DIR/d27/f01 || error "setstripe failed"
967 $GETSTRIPE -c $DIR/d27/f01
968 [ $($GETSTRIPE -c $DIR/d27/f01) -eq 2 ] ||
969 error "two-stripe file doesn't have two stripes"
971 run_test 27b "create two stripe file"
974 [ -f $DIR/d27/f01 ] || skip "test_27b not run" && return
976 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
978 run_test 27c "write to two stripe file"
982 $SETSTRIPE -c 0 -i -1 -S 0 $DIR/d27/fdef || error "setstripe failed"
983 $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
984 dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
986 run_test 27d "create file with default settings ================"
990 $SETSTRIPE -c 2 $DIR/d27/f12 || error "setstripe failed"
991 $SETSTRIPE -c 2 $DIR/d27/f12 && error "setstripe succeeded twice"
992 $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
994 run_test 27e "setstripe existing file (should return error) ======"
998 $SETSTRIPE -S 100 -i 0 -c 1 $DIR/d27/fbad && error "setstripe failed"
999 dd if=/dev/zero of=$DIR/d27/f12 bs=4k count=4 || error "dd failed"
1000 $GETSTRIPE $DIR/d27/fbad || error "$GETSTRIPE failed"
1002 run_test 27f "setstripe with bad stripe size (should return error)"
1006 $MCREATE $DIR/d27/fnone || error "mcreate failed"
1007 $GETSTRIPE $DIR/d27/fnone 2>&1 | grep "no stripe info" ||
1008 error "$DIR/d27/fnone has object"
1010 run_test 27g "$GETSTRIPE with no objects"
1013 touch $DIR/d27/fsome || error "touch failed"
1014 [ $($GETSTRIPE -c $DIR/d27/fsome) -gt 0 ] || error "missing objects"
1016 run_test 27i "$GETSTRIPE with some objects"
1020 $SETSTRIPE -i $OSTCOUNT $DIR/d27/f27j && error "setstripe failed"||true
1022 run_test 27j "setstripe with bad stripe offset (should return error)"
1024 test_27k() { # bug 2844
1027 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
1028 [ ! -d $DIR/d27 ] && mkdir -p $DIR/d27
1029 $SETSTRIPE -S 67108864 $FILE || error "setstripe failed"
1030 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1031 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
1032 dd if=/dev/zero of=$FILE bs=4k count=1
1033 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1034 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
1036 run_test 27k "limit i_blksize for broken user apps ============="
1040 mcreate $DIR/f27l || error "creating file"
1041 $RUNAS $SETSTRIPE -c 1 $DIR/f27l && \
1042 error "setstripe should have failed" || true
1044 run_test 27l "check setstripe permissions (should return error)"
1047 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1048 if [ $ORIGFREE -gt $MAXFREE ]; then
1049 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1053 $SETSTRIPE -i 0 -c 1 $DIR/d27/f27m_1
1054 dd if=/dev/zero of=$DIR/d27/f27m_1 bs=1024 count=$MAXFREE &&
1055 error "dd should fill OST0"
1057 while $SETSTRIPE -i 0 -c 1 $DIR/d27/f27m_$i; do
1059 [ $i -gt 256 ] && break
1062 touch $DIR/d27/f27m_$i
1063 [ `$GETSTRIPE $DIR/d27/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] && \
1064 error "OST0 was full but new created file still use it"
1066 touch $DIR/d27/f27m_$i
1067 [ `$GETSTRIPE $DIR/d27/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] && \
1068 error "OST0 was full but new created file still use it"
1072 run_test 27m "create file while OST0 was full =================="
1075 local DELAY=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage | head -n 1 | awk '{print $1 * 2}')
1079 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1080 # if the OST isn't full anymore.
1082 local OSTIDX=${1:-""}
1084 local list=$(comma_list $(osts_nodes))
1085 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1087 do_nodes $list lctl set_param fail_loc=0
1091 exhaust_precreations() {
1094 local FAILIDX=${3:-$OSTIDX}
1097 local MDSIDX=$(get_mds_dir "$DIR/$tdir")
1098 echo OSTIDX=$OSTIDX MDSIDX=$MDSIDX
1100 local OST=$(ostname_from_index $OSTIDX)
1101 local MDT_INDEX=$(lfs df | grep "\[MDT:$((MDSIDX - 1))\]" | awk '{print $1}' | \
1102 sed -e 's/_UUID$//;s/^.*-//')
1105 local mdtosc_proc1=$(get_mdtosc_proc_path mds${MDSIDX} $OST)
1106 local last_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1107 osc.$mdtosc_proc1.prealloc_last_id)
1108 local next_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1109 osc.$mdtosc_proc1.prealloc_next_id)
1111 local mdtosc_proc2=$(get_mdtosc_proc_path mds${MDSIDX})
1112 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1114 mkdir -p $DIR/$tdir/${OST}
1115 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1116 #define OBD_FAIL_OST_ENOSPC 0x215
1117 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=$FAILIDX
1118 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x215
1119 echo "Creating to objid $last_id on ost $OST..."
1120 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1121 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1122 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=$FAILLOC
1126 exhaust_all_precreations() {
1128 for (( i=0; i < OSTCOUNT; i++ )) ; do
1129 exhaust_precreations $i $1 -1
1134 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1135 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1136 remote_ost_nodsh && skip "remote OST with nodsh" && return
1139 rm -f $DIR/$tdir/$tfile
1140 exhaust_precreations 0 0x80000215
1141 $SETSTRIPE -c -1 $DIR/$tdir
1142 touch $DIR/$tdir/$tfile || error
1143 $GETSTRIPE $DIR/$tdir/$tfile
1146 run_test 27n "create file with some full OSTs =================="
1149 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1150 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1151 remote_ost_nodsh && skip "remote OST with nodsh" && return
1154 rm -f $DIR/$tdir/$tfile
1155 exhaust_all_precreations 0x215
1157 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1162 run_test 27o "create file with all full OSTs (should error) ===="
1165 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1166 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1167 remote_ost_nodsh && skip "remote OST with nodsh" && return
1170 rm -f $DIR/$tdir/$tfile
1173 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1174 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1175 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1177 exhaust_precreations 0 0x80000215
1178 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1179 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1180 $GETSTRIPE $DIR/$tdir/$tfile
1184 run_test 27p "append to a truncated file with some full OSTs ==="
1187 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1188 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1189 remote_ost_nodsh && skip "remote OST with nodsh" && return
1192 rm -f $DIR/$tdir/$tfile
1195 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1196 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||error "truncate $DIR/$tdir/$tfile failed"
1197 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1199 exhaust_all_precreations 0x215
1201 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1202 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1206 run_test 27q "append to truncated file with all OSTs full (should error) ==="
1209 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1210 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1211 remote_ost_nodsh && skip "remote OST with nodsh" && return
1214 rm -f $DIR/$tdir/$tfile
1215 exhaust_precreations 0 0x80000215
1217 $SETSTRIPE -i 0 -c 2 $DIR/$tdir/$tfile # && error
1221 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1223 test_27s() { # bug 10725
1225 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1226 local stripe_count=0
1227 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1228 $SETSTRIPE -S $stripe_size -c $stripe_count $DIR/$tdir &&
1229 error "stripe width >= 2^32 succeeded" || true
1232 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1234 test_27t() { # bug 10864
1239 $WLFS getstripe $tfile
1242 run_test 27t "check that utils parse path correctly"
1244 test_27u() { # bug 4900
1245 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1246 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1248 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1249 do_facet $SINGLEMDS lctl set_param fail_loc=0x139
1251 createmany -o $DIR/$tdir/t- 1000
1252 do_facet $SINGLEMDS lctl set_param fail_loc=0
1254 TLOG=$DIR/$tfile.getstripe
1255 $GETSTRIPE $DIR/$tdir > $TLOG
1256 OBJS=`awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj;}' $TLOG`
1257 unlinkmany $DIR/$tdir/t- 1000
1258 [ $OBJS -gt 0 ] && \
1259 error "$OBJS objects created on OST-0. See $TLOG" || pass
1261 run_test 27u "skip object creation on OSC w/o objects =========="
1263 test_27v() { # bug 4900
1264 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1265 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1266 remote_ost_nodsh && skip "remote OST with nodsh" && return
1268 exhaust_all_precreations 0x215
1272 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1274 touch $DIR/$tdir/$tfile
1275 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1277 for (( i=1; i < OSTCOUNT; i++ )); do
1278 do_facet ost$i lctl set_param fail_loc=0x705
1280 local START=`date +%s`
1281 createmany -o $DIR/$tdir/$tfile 32
1283 local FINISH=`date +%s`
1284 local TIMEOUT=`lctl get_param -n timeout`
1285 local PROCESS=$((FINISH - START))
1286 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1287 error "$FINISH - $START >= $TIMEOUT / 2"
1288 sleep $((TIMEOUT / 2 - PROCESS))
1291 run_test 27v "skip object creation on slow OST ================="
1293 test_27w() { # bug 10997
1294 mkdir -p $DIR/$tdir || error "mkdir failed"
1295 $SETSTRIPE -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1296 [ $($GETSTRIPE -S $DIR/$tdir/f0) -ne 65536 ] &&
1297 error "stripe size $size != 65536" || true
1298 [ $($GETSTRIPE -d $DIR/$tdir | grep -c "stripe_count") -ne 1 ] &&
1299 error "$GETSTRIPE -d $DIR/$tdir failed" || true
1301 run_test 27w "check $SETSTRIPE -S option"
1304 [ "$OSTCOUNT" -lt "2" ] &&
1305 skip_env "skipping multiple stripe count/offset test" && return
1307 mkdir -p $DIR/$tdir || error "mkdir failed"
1308 for i in $(seq 1 $OSTCOUNT); do
1310 $SETSTRIPE -c $i -i $offset $DIR/$tdir/f$i ||
1311 error "setstripe -c $i -i $offset failed"
1312 count=$($GETSTRIPE -c $DIR/$tdir/f$i)
1313 index=$($GETSTRIPE -i $DIR/$tdir/f$i)
1314 [ $count -ne $i ] && error "stripe count $count != $i" || true
1315 [ $index -ne $offset ] &&
1316 error "stripe offset $index != $offset" || true
1319 run_test 27wa "check $SETSTRIPE -c -i options"
1322 remote_ost_nodsh && skip "remote OST with nodsh" && return
1323 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs" && return
1324 OFFSET=$(($OSTCOUNT - 1))
1326 local OST=$(ostname_from_index $OSTIDX)
1329 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe per file
1330 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1332 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1333 for i in `seq 0 $OFFSET`; do
1334 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}' | grep -w "$OSTIDX"` ] &&
1335 error "OST0 was degraded but new created file still use it"
1337 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1339 run_test 27x "create files while OST0 is degraded"
1342 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1343 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1344 remote_ost_nodsh && skip "remote OST with nodsh" && return
1346 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1347 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1348 osc.$mdtosc.prealloc_last_id)
1349 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1350 osc.$mdtosc.prealloc_next_id)
1351 local fcount=$((last_id - next_id))
1352 [ $fcount -eq 0 ] && skip "not enough space on OST0" && return
1353 [ $fcount -gt $OSTCOUNT ] && fcount=$OSTCOUNT
1355 MDS_OSCS=`do_facet $SINGLEMDS lctl dl | awk '/[oO][sS][cC].*md[ts]/ { print $4 }'`
1356 OFFSET=$(($OSTCOUNT-1))
1358 for OSC in $MDS_OSCS; do
1359 if [ $OST == -1 ]; then {
1360 OST=`osc_to_ost $OSC`
1362 echo $OSC "is Deactivate:"
1363 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1367 OSTIDX=$(index_from_ostuuid $OST)
1369 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1371 do_facet ost$((OSTIDX+1)) lctl set_param -n obdfilter.$OST.degraded 1
1373 createmany -o $DIR/$tdir/$tfile $fcount
1374 do_facet ost$((OSTIDX+1)) lctl set_param -n obdfilter.$OST.degraded 0
1376 for i in `seq 0 $OFFSET`; do
1377 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "$OSTIDX"` ] || \
1378 error "files created on deactivated OSTs instead of degraded OST"
1380 for OSC in $MDS_OSCS; do
1381 [ `osc_to_ost $OSC` != $OST ] && {
1382 echo $OSC "is activate"
1383 do_facet $SINGLEMDS lctl --device %$OSC activate
1387 run_test 27y "create files while OST0 is degraded and the rest inactive"
1393 lmm_count=$($GETSTRIPE -c $1)
1394 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1395 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1397 local old_ifs="$IFS"
1399 fid=($($LFS path2fid $1))
1402 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1403 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1405 # compare lmm_seq and lu_fid->f_seq
1406 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1407 # compare lmm_object_id and lu_fid->oid
1408 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1410 # check the trusted.fid attribute of the OST objects of the file
1411 local have_obdidx=false
1413 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1414 # skip lines up to and including "obdidx"
1415 [ -z "$obdidx" ] && break
1416 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1417 $have_obdidx || continue
1419 local ost=$((obdidx + 1))
1420 local dev=$(ostdevname $ost)
1422 if [ $(facet_fstype ost$ost) != ldiskfs ]; then
1423 echo "Currently only works with ldiskfs-based OSTs"
1427 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1429 #don't unmount/remount the OSTs if we don't need to do that
1430 #local dir=$(facet_mntpt ost$ost)
1432 #do_facet ost$dev mount -t $FSTYPE $dev $dir $OST_MOUNT_OPTS ||
1433 # { error "mounting $dev as $FSTYPE failed"; return 3; }
1434 #local obj_file=$(do_facet ost$ost find $dir/O/$seq -name $oid)
1435 #local ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID $obj_file)
1437 local obj_file="O/$seq/d$((oid %32))/$oid"
1438 local ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
1439 $dev 2>/dev/null" | grep "parent=")
1441 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
1443 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
1445 #do_facet ost$ost umount -d $dir
1446 #start ost$ost $dev $OST_MOUNT_OPTS
1448 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
1449 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
1450 local ff_parent=$(echo $ff|sed -e 's/.*parent=.//')
1451 local ff_pseq=$(echo $ff_parent | cut -d: -f1)
1452 local ff_poid=$(echo $ff_parent | cut -d: -f2)
1453 local ff_pstripe=$(echo $ff_parent | sed -e 's/.*stripe=//')
1455 # compare lmm_seq and filter_fid->ff_parent.f_seq
1456 [ $ff_pseq = $lmm_seq ] ||
1457 error "FF parent SEQ $ff_pseq != $lmm_seq"
1458 # compare lmm_object_id and filter_fid->ff_parent.f_oid
1459 [ $ff_poid = $lmm_oid ] ||
1460 error "FF parent OID $ff_poid != $lmm_oid"
1461 [ $ff_pstripe = $stripe_nr ] ||
1462 error "FF stripe $ff_pstripe != $stripe_nr"
1464 stripe_nr=$((stripe_nr + 1))
1469 remote_ost_nodsh && skip "remote OST with nodsh" && return
1472 $SETSTRIPE -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
1473 { error "setstripe -c -1 failed"; return 1; }
1474 # We need to send a write to every object to get parent FID info set.
1475 # This _should_ also work for setattr, but does not currently.
1476 # touch $DIR/$tdir/$tfile-1 ||
1477 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
1478 { error "dd $tfile-1 failed"; return 2; }
1479 $SETSTRIPE -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
1480 { error "setstripe -c -1 failed"; return 3; }
1481 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
1482 { error "dd $tfile-2 failed"; return 4; }
1484 # make sure write RPCs have been sent to OSTs
1487 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
1488 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
1490 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
1492 test_27A() { # b=19102
1493 local restore_size=$($GETSTRIPE -S $MOUNT)
1494 local restore_count=$($GETSTRIPE -c $MOUNT)
1495 local restore_offset=$($GETSTRIPE -i $MOUNT)
1496 $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
1497 local default_size=$($GETSTRIPE -S $MOUNT)
1498 local default_count=$($GETSTRIPE -c $MOUNT)
1499 local default_offset=$($GETSTRIPE -i $MOUNT)
1500 local dsize=$((1024 * 1024))
1501 [ $default_size -eq $dsize ] ||
1502 error "stripe size $default_size != $dsize"
1503 [ $default_count -eq 1 ] || error "stripe count $default_count != 1"
1504 [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
1505 $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
1507 run_test 27A "check filesystem-wide default LOV EA values"
1509 # createtest also checks that device nodes are created and
1510 # then visible correctly (#2091)
1511 test_28() { # bug 2091
1513 $CREATETEST $DIR/d28/ct || error
1515 run_test 28 "create/mknod/mkdir with bad file types ============"
1518 cancel_lru_locks mdc
1524 declare -i LOCKCOUNTORIG=0
1525 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1526 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
1528 [ $LOCKCOUNTORIG -eq 0 ] && echo "No mdc lock count" && return 1
1530 declare -i LOCKUNUSEDCOUNTORIG=0
1531 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1532 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
1539 declare -i LOCKCOUNTCURRENT=0
1540 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1541 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
1544 declare -i LOCKUNUSEDCOUNTCURRENT=0
1545 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1546 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
1549 if [ "$LOCKCOUNTCURRENT" -gt "$LOCKCOUNTORIG" ]; then
1550 lctl set_param -n ldlm.dump_namespaces ""
1551 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
1552 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1553 log "dumped log to $TMP/test_29.dk (bug 5793)"
1556 if [ "$LOCKUNUSEDCOUNTCURRENT" -gt "$LOCKUNUSEDCOUNTORIG" ]; then
1557 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
1558 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1559 log "dumped log to $TMP/test_29.dk (bug 5793)"
1563 run_test 29 "IT_GETATTR regression ============================"
1565 test_30a() { # was test_30
1566 cp `which ls` $DIR || cp /bin/ls $DIR
1570 run_test 30a "execute binary from Lustre (execve) =============="
1573 cp `which ls` $DIR || cp /bin/ls $DIR
1575 $RUNAS $DIR/ls / || error
1578 run_test 30b "execute binary from Lustre as non-root ==========="
1580 test_30c() { # b=22376
1581 cp `which ls` $DIR || cp /bin/ls $DIR
1583 cancel_lru_locks mdc
1584 cancel_lru_locks osc
1585 $RUNAS $DIR/ls / || error
1588 run_test 30c "execute binary from Lustre without read perms ===="
1591 $OPENUNLINK $DIR/f31 $DIR/f31 || error
1592 $CHECKSTAT -a $DIR/f31 || error
1594 run_test 31a "open-unlink file =================================="
1597 touch $DIR/f31 || error
1598 ln $DIR/f31 $DIR/f31b || error
1599 $MULTIOP $DIR/f31b Ouc || error
1600 $CHECKSTAT -t file $DIR/f31 || error
1602 run_test 31b "unlink file with multiple links while open ======="
1605 touch $DIR/f31 || error
1606 ln $DIR/f31 $DIR/f31c || error
1607 multiop_bg_pause $DIR/f31 O_uc || return 1
1609 $MULTIOP $DIR/f31c Ouc
1610 kill -USR1 $MULTIPID
1613 run_test 31c "open-unlink file with multiple links ============="
1616 opendirunlink $DIR/d31d $DIR/d31d || error
1617 $CHECKSTAT -a $DIR/d31d || error
1619 run_test 31d "remove of open directory ========================="
1621 test_31e() { # bug 2904
1622 check_kernel_version 34 || return 0
1623 openfilleddirunlink $DIR/d31e || error
1625 run_test 31e "remove of open non-empty directory ==============="
1627 test_31f() { # bug 4554
1630 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
1631 cp /etc/hosts $DIR/d31f
1633 $GETSTRIPE $DIR/d31f/hosts
1634 multiop_bg_pause $DIR/d31f D_c || return 1
1637 rm -rv $DIR/d31f || error "first of $DIR/d31f"
1639 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
1640 cp /etc/hosts $DIR/d31f
1642 $GETSTRIPE $DIR/d31f/hosts
1643 multiop_bg_pause $DIR/d31f D_c || return 1
1646 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
1647 wait $MULTIPID || error "first opendir $MULTIPID failed"
1651 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
1652 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
1655 run_test 31f "remove of open directory with open-unlink file ==="
1658 echo "-- cross directory link --"
1659 mkdir $DIR/d31g{a,b}
1661 ln $DIR/d31ga/f $DIR/d31gb/g
1662 $CHECKSTAT -t file $DIR/d31ga/f || error "source"
1663 [ `stat -c%h $DIR/d31ga/f` == '2' ] || error "source nlink"
1664 $CHECKSTAT -t file $DIR/d31gb/g || error "target"
1665 [ `stat -c%h $DIR/d31gb/g` == '2' ] || error "target nlink"
1667 run_test 31g "cross directory link==============="
1670 echo "-- cross directory link --"
1674 ln $DIR/d31h/f $DIR/d31h/dir/g
1675 $CHECKSTAT -t file $DIR/d31h/f || error "source"
1676 [ `stat -c%h $DIR/d31h/f` == '2' ] || error "source nlink"
1677 $CHECKSTAT -t file $DIR/d31h/dir/g || error "target"
1678 [ `stat -c%h $DIR/d31h/dir/g` == '2' ] || error "target nlink"
1680 run_test 31h "cross directory link under child==============="
1683 echo "-- cross directory link --"
1686 touch $DIR/d31i/dir/f
1687 ln $DIR/d31i/dir/f $DIR/d31i/g
1688 $CHECKSTAT -t file $DIR/d31i/dir/f || error "source"
1689 [ `stat -c%h $DIR/d31i/dir/f` == '2' ] || error "source nlink"
1690 $CHECKSTAT -t file $DIR/d31i/g || error "target"
1691 [ `stat -c%h $DIR/d31i/g` == '2' ] || error "target nlink"
1693 run_test 31i "cross directory link under parent==============="
1698 mkdir $DIR/d31j/dir1
1699 ln $DIR/d31j/dir1 $DIR/d31j/dir2 && error "ln for dir"
1700 link $DIR/d31j/dir1 $DIR/d31j/dir3 && error "link for dir"
1701 mlink $DIR/d31j/dir1 $DIR/d31j/dir4 && error "mlink for dir"
1702 mlink $DIR/d31j/dir1 $DIR/d31j/dir1 && error "mlink to the same dir"
1705 run_test 31j "link for directory==============="
1711 touch $DIR/d31k/exist
1712 mlink $DIR/d31k/s $DIR/d31k/t || error "mlink"
1713 mlink $DIR/d31k/s $DIR/d31k/exist && error "mlink to exist file"
1714 mlink $DIR/d31k/s $DIR/d31k/s && error "mlink to the same file"
1715 mlink $DIR/d31k/s $DIR/d31k && error "mlink to parent dir"
1716 mlink $DIR/d31k $DIR/d31k/s && error "mlink parent dir to target"
1717 mlink $DIR/d31k/not-exist $DIR/d31k/foo && error "mlink non-existing to new"
1718 mlink $DIR/d31k/not-exist $DIR/d31k/s && error "mlink non-existing to exist"
1721 run_test 31k "link to file: the same, non-existing, dir==============="
1727 touch $DIR/d31m2/exist
1728 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
1729 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
1730 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
1731 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
1732 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
1733 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
1736 run_test 31m "link to file: the same, non-existing, dir==============="
1739 echo "== more mountpoints and symlinks ================="
1740 [ -e $DIR/d32a ] && rm -fr $DIR/d32a
1741 mkdir -p $DIR/d32a/ext2-mountpoint
1742 mount -t ext2 -o loop $EXT2_DEV $DIR/d32a/ext2-mountpoint || error
1743 $CHECKSTAT -t dir $DIR/d32a/ext2-mountpoint/.. || error
1744 $UMOUNT $DIR/d32a/ext2-mountpoint || error
1746 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
1749 [ -e $DIR/d32b ] && rm -fr $DIR/d32b
1750 mkdir -p $DIR/d32b/ext2-mountpoint
1751 mount -t ext2 -o loop $EXT2_DEV $DIR/d32b/ext2-mountpoint || error
1752 ls -al $DIR/d32b/ext2-mountpoint/.. || error
1753 $UMOUNT $DIR/d32b/ext2-mountpoint || error
1755 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
1758 [ -e $DIR/d32c ] && rm -fr $DIR/d32c
1759 mkdir -p $DIR/d32c/ext2-mountpoint
1760 mount -t ext2 -o loop $EXT2_DEV $DIR/d32c/ext2-mountpoint || error
1761 mkdir -p $DIR/d32c/d2/test_dir
1762 $CHECKSTAT -t dir $DIR/d32c/ext2-mountpoint/../d2/test_dir || error
1763 $UMOUNT $DIR/d32c/ext2-mountpoint || error
1765 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
1768 [ -e $DIR/d32d ] && rm -fr $DIR/d32d
1769 mkdir -p $DIR/d32d/ext2-mountpoint
1770 mount -t ext2 -o loop $EXT2_DEV $DIR/d32d/ext2-mountpoint || error
1771 mkdir -p $DIR/d32d/d2/test_dir
1772 ls -al $DIR/d32d/ext2-mountpoint/../d2/test_dir || error
1773 $UMOUNT $DIR/d32d/ext2-mountpoint || error
1775 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
1778 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
1779 mkdir -p $DIR/d32e/tmp
1780 TMP_DIR=$DIR/d32e/tmp
1781 ln -s $DIR/d32e $TMP_DIR/symlink11
1782 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1783 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
1784 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
1786 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
1789 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
1790 mkdir -p $DIR/d32f/tmp
1791 TMP_DIR=$DIR/d32f/tmp
1792 ln -s $DIR/d32f $TMP_DIR/symlink11
1793 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1794 ls $DIR/d32f/tmp/symlink11 || error
1795 ls $DIR/d32f/symlink01 || error
1797 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
1800 TMP_DIR=$DIR/$tdir/tmp
1801 mkdir -p $TMP_DIR $DIR/${tdir}2
1802 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
1803 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1804 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
1805 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
1806 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
1807 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
1809 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
1812 rm -fr $DIR/$tdir $DIR/${tdir}2
1813 TMP_DIR=$DIR/$tdir/tmp
1814 mkdir -p $TMP_DIR $DIR/${tdir}2
1815 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
1816 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1817 ls $TMP_DIR/symlink12 || error
1818 ls $DIR/$tdir/symlink02 || error
1820 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
1823 [ -e $DIR/d32i ] && rm -fr $DIR/d32i
1824 mkdir -p $DIR/d32i/ext2-mountpoint
1825 mount -t ext2 -o loop $EXT2_DEV $DIR/d32i/ext2-mountpoint || error
1826 touch $DIR/d32i/test_file
1827 $CHECKSTAT -t file $DIR/d32i/ext2-mountpoint/../test_file || error
1828 $UMOUNT $DIR/d32i/ext2-mountpoint || error
1830 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
1833 [ -e $DIR/d32j ] && rm -fr $DIR/d32j
1834 mkdir -p $DIR/d32j/ext2-mountpoint
1835 mount -t ext2 -o loop $EXT2_DEV $DIR/d32j/ext2-mountpoint || error
1836 touch $DIR/d32j/test_file
1837 cat $DIR/d32j/ext2-mountpoint/../test_file || error
1838 $UMOUNT $DIR/d32j/ext2-mountpoint || error
1840 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
1844 mkdir -p $DIR/d32k/ext2-mountpoint
1845 mount -t ext2 -o loop $EXT2_DEV $DIR/d32k/ext2-mountpoint
1846 mkdir -p $DIR/d32k/d2
1847 touch $DIR/d32k/d2/test_file || error
1848 $CHECKSTAT -t file $DIR/d32k/ext2-mountpoint/../d2/test_file || error
1849 $UMOUNT $DIR/d32k/ext2-mountpoint || error
1851 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
1855 mkdir -p $DIR/d32l/ext2-mountpoint
1856 mount -t ext2 -o loop $EXT2_DEV $DIR/d32l/ext2-mountpoint || error
1857 mkdir -p $DIR/d32l/d2
1858 touch $DIR/d32l/d2/test_file
1859 cat $DIR/d32l/ext2-mountpoint/../d2/test_file || error
1860 $UMOUNT $DIR/d32l/ext2-mountpoint || error
1862 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
1866 mkdir -p $DIR/d32m/tmp
1867 TMP_DIR=$DIR/d32m/tmp
1868 ln -s $DIR $TMP_DIR/symlink11
1869 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1870 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
1871 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
1873 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
1877 mkdir -p $DIR/d32n/tmp
1878 TMP_DIR=$DIR/d32n/tmp
1879 ln -s $DIR $TMP_DIR/symlink11
1880 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1881 ls -l $DIR/d32n/tmp/symlink11 || error
1882 ls -l $DIR/d32n/symlink01 || error
1884 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
1887 rm -fr $DIR/d32o $DIR/$tfile
1889 mkdir -p $DIR/d32o/tmp
1890 TMP_DIR=$DIR/d32o/tmp
1891 ln -s $DIR/$tfile $TMP_DIR/symlink12
1892 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1893 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
1894 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
1895 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
1896 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
1898 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
1908 mkdir -p $DIR/d32p/tmp
1910 TMP_DIR=$DIR/d32p/tmp
1912 ln -s $DIR/$tfile $TMP_DIR/symlink12
1914 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1916 cat $DIR/d32p/tmp/symlink12 || error
1918 cat $DIR/d32p/symlink02 || error
1921 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
1924 [ -e $DIR/d32q ] && rm -fr $DIR/d32q
1926 touch $DIR/d32q/under_the_mount
1927 mount -t ext2 -o loop $EXT2_DEV $DIR/d32q
1928 ls $DIR/d32q/under_the_mount && error || true
1929 $UMOUNT $DIR/d32q || error
1931 run_test 32q "stat follows mountpoints in Lustre (should return error)"
1934 [ -e $DIR/d32r ] && rm -fr $DIR/d32r
1936 touch $DIR/d32r/under_the_mount
1937 mount -t ext2 -o loop $EXT2_DEV $DIR/d32r
1938 ls $DIR/d32r | grep -q under_the_mount && error || true
1939 $UMOUNT $DIR/d32r || error
1941 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
1946 chmod 444 $DIR/$tfile
1947 chown $RUNAS_ID $DIR/$tfile
1949 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
1952 run_test 33 "write file with mode 444 (should return error) ===="
1957 chown $RUNAS_ID $DIR/d33
1958 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
1959 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
1960 error "open RDWR" || true
1962 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
1967 chown $RUNAS_ID $DIR/d33
1968 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33 && error "create" || true
1970 run_test 33b "test open file with malformed flags (No panic and return error)"
1978 remote_ost_nodsh && skip "remote OST with nodsh" && return
1982 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
1985 for ostnum in $(seq $OSTCOUNT); do
1986 # test-framework's OST numbering is one-based, while Lustre's
1988 ostname=$(printf "$FSNAME-OST%.4d" $((ostnum - 1)))
1989 # Parsing llobdstat's output sucks; we could grep the /proc
1990 # path, but that's likely to not be as portable as using the
1991 # llobdstat utility. So we parse lctl output instead.
1992 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
1993 obdfilter/$ostname/stats |
1994 awk '/^write_bytes/ {print $7}' )
1995 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
1996 if (( ${write_bytes:-0} > 0 ))
2003 $all_zeros || return 0
2006 echo foo > $DIR/d33/bar
2010 # Total up write_bytes after writing. We'd better find non-zeros.
2011 for ostnum in $(seq $OSTCOUNT); do
2012 ostname=$(printf "$FSNAME-OST%.4d" $((ostnum - 1)))
2013 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2014 obdfilter/$ostname/stats |
2015 awk '/^write_bytes/ {print $7}' )
2016 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2017 if (( ${write_bytes:-0} > 0 ))
2026 for ostnum in $(seq $OSTCOUNT); do
2027 ostname=$(printf "$FSNAME-OST%.4d" $((ostnum - 1)))
2028 echo "Check that write_bytes is present in obdfilter/*/stats:"
2029 do_facet ost$ostnum lctl get_param -n \
2030 obdfilter/$ostname/stats
2032 error "OST not keeping write_bytes stats (b22312)"
2035 run_test 33c "test llobdstat and write_bytes"
2037 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
2040 $MCREATE $DIR/f34 || error
2041 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2042 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
2043 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2044 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2046 run_test 34a "truncate file that has not been opened ==========="
2049 [ ! -f $DIR/f34 ] && test_34a
2050 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2051 $OPENFILE -f O_RDONLY $DIR/f34
2052 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2053 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2055 run_test 34b "O_RDONLY opening file doesn't create objects ====="
2058 [ ! -f $DIR/f34 ] && test_34a
2059 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2060 $OPENFILE -f O_RDWR $DIR/f34
2061 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2062 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2064 run_test 34c "O_RDWR opening file-with-size works =============="
2067 [ ! -f $DIR/f34 ] && test_34a
2068 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2069 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2072 run_test 34d "write to sparse file ============================="
2076 $MCREATE $DIR/f34e || error
2077 $TRUNCATE $DIR/f34e 1000 || error
2078 $CHECKSTAT -s 1000 $DIR/f34e || error
2079 $OPENFILE -f O_RDWR $DIR/f34e
2080 $CHECKSTAT -s 1000 $DIR/f34e || error
2082 run_test 34e "create objects, some with size and some without =="
2084 test_34f() { # bug 6242, 6243
2087 $MCREATE $DIR/f34f || error
2088 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
2089 dd if=$DIR/f34f of=$TMP/f34f
2090 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
2091 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
2092 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
2093 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
2094 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
2096 run_test 34f "read from a file with no objects until EOF ======="
2099 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
2100 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
2101 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
2102 cancel_lru_locks osc
2103 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
2104 error "wrong size after lock cancel"
2106 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
2107 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2108 error "expanding truncate failed"
2109 cancel_lru_locks osc
2110 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2111 error "wrong expanded size after lock cancel"
2113 run_test 34g "truncate long file ==============================="
2119 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
2120 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
2124 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
2125 error "Multiop blocked on ftruncate, pid=$MULTIPID"
2129 local nsz=`stat -c %s $DIR/$tfile`
2130 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
2132 run_test 34h "ftruncate file under grouplock should not block"
2135 cp /bin/sh $DIR/f35a
2137 chown $RUNAS_ID $DIR/f35a
2138 $RUNAS $DIR/f35a && error || true
2141 run_test 35a "exec file with mode 444 (should return and not leak) ====="
2145 utime $DIR/f36 || error
2147 run_test 36a "MDS utime check (mknod, utime) ==================="
2151 utime $DIR/f36 || error
2153 run_test 36b "OST utime check (open, utime) ===================="
2158 chown $RUNAS_ID $DIR/d36
2159 $RUNAS utime $DIR/d36/f36 || error
2161 run_test 36c "non-root MDS utime check (mknod, utime) =========="
2164 [ ! -d $DIR/d36 ] && test_36c
2165 echo "" > $DIR/d36/f36
2166 $RUNAS utime $DIR/d36/f36 || error
2168 run_test 36d "non-root OST utime check (open, utime) ==========="
2171 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
2173 touch $DIR/$tdir/$tfile
2174 $RUNAS utime $DIR/$tdir/$tfile && \
2175 error "utime worked, expected failure" || true
2177 run_test 36e "utime on non-owned file (should return error) ===="
2181 local LANG_SAVE=$LANG
2182 local LC_LANG_SAVE=$LC_LANG
2183 export LANG=C LC_LANG=C # for date language
2185 DATESTR="Dec 20 2000"
2187 lctl set_param fail_loc=$fl
2189 cp /etc/hosts $DIR/$tdir/$tfile
2190 sync & # write RPC generated with "current" inode timestamp, but delayed
2192 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
2193 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
2194 cancel_lru_locks osc
2195 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
2197 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
2198 echo "BEFORE: $LS_BEFORE" && \
2199 echo "AFTER : $LS_AFTER" && \
2200 echo "WANT : $DATESTR" && \
2201 error "$DIR/$tdir/$tfile timestamps changed" || true
2203 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
2207 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2208 subr_36fh "0x80000214"
2210 run_test 36f "utime on file racing with OST BRW write =========="
2213 remote_ost_nodsh && skip "remote OST with nodsh" && return
2219 fmd_max_age=$(do_facet ost1 \
2220 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
2223 fmd_before=$(do_facet ost1 \
2224 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2225 touch $DIR/$tdir/$tfile
2226 sleep $((fmd_max_age + 12))
2227 fmd_after=$(do_facet ost1 \
2228 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2230 echo "fmd_before: $fmd_before"
2231 echo "fmd_after: $fmd_after"
2232 [ "$fmd_after" -gt "$fmd_before" ] && \
2233 echo "AFTER: $fmd_after > BEFORE: $fmd_before" && \
2234 error "fmd didn't expire after ping" || true
2236 run_test 36g "filter mod data cache expiry ====================="
2239 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
2240 subr_36fh "0x80000227"
2242 run_test 36h "utime on file racing with OST BRW write =========="
2246 echo f > $DIR/$tdir/fbugfile
2247 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2248 ls $DIR/$tdir | grep "\<fbugfile\>" && error
2249 $UMOUNT $DIR/$tdir || error
2250 rm -f $DIR/$tdir/fbugfile || error
2252 run_test 37 "ls a mounted file system to check old content ====="
2255 local file=$DIR/$tfile
2257 openfile -f O_DIRECTORY $file
2260 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
2261 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
2263 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
2267 touch $DIR/${tfile}2
2268 # ls -l $DIR/$tfile $DIR/${tfile}2
2269 # ls -lu $DIR/$tfile $DIR/${tfile}2
2270 # ls -lc $DIR/$tfile $DIR/${tfile}2
2272 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
2273 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
2275 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
2277 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
2279 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
2280 error "O_TRUNC didn't change timestamps"
2283 run_test 39 "mtime changed on create ==========================="
2287 cp -p /etc/passwd $DIR/$tdir/fopen
2288 cp -p /etc/passwd $DIR/$tdir/flink
2289 cp -p /etc/passwd $DIR/$tdir/funlink
2290 cp -p /etc/passwd $DIR/$tdir/frename
2291 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
2294 echo "aaaaaa" >> $DIR/$tdir/fopen
2295 echo "aaaaaa" >> $DIR/$tdir/flink
2296 echo "aaaaaa" >> $DIR/$tdir/funlink
2297 echo "aaaaaa" >> $DIR/$tdir/frename
2299 local open_new=`stat -c %Y $DIR/$tdir/fopen`
2300 local link_new=`stat -c %Y $DIR/$tdir/flink`
2301 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
2302 local rename_new=`stat -c %Y $DIR/$tdir/frename`
2304 cat $DIR/$tdir/fopen > /dev/null
2305 ln $DIR/$tdir/flink $DIR/$tdir/flink2
2306 rm -f $DIR/$tdir/funlink2
2307 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
2309 for (( i=0; i < 2; i++ )) ; do
2310 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
2311 local link_new2=`stat -c %Y $DIR/$tdir/flink`
2312 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
2313 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
2315 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
2316 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
2317 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
2318 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
2320 cancel_lru_locks osc
2321 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2324 run_test 39b "mtime change on open, link, unlink, rename ======"
2326 # this should be set to past
2327 TEST_39_MTIME=`date -d "1 year ago" +%s`
2333 local mtime0=`stat -c %Y $DIR1/$tfile`
2335 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2336 local mtime1=`stat -c %Y $DIR1/$tfile`
2337 [ "$mtime1" = $TEST_39_MTIME ] || \
2338 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
2341 echo hello >> $DIR1/$tfile
2343 local mtime2=`stat -c %Y $DIR1/$tfile`
2344 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
2345 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
2347 mv $DIR1/$tfile $DIR1/$tfile-1
2349 for (( i=0; i < 2; i++ )) ; do
2350 local mtime3=`stat -c %Y $DIR1/$tfile-1`
2351 [ "$mtime2" = "$mtime3" ] || \
2352 error "mtime ($mtime2) changed (to $mtime3) on rename"
2354 cancel_lru_locks osc
2355 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2358 run_test 39c "mtime change on rename ==========================="
2364 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2366 for (( i=0; i < 2; i++ )) ; do
2367 local mtime=`stat -c %Y $DIR1/$tfile`
2368 [ $mtime = $TEST_39_MTIME ] || \
2369 error "mtime($mtime) is not set to $TEST_39_MTIME"
2371 cancel_lru_locks osc
2372 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2375 run_test 39d "create, utime, stat =============================="
2380 local mtime1=`stat -c %Y $DIR1/$tfile`
2382 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2384 for (( i=0; i < 2; i++ )) ; do
2385 local mtime2=`stat -c %Y $DIR1/$tfile`
2386 [ $mtime2 = $TEST_39_MTIME ] || \
2387 error "mtime($mtime2) is not set to $TEST_39_MTIME"
2389 cancel_lru_locks osc
2390 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2393 run_test 39e "create, stat, utime, stat ========================"
2398 mtime1=`stat -c %Y $DIR1/$tfile`
2401 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2403 for (( i=0; i < 2; i++ )) ; do
2404 local mtime2=`stat -c %Y $DIR1/$tfile`
2405 [ $mtime2 = $TEST_39_MTIME ] || \
2406 error "mtime($mtime2) is not set to $TEST_39_MTIME"
2408 cancel_lru_locks osc
2409 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2412 run_test 39f "create, stat, sleep, utime, stat ================="
2416 echo hello >> $DIR1/$tfile
2417 local mtime1=`stat -c %Y $DIR1/$tfile`
2420 chmod o+r $DIR1/$tfile
2422 for (( i=0; i < 2; i++ )) ; do
2423 local mtime2=`stat -c %Y $DIR1/$tfile`
2424 [ "$mtime1" = "$mtime2" ] || \
2425 error "lost mtime: $mtime2, should be $mtime1"
2427 cancel_lru_locks osc
2428 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2431 run_test 39g "write, chmod, stat ==============================="
2439 echo hello >> $DIR1/$tfile
2440 local mtime1=`stat -c %Y $DIR1/$tfile`
2442 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2444 if [ "$d1" != "$d2" ]; then
2445 echo "write and touch not within one second"
2447 for (( i=0; i < 2; i++ )) ; do
2448 local mtime2=`stat -c %Y $DIR1/$tfile`
2449 [ "$mtime2" = $TEST_39_MTIME ] || \
2450 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
2452 cancel_lru_locks osc
2453 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2457 run_test 39h "write, utime within one second, stat ============="
2463 echo hello >> $DIR1/$tfile
2464 local mtime1=`stat -c %Y $DIR1/$tfile`
2466 mv $DIR1/$tfile $DIR1/$tfile-1
2468 for (( i=0; i < 2; i++ )) ; do
2469 local mtime2=`stat -c %Y $DIR1/$tfile-1`
2471 [ "$mtime1" = "$mtime2" ] || \
2472 error "lost mtime: $mtime2, should be $mtime1"
2474 cancel_lru_locks osc
2475 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2478 run_test 39i "write, rename, stat =============================="
2481 start_full_debug_logging
2485 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
2486 lctl set_param fail_loc=0x80000412
2487 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
2488 error "multiop failed"
2490 local mtime1=`stat -c %Y $DIR1/$tfile`
2492 mv $DIR1/$tfile $DIR1/$tfile-1
2494 kill -USR1 $multipid
2495 wait $multipid || error "multiop close failed"
2497 for (( i=0; i < 2; i++ )) ; do
2498 local mtime2=`stat -c %Y $DIR1/$tfile-1`
2499 [ "$mtime1" = "$mtime2" ] ||
2500 error "mtime is lost on close: $mtime2, " \
2503 cancel_lru_locks osc
2504 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2506 lctl set_param fail_loc=0
2507 stop_full_debug_logging
2509 run_test 39j "write, rename, close, stat ======================="
2515 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
2517 local mtime1=`stat -c %Y $DIR1/$tfile`
2519 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2521 kill -USR1 $multipid
2522 wait $multipid || error "multiop close failed"
2524 for (( i=0; i < 2; i++ )) ; do
2525 local mtime2=`stat -c %Y $DIR1/$tfile`
2527 [ "$mtime2" = $TEST_39_MTIME ] || \
2528 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
2530 cancel_lru_locks osc
2531 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2534 run_test 39k "write, utime, close, stat ========================"
2536 # this should be set to future
2537 TEST_39_ATIME=`date -d "1 year" +%s`
2540 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2541 local atime_diff=$(do_facet $SINGLEMDS lctl get_param -n mdd.*.atime_diff)
2545 # test setting directory atime to future
2546 touch -a -d @$TEST_39_ATIME $DIR/$tdir
2547 local atime=$(stat -c %X $DIR/$tdir)
2548 [ "$atime" = $TEST_39_ATIME ] || \
2549 error "atime is not set to future: $atime, should be $TEST_39_ATIME"
2551 # test setting directory atime from future to now
2552 local d1=$(date +%s)
2554 local d2=$(date +%s)
2556 cancel_lru_locks mdc
2557 atime=$(stat -c %X $DIR/$tdir)
2558 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
2559 error "atime is not updated from future: $atime, should be $d1<atime<$d2"
2561 do_facet $SINGLEMDS lctl set_param -n mdd.*.atime_diff=2
2564 # test setting directory atime when now > dir atime + atime_diff
2568 cancel_lru_locks mdc
2569 atime=$(stat -c %X $DIR/$tdir)
2570 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
2571 error "atime is not updated : $atime, should be $d2"
2573 do_facet $SINGLEMDS lctl set_param -n mdd.*.atime_diff=60
2576 # test not setting directory atime when now < dir atime + atime_diff
2578 cancel_lru_locks mdc
2579 atime=$(stat -c %X $DIR/$tdir)
2580 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
2581 error "atime is updated to $atime, should remain $d1<atime<$d2"
2583 do_facet $SINGLEMDS lctl set_param -n mdd.*.atime_diff=$atime_diff
2585 run_test 39l "directory atime update ==========================="
2590 local far_past_mtime=$(date -d "May 29 1953" +%s)
2591 local far_past_atime=$(date -d "Dec 17 1903" +%s)
2593 touch -m -d @$far_past_mtime $DIR1/$tfile
2594 touch -a -d @$far_past_atime $DIR1/$tfile
2596 for (( i=0; i < 2; i++ )) ; do
2597 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
2598 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
2599 error "atime or mtime set incorrectly"
2601 cancel_lru_locks osc
2602 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2605 run_test 39m "test atime and mtime before 1970"
2608 dd if=/dev/zero of=$DIR/f40 bs=4096 count=1
2609 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/f40 && error
2610 $CHECKSTAT -t file -s 4096 $DIR/f40 || error
2612 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
2616 small_write $DIR/f41 18
2618 run_test 41 "test small file write + fstat ====================="
2620 count_ost_writes() {
2621 lctl get_param -n osc.*.stats |
2622 awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }'
2629 BG_DIRTY_RATIO_SAVE=10
2630 MAX_BG_DIRTY_RATIO=25
2634 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
2635 # dirty_ratio, dirty_background_ratio
2636 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
2637 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
2638 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
2639 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
2641 # if file not here, we are a 2.4 kernel
2642 kill -CONT `pidof kupdated`
2647 # setup the trap first, so someone cannot exit the test at the
2648 # exact wrong time and mess up a machine
2649 trap start_writeback EXIT
2650 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
2651 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
2652 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
2653 sysctl -w vm.dirty_writeback_centisecs=0
2654 sysctl -w vm.dirty_writeback_centisecs=0
2655 # save and increase /proc/sys/vm/dirty_ratio
2656 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
2657 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
2658 # save and increase /proc/sys/vm/dirty_background_ratio
2659 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
2660 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
2662 # if file not here, we are a 2.4 kernel
2663 kill -STOP `pidof kupdated`
2667 # ensure that all stripes have some grant before we test client-side cache
2669 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
2670 dd if=/dev/zero of=$i bs=4k count=1
2675 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
2676 # file truncation, and file removal.
2679 cancel_lru_locks osc
2681 sync; sleep 1; sync # just to be safe
2682 BEFOREWRITES=`count_ost_writes`
2683 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
2684 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
2685 AFTERWRITES=`count_ost_writes`
2686 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
2687 error "$BEFOREWRITES < $AFTERWRITES"
2690 run_test 42a "ensure that we don't flush on close =============="
2694 cancel_lru_locks osc
2697 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
2698 BEFOREWRITES=`count_ost_writes`
2699 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
2700 AFTERWRITES=`count_ost_writes`
2701 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
2702 error "$BEFOREWRITES < $AFTERWRITES on unlink"
2704 BEFOREWRITES=`count_ost_writes`
2705 sync || error "sync: $?"
2706 AFTERWRITES=`count_ost_writes`
2707 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
2708 error "$BEFOREWRITES < $AFTERWRITES on sync"
2710 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
2714 run_test 42b "test destroy of file with cached dirty data ======"
2716 # if these tests just want to test the effect of truncation,
2717 # they have to be very careful. consider:
2718 # - the first open gets a {0,EOF}PR lock
2719 # - the first write conflicts and gets a {0, count-1}PW
2720 # - the rest of the writes are under {count,EOF}PW
2721 # - the open for truncate tries to match a {0,EOF}PR
2722 # for the filesize and cancels the PWs.
2723 # any number of fixes (don't get {0,EOF} on open, match
2724 # composite locks, do smarter file size management) fix
2725 # this, but for now we want these tests to verify that
2726 # the cancellation with truncate intent works, so we
2727 # start the file with a full-file pw lock to match against
2728 # until the truncate.
2733 cancel_lru_locks osc
2735 # prime the file with 0,EOF PW to match
2739 # now the real test..
2740 dd if=/dev/zero of=$file bs=1024 count=100
2741 BEFOREWRITES=`count_ost_writes`
2742 $TRUNCATE $file $offset
2743 cancel_lru_locks osc
2744 AFTERWRITES=`count_ost_writes`
2750 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
2751 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
2754 run_test 42c "test partial truncate of file with cached dirty data"
2758 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
2759 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
2762 run_test 42d "test complete truncate of file with cached dirty data"
2764 test_42e() { # bug22074
2765 local TDIR=$DIR/${tdir}e
2766 local pagesz=$(page_size)
2767 local pages=16 # hardcoded 16 pages, don't change it.
2768 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
2769 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
2774 $SETSTRIPE -c 1 $TDIR
2775 createmany -o $TDIR/f $files
2777 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
2779 # we assume that with $OSTCOUNT files, at least one of them will
2780 # be allocated on OST0.
2781 warmup_files=$((OSTCOUNT * max_dirty_mb))
2782 createmany -o $TDIR/w $warmup_files
2784 # write a large amount of data into one file and sync, to get good
2785 # avail_grant number from OST.
2786 for ((i=0; i<$warmup_files; i++)); do
2787 idx=$($GETSTRIPE -i $TDIR/w$i)
2788 [ $idx -ne 0 ] && continue
2789 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
2792 [ $i -gt $warmup_files ] && error "OST0 is still cold"
2794 $LCTL get_param $proc_osc0/cur_dirty_bytes
2795 $LCTL get_param $proc_osc0/cur_grant_bytes
2797 # create as much dirty pages as we can while not to trigger the actual
2798 # RPCs directly. but depends on the env, VFS may trigger flush during this
2799 # period, hopefully we are good.
2800 for ((i=0; i<$warmup_files; i++)); do
2801 idx=$($GETSTRIPE -i $TDIR/w$i)
2802 [ $idx -ne 0 ] && continue
2803 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
2805 $LCTL get_param $proc_osc0/cur_dirty_bytes
2806 $LCTL get_param $proc_osc0/cur_grant_bytes
2808 # perform the real test
2809 $LCTL set_param $proc_osc0/rpc_stats 0
2810 for ((;i<$files; i++)); do
2811 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
2812 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
2815 $LCTL get_param $proc_osc0/rpc_stats
2818 local have_ppr=false
2819 $LCTL get_param $proc_osc0/rpc_stats |
2820 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
2821 # skip lines until we are at the RPC histogram data
2822 [ "$PPR" == "pages" ] && have_ppr=true && continue
2823 $have_ppr || continue
2825 # we only want the percent stat for < 16 pages
2826 [ $(echo $PPR | tr -d ':') -ge $pages ] && break
2828 percent=$((percent + WPCT))
2829 if [ $percent -gt 15 ]; then
2830 error "less than 16-pages write RPCs" \
2837 run_test 42e "verify sub-RPC writes are not done synchronously"
2841 cp -p /bin/ls $DIR/$tdir/$tfile
2842 $MULTIOP $DIR/$tdir/$tfile Ow_c &
2844 # give multiop a chance to open
2847 $DIR/$tdir/$tfile && error || true
2850 run_test 43 "execution of file opened for write should return -ETXTBSY"
2854 cp -p `which $MULTIOP` $DIR/d43/multiop || cp -p multiop $DIR/d43/multiop
2855 MULTIOP_PROG=$DIR/d43/multiop multiop_bg_pause $TMP/test43.junk O_c || return 1
2857 $MULTIOP $DIR/d43/multiop Oc && error "expected error, got success"
2858 kill -USR1 $MULTIOP_PID || return 2
2859 wait $MULTIOP_PID || return 3
2862 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
2866 cp -p `which $MULTIOP` $DIR/d43/multiop || cp -p multiop $DIR/d43/multiop
2867 MULTIOP_PROG=$DIR/d43/multiop multiop_bg_pause $TMP/test43.junk O_c || return 1
2869 $TRUNCATE $DIR/d43/multiop 0 && error "expected error, got success"
2870 kill -USR1 $MULTIOP_PID || return 2
2871 wait $MULTIOP_PID || return 3
2874 run_test 43b "truncate of file being executed should return -ETXTBSY"
2877 local testdir="$DIR/d43c"
2880 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
2881 ( cd $testdir && md5sum -c)
2883 run_test 43c "md5sum of copy into lustre========================"
2886 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
2887 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
2888 dd if=$DIR/f1 bs=4k count=1 > /dev/null
2890 run_test 44 "zero length read from a sparse stripe ============="
2893 local nstripe=`$LCTL lov_getconfig $DIR | grep default_stripe_count: | \
2895 [ -z "$nstripe" ] && skip "can't get stripe info" && return
2896 [ "$nstripe" -gt "$OSTCOUNT" ] && skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" && return
2897 local stride=`$LCTL lov_getconfig $DIR | grep default_stripe_size: | \
2899 if [ $nstripe -eq 0 -o $nstripe -eq -1 ] ; then
2900 nstripe=`$LCTL lov_getconfig $DIR | grep obd_count: | awk '{print $2}'`
2903 OFFSETS="0 $((stride/2)) $((stride-1))"
2904 for offset in $OFFSETS ; do
2905 for i in `seq 0 $((nstripe-1))`; do
2906 local GLOBALOFFSETS=""
2907 local size=$((((i + 2 * $nstripe )*$stride + $offset))) # Bytes
2908 local myfn=$DIR/d44a-$size
2909 echo "--------writing $myfn at $size"
2910 ll_sparseness_write $myfn $size || error "ll_sparseness_write"
2911 GLOBALOFFSETS="$GLOBALOFFSETS $size"
2912 ll_sparseness_verify $myfn $GLOBALOFFSETS \
2913 || error "ll_sparseness_verify $GLOBALOFFSETS"
2915 for j in `seq 0 $((nstripe-1))`; do
2916 size=$((((j + $nstripe )*$stride + $offset))) # Bytes
2917 ll_sparseness_write $myfn $size || error "ll_sparseness_write"
2918 GLOBALOFFSETS="$GLOBALOFFSETS $size"
2920 ll_sparseness_verify $myfn $GLOBALOFFSETS \
2921 || error "ll_sparseness_verify $GLOBALOFFSETS"
2926 run_test 44a "test sparse pwrite ==============================="
2930 for d in `lctl get_param -n osc.*.cur_dirty_bytes`; do
2936 before=`dirty_osc_total`
2937 echo executing "\"$*\""
2939 after=`dirty_osc_total`
2940 echo before $before, after $after
2944 # Obtain grants from OST if it supports it
2945 echo blah > ${f}_grant
2948 do_dirty_record "echo blah > $f"
2949 [ $before -eq $after ] && error "write wasn't cached"
2950 do_dirty_record "> $f"
2951 [ $before -gt $after ] || error "truncate didn't lower dirty count"
2952 do_dirty_record "echo blah > $f"
2953 [ $before -eq $after ] && error "write wasn't cached"
2954 do_dirty_record "sync"
2955 [ $before -gt $after ] || error "writeback didn't lower dirty count"
2956 do_dirty_record "echo blah > $f"
2957 [ $before -eq $after ] && error "write wasn't cached"
2958 do_dirty_record "cancel_lru_locks osc"
2959 [ $before -gt $after ] || error "lock cancellation didn't lower dirty count"
2962 run_test 45 "osc io page accounting ============================"
2964 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
2965 # test tickles a bug where re-dirtying a page was failing to be mapped to the
2966 # objects offset and an assert hit when an rpc was built with 1023's mapped
2967 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
2972 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
2974 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
2975 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
2979 run_test 46 "dirtying a previously written page ================"
2981 # test_47 is removed "Device nodes check" is moved to test_28
2983 test_48a() { # bug 2399
2984 check_kernel_version 34 || return 0
2987 mv $DIR/d48a $DIR/d48.new || error "move directory failed"
2988 mkdir $DIR/d48a || error "recreate directory failed"
2989 touch foo || error "'touch foo' failed after recreating cwd"
2990 mkdir bar || error "'mkdir foo' failed after recreating cwd"
2991 if check_kernel_version 44; then
2992 touch .foo || error "'touch .foo' failed after recreating cwd"
2993 mkdir .bar || error "'mkdir .foo' failed after recreating cwd"
2995 ls . > /dev/null || error "'ls .' failed after recreating cwd"
2996 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
2997 cd . || error "'cd .' failed after recreating cwd"
2998 mkdir . && error "'mkdir .' worked after recreating cwd"
2999 rmdir . && error "'rmdir .' worked after recreating cwd"
3000 ln -s . baz || error "'ln -s .' failed after recreating cwd"
3001 cd .. || error "'cd ..' failed after recreating cwd"
3003 run_test 48a "Access renamed working dir (should return errors)="
3005 test_48b() { # bug 2399
3006 check_kernel_version 34 || return 0
3009 rmdir $DIR/d48b || error "remove cwd $DIR/d48b failed"
3010 touch foo && error "'touch foo' worked after removing cwd"
3011 mkdir foo && error "'mkdir foo' worked after removing cwd"
3012 if check_kernel_version 44; then
3013 touch .foo && error "'touch .foo' worked after removing cwd"
3014 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
3016 ls . > /dev/null && error "'ls .' worked after removing cwd"
3017 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3018 is_patchless || ( cd . && error "'cd .' worked after removing cwd" )
3019 mkdir . && error "'mkdir .' worked after removing cwd"
3020 rmdir . && error "'rmdir .' worked after removing cwd"
3021 ln -s . foo && error "'ln -s .' worked after removing cwd"
3022 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
3024 run_test 48b "Access removed working dir (should return errors)="
3026 test_48c() { # bug 2350
3027 check_kernel_version 36 || return 0
3028 #lctl set_param debug=-1
3030 mkdir -p $DIR/d48c/dir
3032 $TRACE rmdir $DIR/d48c/dir || error "remove cwd $DIR/d48c/dir failed"
3033 $TRACE touch foo && error "'touch foo' worked after removing cwd"
3034 $TRACE mkdir foo && error "'mkdir foo' worked after removing cwd"
3035 if check_kernel_version 44; then
3036 touch .foo && error "'touch .foo' worked after removing cwd"
3037 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
3039 $TRACE ls . && error "'ls .' worked after removing cwd"
3040 $TRACE ls .. || error "'ls ..' failed after removing cwd"
3041 is_patchless || ( $TRACE cd . && error "'cd .' worked after removing cwd" )
3042 $TRACE mkdir . && error "'mkdir .' worked after removing cwd"
3043 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
3044 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
3045 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
3047 run_test 48c "Access removed working subdir (should return errors)"
3049 test_48d() { # bug 2350
3050 check_kernel_version 36 || return 0
3051 #lctl set_param debug=-1
3053 mkdir -p $DIR/d48d/dir
3055 $TRACE rmdir $DIR/d48d/dir || error "remove cwd $DIR/d48d/dir failed"
3056 $TRACE rmdir $DIR/d48d || error "remove parent $DIR/d48d failed"
3057 $TRACE touch foo && error "'touch foo' worked after removing parent"
3058 $TRACE mkdir foo && error "'mkdir foo' worked after removing parent"
3059 if check_kernel_version 44; then
3060 touch .foo && error "'touch .foo' worked after removing parent"
3061 mkdir .foo && error "'mkdir .foo' worked after removing parent"
3063 $TRACE ls . && error "'ls .' worked after removing parent"
3064 $TRACE ls .. && error "'ls ..' worked after removing parent"
3065 is_patchless || ( $TRACE cd . && error "'cd .' worked after recreate parent" )
3066 $TRACE mkdir . && error "'mkdir .' worked after removing parent"
3067 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
3068 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
3069 is_patchless || ( $TRACE cd .. && error "'cd ..' worked after removing parent" || true )
3071 run_test 48d "Access removed parent subdir (should return errors)"
3073 test_48e() { # bug 4134
3074 check_kernel_version 41 || return 0
3075 #lctl set_param debug=-1
3077 mkdir -p $DIR/d48e/dir
3079 $TRACE rmdir $DIR/d48e/dir || error "remove cwd $DIR/d48e/dir failed"
3080 $TRACE rmdir $DIR/d48e || error "remove parent $DIR/d48e failed"
3081 $TRACE touch $DIR/d48e || error "'touch $DIR/d48e' failed"
3082 $TRACE chmod +x $DIR/d48e || error "'chmod +x $DIR/d48e' failed"
3083 # On a buggy kernel addition of "touch foo" after cd .. will
3084 # produce kernel oops in lookup_hash_it
3085 touch ../foo && error "'cd ..' worked after recreate parent"
3087 $TRACE rm $DIR/d48e || error "rm '$DIR/d48e' failed"
3089 run_test 48e "Access to recreated parent subdir (should return errors)"
3091 test_49() { # LU-1030
3092 # get ost1 size - lustre-OST0000
3093 ost1_size=$(do_facet ost1 lfs df |grep ${ost1_svc} |awk '{print $4}')
3094 # write 800M at maximum
3095 [ $ost1_size -gt 819200 ] && ost1_size=819200
3097 lfs setstripe -c 1 -i 0 $DIR/$tfile
3098 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
3101 # change max_pages_per_rpc while writing the file
3102 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
3103 local orig_mppc=`$LCTL get_param -n $osc1_mppc`
3104 # loop until dd process exits
3105 while ps ax -opid | grep -wq $dd_pid; do
3106 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
3107 sleep $((RANDOM % 5 + 1))
3109 # restore original max_pages_per_rpc
3110 $LCTL set_param $osc1_mppc=$orig_mppc
3111 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
3113 run_test 49 "Change max_pages_per_rpc won't break osc extent"
3119 ls /proc/$$/cwd || error
3121 run_test 50 "special situations: /proc symlinks ==============="
3123 test_51a() { # was test_51
3124 # bug 1516 - create an empty entry right after ".." then split dir
3127 $MCREATE $DIR/d51/bar
3129 createmany -m $DIR/d51/longfile 201
3131 while [ `ls -sd $DIR/d51 | awk '{ print $1 }'` -eq 4 ]; do
3132 $MCREATE $DIR/d51/longfile$FNUM
3137 ls -l $DIR/d51 > /dev/null || error
3139 run_test 51a "special situations: split htree with empty entry =="
3141 export NUMTEST=70000
3143 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
3144 [ $NUMFREE -lt 21000 ] && \
3145 skip "not enough free inodes ($NUMFREE)" && \
3148 [ $NUMFREE -lt $NUMTEST ] && NUMTEST=$(($NUMFREE - 50))
3151 createmany -d $DIR/d51b/t- $NUMTEST
3153 run_test 51b "mkdir .../t-0 --- .../t-$NUMTEST ===================="
3155 test_51ba() { # LU-993
3156 local BASE=$DIR/d51b
3157 # unlink all but 100 subdirectories, then check it still works
3159 local DELETE=$((NUMTEST - LEFT))
3161 # continue on to run this test even if 51b didn't finish,
3162 # just to delete the many subdirectories created.
3163 ! [ -d "${BASE}/t-1" ] && skip "test_51b() not run" && return 0
3165 # for ldiskfs the nlink count should be 1, but this is OSD specific
3166 # and so this is listed for informational purposes only
3167 log "nlink before: $(stat -c %h $BASE)"
3168 unlinkmany -d $BASE/t- $DELETE ||
3169 error "unlink of first $DELETE subdirs failed"
3171 log "nlink between: $(stat -c %h $BASE)"
3172 local FOUND=$(ls -l ${BASE} | wc -l)
3173 FOUND=$((FOUND - 1)) # trim the first line of ls output
3174 [ $FOUND -ne $LEFT ] &&
3175 error "can't find subdirs: found only $FOUND/$LEFT"
3177 unlinkmany -d $BASE/t- $DELETE $LEFT ||
3178 error "unlink of second $LEFT subdirs failed"
3179 log "nlink after: $(stat -c %h $BASE)"
3181 run_test 51ba "rmdir .../t-0 --- .../t-$NUMTEST"
3184 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3186 local ndirs=${TEST51BB_NDIRS:-10}
3187 local nfiles=${TEST51BB_NFILES:-100}
3189 local numfree=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
3191 [ $numfree -lt $(( ndirs * nfiles)) ] && \
3192 nfiles=$(( numfree / ndirs - 10 ))
3194 local dir=$DIR/d51bb
3196 local savePOLICY=$(lctl get_param -n lmv.*.placement)
3197 lctl set_param -n lmv.*.placement=CHAR
3200 local IUSED=$(lfs df -i $dir | grep MDT | awk '{print $3}')
3204 for ((i=0; i < $ndirs; i++)); do
3205 dirs[i]=$dir/$RANDOM
3206 echo Creating directory ${dirs[i]}
3209 echo Creating $nfiles in dir ${dirs[i]} ...
3210 echo "createmany -o ${dirs[i]}/$tfile- $nfiles"
3211 createmany -o ${dirs[i]}/$tfile- $nfiles
3217 IUSED=$(lfs df -i $dir | grep MDT | awk '{print $3}')
3221 for ((i=0; i<${#NEWUSED[@]}; i++)); do
3222 echo "mds $i: inodes count OLD ${OLDUSED[$i]} NEW ${NEWUSED[$i]}"
3223 [ ${OLDUSED[$i]} -lt ${NEWUSED[$i]} ] || rc=$((rc + 1))
3226 lctl set_param -n lmv.*.placement=$savePOLICY
3228 [ $rc -ne $MDSCOUNT ] || \
3229 error "Objects/inodes are not distributed over all mds servers"
3231 run_test 51bb "mkdir createmany CMD $MDSCOUNT ===================="
3234 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping test with few OSTs" && return
3236 createmany -o $DIR/d51d/t- 1000
3237 $GETSTRIPE $DIR/d51d > $TMP/files
3238 for N in `seq 0 $((OSTCOUNT - 1))`; do
3239 OBJS[$N]=`awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}' $TMP/files`
3240 OBJS0[$N]=`grep -A 1 idx $TMP/files | awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}'`
3241 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
3243 unlinkmany $DIR/d51d/t- 1000
3246 for N in `seq 1 $((OSTCOUNT - 1))`; do
3247 [ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ] && \
3248 error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
3249 [ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ] && \
3250 error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
3252 [ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ] && \
3253 error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
3254 [ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ] && \
3255 error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
3259 run_test 51d "check object distribution ===================="
3262 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
3265 chattr +a $DIR/d52a/foo || error "chattr +a failed"
3266 echo bar >> $DIR/d52a/foo || error "append bar failed"
3267 cp /etc/hosts $DIR/d52a/foo && error "cp worked"
3268 rm -f $DIR/d52a/foo 2>/dev/null && error "rm worked"
3269 link $DIR/d52a/foo $DIR/d52a/foo_link 2>/dev/null && error "link worked"
3270 echo foo >> $DIR/d52a/foo || error "append foo failed"
3271 mrename $DIR/d52a/foo $DIR/d52a/foo_ren && error "rename worked"
3272 lsattr $DIR/d52a/foo | egrep -q "^-+a[-e]+ $DIR/d52a/foo" || error "lsattr"
3273 chattr -a $DIR/d52a/foo || error "chattr -a failed"
3274 cp -r $DIR/d52a /tmp/
3275 rm -fr $DIR/d52a || error "cleanup rm failed"
3277 run_test 52a "append-only flag test (should return errors) ====="
3280 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
3283 chattr +i $DIR/d52b/foo || error "chattr +i failed"
3284 cat test > $DIR/d52b/foo && error "cat test worked"
3285 cp /etc/hosts $DIR/d52b/foo && error "cp worked"
3286 rm -f $DIR/d52b/foo 2>/dev/null && error "rm worked"
3287 link $DIR/d52b/foo $DIR/d52b/foo_link 2>/dev/null && error "link worked"
3288 echo foo >> $DIR/d52b/foo && error "echo worked"
3289 mrename $DIR/d52b/foo $DIR/d52b/foo_ren && error "rename worked"
3290 [ -f $DIR/d52b/foo ] || error
3291 [ -f $DIR/d52b/foo_ren ] && error
3292 lsattr $DIR/d52b/foo | egrep -q "^-+i[-e]+ $DIR/d52b/foo" || error "lsattr"
3293 chattr -i $DIR/d52b/foo || error "chattr failed"
3295 rm -fr $DIR/d52b || error
3297 run_test 52b "immutable flag test (should return errors) ======="
3300 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3301 remote_ost_nodsh && skip "remote OST with nodsh" && return
3310 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
3311 for value in $(do_facet $SINGLEMDS lctl get_param osc.$mdtosc.prealloc_last_id) ; do
3312 param=`echo ${value[0]} | cut -d "=" -f1`
3313 ostname=`echo $param | cut -d "." -f2 | cut -d - -f 1-2`
3314 mds_last=$(do_facet $SINGLEMDS lctl get_param -n $param)
3315 ostnum=$(echo $ostname | sed "s/${FSNAME}-OST//g" | awk '{print ($1+1)}' )
3316 ost_last=$(do_facet ost$ostnum lctl get_param -n obdfilter.$ostname.last_id | head -n 1)
3317 echo "$ostname.last_id=$ost_last ; MDS.last_id=$mds_last"
3318 if [ $ost_last != $mds_last ]; then
3319 error "$ostname.last_id=$ost_last ; MDS.last_id=$mds_last"
3323 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
3326 [ ! -f "$SOCKETSERVER" ] && skip_env "no socketserver, skipping" && return
3327 [ ! -f "$SOCKETCLIENT" ] && skip_env "no socketclient, skipping" && return
3328 $SOCKETSERVER $DIR/socket
3329 $SOCKETCLIENT $DIR/socket || error
3330 $MUNLINK $DIR/socket
3332 run_test 54a "unix domain socket test =========================="
3338 dd if=/dev/zero of=$f bs=`page_size` count=1
3340 run_test 54b "char device works in lustre ======================"
3343 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
3344 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
3345 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
3347 for i in `seq 3 7`; do
3348 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
3358 loopdev="$DIR/loop54c"
3361 [ -z "$LOOPNUM" ] && echo "couldn't find empty loop device" && return
3362 mknod $loopdev b 7 $LOOPNUM
3363 echo "make a loop file system with $tfile on $loopdev ($LOOPNUM)..."
3364 dd if=/dev/zero of=$tfile bs=`page_size` seek=1024 count=1 > /dev/null
3365 losetup $loopdev $tfile || error "can't set up $loopdev for $tfile"
3366 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
3368 mount -t ext2 $loopdev $tdir || error "error mounting $loopdev on $tdir"
3369 dd if=/dev/zero of=$tdir/tmp bs=`page_size` count=30 || error "dd write"
3371 dd if=$tdir/tmp of=/dev/zero bs=`page_size` count=30 || error "dd read"
3376 run_test 54c "block device works in lustre ====================="
3382 [ "$string" = `echo $string > $f | cat $f` ] || error
3384 run_test 54d "fifo device works in lustre ======================"
3387 check_kernel_version 46 || return 0
3390 cp -aL /dev/console $f
3391 echo $string > $f || error
3393 run_test 54e "console/tty device works in lustre ======================"
3395 #The test_55 used to be iopen test and it was removed by bz#24037.
3396 #run_test 55 "check iopen_connect_dentry() ======================"
3398 test_56a() { # was test_56
3404 NUMFILESx2=$(($NUMFILES * 2))
3405 for i in `seq 1 $NUMFILES` ; do
3406 touch $DIR/d56/file$i
3407 touch $DIR/d56/dir/file$i
3410 # test lfs getstripe with --recursive
3411 FILENUM=`$GETSTRIPE --recursive $DIR/d56 | grep -c obdidx`
3412 [ $FILENUM -eq $NUMFILESx2 ] ||
3413 error "$GETSTRIPE --recursive: found $FILENUM, not $NUMFILESx2"
3414 FILENUM=`$GETSTRIPE $DIR/d56 | grep -c obdidx`
3415 [ $FILENUM -eq $NUMFILES ] ||
3416 error "$GETSTRIPE $DIR/d56: found $FILENUM, not $NUMFILES"
3417 echo "$GETSTRIPE --recursive passed."
3419 # test lfs getstripe with file instead of dir
3420 FILENUM=`$GETSTRIPE $DIR/d56/file1 | grep -c obdidx`
3421 [ $FILENUM -eq 1 ] || error \
3422 "$GETSTRIPE $DIR/d56/file1: found $FILENUM, not 1"
3423 echo "$GETSTRIPE file1 passed."
3425 #test lfs getstripe with --verbose
3426 [ `$GETSTRIPE --verbose $DIR/d56 | grep -c lmm_magic` -eq $NUMFILES ] ||
3427 error "$GETSTRIPE --verbose $DIR/d56: want $NUMFILES lmm_magic"
3428 [ `$GETSTRIPE $DIR/d56 | grep -c lmm_magic` -eq 0 ] ||
3429 error "$GETSTRIPE $DIR/d56: showed lmm_magic"
3430 echo "$GETSTRIPE --verbose passed."
3432 #test lfs getstripe with --obd
3433 $GETSTRIPE --obd wrong_uuid $DIR/d56 2>&1 | grep -q "unknown obduuid" ||
3434 error "$GETSTRIPE --obd wrong_uuid should return error message"
3436 [ "$OSTCOUNT" -lt 2 ] &&
3437 skip_env "skipping other $GETSTRIPE --obd test" && return
3440 OBDUUID=$(ostuuid_from_index $OSTIDX)
3441 FILENUM=`$GETSTRIPE -ir $DIR/d56 | grep -x $OSTIDX | wc -l`
3442 FOUND=`$GETSTRIPE -r --obd $OBDUUID $DIR/d56 | grep obdidx | wc -l`
3443 [ $FOUND -eq $FILENUM ] ||
3444 error "$GETSTRIPE --obd wrong: found $FOUND, expected $FILENUM"
3445 [ `$GETSTRIPE -r -v --obd $OBDUUID $DIR/d56 |
3446 sed '/^[ ]*'${OSTIDX}'[ ]/d' |
3447 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l` -eq 0 ] ||
3448 error "$GETSTRIPE --obd: should not show file on other obd"
3449 echo "$GETSTRIPE --obd passed"
3451 run_test 56a "check $GETSTRIPE"
3456 local LOCAL_NUMFILES="$1"
3457 local LOCAL_NUMDIRS="$2"
3458 local MKDIR_PARAMS="$3"
3460 if [ ! -d "$TDIR" ] ; then
3462 [ "$MKDIR_PARAMS" ] && $SETSTRIPE $MKDIR_PARAMS $TDIR
3463 for i in `seq 1 $LOCAL_NUMFILES` ; do
3466 for i in `seq 1 $LOCAL_NUMDIRS` ; do
3468 for j in `seq 1 $LOCAL_NUMFILES` ; do
3469 touch $TDIR/dir$i/file$j
3475 setup_56_special() {
3479 if [ ! -e "$TDIR/loop1b" ] ; then
3480 for i in `seq 1 $LOCAL_NUMFILES` ; do
3481 mknod $TDIR/loop${i}b b 7 $i
3482 mknod $TDIR/null${i}c c 1 3
3483 ln -s $TDIR/file1 $TDIR/link${i}l
3485 for i in `seq 1 $LOCAL_NUMDIRS` ; do
3486 mknod $TDIR/dir$i/loop${i}b b 7 $i
3487 mknod $TDIR/dir$i/null${i}c c 1 3
3488 ln -s $TDIR/dir$i/file1 $TDIR/dir$i/link${i}l
3497 setup_56 $NUMFILES $NUMDIRS
3499 EXPECTED=$(($NUMDIRS + 2))
3500 # test lfs find with -name
3501 for i in $(seq 1 $NUMFILES) ; do
3502 NUMS=$($LFIND -name "*$i" $TDIR | wc -l)
3503 [ $NUMS -eq $EXPECTED ] ||
3504 error "lfs find -name \"*$i\" $TDIR wrong: "\
3505 "found $NUMS, expected $EXPECTED"
3508 run_test 56g "check lfs find -name ============================="
3514 setup_56 $NUMFILES $NUMDIRS
3516 EXPECTED=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
3517 # test lfs find with ! -name
3518 for i in $(seq 1 $NUMFILES) ; do
3519 NUMS=$($LFIND ! -name "*$i" $TDIR | wc -l)
3520 [ $NUMS -eq $EXPECTED ] ||
3521 error "lfs find ! -name \"*$i\" $TDIR wrong: "\
3522 "found $NUMS, expected $EXPECTED"
3525 run_test 56h "check lfs find ! -name ============================="
3530 UUID=$(ostuuid_from_index 0 $DIR/$tdir)
3531 CMD="$LFIND -ost $UUID $DIR/$tdir"
3533 [ -z "$OUT" ] || error "\"$CMD\" returned directory '$OUT'"
3535 run_test 56i "check 'lfs find -ost UUID' skips directories ======="
3539 setup_56_special $NUMFILES $NUMDIRS
3541 EXPECTED=$((NUMDIRS + 1))
3542 CMD="$LFIND -type d $TDIR"
3543 NUMS=$($CMD | wc -l)
3544 [ $NUMS -eq $EXPECTED ] ||
3545 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3547 run_test 56j "check lfs find -type d ============================="
3551 setup_56_special $NUMFILES $NUMDIRS
3553 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
3554 CMD="$LFIND -type f $TDIR"
3555 NUMS=$($CMD | wc -l)
3556 [ $NUMS -eq $EXPECTED ] ||
3557 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3559 run_test 56k "check lfs find -type f ============================="
3563 setup_56_special $NUMFILES $NUMDIRS
3565 EXPECTED=$((NUMDIRS + NUMFILES))
3566 CMD="$LFIND -type b $TDIR"
3567 NUMS=$($CMD | wc -l)
3568 [ $NUMS -eq $EXPECTED ] ||
3569 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3571 run_test 56l "check lfs find -type b ============================="
3575 setup_56_special $NUMFILES $NUMDIRS
3577 EXPECTED=$((NUMDIRS + NUMFILES))
3578 CMD="$LFIND -type c $TDIR"
3579 NUMS=$($CMD | wc -l)
3580 [ $NUMS -eq $EXPECTED ] ||
3581 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3583 run_test 56m "check lfs find -type c ============================="
3587 setup_56_special $NUMFILES $NUMDIRS
3589 EXPECTED=$((NUMDIRS + NUMFILES))
3590 CMD="$LFIND -type l $TDIR"
3591 NUMS=$($CMD | wc -l)
3592 [ $NUMS -eq $EXPECTED ] ||
3593 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3595 run_test 56n "check lfs find -type l ============================="
3599 setup_56 $NUMFILES $NUMDIRS
3601 utime $TDIR/file1 > /dev/null || error "utime (1)"
3602 utime $TDIR/file2 > /dev/null || error "utime (2)"
3603 utime $TDIR/dir1 > /dev/null || error "utime (3)"
3604 utime $TDIR/dir2 > /dev/null || error "utime (4)"
3605 utime $TDIR/dir1/file1 > /dev/null || error "utime (5)"
3606 dd if=/dev/zero count=1 >> $TDIR/dir1/file1 && sync
3609 NUMS=`$LFIND -mtime +0 $TDIR | wc -l`
3610 [ $NUMS -eq $EXPECTED ] || \
3611 error "lfs find -mtime +0 $TDIR wrong: found $NUMS, expected $EXPECTED"
3614 CMD="$LFIND -mtime 0 $TDIR"
3615 NUMS=$($CMD | wc -l)
3616 [ $NUMS -eq $EXPECTED ] ||
3617 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3619 run_test 56o "check lfs find -mtime for old files =========================="
3622 [ $RUNAS_ID -eq $UID ] &&
3623 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
3626 setup_56 $NUMFILES $NUMDIRS
3628 chown $RUNAS_ID $TDIR/file* || error "chown $DIR/${tdir}g/file$i failed"
3630 CMD="$LFIND -uid $RUNAS_ID $TDIR"
3631 NUMS=$($CMD | wc -l)
3632 [ $NUMS -eq $EXPECTED ] || \
3633 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3635 EXPECTED=$(((NUMFILES + 1) * NUMDIRS + 1))
3636 CMD="$LFIND ! -uid $RUNAS_ID $TDIR"
3637 NUMS=$($CMD | wc -l)
3638 [ $NUMS -eq $EXPECTED ] || \
3639 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3641 run_test 56p "check lfs find -uid and ! -uid ==============================="
3644 [ $RUNAS_ID -eq $UID ] &&
3645 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
3648 setup_56 $NUMFILES $NUMDIRS
3650 chgrp $RUNAS_GID $TDIR/file* || error "chown $TDIR/file$i failed"
3653 CMD="$LFIND -gid $RUNAS_GID $TDIR"
3654 NUMS=$($CMD | wc -l)
3655 [ $NUMS -eq $EXPECTED ] ||
3656 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3658 EXPECTED=$(( ($NUMFILES+1) * $NUMDIRS + 1))
3659 CMD="$LFIND ! -gid $RUNAS_GID $TDIR"
3660 NUMS=$($CMD | wc -l)
3661 [ $NUMS -eq $EXPECTED ] ||
3662 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3664 run_test 56q "check lfs find -gid and ! -gid ==============================="
3668 setup_56 $NUMFILES $NUMDIRS
3671 CMD="$LFIND -size 0 -type f $TDIR"
3672 NUMS=$($CMD | wc -l)
3673 [ $NUMS -eq $EXPECTED ] ||
3674 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3676 CMD="$LFIND ! -size 0 -type f $TDIR"
3677 NUMS=$($CMD | wc -l)
3678 [ $NUMS -eq $EXPECTED ] ||
3679 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3680 echo "test" > $TDIR/$tfile
3681 echo "test2" > $TDIR/$tfile.2 && sync
3683 CMD="$LFIND -size 5 -type f $TDIR"
3684 NUMS=$($CMD | wc -l)
3685 [ $NUMS -eq $EXPECTED ] ||
3686 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3688 CMD="$LFIND -size +5 -type f $TDIR"
3689 NUMS=$($CMD | wc -l)
3690 [ $NUMS -eq $EXPECTED ] ||
3691 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3693 CMD="$LFIND -size +0 -type f $TDIR"
3694 NUMS=$($CMD | wc -l)
3695 [ $NUMS -eq $EXPECTED ] ||
3696 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3698 CMD="$LFIND ! -size -5 -type f $TDIR"
3699 NUMS=$($CMD | wc -l)
3700 [ $NUMS -eq $EXPECTED ] ||
3701 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3703 CMD="$LFIND -size -5 -type f $TDIR"
3704 NUMS=$($CMD | wc -l)
3705 [ $NUMS -eq $EXPECTED ] ||
3706 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3708 run_test 56r "check lfs find -size works =========================="
3710 test_56s() { # LU-611
3712 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT"
3714 if [ $OSTCOUNT -gt 1 ]; then
3715 $SETSTRIPE -c 1 $TDIR/$tfile.{0,1,2,3}
3719 ONESTRIPE=$(((NUMDIRS + 1) * NUMFILES))
3723 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
3724 CMD="$LFIND -stripe-count $OSTCOUNT -type f $TDIR"
3725 NUMS=$($CMD | wc -l)
3726 [ $NUMS -eq $EXPECTED ] ||
3727 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3729 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + EXTRA))
3730 CMD="$LFIND -stripe-count +0 -type f $TDIR"
3731 NUMS=$($CMD | wc -l)
3732 [ $NUMS -eq $EXPECTED ] ||
3733 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3736 CMD="$LFIND -stripe-count 1 -type f $TDIR"
3737 NUMS=$($CMD | wc -l)
3738 [ $NUMS -eq $EXPECTED ] ||
3739 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3741 CMD="$LFIND -stripe-count -2 -type f $TDIR"
3742 NUMS=$($CMD | wc -l)
3743 [ $NUMS -eq $EXPECTED ] ||
3744 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3747 CMD="$LFIND -stripe-count $((OSTCOUNT + 1)) -type f $TDIR"
3748 NUMS=$($CMD | wc -l)
3749 [ $NUMS -eq $EXPECTED ] ||
3750 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3752 run_test 56s "check lfs find -stripe-count works"
3754 test_56t() { # LU-611
3756 setup_56 $NUMFILES $NUMDIRS "-s 512k"
3758 $SETSTRIPE -S 256k $TDIR/$tfile.{0,1,2,3}
3760 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
3761 CMD="$LFIND -stripe-size 512k -type f $TDIR"
3762 NUMS=$($CMD | wc -l)
3763 [ $NUMS -eq $EXPECTED ] ||
3764 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3766 CMD="$LFIND -stripe-size +320k -type f $TDIR"
3767 NUMS=$($CMD | wc -l)
3768 [ $NUMS -eq $EXPECTED ] ||
3769 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3771 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + 4))
3772 CMD="$LFIND -stripe-size +200k -type f $TDIR"
3773 NUMS=$($CMD | wc -l)
3774 [ $NUMS -eq $EXPECTED ] ||
3775 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3777 CMD="$LFIND -stripe-size -640k -type f $TDIR"
3778 NUMS=$($CMD | wc -l)
3779 [ $NUMS -eq $EXPECTED ] ||
3780 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3783 CMD="$LFIND -stripe-size 256k -type f $TDIR"
3784 NUMS=$($CMD | wc -l)
3785 [ $NUMS -eq $EXPECTED ] ||
3786 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3788 CMD="$LFIND -stripe-size -320k -type f $TDIR"
3789 NUMS=$($CMD | wc -l)
3790 [ $NUMS -eq $EXPECTED ] ||
3791 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3794 CMD="$LFIND -stripe-size 1024k -type f $TDIR"
3795 NUMS=$($CMD | wc -l)
3796 [ $NUMS -eq $EXPECTED ] ||
3797 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3799 run_test 56t "check lfs find -stripe-size works"
3801 test_56u() { # LU-611
3803 setup_56 $NUMFILES $NUMDIRS "-i 0"
3805 if [ $OSTCOUNT -gt 1 ]; then
3806 $SETSTRIPE -i 1 $TDIR/$tfile.{0,1,2,3}
3812 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
3813 CMD="$LFIND -stripe-index 0 -type f $TDIR"
3814 NUMS=$($CMD | wc -l)
3815 [ $NUMS -eq $EXPECTED ] ||
3816 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3819 CMD="$LFIND -stripe-index 1 -type f $TDIR"
3820 NUMS=$($CMD | wc -l)
3821 [ $NUMS -eq $EXPECTED ] ||
3822 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3824 CMD="$LFIND ! -stripe-index 0 -type f $TDIR"
3825 NUMS=$($CMD | wc -l)
3826 [ $NUMS -eq $EXPECTED ] ||
3827 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3830 # This should produce an error and not return any files
3831 CMD="$LFIND -stripe-index $OSTCOUNT -type f $TDIR"
3832 NUMS=$($CMD 2>/dev/null | wc -l)
3833 [ $NUMS -eq $EXPECTED ] ||
3834 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3836 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + ONESTRIPE))
3837 CMD="$LFIND -stripe-index 0,1 -type f $TDIR"
3838 NUMS=$($CMD | wc -l)
3839 [ $NUMS -eq $EXPECTED ] ||
3840 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3842 run_test 56u "check lfs find -stripe-index works"
3849 setup_56 $NUMFILES $NUMDIRS
3851 UUID=$(mdtuuid_from_index $MDT_IDX $TDIR)
3852 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT index $MDT_IDX"
3854 for file in $($LFIND -mdt $UUID $TDIR); do
3855 file_mdt_idx=$($GETSTRIPE -M $file)
3856 [ $file_mdt_idx -eq $MDT_IDX ] ||
3857 error "'lfind -mdt $UUID' != 'getstripe -M' ($file_mdt_idx)"
3860 run_test 56v "check 'lfs find -mdt match with lfs getstripe -M' ======="
3862 # Get and check the actual stripe count of one file.
3863 # Usage: check_stripe_count <file> <expected_stripe_count>
3864 check_stripe_count() {
3869 [[ -z "$file" || -z "$expected" ]] &&
3870 error "check_stripe_count: invalid argument!"
3872 local cmd="$GETSTRIPE -c $file"
3873 actual=$($cmd) || error "$cmd failed"
3874 actual=${actual%% *}
3876 if [[ $actual -ne $expected ]]; then
3877 [[ $expected -eq -1 ]] ||
3878 error "$cmd wrong: found $actual, expected $expected"
3879 [[ $actual -eq $OSTCOUNT ]] ||
3880 error "$cmd wrong: found $actual, expected $OSTCOUNT"
3887 rm -rf $TDIR || error "remove $TDIR failed"
3888 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT"
3891 stripe_size=$($GETSTRIPE -S -d $TDIR) ||
3892 error "$GETSTRIPE -S -d $TDIR failed"
3893 stripe_size=${stripe_size%% *}
3895 local file_size=$((stripe_size * OSTCOUNT))
3896 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
3897 local required_space=$((file_num * file_size))
3898 local free_space=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
3899 [[ $free_space -le $((required_space / 1024)) ]] &&
3900 skip_env "need at least $required_space bytes free space," \
3901 "have $free_space kbytes" && return
3904 local dd_count=$((file_size / dd_bs))
3906 # write data into the files
3910 for i in $(seq 1 $NUMFILES); do
3912 yes | dd bs=$dd_bs count=$dd_count of=$file >/dev/null 2>&1 ||
3913 error "write data into $file failed"
3915 for i in $(seq 1 $NUMDIRS); do
3916 for j in $(seq 1 $NUMFILES); do
3917 file=$TDIR/dir$i/file$j
3918 yes | dd bs=$dd_bs count=$dd_count of=$file \
3920 error "write data into $file failed"
3925 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
3928 local cmd="$LFS_MIGRATE -y -c $expected $TDIR/file1"
3930 eval $cmd || error "$cmd failed"
3932 check_stripe_count $TDIR/file1 $expected
3935 cmd="$LFS_MIGRATE -y -c $expected $TDIR/dir1"
3937 eval $cmd || error "$cmd failed"
3939 for j in $(seq 1 $NUMFILES); do
3940 check_stripe_count $TDIR/dir1/file$j $expected
3943 # lfs_migrate works with lfs find
3944 cmd="$LFIND -stripe_count $OSTCOUNT -type f $TDIR |
3945 $LFS_MIGRATE -y -c $expected"
3947 eval $cmd || error "$cmd failed"
3949 for i in $(seq 2 $NUMFILES); do
3950 check_stripe_count $TDIR/file$i $expected
3952 for i in $(seq 2 $NUMDIRS); do
3953 for j in $(seq 1 $NUMFILES); do
3954 check_stripe_count $TDIR/dir$i/file$j $expected
3958 run_test 56w "check lfs_migrate -c stripe_count works"
3961 # note test will not do anything if MDS is not local
3962 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3963 local MNTDEV="osd*.*MDT*.mntdev"
3964 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
3965 [ -z "$DEV" ] && error "can't access $MNTDEV"
3966 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
3967 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
3968 error "can't access $DEV"
3969 DEVISIZE=`awk '/Inode size:/ { print $3 }' $TMP/t57a.dump`
3970 [ "$DEVISIZE" -gt 128 ] || error "inode size $DEVISIZE"
3974 run_test 57a "verify MDS filesystem created with large inodes =="
3977 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3982 local FILEN=$dir/f$FILECOUNT
3984 rm -rf $dir || error "removing $dir"
3985 mkdir -p $dir || error "creating $dir"
3986 local num=$(get_mds_dir $dir)
3989 echo "mcreating $FILECOUNT files"
3990 createmany -m $dir/f 1 $FILECOUNT || \
3991 error "creating files in $dir"
3993 # verify that files do not have EAs yet
3994 $GETSTRIPE $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
3995 $GETSTRIPE $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
3999 df $dir #make sure we get new statfs data
4000 local MDSFREE=$(do_facet $mymds \
4001 lctl get_param -n osd*.*MDT000$((num -1)).kbytesfree)
4002 local MDCFREE=$(lctl get_param -n mdc.*MDT000$((num -1))-mdc-*.kbytesfree)
4003 echo "opening files to create objects/EAs"
4005 for FILE in `seq -f $dir/f%g 1 $FILECOUNT`; do
4006 $OPENFILE -f O_RDWR $FILE > /dev/null 2>&1 || error "opening $FILE"
4009 # verify that files have EAs now
4010 $GETSTRIPE $FILE1 | grep -q "obdidx" || error "$FILE1 missing EA"
4011 $GETSTRIPE $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
4013 sleep 1 #make sure we get new statfs data
4015 local MDSFREE2=$(do_facet $mymds \
4016 lctl get_param -n osd*.*MDT000$((num -1)).kbytesfree)
4017 local MDCFREE2=$(lctl get_param -n mdc.*MDT000$((num -1))-mdc-*.kbytesfree)
4018 if [ "$MDCFREE2" -lt "$((MDCFREE - 8))" ]; then
4019 if [ "$MDSFREE" != "$MDSFREE2" ]; then
4020 error "MDC before $MDCFREE != after $MDCFREE2"
4022 echo "MDC before $MDCFREE != after $MDCFREE2"
4023 echo "unable to confirm if MDS has large inodes"
4028 run_test 57b "default LOV EAs are stored inside large inodes ==="
4031 [ -z "$(which wiretest 2>/dev/null)" ] && skip_env "could not find wiretest" && return
4034 run_test 58 "verify cross-platform wire constants =============="
4037 echo "touch 130 files"
4038 createmany -o $DIR/f59- 130
4040 unlinkmany $DIR/f59- 130
4043 # wait for commitment of removal
4045 run_test 59 "verify cancellation of llog records async ========="
4047 TEST60_HEAD="test_60 run $RANDOM"
4049 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
4050 [ ! -f run-llog.sh ] && skip_env "missing subtest run-llog.sh" && return
4051 log "$TEST60_HEAD - from kernel mode"
4052 do_facet mgs sh run-llog.sh
4054 run_test 60a "llog sanity tests run from kernel module =========="
4056 test_60b() { # bug 6411
4058 LLOG_COUNT=`dmesg | awk "/$TEST60_HEAD/{marker = 1; from_marker = 0;}
4070 [ $LLOG_COUNT -gt 50 ] && error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)"|| true
4072 run_test 60b "limit repeated messages from CERROR/CWARN ========"
4075 echo "create 5000 files"
4076 createmany -o $DIR/f60c- 5000
4077 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
4078 lctl set_param fail_loc=0x80000137
4079 unlinkmany $DIR/f60c- 5000
4080 lctl set_param fail_loc=0
4082 run_test 60c "unlink file when mds full"
4085 SAVEPRINTK=$(lctl get_param -n printk)
4087 # verify "lctl mark" is even working"
4088 MESSAGE="test message ID $RANDOM $$"
4089 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
4090 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
4092 lctl set_param printk=0 || error "set lnet.printk failed"
4093 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
4094 MESSAGE="new test message ID $RANDOM $$"
4095 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
4096 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
4097 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
4099 lctl set_param -n printk="$SAVEPRINTK"
4101 run_test 60d "test printk console message masking"
4105 dd if=/dev/zero of=$f bs=`page_size` count=1
4106 cancel_lru_locks osc
4107 $MULTIOP $f OSMWUc || error
4110 run_test 61 "mmap() writes don't make sync hang ================"
4112 # bug 2330 - insufficient obd_match error checking causes LBUG
4116 cancel_lru_locks osc
4117 lctl set_param fail_loc=0x405
4118 cat $f && error "cat succeeded, expect -EIO"
4119 lctl set_param fail_loc=0
4121 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
4122 # match every page all of the time.
4123 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
4125 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
4126 test_63a() { # was test_63
4127 MAX_DIRTY_MB=`lctl get_param -n osc.*.max_dirty_mb | head -n 1`
4128 lctl set_param -n osc.*.max_dirty_mb 0
4129 for i in `seq 10` ; do
4130 dd if=/dev/zero of=$DIR/f63 bs=8k &
4136 lctl set_param -n osc.*.max_dirty_mb $MAX_DIRTY_MB
4137 rm -f $DIR/f63 || true
4139 run_test 63a "Verify oig_wait interruption does not crash ======="
4141 # bug 2248 - async write errors didn't return to application on sync
4142 # bug 3677 - async write errors left page locked
4145 lctl set_param debug=-1
4147 # ensure we have a grant to do async writes
4148 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
4151 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
4152 lctl set_param fail_loc=0x80000406
4153 $MULTIOP $DIR/$tfile Owy && \
4154 error "sync didn't return ENOMEM"
4155 sync; sleep 2; sync # do a real sync this time to flush page
4156 lctl get_param -n llite.*.dump_page_cache | grep locked && \
4157 error "locked page left in cache after async error" || true
4160 run_test 63b "async write errors should be returned to fsync ==="
4164 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
4166 run_test 64a "verify filter grant calculations (in kernel) ====="
4169 [ ! -f oos.sh ] && skip_env "missing subtest oos.sh" && return
4172 run_test 64b "check out-of-space detection on client ==========="
4174 # bug 1414 - set/get directories' stripe info
4178 $LVERIFY $DIR/d65 $DIR/d65/f1 || error "lverify failed"
4180 run_test 65a "directory with no stripe info ===================="
4184 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/d65||error "setstripe"
4186 $LVERIFY $DIR/d65 $DIR/d65/f2 || error "lverify failed"
4188 run_test 65b "directory setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1"
4191 if [ $OSTCOUNT -gt 1 ]; then
4193 $SETSTRIPE -S $(($STRIPESIZE * 4)) -i 1 \
4194 -c $(($OSTCOUNT - 1)) $DIR/d65 || error "setstripe"
4196 $LVERIFY $DIR/d65 $DIR/d65/f3 || error "lverify failed"
4199 run_test 65c "directory setstripe -S $((STRIPESIZE*4)) -i 1 -c $((OSTCOUNT-1))"
4203 if [ $STRIPECOUNT -le 0 ]; then
4205 elif [ $STRIPECOUNT -gt 2000 ]; then
4206 #LOV_MAX_STRIPE_COUNT is 2000
4207 [ $OSTCOUNT -gt 2000 ] && sc=2000 || sc=$(($OSTCOUNT - 1))
4209 sc=$(($STRIPECOUNT - 1))
4211 $SETSTRIPE -S $STRIPESIZE -c $sc $DIR/d65 || error "setstripe"
4212 touch $DIR/d65/f4 $DIR/d65/f5
4213 $LVERIFY $DIR/d65 $DIR/d65/f4 $DIR/d65/f5 || error "lverify failed"
4215 run_test 65d "directory setstripe -S $STRIPESIZE -c stripe_count"
4220 $SETSTRIPE $DIR/d65 || error "setstripe"
4221 $GETSTRIPE -v $DIR/d65 | grep "Default" || error "no stripe info failed"
4223 $LVERIFY $DIR/d65 $DIR/d65/f6 || error "lverify failed"
4225 run_test 65e "directory setstripe defaults ======================="
4229 $RUNAS $SETSTRIPE $DIR/d65f && error "setstripe succeeded" || true
4231 run_test 65f "dir setstripe permission (should return error) ==="
4235 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/d65 ||error "setstripe"
4236 $SETSTRIPE -d $DIR/d65 || error "setstripe"
4237 $GETSTRIPE -v $DIR/d65 | grep "Default" || \
4238 error "delete default stripe failed"
4240 run_test 65g "directory setstripe -d ==========================="
4244 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/d65 ||error "setstripe"
4245 mkdir -p $DIR/d65/dd1
4246 [ $($GETSTRIPE -c $DIR/d65) == $($GETSTRIPE -c $DIR/d65/dd1) ] ||
4247 error "stripe info inherit failed"
4249 run_test 65h "directory stripe info inherit ===================="
4251 test_65i() { # bug6367
4252 $SETSTRIPE -S 65536 -c -1 $MOUNT
4254 run_test 65i "set non-default striping on root directory (bug 6367)="
4256 test_65ia() { # bug12836
4257 $GETSTRIPE $MOUNT || error "getstripe $MOUNT failed"
4259 run_test 65ia "getstripe on -1 default directory striping"
4261 test_65ib() { # bug12836
4262 $GETSTRIPE -v $MOUNT || error "getstripe -v $MOUNT failed"
4264 run_test 65ib "getstripe -v on -1 default directory striping"
4266 test_65ic() { # bug12836
4267 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
4269 run_test 65ic "new find on -1 default directory striping"
4271 test_65j() { # bug6367
4273 # if we aren't already remounting for each test, do so for this test
4274 if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
4275 cleanup || error "failed to unmount"
4278 $SETSTRIPE -d $MOUNT || error "setstripe failed"
4280 run_test 65j "set default striping on root directory (bug 6367)="
4282 test_65k() { # bug11679
4283 [ "$OSTCOUNT" -lt 2 ] && skip_env "too few OSTs" && return
4284 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4286 echo "Check OST status: "
4287 local MDS_OSCS=`do_facet $SINGLEMDS lctl dl |
4288 awk '/[oO][sS][cC].*md[ts]/ { print $4 }'`
4290 for OSC in $MDS_OSCS; do
4291 echo $OSC "is activate"
4292 do_facet $SINGLEMDS lctl --device %$OSC activate
4295 do_facet client mkdir -p $DIR/$tdir
4296 for INACTIVE_OSC in $MDS_OSCS; do
4297 echo "Deactivate: " $INACTIVE_OSC
4298 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
4299 for STRIPE_OSC in $MDS_OSCS; do
4300 OST=`osc_to_ost $STRIPE_OSC`
4301 IDX=`do_facet $SINGLEMDS lctl get_param -n lov.*md*.target_obd |
4302 awk -F: /$OST/'{ print $1 }' | head -n 1`
4304 [ -f $DIR/$tdir/$IDX ] && continue
4305 echo "$SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX"
4306 do_facet client $SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX
4308 [ $RC -ne 0 ] && error "setstripe should have succeeded"
4310 do_facet client rm -f $DIR/$tdir/*
4311 echo $INACTIVE_OSC "is Activate."
4312 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
4315 run_test 65k "validate manual striping works properly with deactivated OSCs"
4317 test_65l() { # bug 12836
4318 mkdir -p $DIR/$tdir/test_dir
4319 $SETSTRIPE -c -1 $DIR/$tdir/test_dir
4320 $LFS find -mtime -1 $DIR/$tdir >/dev/null
4322 run_test 65l "lfs find on -1 stripe dir ========================"
4324 # bug 2543 - update blocks count on client
4327 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
4328 sync; sync_all_data; sync; sync_all_data
4329 cancel_lru_locks osc
4330 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
4331 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
4333 run_test 66 "update inode blocks count on client ==============="
4339 if [ ! -z "$LLOOP" ]; then
4340 if swapon -s | grep -q $LLOOP; then
4341 swapoff $LLOOP || error "swapoff failed"
4344 $LCTL blockdev_detach $LLOOP || error "detach failed"
4348 if [ ! -z "$LLITELOOPLOAD" ]; then
4356 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
4360 swapon -s | awk '($1 == "'$1'") { print $4 }'
4363 # test case for lloop driver, basic function
4365 [ "$UID" != 0 ] && skip_env "must run as root" && return
4366 llite_lloop_enabled || \
4367 { skip_env "llite_lloop module disabled" && return; }
4369 trap cleanup_68 EXIT
4371 if ! module_loaded llite_lloop; then
4372 if load_module llite/llite_lloop; then
4375 skip_env "can't find module llite_lloop"
4380 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
4381 dd if=/dev/zero of=$DIR/f68a bs=4k count=1024
4382 $LCTL blockdev_attach $DIR/f68a $LLOOP || error "attach failed"
4384 directio rdwr $LLOOP 0 1024 4096 || error "direct write failed"
4385 directio rdwr $LLOOP 0 1025 4096 && error "direct write should fail"
4389 run_test 68a "lloop driver - basic test ========================"
4391 # excercise swapping to lustre by adding a high priority swapfile entry
4392 # and then consuming memory until it is used.
4393 test_68b() { # was test_68
4394 [ "$UID" != 0 ] && skip_env "must run as root" && return
4395 lctl get_param -n devices | grep -q obdfilter && \
4396 skip "local OST" && return
4398 grep -q llite_lloop /proc/modules
4399 [ $? -ne 0 ] && skip "can't find module llite_lloop" && return
4401 [ -z "`$LCTL list_nids | grep -v tcp`" ] && \
4402 skip "can't reliably test swap with TCP" && return
4404 MEMTOTAL=`meminfo MemTotal`
4405 NR_BLOCKS=$((MEMTOTAL>>8))
4406 [[ $NR_BLOCKS -le 2048 ]] && NR_BLOCKS=2048
4408 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
4409 dd if=/dev/zero of=$DIR/f68b bs=64k seek=$NR_BLOCKS count=1
4412 $LCTL blockdev_attach $DIR/f68b $LLOOP || error "attach failed"
4414 trap cleanup_68 EXIT
4416 swapon -p 32767 $LLOOP || error "swapon $LLOOP failed"
4418 echo "before: `swapon -s | grep $LLOOP`"
4419 $MEMHOG $MEMTOTAL || error "error allocating $MEMTOTAL kB"
4420 echo "after: `swapon -s | grep $LLOOP`"
4421 SWAPUSED=`swap_used $LLOOP`
4425 [ $SWAPUSED -eq 0 ] && echo "no swap used???" || true
4427 run_test 68b "support swapping to Lustre ========================"
4429 # bug5265, obdfilter oa2dentry return -ENOENT
4430 # #define OBD_FAIL_OST_ENOENT 0x217
4432 remote_ost_nodsh && skip "remote OST with nodsh" && return
4435 $SETSTRIPE -c 1 -i 0 $f
4437 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
4439 do_facet ost1 lctl set_param fail_loc=0x217
4440 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
4441 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
4443 do_facet ost1 lctl set_param fail_loc=0
4444 $DIRECTIO write $f 0 2 || error "write error"
4446 cancel_lru_locks osc
4447 $DIRECTIO read $f 0 1 || error "read error"
4449 do_facet ost1 lctl set_param fail_loc=0x217
4450 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
4452 do_facet ost1 lctl set_param fail_loc=0
4455 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
4459 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
4461 run_test 71 "Running dbench on lustre (don't segment fault) ===="
4463 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
4464 check_kernel_version 43 || return 0
4465 [ "$RUNAS_ID" = "$UID" ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4467 # Check that testing environment is properly set up. Skip if not
4468 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS || {
4469 skip_env "User $RUNAS_ID does not exist - skipping"
4472 # We had better clear the $DIR to get enough space for dd
4477 $RUNAS dd if=/dev/zero of=$DIR/f72 bs=512 count=1 || error
4478 # See if we are still setuid/sgid
4479 test -u $DIR/f72 -o -g $DIR/f72 && error "S/gid is not dropped on write"
4480 # Now test that MDS is updated too
4481 cancel_lru_locks mdc
4482 test -u $DIR/f72 -o -g $DIR/f72 && error "S/gid is not dropped on MDS"
4486 run_test 72a "Test that remove suid works properly (bug5695) ===="
4488 test_72b() { # bug 24226 -- keep mode setting when size is not changing
4491 [ "$RUNAS_ID" = "$UID" ] && \
4492 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4493 [ "$RUNAS_ID" -eq 0 ] && \
4494 skip_env "RUNAS_ID = 0 -- skipping" && return
4496 # Check that testing environment is properly set up. Skip if not
4497 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS || {
4498 skip_env "User $RUNAS_ID does not exist - skipping"
4501 touch $DIR/${tfile}-f{g,u}
4502 mkdir $DIR/${tfile}-d{g,u}
4503 chmod 770 $DIR/${tfile}-{f,d}{g,u}
4504 chmod g+s $DIR/${tfile}-{f,d}g
4505 chmod u+s $DIR/${tfile}-{f,d}u
4506 for perm in 777 2777 4777; do
4507 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
4508 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
4509 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
4510 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
4514 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
4516 # bug 3462 - multiple simultaneous MDC requests
4520 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
4523 lctl set_param fail_loc=0x80000129
4524 $MULTIOP $DIR/d73-1/f73-2 Oc &
4526 lctl set_param fail_loc=0
4528 $MULTIOP $DIR/d73-2/f73-3 Oc &
4532 wait $pid1 || return 1
4536 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
4537 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
4538 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
4542 run_test 73 "multiple MDC requests (should not deadlock)"
4544 test_74a() { # bug 6149, 6184
4545 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
4547 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
4548 # will spin in a tight reconnection loop
4550 lctl set_param fail_loc=0x8000030e
4551 # get any lock that won't be difficult - lookup works.
4553 lctl set_param fail_loc=0
4557 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
4559 test_74b() { # bug 13310
4560 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
4562 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
4563 # will spin in a tight reconnection loop
4564 lctl set_param fail_loc=0x8000030e
4565 # get a "difficult" lock
4567 lctl set_param fail_loc=0
4571 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
4574 #define OBD_FAIL_LDLM_NEW_LOCK
4575 lctl set_param fail_loc=0x80000319
4576 touch $DIR/$tfile && error "Touch successful"
4579 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
4582 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
4585 get_inode_slab_tunables() {
4586 awk '/lustre_inode_cache/ {print $9," ",$10," ",$11; exit}' /proc/slabinfo
4589 set_inode_slab_tunables() {
4590 echo "lustre_inode_cache $1" > /proc/slabinfo
4593 test_76() { # Now for bug 20433, added originally in bug 1443
4594 local SLAB_SETTINGS=`get_inode_slab_tunables`
4595 local CPUS=`getconf _NPROCESSORS_ONLN`
4596 # we cannot set limit below 1 which means 1 inode in each
4597 # per-cpu cache is still allowed
4598 set_inode_slab_tunables "1 1 0"
4599 cancel_lru_locks osc
4600 BEFORE_INODES=`num_inodes`
4601 echo "before inodes: $BEFORE_INODES"
4603 [ "$SLOW" = "no" ] && COUNT=100
4604 for i in `seq $COUNT`; do
4608 cancel_lru_locks osc
4609 AFTER_INODES=`num_inodes`
4610 echo "after inodes: $AFTER_INODES"
4612 while [ $((AFTER_INODES-1*CPUS)) -gt $BEFORE_INODES ]; do
4614 AFTER_INODES=`num_inodes`
4616 echo "wait $wait seconds inodes: $AFTER_INODES"
4617 if [ $wait -gt 30 ]; then
4618 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
4621 set_inode_slab_tunables "$SLAB_SETTINGS"
4623 run_test 76 "confirm clients recycle inodes properly ===="
4629 # Note: in sptlrpc modes which enable its own bulk checksum, the
4630 # original crc32_le bulk checksum will be automatically disabled,
4631 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
4632 # will be checked by sptlrpc code against sptlrpc bulk checksum.
4633 # In this case set_checksums() will not be no-op, because sptlrpc
4634 # bulk checksum will be enabled all through the test.
4636 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
4637 lctl set_param -n osc.*.checksums $1
4641 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
4642 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
4643 CKSUM_TYPES=${CKSUM_TYPES:-"crc32 adler"}
4644 [ "$ORIG_CSUM_TYPE" = "crc32c" ] && CKSUM_TYPES="$CKSUM_TYPES crc32c"
4647 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
4648 log "set checksum type to $1"
4651 F77_TMP=$TMP/f77-temp
4654 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
4655 error "error writing to $F77_TMP"
4658 test_77a() { # bug 10889
4659 $GSS && skip "could not run with gss" && return
4660 [ ! -f $F77_TMP ] && setup_f77
4662 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
4666 run_test 77a "normal checksum read/write operation ============="
4668 test_77b() { # bug 10889
4669 $GSS && skip "could not run with gss" && return
4670 [ ! -f $F77_TMP ] && setup_f77
4671 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
4672 lctl set_param fail_loc=0x80000409
4674 dd if=$F77_TMP of=$DIR/f77b bs=1M count=$F77SZ conv=sync || \
4675 error "dd error: $?"
4676 lctl set_param fail_loc=0
4679 run_test 77b "checksum error on client write ===================="
4681 test_77c() { # bug 10889
4682 $GSS && skip "could not run with gss" && return
4683 [ ! -f $DIR/f77b ] && skip "requires 77b - skipping" && return
4685 for algo in $CKSUM_TYPES; do
4686 cancel_lru_locks osc
4687 set_checksum_type $algo
4688 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
4689 lctl set_param fail_loc=0x80000408
4690 cmp $F77_TMP $DIR/f77b || error "file compare failed"
4691 lctl set_param fail_loc=0
4694 set_checksum_type $ORIG_CSUM_TYPE
4697 run_test 77c "checksum error on client read ==================="
4699 test_77d() { # bug 10889
4700 $GSS && skip "could not run with gss" && return
4701 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
4702 lctl set_param fail_loc=0x80000409
4704 directio write $DIR/f77 0 $F77SZ $((1024 * 1024)) || \
4705 error "direct write: rc=$?"
4706 lctl set_param fail_loc=0
4709 run_test 77d "checksum error on OST direct write ==============="
4711 test_77e() { # bug 10889
4712 $GSS && skip "could not run with gss" && return
4713 [ ! -f $DIR/f77 ] && skip "requires 77d - skipping" && return
4714 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
4715 lctl set_param fail_loc=0x80000408
4717 cancel_lru_locks osc
4718 directio read $DIR/f77 0 $F77SZ $((1024 * 1024)) || \
4719 error "direct read: rc=$?"
4720 lctl set_param fail_loc=0
4723 run_test 77e "checksum error on OST direct read ================"
4725 test_77f() { # bug 10889
4726 $GSS && skip "could not run with gss" && return
4728 for algo in $CKSUM_TYPES; do
4729 cancel_lru_locks osc
4730 set_checksum_type $algo
4731 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
4732 lctl set_param fail_loc=0x409
4733 directio write $DIR/f77 0 $F77SZ $((1024 * 1024)) && \
4734 error "direct write succeeded"
4735 lctl set_param fail_loc=0
4737 set_checksum_type $ORIG_CSUM_TYPE
4740 run_test 77f "repeat checksum error on write (expect error) ===="
4742 test_77g() { # bug 10889
4743 $GSS && skip "could not run with gss" && return
4744 remote_ost_nodsh && skip "remote OST with nodsh" && return
4746 [ ! -f $F77_TMP ] && setup_f77
4748 $SETSTRIPE -c 1 -i 0 $DIR/f77g
4749 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
4750 do_facet ost1 lctl set_param fail_loc=0x8000021a
4752 dd if=$F77_TMP of=$DIR/f77g bs=1M count=$F77SZ || \
4753 error "write error: rc=$?"
4754 do_facet ost1 lctl set_param fail_loc=0
4757 run_test 77g "checksum error on OST write ======================"
4759 test_77h() { # bug 10889
4760 $GSS && skip "could not run with gss" && return
4761 remote_ost_nodsh && skip "remote OST with nodsh" && return
4763 [ ! -f $DIR/f77g ] && skip "requires 77g - skipping" && return
4764 cancel_lru_locks osc
4765 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
4766 do_facet ost1 lctl set_param fail_loc=0x8000021b
4768 cmp $F77_TMP $DIR/f77g || error "file compare failed"
4769 do_facet ost1 lctl set_param fail_loc=0
4772 run_test 77h "checksum error on OST read ======================="
4774 test_77i() { # bug 13805
4775 $GSS && skip "could not run with gss" && return
4776 #define OBD_FAIL_OSC_CONNECT_CKSUM 0x40b
4777 lctl set_param fail_loc=0x40b
4778 remount_client $MOUNT
4779 lctl set_param fail_loc=0
4780 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
4781 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
4782 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
4783 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
4785 remount_client $MOUNT
4787 run_test 77i "client not supporting OSD_CONNECT_CKSUM =========="
4789 test_77j() { # bug 13805
4790 $GSS && skip "could not run with gss" && return
4791 #define OBD_FAIL_OSC_CKSUM_ADLER_ONLY 0x40c
4792 lctl set_param fail_loc=0x40c
4793 remount_client $MOUNT
4794 lctl set_param fail_loc=0
4795 sleep 2 # wait async osc connect to finish
4796 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
4797 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
4798 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
4799 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
4801 remount_client $MOUNT
4803 run_test 77j "client only supporting ADLER32 ===================="
4805 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
4809 test_78() { # bug 10901
4810 remote_ost || { skip_env "local OST" && return; }
4813 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
4814 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
4815 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
4816 echo "MemTotal: $MEMTOTAL"
4817 # reserve 256MB of memory for the kernel and other running processes,
4818 # and then take 1/2 of the remaining memory for the read/write buffers.
4819 if [ $MEMTOTAL -gt 512 ] ;then
4820 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
4822 # for those poor memory-starved high-end clusters...
4823 MEMTOTAL=$((MEMTOTAL / 2))
4825 echo "Mem to use for directio: $MEMTOTAL"
4826 [ $F78SIZE -gt $MEMTOTAL ] && F78SIZE=$MEMTOTAL
4827 [ $F78SIZE -gt 512 ] && F78SIZE=512
4828 [ $F78SIZE -gt $((MAXFREE / 1024)) ] && F78SIZE=$((MAXFREE / 1024))
4829 SMALLESTOST=`lfs df $DIR |grep OST | awk '{print $4}' |sort -n |head -1`
4830 echo "Smallest OST: $SMALLESTOST"
4831 [ $SMALLESTOST -lt 10240 ] && \
4832 skip "too small OSTSIZE, useless to run large O_DIRECT test" && return 0
4834 [ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ] && \
4835 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
4837 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
4838 echo "File size: $F78SIZE"
4839 $SETSTRIPE -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
4840 for i in `seq 1 $NSEQ`
4842 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
4843 echo directIO rdwr round $i of $NSEQ
4844 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
4849 run_test 78 "handle large O_DIRECT writes correctly ============"
4851 test_79() { # bug 12743
4852 wait_delete_completed
4854 BKTOTAL=$(calc_osc_kbytes kbytestotal)
4855 BKFREE=$(calc_osc_kbytes kbytesfree)
4856 BKAVAIL=$(calc_osc_kbytes kbytesavail)
4858 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
4859 DFTOTAL=`echo $STRING | cut -d, -f1`
4860 DFUSED=`echo $STRING | cut -d, -f2`
4861 DFAVAIL=`echo $STRING | cut -d, -f3`
4862 DFFREE=$(($DFTOTAL - $DFUSED))
4864 ALLOWANCE=$((64 * $OSTCOUNT))
4866 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
4867 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
4868 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
4870 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
4871 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
4872 error "df free($DFFREE) mismatch OST free($BKFREE)"
4874 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
4875 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
4876 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
4879 run_test 79 "df report consistency check ======================="
4881 test_80() { # bug 10718
4882 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
4884 local BEFORE=`date +%s`
4885 cancel_lru_locks osc
4886 local AFTER=`date +%s`
4887 local DIFF=$((AFTER-BEFORE))
4888 if [ $DIFF -gt 1 ] ; then
4889 error "elapsed for 1M@1T = $DIFF"
4894 run_test 80 "Page eviction is equally fast at high offsets too ===="
4896 test_81a() { # LU-456
4897 remote_ost_nodsh && skip "remote OST with nodsh" && return
4898 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
4899 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
4900 do_facet ost0 lctl set_param fail_loc=0x80000228
4902 # write should trigger a retry and success
4903 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
4904 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
4906 if [ $RC -ne 0 ] ; then
4907 error "write should success, but failed for $RC"
4910 run_test 81a "OST should retry write when get -ENOSPC ==============="
4912 test_81b() { # LU-456
4913 remote_ost_nodsh && skip "remote OST with nodsh" && return
4914 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
4915 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
4916 do_facet ost0 lctl set_param fail_loc=0x228
4918 # write should retry several times and return -ENOSPC finally
4919 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
4920 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
4923 if [ $RC -ne $ENOSPC ] ; then
4924 error "dd should fail for -ENOSPC, but succeed."
4927 run_test 81b "OST should return -ENOSPC when retry still fails ======="
4929 test_82() { # LU-1031
4930 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10
4934 multiop_bg_pause $DIR/$tfile OG${gid1}_g${gid1}c || return 1
4936 multiop_bg_pause $DIR/$tfile O_G${gid2}r10g${gid2}c || return 2
4938 kill -USR1 $MULTIPID2
4940 if [[ `ps h -o comm -p $MULTIPID2` == "" ]]; then
4941 error "First grouplock does not block second one"
4943 echo "Second grouplock blocks first one"
4945 kill -USR1 $MULTIPID1
4949 run_test 82 "Basic grouplock test ==============================="
4952 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && \
4954 mkdir -p $DIR/d99cvsroot
4955 chown $RUNAS_ID $DIR/d99cvsroot
4956 local oldPWD=$PWD # bug 13584, use $TMP as working dir
4959 $RUNAS cvs -d $DIR/d99cvsroot init || error
4962 run_test 99a "cvs init ========================================="
4965 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
4966 [ ! -d $DIR/d99cvsroot ] && test_99a
4968 # some versions of cvs import exit(1) when asked to import links or
4969 # files they can't read. ignore those files.
4970 TOIGNORE=$(find . -type l -printf '-I %f\n' -o \
4971 ! -perm +4 -printf '-I %f\n')
4972 $RUNAS cvs -d $DIR/d99cvsroot import -m "nomesg" $TOIGNORE \
4973 d99reposname vtag rtag
4975 run_test 99b "cvs import ======================================="
4978 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
4979 [ ! -d $DIR/d99cvsroot ] && test_99b
4981 mkdir -p $DIR/d99reposname
4982 chown $RUNAS_ID $DIR/d99reposname
4983 $RUNAS cvs -d $DIR/d99cvsroot co d99reposname
4985 run_test 99c "cvs checkout ====================================="
4988 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
4989 [ ! -d $DIR/d99cvsroot ] && test_99c
4990 cd $DIR/d99reposname
4992 $RUNAS cvs add -m 'addmsg' foo99
4994 run_test 99d "cvs add =========================================="
4997 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
4998 [ ! -d $DIR/d99cvsroot ] && test_99c
4999 cd $DIR/d99reposname
5002 run_test 99e "cvs update ======================================="
5005 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5006 [ ! -d $DIR/d99cvsroot ] && test_99d
5007 cd $DIR/d99reposname
5008 $RUNAS cvs commit -m 'nomsg' foo99
5009 rm -fr $DIR/d99cvsroot
5011 run_test 99f "cvs commit ======================================="
5014 [ "$NETTYPE" = tcp ] || \
5015 { skip "TCP secure port test, not useful for NETTYPE=$NETTYPE" && \
5018 remote_ost_nodsh && skip "remote OST with nodsh" && return
5019 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5021 { skip "useless for local single node setup" && return; }
5023 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
5024 [ "$PROT" != "tcp" ] && continue
5025 RPORT=$(echo $REMOTE | cut -d: -f2)
5026 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
5029 LPORT=`echo $LOCAL | cut -d: -f2`
5030 if [ $LPORT -ge 1024 ]; then
5031 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
5033 error_exit "local: $LPORT > 1024, remote: $RPORT"
5036 [ "$rc" = 0 ] || error_exit "privileged port not found" )
5038 run_test 100 "check local port using privileged port ==========="
5040 function get_named_value()
5049 echo $line | sed "s/^$tag[ ]*//"
5056 export CACHE_MAX=`$LCTL get_param -n llite.*.max_cached_mb | head -n 1`
5058 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
5066 [ "$CPU" = "UML" ] && nreads=1000
5067 local cache_limit=32
5069 $LCTL set_param -n osc.*-osc*.rpc_stats 0
5070 trap cleanup_101a EXIT
5071 $LCTL set_param -n llite.*.read_ahead_stats 0
5072 $LCTL set_param -n llite.*.max_cached_mb $cache_limit
5075 # randomly read 10000 of 64K chunks from file 3x 32MB in size
5077 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
5078 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
5081 for s in `$LCTL get_param -n llite.*.read_ahead_stats | \
5082 get_named_value 'read but discarded' | cut -d" " -f1`; do
5083 discard=$(($discard + $s))
5087 if [ $(($discard * 10)) -gt $nreads ] ;then
5088 $LCTL get_param osc.*-osc*.rpc_stats
5089 $LCTL get_param llite.*.read_ahead_stats
5090 error "too many ($discard) discarded pages"
5092 rm -f $DIR/$tfile || true
5094 run_test 101a "check read-ahead for random reads ================"
5099 STRIPE_COUNT=$OSTCOUNT
5102 local list=$(comma_list $(osts_nodes))
5103 do_nodes $list $LCTL set_param -n obdfilter.*.read_cache_enable=0
5104 do_nodes $list $LCTL set_param -n obdfilter.*.writethrough_cache_enable=0
5106 trap cleanup_test101bc EXIT
5107 # prepare the read-ahead file
5108 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
5110 dd if=/dev/zero of=$DIR/$tfile bs=1024k count=100 2> /dev/null
5113 cleanup_test101bc() {
5118 local list=$(comma_list $(osts_nodes))
5119 do_nodes $list $LCTL set_param -n obdfilter.*.read_cache_enable=1
5120 do_nodes $list $LCTL set_param -n obdfilter.*.writethrough_cache_enable=1
5124 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
5129 local STRIPE_SIZE=1048576
5130 local RA_INC=1048576
5131 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
5132 local FILE_LENGTH=$((64*100))
5133 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
5134 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
5135 DISCARD=`$LCTL get_param -n llite.*.read_ahead_stats | \
5136 get_named_value 'read but discarded' | \
5137 cut -d" " -f1 | calc_total`
5138 if [ $DISCARD -gt $discard_limit ]; then
5139 $LCTL get_param llite.*.read_ahead_stats
5140 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
5142 echo "Read-ahead success for size ${READ_SIZE}"
5147 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping stride IO stride-ahead test" && return
5148 local STRIPE_SIZE=1048576
5149 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
5150 local FILE_LENGTH=$((STRIPE_SIZE*100))
5151 local ITERATION=$((FILE_LENGTH/STRIDE_SIZE))
5152 # prepare the read-ahead file
5154 cancel_lru_locks osc
5155 for BIDX in 2 4 8 16 32 64 128 256
5157 local BSIZE=$((BIDX*4096))
5158 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
5159 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
5160 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
5161 $LCTL set_param -n llite.*.read_ahead_stats 0
5162 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
5163 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
5164 cancel_lru_locks osc
5170 run_test 101b "check stride-io mode read-ahead ================="
5173 local STRIPE_SIZE=1048576
5174 local FILE_LENGTH=$((STRIPE_SIZE*100))
5180 cancel_lru_locks osc
5181 $LCTL set_param osc.*.rpc_stats 0
5182 $READS -f $DIR/$tfile -s$FILE_LENGTH -b65536 -n$nreads -t 180
5183 for osc in $($LCTL get_param -N osc.*); do
5184 if [ "$osc" == "osc.num_refs" ]; then
5188 local lines=$($LCTL get_param -n ${osc}.rpc_stats | wc | awk '{print $1}')
5189 if [ $lines -le 20 ]; then
5193 local rpc4k=$($LCTL get_param -n ${osc}.rpc_stats |
5194 awk '$1 == "1:" { print $2; exit; }')
5195 local rpc8k=$($LCTL get_param -n ${osc}.rpc_stats |
5196 awk '$1 == "2:" { print $2; exit; }')
5197 local rpc16k=$($LCTL get_param -n ${osc}.rpc_stats |
5198 awk '$1 == "4:" { print $2; exit; }')
5199 local rpc32k=$($LCTL get_param -n ${osc}.rpc_stats |
5200 awk '$1 == "8:" { print $2; exit; }')
5202 [ $rpc4k != 0 ] && error "Small 4k read IO ${rpc4k}!"
5203 [ $rpc8k != 0 ] && error "Small 8k read IO ${rpc8k}!"
5204 [ $rpc16k != 0 ] && error "Small 16k read IO ${rpc16k}!"
5205 [ $rpc32k != 0 ] && error "Small 32k read IO ${rpc32k}!"
5206 echo "${osc} rpc check passed!"
5211 run_test 101c "check stripe_size aligned read-ahead ================="
5214 $LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1
5215 $LCTL set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
5219 local file=$DIR/$tfile
5220 local size=${FILESIZE_101c:-500}
5221 local ra_MB=${READAHEAD_MB:-40}
5223 local space=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
5224 [ $space -gt $((size / 1024)) ] ||
5225 { skip "Need free space ${size}M, have $space" && return; }
5227 echo Creating ${size}M test file $file
5228 dd if=/dev/zero of=$file bs=1M count=$size
5229 echo Cancel LRU locks on lustre client to flush the client cache
5230 cancel_lru_locks osc
5232 echo Disable read-ahead
5233 local old_READAHEAD=$(set_read_ahead 0)
5235 echo Reading the test file $file with read-ahead disabled
5236 time_ra_OFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$size")
5238 echo Cancel LRU locks on lustre client to flush the client cache
5239 cancel_lru_locks osc
5240 echo Enable read-ahead with ${ra_MB}MB
5241 set_read_ahead $ra_MB
5243 echo Reading the test file $file with read-ahead enabled
5244 time_ra_ON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$size")
5246 echo read-ahead disabled time read $time_ra_OFF
5247 echo read-ahead enabled time read $time_ra_ON
5249 set_read_ahead $old_READAHEAD
5252 [ $time_ra_ON -lt $time_ra_OFF ] ||
5253 error "read-ahead enabled time read (${time_ra_ON}s) is more than
5254 read-ahead disabled time read (${time_ra_OFF}s) filesize ${size}M"
5256 run_test 101d "file read with and without read-ahead enabled ================="
5259 local file=$DIR/$tfile
5264 local space=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
5265 local need_space=$((count * size))
5266 [ $space -gt $need_space ] ||
5267 { skip_env "Need free space $need_space, have $space" && return; }
5269 echo Creating $count ${size}K test files
5270 for ((i = 0; i < $count; i++)); do
5271 dd if=/dev/zero of=${file}_${i} bs=$blksize count=$size 2>/dev/null
5274 echo Cancel LRU locks on lustre client to flush the client cache
5275 cancel_lru_locks osc
5277 echo Reset readahead stats
5278 $LCTL set_param -n llite.*.read_ahead_stats 0
5280 for ((i = 0; i < $count; i++)); do
5281 dd if=${file}_${i} of=/dev/null bs=$blksize count=$size 2>/dev/null
5284 local miss=$($LCTL get_param -n llite.*.read_ahead_stats | \
5285 get_named_value 'misses' | cut -d" " -f1 | calc_total)
5287 for ((i = 0; i < $count; i++)); do
5288 rm -rf ${file}_${i} 2>/dev/null
5291 #10000 means 20% reads are missing in readahead
5292 [ $miss -lt 10000 ] || error "misses too much for small reads"
5294 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
5296 cleanup_test101f() {
5298 $LCTL set_param -n llite.*.max_read_ahead_whole_mb $MAX_WHOLE_MB
5299 rm -rf $DIR/$tfile 2>/dev/null
5303 local file=$DIR/$tfile
5306 MAX_WHOLE_MB=$($LCTL get_param -n llite.*.max_read_ahead_whole_mb)
5307 $LCTL set_param -n llite.*.max_read_ahead_whole_mb 2
5308 dd if=/dev/zero of=${file} bs=2097152 count=1 2>/dev/null
5309 trap cleanup_test101f EXIT
5311 echo Cancel LRU locks on lustre client to flush the client cache
5312 cancel_lru_locks osc
5314 echo Reset readahead stats
5315 $LCTL set_param -n llite.*.read_ahead_stats 0
5316 # Random read in a 2M file, because max_read_ahead_whole_mb = 2M,
5317 # readahead should read in 2M file on second read, so only miss
5319 echo Random 4K reads on 2M file for 1000 times
5320 $READS -f $file -s 2097152 -b 4096 -n $nreads
5322 echo checking missing pages
5323 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
5324 get_named_value 'misses' | cut -d" " -f1 | calc_total)
5326 [ $miss -lt 3 ] || error "misses too much pages!"
5329 run_test 101f "check read-ahead for max_read_ahead_whole_mb"
5333 chown $RUNAS_ID $DIR/$tdir
5336 STRIPE_COUNT=$OSTCOUNT
5337 [ $OSTCOUNT -gt 4 ] && STRIPE_COUNT=4
5339 trap cleanup_test102 EXIT
5341 $1 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
5343 for num in 1 2 3 4; do
5344 for count in $(seq 1 $STRIPE_COUNT); do
5345 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
5346 local size=`expr $STRIPE_SIZE \* $num`
5347 local file=file"$num-$idx-$count"
5348 $1 $SETSTRIPE -S $size -i $idx -c $count $file
5354 $1 $TAR cf $TMP/f102.tar $tdir --xattrs
5360 rm -rf $DIR/d0.sanity/d102
5364 local testfile=$DIR/xattr_testfile
5368 [ "$UID" != 0 ] && skip_env "must run as root" && return
5369 [ -z "`lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr`" ] &&
5370 skip_env "must have user_xattr" && return
5372 [ -z "$(which setfattr 2>/dev/null)" ] &&
5373 skip_env "could not find setfattr" && return
5375 echo "set/get xattr..."
5376 setfattr -n trusted.name1 -v value1 $testfile || error
5377 getfattr -n trusted.name1 $testfile 2> /dev/null |
5378 grep "trusted.name1=.value1" ||
5379 error "$testfile missing trusted.name1=value1"
5381 setfattr -n user.author1 -v author1 $testfile || error
5382 getfattr -n user.author1 $testfile 2> /dev/null |
5383 grep "user.author1=.author1" ||
5384 error "$testfile missing trusted.author1=author1"
5387 setfattr -n trusted.name2 -v value2 $testfile ||
5388 error "$testfile unable to set trusted.name2"
5389 setfattr -n trusted.name3 -v value3 $testfile ||
5390 error "$testfile unable to set trusted.name3"
5391 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
5392 grep "trusted.name" | wc -l) -eq 3 ] ||
5393 error "$testfile missing 3 trusted.name xattrs"
5395 setfattr -n user.author2 -v author2 $testfile ||
5396 error "$testfile unable to set user.author2"
5397 setfattr -n user.author3 -v author3 $testfile ||
5398 error "$testfile unable to set user.author3"
5399 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
5400 grep "user.author" | wc -l) -eq 3 ] ||
5401 error "$testfile missing 3 user.author xattrs"
5403 echo "remove xattr..."
5404 setfattr -x trusted.name1 $testfile ||
5405 error "$testfile error deleting trusted.name1"
5406 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
5407 error "$testfile did not delete trusted.name1 xattr"
5409 setfattr -x user.author1 $testfile ||
5410 error "$testfile error deleting user.author1"
5411 getfattr -d -m user $testfile 2> /dev/null | grep "user.author1" &&
5412 error "$testfile did not delete trusted.name1 xattr"
5414 # b10667: setting lustre special xattr be silently discarded
5415 echo "set lustre special xattr ..."
5416 setfattr -n "trusted.lov" -v "invalid value" $testfile ||
5417 error "$testfile allowed setting trusted.lov"
5419 run_test 102a "user xattr test =================================="
5422 # b10930: get/set/list trusted.lov xattr
5423 echo "get/set/list trusted.lov xattr ..."
5424 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
5425 local testfile=$DIR/$tfile
5426 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
5427 error "setstripe failed"
5428 local STRIPECOUNT=$($GETSTRIPE -c $testfile) ||
5429 error "getstripe failed"
5430 getfattr -d -m "^trusted" $testfile 2> /dev/null | \
5431 grep "trusted.lov" || error "can't get trusted.lov from $testfile"
5433 local testfile2=${testfile}2
5434 local value=`getfattr -n trusted.lov $testfile 2> /dev/null | \
5435 grep "trusted.lov" |sed -e 's/[^=]\+=//'`
5438 setfattr -n trusted.lov -v $value $testfile2
5439 local stripe_size=$($GETSTRIPE -S $testfile2)
5440 local stripe_count=$($GETSTRIPE -c $testfile2)
5441 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
5442 [ $stripe_count -eq $STRIPECOUNT ] ||
5443 error "stripe count $stripe_count != $STRIPECOUNT"
5446 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
5449 # b10930: get/set/list lustre.lov xattr
5450 echo "get/set/list lustre.lov xattr ..."
5451 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
5453 chown $RUNAS_ID $DIR/$tdir
5454 local testfile=$DIR/$tdir/$tfile
5455 $RUNAS $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
5456 error "setstripe failed"
5457 local STRIPECOUNT=$($RUNAS $GETSTRIPE -c $testfile) ||
5458 error "getstripe failed"
5459 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
5460 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
5462 local testfile2=${testfile}2
5463 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
5464 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
5466 $RUNAS $MCREATE $testfile2
5467 $RUNAS setfattr -n lustre.lov -v $value $testfile2
5468 local stripe_size=$($RUNAS $GETSTRIPE -S $testfile2)
5469 local stripe_count=$($RUNAS $GETSTRIPE -c $testfile2)
5470 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
5471 [ $stripe_count -eq $STRIPECOUNT ] ||
5472 error "stripe count $stripe_count != $STRIPECOUNT"
5474 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
5476 compare_stripe_info1() {
5477 local stripe_index_all_zero=true
5479 for num in 1 2 3 4; do
5480 for count in $(seq 1 $STRIPE_COUNT); do
5481 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
5482 local size=$((STRIPE_SIZE * num))
5483 local file=file"$num-$offset-$count"
5484 stripe_size=$(lfs getstripe -S $PWD/$file)
5485 [ $stripe_size -ne $size ] &&
5486 error "$file: size $stripe_size != $size"
5487 stripe_count=$(lfs getstripe -c $PWD/$file)
5488 # allow fewer stripes to be created, ORI-601
5489 [ $stripe_count -lt $(((3 * count + 3) / 4)) ]&&
5490 error "$file: count $stripe_count != $count"
5491 stripe_index=$(lfs getstripe -i $PWD/$file)
5492 [ $stripe_index -ne 0 ] &&
5493 stripe_index_all_zero=false
5497 $stripe_index_all_zero &&
5498 error "all files are being extracted starting from OST index 0"
5503 [ -n "$(which tar 2>/dev/null)" ] &&
5504 strings $(which tar) | grep -q "lustre" && echo tar
5508 # b10930: tar test for trusted.lov xattr
5509 TAR=$(find_lustre_tar)
5510 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
5511 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
5514 $TAR xf $TMP/f102.tar -C $DIR/d102d --xattrs
5516 compare_stripe_info1
5518 run_test 102d "tar restore stripe info from tarfile,not keep osts ==========="
5521 # b10930: tar test for trusted.lov xattr
5522 TAR=$(find_lustre_tar)
5523 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
5524 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
5528 $TAR cf - --xattrs $tdir | $TAR xf - --xattrs -C $DIR/d102f
5530 compare_stripe_info1
5532 run_test 102f "tar copy files, not keep osts ==========="
5535 local xsize=${1:-1024} # in bytes
5536 local file=$DIR/$tfile
5538 [ -z $(lctl get_param -n mdc.*.connect_flags | grep xattr) ] &&
5539 skip "must have user_xattr" && return 0
5540 [ -z "$(which setfattr 2>/dev/null)" ] &&
5541 skip_env "could not find setfattr" && return 0
5542 [ -z "$(which getfattr 2>/dev/null)" ] &&
5543 skip_env "could not find getfattr" && return 0
5547 local value="$(generate_string $xsize)"
5549 local xbig=trusted.big
5550 log "save $xbig on $file"
5551 setfattr -n $xbig -v $value $file ||
5552 error "saving $xbig on $file failed"
5554 local orig=$(get_xattr_value $xbig $file)
5555 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
5557 local xsml=trusted.sml
5558 log "save $xsml on $file"
5559 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
5561 local new=$(get_xattr_value $xbig $file)
5562 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
5564 log "grow $xsml on $file"
5565 setfattr -n $xsml -v "$value" $file ||
5566 error "growing $xsml on $file failed"
5568 new=$(get_xattr_value $xbig $file)
5569 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
5570 log "$xbig still valid after growing $xsml"
5575 test_102h() { # bug 15777
5578 run_test 102h "grow xattr from inside inode to external block"
5581 large_xattr_enabled || { skip "large_xattr disabled" && return; }
5582 grow_xattr $(max_xattr_size)
5584 run_test 102ha "grow xattr from inside inode to external inode"
5586 test_102i() { # bug 17038
5588 ln -s $DIR/$tfile $DIR/${tfile}link
5589 getfattr -n trusted.lov $DIR/$tfile || error "lgetxattr on $DIR/$tfile failed"
5590 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"
5591 rm -f $DIR/$tfile $DIR/${tfile}link
5593 run_test 102i "lgetxattr test on symbolic link ============"
5596 TAR=$(find_lustre_tar)
5597 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
5598 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
5599 setup_test102 "$RUNAS"
5601 chown $RUNAS_ID $DIR/d102j
5602 $RUNAS $TAR xf $TMP/f102.tar -C $DIR/d102j --xattrs
5604 compare_stripe_info1 "$RUNAS"
5606 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
5610 # b22187 just check that does not crash for regular file.
5611 setfattr -n trusted.lov $DIR/$tfile
5612 # b22187 'setfattr -n trusted.lov' should work as remove LOV EA for directories
5613 local test_kdir=$DIR/d102k
5615 local default_size=`$GETSTRIPE -S $test_kdir`
5616 local default_count=`$GETSTRIPE -c $test_kdir`
5617 local default_offset=`$GETSTRIPE -i $test_kdir`
5618 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $test_kdir ||
5619 error 'dir setstripe failed'
5620 setfattr -n trusted.lov $test_kdir
5621 local stripe_size=`$GETSTRIPE -S $test_kdir`
5622 local stripe_count=`$GETSTRIPE -c $test_kdir`
5623 local stripe_offset=`$GETSTRIPE -i $test_kdir`
5624 [ $stripe_size -eq $default_size ] ||
5625 error "stripe size $stripe_size != $default_size"
5626 [ $stripe_count -eq $default_count ] ||
5627 error "stripe count $stripe_count != $default_count"
5628 [ $stripe_offset -eq $default_offset ] ||
5629 error "stripe offset $stripe_offset != $default_offset"
5630 rm -rf $DIR/$tfile $test_kdir
5632 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
5635 # LU-532 trusted. xattr is invisible to non-root
5636 local testfile=$DIR/$tfile
5640 echo "listxattr as user..."
5641 chown $RUNAS_ID $testfile
5642 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
5643 grep -q "trusted" &&
5644 error "$testfile trusted xattrs are user visible"
5648 run_test 102l "listxattr filter test =================================="
5654 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
5659 [ "$UID" != 0 ] && skip_env "must run as root" && return
5660 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
5661 [ -z "$(which setfacl 2>/dev/null)" ] && skip_env "could not find setfacl" && return
5662 $GSS && skip "could not run under gss" && return
5664 declare -a identity_old
5666 for num in `seq $MDSCOUNT`; do
5667 switch_identity $num true || identity_old[$num]=$?
5674 echo "performing cp ..."
5675 run_acl_subtest cp || error
5676 echo "performing getfacl-noacl..."
5677 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
5678 echo "performing misc..."
5679 run_acl_subtest misc || error "misc test failed"
5680 echo "performing permissions..."
5681 run_acl_subtest permissions || error "permissions failed"
5682 echo "performing setfacl..."
5683 run_acl_subtest setfacl || error "setfacl test failed"
5685 # inheritance test got from HP
5686 echo "performing inheritance..."
5687 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
5688 chmod +x make-tree || error "chmod +x failed"
5689 run_acl_subtest inheritance || error "inheritance test failed"
5695 for num in `seq $MDSCOUNT`; do
5696 if [ "${identity_old[$num]}" = 1 ]; then
5697 switch_identity $num false || identity_old[$num]=$?
5701 run_test 103 "acl test ========================================="
5705 lfs df || error "lfs df failed"
5706 lfs df -ih || error "lfs df -ih failed"
5707 lfs df -h $DIR || error "lfs df -h $DIR failed"
5708 lfs df -i $DIR || error "lfs df -i $DIR failed"
5709 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
5710 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
5712 OSC=`lctl dl |grep OST0000-osc-[^M] |awk '{print $4}'`
5713 lctl --device %$OSC deactivate
5714 lfs df || error "lfs df with deactivated OSC failed"
5715 lctl --device %$OSC activate
5716 # wait the osc back to normal
5717 wait_osc_import_state client ost FULL
5719 lfs df || error "lfs df with reactivated OSC failed"
5722 run_test 104a "lfs df [-ih] [path] test ========================="
5725 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5727 denied_cnt=$((`$RUNAS $LFS check servers 2>&1 | grep "Permission denied" | wc -l`))
5728 if [ $denied_cnt -ne 0 ];
5730 error "lfs check servers test failed"
5733 run_test 104b "$RUNAS lfs check servers test ===================="
5736 # doesn't work on 2.4 kernels
5738 if [ -n "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ];
5740 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
5742 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
5746 run_test 105a "flock when mounted without -o flock test ========"
5750 if [ -n "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ];
5752 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
5754 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
5758 run_test 105b "fcntl when mounted without -o flock test ========"
5762 if [ -n "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ];
5764 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
5766 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
5770 run_test 105c "lockf when mounted without -o flock test ========"
5772 test_105d() { # bug 15924
5774 [ -z "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ] && \
5775 skip "mount w/o flock enabled" && return
5776 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
5777 $LCTL set_param fail_loc=0x80000315
5778 flocks_test 2 $DIR/$tdir
5780 run_test 105d "flock race (should not freeze) ========"
5782 test_105e() { # bug 22660 && 22040
5783 [ -z "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ] && \
5784 skip "mount w/o flock enabled" && return
5786 flocks_test 3 $DIR/$tfile
5788 run_test 105e "Two conflicting flocks from same process ======="
5790 test_106() { #bug 10921
5792 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
5793 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
5795 run_test 106 "attempt exec of dir followed by chown of that dir"
5804 local save_pattern=$(sysctl -n kernel.core_pattern)
5805 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
5806 sysctl -w kernel.core_pattern=$file
5807 sysctl -w kernel.core_uses_pid=0
5815 kill -s 11 $SLEEPPID
5817 if [ -e $file ]; then
5818 size=`stat -c%s $file`
5819 [ $size -eq 0 ] && error "Fail to create core file $file"
5821 error "Fail to create core file $file"
5824 sysctl -w kernel.core_pattern=$save_pattern
5825 sysctl -w kernel.core_uses_pid=$save_uses_pid
5828 run_test 107 "Coredump on SIG"
5832 mkdir $DIR/d110/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa || error "mkdir with 255 char fail"
5833 mkdir $DIR/d110/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb && error "mkdir with 256 char should fail, but not"
5834 touch $DIR/d110/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx || error "create with 255 char fail"
5835 touch $DIR/d110/yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy && error ""create with 256 char should fail, but not
5840 run_test 110 "filename length checking"
5843 OSTIO_pre=$(ps -e|grep ll_ost_io|awk '{print $4}'|sort -n|tail -1|\
5845 [ -z "$OSTIO_pre" ] && skip "no OSS threads" && \
5847 echo "Starting with $OSTIO_pre threads"
5850 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
5851 [ $NUMFREE -lt $NUMTEST ] && NUMTEST=$(($NUMFREE - 1000))
5852 echo "$NUMTEST creates/unlinks"
5854 createmany -o $DIR/$tdir/$tfile $NUMTEST
5855 unlinkmany $DIR/$tdir/$tfile $NUMTEST
5857 OSTIO_post=$(ps -e|grep ll_ost_io|awk '{print $4}'|sort -n|tail -1|\
5860 # don't return an error
5861 [ $OSTIO_post == $OSTIO_pre ] && echo \
5862 "WARNING: No new ll_ost_io threads were created ($OSTIO_pre)" &&
5863 echo "This may be fine, depending on what ran before this test" &&
5864 echo "and how fast this system is." && return
5866 echo "Started with $OSTIO_pre threads, ended with $OSTIO_post"
5868 run_test 115 "verify dynamic thread creation===================="
5871 wait_delete_completed
5872 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
5873 echo OST kbytes available: ${AVAIL[@]}
5874 MAXI=0; MAXV=${AVAIL[0]}
5875 MINI=0; MINV=${AVAIL[0]}
5876 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
5877 #echo OST $i: ${AVAIL[i]}kb
5878 if [ ${AVAIL[i]} -gt $MAXV ]; then
5879 MAXV=${AVAIL[i]}; MAXI=$i
5881 if [ ${AVAIL[i]} -lt $MINV ]; then
5882 MINV=${AVAIL[i]}; MINI=$i
5885 echo Min free space: OST $MINI: $MINV
5886 echo Max free space: OST $MAXI: $MAXV
5890 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs" && return
5892 echo -n "Free space priority "
5893 lctl get_param -n lov.*-clilov-*.qos_prio_free
5896 [ $MINV -gt 960000 ] && skip "too much free space in OST$MINI, skip" &&\
5899 # generate uneven OSTs
5900 mkdir -p $DIR/$tdir/OST${MINI}
5903 echo "Filling 25% remaining space in OST${MINI} with ${FILL}Kb"
5904 $SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI}||error "setstripe failed"
5906 while [ $FILL -gt 0 ]; do
5908 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i bs=2M count=1 2>/dev/null
5909 FILL=$(($FILL - 2048))
5917 DIFF=$(($MAXV - $MINV))
5918 DIFF2=$(($DIFF * 100 / $MINV))
5919 echo -n "diff=${DIFF}=${DIFF2}% must be > 20% for QOS mode..."
5920 if [ $DIFF2 -gt 20 ]; then
5923 echo "failed - QOS mode won't be used"
5924 error_ignore "QOS imbalance criteria not met"
5928 MINI1=$MINI; MINV1=$MINV
5929 MAXI1=$MAXI; MAXV1=$MAXV
5931 # now fill using QOS
5932 echo writing a bunch of files to QOS-assigned OSTs
5933 $SETSTRIPE -c 1 $DIR/$tdir
5935 while [ $FILL -gt 0 ]; do
5937 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1024 count=200 2>/dev/null
5938 FILL=$(($FILL - 200))
5941 echo "wrote $i 200k files"
5945 echo "Note: free space may not be updated, so measurements might be off"
5947 DIFF2=$(($MAXV - $MINV))
5948 echo "free space delta: orig $DIFF final $DIFF2"
5949 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
5950 DIFF=$(($MINV1 - ${AVAIL[$MINI1]}))
5951 echo "Wrote $DIFF to smaller OST $MINI1"
5952 DIFF2=$(($MAXV1 - ${AVAIL[$MAXI1]}))
5953 echo "Wrote $DIFF2 to larger OST $MAXI1"
5954 [ $DIFF -gt 0 ] && echo "Wrote $(($DIFF2 * 100 / $DIFF - 100))% more data to larger OST $MAXI1"
5956 # Figure out which files were written where
5957 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
5958 awk '/'$MINI1': / {print $2; exit}')
5960 MINC=$($GETSTRIPE --obd $UUID $DIR/$tdir | wc -l)
5961 echo "$MINC files created on smaller OST $MINI1"
5962 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
5963 awk '/'$MAXI1': / {print $2; exit}')
5965 MAXC=$($GETSTRIPE --obd $UUID $DIR/$tdir | wc -l)
5966 echo "$MAXC files created on larger OST $MAXI1"
5967 [ $MINC -gt 0 ] && echo "Wrote $(($MAXC * 100 / $MINC - 100))% more files to larger OST $MAXI1"
5968 [ $MAXC -gt $MINC ] || error_ignore "stripe QOS didn't balance free space"
5972 run_test 116 "stripe QOS: free space balance ==================="
5974 test_117() # bug 10891
5976 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
5977 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
5978 lctl set_param fail_loc=0x21e
5979 > $DIR/$tfile || error "truncate failed"
5980 lctl set_param fail_loc=0
5981 echo "Truncate succeeded."
5984 run_test 117 "verify fsfilt_extend =========="
5986 export OLD_RESENDCOUNT=""
5987 set_resend_count () {
5988 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
5989 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -1)
5990 lctl set_param -n $PROC_RESENDCOUNT $1
5991 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
5994 [ "$SLOW" = "no" ] && set_resend_count 4 # for reduce test_118* time (bug 14842)
5996 # Reset async IO behavior after error case
5998 FILE=$DIR/reset_async
6000 # Ensure all OSCs are cleared
6001 $SETSTRIPE -c -1 $FILE
6002 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
6007 test_118a() #bug 11710
6011 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6012 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6013 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
6015 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6016 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6021 run_test 118a "verify O_SYNC works =========="
6025 remote_ost_nodsh && skip "remote OST with nodsh" && return
6029 #define OBD_FAIL_OST_ENOENT 0x217
6030 set_nodes_failloc "$(osts_nodes)" 0x217
6031 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6033 set_nodes_failloc "$(osts_nodes)" 0
6034 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6035 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6038 if [[ $RC -eq 0 ]]; then
6039 error "Must return error due to dropped pages, rc=$RC"
6043 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6044 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6048 echo "Dirty pages not leaked on ENOENT"
6050 # Due to the above error the OSC will issue all RPCs syncronously
6051 # until a subsequent RPC completes successfully without error.
6052 $MULTIOP $DIR/$tfile Ow4096yc
6057 run_test 118b "Reclaim dirty pages on fatal error =========="
6061 remote_ost_nodsh && skip "remote OST with nodsh" && return
6065 #define OBD_FAIL_OST_EROFS 0x216
6066 set_nodes_failloc "$(osts_nodes)" 0x216
6068 # multiop should block due to fsync until pages are written
6069 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
6073 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
6074 error "Multiop failed to block on fsync, pid=$MULTIPID"
6077 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6079 if [[ $WRITEBACK -eq 0 ]]; then
6080 error "No page in writeback, writeback=$WRITEBACK"
6083 set_nodes_failloc "$(osts_nodes)" 0
6086 if [[ $RC -ne 0 ]]; then
6087 error "Multiop fsync failed, rc=$RC"
6090 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6091 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6093 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6094 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6098 echo "Dirty pages flushed via fsync on EROFS"
6101 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
6105 remote_ost_nodsh && skip "remote OST with nodsh" && return
6109 #define OBD_FAIL_OST_BRW_PAUSE_BULK
6110 set_nodes_failloc "$(osts_nodes)" 0x214
6111 # multiop should block due to fsync until pages are written
6112 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
6116 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
6117 error "Multiop failed to block on fsync, pid=$MULTIPID"
6120 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6122 if [[ $WRITEBACK -eq 0 ]]; then
6123 error "No page in writeback, writeback=$WRITEBACK"
6126 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
6127 set_nodes_failloc "$(osts_nodes)" 0
6129 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6130 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6132 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6133 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6137 echo "Dirty pages gaurenteed flushed via fsync"
6140 run_test 118d "Fsync validation inject a delay of the bulk =========="
6145 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
6146 lctl set_param fail_loc=0x8000040a
6148 # Should simulate EINVAL error which is fatal
6149 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6151 if [[ $RC -eq 0 ]]; then
6152 error "Must return error due to dropped pages, rc=$RC"
6155 lctl set_param fail_loc=0x0
6157 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6158 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6159 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6161 if [[ $LOCKED -ne 0 ]]; then
6162 error "Locked pages remain in cache, locked=$LOCKED"
6165 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6166 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6170 echo "No pages locked after fsync"
6175 run_test 118f "Simulate unrecoverable OSC side error =========="
6180 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
6181 lctl set_param fail_loc=0x406
6183 # simulate local -ENOMEM
6184 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6187 lctl set_param fail_loc=0
6188 if [[ $RC -eq 0 ]]; then
6189 error "Must return error due to dropped pages, rc=$RC"
6192 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6193 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6194 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6196 if [[ $LOCKED -ne 0 ]]; then
6197 error "Locked pages remain in cache, locked=$LOCKED"
6200 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6201 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6205 echo "No pages locked after fsync"
6210 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
6213 remote_ost_nodsh && skip "remote OST with nodsh" && return
6217 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
6218 set_nodes_failloc "$(osts_nodes)" 0x20e
6219 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
6220 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6223 set_nodes_failloc "$(osts_nodes)" 0
6224 if [[ $RC -eq 0 ]]; then
6225 error "Must return error due to dropped pages, rc=$RC"
6228 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6229 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6230 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6232 if [[ $LOCKED -ne 0 ]]; then
6233 error "Locked pages remain in cache, locked=$LOCKED"
6236 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6237 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6241 echo "No pages locked after fsync"
6245 run_test 118h "Verify timeout in handling recoverables errors =========="
6248 remote_ost_nodsh && skip "remote OST with nodsh" && return
6252 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
6253 set_nodes_failloc "$(osts_nodes)" 0x20e
6255 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
6256 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
6259 set_nodes_failloc "$(osts_nodes)" 0
6263 if [[ $RC -ne 0 ]]; then
6264 error "got error, but should be not, rc=$RC"
6267 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6268 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6269 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
6270 if [[ $LOCKED -ne 0 ]]; then
6271 error "Locked pages remain in cache, locked=$LOCKED"
6274 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6275 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6279 echo "No pages locked after fsync"
6283 run_test 118i "Fix error before timeout in recoverable error =========="
6286 remote_ost_nodsh && skip "remote OST with nodsh" && return
6290 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
6291 set_nodes_failloc "$(osts_nodes)" 0x220
6293 # return -EIO from OST
6294 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6296 set_nodes_failloc "$(osts_nodes)" 0x0
6297 if [[ $RC -eq 0 ]]; then
6298 error "Must return error due to dropped pages, rc=$RC"
6301 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6302 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6303 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
6304 if [[ $LOCKED -ne 0 ]]; then
6305 error "Locked pages remain in cache, locked=$LOCKED"
6308 # in recoverable error on OST we want resend and stay until it finished
6309 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6310 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6314 echo "No pages locked after fsync"
6318 run_test 118j "Simulate unrecoverable OST side error =========="
6322 remote_ost_nodsh && skip "remote OSTs with nodsh" && return
6324 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
6325 set_nodes_failloc "$(osts_nodes)" 0x20e
6328 for ((i=0;i<10;i++)); do
6329 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
6330 error "dd to $DIR/$tdir/$tfile-$i failed" )&
6337 set_nodes_failloc "$(osts_nodes)" 0
6340 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
6346 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
6349 run_test 118l "fsync dir ========="
6351 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
6353 test_119a() # bug 11737
6355 BSIZE=$((512 * 1024))
6356 directio write $DIR/$tfile 0 1 $BSIZE
6357 # We ask to read two blocks, which is more than a file size.
6358 # directio will indicate an error when requested and actual
6359 # sizes aren't equeal (a normal situation in this case) and
6360 # print actual read amount.
6361 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
6362 if [ "$NOB" != "$BSIZE" ]; then
6363 error "read $NOB bytes instead of $BSIZE"
6367 run_test 119a "Short directIO read must return actual read amount"
6369 test_119b() # bug 11737
6371 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
6373 $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
6374 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
6376 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) || \
6377 error "direct read failed"
6380 run_test 119b "Sparse directIO read must return actual read amount"
6382 test_119c() # bug 13099
6385 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
6386 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
6389 run_test 119c "Testing for direct read hitting hole"
6391 test_119d() # bug 15950
6393 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
6394 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
6396 $SETSTRIPE $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
6397 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
6398 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
6399 lctl set_param fail_loc=0x40d
6400 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
6403 cat $DIR/$tfile > /dev/null &
6404 lctl set_param fail_loc=0
6407 log "the DIO writes have completed, now wait for the reads (should not block very long)"
6409 [ -n "`ps h -p $pid_reads -o comm`" ] && \
6410 error "the read rpcs have not completed in 2s"
6412 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
6414 run_test 119d "The DIO path should try to send a new rpc once one is completed"
6418 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6419 skip "no early lock cancel on server" && return 0
6420 lru_resize_disable mdc
6421 lru_resize_disable osc
6422 cancel_lru_locks mdc
6423 stat $DIR/$tdir > /dev/null
6424 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6425 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6427 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6428 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6429 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6430 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6431 lru_resize_enable mdc
6432 lru_resize_enable osc
6434 run_test 120a "Early Lock Cancel: mkdir test"
6438 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6439 skip "no early lock cancel on server" && return 0
6440 lru_resize_disable mdc
6441 lru_resize_disable osc
6442 cancel_lru_locks mdc
6443 stat $DIR/$tdir > /dev/null
6444 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6445 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6447 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6448 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6449 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6450 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6451 lru_resize_enable mdc
6452 lru_resize_enable osc
6454 run_test 120b "Early Lock Cancel: create test"
6458 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6459 skip "no early lock cancel on server" && return 0
6460 lru_resize_disable mdc
6461 lru_resize_disable osc
6462 mkdir -p $DIR/$tdir/d1 $DIR/$tdir/d2
6463 touch $DIR/$tdir/d1/f1
6464 cancel_lru_locks mdc
6465 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
6466 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6467 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6468 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
6469 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6470 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6471 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6472 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6473 lru_resize_enable mdc
6474 lru_resize_enable osc
6476 run_test 120c "Early Lock Cancel: link test"
6480 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6481 skip "no early lock cancel on server" && return 0
6482 lru_resize_disable mdc
6483 lru_resize_disable osc
6485 cancel_lru_locks mdc
6486 stat $DIR/$tdir > /dev/null
6487 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6488 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6489 chmod a+x $DIR/$tdir
6490 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6491 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6492 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6493 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6494 lru_resize_enable mdc
6495 lru_resize_enable osc
6497 run_test 120d "Early Lock Cancel: setattr test"
6501 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6502 skip "no early lock cancel on server" && return 0
6503 lru_resize_disable mdc
6504 lru_resize_disable osc
6505 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
6506 cancel_lru_locks mdc
6507 cancel_lru_locks osc
6508 dd if=$DIR/$tdir/f1 of=/dev/null
6509 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
6510 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6511 awk '/ldlm_cancel/ {print $2}'`
6512 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6513 awk '/ldlm_bl_callback/ {print $2}'`
6514 unlink $DIR/$tdir/f1
6515 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6516 awk '/ldlm_cancel/ {print $2}'`
6517 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6518 awk '/ldlm_bl_callback/ {print $2}'`
6519 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6520 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6521 lru_resize_enable mdc
6522 lru_resize_enable osc
6524 run_test 120e "Early Lock Cancel: unlink test"
6527 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6528 skip "no early lock cancel on server" && return 0
6530 lru_resize_disable mdc
6531 lru_resize_disable osc
6532 mkdir -p $DIR/$tdir/d1 $DIR/$tdir/d2
6533 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
6534 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
6535 cancel_lru_locks mdc
6536 cancel_lru_locks osc
6537 dd if=$DIR/$tdir/d1/f1 of=/dev/null
6538 dd if=$DIR/$tdir/d2/f2 of=/dev/null
6539 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
6540 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6541 awk '/ldlm_cancel/ {print $2}'`
6542 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6543 awk '/ldlm_bl_callback/ {print $2}'`
6544 mv $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
6545 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6546 awk '/ldlm_cancel/ {print $2}'`
6547 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6548 awk '/ldlm_bl_callback/ {print $2}'`
6549 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6550 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6551 lru_resize_enable mdc
6552 lru_resize_enable osc
6554 run_test 120f "Early Lock Cancel: rename test"
6557 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6558 skip "no early lock cancel on server" && return 0
6559 lru_resize_disable mdc
6560 lru_resize_disable osc
6562 echo create $count files
6564 cancel_lru_locks mdc
6565 cancel_lru_locks osc
6568 can0=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6569 awk '/ldlm_cancel/ {print $2}'`
6570 blk0=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6571 awk '/ldlm_bl_callback/ {print $2}'`
6572 createmany -o $DIR/$tdir/f $count
6574 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6575 awk '/ldlm_cancel/ {print $2}'`
6576 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6577 awk '/ldlm_bl_callback/ {print $2}'`
6579 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
6580 echo rm $count files
6583 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6584 awk '/ldlm_cancel/ {print $2}'`
6585 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6586 awk '/ldlm_bl_callback/ {print $2}'`
6588 echo total: $count removes in $((t2-t1))
6589 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
6591 # wait for commitment of removal
6592 lru_resize_enable mdc
6593 lru_resize_enable osc
6595 run_test 120g "Early Lock Cancel: performance test"
6597 test_121() { #bug #10589
6599 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
6600 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
6601 lctl set_param fail_loc=0x310
6602 cancel_lru_locks osc > /dev/null
6603 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
6604 lctl set_param fail_loc=0
6605 [ "$reads" -eq "$writes" ] || error "read" $reads "blocks, must be" $writes
6607 run_test 121 "read cancel race ========="
6609 test_123a() { # was test 123, statahead(bug 11401)
6611 if [ -z "$(grep "processor.*: 1" /proc/cpuinfo)" ]; then
6612 log "testing on UP system. Performance may be not as good as expected."
6618 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
6619 [ $NUMFREE -gt 100000 ] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
6621 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
6622 createmany -o $DIR/$tdir/$tfile $j $((i - j))
6624 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
6625 lctl set_param -n llite.*.statahead_max 0
6626 lctl get_param llite.*.statahead_max
6627 cancel_lru_locks mdc
6628 cancel_lru_locks osc
6630 time ls -l $DIR/$tdir | wc -l
6632 delta=$((etime - stime))
6633 log "ls $i files without statahead: $delta sec"
6634 lctl set_param llite.*.statahead_max=$max
6636 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
6637 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
6638 cancel_lru_locks mdc
6639 cancel_lru_locks osc
6641 time ls -l $DIR/$tdir | wc -l
6643 delta_sa=$((etime - stime))
6644 log "ls $i files with statahead: $delta_sa sec"
6645 lctl get_param -n llite.*.statahead_stats
6646 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
6648 [ $swrong -lt $ewrong ] && log "statahead was stopped, maybe too many locks held!"
6649 [ $delta -eq 0 -o $delta_sa -eq 0 ] && continue
6651 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
6652 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
6653 lctl set_param -n llite.*.statahead_max 0
6654 lctl get_param llite.*.statahead_max
6655 cancel_lru_locks mdc
6656 cancel_lru_locks osc
6658 time ls -l $DIR/$tdir | wc -l
6660 delta=$((etime - stime))
6661 log "ls $i files again without statahead: $delta sec"
6662 lctl set_param llite.*.statahead_max=$max
6663 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
6664 if [ $SLOWOK -eq 0 ]; then
6665 error "ls $i files is slower with statahead!"
6667 log "ls $i files is slower with statahead!"
6673 [ $delta -gt 20 ] && break
6674 [ $delta -gt 8 ] && MULT=$((50 / delta))
6675 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
6683 delta=$((etime - stime))
6684 log "rm -r $DIR/$tdir/: $delta seconds"
6686 lctl get_param -n llite.*.statahead_stats
6688 run_test 123a "verify statahead work"
6690 test_123b () { # statahead(bug 15027)
6692 createmany -o $DIR/$tdir/$tfile-%d 1000
6694 cancel_lru_locks mdc
6695 cancel_lru_locks osc
6697 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
6698 lctl set_param fail_loc=0x80000803
6699 ls -lR $DIR/$tdir > /dev/null
6701 lctl set_param fail_loc=0x0
6702 lctl get_param -n llite.*.statahead_stats
6707 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
6710 [ -z "`lctl get_param -n mdc.*.connect_flags | grep lru_resize`" ] && \
6711 skip "no lru resize on server" && return 0
6713 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
6715 log "create $NR files at $DIR/$tdir"
6716 createmany -o $DIR/$tdir/f $NR ||
6717 error "failed to create $NR files in $DIR/$tdir"
6719 cancel_lru_locks mdc
6720 ls -l $DIR/$tdir > /dev/null
6724 for VALUE in `lctl get_param ldlm.namespaces.*mdc-*.lru_size`; do
6725 local PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
6726 LRU_SIZE=$(lctl get_param -n $PARAM)
6727 if [ $LRU_SIZE -gt $(default_lru_size) ]; then
6728 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
6730 log "NS=$(basename $NSDIR)"
6735 if [ -z "$NSDIR" -o $LRU_SIZE -lt $(default_lru_size) ]; then
6736 skip "Not enough cached locks created!"
6743 # We know that lru resize allows one client to hold $LIMIT locks
6744 # for 10h. After that locks begin to be killed by client.
6746 local LIMIT=`lctl get_param -n $NSDIR.pool.limit`
6749 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
6750 # killing locks. Some time was spent for creating locks. This means
6751 # that up to the moment of sleep finish we must have killed some of
6752 # them (10-100 locks). This depends on how fast ther were created.
6753 # Many of them were touched in almost the same moment and thus will
6754 # be killed in groups.
6755 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
6757 # Use $LRU_SIZE_B here to take into account real number of locks
6758 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
6759 local LRU_SIZE_B=$LRU_SIZE
6761 local OLD_LVF=`lctl get_param -n $NSDIR.pool.lock_volume_factor`
6762 log "OLD_LVF=$OLD_LVF"
6763 lctl set_param -n $NSDIR.pool.lock_volume_factor $LVF
6765 # Let's make sure that we really have some margin. Client checks
6766 # cached locks every 10 sec.
6768 log "Sleep ${SLEEP} sec"
6770 while ((SEC<$SLEEP)); do
6774 LRU_SIZE=`lctl get_param -n $NSDIR/lru_size`
6778 lctl set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
6779 local LRU_SIZE_A=`lctl get_param -n $NSDIR.lru_size`
6781 [ $LRU_SIZE_B -gt $LRU_SIZE_A ] || {
6782 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
6783 unlinkmany $DIR/$tdir/f $NR
6787 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
6788 log "unlink $NR files at $DIR/$tdir"
6789 unlinkmany $DIR/$tdir/f $NR
6791 run_test 124a "lru resize ======================================="
6793 get_max_pool_limit()
6795 local limit=`lctl get_param -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit`
6798 if test $l -gt $max; then
6806 [ -z "`lctl get_param -n mdc.*.connect_flags | grep lru_resize`" ] && \
6807 skip "no lru resize on server" && return 0
6809 LIMIT=`get_max_pool_limit`
6811 NR=$(($(default_lru_size)*20))
6812 if [ $NR -gt $LIMIT ]; then
6813 log "Limit lock number by $LIMIT locks"
6816 lru_resize_disable mdc
6817 mkdir -p $DIR/$tdir/disable_lru_resize ||
6818 error "failed to create $DIR/$tdir/disable_lru_resize"
6820 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
6821 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
6822 cancel_lru_locks mdc
6825 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
6828 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
6831 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
6835 nolruresize_delta=$((etime-stime))
6836 log "ls -la time: $nolruresize_delta seconds"
6837 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
6838 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
6840 lru_resize_enable mdc
6841 mkdir -p $DIR/$tdir/enable_lru_resize ||
6842 error "failed to create $DIR/$tdir/enable_lru_resize"
6844 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
6845 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
6846 cancel_lru_locks mdc
6849 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
6852 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
6855 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
6859 lruresize_delta=$((etime-stime))
6860 log "ls -la time: $lruresize_delta seconds"
6861 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
6863 if [ $lruresize_delta -gt $nolruresize_delta ]; then
6864 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
6865 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
6866 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
6868 log "lru resize performs the same with no lru resize"
6870 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
6872 run_test 124b "lru resize (performance test) ======================="
6874 test_125() { # 13358
6875 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
6876 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
6877 mkdir -p $DIR/d125 || error "mkdir failed"
6878 $SETSTRIPE -S 65536 -c -1 $DIR/d125 || error "setstripe failed"
6879 setfacl -R -m u:bin:rwx $DIR/d125 || error "setfacl $DIR/d125 failed"
6880 ls -ld $DIR/d125 || error "cannot access $DIR/d125"
6882 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
6884 test_126() { # bug 12829/13455
6885 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
6886 [ "$UID" != 0 ] && skip_env "skipping $TESTNAME (must run as root)" && return
6887 $GSS && skip "must run as gss disabled" && return
6889 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
6890 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
6892 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
6894 run_test 126 "check that the fsgid provided by the client is taken into account"
6896 test_127a() { # bug 15521
6897 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
6898 $LCTL set_param osc.*.stats=0
6899 FSIZE=$((2048 * 1024))
6900 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
6901 cancel_lru_locks osc
6902 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
6904 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
6905 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
6906 echo "got $COUNT $NAME"
6907 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
6908 eval $NAME=$COUNT || error "Wrong proc format"
6911 read_bytes|write_bytes)
6912 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
6913 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
6914 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
6915 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
6916 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
6917 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
6918 error "sumsquare is too small: $SUMSQ"
6919 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
6920 error "sumsquare is too big: $SUMSQ"
6924 done < $DIR/${tfile}.tmp
6926 #check that we actually got some stats
6927 [ "$read_bytes" ] || error "Missing read_bytes stats"
6928 [ "$write_bytes" ] || error "Missing write_bytes stats"
6929 [ "$read_bytes" != 0 ] || error "no read done"
6930 [ "$write_bytes" != 0 ] || error "no write done"
6932 run_test 127a "verify the client stats are sane"
6934 test_127b() { # bug LU-333
6935 $LCTL set_param llite.*.stats=0
6936 FSIZE=65536 # sized fixed to match PAGE_SIZE for most clients
6937 # perform 2 reads and writes so MAX is different from SUM.
6938 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
6939 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
6940 cancel_lru_locks osc
6941 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
6942 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
6944 $LCTL get_param llite.*.stats | grep samples > $TMP/${tfile}.tmp
6945 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
6946 echo "got $COUNT $NAME"
6947 eval $NAME=$COUNT || error "Wrong proc format"
6951 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
6952 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
6953 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
6954 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
6957 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
6958 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
6959 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
6960 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
6964 done < $TMP/${tfile}.tmp
6966 #check that we actually got some stats
6967 [ "$read_bytes" ] || error "Missing read_bytes stats"
6968 [ "$write_bytes" ] || error "Missing write_bytes stats"
6969 [ "$read_bytes" != 0 ] || error "no read done"
6970 [ "$write_bytes" != 0 ] || error "no write done"
6972 run_test 127b "verify the llite client stats are sane"
6974 test_128() { # bug 15212
6976 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
6981 result=$(grep error $TMP/$tfile.log)
6983 [ -z "$result" ] || error "consecutive find's under interactive lfs failed"
6985 run_test 128 "interactive lfs for 2 consecutive find's"
6992 local LDPROC=/proc/fs/ldiskfs
6994 for facet in $(get_facets MDS); do
6995 canondev=$(ldiskfs_canon *.$(convert_facet2label $facet).mntdev $facet)
6996 do_facet $facet "test -e $LDPROC/$canondev/max_dir_size" || LDPROC=/sys/fs/ldiskfs
6997 do_facet $facet "echo $1 >$LDPROC/$canondev/max_dir_size"
7001 if [ "$(facet_type_fstype MDS)" != ldiskfs ]; then
7002 skip "Only applicable to ldiskfs-based MDTs"
7005 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7016 while [ ! $I -gt $((MAX * MDSCOUNT)) ]; do
7017 $MULTIOP $DIR/$tdir/$J Oc
7019 if [ $rc -eq $EFBIG ]; then
7021 echo "return code $rc received as expected"
7023 elif [ $rc -ne 0 ]; then
7025 error_exit "return code $rc received instead of expected $EFBIG"
7028 I=$(stat -c%s "$DIR/$tdir")
7032 error "exceeded dir size limit $MAX x $MDSCOUNT $((MAX * MDSCOUNT)) : $I bytes"
7034 run_test 129 "test directory size limit ========================"
7043 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7044 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
7047 trap cleanup_130 EXIT RETURN
7049 local fm_file=$DIR/$tfile
7050 $SETSTRIPE -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
7051 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
7052 error "dd failed for $fm_file"
7054 # LU-1795: test filefrag/FIEMAP once, even if unsupported
7055 filefrag -ves $fm_file
7057 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
7058 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
7059 [ $RC != 0 ] && error "filefrag $fm_file failed"
7061 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
7062 grep -v "ext:" | grep -v "found")
7063 lun=$($GETSTRIPE -i $fm_file)
7065 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
7068 for line in $filefrag_op
7070 frag_lun=`echo $line | cut -d: -f5`
7071 ext_len=`echo $line | cut -d: -f4`
7072 if (( $frag_lun != $lun )); then
7074 error "FIEMAP on 1-stripe file($fm_file) failed"
7077 (( tot_len += ext_len ))
7080 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
7082 error "FIEMAP on 1-stripe file($fm_file) failed;"
7088 echo "FIEMAP on single striped file succeeded"
7090 run_test 130a "FIEMAP (1-stripe file)"
7093 [ "$OSTCOUNT" -lt "2" ] &&
7094 skip_env "skipping FIEMAP on 2-stripe file test" && return
7096 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7097 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
7100 trap cleanup_130 EXIT RETURN
7102 local fm_file=$DIR/$tfile
7103 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
7104 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
7105 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
7107 dd if=/dev/zero of=$fm_file bs=1M count=2 ||
7108 error "dd failed on $fm_file"
7110 filefrag -ves $fm_file || error "filefrag $fm_file failed"
7111 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
7112 grep -v "ext:" | grep -v "found")
7114 last_lun=$(echo $filefrag_op | cut -d: -f5)
7119 for line in $filefrag_op
7121 frag_lun=`echo $line | cut -d: -f5`
7122 ext_len=`echo $line | cut -d: -f4`
7123 if (( $frag_lun != $last_lun )); then
7124 if (( tot_len != 1024 )); then
7126 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 256"
7133 (( tot_len += ext_len ))
7136 if (( num_luns != 2 || tot_len != 1024 )); then
7138 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
7144 echo "FIEMAP on 2-stripe file succeeded"
7146 run_test 130b "FIEMAP (2-stripe file)"
7149 [ "$OSTCOUNT" -lt "2" ] &&
7150 skip_env "skipping FIEMAP on 2-stripe file" && return
7152 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7153 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
7156 trap cleanup_130 EXIT RETURN
7158 local fm_file=$DIR/$tfile
7159 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
7160 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
7161 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
7163 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 || error "dd failed on $fm_file"
7165 filefrag -ves $fm_file || error "filefrag $fm_file failed"
7166 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
7168 last_lun=`echo $filefrag_op | cut -d: -f5`
7173 for line in $filefrag_op
7175 frag_lun=`echo $line | cut -d: -f5`
7176 ext_len=`echo $line | cut -d: -f4`
7177 if (( $frag_lun != $last_lun )); then
7178 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
7179 if (( logical != 512 )); then
7181 error "FIEMAP on $fm_file failed; returned logical start for lun $logical instead of 512"
7184 if (( tot_len != 512 )); then
7186 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
7193 (( tot_len += ext_len ))
7196 if (( num_luns != 2 || tot_len != 512 )); then
7198 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
7204 echo "FIEMAP on 2-stripe file with hole succeeded"
7206 run_test 130c "FIEMAP (2-stripe file with hole)"
7209 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping FIEMAP on N-stripe file test" && return
7211 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7212 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
7214 trap cleanup_130 EXIT RETURN
7216 local fm_file=$DIR/$tfile
7217 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file||error "setstripe on $fm_file"
7218 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
7219 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
7220 dd if=/dev/zero of=$fm_file bs=1M count=$OSTCOUNT || error "dd failed on $fm_file"
7222 filefrag -ves $fm_file || error "filefrag $fm_file failed"
7223 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
7225 last_lun=`echo $filefrag_op | cut -d: -f5`
7230 for line in $filefrag_op
7232 frag_lun=`echo $line | cut -d: -f5`
7233 ext_len=`echo $line | cut -d: -f4`
7234 if (( $frag_lun != $last_lun )); then
7235 if (( tot_len != 1024 )); then
7237 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
7244 (( tot_len += ext_len ))
7247 if (( num_luns != OSTCOUNT || tot_len != 1024 )); then
7249 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
7255 echo "FIEMAP on N-stripe file succeeded"
7257 run_test 130d "FIEMAP (N-stripe file)"
7260 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping continuation FIEMAP test" && return
7262 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7263 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
7265 trap cleanup_130 EXIT RETURN
7267 local fm_file=$DIR/$tfile
7268 $SETSTRIPE -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
7269 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
7270 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
7273 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
7274 for ((i = 0; i < $NUM_BLKS; i++))
7276 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
7279 filefrag -ves $fm_file || error "filefrag $fm_file failed"
7280 filefrag_op=`filefrag -ve $fm_file | grep -A 12000 "ext:" | grep -v "ext:" | grep -v "found"`
7282 last_lun=`echo $filefrag_op | cut -d: -f5`
7287 for line in $filefrag_op
7289 frag_lun=`echo $line | cut -d: -f5`
7290 ext_len=`echo $line | cut -d: -f4`
7291 if (( $frag_lun != $last_lun )); then
7292 if (( tot_len != $EXPECTED_LEN )); then
7294 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of $EXPECTED_LEN"
7301 (( tot_len += ext_len ))
7304 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
7306 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
7312 echo "FIEMAP with continuation calls succeeded"
7314 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
7316 # Test for writev/readv
7318 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 || \
7319 error "writev test failed"
7320 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 || \
7321 error "readv failed"
7324 run_test 131a "test iov's crossing stripe boundary for writev/readv"
7327 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 || \
7328 error "append writev test failed"
7329 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 || \
7330 error "append writev test failed"
7333 run_test 131b "test append writev"
7336 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
7339 run_test 131c "test read/write on file w/o objects"
7342 rwv -f $DIR/$tfile -w -n 1 1572864
7343 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
7344 if [ "$NOB" != 1572864 ]; then
7345 error "Short read filed: read $NOB bytes instead of 1572864"
7349 run_test 131d "test short read"
7352 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
7353 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
7354 error "read hitting hole failed"
7357 run_test 131e "test read hitting hole"
7362 for node in $(osts_nodes); do
7363 gl=$(do_node $node "$LCTL get_param -n ost.OSS.ost.stats" | awk '/'$token'/ {print $2}' | head -n 1)
7364 [ x$gl = x"" ] && gl=0
7365 gl_sum=$((gl_sum + gl))
7375 if [ x$som = x"enabled" ]; then
7376 [ $((gl2 - gl1)) -gt 0 ] && error "no glimpse RPC is expected"
7377 MOUNTOPT=`echo $MOUNTOPT | sed 's/som_preview//g'`
7378 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=disabled"
7380 [ $((gl2 - gl1)) -gt 0 ] || error "some glimpse RPC is expected"
7381 MOUNTOPT="$MOUNTOPT,som_preview"
7382 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=enabled"
7385 # do remount to make new mount-conf parameters actual
7392 test_132() { #1028, SOM
7393 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7394 local num=$(get_mds_dir $DIR)
7395 local mymds=mds${num}
7396 local MOUNTOPT_SAVE=$MOUNTOPT
7398 dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
7399 cancel_lru_locks osc
7401 som1=$(do_facet $mymds "$LCTL get_param mdt.*.som" | awk -F= ' {print $2}' | head -n 1)
7403 gl1=$(get_ost_param "ldlm_glimpse_enqueue")
7404 stat $DIR/$tfile >/dev/null
7405 gl2=$(get_ost_param "ldlm_glimpse_enqueue")
7406 echo "====> SOM is "$som1", "$((gl2 - gl1))" glimpse RPC occured"
7408 som_mode_switch $som1 $gl1 $gl2
7410 dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
7411 cancel_lru_locks osc
7413 som2=$(do_facet $mymds "$LCTL get_param mdt.*.som" | awk -F= ' {print $2}' | head -n 1)
7414 if [ $som1 == $som2 ]; then
7415 error "som is still "$som2
7416 if [ x$som2 = x"enabled" ]; then
7423 gl1=$(get_ost_param "ldlm_glimpse_enqueue")
7424 stat $DIR/$tfile >/dev/null
7425 gl2=$(get_ost_param "ldlm_glimpse_enqueue")
7426 echo "====> SOM is "$som2", "$((gl2 - gl1))" glimpse RPC occured"
7427 som_mode_switch $som2 $gl1 $gl2
7428 MOUNTOPT=$MOUNTOPT_SAVE
7430 run_test 132 "som avoids glimpse rpc"
7436 $SINGLEMDS) res=`do_facet $SINGLEMDS $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$2"`
7438 ost) res=`do_facet ost1 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$2"`
7440 *) error "Wrong argument $1" ;;
7443 count=`echo $res | awk '{print $2}'`
7444 [ -z "$res" ] && error "The counter for $2 on $1 was not incremented"
7445 # if the argument $3 is zero, it means any stat increment is ok.
7446 if [ $3 -gt 0 ] ; then
7447 [ $count -ne $3 ] && error "The $2 counter on $1 is wrong - expected $3"
7452 remote_ost_nodsh && skip "remote OST with nodsh" && return
7453 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7455 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
7456 { skip "MDS doesn't support rename stats"; return; }
7457 local testdir=$DIR/${tdir}/stats_testdir
7458 mkdir -p $DIR/${tdir}
7461 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
7462 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
7464 # verify mdt stats first.
7465 mkdir ${testdir} || error "mkdir failed"
7466 check_stats $SINGLEMDS "mkdir" 1
7467 touch ${testdir}/${tfile} || "touch failed"
7468 check_stats $SINGLEMDS "open" 1
7469 check_stats $SINGLEMDS "close" 1
7470 mknod ${testdir}/${tfile}-pipe p || "mknod failed"
7471 check_stats $SINGLEMDS "mknod" 1
7472 rm -f ${testdir}/${tfile}-pipe || "pipe remove failed"
7473 check_stats $SINGLEMDS "unlink" 1
7474 rm -f ${testdir}/${tfile} || error "file remove failed"
7475 check_stats $SINGLEMDS "unlink" 2
7477 # remove working dir and check mdt stats again.
7478 rmdir ${testdir} || error "rmdir failed"
7479 check_stats $SINGLEMDS "rmdir" 1
7481 local testdir1=$DIR/${tdir}/stats_testdir1
7483 mkdir -p ${testdir1}
7484 touch ${testdir1}/test1
7485 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
7486 check_stats $SINGLEMDS "crossdir_rename" 1
7488 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
7489 check_stats $SINGLEMDS "samedir_rename" 1
7493 run_test 133a "Verifying MDT stats ========================================"
7496 remote_ost_nodsh && skip "remote OST with nodsh" && return
7497 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7498 local testdir=$DIR/${tdir}/stats_testdir
7499 mkdir -p ${testdir} || error "mkdir failed"
7500 touch ${testdir}/${tfile} || "touch failed"
7501 cancel_lru_locks mdc
7504 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
7505 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
7507 # extra mdt stats verification.
7508 chmod 444 ${testdir}/${tfile} || error "chmod failed"
7509 check_stats $SINGLEMDS "setattr" 1
7510 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
7511 if [ $(lustre_version_code $SINGLEMDS) -ne $(version_code 2.2.0) ]
7513 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
7514 check_stats $SINGLEMDS "getattr" 1
7516 $LFS df || error "lfs failed"
7517 check_stats $SINGLEMDS "statfs" 1
7521 run_test 133b "Verifying extra MDT stats =================================="
7524 remote_ost_nodsh && skip "remote OST with nodsh" && return
7525 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7526 local testdir=$DIR/${tdir}/stats_testdir
7527 mkdir -p ${testdir} || error "mkdir failed"
7529 # verify obdfilter stats.
7530 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
7532 cancel_lru_locks osc
7535 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
7536 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
7538 dd if=/dev/zero of=${testdir}/${tfile} conv=notrunc bs=512k count=1 || error "dd failed"
7540 cancel_lru_locks osc
7541 check_stats ost "write" 1
7543 dd if=${testdir}/${tfile} of=/dev/null bs=1k count=1 || error "dd failed"
7544 check_stats ost "read" 1
7546 > ${testdir}/${tfile} || error "truncate failed"
7547 check_stats ost "punch" 1
7549 rm -f ${testdir}/${tfile} || error "file remove failed"
7550 check_stats ost "destroy" 1
7554 run_test 133c "Verifying OST stats ========================================"
7561 while [ $value -ge 2 ]; do
7566 if [ $orig -gt $order ]; then
7574 local size=('K' 'M' 'G' 'T');
7576 local size_string=$value
7578 while [ $value -ge 1024 ]; do
7579 if [ $i -gt 3 ]; then
7580 #T is the biggest unit we get here, if that is bigger,
7582 size_string=${value}T
7585 value=$((value >> 10))
7586 if [ $value -lt 1024 ]; then
7587 size_string=${value}${size[$i]}
7598 local sample=$(do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats |
7599 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
7604 remote_ost_nodsh && skip "remote OST with nodsh" && return
7605 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7606 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
7607 { skip "MDS doesn't support rename stats"; return; }
7609 local testdir1=$DIR/${tdir}/stats_testdir1
7610 local testdir2=$DIR/${tdir}/stats_testdir2
7612 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
7614 mkdir -p ${testdir1} || error "mkdir failed"
7615 mkdir -p ${testdir2} || error "mkdir failed"
7617 createmany -o $testdir1/test 512 || error "createmany failed"
7619 # check samedir rename size
7620 mv ${testdir1}/test0 ${testdir1}/test_0
7622 local testdir1_size=$(ls -l $DIR/${tdir} |
7623 awk '/stats_testdir1/ {print $5}')
7624 local testdir2_size=$(ls -l $DIR/${tdir} |
7625 awk '/stats_testdir2/ {print $5}')
7627 testdir1_size=$(order_2 $testdir1_size)
7628 testdir2_size=$(order_2 $testdir2_size)
7630 testdir1_size=$(size_in_KMGT $testdir1_size)
7631 testdir2_size=$(size_in_KMGT $testdir2_size)
7633 echo "source rename dir size: ${testdir1_size}"
7634 echo "target rename dir size: ${testdir2_size}"
7636 local cmd="do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats"
7637 eval $cmd || error "$cmd failed"
7638 local samedir=$($cmd | grep 'same_dir')
7639 local same_sample=$(get_rename_size $testdir1_size)
7640 [ -z "$samedir" ] && error "samedir_rename_size count error"
7641 [ "$same_sample" -eq 1 ] || error "samedir_rename_size error $same_sample"
7642 echo "Check same dir rename stats success"
7644 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
7646 # check crossdir rename size
7647 mv ${testdir1}/test_0 ${testdir2}/test_0
7649 testdir1_size=$(ls -l $DIR/${tdir} |
7650 awk '/stats_testdir1/ {print $5}')
7651 testdir2_size=$(ls -l $DIR/${tdir} |
7652 awk '/stats_testdir2/ {print $5}')
7654 testdir1_size=$(order_2 $testdir1_size)
7655 testdir2_size=$(order_2 $testdir2_size)
7657 testdir1_size=$(size_in_KMGT $testdir1_size)
7658 testdir2_size=$(size_in_KMGT $testdir2_size)
7660 echo "source rename dir size: ${testdir1_size}"
7661 echo "target rename dir size: ${testdir2_size}"
7663 eval $cmd || error "$cmd failed"
7664 local crossdir=$($cmd | grep 'crossdir')
7665 local src_sample=$(get_rename_size $testdir1_size)
7666 local tgt_sample=$(get_rename_size $testdir2_size)
7667 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
7668 [ "$src_sample" -eq 1 ] || error "crossdir_rename_size error $src_sample"
7669 [ "$tgt_sample" -eq 1 ] || error "crossdir_rename_size error $tgt_sample"
7670 echo "Check cross dir rename stats success"
7673 run_test 133d "Verifying rename_stats ========================================"
7675 test_140() { #bug-17379
7676 mkdir -p $DIR/$tdir || error "Creating dir $DIR/$tdir"
7677 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
7678 cp /usr/bin/stat . || error "Copying stat to $DIR/$tdir"
7680 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
7682 while i=`expr $i + 1`; do
7683 mkdir -p $i || error "Creating dir $i"
7684 cd $i || error "Changing to $i"
7685 ln -s ../stat stat || error "Creating stat symlink"
7686 # Read the symlink until ELOOP present,
7687 # not LBUGing the system is considered success,
7688 # we didn't overrun the stack.
7689 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
7691 if [ $ret -eq 40 ]; then
7694 error "Open stat symlink"
7700 echo "The symlink depth = $i"
7701 [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 ] || error "Invalid symlink depth"
7703 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
7706 local TF="$TMP/$tfile"
7708 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
7710 cancel_lru_locks osc
7711 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
7712 remount_client $MOUNT
7714 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
7717 $TRUNCATE $DIR/$tfile 6000
7718 cancel_lru_locks osc
7719 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
7722 echo "12345" >>$DIR/$tfile
7723 cancel_lru_locks osc
7724 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
7727 echo "12345" >>$DIR/$tfile
7728 cancel_lru_locks osc
7729 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
7734 run_test 150 "truncate/append tests"
7736 function roc_hit() {
7737 local list=$(comma_list $(osts_nodes))
7739 echo $(get_obdfilter_param $list '' stats |
7740 awk '/'cache_hit'/ {sum+=$2} END {print sum}')
7743 function set_cache() {
7746 if [ "$2" == "off" ]; then
7749 local list=$(comma_list $(osts_nodes))
7750 set_obdfilter_param $list '' $1_cache_enable $on
7752 cancel_lru_locks osc
7756 remote_ost_nodsh && skip "remote OST with nodsh" && return
7759 local list=$(comma_list $(osts_nodes))
7761 # check whether obdfilter is cache capable at all
7762 if ! get_obdfilter_param $list '' read_cache_enable >/dev/null; then
7763 echo "not cache-capable obdfilter"
7767 # check cache is enabled on all obdfilters
7768 if get_obdfilter_param $list '' read_cache_enable | grep 0; then
7769 echo "oss cache is disabled"
7773 set_obdfilter_param $list '' writethrough_cache_enable 1
7775 # pages should be in the case right after write
7776 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES || error "dd failed"
7777 local BEFORE=`roc_hit`
7778 cancel_lru_locks osc
7779 cat $DIR/$tfile >/dev/null
7780 local AFTER=`roc_hit`
7781 if ! let "AFTER - BEFORE == CPAGES"; then
7782 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
7785 # the following read invalidates the cache
7786 cancel_lru_locks osc
7787 set_obdfilter_param $list '' read_cache_enable 0
7788 cat $DIR/$tfile >/dev/null
7790 # now data shouldn't be found in the cache
7792 cancel_lru_locks osc
7793 cat $DIR/$tfile >/dev/null
7795 if let "AFTER - BEFORE != 0"; then
7796 error "IN CACHE: before: $BEFORE, after: $AFTER"
7799 set_obdfilter_param $list '' read_cache_enable 1
7802 run_test 151 "test cache on oss and controls ==============================="
7805 local TF="$TMP/$tfile"
7807 # simulate ENOMEM during write
7808 #define OBD_FAIL_OST_NOMEM 0x226
7809 lctl set_param fail_loc=0x80000226
7810 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
7812 sync || error "sync failed"
7813 lctl set_param fail_loc=0
7815 # discard client's cache
7816 cancel_lru_locks osc
7818 # simulate ENOMEM during read
7819 lctl set_param fail_loc=0x80000226
7820 cmp $TF $DIR/$tfile || error "cmp failed"
7821 lctl set_param fail_loc=0
7825 run_test 152 "test read/write with enomem ============================"
7828 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
7830 run_test 153 "test if fdatasync does not crash ======================="
7833 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
7834 { skip "Need MDS version at least 2.2.51"; return 0; }
7836 cp /etc/hosts $DIR/$tfile
7838 fid=$($LFS path2fid $DIR/$tfile)
7840 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
7842 ffid=$DIR/.lustre/fid/$fid
7844 echo "stat fid $fid"
7845 stat $ffid > /dev/null || error "stat $ffid failed."
7846 echo "touch fid $fid"
7847 touch $ffid || error "touch $ffid failed."
7848 echo "write to fid $fid"
7849 cat /etc/hosts > $ffid || error "write $ffid failed."
7850 echo "read fid $fid"
7851 diff /etc/hosts $ffid || error "read $ffid failed."
7852 echo "append write to fid $fid"
7853 cat /etc/hosts >> $ffid || error "append write $ffid failed."
7854 echo "rename fid $fid"
7855 mv $ffid $DIR/$tfile.1 && error "rename $ffid to $tfile.1 should fail."
7857 mv $DIR/$tfile.1 $ffid && error "rename $tfile.1 to $ffid should fail."
7859 echo "truncate fid $fid"
7860 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
7861 echo "link fid $fid"
7862 ln -f $ffid $DIR/tfile.lnk || error "link $ffid failed."
7863 if [ -n $(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl) ]; then
7864 echo "setfacl fid $fid"
7865 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
7866 echo "getfacl fid $fid"
7867 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
7869 echo "unlink fid $fid"
7870 unlink $DIR/.lustre/fid/$fid && error "unlink $ffid should fail."
7871 echo "mknod fid $fid"
7872 mknod $ffid c 1 3 && error "mknod $ffid should fail."
7874 fid=[0xf00000400:0x1:0x0]
7875 ffid=$DIR/.lustre/fid/$fid
7877 echo "stat non-exist fid $fid"
7878 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
7879 echo "write to non-exist fid $fid"
7880 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
7881 echo "link new fid $fid"
7882 ln $DIR/$tfile $ffid && error "link $ffid should fail."
7885 touch $DIR/$tdir/$tfile
7886 fid=$($LFS path2fid $DIR/$tdir)
7888 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
7890 ffid=$DIR/.lustre/fid/$fid
7893 ls $ffid > /dev/null || error "ls $ffid failed."
7894 echo "touch $fid/$tfile.1"
7895 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
7897 echo "touch $DIR/.lustre/fid/$tfile"
7898 touch $DIR/.lustre/fid/$tfile && \
7899 error "touch $DIR/.lustre/fid/$tfile should fail."
7901 echo "setxattr to $DIR/.lustre/fid"
7902 setfattr -n trusted.name1 -v value1 $DIR/.lustre/fid &&
7903 error "setxattr should fail."
7905 echo "listxattr for $DIR/.lustre/fid"
7906 getfattr -d -m "^trusted" $DIR/.lustre/fid &&
7907 error "listxattr should fail."
7909 echo "delxattr from $DIR/.lustre/fid"
7910 setfattr -x trusted.name1 $DIR/.lustre/fid &&
7911 error "delxattr should fail."
7913 echo "touch invalid fid: $DIR/.lustre/fid/[0x200000400:0x2:0x3]"
7914 touch $DIR/.lustre/fid/[0x200000400:0x2:0x3] &&
7915 error "touch invalid fid should fail."
7917 echo "touch non-normal fid: $DIR/.lustre/fid/[0x1:0x2:0x0]"
7918 touch $DIR/.lustre/fid/[0x1:0x2:0x0] &&
7919 error "touch non-normal fid should fail."
7921 echo "rename $tdir to $DIR/.lustre/fid"
7922 mrename $DIR/$tdir $DIR/.lustre/fid &&
7923 error "rename to $DIR/.lustre/fid should fail."
7925 echo "rename .lustre to itself"
7926 fid=$($LFS path2fid $DIR)
7927 mrename $DIR/.lustre $DIR/.lustre/fid/$fid/.lustre &&
7928 error "rename .lustre to itself should fail."
7930 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $DIR/$tfile-2
7931 fid=$($LFS path2fid $DIR/$tfile-2)
7932 echo "cp /etc/passwd $DIR/.lustre/fid/$fid"
7933 cp /etc/passwd $DIR/.lustre/fid/$fid &&
7934 error "create lov data thru .lustre should fail."
7935 echo "cp /etc/passwd $DIR/$tfile-2"
7936 cp /etc/passwd $DIR/$tfile-2 || error "copy to $DIR/$tfile-2 failed."
7937 echo "diff /etc/passwd $DIR/.lustre/fid/$fid"
7938 diff /etc/passwd $DIR/.lustre/fid/$fid ||
7939 error "diff /etc/passwd $DIR/.lustre/fid/$fid failed."
7941 echo "Open-by-FID succeeded"
7943 run_test 154 "Open-by-FID"
7945 test_155_small_load() {
7946 local temp=$TMP/$tfile
7947 local file=$DIR/$tfile
7949 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
7950 error "dd of=$temp bs=6096 count=1 failed"
7952 cancel_lru_locks osc
7953 cmp $temp $file || error "$temp $file differ"
7955 $TRUNCATE $temp 6000
7956 $TRUNCATE $file 6000
7957 cmp $temp $file || error "$temp $file differ (truncate1)"
7959 echo "12345" >>$temp
7960 echo "12345" >>$file
7961 cmp $temp $file || error "$temp $file differ (append1)"
7963 echo "12345" >>$temp
7964 echo "12345" >>$file
7965 cmp $temp $file || error "$temp $file differ (append2)"
7971 test_155_big_load() {
7972 remote_ost_nodsh && skip "remote OST with nodsh" && return
7973 local temp=$TMP/$tfile
7974 local file=$DIR/$tfile
7977 local cache_size=$(do_facet ost$((MAXI+1)) \
7978 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
7979 local large_file_size=$((cache_size * 2))
7981 echo "OSS cache size: $cache_size KB"
7982 echo "Large file size: $large_file_size KB"
7984 [ $MAXV -le $large_file_size ] && \
7985 skip_env "max available OST size needs > $large_file_size KB" && \
7988 $SETSTRIPE $file -c 1 -i $MAXI || error "$SETSTRIPE $file failed"
7990 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k || \
7991 error "dd of=$temp bs=$large_file_size count=1k failed"
7994 cancel_lru_locks osc
7995 cmp $temp $file || error "$temp $file differ"
8003 set_cache writethrough on
8006 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
8010 set_cache writethrough off
8013 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
8017 set_cache writethrough on
8020 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
8024 set_cache writethrough off
8027 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
8031 set_cache writethrough on
8034 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
8038 set_cache writethrough off
8041 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
8045 set_cache writethrough on
8048 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
8052 set_cache writethrough off
8055 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
8061 local file="$DIR/$tfile"
8063 log "Turn on read and write cache"
8065 set_cache writethrough on
8067 log "Write data and read it back."
8068 log "Read should be satisfied from the cache."
8069 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
8071 cancel_lru_locks osc
8072 cat $file >/dev/null
8074 if ! let "AFTER - BEFORE == CPAGES"; then
8075 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
8077 log "cache hits:: before: $BEFORE, after: $AFTER"
8080 log "Read again; it should be satisfied from the cache."
8082 cancel_lru_locks osc
8083 cat $file >/dev/null
8085 if ! let "AFTER - BEFORE == CPAGES"; then
8086 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
8088 log "cache hits:: before: $BEFORE, after: $AFTER"
8092 log "Turn off the read cache and turn on the write cache"
8094 set_cache writethrough on
8096 log "Read again; it should be satisfied from the cache."
8098 cancel_lru_locks osc
8099 cat $file >/dev/null
8101 if ! let "AFTER - BEFORE == CPAGES"; then
8102 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
8104 log "cache hits:: before: $BEFORE, after: $AFTER"
8107 log "Read again; it should not be satisfied from the cache."
8109 cancel_lru_locks osc
8110 cat $file >/dev/null
8112 if ! let "AFTER - BEFORE == 0"; then
8113 error "IN CACHE: before: $BEFORE, after: $AFTER"
8115 log "cache hits:: before: $BEFORE, after: $AFTER"
8118 log "Write data and read it back."
8119 log "Read should be satisfied from the cache."
8120 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
8122 cancel_lru_locks osc
8123 cat $file >/dev/null
8125 if ! let "AFTER - BEFORE == CPAGES"; then
8126 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
8128 log "cache hits:: before: $BEFORE, after: $AFTER"
8131 log "Read again; it should not be satisfied from the cache."
8133 cancel_lru_locks osc
8134 cat $file >/dev/null
8136 if ! let "AFTER - BEFORE == 0"; then
8137 error "IN CACHE: before: $BEFORE, after: $AFTER"
8139 log "cache hits:: before: $BEFORE, after: $AFTER"
8143 log "Turn off read and write cache"
8145 set_cache writethrough off
8147 log "Write data and read it back"
8148 log "It should not be satisfied from the cache."
8150 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
8151 cancel_lru_locks osc
8153 cat $file >/dev/null
8155 if ! let "AFTER - BEFORE == 0"; then
8156 error_ignore 20762 "IN CACHE: before: $BEFORE, after: $AFTER"
8158 log "cache hits:: before: $BEFORE, after: $AFTER"
8162 log "Turn on the read cache and turn off the write cache"
8164 set_cache writethrough off
8166 log "Write data and read it back"
8167 log "It should not be satisfied from the cache."
8169 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
8171 cancel_lru_locks osc
8172 cat $file >/dev/null
8174 if ! let "AFTER - BEFORE == 0"; then
8175 error_ignore 20762 "IN CACHE: before: $BEFORE, after: $AFTER"
8177 log "cache hits:: before: $BEFORE, after: $AFTER"
8180 log "Read again; it should be satisfied from the cache."
8182 cancel_lru_locks osc
8183 cat $file >/dev/null
8185 if ! let "AFTER - BEFORE == CPAGES"; then
8186 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
8188 log "cache hits:: before: $BEFORE, after: $AFTER"
8193 run_test 156 "Verification of tunables ============================"
8197 if [ $MDSCOUNT -gt 1 ]; then
8198 error_ignore 17935 $*
8206 MASK=$(do_facet $SINGLEMDS $LCTL get_param mdd.$MDT0.changelog_mask |\
8209 if [ $MASK -eq 1 ]; then
8210 do_facet $SINGLEMDS $LCTL set_param mdd.$MDT0.changelog_mask="-$1"
8212 do_facet $SINGLEMDS $LCTL set_param mdd.$MDT0.changelog_mask="+$1"
8217 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8218 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
8219 { skip "Need MDS version at least 2.2.0"; return; }
8220 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
8221 echo "Registered as changelog user $USER"
8222 do_facet $SINGLEMDS $LCTL get_param -n mdd.$MDT0.changelog_users | \
8223 grep -q $USER || error "User $USER not found in changelog_users"
8226 mkdir -p $DIR/$tdir/pics/2008/zachy
8227 touch $DIR/$tdir/pics/2008/zachy/timestamp
8228 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
8229 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
8230 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
8231 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
8232 rm $DIR/$tdir/pics/desktop.jpg
8234 $LFS changelog $MDT0 | tail -5
8236 echo "verifying changelog mask"
8237 changelog_chmask "MKDIR"
8238 changelog_chmask "CLOSE"
8240 mkdir -p $DIR/$tdir/pics/zach/sofia
8241 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
8243 changelog_chmask "MKDIR"
8244 changelog_chmask "CLOSE"
8246 mkdir -p $DIR/$tdir/pics/2008/sofia
8247 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
8249 $LFS changelog $MDT0
8250 MKDIRS=$($LFS changelog $MDT0 | tail -5 | grep -c "MKDIR")
8251 CLOSES=$($LFS changelog $MDT0 | tail -5 | grep -c "CLOSE")
8252 [ $MKDIRS -eq 1 ] || err17935 "MKDIR changelog mask count $DIRS != 1"
8253 [ $CLOSES -eq 1 ] || err17935 "CLOSE changelog mask count $DIRS != 1"
8256 echo "verifying target fid"
8257 fidc=$($LFS changelog $MDT0 | grep timestamp | grep "CREAT" | \
8258 tail -1 | awk '{print $6}')
8259 fidf=$($LFS path2fid $DIR/$tdir/pics/zach/timestamp)
8260 [ "$fidc" == "t=$fidf" ] || \
8261 err17935 "fid in changelog $fidc != file fid $fidf"
8262 echo "verifying parent fid"
8263 fidc=$($LFS changelog $MDT0 | grep timestamp | grep "CREAT" | \
8264 tail -1 | awk '{print $7}')
8265 fidf=$($LFS path2fid $DIR/$tdir/pics/zach)
8266 [ "$fidc" == "p=$fidf" ] || \
8267 err17935 "pfid in changelog $fidc != dir fid $fidf"
8269 USER_REC1=$(do_facet $SINGLEMDS $LCTL get_param -n \
8270 mdd.$MDT0.changelog_users | grep $USER | awk '{print $2}')
8271 $LFS changelog_clear $MDT0 $USER $(($USER_REC1 + 5))
8272 USER_REC2=$(do_facet $SINGLEMDS $LCTL get_param -n \
8273 mdd.$MDT0.changelog_users | grep $USER | awk '{print $2}')
8274 echo "verifying user clear: $(( $USER_REC1 + 5 )) == $USER_REC2"
8275 [ $USER_REC2 == $(($USER_REC1 + 5)) ] || \
8276 err17935 "user index should be $(($USER_REC1 + 5)); is $USER_REC2"
8278 MIN_REC=$(do_facet $SINGLEMDS $LCTL get_param mdd.$MDT0.changelog_users | \
8279 awk 'min == "" || $2 < min {min = $2}; END {print min}')
8280 FIRST_REC=$($LFS changelog $MDT0 | head -1 | awk '{print $1}')
8281 echo "verifying min purge: $(( $MIN_REC + 1 )) == $FIRST_REC"
8282 [ $FIRST_REC == $(($MIN_REC + 1)) ] || \
8283 err17935 "first index should be $(($MIN_REC + 1)); is $FIRST_REC"
8285 echo "verifying user deregister"
8286 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
8287 do_facet $SINGLEMDS $LCTL get_param -n mdd.$MDT0.changelog_users | \
8288 grep -q $USER && error "User $USER still found in changelog_users"
8290 USERS=$(( $(do_facet $SINGLEMDS $LCTL get_param -n \
8291 mdd.$MDT0.changelog_users | wc -l) - 2 ))
8292 if [ $USERS -eq 0 ]; then
8293 LAST_REC1=$(do_facet $SINGLEMDS $LCTL get_param -n \
8294 mdd.$MDT0.changelog_users | head -1 | awk '{print $3}')
8295 touch $DIR/$tdir/chloe
8296 LAST_REC2=$(do_facet $SINGLEMDS $LCTL get_param -n \
8297 mdd.$MDT0.changelog_users | head -1 | awk '{print $3}')
8298 echo "verify changelogs are off if we were the only user: $LAST_REC1 == $LAST_REC2"
8299 [ $LAST_REC1 == $LAST_REC2 ] || error "changelogs not off"
8301 echo "$USERS other changelog users; can't verify off"
8304 run_test 160 "changelog sanity"
8308 cp /etc/hosts $DIR/$tdir/$tfile
8309 mkdir $DIR/$tdir/foo1
8310 mkdir $DIR/$tdir/foo2
8311 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
8312 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
8313 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
8314 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
8315 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[')
8316 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
8317 $LFS fid2path $DIR $FID
8318 err17935 "bad link ea"
8321 rm $DIR/$tdir/foo2/zachary
8323 rm $DIR/$tdir/foo2/thor
8325 rm $DIR/$tdir/$tfile
8327 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
8328 if [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ]
8330 $LFS fid2path $DIR $FID
8331 err17935 "bad link rename"
8333 rm $DIR/$tdir/foo2/maggie
8336 local longname=filename_avg_len_is_thirty_two_
8337 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 || \
8338 error "failed to hardlink many files"
8339 links=$($LFS fid2path $DIR $FID | wc -l)
8340 echo -n "${links}/1000 links in link EA"
8341 [ ${links} -gt 60 ] || err17935 "expected at least 60 links in link EA"
8342 unlinkmany $DIR/$tdir/foo2/$longname 1000 || \
8343 error "failed to unlink many hardlinks"
8345 run_test 161 "link ea sanity"
8352 local path=$(${LFS} fid2path $*)
8355 if [ $RC -ne 0 ]; then
8356 err17935 "path looked up of $expected failed. Error $RC"
8358 elif [ "${path}" != "${expected}" ]; then
8359 err17935 "path looked up \"${path}\" instead of \"${expected}\""
8362 echo "fid $fid resolves to path $path (expected $expected)"
8366 # Make changes to filesystem
8367 mkdir -p $DIR/$tdir/d2
8368 touch $DIR/$tdir/d2/$tfile
8369 touch $DIR/$tdir/d2/x1
8370 touch $DIR/$tdir/d2/x2
8371 mkdir -p $DIR/$tdir/d2/a/b/c
8372 mkdir -p $DIR/$tdir/d2/p/q/r
8374 FID=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
8375 check_path "$tdir/d2/$tfile" $FSNAME $FID --link 0
8378 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
8379 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
8380 check_path "$tdir/d2/p/q/r/slink" $FSNAME $FID --link 0
8382 # softlink to wrong file
8383 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
8384 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
8385 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME $FID --link 0
8388 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
8389 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
8390 FID=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
8391 # fid2path dir/fsname should both work
8392 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 1
8393 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR $FID --link 0
8395 # hardlink count: check that there are 2 links
8396 # Doesnt work with CMD yet: 17935
8397 ${LFS} fid2path $DIR $FID | wc -l | grep -q 2 || \
8398 err17935 "expected 2 links"
8400 # hardlink indexing: remove the first link
8401 rm $DIR/$tdir/d2/p/q/r/hlink
8402 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 0
8406 run_test 162 "path lookup sanity"
8409 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8410 copytool --test $FSNAME || { skip "copytool not runnable: $?" && return; }
8413 local uuid=$($LCTL get_param -n mdc.${FSNAME}-MDT0000-mdc-*.uuid)
8414 # this proc file is temporary and linux-only
8415 do_facet $SINGLEMDS lctl set_param mdt.${FSNAME}-MDT0000.mdccomm=$uuid ||\
8416 error "kernel->userspace send failed"
8419 run_test 163 "kernel <-> userspace comms"
8422 # do directio so as not to populate the page cache
8423 log "creating a 10 Mb file"
8424 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
8425 log "starting reads"
8426 dd if=$DIR/$tfile of=/dev/null bs=4096 &
8427 log "truncating the file"
8428 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
8430 kill %+ || true # reads might have finished
8431 echo "wait until dd is finished"
8433 log "removing the temporary file"
8434 rm -rf $DIR/$tfile || error "tmp file removal failed"
8436 run_test 169 "parallel read and truncate should not deadlock"
8439 $LCTL clear # bug 18514
8440 $LCTL debug_daemon start $TMP/${tfile}_log_good
8442 $LCTL debug_daemon stop
8443 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
8444 error "sed failed to read log_good"
8446 $LCTL debug_daemon start $TMP/${tfile}_log_good
8448 $LCTL debug_daemon stop
8450 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
8451 error "lctl df log_bad failed"
8453 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
8454 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
8456 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
8457 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
8459 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
8460 error "bad_line good_line1 good_line2 are empty"
8462 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
8463 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
8464 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
8466 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
8467 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
8468 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
8470 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
8471 error "bad_line_new good_line_new are empty"
8473 local expected_good=$((good_line1 + good_line2*2))
8475 rm -f $TMP/${tfile}*
8476 # LU-231, short malformed line may not be counted into bad lines
8477 if [ $bad_line -ne $bad_line_new ] &&
8478 [ $bad_line -ne $((bad_line_new - 1)) ]; then
8479 error "expected $bad_line bad lines, but got $bad_line_new"
8483 if [ $expected_good -ne $good_line_new ]; then
8484 error "expected $expected_good good lines, but got $good_line_new"
8489 run_test 170 "test lctl df to handle corrupted log ====================="
8491 test_171() { # bug20592
8492 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
8493 $LCTL set_param fail_loc=0x50e
8494 $LCTL set_param fail_val=3000
8495 multiop_bg_pause $DIR/$tfile O_s || true
8497 kill -USR1 $MULTIPID
8501 if dmesg | grep "recursive fault"; then
8502 error "caught a recursive fault"
8504 $LCTL set_param fail_loc=0
8507 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
8509 # it would be good to share it with obdfilter-survey/libecho code
8510 setup_obdecho_osc () {
8513 local obdfilter_name=$2
8514 echo "Creating new osc for $obdfilter_name on $ost_nid"
8515 # make sure we can find loopback nid
8516 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
8518 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
8519 ${obdfilter_name}_osc_UUID || rc=2; }
8520 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
8521 ${obdfilter_name}_UUID $ost_nid || rc=3; }
8525 cleanup_obdecho_osc () {
8526 local obdfilter_name=$1
8527 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
8528 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
8532 obdecho_create_test() {
8537 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
8538 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
8540 if [ $rc -eq 0 ]; then
8541 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
8542 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
8544 echo "New object id is $id"
8545 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec test_brw 10 w v 64 $id" ||
8547 [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec " \
8548 "cleanup" || rc=5; }
8549 [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec " \
8551 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
8556 remote_ost_nodsh && skip "remote OST with nodsh" && return
8560 if ! module_loaded obdecho; then
8561 load_module obdecho/obdecho
8565 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
8566 local host=$(lctl get_param -n osc.$osc.import |
8567 awk '/current_connection:/ {print $2}' )
8568 local target=$(lctl get_param -n osc.$osc.import |
8569 awk '/target:/ {print $2}' )
8570 target=${target%_UUID}
8572 [[ -n $target ]] && { setup_obdecho_osc $host $target || rc=1; } || rc=1
8573 [ $rc -eq 0 ] && { obdecho_create_test ${target}_osc client || rc=2; }
8574 [[ -n $target ]] && cleanup_obdecho_osc $target
8575 [ $rmmod_local -eq 1 ] && rmmod obdecho
8578 run_test 180a "test obdecho on osc"
8581 remote_ost_nodsh && skip "remote OST with nodsh" && return
8583 local rmmod_remote=0
8585 do_facet ost1 "lsmod | grep -q obdecho || " \
8586 "{ insmod ${LUSTRE}/obdecho/obdecho.ko || " \
8587 "modprobe obdecho; }" && rmmod_remote=1
8588 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ {print $4;exit}')
8589 [[ -n $target ]] && { obdecho_create_test $target ost1 || rc=1; }
8590 [ $rmmod_remote -eq 1 ] && do_facet ost1 "rmmod obdecho"
8593 run_test 180b "test obdecho directly on obdfilter"
8595 test_181() { # bug 22177
8596 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
8597 # create enough files to index the directory
8598 createmany -o $DIR/$tdir/foobar 4000
8599 # print attributes for debug purpose
8602 multiop_bg_pause $DIR/$tdir D_Sc || return 1
8604 # remove the files & current working dir
8605 unlinkmany $DIR/$tdir/foobar 4000
8607 kill -USR1 $MULTIPID
8609 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
8612 run_test 181 "Test open-unlinked dir ========================"
8615 # disable MDC RPC lock wouldn't crash client
8619 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
8620 #define OBD_FAIL_MDC_RPCS_SEM 0x804
8621 $LCTL set_param fail_loc=0x804
8623 for (( i=0; i < $tcount; i++ )) ; do
8625 createmany -o $DIR/$tdir/$i/f- $fcount &
8629 for (( i=0; i < $tcount; i++ )) ; do
8630 unlinkmany $DIR/$tdir/$i/f- $fcount &
8636 $LCTL set_param fail_loc=0
8638 run_test 182 "Disable MDC RPCs semaphore wouldn't crash client ================"
8641 check_file_in_pool()
8646 local res=$($GETSTRIPE $file | grep 0x | cut -f2)
8649 for t in $tlist ; do
8650 [ "$i" -eq "$t" ] && continue 2
8653 echo "pool list: $tlist"
8654 echo "striping: $res"
8655 error_noexit "$file not allocated in $pool"
8662 echo "Creating new pool"
8665 create_pool $FSNAME.$pool ||
8666 { error_noexit "No pool created, result code $?"; return 1; }
8667 [ $($LFS pool_list $FSNAME | grep -c $pool) -eq 1 ] ||
8668 { error_noexit "$pool not in lfs pool_list"; return 2; }
8671 pool_add_targets() {
8672 echo "Adding targets to pool"
8678 local list=$(seq $first $step $last)
8680 local t=$(for i in $list; do printf "$FSNAME-OST%04x_UUID " $i; done)
8681 do_facet mgs $LCTL pool_add \
8682 $FSNAME.$pool $FSNAME-OST[$first-$last/$step]
8683 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$pool \
8684 | sort -u | tr '\n' ' ' " "$t" || {
8685 error_noexit "Add to pool failed"
8688 local lfscount=$($LFS pool_list $FSNAME.$pool | grep -c "\-OST")
8689 local addcount=$(((last - first) / step + 1))
8690 [ $lfscount -eq $addcount ] || {
8691 error_noexit "lfs pool_list bad ost count" \
8692 "$lfscount != $addcount"
8700 echo "Setting pool on directory $tdir"
8702 $SETSTRIPE -c 2 -p $pool $tdir && return 0
8704 error_noexit "Cannot set pool $pool to $tdir"
8711 echo "Checking pool on directory $tdir"
8713 local res=$($GETSTRIPE --pool $tdir | sed "s/\s*$//")
8714 [ "$res" = "$pool" ] && return 0
8716 error_noexit "Pool on '$tdir' is '$res', not '$pool'"
8720 pool_dir_rel_path() {
8721 echo "Testing relative path works well"
8726 mkdir -p $root/$tdir/$tdir
8728 pool_set_dir $pool $tdir || return 1
8729 pool_set_dir $pool ./$tdir || return 2
8730 pool_set_dir $pool ../$tdir || return 3
8731 pool_set_dir $pool ../$tdir/$tdir || return 4
8732 rm -rf $tdir; cd - > /dev/null
8735 pool_alloc_files() {
8736 echo "Checking files allocation from directory pool"
8743 for i in $(seq -w 1 $count)
8745 local file=$tdir/file-$i
8747 check_file_in_pool $file $pool "$tlist" || \
8748 failed=$((failed + 1))
8750 [ "$failed" = 0 ] && return 0
8752 error_noexit "$failed files not allocated in $pool"
8756 pool_create_files() {
8757 echo "Creating files in pool"
8765 for i in $(seq -w 1 $count)
8767 local file=$tdir/spoo-$i
8768 $SETSTRIPE -p $pool $file
8769 check_file_in_pool $file $pool "$tlist" || \
8770 failed=$((failed + 1))
8772 [ "$failed" = 0 ] && return 0
8774 error_noexit "$failed files not allocated in $pool"
8779 echo "Checking 'lfs df' output"
8782 local t=$($LCTL get_param -n lov.$FSNAME-clilov-*.pools.$pool |
8784 local res=$($LFS df --pool $FSNAME.$pool |
8786 grep "$FSNAME-OST" |
8788 [ "$res" = "$t" ] && return 0
8790 error_noexit "Pools OSTs '$t' is not '$res' that lfs df reports"
8794 pool_file_rel_path() {
8795 echo "Creating files in a pool with relative pathname"
8800 { error_noexit "unable to create $tdir"; return 1 ; }
8801 local file="/..$tdir/$tfile-1"
8802 $SETSTRIPE -p $pool $file ||
8803 { error_noexit "unable to create $file" ; return 2 ; }
8806 $SETSTRIPE -p $pool $tfile-2 || {
8807 error_noexit "unable to create $tfile-2 in $tdir"
8812 pool_remove_first_target() {
8813 echo "Removing first target from a pool"
8816 local pname="lov.$FSNAME-*.pools.$pool"
8817 local t=$($LCTL get_param -n $pname | head -1)
8818 do_facet mgs $LCTL pool_remove $FSNAME.$pool $t
8819 wait_update $HOSTNAME "lctl get_param -n $pname | grep $t" "" || {
8820 error_noexit "$t not removed from $FSNAME.$pool"
8825 pool_remove_all_targets() {
8826 echo "Removing all targets from pool"
8829 local pname="lov.$FSNAME-*.pools.$pool"
8830 for t in $($LCTL get_param -n $pname | sort -u)
8832 do_facet mgs $LCTL pool_remove $FSNAME.$pool $t
8834 wait_update $HOSTNAME "lctl get_param -n $pname" "" || {
8835 error_noexit "Pool $FSNAME.$pool cannot be drained"
8838 # striping on an empty/nonexistant pool should fall back
8839 # to "pool of everything"
8841 error_noexit "failed to use fallback striping for empty pool"
8844 # setstripe on an empty pool should fail
8845 $SETSTRIPE -p $pool $file 2>/dev/null && {
8846 error_noexit "expected failure when creating file" \
8854 echo "Destroying pool"
8858 do_facet mgs $LCTL pool_destroy $FSNAME.$pool
8861 # striping on an empty/nonexistant pool should fall back
8862 # to "pool of everything"
8864 error_noexit "failed to use fallback striping for missing pool"
8867 # setstripe on an empty pool should fail
8868 $SETSTRIPE -p $pool $file 2>/dev/null && {
8869 error_noexit "expected failure when creating file" \
8874 # get param should return err once pool is gone
8875 if wait_update $HOSTNAME "lctl get_param -n \
8876 lov.$FSNAME-*.pools.$pool 2>/dev/null || echo foo" "foo"
8878 remove_pool_from_list $FSNAME.$pool
8881 error_noexit "Pool $FSNAME.$pool is not destroyed"
8886 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
8888 local POOL=${POOL:-cea1}
8889 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
8890 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
8893 local last_ost=$(($OSTCOUNT - 1))
8895 local ost_list=$(seq $first_ost $ost_step $last_ost)
8896 local ost_range="$first_ost $last_ost $ost_step"
8897 local test_path=$POOL_ROOT/$POOL_DIR_NAME
8898 local file_dir=$POOL_ROOT/file_tst
8902 # former test_200a test_200b
8903 pool_add $POOL || { rc=$? ; break; }
8904 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
8905 # former test_200c test_200d
8907 pool_set_dir $POOL $test_path || { rc=$? ; break; }
8908 pool_check_dir $POOL $test_path || { rc=$? ; break; }
8909 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
8910 || { rc=$? ; break; }
8911 # former test_200e test_200f
8912 local files=$((OSTCOUNT*3))
8913 pool_alloc_files $POOL $test_path $files "$ost_list" \
8914 || { rc=$? ; break; }
8915 pool_create_files $POOL $file_dir $files "$ost_list" \
8916 || { rc=$? ; break; }
8917 # former test_200g test_200h
8918 pool_lfs_df $POOL || { rc=$? ; break; }
8919 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
8921 # former test_201a test_201b test_201c
8922 pool_remove_first_target $POOL || { rc=$? ; break; }
8924 local f=$test_path/$tfile
8925 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
8926 pool_remove $POOL $f || { rc=$? ; break; }
8933 run_test 200 "OST pools"
8935 # usage: default_attr <count | size | offset>
8937 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
8940 # usage: check_default_stripe_attr
8941 check_default_stripe_attr() {
8942 ACTUAL=$($GETSTRIPE $* $DIR/$tdir)
8944 --stripe-count|--count)
8945 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
8946 --stripe-size|--size)
8947 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
8948 --stripe-index|--index)
8951 error "unknown getstripe attr '$1'"
8954 [ $ACTUAL != $EXPECTED ] &&
8955 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
8960 $SETSTRIPE --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
8962 check_default_stripe_attr --stripe-count
8963 check_default_stripe_attr --stripe-size
8964 check_default_stripe_attr --stripe-index
8968 run_test 204a "Print default stripe attributes ================="
8972 $SETSTRIPE --stripe-count 1 $DIR/$tdir
8974 check_default_stripe_attr --stripe-size
8975 check_default_stripe_attr --stripe-index
8979 run_test 204b "Print default stripe size and offset ==========="
8983 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
8985 check_default_stripe_attr --stripe-count
8986 check_default_stripe_attr --stripe-index
8990 run_test 204c "Print default stripe count and offset ==========="
8994 $SETSTRIPE --stripe-index 0 $DIR/$tdir
8996 check_default_stripe_attr --stripe-count
8997 check_default_stripe_attr --stripe-size
9001 run_test 204d "Print default stripe count and size ============="
9005 $SETSTRIPE -d $DIR/$tdir
9007 check_default_stripe_attr --stripe-count --raw
9008 check_default_stripe_attr --stripe-size --raw
9009 check_default_stripe_attr --stripe-index --raw
9013 run_test 204e "Print raw stripe attributes ================="
9017 $SETSTRIPE --stripe-count 1 $DIR/$tdir
9019 check_default_stripe_attr --stripe-size --raw
9020 check_default_stripe_attr --stripe-index --raw
9024 run_test 204f "Print raw stripe size and offset ==========="
9028 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
9030 check_default_stripe_attr --stripe-count --raw
9031 check_default_stripe_attr --stripe-index --raw
9035 run_test 204g "Print raw stripe count and offset ==========="
9039 $SETSTRIPE --stripe-index 0 $DIR/$tdir
9041 check_default_stripe_attr --stripe-count --raw
9042 check_default_stripe_attr --stripe-size --raw
9046 run_test 204h "Print raw stripe count and size ============="
9048 # Figure out which job scheduler is being used, if any,
9050 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
9052 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
9054 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
9056 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
9057 JOBENV=LOADL_STEP_ID
9058 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
9068 # clear old jobstats
9069 do_facet $SINGLEMDS lctl set_param mdt.*.job_stats="clear"
9070 do_facet ost0 lctl set_param obdfilter.*.job_stats="clear"
9072 # use a new JobID for this test, or we might see an old one
9073 [ "$JOBENV" = "FAKE_JOBID" ] && FAKE_JOBID=test_id.$testnum.$RANDOM
9077 log "Using JobID environment variable $JOBENV=$JOBVAL"
9079 if [ $JOBENV = "FAKE_JOBID" ]; then
9080 FAKE_JOBID=$JOBVAL $cmd
9085 if [ "$target" = "mdt" -o "$target" = "both" ]; then
9086 FACET="$SINGLEMDS" # will need to get MDS number for DNE
9087 do_facet $FACET lctl get_param mdt.*.job_stats |
9088 grep $JOBVAL || error "No job stats found on MDT $FACET"
9090 if [ "$target" = "ost" -o "$target" = "both" ]; then
9092 do_facet $FACET lctl get_param obdfilter.*.job_stats |
9093 grep $JOBVAL || error "No job stats found on OST $FACET"
9097 test_205() { # Job stats
9098 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
9099 skip "Server doesn't support jobstats" && return 0
9102 OLD_JOBENV=`$LCTL get_param -n jobid_var`
9103 if [ $OLD_JOBENV != $JOBENV ]; then
9104 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$JOBENV
9105 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" \
9110 cmd="mkdir $DIR/$tfile"
9111 verify_jobstats "$cmd" "mdt"
9113 cmd="rm -fr $DIR/$tfile"
9114 verify_jobstats "$cmd" "mdt"
9116 cmd="mknod $DIR/$tfile c 1 3"
9117 verify_jobstats "$cmd" "mdt"
9119 cmd="rm -f $DIR/$tfile"
9120 verify_jobstats "$cmd" "mdt"
9122 cmd="$SETSTRIPE -i 0 -c 1 $DIR/$tfile"
9123 verify_jobstats "$cmd" "mdt"
9125 cmd="touch $DIR/$tfile"
9126 verify_jobstats "$cmd" "both"
9128 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
9129 verify_jobstats "$cmd" "ost"
9131 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
9132 verify_jobstats "$cmd" "ost"
9134 cmd="$TRUNCATE $DIR/$tfile 0"
9135 verify_jobstats "$cmd" "both"
9137 cmd="mv -f $DIR/$tfile $DIR/jobstats_test_rename"
9138 verify_jobstats "$cmd" "mdt"
9141 rm -f $DIR/jobstats_test_rename
9143 if [ $OLD_JOBENV != $JOBENV ]; then
9144 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$OLD_JOBENV
9145 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" \
9146 $OLD_JOBENV || return 1
9149 run_test 205 "Verify job stats"
9151 # LU-1480, LU-1773 and LU-1657
9154 lfs setstripe -c -1 $DIR/$tdir
9155 #define OBD_FAIL_LOV_INIT 0x1403
9156 $LCTL set_param fail_loc=0xa0001403
9157 $LCTL set_param fail_val=1
9158 touch $DIR/$tdir/$tfile || true
9160 run_test 206 "fail lov_init_raid0() doesn't lbug"
9164 size=$((size % 8192 + 1))
9165 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
9166 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
9167 rm -f $DIR/f212 $DIR/f212.xyz
9169 run_test 212 "Sendfile test ============================================"
9172 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
9173 cancel_lru_locks osc
9174 lctl set_param fail_loc=0x8000040f
9175 # generate a read lock
9176 cat $DIR/$tfile > /dev/null
9177 # write to the file, it will try to cancel the above read lock.
9178 cat /etc/hosts >> $DIR/$tfile
9180 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
9182 test_214() { # for bug 20133
9183 mkdir -p $DIR/d214p/d214c
9184 for (( i=0; i < 340; i++ )) ; do
9185 touch $DIR/d214p/d214c/a$i
9188 ls -l $DIR/d214p || error "ls -l $DIR/d214p failed"
9189 mv $DIR/d214p/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
9190 ls $DIR/d214c || error "ls $DIR/d214c failed"
9191 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
9193 run_test 214 "hash-indexed directory test - bug 20133"
9195 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
9196 create_lnet_proc_files() {
9197 cat /proc/sys/lnet/$1 >$TMP/lnet_$1.out || error "cannot read /proc/sys/lnet/$1"
9198 sysctl lnet.$1 >$TMP/lnet_$1.sys_tmp || error "cannot read lnet.$1"
9200 sed "s/^lnet.$1\ =\ //g" "$TMP/lnet_$1.sys_tmp" >$TMP/lnet_$1.sys
9201 rm -f "$TMP/lnet_$1.sys_tmp"
9204 # counterpart of create_lnet_proc_files
9205 remove_lnet_proc_files() {
9206 rm -f $TMP/lnet_$1.out $TMP/lnet_$1.sys
9209 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
9210 # 3rd arg as regexp for body
9211 check_lnet_proc_stats() {
9212 local l=$(cat "$TMP/lnet_$1" |wc -l)
9213 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
9215 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
9218 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
9219 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
9220 # optional and can be regexp for 2nd line (lnet.routes case)
9221 check_lnet_proc_entry() {
9222 local blp=2 # blp stands for 'position of 1st line of body'
9223 [ "$5" = "" ] || blp=3 # lnet.routes case
9225 local l=$(cat "$TMP/lnet_$1" |wc -l)
9226 # subtracting one from $blp because the body can be empty
9227 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
9229 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
9230 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
9232 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
9233 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
9235 # bail out if any unexpected line happened
9236 sed -n "$blp~1 p" "$TMP/lnet_$1" |grep -Ev "$3"
9237 [ "$?" != 0 ] || error "$2 misformatted"
9240 test_215() { # for bugs 18102, 21079, 21517
9241 local N='(0|[1-9][0-9]*)' # non-negative numeric
9242 local P='[1-9][0-9]*' # positive numeric
9243 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
9244 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
9245 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
9246 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
9248 local L1 # regexp for 1st line
9249 local L2 # regexp for 2nd line (optional)
9250 local BR # regexp for the rest (body)
9252 # /proc/sys/lnet/stats should look as 11 space-separated non-negative numerics
9253 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
9254 create_lnet_proc_files "stats"
9255 check_lnet_proc_stats "stats.out" "/proc/sys/lnet/stats" "$BR"
9256 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
9257 remove_lnet_proc_files "stats"
9259 # /proc/sys/lnet/routes should look like this:
9260 # Routing disabled/enabled
9261 # net hops state router
9262 # where net is a string like tcp0, hops >= 0, state is up/down,
9263 # router is a string like 192.168.1.1@tcp2
9264 L1="^Routing (disabled|enabled)$"
9265 L2="^net +hops +state +router$"
9266 BR="^$NET +$N +(up|down) +$NID$"
9267 create_lnet_proc_files "routes"
9268 check_lnet_proc_entry "routes.out" "/proc/sys/lnet/routes" "$BR" "$L1" "$L2"
9269 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
9270 remove_lnet_proc_files "routes"
9272 # /proc/sys/lnet/routers should look like this:
9273 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
9274 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
9275 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
9276 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
9277 L1="^ref +rtr_ref +alive_cnt +state +last_ping +ping_sent +deadline +down_ni +router$"
9278 BR="^$P +$P +$N +(up|down) +$N +(0|1) +$I +$I +$NID$"
9279 create_lnet_proc_files "routers"
9280 check_lnet_proc_entry "routers.out" "/proc/sys/lnet/routers" "$BR" "$L1"
9281 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
9282 remove_lnet_proc_files "routers"
9284 # /proc/sys/lnet/peers should look like this:
9285 # nid refs state last max rtr min tx min queue
9286 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
9287 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
9288 # numeric (0 or >0 or <0), queue >= 0.
9289 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
9290 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
9291 create_lnet_proc_files "peers"
9292 check_lnet_proc_entry "peers.out" "/proc/sys/lnet/peers" "$BR" "$L1"
9293 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
9294 remove_lnet_proc_files "peers"
9296 # /proc/sys/lnet/buffers should look like this:
9297 # pages count credits min
9298 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
9299 L1="^pages +count +credits +min$"
9300 BR="^ +$N +$N +$I +$I$"
9301 create_lnet_proc_files "buffers"
9302 check_lnet_proc_entry "buffers.out" "/proc/sys/lnet/buffers" "$BR" "$L1"
9303 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
9304 remove_lnet_proc_files "buffers"
9306 # /proc/sys/lnet/nis should look like this:
9307 # nid status alive refs peer rtr max tx min
9308 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
9309 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
9310 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
9311 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
9312 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
9313 create_lnet_proc_files "nis"
9314 check_lnet_proc_entry "nis.out" "/proc/sys/lnet/nis" "$BR" "$L1"
9315 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
9316 remove_lnet_proc_files "nis"
9318 # can we successfully write to /proc/sys/lnet/stats?
9319 echo "0" >/proc/sys/lnet/stats || error "cannot write to /proc/sys/lnet/stats"
9320 sysctl -w lnet.stats=0 || error "cannot write to lnet.stats"
9322 run_test 215 "/proc/sys/lnet exists and has proper content - bugs 18102, 21079, 21517"
9324 test_216() { # bug 20317
9325 remote_ost_nodsh && skip "remote OST with nodsh" && return
9327 local p="$TMP/sanityN-$TESTNAME.parameters"
9328 save_lustre_params $HOSTNAME "osc.*.contention_seconds" > $p
9329 for node in $(osts_nodes); do
9330 save_lustre_params $node "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
9331 save_lustre_params $node "ldlm.namespaces.filter-*.contended_locks" >> $p
9332 save_lustre_params $node "ldlm.namespaces.filter-*.contention_seconds" >> $p
9336 # agressive lockless i/o settings
9337 for node in $(osts_nodes); do
9338 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'
9340 lctl set_param -n osc.*.contention_seconds 60
9342 $DIRECTIO write $DIR/$tfile 0 10 4096
9343 $CHECKSTAT -s 40960 $DIR/$tfile
9345 # disable lockless i/o
9346 for node in $(osts_nodes); do
9347 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'
9349 lctl set_param -n osc.*.contention_seconds 0
9352 dd if=/dev/zero of=$DIR/$tfile count=0
9353 $CHECKSTAT -s 0 $DIR/$tfile
9355 restore_lustre_params <$p
9359 run_test 216 "check lockless direct write works and updates file size and kms correctly"
9361 test_217() { # bug 22430
9365 for node in $(nodes_list); do
9366 nid=$(host_nids_address $node $NETTYPE)
9367 if [[ $nid = *-* ]] ; then
9368 echo "lctl ping $nid@$NETTYPE"
9369 lctl ping $nid@$NETTYPE
9371 echo "skipping $node (no hyphen detected)"
9375 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
9378 # do directio so as not to populate the page cache
9379 log "creating a 10 Mb file"
9380 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
9381 log "starting reads"
9382 dd if=$DIR/$tfile of=/dev/null bs=4096 &
9383 log "truncating the file"
9384 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
9386 kill %+ || true # reads might have finished
9387 echo "wait until dd is finished"
9389 log "removing the temporary file"
9390 rm -rf $DIR/$tfile || error "tmp file removal failed"
9392 run_test 218 "parallel read and truncate should not deadlock ======================="
9395 # write one partial page
9396 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
9397 # set no grant so vvp_io_commit_write will do sync write
9398 $LCTL set_param fail_loc=0x411
9399 # write a full page at the end of file
9400 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
9402 $LCTL set_param fail_loc=0
9403 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
9404 $LCTL set_param fail_loc=0x411
9405 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
9407 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
9409 test_220() { #LU-325
9410 remote_ost_nodsh && skip "remote OST with nodsh" && return
9414 local OST=$(lfs osts | grep ${OSTIDX}": " | \
9415 awk '{print $2}' | sed -e 's/_UUID$//')
9418 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
9419 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
9420 osc.$mdtosc_proc1.prealloc_last_id)
9421 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
9422 osc.$mdtosc_proc1.prealloc_next_id)
9426 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
9427 #define OBD_FAIL_OST_ENOINO 0x229
9428 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
9429 do_facet mgs $LCTL pool_new $FSNAME.$TESTNAME || return 1
9430 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
9432 $SETSTRIPE $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
9434 MDSOBJS=$((last_id - next_id))
9435 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
9437 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
9438 echo "OST still has $count kbytes free"
9440 echo "create $MDSOBJS files @next_id..."
9441 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
9443 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
9444 osc.$mdtosc_proc1.prealloc_last_id)
9445 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
9446 osc.$mdtosc_proc1.prealloc_next_id)
9448 echo "after creation, last_id=$last_id2, next_id=$next_id2"
9453 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
9454 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
9456 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST || return 4
9457 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME || return 5
9458 echo "unlink $MDSOBJS files @$next_id..."
9459 unlinkmany $DIR/$tdir/f $MDSOBJS || return 6
9461 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
9464 dd if=`which date` of=$MOUNT/date oflag=sync
9465 chmod +x $MOUNT/date
9467 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
9468 $LCTL set_param fail_loc=0x80001401
9470 $MOUNT/date > /dev/null
9473 run_test 221 "make sure fault and truncate race to not cause OOM"
9478 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
9479 createmany -o $DIR/$tdir/$tfile 10
9480 cancel_lru_locks mdc
9481 cancel_lru_locks osc
9482 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
9483 $LCTL set_param fail_loc=0x31a
9484 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
9485 $LCTL set_param fail_loc=0
9488 run_test 222a "AGL for ls should not trigger CLIO lock failure ================"
9493 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
9494 createmany -o $DIR/$tdir/$tfile 10
9495 cancel_lru_locks mdc
9496 cancel_lru_locks osc
9497 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
9498 $LCTL set_param fail_loc=0x31a
9499 rm -r $DIR/$tdir || "AGL for rmdir failed"
9500 $LCTL set_param fail_loc=0
9502 run_test 222b "AGL for rmdir should not trigger CLIO lock failure ============="
9507 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
9508 createmany -o $DIR/$tdir/$tfile 10
9509 cancel_lru_locks mdc
9510 cancel_lru_locks osc
9511 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
9512 $LCTL set_param fail_loc=0x31b
9513 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
9514 $LCTL set_param fail_loc=0
9517 run_test 223 "osc reenqueue if without AGL lock granted ======================="
9519 test_224a() { # LU-1039, MRP-303
9520 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
9521 $LCTL set_param fail_loc=0x508
9522 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
9523 $LCTL set_param fail_loc=0
9526 run_test 224a "Don't panic on bulk IO failure"
9528 test_224b() { # LU-1039, MRP-303
9529 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
9530 cancel_lru_locks osc
9531 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
9532 $LCTL set_param fail_loc=0x515
9533 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
9534 $LCTL set_param fail_loc=0
9537 run_test 224b "Don't panic on bulk IO failure"
9539 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
9541 if [ -z ${MDSSURVEY} ]; then
9542 skip_env "mds-survey not found" && return
9544 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
9545 { skip "Need MDS version at least 2.2.51"; return; }
9547 local mds=$(facet_host $SINGLEMDS)
9548 local target=$(do_nodes $mds 'lctl dl' | \
9549 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
9551 local cmd1="file_count=1000 thrhi=4"
9552 local cmd2="dir_count=2 layer=mdd stripe_count=0"
9553 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
9554 local cmd="$cmd1 $cmd2 $cmd3"
9556 rm -f ${TMP}/mds_survey*
9558 eval $cmd || error "mds-survey with zero-stripe failed"
9559 cat ${TMP}/mds_survey*
9560 rm -f ${TMP}/mds_survey*
9562 run_test 225a "Metadata survey sanity with zero-stripe"
9565 if [ -z ${MDSSURVEY} ]; then
9566 skip_env "mds-survey not found" && return
9568 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
9569 { skip "Need MDS version at least 2.2.51"; return; }
9571 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
9572 skip_env "Need to mount OST to test" && return
9575 local mds=$(facet_host $SINGLEMDS)
9576 local target=$(do_nodes $mds 'lctl dl' | \
9577 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
9579 local cmd1="file_count=1000 thrhi=4"
9580 local cmd2="dir_count=2 layer=mdd stripe_count=1"
9581 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
9582 local cmd="$cmd1 $cmd2 $cmd3"
9584 rm -f ${TMP}/mds_survey*
9586 eval $cmd || error "mds-survey with stripe_count failed"
9587 cat ${TMP}/mds_survey*
9588 rm -f ${TMP}/mds_survey*
9590 run_test 225b "Metadata survey sanity with stripe_count = 1"
9592 mcreate_path2fid () {
9598 local path=$DIR/$tdir/$name
9603 $MCREATE --mode=$1 --major=$2 --minor=$3 $path || \
9604 error "error: cannot create $desc"
9606 fid=$($LFS path2fid $path)
9608 [ $rc -ne 0 ] && error "error: cannot get fid of a $desc"
9610 fid_path=$($LFS fid2path $DIR $fid)
9612 [ $rc -ne 0 ] && error "error: cannot get path of a $desc by fid"
9614 [ "$path" == "$fid_path" ] || \
9615 error "error: fid2path returned \`$fid_path', expected \`$path'"
9622 mcreate_path2fid 0010666 0 0 fifo "FIFO"
9623 mcreate_path2fid 0020666 1 3 null "character special file (null)"
9624 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
9625 mcreate_path2fid 0040666 0 0 dir "directory"
9626 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
9627 mcreate_path2fid 0100666 0 0 file "regular file"
9628 mcreate_path2fid 0120666 0 0 link "symbolic link"
9629 mcreate_path2fid 0140666 0 0 sock "socket"
9631 run_test 226 "call path2fid and fid2path on files of all type"
9633 # LU-1299 Executing or running ldd on a truncated executable does not
9634 # cause an out-of-memory condition.
9636 dd if=`which date` of=$MOUNT/date bs=1k count=1
9637 chmod +x $MOUNT/date
9639 $MOUNT/date > /dev/null
9640 ldd $MOUNT/date > /dev/null
9643 run_test 227 "running truncated executable does not cause OOM"
9645 # LU-1512 try to reuse idle OI blocks
9647 [ "$FSTYPE" != "ldiskfs" ] && skip "non-ldiskfs backend" && return
9649 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
9650 local myDIR=$DIR/$tdir
9653 #define OBD_FAIL_SEQ_EXHAUST 0x1002
9654 $LCTL set_param fail_loc=0x80001002
9655 createmany -o $myDIR/t- 10000
9656 $LCTL set_param fail_loc=0
9657 # The guard is current the largest FID holder
9659 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
9661 local IDX=$(($SEQ % 64))
9663 do_facet $SINGLEMDS sync
9664 # Make sure journal flushed.
9666 local blk1=$(do_facet $SINGLEMDS \
9667 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
9668 grep Blockcount | awk '{print $4}')
9670 # Remove old files, some OI blocks will become idle.
9671 unlinkmany $myDIR/t- 10000
9672 # Create new files, idle OI blocks should be reused.
9673 createmany -o $myDIR/t- 2000
9674 do_facet $SINGLEMDS sync
9675 # Make sure journal flushed.
9677 local blk2=$(do_facet $SINGLEMDS \
9678 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
9679 grep Blockcount | awk '{print $4}')
9681 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
9683 run_test 228a "try to reuse idle OI blocks"
9686 [ "$FSTYPE" != "ldiskfs" ] && skip "non-ldiskfs backend" && return
9688 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
9689 local myDIR=$DIR/$tdir
9692 #define OBD_FAIL_SEQ_EXHAUST 0x1002
9693 $LCTL set_param fail_loc=0x80001002
9694 createmany -o $myDIR/t- 10000
9695 $LCTL set_param fail_loc=0
9696 # The guard is current the largest FID holder
9698 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
9700 local IDX=$(($SEQ % 64))
9702 do_facet $SINGLEMDS sync
9703 # Make sure journal flushed.
9705 local blk1=$(do_facet $SINGLEMDS \
9706 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
9707 grep Blockcount | awk '{print $4}')
9709 # Remove old files, some OI blocks will become idle.
9710 unlinkmany $myDIR/t- 10000
9713 stop $SINGLEMDS || error "Fail to stop MDT."
9715 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
9717 df $MOUNT || error "Fail to df."
9718 # Create new files, idle OI blocks should be reused.
9719 createmany -o $myDIR/t- 2000
9720 do_facet $SINGLEMDS sync
9721 # Make sure journal flushed.
9723 local blk2=$(do_facet $SINGLEMDS \
9724 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
9725 grep Blockcount | awk '{print $4}')
9727 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
9729 run_test 228b "idle OI blocks can be reused after MDT restart"
9733 [ "$FSTYPE" != "ldiskfs" ] && skip "non-ldiskfs backend" && return
9735 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
9736 local myDIR=$DIR/$tdir
9739 #define OBD_FAIL_SEQ_EXHAUST 0x1002
9740 $LCTL set_param fail_loc=0x80001002
9741 # 20000 files can guarantee there are index nodes in the OI file
9742 createmany -o $myDIR/t- 20000
9743 $LCTL set_param fail_loc=0
9744 # The guard is current the largest FID holder
9746 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
9748 local IDX=$(($SEQ % 64))
9750 do_facet $SINGLEMDS sync
9751 # Make sure journal flushed.
9753 local blk1=$(do_facet $SINGLEMDS \
9754 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
9755 grep Blockcount | awk '{print $4}')
9757 # Remove old files, some OI blocks will become idle.
9758 unlinkmany $myDIR/t- 20000
9760 # The OI file should become empty now
9762 # Create new files, idle OI blocks should be reused.
9763 createmany -o $myDIR/t- 2000
9764 do_facet $SINGLEMDS sync
9765 # Make sure journal flushed.
9767 local blk2=$(do_facet $SINGLEMDS \
9768 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
9769 grep Blockcount | awk '{print $4}')
9771 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
9773 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
9776 # tests that do cleanup/setup should be run at the end
9781 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
9782 $LCTL set_param fail_loc=0x903
9783 # cancel_lru_locks mgc - does not work due to lctl set_param syntax
9784 for ls in /proc/fs/lustre/ldlm/namespaces/MGC*/lru_size; do
9787 FAIL_ON_ERROR=true cleanup
9788 FAIL_ON_ERROR=true setup
9790 run_test 900 "umount should not race with any mgc requeue thread"
9792 complete $(basename $0) $SECONDS
9793 check_and_cleanup_lustre
9794 if [ "$I_MOUNTED" != "yes" ]; then
9795 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true