6 # bug number for skipped test: 3192 15528/3811 16929 9977 15528/11549 18080
7 ALWAYS_EXCEPT=" 14b 19 22 28 29 35 $SANITYN_EXCEPT"
8 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
10 # bug number for skipped test: 12652 12652
11 grep -q 'Enterprise Server 10' /etc/SuSE-release && ALWAYS_EXCEPT="$ALWAYS_EXCEPT 11 14" || true
13 # Tests that fail on uml
14 [ "$UML" = "true" ] && EXCEPT="$EXCEPT 7"
16 # Join file feature is not supported currently.
17 # It will be ported soon.
21 PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH
24 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
25 GETSTRIPE=${GETSTRIPE:-lfs getstripe}
26 SETSTRIPE=${SETSTRIPE:-lstripe}
27 MCREATE=${MCREATE:-mcreate}
28 OPENFILE=${OPENFILE:-openfile}
29 OPENUNLINK=${OPENUNLINK:-openunlink}
30 TRUNCATE=${TRUNCATE:-truncate}
31 export TMP=${TMP:-/tmp}
32 MOUNT_2=${MOUNT_2:-"yes"}
33 CHECK_GRANT=${CHECK_GRANT:-"yes"}
34 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
38 export NAME=${NAME:-local}
40 LUSTRE=${LUSTRE:-`dirname $0`/..}
41 . $LUSTRE/tests/test-framework.sh
45 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
47 [ "$SLOW" = "no" ] && EXCEPT_SLOW="12 16 33a"
49 SANITYLOG=${TESTSUITELOG:-$TMP/$(basename $0 .sh).log}
55 [ "$SANITYLOG" ] && rm -f $SANITYLOG || true
57 check_and_setup_lustre
59 LOVNAME=`lctl get_param -n llite.*.lov.common_name | tail -n 1`
60 OSTCOUNT=`lctl get_param -n lov.$LOVNAME.numobd`
63 rm -rf $DIR1/[df][0-9]* $DIR1/lnk
65 # $RUNAS_ID may get set incorrectly somewhere else
66 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
68 check_runas_id $RUNAS_ID $RUNAS_ID $RUNAS
74 [ -f $DIR2/f1 ] || error
76 run_test 1a "check create on 2 mtpt's =========================="
80 $CHECKSTAT -t file -p 0777 $DIR1/f1 || error
83 run_test 1b "check attribute updates on 2 mtpt's ==============="
86 $CHECKSTAT -t file -p 0666 $DIR1/f1 || error
88 run_test 1c "check after remount attribute updates on 2 mtpt's ="
92 $CHECKSTAT -a $DIR1/f1 || error
94 run_test 1d "unlink on one mountpoint removes file on other ===="
100 $CHECKSTAT -t file -p 0777 $DIR1/f2a || error
102 run_test 2a "check cached attribute updates on 2 mtpt's ========"
108 $CHECKSTAT -t file -p 0777 $DIR2/f2b || error
110 run_test 2b "check cached attribute updates on 2 mtpt's ========"
112 # NEED TO SAVE ROOT DIR MODE
115 $CHECKSTAT -t dir -p 0777 $DIR2 || error
117 run_test 2c "check cached attribute updates on 2 mtpt's root ==="
121 $CHECKSTAT -t dir -p 0755 $DIR2 || error
123 run_test 2d "check cached attribute updates on 2 mtpt's root ==="
130 $RUNAS dd if=/dev/zero of=$DIR2/$tfile count=1 || error
132 run_test 2e "check chmod on root is propagated to others"
135 ( cd $DIR1 ; ln -s this/is/good $tfile )
136 [ "this/is/good" = "`perl -e 'print readlink("'$DIR2/$tfile'");'`" ] ||
137 error "link $DIR2/$tfile not as expected"
139 run_test 3 "symlink on one mtpt, readlink on another ==========="
142 multifstat $DIR1/f4 $DIR2/f4
144 run_test 4 "fstat validation on multiple mount points =========="
148 truncate $DIR2/f5 100
149 $CHECKSTAT -t file -s 100 $DIR1/f5 || error
152 run_test 5 "create a file on one mount, truncate it on the other"
155 openunlink $DIR1/$tfile $DIR2/$tfile || \
156 error "openunlink $DIR1/$tfile $DIR2/$tfile"
158 run_test 6 "remove of open file on other node =================="
162 opendirunlink $DIR1/$dir $DIR2/$dir || \
163 error "opendirunlink $DIR1/$dir $DIR2/$dir"
165 run_test 7 "remove of open directory on other node ============="
168 opendevunlink $DIR1/$tfile $DIR2/$tfile || \
169 error "opendevunlink $DIR1/$tfile $DIR2/$tfile"
171 run_test 8 "remove of open special file on other node =========="
177 for C in a b c d e f g h i j k l; do
178 dir=`eval echo \\$DIR$MTPT`
179 echo -n $C >> $dir/f9
180 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
182 [ "`cat $DIR1/f9`" = "abcdefghijkl" ] || \
183 error "`od -a $DIR1/f9` != abcdefghijkl"
185 run_test 9 "append of file with sub-page size on multiple mounts"
192 for C in a b c d e f g h i j k l; do
193 dir=`eval echo \\$DIR$MTPT`
194 echo -n $C | dd of=$dir/f10 bs=1 seek=$OFFSET count=1
195 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
196 OFFSET=`expr $OFFSET + 1`
198 [ "`cat $DIR1/f10`" = "abcdefghijkl" ] || \
199 error "`od -a $DIR1/f10` != abcdefghijkl"
201 run_test 10a "write of file with sub-page size on multiple mounts "
205 yes "R" | head -c 4000 >$TMP/f10b-seed
206 dd if=$TMP/f10b-seed of=$DIR1/f10b bs=3k count=1 || error "dd $DIR1"
208 truncate $DIR1/f10b 4096 || error "truncate 4096"
210 dd if=$DIR2/f10b of=$TMP/f10b-lustre bs=4k count=1 || error "dd $DIR2"
212 # create a test file locally to compare
213 dd if=$TMP/f10b-seed of=$TMP/f10b bs=3k count=1 || error "dd random"
214 truncate $TMP/f10b 4096 || error "truncate 4096"
215 cmp $TMP/f10b $TMP/f10b-lustre || error "file miscompare"
216 rm $TMP/f10b $TMP/f10b-lustre $TMP/f10b-seed
218 run_test 10b "write of file with sub-page size on multiple mounts "
222 multiop_bg_pause $DIR1/d11/f O_c || return 1
224 cp -p /bin/ls $DIR1/d11/f
228 wait $MULTIPID || error
229 [ $RC -eq 0 ] && error || true
231 run_test 11 "execution of file opened for write should return error ===="
234 DIR=$DIR DIR2=$DIR2 sh lockorder.sh
236 run_test 12 "test lock ordering (link, stat, unlink) ==========="
238 test_13() { # bug 2451 - directory coherency
240 mkdir $DIR1/d13 || error
241 cd $DIR1/d13 || error
243 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
245 rm -f $DIR2/d13/f13 || error
246 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (1)" || true
247 # need to run it twice
248 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
250 rm -f $DIR2/d13/f13 || error
251 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (2)" || true
253 run_test 13 "test directory page revocation ===================="
257 cp -p /bin/ls $DIR1/$tdir/$tfile
258 multiop_bg_pause $DIR1/$tdir/$tfile Ow_c || return 1
261 $DIR2/$tdir/$tfile && error || true
263 wait $MULTIPID || return 2
265 run_test 14 "execution of file open for write returns -ETXTBSY ="
269 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
270 MULTIOP_PROG=$DIR1/d14/multiop multiop_bg_pause $TMP/test14.junk O_c || return 1
272 multiop $DIR2/d14/multiop Oc && error "expected error, got success"
273 kill -USR1 $MULTIOP_PID || return 2
274 wait $MULTIOP_PID || return 3
275 rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop"
277 run_test 14a "open(RDWR) of executing file returns -ETXTBSY ===="
279 test_14b() { # bug 3192, 7040
281 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
282 MULTIOP_PROG=$DIR1/d14/multiop multiop_bg_pause $TMP/test14.junk O_c || return 1
284 truncate $DIR2/d14/multiop 0 && kill -9 $MULTIOP_PID && \
285 error "expected truncate error, got success"
286 kill -USR1 $MULTIOP_PID || return 2
287 wait $MULTIOP_PID || return 3
288 cmp `which multiop` $DIR1/d14/multiop || error "binary changed"
289 rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop"
291 run_test 14b "truncate of executing file returns -ETXTBSY ======"
293 test_14c() { # bug 3430, 7040
295 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
296 MULTIOP_PROG=$DIR1/d14/multiop multiop_bg_pause $TMP/test14.junk O_c || return 1
298 cp /etc/hosts $DIR2/d14/multiop && error "expected error, got success"
299 kill -USR1 $MULTIOP_PID || return 2
300 wait $MULTIOP_PID || return 3
301 cmp `which multiop` $DIR1/d14/multiop || error "binary changed"
302 rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop"
304 run_test 14c "open(O_TRUNC) of executing file return -ETXTBSY =="
306 test_14d() { # bug 10921
308 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
309 MULTIOP_PROG=$DIR1/d14/multiop multiop_bg_pause $TMP/test14.junk O_c || return 1
312 chmod 600 $DIR1/d14/multiop || error "chmod failed"
313 kill -USR1 $MULTIOP_PID || return 2
314 wait $MULTIOP_PID || return 3
315 cmp `which multiop` $DIR1/d14/multiop || error "binary changed"
316 rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop"
318 run_test 14d "chmod of executing file is still possible ========"
320 test_15() { # bug 974 - ENOSPC
322 sh oos2.sh $MOUNT1 $MOUNT2
323 grant_error=`dmesg | grep "> available"`
324 [ -z "$grant_error" ] || error "$grant_error"
326 run_test 15 "test out-of-space with multiple writers ==========="
329 rm -f $MOUNT1/fsxfile
330 lfs setstripe $MOUNT1/fsxfile -c -1 # b=10919
331 fsx -c 50 -p 100 -N 2500 -l $((SIZE * 256)) -S 0 $MOUNT1/fsxfile $MOUNT2/fsxfile
333 run_test 16 "2500 iterations of dual-mount fsx ================="
335 test_17() { # bug 3513, 3667
336 remote_ost_nodsh && skip "remote OST with nodsh" && return
338 lfs setstripe $DIR1/$tfile -i 0 -c 1
339 cp /etc/termcap $DIR1/$tfile
340 cancel_lru_locks osc > /dev/null
341 #define OBD_FAIL_ONCE|OBD_FAIL_LDLM_CREATE_RESOURCE 0x30a
342 do_facet ost1 lctl set_param fail_loc=0x8000030a
343 ls -ls $DIR1/$tfile | awk '{ print $1,$6 }' > $DIR1/$tfile-1 & \
344 ls -ls $DIR2/$tfile | awk '{ print $1,$6 }' > $DIR2/$tfile-2
346 diff -u $DIR1/$tfile-1 $DIR2/$tfile-2 || error "files are different"
348 run_test 17 "resource creation/LVB creation race ==============="
351 ./mmap_sanity -d $MOUNT1 -m $MOUNT2
354 run_test 18 "mmap sanity check ================================="
356 test_19() { # bug3811
357 [ -d /proc/fs/lustre/obdfilter ] || return 0
359 MAX=`lctl get_param -n obdfilter.*.readcache_max_filesize | head -n 1`
360 lctl set_param -n obdfilter.*OST*.readcache_max_filesize=4096
361 dd if=/dev/urandom of=$TMP/f19b bs=512k count=32
362 SUM=`cksum $TMP/f19b | cut -d" " -f 1,2`
363 cp $TMP/f19b $DIR1/f19b
364 for i in `seq 1 20`; do
365 [ $((i % 5)) -eq 0 ] && log "test_18 loop $i"
366 cancel_lru_locks osc > /dev/null
367 cksum $DIR1/f19b | cut -d" " -f 1,2 > $TMP/sum1 & \
368 cksum $DIR2/f19b | cut -d" " -f 1,2 > $TMP/sum2
370 [ "`cat $TMP/sum1`" = "$SUM" ] || \
371 error "$DIR1/f19b `cat $TMP/sum1` != $SUM"
372 [ "`cat $TMP/sum2`" = "$SUM" ] || \
373 error "$DIR2/f19b `cat $TMP/sum2` != $SUM"
375 lctl set_param -n obdfilter.*OST*.readcache_max_filesize=$MAX
378 run_test 19 "test concurrent uncached read races ==============="
383 CNT=$((`lctl get_param -n llite.*.dump_page_cache | wc -l`))
384 multiop $DIR1/f20 Ow8190c
385 multiop $DIR2/f20 Oz8194w8190c
386 multiop $DIR1/f20 Oz0r8190c
388 CNTD=$((`lctl get_param -n llite.*.dump_page_cache | wc -l` - $CNT))
390 error $CNTD" page left in cache after lock cancel" || true
392 run_test 20 "test extra readahead page left in cache ===="
399 test_21() { # Bug 5907
401 mount /etc $DIR1/d21 --bind || error "mount failed" # Poor man's mount.
403 rmdir -v $DIR1/d21 && error "Removed mounted directory"
404 rmdir -v $DIR2/d21 && echo "Removed mounted directory from another mountpoint, needs to be fixed"
405 test -d $DIR1/d21 || error "Mounted directory disappeared"
407 test -d $DIR2/d21 || test -d $DIR1/d21 && error "Removed dir still visible after umount"
410 run_test 21 " Try to remove mountpoint on another dir ===="
412 JOIN=${JOIN:-"lfs join"}
414 test_22() { # Bug 9926
416 dd if=/dev/urandom of=$DIR1/d21/128k bs=1024 count=128
417 cp -p $DIR1/d21/128k $DIR1/d21/f_head
418 for ((i=0;i<10;i++)); do
419 cp -p $DIR1/d21/128k $DIR1/d21/f_tail
420 $JOIN $DIR1/d21/f_head $DIR1/d21/f_tail || error "join error"
421 $CHECKSTAT -a $DIR1/d21/f_tail || error "tail file exist after join"
423 echo aaaaaaaaaaa >> $DIR1/d21/no_joined
425 mv $DIR2/d21/f_head $DIR2/
426 munlink $DIR2/f_head || error "unlink joined file error"
427 cat $DIR2/d21/no_joined || error "cat error"
428 rm -rf $DIR2/d21/no_joined || error "unlink normal file error"
430 run_test 22 " After joining in one dir, open/close unlink file in anther dir"
432 test_23() { # Bug 5972
433 echo "others should see updated atime while another read" > $DIR1/f23
435 # clear the lock(mode: LCK_PW) gotten from creating operation
441 multiop_bg_pause $DIR1/f23 or20_c || return 1
444 time2=`stat -c "%X" $DIR2/f23`
446 if (( $time2 <= $time1 )); then
448 error "atime doesn't update among nodes"
451 kill -USR1 $MULTIPID || return 1
452 rm -f $DIR1/f23 || error "rm -f $DIR1/f23 failed"
455 run_test 23 " others should see updated atime while another read===="
459 lfs df || error "lfs df failed"
460 lfs df -ih || error "lfs df -ih failed"
461 lfs df -h $DIR1 || error "lfs df -h $DIR1 failed"
462 lfs df -i $DIR2 || error "lfs df -i $DIR2 failed"
463 lfs df $DIR1/$tfile || error "lfs df $DIR1/$tfile failed"
464 lfs df -ih $DIR2/$tfile || error "lfs df -ih $DIR2/$tfile failed"
466 OSC=`lctl dl | awk '/-osc-|OSC.*MNT/ {print $4}' | head -n 1`
467 # OSC=`lctl dl | awk '/-osc-/ {print $4}' | head -n 1`
468 lctl --device %$OSC deactivate
469 lfs df -i || error "lfs df -i with deactivated OSC failed"
470 lctl --device %$OSC recover
471 lfs df || error "lfs df with reactivated OSC failed"
473 run_test 24 "lfs df [-ih] [path] test ========================="
476 [ `lctl get_param -n mdc.*-mdc-*.connect_flags | grep -c acl` -lt 2 ] && \
477 skip "must have acl, skipping" && return
480 touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
481 chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
483 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
484 setfacl -m u:$RUNAS_ID:--- $DIR1/$tdir || error "setfacl $DIR2/$tdir #1"
485 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
486 setfacl -m u:$RUNAS_ID:r-x $DIR1/$tdir || error "setfacl $DIR2/$tdir #2"
487 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
488 setfacl -m u:$RUNAS_ID:--- $DIR1/$tdir || error "setfacl $DIR2/$tdir #3"
489 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
490 setfacl -x u:$RUNAS_ID: $DIR1/$tdir || error "setfacl $DIR2/$tdir #4"
491 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
495 run_test 25 "change ACL on one mountpoint be seen on another ==="
498 utime $DIR1/f26a -s $DIR2/f26a || error
500 run_test 26a "allow mtime to get older"
505 echo "aaa" >> $DIR1/$tfile
507 chmod a+x $DIR2/$tfile
508 mt1=`stat -c %Y $DIR1/$tfile`
509 mt2=`stat -c %Y $DIR2/$tfile`
511 if [ x"$mt1" != x"$mt2" ]; then
512 error "not equal mtime, client1: "$mt1", client2: "$mt2"."
515 run_test 26b "sync mtime between ost and mds"
520 dd if=/dev/zero of=$DIR2/$tfile bs=$((4096+4))k conv=notrunc count=4 seek=3 &
525 dd if=/dev/zero of=$DIR1/$tfile bs=$((16384-1024))k conv=notrunc count=1 seek=4 &
530 dd if=/dev/zero of=$DIR1/$tfile bs=8k conv=notrunc count=1 seek=0
532 lctl set_param -n ldlm.dump_namespaces ""
533 wait $DD1_PID $DD2_PID
534 [ $? -ne 0 ] && lctl dk $TMP/debug || true
536 run_test 27 "align non-overlapping extent locks from request ==="
538 test_28() { # bug 9977
539 ECHO_UUID="ECHO_osc1_UUID"
540 tOST=`$LCTL dl | | awk '/-osc-|OSC.*MNT/ { print $4 }' | head -1`
542 lfs setstripe $DIR1/$tfile -s 1048576 -i 0 -c 2
543 tOBJID=`lfs getstripe $DIR1/$tfile |grep "^[[:space:]]\+1" |awk '{print $2}'`
544 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2
548 attach echo_client ECHO_osc1 $ECHO_UUID
552 tECHOID=`$LCTL dl | grep $ECHO_UUID | awk '{print $1}'`
553 $LCTL --device $tECHOID destroy "${tOBJID}:0"
561 # reading of 1st stripe should pass
562 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error
563 # reading of 2nd stripe should fail (this stripe was destroyed)
564 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 && error
566 # now, recreating test file
567 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2 || error
568 # reading of 1st stripe should pass
569 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error
570 # reading of 2nd stripe should pass
571 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 || error
573 run_test 28 "read/write/truncate file with lost stripes"
575 test_29() { # bug 10999
577 #define OBD_FAIL_LDLM_GLIMPSE 0x30f
578 lctl set_param fail_loc=0x8000030f
581 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1
584 #bug 11549 - permanently turn test off in b1_5
585 run_test 29 "lock put race between glimpse and enqueue ========="
587 test_30() { #bug #11110
589 cp -f /bin/bash $DIR1/$tdir/bash
590 /bin/sh -c 'sleep 1; rm -f $DIR2/$tdir/bash; cp /bin/bash $DIR2/$tdir' &
591 err=$($DIR1/$tdir/bash -c 'sleep 2; openfile -f O_RDONLY /proc/$$/exe >& /dev/null; echo $?')
593 [ $err -ne 116 ] && error_ignore 12900 "return code ($err) != -ESTALE" && return
597 run_test 30 "recreate file race ========="
600 mkdir -p $DIR1/$tdir || error "Creating dir $DIR1/$tdir"
601 writes=`LANG=C dd if=/dev/zero of=$DIR/$tdir/$tfile count=1 2>&1 |
602 awk 'BEGIN { FS="+" } /out/ {print $1}'`
603 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
604 lctl set_param fail_loc=0x314
605 reads=`LANG=C dd if=$DIR2/$tdir/$tfile of=/dev/null 2>&1 |
606 awk 'BEGIN { FS="+" } /in/ {print $1}'`
607 [ $reads -eq $writes ] || error "read" $reads "blocks, must be" $writes
609 run_test 31a "voluntary cancel / blocking ast race=============="
612 remote_ost || { skip "local OST" && return 0; }
613 remote_ost_nodsh && skip "remote OST w/o dsh" && return 0
614 mkdir -p $DIR1/$tdir || error "Creating dir $DIR1/$tdir"
615 lfs setstripe $DIR/$tdir/$tfile -i 0 -c 1
616 cp /etc/hosts $DIR/$tdir/$tfile
617 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
618 lctl set_param fail_loc=0x314
619 #define OBD_FAIL_LDLM_OST_FAIL_RACE 0x316
620 do_facet ost1 lctl set_param fail_loc=0x316
622 cat $DIR2/$tdir/$tfile > /dev/null 2>&1
623 lctl set_param fail_loc=0
624 do_facet ost1 lctl set_param fail_loc=0
626 run_test 31b "voluntary OST cancel / blocking ast race=============="
628 # enable/disable lockless truncate feature, depending on the arg 0/1
629 enable_lockless_truncate() {
630 lctl set_param -n osc.*.lockless_truncate $1
633 test_32a() { # bug 11270
634 local p="$TMP/sanityN-$TESTNAME.parameters"
635 save_lustre_params $HOSTNAME osc.*.lockless_truncate > $p
637 enable_lockless_truncate 1
639 lfs setstripe -c -1 $DIR1/$tfile
640 dd if=/dev/zero of=$DIR1/$tfile count=10 bs=1M > /dev/null 2>&1
643 log "checking cached lockless truncate"
644 $TRUNCATE $DIR1/$tfile 8000000
645 $CHECKSTAT -s 8000000 $DIR2/$tfile || error "wrong file size"
646 [ $(calc_osc_stats lockless_truncate) -eq 0 ] ||
647 error "lockless truncate doesn't use cached locks"
649 log "checking not cached lockless truncate"
650 $TRUNCATE $DIR2/$tfile 5000000
651 $CHECKSTAT -s 5000000 $DIR1/$tfile || error "wrong file size"
652 [ $(calc_osc_stats lockless_truncate) -ne 0 ] ||
653 error "not cached trancate isn't lockless"
655 log "disabled lockless truncate"
656 enable_lockless_truncate 0
658 $TRUNCATE $DIR2/$tfile 3000000
659 $CHECKSTAT -s 3000000 $DIR1/$tfile || error "wrong file size"
660 [ $(calc_osc_stats lockless_truncate) -eq 0 ] ||
661 error "lockless truncate disabling failed"
663 # restore lockless_truncate default values
664 restore_lustre_params < $p
667 run_test 32a "lockless truncate"
669 test_32b() { # bug 11270
670 remote_ost_nodsh && skip "remote OST with nodsh" && return
673 local p="$TMP/sanityN-$TESTNAME.parameters"
674 save_lustre_params $HOSTNAME "osc.*.contention_seconds" > $p
675 for node in $(osts_nodes); do
676 save_lustre_params $node "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
677 save_lustre_params $node "ldlm.namespaces.filter-*.contended_locks" >> $p
678 save_lustre_params $node "ldlm.namespaces.filter-*.contention_seconds" >> $p
681 # agressive lockless i/o settings
682 for node in $(osts_nodes); do
683 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'
685 lctl set_param -n osc.*.contention_seconds 60
686 for i in $(seq 5); do
687 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > /dev/null 2>&1
688 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > /dev/null 2>&1
690 [ $(calc_osc_stats lockless_write_bytes) -ne 0 ] || error "lockless i/o was not triggered"
691 # disable lockless i/o (it is disabled by default)
692 for node in $(osts_nodes); do
693 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'
695 # set contention_seconds to 0 at client too, otherwise Lustre still
696 # remembers lock contention
697 lctl set_param -n osc.*.contention_seconds 0
699 for i in $(seq 1); do
700 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > /dev/null 2>&1
701 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > /dev/null 2>&1
703 [ $(calc_osc_stats lockless_write_bytes) -eq 0 ] ||
704 error "lockless i/o works when disabled"
706 restore_lustre_params <$p
709 run_test 32b "lockless i/o"
712 local dev=$(basename $(do_facet $SINGLEMDS lctl get_param -n osd.*MDT*.mntdev))
713 do_facet $SINGLEMDS cat /proc/fs/jbd/$dev/info | head -1
719 local start_ts=`date +%s`
723 current_ts=`date +%s`
724 ELAPSED=`expr $current_ts - $start_ts`
727 # commit on sharing tests
729 remote_mds_nodsh && skip "remote MDS with nodsh" && return
731 [ -n "$CLIENTS" ] || { skip "Need two or more clients" && return 0; }
732 [ $CLIENTCOUNT -ge 2 ] || \
733 { skip "Need two or more clients, have $CLIENTCOUNT" && return 0; }
735 zconf_mount_clients $CLIENT1,$CLIENT2 $DIR1
736 zconf_mount_clients $CLIENT1,$CLIENT2 $DIR2
738 local nfiles=${TEST33_NFILES:-10000}
739 local param_file=$TMP/$tfile-params
741 save_lustre_params $(facet_active_host $SINGLEMDS) "mdt.*.commit_on_sharing" > $param_file
749 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
754 do_nodes $CLIENT1,$CLIENT2 "mkdir -p $DIR1/$tdir-\\\$(hostname)-$i"
756 jbdold=$(print_jbd_stat)
757 echo "=== START createmany $jbdold"
758 do_and_time "do_nodes $CLIENT1,$CLIENT2 createmany -o $DIR1/$tdir-\\\$(hostname)-$i/f- -r $DIR2/$tdir-\\\$(hostname)-$i/f- $nfiles"
759 jbdnew=$(print_jbd_stat)
760 jbd=$((`echo $jbdnew | cut -d" " -f1` - `echo $jbdold | cut -d" " -f1`))
761 echo "=== END createmany $jbdnew : $jbd transactions nfiles $nfiles time $ELAPSED COS=$COS"
762 avgjbd=$(( avgjbd + jbd ))
763 avgtime=$(( avgtime + ELAPSED ))
765 eval cos${COS}_jbd=$((avgjbd / 3))
766 eval cos${COS}_time=$((avgtime / 3))
769 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
770 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
771 [ "$cos0_jbd" != 0 ] && echo "COS=1 vs COS=0 jbd: $((((cos1_jbd/cos0_jbd - 1)) * 100 )) %"
772 [ "$cos0_time" != 0 ] && echo "COS=1 vs COS=0 time: $((((cos1_time/cos0_time - 1)) * 100 )) %"
774 restore_lustre_params < $param_file
778 run_test 33a "commit on sharing, cross crete/delete, 2 clients, benchmark"
780 # End commit on sharing tests
786 for OPER in notimeout timeout ; do
787 rm $DIR1/$tfile 2>/dev/null
788 lock_in=$(do_nodes $(osts_nodes) "lctl get_param -n ldlm.namespaces.filter-*.lock_timeouts" | calc_sum)
789 if [ $OPER == "timeout" ] ; then
790 for j in `seq $OSTCOUNT`; do
791 #define OBD_FAIL_PTLRPC_HPREQ_TIMEOUT 0x511
792 do_facet ost$j lctl set_param fail_loc=0x511
794 echo lock should expire
796 for j in `seq $OSTCOUNT`; do
797 #define OBD_FAIL_PTLRPC_HPREQ_NOTIMEOUT 0x512
798 do_facet ost$j lctl set_param fail_loc=0x512
800 echo lock should not expire
802 echo writing on client1
803 dd if=/dev/zero of=$DIR1/$tfile count=100 conv=notrunc > /dev/null 2>&1
805 echo reading on client2
806 dd of=/dev/null if=$DIR2/$tfile > /dev/null 2>&1
807 # wait for a lock timeout
809 lock_out=$(do_nodes $(osts_nodes) "lctl get_param -n ldlm.namespaces.filter-*.lock_timeouts" | calc_sum)
810 if [ $OPER == "timeout" ] ; then
811 if [ $lock_in == $lock_out ]; then
812 error "no lock timeout happened"
817 if [ $lock_in != $lock_out ]; then
818 error "lock timeout happened"
825 run_test 34 "no lock timeout under IO"
827 test_35() { # bug 17645
830 for imp in /proc/fs/lustre/mdc/$FSNAME-MDT*-mdc-*; do
831 g=$(awk '/generation/{print $2}' $imp/import)
836 mkdir -p $MOUNT1/$tfile
839 # Let's initiate -EINTR situation by setting fail_loc and take
840 # write lock on same file from same client. This will not cause
841 # bl_ast yet as lock is already in local cache.
842 #define OBD_FAIL_LDLM_INTR_CP_AST 0x317
843 do_facet client "lctl set_param fail_loc=0x80000317"
844 local timeout=`do_facet $SINGLEMDS lctl get_param -n timeout`
845 let timeout=timeout*3
847 while test $nr -lt 10; do
848 log "Race attempt $nr"
849 local blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
850 test "x$blk1" = "x" && blk1=0
851 createmany -o $MOUNT2/$tfile/a 4000 &
855 # Let's make conflict and bl_ast
856 ls -la $MOUNT1/$tfile > /dev/null &
859 log "Wait for $pid1 $pid2 for $timeout sec..."
861 kill -9 $pid1 $pid2 > /dev/null 2>&1
863 local blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
864 test "x$blk2" = "x" && blk2=0
865 test $blk2 -gt $blk1 && break
866 rm -fr $MOUNT1/$tfile/*
870 do_facet client "lctl set_param fail_loc=0x0"
871 df -h $MOUNT1 $MOUNT2
873 for imp in /proc/fs/lustre/mdc/$FSNAME-MDT*-mdc-*; do
874 g=$(awk '/generation/{print $2}' $imp/import)
875 if ! test "$g" -eq "${generation[count]}"; then
876 error "Eviction happened on import $(basename $imp)"
881 run_test 35 "-EINTR cp_ast vs. bl_ast race does not evict client"
883 test_36() { #bug 16417
889 $LFS setstripe -c -1 $DIR1/$tdir
892 let SIZE_B=SIZE*1024*1024
894 while [ $i -le 10 ]; do
895 lctl mark "start test"
896 local before=$($LFS df | awk '{if ($1 ~/^filesystem/) {print $5; exit} }')
897 dd if=/dev/zero of=$DIR1/$tdir/file000 bs=1M count=$SIZE
900 local after_dd=$($LFS df | awk '{if ($1 ~/^filesystem/) {print $5; exit} }')
901 multiop_bg_pause $DIR2/$tdir/file000 O_r${SIZE_B}c || return 3
903 rm -f $DIR1/$tdir/file000
907 local after=$($LFS df | awk '{if ($1 ~/^filesystem/) {print $5; exit} }')
908 echo "*** cycle($i) *** before($before):after_dd($after_dd):after($after)"
909 # this free space! not used
910 if [ $after_dd -ge $after ]; then
917 run_test 36 "handle ESTALE/open-unlink corectly"
919 log "cleanup: ======================================================"
921 check_and_cleanup_lustre
923 echo '=========================== finished ==============================='
924 [ -f "$SANITYLOG" ] && cat $SANITYLOG && grep -q FAIL $SANITYLOG && exit 1 || true