2 # -*- tab-width: 4; indent-tabs-mode: t; -*-
4 # Run select tests by setting ONLY, or as arguments to the script.
5 # Skip specific tests by setting EXCEPT.
7 # e.g. ONLY="22 23" or ONLY="`seq 32 39`" or EXCEPT="31"
11 # bug number for skipped test: 13297 2108 9789 3637 9789 3561 12622 5188
12 ALWAYS_EXCEPT=" 27u 42a 42b 42c 42d 45 51d 68b $SANITY_EXCEPT"
13 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
15 # with LOD/OSP landing
16 # bug number for skipped tests: LU-2036
17 ALWAYS_EXCEPT=" 76 $ALWAYS_EXCEPT"
20 SRCDIR=$(cd $(dirname $0); echo $PWD)
21 export PATH=$PATH:/sbin
25 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
26 CREATETEST=${CREATETEST:-createtest}
28 LFIND=${LFIND:-"$LFS find"}
29 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
31 MCREATE=${MCREATE:-mcreate}
32 OPENFILE=${OPENFILE:-openfile}
33 OPENUNLINK=${OPENUNLINK:-openunlink}
34 export MULTIOP=${MULTIOP:-multiop}
35 READS=${READS:-"reads"}
36 MUNLINK=${MUNLINK:-munlink}
37 SOCKETSERVER=${SOCKETSERVER:-socketserver}
38 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
39 MEMHOG=${MEMHOG:-memhog}
40 DIRECTIO=${DIRECTIO:-directio}
41 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
42 UMOUNT=${UMOUNT:-"umount -d"}
44 CHECK_GRANT=${CHECK_GRANT:-"yes"}
45 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
46 export PARALLEL=${PARALLEL:-"no"}
48 export NAME=${NAME:-local}
55 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
56 . $LUSTRE/tests/test-framework.sh
58 . ${CONFIG:=$LUSTRE/tests/cfg/${NAME}.sh}
61 [ "$SLOW" = "no" ] && EXCEPT_SLOW="24o 24v 27m 36f 36g 36h 51b 60c 63 64b 68 71 73 77f 78 101a 103 115 120g 124b"
67 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
68 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
77 check_kernel_version() {
79 GOT_VER=$(lctl get_param -n version | awk '/kernel:/ {print $2}')
81 patchless|patchless_client) return 0;;
82 *) [ $GOT_VER -ge $WANT_VER ] && return 0 ;;
84 log "test needs at least kernel version $WANT_VER, running $GOT_VER"
88 if [ "$ONLY" == "cleanup" ]; then
93 check_and_setup_lustre
98 MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid | \
99 awk '{gsub(/_UUID/,""); print $1}' | head -1)
100 LOVNAME=$($LCTL get_param -n llite.*.lov.common_name | tail -n 1)
101 OSTCOUNT=$($LCTL get_param -n lov.$LOVNAME.numobd)
102 STRIPECOUNT=$($LCTL get_param -n lov.$LOVNAME.stripecount)
103 STRIPESIZE=$($LCTL get_param -n lov.$LOVNAME.stripesize)
104 ORIGFREE=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
105 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
107 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
108 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
109 rm -rf $DIR/[Rdfs][0-9]*
111 # $RUNAS_ID may get set incorrectly somewhere else
112 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
114 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
118 if [ "${ONLY}" = "MOUNT" ] ; then
119 echo "Lustre is up, please go on"
123 echo "preparing for tests involving mounts"
124 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
126 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
127 echo # add a newline after mke2fs.
131 OLDDEBUG="`lctl get_param -n debug 2> /dev/null`"
132 lctl set_param debug=-1 2> /dev/null || true
135 $CHECKSTAT -t file $DIR/$tfile || error
137 $CHECKSTAT -a $DIR/$tfile || error
139 run_test 0 "touch .../$tfile ; rm .../$tfile ====================="
142 chmod 0755 $DIR || error
143 $CHECKSTAT -p 0755 $DIR || error
145 run_test 0b "chmod 0755 $DIR ============================="
148 $LCTL get_param mdc.*.import | grep "state: FULL" || error "import not FULL"
149 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" || error "bad target"
151 run_test 0c "check import proc ============================="
154 test_mkdir -p $DIR/$tdir
155 test_mkdir -p $DIR/$tdir/d2
156 test_mkdir $DIR/$tdir/d2 && error "we expect EEXIST, but not returned"
157 $CHECKSTAT -t dir $DIR/$tdir/d2 || error
159 run_test 1a "mkdir .../d1; mkdir .../d1/d2 ====================="
164 $CHECKSTAT -a $DIR/$tdir || error
166 run_test 1b "rmdir .../d1/d2; rmdir .../d1 ====================="
169 test_mkdir $DIR/$tdir
170 touch $DIR/$tdir/$tfile
171 $CHECKSTAT -t file $DIR/$tdir/$tfile || error
173 run_test 2a "mkdir .../d2; touch .../d2/f ======================"
177 $CHECKSTAT -a $DIR/$tdir || error
179 run_test 2b "rm -r .../d2; checkstat .../d2/f ======================"
182 test_mkdir -p $DIR/$tdir
183 $CHECKSTAT -t dir $DIR/$tdir || error
185 run_test 3a "mkdir .../d3 ======================================"
188 if [ ! -d $DIR/$tdir ]; then
191 touch $DIR/$tdir/$tfile
192 $CHECKSTAT -t file $DIR/$tdir/$tfile || error
194 run_test 3b "touch .../d3/f ===================================="
198 $CHECKSTAT -a $DIR/$tdir || error
200 run_test 3c "rm -r .../d3 ======================================"
203 test_mkdir -p $DIR/$tdir
204 $CHECKSTAT -t dir $DIR/$tdir || error
206 run_test 4a "mkdir .../d4 ======================================"
209 if [ ! -d $DIR/$tdir ]; then
210 test_mkdir $DIR/$tdir
212 test_mkdir $DIR/$tdir/d2
214 $CHECKSTAT -t dir $DIR/$tdir/d2 || error
216 run_test 4b "mkdir .../d4/d2 ==================================="
219 test_mkdir $DIR/$tdir
220 test_mkdir $DIR/$tdir/d2
221 chmod 0707 $DIR/$tdir/d2
222 $CHECKSTAT -t dir -p 0707 $DIR/$tdir/d2 || error
224 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2 ============"
228 chmod 0666 $DIR/$tfile || error
229 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile || error
231 run_test 6a "touch .../f6a; chmod .../f6a ======================"
234 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
235 if [ ! -f $DIR/$tfile ]; then
237 chmod 0666 $DIR/$tfile
239 $RUNAS chmod 0444 $DIR/$tfile && error
240 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile || error
242 run_test 6b "$RUNAS chmod .../f6a (should return error) =="
245 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
247 chown $RUNAS_ID $DIR/$tfile || error
248 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile || error
250 run_test 6c "touch .../f6c; chown .../f6c ======================"
253 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
254 if [ ! -f $DIR/$tfile ]; then
256 chown $RUNAS_ID $DIR/$tfile
258 $RUNAS chown $UID $DIR/$tfile && error
259 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile || error
261 run_test 6d "$RUNAS chown .../f6c (should return error) =="
264 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
266 chgrp $RUNAS_ID $DIR/$tfile || error
267 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile || error
269 run_test 6e "touch .../f6e; chgrp .../f6e ======================"
272 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
273 if [ ! -f $DIR/$tfile ]; then
275 chgrp $RUNAS_ID $DIR/$tfile
277 $RUNAS chgrp $UID $DIR/$tfile && error
278 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile || error
280 run_test 6f "$RUNAS chgrp .../f6e (should return error) =="
283 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
284 test_mkdir $DIR/$tdir || error
285 chmod 777 $DIR/$tdir || error
286 $RUNAS mkdir $DIR/$tdir/d || error
287 chmod g+s $DIR/$tdir/d || error
288 test_mkdir $DIR/$tdir/d/subdir
289 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir/d/subdir || error
291 run_test 6g "Is new dir in sgid dir inheriting group?"
293 test_6h() { # bug 7331
294 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
295 touch $DIR/$tfile || error "touch failed"
296 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
297 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
299 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/$tfile || error
301 run_test 6h "$RUNAS chown RUNAS_ID.0 .../f6h (should return error)"
304 test_mkdir $DIR/$tdir
305 $MCREATE $DIR/$tdir/$tfile
306 chmod 0666 $DIR/$tdir/$tfile
307 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile || error
309 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
312 if [ ! -d $DIR/$tdir ]; then
315 $MCREATE $DIR/$tdir/$tfile
316 echo -n foo > $DIR/$tdir/$tfile
317 [ "`cat $DIR/$tdir/$tfile`" = "foo" ] || error
318 $CHECKSTAT -t file -s 3 $DIR/$tdir/$tfile || error
320 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
323 test_mkdir $DIR/$tdir
324 touch $DIR/$tdir/$tfile
325 chmod 0666 $DIR/$tdir/$tfile
326 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile || error
328 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
331 test_mkdir $DIR/$tdir
332 test_mkdir $DIR/$tdir/d2
333 test_mkdir $DIR/$tdir/d2/d3
334 $CHECKSTAT -t dir $DIR/$tdir/d2/d3 || error
336 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
339 test_mkdir $DIR/$tdir
340 test_mkdir $DIR/$tdir/d2
341 touch $DIR/$tdir/d2/$tfile
342 $CHECKSTAT -t file $DIR/$tdir/d2/$tfile || error
344 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
347 test_mkdir $DIR/$tdir
348 test_mkdir $DIR/$tdir/d2
349 chmod 0666 $DIR/$tdir/d2
350 chmod 0705 $DIR/$tdir/d2
351 $CHECKSTAT -t dir -p 0705 $DIR/$tdir/d2 || error
353 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
356 test_mkdir $DIR/$tdir
357 touch $DIR/$tdir/$tfile
358 chmod 0666 $DIR/$tdir/$tfile
359 chmod 0654 $DIR/$tdir/$tfile
360 $CHECKSTAT -t file -p 0654 $DIR/$tdir/$tfile || error
362 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
365 test_mkdir $DIR/$tdir
366 dd if=/dev/zero of=$DIR/$tdir/$tfile count=10
368 $CHECKSTAT -t file -s 0 $DIR/$tdir/$tfile || error
370 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
373 test_mkdir $DIR/$tdir
374 touch $DIR/$tdir/$tfile
376 $CHECKSTAT -a $DIR/$tdir/$tfile || error
378 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
381 test_mkdir $DIR/$tdir
382 touch $DIR/$tdir/$tfile
383 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}_2
384 $CHECKSTAT -t file $DIR/$tdir/${tfile}_2 || error
386 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
389 test_mkdir $DIR/$tdir
390 touch $DIR/$tdir/$tfile
391 rm -rf $DIR/$tdir/$tfile
392 $CHECKSTAT -a $DIR/$tdir/$tfile || error
394 run_test 16 "touch .../d16/f; rm -rf .../d16/f ================="
397 test_mkdir -p $DIR/$tdir
398 touch $DIR/$tdir/$tfile
399 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
401 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist || error
402 $CHECKSTAT -f -t f $DIR/$tdir/l-exist || error
403 rm -f $DIR/$tdir/l-exist
404 $CHECKSTAT -a $DIR/$tdir/l-exist || error
406 run_test 17a "symlinks: create, remove (real) =================="
409 test_mkdir -p $DIR/$tdir
410 ln -s no-such-file $DIR/$tdir/l-dangle
412 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle || error
413 $CHECKSTAT -fa $DIR/$tdir/l-dangle || error
414 rm -f $DIR/$tdir/l-dangle
415 $CHECKSTAT -a $DIR/$tdir/l-dangle || error
417 run_test 17b "symlinks: create, remove (dangling) =============="
419 test_17c() { # bug 3440 - don't save failed open RPC for replay
420 test_mkdir -p $DIR/$tdir
421 ln -s foo $DIR/$tdir/$tfile
422 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
424 run_test 17c "symlinks: open dangling (should return error) ===="
427 test_mkdir -p $DIR/$tdir
428 ln -s foo $DIR/$tdir/$tfile
429 touch $DIR/$tdir/$tfile || error "creating to new symlink"
431 run_test 17d "symlinks: create dangling ========================"
434 test_mkdir -p $DIR/$tdir
435 local foo=$DIR/$tdir/$tfile
436 ln -s $foo $foo || error "create symlink failed"
437 ls -l $foo || error "ls -l failed"
438 ls $foo && error "ls not failed" || true
440 run_test 17e "symlinks: create recursive symlink (should return error) ===="
443 test_mkdir -p $DIR/d17f
444 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/d17f/111
445 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/d17f/222
446 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/d17f/333
447 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/d17f/444
448 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/d17f/555
449 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
452 run_test 17f "symlinks: long and very long symlink name ========================"
454 # str_repeat(S, N) generate a string that is string S repeated N times
459 while [ $((n -= 1)) -ge 0 ]; do
465 # Long symlinks and LU-2241
467 test_mkdir -p $DIR/$tdir
468 local TESTS="59 60 61 4094 4095"
471 local SYMNAME=$(str_repeat 'x' $i)
472 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
473 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
476 run_test 17g "symlinks: really long symlink name and inode boundaries"
478 test_17h() { #bug 17378
479 remote_mds_nodsh && skip "remote MDS with nodsh" && return
480 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
482 test_mkdir -p $DIR/$tdir
483 if [ $MDSCOUNT -gt 1 ]; then
484 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
488 $SETSTRIPE -c -1 $DIR/$tdir
489 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
490 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
491 touch $DIR/$tdir/$tfile || true
493 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
495 test_17i() { #bug 20018
496 remote_mds_nodsh && skip "remote MDS with nodsh" && return
497 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
498 test_mkdir -p $DIR/$tdir
499 local foo=$DIR/$tdir/$tfile
501 if [ $MDSCOUNT -gt 1 ]; then
502 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
506 ln -s $foo $foo || error "create symlink failed"
507 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
508 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
509 ls -l $foo && error "error not detected"
512 run_test 17i "don't panic on short symlink"
514 test_17k() { #bug 22301
515 rsync --help | grep -q xattr ||
516 skip_env "$(rsync --version| head -1) does not support xattrs"
517 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
518 test_mkdir -p $DIR/$tdir
519 test_mkdir -p $DIR/$tdir.new
520 touch $DIR/$tdir/$tfile
521 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
522 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
523 error "rsync failed with xattrs enabled"
525 run_test 17k "symlinks: rsync with xattrs enabled ========================="
527 test_17l() { # LU-279
529 touch $DIR/$tdir/$tfile
530 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
531 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
532 # -h to not follow symlinks. -m '' to list all the xattrs.
533 # grep to remove first line: '# file: $path'.
534 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
536 lgetxattr_size_check $path $xattr ||
537 error "lgetxattr_size_check $path $xattr failed"
541 run_test 17l "Ensure lgetxattr's returned xattr size is consistent ========"
545 local short_sym="0123456789"
546 local WDIR=$DIR/${tdir}m
553 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
554 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
555 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
557 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
558 skip "only for ldiskfs MDT" && return 0
560 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
564 # create a long symlink file
565 for ((i = 0; i < 4; ++i)); do
566 long_sym=${long_sym}${long_sym}
569 echo "create 512 short and long symlink files under $WDIR"
570 for ((i = 0; i < 256; ++i)); do
571 ln -sf ${long_sym}"a5a5" $WDIR/long-$i
572 ln -sf ${short_sym}"a5a5" $WDIR/short-$i
578 wait_delete_completed
580 echo "recreate the 512 symlink files with a shorter string"
581 for ((i = 0; i < 512; ++i)); do
582 # rewrite the symlink file with a shorter string
583 ln -sf ${long_sym} $WDIR/long-$i
584 ln -sf ${short_sym} $WDIR/short-$i
587 mds_index=$($LFS getstripe -M $WDIR)
588 mds_index=$((mds_index+1))
589 devname=$(mdsdevname $mds_index)
590 cmd="$E2FSCK -fnvd $devname"
592 echo "stop and checking mds${mds_index}: $cmd"
593 # e2fsck should not return error
594 stop mds${mds_index} -f
595 do_facet mds${mds_index} $cmd || rc=$?
597 start mds${mds_index} $devname $MDS_MOUNT_OPTS
598 df $MOUNT > /dev/null 2>&1
599 [ $rc -ne 0 ] && error "e2fsck should not report error upon "\
600 "short/long symlink MDT: rc=$rc"
603 run_test 17m "run e2fsck against MDT which contains short/long symlink"
605 check_fs_consistency_17n() {
611 for mdt_index in $(seq 1 $MDSCOUNT); do
612 devname=$(mdsdevname $mdt_index)
613 cmd="$E2FSCK -fnvd $devname"
615 echo "stop and checking mds${mdt_index}: $cmd"
616 # e2fsck should not return error
618 do_facet mds${mdt_index} $cmd || rc=$?
620 start mds${mdt_index} $devname $MDS_MOUNT_OPTS
621 df $MOUNT > /dev/null 2>&1
622 [ $rc -ne 0 ] && break
630 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
631 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
632 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
634 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
635 skip "only for ldiskfs MDT" && return 0
637 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
639 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
642 for ((i=0; i<10; i++)); do
643 $LFS mkdir -i 1 $DIR/$tdir/remote_dir_${i} ||
644 error "create remote dir error $i"
645 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
646 error "create files under remote dir failed $i"
649 check_fs_consistency_17n || error "e2fsck report error"
651 for ((i=0;i<10;i++)); do
652 rm -rf $DIR/$tdir/remote_dir_${i} ||
653 error "destroy remote dir error $i"
656 check_fs_consistency_17n || error "e2fsck report error"
658 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
664 run_test 18 "touch .../f ; ls ... =============================="
670 $CHECKSTAT -a $DIR/f19 || error
672 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
675 ls -l $DIR/f19 && error || true
677 run_test 19b "ls -l .../f19 (should return error) =============="
680 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
681 $RUNAS touch $DIR/f19 && error || true
683 run_test 19c "$RUNAS touch .../f19 (should return error) =="
686 cat $DIR/f19 && error || true
688 run_test 19d "cat .../f19 (should return error) =============="
700 $CHECKSTAT -a $DIR/f || error
702 run_test 20 "touch .../f ; ls -l ... ==========================="
706 [ -f $DIR/d21/dangle ] && rm -f $DIR/d21/dangle
707 ln -s dangle $DIR/d21/link
708 echo foo >> $DIR/d21/link
710 $CHECKSTAT -t link $DIR/d21/link || error
711 $CHECKSTAT -f -t file $DIR/d21/link || error
713 run_test 21 "write to dangling link ============================"
717 test_mkdir -p $DIR/$tdir
718 chown $RUNAS_ID:$RUNAS_GID $WDIR
719 (cd $WDIR || error "cd $WDIR failed";
720 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
722 ls -lR $WDIR/etc || error "ls -lR $WDIR/etc failed"
723 $CHECKSTAT -t dir $WDIR/etc || error "checkstat -t dir failed"
724 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $WDIR/etc || error "checkstat -u failed"
726 run_test 22 "unpack tar archive as non-root user ==============="
730 test_mkdir -p $DIR/$tdir
731 local file=$DIR/$tdir/$tfile
733 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
734 openfile -f O_CREAT:O_EXCL $file &&
735 error "$file recreate succeeded" || true
737 run_test 23a "O_CREAT|O_EXCL in subdir =========================="
739 test_23b() { # bug 18988
740 test_mkdir -p $DIR/$tdir
741 local file=$DIR/$tdir/$tfile
744 echo foo > $file || error "write filed"
745 echo bar >> $file || error "append filed"
746 $CHECKSTAT -s 8 $file || error "wrong size"
749 run_test 23b "O_APPEND check =========================="
752 echo '== rename sanity =============================================='
753 echo '-- same directory rename'
756 mv $DIR/R1/f $DIR/R1/g
757 $CHECKSTAT -t file $DIR/R1/g || error
759 run_test 24a "touch .../R1/f; rename .../R1/f .../R1/g ========="
764 mv $DIR/R2/f $DIR/R2/g
765 $CHECKSTAT -a $DIR/R2/f || error
766 $CHECKSTAT -t file $DIR/R2/g || error
768 run_test 24b "touch .../R2/{f,g}; rename .../R2/f .../R2/g ====="
773 mv $DIR/R3/f $DIR/R3/g
774 $CHECKSTAT -a $DIR/R3/f || error
775 $CHECKSTAT -t dir $DIR/R3/g || error
777 run_test 24c "mkdir .../R3/f; rename .../R3/f .../R3/g ========="
783 mrename $DIR/R4/f $DIR/R4/g
784 $CHECKSTAT -a $DIR/R4/f || error
785 $CHECKSTAT -t dir $DIR/R4/g || error
787 run_test 24d "mkdir .../R4/{f,g}; rename .../R4/f .../R4/g ====="
790 echo '-- cross directory renames --'
794 mv $DIR/R5a/f $DIR/R5b/g
795 $CHECKSTAT -a $DIR/R5a/f || error
796 $CHECKSTAT -t file $DIR/R5b/g || error
798 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
803 touch $DIR/R6a/f $DIR/R6b/g
804 mv $DIR/R6a/f $DIR/R6b/g
805 $CHECKSTAT -a $DIR/R6a/f || error
806 $CHECKSTAT -t file $DIR/R6b/g || error
808 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
813 test_mkdir $DIR/R7a/d
814 mv $DIR/R7a/d $DIR/R7b/e
815 $CHECKSTAT -a $DIR/R7a/d || error
816 $CHECKSTAT -t dir $DIR/R7b/e || error
818 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
823 test_mkdir $DIR/R8a/d
824 test_mkdir $DIR/R8b/e
825 mrename $DIR/R8a/d $DIR/R8b/e
826 $CHECKSTAT -a $DIR/R8a/d || error
827 $CHECKSTAT -t dir $DIR/R8b/e || error
829 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
832 echo "-- rename error cases"
836 mrename $DIR/R9/f $DIR/R9/a
837 $CHECKSTAT -t file $DIR/R9/f || error
838 $CHECKSTAT -t dir $DIR/R9/a || error
839 $CHECKSTAT -a $DIR/R9/a/f || error
841 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
845 mrename $DIR/R10/f $DIR/R10/g
846 $CHECKSTAT -t dir $DIR/R10 || error
847 $CHECKSTAT -a $DIR/R10/f || error
848 $CHECKSTAT -a $DIR/R10/g || error
850 run_test 24j "source does not exist ============================"
854 test_mkdir $DIR/R11a/d
856 mv $DIR/R11a/f $DIR/R11a/d
857 $CHECKSTAT -a $DIR/R11a/f || error
858 $CHECKSTAT -t file $DIR/R11a/d/f || error
860 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
862 # bug 2429 - rename foo foo foo creates invalid file
865 $MULTIOP $f OcNs || error
867 run_test 24l "Renaming a file to itself ========================"
871 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
872 # on ext3 this does not remove either the source or target files
873 # though the "expected" operation would be to remove the source
874 $CHECKSTAT -t file ${f} || error "${f} missing"
875 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
877 run_test 24m "Renaming a file to a hard link to itself ========="
881 # this stats the old file after it was renamed, so it should fail
885 $CHECKSTAT ${f}.rename
888 run_test 24n "Statting the old file after renaming (Posix rename 2)"
891 check_kernel_version 37 || return 0
892 test_mkdir -p $DIR/d24o
893 rename_many -s random -v -n 10 $DIR/d24o
895 run_test 24o "rename of files during htree split ==============="
900 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
901 mrename $DIR/R12a $DIR/R12b
902 $CHECKSTAT -a $DIR/R12a || error
903 $CHECKSTAT -t dir $DIR/R12b || error
904 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
905 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
907 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
909 cleanup_multiop_pause() {
915 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
918 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
919 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
922 trap cleanup_multiop_pause EXIT
923 mrename $DIR/R13a $DIR/R13b
924 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
925 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
926 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
927 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
928 cleanup_multiop_pause
929 wait $MULTIPID || error "multiop close failed"
931 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
933 test_24r() { #bug 3789
935 test_mkdir $DIR/R14a/b
936 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
937 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
938 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
940 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
944 test_mkdir $DIR/R15a/b
945 test_mkdir $DIR/R15a/b/c
946 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
947 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
948 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
950 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
953 test_mkdir $DIR/R16a/b
954 test_mkdir $DIR/R16a/b/c
955 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
956 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
957 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
959 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
961 test_24u() { # bug12192
963 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error
964 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
966 run_test 24u "create stripe file"
972 simple_cleanup_common() {
975 wait_delete_completed
978 max_pages_per_rpc() {
979 $LCTL get_param -n mdc.*.max_pages_per_rpc | head -1
984 local FREE_INODES=$(lfs_df -i | grep "summary" | awk '{print $4}')
985 [ $FREE_INODES -lt $NRFILES ] && \
986 skip "not enough free inodes $FREE_INODES required $NRFILES" &&
989 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
990 trap simple_cleanup_common EXIT
993 createmany -m $DIR/$tdir/$tfile $NRFILES
996 lctl set_param mdc.*.stats clear
998 ls $DIR/$tdir >/dev/null || error "error in listing large dir"
1000 # LU-5 large readdir
1001 # DIRENT_SIZE = 32 bytes for sizeof(struct lu_dirent) +
1002 # 8 bytes for name(filename is mostly 5 in this test) +
1003 # 8 bytes for luda_type
1004 # take into account of overhead in lu_dirpage header and end mark in
1005 # each page, plus one in RPC_NUM calculation.
1007 RPC_SIZE=$(($(max_pages_per_rpc) * $(page_size)))
1008 RPC_NUM=$(((NRFILES * DIRENT_SIZE + RPC_SIZE - 1) / RPC_SIZE + 1))
1009 mds_readpage=$(lctl get_param mdc.*MDT0000*.stats | \
1010 awk '/^mds_readpage/ {print $2}')
1011 [ $mds_readpage -gt $RPC_NUM ] && \
1012 error "large readdir doesn't take effect"
1014 simple_cleanup_common
1016 run_test 24v "list directory with large files (handle hash collision, bug: 17560)"
1018 test_24w() { # bug21506
1020 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1021 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1022 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1023 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1024 [ "$SZ1" = "$SZ2" ] || \
1025 error "Error reading at the end of the file $tfile"
1027 run_test 24w "Reading a file larger than 4Gb"
1030 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1031 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1033 local remote_dir=$DIR/$tdir/remote_dir
1036 $LFS mkdir -i $MDTIDX $remote_dir ||
1037 error "create remote directory failed"
1039 mkdir -p $DIR/$tdir/src_dir
1040 touch $DIR/$tdir/src_file
1041 mkdir -p $remote_dir/tgt_dir
1042 touch $remote_dir/tgt_file
1044 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir &&
1045 error "rename dir cross MDT works!"
1047 mrename $DIR/$tdir/src_file $remote_dir/tgt_file &&
1048 error "rename file cross MDT works!"
1050 ln $DIR/$tdir/src_file $remote_dir/tgt_file1 &&
1051 error "ln file cross MDT should not work!"
1053 rm -rf $DIR/$tdir || error "Can not delete directories"
1055 run_test 24x "cross rename/link should be failed"
1058 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1059 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1061 local remote_dir=$DIR/$tdir/remote_dir
1064 $LFS mkdir -i $MDTIDX $remote_dir ||
1065 error "create remote directory failed"
1067 mkdir -p $remote_dir/src_dir
1068 touch $remote_dir/src_file
1069 mkdir -p $remote_dir/tgt_dir
1070 touch $remote_dir/tgt_file
1072 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1073 error "rename subdir in the same remote dir failed!"
1075 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1076 error "rename files in the same remote dir failed!"
1078 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1079 error "link files in the same remote dir failed!"
1081 rm -rf $DIR/$tdir || error "Can not delete directories"
1083 run_test 24y "rename/link on the same dir should succeed"
1086 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1087 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1089 local remote_src=$DIR/$tdir/remote_dir
1090 local remote_tgt=$DIR/$tdir/remote_tgt
1093 $LFS mkdir -i $MDTIDX $remote_src ||
1094 error "create remote directory failed"
1096 $LFS mkdir -i $MDTIDX $remote_tgt ||
1097 error "create remote directory failed"
1099 mrename $remote_src $remote_tgt &&
1100 error "rename remote dirs should not work!"
1102 rm -rf $DIR/$tdir || error "Can not delete directories"
1104 run_test 24z "rename one remote dir to another remote dir should fail"
1107 echo '== symlink sanity ============================================='
1111 touch $DIR/s25/foo || error
1113 run_test 25a "create file in symlinked directory ==============="
1116 [ ! -d $DIR/d25 ] && test_25a
1117 $CHECKSTAT -t file $DIR/s25/foo || error
1119 run_test 25b "lookup file in symlinked directory ==============="
1123 test_mkdir $DIR/d26/d26-2
1124 ln -s d26/d26-2 $DIR/s26
1125 touch $DIR/s26/foo || error
1127 run_test 26a "multiple component symlink ======================="
1130 test_mkdir -p $DIR/d26b/d26-2
1131 ln -s d26b/d26-2/foo $DIR/s26-2
1132 touch $DIR/s26-2 || error
1134 run_test 26b "multiple component symlink at end of lookup ======"
1137 test_mkdir $DIR/d26.2
1138 touch $DIR/d26.2/foo
1139 ln -s d26.2 $DIR/s26.2-1
1140 ln -s s26.2-1 $DIR/s26.2-2
1141 ln -s s26.2-2 $DIR/s26.2-3
1142 chmod 0666 $DIR/s26.2-3/foo
1144 run_test 26c "chain of symlinks ================================"
1146 # recursive symlinks (bug 439)
1148 ln -s d26-3/foo $DIR/d26-3
1150 run_test 26d "create multiple component recursive symlink ======"
1153 [ ! -h $DIR/d26-3 ] && test_26d
1156 run_test 26e "unlink multiple component recursive symlink ======"
1158 # recursive symlinks (bug 7022)
1160 test_mkdir -p $DIR/$tdir
1161 test_mkdir $DIR/$tdir/$tfile || error "mkdir $DIR/$tdir/$tfile failed"
1162 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1163 test_mkdir -p lndir bar1 || error "mkdir lndir/bar1 failed"
1164 test_mkdir $DIR/$tdir/$tfile/$tfile || error "mkdir $tfile failed"
1165 cd $tfile || error "cd $tfile failed"
1166 ln -s .. dotdot || error "ln dotdot failed"
1167 ln -s dotdot/lndir lndir || error "ln lndir failed"
1168 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1169 output=`ls $tfile/$tfile/lndir/bar1`
1170 [ "$output" = bar1 ] && error "unexpected output"
1171 rm -r $tfile || error "rm $tfile failed"
1172 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1174 run_test 26f "rm -r of a directory which has recursive symlink ="
1177 echo '== stripe sanity =============================================='
1178 test_mkdir -p $DIR/d27 || error "mkdir failed"
1180 $SETSTRIPE -c 1 $DIR/d27/f0 || error "setstripe failed"
1181 $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
1183 log "== test_27a: write to one stripe file ========================="
1184 cp /etc/hosts $DIR/d27/f0 || error
1186 run_test 27a "one stripe file =================================="
1189 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
1190 test_mkdir -p $DIR/d27
1191 $SETSTRIPE -c 2 $DIR/d27/f01 || error "setstripe failed"
1192 $GETSTRIPE -c $DIR/d27/f01
1193 [ $($GETSTRIPE -c $DIR/d27/f01) -eq 2 ] ||
1194 error "two-stripe file doesn't have two stripes"
1196 run_test 27b "create two stripe file"
1199 [ -f $DIR/d27/f01 ] || skip "test_27b not run" && return
1201 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
1203 run_test 27c "write to two stripe file"
1206 test_mkdir -p $DIR/d27
1207 $SETSTRIPE -c 0 -i -1 -S 0 $DIR/d27/fdef || error "setstripe failed"
1208 $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
1209 dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
1211 run_test 27d "create file with default settings ================"
1214 test_mkdir -p $DIR/d27
1215 $SETSTRIPE -c 2 $DIR/d27/f12 || error "setstripe failed"
1216 $SETSTRIPE -c 2 $DIR/d27/f12 && error "setstripe succeeded twice"
1217 $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
1219 run_test 27e "setstripe existing file (should return error) ======"
1222 test_mkdir -p $DIR/d27
1223 $SETSTRIPE -S 100 -i 0 -c 1 $DIR/d27/fbad && error "setstripe failed"
1224 dd if=/dev/zero of=$DIR/d27/f12 bs=4k count=4 || error "dd failed"
1225 $GETSTRIPE $DIR/d27/fbad || error "$GETSTRIPE failed"
1227 run_test 27f "setstripe with bad stripe size (should return error)"
1230 test_mkdir -p $DIR/d27
1231 $MCREATE $DIR/d27/fnone || error "mcreate failed"
1232 $GETSTRIPE $DIR/d27/fnone 2>&1 | grep "no stripe info" ||
1233 error "$DIR/d27/fnone has object"
1235 run_test 27g "$GETSTRIPE with no objects"
1238 touch $DIR/d27/fsome || error "touch failed"
1239 [ $($GETSTRIPE -c $DIR/d27/fsome) -gt 0 ] || error "missing objects"
1241 run_test 27i "$GETSTRIPE with some objects"
1244 test_mkdir -p $DIR/d27
1245 $SETSTRIPE -i $OSTCOUNT $DIR/d27/f27j && error "setstripe failed"||true
1247 run_test 27j "setstripe with bad stripe offset (should return error)"
1249 test_27k() { # bug 2844
1250 test_mkdir -p $DIR/d27
1252 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
1253 [ ! -d $DIR/d27 ] && test_mkdir -p $DIR d27
1254 $SETSTRIPE -S 67108864 $FILE || error "setstripe failed"
1255 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1256 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
1257 dd if=/dev/zero of=$FILE bs=4k count=1
1258 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1259 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
1261 run_test 27k "limit i_blksize for broken user apps ============="
1264 test_mkdir -p $DIR/d27
1265 mcreate $DIR/f27l || error "creating file"
1266 $RUNAS $SETSTRIPE -c 1 $DIR/f27l && \
1267 error "setstripe should have failed" || true
1269 run_test 27l "check setstripe permissions (should return error)"
1272 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" &&
1274 if [ $ORIGFREE -gt $MAXFREE ]; then
1275 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1278 trap simple_cleanup_common EXIT
1279 test_mkdir -p $DIR/$tdir
1280 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_1
1281 dd if=/dev/zero of=$DIR/$tdir/f27m_1 bs=1024 count=$MAXFREE &&
1282 error "dd should fill OST0"
1284 while $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_$i; do
1286 [ $i -gt 256 ] && break
1289 touch $DIR/$tdir/f27m_$i
1290 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1291 error "OST0 was full but new created file still use it"
1293 touch $DIR/$tdir/f27m_$i
1294 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1295 error "OST0 was full but new created file still use it"
1296 simple_cleanup_common
1298 run_test 27m "create file while OST0 was full =================="
1301 local DELAY=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage | head -n 1 | awk '{print $1 * 2}')
1305 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1306 # if the OST isn't full anymore.
1308 local OSTIDX=${1:-""}
1310 local list=$(comma_list $(osts_nodes))
1311 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1313 do_nodes $list lctl set_param fail_loc=0
1314 sync # initiate all OST_DESTROYs from MDS to OST
1318 exhaust_precreations() {
1321 local FAILIDX=${3:-$OSTIDX}
1323 test_mkdir -p $DIR/$tdir
1324 local MDSIDX=$(get_mds_dir "$DIR/$tdir")
1325 echo OSTIDX=$OSTIDX MDSIDX=$MDSIDX
1327 local OST=$(ostname_from_index $OSTIDX)
1328 local MDT_INDEX=$(lfs df | grep "\[MDT:$((MDSIDX - 1))\]" | awk '{print $1}' | \
1329 sed -e 's/_UUID$//;s/^.*-//')
1332 local mdtosc_proc1=$(get_mdtosc_proc_path mds${MDSIDX} $OST)
1333 local last_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1334 osc.$mdtosc_proc1.prealloc_last_id)
1335 local next_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1336 osc.$mdtosc_proc1.prealloc_next_id)
1338 local mdtosc_proc2=$(get_mdtosc_proc_path mds${MDSIDX})
1339 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1341 test_mkdir -p $DIR/$tdir/${OST}
1342 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1343 #define OBD_FAIL_OST_ENOSPC 0x215
1344 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=$FAILIDX
1345 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x215
1346 echo "Creating to objid $last_id on ost $OST..."
1347 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1348 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1349 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=$FAILLOC
1353 exhaust_all_precreations() {
1355 for (( i=0; i < OSTCOUNT; i++ )) ; do
1356 exhaust_precreations $i $1 -1
1361 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1362 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1363 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1364 remote_ost_nodsh && skip "remote OST with nodsh" && return
1367 rm -f $DIR/$tdir/$tfile
1368 exhaust_precreations 0 0x80000215
1369 $SETSTRIPE -c -1 $DIR/$tdir
1370 touch $DIR/$tdir/$tfile || error
1371 $GETSTRIPE $DIR/$tdir/$tfile
1374 run_test 27n "create file with some full OSTs =================="
1377 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1378 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1379 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1380 remote_ost_nodsh && skip "remote OST with nodsh" && return
1383 rm -f $DIR/$tdir/$tfile
1384 exhaust_all_precreations 0x215
1386 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1391 run_test 27o "create file with all full OSTs (should error) ===="
1394 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1395 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1396 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1397 remote_ost_nodsh && skip "remote OST with nodsh" && return
1400 rm -f $DIR/$tdir/$tfile
1401 test_mkdir -p $DIR/$tdir
1403 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1404 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1405 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1407 exhaust_precreations 0 0x80000215
1408 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1409 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1410 $GETSTRIPE $DIR/$tdir/$tfile
1414 run_test 27p "append to a truncated file with some full OSTs ==="
1417 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1418 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1419 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1420 remote_ost_nodsh && skip "remote OST with nodsh" && return
1423 rm -f $DIR/$tdir/$tfile
1425 test_mkdir -p $DIR/$tdir
1426 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1427 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||error "truncate $DIR/$tdir/$tfile failed"
1428 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1430 exhaust_all_precreations 0x215
1432 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1433 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1437 run_test 27q "append to truncated file with all OSTs full (should error) ==="
1440 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1441 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1442 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1443 remote_ost_nodsh && skip "remote OST with nodsh" && return
1446 rm -f $DIR/$tdir/$tfile
1447 exhaust_precreations 0 0x80000215
1449 $SETSTRIPE -i 0 -c 2 $DIR/$tdir/$tfile # && error
1453 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1455 test_27s() { # bug 10725
1456 test_mkdir -p $DIR/$tdir
1457 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1458 local stripe_count=0
1459 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1460 $SETSTRIPE -S $stripe_size -c $stripe_count $DIR/$tdir &&
1461 error "stripe width >= 2^32 succeeded" || true
1464 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1466 test_27t() { # bug 10864
1471 $WLFS getstripe $tfile
1474 run_test 27t "check that utils parse path correctly"
1476 test_27u() { # bug 4900
1477 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1478 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1480 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1481 do_facet $SINGLEMDS lctl set_param fail_loc=0x139
1482 test_mkdir -p $DIR/$tdir
1483 createmany -o $DIR/$tdir/t- 1000
1484 do_facet $SINGLEMDS lctl set_param fail_loc=0
1486 TLOG=$DIR/$tfile.getstripe
1487 $GETSTRIPE $DIR/$tdir > $TLOG
1488 OBJS=`awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj;}' $TLOG`
1489 unlinkmany $DIR/$tdir/t- 1000
1490 [ $OBJS -gt 0 ] && \
1491 error "$OBJS objects created on OST-0. See $TLOG" || pass
1493 run_test 27u "skip object creation on OSC w/o objects =========="
1495 test_27v() { # bug 4900
1496 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1497 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1498 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1499 remote_ost_nodsh && skip "remote OST with nodsh" && return
1501 exhaust_all_precreations 0x215
1504 test_mkdir -p $DIR/$tdir
1505 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1507 touch $DIR/$tdir/$tfile
1508 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1510 for (( i=1; i < OSTCOUNT; i++ )); do
1511 do_facet ost$i lctl set_param fail_loc=0x705
1513 local START=`date +%s`
1514 createmany -o $DIR/$tdir/$tfile 32
1516 local FINISH=`date +%s`
1517 local TIMEOUT=`lctl get_param -n timeout`
1518 local PROCESS=$((FINISH - START))
1519 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1520 error "$FINISH - $START >= $TIMEOUT / 2"
1521 sleep $((TIMEOUT / 2 - PROCESS))
1524 run_test 27v "skip object creation on slow OST ================="
1526 test_27w() { # bug 10997
1527 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1528 $SETSTRIPE -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1529 [ $($GETSTRIPE -S $DIR/$tdir/f0) -ne 65536 ] &&
1530 error "stripe size $size != 65536" || true
1531 [ $($GETSTRIPE -d $DIR/$tdir | grep -c "stripe_count") -ne 1 ] &&
1532 error "$GETSTRIPE -d $DIR/$tdir failed" || true
1534 run_test 27w "check $SETSTRIPE -S option"
1537 [ "$OSTCOUNT" -lt "2" ] &&
1538 skip_env "skipping multiple stripe count/offset test" && return
1540 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1541 for i in $(seq 1 $OSTCOUNT); do
1543 $SETSTRIPE -c $i -i $offset $DIR/$tdir/f$i ||
1544 error "setstripe -c $i -i $offset failed"
1545 count=$($GETSTRIPE -c $DIR/$tdir/f$i)
1546 index=$($GETSTRIPE -i $DIR/$tdir/f$i)
1547 [ $count -ne $i ] && error "stripe count $count != $i" || true
1548 [ $index -ne $offset ] &&
1549 error "stripe offset $index != $offset" || true
1552 run_test 27wa "check $SETSTRIPE -c -i options"
1555 remote_ost_nodsh && skip "remote OST with nodsh" && return
1556 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs" && return
1557 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1558 OFFSET=$(($OSTCOUNT - 1))
1560 local OST=$(ostname_from_index $OSTIDX)
1562 test_mkdir -p $DIR/$tdir
1563 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe per file
1564 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1566 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1567 for i in `seq 0 $OFFSET`; do
1568 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}' | grep -w "$OSTIDX"` ] &&
1569 error "OST0 was degraded but new created file still use it"
1571 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1573 run_test 27x "create files while OST0 is degraded"
1576 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1577 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1578 remote_ost_nodsh && skip "remote OST with nodsh" && return
1579 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1581 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1582 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1583 osc.$mdtosc.prealloc_last_id)
1584 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1585 osc.$mdtosc.prealloc_next_id)
1586 local fcount=$((last_id - next_id))
1587 [ $fcount -eq 0 ] && skip "not enough space on OST0" && return
1588 [ $fcount -gt $OSTCOUNT ] && fcount=$OSTCOUNT
1590 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
1591 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
1592 local OST_DEACTIVE_IDX=-1
1597 for OSC in $MDS_OSCS; do
1598 OST=$(osc_to_ost $OSC)
1599 OSTIDX=$(index_from_ostuuid $OST)
1600 if [ $OST_DEACTIVE_IDX == -1 ]; then
1601 OST_DEACTIVE_IDX=$OSTIDX
1603 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
1604 echo $OSC "is Deactivated:"
1605 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1609 OSTIDX=$(index_from_ostuuid $OST)
1611 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1613 for OSC in $MDS_OSCS; do
1614 OST=$(osc_to_ost $OSC)
1615 OSTIDX=$(index_from_ostuuid $OST)
1616 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1617 echo $OST "is degraded:"
1618 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1619 obdfilter.$OST.degraded=1
1624 createmany -o $DIR/$tdir/$tfile $fcount
1626 for OSC in $MDS_OSCS; do
1627 OST=$(osc_to_ost $OSC)
1628 OSTIDX=$(index_from_ostuuid $OST)
1629 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1630 echo $OST "is recovered from degraded:"
1631 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1632 obdfilter.$OST.degraded=0
1634 do_facet $SINGLEMDS lctl --device %$OSC activate
1638 run_test 27y "create files while OST0 is degraded and the rest inactive"
1644 lmm_count=$($GETSTRIPE -c $1)
1645 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1646 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1648 local old_ifs="$IFS"
1650 fid=($($LFS path2fid $1))
1653 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1654 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1656 # compare lmm_seq and lu_fid->f_seq
1657 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1658 # compare lmm_object_id and lu_fid->oid
1659 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1661 # check the trusted.fid attribute of the OST objects of the file
1662 local have_obdidx=false
1664 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1665 # skip lines up to and including "obdidx"
1666 [ -z "$obdidx" ] && break
1667 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1668 $have_obdidx || continue
1670 local ost=$((obdidx + 1))
1671 local dev=$(ostdevname $ost)
1673 if [ $(facet_fstype ost$ost) != ldiskfs ]; then
1674 echo "Currently only works with ldiskfs-based OSTs"
1678 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1680 #don't unmount/remount the OSTs if we don't need to do that
1681 #local dir=$(facet_mntpt ost$ost)
1683 #do_facet ost$dev mount -t $FSTYPE $dev $dir $OST_MOUNT_OPTS ||
1684 # { error "mounting $dev as $FSTYPE failed"; return 3; }
1685 #local obj_file=$(do_facet ost$ost find $dir/O/$seq -name $oid)
1686 #local ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID $obj_file)
1687 seq=$(echo $seq | sed -e "s/^0x//g")
1688 if [ $seq == 0 ]; then
1689 oid_hex=$(echo $oid)
1691 oid_hex=$(echo $hex | sed -e "s/^0x//g")
1693 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
1694 local ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
1695 $dev 2>/dev/null" | grep "parent=")
1697 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
1699 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
1701 #do_facet ost$ost umount -d $dir
1702 #start ost$ost $dev $OST_MOUNT_OPTS
1704 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
1705 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
1706 local ff_parent=$(echo $ff|sed -e 's/.*parent=.//')
1707 local ff_pseq=$(echo $ff_parent | cut -d: -f1)
1708 local ff_poid=$(echo $ff_parent | cut -d: -f2)
1709 local ff_pstripe=$(echo $ff_parent | sed -e 's/.*stripe=//')
1711 # compare lmm_seq and filter_fid->ff_parent.f_seq
1712 [ $ff_pseq = $lmm_seq ] ||
1713 error "FF parent SEQ $ff_pseq != $lmm_seq"
1714 # compare lmm_object_id and filter_fid->ff_parent.f_oid
1715 [ $ff_poid = $lmm_oid ] ||
1716 error "FF parent OID $ff_poid != $lmm_oid"
1717 [ $ff_pstripe = $stripe_nr ] ||
1718 error "FF stripe $ff_pstripe != $stripe_nr"
1720 stripe_nr=$((stripe_nr + 1))
1725 remote_ost_nodsh && skip "remote OST with nodsh" && return
1726 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1727 test_mkdir -p $DIR/$tdir
1729 $SETSTRIPE -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
1730 { error "setstripe -c -1 failed"; return 1; }
1731 # We need to send a write to every object to get parent FID info set.
1732 # This _should_ also work for setattr, but does not currently.
1733 # touch $DIR/$tdir/$tfile-1 ||
1734 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
1735 { error "dd $tfile-1 failed"; return 2; }
1736 $SETSTRIPE -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
1737 { error "setstripe -c -1 failed"; return 3; }
1738 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
1739 { error "dd $tfile-2 failed"; return 4; }
1741 # make sure write RPCs have been sent to OSTs
1744 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
1745 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
1747 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
1749 test_27A() { # b=19102
1750 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1751 local restore_size=$($GETSTRIPE -S $MOUNT)
1752 local restore_count=$($GETSTRIPE -c $MOUNT)
1753 local restore_offset=$($GETSTRIPE -i $MOUNT)
1754 $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
1755 local default_size=$($GETSTRIPE -S $MOUNT)
1756 local default_count=$($GETSTRIPE -c $MOUNT)
1757 local default_offset=$($GETSTRIPE -i $MOUNT)
1758 local dsize=$((1024 * 1024))
1759 [ $default_size -eq $dsize ] ||
1760 error "stripe size $default_size != $dsize"
1761 [ $default_count -eq 1 ] || error "stripe count $default_count != 1"
1762 [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
1763 $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
1765 run_test 27A "check filesystem-wide default LOV EA values"
1767 # createtest also checks that device nodes are created and
1768 # then visible correctly (#2091)
1769 test_28() { # bug 2091
1771 $CREATETEST $DIR/d28/ct || error
1773 run_test 28 "create/mknod/mkdir with bad file types ============"
1776 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1777 cancel_lru_locks mdc
1783 declare -i LOCKCOUNTORIG=0
1784 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1785 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
1787 [ $LOCKCOUNTORIG -eq 0 ] && echo "No mdc lock count" && return 1
1789 declare -i LOCKUNUSEDCOUNTORIG=0
1790 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1791 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
1798 declare -i LOCKCOUNTCURRENT=0
1799 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1800 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
1803 declare -i LOCKUNUSEDCOUNTCURRENT=0
1804 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1805 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
1808 if [ "$LOCKCOUNTCURRENT" -gt "$LOCKCOUNTORIG" ]; then
1809 lctl set_param -n ldlm.dump_namespaces ""
1810 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
1811 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1812 log "dumped log to $TMP/test_29.dk (bug 5793)"
1815 if [ "$LOCKUNUSEDCOUNTCURRENT" -gt "$LOCKUNUSEDCOUNTORIG" ]; then
1816 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
1817 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1818 log "dumped log to $TMP/test_29.dk (bug 5793)"
1822 run_test 29 "IT_GETATTR regression ============================"
1824 test_30a() { # was test_30
1825 cp `which ls` $DIR || cp /bin/ls $DIR
1829 run_test 30a "execute binary from Lustre (execve) =============="
1832 cp `which ls` $DIR || cp /bin/ls $DIR
1834 $RUNAS $DIR/ls / || error
1837 run_test 30b "execute binary from Lustre as non-root ==========="
1839 test_30c() { # b=22376
1840 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1841 cp `which ls` $DIR || cp /bin/ls $DIR
1843 cancel_lru_locks mdc
1844 cancel_lru_locks osc
1845 $RUNAS $DIR/ls / || error
1848 run_test 30c "execute binary from Lustre without read perms ===="
1851 $OPENUNLINK $DIR/f31 $DIR/f31 || error
1852 $CHECKSTAT -a $DIR/f31 || error
1854 run_test 31a "open-unlink file =================================="
1857 touch $DIR/f31 || error
1858 ln $DIR/f31 $DIR/f31b || error
1859 $MULTIOP $DIR/f31b Ouc || error
1860 $CHECKSTAT -t file $DIR/f31 || error
1862 run_test 31b "unlink file with multiple links while open ======="
1865 touch $DIR/f31 || error
1866 ln $DIR/f31 $DIR/f31c || error
1867 multiop_bg_pause $DIR/f31 O_uc || return 1
1869 $MULTIOP $DIR/f31c Ouc
1870 kill -USR1 $MULTIPID
1873 run_test 31c "open-unlink file with multiple links ============="
1876 opendirunlink $DIR/d31d $DIR/d31d || error
1877 $CHECKSTAT -a $DIR/d31d || error
1879 run_test 31d "remove of open directory ========================="
1881 test_31e() { # bug 2904
1882 check_kernel_version 34 || return 0
1883 openfilleddirunlink $DIR/d31e || error
1885 run_test 31e "remove of open non-empty directory ==============="
1887 test_31f() { # bug 4554
1888 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1890 test_mkdir $DIR/d31f
1891 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
1892 cp /etc/hosts $DIR/d31f
1894 $GETSTRIPE $DIR/d31f/hosts
1895 multiop_bg_pause $DIR/d31f D_c || return 1
1898 rm -rv $DIR/d31f || error "first of $DIR/d31f"
1899 test_mkdir $DIR/d31f
1900 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
1901 cp /etc/hosts $DIR/d31f
1903 $GETSTRIPE $DIR/d31f/hosts
1904 multiop_bg_pause $DIR/d31f D_c || return 1
1907 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
1908 wait $MULTIPID || error "first opendir $MULTIPID failed"
1912 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
1913 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
1916 run_test 31f "remove of open directory with open-unlink file ==="
1919 echo "-- cross directory link --"
1920 test_mkdir $DIR/d31ga
1921 test_mkdir $DIR/d31gb
1923 ln $DIR/d31ga/f $DIR/d31gb/g
1924 $CHECKSTAT -t file $DIR/d31ga/f || error "source"
1925 [ `stat -c%h $DIR/d31ga/f` == '2' ] || error "source nlink"
1926 $CHECKSTAT -t file $DIR/d31gb/g || error "target"
1927 [ `stat -c%h $DIR/d31gb/g` == '2' ] || error "target nlink"
1929 run_test 31g "cross directory link==============="
1932 echo "-- cross directory link --"
1933 test_mkdir $DIR/d31h
1934 test_mkdir $DIR/d31h/dir
1936 ln $DIR/d31h/f $DIR/d31h/dir/g
1937 $CHECKSTAT -t file $DIR/d31h/f || error "source"
1938 [ `stat -c%h $DIR/d31h/f` == '2' ] || error "source nlink"
1939 $CHECKSTAT -t file $DIR/d31h/dir/g || error "target"
1940 [ `stat -c%h $DIR/d31h/dir/g` == '2' ] || error "target nlink"
1942 run_test 31h "cross directory link under child==============="
1945 echo "-- cross directory link --"
1946 test_mkdir $DIR/d31i
1947 test_mkdir $DIR/d31i/dir
1948 touch $DIR/d31i/dir/f
1949 ln $DIR/d31i/dir/f $DIR/d31i/g
1950 $CHECKSTAT -t file $DIR/d31i/dir/f || error "source"
1951 [ `stat -c%h $DIR/d31i/dir/f` == '2' ] || error "source nlink"
1952 $CHECKSTAT -t file $DIR/d31i/g || error "target"
1953 [ `stat -c%h $DIR/d31i/g` == '2' ] || error "target nlink"
1955 run_test 31i "cross directory link under parent==============="
1959 test_mkdir $DIR/d31j
1960 test_mkdir $DIR/d31j/dir1
1961 ln $DIR/d31j/dir1 $DIR/d31j/dir2 && error "ln for dir"
1962 link $DIR/d31j/dir1 $DIR/d31j/dir3 && error "link for dir"
1963 mlink $DIR/d31j/dir1 $DIR/d31j/dir4 && error "mlink for dir"
1964 mlink $DIR/d31j/dir1 $DIR/d31j/dir1 && error "mlink to the same dir"
1967 run_test 31j "link for directory==============="
1971 test_mkdir $DIR/d31k
1973 touch $DIR/d31k/exist
1974 mlink $DIR/d31k/s $DIR/d31k/t || error "mlink"
1975 mlink $DIR/d31k/s $DIR/d31k/exist && error "mlink to exist file"
1976 mlink $DIR/d31k/s $DIR/d31k/s && error "mlink to the same file"
1977 mlink $DIR/d31k/s $DIR/d31k && error "mlink to parent dir"
1978 mlink $DIR/d31k $DIR/d31k/s && error "mlink parent dir to target"
1979 mlink $DIR/d31k/not-exist $DIR/d31k/foo && error "mlink non-existing to new"
1980 mlink $DIR/d31k/not-exist $DIR/d31k/s && error "mlink non-existing to exist"
1983 run_test 31k "link to file: the same, non-existing, dir==============="
1986 test_mkdir $DIR/d31m
1988 test_mkdir $DIR/d31m2
1989 touch $DIR/d31m2/exist
1990 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
1991 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
1992 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
1993 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
1994 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
1995 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
1998 run_test 31m "link to file: the same, non-existing, dir==============="
2000 cleanup_test32_mount() {
2002 $UMOUNT $DIR/$tdir/ext2-mountpoint
2006 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2007 echo "== more mountpoints and symlinks ================="
2008 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2009 trap cleanup_test32_mount EXIT
2010 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2011 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2012 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. || error
2013 cleanup_test32_mount
2015 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
2018 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2019 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2020 trap cleanup_test32_mount EXIT
2021 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2022 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2023 ls -al $DIR/$tdir/ext2-mountpoint/.. || error
2024 cleanup_test32_mount
2026 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
2029 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2030 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2031 trap cleanup_test32_mount EXIT
2032 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2033 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2034 test_mkdir -p $DIR/$tdir/d2/test_dir
2035 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2036 cleanup_test32_mount
2038 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2041 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2042 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2043 trap cleanup_test32_mount EXIT
2044 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2045 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2046 test_mkdir -p $DIR/$tdir/d2/test_dir
2047 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2048 cleanup_test32_mount
2050 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
2053 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
2054 test_mkdir -p $DIR/d32e/tmp
2055 TMP_DIR=$DIR/d32e/tmp
2056 ln -s $DIR/d32e $TMP_DIR/symlink11
2057 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2058 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
2059 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
2061 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
2064 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
2065 test_mkdir -p $DIR/d32f/tmp
2066 TMP_DIR=$DIR/d32f/tmp
2067 ln -s $DIR/d32f $TMP_DIR/symlink11
2068 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2069 ls $DIR/d32f/tmp/symlink11 || error
2070 ls $DIR/d32f/symlink01 || error
2072 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
2075 TMP_DIR=$DIR/$tdir/tmp
2076 test_mkdir -p $DIR/$tdir/tmp
2077 test_mkdir $DIR/${tdir}2
2078 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2079 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2080 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
2081 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
2082 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
2083 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
2085 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2088 rm -fr $DIR/$tdir $DIR/${tdir}2
2089 TMP_DIR=$DIR/$tdir/tmp
2090 test_mkdir -p $DIR/$tdir/tmp
2091 test_mkdir $DIR/${tdir}2
2092 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2093 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2094 ls $TMP_DIR/symlink12 || error
2095 ls $DIR/$tdir/symlink02 || error
2097 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2100 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2101 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2102 trap cleanup_test32_mount EXIT
2103 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2104 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2105 touch $DIR/$tdir/test_file
2106 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file || error
2107 cleanup_test32_mount
2109 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
2112 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2113 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2114 trap cleanup_test32_mount EXIT
2115 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2116 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2117 touch $DIR/$tdir/test_file
2118 cat $DIR/$tdir/ext2-mountpoint/../test_file || error
2119 cleanup_test32_mount
2121 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
2124 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2126 trap cleanup_test32_mount EXIT
2127 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2128 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2129 test_mkdir -p $DIR/$tdir/d2
2130 touch $DIR/$tdir/d2/test_file || error
2131 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2132 cleanup_test32_mount
2134 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
2137 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2139 trap cleanup_test32_mount EXIT
2140 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2141 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2142 test_mkdir -p $DIR/$tdir/d2
2143 touch $DIR/$tdir/d2/test_file
2144 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2145 cleanup_test32_mount
2147 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
2151 test_mkdir -p $DIR/d32m/tmp
2152 TMP_DIR=$DIR/d32m/tmp
2153 ln -s $DIR $TMP_DIR/symlink11
2154 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2155 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
2156 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
2158 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
2162 test_mkdir -p $DIR/d32n/tmp
2163 TMP_DIR=$DIR/d32n/tmp
2164 ln -s $DIR $TMP_DIR/symlink11
2165 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2166 ls -l $DIR/d32n/tmp/symlink11 || error
2167 ls -l $DIR/d32n/symlink01 || error
2169 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
2172 rm -fr $DIR/d32o $DIR/$tfile
2174 test_mkdir -p $DIR/d32o/tmp
2175 TMP_DIR=$DIR/d32o/tmp
2176 ln -s $DIR/$tfile $TMP_DIR/symlink12
2177 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2178 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
2179 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
2180 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
2181 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
2183 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
2193 test_mkdir -p $DIR/d32p/tmp
2195 TMP_DIR=$DIR/d32p/tmp
2197 ln -s $DIR/$tfile $TMP_DIR/symlink12
2199 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2201 cat $DIR/d32p/tmp/symlink12 || error
2203 cat $DIR/d32p/symlink02 || error
2206 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
2208 cleanup_testdir_mount() {
2214 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2215 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2216 trap cleanup_testdir_mount EXIT
2217 test_mkdir -p $DIR/$tdir
2218 touch $DIR/$tdir/under_the_mount
2219 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2220 ls $DIR/$tdir | grep "\<under_the_mount\>" && error
2221 cleanup_testdir_mount
2223 run_test 32q "stat follows mountpoints in Lustre (should return error)"
2226 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2227 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2228 trap cleanup_testdir_mount EXIT
2229 test_mkdir -p $DIR/$tdir
2230 touch $DIR/$tdir/under_the_mount
2231 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2232 ls $DIR/$tdir | grep -q under_the_mount && error || true
2233 cleanup_testdir_mount
2235 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
2240 chmod 444 $DIR/$tfile
2241 chown $RUNAS_ID $DIR/$tfile
2243 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2246 run_test 33aa "write file with mode 444 (should return error) ===="
2250 test_mkdir -p $DIR/d33
2251 chown $RUNAS_ID $DIR/d33
2252 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
2253 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
2254 error "open RDWR" || true
2256 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
2260 test_mkdir -p $DIR/d33
2261 chown $RUNAS_ID $DIR/d33
2262 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33 && error "create" || true
2264 run_test 33b "test open file with malformed flags (No panic and return error)"
2267 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2273 remote_ost_nodsh && skip "remote OST with nodsh" && return
2276 test_mkdir -p $DIR/d33
2277 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2280 for ostnum in $(seq $OSTCOUNT); do
2281 # test-framework's OST numbering is one-based, while Lustre's
2283 ostname=$(printf "$FSNAME-OST%.4d" $((ostnum - 1)))
2284 # Parsing llobdstat's output sucks; we could grep the /proc
2285 # path, but that's likely to not be as portable as using the
2286 # llobdstat utility. So we parse lctl output instead.
2287 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2288 obdfilter/$ostname/stats |
2289 awk '/^write_bytes/ {print $7}' )
2290 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2291 if (( ${write_bytes:-0} > 0 ))
2298 $all_zeros || return 0
2301 echo foo > $DIR/d33/bar
2305 # Total up write_bytes after writing. We'd better find non-zeros.
2306 for ostnum in $(seq $OSTCOUNT); do
2307 ostname=$(printf "$FSNAME-OST%.4d" $((ostnum - 1)))
2308 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2309 obdfilter/$ostname/stats |
2310 awk '/^write_bytes/ {print $7}' )
2311 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2312 if (( ${write_bytes:-0} > 0 ))
2321 for ostnum in $(seq $OSTCOUNT); do
2322 ostname=$(printf "$FSNAME-OST%.4d" $((ostnum - 1)))
2323 echo "Check that write_bytes is present in obdfilter/*/stats:"
2324 do_facet ost$ostnum lctl get_param -n \
2325 obdfilter/$ostname/stats
2327 error "OST not keeping write_bytes stats (b22312)"
2330 run_test 33c "test llobdstat and write_bytes"
2333 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2334 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2336 local remote_dir=$DIR/$tdir/remote_dir
2339 $LFS mkdir -i $MDTIDX $remote_dir ||
2340 error "create remote directory failed"
2342 touch $remote_dir/$tfile
2343 chmod 444 $remote_dir/$tfile
2344 chown $RUNAS_ID $remote_dir/$tfile
2346 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2348 chown $RUNAS_ID $remote_dir
2349 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
2350 error "create" || true
2351 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
2352 error "open RDWR" || true
2353 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 &&
2354 error "create" || true
2356 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
2358 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
2361 $MCREATE $DIR/f34 || error
2362 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2363 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
2364 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2365 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2367 run_test 34a "truncate file that has not been opened ==========="
2370 [ ! -f $DIR/f34 ] && test_34a
2371 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2372 $OPENFILE -f O_RDONLY $DIR/f34
2373 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2374 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2376 run_test 34b "O_RDONLY opening file doesn't create objects ====="
2379 [ ! -f $DIR/f34 ] && test_34a
2380 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2381 $OPENFILE -f O_RDWR $DIR/f34
2382 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2383 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2385 run_test 34c "O_RDWR opening file-with-size works =============="
2388 [ ! -f $DIR/f34 ] && test_34a
2389 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2390 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2393 run_test 34d "write to sparse file ============================="
2397 $MCREATE $DIR/f34e || error
2398 $TRUNCATE $DIR/f34e 1000 || error
2399 $CHECKSTAT -s 1000 $DIR/f34e || error
2400 $OPENFILE -f O_RDWR $DIR/f34e
2401 $CHECKSTAT -s 1000 $DIR/f34e || error
2403 run_test 34e "create objects, some with size and some without =="
2405 test_34f() { # bug 6242, 6243
2406 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2409 $MCREATE $DIR/f34f || error
2410 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
2411 dd if=$DIR/f34f of=$TMP/f34f
2412 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
2413 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
2414 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
2415 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
2416 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
2418 run_test 34f "read from a file with no objects until EOF ======="
2421 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2422 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
2423 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
2424 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
2425 cancel_lru_locks osc
2426 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
2427 error "wrong size after lock cancel"
2429 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
2430 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2431 error "expanding truncate failed"
2432 cancel_lru_locks osc
2433 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2434 error "wrong expanded size after lock cancel"
2436 run_test 34g "truncate long file ==============================="
2439 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2443 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
2444 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
2448 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
2449 error "Multiop blocked on ftruncate, pid=$MULTIPID"
2453 local nsz=`stat -c %s $DIR/$tfile`
2454 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
2456 run_test 34h "ftruncate file under grouplock should not block"
2459 cp /bin/sh $DIR/f35a
2461 chown $RUNAS_ID $DIR/f35a
2462 $RUNAS $DIR/f35a && error || true
2465 run_test 35a "exec file with mode 444 (should return and not leak) ====="
2469 utime $DIR/f36 || error
2471 run_test 36a "MDS utime check (mknod, utime) ==================="
2475 utime $DIR/f36 || error
2477 run_test 36b "OST utime check (open, utime) ===================="
2482 chown $RUNAS_ID $DIR/d36
2483 $RUNAS utime $DIR/d36/f36 || error
2485 run_test 36c "non-root MDS utime check (mknod, utime) =========="
2488 [ ! -d $DIR/d36 ] && test_36c
2489 echo "" > $DIR/d36/f36
2490 $RUNAS utime $DIR/d36/f36 || error
2492 run_test 36d "non-root OST utime check (open, utime) ==========="
2495 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
2496 test_mkdir -p $DIR/$tdir
2497 touch $DIR/$tdir/$tfile
2498 $RUNAS utime $DIR/$tdir/$tfile && \
2499 error "utime worked, expected failure" || true
2501 run_test 36e "utime on non-owned file (should return error) ===="
2505 local LANG_SAVE=$LANG
2506 local LC_LANG_SAVE=$LC_LANG
2507 export LANG=C LC_LANG=C # for date language
2509 DATESTR="Dec 20 2000"
2510 test_mkdir -p $DIR/$tdir
2511 lctl set_param fail_loc=$fl
2513 cp /etc/hosts $DIR/$tdir/$tfile
2514 sync & # write RPC generated with "current" inode timestamp, but delayed
2516 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
2517 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
2518 cancel_lru_locks osc
2519 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
2521 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
2522 echo "BEFORE: $LS_BEFORE" && \
2523 echo "AFTER : $LS_AFTER" && \
2524 echo "WANT : $DATESTR" && \
2525 error "$DIR/$tdir/$tfile timestamps changed" || true
2527 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
2531 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2532 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2533 subr_36fh "0x80000214"
2535 run_test 36f "utime on file racing with OST BRW write =========="
2538 remote_ost_nodsh && skip "remote OST with nodsh" && return
2539 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2544 test_mkdir -p $DIR/$tdir
2545 fmd_max_age=$(do_facet ost1 \
2546 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
2549 fmd_before=$(do_facet ost1 \
2550 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2551 touch $DIR/$tdir/$tfile
2552 sleep $((fmd_max_age + 12))
2553 fmd_after=$(do_facet ost1 \
2554 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2556 echo "fmd_before: $fmd_before"
2557 echo "fmd_after: $fmd_after"
2558 [ "$fmd_after" -gt "$fmd_before" ] && \
2559 echo "AFTER: $fmd_after > BEFORE: $fmd_before" && \
2560 error "fmd didn't expire after ping" || true
2562 run_test 36g "filter mod data cache expiry ====================="
2565 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2566 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
2567 subr_36fh "0x80000227"
2569 run_test 36h "utime on file racing with OST BRW write =========="
2571 # test_37 - duplicate with tests 32q 32r
2574 local file=$DIR/$tfile
2576 openfile -f O_DIRECTORY $file
2579 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
2580 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
2582 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
2586 touch $DIR/${tfile}2
2587 # ls -l $DIR/$tfile $DIR/${tfile}2
2588 # ls -lu $DIR/$tfile $DIR/${tfile}2
2589 # ls -lc $DIR/$tfile $DIR/${tfile}2
2591 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
2592 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
2594 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
2596 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
2598 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
2599 error "O_TRUNC didn't change timestamps"
2602 run_test 39 "mtime changed on create ==========================="
2605 test_mkdir -p $DIR/$tdir
2606 cp -p /etc/passwd $DIR/$tdir/fopen
2607 cp -p /etc/passwd $DIR/$tdir/flink
2608 cp -p /etc/passwd $DIR/$tdir/funlink
2609 cp -p /etc/passwd $DIR/$tdir/frename
2610 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
2613 echo "aaaaaa" >> $DIR/$tdir/fopen
2614 echo "aaaaaa" >> $DIR/$tdir/flink
2615 echo "aaaaaa" >> $DIR/$tdir/funlink
2616 echo "aaaaaa" >> $DIR/$tdir/frename
2618 local open_new=`stat -c %Y $DIR/$tdir/fopen`
2619 local link_new=`stat -c %Y $DIR/$tdir/flink`
2620 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
2621 local rename_new=`stat -c %Y $DIR/$tdir/frename`
2623 cat $DIR/$tdir/fopen > /dev/null
2624 ln $DIR/$tdir/flink $DIR/$tdir/flink2
2625 rm -f $DIR/$tdir/funlink2
2626 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
2628 for (( i=0; i < 2; i++ )) ; do
2629 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
2630 local link_new2=`stat -c %Y $DIR/$tdir/flink`
2631 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
2632 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
2634 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
2635 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
2636 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
2637 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
2639 cancel_lru_locks osc
2640 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2643 run_test 39b "mtime change on open, link, unlink, rename ======"
2645 # this should be set to past
2646 TEST_39_MTIME=`date -d "1 year ago" +%s`
2652 local mtime0=`stat -c %Y $DIR1/$tfile`
2654 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2655 local mtime1=`stat -c %Y $DIR1/$tfile`
2656 [ "$mtime1" = $TEST_39_MTIME ] || \
2657 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
2660 echo hello >> $DIR1/$tfile
2662 local mtime2=`stat -c %Y $DIR1/$tfile`
2663 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
2664 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
2666 mv $DIR1/$tfile $DIR1/$tfile-1
2668 for (( i=0; i < 2; i++ )) ; do
2669 local mtime3=`stat -c %Y $DIR1/$tfile-1`
2670 [ "$mtime2" = "$mtime3" ] || \
2671 error "mtime ($mtime2) changed (to $mtime3) on rename"
2673 cancel_lru_locks osc
2674 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2677 run_test 39c "mtime change on rename ==========================="
2681 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2684 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2686 for (( i=0; i < 2; i++ )) ; do
2687 local mtime=`stat -c %Y $DIR1/$tfile`
2688 [ $mtime = $TEST_39_MTIME ] || \
2689 error "mtime($mtime) is not set to $TEST_39_MTIME"
2691 cancel_lru_locks osc
2692 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2695 run_test 39d "create, utime, stat =============================="
2699 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2701 local mtime1=`stat -c %Y $DIR1/$tfile`
2703 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2705 for (( i=0; i < 2; i++ )) ; do
2706 local mtime2=`stat -c %Y $DIR1/$tfile`
2707 [ $mtime2 = $TEST_39_MTIME ] || \
2708 error "mtime($mtime2) is not set to $TEST_39_MTIME"
2710 cancel_lru_locks osc
2711 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2714 run_test 39e "create, stat, utime, stat ========================"
2718 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2720 mtime1=`stat -c %Y $DIR1/$tfile`
2723 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2725 for (( i=0; i < 2; i++ )) ; do
2726 local mtime2=`stat -c %Y $DIR1/$tfile`
2727 [ $mtime2 = $TEST_39_MTIME ] || \
2728 error "mtime($mtime2) is not set to $TEST_39_MTIME"
2730 cancel_lru_locks osc
2731 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2734 run_test 39f "create, stat, sleep, utime, stat ================="
2738 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2739 echo hello >> $DIR1/$tfile
2740 local mtime1=`stat -c %Y $DIR1/$tfile`
2743 chmod o+r $DIR1/$tfile
2745 for (( i=0; i < 2; i++ )) ; do
2746 local mtime2=`stat -c %Y $DIR1/$tfile`
2747 [ "$mtime1" = "$mtime2" ] || \
2748 error "lost mtime: $mtime2, should be $mtime1"
2750 cancel_lru_locks osc
2751 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2754 run_test 39g "write, chmod, stat ==============================="
2758 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2763 echo hello >> $DIR1/$tfile
2764 local mtime1=`stat -c %Y $DIR1/$tfile`
2766 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2768 if [ "$d1" != "$d2" ]; then
2769 echo "write and touch not within one second"
2771 for (( i=0; i < 2; i++ )) ; do
2772 local mtime2=`stat -c %Y $DIR1/$tfile`
2773 [ "$mtime2" = $TEST_39_MTIME ] || \
2774 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
2776 cancel_lru_locks osc
2777 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2781 run_test 39h "write, utime within one second, stat ============="
2784 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2788 echo hello >> $DIR1/$tfile
2789 local mtime1=`stat -c %Y $DIR1/$tfile`
2791 mv $DIR1/$tfile $DIR1/$tfile-1
2793 for (( i=0; i < 2; i++ )) ; do
2794 local mtime2=`stat -c %Y $DIR1/$tfile-1`
2796 [ "$mtime1" = "$mtime2" ] || \
2797 error "lost mtime: $mtime2, should be $mtime1"
2799 cancel_lru_locks osc
2800 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2803 run_test 39i "write, rename, stat =============================="
2806 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2807 start_full_debug_logging
2811 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
2812 lctl set_param fail_loc=0x80000412
2813 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
2814 error "multiop failed"
2816 local mtime1=`stat -c %Y $DIR1/$tfile`
2818 mv $DIR1/$tfile $DIR1/$tfile-1
2820 kill -USR1 $multipid
2821 wait $multipid || error "multiop close failed"
2823 for (( i=0; i < 2; i++ )) ; do
2824 local mtime2=`stat -c %Y $DIR1/$tfile-1`
2825 [ "$mtime1" = "$mtime2" ] ||
2826 error "mtime is lost on close: $mtime2, " \
2829 cancel_lru_locks osc
2830 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2832 lctl set_param fail_loc=0
2833 stop_full_debug_logging
2835 run_test 39j "write, rename, close, stat ======================="
2838 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2842 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
2844 local mtime1=`stat -c %Y $DIR1/$tfile`
2846 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2848 kill -USR1 $multipid
2849 wait $multipid || error "multiop close failed"
2851 for (( i=0; i < 2; i++ )) ; do
2852 local mtime2=`stat -c %Y $DIR1/$tfile`
2854 [ "$mtime2" = $TEST_39_MTIME ] || \
2855 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
2857 cancel_lru_locks osc
2858 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2861 run_test 39k "write, utime, close, stat ========================"
2863 # this should be set to future
2864 TEST_39_ATIME=`date -d "1 year" +%s`
2867 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2868 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2869 local atime_diff=$(do_facet $SINGLEMDS \
2870 lctl get_param -n mdd.*MDT0000*.atime_diff)
2874 # test setting directory atime to future
2875 touch -a -d @$TEST_39_ATIME $DIR/$tdir
2876 local atime=$(stat -c %X $DIR/$tdir)
2877 [ "$atime" = $TEST_39_ATIME ] || \
2878 error "atime is not set to future: $atime, $TEST_39_ATIME"
2880 # test setting directory atime from future to now
2881 local d1=$(date +%s)
2883 local d2=$(date +%s)
2885 cancel_lru_locks mdc
2886 atime=$(stat -c %X $DIR/$tdir)
2887 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
2888 error "atime is not updated from future: $atime, $d1<atime<$d2"
2890 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
2893 # test setting directory atime when now > dir atime + atime_diff
2897 cancel_lru_locks mdc
2898 atime=$(stat -c %X $DIR/$tdir)
2899 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
2900 error "atime is not updated : $atime, should be $d2"
2902 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
2905 # test not setting directory atime when now < dir atime + atime_diff
2907 cancel_lru_locks mdc
2908 atime=$(stat -c %X $DIR/$tdir)
2909 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
2910 error "atime is updated to $atime, should remain $d1<atime<$d2"
2912 do_facet $SINGLEMDS \
2913 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
2915 run_test 39l "directory atime update ==========================="
2918 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2921 local far_past_mtime=$(date -d "May 29 1953" +%s)
2922 local far_past_atime=$(date -d "Dec 17 1903" +%s)
2924 touch -m -d @$far_past_mtime $DIR1/$tfile
2925 touch -a -d @$far_past_atime $DIR1/$tfile
2927 for (( i=0; i < 2; i++ )) ; do
2928 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
2929 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
2930 error "atime or mtime set incorrectly"
2932 cancel_lru_locks osc
2933 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2936 run_test 39m "test atime and mtime before 1970"
2939 dd if=/dev/zero of=$DIR/f40 bs=4096 count=1
2940 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/f40 && error
2941 $CHECKSTAT -t file -s 4096 $DIR/f40 || error
2943 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
2947 small_write $DIR/f41 18
2949 run_test 41 "test small file write + fstat ====================="
2951 count_ost_writes() {
2952 lctl get_param -n osc.*.stats |
2953 awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }'
2960 BG_DIRTY_RATIO_SAVE=10
2961 MAX_BG_DIRTY_RATIO=25
2965 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
2966 # dirty_ratio, dirty_background_ratio
2967 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
2968 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
2969 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
2970 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
2972 # if file not here, we are a 2.4 kernel
2973 kill -CONT `pidof kupdated`
2978 # setup the trap first, so someone cannot exit the test at the
2979 # exact wrong time and mess up a machine
2980 trap start_writeback EXIT
2981 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
2982 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
2983 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
2984 sysctl -w vm.dirty_writeback_centisecs=0
2985 sysctl -w vm.dirty_writeback_centisecs=0
2986 # save and increase /proc/sys/vm/dirty_ratio
2987 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
2988 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
2989 # save and increase /proc/sys/vm/dirty_background_ratio
2990 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
2991 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
2993 # if file not here, we are a 2.4 kernel
2994 kill -STOP `pidof kupdated`
2998 # ensure that all stripes have some grant before we test client-side cache
3000 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
3001 dd if=/dev/zero of=$i bs=4k count=1
3006 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
3007 # file truncation, and file removal.
3009 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3011 cancel_lru_locks osc
3013 sync; sleep 1; sync # just to be safe
3014 BEFOREWRITES=`count_ost_writes`
3015 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
3016 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
3017 AFTERWRITES=`count_ost_writes`
3018 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3019 error "$BEFOREWRITES < $AFTERWRITES"
3022 run_test 42a "ensure that we don't flush on close =============="
3025 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3027 cancel_lru_locks osc
3030 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
3031 BEFOREWRITES=`count_ost_writes`
3032 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
3033 AFTERWRITES=`count_ost_writes`
3034 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
3035 error "$BEFOREWRITES < $AFTERWRITES on unlink"
3037 BEFOREWRITES=`count_ost_writes`
3038 sync || error "sync: $?"
3039 AFTERWRITES=`count_ost_writes`
3040 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
3041 error "$BEFOREWRITES < $AFTERWRITES on sync"
3043 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
3047 run_test 42b "test destroy of file with cached dirty data ======"
3049 # if these tests just want to test the effect of truncation,
3050 # they have to be very careful. consider:
3051 # - the first open gets a {0,EOF}PR lock
3052 # - the first write conflicts and gets a {0, count-1}PW
3053 # - the rest of the writes are under {count,EOF}PW
3054 # - the open for truncate tries to match a {0,EOF}PR
3055 # for the filesize and cancels the PWs.
3056 # any number of fixes (don't get {0,EOF} on open, match
3057 # composite locks, do smarter file size management) fix
3058 # this, but for now we want these tests to verify that
3059 # the cancellation with truncate intent works, so we
3060 # start the file with a full-file pw lock to match against
3061 # until the truncate.
3066 cancel_lru_locks osc
3068 # prime the file with 0,EOF PW to match
3072 # now the real test..
3073 dd if=/dev/zero of=$file bs=1024 count=100
3074 BEFOREWRITES=`count_ost_writes`
3075 $TRUNCATE $file $offset
3076 cancel_lru_locks osc
3077 AFTERWRITES=`count_ost_writes`
3082 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3084 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
3085 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
3088 run_test 42c "test partial truncate of file with cached dirty data"
3091 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3093 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3094 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
3097 run_test 42d "test complete truncate of file with cached dirty data"
3099 test_42e() { # bug22074
3100 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3101 local TDIR=$DIR/${tdir}e
3102 local pagesz=$(page_size)
3103 local pages=16 # hardcoded 16 pages, don't change it.
3104 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
3105 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
3109 test_mkdir -p $DIR/${tdir}e
3110 $SETSTRIPE -c 1 $TDIR
3111 createmany -o $TDIR/f $files
3113 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
3115 # we assume that with $OSTCOUNT files, at least one of them will
3116 # be allocated on OST0.
3117 warmup_files=$((OSTCOUNT * max_dirty_mb))
3118 createmany -o $TDIR/w $warmup_files
3120 # write a large amount of data into one file and sync, to get good
3121 # avail_grant number from OST.
3122 for ((i=0; i<$warmup_files; i++)); do
3123 idx=$($GETSTRIPE -i $TDIR/w$i)
3124 [ $idx -ne 0 ] && continue
3125 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
3128 [ $i -gt $warmup_files ] && error "OST0 is still cold"
3130 $LCTL get_param $proc_osc0/cur_dirty_bytes
3131 $LCTL get_param $proc_osc0/cur_grant_bytes
3133 # create as much dirty pages as we can while not to trigger the actual
3134 # RPCs directly. but depends on the env, VFS may trigger flush during this
3135 # period, hopefully we are good.
3136 for ((i=0; i<$warmup_files; i++)); do
3137 idx=$($GETSTRIPE -i $TDIR/w$i)
3138 [ $idx -ne 0 ] && continue
3139 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
3141 $LCTL get_param $proc_osc0/cur_dirty_bytes
3142 $LCTL get_param $proc_osc0/cur_grant_bytes
3144 # perform the real test
3145 $LCTL set_param $proc_osc0/rpc_stats 0
3146 for ((;i<$files; i++)); do
3147 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
3148 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
3151 $LCTL get_param $proc_osc0/rpc_stats
3154 local have_ppr=false
3155 $LCTL get_param $proc_osc0/rpc_stats |
3156 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
3157 # skip lines until we are at the RPC histogram data
3158 [ "$PPR" == "pages" ] && have_ppr=true && continue
3159 $have_ppr || continue
3161 # we only want the percent stat for < 16 pages
3162 [ $(echo $PPR | tr -d ':') -ge $pages ] && break
3164 percent=$((percent + WPCT))
3165 if [ $percent -gt 15 ]; then
3166 error "less than 16-pages write RPCs" \
3173 run_test 42e "verify sub-RPC writes are not done synchronously"
3176 test_mkdir -p $DIR/$tdir
3177 cp -p /bin/ls $DIR/$tdir/$tfile
3178 $MULTIOP $DIR/$tdir/$tfile Ow_c &
3180 # give multiop a chance to open
3183 $DIR/$tdir/$tfile && error || true
3186 run_test 43 "execution of file opened for write should return -ETXTBSY"
3189 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3190 test_mkdir -p $DIR/$tdir
3191 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3192 cp -p multiop $DIR/$tdir/multiop
3193 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/test43.junk O_c ||
3196 $MULTIOP $DIR/$tdir/multiop Oc && error "expected error, got success"
3197 kill -USR1 $MULTIOP_PID || return 2
3198 wait $MULTIOP_PID || return 3
3201 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
3204 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3205 test_mkdir -p $DIR/$tdir
3206 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3207 cp -p multiop $DIR/$tdir/multiop
3208 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/test43.junk O_c ||
3211 $TRUNCATE $DIR/$tdir/multiop 0 && error "expected error, got success"
3212 kill -USR1 $MULTIOP_PID || return 2
3213 wait $MULTIOP_PID || return 3
3216 run_test 43b "truncate of file being executed should return -ETXTBSY"
3219 local testdir="$DIR/$tdir"
3220 test_mkdir -p $DIR/$tdir
3222 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
3223 ( cd $testdir && md5sum -c)
3225 run_test 43c "md5sum of copy into lustre========================"
3228 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
3229 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
3230 dd if=$DIR/f1 bs=4k count=1 > /dev/null
3232 run_test 44 "zero length read from a sparse stripe ============="
3235 local nstripe=`$LCTL lov_getconfig $DIR | grep default_stripe_count: | \
3237 [ -z "$nstripe" ] && skip "can't get stripe info" && return
3238 [ "$nstripe" -gt "$OSTCOUNT" ] && skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" && return
3239 local stride=`$LCTL lov_getconfig $DIR | grep default_stripe_size: | \
3241 if [ $nstripe -eq 0 -o $nstripe -eq -1 ] ; then
3242 nstripe=`$LCTL lov_getconfig $DIR | grep obd_count: | awk '{print $2}'`
3245 OFFSETS="0 $((stride/2)) $((stride-1))"
3246 for offset in $OFFSETS ; do
3247 for i in `seq 0 $((nstripe-1))`; do
3248 local GLOBALOFFSETS=""
3249 local size=$((((i + 2 * $nstripe )*$stride + $offset))) # Bytes
3250 local myfn=$DIR/d44a-$size
3251 echo "--------writing $myfn at $size"
3252 ll_sparseness_write $myfn $size || error "ll_sparseness_write"
3253 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3254 ll_sparseness_verify $myfn $GLOBALOFFSETS \
3255 || error "ll_sparseness_verify $GLOBALOFFSETS"
3257 for j in `seq 0 $((nstripe-1))`; do
3258 size=$((((j + $nstripe )*$stride + $offset))) # Bytes
3259 ll_sparseness_write $myfn $size || error "ll_sparseness_write"
3260 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3262 ll_sparseness_verify $myfn $GLOBALOFFSETS \
3263 || error "ll_sparseness_verify $GLOBALOFFSETS"
3268 run_test 44a "test sparse pwrite ==============================="
3272 for d in `lctl get_param -n osc.*.cur_dirty_bytes`; do
3278 before=`dirty_osc_total`
3279 echo executing "\"$*\""
3281 after=`dirty_osc_total`
3282 echo before $before, after $after
3285 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3287 # Obtain grants from OST if it supports it
3288 echo blah > ${f}_grant
3291 do_dirty_record "echo blah > $f"
3292 [ $before -eq $after ] && error "write wasn't cached"
3293 do_dirty_record "> $f"
3294 [ $before -gt $after ] || error "truncate didn't lower dirty count"
3295 do_dirty_record "echo blah > $f"
3296 [ $before -eq $after ] && error "write wasn't cached"
3297 do_dirty_record "sync"
3298 [ $before -gt $after ] || error "writeback didn't lower dirty count"
3299 do_dirty_record "echo blah > $f"
3300 [ $before -eq $after ] && error "write wasn't cached"
3301 do_dirty_record "cancel_lru_locks osc"
3302 [ $before -gt $after ] || error "lock cancellation didn't lower dirty count"
3305 run_test 45 "osc io page accounting ============================"
3307 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
3308 # test tickles a bug where re-dirtying a page was failing to be mapped to the
3309 # objects offset and an assert hit when an rpc was built with 1023's mapped
3310 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
3312 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3316 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3318 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
3319 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3323 run_test 46 "dirtying a previously written page ================"
3325 # test_47 is removed "Device nodes check" is moved to test_28
3327 test_48a() { # bug 2399
3328 check_kernel_version 34 || return 0
3329 test_mkdir -p $DIR/$tdir
3331 mv $DIR/$tdir $DIR/d48.new || error "move directory failed"
3332 test_mkdir $DIR/$tdir || error "recreate directory failed"
3333 touch foo || error "'touch foo' failed after recreating cwd"
3334 test_mkdir $DIR/$tdir/bar ||
3335 error "'mkdir foo' failed after recreating cwd"
3336 if check_kernel_version 44; then
3337 touch .foo || error "'touch .foo' failed after recreating cwd"
3338 test_mkdir $DIR/$tdir/.bar ||
3339 error "'mkdir .foo' failed after recreating cwd"
3341 ls . > /dev/null || error "'ls .' failed after recreating cwd"
3342 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3343 cd . || error "'cd .' failed after recreating cwd"
3344 test_mkdir . && error "'mkdir .' worked after recreating cwd"
3345 rmdir . && error "'rmdir .' worked after recreating cwd"
3346 ln -s . baz || error "'ln -s .' failed after recreating cwd"
3347 cd .. || error "'cd ..' failed after recreating cwd"
3349 run_test 48a "Access renamed working dir (should return errors)="
3351 test_48b() { # bug 2399
3352 check_kernel_version 34 || return 0
3354 test_mkdir -p $DIR/$tdir
3356 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
3357 touch foo && error "'touch foo' worked after removing cwd"
3358 test_mkdir $DIR/$tdir/foo &&
3359 error "'mkdir foo' worked after removing cwd"
3360 if check_kernel_version 44; then
3361 touch .foo && error "'touch .foo' worked after removing cwd"
3362 test_mkdir $DIR/$tdir/.foo &&
3363 error "'mkdir .foo' worked after removing cwd"
3365 ls . > /dev/null && error "'ls .' worked after removing cwd"
3366 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3367 is_patchless || ( cd . && error "'cd .' worked after removing cwd" )
3368 test_mkdir $DIR/$tdir/. && error "'mkdir .' worked after removing cwd"
3369 rmdir . && error "'rmdir .' worked after removing cwd"
3370 ln -s . foo && error "'ln -s .' worked after removing cwd"
3371 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
3373 run_test 48b "Access removed working dir (should return errors)="
3375 test_48c() { # bug 2350
3376 check_kernel_version 36 || return 0
3377 #lctl set_param debug=-1
3380 test_mkdir -p $DIR/$tdir/dir
3382 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3383 $TRACE touch foo && error "touch foo worked after removing cwd"
3384 $TRACE test_mkdir foo && error "'mkdir foo' worked after removing cwd"
3385 if check_kernel_version 44; then
3386 touch .foo && error "touch .foo worked after removing cwd"
3387 test_mkdir .foo && error "mkdir .foo worked after removing cwd"
3389 $TRACE ls . && error "'ls .' worked after removing cwd"
3390 $TRACE ls .. || error "'ls ..' failed after removing cwd"
3391 is_patchless || ( $TRACE cd . &&
3392 error "'cd .' worked after removing cwd" )
3393 $TRACE test_mkdir . && error "'mkdir .' worked after removing cwd"
3394 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
3395 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
3396 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
3398 run_test 48c "Access removed working subdir (should return errors)"
3400 test_48d() { # bug 2350
3401 check_kernel_version 36 || return 0
3402 #lctl set_param debug=-1
3405 test_mkdir -p $DIR/$tdir/dir
3407 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3408 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3409 $TRACE touch foo && error "'touch foo' worked after removing parent"
3410 $TRACE test_mkdir foo && error "mkdir foo worked after removing parent"
3411 if check_kernel_version 44; then
3412 touch .foo && error "'touch .foo' worked after removing parent"
3414 error "mkdir .foo worked after removing parent"
3416 $TRACE ls . && error "'ls .' worked after removing parent"
3417 $TRACE ls .. && error "'ls ..' worked after removing parent"
3418 is_patchless || ( $TRACE cd . &&
3419 error "'cd .' worked after recreate parent" )
3420 $TRACE test_mkdir . && error "'mkdir .' worked after removing parent"
3421 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
3422 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
3423 is_patchless || ( $TRACE cd .. &&
3424 error "'cd ..' worked after removing parent" || true )
3426 run_test 48d "Access removed parent subdir (should return errors)"
3428 test_48e() { # bug 4134
3429 check_kernel_version 41 || return 0
3430 #lctl set_param debug=-1
3433 test_mkdir -p $DIR/$tdir/dir
3435 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3436 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3437 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
3438 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
3439 # On a buggy kernel addition of "touch foo" after cd .. will
3440 # produce kernel oops in lookup_hash_it
3441 touch ../foo && error "'cd ..' worked after recreate parent"
3443 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
3445 run_test 48e "Access to recreated parent subdir (should return errors)"
3447 test_49() { # LU-1030
3448 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3449 # get ost1 size - lustre-OST0000
3450 ost1_size=$(do_facet ost1 lfs df |grep ${ost1_svc} |awk '{print $4}')
3451 # write 800M at maximum
3452 [ $ost1_size -gt 819200 ] && ost1_size=819200
3454 lfs setstripe -c 1 -i 0 $DIR/$tfile
3455 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
3458 # change max_pages_per_rpc while writing the file
3459 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
3460 local orig_mppc=`$LCTL get_param -n $osc1_mppc`
3461 # loop until dd process exits
3462 while ps ax -opid | grep -wq $dd_pid; do
3463 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
3464 sleep $((RANDOM % 5 + 1))
3466 # restore original max_pages_per_rpc
3467 $LCTL set_param $osc1_mppc=$orig_mppc
3468 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
3470 run_test 49 "Change max_pages_per_rpc won't break osc extent"
3474 test_mkdir $DIR/$tdir
3476 ls /proc/$$/cwd || error
3478 run_test 50 "special situations: /proc symlinks ==============="
3480 test_51a() { # was test_51
3481 # bug 1516 - create an empty entry right after ".." then split dir
3482 test_mkdir -p $DIR/$tdir
3483 touch $DIR/$tdir/foo
3484 $MCREATE $DIR/$tdir/bar
3486 createmany -m $DIR/$tdir/longfile 201
3488 while [ `ls -sd $DIR/$tdir | awk '{ print $1 }'` -eq 4 ]; do
3489 $MCREATE $DIR/$tdir/longfile$FNUM
3494 ls -l $DIR/$tdir > /dev/null || error
3496 run_test 51a "special situations: split htree with empty entry =="
3498 export NUMTEST=70000
3500 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3501 local BASE=$DIR/$tdir
3503 # cleanup the directory
3508 local mdtidx=$(printf "%04x" $($LFS getstripe -M $BASE))
3509 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
3510 [ $numfree -lt 21000 ] && skip "not enough free inodes ($numfree)" &&
3513 [ $numfree -lt $NUMTEST ] && NUMTEST=$(($numfree - 50)) &&
3514 echo "reduced count to $NUMTEST due to inodes"
3516 # need to check free space for the directories as well
3517 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
3518 numfree=$((blkfree / 4))
3519 [ $numfree -lt $NUMTEST ] && NUMTEST=$(($numfree - 50)) &&
3520 echo "reduced count to $NUMTEST due to blocks"
3522 createmany -d $BASE/d $NUMTEST && echo $NUMTEST > $BASE/fnum ||
3523 echo "failed" > $BASE/fnum
3525 run_test 51b "exceed 64k subdirectory nlink limit"
3527 test_51ba() { # LU-993
3528 local BASE=$DIR/$tdir
3529 # unlink all but 100 subdirectories, then check it still works
3531 [ -f $BASE/fnum ] && local NUMPREV=$(cat $BASE/fnum) && rm $BASE/fnum
3533 [ "$NUMPREV" != "failed" ] && NUMTEST=$NUMPREV
3534 local DELETE=$((NUMTEST - LEFT))
3536 # continue on to run this test even if 51b didn't finish,
3537 # just to delete the many subdirectories created.
3538 [ ! -d "${BASE}/d1" ] && skip "test_51b() not run" && return 0
3540 # for ldiskfs the nlink count should be 1, but this is OSD specific
3541 # and so this is listed for informational purposes only
3542 echo "nlink before: $(stat -c %h $BASE), created before: $NUMTEST"
3543 unlinkmany -d $BASE/d $DELETE
3546 if [ $RC -ne 0 ]; then
3547 if [ "$NUMPREV" == "failed" ]; then
3548 skip "previous setup failed"
3551 error "unlink of first $DELETE subdirs failed"
3556 echo "nlink between: $(stat -c %h $BASE)"
3557 # trim the first line of ls output
3558 local FOUND=$(($(ls -l ${BASE} | wc -l) - 1))
3559 [ $FOUND -ne $LEFT ] &&
3560 error "can't find subdirs: found only $FOUND/$LEFT"
3562 unlinkmany -d $BASE/d $DELETE $LEFT ||
3563 error "unlink of second $LEFT subdirs failed"
3564 # regardless of whether the backing filesystem tracks nlink accurately
3565 # or not, the nlink count shouldn't be more than "." and ".." here
3566 local AFTER=$(stat -c %h $BASE)
3567 [ $AFTER -gt 2 ] && error "nlink after: $AFTER > 2" ||
3568 echo "nlink after: $AFTER"
3570 run_test 51ba "verify nlink for many subdirectory cleanup"
3573 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3574 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping test with few OSTs" && return
3575 test_mkdir -p $DIR/$tdir
3576 createmany -o $DIR/$tdir/t- 1000
3577 $GETSTRIPE $DIR/$tdir > $TMP/files
3578 for N in `seq 0 $((OSTCOUNT - 1))`; do
3579 OBJS[$N]=`awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}' $TMP/files`
3580 OBJS0[$N]=`grep -A 1 idx $TMP/files | awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}'`
3581 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
3583 unlinkmany $DIR/$tdir/t- 1000
3586 for N in `seq 1 $((OSTCOUNT - 1))`; do
3587 [ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ] && \
3588 error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
3589 [ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ] && \
3590 error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
3592 [ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ] && \
3593 error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
3594 [ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ] && \
3595 error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
3599 run_test 51d "check object distribution ===================="
3602 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
3603 test_mkdir -p $DIR/$tdir
3604 touch $DIR/$tdir/foo
3605 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
3606 echo bar >> $DIR/$tdir/foo || error "append bar failed"
3607 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
3608 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
3609 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
3611 echo foo >> $DIR/$tdir/foo || error "append foo failed"
3612 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
3613 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
3615 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
3616 cp -r $DIR/$tdir /tmp/
3617 rm -fr $DIR/$tdir || error "cleanup rm failed"
3619 run_test 52a "append-only flag test (should return errors) ====="
3622 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
3623 test_mkdir -p $DIR/$tdir
3624 touch $DIR/$tdir/foo
3625 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
3626 cat test > $DIR/$tdir/foo && error "cat test worked"
3627 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
3628 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
3629 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
3631 echo foo >> $DIR/$tdir/foo && error "echo worked"
3632 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
3633 [ -f $DIR/$tdir/foo ] || error
3634 [ -f $DIR/$tdir/foo_ren ] && error
3635 lsattr $DIR/$tdir/foo | egrep -q "^-+i[-e]+ $DIR/$tdir/foo" ||
3637 chattr -i $DIR/$tdir/foo || error "chattr failed"
3639 rm -fr $DIR/$tdir || error
3641 run_test 52b "immutable flag test (should return errors) ======="
3644 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3645 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3646 remote_ost_nodsh && skip "remote OST with nodsh" && return
3656 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
3657 for value in $(do_facet $SINGLEMDS lctl get_param osc.$mdtosc.prealloc_last_id) ; do
3658 param=`echo ${value[0]} | cut -d "=" -f1`
3659 ostname=`echo $param | cut -d "." -f2 | cut -d - -f 1-2`
3660 mds_last=$(do_facet $SINGLEMDS lctl get_param -n $param)
3661 ostnum=$(index_from_ostuuid ${ostname}_UUID)
3662 node=$(facet_active_host ost$((ostnum+1)))
3663 param="obdfilter.$ostname.last_id"
3664 ost_last=$(do_node $node lctl get_param -n $param | head -n 1)
3665 echo "$ostname.last_id=$ost_last ; MDS.last_id=$mds_last"
3666 if [ $ost_last != $mds_last ]; then
3667 error "$ostname.last_id=$ost_last ; MDS.last_id=$mds_last"
3671 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
3674 [ ! -f "$SOCKETSERVER" ] && skip_env "no socketserver, skipping" && return
3675 [ ! -f "$SOCKETCLIENT" ] && skip_env "no socketclient, skipping" && return
3676 $SOCKETSERVER $DIR/socket
3677 $SOCKETCLIENT $DIR/socket || error
3678 $MUNLINK $DIR/socket
3680 run_test 54a "unix domain socket test =========================="
3686 dd if=/dev/zero of=$f bs=`page_size` count=1
3688 run_test 54b "char device works in lustre ======================"
3691 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
3692 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
3693 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
3695 for i in `seq 3 7`; do
3696 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
3704 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3707 loopdev="$DIR/loop54c"
3710 [ -z "$LOOPNUM" ] && echo "couldn't find empty loop device" && return
3711 mknod $loopdev b 7 $LOOPNUM
3712 echo "make a loop file system with $tfile on $loopdev ($LOOPNUM)..."
3713 dd if=/dev/zero of=$tfile bs=`page_size` seek=1024 count=1 > /dev/null
3714 losetup $loopdev $tfile || error "can't set up $loopdev for $tfile"
3715 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
3717 mount -t ext2 $loopdev $tdir || error "error mounting $loopdev on $tdir"
3718 dd if=/dev/zero of=$tdir/tmp bs=`page_size` count=30 || error "dd write"
3720 dd if=$tdir/tmp of=/dev/zero bs=`page_size` count=30 || error "dd read"
3725 run_test 54c "block device works in lustre ====================="
3731 [ "$string" = `echo $string > $f | cat $f` ] || error
3733 run_test 54d "fifo device works in lustre ======================"
3736 check_kernel_version 46 || return 0
3739 cp -aL /dev/console $f
3740 echo $string > $f || error
3742 run_test 54e "console/tty device works in lustre ======================"
3744 #The test_55 used to be iopen test and it was removed by bz#24037.
3745 #run_test 55 "check iopen_connect_dentry() ======================"
3747 test_56a() { # was test_56
3750 test_mkdir $DIR/$tdir
3751 test_mkdir $DIR/$tdir/dir
3753 NUMFILESx2=$(($NUMFILES * 2))
3754 for i in `seq 1 $NUMFILES` ; do
3755 touch $DIR/$tdir/file$i
3756 touch $DIR/$tdir/dir/file$i
3759 # test lfs getstripe with --recursive
3760 FILENUM=`$GETSTRIPE --recursive $DIR/$tdir | grep -c obdidx`
3761 [ $FILENUM -eq $NUMFILESx2 ] ||
3762 error "$GETSTRIPE --recursive: found $FILENUM, not $NUMFILESx2"
3763 FILENUM=`$GETSTRIPE $DIR/$tdir | grep -c obdidx`
3764 [ $FILENUM -eq $NUMFILES ] ||
3765 error "$GETSTRIPE $DIR/$tdir: found $FILENUM, not $NUMFILES"
3766 echo "$GETSTRIPE --recursive passed."
3768 # test lfs getstripe with file instead of dir
3769 FILENUM=`$GETSTRIPE $DIR/$tdir/file1 | grep -c obdidx`
3770 [ $FILENUM -eq 1 ] || error \
3771 "$GETSTRIPE $DIR/$tdir/file1: found $FILENUM, not 1"
3772 echo "$GETSTRIPE file1 passed."
3774 #test lfs getstripe with --verbose
3775 [ `$GETSTRIPE --verbose $DIR/$tdir |
3776 grep -c lmm_magic` -eq $NUMFILES ] ||
3777 error "$GETSTRIPE --verbose $DIR/$tdir: want $NUMFILES"
3778 [ `$GETSTRIPE $DIR/$tdir | grep -c lmm_magic` -eq 0 ] ||
3779 error "$GETSTRIPE $DIR/$tdir: showed lmm_magic"
3780 echo "$GETSTRIPE --verbose passed."
3782 #test lfs getstripe with --obd
3783 $GETSTRIPE --obd wrong_uuid $DIR/$tdir 2>&1 |
3784 grep -q "unknown obduuid" ||
3785 error "$GETSTRIPE --obd wrong_uuid should return error message"
3787 [ "$OSTCOUNT" -lt 2 ] &&
3788 skip_env "skipping other $GETSTRIPE --obd test" && return
3791 OBDUUID=$(ostuuid_from_index $OSTIDX)
3792 FILENUM=`$GETSTRIPE -ir $DIR/$tdir | grep -x $OSTIDX | wc -l`
3793 FOUND=`$GETSTRIPE -r --obd $OBDUUID $DIR/$tdir | grep obdidx | wc -l`
3794 [ $FOUND -eq $FILENUM ] ||
3795 error "$GETSTRIPE --obd wrong: found $FOUND, expected $FILENUM"
3796 [ `$GETSTRIPE -r -v --obd $OBDUUID $DIR/$tdir |
3797 sed '/^[ ]*'${OSTIDX}'[ ]/d' |
3798 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l` -eq 0 ] ||
3799 error "$GETSTRIPE --obd: should not show file on other obd"
3800 echo "$GETSTRIPE --obd passed"
3802 run_test 56a "check $GETSTRIPE"
3807 local LOCAL_NUMFILES="$1"
3808 local LOCAL_NUMDIRS="$2"
3809 local MKDIR_PARAMS="$3"
3811 if [ ! -d "$TDIR" ] ; then
3813 [ "$MKDIR_PARAMS" ] && $SETSTRIPE $MKDIR_PARAMS $TDIR
3814 for i in `seq 1 $LOCAL_NUMFILES` ; do
3817 for i in `seq 1 $LOCAL_NUMDIRS` ; do
3818 test_mkdir $TDIR/dir$i
3819 for j in `seq 1 $LOCAL_NUMFILES` ; do
3820 touch $TDIR/dir$i/file$j
3826 setup_56_special() {
3830 if [ ! -e "$TDIR/loop1b" ] ; then
3831 for i in `seq 1 $LOCAL_NUMFILES` ; do
3832 mknod $TDIR/loop${i}b b 7 $i
3833 mknod $TDIR/null${i}c c 1 3
3834 ln -s $TDIR/file1 $TDIR/link${i}l
3836 for i in `seq 1 $LOCAL_NUMDIRS` ; do
3837 mknod $TDIR/dir$i/loop${i}b b 7 $i
3838 mknod $TDIR/dir$i/null${i}c c 1 3
3839 ln -s $TDIR/dir$i/file1 $TDIR/dir$i/link${i}l
3848 setup_56 $NUMFILES $NUMDIRS
3850 EXPECTED=$(($NUMDIRS + 2))
3851 # test lfs find with -name
3852 for i in $(seq 1 $NUMFILES) ; do
3853 NUMS=$($LFIND -name "*$i" $TDIR | wc -l)
3854 [ $NUMS -eq $EXPECTED ] ||
3855 error "lfs find -name \"*$i\" $TDIR wrong: "\
3856 "found $NUMS, expected $EXPECTED"
3859 run_test 56g "check lfs find -name ============================="
3865 setup_56 $NUMFILES $NUMDIRS
3867 EXPECTED=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
3868 # test lfs find with ! -name
3869 for i in $(seq 1 $NUMFILES) ; do
3870 NUMS=$($LFIND ! -name "*$i" $TDIR | wc -l)
3871 [ $NUMS -eq $EXPECTED ] ||
3872 error "lfs find ! -name \"*$i\" $TDIR wrong: "\
3873 "found $NUMS, expected $EXPECTED"
3876 run_test 56h "check lfs find ! -name ============================="
3880 test_mkdir -p $DIR/$tdir
3881 UUID=$(ostuuid_from_index 0 $DIR/$tdir)
3882 CMD="$LFIND -ost $UUID $DIR/$tdir"
3884 [ -z "$OUT" ] || error "\"$CMD\" returned directory '$OUT'"
3886 run_test 56i "check 'lfs find -ost UUID' skips directories ======="
3890 setup_56_special $NUMFILES $NUMDIRS
3892 EXPECTED=$((NUMDIRS + 1))
3893 CMD="$LFIND -type d $TDIR"
3894 NUMS=$($CMD | wc -l)
3895 [ $NUMS -eq $EXPECTED ] ||
3896 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3898 run_test 56j "check lfs find -type d ============================="
3902 setup_56_special $NUMFILES $NUMDIRS
3904 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
3905 CMD="$LFIND -type f $TDIR"
3906 NUMS=$($CMD | wc -l)
3907 [ $NUMS -eq $EXPECTED ] ||
3908 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3910 run_test 56k "check lfs find -type f ============================="
3914 setup_56_special $NUMFILES $NUMDIRS
3916 EXPECTED=$((NUMDIRS + NUMFILES))
3917 CMD="$LFIND -type b $TDIR"
3918 NUMS=$($CMD | wc -l)
3919 [ $NUMS -eq $EXPECTED ] ||
3920 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3922 run_test 56l "check lfs find -type b ============================="
3926 setup_56_special $NUMFILES $NUMDIRS
3928 EXPECTED=$((NUMDIRS + NUMFILES))
3929 CMD="$LFIND -type c $TDIR"
3930 NUMS=$($CMD | wc -l)
3931 [ $NUMS -eq $EXPECTED ] ||
3932 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3934 run_test 56m "check lfs find -type c ============================="
3938 setup_56_special $NUMFILES $NUMDIRS
3940 EXPECTED=$((NUMDIRS + NUMFILES))
3941 CMD="$LFIND -type l $TDIR"
3942 NUMS=$($CMD | wc -l)
3943 [ $NUMS -eq $EXPECTED ] ||
3944 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3946 run_test 56n "check lfs find -type l ============================="
3950 setup_56 $NUMFILES $NUMDIRS
3952 utime $TDIR/file1 > /dev/null || error "utime (1)"
3953 utime $TDIR/file2 > /dev/null || error "utime (2)"
3954 utime $TDIR/dir1 > /dev/null || error "utime (3)"
3955 utime $TDIR/dir2 > /dev/null || error "utime (4)"
3956 utime $TDIR/dir1/file1 > /dev/null || error "utime (5)"
3957 dd if=/dev/zero count=1 >> $TDIR/dir1/file1 && sync
3960 NUMS=`$LFIND -mtime +0 $TDIR | wc -l`
3961 [ $NUMS -eq $EXPECTED ] || \
3962 error "lfs find -mtime +0 $TDIR wrong: found $NUMS, expected $EXPECTED"
3965 CMD="$LFIND -mtime 0 $TDIR"
3966 NUMS=$($CMD | wc -l)
3967 [ $NUMS -eq $EXPECTED ] ||
3968 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3970 run_test 56o "check lfs find -mtime for old files =========================="
3973 [ $RUNAS_ID -eq $UID ] &&
3974 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
3977 setup_56 $NUMFILES $NUMDIRS
3979 chown $RUNAS_ID $TDIR/file* || error "chown $DIR/${tdir}g/file$i failed"
3981 CMD="$LFIND -uid $RUNAS_ID $TDIR"
3982 NUMS=$($CMD | wc -l)
3983 [ $NUMS -eq $EXPECTED ] || \
3984 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3986 EXPECTED=$(((NUMFILES + 1) * NUMDIRS + 1))
3987 CMD="$LFIND ! -uid $RUNAS_ID $TDIR"
3988 NUMS=$($CMD | wc -l)
3989 [ $NUMS -eq $EXPECTED ] || \
3990 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3992 run_test 56p "check lfs find -uid and ! -uid ==============================="
3995 [ $RUNAS_ID -eq $UID ] &&
3996 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
3999 setup_56 $NUMFILES $NUMDIRS
4001 chgrp $RUNAS_GID $TDIR/file* || error "chown $TDIR/file$i failed"
4004 CMD="$LFIND -gid $RUNAS_GID $TDIR"
4005 NUMS=$($CMD | wc -l)
4006 [ $NUMS -eq $EXPECTED ] ||
4007 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4009 EXPECTED=$(( ($NUMFILES+1) * $NUMDIRS + 1))
4010 CMD="$LFIND ! -gid $RUNAS_GID $TDIR"
4011 NUMS=$($CMD | wc -l)
4012 [ $NUMS -eq $EXPECTED ] ||
4013 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4015 run_test 56q "check lfs find -gid and ! -gid ==============================="
4019 setup_56 $NUMFILES $NUMDIRS
4022 CMD="$LFIND -size 0 -type f $TDIR"
4023 NUMS=$($CMD | wc -l)
4024 [ $NUMS -eq $EXPECTED ] ||
4025 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4027 CMD="$LFIND ! -size 0 -type f $TDIR"
4028 NUMS=$($CMD | wc -l)
4029 [ $NUMS -eq $EXPECTED ] ||
4030 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4031 echo "test" > $TDIR/$tfile
4032 echo "test2" > $TDIR/$tfile.2 && sync
4034 CMD="$LFIND -size 5 -type f $TDIR"
4035 NUMS=$($CMD | wc -l)
4036 [ $NUMS -eq $EXPECTED ] ||
4037 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4039 CMD="$LFIND -size +5 -type f $TDIR"
4040 NUMS=$($CMD | wc -l)
4041 [ $NUMS -eq $EXPECTED ] ||
4042 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4044 CMD="$LFIND -size +0 -type f $TDIR"
4045 NUMS=$($CMD | wc -l)
4046 [ $NUMS -eq $EXPECTED ] ||
4047 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4049 CMD="$LFIND ! -size -5 -type f $TDIR"
4050 NUMS=$($CMD | wc -l)
4051 [ $NUMS -eq $EXPECTED ] ||
4052 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4054 CMD="$LFIND -size -5 -type f $TDIR"
4055 NUMS=$($CMD | wc -l)
4056 [ $NUMS -eq $EXPECTED ] ||
4057 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4059 run_test 56r "check lfs find -size works =========================="
4061 test_56s() { # LU-611
4063 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT"
4065 if [ $OSTCOUNT -gt 1 ]; then
4066 $SETSTRIPE -c 1 $TDIR/$tfile.{0,1,2,3}
4070 ONESTRIPE=$(((NUMDIRS + 1) * NUMFILES))
4074 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4075 CMD="$LFIND -stripe-count $OSTCOUNT -type f $TDIR"
4076 NUMS=$($CMD | wc -l)
4077 [ $NUMS -eq $EXPECTED ] ||
4078 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4080 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + EXTRA))
4081 CMD="$LFIND -stripe-count +0 -type f $TDIR"
4082 NUMS=$($CMD | wc -l)
4083 [ $NUMS -eq $EXPECTED ] ||
4084 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4087 CMD="$LFIND -stripe-count 1 -type f $TDIR"
4088 NUMS=$($CMD | wc -l)
4089 [ $NUMS -eq $EXPECTED ] ||
4090 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4092 CMD="$LFIND -stripe-count -2 -type f $TDIR"
4093 NUMS=$($CMD | wc -l)
4094 [ $NUMS -eq $EXPECTED ] ||
4095 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4098 CMD="$LFIND -stripe-count $((OSTCOUNT + 1)) -type f $TDIR"
4099 NUMS=$($CMD | wc -l)
4100 [ $NUMS -eq $EXPECTED ] ||
4101 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4103 run_test 56s "check lfs find -stripe-count works"
4105 test_56t() { # LU-611
4107 setup_56 $NUMFILES $NUMDIRS "-s 512k"
4109 $SETSTRIPE -S 256k $TDIR/$tfile.{0,1,2,3}
4111 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4112 CMD="$LFIND -stripe-size 512k -type f $TDIR"
4113 NUMS=$($CMD | wc -l)
4114 [ $NUMS -eq $EXPECTED ] ||
4115 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4117 CMD="$LFIND -stripe-size +320k -type f $TDIR"
4118 NUMS=$($CMD | wc -l)
4119 [ $NUMS -eq $EXPECTED ] ||
4120 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4122 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + 4))
4123 CMD="$LFIND -stripe-size +200k -type f $TDIR"
4124 NUMS=$($CMD | wc -l)
4125 [ $NUMS -eq $EXPECTED ] ||
4126 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4128 CMD="$LFIND -stripe-size -640k -type f $TDIR"
4129 NUMS=$($CMD | wc -l)
4130 [ $NUMS -eq $EXPECTED ] ||
4131 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4134 CMD="$LFIND -stripe-size 256k -type f $TDIR"
4135 NUMS=$($CMD | wc -l)
4136 [ $NUMS -eq $EXPECTED ] ||
4137 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4139 CMD="$LFIND -stripe-size -320k -type f $TDIR"
4140 NUMS=$($CMD | wc -l)
4141 [ $NUMS -eq $EXPECTED ] ||
4142 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4145 CMD="$LFIND -stripe-size 1024k -type f $TDIR"
4146 NUMS=$($CMD | wc -l)
4147 [ $NUMS -eq $EXPECTED ] ||
4148 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4150 run_test 56t "check lfs find -stripe-size works"
4152 test_56u() { # LU-611
4154 setup_56 $NUMFILES $NUMDIRS "-i 0"
4156 if [ $OSTCOUNT -gt 1 ]; then
4157 $SETSTRIPE -i 1 $TDIR/$tfile.{0,1,2,3}
4163 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4164 CMD="$LFIND -stripe-index 0 -type f $TDIR"
4165 NUMS=$($CMD | wc -l)
4166 [ $NUMS -eq $EXPECTED ] ||
4167 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4170 CMD="$LFIND -stripe-index 1 -type f $TDIR"
4171 NUMS=$($CMD | wc -l)
4172 [ $NUMS -eq $EXPECTED ] ||
4173 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4175 CMD="$LFIND ! -stripe-index 0 -type f $TDIR"
4176 NUMS=$($CMD | wc -l)
4177 [ $NUMS -eq $EXPECTED ] ||
4178 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4181 # This should produce an error and not return any files
4182 CMD="$LFIND -stripe-index $OSTCOUNT -type f $TDIR"
4183 NUMS=$($CMD 2>/dev/null | wc -l)
4184 [ $NUMS -eq $EXPECTED ] ||
4185 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4187 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + ONESTRIPE))
4188 CMD="$LFIND -stripe-index 0,1 -type f $TDIR"
4189 NUMS=$($CMD | wc -l)
4190 [ $NUMS -eq $EXPECTED ] ||
4191 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4193 run_test 56u "check lfs find -stripe-index works"
4200 setup_56 $NUMFILES $NUMDIRS
4202 UUID=$(mdtuuid_from_index $MDT_IDX $TDIR)
4203 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT index $MDT_IDX"
4205 for file in $($LFIND -mdt $UUID $TDIR); do
4206 file_mdt_idx=$($GETSTRIPE -M $file)
4207 [ $file_mdt_idx -eq $MDT_IDX ] ||
4208 error "'lfind -mdt $UUID' != 'getstripe -M' ($file_mdt_idx)"
4211 run_test 56v "check 'lfs find -mdt match with lfs getstripe -M' ======="
4213 # Get and check the actual stripe count of one file.
4214 # Usage: check_stripe_count <file> <expected_stripe_count>
4215 check_stripe_count() {
4220 [[ -z "$file" || -z "$expected" ]] &&
4221 error "check_stripe_count: invalid argument!"
4223 local cmd="$GETSTRIPE -c $file"
4224 actual=$($cmd) || error "$cmd failed"
4225 actual=${actual%% *}
4227 if [[ $actual -ne $expected ]]; then
4228 [[ $expected -eq -1 ]] ||
4229 error "$cmd wrong: found $actual, expected $expected"
4230 [[ $actual -eq $OSTCOUNT ]] ||
4231 error "$cmd wrong: found $actual, expected $OSTCOUNT"
4236 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4239 rm -rf $TDIR || error "remove $TDIR failed"
4240 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT"
4243 stripe_size=$($GETSTRIPE -S -d $TDIR) ||
4244 error "$GETSTRIPE -S -d $TDIR failed"
4245 stripe_size=${stripe_size%% *}
4247 local file_size=$((stripe_size * OSTCOUNT))
4248 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
4249 local required_space=$((file_num * file_size))
4250 local free_space=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
4251 [[ $free_space -le $((required_space / 1024)) ]] &&
4252 skip_env "need at least $required_space bytes free space," \
4253 "have $free_space kbytes" && return
4256 local dd_count=$((file_size / dd_bs))
4258 # write data into the files
4262 for i in $(seq 1 $NUMFILES); do
4264 yes | dd bs=$dd_bs count=$dd_count of=$file >/dev/null 2>&1 ||
4265 error "write data into $file failed"
4267 for i in $(seq 1 $NUMDIRS); do
4268 for j in $(seq 1 $NUMFILES); do
4269 file=$TDIR/dir$i/file$j
4270 yes | dd bs=$dd_bs count=$dd_count of=$file \
4272 error "write data into $file failed"
4277 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
4280 local cmd="$LFS_MIGRATE -y -c $expected $TDIR/file1"
4282 eval $cmd || error "$cmd failed"
4284 check_stripe_count $TDIR/file1 $expected
4287 cmd="$LFS_MIGRATE -y -c $expected $TDIR/dir1"
4289 eval $cmd || error "$cmd failed"
4291 for j in $(seq 1 $NUMFILES); do
4292 check_stripe_count $TDIR/dir1/file$j $expected
4295 # lfs_migrate works with lfs find
4296 cmd="$LFIND -stripe_count $OSTCOUNT -type f $TDIR |
4297 $LFS_MIGRATE -y -c $expected"
4299 eval $cmd || error "$cmd failed"
4301 for i in $(seq 2 $NUMFILES); do
4302 check_stripe_count $TDIR/file$i $expected
4304 for i in $(seq 2 $NUMDIRS); do
4305 for j in $(seq 1 $NUMFILES); do
4306 check_stripe_count $TDIR/dir$i/file$j $expected
4310 run_test 56w "check lfs_migrate -c stripe_count works"
4313 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4314 # note test will not do anything if MDS is not local
4315 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4316 skip "Only applicable to ldiskfs-based MDTs"
4320 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4321 local MNTDEV="osd*.*MDT*.mntdev"
4322 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
4323 [ -z "$DEV" ] && error "can't access $MNTDEV"
4324 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
4325 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
4326 error "can't access $DEV"
4327 DEVISIZE=`awk '/Inode size:/ { print $3 }' $TMP/t57a.dump`
4328 [ "$DEVISIZE" -gt 128 ] || error "inode size $DEVISIZE"
4332 run_test 57a "verify MDS filesystem created with large inodes =="
4335 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4336 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4337 skip "Only applicable to ldiskfs-based MDTs"
4341 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4346 local FILEN=$dir/f$FILECOUNT
4348 rm -rf $dir || error "removing $dir"
4349 test_mkdir -p $dir || error "creating $dir"
4350 local num=$(get_mds_dir $dir)
4353 echo "mcreating $FILECOUNT files"
4354 createmany -m $dir/f 1 $FILECOUNT || \
4355 error "creating files in $dir"
4357 # verify that files do not have EAs yet
4358 $GETSTRIPE $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
4359 $GETSTRIPE $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
4363 df $dir #make sure we get new statfs data
4364 local MDSFREE=$(do_facet $mymds \
4365 lctl get_param -n osd*.*MDT000$((num -1)).kbytesfree)
4366 local MDCFREE=$(lctl get_param -n mdc.*MDT000$((num -1))-mdc-*.kbytesfree)
4367 echo "opening files to create objects/EAs"
4369 for FILE in `seq -f $dir/f%g 1 $FILECOUNT`; do
4370 $OPENFILE -f O_RDWR $FILE > /dev/null 2>&1 || error "opening $FILE"
4373 # verify that files have EAs now
4374 $GETSTRIPE $FILE1 | grep -q "obdidx" || error "$FILE1 missing EA"
4375 $GETSTRIPE $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
4377 sleep 1 #make sure we get new statfs data
4379 local MDSFREE2=$(do_facet $mymds \
4380 lctl get_param -n osd*.*MDT000$((num -1)).kbytesfree)
4381 local MDCFREE2=$(lctl get_param -n mdc.*MDT000$((num -1))-mdc-*.kbytesfree)
4382 if [ "$MDCFREE2" -lt "$((MDCFREE - 8))" ]; then
4383 if [ "$MDSFREE" != "$MDSFREE2" ]; then
4384 error "MDC before $MDCFREE != after $MDCFREE2"
4386 echo "MDC before $MDCFREE != after $MDCFREE2"
4387 echo "unable to confirm if MDS has large inodes"
4392 run_test 57b "default LOV EAs are stored inside large inodes ==="
4395 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4396 [ -z "$(which wiretest 2>/dev/null)" ] &&
4397 skip_env "could not find wiretest" && return
4400 run_test 58 "verify cross-platform wire constants =============="
4403 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4404 echo "touch 130 files"
4405 createmany -o $DIR/f59- 130
4407 unlinkmany $DIR/f59- 130
4409 # wait for commitment of removal
4410 wait_delete_completed
4412 run_test 59 "verify cancellation of llog records async ========="
4414 TEST60_HEAD="test_60 run $RANDOM"
4416 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4417 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
4418 [ ! -f run-llog.sh ] && skip_env "missing subtest run-llog.sh" && return
4419 log "$TEST60_HEAD - from kernel mode"
4420 do_facet mgs sh run-llog.sh
4422 run_test 60a "llog sanity tests run from kernel module =========="
4424 test_60b() { # bug 6411
4425 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4427 LLOG_COUNT=`dmesg | awk "/$TEST60_HEAD/{marker = 1; from_marker = 0;}
4439 [ $LLOG_COUNT -gt 50 ] && error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)"|| true
4441 run_test 60b "limit repeated messages from CERROR/CWARN ========"
4444 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4445 echo "create 5000 files"
4446 createmany -o $DIR/f60c- 5000
4447 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
4448 lctl set_param fail_loc=0x80000137
4449 unlinkmany $DIR/f60c- 5000
4450 lctl set_param fail_loc=0
4452 run_test 60c "unlink file when mds full"
4455 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4456 SAVEPRINTK=$(lctl get_param -n printk)
4458 # verify "lctl mark" is even working"
4459 MESSAGE="test message ID $RANDOM $$"
4460 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
4461 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
4463 lctl set_param printk=0 || error "set lnet.printk failed"
4464 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
4465 MESSAGE="new test message ID $RANDOM $$"
4466 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
4467 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
4468 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
4470 lctl set_param -n printk="$SAVEPRINTK"
4472 run_test 60d "test printk console message masking"
4475 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4477 dd if=/dev/zero of=$f bs=`page_size` count=1
4478 cancel_lru_locks osc
4479 $MULTIOP $f OSMWUc || error
4482 run_test 61 "mmap() writes don't make sync hang ================"
4484 # bug 2330 - insufficient obd_match error checking causes LBUG
4486 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4489 cancel_lru_locks osc
4490 lctl set_param fail_loc=0x405
4491 cat $f && error "cat succeeded, expect -EIO"
4492 lctl set_param fail_loc=0
4494 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
4495 # match every page all of the time.
4496 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
4498 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
4499 test_63a() { # was test_63
4500 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4501 MAX_DIRTY_MB=`lctl get_param -n osc.*.max_dirty_mb | head -n 1`
4502 lctl set_param -n osc.*.max_dirty_mb 0
4503 for i in `seq 10` ; do
4504 dd if=/dev/zero of=$DIR/f63 bs=8k &
4510 lctl set_param -n osc.*.max_dirty_mb $MAX_DIRTY_MB
4511 rm -f $DIR/f63 || true
4513 run_test 63a "Verify oig_wait interruption does not crash ======="
4515 # bug 2248 - async write errors didn't return to application on sync
4516 # bug 3677 - async write errors left page locked
4518 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4520 lctl set_param debug=-1
4522 # ensure we have a grant to do async writes
4523 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
4526 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
4527 lctl set_param fail_loc=0x80000406
4528 $MULTIOP $DIR/$tfile Owy && \
4529 error "sync didn't return ENOMEM"
4530 sync; sleep 2; sync # do a real sync this time to flush page
4531 lctl get_param -n llite.*.dump_page_cache | grep locked && \
4532 error "locked page left in cache after async error" || true
4535 run_test 63b "async write errors should be returned to fsync ==="
4538 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4540 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
4542 run_test 64a "verify filter grant calculations (in kernel) ====="
4545 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4546 [ ! -f oos.sh ] && skip_env "missing subtest oos.sh" && return
4549 run_test 64b "check out-of-space detection on client ==========="
4552 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
4554 run_test 64c "verify grant shrink ========================------"
4556 # bug 1414 - set/get directories' stripe info
4558 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4559 test_mkdir -p $DIR/$tdir
4561 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
4563 run_test 65a "directory with no stripe info ===================="
4566 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4567 test_mkdir -p $DIR/$tdir
4568 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
4571 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
4573 run_test 65b "directory setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1"
4576 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4577 if [ $OSTCOUNT -gt 1 ]; then
4578 test_mkdir -p $DIR/$tdir
4579 $SETSTRIPE -S $(($STRIPESIZE * 4)) -i 1 \
4580 -c $(($OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
4582 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
4585 run_test 65c "directory setstripe -S $((STRIPESIZE*4)) -i 1 -c $((OSTCOUNT-1))"
4588 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4589 test_mkdir -p $DIR/$tdir
4590 if [ $STRIPECOUNT -le 0 ]; then
4592 elif [ $STRIPECOUNT -gt 2000 ]; then
4593 #LOV_MAX_STRIPE_COUNT is 2000
4594 [ $OSTCOUNT -gt 2000 ] && sc=2000 || sc=$(($OSTCOUNT - 1))
4596 sc=$(($STRIPECOUNT - 1))
4598 $SETSTRIPE -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
4599 touch $DIR/$tdir/f4 $DIR/$tdir/f5
4600 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
4601 error "lverify failed"
4603 run_test 65d "directory setstripe -S $STRIPESIZE -c stripe_count"
4606 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4607 test_mkdir -p $DIR/$tdir
4609 $SETSTRIPE $DIR/$tdir || error "setstripe"
4610 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
4611 error "no stripe info failed"
4613 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
4615 run_test 65e "directory setstripe defaults ======================="
4618 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4619 test_mkdir -p $DIR/${tdir}f
4620 $RUNAS $SETSTRIPE $DIR/${tdir}f && error "setstripe succeeded" || true
4622 run_test 65f "dir setstripe permission (should return error) ==="
4625 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4626 test_mkdir -p $DIR/$tdir
4627 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
4629 $SETSTRIPE -d $DIR/$tdir || error "setstripe"
4630 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
4631 error "delete default stripe failed"
4633 run_test 65g "directory setstripe -d ==========================="
4636 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4637 test_mkdir -p $DIR/$tdir
4638 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
4640 test_mkdir -p $DIR/$tdir/dd1
4641 [ $($GETSTRIPE -c $DIR/$tdir) == $($GETSTRIPE -c $DIR/$tdir/dd1) ] ||
4642 error "stripe info inherit failed"
4644 run_test 65h "directory stripe info inherit ===================="
4646 test_65i() { # bug6367
4647 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4648 $SETSTRIPE -S 65536 -c -1 $MOUNT
4650 run_test 65i "set non-default striping on root directory (bug 6367)="
4652 test_65ia() { # bug12836
4653 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4654 $GETSTRIPE $MOUNT || error "getstripe $MOUNT failed"
4656 run_test 65ia "getstripe on -1 default directory striping"
4658 test_65ib() { # bug12836
4659 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4660 $GETSTRIPE -v $MOUNT || error "getstripe -v $MOUNT failed"
4662 run_test 65ib "getstripe -v on -1 default directory striping"
4664 test_65ic() { # bug12836
4665 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4666 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
4668 run_test 65ic "new find on -1 default directory striping"
4670 test_65j() { # bug6367
4671 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4673 # if we aren't already remounting for each test, do so for this test
4674 if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
4675 cleanup || error "failed to unmount"
4678 $SETSTRIPE -d $MOUNT || error "setstripe failed"
4680 run_test 65j "set default striping on root directory (bug 6367)="
4682 test_65k() { # bug11679
4683 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4684 [ "$OSTCOUNT" -lt 2 ] && skip_env "too few OSTs" && return
4685 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4687 echo "Check OST status: "
4688 local MDS_OSCS=`do_facet $SINGLEMDS lctl dl |
4689 awk '/[oO][sS][cC].*md[ts]/ { print $4 }'`
4691 for OSC in $MDS_OSCS; do
4692 echo $OSC "is activate"
4693 do_facet $SINGLEMDS lctl --device %$OSC activate
4697 for INACTIVE_OSC in $MDS_OSCS; do
4698 echo "Deactivate: " $INACTIVE_OSC
4699 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
4700 for STRIPE_OSC in $MDS_OSCS; do
4701 OST=`osc_to_ost $STRIPE_OSC`
4702 IDX=`do_facet $SINGLEMDS lctl get_param -n lov.*md*.target_obd |
4703 awk -F: /$OST/'{ print $1 }' | head -n 1`
4705 [ -f $DIR/$tdir/$IDX ] && continue
4706 echo "$SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX"
4707 $SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX
4709 [ $RC -ne 0 ] && error "setstripe should have succeeded"
4712 echo $INACTIVE_OSC "is Activate."
4713 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
4716 run_test 65k "validate manual striping works properly with deactivated OSCs"
4718 test_65l() { # bug 12836
4719 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4720 test_mkdir -p $DIR/$tdir/test_dir
4721 $SETSTRIPE -c -1 $DIR/$tdir/test_dir
4722 $LFS find -mtime -1 $DIR/$tdir >/dev/null
4724 run_test 65l "lfs find on -1 stripe dir ========================"
4726 # bug 2543 - update blocks count on client
4728 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4730 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
4731 sync; sync_all_data; sync; sync_all_data
4732 cancel_lru_locks osc
4733 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
4734 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
4736 run_test 66 "update inode blocks count on client ==============="
4741 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4743 if [ ! -z "$LLOOP" ]; then
4744 if swapon -s | grep -q $LLOOP; then
4745 swapoff $LLOOP || error "swapoff failed"
4748 $LCTL blockdev_detach $LLOOP || error "detach failed"
4752 if [ ! -z "$LLITELOOPLOAD" ]; then
4760 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
4764 swapon -s | awk '($1 == "'$1'") { print $4 }'
4767 # test case for lloop driver, basic function
4769 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4770 [ "$UID" != 0 ] && skip_env "must run as root" && return
4771 llite_lloop_enabled || \
4772 { skip_env "llite_lloop module disabled" && return; }
4774 trap cleanup_68 EXIT
4776 if ! module_loaded llite_lloop; then
4777 if load_module llite/llite_lloop; then
4780 skip_env "can't find module llite_lloop"
4785 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
4786 dd if=/dev/zero of=$DIR/f68a bs=4k count=1024
4787 $LCTL blockdev_attach $DIR/f68a $LLOOP || error "attach failed"
4789 directio rdwr $LLOOP 0 1024 4096 || error "direct write failed"
4790 directio rdwr $LLOOP 0 1025 4096 && error "direct write should fail"
4794 run_test 68a "lloop driver - basic test ========================"
4796 # excercise swapping to lustre by adding a high priority swapfile entry
4797 # and then consuming memory until it is used.
4798 test_68b() { # was test_68
4799 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4800 [ "$UID" != 0 ] && skip_env "must run as root" && return
4801 lctl get_param -n devices | grep -q obdfilter && \
4802 skip "local OST" && return
4804 grep -q llite_lloop /proc/modules
4805 [ $? -ne 0 ] && skip "can't find module llite_lloop" && return
4807 [ -z "`$LCTL list_nids | grep -v tcp`" ] && \
4808 skip "can't reliably test swap with TCP" && return
4810 MEMTOTAL=`meminfo MemTotal`
4811 NR_BLOCKS=$((MEMTOTAL>>8))
4812 [[ $NR_BLOCKS -le 2048 ]] && NR_BLOCKS=2048
4814 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
4815 dd if=/dev/zero of=$DIR/f68b bs=64k seek=$NR_BLOCKS count=1
4818 $LCTL blockdev_attach $DIR/f68b $LLOOP || error "attach failed"
4820 trap cleanup_68 EXIT
4822 swapon -p 32767 $LLOOP || error "swapon $LLOOP failed"
4824 echo "before: `swapon -s | grep $LLOOP`"
4825 $MEMHOG $MEMTOTAL || error "error allocating $MEMTOTAL kB"
4826 echo "after: `swapon -s | grep $LLOOP`"
4827 SWAPUSED=`swap_used $LLOOP`
4831 [ $SWAPUSED -eq 0 ] && echo "no swap used???" || true
4833 run_test 68b "support swapping to Lustre ========================"
4835 # bug5265, obdfilter oa2dentry return -ENOENT
4836 # #define OBD_FAIL_OST_ENOENT 0x217
4838 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4839 remote_ost_nodsh && skip "remote OST with nodsh" && return
4842 $SETSTRIPE -c 1 -i 0 $f
4844 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
4846 do_facet ost1 lctl set_param fail_loc=0x217
4847 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
4848 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
4850 do_facet ost1 lctl set_param fail_loc=0
4851 $DIRECTIO write $f 0 2 || error "write error"
4853 cancel_lru_locks osc
4854 $DIRECTIO read $f 0 1 || error "read error"
4856 do_facet ost1 lctl set_param fail_loc=0x217
4857 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
4859 do_facet ost1 lctl set_param fail_loc=0
4862 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
4865 test_mkdir -p $DIR/$tdir
4866 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
4868 run_test 71 "Running dbench on lustre (don't segment fault) ===="
4870 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
4871 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4872 check_kernel_version 43 || return 0
4873 [ "$RUNAS_ID" = "$UID" ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4875 # Check that testing environment is properly set up. Skip if not
4876 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS || {
4877 skip_env "User $RUNAS_ID does not exist - skipping"
4880 # We had better clear the $DIR to get enough space for dd
4885 $RUNAS dd if=/dev/zero of=$DIR/f72 bs=512 count=1 || error
4886 # See if we are still setuid/sgid
4887 test -u $DIR/f72 -o -g $DIR/f72 && error "S/gid is not dropped on write"
4888 # Now test that MDS is updated too
4889 cancel_lru_locks mdc
4890 test -u $DIR/f72 -o -g $DIR/f72 && error "S/gid is not dropped on MDS"
4893 run_test 72a "Test that remove suid works properly (bug5695) ===="
4895 test_72b() { # bug 24226 -- keep mode setting when size is not changing
4898 [ "$RUNAS_ID" = "$UID" ] && \
4899 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4900 [ "$RUNAS_ID" -eq 0 ] && \
4901 skip_env "RUNAS_ID = 0 -- skipping" && return
4903 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4904 # Check that testing environment is properly set up. Skip if not
4905 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS || {
4906 skip_env "User $RUNAS_ID does not exist - skipping"
4909 touch $DIR/${tfile}-f{g,u}
4910 test_mkdir $DIR/${tfile}-dg
4911 test_mkdir $DIR/${tfile}-du
4912 chmod 770 $DIR/${tfile}-{f,d}{g,u}
4913 chmod g+s $DIR/${tfile}-{f,d}g
4914 chmod u+s $DIR/${tfile}-{f,d}u
4915 for perm in 777 2777 4777; do
4916 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
4917 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
4918 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
4919 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
4923 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
4925 # bug 3462 - multiple simultaneous MDC requests
4927 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4928 test_mkdir $DIR/d73-1
4929 test_mkdir $DIR/d73-2
4930 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
4933 lctl set_param fail_loc=0x80000129
4934 $MULTIOP $DIR/d73-1/f73-2 Oc &
4936 lctl set_param fail_loc=0
4938 $MULTIOP $DIR/d73-2/f73-3 Oc &
4942 wait $pid1 || return 1
4946 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
4947 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
4948 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
4952 run_test 73 "multiple MDC requests (should not deadlock)"
4954 test_74a() { # bug 6149, 6184
4955 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4956 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
4958 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
4959 # will spin in a tight reconnection loop
4961 lctl set_param fail_loc=0x8000030e
4962 # get any lock that won't be difficult - lookup works.
4964 lctl set_param fail_loc=0
4968 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
4970 test_74b() { # bug 13310
4971 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4972 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
4974 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
4975 # will spin in a tight reconnection loop
4976 lctl set_param fail_loc=0x8000030e
4977 # get a "difficult" lock
4979 lctl set_param fail_loc=0
4983 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
4986 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4987 #define OBD_FAIL_LDLM_NEW_LOCK
4988 lctl set_param fail_loc=0x80000319
4989 touch $DIR/$tfile && error "Touch successful"
4992 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
4995 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
4998 get_inode_slab_tunables() {
4999 awk '/lustre_inode_cache/ {print $9," ",$10," ",$11; exit}' /proc/slabinfo
5002 set_inode_slab_tunables() {
5003 echo "lustre_inode_cache $1" > /proc/slabinfo
5006 test_76() { # Now for bug 20433, added originally in bug 1443
5007 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5008 local SLAB_SETTINGS=`get_inode_slab_tunables`
5009 local CPUS=`getconf _NPROCESSORS_ONLN`
5010 # we cannot set limit below 1 which means 1 inode in each
5011 # per-cpu cache is still allowed
5012 set_inode_slab_tunables "1 1 0"
5013 cancel_lru_locks osc
5014 BEFORE_INODES=`num_inodes`
5015 echo "before inodes: $BEFORE_INODES"
5017 [ "$SLOW" = "no" ] && COUNT=100
5018 for i in `seq $COUNT`; do
5022 cancel_lru_locks osc
5023 AFTER_INODES=`num_inodes`
5024 echo "after inodes: $AFTER_INODES"
5026 while [ $((AFTER_INODES-1*CPUS)) -gt $BEFORE_INODES ]; do
5028 AFTER_INODES=`num_inodes`
5030 echo "wait $wait seconds inodes: $AFTER_INODES"
5031 if [ $wait -gt 30 ]; then
5032 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
5035 set_inode_slab_tunables "$SLAB_SETTINGS"
5037 run_test 76 "confirm clients recycle inodes properly ===="
5043 # Note: in sptlrpc modes which enable its own bulk checksum, the
5044 # original crc32_le bulk checksum will be automatically disabled,
5045 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
5046 # will be checked by sptlrpc code against sptlrpc bulk checksum.
5047 # In this case set_checksums() will not be no-op, because sptlrpc
5048 # bulk checksum will be enabled all through the test.
5050 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
5051 lctl set_param -n osc.*.checksums $1
5055 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
5056 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
5057 CKSUM_TYPES=${CKSUM_TYPES:-"crc32 adler"}
5058 [ "$ORIG_CSUM_TYPE" = "crc32c" ] && CKSUM_TYPES="$CKSUM_TYPES crc32c"
5061 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
5062 log "set checksum type to $1"
5065 F77_TMP=$TMP/f77-temp
5068 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
5069 error "error writing to $F77_TMP"
5072 test_77a() { # bug 10889
5073 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5074 $GSS && skip "could not run with gss" && return
5075 [ ! -f $F77_TMP ] && setup_f77
5077 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
5081 run_test 77a "normal checksum read/write operation ============="
5083 test_77b() { # bug 10889
5084 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5085 $GSS && skip "could not run with gss" && return
5086 [ ! -f $F77_TMP ] && setup_f77
5087 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5088 lctl set_param fail_loc=0x80000409
5090 dd if=$F77_TMP of=$DIR/f77b bs=1M count=$F77SZ conv=sync || \
5091 error "dd error: $?"
5092 lctl set_param fail_loc=0
5095 run_test 77b "checksum error on client write ===================="
5097 test_77c() { # bug 10889
5098 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5099 $GSS && skip "could not run with gss" && return
5100 [ ! -f $DIR/f77b ] && skip "requires 77b - skipping" && return
5102 for algo in $CKSUM_TYPES; do
5103 cancel_lru_locks osc
5104 set_checksum_type $algo
5105 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
5106 lctl set_param fail_loc=0x80000408
5107 cmp $F77_TMP $DIR/f77b || error "file compare failed"
5108 lctl set_param fail_loc=0
5111 set_checksum_type $ORIG_CSUM_TYPE
5114 run_test 77c "checksum error on client read ==================="
5116 test_77d() { # bug 10889
5117 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5118 $GSS && skip "could not run with gss" && return
5119 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5120 lctl set_param fail_loc=0x80000409
5122 directio write $DIR/f77 0 $F77SZ $((1024 * 1024)) || \
5123 error "direct write: rc=$?"
5124 lctl set_param fail_loc=0
5127 run_test 77d "checksum error on OST direct write ==============="
5129 test_77e() { # bug 10889
5130 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5131 $GSS && skip "could not run with gss" && return
5132 [ ! -f $DIR/f77 ] && skip "requires 77d - skipping" && return
5133 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
5134 lctl set_param fail_loc=0x80000408
5136 cancel_lru_locks osc
5137 directio read $DIR/f77 0 $F77SZ $((1024 * 1024)) || \
5138 error "direct read: rc=$?"
5139 lctl set_param fail_loc=0
5142 run_test 77e "checksum error on OST direct read ================"
5144 test_77f() { # bug 10889
5145 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5146 $GSS && skip "could not run with gss" && return
5148 for algo in $CKSUM_TYPES; do
5149 cancel_lru_locks osc
5150 set_checksum_type $algo
5151 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5152 lctl set_param fail_loc=0x409
5153 directio write $DIR/f77 0 $F77SZ $((1024 * 1024)) && \
5154 error "direct write succeeded"
5155 lctl set_param fail_loc=0
5157 set_checksum_type $ORIG_CSUM_TYPE
5160 run_test 77f "repeat checksum error on write (expect error) ===="
5162 test_77g() { # bug 10889
5163 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5164 $GSS && skip "could not run with gss" && return
5165 remote_ost_nodsh && skip "remote OST with nodsh" && return
5167 [ ! -f $F77_TMP ] && setup_f77
5169 $SETSTRIPE -c 1 -i 0 $DIR/f77g
5170 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
5171 do_facet ost1 lctl set_param fail_loc=0x8000021a
5173 dd if=$F77_TMP of=$DIR/f77g bs=1M count=$F77SZ || \
5174 error "write error: rc=$?"
5175 do_facet ost1 lctl set_param fail_loc=0
5178 run_test 77g "checksum error on OST write ======================"
5180 test_77h() { # bug 10889
5181 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5182 $GSS && skip "could not run with gss" && return
5183 remote_ost_nodsh && skip "remote OST with nodsh" && return
5185 [ ! -f $DIR/f77g ] && skip "requires 77g - skipping" && return
5186 cancel_lru_locks osc
5187 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
5188 do_facet ost1 lctl set_param fail_loc=0x8000021b
5190 cmp $F77_TMP $DIR/f77g || error "file compare failed"
5191 do_facet ost1 lctl set_param fail_loc=0
5194 run_test 77h "checksum error on OST read ======================="
5196 test_77i() { # bug 13805
5197 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5198 $GSS && skip "could not run with gss" && return
5199 #define OBD_FAIL_OSC_CONNECT_CKSUM 0x40b
5200 lctl set_param fail_loc=0x40b
5201 remount_client $MOUNT
5202 lctl set_param fail_loc=0
5203 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
5204 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
5205 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
5206 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
5208 remount_client $MOUNT
5210 run_test 77i "client not supporting OSD_CONNECT_CKSUM =========="
5212 test_77j() { # bug 13805
5213 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5214 $GSS && skip "could not run with gss" && return
5215 #define OBD_FAIL_OSC_CKSUM_ADLER_ONLY 0x40c
5216 lctl set_param fail_loc=0x40c
5217 remount_client $MOUNT
5218 lctl set_param fail_loc=0
5219 sleep 2 # wait async osc connect to finish
5220 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
5221 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
5222 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
5223 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
5225 remount_client $MOUNT
5227 run_test 77j "client only supporting ADLER32 ===================="
5229 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
5233 test_78() { # bug 10901
5234 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5235 remote_ost || { skip_env "local OST" && return; }
5238 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
5239 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
5240 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
5241 echo "MemTotal: $MEMTOTAL"
5242 # reserve 256MB of memory for the kernel and other running processes,
5243 # and then take 1/2 of the remaining memory for the read/write buffers.
5244 if [ $MEMTOTAL -gt 512 ] ;then
5245 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
5247 # for those poor memory-starved high-end clusters...
5248 MEMTOTAL=$((MEMTOTAL / 2))
5250 echo "Mem to use for directio: $MEMTOTAL"
5251 [ $F78SIZE -gt $MEMTOTAL ] && F78SIZE=$MEMTOTAL
5252 [ $F78SIZE -gt 512 ] && F78SIZE=512
5253 [ $F78SIZE -gt $((MAXFREE / 1024)) ] && F78SIZE=$((MAXFREE / 1024))
5254 SMALLESTOST=`lfs df $DIR |grep OST | awk '{print $4}' |sort -n |head -1`
5255 echo "Smallest OST: $SMALLESTOST"
5256 [ $SMALLESTOST -lt 10240 ] && \
5257 skip "too small OSTSIZE, useless to run large O_DIRECT test" && return 0
5259 [ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ] && \
5260 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
5262 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
5263 echo "File size: $F78SIZE"
5264 $SETSTRIPE -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
5265 for i in `seq 1 $NSEQ`
5267 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
5268 echo directIO rdwr round $i of $NSEQ
5269 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
5274 run_test 78 "handle large O_DIRECT writes correctly ============"
5276 test_79() { # bug 12743
5277 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5278 wait_delete_completed
5280 BKTOTAL=$(calc_osc_kbytes kbytestotal)
5281 BKFREE=$(calc_osc_kbytes kbytesfree)
5282 BKAVAIL=$(calc_osc_kbytes kbytesavail)
5284 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
5285 DFTOTAL=`echo $STRING | cut -d, -f1`
5286 DFUSED=`echo $STRING | cut -d, -f2`
5287 DFAVAIL=`echo $STRING | cut -d, -f3`
5288 DFFREE=$(($DFTOTAL - $DFUSED))
5290 ALLOWANCE=$((64 * $OSTCOUNT))
5292 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
5293 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
5294 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
5296 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
5297 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
5298 error "df free($DFFREE) mismatch OST free($BKFREE)"
5300 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
5301 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
5302 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
5305 run_test 79 "df report consistency check ======================="
5307 test_80() { # bug 10718
5308 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5309 # relax strong synchronous semantics for slow backends like ZFS
5310 local soc="obdfilter.*.sync_on_lock_cancel"
5311 local soc_old=$(do_facet ost1 lctl get_param -n $soc | head -n1)
5313 if [ "$soc_old" != "never" -a "$(facet_fstype ost1)" != "ldiskfs" ]; then
5314 hosts=$(for host in $(seq -f "ost%g" 1 $OSTCOUNT); do
5315 facet_active_host $host; done | sort -u)
5316 do_nodes $hosts lctl set_param $soc=never
5319 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
5321 local BEFORE=`date +%s`
5322 cancel_lru_locks osc
5323 local AFTER=`date +%s`
5324 local DIFF=$((AFTER-BEFORE))
5325 if [ $DIFF -gt 1 ] ; then
5326 error "elapsed for 1M@1T = $DIFF"
5329 [ -n "$hosts" ] && do_nodes $hosts lctl set_param $soc=$soc_old
5333 run_test 80 "Page eviction is equally fast at high offsets too ===="
5335 test_81a() { # LU-456
5336 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5337 remote_ost_nodsh && skip "remote OST with nodsh" && return
5338 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
5339 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
5340 do_facet ost1 lctl set_param fail_loc=0x80000228
5342 # write should trigger a retry and success
5343 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
5344 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
5346 if [ $RC -ne 0 ] ; then
5347 error "write should success, but failed for $RC"
5350 run_test 81a "OST should retry write when get -ENOSPC ==============="
5352 test_81b() { # LU-456
5353 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5354 remote_ost_nodsh && skip "remote OST with nodsh" && return
5355 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
5356 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
5357 do_facet ost1 lctl set_param fail_loc=0x228
5359 # write should retry several times and return -ENOSPC finally
5360 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
5361 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
5364 if [ $RC -ne $ENOSPC ] ; then
5365 error "dd should fail for -ENOSPC, but succeed."
5368 run_test 81b "OST should return -ENOSPC when retry still fails ======="
5370 test_82() { # LU-1031
5371 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10
5375 multiop_bg_pause $DIR/$tfile OG${gid1}_g${gid1}c || return 1
5377 multiop_bg_pause $DIR/$tfile O_G${gid2}r10g${gid2}c || return 2
5379 kill -USR1 $MULTIPID2
5381 if [[ `ps h -o comm -p $MULTIPID2` == "" ]]; then
5382 error "First grouplock does not block second one"
5384 echo "Second grouplock blocks first one"
5386 kill -USR1 $MULTIPID1
5390 run_test 82 "Basic grouplock test ==============================="
5393 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && \
5395 test_mkdir -p $DIR/d99cvsroot
5396 chown $RUNAS_ID $DIR/d99cvsroot
5397 local oldPWD=$PWD # bug 13584, use $TMP as working dir
5400 $RUNAS cvs -d $DIR/d99cvsroot init || error
5403 run_test 99a "cvs init ========================================="
5406 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5407 [ ! -d $DIR/d99cvsroot ] && test_99a
5409 # some versions of cvs import exit(1) when asked to import links or
5410 # files they can't read. ignore those files.
5411 TOIGNORE=$(find . -type l -printf '-I %f\n' -o \
5412 ! -perm +4 -printf '-I %f\n')
5413 $RUNAS cvs -d $DIR/d99cvsroot import -m "nomesg" $TOIGNORE \
5414 d99reposname vtag rtag
5416 run_test 99b "cvs import ======================================="
5419 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5420 [ ! -d $DIR/d99cvsroot ] && test_99b
5422 test_mkdir -p $DIR/d99reposname
5423 chown $RUNAS_ID $DIR/d99reposname
5424 $RUNAS cvs -d $DIR/d99cvsroot co d99reposname
5426 run_test 99c "cvs checkout ====================================="
5429 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5430 [ ! -d $DIR/d99cvsroot ] && test_99c
5431 cd $DIR/d99reposname
5433 $RUNAS cvs add -m 'addmsg' foo99
5435 run_test 99d "cvs add =========================================="
5438 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5439 [ ! -d $DIR/d99cvsroot ] && test_99c
5440 cd $DIR/d99reposname
5443 run_test 99e "cvs update ======================================="
5446 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5447 [ ! -d $DIR/d99cvsroot ] && test_99d
5448 cd $DIR/d99reposname
5449 $RUNAS cvs commit -m 'nomsg' foo99
5450 rm -fr $DIR/d99cvsroot
5452 run_test 99f "cvs commit ======================================="
5455 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5456 [ "$NETTYPE" = tcp ] || \
5457 { skip "TCP secure port test, not useful for NETTYPE=$NETTYPE" && \
5460 remote_ost_nodsh && skip "remote OST with nodsh" && return
5461 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5463 { skip "useless for local single node setup" && return; }
5465 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
5466 [ "$PROT" != "tcp" ] && continue
5467 RPORT=$(echo $REMOTE | cut -d: -f2)
5468 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
5471 LPORT=`echo $LOCAL | cut -d: -f2`
5472 if [ $LPORT -ge 1024 ]; then
5473 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
5475 error_exit "local: $LPORT > 1024, remote: $RPORT"
5478 [ "$rc" = 0 ] || error_exit "privileged port not found" )
5480 run_test 100 "check local port using privileged port ==========="
5482 function get_named_value()
5491 echo $line | sed "s/^$tag[ ]*//"
5498 export CACHE_MAX=$($LCTL get_param -n llite.*.max_cached_mb |
5499 awk '/^max_cached_mb/ { print $2 }')
5502 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
5507 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5511 local cache_limit=32
5513 $LCTL set_param -n osc.*-osc*.rpc_stats 0
5514 trap cleanup_101a EXIT
5515 $LCTL set_param -n llite.*.read_ahead_stats 0
5516 $LCTL set_param -n llite.*.max_cached_mb $cache_limit
5519 # randomly read 10000 of 64K chunks from file 3x 32MB in size
5521 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
5522 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
5525 for s in `$LCTL get_param -n llite.*.read_ahead_stats | \
5526 get_named_value 'read but discarded' | cut -d" " -f1`; do
5527 discard=$(($discard + $s))
5531 if [ $(($discard * 10)) -gt $nreads ] ;then
5532 $LCTL get_param osc.*-osc*.rpc_stats
5533 $LCTL get_param llite.*.read_ahead_stats
5534 error "too many ($discard) discarded pages"
5536 rm -f $DIR/$tfile || true
5538 run_test 101a "check read-ahead for random reads ================"
5541 test_mkdir -p $DIR/$tdir
5543 STRIPE_COUNT=$OSTCOUNT
5546 local list=$(comma_list $(osts_nodes))
5547 set_osd_param $list '' read_cache_enable 0
5548 set_osd_param $list '' writethrough_cache_enable 0
5550 trap cleanup_test101bc EXIT
5551 # prepare the read-ahead file
5552 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
5554 dd if=/dev/zero of=$DIR/$tfile bs=1024k count=100 2> /dev/null
5557 cleanup_test101bc() {
5562 local list=$(comma_list $(osts_nodes))
5563 set_osd_param $list '' read_cache_enable 1
5564 set_osd_param $list '' writethrough_cache_enable 1
5568 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
5573 local STRIPE_SIZE=1048576
5574 local RA_INC=1048576
5575 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
5576 local FILE_LENGTH=$((64*100))
5577 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
5578 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
5579 DISCARD=`$LCTL get_param -n llite.*.read_ahead_stats | \
5580 get_named_value 'read but discarded' | \
5581 cut -d" " -f1 | calc_total`
5582 if [ $DISCARD -gt $discard_limit ]; then
5583 $LCTL get_param llite.*.read_ahead_stats
5584 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
5586 echo "Read-ahead success for size ${READ_SIZE}"
5591 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5592 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping stride IO stride-ahead test" && return
5593 local STRIPE_SIZE=1048576
5594 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
5595 local FILE_LENGTH=$((STRIPE_SIZE*100))
5596 local ITERATION=$((FILE_LENGTH/STRIDE_SIZE))
5597 # prepare the read-ahead file
5599 cancel_lru_locks osc
5600 for BIDX in 2 4 8 16 32 64 128 256
5602 local BSIZE=$((BIDX*4096))
5603 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
5604 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
5605 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
5606 $LCTL set_param -n llite.*.read_ahead_stats 0
5607 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
5608 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
5609 cancel_lru_locks osc
5615 run_test 101b "check stride-io mode read-ahead ================="
5618 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5619 local STRIPE_SIZE=1048576
5620 local FILE_LENGTH=$((STRIPE_SIZE*100))
5626 cancel_lru_locks osc
5627 $LCTL set_param osc.*.rpc_stats 0
5628 $READS -f $DIR/$tfile -s$FILE_LENGTH -b65536 -n$nreads -t 180
5629 for osc in $($LCTL get_param -N osc.*); do
5630 if [ "$osc" == "osc.num_refs" ]; then
5634 local lines=$($LCTL get_param -n ${osc}.rpc_stats | wc | awk '{print $1}')
5635 if [ $lines -le 20 ]; then
5639 local rpc4k=$($LCTL get_param -n ${osc}.rpc_stats |
5640 awk '$1 == "1:" { print $2; exit; }')
5641 local rpc8k=$($LCTL get_param -n ${osc}.rpc_stats |
5642 awk '$1 == "2:" { print $2; exit; }')
5643 local rpc16k=$($LCTL get_param -n ${osc}.rpc_stats |
5644 awk '$1 == "4:" { print $2; exit; }')
5645 local rpc32k=$($LCTL get_param -n ${osc}.rpc_stats |
5646 awk '$1 == "8:" { print $2; exit; }')
5648 [ $rpc4k != 0 ] && error "Small 4k read IO ${rpc4k}!"
5649 [ $rpc8k != 0 ] && error "Small 8k read IO ${rpc8k}!"
5650 [ $rpc16k != 0 ] && error "Small 16k read IO ${rpc16k}!"
5651 [ $rpc32k != 0 ] && error "Small 32k read IO ${rpc32k}!"
5652 echo "${osc} rpc check passed!"
5657 run_test 101c "check stripe_size aligned read-ahead ================="
5660 $LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1
5661 $LCTL set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
5665 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5666 local file=$DIR/$tfile
5667 local size=${FILESIZE_101c:-500}
5668 local ra_MB=${READAHEAD_MB:-40}
5670 local space=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
5671 [ $space -gt $((size * 1024)) ] ||
5672 { skip "Need free space ${size}M, have $space" && return; }
5674 echo Creating ${size}M test file $file
5675 dd if=/dev/zero of=$file bs=1M count=$size || error "dd failed"
5676 echo Cancel LRU locks on lustre client to flush the client cache
5677 cancel_lru_locks osc
5679 echo Disable read-ahead
5680 local old_READAHEAD=$(set_read_ahead 0)
5682 echo Reading the test file $file with read-ahead disabled
5683 time_ra_OFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$size")
5685 echo Cancel LRU locks on lustre client to flush the client cache
5686 cancel_lru_locks osc
5687 echo Enable read-ahead with ${ra_MB}MB
5688 set_read_ahead $ra_MB
5690 echo Reading the test file $file with read-ahead enabled
5691 time_ra_ON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$size")
5693 echo read-ahead disabled time read $time_ra_OFF
5694 echo read-ahead enabled time read $time_ra_ON
5696 set_read_ahead $old_READAHEAD
5698 wait_delete_completed
5700 [ $time_ra_ON -lt $time_ra_OFF ] ||
5701 error "read-ahead enabled time read (${time_ra_ON}s) is more than
5702 read-ahead disabled time read (${time_ra_OFF}s) filesize ${size}M"
5704 run_test 101d "file read with and without read-ahead enabled ================="
5707 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5708 local file=$DIR/$tfile
5713 local space=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
5714 local need_space=$((count * size))
5715 [ $space -gt $need_space ] ||
5716 { skip_env "Need free space $need_space, have $space" && return; }
5718 echo Creating $count ${size}K test files
5719 for ((i = 0; i < $count; i++)); do
5720 dd if=/dev/zero of=${file}_${i} bs=$blksize count=$size 2>/dev/null
5723 echo Cancel LRU locks on lustre client to flush the client cache
5724 cancel_lru_locks osc
5726 echo Reset readahead stats
5727 $LCTL set_param -n llite.*.read_ahead_stats 0
5729 for ((i = 0; i < $count; i++)); do
5730 dd if=${file}_${i} of=/dev/null bs=$blksize count=$size 2>/dev/null
5733 local miss=$($LCTL get_param -n llite.*.read_ahead_stats | \
5734 get_named_value 'misses' | cut -d" " -f1 | calc_total)
5736 for ((i = 0; i < $count; i++)); do
5737 rm -rf ${file}_${i} 2>/dev/null
5740 #10000 means 20% reads are missing in readahead
5741 [ $miss -lt 10000 ] || error "misses too much for small reads"
5743 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
5745 cleanup_test101f() {
5747 $LCTL set_param -n llite.*.max_read_ahead_whole_mb $MAX_WHOLE_MB
5748 rm -rf $DIR/$tfile 2>/dev/null
5752 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5753 local file=$DIR/$tfile
5756 MAX_WHOLE_MB=$($LCTL get_param -n llite.*.max_read_ahead_whole_mb)
5757 $LCTL set_param -n llite.*.max_read_ahead_whole_mb 2
5758 dd if=/dev/zero of=${file} bs=2097152 count=1 2>/dev/null
5759 trap cleanup_test101f EXIT
5761 echo Cancel LRU locks on lustre client to flush the client cache
5762 cancel_lru_locks osc
5764 echo Reset readahead stats
5765 $LCTL set_param -n llite.*.read_ahead_stats 0
5766 # Random read in a 2M file, because max_read_ahead_whole_mb = 2M,
5767 # readahead should read in 2M file on second read, so only miss
5769 echo Random 4K reads on 2M file for 1000 times
5770 $READS -f $file -s 2097152 -b 4096 -n $nreads
5772 echo checking missing pages
5773 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
5774 get_named_value 'misses' | cut -d" " -f1 | calc_total)
5776 [ $miss -lt 3 ] || error "misses too much pages!"
5779 run_test 101f "check read-ahead for max_read_ahead_whole_mb"
5782 test_mkdir -p $DIR/$tdir
5783 chown $RUNAS_ID $DIR/$tdir
5786 STRIPE_COUNT=$OSTCOUNT
5787 [ $OSTCOUNT -gt 4 ] && STRIPE_COUNT=4
5789 trap cleanup_test102 EXIT
5791 $1 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
5793 for num in 1 2 3 4; do
5794 for count in $(seq 1 $STRIPE_COUNT); do
5795 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
5796 local size=`expr $STRIPE_SIZE \* $num`
5797 local file=file"$num-$idx-$count"
5798 $1 $SETSTRIPE -S $size -i $idx -c $count $file
5804 $1 $TAR cf $TMP/f102.tar $tdir --xattrs
5810 rm -rf $DIR/d0.sanity/d102
5814 local testfile=$DIR/xattr_testfile
5818 [ "$UID" != 0 ] && skip_env "must run as root" && return
5819 [ -z "`lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr`" ] &&
5820 skip_env "must have user_xattr" && return
5822 [ -z "$(which setfattr 2>/dev/null)" ] &&
5823 skip_env "could not find setfattr" && return
5825 echo "set/get xattr..."
5826 setfattr -n trusted.name1 -v value1 $testfile || error
5827 getfattr -n trusted.name1 $testfile 2> /dev/null |
5828 grep "trusted.name1=.value1" ||
5829 error "$testfile missing trusted.name1=value1"
5831 setfattr -n user.author1 -v author1 $testfile || error
5832 getfattr -n user.author1 $testfile 2> /dev/null |
5833 grep "user.author1=.author1" ||
5834 error "$testfile missing trusted.author1=author1"
5837 setfattr -n trusted.name2 -v value2 $testfile ||
5838 error "$testfile unable to set trusted.name2"
5839 setfattr -n trusted.name3 -v value3 $testfile ||
5840 error "$testfile unable to set trusted.name3"
5841 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
5842 grep "trusted.name" | wc -l) -eq 3 ] ||
5843 error "$testfile missing 3 trusted.name xattrs"
5845 setfattr -n user.author2 -v author2 $testfile ||
5846 error "$testfile unable to set user.author2"
5847 setfattr -n user.author3 -v author3 $testfile ||
5848 error "$testfile unable to set user.author3"
5849 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
5850 grep "user.author" | wc -l) -eq 3 ] ||
5851 error "$testfile missing 3 user.author xattrs"
5853 echo "remove xattr..."
5854 setfattr -x trusted.name1 $testfile ||
5855 error "$testfile error deleting trusted.name1"
5856 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
5857 error "$testfile did not delete trusted.name1 xattr"
5859 setfattr -x user.author1 $testfile ||
5860 error "$testfile error deleting user.author1"
5861 getfattr -d -m user $testfile 2> /dev/null | grep "user.author1" &&
5862 error "$testfile did not delete trusted.name1 xattr"
5864 # b10667: setting lustre special xattr be silently discarded
5865 echo "set lustre special xattr ..."
5866 setfattr -n "trusted.lov" -v "invalid value" $testfile ||
5867 error "$testfile allowed setting trusted.lov"
5869 run_test 102a "user xattr test =================================="
5872 # b10930: get/set/list trusted.lov xattr
5873 echo "get/set/list trusted.lov xattr ..."
5874 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
5875 local testfile=$DIR/$tfile
5876 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
5877 error "setstripe failed"
5878 local STRIPECOUNT=$($GETSTRIPE -c $testfile) ||
5879 error "getstripe failed"
5880 getfattr -d -m "^trusted" $testfile 2> /dev/null | \
5881 grep "trusted.lov" || error "can't get trusted.lov from $testfile"
5883 local testfile2=${testfile}2
5884 local value=`getfattr -n trusted.lov $testfile 2> /dev/null | \
5885 grep "trusted.lov" |sed -e 's/[^=]\+=//'`
5888 setfattr -n trusted.lov -v $value $testfile2
5889 local stripe_size=$($GETSTRIPE -S $testfile2)
5890 local stripe_count=$($GETSTRIPE -c $testfile2)
5891 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
5892 [ $stripe_count -eq $STRIPECOUNT ] ||
5893 error "stripe count $stripe_count != $STRIPECOUNT"
5896 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
5899 # b10930: get/set/list lustre.lov xattr
5900 echo "get/set/list lustre.lov xattr ..."
5901 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
5902 test_mkdir -p $DIR/$tdir
5903 chown $RUNAS_ID $DIR/$tdir
5904 local testfile=$DIR/$tdir/$tfile
5905 $RUNAS $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
5906 error "setstripe failed"
5907 local STRIPECOUNT=$($RUNAS $GETSTRIPE -c $testfile) ||
5908 error "getstripe failed"
5909 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
5910 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
5912 local testfile2=${testfile}2
5913 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
5914 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
5916 $RUNAS $MCREATE $testfile2
5917 $RUNAS setfattr -n lustre.lov -v $value $testfile2
5918 local stripe_size=$($RUNAS $GETSTRIPE -S $testfile2)
5919 local stripe_count=$($RUNAS $GETSTRIPE -c $testfile2)
5920 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
5921 [ $stripe_count -eq $STRIPECOUNT ] ||
5922 error "stripe count $stripe_count != $STRIPECOUNT"
5924 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
5926 compare_stripe_info1() {
5927 local stripe_index_all_zero=true
5929 for num in 1 2 3 4; do
5930 for count in $(seq 1 $STRIPE_COUNT); do
5931 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
5932 local size=$((STRIPE_SIZE * num))
5933 local file=file"$num-$offset-$count"
5934 stripe_size=$(lfs getstripe -S $PWD/$file)
5935 [ $stripe_size -ne $size ] &&
5936 error "$file: size $stripe_size != $size"
5937 stripe_count=$(lfs getstripe -c $PWD/$file)
5938 # allow fewer stripes to be created, ORI-601
5939 [ $stripe_count -lt $(((3 * count + 3) / 4)) ]&&
5940 error "$file: count $stripe_count != $count"
5941 stripe_index=$(lfs getstripe -i $PWD/$file)
5942 [ $stripe_index -ne 0 ] &&
5943 stripe_index_all_zero=false
5947 $stripe_index_all_zero &&
5948 error "all files are being extracted starting from OST index 0"
5953 [ -n "$(which tar 2>/dev/null)" ] &&
5954 strings $(which tar) | grep -q "lustre" && echo tar
5958 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5959 # b10930: tar test for trusted.lov xattr
5960 TAR=$(find_lustre_tar)
5961 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
5962 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
5964 test_mkdir -p $DIR/d102d
5965 $TAR xf $TMP/f102.tar -C $DIR/d102d --xattrs
5967 compare_stripe_info1
5969 run_test 102d "tar restore stripe info from tarfile,not keep osts ==========="
5972 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5973 # b10930: tar test for trusted.lov xattr
5974 TAR=$(find_lustre_tar)
5975 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
5976 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
5978 test_mkdir -p $DIR/d102f
5980 $TAR cf - --xattrs $tdir | $TAR xf - --xattrs -C $DIR/d102f
5982 compare_stripe_info1
5984 run_test 102f "tar copy files, not keep osts ==========="
5987 local xsize=${1:-1024} # in bytes
5988 local file=$DIR/$tfile
5990 [ -z $(lctl get_param -n mdc.*.connect_flags | grep xattr) ] &&
5991 skip "must have user_xattr" && return 0
5992 [ -z "$(which setfattr 2>/dev/null)" ] &&
5993 skip_env "could not find setfattr" && return 0
5994 [ -z "$(which getfattr 2>/dev/null)" ] &&
5995 skip_env "could not find getfattr" && return 0
5999 local value="$(generate_string $xsize)"
6001 local xbig=trusted.big
6002 log "save $xbig on $file"
6003 setfattr -n $xbig -v $value $file ||
6004 error "saving $xbig on $file failed"
6006 local orig=$(get_xattr_value $xbig $file)
6007 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
6009 local xsml=trusted.sml
6010 log "save $xsml on $file"
6011 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
6013 local new=$(get_xattr_value $xbig $file)
6014 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
6016 log "grow $xsml on $file"
6017 setfattr -n $xsml -v "$value" $file ||
6018 error "growing $xsml on $file failed"
6020 new=$(get_xattr_value $xbig $file)
6021 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
6022 log "$xbig still valid after growing $xsml"
6027 test_102h() { # bug 15777
6030 run_test 102h "grow xattr from inside inode to external block"
6033 large_xattr_enabled || { skip "large_xattr disabled" && return; }
6034 grow_xattr $(max_xattr_size)
6036 run_test 102ha "grow xattr from inside inode to external inode"
6038 test_102i() { # bug 17038
6040 ln -s $DIR/$tfile $DIR/${tfile}link
6041 getfattr -n trusted.lov $DIR/$tfile || error "lgetxattr on $DIR/$tfile failed"
6042 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"
6043 rm -f $DIR/$tfile $DIR/${tfile}link
6045 run_test 102i "lgetxattr test on symbolic link ============"
6048 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6049 TAR=$(find_lustre_tar)
6050 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6051 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
6052 setup_test102 "$RUNAS"
6053 test_mkdir -p $DIR/d102j
6054 chown $RUNAS_ID $DIR/d102j
6055 $RUNAS $TAR xf $TMP/f102.tar -C $DIR/d102j --xattrs
6057 compare_stripe_info1 "$RUNAS"
6059 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
6063 # b22187 just check that does not crash for regular file.
6064 setfattr -n trusted.lov $DIR/$tfile
6065 # b22187 'setfattr -n trusted.lov' should work as remove LOV EA for directories
6066 local test_kdir=$DIR/d102k
6067 test_mkdir $test_kdir
6068 local default_size=`$GETSTRIPE -S $test_kdir`
6069 local default_count=`$GETSTRIPE -c $test_kdir`
6070 local default_offset=`$GETSTRIPE -i $test_kdir`
6071 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $test_kdir ||
6072 error 'dir setstripe failed'
6073 setfattr -n trusted.lov $test_kdir
6074 local stripe_size=`$GETSTRIPE -S $test_kdir`
6075 local stripe_count=`$GETSTRIPE -c $test_kdir`
6076 local stripe_offset=`$GETSTRIPE -i $test_kdir`
6077 [ $stripe_size -eq $default_size ] ||
6078 error "stripe size $stripe_size != $default_size"
6079 [ $stripe_count -eq $default_count ] ||
6080 error "stripe count $stripe_count != $default_count"
6081 [ $stripe_offset -eq $default_offset ] ||
6082 error "stripe offset $stripe_offset != $default_offset"
6083 rm -rf $DIR/$tfile $test_kdir
6085 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
6088 # LU-532 trusted. xattr is invisible to non-root
6089 local testfile=$DIR/$tfile
6093 echo "listxattr as user..."
6094 chown $RUNAS_ID $testfile
6095 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
6096 grep -q "trusted" &&
6097 error "$testfile trusted xattrs are user visible"
6101 run_test 102l "listxattr filter test =================================="
6107 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
6112 [ "$UID" != 0 ] && skip_env "must run as root" && return
6113 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
6114 [ -z "$(which setfacl 2>/dev/null)" ] && skip_env "could not find setfacl" && return
6115 $GSS && skip "could not run under gss" && return
6117 declare -a identity_old
6119 for num in $(seq $MDSCOUNT); do
6120 switch_identity $num true || identity_old[$num]=$?
6127 echo "performing cp ..."
6128 run_acl_subtest cp || error
6129 echo "performing getfacl-noacl..."
6130 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
6131 echo "performing misc..."
6132 run_acl_subtest misc || error "misc test failed"
6133 echo "performing permissions..."
6134 run_acl_subtest permissions || error "permissions failed"
6135 echo "performing setfacl..."
6136 run_acl_subtest setfacl || error "setfacl test failed"
6138 # inheritance test got from HP
6139 echo "performing inheritance..."
6140 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
6141 chmod +x make-tree || error "chmod +x failed"
6142 run_acl_subtest inheritance || error "inheritance test failed"
6145 echo "LU-974 ignore umask when acl is enabled..."
6146 run_acl_subtest 974 || error "LU-974 test failed"
6148 echo "LU-2561 newly created file is same size as directory..."
6149 run_acl_subtest 2561 || error "LU-2561 test failed"
6154 for num in $(seq $MDSCOUNT); do
6155 if [ "${identity_old[$num]}" = 1 ]; then
6156 switch_identity $num false || identity_old[$num]=$?
6160 run_test 103 "acl test ========================================="
6163 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6165 lfs df || error "lfs df failed"
6166 lfs df -ih || error "lfs df -ih failed"
6167 lfs df -h $DIR || error "lfs df -h $DIR failed"
6168 lfs df -i $DIR || error "lfs df -i $DIR failed"
6169 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
6170 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
6172 OSC=`lctl dl |grep OST0000-osc-[^M] |awk '{print $4}'`
6173 lctl --device %$OSC deactivate
6174 lfs df || error "lfs df with deactivated OSC failed"
6175 lctl --device %$OSC activate
6176 # wait the osc back to normal
6177 wait_osc_import_state client ost FULL
6179 lfs df || error "lfs df with reactivated OSC failed"
6182 run_test 104a "lfs df [-ih] [path] test ========================="
6185 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6186 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
6188 denied_cnt=$((`$RUNAS $LFS check servers 2>&1 | grep "Permission denied" | wc -l`))
6189 if [ $denied_cnt -ne 0 ];
6191 error "lfs check servers test failed"
6194 run_test 104b "$RUNAS lfs check servers test ===================="
6197 # doesn't work on 2.4 kernels
6199 if [ -n "`mount | grep \"$MOUNT.*flock\" | grep -v noflock`" ]; then
6200 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
6202 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
6206 run_test 105a "flock when mounted without -o flock test ========"
6210 if [ -n "`mount | grep \"$MOUNT.*flock\" | grep -v noflock`" ]; then
6211 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
6213 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
6217 run_test 105b "fcntl when mounted without -o flock test ========"
6221 if [ -n "`mount | grep \"$MOUNT.*flock\" | grep -v noflock`" ]; then
6222 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
6224 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
6228 run_test 105c "lockf when mounted without -o flock test ========"
6230 test_105d() { # bug 15924
6231 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6232 test_mkdir -p $DIR/$tdir
6233 [ -z "`mount | grep \"$MOUNT.*flock\" | grep -v noflock`" ] && \
6234 skip "mount w/o flock enabled" && return
6235 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
6236 $LCTL set_param fail_loc=0x80000315
6237 flocks_test 2 $DIR/$tdir
6239 run_test 105d "flock race (should not freeze) ========"
6241 test_105e() { # bug 22660 && 22040
6242 [ -z "`mount | grep \"$MOUNT.*flock\" | grep -v noflock`" ] && \
6243 skip "mount w/o flock enabled" && return
6245 flocks_test 3 $DIR/$tfile
6247 run_test 105e "Two conflicting flocks from same process ======="
6249 test_106() { #bug 10921
6250 test_mkdir -p $DIR/$tdir
6251 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
6252 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
6254 run_test 106 "attempt exec of dir followed by chown of that dir"
6257 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6264 local save_pattern=$(sysctl -n kernel.core_pattern)
6265 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
6266 sysctl -w kernel.core_pattern=$file
6267 sysctl -w kernel.core_uses_pid=0
6275 kill -s 11 $SLEEPPID
6277 if [ -e $file ]; then
6278 size=`stat -c%s $file`
6279 [ $size -eq 0 ] && error "Fail to create core file $file"
6281 error "Fail to create core file $file"
6284 sysctl -w kernel.core_pattern=$save_pattern
6285 sysctl -w kernel.core_uses_pid=$save_uses_pid
6288 run_test 107 "Coredump on SIG"
6291 test_mkdir -p $DIR/$tdir
6292 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255) ||
6293 error "mkdir with 255 char failed"
6294 test_mkdir $DIR/$tdir/$(str_repeat 'b' 256) &&
6295 error "mkdir with 256 char should fail, but did not"
6296 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
6297 error "create with 255 char failed"
6298 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
6299 error "create with 256 char should fail, but did not"
6304 run_test 110 "filename length checking"
6307 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6308 OSTIO_pre=$(ps -e|grep ll_ost_io|awk '{print $4}'|sort -n|tail -1|\
6310 [ -z "$OSTIO_pre" ] && skip "no OSS threads" && \
6312 echo "Starting with $OSTIO_pre threads"
6315 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
6316 [ $NUMFREE -lt $NUMTEST ] && NUMTEST=$(($NUMFREE - 1000))
6317 echo "$NUMTEST creates/unlinks"
6318 test_mkdir -p $DIR/$tdir
6319 createmany -o $DIR/$tdir/$tfile $NUMTEST
6320 unlinkmany $DIR/$tdir/$tfile $NUMTEST
6322 OSTIO_post=$(ps -e|grep ll_ost_io|awk '{print $4}'|sort -n|tail -1|\
6325 # don't return an error
6326 [ $OSTIO_post == $OSTIO_pre ] && echo \
6327 "WARNING: No new ll_ost_io threads were created ($OSTIO_pre)" &&
6328 echo "This may be fine, depending on what ran before this test" &&
6329 echo "and how fast this system is." && return
6331 echo "Started with $OSTIO_pre threads, ended with $OSTIO_post"
6333 run_test 115 "verify dynamic thread creation===================="
6336 wait_delete_completed
6337 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
6338 echo OST kbytes available: ${AVAIL[@]}
6339 MAXI=0; MAXV=${AVAIL[0]}
6340 MINI=0; MINV=${AVAIL[0]}
6341 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
6342 #echo OST $i: ${AVAIL[i]}kb
6343 if [ ${AVAIL[i]} -gt $MAXV ]; then
6344 MAXV=${AVAIL[i]}; MAXI=$i
6346 if [ ${AVAIL[i]} -lt $MINV ]; then
6347 MINV=${AVAIL[i]}; MINI=$i
6350 echo Min free space: OST $MINI: $MINV
6351 echo Max free space: OST $MAXI: $MAXV
6354 test_116a() { # was previously test_116()
6355 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6356 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs" && return
6358 echo -n "Free space priority "
6359 lctl get_param -n lov.*-clilov-*.qos_prio_free
6362 [ $MINV -gt 960000 ] && skip "too much free space in OST$MINI, skip" &&\
6365 # generate uneven OSTs
6366 test_mkdir -p $DIR/$tdir/OST${MINI}
6369 echo "Filling 25% remaining space in OST${MINI} with ${FILL}Kb"
6370 $SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI}||error "setstripe failed"
6372 while [ $FILL -gt 0 ]; do
6374 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i bs=2M count=1 2>/dev/null
6375 FILL=$(($FILL - 2048))
6383 DIFF=$(($MAXV - $MINV))
6384 DIFF2=$(($DIFF * 100 / $MINV))
6385 echo -n "diff=${DIFF}=${DIFF2}% must be > 20% for QOS mode..."
6386 if [ $DIFF2 -gt 20 ]; then
6389 echo "failed - QOS mode won't be used"
6390 error_ignore "QOS imbalance criteria not met"
6394 MINI1=$MINI; MINV1=$MINV
6395 MAXI1=$MAXI; MAXV1=$MAXV
6397 # now fill using QOS
6398 echo writing a bunch of files to QOS-assigned OSTs
6399 $SETSTRIPE -c 1 $DIR/$tdir
6401 while [ $FILL -gt 0 ]; do
6403 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1024 count=200 2>/dev/null
6404 FILL=$(($FILL - 200))
6407 echo "wrote $i 200k files"
6411 echo "Note: free space may not be updated, so measurements might be off"
6413 DIFF2=$(($MAXV - $MINV))
6414 echo "free space delta: orig $DIFF final $DIFF2"
6415 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
6416 DIFF=$(($MINV1 - ${AVAIL[$MINI1]}))
6417 echo "Wrote $DIFF to smaller OST $MINI1"
6418 DIFF2=$(($MAXV1 - ${AVAIL[$MAXI1]}))
6419 echo "Wrote $DIFF2 to larger OST $MAXI1"
6420 [ $DIFF -gt 0 ] && echo "Wrote $(($DIFF2 * 100 / $DIFF - 100))% more data to larger OST $MAXI1"
6422 # Figure out which files were written where
6423 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
6424 awk '/'$MINI1': / {print $2; exit}')
6426 MINC=$($GETSTRIPE --obd $UUID $DIR/$tdir | wc -l)
6427 echo "$MINC files created on smaller OST $MINI1"
6428 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
6429 awk '/'$MAXI1': / {print $2; exit}')
6431 MAXC=$($GETSTRIPE --obd $UUID $DIR/$tdir | wc -l)
6432 echo "$MAXC files created on larger OST $MAXI1"
6433 [ $MINC -gt 0 ] && echo "Wrote $(($MAXC * 100 / $MINC - 100))% more files to larger OST $MAXI1"
6434 [ $MAXC -gt $MINC ] || error_ignore "stripe QOS didn't balance free space"
6438 run_test 116a "stripe QOS: free space balance ==================="
6440 test_116b() { # LU-2093
6441 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6442 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
6444 old_rr=$(do_facet $SINGLEMDS lctl get_param -n lov.*mdtlov*.qos_threshold_rr)
6445 do_facet $SINGLEMDS lctl set_param lov.*mdtlov*.qos_threshold_rr 0
6447 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
6448 createmany -o $DIR/$tdir/f- 20 || error "can't create"
6449 do_facet $SINGLEMDS lctl set_param fail_loc=0
6451 do_facet $SINGLEMDS lctl set_param lov.*mdtlov*.qos_threshold_rr $old_rr
6453 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
6455 test_117() # bug 10891
6457 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6458 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
6459 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
6460 lctl set_param fail_loc=0x21e
6461 > $DIR/$tfile || error "truncate failed"
6462 lctl set_param fail_loc=0
6463 echo "Truncate succeeded."
6466 run_test 117 "verify fsfilt_extend =========="
6468 NO_SLOW_RESENDCOUNT=4
6469 export OLD_RESENDCOUNT=""
6470 set_resend_count () {
6471 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
6472 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -1)
6473 lctl set_param -n $PROC_RESENDCOUNT $1
6474 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
6477 # for reduce test_118* time (b=14842)
6478 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
6480 # Reset async IO behavior after error case
6482 FILE=$DIR/reset_async
6484 # Ensure all OSCs are cleared
6485 $SETSTRIPE -c -1 $FILE
6486 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
6491 test_118a() #bug 11710
6493 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6496 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6497 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6498 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
6500 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6501 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6506 run_test 118a "verify O_SYNC works =========="
6510 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6511 remote_ost_nodsh && skip "remote OST with nodsh" && return
6515 #define OBD_FAIL_OST_ENOENT 0x217
6516 set_nodes_failloc "$(osts_nodes)" 0x217
6517 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6519 set_nodes_failloc "$(osts_nodes)" 0
6520 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6521 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6524 if [[ $RC -eq 0 ]]; then
6525 error "Must return error due to dropped pages, rc=$RC"
6529 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6530 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6534 echo "Dirty pages not leaked on ENOENT"
6536 # Due to the above error the OSC will issue all RPCs syncronously
6537 # until a subsequent RPC completes successfully without error.
6538 $MULTIOP $DIR/$tfile Ow4096yc
6543 run_test 118b "Reclaim dirty pages on fatal error =========="
6547 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6549 # for 118c, restore the original resend count, LU-1940
6550 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
6551 set_resend_count $OLD_RESENDCOUNT
6552 remote_ost_nodsh && skip "remote OST with nodsh" && return
6556 #define OBD_FAIL_OST_EROFS 0x216
6557 set_nodes_failloc "$(osts_nodes)" 0x216
6559 # multiop should block due to fsync until pages are written
6560 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
6564 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
6565 error "Multiop failed to block on fsync, pid=$MULTIPID"
6568 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6570 if [[ $WRITEBACK -eq 0 ]]; then
6571 error "No page in writeback, writeback=$WRITEBACK"
6574 set_nodes_failloc "$(osts_nodes)" 0
6577 if [[ $RC -ne 0 ]]; then
6578 error "Multiop fsync failed, rc=$RC"
6581 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6582 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6584 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6585 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6589 echo "Dirty pages flushed via fsync on EROFS"
6592 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
6594 # continue to use small resend count to reduce test_118* time (b=14842)
6595 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
6599 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6600 remote_ost_nodsh && skip "remote OST with nodsh" && return
6604 #define OBD_FAIL_OST_BRW_PAUSE_BULK
6605 set_nodes_failloc "$(osts_nodes)" 0x214
6606 # multiop should block due to fsync until pages are written
6607 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
6611 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
6612 error "Multiop failed to block on fsync, pid=$MULTIPID"
6615 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6617 if [[ $WRITEBACK -eq 0 ]]; then
6618 error "No page in writeback, writeback=$WRITEBACK"
6621 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
6622 set_nodes_failloc "$(osts_nodes)" 0
6624 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6625 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
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 gaurenteed flushed via fsync"
6635 run_test 118d "Fsync validation inject a delay of the bulk =========="
6638 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6641 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
6642 lctl set_param fail_loc=0x8000040a
6644 # Should simulate EINVAL error which is fatal
6645 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6647 if [[ $RC -eq 0 ]]; then
6648 error "Must return error due to dropped pages, rc=$RC"
6651 lctl set_param fail_loc=0x0
6653 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6654 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6655 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6657 if [[ $LOCKED -ne 0 ]]; then
6658 error "Locked pages remain in cache, locked=$LOCKED"
6661 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6662 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6666 echo "No pages locked after fsync"
6671 run_test 118f "Simulate unrecoverable OSC side error =========="
6674 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6677 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
6678 lctl set_param fail_loc=0x406
6680 # simulate local -ENOMEM
6681 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6684 lctl set_param fail_loc=0
6685 if [[ $RC -eq 0 ]]; then
6686 error "Must return error due to dropped pages, rc=$RC"
6689 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6690 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6691 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6693 if [[ $LOCKED -ne 0 ]]; then
6694 error "Locked pages remain in cache, locked=$LOCKED"
6697 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6698 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6702 echo "No pages locked after fsync"
6707 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
6710 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6711 remote_ost_nodsh && skip "remote OST with nodsh" && return
6715 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
6716 set_nodes_failloc "$(osts_nodes)" 0x20e
6717 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
6718 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6721 set_nodes_failloc "$(osts_nodes)" 0
6722 if [[ $RC -eq 0 ]]; then
6723 error "Must return error due to dropped pages, rc=$RC"
6726 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6727 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6728 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6730 if [[ $LOCKED -ne 0 ]]; then
6731 error "Locked pages remain in cache, locked=$LOCKED"
6734 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6735 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6739 echo "No pages locked after fsync"
6743 run_test 118h "Verify timeout in handling recoverables errors =========="
6745 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
6748 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6749 remote_ost_nodsh && skip "remote OST with nodsh" && return
6753 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
6754 set_nodes_failloc "$(osts_nodes)" 0x20e
6756 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
6757 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
6760 set_nodes_failloc "$(osts_nodes)" 0
6764 if [[ $RC -ne 0 ]]; then
6765 error "got error, but should be not, rc=$RC"
6768 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6769 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6770 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
6771 if [[ $LOCKED -ne 0 ]]; then
6772 error "Locked pages remain in cache, locked=$LOCKED"
6775 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6776 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6780 echo "No pages locked after fsync"
6784 run_test 118i "Fix error before timeout in recoverable error =========="
6786 [ "$SLOW" = "no" ] && set_resend_count 4
6789 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6790 remote_ost_nodsh && skip "remote OST with nodsh" && return
6794 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
6795 set_nodes_failloc "$(osts_nodes)" 0x220
6797 # return -EIO from OST
6798 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6800 set_nodes_failloc "$(osts_nodes)" 0x0
6801 if [[ $RC -eq 0 ]]; then
6802 error "Must return error due to dropped pages, rc=$RC"
6805 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6806 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6807 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
6808 if [[ $LOCKED -ne 0 ]]; then
6809 error "Locked pages remain in cache, locked=$LOCKED"
6812 # in recoverable error on OST we want resend and stay until it finished
6813 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6814 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6818 echo "No pages locked after fsync"
6822 run_test 118j "Simulate unrecoverable OST side error =========="
6826 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6827 remote_ost_nodsh && skip "remote OSTs with nodsh" && return
6829 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
6830 set_nodes_failloc "$(osts_nodes)" 0x20e
6831 test_mkdir -p $DIR/$tdir
6833 for ((i=0;i<10;i++)); do
6834 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
6835 error "dd to $DIR/$tdir/$tfile-$i failed" )&
6842 set_nodes_failloc "$(osts_nodes)" 0
6845 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
6849 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6851 test_mkdir -p $DIR/$tdir
6852 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
6855 run_test 118l "fsync dir ========="
6857 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
6859 test_119a() # bug 11737
6861 BSIZE=$((512 * 1024))
6862 directio write $DIR/$tfile 0 1 $BSIZE
6863 # We ask to read two blocks, which is more than a file size.
6864 # directio will indicate an error when requested and actual
6865 # sizes aren't equeal (a normal situation in this case) and
6866 # print actual read amount.
6867 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
6868 if [ "$NOB" != "$BSIZE" ]; then
6869 error "read $NOB bytes instead of $BSIZE"
6873 run_test 119a "Short directIO read must return actual read amount"
6875 test_119b() # bug 11737
6877 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
6879 $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
6880 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
6882 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) || \
6883 error "direct read failed"
6886 run_test 119b "Sparse directIO read must return actual read amount"
6888 test_119c() # bug 13099
6891 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
6892 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
6895 run_test 119c "Testing for direct read hitting hole"
6897 test_119d() # bug 15950
6899 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6900 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
6901 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
6903 $SETSTRIPE $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
6904 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
6905 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
6906 lctl set_param fail_loc=0x40d
6907 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
6910 cat $DIR/$tfile > /dev/null &
6911 lctl set_param fail_loc=0
6914 log "the DIO writes have completed, now wait for the reads (should not block very long)"
6916 [ -n "`ps h -p $pid_reads -o comm`" ] && \
6917 error "the read rpcs have not completed in 2s"
6919 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
6921 run_test 119d "The DIO path should try to send a new rpc once one is completed"
6924 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6925 test_mkdir -p $DIR/$tdir
6926 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6927 skip "no early lock cancel on server" && return 0
6928 lru_resize_disable mdc
6929 lru_resize_disable osc
6930 cancel_lru_locks mdc
6931 stat $DIR/$tdir > /dev/null
6932 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6933 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6934 test_mkdir $DIR/$tdir/d1
6935 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6936 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6937 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6938 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6939 lru_resize_enable mdc
6940 lru_resize_enable osc
6942 run_test 120a "Early Lock Cancel: mkdir test"
6945 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6946 test_mkdir -p $DIR/$tdir
6947 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6948 skip "no early lock cancel on server" && return 0
6949 lru_resize_disable mdc
6950 lru_resize_disable osc
6951 cancel_lru_locks mdc
6952 stat $DIR/$tdir > /dev/null
6953 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6954 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6956 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6957 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6958 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6959 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6960 lru_resize_enable mdc
6961 lru_resize_enable osc
6963 run_test 120b "Early Lock Cancel: create test"
6966 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6967 test_mkdir -p $DIR/$tdir
6968 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6969 skip "no early lock cancel on server" && return 0
6970 lru_resize_disable mdc
6971 lru_resize_disable osc
6972 test_mkdir -p $DIR/$tdir/d1 $DIR/$tdir/d2
6973 touch $DIR/$tdir/d1/f1
6974 cancel_lru_locks mdc
6975 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
6976 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6977 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6978 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
6979 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6980 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6981 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6982 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6983 lru_resize_enable mdc
6984 lru_resize_enable osc
6986 run_test 120c "Early Lock Cancel: link test"
6989 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6990 test_mkdir -p $DIR/$tdir
6991 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6992 skip "no early lock cancel on server" && return 0
6993 lru_resize_disable mdc
6994 lru_resize_disable osc
6996 cancel_lru_locks mdc
6997 stat $DIR/$tdir > /dev/null
6998 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6999 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
7000 chmod a+x $DIR/$tdir
7001 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
7002 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
7003 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7004 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7005 lru_resize_enable mdc
7006 lru_resize_enable osc
7008 run_test 120d "Early Lock Cancel: setattr test"
7011 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7012 test_mkdir -p $DIR/$tdir
7013 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7014 skip "no early lock cancel on server" && return 0
7015 lru_resize_disable mdc
7016 lru_resize_disable osc
7017 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
7018 cancel_lru_locks mdc
7019 cancel_lru_locks osc
7020 dd if=$DIR/$tdir/f1 of=/dev/null
7021 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
7022 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7023 awk '/ldlm_cancel/ {print $2}'`
7024 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7025 awk '/ldlm_bl_callback/ {print $2}'`
7026 unlink $DIR/$tdir/f1
7027 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7028 awk '/ldlm_cancel/ {print $2}'`
7029 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7030 awk '/ldlm_bl_callback/ {print $2}'`
7031 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7032 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7033 lru_resize_enable mdc
7034 lru_resize_enable osc
7036 run_test 120e "Early Lock Cancel: unlink test"
7039 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7040 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7041 skip "no early lock cancel on server" && return 0
7042 test_mkdir -p $DIR/$tdir
7043 lru_resize_disable mdc
7044 lru_resize_disable osc
7045 test_mkdir -p $DIR/$tdir/d1 $DIR/$tdir/d2
7046 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
7047 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
7048 cancel_lru_locks mdc
7049 cancel_lru_locks osc
7050 dd if=$DIR/$tdir/d1/f1 of=/dev/null
7051 dd if=$DIR/$tdir/d2/f2 of=/dev/null
7052 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
7053 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7054 awk '/ldlm_cancel/ {print $2}'`
7055 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7056 awk '/ldlm_bl_callback/ {print $2}'`
7057 mv $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
7058 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7059 awk '/ldlm_cancel/ {print $2}'`
7060 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7061 awk '/ldlm_bl_callback/ {print $2}'`
7062 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7063 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7064 lru_resize_enable mdc
7065 lru_resize_enable osc
7067 run_test 120f "Early Lock Cancel: rename test"
7070 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7071 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7072 skip "no early lock cancel on server" && return 0
7073 lru_resize_disable mdc
7074 lru_resize_disable osc
7076 echo create $count files
7077 test_mkdir -p $DIR/$tdir
7078 cancel_lru_locks mdc
7079 cancel_lru_locks osc
7082 can0=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7083 awk '/ldlm_cancel/ {print $2}'`
7084 blk0=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7085 awk '/ldlm_bl_callback/ {print $2}'`
7086 createmany -o $DIR/$tdir/f $count
7088 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7089 awk '/ldlm_cancel/ {print $2}'`
7090 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7091 awk '/ldlm_bl_callback/ {print $2}'`
7093 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
7094 echo rm $count files
7097 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7098 awk '/ldlm_cancel/ {print $2}'`
7099 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7100 awk '/ldlm_bl_callback/ {print $2}'`
7102 echo total: $count removes in $((t2-t1))
7103 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
7105 # wait for commitment of removal
7106 lru_resize_enable mdc
7107 lru_resize_enable osc
7109 run_test 120g "Early Lock Cancel: performance test"
7111 test_121() { #bug #10589
7112 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7114 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
7115 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
7116 lctl set_param fail_loc=0x310
7117 cancel_lru_locks osc > /dev/null
7118 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
7119 lctl set_param fail_loc=0
7120 [ "$reads" -eq "$writes" ] || error "read" $reads "blocks, must be" $writes
7122 run_test 121 "read cancel race ========="
7124 test_123a() { # was test 123, statahead(bug 11401)
7125 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7127 if [ -z "$(grep "processor.*: 1" /proc/cpuinfo)" ]; then
7128 log "testing on UP system. Performance may be not as good as expected."
7133 test_mkdir -p $DIR/$tdir
7134 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
7135 [ $NUMFREE -gt 100000 ] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
7137 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
7138 createmany -o $DIR/$tdir/$tfile $j $((i - j))
7140 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
7141 lctl set_param -n llite.*.statahead_max 0
7142 lctl get_param llite.*.statahead_max
7143 cancel_lru_locks mdc
7144 cancel_lru_locks osc
7146 time ls -l $DIR/$tdir | wc -l
7148 delta=$((etime - stime))
7149 log "ls $i files without statahead: $delta sec"
7150 lctl set_param llite.*.statahead_max=$max
7152 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
7153 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
7154 cancel_lru_locks mdc
7155 cancel_lru_locks osc
7157 time ls -l $DIR/$tdir | wc -l
7159 delta_sa=$((etime - stime))
7160 log "ls $i files with statahead: $delta_sa sec"
7161 lctl get_param -n llite.*.statahead_stats
7162 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
7164 [ $swrong -lt $ewrong ] && log "statahead was stopped, maybe too many locks held!"
7165 [ $delta -eq 0 -o $delta_sa -eq 0 ] && continue
7167 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
7168 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
7169 lctl set_param -n llite.*.statahead_max 0
7170 lctl get_param llite.*.statahead_max
7171 cancel_lru_locks mdc
7172 cancel_lru_locks osc
7174 time ls -l $DIR/$tdir | wc -l
7176 delta=$((etime - stime))
7177 log "ls $i files again without statahead: $delta sec"
7178 lctl set_param llite.*.statahead_max=$max
7179 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
7180 if [ $SLOWOK -eq 0 ]; then
7181 error "ls $i files is slower with statahead!"
7183 log "ls $i files is slower with statahead!"
7189 [ $delta -gt 20 ] && break
7190 [ $delta -gt 8 ] && MULT=$((50 / delta))
7191 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
7199 delta=$((etime - stime))
7200 log "rm -r $DIR/$tdir/: $delta seconds"
7202 lctl get_param -n llite.*.statahead_stats
7204 run_test 123a "verify statahead work"
7206 test_123b () { # statahead(bug 15027)
7207 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7208 test_mkdir -p $DIR/$tdir
7209 createmany -o $DIR/$tdir/$tfile-%d 1000
7211 cancel_lru_locks mdc
7212 cancel_lru_locks osc
7214 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
7215 lctl set_param fail_loc=0x80000803
7216 ls -lR $DIR/$tdir > /dev/null
7218 lctl set_param fail_loc=0x0
7219 lctl get_param -n llite.*.statahead_stats
7224 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
7227 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7228 [ -z "`lctl get_param -n mdc.*.connect_flags | grep lru_resize`" ] && \
7229 skip "no lru resize on server" && return 0
7231 test_mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
7233 log "create $NR files at $DIR/$tdir"
7234 createmany -o $DIR/$tdir/f $NR ||
7235 error "failed to create $NR files in $DIR/$tdir"
7237 cancel_lru_locks mdc
7238 ls -l $DIR/$tdir > /dev/null
7242 for VALUE in `lctl get_param ldlm.namespaces.*mdc-*.lru_size`; do
7243 local PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
7244 LRU_SIZE=$(lctl get_param -n $PARAM)
7245 if [ $LRU_SIZE -gt $(default_lru_size) ]; then
7246 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
7248 log "NS=$(basename $NSDIR)"
7253 if [ -z "$NSDIR" -o $LRU_SIZE -lt $(default_lru_size) ]; then
7254 skip "Not enough cached locks created!"
7261 # We know that lru resize allows one client to hold $LIMIT locks
7262 # for 10h. After that locks begin to be killed by client.
7264 local LIMIT=`lctl get_param -n $NSDIR.pool.limit`
7267 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
7268 # killing locks. Some time was spent for creating locks. This means
7269 # that up to the moment of sleep finish we must have killed some of
7270 # them (10-100 locks). This depends on how fast ther were created.
7271 # Many of them were touched in almost the same moment and thus will
7272 # be killed in groups.
7273 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
7275 # Use $LRU_SIZE_B here to take into account real number of locks
7276 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
7277 local LRU_SIZE_B=$LRU_SIZE
7279 local OLD_LVF=`lctl get_param -n $NSDIR.pool.lock_volume_factor`
7280 log "OLD_LVF=$OLD_LVF"
7281 lctl set_param -n $NSDIR.pool.lock_volume_factor $LVF
7283 # Let's make sure that we really have some margin. Client checks
7284 # cached locks every 10 sec.
7286 log "Sleep ${SLEEP} sec"
7288 while ((SEC<$SLEEP)); do
7292 LRU_SIZE=`lctl get_param -n $NSDIR/lru_size`
7296 lctl set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
7297 local LRU_SIZE_A=`lctl get_param -n $NSDIR.lru_size`
7299 [ $LRU_SIZE_B -gt $LRU_SIZE_A ] || {
7300 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
7301 unlinkmany $DIR/$tdir/f $NR
7305 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
7306 log "unlink $NR files at $DIR/$tdir"
7307 unlinkmany $DIR/$tdir/f $NR
7309 run_test 124a "lru resize ======================================="
7311 get_max_pool_limit()
7313 local limit=`lctl get_param -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit`
7316 if test $l -gt $max; then
7324 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7325 [ -z "`lctl get_param -n mdc.*.connect_flags | grep lru_resize`" ] && \
7326 skip "no lru resize on server" && return 0
7328 LIMIT=`get_max_pool_limit`
7330 NR=$(($(default_lru_size)*20))
7331 if [ $NR -gt $LIMIT ]; then
7332 log "Limit lock number by $LIMIT locks"
7335 lru_resize_disable mdc
7336 test_mkdir -p $DIR/$tdir/disable_lru_resize ||
7337 error "failed to create $DIR/$tdir/disable_lru_resize"
7339 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
7340 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
7341 cancel_lru_locks mdc
7344 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
7347 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
7350 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
7354 nolruresize_delta=$((etime-stime))
7355 log "ls -la time: $nolruresize_delta seconds"
7356 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
7357 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
7359 lru_resize_enable mdc
7360 test_mkdir -p $DIR/$tdir/enable_lru_resize ||
7361 error "failed to create $DIR/$tdir/enable_lru_resize"
7363 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
7364 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
7365 cancel_lru_locks mdc
7368 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
7371 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
7374 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
7378 lruresize_delta=$((etime-stime))
7379 log "ls -la time: $lruresize_delta seconds"
7380 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
7382 if [ $lruresize_delta -gt $nolruresize_delta ]; then
7383 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
7384 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
7385 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
7387 log "lru resize performs the same with no lru resize"
7389 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
7391 run_test 124b "lru resize (performance test) ======================="
7393 test_125() { # 13358
7394 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
7395 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
7396 test_mkdir -p $DIR/d125 || error "mkdir failed"
7397 $SETSTRIPE -S 65536 -c -1 $DIR/d125 || error "setstripe failed"
7398 setfacl -R -m u:bin:rwx $DIR/d125 || error "setfacl $DIR/d125 failed"
7399 ls -ld $DIR/d125 || error "cannot access $DIR/d125"
7401 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
7403 test_126() { # bug 12829/13455
7404 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
7405 [ "$UID" != 0 ] && skip_env "skipping $TESTNAME (must run as root)" && return
7406 $GSS && skip "must run as gss disabled" && return
7408 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
7409 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
7411 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
7413 run_test 126 "check that the fsgid provided by the client is taken into account"
7415 test_127a() { # bug 15521
7416 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7417 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
7418 $LCTL set_param osc.*.stats=0
7419 FSIZE=$((2048 * 1024))
7420 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
7421 cancel_lru_locks osc
7422 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
7424 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
7425 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
7426 echo "got $COUNT $NAME"
7427 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
7428 eval $NAME=$COUNT || error "Wrong proc format"
7431 read_bytes|write_bytes)
7432 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
7433 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
7434 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
7435 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
7436 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
7437 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
7438 error "sumsquare is too small: $SUMSQ"
7439 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
7440 error "sumsquare is too big: $SUMSQ"
7444 done < $DIR/${tfile}.tmp
7446 #check that we actually got some stats
7447 [ "$read_bytes" ] || error "Missing read_bytes stats"
7448 [ "$write_bytes" ] || error "Missing write_bytes stats"
7449 [ "$read_bytes" != 0 ] || error "no read done"
7450 [ "$write_bytes" != 0 ] || error "no write done"
7452 run_test 127a "verify the client stats are sane"
7454 test_127b() { # bug LU-333
7455 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7456 $LCTL set_param llite.*.stats=0
7457 FSIZE=65536 # sized fixed to match PAGE_SIZE for most clients
7458 # perform 2 reads and writes so MAX is different from SUM.
7459 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
7460 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
7461 cancel_lru_locks osc
7462 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
7463 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
7465 $LCTL get_param llite.*.stats | grep samples > $TMP/${tfile}.tmp
7466 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
7467 echo "got $COUNT $NAME"
7468 eval $NAME=$COUNT || error "Wrong proc format"
7472 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
7473 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
7474 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
7475 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
7478 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
7479 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
7480 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
7481 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
7485 done < $TMP/${tfile}.tmp
7487 #check that we actually got some stats
7488 [ "$read_bytes" ] || error "Missing read_bytes stats"
7489 [ "$write_bytes" ] || error "Missing write_bytes stats"
7490 [ "$read_bytes" != 0 ] || error "no read done"
7491 [ "$write_bytes" != 0 ] || error "no write done"
7493 run_test 127b "verify the llite client stats are sane"
7495 test_128() { # bug 15212
7497 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
7502 result=$(grep error $TMP/$tfile.log)
7504 [ -z "$result" ] || error "consecutive find's under interactive lfs failed"
7506 run_test 128 "interactive lfs for 2 consecutive find's"
7513 local LDPROC=/proc/fs/ldiskfs
7514 local facets=$(get_facets MDS)
7516 for facet in ${facets//,/ }; do
7517 canondev=$(ldiskfs_canon \
7518 *.$(convert_facet2label $facet).mntdev $facet)
7519 do_facet $facet "test -e $LDPROC/$canondev/max_dir_size" ||
7520 LDPROC=/sys/fs/ldiskfs
7521 do_facet $facet "echo $1 >$LDPROC/$canondev/max_dir_size"
7526 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7527 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
7528 skip "Only applicable to ldiskfs-based MDTs"
7531 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7537 test_mkdir -p $DIR/$tdir
7541 while [ ! $I -gt $((MAX * MDSCOUNT)) ]; do
7542 $MULTIOP $DIR/$tdir/$J Oc
7544 if [ $rc -eq $EFBIG ]; then
7546 echo "return code $rc received as expected"
7548 elif [ $rc -ne 0 ]; then
7550 error_exit "return code $rc received instead of expected $EFBIG"
7553 I=$(stat -c%s "$DIR/$tdir")
7557 error "exceeded dir size limit $MAX x $MDSCOUNT $((MAX * MDSCOUNT)) : $I bytes"
7559 run_test 129 "test directory size limit ========================"
7568 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7569 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
7572 trap cleanup_130 EXIT RETURN
7574 local fm_file=$DIR/$tfile
7575 $SETSTRIPE -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
7576 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
7577 error "dd failed for $fm_file"
7579 # LU-1795: test filefrag/FIEMAP once, even if unsupported
7580 filefrag -ves $fm_file
7582 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
7583 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
7584 [ $RC != 0 ] && error "filefrag $fm_file failed"
7586 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
7587 grep -v "ext:" | grep -v "found")
7588 lun=$($GETSTRIPE -i $fm_file)
7590 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
7593 for line in $filefrag_op
7595 frag_lun=`echo $line | cut -d: -f5`
7596 ext_len=`echo $line | cut -d: -f4`
7597 if (( $frag_lun != $lun )); then
7599 error "FIEMAP on 1-stripe file($fm_file) failed"
7602 (( tot_len += ext_len ))
7605 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
7607 error "FIEMAP on 1-stripe file($fm_file) failed;"
7613 echo "FIEMAP on single striped file succeeded"
7615 run_test 130a "FIEMAP (1-stripe file)"
7618 [ "$OSTCOUNT" -lt "2" ] &&
7619 skip_env "skipping FIEMAP on 2-stripe file test" && return
7621 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7622 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
7625 trap cleanup_130 EXIT RETURN
7627 local fm_file=$DIR/$tfile
7628 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
7629 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
7630 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
7632 dd if=/dev/zero of=$fm_file bs=1M count=2 ||
7633 error "dd failed on $fm_file"
7635 filefrag -ves $fm_file || error "filefrag $fm_file failed"
7636 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
7637 grep -v "ext:" | grep -v "found")
7639 last_lun=$(echo $filefrag_op | cut -d: -f5)
7644 for line in $filefrag_op
7646 frag_lun=`echo $line | cut -d: -f5`
7647 ext_len=`echo $line | cut -d: -f4`
7648 if (( $frag_lun != $last_lun )); then
7649 if (( tot_len != 1024 )); then
7651 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 256"
7658 (( tot_len += ext_len ))
7661 if (( num_luns != 2 || tot_len != 1024 )); then
7663 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
7669 echo "FIEMAP on 2-stripe file succeeded"
7671 run_test 130b "FIEMAP (2-stripe file)"
7674 [ "$OSTCOUNT" -lt "2" ] &&
7675 skip_env "skipping FIEMAP on 2-stripe file" && return
7677 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7678 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
7681 trap cleanup_130 EXIT RETURN
7683 local fm_file=$DIR/$tfile
7684 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
7685 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
7686 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
7688 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 || error "dd failed on $fm_file"
7690 filefrag -ves $fm_file || error "filefrag $fm_file failed"
7691 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
7693 last_lun=`echo $filefrag_op | cut -d: -f5`
7698 for line in $filefrag_op
7700 frag_lun=`echo $line | cut -d: -f5`
7701 ext_len=`echo $line | cut -d: -f4`
7702 if (( $frag_lun != $last_lun )); then
7703 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
7704 if (( logical != 512 )); then
7706 error "FIEMAP on $fm_file failed; returned logical start for lun $logical instead of 512"
7709 if (( tot_len != 512 )); then
7711 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
7718 (( tot_len += ext_len ))
7721 if (( num_luns != 2 || tot_len != 512 )); then
7723 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
7729 echo "FIEMAP on 2-stripe file with hole succeeded"
7731 run_test 130c "FIEMAP (2-stripe file with hole)"
7734 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping FIEMAP on N-stripe file test" && return
7736 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7737 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
7739 trap cleanup_130 EXIT RETURN
7741 local fm_file=$DIR/$tfile
7742 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file||error "setstripe on $fm_file"
7743 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
7744 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
7745 dd if=/dev/zero of=$fm_file bs=1M count=$OSTCOUNT || error "dd failed on $fm_file"
7747 filefrag -ves $fm_file || error "filefrag $fm_file failed"
7748 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
7750 last_lun=`echo $filefrag_op | cut -d: -f5`
7755 for line in $filefrag_op
7757 frag_lun=`echo $line | cut -d: -f5`
7758 ext_len=`echo $line | cut -d: -f4`
7759 if (( $frag_lun != $last_lun )); then
7760 if (( tot_len != 1024 )); then
7762 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
7769 (( tot_len += ext_len ))
7772 if (( num_luns != OSTCOUNT || tot_len != 1024 )); then
7774 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
7780 echo "FIEMAP on N-stripe file succeeded"
7782 run_test 130d "FIEMAP (N-stripe file)"
7785 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping continuation FIEMAP test" && return
7787 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7788 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
7790 trap cleanup_130 EXIT RETURN
7792 local fm_file=$DIR/$tfile
7793 $SETSTRIPE -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
7794 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
7795 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
7798 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
7799 for ((i = 0; i < $NUM_BLKS; i++))
7801 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
7804 filefrag -ves $fm_file || error "filefrag $fm_file failed"
7805 filefrag_op=`filefrag -ve $fm_file | grep -A 12000 "ext:" | grep -v "ext:" | grep -v "found"`
7807 last_lun=`echo $filefrag_op | cut -d: -f5`
7812 for line in $filefrag_op
7814 frag_lun=`echo $line | cut -d: -f5`
7815 ext_len=`echo $line | cut -d: -f4`
7816 if (( $frag_lun != $last_lun )); then
7817 if (( tot_len != $EXPECTED_LEN )); then
7819 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of $EXPECTED_LEN"
7826 (( tot_len += ext_len ))
7829 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
7831 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
7837 echo "FIEMAP with continuation calls succeeded"
7839 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
7841 # Test for writev/readv
7843 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 || \
7844 error "writev test failed"
7845 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 || \
7846 error "readv failed"
7849 run_test 131a "test iov's crossing stripe boundary for writev/readv"
7852 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 || \
7853 error "append writev test failed"
7854 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 || \
7855 error "append writev test failed"
7858 run_test 131b "test append writev"
7861 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
7864 run_test 131c "test read/write on file w/o objects"
7867 rwv -f $DIR/$tfile -w -n 1 1572864
7868 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
7869 if [ "$NOB" != 1572864 ]; then
7870 error "Short read filed: read $NOB bytes instead of 1572864"
7874 run_test 131d "test short read"
7877 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
7878 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
7879 error "read hitting hole failed"
7882 run_test 131e "test read hitting hole"
7887 for node in $(osts_nodes); do
7888 gl=$(do_node $node "$LCTL get_param -n ost.OSS.ost.stats" | awk '/'$token'/ {print $2}' | head -n 1)
7889 [ x$gl = x"" ] && gl=0
7890 gl_sum=$((gl_sum + gl))
7900 if [ x$som = x"enabled" ]; then
7901 [ $((gl2 - gl1)) -gt 0 ] && error "no glimpse RPC is expected"
7902 MOUNTOPT=`echo $MOUNTOPT | sed 's/som_preview//g'`
7903 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=disabled"
7905 [ $((gl2 - gl1)) -gt 0 ] || error "some glimpse RPC is expected"
7906 MOUNTOPT="$MOUNTOPT,som_preview"
7907 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=enabled"
7910 # do remount to make new mount-conf parameters actual
7917 test_132() { #1028, SOM
7918 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7919 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7920 local num=$(get_mds_dir $DIR)
7921 local mymds=mds${num}
7922 local MOUNTOPT_SAVE=$MOUNTOPT
7924 dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
7925 cancel_lru_locks osc
7927 som1=$(do_facet $mymds "$LCTL get_param mdt.*.som" | awk -F= ' {print $2}' | head -n 1)
7929 gl1=$(get_ost_param "ldlm_glimpse_enqueue")
7930 stat $DIR/$tfile >/dev/null
7931 gl2=$(get_ost_param "ldlm_glimpse_enqueue")
7932 echo "====> SOM is "$som1", "$((gl2 - gl1))" glimpse RPC occured"
7934 som_mode_switch $som1 $gl1 $gl2
7936 dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
7937 cancel_lru_locks osc
7939 som2=$(do_facet $mymds "$LCTL get_param mdt.*.som" | awk -F= ' {print $2}' | head -n 1)
7940 if [ $som1 == $som2 ]; then
7941 error "som is still "$som2
7942 if [ x$som2 = x"enabled" ]; then
7949 gl1=$(get_ost_param "ldlm_glimpse_enqueue")
7950 stat $DIR/$tfile >/dev/null
7951 gl2=$(get_ost_param "ldlm_glimpse_enqueue")
7952 echo "====> SOM is "$som2", "$((gl2 - gl1))" glimpse RPC occured"
7953 som_mode_switch $som2 $gl1 $gl2
7954 MOUNTOPT=$MOUNTOPT_SAVE
7956 run_test 132 "som avoids glimpse rpc"
7962 $SINGLEMDS) res=`do_facet $SINGLEMDS $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$2"`
7964 ost) res=`do_facet ost1 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$2"`
7966 *) error "Wrong argument $1" ;;
7969 count=`echo $res | awk '{print $2}'`
7970 [ -z "$res" ] && error "The counter for $2 on $1 was not incremented"
7971 # if the argument $3 is zero, it means any stat increment is ok.
7972 if [ $3 -gt 0 ] ; then
7973 [ $count -ne $3 ] && error "The $2 counter on $1 is wrong - expected $3"
7978 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7979 remote_ost_nodsh && skip "remote OST with nodsh" && return
7980 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7982 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
7983 { skip "MDS doesn't support rename stats"; return; }
7984 local testdir=$DIR/${tdir}/stats_testdir
7985 mkdir -p $DIR/${tdir}
7988 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
7989 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
7991 # verify mdt stats first.
7992 mkdir ${testdir} || error "mkdir failed"
7993 check_stats $SINGLEMDS "mkdir" 1
7994 touch ${testdir}/${tfile} || "touch failed"
7995 check_stats $SINGLEMDS "open" 1
7996 check_stats $SINGLEMDS "close" 1
7997 mknod ${testdir}/${tfile}-pipe p || "mknod failed"
7998 check_stats $SINGLEMDS "mknod" 1
7999 rm -f ${testdir}/${tfile}-pipe || "pipe remove failed"
8000 check_stats $SINGLEMDS "unlink" 1
8001 rm -f ${testdir}/${tfile} || error "file remove failed"
8002 check_stats $SINGLEMDS "unlink" 2
8004 # remove working dir and check mdt stats again.
8005 rmdir ${testdir} || error "rmdir failed"
8006 check_stats $SINGLEMDS "rmdir" 1
8008 local testdir1=$DIR/${tdir}/stats_testdir1
8010 mkdir -p ${testdir1}
8011 touch ${testdir1}/test1
8012 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
8013 check_stats $SINGLEMDS "crossdir_rename" 1
8015 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
8016 check_stats $SINGLEMDS "samedir_rename" 1
8020 run_test 133a "Verifying MDT stats ========================================"
8023 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8024 remote_ost_nodsh && skip "remote OST with nodsh" && return
8025 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8026 local testdir=$DIR/${tdir}/stats_testdir
8027 mkdir -p ${testdir} || error "mkdir failed"
8028 touch ${testdir}/${tfile} || "touch failed"
8029 cancel_lru_locks mdc
8032 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8033 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
8035 # extra mdt stats verification.
8036 chmod 444 ${testdir}/${tfile} || error "chmod failed"
8037 check_stats $SINGLEMDS "setattr" 1
8038 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8039 if [ $(lustre_version_code $SINGLEMDS) -ne $(version_code 2.2.0) ]
8041 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
8042 check_stats $SINGLEMDS "getattr" 1
8044 $LFS df || error "lfs failed"
8045 check_stats $SINGLEMDS "statfs" 1
8049 run_test 133b "Verifying extra MDT stats =================================="
8052 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8053 remote_ost_nodsh && skip "remote OST with nodsh" && return
8054 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8055 local testdir=$DIR/${tdir}/stats_testdir
8056 test_mkdir -p ${testdir} || error "mkdir failed"
8058 # verify obdfilter stats.
8059 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
8061 cancel_lru_locks osc
8062 wait_delete_completed
8065 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8066 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
8068 dd if=/dev/zero of=${testdir}/${tfile} conv=notrunc bs=512k count=1 || error "dd failed"
8070 cancel_lru_locks osc
8071 check_stats ost "write" 1
8073 dd if=${testdir}/${tfile} of=/dev/null bs=1k count=1 || error "dd failed"
8074 check_stats ost "read" 1
8076 > ${testdir}/${tfile} || error "truncate failed"
8077 check_stats ost "punch" 1
8079 rm -f ${testdir}/${tfile} || error "file remove failed"
8080 wait_delete_completed
8081 check_stats ost "destroy" 1
8085 run_test 133c "Verifying OST stats ========================================"
8092 while [ $value -ge 2 ]; do
8097 if [ $orig -gt $order ]; then
8105 local size=('K' 'M' 'G' 'T');
8107 local size_string=$value
8109 while [ $value -ge 1024 ]; do
8110 if [ $i -gt 3 ]; then
8111 #T is the biggest unit we get here, if that is bigger,
8113 size_string=${value}T
8116 value=$((value >> 10))
8117 if [ $value -lt 1024 ]; then
8118 size_string=${value}${size[$i]}
8129 local context=${2:-.}
8130 local sample=$(do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats |
8132 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
8137 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8138 remote_ost_nodsh && skip "remote OST with nodsh" && return
8139 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8140 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
8141 { skip "MDS doesn't support rename stats"; return; }
8143 local testdir1=$DIR/${tdir}/stats_testdir1
8144 local testdir2=$DIR/${tdir}/stats_testdir2
8146 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
8148 test_mkdir -p ${testdir1} || error "mkdir failed"
8149 test_mkdir -p ${testdir2} || error "mkdir failed"
8151 createmany -o $testdir1/test 512 || error "createmany failed"
8153 # check samedir rename size
8154 mv ${testdir1}/test0 ${testdir1}/test_0
8156 local testdir1_size=$(ls -l $DIR/${tdir} |
8157 awk '/stats_testdir1/ {print $5}')
8158 local testdir2_size=$(ls -l $DIR/${tdir} |
8159 awk '/stats_testdir2/ {print $5}')
8161 testdir1_size=$(order_2 $testdir1_size)
8162 testdir2_size=$(order_2 $testdir2_size)
8164 testdir1_size=$(size_in_KMGT $testdir1_size)
8165 testdir2_size=$(size_in_KMGT $testdir2_size)
8167 echo "source rename dir size: ${testdir1_size}"
8168 echo "target rename dir size: ${testdir2_size}"
8170 local cmd="do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats"
8171 eval $cmd || error "$cmd failed"
8172 local samedir=$($cmd | grep 'same_dir')
8173 local same_sample=$(get_rename_size $testdir1_size)
8174 [ -z "$samedir" ] && error "samedir_rename_size count error"
8175 [ "$same_sample" -eq 1 ] || error "samedir_rename_size error $same_sample"
8176 echo "Check same dir rename stats success"
8178 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
8180 # check crossdir rename size
8181 mv ${testdir1}/test_0 ${testdir2}/test_0
8183 testdir1_size=$(ls -l $DIR/${tdir} |
8184 awk '/stats_testdir1/ {print $5}')
8185 testdir2_size=$(ls -l $DIR/${tdir} |
8186 awk '/stats_testdir2/ {print $5}')
8188 testdir1_size=$(order_2 $testdir1_size)
8189 testdir2_size=$(order_2 $testdir2_size)
8191 testdir1_size=$(size_in_KMGT $testdir1_size)
8192 testdir2_size=$(size_in_KMGT $testdir2_size)
8194 echo "source rename dir size: ${testdir1_size}"
8195 echo "target rename dir size: ${testdir2_size}"
8197 eval $cmd || error "$cmd failed"
8198 local crossdir=$($cmd | grep 'crossdir')
8199 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
8200 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
8201 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
8202 [ "$src_sample" -eq 1 ] || error "crossdir_rename_size error $src_sample"
8203 [ "$tgt_sample" -eq 1 ] || error "crossdir_rename_size error $tgt_sample"
8204 echo "Check cross dir rename stats success"
8207 run_test 133d "Verifying rename_stats ========================================"
8210 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8211 local testdir=$DIR/${tdir}/stats_testdir
8212 local ctr f0 f1 bs=32768 count=42 sum
8214 remote_ost_nodsh && skip "remote OST with nodsh" && return
8215 mkdir -p ${testdir} || error "mkdir failed"
8217 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
8219 for ctr in {write,read}_bytes; do
8221 cancel_lru_locks osc
8223 do_facet ost1 $LCTL set_param -n \
8224 "obdfilter.*.exports.clear=clear"
8226 if [ $ctr = write_bytes ]; then
8228 f1=${testdir}/${tfile}
8230 f0=${testdir}/${tfile}
8234 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
8237 cancel_lru_locks osc
8239 sum=$(do_facet ost1 $LCTL get_param \
8240 "obdfilter.*.exports.*.stats" | \
8243 $1 == ctr { sum += $7 }
8246 if ((sum != bs * count)); then
8247 error "Bad $ctr sum, expected $((bs * count)), got $sum"
8253 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
8255 test_140() { #bug-17379
8256 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8257 test_mkdir -p $DIR/$tdir || error "Creating dir $DIR/$tdir"
8258 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
8259 cp /usr/bin/stat . || error "Copying stat to $DIR/$tdir"
8261 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
8262 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
8264 while i=`expr $i + 1`; do
8265 test_mkdir -p $i || error "Creating dir $i"
8266 cd $i || error "Changing to $i"
8267 ln -s ../stat stat || error "Creating stat symlink"
8268 # Read the symlink until ELOOP present,
8269 # not LBUGing the system is considered success,
8270 # we didn't overrun the stack.
8271 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
8273 if [ $ret -eq 40 ]; then
8276 error "Open stat symlink"
8282 echo "The symlink depth = $i"
8283 [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 -o $i -eq 40 ] ||
8284 error "Invalid symlink depth"
8286 # Test recursive symlink
8287 ln -s symlink_self symlink_self
8288 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
8289 echo "open symlink_self returns $ret"
8290 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
8292 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
8295 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8296 local TF="$TMP/$tfile"
8298 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
8300 cancel_lru_locks osc
8301 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
8302 remount_client $MOUNT
8304 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
8307 $TRUNCATE $DIR/$tfile 6000
8308 cancel_lru_locks osc
8309 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
8312 echo "12345" >>$DIR/$tfile
8313 cancel_lru_locks osc
8314 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
8317 echo "12345" >>$DIR/$tfile
8318 cancel_lru_locks osc
8319 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
8324 run_test 150 "truncate/append tests"
8326 function roc_hit() {
8327 local list=$(comma_list $(osts_nodes))
8329 echo $(get_osd_param $list '' stats |
8330 awk '/'cache_hit'/ {sum+=$2} END {print sum}')
8333 function set_cache() {
8336 if [ "$2" == "off" ]; then
8339 local list=$(comma_list $(osts_nodes))
8340 set_osd_param $list '' $1_cache_enable $on
8342 cancel_lru_locks osc
8346 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8347 remote_ost_nodsh && skip "remote OST with nodsh" && return
8350 local list=$(comma_list $(osts_nodes))
8352 # check whether obdfilter is cache capable at all
8353 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
8354 echo "not cache-capable obdfilter"
8358 # check cache is enabled on all obdfilters
8359 if get_osd_param $list '' read_cache_enable | grep 0; then
8360 echo "oss cache is disabled"
8364 set_osd_param $list '' writethrough_cache_enable 1
8366 # pages should be in the case right after write
8367 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES || error "dd failed"
8368 local BEFORE=`roc_hit`
8369 cancel_lru_locks osc
8370 cat $DIR/$tfile >/dev/null
8371 local AFTER=`roc_hit`
8372 if ! let "AFTER - BEFORE == CPAGES"; then
8373 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
8376 # the following read invalidates the cache
8377 cancel_lru_locks osc
8378 set_osd_param $list '' read_cache_enable 0
8379 cat $DIR/$tfile >/dev/null
8381 # now data shouldn't be found in the cache
8383 cancel_lru_locks osc
8384 cat $DIR/$tfile >/dev/null
8386 if let "AFTER - BEFORE != 0"; then
8387 error "IN CACHE: before: $BEFORE, after: $AFTER"
8390 set_osd_param $list '' read_cache_enable 1
8393 run_test 151 "test cache on oss and controls ==============================="
8396 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8397 local TF="$TMP/$tfile"
8399 # simulate ENOMEM during write
8400 #define OBD_FAIL_OST_NOMEM 0x226
8401 lctl set_param fail_loc=0x80000226
8402 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
8404 sync || error "sync failed"
8405 lctl set_param fail_loc=0
8407 # discard client's cache
8408 cancel_lru_locks osc
8410 # simulate ENOMEM during read
8411 lctl set_param fail_loc=0x80000226
8412 cmp $TF $DIR/$tfile || error "cmp failed"
8413 lctl set_param fail_loc=0
8417 run_test 152 "test read/write with enomem ============================"
8420 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
8422 run_test 153 "test if fdatasync does not crash ======================="
8425 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8426 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
8427 { skip "Need MDS version at least 2.2.51"; return 0; }
8429 cp /etc/hosts $DIR/$tfile
8431 fid=$($LFS path2fid $DIR/$tfile)
8433 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
8435 ffid=$DIR/.lustre/fid/$fid
8437 echo "stat fid $fid"
8438 stat $ffid > /dev/null || error "stat $ffid failed."
8439 echo "touch fid $fid"
8440 touch $ffid || error "touch $ffid failed."
8441 echo "write to fid $fid"
8442 cat /etc/hosts > $ffid || error "write $ffid failed."
8443 echo "read fid $fid"
8444 diff /etc/hosts $ffid || error "read $ffid failed."
8445 echo "append write to fid $fid"
8446 cat /etc/hosts >> $ffid || error "append write $ffid failed."
8447 echo "rename fid $fid"
8448 mv $ffid $DIR/$tfile.1 && error "rename $ffid to $tfile.1 should fail."
8450 mv $DIR/$tfile.1 $ffid && error "rename $tfile.1 to $ffid should fail."
8452 echo "truncate fid $fid"
8453 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
8454 echo "link fid $fid"
8455 ln -f $ffid $DIR/tfile.lnk || error "link $ffid failed."
8456 if [ -n $(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl) ]; then
8457 echo "setfacl fid $fid"
8458 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
8459 echo "getfacl fid $fid"
8460 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
8462 echo "unlink fid $fid"
8463 unlink $DIR/.lustre/fid/$fid && error "unlink $ffid should fail."
8464 echo "mknod fid $fid"
8465 mknod $ffid c 1 3 && error "mknod $ffid should fail."
8467 fid=[0xf00000400:0x1:0x0]
8468 ffid=$DIR/.lustre/fid/$fid
8470 echo "stat non-exist fid $fid"
8471 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
8472 echo "write to non-exist fid $fid"
8473 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
8474 echo "link new fid $fid"
8475 ln $DIR/$tfile $ffid && error "link $ffid should fail."
8477 test_mkdir -p $DIR/$tdir
8478 touch $DIR/$tdir/$tfile
8479 fid=$($LFS path2fid $DIR/$tdir)
8481 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
8483 ffid=$DIR/.lustre/fid/$fid
8486 ls $ffid > /dev/null || error "ls $ffid failed."
8487 echo "touch $fid/$tfile.1"
8488 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
8490 echo "touch $DIR/.lustre/fid/$tfile"
8491 touch $DIR/.lustre/fid/$tfile && \
8492 error "touch $DIR/.lustre/fid/$tfile should fail."
8494 echo "setxattr to $DIR/.lustre/fid"
8495 setfattr -n trusted.name1 -v value1 $DIR/.lustre/fid &&
8496 error "setxattr should fail."
8498 echo "listxattr for $DIR/.lustre/fid"
8499 getfattr -d -m "^trusted" $DIR/.lustre/fid &&
8500 error "listxattr should fail."
8502 echo "delxattr from $DIR/.lustre/fid"
8503 setfattr -x trusted.name1 $DIR/.lustre/fid &&
8504 error "delxattr should fail."
8506 echo "touch invalid fid: $DIR/.lustre/fid/[0x200000400:0x2:0x3]"
8507 touch $DIR/.lustre/fid/[0x200000400:0x2:0x3] &&
8508 error "touch invalid fid should fail."
8510 echo "touch non-normal fid: $DIR/.lustre/fid/[0x1:0x2:0x0]"
8511 touch $DIR/.lustre/fid/[0x1:0x2:0x0] &&
8512 error "touch non-normal fid should fail."
8514 echo "rename $tdir to $DIR/.lustre/fid"
8515 mrename $DIR/$tdir $DIR/.lustre/fid &&
8516 error "rename to $DIR/.lustre/fid should fail."
8518 echo "rename .lustre to itself"
8519 fid=$($LFS path2fid $DIR)
8520 mrename $DIR/.lustre $DIR/.lustre/fid/$fid/.lustre &&
8521 error "rename .lustre to itself should fail."
8523 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $DIR/$tfile-2
8524 fid=$($LFS path2fid $DIR/$tfile-2)
8525 echo "cp /etc/passwd $DIR/.lustre/fid/$fid"
8526 cp /etc/passwd $DIR/.lustre/fid/$fid &&
8527 error "create lov data thru .lustre should fail."
8528 echo "cp /etc/passwd $DIR/$tfile-2"
8529 cp /etc/passwd $DIR/$tfile-2 || error "copy to $DIR/$tfile-2 failed."
8530 echo "diff /etc/passwd $DIR/.lustre/fid/$fid"
8531 diff /etc/passwd $DIR/.lustre/fid/$fid ||
8532 error "diff /etc/passwd $DIR/.lustre/fid/$fid failed."
8534 echo "Open-by-FID succeeded"
8536 run_test 154 "Open-by-FID"
8538 test_155_small_load() {
8539 local temp=$TMP/$tfile
8540 local file=$DIR/$tfile
8542 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
8543 error "dd of=$temp bs=6096 count=1 failed"
8545 cancel_lru_locks osc
8546 cmp $temp $file || error "$temp $file differ"
8548 $TRUNCATE $temp 6000
8549 $TRUNCATE $file 6000
8550 cmp $temp $file || error "$temp $file differ (truncate1)"
8552 echo "12345" >>$temp
8553 echo "12345" >>$file
8554 cmp $temp $file || error "$temp $file differ (append1)"
8556 echo "12345" >>$temp
8557 echo "12345" >>$file
8558 cmp $temp $file || error "$temp $file differ (append2)"
8564 test_155_big_load() {
8565 remote_ost_nodsh && skip "remote OST with nodsh" && return
8566 local temp=$TMP/$tfile
8567 local file=$DIR/$tfile
8570 local cache_size=$(do_facet ost$((MAXI+1)) \
8571 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
8572 local large_file_size=$((cache_size * 2))
8574 echo "OSS cache size: $cache_size KB"
8575 echo "Large file size: $large_file_size KB"
8577 [ $MAXV -le $large_file_size ] && \
8578 skip_env "max available OST size needs > $large_file_size KB" && \
8581 $SETSTRIPE $file -c 1 -i $MAXI || error "$SETSTRIPE $file failed"
8583 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k || \
8584 error "dd of=$temp bs=$large_file_size count=1k failed"
8587 cancel_lru_locks osc
8588 cmp $temp $file || error "$temp $file differ"
8595 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8597 set_cache writethrough on
8600 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
8603 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8605 set_cache writethrough off
8608 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
8611 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8613 set_cache writethrough on
8616 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
8619 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8621 set_cache writethrough off
8624 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
8627 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8629 set_cache writethrough on
8632 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
8635 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8637 set_cache writethrough off
8640 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
8643 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8645 set_cache writethrough on
8648 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
8651 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8653 set_cache writethrough off
8656 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
8659 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8663 local file="$DIR/$tfile"
8665 [ "$(facet_fstype ost1)" = "zfs" ] &&
8666 skip "LU-1956/LU-2261: stats unimplemented on OSD ZFS" &&
8669 log "Turn on read and write cache"
8671 set_cache writethrough on
8673 log "Write data and read it back."
8674 log "Read should be satisfied from the cache."
8675 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
8677 cancel_lru_locks osc
8678 cat $file >/dev/null
8680 if ! let "AFTER - BEFORE == CPAGES"; then
8681 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
8683 log "cache hits:: before: $BEFORE, after: $AFTER"
8686 log "Read again; it should be satisfied from the cache."
8688 cancel_lru_locks osc
8689 cat $file >/dev/null
8691 if ! let "AFTER - BEFORE == CPAGES"; then
8692 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
8694 log "cache hits:: before: $BEFORE, after: $AFTER"
8698 log "Turn off the read cache and turn on the write cache"
8700 set_cache writethrough on
8702 log "Read again; it should be satisfied from the cache."
8704 cancel_lru_locks osc
8705 cat $file >/dev/null
8707 if ! let "AFTER - BEFORE == CPAGES"; then
8708 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
8710 log "cache hits:: before: $BEFORE, after: $AFTER"
8713 log "Read again; it should not be satisfied from the cache."
8715 cancel_lru_locks osc
8716 cat $file >/dev/null
8718 if ! let "AFTER - BEFORE == 0"; then
8719 error "IN CACHE: before: $BEFORE, after: $AFTER"
8721 log "cache hits:: before: $BEFORE, after: $AFTER"
8724 log "Write data and read it back."
8725 log "Read should be satisfied from the cache."
8726 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
8728 cancel_lru_locks osc
8729 cat $file >/dev/null
8731 if ! let "AFTER - BEFORE == CPAGES"; then
8732 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
8734 log "cache hits:: before: $BEFORE, after: $AFTER"
8737 log "Read again; it should not be satisfied from the cache."
8739 cancel_lru_locks osc
8740 cat $file >/dev/null
8742 if ! let "AFTER - BEFORE == 0"; then
8743 error "IN CACHE: before: $BEFORE, after: $AFTER"
8745 log "cache hits:: before: $BEFORE, after: $AFTER"
8749 log "Turn off read and write cache"
8751 set_cache writethrough off
8753 log "Write data and read it back"
8754 log "It should not be satisfied from the cache."
8756 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
8757 cancel_lru_locks osc
8759 cat $file >/dev/null
8761 if ! let "AFTER - BEFORE == 0"; then
8762 error_ignore 20762 "IN CACHE: before: $BEFORE, after: $AFTER"
8764 log "cache hits:: before: $BEFORE, after: $AFTER"
8768 log "Turn on the read cache and turn off the write cache"
8770 set_cache writethrough off
8772 log "Write data and read it back"
8773 log "It should not be satisfied from the cache."
8775 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
8777 cancel_lru_locks osc
8778 cat $file >/dev/null
8780 if ! let "AFTER - BEFORE == 0"; then
8781 error_ignore 20762 "IN CACHE: before: $BEFORE, after: $AFTER"
8783 log "cache hits:: before: $BEFORE, after: $AFTER"
8786 log "Read again; it should be satisfied from the cache."
8788 cancel_lru_locks osc
8789 cat $file >/dev/null
8791 if ! let "AFTER - BEFORE == CPAGES"; then
8792 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
8794 log "cache hits:: before: $BEFORE, after: $AFTER"
8799 run_test 156 "Verification of tunables ============================"
8803 if [ $MDSCOUNT -gt 1 ]; then
8804 error_ignore 17935 $*
8812 MASK=$(do_facet $SINGLEMDS $LCTL get_param mdd.$MDT0.changelog_mask |\
8815 if [ $MASK -eq 1 ]; then
8816 do_facet $SINGLEMDS $LCTL set_param mdd.$MDT0.changelog_mask="-$1"
8818 do_facet $SINGLEMDS $LCTL set_param mdd.$MDT0.changelog_mask="+$1"
8823 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8824 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8825 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
8826 { skip "Need MDS version at least 2.2.0"; return; }
8827 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
8828 echo "Registered as changelog user $USER"
8829 do_facet $SINGLEMDS $LCTL get_param -n mdd.$MDT0.changelog_users | \
8830 grep -q $USER || error "User $USER not found in changelog_users"
8833 test_mkdir -p $DIR/$tdir/pics/2008/zachy
8834 touch $DIR/$tdir/pics/2008/zachy/timestamp
8835 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
8836 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
8837 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
8838 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
8839 rm $DIR/$tdir/pics/desktop.jpg
8841 $LFS changelog $MDT0 | tail -5
8843 echo "verifying changelog mask"
8844 changelog_chmask "MKDIR"
8845 changelog_chmask "CLOSE"
8847 test_mkdir -p $DIR/$tdir/pics/zach/sofia
8848 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
8850 changelog_chmask "MKDIR"
8851 changelog_chmask "CLOSE"
8853 test_mkdir -p $DIR/$tdir/pics/2008/sofia
8854 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
8856 $LFS changelog $MDT0
8857 MKDIRS=$($LFS changelog $MDT0 | tail -5 | grep -c "MKDIR")
8858 CLOSES=$($LFS changelog $MDT0 | tail -5 | grep -c "CLOSE")
8859 [ $MKDIRS -eq 1 ] || err17935 "MKDIR changelog mask count $DIRS != 1"
8860 [ $CLOSES -eq 1 ] || err17935 "CLOSE changelog mask count $DIRS != 1"
8863 echo "verifying target fid"
8864 fidc=$($LFS changelog $MDT0 | grep timestamp | grep "CREAT" | \
8865 tail -1 | awk '{print $6}')
8866 fidf=$($LFS path2fid $DIR/$tdir/pics/zach/timestamp)
8867 [ "$fidc" == "t=$fidf" ] || \
8868 err17935 "fid in changelog $fidc != file fid $fidf"
8869 echo "verifying parent fid"
8870 fidc=$($LFS changelog $MDT0 | grep timestamp | grep "CREAT" | \
8871 tail -1 | awk '{print $7}')
8872 fidf=$($LFS path2fid $DIR/$tdir/pics/zach)
8873 [ "$fidc" == "p=$fidf" ] || \
8874 err17935 "pfid in changelog $fidc != dir fid $fidf"
8876 USER_REC1=$(do_facet $SINGLEMDS $LCTL get_param -n \
8877 mdd.$MDT0.changelog_users | grep $USER | awk '{print $2}')
8878 $LFS changelog_clear $MDT0 $USER $(($USER_REC1 + 5))
8879 USER_REC2=$(do_facet $SINGLEMDS $LCTL get_param -n \
8880 mdd.$MDT0.changelog_users | grep $USER | awk '{print $2}')
8881 echo "verifying user clear: $(( $USER_REC1 + 5 )) == $USER_REC2"
8882 [ $USER_REC2 == $(($USER_REC1 + 5)) ] || \
8883 err17935 "user index should be $(($USER_REC1 + 5)); is $USER_REC2"
8885 MIN_REC=$(do_facet $SINGLEMDS $LCTL get_param mdd.$MDT0.changelog_users | \
8886 awk 'min == "" || $2 < min {min = $2}; END {print min}')
8887 FIRST_REC=$($LFS changelog $MDT0 | head -1 | awk '{print $1}')
8888 echo "verifying min purge: $(( $MIN_REC + 1 )) == $FIRST_REC"
8889 [ $FIRST_REC == $(($MIN_REC + 1)) ] || \
8890 err17935 "first index should be $(($MIN_REC + 1)); is $FIRST_REC"
8892 echo "verifying user deregister"
8893 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
8894 do_facet $SINGLEMDS $LCTL get_param -n mdd.$MDT0.changelog_users | \
8895 grep -q $USER && error "User $USER still found in changelog_users"
8897 USERS=$(( $(do_facet $SINGLEMDS $LCTL get_param -n \
8898 mdd.$MDT0.changelog_users | wc -l) - 2 ))
8899 if [ $USERS -eq 0 ]; then
8900 LAST_REC1=$(do_facet $SINGLEMDS $LCTL get_param -n \
8901 mdd.$MDT0.changelog_users | head -1 | awk '{print $3}')
8902 touch $DIR/$tdir/chloe
8903 LAST_REC2=$(do_facet $SINGLEMDS $LCTL get_param -n \
8904 mdd.$MDT0.changelog_users | head -1 | awk '{print $3}')
8905 echo "verify changelogs are off if we were the only user: $LAST_REC1 == $LAST_REC2"
8906 [ $LAST_REC1 == $LAST_REC2 ] || error "changelogs not off"
8908 echo "$USERS other changelog users; can't verify off"
8911 run_test 160 "changelog sanity"
8914 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8915 test_mkdir -p $DIR/$tdir
8916 cp /etc/hosts $DIR/$tdir/$tfile
8917 test_mkdir $DIR/$tdir/foo1
8918 test_mkdir $DIR/$tdir/foo2
8919 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
8920 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
8921 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
8922 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
8923 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[')
8924 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
8925 $LFS fid2path $DIR $FID
8926 err17935 "bad link ea"
8929 rm $DIR/$tdir/foo2/zachary
8931 rm $DIR/$tdir/foo2/thor
8933 rm $DIR/$tdir/$tfile
8935 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
8936 if [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ]
8938 $LFS fid2path $DIR $FID
8939 err17935 "bad link rename"
8941 rm $DIR/$tdir/foo2/maggie
8944 local longname=filename_avg_len_is_thirty_two_
8945 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 || \
8946 error "failed to hardlink many files"
8947 links=$($LFS fid2path $DIR $FID | wc -l)
8948 echo -n "${links}/1000 links in link EA"
8949 [ ${links} -gt 60 ] || err17935 "expected at least 60 links in link EA"
8950 unlinkmany $DIR/$tdir/foo2/$longname 1000 || \
8951 error "failed to unlink many hardlinks"
8953 run_test 161 "link ea sanity"
8960 local path=$(${LFS} fid2path $*)
8963 if [ $RC -ne 0 ]; then
8964 err17935 "path looked up of $expected failed. Error $RC"
8966 elif [ "${path}" != "${expected}" ]; then
8967 err17935 "path looked up \"${path}\" instead of \"${expected}\""
8970 echo "fid $fid resolves to path $path (expected $expected)"
8974 # Make changes to filesystem
8975 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8976 test_mkdir -p $DIR/$tdir/d2
8977 touch $DIR/$tdir/d2/$tfile
8978 touch $DIR/$tdir/d2/x1
8979 touch $DIR/$tdir/d2/x2
8980 test_mkdir -p $DIR/$tdir/d2/a/b/c
8981 test_mkdir -p $DIR/$tdir/d2/p/q/r
8983 FID=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
8984 check_path "$tdir/d2/$tfile" $FSNAME $FID --link 0
8987 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
8988 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
8989 check_path "$tdir/d2/p/q/r/slink" $FSNAME $FID --link 0
8991 # softlink to wrong file
8992 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
8993 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
8994 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME $FID --link 0
8997 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
8998 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
8999 FID=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
9000 # fid2path dir/fsname should both work
9001 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 1
9002 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR $FID --link 0
9004 # hardlink count: check that there are 2 links
9005 # Doesnt work with CMD yet: 17935
9006 ${LFS} fid2path $DIR $FID | wc -l | grep -q 2 || \
9007 err17935 "expected 2 links"
9009 # hardlink indexing: remove the first link
9010 rm $DIR/$tdir/d2/p/q/r/hlink
9011 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 0
9015 run_test 162 "path lookup sanity"
9018 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9019 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9020 copytool --test $FSNAME || { skip "copytool not runnable: $?" && return; }
9023 local uuid=$($LCTL get_param -n mdc.${FSNAME}-MDT0000-mdc-*.uuid)
9024 # this proc file is temporary and linux-only
9025 do_facet $SINGLEMDS lctl set_param mdt.${FSNAME}-MDT0000.mdccomm=$uuid ||\
9026 error "kernel->userspace send failed"
9029 run_test 163 "kernel <-> userspace comms"
9032 # do directio so as not to populate the page cache
9033 log "creating a 10 Mb file"
9034 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
9035 log "starting reads"
9036 dd if=$DIR/$tfile of=/dev/null bs=4096 &
9037 log "truncating the file"
9038 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
9040 kill %+ || true # reads might have finished
9041 echo "wait until dd is finished"
9043 log "removing the temporary file"
9044 rm -rf $DIR/$tfile || error "tmp file removal failed"
9046 run_test 169 "parallel read and truncate should not deadlock"
9049 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9050 $LCTL clear # bug 18514
9051 $LCTL debug_daemon start $TMP/${tfile}_log_good
9053 $LCTL debug_daemon stop
9054 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
9055 error "sed failed to read log_good"
9057 $LCTL debug_daemon start $TMP/${tfile}_log_good
9059 $LCTL debug_daemon stop
9061 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
9062 error "lctl df log_bad failed"
9064 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
9065 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
9067 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
9068 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
9070 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
9071 error "bad_line good_line1 good_line2 are empty"
9073 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
9074 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
9075 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
9077 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
9078 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
9079 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
9081 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
9082 error "bad_line_new good_line_new are empty"
9084 local expected_good=$((good_line1 + good_line2*2))
9086 rm -f $TMP/${tfile}*
9087 # LU-231, short malformed line may not be counted into bad lines
9088 if [ $bad_line -ne $bad_line_new ] &&
9089 [ $bad_line -ne $((bad_line_new - 1)) ]; then
9090 error "expected $bad_line bad lines, but got $bad_line_new"
9094 if [ $expected_good -ne $good_line_new ]; then
9095 error "expected $expected_good good lines, but got $good_line_new"
9100 run_test 170 "test lctl df to handle corrupted log ====================="
9102 test_171() { # bug20592
9103 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9104 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
9105 $LCTL set_param fail_loc=0x50e
9106 $LCTL set_param fail_val=3000
9107 multiop_bg_pause $DIR/$tfile O_s || true
9109 kill -USR1 $MULTIPID
9113 if dmesg | grep "recursive fault"; then
9114 error "caught a recursive fault"
9116 $LCTL set_param fail_loc=0
9119 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
9121 # it would be good to share it with obdfilter-survey/libecho code
9122 setup_obdecho_osc () {
9125 local obdfilter_name=$2
9126 echo "Creating new osc for $obdfilter_name on $ost_nid"
9127 # make sure we can find loopback nid
9128 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
9130 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
9131 ${obdfilter_name}_osc_UUID || rc=2; }
9132 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
9133 ${obdfilter_name}_UUID $ost_nid || rc=3; }
9137 cleanup_obdecho_osc () {
9138 local obdfilter_name=$1
9139 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
9140 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
9144 obdecho_create_test() {
9149 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
9150 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
9152 if [ $rc -eq 0 ]; then
9153 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
9154 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
9156 echo "New object id is $id"
9157 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec test_brw 10 w v 64 $id" ||
9159 [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec " \
9160 "cleanup" || rc=5; }
9161 [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec " \
9163 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
9168 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9169 remote_ost_nodsh && skip "remote OST with nodsh" && return
9173 if ! module_loaded obdecho; then
9174 load_module obdecho/obdecho
9178 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
9179 local host=$(lctl get_param -n osc.$osc.import |
9180 awk '/current_connection:/ {print $2}' )
9181 local target=$(lctl get_param -n osc.$osc.import |
9182 awk '/target:/ {print $2}' )
9183 target=${target%_UUID}
9185 [[ -n $target ]] && { setup_obdecho_osc $host $target || rc=1; } || rc=1
9186 [ $rc -eq 0 ] && { obdecho_create_test ${target}_osc client || rc=2; }
9187 [[ -n $target ]] && cleanup_obdecho_osc $target
9188 [ $rmmod_local -eq 1 ] && rmmod obdecho
9191 run_test 180a "test obdecho on osc"
9194 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9195 remote_ost_nodsh && skip "remote OST with nodsh" && return
9197 local rmmod_remote=0
9199 do_facet ost1 "lsmod | grep -q obdecho || " \
9200 "{ insmod ${LUSTRE}/obdecho/obdecho.ko || " \
9201 "modprobe obdecho; }" && rmmod_remote=1
9202 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ {print $4;exit}')
9203 [[ -n $target ]] && { obdecho_create_test $target ost1 || rc=1; }
9204 [ $rmmod_remote -eq 1 ] && do_facet ost1 "rmmod obdecho"
9207 run_test 180b "test obdecho directly on obdfilter"
9209 test_181() { # bug 22177
9210 test_mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
9211 # create enough files to index the directory
9212 createmany -o $DIR/$tdir/foobar 4000
9213 # print attributes for debug purpose
9216 multiop_bg_pause $DIR/$tdir D_Sc || return 1
9218 # remove the files & current working dir
9219 unlinkmany $DIR/$tdir/foobar 4000
9221 kill -USR1 $MULTIPID
9223 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
9226 run_test 181 "Test open-unlinked dir ========================"
9229 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9230 # disable MDC RPC lock wouldn't crash client
9234 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
9235 #define OBD_FAIL_MDC_RPCS_SEM 0x804
9236 $LCTL set_param fail_loc=0x804
9238 for (( i=0; i < $tcount; i++ )) ; do
9240 createmany -o $DIR/$tdir/$i/f- $fcount &
9244 for (( i=0; i < $tcount; i++ )) ; do
9245 unlinkmany $DIR/$tdir/$i/f- $fcount &
9251 $LCTL set_param fail_loc=0
9253 run_test 182 "Disable MDC RPCs semaphore wouldn't crash client ================"
9255 test_183() { # LU-2275
9256 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9257 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
9258 echo aaa > $DIR/$tdir/$tfile
9260 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
9261 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
9263 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
9264 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
9266 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
9268 # Flush negative dentry cache
9269 touch $DIR/$tdir/$tfile
9271 # We are not checking for any leaked references here, they'll
9272 # become evident next time we do cleanup with module unload.
9275 run_test 183 "No crash or request leak in case of strange dispositions ========"
9277 test_185() { # LU-2441
9278 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
9279 touch $DIR/$tdir/spoo
9280 local mtime1=$(stat -c "%Y" $DIR/$tdir)
9281 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
9282 error "cannot create/write a volatile file"
9283 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
9284 error "FID is still valid after close"
9286 multiop_bg_pause $DIR/$tdir vVw4096_c
9293 # assume that the next FID for this client is sequential, since stdout
9294 # is unfortunately eaten by multiop_bg_pause
9295 local n=$((${fidv[1]} + 1))
9296 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
9297 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
9298 error "FID is missing before close"
9299 kill -USR1 $multi_pid
9300 # 1 second delay, so if mtime change we will see it
9302 local mtime2=$(stat -c "%Y" $DIR/$tdir)
9303 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
9305 run_test 185 "Volatile file support"
9307 check_swap_layouts_support()
9309 $LCTL get_param -n llite.*.sbi_flags | grep -q layout ||
9310 { skip "Does not support layout lock."; return 0; }
9314 # test suite 184 is for LU-2016, LU-2017
9316 check_swap_layouts_support && return 0
9318 dir0=$DIR/$tdir/$testnum
9319 test_mkdir -p $dir0 || error "creating dir $dir0"
9324 $SETSTRIPE -c1 $file1
9326 $SETSTRIPE -c2 $file2
9328 gen1=$($GETSTRIPE -g $file1)
9329 gen2=$($GETSTRIPE -g $file2)
9331 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
9332 gen=$($GETSTRIPE -g $file1)
9333 [[ $gen1 != $gen ]] ||
9334 "Layout generation on $file1 does not change"
9335 gen=$($GETSTRIPE -g $file2)
9336 [[ $gen2 != $gen ]] ||
9337 "Layout generation on $file2 does not change"
9339 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
9340 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
9342 run_test 184a "Basic layout swap"
9345 check_swap_layouts_support && return 0
9347 dir0=$DIR/$tdir/$testnum
9348 mkdir -p $dir0 || error "creating dir $dir0"
9355 $SETSTRIPE -c1 $file1
9356 $SETSTRIPE -c2 $file2
9357 $SETSTRIPE -c1 $file3
9358 chown $RUNAS_ID $file3
9359 gen1=$($GETSTRIPE -g $file1)
9360 gen2=$($GETSTRIPE -g $file2)
9362 $LFS swap_layouts $dir1 $dir2 &&
9363 error "swap of directories layouts should fail"
9364 $LFS swap_layouts $dir1 $file1 &&
9365 error "swap of directory and file layouts should fail"
9366 $RUNAS $LFS swap_layouts $file1 $file2 &&
9367 error "swap of file we cannot write should fail"
9368 $LFS swap_layouts $file1 $file3 &&
9369 error "swap of file with different owner should fail"
9370 /bin/true # to clear error code
9372 run_test 184b "Forbidden layout swap (will generate errors)"
9375 check_swap_layouts_support && return 0
9377 dir0=$DIR/$tdir/$testnum
9378 mkdir -p $dir0 || error "creating dir $dir0"
9383 # create a file large enough for the concurent test
9384 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
9385 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
9386 echo "ref file size: ref1(`stat -c %s $ref1`), ref2(`stat -c %s $ref2`)"
9389 dd if=$ref1 of=$file1 bs=64k &
9390 sleep 0.$((RANDOM % 5 + 1))
9392 $LFS swap_layouts $file1 $file2
9395 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
9396 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
9398 # how many bytes copied before swapping layout
9399 local copied=`stat -c %s $file2`
9400 local remaining=`stat -c %s $ref1`
9401 remaining=$((remaining - copied))
9402 echo "Copied $copied bytes before swapping layout..."
9404 cmp -n $copied $file1 $ref2 ||
9405 error "Content mismatch [0, $copied) of ref2 and file1"
9406 cmp -n $copied $file2 $ref1 ||
9407 error "Content mismatch [0, $copied) of ref1 and file2"
9408 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
9409 error "Content mismatch [$copied, EOF) of ref1 and file1"
9412 rm -f $ref1 $ref2 $file1 $file2
9414 run_test 184c "Concurrent write and layout swap"
9417 check_file_in_pool()
9422 local res=$($GETSTRIPE $file | grep 0x | cut -f2)
9425 for t in $tlist ; do
9426 [ "$i" -eq "$t" ] && continue 2
9429 echo "pool list: $tlist"
9430 echo "striping: $res"
9431 error_noexit "$file not allocated in $pool"
9438 echo "Creating new pool"
9441 create_pool $FSNAME.$pool ||
9442 { error_noexit "No pool created, result code $?"; return 1; }
9443 [ $($LFS pool_list $FSNAME | grep -c $pool) -eq 1 ] ||
9444 { error_noexit "$pool not in lfs pool_list"; return 2; }
9447 pool_add_targets() {
9448 echo "Adding targets to pool"
9454 local list=$(seq $first $step $last)
9456 local t=$(for i in $list; do printf "$FSNAME-OST%04x_UUID " $i; done)
9457 do_facet mgs $LCTL pool_add \
9458 $FSNAME.$pool $FSNAME-OST[$first-$last/$step]
9459 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$pool \
9460 | sort -u | tr '\n' ' ' " "$t" || {
9461 error_noexit "Add to pool failed"
9464 local lfscount=$($LFS pool_list $FSNAME.$pool | grep -c "\-OST")
9465 local addcount=$(((last - first) / step + 1))
9466 [ $lfscount -eq $addcount ] || {
9467 error_noexit "lfs pool_list bad ost count" \
9468 "$lfscount != $addcount"
9476 echo "Setting pool on directory $tdir"
9478 $SETSTRIPE -c 2 -p $pool $tdir && return 0
9480 error_noexit "Cannot set pool $pool to $tdir"
9487 echo "Checking pool on directory $tdir"
9489 local res=$($GETSTRIPE --pool $tdir | sed "s/\s*$//")
9490 [ "$res" = "$pool" ] && return 0
9492 error_noexit "Pool on '$tdir' is '$res', not '$pool'"
9496 pool_dir_rel_path() {
9497 echo "Testing relative path works well"
9502 mkdir -p $root/$tdir/$tdir
9504 pool_set_dir $pool $tdir || return 1
9505 pool_set_dir $pool ./$tdir || return 2
9506 pool_set_dir $pool ../$tdir || return 3
9507 pool_set_dir $pool ../$tdir/$tdir || return 4
9508 rm -rf $tdir; cd - > /dev/null
9511 pool_alloc_files() {
9512 echo "Checking files allocation from directory pool"
9519 for i in $(seq -w 1 $count)
9521 local file=$tdir/file-$i
9523 check_file_in_pool $file $pool "$tlist" || \
9524 failed=$((failed + 1))
9526 [ "$failed" = 0 ] && return 0
9528 error_noexit "$failed files not allocated in $pool"
9532 pool_create_files() {
9533 echo "Creating files in pool"
9541 for i in $(seq -w 1 $count)
9543 local file=$tdir/spoo-$i
9544 $SETSTRIPE -p $pool $file
9545 check_file_in_pool $file $pool "$tlist" || \
9546 failed=$((failed + 1))
9548 [ "$failed" = 0 ] && return 0
9550 error_noexit "$failed files not allocated in $pool"
9555 echo "Checking 'lfs df' output"
9558 local t=$($LCTL get_param -n lov.$FSNAME-clilov-*.pools.$pool |
9560 local res=$($LFS df --pool $FSNAME.$pool |
9562 grep "$FSNAME-OST" |
9564 [ "$res" = "$t" ] && return 0
9566 error_noexit "Pools OSTs '$t' is not '$res' that lfs df reports"
9570 pool_file_rel_path() {
9571 echo "Creating files in a pool with relative pathname"
9576 { error_noexit "unable to create $tdir"; return 1 ; }
9577 local file="/..$tdir/$tfile-1"
9578 $SETSTRIPE -p $pool $file ||
9579 { error_noexit "unable to create $file" ; return 2 ; }
9582 $SETSTRIPE -p $pool $tfile-2 || {
9583 error_noexit "unable to create $tfile-2 in $tdir"
9588 pool_remove_first_target() {
9589 echo "Removing first target from a pool"
9592 local pname="lov.$FSNAME-*.pools.$pool"
9593 local t=$($LCTL get_param -n $pname | head -1)
9594 do_facet mgs $LCTL pool_remove $FSNAME.$pool $t
9595 wait_update $HOSTNAME "lctl get_param -n $pname | grep $t" "" || {
9596 error_noexit "$t not removed from $FSNAME.$pool"
9601 pool_remove_all_targets() {
9602 echo "Removing all targets from pool"
9605 local pname="lov.$FSNAME-*.pools.$pool"
9606 for t in $($LCTL get_param -n $pname | sort -u)
9608 do_facet mgs $LCTL pool_remove $FSNAME.$pool $t
9610 wait_update $HOSTNAME "lctl get_param -n $pname" "" || {
9611 error_noexit "Pool $FSNAME.$pool cannot be drained"
9614 # striping on an empty/nonexistant pool should fall back
9615 # to "pool of everything"
9617 error_noexit "failed to use fallback striping for empty pool"
9620 # setstripe on an empty pool should fail
9621 $SETSTRIPE -p $pool $file 2>/dev/null && {
9622 error_noexit "expected failure when creating file" \
9630 echo "Destroying pool"
9634 do_facet mgs $LCTL pool_destroy $FSNAME.$pool
9637 # striping on an empty/nonexistant pool should fall back
9638 # to "pool of everything"
9640 error_noexit "failed to use fallback striping for missing pool"
9643 # setstripe on an empty pool should fail
9644 $SETSTRIPE -p $pool $file 2>/dev/null && {
9645 error_noexit "expected failure when creating file" \
9650 # get param should return err once pool is gone
9651 if wait_update $HOSTNAME "lctl get_param -n \
9652 lov.$FSNAME-*.pools.$pool 2>/dev/null || echo foo" "foo"
9654 remove_pool_from_list $FSNAME.$pool
9657 error_noexit "Pool $FSNAME.$pool is not destroyed"
9662 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9663 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
9665 local POOL=${POOL:-cea1}
9666 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
9667 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
9670 local last_ost=$(($OSTCOUNT - 1))
9672 local ost_list=$(seq $first_ost $ost_step $last_ost)
9673 local ost_range="$first_ost $last_ost $ost_step"
9674 local test_path=$POOL_ROOT/$POOL_DIR_NAME
9675 local file_dir=$POOL_ROOT/file_tst
9679 # former test_200a test_200b
9680 pool_add $POOL || { rc=$? ; break; }
9681 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
9682 # former test_200c test_200d
9684 pool_set_dir $POOL $test_path || { rc=$? ; break; }
9685 pool_check_dir $POOL $test_path || { rc=$? ; break; }
9686 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
9687 || { rc=$? ; break; }
9688 # former test_200e test_200f
9689 local files=$((OSTCOUNT*3))
9690 pool_alloc_files $POOL $test_path $files "$ost_list" \
9691 || { rc=$? ; break; }
9692 pool_create_files $POOL $file_dir $files "$ost_list" \
9693 || { rc=$? ; break; }
9694 # former test_200g test_200h
9695 pool_lfs_df $POOL || { rc=$? ; break; }
9696 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
9698 # former test_201a test_201b test_201c
9699 pool_remove_first_target $POOL || { rc=$? ; break; }
9701 local f=$test_path/$tfile
9702 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
9703 pool_remove $POOL $f || { rc=$? ; break; }
9710 run_test 200 "OST pools"
9712 # usage: default_attr <count | size | offset>
9714 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
9717 # usage: check_default_stripe_attr
9718 check_default_stripe_attr() {
9719 ACTUAL=$($GETSTRIPE $* $DIR/$tdir)
9721 --stripe-count|--count)
9722 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
9723 --stripe-size|--size)
9724 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
9725 --stripe-index|--index)
9728 error "unknown getstripe attr '$1'"
9731 [ $ACTUAL != $EXPECTED ] &&
9732 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
9736 test_mkdir -p $DIR/$tdir
9737 $SETSTRIPE --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
9739 check_default_stripe_attr --stripe-count
9740 check_default_stripe_attr --stripe-size
9741 check_default_stripe_attr --stripe-index
9745 run_test 204a "Print default stripe attributes ================="
9748 test_mkdir -p $DIR/$tdir
9749 $SETSTRIPE --stripe-count 1 $DIR/$tdir
9751 check_default_stripe_attr --stripe-size
9752 check_default_stripe_attr --stripe-index
9756 run_test 204b "Print default stripe size and offset ==========="
9759 test_mkdir -p $DIR/$tdir
9760 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
9762 check_default_stripe_attr --stripe-count
9763 check_default_stripe_attr --stripe-index
9767 run_test 204c "Print default stripe count and offset ==========="
9770 test_mkdir -p $DIR/$tdir
9771 $SETSTRIPE --stripe-index 0 $DIR/$tdir
9773 check_default_stripe_attr --stripe-count
9774 check_default_stripe_attr --stripe-size
9778 run_test 204d "Print default stripe count and size ============="
9781 test_mkdir -p $DIR/$tdir
9782 $SETSTRIPE -d $DIR/$tdir
9784 check_default_stripe_attr --stripe-count --raw
9785 check_default_stripe_attr --stripe-size --raw
9786 check_default_stripe_attr --stripe-index --raw
9790 run_test 204e "Print raw stripe attributes ================="
9793 test_mkdir -p $DIR/$tdir
9794 $SETSTRIPE --stripe-count 1 $DIR/$tdir
9796 check_default_stripe_attr --stripe-size --raw
9797 check_default_stripe_attr --stripe-index --raw
9801 run_test 204f "Print raw stripe size and offset ==========="
9804 test_mkdir -p $DIR/$tdir
9805 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
9807 check_default_stripe_attr --stripe-count --raw
9808 check_default_stripe_attr --stripe-index --raw
9812 run_test 204g "Print raw stripe count and offset ==========="
9815 test_mkdir -p $DIR/$tdir
9816 $SETSTRIPE --stripe-index 0 $DIR/$tdir
9818 check_default_stripe_attr --stripe-count --raw
9819 check_default_stripe_attr --stripe-size --raw
9823 run_test 204h "Print raw stripe count and size ============="
9825 # Figure out which job scheduler is being used, if any,
9827 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
9829 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
9831 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
9833 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
9834 JOBENV=LOADL_STEP_ID
9835 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
9845 # clear old jobstats
9846 do_facet $SINGLEMDS lctl set_param mdt.*.job_stats="clear"
9847 do_facet ost1 lctl set_param obdfilter.*.job_stats="clear"
9849 # use a new JobID for this test, or we might see an old one
9850 [ "$JOBENV" = "FAKE_JOBID" ] && FAKE_JOBID=test_id.$testnum.$RANDOM
9854 log "Using JobID environment variable $JOBENV=$JOBVAL"
9856 if [ $JOBENV = "FAKE_JOBID" ]; then
9857 FAKE_JOBID=$JOBVAL $cmd
9862 if [ "$target" = "mdt" -o "$target" = "both" ]; then
9863 FACET="$SINGLEMDS" # will need to get MDS number for DNE
9864 do_facet $FACET lctl get_param mdt.*.job_stats |
9865 grep $JOBVAL || error "No job stats found on MDT $FACET"
9867 if [ "$target" = "ost" -o "$target" = "both" ]; then
9869 do_facet $FACET lctl get_param obdfilter.*.job_stats |
9870 grep $JOBVAL || error "No job stats found on OST $FACET"
9874 test_205() { # Job stats
9875 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9876 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
9877 skip "Server doesn't support jobstats" && return 0
9880 OLD_JOBENV=`$LCTL get_param -n jobid_var`
9881 if [ $OLD_JOBENV != $JOBENV ]; then
9882 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$JOBENV
9883 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" \
9888 cmd="mkdir $DIR/$tfile"
9889 verify_jobstats "$cmd" "mdt"
9891 cmd="rm -fr $DIR/$tfile"
9892 verify_jobstats "$cmd" "mdt"
9894 cmd="mknod $DIR/$tfile c 1 3"
9895 verify_jobstats "$cmd" "mdt"
9897 cmd="rm -f $DIR/$tfile"
9898 verify_jobstats "$cmd" "mdt"
9900 cmd="$SETSTRIPE -i 0 -c 1 $DIR/$tfile"
9901 verify_jobstats "$cmd" "mdt"
9903 cmd="touch $DIR/$tfile"
9904 verify_jobstats "$cmd" "both"
9906 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
9907 verify_jobstats "$cmd" "ost"
9909 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
9910 verify_jobstats "$cmd" "ost"
9912 cmd="$TRUNCATE $DIR/$tfile 0"
9913 verify_jobstats "$cmd" "both"
9915 cmd="mv -f $DIR/$tfile $DIR/jobstats_test_rename"
9916 verify_jobstats "$cmd" "mdt"
9919 rm -f $DIR/jobstats_test_rename
9921 if [ $OLD_JOBENV != $JOBENV ]; then
9922 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$OLD_JOBENV
9923 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" \
9924 $OLD_JOBENV || return 1
9927 run_test 205 "Verify job stats"
9929 # LU-1480, LU-1773 and LU-1657
9932 lfs setstripe -c -1 $DIR/$tdir
9933 #define OBD_FAIL_LOV_INIT 0x1403
9934 $LCTL set_param fail_loc=0xa0001403
9935 $LCTL set_param fail_val=1
9936 touch $DIR/$tdir/$tfile || true
9938 run_test 206 "fail lov_init_raid0() doesn't lbug"
9941 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
9942 local fsz=`stat -c %s $DIR/$tfile`
9943 cancel_lru_locks mdc
9945 # do not return layout in getattr intent
9946 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
9947 $LCTL set_param fail_loc=0x170
9948 local sz=`stat -c %s $DIR/$tfile`
9950 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
9954 run_test 207a "can refresh layout at glimpse"
9957 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
9958 local cksum=`md5sum $DIR/$tfile`
9959 local fsz=`stat -c %s $DIR/$tfile`
9960 cancel_lru_locks mdc
9961 cancel_lru_locks osc
9963 # do not return layout in getattr intent
9964 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
9965 $LCTL set_param fail_loc=0x171
9967 # it will refresh layout after the file is opened but before read issues
9968 echo checksum is "$cksum"
9969 echo "$cksum" |md5sum -c --quiet || error "file differs"
9973 run_test 207b "can refresh layout at open"
9977 size=$((size % 8192 + 1))
9978 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
9979 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
9980 rm -f $DIR/f212 $DIR/f212.xyz
9982 run_test 212 "Sendfile test ============================================"
9985 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
9986 cancel_lru_locks osc
9987 lctl set_param fail_loc=0x8000040f
9988 # generate a read lock
9989 cat $DIR/$tfile > /dev/null
9990 # write to the file, it will try to cancel the above read lock.
9991 cat /etc/hosts >> $DIR/$tfile
9993 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
9995 test_214() { # for bug 20133
9996 test_mkdir -p $DIR/d214p/d214c
9997 for (( i=0; i < 340; i++ )) ; do
9998 touch $DIR/d214p/d214c/a$i
10001 ls -l $DIR/d214p || error "ls -l $DIR/d214p failed"
10002 mv $DIR/d214p/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
10003 ls $DIR/d214c || error "ls $DIR/d214c failed"
10004 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
10006 run_test 214 "hash-indexed directory test - bug 20133"
10008 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
10009 create_lnet_proc_files() {
10010 cat /proc/sys/lnet/$1 >$TMP/lnet_$1.out || error "cannot read /proc/sys/lnet/$1"
10011 sysctl lnet.$1 >$TMP/lnet_$1.sys_tmp || error "cannot read lnet.$1"
10013 sed "s/^lnet.$1\ =\ //g" "$TMP/lnet_$1.sys_tmp" >$TMP/lnet_$1.sys
10014 rm -f "$TMP/lnet_$1.sys_tmp"
10017 # counterpart of create_lnet_proc_files
10018 remove_lnet_proc_files() {
10019 rm -f $TMP/lnet_$1.out $TMP/lnet_$1.sys
10022 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
10023 # 3rd arg as regexp for body
10024 check_lnet_proc_stats() {
10025 local l=$(cat "$TMP/lnet_$1" |wc -l)
10026 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
10028 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
10031 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
10032 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
10033 # optional and can be regexp for 2nd line (lnet.routes case)
10034 check_lnet_proc_entry() {
10035 local blp=2 # blp stands for 'position of 1st line of body'
10036 [ "$5" = "" ] || blp=3 # lnet.routes case
10038 local l=$(cat "$TMP/lnet_$1" |wc -l)
10039 # subtracting one from $blp because the body can be empty
10040 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
10042 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
10043 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
10045 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
10046 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
10048 # bail out if any unexpected line happened
10049 sed -n "$blp~1 p" "$TMP/lnet_$1" |grep -Ev "$3"
10050 [ "$?" != 0 ] || error "$2 misformatted"
10053 test_215() { # for bugs 18102, 21079, 21517
10054 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10055 local N='(0|[1-9][0-9]*)' # non-negative numeric
10056 local P='[1-9][0-9]*' # positive numeric
10057 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
10058 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
10059 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
10060 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
10062 local L1 # regexp for 1st line
10063 local L2 # regexp for 2nd line (optional)
10064 local BR # regexp for the rest (body)
10066 # /proc/sys/lnet/stats should look as 11 space-separated non-negative numerics
10067 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
10068 create_lnet_proc_files "stats"
10069 check_lnet_proc_stats "stats.out" "/proc/sys/lnet/stats" "$BR"
10070 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
10071 remove_lnet_proc_files "stats"
10073 # /proc/sys/lnet/routes should look like this:
10074 # Routing disabled/enabled
10075 # net hops state router
10076 # where net is a string like tcp0, hops >= 0, state is up/down,
10077 # router is a string like 192.168.1.1@tcp2
10078 L1="^Routing (disabled|enabled)$"
10079 L2="^net +hops +state +router$"
10080 BR="^$NET +$N +(up|down) +$NID$"
10081 create_lnet_proc_files "routes"
10082 check_lnet_proc_entry "routes.out" "/proc/sys/lnet/routes" "$BR" "$L1" "$L2"
10083 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
10084 remove_lnet_proc_files "routes"
10086 # /proc/sys/lnet/routers should look like this:
10087 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
10088 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
10089 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
10090 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
10091 L1="^ref +rtr_ref +alive_cnt +state +last_ping +ping_sent +deadline +down_ni +router$"
10092 BR="^$P +$P +$N +(up|down) +$N +(0|1) +$I +$I +$NID$"
10093 create_lnet_proc_files "routers"
10094 check_lnet_proc_entry "routers.out" "/proc/sys/lnet/routers" "$BR" "$L1"
10095 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
10096 remove_lnet_proc_files "routers"
10098 # /proc/sys/lnet/peers should look like this:
10099 # nid refs state last max rtr min tx min queue
10100 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
10101 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
10102 # numeric (0 or >0 or <0), queue >= 0.
10103 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
10104 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
10105 create_lnet_proc_files "peers"
10106 check_lnet_proc_entry "peers.out" "/proc/sys/lnet/peers" "$BR" "$L1"
10107 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
10108 remove_lnet_proc_files "peers"
10110 # /proc/sys/lnet/buffers should look like this:
10111 # pages count credits min
10112 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
10113 L1="^pages +count +credits +min$"
10114 BR="^ +$N +$N +$I +$I$"
10115 create_lnet_proc_files "buffers"
10116 check_lnet_proc_entry "buffers.out" "/proc/sys/lnet/buffers" "$BR" "$L1"
10117 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
10118 remove_lnet_proc_files "buffers"
10120 # /proc/sys/lnet/nis should look like this:
10121 # nid status alive refs peer rtr max tx min
10122 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
10123 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
10124 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
10125 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
10126 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
10127 create_lnet_proc_files "nis"
10128 check_lnet_proc_entry "nis.out" "/proc/sys/lnet/nis" "$BR" "$L1"
10129 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
10130 remove_lnet_proc_files "nis"
10132 # can we successfully write to /proc/sys/lnet/stats?
10133 echo "0" >/proc/sys/lnet/stats || error "cannot write to /proc/sys/lnet/stats"
10134 sysctl -w lnet.stats=0 || error "cannot write to lnet.stats"
10136 run_test 215 "/proc/sys/lnet exists and has proper content - bugs 18102, 21079, 21517"
10138 test_216() { # bug 20317
10139 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10140 remote_ost_nodsh && skip "remote OST with nodsh" && return
10142 local p="$TMP/sanityN-$TESTNAME.parameters"
10143 save_lustre_params $HOSTNAME "osc.*.contention_seconds" > $p
10144 for node in $(osts_nodes); do
10145 save_lustre_params $node "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
10146 save_lustre_params $node "ldlm.namespaces.filter-*.contended_locks" >> $p
10147 save_lustre_params $node "ldlm.namespaces.filter-*.contention_seconds" >> $p
10151 # agressive lockless i/o settings
10152 for node in $(osts_nodes); do
10153 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'
10155 lctl set_param -n osc.*.contention_seconds 60
10157 $DIRECTIO write $DIR/$tfile 0 10 4096
10158 $CHECKSTAT -s 40960 $DIR/$tfile
10160 # disable lockless i/o
10161 for node in $(osts_nodes); do
10162 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'
10164 lctl set_param -n osc.*.contention_seconds 0
10167 dd if=/dev/zero of=$DIR/$tfile count=0
10168 $CHECKSTAT -s 0 $DIR/$tfile
10170 restore_lustre_params <$p
10174 run_test 216 "check lockless direct write works and updates file size and kms correctly"
10176 test_217() { # bug 22430
10177 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10181 for node in $(nodes_list); do
10182 nid=$(host_nids_address $node $NETTYPE)
10183 if [[ $nid = *-* ]] ; then
10184 echo "lctl ping $nid@$NETTYPE"
10185 lctl ping $nid@$NETTYPE
10187 echo "skipping $node (no hyphen detected)"
10191 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
10194 # do directio so as not to populate the page cache
10195 log "creating a 10 Mb file"
10196 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
10197 log "starting reads"
10198 dd if=$DIR/$tfile of=/dev/null bs=4096 &
10199 log "truncating the file"
10200 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
10202 kill %+ || true # reads might have finished
10203 echo "wait until dd is finished"
10205 log "removing the temporary file"
10206 rm -rf $DIR/$tfile || error "tmp file removal failed"
10208 run_test 218 "parallel read and truncate should not deadlock ======================="
10211 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10212 # write one partial page
10213 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
10214 # set no grant so vvp_io_commit_write will do sync write
10215 $LCTL set_param fail_loc=0x411
10216 # write a full page at the end of file
10217 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
10219 $LCTL set_param fail_loc=0
10220 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
10221 $LCTL set_param fail_loc=0x411
10222 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
10224 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
10226 test_220() { #LU-325
10227 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10228 remote_ost_nodsh && skip "remote OST with nodsh" && return
10231 test_mkdir -p $DIR/$tdir
10232 local OST=$(lfs osts | grep ${OSTIDX}": " | \
10233 awk '{print $2}' | sed -e 's/_UUID$//')
10236 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
10237 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
10238 osc.$mdtosc_proc1.prealloc_last_id)
10239 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
10240 osc.$mdtosc_proc1.prealloc_next_id)
10244 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
10245 #define OBD_FAIL_OST_ENOINO 0x229
10246 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
10247 do_facet mgs $LCTL pool_new $FSNAME.$TESTNAME || return 1
10248 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
10250 $SETSTRIPE $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
10252 MDSOBJS=$((last_id - next_id))
10253 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
10255 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
10256 echo "OST still has $count kbytes free"
10258 echo "create $MDSOBJS files @next_id..."
10259 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
10261 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
10262 osc.$mdtosc_proc1.prealloc_last_id)
10263 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
10264 osc.$mdtosc_proc1.prealloc_next_id)
10266 echo "after creation, last_id=$last_id2, next_id=$next_id2"
10271 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
10272 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
10274 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST || return 4
10275 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME || return 5
10276 echo "unlink $MDSOBJS files @$next_id..."
10277 unlinkmany $DIR/$tdir/f $MDSOBJS || return 6
10279 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
10282 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10283 dd if=`which date` of=$MOUNT/date oflag=sync
10284 chmod +x $MOUNT/date
10286 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
10287 $LCTL set_param fail_loc=0x80001401
10289 $MOUNT/date > /dev/null
10292 run_test 221 "make sure fault and truncate race to not cause OOM"
10295 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10297 test_mkdir -p $DIR/$tdir
10298 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
10299 createmany -o $DIR/$tdir/$tfile 10
10300 cancel_lru_locks mdc
10301 cancel_lru_locks osc
10302 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
10303 $LCTL set_param fail_loc=0x31a
10304 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
10305 $LCTL set_param fail_loc=0
10308 run_test 222a "AGL for ls should not trigger CLIO lock failure ================"
10311 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10313 test_mkdir -p $DIR/$tdir
10314 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
10315 createmany -o $DIR/$tdir/$tfile 10
10316 cancel_lru_locks mdc
10317 cancel_lru_locks osc
10318 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
10319 $LCTL set_param fail_loc=0x31a
10320 rm -r $DIR/$tdir || "AGL for rmdir failed"
10321 $LCTL set_param fail_loc=0
10323 run_test 222b "AGL for rmdir should not trigger CLIO lock failure ============="
10326 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10328 test_mkdir -p $DIR/$tdir
10329 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
10330 createmany -o $DIR/$tdir/$tfile 10
10331 cancel_lru_locks mdc
10332 cancel_lru_locks osc
10333 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
10334 $LCTL set_param fail_loc=0x31b
10335 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
10336 $LCTL set_param fail_loc=0
10339 run_test 223 "osc reenqueue if without AGL lock granted ======================="
10341 test_224a() { # LU-1039, MRP-303
10342 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10343 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
10344 $LCTL set_param fail_loc=0x508
10345 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
10346 $LCTL set_param fail_loc=0
10349 run_test 224a "Don't panic on bulk IO failure"
10351 test_224b() { # LU-1039, MRP-303
10352 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10353 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
10354 cancel_lru_locks osc
10355 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
10356 $LCTL set_param fail_loc=0x515
10357 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
10358 $LCTL set_param fail_loc=0
10361 run_test 224b "Don't panic on bulk IO failure"
10363 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
10365 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10366 if [ -z ${MDSSURVEY} ]; then
10367 skip_env "mds-survey not found" && return
10369 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
10370 { skip "Need MDS version at least 2.2.51"; return; }
10372 local mds=$(facet_host $SINGLEMDS)
10373 local target=$(do_nodes $mds 'lctl dl' | \
10374 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
10376 local cmd1="file_count=1000 thrhi=4"
10377 local cmd2="dir_count=2 layer=mdd stripe_count=0"
10378 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
10379 local cmd="$cmd1 $cmd2 $cmd3"
10381 rm -f ${TMP}/mds_survey*
10383 eval $cmd || error "mds-survey with zero-stripe failed"
10384 cat ${TMP}/mds_survey*
10385 rm -f ${TMP}/mds_survey*
10387 run_test 225a "Metadata survey sanity with zero-stripe"
10390 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10391 if [ -z ${MDSSURVEY} ]; then
10392 skip_env "mds-survey not found" && return
10394 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
10395 { skip "Need MDS version at least 2.2.51"; return; }
10397 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
10398 skip_env "Need to mount OST to test" && return
10401 local mds=$(facet_host $SINGLEMDS)
10402 local target=$(do_nodes $mds 'lctl dl' | \
10403 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
10405 local cmd1="file_count=1000 thrhi=4"
10406 local cmd2="dir_count=2 layer=mdd stripe_count=1"
10407 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
10408 local cmd="$cmd1 $cmd2 $cmd3"
10410 rm -f ${TMP}/mds_survey*
10412 eval $cmd || error "mds-survey with stripe_count failed"
10413 cat ${TMP}/mds_survey*
10414 rm -f ${TMP}/mds_survey*
10416 run_test 225b "Metadata survey sanity with stripe_count = 1"
10418 mcreate_path2fid () {
10424 local path=$DIR/$tdir/$name
10429 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
10430 error "cannot create $desc"
10432 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
10434 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
10436 fid_path=$($LFS fid2path $MOUNT $fid)
10438 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
10440 [ "$path" == "$fid_path" ] ||
10441 error "fid2path returned $fid_path, expected $path"
10443 echo "pass with $path and $fid"
10448 mkdir -p $DIR/$tdir
10450 mcreate_path2fid 0010666 0 0 fifo "FIFO"
10451 mcreate_path2fid 0020666 1 3 null "character special file (null)"
10452 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
10453 mcreate_path2fid 0040666 0 0 dir "directory"
10454 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
10455 mcreate_path2fid 0100666 0 0 file "regular file"
10456 mcreate_path2fid 0120666 0 0 link "symbolic link"
10457 mcreate_path2fid 0140666 0 0 sock "socket"
10459 run_test 226 "call path2fid and fid2path on files of all type"
10461 # LU-1299 Executing or running ldd on a truncated executable does not
10462 # cause an out-of-memory condition.
10464 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10465 dd if=`which date` of=$MOUNT/date bs=1k count=1
10466 chmod +x $MOUNT/date
10468 $MOUNT/date > /dev/null
10469 ldd $MOUNT/date > /dev/null
10472 run_test 227 "running truncated executable does not cause OOM"
10474 # LU-1512 try to reuse idle OI blocks
10476 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10477 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
10478 skip "non-ldiskfs backend" && return
10480 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
10481 local myDIR=$DIR/$tdir
10484 #define OBD_FAIL_SEQ_EXHAUST 0x1002
10485 $LCTL set_param fail_loc=0x80001002
10486 createmany -o $myDIR/t- 10000
10487 $LCTL set_param fail_loc=0
10488 # The guard is current the largest FID holder
10490 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
10492 local IDX=$(($SEQ % 64))
10494 do_facet $SINGLEMDS sync
10495 # Make sure journal flushed.
10497 local blk1=$(do_facet $SINGLEMDS \
10498 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
10499 grep Blockcount | awk '{print $4}')
10501 # Remove old files, some OI blocks will become idle.
10502 unlinkmany $myDIR/t- 10000
10503 # Create new files, idle OI blocks should be reused.
10504 createmany -o $myDIR/t- 2000
10505 do_facet $SINGLEMDS sync
10506 # Make sure journal flushed.
10508 local blk2=$(do_facet $SINGLEMDS \
10509 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
10510 grep Blockcount | awk '{print $4}')
10512 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
10514 run_test 228a "try to reuse idle OI blocks"
10517 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10518 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
10519 skip "non-ldiskfs backend" && return
10521 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
10522 local myDIR=$DIR/$tdir
10525 #define OBD_FAIL_SEQ_EXHAUST 0x1002
10526 $LCTL set_param fail_loc=0x80001002
10527 createmany -o $myDIR/t- 10000
10528 $LCTL set_param fail_loc=0
10529 # The guard is current the largest FID holder
10531 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
10533 local IDX=$(($SEQ % 64))
10535 do_facet $SINGLEMDS sync
10536 # Make sure journal flushed.
10538 local blk1=$(do_facet $SINGLEMDS \
10539 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
10540 grep Blockcount | awk '{print $4}')
10542 # Remove old files, some OI blocks will become idle.
10543 unlinkmany $myDIR/t- 10000
10546 stop $SINGLEMDS || error "Fail to stop MDT."
10548 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
10550 df $MOUNT || error "Fail to df."
10551 # Create new files, idle OI blocks should be reused.
10552 createmany -o $myDIR/t- 2000
10553 do_facet $SINGLEMDS sync
10554 # Make sure journal flushed.
10556 local blk2=$(do_facet $SINGLEMDS \
10557 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
10558 grep Blockcount | awk '{print $4}')
10560 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
10562 run_test 228b "idle OI blocks can be reused after MDT restart"
10566 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10567 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
10568 skip "non-ldiskfs backend" && return
10570 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
10571 local myDIR=$DIR/$tdir
10574 #define OBD_FAIL_SEQ_EXHAUST 0x1002
10575 $LCTL set_param fail_loc=0x80001002
10576 # 20000 files can guarantee there are index nodes in the OI file
10577 createmany -o $myDIR/t- 20000
10578 $LCTL set_param fail_loc=0
10579 # The guard is current the largest FID holder
10581 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
10583 local IDX=$(($SEQ % 64))
10585 do_facet $SINGLEMDS sync
10586 # Make sure journal flushed.
10588 local blk1=$(do_facet $SINGLEMDS \
10589 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
10590 grep Blockcount | awk '{print $4}')
10592 # Remove old files, some OI blocks will become idle.
10593 unlinkmany $myDIR/t- 20000
10595 # The OI file should become empty now
10597 # Create new files, idle OI blocks should be reused.
10598 createmany -o $myDIR/t- 2000
10599 do_facet $SINGLEMDS sync
10600 # Make sure journal flushed.
10602 local blk2=$(do_facet $SINGLEMDS \
10603 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
10604 grep Blockcount | awk '{print $4}')
10606 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
10608 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
10611 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10612 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
10615 mkdir -p $DIR/$tdir/test_230_local
10616 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230_local)
10617 [ $mdt_idx -ne 0 ] &&
10618 error "create local directory on wrong MDT $mdt_idx"
10620 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
10621 error "create remote directory failed"
10622 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230)
10623 [ $mdt_idx -ne $MDTIDX ] &&
10624 error "create remote directory on wrong MDT $mdt_idx"
10626 createmany -o $DIR/$tdir/test_230/t- 10 ||
10627 error "create files on remote directory failed"
10628 mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230/t-0)
10629 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
10630 rm -r $DIR/$tdir || error "unlink remote directory failed"
10632 run_test 230a "Create remote directory and files under the remote directory"
10635 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10636 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
10638 local remote_dir=$DIR/$tdir/remote_dir
10641 mkdir -p $DIR/$tdir
10642 $LFS mkdir -i $MDTIDX $remote_dir ||
10643 error "create remote directory failed"
10645 $LFS mkdir -i 0 $remote_dir/new_dir &&
10646 error "nested remote directory create succeed!"
10648 do_facet mds$((MDTIDX + 1)) lctl set_param mdt.*.enable_remote_dir=1
10649 $LFS mkdir -i 0 $remote_dir/new_dir || rc=$?
10650 do_facet mds$((MDTIDX + 1)) lctl set_param mdt.*.enable_remote_dir=0
10653 error "create remote directory failed after set enable_remote_dir"
10655 rm -r $DIR/$tdir || error "unlink remote directory failed"
10657 run_test 230b "nested remote directory should be failed"
10661 # For simplicity this test assumes that max_pages_per_rpc
10662 # is the same across all OSCs
10663 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -1)
10664 local bulk_size=$((max_pages * 4096))
10666 mkdir -p $DIR/$tdir
10668 # clear the OSC stats
10669 $LCTL set_param osc.*.stats=0 &>/dev/null
10671 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
10672 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
10673 oflag=direct &>/dev/null || error "dd failed"
10675 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
10676 if [ x$nrpcs != "x1" ]; then
10677 error "found $nrpc ost_write RPCs, not 1 as expected"
10680 # Drop the OSC cache, otherwise we will read from it
10681 cancel_lru_locks osc
10683 # clear the OSC stats
10684 $LCTL set_param osc.*.stats=0 &>/dev/null
10686 # Client reads $bulk_size.
10687 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
10688 iflag=direct &>/dev/null || error "dd failed"
10690 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
10691 if [ x$nrpcs != "x1" ]; then
10692 error "found $nrpc ost_read RPCs, not 1 as expected"
10695 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
10698 mkdir -p $DIR/$tdir
10700 for i in {0..1023}; do
10701 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
10702 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
10703 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
10707 run_test 231b "must not assert on fully utilized OST request buffer"
10710 # tests that do cleanup/setup should be run at the end
10714 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10716 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
10717 $LCTL set_param fail_loc=0x903
10718 # cancel_lru_locks mgc - does not work due to lctl set_param syntax
10719 for ls in /proc/fs/lustre/ldlm/namespaces/MGC*/lru_size; do
10722 FAIL_ON_ERROR=true cleanup
10723 FAIL_ON_ERROR=true setup
10725 run_test 900 "umount should not race with any mgc requeue thread"
10728 check_and_cleanup_lustre
10729 if [ "$I_MOUNTED" != "yes" ]; then
10730 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true