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 2> /dev/null &&
12 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 11 14" || true
14 # Tests that fail on uml
15 [ "$UML" = "true" ] && EXCEPT="$EXCEPT 7"
17 # It will be ported soon.
21 PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH
24 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
25 GETSTRIPE=${GETSTRIPE:-lfs getstripe}
26 SETSTRIPE=${SETSTRIPE:-lstripe}
27 MCREATE=${MCREATE:-mcreate}
28 OPENFILE=${OPENFILE:-openfile}
29 OPENUNLINK=${OPENUNLINK:-openunlink}
30 export TMP=${TMP:-/tmp}
31 MOUNT_2=${MOUNT_2:-"yes"}
32 CHECK_GRANT=${CHECK_GRANT:-"yes"}
33 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
34 TSTUSR=${TSTUSR:-"quota_usr"}
38 export NAME=${NAME:-local}
40 LUSTRE=${LUSTRE:-`dirname $0`/..}
41 . $LUSTRE/tests/test-framework.sh
45 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
48 [ "$SLOW" = "no" ] && EXCEPT_SLOW="12 23 33a"
55 check_and_setup_lustre
57 LOVNAME=`lctl get_param -n llite.*.lov.common_name | tail -n 1`
58 OSTCOUNT=`lctl get_param -n lov.$LOVNAME.numobd`
61 rm -rf $DIR1/[df][0-9]* $DIR1/lnk
63 SAMPLE_FILE=$TMP/$(basename $0 .sh).junk
64 dd if=/dev/urandom of=$SAMPLE_FILE bs=1M count=1
66 # $RUNAS_ID may get set incorrectly somewhere else
67 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
69 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
78 [ -f $DIR2/f1 ] || error
80 run_test 1a "check create on 2 mtpt's =========================="
84 $CHECKSTAT -t file -p 0777 $DIR1/f1 || error
87 run_test 1b "check attribute updates on 2 mtpt's ==============="
90 $CHECKSTAT -t file -p 0666 $DIR1/f1 || error
92 run_test 1c "check after remount attribute updates on 2 mtpt's ="
96 $CHECKSTAT -a $DIR1/f1 || error
98 run_test 1d "unlink on one mountpoint removes file on other ===="
104 $CHECKSTAT -t file -p 0777 $DIR1/f2a || error
106 run_test 2a "check cached attribute updates on 2 mtpt's ========"
112 $CHECKSTAT -t file -p 0777 $DIR2/f2b || error
114 run_test 2b "check cached attribute updates on 2 mtpt's ========"
116 # NEED TO SAVE ROOT DIR MODE
119 $CHECKSTAT -t dir -p 0777 $DIR2 || error
121 run_test 2c "check cached attribute updates on 2 mtpt's root ==="
125 $CHECKSTAT -t dir -p 0755 $DIR2 || error
127 run_test 2d "check cached attribute updates on 2 mtpt's root ==="
134 $RUNAS dd if=/dev/zero of=$DIR2/$tfile count=1 || error
136 run_test 2e "check chmod on root is propagated to others"
139 local target="this/is/good"
140 ln -s $target $DIR1/$tfile || error "ln -s $target $DIR1/$tfile failed"
141 [ "$(ls -l $DIR2/$tfile | sed -e 's/.* -> //')" = "$target" ] ||
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
244 mkdir $DIR1/d13 || error
245 cd $DIR1/d13 || error
247 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
249 rm -f $DIR2/d13/f13 || error
250 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (1)" || true
251 # need to run it twice
252 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
254 rm -f $DIR2/d13/f13 || error
255 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (2)" || true
257 run_test 13 "test directory page revocation ===================="
261 cp -p /bin/ls $DIR1/$tdir/$tfile
262 multiop_bg_pause $DIR1/$tdir/$tfile Ow_c || return 1
265 $DIR2/$tdir/$tfile && error || true
267 wait $MULTIPID || return 2
269 run_test 14 "execution of file open for write returns -ETXTBSY ="
273 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
274 MULTIOP_PROG=$DIR1/d14/multiop multiop_bg_pause $TMP/test14.junk O_c || return 1
276 multiop $DIR2/d14/multiop Oc && error "expected error, got success"
277 kill -USR1 $MULTIOP_PID || return 2
278 wait $MULTIOP_PID || return 3
279 rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop"
281 run_test 14a "open(RDWR) of executing file returns -ETXTBSY ===="
283 test_14b() { # bug 3192, 7040
285 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
286 MULTIOP_PROG=$DIR1/d14/multiop multiop_bg_pause $TMP/test14.junk O_c || return 1
288 $TRUNCATE $DIR2/d14/multiop 0 && kill -9 $MULTIOP_PID && \
289 error "expected truncate error, got success"
290 kill -USR1 $MULTIOP_PID || return 2
291 wait $MULTIOP_PID || return 3
292 cmp `which multiop` $DIR1/d14/multiop || error "binary changed"
293 rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop"
295 run_test 14b "truncate of executing file returns -ETXTBSY ======"
297 test_14c() { # bug 3430, 7040
299 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
300 MULTIOP_PROG=$DIR1/d14/multiop multiop_bg_pause $TMP/test14.junk O_c || return 1
302 cp /etc/hosts $DIR2/d14/multiop && error "expected error, got success"
303 kill -USR1 $MULTIOP_PID || return 2
304 wait $MULTIOP_PID || return 3
305 cmp `which multiop` $DIR1/d14/multiop || error "binary changed"
306 rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop"
308 run_test 14c "open(O_TRUNC) of executing file return -ETXTBSY =="
310 test_14d() { # bug 10921
312 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
313 MULTIOP_PROG=$DIR1/d14/multiop multiop_bg_pause $TMP/test14.junk O_c || return 1
316 chmod 600 $DIR1/d14/multiop || error "chmod failed"
317 kill -USR1 $MULTIOP_PID || return 2
318 wait $MULTIOP_PID || return 3
319 cmp `which multiop` $DIR1/d14/multiop || error "binary changed"
320 rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop"
322 run_test 14d "chmod of executing file is still possible ========"
324 test_15() { # bug 974 - ENOSPC
326 sh oos2.sh $MOUNT1 $MOUNT2
327 grant_error=`dmesg | grep "> available"`
328 [ -z "$grant_error" ] || error "$grant_error"
330 run_test 15 "test out-of-space with multiple writers ==========="
333 rm -f $MOUNT1/fsxfile
334 lfs setstripe $MOUNT1/fsxfile -c -1 # b=10919
335 fsx -c 50 -p 100 -N 2500 -l $((SIZE * 256)) -S 0 $MOUNT1/fsxfile $MOUNT2/fsxfile
337 run_test 16 "2500 iterations of dual-mount fsx ================="
339 test_17() { # bug 3513, 3667
340 remote_ost_nodsh && skip "remote OST with nodsh" && return
342 lfs setstripe $DIR1/$tfile -i 0 -c 1
343 cp $SAMPLE_FILE $DIR1/$tfile
344 cancel_lru_locks osc > /dev/null
345 #define OBD_FAIL_ONCE|OBD_FAIL_LDLM_CREATE_RESOURCE 0x30a
346 do_facet ost1 lctl set_param fail_loc=0x8000030a
347 ls -ls $DIR1/$tfile | awk '{ print $1,$6 }' > $DIR1/$tfile-1 & \
348 ls -ls $DIR2/$tfile | awk '{ print $1,$6 }' > $DIR2/$tfile-2
350 diff -u $DIR1/$tfile-1 $DIR2/$tfile-2 || error "files are different"
352 run_test 17 "resource creation/LVB creation race ==============="
355 $LUSTRE/tests/mmap_sanity -d $MOUNT1 -m $MOUNT2
358 run_test 18 "mmap sanity check ================================="
360 test_19() { # bug3811
361 [ -d /proc/fs/lustre/obdfilter ] || return 0
363 MAX=`lctl get_param -n obdfilter.*.readcache_max_filesize | head -n 1`
364 lctl set_param -n obdfilter.*OST*.readcache_max_filesize=4096
365 dd if=/dev/urandom of=$TMP/f19b bs=512k count=32
366 SUM=`cksum $TMP/f19b | cut -d" " -f 1,2`
367 cp $TMP/f19b $DIR1/f19b
368 for i in `seq 1 20`; do
369 [ $((i % 5)) -eq 0 ] && log "test_18 loop $i"
370 cancel_lru_locks osc > /dev/null
371 cksum $DIR1/f19b | cut -d" " -f 1,2 > $TMP/sum1 & \
372 cksum $DIR2/f19b | cut -d" " -f 1,2 > $TMP/sum2
374 [ "`cat $TMP/sum1`" = "$SUM" ] || \
375 error "$DIR1/f19b `cat $TMP/sum1` != $SUM"
376 [ "`cat $TMP/sum2`" = "$SUM" ] || \
377 error "$DIR2/f19b `cat $TMP/sum2` != $SUM"
379 lctl set_param -n obdfilter.*OST*.readcache_max_filesize=$MAX
382 run_test 19 "test concurrent uncached read races ==============="
387 CNT=$((`lctl get_param -n llite.*.dump_page_cache | wc -l`))
388 multiop $DIR1/f20 Ow8190c
389 multiop $DIR2/f20 Oz8194w8190c
390 multiop $DIR1/f20 Oz0r8190c
392 CNTD=$((`lctl get_param -n llite.*.dump_page_cache | wc -l` - $CNT))
394 error $CNTD" page left in cache after lock cancel" || true
396 run_test 20 "test extra readahead page left in cache ===="
403 test_21() { # Bug 5907
405 mount /etc $DIR1/d21 --bind || error "mount failed" # Poor man's mount.
407 rmdir -v $DIR1/d21 && error "Removed mounted directory"
408 rmdir -v $DIR2/d21 && echo "Removed mounted directory from another mountpoint, needs to be fixed"
409 test -d $DIR1/d21 || error "Mounted directory disappeared"
411 test -d $DIR2/d21 || test -d $DIR1/d21 && error "Removed dir still visible after umount"
414 run_test 21 " Try to remove mountpoint on another dir ===="
416 test_23() { # Bug 5972
417 echo "others should see updated atime while another read" > $DIR1/f23
419 # clear the lock(mode: LCK_PW) gotten from creating operation
423 #MAX_ATIME_DIFF 60, we update atime only if older than 60 seconds
426 multiop_bg_pause $DIR1/f23 or20_c || return 1
427 # with SOM and opencache enabled, we need to close a file and cancel
428 # open lock to get atime propogated to MDS
432 time2=`stat -c "%X" $DIR2/f23`
434 if (( $time2 <= $time1 )); then
435 error "atime doesn't update among nodes"
438 rm -f $DIR1/f23 || error "rm -f $DIR1/f23 failed"
441 run_test 23 " others should see updated atime while another read===="
445 lfs df || error "lfs df failed"
446 lfs df -ih || error "lfs df -ih failed"
447 lfs df -h $DIR1 || error "lfs df -h $DIR1 failed"
448 lfs df -i $DIR2 || error "lfs df -i $DIR2 failed"
449 lfs df $DIR1/$tfile || error "lfs df $DIR1/$tfile failed"
450 lfs df -ih $DIR2/$tfile || error "lfs df -ih $DIR2/$tfile failed"
452 OSC=`lctl dl | awk '/-osc-|OSC.*MNT/ {print $4}' | head -n 1`
453 # OSC=`lctl dl | awk '/-osc-/ {print $4}' | head -n 1`
454 lctl --device %$OSC deactivate
455 lfs df -i || error "lfs df -i with deactivated OSC failed"
456 lctl --device %$OSC activate
457 lfs df || error "lfs df with reactivated OSC failed"
459 run_test 24a "lfs df [-ih] [path] test ========================="
463 fsnum=`lfs df | grep -c "filesystem summary:"`
464 [ $fsnum -eq 2 ] || error "lfs df shows $fsnum != 2 filesystems."
466 run_test 24b "lfs df should show both filesystems ==============="
469 [ `lctl get_param -n mdc.*-mdc-*.connect_flags | grep -c acl` -lt 2 ] &&
470 skip "must have acl, skipping" && return
473 touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
474 chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
476 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
477 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
478 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 ||
481 error "setfacl $DIR2/$tdir #2"
482 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
483 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
484 error "setfacl $DIR2/$tdir #3"
485 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
486 setfacl -x u:$RUNAS_ID: -x g:$RUNAS_GID: $DIR1/$tdir ||
487 error "setfacl $DIR2/$tdir #4"
488 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
492 run_test 25 "change ACL on one mountpoint be seen on another ==="
495 utime $DIR1/f26a -s $DIR2/f26a || error
497 run_test 26a "allow mtime to get older"
502 echo "aaa" >> $DIR1/$tfile
504 chmod a+x $DIR2/$tfile
505 mt1=`stat -c %Y $DIR1/$tfile`
506 mt2=`stat -c %Y $DIR2/$tfile`
508 if [ x"$mt1" != x"$mt2" ]; then
509 error "not equal mtime, client1: "$mt1", client2: "$mt2"."
512 run_test 26b "sync mtime between ost and mds"
517 dd if=/dev/zero of=$DIR2/$tfile bs=$((4096+4))k conv=notrunc count=4 seek=3 &
522 dd if=/dev/zero of=$DIR1/$tfile bs=$((16384-1024))k conv=notrunc count=1 seek=4 &
527 dd if=/dev/zero of=$DIR1/$tfile bs=8k conv=notrunc count=1 seek=0
529 lctl set_param -n ldlm.dump_namespaces ""
530 wait $DD1_PID $DD2_PID
531 [ $? -ne 0 ] && lctl dk $TMP/debug || true
533 run_test 27 "align non-overlapping extent locks from request ==="
535 test_28() { # bug 9977
536 ECHO_UUID="ECHO_osc1_UUID"
537 tOST=`$LCTL dl | | awk '/-osc-|OSC.*MNT/ { print $4 }' | head -1`
539 lfs setstripe $DIR1/$tfile -s 1048576 -i 0 -c 2
540 tOBJID=`lfs getstripe $DIR1/$tfile |grep "^[[:space:]]\+1" |awk '{print $2}'`
541 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2
545 attach echo_client ECHO_osc1 $ECHO_UUID
549 tECHOID=`$LCTL dl | grep $ECHO_UUID | awk '{print $1}'`
550 $LCTL --device $tECHOID destroy "${tOBJID}:0"
558 # reading of 1st stripe should pass
559 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error
560 # reading of 2nd stripe should fail (this stripe was destroyed)
561 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 && error
563 # now, recreating test file
564 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2 || error
565 # reading of 1st stripe should pass
566 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error
567 # reading of 2nd stripe should pass
568 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 || error
570 run_test 28 "read/write/truncate file with lost stripes"
572 test_29() { # bug 10999
574 #define OBD_FAIL_LDLM_GLIMPSE 0x30f
575 lctl set_param fail_loc=0x8000030f
578 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1
581 #bug 11549 - permanently turn test off in b1_5
582 run_test 29 "lock put race between glimpse and enqueue ========="
584 test_30() { #bug #11110
586 cp -f /bin/bash $DIR1/$tdir/bash
587 /bin/sh -c 'sleep 1; rm -f $DIR2/$tdir/bash; cp /bin/bash $DIR2/$tdir' &
588 err=$($DIR1/$tdir/bash -c 'sleep 2; openfile -f O_RDONLY /proc/$$/exe >& /dev/null; echo $?')
590 [ $err -ne 116 ] && error_ignore 12900 "return code ($err) != -ESTALE" && return
594 run_test 30 "recreate file race ========="
597 mkdir -p $DIR1/$tdir || error "Creating dir $DIR1/$tdir"
598 writes=`LANG=C dd if=/dev/zero of=$DIR/$tdir/$tfile count=1 2>&1 |
599 awk 'BEGIN { FS="+" } /out/ {print $1}'`
600 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
601 lctl set_param fail_loc=0x314
602 reads=`LANG=C dd if=$DIR2/$tdir/$tfile of=/dev/null 2>&1 |
603 awk 'BEGIN { FS="+" } /in/ {print $1}'`
604 [ $reads -eq $writes ] || error "read" $reads "blocks, must be" $writes
606 run_test 31a "voluntary cancel / blocking ast race=============="
609 remote_ost || { skip "local OST" && return 0; }
610 remote_ost_nodsh && skip "remote OST w/o dsh" && return 0
611 mkdir -p $DIR1/$tdir || error "Creating dir $DIR1/$tdir"
612 lfs setstripe $DIR/$tdir/$tfile -i 0 -c 1
613 cp /etc/hosts $DIR/$tdir/$tfile
614 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
615 lctl set_param fail_loc=0x314
616 #define OBD_FAIL_LDLM_OST_FAIL_RACE 0x316
617 do_facet ost1 lctl set_param fail_loc=0x316
619 cat $DIR2/$tdir/$tfile > /dev/null 2>&1
620 lctl set_param fail_loc=0
621 do_facet ost1 lctl set_param fail_loc=0
622 # cleanup: reconnect the client back
625 run_test 31b "voluntary OST cancel / blocking ast race=============="
627 # enable/disable lockless truncate feature, depending on the arg 0/1
628 enable_lockless_truncate() {
629 lctl set_param -n osc.*.lockless_truncate $1
632 test_32a() { # bug 11270
633 local p="$TMP/sanityN-$TESTNAME.parameters"
634 save_lustre_params $HOSTNAME osc.*.lockless_truncate > $p
636 enable_lockless_truncate 1
638 lfs setstripe -c -1 $DIR1/$tfile
639 dd if=/dev/zero of=$DIR1/$tfile count=$OSTCOUNT bs=$STRIPE_BYTES > \
643 log "checking cached lockless truncate"
644 $TRUNCATE $DIR1/$tfile 8000000
645 $CHECKSTAT -s 8000000 $DIR2/$tfile || error "wrong file size"
646 [ $(calc_osc_stats lockless_truncate) -eq 0 ] ||
647 error "lockless truncate doesn't use cached locks"
649 log "checking not cached lockless truncate"
650 $TRUNCATE $DIR2/$tfile 5000000
651 $CHECKSTAT -s 5000000 $DIR1/$tfile || error "wrong file size"
652 [ $(calc_osc_stats lockless_truncate) -ne 0 ] ||
653 error "not cached trancate isn't lockless"
655 log "disabled lockless truncate"
656 enable_lockless_truncate 0
658 $TRUNCATE $DIR2/$tfile 3000000
659 $CHECKSTAT -s 3000000 $DIR1/$tfile || error "wrong file size"
660 [ $(calc_osc_stats lockless_truncate) -eq 0 ] ||
661 error "lockless truncate disabling failed"
663 # restore lockless_truncate default values
664 restore_lustre_params < $p
667 run_test 32a "lockless truncate"
669 test_32b() { # bug 11270
670 remote_ost_nodsh && skip "remote OST with nodsh" && return
673 local p="$TMP/sanityN-$TESTNAME.parameters"
674 save_lustre_params $HOSTNAME "osc.*.contention_seconds" > $p
675 for node in $(osts_nodes); do
676 save_lustre_params $node "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
677 save_lustre_params $node "ldlm.namespaces.filter-*.contended_locks" >> $p
678 save_lustre_params $node "ldlm.namespaces.filter-*.contention_seconds" >> $p
681 # agressive lockless i/o settings
682 for node in $(osts_nodes); do
683 do_node $node 'lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes 2000000; lctl set_param -n ldlm.namespaces.filter-*.contended_locks 0; lctl set_param -n ldlm.namespaces.filter-*.contention_seconds 60'
685 lctl set_param -n osc.*.contention_seconds 60
686 for i in $(seq 5); do
687 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > /dev/null 2>&1
688 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > /dev/null 2>&1
690 [ $(calc_osc_stats lockless_write_bytes) -ne 0 ] || error "lockless i/o was not triggered"
691 # disable lockless i/o (it is disabled by default)
692 for node in $(osts_nodes); do
693 do_node $node 'lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes 0; lctl set_param -n ldlm.namespaces.filter-*.contended_locks 32; lctl set_param -n ldlm.namespaces.filter-*.contention_seconds 0'
695 # set contention_seconds to 0 at client too, otherwise Lustre still
696 # remembers lock contention
697 lctl set_param -n osc.*.contention_seconds 0
699 for i in $(seq 1); do
700 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > /dev/null 2>&1
701 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > /dev/null 2>&1
703 [ $(calc_osc_stats lockless_write_bytes) -eq 0 ] ||
704 error "lockless i/o works when disabled"
706 restore_lustre_params <$p
709 run_test 32b "lockless i/o"
713 local mdts=$(get_facets MDS)
718 for mds in ${mdts//,/ }; do
720 dev=$(basename $(do_facet $mds lctl get_param -n osd*.${!varsvc}.mntdev))
721 val=$(do_facet $mds "procfile=/proc/fs/jbd/$dev/info;
722 [ -f \\\$procfile ] || procfile=/proc/fs/jbd2/$dev/info;
723 [ -f \\\$procfile ] || procfile=/proc/fs/jbd2/${dev}\:\\\*/info;
724 cat \\\$procfile | head -1;")
726 stat=$(( stat + val))
731 # commit on sharing tests
733 remote_mds_nodsh && skip "remote MDS with nodsh" && return
735 [ -n "$CLIENTS" ] || { skip "Need two or more clients" && return 0; }
736 [ $CLIENTCOUNT -ge 2 ] || \
737 { skip "Need two or more clients, have $CLIENTCOUNT" && return 0; }
739 local nfiles=${TEST33_NFILES:-10000}
740 local param_file=$TMP/$tfile-params
742 save_lustre_params $(comma_list $(mdts_nodes)) "mdt.*.commit_on_sharing" > $param_file
750 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
754 do_nodes $CLIENT1,$CLIENT2 "mkdir -p $DIR1/$tdir-\\\$(hostname)-$i"
756 jbdold=$(print_jbd_stat)
757 echo "=== START createmany old: $jbdold transaction"
758 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")
759 jbdnew=$(print_jbd_stat)
760 jbd=$(( jbdnew - jbdold ))
761 echo "=== END createmany new: $jbdnew transaction : $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
762 avgjbd=$(( avgjbd + jbd ))
763 avgtime=$(( avgtime + elapsed ))
765 eval cos${COS}_jbd=$((avgjbd / 3))
766 eval cos${COS}_time=$((avgtime / 3))
769 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
770 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
771 [ "$cos0_jbd" != 0 ] && echo "COS=1 vs COS=0 jbd: $((((cos1_jbd/cos0_jbd - 1)) * 100 )) %"
772 [ "$cos0_time" != 0 ] && echo "COS=1 vs COS=0 time: $((((cos1_time/cos0_time - 1)) * 100 )) %"
774 restore_lustre_params < $param_file
778 run_test 33a "commit on sharing, cross crete/delete, 2 clients, benchmark"
780 # End commit on sharing tests
782 get_ost_lock_timeouts() {
783 local nodes=${1:-$(comma_list $(osts_nodes))}
785 local locks=$(do_nodes $nodes \
786 "lctl get_param -n ldlm.namespaces.filter-*.lock_timeouts" | calc_sum)
795 for OPER in notimeout timeout ; do
796 rm $DIR1/$tfile 2>/dev/null
797 lock_in=$(get_ost_lock_timeouts)
798 if [ $OPER == "timeout" ] ; then
799 for j in `seq $OSTCOUNT`; do
800 #define OBD_FAIL_PTLRPC_HPREQ_TIMEOUT 0x511
801 do_facet ost$j lctl set_param fail_loc=0x511
803 echo lock should expire
805 for j in `seq $OSTCOUNT`; do
806 #define OBD_FAIL_PTLRPC_HPREQ_NOTIMEOUT 0x512
807 do_facet ost$j lctl set_param fail_loc=0x512
809 echo lock should not expire
811 echo writing on client1
812 dd if=/dev/zero of=$DIR1/$tfile count=100 conv=notrunc > /dev/null 2>&1
814 echo reading on client2
815 dd of=/dev/null if=$DIR2/$tfile > /dev/null 2>&1
816 # wait for a lock timeout
818 lock_out=$(get_ost_lock_timeouts)
819 if [ $OPER == "timeout" ] ; then
820 if [ $lock_in == $lock_out ]; then
821 error "no lock timeout happened"
826 if [ $lock_in != $lock_out ]; then
827 error "lock timeout happened"
834 run_test 34 "no lock timeout under IO"
836 test_35() { # bug 17645
839 for imp in /proc/fs/lustre/mdc/$FSNAME-MDT*-mdc-*; do
840 g=$(awk '/generation/{print $2}' $imp/import)
845 mkdir -p $MOUNT1/$tfile
848 # Let's initiate -EINTR situation by setting fail_loc and take
849 # write lock on same file from same client. This will not cause
850 # bl_ast yet as lock is already in local cache.
851 #define OBD_FAIL_LDLM_INTR_CP_AST 0x317
852 do_facet client "lctl set_param fail_loc=0x80000317"
853 local timeout=`do_facet $SINGLEMDS lctl get_param -n timeout`
854 let timeout=timeout*3
856 while test $nr -lt 10; do
857 log "Race attempt $nr"
858 local blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
859 test "x$blk1" = "x" && blk1=0
860 createmany -o $MOUNT2/$tfile/a 4000 &
864 # Let's make conflict and bl_ast
865 ls -la $MOUNT1/$tfile > /dev/null &
868 log "Wait for $pid1 $pid2 for $timeout sec..."
870 kill -9 $pid1 $pid2 > /dev/null 2>&1
872 local blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
873 test "x$blk2" = "x" && blk2=0
874 test $blk2 -gt $blk1 && break
875 rm -fr $MOUNT1/$tfile/*
879 do_facet client "lctl set_param fail_loc=0x0"
880 df -h $MOUNT1 $MOUNT2
882 for imp in /proc/fs/lustre/mdc/$FSNAME-MDT*-mdc-*; do
883 g=$(awk '/generation/{print $2}' $imp/import)
884 if ! test "$g" -eq "${generation[count]}"; then
885 error "Eviction happened on import $(basename $imp)"
890 run_test 35 "-EINTR cp_ast vs. bl_ast race does not evict client"
892 test_36() { #bug 16417
898 $LFS setstripe -c -1 $DIR1/$tdir
901 let SIZE_B=SIZE*1024*1024
903 while [ $i -le 10 ]; do
904 lctl mark "start test"
905 local before=$($LFS df | awk '{if ($1 ~/^filesystem/) {print $5; exit} }')
906 dd if=/dev/zero of=$DIR1/$tdir/file000 bs=1M count=$SIZE
909 local after_dd=$($LFS df | awk '{if ($1 ~/^filesystem/) {print $5; exit} }')
910 multiop_bg_pause $DIR2/$tdir/file000 O_r${SIZE_B}c || return 3
912 rm -f $DIR1/$tdir/file000
916 local after=$($LFS df | awk '{if ($1 ~/^filesystem/) {print $5; exit} }')
917 echo "*** cycle($i) *** before($before):after_dd($after_dd):after($after)"
918 # this free space! not used
919 if [ $after_dd -ge $after ]; then
926 run_test 36 "handle ESTALE/open-unlink corectly"
928 test_37() { # bug 18695
930 multiop_bg_pause $DIR1/$tdir D_c || return 1
932 # create large directory (32kB seems enough from e2fsck, ~= 1000 files)
933 createmany -m $DIR2/$tdir/f 10000
934 # set mtime/atime backward
935 touch -t 198001010000 $DIR2/$tdir
937 nr_files=`lfs find $DIR1/$tdir -type f | wc -l`
938 [ $nr_files -eq 10000 ] || error "$nr_files != 10000 truncated directory?"
941 run_test 37 "check i_size is not updated for directory on close (bug 18695) =============="
943 # this should be set to past
944 TEST_39_MTIME=`date -d "1 year ago" +%s`
948 local client1=${CLIENT1:-`hostname`}
949 local client2=${CLIENT2:-`hostname`}
951 do_node $client1 "touch $DIR1/$tfile"
953 do_node $client1 "touch -m -d @$TEST_39_MTIME $DIR1/$tfile"
954 local mtime1=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
955 [ "$mtime1" = $TEST_39_MTIME ] || \
956 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
958 local d1=`do_node $client1 date +%s`
959 do_node $client1 'echo hello >> '$DIR1/$tfile
960 local d2=`do_node $client1 date +%s`
962 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
963 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
964 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
966 do_node $client1 "mv $DIR1/$tfile $DIR1/$tfile-1"
968 for (( i=0; i < 2; i++ )) ; do
969 local mtime3=`do_node $client2 "stat -c %Y $DIR1/$tfile-1"`
970 [ "$mtime2" = "$mtime3" ] || \
971 error "mtime ($mtime2) changed (to $mtime3) on rename"
974 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
977 run_test 39a "test from 11063 =================================="
980 local client1=${CLIENT1:-`hostname`}
981 local client2=${CLIENT2:-`hostname`}
985 local mtime1=`stat -c %Y $DIR1/$tfile`
986 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
989 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
991 for (( i=0; i < 2; i++ )) ; do
992 local mtime3=`stat -c %Y $DIR1/$tfile`
993 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
995 [ "$mtime3" = "$mtime4" ] || \
996 error "different mtime on clients: $mtime3, $mtime4"
997 [ "$mtime3" = $TEST_39_MTIME ] || \
998 error "lost mtime: $mtime3, should be $TEST_39_MTIME"
1000 cancel_lru_locks osc
1001 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1004 run_test 39b "11063 problem 1 =================================="
1007 local client1=${CLIENT1:-`hostname`}
1008 local client2=${CLIENT2:-`hostname`}
1010 echo hello > $DIR1/$tfile
1012 local mtime1=`stat -c %Y $DIR1/$tfile`
1013 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1014 [ "$mtime1" = "$mtime2" ] || \
1015 error "create: different mtime on clients: $mtime1, $mtime2"
1018 $TRUNCATE $DIR1/$tfile 1
1020 for (( i=0; i < 2; i++ )) ; do
1021 local mtime3=`stat -c %Y $DIR1/$tfile`
1022 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1024 [ "$mtime3" = "$mtime4" ] || \
1025 error "different mtime on clients: $mtime3, $mtime4"
1026 [ "$mtime3" -gt $mtime2 ] || \
1027 error "truncate did not update mtime: $mtime2, $mtime3"
1029 cancel_lru_locks osc
1030 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1033 run_test 39c "check truncate mtime update ======================"
1035 # check that pid exists hence second operation wasn't blocked by first one
1036 # if it is so then there is no conflict, return 0
1037 # else second operation is conflicting with first one, return 1
1038 check_pdo_conflict() {
1041 sleep 1 # to ensure OP1 is finished on client if OP2 is blocked by OP1
1042 if [[ `ps --pid $pid | wc -l` == 1 ]]; then
1052 # test 40: check non-blocking operations
1054 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1055 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1056 mkdir $DIR1/$tfile &
1059 touch $DIR2/$tfile-2
1060 check_pdo_conflict $PID1 || error "create is blocked"
1061 mkdir $DIR2/$tfile-3
1062 check_pdo_conflict $PID1 || error "mkdir is blocked"
1063 link $DIR2/$tfile-2 $DIR2/$tfile-4
1064 check_pdo_conflict $PID1 || error "link is blocked"
1065 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1066 check_pdo_conflict $PID1 || error "rename is blocked"
1067 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1068 check_pdo_conflict $PID1 || error "getattr is blocked"
1069 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1070 rmdir $DIR2/$tfile-3
1071 check_pdo_conflict $PID1 || error "unlink is blocked"
1072 # all operations above shouldn't wait the first one
1073 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1078 run_test 40a "pdirops: create vs others =============="
1081 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1082 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1083 touch $DIR1/$tfile &
1087 touch $DIR2/$tfile-2
1088 check_pdo_conflict $PID1 || error "create is blocked"
1089 mkdir $DIR2/$tfile-3
1090 check_pdo_conflict $PID1 || error "mkdir is blocked"
1091 link $DIR2/$tfile-2 $DIR2/$tfile-4
1092 check_pdo_conflict $PID1 || error "link is blocked"
1093 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1094 check_pdo_conflict $PID1 || error "rename is blocked"
1095 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1096 check_pdo_conflict $PID1 || error "getattr is blocked"
1097 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1098 rmdir $DIR2/$tfile-3
1099 check_pdo_conflict $PID1 || error "unlink is blocked"
1100 # all operations above shouldn't wait the first one
1101 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1106 run_test 40b "pdirops: open|create and others =============="
1110 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1111 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1112 link $DIR1/$tfile $DIR1/$tfile-0 &
1116 touch $DIR2/$tfile-2
1117 check_pdo_conflict $PID1 || error "create is blocked"
1118 mkdir $DIR2/$tfile-3
1119 check_pdo_conflict $PID1 || error "mkdir is blocked"
1120 link $DIR2/$tfile-2 $DIR2/$tfile-4
1121 check_pdo_conflict $PID1 || error "link is blocked"
1122 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1123 check_pdo_conflict $PID1 || error "rename is blocked"
1124 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1125 check_pdo_conflict $PID1 || error "getattr is blocked"
1126 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1127 rmdir $DIR2/$tfile-3
1128 check_pdo_conflict $PID1 || error "unlink is blocked"
1129 # all operations above shouldn't wait the first one
1130 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1135 run_test 40c "pdirops: link and others =============="
1139 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1140 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1145 touch $DIR2/$tfile-2
1146 check_pdo_conflict $PID1 || error "create is blocked"
1147 mkdir $DIR2/$tfile-3
1148 check_pdo_conflict $PID1 || error "mkdir is blocked"
1149 link $DIR2/$tfile-2 $DIR2/$tfile-4
1150 check_pdo_conflict $PID1 || error "link is blocked"
1151 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1152 check_pdo_conflict $PID1 || error "rename is blocked"
1153 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1154 check_pdo_conflict $PID1 || error "getattr is blocked"
1155 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1156 rmdir $DIR2/$tfile-3
1157 check_pdo_conflict $PID1 || error "unlink is blocked"
1158 # all operations above shouldn't wait the first one
1159 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1163 run_test 40d "pdirops: unlink and others =============="
1167 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1168 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1169 mv $DIR1/$tfile $DIR1/$tfile-0 &
1173 touch $DIR2/$tfile-2
1174 check_pdo_conflict $PID1 || error "create is blocked"
1175 mkdir $DIR2/$tfile-3
1176 check_pdo_conflict $PID1 || error "mkdir is blocked"
1177 link $DIR2/$tfile-2 $DIR2/$tfile-4
1178 check_pdo_conflict $PID1 || error "link is blocked"
1179 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1180 check_pdo_conflict $PID1 || error "getattr is blocked"
1181 rm $DIR2/$tfile-4 $DIR2/$tfile-2
1182 rmdir $DIR2/$tfile-3
1183 check_pdo_conflict $PID1 || error "unlink is blocked"
1184 # all operations above shouldn't wait the first one
1185 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1190 run_test 40e "pdirops: rename and others =============="
1192 # test 41: create blocking operations
1194 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1195 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1196 multiop $DIR1/$tfile oO_CREAT:O_RDWR:c &
1199 mkdir $DIR2/$tfile && error "mkdir must fail"
1200 check_pdo_conflict $PID1 && { wait $PID1; echo "mkdir isn't blocked"; }
1204 run_test 41a "pdirops: create vs mkdir =============="
1207 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1208 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1209 multiop $DIR1/$tfile oO_CREAT:O_RDWR:c &
1212 multiop $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1213 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1217 run_test 41b "pdirops: create vs create =============="
1220 touch $DIR1/$tfile-2
1221 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1222 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1223 multiop $DIR1/$tfile oO_CREAT:O_RDWR:c &
1226 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
1227 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1231 run_test 41c "pdirops: create vs link =============="
1234 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1235 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1236 multiop $DIR1/$tfile oO_CREAT:O_RDWR:c &
1239 rm $DIR2/$tfile || error "unlink must succeed"
1240 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1244 run_test 41d "pdirops: create vs unlink =============="
1247 touch $DIR1/$tfile-2
1248 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1249 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1250 multiop $DIR1/$tfile oO_CREAT:O_RDWR:c &
1253 mv $DIR2/$tfile-2 $DIR2/$tfile || error "rename must succeed"
1254 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1258 run_test 41e "pdirops: create and rename (tgt) =============="
1261 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1262 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1263 multiop $DIR1/$tfile oO_CREAT:O_RDWR:c &
1266 mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
1267 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1271 run_test 41f "pdirops: create and rename (src) =============="
1274 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1275 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1276 multiop $DIR1/$tfile oO_CREAT:O_RDWR:c &
1279 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
1280 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1284 run_test 41g "pdirops: create vs getattr =============="
1287 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1288 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1289 multiop $DIR1/$tfile oO_CREAT:O_RDWR:c &
1292 ls -lia $DIR2/ > /dev/null
1293 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1297 run_test 41h "pdirops: create vs readdir =============="
1299 # test 42: unlink and blocking operations
1301 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1302 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1303 mkdir $DIR1/$tfile &
1306 mkdir $DIR2/$tfile && error "mkdir must fail"
1307 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1311 run_test 42a "pdirops: mkdir vs mkdir =============="
1314 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1315 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1316 mkdir $DIR1/$tfile &
1319 multiop $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1320 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1324 run_test 42b "pdirops: mkdir vs create =============="
1327 touch $DIR1/$tfile-2
1328 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1329 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1330 mkdir $DIR1/$tfile &
1333 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
1334 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1338 run_test 42c "pdirops: mkdir vs link =============="
1341 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1342 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1343 mkdir $DIR1/$tfile &
1346 rmdir $DIR2/$tfile || error "unlink must succeed"
1347 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1351 run_test 42d "pdirops: mkdir vs unlink =============="
1354 touch $DIR1/$tfile-2
1355 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1356 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1357 mkdir $DIR1/$tfile &
1360 mv -T $DIR2/$tfile-2 $DIR2/$tfile && error "rename must fail"
1361 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1365 run_test 42e "pdirops: mkdir and rename (tgt) =============="
1368 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1369 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1370 mkdir $DIR1/$tfile &
1373 mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
1374 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1378 run_test 42f "pdirops: mkdir and rename (src) =============="
1381 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1382 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1383 mkdir $DIR1/$tfile &
1386 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
1387 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1391 run_test 42g "pdirops: mkdir vs getattr =============="
1394 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1395 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1396 mkdir $DIR1/$tfile &
1399 ls -lia $DIR2/ > /dev/null
1400 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1404 run_test 42h "pdirops: mkdir vs readdir =============="
1406 # test 43: unlink and blocking operations
1409 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1410 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1414 mkdir $DIR2/$tfile || error "mkdir must succeed"
1415 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1419 run_test 43a "pdirops: unlink vs mkdir =============="
1423 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1424 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1428 multiop $DIR2/$tfile oO_CREAT:O_EXCL:c || error "create must succeed"
1429 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1433 run_test 43b "pdirops: unlink vs create =============="
1437 touch $DIR1/$tfile-2
1438 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1439 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1443 link $DIR2/$tfile-2 $DIR2/$tfile || error "link must succeed"
1444 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1448 run_test 43c "pdirops: unlink vs link =============="
1452 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1453 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1457 rm $DIR2/$tfile && error "unlink must fail"
1458 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1462 run_test 43d "pdirops: unlink vs unlink =============="
1466 touch $DIR1/$tfile-2
1467 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1468 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1472 mv -u $DIR2/$tfile-2 $DIR2/$tfile || error "rename must succeed"
1473 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1477 run_test 43e "pdirops: unlink and rename (tgt) =============="
1481 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1482 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1486 mv $DIR2/$tfile $DIR2/$tfile-2 && error "rename must fail"
1487 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1491 run_test 43f "pdirops: unlink and rename (src) =============="
1495 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1496 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1500 stat $DIR2/$tfile > /dev/null && error "stat must fail"
1501 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1505 run_test 43g "pdirops: unlink vs getattr =============="
1509 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1510 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1514 ls -lia $DIR2/ > /dev/null
1515 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1519 run_test 43h "pdirops: unlink vs readdir =============="
1521 # test 44: rename tgt and blocking operations
1523 touch $DIR1/$tfile-2
1524 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1525 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1526 mv $DIR1/$tfile-2 $DIR1/$tfile &
1529 mkdir $DIR2/$tfile && error "mkdir must fail"
1530 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1534 run_test 44a "pdirops: rename tgt vs mkdir =============="
1537 touch $DIR1/$tfile-2
1538 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1539 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1540 mv $DIR1/$tfile-2 $DIR1/$tfile &
1543 multiop $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1544 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1548 run_test 44b "pdirops: rename tgt vs create =============="
1551 touch $DIR1/$tfile-2
1552 touch $DIR1/$tfile-3
1553 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1554 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1555 mv $DIR1/$tfile-2 $DIR1/$tfile &
1558 link $DIR2/$tfile-3 $DIR2/$tfile && error "link must fail"
1559 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1563 run_test 44c "pdirops: rename tgt vs link =============="
1566 touch $DIR1/$tfile-2
1567 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1568 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1569 mv $DIR1/$tfile-2 $DIR1/$tfile &
1572 rm $DIR2/$tfile || error "unlink must succeed"
1573 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1577 run_test 44d "pdirops: rename tgt vs unlink =============="
1581 touch $DIR1/$tfile-2
1582 touch $DIR1/$tfile-3
1583 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1584 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1585 mv $DIR1/$tfile-2 $DIR1/$tfile &
1588 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
1589 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1593 run_test 44e "pdirops: rename tgt and rename (tgt) =============="
1596 touch $DIR1/$tfile-2
1597 touch $DIR1/$tfile-3
1598 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1599 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1600 mv $DIR1/$tfile-2 $DIR1/$tfile &
1603 mv $DIR2/$tfile $DIR2/$tfile-3 || error "rename must succeed"
1604 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1608 run_test 44f "pdirops: rename tgt and rename (src) =============="
1611 touch $DIR1/$tfile-2
1612 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1613 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1614 mv $DIR1/$tfile-2 $DIR1/$tfile &
1617 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
1618 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1622 run_test 44g "pdirops: rename tgt vs getattr =============="
1625 touch $DIR1/$tfile-2
1626 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1627 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1628 mv $DIR1/$tfile-2 $DIR1/$tfile &
1631 ls -lia $DIR2/ > /dev/null
1632 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1636 run_test 44h "pdirops: rename tgt vs readdir =============="
1638 # test 45: rename src and blocking operations
1641 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1642 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1643 mv $DIR1/$tfile $DIR1/$tfile-2 &
1646 mkdir $DIR2/$tfile || error "mkdir must succeed"
1647 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1651 run_test 45a "pdirops: rename src vs mkdir =============="
1655 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1656 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1657 mv $DIR1/$tfile $DIR1/$tfile-2 &
1660 multiop $DIR2/$tfile oO_CREAT:O_EXCL:c || error "create must succeed"
1661 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1665 run_test 45b "pdirops: rename src vs create =============="
1669 touch $DIR1/$tfile-3
1670 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1671 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1672 mv $DIR1/$tfile $DIR1/$tfile-2 &
1675 link $DIR2/$tfile-3 $DIR2/$tfile || error "link must succeed"
1676 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1680 run_test 45c "pdirops: rename src vs link =============="
1684 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1685 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1686 mv $DIR1/$tfile $DIR1/$tfile-2 &
1689 rm $DIR2/$tfile && error "unlink must fail"
1690 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1694 run_test 45d "pdirops: rename src vs unlink =============="
1698 touch $DIR1/$tfile-3
1699 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1700 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1701 mv $DIR1/$tfile $DIR1/$tfile-2 &
1704 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
1705 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1709 run_test 45e "pdirops: rename src and rename (tgt) =============="
1713 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1714 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1715 mv $DIR1/$tfile $DIR1/$tfile-2 &
1718 mv $DIR2/$tfile $DIR2/$tfile-3 && error "rename must fail"
1719 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1723 run_test 45f "pdirops: rename src and rename (src) =============="
1727 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1728 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1729 mv $DIR1/$tfile $DIR1/$tfile-2 &
1732 stat $DIR2/$tfile > /dev/null && "stat must fail"
1733 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1737 run_test 45g "pdirops: rename src vs getattr =============="
1741 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1742 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1743 mv $DIR1/$tfile $DIR1/$tfile-2 &
1746 ls -lia $DIR2/ > /dev/null
1747 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1751 run_test 45h "pdirops: unlink vs readdir =============="
1753 # test 46: link and blocking operations
1755 touch $DIR1/$tfile-2
1756 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1757 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1758 link $DIR1/$tfile-2 $DIR1/$tfile &
1761 mkdir $DIR2/$tfile && error "mkdir must fail"
1762 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1766 run_test 46a "pdirops: link vs mkdir =============="
1769 touch $DIR1/$tfile-2
1770 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1771 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1772 link $DIR1/$tfile-2 $DIR1/$tfile &
1775 multiop $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1776 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1780 run_test 46b "pdirops: link vs create =============="
1783 touch $DIR1/$tfile-2
1784 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1785 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1786 link $DIR1/$tfile-2 $DIR1/$tfile &
1789 link $DIR2/$tfile $DIR2/$tfile && error "link must fail"
1790 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1794 run_test 46c "pdirops: link vs link =============="
1797 touch $DIR1/$tfile-2
1798 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1799 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1800 link $DIR1/$tfile-2 $DIR1/$tfile &
1803 rm $DIR2/$tfile || error "unlink must succeed"
1804 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1808 run_test 46d "pdirops: link vs unlink =============="
1811 touch $DIR1/$tfile-2
1812 touch $DIR1/$tfile-3
1813 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1814 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1815 link $DIR1/$tfile-2 $DIR1/$tfile &
1818 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
1819 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1823 run_test 46e "pdirops: link and rename (tgt) =============="
1826 touch $DIR1/$tfile-2
1827 touch $DIR1/$tfile-3
1828 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1829 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1830 link $DIR1/$tfile-2 $DIR1/$tfile &
1833 mv $DIR2/$tfile $DIR2/$tfile-3 || error "rename must succeed"
1834 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1838 run_test 46f "pdirops: link and rename (src) =============="
1841 touch $DIR1/$tfile-2
1842 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1843 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1844 link $DIR1/$tfile-2 $DIR1/$tfile &
1847 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
1848 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1852 run_test 46g "pdirops: link vs getattr =============="
1855 touch $DIR1/$tfile-2
1856 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1857 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1858 link $DIR1/$tfile-2 $DIR1/$tfile &
1861 ls -lia $DIR2/ > /dev/null
1862 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1866 run_test 46h "pdirops: link vs readdir =============="
1870 dd if=/dev/zero of=$DIR1/$tfile bs=1K count=10
1871 #define OBD_FAIL_OSC_CP_ENQ_RACE 0x410
1872 do_facet client "lctl set_param fail_loc=0x410"
1873 $TRUNCATE $DIR2/$tfile $trunc_size
1874 do_facet client "lctl set_param fail_loc=0x0"
1876 size=`stat -c %s $DIR2/$tfile`
1877 [ $size -eq $trunc_size ] || error "wrong size"
1879 run_test 50 "osc lvb attrs: enqueue vs. CP AST =============="
1883 mkdir -p $DIR1/$tdir
1884 file1=$DIR1/$tdir/file
1885 file2=$DIR2/$tdir/file
1887 echo orig > $file2 || error "Could not create $file2"
1888 version=$($LFS data_version $file1)
1891 echo append >> $file2 || error "Could not append to $file2"
1892 version2=$($LFS data_version $file1)
1893 [ "$version" != "$version2" ] ||
1894 error "append did not change data version: $version"
1897 echo overwrite > $file2 || error "Could not overwrite $file2"
1898 version3=$($LFS data_version $file1)
1899 [ "$version2" != "$version3" ] ||
1900 error "overwrite did not change data version: $version2"
1902 # Truncate before EOF
1903 $TRUNCATE $file2 3 || error "Could not truncate $file2"
1904 version4=$($LFS data_version $file1)
1905 [ "$version3" != "$version4" ] ||
1906 error "truncate did not change data version: $version3"
1908 # Truncate after EOF
1909 $TRUNCATE $file2 123456 || error "Could not truncate $file2"
1910 version5=$($LFS data_version $file1)
1911 [ "$version4" != "$version5" ] ||
1912 error "truncate did not change data version: $version4"
1914 # Chmod do not change version
1915 chmod 400 $file2 || error "Could not chmod 400 $file2"
1916 version6=$($LFS data_version $file1)
1917 [ "$version5" == "$version6" ] ||
1918 error "chmod should not change data version: $version5 != $version6"
1920 # Chown do not change version
1921 chown $TSTUSR $file2 || error "Could not chown $TSTUSR $file2"
1922 version7=$($LFS data_version $file1)
1923 [ "$version5" == "$version7" ] ||
1924 error "chown should not change data version: $version5 != $version7"
1926 run_test 60 "Verify data_version behaviour"
1928 log "cleanup: ======================================================"
1930 [ "$(mount | grep $MOUNT2)" ] && umount $MOUNT2
1932 complete $(basename $0) $SECONDS
1933 check_and_cleanup_lustre