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 touch $DIR/f || error "Failed to touch $DIR/f: $?"
682 ls $DIR || error "Failed to ls $DIR: $?"
684 run_test 18 "touch .../f ; ls ... =============================="
690 $CHECKSTAT -a $DIR/f19 || error
692 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
695 ls -l $DIR/f19 && error || true
697 run_test 19b "ls -l .../f19 (should return error) =============="
700 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
701 $RUNAS touch $DIR/f19 && error || true
703 run_test 19c "$RUNAS touch .../f19 (should return error) =="
706 cat $DIR/f19 && error || true
708 run_test 19d "cat .../f19 (should return error) =============="
720 $CHECKSTAT -a $DIR/f || error
722 run_test 20 "touch .../f ; ls -l ... ==========================="
726 [ -f $DIR/d21/dangle ] && rm -f $DIR/d21/dangle
727 ln -s dangle $DIR/d21/link
728 echo foo >> $DIR/d21/link
730 $CHECKSTAT -t link $DIR/d21/link || error
731 $CHECKSTAT -f -t file $DIR/d21/link || error
733 run_test 21 "write to dangling link ============================"
737 test_mkdir -p $DIR/$tdir
738 chown $RUNAS_ID:$RUNAS_GID $WDIR
739 (cd $WDIR || error "cd $WDIR failed";
740 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
742 ls -lR $WDIR/etc || error "ls -lR $WDIR/etc failed"
743 $CHECKSTAT -t dir $WDIR/etc || error "checkstat -t dir failed"
744 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $WDIR/etc || error "checkstat -u failed"
746 run_test 22 "unpack tar archive as non-root user ==============="
750 test_mkdir -p $DIR/$tdir
751 local file=$DIR/$tdir/$tfile
753 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
754 openfile -f O_CREAT:O_EXCL $file &&
755 error "$file recreate succeeded" || true
757 run_test 23a "O_CREAT|O_EXCL in subdir =========================="
759 test_23b() { # bug 18988
760 test_mkdir -p $DIR/$tdir
761 local file=$DIR/$tdir/$tfile
764 echo foo > $file || error "write filed"
765 echo bar >> $file || error "append filed"
766 $CHECKSTAT -s 8 $file || error "wrong size"
769 run_test 23b "O_APPEND check =========================="
772 echo '== rename sanity =============================================='
773 echo '-- same directory rename'
776 mv $DIR/R1/f $DIR/R1/g
777 $CHECKSTAT -t file $DIR/R1/g || error
779 run_test 24a "touch .../R1/f; rename .../R1/f .../R1/g ========="
784 mv $DIR/R2/f $DIR/R2/g
785 $CHECKSTAT -a $DIR/R2/f || error
786 $CHECKSTAT -t file $DIR/R2/g || error
788 run_test 24b "touch .../R2/{f,g}; rename .../R2/f .../R2/g ====="
793 mv $DIR/R3/f $DIR/R3/g
794 $CHECKSTAT -a $DIR/R3/f || error
795 $CHECKSTAT -t dir $DIR/R3/g || error
797 run_test 24c "mkdir .../R3/f; rename .../R3/f .../R3/g ========="
803 mrename $DIR/R4/f $DIR/R4/g
804 $CHECKSTAT -a $DIR/R4/f || error
805 $CHECKSTAT -t dir $DIR/R4/g || error
807 run_test 24d "mkdir .../R4/{f,g}; rename .../R4/f .../R4/g ====="
810 echo '-- cross directory renames --'
814 mv $DIR/R5a/f $DIR/R5b/g
815 $CHECKSTAT -a $DIR/R5a/f || error
816 $CHECKSTAT -t file $DIR/R5b/g || error
818 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
823 touch $DIR/R6a/f $DIR/R6b/g
824 mv $DIR/R6a/f $DIR/R6b/g
825 $CHECKSTAT -a $DIR/R6a/f || error
826 $CHECKSTAT -t file $DIR/R6b/g || error
828 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
833 test_mkdir $DIR/R7a/d
834 mv $DIR/R7a/d $DIR/R7b/e
835 $CHECKSTAT -a $DIR/R7a/d || error
836 $CHECKSTAT -t dir $DIR/R7b/e || error
838 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
843 test_mkdir $DIR/R8a/d
844 test_mkdir $DIR/R8b/e
845 mrename $DIR/R8a/d $DIR/R8b/e
846 $CHECKSTAT -a $DIR/R8a/d || error
847 $CHECKSTAT -t dir $DIR/R8b/e || error
849 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
852 echo "-- rename error cases"
856 mrename $DIR/R9/f $DIR/R9/a
857 $CHECKSTAT -t file $DIR/R9/f || error
858 $CHECKSTAT -t dir $DIR/R9/a || error
859 $CHECKSTAT -a $DIR/R9/a/f || error
861 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
865 mrename $DIR/R10/f $DIR/R10/g
866 $CHECKSTAT -t dir $DIR/R10 || error
867 $CHECKSTAT -a $DIR/R10/f || error
868 $CHECKSTAT -a $DIR/R10/g || error
870 run_test 24j "source does not exist ============================"
874 test_mkdir $DIR/R11a/d
876 mv $DIR/R11a/f $DIR/R11a/d
877 $CHECKSTAT -a $DIR/R11a/f || error
878 $CHECKSTAT -t file $DIR/R11a/d/f || error
880 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
882 # bug 2429 - rename foo foo foo creates invalid file
885 $MULTIOP $f OcNs || error
887 run_test 24l "Renaming a file to itself ========================"
891 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
892 # on ext3 this does not remove either the source or target files
893 # though the "expected" operation would be to remove the source
894 $CHECKSTAT -t file ${f} || error "${f} missing"
895 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
897 run_test 24m "Renaming a file to a hard link to itself ========="
901 # this stats the old file after it was renamed, so it should fail
905 $CHECKSTAT ${f}.rename
908 run_test 24n "Statting the old file after renaming (Posix rename 2)"
911 check_kernel_version 37 || return 0
912 test_mkdir -p $DIR/d24o
913 rename_many -s random -v -n 10 $DIR/d24o
915 run_test 24o "rename of files during htree split ==============="
920 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
921 mrename $DIR/R12a $DIR/R12b
922 $CHECKSTAT -a $DIR/R12a || error
923 $CHECKSTAT -t dir $DIR/R12b || error
924 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
925 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
927 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
929 cleanup_multiop_pause() {
935 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
938 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
939 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
942 trap cleanup_multiop_pause EXIT
943 mrename $DIR/R13a $DIR/R13b
944 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
945 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
946 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
947 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
948 cleanup_multiop_pause
949 wait $MULTIPID || error "multiop close failed"
951 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
953 test_24r() { #bug 3789
955 test_mkdir $DIR/R14a/b
956 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
957 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
958 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
960 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
964 test_mkdir $DIR/R15a/b
965 test_mkdir $DIR/R15a/b/c
966 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
967 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
968 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
970 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
973 test_mkdir $DIR/R16a/b
974 test_mkdir $DIR/R16a/b/c
975 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
976 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
977 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
979 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
981 test_24u() { # bug12192
983 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error
984 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
986 run_test 24u "create stripe file"
992 simple_cleanup_common() {
995 wait_delete_completed
998 max_pages_per_rpc() {
999 $LCTL get_param -n mdc.*.max_pages_per_rpc | head -1
1003 local NRFILES=100000
1004 local FREE_INODES=$(lfs_df -i | grep "summary" | awk '{print $4}')
1005 [ $FREE_INODES -lt $NRFILES ] && \
1006 skip "not enough free inodes $FREE_INODES required $NRFILES" &&
1009 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1010 trap simple_cleanup_common EXIT
1013 createmany -m $DIR/$tdir/$tfile $NRFILES
1015 cancel_lru_locks mdc
1016 lctl set_param mdc.*.stats clear
1018 ls $DIR/$tdir >/dev/null || error "error in listing large dir"
1020 # LU-5 large readdir
1021 # DIRENT_SIZE = 32 bytes for sizeof(struct lu_dirent) +
1022 # 8 bytes for name(filename is mostly 5 in this test) +
1023 # 8 bytes for luda_type
1024 # take into account of overhead in lu_dirpage header and end mark in
1025 # each page, plus one in RPC_NUM calculation.
1027 RPC_SIZE=$(($(max_pages_per_rpc) * $(page_size)))
1028 RPC_NUM=$(((NRFILES * DIRENT_SIZE + RPC_SIZE - 1) / RPC_SIZE + 1))
1029 mds_readpage=$(lctl get_param mdc.*MDT0000*.stats | \
1030 awk '/^mds_readpage/ {print $2}')
1031 [ $mds_readpage -gt $RPC_NUM ] && \
1032 error "large readdir doesn't take effect"
1034 simple_cleanup_common
1036 run_test 24v "list directory with large files (handle hash collision, bug: 17560)"
1038 test_24w() { # bug21506
1040 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1041 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1042 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1043 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1044 [ "$SZ1" = "$SZ2" ] || \
1045 error "Error reading at the end of the file $tfile"
1047 run_test 24w "Reading a file larger than 4Gb"
1050 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1051 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1053 local remote_dir=$DIR/$tdir/remote_dir
1056 $LFS mkdir -i $MDTIDX $remote_dir ||
1057 error "create remote directory failed"
1059 mkdir -p $DIR/$tdir/src_dir
1060 touch $DIR/$tdir/src_file
1061 mkdir -p $remote_dir/tgt_dir
1062 touch $remote_dir/tgt_file
1064 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir &&
1065 error "rename dir cross MDT works!"
1067 mrename $DIR/$tdir/src_file $remote_dir/tgt_file &&
1068 error "rename file cross MDT works!"
1070 ln $DIR/$tdir/src_file $remote_dir/tgt_file1 &&
1071 error "ln file cross MDT should not work!"
1073 rm -rf $DIR/$tdir || error "Can not delete directories"
1075 run_test 24x "cross rename/link should be failed"
1078 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1079 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1081 local remote_dir=$DIR/$tdir/remote_dir
1084 $LFS mkdir -i $MDTIDX $remote_dir ||
1085 error "create remote directory failed"
1087 mkdir -p $remote_dir/src_dir
1088 touch $remote_dir/src_file
1089 mkdir -p $remote_dir/tgt_dir
1090 touch $remote_dir/tgt_file
1092 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1093 error "rename subdir in the same remote dir failed!"
1095 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1096 error "rename files in the same remote dir failed!"
1098 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1099 error "link files in the same remote dir failed!"
1101 rm -rf $DIR/$tdir || error "Can not delete directories"
1103 run_test 24y "rename/link on the same dir should succeed"
1106 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1107 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1109 local remote_src=$DIR/$tdir/remote_dir
1110 local remote_tgt=$DIR/$tdir/remote_tgt
1113 $LFS mkdir -i $MDTIDX $remote_src ||
1114 error "create remote directory failed"
1116 $LFS mkdir -i $MDTIDX $remote_tgt ||
1117 error "create remote directory failed"
1119 mrename $remote_src $remote_tgt &&
1120 error "rename remote dirs should not work!"
1122 rm -rf $DIR/$tdir || error "Can not delete directories"
1124 run_test 24z "rename one remote dir to another remote dir should fail"
1127 echo '== symlink sanity ============================================='
1131 touch $DIR/s25/foo || error
1133 run_test 25a "create file in symlinked directory ==============="
1136 [ ! -d $DIR/d25 ] && test_25a
1137 $CHECKSTAT -t file $DIR/s25/foo || error
1139 run_test 25b "lookup file in symlinked directory ==============="
1143 test_mkdir $DIR/d26/d26-2
1144 ln -s d26/d26-2 $DIR/s26
1145 touch $DIR/s26/foo || error
1147 run_test 26a "multiple component symlink ======================="
1150 test_mkdir -p $DIR/d26b/d26-2
1151 ln -s d26b/d26-2/foo $DIR/s26-2
1152 touch $DIR/s26-2 || error
1154 run_test 26b "multiple component symlink at end of lookup ======"
1157 test_mkdir $DIR/d26.2
1158 touch $DIR/d26.2/foo
1159 ln -s d26.2 $DIR/s26.2-1
1160 ln -s s26.2-1 $DIR/s26.2-2
1161 ln -s s26.2-2 $DIR/s26.2-3
1162 chmod 0666 $DIR/s26.2-3/foo
1164 run_test 26c "chain of symlinks ================================"
1166 # recursive symlinks (bug 439)
1168 ln -s d26-3/foo $DIR/d26-3
1170 run_test 26d "create multiple component recursive symlink ======"
1173 [ ! -h $DIR/d26-3 ] && test_26d
1176 run_test 26e "unlink multiple component recursive symlink ======"
1178 # recursive symlinks (bug 7022)
1180 test_mkdir -p $DIR/$tdir
1181 test_mkdir $DIR/$tdir/$tfile || error "mkdir $DIR/$tdir/$tfile failed"
1182 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1183 test_mkdir -p lndir bar1 || error "mkdir lndir/bar1 failed"
1184 test_mkdir $DIR/$tdir/$tfile/$tfile || error "mkdir $tfile failed"
1185 cd $tfile || error "cd $tfile failed"
1186 ln -s .. dotdot || error "ln dotdot failed"
1187 ln -s dotdot/lndir lndir || error "ln lndir failed"
1188 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1189 output=`ls $tfile/$tfile/lndir/bar1`
1190 [ "$output" = bar1 ] && error "unexpected output"
1191 rm -r $tfile || error "rm $tfile failed"
1192 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1194 run_test 26f "rm -r of a directory which has recursive symlink ="
1197 echo '== stripe sanity =============================================='
1198 test_mkdir -p $DIR/d27 || error "mkdir failed"
1200 $SETSTRIPE -c 1 $DIR/d27/f0 || error "setstripe failed"
1201 $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
1203 log "== test_27a: write to one stripe file ========================="
1204 cp /etc/hosts $DIR/d27/f0 || error
1206 run_test 27a "one stripe file =================================="
1209 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
1210 test_mkdir -p $DIR/d27
1211 $SETSTRIPE -c 2 $DIR/d27/f01 || error "setstripe failed"
1212 $GETSTRIPE -c $DIR/d27/f01
1213 [ $($GETSTRIPE -c $DIR/d27/f01) -eq 2 ] ||
1214 error "two-stripe file doesn't have two stripes"
1216 run_test 27b "create two stripe file"
1219 [ -f $DIR/d27/f01 ] || skip "test_27b not run" && return
1221 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
1223 run_test 27c "write to two stripe file"
1226 test_mkdir -p $DIR/d27
1227 $SETSTRIPE -c 0 -i -1 -S 0 $DIR/d27/fdef || error "setstripe failed"
1228 $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
1229 dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
1231 run_test 27d "create file with default settings ================"
1234 test_mkdir -p $DIR/d27
1235 $SETSTRIPE -c 2 $DIR/d27/f12 || error "setstripe failed"
1236 $SETSTRIPE -c 2 $DIR/d27/f12 && error "setstripe succeeded twice"
1237 $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
1239 run_test 27e "setstripe existing file (should return error) ======"
1242 test_mkdir -p $DIR/d27
1243 $SETSTRIPE -S 100 -i 0 -c 1 $DIR/d27/fbad && error "setstripe failed"
1244 dd if=/dev/zero of=$DIR/d27/f12 bs=4k count=4 || error "dd failed"
1245 $GETSTRIPE $DIR/d27/fbad || error "$GETSTRIPE failed"
1247 run_test 27f "setstripe with bad stripe size (should return error)"
1250 test_mkdir -p $DIR/d27
1251 $MCREATE $DIR/d27/fnone || error "mcreate failed"
1252 $GETSTRIPE $DIR/d27/fnone 2>&1 | grep "no stripe info" ||
1253 error "$DIR/d27/fnone has object"
1255 run_test 27g "$GETSTRIPE with no objects"
1258 touch $DIR/d27/fsome || error "touch failed"
1259 [ $($GETSTRIPE -c $DIR/d27/fsome) -gt 0 ] || error "missing objects"
1261 run_test 27i "$GETSTRIPE with some objects"
1264 test_mkdir -p $DIR/d27
1265 $SETSTRIPE -i $OSTCOUNT $DIR/d27/f27j && error "setstripe failed"||true
1267 run_test 27j "setstripe with bad stripe offset (should return error)"
1269 test_27k() { # bug 2844
1270 test_mkdir -p $DIR/d27
1272 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
1273 [ ! -d $DIR/d27 ] && test_mkdir -p $DIR d27
1274 $SETSTRIPE -S 67108864 $FILE || error "setstripe failed"
1275 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1276 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
1277 dd if=/dev/zero of=$FILE bs=4k count=1
1278 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1279 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
1281 run_test 27k "limit i_blksize for broken user apps ============="
1284 test_mkdir -p $DIR/d27
1285 mcreate $DIR/f27l || error "creating file"
1286 $RUNAS $SETSTRIPE -c 1 $DIR/f27l && \
1287 error "setstripe should have failed" || true
1289 run_test 27l "check setstripe permissions (should return error)"
1292 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" &&
1294 if [ $ORIGFREE -gt $MAXFREE ]; then
1295 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1298 trap simple_cleanup_common EXIT
1299 test_mkdir -p $DIR/$tdir
1300 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_1
1301 dd if=/dev/zero of=$DIR/$tdir/f27m_1 bs=1024 count=$MAXFREE &&
1302 error "dd should fill OST0"
1304 while $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_$i; do
1306 [ $i -gt 256 ] && break
1309 touch $DIR/$tdir/f27m_$i
1310 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1311 error "OST0 was full but new created file still use it"
1313 touch $DIR/$tdir/f27m_$i
1314 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1315 error "OST0 was full but new created file still use it"
1316 simple_cleanup_common
1318 run_test 27m "create file while OST0 was full =================="
1321 local DELAY=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage | head -n 1 | awk '{print $1 * 2}')
1325 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1326 # if the OST isn't full anymore.
1328 local OSTIDX=${1:-""}
1330 local list=$(comma_list $(osts_nodes))
1331 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1333 do_nodes $list lctl set_param fail_loc=0
1334 sync # initiate all OST_DESTROYs from MDS to OST
1338 exhaust_precreations() {
1341 local FAILIDX=${3:-$OSTIDX}
1343 test_mkdir -p $DIR/$tdir
1344 local MDSIDX=$(get_mds_dir "$DIR/$tdir")
1345 echo OSTIDX=$OSTIDX MDSIDX=$MDSIDX
1347 local OST=$(ostname_from_index $OSTIDX)
1348 local MDT_INDEX=$(lfs df | grep "\[MDT:$((MDSIDX - 1))\]" | awk '{print $1}' | \
1349 sed -e 's/_UUID$//;s/^.*-//')
1352 local mdtosc_proc1=$(get_mdtosc_proc_path mds${MDSIDX} $OST)
1353 local last_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1354 osc.$mdtosc_proc1.prealloc_last_id)
1355 local next_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1356 osc.$mdtosc_proc1.prealloc_next_id)
1358 local mdtosc_proc2=$(get_mdtosc_proc_path mds${MDSIDX})
1359 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1361 test_mkdir -p $DIR/$tdir/${OST}
1362 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1363 #define OBD_FAIL_OST_ENOSPC 0x215
1364 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=$FAILIDX
1365 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x215
1366 echo "Creating to objid $last_id on ost $OST..."
1367 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1368 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1369 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=$FAILLOC
1373 exhaust_all_precreations() {
1375 for (( i=0; i < OSTCOUNT; i++ )) ; do
1376 exhaust_precreations $i $1 -1
1381 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1382 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1383 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1384 remote_ost_nodsh && skip "remote OST with nodsh" && return
1387 rm -f $DIR/$tdir/$tfile
1388 exhaust_precreations 0 0x80000215
1389 $SETSTRIPE -c -1 $DIR/$tdir
1390 touch $DIR/$tdir/$tfile || error
1391 $GETSTRIPE $DIR/$tdir/$tfile
1394 run_test 27n "create file with some full OSTs =================="
1397 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1398 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1399 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1400 remote_ost_nodsh && skip "remote OST with nodsh" && return
1403 rm -f $DIR/$tdir/$tfile
1404 exhaust_all_precreations 0x215
1406 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1411 run_test 27o "create file with all full OSTs (should error) ===="
1414 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1415 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1416 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1417 remote_ost_nodsh && skip "remote OST with nodsh" && return
1420 rm -f $DIR/$tdir/$tfile
1421 test_mkdir -p $DIR/$tdir
1423 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1424 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1425 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1427 exhaust_precreations 0 0x80000215
1428 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1429 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1430 $GETSTRIPE $DIR/$tdir/$tfile
1434 run_test 27p "append to a truncated file with some full OSTs ==="
1437 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1438 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1439 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1440 remote_ost_nodsh && skip "remote OST with nodsh" && return
1443 rm -f $DIR/$tdir/$tfile
1445 test_mkdir -p $DIR/$tdir
1446 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1447 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||error "truncate $DIR/$tdir/$tfile failed"
1448 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1450 exhaust_all_precreations 0x215
1452 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1453 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1457 run_test 27q "append to truncated file with all OSTs full (should error) ==="
1460 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1461 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1462 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1463 remote_ost_nodsh && skip "remote OST with nodsh" && return
1466 rm -f $DIR/$tdir/$tfile
1467 exhaust_precreations 0 0x80000215
1469 $SETSTRIPE -i 0 -c 2 $DIR/$tdir/$tfile # && error
1473 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1475 test_27s() { # bug 10725
1476 test_mkdir -p $DIR/$tdir
1477 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1478 local stripe_count=0
1479 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1480 $SETSTRIPE -S $stripe_size -c $stripe_count $DIR/$tdir &&
1481 error "stripe width >= 2^32 succeeded" || true
1484 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1486 test_27t() { # bug 10864
1491 $WLFS getstripe $tfile
1494 run_test 27t "check that utils parse path correctly"
1496 test_27u() { # bug 4900
1497 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1498 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1500 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1501 do_facet $SINGLEMDS lctl set_param fail_loc=0x139
1502 test_mkdir -p $DIR/$tdir
1504 createmany -o $DIR/$tdir/t- 1000
1505 do_facet $SINGLEMDS lctl set_param fail_loc=0
1507 TLOG=$DIR/$tfile.getstripe
1508 $GETSTRIPE $DIR/$tdir > $TLOG
1509 OBJS=`awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj;}' $TLOG`
1510 unlinkmany $DIR/$tdir/t- 1000
1511 [ $OBJS -gt 0 ] && \
1512 error "$OBJS objects created on OST-0. See $TLOG" || pass
1514 run_test 27u "skip object creation on OSC w/o objects =========="
1516 test_27v() { # bug 4900
1517 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1518 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1519 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1520 remote_ost_nodsh && skip "remote OST with nodsh" && return
1522 exhaust_all_precreations 0x215
1525 test_mkdir -p $DIR/$tdir
1526 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1528 touch $DIR/$tdir/$tfile
1529 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1531 for (( i=1; i < OSTCOUNT; i++ )); do
1532 do_facet ost$i lctl set_param fail_loc=0x705
1534 local START=`date +%s`
1535 createmany -o $DIR/$tdir/$tfile 32
1537 local FINISH=`date +%s`
1538 local TIMEOUT=`lctl get_param -n timeout`
1539 local PROCESS=$((FINISH - START))
1540 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1541 error "$FINISH - $START >= $TIMEOUT / 2"
1542 sleep $((TIMEOUT / 2 - PROCESS))
1545 run_test 27v "skip object creation on slow OST ================="
1547 test_27w() { # bug 10997
1548 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1549 $SETSTRIPE -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1550 [ $($GETSTRIPE -S $DIR/$tdir/f0) -ne 65536 ] &&
1551 error "stripe size $size != 65536" || true
1552 [ $($GETSTRIPE -d $DIR/$tdir | grep -c "stripe_count") -ne 1 ] &&
1553 error "$GETSTRIPE -d $DIR/$tdir failed" || true
1555 run_test 27w "check $SETSTRIPE -S option"
1558 [ "$OSTCOUNT" -lt "2" ] &&
1559 skip_env "skipping multiple stripe count/offset test" && return
1561 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1562 for i in $(seq 1 $OSTCOUNT); do
1564 $SETSTRIPE -c $i -i $offset $DIR/$tdir/f$i ||
1565 error "setstripe -c $i -i $offset failed"
1566 count=$($GETSTRIPE -c $DIR/$tdir/f$i)
1567 index=$($GETSTRIPE -i $DIR/$tdir/f$i)
1568 [ $count -ne $i ] && error "stripe count $count != $i" || true
1569 [ $index -ne $offset ] &&
1570 error "stripe offset $index != $offset" || true
1573 run_test 27wa "check $SETSTRIPE -c -i options"
1576 remote_ost_nodsh && skip "remote OST with nodsh" && return
1577 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs" && return
1578 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1579 OFFSET=$(($OSTCOUNT - 1))
1581 local OST=$(ostname_from_index $OSTIDX)
1583 test_mkdir -p $DIR/$tdir
1584 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe per file
1585 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1587 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1588 for i in `seq 0 $OFFSET`; do
1589 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}' | grep -w "$OSTIDX"` ] &&
1590 error "OST0 was degraded but new created file still use it"
1592 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1594 run_test 27x "create files while OST0 is degraded"
1597 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1598 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1599 remote_ost_nodsh && skip "remote OST with nodsh" && return
1600 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1602 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1603 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1604 osc.$mdtosc.prealloc_last_id)
1605 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1606 osc.$mdtosc.prealloc_next_id)
1607 local fcount=$((last_id - next_id))
1608 [ $fcount -eq 0 ] && skip "not enough space on OST0" && return
1609 [ $fcount -gt $OSTCOUNT ] && fcount=$OSTCOUNT
1611 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
1612 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
1613 local OST_DEACTIVE_IDX=-1
1618 for OSC in $MDS_OSCS; do
1619 OST=$(osc_to_ost $OSC)
1620 OSTIDX=$(index_from_ostuuid $OST)
1621 if [ $OST_DEACTIVE_IDX == -1 ]; then
1622 OST_DEACTIVE_IDX=$OSTIDX
1624 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
1625 echo $OSC "is Deactivated:"
1626 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1630 OSTIDX=$(index_from_ostuuid $OST)
1632 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1634 for OSC in $MDS_OSCS; do
1635 OST=$(osc_to_ost $OSC)
1636 OSTIDX=$(index_from_ostuuid $OST)
1637 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1638 echo $OST "is degraded:"
1639 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1640 obdfilter.$OST.degraded=1
1645 createmany -o $DIR/$tdir/$tfile $fcount
1647 for OSC in $MDS_OSCS; do
1648 OST=$(osc_to_ost $OSC)
1649 OSTIDX=$(index_from_ostuuid $OST)
1650 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1651 echo $OST "is recovered from degraded:"
1652 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1653 obdfilter.$OST.degraded=0
1655 do_facet $SINGLEMDS lctl --device %$OSC activate
1659 # all osp devices get activated, hence -1 stripe count restored
1662 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
1663 # devices get activated.
1665 $SETSTRIPE -c -1 $DIR/$tfile
1666 stripecnt=$($GETSTRIPE -c $DIR/$tfile)
1668 [ $stripecnt -ne $OSTCOUNT ] &&
1669 error "Of $OSTCOUNT OSTs, only $stripecnt is available"
1672 run_test 27y "create files while OST0 is degraded and the rest inactive"
1678 lmm_count=$($GETSTRIPE -c $1)
1679 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1680 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1682 local old_ifs="$IFS"
1684 fid=($($LFS path2fid $1))
1687 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1688 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1690 # compare lmm_seq and lu_fid->f_seq
1691 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1692 # compare lmm_object_id and lu_fid->oid
1693 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1695 # check the trusted.fid attribute of the OST objects of the file
1696 local have_obdidx=false
1698 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1699 # skip lines up to and including "obdidx"
1700 [ -z "$obdidx" ] && break
1701 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1702 $have_obdidx || continue
1704 local ost=$((obdidx + 1))
1705 local dev=$(ostdevname $ost)
1707 if [ $(facet_fstype ost$ost) != ldiskfs ]; then
1708 echo "Currently only works with ldiskfs-based OSTs"
1712 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1714 #don't unmount/remount the OSTs if we don't need to do that
1715 #local dir=$(facet_mntpt ost$ost)
1717 #do_facet ost$dev mount -t $FSTYPE $dev $dir $OST_MOUNT_OPTS ||
1718 # { error "mounting $dev as $FSTYPE failed"; return 3; }
1719 #local obj_file=$(do_facet ost$ost find $dir/O/$seq -name $oid)
1720 #local ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID $obj_file)
1721 seq=$(echo $seq | sed -e "s/^0x//g")
1722 if [ $seq == 0 ]; then
1723 oid_hex=$(echo $oid)
1725 oid_hex=$(echo $hex | sed -e "s/^0x//g")
1727 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
1728 local ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
1729 $dev 2>/dev/null" | grep "parent=")
1731 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
1733 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
1735 #do_facet ost$ost umount -d $dir
1736 #start ost$ost $dev $OST_MOUNT_OPTS
1738 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
1739 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
1740 local ff_parent=$(echo $ff|sed -e 's/.*parent=.//')
1741 local ff_pseq=$(echo $ff_parent | cut -d: -f1)
1742 local ff_poid=$(echo $ff_parent | cut -d: -f2)
1743 local ff_pstripe=$(echo $ff_parent | sed -e 's/.*stripe=//')
1745 # compare lmm_seq and filter_fid->ff_parent.f_seq
1746 [ $ff_pseq = $lmm_seq ] ||
1747 error "FF parent SEQ $ff_pseq != $lmm_seq"
1748 # compare lmm_object_id and filter_fid->ff_parent.f_oid
1749 [ $ff_poid = $lmm_oid ] ||
1750 error "FF parent OID $ff_poid != $lmm_oid"
1751 [ $ff_pstripe = $stripe_nr ] ||
1752 error "FF stripe $ff_pstripe != $stripe_nr"
1754 stripe_nr=$((stripe_nr + 1))
1759 remote_ost_nodsh && skip "remote OST with nodsh" && return
1760 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1761 test_mkdir -p $DIR/$tdir
1763 $SETSTRIPE -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
1764 { error "setstripe -c -1 failed"; return 1; }
1765 # We need to send a write to every object to get parent FID info set.
1766 # This _should_ also work for setattr, but does not currently.
1767 # touch $DIR/$tdir/$tfile-1 ||
1768 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
1769 { error "dd $tfile-1 failed"; return 2; }
1770 $SETSTRIPE -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
1771 { error "setstripe -c -1 failed"; return 3; }
1772 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
1773 { error "dd $tfile-2 failed"; return 4; }
1775 # make sure write RPCs have been sent to OSTs
1778 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
1779 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
1781 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
1783 test_27A() { # b=19102
1784 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1785 local restore_size=$($GETSTRIPE -S $MOUNT)
1786 local restore_count=$($GETSTRIPE -c $MOUNT)
1787 local restore_offset=$($GETSTRIPE -i $MOUNT)
1788 $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
1789 local default_size=$($GETSTRIPE -S $MOUNT)
1790 local default_count=$($GETSTRIPE -c $MOUNT)
1791 local default_offset=$($GETSTRIPE -i $MOUNT)
1792 local dsize=$((1024 * 1024))
1793 [ $default_size -eq $dsize ] ||
1794 error "stripe size $default_size != $dsize"
1795 [ $default_count -eq 1 ] || error "stripe count $default_count != 1"
1796 [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
1797 $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
1799 run_test 27A "check filesystem-wide default LOV EA values"
1801 test_27B() { # LU-2523
1802 test_mkdir -p $DIR/$tdir
1803 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
1805 # open f1 with O_LOV_DELAY_CREATE
1807 # call setstripe ioctl on open file descriptor for f1
1809 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
1813 # open f1 with O_LOV_DELAY_CREATE
1815 # call setstripe ioctl on open file descriptor for f1
1817 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
1819 # Allow multiop to fail in imitation of NFS's busted semantics.
1822 run_test 27B "call setstripe on open unlinked file/rename victim"
1824 test_27C() { #LU-2871
1825 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
1832 test_mkdir -p $DIR/$tdir
1834 for i in $(seq 0 $((OSTCOUNT - 1))); do
1835 # set stripe across all OSTs starting from OST$i
1836 $SETSTRIPE -i $i -c -1 $tfile$i
1837 # get striping information
1838 ost_idx=($($GETSTRIPE $tfile$i |
1839 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
1842 for j in $(seq 0 $((OSTCOUNT - 1))); do
1843 index=$(((i + j) % OSTCOUNT))
1844 [ ${ost_idx[$j]} -eq $index ] || error
1848 run_test 27C "check full striping across all OSTs"
1850 # createtest also checks that device nodes are created and
1851 # then visible correctly (#2091)
1852 test_28() { # bug 2091
1854 $CREATETEST $DIR/d28/ct || error
1856 run_test 28 "create/mknod/mkdir with bad file types ============"
1859 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1860 cancel_lru_locks mdc
1866 declare -i LOCKCOUNTORIG=0
1867 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1868 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
1870 [ $LOCKCOUNTORIG -eq 0 ] && echo "No mdc lock count" && return 1
1872 declare -i LOCKUNUSEDCOUNTORIG=0
1873 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1874 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
1881 declare -i LOCKCOUNTCURRENT=0
1882 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1883 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
1886 declare -i LOCKUNUSEDCOUNTCURRENT=0
1887 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1888 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
1891 if [ "$LOCKCOUNTCURRENT" -gt "$LOCKCOUNTORIG" ]; then
1892 lctl set_param -n ldlm.dump_namespaces ""
1893 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
1894 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1895 log "dumped log to $TMP/test_29.dk (bug 5793)"
1898 if [ "$LOCKUNUSEDCOUNTCURRENT" -gt "$LOCKUNUSEDCOUNTORIG" ]; then
1899 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
1900 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1901 log "dumped log to $TMP/test_29.dk (bug 5793)"
1905 run_test 29 "IT_GETATTR regression ============================"
1907 test_30a() { # was test_30
1908 cp `which ls` $DIR || cp /bin/ls $DIR
1912 run_test 30a "execute binary from Lustre (execve) =============="
1915 cp `which ls` $DIR || cp /bin/ls $DIR
1917 $RUNAS $DIR/ls / || error
1920 run_test 30b "execute binary from Lustre as non-root ==========="
1922 test_30c() { # b=22376
1923 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1924 cp `which ls` $DIR || cp /bin/ls $DIR
1926 cancel_lru_locks mdc
1927 cancel_lru_locks osc
1928 $RUNAS $DIR/ls / || error
1931 run_test 30c "execute binary from Lustre without read perms ===="
1934 $OPENUNLINK $DIR/f31 $DIR/f31 || error
1935 $CHECKSTAT -a $DIR/f31 || error
1937 run_test 31a "open-unlink file =================================="
1940 touch $DIR/f31 || error
1941 ln $DIR/f31 $DIR/f31b || error
1942 $MULTIOP $DIR/f31b Ouc || error
1943 $CHECKSTAT -t file $DIR/f31 || error
1945 run_test 31b "unlink file with multiple links while open ======="
1948 touch $DIR/f31 || error
1949 ln $DIR/f31 $DIR/f31c || error
1950 multiop_bg_pause $DIR/f31 O_uc || return 1
1952 $MULTIOP $DIR/f31c Ouc
1953 kill -USR1 $MULTIPID
1956 run_test 31c "open-unlink file with multiple links ============="
1959 opendirunlink $DIR/d31d $DIR/d31d || error
1960 $CHECKSTAT -a $DIR/d31d || error
1962 run_test 31d "remove of open directory ========================="
1964 test_31e() { # bug 2904
1965 check_kernel_version 34 || return 0
1966 openfilleddirunlink $DIR/d31e || error
1968 run_test 31e "remove of open non-empty directory ==============="
1970 test_31f() { # bug 4554
1971 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1973 test_mkdir $DIR/d31f
1974 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
1975 cp /etc/hosts $DIR/d31f
1977 $GETSTRIPE $DIR/d31f/hosts
1978 multiop_bg_pause $DIR/d31f D_c || return 1
1981 rm -rv $DIR/d31f || error "first of $DIR/d31f"
1982 test_mkdir $DIR/d31f
1983 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
1984 cp /etc/hosts $DIR/d31f
1986 $GETSTRIPE $DIR/d31f/hosts
1987 multiop_bg_pause $DIR/d31f D_c || return 1
1990 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
1991 wait $MULTIPID || error "first opendir $MULTIPID failed"
1995 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
1996 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
1999 run_test 31f "remove of open directory with open-unlink file ==="
2002 echo "-- cross directory link --"
2003 test_mkdir $DIR/d31ga
2004 test_mkdir $DIR/d31gb
2006 ln $DIR/d31ga/f $DIR/d31gb/g
2007 $CHECKSTAT -t file $DIR/d31ga/f || error "source"
2008 [ `stat -c%h $DIR/d31ga/f` == '2' ] || error "source nlink"
2009 $CHECKSTAT -t file $DIR/d31gb/g || error "target"
2010 [ `stat -c%h $DIR/d31gb/g` == '2' ] || error "target nlink"
2012 run_test 31g "cross directory link==============="
2015 echo "-- cross directory link --"
2016 test_mkdir $DIR/d31h
2017 test_mkdir $DIR/d31h/dir
2019 ln $DIR/d31h/f $DIR/d31h/dir/g
2020 $CHECKSTAT -t file $DIR/d31h/f || error "source"
2021 [ `stat -c%h $DIR/d31h/f` == '2' ] || error "source nlink"
2022 $CHECKSTAT -t file $DIR/d31h/dir/g || error "target"
2023 [ `stat -c%h $DIR/d31h/dir/g` == '2' ] || error "target nlink"
2025 run_test 31h "cross directory link under child==============="
2028 echo "-- cross directory link --"
2029 test_mkdir $DIR/d31i
2030 test_mkdir $DIR/d31i/dir
2031 touch $DIR/d31i/dir/f
2032 ln $DIR/d31i/dir/f $DIR/d31i/g
2033 $CHECKSTAT -t file $DIR/d31i/dir/f || error "source"
2034 [ `stat -c%h $DIR/d31i/dir/f` == '2' ] || error "source nlink"
2035 $CHECKSTAT -t file $DIR/d31i/g || error "target"
2036 [ `stat -c%h $DIR/d31i/g` == '2' ] || error "target nlink"
2038 run_test 31i "cross directory link under parent==============="
2042 test_mkdir $DIR/d31j
2043 test_mkdir $DIR/d31j/dir1
2044 ln $DIR/d31j/dir1 $DIR/d31j/dir2 && error "ln for dir"
2045 link $DIR/d31j/dir1 $DIR/d31j/dir3 && error "link for dir"
2046 mlink $DIR/d31j/dir1 $DIR/d31j/dir4 && error "mlink for dir"
2047 mlink $DIR/d31j/dir1 $DIR/d31j/dir1 && error "mlink to the same dir"
2050 run_test 31j "link for directory==============="
2054 test_mkdir $DIR/d31k
2056 touch $DIR/d31k/exist
2057 mlink $DIR/d31k/s $DIR/d31k/t || error "mlink"
2058 mlink $DIR/d31k/s $DIR/d31k/exist && error "mlink to exist file"
2059 mlink $DIR/d31k/s $DIR/d31k/s && error "mlink to the same file"
2060 mlink $DIR/d31k/s $DIR/d31k && error "mlink to parent dir"
2061 mlink $DIR/d31k $DIR/d31k/s && error "mlink parent dir to target"
2062 mlink $DIR/d31k/not-exist $DIR/d31k/foo && error "mlink non-existing to new"
2063 mlink $DIR/d31k/not-exist $DIR/d31k/s && error "mlink non-existing to exist"
2066 run_test 31k "link to file: the same, non-existing, dir==============="
2069 test_mkdir $DIR/d31m
2071 test_mkdir $DIR/d31m2
2072 touch $DIR/d31m2/exist
2073 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
2074 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
2075 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
2076 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
2077 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
2078 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
2081 run_test 31m "link to file: the same, non-existing, dir==============="
2084 [ -e /proc/self/fd/173 ] && echo "skipping, fd 173 is in use" && return
2085 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
2086 nlink=$(stat --format=%h $DIR/$tfile)
2087 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2088 exec 173<$DIR/$tfile
2089 trap "exec 173<&-" EXIT
2090 nlink=$(stat --dereference --format=%h /proc/self/fd/173)
2091 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2092 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
2093 nlink=$(stat --dereference --format=%h /proc/self/fd/173)
2094 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
2097 run_test 31n "check link count of unlinked file"
2099 cleanup_test32_mount() {
2101 $UMOUNT $DIR/$tdir/ext2-mountpoint
2105 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2106 echo "== more mountpoints and symlinks ================="
2107 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2108 trap cleanup_test32_mount EXIT
2109 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2110 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2111 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. || error
2112 cleanup_test32_mount
2114 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
2117 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2118 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2119 trap cleanup_test32_mount EXIT
2120 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2121 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2122 ls -al $DIR/$tdir/ext2-mountpoint/.. || error
2123 cleanup_test32_mount
2125 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
2128 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2129 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2130 trap cleanup_test32_mount EXIT
2131 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2132 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2133 test_mkdir -p $DIR/$tdir/d2/test_dir
2134 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2135 cleanup_test32_mount
2137 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2140 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2141 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2142 trap cleanup_test32_mount EXIT
2143 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2144 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2145 test_mkdir -p $DIR/$tdir/d2/test_dir
2146 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2147 cleanup_test32_mount
2149 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
2152 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
2153 test_mkdir -p $DIR/d32e/tmp
2154 TMP_DIR=$DIR/d32e/tmp
2155 ln -s $DIR/d32e $TMP_DIR/symlink11
2156 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2157 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
2158 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
2160 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
2163 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
2164 test_mkdir -p $DIR/d32f/tmp
2165 TMP_DIR=$DIR/d32f/tmp
2166 ln -s $DIR/d32f $TMP_DIR/symlink11
2167 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2168 ls $DIR/d32f/tmp/symlink11 || error
2169 ls $DIR/d32f/symlink01 || error
2171 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
2174 TMP_DIR=$DIR/$tdir/tmp
2175 test_mkdir -p $DIR/$tdir/tmp
2176 test_mkdir $DIR/${tdir}2
2177 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2178 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2179 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
2180 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
2181 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
2182 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
2184 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2187 rm -fr $DIR/$tdir $DIR/${tdir}2
2188 TMP_DIR=$DIR/$tdir/tmp
2189 test_mkdir -p $DIR/$tdir/tmp
2190 test_mkdir $DIR/${tdir}2
2191 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2192 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2193 ls $TMP_DIR/symlink12 || error
2194 ls $DIR/$tdir/symlink02 || error
2196 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2199 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2200 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2201 trap cleanup_test32_mount EXIT
2202 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2203 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2204 touch $DIR/$tdir/test_file
2205 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file || error
2206 cleanup_test32_mount
2208 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
2211 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2212 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2213 trap cleanup_test32_mount EXIT
2214 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2215 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2216 touch $DIR/$tdir/test_file
2217 cat $DIR/$tdir/ext2-mountpoint/../test_file || error
2218 cleanup_test32_mount
2220 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
2223 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2225 trap cleanup_test32_mount EXIT
2226 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2227 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2228 test_mkdir -p $DIR/$tdir/d2
2229 touch $DIR/$tdir/d2/test_file || error
2230 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2231 cleanup_test32_mount
2233 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
2236 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2238 trap cleanup_test32_mount EXIT
2239 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2240 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2241 test_mkdir -p $DIR/$tdir/d2
2242 touch $DIR/$tdir/d2/test_file
2243 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2244 cleanup_test32_mount
2246 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
2250 test_mkdir -p $DIR/d32m/tmp
2251 TMP_DIR=$DIR/d32m/tmp
2252 ln -s $DIR $TMP_DIR/symlink11
2253 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2254 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
2255 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
2257 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
2261 test_mkdir -p $DIR/d32n/tmp
2262 TMP_DIR=$DIR/d32n/tmp
2263 ln -s $DIR $TMP_DIR/symlink11
2264 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2265 ls -l $DIR/d32n/tmp/symlink11 || error
2266 ls -l $DIR/d32n/symlink01 || error
2268 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
2271 rm -fr $DIR/d32o $DIR/$tfile
2273 test_mkdir -p $DIR/d32o/tmp
2274 TMP_DIR=$DIR/d32o/tmp
2275 ln -s $DIR/$tfile $TMP_DIR/symlink12
2276 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2277 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
2278 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
2279 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
2280 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
2282 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
2292 test_mkdir -p $DIR/d32p/tmp
2294 TMP_DIR=$DIR/d32p/tmp
2296 ln -s $DIR/$tfile $TMP_DIR/symlink12
2298 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2300 cat $DIR/d32p/tmp/symlink12 || error
2302 cat $DIR/d32p/symlink02 || error
2305 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
2307 cleanup_testdir_mount() {
2313 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2314 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2315 trap cleanup_testdir_mount EXIT
2316 test_mkdir -p $DIR/$tdir
2317 touch $DIR/$tdir/under_the_mount
2318 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2319 ls $DIR/$tdir | grep "\<under_the_mount\>" && error
2320 cleanup_testdir_mount
2322 run_test 32q "stat follows mountpoints in Lustre (should return error)"
2325 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2326 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2327 trap cleanup_testdir_mount EXIT
2328 test_mkdir -p $DIR/$tdir
2329 touch $DIR/$tdir/under_the_mount
2330 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2331 ls $DIR/$tdir | grep -q under_the_mount && error || true
2332 cleanup_testdir_mount
2334 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
2339 chmod 444 $DIR/$tfile
2340 chown $RUNAS_ID $DIR/$tfile
2342 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2345 run_test 33aa "write file with mode 444 (should return error) ===="
2349 test_mkdir -p $DIR/d33
2350 chown $RUNAS_ID $DIR/d33
2351 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
2352 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
2353 error "open RDWR" || true
2355 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
2359 test_mkdir -p $DIR/d33
2360 chown $RUNAS_ID $DIR/d33
2361 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33 && error "create" || true
2363 run_test 33b "test open file with malformed flags (No panic and return error)"
2366 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2372 remote_ost_nodsh && skip "remote OST with nodsh" && return
2375 test_mkdir -p $DIR/d33
2376 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2379 for ostnum in $(seq $OSTCOUNT); do
2380 # test-framework's OST numbering is one-based, while Lustre's
2382 ostname=$(printf "$FSNAME-OST%.4d" $((ostnum - 1)))
2383 # Parsing llobdstat's output sucks; we could grep the /proc
2384 # path, but that's likely to not be as portable as using the
2385 # llobdstat utility. So we parse lctl output instead.
2386 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2387 obdfilter/$ostname/stats |
2388 awk '/^write_bytes/ {print $7}' )
2389 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2390 if (( ${write_bytes:-0} > 0 ))
2397 $all_zeros || return 0
2400 echo foo > $DIR/d33/bar
2404 # Total up write_bytes after writing. We'd better find non-zeros.
2405 for ostnum in $(seq $OSTCOUNT); do
2406 ostname=$(printf "$FSNAME-OST%.4d" $((ostnum - 1)))
2407 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2408 obdfilter/$ostname/stats |
2409 awk '/^write_bytes/ {print $7}' )
2410 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2411 if (( ${write_bytes:-0} > 0 ))
2420 for ostnum in $(seq $OSTCOUNT); do
2421 ostname=$(printf "$FSNAME-OST%.4d" $((ostnum - 1)))
2422 echo "Check that write_bytes is present in obdfilter/*/stats:"
2423 do_facet ost$ostnum lctl get_param -n \
2424 obdfilter/$ostname/stats
2426 error "OST not keeping write_bytes stats (b22312)"
2429 run_test 33c "test llobdstat and write_bytes"
2432 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2433 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2435 local remote_dir=$DIR/$tdir/remote_dir
2438 $LFS mkdir -i $MDTIDX $remote_dir ||
2439 error "create remote directory failed"
2441 touch $remote_dir/$tfile
2442 chmod 444 $remote_dir/$tfile
2443 chown $RUNAS_ID $remote_dir/$tfile
2445 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2447 chown $RUNAS_ID $remote_dir
2448 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
2449 error "create" || true
2450 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
2451 error "open RDWR" || true
2452 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 &&
2453 error "create" || true
2455 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
2457 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
2460 $MCREATE $DIR/f34 || error
2461 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2462 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
2463 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2464 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2466 run_test 34a "truncate file that has not been opened ==========="
2469 [ ! -f $DIR/f34 ] && test_34a
2470 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2471 $OPENFILE -f O_RDONLY $DIR/f34
2472 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2473 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2475 run_test 34b "O_RDONLY opening file doesn't create objects ====="
2478 [ ! -f $DIR/f34 ] && test_34a
2479 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2480 $OPENFILE -f O_RDWR $DIR/f34
2481 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2482 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2484 run_test 34c "O_RDWR opening file-with-size works =============="
2487 [ ! -f $DIR/f34 ] && test_34a
2488 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2489 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2492 run_test 34d "write to sparse file ============================="
2496 $MCREATE $DIR/f34e || error
2497 $TRUNCATE $DIR/f34e 1000 || error
2498 $CHECKSTAT -s 1000 $DIR/f34e || error
2499 $OPENFILE -f O_RDWR $DIR/f34e
2500 $CHECKSTAT -s 1000 $DIR/f34e || error
2502 run_test 34e "create objects, some with size and some without =="
2504 test_34f() { # bug 6242, 6243
2505 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2508 $MCREATE $DIR/f34f || error
2509 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
2510 dd if=$DIR/f34f of=$TMP/f34f
2511 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
2512 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
2513 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
2514 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
2515 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
2517 run_test 34f "read from a file with no objects until EOF ======="
2520 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2521 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
2522 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
2523 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
2524 cancel_lru_locks osc
2525 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
2526 error "wrong size after lock cancel"
2528 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
2529 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2530 error "expanding truncate failed"
2531 cancel_lru_locks osc
2532 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2533 error "wrong expanded size after lock cancel"
2535 run_test 34g "truncate long file ==============================="
2538 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2542 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
2543 sync # Flush the cache so that multiop below does not block on cache
2544 # flush when getting the group lock
2545 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
2549 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
2550 error "Multiop blocked on ftruncate, pid=$MULTIPID"
2554 local nsz=`stat -c %s $DIR/$tfile`
2555 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
2557 run_test 34h "ftruncate file under grouplock should not block"
2560 cp /bin/sh $DIR/f35a
2562 chown $RUNAS_ID $DIR/f35a
2563 $RUNAS $DIR/f35a && error || true
2566 run_test 35a "exec file with mode 444 (should return and not leak) ====="
2570 utime $DIR/f36 || error
2572 run_test 36a "MDS utime check (mknod, utime) ==================="
2576 utime $DIR/f36 || error
2578 run_test 36b "OST utime check (open, utime) ===================="
2583 chown $RUNAS_ID $DIR/d36
2584 $RUNAS utime $DIR/d36/f36 || error
2586 run_test 36c "non-root MDS utime check (mknod, utime) =========="
2589 [ ! -d $DIR/d36 ] && test_36c
2590 echo "" > $DIR/d36/f36
2591 $RUNAS utime $DIR/d36/f36 || error
2593 run_test 36d "non-root OST utime check (open, utime) ==========="
2596 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
2597 test_mkdir -p $DIR/$tdir
2598 touch $DIR/$tdir/$tfile
2599 $RUNAS utime $DIR/$tdir/$tfile && \
2600 error "utime worked, expected failure" || true
2602 run_test 36e "utime on non-owned file (should return error) ===="
2606 local LANG_SAVE=$LANG
2607 local LC_LANG_SAVE=$LC_LANG
2608 export LANG=C LC_LANG=C # for date language
2610 DATESTR="Dec 20 2000"
2611 test_mkdir -p $DIR/$tdir
2612 lctl set_param fail_loc=$fl
2614 cp /etc/hosts $DIR/$tdir/$tfile
2615 sync & # write RPC generated with "current" inode timestamp, but delayed
2617 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
2618 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
2619 cancel_lru_locks osc
2620 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
2622 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
2623 echo "BEFORE: $LS_BEFORE" && \
2624 echo "AFTER : $LS_AFTER" && \
2625 echo "WANT : $DATESTR" && \
2626 error "$DIR/$tdir/$tfile timestamps changed" || true
2628 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
2632 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2633 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2634 subr_36fh "0x80000214"
2636 run_test 36f "utime on file racing with OST BRW write =========="
2639 remote_ost_nodsh && skip "remote OST with nodsh" && return
2640 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2645 test_mkdir -p $DIR/$tdir
2646 fmd_max_age=$(do_facet ost1 \
2647 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
2650 fmd_before=$(do_facet ost1 \
2651 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2652 touch $DIR/$tdir/$tfile
2653 sleep $((fmd_max_age + 12))
2654 fmd_after=$(do_facet ost1 \
2655 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2657 echo "fmd_before: $fmd_before"
2658 echo "fmd_after: $fmd_after"
2659 [ "$fmd_after" -gt "$fmd_before" ] && \
2660 echo "AFTER: $fmd_after > BEFORE: $fmd_before" && \
2661 error "fmd didn't expire after ping" || true
2663 run_test 36g "filter mod data cache expiry ====================="
2666 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2667 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
2668 subr_36fh "0x80000227"
2670 run_test 36h "utime on file racing with OST BRW write =========="
2672 # test_37 - duplicate with tests 32q 32r
2675 local file=$DIR/$tfile
2677 openfile -f O_DIRECTORY $file
2680 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
2681 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
2683 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
2687 touch $DIR/${tfile}2
2688 # ls -l $DIR/$tfile $DIR/${tfile}2
2689 # ls -lu $DIR/$tfile $DIR/${tfile}2
2690 # ls -lc $DIR/$tfile $DIR/${tfile}2
2692 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
2693 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
2695 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
2697 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
2699 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
2700 error "O_TRUNC didn't change timestamps"
2703 run_test 39 "mtime changed on create ==========================="
2706 test_mkdir -p $DIR/$tdir
2707 cp -p /etc/passwd $DIR/$tdir/fopen
2708 cp -p /etc/passwd $DIR/$tdir/flink
2709 cp -p /etc/passwd $DIR/$tdir/funlink
2710 cp -p /etc/passwd $DIR/$tdir/frename
2711 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
2714 echo "aaaaaa" >> $DIR/$tdir/fopen
2715 echo "aaaaaa" >> $DIR/$tdir/flink
2716 echo "aaaaaa" >> $DIR/$tdir/funlink
2717 echo "aaaaaa" >> $DIR/$tdir/frename
2719 local open_new=`stat -c %Y $DIR/$tdir/fopen`
2720 local link_new=`stat -c %Y $DIR/$tdir/flink`
2721 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
2722 local rename_new=`stat -c %Y $DIR/$tdir/frename`
2724 cat $DIR/$tdir/fopen > /dev/null
2725 ln $DIR/$tdir/flink $DIR/$tdir/flink2
2726 rm -f $DIR/$tdir/funlink2
2727 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
2729 for (( i=0; i < 2; i++ )) ; do
2730 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
2731 local link_new2=`stat -c %Y $DIR/$tdir/flink`
2732 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
2733 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
2735 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
2736 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
2737 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
2738 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
2740 cancel_lru_locks osc
2741 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2744 run_test 39b "mtime change on open, link, unlink, rename ======"
2746 # this should be set to past
2747 TEST_39_MTIME=`date -d "1 year ago" +%s`
2753 local mtime0=`stat -c %Y $DIR1/$tfile`
2755 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2756 local mtime1=`stat -c %Y $DIR1/$tfile`
2757 [ "$mtime1" = $TEST_39_MTIME ] || \
2758 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
2761 echo hello >> $DIR1/$tfile
2763 local mtime2=`stat -c %Y $DIR1/$tfile`
2764 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
2765 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
2767 mv $DIR1/$tfile $DIR1/$tfile-1
2769 for (( i=0; i < 2; i++ )) ; do
2770 local mtime3=`stat -c %Y $DIR1/$tfile-1`
2771 [ "$mtime2" = "$mtime3" ] || \
2772 error "mtime ($mtime2) changed (to $mtime3) on rename"
2774 cancel_lru_locks osc
2775 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2778 run_test 39c "mtime change on rename ==========================="
2782 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2785 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2787 for (( i=0; i < 2; i++ )) ; do
2788 local mtime=`stat -c %Y $DIR1/$tfile`
2789 [ $mtime = $TEST_39_MTIME ] || \
2790 error "mtime($mtime) is not set to $TEST_39_MTIME"
2792 cancel_lru_locks osc
2793 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2796 run_test 39d "create, utime, stat =============================="
2800 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2802 local mtime1=`stat -c %Y $DIR1/$tfile`
2804 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2806 for (( i=0; i < 2; i++ )) ; do
2807 local mtime2=`stat -c %Y $DIR1/$tfile`
2808 [ $mtime2 = $TEST_39_MTIME ] || \
2809 error "mtime($mtime2) is not set to $TEST_39_MTIME"
2811 cancel_lru_locks osc
2812 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2815 run_test 39e "create, stat, utime, stat ========================"
2819 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2821 mtime1=`stat -c %Y $DIR1/$tfile`
2824 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2826 for (( i=0; i < 2; i++ )) ; do
2827 local mtime2=`stat -c %Y $DIR1/$tfile`
2828 [ $mtime2 = $TEST_39_MTIME ] || \
2829 error "mtime($mtime2) is not set to $TEST_39_MTIME"
2831 cancel_lru_locks osc
2832 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2835 run_test 39f "create, stat, sleep, utime, stat ================="
2839 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2840 echo hello >> $DIR1/$tfile
2841 local mtime1=`stat -c %Y $DIR1/$tfile`
2844 chmod o+r $DIR1/$tfile
2846 for (( i=0; i < 2; i++ )) ; do
2847 local mtime2=`stat -c %Y $DIR1/$tfile`
2848 [ "$mtime1" = "$mtime2" ] || \
2849 error "lost mtime: $mtime2, should be $mtime1"
2851 cancel_lru_locks osc
2852 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2855 run_test 39g "write, chmod, stat ==============================="
2859 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2864 echo hello >> $DIR1/$tfile
2865 local mtime1=`stat -c %Y $DIR1/$tfile`
2867 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2869 if [ "$d1" != "$d2" ]; then
2870 echo "write and touch not within one second"
2872 for (( i=0; i < 2; i++ )) ; do
2873 local mtime2=`stat -c %Y $DIR1/$tfile`
2874 [ "$mtime2" = $TEST_39_MTIME ] || \
2875 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
2877 cancel_lru_locks osc
2878 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2882 run_test 39h "write, utime within one second, stat ============="
2885 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2889 echo hello >> $DIR1/$tfile
2890 local mtime1=`stat -c %Y $DIR1/$tfile`
2892 mv $DIR1/$tfile $DIR1/$tfile-1
2894 for (( i=0; i < 2; i++ )) ; do
2895 local mtime2=`stat -c %Y $DIR1/$tfile-1`
2897 [ "$mtime1" = "$mtime2" ] || \
2898 error "lost mtime: $mtime2, should be $mtime1"
2900 cancel_lru_locks osc
2901 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2904 run_test 39i "write, rename, stat =============================="
2907 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2908 start_full_debug_logging
2912 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
2913 lctl set_param fail_loc=0x80000412
2914 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
2915 error "multiop failed"
2917 local mtime1=`stat -c %Y $DIR1/$tfile`
2919 mv $DIR1/$tfile $DIR1/$tfile-1
2921 kill -USR1 $multipid
2922 wait $multipid || error "multiop close failed"
2924 for (( i=0; i < 2; i++ )) ; do
2925 local mtime2=`stat -c %Y $DIR1/$tfile-1`
2926 [ "$mtime1" = "$mtime2" ] ||
2927 error "mtime is lost on close: $mtime2, " \
2930 cancel_lru_locks osc
2931 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2933 lctl set_param fail_loc=0
2934 stop_full_debug_logging
2936 run_test 39j "write, rename, close, stat ======================="
2939 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2943 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
2945 local mtime1=`stat -c %Y $DIR1/$tfile`
2947 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2949 kill -USR1 $multipid
2950 wait $multipid || error "multiop close failed"
2952 for (( i=0; i < 2; i++ )) ; do
2953 local mtime2=`stat -c %Y $DIR1/$tfile`
2955 [ "$mtime2" = $TEST_39_MTIME ] || \
2956 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
2958 cancel_lru_locks osc
2959 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2962 run_test 39k "write, utime, close, stat ========================"
2964 # this should be set to future
2965 TEST_39_ATIME=`date -d "1 year" +%s`
2968 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2969 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2970 local atime_diff=$(do_facet $SINGLEMDS \
2971 lctl get_param -n mdd.*MDT0000*.atime_diff)
2975 # test setting directory atime to future
2976 touch -a -d @$TEST_39_ATIME $DIR/$tdir
2977 local atime=$(stat -c %X $DIR/$tdir)
2978 [ "$atime" = $TEST_39_ATIME ] || \
2979 error "atime is not set to future: $atime, $TEST_39_ATIME"
2981 # test setting directory atime from future to now
2982 local d1=$(date +%s)
2984 local d2=$(date +%s)
2986 cancel_lru_locks mdc
2987 atime=$(stat -c %X $DIR/$tdir)
2988 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
2989 error "atime is not updated from future: $atime, $d1<atime<$d2"
2991 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
2994 # test setting directory atime when now > dir atime + atime_diff
2998 cancel_lru_locks mdc
2999 atime=$(stat -c %X $DIR/$tdir)
3000 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3001 error "atime is not updated : $atime, should be $d2"
3003 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
3006 # test not setting directory atime when now < dir atime + atime_diff
3008 cancel_lru_locks mdc
3009 atime=$(stat -c %X $DIR/$tdir)
3010 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3011 error "atime is updated to $atime, should remain $d1<atime<$d2"
3013 do_facet $SINGLEMDS \
3014 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3016 run_test 39l "directory atime update ==========================="
3019 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3022 local far_past_mtime=$(date -d "May 29 1953" +%s)
3023 local far_past_atime=$(date -d "Dec 17 1903" +%s)
3025 touch -m -d @$far_past_mtime $DIR1/$tfile
3026 touch -a -d @$far_past_atime $DIR1/$tfile
3028 for (( i=0; i < 2; i++ )) ; do
3029 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
3030 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
3031 error "atime or mtime set incorrectly"
3033 cancel_lru_locks osc
3034 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3037 run_test 39m "test atime and mtime before 1970"
3040 dd if=/dev/zero of=$DIR/f40 bs=4096 count=1
3041 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/f40 && error
3042 $CHECKSTAT -t file -s 4096 $DIR/f40 || error
3044 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
3048 small_write $DIR/f41 18
3050 run_test 41 "test small file write + fstat ====================="
3052 count_ost_writes() {
3053 lctl get_param -n osc.*.stats |
3054 awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }'
3061 BG_DIRTY_RATIO_SAVE=10
3062 MAX_BG_DIRTY_RATIO=25
3066 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
3067 # dirty_ratio, dirty_background_ratio
3068 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3069 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
3070 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
3071 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
3073 # if file not here, we are a 2.4 kernel
3074 kill -CONT `pidof kupdated`
3079 # setup the trap first, so someone cannot exit the test at the
3080 # exact wrong time and mess up a machine
3081 trap start_writeback EXIT
3082 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
3083 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3084 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
3085 sysctl -w vm.dirty_writeback_centisecs=0
3086 sysctl -w vm.dirty_writeback_centisecs=0
3087 # save and increase /proc/sys/vm/dirty_ratio
3088 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
3089 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
3090 # save and increase /proc/sys/vm/dirty_background_ratio
3091 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
3092 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
3094 # if file not here, we are a 2.4 kernel
3095 kill -STOP `pidof kupdated`
3099 # ensure that all stripes have some grant before we test client-side cache
3101 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
3102 dd if=/dev/zero of=$i bs=4k count=1
3107 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
3108 # file truncation, and file removal.
3110 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3112 cancel_lru_locks osc
3114 sync; sleep 1; sync # just to be safe
3115 BEFOREWRITES=`count_ost_writes`
3116 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
3117 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
3118 AFTERWRITES=`count_ost_writes`
3119 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3120 error "$BEFOREWRITES < $AFTERWRITES"
3123 run_test 42a "ensure that we don't flush on close =============="
3126 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3128 cancel_lru_locks osc
3131 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
3132 BEFOREWRITES=`count_ost_writes`
3133 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
3134 AFTERWRITES=`count_ost_writes`
3135 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
3136 error "$BEFOREWRITES < $AFTERWRITES on unlink"
3138 BEFOREWRITES=`count_ost_writes`
3139 sync || error "sync: $?"
3140 AFTERWRITES=`count_ost_writes`
3141 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
3142 error "$BEFOREWRITES < $AFTERWRITES on sync"
3144 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
3148 run_test 42b "test destroy of file with cached dirty data ======"
3150 # if these tests just want to test the effect of truncation,
3151 # they have to be very careful. consider:
3152 # - the first open gets a {0,EOF}PR lock
3153 # - the first write conflicts and gets a {0, count-1}PW
3154 # - the rest of the writes are under {count,EOF}PW
3155 # - the open for truncate tries to match a {0,EOF}PR
3156 # for the filesize and cancels the PWs.
3157 # any number of fixes (don't get {0,EOF} on open, match
3158 # composite locks, do smarter file size management) fix
3159 # this, but for now we want these tests to verify that
3160 # the cancellation with truncate intent works, so we
3161 # start the file with a full-file pw lock to match against
3162 # until the truncate.
3167 cancel_lru_locks osc
3169 # prime the file with 0,EOF PW to match
3173 # now the real test..
3174 dd if=/dev/zero of=$file bs=1024 count=100
3175 BEFOREWRITES=`count_ost_writes`
3176 $TRUNCATE $file $offset
3177 cancel_lru_locks osc
3178 AFTERWRITES=`count_ost_writes`
3183 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3185 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
3186 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
3189 run_test 42c "test partial truncate of file with cached dirty data"
3192 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3194 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3195 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
3198 run_test 42d "test complete truncate of file with cached dirty data"
3200 test_42e() { # bug22074
3201 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3202 local TDIR=$DIR/${tdir}e
3203 local pagesz=$(page_size)
3204 local pages=16 # hardcoded 16 pages, don't change it.
3205 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
3206 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
3210 test_mkdir -p $DIR/${tdir}e
3211 $SETSTRIPE -c 1 $TDIR
3212 createmany -o $TDIR/f $files
3214 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
3216 # we assume that with $OSTCOUNT files, at least one of them will
3217 # be allocated on OST0.
3218 warmup_files=$((OSTCOUNT * max_dirty_mb))
3219 createmany -o $TDIR/w $warmup_files
3221 # write a large amount of data into one file and sync, to get good
3222 # avail_grant number from OST.
3223 for ((i=0; i<$warmup_files; i++)); do
3224 idx=$($GETSTRIPE -i $TDIR/w$i)
3225 [ $idx -ne 0 ] && continue
3226 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
3229 [ $i -gt $warmup_files ] && error "OST0 is still cold"
3231 $LCTL get_param $proc_osc0/cur_dirty_bytes
3232 $LCTL get_param $proc_osc0/cur_grant_bytes
3234 # create as much dirty pages as we can while not to trigger the actual
3235 # RPCs directly. but depends on the env, VFS may trigger flush during this
3236 # period, hopefully we are good.
3237 for ((i=0; i<$warmup_files; i++)); do
3238 idx=$($GETSTRIPE -i $TDIR/w$i)
3239 [ $idx -ne 0 ] && continue
3240 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
3242 $LCTL get_param $proc_osc0/cur_dirty_bytes
3243 $LCTL get_param $proc_osc0/cur_grant_bytes
3245 # perform the real test
3246 $LCTL set_param $proc_osc0/rpc_stats 0
3247 for ((;i<$files; i++)); do
3248 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
3249 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
3252 $LCTL get_param $proc_osc0/rpc_stats
3255 local have_ppr=false
3256 $LCTL get_param $proc_osc0/rpc_stats |
3257 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
3258 # skip lines until we are at the RPC histogram data
3259 [ "$PPR" == "pages" ] && have_ppr=true && continue
3260 $have_ppr || continue
3262 # we only want the percent stat for < 16 pages
3263 [ $(echo $PPR | tr -d ':') -ge $pages ] && break
3265 percent=$((percent + WPCT))
3266 if [ $percent -gt 15 ]; then
3267 error "less than 16-pages write RPCs" \
3274 run_test 42e "verify sub-RPC writes are not done synchronously"
3277 test_mkdir -p $DIR/$tdir
3278 cp -p /bin/ls $DIR/$tdir/$tfile
3279 $MULTIOP $DIR/$tdir/$tfile Ow_c &
3281 # give multiop a chance to open
3284 $DIR/$tdir/$tfile && error || true
3287 run_test 43 "execution of file opened for write should return -ETXTBSY"
3290 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3291 test_mkdir -p $DIR/$tdir
3292 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3293 cp -p multiop $DIR/$tdir/multiop
3294 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/test43.junk O_c ||
3297 $MULTIOP $DIR/$tdir/multiop Oc && error "expected error, got success"
3298 kill -USR1 $MULTIOP_PID || return 2
3299 wait $MULTIOP_PID || return 3
3302 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
3305 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3306 test_mkdir -p $DIR/$tdir
3307 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3308 cp -p multiop $DIR/$tdir/multiop
3309 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/test43.junk O_c ||
3312 $TRUNCATE $DIR/$tdir/multiop 0 && error "expected error, got success"
3313 kill -USR1 $MULTIOP_PID || return 2
3314 wait $MULTIOP_PID || return 3
3317 run_test 43b "truncate of file being executed should return -ETXTBSY"
3320 local testdir="$DIR/$tdir"
3321 test_mkdir -p $DIR/$tdir
3323 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
3324 ( cd $testdir && md5sum -c)
3326 run_test 43c "md5sum of copy into lustre========================"
3329 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
3330 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
3331 dd if=$DIR/f1 bs=4k count=1 > /dev/null
3333 run_test 44 "zero length read from a sparse stripe ============="
3336 local nstripe=`$LCTL lov_getconfig $DIR | grep default_stripe_count: | \
3338 [ -z "$nstripe" ] && skip "can't get stripe info" && return
3339 [ "$nstripe" -gt "$OSTCOUNT" ] && skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" && return
3340 local stride=`$LCTL lov_getconfig $DIR | grep default_stripe_size: | \
3342 if [ $nstripe -eq 0 -o $nstripe -eq -1 ] ; then
3343 nstripe=`$LCTL lov_getconfig $DIR | grep obd_count: | awk '{print $2}'`
3346 OFFSETS="0 $((stride/2)) $((stride-1))"
3347 for offset in $OFFSETS ; do
3348 for i in `seq 0 $((nstripe-1))`; do
3349 local GLOBALOFFSETS=""
3350 local size=$((((i + 2 * $nstripe )*$stride + $offset))) # Bytes
3351 local myfn=$DIR/d44a-$size
3352 echo "--------writing $myfn at $size"
3353 ll_sparseness_write $myfn $size || error "ll_sparseness_write"
3354 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3355 ll_sparseness_verify $myfn $GLOBALOFFSETS \
3356 || error "ll_sparseness_verify $GLOBALOFFSETS"
3358 for j in `seq 0 $((nstripe-1))`; do
3359 size=$((((j + $nstripe )*$stride + $offset))) # Bytes
3360 ll_sparseness_write $myfn $size || error "ll_sparseness_write"
3361 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3363 ll_sparseness_verify $myfn $GLOBALOFFSETS \
3364 || error "ll_sparseness_verify $GLOBALOFFSETS"
3369 run_test 44a "test sparse pwrite ==============================="
3373 for d in `lctl get_param -n osc.*.cur_dirty_bytes`; do
3379 before=`dirty_osc_total`
3380 echo executing "\"$*\""
3382 after=`dirty_osc_total`
3383 echo before $before, after $after
3386 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3388 # Obtain grants from OST if it supports it
3389 echo blah > ${f}_grant
3392 do_dirty_record "echo blah > $f"
3393 [ $before -eq $after ] && error "write wasn't cached"
3394 do_dirty_record "> $f"
3395 [ $before -gt $after ] || error "truncate didn't lower dirty count"
3396 do_dirty_record "echo blah > $f"
3397 [ $before -eq $after ] && error "write wasn't cached"
3398 do_dirty_record "sync"
3399 [ $before -gt $after ] || error "writeback didn't lower dirty count"
3400 do_dirty_record "echo blah > $f"
3401 [ $before -eq $after ] && error "write wasn't cached"
3402 do_dirty_record "cancel_lru_locks osc"
3403 [ $before -gt $after ] || error "lock cancellation didn't lower dirty count"
3406 run_test 45 "osc io page accounting ============================"
3408 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
3409 # test tickles a bug where re-dirtying a page was failing to be mapped to the
3410 # objects offset and an assert hit when an rpc was built with 1023's mapped
3411 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
3413 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3417 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1