2 # -*- tab-width: 4; indent-tabs-mode: t; -*-
4 # Run select tests by setting ONLY, or as arguments to the script.
5 # Skip specific tests by setting EXCEPT.
7 # e.g. ONLY="22 23" or ONLY="`seq 32 39`" or EXCEPT="31"
11 # bug number for skipped test: 13297 2108 9789 3637 9789 3561 12622 5188
12 ALWAYS_EXCEPT=" 27u 42a 42b 42c 42d 45 51d 68b $SANITY_EXCEPT"
13 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
15 # with LOD/OSP landing
16 # bug number for skipped tests: LU-2036
17 ALWAYS_EXCEPT=" 76 $ALWAYS_EXCEPT"
20 # Tests that fail on uml
21 CPU=`awk '/model/ {print $4}' /proc/cpuinfo`
22 # buffer i/o errs sock spc runas
23 [ "$CPU" = "UML" ] && EXCEPT="$EXCEPT 27m 27n 27o 27p 27q 27r 31d 54a 64b 99a 99b 99c 99d 99e 99f 101a"
25 SRCDIR=$(cd $(dirname $0); echo $PWD)
26 export PATH=$PATH:/sbin
30 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
31 CREATETEST=${CREATETEST:-createtest}
33 LFIND=${LFIND:-"$LFS find"}
34 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
36 MCREATE=${MCREATE:-mcreate}
37 OPENFILE=${OPENFILE:-openfile}
38 OPENUNLINK=${OPENUNLINK:-openunlink}
39 export MULTIOP=${MULTIOP:-multiop}
40 READS=${READS:-"reads"}
41 MUNLINK=${MUNLINK:-munlink}
42 SOCKETSERVER=${SOCKETSERVER:-socketserver}
43 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
44 MEMHOG=${MEMHOG:-memhog}
45 DIRECTIO=${DIRECTIO:-directio}
46 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
47 UMOUNT=${UMOUNT:-"umount -d"}
49 CHECK_GRANT=${CHECK_GRANT:-"yes"}
50 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
52 export NAME=${NAME:-local}
59 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
60 . $LUSTRE/tests/test-framework.sh
62 . ${CONFIG:=$LUSTRE/tests/cfg/${NAME}.sh}
65 [ "$SLOW" = "no" ] && EXCEPT_SLOW="24o 24v 27m 36f 36g 36h 51b 60c 63 64b 68 71 73 77f 78 101a 103 115 120g 124b"
71 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
72 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
81 check_kernel_version() {
83 GOT_VER=$(lctl get_param -n version | awk '/kernel:/ {print $2}')
85 patchless|patchless_client) return 0;;
86 *) [ $GOT_VER -ge $WANT_VER ] && return 0 ;;
88 log "test needs at least kernel version $WANT_VER, running $GOT_VER"
92 if [ "$ONLY" == "cleanup" ]; then
97 check_and_setup_lustre
102 MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid | \
103 awk '{gsub(/_UUID/,""); print $1}' | head -1)
104 LOVNAME=$($LCTL get_param -n llite.*.lov.common_name | tail -n 1)
105 OSTCOUNT=$($LCTL get_param -n lov.$LOVNAME.numobd)
106 STRIPECOUNT=$($LCTL get_param -n lov.$LOVNAME.stripecount)
107 STRIPESIZE=$($LCTL get_param -n lov.$LOVNAME.stripesize)
108 ORIGFREE=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
109 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
111 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
112 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
113 rm -rf $DIR/[Rdfs][0-9]*
115 # $RUNAS_ID may get set incorrectly somewhere else
116 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
118 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
122 if [ "${ONLY}" = "MOUNT" ] ; then
123 echo "Lustre is up, please go on"
127 echo "preparing for tests involving mounts"
128 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
130 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
131 echo # add a newline after mke2fs.
135 OLDDEBUG="`lctl get_param -n debug 2> /dev/null`"
136 lctl set_param debug=-1 2> /dev/null || true
139 $CHECKSTAT -t file $DIR/$tfile || error
141 $CHECKSTAT -a $DIR/$tfile || error
143 run_test 0 "touch .../$tfile ; rm .../$tfile ====================="
146 chmod 0755 $DIR || error
147 $CHECKSTAT -p 0755 $DIR || error
149 run_test 0b "chmod 0755 $DIR ============================="
152 $LCTL get_param mdc.*.import | grep "state: FULL" || error "import not FULL"
153 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" || error "bad target"
155 run_test 0c "check import proc ============================="
160 mkdir $DIR/d1/d2 && error "we expect EEXIST, but not returned"
161 $CHECKSTAT -t dir $DIR/d1/d2 || error
163 run_test 1a "mkdir .../d1; mkdir .../d1/d2 ====================="
168 $CHECKSTAT -a $DIR/d1 || error
170 run_test 1b "rmdir .../d1/d2; rmdir .../d1 ====================="
175 $CHECKSTAT -t file $DIR/d2/f || error
177 run_test 2a "mkdir .../d2; touch .../d2/f ======================"
181 $CHECKSTAT -a $DIR/d2 || error
183 run_test 2b "rm -r .../d2; checkstat .../d2/f ======================"
187 $CHECKSTAT -t dir $DIR/d3 || error
189 run_test 3a "mkdir .../d3 ======================================"
192 if [ ! -d $DIR/d3 ]; then
196 $CHECKSTAT -t file $DIR/d3/f || error
198 run_test 3b "touch .../d3/f ===================================="
202 $CHECKSTAT -a $DIR/d3 || error
204 run_test 3c "rm -r .../d3 ======================================"
208 $CHECKSTAT -t dir $DIR/d4 || error
210 run_test 4a "mkdir .../d4 ======================================"
213 if [ ! -d $DIR/d4 ]; then
217 $CHECKSTAT -t dir $DIR/d4/d2 || error
219 run_test 4b "mkdir .../d4/d2 ==================================="
224 chmod 0707 $DIR/d5/d2
225 $CHECKSTAT -t dir -p 0707 $DIR/d5/d2 || error
227 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2 ============"
231 chmod 0666 $DIR/f6a || error
232 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/f6a || error
234 run_test 6a "touch .../f6a; chmod .../f6a ======================"
237 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
238 if [ ! -f $DIR/f6a ]; then
242 $RUNAS chmod 0444 $DIR/f6a && error
243 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/f6a || error
245 run_test 6b "$RUNAS chmod .../f6a (should return error) =="
248 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
250 chown $RUNAS_ID $DIR/f6c || error
251 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/f6c || error
253 run_test 6c "touch .../f6c; chown .../f6c ======================"
256 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
257 if [ ! -f $DIR/f6c ]; then
259 chown $RUNAS_ID $DIR/f6c
261 $RUNAS chown $UID $DIR/f6c && error
262 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/f6c || error
264 run_test 6d "$RUNAS chown .../f6c (should return error) =="
267 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
269 chgrp $RUNAS_ID $DIR/f6e || error
270 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/f6e || error
272 run_test 6e "touch .../f6e; chgrp .../f6e ======================"
275 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
276 if [ ! -f $DIR/f6e ]; then
278 chgrp $RUNAS_ID $DIR/f6e
280 $RUNAS chgrp $UID $DIR/f6e && error
281 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/f6e || error
283 run_test 6f "$RUNAS chgrp .../f6e (should return error) =="
286 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
287 mkdir $DIR/d6g || error
288 chmod 777 $DIR/d6g || error
289 $RUNAS mkdir $DIR/d6g/d || error
290 chmod g+s $DIR/d6g/d || error
291 mkdir $DIR/d6g/d/subdir
292 $CHECKSTAT -g \#$RUNAS_GID $DIR/d6g/d/subdir || error
294 run_test 6g "Is new dir in sgid dir inheriting group?"
296 test_6h() { # bug 7331
297 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
298 touch $DIR/f6h || error "touch failed"
299 chown $RUNAS_ID:$RUNAS_GID $DIR/f6h || error "initial chown failed"
300 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/f6h && error "chown worked"
301 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/f6h || error
303 run_test 6h "$RUNAS chown RUNAS_ID.0 .../f6h (should return error)"
309 $CHECKSTAT -t file -p 0666 $DIR/d7/f || error
311 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
314 if [ ! -d $DIR/d7 ]; then
318 echo -n foo > $DIR/d7/f2
319 [ "`cat $DIR/d7/f2`" = "foo" ] || error
320 $CHECKSTAT -t file -s 3 $DIR/d7/f2 || error
322 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
328 $CHECKSTAT -t file -p 0666 $DIR/d8/f || error
330 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
336 $CHECKSTAT -t dir $DIR/d9/d2/d3 || error
338 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
344 $CHECKSTAT -t file $DIR/d10/d2/f || error
346 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
351 chmod 0666 $DIR/d11/d2
352 chmod 0705 $DIR/d11/d2
353 $CHECKSTAT -t dir -p 0705 $DIR/d11/d2 || error
355 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
360 chmod 0666 $DIR/d12/f
361 chmod 0654 $DIR/d12/f
362 $CHECKSTAT -t file -p 0654 $DIR/d12/f || error
364 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
368 dd if=/dev/zero of=$DIR/d13/f count=10
370 $CHECKSTAT -t file -s 0 $DIR/d13/f || error
372 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
378 $CHECKSTAT -a $DIR/d14/f || error
380 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
385 mv $DIR/d15/f $DIR/d15/f2
386 $CHECKSTAT -t file $DIR/d15/f2 || error
388 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
394 $CHECKSTAT -a $DIR/d16/f || error
396 run_test 16 "touch .../d16/f; rm -rf .../d16/f ================="
401 ln -s $DIR/d17/f $DIR/d17/l-exist
403 $CHECKSTAT -l $DIR/d17/f $DIR/d17/l-exist || error
404 $CHECKSTAT -f -t f $DIR/d17/l-exist || error
405 rm -f $DIR/d17/l-exist
406 $CHECKSTAT -a $DIR/d17/l-exist || error
408 run_test 17a "symlinks: create, remove (real) =================="
412 ln -s no-such-file $DIR/d17/l-dangle
414 $CHECKSTAT -l no-such-file $DIR/d17/l-dangle || error
415 $CHECKSTAT -fa $DIR/d17/l-dangle || error
416 rm -f $DIR/d17/l-dangle
417 $CHECKSTAT -a $DIR/d17/l-dangle || error
419 run_test 17b "symlinks: create, remove (dangling) =============="
421 test_17c() { # bug 3440 - don't save failed open RPC for replay
423 ln -s foo $DIR/d17/f17c
424 cat $DIR/d17/f17c && error "opened non-existent symlink" || true
426 run_test 17c "symlinks: open dangling (should return error) ===="
430 ln -s foo $DIR/d17/f17d
431 touch $DIR/d17/f17d || error "creating to new symlink"
433 run_test 17d "symlinks: create dangling ========================"
437 local foo=$DIR/$tdir/$tfile
438 ln -s $foo $foo || error "create symlink failed"
439 ls -l $foo || error "ls -l failed"
440 ls $foo && error "ls not failed" || true
442 run_test 17e "symlinks: create recursive symlink (should return error) ===="
446 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/d17f/111
447 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/d17f/222
448 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/d17f/333
449 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/d17f/444
450 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/d17f/555
451 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
454 run_test 17f "symlinks: long and very long symlink name ========================"
456 # str_repeat(S, N) generate a string that is string S repeated N times
461 while [ $((n -= 1)) -ge 0 ]; do
467 # Long symlinks and LU-2241
470 local TESTS="59 60 61 4094 4095"
473 local SYMNAME=$(str_repeat 'x' $i)
474 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
475 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
478 run_test 17g "symlinks: really long symlink name and inode boundaries"
480 test_17h() { #bug 17378
481 remote_mds_nodsh && skip "remote MDS with nodsh" && return
483 $SETSTRIPE -c -1 $DIR/$tdir
484 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
485 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000141
486 touch $DIR/$tdir/$tfile || true
488 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
490 test_17i() { #bug 20018
491 remote_mds_nodsh && skip "remote MDS with nodsh" && return
493 local foo=$DIR/$tdir/$tfile
494 ln -s $foo $foo || error "create symlink failed"
495 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
496 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000143
497 ls -l $foo && error "error not detected"
500 run_test 17i "don't panic on short symlink"
502 test_17k() { #bug 22301
503 rsync --help | grep -q xattr ||
504 skip_env "$(rsync --version| head -1) does not support xattrs"
505 mkdir -p $DIR/{$tdir,$tdir.new}
506 touch $DIR/$tdir/$tfile
507 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
508 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
509 error "rsync failed with xattrs enabled"
511 run_test 17k "symlinks: rsync with xattrs enabled ========================="
515 local short_sym="0123456789"
516 local WDIR=$DIR/${tdir}m
523 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
524 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
525 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
527 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
528 skip "only for ldiskfs MDT" && return 0
532 # create a long symlink file
533 for ((i = 0; i < 4; ++i)); do
534 long_sym=${long_sym}${long_sym}
537 echo "create 512 short and long symlink files under $WDIR"
538 for ((i = 0; i < 256; ++i)); do
539 ln -sf ${long_sym}"a5a5" $WDIR/long-$i
540 ln -sf ${short_sym}"a5a5" $WDIR/short-$i
546 wait_delete_completed
548 echo "recreate the 512 symlink files with a shorter string"
549 for ((i = 0; i < 512; ++i)); do
550 # rewrite the symlink file with a shorter string
551 ln -sf ${long_sym} $WDIR/long-$i
552 ln -sf ${short_sym} $WDIR/short-$i
555 mds_index=$($LFS getstripe -M $WDIR)
556 mds_index=$((mds_index+1))
557 devname=$(mdsdevname $mds_index)
558 cmd="$E2FSCK -fnvd $devname"
560 echo "stop and checking mds${mds_index}: $cmd"
561 # e2fsck should not return error
562 stop mds${mds_index} -f
563 do_facet mds${mds_index} $cmd || rc=$?
565 start mds${mds_index} $devname $MDS_MOUNT_OPTS
566 df $MOUNT > /dev/null 2>&1
567 [ $rc -ne 0 ] && error "e2fsck should not report error upon "\
568 "short/long symlink MDT: rc=$rc"
571 run_test 17m "run e2fsck against MDT which contains short/long symlink"
577 run_test 18 "touch .../f ; ls ... =============================="
583 $CHECKSTAT -a $DIR/f19 || error
585 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
588 ls -l $DIR/f19 && error || true
590 run_test 19b "ls -l .../f19 (should return error) =============="
593 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
594 $RUNAS touch $DIR/f19 && error || true
596 run_test 19c "$RUNAS touch .../f19 (should return error) =="
599 cat $DIR/f19 && error || true
601 run_test 19d "cat .../f19 (should return error) =============="
613 $CHECKSTAT -a $DIR/f || error
615 run_test 20 "touch .../f ; ls -l ... ==========================="
619 [ -f $DIR/d21/dangle ] && rm -f $DIR/d21/dangle
620 ln -s dangle $DIR/d21/link
621 echo foo >> $DIR/d21/link
623 $CHECKSTAT -t link $DIR/d21/link || error
624 $CHECKSTAT -f -t file $DIR/d21/link || error
626 run_test 21 "write to dangling link ============================"
631 chown $RUNAS_ID:$RUNAS_GID $WDIR
632 (cd $WDIR || error "cd $WDIR failed";
633 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
635 ls -lR $WDIR/etc || error "ls -lR $WDIR/etc failed"
636 $CHECKSTAT -t dir $WDIR/etc || error "checkstat -t dir failed"
637 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $WDIR/etc || error "checkstat -u failed"
639 run_test 22 "unpack tar archive as non-root user ==============="
644 local file=$DIR/$tdir/$tfile
646 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
647 openfile -f O_CREAT:O_EXCL $file &&
648 error "$file recreate succeeded" || true
650 run_test 23a "O_CREAT|O_EXCL in subdir =========================="
652 test_23b() { # bug 18988
654 local file=$DIR/$tdir/$tfile
657 echo foo > $file || error "write filed"
658 echo bar >> $file || error "append filed"
659 $CHECKSTAT -s 8 $file || error "wrong size"
662 run_test 23b "O_APPEND check =========================="
665 echo '== rename sanity =============================================='
666 echo '-- same directory rename'
669 mv $DIR/R1/f $DIR/R1/g
670 $CHECKSTAT -t file $DIR/R1/g || error
672 run_test 24a "touch .../R1/f; rename .../R1/f .../R1/g ========="
677 mv $DIR/R2/f $DIR/R2/g
678 $CHECKSTAT -a $DIR/R2/f || error
679 $CHECKSTAT -t file $DIR/R2/g || error
681 run_test 24b "touch .../R2/{f,g}; rename .../R2/f .../R2/g ====="
686 mv $DIR/R3/f $DIR/R3/g
687 $CHECKSTAT -a $DIR/R3/f || error
688 $CHECKSTAT -t dir $DIR/R3/g || error
690 run_test 24c "mkdir .../R3/f; rename .../R3/f .../R3/g ========="
695 mrename $DIR/R4/f $DIR/R4/g
696 $CHECKSTAT -a $DIR/R4/f || error
697 $CHECKSTAT -t dir $DIR/R4/g || error
699 run_test 24d "mkdir .../R4/{f,g}; rename .../R4/f .../R4/g ====="
702 echo '-- cross directory renames --'
705 mv $DIR/R5a/f $DIR/R5b/g
706 $CHECKSTAT -a $DIR/R5a/f || error
707 $CHECKSTAT -t file $DIR/R5b/g || error
709 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
713 touch $DIR/R6a/f $DIR/R6b/g
714 mv $DIR/R6a/f $DIR/R6b/g
715 $CHECKSTAT -a $DIR/R6a/f || error
716 $CHECKSTAT -t file $DIR/R6b/g || error
718 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
723 mv $DIR/R7a/d $DIR/R7b/e
724 $CHECKSTAT -a $DIR/R7a/d || error
725 $CHECKSTAT -t dir $DIR/R7b/e || error
727 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
731 mkdir $DIR/R8a/d $DIR/R8b/e
732 mrename $DIR/R8a/d $DIR/R8b/e
733 $CHECKSTAT -a $DIR/R8a/d || error
734 $CHECKSTAT -t dir $DIR/R8b/e || error
736 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
739 echo "-- rename error cases"
743 mrename $DIR/R9/f $DIR/R9/a
744 $CHECKSTAT -t file $DIR/R9/f || error
745 $CHECKSTAT -t dir $DIR/R9/a || error
746 $CHECKSTAT -a $DIR/R9/a/f || error
748 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
752 mrename $DIR/R10/f $DIR/R10/g
753 $CHECKSTAT -t dir $DIR/R10 || error
754 $CHECKSTAT -a $DIR/R10/f || error
755 $CHECKSTAT -a $DIR/R10/g || error
757 run_test 24j "source does not exist ============================"
760 mkdir $DIR/R11a $DIR/R11a/d
762 mv $DIR/R11a/f $DIR/R11a/d
763 $CHECKSTAT -a $DIR/R11a/f || error
764 $CHECKSTAT -t file $DIR/R11a/d/f || error
766 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
768 # bug 2429 - rename foo foo foo creates invalid file
771 $MULTIOP $f OcNs || error
773 run_test 24l "Renaming a file to itself ========================"
777 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
778 # on ext3 this does not remove either the source or target files
779 # though the "expected" operation would be to remove the source
780 $CHECKSTAT -t file ${f} || error "${f} missing"
781 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
783 run_test 24m "Renaming a file to a hard link to itself ========="
787 # this stats the old file after it was renamed, so it should fail
791 $CHECKSTAT ${f}.rename
794 run_test 24n "Statting the old file after renaming (Posix rename 2)"
797 check_kernel_version 37 || return 0
799 rename_many -s random -v -n 10 $DIR/d24o
801 run_test 24o "rename of files during htree split ==============="
805 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
806 mrename $DIR/R12a $DIR/R12b
807 $CHECKSTAT -a $DIR/R12a || error
808 $CHECKSTAT -t dir $DIR/R12b || error
809 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
810 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
812 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
816 DIRINO=`ls -lid $DIR/R13a | awk '{ print $1 }'`
817 multiop_bg_pause $DIR/R13b D_c || return 1
820 mrename $DIR/R13a $DIR/R13b
821 $CHECKSTAT -a $DIR/R13a || error
822 $CHECKSTAT -t dir $DIR/R13b || error
823 DIRINO2=`ls -lid $DIR/R13b | awk '{ print $1 }'`
824 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
826 wait $MULTIPID || error "multiop close failed"
828 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
830 test_24r() { #bug 3789
831 mkdir $DIR/R14a $DIR/R14a/b
832 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
833 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
834 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
836 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
839 mkdir $DIR/R15a $DIR/R15a/b $DIR/R15a/b/c
840 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
841 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
842 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
844 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
846 mkdir $DIR/R16a $DIR/R16a/b $DIR/R16a/b/c
847 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
848 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
849 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
851 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
853 test_24u() { # bug12192
854 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error
855 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
857 run_test 24u "create stripe file"
863 simple_cleanup_common() {
866 wait_delete_completed
871 local FREE_INODES=`lfs df -i|grep "filesystem summary" | awk '{print $5}'`
872 [ $FREE_INODES -lt $NRFILES ] && \
873 skip "not enough free inodes $FREE_INODES required $NRFILES" &&
876 trap simple_cleanup_common EXIT
879 createmany -m $DIR/$tdir/$tfile $NRFILES
882 lctl set_param mdc.*.stats clear
884 ls $DIR/$tdir >/dev/null || error "error in listing large dir"
887 # DIRENT_SIZE = 32 bytes for sizeof(struct lu_dirent) +
888 # 8 bytes for name(filename is mostly 5 in this test) +
889 # 8 bytes for luda_type
890 # take into account of overhead in lu_dirpage header and end mark in
891 # each page, plus one in RPC_NUM calculation.
893 RPC_SIZE=$(($(lctl get_param -n mdc.*.max_pages_per_rpc)*$(page_size)))
894 RPC_NUM=$(((NRFILES * DIRENT_SIZE + RPC_SIZE - 1) / RPC_SIZE + 1))
895 mds_readpage=`lctl get_param mdc.*.stats | \
896 awk '/^mds_readpage/ {print $2}'`
897 [ $mds_readpage -gt $RPC_NUM ] && \
898 error "large readdir doesn't take effect"
900 simple_cleanup_common
902 run_test 24v "list directory with large files (handle hash collision, bug: 17560)"
904 test_24w() { # bug21506
906 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
907 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
908 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
909 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
910 [ "$SZ1" = "$SZ2" ] || \
911 error "Error reading at the end of the file $tfile"
913 run_test 24w "Reading a file larger than 4Gb"
916 echo '== symlink sanity ============================================='
920 touch $DIR/s25/foo || error
922 run_test 25a "create file in symlinked directory ==============="
925 [ ! -d $DIR/d25 ] && test_25a
926 $CHECKSTAT -t file $DIR/s25/foo || error
928 run_test 25b "lookup file in symlinked directory ==============="
933 ln -s d26/d26-2 $DIR/s26
934 touch $DIR/s26/foo || error
936 run_test 26a "multiple component symlink ======================="
939 mkdir -p $DIR/d26b/d26-2
940 ln -s d26b/d26-2/foo $DIR/s26-2
941 touch $DIR/s26-2 || error
943 run_test 26b "multiple component symlink at end of lookup ======"
948 ln -s d26.2 $DIR/s26.2-1
949 ln -s s26.2-1 $DIR/s26.2-2
950 ln -s s26.2-2 $DIR/s26.2-3
951 chmod 0666 $DIR/s26.2-3/foo
953 run_test 26c "chain of symlinks ================================"
955 # recursive symlinks (bug 439)
957 ln -s d26-3/foo $DIR/d26-3
959 run_test 26d "create multiple component recursive symlink ======"
962 [ ! -h $DIR/d26-3 ] && test_26d
965 run_test 26e "unlink multiple component recursive symlink ======"
967 # recursive symlinks (bug 7022)
970 mkdir $DIR/$tdir/$tfile || error "mkdir $DIR/$tdir/$tfile failed"
971 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
972 mkdir -p lndir/bar1 || error "mkdir lndir/bar1 failed"
973 mkdir $tfile || error "mkdir $tfile failed"
974 cd $tfile || error "cd $tfile failed"
975 ln -s .. dotdot || error "ln dotdot failed"
976 ln -s dotdot/lndir lndir || error "ln lndir failed"
977 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
978 output=`ls $tfile/$tfile/lndir/bar1`
979 [ "$output" = bar1 ] && error "unexpected output"
980 rm -r $tfile || error "rm $tfile failed"
981 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
983 run_test 26f "rm -r of a directory which has recursive symlink ="
986 echo '== stripe sanity =============================================='
987 mkdir -p $DIR/d27 || error "mkdir failed"
989 $SETSTRIPE -c 1 $DIR/d27/f0 || error "setstripe failed"
990 $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
992 log "== test_27a: write to one stripe file ========================="
993 cp /etc/hosts $DIR/d27/f0 || error
995 run_test 27a "one stripe file =================================="
998 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
1000 $SETSTRIPE -c 2 $DIR/d27/f01 || error "setstripe failed"
1001 $GETSTRIPE -c $DIR/d27/f01
1002 [ $($GETSTRIPE -c $DIR/d27/f01) -eq 2 ] ||
1003 error "two-stripe file doesn't have two stripes"
1005 run_test 27b "create two stripe file"
1008 [ -f $DIR/d27/f01 ] || skip "test_27b not run" && return
1010 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
1012 run_test 27c "write to two stripe file"
1016 $SETSTRIPE -c 0 -i -1 -S 0 $DIR/d27/fdef || error "setstripe failed"
1017 $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
1018 dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
1020 run_test 27d "create file with default settings ================"
1024 $SETSTRIPE -c 2 $DIR/d27/f12 || error "setstripe failed"
1025 $SETSTRIPE -c 2 $DIR/d27/f12 && error "setstripe succeeded twice"
1026 $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
1028 run_test 27e "setstripe existing file (should return error) ======"
1032 $SETSTRIPE -S 100 -i 0 -c 1 $DIR/d27/fbad && error "setstripe failed"
1033 dd if=/dev/zero of=$DIR/d27/f12 bs=4k count=4 || error "dd failed"
1034 $GETSTRIPE $DIR/d27/fbad || error "$GETSTRIPE failed"
1036 run_test 27f "setstripe with bad stripe size (should return error)"
1040 $MCREATE $DIR/d27/fnone || error "mcreate failed"
1041 $GETSTRIPE $DIR/d27/fnone 2>&1 | grep "no stripe info" ||
1042 error "$DIR/d27/fnone has object"
1044 run_test 27g "$GETSTRIPE with no objects"
1047 touch $DIR/d27/fsome || error "touch failed"
1048 [ $($GETSTRIPE -c $DIR/d27/fsome) -gt 0 ] || error "missing objects"
1050 run_test 27i "$GETSTRIPE with some objects"
1054 $SETSTRIPE -i $OSTCOUNT $DIR/d27/f27j && error "setstripe failed"||true
1056 run_test 27j "setstripe with bad stripe offset (should return error)"
1058 test_27k() { # bug 2844
1061 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
1062 [ ! -d $DIR/d27 ] && mkdir -p $DIR/d27
1063 $SETSTRIPE -S 67108864 $FILE || error "setstripe failed"
1064 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1065 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
1066 dd if=/dev/zero of=$FILE bs=4k count=1
1067 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1068 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
1070 run_test 27k "limit i_blksize for broken user apps ============="
1074 mcreate $DIR/f27l || error "creating file"
1075 $RUNAS $SETSTRIPE -c 1 $DIR/f27l && \
1076 error "setstripe should have failed" || true
1078 run_test 27l "check setstripe permissions (should return error)"
1081 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" &&
1083 if [ $ORIGFREE -gt $MAXFREE ]; then
1084 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1087 trap simple_cleanup_common EXIT
1089 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_1
1090 dd if=/dev/zero of=$DIR/$tdir/f27m_1 bs=1024 count=$MAXFREE &&
1091 error "dd should fill OST0"
1093 while $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_$i; do
1095 [ $i -gt 256 ] && break
1098 touch $DIR/$tdir/f27m_$i
1099 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1100 error "OST0 was full but new created file still use it"
1102 touch $DIR/$tdir/f27m_$i
1103 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1104 error "OST0 was full but new created file still use it"
1105 simple_cleanup_common
1107 run_test 27m "create file while OST0 was full =================="
1110 local DELAY=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage | head -n 1 | awk '{print $1 * 2}')
1114 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1115 # if the OST isn't full anymore.
1117 local OSTIDX=${1:-""}
1119 local list=$(comma_list $(osts_nodes))
1120 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1122 do_nodes $list lctl set_param fail_loc=0
1123 sync # initiate all OST_DESTROYs from MDS to OST
1127 exhaust_precreations() {
1130 local FAILIDX=${3:-$OSTIDX}
1133 local MDSIDX=$(get_mds_dir "$DIR/$tdir")
1134 echo OSTIDX=$OSTIDX MDSIDX=$MDSIDX
1136 local OST=$(ostname_from_index $OSTIDX)
1137 local MDT_INDEX=$(lfs df | grep "\[MDT:$((MDSIDX - 1))\]" | awk '{print $1}' | \
1138 sed -e 's/_UUID$//;s/^.*-//')
1141 local mdtosc_proc1=$(get_mdtosc_proc_path mds${MDSIDX} $OST)
1142 local last_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1143 osc.$mdtosc_proc1.prealloc_last_id)
1144 local next_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1145 osc.$mdtosc_proc1.prealloc_next_id)
1147 local mdtosc_proc2=$(get_mdtosc_proc_path mds${MDSIDX})
1148 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1150 mkdir -p $DIR/$tdir/${OST}
1151 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1152 #define OBD_FAIL_OST_ENOSPC 0x215
1153 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=$FAILIDX
1154 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x215
1155 echo "Creating to objid $last_id on ost $OST..."
1156 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1157 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1158 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=$FAILLOC
1162 exhaust_all_precreations() {
1164 for (( i=0; i < OSTCOUNT; i++ )) ; do
1165 exhaust_precreations $i $1 -1
1170 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1171 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1172 remote_ost_nodsh && skip "remote OST with nodsh" && return
1175 rm -f $DIR/$tdir/$tfile
1176 exhaust_precreations 0 0x80000215
1177 $SETSTRIPE -c -1 $DIR/$tdir
1178 touch $DIR/$tdir/$tfile || error
1179 $GETSTRIPE $DIR/$tdir/$tfile
1182 run_test 27n "create file with some full OSTs =================="
1185 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1186 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1187 remote_ost_nodsh && skip "remote OST with nodsh" && return
1190 rm -f $DIR/$tdir/$tfile
1191 exhaust_all_precreations 0x215
1193 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1198 run_test 27o "create file with all full OSTs (should error) ===="
1201 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1202 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1203 remote_ost_nodsh && skip "remote OST with nodsh" && return
1206 rm -f $DIR/$tdir/$tfile
1209 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1210 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1211 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1213 exhaust_precreations 0 0x80000215
1214 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1215 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1216 $GETSTRIPE $DIR/$tdir/$tfile
1220 run_test 27p "append to a truncated file with some full OSTs ==="
1223 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1224 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1225 remote_ost_nodsh && skip "remote OST with nodsh" && return
1228 rm -f $DIR/$tdir/$tfile
1231 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1232 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||error "truncate $DIR/$tdir/$tfile failed"
1233 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1235 exhaust_all_precreations 0x215
1237 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1238 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1242 run_test 27q "append to truncated file with all OSTs full (should error) ==="
1245 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1246 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1247 remote_ost_nodsh && skip "remote OST with nodsh" && return
1250 rm -f $DIR/$tdir/$tfile
1251 exhaust_precreations 0 0x80000215
1253 $SETSTRIPE -i 0 -c 2 $DIR/$tdir/$tfile # && error
1257 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1259 test_27s() { # bug 10725
1261 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1262 local stripe_count=0
1263 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1264 $SETSTRIPE -S $stripe_size -c $stripe_count $DIR/$tdir &&
1265 error "stripe width >= 2^32 succeeded" || true
1268 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1270 test_27t() { # bug 10864
1275 $WLFS getstripe $tfile
1278 run_test 27t "check that utils parse path correctly"
1280 test_27u() { # bug 4900
1281 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1282 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1284 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1285 do_facet $SINGLEMDS lctl set_param fail_loc=0x139
1287 createmany -o $DIR/$tdir/t- 1000
1288 do_facet $SINGLEMDS lctl set_param fail_loc=0
1290 TLOG=$DIR/$tfile.getstripe
1291 $GETSTRIPE $DIR/$tdir > $TLOG
1292 OBJS=`awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj;}' $TLOG`
1293 unlinkmany $DIR/$tdir/t- 1000
1294 [ $OBJS -gt 0 ] && \
1295 error "$OBJS objects created on OST-0. See $TLOG" || pass
1297 run_test 27u "skip object creation on OSC w/o objects =========="
1299 test_27v() { # bug 4900
1300 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1301 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1302 remote_ost_nodsh && skip "remote OST with nodsh" && return
1304 exhaust_all_precreations 0x215
1308 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1310 touch $DIR/$tdir/$tfile
1311 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1313 for (( i=1; i < OSTCOUNT; i++ )); do
1314 do_facet ost$i lctl set_param fail_loc=0x705
1316 local START=`date +%s`
1317 createmany -o $DIR/$tdir/$tfile 32
1319 local FINISH=`date +%s`
1320 local TIMEOUT=`lctl get_param -n timeout`
1321 local PROCESS=$((FINISH - START))
1322 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1323 error "$FINISH - $START >= $TIMEOUT / 2"
1324 sleep $((TIMEOUT / 2 - PROCESS))
1327 run_test 27v "skip object creation on slow OST ================="
1329 test_27w() { # bug 10997
1330 mkdir -p $DIR/$tdir || error "mkdir failed"
1331 $SETSTRIPE -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1332 [ $($GETSTRIPE -S $DIR/$tdir/f0) -ne 65536 ] &&
1333 error "stripe size $size != 65536" || true
1334 [ $($GETSTRIPE -d $DIR/$tdir | grep -c "stripe_count") -ne 1 ] &&
1335 error "$GETSTRIPE -d $DIR/$tdir failed" || true
1337 run_test 27w "check $SETSTRIPE -S option"
1340 [ "$OSTCOUNT" -lt "2" ] &&
1341 skip_env "skipping multiple stripe count/offset test" && return
1343 mkdir -p $DIR/$tdir || error "mkdir failed"
1344 for i in $(seq 1 $OSTCOUNT); do
1346 $SETSTRIPE -c $i -i $offset $DIR/$tdir/f$i ||
1347 error "setstripe -c $i -i $offset failed"
1348 count=$($GETSTRIPE -c $DIR/$tdir/f$i)
1349 index=$($GETSTRIPE -i $DIR/$tdir/f$i)
1350 [ $count -ne $i ] && error "stripe count $count != $i" || true
1351 [ $index -ne $offset ] &&
1352 error "stripe offset $index != $offset" || true
1355 run_test 27wa "check $SETSTRIPE -c -i options"
1358 remote_ost_nodsh && skip "remote OST with nodsh" && return
1359 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs" && return
1360 OFFSET=$(($OSTCOUNT - 1))
1362 local OST=$(ostname_from_index $OSTIDX)
1365 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe per file
1366 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1368 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1369 for i in `seq 0 $OFFSET`; do
1370 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}' | grep -w "$OSTIDX"` ] &&
1371 error "OST0 was degraded but new created file still use it"
1373 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1375 run_test 27x "create files while OST0 is degraded"
1378 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1379 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1380 remote_ost_nodsh && skip "remote OST with nodsh" && return
1382 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1383 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1384 osc.$mdtosc.prealloc_last_id)
1385 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1386 osc.$mdtosc.prealloc_next_id)
1387 local fcount=$((last_id - next_id))
1388 [ $fcount -eq 0 ] && skip "not enough space on OST0" && return
1389 [ $fcount -gt $OSTCOUNT ] && fcount=$OSTCOUNT
1391 MDS_OSCS=`do_facet $SINGLEMDS lctl dl | awk '/[oO][sS][cC].*md[ts]/ { print $4 }'`
1392 OFFSET=$(($OSTCOUNT-1))
1394 for OSC in $MDS_OSCS; do
1395 if [ $OST == -1 ]; then {
1396 OST=`osc_to_ost $OSC`
1398 echo $OSC "is Deactivate:"
1399 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1403 OSTIDX=$(index_from_ostuuid $OST)
1405 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1407 do_facet ost$((OSTIDX+1)) lctl set_param -n obdfilter.$OST.degraded 1
1409 createmany -o $DIR/$tdir/$tfile $fcount
1410 do_facet ost$((OSTIDX+1)) lctl set_param -n obdfilter.$OST.degraded 0
1412 for i in `seq 0 $OFFSET`; do
1413 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "$OSTIDX"` ] || \
1414 error "files created on deactivated OSTs instead of degraded OST"
1416 for OSC in $MDS_OSCS; do
1417 [ `osc_to_ost $OSC` != $OST ] && {
1418 echo $OSC "is activate"
1419 do_facet $SINGLEMDS lctl --device %$OSC activate
1423 run_test 27y "create files while OST0 is degraded and the rest inactive"
1429 lmm_count=$($GETSTRIPE -c $1)
1430 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1431 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1433 local old_ifs="$IFS"
1435 fid=($($LFS path2fid $1))
1438 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1439 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1441 # compare lmm_seq and lu_fid->f_seq
1442 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1443 # compare lmm_object_id and lu_fid->oid
1444 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1446 # check the trusted.fid attribute of the OST objects of the file
1447 local have_obdidx=false
1449 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1450 # skip lines up to and including "obdidx"
1451 [ -z "$obdidx" ] && break
1452 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1453 $have_obdidx || continue
1455 local ost=$((obdidx + 1))
1456 local dev=$(ostdevname $ost)
1458 if [ $(facet_fstype ost$ost) != ldiskfs ]; then
1459 echo "Currently only works with ldiskfs-based OSTs"
1463 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1465 #don't unmount/remount the OSTs if we don't need to do that
1466 #local dir=$(facet_mntpt ost$ost)
1468 #do_facet ost$dev mount -t $FSTYPE $dev $dir $OST_MOUNT_OPTS ||
1469 # { error "mounting $dev as $FSTYPE failed"; return 3; }
1470 #local obj_file=$(do_facet ost$ost find $dir/O/$seq -name $oid)
1471 #local ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID $obj_file)
1473 local obj_file="O/$seq/d$((oid %32))/$oid"
1474 local ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
1475 $dev 2>/dev/null" | grep "parent=")
1477 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
1479 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
1481 #do_facet ost$ost umount -d $dir
1482 #start ost$ost $dev $OST_MOUNT_OPTS
1484 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
1485 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
1486 local ff_parent=$(echo $ff|sed -e 's/.*parent=.//')
1487 local ff_pseq=$(echo $ff_parent | cut -d: -f1)
1488 local ff_poid=$(echo $ff_parent | cut -d: -f2)
1489 local ff_pstripe=$(echo $ff_parent | sed -e 's/.*stripe=//')
1491 # compare lmm_seq and filter_fid->ff_parent.f_seq
1492 [ $ff_pseq = $lmm_seq ] ||
1493 error "FF parent SEQ $ff_pseq != $lmm_seq"
1494 # compare lmm_object_id and filter_fid->ff_parent.f_oid
1495 [ $ff_poid = $lmm_oid ] ||
1496 error "FF parent OID $ff_poid != $lmm_oid"
1497 [ $ff_pstripe = $stripe_nr ] ||
1498 error "FF stripe $ff_pstripe != $stripe_nr"
1500 stripe_nr=$((stripe_nr + 1))
1505 remote_ost_nodsh && skip "remote OST with nodsh" && return
1508 $SETSTRIPE -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
1509 { error "setstripe -c -1 failed"; return 1; }
1510 # We need to send a write to every object to get parent FID info set.
1511 # This _should_ also work for setattr, but does not currently.
1512 # touch $DIR/$tdir/$tfile-1 ||
1513 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
1514 { error "dd $tfile-1 failed"; return 2; }
1515 $SETSTRIPE -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
1516 { error "setstripe -c -1 failed"; return 3; }
1517 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
1518 { error "dd $tfile-2 failed"; return 4; }
1520 # make sure write RPCs have been sent to OSTs
1523 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
1524 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
1526 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
1528 test_27A() { # b=19102
1529 local restore_size=$($GETSTRIPE -S $MOUNT)
1530 local restore_count=$($GETSTRIPE -c $MOUNT)
1531 local restore_offset=$($GETSTRIPE -i $MOUNT)
1532 $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
1533 local default_size=$($GETSTRIPE -S $MOUNT)
1534 local default_count=$($GETSTRIPE -c $MOUNT)
1535 local default_offset=$($GETSTRIPE -i $MOUNT)
1536 local dsize=$((1024 * 1024))
1537 [ $default_size -eq $dsize ] ||
1538 error "stripe size $default_size != $dsize"
1539 [ $default_count -eq 1 ] || error "stripe count $default_count != 1"
1540 [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
1541 $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
1543 run_test 27A "check filesystem-wide default LOV EA values"
1545 # createtest also checks that device nodes are created and
1546 # then visible correctly (#2091)
1547 test_28() { # bug 2091
1549 $CREATETEST $DIR/d28/ct || error
1551 run_test 28 "create/mknod/mkdir with bad file types ============"
1554 cancel_lru_locks mdc
1560 declare -i LOCKCOUNTORIG=0
1561 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1562 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
1564 [ $LOCKCOUNTORIG -eq 0 ] && echo "No mdc lock count" && return 1
1566 declare -i LOCKUNUSEDCOUNTORIG=0
1567 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1568 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
1575 declare -i LOCKCOUNTCURRENT=0
1576 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1577 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
1580 declare -i LOCKUNUSEDCOUNTCURRENT=0
1581 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1582 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
1585 if [ "$LOCKCOUNTCURRENT" -gt "$LOCKCOUNTORIG" ]; then
1586 lctl set_param -n ldlm.dump_namespaces ""
1587 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
1588 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1589 log "dumped log to $TMP/test_29.dk (bug 5793)"
1592 if [ "$LOCKUNUSEDCOUNTCURRENT" -gt "$LOCKUNUSEDCOUNTORIG" ]; then
1593 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
1594 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1595 log "dumped log to $TMP/test_29.dk (bug 5793)"
1599 run_test 29 "IT_GETATTR regression ============================"
1601 test_30a() { # was test_30
1602 cp `which ls` $DIR || cp /bin/ls $DIR
1606 run_test 30a "execute binary from Lustre (execve) =============="
1609 cp `which ls` $DIR || cp /bin/ls $DIR
1611 $RUNAS $DIR/ls / || error
1614 run_test 30b "execute binary from Lustre as non-root ==========="
1616 test_30c() { # b=22376
1617 cp `which ls` $DIR || cp /bin/ls $DIR
1619 cancel_lru_locks mdc
1620 cancel_lru_locks osc
1621 $RUNAS $DIR/ls / || error
1624 run_test 30c "execute binary from Lustre without read perms ===="
1627 $OPENUNLINK $DIR/f31 $DIR/f31 || error
1628 $CHECKSTAT -a $DIR/f31 || error
1630 run_test 31a "open-unlink file =================================="
1633 touch $DIR/f31 || error
1634 ln $DIR/f31 $DIR/f31b || error
1635 $MULTIOP $DIR/f31b Ouc || error
1636 $CHECKSTAT -t file $DIR/f31 || error
1638 run_test 31b "unlink file with multiple links while open ======="
1641 touch $DIR/f31 || error
1642 ln $DIR/f31 $DIR/f31c || error
1643 multiop_bg_pause $DIR/f31 O_uc || return 1
1645 $MULTIOP $DIR/f31c Ouc
1646 kill -USR1 $MULTIPID
1649 run_test 31c "open-unlink file with multiple links ============="
1652 opendirunlink $DIR/d31d $DIR/d31d || error
1653 $CHECKSTAT -a $DIR/d31d || error
1655 run_test 31d "remove of open directory ========================="
1657 test_31e() { # bug 2904
1658 check_kernel_version 34 || return 0
1659 openfilleddirunlink $DIR/d31e || error
1661 run_test 31e "remove of open non-empty directory ==============="
1663 test_31f() { # bug 4554
1666 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
1667 cp /etc/hosts $DIR/d31f
1669 $GETSTRIPE $DIR/d31f/hosts
1670 multiop_bg_pause $DIR/d31f D_c || return 1
1673 rm -rv $DIR/d31f || error "first of $DIR/d31f"
1675 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
1676 cp /etc/hosts $DIR/d31f
1678 $GETSTRIPE $DIR/d31f/hosts
1679 multiop_bg_pause $DIR/d31f D_c || return 1
1682 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
1683 wait $MULTIPID || error "first opendir $MULTIPID failed"
1687 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
1688 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
1691 run_test 31f "remove of open directory with open-unlink file ==="
1694 echo "-- cross directory link --"
1695 mkdir $DIR/d31g{a,b}
1697 ln $DIR/d31ga/f $DIR/d31gb/g
1698 $CHECKSTAT -t file $DIR/d31ga/f || error "source"
1699 [ `stat -c%h $DIR/d31ga/f` == '2' ] || error "source nlink"
1700 $CHECKSTAT -t file $DIR/d31gb/g || error "target"
1701 [ `stat -c%h $DIR/d31gb/g` == '2' ] || error "target nlink"
1703 run_test 31g "cross directory link==============="
1706 echo "-- cross directory link --"
1710 ln $DIR/d31h/f $DIR/d31h/dir/g
1711 $CHECKSTAT -t file $DIR/d31h/f || error "source"
1712 [ `stat -c%h $DIR/d31h/f` == '2' ] || error "source nlink"
1713 $CHECKSTAT -t file $DIR/d31h/dir/g || error "target"
1714 [ `stat -c%h $DIR/d31h/dir/g` == '2' ] || error "target nlink"
1716 run_test 31h "cross directory link under child==============="
1719 echo "-- cross directory link --"
1722 touch $DIR/d31i/dir/f
1723 ln $DIR/d31i/dir/f $DIR/d31i/g
1724 $CHECKSTAT -t file $DIR/d31i/dir/f || error "source"
1725 [ `stat -c%h $DIR/d31i/dir/f` == '2' ] || error "source nlink"
1726 $CHECKSTAT -t file $DIR/d31i/g || error "target"
1727 [ `stat -c%h $DIR/d31i/g` == '2' ] || error "target nlink"
1729 run_test 31i "cross directory link under parent==============="
1734 mkdir $DIR/d31j/dir1
1735 ln $DIR/d31j/dir1 $DIR/d31j/dir2 && error "ln for dir"
1736 link $DIR/d31j/dir1 $DIR/d31j/dir3 && error "link for dir"
1737 mlink $DIR/d31j/dir1 $DIR/d31j/dir4 && error "mlink for dir"
1738 mlink $DIR/d31j/dir1 $DIR/d31j/dir1 && error "mlink to the same dir"
1741 run_test 31j "link for directory==============="
1747 touch $DIR/d31k/exist
1748 mlink $DIR/d31k/s $DIR/d31k/t || error "mlink"
1749 mlink $DIR/d31k/s $DIR/d31k/exist && error "mlink to exist file"
1750 mlink $DIR/d31k/s $DIR/d31k/s && error "mlink to the same file"
1751 mlink $DIR/d31k/s $DIR/d31k && error "mlink to parent dir"
1752 mlink $DIR/d31k $DIR/d31k/s && error "mlink parent dir to target"
1753 mlink $DIR/d31k/not-exist $DIR/d31k/foo && error "mlink non-existing to new"
1754 mlink $DIR/d31k/not-exist $DIR/d31k/s && error "mlink non-existing to exist"
1757 run_test 31k "link to file: the same, non-existing, dir==============="
1763 touch $DIR/d31m2/exist
1764 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
1765 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
1766 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
1767 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
1768 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
1769 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
1772 run_test 31m "link to file: the same, non-existing, dir==============="
1774 cleanup_test32_mount() {
1776 $UMOUNT $DIR/$tdir/ext2-mountpoint
1780 echo "== more mountpoints and symlinks ================="
1781 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
1782 trap cleanup_test32_mount EXIT
1783 mkdir -p $DIR/$tdir/ext2-mountpoint
1784 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
1785 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. || error
1786 cleanup_test32_mount
1788 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
1791 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
1792 trap cleanup_test32_mount EXIT
1793 mkdir -p $DIR/$tdir/ext2-mountpoint
1794 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
1795 ls -al $DIR/$tdir/ext2-mountpoint/.. || error
1796 cleanup_test32_mount
1798 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
1801 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
1802 trap cleanup_test32_mount EXIT
1803 mkdir -p $DIR/$tdir/ext2-mountpoint
1804 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
1805 mkdir -p $DIR/$tdir/d2/test_dir
1806 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
1807 cleanup_test32_mount
1809 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
1812 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
1813 trap cleanup_test32_mount EXIT
1814 mkdir -p $DIR/$tdir/ext2-mountpoint
1815 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
1816 mkdir -p $DIR/$tdir/d2/test_dir
1817 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
1818 cleanup_test32_mount
1820 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
1823 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
1824 mkdir -p $DIR/d32e/tmp
1825 TMP_DIR=$DIR/d32e/tmp
1826 ln -s $DIR/d32e $TMP_DIR/symlink11
1827 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1828 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
1829 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
1831 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
1834 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
1835 mkdir -p $DIR/d32f/tmp
1836 TMP_DIR=$DIR/d32f/tmp
1837 ln -s $DIR/d32f $TMP_DIR/symlink11
1838 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1839 ls $DIR/d32f/tmp/symlink11 || error
1840 ls $DIR/d32f/symlink01 || error
1842 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
1845 TMP_DIR=$DIR/$tdir/tmp
1846 mkdir -p $TMP_DIR $DIR/${tdir}2
1847 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
1848 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1849 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
1850 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
1851 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
1852 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
1854 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
1857 rm -fr $DIR/$tdir $DIR/${tdir}2
1858 TMP_DIR=$DIR/$tdir/tmp
1859 mkdir -p $TMP_DIR $DIR/${tdir}2
1860 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
1861 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1862 ls $TMP_DIR/symlink12 || error
1863 ls $DIR/$tdir/symlink02 || error
1865 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
1868 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
1869 trap cleanup_test32_mount EXIT
1870 mkdir -p $DIR/$tdir/ext2-mountpoint
1871 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
1872 touch $DIR/$tdir/test_file
1873 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file || error
1874 cleanup_test32_mount
1876 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
1879 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
1880 trap cleanup_test32_mount EXIT
1881 mkdir -p $DIR/$tdir/ext2-mountpoint
1882 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
1883 touch $DIR/$tdir/test_file
1884 cat $DIR/$tdir/ext2-mountpoint/../test_file || error
1885 cleanup_test32_mount
1887 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
1891 trap cleanup_test32_mount EXIT
1892 mkdir -p $DIR/$tdir/ext2-mountpoint
1893 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
1894 mkdir -p $DIR/$tdir/d2
1895 touch $DIR/$tdir/d2/test_file || error
1896 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
1897 cleanup_test32_mount
1899 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
1903 trap cleanup_test32_mount EXIT
1904 mkdir -p $DIR/$tdir/ext2-mountpoint
1905 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
1906 mkdir -p $DIR/$tdir/d2
1907 touch $DIR/$tdir/d2/test_file
1908 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
1909 cleanup_test32_mount
1911 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
1915 mkdir -p $DIR/d32m/tmp
1916 TMP_DIR=$DIR/d32m/tmp
1917 ln -s $DIR $TMP_DIR/symlink11
1918 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1919 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
1920 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
1922 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
1926 mkdir -p $DIR/d32n/tmp
1927 TMP_DIR=$DIR/d32n/tmp
1928 ln -s $DIR $TMP_DIR/symlink11
1929 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
1930 ls -l $DIR/d32n/tmp/symlink11 || error
1931 ls -l $DIR/d32n/symlink01 || error
1933 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
1936 rm -fr $DIR/d32o $DIR/$tfile
1938 mkdir -p $DIR/d32o/tmp
1939 TMP_DIR=$DIR/d32o/tmp
1940 ln -s $DIR/$tfile $TMP_DIR/symlink12
1941 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1942 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
1943 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
1944 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
1945 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
1947 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
1957 mkdir -p $DIR/d32p/tmp
1959 TMP_DIR=$DIR/d32p/tmp
1961 ln -s $DIR/$tfile $TMP_DIR/symlink12
1963 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
1965 cat $DIR/d32p/tmp/symlink12 || error
1967 cat $DIR/d32p/symlink02 || error
1970 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
1972 cleanup_testdir_mount() {
1978 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
1979 trap cleanup_testdir_mount EXIT
1981 touch $DIR/$tdir/under_the_mount
1982 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
1983 ls $DIR/$tdir | grep "\<under_the_mount\>" && error
1984 cleanup_testdir_mount
1986 run_test 32q "stat follows mountpoints in Lustre (should return error)"
1989 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
1990 trap cleanup_testdir_mount EXIT
1992 touch $DIR/$tdir/under_the_mount
1993 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
1994 ls $DIR/$tdir | grep -q under_the_mount && error || true
1995 cleanup_testdir_mount
1997 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
2002 chmod 444 $DIR/$tfile
2003 chown $RUNAS_ID $DIR/$tfile
2005 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2008 run_test 33 "write file with mode 444 (should return error) ===="
2013 chown $RUNAS_ID $DIR/d33
2014 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
2015 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
2016 error "open RDWR" || true
2018 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
2023 chown $RUNAS_ID $DIR/d33
2024 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33 && error "create" || true
2026 run_test 33b "test open file with malformed flags (No panic and return error)"
2034 remote_ost_nodsh && skip "remote OST with nodsh" && return
2038 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2041 for ostnum in $(seq $OSTCOUNT); do
2042 # test-framework's OST numbering is one-based, while Lustre's
2044 ostname=$(printf "$FSNAME-OST%.4d" $((ostnum - 1)))
2045 # Parsing llobdstat's output sucks; we could grep the /proc
2046 # path, but that's likely to not be as portable as using the
2047 # llobdstat utility. So we parse lctl output instead.
2048 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2049 obdfilter/$ostname/stats |
2050 awk '/^write_bytes/ {print $7}' )
2051 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2052 if (( ${write_bytes:-0} > 0 ))
2059 $all_zeros || return 0
2062 echo foo > $DIR/d33/bar
2066 # Total up write_bytes after writing. We'd better find non-zeros.
2067 for ostnum in $(seq $OSTCOUNT); do
2068 ostname=$(printf "$FSNAME-OST%.4d" $((ostnum - 1)))
2069 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2070 obdfilter/$ostname/stats |
2071 awk '/^write_bytes/ {print $7}' )
2072 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2073 if (( ${write_bytes:-0} > 0 ))
2082 for ostnum in $(seq $OSTCOUNT); do
2083 ostname=$(printf "$FSNAME-OST%.4d" $((ostnum - 1)))
2084 echo "Check that write_bytes is present in obdfilter/*/stats:"
2085 do_facet ost$ostnum lctl get_param -n \
2086 obdfilter/$ostname/stats
2088 error "OST not keeping write_bytes stats (b22312)"
2091 run_test 33c "test llobdstat and write_bytes"
2093 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
2096 $MCREATE $DIR/f34 || error
2097 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2098 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
2099 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2100 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2102 run_test 34a "truncate file that has not been opened ==========="
2105 [ ! -f $DIR/f34 ] && test_34a
2106 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2107 $OPENFILE -f O_RDONLY $DIR/f34
2108 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2109 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2111 run_test 34b "O_RDONLY opening file doesn't create objects ====="
2114 [ ! -f $DIR/f34 ] && test_34a
2115 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2116 $OPENFILE -f O_RDWR $DIR/f34
2117 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2118 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2120 run_test 34c "O_RDWR opening file-with-size works =============="
2123 [ ! -f $DIR/f34 ] && test_34a
2124 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2125 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2128 run_test 34d "write to sparse file ============================="
2132 $MCREATE $DIR/f34e || error
2133 $TRUNCATE $DIR/f34e 1000 || error
2134 $CHECKSTAT -s 1000 $DIR/f34e || error
2135 $OPENFILE -f O_RDWR $DIR/f34e
2136 $CHECKSTAT -s 1000 $DIR/f34e || error
2138 run_test 34e "create objects, some with size and some without =="
2140 test_34f() { # bug 6242, 6243
2143 $MCREATE $DIR/f34f || error
2144 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
2145 dd if=$DIR/f34f of=$TMP/f34f
2146 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
2147 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
2148 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
2149 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
2150 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
2152 run_test 34f "read from a file with no objects until EOF ======="
2155 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
2156 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
2157 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
2158 cancel_lru_locks osc
2159 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
2160 error "wrong size after lock cancel"
2162 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
2163 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2164 error "expanding truncate failed"
2165 cancel_lru_locks osc
2166 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2167 error "wrong expanded size after lock cancel"
2169 run_test 34g "truncate long file ==============================="
2175 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
2176 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
2180 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
2181 error "Multiop blocked on ftruncate, pid=$MULTIPID"
2185 local nsz=`stat -c %s $DIR/$tfile`
2186 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
2188 run_test 34h "ftruncate file under grouplock should not block"
2191 cp /bin/sh $DIR/f35a
2193 chown $RUNAS_ID $DIR/f35a
2194 $RUNAS $DIR/f35a && error || true
2197 run_test 35a "exec file with mode 444 (should return and not leak) ====="
2201 utime $DIR/f36 || error
2203 run_test 36a "MDS utime check (mknod, utime) ==================="
2207 utime $DIR/f36 || error
2209 run_test 36b "OST utime check (open, utime) ===================="
2214 chown $RUNAS_ID $DIR/d36
2215 $RUNAS utime $DIR/d36/f36 || error
2217 run_test 36c "non-root MDS utime check (mknod, utime) =========="
2220 [ ! -d $DIR/d36 ] && test_36c
2221 echo "" > $DIR/d36/f36
2222 $RUNAS utime $DIR/d36/f36 || error
2224 run_test 36d "non-root OST utime check (open, utime) ==========="
2227 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
2229 touch $DIR/$tdir/$tfile
2230 $RUNAS utime $DIR/$tdir/$tfile && \
2231 error "utime worked, expected failure" || true
2233 run_test 36e "utime on non-owned file (should return error) ===="
2237 local LANG_SAVE=$LANG
2238 local LC_LANG_SAVE=$LC_LANG
2239 export LANG=C LC_LANG=C # for date language
2241 DATESTR="Dec 20 2000"
2243 lctl set_param fail_loc=$fl
2245 cp /etc/hosts $DIR/$tdir/$tfile
2246 sync & # write RPC generated with "current" inode timestamp, but delayed
2248 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
2249 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
2250 cancel_lru_locks osc
2251 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
2253 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
2254 echo "BEFORE: $LS_BEFORE" && \
2255 echo "AFTER : $LS_AFTER" && \
2256 echo "WANT : $DATESTR" && \
2257 error "$DIR/$tdir/$tfile timestamps changed" || true
2259 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
2263 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2264 subr_36fh "0x80000214"
2266 run_test 36f "utime on file racing with OST BRW write =========="
2269 remote_ost_nodsh && skip "remote OST with nodsh" && return
2275 fmd_max_age=$(do_facet ost1 \
2276 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
2279 fmd_before=$(do_facet ost1 \
2280 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2281 touch $DIR/$tdir/$tfile
2282 sleep $((fmd_max_age + 12))
2283 fmd_after=$(do_facet ost1 \
2284 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2286 echo "fmd_before: $fmd_before"
2287 echo "fmd_after: $fmd_after"
2288 [ "$fmd_after" -gt "$fmd_before" ] && \
2289 echo "AFTER: $fmd_after > BEFORE: $fmd_before" && \
2290 error "fmd didn't expire after ping" || true
2292 run_test 36g "filter mod data cache expiry ====================="
2295 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
2296 subr_36fh "0x80000227"
2298 run_test 36h "utime on file racing with OST BRW write =========="
2300 # test_37 - duplicate with tests 32q 32r
2303 local file=$DIR/$tfile
2305 openfile -f O_DIRECTORY $file
2308 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
2309 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
2311 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
2315 touch $DIR/${tfile}2
2316 # ls -l $DIR/$tfile $DIR/${tfile}2
2317 # ls -lu $DIR/$tfile $DIR/${tfile}2
2318 # ls -lc $DIR/$tfile $DIR/${tfile}2
2320 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
2321 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
2323 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
2325 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
2327 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
2328 error "O_TRUNC didn't change timestamps"
2331 run_test 39 "mtime changed on create ==========================="
2335 cp -p /etc/passwd $DIR/$tdir/fopen
2336 cp -p /etc/passwd $DIR/$tdir/flink
2337 cp -p /etc/passwd $DIR/$tdir/funlink
2338 cp -p /etc/passwd $DIR/$tdir/frename
2339 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
2342 echo "aaaaaa" >> $DIR/$tdir/fopen
2343 echo "aaaaaa" >> $DIR/$tdir/flink
2344 echo "aaaaaa" >> $DIR/$tdir/funlink
2345 echo "aaaaaa" >> $DIR/$tdir/frename
2347 local open_new=`stat -c %Y $DIR/$tdir/fopen`
2348 local link_new=`stat -c %Y $DIR/$tdir/flink`
2349 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
2350 local rename_new=`stat -c %Y $DIR/$tdir/frename`
2352 cat $DIR/$tdir/fopen > /dev/null
2353 ln $DIR/$tdir/flink $DIR/$tdir/flink2
2354 rm -f $DIR/$tdir/funlink2
2355 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
2357 for (( i=0; i < 2; i++ )) ; do
2358 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
2359 local link_new2=`stat -c %Y $DIR/$tdir/flink`
2360 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
2361 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
2363 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
2364 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
2365 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
2366 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
2368 cancel_lru_locks osc
2369 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2372 run_test 39b "mtime change on open, link, unlink, rename ======"
2374 # this should be set to past
2375 TEST_39_MTIME=`date -d "1 year ago" +%s`
2381 local mtime0=`stat -c %Y $DIR1/$tfile`
2383 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2384 local mtime1=`stat -c %Y $DIR1/$tfile`
2385 [ "$mtime1" = $TEST_39_MTIME ] || \
2386 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
2389 echo hello >> $DIR1/$tfile
2391 local mtime2=`stat -c %Y $DIR1/$tfile`
2392 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
2393 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
2395 mv $DIR1/$tfile $DIR1/$tfile-1
2397 for (( i=0; i < 2; i++ )) ; do
2398 local mtime3=`stat -c %Y $DIR1/$tfile-1`
2399 [ "$mtime2" = "$mtime3" ] || \
2400 error "mtime ($mtime2) changed (to $mtime3) on rename"
2402 cancel_lru_locks osc
2403 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2406 run_test 39c "mtime change on rename ==========================="
2412 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2414 for (( i=0; i < 2; i++ )) ; do
2415 local mtime=`stat -c %Y $DIR1/$tfile`
2416 [ $mtime = $TEST_39_MTIME ] || \
2417 error "mtime($mtime) is not set to $TEST_39_MTIME"
2419 cancel_lru_locks osc
2420 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2423 run_test 39d "create, utime, stat =============================="
2428 local mtime1=`stat -c %Y $DIR1/$tfile`
2430 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2432 for (( i=0; i < 2; i++ )) ; do
2433 local mtime2=`stat -c %Y $DIR1/$tfile`
2434 [ $mtime2 = $TEST_39_MTIME ] || \
2435 error "mtime($mtime2) is not set to $TEST_39_MTIME"
2437 cancel_lru_locks osc
2438 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2441 run_test 39e "create, stat, utime, stat ========================"
2446 mtime1=`stat -c %Y $DIR1/$tfile`
2449 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2451 for (( i=0; i < 2; i++ )) ; do
2452 local mtime2=`stat -c %Y $DIR1/$tfile`
2453 [ $mtime2 = $TEST_39_MTIME ] || \
2454 error "mtime($mtime2) is not set to $TEST_39_MTIME"
2456 cancel_lru_locks osc
2457 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2460 run_test 39f "create, stat, sleep, utime, stat ================="
2464 echo hello >> $DIR1/$tfile
2465 local mtime1=`stat -c %Y $DIR1/$tfile`
2468 chmod o+r $DIR1/$tfile
2470 for (( i=0; i < 2; i++ )) ; do
2471 local mtime2=`stat -c %Y $DIR1/$tfile`
2472 [ "$mtime1" = "$mtime2" ] || \
2473 error "lost mtime: $mtime2, should be $mtime1"
2475 cancel_lru_locks osc
2476 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2479 run_test 39g "write, chmod, stat ==============================="
2487 echo hello >> $DIR1/$tfile
2488 local mtime1=`stat -c %Y $DIR1/$tfile`
2490 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2492 if [ "$d1" != "$d2" ]; then
2493 echo "write and touch not within one second"
2495 for (( i=0; i < 2; i++ )) ; do
2496 local mtime2=`stat -c %Y $DIR1/$tfile`
2497 [ "$mtime2" = $TEST_39_MTIME ] || \
2498 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
2500 cancel_lru_locks osc
2501 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2505 run_test 39h "write, utime within one second, stat ============="
2511 echo hello >> $DIR1/$tfile
2512 local mtime1=`stat -c %Y $DIR1/$tfile`
2514 mv $DIR1/$tfile $DIR1/$tfile-1
2516 for (( i=0; i < 2; i++ )) ; do
2517 local mtime2=`stat -c %Y $DIR1/$tfile-1`
2519 [ "$mtime1" = "$mtime2" ] || \
2520 error "lost mtime: $mtime2, should be $mtime1"
2522 cancel_lru_locks osc
2523 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2526 run_test 39i "write, rename, stat =============================="
2529 start_full_debug_logging
2533 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
2534 lctl set_param fail_loc=0x80000412
2535 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
2536 error "multiop failed"
2538 local mtime1=`stat -c %Y $DIR1/$tfile`
2540 mv $DIR1/$tfile $DIR1/$tfile-1
2542 kill -USR1 $multipid
2543 wait $multipid || error "multiop close failed"
2545 for (( i=0; i < 2; i++ )) ; do
2546 local mtime2=`stat -c %Y $DIR1/$tfile-1`
2547 [ "$mtime1" = "$mtime2" ] ||
2548 error "mtime is lost on close: $mtime2, " \
2551 cancel_lru_locks osc
2552 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2554 lctl set_param fail_loc=0
2555 stop_full_debug_logging
2557 run_test 39j "write, rename, close, stat ======================="
2563 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
2565 local mtime1=`stat -c %Y $DIR1/$tfile`
2567 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2569 kill -USR1 $multipid
2570 wait $multipid || error "multiop close failed"
2572 for (( i=0; i < 2; i++ )) ; do
2573 local mtime2=`stat -c %Y $DIR1/$tfile`
2575 [ "$mtime2" = $TEST_39_MTIME ] || \
2576 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
2578 cancel_lru_locks osc
2579 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2582 run_test 39k "write, utime, close, stat ========================"
2584 # this should be set to future
2585 TEST_39_ATIME=`date -d "1 year" +%s`
2587 is_sles11() # LU-1783
2589 if [ -r /etc/SuSE-release ]
2591 local vers=`grep VERSION /etc/SuSE-release | awk '{print $3}'`
2592 local patchlev=`grep PATCHLEVEL /etc/SuSE-release \
2594 if [ $vers -eq 11 ] && [ $patchlev -eq 1 ]
2603 is_sles11 && skip "SLES 11 SP1" && return # LU-1783
2604 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2605 local atime_diff=$(do_facet $SINGLEMDS lctl get_param -n mdd.*.atime_diff)
2609 # test setting directory atime to future
2610 touch -a -d @$TEST_39_ATIME $DIR/$tdir
2611 local atime=$(stat -c %X $DIR/$tdir)
2612 [ "$atime" = $TEST_39_ATIME ] || \
2613 error "atime is not set to future: $atime, should be $TEST_39_ATIME"
2615 # test setting directory atime from future to now
2616 local d1=$(date +%s)
2618 local d2=$(date +%s)
2620 cancel_lru_locks mdc
2621 atime=$(stat -c %X $DIR/$tdir)
2622 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
2623 error "atime is not updated from future: $atime, should be $d1<atime<$d2"
2625 do_facet $SINGLEMDS lctl set_param -n mdd.*.atime_diff=2
2628 # test setting directory atime when now > dir atime + atime_diff
2632 cancel_lru_locks mdc
2633 atime=$(stat -c %X $DIR/$tdir)
2634 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
2635 error "atime is not updated : $atime, should be $d2"
2637 do_facet $SINGLEMDS lctl set_param -n mdd.*.atime_diff=60
2640 # test not setting directory atime when now < dir atime + atime_diff
2642 cancel_lru_locks mdc
2643 atime=$(stat -c %X $DIR/$tdir)
2644 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
2645 error "atime is updated to $atime, should remain $d1<atime<$d2"
2647 do_facet $SINGLEMDS lctl set_param -n mdd.*.atime_diff=$atime_diff
2649 run_test 39l "directory atime update ==========================="
2654 local far_past_mtime=$(date -d "May 29 1953" +%s)
2655 local far_past_atime=$(date -d "Dec 17 1903" +%s)
2657 touch -m -d @$far_past_mtime $DIR1/$tfile
2658 touch -a -d @$far_past_atime $DIR1/$tfile
2660 for (( i=0; i < 2; i++ )) ; do
2661 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
2662 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
2663 error "atime or mtime set incorrectly"
2665 cancel_lru_locks osc
2666 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2669 run_test 39m "test atime and mtime before 1970"
2672 dd if=/dev/zero of=$DIR/f40 bs=4096 count=1
2673 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/f40 && error
2674 $CHECKSTAT -t file -s 4096 $DIR/f40 || error
2676 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
2680 small_write $DIR/f41 18
2682 run_test 41 "test small file write + fstat ====================="
2684 count_ost_writes() {
2685 lctl get_param -n osc.*.stats |
2686 awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }'
2693 BG_DIRTY_RATIO_SAVE=10
2694 MAX_BG_DIRTY_RATIO=25
2698 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
2699 # dirty_ratio, dirty_background_ratio
2700 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
2701 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
2702 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
2703 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
2705 # if file not here, we are a 2.4 kernel
2706 kill -CONT `pidof kupdated`
2711 # setup the trap first, so someone cannot exit the test at the
2712 # exact wrong time and mess up a machine
2713 trap start_writeback EXIT
2714 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
2715 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
2716 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
2717 sysctl -w vm.dirty_writeback_centisecs=0
2718 sysctl -w vm.dirty_writeback_centisecs=0
2719 # save and increase /proc/sys/vm/dirty_ratio
2720 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
2721 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
2722 # save and increase /proc/sys/vm/dirty_background_ratio
2723 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
2724 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
2726 # if file not here, we are a 2.4 kernel
2727 kill -STOP `pidof kupdated`
2731 # ensure that all stripes have some grant before we test client-side cache
2733 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
2734 dd if=/dev/zero of=$i bs=4k count=1
2739 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
2740 # file truncation, and file removal.
2743 cancel_lru_locks osc
2745 sync; sleep 1; sync # just to be safe
2746 BEFOREWRITES=`count_ost_writes`
2747 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
2748 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
2749 AFTERWRITES=`count_ost_writes`
2750 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
2751 error "$BEFOREWRITES < $AFTERWRITES"
2754 run_test 42a "ensure that we don't flush on close =============="
2758 cancel_lru_locks osc
2761 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
2762 BEFOREWRITES=`count_ost_writes`
2763 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
2764 AFTERWRITES=`count_ost_writes`
2765 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
2766 error "$BEFOREWRITES < $AFTERWRITES on unlink"
2768 BEFOREWRITES=`count_ost_writes`
2769 sync || error "sync: $?"
2770 AFTERWRITES=`count_ost_writes`
2771 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
2772 error "$BEFOREWRITES < $AFTERWRITES on sync"
2774 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
2778 run_test 42b "test destroy of file with cached dirty data ======"
2780 # if these tests just want to test the effect of truncation,
2781 # they have to be very careful. consider:
2782 # - the first open gets a {0,EOF}PR lock
2783 # - the first write conflicts and gets a {0, count-1}PW
2784 # - the rest of the writes are under {count,EOF}PW
2785 # - the open for truncate tries to match a {0,EOF}PR
2786 # for the filesize and cancels the PWs.
2787 # any number of fixes (don't get {0,EOF} on open, match
2788 # composite locks, do smarter file size management) fix
2789 # this, but for now we want these tests to verify that
2790 # the cancellation with truncate intent works, so we
2791 # start the file with a full-file pw lock to match against
2792 # until the truncate.
2797 cancel_lru_locks osc
2799 # prime the file with 0,EOF PW to match
2803 # now the real test..
2804 dd if=/dev/zero of=$file bs=1024 count=100
2805 BEFOREWRITES=`count_ost_writes`
2806 $TRUNCATE $file $offset
2807 cancel_lru_locks osc
2808 AFTERWRITES=`count_ost_writes`
2814 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
2815 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
2818 run_test 42c "test partial truncate of file with cached dirty data"
2822 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
2823 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
2826 run_test 42d "test complete truncate of file with cached dirty data"
2828 test_42e() { # bug22074
2829 local TDIR=$DIR/${tdir}e
2830 local pagesz=$(page_size)
2831 local pages=16 # hardcoded 16 pages, don't change it.
2832 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
2833 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
2838 $SETSTRIPE -c 1 $TDIR
2839 createmany -o $TDIR/f $files
2841 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
2843 # we assume that with $OSTCOUNT files, at least one of them will
2844 # be allocated on OST0.
2845 warmup_files=$((OSTCOUNT * max_dirty_mb))
2846 createmany -o $TDIR/w $warmup_files
2848 # write a large amount of data into one file and sync, to get good
2849 # avail_grant number from OST.
2850 for ((i=0; i<$warmup_files; i++)); do
2851 idx=$($GETSTRIPE -i $TDIR/w$i)
2852 [ $idx -ne 0 ] && continue
2853 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
2856 [ $i -gt $warmup_files ] && error "OST0 is still cold"
2858 $LCTL get_param $proc_osc0/cur_dirty_bytes
2859 $LCTL get_param $proc_osc0/cur_grant_bytes
2861 # create as much dirty pages as we can while not to trigger the actual
2862 # RPCs directly. but depends on the env, VFS may trigger flush during this
2863 # period, hopefully we are good.
2864 for ((i=0; i<$warmup_files; i++)); do
2865 idx=$($GETSTRIPE -i $TDIR/w$i)
2866 [ $idx -ne 0 ] && continue
2867 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
2869 $LCTL get_param $proc_osc0/cur_dirty_bytes
2870 $LCTL get_param $proc_osc0/cur_grant_bytes
2872 # perform the real test
2873 $LCTL set_param $proc_osc0/rpc_stats 0
2874 for ((;i<$files; i++)); do
2875 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
2876 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
2879 $LCTL get_param $proc_osc0/rpc_stats
2882 local have_ppr=false
2883 $LCTL get_param $proc_osc0/rpc_stats |
2884 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
2885 # skip lines until we are at the RPC histogram data
2886 [ "$PPR" == "pages" ] && have_ppr=true && continue
2887 $have_ppr || continue
2889 # we only want the percent stat for < 16 pages
2890 [ $(echo $PPR | tr -d ':') -ge $pages ] && break
2892 percent=$((percent + WPCT))
2893 if [ $percent -gt 15 ]; then
2894 error "less than 16-pages write RPCs" \
2901 run_test 42e "verify sub-RPC writes are not done synchronously"
2905 cp -p /bin/ls $DIR/$tdir/$tfile
2906 $MULTIOP $DIR/$tdir/$tfile Ow_c &
2908 # give multiop a chance to open
2911 $DIR/$tdir/$tfile && error || true
2914 run_test 43 "execution of file opened for write should return -ETXTBSY"
2918 cp -p `which $MULTIOP` $DIR/d43/multiop || cp -p multiop $DIR/d43/multiop
2919 MULTIOP_PROG=$DIR/d43/multiop multiop_bg_pause $TMP/test43.junk O_c || return 1
2921 $MULTIOP $DIR/d43/multiop Oc && error "expected error, got success"
2922 kill -USR1 $MULTIOP_PID || return 2
2923 wait $MULTIOP_PID || return 3
2926 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
2930 cp -p `which $MULTIOP` $DIR/d43/multiop || cp -p multiop $DIR/d43/multiop
2931 MULTIOP_PROG=$DIR/d43/multiop multiop_bg_pause $TMP/test43.junk O_c || return 1
2933 $TRUNCATE $DIR/d43/multiop 0 && error "expected error, got success"
2934 kill -USR1 $MULTIOP_PID || return 2
2935 wait $MULTIOP_PID || return 3
2938 run_test 43b "truncate of file being executed should return -ETXTBSY"
2941 local testdir="$DIR/d43c"
2944 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
2945 ( cd $testdir && md5sum -c)
2947 run_test 43c "md5sum of copy into lustre========================"
2950 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
2951 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
2952 dd if=$DIR/f1 bs=4k count=1 > /dev/null
2954 run_test 44 "zero length read from a sparse stripe ============="
2957 local nstripe=`$LCTL lov_getconfig $DIR | grep default_stripe_count: | \
2959 [ -z "$nstripe" ] && skip "can't get stripe info" && return
2960 [ "$nstripe" -gt "$OSTCOUNT" ] && skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" && return
2961 local stride=`$LCTL lov_getconfig $DIR | grep default_stripe_size: | \
2963 if [ $nstripe -eq 0 -o $nstripe -eq -1 ] ; then
2964 nstripe=`$LCTL lov_getconfig $DIR | grep obd_count: | awk '{print $2}'`
2967 OFFSETS="0 $((stride/2)) $((stride-1))"
2968 for offset in $OFFSETS ; do
2969 for i in `seq 0 $((nstripe-1))`; do
2970 local GLOBALOFFSETS=""
2971 local size=$((((i + 2 * $nstripe )*$stride + $offset))) # Bytes
2972 local myfn=$DIR/d44a-$size
2973 echo "--------writing $myfn at $size"
2974 ll_sparseness_write $myfn $size || error "ll_sparseness_write"
2975 GLOBALOFFSETS="$GLOBALOFFSETS $size"
2976 ll_sparseness_verify $myfn $GLOBALOFFSETS \
2977 || error "ll_sparseness_verify $GLOBALOFFSETS"
2979 for j in `seq 0 $((nstripe-1))`; do
2980 size=$((((j + $nstripe )*$stride + $offset))) # Bytes
2981 ll_sparseness_write $myfn $size || error "ll_sparseness_write"
2982 GLOBALOFFSETS="$GLOBALOFFSETS $size"
2984 ll_sparseness_verify $myfn $GLOBALOFFSETS \
2985 || error "ll_sparseness_verify $GLOBALOFFSETS"
2990 run_test 44a "test sparse pwrite ==============================="
2994 for d in `lctl get_param -n osc.*.cur_dirty_bytes`; do
3000 before=`dirty_osc_total`
3001 echo executing "\"$*\""
3003 after=`dirty_osc_total`
3004 echo before $before, after $after
3008 # Obtain grants from OST if it supports it
3009 echo blah > ${f}_grant
3012 do_dirty_record "echo blah > $f"
3013 [ $before -eq $after ] && error "write wasn't cached"
3014 do_dirty_record "> $f"
3015 [ $before -gt $after ] || error "truncate didn't lower dirty count"
3016 do_dirty_record "echo blah > $f"
3017 [ $before -eq $after ] && error "write wasn't cached"
3018 do_dirty_record "sync"
3019 [ $before -gt $after ] || error "writeback didn't lower dirty count"
3020 do_dirty_record "echo blah > $f"
3021 [ $before -eq $after ] && error "write wasn't cached"
3022 do_dirty_record "cancel_lru_locks osc"
3023 [ $before -gt $after ] || error "lock cancellation didn't lower dirty count"
3026 run_test 45 "osc io page accounting ============================"
3028 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
3029 # test tickles a bug where re-dirtying a page was failing to be mapped to the
3030 # objects offset and an assert hit when an rpc was built with 1023's mapped
3031 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
3036 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3038 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
3039 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3043 run_test 46 "dirtying a previously written page ================"
3045 # test_47 is removed "Device nodes check" is moved to test_28
3047 test_48a() { # bug 2399
3048 check_kernel_version 34 || return 0
3051 mv $DIR/d48a $DIR/d48.new || error "move directory failed"
3052 mkdir $DIR/d48a || error "recreate directory failed"
3053 touch foo || error "'touch foo' failed after recreating cwd"
3054 mkdir bar || error "'mkdir foo' failed after recreating cwd"
3055 if check_kernel_version 44; then
3056 touch .foo || error "'touch .foo' failed after recreating cwd"
3057 mkdir .bar || error "'mkdir .foo' failed after recreating cwd"
3059 ls . > /dev/null || error "'ls .' failed after recreating cwd"
3060 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3061 cd . || error "'cd .' failed after recreating cwd"
3062 mkdir . && error "'mkdir .' worked after recreating cwd"
3063 rmdir . && error "'rmdir .' worked after recreating cwd"
3064 ln -s . baz || error "'ln -s .' failed after recreating cwd"
3065 cd .. || error "'cd ..' failed after recreating cwd"
3067 run_test 48a "Access renamed working dir (should return errors)="
3069 test_48b() { # bug 2399
3070 check_kernel_version 34 || return 0
3073 rmdir $DIR/d48b || error "remove cwd $DIR/d48b failed"
3074 touch foo && error "'touch foo' worked after removing cwd"
3075 mkdir foo && error "'mkdir foo' worked after removing cwd"
3076 if check_kernel_version 44; then
3077 touch .foo && error "'touch .foo' worked after removing cwd"
3078 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
3080 ls . > /dev/null && error "'ls .' worked after removing cwd"
3081 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3082 is_patchless || ( cd . && error "'cd .' worked after removing cwd" )
3083 mkdir . && error "'mkdir .' worked after removing cwd"
3084 rmdir . && error "'rmdir .' worked after removing cwd"
3085 ln -s . foo && error "'ln -s .' worked after removing cwd"
3086 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
3088 run_test 48b "Access removed working dir (should return errors)="
3090 test_48c() { # bug 2350
3091 check_kernel_version 36 || return 0
3092 #lctl set_param debug=-1
3094 mkdir -p $DIR/d48c/dir
3096 $TRACE rmdir $DIR/d48c/dir || error "remove cwd $DIR/d48c/dir failed"
3097 $TRACE touch foo && error "'touch foo' worked after removing cwd"
3098 $TRACE mkdir foo && error "'mkdir foo' worked after removing cwd"
3099 if check_kernel_version 44; then
3100 touch .foo && error "'touch .foo' worked after removing cwd"
3101 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
3103 $TRACE ls . && error "'ls .' worked after removing cwd"
3104 $TRACE ls .. || error "'ls ..' failed after removing cwd"
3105 is_patchless || ( $TRACE cd . && error "'cd .' worked after removing cwd" )
3106 $TRACE mkdir . && error "'mkdir .' worked after removing cwd"
3107 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
3108 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
3109 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
3111 run_test 48c "Access removed working subdir (should return errors)"
3113 test_48d() { # bug 2350
3114 check_kernel_version 36 || return 0
3115 #lctl set_param debug=-1
3117 mkdir -p $DIR/d48d/dir
3119 $TRACE rmdir $DIR/d48d/dir || error "remove cwd $DIR/d48d/dir failed"
3120 $TRACE rmdir $DIR/d48d || error "remove parent $DIR/d48d failed"
3121 $TRACE touch foo && error "'touch foo' worked after removing parent"
3122 $TRACE mkdir foo && error "'mkdir foo' worked after removing parent"
3123 if check_kernel_version 44; then
3124 touch .foo && error "'touch .foo' worked after removing parent"
3125 mkdir .foo && error "'mkdir .foo' worked after removing parent"
3127 $TRACE ls . && error "'ls .' worked after removing parent"
3128 $TRACE ls .. && error "'ls ..' worked after removing parent"
3129 is_patchless || ( $TRACE cd . && error "'cd .' worked after recreate parent" )
3130 $TRACE mkdir . && error "'mkdir .' worked after removing parent"
3131 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
3132 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
3133 is_patchless || ( $TRACE cd .. && error "'cd ..' worked after removing parent" || true )
3135 run_test 48d "Access removed parent subdir (should return errors)"
3137 test_48e() { # bug 4134
3138 check_kernel_version 41 || return 0
3139 #lctl set_param debug=-1
3141 mkdir -p $DIR/d48e/dir
3143 $TRACE rmdir $DIR/d48e/dir || error "remove cwd $DIR/d48e/dir failed"
3144 $TRACE rmdir $DIR/d48e || error "remove parent $DIR/d48e failed"
3145 $TRACE touch $DIR/d48e || error "'touch $DIR/d48e' failed"
3146 $TRACE chmod +x $DIR/d48e || error "'chmod +x $DIR/d48e' failed"
3147 # On a buggy kernel addition of "touch foo" after cd .. will
3148 # produce kernel oops in lookup_hash_it
3149 touch ../foo && error "'cd ..' worked after recreate parent"
3151 $TRACE rm $DIR/d48e || error "rm '$DIR/d48e' failed"
3153 run_test 48e "Access to recreated parent subdir (should return errors)"
3155 test_49() { # LU-1030
3156 # get ost1 size - lustre-OST0000
3157 ost1_size=$(do_facet ost1 lfs df |grep ${ost1_svc} |awk '{print $4}')
3158 # write 800M at maximum
3159 [ $ost1_size -gt 819200 ] && ost1_size=819200
3161 lfs setstripe -c 1 -i 0 $DIR/$tfile
3162 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
3165 # change max_pages_per_rpc while writing the file
3166 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
3167 local orig_mppc=`$LCTL get_param -n $osc1_mppc`
3168 # loop until dd process exits
3169 while ps ax -opid | grep -wq $dd_pid; do
3170 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
3171 sleep $((RANDOM % 5 + 1))
3173 # restore original max_pages_per_rpc
3174 $LCTL set_param $osc1_mppc=$orig_mppc
3175 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
3177 run_test 49 "Change max_pages_per_rpc won't break osc extent"
3183 ls /proc/$$/cwd || error
3185 run_test 50 "special situations: /proc symlinks ==============="
3187 test_51a() { # was test_51
3188 # bug 1516 - create an empty entry right after ".." then split dir
3191 $MCREATE $DIR/d51/bar
3193 createmany -m $DIR/d51/longfile 201
3195 while [ `ls -sd $DIR/d51 | awk '{ print $1 }'` -eq 4 ]; do
3196 $MCREATE $DIR/d51/longfile$FNUM
3201 ls -l $DIR/d51 > /dev/null || error
3203 run_test 51a "special situations: split htree with empty entry =="
3205 export NUMTEST=70000
3207 local BASE=$DIR/$tdir
3210 local mdtidx=$(printf "%04x" $($LFS getstripe -M $BASE))
3211 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
3212 [ $numfree -lt 21000 ] && skip "not enough free inodes ($numfree)" &&
3215 [ $numfree -lt $NUMTEST ] && NUMTEST=$(($numfree - 50)) &&
3216 echo "reduced count to $NUMTEST due to inodes"
3218 # need to check free space for the directories as well
3219 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
3220 numfree=$((blkfree / 4))
3221 [ $numfree -lt $NUMTEST ] && NUMTEST=$(($numfree - 50)) &&
3222 echo "reduced count to $NUMTEST due to blocks"
3224 createmany -d $BASE/d $NUMTEST && echo $NUMTEST > $BASE/fnum ||
3225 echo "failed" > $BASE/fnum
3227 run_test 51b "exceed 64k subdirectory nlink limit"
3229 test_51ba() { # LU-993
3230 local BASE=$DIR/$tdir
3231 # unlink all but 100 subdirectories, then check it still works
3233 [ -f $BASE/fnum ] && local NUMPREV=$(cat $BASE/fnum) && rm $BASE/fnum
3235 [ "$NUMPREV" != "failed" ] && NUMTEST=$NUMPREV
3236 local DELETE=$((NUMTEST - LEFT))
3238 # continue on to run this test even if 51b didn't finish,
3239 # just to delete the many subdirectories created.
3240 [ ! -d "${BASE}/d1" ] && skip "test_51b() not run" && return 0
3242 # for ldiskfs the nlink count should be 1, but this is OSD specific
3243 # and so this is listed for informational purposes only
3244 echo "nlink before: $(stat -c %h $BASE), created before: $NUMTEST"
3245 unlinkmany -d $BASE/d $DELETE
3248 if [ $RC -ne 0 ]; then
3249 if [ "$NUMPREV" == "failed" ]; then
3250 skip "previous setup failed"
3253 error "unlink of first $DELETE subdirs failed"
3258 echo "nlink between: $(stat -c %h $BASE)"
3259 # trim the first line of ls output
3260 local FOUND=$(($(ls -l ${BASE} | wc -l) - 1))
3261 [ $FOUND -ne $LEFT ] &&
3262 error "can't find subdirs: found only $FOUND/$LEFT"
3264 unlinkmany -d $BASE/d $DELETE $LEFT ||
3265 error "unlink of second $LEFT subdirs failed"
3266 # regardless of whether the backing filesystem tracks nlink accurately
3267 # or not, the nlink count shouldn't be more than "." and ".." here
3268 local AFTER=$(stat -c %h $BASE)
3269 [ $AFTER -gt 2 ] && error "nlink after: $AFTER > 2" ||
3270 echo "nlink after: $AFTER"
3272 run_test 51ba "verify nlink for many subdirectory cleanup"
3275 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3277 local ndirs=${TEST51BB_NDIRS:-10}
3278 local nfiles=${TEST51BB_NFILES:-100}
3280 local numfree=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
3282 [ $numfree -lt $(( ndirs * nfiles)) ] && \
3283 nfiles=$(( numfree / ndirs - 10 ))
3285 local dir=$DIR/d51bb
3287 local savePOLICY=$(lctl get_param -n lmv.*.placement)
3288 lctl set_param -n lmv.*.placement=CHAR
3291 local IUSED=$(lfs df -i $dir | grep MDT | awk '{print $3}')
3295 for ((i=0; i < $ndirs; i++)); do
3296 dirs[i]=$dir/$RANDOM
3297 echo Creating directory ${dirs[i]}
3300 echo Creating $nfiles in dir ${dirs[i]} ...
3301 echo "createmany -o ${dirs[i]}/$tfile- $nfiles"
3302 createmany -o ${dirs[i]}/$tfile- $nfiles
3308 IUSED=$(lfs df -i $dir | grep MDT | awk '{print $3}')
3312 for ((i=0; i<${#NEWUSED[@]}; i++)); do
3313 echo "mds $i: inodes count OLD ${OLDUSED[$i]} NEW ${NEWUSED[$i]}"
3314 [ ${OLDUSED[$i]} -lt ${NEWUSED[$i]} ] || rc=$((rc + 1))
3317 lctl set_param -n lmv.*.placement=$savePOLICY
3319 [ $rc -ne $MDSCOUNT ] || \
3320 error "Objects/inodes are not distributed over all mds servers"
3322 run_test 51bb "mkdir createmany CMD $MDSCOUNT ===================="
3325 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping test with few OSTs" && return
3327 createmany -o $DIR/d51d/t- 1000
3328 $GETSTRIPE $DIR/d51d > $TMP/files
3329 for N in `seq 0 $((OSTCOUNT - 1))`; do
3330 OBJS[$N]=`awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}' $TMP/files`
3331 OBJS0[$N]=`grep -A 1 idx $TMP/files | awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}'`
3332 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
3334 unlinkmany $DIR/d51d/t- 1000
3337 for N in `seq 1 $((OSTCOUNT - 1))`; do
3338 [ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ] && \
3339 error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
3340 [ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ] && \
3341 error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
3343 [ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ] && \
3344 error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
3345 [ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ] && \
3346 error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
3350 run_test 51d "check object distribution ===================="
3353 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
3356 chattr +a $DIR/d52a/foo || error "chattr +a failed"
3357 echo bar >> $DIR/d52a/foo || error "append bar failed"
3358 cp /etc/hosts $DIR/d52a/foo && error "cp worked"
3359 rm -f $DIR/d52a/foo 2>/dev/null && error "rm worked"
3360 link $DIR/d52a/foo $DIR/d52a/foo_link 2>/dev/null && error "link worked"
3361 echo foo >> $DIR/d52a/foo || error "append foo failed"
3362 mrename $DIR/d52a/foo $DIR/d52a/foo_ren && error "rename worked"
3363 lsattr $DIR/d52a/foo | egrep -q "^-+a[-e]+ $DIR/d52a/foo" || error "lsattr"
3364 chattr -a $DIR/d52a/foo || error "chattr -a failed"
3365 cp -r $DIR/d52a /tmp/
3366 rm -fr $DIR/d52a || error "cleanup rm failed"
3368 run_test 52a "append-only flag test (should return errors) ====="
3371 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
3374 chattr +i $DIR/d52b/foo || error "chattr +i failed"
3375 cat test > $DIR/d52b/foo && error "cat test worked"
3376 cp /etc/hosts $DIR/d52b/foo && error "cp worked"
3377 rm -f $DIR/d52b/foo 2>/dev/null && error "rm worked"
3378 link $DIR/d52b/foo $DIR/d52b/foo_link 2>/dev/null && error "link worked"
3379 echo foo >> $DIR/d52b/foo && error "echo worked"
3380 mrename $DIR/d52b/foo $DIR/d52b/foo_ren && error "rename worked"
3381 [ -f $DIR/d52b/foo ] || error
3382 [ -f $DIR/d52b/foo_ren ] && error
3383 lsattr $DIR/d52b/foo | egrep -q "^-+i[-e]+ $DIR/d52b/foo" || error "lsattr"
3384 chattr -i $DIR/d52b/foo || error "chattr failed"
3386 rm -fr $DIR/d52b || error
3388 run_test 52b "immutable flag test (should return errors) ======="
3391 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3392 remote_ost_nodsh && skip "remote OST with nodsh" && return
3401 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
3402 for value in $(do_facet $SINGLEMDS lctl get_param osc.$mdtosc.prealloc_last_id) ; do
3403 param=`echo ${value[0]} | cut -d "=" -f1`
3404 ostname=`echo $param | cut -d "." -f2 | cut -d - -f 1-2`
3405 mds_last=$(do_facet $SINGLEMDS lctl get_param -n $param)
3406 ostnum=$(echo $ostname | sed "s/${FSNAME}-OST//g" | awk '{print ($1+1)}' )
3407 ost_last=$(do_facet ost$ostnum lctl get_param -n obdfilter.$ostname.last_id | head -n 1)
3408 echo "$ostname.last_id=$ost_last ; MDS.last_id=$mds_last"
3409 if [ $ost_last != $mds_last ]; then
3410 error "$ostname.last_id=$ost_last ; MDS.last_id=$mds_last"
3414 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
3417 [ ! -f "$SOCKETSERVER" ] && skip_env "no socketserver, skipping" && return
3418 [ ! -f "$SOCKETCLIENT" ] && skip_env "no socketclient, skipping" && return
3419 $SOCKETSERVER $DIR/socket
3420 $SOCKETCLIENT $DIR/socket || error
3421 $MUNLINK $DIR/socket
3423 run_test 54a "unix domain socket test =========================="