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 export OLD_RESENDCOUNT=""
6469 set_resend_count () {
6470 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
6471 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -1)
6472 lctl set_param -n $PROC_RESENDCOUNT $1
6473 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
6476 [ "$SLOW" = "no" ] && set_resend_count 4 # for reduce test_118* time (bug 14842)
6478 # Reset async IO behavior after error case
6480 FILE=$DIR/reset_async
6482 # Ensure all OSCs are cleared
6483 $SETSTRIPE -c -1 $FILE
6484 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
6489 test_118a() #bug 11710
6491 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6494 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6495 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6496 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
6498 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6499 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6504 run_test 118a "verify O_SYNC works =========="
6508 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6509 remote_ost_nodsh && skip "remote OST with nodsh" && return
6513 #define OBD_FAIL_OST_ENOENT 0x217
6514 set_nodes_failloc "$(osts_nodes)" 0x217
6515 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6517 set_nodes_failloc "$(osts_nodes)" 0
6518 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6519 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6522 if [[ $RC -eq 0 ]]; then
6523 error "Must return error due to dropped pages, rc=$RC"
6527 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6528 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6532 echo "Dirty pages not leaked on ENOENT"
6534 # Due to the above error the OSC will issue all RPCs syncronously
6535 # until a subsequent RPC completes successfully without error.
6536 $MULTIOP $DIR/$tfile Ow4096yc
6541 run_test 118b "Reclaim dirty pages on fatal error =========="
6545 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6546 remote_ost_nodsh && skip "remote OST with nodsh" && return
6550 #define OBD_FAIL_OST_EROFS 0x216
6551 set_nodes_failloc "$(osts_nodes)" 0x216
6553 # multiop should block due to fsync until pages are written
6554 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
6558 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
6559 error "Multiop failed to block on fsync, pid=$MULTIPID"
6562 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6564 if [[ $WRITEBACK -eq 0 ]]; then
6565 error "No page in writeback, writeback=$WRITEBACK"
6568 set_nodes_failloc "$(osts_nodes)" 0
6571 if [[ $RC -ne 0 ]]; then
6572 error "Multiop fsync failed, rc=$RC"
6575 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6576 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6578 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6579 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6583 echo "Dirty pages flushed via fsync on EROFS"
6586 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
6590 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6591 remote_ost_nodsh && skip "remote OST with nodsh" && return
6595 #define OBD_FAIL_OST_BRW_PAUSE_BULK
6596 set_nodes_failloc "$(osts_nodes)" 0x214
6597 # multiop should block due to fsync until pages are written
6598 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
6602 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
6603 error "Multiop failed to block on fsync, pid=$MULTIPID"
6606 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6608 if [[ $WRITEBACK -eq 0 ]]; then
6609 error "No page in writeback, writeback=$WRITEBACK"
6612 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
6613 set_nodes_failloc "$(osts_nodes)" 0
6615 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6616 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6618 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6619 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6623 echo "Dirty pages gaurenteed flushed via fsync"
6626 run_test 118d "Fsync validation inject a delay of the bulk =========="
6629 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6632 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
6633 lctl set_param fail_loc=0x8000040a
6635 # Should simulate EINVAL error which is fatal
6636 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6638 if [[ $RC -eq 0 ]]; then
6639 error "Must return error due to dropped pages, rc=$RC"
6642 lctl set_param fail_loc=0x0
6644 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6645 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6646 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6648 if [[ $LOCKED -ne 0 ]]; then
6649 error "Locked pages remain in cache, locked=$LOCKED"
6652 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6653 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6657 echo "No pages locked after fsync"
6662 run_test 118f "Simulate unrecoverable OSC side error =========="
6665 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6668 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
6669 lctl set_param fail_loc=0x406
6671 # simulate local -ENOMEM
6672 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6675 lctl set_param fail_loc=0
6676 if [[ $RC -eq 0 ]]; then
6677 error "Must return error due to dropped pages, rc=$RC"
6680 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6681 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6682 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6684 if [[ $LOCKED -ne 0 ]]; then
6685 error "Locked pages remain in cache, locked=$LOCKED"
6688 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6689 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6693 echo "No pages locked after fsync"
6698 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
6701 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6702 remote_ost_nodsh && skip "remote OST with nodsh" && return
6706 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
6707 set_nodes_failloc "$(osts_nodes)" 0x20e
6708 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
6709 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6712 set_nodes_failloc "$(osts_nodes)" 0
6713 if [[ $RC -eq 0 ]]; then
6714 error "Must return error due to dropped pages, rc=$RC"
6717 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6718 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6719 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6721 if [[ $LOCKED -ne 0 ]]; then
6722 error "Locked pages remain in cache, locked=$LOCKED"
6725 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6726 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6730 echo "No pages locked after fsync"
6734 run_test 118h "Verify timeout in handling recoverables errors =========="
6736 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
6739 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6740 remote_ost_nodsh && skip "remote OST with nodsh" && return
6744 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
6745 set_nodes_failloc "$(osts_nodes)" 0x20e
6747 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
6748 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
6751 set_nodes_failloc "$(osts_nodes)" 0
6755 if [[ $RC -ne 0 ]]; then
6756 error "got error, but should be not, rc=$RC"
6759 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6760 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6761 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
6762 if [[ $LOCKED -ne 0 ]]; then
6763 error "Locked pages remain in cache, locked=$LOCKED"
6766 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6767 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6771 echo "No pages locked after fsync"
6775 run_test 118i "Fix error before timeout in recoverable error =========="
6777 [ "$SLOW" = "no" ] && set_resend_count 4
6780 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6781 remote_ost_nodsh && skip "remote OST with nodsh" && return
6785 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
6786 set_nodes_failloc "$(osts_nodes)" 0x220
6788 # return -EIO from OST
6789 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6791 set_nodes_failloc "$(osts_nodes)" 0x0
6792 if [[ $RC -eq 0 ]]; then
6793 error "Must return error due to dropped pages, rc=$RC"
6796 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6797 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6798 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
6799 if [[ $LOCKED -ne 0 ]]; then
6800 error "Locked pages remain in cache, locked=$LOCKED"
6803 # in recoverable error on OST we want resend and stay until it finished
6804 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6805 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6809 echo "No pages locked after fsync"
6813 run_test 118j "Simulate unrecoverable OST side error =========="
6817 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6818 remote_ost_nodsh && skip "remote OSTs with nodsh" && return
6820 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
6821 set_nodes_failloc "$(osts_nodes)" 0x20e
6822 test_mkdir -p $DIR/$tdir
6824 for ((i=0;i<10;i++)); do
6825 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
6826 error "dd to $DIR/$tdir/$tfile-$i failed" )&
6833 set_nodes_failloc "$(osts_nodes)" 0
6836 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
6840 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6842 test_mkdir -p $DIR/$tdir
6843 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
6846 run_test 118l "fsync dir ========="
6848 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
6850 test_119a() # bug 11737
6852 BSIZE=$((512 * 1024))
6853 directio write $DIR/$tfile 0 1 $BSIZE
6854 # We ask to read two blocks, which is more than a file size.
6855 # directio will indicate an error when requested and actual
6856 # sizes aren't equeal (a normal situation in this case) and
6857 # print actual read amount.
6858 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
6859 if [ "$NOB" != "$BSIZE" ]; then
6860 error "read $NOB bytes instead of $BSIZE"
6864 run_test 119a "Short directIO read must return actual read amount"
6866 test_119b() # bug 11737
6868 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
6870 $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
6871 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
6873 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) || \
6874 error "direct read failed"
6877 run_test 119b "Sparse directIO read must return actual read amount"
6879 test_119c() # bug 13099
6882 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
6883 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
6886 run_test 119c "Testing for direct read hitting hole"
6888 test_119d() # bug 15950
6890 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6891 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
6892 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
6894 $SETSTRIPE $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
6895 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
6896 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
6897 lctl set_param fail_loc=0x40d
6898 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
6901 cat $DIR/$tfile > /dev/null &
6902 lctl set_param fail_loc=0
6905 log "the DIO writes have completed, now wait for the reads (should not block very long)"
6907 [ -n "`ps h -p $pid_reads -o comm`" ] && \
6908 error "the read rpcs have not completed in 2s"
6910 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
6912 run_test 119d "The DIO path should try to send a new rpc once one is completed"
6915 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6916 test_mkdir -p $DIR/$tdir
6917 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6918 skip "no early lock cancel on server" && return 0
6919 lru_resize_disable mdc
6920 lru_resize_disable osc
6921 cancel_lru_locks mdc
6922 stat $DIR/$tdir > /dev/null
6923 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6924 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6925 test_mkdir $DIR/$tdir/d1
6926 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6927 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6928 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6929 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6930 lru_resize_enable mdc
6931 lru_resize_enable osc
6933 run_test 120a "Early Lock Cancel: mkdir test"
6936 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6937 test_mkdir -p $DIR/$tdir
6938 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6939 skip "no early lock cancel on server" && return 0
6940 lru_resize_disable mdc
6941 lru_resize_disable osc
6942 cancel_lru_locks mdc
6943 stat $DIR/$tdir > /dev/null
6944 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6945 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6947 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6948 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6949 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6950 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6951 lru_resize_enable mdc
6952 lru_resize_enable osc
6954 run_test 120b "Early Lock Cancel: create test"
6957 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6958 test_mkdir -p $DIR/$tdir
6959 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6960 skip "no early lock cancel on server" && return 0
6961 lru_resize_disable mdc
6962 lru_resize_disable osc
6963 test_mkdir -p $DIR/$tdir/d1 $DIR/$tdir/d2
6964 touch $DIR/$tdir/d1/f1
6965 cancel_lru_locks mdc
6966 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
6967 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6968 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6969 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
6970 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6971 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6972 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6973 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6974 lru_resize_enable mdc
6975 lru_resize_enable osc
6977 run_test 120c "Early Lock Cancel: link test"
6980 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6981 test_mkdir -p $DIR/$tdir
6982 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6983 skip "no early lock cancel on server" && return 0
6984 lru_resize_disable mdc
6985 lru_resize_disable osc
6987 cancel_lru_locks mdc
6988 stat $DIR/$tdir > /dev/null
6989 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6990 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6991 chmod a+x $DIR/$tdir
6992 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6993 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6994 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6995 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6996 lru_resize_enable mdc
6997 lru_resize_enable osc
6999 run_test 120d "Early Lock Cancel: setattr test"
7002 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7003 test_mkdir -p $DIR/$tdir
7004 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7005 skip "no early lock cancel on server" && return 0
7006 lru_resize_disable mdc
7007 lru_resize_disable osc
7008 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
7009 cancel_lru_locks mdc
7010 cancel_lru_locks osc
7011 dd if=$DIR/$tdir/f1 of=/dev/null
7012 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
7013 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7014 awk '/ldlm_cancel/ {print $2}'`
7015 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7016 awk '/ldlm_bl_callback/ {print $2}'`
7017 unlink $DIR/$tdir/f1
7018 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7019 awk '/ldlm_cancel/ {print $2}'`
7020 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7021 awk '/ldlm_bl_callback/ {print $2}'`
7022 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7023 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7024 lru_resize_enable mdc
7025 lru_resize_enable osc
7027 run_test 120e "Early Lock Cancel: unlink test"
7030 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7031 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7032 skip "no early lock cancel on server" && return 0
7033 test_mkdir -p $DIR/$tdir
7034 lru_resize_disable mdc
7035 lru_resize_disable osc
7036 test_mkdir -p $DIR/$tdir/d1 $DIR/$tdir/d2
7037 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
7038 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
7039 cancel_lru_locks mdc
7040 cancel_lru_locks osc
7041 dd if=$DIR/$tdir/d1/f1 of=/dev/null
7042 dd if=$DIR/$tdir/d2/f2 of=/dev/null
7043 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
7044 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7045 awk '/ldlm_cancel/ {print $2}'`
7046 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7047 awk '/ldlm_bl_callback/ {print $2}'`
7048 mv $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
7049 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7050 awk '/ldlm_cancel/ {print $2}'`
7051 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7052 awk '/ldlm_bl_callback/ {print $2}'`
7053 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7054 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7055 lru_resize_enable mdc
7056 lru_resize_enable osc
7058 run_test 120f "Early Lock Cancel: rename test"
7061 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7062 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7063 skip "no early lock cancel on server" && return 0
7064 lru_resize_disable mdc
7065 lru_resize_disable osc
7067 echo create $count files
7068 test_mkdir -p $DIR/$tdir
7069 cancel_lru_locks mdc
7070 cancel_lru_locks osc
7073 can0=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7074 awk '/ldlm_cancel/ {print $2}'`
7075 blk0=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7076 awk '/ldlm_bl_callback/ {print $2}'`
7077 createmany -o $DIR/$tdir/f $count
7079 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7080 awk '/ldlm_cancel/ {print $2}'`
7081 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7082 awk '/ldlm_bl_callback/ {print $2}'`
7084 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
7085 echo rm $count files
7088 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7089 awk '/ldlm_cancel/ {print $2}'`
7090 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7091 awk '/ldlm_bl_callback/ {print $2}'`
7093 echo total: $count removes in $((t2-t1))
7094 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
7096 # wait for commitment of removal
7097 lru_resize_enable mdc
7098 lru_resize_enable osc
7100 run_test 120g "Early Lock Cancel: performance test"
7102 test_121() { #bug #10589
7103 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7105 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
7106 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
7107 lctl set_param fail_loc=0x310
7108 cancel_lru_locks osc > /dev/null
7109 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
7110 lctl set_param fail_loc=0
7111 [ "$reads" -eq "$writes" ] || error "read" $reads "blocks, must be" $writes
7113 run_test 121 "read cancel race ========="
7115 test_123a() { # was test 123, statahead(bug 11401)
7116 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7118 if [ -z "$(grep "processor.*: 1" /proc/cpuinfo)" ]; then
7119 log "testing on UP system. Performance may be not as good as expected."
7124 test_mkdir -p $DIR/$tdir
7125 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
7126 [ $NUMFREE -gt 100000 ] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
7128 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
7129 createmany -o $DIR/$tdir/$tfile $j $((i - j))
7131 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
7132 lctl set_param -n llite.*.statahead_max 0
7133 lctl get_param llite.*.statahead_max
7134 cancel_lru_locks mdc
7135 cancel_lru_locks osc
7137 time ls -l $DIR/$tdir | wc -l
7139 delta=$((etime - stime))
7140 log "ls $i files without statahead: $delta sec"
7141 lctl set_param llite.*.statahead_max=$max
7143 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
7144 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
7145 cancel_lru_locks mdc
7146 cancel_lru_locks osc
7148 time ls -l $DIR/$tdir | wc -l
7150 delta_sa=$((etime - stime))
7151 log "ls $i files with statahead: $delta_sa sec"
7152 lctl get_param -n llite.*.statahead_stats
7153 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
7155 [ $swrong -lt $ewrong ] && log "statahead was stopped, maybe too many locks held!"
7156 [ $delta -eq 0 -o $delta_sa -eq 0 ] && continue
7158 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
7159 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
7160 lctl set_param -n llite.*.statahead_max 0
7161 lctl get_param llite.*.statahead_max
7162 cancel_lru_locks mdc
7163 cancel_lru_locks osc
7165 time ls -l $DIR/$tdir | wc -l
7167 delta=$((etime - stime))
7168 log "ls $i files again without statahead: $delta sec"
7169 lctl set_param llite.*.statahead_max=$max
7170 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
7171 if [ $SLOWOK -eq 0 ]; then
7172 error "ls $i files is slower with statahead!"
7174 log "ls $i files is slower with statahead!"
7180 [ $delta -gt 20 ] && break
7181 [ $delta -gt 8 ] && MULT=$((50 / delta))
7182 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
7190 delta=$((etime - stime))
7191 log "rm -r $DIR/$tdir/: $delta seconds"
7193 lctl get_param -n llite.*.statahead_stats
7195 run_test 123a "verify statahead work"
7197 test_123b () { # statahead(bug 15027)
7198 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7199 test_mkdir -p $DIR/$tdir
7200 createmany -o $DIR/$tdir/$tfile-%d 1000
7202 cancel_lru_locks mdc
7203 cancel_lru_locks osc
7205 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
7206 lctl set_param fail_loc=0x80000803
7207 ls -lR $DIR/$tdir > /dev/null
7209 lctl set_param fail_loc=0x0
7210 lctl get_param -n llite.*.statahead_stats
7215 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
7218 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7219 [ -z "`lctl get_param -n mdc.*.connect_flags | grep lru_resize`" ] && \
7220 skip "no lru resize on server" && return 0
7222 test_mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
7224 log "create $NR files at $DIR/$tdir"
7225 createmany -o $DIR/$tdir/f $NR ||
7226 error "failed to create $NR files in $DIR/$tdir"
7228 cancel_lru_locks mdc
7229 ls -l $DIR/$tdir > /dev/null
7233 for VALUE in `lctl get_param ldlm.namespaces.*mdc-*.lru_size`; do
7234 local PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
7235 LRU_SIZE=$(lctl get_param -n $PARAM)
7236 if [ $LRU_SIZE -gt $(default_lru_size) ]; then
7237 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
7239 log "NS=$(basename $NSDIR)"
7244 if [ -z "$NSDIR" -o $LRU_SIZE -lt $(default_lru_size) ]; then
7245 skip "Not enough cached locks created!"
7252 # We know that lru resize allows one client to hold $LIMIT locks
7253 # for 10h. After that locks begin to be killed by client.
7255 local LIMIT=`lctl get_param -n $NSDIR.pool.limit`
7258 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
7259 # killing locks. Some time was spent for creating locks. This means
7260 # that up to the moment of sleep finish we must have killed some of
7261 # them (10-100 locks). This depends on how fast ther were created.
7262 # Many of them were touched in almost the same moment and thus will
7263 # be killed in groups.
7264 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
7266 # Use $LRU_SIZE_B here to take into account real number of locks
7267 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
7268 local LRU_SIZE_B=$LRU_SIZE
7270 local OLD_LVF=`lctl get_param -n $NSDIR.pool.lock_volume_factor`
7271 log "OLD_LVF=$OLD_LVF"
7272 lctl set_param -n $NSDIR.pool.lock_volume_factor $LVF
7274 # Let's make sure that we really have some margin. Client checks
7275 # cached locks every 10 sec.
7277 log "Sleep ${SLEEP} sec"
7279 while ((SEC<$SLEEP)); do
7283 LRU_SIZE=`lctl get_param -n $NSDIR/lru_size`
7287 lctl set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
7288 local LRU_SIZE_A=`lctl get_param -n $NSDIR.lru_size`
7290 [ $LRU_SIZE_B -gt $LRU_SIZE_A ] || {
7291 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
7292 unlinkmany $DIR/$tdir/f $NR
7296 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
7297 log "unlink $NR files at $DIR/$tdir"
7298 unlinkmany $DIR/$tdir/f $NR
7300 run_test 124a "lru resize ======================================="
7302 get_max_pool_limit()
7304 local limit=`lctl get_param -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit`
7307 if test $l -gt $max; then
7315 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7316 [ -z "`lctl get_param -n mdc.*.connect_flags | grep lru_resize`" ] && \
7317 skip "no lru resize on server" && return 0
7319 LIMIT=`get_max_pool_limit`
7321 NR=$(($(default_lru_size)*20))
7322 if [ $NR -gt $LIMIT ]; then
7323 log "Limit lock number by $LIMIT locks"
7326 lru_resize_disable mdc
7327 test_mkdir -p $DIR/$tdir/disable_lru_resize ||
7328 error "failed to create $DIR/$tdir/disable_lru_resize"
7330 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
7331 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
7332 cancel_lru_locks mdc
7335 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
7338 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
7341 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
7345 nolruresize_delta=$((etime-stime))
7346 log "ls -la time: $nolruresize_delta seconds"
7347 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
7348 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
7350 lru_resize_enable mdc
7351 test_mkdir -p $DIR/$tdir/enable_lru_resize ||
7352 error "failed to create $DIR/$tdir/enable_lru_resize"
7354 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
7355 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
7356 cancel_lru_locks mdc
7359 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
7362 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
7365 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
7369 lruresize_delta=$((etime-stime))
7370 log "ls -la time: $lruresize_delta seconds"
7371 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
7373 if [ $lruresize_delta -gt $nolruresize_delta ]; then
7374 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
7375 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
7376 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
7378 log "lru resize performs the same with no lru resize"
7380 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
7382 run_test 124b "lru resize (performance test) ======================="
7384 test_125() { # 13358
7385 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
7386 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
7387 test_mkdir -p $DIR/d125 || error "mkdir failed"
7388 $SETSTRIPE -S 65536 -c -1 $DIR/d125 || error "setstripe failed"
7389 setfacl -R -m u:bin:rwx $DIR/d125 || error "setfacl $DIR/d125 failed"
7390 ls -ld $DIR/d125 || error "cannot access $DIR/d125"
7392 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
7394 test_126() { # bug 12829/13455
7395 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
7396 [ "$UID" != 0 ] && skip_env "skipping $TESTNAME (must run as root)" && return
7397 $GSS && skip "must run as gss disabled" && return
7399 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
7400 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
7402 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
7404 run_test 126 "check that the fsgid provided by the client is taken into account"
7406 test_127a() { # bug 15521
7407 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7408 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
7409 $LCTL set_param osc.*.stats=0
7410 FSIZE=$((2048 * 1024))
7411 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
7412 cancel_lru_locks osc
7413 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
7415 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
7416 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
7417 echo "got $COUNT $NAME"
7418 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
7419 eval $NAME=$COUNT || error "Wrong proc format"
7422 read_bytes|write_bytes)
7423 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
7424 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
7425 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
7426 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
7427 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
7428 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
7429 error "sumsquare is too small: $SUMSQ"
7430 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
7431 error "sumsquare is too big: $SUMSQ"
7435 done < $DIR/${tfile}.tmp
7437 #check that we actually got some stats
7438 [ "$read_bytes" ] || error "Missing read_bytes stats"
7439 [ "$write_bytes" ] || error "Missing write_bytes stats"
7440 [ "$read_bytes" != 0 ] || error "no read done"
7441 [ "$write_bytes" != 0 ] || error "no write done"
7443 run_test 127a "verify the client stats are sane"
7445 test_127b() { # bug LU-333
7446 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7447 $LCTL set_param llite.*.stats=0
7448 FSIZE=65536 # sized fixed to match PAGE_SIZE for most clients
7449 # perform 2 reads and writes so MAX is different from SUM.
7450 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
7451 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
7452 cancel_lru_locks osc
7453 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
7454 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
7456 $LCTL get_param llite.*.stats | grep samples > $TMP/${tfile}.tmp
7457 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
7458 echo "got $COUNT $NAME"
7459 eval $NAME=$COUNT || error "Wrong proc format"
7463 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
7464 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
7465 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
7466 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
7469 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
7470 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
7471 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
7472 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
7476 done < $TMP/${tfile}.tmp
7478 #check that we actually got some stats
7479 [ "$read_bytes" ] || error "Missing read_bytes stats"
7480 [ "$write_bytes" ] || error "Missing write_bytes stats"
7481 [ "$read_bytes" != 0 ] || error "no read done"
7482 [ "$write_bytes" != 0 ] || error "no write done"
7484 run_test 127b "verify the llite client stats are sane"
7486 test_128() { # bug 15212
7488 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
7493 result=$(grep error $TMP/$tfile.log)
7495 [ -z "$result" ] || error "consecutive find's under interactive lfs failed"
7497 run_test 128 "interactive lfs for 2 consecutive find's"
7504 local LDPROC=/proc/fs/ldiskfs
7505 local facets=$(get_facets MDS)
7507 for facet in ${facets//,/ }; do
7508 canondev=$(ldiskfs_canon \
7509 *.$(convert_facet2label $facet).mntdev $facet)
7510 do_facet $facet "test -e $LDPROC/$canondev/max_dir_size" ||
7511 LDPROC=/sys/fs/ldiskfs
7512 do_facet $facet "echo $1 >$LDPROC/$canondev/max_dir_size"
7517 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7518 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
7519 skip "Only applicable to ldiskfs-based MDTs"
7522 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7528 test_mkdir -p $DIR/$tdir
7532 while [ ! $I -gt $((MAX * MDSCOUNT)) ]; do
7533 $MULTIOP $DIR/$tdir/$J Oc
7535 if [ $rc -eq $EFBIG ]; then
7537 echo "return code $rc received as expected"
7539 elif [ $rc -ne 0 ]; then
7541 error_exit "return code $rc received instead of expected $EFBIG"
7544 I=$(stat -c%s "$DIR/$tdir")
7548 error "exceeded dir size limit $MAX x $MDSCOUNT $((MAX * MDSCOUNT)) : $I bytes"
7550 run_test 129 "test directory size limit ========================"
7559 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7560 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
7563 trap cleanup_130 EXIT RETURN
7565 local fm_file=$DIR/$tfile
7566 $SETSTRIPE -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
7567 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
7568 error "dd failed for $fm_file"
7570 # LU-1795: test filefrag/FIEMAP once, even if unsupported
7571 filefrag -ves $fm_file
7573 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
7574 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
7575 [ $RC != 0 ] && error "filefrag $fm_file failed"
7577 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
7578 grep -v "ext:" | grep -v "found")
7579 lun=$($GETSTRIPE -i $fm_file)
7581 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
7584 for line in $filefrag_op
7586 frag_lun=`echo $line | cut -d: -f5`
7587 ext_len=`echo $line | cut -d: -f4`
7588 if (( $frag_lun != $lun )); then
7590 error "FIEMAP on 1-stripe file($fm_file) failed"
7593 (( tot_len += ext_len ))
7596 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
7598 error "FIEMAP on 1-stripe file($fm_file) failed;"
7604 echo "FIEMAP on single striped file succeeded"
7606 run_test 130a "FIEMAP (1-stripe file)"
7609 [ "$OSTCOUNT" -lt "2" ] &&
7610 skip_env "skipping FIEMAP on 2-stripe file test" && return
7612 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7613 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
7616 trap cleanup_130 EXIT RETURN
7618 local fm_file=$DIR/$tfile
7619 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
7620 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
7621 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
7623 dd if=/dev/zero of=$fm_file bs=1M count=2 ||
7624 error "dd failed on $fm_file"
7626 filefrag -ves $fm_file || error "filefrag $fm_file failed"
7627 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
7628 grep -v "ext:" | grep -v "found")
7630 last_lun=$(echo $filefrag_op | cut -d: -f5)
7635 for line in $filefrag_op
7637 frag_lun=`echo $line | cut -d: -f5`
7638 ext_len=`echo $line | cut -d: -f4`
7639 if (( $frag_lun != $last_lun )); then
7640 if (( tot_len != 1024 )); then
7642 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 256"
7649 (( tot_len += ext_len ))
7652 if (( num_luns != 2 || tot_len != 1024 )); then
7654 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
7660 echo "FIEMAP on 2-stripe file succeeded"
7662 run_test 130b "FIEMAP (2-stripe file)"
7665 [ "$OSTCOUNT" -lt "2" ] &&
7666 skip_env "skipping FIEMAP on 2-stripe file" && return
7668 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7669 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
7672 trap cleanup_130 EXIT RETURN
7674 local fm_file=$DIR/$tfile
7675 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
7676 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
7677 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
7679 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 || error "dd failed on $fm_file"
7681 filefrag -ves $fm_file || error "filefrag $fm_file failed"
7682 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
7684 last_lun=`echo $filefrag_op | cut -d: -f5`
7689 for line in $filefrag_op
7691 frag_lun=`echo $line | cut -d: -f5`
7692 ext_len=`echo $line | cut -d: -f4`
7693 if (( $frag_lun != $last_lun )); then
7694 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
7695 if (( logical != 512 )); then
7697 error "FIEMAP on $fm_file failed; returned logical start for lun $logical instead of 512"
7700 if (( tot_len != 512 )); then
7702 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
7709 (( tot_len += ext_len ))
7712 if (( num_luns != 2 || tot_len != 512 )); then
7714 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
7720 echo "FIEMAP on 2-stripe file with hole succeeded"
7722 run_test 130c "FIEMAP (2-stripe file with hole)"
7725 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping FIEMAP on N-stripe file test" && return
7727 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7728 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
7730 trap cleanup_130 EXIT RETURN
7732 local fm_file=$DIR/$tfile
7733 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file||error "setstripe on $fm_file"
7734 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
7735 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
7736 dd if=/dev/zero of=$fm_file bs=1M count=$OSTCOUNT || error "dd failed on $fm_file"
7738 filefrag -ves $fm_file || error "filefrag $fm_file failed"
7739 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
7741 last_lun=`echo $filefrag_op | cut -d: -f5`
7746 for line in $filefrag_op
7748 frag_lun=`echo $line | cut -d: -f5`
7749 ext_len=`echo $line | cut -d: -f4`
7750 if (( $frag_lun != $last_lun )); then
7751 if (( tot_len != 1024 )); then
7753 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
7760 (( tot_len += ext_len ))
7763 if (( num_luns != OSTCOUNT || tot_len != 1024 )); then
7765 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
7771 echo "FIEMAP on N-stripe file succeeded"
7773 run_test 130d "FIEMAP (N-stripe file)"
7776 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping continuation FIEMAP test" && return
7778 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7779 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
7781 trap cleanup_130 EXIT RETURN
7783 local fm_file=$DIR/$tfile
7784 $SETSTRIPE -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
7785 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
7786 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
7789 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
7790 for ((i = 0; i < $NUM_BLKS; i++))
7792 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
7795 filefrag -ves $fm_file || error "filefrag $fm_file failed"
7796 filefrag_op=`filefrag -ve $fm_file | grep -A 12000 "ext:" | grep -v "ext:" | grep -v "found"`
7798 last_lun=`echo $filefrag_op | cut -d: -f5`
7803 for line in $filefrag_op
7805 frag_lun=`echo $line | cut -d: -f5`
7806 ext_len=`echo $line | cut -d: -f4`
7807 if (( $frag_lun != $last_lun )); then
7808 if (( tot_len != $EXPECTED_LEN )); then
7810 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of $EXPECTED_LEN"
7817 (( tot_len += ext_len ))
7820 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
7822 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
7828 echo "FIEMAP with continuation calls succeeded"
7830 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
7832 # Test for writev/readv
7834 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 || \
7835 error "writev test failed"
7836 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 || \
7837 error "readv failed"
7840 run_test 131a "test iov's crossing stripe boundary for writev/readv"
7843 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 || \
7844 error "append writev test failed"
7845 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 || \
7846 error "append writev test failed"
7849 run_test 131b "test append writev"
7852 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
7855 run_test 131c "test read/write on file w/o objects"
7858 rwv -f $DIR/$tfile -w -n 1 1572864
7859 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
7860 if [ "$NOB" != 1572864 ]; then
7861 error "Short read filed: read $NOB bytes instead of 1572864"
7865 run_test 131d "test short read"
7868 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
7869 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
7870 error "read hitting hole failed"
7873 run_test 131e "test read hitting hole"
7878 for node in $(osts_nodes); do
7879 gl=$(do_node $node "$LCTL get_param -n ost.OSS.ost.stats" | awk '/'$token'/ {print $2}' | head -n 1)
7880 [ x$gl = x"" ] && gl=0
7881 gl_sum=$((gl_sum + gl))
7891 if [ x$som = x"enabled" ]; then
7892 [ $((gl2 - gl1)) -gt 0 ] && error "no glimpse RPC is expected"
7893 MOUNTOPT=`echo $MOUNTOPT | sed 's/som_preview//g'`
7894 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=disabled"
7896 [ $((gl2 - gl1)) -gt 0 ] || error "some glimpse RPC is expected"
7897 MOUNTOPT="$MOUNTOPT,som_preview"
7898 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=enabled"
7901 # do remount to make new mount-conf parameters actual
7908 test_132() { #1028, SOM
7909 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7910 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7911 local num=$(get_mds_dir $DIR)
7912 local mymds=mds${num}
7913 local MOUNTOPT_SAVE=$MOUNTOPT
7915 dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
7916 cancel_lru_locks osc
7918 som1=$(do_facet $mymds "$LCTL get_param mdt.*.som" | awk -F= ' {print $2}' | head -n 1)
7920 gl1=$(get_ost_param "ldlm_glimpse_enqueue")
7921 stat $DIR/$tfile >/dev/null
7922 gl2=$(get_ost_param "ldlm_glimpse_enqueue")
7923 echo "====> SOM is "$som1", "$((gl2 - gl1))" glimpse RPC occured"
7925 som_mode_switch $som1 $gl1 $gl2
7927 dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
7928 cancel_lru_locks osc
7930 som2=$(do_facet $mymds "$LCTL get_param mdt.*.som" | awk -F= ' {print $2}' | head -n 1)
7931 if [ $som1 == $som2 ]; then
7932 error "som is still "$som2
7933 if [ x$som2 = x"enabled" ]; then
7940 gl1=$(get_ost_param "ldlm_glimpse_enqueue")
7941 stat $DIR/$tfile >/dev/null
7942 gl2=$(get_ost_param "ldlm_glimpse_enqueue")
7943 echo "====> SOM is "$som2", "$((gl2 - gl1))" glimpse RPC occured"
7944 som_mode_switch $som2 $gl1 $gl2
7945 MOUNTOPT=$MOUNTOPT_SAVE
7947 run_test 132 "som avoids glimpse rpc"
7953 $SINGLEMDS) res=`do_facet $SINGLEMDS $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$2"`
7955 ost) res=`do_facet ost1 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$2"`
7957 *) error "Wrong argument $1" ;;
7960 count=`echo $res | awk '{print $2}'`
7961 [ -z "$res" ] && error "The counter for $2 on $1 was not incremented"
7962 # if the argument $3 is zero, it means any stat increment is ok.
7963 if [ $3 -gt 0 ] ; then
7964 [ $count -ne $3 ] && error "The $2 counter on $1 is wrong - expected $3"
7969 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7970 remote_ost_nodsh && skip "remote OST with nodsh" && return
7971 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7973 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
7974 { skip "MDS doesn't support rename stats"; return; }
7975 local testdir=$DIR/${tdir}/stats_testdir
7976 mkdir -p $DIR/${tdir}
7979 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
7980 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
7982 # verify mdt stats first.
7983 mkdir ${testdir} || error "mkdir failed"
7984 check_stats $SINGLEMDS "mkdir" 1
7985 touch ${testdir}/${tfile} || "touch failed"
7986 check_stats $SINGLEMDS "open" 1
7987 check_stats $SINGLEMDS "close" 1
7988 mknod ${testdir}/${tfile}-pipe p || "mknod failed"
7989 check_stats $SINGLEMDS "mknod" 1
7990 rm -f ${testdir}/${tfile}-pipe || "pipe remove failed"
7991 check_stats $SINGLEMDS "unlink" 1
7992 rm -f ${testdir}/${tfile} || error "file remove failed"
7993 check_stats $SINGLEMDS "unlink" 2
7995 # remove working dir and check mdt stats again.
7996 rmdir ${testdir} || error "rmdir failed"
7997 check_stats $SINGLEMDS "rmdir" 1
7999 local testdir1=$DIR/${tdir}/stats_testdir1
8001 mkdir -p ${testdir1}
8002 touch ${testdir1}/test1
8003 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
8004 check_stats $SINGLEMDS "crossdir_rename" 1
8006 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
8007 check_stats $SINGLEMDS "samedir_rename" 1
8011 run_test 133a "Verifying MDT stats ========================================"
8014 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8015 remote_ost_nodsh && skip "remote OST with nodsh" && return
8016 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8017 local testdir=$DIR/${tdir}/stats_testdir
8018 mkdir -p ${testdir} || error "mkdir failed"
8019 touch ${testdir}/${tfile} || "touch failed"
8020 cancel_lru_locks mdc
8023 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8024 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
8026 # extra mdt stats verification.
8027 chmod 444 ${testdir}/${tfile} || error "chmod failed"
8028 check_stats $SINGLEMDS "setattr" 1
8029 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8030 if [ $(lustre_version_code $SINGLEMDS) -ne $(version_code 2.2.0) ]
8032 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
8033 check_stats $SINGLEMDS "getattr" 1
8035 $LFS df || error "lfs failed"
8036 check_stats $SINGLEMDS "statfs" 1
8040 run_test 133b "Verifying extra MDT stats =================================="
8043 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8044 remote_ost_nodsh && skip "remote OST with nodsh" && return
8045 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8046 local testdir=$DIR/${tdir}/stats_testdir
8047 test_mkdir -p ${testdir} || error "mkdir failed"
8049 # verify obdfilter stats.
8050 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
8052 cancel_lru_locks osc
8053 wait_delete_completed
8056 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8057 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
8059 dd if=/dev/zero of=${testdir}/${tfile} conv=notrunc bs=512k count=1 || error "dd failed"
8061 cancel_lru_locks osc
8062 check_stats ost "write" 1
8064 dd if=${testdir}/${tfile} of=/dev/null bs=1k count=1 || error "dd failed"
8065 check_stats ost "read" 1
8067 > ${testdir}/${tfile} || error "truncate failed"
8068 check_stats ost "punch" 1
8070 rm -f ${testdir}/${tfile} || error "file remove failed"
8071 wait_delete_completed
8072 check_stats ost "destroy" 1
8076 run_test 133c "Verifying OST stats ========================================"
8083 while [ $value -ge 2 ]; do
8088 if [ $orig -gt $order ]; then
8096 local size=('K' 'M' 'G' 'T');
8098 local size_string=$value
8100 while [ $value -ge 1024 ]; do
8101 if [ $i -gt 3 ]; then
8102 #T is the biggest unit we get here, if that is bigger,
8104 size_string=${value}T
8107 value=$((value >> 10))
8108 if [ $value -lt 1024 ]; then
8109 size_string=${value}${size[$i]}
8120 local context=${2:-.}
8121 local sample=$(do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats |
8123 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
8128 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8129 remote_ost_nodsh && skip "remote OST with nodsh" && return
8130 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8131 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
8132 { skip "MDS doesn't support rename stats"; return; }
8134 local testdir1=$DIR/${tdir}/stats_testdir1
8135 local testdir2=$DIR/${tdir}/stats_testdir2
8137 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
8139 test_mkdir -p ${testdir1} || error "mkdir failed"
8140 test_mkdir -p ${testdir2} || error "mkdir failed"
8142 createmany -o $testdir1/test 512 || error "createmany failed"
8144 # check samedir rename size
8145 mv ${testdir1}/test0 ${testdir1}/test_0
8147 local testdir1_size=$(ls -l $DIR/${tdir} |
8148 awk '/stats_testdir1/ {print $5}')
8149 local testdir2_size=$(ls -l $DIR/${tdir} |
8150 awk '/stats_testdir2/ {print $5}')
8152 testdir1_size=$(order_2 $testdir1_size)
8153 testdir2_size=$(order_2 $testdir2_size)
8155 testdir1_size=$(size_in_KMGT $testdir1_size)
8156 testdir2_size=$(size_in_KMGT $testdir2_size)
8158 echo "source rename dir size: ${testdir1_size}"
8159 echo "target rename dir size: ${testdir2_size}"
8161 local cmd="do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats"
8162 eval $cmd || error "$cmd failed"
8163 local samedir=$($cmd | grep 'same_dir')
8164 local same_sample=$(get_rename_size $testdir1_size)
8165 [ -z "$samedir" ] && error "samedir_rename_size count error"
8166 [ "$same_sample" -eq 1 ] || error "samedir_rename_size error $same_sample"
8167 echo "Check same dir rename stats success"
8169 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
8171 # check crossdir rename size
8172 mv ${testdir1}/test_0 ${testdir2}/test_0
8174 testdir1_size=$(ls -l $DIR/${tdir} |
8175 awk '/stats_testdir1/ {print $5}')
8176 testdir2_size=$(ls -l $DIR/${tdir} |
8177 awk '/stats_testdir2/ {print $5}')
8179 testdir1_size=$(order_2 $testdir1_size)
8180 testdir2_size=$(order_2 $testdir2_size)
8182 testdir1_size=$(size_in_KMGT $testdir1_size)
8183 testdir2_size=$(size_in_KMGT $testdir2_size)
8185 echo "source rename dir size: ${testdir1_size}"
8186 echo "target rename dir size: ${testdir2_size}"
8188 eval $cmd || error "$cmd failed"
8189 local crossdir=$($cmd | grep 'crossdir')
8190 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
8191 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
8192 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
8193 [ "$src_sample" -eq 1 ] || error "crossdir_rename_size error $src_sample"
8194 [ "$tgt_sample" -eq 1 ] || error "crossdir_rename_size error $tgt_sample"
8195 echo "Check cross dir rename stats success"
8198 run_test 133d "Verifying rename_stats ========================================"
8201 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8202 local testdir=$DIR/${tdir}/stats_testdir
8203 local ctr f0 f1 bs=32768 count=42 sum
8205 remote_ost_nodsh && skip "remote OST with nodsh" && return
8206 mkdir -p ${testdir} || error "mkdir failed"
8208 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
8210 for ctr in {write,read}_bytes; do
8212 cancel_lru_locks osc
8214 do_facet ost1 $LCTL set_param -n \
8215 "obdfilter.*.exports.clear=clear"
8217 if [ $ctr = write_bytes ]; then
8219 f1=${testdir}/${tfile}
8221 f0=${testdir}/${tfile}
8225 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
8228 cancel_lru_locks osc
8230 sum=$(do_facet ost1 $LCTL get_param \
8231 "obdfilter.*.exports.*.stats" | \
8234 $1 == ctr { sum += $7 }
8237 if ((sum != bs * count)); then
8238 error "Bad $ctr sum, expected $((bs * count)), got $sum"
8244 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
8246 test_140() { #bug-17379
8247 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8248 test_mkdir -p $DIR/$tdir || error "Creating dir $DIR/$tdir"
8249 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
8250 cp /usr/bin/stat . || error "Copying stat to $DIR/$tdir"
8252 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
8253 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
8255 while i=`expr $i + 1`; do
8256 test_mkdir -p $i || error "Creating dir $i"
8257 cd $i || error "Changing to $i"
8258 ln -s ../stat stat || error "Creating stat symlink"
8259 # Read the symlink until ELOOP present,
8260 # not LBUGing the system is considered success,
8261 # we didn't overrun the stack.
8262 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
8264 if [ $ret -eq 40 ]; then
8267 error "Open stat symlink"
8273 echo "The symlink depth = $i"
8274 [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 -o $i -eq 40 ] ||
8275 error "Invalid symlink depth"
8277 # Test recursive symlink
8278 ln -s symlink_self symlink_self
8279 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
8280 echo "open symlink_self returns $ret"
8281 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
8283 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
8286 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8287 local TF="$TMP/$tfile"
8289 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
8291 cancel_lru_locks osc
8292 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
8293 remount_client $MOUNT
8295 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
8298 $TRUNCATE $DIR/$tfile 6000
8299 cancel_lru_locks osc
8300 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
8303 echo "12345" >>$DIR/$tfile
8304 cancel_lru_locks osc
8305 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
8308 echo "12345" >>$DIR/$tfile
8309 cancel_lru_locks osc
8310 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
8315 run_test 150 "truncate/append tests"
8317 function roc_hit() {
8318 local list=$(comma_list $(osts_nodes))
8320 echo $(get_osd_param $list '' stats |
8321 awk '/'cache_hit'/ {sum+=$2} END {print sum}')
8324 function set_cache() {
8327 if [ "$2" == "off" ]; then
8330 local list=$(comma_list $(osts_nodes))
8331 set_osd_param $list '' $1_cache_enable $on
8333 cancel_lru_locks osc
8337 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8338 remote_ost_nodsh && skip "remote OST with nodsh" && return
8341 local list=$(comma_list $(osts_nodes))
8343 # check whether obdfilter is cache capable at all
8344 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
8345 echo "not cache-capable obdfilter"
8349 # check cache is enabled on all obdfilters
8350 if get_osd_param $list '' read_cache_enable | grep 0; then
8351 echo "oss cache is disabled"
8355 set_osd_param $list '' writethrough_cache_enable 1
8357 # pages should be in the case right after write
8358 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES || error "dd failed"
8359 local BEFORE=`roc_hit`
8360 cancel_lru_locks osc
8361 cat $DIR/$tfile >/dev/null
8362 local AFTER=`roc_hit`
8363 if ! let "AFTER - BEFORE == CPAGES"; then
8364 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
8367 # the following read invalidates the cache
8368 cancel_lru_locks osc
8369 set_osd_param $list '' read_cache_enable 0
8370 cat $DIR/$tfile >/dev/null
8372 # now data shouldn't be found in the cache
8374 cancel_lru_locks osc
8375 cat $DIR/$tfile >/dev/null
8377 if let "AFTER - BEFORE != 0"; then
8378 error "IN CACHE: before: $BEFORE, after: $AFTER"
8381 set_osd_param $list '' read_cache_enable 1
8384 run_test 151 "test cache on oss and controls ==============================="
8387 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8388 local TF="$TMP/$tfile"
8390 # simulate ENOMEM during write
8391 #define OBD_FAIL_OST_NOMEM 0x226
8392 lctl set_param fail_loc=0x80000226
8393 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
8395 sync || error "sync failed"
8396 lctl set_param fail_loc=0
8398 # discard client's cache
8399 cancel_lru_locks osc
8401 # simulate ENOMEM during read
8402 lctl set_param fail_loc=0x80000226
8403 cmp $TF $DIR/$tfile || error "cmp failed"
8404 lctl set_param fail_loc=0
8408 run_test 152 "test read/write with enomem ============================"
8411 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
8413 run_test 153 "test if fdatasync does not crash ======================="
8416 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8417 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
8418 { skip "Need MDS version at least 2.2.51"; return 0; }
8420 cp /etc/hosts $DIR/$tfile
8422 fid=$($LFS path2fid $DIR/$tfile)
8424 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
8426 ffid=$DIR/.lustre/fid/$fid
8428 echo "stat fid $fid"
8429 stat $ffid > /dev/null || error "stat $ffid failed."
8430 echo "touch fid $fid"
8431 touch $ffid || error "touch $ffid failed."
8432 echo "write to fid $fid"
8433 cat /etc/hosts > $ffid || error "write $ffid failed."
8434 echo "read fid $fid"
8435 diff /etc/hosts $ffid || error "read $ffid failed."
8436 echo "append write to fid $fid"
8437 cat /etc/hosts >> $ffid || error "append write $ffid failed."
8438 echo "rename fid $fid"
8439 mv $ffid $DIR/$tfile.1 && error "rename $ffid to $tfile.1 should fail."
8441 mv $DIR/$tfile.1 $ffid && error "rename $tfile.1 to $ffid should fail."
8443 echo "truncate fid $fid"
8444 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
8445 echo "link fid $fid"
8446 ln -f $ffid $DIR/tfile.lnk || error "link $ffid failed."
8447 if [ -n $(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl) ]; then
8448 echo "setfacl fid $fid"
8449 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
8450 echo "getfacl fid $fid"
8451 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
8453 echo "unlink fid $fid"
8454 unlink $DIR/.lustre/fid/$fid && error "unlink $ffid should fail."
8455 echo "mknod fid $fid"
8456 mknod $ffid c 1 3 && error "mknod $ffid should fail."
8458 fid=[0xf00000400:0x1:0x0]
8459 ffid=$DIR/.lustre/fid/$fid
8461 echo "stat non-exist fid $fid"
8462 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
8463 echo "write to non-exist fid $fid"
8464 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
8465 echo "link new fid $fid"
8466 ln $DIR/$tfile $ffid && error "link $ffid should fail."
8468 test_mkdir -p $DIR/$tdir
8469 touch $DIR/$tdir/$tfile
8470 fid=$($LFS path2fid $DIR/$tdir)
8472 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
8474 ffid=$DIR/.lustre/fid/$fid
8477 ls $ffid > /dev/null || error "ls $ffid failed."
8478 echo "touch $fid/$tfile.1"
8479 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
8481 echo "touch $DIR/.lustre/fid/$tfile"
8482 touch $DIR/.lustre/fid/$tfile && \
8483 error "touch $DIR/.lustre/fid/$tfile should fail."
8485 echo "setxattr to $DIR/.lustre/fid"
8486 setfattr -n trusted.name1 -v value1 $DIR/.lustre/fid &&
8487 error "setxattr should fail."
8489 echo "listxattr for $DIR/.lustre/fid"
8490 getfattr -d -m "^trusted" $DIR/.lustre/fid &&
8491 error "listxattr should fail."
8493 echo "delxattr from $DIR/.lustre/fid"
8494 setfattr -x trusted.name1 $DIR/.lustre/fid &&
8495 error "delxattr should fail."
8497 echo "touch invalid fid: $DIR/.lustre/fid/[0x200000400:0x2:0x3]"
8498 touch $DIR/.lustre/fid/[0x200000400:0x2:0x3] &&
8499 error "touch invalid fid should fail."
8501 echo "touch non-normal fid: $DIR/.lustre/fid/[0x1:0x2:0x0]"
8502 touch $DIR/.lustre/fid/[0x1:0x2:0x0] &&
8503 error "touch non-normal fid should fail."
8505 echo "rename $tdir to $DIR/.lustre/fid"
8506 mrename $DIR/$tdir $DIR/.lustre/fid &&
8507 error "rename to $DIR/.lustre/fid should fail."
8509 echo "rename .lustre to itself"
8510 fid=$($LFS path2fid $DIR)
8511 mrename $DIR/.lustre $DIR/.lustre/fid/$fid/.lustre &&
8512 error "rename .lustre to itself should fail."
8514 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $DIR/$tfile-2
8515 fid=$($LFS path2fid $DIR/$tfile-2)
8516 echo "cp /etc/passwd $DIR/.lustre/fid/$fid"
8517 cp /etc/passwd $DIR/.lustre/fid/$fid &&
8518 error "create lov data thru .lustre should fail."
8519 echo "cp /etc/passwd $DIR/$tfile-2"
8520 cp /etc/passwd $DIR/$tfile-2 || error "copy to $DIR/$tfile-2 failed."
8521 echo "diff /etc/passwd $DIR/.lustre/fid/$fid"
8522 diff /etc/passwd $DIR/.lustre/fid/$fid ||
8523 error "diff /etc/passwd $DIR/.lustre/fid/$fid failed."
8525 echo "Open-by-FID succeeded"
8527 run_test 154 "Open-by-FID"
8529 test_155_small_load() {
8530 local temp=$TMP/$tfile
8531 local file=$DIR/$tfile
8533 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
8534 error "dd of=$temp bs=6096 count=1 failed"
8536 cancel_lru_locks osc
8537 cmp $temp $file || error "$temp $file differ"
8539 $TRUNCATE $temp 6000
8540 $TRUNCATE $file 6000
8541 cmp $temp $file || error "$temp $file differ (truncate1)"
8543 echo "12345" >>$temp
8544 echo "12345" >>$file
8545 cmp $temp $file || error "$temp $file differ (append1)"
8547 echo "12345" >>$temp
8548 echo "12345" >>$file
8549 cmp $temp $file || error "$temp $file differ (append2)"
8555 test_155_big_load() {
8556 remote_ost_nodsh && skip "remote OST with nodsh" && return
8557 local temp=$TMP/$tfile
8558 local file=$DIR/$tfile
8561 local cache_size=$(do_facet ost$((MAXI+1)) \
8562 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
8563 local large_file_size=$((cache_size * 2))
8565 echo "OSS cache size: $cache_size KB"
8566 echo "Large file size: $large_file_size KB"
8568 [ $MAXV -le $large_file_size ] && \
8569 skip_env "max available OST size needs > $large_file_size KB" && \
8572 $SETSTRIPE $file -c 1 -i $MAXI || error "$SETSTRIPE $file failed"
8574 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k || \
8575 error "dd of=$temp bs=$large_file_size count=1k failed"
8578 cancel_lru_locks osc
8579 cmp $temp $file || error "$temp $file differ"
8586 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8588 set_cache writethrough on
8591 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
8594 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8596 set_cache writethrough off
8599 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
8602 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8604 set_cache writethrough on
8607 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
8610 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8612 set_cache writethrough off
8615 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
8618 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8620 set_cache writethrough on
8623 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
8626 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8628 set_cache writethrough off
8631 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
8634 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8636 set_cache writethrough on
8639 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
8642 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8644 set_cache writethrough off
8647 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
8650 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8654 local file="$DIR/$tfile"
8656 [ "$(facet_fstype ost1)" = "zfs" ] &&
8657 skip "LU-1956/LU-2261: stats unimplemented on OSD ZFS" &&
8660 log "Turn on read and write cache"
8662 set_cache writethrough on
8664 log "Write data and read it back."
8665 log "Read should be satisfied from the cache."
8666 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
8668 cancel_lru_locks osc
8669 cat $file >/dev/null
8671 if ! let "AFTER - BEFORE == CPAGES"; then
8672 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
8674 log "cache hits:: before: $BEFORE, after: $AFTER"
8677 log "Read again; it should be satisfied from the cache."
8679 cancel_lru_locks osc
8680 cat $file >/dev/null
8682 if ! let "AFTER - BEFORE == CPAGES"; then
8683 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
8685 log "cache hits:: before: $BEFORE, after: $AFTER"
8689 log "Turn off the read cache and turn on the write cache"
8691 set_cache writethrough on
8693 log "Read again; it should be satisfied from the cache."
8695 cancel_lru_locks osc
8696 cat $file >/dev/null
8698 if ! let "AFTER - BEFORE == CPAGES"; then
8699 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
8701 log "cache hits:: before: $BEFORE, after: $AFTER"
8704 log "Read again; it should not be satisfied from the cache."
8706 cancel_lru_locks osc
8707 cat $file >/dev/null
8709 if ! let "AFTER - BEFORE == 0"; then
8710 error "IN CACHE: before: $BEFORE, after: $AFTER"
8712 log "cache hits:: before: $BEFORE, after: $AFTER"
8715 log "Write data and read it back."
8716 log "Read should be satisfied from the cache."
8717 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
8719 cancel_lru_locks osc
8720 cat $file >/dev/null
8722 if ! let "AFTER - BEFORE == CPAGES"; then
8723 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
8725 log "cache hits:: before: $BEFORE, after: $AFTER"
8728 log "Read again; it should not be satisfied from the cache."
8730 cancel_lru_locks osc
8731 cat $file >/dev/null
8733 if ! let "AFTER - BEFORE == 0"; then
8734 error "IN CACHE: before: $BEFORE, after: $AFTER"
8736 log "cache hits:: before: $BEFORE, after: $AFTER"
8740 log "Turn off read and write cache"
8742 set_cache writethrough off
8744 log "Write data and read it back"
8745 log "It should not be satisfied from the cache."
8747 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
8748 cancel_lru_locks osc
8750 cat $file >/dev/null
8752 if ! let "AFTER - BEFORE == 0"; then
8753 error_ignore 20762 "IN CACHE: before: $BEFORE, after: $AFTER"
8755 log "cache hits:: before: $BEFORE, after: $AFTER"
8759 log "Turn on the read cache and turn off the write cache"
8761 set_cache writethrough off
8763 log "Write data and read it back"
8764 log "It should not be satisfied from the cache."
8766 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
8768 cancel_lru_locks osc
8769 cat $file >/dev/null
8771 if ! let "AFTER - BEFORE == 0"; then
8772 error_ignore 20762 "IN CACHE: before: $BEFORE, after: $AFTER"
8774 log "cache hits:: before: $BEFORE, after: $AFTER"
8777 log "Read again; it should be satisfied from the cache."
8779 cancel_lru_locks osc
8780 cat $file >/dev/null
8782 if ! let "AFTER - BEFORE == CPAGES"; then
8783 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
8785 log "cache hits:: before: $BEFORE, after: $AFTER"
8790 run_test 156 "Verification of tunables ============================"
8794 if [ $MDSCOUNT -gt 1 ]; then
8795 error_ignore 17935 $*
8803 MASK=$(do_facet $SINGLEMDS $LCTL get_param mdd.$MDT0.changelog_mask |\
8806 if [ $MASK -eq 1 ]; then
8807 do_facet $SINGLEMDS $LCTL set_param mdd.$MDT0.changelog_mask="-$1"
8809 do_facet $SINGLEMDS $LCTL set_param mdd.$MDT0.changelog_mask="+$1"
8814 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8815 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8816 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
8817 { skip "Need MDS version at least 2.2.0"; return; }
8818 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
8819 echo "Registered as changelog user $USER"
8820 do_facet $SINGLEMDS $LCTL get_param -n mdd.$MDT0.changelog_users | \
8821 grep -q $USER || error "User $USER not found in changelog_users"
8824 test_mkdir -p $DIR/$tdir/pics/2008/zachy
8825 touch $DIR/$tdir/pics/2008/zachy/timestamp
8826 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
8827 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
8828 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
8829 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
8830 rm $DIR/$tdir/pics/desktop.jpg
8832 $LFS changelog $MDT0 | tail -5
8834 echo "verifying changelog mask"
8835 changelog_chmask "MKDIR"
8836 changelog_chmask "CLOSE"
8838 test_mkdir -p $DIR/$tdir/pics/zach/sofia
8839 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
8841 changelog_chmask "MKDIR"
8842 changelog_chmask "CLOSE"
8844 test_mkdir -p $DIR/$tdir/pics/2008/sofia
8845 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
8847 $LFS changelog $MDT0
8848 MKDIRS=$($LFS changelog $MDT0 | tail -5 | grep -c "MKDIR")
8849 CLOSES=$($LFS changelog $MDT0 | tail -5 | grep -c "CLOSE")
8850 [ $MKDIRS -eq 1 ] || err17935 "MKDIR changelog mask count $DIRS != 1"
8851 [ $CLOSES -eq 1 ] || err17935 "CLOSE changelog mask count $DIRS != 1"
8854 echo "verifying target fid"
8855 fidc=$($LFS changelog $MDT0 | grep timestamp | grep "CREAT" | \
8856 tail -1 | awk '{print $6}')
8857 fidf=$($LFS path2fid $DIR/$tdir/pics/zach/timestamp)
8858 [ "$fidc" == "t=$fidf" ] || \
8859 err17935 "fid in changelog $fidc != file fid $fidf"
8860 echo "verifying parent fid"
8861 fidc=$($LFS changelog $MDT0 | grep timestamp | grep "CREAT" | \
8862 tail -1 | awk '{print $7}')
8863 fidf=$($LFS path2fid $DIR/$tdir/pics/zach)
8864 [ "$fidc" == "p=$fidf" ] || \
8865 err17935 "pfid in changelog $fidc != dir fid $fidf"
8867 USER_REC1=$(do_facet $SINGLEMDS $LCTL get_param -n \
8868 mdd.$MDT0.changelog_users | grep $USER | awk '{print $2}')
8869 $LFS changelog_clear $MDT0 $USER $(($USER_REC1 + 5))
8870 USER_REC2=$(do_facet $SINGLEMDS $LCTL get_param -n \
8871 mdd.$MDT0.changelog_users | grep $USER | awk '{print $2}')
8872 echo "verifying user clear: $(( $USER_REC1 + 5 )) == $USER_REC2"
8873 [ $USER_REC2 == $(($USER_REC1 + 5)) ] || \
8874 err17935 "user index should be $(($USER_REC1 + 5)); is $USER_REC2"
8876 MIN_REC=$(do_facet $SINGLEMDS $LCTL get_param mdd.$MDT0.changelog_users | \
8877 awk 'min == "" || $2 < min {min = $2}; END {print min}')
8878 FIRST_REC=$($LFS changelog $MDT0 | head -1 | awk '{print $1}')
8879 echo "verifying min purge: $(( $MIN_REC + 1 )) == $FIRST_REC"
8880 [ $FIRST_REC == $(($MIN_REC + 1)) ] || \
8881 err17935 "first index should be $(($MIN_REC + 1)); is $FIRST_REC"
8883 echo "verifying user deregister"
8884 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
8885 do_facet $SINGLEMDS $LCTL get_param -n mdd.$MDT0.changelog_users | \
8886 grep -q $USER && error "User $USER still found in changelog_users"
8888 USERS=$(( $(do_facet $SINGLEMDS $LCTL get_param -n \
8889 mdd.$MDT0.changelog_users | wc -l) - 2 ))
8890 if [ $USERS -eq 0 ]; then
8891 LAST_REC1=$(do_facet $SINGLEMDS $LCTL get_param -n \
8892 mdd.$MDT0.changelog_users | head -1 | awk '{print $3}')
8893 touch $DIR/$tdir/chloe
8894 LAST_REC2=$(do_facet $SINGLEMDS $LCTL get_param -n \
8895 mdd.$MDT0.changelog_users | head -1 | awk '{print $3}')
8896 echo "verify changelogs are off if we were the only user: $LAST_REC1 == $LAST_REC2"
8897 [ $LAST_REC1 == $LAST_REC2 ] || error "changelogs not off"
8899 echo "$USERS other changelog users; can't verify off"
8902 run_test 160 "changelog sanity"
8905 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8906 test_mkdir -p $DIR/$tdir
8907 cp /etc/hosts $DIR/$tdir/$tfile
8908 test_mkdir $DIR/$tdir/foo1
8909 test_mkdir $DIR/$tdir/foo2
8910 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
8911 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
8912 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
8913 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
8914 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[')
8915 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
8916 $LFS fid2path $DIR $FID
8917 err17935 "bad link ea"
8920 rm $DIR/$tdir/foo2/zachary
8922 rm $DIR/$tdir/foo2/thor
8924 rm $DIR/$tdir/$tfile
8926 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
8927 if [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ]
8929 $LFS fid2path $DIR $FID
8930 err17935 "bad link rename"
8932 rm $DIR/$tdir/foo2/maggie
8935 local longname=filename_avg_len_is_thirty_two_
8936 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 || \
8937 error "failed to hardlink many files"
8938 links=$($LFS fid2path $DIR $FID | wc -l)
8939 echo -n "${links}/1000 links in link EA"
8940 [ ${links} -gt 60 ] || err17935 "expected at least 60 links in link EA"
8941 unlinkmany $DIR/$tdir/foo2/$longname 1000 || \
8942 error "failed to unlink many hardlinks"
8944 run_test 161 "link ea sanity"
8951 local path=$(${LFS} fid2path $*)
8954 if [ $RC -ne 0 ]; then
8955 err17935 "path looked up of $expected failed. Error $RC"
8957 elif [ "${path}" != "${expected}" ]; then
8958 err17935 "path looked up \"${path}\" instead of \"${expected}\""
8961 echo "fid $fid resolves to path $path (expected $expected)"
8965 # Make changes to filesystem
8966 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8967 test_mkdir -p $DIR/$tdir/d2
8968 touch $DIR/$tdir/d2/$tfile
8969 touch $DIR/$tdir/d2/x1
8970 touch $DIR/$tdir/d2/x2
8971 test_mkdir -p $DIR/$tdir/d2/a/b/c
8972 test_mkdir -p $DIR/$tdir/d2/p/q/r
8974 FID=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
8975 check_path "$tdir/d2/$tfile" $FSNAME $FID --link 0
8978 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
8979 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
8980 check_path "$tdir/d2/p/q/r/slink" $FSNAME $FID --link 0
8982 # softlink to wrong file
8983 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
8984 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
8985 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME $FID --link 0
8988 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
8989 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
8990 FID=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
8991 # fid2path dir/fsname should both work
8992 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 1
8993 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR $FID --link 0
8995 # hardlink count: check that there are 2 links
8996 # Doesnt work with CMD yet: 17935
8997 ${LFS} fid2path $DIR $FID | wc -l | grep -q 2 || \
8998 err17935 "expected 2 links"
9000 # hardlink indexing: remove the first link
9001 rm $DIR/$tdir/d2/p/q/r/hlink
9002 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 0
9006 run_test 162 "path lookup sanity"
9009 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9010 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9011 copytool --test $FSNAME || { skip "copytool not runnable: $?" && return; }
9014 local uuid=$($LCTL get_param -n mdc.${FSNAME}-MDT0000-mdc-*.uuid)
9015 # this proc file is temporary and linux-only
9016 do_facet $SINGLEMDS lctl set_param mdt.${FSNAME}-MDT0000.mdccomm=$uuid ||\
9017 error "kernel->userspace send failed"
9020 run_test 163 "kernel <-> userspace comms"
9023 # do directio so as not to populate the page cache
9024 log "creating a 10 Mb file"
9025 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
9026 log "starting reads"
9027 dd if=$DIR/$tfile of=/dev/null bs=4096 &
9028 log "truncating the file"
9029 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
9031 kill %+ || true # reads might have finished
9032 echo "wait until dd is finished"
9034 log "removing the temporary file"
9035 rm -rf $DIR/$tfile || error "tmp file removal failed"
9037 run_test 169 "parallel read and truncate should not deadlock"
9040 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9041 $LCTL clear # bug 18514
9042 $LCTL debug_daemon start $TMP/${tfile}_log_good
9044 $LCTL debug_daemon stop
9045 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
9046 error "sed failed to read log_good"
9048 $LCTL debug_daemon start $TMP/${tfile}_log_good
9050 $LCTL debug_daemon stop
9052 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
9053 error "lctl df log_bad failed"
9055 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
9056 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
9058 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
9059 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
9061 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
9062 error "bad_line good_line1 good_line2 are empty"
9064 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
9065 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
9066 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
9068 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
9069 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
9070 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
9072 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
9073 error "bad_line_new good_line_new are empty"
9075 local expected_good=$((good_line1 + good_line2*2))
9077 rm -f $TMP/${tfile}*
9078 # LU-231, short malformed line may not be counted into bad lines
9079 if [ $bad_line -ne $bad_line_new ] &&
9080 [ $bad_line -ne $((bad_line_new - 1)) ]; then
9081 error "expected $bad_line bad lines, but got $bad_line_new"
9085 if [ $expected_good -ne $good_line_new ]; then
9086 error "expected $expected_good good lines, but got $good_line_new"
9091 run_test 170 "test lctl df to handle corrupted log ====================="
9093 test_171() { # bug20592
9094 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9095 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
9096 $LCTL set_param fail_loc=0x50e
9097 $LCTL set_param fail_val=3000
9098 multiop_bg_pause $DIR/$tfile O_s || true
9100 kill -USR1 $MULTIPID
9104 if dmesg | grep "recursive fault"; then
9105 error "caught a recursive fault"
9107 $LCTL set_param fail_loc=0
9110 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
9112 # it would be good to share it with obdfilter-survey/libecho code
9113 setup_obdecho_osc () {
9116 local obdfilter_name=$2
9117 echo "Creating new osc for $obdfilter_name on $ost_nid"
9118 # make sure we can find loopback nid
9119 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
9121 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
9122 ${obdfilter_name}_osc_UUID || rc=2; }
9123 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
9124 ${obdfilter_name}_UUID $ost_nid || rc=3; }
9128 cleanup_obdecho_osc () {
9129 local obdfilter_name=$1
9130 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
9131 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
9135 obdecho_create_test() {
9140 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
9141 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
9143 if [ $rc -eq 0 ]; then
9144 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
9145 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
9147 echo "New object id is $id"
9148 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec test_brw 10 w v 64 $id" ||
9150 [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec " \
9151 "cleanup" || rc=5; }
9152 [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec " \
9154 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
9159 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9160 remote_ost_nodsh && skip "remote OST with nodsh" && return
9164 if ! module_loaded obdecho; then
9165 load_module obdecho/obdecho
9169 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
9170 local host=$(lctl get_param -n osc.$osc.import |
9171 awk '/current_connection:/ {print $2}' )
9172 local target=$(lctl get_param -n osc.$osc.import |
9173 awk '/target:/ {print $2}' )
9174 target=${target%_UUID}
9176 [[ -n $target ]] && { setup_obdecho_osc $host $target || rc=1; } || rc=1
9177 [ $rc -eq 0 ] && { obdecho_create_test ${target}_osc client || rc=2; }
9178 [[ -n $target ]] && cleanup_obdecho_osc $target
9179 [ $rmmod_local -eq 1 ] && rmmod obdecho
9182 run_test 180a "test obdecho on osc"
9185 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9186 remote_ost_nodsh && skip "remote OST with nodsh" && return
9188 local rmmod_remote=0
9190 do_facet ost1 "lsmod | grep -q obdecho || " \
9191 "{ insmod ${LUSTRE}/obdecho/obdecho.ko || " \
9192 "modprobe obdecho; }" && rmmod_remote=1
9193 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ {print $4;exit}')
9194 [[ -n $target ]] && { obdecho_create_test $target ost1 || rc=1; }
9195 [ $rmmod_remote -eq 1 ] && do_facet ost1 "rmmod obdecho"
9198 run_test 180b "test obdecho directly on obdfilter"
9200 test_181() { # bug 22177
9201 test_mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
9202 # create enough files to index the directory
9203 createmany -o $DIR/$tdir/foobar 4000
9204 # print attributes for debug purpose
9207 multiop_bg_pause $DIR/$tdir D_Sc || return 1
9209 # remove the files & current working dir
9210 unlinkmany $DIR/$tdir/foobar 4000
9212 kill -USR1 $MULTIPID
9214 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
9217 run_test 181 "Test open-unlinked dir ========================"
9220 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9221 # disable MDC RPC lock wouldn't crash client
9225 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
9226 #define OBD_FAIL_MDC_RPCS_SEM 0x804
9227 $LCTL set_param fail_loc=0x804
9229 for (( i=0; i < $tcount; i++ )) ; do
9231 createmany -o $DIR/$tdir/$i/f- $fcount &
9235 for (( i=0; i < $tcount; i++ )) ; do
9236 unlinkmany $DIR/$tdir/$i/f- $fcount &
9242 $LCTL set_param fail_loc=0
9244 run_test 182 "Disable MDC RPCs semaphore wouldn't crash client ================"
9246 test_183() { # LU-2275
9247 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9248 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
9249 echo aaa > $DIR/$tdir/$tfile
9251 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
9252 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
9254 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
9255 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
9257 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
9259 # Flush negative dentry cache
9260 touch $DIR/$tdir/$tfile
9262 # We are not checking for any leaked references here, they'll
9263 # become evident next time we do cleanup with module unload.
9266 run_test 183 "No crash or request leak in case of strange dispositions ========"
9268 test_185() { # LU-2441
9269 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
9270 touch $DIR/$tdir/spoo
9271 local mtime1=$(stat -c "%Y" $DIR/$tdir)
9272 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
9273 error "cannot create/write a volatile file"
9274 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
9275 error "FID is still valid after close"
9277 multiop_bg_pause $DIR/$tdir vVw4096_c
9284 # assume that the next FID for this client is sequential, since stdout
9285 # is unfortunately eaten by multiop_bg_pause
9286 local n=$((${fidv[1]} + 1))
9287 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
9288 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
9289 error "FID is missing before close"
9290 kill -USR1 $multi_pid
9291 # 1 second delay, so if mtime change we will see it
9293 local mtime2=$(stat -c "%Y" $DIR/$tdir)
9294 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
9296 run_test 185 "Volatile file support"
9298 check_swap_layouts_support()
9300 $LCTL get_param -n llite.*.sbi_flags | grep -q layout ||
9301 { skip "Does not support layout lock."; return 0; }
9305 # test suite 184 is for LU-2016, LU-2017
9307 check_swap_layouts_support && return 0
9309 dir0=$DIR/$tdir/$testnum
9310 test_mkdir -p $dir0 || error "creating dir $dir0"
9315 $SETSTRIPE -c1 $file1
9317 $SETSTRIPE -c2 $file2
9319 gen1=$($GETSTRIPE -g $file1)
9320 gen2=$($GETSTRIPE -g $file2)
9322 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
9323 gen=$($GETSTRIPE -g $file1)
9324 [[ $gen1 != $gen ]] ||
9325 "Layout generation on $file1 does not change"
9326 gen=$($GETSTRIPE -g $file2)
9327 [[ $gen2 != $gen ]] ||
9328 "Layout generation on $file2 does not change"
9330 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
9331 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
9333 run_test 184a "Basic layout swap"
9336 check_swap_layouts_support && return 0
9338 dir0=$DIR/$tdir/$testnum
9339 mkdir -p $dir0 || error "creating dir $dir0"
9346 $SETSTRIPE -c1 $file1
9347 $SETSTRIPE -c2 $file2
9348 $SETSTRIPE -c1 $file3
9349 chown $RUNAS_ID $file3
9350 gen1=$($GETSTRIPE -g $file1)
9351 gen2=$($GETSTRIPE -g $file2)
9353 $LFS swap_layouts $dir1 $dir2 &&
9354 error "swap of directories layouts should fail"
9355 $LFS swap_layouts $dir1 $file1 &&
9356 error "swap of directory and file layouts should fail"
9357 $RUNAS $LFS swap_layouts $file1 $file2 &&
9358 error "swap of file we cannot write should fail"
9359 $LFS swap_layouts $file1 $file3 &&
9360 error "swap of file with different owner should fail"
9361 /bin/true # to clear error code
9363 run_test 184b "Forbidden layout swap (will generate errors)"
9366 check_swap_layouts_support && return 0
9368 dir0=$DIR/$tdir/$testnum
9369 mkdir -p $dir0 || error "creating dir $dir0"
9374 # create a file large enough for the concurent test
9375 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
9376 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
9377 echo "ref file size: ref1(`stat -c %s $ref1`), ref2(`stat -c %s $ref2`)"
9380 dd if=$ref1 of=$file1 bs=64k &
9381 sleep 0.$((RANDOM % 5 + 1))
9383 $LFS swap_layouts $file1 $file2
9386 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
9387 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
9389 # how many bytes copied before swapping layout
9390 local copied=`stat -c %s $file2`
9391 local remaining=`stat -c %s $ref1`
9392 remaining=$((remaining - copied))
9393 echo "Copied $copied bytes before swapping layout..."
9395 cmp -n $copied $file1 $ref2 ||
9396 error "Content mismatch [0, $copied) of ref2 and file1"
9397 cmp -n $copied $file2 $ref1 ||
9398 error "Content mismatch [0, $copied) of ref1 and file2"
9399 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
9400 error "Content mismatch [$copied, EOF) of ref1 and file1"
9403 rm -f $ref1 $ref2 $file1 $file2
9405 run_test 184c "Concurrent write and layout swap"
9408 check_file_in_pool()
9413 local res=$($GETSTRIPE $file | grep 0x | cut -f2)
9416 for t in $tlist ; do
9417 [ "$i" -eq "$t" ] && continue 2
9420 echo "pool list: $tlist"
9421 echo "striping: $res"
9422 error_noexit "$file not allocated in $pool"
9429 echo "Creating new pool"
9432 create_pool $FSNAME.$pool ||
9433 { error_noexit "No pool created, result code $?"; return 1; }
9434 [ $($LFS pool_list $FSNAME | grep -c $pool) -eq 1 ] ||
9435 { error_noexit "$pool not in lfs pool_list"; return 2; }
9438 pool_add_targets() {
9439 echo "Adding targets to pool"
9445 local list=$(seq $first $step $last)
9447 local t=$(for i in $list; do printf "$FSNAME-OST%04x_UUID " $i; done)
9448 do_facet mgs $LCTL pool_add \
9449 $FSNAME.$pool $FSNAME-OST[$first-$last/$step]
9450 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$pool \
9451 | sort -u | tr '\n' ' ' " "$t" || {
9452 error_noexit "Add to pool failed"
9455 local lfscount=$($LFS pool_list $FSNAME.$pool | grep -c "\-OST")
9456 local addcount=$(((last - first) / step + 1))
9457 [ $lfscount -eq $addcount ] || {
9458 error_noexit "lfs pool_list bad ost count" \
9459 "$lfscount != $addcount"
9467 echo "Setting pool on directory $tdir"
9469 $SETSTRIPE -c 2 -p $pool $tdir && return 0
9471 error_noexit "Cannot set pool $pool to $tdir"
9478 echo "Checking pool on directory $tdir"
9480 local res=$($GETSTRIPE --pool $tdir | sed "s/\s*$//")
9481 [ "$res" = "$pool" ] && return 0
9483 error_noexit "Pool on '$tdir' is '$res', not '$pool'"
9487 pool_dir_rel_path() {
9488 echo "Testing relative path works well"
9493 mkdir -p $root/$tdir/$tdir
9495 pool_set_dir $pool $tdir || return 1
9496 pool_set_dir $pool ./$tdir || return 2
9497 pool_set_dir $pool ../$tdir || return 3
9498 pool_set_dir $pool ../$tdir/$tdir || return 4
9499 rm -rf $tdir; cd - > /dev/null
9502 pool_alloc_files() {
9503 echo "Checking files allocation from directory pool"
9510 for i in $(seq -w 1 $count)
9512 local file=$tdir/file-$i
9514 check_file_in_pool $file $pool "$tlist" || \
9515 failed=$((failed + 1))
9517 [ "$failed" = 0 ] && return 0
9519 error_noexit "$failed files not allocated in $pool"
9523 pool_create_files() {
9524 echo "Creating files in pool"
9532 for i in $(seq -w 1 $count)
9534 local file=$tdir/spoo-$i
9535 $SETSTRIPE -p $pool $file
9536 check_file_in_pool $file $pool "$tlist" || \
9537 failed=$((failed + 1))
9539 [ "$failed" = 0 ] && return 0
9541 error_noexit "$failed files not allocated in $pool"
9546 echo "Checking 'lfs df' output"
9549 local t=$($LCTL get_param -n lov.$FSNAME-clilov-*.pools.$pool |
9551 local res=$($LFS df --pool $FSNAME.$pool |
9553 grep "$FSNAME-OST" |
9555 [ "$res" = "$t" ] && return 0
9557 error_noexit "Pools OSTs '$t' is not '$res' that lfs df reports"
9561 pool_file_rel_path() {
9562 echo "Creating files in a pool with relative pathname"
9567 { error_noexit "unable to create $tdir"; return 1 ; }
9568 local file="/..$tdir/$tfile-1"
9569 $SETSTRIPE -p $pool $file ||
9570 { error_noexit "unable to create $file" ; return 2 ; }
9573 $SETSTRIPE -p $pool $tfile-2 || {
9574 error_noexit "unable to create $tfile-2 in $tdir"
9579 pool_remove_first_target() {
9580 echo "Removing first target from a pool"
9583 local pname="lov.$FSNAME-*.pools.$pool"
9584 local t=$($LCTL get_param -n $pname | head -1)
9585 do_facet mgs $LCTL pool_remove $FSNAME.$pool $t
9586 wait_update $HOSTNAME "lctl get_param -n $pname | grep $t" "" || {
9587 error_noexit "$t not removed from $FSNAME.$pool"
9592 pool_remove_all_targets() {
9593 echo "Removing all targets from pool"
9596 local pname="lov.$FSNAME-*.pools.$pool"
9597 for t in $($LCTL get_param -n $pname | sort -u)
9599 do_facet mgs $LCTL pool_remove $FSNAME.$pool $t
9601 wait_update $HOSTNAME "lctl get_param -n $pname" "" || {
9602 error_noexit "Pool $FSNAME.$pool cannot be drained"
9605 # striping on an empty/nonexistant pool should fall back
9606 # to "pool of everything"
9608 error_noexit "failed to use fallback striping for empty pool"
9611 # setstripe on an empty pool should fail
9612 $SETSTRIPE -p $pool $file 2>/dev/null && {
9613 error_noexit "expected failure when creating file" \
9621 echo "Destroying pool"
9625 do_facet mgs $LCTL pool_destroy $FSNAME.$pool
9628 # striping on an empty/nonexistant pool should fall back
9629 # to "pool of everything"
9631 error_noexit "failed to use fallback striping for missing pool"
9634 # setstripe on an empty pool should fail
9635 $SETSTRIPE -p $pool $file 2>/dev/null && {
9636 error_noexit "expected failure when creating file" \
9641 # get param should return err once pool is gone
9642 if wait_update $HOSTNAME "lctl get_param -n \
9643 lov.$FSNAME-*.pools.$pool 2>/dev/null || echo foo" "foo"
9645 remove_pool_from_list $FSNAME.$pool
9648 error_noexit "Pool $FSNAME.$pool is not destroyed"
9653 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9654 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
9656 local POOL=${POOL:-cea1}
9657 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
9658 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
9661 local last_ost=$(($OSTCOUNT - 1))
9663 local ost_list=$(seq $first_ost $ost_step $last_ost)
9664 local ost_range="$first_ost $last_ost $ost_step"
9665 local test_path=$POOL_ROOT/$POOL_DIR_NAME
9666 local file_dir=$POOL_ROOT/file_tst
9670 # former test_200a test_200b
9671 pool_add $POOL || { rc=$? ; break; }
9672 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
9673 # former test_200c test_200d
9675 pool_set_dir $POOL $test_path || { rc=$? ; break; }
9676 pool_check_dir $POOL $test_path || { rc=$? ; break; }
9677 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
9678 || { rc=$? ; break; }
9679 # former test_200e test_200f
9680 local files=$((OSTCOUNT*3))
9681 pool_alloc_files $POOL $test_path $files "$ost_list" \
9682 || { rc=$? ; break; }
9683 pool_create_files $POOL $file_dir $files "$ost_list" \
9684 || { rc=$? ; break; }
9685 # former test_200g test_200h
9686 pool_lfs_df $POOL || { rc=$? ; break; }
9687 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
9689 # former test_201a test_201b test_201c
9690 pool_remove_first_target $POOL || { rc=$? ; break; }
9692 local f=$test_path/$tfile
9693 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
9694 pool_remove $POOL $f || { rc=$? ; break; }
9701 run_test 200 "OST pools"
9703 # usage: default_attr <count | size | offset>
9705 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
9708 # usage: check_default_stripe_attr
9709 check_default_stripe_attr() {
9710 ACTUAL=$($GETSTRIPE $* $DIR/$tdir)
9712 --stripe-count|--count)
9713 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
9714 --stripe-size|--size)
9715 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
9716 --stripe-index|--index)
9719 error "unknown getstripe attr '$1'"
9722 [ $ACTUAL != $EXPECTED ] &&
9723 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
9727 test_mkdir -p $DIR/$tdir
9728 $SETSTRIPE --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
9730 check_default_stripe_attr --stripe-count
9731 check_default_stripe_attr --stripe-size
9732 check_default_stripe_attr --stripe-index
9736 run_test 204a "Print default stripe attributes ================="
9739 test_mkdir -p $DIR/$tdir
9740 $SETSTRIPE --stripe-count 1 $DIR/$tdir
9742 check_default_stripe_attr --stripe-size
9743 check_default_stripe_attr --stripe-index
9747 run_test 204b "Print default stripe size and offset ==========="
9750 test_mkdir -p $DIR/$tdir
9751 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
9753 check_default_stripe_attr --stripe-count
9754 check_default_stripe_attr --stripe-index
9758 run_test 204c "Print default stripe count and offset ==========="
9761 test_mkdir -p $DIR/$tdir
9762 $SETSTRIPE --stripe-index 0 $DIR/$tdir
9764 check_default_stripe_attr --stripe-count
9765 check_default_stripe_attr --stripe-size
9769 run_test 204d "Print default stripe count and size ============="
9772 test_mkdir -p $DIR/$tdir
9773 $SETSTRIPE -d $DIR/$tdir
9775 check_default_stripe_attr --stripe-count --raw
9776 check_default_stripe_attr --stripe-size --raw
9777 check_default_stripe_attr --stripe-index --raw
9781 run_test 204e "Print raw stripe attributes ================="
9784 test_mkdir -p $DIR/$tdir
9785 $SETSTRIPE --stripe-count 1 $DIR/$tdir
9787 check_default_stripe_attr --stripe-size --raw
9788 check_default_stripe_attr --stripe-index --raw
9792 run_test 204f "Print raw stripe size and offset ==========="
9795 test_mkdir -p $DIR/$tdir
9796 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
9798 check_default_stripe_attr --stripe-count --raw
9799 check_default_stripe_attr --stripe-index --raw
9803 run_test 204g "Print raw stripe count and offset ==========="
9806 test_mkdir -p $DIR/$tdir
9807 $SETSTRIPE --stripe-index 0 $DIR/$tdir
9809 check_default_stripe_attr --stripe-count --raw
9810 check_default_stripe_attr --stripe-size --raw
9814 run_test 204h "Print raw stripe count and size ============="
9816 # Figure out which job scheduler is being used, if any,
9818 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
9820 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
9822 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
9824 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
9825 JOBENV=LOADL_STEP_ID
9826 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
9836 # clear old jobstats
9837 do_facet $SINGLEMDS lctl set_param mdt.*.job_stats="clear"
9838 do_facet ost1 lctl set_param obdfilter.*.job_stats="clear"
9840 # use a new JobID for this test, or we might see an old one
9841 [ "$JOBENV" = "FAKE_JOBID" ] && FAKE_JOBID=test_id.$testnum.$RANDOM
9845 log "Using JobID environment variable $JOBENV=$JOBVAL"
9847 if [ $JOBENV = "FAKE_JOBID" ]; then
9848 FAKE_JOBID=$JOBVAL $cmd
9853 if [ "$target" = "mdt" -o "$target" = "both" ]; then
9854 FACET="$SINGLEMDS" # will need to get MDS number for DNE
9855 do_facet $FACET lctl get_param mdt.*.job_stats |
9856 grep $JOBVAL || error "No job stats found on MDT $FACET"
9858 if [ "$target" = "ost" -o "$target" = "both" ]; then
9860 do_facet $FACET lctl get_param obdfilter.*.job_stats |
9861 grep $JOBVAL || error "No job stats found on OST $FACET"
9865 test_205() { # Job stats
9866 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9867 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
9868 skip "Server doesn't support jobstats" && return 0
9871 OLD_JOBENV=`$LCTL get_param -n jobid_var`
9872 if [ $OLD_JOBENV != $JOBENV ]; then
9873 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$JOBENV
9874 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" \
9879 cmd="mkdir $DIR/$tfile"
9880 verify_jobstats "$cmd" "mdt"
9882 cmd="rm -fr $DIR/$tfile"
9883 verify_jobstats "$cmd" "mdt"
9885 cmd="mknod $DIR/$tfile c 1 3"
9886 verify_jobstats "$cmd" "mdt"
9888 cmd="rm -f $DIR/$tfile"
9889 verify_jobstats "$cmd" "mdt"
9891 cmd="$SETSTRIPE -i 0 -c 1 $DIR/$tfile"
9892 verify_jobstats "$cmd" "mdt"
9894 cmd="touch $DIR/$tfile"
9895 verify_jobstats "$cmd" "both"
9897 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
9898 verify_jobstats "$cmd" "ost"
9900 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
9901 verify_jobstats "$cmd" "ost"
9903 cmd="$TRUNCATE $DIR/$tfile 0"
9904 verify_jobstats "$cmd" "both"
9906 cmd="mv -f $DIR/$tfile $DIR/jobstats_test_rename"
9907 verify_jobstats "$cmd" "mdt"
9910 rm -f $DIR/jobstats_test_rename
9912 if [ $OLD_JOBENV != $JOBENV ]; then
9913 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$OLD_JOBENV
9914 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" \
9915 $OLD_JOBENV || return 1
9918 run_test 205 "Verify job stats"
9920 # LU-1480, LU-1773 and LU-1657
9923 lfs setstripe -c -1 $DIR/$tdir
9924 #define OBD_FAIL_LOV_INIT 0x1403
9925 $LCTL set_param fail_loc=0xa0001403
9926 $LCTL set_param fail_val=1
9927 touch $DIR/$tdir/$tfile || true
9929 run_test 206 "fail lov_init_raid0() doesn't lbug"
9932 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
9933 local fsz=`stat -c %s $DIR/$tfile`
9934 cancel_lru_locks mdc
9936 # do not return layout in getattr intent
9937 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
9938 $LCTL set_param fail_loc=0x170
9939 local sz=`stat -c %s $DIR/$tfile`
9941 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
9945 run_test 207a "can refresh layout at glimpse"
9948 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
9949 local cksum=`md5sum $DIR/$tfile`
9950 local fsz=`stat -c %s $DIR/$tfile`
9951 cancel_lru_locks mdc
9952 cancel_lru_locks osc
9954 # do not return layout in getattr intent
9955 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
9956 $LCTL set_param fail_loc=0x171
9958 # it will refresh layout after the file is opened but before read issues
9959 echo checksum is "$cksum"
9960 echo "$cksum" |md5sum -c --quiet || error "file differs"
9964 run_test 207b "can refresh layout at open"
9968 size=$((size % 8192 + 1))
9969 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
9970 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
9971 rm -f $DIR/f212 $DIR/f212.xyz
9973 run_test 212 "Sendfile test ============================================"
9976 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
9977 cancel_lru_locks osc
9978 lctl set_param fail_loc=0x8000040f
9979 # generate a read lock
9980 cat $DIR/$tfile > /dev/null
9981 # write to the file, it will try to cancel the above read lock.
9982 cat /etc/hosts >> $DIR/$tfile
9984 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
9986 test_214() { # for bug 20133
9987 test_mkdir -p $DIR/d214p/d214c
9988 for (( i=0; i < 340; i++ )) ; do
9989 touch $DIR/d214p/d214c/a$i
9992 ls -l $DIR/d214p || error "ls -l $DIR/d214p failed"
9993 mv $DIR/d214p/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
9994 ls $DIR/d214c || error "ls $DIR/d214c failed"
9995 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
9997 run_test 214 "hash-indexed directory test - bug 20133"
9999 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
10000 create_lnet_proc_files() {
10001 cat /proc/sys/lnet/$1 >$TMP/lnet_$1.out || error "cannot read /proc/sys/lnet/$1"
10002 sysctl lnet.$1 >$TMP/lnet_$1.sys_tmp || error "cannot read lnet.$1"
10004 sed "s/^lnet.$1\ =\ //g" "$TMP/lnet_$1.sys_tmp" >$TMP/lnet_$1.sys
10005 rm -f "$TMP/lnet_$1.sys_tmp"
10008 # counterpart of create_lnet_proc_files
10009 remove_lnet_proc_files() {
10010 rm -f $TMP/lnet_$1.out $TMP/lnet_$1.sys
10013 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
10014 # 3rd arg as regexp for body
10015 check_lnet_proc_stats() {
10016 local l=$(cat "$TMP/lnet_$1" |wc -l)
10017 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
10019 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
10022 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
10023 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
10024 # optional and can be regexp for 2nd line (lnet.routes case)
10025 check_lnet_proc_entry() {
10026 local blp=2 # blp stands for 'position of 1st line of body'
10027 [ "$5" = "" ] || blp=3 # lnet.routes case
10029 local l=$(cat "$TMP/lnet_$1" |wc -l)
10030 # subtracting one from $blp because the body can be empty
10031 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
10033 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
10034 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
10036 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
10037 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
10039 # bail out if any unexpected line happened
10040 sed -n "$blp~1 p" "$TMP/lnet_$1" |grep -Ev "$3"
10041 [ "$?" != 0 ] || error "$2 misformatted"
10044 test_215() { # for bugs 18102, 21079, 21517
10045 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10046 local N='(0|[1-9][0-9]*)' # non-negative numeric
10047 local P='[1-9][0-9]*' # positive numeric
10048 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
10049 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
10050 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
10051 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
10053 local L1 # regexp for 1st line
10054 local L2 # regexp for 2nd line (optional)
10055 local BR # regexp for the rest (body)
10057 # /proc/sys/lnet/stats should look as 11 space-separated non-negative numerics
10058 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
10059 create_lnet_proc_files "stats"
10060 check_lnet_proc_stats "stats.out" "/proc/sys/lnet/stats" "$BR"
10061 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
10062 remove_lnet_proc_files "stats"
10064 # /proc/sys/lnet/routes should look like this:
10065 # Routing disabled/enabled
10066 # net hops state router
10067 # where net is a string like tcp0, hops >= 0, state is up/down,
10068 # router is a string like 192.168.1.1@tcp2
10069 L1="^Routing (disabled|enabled)$"
10070 L2="^net +hops +state +router$"
10071 BR="^$NET +$N +(up|down) +$NID$"
10072 create_lnet_proc_files "routes"
10073 check_lnet_proc_entry "routes.out" "/proc/sys/lnet/routes" "$BR" "$L1" "$L2"
10074 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
10075 remove_lnet_proc_files "routes"
10077 # /proc/sys/lnet/routers should look like this:
10078 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
10079 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
10080 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
10081 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
10082 L1="^ref +rtr_ref +alive_cnt +state +last_ping +ping_sent +deadline +down_ni +router$"
10083 BR="^$P +$P +$N +(up|down) +$N +(0|1) +$I +$I +$NID$"
10084 create_lnet_proc_files "routers"
10085 check_lnet_proc_entry "routers.out" "/proc/sys/lnet/routers" "$BR" "$L1"
10086 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
10087 remove_lnet_proc_files "routers"
10089 # /proc/sys/lnet/peers should look like this:
10090 # nid refs state last max rtr min tx min queue
10091 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
10092 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
10093 # numeric (0 or >0 or <0), queue >= 0.
10094 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
10095 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
10096 create_lnet_proc_files "peers"
10097 check_lnet_proc_entry "peers.out" "/proc/sys/lnet/peers" "$BR" "$L1"
10098 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
10099 remove_lnet_proc_files "peers"
10101 # /proc/sys/lnet/buffers should look like this:
10102 # pages count credits min
10103 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
10104 L1="^pages +count +credits +min$"
10105 BR="^ +$N +$N +$I +$I$"
10106 create_lnet_proc_files "buffers"
10107 check_lnet_proc_entry "buffers.out" "/proc/sys/lnet/buffers" "$BR" "$L1"
10108 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
10109 remove_lnet_proc_files "buffers"
10111 # /proc/sys/lnet/nis should look like this:
10112 # nid status alive refs peer rtr max tx min
10113 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
10114 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
10115 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
10116 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
10117 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
10118 create_lnet_proc_files "nis"
10119 check_lnet_proc_entry "nis.out" "/proc/sys/lnet/nis" "$BR" "$L1"
10120 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
10121 remove_lnet_proc_files "nis"
10123 # can we successfully write to /proc/sys/lnet/stats?
10124 echo "0" >/proc/sys/lnet/stats || error "cannot write to /proc/sys/lnet/stats"
10125 sysctl -w lnet.stats=0 || error "cannot write to lnet.stats"
10127 run_test 215 "/proc/sys/lnet exists and has proper content - bugs 18102, 21079, 21517"
10129 test_216() { # bug 20317
10130 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10131 remote_ost_nodsh && skip "remote OST with nodsh" && return
10133 local p="$TMP/sanityN-$TESTNAME.parameters"
10134 save_lustre_params $HOSTNAME "osc.*.contention_seconds" > $p
10135 for node in $(osts_nodes); do
10136 save_lustre_params $node "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
10137 save_lustre_params $node "ldlm.namespaces.filter-*.contended_locks" >> $p
10138 save_lustre_params $node "ldlm.namespaces.filter-*.contention_seconds" >> $p
10142 # agressive lockless i/o settings
10143 for node in $(osts_nodes); do
10144 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'
10146 lctl set_param -n osc.*.contention_seconds 60
10148 $DIRECTIO write $DIR/$tfile 0 10 4096
10149 $CHECKSTAT -s 40960 $DIR/$tfile
10151 # disable lockless i/o
10152 for node in $(osts_nodes); do
10153 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'
10155 lctl set_param -n osc.*.contention_seconds 0
10158 dd if=/dev/zero of=$DIR/$tfile count=0
10159 $CHECKSTAT -s 0 $DIR/$tfile
10161 restore_lustre_params <$p
10165 run_test 216 "check lockless direct write works and updates file size and kms correctly"
10167 test_217() { # bug 22430
10168 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10172 for node in $(nodes_list); do
10173 nid=$(host_nids_address $node $NETTYPE)
10174 if [[ $nid = *-* ]] ; then
10175 echo "lctl ping $nid@$NETTYPE"
10176 lctl ping $nid@$NETTYPE
10178 echo "skipping $node (no hyphen detected)"
10182 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
10185 # do directio so as not to populate the page cache
10186 log "creating a 10 Mb file"
10187 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
10188 log "starting reads"
10189 dd if=$DIR/$tfile of=/dev/null bs=4096 &
10190 log "truncating the file"
10191 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
10193 kill %+ || true # reads might have finished
10194 echo "wait until dd is finished"
10196 log "removing the temporary file"
10197 rm -rf $DIR/$tfile || error "tmp file removal failed"
10199 run_test 218 "parallel read and truncate should not deadlock ======================="
10202 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10203 # write one partial page
10204 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
10205 # set no grant so vvp_io_commit_write will do sync write
10206 $LCTL set_param fail_loc=0x411
10207 # write a full page at the end of file
10208 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
10210 $LCTL set_param fail_loc=0
10211 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
10212 $LCTL set_param fail_loc=0x411
10213 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
10215 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
10217 test_220() { #LU-325
10218 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10219 remote_ost_nodsh && skip "remote OST with nodsh" && return
10222 test_mkdir -p $DIR/$tdir
10223 local OST=$(lfs osts | grep ${OSTIDX}": " | \
10224 awk '{print $2}' | sed -e 's/_UUID$//')
10227 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
10228 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
10229 osc.$mdtosc_proc1.prealloc_last_id)
10230 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
10231 osc.$mdtosc_proc1.prealloc_next_id)
10235 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
10236 #define OBD_FAIL_OST_ENOINO 0x229
10237 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
10238 do_facet mgs $LCTL pool_new $FSNAME.$TESTNAME || return 1
10239 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
10241 $SETSTRIPE $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
10243 MDSOBJS=$((last_id - next_id))
10244 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
10246 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
10247 echo "OST still has $count kbytes free"
10249 echo "create $MDSOBJS files @next_id..."
10250 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
10252 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
10253 osc.$mdtosc_proc1.prealloc_last_id)
10254 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
10255 osc.$mdtosc_proc1.prealloc_next_id)
10257 echo "after creation, last_id=$last_id2, next_id=$next_id2"
10262 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
10263 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
10265 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST || return 4
10266 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME || return 5
10267 echo "unlink $MDSOBJS files @$next_id..."
10268 unlinkmany $DIR/$tdir/f $MDSOBJS || return 6
10270 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
10273 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10274 dd if=`which date` of=$MOUNT/date oflag=sync
10275 chmod +x $MOUNT/date
10277 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
10278 $LCTL set_param fail_loc=0x80001401
10280 $MOUNT/date > /dev/null
10283 run_test 221 "make sure fault and truncate race to not cause OOM"
10286 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10288 test_mkdir -p $DIR/$tdir
10289 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
10290 createmany -o $DIR/$tdir/$tfile 10
10291 cancel_lru_locks mdc
10292 cancel_lru_locks osc
10293 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
10294 $LCTL set_param fail_loc=0x31a
10295 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
10296 $LCTL set_param fail_loc=0
10299 run_test 222a "AGL for ls should not trigger CLIO lock failure ================"
10302 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10304 test_mkdir -p $DIR/$tdir
10305 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
10306 createmany -o $DIR/$tdir/$tfile 10
10307 cancel_lru_locks mdc
10308 cancel_lru_locks osc
10309 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
10310 $LCTL set_param fail_loc=0x31a
10311 rm -r $DIR/$tdir || "AGL for rmdir failed"
10312 $LCTL set_param fail_loc=0
10314 run_test 222b "AGL for rmdir should not trigger CLIO lock failure ============="
10317 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10319 test_mkdir -p $DIR/$tdir
10320 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
10321 createmany -o $DIR/$tdir/$tfile 10
10322 cancel_lru_locks mdc
10323 cancel_lru_locks osc
10324 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
10325 $LCTL set_param fail_loc=0x31b
10326 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
10327 $LCTL set_param fail_loc=0
10330 run_test 223 "osc reenqueue if without AGL lock granted ======================="
10332 test_224a() { # LU-1039, MRP-303
10333 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10334 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
10335 $LCTL set_param fail_loc=0x508
10336 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
10337 $LCTL set_param fail_loc=0
10340 run_test 224a "Don't panic on bulk IO failure"
10342 test_224b() { # LU-1039, MRP-303
10343 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10344 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
10345 cancel_lru_locks osc
10346 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
10347 $LCTL set_param fail_loc=0x515
10348 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
10349 $LCTL set_param fail_loc=0
10352 run_test 224b "Don't panic on bulk IO failure"
10354 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
10356 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10357 if [ -z ${MDSSURVEY} ]; then
10358 skip_env "mds-survey not found" && return
10360 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
10361 { skip "Need MDS version at least 2.2.51"; return; }
10363 local mds=$(facet_host $SINGLEMDS)
10364 local target=$(do_nodes $mds 'lctl dl' | \
10365 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
10367 local cmd1="file_count=1000 thrhi=4"
10368 local cmd2="dir_count=2 layer=mdd stripe_count=0"
10369 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
10370 local cmd="$cmd1 $cmd2 $cmd3"
10372 rm -f ${TMP}/mds_survey*
10374 eval $cmd || error "mds-survey with zero-stripe failed"
10375 cat ${TMP}/mds_survey*
10376 rm -f ${TMP}/mds_survey*
10378 run_test 225a "Metadata survey sanity with zero-stripe"
10381 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10382 if [ -z ${MDSSURVEY} ]; then
10383 skip_env "mds-survey not found" && return
10385 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
10386 { skip "Need MDS version at least 2.2.51"; return; }
10388 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
10389 skip_env "Need to mount OST to test" && return
10392 local mds=$(facet_host $SINGLEMDS)
10393 local target=$(do_nodes $mds 'lctl dl' | \
10394 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
10396 local cmd1="file_count=1000 thrhi=4"
10397 local cmd2="dir_count=2 layer=mdd stripe_count=1"
10398 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
10399 local cmd="$cmd1 $cmd2 $cmd3"
10401 rm -f ${TMP}/mds_survey*
10403 eval $cmd || error "mds-survey with stripe_count failed"
10404 cat ${TMP}/mds_survey*
10405 rm -f ${TMP}/mds_survey*
10407 run_test 225b "Metadata survey sanity with stripe_count = 1"
10409 mcreate_path2fid () {
10415 local path=$DIR/$tdir/$name
10420 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
10421 error "cannot create $desc"
10423 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
10425 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
10427 fid_path=$($LFS fid2path $MOUNT $fid)
10429 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
10431 [ "$path" == "$fid_path" ] ||
10432 error "fid2path returned $fid_path, expected $path"
10434 echo "pass with $path and $fid"
10439 mkdir -p $DIR/$tdir
10441 mcreate_path2fid 0010666 0 0 fifo "FIFO"
10442 mcreate_path2fid 0020666 1 3 null "character special file (null)"
10443 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
10444 mcreate_path2fid 0040666 0 0 dir "directory"
10445 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
10446 mcreate_path2fid 0100666 0 0 file "regular file"
10447 mcreate_path2fid 0120666 0 0 link "symbolic link"
10448 mcreate_path2fid 0140666 0 0 sock "socket"
10450 run_test 226 "call path2fid and fid2path on files of all type"
10452 # LU-1299 Executing or running ldd on a truncated executable does not
10453 # cause an out-of-memory condition.
10455 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10456 dd if=`which date` of=$MOUNT/date bs=1k count=1
10457 chmod +x $MOUNT/date
10459 $MOUNT/date > /dev/null
10460 ldd $MOUNT/date > /dev/null
10463 run_test 227 "running truncated executable does not cause OOM"
10465 # LU-1512 try to reuse idle OI blocks
10467 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10468 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
10469 skip "non-ldiskfs backend" && return
10471 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
10472 local myDIR=$DIR/$tdir
10475 #define OBD_FAIL_SEQ_EXHAUST 0x1002
10476 $LCTL set_param fail_loc=0x80001002
10477 createmany -o $myDIR/t- 10000
10478 $LCTL set_param fail_loc=0
10479 # The guard is current the largest FID holder
10481 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
10483 local IDX=$(($SEQ % 64))
10485 do_facet $SINGLEMDS sync
10486 # Make sure journal flushed.
10488 local blk1=$(do_facet $SINGLEMDS \
10489 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
10490 grep Blockcount | awk '{print $4}')
10492 # Remove old files, some OI blocks will become idle.
10493 unlinkmany $myDIR/t- 10000
10494 # Create new files, idle OI blocks should be reused.
10495 createmany -o $myDIR/t- 2000
10496 do_facet $SINGLEMDS sync
10497 # Make sure journal flushed.
10499 local blk2=$(do_facet $SINGLEMDS \
10500 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
10501 grep Blockcount | awk '{print $4}')
10503 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
10505 run_test 228a "try to reuse idle OI blocks"
10508 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10509 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
10510 skip "non-ldiskfs backend" && return
10512 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
10513 local myDIR=$DIR/$tdir
10516 #define OBD_FAIL_SEQ_EXHAUST 0x1002
10517 $LCTL set_param fail_loc=0x80001002
10518 createmany -o $myDIR/t- 10000
10519 $LCTL set_param fail_loc=0
10520 # The guard is current the largest FID holder
10522 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
10524 local IDX=$(($SEQ % 64))
10526 do_facet $SINGLEMDS sync
10527 # Make sure journal flushed.
10529 local blk1=$(do_facet $SINGLEMDS \
10530 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
10531 grep Blockcount | awk '{print $4}')
10533 # Remove old files, some OI blocks will become idle.
10534 unlinkmany $myDIR/t- 10000
10537 stop $SINGLEMDS || error "Fail to stop MDT."
10539 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
10541 df $MOUNT || error "Fail to df."
10542 # Create new files, idle OI blocks should be reused.
10543 createmany -o $myDIR/t- 2000
10544 do_facet $SINGLEMDS sync
10545 # Make sure journal flushed.
10547 local blk2=$(do_facet $SINGLEMDS \
10548 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
10549 grep Blockcount | awk '{print $4}')
10551 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
10553 run_test 228b "idle OI blocks can be reused after MDT restart"
10557 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10558 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
10559 skip "non-ldiskfs backend" && return
10561 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
10562 local myDIR=$DIR/$tdir
10565 #define OBD_FAIL_SEQ_EXHAUST 0x1002
10566 $LCTL set_param fail_loc=0x80001002
10567 # 20000 files can guarantee there are index nodes in the OI file
10568 createmany -o $myDIR/t- 20000
10569 $LCTL set_param fail_loc=0
10570 # The guard is current the largest FID holder
10572 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
10574 local IDX=$(($SEQ % 64))
10576 do_facet $SINGLEMDS sync
10577 # Make sure journal flushed.
10579 local blk1=$(do_facet $SINGLEMDS \
10580 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
10581 grep Blockcount | awk '{print $4}')
10583 # Remove old files, some OI blocks will become idle.
10584 unlinkmany $myDIR/t- 20000
10586 # The OI file should become empty now
10588 # Create new files, idle OI blocks should be reused.
10589 createmany -o $myDIR/t- 2000
10590 do_facet $SINGLEMDS sync
10591 # Make sure journal flushed.
10593 local blk2=$(do_facet $SINGLEMDS \
10594 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
10595 grep Blockcount | awk '{print $4}')
10597 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
10599 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
10602 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10603 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
10606 mkdir -p $DIR/$tdir/test_230_local
10607 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230_local)
10608 [ $mdt_idx -ne 0 ] &&
10609 error "create local directory on wrong MDT $mdt_idx"
10611 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
10612 error "create remote directory failed"
10613 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230)
10614 [ $mdt_idx -ne $MDTIDX ] &&
10615 error "create remote directory on wrong MDT $mdt_idx"
10617 createmany -o $DIR/$tdir/test_230/t- 10 ||
10618 error "create files on remote directory failed"
10619 mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230/t-0)
10620 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
10621 rm -r $DIR/$tdir || error "unlink remote directory failed"
10623 run_test 230a "Create remote directory and files under the remote directory"
10626 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10627 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
10629 local remote_dir=$DIR/$tdir/remote_dir
10632 mkdir -p $DIR/$tdir
10633 $LFS mkdir -i $MDTIDX $remote_dir ||
10634 error "create remote directory failed"
10636 $LFS mkdir -i 0 $remote_dir/new_dir &&
10637 error "nested remote directory create succeed!"
10639 do_facet mds$((MDTIDX + 1)) lctl set_param mdt.*.enable_remote_dir=1
10640 $LFS mkdir -i 0 $remote_dir/new_dir || rc=$?
10641 do_facet mds$((MDTIDX + 1)) lctl set_param mdt.*.enable_remote_dir=0
10644 error "create remote directory failed after set enable_remote_dir"
10646 rm -r $DIR/$tdir || error "unlink remote directory failed"
10648 run_test 230b "nested remote directory should be failed"
10652 # For simplicity this test assumes that max_pages_per_rpc
10653 # is the same across all OSCs
10654 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -1)
10655 local bulk_size=$((max_pages * 4096))
10657 mkdir -p $DIR/$tdir
10659 # clear the OSC stats
10660 $LCTL set_param osc.*.stats=0 &>/dev/null
10662 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
10663 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
10664 oflag=direct &>/dev/null || error "dd failed"
10666 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
10667 if [ x$nrpcs != "x1" ]; then
10668 error "found $nrpc ost_write RPCs, not 1 as expected"
10671 # Drop the OSC cache, otherwise we will read from it
10672 cancel_lru_locks osc
10674 # clear the OSC stats
10675 $LCTL set_param osc.*.stats=0 &>/dev/null
10677 # Client reads $bulk_size.
10678 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
10679 iflag=direct &>/dev/null || error "dd failed"
10681 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
10682 if [ x$nrpcs != "x1" ]; then
10683 error "found $nrpc ost_read RPCs, not 1 as expected"
10686 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
10689 mkdir -p $DIR/$tdir
10691 for i in {0..1023}; do
10692 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
10693 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
10694 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
10698 run_test 231b "must not assert on fully utilized OST request buffer"
10701 # tests that do cleanup/setup should be run at the end
10705 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10707 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
10708 $LCTL set_param fail_loc=0x903
10709 # cancel_lru_locks mgc - does not work due to lctl set_param syntax
10710 for ls in /proc/fs/lustre/ldlm/namespaces/MGC*/lru_size; do
10713 FAIL_ON_ERROR=true cleanup
10714 FAIL_ON_ERROR=true setup
10716 run_test 900 "umount should not race with any mgc requeue thread"
10719 check_and_cleanup_lustre
10720 if [ "$I_MOUNTED" != "yes" ]; then
10721 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true