3 # Run select tests by setting ONLY, or as arguments to the script.
4 # Skip specific tests by setting EXCEPT.
6 # e.g. ONLY="22 23" or ONLY="`seq 32 39`" or EXCEPT="31"
10 # bug number for skipped test: 13297 2108 9789 3637 9789 3561 12622 5188
11 ALWAYS_EXCEPT=" 27u 42a 42b 42c 42d 45 51d 68b $SANITY_EXCEPT"
12 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
14 # with LOD/OSP landing
15 # bug number for skipped tests: LU2036
16 ALWAYS_EXCEPT=" 76 $ALWAYS_EXCEPT"
19 # Tests that fail on uml
20 CPU=`awk '/model/ {print $4}' /proc/cpuinfo`
21 # buffer i/o errs sock spc runas
22 [ "$CPU" = "UML" ] && EXCEPT="$EXCEPT 27m 27n 27o 27p 27q 27r 31d 54a 64b 99a 99b 99c 99d 99e 99f 101a"
24 SRCDIR=$(cd $(dirname $0); echo $PWD)
25 export PATH=$PATH:/sbin
29 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
30 CREATETEST=${CREATETEST:-createtest}
32 LFIND=${LFIND:-"$LFS find"}
33 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
35 MCREATE=${MCREATE:-mcreate}
36 OPENFILE=${OPENFILE:-openfile}
37 OPENUNLINK=${OPENUNLINK:-openunlink}
38 export MULTIOP=${MULTIOP:-multiop}
39 READS=${READS:-"reads"}
40 MUNLINK=${MUNLINK:-munlink}
41 SOCKETSERVER=${SOCKETSERVER:-socketserver}
42 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
43 MEMHOG=${MEMHOG:-memhog}
44 DIRECTIO=${DIRECTIO:-directio}
45 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
46 UMOUNT=${UMOUNT:-"umount -d"}
48 CHECK_GRANT=${CHECK_GRANT:-"yes"}
49 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
51 export NAME=${NAME:-local}
58 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
59 . $LUSTRE/tests/test-framework.sh
61 . ${CONFIG:=$LUSTRE/tests/cfg/${NAME}.sh}
64 [ "$SLOW" = "no" ] && EXCEPT_SLOW="24o 24v 27m 36f 36g 36h 51b 60c 63 64b 68 71 73 77f 78 101a 103 115 120g 124b"
70 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
71 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
80 check_kernel_version() {
82 GOT_VER=$(lctl get_param -n version | awk '/kernel:/ {print $2}')
84 patchless|patchless_client) return 0;;
85 *) [ $GOT_VER -ge $WANT_VER ] && return 0 ;;
87 log "test needs at least kernel version $WANT_VER, running $GOT_VER"
91 if [ "$ONLY" == "cleanup" ]; then
96 check_and_setup_lustre
101 MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid | \
102 awk '{gsub(/_UUID/,""); print $1}' | head -1)
103 LOVNAME=$($LCTL get_param -n llite.*.lov.common_name | tail -n 1)
104 OSTCOUNT=$($LCTL get_param -n lov.$LOVNAME.numobd)
105 STRIPECOUNT=$($LCTL get_param -n lov.$LOVNAME.stripecount)
106 STRIPESIZE=$($LCTL get_param -n lov.$LOVNAME.stripesize)
107 ORIGFREE=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
108 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
110 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
111 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
112 rm -rf $DIR/[Rdfs][0-9]*
114 # $RUNAS_ID may get set incorrectly somewhere else
115 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
117 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
121 if [ "${ONLY}" = "MOUNT" ] ; then
122 echo "Lustre is up, please go on"
126 echo "preparing for tests involving mounts"
127 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
129 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
130 echo # add a newline after mke2fs.
134 OLDDEBUG="`lctl get_param -n debug 2> /dev/null`"
135 lctl set_param debug=-1 2> /dev/null || true
138 $CHECKSTAT -t file $DIR/$tfile || error
140 $CHECKSTAT -a $DIR/$tfile || error
142 run_test 0 "touch .../$tfile ; rm .../$tfile ====================="
145 chmod 0755 $DIR || error
146 $CHECKSTAT -p 0755 $DIR || error
148 run_test 0b "chmod 0755 $DIR ============================="
151 $LCTL get_param mdc.*.import | grep "state: FULL" || error "import not FULL"
152 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" || error "bad target"
154 run_test 0c "check import proc ============================="
159 mkdir $DIR/d1/d2 && error "we expect EEXIST, but not returned"
160 $CHECKSTAT -t dir $DIR/d1/d2 || error
162 run_test 1a "mkdir .../d1; mkdir .../d1/d2 ====================="
167 $CHECKSTAT -a $DIR/d1 || error
169 run_test 1b "rmdir .../d1/d2; rmdir .../d1 ====================="
174 $CHECKSTAT -t file $DIR/d2/f || error
176 run_test 2a "mkdir .../d2; touch .../d2/f ======================"
180 $CHECKSTAT -a $DIR/d2 || error
182 run_test 2b "rm -r .../d2; checkstat .../d2/f ======================"
186 $CHECKSTAT -t dir $DIR/d3 || error
188 run_test 3a "mkdir .../d3 ======================================"
191 if [ ! -d $DIR/d3 ]; then
195 $CHECKSTAT -t file $DIR/d3/f || error
197 run_test 3b "touch .../d3/f ===================================="
201 $CHECKSTAT -a $DIR/d3 || error
203 run_test 3c "rm -r .../d3 ======================================"
207 $CHECKSTAT -t dir $DIR/d4 || error
209 run_test 4a "mkdir .../d4 ======================================"
212 if [ ! -d $DIR/d4 ]; then
216 $CHECKSTAT -t dir $DIR/d4/d2 || error
218 run_test 4b "mkdir .../d4/d2 ==================================="
223 chmod 0707 $DIR/d5/d2
224 $CHECKSTAT -t dir -p 0707 $DIR/d5/d2 || error
226 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2 ============"
230 chmod 0666 $DIR/f6a || error
231 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/f6a || error
233 run_test 6a "touch .../f6a; chmod .../f6a ======================"
236 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
237 if [ ! -f $DIR/f6a ]; then
241 $RUNAS chmod 0444 $DIR/f6a && error
242 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/f6a || error
244 run_test 6b "$RUNAS chmod .../f6a (should return error) =="
247 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
249 chown $RUNAS_ID $DIR/f6c || error
250 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/f6c || error
252 run_test 6c "touch .../f6c; chown .../f6c ======================"
255 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
256 if [ ! -f $DIR/f6c ]; then
258 chown $RUNAS_ID $DIR/f6c
260 $RUNAS chown $UID $DIR/f6c && error
261 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/f6c || error
263 run_test 6d "$RUNAS chown .../f6c (should return error) =="
266 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
268 chgrp $RUNAS_ID $DIR/f6e || error
269 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/f6e || error
271 run_test 6e "touch .../f6e; chgrp .../f6e ======================"
274 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
275 if [ ! -f $DIR/f6e ]; then
277 chgrp $RUNAS_ID $DIR/f6e
279 $RUNAS chgrp $UID $DIR/f6e && error
280 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/f6e || error
282 run_test 6f "$RUNAS chgrp .../f6e (should return error) =="
285 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
286 mkdir $DIR/d6g || error
287 chmod 777 $DIR/d6g || error
288 $RUNAS mkdir $DIR/d6g/d || error
289 chmod g+s $DIR/d6g/d || error
290 mkdir $DIR/d6g/d/subdir
291 $CHECKSTAT -g \#$RUNAS_GID $DIR/d6g/d/subdir || error
293 run_test 6g "Is new dir in sgid dir inheriting group?"
295 test_6h() { # bug 7331
296 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
297 touch $DIR/f6h || error "touch failed"
298 chown $RUNAS_ID:$RUNAS_GID $DIR/f6h || error "initial chown failed"
299 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/f6h && error "chown worked"
300 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/f6h || error
302 run_test 6h "$RUNAS chown RUNAS_ID.0 .../f6h (should return error)"
308 $CHECKSTAT -t file -p 0666 $DIR/d7/f || error
310 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
313 if [ ! -d $DIR/d7 ]; then
317 echo -n foo > $DIR/d7/f2
318 [ "`cat $DIR/d7/f2`" = "foo" ] || error
319 $CHECKSTAT -t file -s 3 $DIR/d7/f2 || error
321 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
327 $CHECKSTAT -t file -p 0666 $DIR/d8/f || error
329 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
335 $CHECKSTAT -t dir $DIR/d9/d2/d3 || error
337 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
343 $CHECKSTAT -t file $DIR/d10/d2/f || error
345 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
350 chmod 0666 $DIR/d11/d2
351 chmod 0705 $DIR/d11/d2
352 $CHECKSTAT -t dir -p 0705 $DIR/d11/d2 || error
354 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
359 chmod 0666 $DIR/d12/f
360 chmod 0654 $DIR/d12/f
361 $CHECKSTAT -t file -p 0654 $DIR/d12/f || error
363 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
367 dd if=/dev/zero of=$DIR/d13/f count=10
369 $CHECKSTAT -t file -s 0 $DIR/d13/f || error
371 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
377 $CHECKSTAT -a $DIR/d14/f || error
379 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
384 mv $DIR/d15/f $DIR/d15/f2
385 $CHECKSTAT -t file $DIR/d15/f2 || error
387 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
393 $CHECKSTAT -a $DIR/d16/f || error
395 run_test 16 "touch .../d16/f; rm -rf .../d16/f ================="
400 ln -s $DIR/d17/f $DIR/d17/l-exist
402 $CHECKSTAT -l $DIR/d17/f $DIR/d17/l-exist || error
403 $CHECKSTAT -f -t f $DIR/d17/l-exist || error
404 rm -f $DIR/d17/l-exist
405 $CHECKSTAT -a $DIR/d17/l-exist || error
407 run_test 17a "symlinks: create, remove (real) =================="
411 ln -s no-such-file $DIR/d17/l-dangle
413 $CHECKSTAT -l no-such-file $DIR/d17/l-dangle || error
414 $CHECKSTAT -fa $DIR/d17/l-dangle || error
415 rm -f $DIR/d17/l-dangle
416 $CHECKSTAT -a $DIR/d17/l-dangle || error
418 run_test 17b "symlinks: create, remove (dangling) =============="
420 test_17c() { # bug 3440 - don't save failed open RPC for replay
422 ln -s foo $DIR/d17/f17c
423 cat $DIR/d17/f17c && error "opened non-existent symlink" || true
425 run_test 17c "symlinks: open dangling (should return error) ===="
429 ln -s foo $DIR/d17/f17d
430 touch $DIR/d17/f17d || error "creating to new symlink"
432 run_test 17d "symlinks: create dangling ========================"
436 local foo=$DIR/$tdir/$tfile
437 ln -s $foo $foo || error "create symlink failed"
438 ls -l $foo || error "ls -l failed"
439 ls $foo && error "ls not failed" || true
441 run_test 17e "symlinks: create recursive symlink (should return error) ===="
445 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/d17f/111
446 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/d17f/222
447 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/d17f/333
448 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/d17f/444
449 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/d17f/555
450 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
453 run_test 17f "symlinks: long and very long symlink name ========================"
457 LONGSYMLINK="$(dd if=/dev/zero bs=4095 count=1 | tr '\0' 'x')"
458 ln -s $LONGSYMLINK $DIR/$tdir/$tfile
461 run_test 17g "symlinks: really long symlink name ==============================="
463 test_17h() { #bug 17378
464 remote_mds_nodsh && skip "remote MDS with nodsh" && return
466 $SETSTRIPE -c -1 $DIR/$tdir
467 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
468 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000141
469 touch $DIR/$tdir/$tfile || true
471 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
473 test_17i() { #bug 20018
474 remote_mds_nodsh && skip "remote MDS with nodsh" && return
476 local foo=$DIR/$tdir/$tfile
477 ln -s $foo $foo || error "create symlink failed"
478 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
479 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000143
480 ls -l $foo && error "error not detected"
483 run_test 17i "don't panic on short symlink"
485 test_17k() { #bug 22301
486 rsync --help | grep -q xattr ||
487 skip_env "$(rsync --version| head -1) does not support xattrs"
488 mkdir -p $DIR/{$tdir,$tdir.new}
489 touch $DIR/$tdir/$tfile
490 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
491 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
492 error "rsync failed with xattrs enabled"
494 run_test 17k "symlinks: rsync with xattrs enabled ========================="
498 local short_sym="0123456789"
499 local WDIR=$DIR/${tdir}m
506 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
507 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
508 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
510 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
511 skip "only for ldiskfs MDT" && return 0
515 # create a long symlink file
516 for ((i = 0; i < 4; ++i)); do
517 long_sym=${long_sym}${long_sym}
520 echo "create 512 short and long symlink files under $WDIR"
521 for ((i = 0; i < 256; ++i)); do
522 ln -sf ${long_sym}"a5a5" $WDIR/long-$i
523 ln -sf ${short_sym}"a5a5" $WDIR/short-$i
531 echo "recreate the 512 symlink files with a shorter string"
532 for ((i = 0; i < 512; ++i)); do
533 # rewrite the symlink file with a shorter string
534 ln -sf ${long_sym} $WDIR/long-$i
535 ln -sf ${short_sym} $WDIR/short-$i
538 mds_index=$($LFS getstripe -M $WDIR)
539 mds_index=$((mds_index+1))
540 devname=$(mdsdevname $mds_index)
541 cmd="$E2FSCK -fnvd $devname"
543 echo "stop and checking mds${mds_index}: $cmd"
544 # e2fsck should not return error
545 stop mds${mds_index} -f
546 do_facet mds${mds_index} $cmd || rc=$?
548 start mds${mds_index} $devname $MDS_MOUNT_OPTS
549 df $MOUNT > /dev/null 2>&1
550 [ $rc -ne 0 ] && error "e2fsck should not report error upon "\
551 "short/long symlink MDT: rc=$rc"
554 run_test 17m "run e2fsck against MDT which contains short/long symlink"
560 run_test 18 "touch .../f ; ls ... =============================="
566 $CHECKSTAT -a $DIR/f19 || error
568 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
571 ls -l $DIR/f19 && error || true
573 run_test 19b "ls -l .../f19 (should return error) =============="
576 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
577 $RUNAS touch $DIR/f19 && error || true
579 run_test 19c "$RUNAS touch .../f19 (should return error) =="
582 cat $DIR/f19 && error || true
584 run_test 19d "cat .../f19 (should return error) =============="
596 $CHECKSTAT -a $DIR/f || error
598 run_test 20 "touch .../f ; ls -l ... ==========================="
602 [ -f $DIR/d21/dangle ] && rm -f $DIR/d21/dangle
603 ln -s dangle $DIR/d21/link
604 echo foo >> $DIR/d21/link
606 $CHECKSTAT -t link $DIR/d21/link || error
607 $CHECKSTAT -f -t file $DIR/d21/link || error
609 run_test 21 "write to dangling link ============================"
614 chown $RUNAS_ID:$RUNAS_GID $WDIR
615 (cd $WDIR || error "cd $WDIR failed";
616 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
618 ls -lR $WDIR/etc || error "ls -lR $WDIR/etc failed"
619 $CHECKSTAT -t dir $WDIR/etc || error "checkstat -t dir failed"
620 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $WDIR/etc || error "checkstat -u failed"
622 run_test 22 "unpack tar archive as non-root user ==============="
627 local file=$DIR/$tdir/$tfile
629 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
630 openfile -f O_CREAT:O_EXCL $file &&
631 error "$file recreate succeeded" || true
633 run_test 23a "O_CREAT|O_EXCL in subdir =========================="
635 test_23b() { # bug 18988
637 local file=$DIR/$tdir/$tfile
640 echo foo > $file || error "write filed"
641 echo bar >> $file || error "append filed"
642 $CHECKSTAT -s 8 $file || error "wrong size"
645 run_test 23b "O_APPEND check =========================="
648 echo '== rename sanity =============================================='
649 echo '-- same directory rename'
652 mv $DIR/R1/f $DIR/R1/g
653 $CHECKSTAT -t file $DIR/R1/g || error
655 run_test 24a "touch .../R1/f; rename .../R1/f .../R1/g ========="
660 mv $DIR/R2/f $DIR/R2/g
661 $CHECKSTAT -a $DIR/R2/f || error
662 $CHECKSTAT -t file $DIR/R2/g || error
664 run_test 24b "touch .../R2/{f,g}; rename .../R2/f .../R2/g ====="
669 mv $DIR/R3/f $DIR/R3/g
670 $CHECKSTAT -a $DIR/R3/f || error
671 $CHECKSTAT -t dir $DIR/R3/g || error
673 run_test 24c "mkdir .../R3/f; rename .../R3/f .../R3/g ========="
678 mrename $DIR/R4/f $DIR/R4/g
679 $CHECKSTAT -a $DIR/R4/f || error
680 $CHECKSTAT -t dir $DIR/R4/g || error
682 run_test 24d "mkdir .../R4/{f,g}; rename .../R4/f .../R4/g ====="
685 echo '-- cross directory renames --'
688 mv $DIR/R5a/f $DIR/R5b/g
689 $CHECKSTAT -a $DIR/R5a/f || error
690 $CHECKSTAT -t file $DIR/R5b/g || error
692 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
696 touch $DIR/R6a/f $DIR/R6b/g
697 mv $DIR/R6a/f $DIR/R6b/g
698 $CHECKSTAT -a $DIR/R6a/f || error
699 $CHECKSTAT -t file $DIR/R6b/g || error
701 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
706 mv $DIR/R7a/d $DIR/R7b/e
707 $CHECKSTAT -a $DIR/R7a/d || error
708 $CHECKSTAT -t dir $DIR/R7b/e || error
710 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
714 mkdir $DIR/R8a/d $DIR/R8b/e
715 mrename $DIR/R8a/d $DIR/R8b/e
716 $CHECKSTAT -a $DIR/R8a/d || error
717 $CHECKSTAT -t dir $DIR/R8b/e || error
719 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
722 echo "-- rename error cases"
726 mrename $DIR/R9/f $DIR/R9/a
727 $CHECKSTAT -t file $DIR/R9/f || error
728 $CHECKSTAT -t dir $DIR/R9/a || error
729 $CHECKSTAT -a $DIR/R9/a/f || error
731 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
735 mrename $DIR/R10/f $DIR/R10/g
736 $CHECKSTAT -t dir $DIR/R10 || error
737 $CHECKSTAT -a $DIR/R10/f || error
738 $CHECKSTAT -a $DIR/R10/g || error
740 run_test 24j "source does not exist ============================"
743 mkdir $DIR/R11a $DIR/R11a/d
745 mv $DIR/R11a/f $DIR/R11a/d
746 $CHECKSTAT -a $DIR/R11a/f || error
747 $CHECKSTAT -t file $DIR/R11a/d/f || error
749 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
751 # bug 2429 - rename foo foo foo creates invalid file
754 $MULTIOP $f OcNs || error
756 run_test 24l "Renaming a file to itself ========================"
760 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
761 # on ext3 this does not remove either the source or target files
762 # though the "expected" operation would be to remove the source
763 $CHECKSTAT -t file ${f} || error "${f} missing"
764 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
766 run_test 24m "Renaming a file to a hard link to itself ========="
770 # this stats the old file after it was renamed, so it should fail
774 $CHECKSTAT ${f}.rename
777 run_test 24n "Statting the old file after renaming (Posix rename 2)"
780 check_kernel_version 37 || return 0
782 rename_many -s random -v -n 10 $DIR/d24o
784 run_test 24o "rename of files during htree split ==============="
788 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
789 mrename $DIR/R12a $DIR/R12b
790 $CHECKSTAT -a $DIR/R12a || error
791 $CHECKSTAT -t dir $DIR/R12b || error
792 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
793 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
795 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
799 DIRINO=`ls -lid $DIR/R13a | awk '{ print $1 }'`
800 multiop_bg_pause $DIR/R13b D_c || return 1
803 mrename $DIR/R13a $DIR/R13b
804 $CHECKSTAT -a $DIR/R13a || error
805 $CHECKSTAT -t dir $DIR/R13b || error
806 DIRINO2=`ls -lid $DIR/R13b | awk '{ print $1 }'`
807 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
809 wait $MULTIPID || error "multiop close failed"
811 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
813 test_24r() { #bug 3789
814 mkdir $DIR/R14a $DIR/R14a/b
815 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
816 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
817 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
819 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
822 mkdir $DIR/R15a $DIR/R15a/b $DIR/R15a/b/c
823 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
824 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
825 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
827 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
829 mkdir $DIR/R16a $DIR/R16a/b $DIR/R16a/b/c
830 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
831 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
832 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
834 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
836 test_24u() { # bug12192
837 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error
838 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
840 run_test 24u "create stripe file"
848 local FREE_INODES=`lfs df -i|grep "filesystem summary" | awk '{print $5}'`
849 [ $FREE_INODES -lt $NRFILES ] && \
850 skip "not enough free inodes $FREE_INODES required $NRFILES" && \
854 createmany -m $DIR/d24v/$tfile $NRFILES
857 lctl set_param mdc.*.stats clear
859 ls $DIR/d24v >/dev/null || error "error in listing large dir"
862 # DIRENT_SIZE = 32 bytes for sizeof(struct lu_dirent) +
863 # 8 bytes for name(filename is mostly 5 in this test) +
864 # 8 bytes for luda_type
865 # take into account of overhead in lu_dirpage header and end mark in
866 # each page, plus one in RPC_NUM calculation.
868 RPC_SIZE=$(($(lctl get_param -n mdc.*.max_pages_per_rpc)*$(page_size)))
869 RPC_NUM=$(((NRFILES * DIRENT_SIZE + RPC_SIZE - 1) / RPC_SIZE + 1))
870 mds_readpage=`lctl get_param mdc.*.stats | \
871 awk '/^mds_readpage/ {print $2}'`
872 [ $mds_readpage -gt $RPC_NUM ] && \
873 error "large readdir doesn't take effect"
877 run_test 24v "list directory with large files (handle hash collision, bug: 17560)"
879 test_24w() { # bug21506
881 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
882 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
883 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
884 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
885 [ "$SZ1" = "$SZ2" ] || \
886 error "Error reading at the end of the file $tfile"
888 run_test 24w "Reading a file larger than 4Gb"
891 echo '== symlink sanity ============================================='
895 touch $DIR/s25/foo || error
897 run_test 25a "create file in symlinked directory ==============="
900 [ ! -d $DIR/d25 ] && test_25a
901 $CHECKSTAT -t file $DIR/s25/foo || error
903 run_test 25b "lookup file in symlinked directory ==============="
908 ln -s d26/d26-2 $DIR/s26
909 touch $DIR/s26/foo || error
911 run_test 26a "multiple component symlink ======================="
914 mkdir -p $DIR/d26b/d26-2
915 ln -s d26b/d26-2/foo $DIR/s26-2
916 touch $DIR/s26-2 || error
918 run_test 26b "multiple component symlink at end of lookup ======"
923 ln -s d26.2 $DIR/s26.2-1
924 ln -s s26.2-1 $DIR/s26.2-2
925 ln -s s26.2-2 $DIR/s26.2-3
926 chmod 0666 $DIR/s26.2-3/foo
928 run_test 26c "chain of symlinks ================================"
930 # recursive symlinks (bug 439)
932 ln -s d26-3/foo $DIR/d26-3
934 run_test 26d "create multiple component recursive symlink ======"
937 [ ! -h $DIR/d26-3 ] && test_26d
940 run_test 26e "unlink multiple component recursive symlink ======"
942 # recursive symlinks (bug 7022)
945 mkdir $DIR/$tdir/$tfile || error "mkdir $DIR/$tdir/$tfile failed"
946 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
947 mkdir -p lndir/bar1 || error "mkdir lndir/bar1 failed"
948 mkdir $tfile || error "mkdir $tfile failed"
949 cd $tfile || error "cd $tfile failed"
950 ln -s .. dotdot || error "ln dotdot failed"
951 ln -s dotdot/lndir lndir || error "ln lndir failed"
952 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
953 output=`ls $tfile/$tfile/lndir/bar1`
954 [ "$output" = bar1 ] && error "unexpected output"
955 rm -r $tfile || error "rm $tfile failed"
956 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
958 run_test 26f "rm -r of a directory which has recursive symlink ="
961 echo '== stripe sanity =============================================='
962 mkdir -p $DIR/d27 || error "mkdir failed"
964 $SETSTRIPE -c 1 $DIR/d27/f0 || error "setstripe failed"
965 $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
967 log "== test_27a: write to one stripe file ========================="
968 cp /etc/hosts $DIR/d27/f0 || error
970 run_test 27a "one stripe file =================================="
973 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
975 $SETSTRIPE -c 2 $DIR/d27/f01 || error "setstripe failed"
976 $GETSTRIPE -c $DIR/d27/f01
977 [ $($GETSTRIPE -c $DIR/d27/f01) -eq 2 ] ||
978 error "two-stripe file doesn't have two stripes"
980 run_test 27b "create two stripe file"
983 [ -f $DIR/d27/f01 ] || skip "test_27b not run" && return
985 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
987 run_test 27c "write to two stripe file"
991 $SETSTRIPE -c 0 -i -1 -S 0 $DIR/d27/fdef || error "setstripe failed"
992 $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
993 dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
995 run_test 27d "create file with default settings ================"
999 $SETSTRIPE -c 2 $DIR/d27/f12 || error "setstripe failed"
1000 $SETSTRIPE -c 2 $DIR/d27/f12 && error "setstripe succeeded twice"
1001 $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
1003 run_test 27e "setstripe existing file (should return error) ======"
1007 $SETSTRIPE -S 100 -i 0 -c 1 $DIR/d27/fbad && error "setstripe failed"
1008 dd if=/dev/zero of=$DIR/d27/f12 bs=4k count=4 || error "dd failed"
1009 $GETSTRIPE $DIR/d27/fbad || error "$GETSTRIPE failed"
1011 run_test 27f "setstripe with bad stripe size (should return error)"
1015 $MCREATE $DIR/d27/fnone || error "mcreate failed"
1016 $GETSTRIPE $DIR/d27/fnone 2>&1 | grep "no stripe info" ||
1017 error "$DIR/d27/fnone has object"
1019 run_test 27g "$GETSTRIPE with no objects"
1022 touch $DIR/d27/fsome || error "touch failed"
1023 [ $($GETSTRIPE -c $DIR/d27/fsome) -gt 0 ] || error "missing objects"
1025 run_test 27i "$GETSTRIPE with some objects"
1029 $SETSTRIPE -i $OSTCOUNT $DIR/d27/f27j && error "setstripe failed"||true
1031 run_test 27j "setstripe with bad stripe offset (should return error)"
1033 test_27k() { # bug 2844
1036 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
1037 [ ! -d $DIR/d27 ] && mkdir -p $DIR/d27
1038 $SETSTRIPE -S 67108864 $FILE || error "setstripe failed"
1039 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1040 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
1041 dd if=/dev/zero of=$FILE bs=4k count=1
1042 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1043 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
1045 run_test 27k "limit i_blksize for broken user apps ============="
1049 mcreate $DIR/f27l || error "creating file"
1050 $RUNAS $SETSTRIPE -c 1 $DIR/f27l && \
1051 error "setstripe should have failed" || true
1053 run_test 27l "check setstripe permissions (should return error)"
1056 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1057 if [ $ORIGFREE -gt $MAXFREE ]; then
1058 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1062 $SETSTRIPE -i 0 -c 1 $DIR/d27/f27m_1
1063 dd if=/dev/zero of=$DIR/d27/f27m_1 bs=1024 count=$MAXFREE &&
1064 error "dd should fill OST0"
1066 while $SETSTRIPE -i 0 -c 1 $DIR/d27/f27m_$i; do
1068 [ $i -gt 256 ] && break
1071 touch $DIR/d27/f27m_$i
1072 [ `$GETSTRIPE $DIR/d27/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] && \
1073 error "OST0 was full but new created file still use it"
1075 touch $DIR/d27/f27m_$i
1076 [ `$GETSTRIPE $DIR/d27/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] && \
1077 error "OST0 was full but new created file still use it"
1081 run_test 27m "create file while OST0 was full =================="
1084 local DELAY=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage | head -n 1 | awk '{print $1 * 2}')
1088 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1089 # if the OST isn't full anymore.
1091 local OSTIDX=${1:-""}
1093 local list=$(comma_list $(osts_nodes))
1094 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1096 do_nodes $list lctl set_param fail_loc=0
1097 sync # initiate all OST_DESTROYs from MDS to OST
1101 exhaust_precreations() {
1104 local FAILIDX=${3:-$OSTIDX}
1107 local MDSIDX=$(get_mds_dir "$DIR/$tdir")
1108 echo OSTIDX=$OSTIDX MDSIDX=$MDSIDX
1110 local OST=$(ostname_from_index $OSTIDX)
1111 local MDT_INDEX=$(lfs df | grep "\[MDT:$((MDSIDX - 1))\]" | awk '{print $1}' | \
1112 sed -e 's/_UUID$//;s/^.*-//')
1115 local mdtosc_proc1=$(get_mdtosc_proc_path mds${MDSIDX} $OST)
1116 local last_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1117 osc.$mdtosc_proc1.prealloc_last_id)
1118 local next_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1119 osc.$mdtosc_proc1.prealloc_next_id)
1121 local mdtosc_proc2=$(get_mdtosc_proc_path mds${MDSIDX})
1122 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1124 mkdir -p $DIR/$tdir/${OST}
1125 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1126 #define OBD_FAIL_OST_ENOSPC 0x215
1127 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=$FAILIDX
1128 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x215
1129 echo "Creating to objid $last_id on ost $OST..."
1130 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1131 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1132 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=$FAILLOC
1136 exhaust_all_precreations() {
1138 for (( i=0; i < OSTCOUNT; i++ )) ; do
1139 exhaust_precreations $i $1 -1
1144 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1145 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1146 remote_ost_nodsh && skip "remote OST with nodsh" && return
1149 rm -f $DIR/$tdir/$tfile
1150 exhaust_precreations 0 0x80000215
1151 $SETSTRIPE -c -1 $DIR/$tdir
1152 touch $DIR/$tdir/$tfile || error
1153 $GETSTRIPE $DIR/$tdir/$tfile
1156 run_test 27n "create file with some full OSTs =================="
1159 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1160 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1161 remote_ost_nodsh && skip "remote OST with nodsh" && return
1164 rm -f $DIR/$tdir/$tfile
1165 exhaust_all_precreations 0x215
1167 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1172 run_test 27o "create file with all full OSTs (should error) ===="
1175 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1176 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1177 remote_ost_nodsh && skip "remote OST with nodsh" && return
1180 rm -f $DIR/$tdir/$tfile
1183 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1184 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1185 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1187 exhaust_precreations 0 0x80000215
1188 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1189 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1190 $GETSTRIPE $DIR/$tdir/$tfile
1194 run_test 27p "append to a truncated file with some full OSTs ==="
1197 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1198 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1199 remote_ost_nodsh && skip "remote OST with nodsh" && return
1202 rm -f $DIR/$tdir/$tfile
1205 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1206 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||error "truncate $DIR/$tdir/$tfile failed"
1207 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1209 exhaust_all_precreations 0x215
1211 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1212 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1216 run_test 27q "append to truncated file with all OSTs full (should error) ==="
1219 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1220 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1221 remote_ost_nodsh && skip "remote OST with nodsh" && return
1224 rm -f $DIR/$tdir/$tfile
1225 exhaust_precreations 0 0x80000215
1227 $SETSTRIPE -i 0 -c 2 $DIR/$tdir/$tfile # && error
1231 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1233 test_27s() { # bug 10725
1235 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1236 local stripe_count=0
1237 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1238 $SETSTRIPE -S $stripe_size -c $stripe_count $DIR/$tdir &&
1239 error "stripe width >= 2^32 succeeded" || true
1242 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1244 test_27t() { # bug 10864
1249 $WLFS getstripe $tfile
1252 run_test 27t "check that utils parse path correctly"
1254 test_27u() { # bug 4900
1255 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1256 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1258 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1259 do_facet $SINGLEMDS lctl set_param fail_loc=0x139
1261 createmany -o $DIR/$tdir/t- 1000
1262 do_facet $SINGLEMDS lctl set_param fail_loc=0
1264 TLOG=$DIR/$tfile.getstripe
1265 $GETSTRIPE $DIR/$tdir > $TLOG
1266 OBJS=`awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj;}' $TLOG`
1267 unlinkmany $DIR/$tdir/t- 1000
1268 [ $OBJS -gt 0 ] && \
1269 error "$OBJS objects created on OST-0. See $TLOG" || pass
1271 run_test 27u "skip object creation on OSC w/o objects =========="
1273 test_27v() { # bug 4900
1274 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1275 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1276 remote_ost_nodsh && skip "remote OST with nodsh" && return
1278 exhaust_all_precreations 0x215
1282 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1284 touch $DIR/$tdir/$tfile
1285 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1287 for (( i=1; i < OSTCOUNT; i++ )); do
1288 do_facet ost$i lctl set_param fail_loc=0x705
1290 local START=`date +%s`
1291 createmany -o $DIR/$tdir/$tfile 32
1293 local FINISH=`date +%s`
1294 local TIMEOUT=`lctl get_param -n timeout`
1295 local PROCESS=$((FINISH - START))
1296 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1297 error "$FINISH - $START >= $TIMEOUT / 2"
1298 sleep $((TIMEOUT / 2 - PROCESS))
1301 run_test 27v "skip object creation on slow OST ================="
1303 test_27w() { # bug 10997
1304 mkdir -p $DIR/$tdir || error "mkdir failed"
1305 $SETSTRIPE -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1306 [ $($GETSTRIPE -S $DIR/$tdir/f0) -ne 65536 ] &&
1307 error "stripe size $size != 65536" || true
1308 [ $($GETSTRIPE -d $DIR/$tdir | grep -c "stripe_count") -ne 1 ] &&
1309 error "$GETSTRIPE -d $DIR/$tdir failed" || true
1311 run_test 27w "check $SETSTRIPE -S option"
1314 [ "$OSTCOUNT" -lt "2" ] &&
1315 skip_env "skipping multiple stripe count/offset test" && return
1317 mkdir -p $DIR/$tdir || error "mkdir failed"
1318 for i in $(seq 1 $OSTCOUNT); do
1320 $SETSTRIPE -c $i -i $offset $DIR/$tdir/f$i ||
1321 error "setstripe -c $i -i $offset failed"
1322 count=$($GETSTRIPE -c $DIR/$tdir/f$i)
1323 index=$($GETSTRIPE -i $DIR/$tdir/f$i)
1324 [ $count -ne $i ] && error "stripe count $count != $i" || true
1325 [ $index -ne $offset ] &&
1326 error "stripe offset $index != $offset" || true
1329 run_test 27wa "check $SETSTRIPE -c -i options"
1332 remote_ost_nodsh && skip "remote OST with nodsh" && return
1333 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs" && return
1334 OFFSET=$(($OSTCOUNT - 1))
1336 local OST=$(ostname_from_index $OSTIDX)
1339 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe per file
1340 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1342 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1343 for i in `seq 0 $OFFSET`; do
1344 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}' | grep -w "$OSTIDX"` ] &&
1345 error "OST0 was degraded but new created file still use it"
1347 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1349 run_test 27x "create files while OST0 is degraded"
1352 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1353 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1354 remote_ost_nodsh && skip "remote OST with nodsh" && return
1356 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1357 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1358 osc.$mdtosc.prealloc_last_id)
1359 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1360 osc.$mdtosc.prealloc_next_id)
1361 local fcount=$((last_id - next_id))
1362 [ $fcount -eq 0 ] && skip "not enough space on OST0" && return
1363 [ $fcount -gt $OSTCOUNT ] && fcount=$OSTCOUNT
1365 MDS_OSCS=`do_facet $SINGLEMDS lctl dl | awk '/[oO][sS][cC].*md[ts]/ { print $4 }'`
1366 OFFSET=$(($OSTCOUNT-1))
1368 for OSC in $MDS_OSCS; do
1369 if [ $OST == -1 ]; then {
1370 OST=`osc_to_ost $OSC`
1372 echo $OSC "is Deactivate:"
1373 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1377 OSTIDX=$(index_from_ostuuid $OST)
1379 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1381 do_facet ost$((OSTIDX+1)) lctl set_param -n obdfilter.$OST.degraded 1
1383 createmany -o $DIR/$tdir/$tfile $fcount
1384 do_facet ost$((OSTIDX+1)) lctl set_param -n obdfilter.$OST.degraded 0
1386 for i in `seq 0 $OFFSET`; do
1387 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "$OSTIDX"` ] || \
1388 error "files created on deactivated OSTs instead of degraded OST"
1390 for OSC in $MDS_OSCS; do
1391 [ `osc_to_ost $OSC` != $OST ] && {
1392 echo $OSC "is activate"
1393 do_facet $SINGLEMDS lctl --device %$OSC activate
1397 run_test 27y "create files while OST0 is degraded and the rest inactive"
1403 lmm_count=$($GETSTRIPE -c $1)
1404 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1405 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1407 local old_ifs="$IFS"
1409 fid=($($LFS path2fid $1))
1412 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1413 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1415 # compare lmm_seq and lu_fid->f_seq
1416 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1417 # compare lmm_object_id and lu_fid->oid
1418 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1420 # check the trusted.fid attribute of the OST objects of the file
1421 local have_obdidx=false
1423 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1424 # skip lines up to and including "obdidx"
1425 [ -z "$obdidx" ] && break
1426 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1427 $have_obdidx || continue
1429 local ost=$((obdidx + 1))
1430 local dev=$(ostdevname $ost)
1432 if [ $(facet_fstype ost$ost) != ldiskfs ]; then
1433 echo "Currently only works with ldiskfs-based OSTs"
1437 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1439 #don't unmount/remount the OSTs if we don't need to do that
1440 #local dir=$(facet_mntpt ost$ost)
1442 #do_facet ost$dev mount -t $FSTYPE $dev $dir $OST_MOUNT_OPTS ||
1443 # { error "mounting $dev as $FSTYPE failed"; return 3; }
1444 #local obj_file=$(do_facet ost$ost find $dir/O/$seq -name $oid)
1445 #local ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID $obj_file)
1447 local obj_file="O/$seq/d$((oid %32))/$oid"
1448 local ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
1449 $dev 2>/dev/null" | grep "parent=")
1451 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
1453 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
1455 #do_facet ost$ost umount -d $dir
1456 #start ost$ost $dev $OST_MOUNT_OPTS
1458 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
1459 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
1460 local ff_parent=$(echo $ff|sed -e 's/.*parent=.//')
1461 local ff_pseq=$(echo $ff_parent | cut -d: -f1)
1462 local ff_poid=$(echo $ff_parent | cut -d: -f2)
1463 local ff_pstripe=$(echo $ff_parent | sed -e 's/.*stripe=//')
1465 # compare lmm_seq and filter_fid->ff_parent.f_seq
1466 [ $ff_pseq = $lmm_seq ] ||
1467 error "FF parent SEQ $ff_pseq != $lmm_seq"
1468 # compare lmm_object_id and filter_fid->ff_parent.f_oid
1469 [ $ff_poid = $lmm_oid ] ||
1470 error "FF parent OID $ff_poid != $lmm_oid"
1471 [ $ff_pstripe = $stripe_nr ] ||
1472 error "FF stripe $ff_pstripe != $stripe_nr"
1474 stripe_nr=$((stripe_nr + 1))
1479 remote_ost_nodsh && skip "remote OST with nodsh" && return
1482 $SETSTRIPE -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
1483 { error "setstripe -c -1 failed"; return 1; }
1484 # We need to send a write to every object to get parent FID info set.
1485 # This _should_ also work for setattr, but does not currently.
1486 # touch $DIR/$tdir/$tfile-1 ||
1487 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
1488 { error "dd $tfile-1 failed"; return 2; }
1489 $SETSTRIPE -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
1490 { error "setstripe -c -1 failed"; return 3; }
1491 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
1492 { error "dd $tfile-2 failed"; return 4; }
1494 # make sure write RPCs have been sent to OSTs
1497 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
1498 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
1500 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
1502 test_27A() { # b=19102
1503 local restore_size=$($GETSTRIPE -S $MOUNT)
1504 local restore_count=$($GETSTRIPE -c $MOUNT)
1505 local restore_offset=$($GETSTRIPE -i $MOUNT)
1506 $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
1507 local default_size=$($GETSTRIPE -S $MOUNT)
1508 local default_count=$($GETSTRIPE -c $MOUNT)
1509 local default_offset=$($GETSTRIPE -i $MOUNT)
1510 local dsize=$((1024 * 1024))
1511 [ $default_size -eq $dsize ] ||
1512 error "stripe size $default_size != $dsize"
1513 [ $default_count -eq 1 ] || error "stripe count $default_count != 1"
1514 [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
1515 $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
1517 run_test 27A "check filesystem-wide default LOV EA values"
1519 # createtest also checks that device nodes are created and
1520 # then visible correctly (#2091)
1521 test_28() { # bug 2091
1523 $CREATETEST $DIR/d28/ct || error
1525 run_test 28 "create/mknod/mkdir with bad file types ============"
1528 cancel_lru_locks mdc
1534 declare -i LOCKCOUNTORIG=0
1535 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1536 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
1538 [ $LOCKCOUNTORIG -eq 0 ] && echo "No mdc lock count" && return 1
1540 declare -i LOCKUNUSEDCOUNTORIG=0
1541 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1542 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
1549 declare -i LOCKCOUNTCURRENT=0
1550 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1551 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
1554 declare -i LOCKUNUSEDCOUNTCURRENT=0
1555 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1556 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
1559 if [ "$LOCKCOUNTCURRENT" -gt "$LOCKCOUNTORIG" ]; then
1560 lctl set_param -n ldlm.dump_namespaces ""
1561 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
1562 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1563 log "dumped log to $TMP/test_29.dk (bug 5793)"
1566 if [ "$LOCKUNUSEDCOUNTCURRENT" -gt "$LOCKUNUSEDCOUNTORIG" ]; then
1567 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
1568 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1569 log "dumped log to $TMP/test_29.dk (bug 5793)"
1573 run_test 29 "IT_GETATTR regression ============================"
1575 test_30a() { # was test_30
1576 cp `which ls` $DIR || cp /bin/ls $DIR
1580 run_test 30a "execute binary from Lustre (execve) =============="
1583 cp `which ls` $DIR || cp /bin/ls $DIR
1585 $RUNAS $DIR/ls / || error
1588 run_test 30b "execute binary from Lustre as non-root ==========="
1590 test_30c() { # b=22376
1591 cp `which ls` $DIR || cp /bin/ls $DIR
1593 cancel_lru_locks mdc
1594 cancel_lru_locks osc
1595 $RUNAS $DIR/ls / || error
1598 run_test 30c "execute binary from Lustre without read perms ===="
1601 $OPENUNLINK $DIR/f31 $DIR/f31 || error
1602 $CHECKSTAT -a $DIR/f31 || error
1604 run_test 31a "open-unlink file =================================="
1607 touch $DIR/f31 || error
1608 ln $DIR/f31 $DIR/f31b || error
1609 $MULTIOP $DIR/f31b Ouc || error
1610 $CHECKSTAT -t file $DIR/f31 || error
1612 run_test 31b "unlink file with multiple links while open ======="
1615 touch $DIR/f31 || error
1616 ln $DIR/f31 $DIR/f31c || error
1617 multiop_bg_pause $DIR/f31 O_uc || return 1
1619 $MULTIOP $DIR/f31c Ouc
1620 kill -USR1 $MULTIPID
1623 run_test 31c "open-unlink file with multiple links ============="
1626 opendirunlink $DIR/d31d $DIR/d31d || error
1627 $CHECKSTAT -a $DIR/d31d || error
1629 run_test 31d "remove of open directory ========================="
1631 test_31e() { # bug 2904
1632 check_kernel_version 34 || return 0
1633 openfilleddirunlink $DIR/d31e || error
1635 run_test 31e "remove of open non-empty directory ==============="
1637 test_31f() { # bug 4554
1640 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
1641 cp /etc/hosts $DIR/d31f
1643 $GETSTRIPE $DIR/d31f/hosts
1644 multiop_bg_pause $DIR/d31f D_c || return 1
1647 rm -rv $DIR/d31f || error "first of $DIR/d31f"
1649 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
1650 cp /etc/hosts $DIR/d31f
1652 $GETSTRIPE $DIR/d31f/hosts
1653 multiop_bg_pause $DIR/d31f D_c || return 1
1656 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
1657 wait $MULTIPID || error "first opendir $MULTIPID failed"
1661 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
1662 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
1665 run_test 31f "remove of open directory with open-unlink file ==="
1668 echo "-- cross directory link --"
1669 mkdir $DIR/d31g{a,b}
1671 ln $DIR/d31ga/f $DIR/d31gb/g
1672 $CHECKSTAT -t file $DIR/d31ga/f || error "source"
1673 [ `stat -c%h $DIR/d31ga/f` == '2' ] || error "source nlink"
1674 $CHECKSTAT -t file $DIR/d31gb/g || error "target"
1675 [ `stat -c%h $DIR/d31gb/g` == '2' ] || error "target nlink"
1677 run_test 31g "cross directory link==============="
1680 echo "-- cross directory link --"
1684 ln $DIR/d31h/f $DIR/d31h/dir/g
1685 $CHECKSTAT -t file $DIR/d31h/f || error "source"
1686 [ `stat -c%h $DIR/d31h/f` == '2' ] || error "source nlink"
1687 $CHECKSTAT -t file $DIR/d31h/dir/g || error "target"
1688 [ `stat -c%h $DIR/d31h/dir/g` == '2' ] || error "target nlink"
1690 run_test 31h "cross directory link under child==============="
1693 echo "-- cross directory link --"
1696 touch $DIR/d31i/dir/f
1697 ln $DIR/d31i/dir/f $DIR/d31i/g
1698 $CHECKSTAT -t file $DIR/d31i/dir/f || error "source"
1699 [ `stat -c%h $DIR/d31i/dir/f` == '2' ] || error "source nlink"
1700 $CHECKSTAT -t file $DIR/d31i/g || error "target"
1701 [ `stat -c%h $DIR/d31i/g` == '2' ] || error "target nlink"
1703 run_test 31i "cross directory link under parent==============="
1708 mkdir $DIR/d31j/dir1
1709 ln $DIR/d31j/dir1 $DIR/d31j/dir2 && error "ln for dir"
1710 link $DIR/d31j/dir1 $DIR/d31j/dir3 && error "link for dir"
1711 mlink $DIR/d31j/dir1 $DIR/d31j/dir4 && error "mlink for dir"
1712 mlink $DIR/d31j/dir1 $DIR/d31j/dir1 && error "mlink to the same dir"
1715 run_test 31j "link for directory==============="
1721 touch $DIR/d31k/exist
1722 mlink $DIR/d31k/s $DIR/d31k/t || error "mlink"
1723 mlink $DIR/d31k/s $DIR/d31k/exist && error "mlink to exist file"
1724 mlink $DIR/d31k/s $DIR/d31k/s && error "mlink to the same file"
1725 mlink $DIR/d31k/s $DIR/d31k && error "mlink to parent dir"
1726 mlink $DIR/d31k $DIR/d31k/s && error "mlink parent dir to target"
1727 mlink $DIR/d31k/not-exist $DIR/d31k/foo && error "mlink non-existing to new"
1728 mlink $DIR/d31k/not-exist $DIR/d31k/s && error "mlink non-existing to exist"
1731 run_test 31k "link to file: the same, non-existing, dir==============="
1737 touch $DIR/d31m2/exist
1738 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
1739 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
1740 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
1741 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
1742 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
1743 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
1746 run_test 31m "link to file: the same, non-existing, dir==============="
1749 echo "== more mountpoints and symlinks ================="
1750 [ -e $DIR/d32a ] && rm -fr $DIR/d32a
1751 mkdir -p $DIR/d32a/ext2-mountpoint
1752 mount -t ext2 -o loop $EXT2_DEV $DIR/d32a/ext2-mountpoint || error
1753 $CHECKSTAT -t dir $DIR/d32a/ext2-mountpoint/.. || error
1754 $UMOUNT $DIR/d32a/ext2-mountpoint || error
1756 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
1759 [ -e $DIR/d32b ] && rm -fr $DIR/d32b
1760 mkdir -p $DIR/d32b/ext2-mountpoint
1761 mount -t ext2 -o loop $EXT2_DEV $DIR/d32b/ext2-mountpoint || error
1762 ls -al $DIR/d32b/ext2-mountpoint/.. || error
1763 $UMOUNT $DIR/d32b/ext2-mountpoint || error
1765 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
1768 [ -e $DIR/d32c ] && rm -fr $DIR/d32c
1769 mkdir -p $DIR/d32c/ext2-mountpoint
1770 mount -t ext2 -o loop $EXT2_DEV $DIR/d32c/ext2-mountpoint || error
1771 mkdir -p $DIR/d32c/d2/test_dir
1772 $CHECKSTAT -t dir $DIR/d32c/ext2-mountpoint/../d2/test_dir || error
1773 $UMOUNT $DIR/d32c/ext2-mountpoint || error
1775 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
1778 [ -e $DIR/d32d ] && rm -fr $DIR/d32d
1779 mkdir -p $DIR/d32d/ext2-mountpoint
1780 mount -t ext2 -o loop $EXT2_DEV $DIR/d32d/ext2-mountpoint || error
1781 mkdir -p $DIR/d32d/d2/test_dir
1782 ls -al $DIR/d32d/ext2-mountpoint/../d2/test_dir || error
1783 $UMOUNT $DIR/d32d/ext2-mountpoint || error
1785 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
1788 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
1789 mkdir -p $DIR/d32e/tmp
1790 TMP_DIR=$DIR/d32e/tmp
1791 ln -s $DIR/d32e $TMP_DIR/symlink11
1792 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1793 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
1794 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
1796 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
1799 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
1800 mkdir -p $DIR/d32f/tmp
1801 TMP_DIR=$DIR/d32f/tmp
1802 ln -s $DIR/d32f $TMP_DIR/symlink11
1803 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1804 ls $DIR/d32f/tmp/symlink11 || error
1805 ls $DIR/d32f/symlink01 || error
1807 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
1810 TMP_DIR=$DIR/$tdir/tmp
1811 mkdir -p $TMP_DIR $DIR/${tdir}2
1812 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
1813 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1814 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
1815 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
1816 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
1817 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
1819 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
1822 rm -fr $DIR/$tdir $DIR/${tdir}2
1823 TMP_DIR=$DIR/$tdir/tmp
1824 mkdir -p $TMP_DIR $DIR/${tdir}2
1825 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
1826 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1827 ls $TMP_DIR/symlink12 || error
1828 ls $DIR/$tdir/symlink02 || error
1830 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
1833 [ -e $DIR/d32i ] && rm -fr $DIR/d32i
1834 mkdir -p $DIR/d32i/ext2-mountpoint
1835 mount -t ext2 -o loop $EXT2_DEV $DIR/d32i/ext2-mountpoint || error
1836 touch $DIR/d32i/test_file
1837 $CHECKSTAT -t file $DIR/d32i/ext2-mountpoint/../test_file || error
1838 $UMOUNT $DIR/d32i/ext2-mountpoint || error
1840 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
1843 [ -e $DIR/d32j ] && rm -fr $DIR/d32j
1844 mkdir -p $DIR/d32j/ext2-mountpoint
1845 mount -t ext2 -o loop $EXT2_DEV $DIR/d32j/ext2-mountpoint || error
1846 touch $DIR/d32j/test_file
1847 cat $DIR/d32j/ext2-mountpoint/../test_file || error
1848 $UMOUNT $DIR/d32j/ext2-mountpoint || error
1850 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
1854 mkdir -p $DIR/d32k/ext2-mountpoint
1855 mount -t ext2 -o loop $EXT2_DEV $DIR/d32k/ext2-mountpoint
1856 mkdir -p $DIR/d32k/d2
1857 touch $DIR/d32k/d2/test_file || error
1858 $CHECKSTAT -t file $DIR/d32k/ext2-mountpoint/../d2/test_file || error
1859 $UMOUNT $DIR/d32k/ext2-mountpoint || error
1861 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
1865 mkdir -p $DIR/d32l/ext2-mountpoint
1866 mount -t ext2 -o loop $EXT2_DEV $DIR/d32l/ext2-mountpoint || error
1867 mkdir -p $DIR/d32l/d2
1868 touch $DIR/d32l/d2/test_file
1869 cat $DIR/d32l/ext2-mountpoint/../d2/test_file || error
1870 $UMOUNT $DIR/d32l/ext2-mountpoint || error
1872 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
1876 mkdir -p $DIR/d32m/tmp
1877 TMP_DIR=$DIR/d32m/tmp
1878 ln -s $DIR $TMP_DIR/symlink11
1879 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1880 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
1881 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
1883 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
1887 mkdir -p $DIR/d32n/tmp
1888 TMP_DIR=$DIR/d32n/tmp
1889 ln -s $DIR $TMP_DIR/symlink11
1890 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1891 ls -l $DIR/d32n/tmp/symlink11 || error
1892 ls -l $DIR/d32n/symlink01 || error
1894 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
1897 rm -fr $DIR/d32o $DIR/$tfile
1899 mkdir -p $DIR/d32o/tmp
1900 TMP_DIR=$DIR/d32o/tmp
1901 ln -s $DIR/$tfile $TMP_DIR/symlink12
1902 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1903 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
1904 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
1905 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
1906 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
1908 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
1918 mkdir -p $DIR/d32p/tmp
1920 TMP_DIR=$DIR/d32p/tmp
1922 ln -s $DIR/$tfile $TMP_DIR/symlink12
1924 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1926 cat $DIR/d32p/tmp/symlink12 || error
1928 cat $DIR/d32p/symlink02 || error
1931 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
1934 [ -e $DIR/d32q ] && rm -fr $DIR/d32q
1936 touch $DIR/d32q/under_the_mount
1937 mount -t ext2 -o loop $EXT2_DEV $DIR/d32q
1938 ls $DIR/d32q/under_the_mount && error || true
1939 $UMOUNT $DIR/d32q || error
1941 run_test 32q "stat follows mountpoints in Lustre (should return error)"
1944 [ -e $DIR/d32r ] && rm -fr $DIR/d32r
1946 touch $DIR/d32r/under_the_mount
1947 mount -t ext2 -o loop $EXT2_DEV $DIR/d32r
1948 ls $DIR/d32r | grep -q under_the_mount && error || true
1949 $UMOUNT $DIR/d32r || error
1951 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
1956 chmod 444 $DIR/$tfile
1957 chown $RUNAS_ID $DIR/$tfile
1959 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
1962 run_test 33 "write file with mode 444 (should return error) ===="
1967 chown $RUNAS_ID $DIR/d33
1968 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
1969 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
1970 error "open RDWR" || true
1972 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
1977 chown $RUNAS_ID $DIR/d33
1978 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33 && error "create" || true
1980 run_test 33b "test open file with malformed flags (No panic and return error)"
1988 remote_ost_nodsh && skip "remote OST with nodsh" && return
1992 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
1995 for ostnum in $(seq $OSTCOUNT); do
1996 # test-framework's OST numbering is one-based, while Lustre's
1998 ostname=$(printf "$FSNAME-OST%.4d" $((ostnum - 1)))
1999 # Parsing llobdstat's output sucks; we could grep the /proc
2000 # path, but that's likely to not be as portable as using the
2001 # llobdstat utility. So we parse lctl output instead.
2002 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2003 obdfilter/$ostname/stats |
2004 awk '/^write_bytes/ {print $7}' )
2005 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2006 if (( ${write_bytes:-0} > 0 ))
2013 $all_zeros || return 0
2016 echo foo > $DIR/d33/bar
2020 # Total up write_bytes after writing. We'd better find non-zeros.
2021 for ostnum in $(seq $OSTCOUNT); do
2022 ostname=$(printf "$FSNAME-OST%.4d" $((ostnum - 1)))
2023 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2024 obdfilter/$ostname/stats |
2025 awk '/^write_bytes/ {print $7}' )
2026 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2027 if (( ${write_bytes:-0} > 0 ))
2036 for ostnum in $(seq $OSTCOUNT); do
2037 ostname=$(printf "$FSNAME-OST%.4d" $((ostnum - 1)))
2038 echo "Check that write_bytes is present in obdfilter/*/stats:"
2039 do_facet ost$ostnum lctl get_param -n \
2040 obdfilter/$ostname/stats
2042 error "OST not keeping write_bytes stats (b22312)"
2045 run_test 33c "test llobdstat and write_bytes"
2047 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
2050 $MCREATE $DIR/f34 || error
2051 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2052 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
2053 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2054 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2056 run_test 34a "truncate file that has not been opened ==========="
2059 [ ! -f $DIR/f34 ] && test_34a
2060 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2061 $OPENFILE -f O_RDONLY $DIR/f34
2062 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2063 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2065 run_test 34b "O_RDONLY opening file doesn't create objects ====="
2068 [ ! -f $DIR/f34 ] && test_34a
2069 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2070 $OPENFILE -f O_RDWR $DIR/f34
2071 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2072 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2074 run_test 34c "O_RDWR opening file-with-size works =============="
2077 [ ! -f $DIR/f34 ] && test_34a
2078 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2079 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2082 run_test 34d "write to sparse file ============================="
2086 $MCREATE $DIR/f34e || error
2087 $TRUNCATE $DIR/f34e 1000 || error
2088 $CHECKSTAT -s 1000 $DIR/f34e || error
2089 $OPENFILE -f O_RDWR $DIR/f34e
2090 $CHECKSTAT -s 1000 $DIR/f34e || error
2092 run_test 34e "create objects, some with size and some without =="
2094 test_34f() { # bug 6242, 6243
2097 $MCREATE $DIR/f34f || error
2098 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
2099 dd if=$DIR/f34f of=$TMP/f34f
2100 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
2101 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
2102 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
2103 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
2104 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
2106 run_test 34f "read from a file with no objects until EOF ======="
2109 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
2110 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
2111 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
2112 cancel_lru_locks osc
2113 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
2114 error "wrong size after lock cancel"
2116 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
2117 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2118 error "expanding truncate failed"
2119 cancel_lru_locks osc
2120 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2121 error "wrong expanded size after lock cancel"
2123 run_test 34g "truncate long file ==============================="
2129 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
2130 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
2134 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
2135 error "Multiop blocked on ftruncate, pid=$MULTIPID"
2139 local nsz=`stat -c %s $DIR/$tfile`
2140 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
2142 run_test 34h "ftruncate file under grouplock should not block"
2145 cp /bin/sh $DIR/f35a
2147 chown $RUNAS_ID $DIR/f35a
2148 $RUNAS $DIR/f35a && error || true
2151 run_test 35a "exec file with mode 444 (should return and not leak) ====="
2155 utime $DIR/f36 || error
2157 run_test 36a "MDS utime check (mknod, utime) ==================="
2161 utime $DIR/f36 || error
2163 run_test 36b "OST utime check (open, utime) ===================="
2168 chown $RUNAS_ID $DIR/d36
2169 $RUNAS utime $DIR/d36/f36 || error
2171 run_test 36c "non-root MDS utime check (mknod, utime) =========="
2174 [ ! -d $DIR/d36 ] && test_36c
2175 echo "" > $DIR/d36/f36
2176 $RUNAS utime $DIR/d36/f36 || error
2178 run_test 36d "non-root OST utime check (open, utime) ==========="
2181 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
2183 touch $DIR/$tdir/$tfile
2184 $RUNAS utime $DIR/$tdir/$tfile && \
2185 error "utime worked, expected failure" || true
2187 run_test 36e "utime on non-owned file (should return error) ===="
2191 local LANG_SAVE=$LANG
2192 local LC_LANG_SAVE=$LC_LANG
2193 export LANG=C LC_LANG=C # for date language
2195 DATESTR="Dec 20 2000"
2197 lctl set_param fail_loc=$fl
2199 cp /etc/hosts $DIR/$tdir/$tfile
2200 sync & # write RPC generated with "current" inode timestamp, but delayed
2202 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
2203 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
2204 cancel_lru_locks osc
2205 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
2207 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
2208 echo "BEFORE: $LS_BEFORE" && \
2209 echo "AFTER : $LS_AFTER" && \
2210 echo "WANT : $DATESTR" && \
2211 error "$DIR/$tdir/$tfile timestamps changed" || true
2213 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
2217 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2218 subr_36fh "0x80000214"
2220 run_test 36f "utime on file racing with OST BRW write =========="
2223 remote_ost_nodsh && skip "remote OST with nodsh" && return
2229 fmd_max_age=$(do_facet ost1 \
2230 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
2233 fmd_before=$(do_facet ost1 \
2234 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2235 touch $DIR/$tdir/$tfile
2236 sleep $((fmd_max_age + 12))
2237 fmd_after=$(do_facet ost1 \
2238 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2240 echo "fmd_before: $fmd_before"
2241 echo "fmd_after: $fmd_after"
2242 [ "$fmd_after" -gt "$fmd_before" ] && \
2243 echo "AFTER: $fmd_after > BEFORE: $fmd_before" && \
2244 error "fmd didn't expire after ping" || true
2246 run_test 36g "filter mod data cache expiry ====================="
2249 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
2250 subr_36fh "0x80000227"
2252 run_test 36h "utime on file racing with OST BRW write =========="
2256 echo f > $DIR/$tdir/fbugfile
2257 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2258 ls $DIR/$tdir | grep "\<fbugfile\>" && error
2259 $UMOUNT $DIR/$tdir || error
2260 rm -f $DIR/$tdir/fbugfile || error
2262 run_test 37 "ls a mounted file system to check old content ====="
2265 local file=$DIR/$tfile
2267 openfile -f O_DIRECTORY $file
2270 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
2271 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
2273 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
2277 touch $DIR/${tfile}2
2278 # ls -l $DIR/$tfile $DIR/${tfile}2
2279 # ls -lu $DIR/$tfile $DIR/${tfile}2
2280 # ls -lc $DIR/$tfile $DIR/${tfile}2
2282 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
2283 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
2285 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
2287 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
2289 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
2290 error "O_TRUNC didn't change timestamps"
2293 run_test 39 "mtime changed on create ==========================="
2297 cp -p /etc/passwd $DIR/$tdir/fopen
2298 cp -p /etc/passwd $DIR/$tdir/flink
2299 cp -p /etc/passwd $DIR/$tdir/funlink
2300 cp -p /etc/passwd $DIR/$tdir/frename
2301 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
2304 echo "aaaaaa" >> $DIR/$tdir/fopen
2305 echo "aaaaaa" >> $DIR/$tdir/flink
2306 echo "aaaaaa" >> $DIR/$tdir/funlink
2307 echo "aaaaaa" >> $DIR/$tdir/frename
2309 local open_new=`stat -c %Y $DIR/$tdir/fopen`
2310 local link_new=`stat -c %Y $DIR/$tdir/flink`
2311 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
2312 local rename_new=`stat -c %Y $DIR/$tdir/frename`
2314 cat $DIR/$tdir/fopen > /dev/null
2315 ln $DIR/$tdir/flink $DIR/$tdir/flink2
2316 rm -f $DIR/$tdir/funlink2
2317 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
2319 for (( i=0; i < 2; i++ )) ; do
2320 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
2321 local link_new2=`stat -c %Y $DIR/$tdir/flink`
2322 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
2323 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
2325 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
2326 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
2327 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
2328 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
2330 cancel_lru_locks osc
2331 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2334 run_test 39b "mtime change on open, link, unlink, rename ======"
2336 # this should be set to past
2337 TEST_39_MTIME=`date -d "1 year ago" +%s`
2343 local mtime0=`stat -c %Y $DIR1/$tfile`
2345 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2346 local mtime1=`stat -c %Y $DIR1/$tfile`
2347 [ "$mtime1" = $TEST_39_MTIME ] || \
2348 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
2351 echo hello >> $DIR1/$tfile
2353 local mtime2=`stat -c %Y $DIR1/$tfile`
2354 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
2355 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
2357 mv $DIR1/$tfile $DIR1/$tfile-1
2359 for (( i=0; i < 2; i++ )) ; do
2360 local mtime3=`stat -c %Y $DIR1/$tfile-1`
2361 [ "$mtime2" = "$mtime3" ] || \
2362 error "mtime ($mtime2) changed (to $mtime3) on rename"
2364 cancel_lru_locks osc
2365 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2368 run_test 39c "mtime change on rename ==========================="
2374 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2376 for (( i=0; i < 2; i++ )) ; do
2377 local mtime=`stat -c %Y $DIR1/$tfile`
2378 [ $mtime = $TEST_39_MTIME ] || \
2379 error "mtime($mtime) is not set to $TEST_39_MTIME"
2381 cancel_lru_locks osc
2382 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2385 run_test 39d "create, utime, stat =============================="
2390 local mtime1=`stat -c %Y $DIR1/$tfile`
2392 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2394 for (( i=0; i < 2; i++ )) ; do
2395 local mtime2=`stat -c %Y $DIR1/$tfile`
2396 [ $mtime2 = $TEST_39_MTIME ] || \
2397 error "mtime($mtime2) is not set to $TEST_39_MTIME"
2399 cancel_lru_locks osc
2400 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2403 run_test 39e "create, stat, utime, stat ========================"
2408 mtime1=`stat -c %Y $DIR1/$tfile`
2411 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2413 for (( i=0; i < 2; i++ )) ; do
2414 local mtime2=`stat -c %Y $DIR1/$tfile`
2415 [ $mtime2 = $TEST_39_MTIME ] || \
2416 error "mtime($mtime2) is not set to $TEST_39_MTIME"
2418 cancel_lru_locks osc
2419 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2422 run_test 39f "create, stat, sleep, utime, stat ================="
2426 echo hello >> $DIR1/$tfile
2427 local mtime1=`stat -c %Y $DIR1/$tfile`
2430 chmod o+r $DIR1/$tfile
2432 for (( i=0; i < 2; i++ )) ; do
2433 local mtime2=`stat -c %Y $DIR1/$tfile`
2434 [ "$mtime1" = "$mtime2" ] || \
2435 error "lost mtime: $mtime2, should be $mtime1"
2437 cancel_lru_locks osc
2438 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2441 run_test 39g "write, chmod, stat ==============================="
2449 echo hello >> $DIR1/$tfile
2450 local mtime1=`stat -c %Y $DIR1/$tfile`
2452 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2454 if [ "$d1" != "$d2" ]; then
2455 echo "write and touch not within one second"
2457 for (( i=0; i < 2; i++ )) ; do
2458 local mtime2=`stat -c %Y $DIR1/$tfile`
2459 [ "$mtime2" = $TEST_39_MTIME ] || \
2460 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
2462 cancel_lru_locks osc
2463 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2467 run_test 39h "write, utime within one second, stat ============="
2473 echo hello >> $DIR1/$tfile
2474 local mtime1=`stat -c %Y $DIR1/$tfile`
2476 mv $DIR1/$tfile $DIR1/$tfile-1
2478 for (( i=0; i < 2; i++ )) ; do
2479 local mtime2=`stat -c %Y $DIR1/$tfile-1`
2481 [ "$mtime1" = "$mtime2" ] || \
2482 error "lost mtime: $mtime2, should be $mtime1"
2484 cancel_lru_locks osc
2485 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2488 run_test 39i "write, rename, stat =============================="
2491 start_full_debug_logging
2495 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
2496 lctl set_param fail_loc=0x80000412
2497 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
2498 error "multiop failed"
2500 local mtime1=`stat -c %Y $DIR1/$tfile`
2502 mv $DIR1/$tfile $DIR1/$tfile-1
2504 kill -USR1 $multipid
2505 wait $multipid || error "multiop close failed"
2507 for (( i=0; i < 2; i++ )) ; do
2508 local mtime2=`stat -c %Y $DIR1/$tfile-1`
2509 [ "$mtime1" = "$mtime2" ] ||
2510 error "mtime is lost on close: $mtime2, " \
2513 cancel_lru_locks osc
2514 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2516 lctl set_param fail_loc=0
2517 stop_full_debug_logging
2519 run_test 39j "write, rename, close, stat ======================="
2525 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
2527 local mtime1=`stat -c %Y $DIR1/$tfile`
2529 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2531 kill -USR1 $multipid
2532 wait $multipid || error "multiop close failed"
2534 for (( i=0; i < 2; i++ )) ; do
2535 local mtime2=`stat -c %Y $DIR1/$tfile`
2537 [ "$mtime2" = $TEST_39_MTIME ] || \
2538 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
2540 cancel_lru_locks osc
2541 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2544 run_test 39k "write, utime, close, stat ========================"
2546 # this should be set to future
2547 TEST_39_ATIME=`date -d "1 year" +%s`
2549 is_sles11() # LU-1783
2551 if [ -r /etc/SuSE-release ]
2553 local vers=`grep VERSION /etc/SuSE-release | awk '{print $3}'`
2554 local patchlev=`grep PATCHLEVEL /etc/SuSE-release \
2556 if [ $vers -eq 11 ] && [ $patchlev -eq 1 ]
2565 is_sles11 && skip "SLES 11 SP1" && return # LU-1783
2566 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2567 local atime_diff=$(do_facet $SINGLEMDS lctl get_param -n mdd.*.atime_diff)
2571 # test setting directory atime to future
2572 touch -a -d @$TEST_39_ATIME $DIR/$tdir
2573 local atime=$(stat -c %X $DIR/$tdir)
2574 [ "$atime" = $TEST_39_ATIME ] || \
2575 error "atime is not set to future: $atime, should be $TEST_39_ATIME"
2577 # test setting directory atime from future to now
2578 local d1=$(date +%s)
2580 local d2=$(date +%s)
2582 cancel_lru_locks mdc
2583 atime=$(stat -c %X $DIR/$tdir)
2584 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
2585 error "atime is not updated from future: $atime, should be $d1<atime<$d2"
2587 do_facet $SINGLEMDS lctl set_param -n mdd.*.atime_diff=2
2590 # test setting directory atime when now > dir atime + atime_diff
2594 cancel_lru_locks mdc
2595 atime=$(stat -c %X $DIR/$tdir)
2596 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
2597 error "atime is not updated : $atime, should be $d2"
2599 do_facet $SINGLEMDS lctl set_param -n mdd.*.atime_diff=60
2602 # test not setting directory atime when now < dir atime + atime_diff
2604 cancel_lru_locks mdc
2605 atime=$(stat -c %X $DIR/$tdir)
2606 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
2607 error "atime is updated to $atime, should remain $d1<atime<$d2"
2609 do_facet $SINGLEMDS lctl set_param -n mdd.*.atime_diff=$atime_diff
2611 run_test 39l "directory atime update ==========================="
2616 local far_past_mtime=$(date -d "May 29 1953" +%s)
2617 local far_past_atime=$(date -d "Dec 17 1903" +%s)
2619 touch -m -d @$far_past_mtime $DIR1/$tfile
2620 touch -a -d @$far_past_atime $DIR1/$tfile
2622 for (( i=0; i < 2; i++ )) ; do
2623 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
2624 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
2625 error "atime or mtime set incorrectly"
2627 cancel_lru_locks osc
2628 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2631 run_test 39m "test atime and mtime before 1970"
2634 dd if=/dev/zero of=$DIR/f40 bs=4096 count=1
2635 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/f40 && error
2636 $CHECKSTAT -t file -s 4096 $DIR/f40 || error
2638 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
2642 small_write $DIR/f41 18
2644 run_test 41 "test small file write + fstat ====================="
2646 count_ost_writes() {
2647 lctl get_param -n osc.*.stats |
2648 awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }'
2655 BG_DIRTY_RATIO_SAVE=10
2656 MAX_BG_DIRTY_RATIO=25
2660 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
2661 # dirty_ratio, dirty_background_ratio
2662 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
2663 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
2664 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
2665 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
2667 # if file not here, we are a 2.4 kernel
2668 kill -CONT `pidof kupdated`
2673 # setup the trap first, so someone cannot exit the test at the
2674 # exact wrong time and mess up a machine
2675 trap start_writeback EXIT
2676 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
2677 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
2678 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
2679 sysctl -w vm.dirty_writeback_centisecs=0
2680 sysctl -w vm.dirty_writeback_centisecs=0
2681 # save and increase /proc/sys/vm/dirty_ratio
2682 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
2683 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
2684 # save and increase /proc/sys/vm/dirty_background_ratio
2685 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
2686 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
2688 # if file not here, we are a 2.4 kernel
2689 kill -STOP `pidof kupdated`
2693 # ensure that all stripes have some grant before we test client-side cache
2695 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
2696 dd if=/dev/zero of=$i bs=4k count=1
2701 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
2702 # file truncation, and file removal.
2705 cancel_lru_locks osc
2707 sync; sleep 1; sync # just to be safe
2708 BEFOREWRITES=`count_ost_writes`
2709 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
2710 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
2711 AFTERWRITES=`count_ost_writes`
2712 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
2713 error "$BEFOREWRITES < $AFTERWRITES"
2716 run_test 42a "ensure that we don't flush on close =============="
2720 cancel_lru_locks osc
2723 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
2724 BEFOREWRITES=`count_ost_writes`
2725 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
2726 AFTERWRITES=`count_ost_writes`
2727 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
2728 error "$BEFOREWRITES < $AFTERWRITES on unlink"
2730 BEFOREWRITES=`count_ost_writes`
2731 sync || error "sync: $?"
2732 AFTERWRITES=`count_ost_writes`
2733 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
2734 error "$BEFOREWRITES < $AFTERWRITES on sync"
2736 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
2740 run_test 42b "test destroy of file with cached dirty data ======"
2742 # if these tests just want to test the effect of truncation,
2743 # they have to be very careful. consider:
2744 # - the first open gets a {0,EOF}PR lock
2745 # - the first write conflicts and gets a {0, count-1}PW
2746 # - the rest of the writes are under {count,EOF}PW
2747 # - the open for truncate tries to match a {0,EOF}PR
2748 # for the filesize and cancels the PWs.
2749 # any number of fixes (don't get {0,EOF} on open, match
2750 # composite locks, do smarter file size management) fix
2751 # this, but for now we want these tests to verify that
2752 # the cancellation with truncate intent works, so we
2753 # start the file with a full-file pw lock to match against
2754 # until the truncate.
2759 cancel_lru_locks osc
2761 # prime the file with 0,EOF PW to match
2765 # now the real test..
2766 dd if=/dev/zero of=$file bs=1024 count=100
2767 BEFOREWRITES=`count_ost_writes`
2768 $TRUNCATE $file $offset
2769 cancel_lru_locks osc
2770 AFTERWRITES=`count_ost_writes`
2776 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
2777 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
2780 run_test 42c "test partial truncate of file with cached dirty data"
2784 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
2785 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
2788 run_test 42d "test complete truncate of file with cached dirty data"
2790 test_42e() { # bug22074
2791 local TDIR=$DIR/${tdir}e
2792 local pagesz=$(page_size)
2793 local pages=16 # hardcoded 16 pages, don't change it.
2794 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
2795 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
2800 $SETSTRIPE -c 1 $TDIR
2801 createmany -o $TDIR/f $files
2803 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
2805 # we assume that with $OSTCOUNT files, at least one of them will
2806 # be allocated on OST0.
2807 warmup_files=$((OSTCOUNT * max_dirty_mb))
2808 createmany -o $TDIR/w $warmup_files
2810 # write a large amount of data into one file and sync, to get good
2811 # avail_grant number from OST.
2812 for ((i=0; i<$warmup_files; i++)); do
2813 idx=$($GETSTRIPE -i $TDIR/w$i)
2814 [ $idx -ne 0 ] && continue
2815 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
2818 [ $i -gt $warmup_files ] && error "OST0 is still cold"
2820 $LCTL get_param $proc_osc0/cur_dirty_bytes
2821 $LCTL get_param $proc_osc0/cur_grant_bytes
2823 # create as much dirty pages as we can while not to trigger the actual
2824 # RPCs directly. but depends on the env, VFS may trigger flush during this
2825 # period, hopefully we are good.
2826 for ((i=0; i<$warmup_files; i++)); do
2827 idx=$($GETSTRIPE -i $TDIR/w$i)
2828 [ $idx -ne 0 ] && continue
2829 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
2831 $LCTL get_param $proc_osc0/cur_dirty_bytes
2832 $LCTL get_param $proc_osc0/cur_grant_bytes
2834 # perform the real test
2835 $LCTL set_param $proc_osc0/rpc_stats 0
2836 for ((;i<$files; i++)); do
2837 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
2838 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
2841 $LCTL get_param $proc_osc0/rpc_stats
2844 local have_ppr=false
2845 $LCTL get_param $proc_osc0/rpc_stats |
2846 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
2847 # skip lines until we are at the RPC histogram data
2848 [ "$PPR" == "pages" ] && have_ppr=true && continue
2849 $have_ppr || continue
2851 # we only want the percent stat for < 16 pages
2852 [ $(echo $PPR | tr -d ':') -ge $pages ] && break
2854 percent=$((percent + WPCT))
2855 if [ $percent -gt 15 ]; then
2856 error "less than 16-pages write RPCs" \
2863 run_test 42e "verify sub-RPC writes are not done synchronously"
2867 cp -p /bin/ls $DIR/$tdir/$tfile
2868 $MULTIOP $DIR/$tdir/$tfile Ow_c &
2870 # give multiop a chance to open
2873 $DIR/$tdir/$tfile && error || true
2876 run_test 43 "execution of file opened for write should return -ETXTBSY"
2880 cp -p `which $MULTIOP` $DIR/d43/multiop || cp -p multiop $DIR/d43/multiop
2881 MULTIOP_PROG=$DIR/d43/multiop multiop_bg_pause $TMP/test43.junk O_c || return 1
2883 $MULTIOP $DIR/d43/multiop Oc && error "expected error, got success"
2884 kill -USR1 $MULTIOP_PID || return 2
2885 wait $MULTIOP_PID || return 3
2888 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
2892 cp -p `which $MULTIOP` $DIR/d43/multiop || cp -p multiop $DIR/d43/multiop
2893 MULTIOP_PROG=$DIR/d43/multiop multiop_bg_pause $TMP/test43.junk O_c || return 1
2895 $TRUNCATE $DIR/d43/multiop 0 && error "expected error, got success"
2896 kill -USR1 $MULTIOP_PID || return 2
2897 wait $MULTIOP_PID || return 3
2900 run_test 43b "truncate of file being executed should return -ETXTBSY"
2903 local testdir="$DIR/d43c"
2906 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
2907 ( cd $testdir && md5sum -c)
2909 run_test 43c "md5sum of copy into lustre========================"
2912 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
2913 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
2914 dd if=$DIR/f1 bs=4k count=1 > /dev/null
2916 run_test 44 "zero length read from a sparse stripe ============="
2919 local nstripe=`$LCTL lov_getconfig $DIR | grep default_stripe_count: | \
2921 [ -z "$nstripe" ] && skip "can't get stripe info" && return
2922 [ "$nstripe" -gt "$OSTCOUNT" ] && skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" && return
2923 local stride=`$LCTL lov_getconfig $DIR | grep default_stripe_size: | \
2925 if [ $nstripe -eq 0 -o $nstripe -eq -1 ] ; then
2926 nstripe=`$LCTL lov_getconfig $DIR | grep obd_count: | awk '{print $2}'`
2929 OFFSETS="0 $((stride/2)) $((stride-1))"
2930 for offset in $OFFSETS ; do
2931 for i in `seq 0 $((nstripe-1))`; do
2932 local GLOBALOFFSETS=""
2933 local size=$((((i + 2 * $nstripe )*$stride + $offset))) # Bytes
2934 local myfn=$DIR/d44a-$size
2935 echo "--------writing $myfn at $size"
2936 ll_sparseness_write $myfn $size || error "ll_sparseness_write"
2937 GLOBALOFFSETS="$GLOBALOFFSETS $size"
2938 ll_sparseness_verify $myfn $GLOBALOFFSETS \
2939 || error "ll_sparseness_verify $GLOBALOFFSETS"
2941 for j in `seq 0 $((nstripe-1))`; do
2942 size=$((((j + $nstripe )*$stride + $offset))) # Bytes
2943 ll_sparseness_write $myfn $size || error "ll_sparseness_write"
2944 GLOBALOFFSETS="$GLOBALOFFSETS $size"
2946 ll_sparseness_verify $myfn $GLOBALOFFSETS \
2947 || error "ll_sparseness_verify $GLOBALOFFSETS"
2952 run_test 44a "test sparse pwrite ==============================="
2956 for d in `lctl get_param -n osc.*.cur_dirty_bytes`; do
2962 before=`dirty_osc_total`
2963 echo executing "\"$*\""
2965 after=`dirty_osc_total`
2966 echo before $before, after $after
2970 # Obtain grants from OST if it supports it
2971 echo blah > ${f}_grant
2974 do_dirty_record "echo blah > $f"
2975 [ $before -eq $after ] && error "write wasn't cached"
2976 do_dirty_record "> $f"
2977 [ $before -gt $after ] || error "truncate didn't lower dirty count"
2978 do_dirty_record "echo blah > $f"
2979 [ $before -eq $after ] && error "write wasn't cached"
2980 do_dirty_record "sync"
2981 [ $before -gt $after ] || error "writeback didn't lower dirty count"
2982 do_dirty_record "echo blah > $f"
2983 [ $before -eq $after ] && error "write wasn't cached"
2984 do_dirty_record "cancel_lru_locks osc"
2985 [ $before -gt $after ] || error "lock cancellation didn't lower dirty count"
2988 run_test 45 "osc io page accounting ============================"
2990 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
2991 # test tickles a bug where re-dirtying a page was failing to be mapped to the
2992 # objects offset and an assert hit when an rpc was built with 1023's mapped
2993 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
2998 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3000 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
3001 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3005 run_test 46 "dirtying a previously written page ================"
3007 # test_47 is removed "Device nodes check" is moved to test_28
3009 test_48a() { # bug 2399
3010 check_kernel_version 34 || return 0
3013 mv $DIR/d48a $DIR/d48.new || error "move directory failed"
3014 mkdir $DIR/d48a || error "recreate directory failed"
3015 touch foo || error "'touch foo' failed after recreating cwd"
3016 mkdir bar || error "'mkdir foo' failed after recreating cwd"
3017 if check_kernel_version 44; then
3018 touch .foo || error "'touch .foo' failed after recreating cwd"
3019 mkdir .bar || error "'mkdir .foo' failed after recreating cwd"
3021 ls . > /dev/null || error "'ls .' failed after recreating cwd"
3022 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3023 cd . || error "'cd .' failed after recreating cwd"
3024 mkdir . && error "'mkdir .' worked after recreating cwd"
3025 rmdir . && error "'rmdir .' worked after recreating cwd"
3026 ln -s . baz || error "'ln -s .' failed after recreating cwd"
3027 cd .. || error "'cd ..' failed after recreating cwd"
3029 run_test 48a "Access renamed working dir (should return errors)="
3031 test_48b() { # bug 2399
3032 check_kernel_version 34 || return 0
3035 rmdir $DIR/d48b || error "remove cwd $DIR/d48b failed"
3036 touch foo && error "'touch foo' worked after removing cwd"
3037 mkdir foo && error "'mkdir foo' worked after removing cwd"
3038 if check_kernel_version 44; then
3039 touch .foo && error "'touch .foo' worked after removing cwd"
3040 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
3042 ls . > /dev/null && error "'ls .' worked after removing cwd"
3043 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3044 is_patchless || ( cd . && error "'cd .' worked after removing cwd" )
3045 mkdir . && error "'mkdir .' worked after removing cwd"
3046 rmdir . && error "'rmdir .' worked after removing cwd"
3047 ln -s . foo && error "'ln -s .' worked after removing cwd"
3048 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
3050 run_test 48b "Access removed working dir (should return errors)="
3052 test_48c() { # bug 2350
3053 check_kernel_version 36 || return 0
3054 #lctl set_param debug=-1
3056 mkdir -p $DIR/d48c/dir
3058 $TRACE rmdir $DIR/d48c/dir || error "remove cwd $DIR/d48c/dir failed"
3059 $TRACE touch foo && error "'touch foo' worked after removing cwd"
3060 $TRACE mkdir foo && error "'mkdir foo' worked after removing cwd"
3061 if check_kernel_version 44; then
3062 touch .foo && error "'touch .foo' worked after removing cwd"
3063 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
3065 $TRACE ls . && error "'ls .' worked after removing cwd"
3066 $TRACE ls .. || error "'ls ..' failed after removing cwd"
3067 is_patchless || ( $TRACE cd . && error "'cd .' worked after removing cwd" )
3068 $TRACE mkdir . && error "'mkdir .' worked after removing cwd"
3069 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
3070 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
3071 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
3073 run_test 48c "Access removed working subdir (should return errors)"
3075 test_48d() { # bug 2350
3076 check_kernel_version 36 || return 0
3077 #lctl set_param debug=-1
3079 mkdir -p $DIR/d48d/dir
3081 $TRACE rmdir $DIR/d48d/dir || error "remove cwd $DIR/d48d/dir failed"
3082 $TRACE rmdir $DIR/d48d || error "remove parent $DIR/d48d failed"
3083 $TRACE touch foo && error "'touch foo' worked after removing parent"
3084 $TRACE mkdir foo && error "'mkdir foo' worked after removing parent"
3085 if check_kernel_version 44; then
3086 touch .foo && error "'touch .foo' worked after removing parent"
3087 mkdir .foo && error "'mkdir .foo' worked after removing parent"
3089 $TRACE ls . && error "'ls .' worked after removing parent"
3090 $TRACE ls .. && error "'ls ..' worked after removing parent"
3091 is_patchless || ( $TRACE cd . && error "'cd .' worked after recreate parent" )
3092 $TRACE mkdir . && error "'mkdir .' worked after removing parent"
3093 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
3094 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
3095 is_patchless || ( $TRACE cd .. && error "'cd ..' worked after removing parent" || true )
3097 run_test 48d "Access removed parent subdir (should return errors)"
3099 test_48e() { # bug 4134
3100 check_kernel_version 41 || return 0
3101 #lctl set_param debug=-1
3103 mkdir -p $DIR/d48e/dir
3105 $TRACE rmdir $DIR/d48e/dir || error "remove cwd $DIR/d48e/dir failed"
3106 $TRACE rmdir $DIR/d48e || error "remove parent $DIR/d48e failed"
3107 $TRACE touch $DIR/d48e || error "'touch $DIR/d48e' failed"
3108 $TRACE chmod +x $DIR/d48e || error "'chmod +x $DIR/d48e' failed"
3109 # On a buggy kernel addition of "touch foo" after cd .. will
3110 # produce kernel oops in lookup_hash_it
3111 touch ../foo && error "'cd ..' worked after recreate parent"
3113 $TRACE rm $DIR/d48e || error "rm '$DIR/d48e' failed"
3115 run_test 48e "Access to recreated parent subdir (should return errors)"
3117 test_49() { # LU-1030
3118 # get ost1 size - lustre-OST0000
3119 ost1_size=$(do_facet ost1 lfs df |grep ${ost1_svc} |awk '{print $4}')
3120 # write 800M at maximum
3121 [ $ost1_size -gt 819200 ] && ost1_size=819200
3123 lfs setstripe -c 1 -i 0 $DIR/$tfile
3124 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
3127 # change max_pages_per_rpc while writing the file
3128 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
3129 local orig_mppc=`$LCTL get_param -n $osc1_mppc`
3130 # loop until dd process exits
3131 while ps ax -opid | grep -wq $dd_pid; do
3132 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
3133 sleep $((RANDOM % 5 + 1))
3135 # restore original max_pages_per_rpc
3136 $LCTL set_param $osc1_mppc=$orig_mppc
3137 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
3139 run_test 49 "Change max_pages_per_rpc won't break osc extent"
3145 ls /proc/$$/cwd || error
3147 run_test 50 "special situations: /proc symlinks ==============="
3149 test_51a() { # was test_51
3150 # bug 1516 - create an empty entry right after ".." then split dir
3153 $MCREATE $DIR/d51/bar
3155 createmany -m $DIR/d51/longfile 201
3157 while [ `ls -sd $DIR/d51 | awk '{ print $1 }'` -eq 4 ]; do
3158 $MCREATE $DIR/d51/longfile$FNUM
3163 ls -l $DIR/d51 > /dev/null || error
3165 run_test 51a "special situations: split htree with empty entry =="
3167 export NUMTEST=70000
3169 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
3170 [ $NUMFREE -lt 21000 ] && \
3171 skip "not enough free inodes ($NUMFREE)" && \
3174 [ $NUMFREE -lt $NUMTEST ] && NUMTEST=$(($NUMFREE - 50))
3177 createmany -d $DIR/d51b/t- $NUMTEST
3179 run_test 51b "mkdir .../t-0 --- .../t-$NUMTEST ===================="
3181 test_51ba() { # LU-993
3182 local BASE=$DIR/d51b
3183 # unlink all but 100 subdirectories, then check it still works
3185 local DELETE=$((NUMTEST - LEFT))
3187 # continue on to run this test even if 51b didn't finish,
3188 # just to delete the many subdirectories created.
3189 ! [ -d "${BASE}/t-1" ] && skip "test_51b() not run" && return 0
3191 # for ldiskfs the nlink count should be 1, but this is OSD specific
3192 # and so this is listed for informational purposes only
3193 log "nlink before: $(stat -c %h $BASE)"
3194 unlinkmany -d $BASE/t- $DELETE ||
3195 error "unlink of first $DELETE subdirs failed"
3197 log "nlink between: $(stat -c %h $BASE)"
3198 local FOUND=$(ls -l ${BASE} | wc -l)
3199 FOUND=$((FOUND - 1)) # trim the first line of ls output
3200 [ $FOUND -ne $LEFT ] &&
3201 error "can't find subdirs: found only $FOUND/$LEFT"
3203 unlinkmany -d $BASE/t- $DELETE $LEFT ||
3204 error "unlink of second $LEFT subdirs failed"
3205 log "nlink after: $(stat -c %h $BASE)"
3207 run_test 51ba "rmdir .../t-0 --- .../t-$NUMTEST"
3210 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3212 local ndirs=${TEST51BB_NDIRS:-10}
3213 local nfiles=${TEST51BB_NFILES:-100}
3215 local numfree=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
3217 [ $numfree -lt $(( ndirs * nfiles)) ] && \
3218 nfiles=$(( numfree / ndirs - 10 ))
3220 local dir=$DIR/d51bb
3222 local savePOLICY=$(lctl get_param -n lmv.*.placement)
3223 lctl set_param -n lmv.*.placement=CHAR
3226 local IUSED=$(lfs df -i $dir | grep MDT | awk '{print $3}')
3230 for ((i=0; i < $ndirs; i++)); do
3231 dirs[i]=$dir/$RANDOM
3232 echo Creating directory ${dirs[i]}
3235 echo Creating $nfiles in dir ${dirs[i]} ...
3236 echo "createmany -o ${dirs[i]}/$tfile- $nfiles"
3237 createmany -o ${dirs[i]}/$tfile- $nfiles
3243 IUSED=$(lfs df -i $dir | grep MDT | awk '{print $3}')
3247 for ((i=0; i<${#NEWUSED[@]}; i++)); do
3248 echo "mds $i: inodes count OLD ${OLDUSED[$i]} NEW ${NEWUSED[$i]}"
3249 [ ${OLDUSED[$i]} -lt ${NEWUSED[$i]} ] || rc=$((rc + 1))
3252 lctl set_param -n lmv.*.placement=$savePOLICY
3254 [ $rc -ne $MDSCOUNT ] || \
3255 error "Objects/inodes are not distributed over all mds servers"
3257 run_test 51bb "mkdir createmany CMD $MDSCOUNT ===================="
3260 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping test with few OSTs" && return
3262 createmany -o $DIR/d51d/t- 1000
3263 $GETSTRIPE $DIR/d51d > $TMP/files
3264 for N in `seq 0 $((OSTCOUNT - 1))`; do
3265 OBJS[$N]=`awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}' $TMP/files`
3266 OBJS0[$N]=`grep -A 1 idx $TMP/files | awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}'`
3267 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
3269 unlinkmany $DIR/d51d/t- 1000
3272 for N in `seq 1 $((OSTCOUNT - 1))`; do
3273 [ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ] && \
3274 error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
3275 [ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ] && \
3276 error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
3278 [ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ] && \
3279 error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
3280 [ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ] && \
3281 error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
3285 run_test 51d "check object distribution ===================="
3288 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
3291 chattr +a $DIR/d52a/foo || error "chattr +a failed"
3292 echo bar >> $DIR/d52a/foo || error "append bar failed"
3293 cp /etc/hosts $DIR/d52a/foo && error "cp worked"
3294 rm -f $DIR/d52a/foo 2>/dev/null && error "rm worked"
3295 link $DIR/d52a/foo $DIR/d52a/foo_link 2>/dev/null && error "link worked"
3296 echo foo >> $DIR/d52a/foo || error "append foo failed"
3297 mrename $DIR/d52a/foo $DIR/d52a/foo_ren && error "rename worked"
3298 lsattr $DIR/d52a/foo | egrep -q "^-+a[-e]+ $DIR/d52a/foo" || error "lsattr"
3299 chattr -a $DIR/d52a/foo || error "chattr -a failed"
3300 cp -r $DIR/d52a /tmp/
3301 rm -fr $DIR/d52a || error "cleanup rm failed"
3303 run_test 52a "append-only flag test (should return errors) ====="
3306 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
3309 chattr +i $DIR/d52b/foo || error "chattr +i failed"
3310 cat test > $DIR/d52b/foo && error "cat test worked"
3311 cp /etc/hosts $DIR/d52b/foo && error "cp worked"
3312 rm -f $DIR/d52b/foo 2>/dev/null && error "rm worked"
3313 link $DIR/d52b/foo $DIR/d52b/foo_link 2>/dev/null && error "link worked"
3314 echo foo >> $DIR/d52b/foo && error "echo worked"
3315 mrename $DIR/d52b/foo $DIR/d52b/foo_ren && error "rename worked"
3316 [ -f $DIR/d52b/foo ] || error
3317 [ -f $DIR/d52b/foo_ren ] && error
3318 lsattr $DIR/d52b/foo | egrep -q "^-+i[-e]+ $DIR/d52b/foo" || error "lsattr"
3319 chattr -i $DIR/d52b/foo || error "chattr failed"
3321 rm -fr $DIR/d52b || error
3323 run_test 52b "immutable flag test (should return errors) ======="
3326 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3327 remote_ost_nodsh && skip "remote OST with nodsh" && return
3336 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
3337 for value in $(do_facet $SINGLEMDS lctl get_param osc.$mdtosc.prealloc_last_id) ; do
3338 param=`echo ${value[0]} | cut -d "=" -f1`
3339 ostname=`echo $param | cut -d "." -f2 | cut -d - -f 1-2`
3340 mds_last=$(do_facet $SINGLEMDS lctl get_param -n $param)
3341 ostnum=$(echo $ostname | sed "s/${FSNAME}-OST//g" | awk '{print ($1+1)}' )
3342 ost_last=$(do_facet ost$ostnum lctl get_param -n obdfilter.$ostname.last_id | head -n 1)
3343 echo "$ostname.last_id=$ost_last ; MDS.last_id=$mds_last"
3344 if [ $ost_last != $mds_last ]; then
3345 error "$ostname.last_id=$ost_last ; MDS.last_id=$mds_last"
3349 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
3352 [ ! -f "$SOCKETSERVER" ] && skip_env "no socketserver, skipping" && return
3353 [ ! -f "$SOCKETCLIENT" ] && skip_env "no socketclient, skipping" && return
3354 $SOCKETSERVER $DIR/socket
3355 $SOCKETCLIENT $DIR/socket || error
3356 $MUNLINK $DIR/socket
3358 run_test 54a "unix domain socket test =========================="
3364 dd if=/dev/zero of=$f bs=`page_size` count=1
3366 run_test 54b "char device works in lustre ======================"
3369 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
3370 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
3371 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
3373 for i in `seq 3 7`; do
3374 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
3384 loopdev="$DIR/loop54c"
3387 [ -z "$LOOPNUM" ] && echo "couldn't find empty loop device" && return
3388 mknod $loopdev b 7 $LOOPNUM
3389 echo "make a loop file system with $tfile on $loopdev ($LOOPNUM)..."
3390 dd if=/dev/zero of=$tfile bs=`page_size` seek=1024 count=1 > /dev/null
3391 losetup $loopdev $tfile || error "can't set up $loopdev for $tfile"
3392 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
3394 mount -t ext2 $loopdev $tdir || error "error mounting $loopdev on $tdir"
3395 dd if=/dev/zero of=$tdir/tmp bs=`page_size` count=30 || error "dd write"
3397 dd if=$tdir/tmp of=/dev/zero bs=`page_size` count=30 || error "dd read"
3402 run_test 54c "block device works in lustre ====================="
3408 [ "$string" = `echo $string > $f | cat $f` ] || error
3410 run_test 54d "fifo device works in lustre ======================"
3413 check_kernel_version 46 || return 0
3416 cp -aL /dev/console $f
3417 echo $string > $f || error
3419 run_test 54e "console/tty device works in lustre ======================"
3421 #The test_55 used to be iopen test and it was removed by bz#24037.
3422 #run_test 55 "check iopen_connect_dentry() ======================"
3424 test_56a() { # was test_56