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=" 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 SRCDIR=$(cd $(dirname $0); echo $PWD)
21 export PATH=$PATH:/sbin
25 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
26 CREATETEST=${CREATETEST:-createtest}
28 LFIND=${LFIND:-"$LFS find"}
29 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
31 MCREATE=${MCREATE:-mcreate}
32 OPENFILE=${OPENFILE:-openfile}
33 OPENUNLINK=${OPENUNLINK:-openunlink}
34 export MULTIOP=${MULTIOP:-multiop}
35 READS=${READS:-"reads"}
36 MUNLINK=${MUNLINK:-munlink}
37 SOCKETSERVER=${SOCKETSERVER:-socketserver}
38 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
39 MEMHOG=${MEMHOG:-memhog}
40 DIRECTIO=${DIRECTIO:-directio}
41 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
42 UMOUNT=${UMOUNT:-"umount -d"}
44 CHECK_GRANT=${CHECK_GRANT:-"yes"}
45 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
46 export PARALLEL=${PARALLEL:-"no"}
48 export NAME=${NAME:-local}
55 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
56 . $LUSTRE/tests/test-framework.sh
58 . ${CONFIG:=$LUSTRE/tests/cfg/${NAME}.sh}
61 [ "$SLOW" = "no" ] && EXCEPT_SLOW="24o 27m 64b 68 71 77f 78 115 124b"
63 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
64 # bug number for skipped test: LU-1593 LU-2610 LU-2833 LU-1957 LU-2805
65 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 34h 40 48a 180 184c"
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 check_swap_layouts_support()
94 $LCTL get_param -n llite.*.sbi_flags | grep -q layout ||
95 { skip "Does not support layout lock."; return 0; }
99 if [ "$ONLY" == "cleanup" ]; then
104 check_and_setup_lustre
109 MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid | \
110 awk '{gsub(/_UUID/,""); print $1}' | head -1)
111 LOVNAME=$($LCTL get_param -n llite.*.lov.common_name | tail -n 1)
112 OSTCOUNT=$($LCTL get_param -n lov.$LOVNAME.numobd)
113 STRIPECOUNT=$($LCTL get_param -n lov.$LOVNAME.stripecount)
114 STRIPESIZE=$($LCTL get_param -n lov.$LOVNAME.stripesize)
115 ORIGFREE=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
116 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
118 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
119 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
120 rm -rf $DIR/[Rdfs][0-9]*
122 # $RUNAS_ID may get set incorrectly somewhere else
123 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
125 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
129 if [ "${ONLY}" = "MOUNT" ] ; then
130 echo "Lustre is up, please go on"
134 echo "preparing for tests involving mounts"
135 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
137 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
138 echo # add a newline after mke2fs.
142 OLDDEBUG="`lctl get_param -n debug 2> /dev/null`"
143 lctl set_param debug=-1 2> /dev/null || true
146 $CHECKSTAT -t file $DIR/$tfile || error
148 $CHECKSTAT -a $DIR/$tfile || error
150 run_test 0 "touch .../$tfile ; rm .../$tfile ====================="
153 chmod 0755 $DIR || error
154 $CHECKSTAT -p 0755 $DIR || error
156 run_test 0b "chmod 0755 $DIR ============================="
159 $LCTL get_param mdc.*.import | grep "state: FULL" || error "import not FULL"
160 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" || error "bad target"
162 run_test 0c "check import proc ============================="
165 test_mkdir -p $DIR/$tdir
166 test_mkdir -p $DIR/$tdir/d2
167 test_mkdir $DIR/$tdir/d2 && error "we expect EEXIST, but not returned"
168 $CHECKSTAT -t dir $DIR/$tdir/d2 || error
170 run_test 1a "mkdir .../d1; mkdir .../d1/d2 ====================="
175 $CHECKSTAT -a $DIR/$tdir || error
177 run_test 1b "rmdir .../d1/d2; rmdir .../d1 ====================="
180 test_mkdir $DIR/$tdir
181 touch $DIR/$tdir/$tfile
182 $CHECKSTAT -t file $DIR/$tdir/$tfile || error
184 run_test 2a "mkdir .../d2; touch .../d2/f ======================"
188 $CHECKSTAT -a $DIR/$tdir || error
190 run_test 2b "rm -r .../d2; checkstat .../d2/f ======================"
193 test_mkdir -p $DIR/$tdir
194 $CHECKSTAT -t dir $DIR/$tdir || error
196 run_test 3a "mkdir .../d3 ======================================"
199 if [ ! -d $DIR/$tdir ]; then
202 touch $DIR/$tdir/$tfile
203 $CHECKSTAT -t file $DIR/$tdir/$tfile || error
205 run_test 3b "touch .../d3/f ===================================="
209 $CHECKSTAT -a $DIR/$tdir || error
211 run_test 3c "rm -r .../d3 ======================================"
214 test_mkdir -p $DIR/$tdir
215 $CHECKSTAT -t dir $DIR/$tdir || error
217 run_test 4a "mkdir .../d4 ======================================"
220 if [ ! -d $DIR/$tdir ]; then
221 test_mkdir $DIR/$tdir
223 test_mkdir $DIR/$tdir/d2
225 $CHECKSTAT -t dir $DIR/$tdir/d2 || error
227 run_test 4b "mkdir .../d4/d2 ==================================="
230 test_mkdir $DIR/$tdir
231 test_mkdir $DIR/$tdir/d2
232 chmod 0707 $DIR/$tdir/d2
233 $CHECKSTAT -t dir -p 0707 $DIR/$tdir/d2 || error
235 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2 ============"
239 chmod 0666 $DIR/$tfile || error
240 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile || error
242 run_test 6a "touch .../f6a; chmod .../f6a ======================"
245 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
246 if [ ! -f $DIR/$tfile ]; then
248 chmod 0666 $DIR/$tfile
250 $RUNAS chmod 0444 $DIR/$tfile && error
251 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile || error
253 run_test 6b "$RUNAS chmod .../f6a (should return error) =="
256 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
258 chown $RUNAS_ID $DIR/$tfile || error
259 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile || error
261 run_test 6c "touch .../f6c; chown .../f6c ======================"
264 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
265 if [ ! -f $DIR/$tfile ]; then
267 chown $RUNAS_ID $DIR/$tfile
269 $RUNAS chown $UID $DIR/$tfile && error
270 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile || error
272 run_test 6d "$RUNAS chown .../f6c (should return error) =="
275 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
277 chgrp $RUNAS_ID $DIR/$tfile || error
278 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile || error
280 run_test 6e "touch .../f6e; chgrp .../f6e ======================"
283 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
284 if [ ! -f $DIR/$tfile ]; then
286 chgrp $RUNAS_ID $DIR/$tfile
288 $RUNAS chgrp $UID $DIR/$tfile && error
289 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile || error
291 run_test 6f "$RUNAS chgrp .../f6e (should return error) =="
294 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
295 test_mkdir $DIR/$tdir || error
296 chmod 777 $DIR/$tdir || error
297 $RUNAS mkdir $DIR/$tdir/d || error
298 chmod g+s $DIR/$tdir/d || error
299 test_mkdir $DIR/$tdir/d/subdir
300 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir/d/subdir || error
302 run_test 6g "Is new dir in sgid dir inheriting group?"
304 test_6h() { # bug 7331
305 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
306 touch $DIR/$tfile || error "touch failed"
307 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
308 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
310 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/$tfile || error
312 run_test 6h "$RUNAS chown RUNAS_ID.0 .../f6h (should return error)"
315 test_mkdir $DIR/$tdir
316 $MCREATE $DIR/$tdir/$tfile
317 chmod 0666 $DIR/$tdir/$tfile
318 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile || error
320 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
323 if [ ! -d $DIR/$tdir ]; then
326 $MCREATE $DIR/$tdir/$tfile
327 echo -n foo > $DIR/$tdir/$tfile
328 [ "`cat $DIR/$tdir/$tfile`" = "foo" ] || error
329 $CHECKSTAT -t file -s 3 $DIR/$tdir/$tfile || error
331 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
334 test_mkdir $DIR/$tdir
335 touch $DIR/$tdir/$tfile
336 chmod 0666 $DIR/$tdir/$tfile
337 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile || error
339 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
342 test_mkdir $DIR/$tdir
343 test_mkdir $DIR/$tdir/d2
344 test_mkdir $DIR/$tdir/d2/d3
345 $CHECKSTAT -t dir $DIR/$tdir/d2/d3 || error
347 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
350 test_mkdir $DIR/$tdir
351 test_mkdir $DIR/$tdir/d2
352 touch $DIR/$tdir/d2/$tfile
353 $CHECKSTAT -t file $DIR/$tdir/d2/$tfile || error
355 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
358 test_mkdir $DIR/$tdir
359 test_mkdir $DIR/$tdir/d2
360 chmod 0666 $DIR/$tdir/d2
361 chmod 0705 $DIR/$tdir/d2
362 $CHECKSTAT -t dir -p 0705 $DIR/$tdir/d2 || error
364 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
367 test_mkdir $DIR/$tdir
368 touch $DIR/$tdir/$tfile
369 chmod 0666 $DIR/$tdir/$tfile
370 chmod 0654 $DIR/$tdir/$tfile
371 $CHECKSTAT -t file -p 0654 $DIR/$tdir/$tfile || error
373 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
376 test_mkdir $DIR/$tdir
377 dd if=/dev/zero of=$DIR/$tdir/$tfile count=10
379 $CHECKSTAT -t file -s 0 $DIR/$tdir/$tfile || error
381 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
384 test_mkdir $DIR/$tdir
385 touch $DIR/$tdir/$tfile
387 $CHECKSTAT -a $DIR/$tdir/$tfile || error
389 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
392 test_mkdir $DIR/$tdir
393 touch $DIR/$tdir/$tfile
394 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}_2
395 $CHECKSTAT -t file $DIR/$tdir/${tfile}_2 || error
397 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
400 test_mkdir $DIR/$tdir
401 touch $DIR/$tdir/$tfile
402 rm -rf $DIR/$tdir/$tfile
403 $CHECKSTAT -a $DIR/$tdir/$tfile || error
405 run_test 16 "touch .../d16/f; rm -rf .../d16/f ================="
408 test_mkdir -p $DIR/$tdir
409 touch $DIR/$tdir/$tfile
410 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
412 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist || error
413 $CHECKSTAT -f -t f $DIR/$tdir/l-exist || error
414 rm -f $DIR/$tdir/l-exist
415 $CHECKSTAT -a $DIR/$tdir/l-exist || error
417 run_test 17a "symlinks: create, remove (real) =================="
420 test_mkdir -p $DIR/$tdir
421 ln -s no-such-file $DIR/$tdir/l-dangle
423 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle || error
424 $CHECKSTAT -fa $DIR/$tdir/l-dangle || error
425 rm -f $DIR/$tdir/l-dangle
426 $CHECKSTAT -a $DIR/$tdir/l-dangle || error
428 run_test 17b "symlinks: create, remove (dangling) =============="
430 test_17c() { # bug 3440 - don't save failed open RPC for replay
431 test_mkdir -p $DIR/$tdir
432 ln -s foo $DIR/$tdir/$tfile
433 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
435 run_test 17c "symlinks: open dangling (should return error) ===="
438 test_mkdir -p $DIR/$tdir
439 ln -s foo $DIR/$tdir/$tfile
440 touch $DIR/$tdir/$tfile || error "creating to new symlink"
442 run_test 17d "symlinks: create dangling ========================"
445 test_mkdir -p $DIR/$tdir
446 local foo=$DIR/$tdir/$tfile
447 ln -s $foo $foo || error "create symlink failed"
448 ls -l $foo || error "ls -l failed"
449 ls $foo && error "ls not failed" || true
451 run_test 17e "symlinks: create recursive symlink (should return error) ===="
454 test_mkdir -p $DIR/d17f
455 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/d17f/111
456 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/d17f/222
457 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/d17f/333
458 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/d17f/444
459 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/d17f/555
460 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
463 run_test 17f "symlinks: long and very long symlink name ========================"
465 # str_repeat(S, N) generate a string that is string S repeated N times
470 while [ $((n -= 1)) -ge 0 ]; do
476 # Long symlinks and LU-2241
478 test_mkdir -p $DIR/$tdir
479 local TESTS="59 60 61 4094 4095"
481 # Fix for inode size boundary in 2.1.4
482 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.4) ] &&
485 # Patch not applied to 2.2 or 2.3 branches
486 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
487 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.3.55) ] &&
491 local SYMNAME=$(str_repeat 'x' $i)
492 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
493 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
496 run_test 17g "symlinks: really long symlink name and inode boundaries"
498 test_17h() { #bug 17378
499 remote_mds_nodsh && skip "remote MDS with nodsh" && return
500 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
502 test_mkdir -p $DIR/$tdir
503 if [ $MDSCOUNT -gt 1 ]; then
504 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
508 $SETSTRIPE -c -1 $DIR/$tdir
509 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
510 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
511 touch $DIR/$tdir/$tfile || true
513 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
515 test_17i() { #bug 20018
516 remote_mds_nodsh && skip "remote MDS with nodsh" && return
517 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
518 test_mkdir -p $DIR/$tdir
519 local foo=$DIR/$tdir/$tfile
521 if [ $MDSCOUNT -gt 1 ]; then
522 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
526 ln -s $foo $foo || error "create symlink failed"
527 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
528 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
529 ls -l $foo && error "error not detected"
532 run_test 17i "don't panic on short symlink"
534 test_17k() { #bug 22301
535 rsync --help | grep -q xattr ||
536 skip_env "$(rsync --version| head -1) does not support xattrs"
537 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
538 test_mkdir -p $DIR/$tdir
539 test_mkdir -p $DIR/$tdir.new
540 touch $DIR/$tdir/$tfile
541 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
542 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
543 error "rsync failed with xattrs enabled"
545 run_test 17k "symlinks: rsync with xattrs enabled ========================="
547 test_17l() { # LU-279
549 touch $DIR/$tdir/$tfile
550 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
551 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
552 # -h to not follow symlinks. -m '' to list all the xattrs.
553 # grep to remove first line: '# file: $path'.
554 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
556 lgetxattr_size_check $path $xattr ||
557 error "lgetxattr_size_check $path $xattr failed"
561 run_test 17l "Ensure lgetxattr's returned xattr size is consistent ========"
565 local short_sym="0123456789"
566 local WDIR=$DIR/${tdir}m
573 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
574 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
575 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
577 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
578 skip "only for ldiskfs MDT" && return 0
580 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
584 # create a long symlink file
585 for ((i = 0; i < 4; ++i)); do
586 long_sym=${long_sym}${long_sym}
589 echo "create 512 short and long symlink files under $WDIR"
590 for ((i = 0; i < 256; ++i)); do
591 ln -sf ${long_sym}"a5a5" $WDIR/long-$i
592 ln -sf ${short_sym}"a5a5" $WDIR/short-$i
598 wait_delete_completed
600 echo "recreate the 512 symlink files with a shorter string"
601 for ((i = 0; i < 512; ++i)); do
602 # rewrite the symlink file with a shorter string
603 ln -sf ${long_sym} $WDIR/long-$i
604 ln -sf ${short_sym} $WDIR/short-$i
607 mds_index=$($LFS getstripe -M $WDIR)
608 mds_index=$((mds_index+1))
609 devname=$(mdsdevname $mds_index)
610 cmd="$E2FSCK -fnvd $devname"
612 echo "stop and checking mds${mds_index}: $cmd"
613 # e2fsck should not return error
614 stop mds${mds_index} -f
615 do_facet mds${mds_index} $cmd || rc=$?
617 start mds${mds_index} $devname $MDS_MOUNT_OPTS
618 df $MOUNT > /dev/null 2>&1
619 [ $rc -ne 0 ] && error "e2fsck should not report error upon "\
620 "short/long symlink MDT: rc=$rc"
623 run_test 17m "run e2fsck against MDT which contains short/long symlink"
625 check_fs_consistency_17n() {
631 for mdt_index in $(seq 1 $MDSCOUNT); do
632 devname=$(mdsdevname $mdt_index)
633 cmd="$E2FSCK -fnvd $devname"
635 echo "stop and checking mds${mdt_index}: $cmd"
636 # e2fsck should not return error
638 do_facet mds${mdt_index} $cmd || rc=$?
640 start mds${mdt_index} $devname $MDS_MOUNT_OPTS
641 df $MOUNT > /dev/null 2>&1
642 [ $rc -ne 0 ] && break
650 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
651 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
652 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
654 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
655 skip "only for ldiskfs MDT" && return 0
657 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
659 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
662 for ((i=0; i<10; i++)); do
663 $LFS mkdir -i 1 $DIR/$tdir/remote_dir_${i} ||
664 error "create remote dir error $i"
665 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
666 error "create files under remote dir failed $i"
669 check_fs_consistency_17n || error "e2fsck report error"
671 for ((i=0;i<10;i++)); do
672 rm -rf $DIR/$tdir/remote_dir_${i} ||
673 error "destroy remote dir error $i"
676 check_fs_consistency_17n || error "e2fsck report error"
678 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
681 local WDIR=$DIR/${tdir}o
687 mdt_index=$($LFS getstripe -M $WDIR)
688 mdt_index=$((mdt_index+1))
689 mdtdevname=$(mdsdevname $mdt_index)
693 start mds${mdt_index} $mdtdevname $MDS_MOUNT_OPTS
695 #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
696 do_facet mds${mdt_index} lctl set_param fail_loc=0x194
697 ls -l $WDIR/$tfile && rc=1
698 do_facet mds${mdt_index} lctl set_param fail_loc=0
699 [[ $rc -ne 0 ]] && error "stat file should fail"
702 run_test 17o "stat file with incompat LMA feature"
705 touch $DIR/f || error "Failed to touch $DIR/f: $?"
706 ls $DIR || error "Failed to ls $DIR: $?"
708 run_test 18 "touch .../f ; ls ... =============================="
714 $CHECKSTAT -a $DIR/f19 || error
716 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
719 ls -l $DIR/f19 && error || true
721 run_test 19b "ls -l .../f19 (should return error) =============="
724 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
725 $RUNAS touch $DIR/f19 && error || true
727 run_test 19c "$RUNAS touch .../f19 (should return error) =="
730 cat $DIR/f19 && error || true
732 run_test 19d "cat .../f19 (should return error) =============="
744 $CHECKSTAT -a $DIR/f || error
746 run_test 20 "touch .../f ; ls -l ... ==========================="
750 [ -f $DIR/d21/dangle ] && rm -f $DIR/d21/dangle
751 ln -s dangle $DIR/d21/link
752 echo foo >> $DIR/d21/link
754 $CHECKSTAT -t link $DIR/d21/link || error
755 $CHECKSTAT -f -t file $DIR/d21/link || error
757 run_test 21 "write to dangling link ============================"
761 test_mkdir -p $DIR/$tdir
762 chown $RUNAS_ID:$RUNAS_GID $WDIR
763 (cd $WDIR || error "cd $WDIR failed";
764 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
766 ls -lR $WDIR/etc || error "ls -lR $WDIR/etc failed"
767 $CHECKSTAT -t dir $WDIR/etc || error "checkstat -t dir failed"
768 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $WDIR/etc || error "checkstat -u failed"
770 run_test 22 "unpack tar archive as non-root user ==============="
774 test_mkdir -p $DIR/$tdir
775 local file=$DIR/$tdir/$tfile
777 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
778 openfile -f O_CREAT:O_EXCL $file &&
779 error "$file recreate succeeded" || true
781 run_test 23a "O_CREAT|O_EXCL in subdir =========================="
783 test_23b() { # bug 18988
784 test_mkdir -p $DIR/$tdir
785 local file=$DIR/$tdir/$tfile
788 echo foo > $file || error "write filed"
789 echo bar >> $file || error "append filed"
790 $CHECKSTAT -s 8 $file || error "wrong size"
793 run_test 23b "O_APPEND check =========================="
796 echo '== rename sanity =============================================='
797 echo '-- same directory rename'
800 mv $DIR/R1/f $DIR/R1/g
801 $CHECKSTAT -t file $DIR/R1/g || error
803 run_test 24a "touch .../R1/f; rename .../R1/f .../R1/g ========="
808 mv $DIR/R2/f $DIR/R2/g
809 $CHECKSTAT -a $DIR/R2/f || error
810 $CHECKSTAT -t file $DIR/R2/g || error
812 run_test 24b "touch .../R2/{f,g}; rename .../R2/f .../R2/g ====="
817 mv $DIR/R3/f $DIR/R3/g
818 $CHECKSTAT -a $DIR/R3/f || error
819 $CHECKSTAT -t dir $DIR/R3/g || error
821 run_test 24c "mkdir .../R3/f; rename .../R3/f .../R3/g ========="
827 mrename $DIR/R4/f $DIR/R4/g
828 $CHECKSTAT -a $DIR/R4/f || error
829 $CHECKSTAT -t dir $DIR/R4/g || error
831 run_test 24d "mkdir .../R4/{f,g}; rename .../R4/f .../R4/g ====="
834 echo '-- cross directory renames --'
838 mv $DIR/R5a/f $DIR/R5b/g
839 $CHECKSTAT -a $DIR/R5a/f || error
840 $CHECKSTAT -t file $DIR/R5b/g || error
842 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
847 touch $DIR/R6a/f $DIR/R6b/g
848 mv $DIR/R6a/f $DIR/R6b/g
849 $CHECKSTAT -a $DIR/R6a/f || error
850 $CHECKSTAT -t file $DIR/R6b/g || error
852 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
857 test_mkdir $DIR/R7a/d
858 mv $DIR/R7a/d $DIR/R7b/e
859 $CHECKSTAT -a $DIR/R7a/d || error
860 $CHECKSTAT -t dir $DIR/R7b/e || error
862 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
867 test_mkdir $DIR/R8a/d
868 test_mkdir $DIR/R8b/e
869 mrename $DIR/R8a/d $DIR/R8b/e
870 $CHECKSTAT -a $DIR/R8a/d || error
871 $CHECKSTAT -t dir $DIR/R8b/e || error
873 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
876 echo "-- rename error cases"
880 mrename $DIR/R9/f $DIR/R9/a
881 $CHECKSTAT -t file $DIR/R9/f || error
882 $CHECKSTAT -t dir $DIR/R9/a || error
883 $CHECKSTAT -a $DIR/R9/a/f || error
885 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
889 mrename $DIR/R10/f $DIR/R10/g
890 $CHECKSTAT -t dir $DIR/R10 || error
891 $CHECKSTAT -a $DIR/R10/f || error
892 $CHECKSTAT -a $DIR/R10/g || error
894 run_test 24j "source does not exist ============================"
898 test_mkdir $DIR/R11a/d
900 mv $DIR/R11a/f $DIR/R11a/d
901 $CHECKSTAT -a $DIR/R11a/f || error
902 $CHECKSTAT -t file $DIR/R11a/d/f || error
904 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
906 # bug 2429 - rename foo foo foo creates invalid file
909 $MULTIOP $f OcNs || error
911 run_test 24l "Renaming a file to itself ========================"
915 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
916 # on ext3 this does not remove either the source or target files
917 # though the "expected" operation would be to remove the source
918 $CHECKSTAT -t file ${f} || error "${f} missing"
919 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
921 run_test 24m "Renaming a file to a hard link to itself ========="
925 # this stats the old file after it was renamed, so it should fail
929 $CHECKSTAT ${f}.rename
932 run_test 24n "Statting the old file after renaming (Posix rename 2)"
935 check_kernel_version 37 || return 0
936 test_mkdir -p $DIR/d24o
937 rename_many -s random -v -n 10 $DIR/d24o
939 run_test 24o "rename of files during htree split ==============="
944 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
945 mrename $DIR/R12a $DIR/R12b
946 $CHECKSTAT -a $DIR/R12a || error
947 $CHECKSTAT -t dir $DIR/R12b || error
948 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
949 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
951 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
953 cleanup_multiop_pause() {
959 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
962 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
963 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
966 trap cleanup_multiop_pause EXIT
967 mrename $DIR/R13a $DIR/R13b
968 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
969 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
970 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
971 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
972 cleanup_multiop_pause
973 wait $MULTIPID || error "multiop close failed"
975 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
977 test_24r() { #bug 3789
979 test_mkdir $DIR/R14a/b
980 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
981 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
982 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
984 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
988 test_mkdir $DIR/R15a/b
989 test_mkdir $DIR/R15a/b/c
990 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
991 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
992 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
994 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
997 test_mkdir $DIR/R16a/b
998 test_mkdir $DIR/R16a/b/c
999 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
1000 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
1001 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
1003 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
1005 test_24u() { # bug12192
1007 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error
1008 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
1010 run_test 24u "create stripe file"
1016 simple_cleanup_common() {
1019 wait_delete_completed
1022 max_pages_per_rpc() {
1023 $LCTL get_param -n mdc.*.max_pages_per_rpc | head -1
1027 local NRFILES=100000
1028 local FREE_INODES=$(lfs_df -i | grep "summary" | awk '{print $4}')
1029 [ $FREE_INODES -lt $NRFILES ] && \
1030 skip "not enough free inodes $FREE_INODES required $NRFILES" &&
1033 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1034 trap simple_cleanup_common EXIT
1037 createmany -m $DIR/$tdir/$tfile $NRFILES
1039 cancel_lru_locks mdc
1040 lctl set_param mdc.*.stats clear
1042 ls $DIR/$tdir >/dev/null || error "error in listing large dir"
1044 # LU-5 large readdir
1045 # DIRENT_SIZE = 32 bytes for sizeof(struct lu_dirent) +
1046 # 8 bytes for name(filename is mostly 5 in this test) +
1047 # 8 bytes for luda_type
1048 # take into account of overhead in lu_dirpage header and end mark in
1049 # each page, plus one in RPC_NUM calculation.
1051 RPC_SIZE=$(($(max_pages_per_rpc) * $(page_size)))
1052 RPC_NUM=$(((NRFILES * DIRENT_SIZE + RPC_SIZE - 1) / RPC_SIZE + 1))
1053 mds_readpage=$(lctl get_param mdc.*MDT0000*.stats | \
1054 awk '/^mds_readpage/ {print $2}')
1055 [ $mds_readpage -gt $RPC_NUM ] && \
1056 error "large readdir doesn't take effect"
1058 simple_cleanup_common
1060 run_test 24v "list directory with large files (handle hash collision, bug: 17560)"
1062 test_24w() { # bug21506
1064 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1065 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1066 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1067 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1068 [ "$SZ1" = "$SZ2" ] || \
1069 error "Error reading at the end of the file $tfile"
1071 run_test 24w "Reading a file larger than 4Gb"
1074 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1075 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1077 local remote_dir=$DIR/$tdir/remote_dir
1080 $LFS mkdir -i $MDTIDX $remote_dir ||
1081 error "create remote directory failed"
1083 mkdir -p $DIR/$tdir/src_dir
1084 touch $DIR/$tdir/src_file
1085 mkdir -p $remote_dir/tgt_dir
1086 touch $remote_dir/tgt_file
1088 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir &&
1089 error "rename dir cross MDT works!"
1091 mrename $DIR/$tdir/src_file $remote_dir/tgt_file &&
1092 error "rename file cross MDT works!"
1094 ln $DIR/$tdir/src_file $remote_dir/tgt_file1 &&
1095 error "ln file cross MDT should not work!"
1097 rm -rf $DIR/$tdir || error "Can not delete directories"
1099 run_test 24x "cross rename/link should be failed"
1102 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1103 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1105 local remote_dir=$DIR/$tdir/remote_dir
1108 $LFS mkdir -i $MDTIDX $remote_dir ||
1109 error "create remote directory failed"
1111 mkdir -p $remote_dir/src_dir
1112 touch $remote_dir/src_file
1113 mkdir -p $remote_dir/tgt_dir
1114 touch $remote_dir/tgt_file
1116 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1117 error "rename subdir in the same remote dir failed!"
1119 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1120 error "rename files in the same remote dir failed!"
1122 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1123 error "link files in the same remote dir failed!"
1125 rm -rf $DIR/$tdir || error "Can not delete directories"
1127 run_test 24y "rename/link on the same dir should succeed"
1130 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1131 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1133 local remote_src=$DIR/$tdir/remote_dir
1134 local remote_tgt=$DIR/$tdir/remote_tgt
1137 $LFS mkdir -i $MDTIDX $remote_src ||
1138 error "create remote directory failed"
1140 $LFS mkdir -i $MDTIDX $remote_tgt ||
1141 error "create remote directory failed"
1143 mrename $remote_src $remote_tgt &&
1144 error "rename remote dirs should not work!"
1146 # If target dir does not exists, it should succeed
1148 mrename $remote_src $remote_tgt ||
1149 error "rename remote dirs(tgt dir does not exists) failed!"
1151 rm -rf $DIR/$tdir || error "Can not delete directories"
1153 run_test 24z "rename one remote dir to another remote dir should fail"
1156 echo '== symlink sanity ============================================='
1160 touch $DIR/s25/foo || error
1162 run_test 25a "create file in symlinked directory ==============="
1165 [ ! -d $DIR/d25 ] && test_25a
1166 $CHECKSTAT -t file $DIR/s25/foo || error
1168 run_test 25b "lookup file in symlinked directory ==============="
1172 test_mkdir $DIR/d26/d26-2
1173 ln -s d26/d26-2 $DIR/s26
1174 touch $DIR/s26/foo || error
1176 run_test 26a "multiple component symlink ======================="
1179 test_mkdir -p $DIR/d26b/d26-2
1180 ln -s d26b/d26-2/foo $DIR/s26-2
1181 touch $DIR/s26-2 || error
1183 run_test 26b "multiple component symlink at end of lookup ======"
1186 test_mkdir $DIR/d26.2
1187 touch $DIR/d26.2/foo
1188 ln -s d26.2 $DIR/s26.2-1
1189 ln -s s26.2-1 $DIR/s26.2-2
1190 ln -s s26.2-2 $DIR/s26.2-3
1191 chmod 0666 $DIR/s26.2-3/foo
1193 run_test 26c "chain of symlinks ================================"
1195 # recursive symlinks (bug 439)
1197 ln -s d26-3/foo $DIR/d26-3
1199 run_test 26d "create multiple component recursive symlink ======"
1202 [ ! -h $DIR/d26-3 ] && test_26d
1205 run_test 26e "unlink multiple component recursive symlink ======"
1207 # recursive symlinks (bug 7022)
1209 test_mkdir -p $DIR/$tdir
1210 test_mkdir $DIR/$tdir/$tfile || error "mkdir $DIR/$tdir/$tfile failed"
1211 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1212 test_mkdir -p lndir bar1 || error "mkdir lndir/bar1 failed"
1213 test_mkdir $DIR/$tdir/$tfile/$tfile || error "mkdir $tfile failed"
1214 cd $tfile || error "cd $tfile failed"
1215 ln -s .. dotdot || error "ln dotdot failed"
1216 ln -s dotdot/lndir lndir || error "ln lndir failed"
1217 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1218 output=`ls $tfile/$tfile/lndir/bar1`
1219 [ "$output" = bar1 ] && error "unexpected output"
1220 rm -r $tfile || error "rm $tfile failed"
1221 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1223 run_test 26f "rm -r of a directory which has recursive symlink ="
1226 echo '== stripe sanity =============================================='
1227 test_mkdir -p $DIR/d27 || error "mkdir failed"
1229 $SETSTRIPE -c 1 $DIR/d27/f0 || error "setstripe failed"
1230 $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
1232 log "== test_27a: write to one stripe file ========================="
1233 cp /etc/hosts $DIR/d27/f0 || error
1235 run_test 27a "one stripe file =================================="
1238 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
1239 test_mkdir -p $DIR/d27
1240 $SETSTRIPE -c 2 $DIR/d27/f01 || error "setstripe failed"
1241 $GETSTRIPE -c $DIR/d27/f01
1242 [ $($GETSTRIPE -c $DIR/d27/f01) -eq 2 ] ||
1243 error "two-stripe file doesn't have two stripes"
1245 run_test 27b "create two stripe file"
1248 [ -f $DIR/d27/f01 ] || skip "test_27b not run" && return
1250 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
1252 run_test 27c "write to two stripe file"
1255 test_mkdir -p $DIR/d27
1256 $SETSTRIPE -c 0 -i -1 -S 0 $DIR/d27/fdef || error "setstripe failed"
1257 $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
1258 dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
1260 run_test 27d "create file with default settings ================"
1263 test_mkdir -p $DIR/d27
1264 $SETSTRIPE -c 2 $DIR/d27/f12 || error "setstripe failed"
1265 $SETSTRIPE -c 2 $DIR/d27/f12 && error "setstripe succeeded twice"
1266 $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
1268 run_test 27e "setstripe existing file (should return error) ======"
1271 test_mkdir -p $DIR/d27
1272 $SETSTRIPE -S 100 -i 0 -c 1 $DIR/d27/fbad && error "setstripe failed"
1273 dd if=/dev/zero of=$DIR/d27/fbad bs=4k count=4 || error "dd failed"
1274 $GETSTRIPE $DIR/d27/fbad || error "$GETSTRIPE failed"
1276 run_test 27f "setstripe with bad stripe size (should return error)"
1279 test_mkdir -p $DIR/d27
1280 $MCREATE $DIR/d27/fnone || error "mcreate failed"
1281 $GETSTRIPE $DIR/d27/fnone 2>&1 | grep "no stripe info" ||
1282 error "$DIR/d27/fnone has object"
1284 run_test 27g "$GETSTRIPE with no objects"
1287 touch $DIR/d27/fsome || error "touch failed"
1288 [ $($GETSTRIPE -c $DIR/d27/fsome) -gt 0 ] || error "missing objects"
1290 run_test 27i "$GETSTRIPE with some objects"
1293 test_mkdir -p $DIR/d27
1294 $SETSTRIPE -i $OSTCOUNT $DIR/d27/f27j && error "setstripe failed"||true
1296 run_test 27j "setstripe with bad stripe offset (should return error)"
1298 test_27k() { # bug 2844
1299 test_mkdir -p $DIR/d27
1301 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
1302 [ ! -d $DIR/d27 ] && test_mkdir -p $DIR d27
1303 $SETSTRIPE -S 67108864 $FILE || error "setstripe failed"
1304 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1305 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
1306 dd if=/dev/zero of=$FILE bs=4k count=1
1307 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1308 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
1310 run_test 27k "limit i_blksize for broken user apps ============="
1313 test_mkdir -p $DIR/d27
1314 mcreate $DIR/f27l || error "creating file"
1315 $RUNAS $SETSTRIPE -c 1 $DIR/f27l && \
1316 error "setstripe should have failed" || true
1318 run_test 27l "check setstripe permissions (should return error)"
1321 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" &&
1323 if [ $ORIGFREE -gt $MAXFREE ]; then
1324 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1327 trap simple_cleanup_common EXIT
1328 test_mkdir -p $DIR/$tdir
1329 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_1
1330 dd if=/dev/zero of=$DIR/$tdir/f27m_1 bs=1024 count=$MAXFREE &&
1331 error "dd should fill OST0"
1333 while $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_$i; do
1335 [ $i -gt 256 ] && break
1338 touch $DIR/$tdir/f27m_$i
1339 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1340 error "OST0 was full but new created file still use it"
1342 touch $DIR/$tdir/f27m_$i
1343 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1344 error "OST0 was full but new created file still use it"
1345 simple_cleanup_common
1347 run_test 27m "create file while OST0 was full =================="
1350 local DELAY=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage | head -n 1 | awk '{print $1 * 2}')
1354 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1355 # if the OST isn't full anymore.
1357 local OSTIDX=${1:-""}
1359 local list=$(comma_list $(osts_nodes))
1360 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1362 do_nodes $list lctl set_param fail_loc=0
1363 sync # initiate all OST_DESTROYs from MDS to OST
1367 exhaust_precreations() {
1370 local FAILIDX=${3:-$OSTIDX}
1372 test_mkdir -p $DIR/$tdir
1373 local MDSIDX=$(get_mds_dir "$DIR/$tdir")
1374 echo OSTIDX=$OSTIDX MDSIDX=$MDSIDX
1376 local OST=$(ostname_from_index $OSTIDX)
1377 local MDT_INDEX=$(lfs df | grep "\[MDT:$((MDSIDX - 1))\]" | awk '{print $1}' | \
1378 sed -e 's/_UUID$//;s/^.*-//')
1381 local mdtosc_proc1=$(get_mdtosc_proc_path mds${MDSIDX} $OST)
1382 local last_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1383 osc.$mdtosc_proc1.prealloc_last_id)
1384 local next_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1385 osc.$mdtosc_proc1.prealloc_next_id)
1387 local mdtosc_proc2=$(get_mdtosc_proc_path mds${MDSIDX})
1388 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1390 test_mkdir -p $DIR/$tdir/${OST}
1391 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1392 #define OBD_FAIL_OST_ENOSPC 0x215
1393 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=$FAILIDX
1394 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x215
1395 echo "Creating to objid $last_id on ost $OST..."
1396 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1397 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1398 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=$FAILLOC
1402 exhaust_all_precreations() {
1404 for (( i=0; i < OSTCOUNT; i++ )) ; do
1405 exhaust_precreations $i $1 -1
1410 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1411 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1412 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1413 remote_ost_nodsh && skip "remote OST with nodsh" && return
1416 rm -f $DIR/$tdir/$tfile
1417 exhaust_precreations 0 0x80000215
1418 $SETSTRIPE -c -1 $DIR/$tdir
1419 touch $DIR/$tdir/$tfile || error
1420 $GETSTRIPE $DIR/$tdir/$tfile
1423 run_test 27n "create file with some full OSTs =================="
1426 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1427 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1428 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1429 remote_ost_nodsh && skip "remote OST with nodsh" && return
1432 rm -f $DIR/$tdir/$tfile
1433 exhaust_all_precreations 0x215
1435 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1440 run_test 27o "create file with all full OSTs (should error) ===="
1443 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1444 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1445 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1446 remote_ost_nodsh && skip "remote OST with nodsh" && return
1449 rm -f $DIR/$tdir/$tfile
1450 test_mkdir -p $DIR/$tdir
1452 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1453 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1454 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1456 exhaust_precreations 0 0x80000215
1457 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1458 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1459 $GETSTRIPE $DIR/$tdir/$tfile
1463 run_test 27p "append to a truncated file with some full OSTs ==="
1466 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1467 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1468 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1469 remote_ost_nodsh && skip "remote OST with nodsh" && return
1472 rm -f $DIR/$tdir/$tfile
1474 test_mkdir -p $DIR/$tdir
1475 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1476 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||error "truncate $DIR/$tdir/$tfile failed"
1477 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1479 exhaust_all_precreations 0x215
1481 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1482 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1486 run_test 27q "append to truncated file with all OSTs full (should error) ==="
1489 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1490 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1491 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1492 remote_ost_nodsh && skip "remote OST with nodsh" && return
1495 rm -f $DIR/$tdir/$tfile
1496 exhaust_precreations 0 0x80000215
1498 $SETSTRIPE -i 0 -c 2 $DIR/$tdir/$tfile # && error
1502 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1504 test_27s() { # bug 10725
1505 test_mkdir -p $DIR/$tdir
1506 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1507 local stripe_count=0
1508 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1509 $SETSTRIPE -S $stripe_size -c $stripe_count $DIR/$tdir &&
1510 error "stripe width >= 2^32 succeeded" || true
1513 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1515 test_27t() { # bug 10864
1520 $WLFS getstripe $tfile
1523 run_test 27t "check that utils parse path correctly"
1525 test_27u() { # bug 4900
1526 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1527 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1529 local list=$(comma_list $(mdts_nodes))
1531 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1532 do_nodes $list $LCTL set_param fail_loc=0x139
1533 test_mkdir -p $DIR/$tdir
1535 createmany -o $DIR/$tdir/t- 1000
1536 do_nodes $list $LCTL set_param fail_loc=0
1538 TLOG=$DIR/$tfile.getstripe
1539 $GETSTRIPE $DIR/$tdir > $TLOG
1540 OBJS=`awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj;}' $TLOG`
1541 unlinkmany $DIR/$tdir/t- 1000
1542 [ $OBJS -gt 0 ] && \
1543 error "$OBJS objects created on OST-0. See $TLOG" || pass
1545 run_test 27u "skip object creation on OSC w/o objects =========="
1547 test_27v() { # bug 4900
1548 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1549 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1550 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1551 remote_ost_nodsh && skip "remote OST with nodsh" && return
1553 exhaust_all_precreations 0x215
1556 test_mkdir -p $DIR/$tdir
1557 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1559 touch $DIR/$tdir/$tfile
1560 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1562 for (( i=1; i < OSTCOUNT; i++ )); do
1563 do_facet ost$i lctl set_param fail_loc=0x705
1565 local START=`date +%s`
1566 createmany -o $DIR/$tdir/$tfile 32
1568 local FINISH=`date +%s`
1569 local TIMEOUT=`lctl get_param -n timeout`
1570 local PROCESS=$((FINISH - START))
1571 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1572 error "$FINISH - $START >= $TIMEOUT / 2"
1573 sleep $((TIMEOUT / 2 - PROCESS))
1576 run_test 27v "skip object creation on slow OST ================="
1578 test_27w() { # bug 10997
1579 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1580 $SETSTRIPE -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1581 [ $($GETSTRIPE -S $DIR/$tdir/f0) -ne 65536 ] &&
1582 error "stripe size $size != 65536" || true
1583 [ $($GETSTRIPE -d $DIR/$tdir | grep -c "stripe_count") -ne 1 ] &&
1584 error "$GETSTRIPE -d $DIR/$tdir failed" || true
1586 run_test 27w "check $SETSTRIPE -S option"
1589 [ "$OSTCOUNT" -lt "2" ] &&
1590 skip_env "skipping multiple stripe count/offset test" && return
1592 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1593 for i in $(seq 1 $OSTCOUNT); do
1595 $SETSTRIPE -c $i -i $offset $DIR/$tdir/f$i ||
1596 error "setstripe -c $i -i $offset failed"
1597 count=$($GETSTRIPE -c $DIR/$tdir/f$i)
1598 index=$($GETSTRIPE -i $DIR/$tdir/f$i)
1599 [ $count -ne $i ] && error "stripe count $count != $i" || true
1600 [ $index -ne $offset ] &&
1601 error "stripe offset $index != $offset" || true
1604 run_test 27wa "check $SETSTRIPE -c -i options"
1607 remote_ost_nodsh && skip "remote OST with nodsh" && return
1608 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs" && return
1609 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1610 OFFSET=$(($OSTCOUNT - 1))
1612 local OST=$(ostname_from_index $OSTIDX)
1614 test_mkdir -p $DIR/$tdir
1615 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe per file
1616 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1618 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1619 for i in `seq 0 $OFFSET`; do
1620 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}' | grep -w "$OSTIDX"` ] &&
1621 error "OST0 was degraded but new created file still use it"
1623 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1625 run_test 27x "create files while OST0 is degraded"
1628 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1629 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1630 remote_ost_nodsh && skip "remote OST with nodsh" && return
1631 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1633 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1634 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1635 osc.$mdtosc.prealloc_last_id)
1636 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1637 osc.$mdtosc.prealloc_next_id)
1638 local fcount=$((last_id - next_id))
1639 [ $fcount -eq 0 ] && skip "not enough space on OST0" && return
1640 [ $fcount -gt $OSTCOUNT ] && fcount=$OSTCOUNT
1642 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
1643 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
1644 local OST_DEACTIVE_IDX=-1
1649 for OSC in $MDS_OSCS; do
1650 OST=$(osc_to_ost $OSC)
1651 OSTIDX=$(index_from_ostuuid $OST)
1652 if [ $OST_DEACTIVE_IDX == -1 ]; then
1653 OST_DEACTIVE_IDX=$OSTIDX
1655 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
1656 echo $OSC "is Deactivated:"
1657 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1661 OSTIDX=$(index_from_ostuuid $OST)
1663 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1665 for OSC in $MDS_OSCS; do
1666 OST=$(osc_to_ost $OSC)
1667 OSTIDX=$(index_from_ostuuid $OST)
1668 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1669 echo $OST "is degraded:"
1670 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1671 obdfilter.$OST.degraded=1
1676 createmany -o $DIR/$tdir/$tfile $fcount
1678 for OSC in $MDS_OSCS; do
1679 OST=$(osc_to_ost $OSC)
1680 OSTIDX=$(index_from_ostuuid $OST)
1681 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1682 echo $OST "is recovered from degraded:"
1683 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1684 obdfilter.$OST.degraded=0
1686 do_facet $SINGLEMDS lctl --device %$OSC activate
1690 # all osp devices get activated, hence -1 stripe count restored
1693 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
1694 # devices get activated.
1696 $SETSTRIPE -c -1 $DIR/$tfile
1697 stripecnt=$($GETSTRIPE -c $DIR/$tfile)
1699 [ $stripecnt -ne $OSTCOUNT ] &&
1700 error "Of $OSTCOUNT OSTs, only $stripecnt is available"
1703 run_test 27y "create files while OST0 is degraded and the rest inactive"
1709 lmm_count=$($GETSTRIPE -c $1)
1710 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1711 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1713 local old_ifs="$IFS"
1715 fid=($($LFS path2fid $1))
1718 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1719 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1721 # compare lmm_seq and lu_fid->f_seq
1722 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1723 # compare lmm_object_id and lu_fid->oid
1724 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1726 # check the trusted.fid attribute of the OST objects of the file
1727 local have_obdidx=false
1729 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1730 # skip lines up to and including "obdidx"
1731 [ -z "$obdidx" ] && break
1732 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1733 $have_obdidx || continue
1735 local ost=$((obdidx + 1))
1736 local dev=$(ostdevname $ost)
1739 if [ $(facet_fstype ost$ost) != ldiskfs ]; then
1740 echo "Currently only works with ldiskfs-based OSTs"
1744 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1746 #don't unmount/remount the OSTs if we don't need to do that
1747 # LU-2577 changes filter_fid to be smaller, so debugfs needs
1748 # update too, until that use mount/ll_decode_filter_fid/mount
1749 local dir=$(facet_mntpt ost$ost)
1750 local opts=${OST_MOUNT_OPTS}
1752 if ! do_facet ost$ost test -b ${dev}; then
1753 opts=$(csa_add "$opts" -o loop)
1757 do_facet ost$ost mount -t $(facet_fstype ost$ost) $opts $dev $dir ||
1758 { error "mounting $dev as $FSTYPE failed"; return 3; }
1760 seq=$(echo $seq | sed -e "s/^0x//g")
1761 if [ $seq == 0 ]; then
1762 oid_hex=$(echo $oid)
1764 oid_hex=$(echo $hex | sed -e "s/^0x//g")
1766 local obj_file=$(do_facet ost$ost find $dir/O/$seq -name $oid_hex)
1767 local ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID $obj_file)
1768 do_facet ost$ost umount -d $dir
1769 start ost$ost $dev $OST_MOUNT_OPTS
1771 # re-enable when debugfs will understand new filter_fid
1772 #local ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
1773 # $dev 2>/dev/null" | grep "parent=")
1775 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
1777 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
1779 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
1780 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
1781 local ff_parent=$(echo $ff|sed -e 's/.*parent=.//')
1782 local ff_pseq=$(echo $ff_parent | cut -d: -f1)
1783 local ff_poid=$(echo $ff_parent | cut -d: -f2)
1784 local ff_pstripe=$(echo $ff_parent | sed -e 's/.*stripe=//')
1786 # compare lmm_seq and filter_fid->ff_parent.f_seq
1787 [ $ff_pseq = $lmm_seq ] ||
1788 error "FF parent SEQ $ff_pseq != $lmm_seq"
1789 # compare lmm_object_id and filter_fid->ff_parent.f_oid
1790 [ $ff_poid = $lmm_oid ] ||
1791 error "FF parent OID $ff_poid != $lmm_oid"
1792 [ $ff_pstripe = $stripe_nr ] ||
1793 error "FF stripe $ff_pstripe != $stripe_nr"
1795 stripe_nr=$((stripe_nr + 1))
1800 remote_ost_nodsh && skip "remote OST with nodsh" && return
1801 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1802 test_mkdir -p $DIR/$tdir
1804 $SETSTRIPE -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
1805 { error "setstripe -c -1 failed"; return 1; }
1806 # We need to send a write to every object to get parent FID info set.
1807 # This _should_ also work for setattr, but does not currently.
1808 # touch $DIR/$tdir/$tfile-1 ||
1809 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
1810 { error "dd $tfile-1 failed"; return 2; }
1811 $SETSTRIPE -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
1812 { error "setstripe -c -1 failed"; return 3; }
1813 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
1814 { error "dd $tfile-2 failed"; return 4; }
1816 # make sure write RPCs have been sent to OSTs
1819 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
1820 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
1822 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
1824 test_27A() { # b=19102
1825 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1826 local restore_size=$($GETSTRIPE -S $MOUNT)
1827 local restore_count=$($GETSTRIPE -c $MOUNT)
1828 local restore_offset=$($GETSTRIPE -i $MOUNT)
1829 $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
1830 local default_size=$($GETSTRIPE -S $MOUNT)
1831 local default_count=$($GETSTRIPE -c $MOUNT)
1832 local default_offset=$($GETSTRIPE -i $MOUNT)
1833 local dsize=$((1024 * 1024))
1834 [ $default_size -eq $dsize ] ||
1835 error "stripe size $default_size != $dsize"
1836 [ $default_count -eq 1 ] || error "stripe count $default_count != 1"
1837 [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
1838 $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
1840 run_test 27A "check filesystem-wide default LOV EA values"
1842 test_27B() { # LU-2523
1843 test_mkdir -p $DIR/$tdir
1844 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
1846 # open f1 with O_LOV_DELAY_CREATE
1848 # call setstripe ioctl on open file descriptor for f1
1850 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
1854 # open f1 with O_LOV_DELAY_CREATE
1856 # call setstripe ioctl on open file descriptor for f1
1858 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
1860 # Allow multiop to fail in imitation of NFS's busted semantics.
1863 run_test 27B "call setstripe on open unlinked file/rename victim"
1865 test_27C() { #LU-2871
1866 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
1873 test_mkdir -p $DIR/$tdir
1875 for i in $(seq 0 $((OSTCOUNT - 1))); do
1876 # set stripe across all OSTs starting from OST$i
1877 $SETSTRIPE -i $i -c -1 $tfile$i
1878 # get striping information
1879 ost_idx=($($GETSTRIPE $tfile$i |
1880 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
1883 for j in $(seq 0 $((OSTCOUNT - 1))); do
1884 index=$(((i + j) % OSTCOUNT))
1885 [ ${ost_idx[$j]} -eq $index ] ||
1886 error "$j:${ost_idx[$j]} != $index"
1890 run_test 27C "check full striping across all OSTs"
1892 # createtest also checks that device nodes are created and
1893 # then visible correctly (#2091)
1894 test_28() { # bug 2091
1896 $CREATETEST $DIR/d28/ct || error
1898 run_test 28 "create/mknod/mkdir with bad file types ============"
1901 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1902 cancel_lru_locks mdc
1908 declare -i LOCKCOUNTORIG=0
1909 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1910 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
1912 [ $LOCKCOUNTORIG -eq 0 ] && echo "No mdc lock count" && return 1
1914 declare -i LOCKUNUSEDCOUNTORIG=0
1915 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1916 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
1923 declare -i LOCKCOUNTCURRENT=0
1924 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1925 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
1928 declare -i LOCKUNUSEDCOUNTCURRENT=0
1929 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1930 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
1933 if [ "$LOCKCOUNTCURRENT" -gt "$LOCKCOUNTORIG" ]; then
1934 lctl set_param -n ldlm.dump_namespaces ""
1935 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
1936 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1937 log "dumped log to $TMP/test_29.dk (bug 5793)"
1940 if [ "$LOCKUNUSEDCOUNTCURRENT" -gt "$LOCKUNUSEDCOUNTORIG" ]; then
1941 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
1942 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1943 log "dumped log to $TMP/test_29.dk (bug 5793)"
1947 run_test 29 "IT_GETATTR regression ============================"
1949 test_30a() { # was test_30
1950 cp `which ls` $DIR || cp /bin/ls $DIR
1954 run_test 30a "execute binary from Lustre (execve) =============="
1957 cp `which ls` $DIR || cp /bin/ls $DIR
1959 $RUNAS $DIR/ls / || error
1962 run_test 30b "execute binary from Lustre as non-root ==========="
1964 test_30c() { # b=22376
1965 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1966 cp `which ls` $DIR || cp /bin/ls $DIR
1968 cancel_lru_locks mdc
1969 cancel_lru_locks osc
1970 $RUNAS $DIR/ls / || error
1973 run_test 30c "execute binary from Lustre without read perms ===="
1976 $OPENUNLINK $DIR/f31 $DIR/f31 || error
1977 $CHECKSTAT -a $DIR/f31 || error
1979 run_test 31a "open-unlink file =================================="
1982 touch $DIR/f31 || error
1983 ln $DIR/f31 $DIR/f31b || error
1984 $MULTIOP $DIR/f31b Ouc || error
1985 $CHECKSTAT -t file $DIR/f31 || error
1987 run_test 31b "unlink file with multiple links while open ======="
1990 touch $DIR/f31 || error
1991 ln $DIR/f31 $DIR/f31c || error
1992 multiop_bg_pause $DIR/f31 O_uc || return 1
1994 $MULTIOP $DIR/f31c Ouc
1995 kill -USR1 $MULTIPID
1998 run_test 31c "open-unlink file with multiple links ============="
2001 opendirunlink $DIR/d31d $DIR/d31d || error
2002 $CHECKSTAT -a $DIR/d31d || error
2004 run_test 31d "remove of open directory ========================="
2006 test_31e() { # bug 2904
2007 check_kernel_version 34 || return 0
2008 openfilleddirunlink $DIR/d31e || error
2010 run_test 31e "remove of open non-empty directory ==============="
2012 test_31f() { # bug 4554
2013 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2015 test_mkdir $DIR/d31f
2016 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2017 cp /etc/hosts $DIR/d31f
2019 $GETSTRIPE $DIR/d31f/hosts
2020 multiop_bg_pause $DIR/d31f D_c || return 1
2023 rm -rv $DIR/d31f || error "first of $DIR/d31f"
2024 test_mkdir $DIR/d31f
2025 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2026 cp /etc/hosts $DIR/d31f
2028 $GETSTRIPE $DIR/d31f/hosts
2029 multiop_bg_pause $DIR/d31f D_c || return 1
2032 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
2033 wait $MULTIPID || error "first opendir $MULTIPID failed"
2037 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
2038 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
2041 run_test 31f "remove of open directory with open-unlink file ==="
2044 echo "-- cross directory link --"
2045 test_mkdir $DIR/d31ga
2046 test_mkdir $DIR/d31gb
2048 ln $DIR/d31ga/f $DIR/d31gb/g
2049 $CHECKSTAT -t file $DIR/d31ga/f || error "source"
2050 [ `stat -c%h $DIR/d31ga/f` == '2' ] || error "source nlink"
2051 $CHECKSTAT -t file $DIR/d31gb/g || error "target"
2052 [ `stat -c%h $DIR/d31gb/g` == '2' ] || error "target nlink"
2054 run_test 31g "cross directory link==============="
2057 echo "-- cross directory link --"
2058 test_mkdir $DIR/d31h
2059 test_mkdir $DIR/d31h/dir
2061 ln $DIR/d31h/f $DIR/d31h/dir/g
2062 $CHECKSTAT -t file $DIR/d31h/f || error "source"
2063 [ `stat -c%h $DIR/d31h/f` == '2' ] || error "source nlink"
2064 $CHECKSTAT -t file $DIR/d31h/dir/g || error "target"
2065 [ `stat -c%h $DIR/d31h/dir/g` == '2' ] || error "target nlink"
2067 run_test 31h "cross directory link under child==============="
2070 echo "-- cross directory link --"
2071 test_mkdir $DIR/d31i
2072 test_mkdir $DIR/d31i/dir
2073 touch $DIR/d31i/dir/f
2074 ln $DIR/d31i/dir/f $DIR/d31i/g
2075 $CHECKSTAT -t file $DIR/d31i/dir/f || error "source"
2076 [ `stat -c%h $DIR/d31i/dir/f` == '2' ] || error "source nlink"
2077 $CHECKSTAT -t file $DIR/d31i/g || error "target"
2078 [ `stat -c%h $DIR/d31i/g` == '2' ] || error "target nlink"
2080 run_test 31i "cross directory link under parent==============="
2084 test_mkdir $DIR/d31j
2085 test_mkdir $DIR/d31j/dir1
2086 ln $DIR/d31j/dir1 $DIR/d31j/dir2 && error "ln for dir"
2087 link $DIR/d31j/dir1 $DIR/d31j/dir3 && error "link for dir"
2088 mlink $DIR/d31j/dir1 $DIR/d31j/dir4 && error "mlink for dir"
2089 mlink $DIR/d31j/dir1 $DIR/d31j/dir1 && error "mlink to the same dir"
2092 run_test 31j "link for directory==============="
2096 test_mkdir $DIR/d31k
2098 touch $DIR/d31k/exist
2099 mlink $DIR/d31k/s $DIR/d31k/t || error "mlink"
2100 mlink $DIR/d31k/s $DIR/d31k/exist && error "mlink to exist file"
2101 mlink $DIR/d31k/s $DIR/d31k/s && error "mlink to the same file"
2102 mlink $DIR/d31k/s $DIR/d31k && error "mlink to parent dir"
2103 mlink $DIR/d31k $DIR/d31k/s && error "mlink parent dir to target"
2104 mlink $DIR/d31k/not-exist $DIR/d31k/foo && error "mlink non-existing to new"
2105 mlink $DIR/d31k/not-exist $DIR/d31k/s && error "mlink non-existing to exist"
2108 run_test 31k "link to file: the same, non-existing, dir==============="
2111 test_mkdir $DIR/d31m
2113 test_mkdir $DIR/d31m2
2114 touch $DIR/d31m2/exist
2115 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
2116 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
2117 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
2118 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
2119 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
2120 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
2123 run_test 31m "link to file: the same, non-existing, dir==============="
2126 [ -e /proc/self/fd/173 ] && echo "skipping, fd 173 is in use" && return
2127 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
2128 nlink=$(stat --format=%h $DIR/$tfile)
2129 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2130 exec 173<$DIR/$tfile
2131 trap "exec 173<&-" EXIT
2132 nlink=$(stat --dereference --format=%h /proc/self/fd/173)
2133 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2134 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
2135 nlink=$(stat --dereference --format=%h /proc/self/fd/173)
2136 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
2139 run_test 31n "check link count of unlinked file"
2141 cleanup_test32_mount() {
2143 $UMOUNT $DIR/$tdir/ext2-mountpoint
2147 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2148 echo "== more mountpoints and symlinks ================="
2149 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2150 trap cleanup_test32_mount EXIT
2151 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2152 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2153 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. || error
2154 cleanup_test32_mount
2156 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
2159 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2160 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2161 trap cleanup_test32_mount EXIT
2162 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2163 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2164 ls -al $DIR/$tdir/ext2-mountpoint/.. || error
2165 cleanup_test32_mount
2167 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
2170 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2171 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2172 trap cleanup_test32_mount EXIT
2173 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2174 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2175 test_mkdir -p $DIR/$tdir/d2/test_dir
2176 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2177 cleanup_test32_mount
2179 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2182 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2183 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2184 trap cleanup_test32_mount EXIT
2185 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2186 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2187 test_mkdir -p $DIR/$tdir/d2/test_dir
2188 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2189 cleanup_test32_mount
2191 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
2194 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
2195 test_mkdir -p $DIR/d32e/tmp
2196 TMP_DIR=$DIR/d32e/tmp
2197 ln -s $DIR/d32e $TMP_DIR/symlink11
2198 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2199 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
2200 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
2202 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
2205 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
2206 test_mkdir -p $DIR/d32f/tmp
2207 TMP_DIR=$DIR/d32f/tmp
2208 ln -s $DIR/d32f $TMP_DIR/symlink11
2209 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2210 ls $DIR/d32f/tmp/symlink11 || error
2211 ls $DIR/d32f/symlink01 || error
2213 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
2216 TMP_DIR=$DIR/$tdir/tmp
2217 test_mkdir -p $DIR/$tdir/tmp
2218 test_mkdir $DIR/${tdir}2
2219 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2220 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2221 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
2222 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
2223 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
2224 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
2226 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2229 rm -fr $DIR/$tdir $DIR/${tdir}2
2230 TMP_DIR=$DIR/$tdir/tmp
2231 test_mkdir -p $DIR/$tdir/tmp
2232 test_mkdir $DIR/${tdir}2
2233 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2234 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2235 ls $TMP_DIR/symlink12 || error
2236 ls $DIR/$tdir/symlink02 || error
2238 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2241 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2242 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2243 trap cleanup_test32_mount EXIT
2244 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2245 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2246 touch $DIR/$tdir/test_file
2247 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file || error
2248 cleanup_test32_mount
2250 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
2253 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2254 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2255 trap cleanup_test32_mount EXIT
2256 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2257 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2258 touch $DIR/$tdir/test_file
2259 cat $DIR/$tdir/ext2-mountpoint/../test_file || error
2260 cleanup_test32_mount
2262 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
2265 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2267 trap cleanup_test32_mount EXIT
2268 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2269 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2270 test_mkdir -p $DIR/$tdir/d2
2271 touch $DIR/$tdir/d2/test_file || error
2272 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2273 cleanup_test32_mount
2275 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
2278 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2280 trap cleanup_test32_mount EXIT
2281 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2282 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2283 test_mkdir -p $DIR/$tdir/d2
2284 touch $DIR/$tdir/d2/test_file
2285 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2286 cleanup_test32_mount
2288 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
2292 test_mkdir -p $DIR/d32m/tmp
2293 TMP_DIR=$DIR/d32m/tmp
2294 ln -s $DIR $TMP_DIR/symlink11
2295 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2296 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
2297 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
2299 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
2303 test_mkdir -p $DIR/d32n/tmp
2304 TMP_DIR=$DIR/d32n/tmp
2305 ln -s $DIR $TMP_DIR/symlink11
2306 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2307 ls -l $DIR/d32n/tmp/symlink11 || error
2308 ls -l $DIR/d32n/symlink01 || error
2310 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
2313 rm -fr $DIR/d32o $DIR/$tfile
2315 test_mkdir -p $DIR/d32o/tmp
2316 TMP_DIR=$DIR/d32o/tmp
2317 ln -s $DIR/$tfile $TMP_DIR/symlink12
2318 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2319 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
2320 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
2321 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
2322 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
2324 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
2334 test_mkdir -p $DIR/d32p/tmp
2336 TMP_DIR=$DIR/d32p/tmp
2338 ln -s $DIR/$tfile $TMP_DIR/symlink12
2340 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2342 cat $DIR/d32p/tmp/symlink12 || error
2344 cat $DIR/d32p/symlink02 || error
2347 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
2349 cleanup_testdir_mount() {
2355 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2356 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2357 trap cleanup_testdir_mount EXIT
2358 test_mkdir -p $DIR/$tdir
2359 touch $DIR/$tdir/under_the_mount
2360 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2361 ls $DIR/$tdir | grep "\<under_the_mount\>" && error
2362 cleanup_testdir_mount
2364 run_test 32q "stat follows mountpoints in Lustre (should return error)"
2367 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2368 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2369 trap cleanup_testdir_mount EXIT
2370 test_mkdir -p $DIR/$tdir
2371 touch $DIR/$tdir/under_the_mount
2372 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2373 ls $DIR/$tdir | grep -q under_the_mount && error || true
2374 cleanup_testdir_mount
2376 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
2381 chmod 444 $DIR/$tfile
2382 chown $RUNAS_ID $DIR/$tfile
2384 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2387 run_test 33aa "write file with mode 444 (should return error) ===="
2391 test_mkdir -p $DIR/d33
2392 chown $RUNAS_ID $DIR/d33
2393 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
2394 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
2395 error "open RDWR" || true
2397 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
2401 test_mkdir -p $DIR/d33
2402 chown $RUNAS_ID $DIR/d33
2403 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33 && error "create" || true
2405 run_test 33b "test open file with malformed flags (No panic and return error)"
2408 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2414 remote_ost_nodsh && skip "remote OST with nodsh" && return
2417 test_mkdir -p $DIR/d33
2418 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2421 for ostnum in $(seq $OSTCOUNT); do
2422 # test-framework's OST numbering is one-based, while Lustre's
2424 ostname=$(printf "$FSNAME-OST%.4d" $((ostnum - 1)))
2425 # Parsing llobdstat's output sucks; we could grep the /proc
2426 # path, but that's likely to not be as portable as using the
2427 # llobdstat utility. So we parse lctl output instead.
2428 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2429 obdfilter/$ostname/stats |
2430 awk '/^write_bytes/ {print $7}' )
2431 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2432 if (( ${write_bytes:-0} > 0 ))
2439 $all_zeros || return 0
2442 echo foo > $DIR/d33/bar
2446 # Total up write_bytes after writing. We'd better find non-zeros.
2447 for ostnum in $(seq $OSTCOUNT); do
2448 ostname=$(printf "$FSNAME-OST%.4d" $((ostnum - 1)))
2449 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2450 obdfilter/$ostname/stats |
2451 awk '/^write_bytes/ {print $7}' )
2452 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2453 if (( ${write_bytes:-0} > 0 ))
2462 for ostnum in $(seq $OSTCOUNT); do
2463 ostname=$(printf "$FSNAME-OST%.4d" $((ostnum - 1)))
2464 echo "Check that write_bytes is present in obdfilter/*/stats:"
2465 do_facet ost$ostnum lctl get_param -n \
2466 obdfilter/$ostname/stats
2468 error "OST not keeping write_bytes stats (b22312)"
2471 run_test 33c "test llobdstat and write_bytes"
2474 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2475 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2477 local remote_dir=$DIR/$tdir/remote_dir
2480 $LFS mkdir -i $MDTIDX $remote_dir ||
2481 error "create remote directory failed"
2483 touch $remote_dir/$tfile
2484 chmod 444 $remote_dir/$tfile
2485 chown $RUNAS_ID $remote_dir/$tfile
2487 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2489 chown $RUNAS_ID $remote_dir
2490 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
2491 error "create" || true
2492 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
2493 error "open RDWR" || true
2494 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 &&
2495 error "create" || true
2497 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
2499 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
2502 $MCREATE $DIR/f34 || error
2503 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2504 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
2505 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2506 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2508 run_test 34a "truncate file that has not been opened ==========="
2511 [ ! -f $DIR/f34 ] && test_34a
2512 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2513 $OPENFILE -f O_RDONLY $DIR/f34
2514 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2515 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2517 run_test 34b "O_RDONLY opening file doesn't create objects ====="
2520 [ ! -f $DIR/f34 ] && test_34a
2521 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2522 $OPENFILE -f O_RDWR $DIR/f34
2523 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2524 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2526 run_test 34c "O_RDWR opening file-with-size works =============="
2529 [ ! -f $DIR/f34 ] && test_34a
2530 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2531 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2534 run_test 34d "write to sparse file ============================="
2538 $MCREATE $DIR/f34e || error
2539 $TRUNCATE $DIR/f34e 1000 || error
2540 $CHECKSTAT -s 1000 $DIR/f34e || error
2541 $OPENFILE -f O_RDWR $DIR/f34e
2542 $CHECKSTAT -s 1000 $DIR/f34e || error
2544 run_test 34e "create objects, some with size and some without =="
2546 test_34f() { # bug 6242, 6243
2547 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2550 $MCREATE $DIR/f34f || error
2551 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
2552 dd if=$DIR/f34f of=$TMP/f34f
2553 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
2554 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
2555 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
2556 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
2557 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
2559 run_test 34f "read from a file with no objects until EOF ======="
2562 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2563 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
2564 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
2565 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
2566 cancel_lru_locks osc
2567 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
2568 error "wrong size after lock cancel"
2570 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
2571 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2572 error "expanding truncate failed"
2573 cancel_lru_locks osc
2574 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2575 error "wrong expanded size after lock cancel"
2577 run_test 34g "truncate long file ==============================="
2580 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2584 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
2585 sync # Flush the cache so that multiop below does not block on cache
2586 # flush when getting the group lock
2587 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
2591 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
2592 error "Multiop blocked on ftruncate, pid=$MULTIPID"
2596 local nsz=`stat -c %s $DIR/$tfile`
2597 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
2599 run_test 34h "ftruncate file under grouplock should not block"
2602 cp /bin/sh $DIR/f35a
2604 chown $RUNAS_ID $DIR/f35a
2605 $RUNAS $DIR/f35a && error || true
2608 run_test 35a "exec file with mode 444 (should return and not leak) ====="
2612 utime $DIR/f36 || error
2614 run_test 36a "MDS utime check (mknod, utime) ==================="
2618 utime $DIR/f36 || error
2620 run_test 36b "OST utime check (open, utime) ===================="
2625 chown $RUNAS_ID $DIR/d36
2626 $RUNAS utime $DIR/d36/f36 || error
2628 run_test 36c "non-root MDS utime check (mknod, utime) =========="
2631 [ ! -d $DIR/d36 ] && test_36c
2632 echo "" > $DIR/d36/f36
2633 $RUNAS utime $DIR/d36/f36 || error
2635 run_test 36d "non-root OST utime check (open, utime) ==========="
2638 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
2639 test_mkdir -p $DIR/$tdir
2640 touch $DIR/$tdir/$tfile
2641 $RUNAS utime $DIR/$tdir/$tfile && \
2642 error "utime worked, expected failure" || true
2644 run_test 36e "utime on non-owned file (should return error) ===="
2648 local LANG_SAVE=$LANG
2649 local LC_LANG_SAVE=$LC_LANG
2650 export LANG=C LC_LANG=C # for date language
2652 DATESTR="Dec 20 2000"
2653 test_mkdir -p $DIR/$tdir
2654 lctl set_param fail_loc=$fl
2656 cp /etc/hosts $DIR/$tdir/$tfile
2657 sync & # write RPC generated with "current" inode timestamp, but delayed
2659 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
2660 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
2661 cancel_lru_locks osc
2662 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
2664 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
2665 echo "BEFORE: $LS_BEFORE" && \
2666 echo "AFTER : $LS_AFTER" && \
2667 echo "WANT : $DATESTR" && \
2668 error "$DIR/$tdir/$tfile timestamps changed" || true
2670 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
2674 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2675 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2676 subr_36fh "0x80000214"
2678 run_test 36f "utime on file racing with OST BRW write =========="
2681 remote_ost_nodsh && skip "remote OST with nodsh" && return
2682 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2687 test_mkdir -p $DIR/$tdir
2688 fmd_max_age=$(do_facet ost1 \
2689 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
2692 fmd_before=$(do_facet ost1 \
2693 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2694 touch $DIR/$tdir/$tfile
2695 sleep $((fmd_max_age + 12))
2696 fmd_after=$(do_facet ost1 \
2697 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2699 echo "fmd_before: $fmd_before"
2700 echo "fmd_after: $fmd_after"
2701 [ "$fmd_after" -gt "$fmd_before" ] && \
2702 echo "AFTER: $fmd_after > BEFORE: $fmd_before" && \
2703 error "fmd didn't expire after ping" || true
2705 run_test 36g "filter mod data cache expiry ====================="
2708 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2709 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
2710 subr_36fh "0x80000227"
2712 run_test 36h "utime on file racing with OST BRW write =========="
2714 # test_37 - duplicate with tests 32q 32r
2717 local file=$DIR/$tfile
2719 openfile -f O_DIRECTORY $file
2722 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
2723 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
2725 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
2729 touch $DIR/${tfile}2
2730 # ls -l $DIR/$tfile $DIR/${tfile}2
2731 # ls -lu $DIR/$tfile $DIR/${tfile}2
2732 # ls -lc $DIR/$tfile $DIR/${tfile}2
2734 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
2735 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
2737 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
2739 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
2741 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
2742 error "O_TRUNC didn't change timestamps"
2745 run_test 39 "mtime changed on create ==========================="
2748 test_mkdir -p $DIR/$tdir
2749 cp -p /etc/passwd $DIR/$tdir/fopen
2750 cp -p /etc/passwd $DIR/$tdir/flink
2751 cp -p /etc/passwd $DIR/$tdir/funlink
2752 cp -p /etc/passwd $DIR/$tdir/frename
2753 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
2756 echo "aaaaaa" >> $DIR/$tdir/fopen
2757 echo "aaaaaa" >> $DIR/$tdir/flink
2758 echo "aaaaaa" >> $DIR/$tdir/funlink
2759 echo "aaaaaa" >> $DIR/$tdir/frename
2761 local open_new=`stat -c %Y $DIR/$tdir/fopen`
2762 local link_new=`stat -c %Y $DIR/$tdir/flink`
2763 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
2764 local rename_new=`stat -c %Y $DIR/$tdir/frename`
2766 cat $DIR/$tdir/fopen > /dev/null
2767 ln $DIR/$tdir/flink $DIR/$tdir/flink2
2768 rm -f $DIR/$tdir/funlink2
2769 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
2771 for (( i=0; i < 2; i++ )) ; do
2772 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
2773 local link_new2=`stat -c %Y $DIR/$tdir/flink`
2774 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
2775 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
2777 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
2778 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
2779 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
2780 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
2782 cancel_lru_locks osc
2783 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2786 run_test 39b "mtime change on open, link, unlink, rename ======"
2788 # this should be set to past
2789 TEST_39_MTIME=`date -d "1 year ago" +%s`
2795 local mtime0=`stat -c %Y $DIR1/$tfile`
2797 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2798 local mtime1=`stat -c %Y $DIR1/$tfile`
2799 [ "$mtime1" = $TEST_39_MTIME ] || \
2800 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
2803 echo hello >> $DIR1/$tfile
2805 local mtime2=`stat -c %Y $DIR1/$tfile`
2806 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
2807 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
2809 mv $DIR1/$tfile $DIR1/$tfile-1
2811 for (( i=0; i < 2; i++ )) ; do
2812 local mtime3=`stat -c %Y $DIR1/$tfile-1`
2813 [ "$mtime2" = "$mtime3" ] || \
2814 error "mtime ($mtime2) changed (to $mtime3) on rename"
2816 cancel_lru_locks osc
2817 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2820 run_test 39c "mtime change on rename ==========================="
2824 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2827 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2829 for (( i=0; i < 2; i++ )) ; do
2830 local mtime=`stat -c %Y $DIR1/$tfile`
2831 [ $mtime = $TEST_39_MTIME ] || \
2832 error "mtime($mtime) is not set to $TEST_39_MTIME"
2834 cancel_lru_locks osc
2835 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2838 run_test 39d "create, utime, stat =============================="
2842 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2844 local mtime1=`stat -c %Y $DIR1/$tfile`
2846 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2848 for (( i=0; i < 2; i++ )) ; do
2849 local mtime2=`stat -c %Y $DIR1/$tfile`
2850 [ $mtime2 = $TEST_39_MTIME ] || \
2851 error "mtime($mtime2) is not set to $TEST_39_MTIME"
2853 cancel_lru_locks osc
2854 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2857 run_test 39e "create, stat, utime, stat ========================"
2861 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2863 mtime1=`stat -c %Y $DIR1/$tfile`
2866 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2868 for (( i=0; i < 2; i++ )) ; do
2869 local mtime2=`stat -c %Y $DIR1/$tfile`
2870 [ $mtime2 = $TEST_39_MTIME ] || \
2871 error "mtime($mtime2) is not set to $TEST_39_MTIME"
2873 cancel_lru_locks osc
2874 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2877 run_test 39f "create, stat, sleep, utime, stat ================="
2881 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2882 echo hello >> $DIR1/$tfile
2883 local mtime1=`stat -c %Y $DIR1/$tfile`
2886 chmod o+r $DIR1/$tfile
2888 for (( i=0; i < 2; i++ )) ; do
2889 local mtime2=`stat -c %Y $DIR1/$tfile`
2890 [ "$mtime1" = "$mtime2" ] || \
2891 error "lost mtime: $mtime2, should be $mtime1"
2893 cancel_lru_locks osc
2894 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2897 run_test 39g "write, chmod, stat ==============================="
2901 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2906 echo hello >> $DIR1/$tfile
2907 local mtime1=`stat -c %Y $DIR1/$tfile`
2909 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2911 if [ "$d1" != "$d2" ]; then
2912 echo "write and touch not within one second"
2914 for (( i=0; i < 2; i++ )) ; do
2915 local mtime2=`stat -c %Y $DIR1/$tfile`
2916 [ "$mtime2" = $TEST_39_MTIME ] || \
2917 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
2919 cancel_lru_locks osc
2920 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2924 run_test 39h "write, utime within one second, stat ============="
2927 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2931 echo hello >> $DIR1/$tfile
2932 local mtime1=`stat -c %Y $DIR1/$tfile`
2934 mv $DIR1/$tfile $DIR1/$tfile-1
2936 for (( i=0; i < 2; i++ )) ; do
2937 local mtime2=`stat -c %Y $DIR1/$tfile-1`
2939 [ "$mtime1" = "$mtime2" ] || \
2940 error "lost mtime: $mtime2, should be $mtime1"
2942 cancel_lru_locks osc
2943 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2946 run_test 39i "write, rename, stat =============================="
2949 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2950 start_full_debug_logging
2954 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
2955 lctl set_param fail_loc=0x80000412
2956 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
2957 error "multiop failed"
2959 local mtime1=`stat -c %Y $DIR1/$tfile`
2961 mv $DIR1/$tfile $DIR1/$tfile-1
2963 kill -USR1 $multipid
2964 wait $multipid || error "multiop close failed"
2966 for (( i=0; i < 2; i++ )) ; do
2967 local mtime2=`stat -c %Y $DIR1/$tfile-1`
2968 [ "$mtime1" = "$mtime2" ] ||
2969 error "mtime is lost on close: $mtime2, " \
2972 cancel_lru_locks osc
2973 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2975 lctl set_param fail_loc=0
2976 stop_full_debug_logging
2978 run_test 39j "write, rename, close, stat ======================="
2981 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2985 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
2987 local mtime1=`stat -c %Y $DIR1/$tfile`
2989 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2991 kill -USR1 $multipid
2992 wait $multipid || error "multiop close failed"
2994 for (( i=0; i < 2; i++ )) ; do
2995 local mtime2=`stat -c %Y $DIR1/$tfile`
2997 [ "$mtime2" = $TEST_39_MTIME ] || \
2998 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
3000 cancel_lru_locks osc
3001 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3004 run_test 39k "write, utime, close, stat ========================"
3006 # this should be set to future
3007 TEST_39_ATIME=`date -d "1 year" +%s`
3010 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3011 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3012 local atime_diff=$(do_facet $SINGLEMDS \
3013 lctl get_param -n mdd.*MDT0000*.atime_diff)
3017 # test setting directory atime to future
3018 touch -a -d @$TEST_39_ATIME $DIR/$tdir
3019 local atime=$(stat -c %X $DIR/$tdir)
3020 [ "$atime" = $TEST_39_ATIME ] || \
3021 error "atime is not set to future: $atime, $TEST_39_ATIME"
3023 # test setting directory atime from future to now
3024 local d1=$(date +%s)
3026 local d2=$(date +%s)
3028 cancel_lru_locks mdc
3029 atime=$(stat -c %X $DIR/$tdir)
3030 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3031 error "atime is not updated from future: $atime, $d1<atime<$d2"
3033 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
3036 # test setting directory atime when now > dir atime + atime_diff
3040 cancel_lru_locks mdc
3041 atime=$(stat -c %X $DIR/$tdir)
3042 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3043 error "atime is not updated : $atime, should be $d2"
3045 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
3048 # test not setting directory atime when now < dir atime + atime_diff
3050 cancel_lru_locks mdc
3051 atime=$(stat -c %X $DIR/$tdir)
3052 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3053 error "atime is updated to $atime, should remain $d1<atime<$d2"
3055 do_facet $SINGLEMDS \
3056 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3058 run_test 39l "directory atime update ==========================="
3061 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3064 local far_past_mtime=$(date -d "May 29 1953" +%s)
3065 local far_past_atime=$(date -d "Dec 17 1903" +%s)
3067 touch -m -d @$far_past_mtime $DIR1/$tfile
3068 touch -a -d @$far_past_atime $DIR1/$tfile
3070 for (( i=0; i < 2; i++ )) ; do
3071 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
3072 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
3073 error "atime or mtime set incorrectly"
3075 cancel_lru_locks osc
3076 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3079 run_test 39m "test atime and mtime before 1970"
3082 dd if=/dev/zero of=$DIR/f40 bs=4096 count=1
3083 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/f40 && error
3084 $CHECKSTAT -t file -s 4096 $DIR/f40 || error
3086 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
3090 small_write $DIR/f41 18
3092 run_test 41 "test small file write + fstat ====================="
3094 count_ost_writes() {
3095 lctl get_param -n osc.*.stats |
3096 awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }'
3103 BG_DIRTY_RATIO_SAVE=10
3104 MAX_BG_DIRTY_RATIO=25
3108 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
3109 # dirty_ratio, dirty_background_ratio
3110 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3111 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
3112 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
3113 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
3115 # if file not here, we are a 2.4 kernel
3116 kill -CONT `pidof kupdated`
3121 # setup the trap first, so someone cannot exit the test at the
3122 # exact wrong time and mess up a machine
3123 trap start_writeback EXIT
3124 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
3125 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3126 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
3127 sysctl -w vm.dirty_writeback_centisecs=0
3128 sysctl -w vm.dirty_writeback_centisecs=0
3129 # save and increase /proc/sys/vm/dirty_ratio
3130 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
3131 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
3132 # save and increase /proc/sys/vm/dirty_background_ratio
3133 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
3134 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
3136 # if file not here, we are a 2.4 kernel
3137 kill -STOP `pidof kupdated`
3141 # ensure that all stripes have some grant before we test client-side cache
3143 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
3144 dd if=/dev/zero of=$i bs=4k count=1
3149 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
3150 # file truncation, and file removal.
3152 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3154 cancel_lru_locks osc
3156 sync; sleep 1; sync # just to be safe
3157 BEFOREWRITES=`count_ost_writes`
3158 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
3159 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
3160 AFTERWRITES=`count_ost_writes`
3161 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3162 error "$BEFOREWRITES < $AFTERWRITES"
3165 run_test 42a "ensure that we don't flush on close =============="
3168 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3170 cancel_lru_locks osc
3173 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
3174 BEFOREWRITES=`count_ost_writes`
3175 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
3176 AFTERWRITES=`count_ost_writes`
3177 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
3178 error "$BEFOREWRITES < $AFTERWRITES on unlink"
3180 BEFOREWRITES=`count_ost_writes`
3181 sync || error "sync: $?"
3182 AFTERWRITES=`count_ost_writes`
3183 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
3184 error "$BEFOREWRITES < $AFTERWRITES on sync"
3186 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
3190 run_test 42b "test destroy of file with cached dirty data ======"
3192 # if these tests just want to test the effect of truncation,
3193 # they have to be very careful. consider:
3194 # - the first open gets a {0,EOF}PR lock
3195 # - the first write conflicts and gets a {0, count-1}PW
3196 # - the rest of the writes are under {count,EOF}PW
3197 # - the open for truncate tries to match a {0,EOF}PR
3198 # for the filesize and cancels the PWs.
3199 # any number of fixes (don't get {0,EOF} on open, match
3200 # composite locks, do smarter file size management) fix
3201 # this, but for now we want these tests to verify that
3202 # the cancellation with truncate intent works, so we
3203 # start the file with a full-file pw lock to match against
3204 # until the truncate.
3209 cancel_lru_locks osc
3211 # prime the file with 0,EOF PW to match
3215 # now the real test..
3216 dd if=/dev/zero of=$file bs=1024 count=100
3217 BEFOREWRITES=`count_ost_writes`
3218 $TRUNCATE $file $offset
3219 cancel_lru_locks osc
3220 AFTERWRITES=`count_ost_writes`
3225 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3227 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
3228 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
3231 run_test 42c "test partial truncate of file with cached dirty data"
3234 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3236 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3237 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
3240 run_test 42d "test complete truncate of file with cached dirty data"
3242 test_42e() { # bug22074
3243 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3244 local TDIR=$DIR/${tdir}e
3245 local pagesz=$(page_size)
3246 local pages=16 # hardcoded 16 pages, don't change it.
3247 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
3248 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
3252 test_mkdir -p $DIR/${tdir}e
3253 $SETSTRIPE -c 1 $TDIR
3254 createmany -o $TDIR/f $files
3256 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
3258 # we assume that with $OSTCOUNT files, at least one of them will
3259 # be allocated on OST0.
3260 warmup_files=$((OSTCOUNT * max_dirty_mb))
3261 createmany -o $TDIR/w $warmup_files
3263 # write a large amount of data into one file and sync, to get good
3264 # avail_grant number from OST.
3265 for ((i=0; i<$warmup_files; i++)); do
3266 idx=$($GETSTRIPE -i $TDIR/w$i)
3267 [ $idx -ne 0 ] && continue
3268 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
3271 [ $i -gt $warmup_files ] && error "OST0 is still cold"
3273 $LCTL get_param $proc_osc0/cur_dirty_bytes
3274 $LCTL get_param $proc_osc0/cur_grant_bytes
3276 # create as much dirty pages as we can while not to trigger the actual
3277 # RPCs directly. but depends on the env, VFS may trigger flush during this
3278 # period, hopefully we are good.
3279 for ((i=0; i<$warmup_files; i++)); do
3280 idx=$($GETSTRIPE -i $TDIR/w$i)
3281 [ $idx -ne 0 ] && continue
3282 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
3284 $LCTL get_param $proc_osc0/cur_dirty_bytes
3285 $LCTL get_param $proc_osc0/cur_grant_bytes
3287 # perform the real test
3288 $LCTL set_param $proc_osc0/rpc_stats 0
3289 for ((;i<$files; i++)); do
3290 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
3291 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
3294 $LCTL get_param $proc_osc0/rpc_stats
3297 local have_ppr=false
3298 $LCTL get_param $proc_osc0/rpc_stats |
3299 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
3300 # skip lines until we are at the RPC histogram data
3301 [ "$PPR" == "pages" ] && have_ppr=true && continue
3302 $have_ppr || continue
3304 # we only want the percent stat for < 16 pages
3305 [ $(echo $PPR | tr -d ':') -ge $pages ] && break
3307 percent=$((percent + WPCT))
3308 if [ $percent -gt 15 ]; then
3309 error "less than 16-pages write RPCs" \
3316 run_test 42e "verify sub-RPC writes are not done synchronously"
3319 test_mkdir -p $DIR/$tdir
3320 cp -p /bin/ls $DIR/$tdir/$tfile
3321 $MULTIOP $DIR/$tdir/$tfile Ow_c &
3323 # give multiop a chance to open
3326 $DIR/$tdir/$tfile && error || true
3329 run_test 43 "execution of file opened for write should return -ETXTBSY"
3332 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3333 test_mkdir -p $DIR/$tdir
3334 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3335 cp -p multiop $DIR/$tdir/multiop
3336 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/test43.junk O_c ||
3339 $MULTIOP $DIR/$tdir/multiop Oc && error "expected error, got success"
3340 kill -USR1 $MULTIOP_PID || return 2
3341 wait $MULTIOP_PID || return 3
3344 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
3347 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3348 test_mkdir -p $DIR/$tdir
3349 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3350 cp -p multiop $DIR/$tdir/multiop
3351 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/test43.junk O_c ||
3354 $TRUNCATE $DIR/$tdir/multiop 0 && error "expected error, got success"
3355 kill -USR1 $MULTIOP_PID || return 2
3356 wait $MULTIOP_PID || return 3
3359 run_test 43b "truncate of file being executed should return -ETXTBSY"
3362 local testdir="$DIR/$tdir"
3363 test_mkdir -p $DIR/$tdir
3365 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
3366 ( cd $testdir && md5sum -c)
3368 run_test 43c "md5sum of copy into lustre========================"
3371 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
3372 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
3373 dd if=$DIR/f1 bs=4k count=1 > /dev/null
3375 run_test 44 "zero length read from a sparse stripe ============="
3378 local nstripe=`$LCTL lov_getconfig $DIR | grep default_stripe_count: | \
3380 [ -z "$nstripe" ] && skip "can't get stripe info" && return
3381 [ "$nstripe" -gt "$OSTCOUNT" ] && skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" && return
3382 local stride=`$LCTL lov_getconfig $DIR | grep default_stripe_size: | \
3384 if [ $nstripe -eq 0 -o $nstripe -eq -1 ] ; then
3385 nstripe=`$LCTL lov_getconfig $DIR | grep obd_count: | awk '{print $2}'`
3388 OFFSETS="0 $((stride/2)) $((stride-1))"
3389 for offset in $OFFSETS ; do
3390 for i in `seq 0 $((nstripe-1))`; do
3391 local GLOBALOFFSETS=""
3392 local size=$((((i + 2 * $nstripe )*$stride + $offset))) # Bytes
3393 local myfn=$DIR/d44a-$size
3394 echo "--------writing $myfn at $size"
3395 ll_sparseness_write $myfn $size || error "ll_sparseness_write"
3396 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3397 ll_sparseness_verify $myfn $GLOBALOFFSETS \
3398 || error "ll_sparseness_verify $GLOBALOFFSETS"
3400 for j in `seq 0 $((nstripe-1))`; do
3401 size=$((((j + $nstripe )*$stride + $offset))) # Bytes
3402 ll_sparseness_write $myfn $size || error "ll_sparseness_write"
3403 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3405 ll_sparseness_verify $myfn $GLOBALOFFSETS \
3406 || error "ll_sparseness_verify $GLOBALOFFSETS"
3411 run_test 44a "test sparse pwrite ==============================="
3415 for d in `lctl get_param -n osc.*.cur_dirty_bytes`; do
3421 before=`dirty_osc_total`
3422 echo executing "\"$*\""