2 # -*- tab-width: 4; indent-tabs-mode: t; -*-
4 # Run select tests by setting ONLY, or as arguments to the script.
5 # Skip specific tests by setting EXCEPT.
7 # e.g. ONLY="22 23" or ONLY="`seq 32 39`" or EXCEPT="31"
11 # bug number for skipped test: 13297 2108 9789 3637 9789 3561 12622 5188
12 ALWAYS_EXCEPT=" 42a 42b 42c 42d 45 51d 68b $SANITY_EXCEPT"
13 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
15 # with LOD/OSP landing
16 # bug number for skipped tests: LU-2036
17 ALWAYS_EXCEPT=" 76 $ALWAYS_EXCEPT"
20 SRCDIR=$(cd $(dirname $0); echo $PWD)
21 export PATH=$PATH:/sbin
25 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
26 CREATETEST=${CREATETEST:-createtest}
28 LFIND=${LFIND:-"$LFS find"}
29 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
31 MCREATE=${MCREATE:-mcreate}
32 OPENFILE=${OPENFILE:-openfile}
33 OPENUNLINK=${OPENUNLINK:-openunlink}
34 export MULTIOP=${MULTIOP:-multiop}
35 READS=${READS:-"reads"}
36 MUNLINK=${MUNLINK:-munlink}
37 SOCKETSERVER=${SOCKETSERVER:-socketserver}
38 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
39 MEMHOG=${MEMHOG:-memhog}
40 DIRECTIO=${DIRECTIO:-directio}
41 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
42 UMOUNT=${UMOUNT:-"umount -d"}
44 CHECK_GRANT=${CHECK_GRANT:-"yes"}
45 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
46 export PARALLEL=${PARALLEL:-"no"}
48 export NAME=${NAME:-local}
55 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
56 . $LUSTRE/tests/test-framework.sh
58 . ${CONFIG:=$LUSTRE/tests/cfg/${NAME}.sh}
61 [ "$SLOW" = "no" ] && EXCEPT_SLOW="24o 27m 64b 68 71 77f 78 115 124b"
63 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
64 # bug number for skipped test: LU-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"
474 # Fix for inode size boundary in 2.1.4
475 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.4) ] &&
478 # Patch not applied to 2.2 or 2.3 branches
479 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
480 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.3.55) ] &&
484 local SYMNAME=$(str_repeat 'x' $i)
485 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
486 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
489 run_test 17g "symlinks: really long symlink name and inode boundaries"
491 test_17h() { #bug 17378
492 remote_mds_nodsh && skip "remote MDS with nodsh" && return
493 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
495 test_mkdir -p $DIR/$tdir
496 if [ $MDSCOUNT -gt 1 ]; then
497 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
501 $SETSTRIPE -c -1 $DIR/$tdir
502 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
503 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
504 touch $DIR/$tdir/$tfile || true
506 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
508 test_17i() { #bug 20018
509 remote_mds_nodsh && skip "remote MDS with nodsh" && return
510 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
511 test_mkdir -p $DIR/$tdir
512 local foo=$DIR/$tdir/$tfile
514 if [ $MDSCOUNT -gt 1 ]; then
515 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
519 ln -s $foo $foo || error "create symlink failed"
520 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
521 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
522 ls -l $foo && error "error not detected"
525 run_test 17i "don't panic on short symlink"
527 test_17k() { #bug 22301
528 rsync --help | grep -q xattr ||
529 skip_env "$(rsync --version| head -1) does not support xattrs"
530 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
531 test_mkdir -p $DIR/$tdir
532 test_mkdir -p $DIR/$tdir.new
533 touch $DIR/$tdir/$tfile
534 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
535 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
536 error "rsync failed with xattrs enabled"
538 run_test 17k "symlinks: rsync with xattrs enabled ========================="
540 test_17l() { # LU-279
542 touch $DIR/$tdir/$tfile
543 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
544 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
545 # -h to not follow symlinks. -m '' to list all the xattrs.
546 # grep to remove first line: '# file: $path'.
547 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
549 lgetxattr_size_check $path $xattr ||
550 error "lgetxattr_size_check $path $xattr failed"
554 run_test 17l "Ensure lgetxattr's returned xattr size is consistent ========"
558 local short_sym="0123456789"
559 local WDIR=$DIR/${tdir}m
566 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
567 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
568 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
570 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
571 skip "only for ldiskfs MDT" && return 0
573 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
577 # create a long symlink file
578 for ((i = 0; i < 4; ++i)); do
579 long_sym=${long_sym}${long_sym}
582 echo "create 512 short and long symlink files under $WDIR"
583 for ((i = 0; i < 256; ++i)); do
584 ln -sf ${long_sym}"a5a5" $WDIR/long-$i
585 ln -sf ${short_sym}"a5a5" $WDIR/short-$i
591 wait_delete_completed
593 echo "recreate the 512 symlink files with a shorter string"
594 for ((i = 0; i < 512; ++i)); do
595 # rewrite the symlink file with a shorter string
596 ln -sf ${long_sym} $WDIR/long-$i
597 ln -sf ${short_sym} $WDIR/short-$i
600 mds_index=$($LFS getstripe -M $WDIR)
601 mds_index=$((mds_index+1))
602 devname=$(mdsdevname $mds_index)
603 cmd="$E2FSCK -fnvd $devname"
605 echo "stop and checking mds${mds_index}: $cmd"
606 # e2fsck should not return error
607 stop mds${mds_index} -f
608 do_facet mds${mds_index} $cmd || rc=$?
610 start mds${mds_index} $devname $MDS_MOUNT_OPTS
611 df $MOUNT > /dev/null 2>&1
612 [ $rc -ne 0 ] && error "e2fsck should not report error upon "\
613 "short/long symlink MDT: rc=$rc"
616 run_test 17m "run e2fsck against MDT which contains short/long symlink"
618 check_fs_consistency_17n() {
624 for mdt_index in $(seq 1 $MDSCOUNT); do
625 devname=$(mdsdevname $mdt_index)
626 cmd="$E2FSCK -fnvd $devname"
628 echo "stop and checking mds${mdt_index}: $cmd"
629 # e2fsck should not return error
631 do_facet mds${mdt_index} $cmd || rc=$?
633 start mds${mdt_index} $devname $MDS_MOUNT_OPTS
634 df $MOUNT > /dev/null 2>&1
635 [ $rc -ne 0 ] && break
643 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
644 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
645 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
647 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
648 skip "only for ldiskfs MDT" && return 0
650 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
652 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
655 for ((i=0; i<10; i++)); do
656 $LFS mkdir -i 1 $DIR/$tdir/remote_dir_${i} ||
657 error "create remote dir error $i"
658 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
659 error "create files under remote dir failed $i"
662 check_fs_consistency_17n || error "e2fsck report error"
664 for ((i=0;i<10;i++)); do
665 rm -rf $DIR/$tdir/remote_dir_${i} ||
666 error "destroy remote dir error $i"
669 check_fs_consistency_17n || error "e2fsck report error"
671 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
677 run_test 18 "touch .../f ; ls ... =============================="
683 $CHECKSTAT -a $DIR/f19 || error
685 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
688 ls -l $DIR/f19 && error || true
690 run_test 19b "ls -l .../f19 (should return error) =============="
693 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
694 $RUNAS touch $DIR/f19 && error || true
696 run_test 19c "$RUNAS touch .../f19 (should return error) =="
699 cat $DIR/f19 && error || true
701 run_test 19d "cat .../f19 (should return error) =============="
713 $CHECKSTAT -a $DIR/f || error
715 run_test 20 "touch .../f ; ls -l ... ==========================="
719 [ -f $DIR/d21/dangle ] && rm -f $DIR/d21/dangle
720 ln -s dangle $DIR/d21/link
721 echo foo >> $DIR/d21/link
723 $CHECKSTAT -t link $DIR/d21/link || error
724 $CHECKSTAT -f -t file $DIR/d21/link || error
726 run_test 21 "write to dangling link ============================"
730 test_mkdir -p $DIR/$tdir
731 chown $RUNAS_ID:$RUNAS_GID $WDIR
732 (cd $WDIR || error "cd $WDIR failed";
733 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
735 ls -lR $WDIR/etc || error "ls -lR $WDIR/etc failed"
736 $CHECKSTAT -t dir $WDIR/etc || error "checkstat -t dir failed"
737 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $WDIR/etc || error "checkstat -u failed"
739 run_test 22 "unpack tar archive as non-root user ==============="
743 test_mkdir -p $DIR/$tdir
744 local file=$DIR/$tdir/$tfile
746 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
747 openfile -f O_CREAT:O_EXCL $file &&
748 error "$file recreate succeeded" || true
750 run_test 23a "O_CREAT|O_EXCL in subdir =========================="
752 test_23b() { # bug 18988
753 test_mkdir -p $DIR/$tdir
754 local file=$DIR/$tdir/$tfile
757 echo foo > $file || error "write filed"
758 echo bar >> $file || error "append filed"
759 $CHECKSTAT -s 8 $file || error "wrong size"
762 run_test 23b "O_APPEND check =========================="
765 echo '== rename sanity =============================================='
766 echo '-- same directory rename'
769 mv $DIR/R1/f $DIR/R1/g
770 $CHECKSTAT -t file $DIR/R1/g || error
772 run_test 24a "touch .../R1/f; rename .../R1/f .../R1/g ========="
777 mv $DIR/R2/f $DIR/R2/g
778 $CHECKSTAT -a $DIR/R2/f || error
779 $CHECKSTAT -t file $DIR/R2/g || error
781 run_test 24b "touch .../R2/{f,g}; rename .../R2/f .../R2/g ====="
786 mv $DIR/R3/f $DIR/R3/g
787 $CHECKSTAT -a $DIR/R3/f || error
788 $CHECKSTAT -t dir $DIR/R3/g || error
790 run_test 24c "mkdir .../R3/f; rename .../R3/f .../R3/g ========="
796 mrename $DIR/R4/f $DIR/R4/g
797 $CHECKSTAT -a $DIR/R4/f || error
798 $CHECKSTAT -t dir $DIR/R4/g || error
800 run_test 24d "mkdir .../R4/{f,g}; rename .../R4/f .../R4/g ====="
803 echo '-- cross directory renames --'
807 mv $DIR/R5a/f $DIR/R5b/g
808 $CHECKSTAT -a $DIR/R5a/f || error
809 $CHECKSTAT -t file $DIR/R5b/g || error
811 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
816 touch $DIR/R6a/f $DIR/R6b/g
817 mv $DIR/R6a/f $DIR/R6b/g
818 $CHECKSTAT -a $DIR/R6a/f || error
819 $CHECKSTAT -t file $DIR/R6b/g || error
821 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
826 test_mkdir $DIR/R7a/d
827 mv $DIR/R7a/d $DIR/R7b/e
828 $CHECKSTAT -a $DIR/R7a/d || error
829 $CHECKSTAT -t dir $DIR/R7b/e || error
831 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
836 test_mkdir $DIR/R8a/d
837 test_mkdir $DIR/R8b/e
838 mrename $DIR/R8a/d $DIR/R8b/e
839 $CHECKSTAT -a $DIR/R8a/d || error
840 $CHECKSTAT -t dir $DIR/R8b/e || error
842 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
845 echo "-- rename error cases"
849 mrename $DIR/R9/f $DIR/R9/a
850 $CHECKSTAT -t file $DIR/R9/f || error
851 $CHECKSTAT -t dir $DIR/R9/a || error
852 $CHECKSTAT -a $DIR/R9/a/f || error
854 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
858 mrename $DIR/R10/f $DIR/R10/g
859 $CHECKSTAT -t dir $DIR/R10 || error
860 $CHECKSTAT -a $DIR/R10/f || error
861 $CHECKSTAT -a $DIR/R10/g || error
863 run_test 24j "source does not exist ============================"
867 test_mkdir $DIR/R11a/d
869 mv $DIR/R11a/f $DIR/R11a/d
870 $CHECKSTAT -a $DIR/R11a/f || error
871 $CHECKSTAT -t file $DIR/R11a/d/f || error
873 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
875 # bug 2429 - rename foo foo foo creates invalid file
878 $MULTIOP $f OcNs || error
880 run_test 24l "Renaming a file to itself ========================"
884 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
885 # on ext3 this does not remove either the source or target files
886 # though the "expected" operation would be to remove the source
887 $CHECKSTAT -t file ${f} || error "${f} missing"
888 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
890 run_test 24m "Renaming a file to a hard link to itself ========="
894 # this stats the old file after it was renamed, so it should fail
898 $CHECKSTAT ${f}.rename
901 run_test 24n "Statting the old file after renaming (Posix rename 2)"
904 check_kernel_version 37 || return 0
905 test_mkdir -p $DIR/d24o
906 rename_many -s random -v -n 10 $DIR/d24o
908 run_test 24o "rename of files during htree split ==============="
913 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
914 mrename $DIR/R12a $DIR/R12b
915 $CHECKSTAT -a $DIR/R12a || error
916 $CHECKSTAT -t dir $DIR/R12b || error
917 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
918 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
920 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
922 cleanup_multiop_pause() {
928 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
931 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
932 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
935 trap cleanup_multiop_pause EXIT
936 mrename $DIR/R13a $DIR/R13b
937 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
938 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
939 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
940 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
941 cleanup_multiop_pause
942 wait $MULTIPID || error "multiop close failed"
944 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
946 test_24r() { #bug 3789
948 test_mkdir $DIR/R14a/b
949 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
950 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
951 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
953 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
957 test_mkdir $DIR/R15a/b
958 test_mkdir $DIR/R15a/b/c
959 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
960 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
961 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
963 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
966 test_mkdir $DIR/R16a/b
967 test_mkdir $DIR/R16a/b/c
968 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
969 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
970 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
972 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
974 test_24u() { # bug12192
976 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error
977 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
979 run_test 24u "create stripe file"
985 simple_cleanup_common() {
988 wait_delete_completed
991 max_pages_per_rpc() {
992 $LCTL get_param -n mdc.*.max_pages_per_rpc | head -1
997 local FREE_INODES=$(lfs_df -i | grep "summary" | awk '{print $4}')
998 [ $FREE_INODES -lt $NRFILES ] && \
999 skip "not enough free inodes $FREE_INODES required $NRFILES" &&
1002 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1003 trap simple_cleanup_common EXIT
1006 createmany -m $DIR/$tdir/$tfile $NRFILES
1008 cancel_lru_locks mdc
1009 lctl set_param mdc.*.stats clear
1011 ls $DIR/$tdir >/dev/null || error "error in listing large dir"
1013 # LU-5 large readdir
1014 # DIRENT_SIZE = 32 bytes for sizeof(struct lu_dirent) +
1015 # 8 bytes for name(filename is mostly 5 in this test) +
1016 # 8 bytes for luda_type
1017 # take into account of overhead in lu_dirpage header and end mark in
1018 # each page, plus one in RPC_NUM calculation.
1020 RPC_SIZE=$(($(max_pages_per_rpc) * $(page_size)))
1021 RPC_NUM=$(((NRFILES * DIRENT_SIZE + RPC_SIZE - 1) / RPC_SIZE + 1))
1022 mds_readpage=$(lctl get_param mdc.*MDT0000*.stats | \
1023 awk '/^mds_readpage/ {print $2}')
1024 [ $mds_readpage -gt $RPC_NUM ] && \
1025 error "large readdir doesn't take effect"
1027 simple_cleanup_common
1029 run_test 24v "list directory with large files (handle hash collision, bug: 17560)"
1031 test_24w() { # bug21506
1033 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1034 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1035 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1036 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1037 [ "$SZ1" = "$SZ2" ] || \
1038 error "Error reading at the end of the file $tfile"
1040 run_test 24w "Reading a file larger than 4Gb"
1043 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1044 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1046 local remote_dir=$DIR/$tdir/remote_dir
1049 $LFS mkdir -i $MDTIDX $remote_dir ||
1050 error "create remote directory failed"
1052 mkdir -p $DIR/$tdir/src_dir
1053 touch $DIR/$tdir/src_file
1054 mkdir -p $remote_dir/tgt_dir
1055 touch $remote_dir/tgt_file
1057 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir &&
1058 error "rename dir cross MDT works!"
1060 mrename $DIR/$tdir/src_file $remote_dir/tgt_file &&
1061 error "rename file cross MDT works!"
1063 ln $DIR/$tdir/src_file $remote_dir/tgt_file1 &&
1064 error "ln file cross MDT should not work!"
1066 rm -rf $DIR/$tdir || error "Can not delete directories"
1068 run_test 24x "cross rename/link should be failed"
1071 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1072 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1074 local remote_dir=$DIR/$tdir/remote_dir
1077 $LFS mkdir -i $MDTIDX $remote_dir ||
1078 error "create remote directory failed"
1080 mkdir -p $remote_dir/src_dir
1081 touch $remote_dir/src_file
1082 mkdir -p $remote_dir/tgt_dir
1083 touch $remote_dir/tgt_file
1085 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1086 error "rename subdir in the same remote dir failed!"
1088 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1089 error "rename files in the same remote dir failed!"
1091 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1092 error "link files in the same remote dir failed!"
1094 rm -rf $DIR/$tdir || error "Can not delete directories"
1096 run_test 24y "rename/link on the same dir should succeed"
1099 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1100 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1102 local remote_src=$DIR/$tdir/remote_dir
1103 local remote_tgt=$DIR/$tdir/remote_tgt
1106 $LFS mkdir -i $MDTIDX $remote_src ||
1107 error "create remote directory failed"
1109 $LFS mkdir -i $MDTIDX $remote_tgt ||
1110 error "create remote directory failed"
1112 mrename $remote_src $remote_tgt &&
1113 error "rename remote dirs should not work!"
1115 rm -rf $DIR/$tdir || error "Can not delete directories"
1117 run_test 24z "rename one remote dir to another remote dir should fail"
1120 echo '== symlink sanity ============================================='
1124 touch $DIR/s25/foo || error
1126 run_test 25a "create file in symlinked directory ==============="
1129 [ ! -d $DIR/d25 ] && test_25a
1130 $CHECKSTAT -t file $DIR/s25/foo || error
1132 run_test 25b "lookup file in symlinked directory ==============="
1136 test_mkdir $DIR/d26/d26-2
1137 ln -s d26/d26-2 $DIR/s26
1138 touch $DIR/s26/foo || error
1140 run_test 26a "multiple component symlink ======================="
1143 test_mkdir -p $DIR/d26b/d26-2
1144 ln -s d26b/d26-2/foo $DIR/s26-2
1145 touch $DIR/s26-2 || error
1147 run_test 26b "multiple component symlink at end of lookup ======"
1150 test_mkdir $DIR/d26.2
1151 touch $DIR/d26.2/foo
1152 ln -s d26.2 $DIR/s26.2-1
1153 ln -s s26.2-1 $DIR/s26.2-2
1154 ln -s s26.2-2 $DIR/s26.2-3
1155 chmod 0666 $DIR/s26.2-3/foo
1157 run_test 26c "chain of symlinks ================================"
1159 # recursive symlinks (bug 439)
1161 ln -s d26-3/foo $DIR/d26-3
1163 run_test 26d "create multiple component recursive symlink ======"
1166 [ ! -h $DIR/d26-3 ] && test_26d
1169 run_test 26e "unlink multiple component recursive symlink ======"
1171 # recursive symlinks (bug 7022)
1173 test_mkdir -p $DIR/$tdir
1174 test_mkdir $DIR/$tdir/$tfile || error "mkdir $DIR/$tdir/$tfile failed"
1175 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1176 test_mkdir -p lndir bar1 || error "mkdir lndir/bar1 failed"
1177 test_mkdir $DIR/$tdir/$tfile/$tfile || error "mkdir $tfile failed"
1178 cd $tfile || error "cd $tfile failed"
1179 ln -s .. dotdot || error "ln dotdot failed"
1180 ln -s dotdot/lndir lndir || error "ln lndir failed"
1181 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1182 output=`ls $tfile/$tfile/lndir/bar1`
1183 [ "$output" = bar1 ] && error "unexpected output"
1184 rm -r $tfile || error "rm $tfile failed"
1185 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1187 run_test 26f "rm -r of a directory which has recursive symlink ="
1190 echo '== stripe sanity =============================================='
1191 test_mkdir -p $DIR/d27 || error "mkdir failed"
1193 $SETSTRIPE -c 1 $DIR/d27/f0 || error "setstripe failed"
1194 $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
1196 log "== test_27a: write to one stripe file ========================="
1197 cp /etc/hosts $DIR/d27/f0 || error
1199 run_test 27a "one stripe file =================================="
1202 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
1203 test_mkdir -p $DIR/d27
1204 $SETSTRIPE -c 2 $DIR/d27/f01 || error "setstripe failed"
1205 $GETSTRIPE -c $DIR/d27/f01
1206 [ $($GETSTRIPE -c $DIR/d27/f01) -eq 2 ] ||
1207 error "two-stripe file doesn't have two stripes"
1209 run_test 27b "create two stripe file"
1212 [ -f $DIR/d27/f01 ] || skip "test_27b not run" && return
1214 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
1216 run_test 27c "write to two stripe file"
1219 test_mkdir -p $DIR/d27
1220 $SETSTRIPE -c 0 -i -1 -S 0 $DIR/d27/fdef || error "setstripe failed"
1221 $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
1222 dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
1224 run_test 27d "create file with default settings ================"
1227 test_mkdir -p $DIR/d27
1228 $SETSTRIPE -c 2 $DIR/d27/f12 || error "setstripe failed"
1229 $SETSTRIPE -c 2 $DIR/d27/f12 && error "setstripe succeeded twice"
1230 $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
1232 run_test 27e "setstripe existing file (should return error) ======"
1235 test_mkdir -p $DIR/d27
1236 $SETSTRIPE -S 100 -i 0 -c 1 $DIR/d27/fbad && error "setstripe failed"
1237 dd if=/dev/zero of=$DIR/d27/f12 bs=4k count=4 || error "dd failed"
1238 $GETSTRIPE $DIR/d27/fbad || error "$GETSTRIPE failed"
1240 run_test 27f "setstripe with bad stripe size (should return error)"
1243 test_mkdir -p $DIR/d27
1244 $MCREATE $DIR/d27/fnone || error "mcreate failed"
1245 $GETSTRIPE $DIR/d27/fnone 2>&1 | grep "no stripe info" ||
1246 error "$DIR/d27/fnone has object"
1248 run_test 27g "$GETSTRIPE with no objects"
1251 touch $DIR/d27/fsome || error "touch failed"
1252 [ $($GETSTRIPE -c $DIR/d27/fsome) -gt 0 ] || error "missing objects"
1254 run_test 27i "$GETSTRIPE with some objects"
1257 test_mkdir -p $DIR/d27
1258 $SETSTRIPE -i $OSTCOUNT $DIR/d27/f27j && error "setstripe failed"||true
1260 run_test 27j "setstripe with bad stripe offset (should return error)"
1262 test_27k() { # bug 2844
1263 test_mkdir -p $DIR/d27
1265 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
1266 [ ! -d $DIR/d27 ] && test_mkdir -p $DIR d27
1267 $SETSTRIPE -S 67108864 $FILE || error "setstripe failed"
1268 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1269 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
1270 dd if=/dev/zero of=$FILE bs=4k count=1
1271 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1272 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
1274 run_test 27k "limit i_blksize for broken user apps ============="
1277 test_mkdir -p $DIR/d27
1278 mcreate $DIR/f27l || error "creating file"
1279 $RUNAS $SETSTRIPE -c 1 $DIR/f27l && \
1280 error "setstripe should have failed" || true
1282 run_test 27l "check setstripe permissions (should return error)"
1285 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" &&
1287 if [ $ORIGFREE -gt $MAXFREE ]; then
1288 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1291 trap simple_cleanup_common EXIT
1292 test_mkdir -p $DIR/$tdir
1293 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_1
1294 dd if=/dev/zero of=$DIR/$tdir/f27m_1 bs=1024 count=$MAXFREE &&
1295 error "dd should fill OST0"
1297 while $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_$i; do
1299 [ $i -gt 256 ] && break
1302 touch $DIR/$tdir/f27m_$i
1303 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1304 error "OST0 was full but new created file still use it"
1306 touch $DIR/$tdir/f27m_$i
1307 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1308 error "OST0 was full but new created file still use it"
1309 simple_cleanup_common
1311 run_test 27m "create file while OST0 was full =================="
1314 local DELAY=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage | head -n 1 | awk '{print $1 * 2}')
1318 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1319 # if the OST isn't full anymore.
1321 local OSTIDX=${1:-""}
1323 local list=$(comma_list $(osts_nodes))
1324 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1326 do_nodes $list lctl set_param fail_loc=0
1327 sync # initiate all OST_DESTROYs from MDS to OST
1331 exhaust_precreations() {
1334 local FAILIDX=${3:-$OSTIDX}
1336 test_mkdir -p $DIR/$tdir
1337 local MDSIDX=$(get_mds_dir "$DIR/$tdir")
1338 echo OSTIDX=$OSTIDX MDSIDX=$MDSIDX
1340 local OST=$(ostname_from_index $OSTIDX)
1341 local MDT_INDEX=$(lfs df | grep "\[MDT:$((MDSIDX - 1))\]" | awk '{print $1}' | \
1342 sed -e 's/_UUID$//;s/^.*-//')
1345 local mdtosc_proc1=$(get_mdtosc_proc_path mds${MDSIDX} $OST)
1346 local last_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1347 osc.$mdtosc_proc1.prealloc_last_id)
1348 local next_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1349 osc.$mdtosc_proc1.prealloc_next_id)
1351 local mdtosc_proc2=$(get_mdtosc_proc_path mds${MDSIDX})
1352 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1354 test_mkdir -p $DIR/$tdir/${OST}
1355 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1356 #define OBD_FAIL_OST_ENOSPC 0x215
1357 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=$FAILIDX
1358 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x215
1359 echo "Creating to objid $last_id on ost $OST..."
1360 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1361 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1362 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=$FAILLOC
1366 exhaust_all_precreations() {
1368 for (( i=0; i < OSTCOUNT; i++ )) ; do
1369 exhaust_precreations $i $1 -1
1374 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1375 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1376 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1377 remote_ost_nodsh && skip "remote OST with nodsh" && return
1380 rm -f $DIR/$tdir/$tfile
1381 exhaust_precreations 0 0x80000215
1382 $SETSTRIPE -c -1 $DIR/$tdir
1383 touch $DIR/$tdir/$tfile || error
1384 $GETSTRIPE $DIR/$tdir/$tfile
1387 run_test 27n "create file with some full OSTs =================="
1390 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1391 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1392 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1393 remote_ost_nodsh && skip "remote OST with nodsh" && return
1396 rm -f $DIR/$tdir/$tfile
1397 exhaust_all_precreations 0x215
1399 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1404 run_test 27o "create file with all full OSTs (should error) ===="
1407 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1408 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1409 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1410 remote_ost_nodsh && skip "remote OST with nodsh" && return
1413 rm -f $DIR/$tdir/$tfile
1414 test_mkdir -p $DIR/$tdir
1416 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1417 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1418 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1420 exhaust_precreations 0 0x80000215
1421 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1422 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1423 $GETSTRIPE $DIR/$tdir/$tfile
1427 run_test 27p "append to a truncated file with some full OSTs ==="
1430 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1431 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1432 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1433 remote_ost_nodsh && skip "remote OST with nodsh" && return
1436 rm -f $DIR/$tdir/$tfile
1438 test_mkdir -p $DIR/$tdir
1439 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1440 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||error "truncate $DIR/$tdir/$tfile failed"
1441 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1443 exhaust_all_precreations 0x215
1445 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1446 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1450 run_test 27q "append to truncated file with all OSTs full (should error) ==="
1453 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1454 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1455 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1456 remote_ost_nodsh && skip "remote OST with nodsh" && return
1459 rm -f $DIR/$tdir/$tfile
1460 exhaust_precreations 0 0x80000215
1462 $SETSTRIPE -i 0 -c 2 $DIR/$tdir/$tfile # && error
1466 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1468 test_27s() { # bug 10725
1469 test_mkdir -p $DIR/$tdir
1470 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1471 local stripe_count=0
1472 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1473 $SETSTRIPE -S $stripe_size -c $stripe_count $DIR/$tdir &&
1474 error "stripe width >= 2^32 succeeded" || true
1477 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1479 test_27t() { # bug 10864
1484 $WLFS getstripe $tfile
1487 run_test 27t "check that utils parse path correctly"
1489 test_27u() { # bug 4900
1490 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1491 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1493 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1494 do_facet $SINGLEMDS lctl set_param fail_loc=0x139
1495 test_mkdir -p $DIR/$tdir
1497 createmany -o $DIR/$tdir/t- 1000
1498 do_facet $SINGLEMDS lctl set_param fail_loc=0
1500 TLOG=$DIR/$tfile.getstripe
1501 $GETSTRIPE $DIR/$tdir > $TLOG
1502 OBJS=`awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj;}' $TLOG`
1503 unlinkmany $DIR/$tdir/t- 1000
1504 [ $OBJS -gt 0 ] && \
1505 error "$OBJS objects created on OST-0. See $TLOG" || pass
1507 run_test 27u "skip object creation on OSC w/o objects =========="
1509 test_27v() { # bug 4900
1510 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1511 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1512 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1513 remote_ost_nodsh && skip "remote OST with nodsh" && return
1515 exhaust_all_precreations 0x215
1518 test_mkdir -p $DIR/$tdir
1519 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1521 touch $DIR/$tdir/$tfile
1522 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1524 for (( i=1; i < OSTCOUNT; i++ )); do
1525 do_facet ost$i lctl set_param fail_loc=0x705
1527 local START=`date +%s`
1528 createmany -o $DIR/$tdir/$tfile 32
1530 local FINISH=`date +%s`
1531 local TIMEOUT=`lctl get_param -n timeout`
1532 local PROCESS=$((FINISH - START))
1533 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1534 error "$FINISH - $START >= $TIMEOUT / 2"
1535 sleep $((TIMEOUT / 2 - PROCESS))
1538 run_test 27v "skip object creation on slow OST ================="
1540 test_27w() { # bug 10997
1541 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1542 $SETSTRIPE -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1543 [ $($GETSTRIPE -S $DIR/$tdir/f0) -ne 65536 ] &&
1544 error "stripe size $size != 65536" || true
1545 [ $($GETSTRIPE -d $DIR/$tdir | grep -c "stripe_count") -ne 1 ] &&
1546 error "$GETSTRIPE -d $DIR/$tdir failed" || true
1548 run_test 27w "check $SETSTRIPE -S option"
1551 [ "$OSTCOUNT" -lt "2" ] &&
1552 skip_env "skipping multiple stripe count/offset test" && return
1554 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1555 for i in $(seq 1 $OSTCOUNT); do
1557 $SETSTRIPE -c $i -i $offset $DIR/$tdir/f$i ||
1558 error "setstripe -c $i -i $offset failed"
1559 count=$($GETSTRIPE -c $DIR/$tdir/f$i)
1560 index=$($GETSTRIPE -i $DIR/$tdir/f$i)
1561 [ $count -ne $i ] && error "stripe count $count != $i" || true
1562 [ $index -ne $offset ] &&
1563 error "stripe offset $index != $offset" || true
1566 run_test 27wa "check $SETSTRIPE -c -i options"
1569 remote_ost_nodsh && skip "remote OST with nodsh" && return
1570 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs" && return
1571 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1572 OFFSET=$(($OSTCOUNT - 1))
1574 local OST=$(ostname_from_index $OSTIDX)
1576 test_mkdir -p $DIR/$tdir
1577 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe per file
1578 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1580 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1581 for i in `seq 0 $OFFSET`; do
1582 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}' | grep -w "$OSTIDX"` ] &&
1583 error "OST0 was degraded but new created file still use it"
1585 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1587 run_test 27x "create files while OST0 is degraded"
1590 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1591 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1592 remote_ost_nodsh && skip "remote OST with nodsh" && return
1593 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1595 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1596 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1597 osc.$mdtosc.prealloc_last_id)
1598 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1599 osc.$mdtosc.prealloc_next_id)
1600 local fcount=$((last_id - next_id))
1601 [ $fcount -eq 0 ] && skip "not enough space on OST0" && return
1602 [ $fcount -gt $OSTCOUNT ] && fcount=$OSTCOUNT
1604 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
1605 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
1606 local OST_DEACTIVE_IDX=-1
1611 for OSC in $MDS_OSCS; do
1612 OST=$(osc_to_ost $OSC)
1613 OSTIDX=$(index_from_ostuuid $OST)
1614 if [ $OST_DEACTIVE_IDX == -1 ]; then
1615 OST_DEACTIVE_IDX=$OSTIDX
1617 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
1618 echo $OSC "is Deactivated:"
1619 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1623 OSTIDX=$(index_from_ostuuid $OST)
1625 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1627 for OSC in $MDS_OSCS; do
1628 OST=$(osc_to_ost $OSC)
1629 OSTIDX=$(index_from_ostuuid $OST)
1630 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1631 echo $OST "is degraded:"
1632 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1633 obdfilter.$OST.degraded=1
1638 createmany -o $DIR/$tdir/$tfile $fcount
1640 for OSC in $MDS_OSCS; do
1641 OST=$(osc_to_ost $OSC)
1642 OSTIDX=$(index_from_ostuuid $OST)
1643 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1644 echo $OST "is recovered from degraded:"
1645 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1646 obdfilter.$OST.degraded=0
1648 do_facet $SINGLEMDS lctl --device %$OSC activate
1652 # all osp devices get activated, hence -1 stripe count restored
1655 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
1656 # devices get activated.
1658 $SETSTRIPE -c -1 $DIR/$tfile
1659 stripecnt=$($GETSTRIPE -c $DIR/$tfile)
1661 [ $stripecnt -ne $OSTCOUNT ] &&
1662 error "Of $OSTCOUNT OSTs, only $stripecnt is available"
1665 run_test 27y "create files while OST0 is degraded and the rest inactive"
1671 lmm_count=$($GETSTRIPE -c $1)
1672 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1673 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1675 local old_ifs="$IFS"
1677 fid=($($LFS path2fid $1))
1680 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1681 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1683 # compare lmm_seq and lu_fid->f_seq
1684 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1685 # compare lmm_object_id and lu_fid->oid
1686 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1688 # check the trusted.fid attribute of the OST objects of the file
1689 local have_obdidx=false
1691 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1692 # skip lines up to and including "obdidx"
1693 [ -z "$obdidx" ] && break
1694 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1695 $have_obdidx || continue
1697 local ost=$((obdidx + 1))
1698 local dev=$(ostdevname $ost)
1700 if [ $(facet_fstype ost$ost) != ldiskfs ]; then
1701 echo "Currently only works with ldiskfs-based OSTs"
1705 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1707 #don't unmount/remount the OSTs if we don't need to do that
1708 #local dir=$(facet_mntpt ost$ost)
1710 #do_facet ost$dev mount -t $FSTYPE $dev $dir $OST_MOUNT_OPTS ||
1711 # { error "mounting $dev as $FSTYPE failed"; return 3; }
1712 #local obj_file=$(do_facet ost$ost find $dir/O/$seq -name $oid)
1713 #local ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID $obj_file)
1714 seq=$(echo $seq | sed -e "s/^0x//g")
1715 if [ $seq == 0 ]; then
1716 oid_hex=$(echo $oid)
1718 oid_hex=$(echo $hex | sed -e "s/^0x//g")
1720 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
1721 local ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
1722 $dev 2>/dev/null" | grep "parent=")
1724 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
1726 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
1728 #do_facet ost$ost umount -d $dir
1729 #start ost$ost $dev $OST_MOUNT_OPTS
1731 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
1732 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
1733 local ff_parent=$(echo $ff|sed -e 's/.*parent=.//')
1734 local ff_pseq=$(echo $ff_parent | cut -d: -f1)
1735 local ff_poid=$(echo $ff_parent | cut -d: -f2)
1736 local ff_pstripe=$(echo $ff_parent | sed -e 's/.*stripe=//')
1738 # compare lmm_seq and filter_fid->ff_parent.f_seq
1739 [ $ff_pseq = $lmm_seq ] ||
1740 error "FF parent SEQ $ff_pseq != $lmm_seq"
1741 # compare lmm_object_id and filter_fid->ff_parent.f_oid
1742 [ $ff_poid = $lmm_oid ] ||
1743 error "FF parent OID $ff_poid != $lmm_oid"
1744 [ $ff_pstripe = $stripe_nr ] ||
1745 error "FF stripe $ff_pstripe != $stripe_nr"
1747 stripe_nr=$((stripe_nr + 1))
1752 remote_ost_nodsh && skip "remote OST with nodsh" && return
1753 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1754 test_mkdir -p $DIR/$tdir
1756 $SETSTRIPE -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
1757 { error "setstripe -c -1 failed"; return 1; }
1758 # We need to send a write to every object to get parent FID info set.
1759 # This _should_ also work for setattr, but does not currently.
1760 # touch $DIR/$tdir/$tfile-1 ||
1761 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
1762 { error "dd $tfile-1 failed"; return 2; }
1763 $SETSTRIPE -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
1764 { error "setstripe -c -1 failed"; return 3; }
1765 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
1766 { error "dd $tfile-2 failed"; return 4; }
1768 # make sure write RPCs have been sent to OSTs
1771 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
1772 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
1774 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
1776 test_27A() { # b=19102
1777 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1778 local restore_size=$($GETSTRIPE -S $MOUNT)
1779 local restore_count=$($GETSTRIPE -c $MOUNT)
1780 local restore_offset=$($GETSTRIPE -i $MOUNT)
1781 $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
1782 local default_size=$($GETSTRIPE -S $MOUNT)
1783 local default_count=$($GETSTRIPE -c $MOUNT)
1784 local default_offset=$($GETSTRIPE -i $MOUNT)
1785 local dsize=$((1024 * 1024))
1786 [ $default_size -eq $dsize ] ||
1787 error "stripe size $default_size != $dsize"
1788 [ $default_count -eq 1 ] || error "stripe count $default_count != 1"
1789 [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
1790 $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
1792 run_test 27A "check filesystem-wide default LOV EA values"
1794 test_27B() { # LU-2523
1795 test_mkdir -p $DIR/$tdir
1796 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
1798 # open f1 with O_LOV_DELAY_CREATE
1800 # call setstripe ioctl on open file descriptor for f1
1802 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
1806 # open f1 with O_LOV_DELAY_CREATE
1808 # call setstripe ioctl on open file descriptor for f1
1810 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
1812 # Allow multiop to fail in imitation of NFS's busted semantics.
1815 run_test 27B "call setstripe on open unlinked file/rename victim"
1817 test_27C() { #LU-2871
1818 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
1825 test_mkdir -p $DIR/$tdir
1827 for i in $(seq 0 $((OSTCOUNT - 1))); do
1828 # set stripe across all OSTs starting from OST$i
1829 $SETSTRIPE -i $i -c -1 $tfile$i
1830 # get striping information
1831 ost_idx=($($GETSTRIPE $tfile$i |
1832 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
1835 for j in $(seq 0 $((OSTCOUNT - 1))); do
1836 index=$(((i + j) % OSTCOUNT))
1837 [ ${ost_idx[$j]} -eq $index ] || error
1841 run_test 27C "check full striping across all OSTs"
1843 # createtest also checks that device nodes are created and
1844 # then visible correctly (#2091)
1845 test_28() { # bug 2091
1847 $CREATETEST $DIR/d28/ct || error
1849 run_test 28 "create/mknod/mkdir with bad file types ============"
1852 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1853 cancel_lru_locks mdc
1859 declare -i LOCKCOUNTORIG=0
1860 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1861 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
1863 [ $LOCKCOUNTORIG -eq 0 ] && echo "No mdc lock count" && return 1
1865 declare -i LOCKUNUSEDCOUNTORIG=0
1866 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1867 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
1874 declare -i LOCKCOUNTCURRENT=0
1875 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1876 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
1879 declare -i LOCKUNUSEDCOUNTCURRENT=0
1880 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1881 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
1884 if [ "$LOCKCOUNTCURRENT" -gt "$LOCKCOUNTORIG" ]; then
1885 lctl set_param -n ldlm.dump_namespaces ""
1886 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
1887 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1888 log "dumped log to $TMP/test_29.dk (bug 5793)"
1891 if [ "$LOCKUNUSEDCOUNTCURRENT" -gt "$LOCKUNUSEDCOUNTORIG" ]; then
1892 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
1893 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1894 log "dumped log to $TMP/test_29.dk (bug 5793)"
1898 run_test 29 "IT_GETATTR regression ============================"
1900 test_30a() { # was test_30
1901 cp `which ls` $DIR || cp /bin/ls $DIR
1905 run_test 30a "execute binary from Lustre (execve) =============="
1908 cp `which ls` $DIR || cp /bin/ls $DIR
1910 $RUNAS $DIR/ls / || error
1913 run_test 30b "execute binary from Lustre as non-root ==========="
1915 test_30c() { # b=22376
1916 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1917 cp `which ls` $DIR || cp /bin/ls $DIR
1919 cancel_lru_locks mdc
1920 cancel_lru_locks osc
1921 $RUNAS $DIR/ls / || error
1924 run_test 30c "execute binary from Lustre without read perms ===="
1927 $OPENUNLINK $DIR/f31 $DIR/f31 || error
1928 $CHECKSTAT -a $DIR/f31 || error
1930 run_test 31a "open-unlink file =================================="
1933 touch $DIR/f31 || error
1934 ln $DIR/f31 $DIR/f31b || error
1935 $MULTIOP $DIR/f31b Ouc || error
1936 $CHECKSTAT -t file $DIR/f31 || error
1938 run_test 31b "unlink file with multiple links while open ======="
1941 touch $DIR/f31 || error
1942 ln $DIR/f31 $DIR/f31c || error
1943 multiop_bg_pause $DIR/f31 O_uc || return 1
1945 $MULTIOP $DIR/f31c Ouc
1946 kill -USR1 $MULTIPID
1949 run_test 31c "open-unlink file with multiple links ============="
1952 opendirunlink $DIR/d31d $DIR/d31d || error
1953 $CHECKSTAT -a $DIR/d31d || error
1955 run_test 31d "remove of open directory ========================="
1957 test_31e() { # bug 2904
1958 check_kernel_version 34 || return 0
1959 openfilleddirunlink $DIR/d31e || error
1961 run_test 31e "remove of open non-empty directory ==============="
1963 test_31f() { # bug 4554
1964 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1966 test_mkdir $DIR/d31f
1967 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
1968 cp /etc/hosts $DIR/d31f
1970 $GETSTRIPE $DIR/d31f/hosts
1971 multiop_bg_pause $DIR/d31f D_c || return 1
1974 rm -rv $DIR/d31f || error "first of $DIR/d31f"
1975 test_mkdir $DIR/d31f
1976 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
1977 cp /etc/hosts $DIR/d31f
1979 $GETSTRIPE $DIR/d31f/hosts
1980 multiop_bg_pause $DIR/d31f D_c || return 1
1983 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
1984 wait $MULTIPID || error "first opendir $MULTIPID failed"
1988 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
1989 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
1992 run_test 31f "remove of open directory with open-unlink file ==="
1995 echo "-- cross directory link --"
1996 test_mkdir $DIR/d31ga
1997 test_mkdir $DIR/d31gb
1999 ln $DIR/d31ga/f $DIR/d31gb/g
2000 $CHECKSTAT -t file $DIR/d31ga/f || error "source"
2001 [ `stat -c%h $DIR/d31ga/f` == '2' ] || error "source nlink"
2002 $CHECKSTAT -t file $DIR/d31gb/g || error "target"
2003 [ `stat -c%h $DIR/d31gb/g` == '2' ] || error "target nlink"
2005 run_test 31g "cross directory link==============="
2008 echo "-- cross directory link --"
2009 test_mkdir $DIR/d31h
2010 test_mkdir $DIR/d31h/dir
2012 ln $DIR/d31h/f $DIR/d31h/dir/g
2013 $CHECKSTAT -t file $DIR/d31h/f || error "source"
2014 [ `stat -c%h $DIR/d31h/f` == '2' ] || error "source nlink"
2015 $CHECKSTAT -t file $DIR/d31h/dir/g || error "target"
2016 [ `stat -c%h $DIR/d31h/dir/g` == '2' ] || error "target nlink"
2018 run_test 31h "cross directory link under child==============="
2021 echo "-- cross directory link --"
2022 test_mkdir $DIR/d31i
2023 test_mkdir $DIR/d31i/dir
2024 touch $DIR/d31i/dir/f
2025 ln $DIR/d31i/dir/f $DIR/d31i/g
2026 $CHECKSTAT -t file $DIR/d31i/dir/f || error "source"
2027 [ `stat -c%h $DIR/d31i/dir/f` == '2' ] || error "source nlink"
2028 $CHECKSTAT -t file $DIR/d31i/g || error "target"
2029 [ `stat -c%h $DIR/d31i/g` == '2' ] || error "target nlink"
2031 run_test 31i "cross directory link under parent==============="
2035 test_mkdir $DIR/d31j
2036 test_mkdir $DIR/d31j/dir1
2037 ln $DIR/d31j/dir1 $DIR/d31j/dir2 && error "ln for dir"
2038 link $DIR/d31j/dir1 $DIR/d31j/dir3 && error "link for dir"
2039 mlink $DIR/d31j/dir1 $DIR/d31j/dir4 && error "mlink for dir"
2040 mlink $DIR/d31j/dir1 $DIR/d31j/dir1 && error "mlink to the same dir"
2043 run_test 31j "link for directory==============="
2047 test_mkdir $DIR/d31k
2049 touch $DIR/d31k/exist
2050 mlink $DIR/d31k/s $DIR/d31k/t || error "mlink"
2051 mlink $DIR/d31k/s $DIR/d31k/exist && error "mlink to exist file"
2052 mlink $DIR/d31k/s $DIR/d31k/s && error "mlink to the same file"
2053 mlink $DIR/d31k/s $DIR/d31k && error "mlink to parent dir"
2054 mlink $DIR/d31k $DIR/d31k/s && error "mlink parent dir to target"
2055 mlink $DIR/d31k/not-exist $DIR/d31k/foo && error "mlink non-existing to new"
2056 mlink $DIR/d31k/not-exist $DIR/d31k/s && error "mlink non-existing to exist"
2059 run_test 31k "link to file: the same, non-existing, dir==============="
2062 test_mkdir $DIR/d31m
2064 test_mkdir $DIR/d31m2
2065 touch $DIR/d31m2/exist
2066 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
2067 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
2068 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
2069 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
2070 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
2071 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
2074 run_test 31m "link to file: the same, non-existing, dir==============="
2077 [ -e /proc/self/fd/173 ] && echo "skipping, fd 173 is in use" && return
2078 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
2079 nlink=$(stat --format=%h $DIR/$tfile)
2080 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2081 exec 173<$DIR/$tfile
2082 trap "exec 173<&-" EXIT
2083 nlink=$(stat --dereference --format=%h /proc/self/fd/173)
2084 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2085 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
2086 nlink=$(stat --dereference --format=%h /proc/self/fd/173)
2087 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
2090 run_test 31n "check link count of unlinked file"
2092 cleanup_test32_mount() {
2094 $UMOUNT $DIR/$tdir/ext2-mountpoint
2098 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2099 echo "== more mountpoints and symlinks ================="
2100 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2101 trap cleanup_test32_mount EXIT
2102 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2103 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2104 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. || error
2105 cleanup_test32_mount
2107 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
2110 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2111 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2112 trap cleanup_test32_mount EXIT
2113 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2114 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2115 ls -al $DIR/$tdir/ext2-mountpoint/.. || error
2116 cleanup_test32_mount
2118 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
2121 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2122 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2123 trap cleanup_test32_mount EXIT
2124 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2125 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2126 test_mkdir -p $DIR/$tdir/d2/test_dir
2127 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2128 cleanup_test32_mount
2130 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2133 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2134 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2135 trap cleanup_test32_mount EXIT
2136 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2137 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2138 test_mkdir -p $DIR/$tdir/d2/test_dir
2139 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2140 cleanup_test32_mount
2142 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
2145 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
2146 test_mkdir -p $DIR/d32e/tmp
2147 TMP_DIR=$DIR/d32e/tmp
2148 ln -s $DIR/d32e $TMP_DIR/symlink11
2149 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2150 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
2151 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
2153 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
2156 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
2157 test_mkdir -p $DIR/d32f/tmp
2158 TMP_DIR=$DIR/d32f/tmp
2159 ln -s $DIR/d32f $TMP_DIR/symlink11
2160 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2161 ls $DIR/d32f/tmp/symlink11 || error
2162 ls $DIR/d32f/symlink01 || error
2164 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
2167 TMP_DIR=$DIR/$tdir/tmp
2168 test_mkdir -p $DIR/$tdir/tmp
2169 test_mkdir $DIR/${tdir}2
2170 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2171 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2172 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
2173 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
2174 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
2175 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
2177 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2180 rm -fr $DIR/$tdir $DIR/${tdir}2
2181 TMP_DIR=$DIR/$tdir/tmp
2182 test_mkdir -p $DIR/$tdir/tmp
2183 test_mkdir $DIR/${tdir}2
2184 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2185 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2186 ls $TMP_DIR/symlink12 || error
2187 ls $DIR/$tdir/symlink02 || error
2189 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2192 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2193 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2194 trap cleanup_test32_mount EXIT
2195 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2196 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2197 touch $DIR/$tdir/test_file
2198 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file || error
2199 cleanup_test32_mount
2201 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
2204 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2205 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2206 trap cleanup_test32_mount EXIT
2207 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2208 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2209 touch $DIR/$tdir/test_file
2210 cat $DIR/$tdir/ext2-mountpoint/../test_file || error
2211 cleanup_test32_mount
2213 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
2216 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2218 trap cleanup_test32_mount EXIT
2219 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2220 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2221 test_mkdir -p $DIR/$tdir/d2
2222 touch $DIR/$tdir/d2/test_file || error
2223 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2224 cleanup_test32_mount
2226 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
2229 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2231 trap cleanup_test32_mount EXIT
2232 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2233 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2234 test_mkdir -p $DIR/$tdir/d2
2235 touch $DIR/$tdir/d2/test_file
2236 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2237 cleanup_test32_mount
2239 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
2243 test_mkdir -p $DIR/d32m/tmp
2244 TMP_DIR=$DIR/d32m/tmp
2245 ln -s $DIR $TMP_DIR/symlink11
2246 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2247 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
2248 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
2250 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
2254 test_mkdir -p $DIR/d32n/tmp
2255 TMP_DIR=$DIR/d32n/tmp
2256 ln -s $DIR $TMP_DIR/symlink11
2257 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2258 ls -l $DIR/d32n/tmp/symlink11 || error
2259 ls -l $DIR/d32n/symlink01 || error
2261 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
2264 rm -fr $DIR/d32o $DIR/$tfile
2266 test_mkdir -p $DIR/d32o/tmp
2267 TMP_DIR=$DIR/d32o/tmp
2268 ln -s $DIR/$tfile $TMP_DIR/symlink12
2269 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2270 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
2271 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
2272 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
2273 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
2275 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
2285 test_mkdir -p $DIR/d32p/tmp
2287 TMP_DIR=$DIR/d32p/tmp
2289 ln -s $DIR/$tfile $TMP_DIR/symlink12
2291 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2293 cat $DIR/d32p/tmp/symlink12 || error
2295 cat $DIR/d32p/symlink02 || error
2298 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
2300 cleanup_testdir_mount() {
2306 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2307 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2308 trap cleanup_testdir_mount EXIT
2309 test_mkdir -p $DIR/$tdir
2310 touch $DIR/$tdir/under_the_mount
2311 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2312 ls $DIR/$tdir | grep "\<under_the_mount\>" && error
2313 cleanup_testdir_mount
2315 run_test 32q "stat follows mountpoints in Lustre (should return error)"
2318 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2319 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2320 trap cleanup_testdir_mount EXIT
2321 test_mkdir -p $DIR/$tdir
2322 touch $DIR/$tdir/under_the_mount
2323 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2324 ls $DIR/$tdir | grep -q under_the_mount && error || true
2325 cleanup_testdir_mount
2327 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
2332 chmod 444 $DIR/$tfile
2333 chown $RUNAS_ID $DIR/$tfile
2335 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2338 run_test 33aa "write file with mode 444 (should return error) ===="
2342 test_mkdir -p $DIR/d33
2343 chown $RUNAS_ID $DIR/d33
2344 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
2345 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
2346 error "open RDWR" || true
2348 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
2352 test_mkdir -p $DIR/d33
2353 chown $RUNAS_ID $DIR/d33
2354 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33 && error "create" || true
2356 run_test 33b "test open file with malformed flags (No panic and return error)"
2359 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2365 remote_ost_nodsh && skip "remote OST with nodsh" && return
2368 test_mkdir -p $DIR/d33
2369 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2372 for ostnum in $(seq $OSTCOUNT); do
2373 # test-framework's OST numbering is one-based, while Lustre's
2375 ostname=$(printf "$FSNAME-OST%.4d" $((ostnum - 1)))
2376 # Parsing llobdstat's output sucks; we could grep the /proc
2377 # path, but that's likely to not be as portable as using the
2378 # llobdstat utility. So we parse lctl output instead.
2379 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2380 obdfilter/$ostname/stats |
2381 awk '/^write_bytes/ {print $7}' )
2382 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2383 if (( ${write_bytes:-0} > 0 ))
2390 $all_zeros || return 0
2393 echo foo > $DIR/d33/bar
2397 # Total up write_bytes after writing. We'd better find non-zeros.
2398 for ostnum in $(seq $OSTCOUNT); do
2399 ostname=$(printf "$FSNAME-OST%.4d" $((ostnum - 1)))
2400 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2401 obdfilter/$ostname/stats |
2402 awk '/^write_bytes/ {print $7}' )
2403 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2404 if (( ${write_bytes:-0} > 0 ))
2413 for ostnum in $(seq $OSTCOUNT); do
2414 ostname=$(printf "$FSNAME-OST%.4d" $((ostnum - 1)))
2415 echo "Check that write_bytes is present in obdfilter/*/stats:"
2416 do_facet ost$ostnum lctl get_param -n \
2417 obdfilter/$ostname/stats
2419 error "OST not keeping write_bytes stats (b22312)"
2422 run_test 33c "test llobdstat and write_bytes"
2425 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2426 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2428 local remote_dir=$DIR/$tdir/remote_dir
2431 $LFS mkdir -i $MDTIDX $remote_dir ||
2432 error "create remote directory failed"
2434 touch $remote_dir/$tfile
2435 chmod 444 $remote_dir/$tfile
2436 chown $RUNAS_ID $remote_dir/$tfile
2438 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2440 chown $RUNAS_ID $remote_dir
2441 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
2442 error "create" || true
2443 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
2444 error "open RDWR" || true
2445 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 &&
2446 error "create" || true
2448 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
2450 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
2453 $MCREATE $DIR/f34 || error
2454 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2455 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
2456 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2457 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2459 run_test 34a "truncate file that has not been opened ==========="
2462 [ ! -f $DIR/f34 ] && test_34a
2463 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2464 $OPENFILE -f O_RDONLY $DIR/f34
2465 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2466 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2468 run_test 34b "O_RDONLY opening file doesn't create objects ====="
2471 [ ! -f $DIR/f34 ] && test_34a
2472 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2473 $OPENFILE -f O_RDWR $DIR/f34
2474 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2475 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2477 run_test 34c "O_RDWR opening file-with-size works =============="
2480 [ ! -f $DIR/f34 ] && test_34a
2481 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2482 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2485 run_test 34d "write to sparse file ============================="
2489 $MCREATE $DIR/f34e || error
2490 $TRUNCATE $DIR/f34e 1000 || error
2491 $CHECKSTAT -s 1000 $DIR/f34e || error
2492 $OPENFILE -f O_RDWR $DIR/f34e
2493 $CHECKSTAT -s 1000 $DIR/f34e || error
2495 run_test 34e "create objects, some with size and some without =="
2497 test_34f() { # bug 6242, 6243
2498 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2501 $MCREATE $DIR/f34f || error
2502 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
2503 dd if=$DIR/f34f of=$TMP/f34f
2504 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
2505 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
2506 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
2507 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
2508 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
2510 run_test 34f "read from a file with no objects until EOF ======="
2513 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2514 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
2515 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
2516 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
2517 cancel_lru_locks osc
2518 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
2519 error "wrong size after lock cancel"
2521 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
2522 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2523 error "expanding truncate failed"
2524 cancel_lru_locks osc
2525 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2526 error "wrong expanded size after lock cancel"
2528 run_test 34g "truncate long file ==============================="
2531 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2535 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
2536 sync # Flush the cache so that multiop below does not block on cache
2537 # flush when getting the group lock
2538 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
2542 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
2543 error "Multiop blocked on ftruncate, pid=$MULTIPID"
2547 local nsz=`stat -c %s $DIR/$tfile`
2548 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
2550 run_test 34h "ftruncate file under grouplock should not block"
2553 cp /bin/sh $DIR/f35a
2555 chown $RUNAS_ID $DIR/f35a
2556 $RUNAS $DIR/f35a && error || true
2559 run_test 35a "exec file with mode 444 (should return and not leak) ====="
2563 utime $DIR/f36 || error
2565 run_test 36a "MDS utime check (mknod, utime) ==================="
2569 utime $DIR/f36 || error
2571 run_test 36b "OST utime check (open, utime) ===================="
2576 chown $RUNAS_ID $DIR/d36
2577 $RUNAS utime $DIR/d36/f36 || error
2579 run_test 36c "non-root MDS utime check (mknod, utime) =========="
2582 [ ! -d $DIR/d36 ] && test_36c
2583 echo "" > $DIR/d36/f36
2584 $RUNAS utime $DIR/d36/f36 || error
2586 run_test 36d "non-root OST utime check (open, utime) ==========="
2589 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
2590 test_mkdir -p $DIR/$tdir
2591 touch $DIR/$tdir/$tfile
2592 $RUNAS utime $DIR/$tdir/$tfile && \
2593 error "utime worked, expected failure" || true
2595 run_test 36e "utime on non-owned file (should return error) ===="
2599 local LANG_SAVE=$LANG
2600 local LC_LANG_SAVE=$LC_LANG
2601 export LANG=C LC_LANG=C # for date language
2603 DATESTR="Dec 20 2000"
2604 test_mkdir -p $DIR/$tdir
2605 lctl set_param fail_loc=$fl
2607 cp /etc/hosts $DIR/$tdir/$tfile
2608 sync & # write RPC generated with "current" inode timestamp, but delayed
2610 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
2611 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
2612 cancel_lru_locks osc
2613 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
2615 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
2616 echo "BEFORE: $LS_BEFORE" && \
2617 echo "AFTER : $LS_AFTER" && \
2618 echo "WANT : $DATESTR" && \
2619 error "$DIR/$tdir/$tfile timestamps changed" || true
2621 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
2625 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2626 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2627 subr_36fh "0x80000214"
2629 run_test 36f "utime on file racing with OST BRW write =========="
2632 remote_ost_nodsh && skip "remote OST with nodsh" && return
2633 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2638 test_mkdir -p $DIR/$tdir
2639 fmd_max_age=$(do_facet ost1 \
2640 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
2643 fmd_before=$(do_facet ost1 \
2644 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2645 touch $DIR/$tdir/$tfile
2646 sleep $((fmd_max_age + 12))
2647 fmd_after=$(do_facet ost1 \
2648 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2650 echo "fmd_before: $fmd_before"
2651 echo "fmd_after: $fmd_after"
2652 [ "$fmd_after" -gt "$fmd_before" ] && \
2653 echo "AFTER: $fmd_after > BEFORE: $fmd_before" && \
2654 error "fmd didn't expire after ping" || true
2656 run_test 36g "filter mod data cache expiry ====================="
2659 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2660 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
2661 subr_36fh "0x80000227"
2663 run_test 36h "utime on file racing with OST BRW write =========="
2665 # test_37 - duplicate with tests 32q 32r
2668 local file=$DIR/$tfile
2670 openfile -f O_DIRECTORY $file
2673 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
2674 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
2676 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
2680 touch $DIR/${tfile}2
2681 # ls -l $DIR/$tfile $DIR/${tfile}2
2682 # ls -lu $DIR/$tfile $DIR/${tfile}2
2683 # ls -lc $DIR/$tfile $DIR/${tfile}2
2685 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
2686 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
2688 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
2690 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
2692 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
2693 error "O_TRUNC didn't change timestamps"
2696 run_test 39 "mtime changed on create ==========================="
2699 test_mkdir -p $DIR/$tdir
2700 cp -p /etc/passwd $DIR/$tdir/fopen
2701 cp -p /etc/passwd $DIR/$tdir/flink
2702 cp -p /etc/passwd $DIR/$tdir/funlink
2703 cp -p /etc/passwd $DIR/$tdir/frename
2704 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
2707 echo "aaaaaa" >> $DIR/$tdir/fopen
2708 echo "aaaaaa" >> $DIR/$tdir/flink
2709 echo "aaaaaa" >> $DIR/$tdir/funlink
2710 echo "aaaaaa" >> $DIR/$tdir/frename
2712 local open_new=`stat -c %Y $DIR/$tdir/fopen`
2713 local link_new=`stat -c %Y $DIR/$tdir/flink`
2714 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
2715 local rename_new=`stat -c %Y $DIR/$tdir/frename`
2717 cat $DIR/$tdir/fopen > /dev/null
2718 ln $DIR/$tdir/flink $DIR/$tdir/flink2
2719 rm -f $DIR/$tdir/funlink2
2720 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
2722 for (( i=0; i < 2; i++ )) ; do
2723 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
2724 local link_new2=`stat -c %Y $DIR/$tdir/flink`
2725 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
2726 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
2728 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
2729 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
2730 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
2731 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
2733 cancel_lru_locks osc
2734 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2737 run_test 39b "mtime change on open, link, unlink, rename ======"
2739 # this should be set to past
2740 TEST_39_MTIME=`date -d "1 year ago" +%s`
2746 local mtime0=`stat -c %Y $DIR1/$tfile`
2748 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2749 local mtime1=`stat -c %Y $DIR1/$tfile`
2750 [ "$mtime1" = $TEST_39_MTIME ] || \
2751 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
2754 echo hello >> $DIR1/$tfile
2756 local mtime2=`stat -c %Y $DIR1/$tfile`
2757 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
2758 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
2760 mv $DIR1/$tfile $DIR1/$tfile-1
2762 for (( i=0; i < 2; i++ )) ; do
2763 local mtime3=`stat -c %Y $DIR1/$tfile-1`
2764 [ "$mtime2" = "$mtime3" ] || \
2765 error "mtime ($mtime2) changed (to $mtime3) on rename"
2767 cancel_lru_locks osc
2768 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2771 run_test 39c "mtime change on rename ==========================="
2775 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2778 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2780 for (( i=0; i < 2; i++ )) ; do
2781 local mtime=`stat -c %Y $DIR1/$tfile`
2782 [ $mtime = $TEST_39_MTIME ] || \
2783 error "mtime($mtime) is not set to $TEST_39_MTIME"
2785 cancel_lru_locks osc
2786 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2789 run_test 39d "create, utime, stat =============================="
2793 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2795 local mtime1=`stat -c %Y $DIR1/$tfile`
2797 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2799 for (( i=0; i < 2; i++ )) ; do
2800 local mtime2=`stat -c %Y $DIR1/$tfile`
2801 [ $mtime2 = $TEST_39_MTIME ] || \
2802 error "mtime($mtime2) is not set to $TEST_39_MTIME"
2804 cancel_lru_locks osc
2805 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2808 run_test 39e "create, stat, utime, stat ========================"
2812 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2814 mtime1=`stat -c %Y $DIR1/$tfile`
2817 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2819 for (( i=0; i < 2; i++ )) ; do
2820 local mtime2=`stat -c %Y $DIR1/$tfile`
2821 [ $mtime2 = $TEST_39_MTIME ] || \
2822 error "mtime($mtime2) is not set to $TEST_39_MTIME"
2824 cancel_lru_locks osc
2825 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2828 run_test 39f "create, stat, sleep, utime, stat ================="
2832 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2833 echo hello >> $DIR1/$tfile
2834 local mtime1=`stat -c %Y $DIR1/$tfile`
2837 chmod o+r $DIR1/$tfile
2839 for (( i=0; i < 2; i++ )) ; do
2840 local mtime2=`stat -c %Y $DIR1/$tfile`
2841 [ "$mtime1" = "$mtime2" ] || \
2842 error "lost mtime: $mtime2, should be $mtime1"
2844 cancel_lru_locks osc
2845 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2848 run_test 39g "write, chmod, stat ==============================="
2852 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2857 echo hello >> $DIR1/$tfile
2858 local mtime1=`stat -c %Y $DIR1/$tfile`
2860 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2862 if [ "$d1" != "$d2" ]; then
2863 echo "write and touch not within one second"
2865 for (( i=0; i < 2; i++ )) ; do
2866 local mtime2=`stat -c %Y $DIR1/$tfile`
2867 [ "$mtime2" = $TEST_39_MTIME ] || \
2868 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
2870 cancel_lru_locks osc
2871 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2875 run_test 39h "write, utime within one second, stat ============="
2878 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2882 echo hello >> $DIR1/$tfile
2883 local mtime1=`stat -c %Y $DIR1/$tfile`
2885 mv $DIR1/$tfile $DIR1/$tfile-1
2887 for (( i=0; i < 2; i++ )) ; do
2888 local mtime2=`stat -c %Y $DIR1/$tfile-1`
2890 [ "$mtime1" = "$mtime2" ] || \
2891 error "lost mtime: $mtime2, should be $mtime1"
2893 cancel_lru_locks osc
2894 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2897 run_test 39i "write, rename, stat =============================="
2900 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2901 start_full_debug_logging
2905 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
2906 lctl set_param fail_loc=0x80000412
2907 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
2908 error "multiop failed"
2910 local mtime1=`stat -c %Y $DIR1/$tfile`
2912 mv $DIR1/$tfile $DIR1/$tfile-1
2914 kill -USR1 $multipid
2915 wait $multipid || error "multiop close failed"
2917 for (( i=0; i < 2; i++ )) ; do
2918 local mtime2=`stat -c %Y $DIR1/$tfile-1`
2919 [ "$mtime1" = "$mtime2" ] ||
2920 error "mtime is lost on close: $mtime2, " \
2923 cancel_lru_locks osc
2924 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2926 lctl set_param fail_loc=0
2927 stop_full_debug_logging
2929 run_test 39j "write, rename, close, stat ======================="
2932 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2936 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
2938 local mtime1=`stat -c %Y $DIR1/$tfile`
2940 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2942 kill -USR1 $multipid
2943 wait $multipid || error "multiop close failed"
2945 for (( i=0; i < 2; i++ )) ; do
2946 local mtime2=`stat -c %Y $DIR1/$tfile`
2948 [ "$mtime2" = $TEST_39_MTIME ] || \
2949 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
2951 cancel_lru_locks osc
2952 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2955 run_test 39k "write, utime, close, stat ========================"
2957 # this should be set to future
2958 TEST_39_ATIME=`date -d "1 year" +%s`
2961 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2962 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2963 local atime_diff=$(do_facet $SINGLEMDS \
2964 lctl get_param -n mdd.*MDT0000*.atime_diff)
2968 # test setting directory atime to future
2969 touch -a -d @$TEST_39_ATIME $DIR/$tdir
2970 local atime=$(stat -c %X $DIR/$tdir)
2971 [ "$atime" = $TEST_39_ATIME ] || \
2972 error "atime is not set to future: $atime, $TEST_39_ATIME"
2974 # test setting directory atime from future to now
2975 local d1=$(date +%s)
2977 local d2=$(date +%s)
2979 cancel_lru_locks mdc
2980 atime=$(stat -c %X $DIR/$tdir)
2981 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
2982 error "atime is not updated from future: $atime, $d1<atime<$d2"
2984 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
2987 # test setting directory atime when now > dir atime + atime_diff
2991 cancel_lru_locks mdc
2992 atime=$(stat -c %X $DIR/$tdir)
2993 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
2994 error "atime is not updated : $atime, should be $d2"
2996 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
2999 # test not setting directory atime when now < dir atime + atime_diff
3001 cancel_lru_locks mdc
3002 atime=$(stat -c %X $DIR/$tdir)
3003 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3004 error "atime is updated to $atime, should remain $d1<atime<$d2"
3006 do_facet $SINGLEMDS \
3007 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3009 run_test 39l "directory atime update ==========================="
3012 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3015 local far_past_mtime=$(date -d "May 29 1953" +%s)
3016 local far_past_atime=$(date -d "Dec 17 1903" +%s)
3018 touch -m -d @$far_past_mtime $DIR1/$tfile
3019 touch -a -d @$far_past_atime $DIR1/$tfile
3021 for (( i=0; i < 2; i++ )) ; do
3022 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
3023 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
3024 error "atime or mtime set incorrectly"
3026 cancel_lru_locks osc
3027 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3030 run_test 39m "test atime and mtime before 1970"
3033 dd if=/dev/zero of=$DIR/f40 bs=4096 count=1
3034 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/f40 && error
3035 $CHECKSTAT -t file -s 4096 $DIR/f40 || error
3037 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
3041 small_write $DIR/f41 18
3043 run_test 41 "test small file write + fstat ====================="
3045 count_ost_writes() {
3046 lctl get_param -n osc.*.stats |
3047 awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }'
3054 BG_DIRTY_RATIO_SAVE=10
3055 MAX_BG_DIRTY_RATIO=25
3059 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
3060 # dirty_ratio, dirty_background_ratio
3061 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3062 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
3063 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
3064 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
3066 # if file not here, we are a 2.4 kernel
3067 kill -CONT `pidof kupdated`
3072 # setup the trap first, so someone cannot exit the test at the
3073 # exact wrong time and mess up a machine
3074 trap start_writeback EXIT
3075 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
3076 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3077 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
3078 sysctl -w vm.dirty_writeback_centisecs=0
3079 sysctl -w vm.dirty_writeback_centisecs=0
3080 # save and increase /proc/sys/vm/dirty_ratio
3081 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
3082 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
3083 # save and increase /proc/sys/vm/dirty_background_ratio
3084 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
3085 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
3087 # if file not here, we are a 2.4 kernel
3088 kill -STOP `pidof kupdated`
3092 # ensure that all stripes have some grant before we test client-side cache
3094 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
3095 dd if=/dev/zero of=$i bs=4k count=1
3100 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
3101 # file truncation, and file removal.
3103 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3105 cancel_lru_locks osc
3107 sync; sleep 1; sync # just to be safe
3108 BEFOREWRITES=`count_ost_writes`
3109 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
3110 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
3111 AFTERWRITES=`count_ost_writes`
3112 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3113 error "$BEFOREWRITES < $AFTERWRITES"
3116 run_test 42a "ensure that we don't flush on close =============="
3119 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3121 cancel_lru_locks osc
3124 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
3125 BEFOREWRITES=`count_ost_writes`
3126 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
3127 AFTERWRITES=`count_ost_writes`
3128 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
3129 error "$BEFOREWRITES < $AFTERWRITES on unlink"
3131 BEFOREWRITES=`count_ost_writes`
3132 sync || error "sync: $?"
3133 AFTERWRITES=`count_ost_writes`
3134 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
3135 error "$BEFOREWRITES < $AFTERWRITES on sync"
3137 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
3141 run_test 42b "test destroy of file with cached dirty data ======"
3143 # if these tests just want to test the effect of truncation,
3144 # they have to be very careful. consider:
3145 # - the first open gets a {0,EOF}PR lock
3146 # - the first write conflicts and gets a {0, count-1}PW
3147 # - the rest of the writes are under {count,EOF}PW
3148 # - the open for truncate tries to match a {0,EOF}PR
3149 # for the filesize and cancels the PWs.
3150 # any number of fixes (don't get {0,EOF} on open, match
3151 # composite locks, do smarter file size management) fix
3152 # this, but for now we want these tests to verify that
3153 # the cancellation with truncate intent works, so we
3154 # start the file with a full-file pw lock to match against
3155 # until the truncate.
3160 cancel_lru_locks osc
3162 # prime the file with 0,EOF PW to match
3166 # now the real test..
3167 dd if=/dev/zero of=$file bs=1024 count=100
3168 BEFOREWRITES=`count_ost_writes`
3169 $TRUNCATE $file $offset
3170 cancel_lru_locks osc
3171 AFTERWRITES=`count_ost_writes`
3176 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3178 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
3179 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
3182 run_test 42c "test partial truncate of file with cached dirty data"
3185 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3187 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3188 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
3191 run_test 42d "test complete truncate of file with cached dirty data"
3193 test_42e() { # bug22074
3194 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3195 local TDIR=$DIR/${tdir}e
3196 local pagesz=$(page_size)
3197 local pages=16 # hardcoded 16 pages, don't change it.
3198 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
3199 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
3203 test_mkdir -p $DIR/${tdir}e
3204 $SETSTRIPE -c 1 $TDIR
3205 createmany -o $TDIR/f $files
3207 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
3209 # we assume that with $OSTCOUNT files, at least one of them will
3210 # be allocated on OST0.
3211 warmup_files=$((OSTCOUNT * max_dirty_mb))
3212 createmany -o $TDIR/w $warmup_files
3214 # write a large amount of data into one file and sync, to get good
3215 # avail_grant number from OST.
3216 for ((i=0; i<$warmup_files; i++)); do
3217 idx=$($GETSTRIPE -i $TDIR/w$i)
3218 [ $idx -ne 0 ] && continue
3219 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
3222 [ $i -gt $warmup_files ] && error "OST0 is still cold"
3224 $LCTL get_param $proc_osc0/cur_dirty_bytes
3225 $LCTL get_param $proc_osc0/cur_grant_bytes
3227 # create as much dirty pages as we can while not to trigger the actual
3228 # RPCs directly. but depends on the env, VFS may trigger flush during this
3229 # period, hopefully we are good.
3230 for ((i=0; i<$warmup_files; i++)); do
3231 idx=$($GETSTRIPE -i $TDIR/w$i)
3232 [ $idx -ne 0 ] && continue
3233 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
3235 $LCTL get_param $proc_osc0/cur_dirty_bytes
3236 $LCTL get_param $proc_osc0/cur_grant_bytes
3238 # perform the real test
3239 $LCTL set_param $proc_osc0/rpc_stats 0
3240 for ((;i<$files; i++)); do
3241 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
3242 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
3245 $LCTL get_param $proc_osc0/rpc_stats
3248 local have_ppr=false
3249 $LCTL get_param $proc_osc0/rpc_stats |
3250 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
3251 # skip lines until we are at the RPC histogram data
3252 [ "$PPR" == "pages" ] && have_ppr=true && continue
3253 $have_ppr || continue
3255 # we only want the percent stat for < 16 pages
3256 [ $(echo $PPR | tr -d ':') -ge $pages ] && break
3258 percent=$((percent + WPCT))
3259 if [ $percent -gt 15 ]; then
3260 error "less than 16-pages write RPCs" \
3267 run_test 42e "verify sub-RPC writes are not done synchronously"
3270 test_mkdir -p $DIR/$tdir
3271 cp -p /bin/ls $DIR/$tdir/$tfile
3272 $MULTIOP $DIR/$tdir/$tfile Ow_c &
3274 # give multiop a chance to open
3277 $DIR/$tdir/$tfile && error || true
3280 run_test 43 "execution of file opened for write should return -ETXTBSY"
3283 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3284 test_mkdir -p $DIR/$tdir
3285 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3286 cp -p multiop $DIR/$tdir/multiop
3287 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/test43.junk O_c ||
3290 $MULTIOP $DIR/$tdir/multiop Oc && error "expected error, got success"
3291 kill -USR1 $MULTIOP_PID || return 2
3292 wait $MULTIOP_PID || return 3
3295 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
3298 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3299 test_mkdir -p $DIR/$tdir
3300 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3301 cp -p multiop $DIR/$tdir/multiop
3302 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/test43.junk O_c ||
3305 $TRUNCATE $DIR/$tdir/multiop 0 && error "expected error, got success"
3306 kill -USR1 $MULTIOP_PID || return 2
3307 wait $MULTIOP_PID || return 3
3310 run_test 43b "truncate of file being executed should return -ETXTBSY"
3313 local testdir="$DIR/$tdir"
3314 test_mkdir -p $DIR/$tdir
3316 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
3317 ( cd $testdir && md5sum -c)
3319 run_test 43c "md5sum of copy into lustre========================"
3322 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
3323 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
3324 dd if=$DIR/f1 bs=4k count=1 > /dev/null
3326 run_test 44 "zero length read from a sparse stripe ============="
3329 local nstripe=`$LCTL lov_getconfig $DIR | grep default_stripe_count: | \
3331 [ -z "$nstripe" ] && skip "can't get stripe info" && return
3332 [ "$nstripe" -gt "$OSTCOUNT" ] && skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" && return
3333 local stride=`$LCTL lov_getconfig $DIR | grep default_stripe_size: | \
3335 if [ $nstripe -eq 0 -o $nstripe -eq -1 ] ; then
3336 nstripe=`$LCTL lov_getconfig $DIR | grep obd_count: | awk '{print $2}'`
3339 OFFSETS="0 $((stride/2)) $((stride-1))"
3340 for offset in $OFFSETS ; do
3341 for i in `seq 0 $((nstripe-1))`; do
3342 local GLOBALOFFSETS=""
3343 local size=$((((i + 2 * $nstripe )*$stride + $offset))) # Bytes
3344 local myfn=$DIR/d44a-$size
3345 echo "--------writing $myfn at $size"
3346 ll_sparseness_write $myfn $size || error "ll_sparseness_write"
3347 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3348 ll_sparseness_verify $myfn $GLOBALOFFSETS \
3349 || error "ll_sparseness_verify $GLOBALOFFSETS"
3351 for j in `seq 0 $((nstripe-1))`; do
3352 size=$((((j + $nstripe )*$stride + $offset))) # Bytes
3353 ll_sparseness_write $myfn $size || error "ll_sparseness_write"
3354 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3356 ll_sparseness_verify $myfn $GLOBALOFFSETS \
3357 || error "ll_sparseness_verify $GLOBALOFFSETS"
3362 run_test 44a "test sparse pwrite ==============================="
3366 for d in `lctl get_param -n osc.*.cur_dirty_bytes`; do
3372 before=`dirty_osc_total`
3373 echo executing "\"$*\""
3375 after=`dirty_osc_total`
3376 echo before $before, after $after
3379 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3381 # Obtain grants from OST if it supports it
3382 echo blah > ${f}_grant
3385 do_dirty_record "echo blah > $f"
3386 [ $before -eq $after ] && error "write wasn't cached"
3387 do_dirty_record "> $f"
3388 [ $before -gt $after ] || error "truncate didn't lower dirty count"
3389 do_dirty_record "echo blah > $f"
3390 [ $before -eq $after ] && error "write wasn't cached"
3391 do_dirty_record "sync"
3392 [ $before -gt $after ] || error "writeback didn't lower dirty count"
3393 do_dirty_record "echo blah > $f"
3394 [ $before -eq $after ] && error "write wasn't cached"
3395 do_dirty_record "cancel_lru_locks osc"
3396 [ $before -gt $after ] || error "lock cancellation didn't lower dirty count"
3399 run_test 45 "osc io page accounting ============================"
3401 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
3402 # test tickles a bug where re-dirtying a page was failing to be mapped to the
3403 # objects offset and an assert hit when an rpc was built with 1023's mapped
3404 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
3406 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3410 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3412 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
3413 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3417 run_test 46 "dirtying a previously written page ================"
3419 # test_47 is removed "Device nodes check" is moved to test_28
3421 test_48a() { # bug 2399
3422 check_kernel_version 34 || return 0
3423 test_mkdir -p $DIR/$tdir
3425 mv $DIR/$tdir $DIR/d48.new || error "move directory failed"
3426 test_mkdir $DIR/$tdir || error "recreate directory failed"
3427 touch foo || error "'touch foo' failed after recreating cwd"
3428 test_mkdir $DIR/$tdir/bar ||
3429 error "'mkdir foo' failed after recreating cwd"
3430 if check_kernel_version 44; then
3431 touch .foo || error "'touch .foo' failed after recreating cwd"
3432 test_mkdir $DIR/$tdir/.bar ||
3433 error "'mkdir .foo' failed after recreating cwd"
3435 ls . > /dev/null || error "'ls .' failed after recreating cwd"
3436 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3437 cd . || error "'cd .' failed after recreating cwd"
3438 test_mkdir . && error "'mkdir .' worked after recreating cwd"
3439 rmdir . && error "'rmdir .' worked after recreating cwd"
3440 ln -s . baz || error "'ln -s .' failed after recreating cwd"
3441 cd .. || error "'cd ..' failed after recreating cwd"
3443 run_test 48a "Access renamed working dir (should return errors)="
3445 test_48b() { # bug 2399
3446 check_kernel_version 34 || return 0
3448 test_mkdir -p $DIR/$tdir
3450 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
3451 touch foo && error "'touch foo' worked after removing cwd"
3452 test_mkdir $DIR/$tdir/foo &&
3453 error "'mkdir foo' worked after removing cwd"
3454 if check_kernel_version 44; then
3455 touch .foo && error "'touch .foo' worked after removing cwd"
3456 test_mkdir $DIR/$tdir/.foo &&
3457 error "'mkdir .foo' worked after removing cwd"
3459 ls . > /dev/null && error "'ls .' worked after removing cwd"
3460 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3461 is_patchless || ( cd . && error "'cd .' worked after removing cwd" )
3462 test_mkdir $DIR/$tdir/. && error "'mkdir .' worked after removing cwd"
3463 rmdir . && error "'rmdir .' worked after removing cwd"
3464 ln -s . foo && error "'ln -s .' worked after removing cwd"
3465 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
3467 run_test 48b "Access removed working dir (should return errors)="
3469 test_48c() { # bug 2350
3470 check_kernel_version 36 || return 0
3471 #lctl set_param debug=-1
3474 test_mkdir -p $DIR/$tdir/dir
3476 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3477 $TRACE touch foo && error "touch foo worked after removing cwd"
3478 $TRACE test_mkdir foo && error "'mkdir foo' worked after removing cwd"
3479 if check_kernel_version 44; then
3480 touch .foo && error "touch .foo worked after removing cwd"
3481 test_mkdir .foo && error "mkdir .foo worked after removing cwd"
3483 $TRACE ls . && error "'ls .' worked after removing cwd"
3484 $TRACE ls .. || error "'ls ..' failed after removing cwd"
3485 is_patchless || ( $TRACE cd . &&
3486 error "'cd .' worked after removing cwd" )
3487 $TRACE test_mkdir . && error "'mkdir .' worked after removing cwd"
3488 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
3489 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
3490 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
3492 run_test 48c "Access removed working subdir (should return errors)"
3494 test_48d() { # bug 2350
3495 check_kernel_version 36 || return 0
3496 #lctl set_param debug=-1
3499 test_mkdir -p $DIR/$tdir/dir
3501 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3502 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3503 $TRACE touch foo && error "'touch foo' worked after removing parent"
3504 $TRACE test_mkdir foo && error "mkdir foo worked after removing parent"
3505 if check_kernel_version 44; then
3506 touch .foo && error "'touch .foo' worked after removing parent"
3508 error "mkdir .foo worked after removing parent"
3510 $TRACE ls . && error "'ls .' worked after removing parent"
3511 $TRACE ls .. && error "'ls ..' worked after removing parent"
3512 is_patchless || ( $TRACE cd . &&
3513 error "'cd .' worked after recreate parent" )
3514 $TRACE test_mkdir . && error "'mkdir .' worked after removing parent"
3515 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
3516 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
3517 is_patchless || ( $TRACE cd .. &&
3518 error "'cd ..' worked after removing parent" || true )
3520 run_test 48d "Access removed parent subdir (should return errors)"
3522 test_48e() { # bug 4134
3523 check_kernel_version 41 || return 0
3524 #lctl set_param debug=-1
3527 test_mkdir -p $DIR/$tdir/dir
3529 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3530 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3531 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
3532 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
3533 # On a buggy kernel addition of "touch foo" after cd .. will
3534 # produce kernel oops in lookup_hash_it
3535 touch ../foo && error "'cd ..' worked after recreate parent"
3537 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
3539 run_test 48e "Access to recreated parent subdir (should return errors)"
3541 test_49() { # LU-1030
3542 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3543 # get ost1 size - lustre-OST0000
3544 ost1_size=$(do_facet ost1 lfs df |grep ${ost1_svc} |awk '{print $4}')
3545 # write 800M at maximum
3546 [ $ost1_size -gt 819200 ] && ost1_size=819200
3548 lfs setstripe -c 1 -i 0 $DIR/$tfile
3549 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
3552 # change max_pages_per_rpc while writing the file
3553 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
3554 local orig_mppc=`$LCTL get_param -n $osc1_mppc`
3555 # loop until dd process exits
3556 while ps ax -opid | grep -wq $dd_pid; do
3557 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
3558 sleep $((RANDOM % 5 + 1))
3560 # restore original max_pages_per_rpc
3561 $LCTL set_param $osc1_mppc=$orig_mppc
3562 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
3564 run_test 49 "Change max_pages_per_rpc won't break osc extent"
3568 test_mkdir $DIR/$tdir
3570 ls /proc/$$/cwd || error
3572 run_test 50 "special situations: /proc symlinks ==============="
3574 test_51a() { # was test_51
3575 # bug 1516 - create an empty entry right after ".." then split dir
3576 test_mkdir -p $DIR/$tdir
3577 touch $DIR/$tdir/foo
3578 $MCREATE $DIR/$tdir/bar
3580 createmany -m $DIR/$tdir/longfile 201
3582 while [ `ls -sd $DIR/$tdir | awk '{ print $1 }'` -eq 4 ]; do
3583 $MCREATE $DIR/$tdir/longfile$FNUM
3588 ls -l $DIR/$tdir > /dev/null || error
3590 run_test 51a "special situations: split htree with empty entry =="
3592 export NUMTEST=70000
3594 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3595 local BASE=$DIR/$tdir
3597 # cleanup the directory
3602 local mdtidx=$(printf "%04x" $($LFS getstripe -M $BASE))
3603 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
3604 [ $numfree -lt 21000 ] && skip "not enough free inodes ($numfree)" &&
3607 [ $numfree -lt $NUMTEST ] && NUMTEST=$(($numfree - 50)) &&
3608 echo "reduced count to $NUMTEST due to inodes"
3610 # need to check free space for the directories as well
3611 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
3612 numfree=$((blkfree / 4))
3613 [ $numfree -lt $NUMTEST ] && NUMTEST=$(($numfree - 50)) &&
3614 echo "reduced count to $NUMTEST due to blocks"
3616 createmany -d $BASE/d $NUMTEST && echo $NUMTEST > $BASE/fnum ||
3617 echo "failed" > $BASE/fnum
3619 run_test 51b "exceed 64k subdirectory nlink limit"
3621 test_51ba() { # LU-993
3622 local BASE=$DIR/$tdir
3623 # unlink all but 100 subdirectories, then check it still works
3625 [ -f $BASE/fnum ] && local NUMPREV=$(cat $BASE/fnum) && rm $BASE/fnum
3627 [ "$NUMPREV" != "failed" ] && NUMTEST=$NUMPREV
3628 local DELETE=$((NUMTEST - LEFT))
3630 # continue on to run this test even if 51b didn't finish,
3631 # just to delete the many subdirectories created.
3632 [ ! -d "${BASE}/d1" ] && skip "test_51b() not run" && return 0
3634 # for ldiskfs the nlink count should be 1, but this is OSD specific
3635 # and so this is listed for informational purposes only
3636 echo "nlink before: $(stat -c %h $BASE), created before: $NUMTEST"
3637 unlinkmany -d $BASE/d $DELETE
3640 if [ $RC -ne 0 ]; then
3641 if [ "$NUMPREV" == "failed" ]; then
3642 skip "previous setup failed"
3645 error "unlink of first $DELETE subdirs failed"
3650 echo "nlink between: $(stat -c %h $BASE)"
3651 # trim the first line of ls output
3652 local FOUND=$(($(ls -l ${BASE} | wc -l) - 1))
3653 [ $FOUND -ne $LEFT ] &&
3654 error "can't find subdirs: found only $FOUND/$LEFT"
3656 unlinkmany -d $BASE/d $DELETE $LEFT ||
3657 error "unlink of second $LEFT subdirs failed"
3658 # regardless of whether the backing filesystem tracks nlink accurately
3659 # or not, the nlink count shouldn't be more than "." and ".." here
3660 local AFTER=$(stat -c %h $BASE)
3661 [ $AFTER -gt 2 ] && error "nlink after: $AFTER > 2" ||
3662 echo "nlink after: $AFTER"
3664 run_test 51ba "verify nlink for many subdirectory cleanup"
3667 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3668 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping test with few OSTs" && return
3669 test_mkdir -p $DIR/$tdir
3670 createmany -o $DIR/$tdir/t- 1000
3671 $GETSTRIPE $DIR/$tdir > $TMP/files
3672 for N in `seq 0 $((OSTCOUNT - 1))`; do
3673 OBJS[$N]=`awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}' $TMP/files`
3674 OBJS0[$N]=`grep -A 1 idx $TMP/files | awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}'`
3675 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
3677 unlinkmany $DIR/$tdir/t- 1000
3680 for N in `seq 1 $((OSTCOUNT - 1))`; do
3681 [ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ] && \
3682 error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
3683 [ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ] && \
3684 error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
3686 [ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ] && \
3687 error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
3688 [ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ] && \
3689 error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
3693 run_test 51d "check object distribution ===================="
3696 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
3697 test_mkdir -p $DIR/$tdir
3698 touch $DIR/$tdir/foo
3699 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
3700 echo bar >> $DIR/$tdir/foo || error "append bar failed"
3701 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
3702 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
3703 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
3705 echo foo >> $DIR/$tdir/foo || error "append foo failed"
3706 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
3707 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
3709 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
3710 cp -r $DIR/$tdir /tmp/
3711 rm -fr $DIR/$tdir || error "cleanup rm failed"
3713 run_test 52a "append-only flag test (should return errors) ====="
3716 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
3717 test_mkdir -p $DIR/$tdir
3718 touch $DIR/$tdir/foo
3719 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
3720 cat test > $DIR/$tdir/foo && error "cat test worked"
3721 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
3722 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
3723 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
3725 echo foo >> $DIR/$tdir/foo && error "echo worked"
3726 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
3727 [ -f $DIR/$tdir/foo ] || error
3728 [ -f $DIR/$tdir/foo_ren ] && error
3729 lsattr $DIR/$tdir/foo | egrep -q "^-+i[-e]+ $DIR/$tdir/foo" ||
3731 chattr -i $DIR/$tdir/foo || error "chattr failed"
3733 rm -fr $DIR/$tdir || error
3735 run_test 52b "immutable flag test (should return errors) ======="
3738 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3739 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3740 remote_ost_nodsh && skip "remote OST with nodsh" && return
3750 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
3751 for value in $(do_facet $SINGLEMDS lctl get_param osc.$mdtosc.prealloc_last_id) ; do
3752 param=`echo ${value[0]} | cut -d "=" -f1`
3753 ostname=`echo $param | cut -d "." -f2 | cut -d - -f 1-2`
3754 mds_last=$(do_facet $SINGLEMDS lctl get_param -n $param)
3755 ostnum=$(index_from_ostuuid ${ostname}_UUID)
3756 node=$(facet_active_host ost$((ostnum+1)))
3757 param="obdfilter.$ostname.last_id"
3758 ost_last=$(do_node $node lctl get_param -n $param | head -n 1)
3759 echo "$ostname.last_id=$ost_last ; MDS.last_id=$mds_last"
3760 if [ $ost_last != $mds_last ]; then
3761 error "$ostname.last_id=$ost_last ; MDS.last_id=$mds_last"
3765 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
3768 [ ! -f "$SOCKETSERVER" ] && skip_env "no socketserver, skipping" && return
3769 [ ! -f "$SOCKETCLIENT" ] && skip_env "no socketclient, skipping" && return
3770 $SOCKETSERVER $DIR/socket
3771 $SOCKETCLIENT $DIR/socket || error
3772 $MUNLINK $DIR/socket
3774 run_test 54a "unix domain socket test =========================="
3780 dd if=/dev/zero of=$f bs=`page_size` count=1
3782 run_test 54b "char device works in lustre ======================"
3785 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
3786 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
3787 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
3789 for i in `seq 3 7`; do
3790 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
3798 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3801 loopdev="$DIR/loop54c"
3804 [ -z "$LOOPNUM" ] && echo "couldn't find empty loop device" && return
3805 mknod $loopdev b 7 $LOOPNUM
3806 echo "make a loop file system with $tfile on $loopdev ($LOOPNUM)..."
3807 dd if=/dev/zero of=$tfile bs=`page_size` seek=1024 count=1 > /dev/null
3808 losetup $loopdev $tfile || error "can't set up $loopdev for $tfile"
3809 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
3811 mount -t ext2 $loopdev $tdir || error "error mounting $loopdev on $tdir"
3812 dd if=/dev/zero of=$tdir/tmp bs=`page_size` count=30 || error "dd write"
3814 dd if=$tdir/tmp of=/dev/zero bs=`page_size` count=30 || error "dd read"
3819 run_test 54c "block device works in lustre ====================="
3825 [ "$string" = `echo $string > $f | cat $f` ] || error
3827 run_test 54d "fifo device works in lustre ======================"
3830 check_kernel_version 46 || return 0
3833 cp -aL /dev/console $f
3834 echo $string > $f || error
3836 run_test 54e "console/tty device works in lustre ======================"
3838 #The test_55 used to be iopen test and it was removed by bz#24037.
3839 #run_test 55 "check iopen_connect_dentry() ======================"
3841 test_56a() { # was test_56
3844 test_mkdir $DIR/$tdir
3845 test_mkdir $DIR/$tdir/dir
3847 NUMFILESx2=$(($NUMFILES * 2))
3848 for i in `seq 1 $NUMFILES` ; do
3849 touch $DIR/$tdir/file$i
3850 touch $DIR/$tdir/dir/file$i
3853 # test lfs getstripe with --recursive
3854 FILENUM=`$GETSTRIPE --recursive $DIR/$tdir | grep -c obdidx`
3855 [ $FILENUM -eq $NUMFILESx2 ] ||
3856 error "$GETSTRIPE --recursive: found $FILENUM, not $NUMFILESx2"
3857 FILENUM=`$GETSTRIPE $DIR/$tdir | grep -c obdidx`
3858 [ $FILENUM -eq $NUMFILES ] ||
3859 error "$GETSTRIPE $DIR/$tdir: found $FILENUM, not $NUMFILES"
3860 echo "$GETSTRIPE --recursive passed."
3862 # test lfs getstripe with file instead of dir
3863 FILENUM=`$GETSTRIPE $DIR/$tdir/file1 | grep -c obdidx`
3864 [ $FILENUM -eq 1 ] || error \
3865 "$GETSTRIPE $DIR/$tdir/file1: found $FILENUM, not 1"
3866 echo "$GETSTRIPE file1 passed."
3868 #test lfs getstripe with --verbose
3869 [ `$GETSTRIPE --verbose $DIR/$tdir |
3870 grep -c lmm_magic` -eq $NUMFILES ] ||
3871 error "$GETSTRIPE --verbose $DIR/$tdir: want $NUMFILES"
3872 [ `$GETSTRIPE $DIR/$tdir | grep -c lmm_magic` -eq 0 ] ||
3873 error "$GETSTRIPE $DIR/$tdir: showed lmm_magic"
3874 echo "$GETSTRIPE --verbose passed."
3876 #test lfs getstripe with --obd
3877 $GETSTRIPE --obd wrong_uuid $DIR/$tdir 2>&1 |
3878 grep -q "unknown obduuid" ||
3879 error "$GETSTRIPE --obd wrong_uuid should return error message"
3881 [ "$OSTCOUNT" -lt 2 ] &&
3882 skip_env "skipping other $GETSTRIPE --obd test" && return
3885 OBDUUID=$(ostuuid_from_index $OSTIDX)
3886 FILENUM=`$GETSTRIPE -ir $DIR/$tdir | grep -x $OSTIDX | wc -l`
3887 FOUND=`$GETSTRIPE -r --obd $OBDUUID $DIR/$tdir | grep obdidx | wc -l`
3888 [ $FOUND -eq $FILENUM ] ||
3889 error "$GETSTRIPE --obd wrong: found $FOUND, expected $FILENUM"
3890 [ `$GETSTRIPE -r -v --obd $OBDUUID $DIR/$tdir |
3891 sed '/^[ ]*'${OSTIDX}'[ ]/d' |
3892 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l` -eq 0 ] ||
3893 error "$GETSTRIPE --obd: should not show file on other obd"
3894 echo "$GETSTRIPE --obd passed"
3896 run_test 56a "check $GETSTRIPE"
3901 local LOCAL_NUMFILES="$1"
3902 local LOCAL_NUMDIRS="$2"
3903 local MKDIR_PARAMS="$3"
3905 if [ ! -d "$TDIR" ] ; then
3907 [ "$MKDIR_PARAMS" ] && $SETSTRIPE $MKDIR_PARAMS $TDIR
3908 for i in `seq 1 $LOCAL_NUMFILES` ; do
3911 for i in `seq 1 $LOCAL_NUMDIRS` ; do
3912 test_mkdir $TDIR/dir$i
3913 for j in `seq 1 $LOCAL_NUMFILES` ; do
3914 touch $TDIR/dir$i/file$j
3920 setup_56_special() {
3924 if [ ! -e "$TDIR/loop1b" ] ; then
3925 for i in `seq 1 $LOCAL_NUMFILES` ; do
3926 mknod $TDIR/loop${i}b b 7 $i
3927 mknod $TDIR/null${i}c c 1 3
3928 ln -s $TDIR/file1 $TDIR/link${i}l
3930 for i in `seq 1 $LOCAL_NUMDIRS` ; do
3931 mknod $TDIR/dir$i/loop${i}b b 7 $i
3932 mknod $TDIR/dir$i/null${i}c c 1 3
3933 ln -s $TDIR/dir$i/file1 $TDIR/dir$i/link${i}l
3942 setup_56 $NUMFILES $NUMDIRS
3944 EXPECTED=$(($NUMDIRS + 2))
3945 # test lfs find with -name
3946 for i in $(seq 1 $NUMFILES) ; do
3947 NUMS=$($LFIND -name "*$i" $TDIR | wc -l)
3948 [ $NUMS -eq $EXPECTED ] ||
3949 error "lfs find -name \"*$i\" $TDIR wrong: "\
3950 "found $NUMS, expected $EXPECTED"
3953 run_test 56g "check lfs find -name ============================="
3959 setup_56 $NUMFILES $NUMDIRS
3961 EXPECTED=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
3962 # test lfs find with ! -name
3963 for i in $(seq 1 $NUMFILES) ; do
3964 NUMS=$($LFIND ! -name "*$i" $TDIR | wc -l)
3965 [ $NUMS -eq $EXPECTED ] ||
3966 error "lfs find ! -name \"*$i\" $TDIR wrong: "\
3967 "found $NUMS, expected $EXPECTED"
3970 run_test 56h "check lfs find ! -name ============================="
3974 test_mkdir -p $DIR/$tdir
3975 UUID=$(ostuuid_from_index 0 $DIR/$tdir)
3976 CMD="$LFIND -ost $UUID $DIR/$tdir"
3978 [ -z "$OUT" ] || error "\"$CMD\" returned directory '$OUT'"
3980 run_test 56i "check 'lfs find -ost UUID' skips directories ======="
3984 setup_56_special $NUMFILES $NUMDIRS
3986 EXPECTED=$((NUMDIRS + 1))
3987 CMD="$LFIND -type d $TDIR"
3988 NUMS=$($CMD | wc -l)
3989 [ $NUMS -eq $EXPECTED ] ||
3990 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3992 run_test 56j "check lfs find -type d ============================="
3996 setup_56_special $NUMFILES $NUMDIRS
3998 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
3999 CMD="$LFIND -type f $TDIR"
4000 NUMS=$($CMD | wc -l)
4001 [ $NUMS -eq $EXPECTED ] ||
4002 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4004 run_test 56k "check lfs find -type f ============================="
4008 setup_56_special $NUMFILES $NUMDIRS
4010 EXPECTED=$((NUMDIRS + NUMFILES))
4011 CMD="$LFIND -type b $TDIR"
4012 NUMS=$($CMD | wc -l)
4013 [ $NUMS -eq $EXPECTED ] ||
4014 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4016 run_test 56l "check lfs find -type b ============================="
4020 setup_56_special $NUMFILES $NUMDIRS
4022 EXPECTED=$((NUMDIRS + NUMFILES))
4023 CMD="$LFIND -type c $TDIR"
4024 NUMS=$($CMD | wc -l)
4025 [ $NUMS -eq $EXPECTED ] ||
4026 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4028 run_test 56m "check lfs find -type c ============================="
4032 setup_56_special $NUMFILES $NUMDIRS
4034 EXPECTED=$((NUMDIRS + NUMFILES))
4035 CMD="$LFIND -type l $TDIR"
4036 NUMS=$($CMD | wc -l)
4037 [ $NUMS -eq $EXPECTED ] ||
4038 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4040 run_test 56n "check lfs find -type l ============================="
4044 setup_56 $NUMFILES $NUMDIRS
4046 utime $TDIR/file1 > /dev/null || error "utime (1)"
4047 utime $TDIR/file2 > /dev/null || error "utime (2)"
4048 utime $TDIR/dir1 > /dev/null || error "utime (3)"
4049 utime $TDIR/dir2 > /dev/null || error "utime (4)"
4050 utime $TDIR/dir1/file1 > /dev/null || error "utime (5)"
4051 dd if=/dev/zero count=1 >> $TDIR/dir1/file1 && sync
4054 NUMS=`$LFIND -mtime +0 $TDIR | wc -l`
4055 [ $NUMS -eq $EXPECTED ] || \
4056 error "lfs find -mtime +0 $TDIR wrong: found $NUMS, expected $EXPECTED"
4059 CMD="$LFIND -mtime 0 $TDIR"
4060 NUMS=$($CMD | wc -l)
4061 [ $NUMS -eq $EXPECTED ] ||
4062 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4064 run_test 56o "check lfs find -mtime for old files =========================="
4067 [ $RUNAS_ID -eq $UID ] &&
4068 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4071 setup_56 $NUMFILES $NUMDIRS
4073 chown $RUNAS_ID $TDIR/file* || error "chown $DIR/${tdir}g/file$i failed"
4075 CMD="$LFIND -uid $RUNAS_ID $TDIR"
4076 NUMS=$($CMD | wc -l)
4077 [ $NUMS -eq $EXPECTED ] || \
4078 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4080 EXPECTED=$(((NUMFILES + 1) * NUMDIRS + 1))
4081 CMD="$LFIND ! -uid $RUNAS_ID $TDIR"
4082 NUMS=$($CMD | wc -l)
4083 [ $NUMS -eq $EXPECTED ] || \
4084 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4086 run_test 56p "check lfs find -uid and ! -uid ==============================="
4089 [ $RUNAS_ID -eq $UID ] &&
4090 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4093 setup_56 $NUMFILES $NUMDIRS
4095 chgrp $RUNAS_GID $TDIR/file* || error "chown $TDIR/file$i failed"
4098 CMD="$LFIND -gid $RUNAS_GID $TDIR"
4099 NUMS=$($CMD | wc -l)
4100 [ $NUMS -eq $EXPECTED ] ||
4101 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4103 EXPECTED=$(( ($NUMFILES+1) * $NUMDIRS + 1))
4104 CMD="$LFIND ! -gid $RUNAS_GID $TDIR"
4105 NUMS=$($CMD | wc -l)
4106 [ $NUMS -eq $EXPECTED ] ||
4107 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4109 run_test 56q "check lfs find -gid and ! -gid ==============================="
4113 setup_56 $NUMFILES $NUMDIRS
4116 CMD="$LFIND -size 0 -type f $TDIR"
4117 NUMS=$($CMD | wc -l)
4118 [ $NUMS -eq $EXPECTED ] ||
4119 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4121 CMD="$LFIND ! -size 0 -type f $TDIR"
4122 NUMS=$($CMD | wc -l)
4123 [ $NUMS -eq $EXPECTED ] ||
4124 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4125 echo "test" > $TDIR/$tfile
4126 echo "test2" > $TDIR/$tfile.2 && sync
4128 CMD="$LFIND -size 5 -type f $TDIR"
4129 NUMS=$($CMD | wc -l)
4130 [ $NUMS -eq $EXPECTED ] ||
4131 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4133 CMD="$LFIND -size +5 -type f $TDIR"
4134 NUMS=$($CMD | wc -l)
4135 [ $NUMS -eq $EXPECTED ] ||
4136 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4138 CMD="$LFIND -size +0 -type f $TDIR"
4139 NUMS=$($CMD | wc -l)
4140 [ $NUMS -eq $EXPECTED ] ||
4141 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4143 CMD="$LFIND ! -size -5 -type f $TDIR"
4144 NUMS=$($CMD | wc -l)
4145 [ $NUMS -eq $EXPECTED ] ||
4146 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4148 CMD="$LFIND -size -5 -type f $TDIR"
4149 NUMS=$($CMD | wc -l)
4150 [ $NUMS -eq $EXPECTED ] ||
4151 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4153 run_test 56r "check lfs find -size works =========================="
4155 test_56s() { # LU-611
4157 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT"
4159 if [ $OSTCOUNT -gt 1 ]; then
4160 $SETSTRIPE -c 1 $TDIR/$tfile.{0,1,2,3}
4164 ONESTRIPE=$(((NUMDIRS + 1) * NUMFILES))
4168 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4169 CMD="$LFIND -stripe-count $OSTCOUNT -type f $TDIR"
4170 NUMS=$($CMD | wc -l)
4171 [ $NUMS -eq $EXPECTED ] ||
4172 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4174 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + EXTRA))
4175 CMD="$LFIND -stripe-count +0 -type f $TDIR"
4176 NUMS=$($CMD | wc -l)
4177 [ $NUMS -eq $EXPECTED ] ||
4178 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4181 CMD="$LFIND -stripe-count 1 -type f $TDIR"
4182 NUMS=$($CMD | wc -l)
4183 [ $NUMS -eq $EXPECTED ] ||
4184 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4186 CMD="$LFIND -stripe-count -2 -type f $TDIR"
4187 NUMS=$($CMD | wc -l)
4188 [ $NUMS -eq $EXPECTED ] ||
4189 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4192 CMD="$LFIND -stripe-count $((OSTCOUNT + 1)) -type f $TDIR"
4193 NUMS=$($CMD | wc -l)
4194 [ $NUMS -eq $EXPECTED ] ||
4195 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4197 run_test 56s "check lfs find -stripe-count works"
4199 test_56t() { # LU-611
4201 setup_56 $NUMFILES $NUMDIRS "-s 512k"
4203 $SETSTRIPE -S 256k $TDIR/$tfile.{0,1,2,3}
4205 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4206 CMD="$LFIND -stripe-size 512k -type f $TDIR"
4207 NUMS=$($CMD | wc -l)
4208 [ $NUMS -eq $EXPECTED ] ||
4209 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4211 CMD="$LFIND -stripe-size +320k -type f $TDIR"
4212 NUMS=$($CMD | wc -l)
4213 [ $NUMS -eq $EXPECTED ] ||
4214 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4216 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + 4))
4217 CMD="$LFIND -stripe-size +200k -type f $TDIR"
4218 NUMS=$($CMD | wc -l)
4219 [ $NUMS -eq $EXPECTED ] ||
4220 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4222 CMD="$LFIND -stripe-size -640k -type f $TDIR"
4223 NUMS=$($CMD | wc -l)
4224 [ $NUMS -eq $EXPECTED ] ||
4225 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4228 CMD="$LFIND -stripe-size 256k -type f $TDIR"
4229 NUMS=$($CMD | wc -l)
4230 [ $NUMS -eq $EXPECTED ] ||
4231 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4233 CMD="$LFIND -stripe-size -320k -type f $TDIR"
4234 NUMS=$($CMD | wc -l)
4235 [ $NUMS -eq $EXPECTED ] ||
4236 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4239 CMD="$LFIND -stripe-size 1024k -type f $TDIR"
4240 NUMS=$($CMD | wc -l)
4241 [ $NUMS -eq $EXPECTED ] ||
4242 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4244 run_test 56t "check lfs find -stripe-size works"
4246 test_56u() { # LU-611
4248 setup_56 $NUMFILES $NUMDIRS "-i 0"
4250 if [ $OSTCOUNT -gt 1 ]; then
4251 $SETSTRIPE -i 1 $TDIR/$tfile.{0,1,2,3}
4257 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4258 CMD="$LFIND -stripe-index 0 -type f $TDIR"
4259 NUMS=$($CMD | wc -l)
4260 [ $NUMS -eq $EXPECTED ] ||
4261 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4264 CMD="$LFIND -stripe-index 1 -type f $TDIR"
4265 NUMS=$($CMD | wc -l)
4266 [ $NUMS -eq $EXPECTED ] ||
4267 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4269 CMD="$LFIND ! -stripe-index 0 -type f $TDIR"
4270 NUMS=$($CMD | wc -l)
4271 [ $NUMS -eq $EXPECTED ] ||
4272 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4275 # This should produce an error and not return any files
4276 CMD="$LFIND -stripe-index $OSTCOUNT -type f $TDIR"
4277 NUMS=$($CMD 2>/dev/null | wc -l)
4278 [ $NUMS -eq $EXPECTED ] ||
4279 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4281 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + ONESTRIPE))
4282 CMD="$LFIND -stripe-index 0,1 -type f $TDIR"
4283 NUMS=$($CMD | wc -l)
4284 [ $NUMS -eq $EXPECTED ] ||
4285 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4287 run_test 56u "check lfs find -stripe-index works"
4294 setup_56 $NUMFILES $NUMDIRS
4296 UUID=$(mdtuuid_from_index $MDT_IDX $TDIR)
4297 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT index $MDT_IDX"
4299 for file in $($LFIND -mdt $UUID $TDIR); do
4300 file_mdt_idx=$($GETSTRIPE -M $file)
4301 [ $file_mdt_idx -eq $MDT_IDX ] ||
4302 error "'lfind -mdt $UUID' != 'getstripe -M' ($file_mdt_idx)"
4305 run_test 56v "check 'lfs find -mdt match with lfs getstripe -M' ======="
4307 # Get and check the actual stripe count of one file.
4308 # Usage: check_stripe_count <file> <expected_stripe_count>
4309 check_stripe_count() {
4314 [[ -z "$file" || -z "$expected" ]] &&
4315 error "check_stripe_count: invalid argument!"
4317 local cmd="$GETSTRIPE -c $file"
4318 actual=$($cmd) || error "$cmd failed"
4319 actual=${actual%% *}
4321 if [[ $actual -ne $expected ]]; then
4322 [[ $expected -eq -1 ]] ||
4323 error "$cmd wrong: found $actual, expected $expected"
4324 [[ $actual -eq $OSTCOUNT ]] ||
4325 error "$cmd wrong: found $actual, expected $OSTCOUNT"
4330 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4333 rm -rf $TDIR || error "remove $TDIR failed"
4334 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT"
4337 stripe_size=$($GETSTRIPE -S -d $TDIR) ||
4338 error "$GETSTRIPE -S -d $TDIR failed"
4339 stripe_size=${stripe_size%% *}
4341 local file_size=$((stripe_size * OSTCOUNT))
4342 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
4343 local required_space=$((file_num * file_size))
4344 local free_space=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
4345 [[ $free_space -le $((required_space / 1024)) ]] &&
4346 skip_env "need at least $required_space bytes free space," \
4347 "have $free_space kbytes" && return
4350 local dd_count=$((file_size / dd_bs))
4352 # write data into the files
4356 for i in $(seq 1 $NUMFILES); do
4358 yes | dd bs=$dd_bs count=$dd_count of=$file >/dev/null 2>&1 ||
4359 error "write data into $file failed"
4361 for i in $(seq 1 $NUMDIRS); do
4362 for j in $(seq 1 $NUMFILES); do
4363 file=$TDIR/dir$i/file$j
4364 yes | dd bs=$dd_bs count=$dd_count of=$file \
4366 error "write data into $file failed"
4371 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
4374 local cmd="$LFS_MIGRATE -y -c $expected $TDIR/file1"
4376 eval $cmd || error "$cmd failed"
4378 check_stripe_count $TDIR/file1 $expected
4381 cmd="$LFS_MIGRATE -y -c $expected $TDIR/dir1"
4383 eval $cmd || error "$cmd failed"
4385 for j in $(seq 1 $NUMFILES); do
4386 check_stripe_count $TDIR/dir1/file$j $expected
4389 # lfs_migrate works with lfs find
4390 cmd="$LFIND -stripe_count $OSTCOUNT -type f $TDIR |
4391 $LFS_MIGRATE -y -c $expected"
4393 eval $cmd || error "$cmd failed"
4395 for i in $(seq 2 $NUMFILES); do
4396 check_stripe_count $TDIR/file$i $expected
4398 for i in $(seq 2 $NUMDIRS); do
4399 for j in $(seq 1 $NUMFILES); do
4400 check_stripe_count $TDIR/dir$i/file$j $expected
4404 run_test 56w "check lfs_migrate -c stripe_count works"
4407 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4408 # note test will not do anything if MDS is not local
4409 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4410 skip "Only applicable to ldiskfs-based MDTs"
4414 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4415 local MNTDEV="osd*.*MDT*.mntdev"
4416 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
4417 [ -z "$DEV" ] && error "can't access $MNTDEV"
4418 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
4419 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
4420 error "can't access $DEV"
4421 DEVISIZE=`awk '/Inode size:/ { print $3 }' $TMP/t57a.dump`
4422 [ "$DEVISIZE" -gt 128 ] || error "inode size $DEVISIZE"
4426 run_test 57a "verify MDS filesystem created with large inodes =="
4429 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4430 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4431 skip "Only applicable to ldiskfs-based MDTs"
4435 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4440 local FILEN=$dir/f$FILECOUNT
4442 rm -rf $dir || error "removing $dir"
4443 test_mkdir -p $dir || error "creating $dir"
4444 local num=$(get_mds_dir $dir)
4447 echo "mcreating $FILECOUNT files"
4448 createmany -m $dir/f 1 $FILECOUNT || \
4449 error "creating files in $dir"
4451 # verify that files do not have EAs yet
4452 $GETSTRIPE $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
4453 $GETSTRIPE $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
4457 df $dir #make sure we get new statfs data
4458 local MDSFREE=$(do_facet $mymds \
4459 lctl get_param -n osd*.*MDT000$((num -1)).kbytesfree)
4460 local MDCFREE=$(lctl get_param -n mdc.*MDT000$((num -1))-mdc-*.kbytesfree)
4461 echo "opening files to create objects/EAs"
4463 for FILE in `seq -f $dir/f%g 1 $FILECOUNT`; do
4464 $OPENFILE -f O_RDWR $FILE > /dev/null 2>&1 || error "opening $FILE"
4467 # verify that files have EAs now
4468 $GETSTRIPE $FILE1 | grep -q "obdidx" || error "$FILE1 missing EA"
4469 $GETSTRIPE $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
4471 sleep 1 #make sure we get new statfs data
4473 local MDSFREE2=$(do_facet $mymds \
4474 lctl get_param -n osd*.*MDT000$((num -1)).kbytesfree)
4475 local MDCFREE2=$(lctl get_param -n mdc.*MDT000$((num -1))-mdc-*.kbytesfree)
4476 if [ "$MDCFREE2" -lt "$((MDCFREE - 8))" ]; then
4477 if [ "$MDSFREE" != "$MDSFREE2" ]; then
4478 error "MDC before $MDCFREE != after $MDCFREE2"
4480 echo "MDC before $MDCFREE != after $MDCFREE2"
4481 echo "unable to confirm if MDS has large inodes"
4486 run_test 57b "default LOV EAs are stored inside large inodes ==="
4489 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4490 [ -z "$(which wiretest 2>/dev/null)" ] &&
4491 skip_env "could not find wiretest" && return
4494 run_test 58 "verify cross-platform wire constants =============="
4497 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4498 echo "touch 130 files"
4499 createmany -o $DIR/f59- 130
4501 unlinkmany $DIR/f59- 130
4503 # wait for commitment of removal
4504 wait_delete_completed
4506 run_test 59 "verify cancellation of llog records async ========="
4508 TEST60_HEAD="test_60 run $RANDOM"
4510 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4511 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
4512 [ ! -f run-llog.sh ] && skip_env "missing subtest run-llog.sh" && return
4513 log "$TEST60_HEAD - from kernel mode"
4514 do_facet mgs sh run-llog.sh
4516 run_test 60a "llog sanity tests run from kernel module =========="
4518 test_60b() { # bug 6411
4519 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4521 LLOG_COUNT=`dmesg | awk "/$TEST60_HEAD/{marker = 1; from_marker = 0;}
4533 [ $LLOG_COUNT -gt 50 ] && error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)"|| true
4535 run_test 60b "limit repeated messages from CERROR/CWARN ========"
4538 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4539 echo "create 5000 files"
4540 createmany -o $DIR/f60c- 5000
4541 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
4542 lctl set_param fail_loc=0x80000137
4543 unlinkmany $DIR/f60c- 5000
4544 lctl set_param fail_loc=0
4546 run_test 60c "unlink file when mds full"
4549 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4550 SAVEPRINTK=$(lctl get_param -n printk)
4552 # verify "lctl mark" is even working"
4553 MESSAGE="test message ID $RANDOM $$"
4554 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
4555 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
4557 lctl set_param printk=0 || error "set lnet.printk failed"
4558 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
4559 MESSAGE="new test message ID $RANDOM $$"
4560 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
4561 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
4562 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
4564 lctl set_param -n printk="$SAVEPRINTK"
4566 run_test 60d "test printk console message masking"
4569 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4571 dd if=/dev/zero of=$f bs=`page_size` count=1
4572 cancel_lru_locks osc
4573 $MULTIOP $f OSMWUc || error
4576 run_test 61 "mmap() writes don't make sync hang ================"
4578 # bug 2330 - insufficient obd_match error checking causes LBUG
4580 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4583 cancel_lru_locks osc
4584 lctl set_param fail_loc=0x405
4585 cat $f && error "cat succeeded, expect -EIO"
4586 lctl set_param fail_loc=0
4588 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
4589 # match every page all of the time.
4590 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
4592 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
4593 test_63a() { # was test_63
4594 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4595 MAX_DIRTY_MB=`lctl get_param -n osc.*.max_dirty_mb | head -n 1`
4596 lctl set_param -n osc.*.max_dirty_mb 0
4597 for i in `seq 10` ; do
4598 dd if=/dev/zero of=$DIR/f63 bs=8k &
4604 lctl set_param -n osc.*.max_dirty_mb $MAX_DIRTY_MB
4605 rm -f $DIR/f63 || true
4607 run_test 63a "Verify oig_wait interruption does not crash ======="
4609 # bug 2248 - async write errors didn't return to application on sync
4610 # bug 3677 - async write errors left page locked
4612 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4614 lctl set_param debug=-1
4616 # ensure we have a grant to do async writes
4617 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
4620 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
4621 lctl set_param fail_loc=0x80000406
4622 $MULTIOP $DIR/$tfile Owy && \
4623 error "sync didn't return ENOMEM"
4624 sync; sleep 2; sync # do a real sync this time to flush page
4625 lctl get_param -n llite.*.dump_page_cache | grep locked && \
4626 error "locked page left in cache after async error" || true
4629 run_test 63b "async write errors should be returned to fsync ==="
4632 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4634 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
4636 run_test 64a "verify filter grant calculations (in kernel) ====="
4639 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4640 [ ! -f oos.sh ] && skip_env "missing subtest oos.sh" && return
4643 run_test 64b "check out-of-space detection on client ==========="
4646 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
4648 run_test 64c "verify grant shrink ========================------"
4650 # bug 1414 - set/get directories' stripe info
4652 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4653 test_mkdir -p $DIR/$tdir
4655 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
4657 run_test 65a "directory with no stripe info ===================="
4660 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4661 test_mkdir -p $DIR/$tdir
4662 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
4665 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
4667 run_test 65b "directory setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1"
4670 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4671 if [ $OSTCOUNT -gt 1 ]; then
4672 test_mkdir -p $DIR/$tdir
4673 $SETSTRIPE -S $(($STRIPESIZE * 4)) -i 1 \
4674 -c $(($OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
4676 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
4679 run_test 65c "directory setstripe -S $((STRIPESIZE*4)) -i 1 -c $((OSTCOUNT-1))"
4682 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4683 test_mkdir -p $DIR/$tdir
4684 if [ $STRIPECOUNT -le 0 ]; then
4686 elif [ $STRIPECOUNT -gt 2000 ]; then
4687 #LOV_MAX_STRIPE_COUNT is 2000
4688 [ $OSTCOUNT -gt 2000 ] && sc=2000 || sc=$(($OSTCOUNT - 1))
4690 sc=$(($STRIPECOUNT - 1))
4692 $SETSTRIPE -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
4693 touch $DIR/$tdir/f4 $DIR/$tdir/f5
4694 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
4695 error "lverify failed"
4697 run_test 65d "directory setstripe -S $STRIPESIZE -c stripe_count"
4700 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4701 test_mkdir -p $DIR/$tdir
4703 $SETSTRIPE $DIR/$tdir || error "setstripe"
4704 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
4705 error "no stripe info failed"
4707 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
4709 run_test 65e "directory setstripe defaults ======================="
4712 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4713 test_mkdir -p $DIR/${tdir}f
4714 $RUNAS $SETSTRIPE $DIR/${tdir}f && error "setstripe succeeded" || true
4716 run_test 65f "dir setstripe permission (should return error) ==="
4719 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4720 test_mkdir -p $DIR/$tdir
4721 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
4723 $SETSTRIPE -d $DIR/$tdir || error "setstripe"
4724 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
4725 error "delete default stripe failed"
4727 run_test 65g "directory setstripe -d ==========================="
4730 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4731 test_mkdir -p $DIR/$tdir
4732 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
4734 test_mkdir -p $DIR/$tdir/dd1
4735 [ $($GETSTRIPE -c $DIR/$tdir) == $($GETSTRIPE -c $DIR/$tdir/dd1) ] ||
4736 error "stripe info inherit failed"
4738 run_test 65h "directory stripe info inherit ===================="
4740 test_65i() { # bug6367
4741 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4742 $SETSTRIPE -S 65536 -c -1 $MOUNT
4744 run_test 65i "set non-default striping on root directory (bug 6367)="
4746 test_65ia() { # bug12836
4747 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4748 $GETSTRIPE $MOUNT || error "getstripe $MOUNT failed"
4750 run_test 65ia "getstripe on -1 default directory striping"
4752 test_65ib() { # bug12836
4753 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4754 $GETSTRIPE -v $MOUNT || error "getstripe -v $MOUNT failed"
4756 run_test 65ib "getstripe -v on -1 default directory striping"
4758 test_65ic() { # bug12836
4759 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4760 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
4762 run_test 65ic "new find on -1 default directory striping"
4764 test_65j() { # bug6367
4765 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4767 # if we aren't already remounting for each test, do so for this test
4768 if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
4769 cleanup || error "failed to unmount"
4772 $SETSTRIPE -d $MOUNT || error "setstripe failed"
4774 run_test 65j "set default striping on root directory (bug 6367)="
4776 test_65k() { # bug11679
4777 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4778 [ "$OSTCOUNT" -lt 2 ] && skip_env "too few OSTs" && return
4779 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4781 echo "Check OST status: "
4782 local MDS_OSCS=`do_facet $SINGLEMDS lctl dl |
4783 awk '/[oO][sS][cC].*md[ts]/ { print $4 }'`
4785 for OSC in $MDS_OSCS; do
4786 echo $OSC "is activate"
4787 do_facet $SINGLEMDS lctl --device %$OSC activate
4791 for INACTIVE_OSC in $MDS_OSCS; do
4792 echo "Deactivate: " $INACTIVE_OSC
4793 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
4794 for STRIPE_OSC in $MDS_OSCS; do
4795 OST=`osc_to_ost $STRIPE_OSC`
4796 IDX=`do_facet $SINGLEMDS lctl get_param -n lov.*md*.target_obd |
4797 awk -F: /$OST/'{ print $1 }' | head -n 1`
4799 [ -f $DIR/$tdir/$IDX ] && continue
4800 echo "$SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX"
4801 $SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX
4803 [ $RC -ne 0 ] && error "setstripe should have succeeded"
4806 echo $INACTIVE_OSC "is Activate."
4807 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
4810 run_test 65k "validate manual striping works properly with deactivated OSCs"
4812 test_65l() { # bug 12836
4813 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4814 test_mkdir -p $DIR/$tdir/test_dir
4815 $SETSTRIPE -c -1 $DIR/$tdir/test_dir
4816 $LFS find -mtime -1 $DIR/$tdir >/dev/null
4818 run_test 65l "lfs find on -1 stripe dir ========================"
4820 # bug 2543 - update blocks count on client
4822 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4824 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
4825 sync; sync_all_data; sync; sync_all_data
4826 cancel_lru_locks osc
4827 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
4828 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
4830 run_test 66 "update inode blocks count on client ==============="
4835 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4837 if [ ! -z "$LLOOP" ]; then
4838 if swapon -s | grep -q $LLOOP; then
4839 swapoff $LLOOP || error "swapoff failed"
4842 $LCTL blockdev_detach $LLOOP || error "detach failed"
4846 if [ ! -z "$LLITELOOPLOAD" ]; then
4854 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
4858 swapon -s | awk '($1 == "'$1'") { print $4 }'
4861 # test case for lloop driver, basic function
4863 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4864 [ "$UID" != 0 ] && skip_env "must run as root" && return
4865 llite_lloop_enabled || \
4866 { skip_env "llite_lloop module disabled" && return; }
4868 trap cleanup_68 EXIT
4870 if ! module_loaded llite_lloop; then
4871 if load_module llite/llite_lloop; then
4874 skip_env "can't find module llite_lloop"
4879 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
4880 dd if=/dev/zero of=$DIR/f68a bs=4k count=1024
4881 $LCTL blockdev_attach $DIR/f68a $LLOOP || error "attach failed"
4883 directio rdwr $LLOOP 0 1024 4096 || error "direct write failed"
4884 directio rdwr $LLOOP 0 1025 4096 && error "direct write should fail"
4888 run_test 68a "lloop driver - basic test ========================"
4890 # excercise swapping to lustre by adding a high priority swapfile entry
4891 # and then consuming memory until it is used.
4892 test_68b() { # was test_68
4893 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4894 [ "$UID" != 0 ] && skip_env "must run as root" && return
4895 lctl get_param -n devices | grep -q obdfilter && \
4896 skip "local OST" && return
4898 grep -q llite_lloop /proc/modules
4899 [ $? -ne 0 ] && skip "can't find module llite_lloop" && return
4901 [ -z "`$LCTL list_nids | grep -v tcp`" ] && \
4902 skip "can't reliably test swap with TCP" && return
4904 MEMTOTAL=`meminfo MemTotal`
4905 NR_BLOCKS=$((MEMTOTAL>>8))
4906 [[ $NR_BLOCKS -le 2048 ]] && NR_BLOCKS=2048
4908 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
4909 dd if=/dev/zero of=$DIR/f68b bs=64k seek=$NR_BLOCKS count=1
4912 $LCTL blockdev_attach $DIR/f68b $LLOOP || error "attach failed"
4914 trap cleanup_68 EXIT
4916 swapon -p 32767 $LLOOP || error "swapon $LLOOP failed"
4918 echo "before: `swapon -s | grep $LLOOP`"
4919 $MEMHOG $MEMTOTAL || error "error allocating $MEMTOTAL kB"
4920 echo "after: `swapon -s | grep $LLOOP`"
4921 SWAPUSED=`swap_used $LLOOP`
4925 [ $SWAPUSED -eq 0 ] && echo "no swap used???" || true
4927 run_test 68b "support swapping to Lustre ========================"
4929 # bug5265, obdfilter oa2dentry return -ENOENT
4930 # #define OBD_FAIL_OST_ENOENT 0x217
4932 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4933 remote_ost_nodsh && skip "remote OST with nodsh" && return
4936 $SETSTRIPE -c 1 -i 0 $f
4938 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
4940 do_facet ost1 lctl set_param fail_loc=0x217
4941 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
4942 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
4944 do_facet ost1 lctl set_param fail_loc=0
4945 $DIRECTIO write $f 0 2 || error "write error"
4947 cancel_lru_locks osc
4948 $DIRECTIO read $f 0 1 || error "read error"
4950 do_facet ost1 lctl set_param fail_loc=0x217
4951 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
4953 do_facet ost1 lctl set_param fail_loc=0
4956 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
4959 test_mkdir -p $DIR/$tdir
4960 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
4962 run_test 71 "Running dbench on lustre (don't segment fault) ===="
4964 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
4965 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4966 check_kernel_version 43 || return 0
4967 [ "$RUNAS_ID" = "$UID" ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4969 # Check that testing environment is properly set up. Skip if not
4970 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS || {
4971 skip_env "User $RUNAS_ID does not exist - skipping"
4974 # We had better clear the $DIR to get enough space for dd
4979 $RUNAS dd if=/dev/zero of=$DIR/f72 bs=512 count=1 || error
4980 # See if we are still setuid/sgid
4981 test -u $DIR/f72 -o -g $DIR/f72 && error "S/gid is not dropped on write"
4982 # Now test that MDS is updated too
4983 cancel_lru_locks mdc
4984 test -u $DIR/f72 -o -g $DIR/f72 && error "S/gid is not dropped on MDS"
4987 run_test 72a "Test that remove suid works properly (bug5695) ===="
4989 test_72b() { # bug 24226 -- keep mode setting when size is not changing
4992 [ "$RUNAS_ID" = "$UID" ] && \
4993 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4994 [ "$RUNAS_ID" -eq 0 ] && \
4995 skip_env "RUNAS_ID = 0 -- skipping" && return
4997 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4998 # Check that testing environment is properly set up. Skip if not
4999 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS || {
5000 skip_env "User $RUNAS_ID does not exist - skipping"
5003 touch $DIR/${tfile}-f{g,u}
5004 test_mkdir $DIR/${tfile}-dg
5005 test_mkdir $DIR/${tfile}-du
5006 chmod 770 $DIR/${tfile}-{f,d}{g,u}
5007 chmod g+s $DIR/${tfile}-{f,d}g
5008 chmod u+s $DIR/${tfile}-{f,d}u
5009 for perm in 777 2777 4777; do
5010 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
5011 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
5012 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
5013 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
5017 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
5019 # bug 3462 - multiple simultaneous MDC requests
5021 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5022 test_mkdir $DIR/d73-1
5023 test_mkdir $DIR/d73-2
5024 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
5027 lctl set_param fail_loc=0x80000129
5028 $MULTIOP $DIR/d73-1/f73-2 Oc &
5030 lctl set_param fail_loc=0
5032 $MULTIOP $DIR/d73-2/f73-3 Oc &
5036 wait $pid1 || return 1
5040 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
5041 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
5042 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
5046 run_test 73 "multiple MDC requests (should not deadlock)"
5048 test_74a() { # bug 6149, 6184
5049 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5050 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
5052 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
5053 # will spin in a tight reconnection loop
5055 lctl set_param fail_loc=0x8000030e
5056 # get any lock that won't be difficult - lookup works.
5058 lctl set_param fail_loc=0
5062 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
5064 test_74b() { # bug 13310
5065 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5066 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
5068 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
5069 # will spin in a tight reconnection loop
5070 lctl set_param fail_loc=0x8000030e
5071 # get a "difficult" lock
5073 lctl set_param fail_loc=0
5077 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
5080 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5081 #define OBD_FAIL_LDLM_NEW_LOCK
5082 lctl set_param fail_loc=0x80000319
5083 touch $DIR/$tfile && error "Touch successful"
5086 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
5089 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
5092 get_inode_slab_tunables() {
5093 awk '/lustre_inode_cache/ {print $9," ",$10," ",$11; exit}' /proc/slabinfo
5096 set_inode_slab_tunables() {
5097 echo "lustre_inode_cache $1" > /proc/slabinfo
5100 test_76() { # Now for bug 20433, added originally in bug 1443
5101 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5102 local SLAB_SETTINGS=`get_inode_slab_tunables`
5103 local CPUS=`getconf _NPROCESSORS_ONLN`
5104 # we cannot set limit below 1 which means 1 inode in each
5105 # per-cpu cache is still allowed
5106 set_inode_slab_tunables "1 1 0"
5107 cancel_lru_locks osc
5108 BEFORE_INODES=`num_inodes`
5109 echo "before inodes: $BEFORE_INODES"
5111 [ "$SLOW" = "no" ] && COUNT=100
5112 for i in `seq $COUNT`; do
5116 cancel_lru_locks osc
5117 AFTER_INODES=`num_inodes`
5118 echo "after inodes: $AFTER_INODES"
5120 while [ $((AFTER_INODES-1*CPUS)) -gt $BEFORE_INODES ]; do
5122 AFTER_INODES=`num_inodes`
5124 echo "wait $wait seconds inodes: $AFTER_INODES"
5125 if [ $wait -gt 30 ]; then
5126 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
5129 set_inode_slab_tunables "$SLAB_SETTINGS"
5131 run_test 76 "confirm clients recycle inodes properly ===="
5137 # Note: in sptlrpc modes which enable its own bulk checksum, the
5138 # original crc32_le bulk checksum will be automatically disabled,
5139 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
5140 # will be checked by sptlrpc code against sptlrpc bulk checksum.
5141 # In this case set_checksums() will not be no-op, because sptlrpc
5142 # bulk checksum will be enabled all through the test.
5144 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
5145 lctl set_param -n osc.*.checksums $1
5149 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
5150 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
5151 CKSUM_TYPES=${CKSUM_TYPES:-"crc32 adler"}
5152 [ "$ORIG_CSUM_TYPE" = "crc32c" ] && CKSUM_TYPES="$CKSUM_TYPES crc32c"
5155 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
5156 log "set checksum type to $1"
5159 F77_TMP=$TMP/f77-temp
5162 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
5163 error "error writing to $F77_TMP"
5166 test_77a() { # bug 10889
5167 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5168 $GSS && skip "could not run with gss" && return
5169 [ ! -f $F77_TMP ] && setup_f77
5171 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
5175 run_test 77a "normal checksum read/write operation ============="
5177 test_77b() { # bug 10889
5178 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5179 $GSS && skip "could not run with gss" && return
5180 [ ! -f $F77_TMP ] && setup_f77
5181 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5182 lctl set_param fail_loc=0x80000409
5184 dd if=$F77_TMP of=$DIR/f77b bs=1M count=$F77SZ conv=sync || \
5185 error "dd error: $?"
5186 lctl set_param fail_loc=0
5189 run_test 77b "checksum error on client write ===================="
5191 test_77c() { # bug 10889
5192 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5193 $GSS && skip "could not run with gss" && return
5194 [ ! -f $DIR/f77b ] && skip "requires 77b - skipping" && return
5196 for algo in $CKSUM_TYPES; do
5197 cancel_lru_locks osc
5198 set_checksum_type $algo
5199 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
5200 lctl set_param fail_loc=0x80000408
5201 cmp $F77_TMP $DIR/f77b || error "file compare failed"
5202 lctl set_param fail_loc=0
5205 set_checksum_type $ORIG_CSUM_TYPE
5208 run_test 77c "checksum error on client read ==================="
5210 test_77d() { # bug 10889
5211 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5212 $GSS && skip "could not run with gss" && return
5213 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5214 lctl set_param fail_loc=0x80000409
5216 directio write $DIR/f77 0 $F77SZ $((1024 * 1024)) || \
5217 error "direct write: rc=$?"
5218 lctl set_param fail_loc=0
5221 run_test 77d "checksum error on OST direct write ==============="
5223 test_77e() { # bug 10889
5224 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5225 $GSS && skip "could not run with gss" && return
5226 [ ! -f $DIR/f77 ] && skip "requires 77d - skipping" && return
5227 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
5228 lctl set_param fail_loc=0x80000408
5230 cancel_lru_locks osc
5231 directio read $DIR/f77 0 $F77SZ $((1024 * 1024)) || \
5232 error "direct read: rc=$?"
5233 lctl set_param fail_loc=0
5236 run_test 77e "checksum error on OST direct read ================"
5238 test_77f() { # bug 10889
5239 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5240 $GSS && skip "could not run with gss" && return
5242 for algo in $CKSUM_TYPES; do
5243 cancel_lru_locks osc
5244 set_checksum_type $algo
5245 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5246 lctl set_param fail_loc=0x409
5247 directio write $DIR/f77 0 $F77SZ $((1024 * 1024)) && \
5248 error "direct write succeeded"
5249 lctl set_param fail_loc=0
5251 set_checksum_type $ORIG_CSUM_TYPE
5254 run_test 77f "repeat checksum error on write (expect error) ===="
5256 test_77g() { # bug 10889
5257 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5258 $GSS && skip "could not run with gss" && return
5259 remote_ost_nodsh && skip "remote OST with nodsh" && return
5261 [ ! -f $F77_TMP ] && setup_f77
5263 $SETSTRIPE -c 1 -i 0 $DIR/f77g
5264 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
5265 do_facet ost1 lctl set_param fail_loc=0x8000021a
5267 dd if=$F77_TMP of=$DIR/f77g bs=1M count=$F77SZ || \
5268 error "write error: rc=$?"
5269 do_facet ost1 lctl set_param fail_loc=0
5272 run_test 77g "checksum error on OST write ======================"
5274 test_77h() { # bug 10889
5275 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5276 $GSS && skip "could not run with gss" && return
5277 remote_ost_nodsh && skip "remote OST with nodsh" && return
5279 [ ! -f $DIR/f77g ] && skip "requires 77g - skipping" && return
5280 cancel_lru_locks osc
5281 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
5282 do_facet ost1 lctl set_param fail_loc=0x8000021b
5284 cmp $F77_TMP $DIR/f77g || error "file compare failed"
5285 do_facet ost1 lctl set_param fail_loc=0
5288 run_test 77h "checksum error on OST read ======================="
5290 test_77i() { # bug 13805
5291 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5292 $GSS && skip "could not run with gss" && return
5293 #define OBD_FAIL_OSC_CONNECT_CKSUM 0x40b
5294 lctl set_param fail_loc=0x40b
5295 remount_client $MOUNT
5296 lctl set_param fail_loc=0
5297 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
5298 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
5299 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
5300 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
5302 remount_client $MOUNT
5304 run_test 77i "client not supporting OSD_CONNECT_CKSUM =========="
5306 test_77j() { # bug 13805
5307 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5308 $GSS && skip "could not run with gss" && return
5309 #define OBD_FAIL_OSC_CKSUM_ADLER_ONLY 0x40c
5310 lctl set_param fail_loc=0x40c
5311 remount_client $MOUNT
5312 lctl set_param fail_loc=0
5313 sleep 2 # wait async osc connect to finish
5314 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
5315 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
5316 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
5317 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
5319 remount_client $MOUNT
5321 run_test 77j "client only supporting ADLER32 ===================="
5323 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
5327 test_78() { # bug 10901
5328 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5329 remote_ost || { skip_env "local OST" && return; }
5332 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
5333 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
5334 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
5335 echo "MemTotal: $MEMTOTAL"
5336 # reserve 256MB of memory for the kernel and other running processes,
5337 # and then take 1/2 of the remaining memory for the read/write buffers.
5338 if [ $MEMTOTAL -gt 512 ] ;then
5339 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
5341 # for those poor memory-starved high-end clusters...
5342 MEMTOTAL=$((MEMTOTAL / 2))
5344 echo "Mem to use for directio: $MEMTOTAL"
5345 [ $F78SIZE -gt $MEMTOTAL ] && F78SIZE=$MEMTOTAL
5346 [ $F78SIZE -gt 512 ] && F78SIZE=512
5347 [ $F78SIZE -gt $((MAXFREE / 1024)) ] && F78SIZE=$((MAXFREE / 1024))
5348 SMALLESTOST=`lfs df $DIR |grep OST | awk '{print $4}' |sort -n |head -1`
5349 echo "Smallest OST: $SMALLESTOST"
5350 [ $SMALLESTOST -lt 10240 ] && \
5351 skip "too small OSTSIZE, useless to run large O_DIRECT test" && return 0
5353 [ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ] && \
5354 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
5356 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
5357 echo "File size: $F78SIZE"
5358 $SETSTRIPE -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
5359 for i in `seq 1 $NSEQ`
5361 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
5362 echo directIO rdwr round $i of $NSEQ
5363 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
5368 run_test 78 "handle large O_DIRECT writes correctly ============"
5370 test_79() { # bug 12743
5371 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5372 wait_delete_completed
5374 BKTOTAL=$(calc_osc_kbytes kbytestotal)
5375 BKFREE=$(calc_osc_kbytes kbytesfree)
5376 BKAVAIL=$(calc_osc_kbytes kbytesavail)
5378 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
5379 DFTOTAL=`echo $STRING | cut -d, -f1`
5380 DFUSED=`echo $STRING | cut -d, -f2`
5381 DFAVAIL=`echo $STRING | cut -d, -f3`
5382 DFFREE=$(($DFTOTAL - $DFUSED))
5384 ALLOWANCE=$((64 * $OSTCOUNT))
5386 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
5387 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
5388 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
5390 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
5391 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
5392 error "df free($DFFREE) mismatch OST free($BKFREE)"
5394 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
5395 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
5396 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
5399 run_test 79 "df report consistency check ======================="
5401 test_80() { # bug 10718
5402 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5403 # relax strong synchronous semantics for slow backends like ZFS
5404 local soc="obdfilter.*.sync_on_lock_cancel"
5405 local soc_old=$(do_facet ost1 lctl get_param -n $soc | head -n1)
5407 if [ "$soc_old" != "never" -a "$(facet_fstype ost1)" != "ldiskfs" ]; then
5408 hosts=$(for host in $(seq -f "ost%g" 1 $OSTCOUNT); do
5409 facet_active_host $host; done | sort -u)
5410 do_nodes $hosts lctl set_param $soc=never
5413 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
5415 local BEFORE=`date +%s`
5416 cancel_lru_locks osc
5417 local AFTER=`date +%s`
5418 local DIFF=$((AFTER-BEFORE))
5419 if [ $DIFF -gt 1 ] ; then
5420 error "elapsed for 1M@1T = $DIFF"
5423 [ -n "$hosts" ] && do_nodes $hosts lctl set_param $soc=$soc_old
5427 run_test 80 "Page eviction is equally fast at high offsets too ===="
5429 test_81a() { # LU-456
5430 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5431 remote_ost_nodsh && skip "remote OST with nodsh" && return
5432 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
5433 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
5434 do_facet ost1 lctl set_param fail_loc=0x80000228
5436 # write should trigger a retry and success
5437 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
5438 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
5440 if [ $RC -ne 0 ] ; then
5441 error "write should success, but failed for $RC"
5444 run_test 81a "OST should retry write when get -ENOSPC ==============="
5446 test_81b() { # LU-456
5447 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5448 remote_ost_nodsh && skip "remote OST with nodsh" && return
5449 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
5450 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
5451 do_facet ost1 lctl set_param fail_loc=0x228
5453 # write should retry several times and return -ENOSPC finally
5454 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
5455 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
5458 if [ $RC -ne $ENOSPC ] ; then
5459 error "dd should fail for -ENOSPC, but succeed."
5462 run_test 81b "OST should return -ENOSPC when retry still fails ======="
5464 test_82() { # LU-1031
5465 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10
5469 multiop_bg_pause $DIR/$tfile OG${gid1}_g${gid1}c || return 1
5471 multiop_bg_pause $DIR/$tfile O_G${gid2}r10g${gid2}c || return 2
5473 kill -USR1 $MULTIPID2
5475 if [[ `ps h -o comm -p $MULTIPID2` == "" ]]; then
5476 error "First grouplock does not block second one"
5478 echo "Second grouplock blocks first one"
5480 kill -USR1 $MULTIPID1
5484 run_test 82 "Basic grouplock test ==============================="
5487 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && \
5489 test_mkdir -p $DIR/d99cvsroot
5490 chown $RUNAS_ID $DIR/d99cvsroot
5491 local oldPWD=$PWD # bug 13584, use $TMP as working dir
5494 $RUNAS cvs -d $DIR/d99cvsroot init || error
5497 run_test 99a "cvs init ========================================="
5500 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5501 [ ! -d $DIR/d99cvsroot ] && test_99a
5503 # some versions of cvs import exit(1) when asked to import links or
5504 # files they can't read. ignore those files.
5505 TOIGNORE=$(find . -type l -printf '-I %f\n' -o \
5506 ! -perm +4 -printf '-I %f\n')
5507 $RUNAS cvs -d $DIR/d99cvsroot import -m "nomesg" $TOIGNORE \
5508 d99reposname vtag rtag
5510 run_test 99b "cvs import ======================================="
5513 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5514 [ ! -d $DIR/d99cvsroot ] && test_99b
5516 test_mkdir -p $DIR/d99reposname
5517 chown $RUNAS_ID $DIR/d99reposname
5518 $RUNAS cvs -d $DIR/d99cvsroot co d99reposname
5520 run_test 99c "cvs checkout ====================================="
5523 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5524 [ ! -d $DIR/d99cvsroot ] && test_99c
5525 cd $DIR/d99reposname
5527 $RUNAS cvs add -m 'addmsg' foo99
5529 run_test 99d "cvs add =========================================="
5532 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5533 [ ! -d $DIR/d99cvsroot ] && test_99c
5534 cd $DIR/d99reposname
5537 run_test 99e "cvs update ======================================="
5540 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5541 [ ! -d $DIR/d99cvsroot ] && test_99d
5542 cd $DIR/d99reposname
5543 $RUNAS cvs commit -m 'nomsg' foo99
5544 rm -fr $DIR/d99cvsroot
5546 run_test 99f "cvs commit ======================================="
5549 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5550 [ "$NETTYPE" = tcp ] || \
5551 { skip "TCP secure port test, not useful for NETTYPE=$NETTYPE" && \
5554 remote_ost_nodsh && skip "remote OST with nodsh" && return
5555 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5557 { skip "useless for local single node setup" && return; }
5559 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
5560 [ "$PROT" != "tcp" ] && continue
5561 RPORT=$(echo $REMOTE | cut -d: -f2)
5562 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
5565 LPORT=`echo $LOCAL | cut -d: -f2`
5566 if [ $LPORT -ge 1024 ]; then
5567 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
5569 error_exit "local: $LPORT > 1024, remote: $RPORT"
5572 [ "$rc" = 0 ] || error_exit "privileged port not found" )
5574 run_test 100 "check local port using privileged port ==========="
5576 function get_named_value()
5585 echo $line | sed "s/^$tag[ ]*//"
5592 export CACHE_MAX=$($LCTL get_param -n llite.*.max_cached_mb |
5593 awk '/^max_cached_mb/ { print $2 }')
5596 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
5601 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5605 local cache_limit=32
5607 $LCTL set_param -n osc.*-osc*.rpc_stats 0
5608 trap cleanup_101a EXIT
5609 $LCTL set_param -n llite.*.read_ahead_stats 0
5610 $LCTL set_param -n llite.*.max_cached_mb $cache_limit
5613 # randomly read 10000 of 64K chunks from file 3x 32MB in size
5615 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
5616 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
5619 for s in `$LCTL get_param -n llite.*.read_ahead_stats | \
5620 get_named_value 'read but discarded' | cut -d" " -f1`; do
5621 discard=$(($discard + $s))
5625 if [ $(($discard * 10)) -gt $nreads ] ;then
5626 $LCTL get_param osc.*-osc*.rpc_stats
5627 $LCTL get_param llite.*.read_ahead_stats
5628 error "too many ($discard) discarded pages"
5630 rm -f $DIR/$tfile || true
5632 run_test 101a "check read-ahead for random reads ================"
5635 test_mkdir -p $DIR/$tdir
5637 STRIPE_COUNT=$OSTCOUNT
5640 local list=$(comma_list $(osts_nodes))
5641 set_osd_param $list '' read_cache_enable 0
5642 set_osd_param $list '' writethrough_cache_enable 0
5644 trap cleanup_test101bc EXIT
5645 # prepare the read-ahead file
5646 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
5648 dd if=/dev/zero of=$DIR/$tfile bs=1024k count=100 2> /dev/null
5651 cleanup_test101bc() {
5656 local list=$(comma_list $(osts_nodes))
5657 set_osd_param $list '' read_cache_enable 1
5658 set_osd_param $list '' writethrough_cache_enable 1
5662 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
5667 local STRIPE_SIZE=1048576
5668 local RA_INC=1048576
5669 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
5670 local FILE_LENGTH=$((64*100))
5671 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
5672 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
5673 DISCARD=`$LCTL get_param -n llite.*.read_ahead_stats | \
5674 get_named_value 'read but discarded' | \
5675 cut -d" " -f1 | calc_total`
5676 if [ $DISCARD -gt $discard_limit ]; then
5677 $LCTL get_param llite.*.read_ahead_stats
5678 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
5680 echo "Read-ahead success for size ${READ_SIZE}"
5685 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5686 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping stride IO stride-ahead test" && return
5687 local STRIPE_SIZE=1048576
5688 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
5689 local FILE_LENGTH=$((STRIPE_SIZE*100))
5690 local ITERATION=$((FILE_LENGTH/STRIDE_SIZE))
5691 # prepare the read-ahead file
5693 cancel_lru_locks osc
5694 for BIDX in 2 4 8 16 32 64 128 256
5696 local BSIZE=$((BIDX*4096))
5697 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
5698 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
5699 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
5700 $LCTL set_param -n llite.*.read_ahead_stats 0
5701 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
5702 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
5703 cancel_lru_locks osc
5709 run_test 101b "check stride-io mode read-ahead ================="
5712 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5713 local STRIPE_SIZE=1048576
5714 local FILE_LENGTH=$((STRIPE_SIZE*100))
5720 cancel_lru_locks osc
5721 $LCTL set_param osc.*.rpc_stats 0
5722 $READS -f $DIR/$tfile -s$FILE_LENGTH -b65536 -n$nreads -t 180
5723 for osc in $($LCTL get_param -N osc.*); do
5724 if [ "$osc" == "osc.num_refs" ]; then
5728 local lines=$($LCTL get_param -n ${osc}.rpc_stats | wc | awk '{print $1}')
5729 if [ $lines -le 20 ]; then
5733 local rpc4k=$($LCTL get_param -n ${osc}.rpc_stats |
5734 awk '$1 == "1:" { print $2; exit; }')
5735 local rpc8k=$($LCTL get_param -n ${osc}.rpc_stats |
5736 awk '$1 == "2:" { print $2; exit; }')
5737 local rpc16k=$($LCTL get_param -n ${osc}.rpc_stats |
5738 awk '$1 == "4:" { print $2; exit; }')
5739 local rpc32k=$($LCTL get_param -n ${osc}.rpc_stats |
5740 awk '$1 == "8:" { print $2; exit; }')
5742 [ $rpc4k != 0 ] && error "Small 4k read IO ${rpc4k}!"
5743 [ $rpc8k != 0 ] && error "Small 8k read IO ${rpc8k}!"
5744 [ $rpc16k != 0 ] && error "Small 16k read IO ${rpc16k}!"
5745 [ $rpc32k != 0 ] && error "Small 32k read IO ${rpc32k}!"
5746 echo "${osc} rpc check passed!"
5751 run_test 101c "check stripe_size aligned read-ahead ================="
5754 $LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1
5755 $LCTL set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
5759 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5760 local file=$DIR/$tfile
5761 local size=${FILESIZE_101c:-500}
5762 local ra_MB=${READAHEAD_MB:-40}
5764 local space=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
5765 [ $space -gt $((size * 1024)) ] ||
5766 { skip "Need free space ${size}M, have $space" && return; }
5768 echo Creating ${size}M test file $file
5769 dd if=/dev/zero of=$file bs=1M count=$size || error "dd failed"
5770 echo Cancel LRU locks on lustre client to flush the client cache
5771 cancel_lru_locks osc
5773 echo Disable read-ahead
5774 local old_READAHEAD=$(set_read_ahead 0)
5776 echo Reading the test file $file with read-ahead disabled
5777 time_ra_OFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$size")
5779 echo Cancel LRU locks on lustre client to flush the client cache
5780 cancel_lru_locks osc
5781 echo Enable read-ahead with ${ra_MB}MB
5782 set_read_ahead $ra_MB
5784 echo Reading the test file $file with read-ahead enabled
5785 time_ra_ON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$size")
5787 echo read-ahead disabled time read $time_ra_OFF
5788 echo read-ahead enabled time read $time_ra_ON
5790 set_read_ahead $old_READAHEAD
5792 wait_delete_completed
5794 [ $time_ra_ON -lt $time_ra_OFF ] ||
5795 error "read-ahead enabled time read (${time_ra_ON}s) is more than
5796 read-ahead disabled time read (${time_ra_OFF}s) filesize ${size}M"
5798 run_test 101d "file read with and without read-ahead enabled ================="
5801 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5802 local file=$DIR/$tfile
5807 local space=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
5808 local need_space=$((count * size))
5809 [ $space -gt $need_space ] ||
5810 { skip_env "Need free space $need_space, have $space" && return; }
5812 echo Creating $count ${size}K test files
5813 for ((i = 0; i < $count; i++)); do
5814 dd if=/dev/zero of=${file}_${i} bs=$blksize count=$size 2>/dev/null
5817 echo Cancel LRU locks on lustre client to flush the client cache
5818 cancel_lru_locks osc
5820 echo Reset readahead stats
5821 $LCTL set_param -n llite.*.read_ahead_stats 0
5823 for ((i = 0; i < $count; i++)); do
5824 dd if=${file}_${i} of=/dev/null bs=$blksize count=$size 2>/dev/null
5827 local miss=$($LCTL get_param -n llite.*.read_ahead_stats | \
5828 get_named_value 'misses' | cut -d" " -f1 | calc_total)
5830 for ((i = 0; i < $count; i++)); do
5831 rm -rf ${file}_${i} 2>/dev/null
5834 #10000 means 20% reads are missing in readahead
5835 [ $miss -lt 10000 ] || error "misses too much for small reads"
5837 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
5839 cleanup_test101f() {
5841 $LCTL set_param -n llite.*.max_read_ahead_whole_mb $MAX_WHOLE_MB
5842 rm -rf $DIR/$tfile 2>/dev/null
5846 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5847 local file=$DIR/$tfile
5850 MAX_WHOLE_MB=$($LCTL get_param -n llite.*.max_read_ahead_whole_mb)
5851 $LCTL set_param -n llite.*.max_read_ahead_whole_mb 2
5852 dd if=/dev/zero of=${file} bs=2097152 count=1 2>/dev/null
5853 trap cleanup_test101f EXIT
5855 echo Cancel LRU locks on lustre client to flush the client cache
5856 cancel_lru_locks osc
5858 echo Reset readahead stats
5859 $LCTL set_param -n llite.*.read_ahead_stats 0
5860 # Random read in a 2M file, because max_read_ahead_whole_mb = 2M,
5861 # readahead should read in 2M file on second read, so only miss
5863 echo Random 4K reads on 2M file for 1000 times
5864 $READS -f $file -s 2097152 -b 4096 -n $nreads
5866 echo checking missing pages
5867 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
5868 get_named_value 'misses' | cut -d" " -f1 | calc_total)
5870 [ $miss -lt 3 ] || error "misses too much pages!"
5873 run_test 101f "check read-ahead for max_read_ahead_whole_mb"
5876 test_mkdir -p $DIR/$tdir
5877 chown $RUNAS_ID $DIR/$tdir
5880 STRIPE_COUNT=$OSTCOUNT
5881 [ $OSTCOUNT -gt 4 ] && STRIPE_COUNT=4
5883 trap cleanup_test102 EXIT
5885 $1 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
5887 for num in 1 2 3 4; do
5888 for count in $(seq 1 $STRIPE_COUNT); do
5889 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
5890 local size=`expr $STRIPE_SIZE \* $num`
5891 local file=file"$num-$idx-$count"
5892 $1 $SETSTRIPE -S $size -i $idx -c $count $file
5898 $1 $TAR cf $TMP/f102.tar $tdir --xattrs
5904 rm -rf $DIR/d0.sanity/d102
5908 local testfile=$DIR/xattr_testfile
5912 [ "$UID" != 0 ] && skip_env "must run as root" && return
5913 [ -z "`lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr`" ] &&
5914 skip_env "must have user_xattr" && return
5916 [ -z "$(which setfattr 2>/dev/null)" ] &&
5917 skip_env "could not find setfattr" && return
5919 echo "set/get xattr..."
5920 setfattr -n trusted.name1 -v value1 $testfile || error
5921 getfattr -n trusted.name1 $testfile 2> /dev/null |
5922 grep "trusted.name1=.value1" ||
5923 error "$testfile missing trusted.name1=value1"
5925 setfattr -n user.author1 -v author1 $testfile || error
5926 getfattr -n user.author1 $testfile 2> /dev/null |
5927 grep "user.author1=.author1" ||
5928 error "$testfile missing trusted.author1=author1"
5931 setfattr -n trusted.name2 -v value2 $testfile ||
5932 error "$testfile unable to set trusted.name2"
5933 setfattr -n trusted.name3 -v value3 $testfile ||
5934 error "$testfile unable to set trusted.name3"
5935 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
5936 grep "trusted.name" | wc -l) -eq 3 ] ||
5937 error "$testfile missing 3 trusted.name xattrs"
5939 setfattr -n user.author2 -v author2 $testfile ||
5940 error "$testfile unable to set user.author2"
5941 setfattr -n user.author3 -v author3 $testfile ||
5942 error "$testfile unable to set user.author3"
5943 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
5944 grep "user.author" | wc -l) -eq 3 ] ||
5945 error "$testfile missing 3 user.author xattrs"
5947 echo "remove xattr..."
5948 setfattr -x trusted.name1 $testfile ||
5949 error "$testfile error deleting trusted.name1"
5950 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
5951 error "$testfile did not delete trusted.name1 xattr"
5953 setfattr -x user.author1 $testfile ||
5954 error "$testfile error deleting user.author1"
5955 getfattr -d -m user $testfile 2> /dev/null | grep "user.author1" &&
5956 error "$testfile did not delete trusted.name1 xattr"
5958 # b10667: setting lustre special xattr be silently discarded
5959 echo "set lustre special xattr ..."
5960 setfattr -n "trusted.lov" -v "invalid value" $testfile ||
5961 error "$testfile allowed setting trusted.lov"
5963 run_test 102a "user xattr test =================================="
5966 # b10930: get/set/list trusted.lov xattr
5967 echo "get/set/list trusted.lov xattr ..."
5968 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
5969 local testfile=$DIR/$tfile
5970 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
5971 error "setstripe failed"
5972 local STRIPECOUNT=$($GETSTRIPE -c $testfile) ||
5973 error "getstripe failed"
5974 getfattr -d -m "^trusted" $testfile 2> /dev/null | \
5975 grep "trusted.lov" || error "can't get trusted.lov from $testfile"
5977 local testfile2=${testfile}2
5978 local value=`getfattr -n trusted.lov $testfile 2> /dev/null | \
5979 grep "trusted.lov" |sed -e 's/[^=]\+=//'`
5982 setfattr -n trusted.lov -v $value $testfile2
5983 local stripe_size=$($GETSTRIPE -S $testfile2)
5984 local stripe_count=$($GETSTRIPE -c $testfile2)
5985 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
5986 [ $stripe_count -eq $STRIPECOUNT ] ||
5987 error "stripe count $stripe_count != $STRIPECOUNT"
5990 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
5993 # b10930: get/set/list lustre.lov xattr
5994 echo "get/set/list lustre.lov xattr ..."
5995 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
5996 test_mkdir -p $DIR/$tdir
5997 chown $RUNAS_ID $DIR/$tdir
5998 local testfile=$DIR/$tdir/$tfile
5999 $RUNAS $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
6000 error "setstripe failed"
6001 local STRIPECOUNT=$($RUNAS $GETSTRIPE -c $testfile) ||
6002 error "getstripe failed"
6003 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
6004 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
6006 local testfile2=${testfile}2
6007 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
6008 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
6010 $RUNAS $MCREATE $testfile2
6011 $RUNAS setfattr -n lustre.lov -v $value $testfile2
6012 local stripe_size=$($RUNAS $GETSTRIPE -S $testfile2)
6013 local stripe_count=$($RUNAS $GETSTRIPE -c $testfile2)
6014 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
6015 [ $stripe_count -eq $STRIPECOUNT ] ||
6016 error "stripe count $stripe_count != $STRIPECOUNT"
6018 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
6020 compare_stripe_info1() {
6021 local stripe_index_all_zero=true
6023 for num in 1 2 3 4; do
6024 for count in $(seq 1 $STRIPE_COUNT); do
6025 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
6026 local size=$((STRIPE_SIZE * num))
6027 local file=file"$num-$offset-$count"
6028 stripe_size=$(lfs getstripe -S $PWD/$file)
6029 [ $stripe_size -ne $size ] &&
6030 error "$file: size $stripe_size != $size"
6031 stripe_count=$(lfs getstripe -c $PWD/$file)
6032 # allow fewer stripes to be created, ORI-601
6033 [ $stripe_count -lt $(((3 * count + 3) / 4)) ]&&
6034 error "$file: count $stripe_count != $count"
6035 stripe_index=$(lfs getstripe -i $PWD/$file)
6036 [ $stripe_index -ne 0 ] &&
6037 stripe_index_all_zero=false
6041 $stripe_index_all_zero &&
6042 error "all files are being extracted starting from OST index 0"
6047 [ -n "$(which tar 2>/dev/null)" ] &&
6048 strings $(which tar) | grep -q "lustre" && echo tar
6052 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6053 # b10930: tar test for trusted.lov xattr
6054 TAR=$(find_lustre_tar)
6055 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6056 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
6058 test_mkdir -p $DIR/d102d
6059 $TAR xf $TMP/f102.tar -C $DIR/d102d --xattrs
6061 compare_stripe_info1
6063 run_test 102d "tar restore stripe info from tarfile,not keep osts ==========="
6066 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6067 # b10930: tar test for trusted.lov xattr
6068 TAR=$(find_lustre_tar)
6069 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6070 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
6072 test_mkdir -p $DIR/d102f
6074 $TAR cf - --xattrs $tdir | $TAR xf - --xattrs -C $DIR/d102f
6076 compare_stripe_info1
6078 run_test 102f "tar copy files, not keep osts ==========="
6081 local xsize=${1:-1024} # in bytes
6082 local file=$DIR/$tfile
6084 [ -z $(lctl get_param -n mdc.*.connect_flags | grep xattr) ] &&
6085 skip "must have user_xattr" && return 0
6086 [ -z "$(which setfattr 2>/dev/null)" ] &&
6087 skip_env "could not find setfattr" && return 0
6088 [ -z "$(which getfattr 2>/dev/null)" ] &&
6089 skip_env "could not find getfattr" && return 0
6093 local value="$(generate_string $xsize)"
6095 local xbig=trusted.big
6096 log "save $xbig on $file"
6097 setfattr -n $xbig -v $value $file ||
6098 error "saving $xbig on $file failed"
6100 local orig=$(get_xattr_value $xbig $file)
6101 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
6103 local xsml=trusted.sml
6104 log "save $xsml on $file"
6105 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
6107 local new=$(get_xattr_value $xbig $file)
6108 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
6110 log "grow $xsml on $file"
6111 setfattr -n $xsml -v "$value" $file ||
6112 error "growing $xsml on $file failed"
6114 new=$(get_xattr_value $xbig $file)
6115 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
6116 log "$xbig still valid after growing $xsml"
6121 test_102h() { # bug 15777
6124 run_test 102h "grow xattr from inside inode to external block"
6127 large_xattr_enabled || { skip "large_xattr disabled" && return; }
6128 grow_xattr $(max_xattr_size)
6130 run_test 102ha "grow xattr from inside inode to external inode"
6132 test_102i() { # bug 17038
6134 ln -s $DIR/$tfile $DIR/${tfile}link
6135 getfattr -n trusted.lov $DIR/$tfile || error "lgetxattr on $DIR/$tfile failed"
6136 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"
6137 rm -f $DIR/$tfile $DIR/${tfile}link
6139 run_test 102i "lgetxattr test on symbolic link ============"
6142 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6143 TAR=$(find_lustre_tar)
6144 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6145 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
6146 setup_test102 "$RUNAS"
6147 test_mkdir -p $DIR/d102j
6148 chown $RUNAS_ID $DIR/d102j
6149 $RUNAS $TAR xf $TMP/f102.tar -C $DIR/d102j --xattrs
6151 compare_stripe_info1 "$RUNAS"
6153 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
6157 # b22187 just check that does not crash for regular file.
6158 setfattr -n trusted.lov $DIR/$tfile
6159 # b22187 'setfattr -n trusted.lov' should work as remove LOV EA for directories
6160 local test_kdir=$DIR/d102k
6161 test_mkdir $test_kdir
6162 local default_size=`$GETSTRIPE -S $test_kdir`
6163 local default_count=`$GETSTRIPE -c $test_kdir`
6164 local default_offset=`$GETSTRIPE -i $test_kdir`
6165 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $test_kdir ||
6166 error 'dir setstripe failed'
6167 setfattr -n trusted.lov $test_kdir
6168 local stripe_size=`$GETSTRIPE -S $test_kdir`
6169 local stripe_count=`$GETSTRIPE -c $test_kdir`
6170 local stripe_offset=`$GETSTRIPE -i $test_kdir`
6171 [ $stripe_size -eq $default_size ] ||
6172 error "stripe size $stripe_size != $default_size"
6173 [ $stripe_count -eq $default_count ] ||
6174 error "stripe count $stripe_count != $default_count"
6175 [ $stripe_offset -eq $default_offset ] ||
6176 error "stripe offset $stripe_offset != $default_offset"
6177 rm -rf $DIR/$tfile $test_kdir
6179 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
6182 # LU-532 trusted. xattr is invisible to non-root
6183 local testfile=$DIR/$tfile
6187 echo "listxattr as user..."
6188 chown $RUNAS_ID $testfile
6189 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
6190 grep -q "trusted" &&
6191 error "$testfile trusted xattrs are user visible"
6195 run_test 102l "listxattr filter test =================================="
6201 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
6206 [ "$UID" != 0 ] && skip_env "must run as root" && return
6207 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
6208 [ -z "$(which setfacl 2>/dev/null)" ] && skip_env "could not find setfacl" && return
6209 $GSS && skip "could not run under gss" && return
6211 declare -a identity_old
6213 for num in $(seq $MDSCOUNT); do
6214 switch_identity $num true || identity_old[$num]=$?
6221 echo "performing cp ..."
6222 run_acl_subtest cp || error
6223 echo "performing getfacl-noacl..."
6224 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
6225 echo "performing misc..."
6226 run_acl_subtest misc || error "misc test failed"
6227 echo "performing permissions..."
6228 run_acl_subtest permissions || error "permissions failed"
6229 echo "performing setfacl..."
6230 run_acl_subtest setfacl || error "setfacl test failed"
6232 # inheritance test got from HP
6233 echo "performing inheritance..."
6234 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
6235 chmod +x make-tree || error "chmod +x failed"
6236 run_acl_subtest inheritance || error "inheritance test failed"
6239 echo "LU-974 ignore umask when acl is enabled..."
6240 run_acl_subtest 974 || error "LU-974 test failed"
6241 if [ $MDSCOUNT -ge 2 ]; then
6242 run_acl_subtest 974_remote ||
6243 error "LU-974 test failed under remote dir"
6246 echo "LU-2561 newly created file is same size as directory..."
6247 run_acl_subtest 2561 || error "LU-2561 test failed"
6252 for num in $(seq $MDSCOUNT); do
6253 if [ "${identity_old[$num]}" = 1 ]; then
6254 switch_identity $num false || identity_old[$num]=$?
6258 run_test 103 "acl test ========================================="
6261 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6263 lfs df || error "lfs df failed"
6264 lfs df -ih || error "lfs df -ih failed"
6265 lfs df -h $DIR || error "lfs df -h $DIR failed"
6266 lfs df -i $DIR || error "lfs df -i $DIR failed"
6267 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
6268 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
6270 OSC=`lctl dl |grep OST0000-osc-[^M] |awk '{print $4}'`
6271 lctl --device %$OSC deactivate
6272 lfs df || error "lfs df with deactivated OSC failed"
6273 lctl --device %$OSC activate
6274 # wait the osc back to normal
6275 wait_osc_import_state client ost FULL
6277 lfs df || error "lfs df with reactivated OSC failed"
6280 run_test 104a "lfs df [-ih] [path] test ========================="
6283 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6284 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
6286 denied_cnt=$((`$RUNAS $LFS check servers 2>&1 | grep "Permission denied" | wc -l`))
6287 if [ $denied_cnt -ne 0 ];
6289 error "lfs check servers test failed"
6292 run_test 104b "$RUNAS lfs check servers test ===================="
6295 # doesn't work on 2.4 kernels
6297 if [ -n "`mount | grep \"$MOUNT.*flock\" | grep -v noflock`" ]; then
6298 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
6300 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
6304 run_test 105a "flock when mounted without -o flock test ========"
6308 if [ -n "`mount | grep \"$MOUNT.*flock\" | grep -v noflock`" ]; then
6309 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
6311 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
6315 run_test 105b "fcntl when mounted without -o flock test ========"
6319 if [ -n "`mount | grep \"$MOUNT.*flock\" | grep -v noflock`" ]; then
6320 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
6322 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
6326 run_test 105c "lockf when mounted without -o flock test ========"
6328 test_105d() { # bug 15924
6329 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6330 test_mkdir -p $DIR/$tdir
6331 [ -z "`mount | grep \"$MOUNT.*flock\" | grep -v noflock`" ] && \
6332 skip "mount w/o flock enabled" && return
6333 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
6334 $LCTL set_param fail_loc=0x80000315
6335 flocks_test 2 $DIR/$tdir
6337 run_test 105d "flock race (should not freeze) ========"
6339 test_105e() { # bug 22660 && 22040
6340 [ -z "`mount | grep \"$MOUNT.*flock\" | grep -v noflock`" ] && \
6341 skip "mount w/o flock enabled" && return
6343 flocks_test 3 $DIR/$tfile
6345 run_test 105e "Two conflicting flocks from same process ======="
6347 test_106() { #bug 10921
6348 test_mkdir -p $DIR/$tdir
6349 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
6350 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
6352 run_test 106 "attempt exec of dir followed by chown of that dir"
6355 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6362 local save_pattern=$(sysctl -n kernel.core_pattern)
6363 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
6364 sysctl -w kernel.core_pattern=$file
6365 sysctl -w kernel.core_uses_pid=0
6373 kill -s 11 $SLEEPPID
6375 if [ -e $file ]; then
6376 size=`stat -c%s $file`
6377 [ $size -eq 0 ] && error "Fail to create core file $file"
6379 error "Fail to create core file $file"
6382 sysctl -w kernel.core_pattern=$save_pattern
6383 sysctl -w kernel.core_uses_pid=$save_uses_pid
6386 run_test 107 "Coredump on SIG"
6389 test_mkdir -p $DIR/$tdir
6390 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255) ||
6391 error "mkdir with 255 char failed"
6392 test_mkdir $DIR/$tdir/$(str_repeat 'b' 256) &&
6393 error "mkdir with 256 char should fail, but did not"
6394 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
6395 error "create with 255 char failed"
6396 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
6397 error "create with 256 char should fail, but did not"
6402 run_test 110 "filename length checking"
6405 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6406 OSTIO_pre=$(ps -e|grep ll_ost_io|awk '{print $4}'|sort -n|tail -1|\
6408 [ -z "$OSTIO_pre" ] && skip "no OSS threads" && \
6410 echo "Starting with $OSTIO_pre threads"
6413 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
6414 [ $NUMFREE -lt $NUMTEST ] && NUMTEST=$(($NUMFREE - 1000))
6415 echo "$NUMTEST creates/unlinks"
6416 test_mkdir -p $DIR/$tdir
6417 createmany -o $DIR/$tdir/$tfile $NUMTEST
6418 unlinkmany $DIR/$tdir/$tfile $NUMTEST
6420 OSTIO_post=$(ps -e|grep ll_ost_io|awk '{print $4}'|sort -n|tail -1|\
6423 # don't return an error
6424 [ $OSTIO_post == $OSTIO_pre ] && echo \
6425 "WARNING: No new ll_ost_io threads were created ($OSTIO_pre)" &&
6426 echo "This may be fine, depending on what ran before this test" &&
6427 echo "and how fast this system is." && return
6429 echo "Started with $OSTIO_pre threads, ended with $OSTIO_post"
6431 run_test 115 "verify dynamic thread creation===================="
6434 wait_delete_completed
6435 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
6436 echo OST kbytes available: ${AVAIL[@]}
6437 MAXI=0; MAXV=${AVAIL[0]}
6438 MINI=0; MINV=${AVAIL[0]}
6439 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
6440 #echo OST $i: ${AVAIL[i]}kb
6441 if [ ${AVAIL[i]} -gt $MAXV ]; then
6442 MAXV=${AVAIL[i]}; MAXI=$i
6444 if [ ${AVAIL[i]} -lt $MINV ]; then
6445 MINV=${AVAIL[i]}; MINI=$i
6448 echo Min free space: OST $MINI: $MINV
6449 echo Max free space: OST $MAXI: $MAXV
6452 test_116a() { # was previously test_116()
6453 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6454 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs" && return
6456 echo -n "Free space priority "
6457 lctl get_param -n lov.*-clilov-*.qos_prio_free
6460 [ $MINV -gt 960000 ] && skip "too much free space in OST$MINI, skip" &&\
6463 # generate uneven OSTs
6464 test_mkdir -p $DIR/$tdir/OST${MINI}
6467 echo "Filling 25% remaining space in OST${MINI} with ${FILL}Kb"
6468 $SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI}||error "setstripe failed"
6470 while [ $FILL -gt 0 ]; do
6472 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i bs=2M count=1 2>/dev/null
6473 FILL=$(($FILL - 2048))
6481 DIFF=$(($MAXV - $MINV))
6482 DIFF2=$(($DIFF * 100 / $MINV))
6483 echo -n "diff=${DIFF}=${DIFF2}% must be > 20% for QOS mode..."
6484 if [ $DIFF2 -gt 20 ]; then
6487 echo "failed - QOS mode won't be used"
6488 error_ignore "QOS imbalance criteria not met"
6492 MINI1=$MINI; MINV1=$MINV
6493 MAXI1=$MAXI; MAXV1=$MAXV
6495 # now fill using QOS
6496 echo writing a bunch of files to QOS-assigned OSTs
6497 $SETSTRIPE -c 1 $DIR/$tdir
6499 while [ $FILL -gt 0 ]; do
6501 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1024 count=200 2>/dev/null
6502 FILL=$(($FILL - 200))
6505 echo "wrote $i 200k files"
6509 echo "Note: free space may not be updated, so measurements might be off"
6511 DIFF2=$(($MAXV - $MINV))
6512 echo "free space delta: orig $DIFF final $DIFF2"
6513 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
6514 DIFF=$(($MINV1 - ${AVAIL[$MINI1]}))
6515 echo "Wrote $DIFF to smaller OST $MINI1"
6516 DIFF2=$(($MAXV1 - ${AVAIL[$MAXI1]}))
6517 echo "Wrote $DIFF2 to larger OST $MAXI1"
6518 [ $DIFF -gt 0 ] && echo "Wrote $(($DIFF2 * 100 / $DIFF - 100))% more data to larger OST $MAXI1"
6520 # Figure out which files were written where
6521 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
6522 awk '/'$MINI1': / {print $2; exit}')
6524 MINC=$($GETSTRIPE --obd $UUID $DIR/$tdir | wc -l)
6525 echo "$MINC files created on smaller OST $MINI1"
6526 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
6527 awk '/'$MAXI1': / {print $2; exit}')
6529 MAXC=$($GETSTRIPE --obd $UUID $DIR/$tdir | wc -l)
6530 echo "$MAXC files created on larger OST $MAXI1"
6531 [ $MINC -gt 0 ] && echo "Wrote $(($MAXC * 100 / $MINC - 100))% more files to larger OST $MAXI1"
6532 [ $MAXC -gt $MINC ] || error_ignore "stripe QOS didn't balance free space"
6536 run_test 116a "stripe QOS: free space balance ==================="
6538 test_116b() { # LU-2093
6539 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6540 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
6542 old_rr=$(do_facet $SINGLEMDS lctl get_param -n lov.*mdtlov*.qos_threshold_rr)
6543 do_facet $SINGLEMDS lctl set_param lov.*mdtlov*.qos_threshold_rr 0
6545 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
6546 createmany -o $DIR/$tdir/f- 20 || error "can't create"
6547 do_facet $SINGLEMDS lctl set_param fail_loc=0
6549 do_facet $SINGLEMDS lctl set_param lov.*mdtlov*.qos_threshold_rr $old_rr
6551 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
6553 test_117() # bug 10891
6555 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6556 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
6557 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
6558 lctl set_param fail_loc=0x21e
6559 > $DIR/$tfile || error "truncate failed"
6560 lctl set_param fail_loc=0
6561 echo "Truncate succeeded."
6564 run_test 117 "verify fsfilt_extend =========="
6566 NO_SLOW_RESENDCOUNT=4
6567 export OLD_RESENDCOUNT=""
6568 set_resend_count () {
6569 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
6570 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -1)
6571 lctl set_param -n $PROC_RESENDCOUNT $1
6572 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
6575 # for reduce test_118* time (b=14842)
6576 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
6578 # Reset async IO behavior after error case
6580 FILE=$DIR/reset_async
6582 # Ensure all OSCs are cleared
6583 $SETSTRIPE -c -1 $FILE
6584 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
6589 test_118a() #bug 11710
6591 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6594 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6595 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6596 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
6598 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6599 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6604 run_test 118a "verify O_SYNC works =========="
6608 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6609 remote_ost_nodsh && skip "remote OST with nodsh" && return
6613 #define OBD_FAIL_OST_ENOENT 0x217
6614 set_nodes_failloc "$(osts_nodes)" 0x217
6615 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6617 set_nodes_failloc "$(osts_nodes)" 0
6618 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6619 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6622 if [[ $RC -eq 0 ]]; then
6623 error "Must return error due to dropped pages, rc=$RC"
6627 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6628 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6632 echo "Dirty pages not leaked on ENOENT"
6634 # Due to the above error the OSC will issue all RPCs syncronously
6635 # until a subsequent RPC completes successfully without error.
6636 $MULTIOP $DIR/$tfile Ow4096yc
6641 run_test 118b "Reclaim dirty pages on fatal error =========="
6645 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6647 # for 118c, restore the original resend count, LU-1940
6648 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
6649 set_resend_count $OLD_RESENDCOUNT
6650 remote_ost_nodsh && skip "remote OST with nodsh" && return
6654 #define OBD_FAIL_OST_EROFS 0x216
6655 set_nodes_failloc "$(osts_nodes)" 0x216
6657 # multiop should block due to fsync until pages are written
6658 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
6662 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
6663 error "Multiop failed to block on fsync, pid=$MULTIPID"
6666 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6668 if [[ $WRITEBACK -eq 0 ]]; then
6669 error "No page in writeback, writeback=$WRITEBACK"
6672 set_nodes_failloc "$(osts_nodes)" 0
6675 if [[ $RC -ne 0 ]]; then
6676 error "Multiop fsync failed, rc=$RC"
6679 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6680 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6682 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6683 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6687 echo "Dirty pages flushed via fsync on EROFS"
6690 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
6692 # continue to use small resend count to reduce test_118* time (b=14842)
6693 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
6697 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6698 remote_ost_nodsh && skip "remote OST with nodsh" && return
6702 #define OBD_FAIL_OST_BRW_PAUSE_BULK
6703 set_nodes_failloc "$(osts_nodes)" 0x214
6704 # multiop should block due to fsync until pages are written
6705 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
6709 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
6710 error "Multiop failed to block on fsync, pid=$MULTIPID"
6713 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6715 if [[ $WRITEBACK -eq 0 ]]; then
6716 error "No page in writeback, writeback=$WRITEBACK"
6719 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
6720 set_nodes_failloc "$(osts_nodes)" 0
6722 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6723 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6725 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6726 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6730 echo "Dirty pages gaurenteed flushed via fsync"
6733 run_test 118d "Fsync validation inject a delay of the bulk =========="
6736 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6739 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
6740 lctl set_param fail_loc=0x8000040a
6742 # Should simulate EINVAL error which is fatal
6743 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6745 if [[ $RC -eq 0 ]]; then
6746 error "Must return error due to dropped pages, rc=$RC"
6749 lctl set_param fail_loc=0x0
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 118f "Simulate unrecoverable OSC side error =========="
6772 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6775 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
6776 lctl set_param fail_loc=0x406
6778 # simulate local -ENOMEM
6779 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6782 lctl set_param fail_loc=0
6783 if [[ $RC -eq 0 ]]; then
6784 error "Must return error due to dropped pages, rc=$RC"
6787 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6788 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6789 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6791 if [[ $LOCKED -ne 0 ]]; then
6792 error "Locked pages remain in cache, locked=$LOCKED"
6795 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6796 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6800 echo "No pages locked after fsync"
6805 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
6808 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6809 remote_ost_nodsh && skip "remote OST with nodsh" && return
6813 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
6814 set_nodes_failloc "$(osts_nodes)" 0x20e
6815 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
6816 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6819 set_nodes_failloc "$(osts_nodes)" 0
6820 if [[ $RC -eq 0 ]]; then
6821 error "Must return error due to dropped pages, rc=$RC"
6824 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6825 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6826 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6828 if [[ $LOCKED -ne 0 ]]; then
6829 error "Locked pages remain in cache, locked=$LOCKED"
6832 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6833 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6837 echo "No pages locked after fsync"
6841 run_test 118h "Verify timeout in handling recoverables errors =========="
6843 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
6846 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6847 remote_ost_nodsh && skip "remote OST with nodsh" && return
6851 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
6852 set_nodes_failloc "$(osts_nodes)" 0x20e
6854 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
6855 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
6858 set_nodes_failloc "$(osts_nodes)" 0
6862 if [[ $RC -ne 0 ]]; then
6863 error "got error, but should be not, rc=$RC"
6866 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6867 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6868 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
6869 if [[ $LOCKED -ne 0 ]]; then
6870 error "Locked pages remain in cache, locked=$LOCKED"
6873 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6874 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6878 echo "No pages locked after fsync"
6882 run_test 118i "Fix error before timeout in recoverable error =========="
6884 [ "$SLOW" = "no" ] && set_resend_count 4
6887 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6888 remote_ost_nodsh && skip "remote OST with nodsh" && return
6892 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
6893 set_nodes_failloc "$(osts_nodes)" 0x220
6895 # return -EIO from OST
6896 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6898 set_nodes_failloc "$(osts_nodes)" 0x0
6899 if [[ $RC -eq 0 ]]; then
6900 error "Must return error due to dropped pages, rc=$RC"
6903 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6904 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6905 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
6906 if [[ $LOCKED -ne 0 ]]; then
6907 error "Locked pages remain in cache, locked=$LOCKED"
6910 # in recoverable error on OST we want resend and stay until it finished
6911 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6912 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6916 echo "No pages locked after fsync"
6920 run_test 118j "Simulate unrecoverable OST side error =========="
6924 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6925 remote_ost_nodsh && skip "remote OSTs with nodsh" && return
6927 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
6928 set_nodes_failloc "$(osts_nodes)" 0x20e
6929 test_mkdir -p $DIR/$tdir
6931 for ((i=0;i<10;i++)); do
6932 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
6933 error "dd to $DIR/$tdir/$tfile-$i failed" )&
6940 set_nodes_failloc "$(osts_nodes)" 0
6943 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
6947 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6949 test_mkdir -p $DIR/$tdir
6950 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
6953 run_test 118l "fsync dir ========="
6955 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
6957 test_119a() # bug 11737
6959 BSIZE=$((512 * 1024))
6960 directio write $DIR/$tfile 0 1 $BSIZE
6961 # We ask to read two blocks, which is more than a file size.
6962 # directio will indicate an error when requested and actual
6963 # sizes aren't equeal (a normal situation in this case) and
6964 # print actual read amount.
6965 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
6966 if [ "$NOB" != "$BSIZE" ]; then
6967 error "read $NOB bytes instead of $BSIZE"
6971 run_test 119a "Short directIO read must return actual read amount"
6973 test_119b() # bug 11737
6975 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
6977 $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
6978 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
6980 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) || \
6981 error "direct read failed"
6984 run_test 119b "Sparse directIO read must return actual read amount"
6986 test_119c() # bug 13099
6989 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
6990 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
6993 run_test 119c "Testing for direct read hitting hole"
6995 test_119d() # bug 15950
6997 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6998 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
6999 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
7001 $SETSTRIPE $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
7002 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
7003 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
7004 lctl set_param fail_loc=0x40d
7005 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
7008 cat $DIR/$tfile > /dev/null &
7009 lctl set_param fail_loc=0
7012 log "the DIO writes have completed, now wait for the reads (should not block very long)"
7014 [ -n "`ps h -p $pid_reads -o comm`" ] && \
7015 error "the read rpcs have not completed in 2s"
7017 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
7019 run_test 119d "The DIO path should try to send a new rpc once one is completed"
7022 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7023 test_mkdir -p $DIR/$tdir
7024 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7025 skip "no early lock cancel on server" && return 0
7026 lru_resize_disable mdc
7027 lru_resize_disable osc
7028 cancel_lru_locks mdc
7029 stat $DIR/$tdir > /dev/null
7030 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
7031 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
7032 test_mkdir $DIR/$tdir/d1
7033 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
7034 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
7035 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7036 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7037 lru_resize_enable mdc
7038 lru_resize_enable osc
7040 run_test 120a "Early Lock Cancel: mkdir test"
7043 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7044 test_mkdir -p $DIR/$tdir
7045 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7046 skip "no early lock cancel on server" && return 0
7047 lru_resize_disable mdc
7048 lru_resize_disable osc
7049 cancel_lru_locks mdc
7050 stat $DIR/$tdir > /dev/null
7051 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
7052 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
7054 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
7055 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
7056 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7057 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7058 lru_resize_enable mdc
7059 lru_resize_enable osc
7061 run_test 120b "Early Lock Cancel: create test"
7064 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7065 test_mkdir -p $DIR/$tdir
7066 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7067 skip "no early lock cancel on server" && return 0
7068 lru_resize_disable mdc
7069 lru_resize_disable osc
7070 test_mkdir -p $DIR/$tdir/d1 $DIR/$tdir/d2
7071 touch $DIR/$tdir/d1/f1
7072 cancel_lru_locks mdc
7073 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
7074 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
7075 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
7076 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
7077 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
7078 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
7079 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7080 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7081 lru_resize_enable mdc
7082 lru_resize_enable osc
7084 run_test 120c "Early Lock Cancel: link test"
7087 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7088 test_mkdir -p $DIR/$tdir
7089 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7090 skip "no early lock cancel on server" && return 0
7091 lru_resize_disable mdc
7092 lru_resize_disable osc
7094 cancel_lru_locks mdc
7095 stat $DIR/$tdir > /dev/null
7096 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
7097 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
7098 chmod a+x $DIR/$tdir
7099 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
7100 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
7101 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7102 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7103 lru_resize_enable mdc
7104 lru_resize_enable osc
7106 run_test 120d "Early Lock Cancel: setattr test"
7109 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7110 test_mkdir -p $DIR/$tdir
7111 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7112 skip "no early lock cancel on server" && return 0
7113 lru_resize_disable mdc
7114 lru_resize_disable osc
7115 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
7116 cancel_lru_locks mdc
7117 cancel_lru_locks osc
7118 dd if=$DIR/$tdir/f1 of=/dev/null
7119 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
7120 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7121 awk '/ldlm_cancel/ {print $2}'`
7122 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7123 awk '/ldlm_bl_callback/ {print $2}'`
7124 unlink $DIR/$tdir/f1
7125 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7126 awk '/ldlm_cancel/ {print $2}'`
7127 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7128 awk '/ldlm_bl_callback/ {print $2}'`
7129 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7130 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7131 lru_resize_enable mdc
7132 lru_resize_enable osc
7134 run_test 120e "Early Lock Cancel: unlink test"
7137 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7138 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7139 skip "no early lock cancel on server" && return 0
7140 test_mkdir -p $DIR/$tdir
7141 lru_resize_disable mdc
7142 lru_resize_disable osc
7143 test_mkdir -p $DIR/$tdir/d1 $DIR/$tdir/d2
7144 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
7145 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
7146 cancel_lru_locks mdc
7147 cancel_lru_locks osc
7148 dd if=$DIR/$tdir/d1/f1 of=/dev/null
7149 dd if=$DIR/$tdir/d2/f2 of=/dev/null
7150 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
7151 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7152 awk '/ldlm_cancel/ {print $2}'`
7153 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7154 awk '/ldlm_bl_callback/ {print $2}'`
7155 mv $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
7156 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7157 awk '/ldlm_cancel/ {print $2}'`
7158 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7159 awk '/ldlm_bl_callback/ {print $2}'`
7160 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7161 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7162 lru_resize_enable mdc
7163 lru_resize_enable osc
7165 run_test 120f "Early Lock Cancel: rename test"
7168 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7169 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7170 skip "no early lock cancel on server" && return 0
7171 lru_resize_disable mdc
7172 lru_resize_disable osc
7174 echo create $count files
7175 test_mkdir -p $DIR/$tdir
7176 cancel_lru_locks mdc
7177 cancel_lru_locks osc
7180 can0=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7181 awk '/ldlm_cancel/ {print $2}'`
7182 blk0=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7183 awk '/ldlm_bl_callback/ {print $2}'`
7184 createmany -o $DIR/$tdir/f $count
7186 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7187 awk '/ldlm_cancel/ {print $2}'`
7188 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7189 awk '/ldlm_bl_callback/ {print $2}'`
7191 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
7192 echo rm $count files
7195 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7196 awk '/ldlm_cancel/ {print $2}'`
7197 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7198 awk '/ldlm_bl_callback/ {print $2}'`
7200 echo total: $count removes in $((t2-t1))
7201 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
7203 # wait for commitment of removal
7204 lru_resize_enable mdc
7205 lru_resize_enable osc
7207 run_test 120g "Early Lock Cancel: performance test"
7209 test_121() { #bug #10589
7210 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7212 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
7213 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
7214 lctl set_param fail_loc=0x310
7215 cancel_lru_locks osc > /dev/null
7216 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
7217 lctl set_param fail_loc=0
7218 [ "$reads" -eq "$writes" ] || error "read" $reads "blocks, must be" $writes
7220 run_test 121 "read cancel race ========="
7222 test_123a() { # was test 123, statahead(bug 11401)
7223 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7225 if [ -z "$(grep "processor.*: 1" /proc/cpuinfo)" ]; then
7226 log "testing on UP system. Performance may be not as good as expected."
7231 test_mkdir -p $DIR/$tdir
7232 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
7233 [ $NUMFREE -gt 100000 ] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
7235 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
7236 createmany -o $DIR/$tdir/$tfile $j $((i - j))
7238 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
7239 lctl set_param -n llite.*.statahead_max 0
7240 lctl get_param llite.*.statahead_max
7241 cancel_lru_locks mdc
7242 cancel_lru_locks osc
7244 time ls -l $DIR/$tdir | wc -l
7246 delta=$((etime - stime))
7247 log "ls $i files without statahead: $delta sec"
7248 lctl set_param llite.*.statahead_max=$max
7250 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
7251 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
7252 cancel_lru_locks mdc
7253 cancel_lru_locks osc
7255 time ls -l $DIR/$tdir | wc -l
7257 delta_sa=$((etime - stime))
7258 log "ls $i files with statahead: $delta_sa sec"
7259 lctl get_param -n llite.*.statahead_stats
7260 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
7262 [ $swrong -lt $ewrong ] && log "statahead was stopped, maybe too many locks held!"
7263 [ $delta -eq 0 -o $delta_sa -eq 0 ] && continue
7265 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
7266 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
7267 lctl set_param -n llite.*.statahead_max 0
7268 lctl get_param llite.*.statahead_max
7269 cancel_lru_locks mdc
7270 cancel_lru_locks osc
7272 time ls -l $DIR/$tdir | wc -l
7274 delta=$((etime - stime))
7275 log "ls $i files again without statahead: $delta sec"
7276 lctl set_param llite.*.statahead_max=$max
7277 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
7278 if [ $SLOWOK -eq 0 ]; then
7279 error "ls $i files is slower with statahead!"
7281 log "ls $i files is slower with statahead!"
7287 [ $delta -gt 20 ] && break
7288 [ $delta -gt 8 ] && MULT=$((50 / delta))
7289 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
7297 delta=$((etime - stime))
7298 log "rm -r $DIR/$tdir/: $delta seconds"
7300 lctl get_param -n llite.*.statahead_stats
7302 run_test 123a "verify statahead work"
7304 test_123b () { # statahead(bug 15027)
7305 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7306 test_mkdir -p $DIR/$tdir
7307 createmany -o $DIR/$tdir/$tfile-%d 1000
7309 cancel_lru_locks mdc
7310 cancel_lru_locks osc
7312 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
7313 lctl set_param fail_loc=0x80000803
7314 ls -lR $DIR/$tdir > /dev/null
7316 lctl set_param fail_loc=0x0
7317 lctl get_param -n llite.*.statahead_stats
7322 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
7325 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7326 [ -z "`lctl get_param -n mdc.*.connect_flags | grep lru_resize`" ] && \
7327 skip "no lru resize on server" && return 0
7329 test_mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
7331 log "create $NR files at $DIR/$tdir"
7332 createmany -o $DIR/$tdir/f $NR ||
7333 error "failed to create $NR files in $DIR/$tdir"
7335 cancel_lru_locks mdc
7336 ls -l $DIR/$tdir > /dev/null
7340 for VALUE in `lctl get_param ldlm.namespaces.*mdc-*.lru_size`; do
7341 local PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
7342 LRU_SIZE=$(lctl get_param -n $PARAM)
7343 if [ $LRU_SIZE -gt $(default_lru_size) ]; then
7344 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
7346 log "NS=$(basename $NSDIR)"
7351 if [ -z "$NSDIR" -o $LRU_SIZE -lt $(default_lru_size) ]; then
7352 skip "Not enough cached locks created!"
7359 # We know that lru resize allows one client to hold $LIMIT locks
7360 # for 10h. After that locks begin to be killed by client.
7362 local LIMIT=`lctl get_param -n $NSDIR.pool.limit`
7365 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
7366 # killing locks. Some time was spent for creating locks. This means
7367 # that up to the moment of sleep finish we must have killed some of
7368 # them (10-100 locks). This depends on how fast ther were created.
7369 # Many of them were touched in almost the same moment and thus will
7370 # be killed in groups.
7371 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
7373 # Use $LRU_SIZE_B here to take into account real number of locks
7374 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
7375 local LRU_SIZE_B=$LRU_SIZE
7377 local OLD_LVF=`lctl get_param -n $NSDIR.pool.lock_volume_factor`
7378 log "OLD_LVF=$OLD_LVF"
7379 lctl set_param -n $NSDIR.pool.lock_volume_factor $LVF
7381 # Let's make sure that we really have some margin. Client checks
7382 # cached locks every 10 sec.
7384 log "Sleep ${SLEEP} sec"
7386 while ((SEC<$SLEEP)); do
7390 LRU_SIZE=`lctl get_param -n $NSDIR/lru_size`
7394 lctl set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
7395 local LRU_SIZE_A=`lctl get_param -n $NSDIR.lru_size`
7397 [ $LRU_SIZE_B -gt $LRU_SIZE_A ] || {
7398 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
7399 unlinkmany $DIR/$tdir/f $NR
7403 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
7404 log "unlink $NR files at $DIR/$tdir"
7405 unlinkmany $DIR/$tdir/f $NR
7407 run_test 124a "lru resize ======================================="
7409 get_max_pool_limit()
7411 local limit=`lctl get_param -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit`
7414 if test $l -gt $max; then
7422 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7423 [ -z "`lctl get_param -n mdc.*.connect_flags | grep lru_resize`" ] && \
7424 skip "no lru resize on server" && return 0
7426 LIMIT=`get_max_pool_limit`
7428 NR=$(($(default_lru_size)*20))
7429 if [ $NR -gt $LIMIT ]; then
7430 log "Limit lock number by $LIMIT locks"
7433 lru_resize_disable mdc
7434 test_mkdir -p $DIR/$tdir/disable_lru_resize ||
7435 error "failed to create $DIR/$tdir/disable_lru_resize"
7437 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
7438 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
7439 cancel_lru_locks mdc
7442 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
7445 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
7448 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
7452 nolruresize_delta=$((etime-stime))
7453 log "ls -la time: $nolruresize_delta seconds"
7454 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
7455 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
7457 lru_resize_enable mdc
7458 test_mkdir -p $DIR/$tdir/enable_lru_resize ||
7459 error "failed to create $DIR/$tdir/enable_lru_resize"
7461 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
7462 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
7463 cancel_lru_locks mdc
7466 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
7469 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
7472 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
7476 lruresize_delta=$((etime-stime))
7477 log "ls -la time: $lruresize_delta seconds"
7478 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
7480 if [ $lruresize_delta -gt $nolruresize_delta ]; then
7481 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
7482 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
7483 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
7485 log "lru resize performs the same with no lru resize"
7487 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
7489 run_test 124b "lru resize (performance test) ======================="
7491 test_125() { # 13358
7492 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
7493 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
7494 test_mkdir -p $DIR/d125 || error "mkdir failed"
7495 $SETSTRIPE -S 65536 -c -1 $DIR/d125 || error "setstripe failed"
7496 setfacl -R -m u:bin:rwx $DIR/d125 || error "setfacl $DIR/d125 failed"
7497 ls -ld $DIR/d125 || error "cannot access $DIR/d125"
7499 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
7501 test_126() { # bug 12829/13455
7502 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
7503 [ "$UID" != 0 ] && skip_env "skipping $TESTNAME (must run as root)" && return
7504 $GSS && skip "must run as gss disabled" && return
7506 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
7507 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
7509 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
7511 run_test 126 "check that the fsgid provided by the client is taken into account"
7513 test_127a() { # bug 15521
7514 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7515 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
7516 $LCTL set_param osc.*.stats=0
7517 FSIZE=$((2048 * 1024))
7518 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
7519 cancel_lru_locks osc
7520 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
7522 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
7523 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
7524 echo "got $COUNT $NAME"
7525 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
7526 eval $NAME=$COUNT || error "Wrong proc format"
7529 read_bytes|write_bytes)
7530 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
7531 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
7532 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
7533 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
7534 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
7535 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
7536 error "sumsquare is too small: $SUMSQ"
7537 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
7538 error "sumsquare is too big: $SUMSQ"
7542 done < $DIR/${tfile}.tmp
7544 #check that we actually got some stats
7545 [ "$read_bytes" ] || error "Missing read_bytes stats"
7546 [ "$write_bytes" ] || error "Missing write_bytes stats"
7547 [ "$read_bytes" != 0 ] || error "no read done"
7548 [ "$write_bytes" != 0 ] || error "no write done"
7550 run_test 127a "verify the client stats are sane"
7552 test_127b() { # bug LU-333
7553 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7554 $LCTL set_param llite.*.stats=0
7555 FSIZE=65536 # sized fixed to match PAGE_SIZE for most clients
7556 # perform 2 reads and writes so MAX is different from SUM.
7557 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
7558 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
7559 cancel_lru_locks osc
7560 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
7561 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
7563 $LCTL get_param llite.*.stats | grep samples > $TMP/${tfile}.tmp
7564 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
7565 echo "got $COUNT $NAME"
7566 eval $NAME=$COUNT || error "Wrong proc format"
7570 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
7571 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
7572 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
7573 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
7576 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
7577 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
7578 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
7579 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
7583 done < $TMP/${tfile}.tmp
7585 #check that we actually got some stats
7586 [ "$read_bytes" ] || error "Missing read_bytes stats"
7587 [ "$write_bytes" ] || error "Missing write_bytes stats"
7588 [ "$read_bytes" != 0 ] || error "no read done"
7589 [ "$write_bytes" != 0 ] || error "no write done"
7591 run_test 127b "verify the llite client stats are sane"
7593 test_128() { # bug 15212
7595 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
7600 result=$(grep error $TMP/$tfile.log)
7602 [ -z "$result" ] || error "consecutive find's under interactive lfs failed"
7604 run_test 128 "interactive lfs for 2 consecutive find's"
7611 local LDPROC=/proc/fs/ldiskfs
7612 local facets=$(get_facets MDS)
7614 for facet in ${facets//,/ }; do
7615 canondev=$(ldiskfs_canon \
7616 *.$(convert_facet2label $facet).mntdev $facet)
7617 do_facet $facet "test -e $LDPROC/$canondev/max_dir_size" ||
7618 LDPROC=/sys/fs/ldiskfs
7619 do_facet $facet "echo $1 >$LDPROC/$canondev/max_dir_size"
7624 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7625 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
7626 skip "Only applicable to ldiskfs-based MDTs"
7629 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7635 test_mkdir -p $DIR/$tdir
7639 while [ ! $I -gt $((MAX * MDSCOUNT)) ]; do
7640 $MULTIOP $DIR/$tdir/$J Oc
7642 if [ $rc -eq $EFBIG ]; then
7644 echo "return code $rc received as expected"
7646 elif [ $rc -ne 0 ]; then
7648 error_exit "return code $rc received instead of expected $EFBIG"
7651 I=$(stat -c%s "$DIR/$tdir")
7655 error "exceeded dir size limit $MAX x $MDSCOUNT $((MAX * MDSCOUNT)) : $I bytes"
7657 run_test 129 "test directory size limit ========================"
7666 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7667 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
7670 trap cleanup_130 EXIT RETURN
7672 local fm_file=$DIR/$tfile
7673 $SETSTRIPE -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
7674 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
7675 error "dd failed for $fm_file"
7677 # LU-1795: test filefrag/FIEMAP once, even if unsupported
7678 filefrag -ves $fm_file
7680 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
7681 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
7682 [ $RC != 0 ] && error "filefrag $fm_file failed"
7684 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
7685 grep -v "ext:" | grep -v "found")
7686 lun=$($GETSTRIPE -i $fm_file)
7688 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
7691 for line in $filefrag_op
7693 frag_lun=`echo $line | cut -d: -f5`
7694 ext_len=`echo $line | cut -d: -f4`
7695 if (( $frag_lun != $lun )); then
7697 error "FIEMAP on 1-stripe file($fm_file) failed"
7700 (( tot_len += ext_len ))
7703 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
7705 error "FIEMAP on 1-stripe file($fm_file) failed;"
7711 echo "FIEMAP on single striped file succeeded"
7713 run_test 130a "FIEMAP (1-stripe file)"
7716 [ "$OSTCOUNT" -lt "2" ] &&
7717 skip_env "skipping FIEMAP on 2-stripe file test" && return
7719 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7720 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
7723 trap cleanup_130 EXIT RETURN
7725 local fm_file=$DIR/$tfile
7726 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
7727 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
7728 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
7730 dd if=/dev/zero of=$fm_file bs=1M count=2 ||
7731 error "dd failed on $fm_file"
7733 filefrag -ves $fm_file || error "filefrag $fm_file failed"
7734 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
7735 grep -v "ext:" | grep -v "found")
7737 last_lun=$(echo $filefrag_op | cut -d: -f5)
7742 for line in $filefrag_op
7744 frag_lun=`echo $line | cut -d: -f5`
7745 ext_len=`echo $line | cut -d: -f4`
7746 if (( $frag_lun != $last_lun )); then
7747 if (( tot_len != 1024 )); then
7749 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 256"
7756 (( tot_len += ext_len ))
7759 if (( num_luns != 2 || tot_len != 1024 )); then
7761 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
7767 echo "FIEMAP on 2-stripe file succeeded"
7769 run_test 130b "FIEMAP (2-stripe file)"
7772 [ "$OSTCOUNT" -lt "2" ] &&
7773 skip_env "skipping FIEMAP on 2-stripe file" && return
7775 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7776 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
7779 trap cleanup_130 EXIT RETURN
7781 local fm_file=$DIR/$tfile
7782 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
7783 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
7784 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
7786 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 || error "dd failed on $fm_file"
7788 filefrag -ves $fm_file || error "filefrag $fm_file failed"
7789 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
7791 last_lun=`echo $filefrag_op | cut -d: -f5`
7796 for line in $filefrag_op
7798 frag_lun=`echo $line | cut -d: -f5`
7799 ext_len=`echo $line | cut -d: -f4`
7800 if (( $frag_lun != $last_lun )); then
7801 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
7802 if (( logical != 512 )); then
7804 error "FIEMAP on $fm_file failed; returned logical start for lun $logical instead of 512"
7807 if (( tot_len != 512 )); then
7809 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
7816 (( tot_len += ext_len ))
7819 if (( num_luns != 2 || tot_len != 512 )); then
7821 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
7827 echo "FIEMAP on 2-stripe file with hole succeeded"
7829 run_test 130c "FIEMAP (2-stripe file with hole)"
7832 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping FIEMAP on N-stripe file test" && return
7834 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7835 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
7837 trap cleanup_130 EXIT RETURN
7839 local fm_file=$DIR/$tfile
7840 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file||error "setstripe on $fm_file"
7841 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
7842 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
7843 dd if=/dev/zero of=$fm_file bs=1M count=$OSTCOUNT || error "dd failed on $fm_file"
7845 filefrag -ves $fm_file || error "filefrag $fm_file failed"
7846 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
7848 last_lun=`echo $filefrag_op | cut -d: -f5`
7853 for line in $filefrag_op
7855 frag_lun=`echo $line | cut -d: -f5`
7856 ext_len=`echo $line | cut -d: -f4`
7857 if (( $frag_lun != $last_lun )); then
7858 if (( tot_len != 1024 )); then
7860 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
7867 (( tot_len += ext_len ))
7870 if (( num_luns != OSTCOUNT || tot_len != 1024 )); then
7872 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
7878 echo "FIEMAP on N-stripe file succeeded"
7880 run_test 130d "FIEMAP (N-stripe file)"
7883 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping continuation FIEMAP test" && return
7885 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7886 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
7888 trap cleanup_130 EXIT RETURN
7890 local fm_file=$DIR/$tfile
7891 $SETSTRIPE -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
7892 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
7893 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
7896 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
7897 for ((i = 0; i < $NUM_BLKS; i++))
7899 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
7902 filefrag -ves $fm_file || error "filefrag $fm_file failed"
7903 filefrag_op=`filefrag -ve $fm_file | grep -A 12000 "ext:" | grep -v "ext:" | grep -v "found"`
7905 last_lun=`echo $filefrag_op | cut -d: -f5`
7910 for line in $filefrag_op
7912 frag_lun=`echo $line | cut -d: -f5`
7913 ext_len=`echo $line | cut -d: -f4`
7914 if (( $frag_lun != $last_lun )); then
7915 if (( tot_len != $EXPECTED_LEN )); then
7917 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of $EXPECTED_LEN"
7924 (( tot_len += ext_len ))
7927 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
7929 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
7935 echo "FIEMAP with continuation calls succeeded"
7937 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
7939 # Test for writev/readv
7941 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 || \
7942 error "writev test failed"
7943 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 || \
7944 error "readv failed"
7947 run_test 131a "test iov's crossing stripe boundary for writev/readv"
7950 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 || \
7951 error "append writev test failed"
7952 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 || \
7953 error "append writev test failed"
7956 run_test 131b "test append writev"
7959 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
7962 run_test 131c "test read/write on file w/o objects"
7965 rwv -f $DIR/$tfile -w -n 1 1572864
7966 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
7967 if [ "$NOB" != 1572864 ]; then
7968 error "Short read filed: read $NOB bytes instead of 1572864"
7972 run_test 131d "test short read"
7975 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
7976 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
7977 error "read hitting hole failed"
7980 run_test 131e "test read hitting hole"
7985 for node in $(osts_nodes); do
7986 gl=$(do_node $node "$LCTL get_param -n ost.OSS.ost.stats" | awk '/'$token'/ {print $2}' | head -n 1)
7987 [ x$gl = x"" ] && gl=0
7988 gl_sum=$((gl_sum + gl))
7998 if [ x$som = x"enabled" ]; then
7999 [ $((gl2 - gl1)) -gt 0 ] && error "no glimpse RPC is expected"
8000 MOUNTOPT=`echo $MOUNTOPT | sed 's/som_preview//g'`
8001 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=disabled"
8003 [ $((gl2 - gl1)) -gt 0 ] || error "some glimpse RPC is expected"
8004 MOUNTOPT="$MOUNTOPT,som_preview"
8005 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=enabled"
8008 # do remount to make new mount-conf parameters actual
8015 test_132() { #1028, SOM
8016 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8017 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8018 local num=$(get_mds_dir $DIR)
8019 local mymds=mds${num}
8020 local MOUNTOPT_SAVE=$MOUNTOPT
8022 dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
8023 cancel_lru_locks osc
8025 som1=$(do_facet $mymds "$LCTL get_param mdt.*.som" | awk -F= ' {print $2}' | head -n 1)
8027 gl1=$(get_ost_param "ldlm_glimpse_enqueue")
8028 stat $DIR/$tfile >/dev/null
8029 gl2=$(get_ost_param "ldlm_glimpse_enqueue")
8030 echo "====> SOM is "$som1", "$((gl2 - gl1))" glimpse RPC occured"
8032 som_mode_switch $som1 $gl1 $gl2
8034 dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
8035 cancel_lru_locks osc
8037 som2=$(do_facet $mymds "$LCTL get_param mdt.*.som" | awk -F= ' {print $2}' | head -n 1)
8038 if [ $som1 == $som2 ]; then
8039 error "som is still "$som2
8040 if [ x$som2 = x"enabled" ]; then
8047 gl1=$(get_ost_param "ldlm_glimpse_enqueue")
8048 stat $DIR/$tfile >/dev/null
8049 gl2=$(get_ost_param "ldlm_glimpse_enqueue")
8050 echo "====> SOM is "$som2", "$((gl2 - gl1))" glimpse RPC occured"
8051 som_mode_switch $som2 $gl1 $gl2
8052 MOUNTOPT=$MOUNTOPT_SAVE
8054 run_test 132 "som avoids glimpse rpc"
8060 $SINGLEMDS) res=`do_facet $SINGLEMDS $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$2"`
8062 ost) res=`do_facet ost1 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$2"`
8064 *) error "Wrong argument $1" ;;
8067 count=`echo $res | awk '{print $2}'`
8068 [ -z "$res" ] && error "The counter for $2 on $1 was not incremented"
8069 # if the argument $3 is zero, it means any stat increment is ok.
8070 if [ $3 -gt 0 ] ; then
8071 [ $count -ne $3 ] && error "The $2 counter on $1 is wrong - expected $3"
8076 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8077 remote_ost_nodsh && skip "remote OST with nodsh" && return
8078 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8080 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
8081 { skip "MDS doesn't support rename stats"; return; }
8082 local testdir=$DIR/${tdir}/stats_testdir
8083 mkdir -p $DIR/${tdir}
8086 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8087 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
8089 # verify mdt stats first.
8090 mkdir ${testdir} || error "mkdir failed"
8091 check_stats $SINGLEMDS "mkdir" 1
8092 touch ${testdir}/${tfile} || "touch failed"
8093 check_stats $SINGLEMDS "open" 1
8094 check_stats $SINGLEMDS "close" 1
8095 mknod ${testdir}/${tfile}-pipe p || "mknod failed"
8096 check_stats $SINGLEMDS "mknod" 1
8097 rm -f ${testdir}/${tfile}-pipe || "pipe remove failed"
8098 check_stats $SINGLEMDS "unlink" 1
8099 rm -f ${testdir}/${tfile} || error "file remove failed"
8100 check_stats $SINGLEMDS "unlink" 2
8102 # remove working dir and check mdt stats again.
8103 rmdir ${testdir} || error "rmdir failed"
8104 check_stats $SINGLEMDS "rmdir" 1
8106 local testdir1=$DIR/${tdir}/stats_testdir1
8108 mkdir -p ${testdir1}
8109 touch ${testdir1}/test1
8110 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
8111 check_stats $SINGLEMDS "crossdir_rename" 1
8113 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
8114 check_stats $SINGLEMDS "samedir_rename" 1
8118 run_test 133a "Verifying MDT stats ========================================"
8121 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8122 remote_ost_nodsh && skip "remote OST with nodsh" && return
8123 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8124 local testdir=$DIR/${tdir}/stats_testdir
8125 mkdir -p ${testdir} || error "mkdir failed"
8126 touch ${testdir}/${tfile} || "touch failed"
8127 cancel_lru_locks mdc
8130 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8131 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
8133 # extra mdt stats verification.
8134 chmod 444 ${testdir}/${tfile} || error "chmod failed"
8135 check_stats $SINGLEMDS "setattr" 1
8136 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8137 if [ $(lustre_version_code $SINGLEMDS) -ne $(version_code 2.2.0) ]
8139 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
8140 check_stats $SINGLEMDS "getattr" 1
8142 $LFS df || error "lfs failed"
8143 check_stats $SINGLEMDS "statfs" 1
8147 run_test 133b "Verifying extra MDT stats =================================="
8150 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8151 remote_ost_nodsh && skip "remote OST with nodsh" && return
8152 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8153 local testdir=$DIR/${tdir}/stats_testdir
8154 test_mkdir -p ${testdir} || error "mkdir failed"
8156 # verify obdfilter stats.
8157 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
8159 cancel_lru_locks osc
8160 wait_delete_completed
8163 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8164 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
8166 dd if=/dev/zero of=${testdir}/${tfile} conv=notrunc bs=512k count=1 || error "dd failed"
8168 cancel_lru_locks osc
8169 check_stats ost "write" 1
8171 dd if=${testdir}/${tfile} of=/dev/null bs=1k count=1 || error "dd failed"
8172 check_stats ost "read" 1
8174 > ${testdir}/${tfile} || error "truncate failed"
8175 check_stats ost "punch" 1
8177 rm -f ${testdir}/${tfile} || error "file remove failed"
8178 wait_delete_completed
8179 check_stats ost "destroy" 1
8183 run_test 133c "Verifying OST stats ========================================"
8190 while [ $value -ge 2 ]; do
8195 if [ $orig -gt $order ]; then
8203 local size=('K' 'M' 'G' 'T');
8205 local size_string=$value
8207 while [ $value -ge 1024 ]; do
8208 if [ $i -gt 3 ]; then
8209 #T is the biggest unit we get here, if that is bigger,
8211 size_string=${value}T
8214 value=$((value >> 10))
8215 if [ $value -lt 1024 ]; then
8216 size_string=${value}${size[$i]}
8227 local context=${2:-.}
8228 local sample=$(do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats |
8230 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
8235 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8236 remote_ost_nodsh && skip "remote OST with nodsh" && return
8237 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8238 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
8239 { skip "MDS doesn't support rename stats"; return; }
8241 local testdir1=$DIR/${tdir}/stats_testdir1
8242 local testdir2=$DIR/${tdir}/stats_testdir2
8244 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
8246 test_mkdir -p ${testdir1} || error "mkdir failed"
8247 test_mkdir -p ${testdir2} || error "mkdir failed"
8249 createmany -o $testdir1/test 512 || error "createmany failed"
8251 # check samedir rename size
8252 mv ${testdir1}/test0 ${testdir1}/test_0
8254 local testdir1_size=$(ls -l $DIR/${tdir} |
8255 awk '/stats_testdir1/ {print $5}')
8256 local testdir2_size=$(ls -l $DIR/${tdir} |
8257 awk '/stats_testdir2/ {print $5}')
8259 testdir1_size=$(order_2 $testdir1_size)
8260 testdir2_size=$(order_2 $testdir2_size)
8262 testdir1_size=$(size_in_KMGT $testdir1_size)
8263 testdir2_size=$(size_in_KMGT $testdir2_size)
8265 echo "source rename dir size: ${testdir1_size}"
8266 echo "target rename dir size: ${testdir2_size}"
8268 local cmd="do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats"
8269 eval $cmd || error "$cmd failed"
8270 local samedir=$($cmd | grep 'same_dir')
8271 local same_sample=$(get_rename_size $testdir1_size)
8272 [ -z "$samedir" ] && error "samedir_rename_size count error"
8273 [ "$same_sample" -eq 1 ] || error "samedir_rename_size error $same_sample"
8274 echo "Check same dir rename stats success"
8276 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
8278 # check crossdir rename size
8279 mv ${testdir1}/test_0 ${testdir2}/test_0
8281 testdir1_size=$(ls -l $DIR/${tdir} |
8282 awk '/stats_testdir1/ {print $5}')
8283 testdir2_size=$(ls -l $DIR/${tdir} |
8284 awk '/stats_testdir2/ {print $5}')
8286 testdir1_size=$(order_2 $testdir1_size)
8287 testdir2_size=$(order_2 $testdir2_size)
8289 testdir1_size=$(size_in_KMGT $testdir1_size)
8290 testdir2_size=$(size_in_KMGT $testdir2_size)
8292 echo "source rename dir size: ${testdir1_size}"
8293 echo "target rename dir size: ${testdir2_size}"
8295 eval $cmd || error "$cmd failed"
8296 local crossdir=$($cmd | grep 'crossdir')
8297 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
8298 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
8299 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
8300 [ "$src_sample" -eq 1 ] || error "crossdir_rename_size error $src_sample"
8301 [ "$tgt_sample" -eq 1 ] || error "crossdir_rename_size error $tgt_sample"
8302 echo "Check cross dir rename stats success"
8305 run_test 133d "Verifying rename_stats ========================================"
8308 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8309 local testdir=$DIR/${tdir}/stats_testdir
8310 local ctr f0 f1 bs=32768 count=42 sum
8312 remote_ost_nodsh && skip "remote OST with nodsh" && return
8313 mkdir -p ${testdir} || error "mkdir failed"
8315 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
8317 for ctr in {write,read}_bytes; do
8319 cancel_lru_locks osc
8321 do_facet ost1 $LCTL set_param -n \
8322 "obdfilter.*.exports.clear=clear"
8324 if [ $ctr = write_bytes ]; then
8326 f1=${testdir}/${tfile}
8328 f0=${testdir}/${tfile}
8332 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
8335 cancel_lru_locks osc
8337 sum=$(do_facet ost1 $LCTL get_param \
8338 "obdfilter.*.exports.*.stats" | \
8341 $1 == ctr { sum += $7 }
8344 if ((sum != bs * count)); then
8345 error "Bad $ctr sum, expected $((bs * count)), got $sum"
8351 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
8354 local proc_dirs="/proc/fs/lustre/ /proc/sys/lnet/ /proc/sys/lustre/"
8357 # First without trusting modes.
8359 -exec cat '{}' \; &> /dev/null
8361 # Second verifying readability.
8365 -exec cat '{}' \; > /dev/null ||
8366 error "proc file read failed"
8368 for facet in $SINGLEMDS ost1; do
8369 do_facet $facet find $proc_dirs \
8370 -not -name req_history \
8371 -exec cat '{}' \\\; &> /dev/null
8373 do_facet $facet find $proc_dirs \
8374 -not -name req_history \
8377 -exec cat '{}' \\\; > /dev/null ||
8378 error "proc file read failed"
8381 run_test 133f "Check for LBUGs/Oopses/unreadable files in /proc"
8383 test_140() { #bug-17379
8384 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8385 test_mkdir -p $DIR/$tdir || error "Creating dir $DIR/$tdir"
8386 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
8387 cp /usr/bin/stat . || error "Copying stat to $DIR/$tdir"
8389 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
8390 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
8392 while i=`expr $i + 1`; do
8393 test_mkdir -p $i || error "Creating dir $i"
8394 cd $i || error "Changing to $i"
8395 ln -s ../stat stat || error "Creating stat symlink"
8396 # Read the symlink until ELOOP present,
8397 # not LBUGing the system is considered success,
8398 # we didn't overrun the stack.
8399 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
8401 if [ $ret -eq 40 ]; then
8404 error "Open stat symlink"
8410 echo "The symlink depth = $i"
8411 [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 -o $i -eq 40 ] ||
8412 error "Invalid symlink depth"
8414 # Test recursive symlink
8415 ln -s symlink_self symlink_self
8416 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
8417 echo "open symlink_self returns $ret"
8418 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
8420 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
8423 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8424 local TF="$TMP/$tfile"
8426 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
8428 cancel_lru_locks osc
8429 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
8430 remount_client $MOUNT
8432 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
8435 $TRUNCATE $DIR/$tfile 6000
8436 cancel_lru_locks osc
8437 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
8440 echo "12345" >>$DIR/$tfile
8441 cancel_lru_locks osc
8442 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
8445 echo "12345" >>$DIR/$tfile
8446 cancel_lru_locks osc
8447 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
8452 run_test 150 "truncate/append tests"
8454 function roc_hit() {
8455 local list=$(comma_list $(osts_nodes))
8456 #debug temp debug for LU-2902: lets see what values we get back
8457 echo $(get_osd_param $list '' stats) 1>&2
8458 echo $(get_osd_param $list '' stats |
8459 awk '/'cache_hit'/ {sum+=$2} END {print sum}')
8462 function set_cache() {
8465 if [ "$2" == "off" ]; then
8468 local list=$(comma_list $(osts_nodes))
8469 set_osd_param $list '' $1_cache_enable $on
8471 cancel_lru_locks osc
8475 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8476 remote_ost_nodsh && skip "remote OST with nodsh" && return
8479 local list=$(comma_list $(osts_nodes))
8481 # check whether obdfilter is cache capable at all
8482 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
8483 echo "not cache-capable obdfilter"
8487 # check cache is enabled on all obdfilters
8488 if get_osd_param $list '' read_cache_enable | grep 0; then
8489 echo "oss cache is disabled"
8493 set_osd_param $list '' writethrough_cache_enable 1
8495 # check write cache is enabled on all obdfilters
8496 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
8497 echo "oss write cache is NOT enabled"
8501 #define OBD_FAIL_OBD_NO_LRU 0x609
8502 do_nodes $list $LCTL set_param fail_loc=0x609
8504 # pages should be in the case right after write
8505 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
8508 local BEFORE=`roc_hit`
8509 cancel_lru_locks osc
8510 cat $DIR/$tfile >/dev/null
8511 local AFTER=`roc_hit`
8513 do_nodes $list $LCTL set_param fail_loc=0
8515 if ! let "AFTER - BEFORE == CPAGES"; then
8516 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
8519 # the following read invalidates the cache
8520 cancel_lru_locks osc
8521 set_osd_param $list '' read_cache_enable 0
8522 cat $DIR/$tfile >/dev/null
8524 # now data shouldn't be found in the cache
8526 cancel_lru_locks osc
8527 cat $DIR/$tfile >/dev/null
8529 if let "AFTER - BEFORE != 0"; then
8530 error "IN CACHE: before: $BEFORE, after: $AFTER"
8533 set_osd_param $list '' read_cache_enable 1
8536 run_test 151 "test cache on oss and controls ==============================="
8539 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8540 local TF="$TMP/$tfile"
8542 # simulate ENOMEM during write
8543 #define OBD_FAIL_OST_NOMEM 0x226
8544 lctl set_param fail_loc=0x80000226
8545 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
8547 sync || error "sync failed"
8548 lctl set_param fail_loc=0
8550 # discard client's cache
8551 cancel_lru_locks osc
8553 # simulate ENOMEM during read
8554 lctl set_param fail_loc=0x80000226
8555 cmp $TF $DIR/$tfile || error "cmp failed"
8556 lctl set_param fail_loc=0
8560 run_test 152 "test read/write with enomem ============================"
8563 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
8565 run_test 153 "test if fdatasync does not crash ======================="
8567 dot_lustre_fid_permission_check() {
8569 local ffid=$MOUNT/.lustre/fid/$fid
8572 echo "stat fid $fid"
8573 stat $ffid > /dev/null || error "stat $ffid failed."
8574 echo "touch fid $fid"
8575 touch $ffid || error "touch $ffid failed."
8576 echo "write to fid $fid"
8577 cat /etc/hosts > $ffid || error "write $ffid failed."
8578 echo "read fid $fid"
8579 diff /etc/hosts $ffid || error "read $ffid failed."
8580 echo "append write to fid $fid"
8581 cat /etc/hosts >> $ffid || error "append write $ffid failed."
8582 echo "rename fid $fid"
8583 mv $ffid $test_dir/$tfile.1 &&
8584 error "rename $ffid to $tfile.1 should fail."
8585 touch $test_dir/$tfile.1
8586 mv $test_dir/$tfile.1 $ffid &&
8587 error "rename $tfile.1 to $ffid should fail."
8588 rm -f $test_dir/$tfile.1
8589 echo "truncate fid $fid"
8590 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
8591 echo "link fid $fid"
8592 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
8593 if [ -n $(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl) ]; then
8594 echo "setfacl fid $fid"
8595 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
8596 echo "getfacl fid $fid"
8597 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
8599 echo "unlink fid $fid"
8600 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
8601 echo "mknod fid $fid"
8602 mknod $ffid c 1 3 && error "mknod $ffid should fail."
8604 fid=[0xf00000400:0x1:0x0]
8605 ffid=$MOUNT/.lustre/fid/$fid
8607 echo "stat non-exist fid $fid"
8608 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
8609 echo "write to non-exist fid $fid"
8610 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
8611 echo "link new fid $fid"
8612 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
8614 mkdir -p $test_dir/$tdir
8615 touch $test_dir/$tdir/$tfile
8616 fid=$($LFS path2fid $test_dir/$tdir)
8619 error "error: could not get fid for $test_dir/$dir/$tfile."
8621 ffid=$MOUNT/.lustre/fid/$fid
8624 ls $ffid > /dev/null || error "ls $ffid failed."
8625 echo "touch $fid/$tfile.1"
8626 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
8628 echo "touch $MOUNT/.lustre/fid/$tfile"
8629 touch $MOUNT/.lustre/fid/$tfile && \
8630 error "touch $MOUNT/.lustre/fid/$tfile should fail."
8632 echo "setxattr to $MOUNT/.lustre/fid"
8633 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid &&
8634 error "setxattr should fail."
8636 echo "listxattr for $MOUNT/.lustre/fid"
8637 getfattr -d -m "^trusted" $MOUNT/.lustre/fid &&
8638 error "listxattr should fail."
8640 echo "delxattr from $MOUNT/.lustre/fid"
8641 setfattr -x trusted.name1 $MOUNT/.lustre/fid &&
8642 error "delxattr should fail."
8644 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
8645 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
8646 error "touch invalid fid should fail."
8648 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
8649 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
8650 error "touch non-normal fid should fail."
8652 echo "rename $tdir to $MOUNT/.lustre/fid"
8653 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
8654 error "rename to $MOUNT/.lustre/fid should fail."
8656 echo "rename .lustre to itself"
8657 fid=$($LFS path2fid $MOUNT)
8658 mrename $MOUNT/.lustre $MOUNT/.lustre/fid/$fid/.lustre &&
8659 error "rename .lustre to itself should fail."
8661 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
8662 fid=$($LFS path2fid $test_dir/$tfile-2)
8663 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
8664 cp /etc/passwd $MOUNT/.lustre/fid/$fid &&
8665 error "create lov data thru .lustre should fail."
8666 echo "cp /etc/passwd $test_dir/$tfile-2"
8667 cp /etc/passwd $test_dir/$tfile-2 ||
8668 error "copy to $test_dir/$tfile-2 failed."
8669 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
8670 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
8671 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
8673 rm -rf $test_dir/tfile.lnk
8674 rm -rf $test_dir/$tfile-2
8678 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8679 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
8680 { skip "Need MDS version at least 2.2.51"; return 0; }
8682 cp /etc/hosts $DIR/$tfile
8684 fid=$($LFS path2fid $DIR/$tfile)
8686 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
8688 dot_lustre_fid_permission_check "$fid" $DIR ||
8689 error "dot lustre permission check $fid failed"
8691 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
8692 chmod 777 $MOUNT/.lustre && error ".lustre is not allowed to be chmod"
8694 touch $MOUNT/.lustre/file &&
8695 error "creation is not allowed under .lustre"
8697 mkdir $MOUNT/.lustre/dir &&
8698 error "mkdir is not allowed under .lustre"
8702 run_test 154a "Open-by-FID"
8705 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8706 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
8707 { skip "Need MDS version at least 2.2.51"; return 0; }
8709 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
8711 local remote_dir=$DIR/$tdir/remote_dir
8716 $LFS mkdir -i $MDTIDX $remote_dir ||
8717 error "create remote directory failed"
8719 cp /etc/hosts $remote_dir/$tfile
8721 fid=$($LFS path2fid $remote_dir/$tfile)
8723 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
8725 dot_lustre_fid_permission_check "$fid" $remote_dir ||
8726 error "dot lustre permission check $fid failed"
8729 run_test 154b "Open-by-FID for remote directory"
8731 test_155_small_load() {
8732 local temp=$TMP/$tfile
8733 local file=$DIR/$tfile
8735 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
8736 error "dd of=$temp bs=6096 count=1 failed"
8738 cancel_lru_locks osc
8739 cmp $temp $file || error "$temp $file differ"
8741 $TRUNCATE $temp 6000
8742 $TRUNCATE $file 6000
8743 cmp $temp $file || error "$temp $file differ (truncate1)"
8745 echo "12345" >>$temp
8746 echo "12345" >>$file
8747 cmp $temp $file || error "$temp $file differ (append1)"
8749 echo "12345" >>$temp
8750 echo "12345" >>$file
8751 cmp $temp $file || error "$temp $file differ (append2)"
8757 test_155_big_load() {
8758 remote_ost_nodsh && skip "remote OST with nodsh" && return
8759 local temp=$TMP/$tfile
8760 local file=$DIR/$tfile
8763 local cache_size=$(do_facet ost$((MAXI+1)) \
8764 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
8765 local large_file_size=$((cache_size * 2))
8767 echo "OSS cache size: $cache_size KB"
8768 echo "Large file size: $large_file_size KB"
8770 [ $MAXV -le $large_file_size ] && \
8771 skip_env "max available OST size needs > $large_file_size KB" && \
8774 $SETSTRIPE $file -c 1 -i $MAXI || error "$SETSTRIPE $file failed"
8776 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k || \
8777 error "dd of=$temp bs=$large_file_size count=1k failed"
8780 cancel_lru_locks osc
8781 cmp $temp $file || error "$temp $file differ"
8788 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8790 set_cache writethrough on
8793 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
8796 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8798 set_cache writethrough off
8801 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
8804 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8806 set_cache writethrough on
8809 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
8812 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8814 set_cache writethrough off
8817 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
8820 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8822 set_cache writethrough on
8825 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
8828 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8830 set_cache writethrough off
8833 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
8836 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8838 set_cache writethrough on
8841 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
8844 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8846 set_cache writethrough off
8849 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
8852 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8856 local file="$DIR/$tfile"
8858 [ "$(facet_fstype ost1)" = "zfs" ] &&
8859 skip "LU-1956/LU-2261: stats unimplemented on OSD ZFS" &&
8862 log "Turn on read and write cache"
8864 set_cache writethrough on
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 be satisfied from the cache."
8881 cancel_lru_locks osc
8882 cat $file >/dev/null
8884 if ! let "AFTER - BEFORE == CPAGES"; then
8885 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
8887 log "cache hits:: before: $BEFORE, after: $AFTER"
8891 log "Turn off the read cache and turn on the write cache"
8893 set_cache writethrough on
8895 log "Read again; it should be satisfied from the cache."
8897 cancel_lru_locks osc
8898 cat $file >/dev/null
8900 if ! let "AFTER - BEFORE == CPAGES"; then
8901 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
8903 log "cache hits:: before: $BEFORE, after: $AFTER"
8906 log "Read again; it should not be satisfied from the cache."
8908 cancel_lru_locks osc
8909 cat $file >/dev/null
8911 if ! let "AFTER - BEFORE == 0"; then
8912 error "IN CACHE: before: $BEFORE, after: $AFTER"
8914 log "cache hits:: before: $BEFORE, after: $AFTER"
8917 log "Write data and read it back."
8918 log "Read should be satisfied from the cache."
8919 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
8921 cancel_lru_locks osc
8922 cat $file >/dev/null
8924 if ! let "AFTER - BEFORE == CPAGES"; then
8925 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
8927 log "cache hits:: before: $BEFORE, after: $AFTER"
8930 log "Read again; it should not be satisfied from the cache."
8932 cancel_lru_locks osc
8933 cat $file >/dev/null
8935 if ! let "AFTER - BEFORE == 0"; then
8936 error "IN CACHE: before: $BEFORE, after: $AFTER"
8938 log "cache hits:: before: $BEFORE, after: $AFTER"
8942 log "Turn off read and write cache"
8944 set_cache writethrough off
8946 log "Write data and read it back"
8947 log "It should not be satisfied from the cache."
8949 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
8950 cancel_lru_locks osc
8952 cat $file >/dev/null
8954 if ! let "AFTER - BEFORE == 0"; then
8955 error_ignore 20762 "IN CACHE: before: $BEFORE, after: $AFTER"
8957 log "cache hits:: before: $BEFORE, after: $AFTER"
8961 log "Turn on the read cache and turn off the write cache"
8963 set_cache writethrough off
8965 log "Write data and read it back"
8966 log "It should not be satisfied from the cache."
8968 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
8970 cancel_lru_locks osc
8971 cat $file >/dev/null
8973 if ! let "AFTER - BEFORE == 0"; then
8974 error_ignore 20762 "IN CACHE: before: $BEFORE, after: $AFTER"
8976 log "cache hits:: before: $BEFORE, after: $AFTER"
8979 log "Read again; it should be satisfied from the cache."
8981 cancel_lru_locks osc
8982 cat $file >/dev/null
8984 if ! let "AFTER - BEFORE == CPAGES"; then
8985 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
8987 log "cache hits:: before: $BEFORE, after: $AFTER"
8992 run_test 156 "Verification of tunables ============================"
8996 if [ $MDSCOUNT -gt 1 ]; then
8997 error_ignore 17935 $*
9005 MASK=$(do_facet $SINGLEMDS $LCTL get_param mdd.$MDT0.changelog_mask |\
9008 if [ $MASK -eq 1 ]; then
9009 do_facet $SINGLEMDS $LCTL set_param mdd.$MDT0.changelog_mask="-$1"
9011 do_facet $SINGLEMDS $LCTL set_param mdd.$MDT0.changelog_mask="+$1"
9016 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9017 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9018 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
9019 { skip "Need MDS version at least 2.2.0"; return; }
9020 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
9021 echo "Registered as changelog user $USER"
9022 do_facet $SINGLEMDS $LCTL get_param -n mdd.$MDT0.changelog_users | \
9023 grep -q $USER || error "User $USER not found in changelog_users"
9026 test_mkdir -p $DIR/$tdir/pics/2008/zachy
9027 touch $DIR/$tdir/pics/2008/zachy/timestamp
9028 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
9029 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
9030 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
9031 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
9032 rm $DIR/$tdir/pics/desktop.jpg
9034 $LFS changelog $MDT0 | tail -5
9036 echo "verifying changelog mask"
9037 changelog_chmask "MKDIR"
9038 changelog_chmask "CLOSE"
9040 test_mkdir -p $DIR/$tdir/pics/zach/sofia
9041 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
9043 changelog_chmask "MKDIR"
9044 changelog_chmask "CLOSE"
9046 test_mkdir -p $DIR/$tdir/pics/2008/sofia
9047 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
9049 $LFS changelog $MDT0
9050 MKDIRS=$($LFS changelog $MDT0 | tail -5 | grep -c "MKDIR")
9051 CLOSES=$($LFS changelog $MDT0 | tail -5 | grep -c "CLOSE")
9052 [ $MKDIRS -eq 1 ] || err17935 "MKDIR changelog mask count $DIRS != 1"
9053 [ $CLOSES -eq 1 ] || err17935 "CLOSE changelog mask count $DIRS != 1"
9056 echo "verifying target fid"
9057 fidc=$($LFS changelog $MDT0 | grep timestamp | grep "CREAT" | \
9058 tail -1 | awk '{print $6}')
9059 fidf=$($LFS path2fid $DIR/$tdir/pics/zach/timestamp)
9060 [ "$fidc" == "t=$fidf" ] || \
9061 err17935 "fid in changelog $fidc != file fid $fidf"
9062 echo "verifying parent fid"
9063 fidc=$($LFS changelog $MDT0 | grep timestamp | grep "CREAT" | \
9064 tail -1 | awk '{print $7}')
9065 fidf=$($LFS path2fid $DIR/$tdir/pics/zach)
9066 [ "$fidc" == "p=$fidf" ] || \
9067 err17935 "pfid in changelog $fidc != dir fid $fidf"
9069 USER_REC1=$(do_facet $SINGLEMDS $LCTL get_param -n \
9070 mdd.$MDT0.changelog_users | grep $USER | awk '{print $2}')
9071 $LFS changelog_clear $MDT0 $USER $(($USER_REC1 + 5))
9072 USER_REC2=$(do_facet $SINGLEMDS $LCTL get_param -n \
9073 mdd.$MDT0.changelog_users | grep $USER | awk '{print $2}')
9074 echo "verifying user clear: $(( $USER_REC1 + 5 )) == $USER_REC2"
9075 [ $USER_REC2 == $(($USER_REC1 + 5)) ] || \
9076 err17935 "user index should be $(($USER_REC1 + 5)); is $USER_REC2"
9078 MIN_REC=$(do_facet $SINGLEMDS $LCTL get_param mdd.$MDT0.changelog_users | \
9079 awk 'min == "" || $2 < min {min = $2}; END {print min}')
9080 FIRST_REC=$($LFS changelog $MDT0 | head -1 | awk '{print $1}')
9081 echo "verifying min purge: $(( $MIN_REC + 1 )) == $FIRST_REC"
9082 [ $FIRST_REC == $(($MIN_REC + 1)) ] || \
9083 err17935 "first index should be $(($MIN_REC + 1)); is $FIRST_REC"
9085 echo "verifying user deregister"
9086 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
9087 do_facet $SINGLEMDS $LCTL get_param -n mdd.$MDT0.changelog_users | \
9088 grep -q $USER && error "User $USER still found in changelog_users"
9090 USERS=$(( $(do_facet $SINGLEMDS $LCTL get_param -n \
9091 mdd.$MDT0.changelog_users | wc -l) - 2 ))
9092 if [ $USERS -eq 0 ]; then
9093 LAST_REC1=$(do_facet $SINGLEMDS $LCTL get_param -n \
9094 mdd.$MDT0.changelog_users | head -1 | awk '{print $3}')
9095 touch $DIR/$tdir/chloe
9096 LAST_REC2=$(do_facet $SINGLEMDS $LCTL get_param -n \
9097 mdd.$MDT0.changelog_users | head -1 | awk '{print $3}')
9098 echo "verify changelogs are off if we were the only user: $LAST_REC1 == $LAST_REC2"
9099 [ $LAST_REC1 == $LAST_REC2 ] || error "changelogs not off"
9101 echo "$USERS other changelog users; can't verify off"
9104 run_test 160 "changelog sanity"
9107 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9108 test_mkdir -p $DIR/$tdir
9109 cp /etc/hosts $DIR/$tdir/$tfile
9110 test_mkdir $DIR/$tdir/foo1
9111 test_mkdir $DIR/$tdir/foo2
9112 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
9113 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
9114 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
9115 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
9116 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
9117 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
9118 $LFS fid2path $DIR $FID
9119 err17935 "bad link ea"
9122 rm $DIR/$tdir/foo2/zachary
9124 rm $DIR/$tdir/foo2/thor
9126 rm $DIR/$tdir/$tfile
9128 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
9129 if [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ]
9131 $LFS fid2path $DIR $FID
9132 err17935 "bad link rename"
9134 rm $DIR/$tdir/foo2/maggie
9137 local longname=filename_avg_len_is_thirty_two_
9138 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 || \
9139 error "failed to hardlink many files"
9140 links=$($LFS fid2path $DIR $FID | wc -l)
9141 echo -n "${links}/1000 links in link EA"
9142 [ ${links} -gt 60 ] || err17935 "expected at least 60 links in link EA"
9143 unlinkmany $DIR/$tdir/foo2/$longname 1000 || \
9144 error "failed to unlink many hardlinks"
9146 run_test 161a "link ea sanity"
9149 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9150 [ $MDSCOUNT -lt 2 ] &&
9151 skip "skipping remote directory test" && return
9153 local remote_dir=$DIR/$tdir/remote_dir
9156 $LFS mkdir -i $MDTIDX $remote_dir ||
9157 error "create remote directory failed"
9159 cp /etc/hosts $remote_dir/$tfile
9160 mkdir -p $remote_dir/foo1
9161 mkdir -p $remote_dir/foo2
9162 ln $remote_dir/$tfile $remote_dir/foo1/sofia
9163 ln $remote_dir/$tfile $remote_dir/foo2/zachary
9164 ln $remote_dir/$tfile $remote_dir/foo1/luna
9165 ln $remote_dir/$tfile $remote_dir/foo2/thor
9167 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
9169 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
9170 $LFS fid2path $DIR $FID
9171 err17935 "bad link ea"
9174 rm $remote_dir/foo2/zachary
9176 rm $remote_dir/foo2/thor
9178 rm $remote_dir/$tfile
9180 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
9181 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
9182 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
9183 $LFS fid2path $DIR $FID
9184 err17935 "bad link rename"
9186 rm $remote_dir/foo2/maggie
9189 local longname=filename_avg_len_is_thirty_two_
9190 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
9191 error "failed to hardlink many files"
9192 links=$($LFS fid2path $DIR $FID | wc -l)
9193 echo -n "${links}/1000 links in link EA"
9194 [ ${links} -gt 60 ] || err17935 "expected at least 60 links in link EA"
9195 unlinkmany $remote_dir/foo2/$longname 1000 ||
9196 error "failed to unlink many hardlinks"
9198 run_test 161b "link ea sanity under remote directory"
9205 local path=$(${LFS} fid2path $*)
9208 if [ $RC -ne 0 ]; then
9209 err17935 "path looked up of $expected failed. Error $RC"
9211 elif [ "${path}" != "${expected}" ]; then
9212 err17935 "path looked up \"${path}\" instead of \"${expected}\""
9215 echo "fid $fid resolves to path $path (expected $expected)"
9219 # Make changes to filesystem
9220 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9221 test_mkdir -p $DIR/$tdir/d2
9222 touch $DIR/$tdir/d2/$tfile
9223 touch $DIR/$tdir/d2/x1
9224 touch $DIR/$tdir/d2/x2
9225 test_mkdir -p $DIR/$tdir/d2/a/b/c
9226 test_mkdir -p $DIR/$tdir/d2/p/q/r
9228 FID=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
9229 check_path "$tdir/d2/$tfile" $FSNAME $FID --link 0
9232 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
9233 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
9234 check_path "$tdir/d2/p/q/r/slink" $FSNAME $FID --link 0
9236 # softlink to wrong file
9237 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
9238 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
9239 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME $FID --link 0
9242 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
9243 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
9244 FID=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
9245 # fid2path dir/fsname should both work
9246 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 1
9247 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR $FID --link 0
9249 # hardlink count: check that there are 2 links
9250 # Doesnt work with CMD yet: 17935
9251 ${LFS} fid2path $DIR $FID | wc -l | grep -q 2 || \
9252 err17935 "expected 2 links"
9254 # hardlink indexing: remove the first link
9255 rm $DIR/$tdir/d2/p/q/r/hlink
9256 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 0
9260 run_test 162 "path lookup sanity"
9263 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9264 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9265 copytool --test $FSNAME || { skip "copytool not runnable: $?" && return; }
9268 local uuid=$($LCTL get_param -n mdc.${FSNAME}-MDT0000-mdc-*.uuid)
9269 # this proc file is temporary and linux-only
9270 do_facet $SINGLEMDS lctl set_param mdt.${FSNAME}-MDT0000.mdccomm=$uuid ||\
9271 error "kernel->userspace send failed"
9274 run_test 163 "kernel <-> userspace comms"
9277 # do directio so as not to populate the page cache
9278 log "creating a 10 Mb file"
9279 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
9280 log "starting reads"
9281 dd if=$DIR/$tfile of=/dev/null bs=4096 &
9282 log "truncating the file"
9283 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
9285 kill %+ || true # reads might have finished
9286 echo "wait until dd is finished"
9288 log "removing the temporary file"
9289 rm -rf $DIR/$tfile || error "tmp file removal failed"
9291 run_test 169 "parallel read and truncate should not deadlock"
9294 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9295 $LCTL clear # bug 18514
9296 $LCTL debug_daemon start $TMP/${tfile}_log_good
9298 $LCTL debug_daemon stop
9299 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
9300 error "sed failed to read log_good"
9302 $LCTL debug_daemon start $TMP/${tfile}_log_good
9304 $LCTL debug_daemon stop
9306 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
9307 error "lctl df log_bad failed"
9309 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
9310 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
9312 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
9313 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
9315 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
9316 error "bad_line good_line1 good_line2 are empty"
9318 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
9319 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
9320 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
9322 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
9323 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
9324 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
9326 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
9327 error "bad_line_new good_line_new are empty"
9329 local expected_good=$((good_line1 + good_line2*2))
9331 rm -f $TMP/${tfile}*
9332 # LU-231, short malformed line may not be counted into bad lines
9333 if [ $bad_line -ne $bad_line_new ] &&
9334 [ $bad_line -ne $((bad_line_new - 1)) ]; then
9335 error "expected $bad_line bad lines, but got $bad_line_new"
9339 if [ $expected_good -ne $good_line_new ]; then
9340 error "expected $expected_good good lines, but got $good_line_new"
9345 run_test 170 "test lctl df to handle corrupted log ====================="
9347 test_171() { # bug20592
9348 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9349 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
9350 $LCTL set_param fail_loc=0x50e
9351 $LCTL set_param fail_val=3000
9352 multiop_bg_pause $DIR/$tfile O_s || true
9354 kill -USR1 $MULTIPID
9358 if dmesg | grep "recursive fault"; then
9359 error "caught a recursive fault"
9361 $LCTL set_param fail_loc=0
9364 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
9366 # it would be good to share it with obdfilter-survey/libecho code
9367 setup_obdecho_osc () {
9370 local obdfilter_name=$2
9371 echo "Creating new osc for $obdfilter_name on $ost_nid"
9372 # make sure we can find loopback nid
9373 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
9375 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
9376 ${obdfilter_name}_osc_UUID || rc=2; }
9377 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
9378 ${obdfilter_name}_UUID $ost_nid || rc=3; }
9382 cleanup_obdecho_osc () {
9383 local obdfilter_name=$1
9384 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
9385 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
9389 obdecho_create_test() {
9394 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
9395 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
9397 if [ $rc -eq 0 ]; then
9398 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
9399 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
9401 echo "New object id is $id"
9402 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec test_brw 10 w v 64 $id" ||
9404 [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec " \
9405 "cleanup" || rc=5; }
9406 [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec " \
9408 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
9413 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9414 remote_ost_nodsh && skip "remote OST with nodsh" && return
9418 if ! module_loaded obdecho; then
9419 load_module obdecho/obdecho
9423 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
9424 local host=$(lctl get_param -n osc.$osc.import |
9425 awk '/current_connection:/ {print $2}' )
9426 local target=$(lctl get_param -n osc.$osc.import |
9427 awk '/target:/ {print $2}' )
9428 target=${target%_UUID}
9430 [[ -n $target ]] && { setup_obdecho_osc $host $target || rc=1; } || rc=1
9431 [ $rc -eq 0 ] && { obdecho_create_test ${target}_osc client || rc=2; }
9432 [[ -n $target ]] && cleanup_obdecho_osc $target
9433 [ $rmmod_local -eq 1 ] && rmmod obdecho
9436 run_test 180a "test obdecho on osc"
9439 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9440 remote_ost_nodsh && skip "remote OST with nodsh" && return
9442 local rmmod_remote=0
9444 do_facet ost1 "lsmod | grep -q obdecho || " \
9445 "{ insmod ${LUSTRE}/obdecho/obdecho.ko || " \
9446 "modprobe obdecho; }" && rmmod_remote=1
9447 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ {print $4;exit}')
9448 [[ -n $target ]] && { obdecho_create_test $target ost1 || rc=1; }
9449 [ $rmmod_remote -eq 1 ] && do_facet ost1 "rmmod obdecho"
9452 run_test 180b "test obdecho directly on obdfilter"
9454 test_181() { # bug 22177
9455 test_mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
9456 # create enough files to index the directory
9457 createmany -o $DIR/$tdir/foobar 4000
9458 # print attributes for debug purpose
9461 multiop_bg_pause $DIR/$tdir D_Sc || return 1
9463 # remove the files & current working dir
9464 unlinkmany $DIR/$tdir/foobar 4000
9466 kill -USR1 $MULTIPID
9468 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
9471 run_test 181 "Test open-unlinked dir ========================"
9474 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9475 # disable MDC RPC lock wouldn't crash client
9479 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
9480 #define OBD_FAIL_MDC_RPCS_SEM 0x804
9481 $LCTL set_param fail_loc=0x804
9483 for (( i=0; i < $tcount; i++ )) ; do
9485 createmany -o $DIR/$tdir/$i/f- $fcount &
9489 for (( i=0; i < $tcount; i++ )) ; do
9490 unlinkmany $DIR/$tdir/$i/f- $fcount &
9496 $LCTL set_param fail_loc=0
9498 run_test 182 "Disable MDC RPCs semaphore wouldn't crash client ================"
9500 test_183() { # LU-2275
9501 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9502 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
9503 echo aaa > $DIR/$tdir/$tfile
9505 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
9506 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
9508 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
9509 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
9511 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
9513 # Flush negative dentry cache
9514 touch $DIR/$tdir/$tfile
9516 # We are not checking for any leaked references here, they'll
9517 # become evident next time we do cleanup with module unload.
9520 run_test 183 "No crash or request leak in case of strange dispositions ========"
9522 test_185() { # LU-2441
9523 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
9524 touch $DIR/$tdir/spoo
9525 local mtime1=$(stat -c "%Y" $DIR/$tdir)
9526 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
9527 error "cannot create/write a volatile file"
9528 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
9529 error "FID is still valid after close"
9531 multiop_bg_pause $DIR/$tdir vVw4096_c
9538 # assume that the next FID for this client is sequential, since stdout
9539 # is unfortunately eaten by multiop_bg_pause
9540 local n=$((${fidv[1]} + 1))
9541 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
9542 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
9543 error "FID is missing before close"
9544 kill -USR1 $multi_pid
9545 # 1 second delay, so if mtime change we will see it
9547 local mtime2=$(stat -c "%Y" $DIR/$tdir)
9548 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
9550 run_test 185 "Volatile file support"
9552 check_swap_layouts_support()
9554 $LCTL get_param -n llite.*.sbi_flags | grep -q layout ||
9555 { skip "Does not support layout lock."; return 0; }
9559 # test suite 184 is for LU-2016, LU-2017
9561 check_swap_layouts_support && return 0
9563 dir0=$DIR/$tdir/$testnum
9564 test_mkdir -p $dir0 || error "creating dir $dir0"
9569 $SETSTRIPE -c1 $file1
9571 $SETSTRIPE -c2 $file2
9573 gen1=$($GETSTRIPE -g $file1)
9574 gen2=$($GETSTRIPE -g $file2)
9576 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
9577 gen=$($GETSTRIPE -g $file1)
9578 [[ $gen1 != $gen ]] ||
9579 "Layout generation on $file1 does not change"
9580 gen=$($GETSTRIPE -g $file2)
9581 [[ $gen2 != $gen ]] ||
9582 "Layout generation on $file2 does not change"
9584 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
9585 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
9587 run_test 184a "Basic layout swap"
9590 check_swap_layouts_support && return 0
9592 dir0=$DIR/$tdir/$testnum
9593 mkdir -p $dir0 || error "creating dir $dir0"
9600 $SETSTRIPE -c1 $file1
9601 $SETSTRIPE -c2 $file2
9602 $SETSTRIPE -c1 $file3
9603 chown $RUNAS_ID $file3
9604 gen1=$($GETSTRIPE -g $file1)
9605 gen2=$($GETSTRIPE -g $file2)
9607 $LFS swap_layouts $dir1 $dir2 &&
9608 error "swap of directories layouts should fail"
9609 $LFS swap_layouts $dir1 $file1 &&
9610 error "swap of directory and file layouts should fail"
9611 $RUNAS $LFS swap_layouts $file1 $file2 &&
9612 error "swap of file we cannot write should fail"
9613 $LFS swap_layouts $file1 $file3 &&
9614 error "swap of file with different owner should fail"
9615 /bin/true # to clear error code
9617 run_test 184b "Forbidden layout swap (will generate errors)"
9620 check_swap_layouts_support && return 0
9622 local dir0=$DIR/$tdir/$testnum
9623 mkdir -p $dir0 || error "creating dir $dir0"
9625 local ref1=$dir0/ref1
9626 local ref2=$dir0/ref2
9627 local file1=$dir0/file1
9628 local file2=$dir0/file2
9629 # create a file large enough for the concurent test
9630 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
9631 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
9632 echo "ref file size: ref1(`stat -c %s $ref1`), ref2(`stat -c %s $ref2`)"
9635 dd if=$ref1 of=$file1 bs=16k &
9638 # Make sure dd starts to copy file
9639 while [ ! -f $file1 ]; do sleep 0.1; done
9641 $LFS swap_layouts $file1 $file2
9644 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
9645 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
9647 # how many bytes copied before swapping layout
9648 local copied=`stat -c %s $file2`
9649 local remaining=`stat -c %s $ref1`
9650 remaining=$((remaining - copied))
9651 echo "Copied $copied bytes before swapping layout..."
9653 cmp -n $copied $file1 $ref2 | grep differ &&
9654 error "Content mismatch [0, $copied) of ref2 and file1"
9655 cmp -n $copied $file2 $ref1 ||
9656 error "Content mismatch [0, $copied) of ref1 and file2"
9657 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
9658 error "Content mismatch [$copied, EOF) of ref1 and file1"
9661 rm -f $ref1 $ref2 $file1 $file2
9663 run_test 184c "Concurrent write and layout swap"
9666 check_file_in_pool()
9671 local res=$($GETSTRIPE $file | grep 0x | cut -f2)
9674 for t in $tlist ; do
9675 [ "$i" -eq "$t" ] && continue 2
9678 echo "pool list: $tlist"
9679 echo "striping: $res"
9680 error_noexit "$file not allocated in $pool"
9687 echo "Creating new pool"
9690 create_pool $FSNAME.$pool ||
9691 { error_noexit "No pool created, result code $?"; return 1; }
9692 [ $($LFS pool_list $FSNAME | grep -c $pool) -eq 1 ] ||
9693 { error_noexit "$pool not in lfs pool_list"; return 2; }
9696 pool_add_targets() {
9697 echo "Adding targets to pool"
9703 local list=$(seq $first $step $last)
9705 local t=$(for i in $list; do printf "$FSNAME-OST%04x_UUID " $i; done)
9706 do_facet mgs $LCTL pool_add \
9707 $FSNAME.$pool $FSNAME-OST[$first-$last/$step]
9708 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$pool \
9709 | sort -u | tr '\n' ' ' " "$t" || {
9710 error_noexit "Add to pool failed"
9713 local lfscount=$($LFS pool_list $FSNAME.$pool | grep -c "\-OST")
9714 local addcount=$(((last - first) / step + 1))
9715 [ $lfscount -eq $addcount ] || {
9716 error_noexit "lfs pool_list bad ost count" \
9717 "$lfscount != $addcount"
9725 echo "Setting pool on directory $tdir"
9727 $SETSTRIPE -c 2 -p $pool $tdir && return 0
9729 error_noexit "Cannot set pool $pool to $tdir"
9736 echo "Checking pool on directory $tdir"
9738 local res=$($GETSTRIPE --pool $tdir | sed "s/\s*$//")
9739 [ "$res" = "$pool" ] && return 0
9741 error_noexit "Pool on '$tdir' is '$res', not '$pool'"
9745 pool_dir_rel_path() {
9746 echo "Testing relative path works well"
9751 mkdir -p $root/$tdir/$tdir
9753 pool_set_dir $pool $tdir || return 1
9754 pool_set_dir $pool ./$tdir || return 2
9755 pool_set_dir $pool ../$tdir || return 3
9756 pool_set_dir $pool ../$tdir/$tdir || return 4
9757 rm -rf $tdir; cd - > /dev/null
9760 pool_alloc_files() {
9761 echo "Checking files allocation from directory pool"
9768 for i in $(seq -w 1 $count)
9770 local file=$tdir/file-$i
9772 check_file_in_pool $file $pool "$tlist" || \
9773 failed=$((failed + 1))
9775 [ "$failed" = 0 ] && return 0
9777 error_noexit "$failed files not allocated in $pool"
9781 pool_create_files() {
9782 echo "Creating files in pool"
9790 for i in $(seq -w 1 $count)
9792 local file=$tdir/spoo-$i
9793 $SETSTRIPE -p $pool $file
9794 check_file_in_pool $file $pool "$tlist" || \
9795 failed=$((failed + 1))
9797 [ "$failed" = 0 ] && return 0
9799 error_noexit "$failed files not allocated in $pool"
9804 echo "Checking 'lfs df' output"
9807 local t=$($LCTL get_param -n lov.$FSNAME-clilov-*.pools.$pool |
9809 local res=$($LFS df --pool $FSNAME.$pool |
9811 grep "$FSNAME-OST" |
9813 [ "$res" = "$t" ] && return 0
9815 error_noexit "Pools OSTs '$t' is not '$res' that lfs df reports"
9819 pool_file_rel_path() {
9820 echo "Creating files in a pool with relative pathname"
9825 { error_noexit "unable to create $tdir"; return 1 ; }
9826 local file="/..$tdir/$tfile-1"
9827 $SETSTRIPE -p $pool $file ||
9828 { error_noexit "unable to create $file" ; return 2 ; }
9831 $SETSTRIPE -p $pool $tfile-2 || {
9832 error_noexit "unable to create $tfile-2 in $tdir"
9837 pool_remove_first_target() {
9838 echo "Removing first target from a pool"
9841 local pname="lov.$FSNAME-*.pools.$pool"
9842 local t=$($LCTL get_param -n $pname | head -1)
9843 do_facet mgs $LCTL pool_remove $FSNAME.$pool $t
9844 wait_update $HOSTNAME "lctl get_param -n $pname | grep $t" "" || {
9845 error_noexit "$t not removed from $FSNAME.$pool"
9850 pool_remove_all_targets() {
9851 echo "Removing all targets from pool"
9854 local pname="lov.$FSNAME-*.pools.$pool"
9855 for t in $($LCTL get_param -n $pname | sort -u)
9857 do_facet mgs $LCTL pool_remove $FSNAME.$pool $t
9859 wait_update $HOSTNAME "lctl get_param -n $pname" "" || {
9860 error_noexit "Pool $FSNAME.$pool cannot be drained"
9863 # striping on an empty/nonexistant pool should fall back
9864 # to "pool of everything"
9866 error_noexit "failed to use fallback striping for empty pool"
9869 # setstripe on an empty pool should fail
9870 $SETSTRIPE -p $pool $file 2>/dev/null && {
9871 error_noexit "expected failure when creating file" \
9879 echo "Destroying pool"
9883 do_facet mgs $LCTL pool_destroy $FSNAME.$pool
9886 # striping on an empty/nonexistant pool should fall back
9887 # to "pool of everything"
9889 error_noexit "failed to use fallback striping for missing pool"
9892 # setstripe on an empty pool should fail
9893 $SETSTRIPE -p $pool $file 2>/dev/null && {
9894 error_noexit "expected failure when creating file" \
9899 # get param should return err once pool is gone
9900 if wait_update $HOSTNAME "lctl get_param -n \
9901 lov.$FSNAME-*.pools.$pool 2>/dev/null || echo foo" "foo"
9903 remove_pool_from_list $FSNAME.$pool
9906 error_noexit "Pool $FSNAME.$pool is not destroyed"
9911 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9912 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
9914 local POOL=${POOL:-cea1}
9915 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
9916 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
9919 local last_ost=$(($OSTCOUNT - 1))
9921 local ost_list=$(seq $first_ost $ost_step $last_ost)
9922 local ost_range="$first_ost $last_ost $ost_step"
9923 local test_path=$POOL_ROOT/$POOL_DIR_NAME
9924 local file_dir=$POOL_ROOT/file_tst
9928 # former test_200a test_200b
9929 pool_add $POOL || { rc=$? ; break; }
9930 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
9931 # former test_200c test_200d
9933 pool_set_dir $POOL $test_path || { rc=$? ; break; }
9934 pool_check_dir $POOL $test_path || { rc=$? ; break; }
9935 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
9936 || { rc=$? ; break; }
9937 # former test_200e test_200f
9938 local files=$((OSTCOUNT*3))
9939 pool_alloc_files $POOL $test_path $files "$ost_list" \
9940 || { rc=$? ; break; }
9941 pool_create_files $POOL $file_dir $files "$ost_list" \
9942 || { rc=$? ; break; }
9943 # former test_200g test_200h
9944 pool_lfs_df $POOL || { rc=$? ; break; }
9945 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
9947 # former test_201a test_201b test_201c
9948 pool_remove_first_target $POOL || { rc=$? ; break; }
9950 local f=$test_path/$tfile
9951 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
9952 pool_remove $POOL $f || { rc=$? ; break; }
9959 run_test 200 "OST pools"
9961 # usage: default_attr <count | size | offset>
9963 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
9966 # usage: check_default_stripe_attr
9967 check_default_stripe_attr() {
9968 ACTUAL=$($GETSTRIPE $* $DIR/$tdir)
9970 --stripe-count|--count)
9971 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
9972 --stripe-size|--size)
9973 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
9974 --stripe-index|--index)
9977 error "unknown getstripe attr '$1'"
9980 [ $ACTUAL != $EXPECTED ] &&
9981 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
9985 test_mkdir -p $DIR/$tdir
9986 $SETSTRIPE --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
9988 check_default_stripe_attr --stripe-count
9989 check_default_stripe_attr --stripe-size
9990 check_default_stripe_attr --stripe-index
9994 run_test 204a "Print default stripe attributes ================="
9997 test_mkdir -p $DIR/$tdir
9998 $SETSTRIPE --stripe-count 1 $DIR/$tdir
10000 check_default_stripe_attr --stripe-size
10001 check_default_stripe_attr --stripe-index
10005 run_test 204b "Print default stripe size and offset ==========="
10008 test_mkdir -p $DIR/$tdir
10009 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
10011 check_default_stripe_attr --stripe-count
10012 check_default_stripe_attr --stripe-index
10016 run_test 204c "Print default stripe count and offset ==========="
10019 test_mkdir -p $DIR/$tdir
10020 $SETSTRIPE --stripe-index 0 $DIR/$tdir
10022 check_default_stripe_attr --stripe-count
10023 check_default_stripe_attr --stripe-size
10027 run_test 204d "Print default stripe count and size ============="
10030 test_mkdir -p $DIR/$tdir
10031 $SETSTRIPE -d $DIR/$tdir
10033 check_default_stripe_attr --stripe-count --raw
10034 check_default_stripe_attr --stripe-size --raw
10035 check_default_stripe_attr --stripe-index --raw
10039 run_test 204e "Print raw stripe attributes ================="
10042 test_mkdir -p $DIR/$tdir
10043 $SETSTRIPE --stripe-count 1 $DIR/$tdir
10045 check_default_stripe_attr --stripe-size --raw
10046 check_default_stripe_attr --stripe-index --raw
10050 run_test 204f "Print raw stripe size and offset ==========="
10053 test_mkdir -p $DIR/$tdir
10054 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
10056 check_default_stripe_attr --stripe-count --raw
10057 check_default_stripe_attr --stripe-index --raw
10061 run_test 204g "Print raw stripe count and offset ==========="
10064 test_mkdir -p $DIR/$tdir
10065 $SETSTRIPE --stripe-index 0 $DIR/$tdir
10067 check_default_stripe_attr --stripe-count --raw
10068 check_default_stripe_attr --stripe-size --raw
10072 run_test 204h "Print raw stripe count and size ============="
10074 # Figure out which job scheduler is being used, if any,
10075 # or use a fake one
10076 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
10077 JOBENV=SLURM_JOB_ID
10078 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
10080 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
10082 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
10083 JOBENV=LOADL_STEP_ID
10084 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
10090 verify_jobstats() {
10094 # clear old jobstats
10095 do_facet $SINGLEMDS lctl set_param mdt.*.job_stats="clear"
10096 do_facet ost1 lctl set_param obdfilter.*.job_stats="clear"
10098 # use a new JobID for this test, or we might see an old one
10099 [ "$JOBENV" = "FAKE_JOBID" ] && FAKE_JOBID=test_id.$testnum.$RANDOM
10103 log "Using JobID environment variable $JOBENV=$JOBVAL"
10105 if [ $JOBENV = "FAKE_JOBID" ]; then
10106 FAKE_JOBID=$JOBVAL $cmd
10111 if [ "$target" = "mdt" -o "$target" = "both" ]; then
10112 FACET="$SINGLEMDS" # will need to get MDS number for DNE
10113 do_facet $FACET lctl get_param mdt.*.job_stats |
10114 grep $JOBVAL || error "No job stats found on MDT $FACET"
10116 if [ "$target" = "ost" -o "$target" = "both" ]; then
10118 do_facet $FACET lctl get_param obdfilter.*.job_stats |
10119 grep $JOBVAL || error "No job stats found on OST $FACET"
10125 NEW_JOBENV=${1:-$OLD_JOBENV}
10126 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$NEW_JOBENV
10127 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" $NEW_JOBENV
10130 test_205() { # Job stats
10131 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10132 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
10133 skip "Server doesn't support jobstats" && return 0
10136 OLD_JOBENV=`$LCTL get_param -n jobid_var`
10137 if [ $OLD_JOBENV != $JOBENV ]; then
10138 jobstats_set $JOBENV
10139 trap jobstats_set EXIT
10143 cmd="mkdir $DIR/$tfile"
10144 verify_jobstats "$cmd" "mdt"
10146 cmd="rm -fr $DIR/$tfile"
10147 verify_jobstats "$cmd" "mdt"
10149 cmd="mknod $DIR/$tfile c 1 3"
10150 verify_jobstats "$cmd" "mdt"
10152 cmd="rm -f $DIR/$tfile"
10153 verify_jobstats "$cmd" "mdt"
10155 cmd="$SETSTRIPE -i 0 -c 1 $DIR/$tfile"
10156 verify_jobstats "$cmd" "mdt"
10158 cmd="touch $DIR/$tfile"
10159 verify_jobstats "$cmd" "both"
10161 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
10162 verify_jobstats "$cmd" "ost"
10164 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
10165 verify_jobstats "$cmd" "ost"
10167 cmd="$TRUNCATE $DIR/$tfile 0"
10168 verify_jobstats "$cmd" "both"
10170 cmd="mv -f $DIR/$tfile $DIR/jobstats_test_rename"
10171 verify_jobstats "$cmd" "mdt"
10174 rm -f $DIR/jobstats_test_rename
10176 [ $OLD_JOBENV != $JOBENV ] && jobstats_set $OLD_JOBENV
10178 run_test 205 "Verify job stats"
10180 # LU-1480, LU-1773 and LU-1657
10182 mkdir -p $DIR/$tdir
10183 lfs setstripe -c -1 $DIR/$tdir
10184 #define OBD_FAIL_LOV_INIT 0x1403
10185 $LCTL set_param fail_loc=0xa0001403
10186 $LCTL set_param fail_val=1
10187 touch $DIR/$tdir/$tfile || true
10189 run_test 206 "fail lov_init_raid0() doesn't lbug"
10192 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
10193 local fsz=`stat -c %s $DIR/$tfile`
10194 cancel_lru_locks mdc
10196 # do not return layout in getattr intent
10197 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
10198 $LCTL set_param fail_loc=0x170
10199 local sz=`stat -c %s $DIR/$tfile`
10201 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
10205 run_test 207a "can refresh layout at glimpse"
10208 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
10209 local cksum=`md5sum $DIR/$tfile`
10210 local fsz=`stat -c %s $DIR/$tfile`
10211 cancel_lru_locks mdc
10212 cancel_lru_locks osc
10214 # do not return layout in getattr intent
10215 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
10216 $LCTL set_param fail_loc=0x171
10218 # it will refresh layout after the file is opened but before read issues
10219 echo checksum is "$cksum"
10220 echo "$cksum" |md5sum -c --quiet || error "file differs"
10224 run_test 207b "can refresh layout at open"
10228 size=$((size % 8192 + 1))
10229 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
10230 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
10231 rm -f $DIR/f212 $DIR/f212.xyz
10233 run_test 212 "Sendfile test ============================================"
10236 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
10237 cancel_lru_locks osc
10238 lctl set_param fail_loc=0x8000040f
10239 # generate a read lock
10240 cat $DIR/$tfile > /dev/null
10241 # write to the file, it will try to cancel the above read lock.
10242 cat /etc/hosts >> $DIR/$tfile
10244 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
10246 test_214() { # for bug 20133
10247 test_mkdir -p $DIR/d214p/d214c
10248 for (( i=0; i < 340; i++ )) ; do
10249 touch $DIR/d214p/d214c/a$i
10252 ls -l $DIR/d214p || error "ls -l $DIR/d214p failed"
10253 mv $DIR/d214p/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
10254 ls $DIR/d214c || error "ls $DIR/d214c failed"
10255 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
10257 run_test 214 "hash-indexed directory test - bug 20133"
10259 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
10260 create_lnet_proc_files() {
10261 cat /proc/sys/lnet/$1 >$TMP/lnet_$1.out || error "cannot read /proc/sys/lnet/$1"
10262 sysctl lnet.$1 >$TMP/lnet_$1.sys_tmp || error "cannot read lnet.$1"
10264 sed "s/^lnet.$1\ =\ //g" "$TMP/lnet_$1.sys_tmp" >$TMP/lnet_$1.sys
10265 rm -f "$TMP/lnet_$1.sys_tmp"
10268 # counterpart of create_lnet_proc_files
10269 remove_lnet_proc_files() {
10270 rm -f $TMP/lnet_$1.out $TMP/lnet_$1.sys
10273 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
10274 # 3rd arg as regexp for body
10275 check_lnet_proc_stats() {
10276 local l=$(cat "$TMP/lnet_$1" |wc -l)
10277 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
10279 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
10282 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
10283 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
10284 # optional and can be regexp for 2nd line (lnet.routes case)
10285 check_lnet_proc_entry() {
10286 local blp=2 # blp stands for 'position of 1st line of body'
10287 [ "$5" = "" ] || blp=3 # lnet.routes case
10289 local l=$(cat "$TMP/lnet_$1" |wc -l)
10290 # subtracting one from $blp because the body can be empty
10291 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
10293 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
10294 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
10296 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
10297 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
10299 # bail out if any unexpected line happened
10300 sed -n "$blp~1 p" "$TMP/lnet_$1" |grep -Ev "$3"
10301 [ "$?" != 0 ] || error "$2 misformatted"
10304 test_215() { # for bugs 18102, 21079, 21517
10305 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10306 local N='(0|[1-9][0-9]*)' # non-negative numeric
10307 local P='[1-9][0-9]*' # positive numeric
10308 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
10309 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
10310 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
10311 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
10313 local L1 # regexp for 1st line
10314 local L2 # regexp for 2nd line (optional)
10315 local BR # regexp for the rest (body)
10317 # /proc/sys/lnet/stats should look as 11 space-separated non-negative numerics
10318 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
10319 create_lnet_proc_files "stats"
10320 check_lnet_proc_stats "stats.out" "/proc/sys/lnet/stats" "$BR"
10321 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
10322 remove_lnet_proc_files "stats"
10324 # /proc/sys/lnet/routes should look like this:
10325 # Routing disabled/enabled
10326 # net hops state router
10327 # where net is a string like tcp0, hops >= 0, state is up/down,
10328 # router is a string like 192.168.1.1@tcp2
10329 L1="^Routing (disabled|enabled)$"
10330 L2="^net +hops +state +router$"
10331 BR="^$NET +$N +(up|down) +$NID$"
10332 create_lnet_proc_files "routes"
10333 check_lnet_proc_entry "routes.out" "/proc/sys/lnet/routes" "$BR" "$L1" "$L2"
10334 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
10335 remove_lnet_proc_files "routes"
10337 # /proc/sys/lnet/routers should look like this:
10338 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
10339 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
10340 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
10341 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
10342 L1="^ref +rtr_ref +alive_cnt +state +last_ping +ping_sent +deadline +down_ni +router$"
10343 BR="^$P +$P +$N +(up|down) +$N +(0|1) +$I +$I +$NID$"
10344 create_lnet_proc_files "routers"
10345 check_lnet_proc_entry "routers.out" "/proc/sys/lnet/routers" "$BR" "$L1"
10346 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
10347 remove_lnet_proc_files "routers"
10349 # /proc/sys/lnet/peers should look like this:
10350 # nid refs state last max rtr min tx min queue
10351 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
10352 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
10353 # numeric (0 or >0 or <0), queue >= 0.
10354 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
10355 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
10356 create_lnet_proc_files "peers"
10357 check_lnet_proc_entry "peers.out" "/proc/sys/lnet/peers" "$BR" "$L1"
10358 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
10359 remove_lnet_proc_files "peers"
10361 # /proc/sys/lnet/buffers should look like this:
10362 # pages count credits min
10363 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
10364 L1="^pages +count +credits +min$"
10365 BR="^ +$N +$N +$I +$I$"
10366 create_lnet_proc_files "buffers"
10367 check_lnet_proc_entry "buffers.out" "/proc/sys/lnet/buffers" "$BR" "$L1"
10368 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
10369 remove_lnet_proc_files "buffers"
10371 # /proc/sys/lnet/nis should look like this:
10372 # nid status alive refs peer rtr max tx min
10373 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
10374 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
10375 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
10376 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
10377 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
10378 create_lnet_proc_files "nis"
10379 check_lnet_proc_entry "nis.out" "/proc/sys/lnet/nis" "$BR" "$L1"
10380 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
10381 remove_lnet_proc_files "nis"
10383 # can we successfully write to /proc/sys/lnet/stats?
10384 echo "0" >/proc/sys/lnet/stats || error "cannot write to /proc/sys/lnet/stats"
10385 sysctl -w lnet.stats=0 || error "cannot write to lnet.stats"
10387 run_test 215 "/proc/sys/lnet exists and has proper content - bugs 18102, 21079, 21517"
10389 test_216() { # bug 20317
10390 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10391 remote_ost_nodsh && skip "remote OST with nodsh" && return
10393 local p="$TMP/sanityN-$TESTNAME.parameters"
10394 save_lustre_params $HOSTNAME "osc.*.contention_seconds" > $p
10395 for node in $(osts_nodes); do
10396 save_lustre_params $node "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
10397 save_lustre_params $node "ldlm.namespaces.filter-*.contended_locks" >> $p
10398 save_lustre_params $node "ldlm.namespaces.filter-*.contention_seconds" >> $p
10402 # agressive lockless i/o settings
10403 for node in $(osts_nodes); do
10404 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'
10406 lctl set_param -n osc.*.contention_seconds 60
10408 $DIRECTIO write $DIR/$tfile 0 10 4096
10409 $CHECKSTAT -s 40960 $DIR/$tfile
10411 # disable lockless i/o
10412 for node in $(osts_nodes); do
10413 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'
10415 lctl set_param -n osc.*.contention_seconds 0
10418 dd if=/dev/zero of=$DIR/$tfile count=0
10419 $CHECKSTAT -s 0 $DIR/$tfile
10421 restore_lustre_params <$p
10425 run_test 216 "check lockless direct write works and updates file size and kms correctly"
10427 test_217() { # bug 22430
10428 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10432 for node in $(nodes_list); do
10433 nid=$(host_nids_address $node $NETTYPE)
10434 if [[ $nid = *-* ]] ; then
10435 echo "lctl ping $nid@$NETTYPE"
10436 lctl ping $nid@$NETTYPE
10438 echo "skipping $node (no hyphen detected)"
10442 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
10445 # do directio so as not to populate the page cache
10446 log "creating a 10 Mb file"
10447 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
10448 log "starting reads"
10449 dd if=$DIR/$tfile of=/dev/null bs=4096 &
10450 log "truncating the file"
10451 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
10453 kill %+ || true # reads might have finished
10454 echo "wait until dd is finished"
10456 log "removing the temporary file"
10457 rm -rf $DIR/$tfile || error "tmp file removal failed"
10459 run_test 218 "parallel read and truncate should not deadlock ======================="
10462 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10463 # write one partial page
10464 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
10465 # set no grant so vvp_io_commit_write will do sync write
10466 $LCTL set_param fail_loc=0x411
10467 # write a full page at the end of file
10468 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
10470 $LCTL set_param fail_loc=0
10471 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
10472 $LCTL set_param fail_loc=0x411
10473 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
10475 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
10477 test_220() { #LU-325
10478 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10479 remote_ost_nodsh && skip "remote OST with nodsh" && return
10482 test_mkdir -p $DIR/$tdir
10483 local OST=$(lfs osts | grep ${OSTIDX}": " | \
10484 awk '{print $2}' | sed -e 's/_UUID$//')
10487 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
10488 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
10489 osc.$mdtosc_proc1.prealloc_last_id)
10490 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
10491 osc.$mdtosc_proc1.prealloc_next_id)
10495 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
10496 #define OBD_FAIL_OST_ENOINO 0x229
10497 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
10498 do_facet mgs $LCTL pool_new $FSNAME.$TESTNAME || return 1
10499 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
10501 $SETSTRIPE $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
10503 MDSOBJS=$((last_id - next_id))
10504 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
10506 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
10507 echo "OST still has $count kbytes free"
10509 echo "create $MDSOBJS files @next_id..."
10510 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
10512 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
10513 osc.$mdtosc_proc1.prealloc_last_id)
10514 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
10515 osc.$mdtosc_proc1.prealloc_next_id)
10517 echo "after creation, last_id=$last_id2, next_id=$next_id2"
10522 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
10523 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
10525 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST || return 4
10526 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME || return 5
10527 echo "unlink $MDSOBJS files @$next_id..."
10528 unlinkmany $DIR/$tdir/f $MDSOBJS || return 6
10530 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
10533 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10534 dd if=`which date` of=$MOUNT/date oflag=sync
10535 chmod +x $MOUNT/date
10537 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
10538 $LCTL set_param fail_loc=0x80001401
10540 $MOUNT/date > /dev/null
10543 run_test 221 "make sure fault and truncate race to not cause OOM"
10546 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10548 test_mkdir -p $DIR/$tdir
10549 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
10550 createmany -o $DIR/$tdir/$tfile 10
10551 cancel_lru_locks mdc
10552 cancel_lru_locks osc
10553 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
10554 $LCTL set_param fail_loc=0x31a
10555 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
10556 $LCTL set_param fail_loc=0
10559 run_test 222a "AGL for ls should not trigger CLIO lock failure ================"
10562 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10564 test_mkdir -p $DIR/$tdir
10565 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
10566 createmany -o $DIR/$tdir/$tfile 10
10567 cancel_lru_locks mdc
10568 cancel_lru_locks osc
10569 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
10570 $LCTL set_param fail_loc=0x31a
10571 rm -r $DIR/$tdir || "AGL for rmdir failed"
10572 $LCTL set_param fail_loc=0
10574 run_test 222b "AGL for rmdir should not trigger CLIO lock failure ============="
10577 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10579 test_mkdir -p $DIR/$tdir
10580 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
10581 createmany -o $DIR/$tdir/$tfile 10
10582 cancel_lru_locks mdc
10583 cancel_lru_locks osc
10584 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
10585 $LCTL set_param fail_loc=0x31b
10586 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
10587 $LCTL set_param fail_loc=0
10590 run_test 223 "osc reenqueue if without AGL lock granted ======================="
10592 test_224a() { # LU-1039, MRP-303
10593 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10594 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
10595 $LCTL set_param fail_loc=0x508
10596 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
10597 $LCTL set_param fail_loc=0
10600 run_test 224a "Don't panic on bulk IO failure"
10602 test_224b() { # LU-1039, MRP-303
10603 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10604 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
10605 cancel_lru_locks osc
10606 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
10607 $LCTL set_param fail_loc=0x515
10608 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
10609 $LCTL set_param fail_loc=0
10612 run_test 224b "Don't panic on bulk IO failure"
10614 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
10616 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10617 if [ -z ${MDSSURVEY} ]; then
10618 skip_env "mds-survey not found" && return
10620 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
10621 { skip "Need MDS version at least 2.2.51"; return; }
10623 local mds=$(facet_host $SINGLEMDS)
10624 local target=$(do_nodes $mds 'lctl dl' | \
10625 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
10627 local cmd1="file_count=1000 thrhi=4"
10628 local cmd2="dir_count=2 layer=mdd stripe_count=0"
10629 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
10630 local cmd="$cmd1 $cmd2 $cmd3"
10632 rm -f ${TMP}/mds_survey*
10634 eval $cmd || error "mds-survey with zero-stripe failed"
10635 cat ${TMP}/mds_survey*
10636 rm -f ${TMP}/mds_survey*
10638 run_test 225a "Metadata survey sanity with zero-stripe"
10641 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10642 if [ -z ${MDSSURVEY} ]; then
10643 skip_env "mds-survey not found" && return
10645 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
10646 { skip "Need MDS version at least 2.2.51"; return; }
10648 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
10649 skip_env "Need to mount OST to test" && return
10652 local mds=$(facet_host $SINGLEMDS)
10653 local target=$(do_nodes $mds 'lctl dl' | \
10654 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
10656 local cmd1="file_count=1000 thrhi=4"
10657 local cmd2="dir_count=2 layer=mdd stripe_count=1"
10658 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
10659 local cmd="$cmd1 $cmd2 $cmd3"
10661 rm -f ${TMP}/mds_survey*
10663 eval $cmd || error "mds-survey with stripe_count failed"
10664 cat ${TMP}/mds_survey*
10665 rm -f ${TMP}/mds_survey*
10667 run_test 225b "Metadata survey sanity with stripe_count = 1"
10669 mcreate_path2fid () {
10675 local path=$DIR/$tdir/$name
10680 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
10681 error "cannot create $desc"
10683 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
10685 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
10687 fid_path=$($LFS fid2path $MOUNT $fid)
10689 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
10691 [ "$path" == "$fid_path" ] ||
10692 error "fid2path returned $fid_path, expected $path"
10694 echo "pass with $path and $fid"
10699 mkdir -p $DIR/$tdir
10701 mcreate_path2fid 0010666 0 0 fifo "FIFO"
10702 mcreate_path2fid 0020666 1 3 null "character special file (null)"
10703 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
10704 mcreate_path2fid 0040666 0 0 dir "directory"
10705 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
10706 mcreate_path2fid 0100666 0 0 file "regular file"
10707 mcreate_path2fid 0120666 0 0 link "symbolic link"
10708 mcreate_path2fid 0140666 0 0 sock "socket"
10710 run_test 226a "call path2fid and fid2path on files of all type"
10713 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
10717 mkdir -p $DIR/$tdir
10718 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
10719 error "create remote directory failed"
10720 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
10721 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
10722 "character special file (null)"
10723 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
10724 "character special file (no device)"
10725 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
10726 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
10727 "block special file (loop)"
10728 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
10729 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
10730 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
10732 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
10734 # LU-1299 Executing or running ldd on a truncated executable does not
10735 # cause an out-of-memory condition.
10737 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10738 dd if=`which date` of=$MOUNT/date bs=1k count=1
10739 chmod +x $MOUNT/date
10741 $MOUNT/date > /dev/null
10742 ldd $MOUNT/date > /dev/null
10745 run_test 227 "running truncated executable does not cause OOM"
10747 # LU-1512 try to reuse idle OI blocks
10749 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10750 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
10751 skip "non-ldiskfs backend" && return
10753 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
10754 local myDIR=$DIR/$tdir
10757 #define OBD_FAIL_SEQ_EXHAUST 0x1002
10758 $LCTL set_param fail_loc=0x80001002
10759 createmany -o $myDIR/t- 10000
10760 $LCTL set_param fail_loc=0
10761 # The guard is current the largest FID holder
10763 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
10765 local IDX=$(($SEQ % 64))
10767 do_facet $SINGLEMDS sync
10768 # Make sure journal flushed.
10770 local blk1=$(do_facet $SINGLEMDS \
10771 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
10772 grep Blockcount | awk '{print $4}')
10774 # Remove old files, some OI blocks will become idle.
10775 unlinkmany $myDIR/t- 10000
10776 # Create new files, idle OI blocks should be reused.
10777 createmany -o $myDIR/t- 2000
10778 do_facet $SINGLEMDS sync
10779 # Make sure journal flushed.
10781 local blk2=$(do_facet $SINGLEMDS \
10782 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
10783 grep Blockcount | awk '{print $4}')
10785 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
10787 run_test 228a "try to reuse idle OI blocks"
10790 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10791 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
10792 skip "non-ldiskfs backend" && return
10794 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
10795 local myDIR=$DIR/$tdir
10798 #define OBD_FAIL_SEQ_EXHAUST 0x1002
10799 $LCTL set_param fail_loc=0x80001002
10800 createmany -o $myDIR/t- 10000
10801 $LCTL set_param fail_loc=0
10802 # The guard is current the largest FID holder
10804 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
10806 local IDX=$(($SEQ % 64))
10808 do_facet $SINGLEMDS sync
10809 # Make sure journal flushed.
10811 local blk1=$(do_facet $SINGLEMDS \
10812 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
10813 grep Blockcount | awk '{print $4}')
10815 # Remove old files, some OI blocks will become idle.
10816 unlinkmany $myDIR/t- 10000
10819 stop $SINGLEMDS || error "Fail to stop MDT."
10821 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
10823 df $MOUNT || error "Fail to df."
10824 # Create new files, idle OI blocks should be reused.
10825 createmany -o $myDIR/t- 2000
10826 do_facet $SINGLEMDS sync
10827 # Make sure journal flushed.
10829 local blk2=$(do_facet $SINGLEMDS \
10830 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
10831 grep Blockcount | awk '{print $4}')
10833 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
10835 run_test 228b "idle OI blocks can be reused after MDT restart"
10839 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10840 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
10841 skip "non-ldiskfs backend" && return
10843 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
10844 local myDIR=$DIR/$tdir
10847 #define OBD_FAIL_SEQ_EXHAUST 0x1002
10848 $LCTL set_param fail_loc=0x80001002
10849 # 20000 files can guarantee there are index nodes in the OI file
10850 createmany -o $myDIR/t- 20000
10851 $LCTL set_param fail_loc=0
10852 # The guard is current the largest FID holder
10854 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
10856 local IDX=$(($SEQ % 64))
10858 do_facet $SINGLEMDS sync
10859 # Make sure journal flushed.
10861 local blk1=$(do_facet $SINGLEMDS \
10862 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
10863 grep Blockcount | awk '{print $4}')
10865 # Remove old files, some OI blocks will become idle.
10866 unlinkmany $myDIR/t- 20000
10868 # The OI file should become empty now
10870 # Create new files, idle OI blocks should be reused.
10871 createmany -o $myDIR/t- 2000
10872 do_facet $SINGLEMDS sync
10873 # Make sure journal flushed.
10875 local blk2=$(do_facet $SINGLEMDS \
10876 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
10877 grep Blockcount | awk '{print $4}')
10879 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
10881 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
10884 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10885 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
10888 mkdir -p $DIR/$tdir/test_230_local
10889 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230_local)
10890 [ $mdt_idx -ne 0 ] &&
10891 error "create local directory on wrong MDT $mdt_idx"
10893 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
10894 error "create remote directory failed"
10895 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230)
10896 [ $mdt_idx -ne $MDTIDX ] &&
10897 error "create remote directory on wrong MDT $mdt_idx"
10899 createmany -o $DIR/$tdir/test_230/t- 10 ||
10900 error "create files on remote directory failed"
10901 mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230/t-0)
10902 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
10903 rm -r $DIR/$tdir || error "unlink remote directory failed"
10905 run_test 230a "Create remote directory and files under the remote directory"
10908 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10909 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
10911 local remote_dir=$DIR/$tdir/remote_dir
10914 mkdir -p $DIR/$tdir
10915 $LFS mkdir -i $MDTIDX $remote_dir ||
10916 error "create remote directory failed"
10918 $LFS mkdir -i 0 $remote_dir/new_dir &&
10919 error "nested remote directory create succeed!"
10921 do_facet mds$((MDTIDX + 1)) lctl set_param mdt.*.enable_remote_dir=1
10922 $LFS mkdir -i 0 $remote_dir/new_dir || rc=$?
10923 do_facet mds$((MDTIDX + 1)) lctl set_param mdt.*.enable_remote_dir=0
10926 error "create remote directory failed after set enable_remote_dir"
10928 rm -rf $remote_dir || error "first unlink remote directory failed"
10930 $RUNAS -G$RUNAS_GID $LFS mkdir -i $MDTIDX $DIR/$tfile &&
10931 error "chown worked"
10933 do_facet mds$MDTIDX lctl set_param \
10934 mdt.*.enable_remote_dir_gid=$RUNAS_GID
10935 $LFS mkdir -i $MDTIDX $remote_dir || rc=$?
10936 do_facet mds$MDTIDX lctl set_param mdt.*.enable_remote_dir_gid=0
10939 error "create remote dir failed after set enable_remote_dir_gid"
10941 rm -r $DIR/$tdir || error "second unlink remote directory failed"
10943 run_test 230b "nested remote directory should be failed"
10947 # For simplicity this test assumes that max_pages_per_rpc
10948 # is the same across all OSCs
10949 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -1)
10950 local bulk_size=$((max_pages * 4096))
10952 mkdir -p $DIR/$tdir
10954 # clear the OSC stats
10955 $LCTL set_param osc.*.stats=0 &>/dev/null
10957 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
10958 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
10959 oflag=direct &>/dev/null || error "dd failed"
10961 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
10962 if [ x$nrpcs != "x1" ]; then
10963 error "found $nrpc ost_write RPCs, not 1 as expected"
10966 # Drop the OSC cache, otherwise we will read from it
10967 cancel_lru_locks osc
10969 # clear the OSC stats
10970 $LCTL set_param osc.*.stats=0 &>/dev/null
10972 # Client reads $bulk_size.
10973 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
10974 iflag=direct &>/dev/null || error "dd failed"
10976 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
10977 if [ x$nrpcs != "x1" ]; then
10978 error "found $nrpc ost_read RPCs, not 1 as expected"
10981 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
10984 mkdir -p $DIR/$tdir
10986 for i in {0..1023}; do
10987 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
10988 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
10989 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
10993 run_test 231b "must not assert on fully utilized OST request buffer"
10996 mkdir -p $DIR/$tdir
10997 #define OBD_FAIL_LDLM_OST_LVB 0x31c
10998 $LCTL set_param fail_loc=0x31c
11000 # ignore dd failure
11001 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
11003 $LCTL set_param fail_loc=0
11004 umount_client $MOUNT || error "umount failed"
11005 mount_client $MOUNT || error "mount failed"
11007 run_test 232 "failed lock should not block umount"
11010 # tests that do cleanup/setup should be run at the end
11014 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11016 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
11017 $LCTL set_param fail_loc=0x903
11018 # cancel_lru_locks mgc - does not work due to lctl set_param syntax
11019 for ls in /proc/fs/lustre/ldlm/namespaces/MGC*/lru_size; do
11022 FAIL_ON_ERROR=true cleanup
11023 FAIL_ON_ERROR=true setup
11025 run_test 900 "umount should not race with any mgc requeue thread"
11028 check_and_cleanup_lustre
11029 if [ "$I_MOUNTED" != "yes" ]; then
11030 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true