6 # bug number for skipped test: 3192 LU-1205 15528/3811 16929 9977 15528/11549 18080
7 ALWAYS_EXCEPT=" 14b 18c 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 MCREATE=${MCREATE:-mcreate}
26 OPENFILE=${OPENFILE:-openfile}
27 OPENUNLINK=${OPENUNLINK:-openunlink}
28 export TMP=${TMP:-/tmp}
29 MOUNT_2=${MOUNT_2:-"yes"}
30 CHECK_GRANT=${CHECK_GRANT:-"yes"}
31 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
35 export NAME=${NAME:-local}
37 LUSTRE=${LUSTRE:-`dirname $0`/..}
38 . $LUSTRE/tests/test-framework.sh
42 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
45 [ "$SLOW" = "no" ] && EXCEPT_SLOW="12 23 33a"
52 check_and_setup_lustre
54 LOVNAME=`lctl get_param -n llite.*.lov.common_name | tail -n 1`
55 OSTCOUNT=`lctl get_param -n lov.$LOVNAME.numobd`
58 rm -rf $DIR1/[df][0-9]* $DIR1/lnk
60 SAMPLE_FILE=$TMP/$(basename $0 .sh).junk
61 dd if=/dev/urandom of=$SAMPLE_FILE bs=1M count=1
63 # $RUNAS_ID may get set incorrectly somewhere else
64 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
66 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
75 [ -f $DIR2/f1 ] || error
77 run_test 1a "check create on 2 mtpt's =========================="
81 $CHECKSTAT -t file -p 0777 $DIR1/f1 || error
84 run_test 1b "check attribute updates on 2 mtpt's ==============="
87 $CHECKSTAT -t file -p 0666 $DIR1/f1 || error
89 run_test 1c "check after remount attribute updates on 2 mtpt's ="
93 $CHECKSTAT -a $DIR1/f1 || error
95 run_test 1d "unlink on one mountpoint removes file on other ===="
101 $CHECKSTAT -t file -p 0777 $DIR1/f2a || error
103 run_test 2a "check cached attribute updates on 2 mtpt's ========"
109 $CHECKSTAT -t file -p 0777 $DIR2/f2b || error
111 run_test 2b "check cached attribute updates on 2 mtpt's ========"
113 # NEED TO SAVE ROOT DIR MODE
116 $CHECKSTAT -t dir -p 0777 $DIR2 || error
118 run_test 2c "check cached attribute updates on 2 mtpt's root ==="
122 $CHECKSTAT -t dir -p 0755 $DIR2 || error
124 run_test 2d "check cached attribute updates on 2 mtpt's root ==="
131 $RUNAS dd if=/dev/zero of=$DIR2/$tfile count=1 || error
133 run_test 2e "check chmod on root is propagated to others"
136 local target="this/is/good"
137 ln -s $target $DIR1/$tfile || error "ln -s $target $DIR1/$tfile failed"
138 [ "$(ls -l $DIR2/$tfile | sed -e 's/.* -> //')" = "$target" ] ||
139 error "link $DIR2/$tfile not as expected"
141 run_test 3 "symlink on one mtpt, readlink on another ==========="
144 multifstat $DIR1/f4 $DIR2/f4
146 run_test 4 "fstat validation on multiple mount points =========="
150 $TRUNCATE $DIR2/f5 100
151 $CHECKSTAT -t file -s 100 $DIR1/f5 || error
154 run_test 5 "create a file on one mount, truncate it on the other"
157 openunlink $DIR1/$tfile $DIR2/$tfile || \
158 error "openunlink $DIR1/$tfile $DIR2/$tfile"
160 run_test 6 "remove of open file on other node =================="
164 opendirunlink $DIR1/$dir $DIR2/$dir || \
165 error "opendirunlink $DIR1/$dir $DIR2/$dir"
167 run_test 7 "remove of open directory on other node ============="
170 opendevunlink $DIR1/$tfile $DIR2/$tfile || \
171 error "opendevunlink $DIR1/$tfile $DIR2/$tfile"
173 run_test 8 "remove of open special file on other node =========="
179 for C in a b c d e f g h i j k l; do
180 dir=`eval echo \\$DIR$MTPT`
181 echo -n $C >> $dir/f9
182 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
184 [ "`cat $DIR1/f9`" = "abcdefghijkl" ] || \
185 error "`od -a $DIR1/f9` != abcdefghijkl"
187 run_test 9 "append of file with sub-page size on multiple mounts"
194 for C in a b c d e f g h i j k l; do
195 dir=`eval echo \\$DIR$MTPT`
196 echo -n $C | dd of=$dir/f10 bs=1 seek=$OFFSET count=1
197 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
198 OFFSET=`expr $OFFSET + 1`
200 [ "`cat $DIR1/f10`" = "abcdefghijkl" ] || \
201 error "`od -a $DIR1/f10` != abcdefghijkl"
203 run_test 10a "write of file with sub-page size on multiple mounts "
207 yes "R" | head -c 4000 >$TMP/f10b-seed
208 dd if=$TMP/f10b-seed of=$DIR1/f10b bs=3k count=1 || error "dd $DIR1"
210 $TRUNCATE $DIR1/f10b 4096 || error "truncate 4096"
212 dd if=$DIR2/f10b of=$TMP/f10b-lustre bs=4k count=1 || error "dd $DIR2"
214 # create a test file locally to compare
215 dd if=$TMP/f10b-seed of=$TMP/f10b bs=3k count=1 || error "dd random"
216 $TRUNCATE $TMP/f10b 4096 || error "truncate 4096"
217 cmp $TMP/f10b $TMP/f10b-lustre || error "file miscompare"
218 rm $TMP/f10b $TMP/f10b-lustre $TMP/f10b-seed
220 run_test 10b "write of file with sub-page size on multiple mounts "
224 multiop_bg_pause $DIR1/d11/f O_c || return 1
226 cp -p /bin/ls $DIR1/d11/f
230 wait $MULTIPID || error
231 [ $RC -eq 0 ] && error || true
233 run_test 11 "execution of file opened for write should return error ===="
236 DIR=$DIR DIR2=$DIR2 sh lockorder.sh
238 run_test 12 "test lock ordering (link, stat, unlink) ==========="
240 test_13() { # bug 2451 - directory coherency
241 mkdir $DIR1/d13 || error
242 cd $DIR1/d13 || error
244 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
246 rm -f $DIR2/d13/f13 || error
247 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (1)" || true
248 # need to run it twice
249 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
251 rm -f $DIR2/d13/f13 || error
252 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (2)" || true
254 run_test 13 "test directory page revocation ===================="
258 cp -p /bin/ls $DIR1/$tdir/$tfile
259 multiop_bg_pause $DIR1/$tdir/$tfile Ow_c || return 1
262 $DIR2/$tdir/$tfile && error || true
264 wait $MULTIPID || return 2
266 run_test 14 "execution of file open for write returns -ETXTBSY ="
270 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
271 MULTIOP_PROG=$DIR1/d14/multiop multiop_bg_pause $TMP/test14.junk O_c || return 1
273 multiop $DIR2/d14/multiop Oc && error "expected error, got success"
274 kill -USR1 $MULTIOP_PID || return 2
275 wait $MULTIOP_PID || return 3
276 rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop"
278 run_test 14a "open(RDWR) of executing file returns -ETXTBSY ===="
280 test_14b() { # bug 3192, 7040
282 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
283 MULTIOP_PROG=$DIR1/d14/multiop multiop_bg_pause $TMP/test14.junk O_c || return 1
285 $TRUNCATE $DIR2/d14/multiop 0 && kill -9 $MULTIOP_PID && \
286 error "expected truncate error, got success"
287 kill -USR1 $MULTIOP_PID || return 2
288 wait $MULTIOP_PID || return 3
289 cmp `which multiop` $DIR1/d14/multiop || error "binary changed"
290 rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop"
292 run_test 14b "truncate of executing file returns -ETXTBSY ======"
294 test_14c() { # bug 3430, 7040
296 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
297 MULTIOP_PROG=$DIR1/d14/multiop multiop_bg_pause $TMP/test14.junk O_c || return 1
299 cp /etc/hosts $DIR2/d14/multiop && error "expected error, got success"
300 kill -USR1 $MULTIOP_PID || return 2
301 wait $MULTIOP_PID || return 3
302 cmp `which multiop` $DIR1/d14/multiop || error "binary changed"
303 rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop"
305 run_test 14c "open(O_TRUNC) of executing file return -ETXTBSY =="
307 test_14d() { # bug 10921
309 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
310 MULTIOP_PROG=$DIR1/d14/multiop multiop_bg_pause $TMP/test14.junk O_c || return 1
313 chmod 600 $DIR1/d14/multiop || error "chmod failed"
314 kill -USR1 $MULTIOP_PID || return 2
315 wait $MULTIOP_PID || return 3
316 cmp `which multiop` $DIR1/d14/multiop || error "binary changed"
317 rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop"
319 run_test 14d "chmod of executing file is still possible ========"
321 test_15() { # bug 974 - ENOSPC
323 sh oos2.sh $MOUNT1 $MOUNT2
324 grant_error=`dmesg | grep "> available"`
325 [ -z "$grant_error" ] || error "$grant_error"
327 run_test 15 "test out-of-space with multiple writers ==========="
330 rm -f $MOUNT1/fsxfile
331 lfs setstripe $MOUNT1/fsxfile -c -1 # b=10919
332 fsx -c 50 -p 100 -N 2500 -l $((SIZE * 256)) -S 0 $MOUNT1/fsxfile $MOUNT2/fsxfile
334 run_test 16 "2500 iterations of dual-mount fsx ================="
336 test_17() { # bug 3513, 3667
337 remote_ost_nodsh && skip "remote OST with nodsh" && return
339 lfs setstripe $DIR1/$tfile -i 0 -c 1
340 cp $SAMPLE_FILE $DIR1/$tfile
341 cancel_lru_locks osc > /dev/null
342 #define OBD_FAIL_ONCE|OBD_FAIL_LDLM_CREATE_RESOURCE 0x30a
343 do_facet ost1 lctl set_param fail_loc=0x8000030a
344 ls -ls $DIR1/$tfile | awk '{ print $1,$6 }' > $DIR1/$tfile-1 & \
345 ls -ls $DIR2/$tfile | awk '{ print $1,$6 }' > $DIR2/$tfile-2
347 diff -u $DIR1/$tfile-1 $DIR2/$tfile-2 || error "files are different"
349 run_test 17 "resource creation/LVB creation race ==============="
352 # turn e.g. ALWAYS_EXCEPT="18c" into "-e 3"
355 for idx in {a..z}; do
356 local ptr=EXCEPT_ALWAYS_18$idx
357 [ x${!ptr} = xtrue ] || continue
359 excepts="$excepts -e $(($(printf %d \'$idx)-96))"
362 $LUSTRE/tests/mmap_sanity -d $MOUNT1 -m $MOUNT2 $excepts
365 run_test 18 "mmap sanity check ================================="
367 test_19() { # bug3811
368 [ -d /proc/fs/lustre/obdfilter ] || return 0
370 MAX=`lctl get_param -n obdfilter.*.readcache_max_filesize | head -n 1`
371 lctl set_param -n obdfilter.*OST*.readcache_max_filesize=4096
372 dd if=/dev/urandom of=$TMP/f19b bs=512k count=32
373 SUM=`cksum $TMP/f19b | cut -d" " -f 1,2`
374 cp $TMP/f19b $DIR1/f19b
375 for i in `seq 1 20`; do
376 [ $((i % 5)) -eq 0 ] && log "test_18 loop $i"
377 cancel_lru_locks osc > /dev/null
378 cksum $DIR1/f19b | cut -d" " -f 1,2 > $TMP/sum1 & \
379 cksum $DIR2/f19b | cut -d" " -f 1,2 > $TMP/sum2
381 [ "`cat $TMP/sum1`" = "$SUM" ] || \
382 error "$DIR1/f19b `cat $TMP/sum1` != $SUM"
383 [ "`cat $TMP/sum2`" = "$SUM" ] || \
384 error "$DIR2/f19b `cat $TMP/sum2` != $SUM"
386 lctl set_param -n obdfilter.*OST*.readcache_max_filesize=$MAX
389 run_test 19 "test concurrent uncached read races ==============="
394 CNT=$((`lctl get_param -n llite.*.dump_page_cache | wc -l`))
395 multiop $DIR1/f20 Ow8190c
396 multiop $DIR2/f20 Oz8194w8190c
397 multiop $DIR1/f20 Oz0r8190c
399 CNTD=$((`lctl get_param -n llite.*.dump_page_cache | wc -l` - $CNT))
401 error $CNTD" page left in cache after lock cancel" || true
403 run_test 20 "test extra readahead page left in cache ===="
410 test_21() { # Bug 5907
412 mount /etc $DIR1/d21 --bind || error "mount failed" # Poor man's mount.
414 rmdir -v $DIR1/d21 && error "Removed mounted directory"
415 rmdir -v $DIR2/d21 && echo "Removed mounted directory from another mountpoint, needs to be fixed"
416 test -d $DIR1/d21 || error "Mounted directory disappeared"
418 test -d $DIR2/d21 || test -d $DIR1/d21 && error "Removed dir still visible after umount"
421 run_test 21 " Try to remove mountpoint on another dir ===="
423 test_23() { # Bug 5972
424 echo "others should see updated atime while another read" > $DIR1/f23
426 # clear the lock(mode: LCK_PW) gotten from creating operation
430 #MAX_ATIME_DIFF 60, we update atime only if older than 60 seconds
433 multiop_bg_pause $DIR1/f23 or20_c || return 1
434 # with SOM and opencache enabled, we need to close a file and cancel
435 # open lock to get atime propogated to MDS
439 time2=`stat -c "%X" $DIR2/f23`
441 if (( $time2 <= $time1 )); then
442 error "atime doesn't update among nodes"
445 rm -f $DIR1/f23 || error "rm -f $DIR1/f23 failed"
448 run_test 23 " others should see updated atime while another read===="
452 lfs df || error "lfs df failed"
453 lfs df -ih || error "lfs df -ih failed"
454 lfs df -h $DIR1 || error "lfs df -h $DIR1 failed"
455 lfs df -i $DIR2 || error "lfs df -i $DIR2 failed"
456 lfs df $DIR1/$tfile || error "lfs df $DIR1/$tfile failed"
457 lfs df -ih $DIR2/$tfile || error "lfs df -ih $DIR2/$tfile failed"
459 OSC=`lctl dl | awk '/-osc-|OSC.*MNT/ {print $4}' | head -n 1`
460 # OSC=`lctl dl | awk '/-osc-/ {print $4}' | head -n 1`
461 lctl --device %$OSC deactivate
462 lfs df -i || error "lfs df -i with deactivated OSC failed"
463 lctl --device %$OSC activate
464 lfs df || error "lfs df with reactivated OSC failed"
466 run_test 24a "lfs df [-ih] [path] test ========================="
470 fsnum=`lfs df | grep -c "filesystem summary:"`
471 [ $fsnum -eq 2 ] || error "lfs df shows $fsnum != 2 filesystems."
473 run_test 24b "lfs df should show both filesystems ==============="
476 [ `lctl get_param -n mdc.*-mdc-*.connect_flags | grep -c acl` -lt 2 ] &&
477 skip "must have acl, skipping" && return
480 touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
481 chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
483 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
484 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
485 error "setfacl $DIR2/$tdir #1"
486 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
487 setfacl -m u:$RUNAS_ID:r-x -m g:$RUNAS_GID:r-x $DIR1/$tdir ||
488 error "setfacl $DIR2/$tdir #2"
489 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
490 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
491 error "setfacl $DIR2/$tdir #3"
492 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
493 setfacl -x u:$RUNAS_ID: -x g:$RUNAS_GID: $DIR1/$tdir ||
494 error "setfacl $DIR2/$tdir #4"
495 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
499 run_test 25 "change ACL on one mountpoint be seen on another ==="
502 utime $DIR1/f26a -s $DIR2/f26a || error
504 run_test 26a "allow mtime to get older"
509 echo "aaa" >> $DIR1/$tfile
511 chmod a+x $DIR2/$tfile
512 mt1=`stat -c %Y $DIR1/$tfile`
513 mt2=`stat -c %Y $DIR2/$tfile`
515 if [ x"$mt1" != x"$mt2" ]; then
516 error "not equal mtime, client1: "$mt1", client2: "$mt2"."
519 run_test 26b "sync mtime between ost and mds"
524 dd if=/dev/zero of=$DIR2/$tfile bs=$((4096+4))k conv=notrunc count=4 seek=3 &
529 dd if=/dev/zero of=$DIR1/$tfile bs=$((16384-1024))k conv=notrunc count=1 seek=4 &
534 dd if=/dev/zero of=$DIR1/$tfile bs=8k conv=notrunc count=1 seek=0
536 lctl set_param -n ldlm.dump_namespaces ""
537 wait $DD1_PID $DD2_PID
538 [ $? -ne 0 ] && lctl dk $TMP/debug || true
540 run_test 27 "align non-overlapping extent locks from request ==="
542 test_28() { # bug 9977
543 ECHO_UUID="ECHO_osc1_UUID"
544 tOST=`$LCTL dl | | awk '/-osc-|OSC.*MNT/ { print $4 }' | head -1`
546 $LFS setstripe $DIR1/$tfile -S 1048576 -i 0 -c 2
547 tOBJID=`$LFS getstripe $DIR1/$tfile | awk '$1 == 1 {print $2}'`
548 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2
552 attach echo_client ECHO_osc1 $ECHO_UUID
556 tECHOID=`$LCTL dl | grep $ECHO_UUID | awk '{ print $1 }'`
557 $LCTL --device $tECHOID destroy "${tOBJID}:0"
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 fail (this stripe was destroyed)
568 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 && error
570 # now, recreating test file
571 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2 || error
572 # reading of 1st stripe should pass
573 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error
574 # reading of 2nd stripe should pass
575 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 || error
577 run_test 28 "read/write/truncate file with lost stripes"
579 test_29() { # bug 10999
581 #define OBD_FAIL_LDLM_GLIMPSE 0x30f
582 lctl set_param fail_loc=0x8000030f
585 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1
588 #bug 11549 - permanently turn test off in b1_5
589 run_test 29 "lock put race between glimpse and enqueue ========="
591 test_30() { #bug #11110
593 cp -f /bin/bash $DIR1/$tdir/bash
594 /bin/sh -c 'sleep 1; rm -f $DIR2/$tdir/bash; cp /bin/bash $DIR2/$tdir' &
595 err=$($DIR1/$tdir/bash -c 'sleep 2; openfile -f O_RDONLY /proc/$$/exe >& /dev/null; echo $?')
597 [ $err -ne 116 ] && error_ignore 12900 "return code ($err) != -ESTALE" && return
601 run_test 30 "recreate file race ========="
604 mkdir -p $DIR1/$tdir || error "Creating dir $DIR1/$tdir"
605 writes=`LANG=C dd if=/dev/zero of=$DIR/$tdir/$tfile count=1 2>&1 |
606 awk 'BEGIN { FS="+" } /out/ {print $1}'`
607 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
608 lctl set_param fail_loc=0x314
609 reads=`LANG=C dd if=$DIR2/$tdir/$tfile of=/dev/null 2>&1 |
610 awk 'BEGIN { FS="+" } /in/ {print $1}'`
611 [ $reads -eq $writes ] || error "read" $reads "blocks, must be" $writes
613 run_test 31a "voluntary cancel / blocking ast race=============="
616 remote_ost || { skip "local OST" && return 0; }
617 remote_ost_nodsh && skip "remote OST w/o dsh" && return 0
618 mkdir -p $DIR1/$tdir || error "Creating dir $DIR1/$tdir"
619 lfs setstripe $DIR/$tdir/$tfile -i 0 -c 1
620 cp /etc/hosts $DIR/$tdir/$tfile
621 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
622 lctl set_param fail_loc=0x314
623 #define OBD_FAIL_LDLM_OST_FAIL_RACE 0x316
624 do_facet ost1 lctl set_param fail_loc=0x316
626 cat $DIR2/$tdir/$tfile > /dev/null 2>&1
627 lctl set_param fail_loc=0
628 do_facet ost1 lctl set_param fail_loc=0
629 # cleanup: reconnect the client back
632 run_test 31b "voluntary OST cancel / blocking ast race=============="
634 # enable/disable lockless truncate feature, depending on the arg 0/1
635 enable_lockless_truncate() {
636 lctl set_param -n osc.*.lockless_truncate $1
639 test_32a() { # bug 11270
640 local p="$TMP/sanityN-$TESTNAME.parameters"
641 save_lustre_params $HOSTNAME osc.*.lockless_truncate > $p
643 enable_lockless_truncate 1
645 lfs setstripe -c -1 $DIR1/$tfile
646 dd if=/dev/zero of=$DIR1/$tfile count=$OSTCOUNT bs=$STRIPE_BYTES > \
650 log "checking cached lockless truncate"
651 $TRUNCATE $DIR1/$tfile 8000000
652 $CHECKSTAT -s 8000000 $DIR2/$tfile || error "wrong file size"
653 [ $(calc_osc_stats lockless_truncate) -eq 0 ] ||
654 error "lockless truncate doesn't use cached locks"
656 log "checking not cached lockless truncate"
657 $TRUNCATE $DIR2/$tfile 5000000
658 $CHECKSTAT -s 5000000 $DIR1/$tfile || error "wrong file size"
659 [ $(calc_osc_stats lockless_truncate) -ne 0 ] ||
660 error "not cached trancate isn't lockless"
662 log "disabled lockless truncate"
663 enable_lockless_truncate 0
665 $TRUNCATE $DIR2/$tfile 3000000
666 $CHECKSTAT -s 3000000 $DIR1/$tfile || error "wrong file size"
667 [ $(calc_osc_stats lockless_truncate) -eq 0 ] ||
668 error "lockless truncate disabling failed"
670 # restore lockless_truncate default values
671 restore_lustre_params < $p
674 run_test 32a "lockless truncate"
676 test_32b() { # bug 11270
677 remote_ost_nodsh && skip "remote OST with nodsh" && return
680 local p="$TMP/sanityN-$TESTNAME.parameters"
681 save_lustre_params $HOSTNAME "osc.*.contention_seconds" > $p
682 for node in $(osts_nodes); do
683 save_lustre_params $node "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
684 save_lustre_params $node "ldlm.namespaces.filter-*.contended_locks" >> $p
685 save_lustre_params $node "ldlm.namespaces.filter-*.contention_seconds" >> $p
688 # agressive lockless i/o settings
689 for node in $(osts_nodes); do
690 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'
692 lctl set_param -n osc.*.contention_seconds 60
693 for i in $(seq 5); do
694 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > /dev/null 2>&1
695 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > /dev/null 2>&1
697 [ $(calc_osc_stats lockless_write_bytes) -ne 0 ] || error "lockless i/o was not triggered"
698 # disable lockless i/o (it is disabled by default)
699 for node in $(osts_nodes); do
700 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'
702 # set contention_seconds to 0 at client too, otherwise Lustre still
703 # remembers lock contention
704 lctl set_param -n osc.*.contention_seconds 0
706 for i in $(seq 1); do
707 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > /dev/null 2>&1
708 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > /dev/null 2>&1
710 [ $(calc_osc_stats lockless_write_bytes) -eq 0 ] ||
711 error "lockless i/o works when disabled"
713 restore_lustre_params <$p
716 run_test 32b "lockless i/o"
720 local mdts=$(get_facets MDS)
725 for mds in ${mdts//,/ }; do
727 dev=$(basename $(do_facet $mds lctl get_param -n osd*.${!varsvc}.mntdev))
728 val=$(do_facet $mds "procfile=/proc/fs/jbd/$dev/info;
729 [ -f \\\$procfile ] || procfile=/proc/fs/jbd2/$dev/info;
730 [ -f \\\$procfile ] || procfile=/proc/fs/jbd2/${dev}\:\\\*/info;
731 cat \\\$procfile | head -1;")
733 stat=$(( stat + val))
738 # commit on sharing tests
740 remote_mds_nodsh && skip "remote MDS with nodsh" && return
742 [ -n "$CLIENTS" ] || { skip "Need two or more clients" && return 0; }
743 [ $CLIENTCOUNT -ge 2 ] || \
744 { skip "Need two or more clients, have $CLIENTCOUNT" && return 0; }
746 local nfiles=${TEST33_NFILES:-10000}
747 local param_file=$TMP/$tfile-params
749 save_lustre_params $(comma_list $(mdts_nodes)) "mdt.*.commit_on_sharing" > $param_file
757 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
761 do_nodes $CLIENT1,$CLIENT2 "mkdir -p $DIR1/$tdir-\\\$(hostname)-$i"
763 jbdold=$(print_jbd_stat)
764 echo "=== START createmany old: $jbdold transaction"
765 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")
766 jbdnew=$(print_jbd_stat)
767 jbd=$(( jbdnew - jbdold ))
768 echo "=== END createmany new: $jbdnew transaction : $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
769 avgjbd=$(( avgjbd + jbd ))
770 avgtime=$(( avgtime + elapsed ))
772 eval cos${COS}_jbd=$((avgjbd / 3))
773 eval cos${COS}_time=$((avgtime / 3))
776 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
777 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
778 [ "$cos0_jbd" != 0 ] && echo "COS=1 vs COS=0 jbd: $((((cos1_jbd/cos0_jbd - 1)) * 100 )) %"
779 [ "$cos0_time" != 0 ] && echo "COS=1 vs COS=0 time: $((((cos1_time/cos0_time - 1)) * 100 )) %"
781 restore_lustre_params < $param_file
785 run_test 33a "commit on sharing, cross crete/delete, 2 clients, benchmark"
787 # End commit on sharing tests
789 get_ost_lock_timeouts() {
790 local nodes=${1:-$(comma_list $(osts_nodes))}
792 local locks=$(do_nodes $nodes \
793 "lctl get_param -n ldlm.namespaces.filter-*.lock_timeouts" | calc_sum)
802 for OPER in notimeout timeout ; do
803 rm $DIR1/$tfile 2>/dev/null
804 lock_in=$(get_ost_lock_timeouts)
805 if [ $OPER == "timeout" ] ; then
806 for j in `seq $OSTCOUNT`; do
807 #define OBD_FAIL_PTLRPC_HPREQ_TIMEOUT 0x511
808 do_facet ost$j lctl set_param fail_loc=0x511
810 echo lock should expire
812 for j in `seq $OSTCOUNT`; do
813 #define OBD_FAIL_PTLRPC_HPREQ_NOTIMEOUT 0x512
814 do_facet ost$j lctl set_param fail_loc=0x512
816 echo lock should not expire
818 echo writing on client1
819 dd if=/dev/zero of=$DIR1/$tfile count=100 conv=notrunc > /dev/null 2>&1
821 echo reading on client2
822 dd of=/dev/null if=$DIR2/$tfile > /dev/null 2>&1
823 # wait for a lock timeout
825 lock_out=$(get_ost_lock_timeouts)
826 if [ $OPER == "timeout" ] ; then
827 if [ $lock_in == $lock_out ]; then
828 error "no lock timeout happened"
833 if [ $lock_in != $lock_out ]; then
834 error "lock timeout happened"
841 run_test 34 "no lock timeout under IO"
843 test_35() { # bug 17645
846 for imp in /proc/fs/lustre/mdc/$FSNAME-MDT*-mdc-*; do
847 g=$(awk '/generation/{print $2}' $imp/import)
852 mkdir -p $MOUNT1/$tfile
855 # Let's initiate -EINTR situation by setting fail_loc and take
856 # write lock on same file from same client. This will not cause
857 # bl_ast yet as lock is already in local cache.
858 #define OBD_FAIL_LDLM_INTR_CP_AST 0x317
859 do_facet client "lctl set_param fail_loc=0x80000317"
860 local timeout=`do_facet $SINGLEMDS lctl get_param -n timeout`
861 let timeout=timeout*3
863 while test $nr -lt 10; do
864 log "Race attempt $nr"
865 local blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
866 test "x$blk1" = "x" && blk1=0
867 createmany -o $MOUNT2/$tfile/a 4000 &
871 # Let's make conflict and bl_ast
872 ls -la $MOUNT1/$tfile > /dev/null &
875 log "Wait for $pid1 $pid2 for $timeout sec..."
877 kill -9 $pid1 $pid2 > /dev/null 2>&1
879 local blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
880 test "x$blk2" = "x" && blk2=0
881 test $blk2 -gt $blk1 && break
882 rm -fr $MOUNT1/$tfile/*
886 do_facet client "lctl set_param fail_loc=0x0"
887 df -h $MOUNT1 $MOUNT2
889 for imp in /proc/fs/lustre/mdc/$FSNAME-MDT*-mdc-*; do
890 g=$(awk '/generation/{print $2}' $imp/import)
891 if ! test "$g" -eq "${generation[count]}"; then
892 error "Eviction happened on import $(basename $imp)"
897 run_test 35 "-EINTR cp_ast vs. bl_ast race does not evict client"
899 test_36() { #bug 16417
905 $LFS setstripe -c -1 $DIR1/$tdir
908 let SIZE_B=SIZE*1024*1024
910 while [ $i -le 10 ]; do
911 lctl mark "start test"
912 local before=$($LFS df | awk '{if ($1 ~/^filesystem/) {print $5; exit} }')
913 dd if=/dev/zero of=$DIR1/$tdir/file000 bs=1M count=$SIZE
916 local after_dd=$($LFS df | awk '{if ($1 ~/^filesystem/) {print $5; exit} }')
917 multiop_bg_pause $DIR2/$tdir/file000 O_r${SIZE_B}c || return 3
919 rm -f $DIR1/$tdir/file000
923 local after=$($LFS df | awk '{if ($1 ~/^filesystem/) {print $5; exit} }')
924 echo "*** cycle($i) *** before($before):after_dd($after_dd):after($after)"
925 # this free space! not used
926 if [ $after_dd -ge $after ]; then
933 run_test 36 "handle ESTALE/open-unlink corectly"
935 test_37() { # bug 18695
937 multiop_bg_pause $DIR1/$tdir D_c || return 1
939 # create large directory (32kB seems enough from e2fsck, ~= 1000 files)
940 createmany -m $DIR2/$tdir/f 10000
941 # set mtime/atime backward
942 touch -t 198001010000 $DIR2/$tdir
944 nr_files=`lfs find $DIR1/$tdir -type f | wc -l`
945 [ $nr_files -eq 10000 ] || error "$nr_files != 10000 truncated directory?"
948 run_test 37 "check i_size is not updated for directory on close (bug 18695) =============="
950 # this should be set to past
951 TEST_39_MTIME=`date -d "1 year ago" +%s`
955 local client1=${CLIENT1:-`hostname`}
956 local client2=${CLIENT2:-`hostname`}
958 do_node $client1 "touch $DIR1/$tfile"
960 do_node $client1 "touch -m -d @$TEST_39_MTIME $DIR1/$tfile"
961 local mtime1=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
962 [ "$mtime1" = $TEST_39_MTIME ] || \
963 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
965 local d1=`do_node $client1 date +%s`
966 do_node $client1 'echo hello >> '$DIR1/$tfile
967 local d2=`do_node $client1 date +%s`
969 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
970 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
971 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
973 do_node $client1 "mv $DIR1/$tfile $DIR1/$tfile-1"
975 for (( i=0; i < 2; i++ )) ; do
976 local mtime3=`do_node $client2 "stat -c %Y $DIR1/$tfile-1"`
977 [ "$mtime2" = "$mtime3" ] || \
978 error "mtime ($mtime2) changed (to $mtime3) on rename"
981 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
984 run_test 39a "test from 11063 =================================="
987 local client1=${CLIENT1:-`hostname`}
988 local client2=${CLIENT2:-`hostname`}
992 local mtime1=`stat -c %Y $DIR1/$tfile`
993 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
996 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
998 for (( i=0; i < 2; i++ )) ; do
999 local mtime3=`stat -c %Y $DIR1/$tfile`
1000 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1002 [ "$mtime3" = "$mtime4" ] || \
1003 error "different mtime on clients: $mtime3, $mtime4"
1004 [ "$mtime3" = $TEST_39_MTIME ] || \
1005 error "lost mtime: $mtime3, should be $TEST_39_MTIME"
1007 cancel_lru_locks osc
1008 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1011 run_test 39b "11063 problem 1 =================================="
1014 local client1=${CLIENT1:-`hostname`}
1015 local client2=${CLIENT2:-`hostname`}
1017 echo hello > $DIR1/$tfile
1019 local mtime1=`stat -c %Y $DIR1/$tfile`
1020 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1021 [ "$mtime1" = "$mtime2" ] || \
1022 error "create: different mtime on clients: $mtime1, $mtime2"
1025 $TRUNCATE $DIR1/$tfile 1
1027 for (( i=0; i < 2; i++ )) ; do
1028 local mtime3=`stat -c %Y $DIR1/$tfile`
1029 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1031 [ "$mtime3" = "$mtime4" ] || \
1032 error "different mtime on clients: $mtime3, $mtime4"
1033 [ "$mtime3" -gt $mtime2 ] || \
1034 error "truncate did not update mtime: $mtime2, $mtime3"
1036 cancel_lru_locks osc
1037 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1040 run_test 39c "check truncate mtime update ======================"
1042 # check that pid exists hence second operation wasn't blocked by first one
1043 # if it is so then there is no conflict, return 0
1044 # else second operation is conflicting with first one, return 1
1045 check_pdo_conflict() {
1048 sleep 1 # to ensure OP1 is finished on client if OP2 is blocked by OP1
1049 if [[ `ps --pid $pid | wc -l` == 1 ]]; then
1059 # test 40: check non-blocking operations
1061 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1062 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1063 mkdir $DIR1/$tfile &
1066 touch $DIR2/$tfile-2
1067 check_pdo_conflict $PID1 || error "create is blocked"
1068 mkdir $DIR2/$tfile-3
1069 check_pdo_conflict $PID1 || error "mkdir is blocked"
1070 link $DIR2/$tfile-2 $DIR2/$tfile-4
1071 check_pdo_conflict $PID1 || error "link is blocked"
1072 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1073 check_pdo_conflict $PID1 || error "rename is blocked"
1074 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1075 check_pdo_conflict $PID1 || error "getattr is blocked"
1076 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1077 rmdir $DIR2/$tfile-3
1078 check_pdo_conflict $PID1 || error "unlink is blocked"
1079 # all operations above shouldn't wait the first one
1080 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1085 run_test 40a "pdirops: create vs others =============="
1088 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1089 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1090 touch $DIR1/$tfile &
1094 touch $DIR2/$tfile-2
1095 check_pdo_conflict $PID1 || error "create is blocked"
1096 mkdir $DIR2/$tfile-3
1097 check_pdo_conflict $PID1 || error "mkdir is blocked"
1098 link $DIR2/$tfile-2 $DIR2/$tfile-4
1099 check_pdo_conflict $PID1 || error "link is blocked"
1100 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1101 check_pdo_conflict $PID1 || error "rename is blocked"
1102 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1103 check_pdo_conflict $PID1 || error "getattr is blocked"
1104 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1105 rmdir $DIR2/$tfile-3
1106 check_pdo_conflict $PID1 || error "unlink is blocked"
1107 # all operations above shouldn't wait the first one
1108 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1113 run_test 40b "pdirops: open|create and others =============="
1117 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1118 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1119 link $DIR1/$tfile $DIR1/$tfile-0 &
1123 touch $DIR2/$tfile-2
1124 check_pdo_conflict $PID1 || error "create is blocked"
1125 mkdir $DIR2/$tfile-3
1126 check_pdo_conflict $PID1 || error "mkdir is blocked"
1127 link $DIR2/$tfile-2 $DIR2/$tfile-4
1128 check_pdo_conflict $PID1 || error "link is blocked"
1129 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1130 check_pdo_conflict $PID1 || error "rename is blocked"
1131 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1132 check_pdo_conflict $PID1 || error "getattr is blocked"
1133 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1134 rmdir $DIR2/$tfile-3
1135 check_pdo_conflict $PID1 || error "unlink is blocked"
1136 # all operations above shouldn't wait the first one
1137 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1142 run_test 40c "pdirops: link and others =============="
1146 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1147 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1152 touch $DIR2/$tfile-2
1153 check_pdo_conflict $PID1 || error "create is blocked"
1154 mkdir $DIR2/$tfile-3
1155 check_pdo_conflict $PID1 || error "mkdir is blocked"
1156 link $DIR2/$tfile-2 $DIR2/$tfile-4
1157 check_pdo_conflict $PID1 || error "link is blocked"
1158 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1159 check_pdo_conflict $PID1 || error "rename is blocked"
1160 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1161 check_pdo_conflict $PID1 || error "getattr is blocked"
1162 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1163 rmdir $DIR2/$tfile-3
1164 check_pdo_conflict $PID1 || error "unlink is blocked"
1165 # all operations above shouldn't wait the first one
1166 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1170 run_test 40d "pdirops: unlink and others =============="
1174 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1175 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1176 mv $DIR1/$tfile $DIR1/$tfile-0 &
1180 touch $DIR2/$tfile-2
1181 check_pdo_conflict $PID1 || error "create is blocked"
1182 mkdir $DIR2/$tfile-3
1183 check_pdo_conflict $PID1 || error "mkdir is blocked"
1184 link $DIR2/$tfile-2 $DIR2/$tfile-4
1185 check_pdo_conflict $PID1 || error "link is blocked"
1186 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1187 check_pdo_conflict $PID1 || error "getattr is blocked"
1188 rm $DIR2/$tfile-4 $DIR2/$tfile-2
1189 rmdir $DIR2/$tfile-3
1190 check_pdo_conflict $PID1 || error "unlink is blocked"
1191 # all operations above shouldn't wait the first one
1192 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1197 run_test 40e "pdirops: rename and others =============="
1199 # test 41: create blocking operations
1201 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1202 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1203 multiop $DIR1/$tfile oO_CREAT:O_RDWR:c &
1206 mkdir $DIR2/$tfile && error "mkdir must fail"
1207 check_pdo_conflict $PID1 && { wait $PID1; echo "mkdir isn't blocked"; }
1211 run_test 41a "pdirops: create vs mkdir =============="
1214 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1215 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1216 multiop $DIR1/$tfile oO_CREAT:O_RDWR:c &
1219 multiop $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1220 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1224 run_test 41b "pdirops: create vs create =============="
1227 touch $DIR1/$tfile-2
1228 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1229 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1230 multiop $DIR1/$tfile oO_CREAT:O_RDWR:c &
1233 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
1234 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1238 run_test 41c "pdirops: create vs link =============="
1241 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1242 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1243 multiop $DIR1/$tfile oO_CREAT:O_RDWR:c &
1246 rm $DIR2/$tfile || error "unlink must succeed"
1247 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1251 run_test 41d "pdirops: create vs unlink =============="
1254 touch $DIR1/$tfile-2
1255 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1256 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1257 multiop $DIR1/$tfile oO_CREAT:O_RDWR:c &
1260 mv $DIR2/$tfile-2 $DIR2/$tfile || error "rename must succeed"
1261 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1265 run_test 41e "pdirops: create and rename (tgt) =============="
1268 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1269 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1270 multiop $DIR1/$tfile oO_CREAT:O_RDWR:c &
1273 mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
1274 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1278 run_test 41f "pdirops: create and rename (src) =============="
1281 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1282 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1283 multiop $DIR1/$tfile oO_CREAT:O_RDWR:c &
1286 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
1287 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1291 run_test 41g "pdirops: create vs getattr =============="
1294 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1295 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1296 multiop $DIR1/$tfile oO_CREAT:O_RDWR:c &
1299 ls -lia $DIR2/ > /dev/null
1300 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1304 run_test 41h "pdirops: create vs readdir =============="
1306 # test 42: unlink and blocking operations
1308 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1309 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1310 mkdir $DIR1/$tfile &
1313 mkdir $DIR2/$tfile && error "mkdir must fail"
1314 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1318 run_test 42a "pdirops: mkdir vs mkdir =============="
1321 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1322 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1323 mkdir $DIR1/$tfile &
1326 multiop $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1327 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1331 run_test 42b "pdirops: mkdir vs create =============="
1334 touch $DIR1/$tfile-2
1335 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1336 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1337 mkdir $DIR1/$tfile &
1340 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
1341 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1345 run_test 42c "pdirops: mkdir vs link =============="
1348 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1349 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1350 mkdir $DIR1/$tfile &
1353 rmdir $DIR2/$tfile || error "unlink must succeed"
1354 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1358 run_test 42d "pdirops: mkdir vs unlink =============="
1361 touch $DIR1/$tfile-2
1362 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1363 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1364 mkdir $DIR1/$tfile &
1367 mv -T $DIR2/$tfile-2 $DIR2/$tfile && error "rename must fail"
1368 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1372 run_test 42e "pdirops: mkdir and rename (tgt) =============="
1375 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1376 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1377 mkdir $DIR1/$tfile &
1380 mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
1381 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1385 run_test 42f "pdirops: mkdir and rename (src) =============="
1388 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1389 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1390 mkdir $DIR1/$tfile &
1393 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
1394 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1398 run_test 42g "pdirops: mkdir vs getattr =============="
1401 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1402 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1403 mkdir $DIR1/$tfile &
1406 ls -lia $DIR2/ > /dev/null
1407 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1411 run_test 42h "pdirops: mkdir vs readdir =============="
1413 # test 43: unlink and blocking operations
1416 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1417 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1421 mkdir $DIR2/$tfile || error "mkdir must succeed"
1422 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1426 run_test 43a "pdirops: unlink vs mkdir =============="
1430 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1431 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1435 multiop $DIR2/$tfile oO_CREAT:O_EXCL:c || error "create must succeed"
1436 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1440 run_test 43b "pdirops: unlink vs create =============="
1444 touch $DIR1/$tfile-2
1445 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1446 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1450 link $DIR2/$tfile-2 $DIR2/$tfile || error "link must succeed"
1451 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1455 run_test 43c "pdirops: unlink vs link =============="
1459 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1460 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1464 rm $DIR2/$tfile && error "unlink must fail"
1465 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1469 run_test 43d "pdirops: unlink vs unlink =============="
1473 touch $DIR1/$tfile-2
1474 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1475 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1479 mv -u $DIR2/$tfile-2 $DIR2/$tfile || error "rename must succeed"
1480 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1484 run_test 43e "pdirops: unlink and rename (tgt) =============="
1488 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1489 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1493 mv $DIR2/$tfile $DIR2/$tfile-2 && error "rename must fail"
1494 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1498 run_test 43f "pdirops: unlink and rename (src) =============="
1502 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1503 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1507 stat $DIR2/$tfile > /dev/null && error "stat must fail"
1508 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1512 run_test 43g "pdirops: unlink vs getattr =============="
1516 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1517 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1521 ls -lia $DIR2/ > /dev/null
1522 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1526 run_test 43h "pdirops: unlink vs readdir =============="
1528 # test 44: rename tgt and blocking operations
1530 touch $DIR1/$tfile-2
1531 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1532 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1533 mv $DIR1/$tfile-2 $DIR1/$tfile &
1536 mkdir $DIR2/$tfile && error "mkdir must fail"
1537 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1541 run_test 44a "pdirops: rename tgt vs mkdir =============="
1544 touch $DIR1/$tfile-2
1545 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1546 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1547 mv $DIR1/$tfile-2 $DIR1/$tfile &
1550 multiop $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1551 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1555 run_test 44b "pdirops: rename tgt vs create =============="
1558 touch $DIR1/$tfile-2
1559 touch $DIR1/$tfile-3
1560 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1561 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1562 mv $DIR1/$tfile-2 $DIR1/$tfile &
1565 link $DIR2/$tfile-3 $DIR2/$tfile && error "link must fail"
1566 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1570 run_test 44c "pdirops: rename tgt vs link =============="
1573 touch $DIR1/$tfile-2
1574 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1575 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1576 mv $DIR1/$tfile-2 $DIR1/$tfile &
1579 rm $DIR2/$tfile || error "unlink must succeed"
1580 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1584 run_test 44d "pdirops: rename tgt vs unlink =============="
1588 touch $DIR1/$tfile-2
1589 touch $DIR1/$tfile-3
1590 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1591 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1592 mv $DIR1/$tfile-2 $DIR1/$tfile &
1595 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
1596 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1600 run_test 44e "pdirops: rename tgt and rename (tgt) =============="
1603 touch $DIR1/$tfile-2
1604 touch $DIR1/$tfile-3
1605 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1606 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1607 mv $DIR1/$tfile-2 $DIR1/$tfile &
1610 mv $DIR2/$tfile $DIR2/$tfile-3 || error "rename must succeed"
1611 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1615 run_test 44f "pdirops: rename tgt and rename (src) =============="
1618 touch $DIR1/$tfile-2
1619 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1620 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1621 mv $DIR1/$tfile-2 $DIR1/$tfile &
1624 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
1625 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1629 run_test 44g "pdirops: rename tgt vs getattr =============="
1632 touch $DIR1/$tfile-2
1633 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1634 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1635 mv $DIR1/$tfile-2 $DIR1/$tfile &
1638 ls -lia $DIR2/ > /dev/null
1639 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1643 run_test 44h "pdirops: rename tgt vs readdir =============="
1645 # test 45: rename src and blocking operations
1648 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1649 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1650 mv $DIR1/$tfile $DIR1/$tfile-2 &
1653 mkdir $DIR2/$tfile || error "mkdir must succeed"
1654 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1658 run_test 45a "pdirops: rename src vs mkdir =============="
1662 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1663 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1664 mv $DIR1/$tfile $DIR1/$tfile-2 &
1667 multiop $DIR2/$tfile oO_CREAT:O_EXCL:c || error "create must succeed"
1668 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1672 run_test 45b "pdirops: rename src vs create =============="
1676 touch $DIR1/$tfile-3
1677 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1678 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1679 mv $DIR1/$tfile $DIR1/$tfile-2 &
1682 link $DIR2/$tfile-3 $DIR2/$tfile || error "link must succeed"
1683 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1687 run_test 45c "pdirops: rename src vs link =============="
1691 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1692 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1693 mv $DIR1/$tfile $DIR1/$tfile-2 &
1696 rm $DIR2/$tfile && error "unlink must fail"
1697 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1701 run_test 45d "pdirops: rename src vs unlink =============="
1705 touch $DIR1/$tfile-3
1706 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1707 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1708 mv $DIR1/$tfile $DIR1/$tfile-2 &
1711 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
1712 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1716 run_test 45e "pdirops: rename src and rename (tgt) =============="
1720 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1721 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1722 mv $DIR1/$tfile $DIR1/$tfile-2 &
1725 mv $DIR2/$tfile $DIR2/$tfile-3 && error "rename must fail"
1726 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1730 run_test 45f "pdirops: rename src and rename (src) =============="
1734 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1735 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1736 mv $DIR1/$tfile $DIR1/$tfile-2 &
1739 stat $DIR2/$tfile > /dev/null && "stat must fail"
1740 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1744 run_test 45g "pdirops: rename src vs getattr =============="
1748 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1749 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1750 mv $DIR1/$tfile $DIR1/$tfile-2 &
1753 ls -lia $DIR2/ > /dev/null
1754 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1758 run_test 45h "pdirops: unlink vs readdir =============="
1760 # test 46: link and blocking operations
1762 touch $DIR1/$tfile-2
1763 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1764 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1765 link $DIR1/$tfile-2 $DIR1/$tfile &
1768 mkdir $DIR2/$tfile && error "mkdir must fail"
1769 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1773 run_test 46a "pdirops: link vs mkdir =============="
1776 touch $DIR1/$tfile-2
1777 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1778 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1779 link $DIR1/$tfile-2 $DIR1/$tfile &
1782 multiop $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1783 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1787 run_test 46b "pdirops: link vs create =============="
1790 touch $DIR1/$tfile-2
1791 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1792 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1793 link $DIR1/$tfile-2 $DIR1/$tfile &
1796 link $DIR2/$tfile $DIR2/$tfile && error "link must fail"
1797 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1801 run_test 46c "pdirops: link vs link =============="
1804 touch $DIR1/$tfile-2
1805 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1806 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1807 link $DIR1/$tfile-2 $DIR1/$tfile &
1810 rm $DIR2/$tfile || error "unlink must succeed"
1811 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1815 run_test 46d "pdirops: link vs unlink =============="
1818 touch $DIR1/$tfile-2
1819 touch $DIR1/$tfile-3
1820 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1821 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1822 link $DIR1/$tfile-2 $DIR1/$tfile &
1825 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
1826 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1830 run_test 46e "pdirops: link and rename (tgt) =============="
1833 touch $DIR1/$tfile-2
1834 touch $DIR1/$tfile-3
1835 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1836 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1837 link $DIR1/$tfile-2 $DIR1/$tfile &
1840 mv $DIR2/$tfile $DIR2/$tfile-3 || error "rename must succeed"
1841 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1845 run_test 46f "pdirops: link and rename (src) =============="
1848 touch $DIR1/$tfile-2
1849 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1850 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1851 link $DIR1/$tfile-2 $DIR1/$tfile &
1854 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
1855 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1859 run_test 46g "pdirops: link vs getattr =============="
1862 touch $DIR1/$tfile-2
1863 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1864 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1865 link $DIR1/$tfile-2 $DIR1/$tfile &
1868 ls -lia $DIR2/ > /dev/null
1869 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1873 run_test 46h "pdirops: link vs readdir =============="
1877 dd if=/dev/zero of=$DIR1/$tfile bs=1K count=10
1878 #define OBD_FAIL_OSC_CP_ENQ_RACE 0x410
1879 do_facet client "lctl set_param fail_loc=0x410"
1880 $TRUNCATE $DIR2/$tfile $trunc_size
1881 do_facet client "lctl set_param fail_loc=0x0"
1883 size=`stat -c %s $DIR2/$tfile`
1884 [ $size -eq $trunc_size ] || error "wrong size"
1886 run_test 50 "osc lvb attrs: enqueue vs. CP AST =============="
1890 mkdir -p $DIR1/$tdir
1891 file1=$DIR1/$tdir/file
1892 file2=$DIR2/$tdir/file
1894 echo orig > $file2 || error "Could not create $file2"
1895 version=$($LFS data_version $file1)
1898 echo append >> $file2 || error "Could not append to $file2"
1899 version2=$($LFS data_version $file1)
1900 [ "$version" != "$version2" ] ||
1901 error "append did not change data version: $version"
1904 echo overwrite > $file2 || error "Could not overwrite $file2"
1905 version3=$($LFS data_version $file1)
1906 [ "$version2" != "$version3" ] ||
1907 error "overwrite did not change data version: $version2"
1909 # Truncate before EOF
1910 $TRUNCATE $file2 3 || error "Could not truncate $file2"
1911 version4=$($LFS data_version $file1)
1912 [ "$version3" != "$version4" ] ||
1913 error "truncate did not change data version: $version3"
1915 # Truncate after EOF
1916 $TRUNCATE $file2 123456 || error "Could not truncate $file2"
1917 version5=$($LFS data_version $file1)
1918 [ "$version4" != "$version5" ] ||
1919 error "truncate did not change data version: $version4"
1921 # Chmod do not change version
1922 chmod 400 $file2 || error "Could not chmod 400 $file2"
1923 version6=$($LFS data_version $file1)
1924 [ "$version5" == "$version6" ] ||
1925 error "chmod should not change data version: $version5 != $version6"
1927 # Chown do not change version
1928 chown $RUNAS_ID $file2 || error "Could not chown $RUNAS_ID $file2"
1929 version7=$($LFS data_version $file1)
1930 [ "$version5" == "$version7" ] ||
1931 error "chown should not change data version: $version5 != $version7"
1933 run_test 60 "Verify data_version behaviour"
1935 log "cleanup: ======================================================"
1937 [ "$(mount | grep $MOUNT2)" ] && umount $MOUNT2
1939 complete $(basename $0) $SECONDS
1940 check_and_cleanup_lustre