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
3419 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
3420 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3424 run_test 46 "dirtying a previously written page ================"
3426 # test_47 is removed "Device nodes check" is moved to test_28
3428 test_48a() { # bug 2399
3429 check_kernel_version 34 || return 0
3430 test_mkdir -p $DIR/$tdir
3432 mv $DIR/$tdir $DIR/d48.new || error "move directory failed"
3433 test_mkdir $DIR/$tdir || error "recreate directory failed"
3434 touch foo || error "'touch foo' failed after recreating cwd"
3435 test_mkdir $DIR/$tdir/bar ||
3436 error "'mkdir foo' failed after recreating cwd"
3437 if check_kernel_version 44; then
3438 touch .foo || error "'touch .foo' failed after recreating cwd"
3439 test_mkdir $DIR/$tdir/.bar ||
3440 error "'mkdir .foo' failed after recreating cwd"
3442 ls . > /dev/null || error "'ls .' failed after recreating cwd"
3443 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3444 cd . || error "'cd .' failed after recreating cwd"
3445 test_mkdir . && error "'mkdir .' worked after recreating cwd"
3446 rmdir . && error "'rmdir .' worked after recreating cwd"
3447 ln -s . baz || error "'ln -s .' failed after recreating cwd"
3448 cd .. || error "'cd ..' failed after recreating cwd"
3450 run_test 48a "Access renamed working dir (should return errors)="
3452 test_48b() { # bug 2399
3453 check_kernel_version 34 || return 0
3455 test_mkdir -p $DIR/$tdir
3457 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
3458 touch foo && error "'touch foo' worked after removing cwd"
3459 test_mkdir $DIR/$tdir/foo &&
3460 error "'mkdir foo' worked after removing cwd"
3461 if check_kernel_version 44; then
3462 touch .foo && error "'touch .foo' worked after removing cwd"
3463 test_mkdir $DIR/$tdir/.foo &&
3464 error "'mkdir .foo' worked after removing cwd"
3466 ls . > /dev/null && error "'ls .' worked after removing cwd"
3467 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3468 is_patchless || ( cd . && error "'cd .' worked after removing cwd" )
3469 test_mkdir $DIR/$tdir/. && error "'mkdir .' worked after removing cwd"
3470 rmdir . && error "'rmdir .' worked after removing cwd"
3471 ln -s . foo && error "'ln -s .' worked after removing cwd"
3472 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
3474 run_test 48b "Access removed working dir (should return errors)="
3476 test_48c() { # bug 2350
3477 check_kernel_version 36 || return 0
3478 #lctl set_param debug=-1
3481 test_mkdir -p $DIR/$tdir/dir
3483 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3484 $TRACE touch foo && error "touch foo worked after removing cwd"
3485 $TRACE test_mkdir foo && error "'mkdir foo' worked after removing cwd"
3486 if check_kernel_version 44; then
3487 touch .foo && error "touch .foo worked after removing cwd"
3488 test_mkdir .foo && error "mkdir .foo worked after removing cwd"
3490 $TRACE ls . && error "'ls .' worked after removing cwd"
3491 $TRACE ls .. || error "'ls ..' failed after removing cwd"
3492 is_patchless || ( $TRACE cd . &&
3493 error "'cd .' worked after removing cwd" )
3494 $TRACE test_mkdir . && error "'mkdir .' worked after removing cwd"
3495 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
3496 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
3497 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
3499 run_test 48c "Access removed working subdir (should return errors)"
3501 test_48d() { # bug 2350
3502 check_kernel_version 36 || return 0
3503 #lctl set_param debug=-1
3506 test_mkdir -p $DIR/$tdir/dir
3508 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3509 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3510 $TRACE touch foo && error "'touch foo' worked after removing parent"
3511 $TRACE test_mkdir foo && error "mkdir foo worked after removing parent"
3512 if check_kernel_version 44; then
3513 touch .foo && error "'touch .foo' worked after removing parent"
3515 error "mkdir .foo worked after removing parent"
3517 $TRACE ls . && error "'ls .' worked after removing parent"
3518 $TRACE ls .. && error "'ls ..' worked after removing parent"
3519 is_patchless || ( $TRACE cd . &&
3520 error "'cd .' worked after recreate parent" )
3521 $TRACE test_mkdir . && error "'mkdir .' worked after removing parent"
3522 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
3523 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
3524 is_patchless || ( $TRACE cd .. &&
3525 error "'cd ..' worked after removing parent" || true )
3527 run_test 48d "Access removed parent subdir (should return errors)"
3529 test_48e() { # bug 4134
3530 check_kernel_version 41 || return 0
3531 #lctl set_param debug=-1
3534 test_mkdir -p $DIR/$tdir/dir
3536 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3537 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3538 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
3539 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
3540 # On a buggy kernel addition of "touch foo" after cd .. will
3541 # produce kernel oops in lookup_hash_it
3542 touch ../foo && error "'cd ..' worked after recreate parent"
3544 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
3546 run_test 48e "Access to recreated parent subdir (should return errors)"
3548 test_49() { # LU-1030
3549 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3550 # get ost1 size - lustre-OST0000
3551 ost1_size=$(do_facet ost1 lfs df |grep ${ost1_svc} |awk '{print $4}')
3552 # write 800M at maximum
3553 [ $ost1_size -gt 819200 ] && ost1_size=819200
3555 lfs setstripe -c 1 -i 0 $DIR/$tfile
3556 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
3559 # change max_pages_per_rpc while writing the file
3560 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
3561 local orig_mppc=`$LCTL get_param -n $osc1_mppc`
3562 # loop until dd process exits
3563 while ps ax -opid | grep -wq $dd_pid; do
3564 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
3565 sleep $((RANDOM % 5 + 1))
3567 # restore original max_pages_per_rpc
3568 $LCTL set_param $osc1_mppc=$orig_mppc
3569 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
3571 run_test 49 "Change max_pages_per_rpc won't break osc extent"
3575 test_mkdir $DIR/$tdir
3577 ls /proc/$$/cwd || error
3579 run_test 50 "special situations: /proc symlinks ==============="
3581 test_51a() { # was test_51
3582 # bug 1516 - create an empty entry right after ".." then split dir
3583 test_mkdir -p $DIR/$tdir
3584 touch $DIR/$tdir/foo
3585 $MCREATE $DIR/$tdir/bar
3587 createmany -m $DIR/$tdir/longfile 201
3589 while [ `ls -sd $DIR/$tdir | awk '{ print $1 }'` -eq 4 ]; do
3590 $MCREATE $DIR/$tdir/longfile$FNUM
3595 ls -l $DIR/$tdir > /dev/null || error
3597 run_test 51a "special situations: split htree with empty entry =="
3599 export NUMTEST=70000
3601 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3602 local BASE=$DIR/$tdir
3604 # cleanup the directory
3609 local mdtidx=$(printf "%04x" $($LFS getstripe -M $BASE))
3610 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
3611 [ $numfree -lt 21000 ] && skip "not enough free inodes ($numfree)" &&
3614 [ $numfree -lt $NUMTEST ] && NUMTEST=$(($numfree - 50)) &&
3615 echo "reduced count to $NUMTEST due to inodes"
3617 # need to check free space for the directories as well
3618 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
3619 numfree=$((blkfree / 4))
3620 [ $numfree -lt $NUMTEST ] && NUMTEST=$(($numfree - 50)) &&
3621 echo "reduced count to $NUMTEST due to blocks"
3623 createmany -d $BASE/d $NUMTEST && echo $NUMTEST > $BASE/fnum ||
3624 echo "failed" > $BASE/fnum
3626 run_test 51b "exceed 64k subdirectory nlink limit"
3628 test_51ba() { # LU-993
3629 local BASE=$DIR/$tdir
3630 # unlink all but 100 subdirectories, then check it still works
3632 [ -f $BASE/fnum ] && local NUMPREV=$(cat $BASE/fnum) && rm $BASE/fnum
3634 [ "$NUMPREV" != "failed" ] && NUMTEST=$NUMPREV
3635 local DELETE=$((NUMTEST - LEFT))
3637 # continue on to run this test even if 51b didn't finish,
3638 # just to delete the many subdirectories created.
3639 [ ! -d "${BASE}/d1" ] && skip "test_51b() not run" && return 0
3641 # for ldiskfs the nlink count should be 1, but this is OSD specific
3642 # and so this is listed for informational purposes only
3643 echo "nlink before: $(stat -c %h $BASE), created before: $NUMTEST"
3644 unlinkmany -d $BASE/d $DELETE
3647 if [ $RC -ne 0 ]; then
3648 if [ "$NUMPREV" == "failed" ]; then
3649 skip "previous setup failed"
3652 error "unlink of first $DELETE subdirs failed"
3657 echo "nlink between: $(stat -c %h $BASE)"
3658 # trim the first line of ls output
3659 local FOUND=$(($(ls -l ${BASE} | wc -l) - 1))
3660 [ $FOUND -ne $LEFT ] &&
3661 error "can't find subdirs: found only $FOUND/$LEFT"
3663 unlinkmany -d $BASE/d $DELETE $LEFT ||
3664 error "unlink of second $LEFT subdirs failed"
3665 # regardless of whether the backing filesystem tracks nlink accurately
3666 # or not, the nlink count shouldn't be more than "." and ".." here
3667 local AFTER=$(stat -c %h $BASE)
3668 [ $AFTER -gt 2 ] && error "nlink after: $AFTER > 2" ||
3669 echo "nlink after: $AFTER"
3671 run_test 51ba "verify nlink for many subdirectory cleanup"
3674 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3675 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping test with few OSTs" && return
3676 test_mkdir -p $DIR/$tdir
3677 createmany -o $DIR/$tdir/t- 1000
3678 $GETSTRIPE $DIR/$tdir > $TMP/files
3679 for N in `seq 0 $((OSTCOUNT - 1))`; do
3680 OBJS[$N]=`awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}' $TMP/files`
3681 OBJS0[$N]=`grep -A 1 idx $TMP/files | awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}'`
3682 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
3684 unlinkmany $DIR/$tdir/t- 1000
3687 for N in `seq 1 $((OSTCOUNT - 1))`; do
3688 [ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ] && \
3689 error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
3690 [ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ] && \
3691 error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
3693 [ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ] && \
3694 error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
3695 [ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ] && \
3696 error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
3700 run_test 51d "check object distribution ===================="
3703 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
3704 test_mkdir -p $DIR/$tdir
3705 touch $DIR/$tdir/foo
3706 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
3707 echo bar >> $DIR/$tdir/foo || error "append bar failed"
3708 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
3709 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
3710 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
3712 echo foo >> $DIR/$tdir/foo || error "append foo failed"
3713 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
3714 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
3716 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
3717 cp -r $DIR/$tdir /tmp/
3718 rm -fr $DIR/$tdir || error "cleanup rm failed"
3720 run_test 52a "append-only flag test (should return errors) ====="
3723 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
3724 test_mkdir -p $DIR/$tdir
3725 touch $DIR/$tdir/foo
3726 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
3727 cat test > $DIR/$tdir/foo && error "cat test worked"
3728 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
3729 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
3730 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
3732 echo foo >> $DIR/$tdir/foo && error "echo worked"
3733 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
3734 [ -f $DIR/$tdir/foo ] || error
3735 [ -f $DIR/$tdir/foo_ren ] && error
3736 lsattr $DIR/$tdir/foo | egrep -q "^-+i[-e]+ $DIR/$tdir/foo" ||
3738 chattr -i $DIR/$tdir/foo || error "chattr failed"
3740 rm -fr $DIR/$tdir || error
3742 run_test 52b "immutable flag test (should return errors) ======="
3745 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3746 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3747 remote_ost_nodsh && skip "remote OST with nodsh" && return
3757 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
3758 for value in $(do_facet $SINGLEMDS lctl get_param osc.$mdtosc.prealloc_last_id) ; do
3759 param=`echo ${value[0]} | cut -d "=" -f1`
3760 ostname=`echo $param | cut -d "." -f2 | cut -d - -f 1-2`
3761 mds_last=$(do_facet $SINGLEMDS lctl get_param -n $param)
3762 ostnum=$(index_from_ostuuid ${ostname}_UUID)
3763 node=$(facet_active_host ost$((ostnum+1)))
3764 param="obdfilter.$ostname.last_id"
3765 ost_last=$(do_node $node lctl get_param -n $param | head -n 1)
3766 echo "$ostname.last_id=$ost_last ; MDS.last_id=$mds_last"
3767 if [ $ost_last != $mds_last ]; then
3768 error "$ostname.last_id=$ost_last ; MDS.last_id=$mds_last"
3772 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
3775 [ ! -f "$SOCKETSERVER" ] && skip_env "no socketserver, skipping" && return
3776 [ ! -f "$SOCKETCLIENT" ] && skip_env "no socketclient, skipping" && return
3777 $SOCKETSERVER $DIR/socket
3778 $SOCKETCLIENT $DIR/socket || error
3779 $MUNLINK $DIR/socket
3781 run_test 54a "unix domain socket test =========================="
3787 dd if=/dev/zero of=$f bs=`page_size` count=1
3789 run_test 54b "char device works in lustre ======================"
3792 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
3793 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
3794 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
3796 for i in `seq 3 7`; do
3797 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
3805 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3808 loopdev="$DIR/loop54c"
3811 [ -z "$LOOPNUM" ] && echo "couldn't find empty loop device" && return
3812 mknod $loopdev b 7 $LOOPNUM
3813 echo "make a loop file system with $tfile on $loopdev ($LOOPNUM)..."
3814 dd if=/dev/zero of=$tfile bs=`page_size` seek=1024 count=1 > /dev/null
3815 losetup $loopdev $tfile || error "can't set up $loopdev for $tfile"
3816 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
3818 mount -t ext2 $loopdev $tdir || error "error mounting $loopdev on $tdir"
3819 dd if=/dev/zero of=$tdir/tmp bs=`page_size` count=30 || error "dd write"
3821 dd if=$tdir/tmp of=/dev/zero bs=`page_size` count=30 || error "dd read"
3826 run_test 54c "block device works in lustre ====================="
3832 [ "$string" = `echo $string > $f | cat $f` ] || error
3834 run_test 54d "fifo device works in lustre ======================"
3837 check_kernel_version 46 || return 0
3840 cp -aL /dev/console $f
3841 echo $string > $f || error
3843 run_test 54e "console/tty device works in lustre ======================"
3845 #The test_55 used to be iopen test and it was removed by bz#24037.
3846 #run_test 55 "check iopen_connect_dentry() ======================"
3848 test_56a() { # was test_56
3851 test_mkdir $DIR/$tdir
3852 test_mkdir $DIR/$tdir/dir
3854 NUMFILESx2=$(($NUMFILES * 2))
3855 for i in `seq 1 $NUMFILES` ; do
3856 touch $DIR/$tdir/file$i
3857 touch $DIR/$tdir/dir/file$i
3860 # test lfs getstripe with --recursive
3861 FILENUM=`$GETSTRIPE --recursive $DIR/$tdir | grep -c obdidx`
3862 [ $FILENUM -eq $NUMFILESx2 ] ||
3863 error "$GETSTRIPE --recursive: found $FILENUM, not $NUMFILESx2"
3864 FILENUM=`$GETSTRIPE $DIR/$tdir | grep -c obdidx`
3865 [ $FILENUM -eq $NUMFILES ] ||
3866 error "$GETSTRIPE $DIR/$tdir: found $FILENUM, not $NUMFILES"
3867 echo "$GETSTRIPE --recursive passed."
3869 # test lfs getstripe with file instead of dir
3870 FILENUM=`$GETSTRIPE $DIR/$tdir/file1 | grep -c obdidx`
3871 [ $FILENUM -eq 1 ] || error \
3872 "$GETSTRIPE $DIR/$tdir/file1: found $FILENUM, not 1"
3873 echo "$GETSTRIPE file1 passed."
3875 #test lfs getstripe with --verbose
3876 [ `$GETSTRIPE --verbose $DIR/$tdir |
3877 grep -c lmm_magic` -eq $NUMFILES ] ||
3878 error "$GETSTRIPE --verbose $DIR/$tdir: want $NUMFILES"
3879 [ `$GETSTRIPE $DIR/$tdir | grep -c lmm_magic` -eq 0 ] ||
3880 error "$GETSTRIPE $DIR/$tdir: showed lmm_magic"
3881 echo "$GETSTRIPE --verbose passed."
3883 #test lfs getstripe with --obd
3884 $GETSTRIPE --obd wrong_uuid $DIR/$tdir 2>&1 |
3885 grep -q "unknown obduuid" ||
3886 error "$GETSTRIPE --obd wrong_uuid should return error message"
3888 [ "$OSTCOUNT" -lt 2 ] &&
3889 skip_env "skipping other $GETSTRIPE --obd test" && return
3892 OBDUUID=$(ostuuid_from_index $OSTIDX)
3893 FILENUM=`$GETSTRIPE -ir $DIR/$tdir | grep -x $OSTIDX | wc -l`
3894 FOUND=`$GETSTRIPE -r --obd $OBDUUID $DIR/$tdir | grep obdidx | wc -l`
3895 [ $FOUND -eq $FILENUM ] ||
3896 error "$GETSTRIPE --obd wrong: found $FOUND, expected $FILENUM"
3897 [ `$GETSTRIPE -r -v --obd $OBDUUID $DIR/$tdir |
3898 sed '/^[ ]*'${OSTIDX}'[ ]/d' |
3899 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l` -eq 0 ] ||
3900 error "$GETSTRIPE --obd: should not show file on other obd"
3901 echo "$GETSTRIPE --obd passed"
3903 run_test 56a "check $GETSTRIPE"
3908 local LOCAL_NUMFILES="$1"
3909 local LOCAL_NUMDIRS="$2"
3910 local MKDIR_PARAMS="$3"
3912 if [ ! -d "$TDIR" ] ; then
3914 [ "$MKDIR_PARAMS" ] && $SETSTRIPE $MKDIR_PARAMS $TDIR
3915 for i in `seq 1 $LOCAL_NUMFILES` ; do
3918 for i in `seq 1 $LOCAL_NUMDIRS` ; do
3919 test_mkdir $TDIR/dir$i
3920 for j in `seq 1 $LOCAL_NUMFILES` ; do
3921 touch $TDIR/dir$i/file$j
3927 setup_56_special() {
3931 if [ ! -e "$TDIR/loop1b" ] ; then
3932 for i in `seq 1 $LOCAL_NUMFILES` ; do
3933 mknod $TDIR/loop${i}b b 7 $i
3934 mknod $TDIR/null${i}c c 1 3
3935 ln -s $TDIR/file1 $TDIR/link${i}l
3937 for i in `seq 1 $LOCAL_NUMDIRS` ; do
3938 mknod $TDIR/dir$i/loop${i}b b 7 $i
3939 mknod $TDIR/dir$i/null${i}c c 1 3
3940 ln -s $TDIR/dir$i/file1 $TDIR/dir$i/link${i}l
3949 setup_56 $NUMFILES $NUMDIRS
3951 EXPECTED=$(($NUMDIRS + 2))
3952 # test lfs find with -name
3953 for i in $(seq 1 $NUMFILES) ; do
3954 NUMS=$($LFIND -name "*$i" $TDIR | wc -l)
3955 [ $NUMS -eq $EXPECTED ] ||
3956 error "lfs find -name \"*$i\" $TDIR wrong: "\
3957 "found $NUMS, expected $EXPECTED"
3960 run_test 56g "check lfs find -name ============================="
3966 setup_56 $NUMFILES $NUMDIRS
3968 EXPECTED=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
3969 # test lfs find with ! -name
3970 for i in $(seq 1 $NUMFILES) ; do
3971 NUMS=$($LFIND ! -name "*$i" $TDIR | wc -l)
3972 [ $NUMS -eq $EXPECTED ] ||
3973 error "lfs find ! -name \"*$i\" $TDIR wrong: "\
3974 "found $NUMS, expected $EXPECTED"
3977 run_test 56h "check lfs find ! -name ============================="
3981 test_mkdir -p $DIR/$tdir
3982 UUID=$(ostuuid_from_index 0 $DIR/$tdir)
3983 CMD="$LFIND -ost $UUID $DIR/$tdir"
3985 [ -z "$OUT" ] || error "\"$CMD\" returned directory '$OUT'"
3987 run_test 56i "check 'lfs find -ost UUID' skips directories ======="
3991 setup_56_special $NUMFILES $NUMDIRS
3993 EXPECTED=$((NUMDIRS + 1))
3994 CMD="$LFIND -type d $TDIR"
3995 NUMS=$($CMD | wc -l)
3996 [ $NUMS -eq $EXPECTED ] ||
3997 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3999 run_test 56j "check lfs find -type d ============================="
4003 setup_56_special $NUMFILES $NUMDIRS
4005 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4006 CMD="$LFIND -type f $TDIR"
4007 NUMS=$($CMD | wc -l)
4008 [ $NUMS -eq $EXPECTED ] ||
4009 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4011 run_test 56k "check lfs find -type f ============================="
4015 setup_56_special $NUMFILES $NUMDIRS
4017 EXPECTED=$((NUMDIRS + NUMFILES))
4018 CMD="$LFIND -type b $TDIR"
4019 NUMS=$($CMD | wc -l)
4020 [ $NUMS -eq $EXPECTED ] ||
4021 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4023 run_test 56l "check lfs find -type b ============================="
4027 setup_56_special $NUMFILES $NUMDIRS
4029 EXPECTED=$((NUMDIRS + NUMFILES))
4030 CMD="$LFIND -type c $TDIR"
4031 NUMS=$($CMD | wc -l)
4032 [ $NUMS -eq $EXPECTED ] ||
4033 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4035 run_test 56m "check lfs find -type c ============================="
4039 setup_56_special $NUMFILES $NUMDIRS
4041 EXPECTED=$((NUMDIRS + NUMFILES))
4042 CMD="$LFIND -type l $TDIR"
4043 NUMS=$($CMD | wc -l)
4044 [ $NUMS -eq $EXPECTED ] ||
4045 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4047 run_test 56n "check lfs find -type l ============================="
4051 setup_56 $NUMFILES $NUMDIRS
4053 utime $TDIR/file1 > /dev/null || error "utime (1)"
4054 utime $TDIR/file2 > /dev/null || error "utime (2)"
4055 utime $TDIR/dir1 > /dev/null || error "utime (3)"
4056 utime $TDIR/dir2 > /dev/null || error "utime (4)"
4057 utime $TDIR/dir1/file1 > /dev/null || error "utime (5)"
4058 dd if=/dev/zero count=1 >> $TDIR/dir1/file1 && sync
4061 NUMS=`$LFIND -mtime +0 $TDIR | wc -l`
4062 [ $NUMS -eq $EXPECTED ] || \
4063 error "lfs find -mtime +0 $TDIR wrong: found $NUMS, expected $EXPECTED"
4066 CMD="$LFIND -mtime 0 $TDIR"
4067 NUMS=$($CMD | wc -l)
4068 [ $NUMS -eq $EXPECTED ] ||
4069 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4071 run_test 56o "check lfs find -mtime for old files =========================="
4074 [ $RUNAS_ID -eq $UID ] &&
4075 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4078 setup_56 $NUMFILES $NUMDIRS
4080 chown $RUNAS_ID $TDIR/file* || error "chown $DIR/${tdir}g/file$i failed"
4082 CMD="$LFIND -uid $RUNAS_ID $TDIR"
4083 NUMS=$($CMD | wc -l)
4084 [ $NUMS -eq $EXPECTED ] || \
4085 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4087 EXPECTED=$(((NUMFILES + 1) * NUMDIRS + 1))
4088 CMD="$LFIND ! -uid $RUNAS_ID $TDIR"
4089 NUMS=$($CMD | wc -l)
4090 [ $NUMS -eq $EXPECTED ] || \
4091 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4093 run_test 56p "check lfs find -uid and ! -uid ==============================="
4096 [ $RUNAS_ID -eq $UID ] &&
4097 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4100 setup_56 $NUMFILES $NUMDIRS
4102 chgrp $RUNAS_GID $TDIR/file* || error "chown $TDIR/file$i failed"
4105 CMD="$LFIND -gid $RUNAS_GID $TDIR"
4106 NUMS=$($CMD | wc -l)
4107 [ $NUMS -eq $EXPECTED ] ||
4108 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4110 EXPECTED=$(( ($NUMFILES+1) * $NUMDIRS + 1))
4111 CMD="$LFIND ! -gid $RUNAS_GID $TDIR"
4112 NUMS=$($CMD | wc -l)
4113 [ $NUMS -eq $EXPECTED ] ||
4114 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4116 run_test 56q "check lfs find -gid and ! -gid ==============================="
4120 setup_56 $NUMFILES $NUMDIRS
4123 CMD="$LFIND -size 0 -type f $TDIR"
4124 NUMS=$($CMD | wc -l)
4125 [ $NUMS -eq $EXPECTED ] ||
4126 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4128 CMD="$LFIND ! -size 0 -type f $TDIR"
4129 NUMS=$($CMD | wc -l)
4130 [ $NUMS -eq $EXPECTED ] ||
4131 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4132 echo "test" > $TDIR/$tfile
4133 echo "test2" > $TDIR/$tfile.2 && sync
4135 CMD="$LFIND -size 5 -type f $TDIR"
4136 NUMS=$($CMD | wc -l)
4137 [ $NUMS -eq $EXPECTED ] ||
4138 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4140 CMD="$LFIND -size +5 -type f $TDIR"
4141 NUMS=$($CMD | wc -l)
4142 [ $NUMS -eq $EXPECTED ] ||
4143 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4145 CMD="$LFIND -size +0 -type f $TDIR"
4146 NUMS=$($CMD | wc -l)
4147 [ $NUMS -eq $EXPECTED ] ||
4148 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4150 CMD="$LFIND ! -size -5 -type f $TDIR"
4151 NUMS=$($CMD | wc -l)
4152 [ $NUMS -eq $EXPECTED ] ||
4153 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4155 CMD="$LFIND -size -5 -type f $TDIR"
4156 NUMS=$($CMD | wc -l)
4157 [ $NUMS -eq $EXPECTED ] ||
4158 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4160 run_test 56r "check lfs find -size works =========================="
4162 test_56s() { # LU-611
4164 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT"
4166 if [ $OSTCOUNT -gt 1 ]; then
4167 $SETSTRIPE -c 1 $TDIR/$tfile.{0,1,2,3}
4171 ONESTRIPE=$(((NUMDIRS + 1) * NUMFILES))
4175 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4176 CMD="$LFIND -stripe-count $OSTCOUNT -type f $TDIR"
4177 NUMS=$($CMD | wc -l)
4178 [ $NUMS -eq $EXPECTED ] ||
4179 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4181 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + EXTRA))
4182 CMD="$LFIND -stripe-count +0 -type f $TDIR"
4183 NUMS=$($CMD | wc -l)
4184 [ $NUMS -eq $EXPECTED ] ||
4185 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4188 CMD="$LFIND -stripe-count 1 -type f $TDIR"
4189 NUMS=$($CMD | wc -l)
4190 [ $NUMS -eq $EXPECTED ] ||
4191 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4193 CMD="$LFIND -stripe-count -2 -type f $TDIR"
4194 NUMS=$($CMD | wc -l)
4195 [ $NUMS -eq $EXPECTED ] ||
4196 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4199 CMD="$LFIND -stripe-count $((OSTCOUNT + 1)) -type f $TDIR"
4200 NUMS=$($CMD | wc -l)
4201 [ $NUMS -eq $EXPECTED ] ||
4202 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4204 run_test 56s "check lfs find -stripe-count works"
4206 test_56t() { # LU-611
4208 setup_56 $NUMFILES $NUMDIRS "-s 512k"
4210 $SETSTRIPE -S 256k $TDIR/$tfile.{0,1,2,3}
4212 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4213 CMD="$LFIND -stripe-size 512k -type f $TDIR"
4214 NUMS=$($CMD | wc -l)
4215 [ $NUMS -eq $EXPECTED ] ||
4216 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4218 CMD="$LFIND -stripe-size +320k -type f $TDIR"
4219 NUMS=$($CMD | wc -l)
4220 [ $NUMS -eq $EXPECTED ] ||
4221 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4223 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + 4))
4224 CMD="$LFIND -stripe-size +200k -type f $TDIR"
4225 NUMS=$($CMD | wc -l)
4226 [ $NUMS -eq $EXPECTED ] ||
4227 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4229 CMD="$LFIND -stripe-size -640k -type f $TDIR"
4230 NUMS=$($CMD | wc -l)
4231 [ $NUMS -eq $EXPECTED ] ||
4232 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4235 CMD="$LFIND -stripe-size 256k -type f $TDIR"
4236 NUMS=$($CMD | wc -l)
4237 [ $NUMS -eq $EXPECTED ] ||
4238 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4240 CMD="$LFIND -stripe-size -320k -type f $TDIR"
4241 NUMS=$($CMD | wc -l)
4242 [ $NUMS -eq $EXPECTED ] ||
4243 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4246 CMD="$LFIND -stripe-size 1024k -type f $TDIR"
4247 NUMS=$($CMD | wc -l)
4248 [ $NUMS -eq $EXPECTED ] ||
4249 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4251 run_test 56t "check lfs find -stripe-size works"
4253 test_56u() { # LU-611
4255 setup_56 $NUMFILES $NUMDIRS "-i 0"
4257 if [ $OSTCOUNT -gt 1 ]; then
4258 $SETSTRIPE -i 1 $TDIR/$tfile.{0,1,2,3}
4264 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4265 CMD="$LFIND -stripe-index 0 -type f $TDIR"
4266 NUMS=$($CMD | wc -l)
4267 [ $NUMS -eq $EXPECTED ] ||
4268 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4271 CMD="$LFIND -stripe-index 1 -type f $TDIR"
4272 NUMS=$($CMD | wc -l)
4273 [ $NUMS -eq $EXPECTED ] ||
4274 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4276 CMD="$LFIND ! -stripe-index 0 -type f $TDIR"
4277 NUMS=$($CMD | wc -l)
4278 [ $NUMS -eq $EXPECTED ] ||
4279 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4282 # This should produce an error and not return any files
4283 CMD="$LFIND -stripe-index $OSTCOUNT -type f $TDIR"
4284 NUMS=$($CMD 2>/dev/null | wc -l)
4285 [ $NUMS -eq $EXPECTED ] ||
4286 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4288 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + ONESTRIPE))
4289 CMD="$LFIND -stripe-index 0,1 -type f $TDIR"
4290 NUMS=$($CMD | wc -l)
4291 [ $NUMS -eq $EXPECTED ] ||
4292 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4294 run_test 56u "check lfs find -stripe-index works"
4301 setup_56 $NUMFILES $NUMDIRS
4303 UUID=$(mdtuuid_from_index $MDT_IDX $TDIR)
4304 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT index $MDT_IDX"
4306 for file in $($LFIND -mdt $UUID $TDIR); do
4307 file_mdt_idx=$($GETSTRIPE -M $file)
4308 [ $file_mdt_idx -eq $MDT_IDX ] ||
4309 error "'lfind -mdt $UUID' != 'getstripe -M' ($file_mdt_idx)"
4312 run_test 56v "check 'lfs find -mdt match with lfs getstripe -M' ======="
4314 # Get and check the actual stripe count of one file.
4315 # Usage: check_stripe_count <file> <expected_stripe_count>
4316 check_stripe_count() {
4321 [[ -z "$file" || -z "$expected" ]] &&
4322 error "check_stripe_count: invalid argument!"
4324 local cmd="$GETSTRIPE -c $file"
4325 actual=$($cmd) || error "$cmd failed"
4326 actual=${actual%% *}
4328 if [[ $actual -ne $expected ]]; then
4329 [[ $expected -eq -1 ]] ||
4330 error "$cmd wrong: found $actual, expected $expected"
4331 [[ $actual -eq $OSTCOUNT ]] ||
4332 error "$cmd wrong: found $actual, expected $OSTCOUNT"
4337 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4340 rm -rf $TDIR || error "remove $TDIR failed"
4341 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT"
4344 stripe_size=$($GETSTRIPE -S -d $TDIR) ||
4345 error "$GETSTRIPE -S -d $TDIR failed"
4346 stripe_size=${stripe_size%% *}
4348 local file_size=$((stripe_size * OSTCOUNT))
4349 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
4350 local required_space=$((file_num * file_size))
4351 local free_space=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
4352 [[ $free_space -le $((required_space / 1024)) ]] &&
4353 skip_env "need at least $required_space bytes free space," \
4354 "have $free_space kbytes" && return
4357 local dd_count=$((file_size / dd_bs))
4359 # write data into the files
4363 for i in $(seq 1 $NUMFILES); do
4365 yes | dd bs=$dd_bs count=$dd_count of=$file >/dev/null 2>&1 ||
4366 error "write data into $file failed"
4368 for i in $(seq 1 $NUMDIRS); do
4369 for j in $(seq 1 $NUMFILES); do
4370 file=$TDIR/dir$i/file$j
4371 yes | dd bs=$dd_bs count=$dd_count of=$file \
4373 error "write data into $file failed"
4378 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
4381 local cmd="$LFS_MIGRATE -y -c $expected $TDIR/file1"
4383 eval $cmd || error "$cmd failed"
4385 check_stripe_count $TDIR/file1 $expected
4388 cmd="$LFS_MIGRATE -y -c $expected $TDIR/dir1"
4390 eval $cmd || error "$cmd failed"
4392 for j in $(seq 1 $NUMFILES); do
4393 check_stripe_count $TDIR/dir1/file$j $expected
4396 # lfs_migrate works with lfs find
4397 cmd="$LFIND -stripe_count $OSTCOUNT -type f $TDIR |
4398 $LFS_MIGRATE -y -c $expected"
4400 eval $cmd || error "$cmd failed"
4402 for i in $(seq 2 $NUMFILES); do
4403 check_stripe_count $TDIR/file$i $expected
4405 for i in $(seq 2 $NUMDIRS); do
4406 for j in $(seq 1 $NUMFILES); do
4407 check_stripe_count $TDIR/dir$i/file$j $expected
4411 run_test 56w "check lfs_migrate -c stripe_count works"
4414 check_swap_layouts_support && return 0
4415 [ "$OSTCOUNT" -lt "2" ] &&
4416 skip_env "need 2 OST, skipping test" && return
4418 local dir0=$DIR/$tdir/$testnum
4419 mkdir -p $dir0 || error "creating dir $dir0"
4421 local ref1=/etc/passwd
4422 local file1=$dir0/file1
4424 $SETSTRIPE -c 2 $file1
4426 $LFS migrate -c 1 $file1 || error "migrate failed rc = $?"
4427 stripe=$($GETSTRIPE -c $file1)
4428 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
4429 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
4434 run_test 56x "lfs migration support"
4437 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4438 # note test will not do anything if MDS is not local
4439 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4440 skip "Only applicable to ldiskfs-based MDTs"
4444 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4445 local MNTDEV="osd*.*MDT*.mntdev"
4446 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
4447 [ -z "$DEV" ] && error "can't access $MNTDEV"
4448 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
4449 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
4450 error "can't access $DEV"
4451 DEVISIZE=`awk '/Inode size:/ { print $3 }' $TMP/t57a.dump`
4452 [ "$DEVISIZE" -gt 128 ] || error "inode size $DEVISIZE"
4456 run_test 57a "verify MDS filesystem created with large inodes =="
4459 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4460 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4461 skip "Only applicable to ldiskfs-based MDTs"
4465 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4470 local FILEN=$dir/f$FILECOUNT
4472 rm -rf $dir || error "removing $dir"
4473 test_mkdir -p $dir || error "creating $dir"
4474 local num=$(get_mds_dir $dir)
4477 echo "mcreating $FILECOUNT files"
4478 createmany -m $dir/f 1 $FILECOUNT || \
4479 error "creating files in $dir"
4481 # verify that files do not have EAs yet
4482 $GETSTRIPE $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
4483 $GETSTRIPE $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
4487 df $dir #make sure we get new statfs data
4488 local MDSFREE=$(do_facet $mymds \
4489 lctl get_param -n osd*.*MDT000$((num -1)).kbytesfree)
4490 local MDCFREE=$(lctl get_param -n mdc.*MDT000$((num -1))-mdc-*.kbytesfree)
4491 echo "opening files to create objects/EAs"
4493 for FILE in `seq -f $dir/f%g 1 $FILECOUNT`; do
4494 $OPENFILE -f O_RDWR $FILE > /dev/null 2>&1 || error "opening $FILE"
4497 # verify that files have EAs now
4498 $GETSTRIPE $FILE1 | grep -q "obdidx" || error "$FILE1 missing EA"
4499 $GETSTRIPE $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
4501 sleep 1 #make sure we get new statfs data
4503 local MDSFREE2=$(do_facet $mymds \
4504 lctl get_param -n osd*.*MDT000$((num -1)).kbytesfree)
4505 local MDCFREE2=$(lctl get_param -n mdc.*MDT000$((num -1))-mdc-*.kbytesfree)
4506 if [ "$MDCFREE2" -lt "$((MDCFREE - 8))" ]; then
4507 if [ "$MDSFREE" != "$MDSFREE2" ]; then
4508 error "MDC before $MDCFREE != after $MDCFREE2"
4510 echo "MDC before $MDCFREE != after $MDCFREE2"
4511 echo "unable to confirm if MDS has large inodes"
4516 run_test 57b "default LOV EAs are stored inside large inodes ==="
4519 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4520 [ -z "$(which wiretest 2>/dev/null)" ] &&
4521 skip_env "could not find wiretest" && return
4524 run_test 58 "verify cross-platform wire constants =============="
4527 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4528 echo "touch 130 files"
4529 createmany -o $DIR/f59- 130
4531 unlinkmany $DIR/f59- 130
4533 # wait for commitment of removal
4534 wait_delete_completed
4536 run_test 59 "verify cancellation of llog records async ========="
4538 TEST60_HEAD="test_60 run $RANDOM"
4540 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4541 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
4542 [ ! -f run-llog.sh ] && skip_env "missing subtest run-llog.sh" && return
4543 log "$TEST60_HEAD - from kernel mode"
4544 do_facet mgs sh run-llog.sh
4546 run_test 60a "llog sanity tests run from kernel module =========="
4548 test_60b() { # bug 6411
4549 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4551 LLOG_COUNT=`dmesg | awk "/$TEST60_HEAD/{marker = 1; from_marker = 0;}
4563 [ $LLOG_COUNT -gt 50 ] && error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)"|| true
4565 run_test 60b "limit repeated messages from CERROR/CWARN ========"
4568 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4569 echo "create 5000 files"
4570 createmany -o $DIR/f60c- 5000
4571 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
4572 lctl set_param fail_loc=0x80000137
4573 unlinkmany $DIR/f60c- 5000
4574 lctl set_param fail_loc=0
4576 run_test 60c "unlink file when mds full"
4579 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4580 SAVEPRINTK=$(lctl get_param -n printk)
4582 # verify "lctl mark" is even working"
4583 MESSAGE="test message ID $RANDOM $$"
4584 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
4585 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
4587 lctl set_param printk=0 || error "set lnet.printk failed"
4588 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
4589 MESSAGE="new test message ID $RANDOM $$"
4590 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
4591 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
4592 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
4594 lctl set_param -n printk="$SAVEPRINTK"
4596 run_test 60d "test printk console message masking"
4599 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4601 dd if=/dev/zero of=$f bs=`page_size` count=1
4602 cancel_lru_locks osc
4603 $MULTIOP $f OSMWUc || error
4606 run_test 61 "mmap() writes don't make sync hang ================"
4608 # bug 2330 - insufficient obd_match error checking causes LBUG
4610 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4613 cancel_lru_locks osc
4614 lctl set_param fail_loc=0x405
4615 cat $f && error "cat succeeded, expect -EIO"
4616 lctl set_param fail_loc=0
4618 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
4619 # match every page all of the time.
4620 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
4622 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
4623 test_63a() { # was test_63
4624 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4625 MAX_DIRTY_MB=`lctl get_param -n osc.*.max_dirty_mb | head -n 1`
4626 lctl set_param -n osc.*.max_dirty_mb 0
4627 for i in `seq 10` ; do
4628 dd if=/dev/zero of=$DIR/f63 bs=8k &
4634 lctl set_param -n osc.*.max_dirty_mb $MAX_DIRTY_MB
4635 rm -f $DIR/f63 || true
4637 run_test 63a "Verify oig_wait interruption does not crash ======="
4639 # bug 2248 - async write errors didn't return to application on sync
4640 # bug 3677 - async write errors left page locked
4642 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4644 lctl set_param debug=-1
4646 # ensure we have a grant to do async writes
4647 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
4650 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
4651 lctl set_param fail_loc=0x80000406
4652 $MULTIOP $DIR/$tfile Owy && \
4653 error "sync didn't return ENOMEM"
4654 sync; sleep 2; sync # do a real sync this time to flush page
4655 lctl get_param -n llite.*.dump_page_cache | grep locked && \
4656 error "locked page left in cache after async error" || true
4659 run_test 63b "async write errors should be returned to fsync ==="
4662 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4664 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
4666 run_test 64a "verify filter grant calculations (in kernel) ====="
4669 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4670 [ ! -f oos.sh ] && skip_env "missing subtest oos.sh" && return
4673 run_test 64b "check out-of-space detection on client ==========="
4676 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
4678 run_test 64c "verify grant shrink ========================------"
4680 # bug 1414 - set/get directories' stripe info
4682 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4683 test_mkdir -p $DIR/$tdir
4685 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
4687 run_test 65a "directory with no stripe info ===================="
4690 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4691 test_mkdir -p $DIR/$tdir
4692 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
4695 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
4697 run_test 65b "directory setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1"
4700 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4701 if [ $OSTCOUNT -gt 1 ]; then
4702 test_mkdir -p $DIR/$tdir
4703 $SETSTRIPE -S $(($STRIPESIZE * 4)) -i 1 \
4704 -c $(($OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
4706 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
4709 run_test 65c "directory setstripe -S $((STRIPESIZE*4)) -i 1 -c $((OSTCOUNT-1))"
4712 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4713 test_mkdir -p $DIR/$tdir
4714 if [ $STRIPECOUNT -le 0 ]; then
4716 elif [ $STRIPECOUNT -gt 2000 ]; then
4717 #LOV_MAX_STRIPE_COUNT is 2000
4718 [ $OSTCOUNT -gt 2000 ] && sc=2000 || sc=$(($OSTCOUNT - 1))
4720 sc=$(($STRIPECOUNT - 1))
4722 $SETSTRIPE -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
4723 touch $DIR/$tdir/f4 $DIR/$tdir/f5
4724 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
4725 error "lverify failed"
4727 run_test 65d "directory setstripe -S $STRIPESIZE -c stripe_count"
4730 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4731 test_mkdir -p $DIR/$tdir
4733 $SETSTRIPE $DIR/$tdir || error "setstripe"
4734 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
4735 error "no stripe info failed"
4737 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
4739 run_test 65e "directory setstripe defaults ======================="
4742 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4743 test_mkdir -p $DIR/${tdir}f
4744 $RUNAS $SETSTRIPE $DIR/${tdir}f && error "setstripe succeeded" || true
4746 run_test 65f "dir setstripe permission (should return error) ==="
4749 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4750 test_mkdir -p $DIR/$tdir
4751 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
4753 $SETSTRIPE -d $DIR/$tdir || error "setstripe"
4754 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
4755 error "delete default stripe failed"
4757 run_test 65g "directory setstripe -d ==========================="
4760 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4761 test_mkdir -p $DIR/$tdir
4762 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
4764 test_mkdir -p $DIR/$tdir/dd1
4765 [ $($GETSTRIPE -c $DIR/$tdir) == $($GETSTRIPE -c $DIR/$tdir/dd1) ] ||
4766 error "stripe info inherit failed"
4768 run_test 65h "directory stripe info inherit ===================="
4770 test_65i() { # bug6367
4771 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4772 $SETSTRIPE -S 65536 -c -1 $MOUNT
4774 run_test 65i "set non-default striping on root directory (bug 6367)="
4776 test_65ia() { # bug12836
4777 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4778 $GETSTRIPE $MOUNT || error "getstripe $MOUNT failed"
4780 run_test 65ia "getstripe on -1 default directory striping"
4782 test_65ib() { # bug12836
4783 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4784 $GETSTRIPE -v $MOUNT || error "getstripe -v $MOUNT failed"
4786 run_test 65ib "getstripe -v on -1 default directory striping"
4788 test_65ic() { # bug12836
4789 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4790 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
4792 run_test 65ic "new find on -1 default directory striping"
4794 test_65j() { # bug6367
4795 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4797 # if we aren't already remounting for each test, do so for this test
4798 if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
4799 cleanup || error "failed to unmount"
4802 $SETSTRIPE -d $MOUNT || error "setstripe failed"
4804 run_test 65j "set default striping on root directory (bug 6367)="
4806 test_65k() { # bug11679
4807 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4808 [ "$OSTCOUNT" -lt 2 ] && skip_env "too few OSTs" && return
4809 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4811 echo "Check OST status: "
4812 local MDS_OSCS=`do_facet $SINGLEMDS lctl dl |
4813 awk '/[oO][sS][cC].*md[ts]/ { print $4 }'`
4815 for OSC in $MDS_OSCS; do
4816 echo $OSC "is activate"
4817 do_facet $SINGLEMDS lctl --device %$OSC activate
4821 for INACTIVE_OSC in $MDS_OSCS; do
4822 echo "Deactivate: " $INACTIVE_OSC
4823 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
4824 for STRIPE_OSC in $MDS_OSCS; do
4825 OST=`osc_to_ost $STRIPE_OSC`
4826 IDX=`do_facet $SINGLEMDS lctl get_param -n lov.*md*.target_obd |
4827 awk -F: /$OST/'{ print $1 }' | head -n 1`
4829 [ -f $DIR/$tdir/$IDX ] && continue
4830 echo "$SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX"
4831 $SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX
4833 [ $RC -ne 0 ] && error "setstripe should have succeeded"
4836 echo $INACTIVE_OSC "is Activate."
4837 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
4840 run_test 65k "validate manual striping works properly with deactivated OSCs"
4842 test_65l() { # bug 12836
4843 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4844 test_mkdir -p $DIR/$tdir/test_dir
4845 $SETSTRIPE -c -1 $DIR/$tdir/test_dir
4846 $LFS find -mtime -1 $DIR/$tdir >/dev/null
4848 run_test 65l "lfs find on -1 stripe dir ========================"
4850 # bug 2543 - update blocks count on client
4852 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4854 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
4855 sync; sync_all_data; sync; sync_all_data
4856 cancel_lru_locks osc
4857 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
4858 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
4860 run_test 66 "update inode blocks count on client ==============="
4865 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4867 if [ ! -z "$LLOOP" ]; then
4868 if swapon -s | grep -q $LLOOP; then
4869 swapoff $LLOOP || error "swapoff failed"
4872 $LCTL blockdev_detach $LLOOP || error "detach failed"
4876 if [ ! -z "$LLITELOOPLOAD" ]; then
4884 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
4888 swapon -s | awk '($1 == "'$1'") { print $4 }'
4891 # test case for lloop driver, basic function
4893 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4894 [ "$UID" != 0 ] && skip_env "must run as root" && return
4895 llite_lloop_enabled || \
4896 { skip_env "llite_lloop module disabled" && return; }
4898 trap cleanup_68 EXIT
4900 if ! module_loaded llite_lloop; then
4901 if load_module llite/llite_lloop; then
4904 skip_env "can't find module llite_lloop"
4909 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
4910 dd if=/dev/zero of=$DIR/f68a bs=4k count=1024
4911 $LCTL blockdev_attach $DIR/f68a $LLOOP || error "attach failed"
4913 directio rdwr $LLOOP 0 1024 4096 || error "direct write failed"
4914 directio rdwr $LLOOP 0 1025 4096 && error "direct write should fail"
4918 run_test 68a "lloop driver - basic test ========================"
4920 # excercise swapping to lustre by adding a high priority swapfile entry
4921 # and then consuming memory until it is used.
4922 test_68b() { # was test_68
4923 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4924 [ "$UID" != 0 ] && skip_env "must run as root" && return
4925 lctl get_param -n devices | grep -q obdfilter && \
4926 skip "local OST" && return
4928 grep -q llite_lloop /proc/modules
4929 [ $? -ne 0 ] && skip "can't find module llite_lloop" && return
4931 [ -z "`$LCTL list_nids | grep -v tcp`" ] && \
4932 skip "can't reliably test swap with TCP" && return
4934 MEMTOTAL=`meminfo MemTotal`
4935 NR_BLOCKS=$((MEMTOTAL>>8))
4936 [[ $NR_BLOCKS -le 2048 ]] && NR_BLOCKS=2048
4938 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
4939 dd if=/dev/zero of=$DIR/f68b bs=64k seek=$NR_BLOCKS count=1
4942 $LCTL blockdev_attach $DIR/f68b $LLOOP || error "attach failed"
4944 trap cleanup_68 EXIT
4946 swapon -p 32767 $LLOOP || error "swapon $LLOOP failed"
4948 echo "before: `swapon -s | grep $LLOOP`"
4949 $MEMHOG $MEMTOTAL || error "error allocating $MEMTOTAL kB"
4950 echo "after: `swapon -s | grep $LLOOP`"
4951 SWAPUSED=`swap_used $LLOOP`
4955 [ $SWAPUSED -eq 0 ] && echo "no swap used???" || true
4957 run_test 68b "support swapping to Lustre ========================"
4959 # bug5265, obdfilter oa2dentry return -ENOENT
4960 # #define OBD_FAIL_OST_ENOENT 0x217
4962 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4963 remote_ost_nodsh && skip "remote OST with nodsh" && return
4966 $SETSTRIPE -c 1 -i 0 $f
4968 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
4970 do_facet ost1 lctl set_param fail_loc=0x217
4971 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
4972 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
4974 do_facet ost1 lctl set_param fail_loc=0
4975 $DIRECTIO write $f 0 2 || error "write error"
4977 cancel_lru_locks osc
4978 $DIRECTIO read $f 0 1 || error "read error"
4980 do_facet ost1 lctl set_param fail_loc=0x217
4981 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
4983 do_facet ost1 lctl set_param fail_loc=0
4986 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
4989 test_mkdir -p $DIR/$tdir
4990 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
4992 run_test 71 "Running dbench on lustre (don't segment fault) ===="
4994 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
4995 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4996 check_kernel_version 43 || return 0
4997 [ "$RUNAS_ID" = "$UID" ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4999 # Check that testing environment is properly set up. Skip if not
5000 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS || {
5001 skip_env "User $RUNAS_ID does not exist - skipping"
5004 # We had better clear the $DIR to get enough space for dd
5009 $RUNAS dd if=/dev/zero of=$DIR/f72 bs=512 count=1 || error
5010 # See if we are still setuid/sgid
5011 test -u $DIR/f72 -o -g $DIR/f72 && error "S/gid is not dropped on write"
5012 # Now test that MDS is updated too
5013 cancel_lru_locks mdc
5014 test -u $DIR/f72 -o -g $DIR/f72 && error "S/gid is not dropped on MDS"
5017 run_test 72a "Test that remove suid works properly (bug5695) ===="
5019 test_72b() { # bug 24226 -- keep mode setting when size is not changing
5022 [ "$RUNAS_ID" = "$UID" ] && \
5023 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5024 [ "$RUNAS_ID" -eq 0 ] && \
5025 skip_env "RUNAS_ID = 0 -- skipping" && return
5027 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5028 # Check that testing environment is properly set up. Skip if not
5029 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS || {
5030 skip_env "User $RUNAS_ID does not exist - skipping"
5033 touch $DIR/${tfile}-f{g,u}
5034 test_mkdir $DIR/${tfile}-dg
5035 test_mkdir $DIR/${tfile}-du
5036 chmod 770 $DIR/${tfile}-{f,d}{g,u}
5037 chmod g+s $DIR/${tfile}-{f,d}g
5038 chmod u+s $DIR/${tfile}-{f,d}u
5039 for perm in 777 2777 4777; do
5040 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
5041 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
5042 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
5043 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
5047 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
5049 # bug 3462 - multiple simultaneous MDC requests
5051 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5052 test_mkdir $DIR/d73-1
5053 test_mkdir $DIR/d73-2
5054 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
5057 lctl set_param fail_loc=0x80000129
5058 $MULTIOP $DIR/d73-1/f73-2 Oc &
5060 lctl set_param fail_loc=0
5062 $MULTIOP $DIR/d73-2/f73-3 Oc &
5066 wait $pid1 || return 1
5070 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
5071 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
5072 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
5076 run_test 73 "multiple MDC requests (should not deadlock)"
5078 test_74a() { # bug 6149, 6184
5079 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5080 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
5082 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
5083 # will spin in a tight reconnection loop
5085 lctl set_param fail_loc=0x8000030e
5086 # get any lock that won't be difficult - lookup works.
5088 lctl set_param fail_loc=0
5092 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
5094 test_74b() { # bug 13310
5095 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5096 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
5098 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
5099 # will spin in a tight reconnection loop
5100 lctl set_param fail_loc=0x8000030e
5101 # get a "difficult" lock
5103 lctl set_param fail_loc=0
5107 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
5110 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5111 #define OBD_FAIL_LDLM_NEW_LOCK
5112 lctl set_param fail_loc=0x80000319
5113 touch $DIR/$tfile && error "Touch successful"
5116 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
5119 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
5122 get_inode_slab_tunables() {
5123 awk '/lustre_inode_cache/ {print $9," ",$10," ",$11; exit}' /proc/slabinfo
5126 set_inode_slab_tunables() {
5127 echo "lustre_inode_cache $1" > /proc/slabinfo
5130 test_76() { # Now for bug 20433, added originally in bug 1443
5131 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5132 local SLAB_SETTINGS=`get_inode_slab_tunables`
5133 local CPUS=`getconf _NPROCESSORS_ONLN`
5134 # we cannot set limit below 1 which means 1 inode in each
5135 # per-cpu cache is still allowed
5136 set_inode_slab_tunables "1 1 0"
5137 cancel_lru_locks osc
5138 BEFORE_INODES=`num_inodes`
5139 echo "before inodes: $BEFORE_INODES"
5141 [ "$SLOW" = "no" ] && COUNT=100
5142 for i in `seq $COUNT`; do
5146 cancel_lru_locks osc
5147 AFTER_INODES=`num_inodes`
5148 echo "after inodes: $AFTER_INODES"
5150 while [ $((AFTER_INODES-1*CPUS)) -gt $BEFORE_INODES ]; do
5152 AFTER_INODES=`num_inodes`
5154 echo "wait $wait seconds inodes: $AFTER_INODES"
5155 if [ $wait -gt 30 ]; then
5156 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
5159 set_inode_slab_tunables "$SLAB_SETTINGS"
5161 run_test 76 "confirm clients recycle inodes properly ===="
5167 # Note: in sptlrpc modes which enable its own bulk checksum, the
5168 # original crc32_le bulk checksum will be automatically disabled,
5169 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
5170 # will be checked by sptlrpc code against sptlrpc bulk checksum.
5171 # In this case set_checksums() will not be no-op, because sptlrpc
5172 # bulk checksum will be enabled all through the test.
5174 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
5175 lctl set_param -n osc.*.checksums $1
5179 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
5180 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
5181 CKSUM_TYPES=${CKSUM_TYPES:-"crc32 adler"}
5182 [ "$ORIG_CSUM_TYPE" = "crc32c" ] && CKSUM_TYPES="$CKSUM_TYPES crc32c"
5185 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
5186 log "set checksum type to $1"
5189 F77_TMP=$TMP/f77-temp
5192 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
5193 error "error writing to $F77_TMP"
5196 test_77a() { # bug 10889
5197 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5198 $GSS && skip "could not run with gss" && return
5199 [ ! -f $F77_TMP ] && setup_f77
5201 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
5205 run_test 77a "normal checksum read/write operation ============="
5207 test_77b() { # bug 10889
5208 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5209 $GSS && skip "could not run with gss" && return
5210 [ ! -f $F77_TMP ] && setup_f77
5211 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5212 lctl set_param fail_loc=0x80000409
5214 dd if=$F77_TMP of=$DIR/f77b bs=1M count=$F77SZ conv=sync || \
5215 error "dd error: $?"
5216 lctl set_param fail_loc=0
5219 run_test 77b "checksum error on client write ===================="
5221 test_77c() { # bug 10889
5222 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5223 $GSS && skip "could not run with gss" && return
5224 [ ! -f $DIR/f77b ] && skip "requires 77b - skipping" && return
5226 for algo in $CKSUM_TYPES; do
5227 cancel_lru_locks osc
5228 set_checksum_type $algo
5229 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
5230 lctl set_param fail_loc=0x80000408
5231 cmp $F77_TMP $DIR/f77b || error "file compare failed"
5232 lctl set_param fail_loc=0
5235 set_checksum_type $ORIG_CSUM_TYPE
5238 run_test 77c "checksum error on client read ==================="
5240 test_77d() { # bug 10889
5241 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5242 $GSS && skip "could not run with gss" && return
5243 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5244 lctl set_param fail_loc=0x80000409
5246 directio write $DIR/f77 0 $F77SZ $((1024 * 1024)) || \
5247 error "direct write: rc=$?"
5248 lctl set_param fail_loc=0
5251 run_test 77d "checksum error on OST direct write ==============="
5253 test_77e() { # bug 10889
5254 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5255 $GSS && skip "could not run with gss" && return
5256 [ ! -f $DIR/f77 ] && skip "requires 77d - skipping" && return
5257 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
5258 lctl set_param fail_loc=0x80000408
5260 cancel_lru_locks osc
5261 directio read $DIR/f77 0 $F77SZ $((1024 * 1024)) || \
5262 error "direct read: rc=$?"
5263 lctl set_param fail_loc=0
5266 run_test 77e "checksum error on OST direct read ================"
5268 test_77f() { # bug 10889
5269 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5270 $GSS && skip "could not run with gss" && return
5272 for algo in $CKSUM_TYPES; do
5273 cancel_lru_locks osc
5274 set_checksum_type $algo
5275 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5276 lctl set_param fail_loc=0x409
5277 directio write $DIR/f77 0 $F77SZ $((1024 * 1024)) && \
5278 error "direct write succeeded"
5279 lctl set_param fail_loc=0
5281 set_checksum_type $ORIG_CSUM_TYPE
5284 run_test 77f "repeat checksum error on write (expect error) ===="
5286 test_77g() { # bug 10889
5287 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5288 $GSS && skip "could not run with gss" && return
5289 remote_ost_nodsh && skip "remote OST with nodsh" && return
5291 [ ! -f $F77_TMP ] && setup_f77
5293 $SETSTRIPE -c 1 -i 0 $DIR/f77g
5294 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
5295 do_facet ost1 lctl set_param fail_loc=0x8000021a
5297 dd if=$F77_TMP of=$DIR/f77g bs=1M count=$F77SZ || \
5298 error "write error: rc=$?"
5299 do_facet ost1 lctl set_param fail_loc=0
5302 run_test 77g "checksum error on OST write ======================"
5304 test_77h() { # bug 10889
5305 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5306 $GSS && skip "could not run with gss" && return
5307 remote_ost_nodsh && skip "remote OST with nodsh" && return
5309 [ ! -f $DIR/f77g ] && skip "requires 77g - skipping" && return
5310 cancel_lru_locks osc
5311 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
5312 do_facet ost1 lctl set_param fail_loc=0x8000021b
5314 cmp $F77_TMP $DIR/f77g || error "file compare failed"
5315 do_facet ost1 lctl set_param fail_loc=0
5318 run_test 77h "checksum error on OST read ======================="
5320 test_77i() { # bug 13805
5321 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5322 $GSS && skip "could not run with gss" && return
5323 #define OBD_FAIL_OSC_CONNECT_CKSUM 0x40b
5324 lctl set_param fail_loc=0x40b
5325 remount_client $MOUNT
5326 lctl set_param fail_loc=0
5327 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
5328 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
5329 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
5330 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
5332 remount_client $MOUNT
5334 run_test 77i "client not supporting OSD_CONNECT_CKSUM =========="
5336 test_77j() { # bug 13805
5337 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5338 $GSS && skip "could not run with gss" && return
5339 #define OBD_FAIL_OSC_CKSUM_ADLER_ONLY 0x40c
5340 lctl set_param fail_loc=0x40c
5341 remount_client $MOUNT
5342 lctl set_param fail_loc=0
5343 sleep 2 # wait async osc connect to finish
5344 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
5345 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
5346 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
5347 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
5349 remount_client $MOUNT
5351 run_test 77j "client only supporting ADLER32 ===================="
5353 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
5357 test_78() { # bug 10901
5358 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5359 remote_ost || { skip_env "local OST" && return; }
5362 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
5363 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
5364 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
5365 echo "MemTotal: $MEMTOTAL"
5366 # reserve 256MB of memory for the kernel and other running processes,
5367 # and then take 1/2 of the remaining memory for the read/write buffers.
5368 if [ $MEMTOTAL -gt 512 ] ;then
5369 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
5371 # for those poor memory-starved high-end clusters...
5372 MEMTOTAL=$((MEMTOTAL / 2))
5374 echo "Mem to use for directio: $MEMTOTAL"
5375 [ $F78SIZE -gt $MEMTOTAL ] && F78SIZE=$MEMTOTAL
5376 [ $F78SIZE -gt 512 ] && F78SIZE=512
5377 [ $F78SIZE -gt $((MAXFREE / 1024)) ] && F78SIZE=$((MAXFREE / 1024))
5378 SMALLESTOST=`lfs df $DIR |grep OST | awk '{print $4}' |sort -n |head -1`
5379 echo "Smallest OST: $SMALLESTOST"
5380 [ $SMALLESTOST -lt 10240 ] && \
5381 skip "too small OSTSIZE, useless to run large O_DIRECT test" && return 0
5383 [ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ] && \
5384 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
5386 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
5387 echo "File size: $F78SIZE"
5388 $SETSTRIPE -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
5389 for i in `seq 1 $NSEQ`
5391 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
5392 echo directIO rdwr round $i of $NSEQ
5393 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
5398 run_test 78 "handle large O_DIRECT writes correctly ============"
5400 test_79() { # bug 12743
5401 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5402 wait_delete_completed
5404 BKTOTAL=$(calc_osc_kbytes kbytestotal)
5405 BKFREE=$(calc_osc_kbytes kbytesfree)
5406 BKAVAIL=$(calc_osc_kbytes kbytesavail)
5408 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
5409 DFTOTAL=`echo $STRING | cut -d, -f1`
5410 DFUSED=`echo $STRING | cut -d, -f2`
5411 DFAVAIL=`echo $STRING | cut -d, -f3`
5412 DFFREE=$(($DFTOTAL - $DFUSED))
5414 ALLOWANCE=$((64 * $OSTCOUNT))
5416 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
5417 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
5418 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
5420 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
5421 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
5422 error "df free($DFFREE) mismatch OST free($BKFREE)"
5424 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
5425 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
5426 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
5429 run_test 79 "df report consistency check ======================="
5431 test_80() { # bug 10718
5432 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5433 # relax strong synchronous semantics for slow backends like ZFS
5434 local soc="obdfilter.*.sync_on_lock_cancel"
5435 local soc_old=$(do_facet ost1 lctl get_param -n $soc | head -n1)
5437 if [ "$soc_old" != "never" -a "$(facet_fstype ost1)" != "ldiskfs" ]; then
5438 hosts=$(for host in $(seq -f "ost%g" 1 $OSTCOUNT); do
5439 facet_active_host $host; done | sort -u)
5440 do_nodes $hosts lctl set_param $soc=never
5443 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
5445 local BEFORE=`date +%s`
5446 cancel_lru_locks osc
5447 local AFTER=`date +%s`
5448 local DIFF=$((AFTER-BEFORE))
5449 if [ $DIFF -gt 1 ] ; then
5450 error "elapsed for 1M@1T = $DIFF"
5453 [ -n "$hosts" ] && do_nodes $hosts lctl set_param $soc=$soc_old
5457 run_test 80 "Page eviction is equally fast at high offsets too ===="
5459 test_81a() { # LU-456
5460 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5461 remote_ost_nodsh && skip "remote OST with nodsh" && return
5462 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
5463 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
5464 do_facet ost1 lctl set_param fail_loc=0x80000228
5466 # write should trigger a retry and success
5467 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
5468 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
5470 if [ $RC -ne 0 ] ; then
5471 error "write should success, but failed for $RC"
5474 run_test 81a "OST should retry write when get -ENOSPC ==============="
5476 test_81b() { # LU-456
5477 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5478 remote_ost_nodsh && skip "remote OST with nodsh" && return
5479 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
5480 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
5481 do_facet ost1 lctl set_param fail_loc=0x228
5483 # write should retry several times and return -ENOSPC finally
5484 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
5485 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
5488 if [ $RC -ne $ENOSPC ] ; then
5489 error "dd should fail for -ENOSPC, but succeed."
5492 run_test 81b "OST should return -ENOSPC when retry still fails ======="
5494 test_82() { # LU-1031
5495 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10
5499 multiop_bg_pause $DIR/$tfile OG${gid1}_g${gid1}c || return 1
5501 multiop_bg_pause $DIR/$tfile O_G${gid2}r10g${gid2}c || return 2
5503 kill -USR1 $MULTIPID2
5505 if [[ `ps h -o comm -p $MULTIPID2` == "" ]]; then
5506 error "First grouplock does not block second one"
5508 echo "Second grouplock blocks first one"
5510 kill -USR1 $MULTIPID1
5514 run_test 82 "Basic grouplock test ==============================="
5517 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && \
5519 test_mkdir -p $DIR/d99cvsroot
5520 chown $RUNAS_ID $DIR/d99cvsroot
5521 local oldPWD=$PWD # bug 13584, use $TMP as working dir
5524 $RUNAS cvs -d $DIR/d99cvsroot init || error
5527 run_test 99a "cvs init ========================================="
5530 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5531 [ ! -d $DIR/d99cvsroot ] && test_99a
5533 # some versions of cvs import exit(1) when asked to import links or
5534 # files they can't read. ignore those files.
5535 TOIGNORE=$(find . -type l -printf '-I %f\n' -o \
5536 ! -perm +4 -printf '-I %f\n')
5537 $RUNAS cvs -d $DIR/d99cvsroot import -m "nomesg" $TOIGNORE \
5538 d99reposname vtag rtag
5540 run_test 99b "cvs import ======================================="
5543 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5544 [ ! -d $DIR/d99cvsroot ] && test_99b
5546 test_mkdir -p $DIR/d99reposname
5547 chown $RUNAS_ID $DIR/d99reposname
5548 $RUNAS cvs -d $DIR/d99cvsroot co d99reposname
5550 run_test 99c "cvs checkout ====================================="
5553 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5554 [ ! -d $DIR/d99cvsroot ] && test_99c
5555 cd $DIR/d99reposname
5557 $RUNAS cvs add -m 'addmsg' foo99
5559 run_test 99d "cvs add =========================================="
5562 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5563 [ ! -d $DIR/d99cvsroot ] && test_99c
5564 cd $DIR/d99reposname
5567 run_test 99e "cvs update ======================================="
5570 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5571 [ ! -d $DIR/d99cvsroot ] && test_99d
5572 cd $DIR/d99reposname
5573 $RUNAS cvs commit -m 'nomsg' foo99
5574 rm -fr $DIR/d99cvsroot
5576 run_test 99f "cvs commit ======================================="
5579 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5580 [ "$NETTYPE" = tcp ] || \
5581 { skip "TCP secure port test, not useful for NETTYPE=$NETTYPE" && \
5584 remote_ost_nodsh && skip "remote OST with nodsh" && return
5585 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5587 { skip "useless for local single node setup" && return; }
5589 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
5590 [ "$PROT" != "tcp" ] && continue
5591 RPORT=$(echo $REMOTE | cut -d: -f2)
5592 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
5595 LPORT=`echo $LOCAL | cut -d: -f2`
5596 if [ $LPORT -ge 1024 ]; then
5597 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
5599 error_exit "local: $LPORT > 1024, remote: $RPORT"
5602 [ "$rc" = 0 ] || error_exit "privileged port not found" )
5604 run_test 100 "check local port using privileged port ==========="
5606 function get_named_value()
5615 echo $line | sed "s/^$tag[ ]*//"
5622 export CACHE_MAX=$($LCTL get_param -n llite.*.max_cached_mb |
5623 awk '/^max_cached_mb/ { print $2 }')
5626 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
5631 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5635 local cache_limit=32
5637 $LCTL set_param -n osc.*-osc*.rpc_stats 0
5638 trap cleanup_101a EXIT
5639 $LCTL set_param -n llite.*.read_ahead_stats 0
5640 $LCTL set_param -n llite.*.max_cached_mb $cache_limit
5643 # randomly read 10000 of 64K chunks from file 3x 32MB in size
5645 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
5646 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
5649 for s in `$LCTL get_param -n llite.*.read_ahead_stats | \
5650 get_named_value 'read but discarded' | cut -d" " -f1`; do
5651 discard=$(($discard + $s))
5655 if [ $(($discard * 10)) -gt $nreads ] ;then
5656 $LCTL get_param osc.*-osc*.rpc_stats
5657 $LCTL get_param llite.*.read_ahead_stats
5658 error "too many ($discard) discarded pages"
5660 rm -f $DIR/$tfile || true
5662 run_test 101a "check read-ahead for random reads ================"
5665 test_mkdir -p $DIR/$tdir
5667 STRIPE_COUNT=$OSTCOUNT
5670 local list=$(comma_list $(osts_nodes))
5671 set_osd_param $list '' read_cache_enable 0
5672 set_osd_param $list '' writethrough_cache_enable 0
5674 trap cleanup_test101bc EXIT
5675 # prepare the read-ahead file
5676 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
5678 dd if=/dev/zero of=$DIR/$tfile bs=1024k count=100 2> /dev/null
5681 cleanup_test101bc() {
5686 local list=$(comma_list $(osts_nodes))
5687 set_osd_param $list '' read_cache_enable 1
5688 set_osd_param $list '' writethrough_cache_enable 1
5692 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
5697 local STRIPE_SIZE=1048576
5698 local RA_INC=1048576
5699 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
5700 local FILE_LENGTH=$((64*100))
5701 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
5702 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
5703 DISCARD=`$LCTL get_param -n llite.*.read_ahead_stats | \
5704 get_named_value 'read but discarded' | \
5705 cut -d" " -f1 | calc_total`
5706 if [ $DISCARD -gt $discard_limit ]; then
5707 $LCTL get_param llite.*.read_ahead_stats
5708 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
5710 echo "Read-ahead success for size ${READ_SIZE}"
5715 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5716 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping stride IO stride-ahead test" && return
5717 local STRIPE_SIZE=1048576
5718 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
5719 local FILE_LENGTH=$((STRIPE_SIZE*100))
5720 local ITERATION=$((FILE_LENGTH/STRIDE_SIZE))
5721 # prepare the read-ahead file
5723 cancel_lru_locks osc
5724 for BIDX in 2 4 8 16 32 64 128 256
5726 local BSIZE=$((BIDX*4096))
5727 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
5728 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
5729 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
5730 $LCTL set_param -n llite.*.read_ahead_stats 0
5731 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
5732 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
5733 cancel_lru_locks osc
5739 run_test 101b "check stride-io mode read-ahead ================="
5742 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5743 local STRIPE_SIZE=1048576
5744 local FILE_LENGTH=$((STRIPE_SIZE*100))
5750 cancel_lru_locks osc
5751 $LCTL set_param osc.*.rpc_stats 0
5752 $READS -f $DIR/$tfile -s$FILE_LENGTH -b65536 -n$nreads -t 180
5753 for osc in $($LCTL get_param -N osc.*); do
5754 if [ "$osc" == "osc.num_refs" ]; then
5758 local lines=$($LCTL get_param -n ${osc}.rpc_stats | wc | awk '{print $1}')
5759 if [ $lines -le 20 ]; then
5763 local rpc4k=$($LCTL get_param -n ${osc}.rpc_stats |
5764 awk '$1 == "1:" { print $2; exit; }')
5765 local rpc8k=$($LCTL get_param -n ${osc}.rpc_stats |
5766 awk '$1 == "2:" { print $2; exit; }')
5767 local rpc16k=$($LCTL get_param -n ${osc}.rpc_stats |
5768 awk '$1 == "4:" { print $2; exit; }')
5769 local rpc32k=$($LCTL get_param -n ${osc}.rpc_stats |
5770 awk '$1 == "8:" { print $2; exit; }')
5772 [ $rpc4k != 0 ] && error "Small 4k read IO ${rpc4k}!"
5773 [ $rpc8k != 0 ] && error "Small 8k read IO ${rpc8k}!"
5774 [ $rpc16k != 0 ] && error "Small 16k read IO ${rpc16k}!"
5775 [ $rpc32k != 0 ] && error "Small 32k read IO ${rpc32k}!"
5776 echo "${osc} rpc check passed!"
5781 run_test 101c "check stripe_size aligned read-ahead ================="
5784 $LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1
5785 $LCTL set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
5789 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5790 local file=$DIR/$tfile
5791 local size=${FILESIZE_101c:-500}
5792 local ra_MB=${READAHEAD_MB:-40}
5794 local space=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
5795 [ $space -gt $((size * 1024)) ] ||
5796 { skip "Need free space ${size}M, have $space" && return; }
5798 echo Creating ${size}M test file $file
5799 dd if=/dev/zero of=$file bs=1M count=$size || error "dd failed"
5800 echo Cancel LRU locks on lustre client to flush the client cache
5801 cancel_lru_locks osc
5803 echo Disable read-ahead
5804 local old_READAHEAD=$(set_read_ahead 0)
5806 echo Reading the test file $file with read-ahead disabled
5807 time_ra_OFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$size")
5809 echo Cancel LRU locks on lustre client to flush the client cache
5810 cancel_lru_locks osc
5811 echo Enable read-ahead with ${ra_MB}MB
5812 set_read_ahead $ra_MB
5814 echo Reading the test file $file with read-ahead enabled
5815 time_ra_ON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$size")
5817 echo read-ahead disabled time read $time_ra_OFF
5818 echo read-ahead enabled time read $time_ra_ON
5820 set_read_ahead $old_READAHEAD
5822 wait_delete_completed
5824 [ $time_ra_ON -lt $time_ra_OFF ] ||
5825 error "read-ahead enabled time read (${time_ra_ON}s) is more than
5826 read-ahead disabled time read (${time_ra_OFF}s) filesize ${size}M"
5828 run_test 101d "file read with and without read-ahead enabled ================="
5831 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5832 local file=$DIR/$tfile
5837 local space=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
5838 local need_space=$((count * size))
5839 [ $space -gt $need_space ] ||
5840 { skip_env "Need free space $need_space, have $space" && return; }
5842 echo Creating $count ${size}K test files
5843 for ((i = 0; i < $count; i++)); do
5844 dd if=/dev/zero of=${file}_${i} bs=$blksize count=$size 2>/dev/null
5847 echo Cancel LRU locks on lustre client to flush the client cache
5848 cancel_lru_locks osc
5850 echo Reset readahead stats
5851 $LCTL set_param -n llite.*.read_ahead_stats 0
5853 for ((i = 0; i < $count; i++)); do
5854 dd if=${file}_${i} of=/dev/null bs=$blksize count=$size 2>/dev/null
5857 local miss=$($LCTL get_param -n llite.*.read_ahead_stats | \
5858 get_named_value 'misses' | cut -d" " -f1 | calc_total)
5860 for ((i = 0; i < $count; i++)); do
5861 rm -rf ${file}_${i} 2>/dev/null
5864 #10000 means 20% reads are missing in readahead
5865 [ $miss -lt 10000 ] || error "misses too much for small reads"
5867 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
5869 cleanup_test101f() {
5871 $LCTL set_param -n llite.*.max_read_ahead_whole_mb $MAX_WHOLE_MB
5872 rm -rf $DIR/$tfile 2>/dev/null
5876 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5877 local file=$DIR/$tfile
5880 MAX_WHOLE_MB=$($LCTL get_param -n llite.*.max_read_ahead_whole_mb)
5881 $LCTL set_param -n llite.*.max_read_ahead_whole_mb 2
5882 dd if=/dev/zero of=${file} bs=2097152 count=1 2>/dev/null
5883 trap cleanup_test101f EXIT
5885 echo Cancel LRU locks on lustre client to flush the client cache
5886 cancel_lru_locks osc
5888 echo Reset readahead stats
5889 $LCTL set_param -n llite.*.read_ahead_stats 0
5890 # Random read in a 2M file, because max_read_ahead_whole_mb = 2M,
5891 # readahead should read in 2M file on second read, so only miss
5893 echo Random 4K reads on 2M file for 1000 times
5894 $READS -f $file -s 2097152 -b 4096 -n $nreads
5896 echo checking missing pages
5897 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
5898 get_named_value 'misses' | cut -d" " -f1 | calc_total)
5900 [ $miss -lt 3 ] || error "misses too much pages!"
5903 run_test 101f "check read-ahead for max_read_ahead_whole_mb"
5906 test_mkdir -p $DIR/$tdir
5907 chown $RUNAS_ID $DIR/$tdir
5910 STRIPE_COUNT=$OSTCOUNT
5911 [ $OSTCOUNT -gt 4 ] && STRIPE_COUNT=4
5913 trap cleanup_test102 EXIT
5915 $1 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
5917 for num in 1 2 3 4; do
5918 for count in $(seq 1 $STRIPE_COUNT); do
5919 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
5920 local size=`expr $STRIPE_SIZE \* $num`
5921 local file=file"$num-$idx-$count"
5922 $1 $SETSTRIPE -S $size -i $idx -c $count $file
5928 $1 $TAR cf $TMP/f102.tar $tdir --xattrs
5934 rm -rf $DIR/d0.sanity/d102
5938 local testfile=$DIR/xattr_testfile
5942 [ "$UID" != 0 ] && skip_env "must run as root" && return
5943 [ -z "`lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr`" ] &&
5944 skip_env "must have user_xattr" && return
5946 [ -z "$(which setfattr 2>/dev/null)" ] &&
5947 skip_env "could not find setfattr" && return
5949 echo "set/get xattr..."
5950 setfattr -n trusted.name1 -v value1 $testfile || error
5951 getfattr -n trusted.name1 $testfile 2> /dev/null |
5952 grep "trusted.name1=.value1" ||
5953 error "$testfile missing trusted.name1=value1"
5955 setfattr -n user.author1 -v author1 $testfile || error
5956 getfattr -n user.author1 $testfile 2> /dev/null |
5957 grep "user.author1=.author1" ||
5958 error "$testfile missing trusted.author1=author1"
5961 setfattr -n trusted.name2 -v value2 $testfile ||
5962 error "$testfile unable to set trusted.name2"
5963 setfattr -n trusted.name3 -v value3 $testfile ||
5964 error "$testfile unable to set trusted.name3"
5965 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
5966 grep "trusted.name" | wc -l) -eq 3 ] ||
5967 error "$testfile missing 3 trusted.name xattrs"
5969 setfattr -n user.author2 -v author2 $testfile ||
5970 error "$testfile unable to set user.author2"
5971 setfattr -n user.author3 -v author3 $testfile ||
5972 error "$testfile unable to set user.author3"
5973 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
5974 grep "user.author" | wc -l) -eq 3 ] ||
5975 error "$testfile missing 3 user.author xattrs"
5977 echo "remove xattr..."
5978 setfattr -x trusted.name1 $testfile ||
5979 error "$testfile error deleting trusted.name1"
5980 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
5981 error "$testfile did not delete trusted.name1 xattr"
5983 setfattr -x user.author1 $testfile ||
5984 error "$testfile error deleting user.author1"
5985 getfattr -d -m user $testfile 2> /dev/null | grep "user.author1" &&
5986 error "$testfile did not delete trusted.name1 xattr"
5988 # b10667: setting lustre special xattr be silently discarded
5989 echo "set lustre special xattr ..."
5990 setfattr -n "trusted.lov" -v "invalid value" $testfile ||
5991 error "$testfile allowed setting trusted.lov"
5993 run_test 102a "user xattr test =================================="
5996 # b10930: get/set/list trusted.lov xattr
5997 echo "get/set/list trusted.lov xattr ..."
5998 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
5999 local testfile=$DIR/$tfile
6000 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
6001 error "setstripe failed"
6002 local STRIPECOUNT=$($GETSTRIPE -c $testfile) ||
6003 error "getstripe failed"
6004 getfattr -d -m "^trusted" $testfile 2> /dev/null | \
6005 grep "trusted.lov" || error "can't get trusted.lov from $testfile"
6007 local testfile2=${testfile}2
6008 local value=`getfattr -n trusted.lov $testfile 2> /dev/null | \
6009 grep "trusted.lov" |sed -e 's/[^=]\+=//'`
6012 setfattr -n trusted.lov -v $value $testfile2
6013 local stripe_size=$($GETSTRIPE -S $testfile2)
6014 local stripe_count=$($GETSTRIPE -c $testfile2)
6015 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
6016 [ $stripe_count -eq $STRIPECOUNT ] ||
6017 error "stripe count $stripe_count != $STRIPECOUNT"
6020 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
6023 # b10930: get/set/list lustre.lov xattr
6024 echo "get/set/list lustre.lov xattr ..."
6025 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
6026 test_mkdir -p $DIR/$tdir
6027 chown $RUNAS_ID $DIR/$tdir
6028 local testfile=$DIR/$tdir/$tfile
6029 $RUNAS $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
6030 error "setstripe failed"
6031 local STRIPECOUNT=$($RUNAS $GETSTRIPE -c $testfile) ||
6032 error "getstripe failed"
6033 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
6034 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
6036 local testfile2=${testfile}2
6037 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
6038 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
6040 $RUNAS $MCREATE $testfile2
6041 $RUNAS setfattr -n lustre.lov -v $value $testfile2
6042 local stripe_size=$($RUNAS $GETSTRIPE -S $testfile2)
6043 local stripe_count=$($RUNAS $GETSTRIPE -c $testfile2)
6044 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
6045 [ $stripe_count -eq $STRIPECOUNT ] ||
6046 error "stripe count $stripe_count != $STRIPECOUNT"
6048 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
6050 compare_stripe_info1() {
6051 local stripe_index_all_zero=true
6053 for num in 1 2 3 4; do
6054 for count in $(seq 1 $STRIPE_COUNT); do
6055 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
6056 local size=$((STRIPE_SIZE * num))
6057 local file=file"$num-$offset-$count"
6058 stripe_size=$(lfs getstripe -S $PWD/$file)
6059 [ $stripe_size -ne $size ] &&
6060 error "$file: size $stripe_size != $size"
6061 stripe_count=$(lfs getstripe -c $PWD/$file)
6062 # allow fewer stripes to be created, ORI-601
6063 [ $stripe_count -lt $(((3 * count + 3) / 4)) ]&&
6064 error "$file: count $stripe_count != $count"
6065 stripe_index=$(lfs getstripe -i $PWD/$file)
6066 [ $stripe_index -ne 0 ] &&
6067 stripe_index_all_zero=false
6071 $stripe_index_all_zero &&
6072 error "all files are being extracted starting from OST index 0"
6077 [ -n "$(which tar 2>/dev/null)" ] &&
6078 strings $(which tar) | grep -q "lustre" && echo tar
6082 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6083 # b10930: tar test for trusted.lov xattr
6084 TAR=$(find_lustre_tar)
6085 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6086 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
6088 test_mkdir -p $DIR/d102d
6089 $TAR xf $TMP/f102.tar -C $DIR/d102d --xattrs
6091 compare_stripe_info1
6093 run_test 102d "tar restore stripe info from tarfile,not keep osts ==========="
6096 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6097 # b10930: tar test for trusted.lov xattr
6098 TAR=$(find_lustre_tar)
6099 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6100 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
6102 test_mkdir -p $DIR/d102f
6104 $TAR cf - --xattrs $tdir | $TAR xf - --xattrs -C $DIR/d102f
6106 compare_stripe_info1
6108 run_test 102f "tar copy files, not keep osts ==========="
6111 local xsize=${1:-1024} # in bytes
6112 local file=$DIR/$tfile
6114 [ -z $(lctl get_param -n mdc.*.connect_flags | grep xattr) ] &&
6115 skip "must have user_xattr" && return 0
6116 [ -z "$(which setfattr 2>/dev/null)" ] &&
6117 skip_env "could not find setfattr" && return 0
6118 [ -z "$(which getfattr 2>/dev/null)" ] &&
6119 skip_env "could not find getfattr" && return 0
6123 local value="$(generate_string $xsize)"
6125 local xbig=trusted.big
6126 log "save $xbig on $file"
6127 setfattr -n $xbig -v $value $file ||
6128 error "saving $xbig on $file failed"
6130 local orig=$(get_xattr_value $xbig $file)
6131 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
6133 local xsml=trusted.sml
6134 log "save $xsml on $file"
6135 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
6137 local new=$(get_xattr_value $xbig $file)
6138 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
6140 log "grow $xsml on $file"
6141 setfattr -n $xsml -v "$value" $file ||
6142 error "growing $xsml on $file failed"
6144 new=$(get_xattr_value $xbig $file)
6145 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
6146 log "$xbig still valid after growing $xsml"
6151 test_102h() { # bug 15777
6154 run_test 102h "grow xattr from inside inode to external block"
6157 large_xattr_enabled || { skip "large_xattr disabled" && return; }
6158 grow_xattr $(max_xattr_size)
6160 run_test 102ha "grow xattr from inside inode to external inode"
6162 test_102i() { # bug 17038
6164 ln -s $DIR/$tfile $DIR/${tfile}link
6165 getfattr -n trusted.lov $DIR/$tfile || error "lgetxattr on $DIR/$tfile failed"
6166 getfattr -h -n trusted.lov $DIR/${tfile}link 2>&1 | grep -i "no such attr" || error "error for lgetxattr on $DIR/${tfile}link is not ENODATA"
6167 rm -f $DIR/$tfile $DIR/${tfile}link
6169 run_test 102i "lgetxattr test on symbolic link ============"
6172 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6173 TAR=$(find_lustre_tar)
6174 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6175 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
6176 setup_test102 "$RUNAS"
6177 test_mkdir -p $DIR/d102j
6178 chown $RUNAS_ID $DIR/d102j
6179 $RUNAS $TAR xf $TMP/f102.tar -C $DIR/d102j --xattrs
6181 compare_stripe_info1 "$RUNAS"
6183 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
6187 # b22187 just check that does not crash for regular file.
6188 setfattr -n trusted.lov $DIR/$tfile
6189 # b22187 'setfattr -n trusted.lov' should work as remove LOV EA for directories
6190 local test_kdir=$DIR/d102k
6191 test_mkdir $test_kdir
6192 local default_size=`$GETSTRIPE -S $test_kdir`
6193 local default_count=`$GETSTRIPE -c $test_kdir`
6194 local default_offset=`$GETSTRIPE -i $test_kdir`
6195 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $test_kdir ||
6196 error 'dir setstripe failed'
6197 setfattr -n trusted.lov $test_kdir
6198 local stripe_size=`$GETSTRIPE -S $test_kdir`
6199 local stripe_count=`$GETSTRIPE -c $test_kdir`
6200 local stripe_offset=`$GETSTRIPE -i $test_kdir`
6201 [ $stripe_size -eq $default_size ] ||
6202 error "stripe size $stripe_size != $default_size"
6203 [ $stripe_count -eq $default_count ] ||
6204 error "stripe count $stripe_count != $default_count"
6205 [ $stripe_offset -eq $default_offset ] ||
6206 error "stripe offset $stripe_offset != $default_offset"
6207 rm -rf $DIR/$tfile $test_kdir
6209 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
6212 # LU-532 trusted. xattr is invisible to non-root
6213 local testfile=$DIR/$tfile
6217 echo "listxattr as user..."
6218 chown $RUNAS_ID $testfile
6219 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
6220 grep -q "trusted" &&
6221 error "$testfile trusted xattrs are user visible"
6225 run_test 102l "listxattr filter test =================================="
6231 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
6236 [ "$UID" != 0 ] && skip_env "must run as root" && return
6237 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
6238 [ -z "$(which setfacl 2>/dev/null)" ] && skip_env "could not find setfacl" && return
6239 $GSS && skip "could not run under gss" && return
6241 declare -a identity_old
6243 for num in $(seq $MDSCOUNT); do
6244 switch_identity $num true || identity_old[$num]=$?
6251 echo "performing cp ..."
6252 run_acl_subtest cp || error
6253 echo "performing getfacl-noacl..."
6254 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
6255 echo "performing misc..."
6256 run_acl_subtest misc || error "misc test failed"
6257 echo "performing permissions..."
6258 run_acl_subtest permissions || error "permissions failed"
6259 echo "performing setfacl..."
6260 run_acl_subtest setfacl || error "setfacl test failed"
6262 # inheritance test got from HP
6263 echo "performing inheritance..."
6264 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
6265 chmod +x make-tree || error "chmod +x failed"
6266 run_acl_subtest inheritance || error "inheritance test failed"
6269 echo "LU-974 ignore umask when acl is enabled..."
6270 run_acl_subtest 974 || error "LU-974 test failed"
6271 if [ $MDSCOUNT -ge 2 ]; then
6272 run_acl_subtest 974_remote ||
6273 error "LU-974 test failed under remote dir"
6276 echo "LU-2561 newly created file is same size as directory..."
6277 run_acl_subtest 2561 || error "LU-2561 test failed"
6282 for num in $(seq $MDSCOUNT); do
6283 if [ "${identity_old[$num]}" = 1 ]; then
6284 switch_identity $num false || identity_old[$num]=$?
6288 run_test 103 "acl test ========================================="
6291 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6293 lfs df || error "lfs df failed"
6294 lfs df -ih || error "lfs df -ih failed"
6295 lfs df -h $DIR || error "lfs df -h $DIR failed"
6296 lfs df -i $DIR || error "lfs df -i $DIR failed"
6297 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
6298 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
6300 OSC=`lctl dl |grep OST0000-osc-[^M] |awk '{print $4}'`
6301 lctl --device %$OSC deactivate
6302 lfs df || error "lfs df with deactivated OSC failed"
6303 lctl --device %$OSC activate
6304 # wait the osc back to normal
6305 wait_osc_import_state client ost FULL
6307 lfs df || error "lfs df with reactivated OSC failed"
6310 run_test 104a "lfs df [-ih] [path] test ========================="
6313 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6314 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
6316 denied_cnt=$((`$RUNAS $LFS check servers 2>&1 | grep "Permission denied" | wc -l`))
6317 if [ $denied_cnt -ne 0 ];
6319 error "lfs check servers test failed"
6322 run_test 104b "$RUNAS lfs check servers test ===================="
6325 # doesn't work on 2.4 kernels
6327 if [ -n "`mount | grep \"$MOUNT.*flock\" | grep -v noflock`" ]; then
6328 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
6330 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
6334 run_test 105a "flock when mounted without -o flock test ========"
6338 if [ -n "`mount | grep \"$MOUNT.*flock\" | grep -v noflock`" ]; then
6339 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
6341 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
6345 run_test 105b "fcntl when mounted without -o flock test ========"
6349 if [ -n "`mount | grep \"$MOUNT.*flock\" | grep -v noflock`" ]; then
6350 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
6352 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
6356 run_test 105c "lockf when mounted without -o flock test ========"
6358 test_105d() { # bug 15924
6359 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6360 test_mkdir -p $DIR/$tdir
6361 [ -z "`mount | grep \"$MOUNT.*flock\" | grep -v noflock`" ] && \
6362 skip "mount w/o flock enabled" && return
6363 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
6364 $LCTL set_param fail_loc=0x80000315
6365 flocks_test 2 $DIR/$tdir
6367 run_test 105d "flock race (should not freeze) ========"
6369 test_105e() { # bug 22660 && 22040
6370 [ -z "`mount | grep \"$MOUNT.*flock\" | grep -v noflock`" ] && \
6371 skip "mount w/o flock enabled" && return
6373 flocks_test 3 $DIR/$tfile
6375 run_test 105e "Two conflicting flocks from same process ======="
6377 test_106() { #bug 10921
6378 test_mkdir -p $DIR/$tdir
6379 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
6380 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
6382 run_test 106 "attempt exec of dir followed by chown of that dir"
6385 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6392 local save_pattern=$(sysctl -n kernel.core_pattern)
6393 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
6394 sysctl -w kernel.core_pattern=$file
6395 sysctl -w kernel.core_uses_pid=0
6403 kill -s 11 $SLEEPPID
6405 if [ -e $file ]; then
6406 size=`stat -c%s $file`
6407 [ $size -eq 0 ] && error "Fail to create core file $file"
6409 error "Fail to create core file $file"
6412 sysctl -w kernel.core_pattern=$save_pattern
6413 sysctl -w kernel.core_uses_pid=$save_uses_pid
6416 run_test 107 "Coredump on SIG"
6419 test_mkdir -p $DIR/$tdir
6420 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255) ||
6421 error "mkdir with 255 char failed"
6422 test_mkdir $DIR/$tdir/$(str_repeat 'b' 256) &&
6423 error "mkdir with 256 char should fail, but did not"
6424 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
6425 error "create with 255 char failed"
6426 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
6427 error "create with 256 char should fail, but did not"
6432 run_test 110 "filename length checking"
6435 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6436 OSTIO_pre=$(ps -e|grep ll_ost_io|awk '{print $4}'|sort -n|tail -1|\
6438 [ -z "$OSTIO_pre" ] && skip "no OSS threads" && \
6440 echo "Starting with $OSTIO_pre threads"
6443 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
6444 [ $NUMFREE -lt $NUMTEST ] && NUMTEST=$(($NUMFREE - 1000))
6445 echo "$NUMTEST creates/unlinks"
6446 test_mkdir -p $DIR/$tdir
6447 createmany -o $DIR/$tdir/$tfile $NUMTEST
6448 unlinkmany $DIR/$tdir/$tfile $NUMTEST
6450 OSTIO_post=$(ps -e|grep ll_ost_io|awk '{print $4}'|sort -n|tail -1|\
6453 # don't return an error
6454 [ $OSTIO_post == $OSTIO_pre ] && echo \
6455 "WARNING: No new ll_ost_io threads were created ($OSTIO_pre)" &&
6456 echo "This may be fine, depending on what ran before this test" &&
6457 echo "and how fast this system is." && return
6459 echo "Started with $OSTIO_pre threads, ended with $OSTIO_post"
6461 run_test 115 "verify dynamic thread creation===================="
6464 wait_delete_completed
6465 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
6466 echo OST kbytes available: ${AVAIL[@]}
6467 MAXI=0; MAXV=${AVAIL[0]}
6468 MINI=0; MINV=${AVAIL[0]}
6469 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
6470 #echo OST $i: ${AVAIL[i]}kb
6471 if [ ${AVAIL[i]} -gt $MAXV ]; then
6472 MAXV=${AVAIL[i]}; MAXI=$i
6474 if [ ${AVAIL[i]} -lt $MINV ]; then
6475 MINV=${AVAIL[i]}; MINI=$i
6478 echo Min free space: OST $MINI: $MINV
6479 echo Max free space: OST $MAXI: $MAXV
6482 test_116a() { # was previously test_116()
6483 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6484 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs" && return
6486 echo -n "Free space priority "
6487 lctl get_param -n lov.*-clilov-*.qos_prio_free
6490 [ $MINV -gt 960000 ] && skip "too much free space in OST$MINI, skip" &&\
6493 # generate uneven OSTs
6494 test_mkdir -p $DIR/$tdir/OST${MINI}
6497 echo "Filling 25% remaining space in OST${MINI} with ${FILL}Kb"
6498 $SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI}||error "setstripe failed"
6500 while [ $FILL -gt 0 ]; do
6502 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i bs=2M count=1 2>/dev/null
6503 FILL=$(($FILL - 2048))
6511 DIFF=$(($MAXV - $MINV))
6512 DIFF2=$(($DIFF * 100 / $MINV))
6513 echo -n "diff=${DIFF}=${DIFF2}% must be > 20% for QOS mode..."
6514 if [ $DIFF2 -gt 20 ]; then
6517 echo "failed - QOS mode won't be used"
6518 error_ignore "QOS imbalance criteria not met"
6522 MINI1=$MINI; MINV1=$MINV
6523 MAXI1=$MAXI; MAXV1=$MAXV
6525 # now fill using QOS
6526 echo writing a bunch of files to QOS-assigned OSTs
6527 $SETSTRIPE -c 1 $DIR/$tdir
6529 while [ $FILL -gt 0 ]; do
6531 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1024 count=200 2>/dev/null
6532 FILL=$(($FILL - 200))
6535 echo "wrote $i 200k files"
6539 echo "Note: free space may not be updated, so measurements might be off"
6541 DIFF2=$(($MAXV - $MINV))
6542 echo "free space delta: orig $DIFF final $DIFF2"
6543 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
6544 DIFF=$(($MINV1 - ${AVAIL[$MINI1]}))
6545 echo "Wrote $DIFF to smaller OST $MINI1"
6546 DIFF2=$(($MAXV1 - ${AVAIL[$MAXI1]}))
6547 echo "Wrote $DIFF2 to larger OST $MAXI1"
6548 [ $DIFF -gt 0 ] && echo "Wrote $(($DIFF2 * 100 / $DIFF - 100))% more data to larger OST $MAXI1"
6550 # Figure out which files were written where
6551 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
6552 awk '/'$MINI1': / {print $2; exit}')
6554 MINC=$($GETSTRIPE --obd $UUID $DIR/$tdir | wc -l)
6555 echo "$MINC files created on smaller OST $MINI1"
6556 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
6557 awk '/'$MAXI1': / {print $2; exit}')
6559 MAXC=$($GETSTRIPE --obd $UUID $DIR/$tdir | wc -l)
6560 echo "$MAXC files created on larger OST $MAXI1"
6561 [ $MINC -gt 0 ] && echo "Wrote $(($MAXC * 100 / $MINC - 100))% more files to larger OST $MAXI1"
6562 [ $MAXC -gt $MINC ] || error_ignore "stripe QOS didn't balance free space"
6566 run_test 116a "stripe QOS: free space balance ==================="
6568 test_116b() { # LU-2093
6569 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6570 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
6572 old_rr=$(do_facet $SINGLEMDS lctl get_param -n lov.*mdtlov*.qos_threshold_rr)
6573 do_facet $SINGLEMDS lctl set_param lov.*mdtlov*.qos_threshold_rr 0
6575 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
6576 createmany -o $DIR/$tdir/f- 20 || error "can't create"
6577 do_facet $SINGLEMDS lctl set_param fail_loc=0
6579 do_facet $SINGLEMDS lctl set_param lov.*mdtlov*.qos_threshold_rr $old_rr
6581 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
6583 test_117() # bug 10891
6585 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6586 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
6587 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
6588 lctl set_param fail_loc=0x21e
6589 > $DIR/$tfile || error "truncate failed"
6590 lctl set_param fail_loc=0
6591 echo "Truncate succeeded."
6594 run_test 117 "verify fsfilt_extend =========="
6596 NO_SLOW_RESENDCOUNT=4
6597 export OLD_RESENDCOUNT=""
6598 set_resend_count () {
6599 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
6600 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -1)
6601 lctl set_param -n $PROC_RESENDCOUNT $1
6602 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
6605 # for reduce test_118* time (b=14842)
6606 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
6608 # Reset async IO behavior after error case
6610 FILE=$DIR/reset_async
6612 # Ensure all OSCs are cleared
6613 $SETSTRIPE -c -1 $FILE
6614 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
6619 test_118a() #bug 11710
6621 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6624 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6625 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6626 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
6628 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6629 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6634 run_test 118a "verify O_SYNC works =========="
6638 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6639 remote_ost_nodsh && skip "remote OST with nodsh" && return
6643 #define OBD_FAIL_OST_ENOENT 0x217
6644 set_nodes_failloc "$(osts_nodes)" 0x217
6645 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6647 set_nodes_failloc "$(osts_nodes)" 0
6648 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6649 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6652 if [[ $RC -eq 0 ]]; then
6653 error "Must return error due to dropped pages, rc=$RC"
6657 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6658 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6662 echo "Dirty pages not leaked on ENOENT"
6664 # Due to the above error the OSC will issue all RPCs syncronously
6665 # until a subsequent RPC completes successfully without error.
6666 $MULTIOP $DIR/$tfile Ow4096yc
6671 run_test 118b "Reclaim dirty pages on fatal error =========="
6675 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6677 # for 118c, restore the original resend count, LU-1940
6678 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
6679 set_resend_count $OLD_RESENDCOUNT
6680 remote_ost_nodsh && skip "remote OST with nodsh" && return
6684 #define OBD_FAIL_OST_EROFS 0x216
6685 set_nodes_failloc "$(osts_nodes)" 0x216
6687 # multiop should block due to fsync until pages are written
6688 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
6692 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
6693 error "Multiop failed to block on fsync, pid=$MULTIPID"
6696 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6698 if [[ $WRITEBACK -eq 0 ]]; then
6699 error "No page in writeback, writeback=$WRITEBACK"
6702 set_nodes_failloc "$(osts_nodes)" 0
6705 if [[ $RC -ne 0 ]]; then
6706 error "Multiop fsync failed, rc=$RC"
6709 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6710 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6712 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6713 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6717 echo "Dirty pages flushed via fsync on EROFS"
6720 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
6722 # continue to use small resend count to reduce test_118* time (b=14842)
6723 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
6727 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6728 remote_ost_nodsh && skip "remote OST with nodsh" && return
6732 #define OBD_FAIL_OST_BRW_PAUSE_BULK
6733 set_nodes_failloc "$(osts_nodes)" 0x214
6734 # multiop should block due to fsync until pages are written
6735 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
6739 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
6740 error "Multiop failed to block on fsync, pid=$MULTIPID"
6743 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6745 if [[ $WRITEBACK -eq 0 ]]; then
6746 error "No page in writeback, writeback=$WRITEBACK"
6749 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
6750 set_nodes_failloc "$(osts_nodes)" 0
6752 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6753 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6755 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6756 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6760 echo "Dirty pages gaurenteed flushed via fsync"
6763 run_test 118d "Fsync validation inject a delay of the bulk =========="
6766 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6769 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
6770 lctl set_param fail_loc=0x8000040a
6772 # Should simulate EINVAL error which is fatal
6773 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6775 if [[ $RC -eq 0 ]]; then
6776 error "Must return error due to dropped pages, rc=$RC"
6779 lctl set_param fail_loc=0x0
6781 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6782 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6783 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6785 if [[ $LOCKED -ne 0 ]]; then
6786 error "Locked pages remain in cache, locked=$LOCKED"
6789 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6790 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6794 echo "No pages locked after fsync"
6799 run_test 118f "Simulate unrecoverable OSC side error =========="
6802 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6805 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
6806 lctl set_param fail_loc=0x406
6808 # simulate local -ENOMEM
6809 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6812 lctl set_param fail_loc=0
6813 if [[ $RC -eq 0 ]]; then
6814 error "Must return error due to dropped pages, rc=$RC"
6817 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6818 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6819 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6821 if [[ $LOCKED -ne 0 ]]; then
6822 error "Locked pages remain in cache, locked=$LOCKED"
6825 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6826 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6830 echo "No pages locked after fsync"
6835 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
6838 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6839 remote_ost_nodsh && skip "remote OST with nodsh" && return
6843 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
6844 set_nodes_failloc "$(osts_nodes)" 0x20e
6845 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
6846 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6849 set_nodes_failloc "$(osts_nodes)" 0
6850 if [[ $RC -eq 0 ]]; then
6851 error "Must return error due to dropped pages, rc=$RC"
6854 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6855 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6856 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6858 if [[ $LOCKED -ne 0 ]]; then
6859 error "Locked pages remain in cache, locked=$LOCKED"
6862 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6863 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6867 echo "No pages locked after fsync"
6871 run_test 118h "Verify timeout in handling recoverables errors =========="
6873 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
6876 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6877 remote_ost_nodsh && skip "remote OST with nodsh" && return
6881 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
6882 set_nodes_failloc "$(osts_nodes)" 0x20e
6884 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
6885 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
6888 set_nodes_failloc "$(osts_nodes)" 0
6892 if [[ $RC -ne 0 ]]; then
6893 error "got error, but should be not, rc=$RC"
6896 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6897 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6898 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
6899 if [[ $LOCKED -ne 0 ]]; then
6900 error "Locked pages remain in cache, locked=$LOCKED"
6903 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6904 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6908 echo "No pages locked after fsync"
6912 run_test 118i "Fix error before timeout in recoverable error =========="
6914 [ "$SLOW" = "no" ] && set_resend_count 4
6917 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6918 remote_ost_nodsh && skip "remote OST with nodsh" && return
6922 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
6923 set_nodes_failloc "$(osts_nodes)" 0x220
6925 # return -EIO from OST
6926 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6928 set_nodes_failloc "$(osts_nodes)" 0x0
6929 if [[ $RC -eq 0 ]]; then
6930 error "Must return error due to dropped pages, rc=$RC"
6933 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6934 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6935 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
6936 if [[ $LOCKED -ne 0 ]]; then
6937 error "Locked pages remain in cache, locked=$LOCKED"
6940 # in recoverable error on OST we want resend and stay until it finished
6941 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6942 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6946 echo "No pages locked after fsync"
6950 run_test 118j "Simulate unrecoverable OST side error =========="
6954 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6955 remote_ost_nodsh && skip "remote OSTs with nodsh" && return
6957 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
6958 set_nodes_failloc "$(osts_nodes)" 0x20e
6959 test_mkdir -p $DIR/$tdir
6961 for ((i=0;i<10;i++)); do
6962 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
6963 error "dd to $DIR/$tdir/$tfile-$i failed" )&
6970 set_nodes_failloc "$(osts_nodes)" 0
6973 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
6977 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6979 test_mkdir -p $DIR/$tdir
6980 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
6983 run_test 118l "fsync dir ========="
6985 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
6987 test_119a() # bug 11737
6989 BSIZE=$((512 * 1024))
6990 directio write $DIR/$tfile 0 1 $BSIZE
6991 # We ask to read two blocks, which is more than a file size.
6992 # directio will indicate an error when requested and actual
6993 # sizes aren't equeal (a normal situation in this case) and
6994 # print actual read amount.
6995 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
6996 if [ "$NOB" != "$BSIZE" ]; then
6997 error "read $NOB bytes instead of $BSIZE"
7001 run_test 119a "Short directIO read must return actual read amount"
7003 test_119b() # bug 11737
7005 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
7007 $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
7008 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
7010 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) || \
7011 error "direct read failed"
7014 run_test 119b "Sparse directIO read must return actual read amount"
7016 test_119c() # bug 13099
7019 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
7020 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
7023 run_test 119c "Testing for direct read hitting hole"
7025 test_119d() # bug 15950
7027 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7028 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
7029 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
7031 $SETSTRIPE $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
7032 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
7033 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
7034 lctl set_param fail_loc=0x40d
7035 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
7038 cat $DIR/$tfile > /dev/null &
7039 lctl set_param fail_loc=0
7042 log "the DIO writes have completed, now wait for the reads (should not block very long)"
7044 [ -n "`ps h -p $pid_reads -o comm`" ] && \
7045 error "the read rpcs have not completed in 2s"
7047 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
7049 run_test 119d "The DIO path should try to send a new rpc once one is completed"
7052 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7053 test_mkdir -p $DIR/$tdir
7054 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7055 skip "no early lock cancel on server" && return 0
7056 lru_resize_disable mdc
7057 lru_resize_disable osc
7058 cancel_lru_locks mdc
7059 stat $DIR/$tdir > /dev/null
7060 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
7061 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
7062 test_mkdir $DIR/$tdir/d1
7063 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
7064 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
7065 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7066 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7067 lru_resize_enable mdc
7068 lru_resize_enable osc
7070 run_test 120a "Early Lock Cancel: mkdir test"
7073 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7074 test_mkdir -p $DIR/$tdir
7075 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7076 skip "no early lock cancel on server" && return 0
7077 lru_resize_disable mdc
7078 lru_resize_disable osc
7079 cancel_lru_locks mdc
7080 stat $DIR/$tdir > /dev/null
7081 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
7082 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
7084 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
7085 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
7086 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7087 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7088 lru_resize_enable mdc
7089 lru_resize_enable osc
7091 run_test 120b "Early Lock Cancel: create test"
7094 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7095 test_mkdir -p $DIR/$tdir
7096 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7097 skip "no early lock cancel on server" && return 0
7098 lru_resize_disable mdc
7099 lru_resize_disable osc
7100 test_mkdir -p $DIR/$tdir/d1 $DIR/$tdir/d2
7101 touch $DIR/$tdir/d1/f1
7102 cancel_lru_locks mdc
7103 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
7104 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
7105 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
7106 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
7107 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
7108 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
7109 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7110 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7111 lru_resize_enable mdc
7112 lru_resize_enable osc
7114 run_test 120c "Early Lock Cancel: link test"
7117 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7118 test_mkdir -p $DIR/$tdir
7119 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7120 skip "no early lock cancel on server" && return 0
7121 lru_resize_disable mdc
7122 lru_resize_disable osc
7124 cancel_lru_locks mdc
7125 stat $DIR/$tdir > /dev/null
7126 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
7127 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
7128 chmod a+x $DIR/$tdir
7129 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
7130 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
7131 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7132 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7133 lru_resize_enable mdc
7134 lru_resize_enable osc
7136 run_test 120d "Early Lock Cancel: setattr test"
7139 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7140 test_mkdir -p $DIR/$tdir
7141 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7142 skip "no early lock cancel on server" && return 0
7143 lru_resize_disable mdc
7144 lru_resize_disable osc
7145 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
7146 cancel_lru_locks mdc
7147 cancel_lru_locks osc
7148 dd if=$DIR/$tdir/f1 of=/dev/null
7149 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
7150 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7151 awk '/ldlm_cancel/ {print $2}'`
7152 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7153 awk '/ldlm_bl_callback/ {print $2}'`
7154 unlink $DIR/$tdir/f1
7155 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7156 awk '/ldlm_cancel/ {print $2}'`
7157 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7158 awk '/ldlm_bl_callback/ {print $2}'`
7159 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7160 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7161 lru_resize_enable mdc
7162 lru_resize_enable osc
7164 run_test 120e "Early Lock Cancel: unlink test"
7167 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7168 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7169 skip "no early lock cancel on server" && return 0
7170 test_mkdir -p $DIR/$tdir
7171 lru_resize_disable mdc
7172 lru_resize_disable osc
7173 test_mkdir -p $DIR/$tdir/d1 $DIR/$tdir/d2
7174 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
7175 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
7176 cancel_lru_locks mdc
7177 cancel_lru_locks osc
7178 dd if=$DIR/$tdir/d1/f1 of=/dev/null
7179 dd if=$DIR/$tdir/d2/f2 of=/dev/null
7180 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
7181 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7182 awk '/ldlm_cancel/ {print $2}'`
7183 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7184 awk '/ldlm_bl_callback/ {print $2}'`
7185 mv $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
7186 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7187 awk '/ldlm_cancel/ {print $2}'`
7188 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7189 awk '/ldlm_bl_callback/ {print $2}'`
7190 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7191 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7192 lru_resize_enable mdc
7193 lru_resize_enable osc
7195 run_test 120f "Early Lock Cancel: rename test"
7198 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7199 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7200 skip "no early lock cancel on server" && return 0
7201 lru_resize_disable mdc
7202 lru_resize_disable osc
7204 echo create $count files
7205 test_mkdir -p $DIR/$tdir
7206 cancel_lru_locks mdc
7207 cancel_lru_locks osc
7210 can0=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7211 awk '/ldlm_cancel/ {print $2}'`
7212 blk0=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7213 awk '/ldlm_bl_callback/ {print $2}'`
7214 createmany -o $DIR/$tdir/f $count
7216 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7217 awk '/ldlm_cancel/ {print $2}'`
7218 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7219 awk '/ldlm_bl_callback/ {print $2}'`
7221 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
7222 echo rm $count files
7225 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7226 awk '/ldlm_cancel/ {print $2}'`
7227 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7228 awk '/ldlm_bl_callback/ {print $2}'`
7230 echo total: $count removes in $((t2-t1))
7231 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
7233 # wait for commitment of removal
7234 lru_resize_enable mdc
7235 lru_resize_enable osc
7237 run_test 120g "Early Lock Cancel: performance test"
7239 test_121() { #bug #10589
7240 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7242 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
7243 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
7244 lctl set_param fail_loc=0x310
7245 cancel_lru_locks osc > /dev/null
7246 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
7247 lctl set_param fail_loc=0
7248 [ "$reads" -eq "$writes" ] || error "read" $reads "blocks, must be" $writes
7250 run_test 121 "read cancel race ========="
7252 test_123a() { # was test 123, statahead(bug 11401)
7253 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7255 if [ -z "$(grep "processor.*: 1" /proc/cpuinfo)" ]; then
7256 log "testing on UP system. Performance may be not as good as expected."
7261 test_mkdir -p $DIR/$tdir
7262 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
7263 [ $NUMFREE -gt 100000 ] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
7265 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
7266 createmany -o $DIR/$tdir/$tfile $j $((i - j))
7268 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
7269 lctl set_param -n llite.*.statahead_max 0
7270 lctl get_param llite.*.statahead_max
7271 cancel_lru_locks mdc
7272 cancel_lru_locks osc
7274 time ls -l $DIR/$tdir | wc -l
7276 delta=$((etime - stime))
7277 log "ls $i files without statahead: $delta sec"
7278 lctl set_param llite.*.statahead_max=$max
7280 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
7281 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
7282 cancel_lru_locks mdc
7283 cancel_lru_locks osc
7285 time ls -l $DIR/$tdir | wc -l
7287 delta_sa=$((etime - stime))
7288 log "ls $i files with statahead: $delta_sa sec"
7289 lctl get_param -n llite.*.statahead_stats
7290 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
7292 [ $swrong -lt $ewrong ] && log "statahead was stopped, maybe too many locks held!"
7293 [ $delta -eq 0 -o $delta_sa -eq 0 ] && continue
7295 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
7296 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
7297 lctl set_param -n llite.*.statahead_max 0
7298 lctl get_param llite.*.statahead_max
7299 cancel_lru_locks mdc
7300 cancel_lru_locks osc
7302 time ls -l $DIR/$tdir | wc -l
7304 delta=$((etime - stime))
7305 log "ls $i files again without statahead: $delta sec"
7306 lctl set_param llite.*.statahead_max=$max
7307 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
7308 if [ $SLOWOK -eq 0 ]; then
7309 error "ls $i files is slower with statahead!"
7311 log "ls $i files is slower with statahead!"
7317 [ $delta -gt 20 ] && break
7318 [ $delta -gt 8 ] && MULT=$((50 / delta))
7319 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
7327 delta=$((etime - stime))
7328 log "rm -r $DIR/$tdir/: $delta seconds"
7330 lctl get_param -n llite.*.statahead_stats
7332 run_test 123a "verify statahead work"
7334 test_123b () { # statahead(bug 15027)
7335 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7336 test_mkdir -p $DIR/$tdir
7337 createmany -o $DIR/$tdir/$tfile-%d 1000
7339 cancel_lru_locks mdc
7340 cancel_lru_locks osc
7342 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
7343 lctl set_param fail_loc=0x80000803
7344 ls -lR $DIR/$tdir > /dev/null
7346 lctl set_param fail_loc=0x0
7347 lctl get_param -n llite.*.statahead_stats
7352 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
7355 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7356 [ -z "`lctl get_param -n mdc.*.connect_flags | grep lru_resize`" ] && \
7357 skip "no lru resize on server" && return 0
7359 test_mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
7361 log "create $NR files at $DIR/$tdir"
7362 createmany -o $DIR/$tdir/f $NR ||
7363 error "failed to create $NR files in $DIR/$tdir"
7365 cancel_lru_locks mdc
7366 ls -l $DIR/$tdir > /dev/null
7370 for VALUE in `lctl get_param ldlm.namespaces.*mdc-*.lru_size`; do
7371 local PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
7372 LRU_SIZE=$(lctl get_param -n $PARAM)
7373 if [ $LRU_SIZE -gt $(default_lru_size) ]; then
7374 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
7376 log "NS=$(basename $NSDIR)"
7381 if [ -z "$NSDIR" -o $LRU_SIZE -lt $(default_lru_size) ]; then
7382 skip "Not enough cached locks created!"
7389 # We know that lru resize allows one client to hold $LIMIT locks
7390 # for 10h. After that locks begin to be killed by client.
7392 local LIMIT=`lctl get_param -n $NSDIR.pool.limit`
7395 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
7396 # killing locks. Some time was spent for creating locks. This means
7397 # that up to the moment of sleep finish we must have killed some of
7398 # them (10-100 locks). This depends on how fast ther were created.
7399 # Many of them were touched in almost the same moment and thus will
7400 # be killed in groups.
7401 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
7403 # Use $LRU_SIZE_B here to take into account real number of locks
7404 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
7405 local LRU_SIZE_B=$LRU_SIZE
7407 local OLD_LVF=`lctl get_param -n $NSDIR.pool.lock_volume_factor`
7408 log "OLD_LVF=$OLD_LVF"
7409 lctl set_param -n $NSDIR.pool.lock_volume_factor $LVF
7411 # Let's make sure that we really have some margin. Client checks
7412 # cached locks every 10 sec.
7414 log "Sleep ${SLEEP} sec"
7416 while ((SEC<$SLEEP)); do
7420 LRU_SIZE=`lctl get_param -n $NSDIR/lru_size`
7424 lctl set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
7425 local LRU_SIZE_A=`lctl get_param -n $NSDIR.lru_size`
7427 [ $LRU_SIZE_B -gt $LRU_SIZE_A ] || {
7428 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
7429 unlinkmany $DIR/$tdir/f $NR
7433 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
7434 log "unlink $NR files at $DIR/$tdir"
7435 unlinkmany $DIR/$tdir/f $NR
7437 run_test 124a "lru resize ======================================="
7439 get_max_pool_limit()
7441 local limit=`lctl get_param -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit`
7444 if test $l -gt $max; then
7452 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7453 [ -z "`lctl get_param -n mdc.*.connect_flags | grep lru_resize`" ] && \
7454 skip "no lru resize on server" && return 0
7456 LIMIT=`get_max_pool_limit`
7458 NR=$(($(default_lru_size)*20))
7459 if [ $NR -gt $LIMIT ]; then
7460 log "Limit lock number by $LIMIT locks"
7463 lru_resize_disable mdc
7464 test_mkdir -p $DIR/$tdir/disable_lru_resize ||
7465 error "failed to create $DIR/$tdir/disable_lru_resize"
7467 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
7468 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
7469 cancel_lru_locks mdc
7472 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
7475 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
7478 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
7482 nolruresize_delta=$((etime-stime))
7483 log "ls -la time: $nolruresize_delta seconds"
7484 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
7485 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
7487 lru_resize_enable mdc
7488 test_mkdir -p $DIR/$tdir/enable_lru_resize ||
7489 error "failed to create $DIR/$tdir/enable_lru_resize"
7491 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
7492 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
7493 cancel_lru_locks mdc
7496 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
7499 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
7502 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
7506 lruresize_delta=$((etime-stime))
7507 log "ls -la time: $lruresize_delta seconds"
7508 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
7510 if [ $lruresize_delta -gt $nolruresize_delta ]; then
7511 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
7512 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
7513 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
7515 log "lru resize performs the same with no lru resize"
7517 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
7519 run_test 124b "lru resize (performance test) ======================="
7521 test_125() { # 13358
7522 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
7523 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
7524 test_mkdir -p $DIR/d125 || error "mkdir failed"
7525 $SETSTRIPE -S 65536 -c -1 $DIR/d125 || error "setstripe failed"
7526 setfacl -R -m u:bin:rwx $DIR/d125 || error "setfacl $DIR/d125 failed"
7527 ls -ld $DIR/d125 || error "cannot access $DIR/d125"
7529 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
7531 test_126() { # bug 12829/13455
7532 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
7533 [ "$UID" != 0 ] && skip_env "skipping $TESTNAME (must run as root)" && return
7534 $GSS && skip "must run as gss disabled" && return
7536 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
7537 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
7539 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
7541 run_test 126 "check that the fsgid provided by the client is taken into account"
7543 test_127a() { # bug 15521
7544 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7545 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
7546 $LCTL set_param osc.*.stats=0
7547 FSIZE=$((2048 * 1024))
7548 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
7549 cancel_lru_locks osc
7550 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
7552 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
7553 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
7554 echo "got $COUNT $NAME"
7555 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
7556 eval $NAME=$COUNT || error "Wrong proc format"
7559 read_bytes|write_bytes)
7560 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
7561 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
7562 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
7563 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
7564 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
7565 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
7566 error "sumsquare is too small: $SUMSQ"
7567 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
7568 error "sumsquare is too big: $SUMSQ"
7572 done < $DIR/${tfile}.tmp
7574 #check that we actually got some stats
7575 [ "$read_bytes" ] || error "Missing read_bytes stats"
7576 [ "$write_bytes" ] || error "Missing write_bytes stats"
7577 [ "$read_bytes" != 0 ] || error "no read done"
7578 [ "$write_bytes" != 0 ] || error "no write done"
7580 run_test 127a "verify the client stats are sane"
7582 test_127b() { # bug LU-333
7583 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7584 $LCTL set_param llite.*.stats=0
7585 FSIZE=65536 # sized fixed to match PAGE_SIZE for most clients
7586 # perform 2 reads and writes so MAX is different from SUM.
7587 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
7588 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
7589 cancel_lru_locks osc
7590 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
7591 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
7593 $LCTL get_param llite.*.stats | grep samples > $TMP/${tfile}.tmp
7594 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
7595 echo "got $COUNT $NAME"
7596 eval $NAME=$COUNT || error "Wrong proc format"
7600 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
7601 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
7602 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
7603 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
7606 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
7607 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
7608 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
7609 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
7613 done < $TMP/${tfile}.tmp
7615 #check that we actually got some stats
7616 [ "$read_bytes" ] || error "Missing read_bytes stats"
7617 [ "$write_bytes" ] || error "Missing write_bytes stats"
7618 [ "$read_bytes" != 0 ] || error "no read done"
7619 [ "$write_bytes" != 0 ] || error "no write done"
7621 run_test 127b "verify the llite client stats are sane"
7623 test_128() { # bug 15212
7625 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
7630 result=$(grep error $TMP/$tfile.log)
7632 [ -z "$result" ] || error "consecutive find's under interactive lfs failed"
7634 run_test 128 "interactive lfs for 2 consecutive find's"
7641 local LDPROC=/proc/fs/ldiskfs
7642 local facets=$(get_facets MDS)
7644 for facet in ${facets//,/ }; do
7645 canondev=$(ldiskfs_canon \
7646 *.$(convert_facet2label $facet).mntdev $facet)
7647 do_facet $facet "test -e $LDPROC/$canondev/max_dir_size" ||
7648 LDPROC=/sys/fs/ldiskfs
7649 do_facet $facet "echo $1 >$LDPROC/$canondev/max_dir_size"
7654 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7655 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
7656 skip "Only applicable to ldiskfs-based MDTs"
7659 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7665 test_mkdir -p $DIR/$tdir
7669 while [ ! $I -gt $((MAX * MDSCOUNT)) ]; do
7670 $MULTIOP $DIR/$tdir/$J Oc
7672 if [ $rc -eq $EFBIG ]; then
7674 echo "return code $rc received as expected"
7676 elif [ $rc -ne 0 ]; then
7678 error_exit "return code $rc received instead of expected $EFBIG"
7681 I=$(stat -c%s "$DIR/$tdir")
7685 error "exceeded dir size limit $MAX x $MDSCOUNT $((MAX * MDSCOUNT)) : $I bytes"
7687 run_test 129 "test directory size limit ========================"
7696 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7697 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
7700 trap cleanup_130 EXIT RETURN
7702 local fm_file=$DIR/$tfile
7703 $SETSTRIPE -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
7704 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
7705 error "dd failed for $fm_file"
7707 # LU-1795: test filefrag/FIEMAP once, even if unsupported
7708 filefrag -ves $fm_file
7710 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
7711 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
7712 [ $RC != 0 ] && error "filefrag $fm_file failed"
7714 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
7715 grep -v "ext:" | grep -v "found")
7716 lun=$($GETSTRIPE -i $fm_file)
7718 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
7721 for line in $filefrag_op
7723 frag_lun=`echo $line | cut -d: -f5`
7724 ext_len=`echo $line | cut -d: -f4`
7725 if (( $frag_lun != $lun )); then
7727 error "FIEMAP on 1-stripe file($fm_file) failed"
7730 (( tot_len += ext_len ))
7733 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
7735 error "FIEMAP on 1-stripe file($fm_file) failed;"
7741 echo "FIEMAP on single striped file succeeded"
7743 run_test 130a "FIEMAP (1-stripe file)"
7746 [ "$OSTCOUNT" -lt "2" ] &&
7747 skip_env "skipping FIEMAP on 2-stripe file test" && return
7749 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7750 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
7753 trap cleanup_130 EXIT RETURN
7755 local fm_file=$DIR/$tfile
7756 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
7757 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
7758 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
7760 dd if=/dev/zero of=$fm_file bs=1M count=2 ||
7761 error "dd failed on $fm_file"
7763 filefrag -ves $fm_file || error "filefrag $fm_file failed"
7764 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
7765 grep -v "ext:" | grep -v "found")
7767 last_lun=$(echo $filefrag_op | cut -d: -f5)
7772 for line in $filefrag_op
7774 frag_lun=`echo $line | cut -d: -f5`
7775 ext_len=`echo $line | cut -d: -f4`
7776 if (( $frag_lun != $last_lun )); then
7777 if (( tot_len != 1024 )); then
7779 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 256"
7786 (( tot_len += ext_len ))
7789 if (( num_luns != 2 || tot_len != 1024 )); then
7791 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
7797 echo "FIEMAP on 2-stripe file succeeded"
7799 run_test 130b "FIEMAP (2-stripe file)"
7802 [ "$OSTCOUNT" -lt "2" ] &&
7803 skip_env "skipping FIEMAP on 2-stripe file" && return
7805 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7806 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
7809 trap cleanup_130 EXIT RETURN
7811 local fm_file=$DIR/$tfile
7812 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
7813 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
7814 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
7816 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 || error "dd failed on $fm_file"
7818 filefrag -ves $fm_file || error "filefrag $fm_file failed"
7819 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
7821 last_lun=`echo $filefrag_op | cut -d: -f5`
7826 for line in $filefrag_op
7828 frag_lun=`echo $line | cut -d: -f5`
7829 ext_len=`echo $line | cut -d: -f4`
7830 if (( $frag_lun != $last_lun )); then
7831 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
7832 if (( logical != 512 )); then
7834 error "FIEMAP on $fm_file failed; returned logical start for lun $logical instead of 512"
7837 if (( tot_len != 512 )); then
7839 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
7846 (( tot_len += ext_len ))
7849 if (( num_luns != 2 || tot_len != 512 )); then
7851 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
7857 echo "FIEMAP on 2-stripe file with hole succeeded"
7859 run_test 130c "FIEMAP (2-stripe file with hole)"
7862 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping FIEMAP on N-stripe file test" && return
7864 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7865 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
7867 trap cleanup_130 EXIT RETURN
7869 local fm_file=$DIR/$tfile
7870 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file||error "setstripe on $fm_file"
7871 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
7872 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
7873 dd if=/dev/zero of=$fm_file bs=1M count=$OSTCOUNT || error "dd failed on $fm_file"
7875 filefrag -ves $fm_file || error "filefrag $fm_file failed"
7876 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
7878 last_lun=`echo $filefrag_op | cut -d: -f5`
7883 for line in $filefrag_op
7885 frag_lun=`echo $line | cut -d: -f5`
7886 ext_len=`echo $line | cut -d: -f4`
7887 if (( $frag_lun != $last_lun )); then
7888 if (( tot_len != 1024 )); then
7890 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
7897 (( tot_len += ext_len ))
7900 if (( num_luns != OSTCOUNT || tot_len != 1024 )); then
7902 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
7908 echo "FIEMAP on N-stripe file succeeded"
7910 run_test 130d "FIEMAP (N-stripe file)"
7913 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping continuation FIEMAP test" && return
7915 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7916 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
7918 trap cleanup_130 EXIT RETURN
7920 local fm_file=$DIR/$tfile
7921 $SETSTRIPE -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
7922 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
7923 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
7926 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
7927 for ((i = 0; i < $NUM_BLKS; i++))
7929 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
7932 filefrag -ves $fm_file || error "filefrag $fm_file failed"
7933 filefrag_op=`filefrag -ve $fm_file | grep -A 12000 "ext:" | grep -v "ext:" | grep -v "found"`
7935 last_lun=`echo $filefrag_op | cut -d: -f5`
7940 for line in $filefrag_op
7942 frag_lun=`echo $line | cut -d: -f5`
7943 ext_len=`echo $line | cut -d: -f4`
7944 if (( $frag_lun != $last_lun )); then
7945 if (( tot_len != $EXPECTED_LEN )); then
7947 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of $EXPECTED_LEN"
7954 (( tot_len += ext_len ))
7957 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
7959 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
7965 echo "FIEMAP with continuation calls succeeded"
7967 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
7969 # Test for writev/readv
7971 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 || \
7972 error "writev test failed"
7973 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 || \
7974 error "readv failed"
7977 run_test 131a "test iov's crossing stripe boundary for writev/readv"
7980 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 || \
7981 error "append writev test failed"
7982 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 || \
7983 error "append writev test failed"
7986 run_test 131b "test append writev"
7989 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
7992 run_test 131c "test read/write on file w/o objects"
7995 rwv -f $DIR/$tfile -w -n 1 1572864
7996 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
7997 if [ "$NOB" != 1572864 ]; then
7998 error "Short read filed: read $NOB bytes instead of 1572864"
8002 run_test 131d "test short read"
8005 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
8006 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
8007 error "read hitting hole failed"
8010 run_test 131e "test read hitting hole"
8015 for node in $(osts_nodes); do
8016 gl=$(do_node $node "$LCTL get_param -n ost.OSS.ost.stats" | awk '/'$token'/ {print $2}' | head -n 1)
8017 [ x$gl = x"" ] && gl=0
8018 gl_sum=$((gl_sum + gl))
8028 if [ x$som = x"enabled" ]; then
8029 [ $((gl2 - gl1)) -gt 0 ] && error "no glimpse RPC is expected"
8030 MOUNTOPT=`echo $MOUNTOPT | sed 's/som_preview//g'`
8031 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=disabled"
8033 [ $((gl2 - gl1)) -gt 0 ] || error "some glimpse RPC is expected"
8034 MOUNTOPT="$MOUNTOPT,som_preview"
8035 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=enabled"
8038 # do remount to make new mount-conf parameters actual
8045 test_132() { #1028, SOM
8046 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8047 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8048 local num=$(get_mds_dir $DIR)
8049 local mymds=mds${num}
8050 local MOUNTOPT_SAVE=$MOUNTOPT
8052 dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
8053 cancel_lru_locks osc
8055 som1=$(do_facet $mymds "$LCTL get_param mdt.*.som" | awk -F= ' {print $2}' | head -n 1)
8057 gl1=$(get_ost_param "ldlm_glimpse_enqueue")
8058 stat $DIR/$tfile >/dev/null
8059 gl2=$(get_ost_param "ldlm_glimpse_enqueue")
8060 echo "====> SOM is "$som1", "$((gl2 - gl1))" glimpse RPC occured"
8062 som_mode_switch $som1 $gl1 $gl2
8064 dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
8065 cancel_lru_locks osc
8067 som2=$(do_facet $mymds "$LCTL get_param mdt.*.som" | awk -F= ' {print $2}' | head -n 1)
8068 if [ $som1 == $som2 ]; then
8069 error "som is still "$som2
8070 if [ x$som2 = x"enabled" ]; then
8077 gl1=$(get_ost_param "ldlm_glimpse_enqueue")
8078 stat $DIR/$tfile >/dev/null
8079 gl2=$(get_ost_param "ldlm_glimpse_enqueue")
8080 echo "====> SOM is "$som2", "$((gl2 - gl1))" glimpse RPC occured"
8081 som_mode_switch $som2 $gl1 $gl2
8082 MOUNTOPT=$MOUNTOPT_SAVE
8084 run_test 132 "som avoids glimpse rpc"
8090 $SINGLEMDS) res=`do_facet $SINGLEMDS $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$2"`
8092 ost) res=`do_facet ost1 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$2"`
8094 *) error "Wrong argument $1" ;;
8097 count=`echo $res | awk '{print $2}'`
8098 [ -z "$res" ] && error "The counter for $2 on $1 was not incremented"
8099 # if the argument $3 is zero, it means any stat increment is ok.
8100 if [ $3 -gt 0 ] ; then
8101 [ $count -ne $3 ] && error "The $2 counter on $1 is wrong - expected $3"
8106 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8107 remote_ost_nodsh && skip "remote OST with nodsh" && return
8108 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8110 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
8111 { skip "MDS doesn't support rename stats"; return; }
8112 local testdir=$DIR/${tdir}/stats_testdir
8113 mkdir -p $DIR/${tdir}
8116 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8117 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
8119 # verify mdt stats first.
8120 mkdir ${testdir} || error "mkdir failed"
8121 check_stats $SINGLEMDS "mkdir" 1
8122 touch ${testdir}/${tfile} || "touch failed"
8123 check_stats $SINGLEMDS "open" 1
8124 check_stats $SINGLEMDS "close" 1
8125 mknod ${testdir}/${tfile}-pipe p || "mknod failed"
8126 check_stats $SINGLEMDS "mknod" 1
8127 rm -f ${testdir}/${tfile}-pipe || "pipe remove failed"
8128 check_stats $SINGLEMDS "unlink" 1
8129 rm -f ${testdir}/${tfile} || error "file remove failed"
8130 check_stats $SINGLEMDS "unlink" 2
8132 # remove working dir and check mdt stats again.
8133 rmdir ${testdir} || error "rmdir failed"
8134 check_stats $SINGLEMDS "rmdir" 1
8136 local testdir1=$DIR/${tdir}/stats_testdir1
8138 mkdir -p ${testdir1}
8139 touch ${testdir1}/test1
8140 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
8141 check_stats $SINGLEMDS "crossdir_rename" 1
8143 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
8144 check_stats $SINGLEMDS "samedir_rename" 1
8148 run_test 133a "Verifying MDT stats ========================================"
8151 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8152 remote_ost_nodsh && skip "remote OST with nodsh" && return
8153 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8154 local testdir=$DIR/${tdir}/stats_testdir
8155 mkdir -p ${testdir} || error "mkdir failed"
8156 touch ${testdir}/${tfile} || "touch failed"
8157 cancel_lru_locks mdc
8160 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8161 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
8163 # extra mdt stats verification.
8164 chmod 444 ${testdir}/${tfile} || error "chmod failed"
8165 check_stats $SINGLEMDS "setattr" 1
8166 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8167 if [ $(lustre_version_code $SINGLEMDS) -ne $(version_code 2.2.0) ]
8169 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
8170 check_stats $SINGLEMDS "getattr" 1
8172 $LFS df || error "lfs failed"
8173 check_stats $SINGLEMDS "statfs" 1
8177 run_test 133b "Verifying extra MDT stats =================================="
8180 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8181 remote_ost_nodsh && skip "remote OST with nodsh" && return
8182 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8183 local testdir=$DIR/${tdir}/stats_testdir
8184 test_mkdir -p ${testdir} || error "mkdir failed"
8186 # verify obdfilter stats.
8187 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
8189 cancel_lru_locks osc
8190 wait_delete_completed
8193 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8194 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
8196 dd if=/dev/zero of=${testdir}/${tfile} conv=notrunc bs=512k count=1 || error "dd failed"
8198 cancel_lru_locks osc
8199 check_stats ost "write" 1
8201 dd if=${testdir}/${tfile} of=/dev/null bs=1k count=1 || error "dd failed"
8202 check_stats ost "read" 1
8204 > ${testdir}/${tfile} || error "truncate failed"
8205 check_stats ost "punch" 1
8207 rm -f ${testdir}/${tfile} || error "file remove failed"
8208 wait_delete_completed
8209 check_stats ost "destroy" 1
8213 run_test 133c "Verifying OST stats ========================================"
8220 while [ $value -ge 2 ]; do
8225 if [ $orig -gt $order ]; then
8233 local size=('K' 'M' 'G' 'T');
8235 local size_string=$value
8237 while [ $value -ge 1024 ]; do
8238 if [ $i -gt 3 ]; then
8239 #T is the biggest unit we get here, if that is bigger,
8241 size_string=${value}T
8244 value=$((value >> 10))
8245 if [ $value -lt 1024 ]; then
8246 size_string=${value}${size[$i]}
8257 local context=${2:-.}
8258 local sample=$(do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats |
8260 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
8265 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8266 remote_ost_nodsh && skip "remote OST with nodsh" && return
8267 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8268 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
8269 { skip "MDS doesn't support rename stats"; return; }
8271 local testdir1=$DIR/${tdir}/stats_testdir1
8272 local testdir2=$DIR/${tdir}/stats_testdir2
8274 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
8276 test_mkdir -p ${testdir1} || error "mkdir failed"
8277 test_mkdir -p ${testdir2} || error "mkdir failed"
8279 createmany -o $testdir1/test 512 || error "createmany failed"
8281 # check samedir rename size
8282 mv ${testdir1}/test0 ${testdir1}/test_0
8284 local testdir1_size=$(ls -l $DIR/${tdir} |
8285 awk '/stats_testdir1/ {print $5}')
8286 local testdir2_size=$(ls -l $DIR/${tdir} |
8287 awk '/stats_testdir2/ {print $5}')
8289 testdir1_size=$(order_2 $testdir1_size)
8290 testdir2_size=$(order_2 $testdir2_size)
8292 testdir1_size=$(size_in_KMGT $testdir1_size)
8293 testdir2_size=$(size_in_KMGT $testdir2_size)
8295 echo "source rename dir size: ${testdir1_size}"
8296 echo "target rename dir size: ${testdir2_size}"
8298 local cmd="do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats"
8299 eval $cmd || error "$cmd failed"
8300 local samedir=$($cmd | grep 'same_dir')
8301 local same_sample=$(get_rename_size $testdir1_size)
8302 [ -z "$samedir" ] && error "samedir_rename_size count error"
8303 [ "$same_sample" -eq 1 ] || error "samedir_rename_size error $same_sample"
8304 echo "Check same dir rename stats success"
8306 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
8308 # check crossdir rename size
8309 mv ${testdir1}/test_0 ${testdir2}/test_0
8311 testdir1_size=$(ls -l $DIR/${tdir} |
8312 awk '/stats_testdir1/ {print $5}')
8313 testdir2_size=$(ls -l $DIR/${tdir} |
8314 awk '/stats_testdir2/ {print $5}')
8316 testdir1_size=$(order_2 $testdir1_size)
8317 testdir2_size=$(order_2 $testdir2_size)
8319 testdir1_size=$(size_in_KMGT $testdir1_size)
8320 testdir2_size=$(size_in_KMGT $testdir2_size)
8322 echo "source rename dir size: ${testdir1_size}"
8323 echo "target rename dir size: ${testdir2_size}"
8325 eval $cmd || error "$cmd failed"
8326 local crossdir=$($cmd | grep 'crossdir')
8327 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
8328 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
8329 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
8330 [ "$src_sample" -eq 1 ] || error "crossdir_rename_size error $src_sample"
8331 [ "$tgt_sample" -eq 1 ] || error "crossdir_rename_size error $tgt_sample"
8332 echo "Check cross dir rename stats success"
8335 run_test 133d "Verifying rename_stats ========================================"
8338 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8339 local testdir=$DIR/${tdir}/stats_testdir
8340 local ctr f0 f1 bs=32768 count=42 sum
8342 remote_ost_nodsh && skip "remote OST with nodsh" && return
8343 mkdir -p ${testdir} || error "mkdir failed"
8345 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
8347 for ctr in {write,read}_bytes; do
8349 cancel_lru_locks osc
8351 do_facet ost1 $LCTL set_param -n \
8352 "obdfilter.*.exports.clear=clear"
8354 if [ $ctr = write_bytes ]; then
8356 f1=${testdir}/${tfile}
8358 f0=${testdir}/${tfile}
8362 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
8365 cancel_lru_locks osc
8367 sum=$(do_facet ost1 $LCTL get_param \
8368 "obdfilter.*.exports.*.stats" | \
8371 $1 == ctr { sum += $7 }
8374 if ((sum != bs * count)); then
8375 error "Bad $ctr sum, expected $((bs * count)), got $sum"
8381 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
8384 local proc_dirs="/proc/fs/lustre/ /proc/sys/lnet/ /proc/sys/lustre/"
8387 # First without trusting modes.
8389 -exec cat '{}' \; &> /dev/null
8391 # Second verifying readability.
8395 -exec cat '{}' \; > /dev/null ||
8396 error "proc file read failed"
8398 for facet in $SINGLEMDS ost1; do
8399 do_facet $facet find $proc_dirs \
8400 -not -name req_history \
8401 -exec cat '{}' \\\; &> /dev/null
8403 do_facet $facet find $proc_dirs \
8404 -not -name req_history \
8407 -exec cat '{}' \\\; > /dev/null ||
8408 error "proc file read failed"
8411 run_test 133f "Check for LBUGs/Oopses/unreadable files in /proc"
8413 test_140() { #bug-17379
8414 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8415 test_mkdir -p $DIR/$tdir || error "Creating dir $DIR/$tdir"
8416 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
8417 cp /usr/bin/stat . || error "Copying stat to $DIR/$tdir"
8419 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
8420 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
8422 while i=`expr $i + 1`; do
8423 test_mkdir -p $i || error "Creating dir $i"
8424 cd $i || error "Changing to $i"
8425 ln -s ../stat stat || error "Creating stat symlink"
8426 # Read the symlink until ELOOP present,
8427 # not LBUGing the system is considered success,
8428 # we didn't overrun the stack.
8429 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
8431 if [ $ret -eq 40 ]; then
8434 error "Open stat symlink"
8440 echo "The symlink depth = $i"
8441 [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 -o $i -eq 40 ] ||
8442 error "Invalid symlink depth"
8444 # Test recursive symlink
8445 ln -s symlink_self symlink_self
8446 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
8447 echo "open symlink_self returns $ret"
8448 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
8450 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
8453 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8454 local TF="$TMP/$tfile"
8456 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
8458 cancel_lru_locks osc
8459 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
8460 remount_client $MOUNT
8462 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
8465 $TRUNCATE $DIR/$tfile 6000
8466 cancel_lru_locks osc
8467 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
8470 echo "12345" >>$DIR/$tfile
8471 cancel_lru_locks osc
8472 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
8475 echo "12345" >>$DIR/$tfile
8476 cancel_lru_locks osc
8477 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
8482 run_test 150 "truncate/append tests"
8484 function roc_hit() {
8485 local list=$(comma_list $(osts_nodes))
8486 #debug temp debug for LU-2902: lets see what values we get back
8487 echo $(get_osd_param $list '' stats) 1>&2
8488 echo $(get_osd_param $list '' stats |
8489 awk '/'cache_hit'/ {sum+=$2} END {print sum}')
8492 function set_cache() {
8495 if [ "$2" == "off" ]; then
8498 local list=$(comma_list $(osts_nodes))
8499 set_osd_param $list '' $1_cache_enable $on
8501 cancel_lru_locks osc
8505 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8506 remote_ost_nodsh && skip "remote OST with nodsh" && return
8509 local list=$(comma_list $(osts_nodes))
8511 # check whether obdfilter is cache capable at all
8512 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
8513 echo "not cache-capable obdfilter"
8517 # check cache is enabled on all obdfilters
8518 if get_osd_param $list '' read_cache_enable | grep 0; then
8519 echo "oss cache is disabled"
8523 set_osd_param $list '' writethrough_cache_enable 1
8525 # check write cache is enabled on all obdfilters
8526 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
8527 echo "oss write cache is NOT enabled"
8531 #define OBD_FAIL_OBD_NO_LRU 0x609
8532 do_nodes $list $LCTL set_param fail_loc=0x609
8534 # pages should be in the case right after write
8535 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
8538 local BEFORE=`roc_hit`
8539 cancel_lru_locks osc
8540 cat $DIR/$tfile >/dev/null
8541 local AFTER=`roc_hit`
8543 do_nodes $list $LCTL set_param fail_loc=0
8545 if ! let "AFTER - BEFORE == CPAGES"; then
8546 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
8549 # the following read invalidates the cache
8550 cancel_lru_locks osc
8551 set_osd_param $list '' read_cache_enable 0
8552 cat $DIR/$tfile >/dev/null
8554 # now data shouldn't be found in the cache
8556 cancel_lru_locks osc
8557 cat $DIR/$tfile >/dev/null
8559 if let "AFTER - BEFORE != 0"; then
8560 error "IN CACHE: before: $BEFORE, after: $AFTER"
8563 set_osd_param $list '' read_cache_enable 1
8566 run_test 151 "test cache on oss and controls ==============================="
8569 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8570 local TF="$TMP/$tfile"
8572 # simulate ENOMEM during write
8573 #define OBD_FAIL_OST_NOMEM 0x226
8574 lctl set_param fail_loc=0x80000226
8575 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
8577 sync || error "sync failed"
8578 lctl set_param fail_loc=0
8580 # discard client's cache
8581 cancel_lru_locks osc
8583 # simulate ENOMEM during read
8584 lctl set_param fail_loc=0x80000226
8585 cmp $TF $DIR/$tfile || error "cmp failed"
8586 lctl set_param fail_loc=0
8590 run_test 152 "test read/write with enomem ============================"
8593 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
8595 run_test 153 "test if fdatasync does not crash ======================="
8597 dot_lustre_fid_permission_check() {
8599 local ffid=$MOUNT/.lustre/fid/$fid
8602 echo "stat fid $fid"
8603 stat $ffid > /dev/null || error "stat $ffid failed."
8604 echo "touch fid $fid"
8605 touch $ffid || error "touch $ffid failed."
8606 echo "write to fid $fid"
8607 cat /etc/hosts > $ffid || error "write $ffid failed."
8608 echo "read fid $fid"
8609 diff /etc/hosts $ffid || error "read $ffid failed."
8610 echo "append write to fid $fid"
8611 cat /etc/hosts >> $ffid || error "append write $ffid failed."
8612 echo "rename fid $fid"
8613 mv $ffid $test_dir/$tfile.1 &&
8614 error "rename $ffid to $tfile.1 should fail."
8615 touch $test_dir/$tfile.1
8616 mv $test_dir/$tfile.1 $ffid &&
8617 error "rename $tfile.1 to $ffid should fail."
8618 rm -f $test_dir/$tfile.1
8619 echo "truncate fid $fid"
8620 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
8621 echo "link fid $fid"
8622 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
8623 if [ -n $(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl) ]; then
8624 echo "setfacl fid $fid"
8625 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
8626 echo "getfacl fid $fid"
8627 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
8629 echo "unlink fid $fid"
8630 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
8631 echo "mknod fid $fid"
8632 mknod $ffid c 1 3 && error "mknod $ffid should fail."
8634 fid=[0xf00000400:0x1:0x0]
8635 ffid=$MOUNT/.lustre/fid/$fid
8637 echo "stat non-exist fid $fid"
8638 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
8639 echo "write to non-exist fid $fid"
8640 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
8641 echo "link new fid $fid"
8642 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
8644 mkdir -p $test_dir/$tdir
8645 touch $test_dir/$tdir/$tfile
8646 fid=$($LFS path2fid $test_dir/$tdir)
8649 error "error: could not get fid for $test_dir/$dir/$tfile."
8651 ffid=$MOUNT/.lustre/fid/$fid
8654 ls $ffid > /dev/null || error "ls $ffid failed."
8655 echo "touch $fid/$tfile.1"
8656 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
8658 echo "touch $MOUNT/.lustre/fid/$tfile"
8659 touch $MOUNT/.lustre/fid/$tfile && \
8660 error "touch $MOUNT/.lustre/fid/$tfile should fail."
8662 echo "setxattr to $MOUNT/.lustre/fid"
8663 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid &&
8664 error "setxattr should fail."
8666 echo "listxattr for $MOUNT/.lustre/fid"
8667 getfattr -d -m "^trusted" $MOUNT/.lustre/fid &&
8668 error "listxattr should fail."
8670 echo "delxattr from $MOUNT/.lustre/fid"
8671 setfattr -x trusted.name1 $MOUNT/.lustre/fid &&
8672 error "delxattr should fail."
8674 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
8675 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
8676 error "touch invalid fid should fail."
8678 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
8679 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
8680 error "touch non-normal fid should fail."
8682 echo "rename $tdir to $MOUNT/.lustre/fid"
8683 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
8684 error "rename to $MOUNT/.lustre/fid should fail."
8686 echo "rename .lustre to itself"
8687 fid=$($LFS path2fid $MOUNT)
8688 mrename $MOUNT/.lustre $MOUNT/.lustre/fid/$fid/.lustre &&
8689 error "rename .lustre to itself should fail."
8691 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
8692 fid=$($LFS path2fid $test_dir/$tfile-2)
8693 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
8694 cp /etc/passwd $MOUNT/.lustre/fid/$fid &&
8695 error "create lov data thru .lustre should fail."
8696 echo "cp /etc/passwd $test_dir/$tfile-2"
8697 cp /etc/passwd $test_dir/$tfile-2 ||
8698 error "copy to $test_dir/$tfile-2 failed."
8699 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
8700 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
8701 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
8703 rm -rf $test_dir/tfile.lnk
8704 rm -rf $test_dir/$tfile-2
8708 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8709 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
8710 { skip "Need MDS version at least 2.2.51"; return 0; }
8712 cp /etc/hosts $DIR/$tfile
8714 fid=$($LFS path2fid $DIR/$tfile)
8716 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
8718 dot_lustre_fid_permission_check "$fid" $DIR ||
8719 error "dot lustre permission check $fid failed"
8721 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
8722 chmod 777 $MOUNT/.lustre && error ".lustre is not allowed to be chmod"
8724 touch $MOUNT/.lustre/file &&
8725 error "creation is not allowed under .lustre"
8727 mkdir $MOUNT/.lustre/dir &&
8728 error "mkdir is not allowed under .lustre"
8732 run_test 154a "Open-by-FID"
8735 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8736 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
8737 { skip "Need MDS version at least 2.2.51"; return 0; }
8739 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
8741 local remote_dir=$DIR/$tdir/remote_dir
8746 $LFS mkdir -i $MDTIDX $remote_dir ||
8747 error "create remote directory failed"
8749 cp /etc/hosts $remote_dir/$tfile
8751 fid=$($LFS path2fid $remote_dir/$tfile)
8753 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
8755 dot_lustre_fid_permission_check "$fid" $remote_dir ||
8756 error "dot lustre permission check $fid failed"
8759 run_test 154b "Open-by-FID for remote directory"
8761 test_155_small_load() {
8762 local temp=$TMP/$tfile
8763 local file=$DIR/$tfile
8765 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
8766 error "dd of=$temp bs=6096 count=1 failed"
8768 cancel_lru_locks osc
8769 cmp $temp $file || error "$temp $file differ"
8771 $TRUNCATE $temp 6000
8772 $TRUNCATE $file 6000
8773 cmp $temp $file || error "$temp $file differ (truncate1)"
8775 echo "12345" >>$temp
8776 echo "12345" >>$file
8777 cmp $temp $file || error "$temp $file differ (append1)"
8779 echo "12345" >>$temp
8780 echo "12345" >>$file
8781 cmp $temp $file || error "$temp $file differ (append2)"
8787 test_155_big_load() {
8788 remote_ost_nodsh && skip "remote OST with nodsh" && return
8789 local temp=$TMP/$tfile
8790 local file=$DIR/$tfile
8793 local cache_size=$(do_facet ost$((MAXI+1)) \
8794 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
8795 local large_file_size=$((cache_size * 2))
8797 echo "OSS cache size: $cache_size KB"
8798 echo "Large file size: $large_file_size KB"
8800 [ $MAXV -le $large_file_size ] && \
8801 skip_env "max available OST size needs > $large_file_size KB" && \
8804 $SETSTRIPE $file -c 1 -i $MAXI || error "$SETSTRIPE $file failed"
8806 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k || \
8807 error "dd of=$temp bs=$large_file_size count=1k failed"
8810 cancel_lru_locks osc
8811 cmp $temp $file || error "$temp $file differ"
8818 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8820 set_cache writethrough on
8823 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
8826 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8828 set_cache writethrough off
8831 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
8834 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8836 set_cache writethrough on
8839 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
8842 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8844 set_cache writethrough off
8847 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
8850 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8852 set_cache writethrough on
8855 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
8858 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8860 set_cache writethrough off
8863 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
8866 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8868 set_cache writethrough on
8871 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
8874 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8876 set_cache writethrough off
8879 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
8882 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8886 local file="$DIR/$tfile"
8888 [ "$(facet_fstype ost1)" = "zfs" ] &&
8889 skip "LU-1956/LU-2261: stats unimplemented on OSD ZFS" &&
8892 log "Turn on read and write cache"
8894 set_cache writethrough on
8896 log "Write data and read it back."
8897 log "Read should be satisfied from the cache."
8898 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
8900 cancel_lru_locks osc
8901 cat $file >/dev/null
8903 if ! let "AFTER - BEFORE == CPAGES"; then
8904 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
8906 log "cache hits:: before: $BEFORE, after: $AFTER"
8909 log "Read again; it should be satisfied from the cache."
8911 cancel_lru_locks osc
8912 cat $file >/dev/null
8914 if ! let "AFTER - BEFORE == CPAGES"; then
8915 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
8917 log "cache hits:: before: $BEFORE, after: $AFTER"
8921 log "Turn off the read cache and turn on the write cache"
8923 set_cache writethrough on
8925 log "Read again; it should be satisfied from the cache."
8927 cancel_lru_locks osc
8928 cat $file >/dev/null
8930 if ! let "AFTER - BEFORE == CPAGES"; then
8931 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
8933 log "cache hits:: before: $BEFORE, after: $AFTER"
8936 log "Read again; it should not be satisfied from the cache."
8938 cancel_lru_locks osc
8939 cat $file >/dev/null
8941 if ! let "AFTER - BEFORE == 0"; then
8942 error "IN CACHE: before: $BEFORE, after: $AFTER"
8944 log "cache hits:: before: $BEFORE, after: $AFTER"
8947 log "Write data and read it back."
8948 log "Read should be satisfied from the cache."
8949 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
8951 cancel_lru_locks osc
8952 cat $file >/dev/null
8954 if ! let "AFTER - BEFORE == CPAGES"; then
8955 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
8957 log "cache hits:: before: $BEFORE, after: $AFTER"
8960 log "Read again; it should not be satisfied from the cache."
8962 cancel_lru_locks osc
8963 cat $file >/dev/null
8965 if ! let "AFTER - BEFORE == 0"; then
8966 error "IN CACHE: before: $BEFORE, after: $AFTER"
8968 log "cache hits:: before: $BEFORE, after: $AFTER"
8972 log "Turn off read and write cache"
8974 set_cache writethrough off
8976 log "Write data and read it back"
8977 log "It should not be satisfied from the cache."
8979 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
8980 cancel_lru_locks osc
8982 cat $file >/dev/null
8984 if ! let "AFTER - BEFORE == 0"; then
8985 error_ignore 20762 "IN CACHE: before: $BEFORE, after: $AFTER"
8987 log "cache hits:: before: $BEFORE, after: $AFTER"
8991 log "Turn on the read cache and turn off the write cache"
8993 set_cache writethrough off
8995 log "Write data and read it back"
8996 log "It should not be satisfied from the cache."
8998 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
9000 cancel_lru_locks osc
9001 cat $file >/dev/null
9003 if ! let "AFTER - BEFORE == 0"; then
9004 error_ignore 20762 "IN CACHE: before: $BEFORE, after: $AFTER"
9006 log "cache hits:: before: $BEFORE, after: $AFTER"
9009 log "Read again; it should be satisfied from the cache."
9011 cancel_lru_locks osc
9012 cat $file >/dev/null
9014 if ! let "AFTER - BEFORE == CPAGES"; then
9015 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9017 log "cache hits:: before: $BEFORE, after: $AFTER"
9022 run_test 156 "Verification of tunables ============================"
9026 if [ $MDSCOUNT -gt 1 ]; then
9027 error_ignore 17935 $*
9035 MASK=$(do_facet $SINGLEMDS $LCTL get_param mdd.$MDT0.changelog_mask |\
9038 if [ $MASK -eq 1 ]; then
9039 do_facet $SINGLEMDS $LCTL set_param mdd.$MDT0.changelog_mask="-$1"
9041 do_facet $SINGLEMDS $LCTL set_param mdd.$MDT0.changelog_mask="+$1"
9046 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9047 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9048 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
9049 { skip "Need MDS version at least 2.2.0"; return; }
9050 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
9051 echo "Registered as changelog user $USER"
9052 do_facet $SINGLEMDS $LCTL get_param -n mdd.$MDT0.changelog_users | \
9053 grep -q $USER || error "User $USER not found in changelog_users"
9056 test_mkdir -p $DIR/$tdir/pics/2008/zachy
9057 touch $DIR/$tdir/pics/2008/zachy/timestamp
9058 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
9059 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
9060 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
9061 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
9062 rm $DIR/$tdir/pics/desktop.jpg
9064 $LFS changelog $MDT0 | tail -5
9066 echo "verifying changelog mask"
9067 changelog_chmask "MKDIR"
9068 changelog_chmask "CLOSE"
9070 test_mkdir -p $DIR/$tdir/pics/zach/sofia
9071 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
9073 changelog_chmask "MKDIR"
9074 changelog_chmask "CLOSE"
9076 test_mkdir -p $DIR/$tdir/pics/2008/sofia
9077 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
9079 $LFS changelog $MDT0
9080 MKDIRS=$($LFS changelog $MDT0 | tail -5 | grep -c "MKDIR")
9081 CLOSES=$($LFS changelog $MDT0 | tail -5 | grep -c "CLOSE")
9082 [ $MKDIRS -eq 1 ] || err17935 "MKDIR changelog mask count $DIRS != 1"
9083 [ $CLOSES -eq 1 ] || err17935 "CLOSE changelog mask count $DIRS != 1"
9086 echo "verifying target fid"
9087 fidc=$($LFS changelog $MDT0 | grep timestamp | grep "CREAT" | \
9088 tail -1 | awk '{print $6}')
9089 fidf=$($LFS path2fid $DIR/$tdir/pics/zach/timestamp)
9090 [ "$fidc" == "t=$fidf" ] || \
9091 err17935 "fid in changelog $fidc != file fid $fidf"
9092 echo "verifying parent fid"
9093 fidc=$($LFS changelog $MDT0 | grep timestamp | grep "CREAT" | \
9094 tail -1 | awk '{print $7}')
9095 fidf=$($LFS path2fid $DIR/$tdir/pics/zach)
9096 [ "$fidc" == "p=$fidf" ] || \
9097 err17935 "pfid in changelog $fidc != dir fid $fidf"
9099 USER_REC1=$(do_facet $SINGLEMDS $LCTL get_param -n \
9100 mdd.$MDT0.changelog_users | grep $USER | awk '{print $2}')
9101 $LFS changelog_clear $MDT0 $USER $(($USER_REC1 + 5))
9102 USER_REC2=$(do_facet $SINGLEMDS $LCTL get_param -n \
9103 mdd.$MDT0.changelog_users | grep $USER | awk '{print $2}')
9104 echo "verifying user clear: $(( $USER_REC1 + 5 )) == $USER_REC2"
9105 [ $USER_REC2 == $(($USER_REC1 + 5)) ] || \
9106 err17935 "user index should be $(($USER_REC1 + 5)); is $USER_REC2"
9108 MIN_REC=$(do_facet $SINGLEMDS $LCTL get_param mdd.$MDT0.changelog_users | \
9109 awk 'min == "" || $2 < min {min = $2}; END {print min}')
9110 FIRST_REC=$($LFS changelog $MDT0 | head -1 | awk '{print $1}')
9111 echo "verifying min purge: $(( $MIN_REC + 1 )) == $FIRST_REC"
9112 [ $FIRST_REC == $(($MIN_REC + 1)) ] || \
9113 err17935 "first index should be $(($MIN_REC + 1)); is $FIRST_REC"
9115 echo "verifying user deregister"
9116 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
9117 do_facet $SINGLEMDS $LCTL get_param -n mdd.$MDT0.changelog_users | \
9118 grep -q $USER && error "User $USER still found in changelog_users"
9120 USERS=$(( $(do_facet $SINGLEMDS $LCTL get_param -n \
9121 mdd.$MDT0.changelog_users | wc -l) - 2 ))
9122 if [ $USERS -eq 0 ]; then
9123 LAST_REC1=$(do_facet $SINGLEMDS $LCTL get_param -n \
9124 mdd.$MDT0.changelog_users | head -1 | awk '{print $3}')
9125 touch $DIR/$tdir/chloe
9126 LAST_REC2=$(do_facet $SINGLEMDS $LCTL get_param -n \
9127 mdd.$MDT0.changelog_users | head -1 | awk '{print $3}')
9128 echo "verify changelogs are off if we were the only user: $LAST_REC1 == $LAST_REC2"
9129 [ $LAST_REC1 == $LAST_REC2 ] || error "changelogs not off"
9131 echo "$USERS other changelog users; can't verify off"
9134 run_test 160 "changelog sanity"
9137 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9138 test_mkdir -p $DIR/$tdir
9139 cp /etc/hosts $DIR/$tdir/$tfile
9140 test_mkdir $DIR/$tdir/foo1
9141 test_mkdir $DIR/$tdir/foo2
9142 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
9143 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
9144 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
9145 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
9146 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
9147 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
9148 $LFS fid2path $DIR $FID
9149 err17935 "bad link ea"
9152 rm $DIR/$tdir/foo2/zachary
9154 rm $DIR/$tdir/foo2/thor
9156 rm $DIR/$tdir/$tfile
9158 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
9159 if [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ]
9161 $LFS fid2path $DIR $FID
9162 err17935 "bad link rename"
9164 rm $DIR/$tdir/foo2/maggie
9167 local longname=filename_avg_len_is_thirty_two_
9168 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 || \
9169 error "failed to hardlink many files"
9170 links=$($LFS fid2path $DIR $FID | wc -l)
9171 echo -n "${links}/1000 links in link EA"
9172 [ ${links} -gt 60 ] || err17935 "expected at least 60 links in link EA"
9173 unlinkmany $DIR/$tdir/foo2/$longname 1000 || \
9174 error "failed to unlink many hardlinks"
9176 run_test 161a "link ea sanity"
9179 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9180 [ $MDSCOUNT -lt 2 ] &&
9181 skip "skipping remote directory test" && return
9183 local remote_dir=$DIR/$tdir/remote_dir
9186 $LFS mkdir -i $MDTIDX $remote_dir ||
9187 error "create remote directory failed"
9189 cp /etc/hosts $remote_dir/$tfile
9190 mkdir -p $remote_dir/foo1
9191 mkdir -p $remote_dir/foo2
9192 ln $remote_dir/$tfile $remote_dir/foo1/sofia
9193 ln $remote_dir/$tfile $remote_dir/foo2/zachary
9194 ln $remote_dir/$tfile $remote_dir/foo1/luna
9195 ln $remote_dir/$tfile $remote_dir/foo2/thor
9197 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
9199 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
9200 $LFS fid2path $DIR $FID
9201 err17935 "bad link ea"
9204 rm $remote_dir/foo2/zachary
9206 rm $remote_dir/foo2/thor
9208 rm $remote_dir/$tfile
9210 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
9211 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
9212 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
9213 $LFS fid2path $DIR $FID
9214 err17935 "bad link rename"
9216 rm $remote_dir/foo2/maggie
9219 local longname=filename_avg_len_is_thirty_two_
9220 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
9221 error "failed to hardlink many files"
9222 links=$($LFS fid2path $DIR $FID | wc -l)
9223 echo -n "${links}/1000 links in link EA"
9224 [ ${links} -gt 60 ] || err17935 "expected at least 60 links in link EA"
9225 unlinkmany $remote_dir/foo2/$longname 1000 ||
9226 error "failed to unlink many hardlinks"
9228 run_test 161b "link ea sanity under remote directory"
9235 local path=$(${LFS} fid2path $*)
9238 if [ $RC -ne 0 ]; then
9239 err17935 "path looked up of $expected failed. Error $RC"
9241 elif [ "${path}" != "${expected}" ]; then
9242 err17935 "path looked up \"${path}\" instead of \"${expected}\""
9245 echo "fid $fid resolves to path $path (expected $expected)"
9249 # Make changes to filesystem
9250 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9251 test_mkdir -p $DIR/$tdir/d2
9252 touch $DIR/$tdir/d2/$tfile
9253 touch $DIR/$tdir/d2/x1
9254 touch $DIR/$tdir/d2/x2
9255 test_mkdir -p $DIR/$tdir/d2/a/b/c
9256 test_mkdir -p $DIR/$tdir/d2/p/q/r
9258 FID=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
9259 check_path "$tdir/d2/$tfile" $FSNAME $FID --link 0
9262 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
9263 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
9264 check_path "$tdir/d2/p/q/r/slink" $FSNAME $FID --link 0
9266 # softlink to wrong file
9267 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
9268 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
9269 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME $FID --link 0
9272 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
9273 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
9274 FID=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
9275 # fid2path dir/fsname should both work
9276 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 1
9277 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR $FID --link 0
9279 # hardlink count: check that there are 2 links
9280 # Doesnt work with CMD yet: 17935
9281 ${LFS} fid2path $DIR $FID | wc -l | grep -q 2 || \
9282 err17935 "expected 2 links"
9284 # hardlink indexing: remove the first link
9285 rm $DIR/$tdir/d2/p/q/r/hlink
9286 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 0
9290 run_test 162 "path lookup sanity"
9293 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9294 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9295 copytool --test $FSNAME || { skip "copytool not runnable: $?" && return; }
9298 local uuid=$($LCTL get_param -n mdc.${FSNAME}-MDT0000-mdc-*.uuid)
9299 # this proc file is temporary and linux-only
9300 do_facet $SINGLEMDS lctl set_param mdt.${FSNAME}-MDT0000.mdccomm=$uuid ||\
9301 error "kernel->userspace send failed"
9304 run_test 163 "kernel <-> userspace comms"
9307 # do directio so as not to populate the page cache
9308 log "creating a 10 Mb file"
9309 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
9310 log "starting reads"
9311 dd if=$DIR/$tfile of=/dev/null bs=4096 &
9312 log "truncating the file"
9313 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
9315 kill %+ || true # reads might have finished
9316 echo "wait until dd is finished"
9318 log "removing the temporary file"
9319 rm -rf $DIR/$tfile || error "tmp file removal failed"
9321 run_test 169 "parallel read and truncate should not deadlock"
9324 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9325 $LCTL clear # bug 18514
9326 $LCTL debug_daemon start $TMP/${tfile}_log_good
9328 $LCTL debug_daemon stop
9329 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
9330 error "sed failed to read log_good"
9332 $LCTL debug_daemon start $TMP/${tfile}_log_good
9334 $LCTL debug_daemon stop
9336 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
9337 error "lctl df log_bad failed"
9339 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
9340 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
9342 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
9343 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
9345 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
9346 error "bad_line good_line1 good_line2 are empty"
9348 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
9349 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
9350 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
9352 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
9353 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
9354 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
9356 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
9357 error "bad_line_new good_line_new are empty"
9359 local expected_good=$((good_line1 + good_line2*2))
9361 rm -f $TMP/${tfile}*
9362 # LU-231, short malformed line may not be counted into bad lines
9363 if [ $bad_line -ne $bad_line_new ] &&
9364 [ $bad_line -ne $((bad_line_new - 1)) ]; then
9365 error "expected $bad_line bad lines, but got $bad_line_new"
9369 if [ $expected_good -ne $good_line_new ]; then
9370 error "expected $expected_good good lines, but got $good_line_new"
9375 run_test 170 "test lctl df to handle corrupted log ====================="
9377 test_171() { # bug20592
9378 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9379 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
9380 $LCTL set_param fail_loc=0x50e
9381 $LCTL set_param fail_val=3000
9382 multiop_bg_pause $DIR/$tfile O_s || true
9384 kill -USR1 $MULTIPID
9388 if dmesg | grep "recursive fault"; then
9389 error "caught a recursive fault"
9391 $LCTL set_param fail_loc=0
9394 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
9396 # it would be good to share it with obdfilter-survey/libecho code
9397 setup_obdecho_osc () {
9400 local obdfilter_name=$2
9401 echo "Creating new osc for $obdfilter_name on $ost_nid"
9402 # make sure we can find loopback nid
9403 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
9405 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
9406 ${obdfilter_name}_osc_UUID || rc=2; }
9407 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
9408 ${obdfilter_name}_UUID $ost_nid || rc=3; }
9412 cleanup_obdecho_osc () {
9413 local obdfilter_name=$1
9414 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
9415 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
9419 obdecho_create_test() {
9424 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
9425 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
9427 if [ $rc -eq 0 ]; then
9428 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
9429 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
9431 echo "New object id is $id"
9432 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec test_brw 10 w v 64 $id" ||
9434 [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec " \
9435 "cleanup" || rc=5; }
9436 [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec " \
9438 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
9443 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9444 remote_ost_nodsh && skip "remote OST with nodsh" && return
9448 if ! module_loaded obdecho; then
9449 load_module obdecho/obdecho
9453 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
9454 local host=$(lctl get_param -n osc.$osc.import |
9455 awk '/current_connection:/ {print $2}' )
9456 local target=$(lctl get_param -n osc.$osc.import |
9457 awk '/target:/ {print $2}' )
9458 target=${target%_UUID}
9460 [[ -n $target ]] && { setup_obdecho_osc $host $target || rc=1; } || rc=1
9461 [ $rc -eq 0 ] && { obdecho_create_test ${target}_osc client || rc=2; }
9462 [[ -n $target ]] && cleanup_obdecho_osc $target
9463 [ $rmmod_local -eq 1 ] && rmmod obdecho
9466 run_test 180a "test obdecho on osc"
9469 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9470 remote_ost_nodsh && skip "remote OST with nodsh" && return
9472 local rmmod_remote=0
9474 do_facet ost1 "lsmod | grep -q obdecho || " \
9475 "{ insmod ${LUSTRE}/obdecho/obdecho.ko || " \
9476 "modprobe obdecho; }" && rmmod_remote=1
9477 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ {print $4;exit}')
9478 [[ -n $target ]] && { obdecho_create_test $target ost1 || rc=1; }
9479 [ $rmmod_remote -eq 1 ] && do_facet ost1 "rmmod obdecho"
9482 run_test 180b "test obdecho directly on obdfilter"
9484 test_181() { # bug 22177
9485 test_mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
9486 # create enough files to index the directory
9487 createmany -o $DIR/$tdir/foobar 4000
9488 # print attributes for debug purpose
9491 multiop_bg_pause $DIR/$tdir D_Sc || return 1
9493 # remove the files & current working dir
9494 unlinkmany $DIR/$tdir/foobar 4000
9496 kill -USR1 $MULTIPID
9498 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
9501 run_test 181 "Test open-unlinked dir ========================"
9504 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9505 # disable MDC RPC lock wouldn't crash client
9509 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
9510 #define OBD_FAIL_MDC_RPCS_SEM 0x804
9511 $LCTL set_param fail_loc=0x804
9513 for (( i=0; i < $tcount; i++ )) ; do
9515 createmany -o $DIR/$tdir/$i/f- $fcount &
9519 for (( i=0; i < $tcount; i++ )) ; do
9520 unlinkmany $DIR/$tdir/$i/f- $fcount &
9526 $LCTL set_param fail_loc=0
9528 run_test 182 "Disable MDC RPCs semaphore wouldn't crash client ================"
9530 test_183() { # LU-2275
9531 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9532 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
9533 echo aaa > $DIR/$tdir/$tfile
9535 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
9536 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
9538 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
9539 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
9541 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
9543 # Flush negative dentry cache
9544 touch $DIR/$tdir/$tfile
9546 # We are not checking for any leaked references here, they'll
9547 # become evident next time we do cleanup with module unload.
9550 run_test 183 "No crash or request leak in case of strange dispositions ========"
9552 # test suite 184 is for LU-2016, LU-2017
9554 check_swap_layouts_support && return 0
9556 dir0=$DIR/$tdir/$testnum
9557 test_mkdir -p $dir0 || error "creating dir $dir0"
9562 $SETSTRIPE -c1 $file1
9564 $SETSTRIPE -c2 $file2
9566 gen1=$($GETSTRIPE -g $file1)
9567 gen2=$($GETSTRIPE -g $file2)
9569 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
9570 gen=$($GETSTRIPE -g $file1)
9571 [[ $gen1 != $gen ]] ||
9572 "Layout generation on $file1 does not change"
9573 gen=$($GETSTRIPE -g $file2)
9574 [[ $gen2 != $gen ]] ||
9575 "Layout generation on $file2 does not change"
9577 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
9578 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
9580 run_test 184a "Basic layout swap"
9583 check_swap_layouts_support && return 0
9585 dir0=$DIR/$tdir/$testnum
9586 mkdir -p $dir0 || error "creating dir $dir0"
9593 $SETSTRIPE -c1 $file1
9594 $SETSTRIPE -c2 $file2
9595 $SETSTRIPE -c1 $file3
9596 chown $RUNAS_ID $file3
9597 gen1=$($GETSTRIPE -g $file1)
9598 gen2=$($GETSTRIPE -g $file2)
9600 $LFS swap_layouts $dir1 $dir2 &&
9601 error "swap of directories layouts should fail"
9602 $LFS swap_layouts $dir1 $file1 &&
9603 error "swap of directory and file layouts should fail"
9604 $RUNAS $LFS swap_layouts $file1 $file2 &&
9605 error "swap of file we cannot write should fail"
9606 $LFS swap_layouts $file1 $file3 &&
9607 error "swap of file with different owner should fail"
9608 /bin/true # to clear error code
9610 run_test 184b "Forbidden layout swap (will generate errors)"
9613 check_swap_layouts_support && return 0
9615 local dir0=$DIR/$tdir/$testnum
9616 mkdir -p $dir0 || error "creating dir $dir0"
9618 local ref1=$dir0/ref1
9619 local ref2=$dir0/ref2
9620 local file1=$dir0/file1
9621 local file2=$dir0/file2
9622 # create a file large enough for the concurent test
9623 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
9624 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
9625 echo "ref file size: ref1(`stat -c %s $ref1`), ref2(`stat -c %s $ref2`)"
9628 dd if=$ref1 of=$file1 bs=16k &
9631 # Make sure dd starts to copy file
9632 while [ ! -f $file1 ]; do sleep 0.1; done
9634 $LFS swap_layouts $file1 $file2
9637 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
9638 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
9640 # how many bytes copied before swapping layout
9641 local copied=`stat -c %s $file2`
9642 local remaining=`stat -c %s $ref1`
9643 remaining=$((remaining - copied))
9644 echo "Copied $copied bytes before swapping layout..."
9646 cmp -n $copied $file1 $ref2 | grep differ &&
9647 error "Content mismatch [0, $copied) of ref2 and file1"
9648 cmp -n $copied $file2 $ref1 ||
9649 error "Content mismatch [0, $copied) of ref1 and file2"
9650 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
9651 error "Content mismatch [$copied, EOF) of ref1 and file1"
9654 rm -f $ref1 $ref2 $file1 $file2
9656 run_test 184c "Concurrent write and layout swap"
9658 test_185() { # LU-2441
9659 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
9660 touch $DIR/$tdir/spoo
9661 local mtime1=$(stat -c "%Y" $DIR/$tdir)
9662 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
9663 error "cannot create/write a volatile file"
9664 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
9665 error "FID is still valid after close"
9667 multiop_bg_pause $DIR/$tdir vVw4096_c
9674 # assume that the next FID for this client is sequential, since stdout
9675 # is unfortunately eaten by multiop_bg_pause
9676 local n=$((${fidv[1]} + 1))
9677 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
9678 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
9679 error "FID is missing before close"
9680 kill -USR1 $multi_pid
9681 # 1 second delay, so if mtime change we will see it
9683 local mtime2=$(stat -c "%Y" $DIR/$tdir)
9684 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
9686 run_test 185 "Volatile file support"
9689 check_file_in_pool()
9694 local res=$($GETSTRIPE $file | grep 0x | cut -f2)
9697 for t in $tlist ; do
9698 [ "$i" -eq "$t" ] && continue 2
9701 echo "pool list: $tlist"
9702 echo "striping: $res"
9703 error_noexit "$file not allocated in $pool"
9710 echo "Creating new pool"
9713 create_pool $FSNAME.$pool ||
9714 { error_noexit "No pool created, result code $?"; return 1; }
9715 [ $($LFS pool_list $FSNAME | grep -c $pool) -eq 1 ] ||
9716 { error_noexit "$pool not in lfs pool_list"; return 2; }
9719 pool_add_targets() {
9720 echo "Adding targets to pool"
9726 local list=$(seq $first $step $last)
9728 local t=$(for i in $list; do printf "$FSNAME-OST%04x_UUID " $i; done)
9729 do_facet mgs $LCTL pool_add \
9730 $FSNAME.$pool $FSNAME-OST[$first-$last/$step]
9731 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$pool \
9732 | sort -u | tr '\n' ' ' " "$t" || {
9733 error_noexit "Add to pool failed"
9736 local lfscount=$($LFS pool_list $FSNAME.$pool | grep -c "\-OST")
9737 local addcount=$(((last - first) / step + 1))
9738 [ $lfscount -eq $addcount ] || {
9739 error_noexit "lfs pool_list bad ost count" \
9740 "$lfscount != $addcount"
9748 echo "Setting pool on directory $tdir"
9750 $SETSTRIPE -c 2 -p $pool $tdir && return 0
9752 error_noexit "Cannot set pool $pool to $tdir"
9759 echo "Checking pool on directory $tdir"
9761 local res=$($GETSTRIPE --pool $tdir | sed "s/\s*$//")
9762 [ "$res" = "$pool" ] && return 0
9764 error_noexit "Pool on '$tdir' is '$res', not '$pool'"
9768 pool_dir_rel_path() {
9769 echo "Testing relative path works well"
9774 mkdir -p $root/$tdir/$tdir
9776 pool_set_dir $pool $tdir || return 1
9777 pool_set_dir $pool ./$tdir || return 2
9778 pool_set_dir $pool ../$tdir || return 3
9779 pool_set_dir $pool ../$tdir/$tdir || return 4
9780 rm -rf $tdir; cd - > /dev/null
9783 pool_alloc_files() {
9784 echo "Checking files allocation from directory pool"
9791 for i in $(seq -w 1 $count)
9793 local file=$tdir/file-$i
9795 check_file_in_pool $file $pool "$tlist" || \
9796 failed=$((failed + 1))
9798 [ "$failed" = 0 ] && return 0
9800 error_noexit "$failed files not allocated in $pool"
9804 pool_create_files() {
9805 echo "Creating files in pool"
9813 for i in $(seq -w 1 $count)
9815 local file=$tdir/spoo-$i
9816 $SETSTRIPE -p $pool $file
9817 check_file_in_pool $file $pool "$tlist" || \
9818 failed=$((failed + 1))
9820 [ "$failed" = 0 ] && return 0
9822 error_noexit "$failed files not allocated in $pool"
9827 echo "Checking 'lfs df' output"
9830 local t=$($LCTL get_param -n lov.$FSNAME-clilov-*.pools.$pool |
9832 local res=$($LFS df --pool $FSNAME.$pool |
9834 grep "$FSNAME-OST" |
9836 [ "$res" = "$t" ] && return 0
9838 error_noexit "Pools OSTs '$t' is not '$res' that lfs df reports"
9842 pool_file_rel_path() {
9843 echo "Creating files in a pool with relative pathname"
9848 { error_noexit "unable to create $tdir"; return 1 ; }
9849 local file="/..$tdir/$tfile-1"
9850 $SETSTRIPE -p $pool $file ||
9851 { error_noexit "unable to create $file" ; return 2 ; }
9854 $SETSTRIPE -p $pool $tfile-2 || {
9855 error_noexit "unable to create $tfile-2 in $tdir"
9860 pool_remove_first_target() {
9861 echo "Removing first target from a pool"
9864 local pname="lov.$FSNAME-*.pools.$pool"
9865 local t=$($LCTL get_param -n $pname | head -1)
9866 do_facet mgs $LCTL pool_remove $FSNAME.$pool $t
9867 wait_update $HOSTNAME "lctl get_param -n $pname | grep $t" "" || {
9868 error_noexit "$t not removed from $FSNAME.$pool"
9873 pool_remove_all_targets() {
9874 echo "Removing all targets from pool"
9877 local pname="lov.$FSNAME-*.pools.$pool"
9878 for t in $($LCTL get_param -n $pname | sort -u)
9880 do_facet mgs $LCTL pool_remove $FSNAME.$pool $t
9882 wait_update $HOSTNAME "lctl get_param -n $pname" "" || {
9883 error_noexit "Pool $FSNAME.$pool cannot be drained"
9886 # striping on an empty/nonexistant pool should fall back
9887 # to "pool of everything"
9889 error_noexit "failed to use fallback striping for empty pool"
9892 # setstripe on an empty pool should fail
9893 $SETSTRIPE -p $pool $file 2>/dev/null && {
9894 error_noexit "expected failure when creating file" \
9902 echo "Destroying pool"
9906 do_facet mgs $LCTL pool_destroy $FSNAME.$pool
9909 # striping on an empty/nonexistant pool should fall back
9910 # to "pool of everything"
9912 error_noexit "failed to use fallback striping for missing pool"
9915 # setstripe on an empty pool should fail
9916 $SETSTRIPE -p $pool $file 2>/dev/null && {
9917 error_noexit "expected failure when creating file" \
9922 # get param should return err once pool is gone
9923 if wait_update $HOSTNAME "lctl get_param -n \
9924 lov.$FSNAME-*.pools.$pool 2>/dev/null || echo foo" "foo"
9926 remove_pool_from_list $FSNAME.$pool
9929 error_noexit "Pool $FSNAME.$pool is not destroyed"
9934 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9935 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
9937 local POOL=${POOL:-cea1}
9938 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
9939 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
9942 local last_ost=$(($OSTCOUNT - 1))
9944 local ost_list=$(seq $first_ost $ost_step $last_ost)
9945 local ost_range="$first_ost $last_ost $ost_step"
9946 local test_path=$POOL_ROOT/$POOL_DIR_NAME
9947 local file_dir=$POOL_ROOT/file_tst
9951 # former test_200a test_200b
9952 pool_add $POOL || { rc=$? ; break; }
9953 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
9954 # former test_200c test_200d
9956 pool_set_dir $POOL $test_path || { rc=$? ; break; }
9957 pool_check_dir $POOL $test_path || { rc=$? ; break; }
9958 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
9959 || { rc=$? ; break; }
9960 # former test_200e test_200f
9961 local files=$((OSTCOUNT*3))
9962 pool_alloc_files $POOL $test_path $files "$ost_list" \
9963 || { rc=$? ; break; }
9964 pool_create_files $POOL $file_dir $files "$ost_list" \
9965 || { rc=$? ; break; }
9966 # former test_200g test_200h
9967 pool_lfs_df $POOL || { rc=$? ; break; }
9968 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
9970 # former test_201a test_201b test_201c
9971 pool_remove_first_target $POOL || { rc=$? ; break; }
9973 local f=$test_path/$tfile
9974 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
9975 pool_remove $POOL $f || { rc=$? ; break; }
9982 run_test 200 "OST pools"
9984 # usage: default_attr <count | size | offset>
9986 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
9989 # usage: check_default_stripe_attr
9990 check_default_stripe_attr() {
9991 ACTUAL=$($GETSTRIPE $* $DIR/$tdir)
9993 --stripe-count|--count)
9994 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
9995 --stripe-size|--size)
9996 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
9997 --stripe-index|--index)
10000 error "unknown getstripe attr '$1'"
10003 [ $ACTUAL != $EXPECTED ] &&
10004 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
10008 test_mkdir -p $DIR/$tdir
10009 $SETSTRIPE --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
10011 check_default_stripe_attr --stripe-count
10012 check_default_stripe_attr --stripe-size
10013 check_default_stripe_attr --stripe-index
10017 run_test 204a "Print default stripe attributes ================="
10020 test_mkdir -p $DIR/$tdir
10021 $SETSTRIPE --stripe-count 1 $DIR/$tdir
10023 check_default_stripe_attr --stripe-size
10024 check_default_stripe_attr --stripe-index
10028 run_test 204b "Print default stripe size and offset ==========="
10031 test_mkdir -p $DIR/$tdir
10032 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
10034 check_default_stripe_attr --stripe-count
10035 check_default_stripe_attr --stripe-index
10039 run_test 204c "Print default stripe count and offset ==========="
10042 test_mkdir -p $DIR/$tdir
10043 $SETSTRIPE --stripe-index 0 $DIR/$tdir
10045 check_default_stripe_attr --stripe-count
10046 check_default_stripe_attr --stripe-size
10050 run_test 204d "Print default stripe count and size ============="
10053 test_mkdir -p $DIR/$tdir
10054 $SETSTRIPE -d $DIR/$tdir
10056 check_default_stripe_attr --stripe-count --raw
10057 check_default_stripe_attr --stripe-size --raw
10058 check_default_stripe_attr --stripe-index --raw
10062 run_test 204e "Print raw stripe attributes ================="
10065 test_mkdir -p $DIR/$tdir
10066 $SETSTRIPE --stripe-count 1 $DIR/$tdir
10068 check_default_stripe_attr --stripe-size --raw
10069 check_default_stripe_attr --stripe-index --raw
10073 run_test 204f "Print raw stripe size and offset ==========="
10076 test_mkdir -p $DIR/$tdir
10077 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
10079 check_default_stripe_attr --stripe-count --raw
10080 check_default_stripe_attr --stripe-index --raw
10084 run_test 204g "Print raw stripe count and offset ==========="
10087 test_mkdir -p $DIR/$tdir
10088 $SETSTRIPE --stripe-index 0 $DIR/$tdir
10090 check_default_stripe_attr --stripe-count --raw
10091 check_default_stripe_attr --stripe-size --raw
10095 run_test 204h "Print raw stripe count and size ============="
10097 # Figure out which job scheduler is being used, if any,
10098 # or use a fake one
10099 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
10100 JOBENV=SLURM_JOB_ID
10101 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
10103 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
10105 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
10106 JOBENV=LOADL_STEP_ID
10107 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
10113 verify_jobstats() {
10117 # clear old jobstats
10118 do_facet $SINGLEMDS lctl set_param mdt.*.job_stats="clear"
10119 do_facet ost1 lctl set_param obdfilter.*.job_stats="clear"
10121 # use a new JobID for this test, or we might see an old one
10122 [ "$JOBENV" = "FAKE_JOBID" ] && FAKE_JOBID=test_id.$testnum.$RANDOM
10126 log "Using JobID environment variable $JOBENV=$JOBVAL"
10128 if [ $JOBENV = "FAKE_JOBID" ]; then
10129 FAKE_JOBID=$JOBVAL $cmd
10134 if [ "$target" = "mdt" -o "$target" = "both" ]; then
10135 FACET="$SINGLEMDS" # will need to get MDS number for DNE
10136 do_facet $FACET lctl get_param mdt.*.job_stats |
10137 grep $JOBVAL || error "No job stats found on MDT $FACET"
10139 if [ "$target" = "ost" -o "$target" = "both" ]; then
10141 do_facet $FACET lctl get_param obdfilter.*.job_stats |
10142 grep $JOBVAL || error "No job stats found on OST $FACET"
10148 NEW_JOBENV=${1:-$OLD_JOBENV}
10149 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$NEW_JOBENV
10150 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" $NEW_JOBENV
10153 test_205() { # Job stats
10154 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10155 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
10156 skip "Server doesn't support jobstats" && return 0
10159 OLD_JOBENV=`$LCTL get_param -n jobid_var`
10160 if [ $OLD_JOBENV != $JOBENV ]; then
10161 jobstats_set $JOBENV
10162 trap jobstats_set EXIT
10166 cmd="mkdir $DIR/$tfile"
10167 verify_jobstats "$cmd" "mdt"
10169 cmd="rm -fr $DIR/$tfile"
10170 verify_jobstats "$cmd" "mdt"
10172 cmd="mknod $DIR/$tfile c 1 3"
10173 verify_jobstats "$cmd" "mdt"
10175 cmd="rm -f $DIR/$tfile"
10176 verify_jobstats "$cmd" "mdt"
10178 cmd="$SETSTRIPE -i 0 -c 1 $DIR/$tfile"
10179 verify_jobstats "$cmd" "mdt"
10181 cmd="touch $DIR/$tfile"
10182 verify_jobstats "$cmd" "both"
10184 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
10185 verify_jobstats "$cmd" "ost"
10187 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
10188 verify_jobstats "$cmd" "ost"
10190 cmd="$TRUNCATE $DIR/$tfile 0"
10191 verify_jobstats "$cmd" "both"
10193 cmd="mv -f $DIR/$tfile $DIR/jobstats_test_rename"
10194 verify_jobstats "$cmd" "mdt"
10197 rm -f $DIR/jobstats_test_rename
10199 [ $OLD_JOBENV != $JOBENV ] && jobstats_set $OLD_JOBENV
10201 run_test 205 "Verify job stats"
10203 # LU-1480, LU-1773 and LU-1657
10205 mkdir -p $DIR/$tdir
10206 lfs setstripe -c -1 $DIR/$tdir
10207 #define OBD_FAIL_LOV_INIT 0x1403
10208 $LCTL set_param fail_loc=0xa0001403
10209 $LCTL set_param fail_val=1
10210 touch $DIR/$tdir/$tfile || true
10212 run_test 206 "fail lov_init_raid0() doesn't lbug"
10215 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
10216 local fsz=`stat -c %s $DIR/$tfile`
10217 cancel_lru_locks mdc
10219 # do not return layout in getattr intent
10220 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
10221 $LCTL set_param fail_loc=0x170
10222 local sz=`stat -c %s $DIR/$tfile`
10224 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
10228 run_test 207a "can refresh layout at glimpse"
10231 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
10232 local cksum=`md5sum $DIR/$tfile`
10233 local fsz=`stat -c %s $DIR/$tfile`
10234 cancel_lru_locks mdc
10235 cancel_lru_locks osc
10237 # do not return layout in getattr intent
10238 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
10239 $LCTL set_param fail_loc=0x171
10241 # it will refresh layout after the file is opened but before read issues
10242 echo checksum is "$cksum"
10243 echo "$cksum" |md5sum -c --quiet || error "file differs"
10247 run_test 207b "can refresh layout at open"
10251 size=$((size % 8192 + 1))
10252 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
10253 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
10254 rm -f $DIR/f212 $DIR/f212.xyz
10256 run_test 212 "Sendfile test ============================================"
10259 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
10260 cancel_lru_locks osc
10261 lctl set_param fail_loc=0x8000040f
10262 # generate a read lock
10263 cat $DIR/$tfile > /dev/null
10264 # write to the file, it will try to cancel the above read lock.
10265 cat /etc/hosts >> $DIR/$tfile
10267 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
10269 test_214() { # for bug 20133
10270 test_mkdir -p $DIR/d214p/d214c
10271 for (( i=0; i < 340; i++ )) ; do
10272 touch $DIR/d214p/d214c/a$i
10275 ls -l $DIR/d214p || error "ls -l $DIR/d214p failed"
10276 mv $DIR/d214p/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
10277 ls $DIR/d214c || error "ls $DIR/d214c failed"
10278 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
10280 run_test 214 "hash-indexed directory test - bug 20133"
10282 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
10283 create_lnet_proc_files() {
10284 cat /proc/sys/lnet/$1 >$TMP/lnet_$1.out || error "cannot read /proc/sys/lnet/$1"
10285 sysctl lnet.$1 >$TMP/lnet_$1.sys_tmp || error "cannot read lnet.$1"
10287 sed "s/^lnet.$1\ =\ //g" "$TMP/lnet_$1.sys_tmp" >$TMP/lnet_$1.sys
10288 rm -f "$TMP/lnet_$1.sys_tmp"
10291 # counterpart of create_lnet_proc_files
10292 remove_lnet_proc_files() {
10293 rm -f $TMP/lnet_$1.out $TMP/lnet_$1.sys
10296 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
10297 # 3rd arg as regexp for body
10298 check_lnet_proc_stats() {
10299 local l=$(cat "$TMP/lnet_$1" |wc -l)
10300 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
10302 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
10305 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
10306 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
10307 # optional and can be regexp for 2nd line (lnet.routes case)
10308 check_lnet_proc_entry() {
10309 local blp=2 # blp stands for 'position of 1st line of body'
10310 [ "$5" = "" ] || blp=3 # lnet.routes case
10312 local l=$(cat "$TMP/lnet_$1" |wc -l)
10313 # subtracting one from $blp because the body can be empty
10314 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
10316 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
10317 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
10319 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
10320 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
10322 # bail out if any unexpected line happened
10323 sed -n "$blp~1 p" "$TMP/lnet_$1" |grep -Ev "$3"
10324 [ "$?" != 0 ] || error "$2 misformatted"
10327 test_215() { # for bugs 18102, 21079, 21517
10328 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10329 local N='(0|[1-9][0-9]*)' # non-negative numeric
10330 local P='[1-9][0-9]*' # positive numeric
10331 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
10332 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
10333 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
10334 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
10336 local L1 # regexp for 1st line
10337 local L2 # regexp for 2nd line (optional)
10338 local BR # regexp for the rest (body)
10340 # /proc/sys/lnet/stats should look as 11 space-separated non-negative numerics
10341 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
10342 create_lnet_proc_files "stats"
10343 check_lnet_proc_stats "stats.out" "/proc/sys/lnet/stats" "$BR"
10344 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
10345 remove_lnet_proc_files "stats"
10347 # /proc/sys/lnet/routes should look like this:
10348 # Routing disabled/enabled
10349 # net hops state router
10350 # where net is a string like tcp0, hops >= 0, state is up/down,
10351 # router is a string like 192.168.1.1@tcp2
10352 L1="^Routing (disabled|enabled)$"
10353 L2="^net +hops +state +router$"
10354 BR="^$NET +$N +(up|down) +$NID$"
10355 create_lnet_proc_files "routes"
10356 check_lnet_proc_entry "routes.out" "/proc/sys/lnet/routes" "$BR" "$L1" "$L2"
10357 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
10358 remove_lnet_proc_files "routes"
10360 # /proc/sys/lnet/routers should look like this:
10361 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
10362 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
10363 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
10364 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
10365 L1="^ref +rtr_ref +alive_cnt +state +last_ping +ping_sent +deadline +down_ni +router$"
10366 BR="^$P +$P +$N +(up|down) +$N +(0|1) +$I +$I +$NID$"
10367 create_lnet_proc_files "routers"
10368 check_lnet_proc_entry "routers.out" "/proc/sys/lnet/routers" "$BR" "$L1"
10369 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
10370 remove_lnet_proc_files "routers"
10372 # /proc/sys/lnet/peers should look like this:
10373 # nid refs state last max rtr min tx min queue
10374 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
10375 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
10376 # numeric (0 or >0 or <0), queue >= 0.
10377 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
10378 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
10379 create_lnet_proc_files "peers"
10380 check_lnet_proc_entry "peers.out" "/proc/sys/lnet/peers" "$BR" "$L1"
10381 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
10382 remove_lnet_proc_files "peers"
10384 # /proc/sys/lnet/buffers should look like this:
10385 # pages count credits min
10386 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
10387 L1="^pages +count +credits +min$"
10388 BR="^ +$N +$N +$I +$I$"
10389 create_lnet_proc_files "buffers"
10390 check_lnet_proc_entry "buffers.out" "/proc/sys/lnet/buffers" "$BR" "$L1"
10391 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
10392 remove_lnet_proc_files "buffers"
10394 # /proc/sys/lnet/nis should look like this:
10395 # nid status alive refs peer rtr max tx min
10396 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
10397 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
10398 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
10399 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
10400 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
10401 create_lnet_proc_files "nis"
10402 check_lnet_proc_entry "nis.out" "/proc/sys/lnet/nis" "$BR" "$L1"
10403 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
10404 remove_lnet_proc_files "nis"
10406 # can we successfully write to /proc/sys/lnet/stats?
10407 echo "0" >/proc/sys/lnet/stats || error "cannot write to /proc/sys/lnet/stats"
10408 sysctl -w lnet.stats=0 || error "cannot write to lnet.stats"
10410 run_test 215 "/proc/sys/lnet exists and has proper content - bugs 18102, 21079, 21517"
10412 test_216() { # bug 20317
10413 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10414 remote_ost_nodsh && skip "remote OST with nodsh" && return
10416 local p="$TMP/sanityN-$TESTNAME.parameters"
10417 save_lustre_params $HOSTNAME "osc.*.contention_seconds" > $p
10418 for node in $(osts_nodes); do
10419 save_lustre_params $node "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
10420 save_lustre_params $node "ldlm.namespaces.filter-*.contended_locks" >> $p
10421 save_lustre_params $node "ldlm.namespaces.filter-*.contention_seconds" >> $p
10425 # agressive lockless i/o settings
10426 for node in $(osts_nodes); do
10427 do_node $node 'lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes 2000000; lctl set_param -n ldlm.namespaces.filter-*.contended_locks 0; lctl set_param -n ldlm.namespaces.filter-*.contention_seconds 60'
10429 lctl set_param -n osc.*.contention_seconds 60
10431 $DIRECTIO write $DIR/$tfile 0 10 4096
10432 $CHECKSTAT -s 40960 $DIR/$tfile
10434 # disable lockless i/o
10435 for node in $(osts_nodes); do
10436 do_node $node 'lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes 0; lctl set_param -n ldlm.namespaces.filter-*.contended_locks 32; lctl set_param -n ldlm.namespaces.filter-*.contention_seconds 0'
10438 lctl set_param -n osc.*.contention_seconds 0
10441 dd if=/dev/zero of=$DIR/$tfile count=0
10442 $CHECKSTAT -s 0 $DIR/$tfile
10444 restore_lustre_params <$p
10448 run_test 216 "check lockless direct write works and updates file size and kms correctly"
10450 test_217() { # bug 22430
10451 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10455 for node in $(nodes_list); do
10456 nid=$(host_nids_address $node $NETTYPE)
10457 if [[ $nid = *-* ]] ; then
10458 echo "lctl ping $nid@$NETTYPE"
10459 lctl ping $nid@$NETTYPE
10461 echo "skipping $node (no hyphen detected)"
10465 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
10468 # do directio so as not to populate the page cache
10469 log "creating a 10 Mb file"
10470 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
10471 log "starting reads"
10472 dd if=$DIR/$tfile of=/dev/null bs=4096 &
10473 log "truncating the file"
10474 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
10476 kill %+ || true # reads might have finished
10477 echo "wait until dd is finished"
10479 log "removing the temporary file"
10480 rm -rf $DIR/$tfile || error "tmp file removal failed"
10482 run_test 218 "parallel read and truncate should not deadlock ======================="
10485 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10486 # write one partial page
10487 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
10488 # set no grant so vvp_io_commit_write will do sync write
10489 $LCTL set_param fail_loc=0x411
10490 # write a full page at the end of file
10491 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
10493 $LCTL set_param fail_loc=0
10494 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
10495 $LCTL set_param fail_loc=0x411
10496 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
10498 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
10500 test_220() { #LU-325
10501 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10502 remote_ost_nodsh && skip "remote OST with nodsh" && return
10505 test_mkdir -p $DIR/$tdir
10506 local OST=$(lfs osts | grep ${OSTIDX}": " | \
10507 awk '{print $2}' | sed -e 's/_UUID$//')
10510 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
10511 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
10512 osc.$mdtosc_proc1.prealloc_last_id)
10513 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
10514 osc.$mdtosc_proc1.prealloc_next_id)
10518 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
10519 #define OBD_FAIL_OST_ENOINO 0x229
10520 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
10521 do_facet mgs $LCTL pool_new $FSNAME.$TESTNAME || return 1
10522 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
10524 $SETSTRIPE $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
10526 MDSOBJS=$((last_id - next_id))
10527 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
10529 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
10530 echo "OST still has $count kbytes free"
10532 echo "create $MDSOBJS files @next_id..."
10533 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
10535 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
10536 osc.$mdtosc_proc1.prealloc_last_id)
10537 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
10538 osc.$mdtosc_proc1.prealloc_next_id)
10540 echo "after creation, last_id=$last_id2, next_id=$next_id2"
10545 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
10546 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
10548 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST || return 4
10549 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME || return 5
10550 echo "unlink $MDSOBJS files @$next_id..."
10551 unlinkmany $DIR/$tdir/f $MDSOBJS || return 6
10553 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
10556 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10557 dd if=`which date` of=$MOUNT/date oflag=sync
10558 chmod +x $MOUNT/date
10560 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
10561 $LCTL set_param fail_loc=0x80001401
10563 $MOUNT/date > /dev/null
10566 run_test 221 "make sure fault and truncate race to not cause OOM"
10569 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10571 test_mkdir -p $DIR/$tdir
10572 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
10573 createmany -o $DIR/$tdir/$tfile 10
10574 cancel_lru_locks mdc
10575 cancel_lru_locks osc
10576 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
10577 $LCTL set_param fail_loc=0x31a
10578 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
10579 $LCTL set_param fail_loc=0
10582 run_test 222a "AGL for ls should not trigger CLIO lock failure ================"
10585 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10587 test_mkdir -p $DIR/$tdir
10588 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
10589 createmany -o $DIR/$tdir/$tfile 10
10590 cancel_lru_locks mdc
10591 cancel_lru_locks osc
10592 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
10593 $LCTL set_param fail_loc=0x31a
10594 rm -r $DIR/$tdir || "AGL for rmdir failed"
10595 $LCTL set_param fail_loc=0
10597 run_test 222b "AGL for rmdir should not trigger CLIO lock failure ============="
10600 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10602 test_mkdir -p $DIR/$tdir
10603 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
10604 createmany -o $DIR/$tdir/$tfile 10
10605 cancel_lru_locks mdc
10606 cancel_lru_locks osc
10607 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
10608 $LCTL set_param fail_loc=0x31b
10609 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
10610 $LCTL set_param fail_loc=0
10613 run_test 223 "osc reenqueue if without AGL lock granted ======================="
10615 test_224a() { # LU-1039, MRP-303
10616 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10617 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
10618 $LCTL set_param fail_loc=0x508
10619 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
10620 $LCTL set_param fail_loc=0
10623 run_test 224a "Don't panic on bulk IO failure"
10625 test_224b() { # LU-1039, MRP-303
10626 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10627 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
10628 cancel_lru_locks osc
10629 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
10630 $LCTL set_param fail_loc=0x515
10631 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
10632 $LCTL set_param fail_loc=0
10635 run_test 224b "Don't panic on bulk IO failure"
10637 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
10639 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10640 if [ -z ${MDSSURVEY} ]; then
10641 skip_env "mds-survey not found" && return
10643 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
10644 { skip "Need MDS version at least 2.2.51"; return; }
10646 local mds=$(facet_host $SINGLEMDS)
10647 local target=$(do_nodes $mds 'lctl dl' | \
10648 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
10650 local cmd1="file_count=1000 thrhi=4"
10651 local cmd2="dir_count=2 layer=mdd stripe_count=0"
10652 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
10653 local cmd="$cmd1 $cmd2 $cmd3"
10655 rm -f ${TMP}/mds_survey*
10657 eval $cmd || error "mds-survey with zero-stripe failed"
10658 cat ${TMP}/mds_survey*
10659 rm -f ${TMP}/mds_survey*
10661 run_test 225a "Metadata survey sanity with zero-stripe"
10664 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10665 if [ -z ${MDSSURVEY} ]; then
10666 skip_env "mds-survey not found" && return
10668 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
10669 { skip "Need MDS version at least 2.2.51"; return; }
10671 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
10672 skip_env "Need to mount OST to test" && return
10675 local mds=$(facet_host $SINGLEMDS)
10676 local target=$(do_nodes $mds 'lctl dl' | \
10677 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
10679 local cmd1="file_count=1000 thrhi=4"
10680 local cmd2="dir_count=2 layer=mdd stripe_count=1"
10681 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
10682 local cmd="$cmd1 $cmd2 $cmd3"
10684 rm -f ${TMP}/mds_survey*
10686 eval $cmd || error "mds-survey with stripe_count failed"
10687 cat ${TMP}/mds_survey*
10688 rm -f ${TMP}/mds_survey*
10690 run_test 225b "Metadata survey sanity with stripe_count = 1"
10692 mcreate_path2fid () {
10698 local path=$DIR/$tdir/$name
10703 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
10704 error "cannot create $desc"
10706 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
10708 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
10710 fid_path=$($LFS fid2path $MOUNT $fid)
10712 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
10714 [ "$path" == "$fid_path" ] ||
10715 error "fid2path returned $fid_path, expected $path"
10717 echo "pass with $path and $fid"
10722 mkdir -p $DIR/$tdir
10724 mcreate_path2fid 0010666 0 0 fifo "FIFO"
10725 mcreate_path2fid 0020666 1 3 null "character special file (null)"
10726 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
10727 mcreate_path2fid 0040666 0 0 dir "directory"
10728 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
10729 mcreate_path2fid 0100666 0 0 file "regular file"
10730 mcreate_path2fid 0120666 0 0 link "symbolic link"
10731 mcreate_path2fid 0140666 0 0 sock "socket"
10733 run_test 226a "call path2fid and fid2path on files of all type"
10736 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
10740 mkdir -p $DIR/$tdir
10741 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
10742 error "create remote directory failed"
10743 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
10744 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
10745 "character special file (null)"
10746 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
10747 "character special file (no device)"
10748 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
10749 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
10750 "block special file (loop)"
10751 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
10752 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
10753 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
10755 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
10757 # LU-1299 Executing or running ldd on a truncated executable does not
10758 # cause an out-of-memory condition.
10760 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10761 dd if=`which date` of=$MOUNT/date bs=1k count=1
10762 chmod +x $MOUNT/date
10764 $MOUNT/date > /dev/null
10765 ldd $MOUNT/date > /dev/null
10768 run_test 227 "running truncated executable does not cause OOM"
10770 # LU-1512 try to reuse idle OI blocks
10772 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10773 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
10774 skip "non-ldiskfs backend" && return
10776 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
10777 local myDIR=$DIR/$tdir
10780 #define OBD_FAIL_SEQ_EXHAUST 0x1002
10781 $LCTL set_param fail_loc=0x80001002
10782 createmany -o $myDIR/t- 10000
10783 $LCTL set_param fail_loc=0
10784 # The guard is current the largest FID holder
10786 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
10788 local IDX=$(($SEQ % 64))
10790 do_facet $SINGLEMDS sync
10791 # Make sure journal flushed.
10793 local blk1=$(do_facet $SINGLEMDS \
10794 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
10795 grep Blockcount | awk '{print $4}')
10797 # Remove old files, some OI blocks will become idle.
10798 unlinkmany $myDIR/t- 10000
10799 # Create new files, idle OI blocks should be reused.
10800 createmany -o $myDIR/t- 2000
10801 do_facet $SINGLEMDS sync
10802 # Make sure journal flushed.
10804 local blk2=$(do_facet $SINGLEMDS \
10805 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
10806 grep Blockcount | awk '{print $4}')
10808 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
10810 run_test 228a "try to reuse idle OI blocks"
10813 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10814 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
10815 skip "non-ldiskfs backend" && return
10817 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
10818 local myDIR=$DIR/$tdir
10821 #define OBD_FAIL_SEQ_EXHAUST 0x1002
10822 $LCTL set_param fail_loc=0x80001002
10823 createmany -o $myDIR/t- 10000
10824 $LCTL set_param fail_loc=0
10825 # The guard is current the largest FID holder
10827 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
10829 local IDX=$(($SEQ % 64))
10831 do_facet $SINGLEMDS sync
10832 # Make sure journal flushed.
10834 local blk1=$(do_facet $SINGLEMDS \
10835 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
10836 grep Blockcount | awk '{print $4}')
10838 # Remove old files, some OI blocks will become idle.
10839 unlinkmany $myDIR/t- 10000
10842 stop $SINGLEMDS || error "Fail to stop MDT."
10844 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
10846 df $MOUNT || error "Fail to df."
10847 # Create new files, idle OI blocks should be reused.
10848 createmany -o $myDIR/t- 2000
10849 do_facet $SINGLEMDS sync
10850 # Make sure journal flushed.
10852 local blk2=$(do_facet $SINGLEMDS \
10853 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
10854 grep Blockcount | awk '{print $4}')
10856 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
10858 run_test 228b "idle OI blocks can be reused after MDT restart"
10862 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10863 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
10864 skip "non-ldiskfs backend" && return
10866 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
10867 local myDIR=$DIR/$tdir
10870 #define OBD_FAIL_SEQ_EXHAUST 0x1002
10871 $LCTL set_param fail_loc=0x80001002
10872 # 20000 files can guarantee there are index nodes in the OI file
10873 createmany -o $myDIR/t- 20000
10874 $LCTL set_param fail_loc=0
10875 # The guard is current the largest FID holder
10877 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
10879 local IDX=$(($SEQ % 64))
10881 do_facet $SINGLEMDS sync
10882 # Make sure journal flushed.
10884 local blk1=$(do_facet $SINGLEMDS \
10885 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
10886 grep Blockcount | awk '{print $4}')
10888 # Remove old files, some OI blocks will become idle.
10889 unlinkmany $myDIR/t- 20000
10891 # The OI file should become empty now
10893 # Create new files, idle OI blocks should be reused.
10894 createmany -o $myDIR/t- 2000
10895 do_facet $SINGLEMDS sync
10896 # Make sure journal flushed.
10898 local blk2=$(do_facet $SINGLEMDS \
10899 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
10900 grep Blockcount | awk '{print $4}')
10902 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
10904 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
10907 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10908 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
10911 mkdir -p $DIR/$tdir/test_230_local
10912 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230_local)
10913 [ $mdt_idx -ne 0 ] &&
10914 error "create local directory on wrong MDT $mdt_idx"
10916 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
10917 error "create remote directory failed"
10918 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230)
10919 [ $mdt_idx -ne $MDTIDX ] &&
10920 error "create remote directory on wrong MDT $mdt_idx"
10922 createmany -o $DIR/$tdir/test_230/t- 10 ||
10923 error "create files on remote directory failed"
10924 mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230/t-0)
10925 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
10926 rm -r $DIR/$tdir || error "unlink remote directory failed"
10928 run_test 230a "Create remote directory and files under the remote directory"
10931 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10932 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
10934 local remote_dir=$DIR/$tdir/remote_dir
10937 mkdir -p $DIR/$tdir
10938 $LFS mkdir -i $MDTIDX $remote_dir ||
10939 error "create remote directory failed"
10941 $LFS mkdir -i 0 $remote_dir/new_dir &&
10942 error "nested remote directory create succeed!"
10944 do_facet mds$((MDTIDX + 1)) lctl set_param mdt.*.enable_remote_dir=1
10945 $LFS mkdir -i 0 $remote_dir/new_dir || rc=$?
10946 do_facet mds$((MDTIDX + 1)) lctl set_param mdt.*.enable_remote_dir=0
10949 error "create remote directory failed after set enable_remote_dir"
10951 rm -rf $remote_dir || error "first unlink remote directory failed"
10953 $RUNAS -G$RUNAS_GID $LFS mkdir -i $MDTIDX $DIR/$tfile &&
10954 error "chown worked"
10956 do_facet mds$MDTIDX lctl set_param \
10957 mdt.*.enable_remote_dir_gid=$RUNAS_GID
10958 $LFS mkdir -i $MDTIDX $remote_dir || rc=$?
10959 do_facet mds$MDTIDX lctl set_param mdt.*.enable_remote_dir_gid=0
10962 error "create remote dir failed after set enable_remote_dir_gid"
10964 rm -r $DIR/$tdir || error "second unlink remote directory failed"
10966 run_test 230b "nested remote directory should be failed"
10970 # For simplicity this test assumes that max_pages_per_rpc
10971 # is the same across all OSCs
10972 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -1)
10973 local bulk_size=$((max_pages * 4096))
10975 mkdir -p $DIR/$tdir
10977 # clear the OSC stats
10978 $LCTL set_param osc.*.stats=0 &>/dev/null
10980 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
10981 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
10982 oflag=direct &>/dev/null || error "dd failed"
10984 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
10985 if [ x$nrpcs != "x1" ]; then
10986 error "found $nrpc ost_write RPCs, not 1 as expected"
10989 # Drop the OSC cache, otherwise we will read from it
10990 cancel_lru_locks osc
10992 # clear the OSC stats
10993 $LCTL set_param osc.*.stats=0 &>/dev/null
10995 # Client reads $bulk_size.
10996 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
10997 iflag=direct &>/dev/null || error "dd failed"
10999 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
11000 if [ x$nrpcs != "x1" ]; then
11001 error "found $nrpc ost_read RPCs, not 1 as expected"
11004 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
11007 mkdir -p $DIR/$tdir
11009 for i in {0..1023}; do
11010 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
11011 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
11012 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
11016 run_test 231b "must not assert on fully utilized OST request buffer"
11019 mkdir -p $DIR/$tdir
11020 #define OBD_FAIL_LDLM_OST_LVB 0x31c
11021 $LCTL set_param fail_loc=0x31c
11023 # ignore dd failure
11024 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
11026 $LCTL set_param fail_loc=0
11027 umount_client $MOUNT || error "umount failed"
11028 mount_client $MOUNT || error "mount failed"
11030 run_test 232 "failed lock should not block umount"
11033 # tests that do cleanup/setup should be run at the end
11037 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11039 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
11040 $LCTL set_param fail_loc=0x903
11041 # cancel_lru_locks mgc - does not work due to lctl set_param syntax
11042 for ls in /proc/fs/lustre/ldlm/namespaces/MGC*/lru_size; do
11045 FAIL_ON_ERROR=true cleanup
11046 FAIL_ON_ERROR=true setup
11048 run_test 900 "umount should not race with any mgc requeue thread"
11051 check_and_cleanup_lustre
11052 if [ "$I_MOUNTED" != "yes" ]; then
11053 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true