2 # -*- tab-width: 4; indent-tabs-mode: t; -*-
4 # Run select tests by setting ONLY, or as arguments to the script.
5 # Skip specific tests by setting EXCEPT.
7 # e.g. ONLY="22 23" or ONLY="`seq 32 39`" or EXCEPT="31"
11 # bug number for skipped test: 13297 2108 9789 3637 9789 3561 12622 5188
12 ALWAYS_EXCEPT=" 27u 42a 42b 42c 42d 45 51d 68b $SANITY_EXCEPT"
13 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
15 # with LOD/OSP landing
16 # bug number for skipped tests: LU-2036
17 ALWAYS_EXCEPT=" 76 $ALWAYS_EXCEPT"
20 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 24v 27m 36f 36g 36h 51b 60c 63 64b 68 71 73 77f 78 101a 115 120g 124b"
63 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
64 # bug number for skipped test: LU-2834 LU-1593 LU-2610 LU-2833 LU-1957 LU-2805
65 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 18 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 if [ "$ONLY" == "cleanup" ]; then
97 check_and_setup_lustre
102 MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid | \
103 awk '{gsub(/_UUID/,""); print $1}' | head -1)
104 LOVNAME=$($LCTL get_param -n llite.*.lov.common_name | tail -n 1)
105 OSTCOUNT=$($LCTL get_param -n lov.$LOVNAME.numobd)
106 STRIPECOUNT=$($LCTL get_param -n lov.$LOVNAME.stripecount)
107 STRIPESIZE=$($LCTL get_param -n lov.$LOVNAME.stripesize)
108 ORIGFREE=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
109 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
111 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
112 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
113 rm -rf $DIR/[Rdfs][0-9]*
115 # $RUNAS_ID may get set incorrectly somewhere else
116 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
118 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
122 if [ "${ONLY}" = "MOUNT" ] ; then
123 echo "Lustre is up, please go on"
127 echo "preparing for tests involving mounts"
128 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
130 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
131 echo # add a newline after mke2fs.
135 OLDDEBUG="`lctl get_param -n debug 2> /dev/null`"
136 lctl set_param debug=-1 2> /dev/null || true
139 $CHECKSTAT -t file $DIR/$tfile || error
141 $CHECKSTAT -a $DIR/$tfile || error
143 run_test 0 "touch .../$tfile ; rm .../$tfile ====================="
146 chmod 0755 $DIR || error
147 $CHECKSTAT -p 0755 $DIR || error
149 run_test 0b "chmod 0755 $DIR ============================="
152 $LCTL get_param mdc.*.import | grep "state: FULL" || error "import not FULL"
153 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" || error "bad target"
155 run_test 0c "check import proc ============================="
158 test_mkdir -p $DIR/$tdir
159 test_mkdir -p $DIR/$tdir/d2
160 test_mkdir $DIR/$tdir/d2 && error "we expect EEXIST, but not returned"
161 $CHECKSTAT -t dir $DIR/$tdir/d2 || error
163 run_test 1a "mkdir .../d1; mkdir .../d1/d2 ====================="
168 $CHECKSTAT -a $DIR/$tdir || error
170 run_test 1b "rmdir .../d1/d2; rmdir .../d1 ====================="
173 test_mkdir $DIR/$tdir
174 touch $DIR/$tdir/$tfile
175 $CHECKSTAT -t file $DIR/$tdir/$tfile || error
177 run_test 2a "mkdir .../d2; touch .../d2/f ======================"
181 $CHECKSTAT -a $DIR/$tdir || error
183 run_test 2b "rm -r .../d2; checkstat .../d2/f ======================"
186 test_mkdir -p $DIR/$tdir
187 $CHECKSTAT -t dir $DIR/$tdir || error
189 run_test 3a "mkdir .../d3 ======================================"
192 if [ ! -d $DIR/$tdir ]; then
195 touch $DIR/$tdir/$tfile
196 $CHECKSTAT -t file $DIR/$tdir/$tfile || error
198 run_test 3b "touch .../d3/f ===================================="
202 $CHECKSTAT -a $DIR/$tdir || error
204 run_test 3c "rm -r .../d3 ======================================"
207 test_mkdir -p $DIR/$tdir
208 $CHECKSTAT -t dir $DIR/$tdir || error
210 run_test 4a "mkdir .../d4 ======================================"
213 if [ ! -d $DIR/$tdir ]; then
214 test_mkdir $DIR/$tdir
216 test_mkdir $DIR/$tdir/d2
218 $CHECKSTAT -t dir $DIR/$tdir/d2 || error
220 run_test 4b "mkdir .../d4/d2 ==================================="
223 test_mkdir $DIR/$tdir
224 test_mkdir $DIR/$tdir/d2
225 chmod 0707 $DIR/$tdir/d2
226 $CHECKSTAT -t dir -p 0707 $DIR/$tdir/d2 || error
228 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2 ============"
232 chmod 0666 $DIR/$tfile || error
233 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile || error
235 run_test 6a "touch .../f6a; chmod .../f6a ======================"
238 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
239 if [ ! -f $DIR/$tfile ]; then
241 chmod 0666 $DIR/$tfile
243 $RUNAS chmod 0444 $DIR/$tfile && error
244 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile || error
246 run_test 6b "$RUNAS chmod .../f6a (should return error) =="
249 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
251 chown $RUNAS_ID $DIR/$tfile || error
252 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile || error
254 run_test 6c "touch .../f6c; chown .../f6c ======================"
257 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
258 if [ ! -f $DIR/$tfile ]; then
260 chown $RUNAS_ID $DIR/$tfile
262 $RUNAS chown $UID $DIR/$tfile && error
263 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile || error
265 run_test 6d "$RUNAS chown .../f6c (should return error) =="
268 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
270 chgrp $RUNAS_ID $DIR/$tfile || error
271 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile || error
273 run_test 6e "touch .../f6e; chgrp .../f6e ======================"
276 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
277 if [ ! -f $DIR/$tfile ]; then
279 chgrp $RUNAS_ID $DIR/$tfile
281 $RUNAS chgrp $UID $DIR/$tfile && error
282 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile || error
284 run_test 6f "$RUNAS chgrp .../f6e (should return error) =="
287 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
288 test_mkdir $DIR/$tdir || error
289 chmod 777 $DIR/$tdir || error
290 $RUNAS mkdir $DIR/$tdir/d || error
291 chmod g+s $DIR/$tdir/d || error
292 test_mkdir $DIR/$tdir/d/subdir
293 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir/d/subdir || error
295 run_test 6g "Is new dir in sgid dir inheriting group?"
297 test_6h() { # bug 7331
298 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
299 touch $DIR/$tfile || error "touch failed"
300 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
301 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
303 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/$tfile || error
305 run_test 6h "$RUNAS chown RUNAS_ID.0 .../f6h (should return error)"
308 test_mkdir $DIR/$tdir
309 $MCREATE $DIR/$tdir/$tfile
310 chmod 0666 $DIR/$tdir/$tfile
311 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile || error
313 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
316 if [ ! -d $DIR/$tdir ]; then
319 $MCREATE $DIR/$tdir/$tfile
320 echo -n foo > $DIR/$tdir/$tfile
321 [ "`cat $DIR/$tdir/$tfile`" = "foo" ] || error
322 $CHECKSTAT -t file -s 3 $DIR/$tdir/$tfile || error
324 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
327 test_mkdir $DIR/$tdir
328 touch $DIR/$tdir/$tfile
329 chmod 0666 $DIR/$tdir/$tfile
330 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile || error
332 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
335 test_mkdir $DIR/$tdir
336 test_mkdir $DIR/$tdir/d2
337 test_mkdir $DIR/$tdir/d2/d3
338 $CHECKSTAT -t dir $DIR/$tdir/d2/d3 || error
340 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
343 test_mkdir $DIR/$tdir
344 test_mkdir $DIR/$tdir/d2
345 touch $DIR/$tdir/d2/$tfile
346 $CHECKSTAT -t file $DIR/$tdir/d2/$tfile || error
348 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
351 test_mkdir $DIR/$tdir
352 test_mkdir $DIR/$tdir/d2
353 chmod 0666 $DIR/$tdir/d2
354 chmod 0705 $DIR/$tdir/d2
355 $CHECKSTAT -t dir -p 0705 $DIR/$tdir/d2 || error
357 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
360 test_mkdir $DIR/$tdir
361 touch $DIR/$tdir/$tfile
362 chmod 0666 $DIR/$tdir/$tfile
363 chmod 0654 $DIR/$tdir/$tfile
364 $CHECKSTAT -t file -p 0654 $DIR/$tdir/$tfile || error
366 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
369 test_mkdir $DIR/$tdir
370 dd if=/dev/zero of=$DIR/$tdir/$tfile count=10
372 $CHECKSTAT -t file -s 0 $DIR/$tdir/$tfile || error
374 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
377 test_mkdir $DIR/$tdir
378 touch $DIR/$tdir/$tfile
380 $CHECKSTAT -a $DIR/$tdir/$tfile || error
382 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
385 test_mkdir $DIR/$tdir
386 touch $DIR/$tdir/$tfile
387 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}_2
388 $CHECKSTAT -t file $DIR/$tdir/${tfile}_2 || error
390 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
393 test_mkdir $DIR/$tdir
394 touch $DIR/$tdir/$tfile
395 rm -rf $DIR/$tdir/$tfile
396 $CHECKSTAT -a $DIR/$tdir/$tfile || error
398 run_test 16 "touch .../d16/f; rm -rf .../d16/f ================="
401 test_mkdir -p $DIR/$tdir
402 touch $DIR/$tdir/$tfile
403 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
405 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist || error
406 $CHECKSTAT -f -t f $DIR/$tdir/l-exist || error
407 rm -f $DIR/$tdir/l-exist
408 $CHECKSTAT -a $DIR/$tdir/l-exist || error
410 run_test 17a "symlinks: create, remove (real) =================="
413 test_mkdir -p $DIR/$tdir
414 ln -s no-such-file $DIR/$tdir/l-dangle
416 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle || error
417 $CHECKSTAT -fa $DIR/$tdir/l-dangle || error
418 rm -f $DIR/$tdir/l-dangle
419 $CHECKSTAT -a $DIR/$tdir/l-dangle || error
421 run_test 17b "symlinks: create, remove (dangling) =============="
423 test_17c() { # bug 3440 - don't save failed open RPC for replay
424 test_mkdir -p $DIR/$tdir
425 ln -s foo $DIR/$tdir/$tfile
426 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
428 run_test 17c "symlinks: open dangling (should return error) ===="
431 test_mkdir -p $DIR/$tdir
432 ln -s foo $DIR/$tdir/$tfile
433 touch $DIR/$tdir/$tfile || error "creating to new symlink"
435 run_test 17d "symlinks: create dangling ========================"
438 test_mkdir -p $DIR/$tdir
439 local foo=$DIR/$tdir/$tfile
440 ln -s $foo $foo || error "create symlink failed"
441 ls -l $foo || error "ls -l failed"
442 ls $foo && error "ls not failed" || true
444 run_test 17e "symlinks: create recursive symlink (should return error) ===="
447 test_mkdir -p $DIR/d17f
448 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/d17f/111
449 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/d17f/222
450 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/d17f/333
451 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/d17f/444
452 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/d17f/555
453 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
456 run_test 17f "symlinks: long and very long symlink name ========================"
458 # str_repeat(S, N) generate a string that is string S repeated N times
463 while [ $((n -= 1)) -ge 0 ]; do
469 # Long symlinks and LU-2241
471 test_mkdir -p $DIR/$tdir
472 local TESTS="59 60 61 4094 4095"
475 local SYMNAME=$(str_repeat 'x' $i)
476 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
477 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
480 run_test 17g "symlinks: really long symlink name and inode boundaries"
482 test_17h() { #bug 17378
483 remote_mds_nodsh && skip "remote MDS with nodsh" && return
484 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
486 test_mkdir -p $DIR/$tdir
487 if [ $MDSCOUNT -gt 1 ]; then
488 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
492 $SETSTRIPE -c -1 $DIR/$tdir
493 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
494 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
495 touch $DIR/$tdir/$tfile || true
497 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
499 test_17i() { #bug 20018
500 remote_mds_nodsh && skip "remote MDS with nodsh" && return
501 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
502 test_mkdir -p $DIR/$tdir
503 local foo=$DIR/$tdir/$tfile
505 if [ $MDSCOUNT -gt 1 ]; then
506 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
510 ln -s $foo $foo || error "create symlink failed"
511 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
512 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
513 ls -l $foo && error "error not detected"
516 run_test 17i "don't panic on short symlink"
518 test_17k() { #bug 22301
519 rsync --help | grep -q xattr ||
520 skip_env "$(rsync --version| head -1) does not support xattrs"
521 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
522 test_mkdir -p $DIR/$tdir
523 test_mkdir -p $DIR/$tdir.new
524 touch $DIR/$tdir/$tfile
525 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
526 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
527 error "rsync failed with xattrs enabled"
529 run_test 17k "symlinks: rsync with xattrs enabled ========================="
531 test_17l() { # LU-279
533 touch $DIR/$tdir/$tfile
534 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
535 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
536 # -h to not follow symlinks. -m '' to list all the xattrs.
537 # grep to remove first line: '# file: $path'.
538 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
540 lgetxattr_size_check $path $xattr ||
541 error "lgetxattr_size_check $path $xattr failed"
545 run_test 17l "Ensure lgetxattr's returned xattr size is consistent ========"
549 local short_sym="0123456789"
550 local WDIR=$DIR/${tdir}m
557 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
558 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
559 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
561 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
562 skip "only for ldiskfs MDT" && return 0
564 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
568 # create a long symlink file
569 for ((i = 0; i < 4; ++i)); do
570 long_sym=${long_sym}${long_sym}
573 echo "create 512 short and long symlink files under $WDIR"
574 for ((i = 0; i < 256; ++i)); do
575 ln -sf ${long_sym}"a5a5" $WDIR/long-$i
576 ln -sf ${short_sym}"a5a5" $WDIR/short-$i
582 wait_delete_completed
584 echo "recreate the 512 symlink files with a shorter string"
585 for ((i = 0; i < 512; ++i)); do
586 # rewrite the symlink file with a shorter string
587 ln -sf ${long_sym} $WDIR/long-$i
588 ln -sf ${short_sym} $WDIR/short-$i
591 mds_index=$($LFS getstripe -M $WDIR)
592 mds_index=$((mds_index+1))
593 devname=$(mdsdevname $mds_index)
594 cmd="$E2FSCK -fnvd $devname"
596 echo "stop and checking mds${mds_index}: $cmd"
597 # e2fsck should not return error
598 stop mds${mds_index} -f
599 do_facet mds${mds_index} $cmd || rc=$?
601 start mds${mds_index} $devname $MDS_MOUNT_OPTS
602 df $MOUNT > /dev/null 2>&1
603 [ $rc -ne 0 ] && error "e2fsck should not report error upon "\
604 "short/long symlink MDT: rc=$rc"
607 run_test 17m "run e2fsck against MDT which contains short/long symlink"
609 check_fs_consistency_17n() {
615 for mdt_index in $(seq 1 $MDSCOUNT); do
616 devname=$(mdsdevname $mdt_index)
617 cmd="$E2FSCK -fnvd $devname"
619 echo "stop and checking mds${mdt_index}: $cmd"
620 # e2fsck should not return error
622 do_facet mds${mdt_index} $cmd || rc=$?
624 start mds${mdt_index} $devname $MDS_MOUNT_OPTS
625 df $MOUNT > /dev/null 2>&1
626 [ $rc -ne 0 ] && break
634 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
635 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
636 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
638 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
639 skip "only for ldiskfs MDT" && return 0
641 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
643 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
646 for ((i=0; i<10; i++)); do
647 $LFS mkdir -i 1 $DIR/$tdir/remote_dir_${i} ||
648 error "create remote dir error $i"
649 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
650 error "create files under remote dir failed $i"
653 check_fs_consistency_17n || error "e2fsck report error"
655 for ((i=0;i<10;i++)); do
656 rm -rf $DIR/$tdir/remote_dir_${i} ||
657 error "destroy remote dir error $i"
660 check_fs_consistency_17n || error "e2fsck report error"
662 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
668 run_test 18 "touch .../f ; ls ... =============================="
674 $CHECKSTAT -a $DIR/f19 || error
676 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
679 ls -l $DIR/f19 && error || true
681 run_test 19b "ls -l .../f19 (should return error) =============="
684 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
685 $RUNAS touch $DIR/f19 && error || true
687 run_test 19c "$RUNAS touch .../f19 (should return error) =="
690 cat $DIR/f19 && error || true
692 run_test 19d "cat .../f19 (should return error) =============="
704 $CHECKSTAT -a $DIR/f || error
706 run_test 20 "touch .../f ; ls -l ... ==========================="
710 [ -f $DIR/d21/dangle ] && rm -f $DIR/d21/dangle
711 ln -s dangle $DIR/d21/link
712 echo foo >> $DIR/d21/link
714 $CHECKSTAT -t link $DIR/d21/link || error
715 $CHECKSTAT -f -t file $DIR/d21/link || error
717 run_test 21 "write to dangling link ============================"
721 test_mkdir -p $DIR/$tdir
722 chown $RUNAS_ID:$RUNAS_GID $WDIR
723 (cd $WDIR || error "cd $WDIR failed";
724 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
726 ls -lR $WDIR/etc || error "ls -lR $WDIR/etc failed"
727 $CHECKSTAT -t dir $WDIR/etc || error "checkstat -t dir failed"
728 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $WDIR/etc || error "checkstat -u failed"
730 run_test 22 "unpack tar archive as non-root user ==============="
734 test_mkdir -p $DIR/$tdir
735 local file=$DIR/$tdir/$tfile
737 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
738 openfile -f O_CREAT:O_EXCL $file &&
739 error "$file recreate succeeded" || true
741 run_test 23a "O_CREAT|O_EXCL in subdir =========================="
743 test_23b() { # bug 18988
744 test_mkdir -p $DIR/$tdir
745 local file=$DIR/$tdir/$tfile
748 echo foo > $file || error "write filed"
749 echo bar >> $file || error "append filed"
750 $CHECKSTAT -s 8 $file || error "wrong size"
753 run_test 23b "O_APPEND check =========================="
756 echo '== rename sanity =============================================='
757 echo '-- same directory rename'
760 mv $DIR/R1/f $DIR/R1/g
761 $CHECKSTAT -t file $DIR/R1/g || error
763 run_test 24a "touch .../R1/f; rename .../R1/f .../R1/g ========="
768 mv $DIR/R2/f $DIR/R2/g
769 $CHECKSTAT -a $DIR/R2/f || error
770 $CHECKSTAT -t file $DIR/R2/g || error
772 run_test 24b "touch .../R2/{f,g}; rename .../R2/f .../R2/g ====="
777 mv $DIR/R3/f $DIR/R3/g
778 $CHECKSTAT -a $DIR/R3/f || error
779 $CHECKSTAT -t dir $DIR/R3/g || error
781 run_test 24c "mkdir .../R3/f; rename .../R3/f .../R3/g ========="
787 mrename $DIR/R4/f $DIR/R4/g
788 $CHECKSTAT -a $DIR/R4/f || error
789 $CHECKSTAT -t dir $DIR/R4/g || error
791 run_test 24d "mkdir .../R4/{f,g}; rename .../R4/f .../R4/g ====="
794 echo '-- cross directory renames --'
798 mv $DIR/R5a/f $DIR/R5b/g
799 $CHECKSTAT -a $DIR/R5a/f || error
800 $CHECKSTAT -t file $DIR/R5b/g || error
802 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
807 touch $DIR/R6a/f $DIR/R6b/g
808 mv $DIR/R6a/f $DIR/R6b/g
809 $CHECKSTAT -a $DIR/R6a/f || error
810 $CHECKSTAT -t file $DIR/R6b/g || error
812 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
817 test_mkdir $DIR/R7a/d
818 mv $DIR/R7a/d $DIR/R7b/e
819 $CHECKSTAT -a $DIR/R7a/d || error
820 $CHECKSTAT -t dir $DIR/R7b/e || error
822 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
827 test_mkdir $DIR/R8a/d
828 test_mkdir $DIR/R8b/e
829 mrename $DIR/R8a/d $DIR/R8b/e
830 $CHECKSTAT -a $DIR/R8a/d || error
831 $CHECKSTAT -t dir $DIR/R8b/e || error
833 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
836 echo "-- rename error cases"
840 mrename $DIR/R9/f $DIR/R9/a
841 $CHECKSTAT -t file $DIR/R9/f || error
842 $CHECKSTAT -t dir $DIR/R9/a || error
843 $CHECKSTAT -a $DIR/R9/a/f || error
845 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
849 mrename $DIR/R10/f $DIR/R10/g
850 $CHECKSTAT -t dir $DIR/R10 || error
851 $CHECKSTAT -a $DIR/R10/f || error
852 $CHECKSTAT -a $DIR/R10/g || error
854 run_test 24j "source does not exist ============================"
858 test_mkdir $DIR/R11a/d
860 mv $DIR/R11a/f $DIR/R11a/d
861 $CHECKSTAT -a $DIR/R11a/f || error
862 $CHECKSTAT -t file $DIR/R11a/d/f || error
864 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
866 # bug 2429 - rename foo foo foo creates invalid file
869 $MULTIOP $f OcNs || error
871 run_test 24l "Renaming a file to itself ========================"
875 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
876 # on ext3 this does not remove either the source or target files
877 # though the "expected" operation would be to remove the source
878 $CHECKSTAT -t file ${f} || error "${f} missing"
879 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
881 run_test 24m "Renaming a file to a hard link to itself ========="
885 # this stats the old file after it was renamed, so it should fail
889 $CHECKSTAT ${f}.rename
892 run_test 24n "Statting the old file after renaming (Posix rename 2)"
895 check_kernel_version 37 || return 0
896 test_mkdir -p $DIR/d24o
897 rename_many -s random -v -n 10 $DIR/d24o
899 run_test 24o "rename of files during htree split ==============="
904 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
905 mrename $DIR/R12a $DIR/R12b
906 $CHECKSTAT -a $DIR/R12a || error
907 $CHECKSTAT -t dir $DIR/R12b || error
908 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
909 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
911 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
913 cleanup_multiop_pause() {
919 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
922 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
923 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
926 trap cleanup_multiop_pause EXIT
927 mrename $DIR/R13a $DIR/R13b
928 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
929 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
930 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
931 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
932 cleanup_multiop_pause
933 wait $MULTIPID || error "multiop close failed"
935 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
937 test_24r() { #bug 3789
939 test_mkdir $DIR/R14a/b
940 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
941 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
942 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
944 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
948 test_mkdir $DIR/R15a/b
949 test_mkdir $DIR/R15a/b/c
950 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
951 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
952 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
954 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
957 test_mkdir $DIR/R16a/b
958 test_mkdir $DIR/R16a/b/c
959 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
960 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
961 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
963 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
965 test_24u() { # bug12192
967 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error
968 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
970 run_test 24u "create stripe file"
976 simple_cleanup_common() {
979 wait_delete_completed
982 max_pages_per_rpc() {
983 $LCTL get_param -n mdc.*.max_pages_per_rpc | head -1
988 local FREE_INODES=$(lfs_df -i | grep "summary" | awk '{print $4}')
989 [ $FREE_INODES -lt $NRFILES ] && \
990 skip "not enough free inodes $FREE_INODES required $NRFILES" &&
993 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
994 trap simple_cleanup_common EXIT
997 createmany -m $DIR/$tdir/$tfile $NRFILES
1000 lctl set_param mdc.*.stats clear
1002 ls $DIR/$tdir >/dev/null || error "error in listing large dir"
1004 # LU-5 large readdir
1005 # DIRENT_SIZE = 32 bytes for sizeof(struct lu_dirent) +
1006 # 8 bytes for name(filename is mostly 5 in this test) +
1007 # 8 bytes for luda_type
1008 # take into account of overhead in lu_dirpage header and end mark in
1009 # each page, plus one in RPC_NUM calculation.
1011 RPC_SIZE=$(($(max_pages_per_rpc) * $(page_size)))
1012 RPC_NUM=$(((NRFILES * DIRENT_SIZE + RPC_SIZE - 1) / RPC_SIZE + 1))
1013 mds_readpage=$(lctl get_param mdc.*MDT0000*.stats | \
1014 awk '/^mds_readpage/ {print $2}')
1015 [ $mds_readpage -gt $RPC_NUM ] && \
1016 error "large readdir doesn't take effect"
1018 simple_cleanup_common
1020 run_test 24v "list directory with large files (handle hash collision, bug: 17560)"
1022 test_24w() { # bug21506
1024 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1025 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1026 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1027 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1028 [ "$SZ1" = "$SZ2" ] || \
1029 error "Error reading at the end of the file $tfile"
1031 run_test 24w "Reading a file larger than 4Gb"
1034 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1035 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1037 local remote_dir=$DIR/$tdir/remote_dir
1040 $LFS mkdir -i $MDTIDX $remote_dir ||
1041 error "create remote directory failed"
1043 mkdir -p $DIR/$tdir/src_dir
1044 touch $DIR/$tdir/src_file
1045 mkdir -p $remote_dir/tgt_dir
1046 touch $remote_dir/tgt_file
1048 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir &&
1049 error "rename dir cross MDT works!"
1051 mrename $DIR/$tdir/src_file $remote_dir/tgt_file &&
1052 error "rename file cross MDT works!"
1054 ln $DIR/$tdir/src_file $remote_dir/tgt_file1 &&
1055 error "ln file cross MDT should not work!"
1057 rm -rf $DIR/$tdir || error "Can not delete directories"
1059 run_test 24x "cross rename/link should be failed"
1062 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1063 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1065 local remote_dir=$DIR/$tdir/remote_dir
1068 $LFS mkdir -i $MDTIDX $remote_dir ||
1069 error "create remote directory failed"
1071 mkdir -p $remote_dir/src_dir
1072 touch $remote_dir/src_file
1073 mkdir -p $remote_dir/tgt_dir
1074 touch $remote_dir/tgt_file
1076 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1077 error "rename subdir in the same remote dir failed!"
1079 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1080 error "rename files in the same remote dir failed!"
1082 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1083 error "link files in the same remote dir failed!"
1085 rm -rf $DIR/$tdir || error "Can not delete directories"
1087 run_test 24y "rename/link on the same dir should succeed"
1090 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1091 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1093 local remote_src=$DIR/$tdir/remote_dir
1094 local remote_tgt=$DIR/$tdir/remote_tgt
1097 $LFS mkdir -i $MDTIDX $remote_src ||
1098 error "create remote directory failed"
1100 $LFS mkdir -i $MDTIDX $remote_tgt ||
1101 error "create remote directory failed"
1103 mrename $remote_src $remote_tgt &&
1104 error "rename remote dirs should not work!"
1106 rm -rf $DIR/$tdir || error "Can not delete directories"
1108 run_test 24z "rename one remote dir to another remote dir should fail"
1111 echo '== symlink sanity ============================================='
1115 touch $DIR/s25/foo || error
1117 run_test 25a "create file in symlinked directory ==============="
1120 [ ! -d $DIR/d25 ] && test_25a
1121 $CHECKSTAT -t file $DIR/s25/foo || error
1123 run_test 25b "lookup file in symlinked directory ==============="
1127 test_mkdir $DIR/d26/d26-2
1128 ln -s d26/d26-2 $DIR/s26
1129 touch $DIR/s26/foo || error
1131 run_test 26a "multiple component symlink ======================="
1134 test_mkdir -p $DIR/d26b/d26-2
1135 ln -s d26b/d26-2/foo $DIR/s26-2
1136 touch $DIR/s26-2 || error
1138 run_test 26b "multiple component symlink at end of lookup ======"
1141 test_mkdir $DIR/d26.2
1142 touch $DIR/d26.2/foo
1143 ln -s d26.2 $DIR/s26.2-1
1144 ln -s s26.2-1 $DIR/s26.2-2
1145 ln -s s26.2-2 $DIR/s26.2-3
1146 chmod 0666 $DIR/s26.2-3/foo
1148 run_test 26c "chain of symlinks ================================"
1150 # recursive symlinks (bug 439)
1152 ln -s d26-3/foo $DIR/d26-3
1154 run_test 26d "create multiple component recursive symlink ======"
1157 [ ! -h $DIR/d26-3 ] && test_26d
1160 run_test 26e "unlink multiple component recursive symlink ======"
1162 # recursive symlinks (bug 7022)
1164 test_mkdir -p $DIR/$tdir
1165 test_mkdir $DIR/$tdir/$tfile || error "mkdir $DIR/$tdir/$tfile failed"
1166 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1167 test_mkdir -p lndir bar1 || error "mkdir lndir/bar1 failed"
1168 test_mkdir $DIR/$tdir/$tfile/$tfile || error "mkdir $tfile failed"
1169 cd $tfile || error "cd $tfile failed"
1170 ln -s .. dotdot || error "ln dotdot failed"
1171 ln -s dotdot/lndir lndir || error "ln lndir failed"
1172 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1173 output=`ls $tfile/$tfile/lndir/bar1`
1174 [ "$output" = bar1 ] && error "unexpected output"
1175 rm -r $tfile || error "rm $tfile failed"
1176 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1178 run_test 26f "rm -r of a directory which has recursive symlink ="
1181 echo '== stripe sanity =============================================='
1182 test_mkdir -p $DIR/d27 || error "mkdir failed"
1184 $SETSTRIPE -c 1 $DIR/d27/f0 || error "setstripe failed"
1185 $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
1187 log "== test_27a: write to one stripe file ========================="
1188 cp /etc/hosts $DIR/d27/f0 || error
1190 run_test 27a "one stripe file =================================="
1193 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
1194 test_mkdir -p $DIR/d27
1195 $SETSTRIPE -c 2 $DIR/d27/f01 || error "setstripe failed"
1196 $GETSTRIPE -c $DIR/d27/f01
1197 [ $($GETSTRIPE -c $DIR/d27/f01) -eq 2 ] ||
1198 error "two-stripe file doesn't have two stripes"
1200 run_test 27b "create two stripe file"
1203 [ -f $DIR/d27/f01 ] || skip "test_27b not run" && return
1205 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
1207 run_test 27c "write to two stripe file"
1210 test_mkdir -p $DIR/d27
1211 $SETSTRIPE -c 0 -i -1 -S 0 $DIR/d27/fdef || error "setstripe failed"
1212 $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
1213 dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
1215 run_test 27d "create file with default settings ================"
1218 test_mkdir -p $DIR/d27
1219 $SETSTRIPE -c 2 $DIR/d27/f12 || error "setstripe failed"
1220 $SETSTRIPE -c 2 $DIR/d27/f12 && error "setstripe succeeded twice"
1221 $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
1223 run_test 27e "setstripe existing file (should return error) ======"
1226 test_mkdir -p $DIR/d27
1227 $SETSTRIPE -S 100 -i 0 -c 1 $DIR/d27/fbad && error "setstripe failed"
1228 dd if=/dev/zero of=$DIR/d27/f12 bs=4k count=4 || error "dd failed"
1229 $GETSTRIPE $DIR/d27/fbad || error "$GETSTRIPE failed"
1231 run_test 27f "setstripe with bad stripe size (should return error)"
1234 test_mkdir -p $DIR/d27
1235 $MCREATE $DIR/d27/fnone || error "mcreate failed"
1236 $GETSTRIPE $DIR/d27/fnone 2>&1 | grep "no stripe info" ||
1237 error "$DIR/d27/fnone has object"
1239 run_test 27g "$GETSTRIPE with no objects"
1242 touch $DIR/d27/fsome || error "touch failed"
1243 [ $($GETSTRIPE -c $DIR/d27/fsome) -gt 0 ] || error "missing objects"
1245 run_test 27i "$GETSTRIPE with some objects"
1248 test_mkdir -p $DIR/d27
1249 $SETSTRIPE -i $OSTCOUNT $DIR/d27/f27j && error "setstripe failed"||true
1251 run_test 27j "setstripe with bad stripe offset (should return error)"
1253 test_27k() { # bug 2844
1254 test_mkdir -p $DIR/d27
1256 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
1257 [ ! -d $DIR/d27 ] && test_mkdir -p $DIR d27
1258 $SETSTRIPE -S 67108864 $FILE || error "setstripe failed"
1259 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1260 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
1261 dd if=/dev/zero of=$FILE bs=4k count=1
1262 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1263 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
1265 run_test 27k "limit i_blksize for broken user apps ============="
1268 test_mkdir -p $DIR/d27
1269 mcreate $DIR/f27l || error "creating file"
1270 $RUNAS $SETSTRIPE -c 1 $DIR/f27l && \
1271 error "setstripe should have failed" || true
1273 run_test 27l "check setstripe permissions (should return error)"
1276 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" &&
1278 if [ $ORIGFREE -gt $MAXFREE ]; then
1279 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1282 trap simple_cleanup_common EXIT
1283 test_mkdir -p $DIR/$tdir
1284 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_1
1285 dd if=/dev/zero of=$DIR/$tdir/f27m_1 bs=1024 count=$MAXFREE &&
1286 error "dd should fill OST0"
1288 while $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_$i; do
1290 [ $i -gt 256 ] && break
1293 touch $DIR/$tdir/f27m_$i
1294 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1295 error "OST0 was full but new created file still use it"
1297 touch $DIR/$tdir/f27m_$i
1298 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1299 error "OST0 was full but new created file still use it"
1300 simple_cleanup_common
1302 run_test 27m "create file while OST0 was full =================="
1305 local DELAY=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage | head -n 1 | awk '{print $1 * 2}')
1309 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1310 # if the OST isn't full anymore.
1312 local OSTIDX=${1:-""}
1314 local list=$(comma_list $(osts_nodes))
1315 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1317 do_nodes $list lctl set_param fail_loc=0
1318 sync # initiate all OST_DESTROYs from MDS to OST
1322 exhaust_precreations() {
1325 local FAILIDX=${3:-$OSTIDX}
1327 test_mkdir -p $DIR/$tdir
1328 local MDSIDX=$(get_mds_dir "$DIR/$tdir")
1329 echo OSTIDX=$OSTIDX MDSIDX=$MDSIDX
1331 local OST=$(ostname_from_index $OSTIDX)
1332 local MDT_INDEX=$(lfs df | grep "\[MDT:$((MDSIDX - 1))\]" | awk '{print $1}' | \
1333 sed -e 's/_UUID$//;s/^.*-//')
1336 local mdtosc_proc1=$(get_mdtosc_proc_path mds${MDSIDX} $OST)
1337 local last_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1338 osc.$mdtosc_proc1.prealloc_last_id)
1339 local next_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1340 osc.$mdtosc_proc1.prealloc_next_id)
1342 local mdtosc_proc2=$(get_mdtosc_proc_path mds${MDSIDX})
1343 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1345 test_mkdir -p $DIR/$tdir/${OST}
1346 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1347 #define OBD_FAIL_OST_ENOSPC 0x215
1348 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=$FAILIDX
1349 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x215
1350 echo "Creating to objid $last_id on ost $OST..."
1351 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1352 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1353 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=$FAILLOC
1357 exhaust_all_precreations() {
1359 for (( i=0; i < OSTCOUNT; i++ )) ; do
1360 exhaust_precreations $i $1 -1
1365 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1366 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1367 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1368 remote_ost_nodsh && skip "remote OST with nodsh" && return
1371 rm -f $DIR/$tdir/$tfile
1372 exhaust_precreations 0 0x80000215
1373 $SETSTRIPE -c -1 $DIR/$tdir
1374 touch $DIR/$tdir/$tfile || error
1375 $GETSTRIPE $DIR/$tdir/$tfile
1378 run_test 27n "create file with some full OSTs =================="
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_all_precreations 0x215
1390 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1395 run_test 27o "create file with all full OSTs (should error) ===="
1398 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1399 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1400 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1401 remote_ost_nodsh && skip "remote OST with nodsh" && return
1404 rm -f $DIR/$tdir/$tfile
1405 test_mkdir -p $DIR/$tdir
1407 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1408 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1409 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1411 exhaust_precreations 0 0x80000215
1412 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1413 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1414 $GETSTRIPE $DIR/$tdir/$tfile
1418 run_test 27p "append to a truncated file with some full OSTs ==="
1421 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1422 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1423 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1424 remote_ost_nodsh && skip "remote OST with nodsh" && return
1427 rm -f $DIR/$tdir/$tfile
1429 test_mkdir -p $DIR/$tdir
1430 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1431 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||error "truncate $DIR/$tdir/$tfile failed"
1432 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1434 exhaust_all_precreations 0x215
1436 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1437 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1441 run_test 27q "append to truncated file with all OSTs full (should error) ==="
1444 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1445 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1446 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1447 remote_ost_nodsh && skip "remote OST with nodsh" && return
1450 rm -f $DIR/$tdir/$tfile
1451 exhaust_precreations 0 0x80000215
1453 $SETSTRIPE -i 0 -c 2 $DIR/$tdir/$tfile # && error
1457 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1459 test_27s() { # bug 10725
1460 test_mkdir -p $DIR/$tdir
1461 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1462 local stripe_count=0
1463 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1464 $SETSTRIPE -S $stripe_size -c $stripe_count $DIR/$tdir &&
1465 error "stripe width >= 2^32 succeeded" || true
1468 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1470 test_27t() { # bug 10864
1475 $WLFS getstripe $tfile
1478 run_test 27t "check that utils parse path correctly"
1480 test_27u() { # bug 4900
1481 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1482 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1484 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1485 do_facet $SINGLEMDS lctl set_param fail_loc=0x139
1486 test_mkdir -p $DIR/$tdir
1487 createmany -o $DIR/$tdir/t- 1000
1488 do_facet $SINGLEMDS lctl set_param fail_loc=0
1490 TLOG=$DIR/$tfile.getstripe
1491 $GETSTRIPE $DIR/$tdir > $TLOG
1492 OBJS=`awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj;}' $TLOG`
1493 unlinkmany $DIR/$tdir/t- 1000
1494 [ $OBJS -gt 0 ] && \
1495 error "$OBJS objects created on OST-0. See $TLOG" || pass
1497 run_test 27u "skip object creation on OSC w/o objects =========="
1499 test_27v() { # bug 4900
1500 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1501 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1502 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1503 remote_ost_nodsh && skip "remote OST with nodsh" && return
1505 exhaust_all_precreations 0x215
1508 test_mkdir -p $DIR/$tdir
1509 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1511 touch $DIR/$tdir/$tfile
1512 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1514 for (( i=1; i < OSTCOUNT; i++ )); do
1515 do_facet ost$i lctl set_param fail_loc=0x705
1517 local START=`date +%s`
1518 createmany -o $DIR/$tdir/$tfile 32
1520 local FINISH=`date +%s`
1521 local TIMEOUT=`lctl get_param -n timeout`
1522 local PROCESS=$((FINISH - START))
1523 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1524 error "$FINISH - $START >= $TIMEOUT / 2"
1525 sleep $((TIMEOUT / 2 - PROCESS))
1528 run_test 27v "skip object creation on slow OST ================="
1530 test_27w() { # bug 10997
1531 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1532 $SETSTRIPE -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1533 [ $($GETSTRIPE -S $DIR/$tdir/f0) -ne 65536 ] &&
1534 error "stripe size $size != 65536" || true
1535 [ $($GETSTRIPE -d $DIR/$tdir | grep -c "stripe_count") -ne 1 ] &&
1536 error "$GETSTRIPE -d $DIR/$tdir failed" || true
1538 run_test 27w "check $SETSTRIPE -S option"
1541 [ "$OSTCOUNT" -lt "2" ] &&
1542 skip_env "skipping multiple stripe count/offset test" && return
1544 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1545 for i in $(seq 1 $OSTCOUNT); do
1547 $SETSTRIPE -c $i -i $offset $DIR/$tdir/f$i ||
1548 error "setstripe -c $i -i $offset failed"
1549 count=$($GETSTRIPE -c $DIR/$tdir/f$i)
1550 index=$($GETSTRIPE -i $DIR/$tdir/f$i)
1551 [ $count -ne $i ] && error "stripe count $count != $i" || true
1552 [ $index -ne $offset ] &&
1553 error "stripe offset $index != $offset" || true
1556 run_test 27wa "check $SETSTRIPE -c -i options"
1559 remote_ost_nodsh && skip "remote OST with nodsh" && return
1560 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs" && return
1561 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1562 OFFSET=$(($OSTCOUNT - 1))
1564 local OST=$(ostname_from_index $OSTIDX)
1566 test_mkdir -p $DIR/$tdir
1567 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe per file
1568 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1570 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1571 for i in `seq 0 $OFFSET`; do
1572 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}' | grep -w "$OSTIDX"` ] &&
1573 error "OST0 was degraded but new created file still use it"
1575 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1577 run_test 27x "create files while OST0 is degraded"
1580 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1581 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1582 remote_ost_nodsh && skip "remote OST with nodsh" && return
1583 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1585 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1586 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1587 osc.$mdtosc.prealloc_last_id)
1588 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1589 osc.$mdtosc.prealloc_next_id)
1590 local fcount=$((last_id - next_id))
1591 [ $fcount -eq 0 ] && skip "not enough space on OST0" && return
1592 [ $fcount -gt $OSTCOUNT ] && fcount=$OSTCOUNT
1594 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
1595 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
1596 local OST_DEACTIVE_IDX=-1
1601 for OSC in $MDS_OSCS; do
1602 OST=$(osc_to_ost $OSC)
1603 OSTIDX=$(index_from_ostuuid $OST)
1604 if [ $OST_DEACTIVE_IDX == -1 ]; then
1605 OST_DEACTIVE_IDX=$OSTIDX
1607 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
1608 echo $OSC "is Deactivated:"
1609 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1613 OSTIDX=$(index_from_ostuuid $OST)
1615 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1617 for OSC in $MDS_OSCS; do
1618 OST=$(osc_to_ost $OSC)
1619 OSTIDX=$(index_from_ostuuid $OST)
1620 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1621 echo $OST "is degraded:"
1622 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1623 obdfilter.$OST.degraded=1
1628 createmany -o $DIR/$tdir/$tfile $fcount
1630 for OSC in $MDS_OSCS; do
1631 OST=$(osc_to_ost $OSC)
1632 OSTIDX=$(index_from_ostuuid $OST)
1633 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1634 echo $OST "is recovered from degraded:"
1635 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1636 obdfilter.$OST.degraded=0
1638 do_facet $SINGLEMDS lctl --device %$OSC activate
1642 # all osp devices get activated, hence -1 stripe count restored
1645 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
1646 # devices get activated.
1648 $SETSTRIPE -c -1 $DIR/$tfile
1649 stripecnt=$($GETSTRIPE -c $DIR/$tfile)
1651 [ $stripecnt -ne $OSTCOUNT ] &&
1652 error "Of $OSTCOUNT OSTs, only $stripecnt is available"
1655 run_test 27y "create files while OST0 is degraded and the rest inactive"
1661 lmm_count=$($GETSTRIPE -c $1)
1662 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1663 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1665 local old_ifs="$IFS"
1667 fid=($($LFS path2fid $1))
1670 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1671 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1673 # compare lmm_seq and lu_fid->f_seq
1674 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1675 # compare lmm_object_id and lu_fid->oid
1676 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1678 # check the trusted.fid attribute of the OST objects of the file
1679 local have_obdidx=false
1681 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1682 # skip lines up to and including "obdidx"
1683 [ -z "$obdidx" ] && break
1684 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1685 $have_obdidx || continue
1687 local ost=$((obdidx + 1))
1688 local dev=$(ostdevname $ost)
1690 if [ $(facet_fstype ost$ost) != ldiskfs ]; then
1691 echo "Currently only works with ldiskfs-based OSTs"
1695 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1697 #don't unmount/remount the OSTs if we don't need to do that
1698 #local dir=$(facet_mntpt ost$ost)
1700 #do_facet ost$dev mount -t $FSTYPE $dev $dir $OST_MOUNT_OPTS ||
1701 # { error "mounting $dev as $FSTYPE failed"; return 3; }
1702 #local obj_file=$(do_facet ost$ost find $dir/O/$seq -name $oid)
1703 #local ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID $obj_file)
1704 seq=$(echo $seq | sed -e "s/^0x//g")
1705 if [ $seq == 0 ]; then
1706 oid_hex=$(echo $oid)
1708 oid_hex=$(echo $hex | sed -e "s/^0x//g")
1710 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
1711 local ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
1712 $dev 2>/dev/null" | grep "parent=")
1714 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
1716 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
1718 #do_facet ost$ost umount -d $dir
1719 #start ost$ost $dev $OST_MOUNT_OPTS
1721 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
1722 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
1723 local ff_parent=$(echo $ff|sed -e 's/.*parent=.//')
1724 local ff_pseq=$(echo $ff_parent | cut -d: -f1)
1725 local ff_poid=$(echo $ff_parent | cut -d: -f2)
1726 local ff_pstripe=$(echo $ff_parent | sed -e 's/.*stripe=//')
1728 # compare lmm_seq and filter_fid->ff_parent.f_seq
1729 [ $ff_pseq = $lmm_seq ] ||
1730 error "FF parent SEQ $ff_pseq != $lmm_seq"
1731 # compare lmm_object_id and filter_fid->ff_parent.f_oid
1732 [ $ff_poid = $lmm_oid ] ||
1733 error "FF parent OID $ff_poid != $lmm_oid"
1734 [ $ff_pstripe = $stripe_nr ] ||
1735 error "FF stripe $ff_pstripe != $stripe_nr"
1737 stripe_nr=$((stripe_nr + 1))
1742 remote_ost_nodsh && skip "remote OST with nodsh" && return
1743 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1744 test_mkdir -p $DIR/$tdir
1746 $SETSTRIPE -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
1747 { error "setstripe -c -1 failed"; return 1; }
1748 # We need to send a write to every object to get parent FID info set.
1749 # This _should_ also work for setattr, but does not currently.
1750 # touch $DIR/$tdir/$tfile-1 ||
1751 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
1752 { error "dd $tfile-1 failed"; return 2; }
1753 $SETSTRIPE -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
1754 { error "setstripe -c -1 failed"; return 3; }
1755 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
1756 { error "dd $tfile-2 failed"; return 4; }
1758 # make sure write RPCs have been sent to OSTs
1761 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
1762 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
1764 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
1766 test_27A() { # b=19102
1767 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1768 local restore_size=$($GETSTRIPE -S $MOUNT)
1769 local restore_count=$($GETSTRIPE -c $MOUNT)
1770 local restore_offset=$($GETSTRIPE -i $MOUNT)
1771 $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
1772 local default_size=$($GETSTRIPE -S $MOUNT)
1773 local default_count=$($GETSTRIPE -c $MOUNT)
1774 local default_offset=$($GETSTRIPE -i $MOUNT)
1775 local dsize=$((1024 * 1024))
1776 [ $default_size -eq $dsize ] ||
1777 error "stripe size $default_size != $dsize"
1778 [ $default_count -eq 1 ] || error "stripe count $default_count != 1"
1779 [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
1780 $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
1782 run_test 27A "check filesystem-wide default LOV EA values"
1784 test_27B() { # LU-2523
1785 test_mkdir -p $DIR/$tdir
1786 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
1788 # open f1 with O_LOV_DELAY_CREATE
1790 # call setstripe ioctl on open file descriptor for f1
1792 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
1796 # open f1 with O_LOV_DELAY_CREATE
1798 # call setstripe ioctl on open file descriptor for f1
1800 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
1802 # Allow multiop to fail in imitation of NFS's busted semantics.
1805 run_test 27B "call setstripe on open unlinked file/rename victim"
1807 # createtest also checks that device nodes are created and
1808 # then visible correctly (#2091)
1809 test_28() { # bug 2091
1811 $CREATETEST $DIR/d28/ct || error
1813 run_test 28 "create/mknod/mkdir with bad file types ============"
1816 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1817 cancel_lru_locks mdc
1823 declare -i LOCKCOUNTORIG=0
1824 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1825 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
1827 [ $LOCKCOUNTORIG -eq 0 ] && echo "No mdc lock count" && return 1
1829 declare -i LOCKUNUSEDCOUNTORIG=0
1830 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1831 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
1838 declare -i LOCKCOUNTCURRENT=0
1839 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1840 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
1843 declare -i LOCKUNUSEDCOUNTCURRENT=0
1844 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1845 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
1848 if [ "$LOCKCOUNTCURRENT" -gt "$LOCKCOUNTORIG" ]; then
1849 lctl set_param -n ldlm.dump_namespaces ""
1850 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
1851 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1852 log "dumped log to $TMP/test_29.dk (bug 5793)"
1855 if [ "$LOCKUNUSEDCOUNTCURRENT" -gt "$LOCKUNUSEDCOUNTORIG" ]; then
1856 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
1857 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1858 log "dumped log to $TMP/test_29.dk (bug 5793)"
1862 run_test 29 "IT_GETATTR regression ============================"
1864 test_30a() { # was test_30
1865 cp `which ls` $DIR || cp /bin/ls $DIR
1869 run_test 30a "execute binary from Lustre (execve) =============="
1872 cp `which ls` $DIR || cp /bin/ls $DIR
1874 $RUNAS $DIR/ls / || error
1877 run_test 30b "execute binary from Lustre as non-root ==========="
1879 test_30c() { # b=22376
1880 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1881 cp `which ls` $DIR || cp /bin/ls $DIR
1883 cancel_lru_locks mdc
1884 cancel_lru_locks osc
1885 $RUNAS $DIR/ls / || error
1888 run_test 30c "execute binary from Lustre without read perms ===="
1891 $OPENUNLINK $DIR/f31 $DIR/f31 || error
1892 $CHECKSTAT -a $DIR/f31 || error
1894 run_test 31a "open-unlink file =================================="
1897 touch $DIR/f31 || error
1898 ln $DIR/f31 $DIR/f31b || error
1899 $MULTIOP $DIR/f31b Ouc || error
1900 $CHECKSTAT -t file $DIR/f31 || error
1902 run_test 31b "unlink file with multiple links while open ======="
1905 touch $DIR/f31 || error
1906 ln $DIR/f31 $DIR/f31c || error
1907 multiop_bg_pause $DIR/f31 O_uc || return 1
1909 $MULTIOP $DIR/f31c Ouc
1910 kill -USR1 $MULTIPID
1913 run_test 31c "open-unlink file with multiple links ============="
1916 opendirunlink $DIR/d31d $DIR/d31d || error
1917 $CHECKSTAT -a $DIR/d31d || error
1919 run_test 31d "remove of open directory ========================="
1921 test_31e() { # bug 2904
1922 check_kernel_version 34 || return 0
1923 openfilleddirunlink $DIR/d31e || error
1925 run_test 31e "remove of open non-empty directory ==============="
1927 test_31f() { # bug 4554
1928 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1930 test_mkdir $DIR/d31f
1931 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
1932 cp /etc/hosts $DIR/d31f
1934 $GETSTRIPE $DIR/d31f/hosts
1935 multiop_bg_pause $DIR/d31f D_c || return 1
1938 rm -rv $DIR/d31f || error "first of $DIR/d31f"
1939 test_mkdir $DIR/d31f
1940 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
1941 cp /etc/hosts $DIR/d31f
1943 $GETSTRIPE $DIR/d31f/hosts
1944 multiop_bg_pause $DIR/d31f D_c || return 1
1947 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
1948 wait $MULTIPID || error "first opendir $MULTIPID failed"
1952 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
1953 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
1956 run_test 31f "remove of open directory with open-unlink file ==="
1959 echo "-- cross directory link --"
1960 test_mkdir $DIR/d31ga
1961 test_mkdir $DIR/d31gb
1963 ln $DIR/d31ga/f $DIR/d31gb/g
1964 $CHECKSTAT -t file $DIR/d31ga/f || error "source"
1965 [ `stat -c%h $DIR/d31ga/f` == '2' ] || error "source nlink"
1966 $CHECKSTAT -t file $DIR/d31gb/g || error "target"
1967 [ `stat -c%h $DIR/d31gb/g` == '2' ] || error "target nlink"
1969 run_test 31g "cross directory link==============="
1972 echo "-- cross directory link --"
1973 test_mkdir $DIR/d31h
1974 test_mkdir $DIR/d31h/dir
1976 ln $DIR/d31h/f $DIR/d31h/dir/g
1977 $CHECKSTAT -t file $DIR/d31h/f || error "source"
1978 [ `stat -c%h $DIR/d31h/f` == '2' ] || error "source nlink"
1979 $CHECKSTAT -t file $DIR/d31h/dir/g || error "target"
1980 [ `stat -c%h $DIR/d31h/dir/g` == '2' ] || error "target nlink"
1982 run_test 31h "cross directory link under child==============="
1985 echo "-- cross directory link --"
1986 test_mkdir $DIR/d31i
1987 test_mkdir $DIR/d31i/dir
1988 touch $DIR/d31i/dir/f
1989 ln $DIR/d31i/dir/f $DIR/d31i/g
1990 $CHECKSTAT -t file $DIR/d31i/dir/f || error "source"
1991 [ `stat -c%h $DIR/d31i/dir/f` == '2' ] || error "source nlink"
1992 $CHECKSTAT -t file $DIR/d31i/g || error "target"
1993 [ `stat -c%h $DIR/d31i/g` == '2' ] || error "target nlink"
1995 run_test 31i "cross directory link under parent==============="
1999 test_mkdir $DIR/d31j
2000 test_mkdir $DIR/d31j/dir1
2001 ln $DIR/d31j/dir1 $DIR/d31j/dir2 && error "ln for dir"
2002 link $DIR/d31j/dir1 $DIR/d31j/dir3 && error "link for dir"
2003 mlink $DIR/d31j/dir1 $DIR/d31j/dir4 && error "mlink for dir"
2004 mlink $DIR/d31j/dir1 $DIR/d31j/dir1 && error "mlink to the same dir"
2007 run_test 31j "link for directory==============="
2011 test_mkdir $DIR/d31k
2013 touch $DIR/d31k/exist
2014 mlink $DIR/d31k/s $DIR/d31k/t || error "mlink"
2015 mlink $DIR/d31k/s $DIR/d31k/exist && error "mlink to exist file"
2016 mlink $DIR/d31k/s $DIR/d31k/s && error "mlink to the same file"
2017 mlink $DIR/d31k/s $DIR/d31k && error "mlink to parent dir"
2018 mlink $DIR/d31k $DIR/d31k/s && error "mlink parent dir to target"
2019 mlink $DIR/d31k/not-exist $DIR/d31k/foo && error "mlink non-existing to new"
2020 mlink $DIR/d31k/not-exist $DIR/d31k/s && error "mlink non-existing to exist"
2023 run_test 31k "link to file: the same, non-existing, dir==============="
2026 test_mkdir $DIR/d31m
2028 test_mkdir $DIR/d31m2
2029 touch $DIR/d31m2/exist
2030 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
2031 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
2032 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
2033 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
2034 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
2035 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
2038 run_test 31m "link to file: the same, non-existing, dir==============="
2041 [ -e /proc/self/fd/173 ] && echo "skipping, fd 173 is in use" && return
2042 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
2043 nlink=$(stat --format=%h $DIR/$tfile)
2044 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2045 exec 173<$DIR/$tfile
2046 trap "exec 173<&-" EXIT
2047 nlink=$(stat --dereference --format=%h /proc/self/fd/173)
2048 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2049 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
2050 nlink=$(stat --dereference --format=%h /proc/self/fd/173)
2051 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
2054 run_test 31n "check link count of unlinked file"
2056 cleanup_test32_mount() {
2058 $UMOUNT $DIR/$tdir/ext2-mountpoint
2062 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2063 echo "== more mountpoints and symlinks ================="
2064 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2065 trap cleanup_test32_mount EXIT
2066 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2067 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2068 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. || error
2069 cleanup_test32_mount
2071 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
2074 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2075 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2076 trap cleanup_test32_mount EXIT
2077 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2078 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2079 ls -al $DIR/$tdir/ext2-mountpoint/.. || error
2080 cleanup_test32_mount
2082 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
2085 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2086 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2087 trap cleanup_test32_mount EXIT
2088 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2089 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2090 test_mkdir -p $DIR/$tdir/d2/test_dir
2091 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2092 cleanup_test32_mount
2094 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2097 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2098 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2099 trap cleanup_test32_mount EXIT
2100 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2101 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2102 test_mkdir -p $DIR/$tdir/d2/test_dir
2103 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2104 cleanup_test32_mount
2106 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
2109 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
2110 test_mkdir -p $DIR/d32e/tmp
2111 TMP_DIR=$DIR/d32e/tmp
2112 ln -s $DIR/d32e $TMP_DIR/symlink11
2113 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2114 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
2115 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
2117 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
2120 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
2121 test_mkdir -p $DIR/d32f/tmp
2122 TMP_DIR=$DIR/d32f/tmp
2123 ln -s $DIR/d32f $TMP_DIR/symlink11
2124 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2125 ls $DIR/d32f/tmp/symlink11 || error
2126 ls $DIR/d32f/symlink01 || error
2128 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
2131 TMP_DIR=$DIR/$tdir/tmp
2132 test_mkdir -p $DIR/$tdir/tmp
2133 test_mkdir $DIR/${tdir}2
2134 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2135 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2136 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
2137 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
2138 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
2139 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
2141 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2144 rm -fr $DIR/$tdir $DIR/${tdir}2
2145 TMP_DIR=$DIR/$tdir/tmp
2146 test_mkdir -p $DIR/$tdir/tmp
2147 test_mkdir $DIR/${tdir}2
2148 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2149 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2150 ls $TMP_DIR/symlink12 || error
2151 ls $DIR/$tdir/symlink02 || error
2153 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2156 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2157 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2158 trap cleanup_test32_mount EXIT
2159 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2160 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2161 touch $DIR/$tdir/test_file
2162 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file || error
2163 cleanup_test32_mount
2165 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
2168 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2169 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2170 trap cleanup_test32_mount EXIT
2171 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2172 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2173 touch $DIR/$tdir/test_file
2174 cat $DIR/$tdir/ext2-mountpoint/../test_file || error
2175 cleanup_test32_mount
2177 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
2180 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2182 trap cleanup_test32_mount EXIT
2183 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2184 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2185 test_mkdir -p $DIR/$tdir/d2
2186 touch $DIR/$tdir/d2/test_file || error
2187 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2188 cleanup_test32_mount
2190 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
2193 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2195 trap cleanup_test32_mount EXIT
2196 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2197 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2198 test_mkdir -p $DIR/$tdir/d2
2199 touch $DIR/$tdir/d2/test_file
2200 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2201 cleanup_test32_mount
2203 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
2207 test_mkdir -p $DIR/d32m/tmp
2208 TMP_DIR=$DIR/d32m/tmp
2209 ln -s $DIR $TMP_DIR/symlink11
2210 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2211 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
2212 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
2214 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
2218 test_mkdir -p $DIR/d32n/tmp
2219 TMP_DIR=$DIR/d32n/tmp
2220 ln -s $DIR $TMP_DIR/symlink11
2221 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2222 ls -l $DIR/d32n/tmp/symlink11 || error
2223 ls -l $DIR/d32n/symlink01 || error
2225 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
2228 rm -fr $DIR/d32o $DIR/$tfile
2230 test_mkdir -p $DIR/d32o/tmp
2231 TMP_DIR=$DIR/d32o/tmp
2232 ln -s $DIR/$tfile $TMP_DIR/symlink12
2233 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2234 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
2235 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
2236 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
2237 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
2239 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
2249 test_mkdir -p $DIR/d32p/tmp
2251 TMP_DIR=$DIR/d32p/tmp
2253 ln -s $DIR/$tfile $TMP_DIR/symlink12
2255 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2257 cat $DIR/d32p/tmp/symlink12 || error
2259 cat $DIR/d32p/symlink02 || error
2262 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
2264 cleanup_testdir_mount() {
2270 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2271 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2272 trap cleanup_testdir_mount EXIT
2273 test_mkdir -p $DIR/$tdir
2274 touch $DIR/$tdir/under_the_mount
2275 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2276 ls $DIR/$tdir | grep "\<under_the_mount\>" && error
2277 cleanup_testdir_mount
2279 run_test 32q "stat follows mountpoints in Lustre (should return error)"
2282 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2283 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2284 trap cleanup_testdir_mount EXIT
2285 test_mkdir -p $DIR/$tdir
2286 touch $DIR/$tdir/under_the_mount
2287 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2288 ls $DIR/$tdir | grep -q under_the_mount && error || true
2289 cleanup_testdir_mount
2291 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
2296 chmod 444 $DIR/$tfile
2297 chown $RUNAS_ID $DIR/$tfile
2299 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2302 run_test 33aa "write file with mode 444 (should return error) ===="
2306 test_mkdir -p $DIR/d33
2307 chown $RUNAS_ID $DIR/d33
2308 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
2309 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
2310 error "open RDWR" || true
2312 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
2316 test_mkdir -p $DIR/d33
2317 chown $RUNAS_ID $DIR/d33
2318 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33 && error "create" || true
2320 run_test 33b "test open file with malformed flags (No panic and return error)"
2323 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2329 remote_ost_nodsh && skip "remote OST with nodsh" && return
2332 test_mkdir -p $DIR/d33
2333 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2336 for ostnum in $(seq $OSTCOUNT); do
2337 # test-framework's OST numbering is one-based, while Lustre's
2339 ostname=$(printf "$FSNAME-OST%.4d" $((ostnum - 1)))
2340 # Parsing llobdstat's output sucks; we could grep the /proc
2341 # path, but that's likely to not be as portable as using the
2342 # llobdstat utility. So we parse lctl output instead.
2343 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2344 obdfilter/$ostname/stats |
2345 awk '/^write_bytes/ {print $7}' )
2346 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2347 if (( ${write_bytes:-0} > 0 ))
2354 $all_zeros || return 0
2357 echo foo > $DIR/d33/bar
2361 # Total up write_bytes after writing. We'd better find non-zeros.
2362 for ostnum in $(seq $OSTCOUNT); do
2363 ostname=$(printf "$FSNAME-OST%.4d" $((ostnum - 1)))
2364 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2365 obdfilter/$ostname/stats |
2366 awk '/^write_bytes/ {print $7}' )
2367 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2368 if (( ${write_bytes:-0} > 0 ))
2377 for ostnum in $(seq $OSTCOUNT); do
2378 ostname=$(printf "$FSNAME-OST%.4d" $((ostnum - 1)))
2379 echo "Check that write_bytes is present in obdfilter/*/stats:"
2380 do_facet ost$ostnum lctl get_param -n \
2381 obdfilter/$ostname/stats
2383 error "OST not keeping write_bytes stats (b22312)"
2386 run_test 33c "test llobdstat and write_bytes"
2389 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2390 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2392 local remote_dir=$DIR/$tdir/remote_dir
2395 $LFS mkdir -i $MDTIDX $remote_dir ||
2396 error "create remote directory failed"
2398 touch $remote_dir/$tfile
2399 chmod 444 $remote_dir/$tfile
2400 chown $RUNAS_ID $remote_dir/$tfile
2402 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2404 chown $RUNAS_ID $remote_dir
2405 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
2406 error "create" || true
2407 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
2408 error "open RDWR" || true
2409 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 &&
2410 error "create" || true
2412 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
2414 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
2417 $MCREATE $DIR/f34 || error
2418 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2419 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
2420 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2421 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2423 run_test 34a "truncate file that has not been opened ==========="
2426 [ ! -f $DIR/f34 ] && test_34a
2427 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2428 $OPENFILE -f O_RDONLY $DIR/f34
2429 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2430 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2432 run_test 34b "O_RDONLY opening file doesn't create objects ====="
2435 [ ! -f $DIR/f34 ] && test_34a
2436 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2437 $OPENFILE -f O_RDWR $DIR/f34
2438 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2439 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2441 run_test 34c "O_RDWR opening file-with-size works =============="
2444 [ ! -f $DIR/f34 ] && test_34a
2445 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2446 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2449 run_test 34d "write to sparse file ============================="
2453 $MCREATE $DIR/f34e || error
2454 $TRUNCATE $DIR/f34e 1000 || error
2455 $CHECKSTAT -s 1000 $DIR/f34e || error
2456 $OPENFILE -f O_RDWR $DIR/f34e
2457 $CHECKSTAT -s 1000 $DIR/f34e || error
2459 run_test 34e "create objects, some with size and some without =="
2461 test_34f() { # bug 6242, 6243
2462 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2465 $MCREATE $DIR/f34f || error
2466 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
2467 dd if=$DIR/f34f of=$TMP/f34f
2468 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
2469 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
2470 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
2471 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
2472 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
2474 run_test 34f "read from a file with no objects until EOF ======="
2477 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2478 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
2479 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
2480 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
2481 cancel_lru_locks osc
2482 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
2483 error "wrong size after lock cancel"
2485 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
2486 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2487 error "expanding truncate failed"
2488 cancel_lru_locks osc
2489 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2490 error "wrong expanded size after lock cancel"
2492 run_test 34g "truncate long file ==============================="
2495 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2499 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
2500 sync # Flush the cache so that multiop below does not block on cache
2501 # flush when getting the group lock
2502 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
2506 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
2507 error "Multiop blocked on ftruncate, pid=$MULTIPID"
2511 local nsz=`stat -c %s $DIR/$tfile`
2512 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
2514 run_test 34h "ftruncate file under grouplock should not block"
2517 cp /bin/sh $DIR/f35a
2519 chown $RUNAS_ID $DIR/f35a
2520 $RUNAS $DIR/f35a && error || true
2523 run_test 35a "exec file with mode 444 (should return and not leak) ====="
2527 utime $DIR/f36 || error
2529 run_test 36a "MDS utime check (mknod, utime) ==================="
2533 utime $DIR/f36 || error
2535 run_test 36b "OST utime check (open, utime) ===================="
2540 chown $RUNAS_ID $DIR/d36
2541 $RUNAS utime $DIR/d36/f36 || error
2543 run_test 36c "non-root MDS utime check (mknod, utime) =========="
2546 [ ! -d $DIR/d36 ] && test_36c
2547 echo "" > $DIR/d36/f36
2548 $RUNAS utime $DIR/d36/f36 || error
2550 run_test 36d "non-root OST utime check (open, utime) ==========="
2553 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
2554 test_mkdir -p $DIR/$tdir
2555 touch $DIR/$tdir/$tfile
2556 $RUNAS utime $DIR/$tdir/$tfile && \
2557 error "utime worked, expected failure" || true
2559 run_test 36e "utime on non-owned file (should return error) ===="
2563 local LANG_SAVE=$LANG
2564 local LC_LANG_SAVE=$LC_LANG
2565 export LANG=C LC_LANG=C # for date language
2567 DATESTR="Dec 20 2000"
2568 test_mkdir -p $DIR/$tdir
2569 lctl set_param fail_loc=$fl
2571 cp /etc/hosts $DIR/$tdir/$tfile
2572 sync & # write RPC generated with "current" inode timestamp, but delayed
2574 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
2575 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
2576 cancel_lru_locks osc
2577 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
2579 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
2580 echo "BEFORE: $LS_BEFORE" && \
2581 echo "AFTER : $LS_AFTER" && \
2582 echo "WANT : $DATESTR" && \
2583 error "$DIR/$tdir/$tfile timestamps changed" || true
2585 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
2589 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2590 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2591 subr_36fh "0x80000214"
2593 run_test 36f "utime on file racing with OST BRW write =========="
2596 remote_ost_nodsh && skip "remote OST with nodsh" && return
2597 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2602 test_mkdir -p $DIR/$tdir
2603 fmd_max_age=$(do_facet ost1 \
2604 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
2607 fmd_before=$(do_facet ost1 \
2608 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2609 touch $DIR/$tdir/$tfile
2610 sleep $((fmd_max_age + 12))
2611 fmd_after=$(do_facet ost1 \
2612 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2614 echo "fmd_before: $fmd_before"
2615 echo "fmd_after: $fmd_after"
2616 [ "$fmd_after" -gt "$fmd_before" ] && \
2617 echo "AFTER: $fmd_after > BEFORE: $fmd_before" && \
2618 error "fmd didn't expire after ping" || true
2620 run_test 36g "filter mod data cache expiry ====================="
2623 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2624 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
2625 subr_36fh "0x80000227"
2627 run_test 36h "utime on file racing with OST BRW write =========="
2629 # test_37 - duplicate with tests 32q 32r
2632 local file=$DIR/$tfile
2634 openfile -f O_DIRECTORY $file
2637 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
2638 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
2640 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
2644 touch $DIR/${tfile}2
2645 # ls -l $DIR/$tfile $DIR/${tfile}2
2646 # ls -lu $DIR/$tfile $DIR/${tfile}2
2647 # ls -lc $DIR/$tfile $DIR/${tfile}2
2649 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
2650 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
2652 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
2654 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
2656 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
2657 error "O_TRUNC didn't change timestamps"
2660 run_test 39 "mtime changed on create ==========================="
2663 test_mkdir -p $DIR/$tdir
2664 cp -p /etc/passwd $DIR/$tdir/fopen
2665 cp -p /etc/passwd $DIR/$tdir/flink
2666 cp -p /etc/passwd $DIR/$tdir/funlink
2667 cp -p /etc/passwd $DIR/$tdir/frename
2668 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
2671 echo "aaaaaa" >> $DIR/$tdir/fopen
2672 echo "aaaaaa" >> $DIR/$tdir/flink
2673 echo "aaaaaa" >> $DIR/$tdir/funlink
2674 echo "aaaaaa" >> $DIR/$tdir/frename
2676 local open_new=`stat -c %Y $DIR/$tdir/fopen`
2677 local link_new=`stat -c %Y $DIR/$tdir/flink`
2678 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
2679 local rename_new=`stat -c %Y $DIR/$tdir/frename`
2681 cat $DIR/$tdir/fopen > /dev/null
2682 ln $DIR/$tdir/flink $DIR/$tdir/flink2
2683 rm -f $DIR/$tdir/funlink2
2684 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
2686 for (( i=0; i < 2; i++ )) ; do
2687 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
2688 local link_new2=`stat -c %Y $DIR/$tdir/flink`
2689 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
2690 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
2692 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
2693 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
2694 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
2695 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
2697 cancel_lru_locks osc
2698 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2701 run_test 39b "mtime change on open, link, unlink, rename ======"
2703 # this should be set to past
2704 TEST_39_MTIME=`date -d "1 year ago" +%s`
2710 local mtime0=`stat -c %Y $DIR1/$tfile`
2712 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2713 local mtime1=`stat -c %Y $DIR1/$tfile`
2714 [ "$mtime1" = $TEST_39_MTIME ] || \
2715 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
2718 echo hello >> $DIR1/$tfile
2720 local mtime2=`stat -c %Y $DIR1/$tfile`
2721 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
2722 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
2724 mv $DIR1/$tfile $DIR1/$tfile-1
2726 for (( i=0; i < 2; i++ )) ; do
2727 local mtime3=`stat -c %Y $DIR1/$tfile-1`
2728 [ "$mtime2" = "$mtime3" ] || \
2729 error "mtime ($mtime2) changed (to $mtime3) on rename"
2731 cancel_lru_locks osc
2732 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2735 run_test 39c "mtime change on rename ==========================="
2739 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2742 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2744 for (( i=0; i < 2; i++ )) ; do
2745 local mtime=`stat -c %Y $DIR1/$tfile`
2746 [ $mtime = $TEST_39_MTIME ] || \
2747 error "mtime($mtime) is not set to $TEST_39_MTIME"
2749 cancel_lru_locks osc
2750 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2753 run_test 39d "create, utime, stat =============================="
2757 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2759 local mtime1=`stat -c %Y $DIR1/$tfile`
2761 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2763 for (( i=0; i < 2; i++ )) ; do
2764 local mtime2=`stat -c %Y $DIR1/$tfile`
2765 [ $mtime2 = $TEST_39_MTIME ] || \
2766 error "mtime($mtime2) is not set to $TEST_39_MTIME"
2768 cancel_lru_locks osc
2769 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2772 run_test 39e "create, stat, utime, stat ========================"
2776 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2778 mtime1=`stat -c %Y $DIR1/$tfile`
2781 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2783 for (( i=0; i < 2; i++ )) ; do
2784 local mtime2=`stat -c %Y $DIR1/$tfile`
2785 [ $mtime2 = $TEST_39_MTIME ] || \
2786 error "mtime($mtime2) is not set to $TEST_39_MTIME"
2788 cancel_lru_locks osc
2789 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2792 run_test 39f "create, stat, sleep, utime, stat ================="
2796 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2797 echo hello >> $DIR1/$tfile
2798 local mtime1=`stat -c %Y $DIR1/$tfile`
2801 chmod o+r $DIR1/$tfile
2803 for (( i=0; i < 2; i++ )) ; do
2804 local mtime2=`stat -c %Y $DIR1/$tfile`
2805 [ "$mtime1" = "$mtime2" ] || \
2806 error "lost mtime: $mtime2, should be $mtime1"
2808 cancel_lru_locks osc
2809 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2812 run_test 39g "write, chmod, stat ==============================="
2816 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2821 echo hello >> $DIR1/$tfile
2822 local mtime1=`stat -c %Y $DIR1/$tfile`
2824 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2826 if [ "$d1" != "$d2" ]; then
2827 echo "write and touch not within one second"
2829 for (( i=0; i < 2; i++ )) ; do
2830 local mtime2=`stat -c %Y $DIR1/$tfile`
2831 [ "$mtime2" = $TEST_39_MTIME ] || \
2832 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
2834 cancel_lru_locks osc
2835 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2839 run_test 39h "write, utime within one second, stat ============="
2842 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2846 echo hello >> $DIR1/$tfile
2847 local mtime1=`stat -c %Y $DIR1/$tfile`
2849 mv $DIR1/$tfile $DIR1/$tfile-1
2851 for (( i=0; i < 2; i++ )) ; do
2852 local mtime2=`stat -c %Y $DIR1/$tfile-1`
2854 [ "$mtime1" = "$mtime2" ] || \
2855 error "lost mtime: $mtime2, should be $mtime1"
2857 cancel_lru_locks osc
2858 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2861 run_test 39i "write, rename, stat =============================="
2864 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2865 start_full_debug_logging
2869 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
2870 lctl set_param fail_loc=0x80000412
2871 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
2872 error "multiop failed"
2874 local mtime1=`stat -c %Y $DIR1/$tfile`
2876 mv $DIR1/$tfile $DIR1/$tfile-1
2878 kill -USR1 $multipid
2879 wait $multipid || error "multiop close failed"
2881 for (( i=0; i < 2; i++ )) ; do
2882 local mtime2=`stat -c %Y $DIR1/$tfile-1`
2883 [ "$mtime1" = "$mtime2" ] ||
2884 error "mtime is lost on close: $mtime2, " \
2887 cancel_lru_locks osc
2888 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2890 lctl set_param fail_loc=0
2891 stop_full_debug_logging
2893 run_test 39j "write, rename, close, stat ======================="
2896 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2900 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
2902 local mtime1=`stat -c %Y $DIR1/$tfile`
2904 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2906 kill -USR1 $multipid
2907 wait $multipid || error "multiop close failed"
2909 for (( i=0; i < 2; i++ )) ; do
2910 local mtime2=`stat -c %Y $DIR1/$tfile`
2912 [ "$mtime2" = $TEST_39_MTIME ] || \
2913 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
2915 cancel_lru_locks osc
2916 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2919 run_test 39k "write, utime, close, stat ========================"
2921 # this should be set to future
2922 TEST_39_ATIME=`date -d "1 year" +%s`
2925 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2926 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2927 local atime_diff=$(do_facet $SINGLEMDS \
2928 lctl get_param -n mdd.*MDT0000*.atime_diff)
2932 # test setting directory atime to future
2933 touch -a -d @$TEST_39_ATIME $DIR/$tdir
2934 local atime=$(stat -c %X $DIR/$tdir)
2935 [ "$atime" = $TEST_39_ATIME ] || \
2936 error "atime is not set to future: $atime, $TEST_39_ATIME"
2938 # test setting directory atime from future to now
2939 local d1=$(date +%s)
2941 local d2=$(date +%s)
2943 cancel_lru_locks mdc
2944 atime=$(stat -c %X $DIR/$tdir)
2945 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
2946 error "atime is not updated from future: $atime, $d1<atime<$d2"
2948 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
2951 # test setting directory atime when now > dir atime + atime_diff
2955 cancel_lru_locks mdc
2956 atime=$(stat -c %X $DIR/$tdir)
2957 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
2958 error "atime is not updated : $atime, should be $d2"
2960 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
2963 # test not setting directory atime when now < dir atime + atime_diff
2965 cancel_lru_locks mdc
2966 atime=$(stat -c %X $DIR/$tdir)
2967 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
2968 error "atime is updated to $atime, should remain $d1<atime<$d2"
2970 do_facet $SINGLEMDS \
2971 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
2973 run_test 39l "directory atime update ==========================="
2976 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2979 local far_past_mtime=$(date -d "May 29 1953" +%s)
2980 local far_past_atime=$(date -d "Dec 17 1903" +%s)
2982 touch -m -d @$far_past_mtime $DIR1/$tfile
2983 touch -a -d @$far_past_atime $DIR1/$tfile
2985 for (( i=0; i < 2; i++ )) ; do
2986 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
2987 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
2988 error "atime or mtime set incorrectly"
2990 cancel_lru_locks osc
2991 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2994 run_test 39m "test atime and mtime before 1970"
2997 dd if=/dev/zero of=$DIR/f40 bs=4096 count=1
2998 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/f40 && error
2999 $CHECKSTAT -t file -s 4096 $DIR/f40 || error
3001 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
3005 small_write $DIR/f41 18
3007 run_test 41 "test small file write + fstat ====================="
3009 count_ost_writes() {
3010 lctl get_param -n osc.*.stats |
3011 awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }'
3018 BG_DIRTY_RATIO_SAVE=10
3019 MAX_BG_DIRTY_RATIO=25
3023 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
3024 # dirty_ratio, dirty_background_ratio
3025 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3026 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
3027 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
3028 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
3030 # if file not here, we are a 2.4 kernel
3031 kill -CONT `pidof kupdated`
3036 # setup the trap first, so someone cannot exit the test at the
3037 # exact wrong time and mess up a machine
3038 trap start_writeback EXIT
3039 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
3040 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3041 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
3042 sysctl -w vm.dirty_writeback_centisecs=0
3043 sysctl -w vm.dirty_writeback_centisecs=0
3044 # save and increase /proc/sys/vm/dirty_ratio
3045 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
3046 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
3047 # save and increase /proc/sys/vm/dirty_background_ratio
3048 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
3049 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
3051 # if file not here, we are a 2.4 kernel
3052 kill -STOP `pidof kupdated`
3056 # ensure that all stripes have some grant before we test client-side cache
3058 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
3059 dd if=/dev/zero of=$i bs=4k count=1
3064 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
3065 # file truncation, and file removal.
3067 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3069 cancel_lru_locks osc
3071 sync; sleep 1; sync # just to be safe
3072 BEFOREWRITES=`count_ost_writes`
3073 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
3074 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
3075 AFTERWRITES=`count_ost_writes`
3076 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3077 error "$BEFOREWRITES < $AFTERWRITES"
3080 run_test 42a "ensure that we don't flush on close =============="
3083 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3085 cancel_lru_locks osc
3088 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
3089 BEFOREWRITES=`count_ost_writes`
3090 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
3091 AFTERWRITES=`count_ost_writes`
3092 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
3093 error "$BEFOREWRITES < $AFTERWRITES on unlink"
3095 BEFOREWRITES=`count_ost_writes`
3096 sync || error "sync: $?"
3097 AFTERWRITES=`count_ost_writes`
3098 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
3099 error "$BEFOREWRITES < $AFTERWRITES on sync"
3101 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
3105 run_test 42b "test destroy of file with cached dirty data ======"
3107 # if these tests just want to test the effect of truncation,
3108 # they have to be very careful. consider:
3109 # - the first open gets a {0,EOF}PR lock
3110 # - the first write conflicts and gets a {0, count-1}PW
3111 # - the rest of the writes are under {count,EOF}PW
3112 # - the open for truncate tries to match a {0,EOF}PR
3113 # for the filesize and cancels the PWs.
3114 # any number of fixes (don't get {0,EOF} on open, match
3115 # composite locks, do smarter file size management) fix
3116 # this, but for now we want these tests to verify that
3117 # the cancellation with truncate intent works, so we
3118 # start the file with a full-file pw lock to match against
3119 # until the truncate.
3124 cancel_lru_locks osc
3126 # prime the file with 0,EOF PW to match
3130 # now the real test..
3131 dd if=/dev/zero of=$file bs=1024 count=100
3132 BEFOREWRITES=`count_ost_writes`
3133 $TRUNCATE $file $offset
3134 cancel_lru_locks osc
3135 AFTERWRITES=`count_ost_writes`
3140 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3142 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
3143 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
3146 run_test 42c "test partial truncate of file with cached dirty data"
3149 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3151 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3152 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
3155 run_test 42d "test complete truncate of file with cached dirty data"
3157 test_42e() { # bug22074
3158 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3159 local TDIR=$DIR/${tdir}e
3160 local pagesz=$(page_size)
3161 local pages=16 # hardcoded 16 pages, don't change it.
3162 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
3163 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
3167 test_mkdir -p $DIR/${tdir}e
3168 $SETSTRIPE -c 1 $TDIR
3169 createmany -o $TDIR/f $files
3171 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
3173 # we assume that with $OSTCOUNT files, at least one of them will
3174 # be allocated on OST0.
3175 warmup_files=$((OSTCOUNT * max_dirty_mb))
3176 createmany -o $TDIR/w $warmup_files
3178 # write a large amount of data into one file and sync, to get good
3179 # avail_grant number from OST.
3180 for ((i=0; i<$warmup_files; i++)); do
3181 idx=$($GETSTRIPE -i $TDIR/w$i)
3182 [ $idx -ne 0 ] && continue
3183 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
3186 [ $i -gt $warmup_files ] && error "OST0 is still cold"
3188 $LCTL get_param $proc_osc0/cur_dirty_bytes
3189 $LCTL get_param $proc_osc0/cur_grant_bytes
3191 # create as much dirty pages as we can while not to trigger the actual
3192 # RPCs directly. but depends on the env, VFS may trigger flush during this
3193 # period, hopefully we are good.
3194 for ((i=0; i<$warmup_files; i++)); do
3195 idx=$($GETSTRIPE -i $TDIR/w$i)
3196 [ $idx -ne 0 ] && continue
3197 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
3199 $LCTL get_param $proc_osc0/cur_dirty_bytes
3200 $LCTL get_param $proc_osc0/cur_grant_bytes
3202 # perform the real test
3203 $LCTL set_param $proc_osc0/rpc_stats 0
3204 for ((;i<$files; i++)); do
3205 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
3206 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
3209 $LCTL get_param $proc_osc0/rpc_stats
3212 local have_ppr=false
3213 $LCTL get_param $proc_osc0/rpc_stats |
3214 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
3215 # skip lines until we are at the RPC histogram data
3216 [ "$PPR" == "pages" ] && have_ppr=true && continue
3217 $have_ppr || continue
3219 # we only want the percent stat for < 16 pages
3220 [ $(echo $PPR | tr -d ':') -ge $pages ] && break
3222 percent=$((percent + WPCT))
3223 if [ $percent -gt 15 ]; then
3224 error "less than 16-pages write RPCs" \
3231 run_test 42e "verify sub-RPC writes are not done synchronously"
3234 test_mkdir -p $DIR/$tdir
3235 cp -p /bin/ls $DIR/$tdir/$tfile
3236 $MULTIOP $DIR/$tdir/$tfile Ow_c &
3238 # give multiop a chance to open
3241 $DIR/$tdir/$tfile && error || true
3244 run_test 43 "execution of file opened for write should return -ETXTBSY"
3247 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3248 test_mkdir -p $DIR/$tdir
3249 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3250 cp -p multiop $DIR/$tdir/multiop
3251 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/test43.junk O_c ||
3254 $MULTIOP $DIR/$tdir/multiop Oc && error "expected error, got success"
3255 kill -USR1 $MULTIOP_PID || return 2
3256 wait $MULTIOP_PID || return 3
3259 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
3262 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3263 test_mkdir -p $DIR/$tdir
3264 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3265 cp -p multiop $DIR/$tdir/multiop
3266 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/test43.junk O_c ||
3269 $TRUNCATE $DIR/$tdir/multiop 0 && error "expected error, got success"
3270 kill -USR1 $MULTIOP_PID || return 2
3271 wait $MULTIOP_PID || return 3
3274 run_test 43b "truncate of file being executed should return -ETXTBSY"
3277 local testdir="$DIR/$tdir"
3278 test_mkdir -p $DIR/$tdir
3280 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
3281 ( cd $testdir && md5sum -c)
3283 run_test 43c "md5sum of copy into lustre========================"
3286 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
3287 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
3288 dd if=$DIR/f1 bs=4k count=1 > /dev/null
3290 run_test 44 "zero length read from a sparse stripe ============="
3293 local nstripe=`$LCTL lov_getconfig $DIR | grep default_stripe_count: | \
3295 [ -z "$nstripe" ] && skip "can't get stripe info" && return
3296 [ "$nstripe" -gt "$OSTCOUNT" ] && skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" && return
3297 local stride=`$LCTL lov_getconfig $DIR | grep default_stripe_size: | \
3299 if [ $nstripe -eq 0 -o $nstripe -eq -1 ] ; then
3300 nstripe=`$LCTL lov_getconfig $DIR | grep obd_count: | awk '{print $2}'`
3303 OFFSETS="0 $((stride/2)) $((stride-1))"
3304 for offset in $OFFSETS ; do
3305 for i in `seq 0 $((nstripe-1))`; do
3306 local GLOBALOFFSETS=""
3307 local size=$((((i + 2 * $nstripe )*$stride + $offset))) # Bytes
3308 local myfn=$DIR/d44a-$size
3309 echo "--------writing $myfn at $size"
3310 ll_sparseness_write $myfn $size || error "ll_sparseness_write"
3311 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3312 ll_sparseness_verify $myfn $GLOBALOFFSETS \
3313 || error "ll_sparseness_verify $GLOBALOFFSETS"
3315 for j in `seq 0 $((nstripe-1))`; do
3316 size=$((((j + $nstripe )*$stride + $offset))) # Bytes
3317 ll_sparseness_write $myfn $size || error "ll_sparseness_write"
3318 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3320 ll_sparseness_verify $myfn $GLOBALOFFSETS \
3321 || error "ll_sparseness_verify $GLOBALOFFSETS"
3326 run_test 44a "test sparse pwrite ==============================="
3330 for d in `lctl get_param -n osc.*.cur_dirty_bytes`; do
3336 before=`dirty_osc_total`
3337 echo executing "\"$*\""
3339 after=`dirty_osc_total`
3340 echo before $before, after $after
3343 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3345 # Obtain grants from OST if it supports it
3346 echo blah > ${f}_grant
3349 do_dirty_record "echo blah > $f"
3350 [ $before -eq $after ] && error "write wasn't cached"
3351 do_dirty_record "> $f"
3352 [ $before -gt $after ] || error "truncate didn't lower dirty count"
3353 do_dirty_record "echo blah > $f"
3354 [ $before -eq $after ] && error "write wasn't cached"
3355 do_dirty_record "sync"
3356 [ $before -gt $after ] || error "writeback didn't lower dirty count"
3357 do_dirty_record "echo blah > $f"
3358 [ $before -eq $after ] && error "write wasn't cached"
3359 do_dirty_record "cancel_lru_locks osc"
3360 [ $before -gt $after ] || error "lock cancellation didn't lower dirty count"
3363 run_test 45 "osc io page accounting ============================"
3365 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
3366 # test tickles a bug where re-dirtying a page was failing to be mapped to the
3367 # objects offset and an assert hit when an rpc was built with 1023's mapped
3368 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
3370 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3374 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3376 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
3377 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3381 run_test 46 "dirtying a previously written page ================"
3383 # test_47 is removed "Device nodes check" is moved to test_28
3385 test_48a() { # bug 2399
3386 check_kernel_version 34 || return 0
3387 test_mkdir -p $DIR/$tdir
3389 mv $DIR/$tdir $DIR/d48.new || error "move directory failed"
3390 test_mkdir $DIR/$tdir || error "recreate directory failed"
3391 touch foo || error "'touch foo' failed after recreating cwd"
3392 test_mkdir $DIR/$tdir/bar ||
3393 error "'mkdir foo' failed after recreating cwd"
3394 if check_kernel_version 44; then
3395 touch .foo || error "'touch .foo' failed after recreating cwd"
3396 test_mkdir $DIR/$tdir/.bar ||
3397 error "'mkdir .foo' failed after recreating cwd"
3399 ls . > /dev/null || error "'ls .' failed after recreating cwd"
3400 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3401 cd . || error "'cd .' failed after recreating cwd"
3402 test_mkdir . && error "'mkdir .' worked after recreating cwd"
3403 rmdir . && error "'rmdir .' worked after recreating cwd"
3404 ln -s . baz || error "'ln -s .' failed after recreating cwd"
3405 cd .. || error "'cd ..' failed after recreating cwd"
3407 run_test 48a "Access renamed working dir (should return errors)="
3409 test_48b() { # bug 2399
3410 check_kernel_version 34 || return 0
3412 test_mkdir -p $DIR/$tdir
3414 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
3415 touch foo && error "'touch foo' worked after removing cwd"
3416 test_mkdir $DIR/$tdir/foo &&
3417 error "'mkdir foo' worked after removing cwd"
3418 if check_kernel_version 44; then
3419 touch .foo && error "'touch .foo' worked after removing cwd"
3420 test_mkdir $DIR/$tdir/.foo &&
3421 error "'mkdir .foo' worked after removing cwd"
3423 ls . > /dev/null && error "'ls .' worked after removing cwd"
3424 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3425 is_patchless || ( cd . && error "'cd .' worked after removing cwd" )
3426 test_mkdir $DIR/$tdir/. && error "'mkdir .' worked after removing cwd"
3427 rmdir . && error "'rmdir .' worked after removing cwd"
3428 ln -s . foo && error "'ln -s .' worked after removing cwd"
3429 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
3431 run_test 48b "Access removed working dir (should return errors)="
3433 test_48c() { # bug 2350
3434 check_kernel_version 36 || return 0
3435 #lctl set_param debug=-1
3438 test_mkdir -p $DIR/$tdir/dir
3440 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3441 $TRACE touch foo && error "touch foo worked after removing cwd"
3442 $TRACE test_mkdir foo && error "'mkdir foo' worked after removing cwd"
3443 if check_kernel_version 44; then
3444 touch .foo && error "touch .foo worked after removing cwd"
3445 test_mkdir .foo && error "mkdir .foo worked after removing cwd"
3447 $TRACE ls . && error "'ls .' worked after removing cwd"
3448 $TRACE ls .. || error "'ls ..' failed after removing cwd"
3449 is_patchless || ( $TRACE cd . &&
3450 error "'cd .' worked after removing cwd" )
3451 $TRACE test_mkdir . && error "'mkdir .' worked after removing cwd"
3452 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
3453 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
3454 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
3456 run_test 48c "Access removed working subdir (should return errors)"
3458 test_48d() { # bug 2350
3459 check_kernel_version 36 || return 0
3460 #lctl set_param debug=-1
3463 test_mkdir -p $DIR/$tdir/dir
3465 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3466 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3467 $TRACE touch foo && error "'touch foo' worked after removing parent"
3468 $TRACE test_mkdir foo && error "mkdir foo worked after removing parent"
3469 if check_kernel_version 44; then
3470 touch .foo && error "'touch .foo' worked after removing parent"
3472 error "mkdir .foo worked after removing parent"
3474 $TRACE ls . && error "'ls .' worked after removing parent"
3475 $TRACE ls .. && error "'ls ..' worked after removing parent"
3476 is_patchless || ( $TRACE cd . &&
3477 error "'cd .' worked after recreate parent" )
3478 $TRACE test_mkdir . && error "'mkdir .' worked after removing parent"
3479 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
3480 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
3481 is_patchless || ( $TRACE cd .. &&
3482 error "'cd ..' worked after removing parent" || true )
3484 run_test 48d "Access removed parent subdir (should return errors)"
3486 test_48e() { # bug 4134
3487 check_kernel_version 41 || return 0
3488 #lctl set_param debug=-1
3491 test_mkdir -p $DIR/$tdir/dir
3493 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3494 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3495 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
3496 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
3497 # On a buggy kernel addition of "touch foo" after cd .. will
3498 # produce kernel oops in lookup_hash_it
3499 touch ../foo && error "'cd ..' worked after recreate parent"
3501 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
3503 run_test 48e "Access to recreated parent subdir (should return errors)"
3505 test_49() { # LU-1030
3506 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3507 # get ost1 size - lustre-OST0000
3508 ost1_size=$(do_facet ost1 lfs df |grep ${ost1_svc} |awk '{print $4}')
3509 # write 800M at maximum
3510 [ $ost1_size -gt 819200 ] && ost1_size=819200
3512 lfs setstripe -c 1 -i 0 $DIR/$tfile
3513 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
3516 # change max_pages_per_rpc while writing the file
3517 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
3518 local orig_mppc=`$LCTL get_param -n $osc1_mppc`
3519 # loop until dd process exits
3520 while ps ax -opid | grep -wq $dd_pid; do
3521 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
3522 sleep $((RANDOM % 5 + 1))
3524 # restore original max_pages_per_rpc
3525 $LCTL set_param $osc1_mppc=$orig_mppc
3526 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
3528 run_test 49 "Change max_pages_per_rpc won't break osc extent"
3532 test_mkdir $DIR/$tdir
3534 ls /proc/$$/cwd || error
3536 run_test 50 "special situations: /proc symlinks ==============="
3538 test_51a() { # was test_51
3539 # bug 1516 - create an empty entry right after ".." then split dir
3540 test_mkdir -p $DIR/$tdir
3541 touch $DIR/$tdir/foo
3542 $MCREATE $DIR/$tdir/bar
3544 createmany -m $DIR/$tdir/longfile 201
3546 while [ `ls -sd $DIR/$tdir | awk '{ print $1 }'` -eq 4 ]; do
3547 $MCREATE $DIR/$tdir/longfile$FNUM
3552 ls -l $DIR/$tdir > /dev/null || error
3554 run_test 51a "special situations: split htree with empty entry =="
3556 export NUMTEST=70000
3558 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3559 local BASE=$DIR/$tdir
3561 # cleanup the directory
3566 local mdtidx=$(printf "%04x" $($LFS getstripe -M $BASE))
3567 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
3568 [ $numfree -lt 21000 ] && skip "not enough free inodes ($numfree)" &&
3571 [ $numfree -lt $NUMTEST ] && NUMTEST=$(($numfree - 50)) &&
3572 echo "reduced count to $NUMTEST due to inodes"
3574 # need to check free space for the directories as well
3575 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
3576 numfree=$((blkfree / 4))
3577 [ $numfree -lt $NUMTEST ] && NUMTEST=$(($numfree - 50)) &&
3578 echo "reduced count to $NUMTEST due to blocks"
3580 createmany -d $BASE/d $NUMTEST && echo $NUMTEST > $BASE/fnum ||
3581 echo "failed" > $BASE/fnum
3583 run_test 51b "exceed 64k subdirectory nlink limit"
3585 test_51ba() { # LU-993
3586 local BASE=$DIR/$tdir
3587 # unlink all but 100 subdirectories, then check it still works
3589 [ -f $BASE/fnum ] && local NUMPREV=$(cat $BASE/fnum) && rm $BASE/fnum
3591 [ "$NUMPREV" != "failed" ] && NUMTEST=$NUMPREV
3592 local DELETE=$((NUMTEST - LEFT))
3594 # continue on to run this test even if 51b didn't finish,
3595 # just to delete the many subdirectories created.
3596 [ ! -d "${BASE}/d1" ] && skip "test_51b() not run" && return 0
3598 # for ldiskfs the nlink count should be 1, but this is OSD specific
3599 # and so this is listed for informational purposes only
3600 echo "nlink before: $(stat -c %h $BASE), created before: $NUMTEST"
3601 unlinkmany -d $BASE/d $DELETE
3604 if [ $RC -ne 0 ]; then
3605 if [ "$NUMPREV" == "failed" ]; then
3606 skip "previous setup failed"
3609 error "unlink of first $DELETE subdirs failed"
3614 echo "nlink between: $(stat -c %h $BASE)"
3615 # trim the first line of ls output
3616 local FOUND=$(($(ls -l ${BASE} | wc -l) - 1))
3617 [ $FOUND -ne $LEFT ] &&
3618 error "can't find subdirs: found only $FOUND/$LEFT"
3620 unlinkmany -d $BASE/d $DELETE $LEFT ||
3621 error "unlink of second $LEFT subdirs failed"
3622 # regardless of whether the backing filesystem tracks nlink accurately
3623 # or not, the nlink count shouldn't be more than "." and ".." here
3624 local AFTER=$(stat -c %h $BASE)
3625 [ $AFTER -gt 2 ] && error "nlink after: $AFTER > 2" ||
3626 echo "nlink after: $AFTER"
3628 run_test 51ba "verify nlink for many subdirectory cleanup"
3631 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3632 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping test with few OSTs" && return
3633 test_mkdir -p $DIR/$tdir
3634 createmany -o $DIR/$tdir/t- 1000
3635 $GETSTRIPE $DIR/$tdir > $TMP/files
3636 for N in `seq 0 $((OSTCOUNT - 1))`; do
3637 OBJS[$N]=`awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}' $TMP/files`
3638 OBJS0[$N]=`grep -A 1 idx $TMP/files | awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}'`
3639 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
3641 unlinkmany $DIR/$tdir/t- 1000
3644 for N in `seq 1 $((OSTCOUNT - 1))`; do
3645 [ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ] && \
3646 error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
3647 [ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ] && \
3648 error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
3650 [ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ] && \
3651 error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
3652 [ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ] && \
3653 error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
3657 run_test 51d "check object distribution ===================="
3660 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
3661 test_mkdir -p $DIR/$tdir
3662 touch $DIR/$tdir/foo
3663 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
3664 echo bar >> $DIR/$tdir/foo || error "append bar failed"
3665 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
3666 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
3667 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
3669 echo foo >> $DIR/$tdir/foo || error "append foo failed"
3670 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
3671 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
3673 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
3674 cp -r $DIR/$tdir /tmp/
3675 rm -fr $DIR/$tdir || error "cleanup rm failed"
3677 run_test 52a "append-only flag test (should return errors) ====="
3680 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
3681 test_mkdir -p $DIR/$tdir
3682 touch $DIR/$tdir/foo
3683 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
3684 cat test > $DIR/$tdir/foo && error "cat test worked"
3685 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
3686 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
3687 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
3689 echo foo >> $DIR/$tdir/foo && error "echo worked"
3690 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
3691 [ -f $DIR/$tdir/foo ] || error
3692 [ -f $DIR/$tdir/foo_ren ] && error
3693 lsattr $DIR/$tdir/foo | egrep -q "^-+i[-e]+ $DIR/$tdir/foo" ||
3695 chattr -i $DIR/$tdir/foo || error "chattr failed"
3697 rm -fr $DIR/$tdir || error
3699 run_test 52b "immutable flag test (should return errors) ======="
3702 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3703 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3704 remote_ost_nodsh && skip "remote OST with nodsh" && return
3714 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
3715 for value in $(do_facet $SINGLEMDS lctl get_param osc.$mdtosc.prealloc_last_id) ; do
3716 param=`echo ${value[0]} | cut -d "=" -f1`
3717 ostname=`echo $param | cut -d "." -f2 | cut -d - -f 1-2`
3718 mds_last=$(do_facet $SINGLEMDS lctl get_param -n $param)
3719 ostnum=$(index_from_ostuuid ${ostname}_UUID)
3720 node=$(facet_active_host ost$((ostnum+1)))
3721 param="obdfilter.$ostname.last_id"
3722 ost_last=$(do_node $node lctl get_param -n $param | head -n 1)
3723 echo "$ostname.last_id=$ost_last ; MDS.last_id=$mds_last"
3724 if [ $ost_last != $mds_last ]; then
3725 error "$ostname.last_id=$ost_last ; MDS.last_id=$mds_last"
3729 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
3732 [ ! -f "$SOCKETSERVER" ] && skip_env "no socketserver, skipping" && return
3733 [ ! -f "$SOCKETCLIENT" ] && skip_env "no socketclient, skipping" && return
3734 $SOCKETSERVER $DIR/socket
3735 $SOCKETCLIENT $DIR/socket || error
3736 $MUNLINK $DIR/socket
3738 run_test 54a "unix domain socket test =========================="
3744 dd if=/dev/zero of=$f bs=`page_size` count=1
3746 run_test 54b "char device works in lustre ======================"
3749 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
3750 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
3751 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
3753 for i in `seq 3 7`; do
3754 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
3762 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3765 loopdev="$DIR/loop54c"
3768 [ -z "$LOOPNUM" ] && echo "couldn't find empty loop device" && return
3769 mknod $loopdev b 7 $LOOPNUM
3770 echo "make a loop file system with $tfile on $loopdev ($LOOPNUM)..."
3771 dd if=/dev/zero of=$tfile bs=`page_size` seek=1024 count=1 > /dev/null
3772 losetup $loopdev $tfile || error "can't set up $loopdev for $tfile"
3773 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
3775 mount -t ext2 $loopdev $tdir || error "error mounting $loopdev on $tdir"
3776 dd if=/dev/zero of=$tdir/tmp bs=`page_size` count=30 || error "dd write"
3778 dd if=$tdir/tmp of=/dev/zero bs=`page_size` count=30 || error "dd read"
3783 run_test 54c "block device works in lustre ====================="
3789 [ "$string" = `echo $string > $f | cat $f` ] || error
3791 run_test 54d "fifo device works in lustre ======================"
3794 check_kernel_version 46 || return 0
3797 cp -aL /dev/console $f
3798 echo $string > $f || error
3800 run_test 54e "console/tty device works in lustre ======================"
3802 #The test_55 used to be iopen test and it was removed by bz#24037.
3803 #run_test 55 "check iopen_connect_dentry() ======================"
3805 test_56a() { # was test_56
3808 test_mkdir $DIR/$tdir
3809 test_mkdir $DIR/$tdir/dir
3811 NUMFILESx2=$(($NUMFILES * 2))
3812 for i in `seq 1 $NUMFILES` ; do
3813 touch $DIR/$tdir/file$i
3814 touch $DIR/$tdir/dir/file$i
3817 # test lfs getstripe with --recursive
3818 FILENUM=`$GETSTRIPE --recursive $DIR/$tdir | grep -c obdidx`
3819 [ $FILENUM -eq $NUMFILESx2 ] ||
3820 error "$GETSTRIPE --recursive: found $FILENUM, not $NUMFILESx2"
3821 FILENUM=`$GETSTRIPE $DIR/$tdir | grep -c obdidx`
3822 [ $FILENUM -eq $NUMFILES ] ||
3823 error "$GETSTRIPE $DIR/$tdir: found $FILENUM, not $NUMFILES"
3824 echo "$GETSTRIPE --recursive passed."
3826 # test lfs getstripe with file instead of dir
3827 FILENUM=`$GETSTRIPE $DIR/$tdir/file1 | grep -c obdidx`
3828 [ $FILENUM -eq 1 ] || error \
3829 "$GETSTRIPE $DIR/$tdir/file1: found $FILENUM, not 1"
3830 echo "$GETSTRIPE file1 passed."
3832 #test lfs getstripe with --verbose
3833 [ `$GETSTRIPE --verbose $DIR/$tdir |
3834 grep -c lmm_magic` -eq $NUMFILES ] ||
3835 error "$GETSTRIPE --verbose $DIR/$tdir: want $NUMFILES"
3836 [ `$GETSTRIPE $DIR/$tdir | grep -c lmm_magic` -eq 0 ] ||
3837 error "$GETSTRIPE $DIR/$tdir: showed lmm_magic"
3838 echo "$GETSTRIPE --verbose passed."
3840 #test lfs getstripe with --obd
3841 $GETSTRIPE --obd wrong_uuid $DIR/$tdir 2>&1 |
3842 grep -q "unknown obduuid" ||
3843 error "$GETSTRIPE --obd wrong_uuid should return error message"
3845 [ "$OSTCOUNT" -lt 2 ] &&
3846 skip_env "skipping other $GETSTRIPE --obd test" && return
3849 OBDUUID=$(ostuuid_from_index $OSTIDX)
3850 FILENUM=`$GETSTRIPE -ir $DIR/$tdir | grep -x $OSTIDX | wc -l`
3851 FOUND=`$GETSTRIPE -r --obd $OBDUUID $DIR/$tdir | grep obdidx | wc -l`
3852 [ $FOUND -eq $FILENUM ] ||
3853 error "$GETSTRIPE --obd wrong: found $FOUND, expected $FILENUM"
3854 [ `$GETSTRIPE -r -v --obd $OBDUUID $DIR/$tdir |
3855 sed '/^[ ]*'${OSTIDX}'[ ]/d' |
3856 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l` -eq 0 ] ||
3857 error "$GETSTRIPE --obd: should not show file on other obd"
3858 echo "$GETSTRIPE --obd passed"
3860 run_test 56a "check $GETSTRIPE"
3865 local LOCAL_NUMFILES="$1"
3866 local LOCAL_NUMDIRS="$2"
3867 local MKDIR_PARAMS="$3"
3869 if [ ! -d "$TDIR" ] ; then
3871 [ "$MKDIR_PARAMS" ] && $SETSTRIPE $MKDIR_PARAMS $TDIR
3872 for i in `seq 1 $LOCAL_NUMFILES` ; do
3875 for i in `seq 1 $LOCAL_NUMDIRS` ; do
3876 test_mkdir $TDIR/dir$i
3877 for j in `seq 1 $LOCAL_NUMFILES` ; do
3878 touch $TDIR/dir$i/file$j
3884 setup_56_special() {
3888 if [ ! -e "$TDIR/loop1b" ] ; then
3889 for i in `seq 1 $LOCAL_NUMFILES` ; do
3890 mknod $TDIR/loop${i}b b 7 $i
3891 mknod $TDIR/null${i}c c 1 3
3892 ln -s $TDIR/file1 $TDIR/link${i}l
3894 for i in `seq 1 $LOCAL_NUMDIRS` ; do
3895 mknod $TDIR/dir$i/loop${i}b b 7 $i
3896 mknod $TDIR/dir$i/null${i}c c 1 3
3897 ln -s $TDIR/dir$i/file1 $TDIR/dir$i/link${i}l
3906 setup_56 $NUMFILES $NUMDIRS
3908 EXPECTED=$(($NUMDIRS + 2))
3909 # test lfs find with -name
3910 for i in $(seq 1 $NUMFILES) ; do
3911 NUMS=$($LFIND -name "*$i" $TDIR | wc -l)
3912 [ $NUMS -eq $EXPECTED ] ||
3913 error "lfs find -name \"*$i\" $TDIR wrong: "\
3914 "found $NUMS, expected $EXPECTED"
3917 run_test 56g "check lfs find -name ============================="
3923 setup_56 $NUMFILES $NUMDIRS
3925 EXPECTED=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
3926 # test lfs find with ! -name
3927 for i in $(seq 1 $NUMFILES) ; do
3928 NUMS=$($LFIND ! -name "*$i" $TDIR | wc -l)
3929 [ $NUMS -eq $EXPECTED ] ||
3930 error "lfs find ! -name \"*$i\" $TDIR wrong: "\
3931 "found $NUMS, expected $EXPECTED"
3934 run_test 56h "check lfs find ! -name ============================="
3938 test_mkdir -p $DIR/$tdir
3939 UUID=$(ostuuid_from_index 0 $DIR/$tdir)
3940 CMD="$LFIND -ost $UUID $DIR/$tdir"
3942 [ -z "$OUT" ] || error "\"$CMD\" returned directory '$OUT'"
3944 run_test 56i "check 'lfs find -ost UUID' skips directories ======="
3948 setup_56_special $NUMFILES $NUMDIRS
3950 EXPECTED=$((NUMDIRS + 1))
3951 CMD="$LFIND -type d $TDIR"
3952 NUMS=$($CMD | wc -l)
3953 [ $NUMS -eq $EXPECTED ] ||
3954 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3956 run_test 56j "check lfs find -type d ============================="
3960 setup_56_special $NUMFILES $NUMDIRS
3962 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
3963 CMD="$LFIND -type f $TDIR"
3964 NUMS=$($CMD | wc -l)
3965 [ $NUMS -eq $EXPECTED ] ||
3966 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3968 run_test 56k "check lfs find -type f ============================="
3972 setup_56_special $NUMFILES $NUMDIRS
3974 EXPECTED=$((NUMDIRS + NUMFILES))
3975 CMD="$LFIND -type b $TDIR"
3976 NUMS=$($CMD | wc -l)
3977 [ $NUMS -eq $EXPECTED ] ||
3978 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3980 run_test 56l "check lfs find -type b ============================="
3984 setup_56_special $NUMFILES $NUMDIRS
3986 EXPECTED=$((NUMDIRS + NUMFILES))
3987 CMD="$LFIND -type c $TDIR"
3988 NUMS=$($CMD | wc -l)
3989 [ $NUMS -eq $EXPECTED ] ||
3990 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3992 run_test 56m "check lfs find -type c ============================="
3996 setup_56_special $NUMFILES $NUMDIRS
3998 EXPECTED=$((NUMDIRS + NUMFILES))
3999 CMD="$LFIND -type l $TDIR"
4000 NUMS=$($CMD | wc -l)
4001 [ $NUMS -eq $EXPECTED ] ||
4002 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4004 run_test 56n "check lfs find -type l ============================="
4008 setup_56 $NUMFILES $NUMDIRS
4010 utime $TDIR/file1 > /dev/null || error "utime (1)"
4011 utime $TDIR/file2 > /dev/null || error "utime (2)"
4012 utime $TDIR/dir1 > /dev/null || error "utime (3)"
4013 utime $TDIR/dir2 > /dev/null || error "utime (4)"
4014 utime $TDIR/dir1/file1 > /dev/null || error "utime (5)"
4015 dd if=/dev/zero count=1 >> $TDIR/dir1/file1 && sync
4018 NUMS=`$LFIND -mtime +0 $TDIR | wc -l`
4019 [ $NUMS -eq $EXPECTED ] || \
4020 error "lfs find -mtime +0 $TDIR wrong: found $NUMS, expected $EXPECTED"
4023 CMD="$LFIND -mtime 0 $TDIR"
4024 NUMS=$($CMD | wc -l)
4025 [ $NUMS -eq $EXPECTED ] ||
4026 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4028 run_test 56o "check lfs find -mtime for old files =========================="
4031 [ $RUNAS_ID -eq $UID ] &&
4032 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4035 setup_56 $NUMFILES $NUMDIRS
4037 chown $RUNAS_ID $TDIR/file* || error "chown $DIR/${tdir}g/file$i failed"
4039 CMD="$LFIND -uid $RUNAS_ID $TDIR"
4040 NUMS=$($CMD | wc -l)
4041 [ $NUMS -eq $EXPECTED ] || \
4042 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4044 EXPECTED=$(((NUMFILES + 1) * NUMDIRS + 1))
4045 CMD="$LFIND ! -uid $RUNAS_ID $TDIR"
4046 NUMS=$($CMD | wc -l)
4047 [ $NUMS -eq $EXPECTED ] || \
4048 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4050 run_test 56p "check lfs find -uid and ! -uid ==============================="
4053 [ $RUNAS_ID -eq $UID ] &&
4054 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4057 setup_56 $NUMFILES $NUMDIRS
4059 chgrp $RUNAS_GID $TDIR/file* || error "chown $TDIR/file$i failed"
4062 CMD="$LFIND -gid $RUNAS_GID $TDIR"
4063 NUMS=$($CMD | wc -l)
4064 [ $NUMS -eq $EXPECTED ] ||
4065 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4067 EXPECTED=$(( ($NUMFILES+1) * $NUMDIRS + 1))
4068 CMD="$LFIND ! -gid $RUNAS_GID $TDIR"
4069 NUMS=$($CMD | wc -l)
4070 [ $NUMS -eq $EXPECTED ] ||
4071 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4073 run_test 56q "check lfs find -gid and ! -gid ==============================="
4077 setup_56 $NUMFILES $NUMDIRS
4080 CMD="$LFIND -size 0 -type f $TDIR"
4081 NUMS=$($CMD | wc -l)
4082 [ $NUMS -eq $EXPECTED ] ||
4083 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4085 CMD="$LFIND ! -size 0 -type f $TDIR"
4086 NUMS=$($CMD | wc -l)
4087 [ $NUMS -eq $EXPECTED ] ||
4088 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4089 echo "test" > $TDIR/$tfile
4090 echo "test2" > $TDIR/$tfile.2 && sync
4092 CMD="$LFIND -size 5 -type f $TDIR"
4093 NUMS=$($CMD | wc -l)
4094 [ $NUMS -eq $EXPECTED ] ||
4095 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4097 CMD="$LFIND -size +5 -type f $TDIR"
4098 NUMS=$($CMD | wc -l)
4099 [ $NUMS -eq $EXPECTED ] ||
4100 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4102 CMD="$LFIND -size +0 -type f $TDIR"
4103 NUMS=$($CMD | wc -l)
4104 [ $NUMS -eq $EXPECTED ] ||
4105 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4107 CMD="$LFIND ! -size -5 -type f $TDIR"
4108 NUMS=$($CMD | wc -l)
4109 [ $NUMS -eq $EXPECTED ] ||
4110 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4112 CMD="$LFIND -size -5 -type f $TDIR"
4113 NUMS=$($CMD | wc -l)
4114 [ $NUMS -eq $EXPECTED ] ||
4115 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4117 run_test 56r "check lfs find -size works =========================="
4119 test_56s() { # LU-611
4121 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT"
4123 if [ $OSTCOUNT -gt 1 ]; then
4124 $SETSTRIPE -c 1 $TDIR/$tfile.{0,1,2,3}
4128 ONESTRIPE=$(((NUMDIRS + 1) * NUMFILES))
4132 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4133 CMD="$LFIND -stripe-count $OSTCOUNT -type f $TDIR"
4134 NUMS=$($CMD | wc -l)
4135 [ $NUMS -eq $EXPECTED ] ||
4136 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4138 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + EXTRA))
4139 CMD="$LFIND -stripe-count +0 -type f $TDIR"
4140 NUMS=$($CMD | wc -l)
4141 [ $NUMS -eq $EXPECTED ] ||
4142 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4145 CMD="$LFIND -stripe-count 1 -type f $TDIR"
4146 NUMS=$($CMD | wc -l)
4147 [ $NUMS -eq $EXPECTED ] ||
4148 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4150 CMD="$LFIND -stripe-count -2 -type f $TDIR"
4151 NUMS=$($CMD | wc -l)
4152 [ $NUMS -eq $EXPECTED ] ||
4153 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4156 CMD="$LFIND -stripe-count $((OSTCOUNT + 1)) -type f $TDIR"
4157 NUMS=$($CMD | wc -l)
4158 [ $NUMS -eq $EXPECTED ] ||
4159 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4161 run_test 56s "check lfs find -stripe-count works"
4163 test_56t() { # LU-611
4165 setup_56 $NUMFILES $NUMDIRS "-s 512k"
4167 $SETSTRIPE -S 256k $TDIR/$tfile.{0,1,2,3}
4169 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4170 CMD="$LFIND -stripe-size 512k -type f $TDIR"
4171 NUMS=$($CMD | wc -l)
4172 [ $NUMS -eq $EXPECTED ] ||
4173 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4175 CMD="$LFIND -stripe-size +320k -type f $TDIR"
4176 NUMS=$($CMD | wc -l)
4177 [ $NUMS -eq $EXPECTED ] ||
4178 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4180 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + 4))
4181 CMD="$LFIND -stripe-size +200k -type f $TDIR"
4182 NUMS=$($CMD | wc -l)
4183 [ $NUMS -eq $EXPECTED ] ||
4184 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4186 CMD="$LFIND -stripe-size -640k -type f $TDIR"
4187 NUMS=$($CMD | wc -l)
4188 [ $NUMS -eq $EXPECTED ] ||
4189 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4192 CMD="$LFIND -stripe-size 256k -type f $TDIR"
4193 NUMS=$($CMD | wc -l)
4194 [ $NUMS -eq $EXPECTED ] ||
4195 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4197 CMD="$LFIND -stripe-size -320k -type f $TDIR"
4198 NUMS=$($CMD | wc -l)
4199 [ $NUMS -eq $EXPECTED ] ||
4200 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4203 CMD="$LFIND -stripe-size 1024k -type f $TDIR"
4204 NUMS=$($CMD | wc -l)
4205 [ $NUMS -eq $EXPECTED ] ||
4206 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4208 run_test 56t "check lfs find -stripe-size works"
4210 test_56u() { # LU-611
4212 setup_56 $NUMFILES $NUMDIRS "-i 0"
4214 if [ $OSTCOUNT -gt 1 ]; then
4215 $SETSTRIPE -i 1 $TDIR/$tfile.{0,1,2,3}
4221 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4222 CMD="$LFIND -stripe-index 0 -type f $TDIR"
4223 NUMS=$($CMD | wc -l)
4224 [ $NUMS -eq $EXPECTED ] ||
4225 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4228 CMD="$LFIND -stripe-index 1 -type f $TDIR"
4229 NUMS=$($CMD | wc -l)
4230 [ $NUMS -eq $EXPECTED ] ||
4231 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4233 CMD="$LFIND ! -stripe-index 0 -type f $TDIR"
4234 NUMS=$($CMD | wc -l)
4235 [ $NUMS -eq $EXPECTED ] ||
4236 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4239 # This should produce an error and not return any files
4240 CMD="$LFIND -stripe-index $OSTCOUNT -type f $TDIR"
4241 NUMS=$($CMD 2>/dev/null | wc -l)
4242 [ $NUMS -eq $EXPECTED ] ||
4243 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4245 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + ONESTRIPE))
4246 CMD="$LFIND -stripe-index 0,1 -type f $TDIR"
4247 NUMS=$($CMD | wc -l)
4248 [ $NUMS -eq $EXPECTED ] ||
4249 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4251 run_test 56u "check lfs find -stripe-index works"
4258 setup_56 $NUMFILES $NUMDIRS
4260 UUID=$(mdtuuid_from_index $MDT_IDX $TDIR)
4261 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT index $MDT_IDX"
4263 for file in $($LFIND -mdt $UUID $TDIR); do
4264 file_mdt_idx=$($GETSTRIPE -M $file)
4265 [ $file_mdt_idx -eq $MDT_IDX ] ||
4266 error "'lfind -mdt $UUID' != 'getstripe -M' ($file_mdt_idx)"
4269 run_test 56v "check 'lfs find -mdt match with lfs getstripe -M' ======="
4271 # Get and check the actual stripe count of one file.
4272 # Usage: check_stripe_count <file> <expected_stripe_count>
4273 check_stripe_count() {
4278 [[ -z "$file" || -z "$expected" ]] &&
4279 error "check_stripe_count: invalid argument!"
4281 local cmd="$GETSTRIPE -c $file"
4282 actual=$($cmd) || error "$cmd failed"
4283 actual=${actual%% *}
4285 if [[ $actual -ne $expected ]]; then
4286 [[ $expected -eq -1 ]] ||
4287 error "$cmd wrong: found $actual, expected $expected"
4288 [[ $actual -eq $OSTCOUNT ]] ||
4289 error "$cmd wrong: found $actual, expected $OSTCOUNT"
4294 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4297 rm -rf $TDIR || error "remove $TDIR failed"
4298 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT"
4301 stripe_size=$($GETSTRIPE -S -d $TDIR) ||
4302 error "$GETSTRIPE -S -d $TDIR failed"
4303 stripe_size=${stripe_size%% *}
4305 local file_size=$((stripe_size * OSTCOUNT))
4306 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
4307 local required_space=$((file_num * file_size))
4308 local free_space=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
4309 [[ $free_space -le $((required_space / 1024)) ]] &&
4310 skip_env "need at least $required_space bytes free space," \
4311 "have $free_space kbytes" && return
4314 local dd_count=$((file_size / dd_bs))
4316 # write data into the files
4320 for i in $(seq 1 $NUMFILES); do
4322 yes | dd bs=$dd_bs count=$dd_count of=$file >/dev/null 2>&1 ||
4323 error "write data into $file failed"
4325 for i in $(seq 1 $NUMDIRS); do
4326 for j in $(seq 1 $NUMFILES); do
4327 file=$TDIR/dir$i/file$j
4328 yes | dd bs=$dd_bs count=$dd_count of=$file \
4330 error "write data into $file failed"
4335 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
4338 local cmd="$LFS_MIGRATE -y -c $expected $TDIR/file1"
4340 eval $cmd || error "$cmd failed"
4342 check_stripe_count $TDIR/file1 $expected
4345 cmd="$LFS_MIGRATE -y -c $expected $TDIR/dir1"
4347 eval $cmd || error "$cmd failed"
4349 for j in $(seq 1 $NUMFILES); do
4350 check_stripe_count $TDIR/dir1/file$j $expected
4353 # lfs_migrate works with lfs find
4354 cmd="$LFIND -stripe_count $OSTCOUNT -type f $TDIR |
4355 $LFS_MIGRATE -y -c $expected"
4357 eval $cmd || error "$cmd failed"
4359 for i in $(seq 2 $NUMFILES); do
4360 check_stripe_count $TDIR/file$i $expected
4362 for i in $(seq 2 $NUMDIRS); do
4363 for j in $(seq 1 $NUMFILES); do
4364 check_stripe_count $TDIR/dir$i/file$j $expected
4368 run_test 56w "check lfs_migrate -c stripe_count works"
4371 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4372 # note test will not do anything if MDS is not local
4373 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4374 skip "Only applicable to ldiskfs-based MDTs"
4378 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4379 local MNTDEV="osd*.*MDT*.mntdev"
4380 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
4381 [ -z "$DEV" ] && error "can't access $MNTDEV"
4382 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
4383 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
4384 error "can't access $DEV"
4385 DEVISIZE=`awk '/Inode size:/ { print $3 }' $TMP/t57a.dump`
4386 [ "$DEVISIZE" -gt 128 ] || error "inode size $DEVISIZE"
4390 run_test 57a "verify MDS filesystem created with large inodes =="
4393 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4394 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4395 skip "Only applicable to ldiskfs-based MDTs"
4399 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4404 local FILEN=$dir/f$FILECOUNT
4406 rm -rf $dir || error "removing $dir"
4407 test_mkdir -p $dir || error "creating $dir"
4408 local num=$(get_mds_dir $dir)
4411 echo "mcreating $FILECOUNT files"
4412 createmany -m $dir/f 1 $FILECOUNT || \
4413 error "creating files in $dir"
4415 # verify that files do not have EAs yet
4416 $GETSTRIPE $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
4417 $GETSTRIPE $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
4421 df $dir #make sure we get new statfs data
4422 local MDSFREE=$(do_facet $mymds \
4423 lctl get_param -n osd*.*MDT000$((num -1)).kbytesfree)
4424 local MDCFREE=$(lctl get_param -n mdc.*MDT000$((num -1))-mdc-*.kbytesfree)
4425 echo "opening files to create objects/EAs"
4427 for FILE in `seq -f $dir/f%g 1 $FILECOUNT`; do
4428 $OPENFILE -f O_RDWR $FILE > /dev/null 2>&1 || error "opening $FILE"
4431 # verify that files have EAs now
4432 $GETSTRIPE $FILE1 | grep -q "obdidx" || error "$FILE1 missing EA"
4433 $GETSTRIPE $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
4435 sleep 1 #make sure we get new statfs data
4437 local MDSFREE2=$(do_facet $mymds \
4438 lctl get_param -n osd*.*MDT000$((num -1)).kbytesfree)
4439 local MDCFREE2=$(lctl get_param -n mdc.*MDT000$((num -1))-mdc-*.kbytesfree)
4440 if [ "$MDCFREE2" -lt "$((MDCFREE - 8))" ]; then
4441 if [ "$MDSFREE" != "$MDSFREE2" ]; then
4442 error "MDC before $MDCFREE != after $MDCFREE2"
4444 echo "MDC before $MDCFREE != after $MDCFREE2"
4445 echo "unable to confirm if MDS has large inodes"
4450 run_test 57b "default LOV EAs are stored inside large inodes ==="
4453 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4454 [ -z "$(which wiretest 2>/dev/null)" ] &&
4455 skip_env "could not find wiretest" && return
4458 run_test 58 "verify cross-platform wire constants =============="
4461 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4462 echo "touch 130 files"
4463 createmany -o $DIR/f59- 130
4465 unlinkmany $DIR/f59- 130
4467 # wait for commitment of removal
4468 wait_delete_completed
4470 run_test 59 "verify cancellation of llog records async ========="
4472 TEST60_HEAD="test_60 run $RANDOM"
4474 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4475 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
4476 [ ! -f run-llog.sh ] && skip_env "missing subtest run-llog.sh" && return
4477 log "$TEST60_HEAD - from kernel mode"
4478 do_facet mgs sh run-llog.sh
4480 run_test 60a "llog sanity tests run from kernel module =========="
4482 test_60b() { # bug 6411
4483 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4485 LLOG_COUNT=`dmesg | awk "/$TEST60_HEAD/{marker = 1; from_marker = 0;}
4497 [ $LLOG_COUNT -gt 50 ] && error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)"|| true
4499 run_test 60b "limit repeated messages from CERROR/CWARN ========"
4502 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4503 echo "create 5000 files"
4504 createmany -o $DIR/f60c- 5000
4505 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
4506 lctl set_param fail_loc=0x80000137
4507 unlinkmany $DIR/f60c- 5000
4508 lctl set_param fail_loc=0
4510 run_test 60c "unlink file when mds full"
4513 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4514 SAVEPRINTK=$(lctl get_param -n printk)
4516 # verify "lctl mark" is even working"
4517 MESSAGE="test message ID $RANDOM $$"
4518 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
4519 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
4521 lctl set_param printk=0 || error "set lnet.printk failed"
4522 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
4523 MESSAGE="new test message ID $RANDOM $$"
4524 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
4525 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
4526 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
4528 lctl set_param -n printk="$SAVEPRINTK"
4530 run_test 60d "test printk console message masking"
4533 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4535 dd if=/dev/zero of=$f bs=`page_size` count=1
4536 cancel_lru_locks osc
4537 $MULTIOP $f OSMWUc || error
4540 run_test 61 "mmap() writes don't make sync hang ================"
4542 # bug 2330 - insufficient obd_match error checking causes LBUG
4544 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4547 cancel_lru_locks osc
4548 lctl set_param fail_loc=0x405
4549 cat $f && error "cat succeeded, expect -EIO"
4550 lctl set_param fail_loc=0
4552 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
4553 # match every page all of the time.
4554 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
4556 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
4557 test_63a() { # was test_63
4558 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4559 MAX_DIRTY_MB=`lctl get_param -n osc.*.max_dirty_mb | head -n 1`
4560 lctl set_param -n osc.*.max_dirty_mb 0
4561 for i in `seq 10` ; do
4562 dd if=/dev/zero of=$DIR/f63 bs=8k &
4568 lctl set_param -n osc.*.max_dirty_mb $MAX_DIRTY_MB
4569 rm -f $DIR/f63 || true
4571 run_test 63a "Verify oig_wait interruption does not crash ======="
4573 # bug 2248 - async write errors didn't return to application on sync
4574 # bug 3677 - async write errors left page locked
4576 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4578 lctl set_param debug=-1
4580 # ensure we have a grant to do async writes
4581 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
4584 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
4585 lctl set_param fail_loc=0x80000406
4586 $MULTIOP $DIR/$tfile Owy && \
4587 error "sync didn't return ENOMEM"
4588 sync; sleep 2; sync # do a real sync this time to flush page
4589 lctl get_param -n llite.*.dump_page_cache | grep locked && \
4590 error "locked page left in cache after async error" || true
4593 run_test 63b "async write errors should be returned to fsync ==="
4596 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4598 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
4600 run_test 64a "verify filter grant calculations (in kernel) ====="
4603 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4604 [ ! -f oos.sh ] && skip_env "missing subtest oos.sh" && return
4607 run_test 64b "check out-of-space detection on client ==========="
4610 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
4612 run_test 64c "verify grant shrink ========================------"
4614 # bug 1414 - set/get directories' stripe info
4616 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4617 test_mkdir -p $DIR/$tdir
4619 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
4621 run_test 65a "directory with no stripe info ===================="
4624 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4625 test_mkdir -p $DIR/$tdir
4626 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
4629 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
4631 run_test 65b "directory setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1"
4634 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4635 if [ $OSTCOUNT -gt 1 ]; then
4636 test_mkdir -p $DIR/$tdir
4637 $SETSTRIPE -S $(($STRIPESIZE * 4)) -i 1 \
4638 -c $(($OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
4640 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
4643 run_test 65c "directory setstripe -S $((STRIPESIZE*4)) -i 1 -c $((OSTCOUNT-1))"
4646 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4647 test_mkdir -p $DIR/$tdir
4648 if [ $STRIPECOUNT -le 0 ]; then
4650 elif [ $STRIPECOUNT -gt 2000 ]; then
4651 #LOV_MAX_STRIPE_COUNT is 2000
4652 [ $OSTCOUNT -gt 2000 ] && sc=2000 || sc=$(($OSTCOUNT - 1))
4654 sc=$(($STRIPECOUNT - 1))
4656 $SETSTRIPE -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
4657 touch $DIR/$tdir/f4 $DIR/$tdir/f5
4658 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
4659 error "lverify failed"
4661 run_test 65d "directory setstripe -S $STRIPESIZE -c stripe_count"
4664 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4665 test_mkdir -p $DIR/$tdir
4667 $SETSTRIPE $DIR/$tdir || error "setstripe"
4668 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
4669 error "no stripe info failed"
4671 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
4673 run_test 65e "directory setstripe defaults ======================="
4676 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4677 test_mkdir -p $DIR/${tdir}f
4678 $RUNAS $SETSTRIPE $DIR/${tdir}f && error "setstripe succeeded" || true
4680 run_test 65f "dir setstripe permission (should return error) ==="
4683 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4684 test_mkdir -p $DIR/$tdir
4685 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
4687 $SETSTRIPE -d $DIR/$tdir || error "setstripe"
4688 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
4689 error "delete default stripe failed"
4691 run_test 65g "directory setstripe -d ==========================="
4694 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4695 test_mkdir -p $DIR/$tdir
4696 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
4698 test_mkdir -p $DIR/$tdir/dd1
4699 [ $($GETSTRIPE -c $DIR/$tdir) == $($GETSTRIPE -c $DIR/$tdir/dd1) ] ||
4700 error "stripe info inherit failed"
4702 run_test 65h "directory stripe info inherit ===================="
4704 test_65i() { # bug6367
4705 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4706 $SETSTRIPE -S 65536 -c -1 $MOUNT
4708 run_test 65i "set non-default striping on root directory (bug 6367)="
4710 test_65ia() { # bug12836
4711 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4712 $GETSTRIPE $MOUNT || error "getstripe $MOUNT failed"
4714 run_test 65ia "getstripe on -1 default directory striping"
4716 test_65ib() { # bug12836
4717 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4718 $GETSTRIPE -v $MOUNT || error "getstripe -v $MOUNT failed"
4720 run_test 65ib "getstripe -v on -1 default directory striping"
4722 test_65ic() { # bug12836
4723 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4724 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
4726 run_test 65ic "new find on -1 default directory striping"
4728 test_65j() { # bug6367
4729 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4731 # if we aren't already remounting for each test, do so for this test
4732 if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
4733 cleanup || error "failed to unmount"
4736 $SETSTRIPE -d $MOUNT || error "setstripe failed"
4738 run_test 65j "set default striping on root directory (bug 6367)="
4740 test_65k() { # bug11679
4741 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4742 [ "$OSTCOUNT" -lt 2 ] && skip_env "too few OSTs" && return
4743 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4745 echo "Check OST status: "
4746 local MDS_OSCS=`do_facet $SINGLEMDS lctl dl |
4747 awk '/[oO][sS][cC].*md[ts]/ { print $4 }'`
4749 for OSC in $MDS_OSCS; do
4750 echo $OSC "is activate"
4751 do_facet $SINGLEMDS lctl --device %$OSC activate
4755 for INACTIVE_OSC in $MDS_OSCS; do
4756 echo "Deactivate: " $INACTIVE_OSC
4757 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
4758 for STRIPE_OSC in $MDS_OSCS; do
4759 OST=`osc_to_ost $STRIPE_OSC`
4760 IDX=`do_facet $SINGLEMDS lctl get_param -n lov.*md*.target_obd |
4761 awk -F: /$OST/'{ print $1 }' | head -n 1`
4763 [ -f $DIR/$tdir/$IDX ] && continue
4764 echo "$SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX"
4765 $SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX
4767 [ $RC -ne 0 ] && error "setstripe should have succeeded"
4770 echo $INACTIVE_OSC "is Activate."
4771 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
4774 run_test 65k "validate manual striping works properly with deactivated OSCs"
4776 test_65l() { # bug 12836
4777 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4778 test_mkdir -p $DIR/$tdir/test_dir
4779 $SETSTRIPE -c -1 $DIR/$tdir/test_dir
4780 $LFS find -mtime -1 $DIR/$tdir >/dev/null
4782 run_test 65l "lfs find on -1 stripe dir ========================"
4784 # bug 2543 - update blocks count on client
4786 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4788 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
4789 sync; sync_all_data; sync; sync_all_data
4790 cancel_lru_locks osc
4791 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
4792 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
4794 run_test 66 "update inode blocks count on client ==============="
4799 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4801 if [ ! -z "$LLOOP" ]; then
4802 if swapon -s | grep -q $LLOOP; then
4803 swapoff $LLOOP || error "swapoff failed"
4806 $LCTL blockdev_detach $LLOOP || error "detach failed"
4810 if [ ! -z "$LLITELOOPLOAD" ]; then
4818 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
4822 swapon -s | awk '($1 == "'$1'") { print $4 }'
4825 # test case for lloop driver, basic function
4827 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4828 [ "$UID" != 0 ] && skip_env "must run as root" && return
4829 llite_lloop_enabled || \
4830 { skip_env "llite_lloop module disabled" && return; }
4832 trap cleanup_68 EXIT
4834 if ! module_loaded llite_lloop; then
4835 if load_module llite/llite_lloop; then
4838 skip_env "can't find module llite_lloop"
4843 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
4844 dd if=/dev/zero of=$DIR/f68a bs=4k count=1024
4845 $LCTL blockdev_attach $DIR/f68a $LLOOP || error "attach failed"
4847 directio rdwr $LLOOP 0 1024 4096 || error "direct write failed"
4848 directio rdwr $LLOOP 0 1025 4096 && error "direct write should fail"
4852 run_test 68a "lloop driver - basic test ========================"
4854 # excercise swapping to lustre by adding a high priority swapfile entry
4855 # and then consuming memory until it is used.
4856 test_68b() { # was test_68
4857 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4858 [ "$UID" != 0 ] && skip_env "must run as root" && return
4859 lctl get_param -n devices | grep -q obdfilter && \
4860 skip "local OST" && return
4862 grep -q llite_lloop /proc/modules
4863 [ $? -ne 0 ] && skip "can't find module llite_lloop" && return
4865 [ -z "`$LCTL list_nids | grep -v tcp`" ] && \
4866 skip "can't reliably test swap with TCP" && return
4868 MEMTOTAL=`meminfo MemTotal`
4869 NR_BLOCKS=$((MEMTOTAL>>8))
4870 [[ $NR_BLOCKS -le 2048 ]] && NR_BLOCKS=2048
4872 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
4873 dd if=/dev/zero of=$DIR/f68b bs=64k seek=$NR_BLOCKS count=1
4876 $LCTL blockdev_attach $DIR/f68b $LLOOP || error "attach failed"
4878 trap cleanup_68 EXIT
4880 swapon -p 32767 $LLOOP || error "swapon $LLOOP failed"
4882 echo "before: `swapon -s | grep $LLOOP`"
4883 $MEMHOG $MEMTOTAL || error "error allocating $MEMTOTAL kB"
4884 echo "after: `swapon -s | grep $LLOOP`"
4885 SWAPUSED=`swap_used $LLOOP`
4889 [ $SWAPUSED -eq 0 ] && echo "no swap used???" || true
4891 run_test 68b "support swapping to Lustre ========================"
4893 # bug5265, obdfilter oa2dentry return -ENOENT
4894 # #define OBD_FAIL_OST_ENOENT 0x217
4896 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4897 remote_ost_nodsh && skip "remote OST with nodsh" && return
4900 $SETSTRIPE -c 1 -i 0 $f
4902 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
4904 do_facet ost1 lctl set_param fail_loc=0x217
4905 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
4906 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
4908 do_facet ost1 lctl set_param fail_loc=0
4909 $DIRECTIO write $f 0 2 || error "write error"
4911 cancel_lru_locks osc
4912 $DIRECTIO read $f 0 1 || error "read error"
4914 do_facet ost1 lctl set_param fail_loc=0x217
4915 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
4917 do_facet ost1 lctl set_param fail_loc=0
4920 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
4923 test_mkdir -p $DIR/$tdir
4924 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
4926 run_test 71 "Running dbench on lustre (don't segment fault) ===="
4928 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
4929 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4930 check_kernel_version 43 || return 0
4931 [ "$RUNAS_ID" = "$UID" ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4933 # Check that testing environment is properly set up. Skip if not
4934 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS || {
4935 skip_env "User $RUNAS_ID does not exist - skipping"
4938 # We had better clear the $DIR to get enough space for dd
4943 $RUNAS dd if=/dev/zero of=$DIR/f72 bs=512 count=1 || error
4944 # See if we are still setuid/sgid
4945 test -u $DIR/f72 -o -g $DIR/f72 && error "S/gid is not dropped on write"
4946 # Now test that MDS is updated too
4947 cancel_lru_locks mdc
4948 test -u $DIR/f72 -o -g $DIR/f72 && error "S/gid is not dropped on MDS"
4951 run_test 72a "Test that remove suid works properly (bug5695) ===="
4953 test_72b() { # bug 24226 -- keep mode setting when size is not changing
4956 [ "$RUNAS_ID" = "$UID" ] && \
4957 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4958 [ "$RUNAS_ID" -eq 0 ] && \
4959 skip_env "RUNAS_ID = 0 -- skipping" && return
4961 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4962 # Check that testing environment is properly set up. Skip if not
4963 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS || {
4964 skip_env "User $RUNAS_ID does not exist - skipping"
4967 touch $DIR/${tfile}-f{g,u}
4968 test_mkdir $DIR/${tfile}-dg
4969 test_mkdir $DIR/${tfile}-du
4970 chmod 770 $DIR/${tfile}-{f,d}{g,u}
4971 chmod g+s $DIR/${tfile}-{f,d}g
4972 chmod u+s $DIR/${tfile}-{f,d}u
4973 for perm in 777 2777 4777; do
4974 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
4975 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
4976 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
4977 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
4981 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
4983 # bug 3462 - multiple simultaneous MDC requests
4985 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4986 test_mkdir $DIR/d73-1
4987 test_mkdir $DIR/d73-2
4988 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
4991 lctl set_param fail_loc=0x80000129
4992 $MULTIOP $DIR/d73-1/f73-2 Oc &
4994 lctl set_param fail_loc=0
4996 $MULTIOP $DIR/d73-2/f73-3 Oc &
5000 wait $pid1 || return 1
5004 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
5005 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
5006 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
5010 run_test 73 "multiple MDC requests (should not deadlock)"
5012 test_74a() { # bug 6149, 6184
5013 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5014 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
5016 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
5017 # will spin in a tight reconnection loop
5019 lctl set_param fail_loc=0x8000030e
5020 # get any lock that won't be difficult - lookup works.
5022 lctl set_param fail_loc=0
5026 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
5028 test_74b() { # bug 13310
5029 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5030 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
5032 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
5033 # will spin in a tight reconnection loop
5034 lctl set_param fail_loc=0x8000030e
5035 # get a "difficult" lock
5037 lctl set_param fail_loc=0
5041 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
5044 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5045 #define OBD_FAIL_LDLM_NEW_LOCK
5046 lctl set_param fail_loc=0x80000319
5047 touch $DIR/$tfile && error "Touch successful"
5050 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
5053 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
5056 get_inode_slab_tunables() {
5057 awk '/lustre_inode_cache/ {print $9," ",$10," ",$11; exit}' /proc/slabinfo
5060 set_inode_slab_tunables() {
5061 echo "lustre_inode_cache $1" > /proc/slabinfo
5064 test_76() { # Now for bug 20433, added originally in bug 1443
5065 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5066 local SLAB_SETTINGS=`get_inode_slab_tunables`
5067 local CPUS=`getconf _NPROCESSORS_ONLN`
5068 # we cannot set limit below 1 which means 1 inode in each
5069 # per-cpu cache is still allowed
5070 set_inode_slab_tunables "1 1 0"
5071 cancel_lru_locks osc
5072 BEFORE_INODES=`num_inodes`
5073 echo "before inodes: $BEFORE_INODES"
5075 [ "$SLOW" = "no" ] && COUNT=100
5076 for i in `seq $COUNT`; do
5080 cancel_lru_locks osc
5081 AFTER_INODES=`num_inodes`
5082 echo "after inodes: $AFTER_INODES"
5084 while [ $((AFTER_INODES-1*CPUS)) -gt $BEFORE_INODES ]; do
5086 AFTER_INODES=`num_inodes`
5088 echo "wait $wait seconds inodes: $AFTER_INODES"
5089 if [ $wait -gt 30 ]; then
5090 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
5093 set_inode_slab_tunables "$SLAB_SETTINGS"
5095 run_test 76 "confirm clients recycle inodes properly ===="
5101 # Note: in sptlrpc modes which enable its own bulk checksum, the
5102 # original crc32_le bulk checksum will be automatically disabled,
5103 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
5104 # will be checked by sptlrpc code against sptlrpc bulk checksum.
5105 # In this case set_checksums() will not be no-op, because sptlrpc
5106 # bulk checksum will be enabled all through the test.
5108 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
5109 lctl set_param -n osc.*.checksums $1
5113 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
5114 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
5115 CKSUM_TYPES=${CKSUM_TYPES:-"crc32 adler"}
5116 [ "$ORIG_CSUM_TYPE" = "crc32c" ] && CKSUM_TYPES="$CKSUM_TYPES crc32c"
5119 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
5120 log "set checksum type to $1"
5123 F77_TMP=$TMP/f77-temp
5126 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
5127 error "error writing to $F77_TMP"
5130 test_77a() { # bug 10889
5131 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5132 $GSS && skip "could not run with gss" && return
5133 [ ! -f $F77_TMP ] && setup_f77
5135 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
5139 run_test 77a "normal checksum read/write operation ============="
5141 test_77b() { # bug 10889
5142 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5143 $GSS && skip "could not run with gss" && return
5144 [ ! -f $F77_TMP ] && setup_f77
5145 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5146 lctl set_param fail_loc=0x80000409
5148 dd if=$F77_TMP of=$DIR/f77b bs=1M count=$F77SZ conv=sync || \
5149 error "dd error: $?"
5150 lctl set_param fail_loc=0
5153 run_test 77b "checksum error on client write ===================="
5155 test_77c() { # bug 10889
5156 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5157 $GSS && skip "could not run with gss" && return
5158 [ ! -f $DIR/f77b ] && skip "requires 77b - skipping" && return
5160 for algo in $CKSUM_TYPES; do
5161 cancel_lru_locks osc
5162 set_checksum_type $algo
5163 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
5164 lctl set_param fail_loc=0x80000408
5165 cmp $F77_TMP $DIR/f77b || error "file compare failed"
5166 lctl set_param fail_loc=0
5169 set_checksum_type $ORIG_CSUM_TYPE
5172 run_test 77c "checksum error on client read ==================="
5174 test_77d() { # bug 10889
5175 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5176 $GSS && skip "could not run with gss" && return
5177 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5178 lctl set_param fail_loc=0x80000409
5180 directio write $DIR/f77 0 $F77SZ $((1024 * 1024)) || \
5181 error "direct write: rc=$?"
5182 lctl set_param fail_loc=0
5185 run_test 77d "checksum error on OST direct write ==============="
5187 test_77e() { # bug 10889
5188 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5189 $GSS && skip "could not run with gss" && return
5190 [ ! -f $DIR/f77 ] && skip "requires 77d - skipping" && return
5191 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
5192 lctl set_param fail_loc=0x80000408
5194 cancel_lru_locks osc
5195 directio read $DIR/f77 0 $F77SZ $((1024 * 1024)) || \
5196 error "direct read: rc=$?"
5197 lctl set_param fail_loc=0
5200 run_test 77e "checksum error on OST direct read ================"
5202 test_77f() { # bug 10889
5203 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5204 $GSS && skip "could not run with gss" && return
5206 for algo in $CKSUM_TYPES; do
5207 cancel_lru_locks osc
5208 set_checksum_type $algo
5209 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5210 lctl set_param fail_loc=0x409
5211 directio write $DIR/f77 0 $F77SZ $((1024 * 1024)) && \
5212 error "direct write succeeded"
5213 lctl set_param fail_loc=0
5215 set_checksum_type $ORIG_CSUM_TYPE
5218 run_test 77f "repeat checksum error on write (expect error) ===="
5220 test_77g() { # bug 10889
5221 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5222 $GSS && skip "could not run with gss" && return
5223 remote_ost_nodsh && skip "remote OST with nodsh" && return
5225 [ ! -f $F77_TMP ] && setup_f77
5227 $SETSTRIPE -c 1 -i 0 $DIR/f77g
5228 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
5229 do_facet ost1 lctl set_param fail_loc=0x8000021a
5231 dd if=$F77_TMP of=$DIR/f77g bs=1M count=$F77SZ || \
5232 error "write error: rc=$?"
5233 do_facet ost1 lctl set_param fail_loc=0
5236 run_test 77g "checksum error on OST write ======================"
5238 test_77h() { # bug 10889
5239 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5240 $GSS && skip "could not run with gss" && return
5241 remote_ost_nodsh && skip "remote OST with nodsh" && return
5243 [ ! -f $DIR/f77g ] && skip "requires 77g - skipping" && return
5244 cancel_lru_locks osc
5245 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
5246 do_facet ost1 lctl set_param fail_loc=0x8000021b
5248 cmp $F77_TMP $DIR/f77g || error "file compare failed"
5249 do_facet ost1 lctl set_param fail_loc=0
5252 run_test 77h "checksum error on OST read ======================="
5254 test_77i() { # bug 13805
5255 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5256 $GSS && skip "could not run with gss" && return
5257 #define OBD_FAIL_OSC_CONNECT_CKSUM 0x40b
5258 lctl set_param fail_loc=0x40b
5259 remount_client $MOUNT
5260 lctl set_param fail_loc=0
5261 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
5262 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
5263 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
5264 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
5266 remount_client $MOUNT
5268 run_test 77i "client not supporting OSD_CONNECT_CKSUM =========="
5270 test_77j() { # bug 13805
5271 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5272 $GSS && skip "could not run with gss" && return
5273 #define OBD_FAIL_OSC_CKSUM_ADLER_ONLY 0x40c
5274 lctl set_param fail_loc=0x40c
5275 remount_client $MOUNT
5276 lctl set_param fail_loc=0
5277 sleep 2 # wait async osc connect to finish
5278 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
5279 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
5280 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
5281 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
5283 remount_client $MOUNT
5285 run_test 77j "client only supporting ADLER32 ===================="
5287 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
5291 test_78() { # bug 10901
5292 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5293 remote_ost || { skip_env "local OST" && return; }
5296 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
5297 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
5298 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
5299 echo "MemTotal: $MEMTOTAL"
5300 # reserve 256MB of memory for the kernel and other running processes,
5301 # and then take 1/2 of the remaining memory for the read/write buffers.
5302 if [ $MEMTOTAL -gt 512 ] ;then
5303 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
5305 # for those poor memory-starved high-end clusters...
5306 MEMTOTAL=$((MEMTOTAL / 2))
5308 echo "Mem to use for directio: $MEMTOTAL"
5309 [ $F78SIZE -gt $MEMTOTAL ] && F78SIZE=$MEMTOTAL
5310 [ $F78SIZE -gt 512 ] && F78SIZE=512
5311 [ $F78SIZE -gt $((MAXFREE / 1024)) ] && F78SIZE=$((MAXFREE / 1024))
5312 SMALLESTOST=`lfs df $DIR |grep OST | awk '{print $4}' |sort -n |head -1`
5313 echo "Smallest OST: $SMALLESTOST"
5314 [ $SMALLESTOST -lt 10240 ] && \
5315 skip "too small OSTSIZE, useless to run large O_DIRECT test" && return 0
5317 [ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ] && \
5318 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
5320 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
5321 echo "File size: $F78SIZE"
5322 $SETSTRIPE -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
5323 for i in `seq 1 $NSEQ`
5325 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
5326 echo directIO rdwr round $i of $NSEQ
5327 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
5332 run_test 78 "handle large O_DIRECT writes correctly ============"
5334 test_79() { # bug 12743
5335 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5336 wait_delete_completed
5338 BKTOTAL=$(calc_osc_kbytes kbytestotal)
5339 BKFREE=$(calc_osc_kbytes kbytesfree)
5340 BKAVAIL=$(calc_osc_kbytes kbytesavail)
5342 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
5343 DFTOTAL=`echo $STRING | cut -d, -f1`
5344 DFUSED=`echo $STRING | cut -d, -f2`
5345 DFAVAIL=`echo $STRING | cut -d, -f3`
5346 DFFREE=$(($DFTOTAL - $DFUSED))
5348 ALLOWANCE=$((64 * $OSTCOUNT))
5350 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
5351 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
5352 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
5354 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
5355 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
5356 error "df free($DFFREE) mismatch OST free($BKFREE)"
5358 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
5359 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
5360 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
5363 run_test 79 "df report consistency check ======================="
5365 test_80() { # bug 10718
5366 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5367 # relax strong synchronous semantics for slow backends like ZFS
5368 local soc="obdfilter.*.sync_on_lock_cancel"
5369 local soc_old=$(do_facet ost1 lctl get_param -n $soc | head -n1)
5371 if [ "$soc_old" != "never" -a "$(facet_fstype ost1)" != "ldiskfs" ]; then
5372 hosts=$(for host in $(seq -f "ost%g" 1 $OSTCOUNT); do
5373 facet_active_host $host; done | sort -u)
5374 do_nodes $hosts lctl set_param $soc=never
5377 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
5379 local BEFORE=`date +%s`
5380 cancel_lru_locks osc
5381 local AFTER=`date +%s`
5382 local DIFF=$((AFTER-BEFORE))
5383 if [ $DIFF -gt 1 ] ; then
5384 error "elapsed for 1M@1T = $DIFF"
5387 [ -n "$hosts" ] && do_nodes $hosts lctl set_param $soc=$soc_old
5391 run_test 80 "Page eviction is equally fast at high offsets too ===="
5393 test_81a() { # LU-456
5394 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5395 remote_ost_nodsh && skip "remote OST with nodsh" && return
5396 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
5397 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
5398 do_facet ost1 lctl set_param fail_loc=0x80000228
5400 # write should trigger a retry and success
5401 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
5402 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
5404 if [ $RC -ne 0 ] ; then
5405 error "write should success, but failed for $RC"
5408 run_test 81a "OST should retry write when get -ENOSPC ==============="
5410 test_81b() { # LU-456
5411 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5412 remote_ost_nodsh && skip "remote OST with nodsh" && return
5413 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
5414 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
5415 do_facet ost1 lctl set_param fail_loc=0x228
5417 # write should retry several times and return -ENOSPC finally
5418 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
5419 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
5422 if [ $RC -ne $ENOSPC ] ; then
5423 error "dd should fail for -ENOSPC, but succeed."
5426 run_test 81b "OST should return -ENOSPC when retry still fails ======="
5428 test_82() { # LU-1031
5429 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10
5433 multiop_bg_pause $DIR/$tfile OG${gid1}_g${gid1}c || return 1
5435 multiop_bg_pause $DIR/$tfile O_G${gid2}r10g${gid2}c || return 2
5437 kill -USR1 $MULTIPID2
5439 if [[ `ps h -o comm -p $MULTIPID2` == "" ]]; then
5440 error "First grouplock does not block second one"
5442 echo "Second grouplock blocks first one"
5444 kill -USR1 $MULTIPID1
5448 run_test 82 "Basic grouplock test ==============================="
5451 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && \
5453 test_mkdir -p $DIR/d99cvsroot
5454 chown $RUNAS_ID $DIR/d99cvsroot
5455 local oldPWD=$PWD # bug 13584, use $TMP as working dir
5458 $RUNAS cvs -d $DIR/d99cvsroot init || error
5461 run_test 99a "cvs init ========================================="
5464 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5465 [ ! -d $DIR/d99cvsroot ] && test_99a
5467 # some versions of cvs import exit(1) when asked to import links or
5468 # files they can't read. ignore those files.
5469 TOIGNORE=$(find . -type l -printf '-I %f\n' -o \
5470 ! -perm +4 -printf '-I %f\n')
5471 $RUNAS cvs -d $DIR/d99cvsroot import -m "nomesg" $TOIGNORE \
5472 d99reposname vtag rtag
5474 run_test 99b "cvs import ======================================="
5477 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5478 [ ! -d $DIR/d99cvsroot ] && test_99b
5480 test_mkdir -p $DIR/d99reposname
5481 chown $RUNAS_ID $DIR/d99reposname
5482 $RUNAS cvs -d $DIR/d99cvsroot co d99reposname
5484 run_test 99c "cvs checkout ====================================="
5487 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5488 [ ! -d $DIR/d99cvsroot ] && test_99c
5489 cd $DIR/d99reposname
5491 $RUNAS cvs add -m 'addmsg' foo99
5493 run_test 99d "cvs add =========================================="
5496 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5497 [ ! -d $DIR/d99cvsroot ] && test_99c
5498 cd $DIR/d99reposname
5501 run_test 99e "cvs update ======================================="
5504 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5505 [ ! -d $DIR/d99cvsroot ] && test_99d
5506 cd $DIR/d99reposname
5507 $RUNAS cvs commit -m 'nomsg' foo99
5508 rm -fr $DIR/d99cvsroot
5510 run_test 99f "cvs commit ======================================="
5513 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5514 [ "$NETTYPE" = tcp ] || \
5515 { skip "TCP secure port test, not useful for NETTYPE=$NETTYPE" && \
5518 remote_ost_nodsh && skip "remote OST with nodsh" && return
5519 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5521 { skip "useless for local single node setup" && return; }
5523 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
5524 [ "$PROT" != "tcp" ] && continue
5525 RPORT=$(echo $REMOTE | cut -d: -f2)
5526 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
5529 LPORT=`echo $LOCAL | cut -d: -f2`
5530 if [ $LPORT -ge 1024 ]; then
5531 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
5533 error_exit "local: $LPORT > 1024, remote: $RPORT"
5536 [ "$rc" = 0 ] || error_exit "privileged port not found" )
5538 run_test 100 "check local port using privileged port ==========="
5540 function get_named_value()
5549 echo $line | sed "s/^$tag[ ]*//"
5556 export CACHE_MAX=$($LCTL get_param -n llite.*.max_cached_mb |
5557 awk '/^max_cached_mb/ { print $2 }')
5560 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
5565 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5569 local cache_limit=32
5571 $LCTL set_param -n osc.*-osc*.rpc_stats 0
5572 trap cleanup_101a EXIT
5573 $LCTL set_param -n llite.*.read_ahead_stats 0
5574 $LCTL set_param -n llite.*.max_cached_mb $cache_limit
5577 # randomly read 10000 of 64K chunks from file 3x 32MB in size
5579 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
5580 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
5583 for s in `$LCTL get_param -n llite.*.read_ahead_stats | \
5584 get_named_value 'read but discarded' | cut -d" " -f1`; do
5585 discard=$(($discard + $s))
5589 if [ $(($discard * 10)) -gt $nreads ] ;then
5590 $LCTL get_param osc.*-osc*.rpc_stats
5591 $LCTL get_param llite.*.read_ahead_stats
5592 error "too many ($discard) discarded pages"
5594 rm -f $DIR/$tfile || true
5596 run_test 101a "check read-ahead for random reads ================"
5599 test_mkdir -p $DIR/$tdir
5601 STRIPE_COUNT=$OSTCOUNT
5604 local list=$(comma_list $(osts_nodes))
5605 set_osd_param $list '' read_cache_enable 0
5606 set_osd_param $list '' writethrough_cache_enable 0
5608 trap cleanup_test101bc EXIT
5609 # prepare the read-ahead file
5610 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
5612 dd if=/dev/zero of=$DIR/$tfile bs=1024k count=100 2> /dev/null
5615 cleanup_test101bc() {
5620 local list=$(comma_list $(osts_nodes))
5621 set_osd_param $list '' read_cache_enable 1
5622 set_osd_param $list '' writethrough_cache_enable 1
5626 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
5631 local STRIPE_SIZE=1048576
5632 local RA_INC=1048576
5633 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
5634 local FILE_LENGTH=$((64*100))
5635 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
5636 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
5637 DISCARD=`$LCTL get_param -n llite.*.read_ahead_stats | \
5638 get_named_value 'read but discarded' | \
5639 cut -d" " -f1 | calc_total`
5640 if [ $DISCARD -gt $discard_limit ]; then
5641 $LCTL get_param llite.*.read_ahead_stats
5642 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
5644 echo "Read-ahead success for size ${READ_SIZE}"
5649 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5650 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping stride IO stride-ahead test" && return
5651 local STRIPE_SIZE=1048576
5652 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
5653 local FILE_LENGTH=$((STRIPE_SIZE*100))
5654 local ITERATION=$((FILE_LENGTH/STRIDE_SIZE))
5655 # prepare the read-ahead file
5657 cancel_lru_locks osc
5658 for BIDX in 2 4 8 16 32 64 128 256
5660 local BSIZE=$((BIDX*4096))
5661 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
5662 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
5663 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
5664 $LCTL set_param -n llite.*.read_ahead_stats 0
5665 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
5666 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
5667 cancel_lru_locks osc
5673 run_test 101b "check stride-io mode read-ahead ================="
5676 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5677 local STRIPE_SIZE=1048576
5678 local FILE_LENGTH=$((STRIPE_SIZE*100))
5684 cancel_lru_locks osc
5685 $LCTL set_param osc.*.rpc_stats 0
5686 $READS -f $DIR/$tfile -s$FILE_LENGTH -b65536 -n$nreads -t 180
5687 for osc in $($LCTL get_param -N osc.*); do
5688 if [ "$osc" == "osc.num_refs" ]; then
5692 local lines=$($LCTL get_param -n ${osc}.rpc_stats | wc | awk '{print $1}')
5693 if [ $lines -le 20 ]; then
5697 local rpc4k=$($LCTL get_param -n ${osc}.rpc_stats |
5698 awk '$1 == "1:" { print $2; exit; }')
5699 local rpc8k=$($LCTL get_param -n ${osc}.rpc_stats |
5700 awk '$1 == "2:" { print $2; exit; }')
5701 local rpc16k=$($LCTL get_param -n ${osc}.rpc_stats |
5702 awk '$1 == "4:" { print $2; exit; }')
5703 local rpc32k=$($LCTL get_param -n ${osc}.rpc_stats |
5704 awk '$1 == "8:" { print $2; exit; }')
5706 [ $rpc4k != 0 ] && error "Small 4k read IO ${rpc4k}!"
5707 [ $rpc8k != 0 ] && error "Small 8k read IO ${rpc8k}!"
5708 [ $rpc16k != 0 ] && error "Small 16k read IO ${rpc16k}!"
5709 [ $rpc32k != 0 ] && error "Small 32k read IO ${rpc32k}!"
5710 echo "${osc} rpc check passed!"
5715 run_test 101c "check stripe_size aligned read-ahead ================="
5718 $LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1
5719 $LCTL set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
5723 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5724 local file=$DIR/$tfile
5725 local size=${FILESIZE_101c:-500}
5726 local ra_MB=${READAHEAD_MB:-40}
5728 local space=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
5729 [ $space -gt $((size * 1024)) ] ||
5730 { skip "Need free space ${size}M, have $space" && return; }
5732 echo Creating ${size}M test file $file
5733 dd if=/dev/zero of=$file bs=1M count=$size || error "dd failed"
5734 echo Cancel LRU locks on lustre client to flush the client cache
5735 cancel_lru_locks osc
5737 echo Disable read-ahead
5738 local old_READAHEAD=$(set_read_ahead 0)
5740 echo Reading the test file $file with read-ahead disabled
5741 time_ra_OFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$size")
5743 echo Cancel LRU locks on lustre client to flush the client cache
5744 cancel_lru_locks osc
5745 echo Enable read-ahead with ${ra_MB}MB
5746 set_read_ahead $ra_MB
5748 echo Reading the test file $file with read-ahead enabled
5749 time_ra_ON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$size")
5751 echo read-ahead disabled time read $time_ra_OFF
5752 echo read-ahead enabled time read $time_ra_ON
5754 set_read_ahead $old_READAHEAD
5756 wait_delete_completed
5758 [ $time_ra_ON -lt $time_ra_OFF ] ||
5759 error "read-ahead enabled time read (${time_ra_ON}s) is more than
5760 read-ahead disabled time read (${time_ra_OFF}s) filesize ${size}M"
5762 run_test 101d "file read with and without read-ahead enabled ================="
5765 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5766 local file=$DIR/$tfile
5771 local space=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
5772 local need_space=$((count * size))
5773 [ $space -gt $need_space ] ||
5774 { skip_env "Need free space $need_space, have $space" && return; }
5776 echo Creating $count ${size}K test files
5777 for ((i = 0; i < $count; i++)); do
5778 dd if=/dev/zero of=${file}_${i} bs=$blksize count=$size 2>/dev/null
5781 echo Cancel LRU locks on lustre client to flush the client cache
5782 cancel_lru_locks osc
5784 echo Reset readahead stats
5785 $LCTL set_param -n llite.*.read_ahead_stats 0
5787 for ((i = 0; i < $count; i++)); do
5788 dd if=${file}_${i} of=/dev/null bs=$blksize count=$size 2>/dev/null
5791 local miss=$($LCTL get_param -n llite.*.read_ahead_stats | \
5792 get_named_value 'misses' | cut -d" " -f1 | calc_total)
5794 for ((i = 0; i < $count; i++)); do
5795 rm -rf ${file}_${i} 2>/dev/null
5798 #10000 means 20% reads are missing in readahead
5799 [ $miss -lt 10000 ] || error "misses too much for small reads"
5801 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
5803 cleanup_test101f() {
5805 $LCTL set_param -n llite.*.max_read_ahead_whole_mb $MAX_WHOLE_MB
5806 rm -rf $DIR/$tfile 2>/dev/null
5810 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5811 local file=$DIR/$tfile
5814 MAX_WHOLE_MB=$($LCTL get_param -n llite.*.max_read_ahead_whole_mb)
5815 $LCTL set_param -n llite.*.max_read_ahead_whole_mb 2
5816 dd if=/dev/zero of=${file} bs=2097152 count=1 2>/dev/null
5817 trap cleanup_test101f EXIT
5819 echo Cancel LRU locks on lustre client to flush the client cache
5820 cancel_lru_locks osc
5822 echo Reset readahead stats
5823 $LCTL set_param -n llite.*.read_ahead_stats 0
5824 # Random read in a 2M file, because max_read_ahead_whole_mb = 2M,
5825 # readahead should read in 2M file on second read, so only miss
5827 echo Random 4K reads on 2M file for 1000 times
5828 $READS -f $file -s 2097152 -b 4096 -n $nreads
5830 echo checking missing pages
5831 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
5832 get_named_value 'misses' | cut -d" " -f1 | calc_total)
5834 [ $miss -lt 3 ] || error "misses too much pages!"
5837 run_test 101f "check read-ahead for max_read_ahead_whole_mb"
5840 test_mkdir -p $DIR/$tdir
5841 chown $RUNAS_ID $DIR/$tdir
5844 STRIPE_COUNT=$OSTCOUNT
5845 [ $OSTCOUNT -gt 4 ] && STRIPE_COUNT=4
5847 trap cleanup_test102 EXIT
5849 $1 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
5851 for num in 1 2 3 4; do
5852 for count in $(seq 1 $STRIPE_COUNT); do
5853 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
5854 local size=`expr $STRIPE_SIZE \* $num`
5855 local file=file"$num-$idx-$count"
5856 $1 $SETSTRIPE -S $size -i $idx -c $count $file
5862 $1 $TAR cf $TMP/f102.tar $tdir --xattrs
5868 rm -rf $DIR/d0.sanity/d102
5872 local testfile=$DIR/xattr_testfile
5876 [ "$UID" != 0 ] && skip_env "must run as root" && return
5877 [ -z "`lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr`" ] &&
5878 skip_env "must have user_xattr" && return
5880 [ -z "$(which setfattr 2>/dev/null)" ] &&
5881 skip_env "could not find setfattr" && return
5883 echo "set/get xattr..."
5884 setfattr -n trusted.name1 -v value1 $testfile || error
5885 getfattr -n trusted.name1 $testfile 2> /dev/null |
5886 grep "trusted.name1=.value1" ||
5887 error "$testfile missing trusted.name1=value1"
5889 setfattr -n user.author1 -v author1 $testfile || error
5890 getfattr -n user.author1 $testfile 2> /dev/null |
5891 grep "user.author1=.author1" ||
5892 error "$testfile missing trusted.author1=author1"
5895 setfattr -n trusted.name2 -v value2 $testfile ||
5896 error "$testfile unable to set trusted.name2"
5897 setfattr -n trusted.name3 -v value3 $testfile ||
5898 error "$testfile unable to set trusted.name3"
5899 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
5900 grep "trusted.name" | wc -l) -eq 3 ] ||
5901 error "$testfile missing 3 trusted.name xattrs"
5903 setfattr -n user.author2 -v author2 $testfile ||
5904 error "$testfile unable to set user.author2"
5905 setfattr -n user.author3 -v author3 $testfile ||
5906 error "$testfile unable to set user.author3"
5907 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
5908 grep "user.author" | wc -l) -eq 3 ] ||
5909 error "$testfile missing 3 user.author xattrs"
5911 echo "remove xattr..."
5912 setfattr -x trusted.name1 $testfile ||
5913 error "$testfile error deleting trusted.name1"
5914 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
5915 error "$testfile did not delete trusted.name1 xattr"
5917 setfattr -x user.author1 $testfile ||
5918 error "$testfile error deleting user.author1"
5919 getfattr -d -m user $testfile 2> /dev/null | grep "user.author1" &&
5920 error "$testfile did not delete trusted.name1 xattr"
5922 # b10667: setting lustre special xattr be silently discarded
5923 echo "set lustre special xattr ..."
5924 setfattr -n "trusted.lov" -v "invalid value" $testfile ||
5925 error "$testfile allowed setting trusted.lov"
5927 run_test 102a "user xattr test =================================="
5930 # b10930: get/set/list trusted.lov xattr
5931 echo "get/set/list trusted.lov xattr ..."
5932 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
5933 local testfile=$DIR/$tfile
5934 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
5935 error "setstripe failed"
5936 local STRIPECOUNT=$($GETSTRIPE -c $testfile) ||
5937 error "getstripe failed"
5938 getfattr -d -m "^trusted" $testfile 2> /dev/null | \
5939 grep "trusted.lov" || error "can't get trusted.lov from $testfile"
5941 local testfile2=${testfile}2
5942 local value=`getfattr -n trusted.lov $testfile 2> /dev/null | \
5943 grep "trusted.lov" |sed -e 's/[^=]\+=//'`
5946 setfattr -n trusted.lov -v $value $testfile2
5947 local stripe_size=$($GETSTRIPE -S $testfile2)
5948 local stripe_count=$($GETSTRIPE -c $testfile2)
5949 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
5950 [ $stripe_count -eq $STRIPECOUNT ] ||
5951 error "stripe count $stripe_count != $STRIPECOUNT"
5954 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
5957 # b10930: get/set/list lustre.lov xattr
5958 echo "get/set/list lustre.lov xattr ..."
5959 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
5960 test_mkdir -p $DIR/$tdir
5961 chown $RUNAS_ID $DIR/$tdir
5962 local testfile=$DIR/$tdir/$tfile
5963 $RUNAS $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
5964 error "setstripe failed"
5965 local STRIPECOUNT=$($RUNAS $GETSTRIPE -c $testfile) ||
5966 error "getstripe failed"
5967 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
5968 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
5970 local testfile2=${testfile}2
5971 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
5972 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
5974 $RUNAS $MCREATE $testfile2
5975 $RUNAS setfattr -n lustre.lov -v $value $testfile2
5976 local stripe_size=$($RUNAS $GETSTRIPE -S $testfile2)
5977 local stripe_count=$($RUNAS $GETSTRIPE -c $testfile2)
5978 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
5979 [ $stripe_count -eq $STRIPECOUNT ] ||
5980 error "stripe count $stripe_count != $STRIPECOUNT"
5982 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
5984 compare_stripe_info1() {
5985 local stripe_index_all_zero=true
5987 for num in 1 2 3 4; do
5988 for count in $(seq 1 $STRIPE_COUNT); do
5989 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
5990 local size=$((STRIPE_SIZE * num))
5991 local file=file"$num-$offset-$count"
5992 stripe_size=$(lfs getstripe -S $PWD/$file)
5993 [ $stripe_size -ne $size ] &&
5994 error "$file: size $stripe_size != $size"
5995 stripe_count=$(lfs getstripe -c $PWD/$file)
5996 # allow fewer stripes to be created, ORI-601
5997 [ $stripe_count -lt $(((3 * count + 3) / 4)) ]&&
5998 error "$file: count $stripe_count != $count"
5999 stripe_index=$(lfs getstripe -i $PWD/$file)
6000 [ $stripe_index -ne 0 ] &&
6001 stripe_index_all_zero=false
6005 $stripe_index_all_zero &&
6006 error "all files are being extracted starting from OST index 0"
6011 [ -n "$(which tar 2>/dev/null)" ] &&
6012 strings $(which tar) | grep -q "lustre" && echo tar
6016 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6017 # b10930: tar test for trusted.lov xattr
6018 TAR=$(find_lustre_tar)
6019 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6020 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
6022 test_mkdir -p $DIR/d102d
6023 $TAR xf $TMP/f102.tar -C $DIR/d102d --xattrs
6025 compare_stripe_info1
6027 run_test 102d "tar restore stripe info from tarfile,not keep osts ==========="
6030 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6031 # b10930: tar test for trusted.lov xattr
6032 TAR=$(find_lustre_tar)
6033 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6034 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
6036 test_mkdir -p $DIR/d102f
6038 $TAR cf - --xattrs $tdir | $TAR xf - --xattrs -C $DIR/d102f
6040 compare_stripe_info1
6042 run_test 102f "tar copy files, not keep osts ==========="
6045 local xsize=${1:-1024} # in bytes
6046 local file=$DIR/$tfile
6048 [ -z $(lctl get_param -n mdc.*.connect_flags | grep xattr) ] &&
6049 skip "must have user_xattr" && return 0
6050 [ -z "$(which setfattr 2>/dev/null)" ] &&
6051 skip_env "could not find setfattr" && return 0
6052 [ -z "$(which getfattr 2>/dev/null)" ] &&
6053 skip_env "could not find getfattr" && return 0
6057 local value="$(generate_string $xsize)"
6059 local xbig=trusted.big
6060 log "save $xbig on $file"
6061 setfattr -n $xbig -v $value $file ||
6062 error "saving $xbig on $file failed"
6064 local orig=$(get_xattr_value $xbig $file)
6065 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
6067 local xsml=trusted.sml
6068 log "save $xsml on $file"
6069 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
6071 local new=$(get_xattr_value $xbig $file)
6072 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
6074 log "grow $xsml on $file"
6075 setfattr -n $xsml -v "$value" $file ||
6076 error "growing $xsml on $file failed"
6078 new=$(get_xattr_value $xbig $file)
6079 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
6080 log "$xbig still valid after growing $xsml"
6085 test_102h() { # bug 15777
6088 run_test 102h "grow xattr from inside inode to external block"
6091 large_xattr_enabled || { skip "large_xattr disabled" && return; }
6092 grow_xattr $(max_xattr_size)
6094 run_test 102ha "grow xattr from inside inode to external inode"
6096 test_102i() { # bug 17038
6098 ln -s $DIR/$tfile $DIR/${tfile}link
6099 getfattr -n trusted.lov $DIR/$tfile || error "lgetxattr on $DIR/$tfile failed"
6100 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"
6101 rm -f $DIR/$tfile $DIR/${tfile}link
6103 run_test 102i "lgetxattr test on symbolic link ============"
6106 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6107 TAR=$(find_lustre_tar)
6108 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6109 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
6110 setup_test102 "$RUNAS"
6111 test_mkdir -p $DIR/d102j
6112 chown $RUNAS_ID $DIR/d102j
6113 $RUNAS $TAR xf $TMP/f102.tar -C $DIR/d102j --xattrs
6115 compare_stripe_info1 "$RUNAS"
6117 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
6121 # b22187 just check that does not crash for regular file.
6122 setfattr -n trusted.lov $DIR/$tfile
6123 # b22187 'setfattr -n trusted.lov' should work as remove LOV EA for directories
6124 local test_kdir=$DIR/d102k
6125 test_mkdir $test_kdir
6126 local default_size=`$GETSTRIPE -S $test_kdir`
6127 local default_count=`$GETSTRIPE -c $test_kdir`
6128 local default_offset=`$GETSTRIPE -i $test_kdir`
6129 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $test_kdir ||
6130 error 'dir setstripe failed'
6131 setfattr -n trusted.lov $test_kdir
6132 local stripe_size=`$GETSTRIPE -S $test_kdir`
6133 local stripe_count=`$GETSTRIPE -c $test_kdir`
6134 local stripe_offset=`$GETSTRIPE -i $test_kdir`
6135 [ $stripe_size -eq $default_size ] ||
6136 error "stripe size $stripe_size != $default_size"
6137 [ $stripe_count -eq $default_count ] ||
6138 error "stripe count $stripe_count != $default_count"
6139 [ $stripe_offset -eq $default_offset ] ||
6140 error "stripe offset $stripe_offset != $default_offset"
6141 rm -rf $DIR/$tfile $test_kdir
6143 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
6146 # LU-532 trusted. xattr is invisible to non-root
6147 local testfile=$DIR/$tfile
6151 echo "listxattr as user..."
6152 chown $RUNAS_ID $testfile
6153 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
6154 grep -q "trusted" &&
6155 error "$testfile trusted xattrs are user visible"
6159 run_test 102l "listxattr filter test =================================="
6165 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
6170 [ "$UID" != 0 ] && skip_env "must run as root" && return
6171 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
6172 [ -z "$(which setfacl 2>/dev/null)" ] && skip_env "could not find setfacl" && return
6173 $GSS && skip "could not run under gss" && return
6175 declare -a identity_old
6177 for num in $(seq $MDSCOUNT); do
6178 switch_identity $num true || identity_old[$num]=$?
6185 echo "performing cp ..."
6186 run_acl_subtest cp || error
6187 echo "performing getfacl-noacl..."
6188 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
6189 echo "performing misc..."
6190 run_acl_subtest misc || error "misc test failed"
6191 echo "performing permissions..."
6192 run_acl_subtest permissions || error "permissions failed"
6193 echo "performing setfacl..."
6194 run_acl_subtest setfacl || error "setfacl test failed"
6196 # inheritance test got from HP
6197 echo "performing inheritance..."
6198 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
6199 chmod +x make-tree || error "chmod +x failed"
6200 run_acl_subtest inheritance || error "inheritance test failed"
6203 echo "LU-974 ignore umask when acl is enabled..."
6204 run_acl_subtest 974 || error "LU-974 test failed"
6205 if [ $MDSCOUNT -ge 2 ]; then
6206 run_acl_subtest 974_remote ||
6207 error "LU-974 test failed under remote dir"
6210 echo "LU-2561 newly created file is same size as directory..."
6211 run_acl_subtest 2561 || error "LU-2561 test failed"
6216 for num in $(seq $MDSCOUNT); do
6217 if [ "${identity_old[$num]}" = 1 ]; then
6218 switch_identity $num false || identity_old[$num]=$?
6222 run_test 103 "acl test ========================================="
6225 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6227 lfs df || error "lfs df failed"
6228 lfs df -ih || error "lfs df -ih failed"
6229 lfs df -h $DIR || error "lfs df -h $DIR failed"
6230 lfs df -i $DIR || error "lfs df -i $DIR failed"
6231 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
6232 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
6234 OSC=`lctl dl |grep OST0000-osc-[^M] |awk '{print $4}'`
6235 lctl --device %$OSC deactivate
6236 lfs df || error "lfs df with deactivated OSC failed"
6237 lctl --device %$OSC activate
6238 # wait the osc back to normal
6239 wait_osc_import_state client ost FULL
6241 lfs df || error "lfs df with reactivated OSC failed"
6244 run_test 104a "lfs df [-ih] [path] test ========================="
6247 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6248 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
6250 denied_cnt=$((`$RUNAS $LFS check servers 2>&1 | grep "Permission denied" | wc -l`))
6251 if [ $denied_cnt -ne 0 ];
6253 error "lfs check servers test failed"
6256 run_test 104b "$RUNAS lfs check servers test ===================="
6259 # doesn't work on 2.4 kernels
6261 if [ -n "`mount | grep \"$MOUNT.*flock\" | grep -v noflock`" ]; then
6262 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
6264 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
6268 run_test 105a "flock when mounted without -o flock test ========"
6272 if [ -n "`mount | grep \"$MOUNT.*flock\" | grep -v noflock`" ]; then
6273 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
6275 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
6279 run_test 105b "fcntl when mounted without -o flock test ========"
6283 if [ -n "`mount | grep \"$MOUNT.*flock\" | grep -v noflock`" ]; then
6284 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
6286 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
6290 run_test 105c "lockf when mounted without -o flock test ========"
6292 test_105d() { # bug 15924
6293 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6294 test_mkdir -p $DIR/$tdir
6295 [ -z "`mount | grep \"$MOUNT.*flock\" | grep -v noflock`" ] && \
6296 skip "mount w/o flock enabled" && return
6297 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
6298 $LCTL set_param fail_loc=0x80000315
6299 flocks_test 2 $DIR/$tdir
6301 run_test 105d "flock race (should not freeze) ========"
6303 test_105e() { # bug 22660 && 22040
6304 [ -z "`mount | grep \"$MOUNT.*flock\" | grep -v noflock`" ] && \
6305 skip "mount w/o flock enabled" && return
6307 flocks_test 3 $DIR/$tfile
6309 run_test 105e "Two conflicting flocks from same process ======="
6311 test_106() { #bug 10921
6312 test_mkdir -p $DIR/$tdir
6313 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
6314 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
6316 run_test 106 "attempt exec of dir followed by chown of that dir"
6319 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6326 local save_pattern=$(sysctl -n kernel.core_pattern)
6327 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
6328 sysctl -w kernel.core_pattern=$file
6329 sysctl -w kernel.core_uses_pid=0
6337 kill -s 11 $SLEEPPID
6339 if [ -e $file ]; then
6340 size=`stat -c%s $file`
6341 [ $size -eq 0 ] && error "Fail to create core file $file"
6343 error "Fail to create core file $file"
6346 sysctl -w kernel.core_pattern=$save_pattern
6347 sysctl -w kernel.core_uses_pid=$save_uses_pid
6350 run_test 107 "Coredump on SIG"
6353 test_mkdir -p $DIR/$tdir
6354 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255) ||
6355 error "mkdir with 255 char failed"
6356 test_mkdir $DIR/$tdir/$(str_repeat 'b' 256) &&
6357 error "mkdir with 256 char should fail, but did not"
6358 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
6359 error "create with 255 char failed"
6360 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
6361 error "create with 256 char should fail, but did not"
6366 run_test 110 "filename length checking"
6369 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6370 OSTIO_pre=$(ps -e|grep ll_ost_io|awk '{print $4}'|sort -n|tail -1|\
6372 [ -z "$OSTIO_pre" ] && skip "no OSS threads" && \
6374 echo "Starting with $OSTIO_pre threads"
6377 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
6378 [ $NUMFREE -lt $NUMTEST ] && NUMTEST=$(($NUMFREE - 1000))
6379 echo "$NUMTEST creates/unlinks"
6380 test_mkdir -p $DIR/$tdir
6381 createmany -o $DIR/$tdir/$tfile $NUMTEST
6382 unlinkmany $DIR/$tdir/$tfile $NUMTEST
6384 OSTIO_post=$(ps -e|grep ll_ost_io|awk '{print $4}'|sort -n|tail -1|\
6387 # don't return an error
6388 [ $OSTIO_post == $OSTIO_pre ] && echo \
6389 "WARNING: No new ll_ost_io threads were created ($OSTIO_pre)" &&
6390 echo "This may be fine, depending on what ran before this test" &&
6391 echo "and how fast this system is." && return
6393 echo "Started with $OSTIO_pre threads, ended with $OSTIO_post"
6395 run_test 115 "verify dynamic thread creation===================="
6398 wait_delete_completed
6399 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
6400 echo OST kbytes available: ${AVAIL[@]}
6401 MAXI=0; MAXV=${AVAIL[0]}
6402 MINI=0; MINV=${AVAIL[0]}
6403 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
6404 #echo OST $i: ${AVAIL[i]}kb
6405 if [ ${AVAIL[i]} -gt $MAXV ]; then
6406 MAXV=${AVAIL[i]}; MAXI=$i
6408 if [ ${AVAIL[i]} -lt $MINV ]; then
6409 MINV=${AVAIL[i]}; MINI=$i
6412 echo Min free space: OST $MINI: $MINV
6413 echo Max free space: OST $MAXI: $MAXV
6416 test_116a() { # was previously test_116()
6417 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6418 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs" && return
6420 echo -n "Free space priority "
6421 lctl get_param -n lov.*-clilov-*.qos_prio_free
6424 [ $MINV -gt 960000 ] && skip "too much free space in OST$MINI, skip" &&\
6427 # generate uneven OSTs
6428 test_mkdir -p $DIR/$tdir/OST${MINI}
6431 echo "Filling 25% remaining space in OST${MINI} with ${FILL}Kb"
6432 $SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI}||error "setstripe failed"
6434 while [ $FILL -gt 0 ]; do
6436 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i bs=2M count=1 2>/dev/null
6437 FILL=$(($FILL - 2048))
6445 DIFF=$(($MAXV - $MINV))
6446 DIFF2=$(($DIFF * 100 / $MINV))
6447 echo -n "diff=${DIFF}=${DIFF2}% must be > 20% for QOS mode..."
6448 if [ $DIFF2 -gt 20 ]; then
6451 echo "failed - QOS mode won't be used"
6452 error_ignore "QOS imbalance criteria not met"
6456 MINI1=$MINI; MINV1=$MINV
6457 MAXI1=$MAXI; MAXV1=$MAXV
6459 # now fill using QOS
6460 echo writing a bunch of files to QOS-assigned OSTs
6461 $SETSTRIPE -c 1 $DIR/$tdir
6463 while [ $FILL -gt 0 ]; do
6465 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1024 count=200 2>/dev/null
6466 FILL=$(($FILL - 200))
6469 echo "wrote $i 200k files"
6473 echo "Note: free space may not be updated, so measurements might be off"
6475 DIFF2=$(($MAXV - $MINV))
6476 echo "free space delta: orig $DIFF final $DIFF2"
6477 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
6478 DIFF=$(($MINV1 - ${AVAIL[$MINI1]}))
6479 echo "Wrote $DIFF to smaller OST $MINI1"
6480 DIFF2=$(($MAXV1 - ${AVAIL[$MAXI1]}))
6481 echo "Wrote $DIFF2 to larger OST $MAXI1"
6482 [ $DIFF -gt 0 ] && echo "Wrote $(($DIFF2 * 100 / $DIFF - 100))% more data to larger OST $MAXI1"
6484 # Figure out which files were written where
6485 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
6486 awk '/'$MINI1': / {print $2; exit}')
6488 MINC=$($GETSTRIPE --obd $UUID $DIR/$tdir | wc -l)
6489 echo "$MINC files created on smaller OST $MINI1"
6490 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
6491 awk '/'$MAXI1': / {print $2; exit}')
6493 MAXC=$($GETSTRIPE --obd $UUID $DIR/$tdir | wc -l)
6494 echo "$MAXC files created on larger OST $MAXI1"
6495 [ $MINC -gt 0 ] && echo "Wrote $(($MAXC * 100 / $MINC - 100))% more files to larger OST $MAXI1"
6496 [ $MAXC -gt $MINC ] || error_ignore "stripe QOS didn't balance free space"
6500 run_test 116a "stripe QOS: free space balance ==================="
6502 test_116b() { # LU-2093
6503 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6504 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
6506 old_rr=$(do_facet $SINGLEMDS lctl get_param -n lov.*mdtlov*.qos_threshold_rr)
6507 do_facet $SINGLEMDS lctl set_param lov.*mdtlov*.qos_threshold_rr 0
6509 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
6510 createmany -o $DIR/$tdir/f- 20 || error "can't create"
6511 do_facet $SINGLEMDS lctl set_param fail_loc=0
6513 do_facet $SINGLEMDS lctl set_param lov.*mdtlov*.qos_threshold_rr $old_rr
6515 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
6517 test_117() # bug 10891
6519 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6520 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
6521 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
6522 lctl set_param fail_loc=0x21e
6523 > $DIR/$tfile || error "truncate failed"
6524 lctl set_param fail_loc=0
6525 echo "Truncate succeeded."
6528 run_test 117 "verify fsfilt_extend =========="
6530 NO_SLOW_RESENDCOUNT=4
6531 export OLD_RESENDCOUNT=""
6532 set_resend_count () {
6533 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
6534 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -1)
6535 lctl set_param -n $PROC_RESENDCOUNT $1
6536 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
6539 # for reduce test_118* time (b=14842)
6540 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
6542 # Reset async IO behavior after error case
6544 FILE=$DIR/reset_async
6546 # Ensure all OSCs are cleared
6547 $SETSTRIPE -c -1 $FILE
6548 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
6553 test_118a() #bug 11710
6555 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6558 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6559 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6560 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
6562 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6563 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6568 run_test 118a "verify O_SYNC works =========="
6572 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6573 remote_ost_nodsh && skip "remote OST with nodsh" && return
6577 #define OBD_FAIL_OST_ENOENT 0x217
6578 set_nodes_failloc "$(osts_nodes)" 0x217
6579 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6581 set_nodes_failloc "$(osts_nodes)" 0
6582 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6583 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6586 if [[ $RC -eq 0 ]]; then
6587 error "Must return error due to dropped pages, rc=$RC"
6591 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6592 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6596 echo "Dirty pages not leaked on ENOENT"
6598 # Due to the above error the OSC will issue all RPCs syncronously
6599 # until a subsequent RPC completes successfully without error.
6600 $MULTIOP $DIR/$tfile Ow4096yc
6605 run_test 118b "Reclaim dirty pages on fatal error =========="
6609 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6611 # for 118c, restore the original resend count, LU-1940
6612 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
6613 set_resend_count $OLD_RESENDCOUNT
6614 remote_ost_nodsh && skip "remote OST with nodsh" && return
6618 #define OBD_FAIL_OST_EROFS 0x216
6619 set_nodes_failloc "$(osts_nodes)" 0x216
6621 # multiop should block due to fsync until pages are written
6622 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
6626 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
6627 error "Multiop failed to block on fsync, pid=$MULTIPID"
6630 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6632 if [[ $WRITEBACK -eq 0 ]]; then
6633 error "No page in writeback, writeback=$WRITEBACK"
6636 set_nodes_failloc "$(osts_nodes)" 0
6639 if [[ $RC -ne 0 ]]; then
6640 error "Multiop fsync failed, rc=$RC"
6643 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6644 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6646 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6647 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6651 echo "Dirty pages flushed via fsync on EROFS"
6654 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
6656 # continue to use small resend count to reduce test_118* time (b=14842)
6657 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
6661 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6662 remote_ost_nodsh && skip "remote OST with nodsh" && return
6666 #define OBD_FAIL_OST_BRW_PAUSE_BULK
6667 set_nodes_failloc "$(osts_nodes)" 0x214
6668 # multiop should block due to fsync until pages are written
6669 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
6673 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
6674 error "Multiop failed to block on fsync, pid=$MULTIPID"
6677 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6679 if [[ $WRITEBACK -eq 0 ]]; then
6680 error "No page in writeback, writeback=$WRITEBACK"
6683 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
6684 set_nodes_failloc "$(osts_nodes)" 0
6686 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6687 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6689 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6690 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6694 echo "Dirty pages gaurenteed flushed via fsync"
6697 run_test 118d "Fsync validation inject a delay of the bulk =========="
6700 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6703 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
6704 lctl set_param fail_loc=0x8000040a
6706 # Should simulate EINVAL error which is fatal
6707 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6709 if [[ $RC -eq 0 ]]; then
6710 error "Must return error due to dropped pages, rc=$RC"
6713 lctl set_param fail_loc=0x0
6715 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6716 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6717 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6719 if [[ $LOCKED -ne 0 ]]; then
6720 error "Locked pages remain in cache, locked=$LOCKED"
6723 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6724 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6728 echo "No pages locked after fsync"
6733 run_test 118f "Simulate unrecoverable OSC side error =========="
6736 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6739 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
6740 lctl set_param fail_loc=0x406
6742 # simulate local -ENOMEM
6743 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6746 lctl set_param fail_loc=0
6747 if [[ $RC -eq 0 ]]; then
6748 error "Must return error due to dropped pages, rc=$RC"
6751 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
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 [[ $LOCKED -ne 0 ]]; then
6756 error "Locked pages remain in cache, locked=$LOCKED"
6759 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6760 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6764 echo "No pages locked after fsync"
6769 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
6772 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6773 remote_ost_nodsh && skip "remote OST with nodsh" && return
6777 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
6778 set_nodes_failloc "$(osts_nodes)" 0x20e
6779 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
6780 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6783 set_nodes_failloc "$(osts_nodes)" 0
6784 if [[ $RC -eq 0 ]]; then
6785 error "Must return error due to dropped pages, rc=$RC"
6788 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6789 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6790 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6792 if [[ $LOCKED -ne 0 ]]; then
6793 error "Locked pages remain in cache, locked=$LOCKED"
6796 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6797 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6801 echo "No pages locked after fsync"
6805 run_test 118h "Verify timeout in handling recoverables errors =========="
6807 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
6810 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6811 remote_ost_nodsh && skip "remote OST with nodsh" && return
6815 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
6816 set_nodes_failloc "$(osts_nodes)" 0x20e
6818 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
6819 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
6822 set_nodes_failloc "$(osts_nodes)" 0
6826 if [[ $RC -ne 0 ]]; then
6827 error "got error, but should be not, rc=$RC"
6830 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6831 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6832 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
6833 if [[ $LOCKED -ne 0 ]]; then
6834 error "Locked pages remain in cache, locked=$LOCKED"
6837 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6838 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6842 echo "No pages locked after fsync"
6846 run_test 118i "Fix error before timeout in recoverable error =========="
6848 [ "$SLOW" = "no" ] && set_resend_count 4
6851 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6852 remote_ost_nodsh && skip "remote OST with nodsh" && return
6856 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
6857 set_nodes_failloc "$(osts_nodes)" 0x220
6859 # return -EIO from OST
6860 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6862 set_nodes_failloc "$(osts_nodes)" 0x0
6863 if [[ $RC -eq 0 ]]; then
6864 error "Must return error due to dropped pages, rc=$RC"
6867 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6868 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6869 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
6870 if [[ $LOCKED -ne 0 ]]; then
6871 error "Locked pages remain in cache, locked=$LOCKED"
6874 # in recoverable error on OST we want resend and stay until it finished
6875 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6876 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6880 echo "No pages locked after fsync"
6884 run_test 118j "Simulate unrecoverable OST side error =========="
6888 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6889 remote_ost_nodsh && skip "remote OSTs with nodsh" && return
6891 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
6892 set_nodes_failloc "$(osts_nodes)" 0x20e
6893 test_mkdir -p $DIR/$tdir
6895 for ((i=0;i<10;i++)); do
6896 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
6897 error "dd to $DIR/$tdir/$tfile-$i failed" )&
6904 set_nodes_failloc "$(osts_nodes)" 0
6907 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
6911 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6913 test_mkdir -p $DIR/$tdir
6914 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
6917 run_test 118l "fsync dir ========="
6919 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
6921 test_119a() # bug 11737
6923 BSIZE=$((512 * 1024))
6924 directio write $DIR/$tfile 0 1 $BSIZE
6925 # We ask to read two blocks, which is more than a file size.
6926 # directio will indicate an error when requested and actual
6927 # sizes aren't equeal (a normal situation in this case) and
6928 # print actual read amount.
6929 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
6930 if [ "$NOB" != "$BSIZE" ]; then
6931 error "read $NOB bytes instead of $BSIZE"
6935 run_test 119a "Short directIO read must return actual read amount"
6937 test_119b() # bug 11737
6939 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
6941 $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
6942 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
6944 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) || \
6945 error "direct read failed"
6948 run_test 119b "Sparse directIO read must return actual read amount"
6950 test_119c() # bug 13099
6953 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
6954 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
6957 run_test 119c "Testing for direct read hitting hole"
6959 test_119d() # bug 15950
6961 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6962 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
6963 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
6965 $SETSTRIPE $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
6966 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
6967 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
6968 lctl set_param fail_loc=0x40d
6969 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
6972 cat $DIR/$tfile > /dev/null &
6973 lctl set_param fail_loc=0
6976 log "the DIO writes have completed, now wait for the reads (should not block very long)"
6978 [ -n "`ps h -p $pid_reads -o comm`" ] && \
6979 error "the read rpcs have not completed in 2s"
6981 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
6983 run_test 119d "The DIO path should try to send a new rpc once one is completed"
6986 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6987 test_mkdir -p $DIR/$tdir
6988 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6989 skip "no early lock cancel on server" && return 0
6990 lru_resize_disable mdc
6991 lru_resize_disable osc
6992 cancel_lru_locks mdc
6993 stat $DIR/$tdir > /dev/null
6994 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6995 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6996 test_mkdir $DIR/$tdir/d1
6997 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6998 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6999 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7000 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7001 lru_resize_enable mdc
7002 lru_resize_enable osc
7004 run_test 120a "Early Lock Cancel: mkdir test"
7007 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7008 test_mkdir -p $DIR/$tdir
7009 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7010 skip "no early lock cancel on server" && return 0
7011 lru_resize_disable mdc
7012 lru_resize_disable osc
7013 cancel_lru_locks mdc
7014 stat $DIR/$tdir > /dev/null
7015 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
7016 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
7018 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
7019 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
7020 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7021 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7022 lru_resize_enable mdc
7023 lru_resize_enable osc
7025 run_test 120b "Early Lock Cancel: create test"
7028 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7029 test_mkdir -p $DIR/$tdir
7030 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7031 skip "no early lock cancel on server" && return 0
7032 lru_resize_disable mdc
7033 lru_resize_disable osc
7034 test_mkdir -p $DIR/$tdir/d1 $DIR/$tdir/d2
7035 touch $DIR/$tdir/d1/f1
7036 cancel_lru_locks mdc
7037 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
7038 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
7039 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
7040 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
7041 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
7042 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
7043 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7044 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7045 lru_resize_enable mdc
7046 lru_resize_enable osc
7048 run_test 120c "Early Lock Cancel: link test"
7051 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7052 test_mkdir -p $DIR/$tdir
7053 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7054 skip "no early lock cancel on server" && return 0
7055 lru_resize_disable mdc
7056 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 chmod a+x $DIR/$tdir
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 120d "Early Lock Cancel: setattr 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 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
7080 cancel_lru_locks mdc
7081 cancel_lru_locks osc
7082 dd if=$DIR/$tdir/f1 of=/dev/null
7083 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
7084 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7085 awk '/ldlm_cancel/ {print $2}'`
7086 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7087 awk '/ldlm_bl_callback/ {print $2}'`
7088 unlink $DIR/$tdir/f1
7089 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7090 awk '/ldlm_cancel/ {print $2}'`
7091 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7092 awk '/ldlm_bl_callback/ {print $2}'`
7093 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7094 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7095 lru_resize_enable mdc
7096 lru_resize_enable osc
7098 run_test 120e "Early Lock Cancel: unlink test"
7101 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7102 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7103 skip "no early lock cancel on server" && return 0
7104 test_mkdir -p $DIR/$tdir
7105 lru_resize_disable mdc
7106 lru_resize_disable osc
7107 test_mkdir -p $DIR/$tdir/d1 $DIR/$tdir/d2
7108 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
7109 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
7110 cancel_lru_locks mdc
7111 cancel_lru_locks osc
7112 dd if=$DIR/$tdir/d1/f1 of=/dev/null
7113 dd if=$DIR/$tdir/d2/f2 of=/dev/null
7114 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
7115 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7116 awk '/ldlm_cancel/ {print $2}'`
7117 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7118 awk '/ldlm_bl_callback/ {print $2}'`
7119 mv $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
7120 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7121 awk '/ldlm_cancel/ {print $2}'`
7122 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7123 awk '/ldlm_bl_callback/ {print $2}'`
7124 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7125 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7126 lru_resize_enable mdc
7127 lru_resize_enable osc
7129 run_test 120f "Early Lock Cancel: rename test"
7132 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7133 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7134 skip "no early lock cancel on server" && return 0
7135 lru_resize_disable mdc
7136 lru_resize_disable osc
7138 echo create $count files
7139 test_mkdir -p $DIR/$tdir
7140 cancel_lru_locks mdc
7141 cancel_lru_locks osc
7144 can0=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7145 awk '/ldlm_cancel/ {print $2}'`
7146 blk0=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7147 awk '/ldlm_bl_callback/ {print $2}'`
7148 createmany -o $DIR/$tdir/f $count
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}'`
7155 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
7156 echo rm $count files
7159 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7160 awk '/ldlm_cancel/ {print $2}'`
7161 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7162 awk '/ldlm_bl_callback/ {print $2}'`
7164 echo total: $count removes in $((t2-t1))
7165 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
7167 # wait for commitment of removal
7168 lru_resize_enable mdc
7169 lru_resize_enable osc
7171 run_test 120g "Early Lock Cancel: performance test"
7173 test_121() { #bug #10589
7174 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7176 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
7177 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
7178 lctl set_param fail_loc=0x310
7179 cancel_lru_locks osc > /dev/null
7180 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
7181 lctl set_param fail_loc=0
7182 [ "$reads" -eq "$writes" ] || error "read" $reads "blocks, must be" $writes
7184 run_test 121 "read cancel race ========="
7186 test_123a() { # was test 123, statahead(bug 11401)
7187 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7189 if [ -z "$(grep "processor.*: 1" /proc/cpuinfo)" ]; then
7190 log "testing on UP system. Performance may be not as good as expected."
7195 test_mkdir -p $DIR/$tdir
7196 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
7197 [ $NUMFREE -gt 100000 ] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
7199 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
7200 createmany -o $DIR/$tdir/$tfile $j $((i - j))
7202 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
7203 lctl set_param -n llite.*.statahead_max 0
7204 lctl get_param llite.*.statahead_max
7205 cancel_lru_locks mdc
7206 cancel_lru_locks osc
7208 time ls -l $DIR/$tdir | wc -l
7210 delta=$((etime - stime))
7211 log "ls $i files without statahead: $delta sec"
7212 lctl set_param llite.*.statahead_max=$max
7214 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
7215 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
7216 cancel_lru_locks mdc
7217 cancel_lru_locks osc
7219 time ls -l $DIR/$tdir | wc -l
7221 delta_sa=$((etime - stime))
7222 log "ls $i files with statahead: $delta_sa sec"
7223 lctl get_param -n llite.*.statahead_stats
7224 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
7226 [ $swrong -lt $ewrong ] && log "statahead was stopped, maybe too many locks held!"
7227 [ $delta -eq 0 -o $delta_sa -eq 0 ] && continue
7229 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
7230 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
7231 lctl set_param -n llite.*.statahead_max 0
7232 lctl get_param llite.*.statahead_max
7233 cancel_lru_locks mdc
7234 cancel_lru_locks osc
7236 time ls -l $DIR/$tdir | wc -l
7238 delta=$((etime - stime))
7239 log "ls $i files again without statahead: $delta sec"
7240 lctl set_param llite.*.statahead_max=$max
7241 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
7242 if [ $SLOWOK -eq 0 ]; then
7243 error "ls $i files is slower with statahead!"
7245 log "ls $i files is slower with statahead!"
7251 [ $delta -gt 20 ] && break
7252 [ $delta -gt 8 ] && MULT=$((50 / delta))
7253 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
7261 delta=$((etime - stime))
7262 log "rm -r $DIR/$tdir/: $delta seconds"
7264 lctl get_param -n llite.*.statahead_stats
7266 run_test 123a "verify statahead work"
7268 test_123b () { # statahead(bug 15027)
7269 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7270 test_mkdir -p $DIR/$tdir
7271 createmany -o $DIR/$tdir/$tfile-%d 1000
7273 cancel_lru_locks mdc
7274 cancel_lru_locks osc
7276 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
7277 lctl set_param fail_loc=0x80000803
7278 ls -lR $DIR/$tdir > /dev/null
7280 lctl set_param fail_loc=0x0
7281 lctl get_param -n llite.*.statahead_stats
7286 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
7289 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7290 [ -z "`lctl get_param -n mdc.*.connect_flags | grep lru_resize`" ] && \
7291 skip "no lru resize on server" && return 0
7293 test_mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
7295 log "create $NR files at $DIR/$tdir"
7296 createmany -o $DIR/$tdir/f $NR ||
7297 error "failed to create $NR files in $DIR/$tdir"
7299 cancel_lru_locks mdc
7300 ls -l $DIR/$tdir > /dev/null
7304 for VALUE in `lctl get_param ldlm.namespaces.*mdc-*.lru_size`; do
7305 local PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
7306 LRU_SIZE=$(lctl get_param -n $PARAM)
7307 if [ $LRU_SIZE -gt $(default_lru_size) ]; then
7308 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
7310 log "NS=$(basename $NSDIR)"
7315 if [ -z "$NSDIR" -o $LRU_SIZE -lt $(default_lru_size) ]; then
7316 skip "Not enough cached locks created!"
7323 # We know that lru resize allows one client to hold $LIMIT locks
7324 # for 10h. After that locks begin to be killed by client.
7326 local LIMIT=`lctl get_param -n $NSDIR.pool.limit`
7329 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
7330 # killing locks. Some time was spent for creating locks. This means
7331 # that up to the moment of sleep finish we must have killed some of
7332 # them (10-100 locks). This depends on how fast ther were created.
7333 # Many of them were touched in almost the same moment and thus will
7334 # be killed in groups.
7335 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
7337 # Use $LRU_SIZE_B here to take into account real number of locks
7338 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
7339 local LRU_SIZE_B=$LRU_SIZE
7341 local OLD_LVF=`lctl get_param -n $NSDIR.pool.lock_volume_factor`
7342 log "OLD_LVF=$OLD_LVF"
7343 lctl set_param -n $NSDIR.pool.lock_volume_factor $LVF
7345 # Let's make sure that we really have some margin. Client checks
7346 # cached locks every 10 sec.
7348 log "Sleep ${SLEEP} sec"
7350 while ((SEC<$SLEEP)); do
7354 LRU_SIZE=`lctl get_param -n $NSDIR/lru_size`
7358 lctl set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
7359 local LRU_SIZE_A=`lctl get_param -n $NSDIR.lru_size`
7361 [ $LRU_SIZE_B -gt $LRU_SIZE_A ] || {
7362 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
7363 unlinkmany $DIR/$tdir/f $NR
7367 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
7368 log "unlink $NR files at $DIR/$tdir"
7369 unlinkmany $DIR/$tdir/f $NR
7371 run_test 124a "lru resize ======================================="
7373 get_max_pool_limit()
7375 local limit=`lctl get_param -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit`
7378 if test $l -gt $max; then
7386 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7387 [ -z "`lctl get_param -n mdc.*.connect_flags | grep lru_resize`" ] && \
7388 skip "no lru resize on server" && return 0
7390 LIMIT=`get_max_pool_limit`
7392 NR=$(($(default_lru_size)*20))
7393 if [ $NR -gt $LIMIT ]; then
7394 log "Limit lock number by $LIMIT locks"
7397 lru_resize_disable mdc
7398 test_mkdir -p $DIR/$tdir/disable_lru_resize ||
7399 error "failed to create $DIR/$tdir/disable_lru_resize"
7401 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
7402 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
7403 cancel_lru_locks mdc
7406 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
7409 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
7412 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
7416 nolruresize_delta=$((etime-stime))
7417 log "ls -la time: $nolruresize_delta seconds"
7418 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
7419 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
7421 lru_resize_enable mdc
7422 test_mkdir -p $DIR/$tdir/enable_lru_resize ||
7423 error "failed to create $DIR/$tdir/enable_lru_resize"
7425 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
7426 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
7427 cancel_lru_locks mdc
7430 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
7433 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
7436 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
7440 lruresize_delta=$((etime-stime))
7441 log "ls -la time: $lruresize_delta seconds"
7442 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
7444 if [ $lruresize_delta -gt $nolruresize_delta ]; then
7445 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
7446 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
7447 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
7449 log "lru resize performs the same with no lru resize"
7451 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
7453 run_test 124b "lru resize (performance test) ======================="
7455 test_125() { # 13358
7456 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
7457 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
7458 test_mkdir -p $DIR/d125 || error "mkdir failed"
7459 $SETSTRIPE -S 65536 -c -1 $DIR/d125 || error "setstripe failed"
7460 setfacl -R -m u:bin:rwx $DIR/d125 || error "setfacl $DIR/d125 failed"
7461 ls -ld $DIR/d125 || error "cannot access $DIR/d125"
7463 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
7465 test_126() { # bug 12829/13455
7466 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
7467 [ "$UID" != 0 ] && skip_env "skipping $TESTNAME (must run as root)" && return
7468 $GSS && skip "must run as gss disabled" && return
7470 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
7471 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
7473 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
7475 run_test 126 "check that the fsgid provided by the client is taken into account"
7477 test_127a() { # bug 15521
7478 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7479 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
7480 $LCTL set_param osc.*.stats=0
7481 FSIZE=$((2048 * 1024))
7482 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
7483 cancel_lru_locks osc
7484 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
7486 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
7487 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
7488 echo "got $COUNT $NAME"
7489 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
7490 eval $NAME=$COUNT || error "Wrong proc format"
7493 read_bytes|write_bytes)
7494 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
7495 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
7496 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
7497 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
7498 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
7499 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
7500 error "sumsquare is too small: $SUMSQ"
7501 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
7502 error "sumsquare is too big: $SUMSQ"
7506 done < $DIR/${tfile}.tmp
7508 #check that we actually got some stats
7509 [ "$read_bytes" ] || error "Missing read_bytes stats"
7510 [ "$write_bytes" ] || error "Missing write_bytes stats"
7511 [ "$read_bytes" != 0 ] || error "no read done"
7512 [ "$write_bytes" != 0 ] || error "no write done"
7514 run_test 127a "verify the client stats are sane"
7516 test_127b() { # bug LU-333
7517 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7518 $LCTL set_param llite.*.stats=0
7519 FSIZE=65536 # sized fixed to match PAGE_SIZE for most clients
7520 # perform 2 reads and writes so MAX is different from SUM.
7521 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
7522 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
7523 cancel_lru_locks osc
7524 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
7525 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
7527 $LCTL get_param llite.*.stats | grep samples > $TMP/${tfile}.tmp
7528 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
7529 echo "got $COUNT $NAME"
7530 eval $NAME=$COUNT || error "Wrong proc format"
7534 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
7535 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
7536 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
7537 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
7540 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
7541 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
7542 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
7543 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
7547 done < $TMP/${tfile}.tmp
7549 #check that we actually got some stats
7550 [ "$read_bytes" ] || error "Missing read_bytes stats"
7551 [ "$write_bytes" ] || error "Missing write_bytes stats"
7552 [ "$read_bytes" != 0 ] || error "no read done"
7553 [ "$write_bytes" != 0 ] || error "no write done"
7555 run_test 127b "verify the llite client stats are sane"
7557 test_128() { # bug 15212
7559 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
7564 result=$(grep error $TMP/$tfile.log)
7566 [ -z "$result" ] || error "consecutive find's under interactive lfs failed"
7568 run_test 128 "interactive lfs for 2 consecutive find's"
7575 local LDPROC=/proc/fs/ldiskfs
7576 local facets=$(get_facets MDS)
7578 for facet in ${facets//,/ }; do
7579 canondev=$(ldiskfs_canon \
7580 *.$(convert_facet2label $facet).mntdev $facet)
7581 do_facet $facet "test -e $LDPROC/$canondev/max_dir_size" ||
7582 LDPROC=/sys/fs/ldiskfs
7583 do_facet $facet "echo $1 >$LDPROC/$canondev/max_dir_size"
7588 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7589 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
7590 skip "Only applicable to ldiskfs-based MDTs"
7593 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7599 test_mkdir -p $DIR/$tdir
7603 while [ ! $I -gt $((MAX * MDSCOUNT)) ]; do
7604 $MULTIOP $DIR/$tdir/$J Oc
7606 if [ $rc -eq $EFBIG ]; then
7608 echo "return code $rc received as expected"
7610 elif [ $rc -ne 0 ]; then
7612 error_exit "return code $rc received instead of expected $EFBIG"
7615 I=$(stat -c%s "$DIR/$tdir")
7619 error "exceeded dir size limit $MAX x $MDSCOUNT $((MAX * MDSCOUNT)) : $I bytes"
7621 run_test 129 "test directory size limit ========================"
7630 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7631 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
7634 trap cleanup_130 EXIT RETURN
7636 local fm_file=$DIR/$tfile
7637 $SETSTRIPE -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
7638 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
7639 error "dd failed for $fm_file"
7641 # LU-1795: test filefrag/FIEMAP once, even if unsupported
7642 filefrag -ves $fm_file
7644 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
7645 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
7646 [ $RC != 0 ] && error "filefrag $fm_file failed"
7648 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
7649 grep -v "ext:" | grep -v "found")
7650 lun=$($GETSTRIPE -i $fm_file)
7652 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
7655 for line in $filefrag_op
7657 frag_lun=`echo $line | cut -d: -f5`
7658 ext_len=`echo $line | cut -d: -f4`
7659 if (( $frag_lun != $lun )); then
7661 error "FIEMAP on 1-stripe file($fm_file) failed"
7664 (( tot_len += ext_len ))
7667 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
7669 error "FIEMAP on 1-stripe file($fm_file) failed;"
7675 echo "FIEMAP on single striped file succeeded"
7677 run_test 130a "FIEMAP (1-stripe file)"
7680 [ "$OSTCOUNT" -lt "2" ] &&
7681 skip_env "skipping FIEMAP on 2-stripe file test" && return
7683 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7684 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
7687 trap cleanup_130 EXIT RETURN
7689 local fm_file=$DIR/$tfile
7690 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
7691 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
7692 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
7694 dd if=/dev/zero of=$fm_file bs=1M count=2 ||
7695 error "dd failed on $fm_file"
7697 filefrag -ves $fm_file || error "filefrag $fm_file failed"
7698 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
7699 grep -v "ext:" | grep -v "found")
7701 last_lun=$(echo $filefrag_op | cut -d: -f5)
7706 for line in $filefrag_op
7708 frag_lun=`echo $line | cut -d: -f5`
7709 ext_len=`echo $line | cut -d: -f4`
7710 if (( $frag_lun != $last_lun )); then
7711 if (( tot_len != 1024 )); then
7713 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 256"
7720 (( tot_len += ext_len ))
7723 if (( num_luns != 2 || tot_len != 1024 )); then
7725 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
7731 echo "FIEMAP on 2-stripe file succeeded"
7733 run_test 130b "FIEMAP (2-stripe file)"
7736 [ "$OSTCOUNT" -lt "2" ] &&
7737 skip_env "skipping FIEMAP on 2-stripe file" && return
7739 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7740 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
7743 trap cleanup_130 EXIT RETURN
7745 local fm_file=$DIR/$tfile
7746 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
7747 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
7748 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
7750 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 || error "dd failed on $fm_file"
7752 filefrag -ves $fm_file || error "filefrag $fm_file failed"
7753 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
7755 last_lun=`echo $filefrag_op | cut -d: -f5`
7760 for line in $filefrag_op
7762 frag_lun=`echo $line | cut -d: -f5`
7763 ext_len=`echo $line | cut -d: -f4`
7764 if (( $frag_lun != $last_lun )); then
7765 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
7766 if (( logical != 512 )); then
7768 error "FIEMAP on $fm_file failed; returned logical start for lun $logical instead of 512"
7771 if (( tot_len != 512 )); then
7773 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
7780 (( tot_len += ext_len ))
7783 if (( num_luns != 2 || tot_len != 512 )); then
7785 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
7791 echo "FIEMAP on 2-stripe file with hole succeeded"
7793 run_test 130c "FIEMAP (2-stripe file with hole)"
7796 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping FIEMAP on N-stripe file test" && return
7798 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7799 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
7801 trap cleanup_130 EXIT RETURN
7803 local fm_file=$DIR/$tfile
7804 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file||error "setstripe on $fm_file"
7805 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
7806 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
7807 dd if=/dev/zero of=$fm_file bs=1M count=$OSTCOUNT || error "dd failed on $fm_file"
7809 filefrag -ves $fm_file || error "filefrag $fm_file failed"
7810 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
7812 last_lun=`echo $filefrag_op | cut -d: -f5`
7817 for line in $filefrag_op
7819 frag_lun=`echo $line | cut -d: -f5`
7820 ext_len=`echo $line | cut -d: -f4`
7821 if (( $frag_lun != $last_lun )); then
7822 if (( tot_len != 1024 )); then
7824 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
7831 (( tot_len += ext_len ))
7834 if (( num_luns != OSTCOUNT || tot_len != 1024 )); then
7836 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
7842 echo "FIEMAP on N-stripe file succeeded"
7844 run_test 130d "FIEMAP (N-stripe file)"
7847 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping continuation FIEMAP test" && return
7849 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7850 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
7852 trap cleanup_130 EXIT RETURN
7854 local fm_file=$DIR/$tfile
7855 $SETSTRIPE -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
7856 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
7857 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
7860 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
7861 for ((i = 0; i < $NUM_BLKS; i++))
7863 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
7866 filefrag -ves $fm_file || error "filefrag $fm_file failed"
7867 filefrag_op=`filefrag -ve $fm_file | grep -A 12000 "ext:" | grep -v "ext:" | grep -v "found"`
7869 last_lun=`echo $filefrag_op | cut -d: -f5`
7874 for line in $filefrag_op
7876 frag_lun=`echo $line | cut -d: -f5`
7877 ext_len=`echo $line | cut -d: -f4`
7878 if (( $frag_lun != $last_lun )); then
7879 if (( tot_len != $EXPECTED_LEN )); then
7881 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of $EXPECTED_LEN"
7888 (( tot_len += ext_len ))
7891 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
7893 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
7899 echo "FIEMAP with continuation calls succeeded"
7901 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
7903 # Test for writev/readv
7905 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 || \
7906 error "writev test failed"
7907 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 || \
7908 error "readv failed"
7911 run_test 131a "test iov's crossing stripe boundary for writev/readv"
7914 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 || \
7915 error "append writev test failed"
7916 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 || \
7917 error "append writev test failed"
7920 run_test 131b "test append writev"
7923 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
7926 run_test 131c "test read/write on file w/o objects"
7929 rwv -f $DIR/$tfile -w -n 1 1572864
7930 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
7931 if [ "$NOB" != 1572864 ]; then
7932 error "Short read filed: read $NOB bytes instead of 1572864"
7936 run_test 131d "test short read"
7939 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
7940 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
7941 error "read hitting hole failed"
7944 run_test 131e "test read hitting hole"
7949 for node in $(osts_nodes); do
7950 gl=$(do_node $node "$LCTL get_param -n ost.OSS.ost.stats" | awk '/'$token'/ {print $2}' | head -n 1)
7951 [ x$gl = x"" ] && gl=0
7952 gl_sum=$((gl_sum + gl))
7962 if [ x$som = x"enabled" ]; then
7963 [ $((gl2 - gl1)) -gt 0 ] && error "no glimpse RPC is expected"
7964 MOUNTOPT=`echo $MOUNTOPT | sed 's/som_preview//g'`
7965 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=disabled"
7967 [ $((gl2 - gl1)) -gt 0 ] || error "some glimpse RPC is expected"
7968 MOUNTOPT="$MOUNTOPT,som_preview"
7969 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=enabled"
7972 # do remount to make new mount-conf parameters actual
7979 test_132() { #1028, SOM
7980 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7981 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7982 local num=$(get_mds_dir $DIR)
7983 local mymds=mds${num}
7984 local MOUNTOPT_SAVE=$MOUNTOPT
7986 dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
7987 cancel_lru_locks osc
7989 som1=$(do_facet $mymds "$LCTL get_param mdt.*.som" | awk -F= ' {print $2}' | head -n 1)
7991 gl1=$(get_ost_param "ldlm_glimpse_enqueue")
7992 stat $DIR/$tfile >/dev/null
7993 gl2=$(get_ost_param "ldlm_glimpse_enqueue")
7994 echo "====> SOM is "$som1", "$((gl2 - gl1))" glimpse RPC occured"
7996 som_mode_switch $som1 $gl1 $gl2
7998 dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
7999 cancel_lru_locks osc
8001 som2=$(do_facet $mymds "$LCTL get_param mdt.*.som" | awk -F= ' {print $2}' | head -n 1)
8002 if [ $som1 == $som2 ]; then
8003 error "som is still "$som2
8004 if [ x$som2 = x"enabled" ]; then
8011 gl1=$(get_ost_param "ldlm_glimpse_enqueue")
8012 stat $DIR/$tfile >/dev/null
8013 gl2=$(get_ost_param "ldlm_glimpse_enqueue")
8014 echo "====> SOM is "$som2", "$((gl2 - gl1))" glimpse RPC occured"
8015 som_mode_switch $som2 $gl1 $gl2
8016 MOUNTOPT=$MOUNTOPT_SAVE
8018 run_test 132 "som avoids glimpse rpc"
8024 $SINGLEMDS) res=`do_facet $SINGLEMDS $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$2"`
8026 ost) res=`do_facet ost1 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$2"`
8028 *) error "Wrong argument $1" ;;
8031 count=`echo $res | awk '{print $2}'`
8032 [ -z "$res" ] && error "The counter for $2 on $1 was not incremented"
8033 # if the argument $3 is zero, it means any stat increment is ok.
8034 if [ $3 -gt 0 ] ; then
8035 [ $count -ne $3 ] && error "The $2 counter on $1 is wrong - expected $3"
8040 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8041 remote_ost_nodsh && skip "remote OST with nodsh" && return
8042 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8044 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
8045 { skip "MDS doesn't support rename stats"; return; }
8046 local testdir=$DIR/${tdir}/stats_testdir
8047 mkdir -p $DIR/${tdir}
8050 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8051 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
8053 # verify mdt stats first.
8054 mkdir ${testdir} || error "mkdir failed"
8055 check_stats $SINGLEMDS "mkdir" 1
8056 touch ${testdir}/${tfile} || "touch failed"
8057 check_stats $SINGLEMDS "open" 1
8058 check_stats $SINGLEMDS "close" 1
8059 mknod ${testdir}/${tfile}-pipe p || "mknod failed"
8060 check_stats $SINGLEMDS "mknod" 1
8061 rm -f ${testdir}/${tfile}-pipe || "pipe remove failed"
8062 check_stats $SINGLEMDS "unlink" 1
8063 rm -f ${testdir}/${tfile} || error "file remove failed"
8064 check_stats $SINGLEMDS "unlink" 2
8066 # remove working dir and check mdt stats again.
8067 rmdir ${testdir} || error "rmdir failed"
8068 check_stats $SINGLEMDS "rmdir" 1
8070 local testdir1=$DIR/${tdir}/stats_testdir1
8072 mkdir -p ${testdir1}
8073 touch ${testdir1}/test1
8074 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
8075 check_stats $SINGLEMDS "crossdir_rename" 1
8077 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
8078 check_stats $SINGLEMDS "samedir_rename" 1
8082 run_test 133a "Verifying MDT stats ========================================"
8085 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8086 remote_ost_nodsh && skip "remote OST with nodsh" && return
8087 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8088 local testdir=$DIR/${tdir}/stats_testdir
8089 mkdir -p ${testdir} || error "mkdir failed"
8090 touch ${testdir}/${tfile} || "touch failed"
8091 cancel_lru_locks mdc
8094 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8095 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
8097 # extra mdt stats verification.
8098 chmod 444 ${testdir}/${tfile} || error "chmod failed"
8099 check_stats $SINGLEMDS "setattr" 1
8100 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8101 if [ $(lustre_version_code $SINGLEMDS) -ne $(version_code 2.2.0) ]
8103 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
8104 check_stats $SINGLEMDS "getattr" 1
8106 $LFS df || error "lfs failed"
8107 check_stats $SINGLEMDS "statfs" 1
8111 run_test 133b "Verifying extra MDT stats =================================="
8114 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8115 remote_ost_nodsh && skip "remote OST with nodsh" && return
8116 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8117 local testdir=$DIR/${tdir}/stats_testdir
8118 test_mkdir -p ${testdir} || error "mkdir failed"
8120 # verify obdfilter stats.
8121 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
8123 cancel_lru_locks osc
8124 wait_delete_completed
8127 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8128 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
8130 dd if=/dev/zero of=${testdir}/${tfile} conv=notrunc bs=512k count=1 || error "dd failed"
8132 cancel_lru_locks osc
8133 check_stats ost "write" 1
8135 dd if=${testdir}/${tfile} of=/dev/null bs=1k count=1 || error "dd failed"
8136 check_stats ost "read" 1
8138 > ${testdir}/${tfile} || error "truncate failed"
8139 check_stats ost "punch" 1
8141 rm -f ${testdir}/${tfile} || error "file remove failed"
8142 wait_delete_completed
8143 check_stats ost "destroy" 1
8147 run_test 133c "Verifying OST stats ========================================"
8154 while [ $value -ge 2 ]; do
8159 if [ $orig -gt $order ]; then
8167 local size=('K' 'M' 'G' 'T');
8169 local size_string=$value
8171 while [ $value -ge 1024 ]; do
8172 if [ $i -gt 3 ]; then
8173 #T is the biggest unit we get here, if that is bigger,
8175 size_string=${value}T
8178 value=$((value >> 10))
8179 if [ $value -lt 1024 ]; then
8180 size_string=${value}${size[$i]}
8191 local context=${2:-.}
8192 local sample=$(do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats |
8194 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
8199 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8200 remote_ost_nodsh && skip "remote OST with nodsh" && return
8201 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8202 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
8203 { skip "MDS doesn't support rename stats"; return; }
8205 local testdir1=$DIR/${tdir}/stats_testdir1
8206 local testdir2=$DIR/${tdir}/stats_testdir2
8208 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
8210 test_mkdir -p ${testdir1} || error "mkdir failed"
8211 test_mkdir -p ${testdir2} || error "mkdir failed"
8213 createmany -o $testdir1/test 512 || error "createmany failed"
8215 # check samedir rename size
8216 mv ${testdir1}/test0 ${testdir1}/test_0
8218 local testdir1_size=$(ls -l $DIR/${tdir} |
8219 awk '/stats_testdir1/ {print $5}')
8220 local testdir2_size=$(ls -l $DIR/${tdir} |
8221 awk '/stats_testdir2/ {print $5}')
8223 testdir1_size=$(order_2 $testdir1_size)
8224 testdir2_size=$(order_2 $testdir2_size)
8226 testdir1_size=$(size_in_KMGT $testdir1_size)
8227 testdir2_size=$(size_in_KMGT $testdir2_size)
8229 echo "source rename dir size: ${testdir1_size}"
8230 echo "target rename dir size: ${testdir2_size}"
8232 local cmd="do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats"
8233 eval $cmd || error "$cmd failed"
8234 local samedir=$($cmd | grep 'same_dir')
8235 local same_sample=$(get_rename_size $testdir1_size)
8236 [ -z "$samedir" ] && error "samedir_rename_size count error"
8237 [ "$same_sample" -eq 1 ] || error "samedir_rename_size error $same_sample"
8238 echo "Check same dir rename stats success"
8240 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
8242 # check crossdir rename size
8243 mv ${testdir1}/test_0 ${testdir2}/test_0
8245 testdir1_size=$(ls -l $DIR/${tdir} |
8246 awk '/stats_testdir1/ {print $5}')
8247 testdir2_size=$(ls -l $DIR/${tdir} |
8248 awk '/stats_testdir2/ {print $5}')
8250 testdir1_size=$(order_2 $testdir1_size)
8251 testdir2_size=$(order_2 $testdir2_size)
8253 testdir1_size=$(size_in_KMGT $testdir1_size)
8254 testdir2_size=$(size_in_KMGT $testdir2_size)
8256 echo "source rename dir size: ${testdir1_size}"
8257 echo "target rename dir size: ${testdir2_size}"
8259 eval $cmd || error "$cmd failed"
8260 local crossdir=$($cmd | grep 'crossdir')
8261 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
8262 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
8263 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
8264 [ "$src_sample" -eq 1 ] || error "crossdir_rename_size error $src_sample"
8265 [ "$tgt_sample" -eq 1 ] || error "crossdir_rename_size error $tgt_sample"
8266 echo "Check cross dir rename stats success"
8269 run_test 133d "Verifying rename_stats ========================================"
8272 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8273 local testdir=$DIR/${tdir}/stats_testdir
8274 local ctr f0 f1 bs=32768 count=42 sum
8276 remote_ost_nodsh && skip "remote OST with nodsh" && return
8277 mkdir -p ${testdir} || error "mkdir failed"
8279 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
8281 for ctr in {write,read}_bytes; do
8283 cancel_lru_locks osc
8285 do_facet ost1 $LCTL set_param -n \
8286 "obdfilter.*.exports.clear=clear"
8288 if [ $ctr = write_bytes ]; then
8290 f1=${testdir}/${tfile}
8292 f0=${testdir}/${tfile}
8296 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
8299 cancel_lru_locks osc
8301 sum=$(do_facet ost1 $LCTL get_param \
8302 "obdfilter.*.exports.*.stats" | \
8305 $1 == ctr { sum += $7 }
8308 if ((sum != bs * count)); then
8309 error "Bad $ctr sum, expected $((bs * count)), got $sum"
8315 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
8318 local proc_dirs="/proc/fs/lustre/ /proc/sys/lnet/ /proc/sys/lustre/"
8321 # First without trusting modes.
8323 -exec cat '{}' \; &> /dev/null
8325 # Second verifying readability.
8329 -exec cat '{}' \; > /dev/null ||
8330 error "proc file read failed"
8332 for facet in $SINGLEMDS ost1; do
8333 do_facet $facet find $proc_dirs \
8334 -not -name req_history \
8335 -exec cat '{}' \\\; &> /dev/null
8337 do_facet $facet find $proc_dirs \
8338 -not -name req_history \
8341 -exec cat '{}' \\\; > /dev/null ||
8342 error "proc file read failed"
8345 run_test 133f "Check for LBUGs/Oopses/unreadable files in /proc"
8347 test_140() { #bug-17379
8348 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8349 test_mkdir -p $DIR/$tdir || error "Creating dir $DIR/$tdir"
8350 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
8351 cp /usr/bin/stat . || error "Copying stat to $DIR/$tdir"
8353 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
8354 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
8356 while i=`expr $i + 1`; do
8357 test_mkdir -p $i || error "Creating dir $i"
8358 cd $i || error "Changing to $i"
8359 ln -s ../stat stat || error "Creating stat symlink"
8360 # Read the symlink until ELOOP present,
8361 # not LBUGing the system is considered success,
8362 # we didn't overrun the stack.
8363 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
8365 if [ $ret -eq 40 ]; then
8368 error "Open stat symlink"
8374 echo "The symlink depth = $i"
8375 [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 -o $i -eq 40 ] ||
8376 error "Invalid symlink depth"
8378 # Test recursive symlink
8379 ln -s symlink_self symlink_self
8380 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
8381 echo "open symlink_self returns $ret"
8382 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
8384 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
8387 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8388 local TF="$TMP/$tfile"
8390 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
8392 cancel_lru_locks osc
8393 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
8394 remount_client $MOUNT
8396 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
8399 $TRUNCATE $DIR/$tfile 6000
8400 cancel_lru_locks osc
8401 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
8404 echo "12345" >>$DIR/$tfile
8405 cancel_lru_locks osc
8406 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
8409 echo "12345" >>$DIR/$tfile
8410 cancel_lru_locks osc
8411 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
8416 run_test 150 "truncate/append tests"
8418 function roc_hit() {
8419 local list=$(comma_list $(osts_nodes))
8421 echo $(get_osd_param $list '' stats |
8422 awk '/'cache_hit'/ {sum+=$2} END {print sum}')
8425 function set_cache() {
8428 if [ "$2" == "off" ]; then
8431 local list=$(comma_list $(osts_nodes))
8432 set_osd_param $list '' $1_cache_enable $on
8434 cancel_lru_locks osc
8438 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8439 remote_ost_nodsh && skip "remote OST with nodsh" && return
8442 local list=$(comma_list $(osts_nodes))
8444 # check whether obdfilter is cache capable at all
8445 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
8446 echo "not cache-capable obdfilter"
8450 # check cache is enabled on all obdfilters
8451 if get_osd_param $list '' read_cache_enable | grep 0; then
8452 echo "oss cache is disabled"
8456 set_osd_param $list '' writethrough_cache_enable 1
8458 # pages should be in the case right after write
8459 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES || error "dd failed"
8460 local BEFORE=`roc_hit`
8461 cancel_lru_locks osc
8462 cat $DIR/$tfile >/dev/null
8463 local AFTER=`roc_hit`
8464 if ! let "AFTER - BEFORE == CPAGES"; then
8465 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
8468 # the following read invalidates the cache
8469 cancel_lru_locks osc
8470 set_osd_param $list '' read_cache_enable 0
8471 cat $DIR/$tfile >/dev/null
8473 # now data shouldn't be found in the cache
8475 cancel_lru_locks osc
8476 cat $DIR/$tfile >/dev/null
8478 if let "AFTER - BEFORE != 0"; then
8479 error "IN CACHE: before: $BEFORE, after: $AFTER"
8482 set_osd_param $list '' read_cache_enable 1
8485 run_test 151 "test cache on oss and controls ==============================="
8488 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8489 local TF="$TMP/$tfile"
8491 # simulate ENOMEM during write
8492 #define OBD_FAIL_OST_NOMEM 0x226
8493 lctl set_param fail_loc=0x80000226
8494 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
8496 sync || error "sync failed"
8497 lctl set_param fail_loc=0
8499 # discard client's cache
8500 cancel_lru_locks osc
8502 # simulate ENOMEM during read
8503 lctl set_param fail_loc=0x80000226
8504 cmp $TF $DIR/$tfile || error "cmp failed"
8505 lctl set_param fail_loc=0
8509 run_test 152 "test read/write with enomem ============================"
8512 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
8514 run_test 153 "test if fdatasync does not crash ======================="
8516 dot_lustre_fid_permission_check() {
8518 local ffid=$MOUNT/.lustre/fid/$fid
8521 echo "stat fid $fid"
8522 stat $ffid > /dev/null || error "stat $ffid failed."
8523 echo "touch fid $fid"
8524 touch $ffid || error "touch $ffid failed."
8525 echo "write to fid $fid"
8526 cat /etc/hosts > $ffid || error "write $ffid failed."
8527 echo "read fid $fid"
8528 diff /etc/hosts $ffid || error "read $ffid failed."
8529 echo "append write to fid $fid"
8530 cat /etc/hosts >> $ffid || error "append write $ffid failed."
8531 echo "rename fid $fid"
8532 mv $ffid $test_dir/$tfile.1 &&
8533 error "rename $ffid to $tfile.1 should fail."
8534 touch $test_dir/$tfile.1
8535 mv $test_dir/$tfile.1 $ffid &&
8536 error "rename $tfile.1 to $ffid should fail."
8537 rm -f $test_dir/$tfile.1
8538 echo "truncate fid $fid"
8539 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
8540 echo "link fid $fid"
8541 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
8542 if [ -n $(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl) ]; then
8543 echo "setfacl fid $fid"
8544 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
8545 echo "getfacl fid $fid"
8546 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
8548 echo "unlink fid $fid"
8549 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
8550 echo "mknod fid $fid"
8551 mknod $ffid c 1 3 && error "mknod $ffid should fail."
8553 fid=[0xf00000400:0x1:0x0]
8554 ffid=$MOUNT/.lustre/fid/$fid
8556 echo "stat non-exist fid $fid"
8557 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
8558 echo "write to non-exist fid $fid"
8559 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
8560 echo "link new fid $fid"
8561 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
8563 mkdir -p $test_dir/$tdir
8564 touch $test_dir/$tdir/$tfile
8565 fid=$($LFS path2fid $test_dir/$tdir)
8568 error "error: could not get fid for $test_dir/$dir/$tfile."
8570 ffid=$MOUNT/.lustre/fid/$fid
8573 ls $ffid > /dev/null || error "ls $ffid failed."
8574 echo "touch $fid/$tfile.1"
8575 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
8577 echo "touch $MOUNT/.lustre/fid/$tfile"
8578 touch $MOUNT/.lustre/fid/$tfile && \
8579 error "touch $MOUNT/.lustre/fid/$tfile should fail."
8581 echo "setxattr to $MOUNT/.lustre/fid"
8582 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid &&
8583 error "setxattr should fail."
8585 echo "listxattr for $MOUNT/.lustre/fid"
8586 getfattr -d -m "^trusted" $MOUNT/.lustre/fid &&
8587 error "listxattr should fail."
8589 echo "delxattr from $MOUNT/.lustre/fid"
8590 setfattr -x trusted.name1 $MOUNT/.lustre/fid &&
8591 error "delxattr should fail."
8593 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
8594 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
8595 error "touch invalid fid should fail."
8597 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
8598 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
8599 error "touch non-normal fid should fail."
8601 echo "rename $tdir to $MOUNT/.lustre/fid"
8602 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
8603 error "rename to $MOUNT/.lustre/fid should fail."
8605 echo "rename .lustre to itself"
8606 fid=$($LFS path2fid $MOUNT)
8607 mrename $MOUNT/.lustre $MOUNT/.lustre/fid/$fid/.lustre &&
8608 error "rename .lustre to itself should fail."
8610 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
8611 fid=$($LFS path2fid $test_dir/$tfile-2)
8612 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
8613 cp /etc/passwd $MOUNT/.lustre/fid/$fid &&
8614 error "create lov data thru .lustre should fail."
8615 echo "cp /etc/passwd $test_dir/$tfile-2"
8616 cp /etc/passwd $test_dir/$tfile-2 ||
8617 error "copy to $test_dir/$tfile-2 failed."
8618 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
8619 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
8620 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
8622 rm -rf $test_dir/tfile.lnk
8623 rm -rf $test_dir/$tfile-2
8627 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8628 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
8629 { skip "Need MDS version at least 2.2.51"; return 0; }
8631 cp /etc/hosts $DIR/$tfile
8633 fid=$($LFS path2fid $DIR/$tfile)
8635 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
8637 dot_lustre_fid_permission_check "$fid" $DIR ||
8638 error "dot lustre permission check $fid failed"
8640 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
8641 chmod 777 $MOUNT/.lustre && error ".lustre is not allowed to be chmod"
8643 touch $MOUNT/.lustre/file &&
8644 error "creation is not allowed under .lustre"
8646 mkdir $MOUNT/.lustre/dir &&
8647 error "mkdir is not allowed under .lustre"
8651 run_test 154a "Open-by-FID"
8654 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8655 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
8656 { skip "Need MDS version at least 2.2.51"; return 0; }
8658 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
8660 local remote_dir=$DIR/$tdir/remote_dir
8665 $LFS mkdir -i $MDTIDX $remote_dir ||
8666 error "create remote directory failed"
8668 cp /etc/hosts $remote_dir/$tfile
8670 fid=$($LFS path2fid $remote_dir/$tfile)
8672 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
8674 dot_lustre_fid_permission_check "$fid" $remote_dir ||
8675 error "dot lustre permission check $fid failed"
8678 run_test 154b "Open-by-FID for remote directory"
8680 test_155_small_load() {
8681 local temp=$TMP/$tfile
8682 local file=$DIR/$tfile
8684 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
8685 error "dd of=$temp bs=6096 count=1 failed"
8687 cancel_lru_locks osc
8688 cmp $temp $file || error "$temp $file differ"
8690 $TRUNCATE $temp 6000
8691 $TRUNCATE $file 6000
8692 cmp $temp $file || error "$temp $file differ (truncate1)"
8694 echo "12345" >>$temp
8695 echo "12345" >>$file
8696 cmp $temp $file || error "$temp $file differ (append1)"
8698 echo "12345" >>$temp
8699 echo "12345" >>$file
8700 cmp $temp $file || error "$temp $file differ (append2)"
8706 test_155_big_load() {
8707 remote_ost_nodsh && skip "remote OST with nodsh" && return
8708 local temp=$TMP/$tfile
8709 local file=$DIR/$tfile
8712 local cache_size=$(do_facet ost$((MAXI+1)) \
8713 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
8714 local large_file_size=$((cache_size * 2))
8716 echo "OSS cache size: $cache_size KB"
8717 echo "Large file size: $large_file_size KB"
8719 [ $MAXV -le $large_file_size ] && \
8720 skip_env "max available OST size needs > $large_file_size KB" && \
8723 $SETSTRIPE $file -c 1 -i $MAXI || error "$SETSTRIPE $file failed"
8725 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k || \
8726 error "dd of=$temp bs=$large_file_size count=1k failed"
8729 cancel_lru_locks osc
8730 cmp $temp $file || error "$temp $file differ"
8737 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8739 set_cache writethrough on
8742 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
8745 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8747 set_cache writethrough off
8750 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
8753 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8755 set_cache writethrough on
8758 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
8761 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8763 set_cache writethrough off
8766 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
8769 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8771 set_cache writethrough on
8774 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
8777 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8779 set_cache writethrough off
8782 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
8785 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8787 set_cache writethrough on
8790 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
8793 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8795 set_cache writethrough off
8798 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
8801 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8805 local file="$DIR/$tfile"
8807 [ "$(facet_fstype ost1)" = "zfs" ] &&
8808 skip "LU-1956/LU-2261: stats unimplemented on OSD ZFS" &&
8811 log "Turn on read and write cache"
8813 set_cache writethrough on
8815 log "Write data and read it back."
8816 log "Read should be satisfied from the cache."
8817 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
8819 cancel_lru_locks osc
8820 cat $file >/dev/null
8822 if ! let "AFTER - BEFORE == CPAGES"; then
8823 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
8825 log "cache hits:: before: $BEFORE, after: $AFTER"
8828 log "Read again; it should be satisfied from the cache."
8830 cancel_lru_locks osc
8831 cat $file >/dev/null
8833 if ! let "AFTER - BEFORE == CPAGES"; then
8834 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
8836 log "cache hits:: before: $BEFORE, after: $AFTER"
8840 log "Turn off the read cache and turn on the write cache"
8842 set_cache writethrough on
8844 log "Read again; it should be satisfied from the cache."
8846 cancel_lru_locks osc
8847 cat $file >/dev/null
8849 if ! let "AFTER - BEFORE == CPAGES"; then
8850 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
8852 log "cache hits:: before: $BEFORE, after: $AFTER"
8855 log "Read again; it should not be satisfied from the cache."
8857 cancel_lru_locks osc
8858 cat $file >/dev/null
8860 if ! let "AFTER - BEFORE == 0"; then
8861 error "IN CACHE: before: $BEFORE, after: $AFTER"
8863 log "cache hits:: before: $BEFORE, after: $AFTER"
8866 log "Write data and read it back."
8867 log "Read should be satisfied from the cache."
8868 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
8870 cancel_lru_locks osc
8871 cat $file >/dev/null
8873 if ! let "AFTER - BEFORE == CPAGES"; then
8874 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
8876 log "cache hits:: before: $BEFORE, after: $AFTER"
8879 log "Read again; it should not be satisfied from the cache."
8881 cancel_lru_locks osc
8882 cat $file >/dev/null
8884 if ! let "AFTER - BEFORE == 0"; then
8885 error "IN CACHE: before: $BEFORE, after: $AFTER"
8887 log "cache hits:: before: $BEFORE, after: $AFTER"
8891 log "Turn off read and write cache"
8893 set_cache writethrough off
8895 log "Write data and read it back"
8896 log "It should not be satisfied from the cache."
8898 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
8899 cancel_lru_locks osc
8901 cat $file >/dev/null
8903 if ! let "AFTER - BEFORE == 0"; then
8904 error_ignore 20762 "IN CACHE: before: $BEFORE, after: $AFTER"
8906 log "cache hits:: before: $BEFORE, after: $AFTER"
8910 log "Turn on the read cache and turn off the write cache"
8912 set_cache writethrough off
8914 log "Write data and read it back"
8915 log "It should not be satisfied from the cache."
8917 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
8919 cancel_lru_locks osc
8920 cat $file >/dev/null
8922 if ! let "AFTER - BEFORE == 0"; then
8923 error_ignore 20762 "IN CACHE: before: $BEFORE, after: $AFTER"
8925 log "cache hits:: before: $BEFORE, after: $AFTER"
8928 log "Read again; it should be satisfied from the cache."
8930 cancel_lru_locks osc
8931 cat $file >/dev/null
8933 if ! let "AFTER - BEFORE == CPAGES"; then
8934 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
8936 log "cache hits:: before: $BEFORE, after: $AFTER"
8941 run_test 156 "Verification of tunables ============================"
8945 if [ $MDSCOUNT -gt 1 ]; then
8946 error_ignore 17935 $*
8954 MASK=$(do_facet $SINGLEMDS $LCTL get_param mdd.$MDT0.changelog_mask |\
8957 if [ $MASK -eq 1 ]; then
8958 do_facet $SINGLEMDS $LCTL set_param mdd.$MDT0.changelog_mask="-$1"
8960 do_facet $SINGLEMDS $LCTL set_param mdd.$MDT0.changelog_mask="+$1"
8965 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8966 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8967 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
8968 { skip "Need MDS version at least 2.2.0"; return; }
8969 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
8970 echo "Registered as changelog user $USER"
8971 do_facet $SINGLEMDS $LCTL get_param -n mdd.$MDT0.changelog_users | \
8972 grep -q $USER || error "User $USER not found in changelog_users"
8975 test_mkdir -p $DIR/$tdir/pics/2008/zachy
8976 touch $DIR/$tdir/pics/2008/zachy/timestamp
8977 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
8978 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
8979 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
8980 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
8981 rm $DIR/$tdir/pics/desktop.jpg
8983 $LFS changelog $MDT0 | tail -5
8985 echo "verifying changelog mask"
8986 changelog_chmask "MKDIR"
8987 changelog_chmask "CLOSE"
8989 test_mkdir -p $DIR/$tdir/pics/zach/sofia
8990 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
8992 changelog_chmask "MKDIR"
8993 changelog_chmask "CLOSE"
8995 test_mkdir -p $DIR/$tdir/pics/2008/sofia
8996 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
8998 $LFS changelog $MDT0
8999 MKDIRS=$($LFS changelog $MDT0 | tail -5 | grep -c "MKDIR")
9000 CLOSES=$($LFS changelog $MDT0 | tail -5 | grep -c "CLOSE")
9001 [ $MKDIRS -eq 1 ] || err17935 "MKDIR changelog mask count $DIRS != 1"
9002 [ $CLOSES -eq 1 ] || err17935 "CLOSE changelog mask count $DIRS != 1"
9005 echo "verifying target fid"
9006 fidc=$($LFS changelog $MDT0 | grep timestamp | grep "CREAT" | \
9007 tail -1 | awk '{print $6}')
9008 fidf=$($LFS path2fid $DIR/$tdir/pics/zach/timestamp)
9009 [ "$fidc" == "t=$fidf" ] || \
9010 err17935 "fid in changelog $fidc != file fid $fidf"
9011 echo "verifying parent fid"
9012 fidc=$($LFS changelog $MDT0 | grep timestamp | grep "CREAT" | \
9013 tail -1 | awk '{print $7}')
9014 fidf=$($LFS path2fid $DIR/$tdir/pics/zach)
9015 [ "$fidc" == "p=$fidf" ] || \
9016 err17935 "pfid in changelog $fidc != dir fid $fidf"
9018 USER_REC1=$(do_facet $SINGLEMDS $LCTL get_param -n \
9019 mdd.$MDT0.changelog_users | grep $USER | awk '{print $2}')
9020 $LFS changelog_clear $MDT0 $USER $(($USER_REC1 + 5))
9021 USER_REC2=$(do_facet $SINGLEMDS $LCTL get_param -n \
9022 mdd.$MDT0.changelog_users | grep $USER | awk '{print $2}')
9023 echo "verifying user clear: $(( $USER_REC1 + 5 )) == $USER_REC2"
9024 [ $USER_REC2 == $(($USER_REC1 + 5)) ] || \
9025 err17935 "user index should be $(($USER_REC1 + 5)); is $USER_REC2"
9027 MIN_REC=$(do_facet $SINGLEMDS $LCTL get_param mdd.$MDT0.changelog_users | \
9028 awk 'min == "" || $2 < min {min = $2}; END {print min}')
9029 FIRST_REC=$($LFS changelog $MDT0 | head -1 | awk '{print $1}')
9030 echo "verifying min purge: $(( $MIN_REC + 1 )) == $FIRST_REC"
9031 [ $FIRST_REC == $(($MIN_REC + 1)) ] || \
9032 err17935 "first index should be $(($MIN_REC + 1)); is $FIRST_REC"
9034 echo "verifying user deregister"
9035 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
9036 do_facet $SINGLEMDS $LCTL get_param -n mdd.$MDT0.changelog_users | \
9037 grep -q $USER && error "User $USER still found in changelog_users"
9039 USERS=$(( $(do_facet $SINGLEMDS $LCTL get_param -n \
9040 mdd.$MDT0.changelog_users | wc -l) - 2 ))
9041 if [ $USERS -eq 0 ]; then
9042 LAST_REC1=$(do_facet $SINGLEMDS $LCTL get_param -n \
9043 mdd.$MDT0.changelog_users | head -1 | awk '{print $3}')
9044 touch $DIR/$tdir/chloe
9045 LAST_REC2=$(do_facet $SINGLEMDS $LCTL get_param -n \
9046 mdd.$MDT0.changelog_users | head -1 | awk '{print $3}')
9047 echo "verify changelogs are off if we were the only user: $LAST_REC1 == $LAST_REC2"
9048 [ $LAST_REC1 == $LAST_REC2 ] || error "changelogs not off"
9050 echo "$USERS other changelog users; can't verify off"
9053 run_test 160 "changelog sanity"
9056 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9057 test_mkdir -p $DIR/$tdir
9058 cp /etc/hosts $DIR/$tdir/$tfile
9059 test_mkdir $DIR/$tdir/foo1
9060 test_mkdir $DIR/$tdir/foo2
9061 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
9062 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
9063 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
9064 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
9065 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[')
9066 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
9067 $LFS fid2path $DIR $FID
9068 err17935 "bad link ea"
9071 rm $DIR/$tdir/foo2/zachary
9073 rm $DIR/$tdir/foo2/thor
9075 rm $DIR/$tdir/$tfile
9077 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
9078 if [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ]
9080 $LFS fid2path $DIR $FID
9081 err17935 "bad link rename"
9083 rm $DIR/$tdir/foo2/maggie
9086 local longname=filename_avg_len_is_thirty_two_
9087 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 || \
9088 error "failed to hardlink many files"
9089 links=$($LFS fid2path $DIR $FID | wc -l)
9090 echo -n "${links}/1000 links in link EA"
9091 [ ${links} -gt 60 ] || err17935 "expected at least 60 links in link EA"
9092 unlinkmany $DIR/$tdir/foo2/$longname 1000 || \
9093 error "failed to unlink many hardlinks"
9095 run_test 161 "link ea sanity"
9102 local path=$(${LFS} fid2path $*)
9105 if [ $RC -ne 0 ]; then
9106 err17935 "path looked up of $expected failed. Error $RC"
9108 elif [ "${path}" != "${expected}" ]; then
9109 err17935 "path looked up \"${path}\" instead of \"${expected}\""
9112 echo "fid $fid resolves to path $path (expected $expected)"
9116 # Make changes to filesystem
9117 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9118 test_mkdir -p $DIR/$tdir/d2
9119 touch $DIR/$tdir/d2/$tfile
9120 touch $DIR/$tdir/d2/x1
9121 touch $DIR/$tdir/d2/x2
9122 test_mkdir -p $DIR/$tdir/d2/a/b/c
9123 test_mkdir -p $DIR/$tdir/d2/p/q/r
9125 FID=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
9126 check_path "$tdir/d2/$tfile" $FSNAME $FID --link 0
9129 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
9130 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
9131 check_path "$tdir/d2/p/q/r/slink" $FSNAME $FID --link 0
9133 # softlink to wrong file
9134 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
9135 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
9136 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME $FID --link 0
9139 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
9140 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
9141 FID=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
9142 # fid2path dir/fsname should both work
9143 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 1
9144 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR $FID --link 0
9146 # hardlink count: check that there are 2 links
9147 # Doesnt work with CMD yet: 17935
9148 ${LFS} fid2path $DIR $FID | wc -l | grep -q 2 || \
9149 err17935 "expected 2 links"
9151 # hardlink indexing: remove the first link
9152 rm $DIR/$tdir/d2/p/q/r/hlink
9153 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 0
9157 run_test 162 "path lookup sanity"
9160 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9161 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9162 copytool --test $FSNAME || { skip "copytool not runnable: $?" && return; }
9165 local uuid=$($LCTL get_param -n mdc.${FSNAME}-MDT0000-mdc-*.uuid)
9166 # this proc file is temporary and linux-only
9167 do_facet $SINGLEMDS lctl set_param mdt.${FSNAME}-MDT0000.mdccomm=$uuid ||\
9168 error "kernel->userspace send failed"
9171 run_test 163 "kernel <-> userspace comms"
9174 # do directio so as not to populate the page cache
9175 log "creating a 10 Mb file"
9176 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
9177 log "starting reads"
9178 dd if=$DIR/$tfile of=/dev/null bs=4096 &
9179 log "truncating the file"
9180 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
9182 kill %+ || true # reads might have finished
9183 echo "wait until dd is finished"
9185 log "removing the temporary file"
9186 rm -rf $DIR/$tfile || error "tmp file removal failed"
9188 run_test 169 "parallel read and truncate should not deadlock"
9191 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9192 $LCTL clear # bug 18514
9193 $LCTL debug_daemon start $TMP/${tfile}_log_good
9195 $LCTL debug_daemon stop
9196 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
9197 error "sed failed to read log_good"
9199 $LCTL debug_daemon start $TMP/${tfile}_log_good
9201 $LCTL debug_daemon stop
9203 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
9204 error "lctl df log_bad failed"
9206 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
9207 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
9209 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
9210 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
9212 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
9213 error "bad_line good_line1 good_line2 are empty"
9215 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
9216 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
9217 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
9219 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
9220 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
9221 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
9223 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
9224 error "bad_line_new good_line_new are empty"
9226 local expected_good=$((good_line1 + good_line2*2))
9228 rm -f $TMP/${tfile}*
9229 # LU-231, short malformed line may not be counted into bad lines
9230 if [ $bad_line -ne $bad_line_new ] &&
9231 [ $bad_line -ne $((bad_line_new - 1)) ]; then
9232 error "expected $bad_line bad lines, but got $bad_line_new"
9236 if [ $expected_good -ne $good_line_new ]; then
9237 error "expected $expected_good good lines, but got $good_line_new"
9242 run_test 170 "test lctl df to handle corrupted log ====================="
9244 test_171() { # bug20592
9245 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9246 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
9247 $LCTL set_param fail_loc=0x50e
9248 $LCTL set_param fail_val=3000
9249 multiop_bg_pause $DIR/$tfile O_s || true
9251 kill -USR1 $MULTIPID
9255 if dmesg | grep "recursive fault"; then
9256 error "caught a recursive fault"
9258 $LCTL set_param fail_loc=0
9261 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
9263 # it would be good to share it with obdfilter-survey/libecho code
9264 setup_obdecho_osc () {
9267 local obdfilter_name=$2
9268 echo "Creating new osc for $obdfilter_name on $ost_nid"
9269 # make sure we can find loopback nid
9270 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
9272 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
9273 ${obdfilter_name}_osc_UUID || rc=2; }
9274 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
9275 ${obdfilter_name}_UUID $ost_nid || rc=3; }
9279 cleanup_obdecho_osc () {
9280 local obdfilter_name=$1
9281 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
9282 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
9286 obdecho_create_test() {
9291 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
9292 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
9294 if [ $rc -eq 0 ]; then
9295 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
9296 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
9298 echo "New object id is $id"
9299 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec test_brw 10 w v 64 $id" ||
9301 [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec " \
9302 "cleanup" || rc=5; }
9303 [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec " \
9305 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
9310 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9311 remote_ost_nodsh && skip "remote OST with nodsh" && return
9315 if ! module_loaded obdecho; then
9316 load_module obdecho/obdecho
9320 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
9321 local host=$(lctl get_param -n osc.$osc.import |
9322 awk '/current_connection:/ {print $2}' )
9323 local target=$(lctl get_param -n osc.$osc.import |
9324 awk '/target:/ {print $2}' )
9325 target=${target%_UUID}
9327 [[ -n $target ]] && { setup_obdecho_osc $host $target || rc=1; } || rc=1
9328 [ $rc -eq 0 ] && { obdecho_create_test ${target}_osc client || rc=2; }
9329 [[ -n $target ]] && cleanup_obdecho_osc $target
9330 [ $rmmod_local -eq 1 ] && rmmod obdecho
9333 run_test 180a "test obdecho on osc"
9336 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9337 remote_ost_nodsh && skip "remote OST with nodsh" && return
9339 local rmmod_remote=0
9341 do_facet ost1 "lsmod | grep -q obdecho || " \
9342 "{ insmod ${LUSTRE}/obdecho/obdecho.ko || " \
9343 "modprobe obdecho; }" && rmmod_remote=1
9344 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ {print $4;exit}')
9345 [[ -n $target ]] && { obdecho_create_test $target ost1 || rc=1; }
9346 [ $rmmod_remote -eq 1 ] && do_facet ost1 "rmmod obdecho"
9349 run_test 180b "test obdecho directly on obdfilter"
9351 test_181() { # bug 22177
9352 test_mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
9353 # create enough files to index the directory
9354 createmany -o $DIR/$tdir/foobar 4000
9355 # print attributes for debug purpose
9358 multiop_bg_pause $DIR/$tdir D_Sc || return 1
9360 # remove the files & current working dir
9361 unlinkmany $DIR/$tdir/foobar 4000
9363 kill -USR1 $MULTIPID
9365 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
9368 run_test 181 "Test open-unlinked dir ========================"
9371 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9372 # disable MDC RPC lock wouldn't crash client
9376 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
9377 #define OBD_FAIL_MDC_RPCS_SEM 0x804
9378 $LCTL set_param fail_loc=0x804
9380 for (( i=0; i < $tcount; i++ )) ; do
9382 createmany -o $DIR/$tdir/$i/f- $fcount &
9386 for (( i=0; i < $tcount; i++ )) ; do
9387 unlinkmany $DIR/$tdir/$i/f- $fcount &
9393 $LCTL set_param fail_loc=0
9395 run_test 182 "Disable MDC RPCs semaphore wouldn't crash client ================"
9397 test_183() { # LU-2275
9398 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9399 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
9400 echo aaa > $DIR/$tdir/$tfile
9402 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
9403 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
9405 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
9406 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
9408 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
9410 # Flush negative dentry cache
9411 touch $DIR/$tdir/$tfile
9413 # We are not checking for any leaked references here, they'll
9414 # become evident next time we do cleanup with module unload.
9417 run_test 183 "No crash or request leak in case of strange dispositions ========"
9419 test_185() { # LU-2441
9420 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
9421 touch $DIR/$tdir/spoo
9422 local mtime1=$(stat -c "%Y" $DIR/$tdir)
9423 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
9424 error "cannot create/write a volatile file"
9425 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
9426 error "FID is still valid after close"
9428 multiop_bg_pause $DIR/$tdir vVw4096_c
9435 # assume that the next FID for this client is sequential, since stdout
9436 # is unfortunately eaten by multiop_bg_pause
9437 local n=$((${fidv[1]} + 1))
9438 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
9439 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
9440 error "FID is missing before close"
9441 kill -USR1 $multi_pid
9442 # 1 second delay, so if mtime change we will see it
9444 local mtime2=$(stat -c "%Y" $DIR/$tdir)
9445 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
9447 run_test 185 "Volatile file support"
9449 check_swap_layouts_support()
9451 $LCTL get_param -n llite.*.sbi_flags | grep -q layout ||
9452 { skip "Does not support layout lock."; return 0; }
9456 # test suite 184 is for LU-2016, LU-2017
9458 check_swap_layouts_support && return 0
9460 dir0=$DIR/$tdir/$testnum
9461 test_mkdir -p $dir0 || error "creating dir $dir0"
9466 $SETSTRIPE -c1 $file1
9468 $SETSTRIPE -c2 $file2
9470 gen1=$($GETSTRIPE -g $file1)
9471 gen2=$($GETSTRIPE -g $file2)
9473 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
9474 gen=$($GETSTRIPE -g $file1)
9475 [[ $gen1 != $gen ]] ||
9476 "Layout generation on $file1 does not change"
9477 gen=$($GETSTRIPE -g $file2)
9478 [[ $gen2 != $gen ]] ||
9479 "Layout generation on $file2 does not change"
9481 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
9482 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
9484 run_test 184a "Basic layout swap"
9487 check_swap_layouts_support && return 0
9489 dir0=$DIR/$tdir/$testnum
9490 mkdir -p $dir0 || error "creating dir $dir0"
9497 $SETSTRIPE -c1 $file1
9498 $SETSTRIPE -c2 $file2
9499 $SETSTRIPE -c1 $file3
9500 chown $RUNAS_ID $file3
9501 gen1=$($GETSTRIPE -g $file1)
9502 gen2=$($GETSTRIPE -g $file2)
9504 $LFS swap_layouts $dir1 $dir2 &&
9505 error "swap of directories layouts should fail"
9506 $LFS swap_layouts $dir1 $file1 &&
9507 error "swap of directory and file layouts should fail"
9508 $RUNAS $LFS swap_layouts $file1 $file2 &&
9509 error "swap of file we cannot write should fail"
9510 $LFS swap_layouts $file1 $file3 &&
9511 error "swap of file with different owner should fail"
9512 /bin/true # to clear error code
9514 run_test 184b "Forbidden layout swap (will generate errors)"
9517 check_swap_layouts_support && return 0
9519 local dir0=$DIR/$tdir/$testnum
9520 mkdir -p $dir0 || error "creating dir $dir0"
9522 local ref1=$dir0/ref1
9523 local ref2=$dir0/ref2
9524 local file1=$dir0/file1
9525 local file2=$dir0/file2
9526 # create a file large enough for the concurent test
9527 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
9528 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
9529 echo "ref file size: ref1(`stat -c %s $ref1`), ref2(`stat -c %s $ref2`)"
9532 dd if=$ref1 of=$file1 bs=16k &
9535 sleep 0.$((RANDOM % 5 + 1))
9537 $LFS swap_layouts $file1 $file2
9540 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
9541 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
9543 # how many bytes copied before swapping layout
9544 local copied=`stat -c %s $file2`
9545 local remaining=`stat -c %s $ref1`
9546 remaining=$((remaining - copied))
9547 echo "Copied $copied bytes before swapping layout..."
9549 cmp -n $copied $file1 $ref2 | grep differ &&
9550 error "Content mismatch [0, $copied) of ref2 and file1"
9551 cmp -n $copied $file2 $ref1 ||
9552 error "Content mismatch [0, $copied) of ref1 and file2"
9553 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
9554 error "Content mismatch [$copied, EOF) of ref1 and file1"
9557 rm -f $ref1 $ref2 $file1 $file2
9559 run_test 184c "Concurrent write and layout swap"
9562 check_file_in_pool()
9567 local res=$($GETSTRIPE $file | grep 0x | cut -f2)
9570 for t in $tlist ; do
9571 [ "$i" -eq "$t" ] && continue 2
9574 echo "pool list: $tlist"
9575 echo "striping: $res"
9576 error_noexit "$file not allocated in $pool"
9583 echo "Creating new pool"
9586 create_pool $FSNAME.$pool ||
9587 { error_noexit "No pool created, result code $?"; return 1; }
9588 [ $($LFS pool_list $FSNAME | grep -c $pool) -eq 1 ] ||
9589 { error_noexit "$pool not in lfs pool_list"; return 2; }
9592 pool_add_targets() {
9593 echo "Adding targets to pool"
9599 local list=$(seq $first $step $last)
9601 local t=$(for i in $list; do printf "$FSNAME-OST%04x_UUID " $i; done)
9602 do_facet mgs $LCTL pool_add \
9603 $FSNAME.$pool $FSNAME-OST[$first-$last/$step]
9604 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$pool \
9605 | sort -u | tr '\n' ' ' " "$t" || {
9606 error_noexit "Add to pool failed"
9609 local lfscount=$($LFS pool_list $FSNAME.$pool | grep -c "\-OST")
9610 local addcount=$(((last - first) / step + 1))
9611 [ $lfscount -eq $addcount ] || {
9612 error_noexit "lfs pool_list bad ost count" \
9613 "$lfscount != $addcount"
9621 echo "Setting pool on directory $tdir"
9623 $SETSTRIPE -c 2 -p $pool $tdir && return 0
9625 error_noexit "Cannot set pool $pool to $tdir"
9632 echo "Checking pool on directory $tdir"
9634 local res=$($GETSTRIPE --pool $tdir | sed "s/\s*$//")
9635 [ "$res" = "$pool" ] && return 0
9637 error_noexit "Pool on '$tdir' is '$res', not '$pool'"
9641 pool_dir_rel_path() {
9642 echo "Testing relative path works well"
9647 mkdir -p $root/$tdir/$tdir
9649 pool_set_dir $pool $tdir || return 1
9650 pool_set_dir $pool ./$tdir || return 2
9651 pool_set_dir $pool ../$tdir || return 3
9652 pool_set_dir $pool ../$tdir/$tdir || return 4
9653 rm -rf $tdir; cd - > /dev/null
9656 pool_alloc_files() {
9657 echo "Checking files allocation from directory pool"
9664 for i in $(seq -w 1 $count)
9666 local file=$tdir/file-$i
9668 check_file_in_pool $file $pool "$tlist" || \
9669 failed=$((failed + 1))
9671 [ "$failed" = 0 ] && return 0
9673 error_noexit "$failed files not allocated in $pool"
9677 pool_create_files() {
9678 echo "Creating files in pool"
9686 for i in $(seq -w 1 $count)
9688 local file=$tdir/spoo-$i
9689 $SETSTRIPE -p $pool $file
9690 check_file_in_pool $file $pool "$tlist" || \
9691 failed=$((failed + 1))
9693 [ "$failed" = 0 ] && return 0
9695 error_noexit "$failed files not allocated in $pool"
9700 echo "Checking 'lfs df' output"
9703 local t=$($LCTL get_param -n lov.$FSNAME-clilov-*.pools.$pool |
9705 local res=$($LFS df --pool $FSNAME.$pool |
9707 grep "$FSNAME-OST" |
9709 [ "$res" = "$t" ] && return 0
9711 error_noexit "Pools OSTs '$t' is not '$res' that lfs df reports"
9715 pool_file_rel_path() {
9716 echo "Creating files in a pool with relative pathname"
9721 { error_noexit "unable to create $tdir"; return 1 ; }
9722 local file="/..$tdir/$tfile-1"
9723 $SETSTRIPE -p $pool $file ||
9724 { error_noexit "unable to create $file" ; return 2 ; }
9727 $SETSTRIPE -p $pool $tfile-2 || {
9728 error_noexit "unable to create $tfile-2 in $tdir"
9733 pool_remove_first_target() {
9734 echo "Removing first target from a pool"
9737 local pname="lov.$FSNAME-*.pools.$pool"
9738 local t=$($LCTL get_param -n $pname | head -1)
9739 do_facet mgs $LCTL pool_remove $FSNAME.$pool $t
9740 wait_update $HOSTNAME "lctl get_param -n $pname | grep $t" "" || {
9741 error_noexit "$t not removed from $FSNAME.$pool"
9746 pool_remove_all_targets() {
9747 echo "Removing all targets from pool"
9750 local pname="lov.$FSNAME-*.pools.$pool"
9751 for t in $($LCTL get_param -n $pname | sort -u)
9753 do_facet mgs $LCTL pool_remove $FSNAME.$pool $t
9755 wait_update $HOSTNAME "lctl get_param -n $pname" "" || {
9756 error_noexit "Pool $FSNAME.$pool cannot be drained"
9759 # striping on an empty/nonexistant pool should fall back
9760 # to "pool of everything"
9762 error_noexit "failed to use fallback striping for empty pool"
9765 # setstripe on an empty pool should fail
9766 $SETSTRIPE -p $pool $file 2>/dev/null && {
9767 error_noexit "expected failure when creating file" \
9775 echo "Destroying pool"
9779 do_facet mgs $LCTL pool_destroy $FSNAME.$pool
9782 # striping on an empty/nonexistant pool should fall back
9783 # to "pool of everything"
9785 error_noexit "failed to use fallback striping for missing pool"
9788 # setstripe on an empty pool should fail
9789 $SETSTRIPE -p $pool $file 2>/dev/null && {
9790 error_noexit "expected failure when creating file" \
9795 # get param should return err once pool is gone
9796 if wait_update $HOSTNAME "lctl get_param -n \
9797 lov.$FSNAME-*.pools.$pool 2>/dev/null || echo foo" "foo"
9799 remove_pool_from_list $FSNAME.$pool
9802 error_noexit "Pool $FSNAME.$pool is not destroyed"
9807 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9808 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
9810 local POOL=${POOL:-cea1}
9811 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
9812 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
9815 local last_ost=$(($OSTCOUNT - 1))
9817 local ost_list=$(seq $first_ost $ost_step $last_ost)
9818 local ost_range="$first_ost $last_ost $ost_step"
9819 local test_path=$POOL_ROOT/$POOL_DIR_NAME
9820 local file_dir=$POOL_ROOT/file_tst
9824 # former test_200a test_200b
9825 pool_add $POOL || { rc=$? ; break; }
9826 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
9827 # former test_200c test_200d
9829 pool_set_dir $POOL $test_path || { rc=$? ; break; }
9830 pool_check_dir $POOL $test_path || { rc=$? ; break; }
9831 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
9832 || { rc=$? ; break; }
9833 # former test_200e test_200f
9834 local files=$((OSTCOUNT*3))
9835 pool_alloc_files $POOL $test_path $files "$ost_list" \
9836 || { rc=$? ; break; }
9837 pool_create_files $POOL $file_dir $files "$ost_list" \
9838 || { rc=$? ; break; }
9839 # former test_200g test_200h
9840 pool_lfs_df $POOL || { rc=$? ; break; }
9841 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
9843 # former test_201a test_201b test_201c
9844 pool_remove_first_target $POOL || { rc=$? ; break; }
9846 local f=$test_path/$tfile
9847 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
9848 pool_remove $POOL $f || { rc=$? ; break; }
9855 run_test 200 "OST pools"
9857 # usage: default_attr <count | size | offset>
9859 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
9862 # usage: check_default_stripe_attr
9863 check_default_stripe_attr() {
9864 ACTUAL=$($GETSTRIPE $* $DIR/$tdir)
9866 --stripe-count|--count)
9867 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
9868 --stripe-size|--size)
9869 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
9870 --stripe-index|--index)
9873 error "unknown getstripe attr '$1'"
9876 [ $ACTUAL != $EXPECTED ] &&
9877 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
9881 test_mkdir -p $DIR/$tdir
9882 $SETSTRIPE --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
9884 check_default_stripe_attr --stripe-count
9885 check_default_stripe_attr --stripe-size
9886 check_default_stripe_attr --stripe-index
9890 run_test 204a "Print default stripe attributes ================="
9893 test_mkdir -p $DIR/$tdir
9894 $SETSTRIPE --stripe-count 1 $DIR/$tdir
9896 check_default_stripe_attr --stripe-size
9897 check_default_stripe_attr --stripe-index
9901 run_test 204b "Print default stripe size and offset ==========="
9904 test_mkdir -p $DIR/$tdir
9905 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
9907 check_default_stripe_attr --stripe-count
9908 check_default_stripe_attr --stripe-index
9912 run_test 204c "Print default stripe count and offset ==========="
9915 test_mkdir -p $DIR/$tdir
9916 $SETSTRIPE --stripe-index 0 $DIR/$tdir
9918 check_default_stripe_attr --stripe-count
9919 check_default_stripe_attr --stripe-size
9923 run_test 204d "Print default stripe count and size ============="
9926 test_mkdir -p $DIR/$tdir
9927 $SETSTRIPE -d $DIR/$tdir
9929 check_default_stripe_attr --stripe-count --raw
9930 check_default_stripe_attr --stripe-size --raw
9931 check_default_stripe_attr --stripe-index --raw
9935 run_test 204e "Print raw stripe attributes ================="
9938 test_mkdir -p $DIR/$tdir
9939 $SETSTRIPE --stripe-count 1 $DIR/$tdir
9941 check_default_stripe_attr --stripe-size --raw
9942 check_default_stripe_attr --stripe-index --raw
9946 run_test 204f "Print raw stripe size and offset ==========="
9949 test_mkdir -p $DIR/$tdir
9950 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
9952 check_default_stripe_attr --stripe-count --raw
9953 check_default_stripe_attr --stripe-index --raw
9957 run_test 204g "Print raw stripe count and offset ==========="
9960 test_mkdir -p $DIR/$tdir
9961 $SETSTRIPE --stripe-index 0 $DIR/$tdir
9963 check_default_stripe_attr --stripe-count --raw
9964 check_default_stripe_attr --stripe-size --raw
9968 run_test 204h "Print raw stripe count and size ============="
9970 # Figure out which job scheduler is being used, if any,
9972 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
9974 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
9976 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
9978 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
9979 JOBENV=LOADL_STEP_ID
9980 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
9990 # clear old jobstats
9991 do_facet $SINGLEMDS lctl set_param mdt.*.job_stats="clear"
9992 do_facet ost1 lctl set_param obdfilter.*.job_stats="clear"
9994 # use a new JobID for this test, or we might see an old one
9995 [ "$JOBENV" = "FAKE_JOBID" ] && FAKE_JOBID=test_id.$testnum.$RANDOM
9999 log "Using JobID environment variable $JOBENV=$JOBVAL"
10001 if [ $JOBENV = "FAKE_JOBID" ]; then
10002 FAKE_JOBID=$JOBVAL $cmd
10007 if [ "$target" = "mdt" -o "$target" = "both" ]; then
10008 FACET="$SINGLEMDS" # will need to get MDS number for DNE
10009 do_facet $FACET lctl get_param mdt.*.job_stats |
10010 grep $JOBVAL || error "No job stats found on MDT $FACET"
10012 if [ "$target" = "ost" -o "$target" = "both" ]; then
10014 do_facet $FACET lctl get_param obdfilter.*.job_stats |
10015 grep $JOBVAL || error "No job stats found on OST $FACET"
10019 test_205() { # Job stats
10020 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10021 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
10022 skip "Server doesn't support jobstats" && return 0
10025 OLD_JOBENV=`$LCTL get_param -n jobid_var`
10026 if [ $OLD_JOBENV != $JOBENV ]; then
10027 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$JOBENV
10028 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" \
10029 $JOBENV || return 1
10033 cmd="mkdir $DIR/$tfile"
10034 verify_jobstats "$cmd" "mdt"
10036 cmd="rm -fr $DIR/$tfile"
10037 verify_jobstats "$cmd" "mdt"
10039 cmd="mknod $DIR/$tfile c 1 3"
10040 verify_jobstats "$cmd" "mdt"
10042 cmd="rm -f $DIR/$tfile"
10043 verify_jobstats "$cmd" "mdt"
10045 cmd="$SETSTRIPE -i 0 -c 1 $DIR/$tfile"
10046 verify_jobstats "$cmd" "mdt"
10048 cmd="touch $DIR/$tfile"
10049 verify_jobstats "$cmd" "both"
10051 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
10052 verify_jobstats "$cmd" "ost"
10054 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
10055 verify_jobstats "$cmd" "ost"
10057 cmd="$TRUNCATE $DIR/$tfile 0"
10058 verify_jobstats "$cmd" "both"
10060 cmd="mv -f $DIR/$tfile $DIR/jobstats_test_rename"
10061 verify_jobstats "$cmd" "mdt"
10064 rm -f $DIR/jobstats_test_rename
10066 if [ $OLD_JOBENV != $JOBENV ]; then
10067 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$OLD_JOBENV
10068 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" \
10069 $OLD_JOBENV || return 1
10072 run_test 205 "Verify job stats"
10074 # LU-1480, LU-1773 and LU-1657
10076 mkdir -p $DIR/$tdir
10077 lfs setstripe -c -1 $DIR/$tdir
10078 #define OBD_FAIL_LOV_INIT 0x1403
10079 $LCTL set_param fail_loc=0xa0001403
10080 $LCTL set_param fail_val=1
10081 touch $DIR/$tdir/$tfile || true
10083 run_test 206 "fail lov_init_raid0() doesn't lbug"
10086 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
10087 local fsz=`stat -c %s $DIR/$tfile`
10088 cancel_lru_locks mdc
10090 # do not return layout in getattr intent
10091 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
10092 $LCTL set_param fail_loc=0x170
10093 local sz=`stat -c %s $DIR/$tfile`
10095 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
10099 run_test 207a "can refresh layout at glimpse"
10102 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
10103 local cksum=`md5sum $DIR/$tfile`
10104 local fsz=`stat -c %s $DIR/$tfile`
10105 cancel_lru_locks mdc
10106 cancel_lru_locks osc
10108 # do not return layout in getattr intent
10109 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
10110 $LCTL set_param fail_loc=0x171
10112 # it will refresh layout after the file is opened but before read issues
10113 echo checksum is "$cksum"
10114 echo "$cksum" |md5sum -c --quiet || error "file differs"
10118 run_test 207b "can refresh layout at open"
10122 size=$((size % 8192 + 1))
10123 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
10124 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
10125 rm -f $DIR/f212 $DIR/f212.xyz
10127 run_test 212 "Sendfile test ============================================"
10130 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
10131 cancel_lru_locks osc
10132 lctl set_param fail_loc=0x8000040f
10133 # generate a read lock
10134 cat $DIR/$tfile > /dev/null
10135 # write to the file, it will try to cancel the above read lock.
10136 cat /etc/hosts >> $DIR/$tfile
10138 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
10140 test_214() { # for bug 20133
10141 test_mkdir -p $DIR/d214p/d214c
10142 for (( i=0; i < 340; i++ )) ; do
10143 touch $DIR/d214p/d214c/a$i
10146 ls -l $DIR/d214p || error "ls -l $DIR/d214p failed"
10147 mv $DIR/d214p/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
10148 ls $DIR/d214c || error "ls $DIR/d214c failed"
10149 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
10151 run_test 214 "hash-indexed directory test - bug 20133"
10153 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
10154 create_lnet_proc_files() {
10155 cat /proc/sys/lnet/$1 >$TMP/lnet_$1.out || error "cannot read /proc/sys/lnet/$1"
10156 sysctl lnet.$1 >$TMP/lnet_$1.sys_tmp || error "cannot read lnet.$1"
10158 sed "s/^lnet.$1\ =\ //g" "$TMP/lnet_$1.sys_tmp" >$TMP/lnet_$1.sys
10159 rm -f "$TMP/lnet_$1.sys_tmp"
10162 # counterpart of create_lnet_proc_files
10163 remove_lnet_proc_files() {
10164 rm -f $TMP/lnet_$1.out $TMP/lnet_$1.sys
10167 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
10168 # 3rd arg as regexp for body
10169 check_lnet_proc_stats() {
10170 local l=$(cat "$TMP/lnet_$1" |wc -l)
10171 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
10173 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
10176 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
10177 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
10178 # optional and can be regexp for 2nd line (lnet.routes case)
10179 check_lnet_proc_entry() {
10180 local blp=2 # blp stands for 'position of 1st line of body'
10181 [ "$5" = "" ] || blp=3 # lnet.routes case
10183 local l=$(cat "$TMP/lnet_$1" |wc -l)
10184 # subtracting one from $blp because the body can be empty
10185 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
10187 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
10188 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
10190 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
10191 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
10193 # bail out if any unexpected line happened
10194 sed -n "$blp~1 p" "$TMP/lnet_$1" |grep -Ev "$3"
10195 [ "$?" != 0 ] || error "$2 misformatted"
10198 test_215() { # for bugs 18102, 21079, 21517
10199 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10200 local N='(0|[1-9][0-9]*)' # non-negative numeric
10201 local P='[1-9][0-9]*' # positive numeric
10202 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
10203 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
10204 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
10205 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
10207 local L1 # regexp for 1st line
10208 local L2 # regexp for 2nd line (optional)
10209 local BR # regexp for the rest (body)
10211 # /proc/sys/lnet/stats should look as 11 space-separated non-negative numerics
10212 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
10213 create_lnet_proc_files "stats"
10214 check_lnet_proc_stats "stats.out" "/proc/sys/lnet/stats" "$BR"
10215 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
10216 remove_lnet_proc_files "stats"
10218 # /proc/sys/lnet/routes should look like this:
10219 # Routing disabled/enabled
10220 # net hops state router
10221 # where net is a string like tcp0, hops >= 0, state is up/down,
10222 # router is a string like 192.168.1.1@tcp2
10223 L1="^Routing (disabled|enabled)$"
10224 L2="^net +hops +state +router$"
10225 BR="^$NET +$N +(up|down) +$NID$"
10226 create_lnet_proc_files "routes"
10227 check_lnet_proc_entry "routes.out" "/proc/sys/lnet/routes" "$BR" "$L1" "$L2"
10228 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
10229 remove_lnet_proc_files "routes"
10231 # /proc/sys/lnet/routers should look like this:
10232 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
10233 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
10234 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
10235 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
10236 L1="^ref +rtr_ref +alive_cnt +state +last_ping +ping_sent +deadline +down_ni +router$"
10237 BR="^$P +$P +$N +(up|down) +$N +(0|1) +$I +$I +$NID$"
10238 create_lnet_proc_files "routers"
10239 check_lnet_proc_entry "routers.out" "/proc/sys/lnet/routers" "$BR" "$L1"
10240 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
10241 remove_lnet_proc_files "routers"
10243 # /proc/sys/lnet/peers should look like this:
10244 # nid refs state last max rtr min tx min queue
10245 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
10246 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
10247 # numeric (0 or >0 or <0), queue >= 0.
10248 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
10249 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
10250 create_lnet_proc_files "peers"
10251 check_lnet_proc_entry "peers.out" "/proc/sys/lnet/peers" "$BR" "$L1"
10252 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
10253 remove_lnet_proc_files "peers"
10255 # /proc/sys/lnet/buffers should look like this:
10256 # pages count credits min
10257 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
10258 L1="^pages +count +credits +min$"
10259 BR="^ +$N +$N +$I +$I$"
10260 create_lnet_proc_files "buffers"
10261 check_lnet_proc_entry "buffers.out" "/proc/sys/lnet/buffers" "$BR" "$L1"
10262 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
10263 remove_lnet_proc_files "buffers"
10265 # /proc/sys/lnet/nis should look like this:
10266 # nid status alive refs peer rtr max tx min
10267 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
10268 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
10269 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
10270 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
10271 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
10272 create_lnet_proc_files "nis"
10273 check_lnet_proc_entry "nis.out" "/proc/sys/lnet/nis" "$BR" "$L1"
10274 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
10275 remove_lnet_proc_files "nis"
10277 # can we successfully write to /proc/sys/lnet/stats?
10278 echo "0" >/proc/sys/lnet/stats || error "cannot write to /proc/sys/lnet/stats"
10279 sysctl -w lnet.stats=0 || error "cannot write to lnet.stats"
10281 run_test 215 "/proc/sys/lnet exists and has proper content - bugs 18102, 21079, 21517"
10283 test_216() { # bug 20317
10284 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10285 remote_ost_nodsh && skip "remote OST with nodsh" && return
10287 local p="$TMP/sanityN-$TESTNAME.parameters"
10288 save_lustre_params $HOSTNAME "osc.*.contention_seconds" > $p
10289 for node in $(osts_nodes); do
10290 save_lustre_params $node "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
10291 save_lustre_params $node "ldlm.namespaces.filter-*.contended_locks" >> $p
10292 save_lustre_params $node "ldlm.namespaces.filter-*.contention_seconds" >> $p
10296 # agressive lockless i/o settings
10297 for node in $(osts_nodes); do
10298 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'
10300 lctl set_param -n osc.*.contention_seconds 60
10302 $DIRECTIO write $DIR/$tfile 0 10 4096
10303 $CHECKSTAT -s 40960 $DIR/$tfile
10305 # disable lockless i/o
10306 for node in $(osts_nodes); do
10307 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'
10309 lctl set_param -n osc.*.contention_seconds 0
10312 dd if=/dev/zero of=$DIR/$tfile count=0
10313 $CHECKSTAT -s 0 $DIR/$tfile
10315 restore_lustre_params <$p
10319 run_test 216 "check lockless direct write works and updates file size and kms correctly"
10321 test_217() { # bug 22430
10322 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10326 for node in $(nodes_list); do
10327 nid=$(host_nids_address $node $NETTYPE)
10328 if [[ $nid = *-* ]] ; then
10329 echo "lctl ping $nid@$NETTYPE"
10330 lctl ping $nid@$NETTYPE
10332 echo "skipping $node (no hyphen detected)"
10336 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
10339 # do directio so as not to populate the page cache
10340 log "creating a 10 Mb file"
10341 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
10342 log "starting reads"
10343 dd if=$DIR/$tfile of=/dev/null bs=4096 &
10344 log "truncating the file"
10345 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
10347 kill %+ || true # reads might have finished
10348 echo "wait until dd is finished"
10350 log "removing the temporary file"
10351 rm -rf $DIR/$tfile || error "tmp file removal failed"
10353 run_test 218 "parallel read and truncate should not deadlock ======================="
10356 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10357 # write one partial page
10358 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
10359 # set no grant so vvp_io_commit_write will do sync write
10360 $LCTL set_param fail_loc=0x411
10361 # write a full page at the end of file
10362 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
10364 $LCTL set_param fail_loc=0
10365 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
10366 $LCTL set_param fail_loc=0x411
10367 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
10369 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
10371 test_220() { #LU-325
10372 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10373 remote_ost_nodsh && skip "remote OST with nodsh" && return
10376 test_mkdir -p $DIR/$tdir
10377 local OST=$(lfs osts | grep ${OSTIDX}": " | \
10378 awk '{print $2}' | sed -e 's/_UUID$//')
10381 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
10382 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
10383 osc.$mdtosc_proc1.prealloc_last_id)
10384 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
10385 osc.$mdtosc_proc1.prealloc_next_id)
10389 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
10390 #define OBD_FAIL_OST_ENOINO 0x229
10391 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
10392 do_facet mgs $LCTL pool_new $FSNAME.$TESTNAME || return 1
10393 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
10395 $SETSTRIPE $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
10397 MDSOBJS=$((last_id - next_id))
10398 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
10400 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
10401 echo "OST still has $count kbytes free"
10403 echo "create $MDSOBJS files @next_id..."
10404 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
10406 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
10407 osc.$mdtosc_proc1.prealloc_last_id)
10408 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
10409 osc.$mdtosc_proc1.prealloc_next_id)
10411 echo "after creation, last_id=$last_id2, next_id=$next_id2"
10416 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
10417 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
10419 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST || return 4
10420 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME || return 5
10421 echo "unlink $MDSOBJS files @$next_id..."
10422 unlinkmany $DIR/$tdir/f $MDSOBJS || return 6
10424 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
10427 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10428 dd if=`which date` of=$MOUNT/date oflag=sync
10429 chmod +x $MOUNT/date
10431 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
10432 $LCTL set_param fail_loc=0x80001401
10434 $MOUNT/date > /dev/null
10437 run_test 221 "make sure fault and truncate race to not cause OOM"
10440 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10442 test_mkdir -p $DIR/$tdir
10443 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
10444 createmany -o $DIR/$tdir/$tfile 10
10445 cancel_lru_locks mdc
10446 cancel_lru_locks osc
10447 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
10448 $LCTL set_param fail_loc=0x31a
10449 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
10450 $LCTL set_param fail_loc=0
10453 run_test 222a "AGL for ls should not trigger CLIO lock failure ================"
10456 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10458 test_mkdir -p $DIR/$tdir
10459 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
10460 createmany -o $DIR/$tdir/$tfile 10
10461 cancel_lru_locks mdc
10462 cancel_lru_locks osc
10463 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
10464 $LCTL set_param fail_loc=0x31a
10465 rm -r $DIR/$tdir || "AGL for rmdir failed"
10466 $LCTL set_param fail_loc=0
10468 run_test 222b "AGL for rmdir should not trigger CLIO lock failure ============="
10471 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10473 test_mkdir -p $DIR/$tdir
10474 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
10475 createmany -o $DIR/$tdir/$tfile 10
10476 cancel_lru_locks mdc
10477 cancel_lru_locks osc
10478 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
10479 $LCTL set_param fail_loc=0x31b
10480 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
10481 $LCTL set_param fail_loc=0
10484 run_test 223 "osc reenqueue if without AGL lock granted ======================="
10486 test_224a() { # LU-1039, MRP-303
10487 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10488 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
10489 $LCTL set_param fail_loc=0x508
10490 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
10491 $LCTL set_param fail_loc=0
10494 run_test 224a "Don't panic on bulk IO failure"
10496 test_224b() { # LU-1039, MRP-303
10497 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10498 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
10499 cancel_lru_locks osc
10500 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
10501 $LCTL set_param fail_loc=0x515
10502 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
10503 $LCTL set_param fail_loc=0
10506 run_test 224b "Don't panic on bulk IO failure"
10508 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
10510 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10511 if [ -z ${MDSSURVEY} ]; then
10512 skip_env "mds-survey not found" && return
10514 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
10515 { skip "Need MDS version at least 2.2.51"; return; }
10517 local mds=$(facet_host $SINGLEMDS)
10518 local target=$(do_nodes $mds 'lctl dl' | \
10519 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
10521 local cmd1="file_count=1000 thrhi=4"
10522 local cmd2="dir_count=2 layer=mdd stripe_count=0"
10523 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
10524 local cmd="$cmd1 $cmd2 $cmd3"
10526 rm -f ${TMP}/mds_survey*
10528 eval $cmd || error "mds-survey with zero-stripe failed"
10529 cat ${TMP}/mds_survey*
10530 rm -f ${TMP}/mds_survey*
10532 run_test 225a "Metadata survey sanity with zero-stripe"
10535 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10536 if [ -z ${MDSSURVEY} ]; then
10537 skip_env "mds-survey not found" && return
10539 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
10540 { skip "Need MDS version at least 2.2.51"; return; }
10542 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
10543 skip_env "Need to mount OST to test" && return
10546 local mds=$(facet_host $SINGLEMDS)
10547 local target=$(do_nodes $mds 'lctl dl' | \
10548 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
10550 local cmd1="file_count=1000 thrhi=4"
10551 local cmd2="dir_count=2 layer=mdd stripe_count=1"
10552 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
10553 local cmd="$cmd1 $cmd2 $cmd3"
10555 rm -f ${TMP}/mds_survey*
10557 eval $cmd || error "mds-survey with stripe_count failed"
10558 cat ${TMP}/mds_survey*
10559 rm -f ${TMP}/mds_survey*
10561 run_test 225b "Metadata survey sanity with stripe_count = 1"
10563 mcreate_path2fid () {
10569 local path=$DIR/$tdir/$name
10574 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
10575 error "cannot create $desc"
10577 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
10579 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
10581 fid_path=$($LFS fid2path $MOUNT $fid)
10583 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
10585 [ "$path" == "$fid_path" ] ||
10586 error "fid2path returned $fid_path, expected $path"
10588 echo "pass with $path and $fid"
10593 mkdir -p $DIR/$tdir
10595 mcreate_path2fid 0010666 0 0 fifo "FIFO"
10596 mcreate_path2fid 0020666 1 3 null "character special file (null)"
10597 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
10598 mcreate_path2fid 0040666 0 0 dir "directory"
10599 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
10600 mcreate_path2fid 0100666 0 0 file "regular file"
10601 mcreate_path2fid 0120666 0 0 link "symbolic link"
10602 mcreate_path2fid 0140666 0 0 sock "socket"
10604 run_test 226 "call path2fid and fid2path on files of all type"
10606 # LU-1299 Executing or running ldd on a truncated executable does not
10607 # cause an out-of-memory condition.
10609 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10610 dd if=`which date` of=$MOUNT/date bs=1k count=1
10611 chmod +x $MOUNT/date
10613 $MOUNT/date > /dev/null
10614 ldd $MOUNT/date > /dev/null
10617 run_test 227 "running truncated executable does not cause OOM"
10619 # LU-1512 try to reuse idle OI blocks
10621 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10622 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
10623 skip "non-ldiskfs backend" && return
10625 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
10626 local myDIR=$DIR/$tdir
10629 #define OBD_FAIL_SEQ_EXHAUST 0x1002
10630 $LCTL set_param fail_loc=0x80001002
10631 createmany -o $myDIR/t- 10000
10632 $LCTL set_param fail_loc=0
10633 # The guard is current the largest FID holder
10635 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
10637 local IDX=$(($SEQ % 64))
10639 do_facet $SINGLEMDS sync
10640 # Make sure journal flushed.
10642 local blk1=$(do_facet $SINGLEMDS \
10643 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
10644 grep Blockcount | awk '{print $4}')
10646 # Remove old files, some OI blocks will become idle.
10647 unlinkmany $myDIR/t- 10000
10648 # Create new files, idle OI blocks should be reused.
10649 createmany -o $myDIR/t- 2000
10650 do_facet $SINGLEMDS sync
10651 # Make sure journal flushed.
10653 local blk2=$(do_facet $SINGLEMDS \
10654 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
10655 grep Blockcount | awk '{print $4}')
10657 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
10659 run_test 228a "try to reuse idle OI blocks"
10662 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10663 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
10664 skip "non-ldiskfs backend" && return
10666 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
10667 local myDIR=$DIR/$tdir
10670 #define OBD_FAIL_SEQ_EXHAUST 0x1002
10671 $LCTL set_param fail_loc=0x80001002
10672 createmany -o $myDIR/t- 10000
10673 $LCTL set_param fail_loc=0
10674 # The guard is current the largest FID holder
10676 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
10678 local IDX=$(($SEQ % 64))
10680 do_facet $SINGLEMDS sync
10681 # Make sure journal flushed.
10683 local blk1=$(do_facet $SINGLEMDS \
10684 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
10685 grep Blockcount | awk '{print $4}')
10687 # Remove old files, some OI blocks will become idle.
10688 unlinkmany $myDIR/t- 10000
10691 stop $SINGLEMDS || error "Fail to stop MDT."
10693 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
10695 df $MOUNT || error "Fail to df."
10696 # Create new files, idle OI blocks should be reused.
10697 createmany -o $myDIR/t- 2000
10698 do_facet $SINGLEMDS sync
10699 # Make sure journal flushed.
10701 local blk2=$(do_facet $SINGLEMDS \
10702 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
10703 grep Blockcount | awk '{print $4}')
10705 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
10707 run_test 228b "idle OI blocks can be reused after MDT restart"
10711 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10712 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
10713 skip "non-ldiskfs backend" && return
10715 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
10716 local myDIR=$DIR/$tdir
10719 #define OBD_FAIL_SEQ_EXHAUST 0x1002
10720 $LCTL set_param fail_loc=0x80001002
10721 # 20000 files can guarantee there are index nodes in the OI file
10722 createmany -o $myDIR/t- 20000
10723 $LCTL set_param fail_loc=0
10724 # The guard is current the largest FID holder
10726 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
10728 local IDX=$(($SEQ % 64))
10730 do_facet $SINGLEMDS sync
10731 # Make sure journal flushed.
10733 local blk1=$(do_facet $SINGLEMDS \
10734 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
10735 grep Blockcount | awk '{print $4}')
10737 # Remove old files, some OI blocks will become idle.
10738 unlinkmany $myDIR/t- 20000
10740 # The OI file should become empty now
10742 # Create new files, idle OI blocks should be reused.
10743 createmany -o $myDIR/t- 2000
10744 do_facet $SINGLEMDS sync
10745 # Make sure journal flushed.
10747 local blk2=$(do_facet $SINGLEMDS \
10748 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
10749 grep Blockcount | awk '{print $4}')
10751 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
10753 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
10756 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10757 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
10760 mkdir -p $DIR/$tdir/test_230_local
10761 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230_local)
10762 [ $mdt_idx -ne 0 ] &&
10763 error "create local directory on wrong MDT $mdt_idx"
10765 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
10766 error "create remote directory failed"
10767 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230)
10768 [ $mdt_idx -ne $MDTIDX ] &&
10769 error "create remote directory on wrong MDT $mdt_idx"
10771 createmany -o $DIR/$tdir/test_230/t- 10 ||
10772 error "create files on remote directory failed"
10773 mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230/t-0)
10774 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
10775 rm -r $DIR/$tdir || error "unlink remote directory failed"
10777 run_test 230a "Create remote directory and files under the remote directory"
10780 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10781 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
10783 local remote_dir=$DIR/$tdir/remote_dir
10786 mkdir -p $DIR/$tdir
10787 $LFS mkdir -i $MDTIDX $remote_dir ||
10788 error "create remote directory failed"
10790 $LFS mkdir -i 0 $remote_dir/new_dir &&
10791 error "nested remote directory create succeed!"
10793 do_facet mds$((MDTIDX + 1)) lctl set_param mdt.*.enable_remote_dir=1
10794 $LFS mkdir -i 0 $remote_dir/new_dir || rc=$?
10795 do_facet mds$((MDTIDX + 1)) lctl set_param mdt.*.enable_remote_dir=0
10798 error "create remote directory failed after set enable_remote_dir"
10800 rm -rf $remote_dir || error "first unlink remote directory failed"
10802 $RUNAS -G$RUNAS_GID $LFS mkdir -i $MDTIDX $DIR/$tfile &&
10803 error "chown worked"
10805 do_facet mds$MDTIDX lctl set_param \
10806 mdt.*.enable_remote_dir_gid=$RUNAS_GID
10807 $LFS mkdir -i $MDTIDX $remote_dir || rc=$?
10808 do_facet mds$MDTIDX lctl set_param mdt.*.enable_remote_dir_gid=0
10811 error "create remote dir failed after set enable_remote_dir_gid"
10813 rm -r $DIR/$tdir || error "second unlink remote directory failed"
10815 run_test 230b "nested remote directory should be failed"
10819 # For simplicity this test assumes that max_pages_per_rpc
10820 # is the same across all OSCs
10821 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -1)
10822 local bulk_size=$((max_pages * 4096))
10824 mkdir -p $DIR/$tdir
10826 # clear the OSC stats
10827 $LCTL set_param osc.*.stats=0 &>/dev/null
10829 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
10830 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
10831 oflag=direct &>/dev/null || error "dd failed"
10833 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
10834 if [ x$nrpcs != "x1" ]; then
10835 error "found $nrpc ost_write RPCs, not 1 as expected"
10838 # Drop the OSC cache, otherwise we will read from it
10839 cancel_lru_locks osc
10841 # clear the OSC stats
10842 $LCTL set_param osc.*.stats=0 &>/dev/null
10844 # Client reads $bulk_size.
10845 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
10846 iflag=direct &>/dev/null || error "dd failed"
10848 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
10849 if [ x$nrpcs != "x1" ]; then
10850 error "found $nrpc ost_read RPCs, not 1 as expected"
10853 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
10856 mkdir -p $DIR/$tdir
10858 for i in {0..1023}; do
10859 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
10860 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
10861 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
10865 run_test 231b "must not assert on fully utilized OST request buffer"
10868 # tests that do cleanup/setup should be run at the end
10872 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10874 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
10875 $LCTL set_param fail_loc=0x903
10876 # cancel_lru_locks mgc - does not work due to lctl set_param syntax
10877 for ls in /proc/fs/lustre/ldlm/namespaces/MGC*/lru_size; do
10880 FAIL_ON_ERROR=true cleanup
10881 FAIL_ON_ERROR=true setup
10883 run_test 900 "umount should not race with any mgc requeue thread"
10886 check_and_cleanup_lustre
10887 if [ "$I_MOUNTED" != "yes" ]; then
10888 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true