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 # Tests that fail on uml
21 CPU=`awk '/model/ {print $4}' /proc/cpuinfo`
22 # buffer i/o errs sock spc runas
23 [ "$CPU" = "UML" ] && EXCEPT="$EXCEPT 27m 27n 27o 27p 27q 27r 31d 54a 64b 99a 99b 99c 99d 99e 99f 101a"
25 SRCDIR=$(cd $(dirname $0); echo $PWD)
26 export PATH=$PATH:/sbin
30 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
31 CREATETEST=${CREATETEST:-createtest}
33 LFIND=${LFIND:-"$LFS find"}
34 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
36 MCREATE=${MCREATE:-mcreate}
37 OPENFILE=${OPENFILE:-openfile}
38 OPENUNLINK=${OPENUNLINK:-openunlink}
39 export MULTIOP=${MULTIOP:-multiop}
40 READS=${READS:-"reads"}
41 MUNLINK=${MUNLINK:-munlink}
42 SOCKETSERVER=${SOCKETSERVER:-socketserver}
43 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
44 MEMHOG=${MEMHOG:-memhog}
45 DIRECTIO=${DIRECTIO:-directio}
46 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
47 UMOUNT=${UMOUNT:-"umount -d"}
49 CHECK_GRANT=${CHECK_GRANT:-"yes"}
50 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
51 export PARALLEL=${PARALLEL:-"no"}
53 export NAME=${NAME:-local}
60 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
61 . $LUSTRE/tests/test-framework.sh
63 . ${CONFIG:=$LUSTRE/tests/cfg/${NAME}.sh}
66 [ "$SLOW" = "no" ] && EXCEPT_SLOW="24o 24v 27m 36f 36g 36h 51b 60c 63 64b 68 71 73 77f 78 101a 103 115 120g 124b"
72 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
73 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
82 check_kernel_version() {
84 GOT_VER=$(lctl get_param -n version | awk '/kernel:/ {print $2}')
86 patchless|patchless_client) return 0;;
87 *) [ $GOT_VER -ge $WANT_VER ] && return 0 ;;
89 log "test needs at least kernel version $WANT_VER, running $GOT_VER"
93 if [ "$ONLY" == "cleanup" ]; then
98 check_and_setup_lustre
103 MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid | \
104 awk '{gsub(/_UUID/,""); print $1}' | head -1)
105 LOVNAME=$($LCTL get_param -n llite.*.lov.common_name | tail -n 1)
106 OSTCOUNT=$($LCTL get_param -n lov.$LOVNAME.numobd)
107 STRIPECOUNT=$($LCTL get_param -n lov.$LOVNAME.stripecount)
108 STRIPESIZE=$($LCTL get_param -n lov.$LOVNAME.stripesize)
109 ORIGFREE=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
110 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
112 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
113 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
114 rm -rf $DIR/[Rdfs][0-9]*
116 # $RUNAS_ID may get set incorrectly somewhere else
117 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
119 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
123 if [ "${ONLY}" = "MOUNT" ] ; then
124 echo "Lustre is up, please go on"
128 echo "preparing for tests involving mounts"
129 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
131 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
132 echo # add a newline after mke2fs.
136 OLDDEBUG="`lctl get_param -n debug 2> /dev/null`"
137 lctl set_param debug=-1 2> /dev/null || true
140 $CHECKSTAT -t file $DIR/$tfile || error
142 $CHECKSTAT -a $DIR/$tfile || error
144 run_test 0 "touch .../$tfile ; rm .../$tfile ====================="
147 chmod 0755 $DIR || error
148 $CHECKSTAT -p 0755 $DIR || error
150 run_test 0b "chmod 0755 $DIR ============================="
153 $LCTL get_param mdc.*.import | grep "state: FULL" || error "import not FULL"
154 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" || error "bad target"
156 run_test 0c "check import proc ============================="
159 test_mkdir -p $DIR/$tdir
160 test_mkdir -p $DIR/$tdir/d2
161 test_mkdir $DIR/$tdir/d2 && error "we expect EEXIST, but not returned"
162 $CHECKSTAT -t dir $DIR/$tdir/d2 || error
164 run_test 1a "mkdir .../d1; mkdir .../d1/d2 ====================="
169 $CHECKSTAT -a $DIR/$tdir || error
171 run_test 1b "rmdir .../d1/d2; rmdir .../d1 ====================="
174 test_mkdir $DIR/$tdir
175 touch $DIR/$tdir/$tfile
176 $CHECKSTAT -t file $DIR/$tdir/$tfile || error
178 run_test 2a "mkdir .../d2; touch .../d2/f ======================"
182 $CHECKSTAT -a $DIR/$tdir || error
184 run_test 2b "rm -r .../d2; checkstat .../d2/f ======================"
187 test_mkdir -p $DIR/$tdir
188 $CHECKSTAT -t dir $DIR/$tdir || error
190 run_test 3a "mkdir .../d3 ======================================"
193 if [ ! -d $DIR/$tdir ]; then
196 touch $DIR/$tdir/$tfile
197 $CHECKSTAT -t file $DIR/$tdir/$tfile || error
199 run_test 3b "touch .../d3/f ===================================="
203 $CHECKSTAT -a $DIR/$tdir || error
205 run_test 3c "rm -r .../d3 ======================================"
208 test_mkdir -p $DIR/$tdir
209 $CHECKSTAT -t dir $DIR/$tdir || error
211 run_test 4a "mkdir .../d4 ======================================"
214 if [ ! -d $DIR/$tdir ]; then
215 test_mkdir $DIR/$tdir
217 test_mkdir $DIR/$tdir/d2
219 $CHECKSTAT -t dir $DIR/$tdir/d2 || error
221 run_test 4b "mkdir .../d4/d2 ==================================="
224 test_mkdir $DIR/$tdir
225 test_mkdir $DIR/$tdir/d2
226 chmod 0707 $DIR/$tdir/d2
227 $CHECKSTAT -t dir -p 0707 $DIR/$tdir/d2 || error
229 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2 ============"
233 chmod 0666 $DIR/$tfile || error
234 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile || error
236 run_test 6a "touch .../f6a; chmod .../f6a ======================"
239 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
240 if [ ! -f $DIR/$tfile ]; then
242 chmod 0666 $DIR/$tfile
244 $RUNAS chmod 0444 $DIR/$tfile && error
245 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile || error
247 run_test 6b "$RUNAS chmod .../f6a (should return error) =="
250 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
252 chown $RUNAS_ID $DIR/$tfile || error
253 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile || error
255 run_test 6c "touch .../f6c; chown .../f6c ======================"
258 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
259 if [ ! -f $DIR/$tfile ]; then
261 chown $RUNAS_ID $DIR/$tfile
263 $RUNAS chown $UID $DIR/$tfile && error
264 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile || error
266 run_test 6d "$RUNAS chown .../f6c (should return error) =="
269 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
271 chgrp $RUNAS_ID $DIR/$tfile || error
272 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile || error
274 run_test 6e "touch .../f6e; chgrp .../f6e ======================"
277 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
278 if [ ! -f $DIR/$tfile ]; then
280 chgrp $RUNAS_ID $DIR/$tfile
282 $RUNAS chgrp $UID $DIR/$tfile && error
283 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile || error
285 run_test 6f "$RUNAS chgrp .../f6e (should return error) =="
288 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
289 test_mkdir $DIR/$tdir || error
290 chmod 777 $DIR/$tdir || error
291 $RUNAS mkdir $DIR/$tdir/d || error
292 chmod g+s $DIR/$tdir/d || error
293 test_mkdir $DIR/$tdir/d/subdir
294 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir/d/subdir || error
296 run_test 6g "Is new dir in sgid dir inheriting group?"
298 test_6h() { # bug 7331
299 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
300 touch $DIR/$tfile || error "touch failed"
301 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
302 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
304 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/$tfile || error
306 run_test 6h "$RUNAS chown RUNAS_ID.0 .../f6h (should return error)"
309 test_mkdir $DIR/$tdir
310 $MCREATE $DIR/$tdir/$tfile
311 chmod 0666 $DIR/$tdir/$tfile
312 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile || error
314 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
317 if [ ! -d $DIR/$tdir ]; then
320 $MCREATE $DIR/$tdir/$tfile
321 echo -n foo > $DIR/$tdir/$tfile
322 [ "`cat $DIR/$tdir/$tfile`" = "foo" ] || error
323 $CHECKSTAT -t file -s 3 $DIR/$tdir/$tfile || error
325 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
328 test_mkdir $DIR/$tdir
329 touch $DIR/$tdir/$tfile
330 chmod 0666 $DIR/$tdir/$tfile
331 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile || error
333 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
336 test_mkdir $DIR/$tdir
337 test_mkdir $DIR/$tdir/d2
338 test_mkdir $DIR/$tdir/d2/d3
339 $CHECKSTAT -t dir $DIR/$tdir/d2/d3 || error
341 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
344 test_mkdir $DIR/$tdir
345 test_mkdir $DIR/$tdir/d2
346 touch $DIR/$tdir/d2/$tfile
347 $CHECKSTAT -t file $DIR/$tdir/d2/$tfile || error
349 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
352 test_mkdir $DIR/$tdir
353 test_mkdir $DIR/$tdir/d2
354 chmod 0666 $DIR/$tdir/d2
355 chmod 0705 $DIR/$tdir/d2
356 $CHECKSTAT -t dir -p 0705 $DIR/$tdir/d2 || error
358 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
361 test_mkdir $DIR/$tdir
362 touch $DIR/$tdir/$tfile
363 chmod 0666 $DIR/$tdir/$tfile
364 chmod 0654 $DIR/$tdir/$tfile
365 $CHECKSTAT -t file -p 0654 $DIR/$tdir/$tfile || error
367 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
370 test_mkdir $DIR/$tdir
371 dd if=/dev/zero of=$DIR/$tdir/$tfile count=10
373 $CHECKSTAT -t file -s 0 $DIR/$tdir/$tfile || error
375 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
378 test_mkdir $DIR/$tdir
379 touch $DIR/$tdir/$tfile
381 $CHECKSTAT -a $DIR/$tdir/$tfile || error
383 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
386 test_mkdir $DIR/$tdir
387 touch $DIR/$tdir/$tfile
388 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}_2
389 $CHECKSTAT -t file $DIR/$tdir/${tfile}_2 || error
391 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
394 test_mkdir $DIR/$tdir
395 touch $DIR/$tdir/$tfile
396 rm -rf $DIR/$tdir/$tfile
397 $CHECKSTAT -a $DIR/$tdir/$tfile || error
399 run_test 16 "touch .../d16/f; rm -rf .../d16/f ================="
402 test_mkdir -p $DIR/$tdir
403 touch $DIR/$tdir/$tfile
404 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
406 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist || error
407 $CHECKSTAT -f -t f $DIR/$tdir/l-exist || error
408 rm -f $DIR/$tdir/l-exist
409 $CHECKSTAT -a $DIR/$tdir/l-exist || error
411 run_test 17a "symlinks: create, remove (real) =================="
414 test_mkdir -p $DIR/$tdir
415 ln -s no-such-file $DIR/$tdir/l-dangle
417 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle || error
418 $CHECKSTAT -fa $DIR/$tdir/l-dangle || error
419 rm -f $DIR/$tdir/l-dangle
420 $CHECKSTAT -a $DIR/$tdir/l-dangle || error
422 run_test 17b "symlinks: create, remove (dangling) =============="
424 test_17c() { # bug 3440 - don't save failed open RPC for replay
425 test_mkdir -p $DIR/$tdir
426 ln -s foo $DIR/$tdir/$tfile
427 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
429 run_test 17c "symlinks: open dangling (should return error) ===="
432 test_mkdir -p $DIR/$tdir
433 ln -s foo $DIR/$tdir/$tfile
434 touch $DIR/$tdir/$tfile || error "creating to new symlink"
436 run_test 17d "symlinks: create dangling ========================"
439 test_mkdir -p $DIR/$tdir
440 local foo=$DIR/$tdir/$tfile
441 ln -s $foo $foo || error "create symlink failed"
442 ls -l $foo || error "ls -l failed"
443 ls $foo && error "ls not failed" || true
445 run_test 17e "symlinks: create recursive symlink (should return error) ===="
448 test_mkdir -p $DIR/d17f
449 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/d17f/111
450 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/d17f/222
451 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/d17f/333
452 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/d17f/444
453 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/d17f/555
454 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
457 run_test 17f "symlinks: long and very long symlink name ========================"
459 # str_repeat(S, N) generate a string that is string S repeated N times
464 while [ $((n -= 1)) -ge 0 ]; do
470 # Long symlinks and LU-2241
472 test_mkdir -p $DIR/$tdir
473 local TESTS="59 60 61 4094 4095"
476 local SYMNAME=$(str_repeat 'x' $i)
477 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
478 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
481 run_test 17g "symlinks: really long symlink name and inode boundaries"
483 test_17h() { #bug 17378
484 remote_mds_nodsh && skip "remote MDS with nodsh" && return
485 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
487 test_mkdir -p $DIR/$tdir
488 if [ $MDSCOUNT -gt 1 ]; then
489 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
493 $SETSTRIPE -c -1 $DIR/$tdir
494 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
495 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
496 touch $DIR/$tdir/$tfile || true
498 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
500 test_17i() { #bug 20018
501 remote_mds_nodsh && skip "remote MDS with nodsh" && return
502 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
503 test_mkdir -p $DIR/$tdir
504 local foo=$DIR/$tdir/$tfile
506 if [ $MDSCOUNT -gt 1 ]; then
507 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
511 ln -s $foo $foo || error "create symlink failed"
512 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
513 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
514 ls -l $foo && error "error not detected"
517 run_test 17i "don't panic on short symlink"
519 test_17k() { #bug 22301
520 rsync --help | grep -q xattr ||
521 skip_env "$(rsync --version| head -1) does not support xattrs"
522 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
523 test_mkdir -p $DIR/$tdir
524 test_mkdir -p $DIR/$tdir.new
525 touch $DIR/$tdir/$tfile
526 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
527 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
528 error "rsync failed with xattrs enabled"
530 run_test 17k "symlinks: rsync with xattrs enabled ========================="
532 test_17l() { # LU-279
534 touch $DIR/$tdir/$tfile
535 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
536 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
537 # -h to not follow symlinks. -m '' to list all the xattrs.
538 # grep to remove first line: '# file: $path'.
539 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
541 lgetxattr_size_check $path $xattr ||
542 error "lgetxattr_size_check $path $xattr failed"
546 run_test 17l "Ensure lgetxattr's returned xattr size is consistent ========"
550 local short_sym="0123456789"
551 local WDIR=$DIR/${tdir}m
558 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
559 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
560 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
562 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
563 skip "only for ldiskfs MDT" && return 0
565 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
569 # create a long symlink file
570 for ((i = 0; i < 4; ++i)); do
571 long_sym=${long_sym}${long_sym}
574 echo "create 512 short and long symlink files under $WDIR"
575 for ((i = 0; i < 256; ++i)); do
576 ln -sf ${long_sym}"a5a5" $WDIR/long-$i
577 ln -sf ${short_sym}"a5a5" $WDIR/short-$i
583 wait_delete_completed
585 echo "recreate the 512 symlink files with a shorter string"
586 for ((i = 0; i < 512; ++i)); do
587 # rewrite the symlink file with a shorter string
588 ln -sf ${long_sym} $WDIR/long-$i
589 ln -sf ${short_sym} $WDIR/short-$i
592 mds_index=$($LFS getstripe -M $WDIR)
593 mds_index=$((mds_index+1))
594 devname=$(mdsdevname $mds_index)
595 cmd="$E2FSCK -fnvd $devname"
597 echo "stop and checking mds${mds_index}: $cmd"
598 # e2fsck should not return error
599 stop mds${mds_index} -f
600 do_facet mds${mds_index} $cmd || rc=$?
602 start mds${mds_index} $devname $MDS_MOUNT_OPTS
603 df $MOUNT > /dev/null 2>&1
604 [ $rc -ne 0 ] && error "e2fsck should not report error upon "\
605 "short/long symlink MDT: rc=$rc"
608 run_test 17m "run e2fsck against MDT which contains short/long symlink"
610 check_fs_consistency_17n() {
616 for mdt_index in $(seq 1 $MDSCOUNT); do
617 devname=$(mdsdevname $mdt_index)
618 cmd="$E2FSCK -fnvd $devname"
620 echo "stop and checking mds${mdt_index}: $cmd"
621 # e2fsck should not return error
623 do_facet mds${mdt_index} $cmd || rc=$?
625 start mds${mdt_index} $devname $MDS_MOUNT_OPTS
626 df $MOUNT > /dev/null 2>&1
627 [ $rc -ne 0 ] && break
635 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
636 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
637 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
639 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
640 skip "only for ldiskfs MDT" && return 0
642 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
644 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
647 for ((i=0; i<10; i++)); do
648 $LFS mkdir -i 1 $DIR/$tdir/remote_dir_${i} ||
649 error "create remote dir error $i"
650 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
651 error "create files under remote dir failed $i"
654 check_fs_consistency_17n || error "e2fsck report error"
656 for ((i=0;i<10;i++)); do
657 rm -rf $DIR/$tdir/remote_dir_${i} ||
658 error "destroy remote dir error $i"
661 check_fs_consistency_17n || error "e2fsck report error"
663 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
669 run_test 18 "touch .../f ; ls ... =============================="
675 $CHECKSTAT -a $DIR/f19 || error
677 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
680 ls -l $DIR/f19 && error || true
682 run_test 19b "ls -l .../f19 (should return error) =============="
685 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
686 $RUNAS touch $DIR/f19 && error || true
688 run_test 19c "$RUNAS touch .../f19 (should return error) =="
691 cat $DIR/f19 && error || true
693 run_test 19d "cat .../f19 (should return error) =============="
705 $CHECKSTAT -a $DIR/f || error
707 run_test 20 "touch .../f ; ls -l ... ==========================="
711 [ -f $DIR/d21/dangle ] && rm -f $DIR/d21/dangle
712 ln -s dangle $DIR/d21/link
713 echo foo >> $DIR/d21/link
715 $CHECKSTAT -t link $DIR/d21/link || error
716 $CHECKSTAT -f -t file $DIR/d21/link || error
718 run_test 21 "write to dangling link ============================"
722 test_mkdir -p $DIR/$tdir
723 chown $RUNAS_ID:$RUNAS_GID $WDIR
724 (cd $WDIR || error "cd $WDIR failed";
725 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
727 ls -lR $WDIR/etc || error "ls -lR $WDIR/etc failed"
728 $CHECKSTAT -t dir $WDIR/etc || error "checkstat -t dir failed"
729 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $WDIR/etc || error "checkstat -u failed"
731 run_test 22 "unpack tar archive as non-root user ==============="
735 test_mkdir -p $DIR/$tdir
736 local file=$DIR/$tdir/$tfile
738 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
739 openfile -f O_CREAT:O_EXCL $file &&
740 error "$file recreate succeeded" || true
742 run_test 23a "O_CREAT|O_EXCL in subdir =========================="
744 test_23b() { # bug 18988
745 test_mkdir -p $DIR/$tdir
746 local file=$DIR/$tdir/$tfile
749 echo foo > $file || error "write filed"
750 echo bar >> $file || error "append filed"
751 $CHECKSTAT -s 8 $file || error "wrong size"
754 run_test 23b "O_APPEND check =========================="
757 echo '== rename sanity =============================================='
758 echo '-- same directory rename'
761 mv $DIR/R1/f $DIR/R1/g
762 $CHECKSTAT -t file $DIR/R1/g || error
764 run_test 24a "touch .../R1/f; rename .../R1/f .../R1/g ========="
769 mv $DIR/R2/f $DIR/R2/g
770 $CHECKSTAT -a $DIR/R2/f || error
771 $CHECKSTAT -t file $DIR/R2/g || error
773 run_test 24b "touch .../R2/{f,g}; rename .../R2/f .../R2/g ====="
778 mv $DIR/R3/f $DIR/R3/g
779 $CHECKSTAT -a $DIR/R3/f || error
780 $CHECKSTAT -t dir $DIR/R3/g || error
782 run_test 24c "mkdir .../R3/f; rename .../R3/f .../R3/g ========="
788 mrename $DIR/R4/f $DIR/R4/g
789 $CHECKSTAT -a $DIR/R4/f || error
790 $CHECKSTAT -t dir $DIR/R4/g || error
792 run_test 24d "mkdir .../R4/{f,g}; rename .../R4/f .../R4/g ====="
795 echo '-- cross directory renames --'
799 mv $DIR/R5a/f $DIR/R5b/g
800 $CHECKSTAT -a $DIR/R5a/f || error
801 $CHECKSTAT -t file $DIR/R5b/g || error
803 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
808 touch $DIR/R6a/f $DIR/R6b/g
809 mv $DIR/R6a/f $DIR/R6b/g
810 $CHECKSTAT -a $DIR/R6a/f || error
811 $CHECKSTAT -t file $DIR/R6b/g || error
813 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
818 test_mkdir $DIR/R7a/d
819 mv $DIR/R7a/d $DIR/R7b/e
820 $CHECKSTAT -a $DIR/R7a/d || error
821 $CHECKSTAT -t dir $DIR/R7b/e || error
823 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
828 test_mkdir $DIR/R8a/d
829 test_mkdir $DIR/R8b/e
830 mrename $DIR/R8a/d $DIR/R8b/e
831 $CHECKSTAT -a $DIR/R8a/d || error
832 $CHECKSTAT -t dir $DIR/R8b/e || error
834 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
837 echo "-- rename error cases"
841 mrename $DIR/R9/f $DIR/R9/a
842 $CHECKSTAT -t file $DIR/R9/f || error
843 $CHECKSTAT -t dir $DIR/R9/a || error
844 $CHECKSTAT -a $DIR/R9/a/f || error
846 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
850 mrename $DIR/R10/f $DIR/R10/g
851 $CHECKSTAT -t dir $DIR/R10 || error
852 $CHECKSTAT -a $DIR/R10/f || error
853 $CHECKSTAT -a $DIR/R10/g || error
855 run_test 24j "source does not exist ============================"
859 test_mkdir $DIR/R11a/d
861 mv $DIR/R11a/f $DIR/R11a/d
862 $CHECKSTAT -a $DIR/R11a/f || error
863 $CHECKSTAT -t file $DIR/R11a/d/f || error
865 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
867 # bug 2429 - rename foo foo foo creates invalid file
870 $MULTIOP $f OcNs || error
872 run_test 24l "Renaming a file to itself ========================"
876 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
877 # on ext3 this does not remove either the source or target files
878 # though the "expected" operation would be to remove the source
879 $CHECKSTAT -t file ${f} || error "${f} missing"
880 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
882 run_test 24m "Renaming a file to a hard link to itself ========="
886 # this stats the old file after it was renamed, so it should fail
890 $CHECKSTAT ${f}.rename
893 run_test 24n "Statting the old file after renaming (Posix rename 2)"
896 check_kernel_version 37 || return 0
897 test_mkdir -p $DIR/d24o
898 rename_many -s random -v -n 10 $DIR/d24o
900 run_test 24o "rename of files during htree split ==============="
905 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
906 mrename $DIR/R12a $DIR/R12b
907 $CHECKSTAT -a $DIR/R12a || error
908 $CHECKSTAT -t dir $DIR/R12b || error
909 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
910 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
912 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
914 cleanup_multiop_pause() {
920 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
923 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
924 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
927 trap cleanup_multiop_pause EXIT
928 mrename $DIR/R13a $DIR/R13b
929 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
930 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
931 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
932 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
933 cleanup_multiop_pause
934 wait $MULTIPID || error "multiop close failed"
936 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
938 test_24r() { #bug 3789
940 test_mkdir $DIR/R14a/b
941 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
942 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
943 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
945 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
949 test_mkdir $DIR/R15a/b
950 test_mkdir $DIR/R15a/b/c
951 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
952 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
953 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
955 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
958 test_mkdir $DIR/R16a/b
959 test_mkdir $DIR/R16a/b/c
960 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
961 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
962 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
964 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
966 test_24u() { # bug12192
968 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error
969 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
971 run_test 24u "create stripe file"
977 simple_cleanup_common() {
980 wait_delete_completed
983 max_pages_per_rpc() {
984 $LCTL get_param -n mdc.*.max_pages_per_rpc | head -1
989 local FREE_INODES=$(lfs_df -i | grep "summary" | awk '{print $4}')
990 [ $FREE_INODES -lt $NRFILES ] && \
991 skip "not enough free inodes $FREE_INODES required $NRFILES" &&
994 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
995 trap simple_cleanup_common EXIT
998 createmany -m $DIR/$tdir/$tfile $NRFILES
1000 cancel_lru_locks mdc
1001 lctl set_param mdc.*.stats clear
1003 ls $DIR/$tdir >/dev/null || error "error in listing large dir"
1005 # LU-5 large readdir
1006 # DIRENT_SIZE = 32 bytes for sizeof(struct lu_dirent) +
1007 # 8 bytes for name(filename is mostly 5 in this test) +
1008 # 8 bytes for luda_type
1009 # take into account of overhead in lu_dirpage header and end mark in
1010 # each page, plus one in RPC_NUM calculation.
1012 RPC_SIZE=$(($(max_pages_per_rpc) * $(page_size)))
1013 RPC_NUM=$(((NRFILES * DIRENT_SIZE + RPC_SIZE - 1) / RPC_SIZE + 1))
1014 mds_readpage=$(lctl get_param mdc.*MDT0000*.stats | \
1015 awk '/^mds_readpage/ {print $2}')
1016 [ $mds_readpage -gt $RPC_NUM ] && \
1017 error "large readdir doesn't take effect"
1019 simple_cleanup_common
1021 run_test 24v "list directory with large files (handle hash collision, bug: 17560)"
1023 test_24w() { # bug21506
1025 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1026 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1027 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1028 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1029 [ "$SZ1" = "$SZ2" ] || \
1030 error "Error reading at the end of the file $tfile"
1032 run_test 24w "Reading a file larger than 4Gb"
1035 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1036 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1038 local remote_dir=$DIR/$tdir/remote_dir
1041 $LFS mkdir -i $MDTIDX $remote_dir ||
1042 error "create remote directory failed"
1044 mkdir -p $DIR/$tdir/src_dir
1045 touch $DIR/$tdir/src_file
1046 mkdir -p $remote_dir/tgt_dir
1047 touch $remote_dir/tgt_file
1049 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir &&
1050 error "rename dir cross MDT works!"
1052 mrename $DIR/$tdir/src_file $remote_dir/tgt_file &&
1053 error "rename file cross MDT works!"
1055 ln $DIR/$tdir/src_file $remote_dir/tgt_file1 &&
1056 error "ln file cross MDT should not work!"
1058 rm -rf $DIR/$tdir || error "Can not delete directories"
1060 run_test 24x "cross rename/link should be failed"
1063 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1064 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1066 local remote_dir=$DIR/$tdir/remote_dir
1069 $LFS mkdir -i $MDTIDX $remote_dir ||
1070 error "create remote directory failed"
1072 mkdir -p $remote_dir/src_dir
1073 touch $remote_dir/src_file
1074 mkdir -p $remote_dir/tgt_dir
1075 touch $remote_dir/tgt_file
1077 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1078 error "rename subdir in the same remote dir failed!"
1080 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1081 error "rename files in the same remote dir failed!"
1083 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1084 error "link files in the same remote dir failed!"
1086 rm -rf $DIR/$tdir || error "Can not delete directories"
1088 run_test 24y "rename/link on the same dir should succeed"
1091 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1092 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1094 local remote_src=$DIR/$tdir/remote_dir
1095 local remote_tgt=$DIR/$tdir/remote_tgt
1098 $LFS mkdir -i $MDTIDX $remote_src ||
1099 error "create remote directory failed"
1101 $LFS mkdir -i $MDTIDX $remote_tgt ||
1102 error "create remote directory failed"
1104 mrename $remote_src $remote_tgt &&
1105 error "rename remote dirs should not work!"
1107 rm -rf $DIR/$tdir || error "Can not delete directories"
1109 run_test 24z "rename one remote dir to another remote dir should fail"
1112 echo '== symlink sanity ============================================='
1116 touch $DIR/s25/foo || error
1118 run_test 25a "create file in symlinked directory ==============="
1121 [ ! -d $DIR/d25 ] && test_25a
1122 $CHECKSTAT -t file $DIR/s25/foo || error
1124 run_test 25b "lookup file in symlinked directory ==============="
1128 test_mkdir $DIR/d26/d26-2
1129 ln -s d26/d26-2 $DIR/s26
1130 touch $DIR/s26/foo || error
1132 run_test 26a "multiple component symlink ======================="
1135 test_mkdir -p $DIR/d26b/d26-2
1136 ln -s d26b/d26-2/foo $DIR/s26-2
1137 touch $DIR/s26-2 || error
1139 run_test 26b "multiple component symlink at end of lookup ======"
1142 test_mkdir $DIR/d26.2
1143 touch $DIR/d26.2/foo
1144 ln -s d26.2 $DIR/s26.2-1
1145 ln -s s26.2-1 $DIR/s26.2-2
1146 ln -s s26.2-2 $DIR/s26.2-3
1147 chmod 0666 $DIR/s26.2-3/foo
1149 run_test 26c "chain of symlinks ================================"
1151 # recursive symlinks (bug 439)
1153 ln -s d26-3/foo $DIR/d26-3
1155 run_test 26d "create multiple component recursive symlink ======"
1158 [ ! -h $DIR/d26-3 ] && test_26d
1161 run_test 26e "unlink multiple component recursive symlink ======"
1163 # recursive symlinks (bug 7022)
1165 test_mkdir -p $DIR/$tdir
1166 test_mkdir $DIR/$tdir/$tfile || error "mkdir $DIR/$tdir/$tfile failed"
1167 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1168 test_mkdir -p lndir bar1 || error "mkdir lndir/bar1 failed"
1169 test_mkdir $DIR/$tdir/$tfile/$tfile || error "mkdir $tfile failed"
1170 cd $tfile || error "cd $tfile failed"
1171 ln -s .. dotdot || error "ln dotdot failed"
1172 ln -s dotdot/lndir lndir || error "ln lndir failed"
1173 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1174 output=`ls $tfile/$tfile/lndir/bar1`
1175 [ "$output" = bar1 ] && error "unexpected output"
1176 rm -r $tfile || error "rm $tfile failed"
1177 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1179 run_test 26f "rm -r of a directory which has recursive symlink ="
1182 echo '== stripe sanity =============================================='
1183 test_mkdir -p $DIR/d27 || error "mkdir failed"
1185 $SETSTRIPE -c 1 $DIR/d27/f0 || error "setstripe failed"
1186 $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
1188 log "== test_27a: write to one stripe file ========================="
1189 cp /etc/hosts $DIR/d27/f0 || error
1191 run_test 27a "one stripe file =================================="
1194 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
1195 test_mkdir -p $DIR/d27
1196 $SETSTRIPE -c 2 $DIR/d27/f01 || error "setstripe failed"
1197 $GETSTRIPE -c $DIR/d27/f01
1198 [ $($GETSTRIPE -c $DIR/d27/f01) -eq 2 ] ||
1199 error "two-stripe file doesn't have two stripes"
1201 run_test 27b "create two stripe file"
1204 [ -f $DIR/d27/f01 ] || skip "test_27b not run" && return
1206 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
1208 run_test 27c "write to two stripe file"
1211 test_mkdir -p $DIR/d27
1212 $SETSTRIPE -c 0 -i -1 -S 0 $DIR/d27/fdef || error "setstripe failed"
1213 $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
1214 dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
1216 run_test 27d "create file with default settings ================"
1219 test_mkdir -p $DIR/d27
1220 $SETSTRIPE -c 2 $DIR/d27/f12 || error "setstripe failed"
1221 $SETSTRIPE -c 2 $DIR/d27/f12 && error "setstripe succeeded twice"
1222 $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
1224 run_test 27e "setstripe existing file (should return error) ======"
1227 test_mkdir -p $DIR/d27
1228 $SETSTRIPE -S 100 -i 0 -c 1 $DIR/d27/fbad && error "setstripe failed"
1229 dd if=/dev/zero of=$DIR/d27/f12 bs=4k count=4 || error "dd failed"
1230 $GETSTRIPE $DIR/d27/fbad || error "$GETSTRIPE failed"
1232 run_test 27f "setstripe with bad stripe size (should return error)"
1235 test_mkdir -p $DIR/d27
1236 $MCREATE $DIR/d27/fnone || error "mcreate failed"
1237 $GETSTRIPE $DIR/d27/fnone 2>&1 | grep "no stripe info" ||
1238 error "$DIR/d27/fnone has object"
1240 run_test 27g "$GETSTRIPE with no objects"
1243 touch $DIR/d27/fsome || error "touch failed"
1244 [ $($GETSTRIPE -c $DIR/d27/fsome) -gt 0 ] || error "missing objects"
1246 run_test 27i "$GETSTRIPE with some objects"
1249 test_mkdir -p $DIR/d27
1250 $SETSTRIPE -i $OSTCOUNT $DIR/d27/f27j && error "setstripe failed"||true
1252 run_test 27j "setstripe with bad stripe offset (should return error)"
1254 test_27k() { # bug 2844
1255 test_mkdir -p $DIR/d27
1257 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
1258 [ ! -d $DIR/d27 ] && test_mkdir -p $DIR d27
1259 $SETSTRIPE -S 67108864 $FILE || error "setstripe failed"
1260 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1261 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
1262 dd if=/dev/zero of=$FILE bs=4k count=1
1263 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1264 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
1266 run_test 27k "limit i_blksize for broken user apps ============="
1269 test_mkdir -p $DIR/d27
1270 mcreate $DIR/f27l || error "creating file"
1271 $RUNAS $SETSTRIPE -c 1 $DIR/f27l && \
1272 error "setstripe should have failed" || true
1274 run_test 27l "check setstripe permissions (should return error)"
1277 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" &&
1279 if [ $ORIGFREE -gt $MAXFREE ]; then
1280 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1283 trap simple_cleanup_common EXIT
1284 test_mkdir -p $DIR/$tdir
1285 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_1
1286 dd if=/dev/zero of=$DIR/$tdir/f27m_1 bs=1024 count=$MAXFREE &&
1287 error "dd should fill OST0"
1289 while $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_$i; do
1291 [ $i -gt 256 ] && break
1294 touch $DIR/$tdir/f27m_$i
1295 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1296 error "OST0 was full but new created file still use it"
1298 touch $DIR/$tdir/f27m_$i
1299 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1300 error "OST0 was full but new created file still use it"
1301 simple_cleanup_common
1303 run_test 27m "create file while OST0 was full =================="
1306 local DELAY=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage | head -n 1 | awk '{print $1 * 2}')
1310 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1311 # if the OST isn't full anymore.
1313 local OSTIDX=${1:-""}
1315 local list=$(comma_list $(osts_nodes))
1316 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1318 do_nodes $list lctl set_param fail_loc=0
1319 sync # initiate all OST_DESTROYs from MDS to OST
1323 exhaust_precreations() {
1326 local FAILIDX=${3:-$OSTIDX}
1328 test_mkdir -p $DIR/$tdir
1329 local MDSIDX=$(get_mds_dir "$DIR/$tdir")
1330 echo OSTIDX=$OSTIDX MDSIDX=$MDSIDX
1332 local OST=$(ostname_from_index $OSTIDX)
1333 local MDT_INDEX=$(lfs df | grep "\[MDT:$((MDSIDX - 1))\]" | awk '{print $1}' | \
1334 sed -e 's/_UUID$//;s/^.*-//')
1337 local mdtosc_proc1=$(get_mdtosc_proc_path mds${MDSIDX} $OST)
1338 local last_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1339 osc.$mdtosc_proc1.prealloc_last_id)
1340 local next_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1341 osc.$mdtosc_proc1.prealloc_next_id)
1343 local mdtosc_proc2=$(get_mdtosc_proc_path mds${MDSIDX})
1344 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1346 test_mkdir -p $DIR/$tdir/${OST}
1347 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1348 #define OBD_FAIL_OST_ENOSPC 0x215
1349 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=$FAILIDX
1350 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x215
1351 echo "Creating to objid $last_id on ost $OST..."
1352 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1353 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1354 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=$FAILLOC
1358 exhaust_all_precreations() {
1360 for (( i=0; i < OSTCOUNT; i++ )) ; do
1361 exhaust_precreations $i $1 -1
1366 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1367 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1368 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1369 remote_ost_nodsh && skip "remote OST with nodsh" && return
1372 rm -f $DIR/$tdir/$tfile
1373 exhaust_precreations 0 0x80000215
1374 $SETSTRIPE -c -1 $DIR/$tdir
1375 touch $DIR/$tdir/$tfile || error
1376 $GETSTRIPE $DIR/$tdir/$tfile
1379 run_test 27n "create file with some full OSTs =================="
1382 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1383 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1384 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1385 remote_ost_nodsh && skip "remote OST with nodsh" && return
1388 rm -f $DIR/$tdir/$tfile
1389 exhaust_all_precreations 0x215
1391 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1396 run_test 27o "create file with all full OSTs (should error) ===="
1399 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1400 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1401 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1402 remote_ost_nodsh && skip "remote OST with nodsh" && return
1405 rm -f $DIR/$tdir/$tfile
1406 test_mkdir -p $DIR/$tdir
1408 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1409 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1410 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1412 exhaust_precreations 0 0x80000215
1413 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1414 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1415 $GETSTRIPE $DIR/$tdir/$tfile
1419 run_test 27p "append to a truncated file with some full OSTs ==="
1422 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1423 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1424 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1425 remote_ost_nodsh && skip "remote OST with nodsh" && return
1428 rm -f $DIR/$tdir/$tfile
1430 test_mkdir -p $DIR/$tdir
1431 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1432 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||error "truncate $DIR/$tdir/$tfile failed"
1433 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1435 exhaust_all_precreations 0x215
1437 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1438 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1442 run_test 27q "append to truncated file with all OSTs full (should error) ==="
1445 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1446 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1447 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1448 remote_ost_nodsh && skip "remote OST with nodsh" && return
1451 rm -f $DIR/$tdir/$tfile
1452 exhaust_precreations 0 0x80000215
1454 $SETSTRIPE -i 0 -c 2 $DIR/$tdir/$tfile # && error
1458 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1460 test_27s() { # bug 10725
1461 test_mkdir -p $DIR/$tdir
1462 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1463 local stripe_count=0
1464 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1465 $SETSTRIPE -S $stripe_size -c $stripe_count $DIR/$tdir &&
1466 error "stripe width >= 2^32 succeeded" || true
1469 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1471 test_27t() { # bug 10864
1476 $WLFS getstripe $tfile
1479 run_test 27t "check that utils parse path correctly"
1481 test_27u() { # bug 4900
1482 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1483 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1485 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1486 do_facet $SINGLEMDS lctl set_param fail_loc=0x139
1487 test_mkdir -p $DIR/$tdir
1488 createmany -o $DIR/$tdir/t- 1000
1489 do_facet $SINGLEMDS lctl set_param fail_loc=0
1491 TLOG=$DIR/$tfile.getstripe
1492 $GETSTRIPE $DIR/$tdir > $TLOG
1493 OBJS=`awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj;}' $TLOG`
1494 unlinkmany $DIR/$tdir/t- 1000
1495 [ $OBJS -gt 0 ] && \
1496 error "$OBJS objects created on OST-0. See $TLOG" || pass
1498 run_test 27u "skip object creation on OSC w/o objects =========="
1500 test_27v() { # bug 4900
1501 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1502 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1503 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1504 remote_ost_nodsh && skip "remote OST with nodsh" && return
1506 exhaust_all_precreations 0x215
1509 test_mkdir -p $DIR/$tdir
1510 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1512 touch $DIR/$tdir/$tfile
1513 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1515 for (( i=1; i < OSTCOUNT; i++ )); do
1516 do_facet ost$i lctl set_param fail_loc=0x705
1518 local START=`date +%s`
1519 createmany -o $DIR/$tdir/$tfile 32
1521 local FINISH=`date +%s`
1522 local TIMEOUT=`lctl get_param -n timeout`
1523 local PROCESS=$((FINISH - START))
1524 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1525 error "$FINISH - $START >= $TIMEOUT / 2"
1526 sleep $((TIMEOUT / 2 - PROCESS))
1529 run_test 27v "skip object creation on slow OST ================="
1531 test_27w() { # bug 10997
1532 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1533 $SETSTRIPE -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1534 [ $($GETSTRIPE -S $DIR/$tdir/f0) -ne 65536 ] &&
1535 error "stripe size $size != 65536" || true
1536 [ $($GETSTRIPE -d $DIR/$tdir | grep -c "stripe_count") -ne 1 ] &&
1537 error "$GETSTRIPE -d $DIR/$tdir failed" || true
1539 run_test 27w "check $SETSTRIPE -S option"
1542 [ "$OSTCOUNT" -lt "2" ] &&
1543 skip_env "skipping multiple stripe count/offset test" && return
1545 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1546 for i in $(seq 1 $OSTCOUNT); do
1548 $SETSTRIPE -c $i -i $offset $DIR/$tdir/f$i ||
1549 error "setstripe -c $i -i $offset failed"
1550 count=$($GETSTRIPE -c $DIR/$tdir/f$i)
1551 index=$($GETSTRIPE -i $DIR/$tdir/f$i)
1552 [ $count -ne $i ] && error "stripe count $count != $i" || true
1553 [ $index -ne $offset ] &&
1554 error "stripe offset $index != $offset" || true
1557 run_test 27wa "check $SETSTRIPE -c -i options"
1560 remote_ost_nodsh && skip "remote OST with nodsh" && return
1561 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs" && return
1562 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1563 OFFSET=$(($OSTCOUNT - 1))
1565 local OST=$(ostname_from_index $OSTIDX)
1567 test_mkdir -p $DIR/$tdir
1568 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe per file
1569 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1571 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1572 for i in `seq 0 $OFFSET`; do
1573 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}' | grep -w "$OSTIDX"` ] &&
1574 error "OST0 was degraded but new created file still use it"
1576 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1578 run_test 27x "create files while OST0 is degraded"
1581 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1582 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1583 remote_ost_nodsh && skip "remote OST with nodsh" && return
1584 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1586 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1587 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1588 osc.$mdtosc.prealloc_last_id)
1589 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1590 osc.$mdtosc.prealloc_next_id)
1591 local fcount=$((last_id - next_id))
1592 [ $fcount -eq 0 ] && skip "not enough space on OST0" && return
1593 [ $fcount -gt $OSTCOUNT ] && fcount=$OSTCOUNT
1595 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
1596 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
1597 local OST_DEACTIVE_IDX=-1
1602 for OSC in $MDS_OSCS; do
1603 OST=$(osc_to_ost $OSC)
1604 OSTIDX=$(index_from_ostuuid $OST)
1605 if [ $OST_DEACTIVE_IDX == -1 ]; then
1606 OST_DEACTIVE_IDX=$OSTIDX
1608 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
1609 echo $OSC "is Deactivated:"
1610 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1614 OSTIDX=$(index_from_ostuuid $OST)
1616 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1618 for OSC in $MDS_OSCS; do
1619 OST=$(osc_to_ost $OSC)
1620 OSTIDX=$(index_from_ostuuid $OST)
1621 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1622 echo $OST "is degraded:"
1623 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1624 obdfilter.$OST.degraded=1
1629 createmany -o $DIR/$tdir/$tfile $fcount
1631 for OSC in $MDS_OSCS; do
1632 OST=$(osc_to_ost $OSC)
1633 OSTIDX=$(index_from_ostuuid $OST)
1634 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1635 echo $OST "is recovered from degraded:"
1636 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1637 obdfilter.$OST.degraded=0
1639 do_facet $SINGLEMDS lctl --device %$OSC activate
1643 run_test 27y "create files while OST0 is degraded and the rest inactive"
1649 lmm_count=$($GETSTRIPE -c $1)
1650 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1651 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1653 local old_ifs="$IFS"
1655 fid=($($LFS path2fid $1))
1658 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1659 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1661 # compare lmm_seq and lu_fid->f_seq
1662 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1663 # compare lmm_object_id and lu_fid->oid
1664 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1666 # check the trusted.fid attribute of the OST objects of the file
1667 local have_obdidx=false
1669 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1670 # skip lines up to and including "obdidx"
1671 [ -z "$obdidx" ] && break
1672 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1673 $have_obdidx || continue
1675 local ost=$((obdidx + 1))
1676 local dev=$(ostdevname $ost)
1678 if [ $(facet_fstype ost$ost) != ldiskfs ]; then
1679 echo "Currently only works with ldiskfs-based OSTs"
1683 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1685 #don't unmount/remount the OSTs if we don't need to do that
1686 #local dir=$(facet_mntpt ost$ost)
1688 #do_facet ost$dev mount -t $FSTYPE $dev $dir $OST_MOUNT_OPTS ||
1689 # { error "mounting $dev as $FSTYPE failed"; return 3; }
1690 #local obj_file=$(do_facet ost$ost find $dir/O/$seq -name $oid)
1691 #local ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID $obj_file)
1692 seq=$(echo $seq | sed -e "s/^0x//g")
1693 if [ $seq == 0 ]; then
1694 oid_hex=$(echo $oid)
1696 oid_hex=$(echo $hex | sed -e "s/^0x//g")
1698 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
1699 local ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
1700 $dev 2>/dev/null" | grep "parent=")
1702 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
1704 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
1706 #do_facet ost$ost umount -d $dir
1707 #start ost$ost $dev $OST_MOUNT_OPTS
1709 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
1710 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
1711 local ff_parent=$(echo $ff|sed -e 's/.*parent=.//')
1712 local ff_pseq=$(echo $ff_parent | cut -d: -f1)
1713 local ff_poid=$(echo $ff_parent | cut -d: -f2)
1714 local ff_pstripe=$(echo $ff_parent | sed -e 's/.*stripe=//')
1716 # compare lmm_seq and filter_fid->ff_parent.f_seq
1717 [ $ff_pseq = $lmm_seq ] ||
1718 error "FF parent SEQ $ff_pseq != $lmm_seq"
1719 # compare lmm_object_id and filter_fid->ff_parent.f_oid
1720 [ $ff_poid = $lmm_oid ] ||
1721 error "FF parent OID $ff_poid != $lmm_oid"
1722 [ $ff_pstripe = $stripe_nr ] ||
1723 error "FF stripe $ff_pstripe != $stripe_nr"
1725 stripe_nr=$((stripe_nr + 1))
1730 remote_ost_nodsh && skip "remote OST with nodsh" && return
1731 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1732 test_mkdir -p $DIR/$tdir
1734 $SETSTRIPE -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
1735 { error "setstripe -c -1 failed"; return 1; }
1736 # We need to send a write to every object to get parent FID info set.
1737 # This _should_ also work for setattr, but does not currently.
1738 # touch $DIR/$tdir/$tfile-1 ||
1739 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
1740 { error "dd $tfile-1 failed"; return 2; }
1741 $SETSTRIPE -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
1742 { error "setstripe -c -1 failed"; return 3; }
1743 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
1744 { error "dd $tfile-2 failed"; return 4; }
1746 # make sure write RPCs have been sent to OSTs
1749 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
1750 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
1752 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
1754 test_27A() { # b=19102
1755 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1756 local restore_size=$($GETSTRIPE -S $MOUNT)
1757 local restore_count=$($GETSTRIPE -c $MOUNT)
1758 local restore_offset=$($GETSTRIPE -i $MOUNT)
1759 $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
1760 local default_size=$($GETSTRIPE -S $MOUNT)
1761 local default_count=$($GETSTRIPE -c $MOUNT)
1762 local default_offset=$($GETSTRIPE -i $MOUNT)
1763 local dsize=$((1024 * 1024))
1764 [ $default_size -eq $dsize ] ||
1765 error "stripe size $default_size != $dsize"
1766 [ $default_count -eq 1 ] || error "stripe count $default_count != 1"
1767 [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
1768 $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
1770 run_test 27A "check filesystem-wide default LOV EA values"
1772 # createtest also checks that device nodes are created and
1773 # then visible correctly (#2091)
1774 test_28() { # bug 2091
1776 $CREATETEST $DIR/d28/ct || error
1778 run_test 28 "create/mknod/mkdir with bad file types ============"
1781 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1782 cancel_lru_locks mdc
1788 declare -i LOCKCOUNTORIG=0
1789 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1790 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
1792 [ $LOCKCOUNTORIG -eq 0 ] && echo "No mdc lock count" && return 1
1794 declare -i LOCKUNUSEDCOUNTORIG=0
1795 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1796 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
1803 declare -i LOCKCOUNTCURRENT=0
1804 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1805 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
1808 declare -i LOCKUNUSEDCOUNTCURRENT=0
1809 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1810 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
1813 if [ "$LOCKCOUNTCURRENT" -gt "$LOCKCOUNTORIG" ]; then
1814 lctl set_param -n ldlm.dump_namespaces ""
1815 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
1816 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1817 log "dumped log to $TMP/test_29.dk (bug 5793)"
1820 if [ "$LOCKUNUSEDCOUNTCURRENT" -gt "$LOCKUNUSEDCOUNTORIG" ]; then
1821 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
1822 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1823 log "dumped log to $TMP/test_29.dk (bug 5793)"
1827 run_test 29 "IT_GETATTR regression ============================"
1829 test_30a() { # was test_30
1830 cp `which ls` $DIR || cp /bin/ls $DIR
1834 run_test 30a "execute binary from Lustre (execve) =============="
1837 cp `which ls` $DIR || cp /bin/ls $DIR
1839 $RUNAS $DIR/ls / || error
1842 run_test 30b "execute binary from Lustre as non-root ==========="
1844 test_30c() { # b=22376
1845 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1846 cp `which ls` $DIR || cp /bin/ls $DIR
1848 cancel_lru_locks mdc
1849 cancel_lru_locks osc
1850 $RUNAS $DIR/ls / || error
1853 run_test 30c "execute binary from Lustre without read perms ===="
1856 $OPENUNLINK $DIR/f31 $DIR/f31 || error
1857 $CHECKSTAT -a $DIR/f31 || error
1859 run_test 31a "open-unlink file =================================="
1862 touch $DIR/f31 || error
1863 ln $DIR/f31 $DIR/f31b || error
1864 $MULTIOP $DIR/f31b Ouc || error
1865 $CHECKSTAT -t file $DIR/f31 || error
1867 run_test 31b "unlink file with multiple links while open ======="
1870 touch $DIR/f31 || error
1871 ln $DIR/f31 $DIR/f31c || error
1872 multiop_bg_pause $DIR/f31 O_uc || return 1
1874 $MULTIOP $DIR/f31c Ouc
1875 kill -USR1 $MULTIPID
1878 run_test 31c "open-unlink file with multiple links ============="
1881 opendirunlink $DIR/d31d $DIR/d31d || error
1882 $CHECKSTAT -a $DIR/d31d || error
1884 run_test 31d "remove of open directory ========================="
1886 test_31e() { # bug 2904
1887 check_kernel_version 34 || return 0
1888 openfilleddirunlink $DIR/d31e || error
1890 run_test 31e "remove of open non-empty directory ==============="
1892 test_31f() { # bug 4554
1893 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1895 test_mkdir $DIR/d31f
1896 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
1897 cp /etc/hosts $DIR/d31f
1899 $GETSTRIPE $DIR/d31f/hosts
1900 multiop_bg_pause $DIR/d31f D_c || return 1
1903 rm -rv $DIR/d31f || error "first of $DIR/d31f"
1904 test_mkdir $DIR/d31f
1905 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
1906 cp /etc/hosts $DIR/d31f
1908 $GETSTRIPE $DIR/d31f/hosts
1909 multiop_bg_pause $DIR/d31f D_c || return 1
1912 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
1913 wait $MULTIPID || error "first opendir $MULTIPID failed"
1917 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
1918 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
1921 run_test 31f "remove of open directory with open-unlink file ==="
1924 echo "-- cross directory link --"
1925 test_mkdir $DIR/d31ga
1926 test_mkdir $DIR/d31gb
1928 ln $DIR/d31ga/f $DIR/d31gb/g
1929 $CHECKSTAT -t file $DIR/d31ga/f || error "source"
1930 [ `stat -c%h $DIR/d31ga/f` == '2' ] || error "source nlink"
1931 $CHECKSTAT -t file $DIR/d31gb/g || error "target"
1932 [ `stat -c%h $DIR/d31gb/g` == '2' ] || error "target nlink"
1934 run_test 31g "cross directory link==============="
1937 echo "-- cross directory link --"
1938 test_mkdir $DIR/d31h
1939 test_mkdir $DIR/d31h/dir
1941 ln $DIR/d31h/f $DIR/d31h/dir/g
1942 $CHECKSTAT -t file $DIR/d31h/f || error "source"
1943 [ `stat -c%h $DIR/d31h/f` == '2' ] || error "source nlink"
1944 $CHECKSTAT -t file $DIR/d31h/dir/g || error "target"
1945 [ `stat -c%h $DIR/d31h/dir/g` == '2' ] || error "target nlink"
1947 run_test 31h "cross directory link under child==============="
1950 echo "-- cross directory link --"
1951 test_mkdir $DIR/d31i
1952 test_mkdir $DIR/d31i/dir
1953 touch $DIR/d31i/dir/f
1954 ln $DIR/d31i/dir/f $DIR/d31i/g
1955 $CHECKSTAT -t file $DIR/d31i/dir/f || error "source"
1956 [ `stat -c%h $DIR/d31i/dir/f` == '2' ] || error "source nlink"
1957 $CHECKSTAT -t file $DIR/d31i/g || error "target"
1958 [ `stat -c%h $DIR/d31i/g` == '2' ] || error "target nlink"
1960 run_test 31i "cross directory link under parent==============="
1964 test_mkdir $DIR/d31j
1965 test_mkdir $DIR/d31j/dir1
1966 ln $DIR/d31j/dir1 $DIR/d31j/dir2 && error "ln for dir"
1967 link $DIR/d31j/dir1 $DIR/d31j/dir3 && error "link for dir"
1968 mlink $DIR/d31j/dir1 $DIR/d31j/dir4 && error "mlink for dir"
1969 mlink $DIR/d31j/dir1 $DIR/d31j/dir1 && error "mlink to the same dir"
1972 run_test 31j "link for directory==============="
1976 test_mkdir $DIR/d31k
1978 touch $DIR/d31k/exist
1979 mlink $DIR/d31k/s $DIR/d31k/t || error "mlink"
1980 mlink $DIR/d31k/s $DIR/d31k/exist && error "mlink to exist file"
1981 mlink $DIR/d31k/s $DIR/d31k/s && error "mlink to the same file"
1982 mlink $DIR/d31k/s $DIR/d31k && error "mlink to parent dir"
1983 mlink $DIR/d31k $DIR/d31k/s && error "mlink parent dir to target"
1984 mlink $DIR/d31k/not-exist $DIR/d31k/foo && error "mlink non-existing to new"
1985 mlink $DIR/d31k/not-exist $DIR/d31k/s && error "mlink non-existing to exist"
1988 run_test 31k "link to file: the same, non-existing, dir==============="
1991 test_mkdir $DIR/d31m
1993 test_mkdir $DIR/d31m2
1994 touch $DIR/d31m2/exist
1995 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
1996 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
1997 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
1998 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
1999 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
2000 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
2003 run_test 31m "link to file: the same, non-existing, dir==============="
2005 cleanup_test32_mount() {
2007 $UMOUNT $DIR/$tdir/ext2-mountpoint
2011 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2012 echo "== more mountpoints and symlinks ================="
2013 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2014 trap cleanup_test32_mount EXIT
2015 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2016 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2017 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. || error
2018 cleanup_test32_mount
2020 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
2023 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2024 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2025 trap cleanup_test32_mount EXIT
2026 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2027 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2028 ls -al $DIR/$tdir/ext2-mountpoint/.. || error
2029 cleanup_test32_mount
2031 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
2034 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2035 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2036 trap cleanup_test32_mount EXIT
2037 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2038 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2039 test_mkdir -p $DIR/$tdir/d2/test_dir
2040 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2041 cleanup_test32_mount
2043 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2046 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2047 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2048 trap cleanup_test32_mount EXIT
2049 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2050 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2051 test_mkdir -p $DIR/$tdir/d2/test_dir
2052 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2053 cleanup_test32_mount
2055 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
2058 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
2059 test_mkdir -p $DIR/d32e/tmp
2060 TMP_DIR=$DIR/d32e/tmp
2061 ln -s $DIR/d32e $TMP_DIR/symlink11
2062 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2063 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
2064 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
2066 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
2069 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
2070 test_mkdir -p $DIR/d32f/tmp
2071 TMP_DIR=$DIR/d32f/tmp
2072 ln -s $DIR/d32f $TMP_DIR/symlink11
2073 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2074 ls $DIR/d32f/tmp/symlink11 || error
2075 ls $DIR/d32f/symlink01 || error
2077 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
2080 TMP_DIR=$DIR/$tdir/tmp
2081 test_mkdir -p $DIR/$tdir/tmp
2082 test_mkdir $DIR/${tdir}2
2083 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2084 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2085 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
2086 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
2087 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
2088 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
2090 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2093 rm -fr $DIR/$tdir $DIR/${tdir}2
2094 TMP_DIR=$DIR/$tdir/tmp
2095 test_mkdir -p $DIR/$tdir/tmp
2096 test_mkdir $DIR/${tdir}2
2097 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2098 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2099 ls $TMP_DIR/symlink12 || error
2100 ls $DIR/$tdir/symlink02 || error
2102 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2105 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2106 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2107 trap cleanup_test32_mount EXIT
2108 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2109 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2110 touch $DIR/$tdir/test_file
2111 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file || error
2112 cleanup_test32_mount
2114 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
2117 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2118 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2119 trap cleanup_test32_mount EXIT
2120 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2121 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2122 touch $DIR/$tdir/test_file
2123 cat $DIR/$tdir/ext2-mountpoint/../test_file || error
2124 cleanup_test32_mount
2126 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
2129 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2131 trap cleanup_test32_mount EXIT
2132 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2133 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2134 test_mkdir -p $DIR/$tdir/d2
2135 touch $DIR/$tdir/d2/test_file || error
2136 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2137 cleanup_test32_mount
2139 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
2142 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2144 trap cleanup_test32_mount EXIT
2145 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2146 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2147 test_mkdir -p $DIR/$tdir/d2
2148 touch $DIR/$tdir/d2/test_file
2149 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2150 cleanup_test32_mount
2152 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
2156 test_mkdir -p $DIR/d32m/tmp
2157 TMP_DIR=$DIR/d32m/tmp
2158 ln -s $DIR $TMP_DIR/symlink11
2159 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2160 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
2161 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
2163 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
2167 test_mkdir -p $DIR/d32n/tmp
2168 TMP_DIR=$DIR/d32n/tmp
2169 ln -s $DIR $TMP_DIR/symlink11
2170 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2171 ls -l $DIR/d32n/tmp/symlink11 || error
2172 ls -l $DIR/d32n/symlink01 || error
2174 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
2177 rm -fr $DIR/d32o $DIR/$tfile
2179 test_mkdir -p $DIR/d32o/tmp
2180 TMP_DIR=$DIR/d32o/tmp
2181 ln -s $DIR/$tfile $TMP_DIR/symlink12
2182 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2183 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
2184 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
2185 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
2186 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
2188 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
2198 test_mkdir -p $DIR/d32p/tmp
2200 TMP_DIR=$DIR/d32p/tmp
2202 ln -s $DIR/$tfile $TMP_DIR/symlink12
2204 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2206 cat $DIR/d32p/tmp/symlink12 || error
2208 cat $DIR/d32p/symlink02 || error
2211 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
2213 cleanup_testdir_mount() {
2219 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2220 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2221 trap cleanup_testdir_mount EXIT
2222 test_mkdir -p $DIR/$tdir
2223 touch $DIR/$tdir/under_the_mount
2224 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2225 ls $DIR/$tdir | grep "\<under_the_mount\>" && error
2226 cleanup_testdir_mount
2228 run_test 32q "stat follows mountpoints in Lustre (should return error)"
2231 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2232 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2233 trap cleanup_testdir_mount EXIT
2234 test_mkdir -p $DIR/$tdir
2235 touch $DIR/$tdir/under_the_mount
2236 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2237 ls $DIR/$tdir | grep -q under_the_mount && error || true
2238 cleanup_testdir_mount
2240 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
2245 chmod 444 $DIR/$tfile
2246 chown $RUNAS_ID $DIR/$tfile
2248 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2251 run_test 33aa "write file with mode 444 (should return error) ===="
2255 test_mkdir -p $DIR/d33
2256 chown $RUNAS_ID $DIR/d33
2257 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
2258 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
2259 error "open RDWR" || true
2261 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
2265 test_mkdir -p $DIR/d33
2266 chown $RUNAS_ID $DIR/d33
2267 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33 && error "create" || true
2269 run_test 33b "test open file with malformed flags (No panic and return error)"
2272 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2278 remote_ost_nodsh && skip "remote OST with nodsh" && return
2281 test_mkdir -p $DIR/d33
2282 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2285 for ostnum in $(seq $OSTCOUNT); do
2286 # test-framework's OST numbering is one-based, while Lustre's
2288 ostname=$(printf "$FSNAME-OST%.4d" $((ostnum - 1)))
2289 # Parsing llobdstat's output sucks; we could grep the /proc
2290 # path, but that's likely to not be as portable as using the
2291 # llobdstat utility. So we parse lctl output instead.
2292 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2293 obdfilter/$ostname/stats |
2294 awk '/^write_bytes/ {print $7}' )
2295 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2296 if (( ${write_bytes:-0} > 0 ))
2303 $all_zeros || return 0
2306 echo foo > $DIR/d33/bar
2310 # Total up write_bytes after writing. We'd better find non-zeros.
2311 for ostnum in $(seq $OSTCOUNT); do
2312 ostname=$(printf "$FSNAME-OST%.4d" $((ostnum - 1)))
2313 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2314 obdfilter/$ostname/stats |
2315 awk '/^write_bytes/ {print $7}' )
2316 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2317 if (( ${write_bytes:-0} > 0 ))
2326 for ostnum in $(seq $OSTCOUNT); do
2327 ostname=$(printf "$FSNAME-OST%.4d" $((ostnum - 1)))
2328 echo "Check that write_bytes is present in obdfilter/*/stats:"
2329 do_facet ost$ostnum lctl get_param -n \
2330 obdfilter/$ostname/stats
2332 error "OST not keeping write_bytes stats (b22312)"
2335 run_test 33c "test llobdstat and write_bytes"
2338 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2339 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2341 local remote_dir=$DIR/$tdir/remote_dir
2344 $LFS mkdir -i $MDTIDX $remote_dir ||
2345 error "create remote directory failed"
2347 touch $remote_dir/$tfile
2348 chmod 444 $remote_dir/$tfile
2349 chown $RUNAS_ID $remote_dir/$tfile
2351 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2353 chown $RUNAS_ID $remote_dir
2354 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
2355 error "create" || true
2356 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
2357 error "open RDWR" || true
2358 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 &&
2359 error "create" || true
2361 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
2363 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
2366 $MCREATE $DIR/f34 || error
2367 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2368 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
2369 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2370 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2372 run_test 34a "truncate file that has not been opened ==========="
2375 [ ! -f $DIR/f34 ] && test_34a
2376 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2377 $OPENFILE -f O_RDONLY $DIR/f34
2378 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2379 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2381 run_test 34b "O_RDONLY opening file doesn't create objects ====="
2384 [ ! -f $DIR/f34 ] && test_34a
2385 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2386 $OPENFILE -f O_RDWR $DIR/f34
2387 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2388 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2390 run_test 34c "O_RDWR opening file-with-size works =============="
2393 [ ! -f $DIR/f34 ] && test_34a
2394 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2395 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2398 run_test 34d "write to sparse file ============================="
2402 $MCREATE $DIR/f34e || error
2403 $TRUNCATE $DIR/f34e 1000 || error
2404 $CHECKSTAT -s 1000 $DIR/f34e || error
2405 $OPENFILE -f O_RDWR $DIR/f34e
2406 $CHECKSTAT -s 1000 $DIR/f34e || error
2408 run_test 34e "create objects, some with size and some without =="
2410 test_34f() { # bug 6242, 6243
2411 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2414 $MCREATE $DIR/f34f || error
2415 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
2416 dd if=$DIR/f34f of=$TMP/f34f
2417 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
2418 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
2419 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
2420 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
2421 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
2423 run_test 34f "read from a file with no objects until EOF ======="
2426 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2427 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
2428 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
2429 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
2430 cancel_lru_locks osc
2431 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
2432 error "wrong size after lock cancel"
2434 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
2435 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2436 error "expanding truncate failed"
2437 cancel_lru_locks osc
2438 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2439 error "wrong expanded size after lock cancel"
2441 run_test 34g "truncate long file ==============================="
2444 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2448 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
2449 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
2453 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
2454 error "Multiop blocked on ftruncate, pid=$MULTIPID"
2458 local nsz=`stat -c %s $DIR/$tfile`
2459 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
2461 run_test 34h "ftruncate file under grouplock should not block"
2464 cp /bin/sh $DIR/f35a
2466 chown $RUNAS_ID $DIR/f35a
2467 $RUNAS $DIR/f35a && error || true
2470 run_test 35a "exec file with mode 444 (should return and not leak) ====="
2474 utime $DIR/f36 || error
2476 run_test 36a "MDS utime check (mknod, utime) ==================="
2480 utime $DIR/f36 || error
2482 run_test 36b "OST utime check (open, utime) ===================="
2487 chown $RUNAS_ID $DIR/d36
2488 $RUNAS utime $DIR/d36/f36 || error
2490 run_test 36c "non-root MDS utime check (mknod, utime) =========="
2493 [ ! -d $DIR/d36 ] && test_36c
2494 echo "" > $DIR/d36/f36
2495 $RUNAS utime $DIR/d36/f36 || error
2497 run_test 36d "non-root OST utime check (open, utime) ==========="
2500 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
2501 test_mkdir -p $DIR/$tdir
2502 touch $DIR/$tdir/$tfile
2503 $RUNAS utime $DIR/$tdir/$tfile && \
2504 error "utime worked, expected failure" || true
2506 run_test 36e "utime on non-owned file (should return error) ===="
2510 local LANG_SAVE=$LANG
2511 local LC_LANG_SAVE=$LC_LANG
2512 export LANG=C LC_LANG=C # for date language
2514 DATESTR="Dec 20 2000"
2515 test_mkdir -p $DIR/$tdir
2516 lctl set_param fail_loc=$fl
2518 cp /etc/hosts $DIR/$tdir/$tfile
2519 sync & # write RPC generated with "current" inode timestamp, but delayed
2521 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
2522 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
2523 cancel_lru_locks osc
2524 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
2526 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
2527 echo "BEFORE: $LS_BEFORE" && \
2528 echo "AFTER : $LS_AFTER" && \
2529 echo "WANT : $DATESTR" && \
2530 error "$DIR/$tdir/$tfile timestamps changed" || true
2532 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
2536 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2537 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2538 subr_36fh "0x80000214"
2540 run_test 36f "utime on file racing with OST BRW write =========="
2543 remote_ost_nodsh && skip "remote OST with nodsh" && return
2544 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2549 test_mkdir -p $DIR/$tdir
2550 fmd_max_age=$(do_facet ost1 \
2551 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
2554 fmd_before=$(do_facet ost1 \
2555 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2556 touch $DIR/$tdir/$tfile
2557 sleep $((fmd_max_age + 12))
2558 fmd_after=$(do_facet ost1 \
2559 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2561 echo "fmd_before: $fmd_before"
2562 echo "fmd_after: $fmd_after"
2563 [ "$fmd_after" -gt "$fmd_before" ] && \
2564 echo "AFTER: $fmd_after > BEFORE: $fmd_before" && \
2565 error "fmd didn't expire after ping" || true
2567 run_test 36g "filter mod data cache expiry ====================="
2570 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2571 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
2572 subr_36fh "0x80000227"
2574 run_test 36h "utime on file racing with OST BRW write =========="
2576 # test_37 - duplicate with tests 32q 32r
2579 local file=$DIR/$tfile
2581 openfile -f O_DIRECTORY $file
2584 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
2585 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
2587 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
2591 touch $DIR/${tfile}2
2592 # ls -l $DIR/$tfile $DIR/${tfile}2
2593 # ls -lu $DIR/$tfile $DIR/${tfile}2
2594 # ls -lc $DIR/$tfile $DIR/${tfile}2
2596 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
2597 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
2599 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
2601 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
2603 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
2604 error "O_TRUNC didn't change timestamps"
2607 run_test 39 "mtime changed on create ==========================="
2610 test_mkdir -p $DIR/$tdir
2611 cp -p /etc/passwd $DIR/$tdir/fopen
2612 cp -p /etc/passwd $DIR/$tdir/flink
2613 cp -p /etc/passwd $DIR/$tdir/funlink
2614 cp -p /etc/passwd $DIR/$tdir/frename
2615 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
2618 echo "aaaaaa" >> $DIR/$tdir/fopen
2619 echo "aaaaaa" >> $DIR/$tdir/flink
2620 echo "aaaaaa" >> $DIR/$tdir/funlink
2621 echo "aaaaaa" >> $DIR/$tdir/frename
2623 local open_new=`stat -c %Y $DIR/$tdir/fopen`
2624 local link_new=`stat -c %Y $DIR/$tdir/flink`
2625 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
2626 local rename_new=`stat -c %Y $DIR/$tdir/frename`
2628 cat $DIR/$tdir/fopen > /dev/null
2629 ln $DIR/$tdir/flink $DIR/$tdir/flink2
2630 rm -f $DIR/$tdir/funlink2
2631 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
2633 for (( i=0; i < 2; i++ )) ; do
2634 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
2635 local link_new2=`stat -c %Y $DIR/$tdir/flink`
2636 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
2637 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
2639 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
2640 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
2641 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
2642 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
2644 cancel_lru_locks osc
2645 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2648 run_test 39b "mtime change on open, link, unlink, rename ======"
2650 # this should be set to past
2651 TEST_39_MTIME=`date -d "1 year ago" +%s`
2657 local mtime0=`stat -c %Y $DIR1/$tfile`
2659 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2660 local mtime1=`stat -c %Y $DIR1/$tfile`
2661 [ "$mtime1" = $TEST_39_MTIME ] || \
2662 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
2665 echo hello >> $DIR1/$tfile
2667 local mtime2=`stat -c %Y $DIR1/$tfile`
2668 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
2669 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
2671 mv $DIR1/$tfile $DIR1/$tfile-1
2673 for (( i=0; i < 2; i++ )) ; do
2674 local mtime3=`stat -c %Y $DIR1/$tfile-1`
2675 [ "$mtime2" = "$mtime3" ] || \
2676 error "mtime ($mtime2) changed (to $mtime3) on rename"
2678 cancel_lru_locks osc
2679 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2682 run_test 39c "mtime change on rename ==========================="
2686 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2689 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2691 for (( i=0; i < 2; i++ )) ; do
2692 local mtime=`stat -c %Y $DIR1/$tfile`
2693 [ $mtime = $TEST_39_MTIME ] || \
2694 error "mtime($mtime) is not set to $TEST_39_MTIME"
2696 cancel_lru_locks osc
2697 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2700 run_test 39d "create, utime, stat =============================="
2704 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2706 local mtime1=`stat -c %Y $DIR1/$tfile`
2708 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2710 for (( i=0; i < 2; i++ )) ; do
2711 local mtime2=`stat -c %Y $DIR1/$tfile`
2712 [ $mtime2 = $TEST_39_MTIME ] || \
2713 error "mtime($mtime2) is not set to $TEST_39_MTIME"
2715 cancel_lru_locks osc
2716 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2719 run_test 39e "create, stat, utime, stat ========================"
2723 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2725 mtime1=`stat -c %Y $DIR1/$tfile`
2728 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2730 for (( i=0; i < 2; i++ )) ; do
2731 local mtime2=`stat -c %Y $DIR1/$tfile`
2732 [ $mtime2 = $TEST_39_MTIME ] || \
2733 error "mtime($mtime2) is not set to $TEST_39_MTIME"
2735 cancel_lru_locks osc
2736 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2739 run_test 39f "create, stat, sleep, utime, stat ================="
2743 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2744 echo hello >> $DIR1/$tfile
2745 local mtime1=`stat -c %Y $DIR1/$tfile`
2748 chmod o+r $DIR1/$tfile
2750 for (( i=0; i < 2; i++ )) ; do
2751 local mtime2=`stat -c %Y $DIR1/$tfile`
2752 [ "$mtime1" = "$mtime2" ] || \
2753 error "lost mtime: $mtime2, should be $mtime1"
2755 cancel_lru_locks osc
2756 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2759 run_test 39g "write, chmod, stat ==============================="
2763 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2768 echo hello >> $DIR1/$tfile
2769 local mtime1=`stat -c %Y $DIR1/$tfile`
2771 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2773 if [ "$d1" != "$d2" ]; then
2774 echo "write and touch not within one second"
2776 for (( i=0; i < 2; i++ )) ; do
2777 local mtime2=`stat -c %Y $DIR1/$tfile`
2778 [ "$mtime2" = $TEST_39_MTIME ] || \
2779 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
2781 cancel_lru_locks osc
2782 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2786 run_test 39h "write, utime within one second, stat ============="
2789 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2793 echo hello >> $DIR1/$tfile
2794 local mtime1=`stat -c %Y $DIR1/$tfile`
2796 mv $DIR1/$tfile $DIR1/$tfile-1
2798 for (( i=0; i < 2; i++ )) ; do
2799 local mtime2=`stat -c %Y $DIR1/$tfile-1`
2801 [ "$mtime1" = "$mtime2" ] || \
2802 error "lost mtime: $mtime2, should be $mtime1"
2804 cancel_lru_locks osc
2805 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2808 run_test 39i "write, rename, stat =============================="
2811 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2812 start_full_debug_logging
2816 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
2817 lctl set_param fail_loc=0x80000412
2818 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
2819 error "multiop failed"
2821 local mtime1=`stat -c %Y $DIR1/$tfile`
2823 mv $DIR1/$tfile $DIR1/$tfile-1
2825 kill -USR1 $multipid
2826 wait $multipid || error "multiop close failed"
2828 for (( i=0; i < 2; i++ )) ; do
2829 local mtime2=`stat -c %Y $DIR1/$tfile-1`
2830 [ "$mtime1" = "$mtime2" ] ||
2831 error "mtime is lost on close: $mtime2, " \
2834 cancel_lru_locks osc
2835 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2837 lctl set_param fail_loc=0
2838 stop_full_debug_logging
2840 run_test 39j "write, rename, close, stat ======================="
2843 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2847 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
2849 local mtime1=`stat -c %Y $DIR1/$tfile`
2851 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2853 kill -USR1 $multipid
2854 wait $multipid || error "multiop close failed"
2856 for (( i=0; i < 2; i++ )) ; do
2857 local mtime2=`stat -c %Y $DIR1/$tfile`
2859 [ "$mtime2" = $TEST_39_MTIME ] || \
2860 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
2862 cancel_lru_locks osc
2863 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2866 run_test 39k "write, utime, close, stat ========================"
2868 # this should be set to future
2869 TEST_39_ATIME=`date -d "1 year" +%s`
2872 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2873 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2874 local atime_diff=$(do_facet $SINGLEMDS \
2875 lctl get_param -n mdd.*MDT0000*.atime_diff)
2879 # test setting directory atime to future
2880 touch -a -d @$TEST_39_ATIME $DIR/$tdir
2881 local atime=$(stat -c %X $DIR/$tdir)
2882 [ "$atime" = $TEST_39_ATIME ] || \
2883 error "atime is not set to future: $atime, $TEST_39_ATIME"
2885 # test setting directory atime from future to now
2886 local d1=$(date +%s)
2888 local d2=$(date +%s)
2890 cancel_lru_locks mdc
2891 atime=$(stat -c %X $DIR/$tdir)
2892 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
2893 error "atime is not updated from future: $atime, $d1<atime<$d2"
2895 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
2898 # test setting directory atime when now > dir atime + atime_diff
2902 cancel_lru_locks mdc
2903 atime=$(stat -c %X $DIR/$tdir)
2904 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
2905 error "atime is not updated : $atime, should be $d2"
2907 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
2910 # test not setting directory atime when now < dir atime + atime_diff
2912 cancel_lru_locks mdc
2913 atime=$(stat -c %X $DIR/$tdir)
2914 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
2915 error "atime is updated to $atime, should remain $d1<atime<$d2"
2917 do_facet $SINGLEMDS \
2918 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
2920 run_test 39l "directory atime update ==========================="
2923 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2926 local far_past_mtime=$(date -d "May 29 1953" +%s)
2927 local far_past_atime=$(date -d "Dec 17 1903" +%s)
2929 touch -m -d @$far_past_mtime $DIR1/$tfile
2930 touch -a -d @$far_past_atime $DIR1/$tfile
2932 for (( i=0; i < 2; i++ )) ; do
2933 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
2934 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
2935 error "atime or mtime set incorrectly"
2937 cancel_lru_locks osc
2938 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2941 run_test 39m "test atime and mtime before 1970"
2944 dd if=/dev/zero of=$DIR/f40 bs=4096 count=1
2945 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/f40 && error
2946 $CHECKSTAT -t file -s 4096 $DIR/f40 || error
2948 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
2952 small_write $DIR/f41 18
2954 run_test 41 "test small file write + fstat ====================="
2956 count_ost_writes() {
2957 lctl get_param -n osc.*.stats |
2958 awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }'
2965 BG_DIRTY_RATIO_SAVE=10
2966 MAX_BG_DIRTY_RATIO=25
2970 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
2971 # dirty_ratio, dirty_background_ratio
2972 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
2973 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
2974 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
2975 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
2977 # if file not here, we are a 2.4 kernel
2978 kill -CONT `pidof kupdated`
2983 # setup the trap first, so someone cannot exit the test at the
2984 # exact wrong time and mess up a machine
2985 trap start_writeback EXIT
2986 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
2987 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
2988 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
2989 sysctl -w vm.dirty_writeback_centisecs=0
2990 sysctl -w vm.dirty_writeback_centisecs=0
2991 # save and increase /proc/sys/vm/dirty_ratio
2992 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
2993 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
2994 # save and increase /proc/sys/vm/dirty_background_ratio
2995 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
2996 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
2998 # if file not here, we are a 2.4 kernel
2999 kill -STOP `pidof kupdated`
3003 # ensure that all stripes have some grant before we test client-side cache
3005 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
3006 dd if=/dev/zero of=$i bs=4k count=1
3011 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
3012 # file truncation, and file removal.
3014 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3016 cancel_lru_locks osc
3018 sync; sleep 1; sync # just to be safe
3019 BEFOREWRITES=`count_ost_writes`
3020 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
3021 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
3022 AFTERWRITES=`count_ost_writes`
3023 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3024 error "$BEFOREWRITES < $AFTERWRITES"
3027 run_test 42a "ensure that we don't flush on close =============="
3030 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3032 cancel_lru_locks osc
3035 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
3036 BEFOREWRITES=`count_ost_writes`
3037 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
3038 AFTERWRITES=`count_ost_writes`
3039 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
3040 error "$BEFOREWRITES < $AFTERWRITES on unlink"
3042 BEFOREWRITES=`count_ost_writes`
3043 sync || error "sync: $?"
3044 AFTERWRITES=`count_ost_writes`
3045 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
3046 error "$BEFOREWRITES < $AFTERWRITES on sync"
3048 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
3052 run_test 42b "test destroy of file with cached dirty data ======"
3054 # if these tests just want to test the effect of truncation,
3055 # they have to be very careful. consider:
3056 # - the first open gets a {0,EOF}PR lock
3057 # - the first write conflicts and gets a {0, count-1}PW
3058 # - the rest of the writes are under {count,EOF}PW
3059 # - the open for truncate tries to match a {0,EOF}PR
3060 # for the filesize and cancels the PWs.
3061 # any number of fixes (don't get {0,EOF} on open, match
3062 # composite locks, do smarter file size management) fix
3063 # this, but for now we want these tests to verify that
3064 # the cancellation with truncate intent works, so we
3065 # start the file with a full-file pw lock to match against
3066 # until the truncate.
3071 cancel_lru_locks osc
3073 # prime the file with 0,EOF PW to match
3077 # now the real test..
3078 dd if=/dev/zero of=$file bs=1024 count=100
3079 BEFOREWRITES=`count_ost_writes`
3080 $TRUNCATE $file $offset
3081 cancel_lru_locks osc
3082 AFTERWRITES=`count_ost_writes`
3087 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3089 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
3090 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
3093 run_test 42c "test partial truncate of file with cached dirty data"
3096 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3098 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3099 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
3102 run_test 42d "test complete truncate of file with cached dirty data"
3104 test_42e() { # bug22074
3105 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3106 local TDIR=$DIR/${tdir}e
3107 local pagesz=$(page_size)
3108 local pages=16 # hardcoded 16 pages, don't change it.
3109 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
3110 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
3114 test_mkdir -p $DIR/${tdir}e
3115 $SETSTRIPE -c 1 $TDIR
3116 createmany -o $TDIR/f $files
3118 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
3120 # we assume that with $OSTCOUNT files, at least one of them will
3121 # be allocated on OST0.
3122 warmup_files=$((OSTCOUNT * max_dirty_mb))
3123 createmany -o $TDIR/w $warmup_files
3125 # write a large amount of data into one file and sync, to get good
3126 # avail_grant number from OST.
3127 for ((i=0; i<$warmup_files; i++)); do
3128 idx=$($GETSTRIPE -i $TDIR/w$i)
3129 [ $idx -ne 0 ] && continue
3130 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
3133 [ $i -gt $warmup_files ] && error "OST0 is still cold"
3135 $LCTL get_param $proc_osc0/cur_dirty_bytes
3136 $LCTL get_param $proc_osc0/cur_grant_bytes
3138 # create as much dirty pages as we can while not to trigger the actual
3139 # RPCs directly. but depends on the env, VFS may trigger flush during this
3140 # period, hopefully we are good.
3141 for ((i=0; i<$warmup_files; i++)); do
3142 idx=$($GETSTRIPE -i $TDIR/w$i)
3143 [ $idx -ne 0 ] && continue
3144 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
3146 $LCTL get_param $proc_osc0/cur_dirty_bytes
3147 $LCTL get_param $proc_osc0/cur_grant_bytes
3149 # perform the real test
3150 $LCTL set_param $proc_osc0/rpc_stats 0
3151 for ((;i<$files; i++)); do
3152 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
3153 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
3156 $LCTL get_param $proc_osc0/rpc_stats
3159 local have_ppr=false
3160 $LCTL get_param $proc_osc0/rpc_stats |
3161 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
3162 # skip lines until we are at the RPC histogram data
3163 [ "$PPR" == "pages" ] && have_ppr=true && continue
3164 $have_ppr || continue
3166 # we only want the percent stat for < 16 pages
3167 [ $(echo $PPR | tr -d ':') -ge $pages ] && break
3169 percent=$((percent + WPCT))
3170 if [ $percent -gt 15 ]; then
3171 error "less than 16-pages write RPCs" \
3178 run_test 42e "verify sub-RPC writes are not done synchronously"
3181 test_mkdir -p $DIR/$tdir
3182 cp -p /bin/ls $DIR/$tdir/$tfile
3183 $MULTIOP $DIR/$tdir/$tfile Ow_c &
3185 # give multiop a chance to open
3188 $DIR/$tdir/$tfile && error || true
3191 run_test 43 "execution of file opened for write should return -ETXTBSY"
3194 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3195 test_mkdir -p $DIR/$tdir
3196 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3197 cp -p multiop $DIR/$tdir/multiop
3198 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/test43.junk O_c ||
3201 $MULTIOP $DIR/$tdir/multiop Oc && error "expected error, got success"
3202 kill -USR1 $MULTIOP_PID || return 2
3203 wait $MULTIOP_PID || return 3
3206 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
3209 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3210 test_mkdir -p $DIR/$tdir
3211 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3212 cp -p multiop $DIR/$tdir/multiop
3213 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/test43.junk O_c ||
3216 $TRUNCATE $DIR/$tdir/multiop 0 && error "expected error, got success"
3217 kill -USR1 $MULTIOP_PID || return 2
3218 wait $MULTIOP_PID || return 3
3221 run_test 43b "truncate of file being executed should return -ETXTBSY"
3224 local testdir="$DIR/$tdir"
3225 test_mkdir -p $DIR/$tdir
3227 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
3228 ( cd $testdir && md5sum -c)
3230 run_test 43c "md5sum of copy into lustre========================"
3233 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
3234 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
3235 dd if=$DIR/f1 bs=4k count=1 > /dev/null
3237 run_test 44 "zero length read from a sparse stripe ============="
3240 local nstripe=`$LCTL lov_getconfig $DIR | grep default_stripe_count: | \
3242 [ -z "$nstripe" ] && skip "can't get stripe info" && return
3243 [ "$nstripe" -gt "$OSTCOUNT" ] && skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" && return
3244 local stride=`$LCTL lov_getconfig $DIR | grep default_stripe_size: | \
3246 if [ $nstripe -eq 0 -o $nstripe -eq -1 ] ; then
3247 nstripe=`$LCTL lov_getconfig $DIR | grep obd_count: | awk '{print $2}'`
3250 OFFSETS="0 $((stride/2)) $((stride-1))"
3251 for offset in $OFFSETS ; do
3252 for i in `seq 0 $((nstripe-1))`; do
3253 local GLOBALOFFSETS=""
3254 local size=$((((i + 2 * $nstripe )*$stride + $offset))) # Bytes
3255 local myfn=$DIR/d44a-$size
3256 echo "--------writing $myfn at $size"
3257 ll_sparseness_write $myfn $size || error "ll_sparseness_write"
3258 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3259 ll_sparseness_verify $myfn $GLOBALOFFSETS \
3260 || error "ll_sparseness_verify $GLOBALOFFSETS"
3262 for j in `seq 0 $((nstripe-1))`; do
3263 size=$((((j + $nstripe )*$stride + $offset))) # Bytes
3264 ll_sparseness_write $myfn $size || error "ll_sparseness_write"
3265 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3267 ll_sparseness_verify $myfn $GLOBALOFFSETS \
3268 || error "ll_sparseness_verify $GLOBALOFFSETS"
3273 run_test 44a "test sparse pwrite ==============================="
3277 for d in `lctl get_param -n osc.*.cur_dirty_bytes`; do
3283 before=`dirty_osc_total`
3284 echo executing "\"$*\""
3286 after=`dirty_osc_total`
3287 echo before $before, after $after
3290 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3292 # Obtain grants from OST if it supports it
3293 echo blah > ${f}_grant
3296 do_dirty_record "echo blah > $f"
3297 [ $before -eq $after ] && error "write wasn't cached"
3298 do_dirty_record "> $f"
3299 [ $before -gt $after ] || error "truncate didn't lower dirty count"
3300 do_dirty_record "echo blah > $f"
3301 [ $before -eq $after ] && error "write wasn't cached"
3302 do_dirty_record "sync"
3303 [ $before -gt $after ] || error "writeback didn't lower dirty count"
3304 do_dirty_record "echo blah > $f"
3305 [ $before -eq $after ] && error "write wasn't cached"
3306 do_dirty_record "cancel_lru_locks osc"
3307 [ $before -gt $after ] || error "lock cancellation didn't lower dirty count"
3310 run_test 45 "osc io page accounting ============================"
3312 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
3313 # test tickles a bug where re-dirtying a page was failing to be mapped to the
3314 # objects offset and an assert hit when an rpc was built with 1023's mapped
3315 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
3317 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3321 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3323 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
3324 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3328 run_test 46 "dirtying a previously written page ================"
3330 # test_47 is removed "Device nodes check" is moved to test_28
3332 test_48a() { # bug 2399
3333 check_kernel_version 34 || return 0
3334 test_mkdir -p $DIR/$tdir
3336 mv $DIR/$tdir $DIR/d48.new || error "move directory failed"
3337 test_mkdir $DIR/$tdir || error "recreate directory failed"
3338 touch foo || error "'touch foo' failed after recreating cwd"
3339 test_mkdir $DIR/$tdir/bar ||
3340 error "'mkdir foo' failed after recreating cwd"
3341 if check_kernel_version 44; then
3342 touch .foo || error "'touch .foo' failed after recreating cwd"
3343 test_mkdir $DIR/$tdir/.bar ||
3344 error "'mkdir .foo' failed after recreating cwd"
3346 ls . > /dev/null || error "'ls .' failed after recreating cwd"
3347 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3348 cd . || error "'cd .' failed after recreating cwd"
3349 test_mkdir . && error "'mkdir .' worked after recreating cwd"
3350 rmdir . && error "'rmdir .' worked after recreating cwd"
3351 ln -s . baz || error "'ln -s .' failed after recreating cwd"
3352 cd .. || error "'cd ..' failed after recreating cwd"
3354 run_test 48a "Access renamed working dir (should return errors)="
3356 test_48b() { # bug 2399
3357 check_kernel_version 34 || return 0
3359 test_mkdir -p $DIR/$tdir
3361 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
3362 touch foo && error "'touch foo' worked after removing cwd"
3363 test_mkdir $DIR/$tdir/foo &&
3364 error "'mkdir foo' worked after removing cwd"
3365 if check_kernel_version 44; then
3366 touch .foo && error "'touch .foo' worked after removing cwd"
3367 test_mkdir $DIR/$tdir/.foo &&
3368 error "'mkdir .foo' worked after removing cwd"
3370 ls . > /dev/null && error "'ls .' worked after removing cwd"
3371 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3372 is_patchless || ( cd . && error "'cd .' worked after removing cwd" )
3373 test_mkdir $DIR/$tdir/. && error "'mkdir .' worked after removing cwd"
3374 rmdir . && error "'rmdir .' worked after removing cwd"
3375 ln -s . foo && error "'ln -s .' worked after removing cwd"
3376 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
3378 run_test 48b "Access removed working dir (should return errors)="
3380 test_48c() { # bug 2350
3381 check_kernel_version 36 || return 0
3382 #lctl set_param debug=-1
3385 test_mkdir -p $DIR/$tdir/dir
3387 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3388 $TRACE touch foo && error "touch foo worked after removing cwd"
3389 $TRACE test_mkdir foo && error "'mkdir foo' worked after removing cwd"
3390 if check_kernel_version 44; then
3391 touch .foo && error "touch .foo worked after removing cwd"
3392 test_mkdir .foo && error "mkdir .foo worked after removing cwd"
3394 $TRACE ls . && error "'ls .' worked after removing cwd"
3395 $TRACE ls .. || error "'ls ..' failed after removing cwd"
3396 is_patchless || ( $TRACE cd . &&
3397 error "'cd .' worked after removing cwd" )
3398 $TRACE test_mkdir . && error "'mkdir .' worked after removing cwd"
3399 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
3400 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
3401 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
3403 run_test 48c "Access removed working subdir (should return errors)"
3405 test_48d() { # bug 2350
3406 check_kernel_version 36 || return 0
3407 #lctl set_param debug=-1
3410 test_mkdir -p $DIR/$tdir/dir
3412 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3413 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3414 $TRACE touch foo && error "'touch foo' worked after removing parent"
3415 $TRACE test_mkdir foo && error "mkdir foo worked after removing parent"
3416 if check_kernel_version 44; then
3417 touch .foo && error "'touch .foo' worked after removing parent"
3419 error "mkdir .foo worked after removing parent"
3421 $TRACE ls . && error "'ls .' worked after removing parent"
3422 $TRACE ls .. && error "'ls ..' worked after removing parent"
3423 is_patchless || ( $TRACE cd . &&
3424 error "'cd .' worked after recreate parent" )
3425 $TRACE test_mkdir . && error "'mkdir .' worked after removing parent"
3426 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
3427 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
3428 is_patchless || ( $TRACE cd .. &&
3429 error "'cd ..' worked after removing parent" || true )
3431 run_test 48d "Access removed parent subdir (should return errors)"
3433 test_48e() { # bug 4134
3434 check_kernel_version 41 || return 0
3435 #lctl set_param debug=-1
3438 test_mkdir -p $DIR/$tdir/dir
3440 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3441 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3442 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
3443 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
3444 # On a buggy kernel addition of "touch foo" after cd .. will
3445 # produce kernel oops in lookup_hash_it
3446 touch ../foo && error "'cd ..' worked after recreate parent"
3448 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
3450 run_test 48e "Access to recreated parent subdir (should return errors)"
3452 test_49() { # LU-1030
3453 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3454 # get ost1 size - lustre-OST0000
3455 ost1_size=$(do_facet ost1 lfs df |grep ${ost1_svc} |awk '{print $4}')
3456 # write 800M at maximum
3457 [ $ost1_size -gt 819200 ] && ost1_size=819200
3459 lfs setstripe -c 1 -i 0 $DIR/$tfile
3460 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
3463 # change max_pages_per_rpc while writing the file
3464 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
3465 local orig_mppc=`$LCTL get_param -n $osc1_mppc`
3466 # loop until dd process exits
3467 while ps ax -opid | grep -wq $dd_pid; do
3468 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
3469 sleep $((RANDOM % 5 + 1))
3471 # restore original max_pages_per_rpc
3472 $LCTL set_param $osc1_mppc=$orig_mppc
3473 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
3475 run_test 49 "Change max_pages_per_rpc won't break osc extent"
3479 test_mkdir $DIR/$tdir
3481 ls /proc/$$/cwd || error
3483 run_test 50 "special situations: /proc symlinks ==============="
3485 test_51a() { # was test_51
3486 # bug 1516 - create an empty entry right after ".." then split dir
3487 test_mkdir $DIR/$tdir
3488 touch $DIR/$tdir/foo
3489 $MCREATE $DIR/$tdir/bar
3491 createmany -m $DIR/$tdir/longfile 201
3493 while [ `ls -sd $DIR/$tdir | awk '{ print $1 }'` -eq 4 ]; do
3494 $MCREATE $DIR/$tdir/longfile$FNUM
3499 ls -l $DIR/$tdir > /dev/null || error
3501 run_test 51a "special situations: split htree with empty entry =="
3503 export NUMTEST=70000
3505 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3506 local BASE=$DIR/$tdir
3510 local mdtidx=$(printf "%04x" $($LFS getstripe -M $BASE))
3511 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
3512 [ $numfree -lt 21000 ] && skip "not enough free inodes ($numfree)" &&
3515 [ $numfree -lt $NUMTEST ] && NUMTEST=$(($numfree - 50)) &&
3516 echo "reduced count to $NUMTEST due to inodes"
3518 # need to check free space for the directories as well
3519 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
3520 numfree=$((blkfree / 4))
3521 [ $numfree -lt $NUMTEST ] && NUMTEST=$(($numfree - 50)) &&
3522 echo "reduced count to $NUMTEST due to blocks"
3524 createmany -d $BASE/d $NUMTEST && echo $NUMTEST > $BASE/fnum ||
3525 echo "failed" > $BASE/fnum
3527 run_test 51b "exceed 64k subdirectory nlink limit"
3529 test_51ba() { # LU-993
3530 local BASE=$DIR/$tdir
3531 # unlink all but 100 subdirectories, then check it still works
3533 [ -f $BASE/fnum ] && local NUMPREV=$(cat $BASE/fnum) && rm $BASE/fnum
3535 [ "$NUMPREV" != "failed" ] && NUMTEST=$NUMPREV
3536 local DELETE=$((NUMTEST - LEFT))
3538 # continue on to run this test even if 51b didn't finish,
3539 # just to delete the many subdirectories created.
3540 [ ! -d "${BASE}/d1" ] && skip "test_51b() not run" && return 0
3542 # for ldiskfs the nlink count should be 1, but this is OSD specific
3543 # and so this is listed for informational purposes only
3544 echo "nlink before: $(stat -c %h $BASE), created before: $NUMTEST"
3545 unlinkmany -d $BASE/d $DELETE
3548 if [ $RC -ne 0 ]; then
3549 if [ "$NUMPREV" == "failed" ]; then
3550 skip "previous setup failed"
3553 error "unlink of first $DELETE subdirs failed"
3558 echo "nlink between: $(stat -c %h $BASE)"
3559 # trim the first line of ls output
3560 local FOUND=$(($(ls -l ${BASE} | wc -l) - 1))
3561 [ $FOUND -ne $LEFT ] &&
3562 error "can't find subdirs: found only $FOUND/$LEFT"
3564 unlinkmany -d $BASE/d $DELETE $LEFT ||
3565 error "unlink of second $LEFT subdirs failed"
3566 # regardless of whether the backing filesystem tracks nlink accurately
3567 # or not, the nlink count shouldn't be more than "." and ".." here
3568 local AFTER=$(stat -c %h $BASE)
3569 [ $AFTER -gt 2 ] && error "nlink after: $AFTER > 2" ||
3570 echo "nlink after: $AFTER"
3572 run_test 51ba "verify nlink for many subdirectory cleanup"
3575 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3576 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping test with few OSTs" && return
3577 test_mkdir -p $DIR/$tdir
3578 createmany -o $DIR/$tdir/t- 1000
3579 $GETSTRIPE $DIR/$tdir > $TMP/files
3580 for N in `seq 0 $((OSTCOUNT - 1))`; do
3581 OBJS[$N]=`awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}' $TMP/files`
3582 OBJS0[$N]=`grep -A 1 idx $TMP/files | awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}'`
3583 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
3585 unlinkmany $DIR/$tdir/t- 1000
3588 for N in `seq 1 $((OSTCOUNT - 1))`; do
3589 [ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ] && \
3590 error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
3591 [ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ] && \
3592 error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
3594 [ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ] && \
3595 error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
3596 [ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ] && \
3597 error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
3601 run_test 51d "check object distribution ===================="
3604 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
3605 test_mkdir -p $DIR/$tdir
3606 touch $DIR/$tdir/foo
3607 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
3608 echo bar >> $DIR/$tdir/foo || error "append bar failed"
3609 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
3610 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
3611 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
3613 echo foo >> $DIR/$tdir/foo || error "append foo failed"
3614 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
3615 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
3617 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
3618 cp -r $DIR/$tdir /tmp/
3619 rm -fr $DIR/$tdir || error "cleanup rm failed"
3621 run_test 52a "append-only flag test (should return errors) ====="
3624 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
3625 test_mkdir -p $DIR/$tdir
3626 touch $DIR/$tdir/foo
3627 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
3628 cat test > $DIR/$tdir/foo && error "cat test worked"
3629 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
3630 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
3631 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
3633 echo foo >> $DIR/$tdir/foo && error "echo worked"
3634 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
3635 [ -f $DIR/$tdir/foo ] || error
3636 [ -f $DIR/$tdir/foo_ren ] && error
3637 lsattr $DIR/$tdir/foo | egrep -q "^-+i[-e]+ $DIR/$tdir/foo" ||
3639 chattr -i $DIR/$tdir/foo || error "chattr failed"
3641 rm -fr $DIR/$tdir || error
3643 run_test 52b "immutable flag test (should return errors) ======="
3646 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3647 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3648 remote_ost_nodsh && skip "remote OST with nodsh" && return
3658 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
3659 for value in $(do_facet $SINGLEMDS lctl get_param osc.$mdtosc.prealloc_last_id) ; do
3660 param=`echo ${value[0]} | cut -d "=" -f1`
3661 ostname=`echo $param | cut -d "." -f2 | cut -d - -f 1-2`
3662 mds_last=$(do_facet $SINGLEMDS lctl get_param -n $param)
3663 ostnum=$(index_from_ostuuid ${ostname}_UUID)
3664 node=$(facet_active_host ost$((ostnum+1)))
3665 param="obdfilter.$ostname.last_id"
3666 ost_last=$(do_node $node lctl get_param -n $param | head -n 1)
3667 echo "$ostname.last_id=$ost_last ; MDS.last_id=$mds_last"
3668 if [ $ost_last != $mds_last ]; then
3669 error "$ostname.last_id=$ost_last ; MDS.last_id=$mds_last"
3673 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
3676 [ ! -f "$SOCKETSERVER" ] && skip_env "no socketserver, skipping" && return
3677 [ ! -f "$SOCKETCLIENT" ] && skip_env "no socketclient, skipping" && return
3678 $SOCKETSERVER $DIR/socket
3679 $SOCKETCLIENT $DIR/socket || error
3680 $MUNLINK $DIR/socket
3682 run_test 54a "unix domain socket test =========================="
3688 dd if=/dev/zero of=$f bs=`page_size` count=1
3690 run_test 54b "char device works in lustre ======================"
3693 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
3694 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
3695 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
3697 for i in `seq 3 7`; do
3698 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
3706 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3709 loopdev="$DIR/loop54c"
3712 [ -z "$LOOPNUM" ] && echo "couldn't find empty loop device" && return
3713 mknod $loopdev b 7 $LOOPNUM
3714 echo "make a loop file system with $tfile on $loopdev ($LOOPNUM)..."
3715 dd if=/dev/zero of=$tfile bs=`page_size` seek=1024 count=1 > /dev/null
3716 losetup $loopdev $tfile || error "can't set up $loopdev for $tfile"
3717 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
3719 mount -t ext2 $loopdev $tdir || error "error mounting $loopdev on $tdir"
3720 dd if=/dev/zero of=$tdir/tmp bs=`page_size` count=30 || error "dd write"
3722 dd if=$tdir/tmp of=/dev/zero bs=`page_size` count=30 || error "dd read"
3727 run_test 54c "block device works in lustre ====================="
3733 [ "$string" = `echo $string > $f | cat $f` ] || error
3735 run_test 54d "fifo device works in lustre ======================"
3738 check_kernel_version 46 || return 0
3741 cp -aL /dev/console $f
3742 echo $string > $f || error
3744 run_test 54e "console/tty device works in lustre ======================"
3746 #The test_55 used to be iopen test and it was removed by bz#24037.
3747 #run_test 55 "check iopen_connect_dentry() ======================"
3749 test_56a() { # was test_56
3752 test_mkdir $DIR/$tdir
3753 test_mkdir $DIR/$tdir/dir
3755 NUMFILESx2=$(($NUMFILES * 2))
3756 for i in `seq 1 $NUMFILES` ; do
3757 touch $DIR/$tdir/file$i
3758 touch $DIR/$tdir/dir/file$i
3761 # test lfs getstripe with --recursive
3762 FILENUM=`$GETSTRIPE --recursive $DIR/$tdir | grep -c obdidx`
3763 [ $FILENUM -eq $NUMFILESx2 ] ||
3764 error "$GETSTRIPE --recursive: found $FILENUM, not $NUMFILESx2"
3765 FILENUM=`$GETSTRIPE $DIR/$tdir | grep -c obdidx`
3766 [ $FILENUM -eq $NUMFILES ] ||
3767 error "$GETSTRIPE $DIR/$tdir: found $FILENUM, not $NUMFILES"
3768 echo "$GETSTRIPE --recursive passed."
3770 # test lfs getstripe with file instead of dir
3771 FILENUM=`$GETSTRIPE $DIR/$tdir/file1 | grep -c obdidx`
3772 [ $FILENUM -eq 1 ] || error \
3773 "$GETSTRIPE $DIR/$tdir/file1: found $FILENUM, not 1"
3774 echo "$GETSTRIPE file1 passed."
3776 #test lfs getstripe with --verbose
3777 [ `$GETSTRIPE --verbose $DIR/$tdir |
3778 grep -c lmm_magic` -eq $NUMFILES ] ||
3779 error "$GETSTRIPE --verbose $DIR/$tdir: want $NUMFILES"
3780 [ `$GETSTRIPE $DIR/$tdir | grep -c lmm_magic` -eq 0 ] ||
3781 error "$GETSTRIPE $DIR/$tdir: showed lmm_magic"
3782 echo "$GETSTRIPE --verbose passed."
3784 #test lfs getstripe with --obd
3785 $GETSTRIPE --obd wrong_uuid $DIR/$tdir 2>&1 |
3786 grep -q "unknown obduuid" ||
3787 error "$GETSTRIPE --obd wrong_uuid should return error message"
3789 [ "$OSTCOUNT" -lt 2 ] &&
3790 skip_env "skipping other $GETSTRIPE --obd test" && return
3793 OBDUUID=$(ostuuid_from_index $OSTIDX)
3794 FILENUM=`$GETSTRIPE -ir $DIR/$tdir | grep -x $OSTIDX | wc -l`
3795 FOUND=`$GETSTRIPE -r --obd $OBDUUID $DIR/$tdir | grep obdidx | wc -l`
3796 [ $FOUND -eq $FILENUM ] ||
3797 error "$GETSTRIPE --obd wrong: found $FOUND, expected $FILENUM"
3798 [ `$GETSTRIPE -r -v --obd $OBDUUID $DIR/$tdir |
3799 sed '/^[ ]*'${OSTIDX}'[ ]/d' |
3800 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l` -eq 0 ] ||
3801 error "$GETSTRIPE --obd: should not show file on other obd"
3802 echo "$GETSTRIPE --obd passed"
3804 run_test 56a "check $GETSTRIPE"
3809 local LOCAL_NUMFILES="$1"
3810 local LOCAL_NUMDIRS="$2"
3811 local MKDIR_PARAMS="$3"
3813 if [ ! -d "$TDIR" ] ; then
3815 [ "$MKDIR_PARAMS" ] && $SETSTRIPE $MKDIR_PARAMS $TDIR
3816 for i in `seq 1 $LOCAL_NUMFILES` ; do
3819 for i in `seq 1 $LOCAL_NUMDIRS` ; do
3820 test_mkdir $TDIR/dir$i
3821 for j in `seq 1 $LOCAL_NUMFILES` ; do
3822 touch $TDIR/dir$i/file$j
3828 setup_56_special() {
3832 if [ ! -e "$TDIR/loop1b" ] ; then
3833 for i in `seq 1 $LOCAL_NUMFILES` ; do
3834 mknod $TDIR/loop${i}b b 7 $i
3835 mknod $TDIR/null${i}c c 1 3
3836 ln -s $TDIR/file1 $TDIR/link${i}l
3838 for i in `seq 1 $LOCAL_NUMDIRS` ; do
3839 mknod $TDIR/dir$i/loop${i}b b 7 $i
3840 mknod $TDIR/dir$i/null${i}c c 1 3
3841 ln -s $TDIR/dir$i/file1 $TDIR/dir$i/link${i}l
3850 setup_56 $NUMFILES $NUMDIRS
3852 EXPECTED=$(($NUMDIRS + 2))
3853 # test lfs find with -name
3854 for i in $(seq 1 $NUMFILES) ; do
3855 NUMS=$($LFIND -name "*$i" $TDIR | wc -l)
3856 [ $NUMS -eq $EXPECTED ] ||
3857 error "lfs find -name \"*$i\" $TDIR wrong: "\
3858 "found $NUMS, expected $EXPECTED"
3861 run_test 56g "check lfs find -name ============================="
3867 setup_56 $NUMFILES $NUMDIRS
3869 EXPECTED=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
3870 # test lfs find with ! -name
3871 for i in $(seq 1 $NUMFILES) ; do
3872 NUMS=$($LFIND ! -name "*$i" $TDIR | wc -l)
3873 [ $NUMS -eq $EXPECTED ] ||
3874 error "lfs find ! -name \"*$i\" $TDIR wrong: "\
3875 "found $NUMS, expected $EXPECTED"
3878 run_test 56h "check lfs find ! -name ============================="
3882 test_mkdir -p $DIR/$tdir
3883 UUID=$(ostuuid_from_index 0 $DIR/$tdir)
3884 CMD="$LFIND -ost $UUID $DIR/$tdir"
3886 [ -z "$OUT" ] || error "\"$CMD\" returned directory '$OUT'"
3888 run_test 56i "check 'lfs find -ost UUID' skips directories ======="
3892 setup_56_special $NUMFILES $NUMDIRS
3894 EXPECTED=$((NUMDIRS + 1))
3895 CMD="$LFIND -type d $TDIR"
3896 NUMS=$($CMD | wc -l)
3897 [ $NUMS -eq $EXPECTED ] ||
3898 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3900 run_test 56j "check lfs find -type d ============================="
3904 setup_56_special $NUMFILES $NUMDIRS
3906 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
3907 CMD="$LFIND -type f $TDIR"
3908 NUMS=$($CMD | wc -l)
3909 [ $NUMS -eq $EXPECTED ] ||
3910 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3912 run_test 56k "check lfs find -type f ============================="
3916 setup_56_special $NUMFILES $NUMDIRS
3918 EXPECTED=$((NUMDIRS + NUMFILES))
3919 CMD="$LFIND -type b $TDIR"
3920 NUMS=$($CMD | wc -l)
3921 [ $NUMS -eq $EXPECTED ] ||
3922 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3924 run_test 56l "check lfs find -type b ============================="
3928 setup_56_special $NUMFILES $NUMDIRS
3930 EXPECTED=$((NUMDIRS + NUMFILES))
3931 CMD="$LFIND -type c $TDIR"
3932 NUMS=$($CMD | wc -l)
3933 [ $NUMS -eq $EXPECTED ] ||
3934 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3936 run_test 56m "check lfs find -type c ============================="
3940 setup_56_special $NUMFILES $NUMDIRS
3942 EXPECTED=$((NUMDIRS + NUMFILES))
3943 CMD="$LFIND -type l $TDIR"
3944 NUMS=$($CMD | wc -l)
3945 [ $NUMS -eq $EXPECTED ] ||
3946 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3948 run_test 56n "check lfs find -type l ============================="
3952 setup_56 $NUMFILES $NUMDIRS
3954 utime $TDIR/file1 > /dev/null || error "utime (1)"
3955 utime $TDIR/file2 > /dev/null || error "utime (2)"
3956 utime $TDIR/dir1 > /dev/null || error "utime (3)"
3957 utime $TDIR/dir2 > /dev/null || error "utime (4)"
3958 utime $TDIR/dir1/file1 > /dev/null || error "utime (5)"
3959 dd if=/dev/zero count=1 >> $TDIR/dir1/file1 && sync
3962 NUMS=`$LFIND -mtime +0 $TDIR | wc -l`
3963 [ $NUMS -eq $EXPECTED ] || \
3964 error "lfs find -mtime +0 $TDIR wrong: found $NUMS, expected $EXPECTED"
3967 CMD="$LFIND -mtime 0 $TDIR"
3968 NUMS=$($CMD | wc -l)
3969 [ $NUMS -eq $EXPECTED ] ||
3970 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3972 run_test 56o "check lfs find -mtime for old files =========================="
3975 [ $RUNAS_ID -eq $UID ] &&
3976 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
3979 setup_56 $NUMFILES $NUMDIRS
3981 chown $RUNAS_ID $TDIR/file* || error "chown $DIR/${tdir}g/file$i failed"
3983 CMD="$LFIND -uid $RUNAS_ID $TDIR"
3984 NUMS=$($CMD | wc -l)
3985 [ $NUMS -eq $EXPECTED ] || \
3986 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3988 EXPECTED=$(((NUMFILES + 1) * NUMDIRS + 1))
3989 CMD="$LFIND ! -uid $RUNAS_ID $TDIR"
3990 NUMS=$($CMD | wc -l)
3991 [ $NUMS -eq $EXPECTED ] || \
3992 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3994 run_test 56p "check lfs find -uid and ! -uid ==============================="
3997 [ $RUNAS_ID -eq $UID ] &&
3998 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4001 setup_56 $NUMFILES $NUMDIRS
4003 chgrp $RUNAS_GID $TDIR/file* || error "chown $TDIR/file$i failed"
4006 CMD="$LFIND -gid $RUNAS_GID $TDIR"
4007 NUMS=$($CMD | wc -l)
4008 [ $NUMS -eq $EXPECTED ] ||
4009 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4011 EXPECTED=$(( ($NUMFILES+1) * $NUMDIRS + 1))
4012 CMD="$LFIND ! -gid $RUNAS_GID $TDIR"
4013 NUMS=$($CMD | wc -l)
4014 [ $NUMS -eq $EXPECTED ] ||
4015 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4017 run_test 56q "check lfs find -gid and ! -gid ==============================="
4021 setup_56 $NUMFILES $NUMDIRS
4024 CMD="$LFIND -size 0 -type f $TDIR"
4025 NUMS=$($CMD | wc -l)
4026 [ $NUMS -eq $EXPECTED ] ||
4027 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4029 CMD="$LFIND ! -size 0 -type f $TDIR"
4030 NUMS=$($CMD | wc -l)
4031 [ $NUMS -eq $EXPECTED ] ||
4032 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4033 echo "test" > $TDIR/$tfile
4034 echo "test2" > $TDIR/$tfile.2 && sync
4036 CMD="$LFIND -size 5 -type f $TDIR"
4037 NUMS=$($CMD | wc -l)
4038 [ $NUMS -eq $EXPECTED ] ||
4039 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4041 CMD="$LFIND -size +5 -type f $TDIR"
4042 NUMS=$($CMD | wc -l)
4043 [ $NUMS -eq $EXPECTED ] ||
4044 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4046 CMD="$LFIND -size +0 -type f $TDIR"
4047 NUMS=$($CMD | wc -l)
4048 [ $NUMS -eq $EXPECTED ] ||
4049 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4051 CMD="$LFIND ! -size -5 -type f $TDIR"
4052 NUMS=$($CMD | wc -l)
4053 [ $NUMS -eq $EXPECTED ] ||
4054 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4056 CMD="$LFIND -size -5 -type f $TDIR"
4057 NUMS=$($CMD | wc -l)
4058 [ $NUMS -eq $EXPECTED ] ||
4059 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4061 run_test 56r "check lfs find -size works =========================="
4063 test_56s() { # LU-611
4065 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT"
4067 if [ $OSTCOUNT -gt 1 ]; then
4068 $SETSTRIPE -c 1 $TDIR/$tfile.{0,1,2,3}
4072 ONESTRIPE=$(((NUMDIRS + 1) * NUMFILES))
4076 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4077 CMD="$LFIND -stripe-count $OSTCOUNT -type f $TDIR"
4078 NUMS=$($CMD | wc -l)
4079 [ $NUMS -eq $EXPECTED ] ||
4080 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4082 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + EXTRA))
4083 CMD="$LFIND -stripe-count +0 -type f $TDIR"
4084 NUMS=$($CMD | wc -l)
4085 [ $NUMS -eq $EXPECTED ] ||
4086 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4089 CMD="$LFIND -stripe-count 1 -type f $TDIR"
4090 NUMS=$($CMD | wc -l)
4091 [ $NUMS -eq $EXPECTED ] ||
4092 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4094 CMD="$LFIND -stripe-count -2 -type f $TDIR"
4095 NUMS=$($CMD | wc -l)
4096 [ $NUMS -eq $EXPECTED ] ||
4097 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4100 CMD="$LFIND -stripe-count $((OSTCOUNT + 1)) -type f $TDIR"
4101 NUMS=$($CMD | wc -l)
4102 [ $NUMS -eq $EXPECTED ] ||
4103 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4105 run_test 56s "check lfs find -stripe-count works"
4107 test_56t() { # LU-611
4109 setup_56 $NUMFILES $NUMDIRS "-s 512k"
4111 $SETSTRIPE -S 256k $TDIR/$tfile.{0,1,2,3}
4113 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4114 CMD="$LFIND -stripe-size 512k -type f $TDIR"
4115 NUMS=$($CMD | wc -l)
4116 [ $NUMS -eq $EXPECTED ] ||
4117 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4119 CMD="$LFIND -stripe-size +320k -type f $TDIR"
4120 NUMS=$($CMD | wc -l)
4121 [ $NUMS -eq $EXPECTED ] ||
4122 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4124 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + 4))
4125 CMD="$LFIND -stripe-size +200k -type f $TDIR"
4126 NUMS=$($CMD | wc -l)
4127 [ $NUMS -eq $EXPECTED ] ||
4128 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4130 CMD="$LFIND -stripe-size -640k -type f $TDIR"
4131 NUMS=$($CMD | wc -l)
4132 [ $NUMS -eq $EXPECTED ] ||
4133 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4136 CMD="$LFIND -stripe-size 256k -type f $TDIR"
4137 NUMS=$($CMD | wc -l)
4138 [ $NUMS -eq $EXPECTED ] ||
4139 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4141 CMD="$LFIND -stripe-size -320k -type f $TDIR"
4142 NUMS=$($CMD | wc -l)
4143 [ $NUMS -eq $EXPECTED ] ||
4144 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4147 CMD="$LFIND -stripe-size 1024k -type f $TDIR"
4148 NUMS=$($CMD | wc -l)
4149 [ $NUMS -eq $EXPECTED ] ||
4150 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4152 run_test 56t "check lfs find -stripe-size works"
4154 test_56u() { # LU-611
4156 setup_56 $NUMFILES $NUMDIRS "-i 0"
4158 if [ $OSTCOUNT -gt 1 ]; then
4159 $SETSTRIPE -i 1 $TDIR/$tfile.{0,1,2,3}
4165 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4166 CMD="$LFIND -stripe-index 0 -type f $TDIR"
4167 NUMS=$($CMD | wc -l)
4168 [ $NUMS -eq $EXPECTED ] ||
4169 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4172 CMD="$LFIND -stripe-index 1 -type f $TDIR"
4173 NUMS=$($CMD | wc -l)
4174 [ $NUMS -eq $EXPECTED ] ||
4175 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4177 CMD="$LFIND ! -stripe-index 0 -type f $TDIR"
4178 NUMS=$($CMD | wc -l)
4179 [ $NUMS -eq $EXPECTED ] ||
4180 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4183 # This should produce an error and not return any files
4184 CMD="$LFIND -stripe-index $OSTCOUNT -type f $TDIR"
4185 NUMS=$($CMD 2>/dev/null | wc -l)
4186 [ $NUMS -eq $EXPECTED ] ||
4187 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4189 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + ONESTRIPE))
4190 CMD="$LFIND -stripe-index 0,1 -type f $TDIR"
4191 NUMS=$($CMD | wc -l)
4192 [ $NUMS -eq $EXPECTED ] ||
4193 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4195 run_test 56u "check lfs find -stripe-index works"
4202 setup_56 $NUMFILES $NUMDIRS
4204 UUID=$(mdtuuid_from_index $MDT_IDX $TDIR)
4205 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT index $MDT_IDX"
4207 for file in $($LFIND -mdt $UUID $TDIR); do
4208 file_mdt_idx=$($GETSTRIPE -M $file)
4209 [ $file_mdt_idx -eq $MDT_IDX ] ||
4210 error "'lfind -mdt $UUID' != 'getstripe -M' ($file_mdt_idx)"
4213 run_test 56v "check 'lfs find -mdt match with lfs getstripe -M' ======="
4215 # Get and check the actual stripe count of one file.
4216 # Usage: check_stripe_count <file> <expected_stripe_count>
4217 check_stripe_count() {
4222 [[ -z "$file" || -z "$expected" ]] &&
4223 error "check_stripe_count: invalid argument!"
4225 local cmd="$GETSTRIPE -c $file"
4226 actual=$($cmd) || error "$cmd failed"
4227 actual=${actual%% *}
4229 if [[ $actual -ne $expected ]]; then
4230 [[ $expected -eq -1 ]] ||
4231 error "$cmd wrong: found $actual, expected $expected"
4232 [[ $actual -eq $OSTCOUNT ]] ||
4233 error "$cmd wrong: found $actual, expected $OSTCOUNT"
4238 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4241 rm -rf $TDIR || error "remove $TDIR failed"
4242 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT"
4245 stripe_size=$($GETSTRIPE -S -d $TDIR) ||
4246 error "$GETSTRIPE -S -d $TDIR failed"
4247 stripe_size=${stripe_size%% *}
4249 local file_size=$((stripe_size * OSTCOUNT))
4250 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
4251 local required_space=$((file_num * file_size))
4252 local free_space=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
4253 [[ $free_space -le $((required_space / 1024)) ]] &&
4254 skip_env "need at least $required_space bytes free space," \
4255 "have $free_space kbytes" && return
4258 local dd_count=$((file_size / dd_bs))
4260 # write data into the files
4264 for i in $(seq 1 $NUMFILES); do
4266 yes | dd bs=$dd_bs count=$dd_count of=$file >/dev/null 2>&1 ||
4267 error "write data into $file failed"
4269 for i in $(seq 1 $NUMDIRS); do
4270 for j in $(seq 1 $NUMFILES); do
4271 file=$TDIR/dir$i/file$j
4272 yes | dd bs=$dd_bs count=$dd_count of=$file \
4274 error "write data into $file failed"
4279 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
4282 local cmd="$LFS_MIGRATE -y -c $expected $TDIR/file1"
4284 eval $cmd || error "$cmd failed"
4286 check_stripe_count $TDIR/file1 $expected
4289 cmd="$LFS_MIGRATE -y -c $expected $TDIR/dir1"
4291 eval $cmd || error "$cmd failed"
4293 for j in $(seq 1 $NUMFILES); do
4294 check_stripe_count $TDIR/dir1/file$j $expected
4297 # lfs_migrate works with lfs find
4298 cmd="$LFIND -stripe_count $OSTCOUNT -type f $TDIR |
4299 $LFS_MIGRATE -y -c $expected"
4301 eval $cmd || error "$cmd failed"
4303 for i in $(seq 2 $NUMFILES); do
4304 check_stripe_count $TDIR/file$i $expected
4306 for i in $(seq 2 $NUMDIRS); do
4307 for j in $(seq 1 $NUMFILES); do
4308 check_stripe_count $TDIR/dir$i/file$j $expected
4312 run_test 56w "check lfs_migrate -c stripe_count works"
4315 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4316 # note test will not do anything if MDS is not local
4317 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4318 skip "Only applicable to ldiskfs-based MDTs"
4322 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4323 local MNTDEV="osd*.*MDT*.mntdev"
4324 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
4325 [ -z "$DEV" ] && error "can't access $MNTDEV"
4326 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
4327 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
4328 error "can't access $DEV"
4329 DEVISIZE=`awk '/Inode size:/ { print $3 }' $TMP/t57a.dump`
4330 [ "$DEVISIZE" -gt 128 ] || error "inode size $DEVISIZE"
4334 run_test 57a "verify MDS filesystem created with large inodes =="
4337 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4338 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4339 skip "Only applicable to ldiskfs-based MDTs"
4343 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4348 local FILEN=$dir/f$FILECOUNT
4350 rm -rf $dir || error "removing $dir"
4351 test_mkdir -p $dir || error "creating $dir"
4352 local num=$(get_mds_dir $dir)
4355 echo "mcreating $FILECOUNT files"
4356 createmany -m $dir/f 1 $FILECOUNT || \
4357 error "creating files in $dir"
4359 # verify that files do not have EAs yet
4360 $GETSTRIPE $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
4361 $GETSTRIPE $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
4365 df $dir #make sure we get new statfs data
4366 local MDSFREE=$(do_facet $mymds \
4367 lctl get_param -n osd*.*MDT000$((num -1)).kbytesfree)
4368 local MDCFREE=$(lctl get_param -n mdc.*MDT000$((num -1))-mdc-*.kbytesfree)
4369 echo "opening files to create objects/EAs"
4371 for FILE in `seq -f $dir/f%g 1 $FILECOUNT`; do
4372 $OPENFILE -f O_RDWR $FILE > /dev/null 2>&1 || error "opening $FILE"
4375 # verify that files have EAs now
4376 $GETSTRIPE $FILE1 | grep -q "obdidx" || error "$FILE1 missing EA"
4377 $GETSTRIPE $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
4379 sleep 1 #make sure we get new statfs data
4381 local MDSFREE2=$(do_facet $mymds \
4382 lctl get_param -n osd*.*MDT000$((num -1)).kbytesfree)
4383 local MDCFREE2=$(lctl get_param -n mdc.*MDT000$((num -1))-mdc-*.kbytesfree)
4384 if [ "$MDCFREE2" -lt "$((MDCFREE - 8))" ]; then
4385 if [ "$MDSFREE" != "$MDSFREE2" ]; then
4386 error "MDC before $MDCFREE != after $MDCFREE2"
4388 echo "MDC before $MDCFREE != after $MDCFREE2"
4389 echo "unable to confirm if MDS has large inodes"
4394 run_test 57b "default LOV EAs are stored inside large inodes ==="
4397 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4398 [ -z "$(which wiretest 2>/dev/null)" ] &&
4399 skip_env "could not find wiretest" && return
4402 run_test 58 "verify cross-platform wire constants =============="
4405 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4406 echo "touch 130 files"
4407 createmany -o $DIR/f59- 130
4409 unlinkmany $DIR/f59- 130
4411 # wait for commitment of removal
4412 wait_delete_completed
4414 run_test 59 "verify cancellation of llog records async ========="
4416 TEST60_HEAD="test_60 run $RANDOM"
4418 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4419 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
4420 [ ! -f run-llog.sh ] && skip_env "missing subtest run-llog.sh" && return
4421 log "$TEST60_HEAD - from kernel mode"
4422 do_facet mgs sh run-llog.sh
4424 run_test 60a "llog sanity tests run from kernel module =========="
4426 test_60b() { # bug 6411
4427 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4429 LLOG_COUNT=`dmesg | awk "/$TEST60_HEAD/{marker = 1; from_marker = 0;}
4441 [ $LLOG_COUNT -gt 50 ] && error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)"|| true
4443 run_test 60b "limit repeated messages from CERROR/CWARN ========"
4446 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4447 echo "create 5000 files"
4448 createmany -o $DIR/f60c- 5000
4449 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
4450 lctl set_param fail_loc=0x80000137
4451 unlinkmany $DIR/f60c- 5000
4452 lctl set_param fail_loc=0
4454 run_test 60c "unlink file when mds full"
4457 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4458 SAVEPRINTK=$(lctl get_param -n printk)
4460 # verify "lctl mark" is even working"
4461 MESSAGE="test message ID $RANDOM $$"
4462 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
4463 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
4465 lctl set_param printk=0 || error "set lnet.printk failed"
4466 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
4467 MESSAGE="new test message ID $RANDOM $$"
4468 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
4469 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
4470 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
4472 lctl set_param -n printk="$SAVEPRINTK"
4474 run_test 60d "test printk console message masking"
4477 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4479 dd if=/dev/zero of=$f bs=`page_size` count=1
4480 cancel_lru_locks osc
4481 $MULTIOP $f OSMWUc || error
4484 run_test 61 "mmap() writes don't make sync hang ================"
4486 # bug 2330 - insufficient obd_match error checking causes LBUG
4488 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4491 cancel_lru_locks osc
4492 lctl set_param fail_loc=0x405
4493 cat $f && error "cat succeeded, expect -EIO"
4494 lctl set_param fail_loc=0
4496 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
4497 # match every page all of the time.
4498 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
4500 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
4501 test_63a() { # was test_63
4502 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4503 MAX_DIRTY_MB=`lctl get_param -n osc.*.max_dirty_mb | head -n 1`
4504 lctl set_param -n osc.*.max_dirty_mb 0
4505 for i in `seq 10` ; do
4506 dd if=/dev/zero of=$DIR/f63 bs=8k &
4512 lctl set_param -n osc.*.max_dirty_mb $MAX_DIRTY_MB
4513 rm -f $DIR/f63 || true
4515 run_test 63a "Verify oig_wait interruption does not crash ======="
4517 # bug 2248 - async write errors didn't return to application on sync
4518 # bug 3677 - async write errors left page locked
4520 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4522 lctl set_param debug=-1
4524 # ensure we have a grant to do async writes
4525 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
4528 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
4529 lctl set_param fail_loc=0x80000406
4530 $MULTIOP $DIR/$tfile Owy && \
4531 error "sync didn't return ENOMEM"
4532 sync; sleep 2; sync # do a real sync this time to flush page
4533 lctl get_param -n llite.*.dump_page_cache | grep locked && \
4534 error "locked page left in cache after async error" || true
4537 run_test 63b "async write errors should be returned to fsync ==="
4540 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4542 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
4544 run_test 64a "verify filter grant calculations (in kernel) ====="
4547 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4548 [ ! -f oos.sh ] && skip_env "missing subtest oos.sh" && return
4551 run_test 64b "check out-of-space detection on client ==========="
4554 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
4556 run_test 64c "verify grant shrink ========================------"
4558 # bug 1414 - set/get directories' stripe info
4560 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4561 test_mkdir -p $DIR/$tdir
4563 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
4565 run_test 65a "directory with no stripe info ===================="
4568 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4569 test_mkdir -p $DIR/$tdir
4570 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
4573 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
4575 run_test 65b "directory setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1"
4578 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4579 if [ $OSTCOUNT -gt 1 ]; then
4580 test_mkdir -p $DIR/$tdir
4581 $SETSTRIPE -S $(($STRIPESIZE * 4)) -i 1 \
4582 -c $(($OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
4584 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
4587 run_test 65c "directory setstripe -S $((STRIPESIZE*4)) -i 1 -c $((OSTCOUNT-1))"
4590 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4591 test_mkdir -p $DIR/$tdir
4592 if [ $STRIPECOUNT -le 0 ]; then
4594 elif [ $STRIPECOUNT -gt 2000 ]; then
4595 #LOV_MAX_STRIPE_COUNT is 2000
4596 [ $OSTCOUNT -gt 2000 ] && sc=2000 || sc=$(($OSTCOUNT - 1))
4598 sc=$(($STRIPECOUNT - 1))
4600 $SETSTRIPE -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
4601 touch $DIR/$tdir/f4 $DIR/$tdir/f5
4602 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
4603 error "lverify failed"
4605 run_test 65d "directory setstripe -S $STRIPESIZE -c stripe_count"
4608 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4609 test_mkdir -p $DIR/$tdir
4611 $SETSTRIPE $DIR/$tdir || error "setstripe"
4612 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
4613 error "no stripe info failed"
4615 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
4617 run_test 65e "directory setstripe defaults ======================="
4620 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4621 test_mkdir -p $DIR/${tdir}f
4622 $RUNAS $SETSTRIPE $DIR/${tdir}f && error "setstripe succeeded" || true
4624 run_test 65f "dir setstripe permission (should return error) ==="
4627 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4628 test_mkdir -p $DIR/$tdir
4629 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
4631 $SETSTRIPE -d $DIR/$tdir || error "setstripe"
4632 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
4633 error "delete default stripe failed"
4635 run_test 65g "directory setstripe -d ==========================="
4638 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4639 test_mkdir -p $DIR/$tdir
4640 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
4642 test_mkdir -p $DIR/$tdir/dd1
4643 [ $($GETSTRIPE -c $DIR/$tdir) == $($GETSTRIPE -c $DIR/$tdir/dd1) ] ||
4644 error "stripe info inherit failed"
4646 run_test 65h "directory stripe info inherit ===================="
4648 test_65i() { # bug6367
4649 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4650 $SETSTRIPE -S 65536 -c -1 $MOUNT
4652 run_test 65i "set non-default striping on root directory (bug 6367)="
4654 test_65ia() { # bug12836
4655 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4656 $GETSTRIPE $MOUNT || error "getstripe $MOUNT failed"
4658 run_test 65ia "getstripe on -1 default directory striping"
4660 test_65ib() { # bug12836
4661 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4662 $GETSTRIPE -v $MOUNT || error "getstripe -v $MOUNT failed"
4664 run_test 65ib "getstripe -v on -1 default directory striping"
4666 test_65ic() { # bug12836
4667 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4668 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
4670 run_test 65ic "new find on -1 default directory striping"
4672 test_65j() { # bug6367
4673 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4675 # if we aren't already remounting for each test, do so for this test
4676 if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
4677 cleanup || error "failed to unmount"
4680 $SETSTRIPE -d $MOUNT || error "setstripe failed"
4682 run_test 65j "set default striping on root directory (bug 6367)="
4684 test_65k() { # bug11679
4685 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4686 [ "$OSTCOUNT" -lt 2 ] && skip_env "too few OSTs" && return
4687 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4689 echo "Check OST status: "
4690 local MDS_OSCS=`do_facet $SINGLEMDS lctl dl |
4691 awk '/[oO][sS][cC].*md[ts]/ { print $4 }'`
4693 for OSC in $MDS_OSCS; do
4694 echo $OSC "is activate"
4695 do_facet $SINGLEMDS lctl --device %$OSC activate
4699 for INACTIVE_OSC in $MDS_OSCS; do
4700 echo "Deactivate: " $INACTIVE_OSC
4701 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
4702 for STRIPE_OSC in $MDS_OSCS; do
4703 OST=`osc_to_ost $STRIPE_OSC`
4704 IDX=`do_facet $SINGLEMDS lctl get_param -n lov.*md*.target_obd |
4705 awk -F: /$OST/'{ print $1 }' | head -n 1`
4707 [ -f $DIR/$tdir/$IDX ] && continue
4708 echo "$SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX"
4709 $SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX
4711 [ $RC -ne 0 ] && error "setstripe should have succeeded"
4714 echo $INACTIVE_OSC "is Activate."
4715 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
4718 run_test 65k "validate manual striping works properly with deactivated OSCs"
4720 test_65l() { # bug 12836
4721 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4722 test_mkdir -p $DIR/$tdir/test_dir
4723 $SETSTRIPE -c -1 $DIR/$tdir/test_dir
4724 $LFS find -mtime -1 $DIR/$tdir >/dev/null
4726 run_test 65l "lfs find on -1 stripe dir ========================"
4728 # bug 2543 - update blocks count on client
4730 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4732 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
4733 sync; sync_all_data; sync; sync_all_data
4734 cancel_lru_locks osc
4735 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
4736 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
4738 run_test 66 "update inode blocks count on client ==============="
4743 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4745 if [ ! -z "$LLOOP" ]; then
4746 if swapon -s | grep -q $LLOOP; then
4747 swapoff $LLOOP || error "swapoff failed"
4750 $LCTL blockdev_detach $LLOOP || error "detach failed"
4754 if [ ! -z "$LLITELOOPLOAD" ]; then
4762 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
4766 swapon -s | awk '($1 == "'$1'") { print $4 }'
4769 # test case for lloop driver, basic function
4771 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4772 [ "$UID" != 0 ] && skip_env "must run as root" && return
4773 llite_lloop_enabled || \
4774 { skip_env "llite_lloop module disabled" && return; }
4776 trap cleanup_68 EXIT
4778 if ! module_loaded llite_lloop; then
4779 if load_module llite/llite_lloop; then
4782 skip_env "can't find module llite_lloop"
4787 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
4788 dd if=/dev/zero of=$DIR/f68a bs=4k count=1024
4789 $LCTL blockdev_attach $DIR/f68a $LLOOP || error "attach failed"
4791 directio rdwr $LLOOP 0 1024 4096 || error "direct write failed"
4792 directio rdwr $LLOOP 0 1025 4096 && error "direct write should fail"
4796 run_test 68a "lloop driver - basic test ========================"
4798 # excercise swapping to lustre by adding a high priority swapfile entry
4799 # and then consuming memory until it is used.
4800 test_68b() { # was test_68
4801 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4802 [ "$UID" != 0 ] && skip_env "must run as root" && return
4803 lctl get_param -n devices | grep -q obdfilter && \
4804 skip "local OST" && return
4806 grep -q llite_lloop /proc/modules
4807 [ $? -ne 0 ] && skip "can't find module llite_lloop" && return
4809 [ -z "`$LCTL list_nids | grep -v tcp`" ] && \
4810 skip "can't reliably test swap with TCP" && return
4812 MEMTOTAL=`meminfo MemTotal`
4813 NR_BLOCKS=$((MEMTOTAL>>8))
4814 [[ $NR_BLOCKS -le 2048 ]] && NR_BLOCKS=2048
4816 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
4817 dd if=/dev/zero of=$DIR/f68b bs=64k seek=$NR_BLOCKS count=1
4820 $LCTL blockdev_attach $DIR/f68b $LLOOP || error "attach failed"
4822 trap cleanup_68 EXIT
4824 swapon -p 32767 $LLOOP || error "swapon $LLOOP failed"
4826 echo "before: `swapon -s | grep $LLOOP`"
4827 $MEMHOG $MEMTOTAL || error "error allocating $MEMTOTAL kB"
4828 echo "after: `swapon -s | grep $LLOOP`"
4829 SWAPUSED=`swap_used $LLOOP`
4833 [ $SWAPUSED -eq 0 ] && echo "no swap used???" || true
4835 run_test 68b "support swapping to Lustre ========================"
4837 # bug5265, obdfilter oa2dentry return -ENOENT
4838 # #define OBD_FAIL_OST_ENOENT 0x217
4840 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4841 remote_ost_nodsh && skip "remote OST with nodsh" && return
4844 $SETSTRIPE -c 1 -i 0 $f
4846 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
4848 do_facet ost1 lctl set_param fail_loc=0x217
4849 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
4850 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
4852 do_facet ost1 lctl set_param fail_loc=0
4853 $DIRECTIO write $f 0 2 || error "write error"
4855 cancel_lru_locks osc
4856 $DIRECTIO read $f 0 1 || error "read error"
4858 do_facet ost1 lctl set_param fail_loc=0x217
4859 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
4861 do_facet ost1 lctl set_param fail_loc=0
4864 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
4867 test_mkdir -p $DIR/$tdir
4868 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
4870 run_test 71 "Running dbench on lustre (don't segment fault) ===="
4872 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
4873 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4874 check_kernel_version 43 || return 0
4875 [ "$RUNAS_ID" = "$UID" ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4877 # Check that testing environment is properly set up. Skip if not
4878 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS || {
4879 skip_env "User $RUNAS_ID does not exist - skipping"
4882 # We had better clear the $DIR to get enough space for dd
4887 $RUNAS dd if=/dev/zero of=$DIR/f72 bs=512 count=1 || error
4888 # See if we are still setuid/sgid
4889 test -u $DIR/f72 -o -g $DIR/f72 && error "S/gid is not dropped on write"
4890 # Now test that MDS is updated too
4891 cancel_lru_locks mdc
4892 test -u $DIR/f72 -o -g $DIR/f72 && error "S/gid is not dropped on MDS"
4895 run_test 72a "Test that remove suid works properly (bug5695) ===="
4897 test_72b() { # bug 24226 -- keep mode setting when size is not changing
4900 [ "$RUNAS_ID" = "$UID" ] && \
4901 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4902 [ "$RUNAS_ID" -eq 0 ] && \
4903 skip_env "RUNAS_ID = 0 -- skipping" && return
4905 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4906 # Check that testing environment is properly set up. Skip if not
4907 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS || {
4908 skip_env "User $RUNAS_ID does not exist - skipping"
4911 touch $DIR/${tfile}-f{g,u}
4912 test_mkdir $DIR/${tfile}-dg
4913 test_mkdir $DIR/${tfile}-du
4914 chmod 770 $DIR/${tfile}-{f,d}{g,u}
4915 chmod g+s $DIR/${tfile}-{f,d}g
4916 chmod u+s $DIR/${tfile}-{f,d}u
4917 for perm in 777 2777 4777; do
4918 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
4919 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
4920 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
4921 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
4925 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
4927 # bug 3462 - multiple simultaneous MDC requests
4929 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4930 test_mkdir $DIR/d73-1
4931 test_mkdir $DIR/d73-2
4932 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
4935 lctl set_param fail_loc=0x80000129
4936 $MULTIOP $DIR/d73-1/f73-2 Oc &
4938 lctl set_param fail_loc=0
4940 $MULTIOP $DIR/d73-2/f73-3 Oc &
4944 wait $pid1 || return 1
4948 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
4949 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
4950 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
4954 run_test 73 "multiple MDC requests (should not deadlock)"
4956 test_74a() { # bug 6149, 6184
4957 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4958 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
4960 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
4961 # will spin in a tight reconnection loop
4963 lctl set_param fail_loc=0x8000030e
4964 # get any lock that won't be difficult - lookup works.
4966 lctl set_param fail_loc=0
4970 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
4972 test_74b() { # bug 13310
4973 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4974 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
4976 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
4977 # will spin in a tight reconnection loop
4978 lctl set_param fail_loc=0x8000030e
4979 # get a "difficult" lock
4981 lctl set_param fail_loc=0
4985 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
4988 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4989 #define OBD_FAIL_LDLM_NEW_LOCK
4990 lctl set_param fail_loc=0x80000319
4991 touch $DIR/$tfile && error "Touch successful"
4994 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
4997 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
5000 get_inode_slab_tunables() {
5001 awk '/lustre_inode_cache/ {print $9," ",$10," ",$11; exit}' /proc/slabinfo
5004 set_inode_slab_tunables() {
5005 echo "lustre_inode_cache $1" > /proc/slabinfo
5008 test_76() { # Now for bug 20433, added originally in bug 1443
5009 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5010 local SLAB_SETTINGS=`get_inode_slab_tunables`
5011 local CPUS=`getconf _NPROCESSORS_ONLN`
5012 # we cannot set limit below 1 which means 1 inode in each
5013 # per-cpu cache is still allowed
5014 set_inode_slab_tunables "1 1 0"
5015 cancel_lru_locks osc
5016 BEFORE_INODES=`num_inodes`
5017 echo "before inodes: $BEFORE_INODES"
5019 [ "$SLOW" = "no" ] && COUNT=100
5020 for i in `seq $COUNT`; do
5024 cancel_lru_locks osc
5025 AFTER_INODES=`num_inodes`
5026 echo "after inodes: $AFTER_INODES"
5028 while [ $((AFTER_INODES-1*CPUS)) -gt $BEFORE_INODES ]; do
5030 AFTER_INODES=`num_inodes`
5032 echo "wait $wait seconds inodes: $AFTER_INODES"
5033 if [ $wait -gt 30 ]; then
5034 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
5037 set_inode_slab_tunables "$SLAB_SETTINGS"
5039 run_test 76 "confirm clients recycle inodes properly ===="
5045 # Note: in sptlrpc modes which enable its own bulk checksum, the
5046 # original crc32_le bulk checksum will be automatically disabled,
5047 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
5048 # will be checked by sptlrpc code against sptlrpc bulk checksum.
5049 # In this case set_checksums() will not be no-op, because sptlrpc
5050 # bulk checksum will be enabled all through the test.
5052 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
5053 lctl set_param -n osc.*.checksums $1
5057 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
5058 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
5059 CKSUM_TYPES=${CKSUM_TYPES:-"crc32 adler"}
5060 [ "$ORIG_CSUM_TYPE" = "crc32c" ] && CKSUM_TYPES="$CKSUM_TYPES crc32c"
5063 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
5064 log "set checksum type to $1"
5067 F77_TMP=$TMP/f77-temp
5070 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
5071 error "error writing to $F77_TMP"
5074 test_77a() { # bug 10889
5075 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5076 $GSS && skip "could not run with gss" && return
5077 [ ! -f $F77_TMP ] && setup_f77
5079 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
5083 run_test 77a "normal checksum read/write operation ============="
5085 test_77b() { # bug 10889
5086 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5087 $GSS && skip "could not run with gss" && return
5088 [ ! -f $F77_TMP ] && setup_f77
5089 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5090 lctl set_param fail_loc=0x80000409
5092 dd if=$F77_TMP of=$DIR/f77b bs=1M count=$F77SZ conv=sync || \
5093 error "dd error: $?"
5094 lctl set_param fail_loc=0
5097 run_test 77b "checksum error on client write ===================="
5099 test_77c() { # bug 10889
5100 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5101 $GSS && skip "could not run with gss" && return
5102 [ ! -f $DIR/f77b ] && skip "requires 77b - skipping" && return
5104 for algo in $CKSUM_TYPES; do
5105 cancel_lru_locks osc
5106 set_checksum_type $algo
5107 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
5108 lctl set_param fail_loc=0x80000408
5109 cmp $F77_TMP $DIR/f77b || error "file compare failed"
5110 lctl set_param fail_loc=0
5113 set_checksum_type $ORIG_CSUM_TYPE
5116 run_test 77c "checksum error on client read ==================="
5118 test_77d() { # bug 10889
5119 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5120 $GSS && skip "could not run with gss" && return
5121 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5122 lctl set_param fail_loc=0x80000409
5124 directio write $DIR/f77 0 $F77SZ $((1024 * 1024)) || \
5125 error "direct write: rc=$?"
5126 lctl set_param fail_loc=0
5129 run_test 77d "checksum error on OST direct write ==============="
5131 test_77e() { # bug 10889
5132 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5133 $GSS && skip "could not run with gss" && return
5134 [ ! -f $DIR/f77 ] && skip "requires 77d - skipping" && return
5135 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
5136 lctl set_param fail_loc=0x80000408
5138 cancel_lru_locks osc
5139 directio read $DIR/f77 0 $F77SZ $((1024 * 1024)) || \
5140 error "direct read: rc=$?"
5141 lctl set_param fail_loc=0
5144 run_test 77e "checksum error on OST direct read ================"
5146 test_77f() { # bug 10889
5147 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5148 $GSS && skip "could not run with gss" && return
5150 for algo in $CKSUM_TYPES; do
5151 cancel_lru_locks osc
5152 set_checksum_type $algo
5153 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5154 lctl set_param fail_loc=0x409
5155 directio write $DIR/f77 0 $F77SZ $((1024 * 1024)) && \
5156 error "direct write succeeded"
5157 lctl set_param fail_loc=0
5159 set_checksum_type $ORIG_CSUM_TYPE
5162 run_test 77f "repeat checksum error on write (expect error) ===="
5164 test_77g() { # bug 10889
5165 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5166 $GSS && skip "could not run with gss" && return
5167 remote_ost_nodsh && skip "remote OST with nodsh" && return
5169 [ ! -f $F77_TMP ] && setup_f77
5171 $SETSTRIPE -c 1 -i 0 $DIR/f77g
5172 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
5173 do_facet ost1 lctl set_param fail_loc=0x8000021a
5175 dd if=$F77_TMP of=$DIR/f77g bs=1M count=$F77SZ || \
5176 error "write error: rc=$?"
5177 do_facet ost1 lctl set_param fail_loc=0
5180 run_test 77g "checksum error on OST write ======================"
5182 test_77h() { # bug 10889
5183 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5184 $GSS && skip "could not run with gss" && return
5185 remote_ost_nodsh && skip "remote OST with nodsh" && return
5187 [ ! -f $DIR/f77g ] && skip "requires 77g - skipping" && return
5188 cancel_lru_locks osc
5189 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
5190 do_facet ost1 lctl set_param fail_loc=0x8000021b
5192 cmp $F77_TMP $DIR/f77g || error "file compare failed"
5193 do_facet ost1 lctl set_param fail_loc=0
5196 run_test 77h "checksum error on OST read ======================="
5198 test_77i() { # bug 13805
5199 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5200 $GSS && skip "could not run with gss" && return
5201 #define OBD_FAIL_OSC_CONNECT_CKSUM 0x40b
5202 lctl set_param fail_loc=0x40b
5203 remount_client $MOUNT
5204 lctl set_param fail_loc=0
5205 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
5206 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
5207 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
5208 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
5210 remount_client $MOUNT
5212 run_test 77i "client not supporting OSD_CONNECT_CKSUM =========="
5214 test_77j() { # bug 13805
5215 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5216 $GSS && skip "could not run with gss" && return
5217 #define OBD_FAIL_OSC_CKSUM_ADLER_ONLY 0x40c
5218 lctl set_param fail_loc=0x40c
5219 remount_client $MOUNT
5220 lctl set_param fail_loc=0
5221 sleep 2 # wait async osc connect to finish
5222 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
5223 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
5224 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
5225 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
5227 remount_client $MOUNT
5229 run_test 77j "client only supporting ADLER32 ===================="
5231 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
5235 test_78() { # bug 10901
5236 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5237 remote_ost || { skip_env "local OST" && return; }
5240 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
5241 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
5242 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
5243 echo "MemTotal: $MEMTOTAL"
5244 # reserve 256MB of memory for the kernel and other running processes,
5245 # and then take 1/2 of the remaining memory for the read/write buffers.
5246 if [ $MEMTOTAL -gt 512 ] ;then
5247 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
5249 # for those poor memory-starved high-end clusters...
5250 MEMTOTAL=$((MEMTOTAL / 2))
5252 echo "Mem to use for directio: $MEMTOTAL"
5253 [ $F78SIZE -gt $MEMTOTAL ] && F78SIZE=$MEMTOTAL
5254 [ $F78SIZE -gt 512 ] && F78SIZE=512
5255 [ $F78SIZE -gt $((MAXFREE / 1024)) ] && F78SIZE=$((MAXFREE / 1024))
5256 SMALLESTOST=`lfs df $DIR |grep OST | awk '{print $4}' |sort -n |head -1`
5257 echo "Smallest OST: $SMALLESTOST"
5258 [ $SMALLESTOST -lt 10240 ] && \
5259 skip "too small OSTSIZE, useless to run large O_DIRECT test" && return 0
5261 [ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ] && \
5262 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
5264 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
5265 echo "File size: $F78SIZE"
5266 $SETSTRIPE -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
5267 for i in `seq 1 $NSEQ`
5269 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
5270 echo directIO rdwr round $i of $NSEQ
5271 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
5276 run_test 78 "handle large O_DIRECT writes correctly ============"
5278 test_79() { # bug 12743
5279 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5280 wait_delete_completed
5282 BKTOTAL=$(calc_osc_kbytes kbytestotal)
5283 BKFREE=$(calc_osc_kbytes kbytesfree)
5284 BKAVAIL=$(calc_osc_kbytes kbytesavail)
5286 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
5287 DFTOTAL=`echo $STRING | cut -d, -f1`
5288 DFUSED=`echo $STRING | cut -d, -f2`
5289 DFAVAIL=`echo $STRING | cut -d, -f3`
5290 DFFREE=$(($DFTOTAL - $DFUSED))
5292 ALLOWANCE=$((64 * $OSTCOUNT))
5294 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
5295 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
5296 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
5298 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
5299 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
5300 error "df free($DFFREE) mismatch OST free($BKFREE)"
5302 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
5303 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
5304 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
5307 run_test 79 "df report consistency check ======================="
5309 test_80() { # bug 10718
5310 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5311 # relax strong synchronous semantics for slow backends like ZFS
5312 local soc="obdfilter.*.sync_on_lock_cancel"
5313 local soc_old=$(do_facet ost1 lctl get_param -n $soc | head -n1)
5315 if [ "$soc_old" != "never" -a "$(facet_fstype ost1)" != "ldiskfs" ]; then
5316 hosts=$(for host in $(seq -f "ost%g" 1 $OSTCOUNT); do
5317 facet_active_host $host; done | sort -u)
5318 do_nodes $hosts lctl set_param $soc=never
5321 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
5323 local BEFORE=`date +%s`
5324 cancel_lru_locks osc
5325 local AFTER=`date +%s`
5326 local DIFF=$((AFTER-BEFORE))
5327 if [ $DIFF -gt 1 ] ; then
5328 error "elapsed for 1M@1T = $DIFF"
5331 [ -n "$hosts" ] && do_nodes $hosts lctl set_param $soc=$soc_old
5335 run_test 80 "Page eviction is equally fast at high offsets too ===="
5337 test_81a() { # LU-456
5338 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5339 remote_ost_nodsh && skip "remote OST with nodsh" && return
5340 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
5341 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
5342 do_facet ost1 lctl set_param fail_loc=0x80000228
5344 # write should trigger a retry and success
5345 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
5346 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
5348 if [ $RC -ne 0 ] ; then
5349 error "write should success, but failed for $RC"
5352 run_test 81a "OST should retry write when get -ENOSPC ==============="
5354 test_81b() { # LU-456
5355 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5356 remote_ost_nodsh && skip "remote OST with nodsh" && return
5357 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
5358 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
5359 do_facet ost1 lctl set_param fail_loc=0x228
5361 # write should retry several times and return -ENOSPC finally
5362 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
5363 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
5366 if [ $RC -ne $ENOSPC ] ; then
5367 error "dd should fail for -ENOSPC, but succeed."
5370 run_test 81b "OST should return -ENOSPC when retry still fails ======="
5372 test_82() { # LU-1031
5373 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10
5377 multiop_bg_pause $DIR/$tfile OG${gid1}_g${gid1}c || return 1
5379 multiop_bg_pause $DIR/$tfile O_G${gid2}r10g${gid2}c || return 2
5381 kill -USR1 $MULTIPID2
5383 if [[ `ps h -o comm -p $MULTIPID2` == "" ]]; then
5384 error "First grouplock does not block second one"
5386 echo "Second grouplock blocks first one"
5388 kill -USR1 $MULTIPID1
5392 run_test 82 "Basic grouplock test ==============================="
5395 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && \
5397 test_mkdir -p $DIR/d99cvsroot
5398 chown $RUNAS_ID $DIR/d99cvsroot
5399 local oldPWD=$PWD # bug 13584, use $TMP as working dir
5402 $RUNAS cvs -d $DIR/d99cvsroot init || error
5405 run_test 99a "cvs init ========================================="
5408 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5409 [ ! -d $DIR/d99cvsroot ] && test_99a
5411 # some versions of cvs import exit(1) when asked to import links or
5412 # files they can't read. ignore those files.
5413 TOIGNORE=$(find . -type l -printf '-I %f\n' -o \
5414 ! -perm +4 -printf '-I %f\n')
5415 $RUNAS cvs -d $DIR/d99cvsroot import -m "nomesg" $TOIGNORE \
5416 d99reposname vtag rtag
5418 run_test 99b "cvs import ======================================="
5421 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5422 [ ! -d $DIR/d99cvsroot ] && test_99b
5424 test_mkdir -p $DIR/d99reposname
5425 chown $RUNAS_ID $DIR/d99reposname
5426 $RUNAS cvs -d $DIR/d99cvsroot co d99reposname
5428 run_test 99c "cvs checkout ====================================="
5431 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5432 [ ! -d $DIR/d99cvsroot ] && test_99c
5433 cd $DIR/d99reposname
5435 $RUNAS cvs add -m 'addmsg' foo99
5437 run_test 99d "cvs add =========================================="
5440 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5441 [ ! -d $DIR/d99cvsroot ] && test_99c
5442 cd $DIR/d99reposname
5445 run_test 99e "cvs update ======================================="
5448 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5449 [ ! -d $DIR/d99cvsroot ] && test_99d
5450 cd $DIR/d99reposname
5451 $RUNAS cvs commit -m 'nomsg' foo99
5452 rm -fr $DIR/d99cvsroot
5454 run_test 99f "cvs commit ======================================="
5457 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5458 [ "$NETTYPE" = tcp ] || \
5459 { skip "TCP secure port test, not useful for NETTYPE=$NETTYPE" && \
5462 remote_ost_nodsh && skip "remote OST with nodsh" && return
5463 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5465 { skip "useless for local single node setup" && return; }
5467 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
5468 [ "$PROT" != "tcp" ] && continue
5469 RPORT=$(echo $REMOTE | cut -d: -f2)
5470 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
5473 LPORT=`echo $LOCAL | cut -d: -f2`
5474 if [ $LPORT -ge 1024 ]; then
5475 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
5477 error_exit "local: $LPORT > 1024, remote: $RPORT"
5480 [ "$rc" = 0 ] || error_exit "privileged port not found" )
5482 run_test 100 "check local port using privileged port ==========="
5484 function get_named_value()
5493 echo $line | sed "s/^$tag[ ]*//"
5500 export CACHE_MAX=`$LCTL get_param -n llite.*.max_cached_mb | head -n 1`
5502 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
5507 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5511 [ "$CPU" = "UML" ] && nreads=1000
5512 local cache_limit=32
5514 $LCTL set_param -n osc.*-osc*.rpc_stats 0
5515 trap cleanup_101a EXIT
5516 $LCTL set_param -n llite.*.read_ahead_stats 0
5517 $LCTL set_param -n llite.*.max_cached_mb $cache_limit
5520 # randomly read 10000 of 64K chunks from file 3x 32MB in size
5522 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
5523 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
5526 for s in `$LCTL get_param -n llite.*.read_ahead_stats | \
5527 get_named_value 'read but discarded' | cut -d" " -f1`; do
5528 discard=$(($discard + $s))
5532 if [ $(($discard * 10)) -gt $nreads ] ;then
5533 $LCTL get_param osc.*-osc*.rpc_stats
5534 $LCTL get_param llite.*.read_ahead_stats
5535 error "too many ($discard) discarded pages"
5537 rm -f $DIR/$tfile || true
5539 run_test 101a "check read-ahead for random reads ================"
5542 test_mkdir -p $DIR/$tdir
5544 STRIPE_COUNT=$OSTCOUNT
5547 local list=$(comma_list $(osts_nodes))
5548 set_osd_param $list '' read_cache_enable 0
5549 set_osd_param $list '' writethrough_cache_enable 0
5551 trap cleanup_test101bc EXIT
5552 # prepare the read-ahead file
5553 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
5555 dd if=/dev/zero of=$DIR/$tfile bs=1024k count=100 2> /dev/null
5558 cleanup_test101bc() {
5563 local list=$(comma_list $(osts_nodes))
5564 set_osd_param $list '' read_cache_enable 1
5565 set_osd_param $list '' writethrough_cache_enable 1
5569 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
5574 local STRIPE_SIZE=1048576
5575 local RA_INC=1048576
5576 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
5577 local FILE_LENGTH=$((64*100))
5578 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
5579 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
5580 DISCARD=`$LCTL get_param -n llite.*.read_ahead_stats | \
5581 get_named_value 'read but discarded' | \
5582 cut -d" " -f1 | calc_total`
5583 if [ $DISCARD -gt $discard_limit ]; then
5584 $LCTL get_param llite.*.read_ahead_stats
5585 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
5587 echo "Read-ahead success for size ${READ_SIZE}"
5592 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5593 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping stride IO stride-ahead test" && return
5594 local STRIPE_SIZE=1048576
5595 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
5596 local FILE_LENGTH=$((STRIPE_SIZE*100))
5597 local ITERATION=$((FILE_LENGTH/STRIDE_SIZE))
5598 # prepare the read-ahead file
5600 cancel_lru_locks osc
5601 for BIDX in 2 4 8 16 32 64 128 256
5603 local BSIZE=$((BIDX*4096))
5604 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
5605 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
5606 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
5607 $LCTL set_param -n llite.*.read_ahead_stats 0
5608 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
5609 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
5610 cancel_lru_locks osc
5616 run_test 101b "check stride-io mode read-ahead ================="
5619 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5620 local STRIPE_SIZE=1048576
5621 local FILE_LENGTH=$((STRIPE_SIZE*100))
5627 cancel_lru_locks osc
5628 $LCTL set_param osc.*.rpc_stats 0
5629 $READS -f $DIR/$tfile -s$FILE_LENGTH -b65536 -n$nreads -t 180
5630 for osc in $($LCTL get_param -N osc.*); do
5631 if [ "$osc" == "osc.num_refs" ]; then
5635 local lines=$($LCTL get_param -n ${osc}.rpc_stats | wc | awk '{print $1}')
5636 if [ $lines -le 20 ]; then
5640 local rpc4k=$($LCTL get_param -n ${osc}.rpc_stats |
5641 awk '$1 == "1:" { print $2; exit; }')
5642 local rpc8k=$($LCTL get_param -n ${osc}.rpc_stats |
5643 awk '$1 == "2:" { print $2; exit; }')
5644 local rpc16k=$($LCTL get_param -n ${osc}.rpc_stats |
5645 awk '$1 == "4:" { print $2; exit; }')
5646 local rpc32k=$($LCTL get_param -n ${osc}.rpc_stats |
5647 awk '$1 == "8:" { print $2; exit; }')
5649 [ $rpc4k != 0 ] && error "Small 4k read IO ${rpc4k}!"
5650 [ $rpc8k != 0 ] && error "Small 8k read IO ${rpc8k}!"
5651 [ $rpc16k != 0 ] && error "Small 16k read IO ${rpc16k}!"
5652 [ $rpc32k != 0 ] && error "Small 32k read IO ${rpc32k}!"
5653 echo "${osc} rpc check passed!"
5658 run_test 101c "check stripe_size aligned read-ahead ================="
5661 $LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1
5662 $LCTL set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
5666 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5667 local file=$DIR/$tfile
5668 local size=${FILESIZE_101c:-500}
5669 local ra_MB=${READAHEAD_MB:-40}
5671 local space=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
5672 [ $space -gt $((size * 1024)) ] ||
5673 { skip "Need free space ${size}M, have $space" && return; }
5675 echo Creating ${size}M test file $file
5676 dd if=/dev/zero of=$file bs=1M count=$size || error "dd failed"
5677 echo Cancel LRU locks on lustre client to flush the client cache
5678 cancel_lru_locks osc
5680 echo Disable read-ahead
5681 local old_READAHEAD=$(set_read_ahead 0)
5683 echo Reading the test file $file with read-ahead disabled
5684 time_ra_OFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$size")
5686 echo Cancel LRU locks on lustre client to flush the client cache
5687 cancel_lru_locks osc
5688 echo Enable read-ahead with ${ra_MB}MB
5689 set_read_ahead $ra_MB
5691 echo Reading the test file $file with read-ahead enabled
5692 time_ra_ON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$size")
5694 echo read-ahead disabled time read $time_ra_OFF
5695 echo read-ahead enabled time read $time_ra_ON
5697 set_read_ahead $old_READAHEAD
5699 wait_delete_completed
5701 [ $time_ra_ON -lt $time_ra_OFF ] ||
5702 error "read-ahead enabled time read (${time_ra_ON}s) is more than
5703 read-ahead disabled time read (${time_ra_OFF}s) filesize ${size}M"
5705 run_test 101d "file read with and without read-ahead enabled ================="
5708 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5709 local file=$DIR/$tfile
5714 local space=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
5715 local need_space=$((count * size))
5716 [ $space -gt $need_space ] ||
5717 { skip_env "Need free space $need_space, have $space" && return; }
5719 echo Creating $count ${size}K test files
5720 for ((i = 0; i < $count; i++)); do
5721 dd if=/dev/zero of=${file}_${i} bs=$blksize count=$size 2>/dev/null
5724 echo Cancel LRU locks on lustre client to flush the client cache
5725 cancel_lru_locks osc
5727 echo Reset readahead stats
5728 $LCTL set_param -n llite.*.read_ahead_stats 0
5730 for ((i = 0; i < $count; i++)); do
5731 dd if=${file}_${i} of=/dev/null bs=$blksize count=$size 2>/dev/null
5734 local miss=$($LCTL get_param -n llite.*.read_ahead_stats | \
5735 get_named_value 'misses' | cut -d" " -f1 | calc_total)
5737 for ((i = 0; i < $count; i++)); do
5738 rm -rf ${file}_${i} 2>/dev/null
5741 #10000 means 20% reads are missing in readahead
5742 [ $miss -lt 10000 ] || error "misses too much for small reads"
5744 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
5746 cleanup_test101f() {
5748 $LCTL set_param -n llite.*.max_read_ahead_whole_mb $MAX_WHOLE_MB
5749 rm -rf $DIR/$tfile 2>/dev/null
5753 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5754 local file=$DIR/$tfile
5757 MAX_WHOLE_MB=$($LCTL get_param -n llite.*.max_read_ahead_whole_mb)
5758 $LCTL set_param -n llite.*.max_read_ahead_whole_mb 2
5759 dd if=/dev/zero of=${file} bs=2097152 count=1 2>/dev/null
5760 trap cleanup_test101f EXIT
5762 echo Cancel LRU locks on lustre client to flush the client cache
5763 cancel_lru_locks osc
5765 echo Reset readahead stats
5766 $LCTL set_param -n llite.*.read_ahead_stats 0
5767 # Random read in a 2M file, because max_read_ahead_whole_mb = 2M,
5768 # readahead should read in 2M file on second read, so only miss
5770 echo Random 4K reads on 2M file for 1000 times
5771 $READS -f $file -s 2097152 -b 4096 -n $nreads
5773 echo checking missing pages
5774 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
5775 get_named_value 'misses' | cut -d" " -f1 | calc_total)
5777 [ $miss -lt 3 ] || error "misses too much pages!"
5780 run_test 101f "check read-ahead for max_read_ahead_whole_mb"
5783 test_mkdir -p $DIR/$tdir
5784 chown $RUNAS_ID $DIR/$tdir
5787 STRIPE_COUNT=$OSTCOUNT
5788 [ $OSTCOUNT -gt 4 ] && STRIPE_COUNT=4
5790 trap cleanup_test102 EXIT
5792 $1 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
5794 for num in 1 2 3 4; do
5795 for count in $(seq 1 $STRIPE_COUNT); do
5796 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
5797 local size=`expr $STRIPE_SIZE \* $num`
5798 local file=file"$num-$idx-$count"
5799 $1 $SETSTRIPE -S $size -i $idx -c $count $file
5805 $1 $TAR cf $TMP/f102.tar $tdir --xattrs
5811 rm -rf $DIR/d0.sanity/d102
5815 local testfile=$DIR/xattr_testfile
5819 [ "$UID" != 0 ] && skip_env "must run as root" && return
5820 [ -z "`lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr`" ] &&
5821 skip_env "must have user_xattr" && return
5823 [ -z "$(which setfattr 2>/dev/null)" ] &&
5824 skip_env "could not find setfattr" && return
5826 echo "set/get xattr..."
5827 setfattr -n trusted.name1 -v value1 $testfile || error
5828 getfattr -n trusted.name1 $testfile 2> /dev/null |
5829 grep "trusted.name1=.value1" ||
5830 error "$testfile missing trusted.name1=value1"
5832 setfattr -n user.author1 -v author1 $testfile || error
5833 getfattr -n user.author1 $testfile 2> /dev/null |
5834 grep "user.author1=.author1" ||
5835 error "$testfile missing trusted.author1=author1"
5838 setfattr -n trusted.name2 -v value2 $testfile ||
5839 error "$testfile unable to set trusted.name2"
5840 setfattr -n trusted.name3 -v value3 $testfile ||
5841 error "$testfile unable to set trusted.name3"
5842 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
5843 grep "trusted.name" | wc -l) -eq 3 ] ||
5844 error "$testfile missing 3 trusted.name xattrs"
5846 setfattr -n user.author2 -v author2 $testfile ||
5847 error "$testfile unable to set user.author2"
5848 setfattr -n user.author3 -v author3 $testfile ||
5849 error "$testfile unable to set user.author3"
5850 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
5851 grep "user.author" | wc -l) -eq 3 ] ||
5852 error "$testfile missing 3 user.author xattrs"
5854 echo "remove xattr..."
5855 setfattr -x trusted.name1 $testfile ||
5856 error "$testfile error deleting trusted.name1"
5857 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
5858 error "$testfile did not delete trusted.name1 xattr"
5860 setfattr -x user.author1 $testfile ||
5861 error "$testfile error deleting user.author1"
5862 getfattr -d -m user $testfile 2> /dev/null | grep "user.author1" &&
5863 error "$testfile did not delete trusted.name1 xattr"
5865 # b10667: setting lustre special xattr be silently discarded
5866 echo "set lustre special xattr ..."
5867 setfattr -n "trusted.lov" -v "invalid value" $testfile ||
5868 error "$testfile allowed setting trusted.lov"
5870 run_test 102a "user xattr test =================================="
5873 # b10930: get/set/list trusted.lov xattr
5874 echo "get/set/list trusted.lov xattr ..."
5875 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
5876 local testfile=$DIR/$tfile
5877 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
5878 error "setstripe failed"
5879 local STRIPECOUNT=$($GETSTRIPE -c $testfile) ||
5880 error "getstripe failed"
5881 getfattr -d -m "^trusted" $testfile 2> /dev/null | \
5882 grep "trusted.lov" || error "can't get trusted.lov from $testfile"
5884 local testfile2=${testfile}2
5885 local value=`getfattr -n trusted.lov $testfile 2> /dev/null | \
5886 grep "trusted.lov" |sed -e 's/[^=]\+=//'`
5889 setfattr -n trusted.lov -v $value $testfile2
5890 local stripe_size=$($GETSTRIPE -S $testfile2)
5891 local stripe_count=$($GETSTRIPE -c $testfile2)
5892 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
5893 [ $stripe_count -eq $STRIPECOUNT ] ||
5894 error "stripe count $stripe_count != $STRIPECOUNT"
5897 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
5900 # b10930: get/set/list lustre.lov xattr
5901 echo "get/set/list lustre.lov xattr ..."
5902 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
5903 test_mkdir -p $DIR/$tdir
5904 chown $RUNAS_ID $DIR/$tdir
5905 local testfile=$DIR/$tdir/$tfile
5906 $RUNAS $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
5907 error "setstripe failed"
5908 local STRIPECOUNT=$($RUNAS $GETSTRIPE -c $testfile) ||
5909 error "getstripe failed"
5910 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
5911 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
5913 local testfile2=${testfile}2
5914 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
5915 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
5917 $RUNAS $MCREATE $testfile2
5918 $RUNAS setfattr -n lustre.lov -v $value $testfile2
5919 local stripe_size=$($RUNAS $GETSTRIPE -S $testfile2)
5920 local stripe_count=$($RUNAS $GETSTRIPE -c $testfile2)
5921 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
5922 [ $stripe_count -eq $STRIPECOUNT ] ||
5923 error "stripe count $stripe_count != $STRIPECOUNT"
5925 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
5927 compare_stripe_info1() {
5928 local stripe_index_all_zero=true
5930 for num in 1 2 3 4; do
5931 for count in $(seq 1 $STRIPE_COUNT); do
5932 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
5933 local size=$((STRIPE_SIZE * num))
5934 local file=file"$num-$offset-$count"
5935 stripe_size=$(lfs getstripe -S $PWD/$file)
5936 [ $stripe_size -ne $size ] &&
5937 error "$file: size $stripe_size != $size"
5938 stripe_count=$(lfs getstripe -c $PWD/$file)
5939 # allow fewer stripes to be created, ORI-601
5940 [ $stripe_count -lt $(((3 * count + 3) / 4)) ]&&
5941 error "$file: count $stripe_count != $count"
5942 stripe_index=$(lfs getstripe -i $PWD/$file)
5943 [ $stripe_index -ne 0 ] &&
5944 stripe_index_all_zero=false
5948 $stripe_index_all_zero &&
5949 error "all files are being extracted starting from OST index 0"
5954 [ -n "$(which tar 2>/dev/null)" ] &&
5955 strings $(which tar) | grep -q "lustre" && echo tar
5959 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5960 # b10930: tar test for trusted.lov xattr
5961 TAR=$(find_lustre_tar)
5962 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
5963 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
5965 test_mkdir -p $DIR/d102d
5966 $TAR xf $TMP/f102.tar -C $DIR/d102d --xattrs
5968 compare_stripe_info1
5970 run_test 102d "tar restore stripe info from tarfile,not keep osts ==========="
5973 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5974 # b10930: tar test for trusted.lov xattr
5975 TAR=$(find_lustre_tar)
5976 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
5977 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
5979 test_mkdir -p $DIR/d102f
5981 $TAR cf - --xattrs $tdir | $TAR xf - --xattrs -C $DIR/d102f
5983 compare_stripe_info1
5985 run_test 102f "tar copy files, not keep osts ==========="
5988 local xsize=${1:-1024} # in bytes
5989 local file=$DIR/$tfile
5991 [ -z $(lctl get_param -n mdc.*.connect_flags | grep xattr) ] &&
5992 skip "must have user_xattr" && return 0
5993 [ -z "$(which setfattr 2>/dev/null)" ] &&
5994 skip_env "could not find setfattr" && return 0
5995 [ -z "$(which getfattr 2>/dev/null)" ] &&
5996 skip_env "could not find getfattr" && return 0
6000 local value="$(generate_string $xsize)"
6002 local xbig=trusted.big
6003 log "save $xbig on $file"
6004 setfattr -n $xbig -v $value $file ||
6005 error "saving $xbig on $file failed"
6007 local orig=$(get_xattr_value $xbig $file)
6008 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
6010 local xsml=trusted.sml
6011 log "save $xsml on $file"
6012 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
6014 local new=$(get_xattr_value $xbig $file)
6015 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
6017 log "grow $xsml on $file"
6018 setfattr -n $xsml -v "$value" $file ||
6019 error "growing $xsml on $file failed"
6021 new=$(get_xattr_value $xbig $file)
6022 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
6023 log "$xbig still valid after growing $xsml"
6028 test_102h() { # bug 15777
6031 run_test 102h "grow xattr from inside inode to external block"
6034 large_xattr_enabled || { skip "large_xattr disabled" && return; }
6035 grow_xattr $(max_xattr_size)
6037 run_test 102ha "grow xattr from inside inode to external inode"
6039 test_102i() { # bug 17038
6041 ln -s $DIR/$tfile $DIR/${tfile}link
6042 getfattr -n trusted.lov $DIR/$tfile || error "lgetxattr on $DIR/$tfile failed"
6043 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"
6044 rm -f $DIR/$tfile $DIR/${tfile}link
6046 run_test 102i "lgetxattr test on symbolic link ============"
6049 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6050 TAR=$(find_lustre_tar)
6051 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6052 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
6053 setup_test102 "$RUNAS"
6054 test_mkdir -p $DIR/d102j
6055 chown $RUNAS_ID $DIR/d102j
6056 $RUNAS $TAR xf $TMP/f102.tar -C $DIR/d102j --xattrs
6058 compare_stripe_info1 "$RUNAS"
6060 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
6064 # b22187 just check that does not crash for regular file.
6065 setfattr -n trusted.lov $DIR/$tfile
6066 # b22187 'setfattr -n trusted.lov' should work as remove LOV EA for directories
6067 local test_kdir=$DIR/d102k
6068 test_mkdir $test_kdir
6069 local default_size=`$GETSTRIPE -S $test_kdir`
6070 local default_count=`$GETSTRIPE -c $test_kdir`
6071 local default_offset=`$GETSTRIPE -i $test_kdir`
6072 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $test_kdir ||
6073 error 'dir setstripe failed'
6074 setfattr -n trusted.lov $test_kdir
6075 local stripe_size=`$GETSTRIPE -S $test_kdir`
6076 local stripe_count=`$GETSTRIPE -c $test_kdir`
6077 local stripe_offset=`$GETSTRIPE -i $test_kdir`
6078 [ $stripe_size -eq $default_size ] ||
6079 error "stripe size $stripe_size != $default_size"
6080 [ $stripe_count -eq $default_count ] ||
6081 error "stripe count $stripe_count != $default_count"
6082 [ $stripe_offset -eq $default_offset ] ||
6083 error "stripe offset $stripe_offset != $default_offset"
6084 rm -rf $DIR/$tfile $test_kdir
6086 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
6089 # LU-532 trusted. xattr is invisible to non-root
6090 local testfile=$DIR/$tfile
6094 echo "listxattr as user..."
6095 chown $RUNAS_ID $testfile
6096 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
6097 grep -q "trusted" &&
6098 error "$testfile trusted xattrs are user visible"
6102 run_test 102l "listxattr filter test =================================="
6108 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
6113 [ "$UID" != 0 ] && skip_env "must run as root" && return
6114 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
6115 [ -z "$(which setfacl 2>/dev/null)" ] && skip_env "could not find setfacl" && return
6116 $GSS && skip "could not run under gss" && return
6118 declare -a identity_old
6120 for num in $(seq $MDSCOUNT); do
6121 switch_identity $num true || identity_old[$num]=$?
6128 echo "performing cp ..."
6129 run_acl_subtest cp || error
6130 echo "performing getfacl-noacl..."
6131 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
6132 echo "performing misc..."
6133 run_acl_subtest misc || error "misc test failed"
6134 echo "performing permissions..."
6135 run_acl_subtest permissions || error "permissions failed"
6136 echo "performing setfacl..."
6137 run_acl_subtest setfacl || error "setfacl test failed"
6139 # inheritance test got from HP
6140 echo "performing inheritance..."
6141 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
6142 chmod +x make-tree || error "chmod +x failed"
6143 run_acl_subtest inheritance || error "inheritance test failed"
6146 echo "LU-974 ignore umask when acl is enabled..."
6147 run_acl_subtest 974 || error "LU-974 test failed"
6149 echo "LU-2561 newly created file is same size as directory..."
6150 run_acl_subtest 2561 || error "LU-2561 test failed"
6155 for num in $(seq $MDSCOUNT); do
6156 if [ "${identity_old[$num]}" = 1 ]; then
6157 switch_identity $num false || identity_old[$num]=$?
6161 run_test 103 "acl test ========================================="
6164 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6166 lfs df || error "lfs df failed"
6167 lfs df -ih || error "lfs df -ih failed"
6168 lfs df -h $DIR || error "lfs df -h $DIR failed"
6169 lfs df -i $DIR || error "lfs df -i $DIR failed"
6170 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
6171 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
6173 OSC=`lctl dl |grep OST0000-osc-[^M] |awk '{print $4}'`
6174 lctl --device %$OSC deactivate
6175 lfs df || error "lfs df with deactivated OSC failed"
6176 lctl --device %$OSC activate
6177 # wait the osc back to normal
6178 wait_osc_import_state client ost FULL
6180 lfs df || error "lfs df with reactivated OSC failed"
6183 run_test 104a "lfs df [-ih] [path] test ========================="
6186 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6187 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
6189 denied_cnt=$((`$RUNAS $LFS check servers 2>&1 | grep "Permission denied" | wc -l`))
6190 if [ $denied_cnt -ne 0 ];
6192 error "lfs check servers test failed"
6195 run_test 104b "$RUNAS lfs check servers test ===================="
6198 # doesn't work on 2.4 kernels
6200 if [ -n "`mount | grep \"$MOUNT.*flock\" | grep -v noflock`" ]; then
6201 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
6203 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
6207 run_test 105a "flock when mounted without -o flock test ========"
6211 if [ -n "`mount | grep \"$MOUNT.*flock\" | grep -v noflock`" ]; then
6212 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
6214 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
6218 run_test 105b "fcntl when mounted without -o flock test ========"
6222 if [ -n "`mount | grep \"$MOUNT.*flock\" | grep -v noflock`" ]; then
6223 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
6225 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
6229 run_test 105c "lockf when mounted without -o flock test ========"
6231 test_105d() { # bug 15924
6232 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6233 test_mkdir -p $DIR/$tdir
6234 [ -z "`mount | grep \"$MOUNT.*flock\" | grep -v noflock`" ] && \
6235 skip "mount w/o flock enabled" && return
6236 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
6237 $LCTL set_param fail_loc=0x80000315
6238 flocks_test 2 $DIR/$tdir
6240 run_test 105d "flock race (should not freeze) ========"
6242 test_105e() { # bug 22660 && 22040
6243 [ -z "`mount | grep \"$MOUNT.*flock\" | grep -v noflock`" ] && \
6244 skip "mount w/o flock enabled" && return
6246 flocks_test 3 $DIR/$tfile
6248 run_test 105e "Two conflicting flocks from same process ======="
6250 test_106() { #bug 10921
6251 test_mkdir -p $DIR/$tdir
6252 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
6253 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
6255 run_test 106 "attempt exec of dir followed by chown of that dir"
6258 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6265 local save_pattern=$(sysctl -n kernel.core_pattern)
6266 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
6267 sysctl -w kernel.core_pattern=$file
6268 sysctl -w kernel.core_uses_pid=0
6276 kill -s 11 $SLEEPPID
6278 if [ -e $file ]; then
6279 size=`stat -c%s $file`
6280 [ $size -eq 0 ] && error "Fail to create core file $file"
6282 error "Fail to create core file $file"
6285 sysctl -w kernel.core_pattern=$save_pattern
6286 sysctl -w kernel.core_uses_pid=$save_uses_pid
6289 run_test 107 "Coredump on SIG"
6292 test_mkdir -p $DIR/$tdir
6293 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255) ||
6294 error "mkdir with 255 char failed"
6295 test_mkdir $DIR/$tdir/$(str_repeat 'b' 256) &&
6296 error "mkdir with 256 char should fail, but did not"
6297 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
6298 error "create with 255 char failed"
6299 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
6300 error "create with 256 char should fail, but did not"
6305 run_test 110 "filename length checking"
6308 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6309 OSTIO_pre=$(ps -e|grep ll_ost_io|awk '{print $4}'|sort -n|tail -1|\
6311 [ -z "$OSTIO_pre" ] && skip "no OSS threads" && \
6313 echo "Starting with $OSTIO_pre threads"
6316 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
6317 [ $NUMFREE -lt $NUMTEST ] && NUMTEST=$(($NUMFREE - 1000))
6318 echo "$NUMTEST creates/unlinks"
6319 test_mkdir -p $DIR/$tdir
6320 createmany -o $DIR/$tdir/$tfile $NUMTEST
6321 unlinkmany $DIR/$tdir/$tfile $NUMTEST
6323 OSTIO_post=$(ps -e|grep ll_ost_io|awk '{print $4}'|sort -n|tail -1|\
6326 # don't return an error
6327 [ $OSTIO_post == $OSTIO_pre ] && echo \
6328 "WARNING: No new ll_ost_io threads were created ($OSTIO_pre)" &&
6329 echo "This may be fine, depending on what ran before this test" &&
6330 echo "and how fast this system is." && return
6332 echo "Started with $OSTIO_pre threads, ended with $OSTIO_post"
6334 run_test 115 "verify dynamic thread creation===================="
6337 wait_delete_completed
6338 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
6339 echo OST kbytes available: ${AVAIL[@]}
6340 MAXI=0; MAXV=${AVAIL[0]}
6341 MINI=0; MINV=${AVAIL[0]}
6342 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
6343 #echo OST $i: ${AVAIL[i]}kb
6344 if [ ${AVAIL[i]} -gt $MAXV ]; then
6345 MAXV=${AVAIL[i]}; MAXI=$i
6347 if [ ${AVAIL[i]} -lt $MINV ]; then
6348 MINV=${AVAIL[i]}; MINI=$i
6351 echo Min free space: OST $MINI: $MINV
6352 echo Max free space: OST $MAXI: $MAXV
6355 test_116a() { # was previously test_116()
6356 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6357 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs" && return
6359 echo -n "Free space priority "
6360 lctl get_param -n lov.*-clilov-*.qos_prio_free
6363 [ $MINV -gt 960000 ] && skip "too much free space in OST$MINI, skip" &&\
6366 # generate uneven OSTs
6367 test_mkdir -p $DIR/$tdir/OST${MINI}
6370 echo "Filling 25% remaining space in OST${MINI} with ${FILL}Kb"
6371 $SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI}||error "setstripe failed"
6373 while [ $FILL -gt 0 ]; do
6375 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i bs=2M count=1 2>/dev/null
6376 FILL=$(($FILL - 2048))
6384 DIFF=$(($MAXV - $MINV))
6385 DIFF2=$(($DIFF * 100 / $MINV))
6386 echo -n "diff=${DIFF}=${DIFF2}% must be > 20% for QOS mode..."
6387 if [ $DIFF2 -gt 20 ]; then
6390 echo "failed - QOS mode won't be used"
6391 error_ignore "QOS imbalance criteria not met"
6395 MINI1=$MINI; MINV1=$MINV
6396 MAXI1=$MAXI; MAXV1=$MAXV
6398 # now fill using QOS
6399 echo writing a bunch of files to QOS-assigned OSTs
6400 $SETSTRIPE -c 1 $DIR/$tdir
6402 while [ $FILL -gt 0 ]; do
6404 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1024 count=200 2>/dev/null
6405 FILL=$(($FILL - 200))
6408 echo "wrote $i 200k files"
6412 echo "Note: free space may not be updated, so measurements might be off"
6414 DIFF2=$(($MAXV - $MINV))
6415 echo "free space delta: orig $DIFF final $DIFF2"
6416 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
6417 DIFF=$(($MINV1 - ${AVAIL[$MINI1]}))
6418 echo "Wrote $DIFF to smaller OST $MINI1"
6419 DIFF2=$(($MAXV1 - ${AVAIL[$MAXI1]}))
6420 echo "Wrote $DIFF2 to larger OST $MAXI1"
6421 [ $DIFF -gt 0 ] && echo "Wrote $(($DIFF2 * 100 / $DIFF - 100))% more data to larger OST $MAXI1"
6423 # Figure out which files were written where
6424 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
6425 awk '/'$MINI1': / {print $2; exit}')
6427 MINC=$($GETSTRIPE --obd $UUID $DIR/$tdir | wc -l)
6428 echo "$MINC files created on smaller OST $MINI1"
6429 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
6430 awk '/'$MAXI1': / {print $2; exit}')
6432 MAXC=$($GETSTRIPE --obd $UUID $DIR/$tdir | wc -l)
6433 echo "$MAXC files created on larger OST $MAXI1"
6434 [ $MINC -gt 0 ] && echo "Wrote $(($MAXC * 100 / $MINC - 100))% more files to larger OST $MAXI1"
6435 [ $MAXC -gt $MINC ] || error_ignore "stripe QOS didn't balance free space"
6439 run_test 116a "stripe QOS: free space balance ==================="
6441 test_116b() { # LU-2093
6442 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6443 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
6445 old_rr=$(do_facet $SINGLEMDS lctl get_param -n lov.*mdtlov*.qos_threshold_rr)
6446 do_facet $SINGLEMDS lctl set_param lov.*mdtlov*.qos_threshold_rr 0
6448 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
6449 createmany -o $DIR/$tdir/f- 20 || error "can't create"
6450 do_facet $SINGLEMDS lctl set_param fail_loc=0
6452 do_facet $SINGLEMDS lctl set_param lov.*mdtlov*.qos_threshold_rr $old_rr
6454 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
6456 test_117() # bug 10891
6458 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6459 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
6460 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
6461 lctl set_param fail_loc=0x21e
6462 > $DIR/$tfile || error "truncate failed"
6463 lctl set_param fail_loc=0
6464 echo "Truncate succeeded."
6467 run_test 117 "verify fsfilt_extend =========="
6469 export OLD_RESENDCOUNT=""
6470 set_resend_count () {
6471 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
6472 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -1)
6473 lctl set_param -n $PROC_RESENDCOUNT $1
6474 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
6477 [ "$SLOW" = "no" ] && set_resend_count 4 # for reduce test_118* time (bug 14842)
6479 # Reset async IO behavior after error case
6481 FILE=$DIR/reset_async
6483 # Ensure all OSCs are cleared
6484 $SETSTRIPE -c -1 $FILE
6485 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
6490 test_118a() #bug 11710
6492 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6495 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6496 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6497 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
6499 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6500 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6505 run_test 118a "verify O_SYNC works =========="
6509 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6510 remote_ost_nodsh && skip "remote OST with nodsh" && return
6514 #define OBD_FAIL_OST_ENOENT 0x217
6515 set_nodes_failloc "$(osts_nodes)" 0x217
6516 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6518 set_nodes_failloc "$(osts_nodes)" 0
6519 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6520 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6523 if [[ $RC -eq 0 ]]; then
6524 error "Must return error due to dropped pages, rc=$RC"
6528 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6529 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6533 echo "Dirty pages not leaked on ENOENT"
6535 # Due to the above error the OSC will issue all RPCs syncronously
6536 # until a subsequent RPC completes successfully without error.
6537 $MULTIOP $DIR/$tfile Ow4096yc
6542 run_test 118b "Reclaim dirty pages on fatal error =========="
6546 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6547 remote_ost_nodsh && skip "remote OST with nodsh" && return
6551 #define OBD_FAIL_OST_EROFS 0x216
6552 set_nodes_failloc "$(osts_nodes)" 0x216
6554 # multiop should block due to fsync until pages are written
6555 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
6559 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
6560 error "Multiop failed to block on fsync, pid=$MULTIPID"
6563 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6565 if [[ $WRITEBACK -eq 0 ]]; then
6566 error "No page in writeback, writeback=$WRITEBACK"
6569 set_nodes_failloc "$(osts_nodes)" 0
6572 if [[ $RC -ne 0 ]]; then
6573 error "Multiop fsync failed, rc=$RC"
6576 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6577 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6579 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6580 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6584 echo "Dirty pages flushed via fsync on EROFS"
6587 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
6591 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6592 remote_ost_nodsh && skip "remote OST with nodsh" && return
6596 #define OBD_FAIL_OST_BRW_PAUSE_BULK
6597 set_nodes_failloc "$(osts_nodes)" 0x214
6598 # multiop should block due to fsync until pages are written
6599 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
6603 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
6604 error "Multiop failed to block on fsync, pid=$MULTIPID"
6607 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6609 if [[ $WRITEBACK -eq 0 ]]; then
6610 error "No page in writeback, writeback=$WRITEBACK"
6613 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
6614 set_nodes_failloc "$(osts_nodes)" 0
6616 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6617 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6619 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6620 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6624 echo "Dirty pages gaurenteed flushed via fsync"
6627 run_test 118d "Fsync validation inject a delay of the bulk =========="
6630 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6633 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
6634 lctl set_param fail_loc=0x8000040a
6636 # Should simulate EINVAL error which is fatal
6637 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6639 if [[ $RC -eq 0 ]]; then
6640 error "Must return error due to dropped pages, rc=$RC"
6643 lctl set_param fail_loc=0x0
6645 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6646 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6647 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6649 if [[ $LOCKED -ne 0 ]]; then
6650 error "Locked pages remain in cache, locked=$LOCKED"
6653 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6654 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6658 echo "No pages locked after fsync"
6663 run_test 118f "Simulate unrecoverable OSC side error =========="
6666 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6669 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
6670 lctl set_param fail_loc=0x406
6672 # simulate local -ENOMEM
6673 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6676 lctl set_param fail_loc=0
6677 if [[ $RC -eq 0 ]]; then
6678 error "Must return error due to dropped pages, rc=$RC"
6681 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6682 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6683 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6685 if [[ $LOCKED -ne 0 ]]; then
6686 error "Locked pages remain in cache, locked=$LOCKED"
6689 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6690 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6694 echo "No pages locked after fsync"
6699 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
6702 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6703 remote_ost_nodsh && skip "remote OST with nodsh" && return
6707 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
6708 set_nodes_failloc "$(osts_nodes)" 0x20e
6709 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
6710 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6713 set_nodes_failloc "$(osts_nodes)" 0
6714 if [[ $RC -eq 0 ]]; then
6715 error "Must return error due to dropped pages, rc=$RC"
6718 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6719 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6720 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6722 if [[ $LOCKED -ne 0 ]]; then
6723 error "Locked pages remain in cache, locked=$LOCKED"
6726 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6727 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6731 echo "No pages locked after fsync"
6735 run_test 118h "Verify timeout in handling recoverables errors =========="
6737 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
6740 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6741 remote_ost_nodsh && skip "remote OST with nodsh" && return
6745 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
6746 set_nodes_failloc "$(osts_nodes)" 0x20e
6748 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
6749 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
6752 set_nodes_failloc "$(osts_nodes)" 0
6756 if [[ $RC -ne 0 ]]; then
6757 error "got error, but should be not, rc=$RC"
6760 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6761 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6762 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
6763 if [[ $LOCKED -ne 0 ]]; then
6764 error "Locked pages remain in cache, locked=$LOCKED"
6767 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6768 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6772 echo "No pages locked after fsync"
6776 run_test 118i "Fix error before timeout in recoverable error =========="
6778 [ "$SLOW" = "no" ] && set_resend_count 4
6781 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6782 remote_ost_nodsh && skip "remote OST with nodsh" && return
6786 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
6787 set_nodes_failloc "$(osts_nodes)" 0x220
6789 # return -EIO from OST
6790 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6792 set_nodes_failloc "$(osts_nodes)" 0x0
6793 if [[ $RC -eq 0 ]]; then
6794 error "Must return error due to dropped pages, rc=$RC"
6797 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6798 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6799 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
6800 if [[ $LOCKED -ne 0 ]]; then
6801 error "Locked pages remain in cache, locked=$LOCKED"
6804 # in recoverable error on OST we want resend and stay until it finished
6805 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6806 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6810 echo "No pages locked after fsync"
6814 run_test 118j "Simulate unrecoverable OST side error =========="
6818 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6819 remote_ost_nodsh && skip "remote OSTs with nodsh" && return
6821 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
6822 set_nodes_failloc "$(osts_nodes)" 0x20e
6823 test_mkdir -p $DIR/$tdir
6825 for ((i=0;i<10;i++)); do
6826 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
6827 error "dd to $DIR/$tdir/$tfile-$i failed" )&
6834 set_nodes_failloc "$(osts_nodes)" 0
6837 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
6841 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6843 test_mkdir -p $DIR/$tdir
6844 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
6847 run_test 118l "fsync dir ========="
6849 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
6851 test_119a() # bug 11737
6853 BSIZE=$((512 * 1024))
6854 directio write $DIR/$tfile 0 1 $BSIZE
6855 # We ask to read two blocks, which is more than a file size.
6856 # directio will indicate an error when requested and actual
6857 # sizes aren't equeal (a normal situation in this case) and
6858 # print actual read amount.
6859 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
6860 if [ "$NOB" != "$BSIZE" ]; then
6861 error "read $NOB bytes instead of $BSIZE"
6865 run_test 119a "Short directIO read must return actual read amount"
6867 test_119b() # bug 11737
6869 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
6871 $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
6872 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
6874 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) || \
6875 error "direct read failed"
6878 run_test 119b "Sparse directIO read must return actual read amount"
6880 test_119c() # bug 13099
6883 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
6884 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
6887 run_test 119c "Testing for direct read hitting hole"
6889 test_119d() # bug 15950
6891 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6892 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
6893 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
6895 $SETSTRIPE $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
6896 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
6897 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
6898 lctl set_param fail_loc=0x40d
6899 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
6902 cat $DIR/$tfile > /dev/null &
6903 lctl set_param fail_loc=0
6906 log "the DIO writes have completed, now wait for the reads (should not block very long)"
6908 [ -n "`ps h -p $pid_reads -o comm`" ] && \
6909 error "the read rpcs have not completed in 2s"
6911 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
6913 run_test 119d "The DIO path should try to send a new rpc once one is completed"
6916 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6917 test_mkdir -p $DIR/$tdir
6918 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6919 skip "no early lock cancel on server" && return 0
6920 lru_resize_disable mdc
6921 lru_resize_disable osc
6922 cancel_lru_locks mdc
6923 stat $DIR/$tdir > /dev/null
6924 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6925 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6926 test_mkdir $DIR/$tdir/d1
6927 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6928 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6929 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6930 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6931 lru_resize_enable mdc
6932 lru_resize_enable osc
6934 run_test 120a "Early Lock Cancel: mkdir test"
6937 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6938 test_mkdir -p $DIR/$tdir
6939 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6940 skip "no early lock cancel on server" && return 0
6941 lru_resize_disable mdc
6942 lru_resize_disable osc
6943 cancel_lru_locks mdc
6944 stat $DIR/$tdir > /dev/null
6945 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6946 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6948 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6949 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6950 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6951 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6952 lru_resize_enable mdc
6953 lru_resize_enable osc
6955 run_test 120b "Early Lock Cancel: create test"
6958 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6959 test_mkdir -p $DIR/$tdir
6960 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6961 skip "no early lock cancel on server" && return 0
6962 lru_resize_disable mdc
6963 lru_resize_disable osc
6964 test_mkdir -p $DIR/$tdir/d1 $DIR/$tdir/d2
6965 touch $DIR/$tdir/d1/f1
6966 cancel_lru_locks mdc
6967 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
6968 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6969 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6970 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
6971 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6972 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6973 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6974 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6975 lru_resize_enable mdc
6976 lru_resize_enable osc
6978 run_test 120c "Early Lock Cancel: link test"
6981 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6982 test_mkdir -p $DIR/$tdir
6983 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6984 skip "no early lock cancel on server" && return 0
6985 lru_resize_disable mdc
6986 lru_resize_disable osc
6988 cancel_lru_locks mdc
6989 stat $DIR/$tdir > /dev/null
6990 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6991 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6992 chmod a+x $DIR/$tdir
6993 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6994 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6995 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6996 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6997 lru_resize_enable mdc
6998 lru_resize_enable osc
7000 run_test 120d "Early Lock Cancel: setattr test"
7003 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7004 test_mkdir -p $DIR/$tdir
7005 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7006 skip "no early lock cancel on server" && return 0
7007 lru_resize_disable mdc
7008 lru_resize_disable osc
7009 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
7010 cancel_lru_locks mdc
7011 cancel_lru_locks osc
7012 dd if=$DIR/$tdir/f1 of=/dev/null
7013 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
7014 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7015 awk '/ldlm_cancel/ {print $2}'`
7016 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7017 awk '/ldlm_bl_callback/ {print $2}'`
7018 unlink $DIR/$tdir/f1
7019 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7020 awk '/ldlm_cancel/ {print $2}'`
7021 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7022 awk '/ldlm_bl_callback/ {print $2}'`
7023 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7024 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7025 lru_resize_enable mdc
7026 lru_resize_enable osc
7028 run_test 120e "Early Lock Cancel: unlink test"
7031 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7032 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7033 skip "no early lock cancel on server" && return 0
7034 test_mkdir -p $DIR/$tdir
7035 lru_resize_disable mdc
7036 lru_resize_disable osc
7037 test_mkdir -p $DIR/$tdir/d1 $DIR/$tdir/d2
7038 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
7039 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
7040 cancel_lru_locks mdc
7041 cancel_lru_locks osc
7042 dd if=$DIR/$tdir/d1/f1 of=/dev/null
7043 dd if=$DIR/$tdir/d2/f2 of=/dev/null
7044 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
7045 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7046 awk '/ldlm_cancel/ {print $2}'`
7047 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7048 awk '/ldlm_bl_callback/ {print $2}'`
7049 mv $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
7050 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7051 awk '/ldlm_cancel/ {print $2}'`
7052 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7053 awk '/ldlm_bl_callback/ {print $2}'`
7054 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7055 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7056 lru_resize_enable mdc
7057 lru_resize_enable osc
7059 run_test 120f "Early Lock Cancel: rename test"
7062 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7063 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7064 skip "no early lock cancel on server" && return 0
7065 lru_resize_disable mdc
7066 lru_resize_disable osc
7068 echo create $count files
7069 test_mkdir -p $DIR/$tdir
7070 cancel_lru_locks mdc
7071 cancel_lru_locks osc
7074 can0=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7075 awk '/ldlm_cancel/ {print $2}'`
7076 blk0=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7077 awk '/ldlm_bl_callback/ {print $2}'`
7078 createmany -o $DIR/$tdir/f $count
7080 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7081 awk '/ldlm_cancel/ {print $2}'`
7082 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7083 awk '/ldlm_bl_callback/ {print $2}'`
7085 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
7086 echo rm $count files
7089 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7090 awk '/ldlm_cancel/ {print $2}'`
7091 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7092 awk '/ldlm_bl_callback/ {print $2}'`
7094 echo total: $count removes in $((t2-t1))
7095 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
7097 # wait for commitment of removal
7098 lru_resize_enable mdc
7099 lru_resize_enable osc
7101 run_test 120g "Early Lock Cancel: performance test"
7103 test_121() { #bug #10589
7104 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7106 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
7107 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
7108 lctl set_param fail_loc=0x310
7109 cancel_lru_locks osc > /dev/null
7110 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
7111 lctl set_param fail_loc=0
7112 [ "$reads" -eq "$writes" ] || error "read" $reads "blocks, must be" $writes
7114 run_test 121 "read cancel race ========="
7116 test_123a() { # was test 123, statahead(bug 11401)
7117 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7119 if [ -z "$(grep "processor.*: 1" /proc/cpuinfo)" ]; then
7120 log "testing on UP system. Performance may be not as good as expected."
7125 test_mkdir -p $DIR/$tdir
7126 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
7127 [ $NUMFREE -gt 100000 ] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
7129 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
7130 createmany -o $DIR/$tdir/$tfile $j $((i - j))
7132 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
7133 lctl set_param -n llite.*.statahead_max 0
7134 lctl get_param llite.*.statahead_max
7135 cancel_lru_locks mdc
7136 cancel_lru_locks osc
7138 time ls -l $DIR/$tdir | wc -l
7140 delta=$((etime - stime))
7141 log "ls $i files without statahead: $delta sec"
7142 lctl set_param llite.*.statahead_max=$max
7144 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
7145 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
7146 cancel_lru_locks mdc
7147 cancel_lru_locks osc
7149 time ls -l $DIR/$tdir | wc -l
7151 delta_sa=$((etime - stime))
7152 log "ls $i files with statahead: $delta_sa sec"
7153 lctl get_param -n llite.*.statahead_stats
7154 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
7156 [ $swrong -lt $ewrong ] && log "statahead was stopped, maybe too many locks held!"
7157 [ $delta -eq 0 -o $delta_sa -eq 0 ] && continue
7159 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
7160 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
7161 lctl set_param -n llite.*.statahead_max 0
7162 lctl get_param llite.*.statahead_max
7163 cancel_lru_locks mdc
7164 cancel_lru_locks osc
7166 time ls -l $DIR/$tdir | wc -l
7168 delta=$((etime - stime))
7169 log "ls $i files again without statahead: $delta sec"
7170 lctl set_param llite.*.statahead_max=$max
7171 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
7172 if [ $SLOWOK -eq 0 ]; then
7173 error "ls $i files is slower with statahead!"
7175 log "ls $i files is slower with statahead!"
7181 [ $delta -gt 20 ] && break
7182 [ $delta -gt 8 ] && MULT=$((50 / delta))
7183 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
7191 delta=$((etime - stime))
7192 log "rm -r $DIR/$tdir/: $delta seconds"
7194 lctl get_param -n llite.*.statahead_stats
7196 run_test 123a "verify statahead work"
7198 test_123b () { # statahead(bug 15027)
7199 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7200 test_mkdir -p $DIR/$tdir
7201 createmany -o $DIR/$tdir/$tfile-%d 1000
7203 cancel_lru_locks mdc
7204 cancel_lru_locks osc
7206 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
7207 lctl set_param fail_loc=0x80000803
7208 ls -lR $DIR/$tdir > /dev/null
7210 lctl set_param fail_loc=0x0
7211 lctl get_param -n llite.*.statahead_stats
7216 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
7219 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7220 [ -z "`lctl get_param -n mdc.*.connect_flags | grep lru_resize`" ] && \
7221 skip "no lru resize on server" && return 0
7223 test_mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
7225 log "create $NR files at $DIR/$tdir"
7226 createmany -o $DIR/$tdir/f $NR ||
7227 error "failed to create $NR files in $DIR/$tdir"
7229 cancel_lru_locks mdc
7230 ls -l $DIR/$tdir > /dev/null
7234 for VALUE in `lctl get_param ldlm.namespaces.*mdc-*.lru_size`; do
7235 local PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
7236 LRU_SIZE=$(lctl get_param -n $PARAM)
7237 if [ $LRU_SIZE -gt $(default_lru_size) ]; then
7238 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
7240 log "NS=$(basename $NSDIR)"
7245 if [ -z "$NSDIR" -o $LRU_SIZE -lt $(default_lru_size) ]; then
7246 skip "Not enough cached locks created!"
7253 # We know that lru resize allows one client to hold $LIMIT locks
7254 # for 10h. After that locks begin to be killed by client.
7256 local LIMIT=`lctl get_param -n $NSDIR.pool.limit`
7259 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
7260 # killing locks. Some time was spent for creating locks. This means
7261 # that up to the moment of sleep finish we must have killed some of
7262 # them (10-100 locks). This depends on how fast ther were created.
7263 # Many of them were touched in almost the same moment and thus will
7264 # be killed in groups.
7265 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
7267 # Use $LRU_SIZE_B here to take into account real number of locks
7268 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
7269 local LRU_SIZE_B=$LRU_SIZE
7271 local OLD_LVF=`lctl get_param -n $NSDIR.pool.lock_volume_factor`
7272 log "OLD_LVF=$OLD_LVF"
7273 lctl set_param -n $NSDIR.pool.lock_volume_factor $LVF
7275 # Let's make sure that we really have some margin. Client checks
7276 # cached locks every 10 sec.
7278 log "Sleep ${SLEEP} sec"
7280 while ((SEC<$SLEEP)); do
7284 LRU_SIZE=`lctl get_param -n $NSDIR/lru_size`
7288 lctl set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
7289 local LRU_SIZE_A=`lctl get_param -n $NSDIR.lru_size`
7291 [ $LRU_SIZE_B -gt $LRU_SIZE_A ] || {
7292 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
7293 unlinkmany $DIR/$tdir/f $NR
7297 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
7298 log "unlink $NR files at $DIR/$tdir"
7299 unlinkmany $DIR/$tdir/f $NR
7301 run_test 124a "lru resize ======================================="
7303 get_max_pool_limit()
7305 local limit=`lctl get_param -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit`
7308 if test $l -gt $max; then
7316 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7317 [ -z "`lctl get_param -n mdc.*.connect_flags | grep lru_resize`" ] && \
7318 skip "no lru resize on server" && return 0
7320 LIMIT=`get_max_pool_limit`
7322 NR=$(($(default_lru_size)*20))
7323 if [ $NR -gt $LIMIT ]; then
7324 log "Limit lock number by $LIMIT locks"
7327 lru_resize_disable mdc
7328 test_mkdir -p $DIR/$tdir/disable_lru_resize ||
7329 error "failed to create $DIR/$tdir/disable_lru_resize"
7331 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
7332 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
7333 cancel_lru_locks mdc
7336 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
7339 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
7342 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
7346 nolruresize_delta=$((etime-stime))
7347 log "ls -la time: $nolruresize_delta seconds"
7348 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
7349 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
7351 lru_resize_enable mdc
7352 test_mkdir -p $DIR/$tdir/enable_lru_resize ||
7353 error "failed to create $DIR/$tdir/enable_lru_resize"
7355 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
7356 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
7357 cancel_lru_locks mdc
7360 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
7363 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
7366 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
7370 lruresize_delta=$((etime-stime))
7371 log "ls -la time: $lruresize_delta seconds"
7372 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
7374 if [ $lruresize_delta -gt $nolruresize_delta ]; then
7375 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
7376 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
7377 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
7379 log "lru resize performs the same with no lru resize"
7381 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
7383 run_test 124b "lru resize (performance test) ======================="
7385 test_125() { # 13358
7386 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
7387 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
7388 test_mkdir -p $DIR/d125 || error "mkdir failed"
7389 $SETSTRIPE -S 65536 -c -1 $DIR/d125 || error "setstripe failed"
7390 setfacl -R -m u:bin:rwx $DIR/d125 || error "setfacl $DIR/d125 failed"
7391 ls -ld $DIR/d125 || error "cannot access $DIR/d125"
7393 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
7395 test_126() { # bug 12829/13455
7396 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
7397 [ "$UID" != 0 ] && skip_env "skipping $TESTNAME (must run as root)" && return
7398 $GSS && skip "must run as gss disabled" && return
7400 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
7401 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
7403 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
7405 run_test 126 "check that the fsgid provided by the client is taken into account"
7407 test_127a() { # bug 15521
7408 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7409 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
7410 $LCTL set_param osc.*.stats=0
7411 FSIZE=$((2048 * 1024))
7412 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
7413 cancel_lru_locks osc
7414 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
7416 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
7417 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
7418 echo "got $COUNT $NAME"
7419 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
7420 eval $NAME=$COUNT || error "Wrong proc format"
7423 read_bytes|write_bytes)
7424 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
7425 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
7426 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
7427 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
7428 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
7429 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
7430 error "sumsquare is too small: $SUMSQ"
7431 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
7432 error "sumsquare is too big: $SUMSQ"
7436 done < $DIR/${tfile}.tmp
7438 #check that we actually got some stats
7439 [ "$read_bytes" ] || error "Missing read_bytes stats"
7440 [ "$write_bytes" ] || error "Missing write_bytes stats"
7441 [ "$read_bytes" != 0 ] || error "no read done"
7442 [ "$write_bytes" != 0 ] || error "no write done"
7444 run_test 127a "verify the client stats are sane"
7446 test_127b() { # bug LU-333
7447 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7448 $LCTL set_param llite.*.stats=0
7449 FSIZE=65536 # sized fixed to match PAGE_SIZE for most clients
7450 # perform 2 reads and writes so MAX is different from SUM.
7451 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
7452 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
7453 cancel_lru_locks osc
7454 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
7455 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
7457 $LCTL get_param llite.*.stats | grep samples > $TMP/${tfile}.tmp
7458 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
7459 echo "got $COUNT $NAME"
7460 eval $NAME=$COUNT || error "Wrong proc format"
7464 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
7465 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
7466 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
7467 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
7470 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
7471 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
7472 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
7473 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
7477 done < $TMP/${tfile}.tmp
7479 #check that we actually got some stats
7480 [ "$read_bytes" ] || error "Missing read_bytes stats"
7481 [ "$write_bytes" ] || error "Missing write_bytes stats"
7482 [ "$read_bytes" != 0 ] || error "no read done"
7483 [ "$write_bytes" != 0 ] || error "no write done"
7485 run_test 127b "verify the llite client stats are sane"
7487 test_128() { # bug 15212
7489 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
7494 result=$(grep error $TMP/$tfile.log)
7496 [ -z "$result" ] || error "consecutive find's under interactive lfs failed"
7498 run_test 128 "interactive lfs for 2 consecutive find's"
7505 local LDPROC=/proc/fs/ldiskfs
7506 local facets=$(get_facets MDS)
7508 for facet in ${facets//,/ }; do
7509 canondev=$(ldiskfs_canon \
7510 *.$(convert_facet2label $facet).mntdev $facet)
7511 do_facet $facet "test -e $LDPROC/$canondev/max_dir_size" ||
7512 LDPROC=/sys/fs/ldiskfs
7513 do_facet $facet "echo $1 >$LDPROC/$canondev/max_dir_size"
7518 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7519 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
7520 skip "Only applicable to ldiskfs-based MDTs"
7523 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7529 test_mkdir -p $DIR/$tdir
7533 while [ ! $I -gt $((MAX * MDSCOUNT)) ]; do
7534 $MULTIOP $DIR/$tdir/$J Oc
7536 if [ $rc -eq $EFBIG ]; then
7538 echo "return code $rc received as expected"
7540 elif [ $rc -ne 0 ]; then
7542 error_exit "return code $rc received instead of expected $EFBIG"
7545 I=$(stat -c%s "$DIR/$tdir")
7549 error "exceeded dir size limit $MAX x $MDSCOUNT $((MAX * MDSCOUNT)) : $I bytes"
7551 run_test 129 "test directory size limit ========================"
7560 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7561 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
7564 trap cleanup_130 EXIT RETURN
7566 local fm_file=$DIR/$tfile
7567 $SETSTRIPE -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
7568 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
7569 error "dd failed for $fm_file"
7571 # LU-1795: test filefrag/FIEMAP once, even if unsupported
7572 filefrag -ves $fm_file
7574 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
7575 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
7576 [ $RC != 0 ] && error "filefrag $fm_file failed"
7578 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
7579 grep -v "ext:" | grep -v "found")
7580 lun=$($GETSTRIPE -i $fm_file)
7582 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
7585 for line in $filefrag_op
7587 frag_lun=`echo $line | cut -d: -f5`
7588 ext_len=`echo $line | cut -d: -f4`
7589 if (( $frag_lun != $lun )); then
7591 error "FIEMAP on 1-stripe file($fm_file) failed"
7594 (( tot_len += ext_len ))
7597 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
7599 error "FIEMAP on 1-stripe file($fm_file) failed;"
7605 echo "FIEMAP on single striped file succeeded"
7607 run_test 130a "FIEMAP (1-stripe file)"
7610 [ "$OSTCOUNT" -lt "2" ] &&
7611 skip_env "skipping FIEMAP on 2-stripe file test" && return
7613 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7614 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
7617 trap cleanup_130 EXIT RETURN
7619 local fm_file=$DIR/$tfile
7620 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
7621 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
7622 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
7624 dd if=/dev/zero of=$fm_file bs=1M count=2 ||
7625 error "dd failed on $fm_file"
7627 filefrag -ves $fm_file || error "filefrag $fm_file failed"
7628 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
7629 grep -v "ext:" | grep -v "found")
7631 last_lun=$(echo $filefrag_op | cut -d: -f5)
7636 for line in $filefrag_op
7638 frag_lun=`echo $line | cut -d: -f5`
7639 ext_len=`echo $line | cut -d: -f4`
7640 if (( $frag_lun != $last_lun )); then
7641 if (( tot_len != 1024 )); then
7643 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 256"
7650 (( tot_len += ext_len ))
7653 if (( num_luns != 2 || tot_len != 1024 )); then
7655 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
7661 echo "FIEMAP on 2-stripe file succeeded"
7663 run_test 130b "FIEMAP (2-stripe file)"
7666 [ "$OSTCOUNT" -lt "2" ] &&
7667 skip_env "skipping FIEMAP on 2-stripe file" && return
7669 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7670 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
7673 trap cleanup_130 EXIT RETURN
7675 local fm_file=$DIR/$tfile
7676 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
7677 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
7678 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
7680 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 || error "dd failed on $fm_file"
7682 filefrag -ves $fm_file || error "filefrag $fm_file failed"
7683 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
7685 last_lun=`echo $filefrag_op | cut -d: -f5`
7690 for line in $filefrag_op
7692 frag_lun=`echo $line | cut -d: -f5`
7693 ext_len=`echo $line | cut -d: -f4`
7694 if (( $frag_lun != $last_lun )); then
7695 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
7696 if (( logical != 512 )); then
7698 error "FIEMAP on $fm_file failed; returned logical start for lun $logical instead of 512"
7701 if (( tot_len != 512 )); then
7703 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
7710 (( tot_len += ext_len ))
7713 if (( num_luns != 2 || tot_len != 512 )); then
7715 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
7721 echo "FIEMAP on 2-stripe file with hole succeeded"
7723 run_test 130c "FIEMAP (2-stripe file with hole)"
7726 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping FIEMAP on N-stripe file test" && return
7728 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7729 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
7731 trap cleanup_130 EXIT RETURN
7733 local fm_file=$DIR/$tfile
7734 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file||error "setstripe on $fm_file"
7735 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
7736 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
7737 dd if=/dev/zero of=$fm_file bs=1M count=$OSTCOUNT || error "dd failed on $fm_file"
7739 filefrag -ves $fm_file || error "filefrag $fm_file failed"
7740 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
7742 last_lun=`echo $filefrag_op | cut -d: -f5`
7747 for line in $filefrag_op
7749 frag_lun=`echo $line | cut -d: -f5`
7750 ext_len=`echo $line | cut -d: -f4`
7751 if (( $frag_lun != $last_lun )); then
7752 if (( tot_len != 1024 )); then
7754 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
7761 (( tot_len += ext_len ))
7764 if (( num_luns != OSTCOUNT || tot_len != 1024 )); then
7766 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
7772 echo "FIEMAP on N-stripe file succeeded"
7774 run_test 130d "FIEMAP (N-stripe file)"
7777 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping continuation FIEMAP test" && return
7779 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7780 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
7782 trap cleanup_130 EXIT RETURN
7784 local fm_file=$DIR/$tfile
7785 $SETSTRIPE -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
7786 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
7787 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
7790 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
7791 for ((i = 0; i < $NUM_BLKS; i++))
7793 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
7796 filefrag -ves $fm_file || error "filefrag $fm_file failed"
7797 filefrag_op=`filefrag -ve $fm_file | grep -A 12000 "ext:" | grep -v "ext:" | grep -v "found"`
7799 last_lun=`echo $filefrag_op | cut -d: -f5`
7804 for line in $filefrag_op
7806 frag_lun=`echo $line | cut -d: -f5`
7807 ext_len=`echo $line | cut -d: -f4`
7808 if (( $frag_lun != $last_lun )); then
7809 if (( tot_len != $EXPECTED_LEN )); then
7811 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of $EXPECTED_LEN"
7818 (( tot_len += ext_len ))
7821 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
7823 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
7829 echo "FIEMAP with continuation calls succeeded"
7831 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
7833 # Test for writev/readv
7835 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 || \
7836 error "writev test failed"
7837 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 || \
7838 error "readv failed"
7841 run_test 131a "test iov's crossing stripe boundary for writev/readv"
7844 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 || \
7845 error "append writev test failed"
7846 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 || \
7847 error "append writev test failed"
7850 run_test 131b "test append writev"
7853 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
7856 run_test 131c "test read/write on file w/o objects"
7859 rwv -f $DIR/$tfile -w -n 1 1572864
7860 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
7861 if [ "$NOB" != 1572864 ]; then
7862 error "Short read filed: read $NOB bytes instead of 1572864"
7866 run_test 131d "test short read"
7869 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
7870 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
7871 error "read hitting hole failed"
7874 run_test 131e "test read hitting hole"
7879 for node in $(osts_nodes); do
7880 gl=$(do_node $node "$LCTL get_param -n ost.OSS.ost.stats" | awk '/'$token'/ {print $2}' | head -n 1)
7881 [ x$gl = x"" ] && gl=0
7882 gl_sum=$((gl_sum + gl))
7892 if [ x$som = x"enabled" ]; then
7893 [ $((gl2 - gl1)) -gt 0 ] && error "no glimpse RPC is expected"
7894 MOUNTOPT=`echo $MOUNTOPT | sed 's/som_preview//g'`
7895 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=disabled"
7897 [ $((gl2 - gl1)) -gt 0 ] || error "some glimpse RPC is expected"
7898 MOUNTOPT="$MOUNTOPT,som_preview"
7899 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=enabled"
7902 # do remount to make new mount-conf parameters actual
7909 test_132() { #1028, SOM
7910 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7911 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7912 local num=$(get_mds_dir $DIR)
7913 local mymds=mds${num}
7914 local MOUNTOPT_SAVE=$MOUNTOPT
7916 dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
7917 cancel_lru_locks osc
7919 som1=$(do_facet $mymds "$LCTL get_param mdt.*.som" | awk -F= ' {print $2}' | head -n 1)
7921 gl1=$(get_ost_param "ldlm_glimpse_enqueue")
7922 stat $DIR/$tfile >/dev/null
7923 gl2=$(get_ost_param "ldlm_glimpse_enqueue")
7924 echo "====> SOM is "$som1", "$((gl2 - gl1))" glimpse RPC occured"
7926 som_mode_switch $som1 $gl1 $gl2
7928 dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
7929 cancel_lru_locks osc
7931 som2=$(do_facet $mymds "$LCTL get_param mdt.*.som" | awk -F= ' {print $2}' | head -n 1)
7932 if [ $som1 == $som2 ]; then
7933 error "som is still "$som2
7934 if [ x$som2 = x"enabled" ]; then
7941 gl1=$(get_ost_param "ldlm_glimpse_enqueue")
7942 stat $DIR/$tfile >/dev/null
7943 gl2=$(get_ost_param "ldlm_glimpse_enqueue")
7944 echo "====> SOM is "$som2", "$((gl2 - gl1))" glimpse RPC occured"
7945 som_mode_switch $som2 $gl1 $gl2
7946 MOUNTOPT=$MOUNTOPT_SAVE
7948 run_test 132 "som avoids glimpse rpc"
7954 $SINGLEMDS) res=`do_facet $SINGLEMDS $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$2"`
7956 ost) res=`do_facet ost1 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$2"`
7958 *) error "Wrong argument $1" ;;
7961 count=`echo $res | awk '{print $2}'`
7962 [ -z "$res" ] && error "The counter for $2 on $1 was not incremented"
7963 # if the argument $3 is zero, it means any stat increment is ok.
7964 if [ $3 -gt 0 ] ; then
7965 [ $count -ne $3 ] && error "The $2 counter on $1 is wrong - expected $3"
7970 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7971 remote_ost_nodsh && skip "remote OST with nodsh" && return
7972 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7974 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
7975 { skip "MDS doesn't support rename stats"; return; }
7976 local testdir=$DIR/${tdir}/stats_testdir
7977 mkdir -p $DIR/${tdir}
7980 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
7981 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
7983 # verify mdt stats first.
7984 mkdir ${testdir} || error "mkdir failed"
7985 check_stats $SINGLEMDS "mkdir" 1
7986 touch ${testdir}/${tfile} || "touch failed"
7987 check_stats $SINGLEMDS "open" 1
7988 check_stats $SINGLEMDS "close" 1
7989 mknod ${testdir}/${tfile}-pipe p || "mknod failed"
7990 check_stats $SINGLEMDS "mknod" 1
7991 rm -f ${testdir}/${tfile}-pipe || "pipe remove failed"
7992 check_stats $SINGLEMDS "unlink" 1
7993 rm -f ${testdir}/${tfile} || error "file remove failed"
7994 check_stats $SINGLEMDS "unlink" 2
7996 # remove working dir and check mdt stats again.
7997 rmdir ${testdir} || error "rmdir failed"
7998 check_stats $SINGLEMDS "rmdir" 1
8000 local testdir1=$DIR/${tdir}/stats_testdir1
8002 mkdir -p ${testdir1}
8003 touch ${testdir1}/test1
8004 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
8005 check_stats $SINGLEMDS "crossdir_rename" 1
8007 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
8008 check_stats $SINGLEMDS "samedir_rename" 1
8012 run_test 133a "Verifying MDT stats ========================================"
8015 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8016 remote_ost_nodsh && skip "remote OST with nodsh" && return
8017 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8018 local testdir=$DIR/${tdir}/stats_testdir
8019 mkdir -p ${testdir} || error "mkdir failed"
8020 touch ${testdir}/${tfile} || "touch failed"
8021 cancel_lru_locks mdc
8024 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8025 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
8027 # extra mdt stats verification.
8028 chmod 444 ${testdir}/${tfile} || error "chmod failed"
8029 check_stats $SINGLEMDS "setattr" 1
8030 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8031 if [ $(lustre_version_code $SINGLEMDS) -ne $(version_code 2.2.0) ]
8033 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
8034 check_stats $SINGLEMDS "getattr" 1
8036 $LFS df || error "lfs failed"
8037 check_stats $SINGLEMDS "statfs" 1
8041 run_test 133b "Verifying extra MDT stats =================================="
8044 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8045 remote_ost_nodsh && skip "remote OST with nodsh" && return
8046 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8047 local testdir=$DIR/${tdir}/stats_testdir
8048 test_mkdir -p ${testdir} || error "mkdir failed"
8050 # verify obdfilter stats.
8051 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
8053 cancel_lru_locks osc
8054 wait_delete_completed
8057 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8058 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
8060 dd if=/dev/zero of=${testdir}/${tfile} conv=notrunc bs=512k count=1 || error "dd failed"
8062 cancel_lru_locks osc
8063 check_stats ost "write" 1
8065 dd if=${testdir}/${tfile} of=/dev/null bs=1k count=1 || error "dd failed"
8066 check_stats ost "read" 1
8068 > ${testdir}/${tfile} || error "truncate failed"
8069 check_stats ost "punch" 1
8071 rm -f ${testdir}/${tfile} || error "file remove failed"
8072 wait_delete_completed
8073 check_stats ost "destroy" 1
8077 run_test 133c "Verifying OST stats ========================================"
8084 while [ $value -ge 2 ]; do
8089 if [ $orig -gt $order ]; then
8097 local size=('K' 'M' 'G' 'T');
8099 local size_string=$value
8101 while [ $value -ge 1024 ]; do
8102 if [ $i -gt 3 ]; then
8103 #T is the biggest unit we get here, if that is bigger,
8105 size_string=${value}T
8108 value=$((value >> 10))
8109 if [ $value -lt 1024 ]; then
8110 size_string=${value}${size[$i]}
8121 local context=${2:-.}
8122 local sample=$(do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats |
8124 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
8129 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8130 remote_ost_nodsh && skip "remote OST with nodsh" && return
8131 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8132 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
8133 { skip "MDS doesn't support rename stats"; return; }
8135 local testdir1=$DIR/${tdir}/stats_testdir1
8136 local testdir2=$DIR/${tdir}/stats_testdir2
8138 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
8140 test_mkdir -p ${testdir1} || error "mkdir failed"
8141 test_mkdir -p ${testdir2} || error "mkdir failed"
8143 createmany -o $testdir1/test 512 || error "createmany failed"
8145 # check samedir rename size
8146 mv ${testdir1}/test0 ${testdir1}/test_0
8148 local testdir1_size=$(ls -l $DIR/${tdir} |
8149 awk '/stats_testdir1/ {print $5}')
8150 local testdir2_size=$(ls -l $DIR/${tdir} |
8151 awk '/stats_testdir2/ {print $5}')
8153 testdir1_size=$(order_2 $testdir1_size)
8154 testdir2_size=$(order_2 $testdir2_size)
8156 testdir1_size=$(size_in_KMGT $testdir1_size)
8157 testdir2_size=$(size_in_KMGT $testdir2_size)
8159 echo "source rename dir size: ${testdir1_size}"
8160 echo "target rename dir size: ${testdir2_size}"
8162 local cmd="do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats"
8163 eval $cmd || error "$cmd failed"
8164 local samedir=$($cmd | grep 'same_dir')
8165 local same_sample=$(get_rename_size $testdir1_size)
8166 [ -z "$samedir" ] && error "samedir_rename_size count error"
8167 [ "$same_sample" -eq 1 ] || error "samedir_rename_size error $same_sample"
8168 echo "Check same dir rename stats success"
8170 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
8172 # check crossdir rename size
8173 mv ${testdir1}/test_0 ${testdir2}/test_0
8175 testdir1_size=$(ls -l $DIR/${tdir} |
8176 awk '/stats_testdir1/ {print $5}')
8177 testdir2_size=$(ls -l $DIR/${tdir} |
8178 awk '/stats_testdir2/ {print $5}')
8180 testdir1_size=$(order_2 $testdir1_size)
8181 testdir2_size=$(order_2 $testdir2_size)
8183 testdir1_size=$(size_in_KMGT $testdir1_size)
8184 testdir2_size=$(size_in_KMGT $testdir2_size)
8186 echo "source rename dir size: ${testdir1_size}"
8187 echo "target rename dir size: ${testdir2_size}"
8189 eval $cmd || error "$cmd failed"
8190 local crossdir=$($cmd | grep 'crossdir')
8191 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
8192 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
8193 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
8194 [ "$src_sample" -eq 1 ] || error "crossdir_rename_size error $src_sample"
8195 [ "$tgt_sample" -eq 1 ] || error "crossdir_rename_size error $tgt_sample"
8196 echo "Check cross dir rename stats success"
8199 run_test 133d "Verifying rename_stats ========================================"
8202 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8203 local testdir=$DIR/${tdir}/stats_testdir
8204 local ctr f0 f1 bs=32768 count=42 sum
8206 remote_ost_nodsh && skip "remote OST with nodsh" && return
8207 mkdir -p ${testdir} || error "mkdir failed"
8209 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
8211 for ctr in {write,read}_bytes; do
8213 cancel_lru_locks osc
8215 do_facet ost1 $LCTL set_param -n \
8216 "obdfilter.*.exports.clear=clear"
8218 if [ $ctr = write_bytes ]; then
8220 f1=${testdir}/${tfile}
8222 f0=${testdir}/${tfile}
8226 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
8229 cancel_lru_locks osc
8231 sum=$(do_facet ost1 $LCTL get_param \
8232 "obdfilter.*.exports.*.stats" | \
8235 $1 == ctr { sum += $7 }
8238 if ((sum != bs * count)); then
8239 error "Bad $ctr sum, expected $((bs * count)), got $sum"
8245 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
8247 test_140() { #bug-17379
8248 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8249 test_mkdir -p $DIR/$tdir || error "Creating dir $DIR/$tdir"
8250 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
8251 cp /usr/bin/stat . || error "Copying stat to $DIR/$tdir"
8253 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
8254 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
8256 while i=`expr $i + 1`; do
8257 test_mkdir -p $i || error "Creating dir $i"
8258 cd $i || error "Changing to $i"
8259 ln -s ../stat stat || error "Creating stat symlink"
8260 # Read the symlink until ELOOP present,
8261 # not LBUGing the system is considered success,
8262 # we didn't overrun the stack.
8263 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
8265 if [ $ret -eq 40 ]; then
8268 error "Open stat symlink"
8274 echo "The symlink depth = $i"
8275 [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 -o $i -eq 40 ] ||
8276 error "Invalid symlink depth"
8278 # Test recursive symlink
8279 ln -s symlink_self symlink_self
8280 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
8281 echo "open symlink_self returns $ret"
8282 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
8284 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
8287 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8288 local TF="$TMP/$tfile"
8290 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
8292 cancel_lru_locks osc
8293 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
8294 remount_client $MOUNT
8296 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
8299 $TRUNCATE $DIR/$tfile 6000
8300 cancel_lru_locks osc
8301 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
8304 echo "12345" >>$DIR/$tfile
8305 cancel_lru_locks osc
8306 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
8309 echo "12345" >>$DIR/$tfile
8310 cancel_lru_locks osc
8311 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
8316 run_test 150 "truncate/append tests"
8318 function roc_hit() {
8319 local list=$(comma_list $(osts_nodes))
8321 echo $(get_osd_param $list '' stats |
8322 awk '/'cache_hit'/ {sum+=$2} END {print sum}')
8325 function set_cache() {
8328 if [ "$2" == "off" ]; then
8331 local list=$(comma_list $(osts_nodes))
8332 set_osd_param $list '' $1_cache_enable $on
8334 cancel_lru_locks osc
8338 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8339 remote_ost_nodsh && skip "remote OST with nodsh" && return
8342 local list=$(comma_list $(osts_nodes))
8344 # check whether obdfilter is cache capable at all
8345 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
8346 echo "not cache-capable obdfilter"
8350 # check cache is enabled on all obdfilters
8351 if get_osd_param $list '' read_cache_enable | grep 0; then
8352 echo "oss cache is disabled"
8356 set_osd_param $list '' writethrough_cache_enable 1
8358 # pages should be in the case right after write
8359 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES || error "dd failed"
8360 local BEFORE=`roc_hit`
8361 cancel_lru_locks osc
8362 cat $DIR/$tfile >/dev/null
8363 local AFTER=`roc_hit`
8364 if ! let "AFTER - BEFORE == CPAGES"; then
8365 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
8368 # the following read invalidates the cache
8369 cancel_lru_locks osc
8370 set_osd_param $list '' read_cache_enable 0
8371 cat $DIR/$tfile >/dev/null
8373 # now data shouldn't be found in the cache
8375 cancel_lru_locks osc
8376 cat $DIR/$tfile >/dev/null
8378 if let "AFTER - BEFORE != 0"; then
8379 error "IN CACHE: before: $BEFORE, after: $AFTER"
8382 set_osd_param $list '' read_cache_enable 1
8385 run_test 151 "test cache on oss and controls ==============================="
8388 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8389 local TF="$TMP/$tfile"
8391 # simulate ENOMEM during write
8392 #define OBD_FAIL_OST_NOMEM 0x226
8393 lctl set_param fail_loc=0x80000226
8394 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
8396 sync || error "sync failed"
8397 lctl set_param fail_loc=0
8399 # discard client's cache
8400 cancel_lru_locks osc
8402 # simulate ENOMEM during read
8403 lctl set_param fail_loc=0x80000226
8404 cmp $TF $DIR/$tfile || error "cmp failed"
8405 lctl set_param fail_loc=0
8409 run_test 152 "test read/write with enomem ============================"
8412 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
8414 run_test 153 "test if fdatasync does not crash ======================="
8417 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8418 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
8419 { skip "Need MDS version at least 2.2.51"; return 0; }
8421 cp /etc/hosts $DIR/$tfile
8423 fid=$($LFS path2fid $DIR/$tfile)
8425 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
8427 ffid=$DIR/.lustre/fid/$fid
8429 echo "stat fid $fid"
8430 stat $ffid > /dev/null || error "stat $ffid failed."
8431 echo "touch fid $fid"
8432 touch $ffid || error "touch $ffid failed."
8433 echo "write to fid $fid"
8434 cat /etc/hosts > $ffid || error "write $ffid failed."
8435 echo "read fid $fid"
8436 diff /etc/hosts $ffid || error "read $ffid failed."
8437 echo "append write to fid $fid"
8438 cat /etc/hosts >> $ffid || error "append write $ffid failed."
8439 echo "rename fid $fid"
8440 mv $ffid $DIR/$tfile.1 && error "rename $ffid to $tfile.1 should fail."
8442 mv $DIR/$tfile.1 $ffid && error "rename $tfile.1 to $ffid should fail."
8444 echo "truncate fid $fid"
8445 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
8446 echo "link fid $fid"
8447 ln -f $ffid $DIR/tfile.lnk || error "link $ffid failed."
8448 if [ -n $(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl) ]; then
8449 echo "setfacl fid $fid"
8450 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
8451 echo "getfacl fid $fid"
8452 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
8454 echo "unlink fid $fid"
8455 unlink $DIR/.lustre/fid/$fid && error "unlink $ffid should fail."
8456 echo "mknod fid $fid"
8457 mknod $ffid c 1 3 && error "mknod $ffid should fail."
8459 fid=[0xf00000400:0x1:0x0]
8460 ffid=$DIR/.lustre/fid/$fid
8462 echo "stat non-exist fid $fid"
8463 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
8464 echo "write to non-exist fid $fid"
8465 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
8466 echo "link new fid $fid"
8467 ln $DIR/$tfile $ffid && error "link $ffid should fail."
8469 test_mkdir -p $DIR/$tdir
8470 touch $DIR/$tdir/$tfile
8471 fid=$($LFS path2fid $DIR/$tdir)
8473 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
8475 ffid=$DIR/.lustre/fid/$fid
8478 ls $ffid > /dev/null || error "ls $ffid failed."
8479 echo "touch $fid/$tfile.1"
8480 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
8482 echo "touch $DIR/.lustre/fid/$tfile"
8483 touch $DIR/.lustre/fid/$tfile && \
8484 error "touch $DIR/.lustre/fid/$tfile should fail."
8486 echo "setxattr to $DIR/.lustre/fid"
8487 setfattr -n trusted.name1 -v value1 $DIR/.lustre/fid &&
8488 error "setxattr should fail."
8490 echo "listxattr for $DIR/.lustre/fid"
8491 getfattr -d -m "^trusted" $DIR/.lustre/fid &&
8492 error "listxattr should fail."
8494 echo "delxattr from $DIR/.lustre/fid"
8495 setfattr -x trusted.name1 $DIR/.lustre/fid &&
8496 error "delxattr should fail."
8498 echo "touch invalid fid: $DIR/.lustre/fid/[0x200000400:0x2:0x3]"
8499 touch $DIR/.lustre/fid/[0x200000400:0x2:0x3] &&
8500 error "touch invalid fid should fail."
8502 echo "touch non-normal fid: $DIR/.lustre/fid/[0x1:0x2:0x0]"
8503 touch $DIR/.lustre/fid/[0x1:0x2:0x0] &&
8504 error "touch non-normal fid should fail."
8506 echo "rename $tdir to $DIR/.lustre/fid"
8507 mrename $DIR/$tdir $DIR/.lustre/fid &&
8508 error "rename to $DIR/.lustre/fid should fail."
8510 echo "rename .lustre to itself"
8511 fid=$($LFS path2fid $DIR)
8512 mrename $DIR/.lustre $DIR/.lustre/fid/$fid/.lustre &&
8513 error "rename .lustre to itself should fail."
8515 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $DIR/$tfile-2
8516 fid=$($LFS path2fid $DIR/$tfile-2)
8517 echo "cp /etc/passwd $DIR/.lustre/fid/$fid"
8518 cp /etc/passwd $DIR/.lustre/fid/$fid &&
8519 error "create lov data thru .lustre should fail."
8520 echo "cp /etc/passwd $DIR/$tfile-2"
8521 cp /etc/passwd $DIR/$tfile-2 || error "copy to $DIR/$tfile-2 failed."
8522 echo "diff /etc/passwd $DIR/.lustre/fid/$fid"
8523 diff /etc/passwd $DIR/.lustre/fid/$fid ||
8524 error "diff /etc/passwd $DIR/.lustre/fid/$fid failed."
8526 echo "Open-by-FID succeeded"
8528 run_test 154 "Open-by-FID"
8530 test_155_small_load() {
8531 local temp=$TMP/$tfile
8532 local file=$DIR/$tfile
8534 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
8535 error "dd of=$temp bs=6096 count=1 failed"
8537 cancel_lru_locks osc
8538 cmp $temp $file || error "$temp $file differ"
8540 $TRUNCATE $temp 6000
8541 $TRUNCATE $file 6000
8542 cmp $temp $file || error "$temp $file differ (truncate1)"
8544 echo "12345" >>$temp
8545 echo "12345" >>$file
8546 cmp $temp $file || error "$temp $file differ (append1)"
8548 echo "12345" >>$temp
8549 echo "12345" >>$file
8550 cmp $temp $file || error "$temp $file differ (append2)"
8556 test_155_big_load() {
8557 remote_ost_nodsh && skip "remote OST with nodsh" && return
8558 local temp=$TMP/$tfile
8559 local file=$DIR/$tfile
8562 local cache_size=$(do_facet ost$((MAXI+1)) \
8563 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
8564 local large_file_size=$((cache_size * 2))
8566 echo "OSS cache size: $cache_size KB"
8567 echo "Large file size: $large_file_size KB"
8569 [ $MAXV -le $large_file_size ] && \
8570 skip_env "max available OST size needs > $large_file_size KB" && \
8573 $SETSTRIPE $file -c 1 -i $MAXI || error "$SETSTRIPE $file failed"
8575 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k || \
8576 error "dd of=$temp bs=$large_file_size count=1k failed"
8579 cancel_lru_locks osc
8580 cmp $temp $file || error "$temp $file differ"
8587 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8589 set_cache writethrough on
8592 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
8595 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8597 set_cache writethrough off
8600 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
8603 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8605 set_cache writethrough on
8608 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
8611 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8613 set_cache writethrough off
8616 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
8619 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8621 set_cache writethrough on
8624 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
8627 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8629 set_cache writethrough off
8632 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
8635 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8637 set_cache writethrough on
8640 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
8643 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8645 set_cache writethrough off
8648 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
8651 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8655 local file="$DIR/$tfile"
8657 [ "$(facet_fstype ost1)" = "zfs" ] &&
8658 skip "LU-1956/LU-2261: stats unimplemented on OSD ZFS" &&
8661 log "Turn on read and write cache"
8663 set_cache writethrough on
8665 log "Write data and read it back."
8666 log "Read should be satisfied from the cache."
8667 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
8669 cancel_lru_locks osc
8670 cat $file >/dev/null
8672 if ! let "AFTER - BEFORE == CPAGES"; then
8673 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
8675 log "cache hits:: before: $BEFORE, after: $AFTER"
8678 log "Read again; it should be satisfied from the cache."
8680 cancel_lru_locks osc
8681 cat $file >/dev/null
8683 if ! let "AFTER - BEFORE == CPAGES"; then
8684 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
8686 log "cache hits:: before: $BEFORE, after: $AFTER"
8690 log "Turn off the read cache and turn on the write cache"
8692 set_cache writethrough on
8694 log "Read again; it should be satisfied from the cache."
8696 cancel_lru_locks osc
8697 cat $file >/dev/null
8699 if ! let "AFTER - BEFORE == CPAGES"; then
8700 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
8702 log "cache hits:: before: $BEFORE, after: $AFTER"
8705 log "Read again; it should not be satisfied from the cache."
8707 cancel_lru_locks osc
8708 cat $file >/dev/null
8710 if ! let "AFTER - BEFORE == 0"; then
8711 error "IN CACHE: before: $BEFORE, after: $AFTER"
8713 log "cache hits:: before: $BEFORE, after: $AFTER"
8716 log "Write data and read it back."
8717 log "Read should be satisfied from the cache."
8718 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
8720 cancel_lru_locks osc
8721 cat $file >/dev/null
8723 if ! let "AFTER - BEFORE == CPAGES"; then
8724 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
8726 log "cache hits:: before: $BEFORE, after: $AFTER"
8729 log "Read again; it should not be satisfied from the cache."
8731 cancel_lru_locks osc
8732 cat $file >/dev/null
8734 if ! let "AFTER - BEFORE == 0"; then
8735 error "IN CACHE: before: $BEFORE, after: $AFTER"
8737 log "cache hits:: before: $BEFORE, after: $AFTER"
8741 log "Turn off read and write cache"
8743 set_cache writethrough off
8745 log "Write data and read it back"
8746 log "It should not be satisfied from the cache."
8748 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
8749 cancel_lru_locks osc
8751 cat $file >/dev/null
8753 if ! let "AFTER - BEFORE == 0"; then
8754 error_ignore 20762 "IN CACHE: before: $BEFORE, after: $AFTER"
8756 log "cache hits:: before: $BEFORE, after: $AFTER"
8760 log "Turn on the read cache and turn off the write cache"
8762 set_cache writethrough off
8764 log "Write data and read it back"
8765 log "It should not be satisfied from the cache."
8767 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
8769 cancel_lru_locks osc
8770 cat $file >/dev/null
8772 if ! let "AFTER - BEFORE == 0"; then
8773 error_ignore 20762 "IN CACHE: before: $BEFORE, after: $AFTER"
8775 log "cache hits:: before: $BEFORE, after: $AFTER"
8778 log "Read again; it should be satisfied from the cache."
8780 cancel_lru_locks osc
8781 cat $file >/dev/null
8783 if ! let "AFTER - BEFORE == CPAGES"; then
8784 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
8786 log "cache hits:: before: $BEFORE, after: $AFTER"
8791 run_test 156 "Verification of tunables ============================"
8795 if [ $MDSCOUNT -gt 1 ]; then
8796 error_ignore 17935 $*
8804 MASK=$(do_facet $SINGLEMDS $LCTL get_param mdd.$MDT0.changelog_mask |\
8807 if [ $MASK -eq 1 ]; then
8808 do_facet $SINGLEMDS $LCTL set_param mdd.$MDT0.changelog_mask="-$1"
8810 do_facet $SINGLEMDS $LCTL set_param mdd.$MDT0.changelog_mask="+$1"
8815 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8816 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8817 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
8818 { skip "Need MDS version at least 2.2.0"; return; }
8819 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
8820 echo "Registered as changelog user $USER"
8821 do_facet $SINGLEMDS $LCTL get_param -n mdd.$MDT0.changelog_users | \
8822 grep -q $USER || error "User $USER not found in changelog_users"
8825 test_mkdir -p $DIR/$tdir/pics/2008/zachy
8826 touch $DIR/$tdir/pics/2008/zachy/timestamp
8827 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
8828 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
8829 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
8830 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
8831 rm $DIR/$tdir/pics/desktop.jpg
8833 $LFS changelog $MDT0 | tail -5
8835 echo "verifying changelog mask"
8836 changelog_chmask "MKDIR"
8837 changelog_chmask "CLOSE"
8839 test_mkdir -p $DIR/$tdir/pics/zach/sofia
8840 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
8842 changelog_chmask "MKDIR"
8843 changelog_chmask "CLOSE"
8845 test_mkdir -p $DIR/$tdir/pics/2008/sofia
8846 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
8848 $LFS changelog $MDT0
8849 MKDIRS=$($LFS changelog $MDT0 | tail -5 | grep -c "MKDIR")
8850 CLOSES=$($LFS changelog $MDT0 | tail -5 | grep -c "CLOSE")
8851 [ $MKDIRS -eq 1 ] || err17935 "MKDIR changelog mask count $DIRS != 1"
8852 [ $CLOSES -eq 1 ] || err17935 "CLOSE changelog mask count $DIRS != 1"
8855 echo "verifying target fid"
8856 fidc=$($LFS changelog $MDT0 | grep timestamp | grep "CREAT" | \
8857 tail -1 | awk '{print $6}')
8858 fidf=$($LFS path2fid $DIR/$tdir/pics/zach/timestamp)
8859 [ "$fidc" == "t=$fidf" ] || \
8860 err17935 "fid in changelog $fidc != file fid $fidf"
8861 echo "verifying parent fid"
8862 fidc=$($LFS changelog $MDT0 | grep timestamp | grep "CREAT" | \
8863 tail -1 | awk '{print $7}')
8864 fidf=$($LFS path2fid $DIR/$tdir/pics/zach)
8865 [ "$fidc" == "p=$fidf" ] || \
8866 err17935 "pfid in changelog $fidc != dir fid $fidf"
8868 USER_REC1=$(do_facet $SINGLEMDS $LCTL get_param -n \
8869 mdd.$MDT0.changelog_users | grep $USER | awk '{print $2}')
8870 $LFS changelog_clear $MDT0 $USER $(($USER_REC1 + 5))
8871 USER_REC2=$(do_facet $SINGLEMDS $LCTL get_param -n \
8872 mdd.$MDT0.changelog_users | grep $USER | awk '{print $2}')
8873 echo "verifying user clear: $(( $USER_REC1 + 5 )) == $USER_REC2"
8874 [ $USER_REC2 == $(($USER_REC1 + 5)) ] || \
8875 err17935 "user index should be $(($USER_REC1 + 5)); is $USER_REC2"
8877 MIN_REC=$(do_facet $SINGLEMDS $LCTL get_param mdd.$MDT0.changelog_users | \
8878 awk 'min == "" || $2 < min {min = $2}; END {print min}')
8879 FIRST_REC=$($LFS changelog $MDT0 | head -1 | awk '{print $1}')
8880 echo "verifying min purge: $(( $MIN_REC + 1 )) == $FIRST_REC"
8881 [ $FIRST_REC == $(($MIN_REC + 1)) ] || \
8882 err17935 "first index should be $(($MIN_REC + 1)); is $FIRST_REC"
8884 echo "verifying user deregister"
8885 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
8886 do_facet $SINGLEMDS $LCTL get_param -n mdd.$MDT0.changelog_users | \
8887 grep -q $USER && error "User $USER still found in changelog_users"
8889 USERS=$(( $(do_facet $SINGLEMDS $LCTL get_param -n \
8890 mdd.$MDT0.changelog_users | wc -l) - 2 ))
8891 if [ $USERS -eq 0 ]; then
8892 LAST_REC1=$(do_facet $SINGLEMDS $LCTL get_param -n \
8893 mdd.$MDT0.changelog_users | head -1 | awk '{print $3}')
8894 touch $DIR/$tdir/chloe
8895 LAST_REC2=$(do_facet $SINGLEMDS $LCTL get_param -n \
8896 mdd.$MDT0.changelog_users | head -1 | awk '{print $3}')
8897 echo "verify changelogs are off if we were the only user: $LAST_REC1 == $LAST_REC2"
8898 [ $LAST_REC1 == $LAST_REC2 ] || error "changelogs not off"
8900 echo "$USERS other changelog users; can't verify off"
8903 run_test 160 "changelog sanity"
8906 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8907 test_mkdir -p $DIR/$tdir
8908 cp /etc/hosts $DIR/$tdir/$tfile
8909 test_mkdir $DIR/$tdir/foo1
8910 test_mkdir $DIR/$tdir/foo2
8911 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
8912 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
8913 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
8914 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
8915 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[')
8916 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
8917 $LFS fid2path $DIR $FID
8918 err17935 "bad link ea"
8921 rm $DIR/$tdir/foo2/zachary
8923 rm $DIR/$tdir/foo2/thor
8925 rm $DIR/$tdir/$tfile
8927 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
8928 if [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ]
8930 $LFS fid2path $DIR $FID
8931 err17935 "bad link rename"
8933 rm $DIR/$tdir/foo2/maggie
8936 local longname=filename_avg_len_is_thirty_two_
8937 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 || \
8938 error "failed to hardlink many files"
8939 links=$($LFS fid2path $DIR $FID | wc -l)
8940 echo -n "${links}/1000 links in link EA"
8941 [ ${links} -gt 60 ] || err17935 "expected at least 60 links in link EA"
8942 unlinkmany $DIR/$tdir/foo2/$longname 1000 || \
8943 error "failed to unlink many hardlinks"
8945 run_test 161 "link ea sanity"
8952 local path=$(${LFS} fid2path $*)
8955 if [ $RC -ne 0 ]; then
8956 err17935 "path looked up of $expected failed. Error $RC"
8958 elif [ "${path}" != "${expected}" ]; then
8959 err17935 "path looked up \"${path}\" instead of \"${expected}\""
8962 echo "fid $fid resolves to path $path (expected $expected)"
8966 # Make changes to filesystem
8967 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8968 test_mkdir -p $DIR/$tdir/d2
8969 touch $DIR/$tdir/d2/$tfile
8970 touch $DIR/$tdir/d2/x1
8971 touch $DIR/$tdir/d2/x2
8972 test_mkdir -p $DIR/$tdir/d2/a/b/c
8973 test_mkdir -p $DIR/$tdir/d2/p/q/r
8975 FID=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
8976 check_path "$tdir/d2/$tfile" $FSNAME $FID --link 0
8979 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
8980 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
8981 check_path "$tdir/d2/p/q/r/slink" $FSNAME $FID --link 0
8983 # softlink to wrong file
8984 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
8985 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
8986 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME $FID --link 0
8989 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
8990 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
8991 FID=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
8992 # fid2path dir/fsname should both work
8993 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 1
8994 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR $FID --link 0
8996 # hardlink count: check that there are 2 links
8997 # Doesnt work with CMD yet: 17935
8998 ${LFS} fid2path $DIR $FID | wc -l | grep -q 2 || \
8999 err17935 "expected 2 links"
9001 # hardlink indexing: remove the first link
9002 rm $DIR/$tdir/d2/p/q/r/hlink
9003 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 0
9007 run_test 162 "path lookup sanity"
9010 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9011 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9012 copytool --test $FSNAME || { skip "copytool not runnable: $?" && return; }
9015 local uuid=$($LCTL get_param -n mdc.${FSNAME}-MDT0000-mdc-*.uuid)
9016 # this proc file is temporary and linux-only
9017 do_facet $SINGLEMDS lctl set_param mdt.${FSNAME}-MDT0000.mdccomm=$uuid ||\
9018 error "kernel->userspace send failed"
9021 run_test 163 "kernel <-> userspace comms"
9024 # do directio so as not to populate the page cache
9025 log "creating a 10 Mb file"
9026 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
9027 log "starting reads"
9028 dd if=$DIR/$tfile of=/dev/null bs=4096 &
9029 log "truncating the file"
9030 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
9032 kill %+ || true # reads might have finished
9033 echo "wait until dd is finished"
9035 log "removing the temporary file"
9036 rm -rf $DIR/$tfile || error "tmp file removal failed"
9038 run_test 169 "parallel read and truncate should not deadlock"
9041 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9042 $LCTL clear # bug 18514
9043 $LCTL debug_daemon start $TMP/${tfile}_log_good
9045 $LCTL debug_daemon stop
9046 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
9047 error "sed failed to read log_good"
9049 $LCTL debug_daemon start $TMP/${tfile}_log_good
9051 $LCTL debug_daemon stop
9053 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
9054 error "lctl df log_bad failed"
9056 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
9057 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
9059 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
9060 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
9062 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
9063 error "bad_line good_line1 good_line2 are empty"
9065 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
9066 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
9067 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
9069 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
9070 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
9071 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
9073 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
9074 error "bad_line_new good_line_new are empty"
9076 local expected_good=$((good_line1 + good_line2*2))
9078 rm -f $TMP/${tfile}*
9079 # LU-231, short malformed line may not be counted into bad lines
9080 if [ $bad_line -ne $bad_line_new ] &&
9081 [ $bad_line -ne $((bad_line_new - 1)) ]; then
9082 error "expected $bad_line bad lines, but got $bad_line_new"
9086 if [ $expected_good -ne $good_line_new ]; then
9087 error "expected $expected_good good lines, but got $good_line_new"
9092 run_test 170 "test lctl df to handle corrupted log ====================="
9094 test_171() { # bug20592
9095 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9096 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
9097 $LCTL set_param fail_loc=0x50e
9098 $LCTL set_param fail_val=3000
9099 multiop_bg_pause $DIR/$tfile O_s || true
9101 kill -USR1 $MULTIPID
9105 if dmesg | grep "recursive fault"; then
9106 error "caught a recursive fault"
9108 $LCTL set_param fail_loc=0
9111 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
9113 # it would be good to share it with obdfilter-survey/libecho code
9114 setup_obdecho_osc () {
9117 local obdfilter_name=$2
9118 echo "Creating new osc for $obdfilter_name on $ost_nid"
9119 # make sure we can find loopback nid
9120 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
9122 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
9123 ${obdfilter_name}_osc_UUID || rc=2; }
9124 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
9125 ${obdfilter_name}_UUID $ost_nid || rc=3; }
9129 cleanup_obdecho_osc () {
9130 local obdfilter_name=$1
9131 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
9132 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
9136 obdecho_create_test() {
9141 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
9142 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
9144 if [ $rc -eq 0 ]; then
9145 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
9146 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
9148 echo "New object id is $id"
9149 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec test_brw 10 w v 64 $id" ||
9151 [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec " \
9152 "cleanup" || rc=5; }
9153 [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec " \
9155 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
9160 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9161 remote_ost_nodsh && skip "remote OST with nodsh" && return
9165 if ! module_loaded obdecho; then
9166 load_module obdecho/obdecho
9170 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
9171 local host=$(lctl get_param -n osc.$osc.import |
9172 awk '/current_connection:/ {print $2}' )
9173 local target=$(lctl get_param -n osc.$osc.import |
9174 awk '/target:/ {print $2}' )
9175 target=${target%_UUID}
9177 [[ -n $target ]] && { setup_obdecho_osc $host $target || rc=1; } || rc=1
9178 [ $rc -eq 0 ] && { obdecho_create_test ${target}_osc client || rc=2; }
9179 [[ -n $target ]] && cleanup_obdecho_osc $target
9180 [ $rmmod_local -eq 1 ] && rmmod obdecho
9183 run_test 180a "test obdecho on osc"
9186 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9187 remote_ost_nodsh && skip "remote OST with nodsh" && return
9189 local rmmod_remote=0
9191 do_facet ost1 "lsmod | grep -q obdecho || " \
9192 "{ insmod ${LUSTRE}/obdecho/obdecho.ko || " \
9193 "modprobe obdecho; }" && rmmod_remote=1
9194 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ {print $4;exit}')
9195 [[ -n $target ]] && { obdecho_create_test $target ost1 || rc=1; }
9196 [ $rmmod_remote -eq 1 ] && do_facet ost1 "rmmod obdecho"
9199 run_test 180b "test obdecho directly on obdfilter"
9201 test_181() { # bug 22177
9202 test_mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
9203 # create enough files to index the directory
9204 createmany -o $DIR/$tdir/foobar 4000
9205 # print attributes for debug purpose
9208 multiop_bg_pause $DIR/$tdir D_Sc || return 1
9210 # remove the files & current working dir
9211 unlinkmany $DIR/$tdir/foobar 4000
9213 kill -USR1 $MULTIPID
9215 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
9218 run_test 181 "Test open-unlinked dir ========================"
9221 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9222 # disable MDC RPC lock wouldn't crash client
9226 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
9227 #define OBD_FAIL_MDC_RPCS_SEM 0x804
9228 $LCTL set_param fail_loc=0x804
9230 for (( i=0; i < $tcount; i++ )) ; do
9232 createmany -o $DIR/$tdir/$i/f- $fcount &
9236 for (( i=0; i < $tcount; i++ )) ; do
9237 unlinkmany $DIR/$tdir/$i/f- $fcount &
9243 $LCTL set_param fail_loc=0
9245 run_test 182 "Disable MDC RPCs semaphore wouldn't crash client ================"
9247 test_183() { # LU-2275
9248 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9249 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
9250 echo aaa > $DIR/$tdir/$tfile
9252 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
9253 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
9255 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
9256 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
9258 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
9260 # Flush negative dentry cache
9261 touch $DIR/$tdir/$tfile
9263 # We are not checking for any leaked references here, they'll
9264 # become evident next time we do cleanup with module unload.
9267 run_test 183 "No crash or request leak in case of strange dispositions ========"
9269 test_185() { # LU-2441
9270 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
9271 touch $DIR/$tdir/spoo
9272 local mtime1=$(stat -c "%Y" $DIR/$tdir)
9273 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
9274 error "cannot create/write a volatile file"
9275 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
9276 error "FID is still valid after close"
9278 multiop_bg_pause $DIR/$tdir vVw4096_c
9285 # assume that the next FID for this client is sequential, since stdout
9286 # is unfortunately eaten by multiop_bg_pause
9287 local n=$((${fidv[1]} + 1))
9288 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
9289 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
9290 error "FID is missing before close"
9291 kill -USR1 $multi_pid
9292 # 1 second delay, so if mtime change we will see it
9294 local mtime2=$(stat -c "%Y" $DIR/$tdir)
9295 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
9297 run_test 185 "Volatile file support"
9300 check_file_in_pool()
9305 local res=$($GETSTRIPE $file | grep 0x | cut -f2)
9308 for t in $tlist ; do
9309 [ "$i" -eq "$t" ] && continue 2
9312 echo "pool list: $tlist"
9313 echo "striping: $res"
9314 error_noexit "$file not allocated in $pool"
9321 echo "Creating new pool"
9324 create_pool $FSNAME.$pool ||
9325 { error_noexit "No pool created, result code $?"; return 1; }
9326 [ $($LFS pool_list $FSNAME | grep -c $pool) -eq 1 ] ||
9327 { error_noexit "$pool not in lfs pool_list"; return 2; }
9330 pool_add_targets() {
9331 echo "Adding targets to pool"
9337 local list=$(seq $first $step $last)
9339 local t=$(for i in $list; do printf "$FSNAME-OST%04x_UUID " $i; done)
9340 do_facet mgs $LCTL pool_add \
9341 $FSNAME.$pool $FSNAME-OST[$first-$last/$step]
9342 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$pool \
9343 | sort -u | tr '\n' ' ' " "$t" || {
9344 error_noexit "Add to pool failed"
9347 local lfscount=$($LFS pool_list $FSNAME.$pool | grep -c "\-OST")
9348 local addcount=$(((last - first) / step + 1))
9349 [ $lfscount -eq $addcount ] || {
9350 error_noexit "lfs pool_list bad ost count" \
9351 "$lfscount != $addcount"
9359 echo "Setting pool on directory $tdir"
9361 $SETSTRIPE -c 2 -p $pool $tdir && return 0
9363 error_noexit "Cannot set pool $pool to $tdir"
9370 echo "Checking pool on directory $tdir"
9372 local res=$($GETSTRIPE --pool $tdir | sed "s/\s*$//")
9373 [ "$res" = "$pool" ] && return 0
9375 error_noexit "Pool on '$tdir' is '$res', not '$pool'"
9379 pool_dir_rel_path() {
9380 echo "Testing relative path works well"
9385 mkdir -p $root/$tdir/$tdir
9387 pool_set_dir $pool $tdir || return 1
9388 pool_set_dir $pool ./$tdir || return 2
9389 pool_set_dir $pool ../$tdir || return 3
9390 pool_set_dir $pool ../$tdir/$tdir || return 4
9391 rm -rf $tdir; cd - > /dev/null
9394 pool_alloc_files() {
9395 echo "Checking files allocation from directory pool"
9402 for i in $(seq -w 1 $count)
9404 local file=$tdir/file-$i
9406 check_file_in_pool $file $pool "$tlist" || \
9407 failed=$((failed + 1))
9409 [ "$failed" = 0 ] && return 0
9411 error_noexit "$failed files not allocated in $pool"
9415 pool_create_files() {
9416 echo "Creating files in pool"
9424 for i in $(seq -w 1 $count)
9426 local file=$tdir/spoo-$i
9427 $SETSTRIPE -p $pool $file
9428 check_file_in_pool $file $pool "$tlist" || \
9429 failed=$((failed + 1))
9431 [ "$failed" = 0 ] && return 0
9433 error_noexit "$failed files not allocated in $pool"
9438 echo "Checking 'lfs df' output"
9441 local t=$($LCTL get_param -n lov.$FSNAME-clilov-*.pools.$pool |
9443 local res=$($LFS df --pool $FSNAME.$pool |
9445 grep "$FSNAME-OST" |
9447 [ "$res" = "$t" ] && return 0
9449 error_noexit "Pools OSTs '$t' is not '$res' that lfs df reports"
9453 pool_file_rel_path() {
9454 echo "Creating files in a pool with relative pathname"
9459 { error_noexit "unable to create $tdir"; return 1 ; }
9460 local file="/..$tdir/$tfile-1"
9461 $SETSTRIPE -p $pool $file ||
9462 { error_noexit "unable to create $file" ; return 2 ; }
9465 $SETSTRIPE -p $pool $tfile-2 || {
9466 error_noexit "unable to create $tfile-2 in $tdir"
9471 pool_remove_first_target() {
9472 echo "Removing first target from a pool"
9475 local pname="lov.$FSNAME-*.pools.$pool"
9476 local t=$($LCTL get_param -n $pname | head -1)
9477 do_facet mgs $LCTL pool_remove $FSNAME.$pool $t
9478 wait_update $HOSTNAME "lctl get_param -n $pname | grep $t" "" || {
9479 error_noexit "$t not removed from $FSNAME.$pool"
9484 pool_remove_all_targets() {
9485 echo "Removing all targets from pool"
9488 local pname="lov.$FSNAME-*.pools.$pool"
9489 for t in $($LCTL get_param -n $pname | sort -u)
9491 do_facet mgs $LCTL pool_remove $FSNAME.$pool $t
9493 wait_update $HOSTNAME "lctl get_param -n $pname" "" || {
9494 error_noexit "Pool $FSNAME.$pool cannot be drained"
9497 # striping on an empty/nonexistant pool should fall back
9498 # to "pool of everything"
9500 error_noexit "failed to use fallback striping for empty pool"
9503 # setstripe on an empty pool should fail
9504 $SETSTRIPE -p $pool $file 2>/dev/null && {
9505 error_noexit "expected failure when creating file" \
9513 echo "Destroying pool"
9517 do_facet mgs $LCTL pool_destroy $FSNAME.$pool
9520 # striping on an empty/nonexistant pool should fall back
9521 # to "pool of everything"
9523 error_noexit "failed to use fallback striping for missing pool"
9526 # setstripe on an empty pool should fail
9527 $SETSTRIPE -p $pool $file 2>/dev/null && {
9528 error_noexit "expected failure when creating file" \
9533 # get param should return err once pool is gone
9534 if wait_update $HOSTNAME "lctl get_param -n \
9535 lov.$FSNAME-*.pools.$pool 2>/dev/null || echo foo" "foo"
9537 remove_pool_from_list $FSNAME.$pool
9540 error_noexit "Pool $FSNAME.$pool is not destroyed"
9545 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9546 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
9548 local POOL=${POOL:-cea1}
9549 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
9550 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
9553 local last_ost=$(($OSTCOUNT - 1))
9555 local ost_list=$(seq $first_ost $ost_step $last_ost)
9556 local ost_range="$first_ost $last_ost $ost_step"
9557 local test_path=$POOL_ROOT/$POOL_DIR_NAME
9558 local file_dir=$POOL_ROOT/file_tst
9562 # former test_200a test_200b
9563 pool_add $POOL || { rc=$? ; break; }
9564 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
9565 # former test_200c test_200d
9567 pool_set_dir $POOL $test_path || { rc=$? ; break; }
9568 pool_check_dir $POOL $test_path || { rc=$? ; break; }
9569 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
9570 || { rc=$? ; break; }
9571 # former test_200e test_200f
9572 local files=$((OSTCOUNT*3))
9573 pool_alloc_files $POOL $test_path $files "$ost_list" \
9574 || { rc=$? ; break; }
9575 pool_create_files $POOL $file_dir $files "$ost_list" \
9576 || { rc=$? ; break; }
9577 # former test_200g test_200h
9578 pool_lfs_df $POOL || { rc=$? ; break; }
9579 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
9581 # former test_201a test_201b test_201c
9582 pool_remove_first_target $POOL || { rc=$? ; break; }
9584 local f=$test_path/$tfile
9585 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
9586 pool_remove $POOL $f || { rc=$? ; break; }
9593 run_test 200 "OST pools"
9595 # usage: default_attr <count | size | offset>
9597 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
9600 # usage: check_default_stripe_attr
9601 check_default_stripe_attr() {
9602 ACTUAL=$($GETSTRIPE $* $DIR/$tdir)
9604 --stripe-count|--count)
9605 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
9606 --stripe-size|--size)
9607 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
9608 --stripe-index|--index)
9611 error "unknown getstripe attr '$1'"
9614 [ $ACTUAL != $EXPECTED ] &&
9615 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
9619 test_mkdir -p $DIR/$tdir
9620 $SETSTRIPE --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
9622 check_default_stripe_attr --stripe-count
9623 check_default_stripe_attr --stripe-size
9624 check_default_stripe_attr --stripe-index
9628 run_test 204a "Print default stripe attributes ================="
9631 test_mkdir -p $DIR/$tdir
9632 $SETSTRIPE --stripe-count 1 $DIR/$tdir
9634 check_default_stripe_attr --stripe-size
9635 check_default_stripe_attr --stripe-index
9639 run_test 204b "Print default stripe size and offset ==========="
9642 test_mkdir -p $DIR/$tdir
9643 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
9645 check_default_stripe_attr --stripe-count
9646 check_default_stripe_attr --stripe-index
9650 run_test 204c "Print default stripe count and offset ==========="
9653 test_mkdir -p $DIR/$tdir
9654 $SETSTRIPE --stripe-index 0 $DIR/$tdir
9656 check_default_stripe_attr --stripe-count
9657 check_default_stripe_attr --stripe-size
9661 run_test 204d "Print default stripe count and size ============="
9664 test_mkdir -p $DIR/$tdir
9665 $SETSTRIPE -d $DIR/$tdir
9667 check_default_stripe_attr --stripe-count --raw
9668 check_default_stripe_attr --stripe-size --raw
9669 check_default_stripe_attr --stripe-index --raw
9673 run_test 204e "Print raw stripe attributes ================="
9676 test_mkdir -p $DIR/$tdir
9677 $SETSTRIPE --stripe-count 1 $DIR/$tdir
9679 check_default_stripe_attr --stripe-size --raw
9680 check_default_stripe_attr --stripe-index --raw
9684 run_test 204f "Print raw stripe size and offset ==========="
9687 test_mkdir -p $DIR/$tdir
9688 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
9690 check_default_stripe_attr --stripe-count --raw
9691 check_default_stripe_attr --stripe-index --raw
9695 run_test 204g "Print raw stripe count and offset ==========="
9698 test_mkdir -p $DIR/$tdir
9699 $SETSTRIPE --stripe-index 0 $DIR/$tdir
9701 check_default_stripe_attr --stripe-count --raw
9702 check_default_stripe_attr --stripe-size --raw
9706 run_test 204h "Print raw stripe count and size ============="
9708 # Figure out which job scheduler is being used, if any,
9710 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
9712 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
9714 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
9716 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
9717 JOBENV=LOADL_STEP_ID
9718 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
9728 # clear old jobstats
9729 do_facet $SINGLEMDS lctl set_param mdt.*.job_stats="clear"
9730 do_facet ost1 lctl set_param obdfilter.*.job_stats="clear"
9732 # use a new JobID for this test, or we might see an old one
9733 [ "$JOBENV" = "FAKE_JOBID" ] && FAKE_JOBID=test_id.$testnum.$RANDOM
9737 log "Using JobID environment variable $JOBENV=$JOBVAL"
9739 if [ $JOBENV = "FAKE_JOBID" ]; then
9740 FAKE_JOBID=$JOBVAL $cmd
9745 if [ "$target" = "mdt" -o "$target" = "both" ]; then
9746 FACET="$SINGLEMDS" # will need to get MDS number for DNE
9747 do_facet $FACET lctl get_param mdt.*.job_stats |
9748 grep $JOBVAL || error "No job stats found on MDT $FACET"
9750 if [ "$target" = "ost" -o "$target" = "both" ]; then
9752 do_facet $FACET lctl get_param obdfilter.*.job_stats |
9753 grep $JOBVAL || error "No job stats found on OST $FACET"
9757 test_205() { # Job stats
9758 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9759 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
9760 skip "Server doesn't support jobstats" && return 0
9763 OLD_JOBENV=`$LCTL get_param -n jobid_var`
9764 if [ $OLD_JOBENV != $JOBENV ]; then
9765 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$JOBENV
9766 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" \
9771 cmd="mkdir $DIR/$tfile"
9772 verify_jobstats "$cmd" "mdt"
9774 cmd="rm -fr $DIR/$tfile"
9775 verify_jobstats "$cmd" "mdt"
9777 cmd="mknod $DIR/$tfile c 1 3"
9778 verify_jobstats "$cmd" "mdt"
9780 cmd="rm -f $DIR/$tfile"
9781 verify_jobstats "$cmd" "mdt"
9783 cmd="$SETSTRIPE -i 0 -c 1 $DIR/$tfile"
9784 verify_jobstats "$cmd" "mdt"
9786 cmd="touch $DIR/$tfile"
9787 verify_jobstats "$cmd" "both"
9789 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
9790 verify_jobstats "$cmd" "ost"
9792 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
9793 verify_jobstats "$cmd" "ost"
9795 cmd="$TRUNCATE $DIR/$tfile 0"
9796 verify_jobstats "$cmd" "both"
9798 cmd="mv -f $DIR/$tfile $DIR/jobstats_test_rename"
9799 verify_jobstats "$cmd" "mdt"
9802 rm -f $DIR/jobstats_test_rename
9804 if [ $OLD_JOBENV != $JOBENV ]; then
9805 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$OLD_JOBENV
9806 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" \
9807 $OLD_JOBENV || return 1
9810 run_test 205 "Verify job stats"
9812 # LU-1480, LU-1773 and LU-1657
9815 lfs setstripe -c -1 $DIR/$tdir
9816 #define OBD_FAIL_LOV_INIT 0x1403
9817 $LCTL set_param fail_loc=0xa0001403
9818 $LCTL set_param fail_val=1
9819 touch $DIR/$tdir/$tfile || true
9821 run_test 206 "fail lov_init_raid0() doesn't lbug"
9824 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
9825 local fsz=`stat -c %s $DIR/$tfile`
9826 cancel_lru_locks mdc
9828 # do not return layout in getattr intent
9829 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
9830 $LCTL set_param fail_loc=0x170
9831 local sz=`stat -c %s $DIR/$tfile`
9833 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
9837 run_test 207a "can refresh layout at glimpse"
9840 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
9841 local cksum=`md5sum $DIR/$tfile`
9842 local fsz=`stat -c %s $DIR/$tfile`
9843 cancel_lru_locks mdc
9844 cancel_lru_locks osc
9846 # do not return layout in getattr intent
9847 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
9848 $LCTL set_param fail_loc=0x171
9850 # it will refresh layout after the file is opened but before read issues
9851 echo checksum is "$cksum"
9852 echo "$cksum" |md5sum -c --quiet || error "file differs"
9856 run_test 207b "can refresh layout at open"
9860 size=$((size % 8192 + 1))
9861 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
9862 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
9863 rm -f $DIR/f212 $DIR/f212.xyz
9865 run_test 212 "Sendfile test ============================================"
9868 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
9869 cancel_lru_locks osc
9870 lctl set_param fail_loc=0x8000040f
9871 # generate a read lock
9872 cat $DIR/$tfile > /dev/null
9873 # write to the file, it will try to cancel the above read lock.
9874 cat /etc/hosts >> $DIR/$tfile
9876 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
9878 test_214() { # for bug 20133
9879 test_mkdir -p $DIR/d214p/d214c
9880 for (( i=0; i < 340; i++ )) ; do
9881 touch $DIR/d214p/d214c/a$i
9884 ls -l $DIR/d214p || error "ls -l $DIR/d214p failed"
9885 mv $DIR/d214p/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
9886 ls $DIR/d214c || error "ls $DIR/d214c failed"
9887 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
9889 run_test 214 "hash-indexed directory test - bug 20133"
9891 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
9892 create_lnet_proc_files() {
9893 cat /proc/sys/lnet/$1 >$TMP/lnet_$1.out || error "cannot read /proc/sys/lnet/$1"
9894 sysctl lnet.$1 >$TMP/lnet_$1.sys_tmp || error "cannot read lnet.$1"
9896 sed "s/^lnet.$1\ =\ //g" "$TMP/lnet_$1.sys_tmp" >$TMP/lnet_$1.sys
9897 rm -f "$TMP/lnet_$1.sys_tmp"
9900 # counterpart of create_lnet_proc_files
9901 remove_lnet_proc_files() {
9902 rm -f $TMP/lnet_$1.out $TMP/lnet_$1.sys
9905 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
9906 # 3rd arg as regexp for body
9907 check_lnet_proc_stats() {
9908 local l=$(cat "$TMP/lnet_$1" |wc -l)
9909 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
9911 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
9914 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
9915 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
9916 # optional and can be regexp for 2nd line (lnet.routes case)
9917 check_lnet_proc_entry() {
9918 local blp=2 # blp stands for 'position of 1st line of body'
9919 [ "$5" = "" ] || blp=3 # lnet.routes case
9921 local l=$(cat "$TMP/lnet_$1" |wc -l)
9922 # subtracting one from $blp because the body can be empty
9923 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
9925 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
9926 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
9928 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
9929 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
9931 # bail out if any unexpected line happened
9932 sed -n "$blp~1 p" "$TMP/lnet_$1" |grep -Ev "$3"
9933 [ "$?" != 0 ] || error "$2 misformatted"
9936 test_215() { # for bugs 18102, 21079, 21517
9937 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9938 local N='(0|[1-9][0-9]*)' # non-negative numeric
9939 local P='[1-9][0-9]*' # positive numeric
9940 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
9941 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
9942 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
9943 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
9945 local L1 # regexp for 1st line
9946 local L2 # regexp for 2nd line (optional)
9947 local BR # regexp for the rest (body)
9949 # /proc/sys/lnet/stats should look as 11 space-separated non-negative numerics
9950 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
9951 create_lnet_proc_files "stats"
9952 check_lnet_proc_stats "stats.out" "/proc/sys/lnet/stats" "$BR"
9953 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
9954 remove_lnet_proc_files "stats"
9956 # /proc/sys/lnet/routes should look like this:
9957 # Routing disabled/enabled
9958 # net hops state router
9959 # where net is a string like tcp0, hops >= 0, state is up/down,
9960 # router is a string like 192.168.1.1@tcp2
9961 L1="^Routing (disabled|enabled)$"
9962 L2="^net +hops +state +router$"
9963 BR="^$NET +$N +(up|down) +$NID$"
9964 create_lnet_proc_files "routes"
9965 check_lnet_proc_entry "routes.out" "/proc/sys/lnet/routes" "$BR" "$L1" "$L2"
9966 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
9967 remove_lnet_proc_files "routes"
9969 # /proc/sys/lnet/routers should look like this:
9970 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
9971 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
9972 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
9973 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
9974 L1="^ref +rtr_ref +alive_cnt +state +last_ping +ping_sent +deadline +down_ni +router$"
9975 BR="^$P +$P +$N +(up|down) +$N +(0|1) +$I +$I +$NID$"
9976 create_lnet_proc_files "routers"
9977 check_lnet_proc_entry "routers.out" "/proc/sys/lnet/routers" "$BR" "$L1"
9978 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
9979 remove_lnet_proc_files "routers"
9981 # /proc/sys/lnet/peers should look like this:
9982 # nid refs state last max rtr min tx min queue
9983 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
9984 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
9985 # numeric (0 or >0 or <0), queue >= 0.
9986 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
9987 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
9988 create_lnet_proc_files "peers"
9989 check_lnet_proc_entry "peers.out" "/proc/sys/lnet/peers" "$BR" "$L1"
9990 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
9991 remove_lnet_proc_files "peers"
9993 # /proc/sys/lnet/buffers should look like this:
9994 # pages count credits min
9995 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
9996 L1="^pages +count +credits +min$"
9997 BR="^ +$N +$N +$I +$I$"
9998 create_lnet_proc_files "buffers"
9999 check_lnet_proc_entry "buffers.out" "/proc/sys/lnet/buffers" "$BR" "$L1"
10000 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
10001 remove_lnet_proc_files "buffers"
10003 # /proc/sys/lnet/nis should look like this:
10004 # nid status alive refs peer rtr max tx min
10005 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
10006 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
10007 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
10008 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
10009 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
10010 create_lnet_proc_files "nis"
10011 check_lnet_proc_entry "nis.out" "/proc/sys/lnet/nis" "$BR" "$L1"
10012 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
10013 remove_lnet_proc_files "nis"
10015 # can we successfully write to /proc/sys/lnet/stats?
10016 echo "0" >/proc/sys/lnet/stats || error "cannot write to /proc/sys/lnet/stats"
10017 sysctl -w lnet.stats=0 || error "cannot write to lnet.stats"
10019 run_test 215 "/proc/sys/lnet exists and has proper content - bugs 18102, 21079, 21517"
10021 test_216() { # bug 20317
10022 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10023 remote_ost_nodsh && skip "remote OST with nodsh" && return
10025 local p="$TMP/sanityN-$TESTNAME.parameters"
10026 save_lustre_params $HOSTNAME "osc.*.contention_seconds" > $p
10027 for node in $(osts_nodes); do
10028 save_lustre_params $node "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
10029 save_lustre_params $node "ldlm.namespaces.filter-*.contended_locks" >> $p
10030 save_lustre_params $node "ldlm.namespaces.filter-*.contention_seconds" >> $p
10034 # agressive lockless i/o settings
10035 for node in $(osts_nodes); do
10036 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'
10038 lctl set_param -n osc.*.contention_seconds 60
10040 $DIRECTIO write $DIR/$tfile 0 10 4096
10041 $CHECKSTAT -s 40960 $DIR/$tfile
10043 # disable lockless i/o
10044 for node in $(osts_nodes); do
10045 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'
10047 lctl set_param -n osc.*.contention_seconds 0
10050 dd if=/dev/zero of=$DIR/$tfile count=0
10051 $CHECKSTAT -s 0 $DIR/$tfile
10053 restore_lustre_params <$p
10057 run_test 216 "check lockless direct write works and updates file size and kms correctly"
10059 test_217() { # bug 22430
10060 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10064 for node in $(nodes_list); do
10065 nid=$(host_nids_address $node $NETTYPE)
10066 if [[ $nid = *-* ]] ; then
10067 echo "lctl ping $nid@$NETTYPE"
10068 lctl ping $nid@$NETTYPE
10070 echo "skipping $node (no hyphen detected)"
10074 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
10077 # do directio so as not to populate the page cache
10078 log "creating a 10 Mb file"
10079 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
10080 log "starting reads"
10081 dd if=$DIR/$tfile of=/dev/null bs=4096 &
10082 log "truncating the file"
10083 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
10085 kill %+ || true # reads might have finished
10086 echo "wait until dd is finished"
10088 log "removing the temporary file"
10089 rm -rf $DIR/$tfile || error "tmp file removal failed"
10091 run_test 218 "parallel read and truncate should not deadlock ======================="
10094 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10095 # write one partial page
10096 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
10097 # set no grant so vvp_io_commit_write will do sync write
10098 $LCTL set_param fail_loc=0x411
10099 # write a full page at the end of file
10100 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
10102 $LCTL set_param fail_loc=0
10103 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
10104 $LCTL set_param fail_loc=0x411
10105 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
10107 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
10109 test_220() { #LU-325
10110 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10111 remote_ost_nodsh && skip "remote OST with nodsh" && return
10114 test_mkdir -p $DIR/$tdir
10115 local OST=$(lfs osts | grep ${OSTIDX}": " | \
10116 awk '{print $2}' | sed -e 's/_UUID$//')
10119 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
10120 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
10121 osc.$mdtosc_proc1.prealloc_last_id)
10122 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
10123 osc.$mdtosc_proc1.prealloc_next_id)
10127 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
10128 #define OBD_FAIL_OST_ENOINO 0x229
10129 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
10130 do_facet mgs $LCTL pool_new $FSNAME.$TESTNAME || return 1
10131 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
10133 $SETSTRIPE $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
10135 MDSOBJS=$((last_id - next_id))
10136 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
10138 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
10139 echo "OST still has $count kbytes free"
10141 echo "create $MDSOBJS files @next_id..."
10142 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
10144 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
10145 osc.$mdtosc_proc1.prealloc_last_id)
10146 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
10147 osc.$mdtosc_proc1.prealloc_next_id)
10149 echo "after creation, last_id=$last_id2, next_id=$next_id2"
10154 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
10155 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
10157 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST || return 4
10158 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME || return 5
10159 echo "unlink $MDSOBJS files @$next_id..."
10160 unlinkmany $DIR/$tdir/f $MDSOBJS || return 6
10162 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
10165 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10166 dd if=`which date` of=$MOUNT/date oflag=sync
10167 chmod +x $MOUNT/date
10169 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
10170 $LCTL set_param fail_loc=0x80001401
10172 $MOUNT/date > /dev/null
10175 run_test 221 "make sure fault and truncate race to not cause OOM"
10178 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10180 test_mkdir -p $DIR/$tdir
10181 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
10182 createmany -o $DIR/$tdir/$tfile 10
10183 cancel_lru_locks mdc
10184 cancel_lru_locks osc
10185 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
10186 $LCTL set_param fail_loc=0x31a
10187 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
10188 $LCTL set_param fail_loc=0
10191 run_test 222a "AGL for ls should not trigger CLIO lock failure ================"
10194 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10196 test_mkdir -p $DIR/$tdir
10197 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
10198 createmany -o $DIR/$tdir/$tfile 10
10199 cancel_lru_locks mdc
10200 cancel_lru_locks osc
10201 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
10202 $LCTL set_param fail_loc=0x31a
10203 rm -r $DIR/$tdir || "AGL for rmdir failed"
10204 $LCTL set_param fail_loc=0
10206 run_test 222b "AGL for rmdir should not trigger CLIO lock failure ============="
10209 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10211 test_mkdir -p $DIR/$tdir
10212 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
10213 createmany -o $DIR/$tdir/$tfile 10
10214 cancel_lru_locks mdc
10215 cancel_lru_locks osc
10216 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
10217 $LCTL set_param fail_loc=0x31b
10218 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
10219 $LCTL set_param fail_loc=0
10222 run_test 223 "osc reenqueue if without AGL lock granted ======================="
10224 test_224a() { # LU-1039, MRP-303
10225 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10226 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
10227 $LCTL set_param fail_loc=0x508
10228 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
10229 $LCTL set_param fail_loc=0
10232 run_test 224a "Don't panic on bulk IO failure"
10234 test_224b() { # LU-1039, MRP-303
10235 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10236 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
10237 cancel_lru_locks osc
10238 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
10239 $LCTL set_param fail_loc=0x515
10240 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
10241 $LCTL set_param fail_loc=0
10244 run_test 224b "Don't panic on bulk IO failure"
10246 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
10248 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10249 if [ -z ${MDSSURVEY} ]; then
10250 skip_env "mds-survey not found" && return
10252 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
10253 { skip "Need MDS version at least 2.2.51"; return; }
10255 local mds=$(facet_host $SINGLEMDS)
10256 local target=$(do_nodes $mds 'lctl dl' | \
10257 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
10259 local cmd1="file_count=1000 thrhi=4"
10260 local cmd2="dir_count=2 layer=mdd stripe_count=0"
10261 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
10262 local cmd="$cmd1 $cmd2 $cmd3"
10264 rm -f ${TMP}/mds_survey*
10266 eval $cmd || error "mds-survey with zero-stripe failed"
10267 cat ${TMP}/mds_survey*
10268 rm -f ${TMP}/mds_survey*
10270 run_test 225a "Metadata survey sanity with zero-stripe"
10273 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10274 if [ -z ${MDSSURVEY} ]; then
10275 skip_env "mds-survey not found" && return
10277 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
10278 { skip "Need MDS version at least 2.2.51"; return; }
10280 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
10281 skip_env "Need to mount OST to test" && return
10284 local mds=$(facet_host $SINGLEMDS)
10285 local target=$(do_nodes $mds 'lctl dl' | \
10286 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
10288 local cmd1="file_count=1000 thrhi=4"
10289 local cmd2="dir_count=2 layer=mdd stripe_count=1"
10290 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
10291 local cmd="$cmd1 $cmd2 $cmd3"
10293 rm -f ${TMP}/mds_survey*
10295 eval $cmd || error "mds-survey with stripe_count failed"
10296 cat ${TMP}/mds_survey*
10297 rm -f ${TMP}/mds_survey*
10299 run_test 225b "Metadata survey sanity with stripe_count = 1"
10301 mcreate_path2fid () {
10307 local path=$DIR/$tdir/$name
10312 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
10313 error "cannot create $desc"
10315 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
10317 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
10319 fid_path=$($LFS fid2path $MOUNT $fid)
10321 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
10323 [ "$path" == "$fid_path" ] ||
10324 error "fid2path returned $fid_path, expected $path"
10326 echo "pass with $path and $fid"
10331 mkdir -p $DIR/$tdir
10333 mcreate_path2fid 0010666 0 0 fifo "FIFO"
10334 mcreate_path2fid 0020666 1 3 null "character special file (null)"
10335 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
10336 mcreate_path2fid 0040666 0 0 dir "directory"
10337 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
10338 mcreate_path2fid 0100666 0 0 file "regular file"
10339 mcreate_path2fid 0120666 0 0 link "symbolic link"
10340 mcreate_path2fid 0140666 0 0 sock "socket"
10342 run_test 226 "call path2fid and fid2path on files of all type"
10344 # LU-1299 Executing or running ldd on a truncated executable does not
10345 # cause an out-of-memory condition.
10347 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10348 dd if=`which date` of=$MOUNT/date bs=1k count=1
10349 chmod +x $MOUNT/date
10351 $MOUNT/date > /dev/null
10352 ldd $MOUNT/date > /dev/null
10355 run_test 227 "running truncated executable does not cause OOM"
10357 # LU-1512 try to reuse idle OI blocks
10359 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10360 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
10361 skip "non-ldiskfs backend" && return
10363 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
10364 local myDIR=$DIR/$tdir
10367 #define OBD_FAIL_SEQ_EXHAUST 0x1002
10368 $LCTL set_param fail_loc=0x80001002
10369 createmany -o $myDIR/t- 10000
10370 $LCTL set_param fail_loc=0
10371 # The guard is current the largest FID holder
10373 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
10375 local IDX=$(($SEQ % 64))
10377 do_facet $SINGLEMDS sync
10378 # Make sure journal flushed.
10380 local blk1=$(do_facet $SINGLEMDS \
10381 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
10382 grep Blockcount | awk '{print $4}')
10384 # Remove old files, some OI blocks will become idle.
10385 unlinkmany $myDIR/t- 10000
10386 # Create new files, idle OI blocks should be reused.
10387 createmany -o $myDIR/t- 2000
10388 do_facet $SINGLEMDS sync
10389 # Make sure journal flushed.
10391 local blk2=$(do_facet $SINGLEMDS \
10392 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
10393 grep Blockcount | awk '{print $4}')
10395 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
10397 run_test 228a "try to reuse idle OI blocks"
10400 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10401 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
10402 skip "non-ldiskfs backend" && return
10404 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
10405 local myDIR=$DIR/$tdir
10408 #define OBD_FAIL_SEQ_EXHAUST 0x1002
10409 $LCTL set_param fail_loc=0x80001002
10410 createmany -o $myDIR/t- 10000
10411 $LCTL set_param fail_loc=0
10412 # The guard is current the largest FID holder
10414 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
10416 local IDX=$(($SEQ % 64))
10418 do_facet $SINGLEMDS sync
10419 # Make sure journal flushed.
10421 local blk1=$(do_facet $SINGLEMDS \
10422 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
10423 grep Blockcount | awk '{print $4}')
10425 # Remove old files, some OI blocks will become idle.
10426 unlinkmany $myDIR/t- 10000
10429 stop $SINGLEMDS || error "Fail to stop MDT."
10431 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
10433 df $MOUNT || error "Fail to df."
10434 # Create new files, idle OI blocks should be reused.
10435 createmany -o $myDIR/t- 2000
10436 do_facet $SINGLEMDS sync
10437 # Make sure journal flushed.
10439 local blk2=$(do_facet $SINGLEMDS \
10440 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
10441 grep Blockcount | awk '{print $4}')
10443 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
10445 run_test 228b "idle OI blocks can be reused after MDT restart"
10449 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10450 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
10451 skip "non-ldiskfs backend" && return
10453 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
10454 local myDIR=$DIR/$tdir
10457 #define OBD_FAIL_SEQ_EXHAUST 0x1002
10458 $LCTL set_param fail_loc=0x80001002
10459 # 20000 files can guarantee there are index nodes in the OI file
10460 createmany -o $myDIR/t- 20000
10461 $LCTL set_param fail_loc=0
10462 # The guard is current the largest FID holder
10464 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
10466 local IDX=$(($SEQ % 64))
10468 do_facet $SINGLEMDS sync
10469 # Make sure journal flushed.
10471 local blk1=$(do_facet $SINGLEMDS \
10472 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
10473 grep Blockcount | awk '{print $4}')
10475 # Remove old files, some OI blocks will become idle.
10476 unlinkmany $myDIR/t- 20000
10478 # The OI file should become empty now
10480 # Create new files, idle OI blocks should be reused.
10481 createmany -o $myDIR/t- 2000
10482 do_facet $SINGLEMDS sync
10483 # Make sure journal flushed.
10485 local blk2=$(do_facet $SINGLEMDS \
10486 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
10487 grep Blockcount | awk '{print $4}')
10489 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
10491 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
10494 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10495 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
10498 mkdir -p $DIR/$tdir/test_230_local
10499 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230_local)
10500 [ $mdt_idx -ne 0 ] &&
10501 error "create local directory on wrong MDT $mdt_idx"
10503 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
10504 error "create remote directory failed"
10505 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230)
10506 [ $mdt_idx -ne $MDTIDX ] &&
10507 error "create remote directory on wrong MDT $mdt_idx"
10509 createmany -o $DIR/$tdir/test_230/t- 10 ||
10510 error "create files on remote directory failed"
10511 mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230/t-0)
10512 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
10513 rm -r $DIR/$tdir || error "unlink remote directory failed"
10515 run_test 230a "Create remote directory and files under the remote directory"
10518 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10519 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
10521 local remote_dir=$DIR/$tdir/remote_dir
10523 mkdir -p $DIR/$tdir
10524 $LFS mkdir -i $MDTIDX $remote_dir ||
10525 error "create remote directory failed"
10527 $LFS mkdir -i 0 $remote_dir/new_dir &&
10528 error "nested remote directory create succeed!"
10530 rm -r $DIR/$tdir || error "unlink remote directory failed"
10532 run_test 230b "nested remote directory should be failed"
10535 # tests that do cleanup/setup should be run at the end
10539 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10541 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
10542 $LCTL set_param fail_loc=0x903
10543 # cancel_lru_locks mgc - does not work due to lctl set_param syntax
10544 for ls in /proc/fs/lustre/ldlm/namespaces/MGC*/lru_size; do
10547 FAIL_ON_ERROR=true cleanup
10548 FAIL_ON_ERROR=true setup
10550 run_test 900 "umount should not race with any mgc requeue thread"
10553 check_and_cleanup_lustre
10554 if [ "$I_MOUNTED" != "yes" ]; then
10555 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true