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 export TMP=${TMP:-/tmp}
30 MOUNT_2=${MOUNT_2:-"yes"}
31 CHECK_GRANT=${CHECK_GRANT:-"yes"}
32 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
36 export NAME=${NAME:-local}
38 LUSTRE=${LUSTRE:-`dirname $0`/..}
39 . $LUSTRE/tests/test-framework.sh
43 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
46 [ "$SLOW" = "no" ] && EXCEPT_SLOW="12 16 23 33a"
48 SANITYLOG=${TESTSUITELOG:-$TMP/$(basename $0 .sh).log}
54 [ "$SANITYLOG" ] && rm -f $SANITYLOG || true
56 check_and_setup_lustre
58 LOVNAME=`lctl get_param -n llite.*.lov.common_name | tail -n 1`
59 OSTCOUNT=`lctl get_param -n lov.$LOVNAME.numobd`
62 rm -rf $DIR1/[df][0-9]* $DIR1/lnk
64 SAMPLE_FILE=$TMP/$(basename $0 .sh).junk
65 dd if=/dev/urandom of=$SAMPLE_FILE bs=1M count=1
67 # $RUNAS_ID may get set incorrectly somewhere else
68 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
70 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
79 [ -f $DIR2/f1 ] || error
81 run_test 1a "check create on 2 mtpt's =========================="
85 $CHECKSTAT -t file -p 0777 $DIR1/f1 || error
88 run_test 1b "check attribute updates on 2 mtpt's ==============="
91 $CHECKSTAT -t file -p 0666 $DIR1/f1 || error
93 run_test 1c "check after remount attribute updates on 2 mtpt's ="
97 $CHECKSTAT -a $DIR1/f1 || error
99 run_test 1d "unlink on one mountpoint removes file on other ===="
105 $CHECKSTAT -t file -p 0777 $DIR1/f2a || error
107 run_test 2a "check cached attribute updates on 2 mtpt's ========"
113 $CHECKSTAT -t file -p 0777 $DIR2/f2b || error
115 run_test 2b "check cached attribute updates on 2 mtpt's ========"
117 # NEED TO SAVE ROOT DIR MODE
120 $CHECKSTAT -t dir -p 0777 $DIR2 || error
122 run_test 2c "check cached attribute updates on 2 mtpt's root ==="
126 $CHECKSTAT -t dir -p 0755 $DIR2 || error
128 run_test 2d "check cached attribute updates on 2 mtpt's root ==="
135 $RUNAS dd if=/dev/zero of=$DIR2/$tfile count=1 || error
137 run_test 2e "check chmod on root is propagated to others"
140 ( cd $DIR1 ; ln -s this/is/good $tfile )
141 [ "this/is/good" = "`perl -e 'print readlink("'$DIR2/$tfile'");'`" ] ||
142 error "link $DIR2/$tfile not as expected"
144 run_test 3 "symlink on one mtpt, readlink on another ==========="
147 multifstat $DIR1/f4 $DIR2/f4
149 run_test 4 "fstat validation on multiple mount points =========="
153 $TRUNCATE $DIR2/f5 100
154 $CHECKSTAT -t file -s 100 $DIR1/f5 || error
157 run_test 5 "create a file on one mount, truncate it on the other"
160 openunlink $DIR1/$tfile $DIR2/$tfile || \
161 error "openunlink $DIR1/$tfile $DIR2/$tfile"
163 run_test 6 "remove of open file on other node =================="
167 opendirunlink $DIR1/$dir $DIR2/$dir || \
168 error "opendirunlink $DIR1/$dir $DIR2/$dir"
170 run_test 7 "remove of open directory on other node ============="
173 opendevunlink $DIR1/$tfile $DIR2/$tfile || \
174 error "opendevunlink $DIR1/$tfile $DIR2/$tfile"
176 run_test 8 "remove of open special file on other node =========="
182 for C in a b c d e f g h i j k l; do
183 dir=`eval echo \\$DIR$MTPT`
184 echo -n $C >> $dir/f9
185 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
187 [ "`cat $DIR1/f9`" = "abcdefghijkl" ] || \
188 error "`od -a $DIR1/f9` != abcdefghijkl"
190 run_test 9 "append of file with sub-page size on multiple mounts"
197 for C in a b c d e f g h i j k l; do
198 dir=`eval echo \\$DIR$MTPT`
199 echo -n $C | dd of=$dir/f10 bs=1 seek=$OFFSET count=1
200 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
201 OFFSET=`expr $OFFSET + 1`
203 [ "`cat $DIR1/f10`" = "abcdefghijkl" ] || \
204 error "`od -a $DIR1/f10` != abcdefghijkl"
206 run_test 10a "write of file with sub-page size on multiple mounts "
210 yes "R" | head -c 4000 >$TMP/f10b-seed
211 dd if=$TMP/f10b-seed of=$DIR1/f10b bs=3k count=1 || error "dd $DIR1"
213 $TRUNCATE $DIR1/f10b 4096 || error "truncate 4096"
215 dd if=$DIR2/f10b of=$TMP/f10b-lustre bs=4k count=1 || error "dd $DIR2"
217 # create a test file locally to compare
218 dd if=$TMP/f10b-seed of=$TMP/f10b bs=3k count=1 || error "dd random"
219 $TRUNCATE $TMP/f10b 4096 || error "truncate 4096"
220 cmp $TMP/f10b $TMP/f10b-lustre || error "file miscompare"
221 rm $TMP/f10b $TMP/f10b-lustre $TMP/f10b-seed
223 run_test 10b "write of file with sub-page size on multiple mounts "
227 multiop_bg_pause $DIR1/d11/f O_c || return 1
229 cp -p /bin/ls $DIR1/d11/f
233 wait $MULTIPID || error
234 [ $RC -eq 0 ] && error || true
236 run_test 11 "execution of file opened for write should return error ===="
239 DIR=$DIR DIR2=$DIR2 sh lockorder.sh
241 run_test 12 "test lock ordering (link, stat, unlink) ==========="
243 test_13() { # bug 2451 - directory coherency
245 mkdir $DIR1/d13 || error
246 cd $DIR1/d13 || error
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 (1)" || true
252 # need to run it twice
253 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
255 rm -f $DIR2/d13/f13 || error
256 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (2)" || true
258 run_test 13 "test directory page revocation ===================="
262 cp -p /bin/ls $DIR1/$tdir/$tfile
263 multiop_bg_pause $DIR1/$tdir/$tfile Ow_c || return 1
266 $DIR2/$tdir/$tfile && error || true
268 wait $MULTIPID || return 2
270 run_test 14 "execution of file open for write returns -ETXTBSY ="
274 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
275 MULTIOP_PROG=$DIR1/d14/multiop multiop_bg_pause $TMP/test14.junk O_c || return 1
277 multiop $DIR2/d14/multiop Oc && error "expected error, got success"
278 kill -USR1 $MULTIOP_PID || return 2
279 wait $MULTIOP_PID || return 3
280 rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop"
282 run_test 14a "open(RDWR) of executing file returns -ETXTBSY ===="
284 test_14b() { # bug 3192, 7040
286 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
287 MULTIOP_PROG=$DIR1/d14/multiop multiop_bg_pause $TMP/test14.junk O_c || return 1
289 $TRUNCATE $DIR2/d14/multiop 0 && kill -9 $MULTIOP_PID && \
290 error "expected truncate error, got success"
291 kill -USR1 $MULTIOP_PID || return 2
292 wait $MULTIOP_PID || return 3
293 cmp `which multiop` $DIR1/d14/multiop || error "binary changed"
294 rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop"
296 run_test 14b "truncate of executing file returns -ETXTBSY ======"
298 test_14c() { # bug 3430, 7040
300 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
301 MULTIOP_PROG=$DIR1/d14/multiop multiop_bg_pause $TMP/test14.junk O_c || return 1
303 cp /etc/hosts $DIR2/d14/multiop && error "expected error, got success"
304 kill -USR1 $MULTIOP_PID || return 2
305 wait $MULTIOP_PID || return 3
306 cmp `which multiop` $DIR1/d14/multiop || error "binary changed"
307 rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop"
309 run_test 14c "open(O_TRUNC) of executing file return -ETXTBSY =="
311 test_14d() { # bug 10921
313 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
314 MULTIOP_PROG=$DIR1/d14/multiop multiop_bg_pause $TMP/test14.junk O_c || return 1
317 chmod 600 $DIR1/d14/multiop || error "chmod failed"
318 kill -USR1 $MULTIOP_PID || return 2
319 wait $MULTIOP_PID || return 3
320 cmp `which multiop` $DIR1/d14/multiop || error "binary changed"
321 rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop"
323 run_test 14d "chmod of executing file is still possible ========"
325 test_15() { # bug 974 - ENOSPC
327 sh oos2.sh $MOUNT1 $MOUNT2
328 grant_error=`dmesg | grep "> available"`
329 [ -z "$grant_error" ] || error "$grant_error"
331 run_test 15 "test out-of-space with multiple writers ==========="
334 rm -f $MOUNT1/fsxfile
335 lfs setstripe $MOUNT1/fsxfile -c -1 # b=10919
336 fsx -c 50 -p 100 -N 2500 -l $((SIZE * 256)) -S 0 $MOUNT1/fsxfile $MOUNT2/fsxfile
338 run_test 16 "2500 iterations of dual-mount fsx ================="
340 test_17() { # bug 3513, 3667
341 remote_ost_nodsh && skip "remote OST with nodsh" && return
343 lfs setstripe $DIR1/$tfile -i 0 -c 1
344 cp $SAMPLE_FILE $DIR1/$tfile
345 cancel_lru_locks osc > /dev/null
346 #define OBD_FAIL_ONCE|OBD_FAIL_LDLM_CREATE_RESOURCE 0x30a
347 do_facet ost1 lctl set_param fail_loc=0x8000030a
348 ls -ls $DIR1/$tfile | awk '{ print $1,$6 }' > $DIR1/$tfile-1 & \
349 ls -ls $DIR2/$tfile | awk '{ print $1,$6 }' > $DIR2/$tfile-2
351 diff -u $DIR1/$tfile-1 $DIR2/$tfile-2 || error "files are different"
353 run_test 17 "resource creation/LVB creation race ==============="
356 $LUSTRE/tests/mmap_sanity -d $MOUNT1 -m $MOUNT2
359 run_test 18 "mmap sanity check ================================="
361 test_19() { # bug3811
362 [ -d /proc/fs/lustre/obdfilter ] || return 0
364 MAX=`lctl get_param -n obdfilter.*.readcache_max_filesize | head -n 1`
365 lctl set_param -n obdfilter.*OST*.readcache_max_filesize=4096
366 dd if=/dev/urandom of=$TMP/f19b bs=512k count=32
367 SUM=`cksum $TMP/f19b | cut -d" " -f 1,2`
368 cp $TMP/f19b $DIR1/f19b
369 for i in `seq 1 20`; do
370 [ $((i % 5)) -eq 0 ] && log "test_18 loop $i"
371 cancel_lru_locks osc > /dev/null
372 cksum $DIR1/f19b | cut -d" " -f 1,2 > $TMP/sum1 & \
373 cksum $DIR2/f19b | cut -d" " -f 1,2 > $TMP/sum2
375 [ "`cat $TMP/sum1`" = "$SUM" ] || \
376 error "$DIR1/f19b `cat $TMP/sum1` != $SUM"
377 [ "`cat $TMP/sum2`" = "$SUM" ] || \
378 error "$DIR2/f19b `cat $TMP/sum2` != $SUM"
380 lctl set_param -n obdfilter.*OST*.readcache_max_filesize=$MAX
383 run_test 19 "test concurrent uncached read races ==============="
388 CNT=$((`lctl get_param -n llite.*.dump_page_cache | wc -l`))
389 multiop $DIR1/f20 Ow8190c
390 multiop $DIR2/f20 Oz8194w8190c
391 multiop $DIR1/f20 Oz0r8190c
393 CNTD=$((`lctl get_param -n llite.*.dump_page_cache | wc -l` - $CNT))
395 error $CNTD" page left in cache after lock cancel" || true
397 run_test 20 "test extra readahead page left in cache ===="
404 test_21() { # Bug 5907
406 mount /etc $DIR1/d21 --bind || error "mount failed" # Poor man's mount.
408 rmdir -v $DIR1/d21 && error "Removed mounted directory"
409 rmdir -v $DIR2/d21 && echo "Removed mounted directory from another mountpoint, needs to be fixed"
410 test -d $DIR1/d21 || error "Mounted directory disappeared"
412 test -d $DIR2/d21 || test -d $DIR1/d21 && error "Removed dir still visible after umount"
415 run_test 21 " Try to remove mountpoint on another dir ===="
417 test_23() { # Bug 5972
418 echo "others should see updated atime while another read" > $DIR1/f23
420 # clear the lock(mode: LCK_PW) gotten from creating operation
424 #MAX_ATIME_DIFF 60, we update atime only if older than 60 seconds
427 multiop_bg_pause $DIR1/f23 or20_c || return 1
428 # with SOM and opencache enabled, we need to close a file and cancel
429 # open lock to get atime propogated to MDS
433 time2=`stat -c "%X" $DIR2/f23`
435 if (( $time2 <= $time1 )); then
436 error "atime doesn't update among nodes"
439 rm -f $DIR1/f23 || error "rm -f $DIR1/f23 failed"
442 run_test 23 " others should see updated atime while another read===="
446 lfs df || error "lfs df failed"
447 lfs df -ih || error "lfs df -ih failed"
448 lfs df -h $DIR1 || error "lfs df -h $DIR1 failed"
449 lfs df -i $DIR2 || error "lfs df -i $DIR2 failed"
450 lfs df $DIR1/$tfile || error "lfs df $DIR1/$tfile failed"
451 lfs df -ih $DIR2/$tfile || error "lfs df -ih $DIR2/$tfile failed"
453 OSC=`lctl dl | awk '/-osc-|OSC.*MNT/ {print $4}' | head -n 1`
454 # OSC=`lctl dl | awk '/-osc-/ {print $4}' | head -n 1`
455 lctl --device %$OSC deactivate
456 lfs df -i || error "lfs df -i with deactivated OSC failed"
457 lctl --device %$OSC recover
458 lfs df || error "lfs df with reactivated OSC failed"
460 run_test 24a "lfs df [-ih] [path] test ========================="
464 fsnum=`lfs df | grep -c "filesystem summary:"`
465 [ $fsnum -eq 2 ] || error "lfs df shows $fsnum != 2 filesystems."
467 run_test 24b "lfs df should show both filesystems ==============="
470 [ `lctl get_param -n mdc.*-mdc-*.connect_flags | grep -c acl` -lt 2 ] && \
471 skip "must have acl, skipping" && return
474 touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
475 chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
477 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
478 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir || error "setfacl $DIR2/$tdir #1"
479 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
480 setfacl -m u:$RUNAS_ID:r-x -m g:$RUNAS_GID:r-x $DIR1/$tdir || error "setfacl $DIR2/$tdir #2"
481 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
482 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir || error "setfacl $DIR2/$tdir #3"
483 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
484 setfacl -x u:$RUNAS_ID: -x g:$RUNAS_GID: $DIR1/$tdir || error "setfacl $DIR2/$tdir #4"
485 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
489 run_test 25 "change ACL on one mountpoint be seen on another ==="
492 utime $DIR1/f26a -s $DIR2/f26a || error
494 run_test 26a "allow mtime to get older"
499 echo "aaa" >> $DIR1/$tfile
501 chmod a+x $DIR2/$tfile
502 mt1=`stat -c %Y $DIR1/$tfile`
503 mt2=`stat -c %Y $DIR2/$tfile`
505 if [ x"$mt1" != x"$mt2" ]; then
506 error "not equal mtime, client1: "$mt1", client2: "$mt2"."
509 run_test 26b "sync mtime between ost and mds"
514 dd if=/dev/zero of=$DIR2/$tfile bs=$((4096+4))k conv=notrunc count=4 seek=3 &
519 dd if=/dev/zero of=$DIR1/$tfile bs=$((16384-1024))k conv=notrunc count=1 seek=4 &
524 dd if=/dev/zero of=$DIR1/$tfile bs=8k conv=notrunc count=1 seek=0
526 lctl set_param -n ldlm.dump_namespaces ""
527 wait $DD1_PID $DD2_PID
528 [ $? -ne 0 ] && lctl dk $TMP/debug || true
530 run_test 27 "align non-overlapping extent locks from request ==="
532 test_28() { # bug 9977
533 ECHO_UUID="ECHO_osc1_UUID"
534 tOST=`$LCTL dl | | awk '/-osc-|OSC.*MNT/ { print $4 }' | head -1`
536 lfs setstripe $DIR1/$tfile -s 1048576 -i 0 -c 2
537 tOBJID=`lfs getstripe $DIR1/$tfile |grep "^[[:space:]]\+1" |awk '{print $2}'`
538 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2
542 attach echo_client ECHO_osc1 $ECHO_UUID
546 tECHOID=`$LCTL dl | grep $ECHO_UUID | awk '{print $1}'`
547 $LCTL --device $tECHOID destroy "${tOBJID}:0"
555 # reading of 1st stripe should pass
556 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error
557 # reading of 2nd stripe should fail (this stripe was destroyed)
558 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 && error
560 # now, recreating test file
561 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2 || error
562 # reading of 1st stripe should pass
563 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error
564 # reading of 2nd stripe should pass
565 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 || error
567 run_test 28 "read/write/truncate file with lost stripes"
569 test_29() { # bug 10999
571 #define OBD_FAIL_LDLM_GLIMPSE 0x30f
572 lctl set_param fail_loc=0x8000030f
575 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1
578 #bug 11549 - permanently turn test off in b1_5
579 run_test 29 "lock put race between glimpse and enqueue ========="
581 test_30() { #bug #11110
583 cp -f /bin/bash $DIR1/$tdir/bash
584 /bin/sh -c 'sleep 1; rm -f $DIR2/$tdir/bash; cp /bin/bash $DIR2/$tdir' &
585 err=$($DIR1/$tdir/bash -c 'sleep 2; openfile -f O_RDONLY /proc/$$/exe >& /dev/null; echo $?')
587 [ $err -ne 116 ] && error_ignore 12900 "return code ($err) != -ESTALE" && return
591 run_test 30 "recreate file race ========="
594 mkdir -p $DIR1/$tdir || error "Creating dir $DIR1/$tdir"
595 writes=`LANG=C dd if=/dev/zero of=$DIR/$tdir/$tfile count=1 2>&1 |
596 awk 'BEGIN { FS="+" } /out/ {print $1}'`
597 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
598 lctl set_param fail_loc=0x314
599 reads=`LANG=C dd if=$DIR2/$tdir/$tfile of=/dev/null 2>&1 |
600 awk 'BEGIN { FS="+" } /in/ {print $1}'`
601 [ $reads -eq $writes ] || error "read" $reads "blocks, must be" $writes
603 run_test 31a "voluntary cancel / blocking ast race=============="
606 remote_ost || { skip "local OST" && return 0; }
607 remote_ost_nodsh && skip "remote OST w/o dsh" && return 0
608 mkdir -p $DIR1/$tdir || error "Creating dir $DIR1/$tdir"
609 lfs setstripe $DIR/$tdir/$tfile -i 0 -c 1
610 cp /etc/hosts $DIR/$tdir/$tfile
611 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
612 lctl set_param fail_loc=0x314
613 #define OBD_FAIL_LDLM_OST_FAIL_RACE 0x316
614 do_facet ost1 lctl set_param fail_loc=0x316
616 cat $DIR2/$tdir/$tfile > /dev/null 2>&1
617 lctl set_param fail_loc=0
618 do_facet ost1 lctl set_param fail_loc=0
619 # cleanup: reconnect the client back
622 run_test 31b "voluntary OST cancel / blocking ast race=============="
624 # enable/disable lockless truncate feature, depending on the arg 0/1
625 enable_lockless_truncate() {
626 lctl set_param -n osc.*.lockless_truncate $1
629 test_32a() { # bug 11270
630 local p="$TMP/sanityN-$TESTNAME.parameters"
631 save_lustre_params $HOSTNAME osc.*.lockless_truncate > $p
633 enable_lockless_truncate 1
635 lfs setstripe -c -1 $DIR1/$tfile
636 dd if=/dev/zero of=$DIR1/$tfile count=10 bs=1M > /dev/null 2>&1
639 log "checking cached lockless truncate"
640 $TRUNCATE $DIR1/$tfile 8000000
641 $CHECKSTAT -s 8000000 $DIR2/$tfile || error "wrong file size"
642 [ $(calc_osc_stats lockless_truncate) -eq 0 ] ||
643 error "lockless truncate doesn't use cached locks"
645 log "checking not cached lockless truncate"
646 $TRUNCATE $DIR2/$tfile 5000000
647 $CHECKSTAT -s 5000000 $DIR1/$tfile || error "wrong file size"
648 [ $(calc_osc_stats lockless_truncate) -ne 0 ] ||
649 error "not cached trancate isn't lockless"
651 log "disabled lockless truncate"
652 enable_lockless_truncate 0
654 $TRUNCATE $DIR2/$tfile 3000000
655 $CHECKSTAT -s 3000000 $DIR1/$tfile || error "wrong file size"
656 [ $(calc_osc_stats lockless_truncate) -eq 0 ] ||
657 error "lockless truncate disabling failed"
659 # restore lockless_truncate default values
660 restore_lustre_params < $p
663 run_test 32a "lockless truncate"
665 test_32b() { # bug 11270
666 remote_ost_nodsh && skip "remote OST with nodsh" && return
669 local p="$TMP/sanityN-$TESTNAME.parameters"
670 save_lustre_params $HOSTNAME "osc.*.contention_seconds" > $p
671 for node in $(osts_nodes); do
672 save_lustre_params $node "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
673 save_lustre_params $node "ldlm.namespaces.filter-*.contended_locks" >> $p
674 save_lustre_params $node "ldlm.namespaces.filter-*.contention_seconds" >> $p
677 # agressive lockless i/o settings
678 for node in $(osts_nodes); do
679 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'
681 lctl set_param -n osc.*.contention_seconds 60
682 for i in $(seq 5); do
683 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > /dev/null 2>&1
684 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > /dev/null 2>&1
686 [ $(calc_osc_stats lockless_write_bytes) -ne 0 ] || error "lockless i/o was not triggered"
687 # disable lockless i/o (it is disabled by default)
688 for node in $(osts_nodes); do
689 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'
691 # set contention_seconds to 0 at client too, otherwise Lustre still
692 # remembers lock contention
693 lctl set_param -n osc.*.contention_seconds 0
695 for i in $(seq 1); do
696 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > /dev/null 2>&1
697 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > /dev/null 2>&1
699 [ $(calc_osc_stats lockless_write_bytes) -eq 0 ] ||
700 error "lockless i/o works when disabled"
702 restore_lustre_params <$p
705 run_test 32b "lockless i/o"
709 local mdts=$(get_facets MDS)
714 for mds in ${mdts//,/ }; do
716 dev=$(basename $(do_facet $mds lctl get_param -n osd.${!varsvc}.mntdev))
717 val=$(do_facet $mds "procfile=/proc/fs/jbd/$dev/info;
718 [ -f \\\$procfile ] || procfile=/proc/fs/jbd2/$dev/info;
719 [ -f \\\$procfile ] || procfile=/proc/fs/jbd2/${dev}\:\\\*/info;
720 cat \\\$procfile | head -1;")
722 stat=$(( stat + val))
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 local nfiles=${TEST33_NFILES:-10000}
736 local param_file=$TMP/$tfile-params
738 save_lustre_params $(comma_list $(mdts_nodes)) "mdt.*.commit_on_sharing" > $param_file
746 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
750 do_nodes $CLIENT1,$CLIENT2 "mkdir -p $DIR1/$tdir-\\\$(hostname)-$i"
752 jbdold=$(print_jbd_stat)
753 echo "=== START createmany old: $jbdold transaction"
754 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")
755 jbdnew=$(print_jbd_stat)
756 jbd=$(( jbdnew - jbdold ))
757 echo "=== END createmany new: $jbdnew transaction : $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
758 avgjbd=$(( avgjbd + jbd ))
759 avgtime=$(( avgtime + elapsed ))
761 eval cos${COS}_jbd=$((avgjbd / 3))
762 eval cos${COS}_time=$((avgtime / 3))
765 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
766 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
767 [ "$cos0_jbd" != 0 ] && echo "COS=1 vs COS=0 jbd: $((((cos1_jbd/cos0_jbd - 1)) * 100 )) %"
768 [ "$cos0_time" != 0 ] && echo "COS=1 vs COS=0 time: $((((cos1_time/cos0_time - 1)) * 100 )) %"
770 restore_lustre_params < $param_file
774 run_test 33a "commit on sharing, cross crete/delete, 2 clients, benchmark"
776 # End commit on sharing tests
778 get_ost_lock_timeouts() {
779 local nodes=${1:-$(comma_list $(osts_nodes))}
781 local locks=$(do_nodes $nodes \
782 "lctl get_param -n ldlm.namespaces.filter-*.lock_timeouts" | calc_sum)
791 for OPER in notimeout timeout ; do
792 rm $DIR1/$tfile 2>/dev/null
793 lock_in=$(get_ost_lock_timeouts)
794 if [ $OPER == "timeout" ] ; then
795 for j in `seq $OSTCOUNT`; do
796 #define OBD_FAIL_PTLRPC_HPREQ_TIMEOUT 0x511
797 do_facet ost$j lctl set_param fail_loc=0x511
799 echo lock should expire
801 for j in `seq $OSTCOUNT`; do
802 #define OBD_FAIL_PTLRPC_HPREQ_NOTIMEOUT 0x512
803 do_facet ost$j lctl set_param fail_loc=0x512
805 echo lock should not expire
807 echo writing on client1
808 dd if=/dev/zero of=$DIR1/$tfile count=100 conv=notrunc > /dev/null 2>&1
810 echo reading on client2
811 dd of=/dev/null if=$DIR2/$tfile > /dev/null 2>&1
812 # wait for a lock timeout
814 lock_out=$(get_ost_lock_timeouts)
815 if [ $OPER == "timeout" ] ; then
816 if [ $lock_in == $lock_out ]; then
817 error "no lock timeout happened"
822 if [ $lock_in != $lock_out ]; then
823 error "lock timeout happened"
830 run_test 34 "no lock timeout under IO"
832 test_35() { # bug 17645
835 for imp in /proc/fs/lustre/mdc/$FSNAME-MDT*-mdc-*; do
836 g=$(awk '/generation/{print $2}' $imp/import)
841 mkdir -p $MOUNT1/$tfile
844 # Let's initiate -EINTR situation by setting fail_loc and take
845 # write lock on same file from same client. This will not cause
846 # bl_ast yet as lock is already in local cache.
847 #define OBD_FAIL_LDLM_INTR_CP_AST 0x317
848 do_facet client "lctl set_param fail_loc=0x80000317"
849 local timeout=`do_facet $SINGLEMDS lctl get_param -n timeout`
850 let timeout=timeout*3
852 while test $nr -lt 10; do
853 log "Race attempt $nr"
854 local blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
855 test "x$blk1" = "x" && blk1=0
856 createmany -o $MOUNT2/$tfile/a 4000 &
860 # Let's make conflict and bl_ast
861 ls -la $MOUNT1/$tfile > /dev/null &
864 log "Wait for $pid1 $pid2 for $timeout sec..."
866 kill -9 $pid1 $pid2 > /dev/null 2>&1
868 local blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
869 test "x$blk2" = "x" && blk2=0
870 test $blk2 -gt $blk1 && break
871 rm -fr $MOUNT1/$tfile/*
875 do_facet client "lctl set_param fail_loc=0x0"
876 df -h $MOUNT1 $MOUNT2
878 for imp in /proc/fs/lustre/mdc/$FSNAME-MDT*-mdc-*; do
879 g=$(awk '/generation/{print $2}' $imp/import)
880 if ! test "$g" -eq "${generation[count]}"; then
881 error "Eviction happened on import $(basename $imp)"
886 run_test 35 "-EINTR cp_ast vs. bl_ast race does not evict client"
888 test_36() { #bug 16417
894 $LFS setstripe -c -1 $DIR1/$tdir
897 let SIZE_B=SIZE*1024*1024
899 while [ $i -le 10 ]; do
900 lctl mark "start test"
901 local before=$($LFS df | awk '{if ($1 ~/^filesystem/) {print $5; exit} }')
902 dd if=/dev/zero of=$DIR1/$tdir/file000 bs=1M count=$SIZE
905 local after_dd=$($LFS df | awk '{if ($1 ~/^filesystem/) {print $5; exit} }')
906 multiop_bg_pause $DIR2/$tdir/file000 O_r${SIZE_B}c || return 3
908 rm -f $DIR1/$tdir/file000
912 local after=$($LFS df | awk '{if ($1 ~/^filesystem/) {print $5; exit} }')
913 echo "*** cycle($i) *** before($before):after_dd($after_dd):after($after)"
914 # this free space! not used
915 if [ $after_dd -ge $after ]; then
922 run_test 36 "handle ESTALE/open-unlink corectly"
924 test_37() { # bug 18695
926 multiop_bg_pause $DIR1/$tdir D_c || return 1
928 # create large directory (32kB seems enough from e2fsck, ~= 1000 files)
929 createmany -m $DIR2/$tdir/f 10000
930 # set mtime/atime backward
931 touch -t 198001010000 $DIR2/$tdir
933 nr_files=`lfs find $DIR1/$tdir -type f | wc -l`
934 [ $nr_files -eq 10000 ] || error "$nr_files != 10000 truncated directory?"
937 run_test 37 "check i_size is not updated for directory on close (bug 18695) =============="
939 # this should be set to past
940 TEST_39_MTIME=`date -d "1 year ago" +%s`
944 local client1=${CLIENT1:-`hostname`}
945 local client2=${CLIENT2:-`hostname`}
947 do_node $client1 "touch $DIR1/$tfile"
949 do_node $client1 "touch -m -d @$TEST_39_MTIME $DIR1/$tfile"
950 local mtime1=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
951 [ "$mtime1" = $TEST_39_MTIME ] || \
952 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
954 local d1=`do_node $client1 date +%s`
955 do_node $client1 'echo hello >> '$DIR1/$tfile
956 local d2=`do_node $client1 date +%s`
958 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
959 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
960 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
962 do_node $client1 "mv $DIR1/$tfile $DIR1/$tfile-1"
964 for (( i=0; i < 2; i++ )) ; do
965 local mtime3=`do_node $client2 "stat -c %Y $DIR1/$tfile-1"`
966 [ "$mtime2" = "$mtime3" ] || \
967 error "mtime ($mtime2) changed (to $mtime3) on rename"
970 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
973 run_test 39a "test from 11063 =================================="
976 local client1=${CLIENT1:-`hostname`}
977 local client2=${CLIENT2:-`hostname`}
981 local mtime1=`stat -c %Y $DIR1/$tfile`
982 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
985 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
987 for (( i=0; i < 2; i++ )) ; do
988 local mtime3=`stat -c %Y $DIR1/$tfile`
989 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
991 [ "$mtime3" = "$mtime4" ] || \
992 error "different mtime on clients: $mtime3, $mtime4"
993 [ "$mtime3" = $TEST_39_MTIME ] || \
994 error "lost mtime: $mtime3, should be $TEST_39_MTIME"
997 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1000 run_test 39b "11063 problem 1 =================================="
1003 local client1=${CLIENT1:-`hostname`}
1004 local client2=${CLIENT2:-`hostname`}
1006 echo hello > $DIR1/$tfile
1008 local mtime1=`stat -c %Y $DIR1/$tfile`
1009 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1010 [ "$mtime1" = "$mtime2" ] || \
1011 error "create: different mtime on clients: $mtime1, $mtime2"
1014 $TRUNCATE $DIR1/$tfile 1
1016 for (( i=0; i < 2; i++ )) ; do
1017 local mtime3=`stat -c %Y $DIR1/$tfile`
1018 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1020 [ "$mtime3" = "$mtime4" ] || \
1021 error "different mtime on clients: $mtime3, $mtime4"
1022 [ "$mtime3" -gt $mtime2 ] || \
1023 error "truncate did not update mtime: $mtime2, $mtime3"
1025 cancel_lru_locks osc
1026 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1029 run_test 39c "check truncate mtime update ======================"
1031 # check that pid exists hence second operation wasn't blocked by first one
1032 # if it is so then there is no conflict, return 0
1033 # else second operation is conflicting with first one, return 1
1034 check_pdo_conflict() {
1037 if [[ `ps --pid $pid | wc -l` == 1 ]]; then
1047 # test 40: check non-blocking operations
1049 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1050 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1051 mkdir $DIR1/$tfile &
1054 touch $DIR2/$tfile-2
1055 check_pdo_conflict $PID1 || error "create is blocked"
1056 mkdir $DIR2/$tfile-3
1057 check_pdo_conflict $PID1 || error "mkdir is blocked"
1058 link $DIR2/$tfile-2 $DIR2/$tfile-4
1059 check_pdo_conflict $PID1 || error "link is blocked"
1060 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1061 check_pdo_conflict $PID1 || error "rename is blocked"
1062 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1063 check_pdo_conflict $PID1 || error "getattr is blocked"
1064 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1065 rmdir $DIR2/$tfile-3
1066 check_pdo_conflict $PID1 || error "unlink is blocked"
1067 # all operations above shouldn't wait the first one
1068 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1073 run_test 40a "pdirops: create vs others =============="
1076 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1077 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1078 touch $DIR1/$tfile &
1082 touch $DIR2/$tfile-2
1083 check_pdo_conflict $PID1 || error "create is blocked"
1084 mkdir $DIR2/$tfile-3
1085 check_pdo_conflict $PID1 || error "mkdir is blocked"
1086 link $DIR2/$tfile-2 $DIR2/$tfile-4
1087 check_pdo_conflict $PID1 || error "link is blocked"
1088 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1089 check_pdo_conflict $PID1 || error "rename is blocked"
1090 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1091 check_pdo_conflict $PID1 || error "getattr is blocked"
1092 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1093 rmdir $DIR2/$tfile-3
1094 check_pdo_conflict $PID1 || error "unlink is blocked"
1095 # all operations above shouldn't wait the first one
1096 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1101 run_test 40b "pdirops: open|create and others =============="
1105 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1106 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1107 link $DIR1/$tfile $DIR1/$tfile-0 &
1111 touch $DIR2/$tfile-2
1112 check_pdo_conflict $PID1 || error "create is blocked"
1113 mkdir $DIR2/$tfile-3
1114 check_pdo_conflict $PID1 || error "mkdir is blocked"
1115 link $DIR2/$tfile-2 $DIR2/$tfile-4
1116 check_pdo_conflict $PID1 || error "link is blocked"
1117 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1118 check_pdo_conflict $PID1 || error "rename is blocked"
1119 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1120 check_pdo_conflict $PID1 || error "getattr is blocked"
1121 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1122 rmdir $DIR2/$tfile-3
1123 check_pdo_conflict $PID1 || error "unlink is blocked"
1124 # all operations above shouldn't wait the first one
1125 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1130 run_test 40c "pdirops: link and others =============="
1134 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1135 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1140 touch $DIR2/$tfile-2
1141 check_pdo_conflict $PID1 || error "create is blocked"
1142 mkdir $DIR2/$tfile-3
1143 check_pdo_conflict $PID1 || error "mkdir is blocked"
1144 link $DIR2/$tfile-2 $DIR2/$tfile-4
1145 check_pdo_conflict $PID1 || error "link is blocked"
1146 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1147 check_pdo_conflict $PID1 || error "rename is blocked"
1148 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1149 check_pdo_conflict $PID1 || error "getattr is blocked"
1150 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1151 rmdir $DIR2/$tfile-3
1152 check_pdo_conflict $PID1 || error "unlink is blocked"
1153 # all operations above shouldn't wait the first one
1154 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1158 run_test 40d "pdirops: unlink and others =============="
1162 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1163 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1164 mv $DIR1/$tfile $DIR1/$tfile-0 &
1168 touch $DIR2/$tfile-2
1169 check_pdo_conflict $PID1 || error "create is blocked"
1170 mkdir $DIR2/$tfile-3
1171 check_pdo_conflict $PID1 || error "mkdir is blocked"
1172 link $DIR2/$tfile-2 $DIR2/$tfile-4
1173 check_pdo_conflict $PID1 || error "link is blocked"
1174 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1175 check_pdo_conflict $PID1 || error "getattr is blocked"
1176 rm $DIR2/$tfile-4 $DIR2/$tfile-2
1177 rmdir $DIR2/$tfile-3
1178 check_pdo_conflict $PID1 || error "unlink is blocked"
1179 # all operations above shouldn't wait the first one
1180 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1185 run_test 40e "pdirops: rename and others =============="
1187 # test 41: create blocking operations
1189 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1190 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1191 multiop $DIR1/$tfile oO_CREAT:O_RDWR:c &
1194 mkdir $DIR2/$tfile && error "mkdir must fail"
1195 check_pdo_conflict $PID1 && { wait $PID1; echo "mkdir isn't blocked"; }
1199 run_test 41a "pdirops: create vs mkdir =============="
1202 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1203 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1204 multiop $DIR1/$tfile oO_CREAT:O_RDWR:c &
1207 multiop $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1208 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1212 run_test 41b "pdirops: create vs create =============="
1215 touch $DIR1/$tfile-2
1216 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1217 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1218 multiop $DIR1/$tfile oO_CREAT:O_RDWR:c &
1221 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
1222 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1226 run_test 41c "pdirops: create vs link =============="
1229 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1230 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1231 multiop $DIR1/$tfile oO_CREAT:O_RDWR:c &
1234 rm $DIR2/$tfile || error "unlink must succeed"
1235 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1239 run_test 41d "pdirops: create vs unlink =============="
1242 touch $DIR1/$tfile-2
1243 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1244 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1245 multiop $DIR1/$tfile oO_CREAT:O_RDWR:c &
1248 mv $DIR2/$tfile-2 $DIR2/$tfile || error "rename must succeed"
1249 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1253 run_test 41e "pdirops: create and rename (tgt) =============="
1256 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1257 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1258 multiop $DIR1/$tfile oO_CREAT:O_RDWR:c &
1261 mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
1262 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1266 run_test 41f "pdirops: create and rename (src) =============="
1269 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1270 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1271 multiop $DIR1/$tfile oO_CREAT:O_RDWR:c &
1274 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
1275 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1279 run_test 41g "pdirops: create vs getattr =============="
1282 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1283 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1284 multiop $DIR1/$tfile oO_CREAT:O_RDWR:c &
1287 ls -lia $DIR2/ > /dev/null
1288 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1292 run_test 41h "pdirops: create vs readdir =============="
1294 # test 42: unlink and blocking operations
1296 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1297 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1298 mkdir $DIR1/$tfile &
1301 mkdir $DIR2/$tfile && error "mkdir must fail"
1302 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1306 run_test 42a "pdirops: mkdir vs mkdir =============="
1309 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1310 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1311 mkdir $DIR1/$tfile &
1314 multiop $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1315 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1319 run_test 42b "pdirops: mkdir vs create =============="
1322 touch $DIR1/$tfile-2
1323 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1324 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1325 mkdir $DIR1/$tfile &
1328 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
1329 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1333 run_test 42c "pdirops: mkdir vs link =============="
1336 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1337 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1338 mkdir $DIR1/$tfile &
1341 rmdir $DIR2/$tfile || error "unlink must succeed"
1342 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1346 run_test 42d "pdirops: mkdir vs unlink =============="
1349 touch $DIR1/$tfile-2
1350 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1351 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1352 mkdir $DIR1/$tfile &
1355 mv -T $DIR2/$tfile-2 $DIR2/$tfile && error "rename must fail"
1356 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1360 run_test 42e "pdirops: mkdir and rename (tgt) =============="
1363 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1364 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1365 mkdir $DIR1/$tfile &
1368 mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
1369 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1373 run_test 42f "pdirops: mkdir and rename (src) =============="
1376 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1377 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1378 mkdir $DIR1/$tfile &
1381 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
1382 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1386 run_test 42g "pdirops: mkdir vs getattr =============="
1389 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1390 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1391 mkdir $DIR1/$tfile &
1394 ls -lia $DIR2/ > /dev/null
1395 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1399 run_test 42h "pdirops: mkdir vs readdir =============="
1401 # test 43: unlink and blocking operations
1404 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1405 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1409 mkdir $DIR2/$tfile || error "mkdir must succeed"
1410 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1414 run_test 43a "pdirops: unlink vs mkdir =============="
1418 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1419 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1423 multiop $DIR2/$tfile oO_CREAT:O_EXCL:c || error "create must succeed"
1424 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1428 run_test 43b "pdirops: unlink vs create =============="
1432 touch $DIR1/$tfile-2
1433 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1434 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1438 link $DIR2/$tfile-2 $DIR2/$tfile || error "link must succeed"
1439 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1443 run_test 43c "pdirops: unlink vs link =============="
1447 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1448 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1452 rm $DIR2/$tfile && error "unlink must fail"
1453 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1457 run_test 43d "pdirops: unlink vs unlink =============="
1461 touch $DIR1/$tfile-2
1462 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1463 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1467 mv -u $DIR2/$tfile-2 $DIR2/$tfile || error "rename must succeed"
1468 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1472 run_test 43e "pdirops: unlink and rename (tgt) =============="
1476 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1477 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1481 mv $DIR2/$tfile $DIR2/$tfile-2 && error "rename must fail"
1482 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1486 run_test 43f "pdirops: unlink and rename (src) =============="
1490 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1491 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1495 stat $DIR2/$tfile > /dev/null && error "stat must fail"
1496 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1500 run_test 43g "pdirops: unlink vs getattr =============="
1504 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1505 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1509 ls -lia $DIR2/ > /dev/null
1510 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1514 run_test 43h "pdirops: unlink vs readdir =============="
1516 # test 44: rename tgt and blocking operations
1518 touch $DIR1/$tfile-2
1519 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1520 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1521 mv $DIR1/$tfile-2 $DIR1/$tfile &
1524 mkdir $DIR2/$tfile && error "mkdir must fail"
1525 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1529 run_test 44a "pdirops: rename tgt vs mkdir =============="
1532 touch $DIR1/$tfile-2
1533 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1534 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1535 mv $DIR1/$tfile-2 $DIR1/$tfile &
1538 multiop $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1539 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1543 run_test 44b "pdirops: rename tgt vs create =============="
1546 touch $DIR1/$tfile-2
1547 touch $DIR1/$tfile-3
1548 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1549 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1550 mv $DIR1/$tfile-2 $DIR1/$tfile &
1553 link $DIR2/$tfile-3 $DIR2/$tfile && error "link must fail"
1554 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1558 run_test 44c "pdirops: rename tgt vs link =============="
1561 touch $DIR1/$tfile-2
1562 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1563 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1564 mv $DIR1/$tfile-2 $DIR1/$tfile &
1567 rm $DIR2/$tfile || error "unlink must succeed"
1568 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1572 run_test 44d "pdirops: rename tgt vs unlink =============="
1576 touch $DIR1/$tfile-2
1577 touch $DIR1/$tfile-3
1578 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1579 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1580 mv $DIR1/$tfile-2 $DIR1/$tfile &
1583 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
1584 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1588 run_test 44e "pdirops: rename tgt and rename (tgt) =============="
1591 touch $DIR1/$tfile-2
1592 touch $DIR1/$tfile-3
1593 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1594 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1595 mv $DIR1/$tfile-2 $DIR1/$tfile &
1598 mv $DIR2/$tfile $DIR2/$tfile-3 || error "rename must succeed"
1599 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1603 run_test 44f "pdirops: rename tgt and rename (src) =============="
1606 touch $DIR1/$tfile-2
1607 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1608 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1609 mv $DIR1/$tfile-2 $DIR1/$tfile &
1612 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
1613 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1617 run_test 44g "pdirops: rename tgt vs getattr =============="
1620 touch $DIR1/$tfile-2
1621 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1622 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1623 mv $DIR1/$tfile-2 $DIR1/$tfile &
1626 ls -lia $DIR2/ > /dev/null
1627 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1631 run_test 44h "pdirops: rename tgt vs readdir =============="
1633 # test 45: rename src and blocking operations
1636 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1637 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1638 mv $DIR1/$tfile $DIR1/$tfile-2 &
1641 mkdir $DIR2/$tfile || error "mkdir must succeed"
1642 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1646 run_test 45a "pdirops: rename src vs mkdir =============="
1650 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1651 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1652 mv $DIR1/$tfile $DIR1/$tfile-2 &
1655 multiop $DIR2/$tfile oO_CREAT:O_EXCL:c || error "create must succeed"
1656 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1660 run_test 45b "pdirops: rename src vs create =============="
1664 touch $DIR1/$tfile-3
1665 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1666 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1667 mv $DIR1/$tfile $DIR1/$tfile-2 &
1670 link $DIR2/$tfile-3 $DIR2/$tfile || error "link must succeed"
1671 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1675 run_test 45c "pdirops: rename src vs link =============="
1679 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1680 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1681 mv $DIR1/$tfile $DIR1/$tfile-2 &
1684 rm $DIR2/$tfile && error "unlink must fail"
1685 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1689 run_test 45d "pdirops: rename src vs unlink =============="
1693 touch $DIR1/$tfile-3
1694 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1695 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1696 mv $DIR1/$tfile $DIR1/$tfile-2 &
1699 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
1700 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1704 run_test 45e "pdirops: rename src and rename (tgt) =============="
1708 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1709 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1710 mv $DIR1/$tfile $DIR1/$tfile-2 &
1713 mv $DIR2/$tfile $DIR2/$tfile-3 && error "rename must fail"
1714 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1718 run_test 45f "pdirops: rename src and rename (src) =============="
1722 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1723 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1724 mv $DIR1/$tfile $DIR1/$tfile-2 &
1727 stat $DIR2/$tfile > /dev/null && "stat must fail"
1728 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1732 run_test 45g "pdirops: rename src vs getattr =============="
1736 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1737 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1738 mv $DIR1/$tfile $DIR1/$tfile-2 &
1741 ls -lia $DIR2/ > /dev/null
1742 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1746 run_test 45h "pdirops: unlink vs readdir =============="
1748 # test 46: link and blocking operations
1750 touch $DIR1/$tfile-2
1751 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1752 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1753 link $DIR1/$tfile-2 $DIR1/$tfile &
1756 mkdir $DIR2/$tfile && error "mkdir must fail"
1757 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1761 run_test 46a "pdirops: link vs mkdir =============="
1764 touch $DIR1/$tfile-2
1765 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1766 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1767 link $DIR1/$tfile-2 $DIR1/$tfile &
1770 multiop $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1771 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1775 run_test 46b "pdirops: link vs create =============="
1778 touch $DIR1/$tfile-2
1779 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1780 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1781 link $DIR1/$tfile-2 $DIR1/$tfile &
1784 link $DIR2/$tfile $DIR2/$tfile && error "link must fail"
1785 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1789 run_test 46c "pdirops: link vs link =============="
1792 touch $DIR1/$tfile-2
1793 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1794 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1795 link $DIR1/$tfile-2 $DIR1/$tfile &
1798 rm $DIR2/$tfile || error "unlink must succeed"
1799 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1803 run_test 46d "pdirops: link vs unlink =============="
1806 touch $DIR1/$tfile-2
1807 touch $DIR1/$tfile-3
1808 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1809 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1810 link $DIR1/$tfile-2 $DIR1/$tfile &
1813 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
1814 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1818 run_test 46e "pdirops: link and rename (tgt) =============="
1821 touch $DIR1/$tfile-2
1822 touch $DIR1/$tfile-3
1823 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1824 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1825 link $DIR1/$tfile-2 $DIR1/$tfile &
1828 mv $DIR2/$tfile $DIR2/$tfile-3 || error "rename must succeed"
1829 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1833 run_test 46f "pdirops: link and rename (src) =============="
1836 touch $DIR1/$tfile-2
1837 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1838 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1839 link $DIR1/$tfile-2 $DIR1/$tfile &
1842 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
1843 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1847 run_test 46g "pdirops: link vs getattr =============="
1850 touch $DIR1/$tfile-2
1851 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1852 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1853 link $DIR1/$tfile-2 $DIR1/$tfile &
1856 ls -lia $DIR2/ > /dev/null
1857 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1861 run_test 46h "pdirops: link vs readdir =============="
1865 dd if=/dev/zero of=$DIR1/$tfile bs=1K count=10
1866 #define OBD_FAIL_OSC_CP_ENQ_RACE 0x410
1867 do_facet client "lctl set_param fail_loc=0x410"
1868 $TRUNCATE $DIR2/$tfile $trunc_size
1869 do_facet client "lctl set_param fail_loc=0x0"
1871 size=`stat -c %s $DIR2/$tfile`
1872 [ $size -eq $trunc_size ] || error "wrong size"
1874 run_test 50 "osc lvb attrs: enqueue vs. CP AST =============="
1876 log "cleanup: ======================================================"
1878 [ "$(mount | grep $MOUNT2)" ] && umount $MOUNT2
1879 check_and_cleanup_lustre
1881 echo '=========================== finished ==============================='
1882 [ -f "$SANITYLOG" ] && cat $SANITYLOG && grep -q FAIL $SANITYLOG && exit 1 || true
1883 echo "$0: completed"