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:-""}
52 export NAME=${NAME:-local}
59 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
60 . $LUSTRE/tests/test-framework.sh
62 . ${CONFIG:=$LUSTRE/tests/cfg/${NAME}.sh}
65 [ "$SLOW" = "no" ] && EXCEPT_SLOW="24o 24v 27m 36f 36g 36h 51b 60c 63 64b 68 71 73 77f 78 101a 103 115 120g 124b"
71 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
72 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
81 check_kernel_version() {
83 GOT_VER=$(lctl get_param -n version | awk '/kernel:/ {print $2}')
85 patchless|patchless_client) return 0;;
86 *) [ $GOT_VER -ge $WANT_VER ] && return 0 ;;
88 log "test needs at least kernel version $WANT_VER, running $GOT_VER"
92 if [ "$ONLY" == "cleanup" ]; then
97 check_and_setup_lustre
102 MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid | \
103 awk '{gsub(/_UUID/,""); print $1}' | head -1)
104 LOVNAME=$($LCTL get_param -n llite.*.lov.common_name | tail -n 1)
105 OSTCOUNT=$($LCTL get_param -n lov.$LOVNAME.numobd)
106 STRIPECOUNT=$($LCTL get_param -n lov.$LOVNAME.stripecount)
107 STRIPESIZE=$($LCTL get_param -n lov.$LOVNAME.stripesize)
108 ORIGFREE=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
109 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
111 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
112 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
113 rm -rf $DIR/[Rdfs][0-9]*
115 # $RUNAS_ID may get set incorrectly somewhere else
116 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
118 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
122 if [ "${ONLY}" = "MOUNT" ] ; then
123 echo "Lustre is up, please go on"
127 echo "preparing for tests involving mounts"
128 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
130 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
131 echo # add a newline after mke2fs.
135 OLDDEBUG="`lctl get_param -n debug 2> /dev/null`"
136 lctl set_param debug=-1 2> /dev/null || true
139 $CHECKSTAT -t file $DIR/$tfile || error
141 $CHECKSTAT -a $DIR/$tfile || error
143 run_test 0 "touch .../$tfile ; rm .../$tfile ====================="
146 chmod 0755 $DIR || error
147 $CHECKSTAT -p 0755 $DIR || error
149 run_test 0b "chmod 0755 $DIR ============================="
152 $LCTL get_param mdc.*.import | grep "state: FULL" || error "import not FULL"
153 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" || error "bad target"
155 run_test 0c "check import proc ============================="
158 test_mkdir -p $DIR/$tdir
159 test_mkdir -p $DIR/$tdir/d2
160 test_mkdir $DIR/$tdir/d2 && error "we expect EEXIST, but not returned"
161 $CHECKSTAT -t dir $DIR/$tdir/d2 || error
163 run_test 1a "mkdir .../d1; mkdir .../d1/d2 ====================="
168 $CHECKSTAT -a $DIR/$tdir || error
170 run_test 1b "rmdir .../d1/d2; rmdir .../d1 ====================="
173 test_mkdir $DIR/$tdir
174 touch $DIR/$tdir/$tfile
175 $CHECKSTAT -t file $DIR/$tdir/$tfile || error
177 run_test 2a "mkdir .../d2; touch .../d2/f ======================"
181 $CHECKSTAT -a $DIR/$tdir || error
183 run_test 2b "rm -r .../d2; checkstat .../d2/f ======================"
186 test_mkdir -p $DIR/$tdir
187 $CHECKSTAT -t dir $DIR/$tdir || error
189 run_test 3a "mkdir .../d3 ======================================"
192 if [ ! -d $DIR/$tdir ]; then
195 touch $DIR/$tdir/$tfile
196 $CHECKSTAT -t file $DIR/$tdir/$tfile || error
198 run_test 3b "touch .../d3/f ===================================="
202 $CHECKSTAT -a $DIR/$tdir || error
204 run_test 3c "rm -r .../d3 ======================================"
207 test_mkdir -p $DIR/$tdir
208 $CHECKSTAT -t dir $DIR/$tdir || error
210 run_test 4a "mkdir .../d4 ======================================"
213 if [ ! -d $DIR/$tdir ]; then
214 test_mkdir $DIR/$tdir
216 test_mkdir $DIR/$tdir/d2
218 $CHECKSTAT -t dir $DIR/$tdir/d2 || error
220 run_test 4b "mkdir .../d4/d2 ==================================="
223 test_mkdir $DIR/$tdir
224 test_mkdir $DIR/$tdir/d2
225 chmod 0707 $DIR/$tdir/d2
226 $CHECKSTAT -t dir -p 0707 $DIR/$tdir/d2 || error
228 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2 ============"
232 chmod 0666 $DIR/$tfile || error
233 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile || error
235 run_test 6a "touch .../f6a; chmod .../f6a ======================"
238 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
239 if [ ! -f $DIR/$tfile ]; then
241 chmod 0666 $DIR/$tfile
243 $RUNAS chmod 0444 $DIR/$tfile && error
244 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile || error
246 run_test 6b "$RUNAS chmod .../f6a (should return error) =="
249 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
251 chown $RUNAS_ID $DIR/$tfile || error
252 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile || error
254 run_test 6c "touch .../f6c; chown .../f6c ======================"
257 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
258 if [ ! -f $DIR/$tfile ]; then
260 chown $RUNAS_ID $DIR/$tfile
262 $RUNAS chown $UID $DIR/$tfile && error
263 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile || error
265 run_test 6d "$RUNAS chown .../f6c (should return error) =="
268 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
270 chgrp $RUNAS_ID $DIR/$tfile || error
271 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile || error
273 run_test 6e "touch .../f6e; chgrp .../f6e ======================"
276 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
277 if [ ! -f $DIR/$tfile ]; then
279 chgrp $RUNAS_ID $DIR/$tfile
281 $RUNAS chgrp $UID $DIR/$tfile && error
282 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile || error
284 run_test 6f "$RUNAS chgrp .../f6e (should return error) =="
287 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
288 test_mkdir $DIR/$tdir || error
289 chmod 777 $DIR/$tdir || error
290 $RUNAS mkdir $DIR/$tdir/d || error
291 chmod g+s $DIR/$tdir/d || error
292 test_mkdir $DIR/$tdir/d/subdir
293 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir/d/subdir || error
295 run_test 6g "Is new dir in sgid dir inheriting group?"
297 test_6h() { # bug 7331
298 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
299 touch $DIR/$tfile || error "touch failed"
300 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
301 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
303 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/$tfile || error
305 run_test 6h "$RUNAS chown RUNAS_ID.0 .../f6h (should return error)"
308 test_mkdir $DIR/$tdir
309 $MCREATE $DIR/$tdir/$tfile
310 chmod 0666 $DIR/$tdir/$tfile
311 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile || error
313 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
316 if [ ! -d $DIR/$tdir ]; then
319 $MCREATE $DIR/$tdir/$tfile
320 echo -n foo > $DIR/$tdir/$tfile
321 [ "`cat $DIR/$tdir/$tfile`" = "foo" ] || error
322 $CHECKSTAT -t file -s 3 $DIR/$tdir/$tfile || error
324 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
327 test_mkdir $DIR/$tdir
328 touch $DIR/$tdir/$tfile
329 chmod 0666 $DIR/$tdir/$tfile
330 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile || error
332 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
335 test_mkdir $DIR/$tdir
336 test_mkdir $DIR/$tdir/d2
337 test_mkdir $DIR/$tdir/d2/d3
338 $CHECKSTAT -t dir $DIR/$tdir/d2/d3 || error
340 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
343 test_mkdir $DIR/$tdir
344 test_mkdir $DIR/$tdir/d2
345 touch $DIR/$tdir/d2/$tfile
346 $CHECKSTAT -t file $DIR/$tdir/d2/$tfile || error
348 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
351 test_mkdir $DIR/$tdir
352 test_mkdir $DIR/$tdir/d2
353 chmod 0666 $DIR/$tdir/d2
354 chmod 0705 $DIR/$tdir/d2
355 $CHECKSTAT -t dir -p 0705 $DIR/$tdir/d2 || error
357 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
360 test_mkdir $DIR/$tdir
361 touch $DIR/$tdir/$tfile
362 chmod 0666 $DIR/$tdir/$tfile
363 chmod 0654 $DIR/$tdir/$tfile
364 $CHECKSTAT -t file -p 0654 $DIR/$tdir/$tfile || error
366 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
369 test_mkdir $DIR/$tdir
370 dd if=/dev/zero of=$DIR/$tdir/$tfile count=10
372 $CHECKSTAT -t file -s 0 $DIR/$tdir/$tfile || error
374 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
377 test_mkdir $DIR/$tdir
378 touch $DIR/$tdir/$tfile
380 $CHECKSTAT -a $DIR/$tdir/$tfile || error
382 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
385 test_mkdir $DIR/$tdir
386 touch $DIR/$tdir/$tfile
387 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}_2
388 $CHECKSTAT -t file $DIR/$tdir/${tfile}_2 || error
390 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
393 test_mkdir $DIR/$tdir
394 touch $DIR/$tdir/$tfile
395 rm -rf $DIR/$tdir/$tfile
396 $CHECKSTAT -a $DIR/$tdir/$tfile || error
398 run_test 16 "touch .../d16/f; rm -rf .../d16/f ================="
401 test_mkdir -p $DIR/$tdir
402 touch $DIR/$tdir/$tfile
403 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
405 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist || error
406 $CHECKSTAT -f -t f $DIR/$tdir/l-exist || error
407 rm -f $DIR/$tdir/l-exist
408 $CHECKSTAT -a $DIR/$tdir/l-exist || error
410 run_test 17a "symlinks: create, remove (real) =================="
413 test_mkdir -p $DIR/$tdir
414 ln -s no-such-file $DIR/$tdir/l-dangle
416 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle || error
417 $CHECKSTAT -fa $DIR/$tdir/l-dangle || error
418 rm -f $DIR/$tdir/l-dangle
419 $CHECKSTAT -a $DIR/$tdir/l-dangle || error
421 run_test 17b "symlinks: create, remove (dangling) =============="
423 test_17c() { # bug 3440 - don't save failed open RPC for replay
424 test_mkdir -p $DIR/$tdir
425 ln -s foo $DIR/$tdir/$tfile
426 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
428 run_test 17c "symlinks: open dangling (should return error) ===="
431 test_mkdir -p $DIR/$tdir
432 ln -s foo $DIR/$tdir/$tfile
433 touch $DIR/$tdir/$tfile || error "creating to new symlink"
435 run_test 17d "symlinks: create dangling ========================"
438 test_mkdir -p $DIR/$tdir
439 local foo=$DIR/$tdir/$tfile
440 ln -s $foo $foo || error "create symlink failed"
441 ls -l $foo || error "ls -l failed"
442 ls $foo && error "ls not failed" || true
444 run_test 17e "symlinks: create recursive symlink (should return error) ===="
447 test_mkdir -p $DIR/d17f
448 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/d17f/111
449 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/d17f/222
450 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/d17f/333
451 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/d17f/444
452 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/d17f/555
453 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890/aaaaaaaaaa/bbbbbbbbbb/cccccccccc/dddddddddd/eeeeeeeeee/ffffffffff/ $DIR/d17f/666
456 run_test 17f "symlinks: long and very long symlink name ========================"
458 # str_repeat(S, N) generate a string that is string S repeated N times
463 while [ $((n -= 1)) -ge 0 ]; do
469 # Long symlinks and LU-2241
471 test_mkdir -p $DIR/$tdir
472 local TESTS="59 60 61 4094 4095"
475 local SYMNAME=$(str_repeat 'x' $i)
476 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
477 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
480 run_test 17g "symlinks: really long symlink name and inode boundaries"
482 test_17h() { #bug 17378
483 remote_mds_nodsh && skip "remote MDS with nodsh" && return
485 test_mkdir -p $DIR/$tdir
486 if [ $MDSCOUNT -gt 1 ]; then
487 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
491 $SETSTRIPE -c -1 $DIR/$tdir
492 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
493 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
494 touch $DIR/$tdir/$tfile || true
496 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
498 test_17i() { #bug 20018
499 remote_mds_nodsh && skip "remote MDS with nodsh" && return
500 test_mkdir -p $DIR/$tdir
501 local foo=$DIR/$tdir/$tfile
503 if [ $MDSCOUNT -gt 1 ]; then
504 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
508 ln -s $foo $foo || error "create symlink failed"
509 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
510 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
511 ls -l $foo && error "error not detected"
514 run_test 17i "don't panic on short symlink"
516 test_17k() { #bug 22301
517 rsync --help | grep -q xattr ||
518 skip_env "$(rsync --version| head -1) does not support xattrs"
519 test_mkdir -p $DIR/$tdir
520 test_mkdir -p $DIR/$tdir.new
521 touch $DIR/$tdir/$tfile
522 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
523 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
524 error "rsync failed with xattrs enabled"
526 run_test 17k "symlinks: rsync with xattrs enabled ========================="
528 test_17l() { # LU-279
530 touch $DIR/$tdir/$tfile
531 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
532 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
533 # -h to not follow symlinks. -m '' to list all the xattrs.
534 # grep to remove first line: '# file: $path'.
535 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
537 lgetxattr_size_check $path $xattr ||
538 error "lgetxattr_size_check $path $xattr failed"
542 run_test 17l "Ensure lgetxattr's returned xattr size is consistent ========"
546 local short_sym="0123456789"
547 local WDIR=$DIR/${tdir}m
554 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
555 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
556 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
558 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
559 skip "only for ldiskfs MDT" && return 0
563 # create a long symlink file
564 for ((i = 0; i < 4; ++i)); do
565 long_sym=${long_sym}${long_sym}
568 echo "create 512 short and long symlink files under $WDIR"
569 for ((i = 0; i < 256; ++i)); do
570 ln -sf ${long_sym}"a5a5" $WDIR/long-$i
571 ln -sf ${short_sym}"a5a5" $WDIR/short-$i
577 wait_delete_completed
579 echo "recreate the 512 symlink files with a shorter string"
580 for ((i = 0; i < 512; ++i)); do
581 # rewrite the symlink file with a shorter string
582 ln -sf ${long_sym} $WDIR/long-$i
583 ln -sf ${short_sym} $WDIR/short-$i
586 mds_index=$($LFS getstripe -M $WDIR)
587 mds_index=$((mds_index+1))
588 devname=$(mdsdevname $mds_index)
589 cmd="$E2FSCK -fnvd $devname"
591 echo "stop and checking mds${mds_index}: $cmd"
592 # e2fsck should not return error
593 stop mds${mds_index} -f
594 do_facet mds${mds_index} $cmd || rc=$?
596 start mds${mds_index} $devname $MDS_MOUNT_OPTS
597 df $MOUNT > /dev/null 2>&1
598 [ $rc -ne 0 ] && error "e2fsck should not report error upon "\
599 "short/long symlink MDT: rc=$rc"
602 run_test 17m "run e2fsck against MDT which contains short/long symlink"
604 check_fs_consistency_17n() {
610 for mdt_index in $(seq 1 $MDSCOUNT); do
611 devname=$(mdsdevname $mdt_index)
612 cmd="$E2FSCK -fnvd $devname"
614 echo "stop and checking mds${mdt_index}: $cmd"
615 # e2fsck should not return error
617 do_facet mds${mdt_index} $cmd || rc=$?
619 start mds${mdt_index} $devname $MDS_MOUNT_OPTS
620 df $MOUNT > /dev/null 2>&1
621 [ $rc -ne 0 ] && break
629 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
630 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
631 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
633 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
634 skip "only for ldiskfs MDT" && return 0
636 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
639 for ((i=0; i<10; i++)); do
640 $LFS mkdir -i 1 $DIR/$tdir/remote_dir_${i} ||
641 error "create remote dir error $i"
642 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
643 error "create files under remote dir failed $i"
646 check_fs_consistency_17n || error "e2fsck report error"
648 for ((i=0;i<10;i++)); do
649 rm -rf $DIR/$tdir/remote_dir_${i} ||
650 error "destroy remote dir error $i"
653 check_fs_consistency_17n || error "e2fsck report error"
655 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
661 run_test 18 "touch .../f ; ls ... =============================="
667 $CHECKSTAT -a $DIR/f19 || error
669 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
672 ls -l $DIR/f19 && error || true
674 run_test 19b "ls -l .../f19 (should return error) =============="
677 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
678 $RUNAS touch $DIR/f19 && error || true
680 run_test 19c "$RUNAS touch .../f19 (should return error) =="
683 cat $DIR/f19 && error || true
685 run_test 19d "cat .../f19 (should return error) =============="
697 $CHECKSTAT -a $DIR/f || error
699 run_test 20 "touch .../f ; ls -l ... ==========================="
703 [ -f $DIR/d21/dangle ] && rm -f $DIR/d21/dangle
704 ln -s dangle $DIR/d21/link
705 echo foo >> $DIR/d21/link
707 $CHECKSTAT -t link $DIR/d21/link || error
708 $CHECKSTAT -f -t file $DIR/d21/link || error
710 run_test 21 "write to dangling link ============================"
714 test_mkdir -p $DIR/$tdir
715 chown $RUNAS_ID:$RUNAS_GID $WDIR
716 (cd $WDIR || error "cd $WDIR failed";
717 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
719 ls -lR $WDIR/etc || error "ls -lR $WDIR/etc failed"
720 $CHECKSTAT -t dir $WDIR/etc || error "checkstat -t dir failed"
721 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $WDIR/etc || error "checkstat -u failed"
723 run_test 22 "unpack tar archive as non-root user ==============="
727 test_mkdir -p $DIR/$tdir
728 local file=$DIR/$tdir/$tfile
730 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
731 openfile -f O_CREAT:O_EXCL $file &&
732 error "$file recreate succeeded" || true
734 run_test 23a "O_CREAT|O_EXCL in subdir =========================="
736 test_23b() { # bug 18988
737 test_mkdir -p $DIR/$tdir
738 local file=$DIR/$tdir/$tfile
741 echo foo > $file || error "write filed"
742 echo bar >> $file || error "append filed"
743 $CHECKSTAT -s 8 $file || error "wrong size"
746 run_test 23b "O_APPEND check =========================="
749 echo '== rename sanity =============================================='
750 echo '-- same directory rename'
753 mv $DIR/R1/f $DIR/R1/g
754 $CHECKSTAT -t file $DIR/R1/g || error
756 run_test 24a "touch .../R1/f; rename .../R1/f .../R1/g ========="
761 mv $DIR/R2/f $DIR/R2/g
762 $CHECKSTAT -a $DIR/R2/f || error
763 $CHECKSTAT -t file $DIR/R2/g || error
765 run_test 24b "touch .../R2/{f,g}; rename .../R2/f .../R2/g ====="
770 mv $DIR/R3/f $DIR/R3/g
771 $CHECKSTAT -a $DIR/R3/f || error
772 $CHECKSTAT -t dir $DIR/R3/g || error
774 run_test 24c "mkdir .../R3/f; rename .../R3/f .../R3/g ========="
780 mrename $DIR/R4/f $DIR/R4/g
781 $CHECKSTAT -a $DIR/R4/f || error
782 $CHECKSTAT -t dir $DIR/R4/g || error
784 run_test 24d "mkdir .../R4/{f,g}; rename .../R4/f .../R4/g ====="
787 echo '-- cross directory renames --'
791 mv $DIR/R5a/f $DIR/R5b/g
792 $CHECKSTAT -a $DIR/R5a/f || error
793 $CHECKSTAT -t file $DIR/R5b/g || error
795 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
800 touch $DIR/R6a/f $DIR/R6b/g
801 mv $DIR/R6a/f $DIR/R6b/g
802 $CHECKSTAT -a $DIR/R6a/f || error
803 $CHECKSTAT -t file $DIR/R6b/g || error
805 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
810 test_mkdir $DIR/R7a/d
811 mv $DIR/R7a/d $DIR/R7b/e
812 $CHECKSTAT -a $DIR/R7a/d || error
813 $CHECKSTAT -t dir $DIR/R7b/e || error
815 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
820 test_mkdir $DIR/R8a/d
821 test_mkdir $DIR/R8b/e
822 mrename $DIR/R8a/d $DIR/R8b/e
823 $CHECKSTAT -a $DIR/R8a/d || error
824 $CHECKSTAT -t dir $DIR/R8b/e || error
826 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
829 echo "-- rename error cases"
833 mrename $DIR/R9/f $DIR/R9/a
834 $CHECKSTAT -t file $DIR/R9/f || error
835 $CHECKSTAT -t dir $DIR/R9/a || error
836 $CHECKSTAT -a $DIR/R9/a/f || error
838 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
842 mrename $DIR/R10/f $DIR/R10/g
843 $CHECKSTAT -t dir $DIR/R10 || error
844 $CHECKSTAT -a $DIR/R10/f || error
845 $CHECKSTAT -a $DIR/R10/g || error
847 run_test 24j "source does not exist ============================"
851 test_mkdir $DIR/R11a/d
853 mv $DIR/R11a/f $DIR/R11a/d
854 $CHECKSTAT -a $DIR/R11a/f || error
855 $CHECKSTAT -t file $DIR/R11a/d/f || error
857 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
859 # bug 2429 - rename foo foo foo creates invalid file
862 $MULTIOP $f OcNs || error
864 run_test 24l "Renaming a file to itself ========================"
868 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
869 # on ext3 this does not remove either the source or target files
870 # though the "expected" operation would be to remove the source
871 $CHECKSTAT -t file ${f} || error "${f} missing"
872 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
874 run_test 24m "Renaming a file to a hard link to itself ========="
878 # this stats the old file after it was renamed, so it should fail
882 $CHECKSTAT ${f}.rename
885 run_test 24n "Statting the old file after renaming (Posix rename 2)"
888 check_kernel_version 37 || return 0
889 test_mkdir -p $DIR/d24o
890 rename_many -s random -v -n 10 $DIR/d24o
892 run_test 24o "rename of files during htree split ==============="
897 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
898 mrename $DIR/R12a $DIR/R12b
899 $CHECKSTAT -a $DIR/R12a || error
900 $CHECKSTAT -t dir $DIR/R12b || error
901 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
902 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
904 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
909 DIRINO=`ls -lid $DIR/R13a | awk '{ print $1 }'`
910 multiop_bg_pause $DIR/R13b D_c || return 1
913 mrename $DIR/R13a $DIR/R13b
914 $CHECKSTAT -a $DIR/R13a || error
915 $CHECKSTAT -t dir $DIR/R13b || error
916 DIRINO2=`ls -lid $DIR/R13b | awk '{ print $1 }'`
917 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
919 wait $MULTIPID || error "multiop close failed"
921 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
923 test_24r() { #bug 3789
925 test_mkdir $DIR/R14a/b
926 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
927 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
928 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
930 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
934 test_mkdir $DIR/R15a/b
935 test_mkdir $DIR/R15a/b/c
936 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
937 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
938 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
940 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
943 test_mkdir $DIR/R16a/b
944 test_mkdir $DIR/R16a/b/c
945 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
946 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
947 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
949 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
951 test_24u() { # bug12192
953 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error
954 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
956 run_test 24u "create stripe file"
962 simple_cleanup_common() {
965 wait_delete_completed
968 max_pages_per_rpc() {
969 $LCTL get_param -n mdc.*.max_pages_per_rpc | head -1
974 local FREE_INODES=$(lfs_df -i | grep "summary" | awk '{print $4}')
975 [ $FREE_INODES -lt $NRFILES ] && \
976 skip "not enough free inodes $FREE_INODES required $NRFILES" &&
979 trap simple_cleanup_common EXIT
982 createmany -m $DIR/$tdir/$tfile $NRFILES
985 lctl set_param mdc.*.stats clear
987 ls $DIR/$tdir >/dev/null || error "error in listing large dir"
990 # DIRENT_SIZE = 32 bytes for sizeof(struct lu_dirent) +
991 # 8 bytes for name(filename is mostly 5 in this test) +
992 # 8 bytes for luda_type
993 # take into account of overhead in lu_dirpage header and end mark in
994 # each page, plus one in RPC_NUM calculation.
996 RPC_SIZE=$(($(max_pages_per_rpc) * $(page_size)))
997 RPC_NUM=$(((NRFILES * DIRENT_SIZE + RPC_SIZE - 1) / RPC_SIZE + 1))
998 mds_readpage=$(lctl get_param mdc.*MDT0000*.stats | \
999 awk '/^mds_readpage/ {print $2}')
1000 [ $mds_readpage -gt $RPC_NUM ] && \
1001 error "large readdir doesn't take effect"
1003 simple_cleanup_common
1005 run_test 24v "list directory with large files (handle hash collision, bug: 17560)"
1007 test_24w() { # bug21506
1009 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1010 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1011 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1012 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1013 [ "$SZ1" = "$SZ2" ] || \
1014 error "Error reading at the end of the file $tfile"
1016 run_test 24w "Reading a file larger than 4Gb"
1019 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1021 local remote_dir=$DIR/$tdir/remote_dir
1024 $LFS mkdir -i $MDTIDX $remote_dir ||
1025 error "create remote directory failed"
1027 mkdir -p $DIR/$tdir/src_dir
1028 touch $DIR/$tdir/src_file
1029 mkdir -p $remote_dir/tgt_dir
1030 touch $remote_dir/tgt_file
1032 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir &&
1033 error "rename dir cross MDT works!"
1035 mrename $DIR/$tdir/src_file $remote_dir/tgt_file &&
1036 error "rename file cross MDT works!"
1038 ln $DIR/$tdir/src_file $remote_dir/tgt_file1 &&
1039 error "ln file cross MDT should not work!"
1041 rm -rf $DIR/$tdir || error "Can not delete directories"
1043 run_test 24x "cross rename/link should be failed"
1046 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1048 local remote_dir=$DIR/$tdir/remote_dir
1051 $LFS mkdir -i $MDTIDX $remote_dir ||
1052 error "create remote directory failed"
1054 mkdir -p $remote_dir/src_dir
1055 touch $remote_dir/src_file
1056 mkdir -p $remote_dir/tgt_dir
1057 touch $remote_dir/tgt_file
1059 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1060 error "rename subdir in the same remote dir failed!"
1062 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1063 error "rename files in the same remote dir failed!"
1065 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1066 error "link files in the same remote dir failed!"
1068 rm -rf $DIR/$tdir || error "Can not delete directories"
1070 run_test 24y "rename/link on the same dir should succeed"
1073 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1075 local remote_src=$DIR/$tdir/remote_dir
1076 local remote_tgt=$DIR/$tdir/remote_tgt
1079 $LFS mkdir -i $MDTIDX $remote_src ||
1080 error "create remote directory failed"
1082 $LFS mkdir -i $MDTIDX $remote_tgt ||
1083 error "create remote directory failed"
1085 mrename $remote_src $remote_tgt &&
1086 error "rename remote dirs should not work!"
1088 rm -rf $DIR/$tdir || error "Can not delete directories"
1090 run_test 24z "rename one remote dir to another remote dir should fail"
1093 echo '== symlink sanity ============================================='
1097 touch $DIR/s25/foo || error
1099 run_test 25a "create file in symlinked directory ==============="
1102 [ ! -d $DIR/d25 ] && test_25a
1103 $CHECKSTAT -t file $DIR/s25/foo || error
1105 run_test 25b "lookup file in symlinked directory ==============="
1109 test_mkdir $DIR/d26/d26-2
1110 ln -s d26/d26-2 $DIR/s26
1111 touch $DIR/s26/foo || error
1113 run_test 26a "multiple component symlink ======================="
1116 test_mkdir -p $DIR/d26b/d26-2
1117 ln -s d26b/d26-2/foo $DIR/s26-2
1118 touch $DIR/s26-2 || error
1120 run_test 26b "multiple component symlink at end of lookup ======"
1123 test_mkdir $DIR/d26.2
1124 touch $DIR/d26.2/foo
1125 ln -s d26.2 $DIR/s26.2-1
1126 ln -s s26.2-1 $DIR/s26.2-2
1127 ln -s s26.2-2 $DIR/s26.2-3
1128 chmod 0666 $DIR/s26.2-3/foo
1130 run_test 26c "chain of symlinks ================================"
1132 # recursive symlinks (bug 439)
1134 ln -s d26-3/foo $DIR/d26-3
1136 run_test 26d "create multiple component recursive symlink ======"
1139 [ ! -h $DIR/d26-3 ] && test_26d
1142 run_test 26e "unlink multiple component recursive symlink ======"
1144 # recursive symlinks (bug 7022)
1146 test_mkdir -p $DIR/$tdir
1147 test_mkdir $DIR/$tdir/$tfile || error "mkdir $DIR/$tdir/$tfile failed"
1148 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1149 test_mkdir -p lndir bar1 || error "mkdir lndir/bar1 failed"
1150 test_mkdir $DIR/$tdir/$tfile/$tfile || error "mkdir $tfile failed"
1151 cd $tfile || error "cd $tfile failed"
1152 ln -s .. dotdot || error "ln dotdot failed"
1153 ln -s dotdot/lndir lndir || error "ln lndir failed"
1154 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1155 output=`ls $tfile/$tfile/lndir/bar1`
1156 [ "$output" = bar1 ] && error "unexpected output"
1157 rm -r $tfile || error "rm $tfile failed"
1158 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1160 run_test 26f "rm -r of a directory which has recursive symlink ="
1163 echo '== stripe sanity =============================================='
1164 test_mkdir -p $DIR/d27 || error "mkdir failed"
1166 $SETSTRIPE -c 1 $DIR/d27/f0 || error "setstripe failed"
1167 $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
1169 log "== test_27a: write to one stripe file ========================="
1170 cp /etc/hosts $DIR/d27/f0 || error
1172 run_test 27a "one stripe file =================================="
1175 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
1176 test_mkdir -p $DIR/d27
1177 $SETSTRIPE -c 2 $DIR/d27/f01 || error "setstripe failed"
1178 $GETSTRIPE -c $DIR/d27/f01
1179 [ $($GETSTRIPE -c $DIR/d27/f01) -eq 2 ] ||
1180 error "two-stripe file doesn't have two stripes"
1182 run_test 27b "create two stripe file"
1185 [ -f $DIR/d27/f01 ] || skip "test_27b not run" && return
1187 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
1189 run_test 27c "write to two stripe file"
1192 test_mkdir -p $DIR/d27
1193 $SETSTRIPE -c 0 -i -1 -S 0 $DIR/d27/fdef || error "setstripe failed"
1194 $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
1195 dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
1197 run_test 27d "create file with default settings ================"
1200 test_mkdir -p $DIR/d27
1201 $SETSTRIPE -c 2 $DIR/d27/f12 || error "setstripe failed"
1202 $SETSTRIPE -c 2 $DIR/d27/f12 && error "setstripe succeeded twice"
1203 $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
1205 run_test 27e "setstripe existing file (should return error) ======"
1208 test_mkdir -p $DIR/d27
1209 $SETSTRIPE -S 100 -i 0 -c 1 $DIR/d27/fbad && error "setstripe failed"
1210 dd if=/dev/zero of=$DIR/d27/f12 bs=4k count=4 || error "dd failed"
1211 $GETSTRIPE $DIR/d27/fbad || error "$GETSTRIPE failed"
1213 run_test 27f "setstripe with bad stripe size (should return error)"
1216 test_mkdir -p $DIR/d27
1217 $MCREATE $DIR/d27/fnone || error "mcreate failed"
1218 $GETSTRIPE $DIR/d27/fnone 2>&1 | grep "no stripe info" ||
1219 error "$DIR/d27/fnone has object"
1221 run_test 27g "$GETSTRIPE with no objects"
1224 touch $DIR/d27/fsome || error "touch failed"
1225 [ $($GETSTRIPE -c $DIR/d27/fsome) -gt 0 ] || error "missing objects"
1227 run_test 27i "$GETSTRIPE with some objects"
1230 test_mkdir -p $DIR/d27
1231 $SETSTRIPE -i $OSTCOUNT $DIR/d27/f27j && error "setstripe failed"||true
1233 run_test 27j "setstripe with bad stripe offset (should return error)"
1235 test_27k() { # bug 2844
1236 test_mkdir -p $DIR/d27
1238 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
1239 [ ! -d $DIR/d27 ] && test_mkdir -p $DIR d27
1240 $SETSTRIPE -S 67108864 $FILE || error "setstripe failed"
1241 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1242 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
1243 dd if=/dev/zero of=$FILE bs=4k count=1
1244 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1245 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
1247 run_test 27k "limit i_blksize for broken user apps ============="
1250 test_mkdir -p $DIR/d27
1251 mcreate $DIR/f27l || error "creating file"
1252 $RUNAS $SETSTRIPE -c 1 $DIR/f27l && \
1253 error "setstripe should have failed" || true
1255 run_test 27l "check setstripe permissions (should return error)"
1258 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" &&
1260 if [ $ORIGFREE -gt $MAXFREE ]; then
1261 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1264 trap simple_cleanup_common EXIT
1265 test_mkdir -p $DIR/$tdir
1266 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_1
1267 dd if=/dev/zero of=$DIR/$tdir/f27m_1 bs=1024 count=$MAXFREE &&
1268 error "dd should fill OST0"
1270 while $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_$i; do
1272 [ $i -gt 256 ] && break
1275 touch $DIR/$tdir/f27m_$i
1276 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1277 error "OST0 was full but new created file still use it"
1279 touch $DIR/$tdir/f27m_$i
1280 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1281 error "OST0 was full but new created file still use it"
1282 simple_cleanup_common
1284 run_test 27m "create file while OST0 was full =================="
1287 local DELAY=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage | head -n 1 | awk '{print $1 * 2}')
1291 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1292 # if the OST isn't full anymore.
1294 local OSTIDX=${1:-""}
1296 local list=$(comma_list $(osts_nodes))
1297 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1299 do_nodes $list lctl set_param fail_loc=0
1300 sync # initiate all OST_DESTROYs from MDS to OST
1304 exhaust_precreations() {
1307 local FAILIDX=${3:-$OSTIDX}
1309 test_mkdir -p $DIR/$tdir
1310 local MDSIDX=$(get_mds_dir "$DIR/$tdir")
1311 echo OSTIDX=$OSTIDX MDSIDX=$MDSIDX
1313 local OST=$(ostname_from_index $OSTIDX)
1314 local MDT_INDEX=$(lfs df | grep "\[MDT:$((MDSIDX - 1))\]" | awk '{print $1}' | \
1315 sed -e 's/_UUID$//;s/^.*-//')
1318 local mdtosc_proc1=$(get_mdtosc_proc_path mds${MDSIDX} $OST)
1319 local last_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1320 osc.$mdtosc_proc1.prealloc_last_id)
1321 local next_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1322 osc.$mdtosc_proc1.prealloc_next_id)
1324 local mdtosc_proc2=$(get_mdtosc_proc_path mds${MDSIDX})
1325 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1327 test_mkdir -p $DIR/$tdir/${OST}
1328 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1329 #define OBD_FAIL_OST_ENOSPC 0x215
1330 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=$FAILIDX
1331 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x215
1332 echo "Creating to objid $last_id on ost $OST..."
1333 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1334 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1335 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=$FAILLOC
1339 exhaust_all_precreations() {
1341 for (( i=0; i < OSTCOUNT; i++ )) ; do
1342 exhaust_precreations $i $1 -1
1347 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1348 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1349 remote_ost_nodsh && skip "remote OST with nodsh" && return
1352 rm -f $DIR/$tdir/$tfile
1353 exhaust_precreations 0 0x80000215
1354 $SETSTRIPE -c -1 $DIR/$tdir
1355 touch $DIR/$tdir/$tfile || error
1356 $GETSTRIPE $DIR/$tdir/$tfile
1359 run_test 27n "create file with some full OSTs =================="
1362 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1363 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1364 remote_ost_nodsh && skip "remote OST with nodsh" && return
1367 rm -f $DIR/$tdir/$tfile
1368 exhaust_all_precreations 0x215
1370 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1375 run_test 27o "create file with all full OSTs (should error) ===="
1378 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1379 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1380 remote_ost_nodsh && skip "remote OST with nodsh" && return
1383 rm -f $DIR/$tdir/$tfile
1384 test_mkdir -p $DIR/$tdir
1386 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1387 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1388 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1390 exhaust_precreations 0 0x80000215
1391 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1392 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1393 $GETSTRIPE $DIR/$tdir/$tfile
1397 run_test 27p "append to a truncated file with some full OSTs ==="
1400 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && 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
1407 test_mkdir -p $DIR/$tdir
1408 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1409 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||error "truncate $DIR/$tdir/$tfile failed"
1410 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1412 exhaust_all_precreations 0x215
1414 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1415 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1419 run_test 27q "append to truncated file with all OSTs full (should error) ==="
1422 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1423 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1424 remote_ost_nodsh && skip "remote OST with nodsh" && return
1427 rm -f $DIR/$tdir/$tfile
1428 exhaust_precreations 0 0x80000215
1430 $SETSTRIPE -i 0 -c 2 $DIR/$tdir/$tfile # && error
1434 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1436 test_27s() { # bug 10725
1437 test_mkdir -p $DIR/$tdir
1438 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1439 local stripe_count=0
1440 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1441 $SETSTRIPE -S $stripe_size -c $stripe_count $DIR/$tdir &&
1442 error "stripe width >= 2^32 succeeded" || true
1445 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1447 test_27t() { # bug 10864
1452 $WLFS getstripe $tfile
1455 run_test 27t "check that utils parse path correctly"
1457 test_27u() { # bug 4900
1458 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1459 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1461 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1462 do_facet $SINGLEMDS lctl set_param fail_loc=0x139
1463 test_mkdir -p $DIR/$tdir
1464 createmany -o $DIR/$tdir/t- 1000
1465 do_facet $SINGLEMDS lctl set_param fail_loc=0
1467 TLOG=$DIR/$tfile.getstripe
1468 $GETSTRIPE $DIR/$tdir > $TLOG
1469 OBJS=`awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj;}' $TLOG`
1470 unlinkmany $DIR/$tdir/t- 1000
1471 [ $OBJS -gt 0 ] && \
1472 error "$OBJS objects created on OST-0. See $TLOG" || pass
1474 run_test 27u "skip object creation on OSC w/o objects =========="
1476 test_27v() { # bug 4900
1477 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1478 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1479 remote_ost_nodsh && skip "remote OST with nodsh" && return
1481 exhaust_all_precreations 0x215
1484 test_mkdir -p $DIR/$tdir
1485 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1487 touch $DIR/$tdir/$tfile
1488 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1490 for (( i=1; i < OSTCOUNT; i++ )); do
1491 do_facet ost$i lctl set_param fail_loc=0x705
1493 local START=`date +%s`
1494 createmany -o $DIR/$tdir/$tfile 32
1496 local FINISH=`date +%s`
1497 local TIMEOUT=`lctl get_param -n timeout`
1498 local PROCESS=$((FINISH - START))
1499 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1500 error "$FINISH - $START >= $TIMEOUT / 2"
1501 sleep $((TIMEOUT / 2 - PROCESS))
1504 run_test 27v "skip object creation on slow OST ================="
1506 test_27w() { # bug 10997
1507 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1508 $SETSTRIPE -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1509 [ $($GETSTRIPE -S $DIR/$tdir/f0) -ne 65536 ] &&
1510 error "stripe size $size != 65536" || true
1511 [ $($GETSTRIPE -d $DIR/$tdir | grep -c "stripe_count") -ne 1 ] &&
1512 error "$GETSTRIPE -d $DIR/$tdir failed" || true
1514 run_test 27w "check $SETSTRIPE -S option"
1517 [ "$OSTCOUNT" -lt "2" ] &&
1518 skip_env "skipping multiple stripe count/offset test" && return
1520 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1521 for i in $(seq 1 $OSTCOUNT); do
1523 $SETSTRIPE -c $i -i $offset $DIR/$tdir/f$i ||
1524 error "setstripe -c $i -i $offset failed"
1525 count=$($GETSTRIPE -c $DIR/$tdir/f$i)
1526 index=$($GETSTRIPE -i $DIR/$tdir/f$i)
1527 [ $count -ne $i ] && error "stripe count $count != $i" || true
1528 [ $index -ne $offset ] &&
1529 error "stripe offset $index != $offset" || true
1532 run_test 27wa "check $SETSTRIPE -c -i options"
1535 remote_ost_nodsh && skip "remote OST with nodsh" && return
1536 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs" && return
1537 OFFSET=$(($OSTCOUNT - 1))
1539 local OST=$(ostname_from_index $OSTIDX)
1541 test_mkdir -p $DIR/$tdir
1542 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe per file
1543 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1545 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1546 for i in `seq 0 $OFFSET`; do
1547 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}' | grep -w "$OSTIDX"` ] &&
1548 error "OST0 was degraded but new created file still use it"
1550 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1552 run_test 27x "create files while OST0 is degraded"
1555 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1556 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1557 remote_ost_nodsh && skip "remote OST with nodsh" && return
1559 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1560 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1561 osc.$mdtosc.prealloc_last_id)
1562 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1563 osc.$mdtosc.prealloc_next_id)
1564 local fcount=$((last_id - next_id))
1565 [ $fcount -eq 0 ] && skip "not enough space on OST0" && return
1566 [ $fcount -gt $OSTCOUNT ] && fcount=$OSTCOUNT
1568 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
1569 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
1570 local OST_DEACTIVE_IDX=-1
1575 for OSC in $MDS_OSCS; do
1576 OST=$(osc_to_ost $OSC)
1577 OSTIDX=$(index_from_ostuuid $OST)
1578 if [ $OST_DEACTIVE_IDX == -1 ]; then
1579 OST_DEACTIVE_IDX=$OSTIDX
1581 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
1582 echo $OSC "is Deactivated:"
1583 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1587 OSTIDX=$(index_from_ostuuid $OST)
1589 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1591 for OSC in $MDS_OSCS; do
1592 OST=$(osc_to_ost $OSC)
1593 OSTIDX=$(index_from_ostuuid $OST)
1594 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1595 echo $OST "is degraded:"
1596 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1597 obdfilter.$OST.degraded=1
1602 createmany -o $DIR/$tdir/$tfile $fcount
1604 for OSC in $MDS_OSCS; do
1605 OST=$(osc_to_ost $OSC)
1606 OSTIDX=$(index_from_ostuuid $OST)
1607 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1608 echo $OST "is recovered from degraded:"
1609 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1610 obdfilter.$OST.degraded=0
1612 do_facet $SINGLEMDS lctl --device %$OSC activate
1616 run_test 27y "create files while OST0 is degraded and the rest inactive"
1622 lmm_count=$($GETSTRIPE -c $1)
1623 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1624 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1626 local old_ifs="$IFS"
1628 fid=($($LFS path2fid $1))
1631 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1632 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1634 # compare lmm_seq and lu_fid->f_seq
1635 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1636 # compare lmm_object_id and lu_fid->oid
1637 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1639 # check the trusted.fid attribute of the OST objects of the file
1640 local have_obdidx=false
1642 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1643 # skip lines up to and including "obdidx"
1644 [ -z "$obdidx" ] && break
1645 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1646 $have_obdidx || continue
1648 local ost=$((obdidx + 1))
1649 local dev=$(ostdevname $ost)
1651 if [ $(facet_fstype ost$ost) != ldiskfs ]; then
1652 echo "Currently only works with ldiskfs-based OSTs"
1656 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1658 #don't unmount/remount the OSTs if we don't need to do that
1659 #local dir=$(facet_mntpt ost$ost)
1661 #do_facet ost$dev mount -t $FSTYPE $dev $dir $OST_MOUNT_OPTS ||
1662 # { error "mounting $dev as $FSTYPE failed"; return 3; }
1663 #local obj_file=$(do_facet ost$ost find $dir/O/$seq -name $oid)
1664 #local ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID $obj_file)
1666 local obj_file="O/$seq/d$((oid %32))/$oid"
1667 local ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
1668 $dev 2>/dev/null" | grep "parent=")
1670 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
1672 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
1674 #do_facet ost$ost umount -d $dir
1675 #start ost$ost $dev $OST_MOUNT_OPTS
1677 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
1678 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
1679 local ff_parent=$(echo $ff|sed -e 's/.*parent=.//')
1680 local ff_pseq=$(echo $ff_parent | cut -d: -f1)
1681 local ff_poid=$(echo $ff_parent | cut -d: -f2)
1682 local ff_pstripe=$(echo $ff_parent | sed -e 's/.*stripe=//')
1684 # compare lmm_seq and filter_fid->ff_parent.f_seq
1685 [ $ff_pseq = $lmm_seq ] ||
1686 error "FF parent SEQ $ff_pseq != $lmm_seq"
1687 # compare lmm_object_id and filter_fid->ff_parent.f_oid
1688 [ $ff_poid = $lmm_oid ] ||
1689 error "FF parent OID $ff_poid != $lmm_oid"
1690 [ $ff_pstripe = $stripe_nr ] ||
1691 error "FF stripe $ff_pstripe != $stripe_nr"
1693 stripe_nr=$((stripe_nr + 1))
1698 remote_ost_nodsh && skip "remote OST with nodsh" && return
1699 test_mkdir -p $DIR/$tdir
1701 $SETSTRIPE -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
1702 { error "setstripe -c -1 failed"; return 1; }
1703 # We need to send a write to every object to get parent FID info set.
1704 # This _should_ also work for setattr, but does not currently.
1705 # touch $DIR/$tdir/$tfile-1 ||
1706 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
1707 { error "dd $tfile-1 failed"; return 2; }
1708 $SETSTRIPE -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
1709 { error "setstripe -c -1 failed"; return 3; }
1710 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
1711 { error "dd $tfile-2 failed"; return 4; }
1713 # make sure write RPCs have been sent to OSTs
1716 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
1717 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
1719 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
1721 test_27A() { # b=19102
1722 local restore_size=$($GETSTRIPE -S $MOUNT)
1723 local restore_count=$($GETSTRIPE -c $MOUNT)
1724 local restore_offset=$($GETSTRIPE -i $MOUNT)
1725 $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
1726 local default_size=$($GETSTRIPE -S $MOUNT)
1727 local default_count=$($GETSTRIPE -c $MOUNT)
1728 local default_offset=$($GETSTRIPE -i $MOUNT)
1729 local dsize=$((1024 * 1024))
1730 [ $default_size -eq $dsize ] ||
1731 error "stripe size $default_size != $dsize"
1732 [ $default_count -eq 1 ] || error "stripe count $default_count != 1"
1733 [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
1734 $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
1736 run_test 27A "check filesystem-wide default LOV EA values"
1738 # createtest also checks that device nodes are created and
1739 # then visible correctly (#2091)
1740 test_28() { # bug 2091
1742 $CREATETEST $DIR/d28/ct || error
1744 run_test 28 "create/mknod/mkdir with bad file types ============"
1747 cancel_lru_locks mdc
1753 declare -i LOCKCOUNTORIG=0
1754 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1755 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
1757 [ $LOCKCOUNTORIG -eq 0 ] && echo "No mdc lock count" && return 1
1759 declare -i LOCKUNUSEDCOUNTORIG=0
1760 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1761 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
1768 declare -i LOCKCOUNTCURRENT=0
1769 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1770 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
1773 declare -i LOCKUNUSEDCOUNTCURRENT=0
1774 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1775 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
1778 if [ "$LOCKCOUNTCURRENT" -gt "$LOCKCOUNTORIG" ]; then
1779 lctl set_param -n ldlm.dump_namespaces ""
1780 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
1781 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1782 log "dumped log to $TMP/test_29.dk (bug 5793)"
1785 if [ "$LOCKUNUSEDCOUNTCURRENT" -gt "$LOCKUNUSEDCOUNTORIG" ]; then
1786 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
1787 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1788 log "dumped log to $TMP/test_29.dk (bug 5793)"
1792 run_test 29 "IT_GETATTR regression ============================"
1794 test_30a() { # was test_30
1795 cp `which ls` $DIR || cp /bin/ls $DIR
1799 run_test 30a "execute binary from Lustre (execve) =============="
1802 cp `which ls` $DIR || cp /bin/ls $DIR
1804 $RUNAS $DIR/ls / || error
1807 run_test 30b "execute binary from Lustre as non-root ==========="
1809 test_30c() { # b=22376
1810 cp `which ls` $DIR || cp /bin/ls $DIR
1812 cancel_lru_locks mdc
1813 cancel_lru_locks osc
1814 $RUNAS $DIR/ls / || error
1817 run_test 30c "execute binary from Lustre without read perms ===="
1820 $OPENUNLINK $DIR/f31 $DIR/f31 || error
1821 $CHECKSTAT -a $DIR/f31 || error
1823 run_test 31a "open-unlink file =================================="
1826 touch $DIR/f31 || error
1827 ln $DIR/f31 $DIR/f31b || error
1828 $MULTIOP $DIR/f31b Ouc || error
1829 $CHECKSTAT -t file $DIR/f31 || error
1831 run_test 31b "unlink file with multiple links while open ======="
1834 touch $DIR/f31 || error
1835 ln $DIR/f31 $DIR/f31c || error
1836 multiop_bg_pause $DIR/f31 O_uc || return 1
1838 $MULTIOP $DIR/f31c Ouc
1839 kill -USR1 $MULTIPID
1842 run_test 31c "open-unlink file with multiple links ============="
1845 opendirunlink $DIR/d31d $DIR/d31d || error
1846 $CHECKSTAT -a $DIR/d31d || error
1848 run_test 31d "remove of open directory ========================="
1850 test_31e() { # bug 2904
1851 check_kernel_version 34 || return 0
1852 openfilleddirunlink $DIR/d31e || error
1854 run_test 31e "remove of open non-empty directory ==============="
1856 test_31f() { # bug 4554
1858 test_mkdir $DIR/d31f
1859 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
1860 cp /etc/hosts $DIR/d31f
1862 $GETSTRIPE $DIR/d31f/hosts
1863 multiop_bg_pause $DIR/d31f D_c || return 1
1866 rm -rv $DIR/d31f || error "first of $DIR/d31f"
1867 test_mkdir $DIR/d31f
1868 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
1869 cp /etc/hosts $DIR/d31f
1871 $GETSTRIPE $DIR/d31f/hosts
1872 multiop_bg_pause $DIR/d31f D_c || return 1
1875 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
1876 wait $MULTIPID || error "first opendir $MULTIPID failed"
1880 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
1881 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
1884 run_test 31f "remove of open directory with open-unlink file ==="
1887 echo "-- cross directory link --"
1888 test_mkdir $DIR/d31ga
1889 test_mkdir $DIR/d31gb
1891 ln $DIR/d31ga/f $DIR/d31gb/g
1892 $CHECKSTAT -t file $DIR/d31ga/f || error "source"
1893 [ `stat -c%h $DIR/d31ga/f` == '2' ] || error "source nlink"
1894 $CHECKSTAT -t file $DIR/d31gb/g || error "target"
1895 [ `stat -c%h $DIR/d31gb/g` == '2' ] || error "target nlink"
1897 run_test 31g "cross directory link==============="
1900 echo "-- cross directory link --"
1901 test_mkdir $DIR/d31h
1902 test_mkdir $DIR/d31h/dir
1904 ln $DIR/d31h/f $DIR/d31h/dir/g
1905 $CHECKSTAT -t file $DIR/d31h/f || error "source"
1906 [ `stat -c%h $DIR/d31h/f` == '2' ] || error "source nlink"
1907 $CHECKSTAT -t file $DIR/d31h/dir/g || error "target"
1908 [ `stat -c%h $DIR/d31h/dir/g` == '2' ] || error "target nlink"
1910 run_test 31h "cross directory link under child==============="
1913 echo "-- cross directory link --"
1914 test_mkdir $DIR/d31i
1915 test_mkdir $DIR/d31i/dir
1916 touch $DIR/d31i/dir/f
1917 ln $DIR/d31i/dir/f $DIR/d31i/g
1918 $CHECKSTAT -t file $DIR/d31i/dir/f || error "source"
1919 [ `stat -c%h $DIR/d31i/dir/f` == '2' ] || error "source nlink"
1920 $CHECKSTAT -t file $DIR/d31i/g || error "target"
1921 [ `stat -c%h $DIR/d31i/g` == '2' ] || error "target nlink"
1923 run_test 31i "cross directory link under parent==============="
1927 test_mkdir $DIR/d31j
1928 test_mkdir $DIR/d31j/dir1
1929 ln $DIR/d31j/dir1 $DIR/d31j/dir2 && error "ln for dir"
1930 link $DIR/d31j/dir1 $DIR/d31j/dir3 && error "link for dir"
1931 mlink $DIR/d31j/dir1 $DIR/d31j/dir4 && error "mlink for dir"
1932 mlink $DIR/d31j/dir1 $DIR/d31j/dir1 && error "mlink to the same dir"
1935 run_test 31j "link for directory==============="
1939 test_mkdir $DIR/d31k
1941 touch $DIR/d31k/exist
1942 mlink $DIR/d31k/s $DIR/d31k/t || error "mlink"
1943 mlink $DIR/d31k/s $DIR/d31k/exist && error "mlink to exist file"
1944 mlink $DIR/d31k/s $DIR/d31k/s && error "mlink to the same file"
1945 mlink $DIR/d31k/s $DIR/d31k && error "mlink to parent dir"
1946 mlink $DIR/d31k $DIR/d31k/s && error "mlink parent dir to target"
1947 mlink $DIR/d31k/not-exist $DIR/d31k/foo && error "mlink non-existing to new"
1948 mlink $DIR/d31k/not-exist $DIR/d31k/s && error "mlink non-existing to exist"
1951 run_test 31k "link to file: the same, non-existing, dir==============="
1954 test_mkdir $DIR/d31m
1956 test_mkdir $DIR/d31m2
1957 touch $DIR/d31m2/exist
1958 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
1959 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
1960 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
1961 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
1962 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
1963 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
1966 run_test 31m "link to file: the same, non-existing, dir==============="
1968 cleanup_test32_mount() {
1970 $UMOUNT $DIR/$tdir/ext2-mountpoint
1974 echo "== more mountpoints and symlinks ================="
1975 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
1976 trap cleanup_test32_mount EXIT
1977 test_mkdir -p $DIR/$tdir/ext2-mountpoint
1978 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
1979 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. || error
1980 cleanup_test32_mount
1982 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
1985 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
1986 trap cleanup_test32_mount EXIT
1987 test_mkdir -p $DIR/$tdir/ext2-mountpoint
1988 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
1989 ls -al $DIR/$tdir/ext2-mountpoint/.. || error
1990 cleanup_test32_mount
1992 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
1995 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
1996 trap cleanup_test32_mount EXIT
1997 test_mkdir -p $DIR/$tdir/ext2-mountpoint
1998 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
1999 test_mkdir -p $DIR/$tdir/d2/test_dir
2000 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2001 cleanup_test32_mount
2003 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2006 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2007 trap cleanup_test32_mount EXIT
2008 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2009 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2010 test_mkdir -p $DIR/$tdir/d2/test_dir
2011 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2012 cleanup_test32_mount
2014 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
2017 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
2018 test_mkdir -p $DIR/d32e/tmp
2019 TMP_DIR=$DIR/d32e/tmp
2020 ln -s $DIR/d32e $TMP_DIR/symlink11
2021 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2022 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
2023 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
2025 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
2028 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
2029 test_mkdir -p $DIR/d32f/tmp
2030 TMP_DIR=$DIR/d32f/tmp
2031 ln -s $DIR/d32f $TMP_DIR/symlink11
2032 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2033 ls $DIR/d32f/tmp/symlink11 || error
2034 ls $DIR/d32f/symlink01 || error
2036 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
2039 TMP_DIR=$DIR/$tdir/tmp
2040 test_mkdir -p $DIR/$tdir/tmp
2041 test_mkdir $DIR/${tdir}2
2042 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2043 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2044 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
2045 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
2046 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
2047 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
2049 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2052 rm -fr $DIR/$tdir $DIR/${tdir}2
2053 TMP_DIR=$DIR/$tdir/tmp
2054 test_mkdir -p $DIR/$tdir/tmp
2055 test_mkdir $DIR/${tdir}2
2056 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2057 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2058 ls $TMP_DIR/symlink12 || error
2059 ls $DIR/$tdir/symlink02 || error
2061 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2064 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2065 trap cleanup_test32_mount EXIT
2066 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2067 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2068 touch $DIR/$tdir/test_file
2069 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file || error
2070 cleanup_test32_mount
2072 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
2075 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2076 trap cleanup_test32_mount EXIT
2077 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2078 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2079 touch $DIR/$tdir/test_file
2080 cat $DIR/$tdir/ext2-mountpoint/../test_file || error
2081 cleanup_test32_mount
2083 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
2087 trap cleanup_test32_mount EXIT
2088 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2089 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2090 test_mkdir -p $DIR/$tdir/d2
2091 touch $DIR/$tdir/d2/test_file || error
2092 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2093 cleanup_test32_mount
2095 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
2099 trap cleanup_test32_mount EXIT
2100 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2101 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2102 test_mkdir -p $DIR/$tdir/d2
2103 touch $DIR/$tdir/d2/test_file
2104 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2105 cleanup_test32_mount
2107 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
2111 test_mkdir -p $DIR/d32m/tmp
2112 TMP_DIR=$DIR/d32m/tmp
2113 ln -s $DIR $TMP_DIR/symlink11
2114 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2115 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
2116 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
2118 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
2122 test_mkdir -p $DIR/d32n/tmp
2123 TMP_DIR=$DIR/d32n/tmp
2124 ln -s $DIR $TMP_DIR/symlink11
2125 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2126 ls -l $DIR/d32n/tmp/symlink11 || error
2127 ls -l $DIR/d32n/symlink01 || error
2129 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
2132 rm -fr $DIR/d32o $DIR/$tfile
2134 test_mkdir -p $DIR/d32o/tmp
2135 TMP_DIR=$DIR/d32o/tmp
2136 ln -s $DIR/$tfile $TMP_DIR/symlink12
2137 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2138 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
2139 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
2140 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
2141 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
2143 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
2153 test_mkdir -p $DIR/d32p/tmp
2155 TMP_DIR=$DIR/d32p/tmp
2157 ln -s $DIR/$tfile $TMP_DIR/symlink12
2159 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2161 cat $DIR/d32p/tmp/symlink12 || error
2163 cat $DIR/d32p/symlink02 || error
2166 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
2168 cleanup_testdir_mount() {
2174 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2175 trap cleanup_testdir_mount EXIT
2176 test_mkdir -p $DIR/$tdir
2177 touch $DIR/$tdir/under_the_mount
2178 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2179 ls $DIR/$tdir | grep "\<under_the_mount\>" && error
2180 cleanup_testdir_mount
2182 run_test 32q "stat follows mountpoints in Lustre (should return error)"
2185 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2186 trap cleanup_testdir_mount EXIT
2187 test_mkdir -p $DIR/$tdir
2188 touch $DIR/$tdir/under_the_mount
2189 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2190 ls $DIR/$tdir | grep -q under_the_mount && error || true
2191 cleanup_testdir_mount
2193 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
2198 chmod 444 $DIR/$tfile
2199 chown $RUNAS_ID $DIR/$tfile
2201 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2204 run_test 33aa "write file with mode 444 (should return error) ===="
2208 test_mkdir -p $DIR/d33
2209 chown $RUNAS_ID $DIR/d33
2210 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
2211 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
2212 error "open RDWR" || true
2214 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
2218 test_mkdir -p $DIR/d33
2219 chown $RUNAS_ID $DIR/d33
2220 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33 && error "create" || true
2222 run_test 33b "test open file with malformed flags (No panic and return error)"
2230 remote_ost_nodsh && skip "remote OST with nodsh" && return
2233 test_mkdir -p $DIR/d33
2234 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2237 for ostnum in $(seq $OSTCOUNT); do
2238 # test-framework's OST numbering is one-based, while Lustre's
2240 ostname=$(printf "$FSNAME-OST%.4d" $((ostnum - 1)))
2241 # Parsing llobdstat's output sucks; we could grep the /proc
2242 # path, but that's likely to not be as portable as using the
2243 # llobdstat utility. So we parse lctl output instead.
2244 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2245 obdfilter/$ostname/stats |
2246 awk '/^write_bytes/ {print $7}' )
2247 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2248 if (( ${write_bytes:-0} > 0 ))
2255 $all_zeros || return 0
2258 echo foo > $DIR/d33/bar
2262 # Total up write_bytes after writing. We'd better find non-zeros.
2263 for ostnum in $(seq $OSTCOUNT); do
2264 ostname=$(printf "$FSNAME-OST%.4d" $((ostnum - 1)))
2265 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2266 obdfilter/$ostname/stats |
2267 awk '/^write_bytes/ {print $7}' )
2268 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2269 if (( ${write_bytes:-0} > 0 ))
2278 for ostnum in $(seq $OSTCOUNT); do
2279 ostname=$(printf "$FSNAME-OST%.4d" $((ostnum - 1)))
2280 echo "Check that write_bytes is present in obdfilter/*/stats:"
2281 do_facet ost$ostnum lctl get_param -n \
2282 obdfilter/$ostname/stats
2284 error "OST not keeping write_bytes stats (b22312)"
2287 run_test 33c "test llobdstat and write_bytes"
2290 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2292 local remote_dir=$DIR/$tdir/remote_dir
2295 $LFS mkdir -i $MDTIDX $remote_dir ||
2296 error "create remote directory failed"
2298 touch $remote_dir/$tfile
2299 chmod 444 $remote_dir/$tfile
2300 chown $RUNAS_ID $remote_dir/$tfile
2302 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2304 chown $RUNAS_ID $remote_dir
2305 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
2306 error "create" || true
2307 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
2308 error "open RDWR" || true
2309 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 &&
2310 error "create" || true
2312 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
2314 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
2317 $MCREATE $DIR/f34 || error
2318 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2319 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
2320 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2321 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2323 run_test 34a "truncate file that has not been opened ==========="
2326 [ ! -f $DIR/f34 ] && test_34a
2327 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2328 $OPENFILE -f O_RDONLY $DIR/f34
2329 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2330 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2332 run_test 34b "O_RDONLY opening file doesn't create objects ====="
2335 [ ! -f $DIR/f34 ] && test_34a
2336 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2337 $OPENFILE -f O_RDWR $DIR/f34
2338 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2339 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2341 run_test 34c "O_RDWR opening file-with-size works =============="
2344 [ ! -f $DIR/f34 ] && test_34a
2345 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2346 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2349 run_test 34d "write to sparse file ============================="
2353 $MCREATE $DIR/f34e || error
2354 $TRUNCATE $DIR/f34e 1000 || error
2355 $CHECKSTAT -s 1000 $DIR/f34e || error
2356 $OPENFILE -f O_RDWR $DIR/f34e
2357 $CHECKSTAT -s 1000 $DIR/f34e || error
2359 run_test 34e "create objects, some with size and some without =="
2361 test_34f() { # bug 6242, 6243
2364 $MCREATE $DIR/f34f || error
2365 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
2366 dd if=$DIR/f34f of=$TMP/f34f
2367 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
2368 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
2369 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
2370 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
2371 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
2373 run_test 34f "read from a file with no objects until EOF ======="
2376 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
2377 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
2378 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
2379 cancel_lru_locks osc
2380 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
2381 error "wrong size after lock cancel"
2383 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
2384 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2385 error "expanding truncate failed"
2386 cancel_lru_locks osc
2387 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2388 error "wrong expanded size after lock cancel"
2390 run_test 34g "truncate long file ==============================="
2396 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
2397 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
2401 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
2402 error "Multiop blocked on ftruncate, pid=$MULTIPID"
2406 local nsz=`stat -c %s $DIR/$tfile`
2407 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
2409 run_test 34h "ftruncate file under grouplock should not block"
2412 cp /bin/sh $DIR/f35a
2414 chown $RUNAS_ID $DIR/f35a
2415 $RUNAS $DIR/f35a && error || true
2418 run_test 35a "exec file with mode 444 (should return and not leak) ====="
2422 utime $DIR/f36 || error
2424 run_test 36a "MDS utime check (mknod, utime) ==================="
2428 utime $DIR/f36 || error
2430 run_test 36b "OST utime check (open, utime) ===================="
2435 chown $RUNAS_ID $DIR/d36
2436 $RUNAS utime $DIR/d36/f36 || error
2438 run_test 36c "non-root MDS utime check (mknod, utime) =========="
2441 [ ! -d $DIR/d36 ] && test_36c
2442 echo "" > $DIR/d36/f36
2443 $RUNAS utime $DIR/d36/f36 || error
2445 run_test 36d "non-root OST utime check (open, utime) ==========="
2448 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
2449 test_mkdir -p $DIR/$tdir
2450 touch $DIR/$tdir/$tfile
2451 $RUNAS utime $DIR/$tdir/$tfile && \
2452 error "utime worked, expected failure" || true
2454 run_test 36e "utime on non-owned file (should return error) ===="
2458 local LANG_SAVE=$LANG
2459 local LC_LANG_SAVE=$LC_LANG
2460 export LANG=C LC_LANG=C # for date language
2462 DATESTR="Dec 20 2000"
2463 test_mkdir -p $DIR/$tdir
2464 lctl set_param fail_loc=$fl
2466 cp /etc/hosts $DIR/$tdir/$tfile
2467 sync & # write RPC generated with "current" inode timestamp, but delayed
2469 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
2470 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
2471 cancel_lru_locks osc
2472 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
2474 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
2475 echo "BEFORE: $LS_BEFORE" && \
2476 echo "AFTER : $LS_AFTER" && \
2477 echo "WANT : $DATESTR" && \
2478 error "$DIR/$tdir/$tfile timestamps changed" || true
2480 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
2484 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2485 subr_36fh "0x80000214"
2487 run_test 36f "utime on file racing with OST BRW write =========="
2490 remote_ost_nodsh && skip "remote OST with nodsh" && return
2495 test_mkdir -p $DIR/$tdir
2496 fmd_max_age=$(do_facet ost1 \
2497 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
2500 fmd_before=$(do_facet ost1 \
2501 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2502 touch $DIR/$tdir/$tfile
2503 sleep $((fmd_max_age + 12))
2504 fmd_after=$(do_facet ost1 \
2505 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2507 echo "fmd_before: $fmd_before"
2508 echo "fmd_after: $fmd_after"
2509 [ "$fmd_after" -gt "$fmd_before" ] && \
2510 echo "AFTER: $fmd_after > BEFORE: $fmd_before" && \
2511 error "fmd didn't expire after ping" || true
2513 run_test 36g "filter mod data cache expiry ====================="
2516 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
2517 subr_36fh "0x80000227"
2519 run_test 36h "utime on file racing with OST BRW write =========="
2521 # test_37 - duplicate with tests 32q 32r
2524 local file=$DIR/$tfile
2526 openfile -f O_DIRECTORY $file
2529 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
2530 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
2532 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
2536 touch $DIR/${tfile}2
2537 # ls -l $DIR/$tfile $DIR/${tfile}2
2538 # ls -lu $DIR/$tfile $DIR/${tfile}2
2539 # ls -lc $DIR/$tfile $DIR/${tfile}2
2541 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
2542 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
2544 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
2546 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
2548 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
2549 error "O_TRUNC didn't change timestamps"
2552 run_test 39 "mtime changed on create ==========================="
2555 test_mkdir -p $DIR/$tdir
2556 cp -p /etc/passwd $DIR/$tdir/fopen
2557 cp -p /etc/passwd $DIR/$tdir/flink
2558 cp -p /etc/passwd $DIR/$tdir/funlink
2559 cp -p /etc/passwd $DIR/$tdir/frename
2560 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
2563 echo "aaaaaa" >> $DIR/$tdir/fopen
2564 echo "aaaaaa" >> $DIR/$tdir/flink
2565 echo "aaaaaa" >> $DIR/$tdir/funlink
2566 echo "aaaaaa" >> $DIR/$tdir/frename
2568 local open_new=`stat -c %Y $DIR/$tdir/fopen`
2569 local link_new=`stat -c %Y $DIR/$tdir/flink`
2570 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
2571 local rename_new=`stat -c %Y $DIR/$tdir/frename`
2573 cat $DIR/$tdir/fopen > /dev/null
2574 ln $DIR/$tdir/flink $DIR/$tdir/flink2
2575 rm -f $DIR/$tdir/funlink2
2576 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
2578 for (( i=0; i < 2; i++ )) ; do
2579 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
2580 local link_new2=`stat -c %Y $DIR/$tdir/flink`
2581 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
2582 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
2584 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
2585 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
2586 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
2587 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
2589 cancel_lru_locks osc
2590 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2593 run_test 39b "mtime change on open, link, unlink, rename ======"
2595 # this should be set to past
2596 TEST_39_MTIME=`date -d "1 year ago" +%s`
2602 local mtime0=`stat -c %Y $DIR1/$tfile`
2604 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2605 local mtime1=`stat -c %Y $DIR1/$tfile`
2606 [ "$mtime1" = $TEST_39_MTIME ] || \
2607 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
2610 echo hello >> $DIR1/$tfile
2612 local mtime2=`stat -c %Y $DIR1/$tfile`
2613 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
2614 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
2616 mv $DIR1/$tfile $DIR1/$tfile-1
2618 for (( i=0; i < 2; i++ )) ; do
2619 local mtime3=`stat -c %Y $DIR1/$tfile-1`
2620 [ "$mtime2" = "$mtime3" ] || \
2621 error "mtime ($mtime2) changed (to $mtime3) on rename"
2623 cancel_lru_locks osc
2624 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2627 run_test 39c "mtime change on rename ==========================="
2633 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2635 for (( i=0; i < 2; i++ )) ; do
2636 local mtime=`stat -c %Y $DIR1/$tfile`
2637 [ $mtime = $TEST_39_MTIME ] || \
2638 error "mtime($mtime) is not set to $TEST_39_MTIME"
2640 cancel_lru_locks osc
2641 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2644 run_test 39d "create, utime, stat =============================="
2649 local mtime1=`stat -c %Y $DIR1/$tfile`
2651 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2653 for (( i=0; i < 2; i++ )) ; do
2654 local mtime2=`stat -c %Y $DIR1/$tfile`
2655 [ $mtime2 = $TEST_39_MTIME ] || \
2656 error "mtime($mtime2) is not set to $TEST_39_MTIME"
2658 cancel_lru_locks osc
2659 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2662 run_test 39e "create, stat, utime, stat ========================"
2667 mtime1=`stat -c %Y $DIR1/$tfile`
2670 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2672 for (( i=0; i < 2; i++ )) ; do
2673 local mtime2=`stat -c %Y $DIR1/$tfile`
2674 [ $mtime2 = $TEST_39_MTIME ] || \
2675 error "mtime($mtime2) is not set to $TEST_39_MTIME"
2677 cancel_lru_locks osc
2678 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2681 run_test 39f "create, stat, sleep, utime, stat ================="
2685 echo hello >> $DIR1/$tfile
2686 local mtime1=`stat -c %Y $DIR1/$tfile`
2689 chmod o+r $DIR1/$tfile
2691 for (( i=0; i < 2; i++ )) ; do
2692 local mtime2=`stat -c %Y $DIR1/$tfile`
2693 [ "$mtime1" = "$mtime2" ] || \
2694 error "lost mtime: $mtime2, should be $mtime1"
2696 cancel_lru_locks osc
2697 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2700 run_test 39g "write, chmod, stat ==============================="
2708 echo hello >> $DIR1/$tfile
2709 local mtime1=`stat -c %Y $DIR1/$tfile`
2711 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2713 if [ "$d1" != "$d2" ]; then
2714 echo "write and touch not within one second"
2716 for (( i=0; i < 2; i++ )) ; do
2717 local mtime2=`stat -c %Y $DIR1/$tfile`
2718 [ "$mtime2" = $TEST_39_MTIME ] || \
2719 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
2721 cancel_lru_locks osc
2722 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2726 run_test 39h "write, utime within one second, stat ============="
2732 echo hello >> $DIR1/$tfile
2733 local mtime1=`stat -c %Y $DIR1/$tfile`
2735 mv $DIR1/$tfile $DIR1/$tfile-1
2737 for (( i=0; i < 2; i++ )) ; do
2738 local mtime2=`stat -c %Y $DIR1/$tfile-1`
2740 [ "$mtime1" = "$mtime2" ] || \
2741 error "lost mtime: $mtime2, should be $mtime1"
2743 cancel_lru_locks osc
2744 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2747 run_test 39i "write, rename, stat =============================="
2750 start_full_debug_logging
2754 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
2755 lctl set_param fail_loc=0x80000412
2756 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
2757 error "multiop failed"
2759 local mtime1=`stat -c %Y $DIR1/$tfile`
2761 mv $DIR1/$tfile $DIR1/$tfile-1
2763 kill -USR1 $multipid
2764 wait $multipid || error "multiop close failed"
2766 for (( i=0; i < 2; i++ )) ; do
2767 local mtime2=`stat -c %Y $DIR1/$tfile-1`
2768 [ "$mtime1" = "$mtime2" ] ||
2769 error "mtime is lost on close: $mtime2, " \
2772 cancel_lru_locks osc
2773 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2775 lctl set_param fail_loc=0
2776 stop_full_debug_logging
2778 run_test 39j "write, rename, close, stat ======================="
2784 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
2786 local mtime1=`stat -c %Y $DIR1/$tfile`
2788 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2790 kill -USR1 $multipid
2791 wait $multipid || error "multiop close failed"
2793 for (( i=0; i < 2; i++ )) ; do
2794 local mtime2=`stat -c %Y $DIR1/$tfile`
2796 [ "$mtime2" = $TEST_39_MTIME ] || \
2797 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
2799 cancel_lru_locks osc
2800 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2803 run_test 39k "write, utime, close, stat ========================"
2805 # this should be set to future
2806 TEST_39_ATIME=`date -d "1 year" +%s`
2809 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2810 local atime_diff=$(do_facet $SINGLEMDS \
2811 lctl get_param -n mdd.*MDT0000*.atime_diff)
2815 # test setting directory atime to future
2816 touch -a -d @$TEST_39_ATIME $DIR/$tdir
2817 local atime=$(stat -c %X $DIR/$tdir)
2818 [ "$atime" = $TEST_39_ATIME ] || \
2819 error "atime is not set to future: $atime, $TEST_39_ATIME"
2821 # test setting directory atime from future to now
2822 local d1=$(date +%s)
2824 local d2=$(date +%s)
2826 cancel_lru_locks mdc
2827 atime=$(stat -c %X $DIR/$tdir)
2828 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
2829 error "atime is not updated from future: $atime, $d1<atime<$d2"
2831 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
2834 # test setting directory atime when now > dir atime + atime_diff
2838 cancel_lru_locks mdc
2839 atime=$(stat -c %X $DIR/$tdir)
2840 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
2841 error "atime is not updated : $atime, should be $d2"
2843 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
2846 # test not setting directory atime when now < dir atime + atime_diff
2848 cancel_lru_locks mdc
2849 atime=$(stat -c %X $DIR/$tdir)
2850 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
2851 error "atime is updated to $atime, should remain $d1<atime<$d2"
2853 do_facet $SINGLEMDS \
2854 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
2856 run_test 39l "directory atime update ==========================="
2861 local far_past_mtime=$(date -d "May 29 1953" +%s)
2862 local far_past_atime=$(date -d "Dec 17 1903" +%s)
2864 touch -m -d @$far_past_mtime $DIR1/$tfile
2865 touch -a -d @$far_past_atime $DIR1/$tfile
2867 for (( i=0; i < 2; i++ )) ; do
2868 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
2869 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
2870 error "atime or mtime set incorrectly"
2872 cancel_lru_locks osc
2873 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2876 run_test 39m "test atime and mtime before 1970"
2879 dd if=/dev/zero of=$DIR/f40 bs=4096 count=1
2880 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/f40 && error
2881 $CHECKSTAT -t file -s 4096 $DIR/f40 || error
2883 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
2887 small_write $DIR/f41 18
2889 run_test 41 "test small file write + fstat ====================="
2891 count_ost_writes() {
2892 lctl get_param -n osc.*.stats |
2893 awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }'
2900 BG_DIRTY_RATIO_SAVE=10
2901 MAX_BG_DIRTY_RATIO=25
2905 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
2906 # dirty_ratio, dirty_background_ratio
2907 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
2908 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
2909 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
2910 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
2912 # if file not here, we are a 2.4 kernel
2913 kill -CONT `pidof kupdated`
2918 # setup the trap first, so someone cannot exit the test at the
2919 # exact wrong time and mess up a machine
2920 trap start_writeback EXIT
2921 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
2922 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
2923 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
2924 sysctl -w vm.dirty_writeback_centisecs=0
2925 sysctl -w vm.dirty_writeback_centisecs=0
2926 # save and increase /proc/sys/vm/dirty_ratio
2927 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
2928 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
2929 # save and increase /proc/sys/vm/dirty_background_ratio
2930 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
2931 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
2933 # if file not here, we are a 2.4 kernel
2934 kill -STOP `pidof kupdated`
2938 # ensure that all stripes have some grant before we test client-side cache
2940 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
2941 dd if=/dev/zero of=$i bs=4k count=1
2946 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
2947 # file truncation, and file removal.
2950 cancel_lru_locks osc
2952 sync; sleep 1; sync # just to be safe
2953 BEFOREWRITES=`count_ost_writes`
2954 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
2955 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
2956 AFTERWRITES=`count_ost_writes`
2957 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
2958 error "$BEFOREWRITES < $AFTERWRITES"
2961 run_test 42a "ensure that we don't flush on close =============="
2965 cancel_lru_locks osc
2968 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
2969 BEFOREWRITES=`count_ost_writes`
2970 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
2971 AFTERWRITES=`count_ost_writes`
2972 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
2973 error "$BEFOREWRITES < $AFTERWRITES on unlink"
2975 BEFOREWRITES=`count_ost_writes`
2976 sync || error "sync: $?"
2977 AFTERWRITES=`count_ost_writes`
2978 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
2979 error "$BEFOREWRITES < $AFTERWRITES on sync"
2981 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
2985 run_test 42b "test destroy of file with cached dirty data ======"
2987 # if these tests just want to test the effect of truncation,
2988 # they have to be very careful. consider:
2989 # - the first open gets a {0,EOF}PR lock
2990 # - the first write conflicts and gets a {0, count-1}PW
2991 # - the rest of the writes are under {count,EOF}PW
2992 # - the open for truncate tries to match a {0,EOF}PR
2993 # for the filesize and cancels the PWs.
2994 # any number of fixes (don't get {0,EOF} on open, match
2995 # composite locks, do smarter file size management) fix
2996 # this, but for now we want these tests to verify that
2997 # the cancellation with truncate intent works, so we
2998 # start the file with a full-file pw lock to match against
2999 # until the truncate.
3004 cancel_lru_locks osc
3006 # prime the file with 0,EOF PW to match
3010 # now the real test..
3011 dd if=/dev/zero of=$file bs=1024 count=100
3012 BEFOREWRITES=`count_ost_writes`
3013 $TRUNCATE $file $offset
3014 cancel_lru_locks osc
3015 AFTERWRITES=`count_ost_writes`
3021 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
3022 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
3025 run_test 42c "test partial truncate of file with cached dirty data"
3029 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3030 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
3033 run_test 42d "test complete truncate of file with cached dirty data"
3035 test_42e() { # bug22074
3036 local TDIR=$DIR/${tdir}e
3037 local pagesz=$(page_size)
3038 local pages=16 # hardcoded 16 pages, don't change it.
3039 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
3040 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
3044 test_mkdir -p $DIR/${tdir}e
3045 $SETSTRIPE -c 1 $TDIR
3046 createmany -o $TDIR/f $files
3048 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
3050 # we assume that with $OSTCOUNT files, at least one of them will
3051 # be allocated on OST0.
3052 warmup_files=$((OSTCOUNT * max_dirty_mb))
3053 createmany -o $TDIR/w $warmup_files
3055 # write a large amount of data into one file and sync, to get good
3056 # avail_grant number from OST.
3057 for ((i=0; i<$warmup_files; i++)); do
3058 idx=$($GETSTRIPE -i $TDIR/w$i)
3059 [ $idx -ne 0 ] && continue
3060 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
3063 [ $i -gt $warmup_files ] && error "OST0 is still cold"
3065 $LCTL get_param $proc_osc0/cur_dirty_bytes
3066 $LCTL get_param $proc_osc0/cur_grant_bytes
3068 # create as much dirty pages as we can while not to trigger the actual
3069 # RPCs directly. but depends on the env, VFS may trigger flush during this
3070 # period, hopefully we are good.
3071 for ((i=0; i<$warmup_files; i++)); do
3072 idx=$($GETSTRIPE -i $TDIR/w$i)
3073 [ $idx -ne 0 ] && continue
3074 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
3076 $LCTL get_param $proc_osc0/cur_dirty_bytes
3077 $LCTL get_param $proc_osc0/cur_grant_bytes
3079 # perform the real test
3080 $LCTL set_param $proc_osc0/rpc_stats 0
3081 for ((;i<$files; i++)); do
3082 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
3083 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
3086 $LCTL get_param $proc_osc0/rpc_stats
3089 local have_ppr=false
3090 $LCTL get_param $proc_osc0/rpc_stats |
3091 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
3092 # skip lines until we are at the RPC histogram data
3093 [ "$PPR" == "pages" ] && have_ppr=true && continue
3094 $have_ppr || continue
3096 # we only want the percent stat for < 16 pages
3097 [ $(echo $PPR | tr -d ':') -ge $pages ] && break
3099 percent=$((percent + WPCT))
3100 if [ $percent -gt 15 ]; then
3101 error "less than 16-pages write RPCs" \
3108 run_test 42e "verify sub-RPC writes are not done synchronously"
3111 test_mkdir -p $DIR/$tdir
3112 cp -p /bin/ls $DIR/$tdir/$tfile
3113 $MULTIOP $DIR/$tdir/$tfile Ow_c &
3115 # give multiop a chance to open
3118 $DIR/$tdir/$tfile && error || true
3121 run_test 43 "execution of file opened for write should return -ETXTBSY"
3124 test_mkdir -p $DIR/$tdir
3125 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3126 cp -p multiop $DIR/$tdir/multiop
3127 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/test43.junk O_c ||
3130 $MULTIOP $DIR/$tdir/multiop Oc && error "expected error, got success"
3131 kill -USR1 $MULTIOP_PID || return 2
3132 wait $MULTIOP_PID || return 3
3135 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
3138 test_mkdir -p $DIR/$tdir
3139 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3140 cp -p multiop $DIR/$tdir/multiop
3141 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/test43.junk O_c ||
3144 $TRUNCATE $DIR/$tdir/multiop 0 && error "expected error, got success"
3145 kill -USR1 $MULTIOP_PID || return 2
3146 wait $MULTIOP_PID || return 3
3149 run_test 43b "truncate of file being executed should return -ETXTBSY"
3152 local testdir="$DIR/$tdir"
3153 test_mkdir -p $DIR/$tdir
3155 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
3156 ( cd $testdir && md5sum -c)
3158 run_test 43c "md5sum of copy into lustre========================"
3161 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
3162 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
3163 dd if=$DIR/f1 bs=4k count=1 > /dev/null
3165 run_test 44 "zero length read from a sparse stripe ============="
3168 local nstripe=`$LCTL lov_getconfig $DIR | grep default_stripe_count: | \
3170 [ -z "$nstripe" ] && skip "can't get stripe info" && return
3171 [ "$nstripe" -gt "$OSTCOUNT" ] && skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" && return
3172 local stride=`$LCTL lov_getconfig $DIR | grep default_stripe_size: | \
3174 if [ $nstripe -eq 0 -o $nstripe -eq -1 ] ; then
3175 nstripe=`$LCTL lov_getconfig $DIR | grep obd_count: | awk '{print $2}'`
3178 OFFSETS="0 $((stride/2)) $((stride-1))"
3179 for offset in $OFFSETS ; do
3180 for i in `seq 0 $((nstripe-1))`; do
3181 local GLOBALOFFSETS=""
3182 local size=$((((i + 2 * $nstripe )*$stride + $offset))) # Bytes
3183 local myfn=$DIR/d44a-$size
3184 echo "--------writing $myfn at $size"
3185 ll_sparseness_write $myfn $size || error "ll_sparseness_write"
3186 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3187 ll_sparseness_verify $myfn $GLOBALOFFSETS \
3188 || error "ll_sparseness_verify $GLOBALOFFSETS"
3190 for j in `seq 0 $((nstripe-1))`; do
3191 size=$((((j + $nstripe )*$stride + $offset))) # Bytes
3192 ll_sparseness_write $myfn $size || error "ll_sparseness_write"
3193 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3195 ll_sparseness_verify $myfn $GLOBALOFFSETS \
3196 || error "ll_sparseness_verify $GLOBALOFFSETS"
3201 run_test 44a "test sparse pwrite ==============================="
3205 for d in `lctl get_param -n osc.*.cur_dirty_bytes`; do
3211 before=`dirty_osc_total`
3212 echo executing "\"$*\""
3214 after=`dirty_osc_total`
3215 echo before $before, after $after
3219 # Obtain grants from OST if it supports it
3220 echo blah > ${f}_grant
3223 do_dirty_record "echo blah > $f"
3224 [ $before -eq $after ] && error "write wasn't cached"
3225 do_dirty_record "> $f"
3226 [ $before -gt $after ] || error "truncate didn't lower dirty count"
3227 do_dirty_record "echo blah > $f"
3228 [ $before -eq $after ] && error "write wasn't cached"
3229 do_dirty_record "sync"
3230 [ $before -gt $after ] || error "writeback didn't lower dirty count"
3231 do_dirty_record "echo blah > $f"
3232 [ $before -eq $after ] && error "write wasn't cached"
3233 do_dirty_record "cancel_lru_locks osc"
3234 [ $before -gt $after ] || error "lock cancellation didn't lower dirty count"
3237 run_test 45 "osc io page accounting ============================"
3239 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
3240 # test tickles a bug where re-dirtying a page was failing to be mapped to the
3241 # objects offset and an assert hit when an rpc was built with 1023's mapped
3242 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
3247 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3249 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
3250 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3254 run_test 46 "dirtying a previously written page ================"
3256 # test_47 is removed "Device nodes check" is moved to test_28
3258 test_48a() { # bug 2399
3259 check_kernel_version 34 || return 0
3260 test_mkdir -p $DIR/$tdir
3262 mv $DIR/$tdir $DIR/d48.new || error "move directory failed"
3263 test_mkdir $DIR/$tdir || error "recreate directory failed"
3264 touch foo || error "'touch foo' failed after recreating cwd"
3265 test_mkdir $DIR/$tdir/bar ||
3266 error "'mkdir foo' failed after recreating cwd"
3267 if check_kernel_version 44; then
3268 touch .foo || error "'touch .foo' failed after recreating cwd"
3269 test_mkdir $DIR/$tdir/.bar ||
3270 error "'mkdir .foo' failed after recreating cwd"
3272 ls . > /dev/null || error "'ls .' failed after recreating cwd"
3273 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3274 cd . || error "'cd .' failed after recreating cwd"
3275 test_mkdir . && error "'mkdir .' worked after recreating cwd"
3276 rmdir . && error "'rmdir .' worked after recreating cwd"
3277 ln -s . baz || error "'ln -s .' failed after recreating cwd"
3278 cd .. || error "'cd ..' failed after recreating cwd"
3280 run_test 48a "Access renamed working dir (should return errors)="
3282 test_48b() { # bug 2399
3283 check_kernel_version 34 || return 0
3285 test_mkdir -p $DIR/$tdir
3287 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
3288 touch foo && error "'touch foo' worked after removing cwd"
3289 test_mkdir $DIR/$tdir/foo &&
3290 error "'mkdir foo' worked after removing cwd"
3291 if check_kernel_version 44; then
3292 touch .foo && error "'touch .foo' worked after removing cwd"
3293 test_mkdir $DIR/$tdir/.foo &&
3294 error "'mkdir .foo' worked after removing cwd"
3296 ls . > /dev/null && error "'ls .' worked after removing cwd"
3297 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3298 is_patchless || ( cd . && error "'cd .' worked after removing cwd" )
3299 test_mkdir $DIR/$tdir/. && error "'mkdir .' worked after removing cwd"
3300 rmdir . && error "'rmdir .' worked after removing cwd"
3301 ln -s . foo && error "'ln -s .' worked after removing cwd"
3302 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
3304 run_test 48b "Access removed working dir (should return errors)="
3306 test_48c() { # bug 2350
3307 check_kernel_version 36 || return 0
3308 #lctl set_param debug=-1
3311 test_mkdir -p $DIR/$tdir/dir
3313 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3314 $TRACE touch foo && error "touch foo worked after removing cwd"
3315 $TRACE test_mkdir foo && error "'mkdir foo' worked after removing cwd"
3316 if check_kernel_version 44; then
3317 touch .foo && error "touch .foo worked after removing cwd"
3318 test_mkdir .foo && error "mkdir .foo worked after removing cwd"
3320 $TRACE ls . && error "'ls .' worked after removing cwd"
3321 $TRACE ls .. || error "'ls ..' failed after removing cwd"
3322 is_patchless || ( $TRACE cd . &&
3323 error "'cd .' worked after removing cwd" )
3324 $TRACE test_mkdir . && error "'mkdir .' worked after removing cwd"
3325 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
3326 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
3327 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
3329 run_test 48c "Access removed working subdir (should return errors)"
3331 test_48d() { # bug 2350
3332 check_kernel_version 36 || return 0
3333 #lctl set_param debug=-1
3336 test_mkdir -p $DIR/$tdir/dir
3338 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3339 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3340 $TRACE touch foo && error "'touch foo' worked after removing parent"
3341 $TRACE test_mkdir foo && error "mkdir foo worked after removing parent"
3342 if check_kernel_version 44; then
3343 touch .foo && error "'touch .foo' worked after removing parent"
3345 error "mkdir .foo worked after removing parent"
3347 $TRACE ls . && error "'ls .' worked after removing parent"
3348 $TRACE ls .. && error "'ls ..' worked after removing parent"
3349 is_patchless || ( $TRACE cd . &&
3350 error "'cd .' worked after recreate parent" )
3351 $TRACE test_mkdir . && error "'mkdir .' worked after removing parent"
3352 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
3353 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
3354 is_patchless || ( $TRACE cd .. &&
3355 error "'cd ..' worked after removing parent" || true )
3357 run_test 48d "Access removed parent subdir (should return errors)"
3359 test_48e() { # bug 4134
3360 check_kernel_version 41 || return 0
3361 #lctl set_param debug=-1
3364 test_mkdir -p $DIR/$tdir/dir
3366 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3367 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3368 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
3369 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
3370 # On a buggy kernel addition of "touch foo" after cd .. will
3371 # produce kernel oops in lookup_hash_it
3372 touch ../foo && error "'cd ..' worked after recreate parent"
3374 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
3376 run_test 48e "Access to recreated parent subdir (should return errors)"
3378 test_49() { # LU-1030
3379 # get ost1 size - lustre-OST0000
3380 ost1_size=$(do_facet ost1 lfs df |grep ${ost1_svc} |awk '{print $4}')
3381 # write 800M at maximum
3382 [ $ost1_size -gt 819200 ] && ost1_size=819200
3384 lfs setstripe -c 1 -i 0 $DIR/$tfile
3385 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
3388 # change max_pages_per_rpc while writing the file
3389 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
3390 local orig_mppc=`$LCTL get_param -n $osc1_mppc`
3391 # loop until dd process exits
3392 while ps ax -opid | grep -wq $dd_pid; do
3393 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
3394 sleep $((RANDOM % 5 + 1))
3396 # restore original max_pages_per_rpc
3397 $LCTL set_param $osc1_mppc=$orig_mppc
3398 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
3400 run_test 49 "Change max_pages_per_rpc won't break osc extent"
3404 test_mkdir $DIR/$tdir
3406 ls /proc/$$/cwd || error
3408 run_test 50 "special situations: /proc symlinks ==============="
3410 test_51a() { # was test_51
3411 # bug 1516 - create an empty entry right after ".." then split dir
3412 test_mkdir $DIR/$tdir
3413 touch $DIR/$tdir/foo
3414 $MCREATE $DIR/$tdir/bar
3416 createmany -m $DIR/$tdir/longfile 201
3418 while [ `ls -sd $DIR/$tdir | awk '{ print $1 }'` -eq 4 ]; do
3419 $MCREATE $DIR/$tdir/longfile$FNUM
3424 ls -l $DIR/$tdir > /dev/null || error
3426 run_test 51a "special situations: split htree with empty entry =="
3428 export NUMTEST=70000
3430 local BASE=$DIR/$tdir
3434 local mdtidx=$(printf "%04x" $($LFS getstripe -M $BASE))
3435 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
3436 [ $numfree -lt 21000 ] && skip "not enough free inodes ($numfree)" &&
3439 [ $numfree -lt $NUMTEST ] && NUMTEST=$(($numfree - 50)) &&
3440 echo "reduced count to $NUMTEST due to inodes"
3442 # need to check free space for the directories as well
3443 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
3444 numfree=$((blkfree / 4))
3445 [ $numfree -lt $NUMTEST ] && NUMTEST=$(($numfree - 50)) &&
3446 echo "reduced count to $NUMTEST due to blocks"
3448 createmany -d $BASE/d $NUMTEST && echo $NUMTEST > $BASE/fnum ||
3449 echo "failed" > $BASE/fnum
3451 run_test 51b "exceed 64k subdirectory nlink limit"
3453 test_51ba() { # LU-993
3454 local BASE=$DIR/$tdir
3455 # unlink all but 100 subdirectories, then check it still works
3457 [ -f $BASE/fnum ] && local NUMPREV=$(cat $BASE/fnum) && rm $BASE/fnum
3459 [ "$NUMPREV" != "failed" ] && NUMTEST=$NUMPREV
3460 local DELETE=$((NUMTEST - LEFT))
3462 # continue on to run this test even if 51b didn't finish,
3463 # just to delete the many subdirectories created.
3464 [ ! -d "${BASE}/d1" ] && skip "test_51b() not run" && return 0
3466 # for ldiskfs the nlink count should be 1, but this is OSD specific
3467 # and so this is listed for informational purposes only
3468 echo "nlink before: $(stat -c %h $BASE), created before: $NUMTEST"
3469 unlinkmany -d $BASE/d $DELETE
3472 if [ $RC -ne 0 ]; then
3473 if [ "$NUMPREV" == "failed" ]; then
3474 skip "previous setup failed"
3477 error "unlink of first $DELETE subdirs failed"
3482 echo "nlink between: $(stat -c %h $BASE)"
3483 # trim the first line of ls output
3484 local FOUND=$(($(ls -l ${BASE} | wc -l) - 1))
3485 [ $FOUND -ne $LEFT ] &&
3486 error "can't find subdirs: found only $FOUND/$LEFT"
3488 unlinkmany -d $BASE/d $DELETE $LEFT ||
3489 error "unlink of second $LEFT subdirs failed"
3490 # regardless of whether the backing filesystem tracks nlink accurately
3491 # or not, the nlink count shouldn't be more than "." and ".." here
3492 local AFTER=$(stat -c %h $BASE)
3493 [ $AFTER -gt 2 ] && error "nlink after: $AFTER > 2" ||
3494 echo "nlink after: $AFTER"
3496 run_test 51ba "verify nlink for many subdirectory cleanup"
3499 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping test with few OSTs" && return
3500 test_mkdir -p $DIR/$tdir
3501 createmany -o $DIR/$tdir/t- 1000
3502 $GETSTRIPE $DIR/$tdir > $TMP/files
3503 for N in `seq 0 $((OSTCOUNT - 1))`; do
3504 OBJS[$N]=`awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}' $TMP/files`
3505 OBJS0[$N]=`grep -A 1 idx $TMP/files | awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}'`
3506 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
3508 unlinkmany $DIR/$tdir/t- 1000
3511 for N in `seq 1 $((OSTCOUNT - 1))`; do
3512 [ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ] && \
3513 error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
3514 [ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ] && \
3515 error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
3517 [ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ] && \
3518 error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
3519 [ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ] && \
3520 error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
3524 run_test 51d "check object distribution ===================="
3527 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
3528 test_mkdir -p $DIR/$tdir
3529 touch $DIR/$tdir/foo
3530 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
3531 echo bar >> $DIR/$tdir/foo || error "append bar failed"
3532 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
3533 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
3534 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
3536 echo foo >> $DIR/$tdir/foo || error "append foo failed"
3537 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
3538 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
3540 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
3541 cp -r $DIR/$tdir /tmp/
3542 rm -fr $DIR/$tdir || error "cleanup rm failed"
3544 run_test 52a "append-only flag test (should return errors) ====="
3547 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
3548 test_mkdir -p $DIR/$tdir
3549 touch $DIR/$tdir/foo
3550 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
3551 cat test > $DIR/$tdir/foo && error "cat test worked"
3552 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
3553 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
3554 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
3556 echo foo >> $DIR/$tdir/foo && error "echo worked"
3557 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
3558 [ -f $DIR/$tdir/foo ] || error
3559 [ -f $DIR/$tdir/foo_ren ] && error
3560 lsattr $DIR/$tdir/foo | egrep -q "^-+i[-e]+ $DIR/$tdir/foo" ||
3562 chattr -i $DIR/$tdir/foo || error "chattr failed"
3564 rm -fr $DIR/$tdir || error
3566 run_test 52b "immutable flag test (should return errors) ======="
3569 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3570 remote_ost_nodsh && skip "remote OST with nodsh" && return
3579 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
3580 for value in $(do_facet $SINGLEMDS lctl get_param osc.$mdtosc.prealloc_last_id) ; do
3581 param=`echo ${value[0]} | cut -d "=" -f1`
3582 ostname=`echo $param | cut -d "." -f2 | cut -d - -f 1-2`
3583 mds_last=$(do_facet $SINGLEMDS lctl get_param -n $param)
3584 ostnum=$(echo $ostname | sed "s/${FSNAME}-OST//g" | awk '{print ($1+1)}' )
3585 ost_last=$(do_facet ost$ostnum lctl get_param -n obdfilter.$ostname.last_id | head -n 1)
3586 echo "$ostname.last_id=$ost_last ; MDS.last_id=$mds_last"
3587 if [ $ost_last != $mds_last ]; then
3588 error "$ostname.last_id=$ost_last ; MDS.last_id=$mds_last"
3592 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
3595 [ ! -f "$SOCKETSERVER" ] && skip_env "no socketserver, skipping" && return
3596 [ ! -f "$SOCKETCLIENT" ] && skip_env "no socketclient, skipping" && return
3597 $SOCKETSERVER $DIR/socket
3598 $SOCKETCLIENT $DIR/socket || error
3599 $MUNLINK $DIR/socket
3601 run_test 54a "unix domain socket test =========================="
3607 dd if=/dev/zero of=$f bs=`page_size` count=1
3609 run_test 54b "char device works in lustre ======================"
3612 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
3613 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
3614 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
3616 for i in `seq 3 7`; do
3617 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
3627 loopdev="$DIR/loop54c"
3630 [ -z "$LOOPNUM" ] && echo "couldn't find empty loop device" && return
3631 mknod $loopdev b 7 $LOOPNUM
3632 echo "make a loop file system with $tfile on $loopdev ($LOOPNUM)..."
3633 dd if=/dev/zero of=$tfile bs=`page_size` seek=1024 count=1 > /dev/null
3634 losetup $loopdev $tfile || error "can't set up $loopdev for $tfile"
3635 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
3637 mount -t ext2 $loopdev $tdir || error "error mounting $loopdev on $tdir"
3638 dd if=/dev/zero of=$tdir/tmp bs=`page_size` count=30 || error "dd write"
3640 dd if=$tdir/tmp of=/dev/zero bs=`page_size` count=30 || error "dd read"
3645 run_test 54c "block device works in lustre ====================="
3651 [ "$string" = `echo $string > $f | cat $f` ] || error
3653 run_test 54d "fifo device works in lustre ======================"
3656 check_kernel_version 46 || return 0
3659 cp -aL /dev/console $f
3660 echo $string > $f || error
3662 run_test 54e "console/tty device works in lustre ======================"
3664 #The test_55 used to be iopen test and it was removed by bz#24037.
3665 #run_test 55 "check iopen_connect_dentry() ======================"
3667 test_56a() { # was test_56
3670 test_mkdir $DIR/$tdir
3671 test_mkdir $DIR/$tdir/dir
3673 NUMFILESx2=$(($NUMFILES * 2))
3674 for i in `seq 1 $NUMFILES` ; do
3675 touch $DIR/$tdir/file$i
3676 touch $DIR/$tdir/dir/file$i
3679 # test lfs getstripe with --recursive
3680 FILENUM=`$GETSTRIPE --recursive $DIR/$tdir | grep -c obdidx`
3681 [ $FILENUM -eq $NUMFILESx2 ] ||
3682 error "$GETSTRIPE --recursive: found $FILENUM, not $NUMFILESx2"
3683 FILENUM=`$GETSTRIPE $DIR/$tdir | grep -c obdidx`
3684 [ $FILENUM -eq $NUMFILES ] ||
3685 error "$GETSTRIPE $DIR/$tdir: found $FILENUM, not $NUMFILES"
3686 echo "$GETSTRIPE --recursive passed."
3688 # test lfs getstripe with file instead of dir
3689 FILENUM=`$GETSTRIPE $DIR/$tdir/file1 | grep -c obdidx`
3690 [ $FILENUM -eq 1 ] || error \
3691 "$GETSTRIPE $DIR/$tdir/file1: found $FILENUM, not 1"
3692 echo "$GETSTRIPE file1 passed."
3694 #test lfs getstripe with --verbose
3695 [ `$GETSTRIPE --verbose $DIR/$tdir |
3696 grep -c lmm_magic` -eq $NUMFILES ] ||
3697 error "$GETSTRIPE --verbose $DIR/$tdir: want $NUMFILES"
3698 [ `$GETSTRIPE $DIR/$tdir | grep -c lmm_magic` -eq 0 ] ||
3699 error "$GETSTRIPE $DIR/$tdir: showed lmm_magic"
3700 echo "$GETSTRIPE --verbose passed."
3702 #test lfs getstripe with --obd
3703 $GETSTRIPE --obd wrong_uuid $DIR/$tdir 2>&1 |
3704 grep -q "unknown obduuid" ||
3705 error "$GETSTRIPE --obd wrong_uuid should return error message"
3707 [ "$OSTCOUNT" -lt 2 ] &&
3708 skip_env "skipping other $GETSTRIPE --obd test" && return
3711 OBDUUID=$(ostuuid_from_index $OSTIDX)
3712 FILENUM=`$GETSTRIPE -ir $DIR/$tdir | grep -x $OSTIDX | wc -l`
3713 FOUND=`$GETSTRIPE -r --obd $OBDUUID $DIR/$tdir | grep obdidx | wc -l`
3714 [ $FOUND -eq $FILENUM ] ||
3715 error "$GETSTRIPE --obd wrong: found $FOUND, expected $FILENUM"
3716 [ `$GETSTRIPE -r -v --obd $OBDUUID $DIR/$tdir |
3717 sed '/^[ ]*'${OSTIDX}'[ ]/d' |
3718 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l` -eq 0 ] ||
3719 error "$GETSTRIPE --obd: should not show file on other obd"
3720 echo "$GETSTRIPE --obd passed"
3722 run_test 56a "check $GETSTRIPE"
3727 local LOCAL_NUMFILES="$1"
3728 local LOCAL_NUMDIRS="$2"
3729 local MKDIR_PARAMS="$3"
3731 if [ ! -d "$TDIR" ] ; then
3733 [ "$MKDIR_PARAMS" ] && $SETSTRIPE $MKDIR_PARAMS $TDIR
3734 for i in `seq 1 $LOCAL_NUMFILES` ; do
3737 for i in `seq 1 $LOCAL_NUMDIRS` ; do
3738 test_mkdir $TDIR/dir$i
3739 for j in `seq 1 $LOCAL_NUMFILES` ; do
3740 touch $TDIR/dir$i/file$j
3746 setup_56_special() {
3750 if [ ! -e "$TDIR/loop1b" ] ; then
3751 for i in `seq 1 $LOCAL_NUMFILES` ; do
3752 mknod $TDIR/loop${i}b b 7 $i
3753 mknod $TDIR/null${i}c c 1 3
3754 ln -s $TDIR/file1 $TDIR/link${i}l
3756 for i in `seq 1 $LOCAL_NUMDIRS` ; do
3757 mknod $TDIR/dir$i/loop${i}b b 7 $i
3758 mknod $TDIR/dir$i/null${i}c c 1 3
3759 ln -s $TDIR/dir$i/file1 $TDIR/dir$i/link${i}l
3768 setup_56 $NUMFILES $NUMDIRS
3770 EXPECTED=$(($NUMDIRS + 2))
3771 # test lfs find with -name
3772 for i in $(seq 1 $NUMFILES) ; do
3773 NUMS=$($LFIND -name "*$i" $TDIR | wc -l)
3774 [ $NUMS -eq $EXPECTED ] ||
3775 error "lfs find -name \"*$i\" $TDIR wrong: "\
3776 "found $NUMS, expected $EXPECTED"
3779 run_test 56g "check lfs find -name ============================="
3785 setup_56 $NUMFILES $NUMDIRS
3787 EXPECTED=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
3788 # test lfs find with ! -name
3789 for i in $(seq 1 $NUMFILES) ; do
3790 NUMS=$($LFIND ! -name "*$i" $TDIR | wc -l)
3791 [ $NUMS -eq $EXPECTED ] ||
3792 error "lfs find ! -name \"*$i\" $TDIR wrong: "\
3793 "found $NUMS, expected $EXPECTED"
3796 run_test 56h "check lfs find ! -name ============================="
3800 test_mkdir -p $DIR/$tdir
3801 UUID=$(ostuuid_from_index 0 $DIR/$tdir)
3802 CMD="$LFIND -ost $UUID $DIR/$tdir"
3804 [ -z "$OUT" ] || error "\"$CMD\" returned directory '$OUT'"
3806 run_test 56i "check 'lfs find -ost UUID' skips directories ======="
3810 setup_56_special $NUMFILES $NUMDIRS
3812 EXPECTED=$((NUMDIRS + 1))
3813 CMD="$LFIND -type d $TDIR"
3814 NUMS=$($CMD | wc -l)
3815 [ $NUMS -eq $EXPECTED ] ||
3816 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3818 run_test 56j "check lfs find -type d ============================="
3822 setup_56_special $NUMFILES $NUMDIRS
3824 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
3825 CMD="$LFIND -type f $TDIR"
3826 NUMS=$($CMD | wc -l)
3827 [ $NUMS -eq $EXPECTED ] ||
3828 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3830 run_test 56k "check lfs find -type f ============================="
3834 setup_56_special $NUMFILES $NUMDIRS
3836 EXPECTED=$((NUMDIRS + NUMFILES))
3837 CMD="$LFIND -type b $TDIR"
3838 NUMS=$($CMD | wc -l)
3839 [ $NUMS -eq $EXPECTED ] ||
3840 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3842 run_test 56l "check lfs find -type b ============================="
3846 setup_56_special $NUMFILES $NUMDIRS
3848 EXPECTED=$((NUMDIRS + NUMFILES))
3849 CMD="$LFIND -type c $TDIR"
3850 NUMS=$($CMD | wc -l)
3851 [ $NUMS -eq $EXPECTED ] ||
3852 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3854 run_test 56m "check lfs find -type c ============================="
3858 setup_56_special $NUMFILES $NUMDIRS
3860 EXPECTED=$((NUMDIRS + NUMFILES))
3861 CMD="$LFIND -type l $TDIR"
3862 NUMS=$($CMD | wc -l)
3863 [ $NUMS -eq $EXPECTED ] ||
3864 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3866 run_test 56n "check lfs find -type l ============================="
3870 setup_56 $NUMFILES $NUMDIRS
3872 utime $TDIR/file1 > /dev/null || error "utime (1)"
3873 utime $TDIR/file2 > /dev/null || error "utime (2)"
3874 utime $TDIR/dir1 > /dev/null || error "utime (3)"
3875 utime $TDIR/dir2 > /dev/null || error "utime (4)"
3876 utime $TDIR/dir1/file1 > /dev/null || error "utime (5)"
3877 dd if=/dev/zero count=1 >> $TDIR/dir1/file1 && sync
3880 NUMS=`$LFIND -mtime +0 $TDIR | wc -l`
3881 [ $NUMS -eq $EXPECTED ] || \
3882 error "lfs find -mtime +0 $TDIR wrong: found $NUMS, expected $EXPECTED"
3885 CMD="$LFIND -mtime 0 $TDIR"
3886 NUMS=$($CMD | wc -l)
3887 [ $NUMS -eq $EXPECTED ] ||
3888 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3890 run_test 56o "check lfs find -mtime for old files =========================="
3893 [ $RUNAS_ID -eq $UID ] &&
3894 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
3897 setup_56 $NUMFILES $NUMDIRS
3899 chown $RUNAS_ID $TDIR/file* || error "chown $DIR/${tdir}g/file$i failed"
3901 CMD="$LFIND -uid $RUNAS_ID $TDIR"
3902 NUMS=$($CMD | wc -l)
3903 [ $NUMS -eq $EXPECTED ] || \
3904 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3906 EXPECTED=$(((NUMFILES + 1) * NUMDIRS + 1))
3907 CMD="$LFIND ! -uid $RUNAS_ID $TDIR"
3908 NUMS=$($CMD | wc -l)
3909 [ $NUMS -eq $EXPECTED ] || \
3910 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3912 run_test 56p "check lfs find -uid and ! -uid ==============================="
3915 [ $RUNAS_ID -eq $UID ] &&
3916 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
3919 setup_56 $NUMFILES $NUMDIRS
3921 chgrp $RUNAS_GID $TDIR/file* || error "chown $TDIR/file$i failed"
3924 CMD="$LFIND -gid $RUNAS_GID $TDIR"
3925 NUMS=$($CMD | wc -l)
3926 [ $NUMS -eq $EXPECTED ] ||
3927 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3929 EXPECTED=$(( ($NUMFILES+1) * $NUMDIRS + 1))
3930 CMD="$LFIND ! -gid $RUNAS_GID $TDIR"
3931 NUMS=$($CMD | wc -l)
3932 [ $NUMS -eq $EXPECTED ] ||
3933 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3935 run_test 56q "check lfs find -gid and ! -gid ==============================="
3939 setup_56 $NUMFILES $NUMDIRS
3942 CMD="$LFIND -size 0 -type f $TDIR"
3943 NUMS=$($CMD | wc -l)
3944 [ $NUMS -eq $EXPECTED ] ||
3945 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3947 CMD="$LFIND ! -size 0 -type f $TDIR"
3948 NUMS=$($CMD | wc -l)
3949 [ $NUMS -eq $EXPECTED ] ||
3950 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3951 echo "test" > $TDIR/$tfile
3952 echo "test2" > $TDIR/$tfile.2 && sync
3954 CMD="$LFIND -size 5 -type f $TDIR"
3955 NUMS=$($CMD | wc -l)
3956 [ $NUMS -eq $EXPECTED ] ||
3957 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3959 CMD="$LFIND -size +5 -type f $TDIR"
3960 NUMS=$($CMD | wc -l)
3961 [ $NUMS -eq $EXPECTED ] ||
3962 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3964 CMD="$LFIND -size +0 -type f $TDIR"
3965 NUMS=$($CMD | wc -l)
3966 [ $NUMS -eq $EXPECTED ] ||
3967 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3969 CMD="$LFIND ! -size -5 -type f $TDIR"
3970 NUMS=$($CMD | wc -l)
3971 [ $NUMS -eq $EXPECTED ] ||
3972 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3974 CMD="$LFIND -size -5 -type f $TDIR"
3975 NUMS=$($CMD | wc -l)
3976 [ $NUMS -eq $EXPECTED ] ||
3977 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3979 run_test 56r "check lfs find -size works =========================="
3981 test_56s() { # LU-611
3983 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT"
3985 if [ $OSTCOUNT -gt 1 ]; then
3986 $SETSTRIPE -c 1 $TDIR/$tfile.{0,1,2,3}
3990 ONESTRIPE=$(((NUMDIRS + 1) * NUMFILES))
3994 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
3995 CMD="$LFIND -stripe-count $OSTCOUNT -type f $TDIR"
3996 NUMS=$($CMD | wc -l)
3997 [ $NUMS -eq $EXPECTED ] ||
3998 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4000 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + EXTRA))
4001 CMD="$LFIND -stripe-count +0 -type f $TDIR"
4002 NUMS=$($CMD | wc -l)
4003 [ $NUMS -eq $EXPECTED ] ||
4004 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4007 CMD="$LFIND -stripe-count 1 -type f $TDIR"
4008 NUMS=$($CMD | wc -l)
4009 [ $NUMS -eq $EXPECTED ] ||
4010 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4012 CMD="$LFIND -stripe-count -2 -type f $TDIR"
4013 NUMS=$($CMD | wc -l)
4014 [ $NUMS -eq $EXPECTED ] ||
4015 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4018 CMD="$LFIND -stripe-count $((OSTCOUNT + 1)) -type f $TDIR"
4019 NUMS=$($CMD | wc -l)
4020 [ $NUMS -eq $EXPECTED ] ||
4021 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4023 run_test 56s "check lfs find -stripe-count works"
4025 test_56t() { # LU-611
4027 setup_56 $NUMFILES $NUMDIRS "-s 512k"
4029 $SETSTRIPE -S 256k $TDIR/$tfile.{0,1,2,3}
4031 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4032 CMD="$LFIND -stripe-size 512k -type f $TDIR"
4033 NUMS=$($CMD | wc -l)
4034 [ $NUMS -eq $EXPECTED ] ||
4035 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4037 CMD="$LFIND -stripe-size +320k -type f $TDIR"
4038 NUMS=$($CMD | wc -l)
4039 [ $NUMS -eq $EXPECTED ] ||
4040 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4042 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + 4))
4043 CMD="$LFIND -stripe-size +200k -type f $TDIR"
4044 NUMS=$($CMD | wc -l)
4045 [ $NUMS -eq $EXPECTED ] ||
4046 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4048 CMD="$LFIND -stripe-size -640k -type f $TDIR"
4049 NUMS=$($CMD | wc -l)
4050 [ $NUMS -eq $EXPECTED ] ||
4051 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4054 CMD="$LFIND -stripe-size 256k -type f $TDIR"
4055 NUMS=$($CMD | wc -l)
4056 [ $NUMS -eq $EXPECTED ] ||
4057 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4059 CMD="$LFIND -stripe-size -320k -type f $TDIR"
4060 NUMS=$($CMD | wc -l)
4061 [ $NUMS -eq $EXPECTED ] ||
4062 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4065 CMD="$LFIND -stripe-size 1024k -type f $TDIR"
4066 NUMS=$($CMD | wc -l)
4067 [ $NUMS -eq $EXPECTED ] ||
4068 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4070 run_test 56t "check lfs find -stripe-size works"
4072 test_56u() { # LU-611
4074 setup_56 $NUMFILES $NUMDIRS "-i 0"
4076 if [ $OSTCOUNT -gt 1 ]; then
4077 $SETSTRIPE -i 1 $TDIR/$tfile.{0,1,2,3}
4083 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4084 CMD="$LFIND -stripe-index 0 -type f $TDIR"
4085 NUMS=$($CMD | wc -l)
4086 [ $NUMS -eq $EXPECTED ] ||
4087 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4090 CMD="$LFIND -stripe-index 1 -type f $TDIR"
4091 NUMS=$($CMD | wc -l)
4092 [ $NUMS -eq $EXPECTED ] ||
4093 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4095 CMD="$LFIND ! -stripe-index 0 -type f $TDIR"
4096 NUMS=$($CMD | wc -l)
4097 [ $NUMS -eq $EXPECTED ] ||
4098 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4101 # This should produce an error and not return any files
4102 CMD="$LFIND -stripe-index $OSTCOUNT -type f $TDIR"
4103 NUMS=$($CMD 2>/dev/null | wc -l)
4104 [ $NUMS -eq $EXPECTED ] ||
4105 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4107 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + ONESTRIPE))
4108 CMD="$LFIND -stripe-index 0,1 -type f $TDIR"
4109 NUMS=$($CMD | wc -l)
4110 [ $NUMS -eq $EXPECTED ] ||
4111 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4113 run_test 56u "check lfs find -stripe-index works"
4120 setup_56 $NUMFILES $NUMDIRS
4122 UUID=$(mdtuuid_from_index $MDT_IDX $TDIR)
4123 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT index $MDT_IDX"
4125 for file in $($LFIND -mdt $UUID $TDIR); do
4126 file_mdt_idx=$($GETSTRIPE -M $file)
4127 [ $file_mdt_idx -eq $MDT_IDX ] ||
4128 error "'lfind -mdt $UUID' != 'getstripe -M' ($file_mdt_idx)"
4131 run_test 56v "check 'lfs find -mdt match with lfs getstripe -M' ======="
4133 # Get and check the actual stripe count of one file.
4134 # Usage: check_stripe_count <file> <expected_stripe_count>
4135 check_stripe_count() {
4140 [[ -z "$file" || -z "$expected" ]] &&
4141 error "check_stripe_count: invalid argument!"
4143 local cmd="$GETSTRIPE -c $file"
4144 actual=$($cmd) || error "$cmd failed"
4145 actual=${actual%% *}
4147 if [[ $actual -ne $expected ]]; then
4148 [[ $expected -eq -1 ]] ||
4149 error "$cmd wrong: found $actual, expected $expected"
4150 [[ $actual -eq $OSTCOUNT ]] ||
4151 error "$cmd wrong: found $actual, expected $OSTCOUNT"
4158 rm -rf $TDIR || error "remove $TDIR failed"
4159 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT"
4162 stripe_size=$($GETSTRIPE -S -d $TDIR) ||
4163 error "$GETSTRIPE -S -d $TDIR failed"
4164 stripe_size=${stripe_size%% *}
4166 local file_size=$((stripe_size * OSTCOUNT))
4167 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
4168 local required_space=$((file_num * file_size))
4169 local free_space=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
4170 [[ $free_space -le $((required_space / 1024)) ]] &&
4171 skip_env "need at least $required_space bytes free space," \
4172 "have $free_space kbytes" && return
4175 local dd_count=$((file_size / dd_bs))
4177 # write data into the files
4181 for i in $(seq 1 $NUMFILES); do
4183 yes | dd bs=$dd_bs count=$dd_count of=$file >/dev/null 2>&1 ||
4184 error "write data into $file failed"
4186 for i in $(seq 1 $NUMDIRS); do
4187 for j in $(seq 1 $NUMFILES); do
4188 file=$TDIR/dir$i/file$j
4189 yes | dd bs=$dd_bs count=$dd_count of=$file \
4191 error "write data into $file failed"
4196 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
4199 local cmd="$LFS_MIGRATE -y -c $expected $TDIR/file1"
4201 eval $cmd || error "$cmd failed"
4203 check_stripe_count $TDIR/file1 $expected
4206 cmd="$LFS_MIGRATE -y -c $expected $TDIR/dir1"
4208 eval $cmd || error "$cmd failed"
4210 for j in $(seq 1 $NUMFILES); do
4211 check_stripe_count $TDIR/dir1/file$j $expected
4214 # lfs_migrate works with lfs find
4215 cmd="$LFIND -stripe_count $OSTCOUNT -type f $TDIR |
4216 $LFS_MIGRATE -y -c $expected"
4218 eval $cmd || error "$cmd failed"
4220 for i in $(seq 2 $NUMFILES); do
4221 check_stripe_count $TDIR/file$i $expected
4223 for i in $(seq 2 $NUMDIRS); do
4224 for j in $(seq 1 $NUMFILES); do
4225 check_stripe_count $TDIR/dir$i/file$j $expected
4229 run_test 56w "check lfs_migrate -c stripe_count works"
4232 # note test will not do anything if MDS is not local
4233 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4234 skip "Only applicable to ldiskfs-based MDTs"
4238 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4239 local MNTDEV="osd*.*MDT*.mntdev"
4240 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
4241 [ -z "$DEV" ] && error "can't access $MNTDEV"
4242 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
4243 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
4244 error "can't access $DEV"
4245 DEVISIZE=`awk '/Inode size:/ { print $3 }' $TMP/t57a.dump`
4246 [ "$DEVISIZE" -gt 128 ] || error "inode size $DEVISIZE"
4250 run_test 57a "verify MDS filesystem created with large inodes =="
4253 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4254 skip "Only applicable to ldiskfs-based MDTs"
4258 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4263 local FILEN=$dir/f$FILECOUNT
4265 rm -rf $dir || error "removing $dir"
4266 test_mkdir -p $dir || error "creating $dir"
4267 local num=$(get_mds_dir $dir)
4270 echo "mcreating $FILECOUNT files"
4271 createmany -m $dir/f 1 $FILECOUNT || \
4272 error "creating files in $dir"
4274 # verify that files do not have EAs yet
4275 $GETSTRIPE $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
4276 $GETSTRIPE $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
4280 df $dir #make sure we get new statfs data
4281 local MDSFREE=$(do_facet $mymds \
4282 lctl get_param -n osd*.*MDT000$((num -1)).kbytesfree)
4283 local MDCFREE=$(lctl get_param -n mdc.*MDT000$((num -1))-mdc-*.kbytesfree)
4284 echo "opening files to create objects/EAs"
4286 for FILE in `seq -f $dir/f%g 1 $FILECOUNT`; do
4287 $OPENFILE -f O_RDWR $FILE > /dev/null 2>&1 || error "opening $FILE"
4290 # verify that files have EAs now
4291 $GETSTRIPE $FILE1 | grep -q "obdidx" || error "$FILE1 missing EA"
4292 $GETSTRIPE $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
4294 sleep 1 #make sure we get new statfs data
4296 local MDSFREE2=$(do_facet $mymds \
4297 lctl get_param -n osd*.*MDT000$((num -1)).kbytesfree)
4298 local MDCFREE2=$(lctl get_param -n mdc.*MDT000$((num -1))-mdc-*.kbytesfree)
4299 if [ "$MDCFREE2" -lt "$((MDCFREE - 8))" ]; then
4300 if [ "$MDSFREE" != "$MDSFREE2" ]; then
4301 error "MDC before $MDCFREE != after $MDCFREE2"
4303 echo "MDC before $MDCFREE != after $MDCFREE2"
4304 echo "unable to confirm if MDS has large inodes"
4309 run_test 57b "default LOV EAs are stored inside large inodes ==="
4312 [ -z "$(which wiretest 2>/dev/null)" ] && skip_env "could not find wiretest" && return
4315 run_test 58 "verify cross-platform wire constants =============="
4318 echo "touch 130 files"
4319 createmany -o $DIR/f59- 130
4321 unlinkmany $DIR/f59- 130
4323 # wait for commitment of removal
4324 wait_delete_completed
4326 run_test 59 "verify cancellation of llog records async ========="
4328 TEST60_HEAD="test_60 run $RANDOM"
4330 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
4331 [ ! -f run-llog.sh ] && skip_env "missing subtest run-llog.sh" && return
4332 log "$TEST60_HEAD - from kernel mode"
4333 do_facet mgs sh run-llog.sh
4335 run_test 60a "llog sanity tests run from kernel module =========="
4337 test_60b() { # bug 6411
4339 LLOG_COUNT=`dmesg | awk "/$TEST60_HEAD/{marker = 1; from_marker = 0;}
4351 [ $LLOG_COUNT -gt 50 ] && error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)"|| true
4353 run_test 60b "limit repeated messages from CERROR/CWARN ========"
4356 echo "create 5000 files"
4357 createmany -o $DIR/f60c- 5000
4358 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
4359 lctl set_param fail_loc=0x80000137
4360 unlinkmany $DIR/f60c- 5000
4361 lctl set_param fail_loc=0
4363 run_test 60c "unlink file when mds full"
4366 SAVEPRINTK=$(lctl get_param -n printk)
4368 # verify "lctl mark" is even working"
4369 MESSAGE="test message ID $RANDOM $$"
4370 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
4371 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
4373 lctl set_param printk=0 || error "set lnet.printk failed"
4374 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
4375 MESSAGE="new test message ID $RANDOM $$"
4376 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
4377 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
4378 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
4380 lctl set_param -n printk="$SAVEPRINTK"
4382 run_test 60d "test printk console message masking"
4386 dd if=/dev/zero of=$f bs=`page_size` count=1
4387 cancel_lru_locks osc
4388 $MULTIOP $f OSMWUc || error
4391 run_test 61 "mmap() writes don't make sync hang ================"
4393 # bug 2330 - insufficient obd_match error checking causes LBUG
4397 cancel_lru_locks osc
4398 lctl set_param fail_loc=0x405
4399 cat $f && error "cat succeeded, expect -EIO"
4400 lctl set_param fail_loc=0
4402 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
4403 # match every page all of the time.
4404 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
4406 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
4407 test_63a() { # was test_63
4408 MAX_DIRTY_MB=`lctl get_param -n osc.*.max_dirty_mb | head -n 1`
4409 lctl set_param -n osc.*.max_dirty_mb 0
4410 for i in `seq 10` ; do
4411 dd if=/dev/zero of=$DIR/f63 bs=8k &
4417 lctl set_param -n osc.*.max_dirty_mb $MAX_DIRTY_MB
4418 rm -f $DIR/f63 || true
4420 run_test 63a "Verify oig_wait interruption does not crash ======="
4422 # bug 2248 - async write errors didn't return to application on sync
4423 # bug 3677 - async write errors left page locked
4426 lctl set_param debug=-1
4428 # ensure we have a grant to do async writes
4429 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
4432 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
4433 lctl set_param fail_loc=0x80000406
4434 $MULTIOP $DIR/$tfile Owy && \
4435 error "sync didn't return ENOMEM"
4436 sync; sleep 2; sync # do a real sync this time to flush page
4437 lctl get_param -n llite.*.dump_page_cache | grep locked && \
4438 error "locked page left in cache after async error" || true
4441 run_test 63b "async write errors should be returned to fsync ==="
4445 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
4447 run_test 64a "verify filter grant calculations (in kernel) ====="
4450 [ ! -f oos.sh ] && skip_env "missing subtest oos.sh" && return
4453 run_test 64b "check out-of-space detection on client ==========="
4456 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
4458 run_test 64c "verify grant shrink ========================------"
4460 # bug 1414 - set/get directories' stripe info
4462 test_mkdir -p $DIR/$tdir
4464 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
4466 run_test 65a "directory with no stripe info ===================="
4469 test_mkdir -p $DIR/$tdir
4470 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
4473 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
4475 run_test 65b "directory setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1"
4478 if [ $OSTCOUNT -gt 1 ]; then
4479 test_mkdir -p $DIR/$tdir
4480 $SETSTRIPE -S $(($STRIPESIZE * 4)) -i 1 \
4481 -c $(($OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
4483 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
4486 run_test 65c "directory setstripe -S $((STRIPESIZE*4)) -i 1 -c $((OSTCOUNT-1))"
4489 test_mkdir -p $DIR/$tdir
4490 if [ $STRIPECOUNT -le 0 ]; then
4492 elif [ $STRIPECOUNT -gt 2000 ]; then
4493 #LOV_MAX_STRIPE_COUNT is 2000
4494 [ $OSTCOUNT -gt 2000 ] && sc=2000 || sc=$(($OSTCOUNT - 1))
4496 sc=$(($STRIPECOUNT - 1))
4498 $SETSTRIPE -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
4499 touch $DIR/$tdir/f4 $DIR/$tdir/f5
4500 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
4501 error "lverify failed"
4503 run_test 65d "directory setstripe -S $STRIPESIZE -c stripe_count"
4506 test_mkdir -p $DIR/$tdir
4508 $SETSTRIPE $DIR/$tdir || error "setstripe"
4509 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
4510 error "no stripe info failed"
4512 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
4514 run_test 65e "directory setstripe defaults ======================="
4517 test_mkdir -p $DIR/${tdir}f
4518 $RUNAS $SETSTRIPE $DIR/${tdir}f && error "setstripe succeeded" || true
4520 run_test 65f "dir setstripe permission (should return error) ==="
4523 test_mkdir -p $DIR/$tdir
4524 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
4526 $SETSTRIPE -d $DIR/$tdir || error "setstripe"
4527 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
4528 error "delete default stripe failed"
4530 run_test 65g "directory setstripe -d ==========================="
4533 test_mkdir -p $DIR/$tdir
4534 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
4536 test_mkdir -p $DIR/$tdir/dd1
4537 [ $($GETSTRIPE -c $DIR/$tdir) == $($GETSTRIPE -c $DIR/$tdir/dd1) ] ||
4538 error "stripe info inherit failed"
4540 run_test 65h "directory stripe info inherit ===================="
4542 test_65i() { # bug6367
4543 $SETSTRIPE -S 65536 -c -1 $MOUNT
4545 run_test 65i "set non-default striping on root directory (bug 6367)="
4547 test_65ia() { # bug12836
4548 $GETSTRIPE $MOUNT || error "getstripe $MOUNT failed"
4550 run_test 65ia "getstripe on -1 default directory striping"
4552 test_65ib() { # bug12836
4553 $GETSTRIPE -v $MOUNT || error "getstripe -v $MOUNT failed"
4555 run_test 65ib "getstripe -v on -1 default directory striping"
4557 test_65ic() { # bug12836
4558 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
4560 run_test 65ic "new find on -1 default directory striping"
4562 test_65j() { # bug6367
4564 # if we aren't already remounting for each test, do so for this test
4565 if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
4566 cleanup || error "failed to unmount"
4569 $SETSTRIPE -d $MOUNT || error "setstripe failed"
4571 run_test 65j "set default striping on root directory (bug 6367)="
4573 test_65k() { # bug11679
4574 [ "$OSTCOUNT" -lt 2 ] && skip_env "too few OSTs" && return
4575 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4577 echo "Check OST status: "
4578 local MDS_OSCS=`do_facet $SINGLEMDS lctl dl |
4579 awk '/[oO][sS][cC].*md[ts]/ { print $4 }'`
4581 for OSC in $MDS_OSCS; do
4582 echo $OSC "is activate"
4583 do_facet $SINGLEMDS lctl --device %$OSC activate
4587 for INACTIVE_OSC in $MDS_OSCS; do
4588 echo "Deactivate: " $INACTIVE_OSC
4589 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
4590 for STRIPE_OSC in $MDS_OSCS; do
4591 OST=`osc_to_ost $STRIPE_OSC`
4592 IDX=`do_facet $SINGLEMDS lctl get_param -n lov.*md*.target_obd |
4593 awk -F: /$OST/'{ print $1 }' | head -n 1`
4595 [ -f $DIR/$tdir/$IDX ] && continue
4596 echo "$SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX"
4597 $SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX
4599 [ $RC -ne 0 ] && error "setstripe should have succeeded"
4602 echo $INACTIVE_OSC "is Activate."
4603 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
4606 run_test 65k "validate manual striping works properly with deactivated OSCs"
4608 test_65l() { # bug 12836
4609 test_mkdir -p $DIR/$tdir/test_dir
4610 $SETSTRIPE -c -1 $DIR/$tdir/test_dir
4611 $LFS find -mtime -1 $DIR/$tdir >/dev/null
4613 run_test 65l "lfs find on -1 stripe dir ========================"
4615 # bug 2543 - update blocks count on client
4618 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
4619 sync; sync_all_data; sync; sync_all_data
4620 cancel_lru_locks osc
4621 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
4622 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
4624 run_test 66 "update inode blocks count on client ==============="
4630 if [ ! -z "$LLOOP" ]; then
4631 if swapon -s | grep -q $LLOOP; then
4632 swapoff $LLOOP || error "swapoff failed"
4635 $LCTL blockdev_detach $LLOOP || error "detach failed"
4639 if [ ! -z "$LLITELOOPLOAD" ]; then
4647 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
4651 swapon -s | awk '($1 == "'$1'") { print $4 }'
4654 # test case for lloop driver, basic function
4656 [ "$UID" != 0 ] && skip_env "must run as root" && return
4657 llite_lloop_enabled || \
4658 { skip_env "llite_lloop module disabled" && return; }
4660 trap cleanup_68 EXIT
4662 if ! module_loaded llite_lloop; then
4663 if load_module llite/llite_lloop; then
4666 skip_env "can't find module llite_lloop"
4671 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
4672 dd if=/dev/zero of=$DIR/f68a bs=4k count=1024
4673 $LCTL blockdev_attach $DIR/f68a $LLOOP || error "attach failed"
4675 directio rdwr $LLOOP 0 1024 4096 || error "direct write failed"
4676 directio rdwr $LLOOP 0 1025 4096 && error "direct write should fail"
4680 run_test 68a "lloop driver - basic test ========================"
4682 # excercise swapping to lustre by adding a high priority swapfile entry
4683 # and then consuming memory until it is used.
4684 test_68b() { # was test_68
4685 [ "$UID" != 0 ] && skip_env "must run as root" && return
4686 lctl get_param -n devices | grep -q obdfilter && \
4687 skip "local OST" && return
4689 grep -q llite_lloop /proc/modules
4690 [ $? -ne 0 ] && skip "can't find module llite_lloop" && return
4692 [ -z "`$LCTL list_nids | grep -v tcp`" ] && \
4693 skip "can't reliably test swap with TCP" && return
4695 MEMTOTAL=`meminfo MemTotal`
4696 NR_BLOCKS=$((MEMTOTAL>>8))
4697 [[ $NR_BLOCKS -le 2048 ]] && NR_BLOCKS=2048
4699 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
4700 dd if=/dev/zero of=$DIR/f68b bs=64k seek=$NR_BLOCKS count=1
4703 $LCTL blockdev_attach $DIR/f68b $LLOOP || error "attach failed"
4705 trap cleanup_68 EXIT
4707 swapon -p 32767 $LLOOP || error "swapon $LLOOP failed"
4709 echo "before: `swapon -s | grep $LLOOP`"
4710 $MEMHOG $MEMTOTAL || error "error allocating $MEMTOTAL kB"
4711 echo "after: `swapon -s | grep $LLOOP`"
4712 SWAPUSED=`swap_used $LLOOP`
4716 [ $SWAPUSED -eq 0 ] && echo "no swap used???" || true
4718 run_test 68b "support swapping to Lustre ========================"
4720 # bug5265, obdfilter oa2dentry return -ENOENT
4721 # #define OBD_FAIL_OST_ENOENT 0x217
4723 remote_ost_nodsh && skip "remote OST with nodsh" && return
4726 $SETSTRIPE -c 1 -i 0 $f
4728 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
4730 do_facet ost1 lctl set_param fail_loc=0x217
4731 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
4732 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
4734 do_facet ost1 lctl set_param fail_loc=0
4735 $DIRECTIO write $f 0 2 || error "write error"
4737 cancel_lru_locks osc
4738 $DIRECTIO read $f 0 1 || error "read error"
4740 do_facet ost1 lctl set_param fail_loc=0x217
4741 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
4743 do_facet ost1 lctl set_param fail_loc=0
4746 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
4749 test_mkdir -p $DIR/$tdir
4750 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
4752 run_test 71 "Running dbench on lustre (don't segment fault) ===="
4754 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
4755 check_kernel_version 43 || return 0
4756 [ "$RUNAS_ID" = "$UID" ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4758 # Check that testing environment is properly set up. Skip if not
4759 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS || {
4760 skip_env "User $RUNAS_ID does not exist - skipping"
4763 # We had better clear the $DIR to get enough space for dd
4768 $RUNAS dd if=/dev/zero of=$DIR/f72 bs=512 count=1 || error
4769 # See if we are still setuid/sgid
4770 test -u $DIR/f72 -o -g $DIR/f72 && error "S/gid is not dropped on write"
4771 # Now test that MDS is updated too
4772 cancel_lru_locks mdc
4773 test -u $DIR/f72 -o -g $DIR/f72 && error "S/gid is not dropped on MDS"
4776 run_test 72a "Test that remove suid works properly (bug5695) ===="
4778 test_72b() { # bug 24226 -- keep mode setting when size is not changing
4781 [ "$RUNAS_ID" = "$UID" ] && \
4782 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4783 [ "$RUNAS_ID" -eq 0 ] && \
4784 skip_env "RUNAS_ID = 0 -- skipping" && return
4786 # Check that testing environment is properly set up. Skip if not
4787 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS || {
4788 skip_env "User $RUNAS_ID does not exist - skipping"
4791 touch $DIR/${tfile}-f{g,u}
4792 test_mkdir $DIR/${tfile}-dg
4793 test_mkdir $DIR/${tfile}-du
4794 chmod 770 $DIR/${tfile}-{f,d}{g,u}
4795 chmod g+s $DIR/${tfile}-{f,d}g
4796 chmod u+s $DIR/${tfile}-{f,d}u
4797 for perm in 777 2777 4777; do
4798 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
4799 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
4800 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
4801 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
4805 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
4807 # bug 3462 - multiple simultaneous MDC requests
4809 test_mkdir $DIR/d73-1
4810 test_mkdir $DIR/d73-2
4811 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
4814 lctl set_param fail_loc=0x80000129
4815 $MULTIOP $DIR/d73-1/f73-2 Oc &
4817 lctl set_param fail_loc=0
4819 $MULTIOP $DIR/d73-2/f73-3 Oc &
4823 wait $pid1 || return 1
4827 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
4828 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
4829 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
4833 run_test 73 "multiple MDC requests (should not deadlock)"
4835 test_74a() { # bug 6149, 6184
4836 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
4838 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
4839 # will spin in a tight reconnection loop
4841 lctl set_param fail_loc=0x8000030e
4842 # get any lock that won't be difficult - lookup works.
4844 lctl set_param fail_loc=0
4848 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
4850 test_74b() { # bug 13310
4851 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
4853 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
4854 # will spin in a tight reconnection loop
4855 lctl set_param fail_loc=0x8000030e
4856 # get a "difficult" lock
4858 lctl set_param fail_loc=0
4862 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
4865 #define OBD_FAIL_LDLM_NEW_LOCK
4866 lctl set_param fail_loc=0x80000319
4867 touch $DIR/$tfile && error "Touch successful"
4870 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
4873 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
4876 get_inode_slab_tunables() {
4877 awk '/lustre_inode_cache/ {print $9," ",$10," ",$11; exit}' /proc/slabinfo
4880 set_inode_slab_tunables() {
4881 echo "lustre_inode_cache $1" > /proc/slabinfo
4884 test_76() { # Now for bug 20433, added originally in bug 1443
4885 local SLAB_SETTINGS=`get_inode_slab_tunables`
4886 local CPUS=`getconf _NPROCESSORS_ONLN`
4887 # we cannot set limit below 1 which means 1 inode in each
4888 # per-cpu cache is still allowed
4889 set_inode_slab_tunables "1 1 0"
4890 cancel_lru_locks osc
4891 BEFORE_INODES=`num_inodes`
4892 echo "before inodes: $BEFORE_INODES"
4894 [ "$SLOW" = "no" ] && COUNT=100
4895 for i in `seq $COUNT`; do
4899 cancel_lru_locks osc
4900 AFTER_INODES=`num_inodes`
4901 echo "after inodes: $AFTER_INODES"
4903 while [ $((AFTER_INODES-1*CPUS)) -gt $BEFORE_INODES ]; do
4905 AFTER_INODES=`num_inodes`
4907 echo "wait $wait seconds inodes: $AFTER_INODES"
4908 if [ $wait -gt 30 ]; then
4909 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
4912 set_inode_slab_tunables "$SLAB_SETTINGS"
4914 run_test 76 "confirm clients recycle inodes properly ===="
4920 # Note: in sptlrpc modes which enable its own bulk checksum, the
4921 # original crc32_le bulk checksum will be automatically disabled,
4922 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
4923 # will be checked by sptlrpc code against sptlrpc bulk checksum.
4924 # In this case set_checksums() will not be no-op, because sptlrpc
4925 # bulk checksum will be enabled all through the test.
4927 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
4928 lctl set_param -n osc.*.checksums $1
4932 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
4933 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
4934 CKSUM_TYPES=${CKSUM_TYPES:-"crc32 adler"}
4935 [ "$ORIG_CSUM_TYPE" = "crc32c" ] && CKSUM_TYPES="$CKSUM_TYPES crc32c"
4938 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
4939 log "set checksum type to $1"
4942 F77_TMP=$TMP/f77-temp
4945 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
4946 error "error writing to $F77_TMP"
4949 test_77a() { # bug 10889
4950 $GSS && skip "could not run with gss" && return
4951 [ ! -f $F77_TMP ] && setup_f77
4953 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
4957 run_test 77a "normal checksum read/write operation ============="
4959 test_77b() { # bug 10889
4960 $GSS && skip "could not run with gss" && return
4961 [ ! -f $F77_TMP ] && setup_f77
4962 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
4963 lctl set_param fail_loc=0x80000409
4965 dd if=$F77_TMP of=$DIR/f77b bs=1M count=$F77SZ conv=sync || \
4966 error "dd error: $?"
4967 lctl set_param fail_loc=0
4970 run_test 77b "checksum error on client write ===================="
4972 test_77c() { # bug 10889
4973 $GSS && skip "could not run with gss" && return
4974 [ ! -f $DIR/f77b ] && skip "requires 77b - skipping" && return
4976 for algo in $CKSUM_TYPES; do
4977 cancel_lru_locks osc
4978 set_checksum_type $algo
4979 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
4980 lctl set_param fail_loc=0x80000408
4981 cmp $F77_TMP $DIR/f77b || error "file compare failed"
4982 lctl set_param fail_loc=0
4985 set_checksum_type $ORIG_CSUM_TYPE
4988 run_test 77c "checksum error on client read ==================="
4990 test_77d() { # bug 10889
4991 $GSS && skip "could not run with gss" && return
4992 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
4993 lctl set_param fail_loc=0x80000409
4995 directio write $DIR/f77 0 $F77SZ $((1024 * 1024)) || \
4996 error "direct write: rc=$?"
4997 lctl set_param fail_loc=0
5000 run_test 77d "checksum error on OST direct write ==============="
5002 test_77e() { # bug 10889
5003 $GSS && skip "could not run with gss" && return
5004 [ ! -f $DIR/f77 ] && skip "requires 77d - skipping" && return
5005 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
5006 lctl set_param fail_loc=0x80000408
5008 cancel_lru_locks osc
5009 directio read $DIR/f77 0 $F77SZ $((1024 * 1024)) || \
5010 error "direct read: rc=$?"
5011 lctl set_param fail_loc=0
5014 run_test 77e "checksum error on OST direct read ================"
5016 test_77f() { # bug 10889
5017 $GSS && skip "could not run with gss" && return
5019 for algo in $CKSUM_TYPES; do
5020 cancel_lru_locks osc
5021 set_checksum_type $algo
5022 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5023 lctl set_param fail_loc=0x409
5024 directio write $DIR/f77 0 $F77SZ $((1024 * 1024)) && \
5025 error "direct write succeeded"
5026 lctl set_param fail_loc=0
5028 set_checksum_type $ORIG_CSUM_TYPE
5031 run_test 77f "repeat checksum error on write (expect error) ===="
5033 test_77g() { # bug 10889
5034 $GSS && skip "could not run with gss" && return
5035 remote_ost_nodsh && skip "remote OST with nodsh" && return
5037 [ ! -f $F77_TMP ] && setup_f77
5039 $SETSTRIPE -c 1 -i 0 $DIR/f77g
5040 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
5041 do_facet ost1 lctl set_param fail_loc=0x8000021a
5043 dd if=$F77_TMP of=$DIR/f77g bs=1M count=$F77SZ || \
5044 error "write error: rc=$?"
5045 do_facet ost1 lctl set_param fail_loc=0
5048 run_test 77g "checksum error on OST write ======================"
5050 test_77h() { # bug 10889
5051 $GSS && skip "could not run with gss" && return
5052 remote_ost_nodsh && skip "remote OST with nodsh" && return
5054 [ ! -f $DIR/f77g ] && skip "requires 77g - skipping" && return
5055 cancel_lru_locks osc
5056 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
5057 do_facet ost1 lctl set_param fail_loc=0x8000021b
5059 cmp $F77_TMP $DIR/f77g || error "file compare failed"
5060 do_facet ost1 lctl set_param fail_loc=0
5063 run_test 77h "checksum error on OST read ======================="
5065 test_77i() { # bug 13805
5066 $GSS && skip "could not run with gss" && return
5067 #define OBD_FAIL_OSC_CONNECT_CKSUM 0x40b
5068 lctl set_param fail_loc=0x40b
5069 remount_client $MOUNT
5070 lctl set_param fail_loc=0
5071 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
5072 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
5073 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
5074 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
5076 remount_client $MOUNT
5078 run_test 77i "client not supporting OSD_CONNECT_CKSUM =========="
5080 test_77j() { # bug 13805
5081 $GSS && skip "could not run with gss" && return
5082 #define OBD_FAIL_OSC_CKSUM_ADLER_ONLY 0x40c
5083 lctl set_param fail_loc=0x40c
5084 remount_client $MOUNT
5085 lctl set_param fail_loc=0
5086 sleep 2 # wait async osc connect to finish
5087 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
5088 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
5089 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
5090 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
5092 remount_client $MOUNT
5094 run_test 77j "client only supporting ADLER32 ===================="
5096 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
5100 test_78() { # bug 10901
5101 remote_ost || { skip_env "local OST" && return; }
5104 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
5105 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
5106 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
5107 echo "MemTotal: $MEMTOTAL"
5108 # reserve 256MB of memory for the kernel and other running processes,
5109 # and then take 1/2 of the remaining memory for the read/write buffers.
5110 if [ $MEMTOTAL -gt 512 ] ;then
5111 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
5113 # for those poor memory-starved high-end clusters...
5114 MEMTOTAL=$((MEMTOTAL / 2))
5116 echo "Mem to use for directio: $MEMTOTAL"
5117 [ $F78SIZE -gt $MEMTOTAL ] && F78SIZE=$MEMTOTAL
5118 [ $F78SIZE -gt 512 ] && F78SIZE=512
5119 [ $F78SIZE -gt $((MAXFREE / 1024)) ] && F78SIZE=$((MAXFREE / 1024))
5120 SMALLESTOST=`lfs df $DIR |grep OST | awk '{print $4}' |sort -n |head -1`
5121 echo "Smallest OST: $SMALLESTOST"
5122 [ $SMALLESTOST -lt 10240 ] && \
5123 skip "too small OSTSIZE, useless to run large O_DIRECT test" && return 0
5125 [ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ] && \
5126 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
5128 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
5129 echo "File size: $F78SIZE"
5130 $SETSTRIPE -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
5131 for i in `seq 1 $NSEQ`
5133 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
5134 echo directIO rdwr round $i of $NSEQ
5135 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
5140 run_test 78 "handle large O_DIRECT writes correctly ============"
5142 test_79() { # bug 12743
5143 wait_delete_completed
5145 BKTOTAL=$(calc_osc_kbytes kbytestotal)
5146 BKFREE=$(calc_osc_kbytes kbytesfree)
5147 BKAVAIL=$(calc_osc_kbytes kbytesavail)
5149 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
5150 DFTOTAL=`echo $STRING | cut -d, -f1`
5151 DFUSED=`echo $STRING | cut -d, -f2`
5152 DFAVAIL=`echo $STRING | cut -d, -f3`
5153 DFFREE=$(($DFTOTAL - $DFUSED))
5155 ALLOWANCE=$((64 * $OSTCOUNT))
5157 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
5158 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
5159 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
5161 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
5162 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
5163 error "df free($DFFREE) mismatch OST free($BKFREE)"
5165 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
5166 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
5167 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
5170 run_test 79 "df report consistency check ======================="
5172 test_80() { # bug 10718
5173 # relax strong synchronous semantics for slow backends like ZFS
5174 local soc="obdfilter.*.sync_on_lock_cancel"
5175 local soc_old=$(do_facet ost1 lctl get_param -n $soc | head -n1)
5177 if [ "$soc_old" != "never" -a "$(facet_fstype ost1)" != "ldiskfs" ]; then
5178 hosts=$(for host in $(seq -f "ost%g" 1 $OSTCOUNT); do
5179 facet_active_host $host; done | sort -u)
5180 do_nodes $hosts lctl set_param $soc=never
5183 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
5185 local BEFORE=`date +%s`
5186 cancel_lru_locks osc
5187 local AFTER=`date +%s`
5188 local DIFF=$((AFTER-BEFORE))
5189 if [ $DIFF -gt 1 ] ; then
5190 error "elapsed for 1M@1T = $DIFF"
5193 [ -n "$hosts" ] && do_nodes $hosts lctl set_param $soc=$soc_old
5197 run_test 80 "Page eviction is equally fast at high offsets too ===="
5199 test_81a() { # LU-456
5200 remote_ost_nodsh && skip "remote OST with nodsh" && return
5201 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
5202 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
5203 do_facet ost1 lctl set_param fail_loc=0x80000228
5205 # write should trigger a retry and success
5206 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
5207 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
5209 if [ $RC -ne 0 ] ; then
5210 error "write should success, but failed for $RC"
5213 run_test 81a "OST should retry write when get -ENOSPC ==============="
5215 test_81b() { # LU-456
5216 remote_ost_nodsh && skip "remote OST with nodsh" && return
5217 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
5218 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
5219 do_facet ost1 lctl set_param fail_loc=0x228
5221 # write should retry several times and return -ENOSPC finally
5222 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
5223 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
5226 if [ $RC -ne $ENOSPC ] ; then
5227 error "dd should fail for -ENOSPC, but succeed."
5230 run_test 81b "OST should return -ENOSPC when retry still fails ======="
5232 test_82() { # LU-1031
5233 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10
5237 multiop_bg_pause $DIR/$tfile OG${gid1}_g${gid1}c || return 1
5239 multiop_bg_pause $DIR/$tfile O_G${gid2}r10g${gid2}c || return 2
5241 kill -USR1 $MULTIPID2
5243 if [[ `ps h -o comm -p $MULTIPID2` == "" ]]; then
5244 error "First grouplock does not block second one"
5246 echo "Second grouplock blocks first one"
5248 kill -USR1 $MULTIPID1
5252 run_test 82 "Basic grouplock test ==============================="
5255 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && \
5257 test_mkdir -p $DIR/d99cvsroot
5258 chown $RUNAS_ID $DIR/d99cvsroot
5259 local oldPWD=$PWD # bug 13584, use $TMP as working dir
5262 $RUNAS cvs -d $DIR/d99cvsroot init || error
5265 run_test 99a "cvs init ========================================="
5268 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5269 [ ! -d $DIR/d99cvsroot ] && test_99a
5271 # some versions of cvs import exit(1) when asked to import links or
5272 # files they can't read. ignore those files.
5273 TOIGNORE=$(find . -type l -printf '-I %f\n' -o \
5274 ! -perm +4 -printf '-I %f\n')
5275 $RUNAS cvs -d $DIR/d99cvsroot import -m "nomesg" $TOIGNORE \
5276 d99reposname vtag rtag
5278 run_test 99b "cvs import ======================================="
5281 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5282 [ ! -d $DIR/d99cvsroot ] && test_99b
5284 test_mkdir -p $DIR/d99reposname
5285 chown $RUNAS_ID $DIR/d99reposname
5286 $RUNAS cvs -d $DIR/d99cvsroot co d99reposname
5288 run_test 99c "cvs checkout ====================================="
5291 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5292 [ ! -d $DIR/d99cvsroot ] && test_99c
5293 cd $DIR/d99reposname
5295 $RUNAS cvs add -m 'addmsg' foo99
5297 run_test 99d "cvs add =========================================="
5300 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5301 [ ! -d $DIR/d99cvsroot ] && test_99c
5302 cd $DIR/d99reposname
5305 run_test 99e "cvs update ======================================="
5308 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5309 [ ! -d $DIR/d99cvsroot ] && test_99d
5310 cd $DIR/d99reposname
5311 $RUNAS cvs commit -m 'nomsg' foo99
5312 rm -fr $DIR/d99cvsroot
5314 run_test 99f "cvs commit ======================================="
5317 [ "$NETTYPE" = tcp ] || \
5318 { skip "TCP secure port test, not useful for NETTYPE=$NETTYPE" && \
5321 remote_ost_nodsh && skip "remote OST with nodsh" && return
5322 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5324 { skip "useless for local single node setup" && return; }
5326 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
5327 [ "$PROT" != "tcp" ] && continue
5328 RPORT=$(echo $REMOTE | cut -d: -f2)
5329 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
5332 LPORT=`echo $LOCAL | cut -d: -f2`
5333 if [ $LPORT -ge 1024 ]; then
5334 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
5336 error_exit "local: $LPORT > 1024, remote: $RPORT"
5339 [ "$rc" = 0 ] || error_exit "privileged port not found" )
5341 run_test 100 "check local port using privileged port ==========="
5343 function get_named_value()
5352 echo $line | sed "s/^$tag[ ]*//"
5359 export CACHE_MAX=`$LCTL get_param -n llite.*.max_cached_mb | head -n 1`
5361 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
5369 [ "$CPU" = "UML" ] && nreads=1000
5370 local cache_limit=32
5372 $LCTL set_param -n osc.*-osc*.rpc_stats 0
5373 trap cleanup_101a EXIT
5374 $LCTL set_param -n llite.*.read_ahead_stats 0
5375 $LCTL set_param -n llite.*.max_cached_mb $cache_limit
5378 # randomly read 10000 of 64K chunks from file 3x 32MB in size
5380 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
5381 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
5384 for s in `$LCTL get_param -n llite.*.read_ahead_stats | \
5385 get_named_value 'read but discarded' | cut -d" " -f1`; do
5386 discard=$(($discard + $s))
5390 if [ $(($discard * 10)) -gt $nreads ] ;then
5391 $LCTL get_param osc.*-osc*.rpc_stats
5392 $LCTL get_param llite.*.read_ahead_stats
5393 error "too many ($discard) discarded pages"
5395 rm -f $DIR/$tfile || true
5397 run_test 101a "check read-ahead for random reads ================"
5400 test_mkdir -p $DIR/$tdir
5402 STRIPE_COUNT=$OSTCOUNT
5405 local list=$(comma_list $(osts_nodes))
5406 do_nodes $list $LCTL set_param -n obdfilter.*.read_cache_enable=0
5407 do_nodes $list $LCTL set_param -n obdfilter.*.writethrough_cache_enable=0
5409 trap cleanup_test101bc EXIT
5410 # prepare the read-ahead file
5411 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
5413 dd if=/dev/zero of=$DIR/$tfile bs=1024k count=100 2> /dev/null
5416 cleanup_test101bc() {
5421 local list=$(comma_list $(osts_nodes))
5422 do_nodes $list $LCTL set_param -n obdfilter.*.read_cache_enable=1
5423 do_nodes $list $LCTL set_param -n obdfilter.*.writethrough_cache_enable=1
5427 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
5432 local STRIPE_SIZE=1048576
5433 local RA_INC=1048576
5434 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
5435 local FILE_LENGTH=$((64*100))
5436 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
5437 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
5438 DISCARD=`$LCTL get_param -n llite.*.read_ahead_stats | \
5439 get_named_value 'read but discarded' | \
5440 cut -d" " -f1 | calc_total`
5441 if [ $DISCARD -gt $discard_limit ]; then
5442 $LCTL get_param llite.*.read_ahead_stats
5443 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
5445 echo "Read-ahead success for size ${READ_SIZE}"
5450 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping stride IO stride-ahead test" && return
5451 local STRIPE_SIZE=1048576
5452 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
5453 local FILE_LENGTH=$((STRIPE_SIZE*100))
5454 local ITERATION=$((FILE_LENGTH/STRIDE_SIZE))
5455 # prepare the read-ahead file
5457 cancel_lru_locks osc
5458 for BIDX in 2 4 8 16 32 64 128 256
5460 local BSIZE=$((BIDX*4096))
5461 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
5462 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
5463 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
5464 $LCTL set_param -n llite.*.read_ahead_stats 0
5465 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
5466 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
5467 cancel_lru_locks osc
5473 run_test 101b "check stride-io mode read-ahead ================="
5476 local STRIPE_SIZE=1048576
5477 local FILE_LENGTH=$((STRIPE_SIZE*100))
5483 cancel_lru_locks osc
5484 $LCTL set_param osc.*.rpc_stats 0
5485 $READS -f $DIR/$tfile -s$FILE_LENGTH -b65536 -n$nreads -t 180
5486 for osc in $($LCTL get_param -N osc.*); do
5487 if [ "$osc" == "osc.num_refs" ]; then
5491 local lines=$($LCTL get_param -n ${osc}.rpc_stats | wc | awk '{print $1}')
5492 if [ $lines -le 20 ]; then
5496 local rpc4k=$($LCTL get_param -n ${osc}.rpc_stats |
5497 awk '$1 == "1:" { print $2; exit; }')
5498 local rpc8k=$($LCTL get_param -n ${osc}.rpc_stats |
5499 awk '$1 == "2:" { print $2; exit; }')
5500 local rpc16k=$($LCTL get_param -n ${osc}.rpc_stats |
5501 awk '$1 == "4:" { print $2; exit; }')
5502 local rpc32k=$($LCTL get_param -n ${osc}.rpc_stats |
5503 awk '$1 == "8:" { print $2; exit; }')
5505 [ $rpc4k != 0 ] && error "Small 4k read IO ${rpc4k}!"
5506 [ $rpc8k != 0 ] && error "Small 8k read IO ${rpc8k}!"
5507 [ $rpc16k != 0 ] && error "Small 16k read IO ${rpc16k}!"
5508 [ $rpc32k != 0 ] && error "Small 32k read IO ${rpc32k}!"
5509 echo "${osc} rpc check passed!"
5514 run_test 101c "check stripe_size aligned read-ahead ================="
5517 $LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1
5518 $LCTL set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
5522 local file=$DIR/$tfile
5523 local size=${FILESIZE_101c:-500}
5524 local ra_MB=${READAHEAD_MB:-40}
5526 local space=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
5527 [ $space -gt $((size * 1024)) ] ||
5528 { skip "Need free space ${size}M, have $space" && return; }
5530 echo Creating ${size}M test file $file
5531 dd if=/dev/zero of=$file bs=1M count=$size || error "dd failed"
5532 echo Cancel LRU locks on lustre client to flush the client cache
5533 cancel_lru_locks osc
5535 echo Disable read-ahead
5536 local old_READAHEAD=$(set_read_ahead 0)
5538 echo Reading the test file $file with read-ahead disabled
5539 time_ra_OFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$size")
5541 echo Cancel LRU locks on lustre client to flush the client cache
5542 cancel_lru_locks osc
5543 echo Enable read-ahead with ${ra_MB}MB
5544 set_read_ahead $ra_MB
5546 echo Reading the test file $file with read-ahead enabled
5547 time_ra_ON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$size")
5549 echo read-ahead disabled time read $time_ra_OFF
5550 echo read-ahead enabled time read $time_ra_ON
5552 set_read_ahead $old_READAHEAD
5554 wait_delete_completed
5556 [ $time_ra_ON -lt $time_ra_OFF ] ||
5557 error "read-ahead enabled time read (${time_ra_ON}s) is more than
5558 read-ahead disabled time read (${time_ra_OFF}s) filesize ${size}M"
5560 run_test 101d "file read with and without read-ahead enabled ================="
5563 local file=$DIR/$tfile
5568 local space=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
5569 local need_space=$((count * size))
5570 [ $space -gt $need_space ] ||
5571 { skip_env "Need free space $need_space, have $space" && return; }
5573 echo Creating $count ${size}K test files
5574 for ((i = 0; i < $count; i++)); do
5575 dd if=/dev/zero of=${file}_${i} bs=$blksize count=$size 2>/dev/null
5578 echo Cancel LRU locks on lustre client to flush the client cache
5579 cancel_lru_locks osc
5581 echo Reset readahead stats
5582 $LCTL set_param -n llite.*.read_ahead_stats 0
5584 for ((i = 0; i < $count; i++)); do
5585 dd if=${file}_${i} of=/dev/null bs=$blksize count=$size 2>/dev/null
5588 local miss=$($LCTL get_param -n llite.*.read_ahead_stats | \
5589 get_named_value 'misses' | cut -d" " -f1 | calc_total)
5591 for ((i = 0; i < $count; i++)); do
5592 rm -rf ${file}_${i} 2>/dev/null
5595 #10000 means 20% reads are missing in readahead
5596 [ $miss -lt 10000 ] || error "misses too much for small reads"
5598 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
5600 cleanup_test101f() {
5602 $LCTL set_param -n llite.*.max_read_ahead_whole_mb $MAX_WHOLE_MB
5603 rm -rf $DIR/$tfile 2>/dev/null
5607 local file=$DIR/$tfile
5610 MAX_WHOLE_MB=$($LCTL get_param -n llite.*.max_read_ahead_whole_mb)
5611 $LCTL set_param -n llite.*.max_read_ahead_whole_mb 2
5612 dd if=/dev/zero of=${file} bs=2097152 count=1 2>/dev/null
5613 trap cleanup_test101f EXIT
5615 echo Cancel LRU locks on lustre client to flush the client cache
5616 cancel_lru_locks osc
5618 echo Reset readahead stats
5619 $LCTL set_param -n llite.*.read_ahead_stats 0
5620 # Random read in a 2M file, because max_read_ahead_whole_mb = 2M,
5621 # readahead should read in 2M file on second read, so only miss
5623 echo Random 4K reads on 2M file for 1000 times
5624 $READS -f $file -s 2097152 -b 4096 -n $nreads
5626 echo checking missing pages
5627 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
5628 get_named_value 'misses' | cut -d" " -f1 | calc_total)
5630 [ $miss -lt 3 ] || error "misses too much pages!"
5633 run_test 101f "check read-ahead for max_read_ahead_whole_mb"
5636 test_mkdir -p $DIR/$tdir
5637 chown $RUNAS_ID $DIR/$tdir
5640 STRIPE_COUNT=$OSTCOUNT
5641 [ $OSTCOUNT -gt 4 ] && STRIPE_COUNT=4
5643 trap cleanup_test102 EXIT
5645 $1 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
5647 for num in 1 2 3 4; do
5648 for count in $(seq 1 $STRIPE_COUNT); do
5649 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
5650 local size=`expr $STRIPE_SIZE \* $num`
5651 local file=file"$num-$idx-$count"
5652 $1 $SETSTRIPE -S $size -i $idx -c $count $file
5658 $1 $TAR cf $TMP/f102.tar $tdir --xattrs
5664 rm -rf $DIR/d0.sanity/d102
5668 local testfile=$DIR/xattr_testfile
5672 [ "$UID" != 0 ] && skip_env "must run as root" && return
5673 [ -z "`lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr`" ] &&
5674 skip_env "must have user_xattr" && return
5676 [ -z "$(which setfattr 2>/dev/null)" ] &&
5677 skip_env "could not find setfattr" && return
5679 echo "set/get xattr..."
5680 setfattr -n trusted.name1 -v value1 $testfile || error
5681 getfattr -n trusted.name1 $testfile 2> /dev/null |
5682 grep "trusted.name1=.value1" ||
5683 error "$testfile missing trusted.name1=value1"
5685 setfattr -n user.author1 -v author1 $testfile || error
5686 getfattr -n user.author1 $testfile 2> /dev/null |
5687 grep "user.author1=.author1" ||
5688 error "$testfile missing trusted.author1=author1"
5691 setfattr -n trusted.name2 -v value2 $testfile ||
5692 error "$testfile unable to set trusted.name2"
5693 setfattr -n trusted.name3 -v value3 $testfile ||
5694 error "$testfile unable to set trusted.name3"
5695 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
5696 grep "trusted.name" | wc -l) -eq 3 ] ||
5697 error "$testfile missing 3 trusted.name xattrs"
5699 setfattr -n user.author2 -v author2 $testfile ||
5700 error "$testfile unable to set user.author2"
5701 setfattr -n user.author3 -v author3 $testfile ||
5702 error "$testfile unable to set user.author3"
5703 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
5704 grep "user.author" | wc -l) -eq 3 ] ||
5705 error "$testfile missing 3 user.author xattrs"
5707 echo "remove xattr..."
5708 setfattr -x trusted.name1 $testfile ||
5709 error "$testfile error deleting trusted.name1"
5710 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
5711 error "$testfile did not delete trusted.name1 xattr"
5713 setfattr -x user.author1 $testfile ||
5714 error "$testfile error deleting user.author1"
5715 getfattr -d -m user $testfile 2> /dev/null | grep "user.author1" &&
5716 error "$testfile did not delete trusted.name1 xattr"
5718 # b10667: setting lustre special xattr be silently discarded
5719 echo "set lustre special xattr ..."
5720 setfattr -n "trusted.lov" -v "invalid value" $testfile ||
5721 error "$testfile allowed setting trusted.lov"
5723 run_test 102a "user xattr test =================================="
5726 # b10930: get/set/list trusted.lov xattr
5727 echo "get/set/list trusted.lov xattr ..."
5728 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
5729 local testfile=$DIR/$tfile
5730 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
5731 error "setstripe failed"
5732 local STRIPECOUNT=$($GETSTRIPE -c $testfile) ||
5733 error "getstripe failed"
5734 getfattr -d -m "^trusted" $testfile 2> /dev/null | \
5735 grep "trusted.lov" || error "can't get trusted.lov from $testfile"
5737 local testfile2=${testfile}2
5738 local value=`getfattr -n trusted.lov $testfile 2> /dev/null | \
5739 grep "trusted.lov" |sed -e 's/[^=]\+=//'`
5742 setfattr -n trusted.lov -v $value $testfile2
5743 local stripe_size=$($GETSTRIPE -S $testfile2)
5744 local stripe_count=$($GETSTRIPE -c $testfile2)
5745 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
5746 [ $stripe_count -eq $STRIPECOUNT ] ||
5747 error "stripe count $stripe_count != $STRIPECOUNT"
5750 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
5753 # b10930: get/set/list lustre.lov xattr
5754 echo "get/set/list lustre.lov xattr ..."
5755 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
5756 test_mkdir -p $DIR/$tdir
5757 chown $RUNAS_ID $DIR/$tdir
5758 local testfile=$DIR/$tdir/$tfile
5759 $RUNAS $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
5760 error "setstripe failed"
5761 local STRIPECOUNT=$($RUNAS $GETSTRIPE -c $testfile) ||
5762 error "getstripe failed"
5763 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
5764 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
5766 local testfile2=${testfile}2
5767 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
5768 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
5770 $RUNAS $MCREATE $testfile2
5771 $RUNAS setfattr -n lustre.lov -v $value $testfile2
5772 local stripe_size=$($RUNAS $GETSTRIPE -S $testfile2)
5773 local stripe_count=$($RUNAS $GETSTRIPE -c $testfile2)
5774 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
5775 [ $stripe_count -eq $STRIPECOUNT ] ||
5776 error "stripe count $stripe_count != $STRIPECOUNT"
5778 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
5780 compare_stripe_info1() {
5781 local stripe_index_all_zero=true
5783 for num in 1 2 3 4; do
5784 for count in $(seq 1 $STRIPE_COUNT); do
5785 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
5786 local size=$((STRIPE_SIZE * num))
5787 local file=file"$num-$offset-$count"
5788 stripe_size=$(lfs getstripe -S $PWD/$file)
5789 [ $stripe_size -ne $size ] &&
5790 error "$file: size $stripe_size != $size"
5791 stripe_count=$(lfs getstripe -c $PWD/$file)
5792 # allow fewer stripes to be created, ORI-601
5793 [ $stripe_count -lt $(((3 * count + 3) / 4)) ]&&
5794 error "$file: count $stripe_count != $count"
5795 stripe_index=$(lfs getstripe -i $PWD/$file)
5796 [ $stripe_index -ne 0 ] &&
5797 stripe_index_all_zero=false
5801 $stripe_index_all_zero &&
5802 error "all files are being extracted starting from OST index 0"
5807 [ -n "$(which tar 2>/dev/null)" ] &&
5808 strings $(which tar) | grep -q "lustre" && echo tar
5812 # b10930: tar test for trusted.lov xattr
5813 TAR=$(find_lustre_tar)
5814 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
5815 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
5817 test_mkdir -p $DIR/d102d
5818 $TAR xf $TMP/f102.tar -C $DIR/d102d --xattrs
5820 compare_stripe_info1
5822 run_test 102d "tar restore stripe info from tarfile,not keep osts ==========="
5825 # b10930: tar test for trusted.lov xattr
5826 TAR=$(find_lustre_tar)
5827 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
5828 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
5830 test_mkdir -p $DIR/d102f
5832 $TAR cf - --xattrs $tdir | $TAR xf - --xattrs -C $DIR/d102f
5834 compare_stripe_info1
5836 run_test 102f "tar copy files, not keep osts ==========="
5839 local xsize=${1:-1024} # in bytes
5840 local file=$DIR/$tfile
5842 [ -z $(lctl get_param -n mdc.*.connect_flags | grep xattr) ] &&
5843 skip "must have user_xattr" && return 0
5844 [ -z "$(which setfattr 2>/dev/null)" ] &&
5845 skip_env "could not find setfattr" && return 0
5846 [ -z "$(which getfattr 2>/dev/null)" ] &&
5847 skip_env "could not find getfattr" && return 0
5851 local value="$(generate_string $xsize)"
5853 local xbig=trusted.big
5854 log "save $xbig on $file"
5855 setfattr -n $xbig -v $value $file ||
5856 error "saving $xbig on $file failed"
5858 local orig=$(get_xattr_value $xbig $file)
5859 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
5861 local xsml=trusted.sml
5862 log "save $xsml on $file"
5863 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
5865 local new=$(get_xattr_value $xbig $file)
5866 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
5868 log "grow $xsml on $file"
5869 setfattr -n $xsml -v "$value" $file ||
5870 error "growing $xsml on $file failed"
5872 new=$(get_xattr_value $xbig $file)
5873 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
5874 log "$xbig still valid after growing $xsml"
5879 test_102h() { # bug 15777
5882 run_test 102h "grow xattr from inside inode to external block"
5885 large_xattr_enabled || { skip "large_xattr disabled" && return; }
5886 grow_xattr $(max_xattr_size)
5888 run_test 102ha "grow xattr from inside inode to external inode"
5890 test_102i() { # bug 17038
5892 ln -s $DIR/$tfile $DIR/${tfile}link
5893 getfattr -n trusted.lov $DIR/$tfile || error "lgetxattr on $DIR/$tfile failed"
5894 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"
5895 rm -f $DIR/$tfile $DIR/${tfile}link
5897 run_test 102i "lgetxattr test on symbolic link ============"
5900 TAR=$(find_lustre_tar)
5901 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
5902 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
5903 setup_test102 "$RUNAS"
5904 test_mkdir -p $DIR/d102j
5905 chown $RUNAS_ID $DIR/d102j
5906 $RUNAS $TAR xf $TMP/f102.tar -C $DIR/d102j --xattrs
5908 compare_stripe_info1 "$RUNAS"
5910 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
5914 # b22187 just check that does not crash for regular file.
5915 setfattr -n trusted.lov $DIR/$tfile
5916 # b22187 'setfattr -n trusted.lov' should work as remove LOV EA for directories
5917 local test_kdir=$DIR/d102k
5918 test_mkdir $test_kdir
5919 local default_size=`$GETSTRIPE -S $test_kdir`
5920 local default_count=`$GETSTRIPE -c $test_kdir`
5921 local default_offset=`$GETSTRIPE -i $test_kdir`
5922 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $test_kdir ||
5923 error 'dir setstripe failed'
5924 setfattr -n trusted.lov $test_kdir
5925 local stripe_size=`$GETSTRIPE -S $test_kdir`
5926 local stripe_count=`$GETSTRIPE -c $test_kdir`
5927 local stripe_offset=`$GETSTRIPE -i $test_kdir`
5928 [ $stripe_size -eq $default_size ] ||
5929 error "stripe size $stripe_size != $default_size"
5930 [ $stripe_count -eq $default_count ] ||
5931 error "stripe count $stripe_count != $default_count"
5932 [ $stripe_offset -eq $default_offset ] ||
5933 error "stripe offset $stripe_offset != $default_offset"
5934 rm -rf $DIR/$tfile $test_kdir
5936 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
5939 # LU-532 trusted. xattr is invisible to non-root
5940 local testfile=$DIR/$tfile
5944 echo "listxattr as user..."
5945 chown $RUNAS_ID $testfile
5946 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
5947 grep -q "trusted" &&
5948 error "$testfile trusted xattrs are user visible"
5952 run_test 102l "listxattr filter test =================================="
5958 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
5963 [ "$UID" != 0 ] && skip_env "must run as root" && return
5964 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
5965 [ -z "$(which setfacl 2>/dev/null)" ] && skip_env "could not find setfacl" && return
5966 $GSS && skip "could not run under gss" && return
5968 declare -a identity_old
5970 for num in $(seq $MDSCOUNT); do
5971 switch_identity $num true || identity_old[$num]=$?
5978 echo "performing cp ..."
5979 run_acl_subtest cp || error
5980 echo "performing getfacl-noacl..."
5981 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
5982 echo "performing misc..."
5983 run_acl_subtest misc || error "misc test failed"
5984 echo "performing permissions..."
5985 run_acl_subtest permissions || error "permissions failed"
5986 echo "performing setfacl..."
5987 run_acl_subtest setfacl || error "setfacl test failed"
5989 # inheritance test got from HP
5990 echo "performing inheritance..."
5991 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
5992 chmod +x make-tree || error "chmod +x failed"
5993 run_acl_subtest inheritance || error "inheritance test failed"
5996 echo "LU-974 ignore umask when acl is enabled..."
5999 run_acl_subtest 974 || error "LU-974 test failed"
6005 for num in $(seq $MDSCOUNT); do
6006 if [ "${identity_old[$num]}" = 1 ]; then
6007 switch_identity $num false || identity_old[$num]=$?
6011 run_test 103 "acl test ========================================="
6015 lfs df || error "lfs df failed"
6016 lfs df -ih || error "lfs df -ih failed"
6017 lfs df -h $DIR || error "lfs df -h $DIR failed"
6018 lfs df -i $DIR || error "lfs df -i $DIR failed"
6019 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
6020 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
6022 OSC=`lctl dl |grep OST0000-osc-[^M] |awk '{print $4}'`
6023 lctl --device %$OSC deactivate
6024 lfs df || error "lfs df with deactivated OSC failed"
6025 lctl --device %$OSC activate
6026 # wait the osc back to normal
6027 wait_osc_import_state client ost FULL
6029 lfs df || error "lfs df with reactivated OSC failed"
6032 run_test 104a "lfs df [-ih] [path] test ========================="
6035 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
6037 denied_cnt=$((`$RUNAS $LFS check servers 2>&1 | grep "Permission denied" | wc -l`))
6038 if [ $denied_cnt -ne 0 ];
6040 error "lfs check servers test failed"
6043 run_test 104b "$RUNAS lfs check servers test ===================="
6046 # doesn't work on 2.4 kernels
6048 if [ -n "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ];
6050 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
6052 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
6056 run_test 105a "flock when mounted without -o flock test ========"
6060 if [ -n "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ];
6062 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
6064 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
6068 run_test 105b "fcntl when mounted without -o flock test ========"
6072 if [ -n "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ];
6074 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
6076 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
6080 run_test 105c "lockf when mounted without -o flock test ========"
6082 test_105d() { # bug 15924
6083 test_mkdir -p $DIR/$tdir
6084 [ -z "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ] && \
6085 skip "mount w/o flock enabled" && return
6086 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
6087 $LCTL set_param fail_loc=0x80000315
6088 flocks_test 2 $DIR/$tdir
6090 run_test 105d "flock race (should not freeze) ========"
6092 test_105e() { # bug 22660 && 22040
6093 [ -z "`mount | grep \"$DIR.*flock\" | grep -v noflock`" ] && \
6094 skip "mount w/o flock enabled" && return
6096 flocks_test 3 $DIR/$tfile
6098 run_test 105e "Two conflicting flocks from same process ======="
6100 test_106() { #bug 10921
6101 test_mkdir -p $DIR/$tdir
6102 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
6103 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
6105 run_test 106 "attempt exec of dir followed by chown of that dir"
6114 local save_pattern=$(sysctl -n kernel.core_pattern)
6115 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
6116 sysctl -w kernel.core_pattern=$file
6117 sysctl -w kernel.core_uses_pid=0
6125 kill -s 11 $SLEEPPID
6127 if [ -e $file ]; then
6128 size=`stat -c%s $file`
6129 [ $size -eq 0 ] && error "Fail to create core file $file"
6131 error "Fail to create core file $file"
6134 sysctl -w kernel.core_pattern=$save_pattern
6135 sysctl -w kernel.core_uses_pid=$save_uses_pid
6138 run_test 107 "Coredump on SIG"
6141 test_mkdir -p $DIR/$tdir
6142 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255) ||
6143 error "mkdir with 255 char failed"
6144 test_mkdir $DIR/$tdir/$(str_repeat 'b' 256) &&
6145 error "mkdir with 256 char should fail, but did not"
6146 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
6147 error "create with 255 char failed"
6148 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
6149 error "create with 256 char should fail, but did not"
6154 run_test 110 "filename length checking"
6157 OSTIO_pre=$(ps -e|grep ll_ost_io|awk '{print $4}'|sort -n|tail -1|\
6159 [ -z "$OSTIO_pre" ] && skip "no OSS threads" && \
6161 echo "Starting with $OSTIO_pre threads"
6164 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
6165 [ $NUMFREE -lt $NUMTEST ] && NUMTEST=$(($NUMFREE - 1000))
6166 echo "$NUMTEST creates/unlinks"
6167 test_mkdir -p $DIR/$tdir
6168 createmany -o $DIR/$tdir/$tfile $NUMTEST
6169 unlinkmany $DIR/$tdir/$tfile $NUMTEST
6171 OSTIO_post=$(ps -e|grep ll_ost_io|awk '{print $4}'|sort -n|tail -1|\
6174 # don't return an error
6175 [ $OSTIO_post == $OSTIO_pre ] && echo \
6176 "WARNING: No new ll_ost_io threads were created ($OSTIO_pre)" &&
6177 echo "This may be fine, depending on what ran before this test" &&
6178 echo "and how fast this system is." && return
6180 echo "Started with $OSTIO_pre threads, ended with $OSTIO_post"
6182 run_test 115 "verify dynamic thread creation===================="
6185 wait_delete_completed
6186 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
6187 echo OST kbytes available: ${AVAIL[@]}
6188 MAXI=0; MAXV=${AVAIL[0]}
6189 MINI=0; MINV=${AVAIL[0]}
6190 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
6191 #echo OST $i: ${AVAIL[i]}kb
6192 if [ ${AVAIL[i]} -gt $MAXV ]; then
6193 MAXV=${AVAIL[i]}; MAXI=$i
6195 if [ ${AVAIL[i]} -lt $MINV ]; then
6196 MINV=${AVAIL[i]}; MINI=$i
6199 echo Min free space: OST $MINI: $MINV
6200 echo Max free space: OST $MAXI: $MAXV
6203 test_116a() { # was previously test_116()
6204 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs" && return
6206 echo -n "Free space priority "
6207 lctl get_param -n lov.*-clilov-*.qos_prio_free
6210 [ $MINV -gt 960000 ] && skip "too much free space in OST$MINI, skip" &&\
6213 # generate uneven OSTs
6214 test_mkdir -p $DIR/$tdir/OST${MINI}
6217 echo "Filling 25% remaining space in OST${MINI} with ${FILL}Kb"
6218 $SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI}||error "setstripe failed"
6220 while [ $FILL -gt 0 ]; do
6222 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i bs=2M count=1 2>/dev/null
6223 FILL=$(($FILL - 2048))
6231 DIFF=$(($MAXV - $MINV))
6232 DIFF2=$(($DIFF * 100 / $MINV))
6233 echo -n "diff=${DIFF}=${DIFF2}% must be > 20% for QOS mode..."
6234 if [ $DIFF2 -gt 20 ]; then
6237 echo "failed - QOS mode won't be used"
6238 error_ignore "QOS imbalance criteria not met"
6242 MINI1=$MINI; MINV1=$MINV
6243 MAXI1=$MAXI; MAXV1=$MAXV
6245 # now fill using QOS
6246 echo writing a bunch of files to QOS-assigned OSTs
6247 $SETSTRIPE -c 1 $DIR/$tdir
6249 while [ $FILL -gt 0 ]; do
6251 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1024 count=200 2>/dev/null
6252 FILL=$(($FILL - 200))
6255 echo "wrote $i 200k files"
6259 echo "Note: free space may not be updated, so measurements might be off"
6261 DIFF2=$(($MAXV - $MINV))
6262 echo "free space delta: orig $DIFF final $DIFF2"
6263 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
6264 DIFF=$(($MINV1 - ${AVAIL[$MINI1]}))
6265 echo "Wrote $DIFF to smaller OST $MINI1"
6266 DIFF2=$(($MAXV1 - ${AVAIL[$MAXI1]}))
6267 echo "Wrote $DIFF2 to larger OST $MAXI1"
6268 [ $DIFF -gt 0 ] && echo "Wrote $(($DIFF2 * 100 / $DIFF - 100))% more data to larger OST $MAXI1"
6270 # Figure out which files were written where
6271 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
6272 awk '/'$MINI1': / {print $2; exit}')
6274 MINC=$($GETSTRIPE --obd $UUID $DIR/$tdir | wc -l)
6275 echo "$MINC files created on smaller OST $MINI1"
6276 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
6277 awk '/'$MAXI1': / {print $2; exit}')
6279 MAXC=$($GETSTRIPE --obd $UUID $DIR/$tdir | wc -l)
6280 echo "$MAXC files created on larger OST $MAXI1"
6281 [ $MINC -gt 0 ] && echo "Wrote $(($MAXC * 100 / $MINC - 100))% more files to larger OST $MAXI1"
6282 [ $MAXC -gt $MINC ] || error_ignore "stripe QOS didn't balance free space"
6286 run_test 116a "stripe QOS: free space balance ==================="
6288 test_116b() { # LU-2093
6289 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
6291 old_rr=$(do_facet $SINGLEMDS lctl get_param -n lov.*mdtlov*.qos_threshold_rr)
6292 do_facet $SINGLEMDS lctl set_param lov.*mdtlov*.qos_threshold_rr 0
6294 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
6295 createmany -o $DIR/$tdir/f- 20 || error "can't create"
6296 do_facet $SINGLEMDS lctl set_param fail_loc=0
6298 do_facet $SINGLEMDS lctl set_param lov.*mdtlov*.qos_threshold_rr $old_rr
6300 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
6302 test_117() # bug 10891
6304 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
6305 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
6306 lctl set_param fail_loc=0x21e
6307 > $DIR/$tfile || error "truncate failed"
6308 lctl set_param fail_loc=0
6309 echo "Truncate succeeded."
6312 run_test 117 "verify fsfilt_extend =========="
6314 export OLD_RESENDCOUNT=""
6315 set_resend_count () {
6316 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
6317 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -1)
6318 lctl set_param -n $PROC_RESENDCOUNT $1
6319 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
6322 [ "$SLOW" = "no" ] && set_resend_count 4 # for reduce test_118* time (bug 14842)
6324 # Reset async IO behavior after error case
6326 FILE=$DIR/reset_async
6328 # Ensure all OSCs are cleared
6329 $SETSTRIPE -c -1 $FILE
6330 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
6335 test_118a() #bug 11710
6339 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6340 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6341 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
6343 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6344 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6349 run_test 118a "verify O_SYNC works =========="
6353 remote_ost_nodsh && skip "remote OST with nodsh" && return
6357 #define OBD_FAIL_OST_ENOENT 0x217
6358 set_nodes_failloc "$(osts_nodes)" 0x217
6359 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6361 set_nodes_failloc "$(osts_nodes)" 0
6362 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6363 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6366 if [[ $RC -eq 0 ]]; then
6367 error "Must return error due to dropped pages, rc=$RC"
6371 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6372 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6376 echo "Dirty pages not leaked on ENOENT"
6378 # Due to the above error the OSC will issue all RPCs syncronously
6379 # until a subsequent RPC completes successfully without error.
6380 $MULTIOP $DIR/$tfile Ow4096yc
6385 run_test 118b "Reclaim dirty pages on fatal error =========="
6389 remote_ost_nodsh && skip "remote OST with nodsh" && return
6393 #define OBD_FAIL_OST_EROFS 0x216
6394 set_nodes_failloc "$(osts_nodes)" 0x216
6396 # multiop should block due to fsync until pages are written
6397 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
6401 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
6402 error "Multiop failed to block on fsync, pid=$MULTIPID"
6405 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6407 if [[ $WRITEBACK -eq 0 ]]; then
6408 error "No page in writeback, writeback=$WRITEBACK"
6411 set_nodes_failloc "$(osts_nodes)" 0
6414 if [[ $RC -ne 0 ]]; then
6415 error "Multiop fsync failed, rc=$RC"
6418 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6419 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6421 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6422 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6426 echo "Dirty pages flushed via fsync on EROFS"
6429 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
6433 remote_ost_nodsh && skip "remote OST with nodsh" && return
6437 #define OBD_FAIL_OST_BRW_PAUSE_BULK
6438 set_nodes_failloc "$(osts_nodes)" 0x214
6439 # multiop should block due to fsync until pages are written
6440 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
6444 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
6445 error "Multiop failed to block on fsync, pid=$MULTIPID"
6448 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6450 if [[ $WRITEBACK -eq 0 ]]; then
6451 error "No page in writeback, writeback=$WRITEBACK"
6454 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
6455 set_nodes_failloc "$(osts_nodes)" 0
6457 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6458 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6460 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6461 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6465 echo "Dirty pages gaurenteed flushed via fsync"
6468 run_test 118d "Fsync validation inject a delay of the bulk =========="
6473 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
6474 lctl set_param fail_loc=0x8000040a
6476 # Should simulate EINVAL error which is fatal
6477 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6479 if [[ $RC -eq 0 ]]; then
6480 error "Must return error due to dropped pages, rc=$RC"
6483 lctl set_param fail_loc=0x0
6485 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6486 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6487 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6489 if [[ $LOCKED -ne 0 ]]; then
6490 error "Locked pages remain in cache, locked=$LOCKED"
6493 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6494 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6498 echo "No pages locked after fsync"
6503 run_test 118f "Simulate unrecoverable OSC side error =========="
6508 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
6509 lctl set_param fail_loc=0x406
6511 # simulate local -ENOMEM
6512 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6515 lctl set_param fail_loc=0
6516 if [[ $RC -eq 0 ]]; then
6517 error "Must return error due to dropped pages, rc=$RC"
6520 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6521 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6522 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6524 if [[ $LOCKED -ne 0 ]]; then
6525 error "Locked pages remain in cache, locked=$LOCKED"
6528 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6529 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6533 echo "No pages locked after fsync"
6538 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
6541 remote_ost_nodsh && skip "remote OST with nodsh" && return
6545 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
6546 set_nodes_failloc "$(osts_nodes)" 0x20e
6547 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
6548 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6551 set_nodes_failloc "$(osts_nodes)" 0
6552 if [[ $RC -eq 0 ]]; then
6553 error "Must return error due to dropped pages, rc=$RC"
6556 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6557 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6558 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6560 if [[ $LOCKED -ne 0 ]]; then
6561 error "Locked pages remain in cache, locked=$LOCKED"
6564 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6565 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6569 echo "No pages locked after fsync"
6573 run_test 118h "Verify timeout in handling recoverables errors =========="
6575 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
6578 remote_ost_nodsh && skip "remote OST with nodsh" && return
6582 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
6583 set_nodes_failloc "$(osts_nodes)" 0x20e
6585 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
6586 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
6589 set_nodes_failloc "$(osts_nodes)" 0
6593 if [[ $RC -ne 0 ]]; then
6594 error "got error, but should be not, rc=$RC"
6597 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6598 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6599 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
6600 if [[ $LOCKED -ne 0 ]]; then
6601 error "Locked pages remain in cache, locked=$LOCKED"
6604 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6605 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6609 echo "No pages locked after fsync"
6613 run_test 118i "Fix error before timeout in recoverable error =========="
6615 [ "$SLOW" = "no" ] && set_resend_count 4
6618 remote_ost_nodsh && skip "remote OST with nodsh" && return
6622 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
6623 set_nodes_failloc "$(osts_nodes)" 0x220
6625 # return -EIO from OST
6626 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6628 set_nodes_failloc "$(osts_nodes)" 0x0
6629 if [[ $RC -eq 0 ]]; then
6630 error "Must return error due to dropped pages, rc=$RC"
6633 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6634 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6635 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
6636 if [[ $LOCKED -ne 0 ]]; then
6637 error "Locked pages remain in cache, locked=$LOCKED"
6640 # in recoverable error on OST we want resend and stay until it finished
6641 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6642 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6646 echo "No pages locked after fsync"
6650 run_test 118j "Simulate unrecoverable OST side error =========="
6654 remote_ost_nodsh && skip "remote OSTs with nodsh" && return
6656 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
6657 set_nodes_failloc "$(osts_nodes)" 0x20e
6658 test_mkdir -p $DIR/$tdir
6660 for ((i=0;i<10;i++)); do
6661 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
6662 error "dd to $DIR/$tdir/$tfile-$i failed" )&
6669 set_nodes_failloc "$(osts_nodes)" 0
6672 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
6677 test_mkdir -p $DIR/$tdir
6678 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
6681 run_test 118l "fsync dir ========="
6683 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
6685 test_119a() # bug 11737
6687 BSIZE=$((512 * 1024))
6688 directio write $DIR/$tfile 0 1 $BSIZE
6689 # We ask to read two blocks, which is more than a file size.
6690 # directio will indicate an error when requested and actual
6691 # sizes aren't equeal (a normal situation in this case) and
6692 # print actual read amount.
6693 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
6694 if [ "$NOB" != "$BSIZE" ]; then
6695 error "read $NOB bytes instead of $BSIZE"
6699 run_test 119a "Short directIO read must return actual read amount"
6701 test_119b() # bug 11737
6703 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
6705 $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
6706 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
6708 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) || \
6709 error "direct read failed"
6712 run_test 119b "Sparse directIO read must return actual read amount"
6714 test_119c() # bug 13099
6717 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
6718 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
6721 run_test 119c "Testing for direct read hitting hole"
6723 test_119d() # bug 15950
6725 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
6726 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
6728 $SETSTRIPE $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
6729 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
6730 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
6731 lctl set_param fail_loc=0x40d
6732 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
6735 cat $DIR/$tfile > /dev/null &
6736 lctl set_param fail_loc=0
6739 log "the DIO writes have completed, now wait for the reads (should not block very long)"
6741 [ -n "`ps h -p $pid_reads -o comm`" ] && \
6742 error "the read rpcs have not completed in 2s"
6744 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
6746 run_test 119d "The DIO path should try to send a new rpc once one is completed"
6749 test_mkdir -p $DIR/$tdir
6750 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6751 skip "no early lock cancel on server" && return 0
6752 lru_resize_disable mdc
6753 lru_resize_disable osc
6754 cancel_lru_locks mdc
6755 stat $DIR/$tdir > /dev/null
6756 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6757 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6758 test_mkdir $DIR/$tdir/d1
6759 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6760 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6761 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6762 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6763 lru_resize_enable mdc
6764 lru_resize_enable osc
6766 run_test 120a "Early Lock Cancel: mkdir test"
6769 test_mkdir -p $DIR/$tdir
6770 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6771 skip "no early lock cancel on server" && return 0
6772 lru_resize_disable mdc
6773 lru_resize_disable osc
6774 cancel_lru_locks mdc
6775 stat $DIR/$tdir > /dev/null
6776 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6777 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6779 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6780 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6781 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6782 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6783 lru_resize_enable mdc
6784 lru_resize_enable osc
6786 run_test 120b "Early Lock Cancel: create test"
6789 test_mkdir -p $DIR/$tdir
6790 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6791 skip "no early lock cancel on server" && return 0
6792 lru_resize_disable mdc
6793 lru_resize_disable osc
6794 test_mkdir -p $DIR/$tdir/d1 $DIR/$tdir/d2
6795 touch $DIR/$tdir/d1/f1
6796 cancel_lru_locks mdc
6797 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
6798 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6799 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6800 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
6801 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6802 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6803 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6804 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6805 lru_resize_enable mdc
6806 lru_resize_enable osc
6808 run_test 120c "Early Lock Cancel: link test"
6811 test_mkdir -p $DIR/$tdir
6812 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6813 skip "no early lock cancel on server" && return 0
6814 lru_resize_disable mdc
6815 lru_resize_disable osc
6817 cancel_lru_locks mdc
6818 stat $DIR/$tdir > /dev/null
6819 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6820 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6821 chmod a+x $DIR/$tdir
6822 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
6823 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
6824 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6825 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6826 lru_resize_enable mdc
6827 lru_resize_enable osc
6829 run_test 120d "Early Lock Cancel: setattr test"
6832 test_mkdir -p $DIR/$tdir
6833 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6834 skip "no early lock cancel on server" && return 0
6835 lru_resize_disable mdc
6836 lru_resize_disable osc
6837 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
6838 cancel_lru_locks mdc
6839 cancel_lru_locks osc
6840 dd if=$DIR/$tdir/f1 of=/dev/null
6841 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
6842 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6843 awk '/ldlm_cancel/ {print $2}'`
6844 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6845 awk '/ldlm_bl_callback/ {print $2}'`
6846 unlink $DIR/$tdir/f1
6847 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6848 awk '/ldlm_cancel/ {print $2}'`
6849 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6850 awk '/ldlm_bl_callback/ {print $2}'`
6851 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6852 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6853 lru_resize_enable mdc
6854 lru_resize_enable osc
6856 run_test 120e "Early Lock Cancel: unlink test"
6859 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6860 skip "no early lock cancel on server" && return 0
6861 test_mkdir -p $DIR/$tdir
6862 lru_resize_disable mdc
6863 lru_resize_disable osc
6864 test_mkdir -p $DIR/$tdir/d1 $DIR/$tdir/d2
6865 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
6866 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
6867 cancel_lru_locks mdc
6868 cancel_lru_locks osc
6869 dd if=$DIR/$tdir/d1/f1 of=/dev/null
6870 dd if=$DIR/$tdir/d2/f2 of=/dev/null
6871 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
6872 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6873 awk '/ldlm_cancel/ {print $2}'`
6874 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6875 awk '/ldlm_bl_callback/ {print $2}'`
6876 mv $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
6877 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6878 awk '/ldlm_cancel/ {print $2}'`
6879 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6880 awk '/ldlm_bl_callback/ {print $2}'`
6881 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
6882 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
6883 lru_resize_enable mdc
6884 lru_resize_enable osc
6886 run_test 120f "Early Lock Cancel: rename test"
6889 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
6890 skip "no early lock cancel on server" && return 0
6891 lru_resize_disable mdc
6892 lru_resize_disable osc
6894 echo create $count files
6895 test_mkdir -p $DIR/$tdir
6896 cancel_lru_locks mdc
6897 cancel_lru_locks osc
6900 can0=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6901 awk '/ldlm_cancel/ {print $2}'`
6902 blk0=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6903 awk '/ldlm_bl_callback/ {print $2}'`
6904 createmany -o $DIR/$tdir/f $count
6906 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6907 awk '/ldlm_cancel/ {print $2}'`
6908 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6909 awk '/ldlm_bl_callback/ {print $2}'`
6911 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
6912 echo rm $count files
6915 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
6916 awk '/ldlm_cancel/ {print $2}'`
6917 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
6918 awk '/ldlm_bl_callback/ {print $2}'`
6920 echo total: $count removes in $((t2-t1))
6921 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
6923 # wait for commitment of removal
6924 lru_resize_enable mdc
6925 lru_resize_enable osc
6927 run_test 120g "Early Lock Cancel: performance test"
6929 test_121() { #bug #10589
6931 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
6932 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
6933 lctl set_param fail_loc=0x310
6934 cancel_lru_locks osc > /dev/null
6935 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
6936 lctl set_param fail_loc=0
6937 [ "$reads" -eq "$writes" ] || error "read" $reads "blocks, must be" $writes
6939 run_test 121 "read cancel race ========="
6941 test_123a() { # was test 123, statahead(bug 11401)
6943 if [ -z "$(grep "processor.*: 1" /proc/cpuinfo)" ]; then
6944 log "testing on UP system. Performance may be not as good as expected."
6949 test_mkdir -p $DIR/$tdir
6950 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
6951 [ $NUMFREE -gt 100000 ] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
6953 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
6954 createmany -o $DIR/$tdir/$tfile $j $((i - j))
6956 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
6957 lctl set_param -n llite.*.statahead_max 0
6958 lctl get_param llite.*.statahead_max
6959 cancel_lru_locks mdc
6960 cancel_lru_locks osc
6962 time ls -l $DIR/$tdir | wc -l
6964 delta=$((etime - stime))
6965 log "ls $i files without statahead: $delta sec"
6966 lctl set_param llite.*.statahead_max=$max
6968 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
6969 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
6970 cancel_lru_locks mdc
6971 cancel_lru_locks osc
6973 time ls -l $DIR/$tdir | wc -l
6975 delta_sa=$((etime - stime))
6976 log "ls $i files with statahead: $delta_sa sec"
6977 lctl get_param -n llite.*.statahead_stats
6978 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
6980 [ $swrong -lt $ewrong ] && log "statahead was stopped, maybe too many locks held!"
6981 [ $delta -eq 0 -o $delta_sa -eq 0 ] && continue
6983 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
6984 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
6985 lctl set_param -n llite.*.statahead_max 0
6986 lctl get_param llite.*.statahead_max
6987 cancel_lru_locks mdc
6988 cancel_lru_locks osc
6990 time ls -l $DIR/$tdir | wc -l
6992 delta=$((etime - stime))
6993 log "ls $i files again without statahead: $delta sec"
6994 lctl set_param llite.*.statahead_max=$max
6995 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
6996 if [ $SLOWOK -eq 0 ]; then
6997 error "ls $i files is slower with statahead!"
6999 log "ls $i files is slower with statahead!"
7005 [ $delta -gt 20 ] && break
7006 [ $delta -gt 8 ] && MULT=$((50 / delta))
7007 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
7015 delta=$((etime - stime))
7016 log "rm -r $DIR/$tdir/: $delta seconds"
7018 lctl get_param -n llite.*.statahead_stats
7020 run_test 123a "verify statahead work"
7022 test_123b () { # statahead(bug 15027)
7023 test_mkdir -p $DIR/$tdir
7024 createmany -o $DIR/$tdir/$tfile-%d 1000
7026 cancel_lru_locks mdc
7027 cancel_lru_locks osc
7029 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
7030 lctl set_param fail_loc=0x80000803
7031 ls -lR $DIR/$tdir > /dev/null
7033 lctl set_param fail_loc=0x0
7034 lctl get_param -n llite.*.statahead_stats
7039 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
7042 [ -z "`lctl get_param -n mdc.*.connect_flags | grep lru_resize`" ] && \
7043 skip "no lru resize on server" && return 0
7045 test_mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
7047 log "create $NR files at $DIR/$tdir"
7048 createmany -o $DIR/$tdir/f $NR ||
7049 error "failed to create $NR files in $DIR/$tdir"
7051 cancel_lru_locks mdc
7052 ls -l $DIR/$tdir > /dev/null
7056 for VALUE in `lctl get_param ldlm.namespaces.*mdc-*.lru_size`; do
7057 local PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
7058 LRU_SIZE=$(lctl get_param -n $PARAM)
7059 if [ $LRU_SIZE -gt $(default_lru_size) ]; then
7060 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
7062 log "NS=$(basename $NSDIR)"
7067 if [ -z "$NSDIR" -o $LRU_SIZE -lt $(default_lru_size) ]; then
7068 skip "Not enough cached locks created!"
7075 # We know that lru resize allows one client to hold $LIMIT locks
7076 # for 10h. After that locks begin to be killed by client.
7078 local LIMIT=`lctl get_param -n $NSDIR.pool.limit`
7081 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
7082 # killing locks. Some time was spent for creating locks. This means
7083 # that up to the moment of sleep finish we must have killed some of
7084 # them (10-100 locks). This depends on how fast ther were created.
7085 # Many of them were touched in almost the same moment and thus will
7086 # be killed in groups.
7087 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
7089 # Use $LRU_SIZE_B here to take into account real number of locks
7090 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
7091 local LRU_SIZE_B=$LRU_SIZE
7093 local OLD_LVF=`lctl get_param -n $NSDIR.pool.lock_volume_factor`
7094 log "OLD_LVF=$OLD_LVF"
7095 lctl set_param -n $NSDIR.pool.lock_volume_factor $LVF
7097 # Let's make sure that we really have some margin. Client checks
7098 # cached locks every 10 sec.
7100 log "Sleep ${SLEEP} sec"
7102 while ((SEC<$SLEEP)); do
7106 LRU_SIZE=`lctl get_param -n $NSDIR/lru_size`
7110 lctl set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
7111 local LRU_SIZE_A=`lctl get_param -n $NSDIR.lru_size`
7113 [ $LRU_SIZE_B -gt $LRU_SIZE_A ] || {
7114 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
7115 unlinkmany $DIR/$tdir/f $NR
7119 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
7120 log "unlink $NR files at $DIR/$tdir"
7121 unlinkmany $DIR/$tdir/f $NR
7123 run_test 124a "lru resize ======================================="
7125 get_max_pool_limit()
7127 local limit=`lctl get_param -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit`
7130 if test $l -gt $max; then
7138 [ -z "`lctl get_param -n mdc.*.connect_flags | grep lru_resize`" ] && \
7139 skip "no lru resize on server" && return 0
7141 LIMIT=`get_max_pool_limit`
7143 NR=$(($(default_lru_size)*20))
7144 if [ $NR -gt $LIMIT ]; then
7145 log "Limit lock number by $LIMIT locks"
7148 lru_resize_disable mdc
7149 test_mkdir -p $DIR/$tdir/disable_lru_resize ||
7150 error "failed to create $DIR/$tdir/disable_lru_resize"
7152 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
7153 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
7154 cancel_lru_locks mdc
7157 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
7160 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
7163 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
7167 nolruresize_delta=$((etime-stime))
7168 log "ls -la time: $nolruresize_delta seconds"
7169 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
7170 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
7172 lru_resize_enable mdc
7173 test_mkdir -p $DIR/$tdir/enable_lru_resize ||
7174 error "failed to create $DIR/$tdir/enable_lru_resize"
7176 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
7177 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
7178 cancel_lru_locks mdc
7181 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
7184 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
7187 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
7191 lruresize_delta=$((etime-stime))
7192 log "ls -la time: $lruresize_delta seconds"
7193 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
7195 if [ $lruresize_delta -gt $nolruresize_delta ]; then
7196 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
7197 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
7198 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
7200 log "lru resize performs the same with no lru resize"
7202 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
7204 run_test 124b "lru resize (performance test) ======================="
7206 test_125() { # 13358
7207 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
7208 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
7209 test_mkdir -p $DIR/d125 || error "mkdir failed"
7210 $SETSTRIPE -S 65536 -c -1 $DIR/d125 || error "setstripe failed"
7211 setfacl -R -m u:bin:rwx $DIR/d125 || error "setfacl $DIR/d125 failed"
7212 ls -ld $DIR/d125 || error "cannot access $DIR/d125"
7214 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
7216 test_126() { # bug 12829/13455
7217 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
7218 [ "$UID" != 0 ] && skip_env "skipping $TESTNAME (must run as root)" && return
7219 $GSS && skip "must run as gss disabled" && return
7221 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
7222 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
7224 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
7226 run_test 126 "check that the fsgid provided by the client is taken into account"
7228 test_127a() { # bug 15521
7229 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
7230 $LCTL set_param osc.*.stats=0
7231 FSIZE=$((2048 * 1024))
7232 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
7233 cancel_lru_locks osc
7234 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
7236 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
7237 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
7238 echo "got $COUNT $NAME"
7239 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
7240 eval $NAME=$COUNT || error "Wrong proc format"
7243 read_bytes|write_bytes)
7244 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
7245 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
7246 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
7247 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
7248 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
7249 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
7250 error "sumsquare is too small: $SUMSQ"
7251 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
7252 error "sumsquare is too big: $SUMSQ"
7256 done < $DIR/${tfile}.tmp
7258 #check that we actually got some stats
7259 [ "$read_bytes" ] || error "Missing read_bytes stats"
7260 [ "$write_bytes" ] || error "Missing write_bytes stats"
7261 [ "$read_bytes" != 0 ] || error "no read done"
7262 [ "$write_bytes" != 0 ] || error "no write done"
7264 run_test 127a "verify the client stats are sane"
7266 test_127b() { # bug LU-333
7267 $LCTL set_param llite.*.stats=0
7268 FSIZE=65536 # sized fixed to match PAGE_SIZE for most clients
7269 # perform 2 reads and writes so MAX is different from SUM.
7270 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
7271 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
7272 cancel_lru_locks osc
7273 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
7274 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
7276 $LCTL get_param llite.*.stats | grep samples > $TMP/${tfile}.tmp
7277 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
7278 echo "got $COUNT $NAME"
7279 eval $NAME=$COUNT || error "Wrong proc format"
7283 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
7284 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
7285 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
7286 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
7289 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
7290 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
7291 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
7292 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
7296 done < $TMP/${tfile}.tmp
7298 #check that we actually got some stats
7299 [ "$read_bytes" ] || error "Missing read_bytes stats"
7300 [ "$write_bytes" ] || error "Missing write_bytes stats"
7301 [ "$read_bytes" != 0 ] || error "no read done"
7302 [ "$write_bytes" != 0 ] || error "no write done"
7304 run_test 127b "verify the llite client stats are sane"
7306 test_128() { # bug 15212
7308 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
7313 result=$(grep error $TMP/$tfile.log)
7315 [ -z "$result" ] || error "consecutive find's under interactive lfs failed"
7317 run_test 128 "interactive lfs for 2 consecutive find's"
7324 local LDPROC=/proc/fs/ldiskfs
7325 local facets=$(get_facets MDS)
7327 for facet in ${facets//,/ }; do
7328 canondev=$(ldiskfs_canon \
7329 *.$(convert_facet2label $facet).mntdev $facet)
7330 do_facet $facet "test -e $LDPROC/$canondev/max_dir_size" ||
7331 LDPROC=/sys/fs/ldiskfs
7332 do_facet $facet "echo $1 >$LDPROC/$canondev/max_dir_size"
7337 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
7338 skip "Only applicable to ldiskfs-based MDTs"
7341 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7347 test_mkdir -p $DIR/$tdir
7351 while [ ! $I -gt $((MAX * MDSCOUNT)) ]; do
7352 $MULTIOP $DIR/$tdir/$J Oc
7354 if [ $rc -eq $EFBIG ]; then
7356 echo "return code $rc received as expected"
7358 elif [ $rc -ne 0 ]; then
7360 error_exit "return code $rc received instead of expected $EFBIG"
7363 I=$(stat -c%s "$DIR/$tdir")
7367 error "exceeded dir size limit $MAX x $MDSCOUNT $((MAX * MDSCOUNT)) : $I bytes"
7369 run_test 129 "test directory size limit ========================"
7378 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7379 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
7382 trap cleanup_130 EXIT RETURN
7384 local fm_file=$DIR/$tfile
7385 $SETSTRIPE -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
7386 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
7387 error "dd failed for $fm_file"
7389 # LU-1795: test filefrag/FIEMAP once, even if unsupported
7390 filefrag -ves $fm_file
7392 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
7393 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
7394 [ $RC != 0 ] && error "filefrag $fm_file failed"
7396 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
7397 grep -v "ext:" | grep -v "found")
7398 lun=$($GETSTRIPE -i $fm_file)
7400 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
7403 for line in $filefrag_op
7405 frag_lun=`echo $line | cut -d: -f5`
7406 ext_len=`echo $line | cut -d: -f4`
7407 if (( $frag_lun != $lun )); then
7409 error "FIEMAP on 1-stripe file($fm_file) failed"
7412 (( tot_len += ext_len ))
7415 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
7417 error "FIEMAP on 1-stripe file($fm_file) failed;"
7423 echo "FIEMAP on single striped file succeeded"
7425 run_test 130a "FIEMAP (1-stripe file)"
7428 [ "$OSTCOUNT" -lt "2" ] &&
7429 skip_env "skipping FIEMAP on 2-stripe file test" && return
7431 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7432 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
7435 trap cleanup_130 EXIT RETURN
7437 local fm_file=$DIR/$tfile
7438 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
7439 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
7440 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
7442 dd if=/dev/zero of=$fm_file bs=1M count=2 ||
7443 error "dd failed on $fm_file"
7445 filefrag -ves $fm_file || error "filefrag $fm_file failed"
7446 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
7447 grep -v "ext:" | grep -v "found")
7449 last_lun=$(echo $filefrag_op | cut -d: -f5)
7454 for line in $filefrag_op
7456 frag_lun=`echo $line | cut -d: -f5`
7457 ext_len=`echo $line | cut -d: -f4`
7458 if (( $frag_lun != $last_lun )); then
7459 if (( tot_len != 1024 )); then
7461 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 256"
7468 (( tot_len += ext_len ))
7471 if (( num_luns != 2 || tot_len != 1024 )); then
7473 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
7479 echo "FIEMAP on 2-stripe file succeeded"
7481 run_test 130b "FIEMAP (2-stripe file)"
7484 [ "$OSTCOUNT" -lt "2" ] &&
7485 skip_env "skipping FIEMAP on 2-stripe file" && return
7487 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7488 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
7491 trap cleanup_130 EXIT RETURN
7493 local fm_file=$DIR/$tfile
7494 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
7495 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
7496 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
7498 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 || error "dd failed on $fm_file"
7500 filefrag -ves $fm_file || error "filefrag $fm_file failed"
7501 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
7503 last_lun=`echo $filefrag_op | cut -d: -f5`
7508 for line in $filefrag_op
7510 frag_lun=`echo $line | cut -d: -f5`
7511 ext_len=`echo $line | cut -d: -f4`
7512 if (( $frag_lun != $last_lun )); then
7513 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
7514 if (( logical != 512 )); then
7516 error "FIEMAP on $fm_file failed; returned logical start for lun $logical instead of 512"
7519 if (( tot_len != 512 )); then
7521 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
7528 (( tot_len += ext_len ))
7531 if (( num_luns != 2 || tot_len != 512 )); then
7533 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
7539 echo "FIEMAP on 2-stripe file with hole succeeded"
7541 run_test 130c "FIEMAP (2-stripe file with hole)"
7544 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping FIEMAP on N-stripe file test" && return
7546 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7547 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
7549 trap cleanup_130 EXIT RETURN
7551 local fm_file=$DIR/$tfile
7552 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file||error "setstripe on $fm_file"
7553 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
7554 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
7555 dd if=/dev/zero of=$fm_file bs=1M count=$OSTCOUNT || error "dd failed on $fm_file"
7557 filefrag -ves $fm_file || error "filefrag $fm_file failed"
7558 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
7560 last_lun=`echo $filefrag_op | cut -d: -f5`
7565 for line in $filefrag_op
7567 frag_lun=`echo $line | cut -d: -f5`
7568 ext_len=`echo $line | cut -d: -f4`
7569 if (( $frag_lun != $last_lun )); then
7570 if (( tot_len != 1024 )); then
7572 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
7579 (( tot_len += ext_len ))
7582 if (( num_luns != OSTCOUNT || tot_len != 1024 )); then
7584 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
7590 echo "FIEMAP on N-stripe file succeeded"
7592 run_test 130d "FIEMAP (N-stripe file)"
7595 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping continuation FIEMAP test" && return
7597 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7598 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
7600 trap cleanup_130 EXIT RETURN
7602 local fm_file=$DIR/$tfile
7603 $SETSTRIPE -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
7604 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
7605 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
7608 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
7609 for ((i = 0; i < $NUM_BLKS; i++))
7611 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
7614 filefrag -ves $fm_file || error "filefrag $fm_file failed"
7615 filefrag_op=`filefrag -ve $fm_file | grep -A 12000 "ext:" | grep -v "ext:" | grep -v "found"`
7617 last_lun=`echo $filefrag_op | cut -d: -f5`
7622 for line in $filefrag_op
7624 frag_lun=`echo $line | cut -d: -f5`
7625 ext_len=`echo $line | cut -d: -f4`
7626 if (( $frag_lun != $last_lun )); then
7627 if (( tot_len != $EXPECTED_LEN )); then
7629 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of $EXPECTED_LEN"
7636 (( tot_len += ext_len ))
7639 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
7641 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
7647 echo "FIEMAP with continuation calls succeeded"
7649 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
7651 # Test for writev/readv
7653 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 || \
7654 error "writev test failed"
7655 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 || \
7656 error "readv failed"
7659 run_test 131a "test iov's crossing stripe boundary for writev/readv"
7662 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 || \
7663 error "append writev test failed"
7664 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 || \
7665 error "append writev test failed"
7668 run_test 131b "test append writev"
7671 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
7674 run_test 131c "test read/write on file w/o objects"
7677 rwv -f $DIR/$tfile -w -n 1 1572864
7678 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
7679 if [ "$NOB" != 1572864 ]; then
7680 error "Short read filed: read $NOB bytes instead of 1572864"
7684 run_test 131d "test short read"
7687 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
7688 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
7689 error "read hitting hole failed"
7692 run_test 131e "test read hitting hole"
7697 for node in $(osts_nodes); do
7698 gl=$(do_node $node "$LCTL get_param -n ost.OSS.ost.stats" | awk '/'$token'/ {print $2}' | head -n 1)
7699 [ x$gl = x"" ] && gl=0
7700 gl_sum=$((gl_sum + gl))
7710 if [ x$som = x"enabled" ]; then
7711 [ $((gl2 - gl1)) -gt 0 ] && error "no glimpse RPC is expected"
7712 MOUNTOPT=`echo $MOUNTOPT | sed 's/som_preview//g'`
7713 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=disabled"
7715 [ $((gl2 - gl1)) -gt 0 ] || error "some glimpse RPC is expected"
7716 MOUNTOPT="$MOUNTOPT,som_preview"
7717 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=enabled"
7720 # do remount to make new mount-conf parameters actual
7727 test_132() { #1028, SOM
7728 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7729 local num=$(get_mds_dir $DIR)
7730 local mymds=mds${num}
7731 local MOUNTOPT_SAVE=$MOUNTOPT
7733 dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
7734 cancel_lru_locks osc
7736 som1=$(do_facet $mymds "$LCTL get_param mdt.*.som" | awk -F= ' {print $2}' | head -n 1)
7738 gl1=$(get_ost_param "ldlm_glimpse_enqueue")
7739 stat $DIR/$tfile >/dev/null
7740 gl2=$(get_ost_param "ldlm_glimpse_enqueue")
7741 echo "====> SOM is "$som1", "$((gl2 - gl1))" glimpse RPC occured"
7743 som_mode_switch $som1 $gl1 $gl2
7745 dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
7746 cancel_lru_locks osc
7748 som2=$(do_facet $mymds "$LCTL get_param mdt.*.som" | awk -F= ' {print $2}' | head -n 1)
7749 if [ $som1 == $som2 ]; then
7750 error "som is still "$som2
7751 if [ x$som2 = x"enabled" ]; then
7758 gl1=$(get_ost_param "ldlm_glimpse_enqueue")
7759 stat $DIR/$tfile >/dev/null
7760 gl2=$(get_ost_param "ldlm_glimpse_enqueue")
7761 echo "====> SOM is "$som2", "$((gl2 - gl1))" glimpse RPC occured"
7762 som_mode_switch $som2 $gl1 $gl2
7763 MOUNTOPT=$MOUNTOPT_SAVE
7765 run_test 132 "som avoids glimpse rpc"
7771 $SINGLEMDS) res=`do_facet $SINGLEMDS $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$2"`
7773 ost) res=`do_facet ost1 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$2"`
7775 *) error "Wrong argument $1" ;;
7778 count=`echo $res | awk '{print $2}'`
7779 [ -z "$res" ] && error "The counter for $2 on $1 was not incremented"
7780 # if the argument $3 is zero, it means any stat increment is ok.
7781 if [ $3 -gt 0 ] ; then
7782 [ $count -ne $3 ] && error "The $2 counter on $1 is wrong - expected $3"
7787 remote_ost_nodsh && skip "remote OST with nodsh" && return
7788 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7790 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
7791 { skip "MDS doesn't support rename stats"; return; }
7792 local testdir=$DIR/${tdir}/stats_testdir
7793 mkdir -p $DIR/${tdir}
7796 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
7797 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
7799 # verify mdt stats first.
7800 mkdir ${testdir} || error "mkdir failed"
7801 check_stats $SINGLEMDS "mkdir" 1
7802 touch ${testdir}/${tfile} || "touch failed"
7803 check_stats $SINGLEMDS "open" 1
7804 check_stats $SINGLEMDS "close" 1
7805 mknod ${testdir}/${tfile}-pipe p || "mknod failed"
7806 check_stats $SINGLEMDS "mknod" 1
7807 rm -f ${testdir}/${tfile}-pipe || "pipe remove failed"
7808 check_stats $SINGLEMDS "unlink" 1
7809 rm -f ${testdir}/${tfile} || error "file remove failed"
7810 check_stats $SINGLEMDS "unlink" 2
7812 # remove working dir and check mdt stats again.
7813 rmdir ${testdir} || error "rmdir failed"
7814 check_stats $SINGLEMDS "rmdir" 1
7816 local testdir1=$DIR/${tdir}/stats_testdir1
7818 mkdir -p ${testdir1}
7819 touch ${testdir1}/test1
7820 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
7821 check_stats $SINGLEMDS "crossdir_rename" 1
7823 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
7824 check_stats $SINGLEMDS "samedir_rename" 1
7828 run_test 133a "Verifying MDT stats ========================================"
7831 remote_ost_nodsh && skip "remote OST with nodsh" && return
7832 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7833 local testdir=$DIR/${tdir}/stats_testdir
7834 mkdir -p ${testdir} || error "mkdir failed"
7835 touch ${testdir}/${tfile} || "touch failed"
7836 cancel_lru_locks mdc
7839 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
7840 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
7842 # extra mdt stats verification.
7843 chmod 444 ${testdir}/${tfile} || error "chmod failed"
7844 check_stats $SINGLEMDS "setattr" 1
7845 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
7846 if [ $(lustre_version_code $SINGLEMDS) -ne $(version_code 2.2.0) ]
7848 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
7849 check_stats $SINGLEMDS "getattr" 1
7851 $LFS df || error "lfs failed"
7852 check_stats $SINGLEMDS "statfs" 1
7856 run_test 133b "Verifying extra MDT stats =================================="
7859 remote_ost_nodsh && skip "remote OST with nodsh" && return
7860 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7861 local testdir=$DIR/${tdir}/stats_testdir
7862 test_mkdir -p ${testdir} || error "mkdir failed"
7864 # verify obdfilter stats.
7865 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
7867 cancel_lru_locks osc
7868 wait_delete_completed
7871 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
7872 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
7874 dd if=/dev/zero of=${testdir}/${tfile} conv=notrunc bs=512k count=1 || error "dd failed"
7876 cancel_lru_locks osc
7877 check_stats ost "write" 1
7879 dd if=${testdir}/${tfile} of=/dev/null bs=1k count=1 || error "dd failed"
7880 check_stats ost "read" 1
7882 > ${testdir}/${tfile} || error "truncate failed"
7883 check_stats ost "punch" 1
7885 rm -f ${testdir}/${tfile} || error "file remove failed"
7886 wait_delete_completed
7887 check_stats ost "destroy" 1
7891 run_test 133c "Verifying OST stats ========================================"
7898 while [ $value -ge 2 ]; do
7903 if [ $orig -gt $order ]; then
7911 local size=('K' 'M' 'G' 'T');
7913 local size_string=$value
7915 while [ $value -ge 1024 ]; do
7916 if [ $i -gt 3 ]; then
7917 #T is the biggest unit we get here, if that is bigger,
7919 size_string=${value}T
7922 value=$((value >> 10))
7923 if [ $value -lt 1024 ]; then
7924 size_string=${value}${size[$i]}
7935 local context=${2:-.}
7936 local sample=$(do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats |
7938 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
7943 remote_ost_nodsh && skip "remote OST with nodsh" && return
7944 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7945 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
7946 { skip "MDS doesn't support rename stats"; return; }
7948 local testdir1=$DIR/${tdir}/stats_testdir1
7949 local testdir2=$DIR/${tdir}/stats_testdir2
7951 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
7953 test_mkdir -p ${testdir1} || error "mkdir failed"
7954 test_mkdir -p ${testdir2} || error "mkdir failed"
7956 createmany -o $testdir1/test 512 || error "createmany failed"
7958 # check samedir rename size
7959 mv ${testdir1}/test0 ${testdir1}/test_0
7961 local testdir1_size=$(ls -l $DIR/${tdir} |
7962 awk '/stats_testdir1/ {print $5}')
7963 local testdir2_size=$(ls -l $DIR/${tdir} |
7964 awk '/stats_testdir2/ {print $5}')
7966 testdir1_size=$(order_2 $testdir1_size)
7967 testdir2_size=$(order_2 $testdir2_size)
7969 testdir1_size=$(size_in_KMGT $testdir1_size)
7970 testdir2_size=$(size_in_KMGT $testdir2_size)
7972 echo "source rename dir size: ${testdir1_size}"
7973 echo "target rename dir size: ${testdir2_size}"
7975 local cmd="do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats"
7976 eval $cmd || error "$cmd failed"
7977 local samedir=$($cmd | grep 'same_dir')
7978 local same_sample=$(get_rename_size $testdir1_size)
7979 [ -z "$samedir" ] && error "samedir_rename_size count error"
7980 [ "$same_sample" -eq 1 ] || error "samedir_rename_size error $same_sample"
7981 echo "Check same dir rename stats success"
7983 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
7985 # check crossdir rename size
7986 mv ${testdir1}/test_0 ${testdir2}/test_0
7988 testdir1_size=$(ls -l $DIR/${tdir} |
7989 awk '/stats_testdir1/ {print $5}')
7990 testdir2_size=$(ls -l $DIR/${tdir} |
7991 awk '/stats_testdir2/ {print $5}')
7993 testdir1_size=$(order_2 $testdir1_size)
7994 testdir2_size=$(order_2 $testdir2_size)
7996 testdir1_size=$(size_in_KMGT $testdir1_size)
7997 testdir2_size=$(size_in_KMGT $testdir2_size)
7999 echo "source rename dir size: ${testdir1_size}"
8000 echo "target rename dir size: ${testdir2_size}"
8002 eval $cmd || error "$cmd failed"
8003 local crossdir=$($cmd | grep 'crossdir')
8004 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
8005 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
8006 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
8007 [ "$src_sample" -eq 1 ] || error "crossdir_rename_size error $src_sample"
8008 [ "$tgt_sample" -eq 1 ] || error "crossdir_rename_size error $tgt_sample"
8009 echo "Check cross dir rename stats success"
8012 run_test 133d "Verifying rename_stats ========================================"
8014 test_140() { #bug-17379
8015 test_mkdir -p $DIR/$tdir || error "Creating dir $DIR/$tdir"
8016 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
8017 cp /usr/bin/stat . || error "Copying stat to $DIR/$tdir"
8019 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
8020 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
8022 while i=`expr $i + 1`; do
8023 test_mkdir -p $i || error "Creating dir $i"
8024 cd $i || error "Changing to $i"
8025 ln -s ../stat stat || error "Creating stat symlink"
8026 # Read the symlink until ELOOP present,
8027 # not LBUGing the system is considered success,
8028 # we didn't overrun the stack.
8029 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
8031 if [ $ret -eq 40 ]; then
8034 error "Open stat symlink"
8040 echo "The symlink depth = $i"
8041 [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 -o $i -eq 40 ] ||
8042 error "Invalid symlink depth"
8044 # Test recursive symlink
8045 ln -s symlink_self symlink_self
8046 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
8047 echo "open symlink_self returns $ret"
8048 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
8050 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
8053 local TF="$TMP/$tfile"
8055 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
8057 cancel_lru_locks osc
8058 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
8059 remount_client $MOUNT
8061 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
8064 $TRUNCATE $DIR/$tfile 6000
8065 cancel_lru_locks osc
8066 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
8069 echo "12345" >>$DIR/$tfile
8070 cancel_lru_locks osc
8071 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
8074 echo "12345" >>$DIR/$tfile
8075 cancel_lru_locks osc
8076 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
8081 run_test 150 "truncate/append tests"
8083 function roc_hit() {
8084 local list=$(comma_list $(osts_nodes))
8086 echo $(get_obdfilter_param $list '' stats |
8087 awk '/'cache_hit'/ {sum+=$2} END {print sum}')
8090 function set_cache() {
8093 if [ "$2" == "off" ]; then
8096 local list=$(comma_list $(osts_nodes))
8097 set_obdfilter_param $list '' $1_cache_enable $on
8099 cancel_lru_locks osc
8103 remote_ost_nodsh && skip "remote OST with nodsh" && return
8106 local list=$(comma_list $(osts_nodes))
8108 # check whether obdfilter is cache capable at all
8109 if ! get_obdfilter_param $list '' read_cache_enable >/dev/null; then
8110 echo "not cache-capable obdfilter"
8114 # check cache is enabled on all obdfilters
8115 if get_obdfilter_param $list '' read_cache_enable | grep 0; then
8116 echo "oss cache is disabled"
8120 set_obdfilter_param $list '' writethrough_cache_enable 1
8122 # pages should be in the case right after write
8123 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES || error "dd failed"
8124 local BEFORE=`roc_hit`
8125 cancel_lru_locks osc
8126 cat $DIR/$tfile >/dev/null
8127 local AFTER=`roc_hit`
8128 if ! let "AFTER - BEFORE == CPAGES"; then
8129 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
8132 # the following read invalidates the cache
8133 cancel_lru_locks osc
8134 set_obdfilter_param $list '' read_cache_enable 0
8135 cat $DIR/$tfile >/dev/null
8137 # now data shouldn't be found in the cache
8139 cancel_lru_locks osc
8140 cat $DIR/$tfile >/dev/null
8142 if let "AFTER - BEFORE != 0"; then
8143 error "IN CACHE: before: $BEFORE, after: $AFTER"
8146 set_obdfilter_param $list '' read_cache_enable 1
8149 run_test 151 "test cache on oss and controls ==============================="
8152 local TF="$TMP/$tfile"
8154 # simulate ENOMEM during write
8155 #define OBD_FAIL_OST_NOMEM 0x226
8156 lctl set_param fail_loc=0x80000226
8157 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
8159 sync || error "sync failed"
8160 lctl set_param fail_loc=0
8162 # discard client's cache
8163 cancel_lru_locks osc
8165 # simulate ENOMEM during read
8166 lctl set_param fail_loc=0x80000226
8167 cmp $TF $DIR/$tfile || error "cmp failed"
8168 lctl set_param fail_loc=0
8172 run_test 152 "test read/write with enomem ============================"
8175 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
8177 run_test 153 "test if fdatasync does not crash ======================="
8180 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
8181 { skip "Need MDS version at least 2.2.51"; return 0; }
8183 cp /etc/hosts $DIR/$tfile
8185 fid=$($LFS path2fid $DIR/$tfile)
8187 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
8189 ffid=$DIR/.lustre/fid/$fid
8191 echo "stat fid $fid"
8192 stat $ffid > /dev/null || error "stat $ffid failed."
8193 echo "touch fid $fid"
8194 touch $ffid || error "touch $ffid failed."
8195 echo "write to fid $fid"
8196 cat /etc/hosts > $ffid || error "write $ffid failed."
8197 echo "read fid $fid"
8198 diff /etc/hosts $ffid || error "read $ffid failed."
8199 echo "append write to fid $fid"
8200 cat /etc/hosts >> $ffid || error "append write $ffid failed."
8201 echo "rename fid $fid"
8202 mv $ffid $DIR/$tfile.1 && error "rename $ffid to $tfile.1 should fail."
8204 mv $DIR/$tfile.1 $ffid && error "rename $tfile.1 to $ffid should fail."
8206 echo "truncate fid $fid"
8207 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
8208 echo "link fid $fid"
8209 ln -f $ffid $DIR/tfile.lnk || error "link $ffid failed."
8210 if [ -n $(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl) ]; then
8211 echo "setfacl fid $fid"
8212 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
8213 echo "getfacl fid $fid"
8214 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
8216 echo "unlink fid $fid"
8217 unlink $DIR/.lustre/fid/$fid && error "unlink $ffid should fail."
8218 echo "mknod fid $fid"
8219 mknod $ffid c 1 3 && error "mknod $ffid should fail."
8221 fid=[0xf00000400:0x1:0x0]
8222 ffid=$DIR/.lustre/fid/$fid
8224 echo "stat non-exist fid $fid"
8225 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
8226 echo "write to non-exist fid $fid"
8227 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
8228 echo "link new fid $fid"
8229 ln $DIR/$tfile $ffid && error "link $ffid should fail."
8231 test_mkdir -p $DIR/$tdir
8232 touch $DIR/$tdir/$tfile
8233 fid=$($LFS path2fid $DIR/$tdir)
8235 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
8237 ffid=$DIR/.lustre/fid/$fid
8240 ls $ffid > /dev/null || error "ls $ffid failed."
8241 echo "touch $fid/$tfile.1"
8242 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
8244 echo "touch $DIR/.lustre/fid/$tfile"
8245 touch $DIR/.lustre/fid/$tfile && \
8246 error "touch $DIR/.lustre/fid/$tfile should fail."
8248 echo "setxattr to $DIR/.lustre/fid"
8249 setfattr -n trusted.name1 -v value1 $DIR/.lustre/fid &&
8250 error "setxattr should fail."
8252 echo "listxattr for $DIR/.lustre/fid"
8253 getfattr -d -m "^trusted" $DIR/.lustre/fid &&
8254 error "listxattr should fail."
8256 echo "delxattr from $DIR/.lustre/fid"
8257 setfattr -x trusted.name1 $DIR/.lustre/fid &&
8258 error "delxattr should fail."
8260 echo "touch invalid fid: $DIR/.lustre/fid/[0x200000400:0x2:0x3]"
8261 touch $DIR/.lustre/fid/[0x200000400:0x2:0x3] &&
8262 error "touch invalid fid should fail."
8264 echo "touch non-normal fid: $DIR/.lustre/fid/[0x1:0x2:0x0]"
8265 touch $DIR/.lustre/fid/[0x1:0x2:0x0] &&
8266 error "touch non-normal fid should fail."
8268 echo "rename $tdir to $DIR/.lustre/fid"
8269 mrename $DIR/$tdir $DIR/.lustre/fid &&
8270 error "rename to $DIR/.lustre/fid should fail."
8272 echo "rename .lustre to itself"
8273 fid=$($LFS path2fid $DIR)
8274 mrename $DIR/.lustre $DIR/.lustre/fid/$fid/.lustre &&
8275 error "rename .lustre to itself should fail."
8277 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $DIR/$tfile-2
8278 fid=$($LFS path2fid $DIR/$tfile-2)
8279 echo "cp /etc/passwd $DIR/.lustre/fid/$fid"
8280 cp /etc/passwd $DIR/.lustre/fid/$fid &&
8281 error "create lov data thru .lustre should fail."
8282 echo "cp /etc/passwd $DIR/$tfile-2"
8283 cp /etc/passwd $DIR/$tfile-2 || error "copy to $DIR/$tfile-2 failed."
8284 echo "diff /etc/passwd $DIR/.lustre/fid/$fid"
8285 diff /etc/passwd $DIR/.lustre/fid/$fid ||
8286 error "diff /etc/passwd $DIR/.lustre/fid/$fid failed."
8288 echo "Open-by-FID succeeded"
8290 run_test 154 "Open-by-FID"
8292 test_155_small_load() {
8293 local temp=$TMP/$tfile
8294 local file=$DIR/$tfile
8296 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
8297 error "dd of=$temp bs=6096 count=1 failed"
8299 cancel_lru_locks osc
8300 cmp $temp $file || error "$temp $file differ"
8302 $TRUNCATE $temp 6000
8303 $TRUNCATE $file 6000
8304 cmp $temp $file || error "$temp $file differ (truncate1)"
8306 echo "12345" >>$temp
8307 echo "12345" >>$file
8308 cmp $temp $file || error "$temp $file differ (append1)"
8310 echo "12345" >>$temp
8311 echo "12345" >>$file
8312 cmp $temp $file || error "$temp $file differ (append2)"
8318 test_155_big_load() {
8319 remote_ost_nodsh && skip "remote OST with nodsh" && return
8320 local temp=$TMP/$tfile
8321 local file=$DIR/$tfile
8324 local cache_size=$(do_facet ost$((MAXI+1)) \
8325 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
8326 local large_file_size=$((cache_size * 2))
8328 echo "OSS cache size: $cache_size KB"
8329 echo "Large file size: $large_file_size KB"
8331 [ $MAXV -le $large_file_size ] && \
8332 skip_env "max available OST size needs > $large_file_size KB" && \
8335 $SETSTRIPE $file -c 1 -i $MAXI || error "$SETSTRIPE $file failed"
8337 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k || \
8338 error "dd of=$temp bs=$large_file_size count=1k failed"
8341 cancel_lru_locks osc
8342 cmp $temp $file || error "$temp $file differ"
8350 set_cache writethrough on
8353 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
8357 set_cache writethrough off
8360 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
8364 set_cache writethrough on
8367 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
8371 set_cache writethrough off
8374 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
8378 set_cache writethrough on
8381 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
8385 set_cache writethrough off
8388 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
8392 set_cache writethrough on
8395 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
8399 set_cache writethrough off
8402 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
8408 local file="$DIR/$tfile"
8410 [ "$(facet_fstype ost1)" = "zfs" ] &&
8411 skip "LU-1956/LU-2261: stats unimplemented on OSD ZFS" &&
8414 log "Turn on read and write cache"
8416 set_cache writethrough on
8418 log "Write data and read it back."
8419 log "Read should be satisfied from the cache."
8420 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
8422 cancel_lru_locks osc
8423 cat $file >/dev/null
8425 if ! let "AFTER - BEFORE == CPAGES"; then
8426 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
8428 log "cache hits:: before: $BEFORE, after: $AFTER"
8431 log "Read again; it should be satisfied from the cache."
8433 cancel_lru_locks osc
8434 cat $file >/dev/null
8436 if ! let "AFTER - BEFORE == CPAGES"; then
8437 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
8439 log "cache hits:: before: $BEFORE, after: $AFTER"
8443 log "Turn off the read cache and turn on the write cache"
8445 set_cache writethrough on
8447 log "Read again; it should be satisfied from the cache."
8449 cancel_lru_locks osc
8450 cat $file >/dev/null
8452 if ! let "AFTER - BEFORE == CPAGES"; then
8453 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
8455 log "cache hits:: before: $BEFORE, after: $AFTER"
8458 log "Read again; it should not be satisfied from the cache."
8460 cancel_lru_locks osc
8461 cat $file >/dev/null
8463 if ! let "AFTER - BEFORE == 0"; then
8464 error "IN CACHE: before: $BEFORE, after: $AFTER"
8466 log "cache hits:: before: $BEFORE, after: $AFTER"
8469 log "Write data and read it back."
8470 log "Read should be satisfied from the cache."
8471 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
8473 cancel_lru_locks osc
8474 cat $file >/dev/null
8476 if ! let "AFTER - BEFORE == CPAGES"; then
8477 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
8479 log "cache hits:: before: $BEFORE, after: $AFTER"
8482 log "Read again; it should not be satisfied from the cache."
8484 cancel_lru_locks osc
8485 cat $file >/dev/null
8487 if ! let "AFTER - BEFORE == 0"; then
8488 error "IN CACHE: before: $BEFORE, after: $AFTER"
8490 log "cache hits:: before: $BEFORE, after: $AFTER"
8494 log "Turn off read and write cache"
8496 set_cache writethrough off
8498 log "Write data and read it back"
8499 log "It should not be satisfied from the cache."
8501 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
8502 cancel_lru_locks osc
8504 cat $file >/dev/null
8506 if ! let "AFTER - BEFORE == 0"; then
8507 error_ignore 20762 "IN CACHE: before: $BEFORE, after: $AFTER"
8509 log "cache hits:: before: $BEFORE, after: $AFTER"
8513 log "Turn on the read cache and turn off the write cache"
8515 set_cache writethrough off
8517 log "Write data and read it back"
8518 log "It should not be satisfied from the cache."
8520 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
8522 cancel_lru_locks osc
8523 cat $file >/dev/null
8525 if ! let "AFTER - BEFORE == 0"; then
8526 error_ignore 20762 "IN CACHE: before: $BEFORE, after: $AFTER"
8528 log "cache hits:: before: $BEFORE, after: $AFTER"
8531 log "Read again; it should be satisfied from the cache."
8533 cancel_lru_locks osc
8534 cat $file >/dev/null
8536 if ! let "AFTER - BEFORE == CPAGES"; then
8537 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
8539 log "cache hits:: before: $BEFORE, after: $AFTER"
8544 run_test 156 "Verification of tunables ============================"
8548 if [ $MDSCOUNT -gt 1 ]; then
8549 error_ignore 17935 $*
8557 MASK=$(do_facet $SINGLEMDS $LCTL get_param mdd.$MDT0.changelog_mask |\
8560 if [ $MASK -eq 1 ]; then
8561 do_facet $SINGLEMDS $LCTL set_param mdd.$MDT0.changelog_mask="-$1"
8563 do_facet $SINGLEMDS $LCTL set_param mdd.$MDT0.changelog_mask="+$1"
8568 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8569 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
8570 { skip "Need MDS version at least 2.2.0"; return; }
8571 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
8572 echo "Registered as changelog user $USER"
8573 do_facet $SINGLEMDS $LCTL get_param -n mdd.$MDT0.changelog_users | \
8574 grep -q $USER || error "User $USER not found in changelog_users"
8577 test_mkdir -p $DIR/$tdir/pics/2008/zachy
8578 touch $DIR/$tdir/pics/2008/zachy/timestamp
8579 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
8580 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
8581 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
8582 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
8583 rm $DIR/$tdir/pics/desktop.jpg
8585 $LFS changelog $MDT0 | tail -5
8587 echo "verifying changelog mask"
8588 changelog_chmask "MKDIR"
8589 changelog_chmask "CLOSE"
8591 test_mkdir -p $DIR/$tdir/pics/zach/sofia
8592 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
8594 changelog_chmask "MKDIR"
8595 changelog_chmask "CLOSE"
8597 test_mkdir -p $DIR/$tdir/pics/2008/sofia
8598 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
8600 $LFS changelog $MDT0
8601 MKDIRS=$($LFS changelog $MDT0 | tail -5 | grep -c "MKDIR")
8602 CLOSES=$($LFS changelog $MDT0 | tail -5 | grep -c "CLOSE")
8603 [ $MKDIRS -eq 1 ] || err17935 "MKDIR changelog mask count $DIRS != 1"
8604 [ $CLOSES -eq 1 ] || err17935 "CLOSE changelog mask count $DIRS != 1"
8607 echo "verifying target fid"
8608 fidc=$($LFS changelog $MDT0 | grep timestamp | grep "CREAT" | \
8609 tail -1 | awk '{print $6}')
8610 fidf=$($LFS path2fid $DIR/$tdir/pics/zach/timestamp)
8611 [ "$fidc" == "t=$fidf" ] || \
8612 err17935 "fid in changelog $fidc != file fid $fidf"
8613 echo "verifying parent fid"
8614 fidc=$($LFS changelog $MDT0 | grep timestamp | grep "CREAT" | \
8615 tail -1 | awk '{print $7}')
8616 fidf=$($LFS path2fid $DIR/$tdir/pics/zach)
8617 [ "$fidc" == "p=$fidf" ] || \
8618 err17935 "pfid in changelog $fidc != dir fid $fidf"
8620 USER_REC1=$(do_facet $SINGLEMDS $LCTL get_param -n \
8621 mdd.$MDT0.changelog_users | grep $USER | awk '{print $2}')
8622 $LFS changelog_clear $MDT0 $USER $(($USER_REC1 + 5))
8623 USER_REC2=$(do_facet $SINGLEMDS $LCTL get_param -n \
8624 mdd.$MDT0.changelog_users | grep $USER | awk '{print $2}')
8625 echo "verifying user clear: $(( $USER_REC1 + 5 )) == $USER_REC2"
8626 [ $USER_REC2 == $(($USER_REC1 + 5)) ] || \
8627 err17935 "user index should be $(($USER_REC1 + 5)); is $USER_REC2"
8629 MIN_REC=$(do_facet $SINGLEMDS $LCTL get_param mdd.$MDT0.changelog_users | \
8630 awk 'min == "" || $2 < min {min = $2}; END {print min}')
8631 FIRST_REC=$($LFS changelog $MDT0 | head -1 | awk '{print $1}')
8632 echo "verifying min purge: $(( $MIN_REC + 1 )) == $FIRST_REC"
8633 [ $FIRST_REC == $(($MIN_REC + 1)) ] || \
8634 err17935 "first index should be $(($MIN_REC + 1)); is $FIRST_REC"
8636 echo "verifying user deregister"
8637 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
8638 do_facet $SINGLEMDS $LCTL get_param -n mdd.$MDT0.changelog_users | \
8639 grep -q $USER && error "User $USER still found in changelog_users"
8641 USERS=$(( $(do_facet $SINGLEMDS $LCTL get_param -n \
8642 mdd.$MDT0.changelog_users | wc -l) - 2 ))
8643 if [ $USERS -eq 0 ]; then
8644 LAST_REC1=$(do_facet $SINGLEMDS $LCTL get_param -n \
8645 mdd.$MDT0.changelog_users | head -1 | awk '{print $3}')
8646 touch $DIR/$tdir/chloe
8647 LAST_REC2=$(do_facet $SINGLEMDS $LCTL get_param -n \
8648 mdd.$MDT0.changelog_users | head -1 | awk '{print $3}')
8649 echo "verify changelogs are off if we were the only user: $LAST_REC1 == $LAST_REC2"
8650 [ $LAST_REC1 == $LAST_REC2 ] || error "changelogs not off"
8652 echo "$USERS other changelog users; can't verify off"
8655 run_test 160 "changelog sanity"
8658 test_mkdir -p $DIR/$tdir
8659 cp /etc/hosts $DIR/$tdir/$tfile
8660 test_mkdir $DIR/$tdir/foo1
8661 test_mkdir $DIR/$tdir/foo2
8662 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
8663 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
8664 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
8665 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
8666 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[')
8667 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
8668 $LFS fid2path $DIR $FID
8669 err17935 "bad link ea"
8672 rm $DIR/$tdir/foo2/zachary
8674 rm $DIR/$tdir/foo2/thor
8676 rm $DIR/$tdir/$tfile
8678 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
8679 if [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ]
8681 $LFS fid2path $DIR $FID
8682 err17935 "bad link rename"
8684 rm $DIR/$tdir/foo2/maggie
8687 local longname=filename_avg_len_is_thirty_two_
8688 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 || \
8689 error "failed to hardlink many files"
8690 links=$($LFS fid2path $DIR $FID | wc -l)
8691 echo -n "${links}/1000 links in link EA"
8692 [ ${links} -gt 60 ] || err17935 "expected at least 60 links in link EA"
8693 unlinkmany $DIR/$tdir/foo2/$longname 1000 || \
8694 error "failed to unlink many hardlinks"
8696 run_test 161 "link ea sanity"
8703 local path=$(${LFS} fid2path $*)
8706 if [ $RC -ne 0 ]; then
8707 err17935 "path looked up of $expected failed. Error $RC"
8709 elif [ "${path}" != "${expected}" ]; then
8710 err17935 "path looked up \"${path}\" instead of \"${expected}\""
8713 echo "fid $fid resolves to path $path (expected $expected)"
8717 # Make changes to filesystem
8718 test_mkdir -p $DIR/$tdir/d2
8719 touch $DIR/$tdir/d2/$tfile
8720 touch $DIR/$tdir/d2/x1
8721 touch $DIR/$tdir/d2/x2
8722 test_mkdir -p $DIR/$tdir/d2/a/b/c
8723 test_mkdir -p $DIR/$tdir/d2/p/q/r
8725 FID=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
8726 check_path "$tdir/d2/$tfile" $FSNAME $FID --link 0
8729 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
8730 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
8731 check_path "$tdir/d2/p/q/r/slink" $FSNAME $FID --link 0
8733 # softlink to wrong file
8734 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
8735 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
8736 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME $FID --link 0
8739 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
8740 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
8741 FID=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
8742 # fid2path dir/fsname should both work
8743 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 1
8744 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR $FID --link 0
8746 # hardlink count: check that there are 2 links
8747 # Doesnt work with CMD yet: 17935
8748 ${LFS} fid2path $DIR $FID | wc -l | grep -q 2 || \
8749 err17935 "expected 2 links"
8751 # hardlink indexing: remove the first link
8752 rm $DIR/$tdir/d2/p/q/r/hlink
8753 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 0
8757 run_test 162 "path lookup sanity"
8760 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8761 copytool --test $FSNAME || { skip "copytool not runnable: $?" && return; }
8764 local uuid=$($LCTL get_param -n mdc.${FSNAME}-MDT0000-mdc-*.uuid)
8765 # this proc file is temporary and linux-only
8766 do_facet $SINGLEMDS lctl set_param mdt.${FSNAME}-MDT0000.mdccomm=$uuid ||\
8767 error "kernel->userspace send failed"
8770 run_test 163 "kernel <-> userspace comms"
8773 # do directio so as not to populate the page cache
8774 log "creating a 10 Mb file"
8775 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
8776 log "starting reads"
8777 dd if=$DIR/$tfile of=/dev/null bs=4096 &
8778 log "truncating the file"
8779 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
8781 kill %+ || true # reads might have finished
8782 echo "wait until dd is finished"
8784 log "removing the temporary file"
8785 rm -rf $DIR/$tfile || error "tmp file removal failed"
8787 run_test 169 "parallel read and truncate should not deadlock"
8790 $LCTL clear # bug 18514
8791 $LCTL debug_daemon start $TMP/${tfile}_log_good
8793 $LCTL debug_daemon stop
8794 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
8795 error "sed failed to read log_good"
8797 $LCTL debug_daemon start $TMP/${tfile}_log_good
8799 $LCTL debug_daemon stop
8801 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
8802 error "lctl df log_bad failed"
8804 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
8805 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
8807 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
8808 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
8810 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
8811 error "bad_line good_line1 good_line2 are empty"
8813 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
8814 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
8815 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
8817 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
8818 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
8819 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
8821 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
8822 error "bad_line_new good_line_new are empty"
8824 local expected_good=$((good_line1 + good_line2*2))
8826 rm -f $TMP/${tfile}*
8827 # LU-231, short malformed line may not be counted into bad lines
8828 if [ $bad_line -ne $bad_line_new ] &&
8829 [ $bad_line -ne $((bad_line_new - 1)) ]; then
8830 error "expected $bad_line bad lines, but got $bad_line_new"
8834 if [ $expected_good -ne $good_line_new ]; then
8835 error "expected $expected_good good lines, but got $good_line_new"
8840 run_test 170 "test lctl df to handle corrupted log ====================="
8842 test_171() { # bug20592
8843 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
8844 $LCTL set_param fail_loc=0x50e
8845 $LCTL set_param fail_val=3000
8846 multiop_bg_pause $DIR/$tfile O_s || true
8848 kill -USR1 $MULTIPID
8852 if dmesg | grep "recursive fault"; then
8853 error "caught a recursive fault"
8855 $LCTL set_param fail_loc=0
8858 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
8860 # it would be good to share it with obdfilter-survey/libecho code
8861 setup_obdecho_osc () {
8864 local obdfilter_name=$2
8865 echo "Creating new osc for $obdfilter_name on $ost_nid"
8866 # make sure we can find loopback nid
8867 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
8869 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
8870 ${obdfilter_name}_osc_UUID || rc=2; }
8871 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
8872 ${obdfilter_name}_UUID $ost_nid || rc=3; }
8876 cleanup_obdecho_osc () {
8877 local obdfilter_name=$1
8878 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
8879 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
8883 obdecho_create_test() {
8888 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
8889 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
8891 if [ $rc -eq 0 ]; then
8892 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
8893 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
8895 echo "New object id is $id"
8896 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec test_brw 10 w v 64 $id" ||
8898 [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec " \
8899 "cleanup" || rc=5; }
8900 [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec " \
8902 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
8907 remote_ost_nodsh && skip "remote OST with nodsh" && return
8911 if ! module_loaded obdecho; then
8912 load_module obdecho/obdecho
8916 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
8917 local host=$(lctl get_param -n osc.$osc.import |
8918 awk '/current_connection:/ {print $2}' )
8919 local target=$(lctl get_param -n osc.$osc.import |
8920 awk '/target:/ {print $2}' )
8921 target=${target%_UUID}
8923 [[ -n $target ]] && { setup_obdecho_osc $host $target || rc=1; } || rc=1
8924 [ $rc -eq 0 ] && { obdecho_create_test ${target}_osc client || rc=2; }
8925 [[ -n $target ]] && cleanup_obdecho_osc $target
8926 [ $rmmod_local -eq 1 ] && rmmod obdecho
8929 run_test 180a "test obdecho on osc"
8932 remote_ost_nodsh && skip "remote OST with nodsh" && return
8934 local rmmod_remote=0
8936 do_facet ost1 "lsmod | grep -q obdecho || " \
8937 "{ insmod ${LUSTRE}/obdecho/obdecho.ko || " \
8938 "modprobe obdecho; }" && rmmod_remote=1
8939 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ {print $4;exit}')
8940 [[ -n $target ]] && { obdecho_create_test $target ost1 || rc=1; }
8941 [ $rmmod_remote -eq 1 ] && do_facet ost1 "rmmod obdecho"
8944 run_test 180b "test obdecho directly on obdfilter"
8946 test_181() { # bug 22177
8947 test_mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
8948 # create enough files to index the directory
8949 createmany -o $DIR/$tdir/foobar 4000
8950 # print attributes for debug purpose
8953 multiop_bg_pause $DIR/$tdir D_Sc || return 1
8955 # remove the files & current working dir
8956 unlinkmany $DIR/$tdir/foobar 4000
8958 kill -USR1 $MULTIPID
8960 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
8963 run_test 181 "Test open-unlinked dir ========================"
8966 # disable MDC RPC lock wouldn't crash client
8970 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
8971 #define OBD_FAIL_MDC_RPCS_SEM 0x804
8972 $LCTL set_param fail_loc=0x804
8974 for (( i=0; i < $tcount; i++ )) ; do
8976 createmany -o $DIR/$tdir/$i/f- $fcount &
8980 for (( i=0; i < $tcount; i++ )) ; do
8981 unlinkmany $DIR/$tdir/$i/f- $fcount &
8987 $LCTL set_param fail_loc=0
8989 run_test 182 "Disable MDC RPCs semaphore wouldn't crash client ================"
8991 test_183() { # LU-2275
8992 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
8993 echo aaa > $DIR/$tdir/$tfile
8995 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
8996 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
8998 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
8999 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
9001 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
9003 # Flush negative dentry cache
9004 touch $DIR/$tdir/$tfile
9006 # We are not checking for any leaked references here, they'll
9007 # become evident next time we do cleanup with module unload.
9010 run_test 183 "No crash or request leak in case of strange dispositions ========"
9013 check_file_in_pool()
9018 local res=$($GETSTRIPE $file | grep 0x | cut -f2)
9021 for t in $tlist ; do
9022 [ "$i" -eq "$t" ] && continue 2
9025 echo "pool list: $tlist"
9026 echo "striping: $res"
9027 error_noexit "$file not allocated in $pool"
9034 echo "Creating new pool"
9037 create_pool $FSNAME.$pool ||
9038 { error_noexit "No pool created, result code $?"; return 1; }
9039 [ $($LFS pool_list $FSNAME | grep -c $pool) -eq 1 ] ||
9040 { error_noexit "$pool not in lfs pool_list"; return 2; }
9043 pool_add_targets() {
9044 echo "Adding targets to pool"
9050 local list=$(seq $first $step $last)
9052 local t=$(for i in $list; do printf "$FSNAME-OST%04x_UUID " $i; done)
9053 do_facet mgs $LCTL pool_add \
9054 $FSNAME.$pool $FSNAME-OST[$first-$last/$step]
9055 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$pool \
9056 | sort -u | tr '\n' ' ' " "$t" || {
9057 error_noexit "Add to pool failed"
9060 local lfscount=$($LFS pool_list $FSNAME.$pool | grep -c "\-OST")
9061 local addcount=$(((last - first) / step + 1))
9062 [ $lfscount -eq $addcount ] || {
9063 error_noexit "lfs pool_list bad ost count" \
9064 "$lfscount != $addcount"
9072 echo "Setting pool on directory $tdir"
9074 $SETSTRIPE -c 2 -p $pool $tdir && return 0
9076 error_noexit "Cannot set pool $pool to $tdir"
9083 echo "Checking pool on directory $tdir"
9085 local res=$($GETSTRIPE --pool $tdir | sed "s/\s*$//")
9086 [ "$res" = "$pool" ] && return 0
9088 error_noexit "Pool on '$tdir' is '$res', not '$pool'"
9092 pool_dir_rel_path() {
9093 echo "Testing relative path works well"
9098 mkdir -p $root/$tdir/$tdir
9100 pool_set_dir $pool $tdir || return 1
9101 pool_set_dir $pool ./$tdir || return 2
9102 pool_set_dir $pool ../$tdir || return 3
9103 pool_set_dir $pool ../$tdir/$tdir || return 4
9104 rm -rf $tdir; cd - > /dev/null
9107 pool_alloc_files() {
9108 echo "Checking files allocation from directory pool"
9115 for i in $(seq -w 1 $count)
9117 local file=$tdir/file-$i
9119 check_file_in_pool $file $pool "$tlist" || \
9120 failed=$((failed + 1))
9122 [ "$failed" = 0 ] && return 0
9124 error_noexit "$failed files not allocated in $pool"
9128 pool_create_files() {
9129 echo "Creating files in pool"
9137 for i in $(seq -w 1 $count)
9139 local file=$tdir/spoo-$i
9140 $SETSTRIPE -p $pool $file
9141 check_file_in_pool $file $pool "$tlist" || \
9142 failed=$((failed + 1))
9144 [ "$failed" = 0 ] && return 0
9146 error_noexit "$failed files not allocated in $pool"
9151 echo "Checking 'lfs df' output"
9154 local t=$($LCTL get_param -n lov.$FSNAME-clilov-*.pools.$pool |
9156 local res=$($LFS df --pool $FSNAME.$pool |
9158 grep "$FSNAME-OST" |
9160 [ "$res" = "$t" ] && return 0
9162 error_noexit "Pools OSTs '$t' is not '$res' that lfs df reports"
9166 pool_file_rel_path() {
9167 echo "Creating files in a pool with relative pathname"
9172 { error_noexit "unable to create $tdir"; return 1 ; }
9173 local file="/..$tdir/$tfile-1"
9174 $SETSTRIPE -p $pool $file ||
9175 { error_noexit "unable to create $file" ; return 2 ; }
9178 $SETSTRIPE -p $pool $tfile-2 || {
9179 error_noexit "unable to create $tfile-2 in $tdir"
9184 pool_remove_first_target() {
9185 echo "Removing first target from a pool"
9188 local pname="lov.$FSNAME-*.pools.$pool"
9189 local t=$($LCTL get_param -n $pname | head -1)
9190 do_facet mgs $LCTL pool_remove $FSNAME.$pool $t
9191 wait_update $HOSTNAME "lctl get_param -n $pname | grep $t" "" || {
9192 error_noexit "$t not removed from $FSNAME.$pool"
9197 pool_remove_all_targets() {
9198 echo "Removing all targets from pool"
9201 local pname="lov.$FSNAME-*.pools.$pool"
9202 for t in $($LCTL get_param -n $pname | sort -u)
9204 do_facet mgs $LCTL pool_remove $FSNAME.$pool $t
9206 wait_update $HOSTNAME "lctl get_param -n $pname" "" || {
9207 error_noexit "Pool $FSNAME.$pool cannot be drained"
9210 # striping on an empty/nonexistant pool should fall back
9211 # to "pool of everything"
9213 error_noexit "failed to use fallback striping for empty pool"
9216 # setstripe on an empty pool should fail
9217 $SETSTRIPE -p $pool $file 2>/dev/null && {
9218 error_noexit "expected failure when creating file" \
9226 echo "Destroying pool"
9230 do_facet mgs $LCTL pool_destroy $FSNAME.$pool
9233 # striping on an empty/nonexistant pool should fall back
9234 # to "pool of everything"
9236 error_noexit "failed to use fallback striping for missing pool"
9239 # setstripe on an empty pool should fail
9240 $SETSTRIPE -p $pool $file 2>/dev/null && {
9241 error_noexit "expected failure when creating file" \
9246 # get param should return err once pool is gone
9247 if wait_update $HOSTNAME "lctl get_param -n \
9248 lov.$FSNAME-*.pools.$pool 2>/dev/null || echo foo" "foo"
9250 remove_pool_from_list $FSNAME.$pool
9253 error_noexit "Pool $FSNAME.$pool is not destroyed"
9258 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
9260 local POOL=${POOL:-cea1}
9261 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
9262 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
9265 local last_ost=$(($OSTCOUNT - 1))
9267 local ost_list=$(seq $first_ost $ost_step $last_ost)
9268 local ost_range="$first_ost $last_ost $ost_step"
9269 local test_path=$POOL_ROOT/$POOL_DIR_NAME
9270 local file_dir=$POOL_ROOT/file_tst
9274 # former test_200a test_200b
9275 pool_add $POOL || { rc=$? ; break; }
9276 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
9277 # former test_200c test_200d
9279 pool_set_dir $POOL $test_path || { rc=$? ; break; }
9280 pool_check_dir $POOL $test_path || { rc=$? ; break; }
9281 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
9282 || { rc=$? ; break; }
9283 # former test_200e test_200f
9284 local files=$((OSTCOUNT*3))
9285 pool_alloc_files $POOL $test_path $files "$ost_list" \
9286 || { rc=$? ; break; }
9287 pool_create_files $POOL $file_dir $files "$ost_list" \
9288 || { rc=$? ; break; }
9289 # former test_200g test_200h
9290 pool_lfs_df $POOL || { rc=$? ; break; }
9291 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
9293 # former test_201a test_201b test_201c
9294 pool_remove_first_target $POOL || { rc=$? ; break; }
9296 local f=$test_path/$tfile
9297 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
9298 pool_remove $POOL $f || { rc=$? ; break; }
9305 run_test 200 "OST pools"
9307 # usage: default_attr <count | size | offset>
9309 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
9312 # usage: check_default_stripe_attr
9313 check_default_stripe_attr() {
9314 ACTUAL=$($GETSTRIPE $* $DIR/$tdir)
9316 --stripe-count|--count)
9317 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
9318 --stripe-size|--size)
9319 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
9320 --stripe-index|--index)
9323 error "unknown getstripe attr '$1'"
9326 [ $ACTUAL != $EXPECTED ] &&
9327 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
9331 test_mkdir -p $DIR/$tdir
9332 $SETSTRIPE --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
9334 check_default_stripe_attr --stripe-count
9335 check_default_stripe_attr --stripe-size
9336 check_default_stripe_attr --stripe-index
9340 run_test 204a "Print default stripe attributes ================="
9343 test_mkdir -p $DIR/$tdir
9344 $SETSTRIPE --stripe-count 1 $DIR/$tdir
9346 check_default_stripe_attr --stripe-size
9347 check_default_stripe_attr --stripe-index
9351 run_test 204b "Print default stripe size and offset ==========="
9354 test_mkdir -p $DIR/$tdir
9355 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
9357 check_default_stripe_attr --stripe-count
9358 check_default_stripe_attr --stripe-index
9362 run_test 204c "Print default stripe count and offset ==========="
9365 test_mkdir -p $DIR/$tdir
9366 $SETSTRIPE --stripe-index 0 $DIR/$tdir
9368 check_default_stripe_attr --stripe-count
9369 check_default_stripe_attr --stripe-size
9373 run_test 204d "Print default stripe count and size ============="
9376 test_mkdir -p $DIR/$tdir
9377 $SETSTRIPE -d $DIR/$tdir
9379 check_default_stripe_attr --stripe-count --raw
9380 check_default_stripe_attr --stripe-size --raw
9381 check_default_stripe_attr --stripe-index --raw
9385 run_test 204e "Print raw stripe attributes ================="
9388 test_mkdir -p $DIR/$tdir
9389 $SETSTRIPE --stripe-count 1 $DIR/$tdir
9391 check_default_stripe_attr --stripe-size --raw
9392 check_default_stripe_attr --stripe-index --raw
9396 run_test 204f "Print raw stripe size and offset ==========="
9399 test_mkdir -p $DIR/$tdir
9400 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
9402 check_default_stripe_attr --stripe-count --raw
9403 check_default_stripe_attr --stripe-index --raw
9407 run_test 204g "Print raw stripe count and offset ==========="
9410 test_mkdir -p $DIR/$tdir
9411 $SETSTRIPE --stripe-index 0 $DIR/$tdir
9413 check_default_stripe_attr --stripe-count --raw
9414 check_default_stripe_attr --stripe-size --raw
9418 run_test 204h "Print raw stripe count and size ============="
9420 # Figure out which job scheduler is being used, if any,
9422 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
9424 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
9426 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
9428 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
9429 JOBENV=LOADL_STEP_ID
9430 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
9440 # clear old jobstats
9441 do_facet $SINGLEMDS lctl set_param mdt.*.job_stats="clear"
9442 do_facet ost1 lctl set_param obdfilter.*.job_stats="clear"
9444 # use a new JobID for this test, or we might see an old one
9445 [ "$JOBENV" = "FAKE_JOBID" ] && FAKE_JOBID=test_id.$testnum.$RANDOM
9449 log "Using JobID environment variable $JOBENV=$JOBVAL"
9451 if [ $JOBENV = "FAKE_JOBID" ]; then
9452 FAKE_JOBID=$JOBVAL $cmd
9457 if [ "$target" = "mdt" -o "$target" = "both" ]; then
9458 FACET="$SINGLEMDS" # will need to get MDS number for DNE
9459 do_facet $FACET lctl get_param mdt.*.job_stats |
9460 grep $JOBVAL || error "No job stats found on MDT $FACET"
9462 if [ "$target" = "ost" -o "$target" = "both" ]; then
9464 do_facet $FACET lctl get_param obdfilter.*.job_stats |
9465 grep $JOBVAL || error "No job stats found on OST $FACET"
9469 test_205() { # Job stats
9470 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
9471 skip "Server doesn't support jobstats" && return 0
9474 OLD_JOBENV=`$LCTL get_param -n jobid_var`
9475 if [ $OLD_JOBENV != $JOBENV ]; then
9476 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$JOBENV
9477 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" \
9482 cmd="mkdir $DIR/$tfile"
9483 verify_jobstats "$cmd" "mdt"
9485 cmd="rm -fr $DIR/$tfile"
9486 verify_jobstats "$cmd" "mdt"
9488 cmd="mknod $DIR/$tfile c 1 3"
9489 verify_jobstats "$cmd" "mdt"
9491 cmd="rm -f $DIR/$tfile"
9492 verify_jobstats "$cmd" "mdt"
9494 cmd="$SETSTRIPE -i 0 -c 1 $DIR/$tfile"
9495 verify_jobstats "$cmd" "mdt"
9497 cmd="touch $DIR/$tfile"
9498 verify_jobstats "$cmd" "both"
9500 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
9501 verify_jobstats "$cmd" "ost"
9503 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
9504 verify_jobstats "$cmd" "ost"
9506 cmd="$TRUNCATE $DIR/$tfile 0"
9507 verify_jobstats "$cmd" "both"
9509 cmd="mv -f $DIR/$tfile $DIR/jobstats_test_rename"
9510 verify_jobstats "$cmd" "mdt"
9513 rm -f $DIR/jobstats_test_rename
9515 if [ $OLD_JOBENV != $JOBENV ]; then
9516 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$OLD_JOBENV
9517 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" \
9518 $OLD_JOBENV || return 1
9521 run_test 205 "Verify job stats"
9523 # LU-1480, LU-1773 and LU-1657
9526 lfs setstripe -c -1 $DIR/$tdir
9527 #define OBD_FAIL_LOV_INIT 0x1403
9528 $LCTL set_param fail_loc=0xa0001403
9529 $LCTL set_param fail_val=1
9530 touch $DIR/$tdir/$tfile || true
9532 run_test 206 "fail lov_init_raid0() doesn't lbug"
9536 size=$((size % 8192 + 1))
9537 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
9538 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
9539 rm -f $DIR/f212 $DIR/f212.xyz
9541 run_test 212 "Sendfile test ============================================"
9544 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
9545 cancel_lru_locks osc
9546 lctl set_param fail_loc=0x8000040f
9547 # generate a read lock
9548 cat $DIR/$tfile > /dev/null
9549 # write to the file, it will try to cancel the above read lock.
9550 cat /etc/hosts >> $DIR/$tfile
9552 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
9554 test_214() { # for bug 20133
9555 test_mkdir -p $DIR/d214p/d214c
9556 for (( i=0; i < 340; i++ )) ; do
9557 touch $DIR/d214p/d214c/a$i
9560 ls -l $DIR/d214p || error "ls -l $DIR/d214p failed"
9561 mv $DIR/d214p/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
9562 ls $DIR/d214c || error "ls $DIR/d214c failed"
9563 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
9565 run_test 214 "hash-indexed directory test - bug 20133"
9567 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
9568 create_lnet_proc_files() {
9569 cat /proc/sys/lnet/$1 >$TMP/lnet_$1.out || error "cannot read /proc/sys/lnet/$1"
9570 sysctl lnet.$1 >$TMP/lnet_$1.sys_tmp || error "cannot read lnet.$1"
9572 sed "s/^lnet.$1\ =\ //g" "$TMP/lnet_$1.sys_tmp" >$TMP/lnet_$1.sys
9573 rm -f "$TMP/lnet_$1.sys_tmp"
9576 # counterpart of create_lnet_proc_files
9577 remove_lnet_proc_files() {
9578 rm -f $TMP/lnet_$1.out $TMP/lnet_$1.sys
9581 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
9582 # 3rd arg as regexp for body
9583 check_lnet_proc_stats() {
9584 local l=$(cat "$TMP/lnet_$1" |wc -l)
9585 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
9587 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
9590 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
9591 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
9592 # optional and can be regexp for 2nd line (lnet.routes case)
9593 check_lnet_proc_entry() {
9594 local blp=2 # blp stands for 'position of 1st line of body'
9595 [ "$5" = "" ] || blp=3 # lnet.routes case
9597 local l=$(cat "$TMP/lnet_$1" |wc -l)
9598 # subtracting one from $blp because the body can be empty
9599 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
9601 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
9602 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
9604 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
9605 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
9607 # bail out if any unexpected line happened
9608 sed -n "$blp~1 p" "$TMP/lnet_$1" |grep -Ev "$3"
9609 [ "$?" != 0 ] || error "$2 misformatted"
9612 test_215() { # for bugs 18102, 21079, 21517
9613 local N='(0|[1-9][0-9]*)' # non-negative numeric
9614 local P='[1-9][0-9]*' # positive numeric
9615 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
9616 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
9617 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
9618 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
9620 local L1 # regexp for 1st line
9621 local L2 # regexp for 2nd line (optional)
9622 local BR # regexp for the rest (body)
9624 # /proc/sys/lnet/stats should look as 11 space-separated non-negative numerics
9625 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
9626 create_lnet_proc_files "stats"
9627 check_lnet_proc_stats "stats.out" "/proc/sys/lnet/stats" "$BR"
9628 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
9629 remove_lnet_proc_files "stats"
9631 # /proc/sys/lnet/routes should look like this:
9632 # Routing disabled/enabled
9633 # net hops state router
9634 # where net is a string like tcp0, hops >= 0, state is up/down,
9635 # router is a string like 192.168.1.1@tcp2
9636 L1="^Routing (disabled|enabled)$"
9637 L2="^net +hops +state +router$"
9638 BR="^$NET +$N +(up|down) +$NID$"
9639 create_lnet_proc_files "routes"
9640 check_lnet_proc_entry "routes.out" "/proc/sys/lnet/routes" "$BR" "$L1" "$L2"
9641 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
9642 remove_lnet_proc_files "routes"
9644 # /proc/sys/lnet/routers should look like this:
9645 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
9646 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
9647 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
9648 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
9649 L1="^ref +rtr_ref +alive_cnt +state +last_ping +ping_sent +deadline +down_ni +router$"
9650 BR="^$P +$P +$N +(up|down) +$N +(0|1) +$I +$I +$NID$"
9651 create_lnet_proc_files "routers"
9652 check_lnet_proc_entry "routers.out" "/proc/sys/lnet/routers" "$BR" "$L1"
9653 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
9654 remove_lnet_proc_files "routers"
9656 # /proc/sys/lnet/peers should look like this:
9657 # nid refs state last max rtr min tx min queue
9658 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
9659 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
9660 # numeric (0 or >0 or <0), queue >= 0.
9661 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
9662 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
9663 create_lnet_proc_files "peers"
9664 check_lnet_proc_entry "peers.out" "/proc/sys/lnet/peers" "$BR" "$L1"
9665 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
9666 remove_lnet_proc_files "peers"
9668 # /proc/sys/lnet/buffers should look like this:
9669 # pages count credits min
9670 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
9671 L1="^pages +count +credits +min$"
9672 BR="^ +$N +$N +$I +$I$"
9673 create_lnet_proc_files "buffers"
9674 check_lnet_proc_entry "buffers.out" "/proc/sys/lnet/buffers" "$BR" "$L1"
9675 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
9676 remove_lnet_proc_files "buffers"
9678 # /proc/sys/lnet/nis should look like this:
9679 # nid status alive refs peer rtr max tx min
9680 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
9681 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
9682 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
9683 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
9684 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
9685 create_lnet_proc_files "nis"
9686 check_lnet_proc_entry "nis.out" "/proc/sys/lnet/nis" "$BR" "$L1"
9687 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
9688 remove_lnet_proc_files "nis"
9690 # can we successfully write to /proc/sys/lnet/stats?
9691 echo "0" >/proc/sys/lnet/stats || error "cannot write to /proc/sys/lnet/stats"
9692 sysctl -w lnet.stats=0 || error "cannot write to lnet.stats"
9694 run_test 215 "/proc/sys/lnet exists and has proper content - bugs 18102, 21079, 21517"
9696 test_216() { # bug 20317
9697 remote_ost_nodsh && skip "remote OST with nodsh" && return
9699 local p="$TMP/sanityN-$TESTNAME.parameters"
9700 save_lustre_params $HOSTNAME "osc.*.contention_seconds" > $p
9701 for node in $(osts_nodes); do
9702 save_lustre_params $node "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
9703 save_lustre_params $node "ldlm.namespaces.filter-*.contended_locks" >> $p
9704 save_lustre_params $node "ldlm.namespaces.filter-*.contention_seconds" >> $p
9708 # agressive lockless i/o settings
9709 for node in $(osts_nodes); do
9710 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'
9712 lctl set_param -n osc.*.contention_seconds 60
9714 $DIRECTIO write $DIR/$tfile 0 10 4096
9715 $CHECKSTAT -s 40960 $DIR/$tfile
9717 # disable lockless i/o
9718 for node in $(osts_nodes); do
9719 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'
9721 lctl set_param -n osc.*.contention_seconds 0
9724 dd if=/dev/zero of=$DIR/$tfile count=0
9725 $CHECKSTAT -s 0 $DIR/$tfile
9727 restore_lustre_params <$p
9731 run_test 216 "check lockless direct write works and updates file size and kms correctly"
9733 test_217() { # bug 22430
9737 for node in $(nodes_list); do
9738 nid=$(host_nids_address $node $NETTYPE)
9739 if [[ $nid = *-* ]] ; then
9740 echo "lctl ping $nid@$NETTYPE"
9741 lctl ping $nid@$NETTYPE
9743 echo "skipping $node (no hyphen detected)"
9747 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
9750 # do directio so as not to populate the page cache
9751 log "creating a 10 Mb file"
9752 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
9753 log "starting reads"
9754 dd if=$DIR/$tfile of=/dev/null bs=4096 &
9755 log "truncating the file"
9756 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
9758 kill %+ || true # reads might have finished
9759 echo "wait until dd is finished"
9761 log "removing the temporary file"
9762 rm -rf $DIR/$tfile || error "tmp file removal failed"
9764 run_test 218 "parallel read and truncate should not deadlock ======================="
9767 # write one partial page
9768 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
9769 # set no grant so vvp_io_commit_write will do sync write
9770 $LCTL set_param fail_loc=0x411
9771 # write a full page at the end of file
9772 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
9774 $LCTL set_param fail_loc=0
9775 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
9776 $LCTL set_param fail_loc=0x411
9777 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
9779 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
9781 test_220() { #LU-325
9782 remote_ost_nodsh && skip "remote OST with nodsh" && return
9785 test_mkdir -p $DIR/$tdir
9786 local OST=$(lfs osts | grep ${OSTIDX}": " | \
9787 awk '{print $2}' | sed -e 's/_UUID$//')
9790 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
9791 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
9792 osc.$mdtosc_proc1.prealloc_last_id)
9793 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
9794 osc.$mdtosc_proc1.prealloc_next_id)
9798 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
9799 #define OBD_FAIL_OST_ENOINO 0x229
9800 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
9801 do_facet mgs $LCTL pool_new $FSNAME.$TESTNAME || return 1
9802 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
9804 $SETSTRIPE $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
9806 MDSOBJS=$((last_id - next_id))
9807 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
9809 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
9810 echo "OST still has $count kbytes free"
9812 echo "create $MDSOBJS files @next_id..."
9813 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
9815 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
9816 osc.$mdtosc_proc1.prealloc_last_id)
9817 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
9818 osc.$mdtosc_proc1.prealloc_next_id)
9820 echo "after creation, last_id=$last_id2, next_id=$next_id2"
9825 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
9826 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
9828 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST || return 4
9829 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME || return 5
9830 echo "unlink $MDSOBJS files @$next_id..."
9831 unlinkmany $DIR/$tdir/f $MDSOBJS || return 6
9833 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
9836 dd if=`which date` of=$MOUNT/date oflag=sync
9837 chmod +x $MOUNT/date
9839 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
9840 $LCTL set_param fail_loc=0x80001401
9842 $MOUNT/date > /dev/null
9845 run_test 221 "make sure fault and truncate race to not cause OOM"
9849 test_mkdir -p $DIR/$tdir
9850 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
9851 createmany -o $DIR/$tdir/$tfile 10
9852 cancel_lru_locks mdc
9853 cancel_lru_locks osc
9854 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
9855 $LCTL set_param fail_loc=0x31a
9856 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
9857 $LCTL set_param fail_loc=0
9860 run_test 222a "AGL for ls should not trigger CLIO lock failure ================"
9864 test_mkdir -p $DIR/$tdir
9865 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
9866 createmany -o $DIR/$tdir/$tfile 10
9867 cancel_lru_locks mdc
9868 cancel_lru_locks osc
9869 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
9870 $LCTL set_param fail_loc=0x31a
9871 rm -r $DIR/$tdir || "AGL for rmdir failed"
9872 $LCTL set_param fail_loc=0
9874 run_test 222b "AGL for rmdir should not trigger CLIO lock failure ============="
9878 test_mkdir -p $DIR/$tdir
9879 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
9880 createmany -o $DIR/$tdir/$tfile 10
9881 cancel_lru_locks mdc
9882 cancel_lru_locks osc
9883 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
9884 $LCTL set_param fail_loc=0x31b
9885 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
9886 $LCTL set_param fail_loc=0
9889 run_test 223 "osc reenqueue if without AGL lock granted ======================="
9891 test_224a() { # LU-1039, MRP-303
9892 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
9893 $LCTL set_param fail_loc=0x508
9894 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
9895 $LCTL set_param fail_loc=0
9898 run_test 224a "Don't panic on bulk IO failure"
9900 test_224b() { # LU-1039, MRP-303
9901 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
9902 cancel_lru_locks osc
9903 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
9904 $LCTL set_param fail_loc=0x515
9905 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
9906 $LCTL set_param fail_loc=0
9909 run_test 224b "Don't panic on bulk IO failure"
9911 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
9913 if [ -z ${MDSSURVEY} ]; then
9914 skip_env "mds-survey not found" && return
9916 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
9917 { skip "Need MDS version at least 2.2.51"; return; }
9919 local mds=$(facet_host $SINGLEMDS)
9920 local target=$(do_nodes $mds 'lctl dl' | \
9921 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
9923 local cmd1="file_count=1000 thrhi=4"
9924 local cmd2="dir_count=2 layer=mdd stripe_count=0"
9925 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
9926 local cmd="$cmd1 $cmd2 $cmd3"
9928 rm -f ${TMP}/mds_survey*
9930 eval $cmd || error "mds-survey with zero-stripe failed"
9931 cat ${TMP}/mds_survey*
9932 rm -f ${TMP}/mds_survey*
9934 run_test 225a "Metadata survey sanity with zero-stripe"
9937 if [ -z ${MDSSURVEY} ]; then
9938 skip_env "mds-survey not found" && return
9940 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
9941 { skip "Need MDS version at least 2.2.51"; return; }
9943 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
9944 skip_env "Need to mount OST to test" && return
9947 local mds=$(facet_host $SINGLEMDS)
9948 local target=$(do_nodes $mds 'lctl dl' | \
9949 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
9951 local cmd1="file_count=1000 thrhi=4"
9952 local cmd2="dir_count=2 layer=mdd stripe_count=1"
9953 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
9954 local cmd="$cmd1 $cmd2 $cmd3"
9956 rm -f ${TMP}/mds_survey*
9958 eval $cmd || error "mds-survey with stripe_count failed"
9959 cat ${TMP}/mds_survey*
9960 rm -f ${TMP}/mds_survey*
9962 run_test 225b "Metadata survey sanity with stripe_count = 1"
9964 mcreate_path2fid () {
9970 local path=$DIR/$tdir/$name
9975 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
9976 error "cannot create $desc"
9978 fid=$($LFS path2fid $path)
9980 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
9982 fid_path=$($LFS fid2path $DIR "$fid")
9984 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
9986 [ "$path" == "$fid_path" ] ||
9987 error "fid2path returned $fid_path, expected $path"
9989 echo "pass with $path and $fid"
9996 mcreate_path2fid 0010666 0 0 fifo "FIFO"
9997 mcreate_path2fid 0020666 1 3 null "character special file (null)"
9998 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
9999 mcreate_path2fid 0040666 0 0 dir "directory"
10000 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
10001 mcreate_path2fid 0100666 0 0 file "regular file"
10002 mcreate_path2fid 0120666 0 0 link "symbolic link"
10003 mcreate_path2fid 0140666 0 0 sock "socket"
10005 run_test 226 "call path2fid and fid2path on files of all type"
10007 # LU-1299 Executing or running ldd on a truncated executable does not
10008 # cause an out-of-memory condition.
10010 dd if=`which date` of=$MOUNT/date bs=1k count=1
10011 chmod +x $MOUNT/date
10013 $MOUNT/date > /dev/null
10014 ldd $MOUNT/date > /dev/null
10017 run_test 227 "running truncated executable does not cause OOM"
10019 # LU-1512 try to reuse idle OI blocks
10021 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
10022 skip "non-ldiskfs backend" && return
10024 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
10025 local myDIR=$DIR/$tdir
10028 #define OBD_FAIL_SEQ_EXHAUST 0x1002
10029 $LCTL set_param fail_loc=0x80001002
10030 createmany -o $myDIR/t- 10000
10031 $LCTL set_param fail_loc=0
10032 # The guard is current the largest FID holder
10034 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
10036 local IDX=$(($SEQ % 64))
10038 do_facet $SINGLEMDS sync
10039 # Make sure journal flushed.
10041 local blk1=$(do_facet $SINGLEMDS \
10042 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
10043 grep Blockcount | awk '{print $4}')
10045 # Remove old files, some OI blocks will become idle.
10046 unlinkmany $myDIR/t- 10000
10047 # Create new files, idle OI blocks should be reused.
10048 createmany -o $myDIR/t- 2000
10049 do_facet $SINGLEMDS sync
10050 # Make sure journal flushed.
10052 local blk2=$(do_facet $SINGLEMDS \
10053 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
10054 grep Blockcount | awk '{print $4}')
10056 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
10058 run_test 228a "try to reuse idle OI blocks"
10061 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
10062 skip "non-ldiskfs backend" && return
10064 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
10065 local myDIR=$DIR/$tdir
10068 #define OBD_FAIL_SEQ_EXHAUST 0x1002
10069 $LCTL set_param fail_loc=0x80001002
10070 createmany -o $myDIR/t- 10000
10071 $LCTL set_param fail_loc=0
10072 # The guard is current the largest FID holder
10074 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
10076 local IDX=$(($SEQ % 64))
10078 do_facet $SINGLEMDS sync
10079 # Make sure journal flushed.
10081 local blk1=$(do_facet $SINGLEMDS \
10082 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
10083 grep Blockcount | awk '{print $4}')
10085 # Remove old files, some OI blocks will become idle.
10086 unlinkmany $myDIR/t- 10000
10089 stop $SINGLEMDS || error "Fail to stop MDT."
10091 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
10093 df $MOUNT || error "Fail to df."
10094 # Create new files, idle OI blocks should be reused.
10095 createmany -o $myDIR/t- 2000
10096 do_facet $SINGLEMDS sync
10097 # Make sure journal flushed.
10099 local blk2=$(do_facet $SINGLEMDS \
10100 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
10101 grep Blockcount | awk '{print $4}')
10103 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
10105 run_test 228b "idle OI blocks can be reused after MDT restart"
10109 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
10110 skip "non-ldiskfs backend" && return
10112 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
10113 local myDIR=$DIR/$tdir
10116 #define OBD_FAIL_SEQ_EXHAUST 0x1002
10117 $LCTL set_param fail_loc=0x80001002
10118 # 20000 files can guarantee there are index nodes in the OI file
10119 createmany -o $myDIR/t- 20000
10120 $LCTL set_param fail_loc=0
10121 # The guard is current the largest FID holder
10123 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
10125 local IDX=$(($SEQ % 64))
10127 do_facet $SINGLEMDS sync
10128 # Make sure journal flushed.
10130 local blk1=$(do_facet $SINGLEMDS \
10131 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
10132 grep Blockcount | awk '{print $4}')
10134 # Remove old files, some OI blocks will become idle.
10135 unlinkmany $myDIR/t- 20000
10137 # The OI file should become empty now
10139 # Create new files, idle OI blocks should be reused.
10140 createmany -o $myDIR/t- 2000
10141 do_facet $SINGLEMDS sync
10142 # Make sure journal flushed.
10144 local blk2=$(do_facet $SINGLEMDS \
10145 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
10146 grep Blockcount | awk '{print $4}')
10148 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
10150 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
10153 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
10156 mkdir -p $DIR/$tdir/test_230_local
10157 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230_local)
10158 [ $mdt_idx -ne 0 ] &&
10159 error "create local directory on wrong MDT $mdt_idx"
10161 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
10162 error "create remote directory failed"
10163 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230)
10164 [ $mdt_idx -ne $MDTIDX ] &&
10165 error "create remote directory on wrong MDT $mdt_idx"
10167 createmany -o $DIR/$tdir/test_230/t- 10 ||
10168 error "create files on remote directory failed"
10169 mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230/t-0)
10170 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
10171 rm -r $DIR/$tdir || error "unlink remote directory failed"
10173 run_test 230a "Create remote directory and files under the remote directory"
10176 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
10178 local remote_dir=$DIR/$tdir/remote_dir
10180 mkdir -p $DIR/$tdir
10181 $LFS mkdir -i $MDTIDX $remote_dir ||
10182 error "create remote directory failed"
10184 $LFS mkdir -i 0 $remote_dir/new_dir &&
10185 error "nested remote directory create succeed!"
10187 rm -r $DIR/$tdir || error "unlink remote directory failed"
10189 run_test 230b "nested remote directory should be failed"
10192 # tests that do cleanup/setup should be run at the end
10197 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
10198 $LCTL set_param fail_loc=0x903
10199 # cancel_lru_locks mgc - does not work due to lctl set_param syntax
10200 for ls in /proc/fs/lustre/ldlm/namespaces/MGC*/lru_size; do
10203 FAIL_ON_ERROR=true cleanup
10204 FAIL_ON_ERROR=true setup
10206 run_test 900 "umount should not race with any mgc requeue thread"
10209 check_and_cleanup_lustre
10210 if [ "$I_MOUNTED" != "yes" ]; then
10211 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true