6 # bug number for skipped test: 3192 12652 15528/3811 16929 9977 15528/11549 18080
7 ALWAYS_EXCEPT=" 14b 14c 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"
17 PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH
20 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
21 GETSTRIPE=${GETSTRIPE:-lfs getstripe}
22 SETSTRIPE=${SETSTRIPE:-lstripe}
23 MCREATE=${MCREATE:-mcreate}
24 OPENFILE=${OPENFILE:-openfile}
25 OPENUNLINK=${OPENUNLINK:-openunlink}
26 TRUNCATE=${TRUNCATE:-truncate}
27 export TMP=${TMP:-/tmp}
28 MOUNT_2=${MOUNT_2:-"yes"}
29 CHECK_GRANT=${CHECK_GRANT:-"yes"}
30 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
34 export NAME=${NAME:-local}
36 LUSTRE=${LUSTRE:-`dirname $0`/..}
37 . $LUSTRE/tests/test-framework.sh
41 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
43 [ "$SLOW" = "no" ] && EXCEPT_SLOW="12 16"
45 SANITYLOG=${TESTSUITELOG:-$TMP/$(basename $0 .sh).log}
46 FAIL_ON_ERROR=${FAIL_ON_ERROR:-false}
51 [ "$SANITYLOG" ] && rm -f $SANITYLOG || true
53 check_and_setup_lustre
55 LOVNAME=`lctl get_param -n llite.*.lov.common_name | tail -n 1`
56 OSTCOUNT=`lctl get_param -n lov.$LOVNAME.numobd`
59 rm -rf $DIR1/[df][0-9]* $DIR1/lnk
61 # $RUNAS_ID may get set incorrectly somewhere else
62 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
64 check_runas_id $RUNAS_ID $RUNAS_ID $RUNAS
70 [ -f $DIR2/f1 ] || error
72 run_test 1a "check create on 2 mtpt's =========================="
76 $CHECKSTAT -t file -p 0777 $DIR1/f1 || error
79 run_test 1b "check attribute updates on 2 mtpt's ==============="
82 $CHECKSTAT -t file -p 0666 $DIR1/f1 || error
84 run_test 1c "check after remount attribute updates on 2 mtpt's ="
88 $CHECKSTAT -a $DIR1/f1 || error
90 run_test 1d "unlink on one mountpoint removes file on other ===="
96 $CHECKSTAT -t file -p 0777 $DIR1/f2a || error
98 run_test 2a "check cached attribute updates on 2 mtpt's ========"
104 $CHECKSTAT -t file -p 0777 $DIR2/f2b || error
106 run_test 2b "check cached attribute updates on 2 mtpt's ========"
108 # NEED TO SAVE ROOT DIR MODE
111 $CHECKSTAT -t dir -p 0777 $DIR2 || error
113 run_test 2c "check cached attribute updates on 2 mtpt's root ==="
117 $CHECKSTAT -t dir -p 0755 $DIR2 || error
119 run_test 2d "check cached attribute updates on 2 mtpt's root ==="
126 $RUNAS dd if=/dev/zero of=$DIR2/$tfile count=1 || error
128 run_test 2e "check chmod on root is propagated to others"
131 ( cd $DIR1 ; ln -s this/is/good $tfile )
132 [ "this/is/good" = "`perl -e 'print readlink("'$DIR2/$tfile'");'`" ] ||
133 error "link $DIR2/$tfile not as expected"
135 run_test 3 "symlink on one mtpt, readlink on another ==========="
138 multifstat $DIR1/f4 $DIR2/f4
140 run_test 4 "fstat validation on multiple mount points =========="
144 truncate $DIR2/f5 100
145 $CHECKSTAT -t file -s 100 $DIR1/f5 || error
148 run_test 5 "create a file on one mount, truncate it on the other"
151 openunlink $DIR1/$tfile $DIR2/$tfile || \
152 error "openunlink $DIR1/$tfile $DIR2/$tfile"
154 run_test 6 "remove of open file on other node =================="
158 opendirunlink $DIR1/$dir $DIR2/$dir || \
159 error "opendirunlink $DIR1/$dir $DIR2/$dir"
161 run_test 7 "remove of open directory on other node ============="
164 opendevunlink $DIR1/$tfile $DIR2/$tfile || \
165 error "opendevunlink $DIR1/$tfile $DIR2/$tfile"
167 run_test 8 "remove of open special file on other node =========="
173 for C in a b c d e f g h i j k l; do
174 dir=`eval echo \\$DIR$MTPT`
175 echo -n $C >> $dir/f9
176 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
178 [ "`cat $DIR1/f9`" = "abcdefghijkl" ] || \
179 error "`od -a $DIR1/f9` != abcdefghijkl"
181 run_test 9 "append of file with sub-page size on multiple mounts"
188 for C in a b c d e f g h i j k l; do
189 dir=`eval echo \\$DIR$MTPT`
190 echo -n $C | dd of=$dir/f10 bs=1 seek=$OFFSET count=1
191 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
192 OFFSET=`expr $OFFSET + 1`
194 [ "`cat $DIR1/f10`" = "abcdefghijkl" ] || \
195 error "`od -a $DIR1/f10` != abcdefghijkl"
197 run_test 10a "write of file with sub-page size on multiple mounts "
201 yes "R" | head -c 4000 >$TMP/f10b-seed
202 dd if=$TMP/f10b-seed of=$DIR1/f10b bs=3k count=1 || error "dd $DIR1"
204 truncate $DIR1/f10b 4096 || error "truncate 4096"
206 dd if=$DIR2/f10b of=$TMP/f10b-lustre bs=4k count=1 || error "dd $DIR2"
208 # create a test file locally to compare
209 dd if=$TMP/f10b-seed of=$TMP/f10b bs=3k count=1 || error "dd random"
210 truncate $TMP/f10b 4096 || error "truncate 4096"
211 cmp $TMP/f10b $TMP/f10b-lustre || error "file miscompare"
212 rm $TMP/f10b $TMP/f10b-lustre $TMP/f10b-seed
214 run_test 10b "write of file with sub-page size on multiple mounts "
218 multiop_bg_pause $DIR1/d11/f O_c || return 1
220 cp -p /bin/ls $DIR1/d11/f
224 wait $MULTIPID || error
225 [ $RC -eq 0 ] && error || true
227 run_test 11 "execution of file opened for write should return error ===="
230 DIR=$DIR DIR2=$DIR2 sh lockorder.sh
232 run_test 12 "test lock ordering (link, stat, unlink) ==========="
234 test_13() { # bug 2451 - directory coherency
236 mkdir $DIR1/d13 || error
237 cd $DIR1/d13 || error
239 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
241 rm -f $DIR2/d13/f13 || error
242 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (1)" || true
243 # need to run it twice
244 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
246 rm -f $DIR2/d13/f13 || error
247 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (2)" || true
249 run_test 13 "test directory page revocation ===================="
253 cp -p /bin/ls $DIR1/$tdir/$tfile
254 multiop_bg_pause $DIR1/$tdir/$tfile Ow_c || return 1
257 $DIR2/$tdir/$tfile && error || true
259 wait $MULTIPID || return 2
261 run_test 14 "execution of file open for write returns -ETXTBSY ="
265 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
266 MULTIOP_PROG=$DIR1/d14/multiop multiop_bg_pause $TMP/test14.junk O_c || return 1
268 multiop $DIR2/d14/multiop Oc && error "expected error, got success"
269 kill -USR1 $MULTIOP_PID || return 2
270 wait $MULTIOP_PID || return 3
271 rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop"
273 run_test 14a "open(RDWR) of executing file returns -ETXTBSY ===="
275 test_14b() { # bug 3192, 7040
277 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
278 MULTIOP_PROG=$DIR1/d14/multiop multiop_bg_pause $TMP/test14.junk O_c || return 1
280 truncate $DIR2/d14/multiop 0 && kill -9 $MULTIOP_PID && \
281 error "expected truncate error, got success"
282 kill -USR1 $MULTIOP_PID || return 2
283 wait $MULTIOP_PID || return 3
284 cmp `which multiop` $DIR1/d14/multiop || error "binary changed"
285 rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop"
287 run_test 14b "truncate of executing file returns -ETXTBSY ======"
289 test_14c() { # bug 3430, 7040
291 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
292 MULTIOP_PROG=$DIR1/d14/multiop multiop_bg_pause $TMP/test14.junk O_c || return 1
294 cp /etc/hosts $DIR2/d14/multiop && error "expected error, got success"
295 kill -USR1 $MULTIOP_PID || return 2
296 wait $MULTIOP_PID || return 3
297 cmp `which multiop` $DIR1/d14/multiop || error "binary changed"
298 rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop"
300 run_test 14c "open(O_TRUNC) of executing file return -ETXTBSY =="
302 test_14d() { # bug 10921
304 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
305 MULTIOP_PROG=$DIR1/d14/multiop multiop_bg_pause $TMP/test14.junk O_c || return 1
308 chmod 600 $DIR1/d14/multiop || error "chmod failed"
309 kill -USR1 $MULTIOP_PID || return 2
310 wait $MULTIOP_PID || return 3
311 cmp `which multiop` $DIR1/d14/multiop || error "binary changed"
312 rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop"
314 run_test 14d "chmod of executing file is still possible ========"
316 test_15() { # bug 974 - ENOSPC
318 sh oos2.sh $MOUNT1 $MOUNT2
319 grant_error=`dmesg | grep "> available"`
320 [ -z "$grant_error" ] || error "$grant_error"
322 run_test 15 "test out-of-space with multiple writers ==========="
325 rm -f $MOUNT1/fsxfile
326 lfs setstripe $MOUNT1/fsxfile -c -1 # b=10919
327 fsx -c 50 -p 100 -N 2500 -l $((SIZE * 256)) -S 0 $MOUNT1/fsxfile $MOUNT2/fsxfile
329 run_test 16 "2500 iterations of dual-mount fsx ================="
331 test_17() { # bug 3513, 3667
332 remote_ost_nodsh && skip "remote OST with nodsh" && return
334 lfs setstripe $DIR1/$tfile -i 0 -c 1
335 cp /etc/termcap $DIR1/$tfile
336 cancel_lru_locks osc > /dev/null
337 #define OBD_FAIL_ONCE|OBD_FAIL_LDLM_CREATE_RESOURCE 0x30a
338 do_facet ost1 lctl set_param fail_loc=0x8000030a
339 ls -ls $DIR1/$tfile | awk '{ print $1,$6 }' > $DIR1/$tfile-1 & \
340 ls -ls $DIR2/$tfile | awk '{ print $1,$6 }' > $DIR2/$tfile-2
342 diff -u $DIR1/$tfile-1 $DIR2/$tfile-2 || error "files are different"
344 run_test 17 "resource creation/LVB creation race ==============="
347 ./mmap_sanity -d $MOUNT1 -m $MOUNT2
350 run_test 18 "mmap sanity check ================================="
352 test_19() { # bug3811
353 [ -d /proc/fs/lustre/obdfilter ] || return 0
355 MAX=`lctl get_param -n obdfilter.*.readcache_max_filesize | head -n 1`
356 lctl set_param -n obdfilter.*OST*.readcache_max_filesize=4096
357 dd if=/dev/urandom of=$TMP/f19b bs=512k count=32
358 SUM=`cksum $TMP/f19b | cut -d" " -f 1,2`
359 cp $TMP/f19b $DIR1/f19b
360 for i in `seq 1 20`; do
361 [ $((i % 5)) -eq 0 ] && log "test_18 loop $i"
362 cancel_lru_locks osc > /dev/null
363 cksum $DIR1/f19b | cut -d" " -f 1,2 > $TMP/sum1 & \
364 cksum $DIR2/f19b | cut -d" " -f 1,2 > $TMP/sum2
366 [ "`cat $TMP/sum1`" = "$SUM" ] || \
367 error "$DIR1/f19b `cat $TMP/sum1` != $SUM"
368 [ "`cat $TMP/sum2`" = "$SUM" ] || \
369 error "$DIR2/f19b `cat $TMP/sum2` != $SUM"
371 lctl set_param -n obdfilter.*OST*.readcache_max_filesize=$MAX
374 run_test 19 "test concurrent uncached read races ==============="
379 CNT=$((`lctl get_param -n llite.*.dump_page_cache | wc -l`))
380 multiop $DIR1/f20 Ow8190c
381 multiop $DIR2/f20 Oz8194w8190c
382 multiop $DIR1/f20 Oz0r8190c
384 CNTD=$((`lctl get_param -n llite.*.dump_page_cache | wc -l` - $CNT))
386 error $CNTD" page left in cache after lock cancel" || true
388 run_test 20 "test extra readahead page left in cache ===="
395 test_21() { # Bug 5907
397 mount /etc $DIR1/d21 --bind || error "mount failed" # Poor man's mount.
399 rmdir -v $DIR1/d21 && error "Removed mounted directory"
400 rmdir -v $DIR2/d21 && echo "Removed mounted directory from another mountpoint, needs to be fixed"
401 test -d $DIR1/d21 || error "Mounted directory disappeared"
403 test -d $DIR2/d21 || test -d $DIR1/d21 && error "Removed dir still visible after umount"
406 run_test 21 " Try to remove mountpoint on another dir ===="
408 JOIN=${JOIN:-"lfs join"}
410 test_22() { # Bug 9926
412 dd if=/dev/urandom of=$DIR1/d21/128k bs=1024 count=128
413 cp -p $DIR1/d21/128k $DIR1/d21/f_head
414 for ((i=0;i<10;i++)); do
415 cp -p $DIR1/d21/128k $DIR1/d21/f_tail
416 $JOIN $DIR1/d21/f_head $DIR1/d21/f_tail || error "join error"
417 $CHECKSTAT -a $DIR1/d21/f_tail || error "tail file exist after join"
419 echo aaaaaaaaaaa >> $DIR1/d21/no_joined
421 mv $DIR2/d21/f_head $DIR2/
422 munlink $DIR2/f_head || error "unlink joined file error"
423 cat $DIR2/d21/no_joined || error "cat error"
424 rm -rf $DIR2/d21/no_joined || error "unlink normal file error"
426 run_test 22 " After joining in one dir, open/close unlink file in anther dir"
428 test_23() { # Bug 5972
429 echo "others should see updated atime while another read" > $DIR1/f23
431 # clear the lock(mode: LCK_PW) gotten from creating operation
437 multiop_bg_pause $DIR1/f23 or20_c || return 1
440 time2=`stat -c "%X" $DIR2/f23`
442 if (( $time2 <= $time1 )); then
444 error "atime doesn't update among nodes"
447 kill -USR1 $MULTIPID || return 1
448 rm -f $DIR1/f23 || error "rm -f $DIR1/f23 failed"
451 run_test 23 " others should see updated atime while another read===="
455 lfs df || error "lfs df failed"
456 lfs df -ih || error "lfs df -ih failed"
457 lfs df -h $DIR1 || error "lfs df -h $DIR1 failed"
458 lfs df -i $DIR2 || error "lfs df -i $DIR2 failed"
459 lfs df $DIR1/$tfile || error "lfs df $DIR1/$tfile failed"
460 lfs df -ih $DIR2/$tfile || error "lfs df -ih $DIR2/$tfile failed"
462 OSC=`lctl dl | awk '/-osc-|OSC.*MNT/ {print $4}' | head -n 1`
463 lctl --device %$OSC deactivate
464 lfs df -i || error "lfs df -i with deactivated OSC failed"
465 lctl --device %$OSC recover
466 lfs df || error "lfs df with reactivated OSC failed"
468 run_test 24 "lfs df [-ih] [path] test ========================="
471 [ `lctl get_param -n mdc.*-mdc-*.connect_flags | grep -c acl` -lt 2 ] && \
472 skip "must have acl, skipping" && return
475 touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
476 chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
478 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
479 setfacl -m u:$RUNAS_ID:--- $DIR1/$tdir || error "setfacl $DIR2/$tdir #1"
480 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
481 setfacl -m u:$RUNAS_ID:r-x $DIR1/$tdir || error "setfacl $DIR2/$tdir #2"
482 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
483 setfacl -m u:$RUNAS_ID:--- $DIR1/$tdir || error "setfacl $DIR2/$tdir #3"
484 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
485 setfacl -x u:$RUNAS_ID: $DIR1/$tdir || error "setfacl $DIR2/$tdir #4"
486 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
490 run_test 25 "change ACL on one mountpoint be seen on another ==="
493 utime $DIR1/f26a -s $DIR2/f26a || error
495 run_test 26a "allow mtime to get older"
500 echo "aaa" >> $DIR1/$tfile
502 chmod a+x $DIR2/$tfile
503 mt1=`stat -c %Y $DIR1/$tfile`
504 mt2=`stat -c %Y $DIR2/$tfile`
506 if [ x"$mt1" != x"$mt2" ]; then
507 error "not equal mtime, client1: "$mt1", client2: "$mt2"."
510 run_test 26b "sync mtime between ost and mds"
515 dd if=/dev/zero of=$DIR2/$tfile bs=$((4096+4))k conv=notrunc count=4 seek=3 &
520 dd if=/dev/zero of=$DIR1/$tfile bs=$((16384-1024))k conv=notrunc count=1 seek=4 &
525 dd if=/dev/zero of=$DIR1/$tfile bs=8k conv=notrunc count=1 seek=0
527 lctl set_param -n ldlm.dump_namespaces ""
528 wait $DD1_PID $DD2_PID
529 [ $? -ne 0 ] && lctl dk $TMP/debug || true
531 run_test 27 "align non-overlapping extent locks from request ==="
533 test_28() { # bug 9977
534 ostID=`$LCTL dl | awk '/-osc-|OSC.*MNT/ { ost++; if (ost == 2) { print $1 } }'`
536 lfs setstripe $DIR1/$tfile -s 1048576 -i 0 -c 2
537 tOBJID=`lfs getstripe $DIR1/$tfile | awk '/^[[:space:]]+1/ {print $2}'`
538 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2
540 $LCTL --device $ostID destroy "${tOBJID}"
542 # reading of 1st stripe should pass
543 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error
544 # reading of 2nd stripe should fail (this stripe was destroyed)
545 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 && error
547 # now, recreating test file
548 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2 || error
549 # reading of 1st stripe should pass
550 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error
551 # reading of 2nd stripe should pass
552 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 || error
554 run_test 28 "read/write/truncate file with lost stripes"
556 test_29() { # bug 10999
558 #define OBD_FAIL_LDLM_GLIMPSE 0x30f
559 lctl set_param fail_loc=0x8000030f
562 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1
565 #bug 11549 - permanently turn test off in b1_5
566 run_test 29 "lock put race between glimpse and enqueue ========="
568 test_30() { #bug #11110
570 cp -f /bin/bash $DIR1/$tdir/bash
571 /bin/sh -c 'sleep 1; rm -f $DIR2/$tdir/bash; cp /bin/bash $DIR2/$tdir' &
572 err=$($DIR1/$tdir/bash -c 'sleep 2; openfile -f O_RDONLY /proc/$$/exe >& /dev/null; echo $?')
574 [ $err -ne 116 ] && error_ignore 12900 "return code ($err) != -ESTALE" && return
578 run_test 30 "recreate file race ========="
581 mkdir -p $DIR1/$tdir || error "Creating dir $DIR1/$tdir"
582 writes=`LANG=C dd if=/dev/zero of=$DIR/$tdir/$tfile count=1 2>&1 |
583 awk 'BEGIN { FS="+" } /out/ {print $1}'`
584 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
585 lctl set_param fail_loc=0x314
586 reads=`LANG=C dd if=$DIR2/$tdir/$tfile of=/dev/null 2>&1 |
587 awk 'BEGIN { FS="+" } /in/ {print $1}'`
588 [ $reads -eq $writes ] || error "read" $reads "blocks, must be" $writes
590 run_test 31a "voluntary cancel / blocking ast race=============="
593 remote_ost || { skip "local OST" && return 0; }
594 remote_ost_nodsh && skip "remote OST w/o dsh" && return 0
595 mkdir -p $DIR1/$tdir || error "Creating dir $DIR1/$tdir"
596 lfs setstripe $DIR/$tdir/$tfile -i 0 -c 1
597 cp /etc/hosts $DIR/$tdir/$tfile
598 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
599 lctl set_param fail_loc=0x314
600 #define OBD_FAIL_LDLM_OST_FAIL_RACE 0x316
601 do_facet ost1 lctl set_param fail_loc=0x316
603 cat $DIR2/$tdir/$tfile > /dev/null 2>&1
604 lctl set_param fail_loc=0
605 do_facet ost1 lctl set_param fail_loc=0
607 run_test 31b "voluntary OST cancel / blocking ast race=============="
609 # enable/disable lockless truncate feature, depending on the arg 0/1
610 enable_lockless_truncate() {
611 lctl set_param -n llite.*.lockless_truncate $1
614 test_32a() { # bug 11270
615 local p="$TMP/sanityN-$TESTNAME.parameters"
616 save_lustre_params $HOSTNAME llite.*.lockless_truncate > $p
619 enable_lockless_truncate 1
620 lfs setstripe -c -1 -s 1m $DIR1/$tfile
621 dd if=/dev/zero of=$DIR1/$tfile count=10 bs=1M > /dev/null 2>&1
624 log "checking cached lockless truncate"
625 $TRUNCATE $DIR1/$tfile 8000000
626 $CHECKSTAT -s 8000000 $DIR2/$tfile || error "wrong file size"
627 [ $(calc_llite_stats lockless_truncate) -eq 0 ] ||
628 error "lockless truncate doesn't use cached locks"
630 log "checking not cached lockless truncate"
631 $TRUNCATE $DIR2/$tfile 5000000
632 $CHECKSTAT -s 5000000 $DIR1/$tfile || error "wrong file size"
633 [ $(calc_llite_stats lockless_truncate) -ne 0 ] ||
634 error "not cached trancate isn't lockless"
636 log "disabled lockless truncate"
637 enable_lockless_truncate 0
639 $TRUNCATE $DIR2/$tfile 3000000
640 $CHECKSTAT -s 3000000 $DIR1/$tfile || error "wrong file size"
641 [ $(calc_llite_stats lockless_truncate) -eq 0 ] ||
642 error "lockless truncate disabling failed"
644 # restore lockless_truncate default values
645 restore_lustre_params < $p
648 run_test 32a "lockless truncate"
650 test_32b() { # bug 11270
651 remote_ost_nodsh && skip "remote OST with nodsh" && return
654 local p="$TMP/sanityN-$TESTNAME.parameters"
655 save_lustre_params $HOSTNAME "llite.*.contention_seconds" > $p
656 for node in $(osts_nodes); do
657 save_lustre_params $node "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
658 save_lustre_params $node "ldlm.namespaces.filter-*.contended_locks" >> $p
659 save_lustre_params $node "ldlm.namespaces.filter-*.contention_seconds" >> $p
662 # agressive lockless i/o settings
663 for node in $(osts_nodes); do
664 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'
666 lctl set_param -n llite.*.contention_seconds 60
667 for i in $(seq 5); do
668 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > /dev/null 2>&1
669 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > /dev/null 2>&1
671 [ $(calc_llite_stats lockless_write_bytes) -ne 0 ] || error "lockless i/o was not triggered"
672 # disable lockless i/o (it is disabled by default)
673 for node in $(osts_nodes); do
674 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'
676 # set contention_seconds to 0 at client too, otherwise Lustre still
677 # remembers lock contention
678 lctl set_param -n llite.*.contention_seconds 0
680 for i in $(seq 5); do
681 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > /dev/null 2>&1
682 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > /dev/null 2>&1
684 [ $(calc_llite_stats lockless_write_bytes) -eq 0 ] ||
685 error "lockless i/o works when disabled"
687 restore_lustre_params <$p
690 run_test 32b "lockless i/o"
696 for OPER in notimeout timeout ; do
697 rm $DIR1/$tfile 2>/dev/null
698 lock_in=$(do_nodes $(osts_nodes) "lctl get_param -n ldlm.namespaces.filter-*.lock_timeouts" | calc_sum)
699 if [ $OPER == "timeout" ] ; then
700 for j in `seq $OSTCOUNT`; do
701 #define OBD_FAIL_PTLRPC_HPREQ_TIMEOUT 0x511
702 do_facet ost$j lctl set_param fail_loc=0x511
704 echo lock should expire
706 for j in `seq $OSTCOUNT`; do
707 #define OBD_FAIL_PTLRPC_HPREQ_NOTIMEOUT 0x512
708 do_facet ost$j lctl set_param fail_loc=0x512
710 echo lock should not expire
712 echo writing on client1
713 dd if=/dev/zero of=$DIR1/$tfile count=100 conv=notrunc > /dev/null 2>&1
715 echo reading on client2
716 dd of=/dev/null if=$DIR2/$tfile > /dev/null 2>&1
717 # wait for a lock timeout
719 lock_out=$(do_nodes $(osts_nodes) "lctl get_param -n ldlm.namespaces.filter-*.lock_timeouts" | calc_sum)
720 if [ $OPER == "timeout" ] ; then
721 if [ $lock_in == $lock_out ]; then
722 error "no lock timeout happened"
727 if [ $lock_in != $lock_out ]; then
728 error "lock timeout happened"
735 run_test 33 "no lock timeout under IO"
737 test_35() { # bug 17645
740 for imp in /proc/fs/lustre/mdc/$FSNAME-MDT*-mdc-*; do
741 g=$(awk '/generation/{print $2}' $imp/import)
746 mkdir -p $MOUNT1/$tfile
749 # Let's initiate -EINTR situation by setting fail_loc and take
750 # write lock on same file from same client. This will not cause
751 # bl_ast yet as lock is already in local cache.
752 #define OBD_FAIL_LDLM_INTR_CP_AST 0x317
753 do_facet client "lctl set_param fail_loc=0x80000317"
754 local timeout=`do_facet mds lctl get_param -n timeout`
755 let timeout=timeout*3
757 while test $nr -lt 10; do
758 log "Race attempt $nr"
759 local blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
760 test "x$blk1" = "x" && blk1=0
761 createmany -o $MOUNT2/$tfile/a 4000 &
765 # Let's make conflict and bl_ast
766 ls -la $MOUNT1/$tfile > /dev/null &
769 log "Wait for $pid1 $pid2 for $timeout sec..."
771 kill -9 $pid1 $pid2 > /dev/null 2>&1
773 local blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
774 test "x$blk2" = "x" && blk2=0
775 test $blk2 -gt $blk1 && break
776 rm -fr $MOUNT1/$tfile/*
780 do_facet client "lctl set_param fail_loc=0x0"
781 df -h $MOUNT1 $MOUNT2
783 for imp in /proc/fs/lustre/mdc/$FSNAME-MDT*-mdc-*; do
784 g=$(awk '/generation/{print $2}' $imp/import)
785 if ! test "$g" -eq "${generation[count]}"; then
786 error "Eviction happened on import $(basename $imp)"
791 run_test 35 "-EINTR cp_ast vs. bl_ast race does not evict client"
793 test_36() { #bug 16417
795 mkdir -p $MOUNT1/$tdir
796 lfs setstripe -c -1 $MOUNT1/$tdir
800 while [ $i -le 10 ]; do
801 lctl mark "start test"
802 before=$($LFS df | awk '{if ($1 ~/^filesystem/) {print $5; exit} }')
803 dd if=/dev/zero of=$MOUNT1/$tdir/file000 bs=1M count=$SIZE
804 dd if=$MOUNT2/$tdir/file000 of=/dev/null bs=1M count=$SIZE &
807 rm -f $MOUNT1/$tdir/file000
809 after=$($LFS df | awk '{if ($1 ~/^filesystem/) {print $5; exit} }')
810 if [ $before -gt $after ]; then
817 run_test 36 "handle ESTALE/open-unlink corectly"
819 test_37() { # bug 18695
821 multiop_bg_pause $DIR1/$tdir D_c || return 1
823 # create large directory (32kB seems enough from e2fsck, ~= 1000 files)
824 createmany -m $DIR2/$tdir/f 10000
825 # set mtime/atime backward
826 touch -t 198001010000 $DIR2/$tdir
828 nr_files=`lfs find $DIR1/$tdir -type f | wc -l`
829 [ $nr_files -eq 10000 ] || error "$nr_files != 10000 truncated directory?"
832 run_test 37 "check i_size is not updated for directory on close (bug 18695) =============="
834 log "cleanup: ======================================================"
836 check_and_cleanup_lustre
838 echo '=========================== finished ==============================='
839 [ -f "$SANITYLOG" ] && cat $SANITYLOG && grep -q FAIL $SANITYLOG && exit 1 || true