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 # It will be ported soon.
20 PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH
23 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
24 GETSTRIPE=${GETSTRIPE:-lfs getstripe}
25 SETSTRIPE=${SETSTRIPE:-lstripe}
26 MCREATE=${MCREATE:-mcreate}
27 OPENFILE=${OPENFILE:-openfile}
28 OPENUNLINK=${OPENUNLINK:-openunlink}
29 TRUNCATE=${TRUNCATE:-truncate}
30 export TMP=${TMP:-/tmp}
31 MOUNT_2=${MOUNT_2:-"yes"}
32 CHECK_GRANT=${CHECK_GRANT:-"yes"}
33 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
37 export NAME=${NAME:-local}
39 LUSTRE=${LUSTRE:-`dirname $0`/..}
40 . $LUSTRE/tests/test-framework.sh
44 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
47 [ "$SLOW" = "no" ] && EXCEPT_SLOW="12 16 23 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_GID $RUNAS
77 [ -f $DIR2/f1 ] || error
79 run_test 1a "check create on 2 mtpt's =========================="
83 $CHECKSTAT -t file -p 0777 $DIR1/f1 || error
86 run_test 1b "check attribute updates on 2 mtpt's ==============="
89 $CHECKSTAT -t file -p 0666 $DIR1/f1 || error
91 run_test 1c "check after remount attribute updates on 2 mtpt's ="
95 $CHECKSTAT -a $DIR1/f1 || error
97 run_test 1d "unlink on one mountpoint removes file on other ===="
103 $CHECKSTAT -t file -p 0777 $DIR1/f2a || error
105 run_test 2a "check cached attribute updates on 2 mtpt's ========"
111 $CHECKSTAT -t file -p 0777 $DIR2/f2b || error
113 run_test 2b "check cached attribute updates on 2 mtpt's ========"
115 # NEED TO SAVE ROOT DIR MODE
118 $CHECKSTAT -t dir -p 0777 $DIR2 || error
120 run_test 2c "check cached attribute updates on 2 mtpt's root ==="
124 $CHECKSTAT -t dir -p 0755 $DIR2 || error
126 run_test 2d "check cached attribute updates on 2 mtpt's root ==="
133 $RUNAS dd if=/dev/zero of=$DIR2/$tfile count=1 || error
135 run_test 2e "check chmod on root is propagated to others"
138 ( cd $DIR1 ; ln -s this/is/good $tfile )
139 [ "this/is/good" = "`perl -e 'print readlink("'$DIR2/$tfile'");'`" ] ||
140 error "link $DIR2/$tfile not as expected"
142 run_test 3 "symlink on one mtpt, readlink on another ==========="
145 multifstat $DIR1/f4 $DIR2/f4
147 run_test 4 "fstat validation on multiple mount points =========="
151 truncate $DIR2/f5 100
152 $CHECKSTAT -t file -s 100 $DIR1/f5 || error
155 run_test 5 "create a file on one mount, truncate it on the other"
158 openunlink $DIR1/$tfile $DIR2/$tfile || \
159 error "openunlink $DIR1/$tfile $DIR2/$tfile"
161 run_test 6 "remove of open file on other node =================="
165 opendirunlink $DIR1/$dir $DIR2/$dir || \
166 error "opendirunlink $DIR1/$dir $DIR2/$dir"
168 run_test 7 "remove of open directory on other node ============="
171 opendevunlink $DIR1/$tfile $DIR2/$tfile || \
172 error "opendevunlink $DIR1/$tfile $DIR2/$tfile"
174 run_test 8 "remove of open special file on other node =========="
180 for C in a b c d e f g h i j k l; do
181 dir=`eval echo \\$DIR$MTPT`
182 echo -n $C >> $dir/f9
183 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
185 [ "`cat $DIR1/f9`" = "abcdefghijkl" ] || \
186 error "`od -a $DIR1/f9` != abcdefghijkl"
188 run_test 9 "append of file with sub-page size on multiple mounts"
195 for C in a b c d e f g h i j k l; do
196 dir=`eval echo \\$DIR$MTPT`
197 echo -n $C | dd of=$dir/f10 bs=1 seek=$OFFSET count=1
198 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
199 OFFSET=`expr $OFFSET + 1`
201 [ "`cat $DIR1/f10`" = "abcdefghijkl" ] || \
202 error "`od -a $DIR1/f10` != abcdefghijkl"
204 run_test 10a "write of file with sub-page size on multiple mounts "
208 yes "R" | head -c 4000 >$TMP/f10b-seed
209 dd if=$TMP/f10b-seed of=$DIR1/f10b bs=3k count=1 || error "dd $DIR1"
211 truncate $DIR1/f10b 4096 || error "truncate 4096"
213 dd if=$DIR2/f10b of=$TMP/f10b-lustre bs=4k count=1 || error "dd $DIR2"
215 # create a test file locally to compare
216 dd if=$TMP/f10b-seed of=$TMP/f10b bs=3k count=1 || error "dd random"
217 truncate $TMP/f10b 4096 || error "truncate 4096"
218 cmp $TMP/f10b $TMP/f10b-lustre || error "file miscompare"
219 rm $TMP/f10b $TMP/f10b-lustre $TMP/f10b-seed
221 run_test 10b "write of file with sub-page size on multiple mounts "
225 multiop_bg_pause $DIR1/d11/f O_c || return 1
227 cp -p /bin/ls $DIR1/d11/f
231 wait $MULTIPID || error
232 [ $RC -eq 0 ] && error || true
234 run_test 11 "execution of file opened for write should return error ===="
237 DIR=$DIR DIR2=$DIR2 sh lockorder.sh
239 run_test 12 "test lock ordering (link, stat, unlink) ==========="
241 test_13() { # bug 2451 - directory coherency
243 mkdir $DIR1/d13 || error
244 cd $DIR1/d13 || error
246 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
248 rm -f $DIR2/d13/f13 || error
249 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (1)" || true
250 # need to run it twice
251 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
253 rm -f $DIR2/d13/f13 || error
254 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (2)" || true
256 run_test 13 "test directory page revocation ===================="
260 cp -p /bin/ls $DIR1/$tdir/$tfile
261 multiop_bg_pause $DIR1/$tdir/$tfile Ow_c || return 1
264 $DIR2/$tdir/$tfile && error || true
266 wait $MULTIPID || return 2
268 run_test 14 "execution of file open for write returns -ETXTBSY ="
272 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
273 MULTIOP_PROG=$DIR1/d14/multiop multiop_bg_pause $TMP/test14.junk O_c || return 1
275 multiop $DIR2/d14/multiop Oc && error "expected error, got success"
276 kill -USR1 $MULTIOP_PID || return 2
277 wait $MULTIOP_PID || return 3
278 rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop"
280 run_test 14a "open(RDWR) of executing file returns -ETXTBSY ===="
282 test_14b() { # bug 3192, 7040
284 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
285 MULTIOP_PROG=$DIR1/d14/multiop multiop_bg_pause $TMP/test14.junk O_c || return 1
287 truncate $DIR2/d14/multiop 0 && kill -9 $MULTIOP_PID && \
288 error "expected truncate error, got success"
289 kill -USR1 $MULTIOP_PID || return 2
290 wait $MULTIOP_PID || return 3
291 cmp `which multiop` $DIR1/d14/multiop || error "binary changed"
292 rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop"
294 run_test 14b "truncate of executing file returns -ETXTBSY ======"
296 test_14c() { # bug 3430, 7040
298 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
299 MULTIOP_PROG=$DIR1/d14/multiop multiop_bg_pause $TMP/test14.junk O_c || return 1
301 cp /etc/hosts $DIR2/d14/multiop && error "expected error, got success"
302 kill -USR1 $MULTIOP_PID || return 2
303 wait $MULTIOP_PID || return 3
304 cmp `which multiop` $DIR1/d14/multiop || error "binary changed"
305 rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop"
307 run_test 14c "open(O_TRUNC) of executing file return -ETXTBSY =="
309 test_14d() { # bug 10921
311 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
312 MULTIOP_PROG=$DIR1/d14/multiop multiop_bg_pause $TMP/test14.junk O_c || return 1
315 chmod 600 $DIR1/d14/multiop || error "chmod failed"
316 kill -USR1 $MULTIOP_PID || return 2
317 wait $MULTIOP_PID || return 3
318 cmp `which multiop` $DIR1/d14/multiop || error "binary changed"
319 rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop"
321 run_test 14d "chmod of executing file is still possible ========"
323 test_15() { # bug 974 - ENOSPC
325 sh oos2.sh $MOUNT1 $MOUNT2
326 grant_error=`dmesg | grep "> available"`
327 [ -z "$grant_error" ] || error "$grant_error"
329 run_test 15 "test out-of-space with multiple writers ==========="
332 rm -f $MOUNT1/fsxfile
333 lfs setstripe $MOUNT1/fsxfile -c -1 # b=10919
334 fsx -c 50 -p 100 -N 2500 -l $((SIZE * 256)) -S 0 $MOUNT1/fsxfile $MOUNT2/fsxfile
336 run_test 16 "2500 iterations of dual-mount fsx ================="
338 test_17() { # bug 3513, 3667
339 remote_ost_nodsh && skip "remote OST with nodsh" && return
341 lfs setstripe $DIR1/$tfile -i 0 -c 1
342 cp /etc/termcap $DIR1/$tfile
343 cancel_lru_locks osc > /dev/null
344 #define OBD_FAIL_ONCE|OBD_FAIL_LDLM_CREATE_RESOURCE 0x30a
345 do_facet ost1 lctl set_param fail_loc=0x8000030a
346 ls -ls $DIR1/$tfile | awk '{ print $1,$6 }' > $DIR1/$tfile-1 & \
347 ls -ls $DIR2/$tfile | awk '{ print $1,$6 }' > $DIR2/$tfile-2
349 diff -u $DIR1/$tfile-1 $DIR2/$tfile-2 || error "files are different"
351 run_test 17 "resource creation/LVB creation race ==============="
354 $LUSTRE/tests/mmap_sanity -d $MOUNT1 -m $MOUNT2
357 run_test 18 "mmap sanity check ================================="
359 test_19() { # bug3811
360 [ -d /proc/fs/lustre/obdfilter ] || return 0
362 MAX=`lctl get_param -n obdfilter.*.readcache_max_filesize | head -n 1`
363 lctl set_param -n obdfilter.*OST*.readcache_max_filesize=4096
364 dd if=/dev/urandom of=$TMP/f19b bs=512k count=32
365 SUM=`cksum $TMP/f19b | cut -d" " -f 1,2`
366 cp $TMP/f19b $DIR1/f19b
367 for i in `seq 1 20`; do
368 [ $((i % 5)) -eq 0 ] && log "test_18 loop $i"
369 cancel_lru_locks osc > /dev/null
370 cksum $DIR1/f19b | cut -d" " -f 1,2 > $TMP/sum1 & \
371 cksum $DIR2/f19b | cut -d" " -f 1,2 > $TMP/sum2
373 [ "`cat $TMP/sum1`" = "$SUM" ] || \
374 error "$DIR1/f19b `cat $TMP/sum1` != $SUM"
375 [ "`cat $TMP/sum2`" = "$SUM" ] || \
376 error "$DIR2/f19b `cat $TMP/sum2` != $SUM"
378 lctl set_param -n obdfilter.*OST*.readcache_max_filesize=$MAX
381 run_test 19 "test concurrent uncached read races ==============="
386 CNT=$((`lctl get_param -n llite.*.dump_page_cache | wc -l`))
387 multiop $DIR1/f20 Ow8190c
388 multiop $DIR2/f20 Oz8194w8190c
389 multiop $DIR1/f20 Oz0r8190c
391 CNTD=$((`lctl get_param -n llite.*.dump_page_cache | wc -l` - $CNT))
393 error $CNTD" page left in cache after lock cancel" || true
395 run_test 20 "test extra readahead page left in cache ===="
402 test_21() { # Bug 5907
404 mount /etc $DIR1/d21 --bind || error "mount failed" # Poor man's mount.
406 rmdir -v $DIR1/d21 && error "Removed mounted directory"
407 rmdir -v $DIR2/d21 && echo "Removed mounted directory from another mountpoint, needs to be fixed"
408 test -d $DIR1/d21 || error "Mounted directory disappeared"
410 test -d $DIR2/d21 || test -d $DIR1/d21 && error "Removed dir still visible after umount"
413 run_test 21 " Try to remove mountpoint on another dir ===="
415 test_23() { # Bug 5972
416 echo "others should see updated atime while another read" > $DIR1/f23
418 # clear the lock(mode: LCK_PW) gotten from creating operation
422 #MAX_ATIME_DIFF 60, we update atime only if older than 60 seconds
425 multiop_bg_pause $DIR1/f23 or20_c || return 1
426 # with SOM and opencache enabled, we need to close a file and cancel
427 # open lock to get atime propogated to MDS
431 time2=`stat -c "%X" $DIR2/f23`
433 if (( $time2 <= $time1 )); then
434 error "atime doesn't update among nodes"
437 rm -f $DIR1/f23 || error "rm -f $DIR1/f23 failed"
440 run_test 23 " others should see updated atime while another read===="
444 lfs df || error "lfs df failed"
445 lfs df -ih || error "lfs df -ih failed"
446 lfs df -h $DIR1 || error "lfs df -h $DIR1 failed"
447 lfs df -i $DIR2 || error "lfs df -i $DIR2 failed"
448 lfs df $DIR1/$tfile || error "lfs df $DIR1/$tfile failed"
449 lfs df -ih $DIR2/$tfile || error "lfs df -ih $DIR2/$tfile failed"
451 OSC=`lctl dl | awk '/-osc-|OSC.*MNT/ {print $4}' | head -n 1`
452 # OSC=`lctl dl | awk '/-osc-/ {print $4}' | head -n 1`
453 lctl --device %$OSC deactivate
454 lfs df -i || error "lfs df -i with deactivated OSC failed"
455 lctl --device %$OSC recover
456 lfs df || error "lfs df with reactivated OSC failed"
458 run_test 24a "lfs df [-ih] [path] test ========================="
462 fsnum=`lfs df | grep -c "filesystem summary:"`
463 [ $fsnum -eq 2 ] || error "lfs df shows $fsnum != 2 filesystems."
465 run_test 24b "lfs df should show both filesystems ==============="
468 [ `lctl get_param -n mdc.*-mdc-*.connect_flags | grep -c acl` -lt 2 ] && \
469 skip "must have acl, skipping" && return
472 touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
473 chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
475 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
476 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir || error "setfacl $DIR2/$tdir #1"
477 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
478 setfacl -m u:$RUNAS_ID:r-x -m g:$RUNAS_GID:r-x $DIR1/$tdir || error "setfacl $DIR2/$tdir #2"
479 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
480 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir || error "setfacl $DIR2/$tdir #3"
481 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
482 setfacl -x u:$RUNAS_ID: -x g:$RUNAS_GID: $DIR1/$tdir || error "setfacl $DIR2/$tdir #4"
483 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
487 run_test 25 "change ACL on one mountpoint be seen on another ==="
490 utime $DIR1/f26a -s $DIR2/f26a || error
492 run_test 26a "allow mtime to get older"
497 echo "aaa" >> $DIR1/$tfile
499 chmod a+x $DIR2/$tfile
500 mt1=`stat -c %Y $DIR1/$tfile`
501 mt2=`stat -c %Y $DIR2/$tfile`
503 if [ x"$mt1" != x"$mt2" ]; then
504 error "not equal mtime, client1: "$mt1", client2: "$mt2"."
507 run_test 26b "sync mtime between ost and mds"
512 dd if=/dev/zero of=$DIR2/$tfile bs=$((4096+4))k conv=notrunc count=4 seek=3 &
517 dd if=/dev/zero of=$DIR1/$tfile bs=$((16384-1024))k conv=notrunc count=1 seek=4 &
522 dd if=/dev/zero of=$DIR1/$tfile bs=8k conv=notrunc count=1 seek=0
524 lctl set_param -n ldlm.dump_namespaces ""
525 wait $DD1_PID $DD2_PID
526 [ $? -ne 0 ] && lctl dk $TMP/debug || true
528 run_test 27 "align non-overlapping extent locks from request ==="
530 test_28() { # bug 9977
531 ECHO_UUID="ECHO_osc1_UUID"
532 tOST=`$LCTL dl | | awk '/-osc-|OSC.*MNT/ { print $4 }' | head -1`
534 lfs setstripe $DIR1/$tfile -s 1048576 -i 0 -c 2
535 tOBJID=`lfs getstripe $DIR1/$tfile |grep "^[[:space:]]\+1" |awk '{print $2}'`
536 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2
540 attach echo_client ECHO_osc1 $ECHO_UUID
544 tECHOID=`$LCTL dl | grep $ECHO_UUID | awk '{print $1}'`
545 $LCTL --device $tECHOID destroy "${tOBJID}:0"
553 # reading of 1st stripe should pass
554 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error
555 # reading of 2nd stripe should fail (this stripe was destroyed)
556 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 && error
558 # now, recreating test file
559 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2 || error
560 # reading of 1st stripe should pass
561 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error
562 # reading of 2nd stripe should pass
563 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 || error
565 run_test 28 "read/write/truncate file with lost stripes"
567 test_29() { # bug 10999
569 #define OBD_FAIL_LDLM_GLIMPSE 0x30f
570 lctl set_param fail_loc=0x8000030f
573 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1
576 #bug 11549 - permanently turn test off in b1_5
577 run_test 29 "lock put race between glimpse and enqueue ========="
579 test_30() { #bug #11110
581 cp -f /bin/bash $DIR1/$tdir/bash
582 /bin/sh -c 'sleep 1; rm -f $DIR2/$tdir/bash; cp /bin/bash $DIR2/$tdir' &
583 err=$($DIR1/$tdir/bash -c 'sleep 2; openfile -f O_RDONLY /proc/$$/exe >& /dev/null; echo $?')
585 [ $err -ne 116 ] && error_ignore 12900 "return code ($err) != -ESTALE" && return
589 run_test 30 "recreate file race ========="
592 mkdir -p $DIR1/$tdir || error "Creating dir $DIR1/$tdir"
593 writes=`LANG=C dd if=/dev/zero of=$DIR/$tdir/$tfile count=1 2>&1 |
594 awk 'BEGIN { FS="+" } /out/ {print $1}'`
595 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
596 lctl set_param fail_loc=0x314
597 reads=`LANG=C dd if=$DIR2/$tdir/$tfile of=/dev/null 2>&1 |
598 awk 'BEGIN { FS="+" } /in/ {print $1}'`
599 [ $reads -eq $writes ] || error "read" $reads "blocks, must be" $writes
601 run_test 31a "voluntary cancel / blocking ast race=============="
604 remote_ost || { skip "local OST" && return 0; }
605 remote_ost_nodsh && skip "remote OST w/o dsh" && return 0
606 mkdir -p $DIR1/$tdir || error "Creating dir $DIR1/$tdir"
607 lfs setstripe $DIR/$tdir/$tfile -i 0 -c 1
608 cp /etc/hosts $DIR/$tdir/$tfile
609 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
610 lctl set_param fail_loc=0x314
611 #define OBD_FAIL_LDLM_OST_FAIL_RACE 0x316
612 do_facet ost1 lctl set_param fail_loc=0x316
614 cat $DIR2/$tdir/$tfile > /dev/null 2>&1
615 lctl set_param fail_loc=0
616 do_facet ost1 lctl set_param fail_loc=0
617 # cleanup: reconnect the client back
620 run_test 31b "voluntary OST cancel / blocking ast race=============="
622 # enable/disable lockless truncate feature, depending on the arg 0/1
623 enable_lockless_truncate() {
624 lctl set_param -n osc.*.lockless_truncate $1
627 test_32a() { # bug 11270
628 local p="$TMP/sanityN-$TESTNAME.parameters"
629 save_lustre_params $HOSTNAME osc.*.lockless_truncate > $p
631 enable_lockless_truncate 1
633 lfs setstripe -c -1 $DIR1/$tfile
634 dd if=/dev/zero of=$DIR1/$tfile count=10 bs=1M > /dev/null 2>&1
637 log "checking cached lockless truncate"
638 $TRUNCATE $DIR1/$tfile 8000000
639 $CHECKSTAT -s 8000000 $DIR2/$tfile || error "wrong file size"
640 [ $(calc_osc_stats lockless_truncate) -eq 0 ] ||
641 error "lockless truncate doesn't use cached locks"
643 log "checking not cached lockless truncate"
644 $TRUNCATE $DIR2/$tfile 5000000
645 $CHECKSTAT -s 5000000 $DIR1/$tfile || error "wrong file size"
646 [ $(calc_osc_stats lockless_truncate) -ne 0 ] ||
647 error "not cached trancate isn't lockless"
649 log "disabled lockless truncate"
650 enable_lockless_truncate 0
652 $TRUNCATE $DIR2/$tfile 3000000
653 $CHECKSTAT -s 3000000 $DIR1/$tfile || error "wrong file size"
654 [ $(calc_osc_stats lockless_truncate) -eq 0 ] ||
655 error "lockless truncate disabling failed"
657 # restore lockless_truncate default values
658 restore_lustre_params < $p
661 run_test 32a "lockless truncate"
663 test_32b() { # bug 11270
664 remote_ost_nodsh && skip "remote OST with nodsh" && return
667 local p="$TMP/sanityN-$TESTNAME.parameters"
668 save_lustre_params $HOSTNAME "osc.*.contention_seconds" > $p
669 for node in $(osts_nodes); do
670 save_lustre_params $node "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
671 save_lustre_params $node "ldlm.namespaces.filter-*.contended_locks" >> $p
672 save_lustre_params $node "ldlm.namespaces.filter-*.contention_seconds" >> $p
675 # agressive lockless i/o settings
676 for node in $(osts_nodes); do
677 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'
679 lctl set_param -n osc.*.contention_seconds 60
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_osc_stats lockless_write_bytes) -ne 0 ] || error "lockless i/o was not triggered"
685 # disable lockless i/o (it is disabled by default)
686 for node in $(osts_nodes); do
687 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'
689 # set contention_seconds to 0 at client too, otherwise Lustre still
690 # remembers lock contention
691 lctl set_param -n osc.*.contention_seconds 0
693 for i in $(seq 1); do
694 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > /dev/null 2>&1
695 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > /dev/null 2>&1
697 [ $(calc_osc_stats lockless_write_bytes) -eq 0 ] ||
698 error "lockless i/o works when disabled"
700 restore_lustre_params <$p
703 run_test 32b "lockless i/o"
707 local mdts=$(get_facets MDS)
712 for mds in ${mdts//,/ }; do
714 dev=$(basename $(do_facet $mds lctl get_param -n osd.${!varsvc}.mntdev))
715 val=$(do_facet $mds "procfile=/proc/fs/jbd/$dev/info;
716 [ -f \\\$procfile ] || procfile=/proc/fs/jbd2/$dev/info;
717 [ -f \\\$procfile ] || procfile=/proc/fs/jbd2/${dev}\:\\\*/info;
718 cat \\\$procfile | head -1;")
720 stat=$(( stat + val))
725 # commit on sharing tests
727 remote_mds_nodsh && skip "remote MDS with nodsh" && return
729 [ -n "$CLIENTS" ] || { skip "Need two or more clients" && return 0; }
730 [ $CLIENTCOUNT -ge 2 ] || \
731 { skip "Need two or more clients, have $CLIENTCOUNT" && return 0; }
733 local nfiles=${TEST33_NFILES:-10000}
734 local param_file=$TMP/$tfile-params
736 save_lustre_params $(comma_list $(mdts_nodes)) "mdt.*.commit_on_sharing" > $param_file
744 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
748 do_nodes $CLIENT1,$CLIENT2 "mkdir -p $DIR1/$tdir-\\\$(hostname)-$i"
750 jbdold=$(print_jbd_stat)
751 echo "=== START createmany old: $jbdold transaction"
752 local elapsed=$(do_and_time "do_nodes $CLIENT1,$CLIENT2 createmany -o $DIR1/$tdir-\\\$(hostname)-$i/f- -r $DIR2/$tdir-\\\$(hostname)-$i/f- $nfiles > /dev/null 2>&1")
753 jbdnew=$(print_jbd_stat)
754 jbd=$(( jbdnew - jbdold ))
755 echo "=== END createmany new: $jbdnew transaction : $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
756 avgjbd=$(( avgjbd + jbd ))
757 avgtime=$(( avgtime + elapsed ))
759 eval cos${COS}_jbd=$((avgjbd / 3))
760 eval cos${COS}_time=$((avgtime / 3))
763 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
764 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
765 [ "$cos0_jbd" != 0 ] && echo "COS=1 vs COS=0 jbd: $((((cos1_jbd/cos0_jbd - 1)) * 100 )) %"
766 [ "$cos0_time" != 0 ] && echo "COS=1 vs COS=0 time: $((((cos1_time/cos0_time - 1)) * 100 )) %"
768 restore_lustre_params < $param_file
772 run_test 33a "commit on sharing, cross crete/delete, 2 clients, benchmark"
774 # End commit on sharing tests
776 get_ost_lock_timeouts() {
777 local nodes=${1:-$(comma_list $(osts_nodes))}
779 local locks=$(do_nodes $nodes \
780 "lctl get_param -n ldlm.namespaces.filter-*.lock_timeouts" | calc_sum)
789 for OPER in notimeout timeout ; do
790 rm $DIR1/$tfile 2>/dev/null
791 lock_in=$(get_ost_lock_timeouts)
792 if [ $OPER == "timeout" ] ; then
793 for j in `seq $OSTCOUNT`; do
794 #define OBD_FAIL_PTLRPC_HPREQ_TIMEOUT 0x511
795 do_facet ost$j lctl set_param fail_loc=0x511
797 echo lock should expire
799 for j in `seq $OSTCOUNT`; do
800 #define OBD_FAIL_PTLRPC_HPREQ_NOTIMEOUT 0x512
801 do_facet ost$j lctl set_param fail_loc=0x512
803 echo lock should not expire
805 echo writing on client1
806 dd if=/dev/zero of=$DIR1/$tfile count=100 conv=notrunc > /dev/null 2>&1
808 echo reading on client2
809 dd of=/dev/null if=$DIR2/$tfile > /dev/null 2>&1
810 # wait for a lock timeout
812 lock_out=$(get_ost_lock_timeouts)
813 if [ $OPER == "timeout" ] ; then
814 if [ $lock_in == $lock_out ]; then
815 error "no lock timeout happened"
820 if [ $lock_in != $lock_out ]; then
821 error "lock timeout happened"
828 run_test 34 "no lock timeout under IO"
830 test_35() { # bug 17645
833 for imp in /proc/fs/lustre/mdc/$FSNAME-MDT*-mdc-*; do
834 g=$(awk '/generation/{print $2}' $imp/import)
839 mkdir -p $MOUNT1/$tfile
842 # Let's initiate -EINTR situation by setting fail_loc and take
843 # write lock on same file from same client. This will not cause
844 # bl_ast yet as lock is already in local cache.
845 #define OBD_FAIL_LDLM_INTR_CP_AST 0x317
846 do_facet client "lctl set_param fail_loc=0x80000317"
847 local timeout=`do_facet $SINGLEMDS lctl get_param -n timeout`
848 let timeout=timeout*3
850 while test $nr -lt 10; do
851 log "Race attempt $nr"
852 local blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
853 test "x$blk1" = "x" && blk1=0
854 createmany -o $MOUNT2/$tfile/a 4000 &
858 # Let's make conflict and bl_ast
859 ls -la $MOUNT1/$tfile > /dev/null &
862 log "Wait for $pid1 $pid2 for $timeout sec..."
864 kill -9 $pid1 $pid2 > /dev/null 2>&1
866 local blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
867 test "x$blk2" = "x" && blk2=0
868 test $blk2 -gt $blk1 && break
869 rm -fr $MOUNT1/$tfile/*
873 do_facet client "lctl set_param fail_loc=0x0"
874 df -h $MOUNT1 $MOUNT2
876 for imp in /proc/fs/lustre/mdc/$FSNAME-MDT*-mdc-*; do
877 g=$(awk '/generation/{print $2}' $imp/import)
878 if ! test "$g" -eq "${generation[count]}"; then
879 error "Eviction happened on import $(basename $imp)"
884 run_test 35 "-EINTR cp_ast vs. bl_ast race does not evict client"
886 test_36() { #bug 16417
892 $LFS setstripe -c -1 $DIR1/$tdir
895 let SIZE_B=SIZE*1024*1024
897 while [ $i -le 10 ]; do
898 lctl mark "start test"
899 local before=$($LFS df | awk '{if ($1 ~/^filesystem/) {print $5; exit} }')
900 dd if=/dev/zero of=$DIR1/$tdir/file000 bs=1M count=$SIZE
903 local after_dd=$($LFS df | awk '{if ($1 ~/^filesystem/) {print $5; exit} }')
904 multiop_bg_pause $DIR2/$tdir/file000 O_r${SIZE_B}c || return 3
906 rm -f $DIR1/$tdir/file000
910 local after=$($LFS df | awk '{if ($1 ~/^filesystem/) {print $5; exit} }')
911 echo "*** cycle($i) *** before($before):after_dd($after_dd):after($after)"
912 # this free space! not used
913 if [ $after_dd -ge $after ]; then
920 run_test 36 "handle ESTALE/open-unlink corectly"
922 test_37() { # bug 18695
924 multiop_bg_pause $DIR1/$tdir D_c || return 1
926 # create large directory (32kB seems enough from e2fsck, ~= 1000 files)
927 createmany -m $DIR2/$tdir/f 10000
928 # set mtime/atime backward
929 touch -t 198001010000 $DIR2/$tdir
931 nr_files=`lfs find $DIR1/$tdir -type f | wc -l`
932 [ $nr_files -eq 10000 ] || error "$nr_files != 10000 truncated directory?"
935 run_test 37 "check i_size is not updated for directory on close (bug 18695) =============="
937 # this should be set to past
938 TEST_39_MTIME=`date -d "1 year ago" +%s`
942 local client1=${CLIENT1:-`hostname`}
943 local client2=${CLIENT2:-`hostname`}
945 do_node $client1 "touch $DIR1/$tfile"
947 do_node $client1 "touch -m -d @$TEST_39_MTIME $DIR1/$tfile"
948 local mtime1=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
949 [ "$mtime1" = $TEST_39_MTIME ] || \
950 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
952 local d1=`do_node $client1 date +%s`
953 do_node $client1 'echo hello >> '$DIR1/$tfile
954 local d2=`do_node $client1 date +%s`
956 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
957 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
958 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
960 do_node $client1 "mv $DIR1/$tfile $DIR1/$tfile-1"
962 for (( i=0; i < 2; i++ )) ; do
963 local mtime3=`do_node $client2 "stat -c %Y $DIR1/$tfile-1"`
964 [ "$mtime2" = "$mtime3" ] || \
965 error "mtime ($mtime2) changed (to $mtime3) on rename"
968 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
971 run_test 39a "test from 11063 =================================="
974 local client1=${CLIENT1:-`hostname`}
975 local client2=${CLIENT2:-`hostname`}
979 local mtime1=`stat -c %Y $DIR1/$tfile`
980 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
983 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
985 for (( i=0; i < 2; i++ )) ; do
986 local mtime3=`stat -c %Y $DIR1/$tfile`
987 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
989 [ "$mtime3" = "$mtime4" ] || \
990 error "different mtime on clients: $mtime3, $mtime4"
991 [ "$mtime3" = $TEST_39_MTIME ] || \
992 error "lost mtime: $mtime3, should be $TEST_39_MTIME"
995 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
998 run_test 39b "11063 problem 1 =================================="
1001 local client1=${CLIENT1:-`hostname`}
1002 local client2=${CLIENT2:-`hostname`}
1004 echo hello > $DIR1/$tfile
1006 local mtime1=`stat -c %Y $DIR1/$tfile`
1007 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1008 [ "$mtime1" = "$mtime2" ] || \
1009 error "create: different mtime on clients: $mtime1, $mtime2"
1012 $TRUNCATE $DIR1/$tfile 1
1014 for (( i=0; i < 2; i++ )) ; do
1015 local mtime3=`stat -c %Y $DIR1/$tfile`
1016 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1018 [ "$mtime3" = "$mtime4" ] || \
1019 error "different mtime on clients: $mtime3, $mtime4"
1020 [ "$mtime3" -gt $mtime2 ] || \
1021 error "truncate did not update mtime: $mtime2, $mtime3"
1023 cancel_lru_locks osc
1024 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1027 run_test 39c "check truncate mtime update ======================"
1029 # check that pid exists hence second operation wasn't blocked by first one
1030 # if it is so then there is no conflict, return 0
1031 # else second operation is conflicting with first one, return 1
1032 check_pdo_conflict() {
1035 if [[ `ps --pid $pid | wc -l` == 1 ]]; then
1045 # test 40: check non-blocking operations
1047 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1048 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1049 mkdir $DIR1/$tfile &
1052 touch $DIR2/$tfile-2
1053 check_pdo_conflict $PID1 || error "create is blocked"
1054 mkdir $DIR2/$tfile-3
1055 check_pdo_conflict $PID1 || error "mkdir is blocked"
1056 link $DIR2/$tfile-2 $DIR2/$tfile-4
1057 check_pdo_conflict $PID1 || error "link is blocked"
1058 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1059 check_pdo_conflict $PID1 || error "rename is blocked"
1060 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1061 check_pdo_conflict $PID1 || error "getattr is blocked"
1062 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1063 rmdir $DIR2/$tfile-3
1064 check_pdo_conflict $PID1 || error "unlink is blocked"
1065 # all operations above shouldn't wait the first one
1066 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1071 run_test 40a "pdirops: create vs others =============="
1074 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1075 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1076 touch $DIR1/$tfile &
1080 touch $DIR2/$tfile-2
1081 check_pdo_conflict $PID1 || error "create is blocked"
1082 mkdir $DIR2/$tfile-3
1083 check_pdo_conflict $PID1 || error "mkdir is blocked"
1084 link $DIR2/$tfile-2 $DIR2/$tfile-4
1085 check_pdo_conflict $PID1 || error "link is blocked"
1086 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1087 check_pdo_conflict $PID1 || error "rename is blocked"
1088 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1089 check_pdo_conflict $PID1 || error "getattr is blocked"
1090 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1091 rmdir $DIR2/$tfile-3
1092 check_pdo_conflict $PID1 || error "unlink is blocked"
1093 # all operations above shouldn't wait the first one
1094 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1099 run_test 40b "pdirops: open|create and others =============="
1103 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1104 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1105 link $DIR1/$tfile $DIR1/$tfile-0 &
1109 touch $DIR2/$tfile-2
1110 check_pdo_conflict $PID1 || error "create is blocked"
1111 mkdir $DIR2/$tfile-3
1112 check_pdo_conflict $PID1 || error "mkdir is blocked"
1113 link $DIR2/$tfile-2 $DIR2/$tfile-4
1114 check_pdo_conflict $PID1 || error "link is blocked"
1115 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1116 check_pdo_conflict $PID1 || error "rename is blocked"
1117 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1118 check_pdo_conflict $PID1 || error "getattr is blocked"
1119 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1120 rmdir $DIR2/$tfile-3
1121 check_pdo_conflict $PID1 || error "unlink is blocked"
1122 # all operations above shouldn't wait the first one
1123 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1128 run_test 40c "pdirops: link and others =============="
1132 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1133 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1138 touch $DIR2/$tfile-2
1139 check_pdo_conflict $PID1 || error "create is blocked"
1140 mkdir $DIR2/$tfile-3
1141 check_pdo_conflict $PID1 || error "mkdir is blocked"
1142 link $DIR2/$tfile-2 $DIR2/$tfile-4
1143 check_pdo_conflict $PID1 || error "link is blocked"
1144 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1145 check_pdo_conflict $PID1 || error "rename is blocked"
1146 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1147 check_pdo_conflict $PID1 || error "getattr is blocked"
1148 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1149 rmdir $DIR2/$tfile-3
1150 check_pdo_conflict $PID1 || error "unlink is blocked"
1151 # all operations above shouldn't wait the first one
1152 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1156 run_test 40d "pdirops: unlink and others =============="
1160 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1161 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1162 mv $DIR1/$tfile $DIR1/$tfile-0 &
1166 touch $DIR2/$tfile-2
1167 check_pdo_conflict $PID1 || error "create is blocked"
1168 mkdir $DIR2/$tfile-3
1169 check_pdo_conflict $PID1 || error "mkdir is blocked"
1170 link $DIR2/$tfile-2 $DIR2/$tfile-4
1171 check_pdo_conflict $PID1 || error "link is blocked"
1172 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1173 check_pdo_conflict $PID1 || error "getattr is blocked"
1174 rm $DIR2/$tfile-4 $DIR2/$tfile-2
1175 rmdir $DIR2/$tfile-3
1176 check_pdo_conflict $PID1 || error "unlink is blocked"
1177 # all operations above shouldn't wait the first one
1178 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1183 run_test 40e "pdirops: rename and others =============="
1185 # test 41: create blocking operations
1187 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1188 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1189 multiop $DIR1/$tfile oO_CREAT:O_RDWR:c &
1192 mkdir $DIR2/$tfile && error "mkdir must fail"
1193 check_pdo_conflict $PID1 && { wait $PID1; echo "mkdir isn't blocked"; }
1197 run_test 41a "pdirops: create vs mkdir =============="
1200 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1201 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1202 multiop $DIR1/$tfile oO_CREAT:O_RDWR:c &
1205 multiop $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1206 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1210 run_test 41b "pdirops: create vs create =============="
1213 touch $DIR1/$tfile-2
1214 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1215 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1216 multiop $DIR1/$tfile oO_CREAT:O_RDWR:c &
1219 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
1220 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1224 run_test 41c "pdirops: create vs link =============="
1227 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1228 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1229 multiop $DIR1/$tfile oO_CREAT:O_RDWR:c &
1232 rm $DIR2/$tfile || error "unlink must succeed"
1233 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1237 run_test 41d "pdirops: create vs unlink =============="
1240 touch $DIR1/$tfile-2
1241 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1242 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1243 multiop $DIR1/$tfile oO_CREAT:O_RDWR:c &
1246 mv $DIR2/$tfile-2 $DIR2/$tfile || error "rename must succeed"
1247 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1251 run_test 41e "pdirops: create and rename (tgt) =============="
1254 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1255 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1256 multiop $DIR1/$tfile oO_CREAT:O_RDWR:c &
1259 mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
1260 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1264 run_test 41f "pdirops: create and rename (src) =============="
1267 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1268 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1269 multiop $DIR1/$tfile oO_CREAT:O_RDWR:c &
1272 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
1273 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1277 run_test 41g "pdirops: create vs getattr =============="
1280 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1281 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1282 multiop $DIR1/$tfile oO_CREAT:O_RDWR:c &
1285 ls -lia $DIR2/ > /dev/null
1286 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1290 run_test 41h "pdirops: create vs readdir =============="
1292 # test 42: unlink and blocking operations
1294 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1295 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1296 mkdir $DIR1/$tfile &
1299 mkdir $DIR2/$tfile && error "mkdir must fail"
1300 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1304 run_test 42a "pdirops: mkdir vs mkdir =============="
1307 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1308 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1309 mkdir $DIR1/$tfile &
1312 multiop $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1313 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1317 run_test 42b "pdirops: mkdir vs create =============="
1320 touch $DIR1/$tfile-2
1321 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1322 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1323 mkdir $DIR1/$tfile &
1326 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
1327 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1331 run_test 42c "pdirops: mkdir vs link =============="
1334 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1335 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1336 mkdir $DIR1/$tfile &
1339 rmdir $DIR2/$tfile || error "unlink must succeed"
1340 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1344 run_test 42d "pdirops: mkdir vs unlink =============="
1347 touch $DIR1/$tfile-2
1348 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1349 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1350 mkdir $DIR1/$tfile &
1353 mv -T $DIR2/$tfile-2 $DIR2/$tfile && error "rename must fail"
1354 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1358 run_test 42e "pdirops: mkdir and rename (tgt) =============="
1361 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1362 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1363 mkdir $DIR1/$tfile &
1366 mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
1367 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1371 run_test 42f "pdirops: mkdir and rename (src) =============="
1374 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1375 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1376 mkdir $DIR1/$tfile &
1379 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
1380 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1384 run_test 42g "pdirops: mkdir vs getattr =============="
1387 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1388 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1389 mkdir $DIR1/$tfile &
1392 ls -lia $DIR2/ > /dev/null
1393 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1397 run_test 42h "pdirops: mkdir vs readdir =============="
1399 # test 43: unlink and blocking operations
1402 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1403 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1407 mkdir $DIR2/$tfile || error "mkdir must succeed"
1408 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1412 run_test 43a "pdirops: unlink vs mkdir =============="
1416 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1417 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1421 multiop $DIR2/$tfile oO_CREAT:O_EXCL:c || error "create must succeed"
1422 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1426 run_test 43b "pdirops: unlink vs create =============="
1430 touch $DIR1/$tfile-2
1431 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1432 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1436 link $DIR2/$tfile-2 $DIR2/$tfile || error "link must succeed"
1437 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1441 run_test 43c "pdirops: unlink vs link =============="
1445 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1446 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1450 rm $DIR2/$tfile && error "unlink must fail"
1451 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1455 run_test 43d "pdirops: unlink vs unlink =============="
1459 touch $DIR1/$tfile-2
1460 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1461 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1465 mv -u $DIR2/$tfile-2 $DIR2/$tfile || error "rename must succeed"
1466 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1470 run_test 43e "pdirops: unlink and rename (tgt) =============="
1474 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1475 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1479 mv $DIR2/$tfile $DIR2/$tfile-2 && error "rename must fail"
1480 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1484 run_test 43f "pdirops: unlink and rename (src) =============="
1488 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1489 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1493 stat $DIR2/$tfile > /dev/null && error "stat must fail"
1494 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1498 run_test 43g "pdirops: unlink vs getattr =============="
1502 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1503 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1507 ls -lia $DIR2/ > /dev/null
1508 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1512 run_test 43h "pdirops: unlink vs readdir =============="
1514 # test 44: rename tgt and blocking operations
1516 touch $DIR1/$tfile-2
1517 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1518 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1519 mv $DIR1/$tfile-2 $DIR1/$tfile &
1522 mkdir $DIR2/$tfile && error "mkdir must fail"
1523 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1527 run_test 44a "pdirops: rename tgt vs mkdir =============="
1530 touch $DIR1/$tfile-2
1531 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1532 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1533 mv $DIR1/$tfile-2 $DIR1/$tfile &
1536 multiop $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1537 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1541 run_test 44b "pdirops: rename tgt vs create =============="
1544 touch $DIR1/$tfile-2
1545 touch $DIR1/$tfile-3
1546 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1547 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1548 mv $DIR1/$tfile-2 $DIR1/$tfile &
1551 link $DIR2/$tfile-3 $DIR2/$tfile && error "link must fail"
1552 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1556 run_test 44c "pdirops: rename tgt vs link =============="
1559 touch $DIR1/$tfile-2
1560 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1561 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1562 mv $DIR1/$tfile-2 $DIR1/$tfile &
1565 rm $DIR2/$tfile || error "unlink must succeed"
1566 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1570 run_test 44d "pdirops: rename tgt vs unlink =============="
1574 touch $DIR1/$tfile-2
1575 touch $DIR1/$tfile-3
1576 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1577 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1578 mv $DIR1/$tfile-2 $DIR1/$tfile &
1581 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
1582 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1586 run_test 44e "pdirops: rename tgt and rename (tgt) =============="
1589 touch $DIR1/$tfile-2
1590 touch $DIR1/$tfile-3
1591 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1592 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1593 mv $DIR1/$tfile-2 $DIR1/$tfile &
1596 mv $DIR2/$tfile $DIR2/$tfile-3 || error "rename must succeed"
1597 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1601 run_test 44f "pdirops: rename tgt and rename (src) =============="
1604 touch $DIR1/$tfile-2
1605 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1606 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1607 mv $DIR1/$tfile-2 $DIR1/$tfile &
1610 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
1611 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1615 run_test 44g "pdirops: rename tgt vs getattr =============="
1618 touch $DIR1/$tfile-2
1619 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1620 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1621 mv $DIR1/$tfile-2 $DIR1/$tfile &
1624 ls -lia $DIR2/ > /dev/null
1625 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1629 run_test 44h "pdirops: rename tgt vs readdir =============="
1631 # test 45: rename src and blocking operations
1634 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1635 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1636 mv $DIR1/$tfile $DIR1/$tfile-2 &
1639 mkdir $DIR2/$tfile || error "mkdir must succeed"
1640 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1644 run_test 45a "pdirops: rename src vs mkdir =============="
1648 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1649 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1650 mv $DIR1/$tfile $DIR1/$tfile-2 &
1653 multiop $DIR2/$tfile oO_CREAT:O_EXCL:c || error "create must succeed"
1654 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1658 run_test 45b "pdirops: rename src vs create =============="
1662 touch $DIR1/$tfile-3
1663 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1664 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1665 mv $DIR1/$tfile $DIR1/$tfile-2 &
1668 link $DIR2/$tfile-3 $DIR2/$tfile || error "link must succeed"
1669 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1673 run_test 45c "pdirops: rename src vs link =============="
1677 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1678 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1679 mv $DIR1/$tfile $DIR1/$tfile-2 &
1682 rm $DIR2/$tfile && error "unlink must fail"
1683 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1687 run_test 45d "pdirops: rename src vs unlink =============="
1691 touch $DIR1/$tfile-3
1692 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1693 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1694 mv $DIR1/$tfile $DIR1/$tfile-2 &
1697 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
1698 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1702 run_test 45e "pdirops: rename src and rename (tgt) =============="
1706 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1707 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1708 mv $DIR1/$tfile $DIR1/$tfile-2 &
1711 mv $DIR2/$tfile $DIR2/$tfile-3 && error "rename must fail"
1712 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1716 run_test 45f "pdirops: rename src and rename (src) =============="
1720 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1721 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1722 mv $DIR1/$tfile $DIR1/$tfile-2 &
1725 stat $DIR2/$tfile > /dev/null && "stat must fail"
1726 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1730 run_test 45g "pdirops: rename src vs getattr =============="
1734 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1735 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1736 mv $DIR1/$tfile $DIR1/$tfile-2 &
1739 ls -lia $DIR2/ > /dev/null
1740 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1744 run_test 45h "pdirops: unlink vs readdir =============="
1746 # test 46: link and blocking operations
1748 touch $DIR1/$tfile-2
1749 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1750 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1751 link $DIR1/$tfile-2 $DIR1/$tfile &
1754 mkdir $DIR2/$tfile && error "mkdir must fail"
1755 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1759 run_test 46a "pdirops: link vs mkdir =============="
1762 touch $DIR1/$tfile-2
1763 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1764 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1765 link $DIR1/$tfile-2 $DIR1/$tfile &
1768 multiop $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1769 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1773 run_test 46b "pdirops: link vs create =============="
1776 touch $DIR1/$tfile-2
1777 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1778 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1779 link $DIR1/$tfile-2 $DIR1/$tfile &
1782 link $DIR2/$tfile $DIR2/$tfile && error "link must fail"
1783 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1787 run_test 46c "pdirops: link vs link =============="
1790 touch $DIR1/$tfile-2
1791 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1792 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1793 link $DIR1/$tfile-2 $DIR1/$tfile &
1796 rm $DIR2/$tfile || error "unlink must succeed"
1797 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1801 run_test 46d "pdirops: link vs unlink =============="
1804 touch $DIR1/$tfile-2
1805 touch $DIR1/$tfile-3
1806 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1807 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1808 link $DIR1/$tfile-2 $DIR1/$tfile &
1811 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
1812 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1816 run_test 46e "pdirops: link and rename (tgt) =============="
1819 touch $DIR1/$tfile-2
1820 touch $DIR1/$tfile-3
1821 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1822 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1823 link $DIR1/$tfile-2 $DIR1/$tfile &
1826 mv $DIR2/$tfile $DIR2/$tfile-3 || error "rename must succeed"
1827 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1831 run_test 46f "pdirops: link and rename (src) =============="
1834 touch $DIR1/$tfile-2
1835 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1836 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1837 link $DIR1/$tfile-2 $DIR1/$tfile &
1840 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
1841 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1845 run_test 46g "pdirops: link vs getattr =============="
1848 touch $DIR1/$tfile-2
1849 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1850 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1851 link $DIR1/$tfile-2 $DIR1/$tfile &
1854 ls -lia $DIR2/ > /dev/null
1855 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1859 run_test 46h "pdirops: link vs readdir =============="
1863 dd if=/dev/zero of=$DIR1/$tfile bs=1K count=10
1864 #define OBD_FAIL_OSC_CP_ENQ_RACE 0x410
1865 do_facet client "lctl set_param fail_loc=0x410"
1866 $TRUNCATE $DIR2/$tfile $trunc_size
1867 do_facet client "lctl set_param fail_loc=0x0"
1869 size=`stat -c %s $DIR2/$tfile`
1870 [ $size -eq $trunc_size ] || error "wrong size"
1872 run_test 50 "osc lvb attrs: enqueue vs. CP AST =============="
1874 log "cleanup: ======================================================"
1876 [ "$(mount | grep $MOUNT2)" ] && umount $MOUNT2
1877 check_and_cleanup_lustre
1879 echo '=========================== finished ==============================='
1880 [ -f "$SANITYLOG" ] && cat $SANITYLOG && grep -q FAIL $SANITYLOG && exit 1 || true
1881 echo "$0: completed"