2 # -*- mode: Bash; tab-width: 4; indent-tabs-mode: t; -*-
3 # vim:autoindent:shiftwidth=4:tabstop=4:
5 # Run select tests by setting ONLY, or as arguments to the script.
6 # Skip specific tests by setting EXCEPT.
8 # e.g. ONLY="22 23" or ONLY="`seq 32 39`" or EXCEPT="31"
12 # bug number for skipped test: 13297 2108 9789 3637 9789 3561 12622 5188
13 ALWAYS_EXCEPT=" 27u 42a 42b 42c 42d 45 51d 68b $SANITY_EXCEPT"
14 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
16 # Tests that fail on uml
17 CPU=`awk '/model/ {print $4}' /proc/cpuinfo`
18 # buffer i/o errs sock spc runas
19 [ "$CPU" = "UML" ] && EXCEPT="$EXCEPT 27m 27n 27o 27p 27q 27r 31d 54a 64b 99a 99b 99c 99d 99e 99f 101a"
22 2.4*) FSTYPE=${FSTYPE:-ext3} ;;
23 2.6*) FSTYPE=${FSTYPE:-ldiskfs} ;;
24 *) error "unsupported kernel" ;;
27 SRCDIR=$(cd $(dirname $0); echo $PWD)
28 export PATH=$PATH:/sbin
32 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
33 CREATETEST=${CREATETEST:-createtest}
35 SETSTRIPE=${SETSTRIPE:-"$LFS setstripe"}
36 GETSTRIPE=${GETSTRIPE:-"$LFS getstripe"}
37 LSTRIPE=${LSTRIPE:-"$LFS setstripe"}
38 LFIND=${LFIND:-"$LFS find"}
39 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
41 MCREATE=${MCREATE:-mcreate}
42 OPENFILE=${OPENFILE:-openfile}
43 OPENUNLINK=${OPENUNLINK:-openunlink}
44 READS=${READS:-"reads"}
45 MUNLINK=${MUNLINK:-munlink}
46 SOCKETSERVER=${SOCKETSERVER:-socketserver}
47 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
48 MEMHOG=${MEMHOG:-memhog}
49 DIRECTIO=${DIRECTIO:-directio}
50 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
51 UMOUNT=${UMOUNT:-"umount -d"}
53 CHECK_GRANT=${CHECK_GRANT:-"yes"}
54 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
56 export NAME=${NAME:-local}
63 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
64 . $LUSTRE/tests/test-framework.sh
66 . ${CONFIG:=$LUSTRE/tests/cfg/${NAME}.sh}
69 [ "$SLOW" = "no" ] && EXCEPT_SLOW="24o 24v 27m 36f 36g 36h 51b 51c 60c 63 64b 68 71 73 77f 78 101a 103 115 120g 124b"
75 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
76 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
85 check_kernel_version() {
87 GOT_VER=$(lctl get_param -n version | awk '/kernel:/ {print $2}')
89 patchless|patchless_client) return 0;;
90 *) [ $GOT_VER -ge $WANT_VER ] && return 0 ;;
92 log "test needs at least kernel version $WANT_VER, running $GOT_VER"
96 if [ "$ONLY" == "cleanup" ]; then
101 check_and_setup_lustre
106 MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid | \
107 awk '{gsub(/_UUID/,""); print $1}' | head -1)
108 LOVNAME=$($LCTL get_param -n llite.*.lov.common_name | tail -n 1)
109 OSTCOUNT=$($LCTL get_param -n lov.$LOVNAME.numobd)
110 STRIPECOUNT=$($LCTL get_param -n lov.$LOVNAME.stripecount)
111 STRIPESIZE=$($LCTL get_param -n lov.$LOVNAME.stripesize)
112 ORIGFREE=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
113 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
115 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
116 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
117 rm -rf $DIR/[Rdfs][0-9]*
119 # $RUNAS_ID may get set incorrectly somewhere else
120 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
122 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
126 if [ "${ONLY}" = "MOUNT" ] ; then
127 echo "Lustre is up, please go on"
131 echo "preparing for tests involving mounts"
132 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
134 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
135 echo # add a newline after mke2fs.
139 OLDDEBUG="`lctl get_param -n debug 2> /dev/null`"
140 lctl set_param debug=-1 2> /dev/null || true
143 $CHECKSTAT -t file $DIR/$tfile || error
145 $CHECKSTAT -a $DIR/$tfile || error
147 run_test 0 "touch .../$tfile ; rm .../$tfile ====================="
150 chmod 0755 $DIR || error
151 $CHECKSTAT -p 0755 $DIR || error
153 run_test 0b "chmod 0755 $DIR ============================="
156 $LCTL get_param mdc.*.import | grep "state: FULL" || error "import not FULL"
157 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" || error "bad target"
159 run_test 0c "check import proc ============================="
164 mkdir $DIR/d1/d2 && error "we expect EEXIST, but not returned"
165 $CHECKSTAT -t dir $DIR/d1/d2 || error
167 run_test 1a "mkdir .../d1; mkdir .../d1/d2 ====================="
172 $CHECKSTAT -a $DIR/d1 || error
174 run_test 1b "rmdir .../d1/d2; rmdir .../d1 ====================="
179 $CHECKSTAT -t file $DIR/d2/f || error
181 run_test 2a "mkdir .../d2; touch .../d2/f ======================"
185 $CHECKSTAT -a $DIR/d2 || error
187 run_test 2b "rm -r .../d2; checkstat .../d2/f ======================"
191 $CHECKSTAT -t dir $DIR/d3 || error
193 run_test 3a "mkdir .../d3 ======================================"
196 if [ ! -d $DIR/d3 ]; then
200 $CHECKSTAT -t file $DIR/d3/f || error
202 run_test 3b "touch .../d3/f ===================================="
206 $CHECKSTAT -a $DIR/d3 || error
208 run_test 3c "rm -r .../d3 ======================================"
212 $CHECKSTAT -t dir $DIR/d4 || error
214 run_test 4a "mkdir .../d4 ======================================"
217 if [ ! -d $DIR/d4 ]; then
221 $CHECKSTAT -t dir $DIR/d4/d2 || error
223 run_test 4b "mkdir .../d4/d2 ==================================="
228 chmod 0707 $DIR/d5/d2
229 $CHECKSTAT -t dir -p 0707 $DIR/d5/d2 || error
231 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2 ============"
235 chmod 0666 $DIR/f6a || error
236 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/f6a || error
238 run_test 6a "touch .../f6a; chmod .../f6a ======================"
241 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
242 if [ ! -f $DIR/f6a ]; then
246 $RUNAS chmod 0444 $DIR/f6a && error
247 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/f6a || error
249 run_test 6b "$RUNAS chmod .../f6a (should return error) =="
252 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
254 chown $RUNAS_ID $DIR/f6c || error
255 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/f6c || error
257 run_test 6c "touch .../f6c; chown .../f6c ======================"
260 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
261 if [ ! -f $DIR/f6c ]; then
263 chown $RUNAS_ID $DIR/f6c
265 $RUNAS chown $UID $DIR/f6c && error
266 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/f6c || error
268 run_test 6d "$RUNAS chown .../f6c (should return error) =="
271 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
273 chgrp $RUNAS_ID $DIR/f6e || error
274 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/f6e || error
276 run_test 6e "touch .../f6e; chgrp .../f6e ======================"
279 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
280 if [ ! -f $DIR/f6e ]; then
282 chgrp $RUNAS_ID $DIR/f6e
284 $RUNAS chgrp $UID $DIR/f6e && error
285 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/f6e || error
287 run_test 6f "$RUNAS chgrp .../f6e (should return error) =="
290 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
291 mkdir $DIR/d6g || error
292 chmod 777 $DIR/d6g || error
293 $RUNAS mkdir $DIR/d6g/d || error
294 chmod g+s $DIR/d6g/d || error
295 mkdir $DIR/d6g/d/subdir
296 $CHECKSTAT -g \#$RUNAS_GID $DIR/d6g/d/subdir || error
298 run_test 6g "Is new dir in sgid dir inheriting group?"
300 test_6h() { # bug 7331
301 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
302 touch $DIR/f6h || error "touch failed"
303 chown $RUNAS_ID:$RUNAS_GID $DIR/f6h || error "initial chown failed"
304 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/f6h && error "chown worked"
305 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/f6h || error
307 run_test 6h "$RUNAS chown RUNAS_ID.0 .../f6h (should return error)"
313 $CHECKSTAT -t file -p 0666 $DIR/d7/f || error
315 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
318 if [ ! -d $DIR/d7 ]; then
322 echo -n foo > $DIR/d7/f2
323 [ "`cat $DIR/d7/f2`" = "foo" ] || error
324 $CHECKSTAT -t file -s 3 $DIR/d7/f2 || error
326 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
332 $CHECKSTAT -t file -p 0666 $DIR/d8/f || error
334 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
340 $CHECKSTAT -t dir $DIR/d9/d2/d3 || error
342 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
348 $CHECKSTAT -t file $DIR/d10/d2/f || error
350 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
355 chmod 0666 $DIR/d11/d2
356 chmod 0705 $DIR/d11/d2
357 $CHECKSTAT -t dir -p 0705 $DIR/d11/d2 || error
359 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
364 chmod 0666 $DIR/d12/f
365 chmod 0654 $DIR/d12/f
366 $CHECKSTAT -t file -p 0654 $DIR/d12/f || error
368 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
372 dd if=/dev/zero of=$DIR/d13/f count=10
374 $CHECKSTAT -t file -s 0 $DIR/d13/f || error
376 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
382 $CHECKSTAT -a $DIR/d14/f || error
384 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
389 mv $DIR/d15/f $DIR/d15/f2
390 $CHECKSTAT -t file $DIR/d15/f2 || error
392 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
398 $CHECKSTAT -a $DIR/d16/f || error
400 run_test 16 "touch .../d16/f; rm -rf .../d16/f ================="
405 ln -s $DIR/d17/f $DIR/d17/l-exist
407 $CHECKSTAT -l $DIR/d17/f $DIR/d17/l-exist || error
408 $CHECKSTAT -f -t f $DIR/d17/l-exist || error
409 rm -f $DIR/d17/l-exist
410 $CHECKSTAT -a $DIR/d17/l-exist || error
412 run_test 17a "symlinks: create, remove (real) =================="
416 ln -s no-such-file $DIR/d17/l-dangle
418 $CHECKSTAT -l no-such-file $DIR/d17/l-dangle || error
419 $CHECKSTAT -fa $DIR/d17/l-dangle || error
420 rm -f $DIR/d17/l-dangle
421 $CHECKSTAT -a $DIR/d17/l-dangle || error
423 run_test 17b "symlinks: create, remove (dangling) =============="
425 test_17c() { # bug 3440 - don't save failed open RPC for replay
427 ln -s foo $DIR/d17/f17c
428 cat $DIR/d17/f17c && error "opened non-existent symlink" || true
430 run_test 17c "symlinks: open dangling (should return error) ===="
434 ln -s foo $DIR/d17/f17d
435 touch $DIR/d17/f17d || error "creating to new symlink"
437 run_test 17d "symlinks: create dangling ========================"
441 local foo=$DIR/$tdir/$tfile
442 ln -s $foo $foo || error "create symlink failed"
443 ls -l $foo || error "ls -l failed"
444 ls $foo && error "ls not failed" || true
446 run_test 17e "symlinks: create recursive symlink (should return error) ===="
450 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/d17f/111
451 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/d17f/222
452 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/d17f/333
453 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/d17f/444
454 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/d17f/555
455 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
458 run_test 17f "symlinks: long and very long symlink name ========================"
462 LONGSYMLINK="$(dd if=/dev/zero bs=4095 count=1 | tr '\0' 'x')"
463 ln -s $LONGSYMLINK $DIR/$tdir/$tfile
466 run_test 17g "symlinks: really long symlink name ==============================="
468 test_17h() { #bug 17378
470 $SETSTRIPE $DIR/$tdir -c -1
471 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
472 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000141
473 touch $DIR/$tdir/$tfile || true
475 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
477 test_17i() { #bug 20018
479 local foo=$DIR/$tdir/$tfile
480 ln -s $foo $foo || error "create symlink failed"
481 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
482 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000143
483 ls -l $foo && error "error not detected"
486 run_test 17i "don't panic on short symlink"
488 test_17k() { #bug 22301
489 rsync --help | grep -q xattr ||
490 skip_env "$(rsync --version| head -1) does not support xattrs"
491 mkdir -p $DIR/{$tdir,$tdir.new}
492 touch $DIR/$tdir/$tfile
493 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
494 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
495 error "rsync failed with xattrs enabled"
497 run_test 17k "symlinks: rsync with xattrs enabled ========================="
501 local short_sym="0123456789"
502 local WDIR=$DIR/${tdir}m
511 # create a long symlink file
512 for ((i = 0; i < 4; ++i)); do
513 long_sym=${long_sym}${long_sym}
516 echo "create 512 short and long symlink files under $WDIR"
517 for ((i = 0; i < 256; ++i)); do
518 ln -sf ${long_sym}"a5a5" $WDIR/long-$i
519 ln -sf ${short_sym}"a5a5" $WDIR/short-$i
527 echo "recreate the 512 symlink files with a shorter string"
528 for ((i = 0; i < 512; ++i)); do
529 # rewrite the symlink file with a shorter string
530 ln -sf ${long_sym} $WDIR/long-$i
531 ln -sf ${short_sym} $WDIR/short-$i
535 devname=$(mdsdevname $mds_index)
536 cmd="$E2FSCK -fnvd $devname"
538 echo "stop and checking mds${mds_index}: $cmd"
539 # e2fsck should not return error
540 stop mds${mds_index} -f
541 do_facet mds${mds_index} $cmd || rc=$?
543 start mds${mds_index} $devname $MDS_MOUNT_OPTS
544 df $MOUNT > /dev/null 2>&1
545 [ $rc -ne 0 ] && error "e2fsck should not report error upon "\
546 "short/long symlink MDT: rc=$rc"
549 run_test 17m "run e2fsck against MDT which contains short/long symlink"
555 run_test 18 "touch .../f ; ls ... =============================="
561 $CHECKSTAT -a $DIR/f19 || error
563 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
566 ls -l $DIR/f19 && error || true
568 run_test 19b "ls -l .../f19 (should return error) =============="
571 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
572 $RUNAS touch $DIR/f19 && error || true
574 run_test 19c "$RUNAS touch .../f19 (should return error) =="
577 cat $DIR/f19 && error || true
579 run_test 19d "cat .../f19 (should return error) =============="
591 $CHECKSTAT -a $DIR/f || error
593 run_test 20 "touch .../f ; ls -l ... ==========================="
597 [ -f $DIR/d21/dangle ] && rm -f $DIR/d21/dangle
598 ln -s dangle $DIR/d21/link
599 echo foo >> $DIR/d21/link
601 $CHECKSTAT -t link $DIR/d21/link || error
602 $CHECKSTAT -f -t file $DIR/d21/link || error
604 run_test 21 "write to dangling link ============================"
609 chown $RUNAS_ID:$RUNAS_GID $WDIR
610 (cd $WDIR || error "cd $WDIR failed";
611 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
613 ls -lR $WDIR/etc || error "ls -lR $WDIR/etc failed"
614 $CHECKSTAT -t dir $WDIR/etc || error "checkstat -t dir failed"
615 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $WDIR/etc || error "checkstat -u failed"
617 run_test 22 "unpack tar archive as non-root user ==============="
622 local file=$DIR/$tdir/$tfile
624 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
625 openfile -f O_CREAT:O_EXCL $file &&
626 error "$file recreate succeeded" || true
628 run_test 23a "O_CREAT|O_EXCL in subdir =========================="
630 test_23b() { # bug 18988
632 local file=$DIR/$tdir/$tfile
635 echo foo > $file || error "write filed"
636 echo bar >> $file || error "append filed"
637 $CHECKSTAT -s 8 $file || error "wrong size"
640 run_test 23b "O_APPEND check =========================="
643 echo '== rename sanity =============================================='
644 echo '-- same directory rename'
647 mv $DIR/R1/f $DIR/R1/g
648 $CHECKSTAT -t file $DIR/R1/g || error
650 run_test 24a "touch .../R1/f; rename .../R1/f .../R1/g ========="
655 mv $DIR/R2/f $DIR/R2/g
656 $CHECKSTAT -a $DIR/R2/f || error
657 $CHECKSTAT -t file $DIR/R2/g || error
659 run_test 24b "touch .../R2/{f,g}; rename .../R2/f .../R2/g ====="
664 mv $DIR/R3/f $DIR/R3/g
665 $CHECKSTAT -a $DIR/R3/f || error
666 $CHECKSTAT -t dir $DIR/R3/g || error
668 run_test 24c "mkdir .../R3/f; rename .../R3/f .../R3/g ========="
673 mrename $DIR/R4/f $DIR/R4/g
674 $CHECKSTAT -a $DIR/R4/f || error
675 $CHECKSTAT -t dir $DIR/R4/g || error
677 run_test 24d "mkdir .../R4/{f,g}; rename .../R4/f .../R4/g ====="
680 echo '-- cross directory renames --'
683 mv $DIR/R5a/f $DIR/R5b/g
684 $CHECKSTAT -a $DIR/R5a/f || error
685 $CHECKSTAT -t file $DIR/R5b/g || error
687 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
691 touch $DIR/R6a/f $DIR/R6b/g
692 mv $DIR/R6a/f $DIR/R6b/g
693 $CHECKSTAT -a $DIR/R6a/f || error
694 $CHECKSTAT -t file $DIR/R6b/g || error
696 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
701 mv $DIR/R7a/d $DIR/R7b/e
702 $CHECKSTAT -a $DIR/R7a/d || error
703 $CHECKSTAT -t dir $DIR/R7b/e || error
705 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
709 mkdir $DIR/R8a/d $DIR/R8b/e
710 mrename $DIR/R8a/d $DIR/R8b/e
711 $CHECKSTAT -a $DIR/R8a/d || error
712 $CHECKSTAT -t dir $DIR/R8b/e || error
714 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
717 echo "-- rename error cases"
721 mrename $DIR/R9/f $DIR/R9/a
722 $CHECKSTAT -t file $DIR/R9/f || error
723 $CHECKSTAT -t dir $DIR/R9/a || error
724 $CHECKSTAT -a $DIR/R9/a/f || error
726 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
730 mrename $DIR/R10/f $DIR/R10/g
731 $CHECKSTAT -t dir $DIR/R10 || error
732 $CHECKSTAT -a $DIR/R10/f || error
733 $CHECKSTAT -a $DIR/R10/g || error
735 run_test 24j "source does not exist ============================"
738 mkdir $DIR/R11a $DIR/R11a/d
740 mv $DIR/R11a/f $DIR/R11a/d
741 $CHECKSTAT -a $DIR/R11a/f || error
742 $CHECKSTAT -t file $DIR/R11a/d/f || error
744 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
746 # bug 2429 - rename foo foo foo creates invalid file
749 multiop $f OcNs || error
751 run_test 24l "Renaming a file to itself ========================"
755 multiop $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
756 # on ext3 this does not remove either the source or target files
757 # though the "expected" operation would be to remove the source
758 $CHECKSTAT -t file ${f} || error "${f} missing"
759 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
761 run_test 24m "Renaming a file to a hard link to itself ========="
765 # this stats the old file after it was renamed, so it should fail
769 $CHECKSTAT ${f}.rename
772 run_test 24n "Statting the old file after renaming (Posix rename 2)"
775 check_kernel_version 37 || return 0
777 rename_many -s random -v -n 10 $DIR/d24o
779 run_test 24o "rename of files during htree split ==============="
783 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
784 mrename $DIR/R12a $DIR/R12b
785 $CHECKSTAT -a $DIR/R12a || error
786 $CHECKSTAT -t dir $DIR/R12b || error
787 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
788 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
790 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
794 DIRINO=`ls -lid $DIR/R13a | awk '{ print $1 }'`
795 multiop_bg_pause $DIR/R13b D_c || return 1
798 mrename $DIR/R13a $DIR/R13b
799 $CHECKSTAT -a $DIR/R13a || error
800 $CHECKSTAT -t dir $DIR/R13b || error
801 DIRINO2=`ls -lid $DIR/R13b | awk '{ print $1 }'`
802 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
804 wait $MULTIPID || error "multiop close failed"
806 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
808 test_24r() { #bug 3789
809 mkdir $DIR/R14a $DIR/R14a/b
810 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
811 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
812 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
814 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
817 mkdir $DIR/R15a $DIR/R15a/b $DIR/R15a/b/c
818 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
819 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
820 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
822 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
824 mkdir $DIR/R16a $DIR/R16a/b $DIR/R16a/b/c
825 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
826 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
827 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
829 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
831 test_24u() { # bug12192
832 multiop $DIR/$tfile C2w$((2048 * 1024))c || error
833 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
835 run_test 24u "create stripe file"
843 local FREE_INODES=`lfs df -i|grep "filesystem summary" | awk '{print $5}'`
844 [ $FREE_INODES -lt $NRFILES ] && \
845 skip "not enough free inodes $FREE_INODES required $NRFILES" && \
849 createmany -m $DIR/d24v/$tfile $NRFILES
852 lctl set_param mdc.*.stats clear
854 ls $DIR/d24v >/dev/null || error "error in listing large dir"
857 # DIRENT_SIZE = 32 bytes for sizeof(struct lu_dirent) +
858 # 8 bytes for name(filename is mostly 5 in this test) +
859 # 8 bytes for luda_type
860 # take into account of overhead in lu_dirpage header and end mark in
861 # each page, plus one in RPC_NUM calculation.
863 RPC_SIZE=$(($(lctl get_param -n mdc.*.max_pages_per_rpc)*$(page_size)))
864 RPC_NUM=$(((NRFILES * DIRENT_SIZE + RPC_SIZE - 1) / RPC_SIZE + 1))
865 mds_readpage=`lctl get_param mdc.*.stats | \
866 awk '/^mds_readpage/ {print $2}'`
867 [ $mds_readpage -gt $RPC_NUM ] && \
868 error "large readdir doesn't take effect"
872 run_test 24v "list directory with large files (handle hash collision, bug: 17560)"
874 test_24w() { # bug21506
876 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
877 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
878 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
879 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
880 [ "$SZ1" = "$SZ2" ] || \
881 error "Error reading at the end of the file $tfile"
883 run_test 24w "Reading a file larger than 4Gb"
886 echo '== symlink sanity ============================================='
890 touch $DIR/s25/foo || error
892 run_test 25a "create file in symlinked directory ==============="
895 [ ! -d $DIR/d25 ] && test_25a
896 $CHECKSTAT -t file $DIR/s25/foo || error
898 run_test 25b "lookup file in symlinked directory ==============="
903 ln -s d26/d26-2 $DIR/s26
904 touch $DIR/s26/foo || error
906 run_test 26a "multiple component symlink ======================="
909 mkdir -p $DIR/d26b/d26-2
910 ln -s d26b/d26-2/foo $DIR/s26-2
911 touch $DIR/s26-2 || error
913 run_test 26b "multiple component symlink at end of lookup ======"
918 ln -s d26.2 $DIR/s26.2-1
919 ln -s s26.2-1 $DIR/s26.2-2
920 ln -s s26.2-2 $DIR/s26.2-3
921 chmod 0666 $DIR/s26.2-3/foo
923 run_test 26c "chain of symlinks ================================"
925 # recursive symlinks (bug 439)
927 ln -s d26-3/foo $DIR/d26-3
929 run_test 26d "create multiple component recursive symlink ======"
932 [ ! -h $DIR/d26-3 ] && test_26d
935 run_test 26e "unlink multiple component recursive symlink ======"
937 # recursive symlinks (bug 7022)
940 mkdir $DIR/$tdir/$tfile || error "mkdir $DIR/$tdir/$tfile failed"
941 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
942 mkdir -p lndir/bar1 || error "mkdir lndir/bar1 failed"
943 mkdir $tfile || error "mkdir $tfile failed"
944 cd $tfile || error "cd $tfile failed"
945 ln -s .. dotdot || error "ln dotdot failed"
946 ln -s dotdot/lndir lndir || error "ln lndir failed"
947 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
948 output=`ls $tfile/$tfile/lndir/bar1`
949 [ "$output" = bar1 ] && error "unexpected output"
950 rm -r $tfile || error "rm $tfile failed"
951 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
953 run_test 26f "rm -r of a directory which has recursive symlink ="
956 echo '== stripe sanity =============================================='
957 mkdir -p $DIR/d27 || error "mkdir failed"
959 $SETSTRIPE $DIR/d27/f0 -c 1 || error "lstripe failed"
960 $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
962 log "== test_27a: write to one stripe file ========================="
963 cp /etc/hosts $DIR/d27/f0 || error
965 run_test 27a "one stripe file =================================="
968 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
970 $SETSTRIPE $DIR/d27/f01 -c 2 || error "lstripe failed"
971 [ `$GETSTRIPE $DIR/d27/f01 | grep -A 10 obdidx | wc -l` -eq 4 ] ||
972 error "two-stripe file doesn't have two stripes"
974 log "== test_27c: write to two stripe file file f01 ================"
975 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
977 run_test 27c "create two stripe file f01 ======================="
981 $SETSTRIPE -c0 -i-1 -s0 $DIR/d27/fdef || error "lstripe failed"
982 $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
983 dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
985 run_test 27d "create file with default settings ================"
989 $SETSTRIPE $DIR/d27/f12 -c 2 || error "lstripe failed"
990 $SETSTRIPE $DIR/d27/f12 -c 2 && error "lstripe succeeded twice"
991 $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
993 run_test 27e "setstripe existing file (should return error) ======"
997 $SETSTRIPE $DIR/d27/fbad -s 100 -i 0 -c 1 && error "lstripe failed"
998 dd if=/dev/zero of=$DIR/d27/f12 bs=4k count=4 || error "dd failed"
999 $GETSTRIPE $DIR/d27/fbad || error "lfs getstripe failed"
1001 run_test 27f "setstripe with bad stripe size (should return error)"
1005 $MCREATE $DIR/d27/fnone || error "mcreate failed"
1007 log "== test 27h: lfs getstripe with no objects ===================="
1008 $GETSTRIPE $DIR/d27/fnone 2>&1 | grep "no stripe info" || error "has object"
1010 log "== test 27i: lfs getstripe with some objects =================="
1011 touch $DIR/d27/fsome || error "touch failed"
1012 $GETSTRIPE $DIR/d27/fsome | grep obdidx || error "missing objects"
1014 run_test 27g "test lfs getstripe ==========================================="
1018 $SETSTRIPE $DIR/d27/f27j -i $OSTCOUNT && error "lstripe failed"||true
1020 run_test 27j "setstripe with bad stripe offset (should return error)"
1022 test_27k() { # bug 2844
1025 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
1026 [ ! -d $DIR/d27 ] && mkdir -p $DIR/d27
1027 $SETSTRIPE $FILE -s 67108864 || error "lstripe failed"
1028 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1029 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
1030 dd if=/dev/zero of=$FILE bs=4k count=1
1031 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1032 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
1034 run_test 27k "limit i_blksize for broken user apps ============="
1038 mcreate $DIR/f27l || error "creating file"
1039 $RUNAS $SETSTRIPE $DIR/f27l -c 1 && \
1040 error "lstripe should have failed" || true
1042 run_test 27l "check setstripe permissions (should return error)"
1045 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1046 if [ $ORIGFREE -gt $MAXFREE ]; then
1047 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1051 $SETSTRIPE $DIR/d27/f27m_1 -i 0 -c 1
1052 dd if=/dev/zero of=$DIR/d27/f27m_1 bs=1024 count=$MAXFREE && \
1053 error "dd should fill OST0"
1055 while $SETSTRIPE $DIR/d27/f27m_$i -i 0 -c 1 ; do
1057 [ $i -gt 256 ] && break
1060 touch $DIR/d27/f27m_$i
1061 [ `$GETSTRIPE $DIR/d27/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] && \
1062 error "OST0 was full but new created file still use it"
1064 touch $DIR/d27/f27m_$i
1065 [ `$GETSTRIPE $DIR/d27/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] && \
1066 error "OST0 was full but new created file still use it"
1070 run_test 27m "create file while OST0 was full =================="
1073 local DELAY=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage | head -n 1 | awk '{print $1 * 2}')
1077 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1078 # if the OST isn't full anymore.
1080 local OSTIDX=${1:-""}
1082 local list=$(comma_list $(osts_nodes))
1083 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1085 do_nodes $list lctl set_param fail_loc=0
1089 exhaust_precreations() {
1092 local FAILIDX=${3:-$OSTIDX}
1095 local MDSIDX=$(get_mds_dir "$DIR/$tdir")
1096 echo OSTIDX=$OSTIDX MDSIDX=$MDSIDX
1098 local OST=$(lfs osts | grep ${OSTIDX}": " | \
1099 awk '{print $2}' | sed -e 's/_UUID$//')
1100 local MDT_INDEX=$(lfs df | grep "\[MDT:$((MDSIDX - 1))\]" | awk '{print $1}' | \
1101 sed -e 's/_UUID$//;s/^.*-//')
1104 local mdtosc_proc1=$(get_mdtosc_proc_path mds${MDSIDX} $OST)
1105 local last_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1106 osc.$mdtosc_proc1.prealloc_last_id)
1107 local next_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1108 osc.$mdtosc_proc1.prealloc_next_id)
1110 local mdtosc_proc2=$(get_mdtosc_proc_path mds${MDSIDX})
1111 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1113 mkdir -p $DIR/$tdir/${OST}
1114 $SETSTRIPE $DIR/$tdir/${OST} -i $OSTIDX -c 1
1115 #define OBD_FAIL_OST_ENOSPC 0x215
1116 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=$FAILIDX
1117 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x215
1118 echo "Creating to objid $last_id on ost $OST..."
1119 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1120 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1121 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=$FAILLOC
1125 exhaust_all_precreations() {
1127 for (( i=0; i < OSTCOUNT; i++ )) ; do
1128 exhaust_precreations $i $1 -1
1133 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1134 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1135 remote_ost_nodsh && skip "remote OST with nodsh" && return
1138 rm -f $DIR/$tdir/$tfile
1139 exhaust_precreations 0 0x80000215
1140 $SETSTRIPE -c -1 $DIR/$tdir
1141 touch $DIR/$tdir/$tfile || error
1142 $GETSTRIPE $DIR/$tdir/$tfile
1145 run_test 27n "create file with some full OSTs =================="
1148 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1149 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1150 remote_ost_nodsh && skip "remote OST with nodsh" && return
1153 rm -f $DIR/$tdir/$tfile
1154 exhaust_all_precreations 0x215
1156 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1161 run_test 27o "create file with all full OSTs (should error) ===="
1164 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1165 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1166 remote_ost_nodsh && skip "remote OST with nodsh" && return
1169 rm -f $DIR/$tdir/$tfile
1172 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1173 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1174 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1176 exhaust_precreations 0 0x80000215
1177 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1178 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1179 $LFS getstripe $DIR/$tdir/$tfile
1183 run_test 27p "append to a truncated file with some full OSTs ==="
1186 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1187 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1188 remote_ost_nodsh && skip "remote OST with nodsh" && return
1191 rm -f $DIR/$tdir/$tfile
1193 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1194 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||error "truncate $DIR/$tdir/$tfile failed"
1195 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1197 exhaust_all_precreations 0x215
1199 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1200 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1204 run_test 27q "append to truncated file with all OSTs full (should error) ==="
1207 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1208 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1209 remote_ost_nodsh && skip "remote OST with nodsh" && return
1212 rm -f $DIR/$tdir/$tfile
1213 exhaust_precreations 0 0x80000215
1215 $SETSTRIPE $DIR/$tdir/$tfile -i 0 -c 2 # && error
1219 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1221 test_27s() { # bug 10725
1223 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1224 local stripe_count=0
1225 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1226 $SETSTRIPE $DIR/$tdir -s $stripe_size -c $stripe_count && \
1227 error "stripe width >= 2^32 succeeded" || true
1230 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1232 test_27t() { # bug 10864
1237 $WLFS getstripe $tfile
1240 run_test 27t "check that utils parse path correctly"
1242 test_27u() { # bug 4900
1243 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1244 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1246 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1247 do_facet $SINGLEMDS lctl set_param fail_loc=0x139
1249 createmany -o $DIR/$tdir/t- 1000
1250 do_facet $SINGLEMDS lctl set_param fail_loc=0
1252 TLOG=$DIR/$tfile.getstripe
1253 $GETSTRIPE $DIR/$tdir > $TLOG
1254 OBJS=`awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj;}' $TLOG`
1255 unlinkmany $DIR/$tdir/t- 1000
1256 [ $OBJS -gt 0 ] && \
1257 error "$OBJS objects created on OST-0. See $TLOG" || pass
1259 run_test 27u "skip object creation on OSC w/o objects =========="
1261 test_27v() { # bug 4900
1262 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1263 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1264 remote_ost_nodsh && skip "remote OST with nodsh" && return
1266 exhaust_all_precreations 0x215
1270 $SETSTRIPE $DIR/$tdir -c 1 # 1 stripe / file
1272 touch $DIR/$tdir/$tfile
1273 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1275 for (( i=0; i < OSTCOUNT; i++ )) ; do
1276 do_facet ost$i lctl set_param fail_loc=0x705
1278 local START=`date +%s`
1279 createmany -o $DIR/$tdir/$tfile 32
1281 local FINISH=`date +%s`
1282 local TIMEOUT=`lctl get_param -n timeout`
1283 local PROCESS=$((FINISH - START))
1284 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1285 error "$FINISH - $START >= $TIMEOUT / 2"
1286 sleep $((TIMEOUT / 2 - PROCESS))
1289 run_test 27v "skip object creation on slow OST ================="
1291 test_27w() { # bug 10997
1292 mkdir -p $DIR/$tdir || error "mkdir failed"
1293 $LSTRIPE $DIR/$tdir/f0 -s 65536 || error "lstripe failed"
1294 size=`$GETSTRIPE $DIR/$tdir/f0 -s`
1295 [ $size -ne 65536 ] && error "stripe size $size != 65536" || true
1296 gsdir=$($LFS getstripe -d $DIR/$tdir)
1297 [ $(echo $gsdir | grep -c stripe_count) -ne 1 ] && error "$LFS getstripe -d $DIR/$tdir failed"
1299 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping multiple stripe count/offset test" && return
1300 for i in `seq 1 $OSTCOUNT`; do
1302 $LSTRIPE $DIR/$tdir/f$i -c $i -i $offset || error "lstripe -c $i -i $offset failed"
1303 count=`$GETSTRIPE -c $DIR/$tdir/f$i`
1304 index=`$GETSTRIPE -o $DIR/$tdir/f$i`
1305 [ $count -ne $i ] && error "stripe count $count != $i" || true
1306 [ $index -ne $offset ] && error "stripe offset $index != $offset" || true
1309 run_test 27w "check lfs setstripe -c -s -i options ============="
1312 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs" && return
1313 OFFSET=$(($OSTCOUNT - 1))
1315 local OST=$(lfs osts | awk '/'${OSTIDX}': / { print $2 }' | sed -e 's/_UUID$//')
1318 $SETSTRIPE $DIR/$tdir -c 1 # 1 stripe per file
1319 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1321 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1322 for i in `seq 0 $OFFSET`; do
1323 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}' | grep -w "$OSTIDX"` ] &&
1324 error "OST0 was degraded but new created file still use it"
1326 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1328 run_test 27x "create files while OST0 is degraded"
1331 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1332 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1334 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1335 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1336 osc.$mdtosc.prealloc_last_id)
1337 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1338 osc.$mdtosc.prealloc_next_id)
1339 local fcount=$((last_id - next_id))
1340 [ $fcount -eq 0 ] && skip "not enough space on OST0" && return
1341 [ $fcount -gt $OSTCOUNT ] && fcount=$OSTCOUNT
1343 MDS_OSCS=`do_facet $SINGLEMDS lctl dl | awk '/[oO][sS][cC].*md[ts]/ { print $4 }'`
1344 OFFSET=$(($OSTCOUNT-1))
1346 for OSC in $MDS_OSCS; do
1347 if [ $OST == -1 ]; then {
1348 OST=`osc_to_ost $OSC`
1350 echo $OSC "is Deactivate:"
1351 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1355 OSTIDX=$(lfs osts | grep ${OST} | awk '{print $1}' | sed -e 's/://')
1357 $SETSTRIPE $DIR/$tdir -c 1 # 1 stripe / file
1359 do_facet ost$OSTIDX lctl set_param -n obdfilter.$OST.degraded 1
1361 createmany -o $DIR/$tdir/$tfile $fcount
1362 do_facet ost$OSTIDX lctl set_param -n obdfilter.$OST.degraded 0
1364 for i in `seq 0 $OFFSET`; do
1365 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "$OSTIDX"` ] || \
1366 error "files created on deactivated OSTs instead of degraded OST"
1368 for OSC in $MDS_OSCS; do
1369 [ `osc_to_ost $OSC` != $OST ] && {
1370 echo $OSC "is activate"
1371 do_facet $SINGLEMDS lctl --device %$OSC activate
1375 run_test 27y "create files while OST0 is degraded and the rest inactive"
1380 local old_ifs="$IFS"
1382 lmm=($($GETSTRIPE -v $1))
1385 fid=($($LFS path2fid $1))
1388 # compare lmm_seq and lu_fid->f_seq
1389 [ ${lmm[4]} = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1390 # compare lmm_object_id and lu_fid->oid
1391 [ ${lmm[6]} = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1393 echo -e "\tseq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}\n\tstripe count: ${lmm[8]}"
1395 [ "$FSTYPE" != "ldiskfs" ] && skip "can not check trusted.fid FSTYPE=$FSTYPE" && return 0
1397 # check the trusted.fid attribute of the OST objects of the file
1398 for (( i=0, j=19; i < ${lmm[8]}; i++, j+=4 )); do
1399 local obdidx=${lmm[$j]}
1400 local devnum=$((obdidx + 1))
1401 local objid=${lmm[$((j+1))]}
1402 local group=${lmm[$((j+3))]}
1403 local dev=$(ostdevname $devnum)
1404 local dir=${MOUNT%/*}/ost$devnum
1405 local mntpt=$(facet_mntpt ost$devnum)
1408 do_facet ost$devnum mount -t $FSTYPE $dev $dir $OST_MOUNT_OPTS ||
1409 { error "mounting $dev as $FSTYPE failed"; return 3; }
1411 obj_filename=$(do_facet ost$devnum find $dir/O/$group -name $objid)
1412 local ff=$(do_facet ost$devnum $LL_DECODE_FILTER_FID $obj_filename)
1417 # compare lmm_seq and filter_fid->ff_parent.f_seq
1418 [ ${ff[11]} = ${lmm[4]} ] || { error "parent SEQ mismatch"; return 4; }
1419 # compare lmm_object_id and filter_fid->ff_parent.f_oid
1420 [ ${ff[12]} = ${lmm[6]} ] || { error "parent OID mismatch"; return 5; }
1421 let stripe=${ff[13]}
1422 [ $stripe -eq $i ] || { error "stripe mismatch"; return 6; }
1424 echo -e "\t\tost $obdidx, objid $objid, group $group"
1425 do_facet ost$devnum umount -d $mntpt
1426 start ost$devnum $dev $OST_MOUNT_OPTS
1432 $SETSTRIPE $DIR/$tdir/$tfile-1 -c 1 -o 0 -s 1m ||
1433 { error "setstripe -c -1 failed"; return 1; }
1434 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
1435 { error "dd 1 mb failed"; return 2; }
1436 $SETSTRIPE $DIR/$tdir/$tfile-2 -c -1 -o $(($OSTCOUNT - 1)) -s 1m ||
1437 { error "setstripe -c 1 failed"; return 3; }
1438 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
1439 { error "dd $OSTCOUNT mb failed"; return 4; }
1442 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
1443 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
1445 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
1447 test_27A() { # b=19102
1448 local restore_size=`$GETSTRIPE -s $MOUNT`
1449 local restore_count=`$GETSTRIPE -c $MOUNT`
1450 local restore_offset=`$GETSTRIPE -o $MOUNT`
1451 $SETSTRIPE -c 0 -o -1 -s 0 $MOUNT
1452 local default_size=`$GETSTRIPE -s $MOUNT`
1453 local default_count=`$GETSTRIPE -c $MOUNT`
1454 local default_offset=`$GETSTRIPE -o $MOUNT`
1455 local dsize=$((1024 * 1024))
1456 [ $default_size -eq $dsize ] || error "stripe size $default_size != $dsize"
1457 [ $default_count -eq 1 ] || error "stripe count $default_count != 1"
1458 [ $default_offset -eq -1 ] || error "stripe offset $default_offset != -1"
1459 $SETSTRIPE -c $restore_count -o $restore_offset -s $restore_size $MOUNT
1461 run_test 27A "check filesystem-wide default LOV EA values"
1463 # createtest also checks that device nodes are created and
1464 # then visible correctly (#2091)
1465 test_28() { # bug 2091
1467 $CREATETEST $DIR/d28/ct || error
1469 run_test 28 "create/mknod/mkdir with bad file types ============"
1472 cancel_lru_locks mdc
1478 declare -i LOCKCOUNTORIG=0
1479 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1480 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
1482 [ $LOCKCOUNTORIG -eq 0 ] && echo "No mdc lock count" && return 1
1484 declare -i LOCKUNUSEDCOUNTORIG=0
1485 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1486 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
1493 declare -i LOCKCOUNTCURRENT=0
1494 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1495 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
1498 declare -i LOCKUNUSEDCOUNTCURRENT=0
1499 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1500 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
1503 if [ "$LOCKCOUNTCURRENT" -gt "$LOCKCOUNTORIG" ]; then
1504 lctl set_param -n ldlm.dump_namespaces ""
1505 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
1506 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1507 log "dumped log to $TMP/test_29.dk (bug 5793)"
1510 if [ "$LOCKUNUSEDCOUNTCURRENT" -gt "$LOCKUNUSEDCOUNTORIG" ]; then
1511 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
1512 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1513 log "dumped log to $TMP/test_29.dk (bug 5793)"
1517 run_test 29 "IT_GETATTR regression ============================"
1519 test_30a() { # was test_30
1520 cp `which ls` $DIR || cp /bin/ls $DIR
1524 run_test 30a "execute binary from Lustre (execve) =============="
1527 cp `which ls` $DIR || cp /bin/ls $DIR
1529 $RUNAS $DIR/ls / || error
1532 run_test 30b "execute binary from Lustre as non-root ==========="
1534 test_30c() { # b=22376
1535 cp `which ls` $DIR || cp /bin/ls $DIR
1537 cancel_lru_locks mdc
1538 cancel_lru_locks osc
1539 $RUNAS $DIR/ls / || error
1542 run_test 30c "execute binary from Lustre without read perms ===="
1545 $OPENUNLINK $DIR/f31 $DIR/f31 || error
1546 $CHECKSTAT -a $DIR/f31 || error
1548 run_test 31a "open-unlink file =================================="
1551 touch $DIR/f31 || error
1552 ln $DIR/f31 $DIR/f31b || error
1553 multiop $DIR/f31b Ouc || error
1554 $CHECKSTAT -t file $DIR/f31 || error
1556 run_test 31b "unlink file with multiple links while open ======="
1559 touch $DIR/f31 || error
1560 ln $DIR/f31 $DIR/f31c || error
1561 multiop_bg_pause $DIR/f31 O_uc || return 1
1563 multiop $DIR/f31c Ouc
1564 kill -USR1 $MULTIPID
1567 run_test 31c "open-unlink file with multiple links ============="
1570 opendirunlink $DIR/d31d $DIR/d31d || error
1571 $CHECKSTAT -a $DIR/d31d || error
1573 run_test 31d "remove of open directory ========================="
1575 test_31e() { # bug 2904
1576 check_kernel_version 34 || return 0
1577 openfilleddirunlink $DIR/d31e || error
1579 run_test 31e "remove of open non-empty directory ==============="
1581 test_31f() { # bug 4554
1584 $SETSTRIPE $DIR/d31f -s 1048576 -c 1
1585 cp /etc/hosts $DIR/d31f
1587 $GETSTRIPE $DIR/d31f/hosts
1588 multiop_bg_pause $DIR/d31f D_c || return 1
1591 rm -rv $DIR/d31f || error "first of $DIR/d31f"
1593 $SETSTRIPE $DIR/d31f -s 1048576 -c 1
1594 cp /etc/hosts $DIR/d31f
1596 $GETSTRIPE $DIR/d31f/hosts
1597 multiop_bg_pause $DIR/d31f D_c || return 1
1600 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
1601 wait $MULTIPID || error "first opendir $MULTIPID failed"
1605 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
1606 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
1609 run_test 31f "remove of open directory with open-unlink file ==="
1612 echo "-- cross directory link --"
1613 mkdir $DIR/d31g{a,b}
1615 ln $DIR/d31ga/f $DIR/d31gb/g
1616 $CHECKSTAT -t file $DIR/d31ga/f || error "source"
1617 [ `stat -c%h $DIR/d31ga/f` == '2' ] || error "source nlink"
1618 $CHECKSTAT -t file $DIR/d31gb/g || error "target"
1619 [ `stat -c%h $DIR/d31gb/g` == '2' ] || error "target nlink"
1621 run_test 31g "cross directory link==============="
1624 echo "-- cross directory link --"
1628 ln $DIR/d31h/f $DIR/d31h/dir/g
1629 $CHECKSTAT -t file $DIR/d31h/f || error "source"
1630 [ `stat -c%h $DIR/d31h/f` == '2' ] || error "source nlink"
1631 $CHECKSTAT -t file $DIR/d31h/dir/g || error "target"
1632 [ `stat -c%h $DIR/d31h/dir/g` == '2' ] || error "target nlink"
1634 run_test 31h "cross directory link under child==============="
1637 echo "-- cross directory link --"
1640 touch $DIR/d31i/dir/f
1641 ln $DIR/d31i/dir/f $DIR/d31i/g
1642 $CHECKSTAT -t file $DIR/d31i/dir/f || error "source"
1643 [ `stat -c%h $DIR/d31i/dir/f` == '2' ] || error "source nlink"
1644 $CHECKSTAT -t file $DIR/d31i/g || error "target"
1645 [ `stat -c%h $DIR/d31i/g` == '2' ] || error "target nlink"
1647 run_test 31i "cross directory link under parent==============="
1652 mkdir $DIR/d31j/dir1
1653 ln $DIR/d31j/dir1 $DIR/d31j/dir2 && error "ln for dir"
1654 link $DIR/d31j/dir1 $DIR/d31j/dir3 && error "link for dir"
1655 mlink $DIR/d31j/dir1 $DIR/d31j/dir4 && error "mlink for dir"
1656 mlink $DIR/d31j/dir1 $DIR/d31j/dir1 && error "mlink to the same dir"
1659 run_test 31j "link for directory==============="
1665 touch $DIR/d31k/exist
1666 mlink $DIR/d31k/s $DIR/d31k/t || error "mlink"
1667 mlink $DIR/d31k/s $DIR/d31k/exist && error "mlink to exist file"
1668 mlink $DIR/d31k/s $DIR/d31k/s && error "mlink to the same file"
1669 mlink $DIR/d31k/s $DIR/d31k && error "mlink to parent dir"
1670 mlink $DIR/d31k $DIR/d31k/s && error "mlink parent dir to target"
1671 mlink $DIR/d31k/not-exist $DIR/d31k/foo && error "mlink non-existing to new"
1672 mlink $DIR/d31k/not-exist $DIR/d31k/s && error "mlink non-existing to exist"
1675 run_test 31k "link to file: the same, non-existing, dir==============="
1681 touch $DIR/d31m2/exist
1682 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
1683 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
1684 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
1685 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
1686 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
1687 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
1690 run_test 31m "link to file: the same, non-existing, dir==============="
1693 echo "== more mountpoints and symlinks ================="
1694 [ -e $DIR/d32a ] && rm -fr $DIR/d32a
1695 mkdir -p $DIR/d32a/ext2-mountpoint
1696 mount -t ext2 -o loop $EXT2_DEV $DIR/d32a/ext2-mountpoint || error
1697 $CHECKSTAT -t dir $DIR/d32a/ext2-mountpoint/.. || error
1698 $UMOUNT $DIR/d32a/ext2-mountpoint || error
1700 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
1703 [ -e $DIR/d32b ] && rm -fr $DIR/d32b
1704 mkdir -p $DIR/d32b/ext2-mountpoint
1705 mount -t ext2 -o loop $EXT2_DEV $DIR/d32b/ext2-mountpoint || error
1706 ls -al $DIR/d32b/ext2-mountpoint/.. || error
1707 $UMOUNT $DIR/d32b/ext2-mountpoint || error
1709 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
1712 [ -e $DIR/d32c ] && rm -fr $DIR/d32c
1713 mkdir -p $DIR/d32c/ext2-mountpoint
1714 mount -t ext2 -o loop $EXT2_DEV $DIR/d32c/ext2-mountpoint || error
1715 mkdir -p $DIR/d32c/d2/test_dir
1716 $CHECKSTAT -t dir $DIR/d32c/ext2-mountpoint/../d2/test_dir || error
1717 $UMOUNT $DIR/d32c/ext2-mountpoint || error
1719 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
1722 [ -e $DIR/d32d ] && rm -fr $DIR/d32d
1723 mkdir -p $DIR/d32d/ext2-mountpoint
1724 mount -t ext2 -o loop $EXT2_DEV $DIR/d32d/ext2-mountpoint || error
1725 mkdir -p $DIR/d32d/d2/test_dir
1726 ls -al $DIR/d32d/ext2-mountpoint/../d2/test_dir || error
1727 $UMOUNT $DIR/d32d/ext2-mountpoint || error
1729 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
1732 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
1733 mkdir -p $DIR/d32e/tmp
1734 TMP_DIR=$DIR/d32e/tmp
1735 ln -s $DIR/d32e $TMP_DIR/symlink11
1736 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1737 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
1738 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
1740 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
1743 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
1744 mkdir -p $DIR/d32f/tmp
1745 TMP_DIR=$DIR/d32f/tmp
1746 ln -s $DIR/d32f $TMP_DIR/symlink11
1747 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1748 ls $DIR/d32f/tmp/symlink11 || error
1749 ls $DIR/d32f/symlink01 || error
1751 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
1754 TMP_DIR=$DIR/$tdir/tmp
1755 mkdir -p $TMP_DIR $DIR/${tdir}2
1756 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
1757 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1758 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
1759 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
1760 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
1761 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
1763 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
1766 rm -fr $DIR/$tdir $DIR/${tdir}2
1767 TMP_DIR=$DIR/$tdir/tmp
1768 mkdir -p $TMP_DIR $DIR/${tdir}2
1769 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
1770 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1771 ls $TMP_DIR/symlink12 || error
1772 ls $DIR/$tdir/symlink02 || error
1774 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
1777 [ -e $DIR/d32i ] && rm -fr $DIR/d32i
1778 mkdir -p $DIR/d32i/ext2-mountpoint
1779 mount -t ext2 -o loop $EXT2_DEV $DIR/d32i/ext2-mountpoint || error
1780 touch $DIR/d32i/test_file
1781 $CHECKSTAT -t file $DIR/d32i/ext2-mountpoint/../test_file || error
1782 $UMOUNT $DIR/d32i/ext2-mountpoint || error
1784 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
1787 [ -e $DIR/d32j ] && rm -fr $DIR/d32j
1788 mkdir -p $DIR/d32j/ext2-mountpoint
1789 mount -t ext2 -o loop $EXT2_DEV $DIR/d32j/ext2-mountpoint || error
1790 touch $DIR/d32j/test_file
1791 cat $DIR/d32j/ext2-mountpoint/../test_file || error
1792 $UMOUNT $DIR/d32j/ext2-mountpoint || error
1794 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
1798 mkdir -p $DIR/d32k/ext2-mountpoint
1799 mount -t ext2 -o loop $EXT2_DEV $DIR/d32k/ext2-mountpoint
1800 mkdir -p $DIR/d32k/d2
1801 touch $DIR/d32k/d2/test_file || error
1802 $CHECKSTAT -t file $DIR/d32k/ext2-mountpoint/../d2/test_file || error
1803 $UMOUNT $DIR/d32k/ext2-mountpoint || error
1805 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
1809 mkdir -p $DIR/d32l/ext2-mountpoint
1810 mount -t ext2 -o loop $EXT2_DEV $DIR/d32l/ext2-mountpoint || error
1811 mkdir -p $DIR/d32l/d2
1812 touch $DIR/d32l/d2/test_file
1813 cat $DIR/d32l/ext2-mountpoint/../d2/test_file || error
1814 $UMOUNT $DIR/d32l/ext2-mountpoint || error
1816 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
1820 mkdir -p $DIR/d32m/tmp
1821 TMP_DIR=$DIR/d32m/tmp
1822 ln -s $DIR $TMP_DIR/symlink11
1823 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1824 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
1825 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
1827 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
1831 mkdir -p $DIR/d32n/tmp
1832 TMP_DIR=$DIR/d32n/tmp
1833 ln -s $DIR $TMP_DIR/symlink11
1834 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1835 ls -l $DIR/d32n/tmp/symlink11 || error
1836 ls -l $DIR/d32n/symlink01 || error
1838 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
1841 rm -fr $DIR/d32o $DIR/$tfile
1843 mkdir -p $DIR/d32o/tmp
1844 TMP_DIR=$DIR/d32o/tmp
1845 ln -s $DIR/$tfile $TMP_DIR/symlink12
1846 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1847 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
1848 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
1849 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
1850 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
1852 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
1862 mkdir -p $DIR/d32p/tmp
1864 TMP_DIR=$DIR/d32p/tmp
1866 ln -s $DIR/$tfile $TMP_DIR/symlink12
1868 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1870 cat $DIR/d32p/tmp/symlink12 || error
1872 cat $DIR/d32p/symlink02 || error
1875 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
1878 [ -e $DIR/d32q ] && rm -fr $DIR/d32q
1880 touch $DIR/d32q/under_the_mount
1881 mount -t ext2 -o loop $EXT2_DEV $DIR/d32q
1882 ls $DIR/d32q/under_the_mount && error || true
1883 $UMOUNT $DIR/d32q || error
1885 run_test 32q "stat follows mountpoints in Lustre (should return error)"
1888 [ -e $DIR/d32r ] && rm -fr $DIR/d32r
1890 touch $DIR/d32r/under_the_mount
1891 mount -t ext2 -o loop $EXT2_DEV $DIR/d32r
1892 ls $DIR/d32r | grep -q under_the_mount && error || true
1893 $UMOUNT $DIR/d32r || error
1895 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
1900 chmod 444 $DIR/$tfile
1901 chown $RUNAS_ID $DIR/$tfile
1903 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
1906 run_test 33 "write file with mode 444 (should return error) ===="
1911 chown $RUNAS_ID $DIR/d33
1912 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
1913 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
1914 error "open RDWR" || true
1916 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
1921 chown $RUNAS_ID $DIR/d33
1922 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33 && error "create" || true
1924 run_test 33b "test open file with malformed flags (No panic and return error)"
1935 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
1938 for ostnum in $(seq $OSTCOUNT); do
1939 # test-framework's OST numbering is one-based, while Lustre's
1941 ostname=$(printf "$FSNAME-OST%.4d" $((ostnum - 1)))
1942 # Parsing llobdstat's output sucks; we could grep the /proc
1943 # path, but that's likely to not be as portable as using the
1944 # llobdstat utility. So we parse lctl output instead.
1945 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
1946 obdfilter/$ostname/stats |
1947 awk '/^write_bytes/ {print $7}' )
1948 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
1949 if (( ${write_bytes:-0} > 0 ))
1956 $all_zeros || return 0
1959 echo foo > $DIR/d33/bar
1963 # Total up write_bytes after writing. We'd better find non-zeros.
1964 for ostnum in $(seq $OSTCOUNT); do
1965 ostname=$(printf "$FSNAME-OST%.4d" $((ostnum - 1)))
1966 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
1967 obdfilter/$ostname/stats |
1968 awk '/^write_bytes/ {print $7}' )
1969 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
1970 if (( ${write_bytes:-0} > 0 ))
1979 for ostnum in $(seq $OSTCOUNT); do
1980 ostname=$(printf "$FSNAME-OST%.4d" $((ostnum - 1)))
1981 echo "Check that write_bytes is present in obdfilter/*/stats:"
1982 do_facet ost$ostnum lctl get_param -n \
1983 obdfilter/$ostname/stats
1985 error "OST not keeping write_bytes stats (b22312)"
1988 run_test 33c "test llobdstat and write_bytes"
1990 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
1993 $MCREATE $DIR/f34 || error
1994 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
1995 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
1996 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
1997 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1999 run_test 34a "truncate file that has not been opened ==========="
2002 [ ! -f $DIR/f34 ] && test_34a
2003 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2004 $OPENFILE -f O_RDONLY $DIR/f34
2005 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2006 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2008 run_test 34b "O_RDONLY opening file doesn't create objects ====="
2011 [ ! -f $DIR/f34 ] && test_34a
2012 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2013 $OPENFILE -f O_RDWR $DIR/f34
2014 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2015 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2017 run_test 34c "O_RDWR opening file-with-size works =============="
2020 [ ! -f $DIR/f34 ] && test_34a
2021 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2022 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2025 run_test 34d "write to sparse file ============================="
2029 $MCREATE $DIR/f34e || error
2030 $TRUNCATE $DIR/f34e 1000 || error
2031 $CHECKSTAT -s 1000 $DIR/f34e || error
2032 $OPENFILE -f O_RDWR $DIR/f34e
2033 $CHECKSTAT -s 1000 $DIR/f34e || error
2035 run_test 34e "create objects, some with size and some without =="
2037 test_34f() { # bug 6242, 6243
2040 $MCREATE $DIR/f34f || error
2041 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
2042 dd if=$DIR/f34f of=$TMP/f34f
2043 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
2044 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
2045 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
2046 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
2047 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
2049 run_test 34f "read from a file with no objects until EOF ======="
2052 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
2053 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
2054 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
2055 cancel_lru_locks osc
2056 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
2057 error "wrong size after lock cancel"
2059 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
2060 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2061 error "expanding truncate failed"
2062 cancel_lru_locks osc
2063 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2064 error "wrong expanded size after lock cancel"
2066 run_test 34g "truncate long file ==============================="
2069 cp /bin/sh $DIR/f35a
2071 chown $RUNAS_ID $DIR/f35a
2072 $RUNAS $DIR/f35a && error || true
2075 run_test 35a "exec file with mode 444 (should return and not leak) ====="
2079 utime $DIR/f36 || error
2081 run_test 36a "MDS utime check (mknod, utime) ==================="
2085 utime $DIR/f36 || error
2087 run_test 36b "OST utime check (open, utime) ===================="
2092 chown $RUNAS_ID $DIR/d36
2093 $RUNAS utime $DIR/d36/f36 || error
2095 run_test 36c "non-root MDS utime check (mknod, utime) =========="
2098 [ ! -d $DIR/d36 ] && test_36c
2099 echo "" > $DIR/d36/f36
2100 $RUNAS utime $DIR/d36/f36 || error
2102 run_test 36d "non-root OST utime check (open, utime) ==========="
2105 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
2107 touch $DIR/$tdir/$tfile
2108 $RUNAS utime $DIR/$tdir/$tfile && \
2109 error "utime worked, expected failure" || true
2111 run_test 36e "utime on non-owned file (should return error) ===="
2115 local LANG_SAVE=$LANG
2116 local LC_LANG_SAVE=$LC_LANG
2117 export LANG=C LC_LANG=C # for date language
2119 DATESTR="Dec 20 2000"
2121 lctl set_param fail_loc=$fl
2123 cp /etc/hosts $DIR/$tdir/$tfile
2124 sync & # write RPC generated with "current" inode timestamp, but delayed
2126 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
2127 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
2128 cancel_lru_locks osc
2129 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
2131 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
2132 echo "BEFORE: $LS_BEFORE" && \
2133 echo "AFTER : $LS_AFTER" && \
2134 echo "WANT : $DATESTR" && \
2135 error "$DIR/$tdir/$tfile timestamps changed" || true
2137 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
2141 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2142 subr_36fh "0x80000214"
2144 run_test 36f "utime on file racing with OST BRW write =========="
2147 remote_ost_nodsh && skip "remote OST with nodsh" && return
2153 fmd_max_age=$(do_facet ost1 \
2154 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
2157 fmd_before=$(do_facet ost1 \
2158 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2159 touch $DIR/$tdir/$tfile
2160 sleep $((fmd_max_age + 12))
2161 fmd_after=$(do_facet ost1 \
2162 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2164 echo "fmd_before: $fmd_before"
2165 echo "fmd_after: $fmd_after"
2166 [ "$fmd_after" -gt "$fmd_before" ] && \
2167 echo "AFTER: $fmd_after > BEFORE: $fmd_before" && \
2168 error "fmd didn't expire after ping" || true
2170 run_test 36g "filter mod data cache expiry ====================="
2173 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
2174 subr_36fh "0x80000227"
2176 run_test 36h "utime on file racing with OST BRW write =========="
2180 echo f > $DIR/$tdir/fbugfile
2181 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2182 ls $DIR/$tdir | grep "\<fbugfile\>" && error
2183 $UMOUNT $DIR/$tdir || error
2184 rm -f $DIR/$tdir/fbugfile || error
2186 run_test 37 "ls a mounted file system to check old content ====="
2189 local file=$DIR/$tfile
2191 openfile -f O_DIRECTORY $file
2194 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
2195 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
2197 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
2201 touch $DIR/${tfile}2
2202 # ls -l $DIR/$tfile $DIR/${tfile}2
2203 # ls -lu $DIR/$tfile $DIR/${tfile}2
2204 # ls -lc $DIR/$tfile $DIR/${tfile}2
2206 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
2207 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
2209 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
2211 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
2213 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
2214 error "O_TRUNC didn't change timestamps"
2217 run_test 39 "mtime changed on create ==========================="
2221 cp -p /etc/passwd $DIR/$tdir/fopen
2222 cp -p /etc/passwd $DIR/$tdir/flink
2223 cp -p /etc/passwd $DIR/$tdir/funlink
2224 cp -p /etc/passwd $DIR/$tdir/frename
2225 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
2228 echo "aaaaaa" >> $DIR/$tdir/fopen
2229 echo "aaaaaa" >> $DIR/$tdir/flink
2230 echo "aaaaaa" >> $DIR/$tdir/funlink
2231 echo "aaaaaa" >> $DIR/$tdir/frename
2233 local open_new=`stat -c %Y $DIR/$tdir/fopen`
2234 local link_new=`stat -c %Y $DIR/$tdir/flink`
2235 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
2236 local rename_new=`stat -c %Y $DIR/$tdir/frename`
2238 cat $DIR/$tdir/fopen > /dev/null
2239 ln $DIR/$tdir/flink $DIR/$tdir/flink2
2240 rm -f $DIR/$tdir/funlink2
2241 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
2243 for (( i=0; i < 2; i++ )) ; do
2244 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
2245 local link_new2=`stat -c %Y $DIR/$tdir/flink`
2246 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
2247 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
2249 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
2250 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
2251 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
2252 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
2254 cancel_lru_locks osc
2255 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2258 run_test 39b "mtime change on open, link, unlink, rename ======"
2260 # this should be set to past
2261 TEST_39_MTIME=`date -d "1 year ago" +%s`
2267 local mtime0=`stat -c %Y $DIR1/$tfile`
2269 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2270 local mtime1=`stat -c %Y $DIR1/$tfile`
2271 [ "$mtime1" = $TEST_39_MTIME ] || \
2272 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
2275 echo hello >> $DIR1/$tfile
2277 local mtime2=`stat -c %Y $DIR1/$tfile`
2278 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
2279 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
2281 mv $DIR1/$tfile $DIR1/$tfile-1
2283 for (( i=0; i < 2; i++ )) ; do
2284 local mtime3=`stat -c %Y $DIR1/$tfile-1`
2285 [ "$mtime2" = "$mtime3" ] || \
2286 error "mtime ($mtime2) changed (to $mtime3) on rename"
2288 cancel_lru_locks osc
2289 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2292 run_test 39c "mtime change on rename ==========================="
2298 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2300 for (( i=0; i < 2; i++ )) ; do
2301 local mtime=`stat -c %Y $DIR1/$tfile`
2302 [ $mtime = $TEST_39_MTIME ] || \
2303 error "mtime($mtime) is not set to $TEST_39_MTIME"
2305 cancel_lru_locks osc
2306 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2309 run_test 39d "create, utime, stat =============================="
2314 local mtime1=`stat -c %Y $DIR1/$tfile`
2316 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2318 for (( i=0; i < 2; i++ )) ; do
2319 local mtime2=`stat -c %Y $DIR1/$tfile`
2320 [ $mtime2 = $TEST_39_MTIME ] || \
2321 error "mtime($mtime2) is not set to $TEST_39_MTIME"
2323 cancel_lru_locks osc
2324 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2327 run_test 39e "create, stat, utime, stat ========================"
2332 mtime1=`stat -c %Y $DIR1/$tfile`
2335 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2337 for (( i=0; i < 2; i++ )) ; do
2338 local mtime2=`stat -c %Y $DIR1/$tfile`
2339 [ $mtime2 = $TEST_39_MTIME ] || \
2340 error "mtime($mtime2) is not set to $TEST_39_MTIME"
2342 cancel_lru_locks osc
2343 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2346 run_test 39f "create, stat, sleep, utime, stat ================="
2350 echo hello >> $DIR1/$tfile
2351 local mtime1=`stat -c %Y $DIR1/$tfile`
2354 chmod o+r $DIR1/$tfile
2356 for (( i=0; i < 2; i++ )) ; do
2357 local mtime2=`stat -c %Y $DIR1/$tfile`
2358 [ "$mtime1" = "$mtime2" ] || \
2359 error "lost mtime: $mtime2, should be $mtime1"
2361 cancel_lru_locks osc
2362 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2365 run_test 39g "write, chmod, stat ==============================="
2373 echo hello >> $DIR1/$tfile
2374 local mtime1=`stat -c %Y $DIR1/$tfile`
2376 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2378 if [ "$d1" != "$d2" ]; then
2379 echo "write and touch not within one second"
2381 for (( i=0; i < 2; i++ )) ; do
2382 local mtime2=`stat -c %Y $DIR1/$tfile`
2383 [ "$mtime2" = $TEST_39_MTIME ] || \
2384 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
2386 cancel_lru_locks osc
2387 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2391 run_test 39h "write, utime within one second, stat ============="
2397 echo hello >> $DIR1/$tfile
2398 local mtime1=`stat -c %Y $DIR1/$tfile`
2400 mv $DIR1/$tfile $DIR1/$tfile-1
2402 for (( i=0; i < 2; i++ )) ; do
2403 local mtime2=`stat -c %Y $DIR1/$tfile-1`
2405 [ "$mtime1" = "$mtime2" ] || \
2406 error "lost mtime: $mtime2, should be $mtime1"
2408 cancel_lru_locks osc
2409 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2412 run_test 39i "write, rename, stat =============================="
2418 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
2420 local mtime1=`stat -c %Y $DIR1/$tfile`
2422 mv $DIR1/$tfile $DIR1/$tfile-1
2424 kill -USR1 $multipid
2425 wait $multipid || error "multiop close failed"
2427 for (( i=0; i < 2; i++ )) ; do
2428 local mtime2=`stat -c %Y $DIR1/$tfile-1`
2429 [ "$mtime1" = "$mtime2" ] || \
2430 error "mtime is lost on close: $mtime2, should be $mtime1"
2432 cancel_lru_locks osc
2433 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2436 run_test 39j "write, rename, close, stat ======================="
2442 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
2444 local mtime1=`stat -c %Y $DIR1/$tfile`
2446 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2448 kill -USR1 $multipid
2449 wait $multipid || error "multiop close failed"
2451 for (( i=0; i < 2; i++ )) ; do
2452 local mtime2=`stat -c %Y $DIR1/$tfile`
2454 [ "$mtime2" = $TEST_39_MTIME ] || \
2455 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
2457 cancel_lru_locks osc
2458 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2461 run_test 39k "write, utime, close, stat ========================"
2463 # this should be set to future
2464 TEST_39_ATIME=`date -d "1 year" +%s`
2467 local atime_diff=$(do_facet $SINGLEMDS lctl get_param -n mdd.*.atime_diff)
2471 # test setting directory atime to future
2472 touch -a -d @$TEST_39_ATIME $DIR/$tdir
2473 local atime=$(stat -c %X $DIR/$tdir)
2474 [ "$atime" = $TEST_39_ATIME ] || \
2475 error "atime is not set to future: $atime, should be $TEST_39_ATIME"
2477 # test setting directory atime from future to now
2478 local d1=$(date +%s)
2480 local d2=$(date +%s)
2482 cancel_lru_locks mdc
2483 atime=$(stat -c %X $DIR/$tdir)
2484 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
2485 error "atime is not updated from future: $atime, should be $d1<atime<$d2"
2487 do_facet $SINGLEMDS lctl set_param -n mdd.*.atime_diff=2
2490 # test setting directory atime when now > dir atime + atime_diff
2494 cancel_lru_locks mdc
2495 atime=$(stat -c %X $DIR/$tdir)
2496 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
2497 error "atime is not updated : $atime, should be $d2"
2499 do_facet $SINGLEMDS lctl set_param -n mdd.*.atime_diff=60
2502 # test not setting directory atime when now < dir atime + atime_diff
2504 cancel_lru_locks mdc
2505 atime=$(stat -c %X $DIR/$tdir)
2506 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
2507 error "atime is updated to $atime, should remain $d1<atime<$d2"
2509 do_facet $SINGLEMDS lctl set_param -n mdd.*.atime_diff=$atime_diff
2511 run_test 39l "directory atime update ==========================="
2516 local far_past_mtime=$(date -d "May 29 1953" +%s)
2517 local far_past_atime=$(date -d "Dec 17 1903" +%s)
2519 touch -m -d @$far_past_mtime $DIR1/$tfile
2520 touch -a -d @$far_past_atime $DIR1/$tfile
2522 for (( i=0; i < 2; i++ )) ; do
2523 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
2524 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
2525 error "atime or mtime set incorrectly"
2527 cancel_lru_locks osc
2528 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2531 run_test 39m "test atime and mtime before 1970"
2534 dd if=/dev/zero of=$DIR/f40 bs=4096 count=1
2535 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/f40 && error
2536 $CHECKSTAT -t file -s 4096 $DIR/f40 || error
2538 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
2542 small_write $DIR/f41 18
2544 run_test 41 "test small file write + fstat ====================="
2546 count_ost_writes() {
2547 lctl get_param -n osc.*.stats |
2548 awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }'
2555 BG_DIRTY_RATIO_SAVE=10
2556 MAX_BG_DIRTY_RATIO=25
2560 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
2561 # dirty_ratio, dirty_background_ratio
2562 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
2563 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
2564 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
2565 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
2567 # if file not here, we are a 2.4 kernel
2568 kill -CONT `pidof kupdated`
2573 # setup the trap first, so someone cannot exit the test at the
2574 # exact wrong time and mess up a machine
2575 trap start_writeback EXIT
2576 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
2577 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
2578 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
2579 sysctl -w vm.dirty_writeback_centisecs=0
2580 sysctl -w vm.dirty_writeback_centisecs=0
2581 # save and increase /proc/sys/vm/dirty_ratio
2582 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
2583 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
2584 # save and increase /proc/sys/vm/dirty_background_ratio
2585 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
2586 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
2588 # if file not here, we are a 2.4 kernel
2589 kill -STOP `pidof kupdated`
2593 # ensure that all stripes have some grant before we test client-side cache
2595 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
2596 dd if=/dev/zero of=$i bs=4k count=1
2601 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
2602 # file truncation, and file removal.
2605 cancel_lru_locks osc
2607 sync; sleep 1; sync # just to be safe
2608 BEFOREWRITES=`count_ost_writes`
2609 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
2610 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
2611 AFTERWRITES=`count_ost_writes`
2612 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
2613 error "$BEFOREWRITES < $AFTERWRITES"
2616 run_test 42a "ensure that we don't flush on close =============="
2620 cancel_lru_locks osc
2623 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
2624 BEFOREWRITES=`count_ost_writes`
2625 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
2626 AFTERWRITES=`count_ost_writes`
2627 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
2628 error "$BEFOREWRITES < $AFTERWRITES on unlink"
2630 BEFOREWRITES=`count_ost_writes`
2631 sync || error "sync: $?"
2632 AFTERWRITES=`count_ost_writes`
2633 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
2634 error "$BEFOREWRITES < $AFTERWRITES on sync"
2636 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
2640 run_test 42b "test destroy of file with cached dirty data ======"
2642 # if these tests just want to test the effect of truncation,
2643 # they have to be very careful. consider:
2644 # - the first open gets a {0,EOF}PR lock
2645 # - the first write conflicts and gets a {0, count-1}PW
2646 # - the rest of the writes are under {count,EOF}PW
2647 # - the open for truncate tries to match a {0,EOF}PR
2648 # for the filesize and cancels the PWs.
2649 # any number of fixes (don't get {0,EOF} on open, match
2650 # composite locks, do smarter file size management) fix
2651 # this, but for now we want these tests to verify that
2652 # the cancellation with truncate intent works, so we
2653 # start the file with a full-file pw lock to match against
2654 # until the truncate.
2659 cancel_lru_locks osc
2661 # prime the file with 0,EOF PW to match
2665 # now the real test..
2666 dd if=/dev/zero of=$file bs=1024 count=100
2667 BEFOREWRITES=`count_ost_writes`
2668 $TRUNCATE $file $offset
2669 cancel_lru_locks osc
2670 AFTERWRITES=`count_ost_writes`
2676 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
2677 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
2680 run_test 42c "test partial truncate of file with cached dirty data"
2684 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
2685 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
2688 run_test 42d "test complete truncate of file with cached dirty data"
2690 test_42e() { # bug22074
2691 local TDIR=$DIR/${tdir}e
2692 local pagesz=$(page_size)
2694 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
2695 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
2700 $LFS setstripe -c 1 $TDIR
2701 createmany -o $TDIR/f $files
2703 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
2705 # we assume that with $OSTCOUNT files, at least one of them will
2706 # be allocated on OST0.
2707 warmup_files=$((OSTCOUNT * max_dirty_mb))
2708 createmany -o $TDIR/w $warmup_files
2710 # write a large amount of data into one file and sync, to get good
2711 # avail_grant number from OST.
2712 for ((i=0; i<$warmup_files; i++)); do
2713 idx=$($LFS getstripe -i $TDIR/w$i)
2714 [ $idx -ne 0 ] && continue
2715 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
2718 [ $i -gt $warmup_files ] && error "OST0 is still cold"
2720 $LCTL get_param $proc_osc0/cur_dirty_bytes
2721 $LCTL get_param $proc_osc0/cur_grant_bytes
2723 # create as much dirty pages as we can while not to trigger the actual
2724 # RPCs directly. but depends on the env, VFS may trigger flush during this
2725 # period, hopefully we are good.
2726 for ((i=0; i<$warmup_files; i++)); do
2727 idx=$($LFS getstripe -i $TDIR/w$i)
2728 [ $idx -ne 0 ] && continue
2729 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
2731 $LCTL get_param $proc_osc0/cur_dirty_bytes
2732 $LCTL get_param $proc_osc0/cur_grant_bytes
2734 # perform the real test
2735 $LCTL set_param $proc_osc0/rpc_stats 0
2736 for ((;i<$files; i++)); do
2737 [ $($LFS getstripe -i $TDIR/f$i) -eq 0 ] || continue
2738 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
2741 $LCTL get_param $proc_osc0/rpc_stats
2743 $LCTL get_param $proc_osc0/rpc_stats |
2744 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
2745 [ "$PPR" != "16:" ] && continue
2746 [ $WPCT -lt 85 ] && error "$pages-page write RPCs only $WPCT% < 85%"
2747 break # we only want the "pages per rpc" stat
2751 run_test 42e "verify sub-RPC writes are not done synchronously"
2755 cp -p /bin/ls $DIR/$tdir/$tfile
2756 multiop $DIR/$tdir/$tfile Ow_c &
2758 # give multiop a chance to open
2761 $DIR/$tdir/$tfile && error || true
2764 run_test 43 "execution of file opened for write should return -ETXTBSY"
2768 cp -p `which multiop` $DIR/d43/multiop || cp -p multiop $DIR/d43/multiop
2769 MULTIOP_PROG=$DIR/d43/multiop multiop_bg_pause $TMP/test43.junk O_c || return 1
2771 multiop $DIR/d43/multiop Oc && error "expected error, got success"
2772 kill -USR1 $MULTIOP_PID || return 2
2773 wait $MULTIOP_PID || return 3
2776 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
2780 cp -p `which multiop` $DIR/d43/multiop || cp -p multiop $DIR/d43/multiop
2781 MULTIOP_PROG=$DIR/d43/multiop multiop_bg_pause $TMP/test43.junk O_c || return 1
2783 $TRUNCATE $DIR/d43/multiop 0 && error "expected error, got success"
2784 kill -USR1 $MULTIOP_PID || return 2
2785 wait $MULTIOP_PID || return 3
2788 run_test 43b "truncate of file being executed should return -ETXTBSY"
2791 local testdir="$DIR/d43c"
2794 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
2795 ( cd $testdir && md5sum -c)
2797 run_test 43c "md5sum of copy into lustre========================"
2800 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
2801 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
2802 dd if=$DIR/f1 bs=4k count=1 > /dev/null
2804 run_test 44 "zero length read from a sparse stripe ============="
2807 local nstripe=`$LCTL lov_getconfig $DIR | grep default_stripe_count: | \
2809 [ -z "$nstripe" ] && skip "can't get stripe info" && return
2810 [ "$nstripe" -gt "$OSTCOUNT" ] && skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" && return
2811 local stride=`$LCTL lov_getconfig $DIR | grep default_stripe_size: | \
2813 if [ $nstripe -eq 0 -o $nstripe -eq -1 ] ; then
2814 nstripe=`$LCTL lov_getconfig $DIR | grep obd_count: | awk '{print $2}'`
2817 OFFSETS="0 $((stride/2)) $((stride-1))"
2818 for offset in $OFFSETS ; do
2819 for i in `seq 0 $((nstripe-1))`; do
2820 local GLOBALOFFSETS=""
2821 local size=$((((i + 2 * $nstripe )*$stride + $offset))) # Bytes
2822 local myfn=$DIR/d44a-$size
2823 echo "--------writing $myfn at $size"
2824 ll_sparseness_write $myfn $size || error "ll_sparseness_write"
2825 GLOBALOFFSETS="$GLOBALOFFSETS $size"
2826 ll_sparseness_verify $myfn $GLOBALOFFSETS \
2827 || error "ll_sparseness_verify $GLOBALOFFSETS"
2829 for j in `seq 0 $((nstripe-1))`; do
2830 size=$((((j + $nstripe )*$stride + $offset))) # Bytes
2831 ll_sparseness_write $myfn $size || error "ll_sparseness_write"
2832 GLOBALOFFSETS="$GLOBALOFFSETS $size"
2834 ll_sparseness_verify $myfn $GLOBALOFFSETS \
2835 || error "ll_sparseness_verify $GLOBALOFFSETS"
2840 run_test 44a "test sparse pwrite ==============================="
2844 for d in `lctl get_param -n osc.*.cur_dirty_bytes`; do
2850 before=`dirty_osc_total`
2851 echo executing "\"$*\""
2853 after=`dirty_osc_total`
2854 echo before $before, after $after
2858 # Obtain grants from OST if it supports it
2859 echo blah > ${f}_grant
2862 do_dirty_record "echo blah > $f"
2863 [ $before -eq $after ] && error "write wasn't cached"
2864 do_dirty_record "> $f"
2865 [ $before -gt $after ] || error "truncate didn't lower dirty count"
2866 do_dirty_record "echo blah > $f"
2867 [ $before -eq $after ] && error "write wasn't cached"
2868 do_dirty_record "sync"
2869 [ $before -gt $after ] || error "writeback didn't lower dirty count"
2870 do_dirty_record "echo blah > $f"
2871 [ $before -eq $after ] && error "write wasn't cached"
2872 do_dirty_record "cancel_lru_locks osc"
2873 [ $before -gt $after ] || error "lock cancellation didn't lower dirty count"
2876 run_test 45 "osc io page accounting ============================"
2878 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
2879 # test tickles a bug where re-dirtying a page was failing to be mapped to the
2880 # objects offset and an assert hit when an rpc was built with 1023's mapped
2881 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
2886 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
2888 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
2889 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
2893 run_test 46 "dirtying a previously written page ================"
2895 # test_47 is removed "Device nodes check" is moved to test_28
2897 test_48a() { # bug 2399
2898 check_kernel_version 34 || return 0
2901 mv $DIR/d48a $DIR/d48.new || error "move directory failed"
2902 mkdir $DIR/d48a || error "recreate directory failed"
2903 touch foo || error "'touch foo' failed after recreating cwd"
2904 mkdir bar || error "'mkdir foo' failed after recreating cwd"
2905 if check_kernel_version 44; then
2906 touch .foo || error "'touch .foo' failed after recreating cwd"
2907 mkdir .bar || error "'mkdir .foo' failed after recreating cwd"
2909 ls . > /dev/null || error "'ls .' failed after recreating cwd"
2910 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
2911 cd . || error "'cd .' failed after recreating cwd"
2912 mkdir . && error "'mkdir .' worked after recreating cwd"
2913 rmdir . && error "'rmdir .' worked after recreating cwd"
2914 ln -s . baz || error "'ln -s .' failed after recreating cwd"
2915 cd .. || error "'cd ..' failed after recreating cwd"
2917 run_test 48a "Access renamed working dir (should return errors)="
2919 test_48b() { # bug 2399
2920 check_kernel_version 34 || return 0
2923 rmdir $DIR/d48b || error "remove cwd $DIR/d48b failed"
2924 touch foo && error "'touch foo' worked after removing cwd"
2925 mkdir foo && error "'mkdir foo' worked after removing cwd"
2926 if check_kernel_version 44; then
2927 touch .foo && error "'touch .foo' worked after removing cwd"
2928 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
2930 ls . > /dev/null && error "'ls .' worked after removing cwd"
2931 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
2932 is_patchless || ( cd . && error "'cd .' worked after removing cwd" )
2933 mkdir . && error "'mkdir .' worked after removing cwd"
2934 rmdir . && error "'rmdir .' worked after removing cwd"
2935 ln -s . foo && error "'ln -s .' worked after removing cwd"
2936 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
2938 run_test 48b "Access removed working dir (should return errors)="
2940 test_48c() { # bug 2350
2941 check_kernel_version 36 || return 0
2942 #lctl set_param debug=-1
2944 mkdir -p $DIR/d48c/dir
2946 $TRACE rmdir $DIR/d48c/dir || error "remove cwd $DIR/d48c/dir failed"
2947 $TRACE touch foo && error "'touch foo' worked after removing cwd"
2948 $TRACE mkdir foo && error "'mkdir foo' worked after removing cwd"
2949 if check_kernel_version 44; then
2950 touch .foo && error "'touch .foo' worked after removing cwd"
2951 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
2953 $TRACE ls . && error "'ls .' worked after removing cwd"
2954 $TRACE ls .. || error "'ls ..' failed after removing cwd"
2955 is_patchless || ( $TRACE cd . && error "'cd .' worked after removing cwd" )
2956 $TRACE mkdir . && error "'mkdir .' worked after removing cwd"
2957 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
2958 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
2959 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
2961 run_test 48c "Access removed working subdir (should return errors)"
2963 test_48d() { # bug 2350
2964 check_kernel_version 36 || return 0
2965 #lctl set_param debug=-1
2967 mkdir -p $DIR/d48d/dir
2969 $TRACE rmdir $DIR/d48d/dir || error "remove cwd $DIR/d48d/dir failed"
2970 $TRACE rmdir $DIR/d48d || error "remove parent $DIR/d48d failed"
2971 $TRACE touch foo && error "'touch foo' worked after removing parent"
2972 $TRACE mkdir foo && error "'mkdir foo' worked after removing parent"
2973 if check_kernel_version 44; then
2974 touch .foo && error "'touch .foo' worked after removing parent"
2975 mkdir .foo && error "'mkdir .foo' worked after removing parent"
2977 $TRACE ls . && error "'ls .' worked after removing parent"
2978 $TRACE ls .. && error "'ls ..' worked after removing parent"
2979 is_patchless || ( $TRACE cd . && error "'cd .' worked after recreate parent" )
2980 $TRACE mkdir . && error "'mkdir .' worked after removing parent"
2981 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
2982 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
2983 is_patchless || ( $TRACE cd .. && error "'cd ..' worked after removing parent" || true )
2985 run_test 48d "Access removed parent subdir (should return errors)"
2987 test_48e() { # bug 4134
2988 check_kernel_version 41 || return 0
2989 #lctl set_param debug=-1
2991 mkdir -p $DIR/d48e/dir
2993 $TRACE rmdir $DIR/d48e/dir || error "remove cwd $DIR/d48e/dir failed"
2994 $TRACE rmdir $DIR/d48e || error "remove parent $DIR/d48e failed"
2995 $TRACE touch $DIR/d48e || error "'touch $DIR/d48e' failed"
2996 $TRACE chmod +x $DIR/d48e || error "'chmod +x $DIR/d48e' failed"
2997 # On a buggy kernel addition of "touch foo" after cd .. will
2998 # produce kernel oops in lookup_hash_it
2999 touch ../foo && error "'cd ..' worked after recreate parent"
3001 $TRACE rm $DIR/d48e || error "rm '$DIR/d48e' failed"
3003 run_test 48e "Access to recreated parent subdir (should return errors)"
3009 ls /proc/$$/cwd || error
3011 run_test 50 "special situations: /proc symlinks ==============="
3013 test_51a() { # was test_51
3014 # bug 1516 - create an empty entry right after ".." then split dir
3017 $MCREATE $DIR/d51/bar
3019 createmany -m $DIR/d51/longfile 201
3021 while [ `ls -sd $DIR/d51 | awk '{ print $1 }'` -eq 4 ]; do
3022 $MCREATE $DIR/d51/longfile$FNUM
3027 ls -l $DIR/d51 > /dev/null || error
3029 run_test 51a "special situations: split htree with empty entry =="
3031 #export NUMTEST=70000
3032 # FIXME: I select a relatively small number to do basic test.
3033 # large number may give panic(). debugging on this is going on.
3036 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
3037 [ $NUMFREE -lt 21000 ] && \
3038 skip "not enough free inodes ($NUMFREE)" && \
3041 check_kernel_version 40 || NUMTEST=31000
3042 [ $NUMFREE -lt $NUMTEST ] && NUMTEST=$(($NUMFREE - 50))
3045 createmany -d $DIR/d51b/t- $NUMTEST
3047 run_test 51b "mkdir .../t-0 --- .../t-$NUMTEST ===================="
3050 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3052 local ndirs=${TEST51BB_NDIRS:-10}
3053 local nfiles=${TEST51BB_NFILES:-100}
3055 local numfree=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
3057 [ $numfree -lt $(( ndirs * nfiles)) ] && \
3058 nfiles=$(( numfree / ndirs - 10 ))
3060 local dir=$DIR/d51bb
3062 local savePOLICY=$(lctl get_param -n lmv.*.placement)
3063 lctl set_param -n lmv.*.placement=CHAR
3066 local IUSED=$(lfs df -i $dir | grep MDT | awk '{print $3}')
3070 for ((i=0; i < $ndirs; i++)); do
3071 dirs[i]=$dir/$RANDOM
3072 echo Creating directory ${dirs[i]}
3075 echo Creating $nfiles in dir ${dirs[i]} ...
3076 echo "createmany -o ${dirs[i]}/$tfile- $nfiles"
3077 createmany -o ${dirs[i]}/$tfile- $nfiles
3083 IUSED=$(lfs df -i $dir | grep MDT | awk '{print $3}')
3087 for ((i=0; i<${#NEWUSED[@]}; i++)); do
3088 echo "mds $i: inodes count OLD ${OLDUSED[$i]} NEW ${NEWUSED[$i]}"
3089 [ ${OLDUSED[$i]} -lt ${NEWUSED[$i]} ] || rc=$((rc + 1))
3092 lctl set_param -n lmv.*.placement=$savePOLICY
3094 [ $rc -ne $MDSCOUNT ] || \
3095 error "Objects/inodes are not distributed over all mds servers"
3097 run_test 51bb "mkdir createmany CMD $MDSCOUNT ===================="
3101 [ ! -d $DIR/d51b ] && skip "$DIR/51b missing" && \
3104 unlinkmany -d $DIR/d51b/t- $NUMTEST
3106 run_test 51c "rmdir .../t-0 --- .../t-$NUMTEST ===================="
3109 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping test with few OSTs" && return
3111 createmany -o $DIR/d51d/t- 1000
3112 $LFS getstripe $DIR/d51d > $TMP/files
3113 for N in `seq 0 $((OSTCOUNT - 1))`; do
3114 OBJS[$N]=`awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}' $TMP/files`
3115 OBJS0[$N]=`grep -A 1 idx $TMP/files | awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}'`
3116 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
3118 unlinkmany $DIR/d51d/t- 1000
3121 for N in `seq 1 $((OSTCOUNT - 1))`; do
3122 [ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ] && \
3123 error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
3124 [ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ] && \
3125 error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
3127 [ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ] && \
3128 error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
3129 [ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ] && \
3130 error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
3134 run_test 51d "check object distribution ===================="
3137 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
3140 chattr +a $DIR/d52a/foo || error "chattr +a failed"
3141 echo bar >> $DIR/d52a/foo || error "append bar failed"
3142 cp /etc/hosts $DIR/d52a/foo && error "cp worked"
3143 rm -f $DIR/d52a/foo 2>/dev/null && error "rm worked"
3144 link $DIR/d52a/foo $DIR/d52a/foo_link 2>/dev/null && error "link worked"
3145 echo foo >> $DIR/d52a/foo || error "append foo failed"
3146 mrename $DIR/d52a/foo $DIR/d52a/foo_ren && error "rename worked"
3147 lsattr $DIR/d52a/foo | egrep -q "^-+a[-e]+ $DIR/d52a/foo" || error "lsattr"
3148 chattr -a $DIR/d52a/foo || error "chattr -a failed"
3149 cp -r $DIR/d52a /tmp/
3150 rm -fr $DIR/d52a || error "cleanup rm failed"
3152 run_test 52a "append-only flag test (should return errors) ====="
3155 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
3158 chattr +i $DIR/d52b/foo || error "chattr +i failed"
3159 cat test > $DIR/d52b/foo && error "cat test worked"
3160 cp /etc/hosts $DIR/d52b/foo && error "cp worked"
3161 rm -f $DIR/d52b/foo 2>/dev/null && error "rm worked"
3162 link $DIR/d52b/foo $DIR/d52b/foo_link 2>/dev/null && error "link worked"
3163 echo foo >> $DIR/d52b/foo && error "echo worked"
3164 mrename $DIR/d52b/foo $DIR/d52b/foo_ren && error "rename worked"
3165 [ -f $DIR/d52b/foo ] || error
3166 [ -f $DIR/d52b/foo_ren ] && error
3167 lsattr $DIR/d52b/foo | egrep -q "^-+i[-e]+ $DIR/d52b/foo" || error "lsattr"
3168 chattr -i $DIR/d52b/foo || error "chattr failed"
3170 rm -fr $DIR/d52b || error
3172 run_test 52b "immutable flag test (should return errors) ======="
3175 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3176 remote_ost_nodsh && skip "remote OST with nodsh" && return
3185 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
3186 for value in $(do_facet $SINGLEMDS lctl get_param osc.$mdtosc.prealloc_last_id) ; do
3187 param=`echo ${value[0]} | cut -d "=" -f1`
3188 ostname=`echo $param | cut -d "." -f2 | cut -d - -f 1-2`
3189 mds_last=$(do_facet $SINGLEMDS lctl get_param -n $param)
3190 ostnum=$(echo $ostname | sed "s/${FSNAME}-OST//g" | awk '{print ($1+1)}' )
3191 ost_last=$(do_facet ost$ostnum lctl get_param -n obdfilter.$ostname.last_id | head -n 1)
3192 echo "$ostname.last_id=$ost_last ; MDS.last_id=$mds_last"
3193 if [ $ost_last != $mds_last ]; then
3194 error "$ostname.last_id=$ost_last ; MDS.last_id=$mds_last"
3198 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
3201 [ ! -f "$SOCKETSERVER" ] && skip_env "no socketserver, skipping" && return
3202 [ ! -f "$SOCKETCLIENT" ] && skip_env "no socketclient, skipping" && return
3203 $SOCKETSERVER $DIR/socket
3204 $SOCKETCLIENT $DIR/socket || error
3205 $MUNLINK $DIR/socket
3207 run_test 54a "unix domain socket test =========================="
3213 dd if=/dev/zero of=$f bs=`page_size` count=1
3215 run_test 54b "char device works in lustre ======================"
3218 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
3219 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
3220 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
3222 for i in `seq 3 7`; do
3223 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
3233 loopdev="$DIR/loop54c"
3236 [ -z "$LOOPNUM" ] && echo "couldn't find empty loop device" && return
3237 mknod $loopdev b 7 $LOOPNUM
3238 echo "make a loop file system with $tfile on $loopdev ($LOOPNUM)..."
3239 dd if=/dev/zero of=$tfile bs=`page_size` seek=1024 count=1 > /dev/null
3240 losetup $loopdev $tfile || error "can't set up $loopdev for $tfile"
3241 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
3243 mount -t ext2 $loopdev $tdir || error "error mounting $loopdev on $tdir"
3244 dd if=/dev/zero of=$tdir/tmp bs=`page_size` count=30 || error "dd write"
3246 dd if=$tdir/tmp of=/dev/zero bs=`page_size` count=30 || error "dd read"
3251 run_test 54c "block device works in lustre ====================="
3257 [ "$string" = `echo $string > $f | cat $f` ] || error
3259 run_test 54d "fifo device works in lustre ======================"
3262 check_kernel_version 46 || return 0
3265 cp -aL /dev/console $f
3266 echo $string > $f || error
3268 run_test 54e "console/tty device works in lustre ======================"
3270 #The test_55 used to be iopen test and it was removed by bz#24037.
3271 #run_test 55 "check iopen_connect_dentry() ======================"
3273 test_56a() { # was test_56
3279 NUMFILESx2=$(($NUMFILES * 2))
3280 for i in `seq 1 $NUMFILES` ; do
3281 touch $DIR/d56/file$i
3282 touch $DIR/d56/dir/file$i
3285 # test lfs getstripe with --recursive
3286 FILENUM=`$GETSTRIPE --recursive $DIR/d56 | grep -c obdidx`
3287 [ $FILENUM -eq $NUMFILESx2 ] || error \
3288 "lfs getstripe --recursive $DIR/d56 wrong: found $FILENUM, expected $NUMFILESx2"
3289 FILENUM=`$GETSTRIPE $DIR/d56 | grep -c obdidx`
3290 [ $FILENUM -eq $NUMFILES ] || error \
3291 "lfs getstripe $DIR/d56 without --recursive wrong: found $FILENUM, expected $NUMFILES"
3292 echo "lfs getstripe --recursive passed."
3294 # test lfs getstripe with file instead of dir
3295 FILENUM=`$GETSTRIPE $DIR/d56/file1 | grep -c obdidx`
3296 [ $FILENUM -eq 1 ] || error \
3297 "lfs getstripe $DIR/d56/file1 wrong:found $FILENUM, expected 1"
3298 echo "lfs getstripe file passed."
3300 #test lfs getstripe with --verbose
3301 [ `$GETSTRIPE --verbose $DIR/d56 | grep -c lmm_magic` -eq $NUMFILES ] ||\
3302 error "lfs getstripe --verbose $DIR/d56 wrong: should find $NUMFILES lmm_magic info"
3303 [ `$GETSTRIPE $DIR/d56 | grep -c lmm_magic` -eq 0 ] || error \
3304 "lfs getstripe $DIR/d56 without --verbose wrong: should not show lmm_magic info"
3305 echo "lfs getstripe --verbose passed."
3307 #test lfs getstripe with --obd
3308 $GETSTRIPE --obd wrong_uuid $DIR/d56 2>&1 | grep -q "unknown obduuid" || \
3309 error "lfs getstripe --obd wrong_uuid should return error message"
3311 [ "$OSTCOUNT" -lt 2 ] && \
3312 skip_env "skipping other lfs getstripe --obd test" && return
3314 OBDUUID=$(lfs osts | grep ${OSTIDX}": " | awk '{print $2}')
3315 FILENUM=`$GETSTRIPE -ir $DIR/d56 | grep -x $OSTIDX | wc -l`
3316 FOUND=`$GETSTRIPE -r --obd $OBDUUID $DIR/d56 | grep obdidx | wc -l`
3317 [ $FOUND -eq $FILENUM ] || \
3318 error "lfs getstripe --obd wrong: found $FOUND, expected $FILENUM"
3319 [ `$GETSTRIPE -r -v --obd $OBDUUID $DIR/d56 | \
3320 sed '/^[ ]*'${OSTIDX}'[ ]/d' |\
3321 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l` -eq 0 ] || \
3322 error "lfs getstripe --obd wrong: should not show file on other obd"
3323 echo "lfs getstripe --obd passed."
3325 run_test 56a "check lfs getstripe ===================================="
3332 if [ ! -d "$DIR/${tdir}g" ] ; then
3333 mkdir -p $DIR/${tdir}g
3334 for i in `seq 1 $LOCAL_NUMFILES` ; do
3335 touch $DIR/${tdir}g/file$i
3337 for i in `seq 1 $LOCAL_NUMDIRS` ; do
3338 mkdir $DIR/${tdir}g/dir$i
3339 for j in `seq 1 $LOCAL_NUMFILES` ; do
3340 touch $DIR/${tdir}g/dir$i/file$j
3346 setup_56_special() {
3351 if [ ! -e "$TDIR/loop1b" ] ; then
3352 for i in `seq 1 $LOCAL_NUMFILES` ; do
3353 mknod $TDIR/loop${i}b b 7 $i
3354 mknod $TDIR/null${i}c c 1 3
3355 ln -s $TDIR/file1 $TDIR/link${i}l
3357 for i in `seq 1 $LOCAL_NUMDIRS` ; do
3358 mknod $TDIR/dir$i/loop${i}b b 7 $i
3359 mknod $TDIR/dir$i/null${i}c c 1 3
3360 ln -s $TDIR/dir$i/file1 $TDIR/dir$i/link${i}l
3368 setup_56 $NUMFILES $NUMDIRS
3370 EXPECTED=$(($NUMDIRS + 2))
3371 # test lfs find with -name
3372 for i in `seq 1 $NUMFILES` ; do
3373 NUMS=`$LFIND -name "*$i" $DIR/${tdir}g | wc -l`
3374 [ $NUMS -eq $EXPECTED ] || error \
3375 "lfs find -name \"*$i\" $DIR/${tdir}g wrong: found $NUMS, expected $EXPECTED"
3377 echo "lfs find -name passed."
3379 run_test 56g "check lfs find -name ============================="
3384 setup_56 $NUMFILES $NUMDIRS
3386 EXPECTED=$((($NUMDIRS+1)*($NUMFILES-1)+$NUMFILES))
3387 # test lfs find with ! -name
3388 for i in `seq 1 $NUMFILES` ; do
3389 NUMS=`$LFIND ! -name "*$i" $DIR/${tdir}g | wc -l`
3390 [ $NUMS -eq $EXPECTED ] || error \
3391 "lfs find ! -name \"*$i\" $DIR/${tdir}g wrong: found $NUMS, expected $EXPECTED"
3393 echo "lfs find ! -name passed."
3395 run_test 56h "check lfs find ! -name ============================="
3400 UUID=$(ostuuid_from_index 0 $DIR/$tdir)
3401 OUT=$($LFIND -obd $UUID $DIR/$tdir)
3402 [ "$OUT" ] && error "$LFIND returned directory '$OUT'" || true
3404 run_test 56i "check 'lfs find -ost UUID' skips directories ======="
3407 setup_56_special $NUMFILES $NUMDIRS
3409 EXPECTED=$((NUMDIRS+1))
3410 NUMS=`$LFIND -type d $DIR/${tdir}g | wc -l`
3411 [ $NUMS -eq $EXPECTED ] || \
3412 error "lfs find -type d $DIR/${tdir}g wrong: found $NUMS, expected $EXPECTED"
3414 run_test 56j "check lfs find -type d ============================="
3417 setup_56_special $NUMFILES $NUMDIRS
3419 EXPECTED=$(((NUMDIRS+1) * NUMFILES))
3420 NUMS=`$LFIND -type f $DIR/${tdir}g | wc -l`
3421 [ $NUMS -eq $EXPECTED ] || \
3422 error "lfs find -type f $DIR/${tdir}g wrong: found $NUMS, expected $EXPECTED"
3424 run_test 56k "check lfs find -type f ============================="
3427 setup_56_special $NUMFILES $NUMDIRS
3429 EXPECTED=$((NUMDIRS + NUMFILES))
3430 NUMS=`$LFIND -type b $DIR/${tdir}g | wc -l`
3431 [ $NUMS -eq $EXPECTED ] || \
3432 error "lfs find -type b $DIR/${tdir}g wrong: found $NUMS, expected $EXPECTED"
3434 run_test 56l "check lfs find -type b ============================="
3437 setup_56_special $NUMFILES $NUMDIRS
3439 EXPECTED=$((NUMDIRS + NUMFILES))
3440 NUMS=`$LFIND -type c $DIR/${tdir}g | wc -l`
3441 [ $NUMS -eq $EXPECTED ] || \
3442 error "lfs find -type c $DIR/${tdir}g wrong: found $NUMS, expected $EXPECTED"
3444 run_test 56m "check lfs find -type c ============================="
3447 setup_56_special $NUMFILES $NUMDIRS
3449 EXPECTED=$((NUMDIRS + NUMFILES))
3450 NUMS=`$LFIND -type l $DIR/${tdir}g | wc -l`
3451 [ $NUMS -eq $EXPECTED ] || \
3452 error "lfs find -type l $DIR/${tdir}g wrong: found $NUMS, expected $EXPECTED"
3454 run_test 56n "check lfs find -type l ============================="
3459 setup_56 $NUMFILES $NUMDIRS
3461 utime $TDIR/file1 > /dev/null || error "utime (1)"
3462 utime $TDIR/file2 > /dev/null || error "utime (2)"
3463 utime $TDIR/dir1 > /dev/null || error "utime (3)"
3464 utime $TDIR/dir2 > /dev/null || error "utime (4)"
3465 utime $TDIR/dir1/file1 > /dev/null || error "utime (5)"
3466 dd if=/dev/zero count=1 >> $TDIR/dir1/file1 && sync
3469 NUMS=`$LFIND -mtime +0 $TDIR | wc -l`
3470 [ $NUMS -eq $EXPECTED ] || \
3471 error "lfs find -mtime +0 $TDIR wrong: found $NUMS, expected $EXPECTED"
3474 NUMS=`$LFIND -mtime 0 $TDIR | wc -l`
3475 [ $NUMS -eq $EXPECTED ] || \
3476 error "lfs find -mtime 0 $TDIR wrong: found $NUMS, expected $EXPECTED"
3479 run_test 56o "check lfs find -mtime for old files =========================="
3482 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
3487 setup_56 $NUMFILES $NUMDIRS
3489 chown $RUNAS_ID $TDIR/file* || error "chown $DIR/${tdir}g/file$i failed"
3491 NUMS="`$LFIND -uid $RUNAS_ID $TDIR | wc -l`"
3492 [ $NUMS -eq $EXPECTED ] || \
3493 error "lfs find -uid $TDIR wrong: found $NUMS, expected $EXPECTED"
3495 EXPECTED=$(( ($NUMFILES+1) * $NUMDIRS + 1))
3496 NUMS="`$LFIND ! -uid $RUNAS_ID $TDIR | wc -l`"
3497 [ $NUMS -eq $EXPECTED ] || \
3498 error "lfs find ! -uid $TDIR wrong: found $NUMS, expected $EXPECTED"
3500 echo "lfs find -uid and ! -uid passed."
3502 run_test 56p "check lfs find -uid and ! -uid ==============================="
3505 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
3510 setup_56 $NUMFILES $NUMDIRS
3512 chgrp $RUNAS_GID $TDIR/file* || error "chown $DIR/${tdir}g/file$i failed"
3514 NUMS="`$LFIND -gid $RUNAS_GID $TDIR | wc -l`"
3515 [ $NUMS -eq $EXPECTED ] || \
3516 error "lfs find -gid $TDIR wrong: found $NUMS, expected $EXPECTED"
3518 EXPECTED=$(( ($NUMFILES+1) * $NUMDIRS + 1))
3519 NUMS="`$LFIND ! -gid $RUNAS_GID $TDIR | wc -l`"
3520 [ $NUMS -eq $EXPECTED ] || \
3521 error "lfs find ! -gid $TDIR wrong: found $NUMS, expected $EXPECTED"
3523 echo "lfs find -gid and ! -gid passed."
3525 run_test 56q "check lfs find -gid and ! -gid ==============================="
3528 setup_56 $NUMFILES $NUMDIRS
3532 NUMS=`$LFIND -size 0 -t f $TDIR | wc -l`
3533 [ $NUMS -eq $EXPECTED ] || \
3534 error "lfs find $TDIR -size 0 wrong: found $NUMS, expected $EXPECTED"
3536 NUMS=`$LFIND ! -size 0 -t f $TDIR | wc -l`
3537 [ $NUMS -eq $EXPECTED ] || \
3538 error "lfs find $TDIR ! -size 0 wrong: found $NUMS, expected $EXPECTED"
3539 echo "test" > $TDIR/56r && sync
3540 echo "test2" > $TDIR/56r2 && sync
3542 NUMS=`$LFIND -size 5 -t f $TDIR | wc -l`
3543 [ $NUMS -eq $EXPECTED ] || \
3544 error "lfs find $TDIR -size 5 wrong: found $NUMS, expected $EXPECTED"
3546 NUMS=`$LFIND -size +5 -t f $TDIR | wc -l`
3547 [ $NUMS -eq $EXPECTED ] || \
3548 error "lfs find $TDIR -size +5 wrong: found $NUMS, expected $EXPECTED"
3550 NUMS=`$LFIND -size +0 -t f $TDIR | wc -l`
3551 [ $NUMS -eq $EXPECTED ] || \
3552 error "lfs find $TDIR -size +0 wrong: found $NUMS, expected $EXPECTED"
3554 NUMS=`$LFIND ! -size -5 -t f $TDIR | wc -l`
3555 [ $NUMS -eq $EXPECTED ] || \
3556 error "lfs find $TDIR ! -size -5 wrong: found $NUMS, expected $EXPECTED"
3558 NUMS=`$LFIND -size -5 -t f $TDIR | wc -l`
3559 [ $NUMS -eq $EXPECTED ] || \
3560 error "lfs find $TDIR -size -5 wrong: found $NUMS, expected $EXPECTED"
3563 run_test 56r "check lfs find -size works =========================="
3566 # note test will not do anything if MDS is not local
3567 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3568 local MNTDEV="osd*.*MDT*.mntdev"
3569 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
3570 [ -z "$DEV" ] && error "can't access $MNTDEV"
3571 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
3572 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump || error "can't access $DEV"
3573 DEVISIZE=`awk '/Inode size:/ { print $3 }' $TMP/t57a.dump`
3574 [ "$DEVISIZE" -gt 128 ] || error "inode size $DEVISIZE"
3578 run_test 57a "verify MDS filesystem created with large inodes =="
3585 local FILEN=$dir/f$FILECOUNT
3587 rm -rf $dir || error "removing $dir"
3588 mkdir -p $dir || error "creating $dir"
3589 local num=$(get_mds_dir $dir)
3592 echo "mcreating $FILECOUNT files"
3593 createmany -m $dir/f 1 $FILECOUNT || \
3594 error "creating files in $dir"
3596 # verify that files do not have EAs yet
3597 $GETSTRIPE $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
3598 $GETSTRIPE $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
3602 df $dir #make sure we get new statfs data
3603 local MDSFREE=$(do_facet $mymds \
3604 lctl get_param -n osd*.*MDT000$((num -1)).kbytesfree)
3605 local MDCFREE=$(lctl get_param -n mdc.*MDT000$((num -1))-mdc-*.kbytesfree)
3606 echo "opening files to create objects/EAs"
3608 for FILE in `seq -f $dir/f%g 1 $FILECOUNT`; do
3609 $OPENFILE -f O_RDWR $FILE > /dev/null 2>&1 || error "opening $FILE"
3612 # verify that files have EAs now
3613 $GETSTRIPE $FILE1 | grep -q "obdidx" || error "$FILE1 missing EA"
3614 $GETSTRIPE $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
3616 sleep 1 #make sure we get new statfs data
3618 local MDSFREE2=$(do_facet $mymds \
3619 lctl get_param -n osd*.*MDT000$((num -1)).kbytesfree)
3620 local MDCFREE2=$(lctl get_param -n mdc.*MDT000$((num -1))-mdc-*.kbytesfree)
3621 if [ "$MDCFREE2" -lt "$((MDCFREE - 8))" ]; then
3622 if [ "$MDSFREE" != "$MDSFREE2" ]; then
3623 error "MDC before $MDCFREE != after $MDCFREE2"
3625 echo "MDC before $MDCFREE != after $MDCFREE2"
3626 echo "unable to confirm if MDS has large inodes"
3631 run_test 57b "default LOV EAs are stored inside large inodes ==="
3634 [ -z "$(which wiretest 2>/dev/null)" ] && skip_env "could not find wiretest" && return
3637 run_test 58 "verify cross-platform wire constants =============="
3640 echo "touch 130 files"
3641 createmany -o $DIR/f59- 130
3643 unlinkmany $DIR/f59- 130
3646 # wait for commitment of removal
3648 run_test 59 "verify cancellation of llog records async ========="
3650 TEST60_HEAD="test_60 run $RANDOM"
3652 [ ! -f run-llog.sh ] && skip_env "missing subtest run-llog.sh" && return
3653 log "$TEST60_HEAD - from kernel mode"
3654 do_facet mgs sh run-llog.sh
3656 run_test 60a "llog sanity tests run from kernel module =========="
3658 test_60b() { # bug 6411
3660 LLOG_COUNT=`dmesg | awk "/$TEST60_HEAD/{marker = 1; from_marker = 0;}
3672 [ $LLOG_COUNT -gt 50 ] && error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)"|| true
3674 run_test 60b "limit repeated messages from CERROR/CWARN ========"
3677 echo "create 5000 files"
3678 createmany -o $DIR/f60c- 5000
3679 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
3680 lctl set_param fail_loc=0x80000137
3681 unlinkmany $DIR/f60c- 5000
3682 lctl set_param fail_loc=0
3684 run_test 60c "unlink file when mds full"
3687 SAVEPRINTK=$(lctl get_param -n printk)
3689 # verify "lctl mark" is even working"
3690 MESSAGE="test message ID $RANDOM $$"
3691 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
3692 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
3694 lctl set_param printk=0 || error "set lnet.printk failed"
3695 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
3696 MESSAGE="new test message ID $RANDOM $$"
3697 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
3698 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
3699 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
3701 lctl set_param -n printk="$SAVEPRINTK"
3703 run_test 60d "test printk console message masking"
3707 dd if=/dev/zero of=$f bs=`page_size` count=1
3708 cancel_lru_locks osc
3709 multiop $f OSMWUc || error
3712 run_test 61 "mmap() writes don't make sync hang ================"
3714 # bug 2330 - insufficient obd_match error checking causes LBUG
3718 cancel_lru_locks osc
3719 lctl set_param fail_loc=0x405
3720 cat $f && error "cat succeeded, expect -EIO"
3721 lctl set_param fail_loc=0
3723 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
3724 # match every page all of the time.
3725 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
3727 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
3728 test_63a() { # was test_63
3729 MAX_DIRTY_MB=`lctl get_param -n osc.*.max_dirty_mb | head -n 1`
3730 lctl set_param -n osc.*.max_dirty_mb 0
3731 for i in `seq 10` ; do
3732 dd if=/dev/zero of=$DIR/f63 bs=8k &
3738 lctl set_param -n osc.*.max_dirty_mb $MAX_DIRTY_MB
3739 rm -f $DIR/f63 || true
3741 run_test 63a "Verify oig_wait interruption does not crash ======="
3743 # bug 2248 - async write errors didn't return to application on sync
3744 # bug 3677 - async write errors left page locked
3747 lctl set_param debug=-1
3749 # ensure we have a grant to do async writes
3750 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
3753 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
3754 lctl set_param fail_loc=0x80000406
3755 multiop $DIR/$tfile Owy && \
3756 error "sync didn't return ENOMEM"
3757 sync; sleep 2; sync # do a real sync this time to flush page
3758 lctl get_param -n llite.*.dump_page_cache | grep locked && \
3759 error "locked page left in cache after async error" || true
3762 run_test 63b "async write errors should be returned to fsync ==="
3766 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
3768 run_test 64a "verify filter grant calculations (in kernel) ====="
3771 [ ! -f oos.sh ] && skip_env "missing subtest oos.sh" && return
3774 run_test 64b "check out-of-space detection on client ==========="
3776 # bug 1414 - set/get directories' stripe info
3780 $LVERIFY $DIR/d65 $DIR/d65/f1 || error "lverify failed"
3782 run_test 65a "directory with no stripe info ===================="
3786 $SETSTRIPE $DIR/d65 -s $(($STRIPESIZE * 2)) -i 0 -c 1 || error "setstripe"
3788 $LVERIFY $DIR/d65 $DIR/d65/f2 || error "lverify failed"
3790 run_test 65b "directory setstripe $(($STRIPESIZE * 2)) 0 1 ==============="
3793 if [ $OSTCOUNT -gt 1 ]; then
3795 $SETSTRIPE $DIR/d65 -s $(($STRIPESIZE * 4)) -i 1 \
3796 -c $(($OSTCOUNT - 1)) || error "setstripe"
3798 $LVERIFY $DIR/d65 $DIR/d65/f3 || error "lverify failed"
3801 run_test 65c "directory setstripe $(($STRIPESIZE * 4)) 1 $(($OSTCOUNT - 1))"
3805 if [ $STRIPECOUNT -le 0 ]; then
3807 elif [ $STRIPECOUNT -gt 160 ]; then
3808 #LOV_MAX_STRIPE_COUNT is 160
3809 [ $OSTCOUNT -gt 160 ] && sc=160 || sc=$(($OSTCOUNT - 1))
3811 sc=$(($STRIPECOUNT - 1))
3813 $SETSTRIPE $DIR/d65 -s $STRIPESIZE -c $sc || error "setstripe"
3814 touch $DIR/d65/f4 $DIR/d65/f5
3815 $LVERIFY $DIR/d65 $DIR/d65/f4 $DIR/d65/f5 || error "lverify failed"
3817 run_test 65d "directory setstripe $STRIPESIZE -1 stripe_count =============="
3822 $SETSTRIPE $DIR/d65 || error "setstripe"
3823 $GETSTRIPE -v $DIR/d65 | grep "Default" || error "no stripe info failed"
3825 $LVERIFY $DIR/d65 $DIR/d65/f6 || error "lverify failed"
3827 run_test 65e "directory setstripe defaults ======================="
3831 $RUNAS $SETSTRIPE $DIR/d65f && error "setstripe succeeded" || true
3833 run_test 65f "dir setstripe permission (should return error) ==="
3837 $SETSTRIPE $DIR/d65 -s $(($STRIPESIZE * 2)) -i 0 -c 1 || error "setstripe"
3838 $SETSTRIPE -d $DIR/d65 || error "setstripe"
3839 $GETSTRIPE -v $DIR/d65 | grep "Default" || \
3840 error "delete default stripe failed"
3842 run_test 65g "directory setstripe -d ==========================="
3846 $SETSTRIPE $DIR/d65 -s $(($STRIPESIZE * 2)) -i 0 -c 1 || error "setstripe"
3847 mkdir -p $DIR/d65/dd1
3848 [ "`$GETSTRIPE -v $DIR/d65 | grep "^count"`" == \
3849 "`$GETSTRIPE -v $DIR/d65/dd1 | grep "^count"`" ] || error "stripe info inherit failed"
3851 run_test 65h "directory stripe info inherit ===================="
3853 test_65i() { # bug6367
3854 $SETSTRIPE $MOUNT -s 65536 -c -1
3856 run_test 65i "set non-default striping on root directory (bug 6367)="
3858 test_65ia() { # bug12836
3859 $LFS getstripe $MOUNT || error "getstripe $MOUNT failed"
3861 run_test 65ia "getstripe on -1 default directory striping"
3863 test_65ib() { # bug12836
3864 $LFS getstripe -v $MOUNT || error "getstripe -v $MOUNT failed"
3866 run_test 65ib "getstripe -v on -1 default directory striping"
3868 test_65ic() { # bug12836
3869 $LFS find -mtime -1 $MOUNT || error "find $MOUNT failed"
3871 run_test 65ic "new find on -1 default directory striping"
3873 test_65j() { # bug6367
3875 # if we aren't already remounting for each test, do so for this test
3876 if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
3877 cleanup || error "failed to unmount"
3880 $SETSTRIPE -d $MOUNT || error "setstripe failed"
3882 run_test 65j "set default striping on root directory (bug 6367)="
3884 test_65k() { # bug11679
3885 [ "$OSTCOUNT" -lt 2 ] && skip_env "too few OSTs" && return
3886 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3888 echo "Check OST status: "
3889 MDS_OSCS=`do_facet $SINGLEMDS lctl dl | awk '/[oO][sS][cC].*md[ts]/ { print $4 }'`
3890 for OSC in $MDS_OSCS; do
3891 echo $OSC "is activate"
3892 do_facet $SINGLEMDS lctl --device %$OSC activate
3894 do_facet client mkdir -p $DIR/$tdir
3895 for INACTIVE_OSC in $MDS_OSCS; do
3896 echo $INACTIVE_OSC "is Deactivate:"
3897 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
3898 for STRIPE_OSC in $MDS_OSCS; do
3899 STRIPE_OST=`osc_to_ost $STRIPE_OSC`
3900 STRIPE_INDEX=`do_facet $SINGLEMDS lctl get_param -n lov.*md*.target_obd |
3901 grep $STRIPE_OST | awk -F: '{print $1}' | head -n 1`
3903 [ -f $DIR/$tdir/${STRIPE_INDEX} ] && continue
3904 echo "$SETSTRIPE $DIR/$tdir/${STRIPE_INDEX} -i ${STRIPE_INDEX} -c 1"
3905 do_facet client $SETSTRIPE $DIR/$tdir/${STRIPE_INDEX} -i ${STRIPE_INDEX} -c 1
3907 [ $RC -ne 0 ] && error "setstripe should have succeeded"
3909 do_facet client rm -f $DIR/$tdir/*
3910 echo $INACTIVE_OSC "is Activate."
3911 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
3914 run_test 65k "validate manual striping works properly with deactivated OSCs"
3916 test_65l() { # bug 12836
3917 mkdir -p $DIR/$tdir/test_dir
3918 $SETSTRIPE $DIR/$tdir/test_dir -c -1
3919 $LFS find -mtime -1 $DIR/$tdir >/dev/null
3921 run_test 65l "lfs find on -1 stripe dir ========================"
3923 # bug 2543 - update blocks count on client
3926 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
3928 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
3929 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
3931 run_test 66 "update inode blocks count on client ==============="
3937 if [ ! -z "$LLOOP" ]; then
3938 if swapon -s | grep -q $LLOOP; then
3939 swapoff $LLOOP || error "swapoff failed"
3942 $LCTL blockdev_detach $LLOOP || error "detach failed"
3946 if [ ! -z "$LLITELOOPLOAD" ]; then
3954 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
3958 swapon -s | awk '($1 == "'$1'") { print $4 }'
3961 # test case for lloop driver, basic function
3963 [ "$UID" != 0 ] && skip_env "must run as root" && return
3964 llite_lloop_enabled || \
3965 { skip_env "llite_lloop module disabled" && return; }
3967 trap cleanup_68 EXIT
3969 if ! module_loaded llite_lloop; then
3970 if load_module llite/llite_lloop; then
3973 skip_env "can't find module llite_lloop"
3978 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
3979 dd if=/dev/zero of=$DIR/f68a bs=4k count=1024
3980 $LCTL blockdev_attach $DIR/f68a $LLOOP || error "attach failed"
3982 directio rdwr $LLOOP 0 1024 4096 || error "direct write failed"
3983 directio rdwr $LLOOP 0 1025 4096 && error "direct write should fail"
3987 run_test 68a "lloop driver - basic test ========================"
3989 # excercise swapping to lustre by adding a high priority swapfile entry
3990 # and then consuming memory until it is used.
3991 test_68b() { # was test_68
3992 [ "$UID" != 0 ] && skip_env "must run as root" && return
3993 lctl get_param -n devices | grep -q obdfilter && \
3994 skip "local OST" && return
3996 grep -q llite_lloop /proc/modules
3997 [ $? -ne 0 ] && skip "can't find module llite_lloop" && return
3999 [ -z "`$LCTL list_nids | grep -v tcp`" ] && \
4000 skip "can't reliably test swap with TCP" && return
4002 MEMTOTAL=`meminfo MemTotal`
4003 NR_BLOCKS=$((MEMTOTAL>>8))
4004 [[ $NR_BLOCKS -le 2048 ]] && NR_BLOCKS=2048
4006 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
4007 dd if=/dev/zero of=$DIR/f68b bs=64k seek=$NR_BLOCKS count=1
4010 $LCTL blockdev_attach $DIR/f68b $LLOOP || error "attach failed"
4012 trap cleanup_68 EXIT
4014 swapon -p 32767 $LLOOP || error "swapon $LLOOP failed"
4016 echo "before: `swapon -s | grep $LLOOP`"
4017 $MEMHOG $MEMTOTAL || error "error allocating $MEMTOTAL kB"
4018 echo "after: `swapon -s | grep $LLOOP`"
4019 SWAPUSED=`swap_used $LLOOP`
4023 [ $SWAPUSED -eq 0 ] && echo "no swap used???" || true
4025 run_test 68b "support swapping to Lustre ========================"
4027 # bug5265, obdfilter oa2dentry return -ENOENT
4028 # #define OBD_FAIL_OST_ENOENT 0x217
4030 remote_ost_nodsh && skip "remote OST with nodsh" && return
4033 $SETSTRIPE $f -c 1 -i 0
4035 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
4037 do_facet ost1 lctl set_param fail_loc=0x217
4038 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
4039 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
4041 do_facet ost1 lctl set_param fail_loc=0
4042 $DIRECTIO write $f 0 2 || error "write error"
4044 cancel_lru_locks osc
4045 $DIRECTIO read $f 0 1 || error "read error"
4047 do_facet ost1 lctl set_param fail_loc=0x217
4048 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
4050 do_facet ost1 lctl set_param fail_loc=0
4053 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
4057 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
4059 run_test 71 "Running dbench on lustre (don't segment fault) ===="
4061 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
4062 check_kernel_version 43 || return 0
4063 [ "$RUNAS_ID" = "$UID" ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4065 # Check that testing environment is properly set up. Skip if not
4066 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS || {
4067 skip_env "User $RUNAS_ID does not exist - skipping"
4070 # We had better clear the $DIR to get enough space for dd
4075 $RUNAS dd if=/dev/zero of=$DIR/f72 bs=512 count=1 || error
4076 # See if we are still setuid/sgid
4077 test -u $DIR/f72 -o -g $DIR/f72 && error "S/gid is not dropped on write"
4078 # Now test that MDS is updated too
4079 cancel_lru_locks mdc
4080 test -u $DIR/f72 -o -g $DIR/f72 && error "S/gid is not dropped on MDS"
4084 run_test 72a "Test that remove suid works properly (bug5695) ===="
4086 test_72b() { # bug 24226 -- keep mode setting when size is not changing
4089 [ "$RUNAS_ID" = "$UID" ] && \
4090 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4091 [ "$RUNAS_ID" -eq 0 ] && \
4092 skip_env "RUNAS_ID = 0 -- skipping" && return
4094 # Check that testing environment is properly set up. Skip if not
4095 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS || {
4096 skip_env "User $RUNAS_ID does not exist - skipping"
4099 touch $DIR/${tfile}-f{g,u}
4100 mkdir $DIR/${tfile}-d{g,u}
4101 chmod 770 $DIR/${tfile}-{f,d}{g,u}
4102 chmod g+s $DIR/${tfile}-{f,d}g
4103 chmod u+s $DIR/${tfile}-{f,d}u
4104 for perm in 777 2777 4777; do
4105 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
4106 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
4107 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
4108 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
4112 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
4114 # bug 3462 - multiple simultaneous MDC requests
4118 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
4121 lctl set_param fail_loc=0x80000129
4122 multiop $DIR/d73-1/f73-2 Oc &
4124 lctl set_param fail_loc=0
4126 multiop $DIR/d73-2/f73-3 Oc &
4130 wait $pid1 || return 1
4134 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
4135 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
4136 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
4140 run_test 73 "multiple MDC requests (should not deadlock)"
4142 test_74a() { # bug 6149, 6184
4143 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
4145 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
4146 # will spin in a tight reconnection loop
4148 lctl set_param fail_loc=0x8000030e
4149 # get any lock that won't be difficult - lookup works.
4151 lctl set_param fail_loc=0
4155 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
4157 test_74b() { # bug 13310
4158 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
4160 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
4161 # will spin in a tight reconnection loop
4162 lctl set_param fail_loc=0x8000030e
4163 # get a "difficult" lock
4165 lctl set_param fail_loc=0
4169 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
4172 #define OBD_FAIL_LDLM_NEW_LOCK
4173 lctl set_param fail_loc=0x80000319
4174 touch $DIR/$tfile && error "Touch successful"
4177 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
4180 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
4183 get_inode_slab_tunables() {
4184 awk '/lustre_inode_cache/ {print $9," ",$10," ",$11; exit}' /proc/slabinfo
4187 set_inode_slab_tunables() {
4188 echo "lustre_inode_cache $1" > /proc/slabinfo
4191 test_76() { # Now for bug 20433, added originally in bug 1443
4192 local SLAB_SETTINGS=`get_inode_slab_tunables`
4193 local CPUS=`getconf _NPROCESSORS_ONLN`
4194 # we cannot set limit below 1 which means 1 inode in each
4195 # per-cpu cache is still allowed
4196 set_inode_slab_tunables "1 1 0"
4197 cancel_lru_locks osc
4198 BEFORE_INODES=`num_inodes`
4199 echo "before inodes: $BEFORE_INODES"
4201 [ "$SLOW" = "no" ] && COUNT=100
4202 for i in `seq $COUNT`; do
4206 cancel_lru_locks osc
4207 AFTER_INODES=`num_inodes`
4208 echo "after inodes: $AFTER_INODES"
4210 while [ $((AFTER_INODES-1*CPUS)) -gt $BEFORE_INODES ]; do
4212 AFTER_INODES=`num_inodes`
4214 echo "wait $wait seconds inodes: $AFTER_INODES"
4215 if [ $wait -gt 30 ]; then
4216 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
4219 set_inode_slab_tunables "$SLAB_SETTINGS"
4221 run_test 76 "confirm clients recycle inodes properly ===="
4227 # Note: in sptlrpc modes which enable its own bulk checksum, the
4228 # original crc32_le bulk checksum will be automatically disabled,
4229 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
4230 # will be checked by sptlrpc code against sptlrpc bulk checksum.
4231 # In this case set_checksums() will not be no-op, because sptlrpc
4232 # bulk checksum will be enabled all through the test.
4234 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
4235 lctl set_param -n osc.*.checksums $1
4239 export ORIG_CSUM_TYPE=""
4240 CKSUM_TYPES=${CKSUM_TYPES:-"crc32 adler"}
4243 [ "$ORIG_CSUM_TYPE" ] || \
4244 ORIG_CSUM_TYPE=`lctl get_param -n osc/*osc-[^mM]*/checksum_type |
4245 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`
4246 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
4247 log "set checksum type to $1"
4250 F77_TMP=$TMP/f77-temp
4253 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
4254 error "error writing to $F77_TMP"
4257 test_77a() { # bug 10889
4258 $GSS && skip "could not run with gss" && return
4259 [ ! -f $F77_TMP ] && setup_f77
4261 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
4265 run_test 77a "normal checksum read/write operation ============="
4267 test_77b() { # bug 10889
4268 $GSS && skip "could not run with gss" && return
4269 [ ! -f $F77_TMP ] && setup_f77
4270 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
4271 lctl set_param fail_loc=0x80000409
4273 dd if=$F77_TMP of=$DIR/f77b bs=1M count=$F77SZ conv=sync || \
4274 error "dd error: $?"
4275 lctl set_param fail_loc=0
4278 run_test 77b "checksum error on client write ===================="
4280 test_77c() { # bug 10889
4281 $GSS && skip "could not run with gss" && return
4282 [ ! -f $DIR/f77b ] && skip "requires 77b - skipping" && return
4284 for algo in $CKSUM_TYPES; do
4285 cancel_lru_locks osc
4286 set_checksum_type $algo
4287 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
4288 lctl set_param fail_loc=0x80000408
4289 cmp $F77_TMP $DIR/f77b || error "file compare failed"
4290 lctl set_param fail_loc=0
4293 set_checksum_type $ORIG_CSUM_TYPE
4296 run_test 77c "checksum error on client read ==================="
4298 test_77d() { # bug 10889
4299 $GSS && skip "could not run with gss" && return
4300 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
4301 lctl set_param fail_loc=0x80000409
4303 directio write $DIR/f77 0 $F77SZ $((1024 * 1024)) || \
4304 error "direct write: rc=$?"
4305 lctl set_param fail_loc=0
4308 run_test 77d "checksum error on OST direct write ==============="
4310 test_77e() { # bug 10889
4311 $GSS && skip "could not run with gss" && return
4312 [ ! -f $DIR/f77 ] && skip "requires 77d - skipping" && return
4313 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
4314 lctl set_param fail_loc=0x80000408
4316 cancel_lru_locks osc
4317 directio read $DIR/f77 0 $F77SZ $((1024 * 1024)) || \
4318 error "direct read: rc=$?"
4319 lctl set_param fail_loc=0
4322 run_test 77e "checksum error on OST direct read ================"
4324 test_77f() { # bug 10889
4325 $GSS && skip "could not run with gss" && return
4327 for algo in $CKSUM_TYPES; do
4328 cancel_lru_locks osc
4329 set_checksum_type $algo
4330 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
4331 lctl set_param fail_loc=0x409
4332 directio write $DIR/f77 0 $F77SZ $((1024 * 1024)) && \
4333 error "direct write succeeded"
4334 lctl set_param fail_loc=0
4336 set_checksum_type $ORIG_CSUM_TYPE
4339 run_test 77f "repeat checksum error on write (expect error) ===="
4341 test_77g() { # bug 10889
4342 $GSS && skip "could not run with gss" && return
4343 remote_ost_nodsh && skip "remote OST with nodsh" && return
4345 [ ! -f $F77_TMP ] && setup_f77
4347 $SETSTRIPE $DIR/f77g -c 1 -i 0
4348 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
4349 do_facet ost1 lctl set_param fail_loc=0x8000021a
4351 dd if=$F77_TMP of=$DIR/f77g bs=1M count=$F77SZ || \
4352 error "write error: rc=$?"
4353 do_facet ost1 lctl set_param fail_loc=0
4356 run_test 77g "checksum error on OST write ======================"
4358 test_77h() { # bug 10889
4359 $GSS && skip "could not run with gss" && return
4360 remote_ost_nodsh && skip "remote OST with nodsh" && return
4362 [ ! -f $DIR/f77g ] && skip "requires 77g - skipping" && return
4363 cancel_lru_locks osc
4364 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
4365 do_facet ost1 lctl set_param fail_loc=0x8000021b
4367 cmp $F77_TMP $DIR/f77g || error "file compare failed"
4368 do_facet ost1 lctl set_param fail_loc=0
4371 run_test 77h "checksum error on OST read ======================="
4373 test_77i() { # bug 13805
4374 $GSS && skip "could not run with gss" && return
4375 #define OBD_FAIL_OSC_CONNECT_CKSUM 0x40b
4376 lctl set_param fail_loc=0x40b
4377 remount_client $MOUNT
4378 lctl set_param fail_loc=0
4379 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
4380 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
4381 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
4382 [ "$algo" = "crc32" ] || error "algo set to $algo instead of crc32"
4384 remount_client $MOUNT
4386 run_test 77i "client not supporting OSD_CONNECT_CKSUM =========="
4388 test_77j() { # bug 13805
4389 $GSS && skip "could not run with gss" && return
4390 #define OBD_FAIL_OSC_CKSUM_ADLER_ONLY 0x40c
4391 lctl set_param fail_loc=0x40c
4392 remount_client $MOUNT
4393 lctl set_param fail_loc=0
4394 sleep 2 # wait async osc connect to finish
4395 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
4396 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
4397 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
4398 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
4400 remount_client $MOUNT
4402 run_test 77j "client only supporting ADLER32 ===================="
4404 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
4408 test_78() { # bug 10901
4409 remote_ost || { skip_env "local OST" && return; }
4412 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
4413 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
4414 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
4415 echo "MemTotal: $MEMTOTAL"
4416 # reserve 256MB of memory for the kernel and other running processes,
4417 # and then take 1/2 of the remaining memory for the read/write buffers.
4418 if [ $MEMTOTAL -gt 512 ] ;then
4419 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
4421 # for those poor memory-starved high-end clusters...
4422 MEMTOTAL=$((MEMTOTAL / 2))
4424 echo "Mem to use for directio: $MEMTOTAL"
4425 [ $F78SIZE -gt $MEMTOTAL ] && F78SIZE=$MEMTOTAL
4426 [ $F78SIZE -gt 512 ] && F78SIZE=512
4427 [ $F78SIZE -gt $((MAXFREE / 1024)) ] && F78SIZE=$((MAXFREE / 1024))
4428 SMALLESTOST=`lfs df $DIR |grep OST | awk '{print $4}' |sort -n |head -1`
4429 echo "Smallest OST: $SMALLESTOST"
4430 [ $SMALLESTOST -lt 10240 ] && \
4431 skip "too small OSTSIZE, useless to run large O_DIRECT test" && return 0
4433 [ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ] && \
4434 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
4436 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
4437 echo "File size: $F78SIZE"
4438 $SETSTRIPE $DIR/$tfile -c $OSTCOUNT || error "setstripe failed"
4439 for i in `seq 1 $NSEQ`
4441 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
4442 echo directIO rdwr round $i of $NSEQ
4443 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
4448 run_test 78 "handle large O_DIRECT writes correctly ============"
4450 test_79() { # bug 12743
4451 wait_delete_completed
4453 BKTOTAL=$(calc_osc_kbytes kbytestotal)
4454 BKFREE=$(calc_osc_kbytes kbytesfree)
4455 BKAVAIL=$(calc_osc_kbytes kbytesavail)
4457 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
4458 DFTOTAL=`echo $STRING | cut -d, -f1`
4459 DFUSED=`echo $STRING | cut -d, -f2`
4460 DFAVAIL=`echo $STRING | cut -d, -f3`
4461 DFFREE=$(($DFTOTAL - $DFUSED))
4463 ALLOWANCE=$((64 * $OSTCOUNT))
4465 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
4466 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
4467 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
4469 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
4470 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
4471 error "df free($DFFREE) mismatch OST free($BKFREE)"
4473 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
4474 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
4475 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
4478 run_test 79 "df report consistency check ======================="
4480 test_80() { # bug 10718
4481 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
4483 local BEFORE=`date +%s`
4484 cancel_lru_locks osc
4485 local AFTER=`date +%s`
4486 local DIFF=$((AFTER-BEFORE))
4487 if [ $DIFF -gt 1 ] ; then
4488 error "elapsed for 1M@1T = $DIFF"
4493 run_test 80 "Page eviction is equally fast at high offsets too ===="
4495 test_81a() { # LU-456
4496 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
4497 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
4498 do_facet ost0 lctl set_param fail_loc=0x80000228
4500 # write should trigger a retry and success
4501 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
4502 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
4504 if [ $RC -ne 0 ] ; then
4505 error "write should success, but failed for $RC"
4508 run_test 81a "OST should retry write when get -ENOSPC ==============="
4510 test_81b() { # LU-456
4511 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
4512 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
4513 do_facet ost0 lctl set_param fail_loc=0x228
4515 # write should retry several times and return -ENOSPC finally
4516 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
4517 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
4520 if [ $RC -ne $ENOSPC ] ; then
4521 error "dd should fail for -ENOSPC, but succeed."
4524 run_test 81b "OST should return -ENOSPC when retry still fails ======="
4528 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && \
4530 mkdir -p $DIR/d99cvsroot
4531 chown $RUNAS_ID $DIR/d99cvsroot
4532 local oldPWD=$PWD # bug 13584, use $TMP as working dir
4535 $RUNAS cvs -d $DIR/d99cvsroot init || error
4538 run_test 99a "cvs init ========================================="
4541 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
4542 [ ! -d $DIR/d99cvsroot ] && test_99a
4544 # some versions of cvs import exit(1) when asked to import links or
4545 # files they can't read. ignore those files.
4546 TOIGNORE=$(find . -type l -printf '-I %f\n' -o \
4547 ! -perm +4 -printf '-I %f\n')
4548 $RUNAS cvs -d $DIR/d99cvsroot import -m "nomesg" $TOIGNORE \
4549 d99reposname vtag rtag
4551 run_test 99b "cvs import ======================================="
4554 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
4555 [ ! -d $DIR/d99cvsroot ] && test_99b
4557 mkdir -p $DIR/d99reposname
4558 chown $RUNAS_ID $DIR/d99reposname
4559 $RUNAS cvs -d $DIR/d99cvsroot co d99reposname
4561 run_test 99c "cvs checkout ====================================="
4564 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
4565 [ ! -d $DIR/d99cvsroot ] && test_99c
4566 cd $DIR/d99reposname
4568 $RUNAS cvs add -m 'addmsg' foo99
4570 run_test 99d "cvs add =========================================="
4573 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
4574 [ ! -d $DIR/d99cvsroot ] && test_99c
4575 cd $DIR/d99reposname
4578 run_test 99e "cvs update ======================================="
4581 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
4582 [ ! -d $DIR/d99cvsroot ] && test_99d
4583 cd $DIR/d99reposname
4584 $RUNAS cvs commit -m 'nomsg' foo99
4585 rm -fr $DIR/d99cvsroot
4587 run_test 99f "cvs commit ======================================="
4590 [ "$NETTYPE" = tcp ] || \
4591 { skip "TCP secure port test, not useful for NETTYPE=$NETTYPE" && \
4594 remote_ost_nodsh && skip "remote OST with nodsh" && return
4595 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4597 { skip "useless for local single node setup" && return; }
4599 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
4600 [ "$PROT" != "tcp" ] && continue
4601 RPORT=$(echo $REMOTE | cut -d: -f2)
4602 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
4605 LPORT=`echo $LOCAL | cut -d: -f2`
4606 if [ $LPORT -ge 1024 ]; then
4607 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
4609 error_exit "local: $LPORT > 1024, remote: $RPORT"
4612 [ "$rc" = 0 ] || error_exit "privileged port not found" )
4614 run_test 100 "check local port using privileged port ==========="
4616 function get_named_value()
4625 echo $line | sed "s/^$tag[ ]*//"
4632 export CACHE_MAX=`$LCTL get_param -n llite.*.max_cached_mb | head -n 1`
4634 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
4642 [ "$CPU" = "UML" ] && nreads=1000
4643 local cache_limit=32
4645 $LCTL set_param -n osc.*-osc*.rpc_stats 0
4646 trap cleanup_101a EXIT
4647 $LCTL set_param -n llite.*.read_ahead_stats 0
4648 $LCTL set_param -n llite.*.max_cached_mb $cache_limit
4651 # randomly read 10000 of 64K chunks from file 3x 32MB in size
4653 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
4654 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
4657 for s in `$LCTL get_param -n llite.*.read_ahead_stats | \
4658 get_named_value 'read but discarded' | cut -d" " -f1`; do
4659 discard=$(($discard + $s))
4663 if [ $(($discard * 10)) -gt $nreads ] ;then
4664 $LCTL get_param osc.*-osc*.rpc_stats
4665 $LCTL get_param llite.*.read_ahead_stats
4666 error "too many ($discard) discarded pages"
4668 rm -f $DIR/$tfile || true
4670 run_test 101a "check read-ahead for random reads ================"
4675 STRIPE_COUNT=$OSTCOUNT
4678 local list=$(comma_list $(osts_nodes))
4679 do_nodes $list $LCTL set_param -n obdfilter.*.read_cache_enable=0
4680 do_nodes $list $LCTL set_param -n obdfilter.*.writethrough_cache_enable=0
4682 trap cleanup_test101bc EXIT
4683 # prepare the read-ahead file
4684 $SETSTRIPE $DIR/$tfile -s $STRIPE_SIZE -i $STRIPE_OFFSET -c $OSTCOUNT
4686 dd if=/dev/zero of=$DIR/$tfile bs=1024k count=100 2> /dev/null
4689 cleanup_test101bc() {
4694 local list=$(comma_list $(osts_nodes))
4695 do_nodes $list $LCTL set_param -n obdfilter.*.read_cache_enable=1
4696 do_nodes $list $LCTL set_param -n obdfilter.*.writethrough_cache_enable=1
4700 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
4705 local STRIPE_SIZE=1048576
4706 local RA_INC=1048576
4707 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
4708 local FILE_LENGTH=$((64*100))
4709 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
4710 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
4711 DISCARD=`$LCTL get_param -n llite.*.read_ahead_stats | \
4712 get_named_value 'read but discarded' | \
4713 cut -d" " -f1 | calc_total`
4714 if [ $DISCARD -gt $discard_limit ]; then
4715 $LCTL get_param llite.*.read_ahead_stats
4716 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
4718 echo "Read-ahead success for size ${READ_SIZE}"
4723 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping stride IO stride-ahead test" && return
4724 local STRIPE_SIZE=1048576
4725 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
4726 local FILE_LENGTH=$((STRIPE_SIZE*100))
4727 local ITERATION=$((FILE_LENGTH/STRIDE_SIZE))
4728 # prepare the read-ahead file
4730 cancel_lru_locks osc
4731 for BIDX in 2 4 8 16 32 64 128 256
4733 local BSIZE=$((BIDX*4096))
4734 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
4735 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
4736 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
4737 $LCTL set_param -n llite.*.read_ahead_stats 0
4738 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
4739 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
4740 cancel_lru_locks osc
4746 run_test 101b "check stride-io mode read-ahead ================="
4749 local STRIPE_SIZE=1048576
4750 local FILE_LENGTH=$((STRIPE_SIZE*100))
4756 cancel_lru_locks osc
4757 $LCTL set_param osc.*.rpc_stats 0
4758 $READS -f $DIR/$tfile -s$FILE_LENGTH -b65536 -n$nreads -t 180
4759 for osc in $($LCTL get_param -N osc.*); do
4760 if [ "$osc" == "osc.num_refs" ]; then
4764 local lines=$($LCTL get_param -n ${osc}.rpc_stats | wc | awk '{print $1}')
4765 if [ $lines -le 20 ]; then
4769 local rpc4k=$($LCTL get_param -n ${osc}.rpc_stats |
4770 awk '$1 == "1:" { print $2; exit; }')
4771 local rpc8k=$($LCTL get_param -n ${osc}.rpc_stats |
4772 awk '$1 == "2:" { print $2; exit; }')
4773 local rpc16k=$($LCTL get_param -n ${osc}.rpc_stats |
4774 awk '$1 == "4:" { print $2; exit; }')
4775 local rpc32k=$($LCTL get_param -n ${osc}.rpc_stats |
4776 awk '$1 == "8:" { print $2; exit; }')
4778 [ $rpc4k != 0 ] && error "Small 4k read IO ${rpc4k}!"
4779 [ $rpc8k != 0 ] && error "Small 8k read IO ${rpc8k}!"
4780 [ $rpc16k != 0 ] && error "Small 16k read IO ${rpc16k}!"
4781 [ $rpc32k != 0 ] && error "Small 32k read IO ${rpc32k}!"
4782 echo "${osc} rpc check passed!"
4787 run_test 101c "check stripe_size aligned read-ahead ================="
4790 $LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1
4791 $LCTL set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
4795 local file=$DIR/$tfile
4796 local size=${FILESIZE_101c:-500}
4797 local ra_MB=${READAHEAD_MB:-40}
4799 local space=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
4800 [ $space -gt $((size / 1024)) ] ||
4801 { skip "Need free space ${size}M, have $space" && return; }
4803 echo Creating ${size}M test file $file
4804 dd if=/dev/zero of=$file bs=1M count=$size
4805 echo Cancel LRU locks on lustre client to flush the client cache
4806 cancel_lru_locks osc
4808 echo Disable read-ahead
4809 local old_READAHEAD=$(set_read_ahead 0)
4811 echo Reading the test file $file with read-ahead disabled
4812 time_ra_OFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$size")
4814 echo Cancel LRU locks on lustre client to flush the client cache
4815 cancel_lru_locks osc
4816 echo Enable read-ahead with ${ra_MB}MB
4817 set_read_ahead $ra_MB
4819 echo Reading the test file $file with read-ahead enabled
4820 time_ra_ON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$size")
4822 echo read-ahead disabled time read $time_ra_OFF
4823 echo read-ahead enabled time read $time_ra_ON
4825 set_read_ahead $old_READAHEAD
4828 [ $time_ra_ON -lt $time_ra_OFF ] ||
4829 error "read-ahead enabled time read (${time_ra_ON}s) is more than
4830 read-ahead disabled time read (${time_ra_OFF}s) filesize ${size}M"
4832 run_test 101d "file read with and without read-ahead enabled ================="
4835 local file=$DIR/$tfile
4840 local space=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
4841 local need_space=$((count * size))
4842 [ $space -gt $need_space ] ||
4843 { skip_env "Need free space $need_space, have $space" && return; }
4845 echo Creating $count ${size}K test files
4846 for ((i = 0; i < $count; i++)); do
4847 dd if=/dev/zero of=${file}_${i} bs=$blksize count=$size 2>/dev/null
4850 echo Cancel LRU locks on lustre client to flush the client cache
4851 cancel_lru_locks osc
4853 echo Reset readahead stats
4854 $LCTL set_param -n llite.*.read_ahead_stats 0
4856 for ((i = 0; i < $count; i++)); do
4857 dd if=${file}_${i} of=/dev/null bs=$blksize count=$size 2>/dev/null
4860 local miss=$($LCTL get_param -n llite.*.read_ahead_stats | \
4861 get_named_value 'misses' | cut -d" " -f1 | calc_total)
4863 for ((i = 0; i < $count; i++)); do
4864 rm -rf ${file}_${i} 2>/dev/null
4867 #10000 means 20% reads are missing in readahead
4868 [ $miss -lt 10000 ] || error "misses too much for small reads"
4870 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
4872 cleanup_test101f() {
4874 $LCTL set_param -n llite.*.max_read_ahead_whole_mb $MAX_WHOLE_MB
4875 rm -rf $DIR/$tfile 2>/dev/null
4879 local file=$DIR/$tfile
4882 MAX_WHOLE_MB=$($LCTL get_param -n llite.*.max_read_ahead_whole_mb)
4883 $LCTL set_param -n llite.*.max_read_ahead_whole_mb 2
4884 dd if=/dev/zero of=${file} bs=2097152 count=1 2>/dev/null
4885 trap cleanup_test101f EXIT
4887 echo Cancel LRU locks on lustre client to flush the client cache
4888 cancel_lru_locks osc
4890 echo Reset readahead stats
4891 $LCTL set_param -n llite.*.read_ahead_stats 0
4892 # Random read in a 2M file, because max_read_ahead_whole_mb = 2M,
4893 # readahead should read in 2M file on second read, so only miss
4895 echo Random 4K reads on 2M file for 1000 times
4896 $READS -f $file -s 2097152 -b 4096 -n $nreads
4898 echo checking missing pages
4899 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
4900 get_named_value 'misses' | cut -d" " -f1 | calc_total)
4902 [ $miss -lt 3 ] || error "misses too much pages!"
4905 run_test 101f "check read-ahead for max_read_ahead_whole_mb"
4909 chown $RUNAS_ID $DIR/$tdir
4912 STRIPE_COUNT=$OSTCOUNT
4913 [ $OSTCOUNT -gt 4 ] && STRIPE_COUNT=4
4915 trap cleanup_test102 EXIT
4917 $1 $SETSTRIPE $tdir -s $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT
4921 for count in `seq 1 $STRIPE_COUNT`
4923 for offset in `seq 0 $[$STRIPE_COUNT - 1]`
4925 local stripe_size=`expr $STRIPE_SIZE \* $num`
4926 local file=file"$num-$offset-$count"
4927 $1 $SETSTRIPE $file -s $stripe_size -i $offset -c $count
4933 $1 $TAR cf $TMP/f102.tar $tdir --xattrs
4939 rm -rf $DIR/d0.sanity/d102
4943 local testfile=$DIR/xattr_testfile
4948 [ "$UID" != 0 ] && skip_env "must run as root" && return
4949 [ -z "`lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr`" ] && skip_env "must have user_xattr" && return
4951 [ -z "$(which setfattr 2>/dev/null)" ] && skip_env "could not find setfattr" && return
4953 echo "set/get xattr..."
4954 setfattr -n trusted.name1 -v value1 $testfile || error
4955 [ "`getfattr -n trusted.name1 $testfile 2> /dev/null | \
4956 grep "trusted.name1"`" == "trusted.name1=\"value1\"" ] || error
4958 setfattr -n user.author1 -v author1 $testfile || error
4959 [ "`getfattr -n user.author1 $testfile 2> /dev/null | \
4960 grep "user.author1"`" == "user.author1=\"author1\"" ] || error
4963 setfattr -n trusted.name2 -v value2 $testfile || error
4964 setfattr -n trusted.name3 -v value3 $testfile || error
4965 [ `getfattr -d -m "^trusted" $testfile 2> /dev/null | \
4966 grep "trusted.name" | wc -l` -eq 3 ] || error
4969 setfattr -n user.author2 -v author2 $testfile || error
4970 setfattr -n user.author3 -v author3 $testfile || error
4971 [ `getfattr -d -m "^user" $testfile 2> /dev/null | \
4972 grep "user" | wc -l` -eq 3 ] || error
4974 echo "remove xattr..."
4975 setfattr -x trusted.name1 $testfile || error
4976 getfattr -d -m trusted $testfile 2> /dev/null | \
4977 grep "trusted.name1" && error || true
4979 setfattr -x user.author1 $testfile || error
4980 getfattr -d -m user $testfile 2> /dev/null | \
4981 grep "user.author1" && error || true
4983 # b10667: setting lustre special xattr be silently discarded
4984 echo "set lustre special xattr ..."
4985 setfattr -n "trusted.lov" -v "invalid value" $testfile || error
4989 run_test 102a "user xattr test =================================="
4992 # b10930: get/set/list trusted.lov xattr
4993 echo "get/set/list trusted.lov xattr ..."
4994 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
4995 local testfile=$DIR/$tfile
4996 $SETSTRIPE -s 65536 -i 1 -c 2 $testfile || error "setstripe failed"
4997 getfattr -d -m "^trusted" $testfile 2> /dev/null | \
4998 grep "trusted.lov" || error "can't get trusted.lov from $testfile"
5000 local testfile2=${testfile}2
5001 local value=`getfattr -n trusted.lov $testfile 2> /dev/null | \
5002 grep "trusted.lov" |sed -e 's/[^=]\+=//'`
5005 setfattr -n trusted.lov -v $value $testfile2
5006 local tmp_file=${testfile}3
5007 $GETSTRIPE -v $testfile2 > $tmp_file
5008 local stripe_size=`grep "size" $tmp_file| awk '{print $2}'`
5009 local stripe_count=`grep "count" $tmp_file| awk '{print $2}'`
5010 [ "$stripe_size" -eq 65536 ] || error "stripe size $stripe_size != 65536"
5011 [ "$stripe_count" -eq 2 ] || error "stripe count $stripe_count != 2"
5014 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
5017 # b10930: get/set/list lustre.lov xattr
5018 echo "get/set/list lustre.lov xattr ..."
5019 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
5021 chown $RUNAS_ID $DIR/$tdir
5022 local testfile=$DIR/$tdir/$tfile
5023 $RUNAS $SETSTRIPE -s 65536 -i 1 -c 2 $testfile||error "setstripe failed"
5024 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
5025 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
5027 local testfile2=${testfile}2
5028 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
5029 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
5031 $RUNAS $MCREATE $testfile2
5032 $RUNAS setfattr -n lustre.lov -v $value $testfile2
5033 local tmp_file=${testfile}3
5034 $RUNAS $GETSTRIPE -v $testfile2 > $tmp_file
5035 local stripe_size=`grep "size" $tmp_file| awk '{print $2}'`
5036 local stripe_count=`grep "count" $tmp_file| awk '{print $2}'`
5037 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
5038 [ $stripe_count -eq 2 ] || error "stripe count $stripe_count != 2"
5040 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
5042 compare_stripe_info1() {
5043 local stripe_index_all_zero=1
5047 for count in `seq 1 $STRIPE_COUNT`
5049 for offset in `seq 0 $[$STRIPE_COUNT - 1]`
5051 local size=`expr $STRIPE_SIZE \* $num`
5052 local file=file"$num-$offset-$count"
5053 get_stripe_info client $PWD/$file "$1"
5054 if [ $stripe_size -ne $size ]; then
5055 error "$file: different stripe size $stripe_size, expected $size" && return
5057 if [ $stripe_count -ne $count ]; then
5058 error "$file: different stripe count $stripe_count, expected $count" && return
5060 if [ $stripe_index -ne 0 ]; then
5061 stripe_index_all_zero=0
5066 [ $stripe_index_all_zero -eq 1 ] && error "all files are being extracted starting from OST index 0"
5070 compare_stripe_info2() {
5073 for count in `seq 1 $STRIPE_COUNT`
5075 for offset in `seq 0 $[$STRIPE_COUNT - 1]`
5077 local size=`expr $STRIPE_SIZE \* $num`
5078 local file=file"$num-$offset-$count"
5079 get_stripe_info client $PWD/$file
5080 if [ $stripe_size -ne $size ]; then
5081 error "$file: different stripe size $stripe_size, expected $size" && return
5083 if [ $stripe_count -ne $count ]; then
5084 error "$file: different stripe count $stripe_count, expected $count" && return
5086 if [ $stripe_index -ne $offset ]; then
5087 error "$file: different stripe offset $stripe_index, expected $offset" && return
5095 [ -n "$(which tar 2>/dev/null)" ] && strings $(which tar) | grep -q lustre && echo tar
5099 # b10930: tar test for trusted.lov xattr
5100 TAR=$(find_lustre_tar)
5101 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
5102 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
5105 $TAR xf $TMP/f102.tar -C $DIR/d102d --xattrs
5107 compare_stripe_info1
5109 run_test 102d "tar restore stripe info from tarfile,not keep osts ==========="
5112 # b10930: tar test for trusted.lov xattr
5113 TAR=$(find_lustre_tar)
5114 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
5115 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
5119 $TAR cf - --xattrs $tdir | $TAR xf - --xattrs -C $DIR/d102f
5121 compare_stripe_info1
5123 run_test 102f "tar copy files, not keep osts ==========="
5125 test_102h() { # bug 15777
5126 [ -z $(lctl get_param -n mdc.*.connect_flags | grep xattr) ] &&
5127 skip "must have user_xattr" && return
5128 [ -z "$(which setfattr 2>/dev/null)" ] &&
5129 skip_env "could not find setfattr" && return
5134 VALUE=datadatadatadatadatadatadatadata
5135 while [ $(echo $VALUE | wc -c) -lt $XSIZE ]; do
5136 VALUE="$VALUE$VALUE"
5138 log "save $XBIG on $DIR/$tfile"
5139 setfattr -n $XBIG -v "$VALUE" $DIR/$tfile ||
5140 error "saving $XBIG on $DIR/$tfile failed"
5141 ORIG=$(getfattr -n $XBIG $DIR/$tfile 2> /dev/null | grep $XBIG)
5142 OSIZE=$(echo $ORIG | wc -c)
5143 [ $OSIZE -lt $XSIZE ] && error "set $XBIG too small ($OSIZE < $XSIZE)"
5146 log "save $XSML on $DIR/$tfile"
5147 setfattr -n $XSML -v val $DIR/$tfile ||
5148 error "saving $XSML on $DIR/$tfile failed"
5149 NEW=$(getfattr -n $XBIG $DIR/$tfile 2> /dev/null | grep $XBIG)
5150 if [ "$NEW" != "$ORIG" ]; then
5153 error "$XBIG different after saving $XSML"
5156 log "grow $XSML on $DIR/$tfile"
5157 setfattr -n $XSML -v "$VALUE" $DIR/$tfile ||
5158 error "growing $XSML on $DIR/$tfile failed"
5159 NEW=$(getfattr -n $XBIG $DIR/$tfile 2> /dev/null | grep $XBIG)
5160 if [ "$NEW" != "$ORIG" ]; then
5163 error "$XBIG different after growing $XSML"
5165 log "$XBIG still valid after growing $XSML"
5168 run_test 102h "grow xattr from inside inode to external block"
5170 test_102i() { # bug 17038
5172 ln -s $DIR/$tfile $DIR/${tfile}link
5173 getfattr -n trusted.lov $DIR/$tfile || error "lgetxattr on $DIR/$tfile failed"
5174 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"
5175 rm -f $DIR/$tfile $DIR/${tfile}link
5177 run_test 102i "lgetxattr test on symbolic link ============"
5180 TAR=$(find_lustre_tar)
5181 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
5182 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
5183 setup_test102 "$RUNAS"
5185 chown $RUNAS_ID $DIR/d102j
5186 $RUNAS $TAR xf $TMP/f102.tar -C $DIR/d102j --xattrs
5188 compare_stripe_info1 "$RUNAS"
5190 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
5194 # b22187 just check that does not crash for regular file.
5195 setfattr -n trusted.lov $DIR/$tfile
5196 # b22187 'setfattr -n trusted.lov' should work as remove LOV EA for directories
5197 local test_kdir=$DIR/d102k
5199 local default_size=`$GETSTRIPE -s $test_kdir`
5200 local default_count=`$GETSTRIPE -c $test_kdir`
5201 local default_offset=`$GETSTRIPE -o $test_kdir`
5202 $SETSTRIPE -s 65536 -i 1 -c $OSTCOUNT $test_kdir || error 'dir setstripe failed'
5203 setfattr -n trusted.lov $test_kdir
5204 local stripe_size=`$GETSTRIPE -s $test_kdir`
5205 local stripe_count=`$GETSTRIPE -c $test_kdir`
5206 local stripe_offset=`$GETSTRIPE -o $test_kdir`
5207 [ $stripe_size -eq $default_size ] || error "stripe size $stripe_size != $default_size"
5208 [ $stripe_count -eq $default_count ] || error "stripe count $stripe_count != $default_count"
5209 [ $stripe_offset -eq $default_offset ] || error "stripe offset $stripe_offset != $default_offset"
5210 rm -rf $DIR/$tfile $test_kdir
5212 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
5215 # LU-532 trusted. xattr is invisible to non-root
5216 local testfile=$DIR/$tfile
5220 echo "listxattr as user..."
5221 chown $RUNAS_ID $testfile
5222 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
5223 grep -q "trusted" &&
5224 error "$testfile trusted xattrs are user visible"
5228 run_test 102l "listxattr filter test =================================="
5234 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
5239 [ "$UID" != 0 ] && skip_env "must run as root" && return
5240 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
5241 [ -z "$(which setfacl 2>/dev/null)" ] && skip_env "could not find setfacl" && return
5242 $GSS && skip "could not run under gss" && return
5244 declare -a identity_old
5246 for num in `seq $MDSCOUNT`; do
5247 switch_identity $num true || identity_old[$num]=$?
5254 echo "performing cp ..."
5255 run_acl_subtest cp || error
5256 echo "performing getfacl-noacl..."
5257 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
5258 echo "performing misc..."
5259 run_acl_subtest misc || error "misc test failed"
5260 echo "performing permissions..."
5261 run_acl_subtest permissions || error "permissions failed"
5262 echo "performing setfacl..."
5263 run_acl_subtest setfacl || error "setfacl test failed"
5265 # inheritance test got from HP
5266 echo "performing inheritance..."
5267 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
5268 chmod +x make-tree || error "chmod +x failed"
5269 run_acl_subtest inheritance || error "inheritance test failed"
5275 for num in `seq $MDSCOUNT`; do
5276 if [ "${identity_old[$num]}" = 1 ]; then
5277 switch_identity $num false || identity_old[$num]=$?
5281 run_test 103 "acl test ========================================="
5285 lfs df || error "lfs df failed"
5286 lfs df -ih || error "lfs df -ih failed"
5287 lfs df -h $DIR || error "lfs df -h $DIR failed"
5288 lfs df -i $DIR || error "lfs df -i $DIR failed"
5289 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
5290 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
5292 OSC=`lctl get_param -n devices | awk '/-osc-/ {print $4}' | head -n 1`
5293 lctl --device %$OSC deactivate
5294 lfs df || error "lfs df with deactivated OSC failed"
5295 lctl --device %$OSC recover
5296 lfs df || error "lfs df with reactivated OSC failed"
5299 run_test 104a "lfs df [-ih] [path] test ========================="
5302 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5304 denied_cnt=$((`$RUNAS $LFS check servers 2>&1 | grep "Permission denied" | wc -l`))
5305 if [ $denied_cnt -ne 0 ];
5307 error "lfs check servers test failed"
5310 run_test 104b "$RUNAS lfs check servers test ===================="
5313 # doesn't work on 2.4 kernels
5315 if [ -n "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ];
5317 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
5319 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
5323 run_test 105a "flock when mounted without -o flock test ========"
5327 if [ -n "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ];
5329 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
5331 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
5335 run_test 105b "fcntl when mounted without -o flock test ========"
5339 if [ -n "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ];
5341 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
5343 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
5347 run_test 105c "lockf when mounted without -o flock test ========"
5349 test_105d() { # bug 15924
5351 [ -z "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ] && \
5352 skip "mount w/o flock enabled" && return
5353 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
5354 $LCTL set_param fail_loc=0x80000315
5355 flocks_test 2 $DIR/$tdir
5357 run_test 105d "flock race (should not freeze) ========"
5359 test_105e() { # bug 22660 && 22040
5360 [ -z "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ] && \
5361 skip "mount w/o flock enabled" && return
5363 flocks_test 3 $DIR/$tfile
5365 run_test 105e "Two conflicting flocks from same process ======="
5367 test_106() { #bug 10921
5369 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
5370 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
5372 run_test 106 "attempt exec of dir followed by chown of that dir"
5381 local save_pattern=$(sysctl -n kernel.core_pattern)
5382 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
5383 sysctl -w kernel.core_pattern=$file
5384 sysctl -w kernel.core_uses_pid=0
5392 kill -s 11 $SLEEPPID
5394 if [ -e $file ]; then
5395 size=`stat -c%s $file`
5396 [ $size -eq 0 ] && error "Fail to create core file $file"
5398 error "Fail to create core file $file"
5401 sysctl -w kernel.core_pattern=$save_pattern
5402 sysctl -w kernel.core_uses_pid=$save_uses_pid
5405 run_test 107 "Coredump on SIG"
5409 mkdir $DIR/d110/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa || error "mkdir with 255 char fail"
5410 mkdir $DIR/d110/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb && error "mkdir with 256 char should fail, but not"
5411 touch $DIR/d110/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx || error "create with 255 char fail"
5412 touch $DIR/d110/yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy && error ""create with 256 char should fail, but not
5417 run_test 110 "filename length checking"
5420 OSTIO_pre=$(ps -e|grep ll_ost_io|awk '{print $4}'|sort -n|tail -1|\
5422 [ -z "$OSTIO_pre" ] && skip "no OSS threads" && \
5424 echo "Starting with $OSTIO_pre threads"
5427 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
5428 [ $NUMFREE -lt $NUMTEST ] && NUMTEST=$(($NUMFREE - 1000))
5429 echo "$NUMTEST creates/unlinks"
5431 createmany -o $DIR/$tdir/$tfile $NUMTEST
5432 unlinkmany $DIR/$tdir/$tfile $NUMTEST
5434 OSTIO_post=$(ps -e|grep ll_ost_io|awk '{print $4}'|sort -n|tail -1|\
5437 # don't return an error
5438 [ $OSTIO_post -eq $OSTIO_pre ] && echo \
5439 "WARNING: No new ll_ost_io threads were created ($OSTIO_pre)" &&\
5440 echo "This may be fine, depending on what ran before this test" &&\
5441 echo "and how fast this system is." && return
5443 echo "Started with $OSTIO_pre threads, ended with $OSTIO_post"
5445 run_test 115 "verify dynamic thread creation===================="
5448 wait_delete_completed
5449 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
5450 echo OST kbytes available: ${AVAIL[@]}
5451 MAXI=0; MAXV=${AVAIL[0]}
5452 MINI=0; MINV=${AVAIL[0]}
5453 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
5454 #echo OST $i: ${AVAIL[i]}kb
5455 if [ ${AVAIL[i]} -gt $MAXV ]; then
5456 MAXV=${AVAIL[i]}; MAXI=$i
5458 if [ ${AVAIL[i]} -lt $MINV ]; then
5459 MINV=${AVAIL[i]}; MINI=$i
5462 echo Min free space: OST $MINI: $MINV
5463 echo Max free space: OST $MAXI: $MAXV
5467 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs" && return
5469 echo -n "Free space priority "
5470 lctl get_param -n lov.*-clilov-*.qos_prio_free
5473 [ $MINV -gt 960000 ] && skip "too much free space in OST$MINI, skip" &&\
5476 # generate uneven OSTs
5477 mkdir -p $DIR/$tdir/OST${MINI}
5480 echo "Filling 25% remaining space in OST${MINI} with ${FILL}Kb"
5481 $SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI}||error "setstripe failed"
5483 while [ $FILL -gt 0 ]; do
5485 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i bs=2M count=1 2>/dev/null
5486 FILL=$(($FILL - 2048))
5494 DIFF=$(($MAXV - $MINV))
5495 DIFF2=$(($DIFF * 100 / $MINV))
5496 echo -n "diff=${DIFF}=${DIFF2}% must be > 20% for QOS mode..."
5497 if [ $DIFF2 -gt 20 ]; then
5500 echo "failed - QOS mode won't be used"
5501 error_ignore "QOS imbalance criteria not met"
5505 MINI1=$MINI; MINV1=$MINV
5506 MAXI1=$MAXI; MAXV1=$MAXV
5508 # now fill using QOS
5509 echo writing a bunch of files to QOS-assigned OSTs
5510 $SETSTRIPE $DIR/$tdir -c 1
5512 while [ $FILL -gt 0 ]; do
5514 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1024 count=200 2>/dev/null
5515 FILL=$(($FILL - 200))
5518 echo "wrote $i 200k files"
5522 echo "Note: free space may not be updated, so measurements might be off"
5524 DIFF2=$(($MAXV - $MINV))
5525 echo "free space delta: orig $DIFF final $DIFF2"
5526 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
5527 DIFF=$(($MINV1 - ${AVAIL[$MINI1]}))
5528 echo "Wrote $DIFF to smaller OST $MINI1"
5529 DIFF2=$(($MAXV1 - ${AVAIL[$MAXI1]}))
5530 echo "Wrote $DIFF2 to larger OST $MAXI1"
5531 [ $DIFF -gt 0 ] && echo "Wrote $(($DIFF2 * 100 / $DIFF - 100))% more data to larger OST $MAXI1"
5533 # Figure out which files were written where
5534 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
5535 awk '/'$MINI1': / {print $2; exit}')
5537 MINC=$($GETSTRIPE --obd $UUID $DIR/$tdir | wc -l)
5538 echo "$MINC files created on smaller OST $MINI1"
5539 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
5540 awk '/'$MAXI1': / {print $2; exit}')
5542 MAXC=$($GETSTRIPE --obd $UUID $DIR/$tdir | wc -l)
5543 echo "$MAXC files created on larger OST $MAXI1"
5544 [ $MINC -gt 0 ] && echo "Wrote $(($MAXC * 100 / $MINC - 100))% more files to larger OST $MAXI1"
5545 [ $MAXC -gt $MINC ] || error_ignore "stripe QOS didn't balance free space"
5549 run_test 116 "stripe QOS: free space balance ==================="
5551 test_117() # bug 10891
5553 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
5554 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
5555 lctl set_param fail_loc=0x21e
5556 > $DIR/$tfile || error "truncate failed"
5557 lctl set_param fail_loc=0
5558 echo "Truncate succeeded."
5561 run_test 117 "verify fsfilt_extend =========="
5563 export OLD_RESENDCOUNT=""
5564 set_resend_count () {
5565 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
5566 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -1)
5567 lctl set_param -n $PROC_RESENDCOUNT $1
5568 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
5571 [ "$SLOW" = "no" ] && set_resend_count 4 # for reduce test_118* time (bug 14842)
5573 # Reset async IO behavior after error case
5575 FILE=$DIR/reset_async
5577 # Ensure all OSCs are cleared
5578 $LSTRIPE -c -1 $FILE
5579 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
5584 test_118a() #bug 11710
5588 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
5589 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
5590 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
5592 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
5593 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
5598 run_test 118a "verify O_SYNC works =========="
5602 remote_ost_nodsh && skip "remote OST with nodsh" && return
5606 #define OBD_FAIL_OST_ENOENT 0x217
5607 set_nodes_failloc "$(osts_nodes)" 0x217
5608 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
5610 set_nodes_failloc "$(osts_nodes)" 0
5611 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
5612 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
5615 if [[ $RC -eq 0 ]]; then
5616 error "Must return error due to dropped pages, rc=$RC"
5620 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
5621 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
5625 echo "Dirty pages not leaked on ENOENT"
5627 # Due to the above error the OSC will issue all RPCs syncronously
5628 # until a subsequent RPC completes successfully without error.
5629 multiop $DIR/$tfile Ow4096yc
5634 run_test 118b "Reclaim dirty pages on fatal error =========="
5638 remote_ost_nodsh && skip "remote OST with nodsh" && return
5642 #define OBD_FAIL_OST_EROFS 0x216
5643 set_nodes_failloc "$(osts_nodes)" 0x216
5645 # multiop should block due to fsync until pages are written
5646 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
5650 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
5651 error "Multiop failed to block on fsync, pid=$MULTIPID"
5654 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
5656 if [[ $WRITEBACK -eq 0 ]]; then
5657 error "No page in writeback, writeback=$WRITEBACK"
5660 set_nodes_failloc "$(osts_nodes)" 0
5663 if [[ $RC -ne 0 ]]; then
5664 error "Multiop fsync failed, rc=$RC"
5667 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
5668 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
5670 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
5671 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
5675 echo "Dirty pages flushed via fsync on EROFS"
5678 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
5682 remote_ost_nodsh && skip "remote OST with nodsh" && return
5686 #define OBD_FAIL_OST_BRW_PAUSE_BULK
5687 set_nodes_failloc "$(osts_nodes)" 0x214
5688 # multiop should block due to fsync until pages are written
5689 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
5693 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
5694 error "Multiop failed to block on fsync, pid=$MULTIPID"
5697 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
5699 if [[ $WRITEBACK -eq 0 ]]; then
5700 error "No page in writeback, writeback=$WRITEBACK"
5703 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
5704 set_nodes_failloc "$(osts_nodes)" 0
5706 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
5707 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
5709 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
5710 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
5714 echo "Dirty pages gaurenteed flushed via fsync"
5717 run_test 118d "Fsync validation inject a delay of the bulk =========="
5722 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
5723 lctl set_param fail_loc=0x8000040a
5725 # Should simulate EINVAL error which is fatal
5726 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
5728 if [[ $RC -eq 0 ]]; then
5729 error "Must return error due to dropped pages, rc=$RC"
5732 lctl set_param fail_loc=0x0
5734 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
5735 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
5736 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
5738 if [[ $LOCKED -ne 0 ]]; then
5739 error "Locked pages remain in cache, locked=$LOCKED"
5742 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
5743 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
5747 echo "No pages locked after fsync"
5752 run_test 118f "Simulate unrecoverable OSC side error =========="
5757 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
5758 lctl set_param fail_loc=0x406
5760 # simulate local -ENOMEM
5761 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
5764 lctl set_param fail_loc=0
5765 if [[ $RC -eq 0 ]]; then
5766 error "Must return error due to dropped pages, rc=$RC"
5769 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
5770 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
5771 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
5773 if [[ $LOCKED -ne 0 ]]; then
5774 error "Locked pages remain in cache, locked=$LOCKED"
5777 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
5778 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
5782 echo "No pages locked after fsync"
5787 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
5790 remote_ost_nodsh && skip "remote OST with nodsh" && return
5794 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
5795 set_nodes_failloc "$(osts_nodes)" 0x20e
5796 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
5797 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
5800 set_nodes_failloc "$(osts_nodes)" 0
5801 if [[ $RC -eq 0 ]]; then
5802 error "Must return error due to dropped pages, rc=$RC"
5805 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
5806 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
5807 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
5809 if [[ $LOCKED -ne 0 ]]; then
5810 error "Locked pages remain in cache, locked=$LOCKED"
5813 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
5814 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
5818 echo "No pages locked after fsync"
5822 run_test 118h "Verify timeout in handling recoverables errors =========="
5825 remote_ost_nodsh && skip "remote OST with nodsh" && return
5829 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
5830 set_nodes_failloc "$(osts_nodes)" 0x20e
5832 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
5833 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
5836 set_nodes_failloc "$(osts_nodes)" 0
5840 if [[ $RC -ne 0 ]]; then
5841 error "got error, but should be not, rc=$RC"
5844 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
5845 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
5846 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
5847 if [[ $LOCKED -ne 0 ]]; then
5848 error "Locked pages remain in cache, locked=$LOCKED"
5851 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
5852 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
5856 echo "No pages locked after fsync"
5860 run_test 118i "Fix error before timeout in recoverable error =========="
5863 remote_ost_nodsh && skip "remote OST with nodsh" && return
5867 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
5868 set_nodes_failloc "$(osts_nodes)" 0x220
5870 # return -EIO from OST
5871 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
5873 set_nodes_failloc "$(osts_nodes)" 0x0
5874 if [[ $RC -eq 0 ]]; then
5875 error "Must return error due to dropped pages, rc=$RC"
5878 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
5879 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
5880 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
5881 if [[ $LOCKED -ne 0 ]]; then
5882 error "Locked pages remain in cache, locked=$LOCKED"
5885 # in recoverable error on OST we want resend and stay until it finished
5886 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
5887 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
5891 echo "No pages locked after fsync"
5895 run_test 118j "Simulate unrecoverable OST side error =========="
5899 remote_ost_nodsh && skip "remote OSTs with nodsh" && return
5901 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
5902 set_nodes_failloc "$(osts_nodes)" 0x20e
5905 for ((i=0;i<10;i++)); do
5906 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
5907 error "dd to $DIR/$tdir/$tfile-$i failed" )&
5914 set_nodes_failloc "$(osts_nodes)" 0
5917 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
5923 multiop $DIR/$tdir Dy || error "fsync dir failed"
5926 run_test 118l "fsync dir ========="
5928 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
5930 test_119a() # bug 11737
5932 BSIZE=$((512 * 1024))
5933 directio write $DIR/$tfile 0 1 $BSIZE
5934 # We ask to read two blocks, which is more than a file size.
5935 # directio will indicate an error when requested and actual
5936 # sizes aren't equeal (a normal situation in this case) and
5937 # print actual read amount.
5938 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
5939 if [ "$NOB" != "$BSIZE" ]; then
5940 error "read $NOB bytes instead of $BSIZE"
5944 run_test 119a "Short directIO read must return actual read amount"
5946 test_119b() # bug 11737
5948 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
5950 $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
5951 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
5953 multiop $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) || \
5954 error "direct read failed"
5957 run_test 119b "Sparse directIO read must return actual read amount"
5959 test_119c() # bug 13099
5962 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
5963 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
5966 run_test 119c "Testing for direct read hitting hole"
5968 test_119d() # bug 15950
5970 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
5971 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
5973 $SETSTRIPE $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
5974 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
5975 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
5976 lctl set_param fail_loc=0x40d
5977 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
5980 cat $DIR/$tfile > /dev/null &
5981 lctl set_param fail_loc=0
5984 log "the DIO writes have completed, now wait for the reads (should not block very long)"
5986 [ -n "`ps h -p $pid_reads -o comm`" ] && \
5987 error "the read rpcs have not completed in 2s"
5989 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
5991 run_test 119d "The DIO path should try to send a new rpc once one is completed"
5995 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
5996 skip "no early lock cancel on server" && return 0
5997 lru_resize_disable mdc
5998 lru_resize_disable osc
5999 cancel_lru_locks mdc
6000 stat $DIR/$tdir > /dev/null
6001 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6002 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6004 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6005 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6006 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6007 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6008 lru_resize_enable mdc
6009 lru_resize_enable osc
6011 run_test 120a "Early Lock Cancel: mkdir test"
6015 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6016 skip "no early lock cancel on server" && return 0
6017 lru_resize_disable mdc
6018 lru_resize_disable osc
6019 cancel_lru_locks mdc
6020 stat $DIR/$tdir > /dev/null
6021 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6022 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6024 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6025 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6026 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6027 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6028 lru_resize_enable mdc
6029 lru_resize_enable osc
6031 run_test 120b "Early Lock Cancel: create test"
6035 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6036 skip "no early lock cancel on server" && return 0
6037 lru_resize_disable mdc
6038 lru_resize_disable osc
6039 mkdir -p $DIR/$tdir/d1 $DIR/$tdir/d2
6040 touch $DIR/$tdir/d1/f1
6041 cancel_lru_locks mdc
6042 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
6043 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6044 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6045 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
6046 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6047 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6048 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6049 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6050 lru_resize_enable mdc
6051 lru_resize_enable osc
6053 run_test 120c "Early Lock Cancel: link test"
6057 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6058 skip "no early lock cancel on server" && return 0
6059 lru_resize_disable mdc
6060 lru_resize_disable osc
6062 cancel_lru_locks mdc
6063 stat $DIR/$tdir > /dev/null
6064 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6065 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6066 chmod a+x $DIR/$tdir
6067 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6068 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6069 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6070 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6071 lru_resize_enable mdc
6072 lru_resize_enable osc
6074 run_test 120d "Early Lock Cancel: setattr test"
6078 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6079 skip "no early lock cancel on server" && return 0
6080 lru_resize_disable mdc
6081 lru_resize_disable osc
6082 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
6083 cancel_lru_locks mdc
6084 cancel_lru_locks osc
6085 dd if=$DIR/$tdir/f1 of=/dev/null
6086 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
6087 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6088 awk '/ldlm_cancel/ {print $2}'`
6089 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6090 awk '/ldlm_bl_callback/ {print $2}'`
6091 unlink $DIR/$tdir/f1
6092 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6093 awk '/ldlm_cancel/ {print $2}'`
6094 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6095 awk '/ldlm_bl_callback/ {print $2}'`
6096 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6097 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6098 lru_resize_enable mdc
6099 lru_resize_enable osc
6101 run_test 120e "Early Lock Cancel: unlink test"
6104 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6105 skip "no early lock cancel on server" && return 0
6107 lru_resize_disable mdc
6108 lru_resize_disable osc
6109 mkdir -p $DIR/$tdir/d1 $DIR/$tdir/d2
6110 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
6111 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
6112 cancel_lru_locks mdc
6113 cancel_lru_locks osc
6114 dd if=$DIR/$tdir/d1/f1 of=/dev/null
6115 dd if=$DIR/$tdir/d2/f2 of=/dev/null
6116 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
6117 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6118 awk '/ldlm_cancel/ {print $2}'`
6119 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6120 awk '/ldlm_bl_callback/ {print $2}'`
6121 mv $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
6122 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6123 awk '/ldlm_cancel/ {print $2}'`
6124 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6125 awk '/ldlm_bl_callback/ {print $2}'`
6126 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6127 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6128 lru_resize_enable mdc
6129 lru_resize_enable osc
6131 run_test 120f "Early Lock Cancel: rename test"
6134 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6135 skip "no early lock cancel on server" && return 0
6136 lru_resize_disable mdc
6137 lru_resize_disable osc
6139 echo create $count files
6141 cancel_lru_locks mdc
6142 cancel_lru_locks osc
6145 can0=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6146 awk '/ldlm_cancel/ {print $2}'`
6147 blk0=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6148 awk '/ldlm_bl_callback/ {print $2}'`
6149 createmany -o $DIR/$tdir/f $count
6151 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6152 awk '/ldlm_cancel/ {print $2}'`
6153 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6154 awk '/ldlm_bl_callback/ {print $2}'`
6156 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
6157 echo rm $count files
6160 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6161 awk '/ldlm_cancel/ {print $2}'`
6162 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6163 awk '/ldlm_bl_callback/ {print $2}'`
6165 echo total: $count removes in $((t2-t1))
6166 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
6168 # wait for commitment of removal
6169 lru_resize_enable mdc
6170 lru_resize_enable osc
6172 run_test 120g "Early Lock Cancel: performance test"
6174 test_121() { #bug #10589
6176 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
6177 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
6178 lctl set_param fail_loc=0x310
6179 cancel_lru_locks osc > /dev/null
6180 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
6181 lctl set_param fail_loc=0
6182 [ "$reads" -eq "$writes" ] || error "read" $reads "blocks, must be" $writes
6184 run_test 121 "read cancel race ========="
6186 test_123a() { # was test 123, statahead(bug 11401)
6188 if [ -z "$(grep "processor.*: 1" /proc/cpuinfo)" ]; then
6189 log "testing on UP system. Performance may be not as good as expected."
6195 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
6196 [ $NUMFREE -gt 100000 ] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
6198 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
6199 createmany -o $DIR/$tdir/$tfile $j $((i - j))
6201 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
6202 lctl set_param -n llite.*.statahead_max 0
6203 lctl get_param llite.*.statahead_max
6204 cancel_lru_locks mdc
6205 cancel_lru_locks osc
6207 time ls -l $DIR/$tdir | wc -l
6209 delta=$((etime - stime))
6210 log "ls $i files without statahead: $delta sec"
6211 lctl set_param llite.*.statahead_max=$max
6213 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
6214 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
6215 cancel_lru_locks mdc
6216 cancel_lru_locks osc
6218 time ls -l $DIR/$tdir | wc -l
6220 delta_sa=$((etime - stime))
6221 log "ls $i files with statahead: $delta_sa sec"
6222 lctl get_param -n llite.*.statahead_stats
6223 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
6225 [ $swrong -lt $ewrong ] && log "statahead was stopped, maybe too many locks held!"
6226 [ $delta -eq 0 -o $delta_sa -eq 0 ] && continue
6228 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
6229 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
6230 lctl set_param -n llite.*.statahead_max 0
6231 lctl get_param llite.*.statahead_max
6232 cancel_lru_locks mdc
6233 cancel_lru_locks osc
6235 time ls -l $DIR/$tdir | wc -l
6237 delta=$((etime - stime))
6238 log "ls $i files again without statahead: $delta sec"
6239 lctl set_param llite.*.statahead_max=$max
6240 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
6241 if [ $SLOWOK -eq 0 ]; then
6242 error "ls $i files is slower with statahead!"
6244 log "ls $i files is slower with statahead!"
6250 [ $delta -gt 20 ] && break
6251 [ $delta -gt 8 ] && MULT=$((50 / delta))
6252 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
6260 delta=$((etime - stime))
6261 log "rm -r $DIR/$tdir/: $delta seconds"
6263 lctl get_param -n llite.*.statahead_stats
6265 run_test 123a "verify statahead work"
6267 test_123b () { # statahead(bug 15027)
6269 createmany -o $DIR/$tdir/$tfile-%d 1000
6271 cancel_lru_locks mdc
6272 cancel_lru_locks osc
6274 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
6275 lctl set_param fail_loc=0x80000803
6276 ls -lR $DIR/$tdir > /dev/null
6278 lctl set_param fail_loc=0x0
6279 lctl get_param -n llite.*.statahead_stats
6284 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
6287 [ -z "`lctl get_param -n mdc.*.connect_flags | grep lru_resize`" ] && \
6288 skip "no lru resize on server" && return 0
6290 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
6292 log "create $NR files at $DIR/$tdir"
6293 createmany -o $DIR/$tdir/f $NR ||
6294 error "failed to create $NR files in $DIR/$tdir"
6296 cancel_lru_locks mdc
6297 ls -l $DIR/$tdir > /dev/null
6301 for VALUE in `lctl get_param ldlm.namespaces.*mdc-*.lru_size`; do
6302 local PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
6303 LRU_SIZE=$(lctl get_param -n $PARAM)
6304 if [ $LRU_SIZE -gt $(default_lru_size) ]; then
6305 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
6307 log "NS=$(basename $NSDIR)"
6312 if [ -z "$NSDIR" -o $LRU_SIZE -lt $(default_lru_size) ]; then
6313 skip "Not enough cached locks created!"
6320 # We know that lru resize allows one client to hold $LIMIT locks
6321 # for 10h. After that locks begin to be killed by client.
6323 local LIMIT=`lctl get_param -n $NSDIR.pool.limit`
6326 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
6327 # killing locks. Some time was spent for creating locks. This means
6328 # that up to the moment of sleep finish we must have killed some of
6329 # them (10-100 locks). This depends on how fast ther were created.
6330 # Many of them were touched in almost the same moment and thus will
6331 # be killed in groups.
6332 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
6334 # Use $LRU_SIZE_B here to take into account real number of locks
6335 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
6336 local LRU_SIZE_B=$LRU_SIZE
6338 local OLD_LVF=`lctl get_param -n $NSDIR.pool.lock_volume_factor`
6339 log "OLD_LVF=$OLD_LVF"
6340 lctl set_param -n $NSDIR.pool.lock_volume_factor $LVF
6342 # Let's make sure that we really have some margin. Client checks
6343 # cached locks every 10 sec.
6345 log "Sleep ${SLEEP} sec"
6347 while ((SEC<$SLEEP)); do
6351 LRU_SIZE=`lctl get_param -n $NSDIR/lru_size`
6355 lctl set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
6356 local LRU_SIZE_A=`lctl get_param -n $NSDIR/lru_size`
6358 [ $LRU_SIZE_B -gt $LRU_SIZE_A ] || {
6359 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
6360 unlinkmany $DIR/$tdir/f $NR
6364 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
6365 log "unlink $NR files at $DIR/$tdir"
6366 unlinkmany $DIR/$tdir/f $NR
6368 run_test 124a "lru resize ======================================="
6370 get_max_pool_limit()
6372 local limit=`lctl get_param -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit`
6375 if test $l -gt $max; then
6383 [ -z "`lctl get_param -n mdc.*.connect_flags | grep lru_resize`" ] && \
6384 skip "no lru resize on server" && return 0
6386 LIMIT=`get_max_pool_limit`
6388 NR=$(($(default_lru_size)*20))
6389 if [ $NR -gt $LIMIT ]; then
6390 log "Limit lock number by $LIMIT locks"
6393 lru_resize_disable mdc
6394 mkdir -p $DIR/$tdir/disable_lru_resize ||
6395 error "failed to create $DIR/$tdir/disable_lru_resize"
6397 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
6398 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
6399 cancel_lru_locks mdc
6402 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
6405 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
6408 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
6412 nolruresize_delta=$((etime-stime))
6413 log "ls -la time: $nolruresize_delta seconds"
6414 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
6415 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
6417 lru_resize_enable mdc
6418 mkdir -p $DIR/$tdir/enable_lru_resize ||
6419 error "failed to create $DIR/$tdir/enable_lru_resize"
6421 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
6422 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
6423 cancel_lru_locks mdc
6426 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
6429 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
6432 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
6436 lruresize_delta=$((etime-stime))
6437 log "ls -la time: $lruresize_delta seconds"
6438 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
6440 if [ $lruresize_delta -gt $nolruresize_delta ]; then
6441 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
6442 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
6443 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
6445 log "lru resize performs the same with no lru resize"
6447 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
6449 run_test 124b "lru resize (performance test) ======================="
6451 test_125() { # 13358
6452 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
6453 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
6454 mkdir -p $DIR/d125 || error "mkdir failed"
6455 $SETSTRIPE $DIR/d125 -s 65536 -c -1 || error "setstripe failed"
6456 setfacl -R -m u:bin:rwx $DIR/d125 || error "setfacl $DIR/d125 failed"
6457 ls -ld $DIR/d125 || error "cannot access $DIR/d125"
6459 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
6461 test_126() { # bug 12829/13455
6462 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
6463 [ "$UID" != 0 ] && skip_env "skipping $TESTNAME (must run as root)" && return
6464 $GSS && skip "must run as gss disabled" && return
6466 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
6467 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
6469 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
6471 run_test 126 "check that the fsgid provided by the client is taken into account"
6473 test_127a() { # bug 15521
6474 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
6475 $LCTL set_param osc.*.stats=0
6476 FSIZE=$((2048 * 1024))
6477 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
6478 cancel_lru_locks osc
6479 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
6481 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
6482 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
6483 echo "got $COUNT $NAME"
6484 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
6485 eval $NAME=$COUNT || error "Wrong proc format"
6488 read_bytes|write_bytes)
6489 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
6490 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
6491 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
6492 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
6493 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
6494 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
6495 error "sumsquare is too small: $SUMSQ"
6496 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
6497 error "sumsquare is too big: $SUMSQ"
6501 done < $DIR/${tfile}.tmp
6503 #check that we actually got some stats
6504 [ "$read_bytes" ] || error "Missing read_bytes stats"
6505 [ "$write_bytes" ] || error "Missing write_bytes stats"
6506 [ "$read_bytes" != 0 ] || error "no read done"
6507 [ "$write_bytes" != 0 ] || error "no write done"
6509 run_test 127a "verify the client stats are sane"
6511 test_127b() { # bug LU-333
6512 $LCTL set_param llite.*.stats=0
6513 FSIZE=65536 # sized fixed to match PAGE_SIZE for most clients
6514 # perform 2 reads and writes so MAX is different from SUM.
6515 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
6516 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
6517 cancel_lru_locks osc
6518 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
6519 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
6521 $LCTL get_param llite.*.stats | grep samples > $TMP/${tfile}.tmp
6522 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
6523 echo "got $COUNT $NAME"
6524 eval $NAME=$COUNT || error "Wrong proc format"
6528 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
6529 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
6530 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
6531 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
6534 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
6535 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
6536 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
6537 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
6541 done < $TMP/${tfile}.tmp
6543 #check that we actually got some stats
6544 [ "$read_bytes" ] || error "Missing read_bytes stats"
6545 [ "$write_bytes" ] || error "Missing write_bytes stats"
6546 [ "$read_bytes" != 0 ] || error "no read done"
6547 [ "$write_bytes" != 0 ] || error "no write done"
6549 run_test 127b "verify the llite client stats are sane"
6551 test_128() { # bug 15212
6553 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
6558 result=$(grep error $TMP/$tfile.log)
6560 [ -z "$result" ] || error "consecutive find's under interactive lfs failed"
6562 run_test 128 "interactive lfs for 2 consecutive find's"
6569 local LDPROC=/proc/fs/ldiskfs
6571 for facet in $(get_facets MDS); do
6572 canondev=$(ldiskfs_canon *.$(convert_facet2label $facet).mntdev $facet)
6573 do_facet $facet "test -e $LDPROC/$canondev/max_dir_size" || LDPROC=/sys/fs/ldiskfs
6574 do_facet $facet "echo $1 >$LDPROC/$canondev/max_dir_size"
6578 [ "$FSTYPE" != "ldiskfs" ] && skip "not needed for FSTYPE=$FSTYPE" && return 0
6579 remote_mds_nodsh && skip "remote MDS with nodsh" && return
6590 while [ ! $I -gt $((MAX * MDSCOUNT)) ]; do
6591 multiop $DIR/$tdir/$J Oc
6593 if [ $rc -eq $EFBIG ]; then
6595 echo "return code $rc received as expected"
6597 elif [ $rc -ne 0 ]; then
6599 error_exit "return code $rc received instead of expected $EFBIG"
6602 I=$(stat -c%s "$DIR/$tdir")
6606 error "exceeded dir size limit $MAX x $MDSCOUNT $((MAX * MDSCOUNT)) : $I bytes"
6608 run_test 129 "test directory size limit ========================"
6617 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
6618 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
6620 trap cleanup_130 EXIT RETURN
6622 local fm_file=$DIR/$tfile
6623 lfs setstripe -s 65536 -c 1 $fm_file || error "setstripe failed on $fm_file"
6624 dd if=/dev/zero of=$fm_file bs=65536 count=1 || error "dd failed for $fm_file"
6626 filefrag -ves $fm_file || error "filefrag $fm_file failed"
6627 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
6629 lun=`$GETSTRIPE $fm_file | grep -A 10 obdidx | awk '{print $1}' | grep -v "obdidx"`
6631 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
6634 for line in $filefrag_op
6636 frag_lun=`echo $line | cut -d: -f5`
6637 ext_len=`echo $line | cut -d: -f4`
6638 if (( $frag_lun != $lun )); then
6640 error "FIEMAP on 1-stripe file($fm_file) failed"
6643 (( tot_len += ext_len ))
6646 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
6648 error "FIEMAP on 1-stripe file($fm_file) failed;"
6654 echo "FIEMAP on single striped file succeeded"
6656 run_test 130a "FIEMAP (1-stripe file)"
6659 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping FIEMAP on 2-stripe file test" && return
6661 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
6662 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
6664 trap cleanup_130 EXIT RETURN
6666 local fm_file=$DIR/$tfile
6667 lfs setstripe -s 65536 -c 2 $fm_file || error "setstripe failed on $fm_file"
6668 dd if=/dev/zero of=$fm_file bs=1M count=2 || error "dd failed on $fm_file"
6670 filefrag -ves $fm_file || error "filefrag $fm_file failed"
6671 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
6673 last_lun=`echo $filefrag_op | cut -d: -f5`
6678 for line in $filefrag_op
6680 frag_lun=`echo $line | cut -d: -f5`
6681 ext_len=`echo $line | cut -d: -f4`
6682 if (( $frag_lun != $last_lun )); then
6683 if (( tot_len != 1024 )); then
6685 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 256"
6692 (( tot_len += ext_len ))
6695 if (( num_luns != 2 || tot_len != 1024 )); then
6697 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
6703 echo "FIEMAP on 2-stripe file succeeded"
6705 run_test 130b "FIEMAP (2-stripe file)"
6708 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping FIEMAP on 2-stripe file with hole test" && return
6710 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
6711 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
6713 trap cleanup_130 EXIT RETURN
6715 local fm_file=$DIR/$tfile
6716 lfs setstripe -s 65536 -c 2 $fm_file || error "setstripe failed on $fm_file"
6717 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 || error "dd failed on $fm_file"
6719 filefrag -ves $fm_file || error "filefrag $fm_file failed"
6720 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
6722 last_lun=`echo $filefrag_op | cut -d: -f5`
6727 for line in $filefrag_op
6729 frag_lun=`echo $line | cut -d: -f5`
6730 ext_len=`echo $line | cut -d: -f4`
6731 if (( $frag_lun != $last_lun )); then
6732 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
6733 if (( logical != 512 )); then
6735 error "FIEMAP on $fm_file failed; returned logical start for lun $logical instead of 512"
6738 if (( tot_len != 512 )); then
6740 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
6747 (( tot_len += ext_len ))
6750 if (( num_luns != 2 || tot_len != 512 )); then
6752 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
6758 echo "FIEMAP on 2-stripe file with hole succeeded"
6760 run_test 130c "FIEMAP (2-stripe file with hole)"
6763 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping FIEMAP on N-stripe file test" && return
6765 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
6766 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
6768 trap cleanup_130 EXIT RETURN
6770 local fm_file=$DIR/$tfile
6771 lfs setstripe -s 65536 -c $OSTCOUNT $fm_file || error "setstripe failed on $fm_file"
6772 dd if=/dev/zero of=$fm_file bs=1M count=$OSTCOUNT || error "dd failed on $fm_file"
6774 filefrag -ves $fm_file || error "filefrag $fm_file failed"
6775 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
6777 last_lun=`echo $filefrag_op | cut -d: -f5`
6782 for line in $filefrag_op
6784 frag_lun=`echo $line | cut -d: -f5`
6785 ext_len=`echo $line | cut -d: -f4`
6786 if (( $frag_lun != $last_lun )); then
6787 if (( tot_len != 1024 )); then
6789 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
6796 (( tot_len += ext_len ))
6799 if (( num_luns != OSTCOUNT || tot_len != 1024 )); then
6801 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
6807 echo "FIEMAP on N-stripe file succeeded"
6809 run_test 130d "FIEMAP (N-stripe file)"
6812 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping continuation FIEMAP test" && return
6814 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
6815 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
6817 trap cleanup_130 EXIT RETURN
6819 local fm_file=$DIR/$tfile
6820 lfs setstripe -s 131072 -c 2 $fm_file || error "setstripe failed on $fm_file"
6822 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
6823 for ((i = 0; i < $NUM_BLKS; i++))
6825 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
6828 filefrag -ves $fm_file || error "filefrag $fm_file failed"
6829 filefrag_op=`filefrag -ve $fm_file | grep -A 12000 "ext:" | grep -v "ext:" | grep -v "found"`
6831 last_lun=`echo $filefrag_op | cut -d: -f5`
6836 for line in $filefrag_op
6838 frag_lun=`echo $line | cut -d: -f5`
6839 ext_len=`echo $line | cut -d: -f4`
6840 if (( $frag_lun != $last_lun )); then
6841 if (( tot_len != $EXPECTED_LEN )); then
6843 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of $EXPECTED_LEN"
6850 (( tot_len += ext_len ))
6853 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
6855 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
6861 echo "FIEMAP with continuation calls succeeded"
6863 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
6865 # Test for writev/readv
6867 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 || \
6868 error "writev test failed"
6869 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 || \
6870 error "readv failed"
6873 run_test 131a "test iov's crossing stripe boundary for writev/readv"
6876 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 || \
6877 error "append writev test failed"
6878 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 || \
6879 error "append writev test failed"
6882 run_test 131b "test append writev"
6885 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
6888 run_test 131c "test read/write on file w/o objects"
6891 rwv -f $DIR/$tfile -w -n 1 1572864
6892 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
6893 if [ "$NOB" != 1572864 ]; then
6894 error "Short read filed: read $NOB bytes instead of 1572864"
6898 run_test 131d "test short read"
6901 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
6902 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
6903 error "read hitting hole failed"
6906 run_test 131e "test read hitting hole"
6911 for node in $(osts_nodes); do
6912 gl=$(do_node $node "$LCTL get_param -n ost.OSS.ost.stats" | awk '/'$token'/ {print $2}' | head -n 1)
6913 [ x$gl = x"" ] && gl=0
6914 gl_sum=$((gl_sum + gl))
6924 if [ x$som = x"enabled" ]; then
6925 [ $((gl2 - gl1)) -gt 0 ] && error "no glimpse RPC is expected"
6926 MOUNTOPT=`echo $MOUNTOPT | sed 's/som_preview//g'`
6927 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=disabled"
6929 [ $((gl2 - gl1)) -gt 0 ] || error "some glimpse RPC is expected"
6930 MOUNTOPT="$MOUNTOPT,som_preview"
6931 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=enabled"
6934 # do remount to make new mount-conf parameters actual
6941 test_132() { #1028, SOM
6942 local num=$(get_mds_dir $DIR)
6943 local mymds=mds${num}
6944 local MOUNTOPT_SAVE=$MOUNTOPT
6946 dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
6947 cancel_lru_locks osc
6949 som1=$(do_facet $mymds "$LCTL get_param mdt.*.som" | awk -F= ' {print $2}' | head -n 1)
6951 gl1=$(get_ost_param "ldlm_glimpse_enqueue")
6952 stat $DIR/$tfile >/dev/null
6953 gl2=$(get_ost_param "ldlm_glimpse_enqueue")
6954 echo "====> SOM is "$som1", "$((gl2 - gl1))" glimpse RPC occured"
6956 som_mode_switch $som1 $gl1 $gl2
6958 dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
6959 cancel_lru_locks osc
6961 som2=$(do_facet $mymds "$LCTL get_param mdt.*.som" | awk -F= ' {print $2}' | head -n 1)
6962 if [ $som1 == $som2 ]; then
6963 error "som is still "$som2
6964 if [ x$som2 = x"enabled" ]; then
6971 gl1=$(get_ost_param "ldlm_glimpse_enqueue")
6972 stat $DIR/$tfile >/dev/null
6973 gl2=$(get_ost_param "ldlm_glimpse_enqueue")
6974 echo "====> SOM is "$som2", "$((gl2 - gl1))" glimpse RPC occured"
6975 som_mode_switch $som2 $gl1 $gl2
6976 MOUNTOPT=$MOUNTOPT_SAVE
6978 run_test 132 "som avoids glimpse rpc"
6984 $SINGLEMDS) res=`do_facet $SINGLEMDS $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$2"`
6986 ost) res=`do_facet ost $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$2"`
6988 *) error "Wrong argument $1" ;;
6991 count=`echo $res | awk '{print $2}'`
6992 [ -z "$res" ] && error "The counter for $2 on $1 was not incremented"
6993 # if the argument $3 is zero, it means any stat increment is ok.
6994 if [ $3 -gt 0 ] ; then
6995 [ $count -ne $3 ] && error "The $2 counter on $1 is wrong - expected $3"
7000 local testdir=$DIR/${tdir}/stats_testdir
7001 mkdir -p $DIR/${tdir}
7004 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
7005 do_facet ost $LCTL set_param obdfilter.*.stats=clear
7007 # verify mdt stats first.
7008 mkdir ${testdir} || error "mkdir failed"
7009 check_stats $SINGLEMDS "mkdir" 1
7010 touch ${testdir}/${tfile} || "touch failed"
7011 check_stats $SINGLEMDS "open" 1
7012 check_stats $SINGLEMDS "close" 1
7013 mknod ${testdir}/${tfile}-pipe p || "mknod failed"
7014 check_stats $SINGLEMDS "mknod" 1
7015 rm -f ${testdir}/${tfile}-pipe || "pipe remove failed"
7016 check_stats $SINGLEMDS "unlink" 1
7017 rm -f ${testdir}/${tfile} || error "file remove failed"
7018 check_stats $SINGLEMDS "unlink" 2
7020 # remove working dir and check mdt stats again.
7021 rmdir ${testdir} || error "rmdir failed"
7022 check_stats $SINGLEMDS "rmdir" 1
7026 run_test 133a "Verifying MDT stats ========================================"
7029 local testdir=$DIR/${tdir}/stats_testdir
7030 mkdir -p ${testdir} || error "mkdir failed"
7031 touch ${testdir}/${tfile} || "touch failed"
7032 cancel_lru_locks mdc
7035 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
7036 do_facet ost $LCTL set_param obdfilter.*.stats=clear
7038 # extra mdt stats verification.
7039 chmod 444 ${testdir}/${tfile} || error "chmod failed"
7040 check_stats $SINGLEMDS "setattr" 1
7041 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
7042 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
7043 check_stats $SINGLEMDS "getattr" 1
7044 $LFS df || error "lfs failed"
7045 check_stats $SINGLEMDS "statfs" 1
7049 run_test 133b "Verifying extra MDT stats =================================="
7052 local testdir=$DIR/${tdir}/stats_testdir
7053 mkdir -p ${testdir} || error "mkdir failed"
7055 # verify obdfilter stats.
7056 $LFS setstripe -c 1 -o 0 ${testdir}/${tfile}
7058 cancel_lru_locks osc
7061 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
7062 do_facet ost $LCTL set_param obdfilter.*.stats=clear
7064 dd if=/dev/zero of=${testdir}/${tfile} conv=notrunc bs=1024k count=1 || error "dd failed"
7066 cancel_lru_locks osc
7067 check_stats ost "write" 1
7069 dd if=${testdir}/${tfile} of=/dev/null bs=1k count=1 || error "dd failed"
7070 check_stats ost "read" 1
7072 > ${testdir}/${tfile} || error "truncate failed"
7073 check_stats ost "punch" 1
7075 rm -f ${testdir}/${tfile} || error "file remove failed"
7076 check_stats ost "destroy" 1
7080 run_test 133c "Verifying OST stats ========================================"
7082 test_140() { #bug-17379
7083 mkdir -p $DIR/$tdir || error "Creating dir $DIR/$tdir"
7084 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
7085 cp /usr/bin/stat . || error "Copying stat to $DIR/$tdir"
7087 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
7089 while i=`expr $i + 1`; do
7090 mkdir -p $i || error "Creating dir $i"
7091 cd $i || error "Changing to $i"
7092 ln -s ../stat stat || error "Creating stat symlink"
7093 # Read the symlink until ELOOP present,
7094 # not LBUGing the system is considered success,
7095 # we didn't overrun the stack.
7096 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
7098 if [ $ret -eq 40 ]; then
7101 error "Open stat symlink"
7107 echo "The symlink depth = $i"
7108 [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 ] || error "Invalid symlink depth"
7110 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
7113 local TF="$TMP/$tfile"
7115 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
7117 cancel_lru_locks osc
7118 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
7119 remount_client $MOUNT
7121 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
7124 $TRUNCATE $DIR/$tfile 6000
7125 cancel_lru_locks osc
7126 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
7129 echo "12345" >>$DIR/$tfile
7130 cancel_lru_locks osc
7131 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
7134 echo "12345" >>$DIR/$tfile
7135 cancel_lru_locks osc
7136 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
7141 run_test 150 "truncate/append tests"
7143 function roc_hit() {
7144 local list=$(comma_list $(osts_nodes))
7146 ACCNUM=$(do_nodes $list $LCTL get_param -n obdfilter.*.stats | \
7147 awk '/'cache_hit'/ {sum+=$2} END {print sum}')
7151 function set_cache() {
7154 if [ "$2" == "off" ]; then
7157 local list=$(comma_list $(osts_nodes))
7158 do_nodes $list lctl set_param obdfilter.*.${1}_cache_enable $on
7160 cancel_lru_locks osc
7164 remote_ost_nodsh && skip "remote OST with nodsh" && return
7167 local list=$(comma_list $(osts_nodes))
7169 # check whether obdfilter is cache capable at all
7170 if ! do_nodes $list $LCTL get_param -n obdfilter.*.read_cache_enable > /dev/null; then
7171 echo "not cache-capable obdfilter"
7175 # check cache is enabled on all obdfilters
7176 if do_nodes $list $LCTL get_param -n obdfilter.*.read_cache_enable | grep 0 >&/dev/null; then
7177 echo "oss cache is disabled"
7181 do_nodes $list $LCTL set_param -n obdfilter.*.writethrough_cache_enable 1
7183 # pages should be in the case right after write
7184 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES || error "dd failed"
7185 local BEFORE=`roc_hit`
7186 cancel_lru_locks osc
7187 cat $DIR/$tfile >/dev/null
7188 local AFTER=`roc_hit`
7189 if ! let "AFTER - BEFORE == CPAGES"; then
7190 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
7193 # the following read invalidates the cache
7194 cancel_lru_locks osc
7195 do_nodes $list $LCTL set_param -n obdfilter.*.read_cache_enable 0
7196 cat $DIR/$tfile >/dev/null
7198 # now data shouldn't be found in the cache
7200 cancel_lru_locks osc
7201 cat $DIR/$tfile >/dev/null
7203 if let "AFTER - BEFORE != 0"; then
7204 error "IN CACHE: before: $BEFORE, after: $AFTER"
7207 do_nodes $list $LCTL set_param -n obdfilter.*.read_cache_enable 1
7210 run_test 151 "test cache on oss and controls ==============================="
7213 local TF="$TMP/$tfile"
7215 # simulate ENOMEM during write
7216 #define OBD_FAIL_OST_NOMEM 0x226
7217 lctl set_param fail_loc=0x80000226
7218 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
7220 sync || error "sync failed"
7221 lctl set_param fail_loc=0
7223 # discard client's cache
7224 cancel_lru_locks osc
7226 # simulate ENOMEM during read
7227 lctl set_param fail_loc=0x80000226
7228 cmp $TF $DIR/$tfile || error "cmp failed"
7229 lctl set_param fail_loc=0
7233 run_test 152 "test read/write with enomem ============================"
7236 multiop $DIR/$tfile Ow4096Ycu || error "multiop failed"
7238 run_test 153 "test if fdatasync does not crash ======================="
7241 cp /etc/hosts $DIR/$tfile
7243 fid=$($LFS path2fid $DIR/$tfile)
7245 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
7247 echo "open fid $fid"
7248 diff /etc/hosts $DIR/.lustre/fid/$fid || error "open by fid failed: did not find expected data in file."
7250 echo "Opening a file by FID succeeded"
7252 run_test 154 "Opening a file by FID"
7254 test_155_small_load() {
7255 local temp=$TMP/$tfile
7256 local file=$DIR/$tfile
7258 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
7259 error "dd of=$temp bs=6096 count=1 failed"
7261 cancel_lru_locks osc
7262 cmp $temp $file || error "$temp $file differ"
7264 $TRUNCATE $temp 6000
7265 $TRUNCATE $file 6000
7266 cmp $temp $file || error "$temp $file differ (truncate1)"
7268 echo "12345" >>$temp
7269 echo "12345" >>$file
7270 cmp $temp $file || error "$temp $file differ (append1)"
7272 echo "12345" >>$temp
7273 echo "12345" >>$file
7274 cmp $temp $file || error "$temp $file differ (append2)"
7280 test_155_big_load() {
7281 local temp=$TMP/$tfile
7282 local file=$DIR/$tfile
7285 local cache_size=$(do_facet ost$((MAXI+1)) \
7286 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
7287 local large_file_size=$((cache_size * 2))
7289 echo "OSS cache size: $cache_size KB"
7290 echo "Large file size: $large_file_size KB"
7292 [ $MAXV -le $large_file_size ] && \
7293 skip_env "max available OST size needs > $large_file_size KB" && \
7296 $SETSTRIPE $file -c 1 -i $MAXI || error "$SETSTRIPE $file failed"
7298 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k || \
7299 error "dd of=$temp bs=$large_file_size count=1k failed"
7302 cancel_lru_locks osc
7303 cmp $temp $file || error "$temp $file differ"
7311 set_cache writethrough on
7314 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
7318 set_cache writethrough off
7321 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
7325 set_cache writethrough on
7328 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
7332 set_cache writethrough off
7335 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
7339 set_cache writethrough on
7342 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
7346 set_cache writethrough off
7349 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
7353 set_cache writethrough on
7356 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
7360 set_cache writethrough off
7363 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
7369 local file="$DIR/$tfile"
7371 log "Turn on read and write cache"
7373 set_cache writethrough on
7375 log "Write data and read it back."
7376 log "Read should be satisfied from the cache."
7377 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
7379 cancel_lru_locks osc
7380 cat $file >/dev/null
7382 if ! let "AFTER - BEFORE == CPAGES"; then
7383 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
7385 log "cache hits:: before: $BEFORE, after: $AFTER"
7388 log "Read again; it should be satisfied from the cache."
7390 cancel_lru_locks osc
7391 cat $file >/dev/null
7393 if ! let "AFTER - BEFORE == CPAGES"; then
7394 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
7396 log "cache hits:: before: $BEFORE, after: $AFTER"
7400 log "Turn off the read cache and turn on the write cache"
7402 set_cache writethrough on
7404 log "Read again; it should be satisfied from the cache."
7406 cancel_lru_locks osc
7407 cat $file >/dev/null
7409 if ! let "AFTER - BEFORE == CPAGES"; then
7410 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
7412 log "cache hits:: before: $BEFORE, after: $AFTER"
7415 log "Read again; it should not be satisfied from the cache."
7417 cancel_lru_locks osc
7418 cat $file >/dev/null
7420 if ! let "AFTER - BEFORE == 0"; then
7421 error "IN CACHE: before: $BEFORE, after: $AFTER"
7423 log "cache hits:: before: $BEFORE, after: $AFTER"
7426 log "Write data and read it back."
7427 log "Read should be satisfied from the cache."
7428 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
7430 cancel_lru_locks osc
7431 cat $file >/dev/null
7433 if ! let "AFTER - BEFORE == CPAGES"; then
7434 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
7436 log "cache hits:: before: $BEFORE, after: $AFTER"
7439 log "Read again; it should not be satisfied from the cache."
7441 cancel_lru_locks osc
7442 cat $file >/dev/null
7444 if ! let "AFTER - BEFORE == 0"; then
7445 error "IN CACHE: before: $BEFORE, after: $AFTER"
7447 log "cache hits:: before: $BEFORE, after: $AFTER"
7451 log "Turn off read and write cache"
7453 set_cache writethrough off
7455 log "Write data and read it back"
7456 log "It should not be satisfied from the cache."
7458 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
7459 cancel_lru_locks osc
7461 cat $file >/dev/null
7463 if ! let "AFTER - BEFORE == 0"; then
7464 error_ignore 20762 "IN CACHE: before: $BEFORE, after: $AFTER"
7466 log "cache hits:: before: $BEFORE, after: $AFTER"
7470 log "Turn on the read cache and turn off the write cache"
7472 set_cache writethrough off
7474 log "Write data and read it back"
7475 log "It should not be satisfied from the cache."
7477 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
7479 cancel_lru_locks osc
7480 cat $file >/dev/null
7482 if ! let "AFTER - BEFORE == 0"; then
7483 error_ignore 20762 "IN CACHE: before: $BEFORE, after: $AFTER"
7485 log "cache hits:: before: $BEFORE, after: $AFTER"
7488 log "Read again; it should be satisfied from the cache."
7490 cancel_lru_locks osc
7491 cat $file >/dev/null
7493 if ! let "AFTER - BEFORE == CPAGES"; then
7494 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
7496 log "cache hits:: before: $BEFORE, after: $AFTER"
7501 run_test 156 "Verification of tunables ============================"
7505 if [ $MDSCOUNT -gt 1 ]; then
7506 error_ignore 17935 $*
7512 USER=$(do_facet $SINGLEMDS lctl --device $MDT0 changelog_register -n)
7513 echo "Registered as changelog user $USER"
7514 do_facet $SINGLEMDS lctl get_param -n mdd.$MDT0.changelog_users | \
7515 grep -q $USER || error "User $USER not found in changelog_users"
7518 mkdir -p $DIR/$tdir/pics/2008/zachy
7519 touch $DIR/$tdir/pics/2008/zachy/timestamp
7520 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
7521 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
7522 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
7523 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
7524 rm $DIR/$tdir/pics/desktop.jpg
7526 $LFS changelog $MDT0 | tail -5
7528 echo "verifying changelog mask"
7529 do_facet $SINGLEMDS lctl set_param mdd.$MDT0.changelog_mask="-mkdir"
7530 mkdir -p $DIR/$tdir/pics/2009/sofia
7531 do_facet $SINGLEMDS lctl set_param mdd.$MDT0.changelog_mask="+mkdir"
7532 mkdir $DIR/$tdir/pics/2009/zachary
7533 DIRS=$($LFS changelog $MDT0 | tail -5 | grep -c MKDIR)
7534 [ $DIRS -eq 1 ] || err17935 "changelog mask count $DIRS != 1"
7537 echo "verifying target fid"
7538 fidc=$($LFS changelog $MDT0 | grep timestamp | grep "CREAT" | \
7539 tail -1 | awk '{print $6}')
7540 fidf=$($LFS path2fid $DIR/$tdir/pics/zach/timestamp)
7541 [ "$fidc" == "t=$fidf" ] || \
7542 err17935 "fid in changelog $fidc != file fid $fidf"
7543 echo "verifying parent fid"
7544 fidc=$($LFS changelog $MDT0 | grep timestamp | grep "CREAT" | \
7545 tail -1 | awk '{print $7}')
7546 fidf=$($LFS path2fid $DIR/$tdir/pics/zach)
7547 [ "$fidc" == "p=$fidf" ] || \
7548 err17935 "pfid in changelog $fidc != dir fid $fidf"
7550 USER_REC1=$(do_facet $SINGLEMDS lctl get_param -n \
7551 mdd.$MDT0.changelog_users | grep $USER | awk '{print $2}')
7552 $LFS changelog_clear $MDT0 $USER $(($USER_REC1 + 5))
7553 USER_REC2=$(do_facet $SINGLEMDS lctl get_param -n \
7554 mdd.$MDT0.changelog_users | grep $USER | awk '{print $2}')
7555 echo "verifying user clear: $(( $USER_REC1 + 5 )) == $USER_REC2"
7556 [ $USER_REC2 == $(($USER_REC1 + 5)) ] || \
7557 err17935 "user index should be $(($USER_REC1 + 5)); is $USER_REC2"
7559 MIN_REC=$(do_facet $SINGLEMDS lctl get_param mdd.$MDT0.changelog_users | \
7560 awk 'min == "" || $2 < min {min = $2}; END {print min}')
7561 FIRST_REC=$($LFS changelog $MDT0 | head -1 | awk '{print $1}')
7562 echo "verifying min purge: $(( $MIN_REC + 1 )) == $FIRST_REC"
7563 [ $FIRST_REC == $(($MIN_REC + 1)) ] || \
7564 err17935 "first index should be $(($MIN_REC + 1)); is $FIRST_REC"
7566 echo "verifying user deregister"
7567 do_facet $SINGLEMDS lctl --device $MDT0 changelog_deregister $USER
7568 do_facet $SINGLEMDS lctl get_param -n mdd.$MDT0.changelog_users | \
7569 grep -q $USER && error "User $USER still found in changelog_users"
7571 USERS=$(( $(do_facet $SINGLEMDS lctl get_param -n \
7572 mdd.$MDT0.changelog_users | wc -l) - 2 ))
7573 if [ $USERS -eq 0 ]; then
7574 LAST_REC1=$(do_facet $SINGLEMDS lctl get_param -n \
7575 mdd.$MDT0.changelog_users | head -1 | awk '{print $3}')
7576 touch $DIR/$tdir/chloe
7577 LAST_REC2=$(do_facet $SINGLEMDS lctl get_param -n \
7578 mdd.$MDT0.changelog_users | head -1 | awk '{print $3}')
7579 echo "verify changelogs are off if we were the only user: $LAST_REC1 == $LAST_REC2"
7580 [ $LAST_REC1 == $LAST_REC2 ] || error "changelogs not off"
7582 echo "$USERS other changelog users; can't verify off"
7585 run_test 160 "changelog sanity"
7589 cp /etc/hosts $DIR/$tdir/$tfile
7590 mkdir $DIR/$tdir/foo1
7591 mkdir $DIR/$tdir/foo2
7592 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
7593 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
7594 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
7595 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
7596 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[')
7597 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
7598 $LFS fid2path $DIR $FID
7599 err17935 "bad link ea"
7602 rm $DIR/$tdir/foo2/zachary
7604 rm $DIR/$tdir/foo2/thor
7606 rm $DIR/$tdir/$tfile
7608 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
7609 if [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ]
7611 $LFS fid2path $DIR $FID
7612 err17935 "bad link rename"
7614 rm $DIR/$tdir/foo2/maggie
7617 local longname=filename_avg_len_is_thirty_two_
7618 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 || \
7619 error "failed to hardlink many files"
7620 links=$($LFS fid2path $DIR $FID | wc -l)
7621 echo -n "${links}/1000 links in link EA"
7622 [ ${links} -gt 60 ] || err17935 "expected at least 60 links in link EA"
7623 unlinkmany $DIR/$tdir/foo2/$longname 1000 || \
7624 error "failed to unlink many hardlinks"
7626 run_test 161 "link ea sanity"
7633 local path=$(${LFS} fid2path $*)
7636 if [ $RC -ne 0 ]; then
7637 err17935 "path looked up of $expected failed. Error $RC"
7639 elif [ "${path}" != "${expected}" ]; then
7640 err17935 "path looked up \"${path}\" instead of \"${expected}\""
7643 echo "fid $fid resolves to path $path (expected $expected)"
7647 # Make changes to filesystem
7648 mkdir -p $DIR/$tdir/d2
7649 touch $DIR/$tdir/d2/$tfile
7650 touch $DIR/$tdir/d2/x1
7651 touch $DIR/$tdir/d2/x2
7652 mkdir -p $DIR/$tdir/d2/a/b/c
7653 mkdir -p $DIR/$tdir/d2/p/q/r
7655 FID=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
7656 check_path "$tdir/d2/$tfile" $FSNAME $FID --link 0
7659 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
7660 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
7661 check_path "$tdir/d2/p/q/r/slink" $FSNAME $FID --link 0
7663 # softlink to wrong file
7664 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
7665 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
7666 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME $FID --link 0
7669 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
7670 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
7671 FID=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
7672 # fid2path dir/fsname should both work
7673 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 1
7674 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR $FID --link 0
7676 # hardlink count: check that there are 2 links
7677 # Doesnt work with CMD yet: 17935
7678 ${LFS} fid2path $DIR $FID | wc -l | grep -q 2 || \
7679 err17935 "expected 2 links"
7681 # hardlink indexing: remove the first link
7682 rm $DIR/$tdir/d2/p/q/r/hlink
7683 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 0
7687 run_test 162 "path lookup sanity"
7690 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7691 copytool --test $FSNAME || { skip "copytool not runnable: $?" && return; }
7694 local uuid=$($LCTL get_param -n mdc.${FSNAME}-MDT0000-mdc-*.uuid)
7695 # this proc file is temporary and linux-only
7696 do_facet $SINGLEMDS lctl set_param mdt.${FSNAME}-MDT0000.mdccomm=$uuid ||\
7697 error "kernel->userspace send failed"
7700 run_test 163 "kernel <-> userspace comms"
7703 # do directio so as not to populate the page cache
7704 log "creating a 10 Mb file"
7705 multiop $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
7706 log "starting reads"
7707 dd if=$DIR/$tfile of=/dev/null bs=4096 &
7708 log "truncating the file"
7709 multiop $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
7711 kill %+ || true # reads might have finished
7712 echo "wait until dd is finished"
7714 log "removing the temporary file"
7715 rm -rf $DIR/$tfile || error "tmp file removal failed"
7717 run_test 169 "parallel read and truncate should not deadlock"
7720 $LCTL clear # bug 18514
7721 $LCTL debug_daemon start $TMP/${tfile}_log_good
7723 $LCTL debug_daemon stop
7724 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
7725 error "sed failed to read log_good"
7727 $LCTL debug_daemon start $TMP/${tfile}_log_good
7729 $LCTL debug_daemon stop
7731 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
7732 error "lctl df log_bad failed"
7734 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
7735 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
7737 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
7738 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
7740 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
7741 error "bad_line good_line1 good_line2 are empty"
7743 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
7744 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
7745 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
7747 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
7748 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
7749 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
7751 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
7752 error "bad_line_new good_line_new are empty"
7754 local expected_good=$((good_line1 + good_line2*2))
7756 rm -f $TMP/${tfile}*
7757 # LU-231, short malformed line may not be counted into bad lines
7758 if [ $bad_line -ne $bad_line_new ] &&
7759 [ $bad_line -ne $((bad_line_new - 1)) ]; then
7760 error "expected $bad_line bad lines, but got $bad_line_new"
7764 if [ $expected_good -ne $good_line_new ]; then
7765 error "expected $expected_good good lines, but got $good_line_new"
7770 run_test 170 "test lctl df to handle corrupted log ====================="
7772 test_171() { # bug20592
7773 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
7774 $LCTL set_param fail_loc=0x50e
7775 $LCTL set_param fail_val=3000
7776 multiop_bg_pause $DIR/$tfile O_s || true
7778 kill -USR1 $MULTIPID
7782 if dmesg | grep "recursive fault"; then
7783 error "caught a recursive fault"
7785 $LCTL set_param fail_loc=0
7788 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
7790 # it would be good to share it with obdfilter-survey/libecho code
7791 setup_obdecho_osc () {
7794 local obdfilter_name=$2
7795 echo "Creating new osc for $obdfilter_name on $ost_nid"
7796 # make sure we can find loopback nid
7797 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
7799 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
7800 ${obdfilter_name}_osc_UUID || rc=2; }
7801 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
7802 ${obdfilter_name}_UUID $ost_nid || rc=3; }
7806 cleanup_obdecho_osc () {
7807 local obdfilter_name=$1
7808 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
7809 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
7813 obdecho_create_test() {
7818 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
7819 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
7821 if [ $rc -eq 0 ]; then
7822 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
7823 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
7825 echo "New object id is $id"
7826 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec test_brw 10 w v 64 $id" ||
7828 [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec " \
7829 "cleanup" || rc=5; }
7830 [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec " \
7832 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
7840 if ! module_loaded obdecho; then
7841 load_module obdecho/obdecho
7845 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
7846 local host=$(lctl get_param -n osc.$osc.import |
7847 awk '/current_connection:/ {print $2}' )
7848 local target=$(lctl get_param -n osc.$osc.import |
7849 awk '/target:/ {print $2}' )
7850 target=${target%_UUID}
7852 [[ -n $target ]] && { setup_obdecho_osc $host $target || rc=1; } || rc=1
7853 [ $rc -eq 0 ] && { obdecho_create_test ${target}_osc client || rc=2; }
7854 [[ -n $target ]] && cleanup_obdecho_osc $target
7855 [ $rmmod_local -eq 1 ] && rmmod obdecho
7858 run_test 180a "test obdecho on osc"
7862 local rmmod_remote=0
7864 do_facet ost "lsmod | grep -q obdecho || " \
7865 "{ insmod ${LUSTRE}/obdecho/obdecho.ko || " \
7866 "modprobe obdecho; }" && rmmod_remote=1
7867 target=$(do_facet ost $LCTL dl | awk '/obdfilter/ {print $4;exit}')
7868 [[ -n $target ]] && { obdecho_create_test $target ost || rc=1; }
7869 [ $rmmod_remote -eq 1 ] && do_facet ost "rmmod obdecho"
7872 run_test 180b "test obdecho directly on obdfilter"
7874 test_181() { # bug 22177
7875 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
7876 # create enough files to index the directory
7877 createmany -o $DIR/$tdir/foobar 4000
7878 # print attributes for debug purpose
7881 multiop_bg_pause $DIR/$tdir D_Sc || return 1
7883 # remove the files & current working dir
7884 unlinkmany $DIR/$tdir/foobar 4000
7886 kill -USR1 $MULTIPID
7888 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
7891 run_test 181 "Test open-unlinked dir ========================"
7897 TGTPOOL_MAX=$(($TGT_COUNT - 1))
7899 TGTPOOL_LIST=`seq $TGTPOOL_FIRST $TGTPOOL_STEP $TGTPOOL_MAX`
7900 POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
7901 POOL_DIR_NAME=dir_tst
7902 POOL_DIR=$POOL_ROOT/$POOL_DIR_NAME
7903 POOL_FILE=$POOL_ROOT/file_tst
7905 check_file_in_pool()
7908 res=$($GETSTRIPE $file | grep 0x | cut -f2)
7911 found=$(echo :$TGTPOOL_LIST: | tr " " ":" | grep :$i:)
7912 if [[ "$found" == "" ]]
7914 echo "pool list: $TGTPOOL_LIST"
7915 echo "striping: $res"
7916 error "$file not allocated in $POOL"
7923 trap "cleanup_pools $FSNAME" EXIT
7926 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
7927 create_pool $FSNAME.$POOL || return $?
7928 [ $($LFS pool_list $FSNAME | grep -c $POOL) -eq 1 ] ||
7929 error "$POOL not in lfs pool_list"
7931 run_test 200a "Create new pool =========================================="
7934 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
7935 TGT=$(for i in $TGTPOOL_LIST; do printf "$FSNAME-OST%04x_UUID " $i; done)
7936 do_facet mgs $LCTL pool_add $FSNAME.$POOL \
7937 $FSNAME-OST[$TGTPOOL_FIRST-$TGTPOOL_MAX/$TGTPOOL_STEP]
7938 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL | sort -u | tr '\n' ' ' " "$TGT" ||
7939 error "Add to pool failed"
7940 local lfscount=$($LFS pool_list $FSNAME.$POOL | grep -c "\-OST")
7941 local addcount=$((($TGTPOOL_MAX - $TGTPOOL_FIRST) / $TGTPOOL_STEP + 1))
7942 [ $lfscount -eq $addcount ] ||
7943 error "lfs pool_list bad ost count $lfscount != $addcount"
7945 run_test 200b "Add targets to a pool ===================================="
7948 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
7950 $SETSTRIPE -c 2 -p $POOL $POOL_DIR
7951 [ $? = 0 ] || error "Cannot set pool $POOL to $POOL_DIR"
7952 # b-19919 test relative path works well
7953 mkdir -p $POOL_DIR/$POOL_DIR_NAME
7955 $SETSTRIPE -c 2 -p $POOL $POOL_DIR_NAME
7956 [ $? = 0 ] || error "Cannot set pool $POOL to $POOL_DIR/$POOL_DIR_NAME"
7957 $SETSTRIPE -c 2 -p $POOL ./$POOL_DIR_NAME
7958 [ $? = 0 ] || error "Cannot set pool $POOL to $POOL_DIR/./$POOL_DIR_NAME"
7959 $SETSTRIPE -c 2 -p $POOL ../$POOL_DIR_NAME
7960 [ $? = 0 ] || error "Cannot set pool $POOL to $POOL_DIR/../$POOL_DIR_NAME"
7961 $SETSTRIPE -c 2 -p $POOL ../$POOL_DIR_NAME/$POOL_DIR_NAME
7962 [ $? = 0 ] || error "Cannot set pool $POOL to $POOL_DIR/../$POOL_DIR_NAME/$POOL_DIR_NAME"
7963 rm -rf $POOL_DIR_NAME; cd -
7965 run_test 200c "Set pool on a directory ================================="
7968 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
7969 res=$($GETSTRIPE --pool $POOL_DIR)
7970 [ $res = $POOL ] || error "Pool on $POOL_DIR is $res, not $POOL"
7972 run_test 200d "Check pool on a directory ==============================="
7975 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
7977 for i in $(seq -w 1 $(($TGT_COUNT * 3)))
7979 file=$POOL_DIR/file-$i
7981 check_file_in_pool $file
7984 failed=$(($failed + 1))
7987 [ "$failed" = 0 ] || error "$failed files not allocated in $POOL"
7989 run_test 200e "Check files allocation from directory pool =============="
7992 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
7995 for i in $(seq -w 1 $(($TGT_COUNT * 3)))
7997 file=$POOL_FILE/spoo-$i
7998 $SETSTRIPE -p $POOL $file
7999 check_file_in_pool $file
8002 failed=$(($failed + 1))
8005 [ "$failed" = 0 ] || error "$failed files not allocated in $POOL"
8007 run_test 200f "Create files in a pool ==================================="
8010 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
8011 TGT=$($LCTL get_param -n lov.$FSNAME-clilov-*.pools.$POOL | tr '\n' ' ')
8012 res=$($LFS df --pool $FSNAME.$POOL | awk '{print $1}' | grep "$FSNAME-OST" | tr '\n' ' ')
8013 [ "$res" = "$TGT" ] || error "Pools OSTs '$TGT' is not '$res' that lfs df reports"
8015 run_test 200g "lfs df a pool ============================================"
8017 test_200h() { # b=24039
8018 mkdir -p $POOL_DIR || error "unable to create $POOL_DIR"
8020 local file="/..$POOL_DIR/$tfile-1"
8021 $SETSTRIPE -p $POOL $file || error "unable to create $file"
8024 $SETSTRIPE -p $POOL $tfile-2 || \
8025 error "unable to create $tfile-2 in $POOL_DIR"
8027 run_test 200h "Create files in a pool with relative pathname ============"
8030 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
8031 TGT=$($LCTL get_param -n lov.$FSNAME-*.pools.$POOL | head -1)
8032 do_facet mgs $LCTL pool_remove $FSNAME.$POOL $TGT
8033 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL | grep $TGT" "" ||
8034 error "$TGT not removed from $FSNAME.$POOL"
8036 run_test 201a "Remove a target from a pool ============================="
8039 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
8040 for TGT in $($LCTL get_param -n lov.$FSNAME-*.pools.$POOL | sort -u)
8042 do_facet mgs $LCTL pool_remove $FSNAME.$POOL $TGT
8044 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL" "" ||
8045 error "Pool $FSNAME.$POOL cannot be drained"
8046 # striping on an empty/nonexistant pool should fall back to "pool of everything"
8047 touch ${POOL_DIR}/$tfile || error "failed to use fallback striping for empty pool"
8048 # setstripe on an empty pool should fail
8049 $SETSTRIPE -p $POOL ${POOL_FILE}/$tfile 2>/dev/null && \
8050 error "expected failure when creating file with empty pool"
8053 run_test 201b "Remove all targets from a pool =========================="
8056 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
8057 do_facet mgs $LCTL pool_destroy $FSNAME.$POOL
8060 # striping on an empty/nonexistant pool should fall back to "pool of everything"
8061 touch ${POOL_DIR}/$tfile || error "failed to use fallback striping for missing pool"
8062 # setstripe on an empty pool should fail
8063 $SETSTRIPE -p $POOL ${POOL_FILE}/$tfile 2>/dev/null && \
8064 error "expected failure when creating file with missing pool"
8066 # get param should return err once pool is gone
8067 if wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null ||
8068 echo foo" "foo"; then
8069 remove_pool_from_list $FSNAME.$POOL
8072 error "Pool $FSNAME.$POOL is not destroyed"
8074 run_test 201c "Remove a pool ============================================"
8076 cleanup_pools $FSNAME
8078 # usage: default_attr <count | size | offset>
8080 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
8083 # usage: trim <string>
8084 # Trims leading and trailing whitespace from the parameter string
8089 # usage: check_default_stripe_attr <count | size | offset>
8090 check_default_stripe_attr() {
8091 # $GETSTRIPE returns trailing whitespace which needs to be trimmed off
8092 ACTUAL=$(trim $($GETSTRIPE --$1 $DIR/$tdir))
8093 if [ $1 = "count" -o $1 = "size" ]; then
8094 EXPECTED=`default_attr $1`;
8096 # the 'stripeoffset' parameter prints as an unsigned int, so
8097 # until this is fixed we hard-code -1 here
8100 [ "x$ACTUAL" != "x$EXPECTED" ] &&
8101 error "$DIR/$tdir has stripe $1 '$ACTUAL', not '$EXPECTED'"
8104 # usage: check_raw_stripe_attr <count | size | offset>
8105 check_raw_stripe_attr() {
8106 # $GETSTRIPE returns trailing whitespace which needs to be trimmed off
8107 ACTUAL=$(trim $($GETSTRIPE --raw --$1 $DIR/$tdir))
8108 if [ $1 = "count" -o $1 = "size" ]; then
8113 [ "x$ACTUAL" != "x$EXPECTED" ] &&
8114 error "$DIR/$tdir has raw stripe $1 '$ACTUAL', not '$EXPECTED'"
8120 $SETSTRIPE --count 0 --size 0 --offset -1 $DIR/$tdir
8122 check_default_stripe_attr count
8123 check_default_stripe_attr size
8124 check_default_stripe_attr offset
8128 run_test 204a "Print default stripe attributes ================="
8132 $SETSTRIPE --count 1 $DIR/$tdir
8134 check_default_stripe_attr size
8135 check_default_stripe_attr offset
8139 run_test 204b "Print default stripe size and offset ==========="
8143 $SETSTRIPE --size 65536 $DIR/$tdir
8145 check_default_stripe_attr count
8146 check_default_stripe_attr offset
8150 run_test 204c "Print default stripe count and offset ==========="
8154 $SETSTRIPE --offset 0 $DIR/$tdir
8156 check_default_stripe_attr count
8157 check_default_stripe_attr size
8161 run_test 204d "Print default stripe count and size ============="
8165 $SETSTRIPE -d $DIR/$tdir
8167 check_raw_stripe_attr count
8168 check_raw_stripe_attr size
8169 check_raw_stripe_attr offset
8173 run_test 204e "Print raw stripe attributes ================="
8177 $SETSTRIPE --count 1 $DIR/$tdir
8179 check_raw_stripe_attr size
8180 check_raw_stripe_attr offset
8184 run_test 204f "Print raw stripe size and offset ==========="
8188 $SETSTRIPE --size 65536 $DIR/$tdir
8190 check_raw_stripe_attr count
8191 check_raw_stripe_attr offset
8195 run_test 204g "Print raw stripe count and offset ==========="
8199 $SETSTRIPE --offset 0 $DIR/$tdir
8201 check_raw_stripe_attr count
8202 check_raw_stripe_attr size
8206 run_test 204h "Print raw stripe count and size ============="
8210 size=$((size % 8192 + 1))
8211 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
8212 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
8213 rm -f $DIR/f212 $DIR/f212.xyz
8215 run_test 212 "Sendfile test ============================================"
8218 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
8219 cancel_lru_locks osc
8220 lctl set_param fail_loc=0x8000040f
8221 # generate a read lock
8222 cat $DIR/$tfile > /dev/null
8223 # write to the file, it will try to cancel the above read lock.
8224 cat /etc/hosts >> $DIR/$tfile
8226 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
8228 test_214() { # for bug 20133
8229 mkdir -p $DIR/d214p/d214c
8230 for (( i=0; i < 340; i++ )) ; do
8231 touch $DIR/d214p/d214c/a$i
8234 ls -l $DIR/d214p || error "ls -l $DIR/d214p failed"
8235 mv $DIR/d214p/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
8236 ls $DIR/d214c || error "ls $DIR/d214c failed"
8237 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
8239 run_test 214 "hash-indexed directory test - bug 20133"
8241 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
8242 create_lnet_proc_files() {
8243 cat /proc/sys/lnet/$1 >$TMP/lnet_$1.out || error "cannot read /proc/sys/lnet/$1"
8244 sysctl lnet.$1 >$TMP/lnet_$1.sys_tmp || error "cannot read lnet.$1"
8246 sed "s/^lnet.$1\ =\ //g" "$TMP/lnet_$1.sys_tmp" >$TMP/lnet_$1.sys
8247 rm -f "$TMP/lnet_$1.sys_tmp"
8250 # counterpart of create_lnet_proc_files
8251 remove_lnet_proc_files() {
8252 rm -f $TMP/lnet_$1.out $TMP/lnet_$1.sys
8255 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
8256 # 3rd arg as regexp for body
8257 check_lnet_proc_stats() {
8258 local l=$(cat "$TMP/lnet_$1" |wc -l)
8259 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
8261 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
8264 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
8265 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
8266 # optional and can be regexp for 2nd line (lnet.routes case)
8267 check_lnet_proc_entry() {
8268 local blp=2 # blp stands for 'position of 1st line of body'
8269 [ "$5" = "" ] || blp=3 # lnet.routes case
8271 local l=$(cat "$TMP/lnet_$1" |wc -l)
8272 # subtracting one from $blp because the body can be empty
8273 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
8275 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
8276 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
8278 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
8279 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
8281 # bail out if any unexpected line happened
8282 sed -n "$blp~1 p" "$TMP/lnet_$1" |grep -Ev "$3"
8283 [ "$?" != 0 ] || error "$2 misformatted"
8286 test_215() { # for bugs 18102, 21079, 21517
8287 local N='(0|[1-9][0-9]*)' # non-negative numeric
8288 local P='[1-9][0-9]*' # positive numeric
8289 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
8290 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
8291 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
8292 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
8294 local L1 # regexp for 1st line
8295 local L2 # regexp for 2nd line (optional)
8296 local BR # regexp for the rest (body)
8298 # /proc/sys/lnet/stats should look as 11 space-separated non-negative numerics
8299 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
8300 create_lnet_proc_files "stats"
8301 check_lnet_proc_stats "stats.out" "/proc/sys/lnet/stats" "$BR"
8302 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
8303 remove_lnet_proc_files "stats"
8305 # /proc/sys/lnet/routes should look like this:
8306 # Routing disabled/enabled
8307 # net hops state router
8308 # where net is a string like tcp0, hops >= 0, state is up/down,
8309 # router is a string like 192.168.1.1@tcp2
8310 L1="^Routing (disabled|enabled)$"
8311 L2="^net +hops +state +router$"
8312 BR="^$NET +$N +(up|down) +$NID$"
8313 create_lnet_proc_files "routes"
8314 check_lnet_proc_entry "routes.out" "/proc/sys/lnet/routes" "$BR" "$L1" "$L2"
8315 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
8316 remove_lnet_proc_files "routes"
8318 # /proc/sys/lnet/routers should look like this:
8319 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
8320 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
8321 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
8322 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
8323 L1="^ref +rtr_ref +alive_cnt +state +last_ping +ping_sent +deadline +down_ni +router$"
8324 BR="^$P +$P +$N +(up|down) +$N +(0|1) +$I +$I +$NID$"
8325 create_lnet_proc_files "routers"
8326 check_lnet_proc_entry "routers.out" "/proc/sys/lnet/routers" "$BR" "$L1"
8327 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
8328 remove_lnet_proc_files "routers"
8330 # /proc/sys/lnet/peers should look like this:
8331 # nid refs state last max rtr min tx min queue
8332 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
8333 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
8334 # numeric (0 or >0 or <0), queue >= 0.
8335 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
8336 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
8337 create_lnet_proc_files "peers"
8338 check_lnet_proc_entry "peers.out" "/proc/sys/lnet/peers" "$BR" "$L1"
8339 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
8340 remove_lnet_proc_files "peers"
8342 # /proc/sys/lnet/buffers should look like this:
8343 # pages count credits min
8344 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
8345 L1="^pages +count +credits +min$"
8346 BR="^ +$N +$N +$I +$I$"
8347 create_lnet_proc_files "buffers"
8348 check_lnet_proc_entry "buffers.out" "/proc/sys/lnet/buffers" "$BR" "$L1"
8349 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
8350 remove_lnet_proc_files "buffers"
8352 # /proc/sys/lnet/nis should look like this:
8353 # nid status alive refs peer rtr max tx min
8354 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
8355 # alive is numeric (0 or >0 or <0), refs > 0, peer >= 0,
8356 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
8357 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
8358 BR="^$NID +(up|down) +$I +$P +$N +$N +$N +$I +$I$"
8359 create_lnet_proc_files "nis"
8360 check_lnet_proc_entry "nis.out" "/proc/sys/lnet/nis" "$BR" "$L1"
8361 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
8362 remove_lnet_proc_files "nis"
8364 # can we successfully write to /proc/sys/lnet/stats?
8365 echo "0" >/proc/sys/lnet/stats || error "cannot write to /proc/sys/lnet/stats"
8366 sysctl -w lnet.stats=0 || error "cannot write to lnet.stats"
8368 run_test 215 "/proc/sys/lnet exists and has proper content - bugs 18102, 21079, 21517"
8370 test_216() { # bug 20317
8372 local p="$TMP/sanityN-$TESTNAME.parameters"
8373 save_lustre_params $HOSTNAME "osc.*.contention_seconds" > $p
8374 for node in $(osts_nodes); do
8375 save_lustre_params $node "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
8376 save_lustre_params $node "ldlm.namespaces.filter-*.contended_locks" >> $p
8377 save_lustre_params $node "ldlm.namespaces.filter-*.contention_seconds" >> $p
8381 # agressive lockless i/o settings
8382 for node in $(osts_nodes); do
8383 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'
8385 lctl set_param -n osc.*.contention_seconds 60
8387 $DIRECTIO write $DIR/$tfile 0 10 4096
8388 $CHECKSTAT -s 40960 $DIR/$tfile
8390 # disable lockless i/o
8391 for node in $(osts_nodes); do
8392 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'
8394 lctl set_param -n osc.*.contention_seconds 0
8397 dd if=/dev/zero of=$DIR/$tfile count=0
8398 $CHECKSTAT -s 0 $DIR/$tfile
8400 restore_lustre_params <$p
8404 run_test 216 "check lockless direct write works and updates file size and kms correctly"
8406 test_217() { # bug 22430
8408 for node in $(nodes_list); do
8409 if [[ $node = *-* ]] ; then
8410 echo "lctl ping $node@$NETTYPE"
8411 lctl ping $node@$NETTYPE
8413 echo "skipping $node (no hiphen detected)"
8417 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
8420 # do directio so as not to populate the page cache
8421 log "creating a 10 Mb file"
8422 multiop $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
8423 log "starting reads"
8424 dd if=$DIR/$tfile of=/dev/null bs=4096 &
8425 log "truncating the file"
8426 multiop $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
8428 kill %+ || true # reads might have finished
8429 echo "wait until dd is finished"
8431 log "removing the temporary file"
8432 rm -rf $DIR/$tfile || error "tmp file removal failed"
8434 run_test 218 "parallel read and truncate should not deadlock ======================="
8437 # write one partial page
8438 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
8439 # set no grant so vvp_io_commit_write will do sync write
8440 $LCTL set_param fail_loc=0x411
8441 # write a full page at the end of file
8442 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
8444 $LCTL set_param fail_loc=0
8445 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
8446 $LCTL set_param fail_loc=0x411
8447 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
8449 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
8451 test_220() { #LU-325
8452 remote_ost_nodsh && skip "remote OST with nodsh" && return
8456 local OST=$(lfs osts | grep ${OSTIDX}": " | \
8457 awk '{print $2}' | sed -e 's/_UUID$//')
8460 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
8461 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
8462 osc.$mdtosc_proc1.prealloc_last_id)
8463 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
8464 osc.$mdtosc_proc1.prealloc_next_id)
8468 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
8469 #define OBD_FAIL_OST_ENOINO 0x229
8470 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
8471 do_facet mgs $LCTL pool_new $FSNAME.$TESTNAME || return 1
8472 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
8474 $SETSTRIPE $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
8476 MDSOBJS=$((last_id - next_id))
8477 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
8479 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
8480 echo "OST still has $count kbytes free"
8482 echo "create $MDSOBJS files @next_id..."
8483 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
8485 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
8486 osc.$mdtosc_proc1.prealloc_last_id)
8487 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
8488 osc.$mdtosc_proc1.prealloc_next_id)
8490 echo "after creation, last_id=$last_id2, next_id=$next_id2"
8495 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
8496 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
8498 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST || return 4
8499 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME || return 5
8500 echo "unlink $MDSOBJS files @$next_id..."
8501 unlinkmany $DIR/$tdir/f $MDSOBJS || return 6
8503 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
8506 cp `which date` $MOUNT
8508 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
8509 $LCTL set_param fail_loc=0x80001401
8511 $MOUNT/date > /dev/null
8514 run_test 221 "make sure fault and truncate race to not cause OOM"
8517 # tests that do cleanup/setup should be run at the end
8522 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
8523 $LCTL set_param fail_loc=0x903
8524 # cancel_lru_locks mgc - does not work due to lctl set_param syntax
8525 for ls in /proc/fs/lustre/ldlm/namespaces/MGC*/lru_size; do
8528 FAIL_ON_ERROR=true cleanup
8529 FAIL_ON_ERROR=true setup
8531 run_test 900 "umount should not race with any mgc requeue thread"
8533 complete $(basename $0) $SECONDS
8534 check_and_cleanup_lustre
8535 if [ "$I_MOUNTED" != "yes" ]; then
8536 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true