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
511 # create a long symlink file
512 for ((i = 0; i < 4; ++i)); do
513 long_sym=${long_sym}${long_sym}
516 echo "create 512 short and long symlink files under $WDIR"
517 for ((i = 0; i < 256; ++i)); do
518 ln -sf ${long_sym}"a5a5" $WDIR/long-$i
519 ln -sf ${short_sym}"a5a5" $WDIR/short-$i
527 echo "recreate the 512 symlink files with a shorter string"
528 for ((i = 0; i < 512; ++i)); do
529 # rewrite the symlink file with a shorter string
530 ln -sf ${long_sym} $WDIR/long-$i
531 ln -sf ${short_sym} $WDIR/short-$i
534 mds_index=$($LFS getstripe -M $WDIR)
535 mds_index=$((mds_index+1))
536 devname=$(mdsdevname $mds_index)
537 cmd="$E2FSCK -fnvd $devname"
539 echo "stop and checking mds${mds_index}: $cmd"
540 # e2fsck should not return error
541 stop mds${mds_index} -f
542 do_facet mds${mds_index} $cmd || rc=$?
544 start mds${mds_index} $devname $MDS_MOUNT_OPTS
545 df $MOUNT > /dev/null 2>&1
546 [ $rc -ne 0 ] && error "e2fsck should not report error upon "\
547 "short/long symlink MDT: rc=$rc"
550 run_test 17m "run e2fsck against MDT which contains short/long symlink"
556 run_test 18 "touch .../f ; ls ... =============================="
562 $CHECKSTAT -a $DIR/f19 || error
564 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
567 ls -l $DIR/f19 && error || true
569 run_test 19b "ls -l .../f19 (should return error) =============="
572 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
573 $RUNAS touch $DIR/f19 && error || true
575 run_test 19c "$RUNAS touch .../f19 (should return error) =="
578 cat $DIR/f19 && error || true
580 run_test 19d "cat .../f19 (should return error) =============="
592 $CHECKSTAT -a $DIR/f || error
594 run_test 20 "touch .../f ; ls -l ... ==========================="
598 [ -f $DIR/d21/dangle ] && rm -f $DIR/d21/dangle
599 ln -s dangle $DIR/d21/link
600 echo foo >> $DIR/d21/link
602 $CHECKSTAT -t link $DIR/d21/link || error
603 $CHECKSTAT -f -t file $DIR/d21/link || error
605 run_test 21 "write to dangling link ============================"
610 chown $RUNAS_ID:$RUNAS_GID $WDIR
611 (cd $WDIR || error "cd $WDIR failed";
612 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
614 ls -lR $WDIR/etc || error "ls -lR $WDIR/etc failed"
615 $CHECKSTAT -t dir $WDIR/etc || error "checkstat -t dir failed"
616 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $WDIR/etc || error "checkstat -u failed"
618 run_test 22 "unpack tar archive as non-root user ==============="
623 local file=$DIR/$tdir/$tfile
625 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
626 openfile -f O_CREAT:O_EXCL $file &&
627 error "$file recreate succeeded" || true
629 run_test 23a "O_CREAT|O_EXCL in subdir =========================="
631 test_23b() { # bug 18988
633 local file=$DIR/$tdir/$tfile
636 echo foo > $file || error "write filed"
637 echo bar >> $file || error "append filed"
638 $CHECKSTAT -s 8 $file || error "wrong size"
641 run_test 23b "O_APPEND check =========================="
644 echo '== rename sanity =============================================='
645 echo '-- same directory rename'
648 mv $DIR/R1/f $DIR/R1/g
649 $CHECKSTAT -t file $DIR/R1/g || error
651 run_test 24a "touch .../R1/f; rename .../R1/f .../R1/g ========="
656 mv $DIR/R2/f $DIR/R2/g
657 $CHECKSTAT -a $DIR/R2/f || error
658 $CHECKSTAT -t file $DIR/R2/g || error
660 run_test 24b "touch .../R2/{f,g}; rename .../R2/f .../R2/g ====="
665 mv $DIR/R3/f $DIR/R3/g
666 $CHECKSTAT -a $DIR/R3/f || error
667 $CHECKSTAT -t dir $DIR/R3/g || error
669 run_test 24c "mkdir .../R3/f; rename .../R3/f .../R3/g ========="
674 mrename $DIR/R4/f $DIR/R4/g
675 $CHECKSTAT -a $DIR/R4/f || error
676 $CHECKSTAT -t dir $DIR/R4/g || error
678 run_test 24d "mkdir .../R4/{f,g}; rename .../R4/f .../R4/g ====="
681 echo '-- cross directory renames --'
684 mv $DIR/R5a/f $DIR/R5b/g
685 $CHECKSTAT -a $DIR/R5a/f || error
686 $CHECKSTAT -t file $DIR/R5b/g || error
688 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
692 touch $DIR/R6a/f $DIR/R6b/g
693 mv $DIR/R6a/f $DIR/R6b/g
694 $CHECKSTAT -a $DIR/R6a/f || error
695 $CHECKSTAT -t file $DIR/R6b/g || error
697 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
702 mv $DIR/R7a/d $DIR/R7b/e
703 $CHECKSTAT -a $DIR/R7a/d || error
704 $CHECKSTAT -t dir $DIR/R7b/e || error
706 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
710 mkdir $DIR/R8a/d $DIR/R8b/e
711 mrename $DIR/R8a/d $DIR/R8b/e
712 $CHECKSTAT -a $DIR/R8a/d || error
713 $CHECKSTAT -t dir $DIR/R8b/e || error
715 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
718 echo "-- rename error cases"
722 mrename $DIR/R9/f $DIR/R9/a
723 $CHECKSTAT -t file $DIR/R9/f || error
724 $CHECKSTAT -t dir $DIR/R9/a || error
725 $CHECKSTAT -a $DIR/R9/a/f || error
727 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
731 mrename $DIR/R10/f $DIR/R10/g
732 $CHECKSTAT -t dir $DIR/R10 || error
733 $CHECKSTAT -a $DIR/R10/f || error
734 $CHECKSTAT -a $DIR/R10/g || error
736 run_test 24j "source does not exist ============================"
739 mkdir $DIR/R11a $DIR/R11a/d
741 mv $DIR/R11a/f $DIR/R11a/d
742 $CHECKSTAT -a $DIR/R11a/f || error
743 $CHECKSTAT -t file $DIR/R11a/d/f || error
745 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
747 # bug 2429 - rename foo foo foo creates invalid file
750 $MULTIOP $f OcNs || error
752 run_test 24l "Renaming a file to itself ========================"
756 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
757 # on ext3 this does not remove either the source or target files
758 # though the "expected" operation would be to remove the source
759 $CHECKSTAT -t file ${f} || error "${f} missing"
760 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
762 run_test 24m "Renaming a file to a hard link to itself ========="
766 # this stats the old file after it was renamed, so it should fail
770 $CHECKSTAT ${f}.rename
773 run_test 24n "Statting the old file after renaming (Posix rename 2)"
776 check_kernel_version 37 || return 0
778 rename_many -s random -v -n 10 $DIR/d24o
780 run_test 24o "rename of files during htree split ==============="
784 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
785 mrename $DIR/R12a $DIR/R12b
786 $CHECKSTAT -a $DIR/R12a || error
787 $CHECKSTAT -t dir $DIR/R12b || error
788 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
789 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
791 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
795 DIRINO=`ls -lid $DIR/R13a | awk '{ print $1 }'`
796 multiop_bg_pause $DIR/R13b D_c || return 1
799 mrename $DIR/R13a $DIR/R13b
800 $CHECKSTAT -a $DIR/R13a || error
801 $CHECKSTAT -t dir $DIR/R13b || error
802 DIRINO2=`ls -lid $DIR/R13b | awk '{ print $1 }'`
803 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
805 wait $MULTIPID || error "multiop close failed"
807 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
809 test_24r() { #bug 3789
810 mkdir $DIR/R14a $DIR/R14a/b
811 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
812 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
813 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
815 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
818 mkdir $DIR/R15a $DIR/R15a/b $DIR/R15a/b/c
819 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
820 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
821 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
823 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
825 mkdir $DIR/R16a $DIR/R16a/b $DIR/R16a/b/c
826 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
827 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
828 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
830 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
832 test_24u() { # bug12192
833 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error
834 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
836 run_test 24u "create stripe file"
844 local FREE_INODES=`lfs df -i|grep "filesystem summary" | awk '{print $5}'`
845 [ $FREE_INODES -lt $NRFILES ] && \
846 skip "not enough free inodes $FREE_INODES required $NRFILES" && \
850 createmany -m $DIR/d24v/$tfile $NRFILES
853 lctl set_param mdc.*.stats clear
855 ls $DIR/d24v >/dev/null || error "error in listing large dir"
858 # DIRENT_SIZE = 32 bytes for sizeof(struct lu_dirent) +
859 # 8 bytes for name(filename is mostly 5 in this test) +
860 # 8 bytes for luda_type
861 # take into account of overhead in lu_dirpage header and end mark in
862 # each page, plus one in RPC_NUM calculation.
864 RPC_SIZE=$(($(lctl get_param -n mdc.*.max_pages_per_rpc)*$(page_size)))
865 RPC_NUM=$(((NRFILES * DIRENT_SIZE + RPC_SIZE - 1) / RPC_SIZE + 1))
866 mds_readpage=`lctl get_param mdc.*.stats | \
867 awk '/^mds_readpage/ {print $2}'`
868 [ $mds_readpage -gt $RPC_NUM ] && \
869 error "large readdir doesn't take effect"
873 run_test 24v "list directory with large files (handle hash collision, bug: 17560)"
875 test_24w() { # bug21506
877 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
878 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
879 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
880 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
881 [ "$SZ1" = "$SZ2" ] || \
882 error "Error reading at the end of the file $tfile"
884 run_test 24w "Reading a file larger than 4Gb"
887 echo '== symlink sanity ============================================='
891 touch $DIR/s25/foo || error
893 run_test 25a "create file in symlinked directory ==============="
896 [ ! -d $DIR/d25 ] && test_25a
897 $CHECKSTAT -t file $DIR/s25/foo || error
899 run_test 25b "lookup file in symlinked directory ==============="
904 ln -s d26/d26-2 $DIR/s26
905 touch $DIR/s26/foo || error
907 run_test 26a "multiple component symlink ======================="
910 mkdir -p $DIR/d26b/d26-2
911 ln -s d26b/d26-2/foo $DIR/s26-2
912 touch $DIR/s26-2 || error
914 run_test 26b "multiple component symlink at end of lookup ======"
919 ln -s d26.2 $DIR/s26.2-1
920 ln -s s26.2-1 $DIR/s26.2-2
921 ln -s s26.2-2 $DIR/s26.2-3
922 chmod 0666 $DIR/s26.2-3/foo
924 run_test 26c "chain of symlinks ================================"
926 # recursive symlinks (bug 439)
928 ln -s d26-3/foo $DIR/d26-3
930 run_test 26d "create multiple component recursive symlink ======"
933 [ ! -h $DIR/d26-3 ] && test_26d
936 run_test 26e "unlink multiple component recursive symlink ======"
938 # recursive symlinks (bug 7022)
941 mkdir $DIR/$tdir/$tfile || error "mkdir $DIR/$tdir/$tfile failed"
942 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
943 mkdir -p lndir/bar1 || error "mkdir lndir/bar1 failed"
944 mkdir $tfile || error "mkdir $tfile failed"
945 cd $tfile || error "cd $tfile failed"
946 ln -s .. dotdot || error "ln dotdot failed"
947 ln -s dotdot/lndir lndir || error "ln lndir failed"
948 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
949 output=`ls $tfile/$tfile/lndir/bar1`
950 [ "$output" = bar1 ] && error "unexpected output"
951 rm -r $tfile || error "rm $tfile failed"
952 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
954 run_test 26f "rm -r of a directory which has recursive symlink ="
957 echo '== stripe sanity =============================================='
958 mkdir -p $DIR/d27 || error "mkdir failed"
960 $SETSTRIPE -c 1 $DIR/d27/f0 || error "setstripe failed"
961 $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
963 log "== test_27a: write to one stripe file ========================="
964 cp /etc/hosts $DIR/d27/f0 || error
966 run_test 27a "one stripe file =================================="
969 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
971 $SETSTRIPE -c 2 $DIR/d27/f01 || error "setstripe failed"
972 $GETSTRIPE -c $DIR/d27/f01
973 [ $($GETSTRIPE -c $DIR/d27/f01) -eq 2 ] ||
974 error "two-stripe file doesn't have two stripes"
976 run_test 27b "create two stripe file"
979 [ -f $DIR/d27/f01 ] || skip "test_27b not run" && return
981 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
983 run_test 27c "write to two stripe file"
987 $SETSTRIPE -c 0 -i -1 -S 0 $DIR/d27/fdef || error "setstripe failed"
988 $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
989 dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
991 run_test 27d "create file with default settings ================"
995 $SETSTRIPE -c 2 $DIR/d27/f12 || error "setstripe failed"
996 $SETSTRIPE -c 2 $DIR/d27/f12 && error "setstripe succeeded twice"
997 $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
999 run_test 27e "setstripe existing file (should return error) ======"
1003 $SETSTRIPE -S 100 -i 0 -c 1 $DIR/d27/fbad && error "setstripe failed"
1004 dd if=/dev/zero of=$DIR/d27/f12 bs=4k count=4 || error "dd failed"
1005 $GETSTRIPE $DIR/d27/fbad || error "$GETSTRIPE failed"
1007 run_test 27f "setstripe with bad stripe size (should return error)"
1011 $MCREATE $DIR/d27/fnone || error "mcreate failed"
1012 $GETSTRIPE $DIR/d27/fnone 2>&1 | grep "no stripe info" ||
1013 error "$DIR/d27/fnone has object"
1015 run_test 27g "$GETSTRIPE with no objects"
1018 touch $DIR/d27/fsome || error "touch failed"
1019 [ $($GETSTRIPE -c $DIR/d27/fsome) -gt 0 ] || error "missing objects"
1021 run_test 27i "$GETSTRIPE with some objects"
1025 $SETSTRIPE -i $OSTCOUNT $DIR/d27/f27j && error "setstripe failed"||true
1027 run_test 27j "setstripe with bad stripe offset (should return error)"
1029 test_27k() { # bug 2844
1032 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
1033 [ ! -d $DIR/d27 ] && mkdir -p $DIR/d27
1034 $SETSTRIPE -S 67108864 $FILE || error "setstripe failed"
1035 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1036 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
1037 dd if=/dev/zero of=$FILE bs=4k count=1
1038 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1039 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
1041 run_test 27k "limit i_blksize for broken user apps ============="
1045 mcreate $DIR/f27l || error "creating file"
1046 $RUNAS $SETSTRIPE -c 1 $DIR/f27l && \
1047 error "setstripe should have failed" || true
1049 run_test 27l "check setstripe permissions (should return error)"
1052 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1053 if [ $ORIGFREE -gt $MAXFREE ]; then
1054 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1058 $SETSTRIPE -i 0 -c 1 $DIR/d27/f27m_1
1059 dd if=/dev/zero of=$DIR/d27/f27m_1 bs=1024 count=$MAXFREE &&
1060 error "dd should fill OST0"
1062 while $SETSTRIPE -i 0 -c 1 $DIR/d27/f27m_$i; do
1064 [ $i -gt 256 ] && break
1067 touch $DIR/d27/f27m_$i
1068 [ `$GETSTRIPE $DIR/d27/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] && \
1069 error "OST0 was full but new created file still use it"
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"
1077 run_test 27m "create file while OST0 was full =================="
1080 local DELAY=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage | head -n 1 | awk '{print $1 * 2}')
1084 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1085 # if the OST isn't full anymore.
1087 local OSTIDX=${1:-""}
1089 local list=$(comma_list $(osts_nodes))
1090 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1092 do_nodes $list lctl set_param fail_loc=0
1093 sync # initiate all OST_DESTROYs from MDS to OST
1097 exhaust_precreations() {
1100 local FAILIDX=${3:-$OSTIDX}
1103 local MDSIDX=$(get_mds_dir "$DIR/$tdir")
1104 echo OSTIDX=$OSTIDX MDSIDX=$MDSIDX
1106 local OST=$(ostname_from_index $OSTIDX)
1107 local MDT_INDEX=$(lfs df | grep "\[MDT:$((MDSIDX - 1))\]" | awk '{print $1}' | \
1108 sed -e 's/_UUID$//;s/^.*-//')
1111 local mdtosc_proc1=$(get_mdtosc_proc_path mds${MDSIDX} $OST)
1112 local last_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1113 osc.$mdtosc_proc1.prealloc_last_id)
1114 local next_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1115 osc.$mdtosc_proc1.prealloc_next_id)
1117 local mdtosc_proc2=$(get_mdtosc_proc_path mds${MDSIDX})
1118 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1120 mkdir -p $DIR/$tdir/${OST}
1121 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1122 #define OBD_FAIL_OST_ENOSPC 0x215
1123 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=$FAILIDX
1124 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x215
1125 echo "Creating to objid $last_id on ost $OST..."
1126 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1127 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1128 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=$FAILLOC
1132 exhaust_all_precreations() {
1134 for (( i=0; i < OSTCOUNT; i++ )) ; do
1135 exhaust_precreations $i $1 -1
1140 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1141 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1142 remote_ost_nodsh && skip "remote OST with nodsh" && return
1145 rm -f $DIR/$tdir/$tfile
1146 exhaust_precreations 0 0x80000215
1147 $SETSTRIPE -c -1 $DIR/$tdir
1148 touch $DIR/$tdir/$tfile || error
1149 $GETSTRIPE $DIR/$tdir/$tfile
1152 run_test 27n "create file with some full OSTs =================="
1155 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1156 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1157 remote_ost_nodsh && skip "remote OST with nodsh" && return
1160 rm -f $DIR/$tdir/$tfile
1161 exhaust_all_precreations 0x215
1163 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1168 run_test 27o "create file with all full OSTs (should error) ===="
1171 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1172 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1173 remote_ost_nodsh && skip "remote OST with nodsh" && return
1176 rm -f $DIR/$tdir/$tfile
1179 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1180 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1181 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1183 exhaust_precreations 0 0x80000215
1184 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1185 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1186 $GETSTRIPE $DIR/$tdir/$tfile
1190 run_test 27p "append to a truncated file with some full OSTs ==="
1193 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1194 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1195 remote_ost_nodsh && skip "remote OST with nodsh" && return
1198 rm -f $DIR/$tdir/$tfile
1201 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1202 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||error "truncate $DIR/$tdir/$tfile failed"
1203 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1205 exhaust_all_precreations 0x215
1207 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1208 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1212 run_test 27q "append to truncated file with all OSTs full (should error) ==="
1215 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1216 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1217 remote_ost_nodsh && skip "remote OST with nodsh" && return
1220 rm -f $DIR/$tdir/$tfile
1221 exhaust_precreations 0 0x80000215
1223 $SETSTRIPE -i 0 -c 2 $DIR/$tdir/$tfile # && error
1227 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1229 test_27s() { # bug 10725
1231 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1232 local stripe_count=0
1233 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1234 $SETSTRIPE -S $stripe_size -c $stripe_count $DIR/$tdir &&
1235 error "stripe width >= 2^32 succeeded" || true
1238 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1240 test_27t() { # bug 10864
1245 $WLFS getstripe $tfile
1248 run_test 27t "check that utils parse path correctly"
1250 test_27u() { # bug 4900
1251 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1252 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1254 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1255 do_facet $SINGLEMDS lctl set_param fail_loc=0x139
1257 createmany -o $DIR/$tdir/t- 1000
1258 do_facet $SINGLEMDS lctl set_param fail_loc=0
1260 TLOG=$DIR/$tfile.getstripe
1261 $GETSTRIPE $DIR/$tdir > $TLOG
1262 OBJS=`awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj;}' $TLOG`
1263 unlinkmany $DIR/$tdir/t- 1000
1264 [ $OBJS -gt 0 ] && \
1265 error "$OBJS objects created on OST-0. See $TLOG" || pass
1267 run_test 27u "skip object creation on OSC w/o objects =========="
1269 test_27v() { # bug 4900
1270 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1271 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1272 remote_ost_nodsh && skip "remote OST with nodsh" && return
1274 exhaust_all_precreations 0x215
1278 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1280 touch $DIR/$tdir/$tfile
1281 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1283 for (( i=1; i < OSTCOUNT; i++ )); do
1284 do_facet ost$i lctl set_param fail_loc=0x705
1286 local START=`date +%s`
1287 createmany -o $DIR/$tdir/$tfile 32
1289 local FINISH=`date +%s`
1290 local TIMEOUT=`lctl get_param -n timeout`
1291 local PROCESS=$((FINISH - START))
1292 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1293 error "$FINISH - $START >= $TIMEOUT / 2"
1294 sleep $((TIMEOUT / 2 - PROCESS))
1297 run_test 27v "skip object creation on slow OST ================="
1299 test_27w() { # bug 10997
1300 mkdir -p $DIR/$tdir || error "mkdir failed"
1301 $SETSTRIPE -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1302 [ $($GETSTRIPE -S $DIR/$tdir/f0) -ne 65536 ] &&
1303 error "stripe size $size != 65536" || true
1304 [ $($GETSTRIPE -d $DIR/$tdir | grep -c "stripe_count") -ne 1 ] &&
1305 error "$GETSTRIPE -d $DIR/$tdir failed" || true
1307 run_test 27w "check $SETSTRIPE -S option"
1310 [ "$OSTCOUNT" -lt "2" ] &&
1311 skip_env "skipping multiple stripe count/offset test" && return
1313 mkdir -p $DIR/$tdir || error "mkdir failed"
1314 for i in $(seq 1 $OSTCOUNT); do
1316 $SETSTRIPE -c $i -i $offset $DIR/$tdir/f$i ||
1317 error "setstripe -c $i -i $offset failed"
1318 count=$($GETSTRIPE -c $DIR/$tdir/f$i)
1319 index=$($GETSTRIPE -i $DIR/$tdir/f$i)
1320 [ $count -ne $i ] && error "stripe count $count != $i" || true
1321 [ $index -ne $offset ] &&
1322 error "stripe offset $index != $offset" || true
1325 run_test 27wa "check $SETSTRIPE -c -i options"
1328 remote_ost_nodsh && skip "remote OST with nodsh" && return
1329 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs" && return
1330 OFFSET=$(($OSTCOUNT - 1))
1332 local OST=$(ostname_from_index $OSTIDX)
1335 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe per file
1336 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1338 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1339 for i in `seq 0 $OFFSET`; do
1340 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}' | grep -w "$OSTIDX"` ] &&
1341 error "OST0 was degraded but new created file still use it"
1343 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1345 run_test 27x "create files while OST0 is degraded"
1348 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1349 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1350 remote_ost_nodsh && skip "remote OST with nodsh" && return
1352 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1353 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1354 osc.$mdtosc.prealloc_last_id)
1355 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1356 osc.$mdtosc.prealloc_next_id)
1357 local fcount=$((last_id - next_id))
1358 [ $fcount -eq 0 ] && skip "not enough space on OST0" && return
1359 [ $fcount -gt $OSTCOUNT ] && fcount=$OSTCOUNT
1361 MDS_OSCS=`do_facet $SINGLEMDS lctl dl | awk '/[oO][sS][cC].*md[ts]/ { print $4 }'`
1362 OFFSET=$(($OSTCOUNT-1))
1364 for OSC in $MDS_OSCS; do
1365 if [ $OST == -1 ]; then {
1366 OST=`osc_to_ost $OSC`
1368 echo $OSC "is Deactivate:"
1369 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1373 OSTIDX=$(index_from_ostuuid $OST)
1375 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1377 do_facet ost$((OSTIDX+1)) lctl set_param -n obdfilter.$OST.degraded 1
1379 createmany -o $DIR/$tdir/$tfile $fcount
1380 do_facet ost$((OSTIDX+1)) lctl set_param -n obdfilter.$OST.degraded 0
1382 for i in `seq 0 $OFFSET`; do
1383 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "$OSTIDX"` ] || \
1384 error "files created on deactivated OSTs instead of degraded OST"
1386 for OSC in $MDS_OSCS; do
1387 [ `osc_to_ost $OSC` != $OST ] && {
1388 echo $OSC "is activate"
1389 do_facet $SINGLEMDS lctl --device %$OSC activate
1393 run_test 27y "create files while OST0 is degraded and the rest inactive"
1399 lmm_count=$($GETSTRIPE -c $1)
1400 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1401 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1403 local old_ifs="$IFS"
1405 fid=($($LFS path2fid $1))
1408 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1409 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1411 # compare lmm_seq and lu_fid->f_seq
1412 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1413 # compare lmm_object_id and lu_fid->oid
1414 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1416 # check the trusted.fid attribute of the OST objects of the file
1417 local have_obdidx=false
1419 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1420 # skip lines up to and including "obdidx"
1421 [ -z "$obdidx" ] && break
1422 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1423 $have_obdidx || continue
1425 local ost=$((obdidx + 1))
1426 local dev=$(ostdevname $ost)
1428 if [ $(facet_fstype ost$ost) != ldiskfs ]; then
1429 echo "Currently only works with ldiskfs-based OSTs"
1433 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1435 #don't unmount/remount the OSTs if we don't need to do that
1436 #local dir=$(facet_mntpt ost$ost)
1438 #do_facet ost$dev mount -t $FSTYPE $dev $dir $OST_MOUNT_OPTS ||
1439 # { error "mounting $dev as $FSTYPE failed"; return 3; }
1440 #local obj_file=$(do_facet ost$ost find $dir/O/$seq -name $oid)
1441 #local ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID $obj_file)
1443 local obj_file="O/$seq/d$((oid %32))/$oid"
1444 local ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
1445 $dev 2>/dev/null" | grep "parent=")
1447 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
1449 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
1451 #do_facet ost$ost umount -d $dir
1452 #start ost$ost $dev $OST_MOUNT_OPTS
1454 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
1455 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
1456 local ff_parent=$(echo $ff|sed -e 's/.*parent=.//')
1457 local ff_pseq=$(echo $ff_parent | cut -d: -f1)
1458 local ff_poid=$(echo $ff_parent | cut -d: -f2)
1459 local ff_pstripe=$(echo $ff_parent | sed -e 's/.*stripe=//')
1461 # compare lmm_seq and filter_fid->ff_parent.f_seq
1462 [ $ff_pseq = $lmm_seq ] ||
1463 error "FF parent SEQ $ff_pseq != $lmm_seq"
1464 # compare lmm_object_id and filter_fid->ff_parent.f_oid
1465 [ $ff_poid = $lmm_oid ] ||
1466 error "FF parent OID $ff_poid != $lmm_oid"
1467 [ $ff_pstripe = $stripe_nr ] ||
1468 error "FF stripe $ff_pstripe != $stripe_nr"
1470 stripe_nr=$((stripe_nr + 1))
1475 remote_ost_nodsh && skip "remote OST with nodsh" && return
1478 $SETSTRIPE -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
1479 { error "setstripe -c -1 failed"; return 1; }
1480 # We need to send a write to every object to get parent FID info set.
1481 # This _should_ also work for setattr, but does not currently.
1482 # touch $DIR/$tdir/$tfile-1 ||
1483 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
1484 { error "dd $tfile-1 failed"; return 2; }
1485 $SETSTRIPE -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
1486 { error "setstripe -c -1 failed"; return 3; }
1487 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
1488 { error "dd $tfile-2 failed"; return 4; }
1490 # make sure write RPCs have been sent to OSTs
1493 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
1494 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
1496 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
1498 test_27A() { # b=19102
1499 local restore_size=$($GETSTRIPE -S $MOUNT)
1500 local restore_count=$($GETSTRIPE -c $MOUNT)
1501 local restore_offset=$($GETSTRIPE -i $MOUNT)
1502 $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
1503 local default_size=$($GETSTRIPE -S $MOUNT)
1504 local default_count=$($GETSTRIPE -c $MOUNT)
1505 local default_offset=$($GETSTRIPE -i $MOUNT)
1506 local dsize=$((1024 * 1024))
1507 [ $default_size -eq $dsize ] ||
1508 error "stripe size $default_size != $dsize"
1509 [ $default_count -eq 1 ] || error "stripe count $default_count != 1"
1510 [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
1511 $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
1513 run_test 27A "check filesystem-wide default LOV EA values"
1515 # createtest also checks that device nodes are created and
1516 # then visible correctly (#2091)
1517 test_28() { # bug 2091
1519 $CREATETEST $DIR/d28/ct || error
1521 run_test 28 "create/mknod/mkdir with bad file types ============"
1524 cancel_lru_locks mdc
1530 declare -i LOCKCOUNTORIG=0
1531 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1532 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
1534 [ $LOCKCOUNTORIG -eq 0 ] && echo "No mdc lock count" && return 1
1536 declare -i LOCKUNUSEDCOUNTORIG=0
1537 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1538 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
1545 declare -i LOCKCOUNTCURRENT=0
1546 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1547 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
1550 declare -i LOCKUNUSEDCOUNTCURRENT=0
1551 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1552 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
1555 if [ "$LOCKCOUNTCURRENT" -gt "$LOCKCOUNTORIG" ]; then
1556 lctl set_param -n ldlm.dump_namespaces ""
1557 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
1558 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1559 log "dumped log to $TMP/test_29.dk (bug 5793)"
1562 if [ "$LOCKUNUSEDCOUNTCURRENT" -gt "$LOCKUNUSEDCOUNTORIG" ]; then
1563 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
1564 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1565 log "dumped log to $TMP/test_29.dk (bug 5793)"
1569 run_test 29 "IT_GETATTR regression ============================"
1571 test_30a() { # was test_30
1572 cp `which ls` $DIR || cp /bin/ls $DIR
1576 run_test 30a "execute binary from Lustre (execve) =============="
1579 cp `which ls` $DIR || cp /bin/ls $DIR
1581 $RUNAS $DIR/ls / || error
1584 run_test 30b "execute binary from Lustre as non-root ==========="
1586 test_30c() { # b=22376
1587 cp `which ls` $DIR || cp /bin/ls $DIR
1589 cancel_lru_locks mdc
1590 cancel_lru_locks osc
1591 $RUNAS $DIR/ls / || error
1594 run_test 30c "execute binary from Lustre without read perms ===="
1597 $OPENUNLINK $DIR/f31 $DIR/f31 || error
1598 $CHECKSTAT -a $DIR/f31 || error
1600 run_test 31a "open-unlink file =================================="
1603 touch $DIR/f31 || error
1604 ln $DIR/f31 $DIR/f31b || error
1605 $MULTIOP $DIR/f31b Ouc || error
1606 $CHECKSTAT -t file $DIR/f31 || error
1608 run_test 31b "unlink file with multiple links while open ======="
1611 touch $DIR/f31 || error
1612 ln $DIR/f31 $DIR/f31c || error
1613 multiop_bg_pause $DIR/f31 O_uc || return 1
1615 $MULTIOP $DIR/f31c Ouc
1616 kill -USR1 $MULTIPID
1619 run_test 31c "open-unlink file with multiple links ============="
1622 opendirunlink $DIR/d31d $DIR/d31d || error
1623 $CHECKSTAT -a $DIR/d31d || error
1625 run_test 31d "remove of open directory ========================="
1627 test_31e() { # bug 2904
1628 check_kernel_version 34 || return 0
1629 openfilleddirunlink $DIR/d31e || error
1631 run_test 31e "remove of open non-empty directory ==============="
1633 test_31f() { # bug 4554
1636 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
1637 cp /etc/hosts $DIR/d31f
1639 $GETSTRIPE $DIR/d31f/hosts
1640 multiop_bg_pause $DIR/d31f D_c || return 1
1643 rm -rv $DIR/d31f || error "first of $DIR/d31f"
1645 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
1646 cp /etc/hosts $DIR/d31f
1648 $GETSTRIPE $DIR/d31f/hosts
1649 multiop_bg_pause $DIR/d31f D_c || return 1
1652 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
1653 wait $MULTIPID || error "first opendir $MULTIPID failed"
1657 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
1658 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
1661 run_test 31f "remove of open directory with open-unlink file ==="
1664 echo "-- cross directory link --"
1665 mkdir $DIR/d31g{a,b}
1667 ln $DIR/d31ga/f $DIR/d31gb/g
1668 $CHECKSTAT -t file $DIR/d31ga/f || error "source"
1669 [ `stat -c%h $DIR/d31ga/f` == '2' ] || error "source nlink"
1670 $CHECKSTAT -t file $DIR/d31gb/g || error "target"
1671 [ `stat -c%h $DIR/d31gb/g` == '2' ] || error "target nlink"
1673 run_test 31g "cross directory link==============="
1676 echo "-- cross directory link --"
1680 ln $DIR/d31h/f $DIR/d31h/dir/g
1681 $CHECKSTAT -t file $DIR/d31h/f || error "source"
1682 [ `stat -c%h $DIR/d31h/f` == '2' ] || error "source nlink"
1683 $CHECKSTAT -t file $DIR/d31h/dir/g || error "target"
1684 [ `stat -c%h $DIR/d31h/dir/g` == '2' ] || error "target nlink"
1686 run_test 31h "cross directory link under child==============="
1689 echo "-- cross directory link --"
1692 touch $DIR/d31i/dir/f
1693 ln $DIR/d31i/dir/f $DIR/d31i/g
1694 $CHECKSTAT -t file $DIR/d31i/dir/f || error "source"
1695 [ `stat -c%h $DIR/d31i/dir/f` == '2' ] || error "source nlink"
1696 $CHECKSTAT -t file $DIR/d31i/g || error "target"
1697 [ `stat -c%h $DIR/d31i/g` == '2' ] || error "target nlink"
1699 run_test 31i "cross directory link under parent==============="
1704 mkdir $DIR/d31j/dir1
1705 ln $DIR/d31j/dir1 $DIR/d31j/dir2 && error "ln for dir"
1706 link $DIR/d31j/dir1 $DIR/d31j/dir3 && error "link for dir"
1707 mlink $DIR/d31j/dir1 $DIR/d31j/dir4 && error "mlink for dir"
1708 mlink $DIR/d31j/dir1 $DIR/d31j/dir1 && error "mlink to the same dir"
1711 run_test 31j "link for directory==============="
1717 touch $DIR/d31k/exist
1718 mlink $DIR/d31k/s $DIR/d31k/t || error "mlink"
1719 mlink $DIR/d31k/s $DIR/d31k/exist && error "mlink to exist file"
1720 mlink $DIR/d31k/s $DIR/d31k/s && error "mlink to the same file"
1721 mlink $DIR/d31k/s $DIR/d31k && error "mlink to parent dir"
1722 mlink $DIR/d31k $DIR/d31k/s && error "mlink parent dir to target"
1723 mlink $DIR/d31k/not-exist $DIR/d31k/foo && error "mlink non-existing to new"
1724 mlink $DIR/d31k/not-exist $DIR/d31k/s && error "mlink non-existing to exist"
1727 run_test 31k "link to file: the same, non-existing, dir==============="
1733 touch $DIR/d31m2/exist
1734 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
1735 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
1736 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
1737 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
1738 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
1739 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
1742 run_test 31m "link to file: the same, non-existing, dir==============="
1745 echo "== more mountpoints and symlinks ================="
1746 [ -e $DIR/d32a ] && rm -fr $DIR/d32a
1747 mkdir -p $DIR/d32a/ext2-mountpoint
1748 mount -t ext2 -o loop $EXT2_DEV $DIR/d32a/ext2-mountpoint || error
1749 $CHECKSTAT -t dir $DIR/d32a/ext2-mountpoint/.. || error
1750 $UMOUNT $DIR/d32a/ext2-mountpoint || error
1752 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
1755 [ -e $DIR/d32b ] && rm -fr $DIR/d32b
1756 mkdir -p $DIR/d32b/ext2-mountpoint
1757 mount -t ext2 -o loop $EXT2_DEV $DIR/d32b/ext2-mountpoint || error
1758 ls -al $DIR/d32b/ext2-mountpoint/.. || error
1759 $UMOUNT $DIR/d32b/ext2-mountpoint || error
1761 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
1764 [ -e $DIR/d32c ] && rm -fr $DIR/d32c
1765 mkdir -p $DIR/d32c/ext2-mountpoint
1766 mount -t ext2 -o loop $EXT2_DEV $DIR/d32c/ext2-mountpoint || error
1767 mkdir -p $DIR/d32c/d2/test_dir
1768 $CHECKSTAT -t dir $DIR/d32c/ext2-mountpoint/../d2/test_dir || error
1769 $UMOUNT $DIR/d32c/ext2-mountpoint || error
1771 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
1774 [ -e $DIR/d32d ] && rm -fr $DIR/d32d
1775 mkdir -p $DIR/d32d/ext2-mountpoint
1776 mount -t ext2 -o loop $EXT2_DEV $DIR/d32d/ext2-mountpoint || error
1777 mkdir -p $DIR/d32d/d2/test_dir
1778 ls -al $DIR/d32d/ext2-mountpoint/../d2/test_dir || error
1779 $UMOUNT $DIR/d32d/ext2-mountpoint || error
1781 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
1784 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
1785 mkdir -p $DIR/d32e/tmp
1786 TMP_DIR=$DIR/d32e/tmp
1787 ln -s $DIR/d32e $TMP_DIR/symlink11
1788 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1789 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
1790 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
1792 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
1795 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
1796 mkdir -p $DIR/d32f/tmp
1797 TMP_DIR=$DIR/d32f/tmp
1798 ln -s $DIR/d32f $TMP_DIR/symlink11
1799 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1800 ls $DIR/d32f/tmp/symlink11 || error
1801 ls $DIR/d32f/symlink01 || error
1803 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
1806 TMP_DIR=$DIR/$tdir/tmp
1807 mkdir -p $TMP_DIR $DIR/${tdir}2
1808 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
1809 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1810 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
1811 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
1812 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
1813 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
1815 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
1818 rm -fr $DIR/$tdir $DIR/${tdir}2
1819 TMP_DIR=$DIR/$tdir/tmp
1820 mkdir -p $TMP_DIR $DIR/${tdir}2
1821 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
1822 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1823 ls $TMP_DIR/symlink12 || error
1824 ls $DIR/$tdir/symlink02 || error
1826 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
1829 [ -e $DIR/d32i ] && rm -fr $DIR/d32i
1830 mkdir -p $DIR/d32i/ext2-mountpoint
1831 mount -t ext2 -o loop $EXT2_DEV $DIR/d32i/ext2-mountpoint || error
1832 touch $DIR/d32i/test_file
1833 $CHECKSTAT -t file $DIR/d32i/ext2-mountpoint/../test_file || error
1834 $UMOUNT $DIR/d32i/ext2-mountpoint || error
1836 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
1839 [ -e $DIR/d32j ] && rm -fr $DIR/d32j
1840 mkdir -p $DIR/d32j/ext2-mountpoint
1841 mount -t ext2 -o loop $EXT2_DEV $DIR/d32j/ext2-mountpoint || error
1842 touch $DIR/d32j/test_file
1843 cat $DIR/d32j/ext2-mountpoint/../test_file || error
1844 $UMOUNT $DIR/d32j/ext2-mountpoint || error
1846 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
1850 mkdir -p $DIR/d32k/ext2-mountpoint
1851 mount -t ext2 -o loop $EXT2_DEV $DIR/d32k/ext2-mountpoint
1852 mkdir -p $DIR/d32k/d2
1853 touch $DIR/d32k/d2/test_file || error
1854 $CHECKSTAT -t file $DIR/d32k/ext2-mountpoint/../d2/test_file || error
1855 $UMOUNT $DIR/d32k/ext2-mountpoint || error
1857 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
1861 mkdir -p $DIR/d32l/ext2-mountpoint
1862 mount -t ext2 -o loop $EXT2_DEV $DIR/d32l/ext2-mountpoint || error
1863 mkdir -p $DIR/d32l/d2
1864 touch $DIR/d32l/d2/test_file
1865 cat $DIR/d32l/ext2-mountpoint/../d2/test_file || error
1866 $UMOUNT $DIR/d32l/ext2-mountpoint || error
1868 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
1872 mkdir -p $DIR/d32m/tmp
1873 TMP_DIR=$DIR/d32m/tmp
1874 ln -s $DIR $TMP_DIR/symlink11
1875 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1876 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
1877 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
1879 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
1883 mkdir -p $DIR/d32n/tmp
1884 TMP_DIR=$DIR/d32n/tmp
1885 ln -s $DIR $TMP_DIR/symlink11
1886 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1887 ls -l $DIR/d32n/tmp/symlink11 || error
1888 ls -l $DIR/d32n/symlink01 || error
1890 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
1893 rm -fr $DIR/d32o $DIR/$tfile
1895 mkdir -p $DIR/d32o/tmp
1896 TMP_DIR=$DIR/d32o/tmp
1897 ln -s $DIR/$tfile $TMP_DIR/symlink12
1898 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1899 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
1900 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
1901 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
1902 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
1904 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
1914 mkdir -p $DIR/d32p/tmp
1916 TMP_DIR=$DIR/d32p/tmp
1918 ln -s $DIR/$tfile $TMP_DIR/symlink12
1920 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1922 cat $DIR/d32p/tmp/symlink12 || error
1924 cat $DIR/d32p/symlink02 || error
1927 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
1930 [ -e $DIR/d32q ] && rm -fr $DIR/d32q
1932 touch $DIR/d32q/under_the_mount
1933 mount -t ext2 -o loop $EXT2_DEV $DIR/d32q
1934 ls $DIR/d32q/under_the_mount && error || true
1935 $UMOUNT $DIR/d32q || error
1937 run_test 32q "stat follows mountpoints in Lustre (should return error)"
1940 [ -e $DIR/d32r ] && rm -fr $DIR/d32r
1942 touch $DIR/d32r/under_the_mount
1943 mount -t ext2 -o loop $EXT2_DEV $DIR/d32r
1944 ls $DIR/d32r | grep -q under_the_mount && error || true
1945 $UMOUNT $DIR/d32r || error
1947 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
1952 chmod 444 $DIR/$tfile
1953 chown $RUNAS_ID $DIR/$tfile
1955 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
1958 run_test 33 "write file with mode 444 (should return error) ===="
1963 chown $RUNAS_ID $DIR/d33
1964 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
1965 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
1966 error "open RDWR" || true
1968 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
1973 chown $RUNAS_ID $DIR/d33
1974 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33 && error "create" || true
1976 run_test 33b "test open file with malformed flags (No panic and return error)"
1984 remote_ost_nodsh && skip "remote OST with nodsh" && return
1988 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
1991 for ostnum in $(seq $OSTCOUNT); do
1992 # test-framework's OST numbering is one-based, while Lustre's
1994 ostname=$(printf "$FSNAME-OST%.4d" $((ostnum - 1)))
1995 # Parsing llobdstat's output sucks; we could grep the /proc
1996 # path, but that's likely to not be as portable as using the
1997 # llobdstat utility. So we parse lctl output instead.
1998 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
1999 obdfilter/$ostname/stats |
2000 awk '/^write_bytes/ {print $7}' )
2001 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2002 if (( ${write_bytes:-0} > 0 ))
2009 $all_zeros || return 0
2012 echo foo > $DIR/d33/bar
2016 # Total up write_bytes after writing. We'd better find non-zeros.
2017 for ostnum in $(seq $OSTCOUNT); do
2018 ostname=$(printf "$FSNAME-OST%.4d" $((ostnum - 1)))
2019 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2020 obdfilter/$ostname/stats |
2021 awk '/^write_bytes/ {print $7}' )
2022 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2023 if (( ${write_bytes:-0} > 0 ))
2032 for ostnum in $(seq $OSTCOUNT); do
2033 ostname=$(printf "$FSNAME-OST%.4d" $((ostnum - 1)))
2034 echo "Check that write_bytes is present in obdfilter/*/stats:"
2035 do_facet ost$ostnum lctl get_param -n \
2036 obdfilter/$ostname/stats
2038 error "OST not keeping write_bytes stats (b22312)"
2041 run_test 33c "test llobdstat and write_bytes"
2043 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
2046 $MCREATE $DIR/f34 || error
2047 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2048 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
2049 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2050 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2052 run_test 34a "truncate file that has not been opened ==========="
2055 [ ! -f $DIR/f34 ] && test_34a
2056 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2057 $OPENFILE -f O_RDONLY $DIR/f34
2058 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2059 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2061 run_test 34b "O_RDONLY opening file doesn't create objects ====="
2064 [ ! -f $DIR/f34 ] && test_34a
2065 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2066 $OPENFILE -f O_RDWR $DIR/f34
2067 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2068 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2070 run_test 34c "O_RDWR opening file-with-size works =============="
2073 [ ! -f $DIR/f34 ] && test_34a
2074 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2075 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2078 run_test 34d "write to sparse file ============================="
2082 $MCREATE $DIR/f34e || error
2083 $TRUNCATE $DIR/f34e 1000 || error
2084 $CHECKSTAT -s 1000 $DIR/f34e || error
2085 $OPENFILE -f O_RDWR $DIR/f34e
2086 $CHECKSTAT -s 1000 $DIR/f34e || error
2088 run_test 34e "create objects, some with size and some without =="
2090 test_34f() { # bug 6242, 6243
2093 $MCREATE $DIR/f34f || error
2094 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
2095 dd if=$DIR/f34f of=$TMP/f34f
2096 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
2097 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
2098 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
2099 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
2100 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
2102 run_test 34f "read from a file with no objects until EOF ======="
2105 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
2106 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
2107 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
2108 cancel_lru_locks osc
2109 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
2110 error "wrong size after lock cancel"
2112 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
2113 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2114 error "expanding truncate failed"
2115 cancel_lru_locks osc
2116 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2117 error "wrong expanded size after lock cancel"
2119 run_test 34g "truncate long file ==============================="
2125 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
2126 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
2130 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
2131 error "Multiop blocked on ftruncate, pid=$MULTIPID"
2135 local nsz=`stat -c %s $DIR/$tfile`
2136 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
2138 run_test 34h "ftruncate file under grouplock should not block"
2141 cp /bin/sh $DIR/f35a
2143 chown $RUNAS_ID $DIR/f35a
2144 $RUNAS $DIR/f35a && error || true
2147 run_test 35a "exec file with mode 444 (should return and not leak) ====="
2151 utime $DIR/f36 || error
2153 run_test 36a "MDS utime check (mknod, utime) ==================="
2157 utime $DIR/f36 || error
2159 run_test 36b "OST utime check (open, utime) ===================="
2164 chown $RUNAS_ID $DIR/d36
2165 $RUNAS utime $DIR/d36/f36 || error
2167 run_test 36c "non-root MDS utime check (mknod, utime) =========="
2170 [ ! -d $DIR/d36 ] && test_36c
2171 echo "" > $DIR/d36/f36
2172 $RUNAS utime $DIR/d36/f36 || error
2174 run_test 36d "non-root OST utime check (open, utime) ==========="
2177 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
2179 touch $DIR/$tdir/$tfile
2180 $RUNAS utime $DIR/$tdir/$tfile && \
2181 error "utime worked, expected failure" || true
2183 run_test 36e "utime on non-owned file (should return error) ===="
2187 local LANG_SAVE=$LANG
2188 local LC_LANG_SAVE=$LC_LANG
2189 export LANG=C LC_LANG=C # for date language
2191 DATESTR="Dec 20 2000"
2193 lctl set_param fail_loc=$fl
2195 cp /etc/hosts $DIR/$tdir/$tfile
2196 sync & # write RPC generated with "current" inode timestamp, but delayed
2198 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
2199 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
2200 cancel_lru_locks osc
2201 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
2203 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
2204 echo "BEFORE: $LS_BEFORE" && \
2205 echo "AFTER : $LS_AFTER" && \
2206 echo "WANT : $DATESTR" && \
2207 error "$DIR/$tdir/$tfile timestamps changed" || true
2209 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
2213 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2214 subr_36fh "0x80000214"
2216 run_test 36f "utime on file racing with OST BRW write =========="
2219 remote_ost_nodsh && skip "remote OST with nodsh" && return
2225 fmd_max_age=$(do_facet ost1 \
2226 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
2229 fmd_before=$(do_facet ost1 \
2230 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2231 touch $DIR/$tdir/$tfile
2232 sleep $((fmd_max_age + 12))
2233 fmd_after=$(do_facet ost1 \
2234 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2236 echo "fmd_before: $fmd_before"
2237 echo "fmd_after: $fmd_after"
2238 [ "$fmd_after" -gt "$fmd_before" ] && \
2239 echo "AFTER: $fmd_after > BEFORE: $fmd_before" && \
2240 error "fmd didn't expire after ping" || true
2242 run_test 36g "filter mod data cache expiry ====================="
2245 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
2246 subr_36fh "0x80000227"
2248 run_test 36h "utime on file racing with OST BRW write =========="
2252 echo f > $DIR/$tdir/fbugfile
2253 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2254 ls $DIR/$tdir | grep "\<fbugfile\>" && error
2255 $UMOUNT $DIR/$tdir || error
2256 rm -f $DIR/$tdir/fbugfile || error
2258 run_test 37 "ls a mounted file system to check old content ====="
2261 local file=$DIR/$tfile
2263 openfile -f O_DIRECTORY $file
2266 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
2267 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
2269 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
2273 touch $DIR/${tfile}2
2274 # ls -l $DIR/$tfile $DIR/${tfile}2
2275 # ls -lu $DIR/$tfile $DIR/${tfile}2
2276 # ls -lc $DIR/$tfile $DIR/${tfile}2
2278 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
2279 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
2281 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
2283 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
2285 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
2286 error "O_TRUNC didn't change timestamps"
2289 run_test 39 "mtime changed on create ==========================="
2293 cp -p /etc/passwd $DIR/$tdir/fopen
2294 cp -p /etc/passwd $DIR/$tdir/flink
2295 cp -p /etc/passwd $DIR/$tdir/funlink
2296 cp -p /etc/passwd $DIR/$tdir/frename
2297 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
2300 echo "aaaaaa" >> $DIR/$tdir/fopen
2301 echo "aaaaaa" >> $DIR/$tdir/flink
2302 echo "aaaaaa" >> $DIR/$tdir/funlink
2303 echo "aaaaaa" >> $DIR/$tdir/frename
2305 local open_new=`stat -c %Y $DIR/$tdir/fopen`
2306 local link_new=`stat -c %Y $DIR/$tdir/flink`
2307 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
2308 local rename_new=`stat -c %Y $DIR/$tdir/frename`
2310 cat $DIR/$tdir/fopen > /dev/null
2311 ln $DIR/$tdir/flink $DIR/$tdir/flink2
2312 rm -f $DIR/$tdir/funlink2
2313 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
2315 for (( i=0; i < 2; i++ )) ; do
2316 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
2317 local link_new2=`stat -c %Y $DIR/$tdir/flink`
2318 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
2319 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
2321 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
2322 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
2323 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
2324 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
2326 cancel_lru_locks osc
2327 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2330 run_test 39b "mtime change on open, link, unlink, rename ======"
2332 # this should be set to past
2333 TEST_39_MTIME=`date -d "1 year ago" +%s`
2339 local mtime0=`stat -c %Y $DIR1/$tfile`
2341 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2342 local mtime1=`stat -c %Y $DIR1/$tfile`
2343 [ "$mtime1" = $TEST_39_MTIME ] || \
2344 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
2347 echo hello >> $DIR1/$tfile
2349 local mtime2=`stat -c %Y $DIR1/$tfile`
2350 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
2351 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
2353 mv $DIR1/$tfile $DIR1/$tfile-1
2355 for (( i=0; i < 2; i++ )) ; do
2356 local mtime3=`stat -c %Y $DIR1/$tfile-1`
2357 [ "$mtime2" = "$mtime3" ] || \
2358 error "mtime ($mtime2) changed (to $mtime3) on rename"
2360 cancel_lru_locks osc
2361 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2364 run_test 39c "mtime change on rename ==========================="
2370 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2372 for (( i=0; i < 2; i++ )) ; do
2373 local mtime=`stat -c %Y $DIR1/$tfile`
2374 [ $mtime = $TEST_39_MTIME ] || \
2375 error "mtime($mtime) is not set to $TEST_39_MTIME"
2377 cancel_lru_locks osc
2378 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2381 run_test 39d "create, utime, stat =============================="
2386 local mtime1=`stat -c %Y $DIR1/$tfile`
2388 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2390 for (( i=0; i < 2; i++ )) ; do
2391 local mtime2=`stat -c %Y $DIR1/$tfile`
2392 [ $mtime2 = $TEST_39_MTIME ] || \
2393 error "mtime($mtime2) is not set to $TEST_39_MTIME"
2395 cancel_lru_locks osc
2396 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2399 run_test 39e "create, stat, utime, stat ========================"
2404 mtime1=`stat -c %Y $DIR1/$tfile`
2407 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2409 for (( i=0; i < 2; i++ )) ; do
2410 local mtime2=`stat -c %Y $DIR1/$tfile`
2411 [ $mtime2 = $TEST_39_MTIME ] || \
2412 error "mtime($mtime2) is not set to $TEST_39_MTIME"
2414 cancel_lru_locks osc
2415 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2418 run_test 39f "create, stat, sleep, utime, stat ================="
2422 echo hello >> $DIR1/$tfile
2423 local mtime1=`stat -c %Y $DIR1/$tfile`
2426 chmod o+r $DIR1/$tfile
2428 for (( i=0; i < 2; i++ )) ; do
2429 local mtime2=`stat -c %Y $DIR1/$tfile`
2430 [ "$mtime1" = "$mtime2" ] || \
2431 error "lost mtime: $mtime2, should be $mtime1"
2433 cancel_lru_locks osc
2434 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2437 run_test 39g "write, chmod, stat ==============================="
2445 echo hello >> $DIR1/$tfile
2446 local mtime1=`stat -c %Y $DIR1/$tfile`
2448 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2450 if [ "$d1" != "$d2" ]; then
2451 echo "write and touch not within one second"
2453 for (( i=0; i < 2; i++ )) ; do
2454 local mtime2=`stat -c %Y $DIR1/$tfile`
2455 [ "$mtime2" = $TEST_39_MTIME ] || \
2456 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
2458 cancel_lru_locks osc
2459 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2463 run_test 39h "write, utime within one second, stat ============="
2469 echo hello >> $DIR1/$tfile
2470 local mtime1=`stat -c %Y $DIR1/$tfile`
2472 mv $DIR1/$tfile $DIR1/$tfile-1
2474 for (( i=0; i < 2; i++ )) ; do
2475 local mtime2=`stat -c %Y $DIR1/$tfile-1`
2477 [ "$mtime1" = "$mtime2" ] || \
2478 error "lost mtime: $mtime2, should be $mtime1"
2480 cancel_lru_locks osc
2481 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2484 run_test 39i "write, rename, stat =============================="
2487 start_full_debug_logging
2491 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
2492 lctl set_param fail_loc=0x80000412
2493 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
2494 error "multiop failed"
2496 local mtime1=`stat -c %Y $DIR1/$tfile`
2498 mv $DIR1/$tfile $DIR1/$tfile-1
2500 kill -USR1 $multipid
2501 wait $multipid || error "multiop close failed"
2503 for (( i=0; i < 2; i++ )) ; do
2504 local mtime2=`stat -c %Y $DIR1/$tfile-1`
2505 [ "$mtime1" = "$mtime2" ] ||
2506 error "mtime is lost on close: $mtime2, " \
2509 cancel_lru_locks osc
2510 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2512 lctl set_param fail_loc=0
2513 stop_full_debug_logging
2515 run_test 39j "write, rename, close, stat ======================="
2521 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
2523 local mtime1=`stat -c %Y $DIR1/$tfile`
2525 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2527 kill -USR1 $multipid
2528 wait $multipid || error "multiop close failed"
2530 for (( i=0; i < 2; i++ )) ; do
2531 local mtime2=`stat -c %Y $DIR1/$tfile`
2533 [ "$mtime2" = $TEST_39_MTIME ] || \
2534 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
2536 cancel_lru_locks osc
2537 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2540 run_test 39k "write, utime, close, stat ========================"
2542 # this should be set to future
2543 TEST_39_ATIME=`date -d "1 year" +%s`
2545 is_sles11() # LU-1783
2547 if [ -r /etc/SuSE-release ]
2549 local vers=`grep VERSION /etc/SuSE-release | awk '{print $3}'`
2550 local patchlev=`grep PATCHLEVEL /etc/SuSE-release \
2552 if [ $vers -eq 11 ] && [ $patchlev -eq 1 ]
2561 is_sles11 && skip "SLES 11 SP1" && return # LU-1783
2562 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2563 local atime_diff=$(do_facet $SINGLEMDS lctl get_param -n mdd.*.atime_diff)
2567 # test setting directory atime to future
2568 touch -a -d @$TEST_39_ATIME $DIR/$tdir
2569 local atime=$(stat -c %X $DIR/$tdir)
2570 [ "$atime" = $TEST_39_ATIME ] || \
2571 error "atime is not set to future: $atime, should be $TEST_39_ATIME"
2573 # test setting directory atime from future to now
2574 local d1=$(date +%s)
2576 local d2=$(date +%s)
2578 cancel_lru_locks mdc
2579 atime=$(stat -c %X $DIR/$tdir)
2580 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
2581 error "atime is not updated from future: $atime, should be $d1<atime<$d2"
2583 do_facet $SINGLEMDS lctl set_param -n mdd.*.atime_diff=2
2586 # test setting directory atime when now > dir atime + atime_diff
2590 cancel_lru_locks mdc
2591 atime=$(stat -c %X $DIR/$tdir)
2592 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
2593 error "atime is not updated : $atime, should be $d2"
2595 do_facet $SINGLEMDS lctl set_param -n mdd.*.atime_diff=60
2598 # test not setting directory atime when now < dir atime + atime_diff
2600 cancel_lru_locks mdc
2601 atime=$(stat -c %X $DIR/$tdir)
2602 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
2603 error "atime is updated to $atime, should remain $d1<atime<$d2"
2605 do_facet $SINGLEMDS lctl set_param -n mdd.*.atime_diff=$atime_diff
2607 run_test 39l "directory atime update ==========================="
2612 local far_past_mtime=$(date -d "May 29 1953" +%s)
2613 local far_past_atime=$(date -d "Dec 17 1903" +%s)
2615 touch -m -d @$far_past_mtime $DIR1/$tfile
2616 touch -a -d @$far_past_atime $DIR1/$tfile
2618 for (( i=0; i < 2; i++ )) ; do
2619 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
2620 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
2621 error "atime or mtime set incorrectly"
2623 cancel_lru_locks osc
2624 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2627 run_test 39m "test atime and mtime before 1970"
2630 dd if=/dev/zero of=$DIR/f40 bs=4096 count=1
2631 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/f40 && error
2632 $CHECKSTAT -t file -s 4096 $DIR/f40 || error
2634 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
2638 small_write $DIR/f41 18
2640 run_test 41 "test small file write + fstat ====================="
2642 count_ost_writes() {
2643 lctl get_param -n osc.*.stats |
2644 awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }'
2651 BG_DIRTY_RATIO_SAVE=10
2652 MAX_BG_DIRTY_RATIO=25
2656 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
2657 # dirty_ratio, dirty_background_ratio
2658 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
2659 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
2660 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
2661 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
2663 # if file not here, we are a 2.4 kernel
2664 kill -CONT `pidof kupdated`
2669 # setup the trap first, so someone cannot exit the test at the
2670 # exact wrong time and mess up a machine
2671 trap start_writeback EXIT
2672 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
2673 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
2674 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
2675 sysctl -w vm.dirty_writeback_centisecs=0
2676 sysctl -w vm.dirty_writeback_centisecs=0
2677 # save and increase /proc/sys/vm/dirty_ratio
2678 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
2679 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
2680 # save and increase /proc/sys/vm/dirty_background_ratio
2681 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
2682 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
2684 # if file not here, we are a 2.4 kernel
2685 kill -STOP `pidof kupdated`
2689 # ensure that all stripes have some grant before we test client-side cache
2691 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
2692 dd if=/dev/zero of=$i bs=4k count=1
2697 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
2698 # file truncation, and file removal.
2701 cancel_lru_locks osc
2703 sync; sleep 1; sync # just to be safe
2704 BEFOREWRITES=`count_ost_writes`
2705 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
2706 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
2707 AFTERWRITES=`count_ost_writes`
2708 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
2709 error "$BEFOREWRITES < $AFTERWRITES"
2712 run_test 42a "ensure that we don't flush on close =============="
2716 cancel_lru_locks osc
2719 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
2720 BEFOREWRITES=`count_ost_writes`
2721 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
2722 AFTERWRITES=`count_ost_writes`
2723 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
2724 error "$BEFOREWRITES < $AFTERWRITES on unlink"
2726 BEFOREWRITES=`count_ost_writes`
2727 sync || error "sync: $?"
2728 AFTERWRITES=`count_ost_writes`
2729 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
2730 error "$BEFOREWRITES < $AFTERWRITES on sync"
2732 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
2736 run_test 42b "test destroy of file with cached dirty data ======"
2738 # if these tests just want to test the effect of truncation,
2739 # they have to be very careful. consider:
2740 # - the first open gets a {0,EOF}PR lock
2741 # - the first write conflicts and gets a {0, count-1}PW
2742 # - the rest of the writes are under {count,EOF}PW
2743 # - the open for truncate tries to match a {0,EOF}PR
2744 # for the filesize and cancels the PWs.
2745 # any number of fixes (don't get {0,EOF} on open, match
2746 # composite locks, do smarter file size management) fix
2747 # this, but for now we want these tests to verify that
2748 # the cancellation with truncate intent works, so we
2749 # start the file with a full-file pw lock to match against
2750 # until the truncate.
2755 cancel_lru_locks osc
2757 # prime the file with 0,EOF PW to match
2761 # now the real test..
2762 dd if=/dev/zero of=$file bs=1024 count=100
2763 BEFOREWRITES=`count_ost_writes`
2764 $TRUNCATE $file $offset
2765 cancel_lru_locks osc
2766 AFTERWRITES=`count_ost_writes`
2772 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
2773 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
2776 run_test 42c "test partial truncate of file with cached dirty data"
2780 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
2781 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
2784 run_test 42d "test complete truncate of file with cached dirty data"
2786 test_42e() { # bug22074
2787 local TDIR=$DIR/${tdir}e
2788 local pagesz=$(page_size)
2789 local pages=16 # hardcoded 16 pages, don't change it.
2790 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
2791 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
2796 $SETSTRIPE -c 1 $TDIR
2797 createmany -o $TDIR/f $files
2799 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
2801 # we assume that with $OSTCOUNT files, at least one of them will
2802 # be allocated on OST0.
2803 warmup_files=$((OSTCOUNT * max_dirty_mb))
2804 createmany -o $TDIR/w $warmup_files
2806 # write a large amount of data into one file and sync, to get good
2807 # avail_grant number from OST.
2808 for ((i=0; i<$warmup_files; i++)); do
2809 idx=$($GETSTRIPE -i $TDIR/w$i)
2810 [ $idx -ne 0 ] && continue
2811 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
2814 [ $i -gt $warmup_files ] && error "OST0 is still cold"
2816 $LCTL get_param $proc_osc0/cur_dirty_bytes
2817 $LCTL get_param $proc_osc0/cur_grant_bytes
2819 # create as much dirty pages as we can while not to trigger the actual
2820 # RPCs directly. but depends on the env, VFS may trigger flush during this
2821 # period, hopefully we are good.
2822 for ((i=0; i<$warmup_files; i++)); do
2823 idx=$($GETSTRIPE -i $TDIR/w$i)
2824 [ $idx -ne 0 ] && continue
2825 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
2827 $LCTL get_param $proc_osc0/cur_dirty_bytes
2828 $LCTL get_param $proc_osc0/cur_grant_bytes
2830 # perform the real test
2831 $LCTL set_param $proc_osc0/rpc_stats 0
2832 for ((;i<$files; i++)); do
2833 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
2834 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
2837 $LCTL get_param $proc_osc0/rpc_stats
2840 local have_ppr=false
2841 $LCTL get_param $proc_osc0/rpc_stats |
2842 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
2843 # skip lines until we are at the RPC histogram data
2844 [ "$PPR" == "pages" ] && have_ppr=true && continue
2845 $have_ppr || continue
2847 # we only want the percent stat for < 16 pages
2848 [ $(echo $PPR | tr -d ':') -ge $pages ] && break
2850 percent=$((percent + WPCT))
2851 if [ $percent -gt 15 ]; then
2852 error "less than 16-pages write RPCs" \
2859 run_test 42e "verify sub-RPC writes are not done synchronously"
2863 cp -p /bin/ls $DIR/$tdir/$tfile
2864 $MULTIOP $DIR/$tdir/$tfile Ow_c &
2866 # give multiop a chance to open
2869 $DIR/$tdir/$tfile && error || true
2872 run_test 43 "execution of file opened for write should return -ETXTBSY"
2876 cp -p `which $MULTIOP` $DIR/d43/multiop || cp -p multiop $DIR/d43/multiop
2877 MULTIOP_PROG=$DIR/d43/multiop multiop_bg_pause $TMP/test43.junk O_c || return 1
2879 $MULTIOP $DIR/d43/multiop Oc && error "expected error, got success"
2880 kill -USR1 $MULTIOP_PID || return 2
2881 wait $MULTIOP_PID || return 3
2884 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
2888 cp -p `which $MULTIOP` $DIR/d43/multiop || cp -p multiop $DIR/d43/multiop
2889 MULTIOP_PROG=$DIR/d43/multiop multiop_bg_pause $TMP/test43.junk O_c || return 1
2891 $TRUNCATE $DIR/d43/multiop 0 && error "expected error, got success"
2892 kill -USR1 $MULTIOP_PID || return 2
2893 wait $MULTIOP_PID || return 3
2896 run_test 43b "truncate of file being executed should return -ETXTBSY"
2899 local testdir="$DIR/d43c"
2902 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
2903 ( cd $testdir && md5sum -c)
2905 run_test 43c "md5sum of copy into lustre========================"
2908 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
2909 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
2910 dd if=$DIR/f1 bs=4k count=1 > /dev/null
2912 run_test 44 "zero length read from a sparse stripe ============="
2915 local nstripe=`$LCTL lov_getconfig $DIR | grep default_stripe_count: | \
2917 [ -z "$nstripe" ] && skip "can't get stripe info" && return
2918 [ "$nstripe" -gt "$OSTCOUNT" ] && skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" && return
2919 local stride=`$LCTL lov_getconfig $DIR | grep default_stripe_size: | \
2921 if [ $nstripe -eq 0 -o $nstripe -eq -1 ] ; then
2922 nstripe=`$LCTL lov_getconfig $DIR | grep obd_count: | awk '{print $2}'`
2925 OFFSETS="0 $((stride/2)) $((stride-1))"
2926 for offset in $OFFSETS ; do
2927 for i in `seq 0 $((nstripe-1))`; do
2928 local GLOBALOFFSETS=""
2929 local size=$((((i + 2 * $nstripe )*$stride + $offset))) # Bytes
2930 local myfn=$DIR/d44a-$size
2931 echo "--------writing $myfn at $size"
2932 ll_sparseness_write $myfn $size || error "ll_sparseness_write"
2933 GLOBALOFFSETS="$GLOBALOFFSETS $size"
2934 ll_sparseness_verify $myfn $GLOBALOFFSETS \
2935 || error "ll_sparseness_verify $GLOBALOFFSETS"
2937 for j in `seq 0 $((nstripe-1))`; do
2938 size=$((((j + $nstripe )*$stride + $offset))) # Bytes
2939 ll_sparseness_write $myfn $size || error "ll_sparseness_write"
2940 GLOBALOFFSETS="$GLOBALOFFSETS $size"
2942 ll_sparseness_verify $myfn $GLOBALOFFSETS \
2943 || error "ll_sparseness_verify $GLOBALOFFSETS"
2948 run_test 44a "test sparse pwrite ==============================="
2952 for d in `lctl get_param -n osc.*.cur_dirty_bytes`; do
2958 before=`dirty_osc_total`
2959 echo executing "\"$*\""
2961 after=`dirty_osc_total`
2962 echo before $before, after $after
2966 # Obtain grants from OST if it supports it
2967 echo blah > ${f}_grant
2970 do_dirty_record "echo blah > $f"
2971 [ $before -eq $after ] && error "write wasn't cached"
2972 do_dirty_record "> $f"
2973 [ $before -gt $after ] || error "truncate didn't lower dirty count"
2974 do_dirty_record "echo blah > $f"
2975 [ $before -eq $after ] && error "write wasn't cached"
2976 do_dirty_record "sync"
2977 [ $before -gt $after ] || error "writeback 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 "cancel_lru_locks osc"
2981 [ $before -gt $after ] || error "lock cancellation didn't lower dirty count"
2984 run_test 45 "osc io page accounting ============================"
2986 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
2987 # test tickles a bug where re-dirtying a page was failing to be mapped to the
2988 # objects offset and an assert hit when an rpc was built with 1023's mapped
2989 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
2994 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
2996 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
2997 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3001 run_test 46 "dirtying a previously written page ================"
3003 # test_47 is removed "Device nodes check" is moved to test_28
3005 test_48a() { # bug 2399
3006 check_kernel_version 34 || return 0
3009 mv $DIR/d48a $DIR/d48.new || error "move directory failed"
3010 mkdir $DIR/d48a || error "recreate directory failed"
3011 touch foo || error "'touch foo' failed after recreating cwd"
3012 mkdir bar || error "'mkdir foo' failed after recreating cwd"
3013 if check_kernel_version 44; then
3014 touch .foo || error "'touch .foo' failed after recreating cwd"
3015 mkdir .bar || error "'mkdir .foo' failed after recreating cwd"
3017 ls . > /dev/null || error "'ls .' failed after recreating cwd"
3018 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3019 cd . || error "'cd .' failed after recreating cwd"
3020 mkdir . && error "'mkdir .' worked after recreating cwd"
3021 rmdir . && error "'rmdir .' worked after recreating cwd"
3022 ln -s . baz || error "'ln -s .' failed after recreating cwd"
3023 cd .. || error "'cd ..' failed after recreating cwd"
3025 run_test 48a "Access renamed working dir (should return errors)="
3027 test_48b() { # bug 2399
3028 check_kernel_version 34 || return 0
3031 rmdir $DIR/d48b || error "remove cwd $DIR/d48b failed"
3032 touch foo && error "'touch foo' worked after removing cwd"
3033 mkdir foo && error "'mkdir foo' worked after removing cwd"
3034 if check_kernel_version 44; then
3035 touch .foo && error "'touch .foo' worked after removing cwd"
3036 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
3038 ls . > /dev/null && error "'ls .' worked after removing cwd"
3039 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3040 is_patchless || ( cd . && error "'cd .' worked after removing cwd" )
3041 mkdir . && error "'mkdir .' worked after removing cwd"
3042 rmdir . && error "'rmdir .' worked after removing cwd"
3043 ln -s . foo && error "'ln -s .' worked after removing cwd"
3044 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
3046 run_test 48b "Access removed working dir (should return errors)="
3048 test_48c() { # bug 2350
3049 check_kernel_version 36 || return 0
3050 #lctl set_param debug=-1
3052 mkdir -p $DIR/d48c/dir
3054 $TRACE rmdir $DIR/d48c/dir || error "remove cwd $DIR/d48c/dir failed"
3055 $TRACE touch foo && error "'touch foo' worked after removing cwd"
3056 $TRACE mkdir foo && error "'mkdir foo' worked after removing cwd"
3057 if check_kernel_version 44; then
3058 touch .foo && error "'touch .foo' worked after removing cwd"
3059 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
3061 $TRACE ls . && error "'ls .' worked after removing cwd"
3062 $TRACE ls .. || error "'ls ..' failed after removing cwd"
3063 is_patchless || ( $TRACE cd . && error "'cd .' worked after removing cwd" )
3064 $TRACE mkdir . && error "'mkdir .' worked after removing cwd"
3065 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
3066 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
3067 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
3069 run_test 48c "Access removed working subdir (should return errors)"
3071 test_48d() { # bug 2350
3072 check_kernel_version 36 || return 0
3073 #lctl set_param debug=-1
3075 mkdir -p $DIR/d48d/dir
3077 $TRACE rmdir $DIR/d48d/dir || error "remove cwd $DIR/d48d/dir failed"
3078 $TRACE rmdir $DIR/d48d || error "remove parent $DIR/d48d failed"
3079 $TRACE touch foo && error "'touch foo' worked after removing parent"
3080 $TRACE mkdir foo && error "'mkdir foo' worked after removing parent"
3081 if check_kernel_version 44; then
3082 touch .foo && error "'touch .foo' worked after removing parent"
3083 mkdir .foo && error "'mkdir .foo' worked after removing parent"
3085 $TRACE ls . && error "'ls .' worked after removing parent"
3086 $TRACE ls .. && error "'ls ..' worked after removing parent"
3087 is_patchless || ( $TRACE cd . && error "'cd .' worked after recreate parent" )
3088 $TRACE mkdir . && error "'mkdir .' worked after removing parent"
3089 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
3090 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
3091 is_patchless || ( $TRACE cd .. && error "'cd ..' worked after removing parent" || true )
3093 run_test 48d "Access removed parent subdir (should return errors)"
3095 test_48e() { # bug 4134
3096 check_kernel_version 41 || return 0
3097 #lctl set_param debug=-1
3099 mkdir -p $DIR/d48e/dir
3101 $TRACE rmdir $DIR/d48e/dir || error "remove cwd $DIR/d48e/dir failed"
3102 $TRACE rmdir $DIR/d48e || error "remove parent $DIR/d48e failed"
3103 $TRACE touch $DIR/d48e || error "'touch $DIR/d48e' failed"
3104 $TRACE chmod +x $DIR/d48e || error "'chmod +x $DIR/d48e' failed"
3105 # On a buggy kernel addition of "touch foo" after cd .. will
3106 # produce kernel oops in lookup_hash_it
3107 touch ../foo && error "'cd ..' worked after recreate parent"
3109 $TRACE rm $DIR/d48e || error "rm '$DIR/d48e' failed"
3111 run_test 48e "Access to recreated parent subdir (should return errors)"
3113 test_49() { # LU-1030
3114 # get ost1 size - lustre-OST0000
3115 ost1_size=$(do_facet ost1 lfs df |grep ${ost1_svc} |awk '{print $4}')
3116 # write 800M at maximum
3117 [ $ost1_size -gt 819200 ] && ost1_size=819200
3119 lfs setstripe -c 1 -i 0 $DIR/$tfile
3120 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
3123 # change max_pages_per_rpc while writing the file
3124 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
3125 local orig_mppc=`$LCTL get_param -n $osc1_mppc`
3126 # loop until dd process exits
3127 while ps ax -opid | grep -wq $dd_pid; do
3128 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
3129 sleep $((RANDOM % 5 + 1))
3131 # restore original max_pages_per_rpc
3132 $LCTL set_param $osc1_mppc=$orig_mppc
3133 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
3135 run_test 49 "Change max_pages_per_rpc won't break osc extent"
3141 ls /proc/$$/cwd || error
3143 run_test 50 "special situations: /proc symlinks ==============="
3145 test_51a() { # was test_51
3146 # bug 1516 - create an empty entry right after ".." then split dir
3149 $MCREATE $DIR/d51/bar
3151 createmany -m $DIR/d51/longfile 201
3153 while [ `ls -sd $DIR/d51 | awk '{ print $1 }'` -eq 4 ]; do
3154 $MCREATE $DIR/d51/longfile$FNUM
3159 ls -l $DIR/d51 > /dev/null || error
3161 run_test 51a "special situations: split htree with empty entry =="
3163 export NUMTEST=70000
3165 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
3166 [ $NUMFREE -lt 21000 ] && \
3167 skip "not enough free inodes ($NUMFREE)" && \
3170 [ $NUMFREE -lt $NUMTEST ] && NUMTEST=$(($NUMFREE - 50))
3173 createmany -d $DIR/d51b/t- $NUMTEST
3175 run_test 51b "mkdir .../t-0 --- .../t-$NUMTEST ===================="
3177 test_51ba() { # LU-993
3178 local BASE=$DIR/d51b
3179 # unlink all but 100 subdirectories, then check it still works
3181 local DELETE=$((NUMTEST - LEFT))
3183 # continue on to run this test even if 51b didn't finish,
3184 # just to delete the many subdirectories created.
3185 ! [ -d "${BASE}/t-1" ] && skip "test_51b() not run" && return 0
3187 # for ldiskfs the nlink count should be 1, but this is OSD specific
3188 # and so this is listed for informational purposes only
3189 log "nlink before: $(stat -c %h $BASE)"
3190 unlinkmany -d $BASE/t- $DELETE ||
3191 error "unlink of first $DELETE subdirs failed"
3193 log "nlink between: $(stat -c %h $BASE)"
3194 local FOUND=$(ls -l ${BASE} | wc -l)
3195 FOUND=$((FOUND - 1)) # trim the first line of ls output
3196 [ $FOUND -ne $LEFT ] &&
3197 error "can't find subdirs: found only $FOUND/$LEFT"
3199 unlinkmany -d $BASE/t- $DELETE $LEFT ||
3200 error "unlink of second $LEFT subdirs failed"
3201 log "nlink after: $(stat -c %h $BASE)"
3203 run_test 51ba "rmdir .../t-0 --- .../t-$NUMTEST"
3206 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3208 local ndirs=${TEST51BB_NDIRS:-10}
3209 local nfiles=${TEST51BB_NFILES:-100}
3211 local numfree=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
3213 [ $numfree -lt $(( ndirs * nfiles)) ] && \
3214 nfiles=$(( numfree / ndirs - 10 ))
3216 local dir=$DIR/d51bb
3218 local savePOLICY=$(lctl get_param -n lmv.*.placement)
3219 lctl set_param -n lmv.*.placement=CHAR
3222 local IUSED=$(lfs df -i $dir | grep MDT | awk '{print $3}')
3226 for ((i=0; i < $ndirs; i++)); do
3227 dirs[i]=$dir/$RANDOM
3228 echo Creating directory ${dirs[i]}
3231 echo Creating $nfiles in dir ${dirs[i]} ...
3232 echo "createmany -o ${dirs[i]}/$tfile- $nfiles"
3233 createmany -o ${dirs[i]}/$tfile- $nfiles
3239 IUSED=$(lfs df -i $dir | grep MDT | awk '{print $3}')
3243 for ((i=0; i<${#NEWUSED[@]}; i++)); do
3244 echo "mds $i: inodes count OLD ${OLDUSED[$i]} NEW ${NEWUSED[$i]}"
3245 [ ${OLDUSED[$i]} -lt ${NEWUSED[$i]} ] || rc=$((rc + 1))
3248 lctl set_param -n lmv.*.placement=$savePOLICY
3250 [ $rc -ne $MDSCOUNT ] || \
3251 error "Objects/inodes are not distributed over all mds servers"
3253 run_test 51bb "mkdir createmany CMD $MDSCOUNT ===================="
3256 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping test with few OSTs" && return
3258 createmany -o $DIR/d51d/t- 1000
3259 $GETSTRIPE $DIR/d51d > $TMP/files
3260 for N in `seq 0 $((OSTCOUNT - 1))`; do
3261 OBJS[$N]=`awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}' $TMP/files`
3262 OBJS0[$N]=`grep -A 1 idx $TMP/files | awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}'`
3263 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
3265 unlinkmany $DIR/d51d/t- 1000
3268 for N in `seq 1 $((OSTCOUNT - 1))`; do
3269 [ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ] && \
3270 error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
3271 [ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ] && \
3272 error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
3274 [ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ] && \
3275 error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
3276 [ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ] && \
3277 error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
3281 run_test 51d "check object distribution ===================="
3284 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
3287 chattr +a $DIR/d52a/foo || error "chattr +a failed"
3288 echo bar >> $DIR/d52a/foo || error "append bar failed"
3289 cp /etc/hosts $DIR/d52a/foo && error "cp worked"
3290 rm -f $DIR/d52a/foo 2>/dev/null && error "rm worked"
3291 link $DIR/d52a/foo $DIR/d52a/foo_link 2>/dev/null && error "link worked"
3292 echo foo >> $DIR/d52a/foo || error "append foo failed"
3293 mrename $DIR/d52a/foo $DIR/d52a/foo_ren && error "rename worked"
3294 lsattr $DIR/d52a/foo | egrep -q "^-+a[-e]+ $DIR/d52a/foo" || error "lsattr"
3295 chattr -a $DIR/d52a/foo || error "chattr -a failed"
3296 cp -r $DIR/d52a /tmp/
3297 rm -fr $DIR/d52a || error "cleanup rm failed"
3299 run_test 52a "append-only flag test (should return errors) ====="
3302 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
3305 chattr +i $DIR/d52b/foo || error "chattr +i failed"
3306 cat test > $DIR/d52b/foo && error "cat test worked"
3307 cp /etc/hosts $DIR/d52b/foo && error "cp worked"
3308 rm -f $DIR/d52b/foo 2>/dev/null && error "rm worked"
3309 link $DIR/d52b/foo $DIR/d52b/foo_link 2>/dev/null && error "link worked"
3310 echo foo >> $DIR/d52b/foo && error "echo worked"
3311 mrename $DIR/d52b/foo $DIR/d52b/foo_ren && error "rename worked"
3312 [ -f $DIR/d52b/foo ] || error
3313 [ -f $DIR/d52b/foo_ren ] && error
3314 lsattr $DIR/d52b/foo | egrep -q "^-+i[-e]+ $DIR/d52b/foo" || error "lsattr"
3315 chattr -i $DIR/d52b/foo || error "chattr failed"
3317 rm -fr $DIR/d52b || error
3319 run_test 52b "immutable flag test (should return errors) ======="
3322 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3323 remote_ost_nodsh && skip "remote OST with nodsh" && return
3332 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
3333 for value in $(do_facet $SINGLEMDS lctl get_param osc.$mdtosc.prealloc_last_id) ; do
3334 param=`echo ${value[0]} | cut -d "=" -f1`
3335 ostname=`echo $param | cut -d "." -f2 | cut -d - -f 1-2`
3336 mds_last=$(do_facet $SINGLEMDS lctl get_param -n $param)
3337 ostnum=$(echo $ostname | sed "s/${FSNAME}-OST//g" | awk '{print ($1+1)}' )
3338 ost_last=$(do_facet ost$ostnum lctl get_param -n obdfilter.$ostname.last_id | head -n 1)
3339 echo "$ostname.last_id=$ost_last ; MDS.last_id=$mds_last"
3340 if [ $ost_last != $mds_last ]; then
3341 error "$ostname.last_id=$ost_last ; MDS.last_id=$mds_last"
3345 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
3348 [ ! -f "$SOCKETSERVER" ] && skip_env "no socketserver, skipping" && return
3349 [ ! -f "$SOCKETCLIENT" ] && skip_env "no socketclient, skipping" && return
3350 $SOCKETSERVER $DIR/socket
3351 $SOCKETCLIENT $DIR/socket || error
3352 $MUNLINK $DIR/socket
3354 run_test 54a "unix domain socket test =========================="
3360 dd if=/dev/zero of=$f bs=`page_size` count=1
3362 run_test 54b "char device works in lustre ======================"
3365 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
3366 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
3367 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
3369 for i in `seq 3 7`; do
3370 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
3380 loopdev="$DIR/loop54c"
3383 [ -z "$LOOPNUM" ] && echo "couldn't find empty loop device" && return
3384 mknod $loopdev b 7 $LOOPNUM
3385 echo "make a loop file system with $tfile on $loopdev ($LOOPNUM)..."
3386 dd if=/dev/zero of=$tfile bs=`page_size` seek=1024 count=1 > /dev/null
3387 losetup $loopdev $tfile || error "can't set up $loopdev for $tfile"
3388 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
3390 mount -t ext2 $loopdev $tdir || error "error mounting $loopdev on $tdir"
3391 dd if=/dev/zero of=$tdir/tmp bs=`page_size` count=30 || error "dd write"
3393 dd if=$tdir/tmp of=/dev/zero bs=`page_size` count=30 || error "dd read"
3398 run_test 54c "block device works in lustre ====================="
3404 [ "$string" = `echo $string > $f | cat $f` ] || error
3406 run_test 54d "fifo device works in lustre ======================"
3409 check_kernel_version 46 || return 0
3412 cp -aL /dev/console $f
3413 echo $string > $f || error
3415 run_test 54e "console/tty device works in lustre ======================"
3417 #The test_55 used to be iopen test and it was removed by bz#24037.
3418 #run_test 55 "check iopen_connect_dentry() ======================"
3420 test_56a() { # was test_56
3426 NUMFILESx2=$(($NUMFILES * 2))
3427 for i in `seq 1 $NUMFILES` ; do
3428 touch $DIR/d56/file$i
3429 touch $DIR/d56/dir/file$i
3432 # test lfs getstripe with --recursive
3433 FILENUM=`$GETSTRIPE --recursive $DIR/d56 | grep -c obdidx`
3434 [ $FILENUM -eq $NUMFILESx2 ] ||
3435 error "$GETSTRIPE --recursive: found $FILENUM, not $NUMFILESx2"
3436 FILENUM=`$GETSTRIPE $DIR/d56 | grep -c obdidx`
3437 [ $FILENUM -eq $NUMFILES ] ||
3438 error "$GETSTRIPE $DIR/d56: found $FILENUM, not $NUMFILES"
3439 echo "$GETSTRIPE --recursive passed."
3441 # test lfs getstripe with file instead of dir
3442 FILENUM=`$GETSTRIPE $DIR/d56/file1 | grep -c obdidx`
3443 [ $FILENUM -eq 1 ] || error \
3444 "$GETSTRIPE $DIR/d56/file1: found $FILENUM, not 1"
3445 echo "$GETSTRIPE file1 passed."
3447 #test lfs getstripe with --verbose
3448 [ `$GETSTRIPE --verbose $DIR/d56 | grep -c lmm_magic` -eq $NUMFILES ] ||
3449 error "$GETSTRIPE --verbose $DIR/d56: want $NUMFILES lmm_magic"
3450 [ `$GETSTRIPE $DIR/d56 | grep -c lmm_magic` -eq 0 ] ||
3451 error "$GETSTRIPE $DIR/d56: showed lmm_magic"
3452 echo "$GETSTRIPE --verbose passed."
3454 #test lfs getstripe with --obd
3455 $GETSTRIPE --obd wrong_uuid $DIR/d56 2>&1 | grep -q "unknown obduuid" ||
3456 error "$GETSTRIPE --obd wrong_uuid should return error message"
3458 [ "$OSTCOUNT" -lt 2 ] &&
3459 skip_env "skipping other $GETSTRIPE --obd test" && return
3462 OBDUUID=$(ostuuid_from_index $OSTIDX)
3463 FILENUM=`$GETSTRIPE -ir $DIR/d56 | grep -x $OSTIDX | wc -l`
3464 FOUND=`$GETSTRIPE -r --obd $OBDUUID $DIR/d56 | grep obdidx | wc -l`
3465 [ $FOUND -eq $FILENUM ] ||
3466 error "$GETSTRIPE --obd wrong: found $FOUND, expected $FILENUM"
3467 [ `$GETSTRIPE -r -v --obd $OBDUUID $DIR/d56 |
3468 sed '/^[ ]*'${OSTIDX}'[ ]/d' |
3469 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l` -eq 0 ] ||
3470 error "$GETSTRIPE --obd: should not show file on other obd"
3471 echo "$GETSTRIPE --obd passed"
3473 run_test 56a "check $GETSTRIPE"
3478 local LOCAL_NUMFILES="$1"
3479 local LOCAL_NUMDIRS="$2"
3480 local MKDIR_PARAMS="$3"
3482 if [ ! -d "$TDIR" ] ; then
3484 [ "$MKDIR_PARAMS" ] && $SETSTRIPE $MKDIR_PARAMS $TDIR
3485 for i in `seq 1 $LOCAL_NUMFILES` ; do
3488 for i in `seq 1 $LOCAL_NUMDIRS` ; do
3490 for j in `seq 1 $LOCAL_NUMFILES` ; do
3491 touch $TDIR/dir$i/file$j
3497 setup_56_special() {
3501 if [ ! -e "$TDIR/loop1b" ] ; then
3502 for i in `seq 1 $LOCAL_NUMFILES` ; do
3503 mknod $TDIR/loop${i}b b 7 $i
3504 mknod $TDIR/null${i}c c 1 3
3505 ln -s $TDIR/file1 $TDIR/link${i}l
3507 for i in `seq 1 $LOCAL_NUMDIRS` ; do
3508 mknod $TDIR/dir$i/loop${i}b b 7 $i
3509 mknod $TDIR/dir$i/null${i}c c 1 3
3510 ln -s $TDIR/dir$i/file1 $TDIR/dir$i/link${i}l
3519 setup_56 $NUMFILES $NUMDIRS
3521 EXPECTED=$(($NUMDIRS + 2))
3522 # test lfs find with -name
3523 for i in $(seq 1 $NUMFILES) ; do
3524 NUMS=$($LFIND -name "*$i" $TDIR | wc -l)
3525 [ $NUMS -eq $EXPECTED ] ||
3526 error "lfs find -name \"*$i\" $TDIR wrong: "\
3527 "found $NUMS, expected $EXPECTED"
3530 run_test 56g "check lfs find -name ============================="
3536 setup_56 $NUMFILES $NUMDIRS
3538 EXPECTED=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
3539 # test lfs find with ! -name
3540 for i in $(seq 1 $NUMFILES) ; do
3541 NUMS=$($LFIND ! -name "*$i" $TDIR | wc -l)
3542 [ $NUMS -eq $EXPECTED ] ||
3543 error "lfs find ! -name \"*$i\" $TDIR wrong: "\
3544 "found $NUMS, expected $EXPECTED"
3547 run_test 56h "check lfs find ! -name ============================="
3552 UUID=$(ostuuid_from_index 0 $DIR/$tdir)
3553 CMD="$LFIND -ost $UUID $DIR/$tdir"
3555 [ -z "$OUT" ] || error "\"$CMD\" returned directory '$OUT'"
3557 run_test 56i "check 'lfs find -ost UUID' skips directories ======="
3561 setup_56_special $NUMFILES $NUMDIRS
3563 EXPECTED=$((NUMDIRS + 1))
3564 CMD="$LFIND -type d $TDIR"
3565 NUMS=$($CMD | wc -l)
3566 [ $NUMS -eq $EXPECTED ] ||
3567 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3569 run_test 56j "check lfs find -type d ============================="
3573 setup_56_special $NUMFILES $NUMDIRS
3575 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
3576 CMD="$LFIND -type f $TDIR"
3577 NUMS=$($CMD | wc -l)
3578 [ $NUMS -eq $EXPECTED ] ||
3579 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3581 run_test 56k "check lfs find -type f ============================="
3585 setup_56_special $NUMFILES $NUMDIRS
3587 EXPECTED=$((NUMDIRS + NUMFILES))
3588 CMD="$LFIND -type b $TDIR"
3589 NUMS=$($CMD | wc -l)
3590 [ $NUMS -eq $EXPECTED ] ||
3591 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3593 run_test 56l "check lfs find -type b ============================="
3597 setup_56_special $NUMFILES $NUMDIRS
3599 EXPECTED=$((NUMDIRS + NUMFILES))
3600 CMD="$LFIND -type c $TDIR"
3601 NUMS=$($CMD | wc -l)
3602 [ $NUMS -eq $EXPECTED ] ||
3603 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3605 run_test 56m "check lfs find -type c ============================="
3609 setup_56_special $NUMFILES $NUMDIRS
3611 EXPECTED=$((NUMDIRS + NUMFILES))
3612 CMD="$LFIND -type l $TDIR"
3613 NUMS=$($CMD | wc -l)
3614 [ $NUMS -eq $EXPECTED ] ||
3615 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3617 run_test 56n "check lfs find -type l ============================="
3621 setup_56 $NUMFILES $NUMDIRS
3623 utime $TDIR/file1 > /dev/null || error "utime (1)"
3624 utime $TDIR/file2 > /dev/null || error "utime (2)"
3625 utime $TDIR/dir1 > /dev/null || error "utime (3)"
3626 utime $TDIR/dir2 > /dev/null || error "utime (4)"
3627 utime $TDIR/dir1/file1 > /dev/null || error "utime (5)"
3628 dd if=/dev/zero count=1 >> $TDIR/dir1/file1 && sync
3631 NUMS=`$LFIND -mtime +0 $TDIR | wc -l`
3632 [ $NUMS -eq $EXPECTED ] || \
3633 error "lfs find -mtime +0 $TDIR wrong: found $NUMS, expected $EXPECTED"
3636 CMD="$LFIND -mtime 0 $TDIR"
3637 NUMS=$($CMD | wc -l)
3638 [ $NUMS -eq $EXPECTED ] ||
3639 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3641 run_test 56o "check lfs find -mtime for old files =========================="
3644 [ $RUNAS_ID -eq $UID ] &&
3645 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
3648 setup_56 $NUMFILES $NUMDIRS
3650 chown $RUNAS_ID $TDIR/file* || error "chown $DIR/${tdir}g/file$i failed"
3652 CMD="$LFIND -uid $RUNAS_ID $TDIR"
3653 NUMS=$($CMD | wc -l)
3654 [ $NUMS -eq $EXPECTED ] || \
3655 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3657 EXPECTED=$(((NUMFILES + 1) * NUMDIRS + 1))
3658 CMD="$LFIND ! -uid $RUNAS_ID $TDIR"
3659 NUMS=$($CMD | wc -l)
3660 [ $NUMS -eq $EXPECTED ] || \
3661 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3663 run_test 56p "check lfs find -uid and ! -uid ==============================="
3666 [ $RUNAS_ID -eq $UID ] &&
3667 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
3670 setup_56 $NUMFILES $NUMDIRS
3672 chgrp $RUNAS_GID $TDIR/file* || error "chown $TDIR/file$i failed"
3675 CMD="$LFIND -gid $RUNAS_GID $TDIR"
3676 NUMS=$($CMD | wc -l)
3677 [ $NUMS -eq $EXPECTED ] ||
3678 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3680 EXPECTED=$(( ($NUMFILES+1) * $NUMDIRS + 1))
3681 CMD="$LFIND ! -gid $RUNAS_GID $TDIR"
3682 NUMS=$($CMD | wc -l)
3683 [ $NUMS -eq $EXPECTED ] ||
3684 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3686 run_test 56q "check lfs find -gid and ! -gid ==============================="
3690 setup_56 $NUMFILES $NUMDIRS
3693 CMD="$LFIND -size 0 -type f $TDIR"
3694 NUMS=$($CMD | wc -l)
3695 [ $NUMS -eq $EXPECTED ] ||
3696 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3698 CMD="$LFIND ! -size 0 -type f $TDIR"
3699 NUMS=$($CMD | wc -l)
3700 [ $NUMS -eq $EXPECTED ] ||
3701 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3702 echo "test" > $TDIR/$tfile
3703 echo "test2" > $TDIR/$tfile.2 && sync
3705 CMD="$LFIND -size 5 -type f $TDIR"
3706 NUMS=$($CMD | wc -l)
3707 [ $NUMS -eq $EXPECTED ] ||
3708 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3710 CMD="$LFIND -size +5 -type f $TDIR"
3711 NUMS=$($CMD | wc -l)
3712 [ $NUMS -eq $EXPECTED ] ||
3713 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3715 CMD="$LFIND -size +0 -type f $TDIR"
3716 NUMS=$($CMD | wc -l)
3717 [ $NUMS -eq $EXPECTED ] ||
3718 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3720 CMD="$LFIND ! -size -5 -type f $TDIR"
3721 NUMS=$($CMD | wc -l)
3722 [ $NUMS -eq $EXPECTED ] ||
3723 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3725 CMD="$LFIND -size -5 -type f $TDIR"
3726 NUMS=$($CMD | wc -l)
3727 [ $NUMS -eq $EXPECTED ] ||
3728 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3730 run_test 56r "check lfs find -size works =========================="
3732 test_56s() { # LU-611
3734 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT"
3736 if [ $OSTCOUNT -gt 1 ]; then
3737 $SETSTRIPE -c 1 $TDIR/$tfile.{0,1,2,3}
3741 ONESTRIPE=$(((NUMDIRS + 1) * NUMFILES))
3745 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
3746 CMD="$LFIND -stripe-count $OSTCOUNT -type f $TDIR"
3747 NUMS=$($CMD | wc -l)
3748 [ $NUMS -eq $EXPECTED ] ||
3749 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3751 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + EXTRA))
3752 CMD="$LFIND -stripe-count +0 -type f $TDIR"
3753 NUMS=$($CMD | wc -l)
3754 [ $NUMS -eq $EXPECTED ] ||
3755 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3758 CMD="$LFIND -stripe-count 1 -type f $TDIR"
3759 NUMS=$($CMD | wc -l)
3760 [ $NUMS -eq $EXPECTED ] ||
3761 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3763 CMD="$LFIND -stripe-count -2 -type f $TDIR"
3764 NUMS=$($CMD | wc -l)
3765 [ $NUMS -eq $EXPECTED ] ||
3766 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3769 CMD="$LFIND -stripe-count $((OSTCOUNT + 1)) -type f $TDIR"
3770 NUMS=$($CMD | wc -l)
3771 [ $NUMS -eq $EXPECTED ] ||
3772 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3774 run_test 56s "check lfs find -stripe-count works"
3776 test_56t() { # LU-611
3778 setup_56 $NUMFILES $NUMDIRS "-s 512k"
3780 $SETSTRIPE -S 256k $TDIR/$tfile.{0,1,2,3}
3782 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
3783 CMD="$LFIND -stripe-size 512k -type f $TDIR"
3784 NUMS=$($CMD | wc -l)
3785 [ $NUMS -eq $EXPECTED ] ||
3786 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3788 CMD="$LFIND -stripe-size +320k -type f $TDIR"
3789 NUMS=$($CMD | wc -l)
3790 [ $NUMS -eq $EXPECTED ] ||
3791 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3793 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + 4))
3794 CMD="$LFIND -stripe-size +200k -type f $TDIR"
3795 NUMS=$($CMD | wc -l)
3796 [ $NUMS -eq $EXPECTED ] ||
3797 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3799 CMD="$LFIND -stripe-size -640k -type f $TDIR"
3800 NUMS=$($CMD | wc -l)
3801 [ $NUMS -eq $EXPECTED ] ||
3802 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3805 CMD="$LFIND -stripe-size 256k -type f $TDIR"
3806 NUMS=$($CMD | wc -l)
3807 [ $NUMS -eq $EXPECTED ] ||
3808 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3810 CMD="$LFIND -stripe-size -320k -type f $TDIR"
3811 NUMS=$($CMD | wc -l)
3812 [ $NUMS -eq $EXPECTED ] ||
3813 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3816 CMD="$LFIND -stripe-size 1024k -type f $TDIR"
3817 NUMS=$($CMD | wc -l)
3818 [ $NUMS -eq $EXPECTED ] ||
3819 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3821 run_test 56t "check lfs find -stripe-size works"
3823 test_56u() { # LU-611
3825 setup_56 $NUMFILES $NUMDIRS "-i 0"
3827 if [ $OSTCOUNT -gt 1 ]; then
3828 $SETSTRIPE -i 1 $TDIR/$tfile.{0,1,2,3}
3834 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
3835 CMD="$LFIND -stripe-index 0 -type f $TDIR"
3836 NUMS=$($CMD | wc -l)
3837 [ $NUMS -eq $EXPECTED ] ||
3838 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3841 CMD="$LFIND -stripe-index 1 -type f $TDIR"
3842 NUMS=$($CMD | wc -l)
3843 [ $NUMS -eq $EXPECTED ] ||
3844 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3846 CMD="$LFIND ! -stripe-index 0 -type f $TDIR"
3847 NUMS=$($CMD | wc -l)
3848 [ $NUMS -eq $EXPECTED ] ||
3849 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3852 # This should produce an error and not return any files
3853 CMD="$LFIND -stripe-index $OSTCOUNT -type f $TDIR"
3854 NUMS=$($CMD 2>/dev/null | wc -l)
3855 [ $NUMS -eq $EXPECTED ] ||
3856 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3858 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + ONESTRIPE))
3859 CMD="$LFIND -stripe-index 0,1 -type f $TDIR"
3860 NUMS=$($CMD | wc -l)
3861 [ $NUMS -eq $EXPECTED ] ||
3862 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3864 run_test 56u "check lfs find -stripe-index works"
3871 setup_56 $NUMFILES $NUMDIRS
3873 UUID=$(mdtuuid_from_index $MDT_IDX $TDIR)
3874 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT index $MDT_IDX"
3876 for file in $($LFIND -mdt $UUID $TDIR); do
3877 file_mdt_idx=$($GETSTRIPE -M $file)
3878 [ $file_mdt_idx -eq $MDT_IDX ] ||
3879 error "'lfind -mdt $UUID' != 'getstripe -M' ($file_mdt_idx)"
3882 run_test 56v "check 'lfs find -mdt match with lfs getstripe -M' ======="
3884 # Get and check the actual stripe count of one file.
3885 # Usage: check_stripe_count <file> <expected_stripe_count>
3886 check_stripe_count() {
3891 [[ -z "$file" || -z "$expected" ]] &&
3892 error "check_stripe_count: invalid argument!"
3894 local cmd="$GETSTRIPE -c $file"
3895 actual=$($cmd) || error "$cmd failed"
3896 actual=${actual%% *}
3898 if [[ $actual -ne $expected ]]; then
3899 [[ $expected -eq -1 ]] ||
3900 error "$cmd wrong: found $actual, expected $expected"
3901 [[ $actual -eq $OSTCOUNT ]] ||
3902 error "$cmd wrong: found $actual, expected $OSTCOUNT"
3909 rm -rf $TDIR || error "remove $TDIR failed"
3910 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT"
3913 stripe_size=$($GETSTRIPE -S -d $TDIR) ||
3914 error "$GETSTRIPE -S -d $TDIR failed"
3915 stripe_size=${stripe_size%% *}
3917 local file_size=$((stripe_size * OSTCOUNT))
3918 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
3919 local required_space=$((file_num * file_size))
3920 local free_space=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
3921 [[ $free_space -le $((required_space / 1024)) ]] &&
3922 skip_env "need at least $required_space bytes free space," \
3923 "have $free_space kbytes" && return
3926 local dd_count=$((file_size / dd_bs))
3928 # write data into the files
3932 for i in $(seq 1 $NUMFILES); do
3934 yes | dd bs=$dd_bs count=$dd_count of=$file >/dev/null 2>&1 ||
3935 error "write data into $file failed"
3937 for i in $(seq 1 $NUMDIRS); do
3938 for j in $(seq 1 $NUMFILES); do
3939 file=$TDIR/dir$i/file$j
3940 yes | dd bs=$dd_bs count=$dd_count of=$file \
3942 error "write data into $file failed"
3947 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
3950 local cmd="$LFS_MIGRATE -y -c $expected $TDIR/file1"
3952 eval $cmd || error "$cmd failed"
3954 check_stripe_count $TDIR/file1 $expected
3957 cmd="$LFS_MIGRATE -y -c $expected $TDIR/dir1"
3959 eval $cmd || error "$cmd failed"
3961 for j in $(seq 1 $NUMFILES); do
3962 check_stripe_count $TDIR/dir1/file$j $expected
3965 # lfs_migrate works with lfs find
3966 cmd="$LFIND -stripe_count $OSTCOUNT -type f $TDIR |
3967 $LFS_MIGRATE -y -c $expected"
3969 eval $cmd || error "$cmd failed"
3971 for i in $(seq 2 $NUMFILES); do
3972 check_stripe_count $TDIR/file$i $expected
3974 for i in $(seq 2 $NUMDIRS); do
3975 for j in $(seq 1 $NUMFILES); do
3976 check_stripe_count $TDIR/dir$i/file$j $expected
3980 run_test 56w "check lfs_migrate -c stripe_count works"
3983 # note test will not do anything if MDS is not local
3984 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3985 local MNTDEV="osd*.*MDT*.mntdev"
3986 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
3987 [ -z "$DEV" ] && error "can't access $MNTDEV"
3988 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
3989 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
3990 error "can't access $DEV"
3991 DEVISIZE=`awk '/Inode size:/ { print $3 }' $TMP/t57a.dump`
3992 [ "$DEVISIZE" -gt 128 ] || error "inode size $DEVISIZE"
3996 run_test 57a "verify MDS filesystem created with large inodes =="