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 MULTIOP=${MULTIOP:-multiop}
29 export TMP=${TMP:-/tmp}
30 MOUNT_2=${MOUNT_2:-"yes"}
31 CHECK_GRANT=${CHECK_GRANT:-"yes"}
32 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
36 export NAME=${NAME:-local}
38 LUSTRE=${LUSTRE:-`dirname $0`/..}
39 . $LUSTRE/tests/test-framework.sh
43 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
46 [ "$SLOW" = "no" ] && EXCEPT_SLOW="12 23 33a"
53 check_and_setup_lustre
55 LOVNAME=$($LCTL get_param -n llite.*.lov.common_name | tail -n 1)
56 OSTCOUNT=$($LCTL get_param -n lov.$LOVNAME.numobd)
59 rm -rf $DIR1/[df][0-9]* $DIR1/lnk
61 SAMPLE_FILE=$TMP/$(basename $0 .sh).junk
62 dd if=/dev/urandom of=$SAMPLE_FILE bs=1M count=1
64 # $RUNAS_ID may get set incorrectly somewhere else
65 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
67 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
76 [ -f $DIR2/f1 ] || error
78 run_test 1a "check create on 2 mtpt's =========================="
82 $CHECKSTAT -t file -p 0777 $DIR1/f1 || error
85 run_test 1b "check attribute updates on 2 mtpt's ==============="
88 $CHECKSTAT -t file -p 0666 $DIR1/f1 || error
90 run_test 1c "check after remount attribute updates on 2 mtpt's ="
94 $CHECKSTAT -a $DIR1/f1 || error
96 run_test 1d "unlink on one mountpoint removes file on other ===="
102 $CHECKSTAT -t file -p 0777 $DIR1/f2a || error
104 run_test 2a "check cached attribute updates on 2 mtpt's ========"
110 $CHECKSTAT -t file -p 0777 $DIR2/f2b || error
112 run_test 2b "check cached attribute updates on 2 mtpt's ========"
114 # NEED TO SAVE ROOT DIR MODE
117 $CHECKSTAT -t dir -p 0777 $DIR2 || error
119 run_test 2c "check cached attribute updates on 2 mtpt's root ==="
123 $CHECKSTAT -t dir -p 0755 $DIR2 || error
125 run_test 2d "check cached attribute updates on 2 mtpt's root ==="
132 $RUNAS dd if=/dev/zero of=$DIR2/$tfile count=1 || error
134 run_test 2e "check chmod on root is propagated to others"
137 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
139 local remote_dir=$tdir/remote_dir
142 $LFS mkdir -i $MDTIDX $DIR1/$remote_dir ||
143 error "Create remote directory failed"
145 touch $DIR1/$remote_dir/$tfile ||
146 error "Create file under remote directory failed"
147 chmod 777 $DIR1/$remote_dir/$tfile ||
148 error "Chmod file under remote directory failed"
150 $CHECKSTAT -t file -p 0777 $DIR2/$remote_dir/$tfile ||
151 error "Check attr of file under remote directory failed"
153 chown $RUNAS_ID:$RUNAS_GID $DIR1/$remote_dir/$tfile ||
154 error "Chown file under remote directory failed"
156 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR2/$remote_dir/$tfile ||
157 error "Check owner of file under remote directory failed"
159 cd $DIR2/$remote_dir || error "enter remote dir"
160 rm -rf $DIR1/$remote_dir/$tfile ||
161 error "Unlink remote directory failed"
163 $CHECKSTAT -t file $DIR2/$remote_dir/$tfile &&
164 error "unlink file still exists!"
166 cd $DIR2/$tdir || error "exit remote dir"
167 rm -rf $DIR1/$tdir || error "unlink directory failed"
169 run_test 2f "check attr/owner updates on DNE with 2 mtpt's"
172 local target="this/is/good"
173 ln -s $target $DIR1/$tfile || error "ln -s $target $DIR1/$tfile failed"
174 [ "$(ls -l $DIR2/$tfile | sed -e 's/.* -> //')" = "$target" ] ||
175 error "link $DIR2/$tfile not as expected"
177 run_test 3 "symlink on one mtpt, readlink on another ==========="
180 multifstat $DIR1/f4 $DIR2/f4
182 run_test 4 "fstat validation on multiple mount points =========="
186 $TRUNCATE $DIR2/f5 100
187 $CHECKSTAT -t file -s 100 $DIR1/f5 || error
190 run_test 5 "create a file on one mount, truncate it on the other"
193 openunlink $DIR1/$tfile $DIR2/$tfile || \
194 error "openunlink $DIR1/$tfile $DIR2/$tfile"
196 run_test 6 "remove of open file on other node =================="
200 opendirunlink $DIR1/$dir $DIR2/$dir || \
201 error "opendirunlink $DIR1/$dir $DIR2/$dir"
203 run_test 7 "remove of open directory on other node ============="
206 opendevunlink $DIR1/$tfile $DIR2/$tfile || \
207 error "opendevunlink $DIR1/$tfile $DIR2/$tfile"
209 run_test 8 "remove of open special file on other node =========="
215 for C in a b c d e f g h i j k l; do
216 dir=`eval echo \\$DIR$MTPT`
217 echo -n $C >> $dir/f9
218 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
220 [ "`cat $DIR1/f9`" = "abcdefghijkl" ] || \
221 error "`od -a $DIR1/f9` != abcdefghijkl"
223 run_test 9 "append of file with sub-page size on multiple mounts"
230 for C in a b c d e f g h i j k l; do
231 dir=`eval echo \\$DIR$MTPT`
232 echo -n $C | dd of=$dir/f10 bs=1 seek=$OFFSET count=1
233 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
234 OFFSET=`expr $OFFSET + 1`
236 [ "`cat $DIR1/f10`" = "abcdefghijkl" ] || \
237 error "`od -a $DIR1/f10` != abcdefghijkl"
239 run_test 10a "write of file with sub-page size on multiple mounts "
243 yes "R" | head -c 4000 >$TMP/f10b-seed
244 dd if=$TMP/f10b-seed of=$DIR1/f10b bs=3k count=1 || error "dd $DIR1"
246 $TRUNCATE $DIR1/f10b 4096 || error "truncate 4096"
248 dd if=$DIR2/f10b of=$TMP/f10b-lustre bs=4k count=1 || error "dd $DIR2"
250 # create a test file locally to compare
251 dd if=$TMP/f10b-seed of=$TMP/f10b bs=3k count=1 || error "dd random"
252 $TRUNCATE $TMP/f10b 4096 || error "truncate 4096"
253 cmp $TMP/f10b $TMP/f10b-lustre || error "file miscompare"
254 rm $TMP/f10b $TMP/f10b-lustre $TMP/f10b-seed
256 run_test 10b "write of file with sub-page size on multiple mounts "
260 multiop_bg_pause $DIR1/d11/f O_c || return 1
262 cp -p /bin/ls $DIR1/d11/f
266 wait $MULTIPID || error
267 [ $RC -eq 0 ] && error || true
269 run_test 11 "execution of file opened for write should return error ===="
272 DIR=$DIR DIR2=$DIR2 sh lockorder.sh
274 run_test 12 "test lock ordering (link, stat, unlink) ==========="
276 test_13() { # bug 2451 - directory coherency
277 test_mkdir $DIR1/d13 || error
278 cd $DIR1/d13 || error
280 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
282 rm -f $DIR2/d13/f13 || error
283 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (1)" || true
284 # need to run it twice
285 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
287 rm -f $DIR2/d13/f13 || error
288 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (2)" || true
290 run_test 13 "test directory page revocation ===================="
293 test_mkdir -p $DIR1/$tdir
294 cp -p /bin/ls $DIR1/$tdir/$tfile
295 multiop_bg_pause $DIR1/$tdir/$tfile Ow_c || return 1
298 $DIR2/$tdir/$tfile && error || true
300 wait $MULTIPID || return 2
302 run_test 14 "execution of file open for write returns -ETXTBSY ="
305 test_mkdir -p $DIR1/d14
306 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
307 MULTIOP_PROG=$DIR1/d14/multiop multiop_bg_pause $TMP/test14.junk O_c || return 1
309 $MULTIOP $DIR2/d14/multiop Oc && error "expected error, got success"
310 kill -USR1 $MULTIOP_PID || return 2
311 wait $MULTIOP_PID || return 3
312 rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop"
314 run_test 14a "open(RDWR) of executing file returns -ETXTBSY ===="
316 test_14b() { # bug 3192, 7040
317 test_mkdir -p $DIR1/d14
318 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
319 MULTIOP_PROG=$DIR1/d14/multiop multiop_bg_pause $TMP/test14.junk O_c || return 1
321 $TRUNCATE $DIR2/d14/multiop 0 && kill -9 $MULTIOP_PID && \
322 error "expected truncate error, got success"
323 kill -USR1 $MULTIOP_PID || return 2
324 wait $MULTIOP_PID || return 3
325 cmp `which multiop` $DIR1/d14/multiop || error "binary changed"
326 rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop"
328 run_test 14b "truncate of executing file returns -ETXTBSY ======"
330 test_14c() { # bug 3430, 7040
331 test_mkdir -p $DIR1/d14
332 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
333 MULTIOP_PROG=$DIR1/d14/multiop multiop_bg_pause $TMP/test14.junk O_c || return 1
335 cp /etc/hosts $DIR2/d14/multiop && error "expected error, got success"
336 kill -USR1 $MULTIOP_PID || return 2
337 wait $MULTIOP_PID || return 3
338 cmp `which multiop` $DIR1/d14/multiop || error "binary changed"
339 rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop"
341 run_test 14c "open(O_TRUNC) of executing file return -ETXTBSY =="
343 test_14d() { # bug 10921
344 test_mkdir -p $DIR1/d14
345 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
346 MULTIOP_PROG=$DIR1/d14/multiop multiop_bg_pause $TMP/test14.junk O_c || return 1
349 chmod 600 $DIR1/d14/multiop || error "chmod failed"
350 kill -USR1 $MULTIOP_PID || return 2
351 wait $MULTIOP_PID || return 3
352 cmp `which multiop` $DIR1/d14/multiop || error "binary changed"
353 rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop"
355 run_test 14d "chmod of executing file is still possible ========"
357 test_15() { # bug 974 - ENOSPC
359 sh oos2.sh $MOUNT1 $MOUNT2
360 wait_delete_completed
361 grant_error=`dmesg | grep "> available"`
362 [ -z "$grant_error" ] || error "$grant_error"
364 run_test 15 "test out-of-space with multiple writers ==========="
367 # The FSXNUM reduction for ZFS is needed until ORI-487 is fixed.
368 # We don't want to skip it entirely, but ZFS is VERY slow and cannot
369 # pass a 2500 operation dual-mount run within the time limit.
370 if [ "$(facet_fstype ost1)" = "zfs" ]; then
371 FSXNUM=$((COUNT / 5))
373 elif [ "$SLOW" = "yes" ]; then
374 FSXNUM=$((COUNT * 5))
382 local file1=$DIR1/$tfile
383 local file2=$DIR2/$tfile
385 # to allocate grant because it may run out due to test_15.
386 lfs setstripe -c -1 $file1
387 dd if=/dev/zero of=$file1 bs=$STRIPE_BYTES count=$OSTCOUNT oflag=sync
388 dd if=/dev/zero of=$file2 bs=$STRIPE_BYTES count=$OSTCOUNT oflag=sync
391 lfs setstripe -c -1 $file1 # b=10919
392 fsx -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -S 0 $file1 $file2
394 run_test 16 "$FSXNUM iterations of dual-mount fsx"
396 test_17() { # bug 3513, 3667
397 remote_ost_nodsh && skip "remote OST with nodsh" && return
399 lfs setstripe $DIR1/$tfile -i 0 -c 1
400 cp $SAMPLE_FILE $DIR1/$tfile
401 cancel_lru_locks osc > /dev/null
402 #define OBD_FAIL_ONCE|OBD_FAIL_LDLM_CREATE_RESOURCE 0x30a
403 do_facet ost1 lctl set_param fail_loc=0x8000030a
404 ls -ls $DIR1/$tfile | awk '{ print $1,$6 }' > $DIR1/$tfile-1 & \
405 ls -ls $DIR2/$tfile | awk '{ print $1,$6 }' > $DIR2/$tfile-2
407 diff -u $DIR1/$tfile-1 $DIR2/$tfile-2 || error "files are different"
409 run_test 17 "resource creation/LVB creation race ==============="
412 # turn e.g. ALWAYS_EXCEPT="18c" into "-e 3"
415 for idx in {a..z}; do
416 local ptr=EXCEPT_ALWAYS_18$idx
417 [ x${!ptr} = xtrue ] || continue
419 excepts="$excepts -e $(($(printf %d \'$idx)-96))"
422 $LUSTRE/tests/mmap_sanity -d $MOUNT1 -m $MOUNT2 $excepts
425 run_test 18 "mmap sanity check ================================="
427 test_19() { # bug3811
428 local node=$(facet_active_host ost1)
430 # check whether obdfilter is cache capable at all
431 if ! get_obdfilter_param $node '' read_cache_enable >/dev/null; then
432 echo "not cache-capable obdfilter"
436 local MAX=$(get_obdfilter_param $node '' readcache_max_filesize | \
438 set_obdfilter_param $node '' readcache_max_filesize 4096
439 dd if=/dev/urandom of=$TMP/$tfile bs=512k count=32
440 local SUM=$(cksum $TMP/$tfile | cut -d" " -f 1,2)
441 cp $TMP/$tfile $DIR1/$tfile
442 for i in `seq 1 20`; do
443 [ $((i % 5)) -eq 0 ] && log "$testname loop $i"
444 cancel_lru_locks osc > /dev/null
445 cksum $DIR1/$tfile | cut -d" " -f 1,2 > $TMP/sum1 & \
446 cksum $DIR2/$tfile | cut -d" " -f 1,2 > $TMP/sum2
448 [ "$(cat $TMP/sum1)" = "$SUM" ] || \
449 error "$DIR1/$tfile $(cat $TMP/sum1) != $SUM"
450 [ "$(cat $TMP/sum2)" = "$SUM" ] || \
451 error "$DIR2/$tfile $(cat $TMP/sum2) != $SUM"
453 set_obdfilter_param $node '' readcache_max_filesize $MAX
456 run_test 19 "test concurrent uncached read races ==============="
461 CNT=$((`lctl get_param -n llite.*.dump_page_cache | wc -l`))
462 $MULTIOP $DIR1/f20 Ow8190c
463 $MULTIOP $DIR2/f20 Oz8194w8190c
464 $MULTIOP $DIR1/f20 Oz0r8190c
466 CNTD=$((`lctl get_param -n llite.*.dump_page_cache | wc -l` - $CNT))
468 error $CNTD" page left in cache after lock cancel" || true
470 run_test 20 "test extra readahead page left in cache ===="
477 test_21() { # Bug 5907
479 mount /etc $DIR1/d21 --bind || error "mount failed" # Poor man's mount.
481 rmdir -v $DIR1/d21 && error "Removed mounted directory"
482 rmdir -v $DIR2/d21 && echo "Removed mounted directory from another mountpoint, needs to be fixed"
483 test -d $DIR1/d21 || error "Mounted directory disappeared"
485 test -d $DIR2/d21 || test -d $DIR1/d21 && error "Removed dir still visible after umount"
488 run_test 21 " Try to remove mountpoint on another dir ===="
490 test_23() { # Bug 5972
491 echo "others should see updated atime while another read" > $DIR1/f23
493 # clear the lock(mode: LCK_PW) gotten from creating operation
497 #MAX_ATIME_DIFF 60, we update atime only if older than 60 seconds
500 multiop_bg_pause $DIR1/f23 or20_c || return 1
501 # with SOM and opencache enabled, we need to close a file and cancel
502 # open lock to get atime propogated to MDS
506 time2=`stat -c "%X" $DIR2/f23`
508 if (( $time2 <= $time1 )); then
509 error "atime doesn't update among nodes"
512 rm -f $DIR1/f23 || error "rm -f $DIR1/f23 failed"
515 run_test 23 " others should see updated atime while another read===="
519 lfs df || error "lfs df failed"
520 lfs df -ih || error "lfs df -ih failed"
521 lfs df -h $DIR1 || error "lfs df -h $DIR1 failed"
522 lfs df -i $DIR2 || error "lfs df -i $DIR2 failed"
523 lfs df $DIR1/$tfile || error "lfs df $DIR1/$tfile failed"
524 lfs df -ih $DIR2/$tfile || error "lfs df -ih $DIR2/$tfile failed"
526 OSC=`lctl dl | awk '/-osc-|OSC.*MNT/ {print $4}' | head -n 1`
527 # OSC=`lctl dl | awk '/-osc-/ {print $4}' | head -n 1`
528 lctl --device %$OSC deactivate
529 lfs df -i || error "lfs df -i with deactivated OSC failed"
530 lctl --device %$OSC activate
531 lfs df || error "lfs df with reactivated OSC failed"
533 run_test 24a "lfs df [-ih] [path] test ========================="
537 fsnum=$(lfs_df | grep -c "summary")
538 [ $fsnum -eq 2 ] || error "lfs df shows $fsnum != 2 filesystems."
540 run_test 24b "lfs df should show both filesystems ==============="
543 local acl=$(lctl get_param -n mdc.*MDT0000-mdc-*.connect_flags |
545 [ "$acl" -lt 1 ] && skip "must have acl, skipping" && return
548 touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
549 chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
551 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
552 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
553 error "setfacl $DIR2/$tdir #1"
554 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
555 setfacl -m u:$RUNAS_ID:r-x -m g:$RUNAS_GID:r-x $DIR1/$tdir ||
556 error "setfacl $DIR2/$tdir #2"
557 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
558 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
559 error "setfacl $DIR2/$tdir #3"
560 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
561 setfacl -x u:$RUNAS_ID: -x g:$RUNAS_GID: $DIR1/$tdir ||
562 error "setfacl $DIR2/$tdir #4"
563 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
567 run_test 25a "change ACL on one mountpoint be seen on another ==="
570 local acl=$(lctl get_param -n mdc.*MDT0000-mdc-*.connect_flags |
572 [ "$acl" -lt 1 ] && skip "must have acl, skipping" && return
574 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
577 $LFS mkdir -i 1 $DIR1/$tdir
578 touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
579 chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
581 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
582 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
583 error "setfacl $DIR2/$tdir #1"
584 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
585 setfacl -m u:$RUNAS_ID:r-x -m g:$RUNAS_GID:r-x $DIR1/$tdir ||
586 error "setfacl $DIR2/$tdir #2"
587 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
588 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
589 error "setfacl $DIR2/$tdir #3"
590 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
591 setfacl -x u:$RUNAS_ID: -x g:$RUNAS_GID: $DIR1/$tdir ||
592 error "setfacl $DIR2/$tdir #4"
593 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
597 run_test 25b "change ACL under remote dir on one mountpoint be seen on another"
600 utime $DIR1/f26a -s $DIR2/f26a || error
602 run_test 26a "allow mtime to get older"
607 echo "aaa" >> $DIR1/$tfile
609 chmod a+x $DIR2/$tfile
610 mt1=`stat -c %Y $DIR1/$tfile`
611 mt2=`stat -c %Y $DIR2/$tfile`
613 if [ x"$mt1" != x"$mt2" ]; then
614 error "not equal mtime, client1: "$mt1", client2: "$mt2"."
617 run_test 26b "sync mtime between ost and mds"
622 dd if=/dev/zero of=$DIR2/$tfile bs=$((4096+4))k conv=notrunc count=4 seek=3 &
627 dd if=/dev/zero of=$DIR1/$tfile bs=$((16384-1024))k conv=notrunc count=1 seek=4 &
632 dd if=/dev/zero of=$DIR1/$tfile bs=8k conv=notrunc count=1 seek=0
634 lctl set_param -n ldlm.dump_namespaces ""
635 wait $DD1_PID $DD2_PID
636 [ $? -ne 0 ] && lctl dk $TMP/debug || true
638 run_test 27 "align non-overlapping extent locks from request ==="
640 test_28() { # bug 9977
641 ECHO_UUID="ECHO_osc1_UUID"
642 tOST=`$LCTL dl | | awk '/-osc-|OSC.*MNT/ { print $4 }' | head -1`
644 $LFS setstripe $DIR1/$tfile -S 1048576 -i 0 -c 2
645 tOBJID=`$LFS getstripe $DIR1/$tfile | awk '$1 == 1 {print $2}'`
646 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2
650 attach echo_client ECHO_osc1 $ECHO_UUID
654 tECHOID=`$LCTL dl | grep $ECHO_UUID | awk '{ print $1 }'`
655 $LCTL --device $tECHOID destroy "${tOBJID}:0"
663 # reading of 1st stripe should pass
664 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error
665 # reading of 2nd stripe should fail (this stripe was destroyed)
666 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 && error
668 # now, recreating test file
669 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2 || error
670 # reading of 1st stripe should pass
671 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error
672 # reading of 2nd stripe should pass
673 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 || error
675 run_test 28 "read/write/truncate file with lost stripes"
677 test_29() { # bug 10999
679 #define OBD_FAIL_LDLM_GLIMPSE 0x30f
680 lctl set_param fail_loc=0x8000030f
683 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1
686 #bug 11549 - permanently turn test off in b1_5
687 run_test 29 "lock put race between glimpse and enqueue ========="
689 test_30() { #bug #11110
690 test_mkdir -p $DIR1/$tdir
691 cp -f /bin/bash $DIR1/$tdir/bash
692 /bin/sh -c 'sleep 1; rm -f $DIR2/$tdir/bash;
693 cp /bin/bash $DIR2/$tdir' &
694 local err=$($DIR1/$tdir/bash -c 'sleep 2;
695 openfile -f O_RDONLY /proc/$$/exe >& /dev/null; echo $?')
698 error_ignore 12900 "return code ($err) != -ESTALE" && return
702 run_test 30 "recreate file race"
705 test_mkdir -p $DIR1/$tdir || error "Creating dir $DIR1/$tdir"
706 local writes=$(LANG=C dd if=/dev/zero of=$DIR/$tdir/$tfile \
707 count=1 2>&1 | awk 'BEGIN { FS="+" } /out/ {print $1}')
708 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
709 lctl set_param fail_loc=0x314
710 local reads=$(LANG=C dd if=$DIR2/$tdir/$tfile of=/dev/null 2>&1 |
711 awk 'BEGIN { FS="+" } /in/ {print $1}')
712 [ $reads -eq $writes ] || error "read" $reads "blocks, must be" $writes
714 run_test 31a "voluntary cancel / blocking ast race=============="
717 remote_ost || { skip "local OST" && return 0; }
718 remote_ost_nodsh && skip "remote OST w/o dsh" && return 0
720 # make sure there is no local locks due to destroy
721 wait_mds_ost_sync || error "wait_mds_ost_sync()"
722 wait_delete_completed || error "wait_delete_completed()"
724 test_mkdir -p $DIR1/$tdir || error "Creating dir $DIR1/$tdir"
725 lfs setstripe $DIR/$tdir/$tfile -i 0 -c 1
726 cp /etc/hosts $DIR/$tdir/$tfile
727 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
728 lctl set_param fail_loc=0x314
729 #define OBD_FAIL_LDLM_OST_FAIL_RACE 0x316
730 do_facet ost1 lctl set_param fail_loc=0x316
732 cat $DIR2/$tdir/$tfile > /dev/null 2>&1
733 lctl set_param fail_loc=0
734 do_facet ost1 lctl set_param fail_loc=0
735 # cleanup: reconnect the client back
738 run_test 31b "voluntary OST cancel / blocking ast race=============="
740 # enable/disable lockless truncate feature, depending on the arg 0/1
741 enable_lockless_truncate() {
742 lctl set_param -n osc.*.lockless_truncate $1
745 test_32a() { # bug 11270
746 local p="$TMP/sanityN-$TESTNAME.parameters"
747 save_lustre_params $HOSTNAME osc.*.lockless_truncate > $p
749 enable_lockless_truncate 1
751 lfs setstripe -c -1 $DIR1/$tfile
752 dd if=/dev/zero of=$DIR1/$tfile count=$OSTCOUNT bs=$STRIPE_BYTES > \
756 log "checking cached lockless truncate"
757 $TRUNCATE $DIR1/$tfile 8000000
758 $CHECKSTAT -s 8000000 $DIR2/$tfile || error "wrong file size"
759 [ $(calc_osc_stats lockless_truncate) -eq 0 ] ||
760 error "lockless truncate doesn't use cached locks"
762 log "checking not cached lockless truncate"
763 $TRUNCATE $DIR2/$tfile 5000000
764 $CHECKSTAT -s 5000000 $DIR1/$tfile || error "wrong file size"
765 [ $(calc_osc_stats lockless_truncate) -ne 0 ] ||
766 error "not cached trancate isn't lockless"
768 log "disabled lockless truncate"
769 enable_lockless_truncate 0
771 $TRUNCATE $DIR2/$tfile 3000000
772 $CHECKSTAT -s 3000000 $DIR1/$tfile || error "wrong file size"
773 [ $(calc_osc_stats lockless_truncate) -eq 0 ] ||
774 error "lockless truncate disabling failed"
776 # restore lockless_truncate default values
777 restore_lustre_params < $p
780 run_test 32a "lockless truncate"
782 test_32b() { # bug 11270
783 remote_ost_nodsh && skip "remote OST with nodsh" && return
786 local p="$TMP/sanityN-$TESTNAME.parameters"
787 save_lustre_params $HOSTNAME "osc.*.contention_seconds" > $p
788 for node in $(osts_nodes); do
789 save_lustre_params $node "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
790 save_lustre_params $node "ldlm.namespaces.filter-*.contended_locks" >> $p
791 save_lustre_params $node "ldlm.namespaces.filter-*.contention_seconds" >> $p
794 # agressive lockless i/o settings
795 for node in $(osts_nodes); do
796 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'
798 lctl set_param -n osc.*.contention_seconds 60
799 for i in $(seq 5); do
800 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > /dev/null 2>&1
801 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > /dev/null 2>&1
803 [ $(calc_osc_stats lockless_write_bytes) -ne 0 ] || error "lockless i/o was not triggered"
804 # disable lockless i/o (it is disabled by default)
805 for node in $(osts_nodes); do
806 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'
808 # set contention_seconds to 0 at client too, otherwise Lustre still
809 # remembers lock contention
810 lctl set_param -n osc.*.contention_seconds 0
812 for i in $(seq 1); do
813 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > /dev/null 2>&1
814 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > /dev/null 2>&1
816 [ $(calc_osc_stats lockless_write_bytes) -eq 0 ] ||
817 error "lockless i/o works when disabled"
819 restore_lustre_params <$p
822 run_test 32b "lockless i/o"
826 local mdts=$(get_facets MDS)
831 for mds in ${mdts//,/ }; do
833 dev=$(basename $(do_facet $mds lctl get_param -n osd*.${!varsvc}.mntdev))
834 val=$(do_facet $mds "procfile=/proc/fs/jbd/$dev/info;
835 [ -f \\\$procfile ] || procfile=/proc/fs/jbd2/$dev/info;
836 [ -f \\\$procfile ] || procfile=/proc/fs/jbd2/${dev}\:\\\*/info;
837 cat \\\$procfile | head -1;")
839 stat=$(( stat + val))
844 # commit on sharing tests
846 remote_mds_nodsh && skip "remote MDS with nodsh" && return
848 [ -n "$CLIENTS" ] || { skip "Need two or more clients" && return 0; }
849 [ $CLIENTCOUNT -ge 2 ] || \
850 { skip "Need two or more clients, have $CLIENTCOUNT" && return 0; }
852 local nfiles=${TEST33_NFILES:-10000}
853 local param_file=$TMP/$tfile-params
855 save_lustre_params $(comma_list $(mdts_nodes)) "mdt.*.commit_on_sharing" > $param_file
863 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
867 do_nodes $CLIENT1,$CLIENT2 "mkdir -p $DIR1/$tdir-\\\$(hostname)-$i"
869 jbdold=$(print_jbd_stat)
870 echo "=== START createmany old: $jbdold transaction"
871 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")
872 jbdnew=$(print_jbd_stat)
873 jbd=$(( jbdnew - jbdold ))
874 echo "=== END createmany new: $jbdnew transaction : $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
875 avgjbd=$(( avgjbd + jbd ))
876 avgtime=$(( avgtime + elapsed ))
878 eval cos${COS}_jbd=$((avgjbd / 3))
879 eval cos${COS}_time=$((avgtime / 3))
882 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
883 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
884 [ "$cos0_jbd" != 0 ] && echo "COS=1 vs COS=0 jbd: $((((cos1_jbd/cos0_jbd - 1)) * 100 )) %"
885 [ "$cos0_time" != 0 ] && echo "COS=1 vs COS=0 time: $((((cos1_time/cos0_time - 1)) * 100 )) %"
887 restore_lustre_params < $param_file
891 run_test 33a "commit on sharing, cross crete/delete, 2 clients, benchmark"
893 # commit on sharing tests
895 remote_mds_nodsh && skip "remote MDS with nodsh" && return
897 [ -n "$CLIENTS" ] || { skip "Need two or more clients" && return 0; }
898 [ $CLIENTCOUNT -ge 2 ] ||
899 { skip "Need two or more clients, have $CLIENTCOUNT" &&
901 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
903 local nfiles=${TEST33_NFILES:-10000}
904 local param_file=$TMP/$tfile-params
906 save_lustre_params $(comma_list $(mdts_nodes)) \
907 "mdt.*.commit_on_sharing" > $param_file
915 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
919 do_node $CLIENT1 "$LFS mkdir -i $MDTIDX -p \
920 $DIR1/$tdir-\\\$(hostname)-$i"
922 jbdold=$(print_jbd_stat)
923 echo "=== START createmany old: $jbdold transaction"
924 local elapsed=$(do_and_time "do_nodes $CLIENT1,$CLIENT2\
925 createmany -o $DIR1/$tdir-\\\$(hostname)-$i/f- \
926 -r $DIR2/$tdir-\\\$(hostname)-$i/f- $nfiles > \
928 jbdnew=$(print_jbd_stat)
929 jbd=$(( jbdnew - jbdold ))
930 echo "=== END createmany new: $jbdnew transaction : \
931 $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
932 avgjbd=$(( avgjbd + jbd ))
933 avgtime=$(( avgtime + elapsed ))
935 eval cos${COS}_jbd=$((avgjbd / 3))
936 eval cos${COS}_time=$((avgtime / 3))
939 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
940 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
941 [ "$cos0_jbd" != 0 ] &&
942 echo "COS=1 vs COS=0 jbd: $(((cos1_jbd/cos0_jbd - 1) * 100)) %"
943 [ "$cos0_time" != 0 ] &&
944 echo "COS=1 vs COS=0 time: $(((cos1_time/cos0_time - 1) * 100)) %"
946 restore_lustre_params < $param_file
950 run_test 33b "COS: cross create/delete, 2 clients, benchmark under remote dir"
952 # End commit on sharing tests
954 get_ost_lock_timeouts() {
955 local nodes=${1:-$(comma_list $(osts_nodes))}
957 local locks=$(do_nodes $nodes \
958 "lctl get_param -n ldlm.namespaces.filter-*.lock_timeouts" | calc_sum)
967 for OPER in notimeout timeout ; do
968 rm $DIR1/$tfile 2>/dev/null
969 lock_in=$(get_ost_lock_timeouts)
970 if [ $OPER == "timeout" ] ; then
971 for j in `seq $OSTCOUNT`; do
972 #define OBD_FAIL_PTLRPC_HPREQ_TIMEOUT 0x511
973 do_facet ost$j lctl set_param fail_loc=0x511
975 echo lock should expire
977 for j in `seq $OSTCOUNT`; do
978 #define OBD_FAIL_PTLRPC_HPREQ_NOTIMEOUT 0x512
979 do_facet ost$j lctl set_param fail_loc=0x512
981 echo lock should not expire
983 echo writing on client1
984 dd if=/dev/zero of=$DIR1/$tfile count=100 conv=notrunc > /dev/null 2>&1
986 echo reading on client2
987 dd of=/dev/null if=$DIR2/$tfile > /dev/null 2>&1
988 # wait for a lock timeout
990 lock_out=$(get_ost_lock_timeouts)
991 if [ $OPER == "timeout" ] ; then
992 if [ $lock_in == $lock_out ]; then
993 error "no lock timeout happened"
998 if [ $lock_in != $lock_out ]; then
999 error "lock timeout happened"
1006 run_test 34 "no lock timeout under IO"
1008 test_35() { # bug 17645
1011 for imp in /proc/fs/lustre/mdc/$FSNAME-MDT*-mdc-*; do
1012 g=$(awk '/generation/{print $2}' $imp/import)
1013 generation[count]=$g
1017 test_mkdir -p $MOUNT1/$tfile
1018 cancel_lru_locks mdc
1020 # Let's initiate -EINTR situation by setting fail_loc and take
1021 # write lock on same file from same client. This will not cause
1022 # bl_ast yet as lock is already in local cache.
1023 #define OBD_FAIL_LDLM_INTR_CP_AST 0x317
1024 do_facet client "lctl set_param fail_loc=0x80000317"
1025 local timeout=`do_facet $SINGLEMDS lctl get_param -n timeout`
1026 let timeout=timeout*3
1028 while test $nr -lt 10; do
1029 log "Race attempt $nr"
1030 local blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
1031 test "x$blk1" = "x" && blk1=0
1032 createmany -o $MOUNT2/$tfile/a 4000 &
1036 # Let's make conflict and bl_ast
1037 ls -la $MOUNT1/$tfile > /dev/null &
1040 log "Wait for $pid1 $pid2 for $timeout sec..."
1042 kill -9 $pid1 $pid2 > /dev/null 2>&1
1044 local blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
1045 test "x$blk2" = "x" && blk2=0
1046 test $blk2 -gt $blk1 && break
1047 rm -fr $MOUNT1/$tfile/*
1048 cancel_lru_locks mdc
1051 do_facet client "lctl set_param fail_loc=0x0"
1052 df -h $MOUNT1 $MOUNT2
1054 for imp in /proc/fs/lustre/mdc/$FSNAME-MDT*-mdc-*; do
1055 g=$(awk '/generation/{print $2}' $imp/import)
1056 if ! test "$g" -eq "${generation[count]}"; then
1057 error "Eviction happened on import $(basename $imp)"
1062 run_test 35 "-EINTR cp_ast vs. bl_ast race does not evict client"
1064 test_36() { #bug 16417
1069 test_mkdir -p $DIR1/$tdir
1070 $LFS setstripe -c -1 $DIR1/$tdir
1073 let SIZE_B=SIZE*1024*1024
1075 while [ $i -le 10 ]; do
1076 lctl mark "start test"
1077 local before=$($LFS df | awk '{ if ($1 ~/^filesystem/) \
1078 { print $5; exit} }')
1079 dd if=/dev/zero of=$DIR1/$tdir/$tfile bs=1M count=$SIZE ||
1080 error "dd $DIR1/$tdir/$tfile ${SIZE}MB failed"
1081 sync # sync data from client cache
1082 sync_all_data # sync data from server cache (delayed allocation)
1084 local after_dd=$($LFS df | awk '{ if ($1 ~/^filesystem/) \
1085 { print $5; exit} }')
1086 multiop_bg_pause $DIR2/$tdir/$tfile O_r${SIZE_B}c || return 3
1088 rm -f $DIR1/$tdir/$tfile
1089 kill -USR1 $read_pid
1091 wait_delete_completed
1092 local after=$($LFS df | awk '{ if ($1 ~/^filesystem/) \
1093 { print $5; exit} }')
1094 echo "*** cycle($i) *** before($before) after_dd($after_dd)" \
1096 # this free space! not used
1097 if [ $after_dd -ge $after ]; then
1098 error "space leaked"
1104 run_test 36 "handle ESTALE/open-unlink correctly"
1106 test_37() { # bug 18695
1107 test_mkdir -p $DIR1/$tdir
1108 multiop_bg_pause $DIR1/$tdir D_c || return 1
1110 # create large directory (32kB seems enough from e2fsck, ~= 1000 files)
1111 createmany -m $DIR2/$tdir/f 10000
1112 # set mtime/atime backward
1113 touch -t 198001010000 $DIR2/$tdir
1114 kill -USR1 $MULTIPID
1115 nr_files=`lfs find $DIR1/$tdir -type f | wc -l`
1116 [ $nr_files -eq 10000 ] || error "$nr_files != 10000 truncated directory?"
1119 run_test 37 "check i_size is not updated for directory on close (bug 18695) =============="
1121 # this should be set to past
1122 TEST_39_MTIME=`date -d "1 year ago" +%s`
1126 local client1=${CLIENT1:-`hostname`}
1127 local client2=${CLIENT2:-`hostname`}
1129 do_node $client1 "touch $DIR1/$tfile"
1131 do_node $client1 "touch -m -d @$TEST_39_MTIME $DIR1/$tfile"
1132 local mtime1=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1133 [ "$mtime1" = $TEST_39_MTIME ] || \
1134 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
1136 local d1=`do_node $client1 date +%s`
1137 do_node $client1 'echo hello >> '$DIR1/$tfile
1138 local d2=`do_node $client1 date +%s`
1140 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1141 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
1142 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
1144 do_node $client1 "mv $DIR1/$tfile $DIR1/$tfile-1"
1146 for (( i=0; i < 2; i++ )) ; do
1147 local mtime3=`do_node $client2 "stat -c %Y $DIR1/$tfile-1"`
1148 [ "$mtime2" = "$mtime3" ] || \
1149 error "mtime ($mtime2) changed (to $mtime3) on rename"
1151 cancel_lru_locks osc
1152 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1155 run_test 39a "test from 11063 =================================="
1158 local client1=${CLIENT1:-`hostname`}
1159 local client2=${CLIENT2:-`hostname`}
1163 local mtime1=`stat -c %Y $DIR1/$tfile`
1164 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1167 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
1169 for (( i=0; i < 2; i++ )) ; do
1170 local mtime3=`stat -c %Y $DIR1/$tfile`
1171 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1173 [ "$mtime3" = "$mtime4" ] || \
1174 error "different mtime on clients: $mtime3, $mtime4"
1175 [ "$mtime3" = $TEST_39_MTIME ] || \
1176 error "lost mtime: $mtime3, should be $TEST_39_MTIME"
1178 cancel_lru_locks osc
1179 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1182 run_test 39b "11063 problem 1 =================================="
1185 local client1=${CLIENT1:-`hostname`}
1186 local client2=${CLIENT2:-`hostname`}
1188 echo hello > $DIR1/$tfile
1190 local mtime1=`stat -c %Y $DIR1/$tfile`
1191 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1192 [ "$mtime1" = "$mtime2" ] || \
1193 error "create: different mtime on clients: $mtime1, $mtime2"
1196 $TRUNCATE $DIR1/$tfile 1
1198 for (( i=0; i < 2; i++ )) ; do
1199 local mtime3=`stat -c %Y $DIR1/$tfile`
1200 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1202 [ "$mtime3" = "$mtime4" ] || \
1203 error "different mtime on clients: $mtime3, $mtime4"
1204 [ "$mtime3" -gt $mtime2 ] || \
1205 error "truncate did not update mtime: $mtime2, $mtime3"
1207 cancel_lru_locks osc
1208 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1211 run_test 39c "check truncate mtime update ======================"
1213 # check that pid exists hence second operation wasn't blocked by first one
1214 # if it is so then there is no conflict, return 0
1215 # else second operation is conflicting with first one, return 1
1216 check_pdo_conflict() {
1219 sleep 1 # to ensure OP1 is finished on client if OP2 is blocked by OP1
1220 if [[ `ps --pid $pid | wc -l` == 1 ]]; then
1230 # test 40: check non-blocking operations
1232 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1233 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1234 mkdir $DIR1/$tfile &
1237 touch $DIR2/$tfile-2
1238 check_pdo_conflict $PID1 || error "create is blocked"
1239 mkdir $DIR2/$tfile-3
1240 check_pdo_conflict $PID1 || error "mkdir is blocked"
1241 link $DIR2/$tfile-2 $DIR2/$tfile-4
1242 check_pdo_conflict $PID1 || error "link is blocked"
1243 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1244 check_pdo_conflict $PID1 || error "rename is blocked"
1245 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1246 check_pdo_conflict $PID1 || error "getattr is blocked"
1247 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1248 rmdir $DIR2/$tfile-3
1249 check_pdo_conflict $PID1 || error "unlink is blocked"
1251 if [ $MDSCOUNT -ge 2 ]; then
1252 $LFS mkdir -i 1 $DIR2/$tfile-6
1253 check_pdo_conflict $PID1 || error "remote mkdir is blocked"
1256 # all operations above shouldn't wait the first one
1257 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1262 run_test 40a "pdirops: create vs others =============="
1265 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1266 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1267 touch $DIR1/$tfile &
1271 touch $DIR2/$tfile-2
1272 check_pdo_conflict $PID1 || error "create is blocked"
1273 mkdir $DIR2/$tfile-3
1274 check_pdo_conflict $PID1 || error "mkdir is blocked"
1275 link $DIR2/$tfile-2 $DIR2/$tfile-4
1276 check_pdo_conflict $PID1 || error "link is blocked"
1277 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1278 check_pdo_conflict $PID1 || error "rename is blocked"
1279 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1280 check_pdo_conflict $PID1 || error "getattr is blocked"
1281 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1282 rmdir $DIR2/$tfile-3
1283 check_pdo_conflict $PID1 || error "unlink is blocked"
1284 # all operations above shouldn't wait the first one
1286 if [ $MDSCOUNT -ge 2 ]; then
1287 $LFS mkdir -i 1 $DIR2/$tfile-6
1288 check_pdo_conflict $PID1 || error "remote mkdir is blocked"
1291 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1296 run_test 40b "pdirops: open|create and others =============="
1300 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1301 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1302 link $DIR1/$tfile $DIR1/$tfile-0 &
1306 touch $DIR2/$tfile-2
1307 check_pdo_conflict $PID1 || error "create is blocked"
1308 mkdir $DIR2/$tfile-3
1309 check_pdo_conflict $PID1 || error "mkdir is blocked"
1310 link $DIR2/$tfile-2 $DIR2/$tfile-4
1311 check_pdo_conflict $PID1 || error "link is blocked"
1312 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1313 check_pdo_conflict $PID1 || error "rename is blocked"
1314 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1315 check_pdo_conflict $PID1 || error "getattr is blocked"
1316 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1317 rmdir $DIR2/$tfile-3
1318 check_pdo_conflict $PID1 || error "unlink is blocked"
1320 if [ $MDSCOUNT -ge 2 ]; then
1321 $LFS mkdir -i 1 $DIR2/$tfile-6
1322 check_pdo_conflict $PID1 || error "remote mkdir is blocked"
1325 # all operations above shouldn't wait the first one
1326 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1331 run_test 40c "pdirops: link and others =============="
1335 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1336 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1341 touch $DIR2/$tfile-2
1342 check_pdo_conflict $PID1 || error "create is blocked"
1343 mkdir $DIR2/$tfile-3
1344 check_pdo_conflict $PID1 || error "mkdir is blocked"
1345 link $DIR2/$tfile-2 $DIR2/$tfile-4
1346 check_pdo_conflict $PID1 || error "link is blocked"
1347 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1348 check_pdo_conflict $PID1 || error "rename is blocked"
1349 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1350 check_pdo_conflict $PID1 || error "getattr is blocked"
1351 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1352 rmdir $DIR2/$tfile-3
1353 check_pdo_conflict $PID1 || error "unlink is blocked"
1355 if [ $MDSCOUNT -ge 2 ]; then
1356 $LFS mkdir -i 1 $DIR2/$tfile-6
1357 check_pdo_conflict $PID1 || error "remote mkdir is blocked"
1360 # all operations above shouldn't wait the first one
1361 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1365 run_test 40d "pdirops: unlink and others =============="
1369 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1370 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1371 mv $DIR1/$tfile $DIR1/$tfile-0 &
1375 touch $DIR2/$tfile-2
1376 check_pdo_conflict $PID1 || error "create is blocked"
1377 mkdir $DIR2/$tfile-3
1378 check_pdo_conflict $PID1 || error "mkdir is blocked"
1379 link $DIR2/$tfile-2 $DIR2/$tfile-4
1380 check_pdo_conflict $PID1 || error "link is blocked"
1381 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1382 check_pdo_conflict $PID1 || error "getattr is blocked"
1383 rm $DIR2/$tfile-4 $DIR2/$tfile-2
1384 rmdir $DIR2/$tfile-3
1385 check_pdo_conflict $PID1 || error "unlink is blocked"
1387 if [ $MDSCOUNT -ge 2 ]; then
1388 $LFS mkdir -i 1 $DIR2/$tfile-6
1389 check_pdo_conflict $PID1 || error "remote mkdir is blocked"
1392 # all operations above shouldn't wait the first one
1393 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1398 run_test 40e "pdirops: rename and others =============="
1400 # test 41: create blocking operations
1402 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1403 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1404 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1407 mkdir $DIR2/$tfile && error "mkdir must fail"
1408 check_pdo_conflict $PID1 && { wait $PID1; echo "mkdir isn't blocked"; }
1412 run_test 41a "pdirops: create vs mkdir =============="
1415 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1416 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1417 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1420 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1421 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1425 run_test 41b "pdirops: create vs create =============="
1428 touch $DIR1/$tfile-2
1429 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1430 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1431 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1434 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
1435 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1439 run_test 41c "pdirops: create vs link =============="
1442 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1443 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1444 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1447 rm $DIR2/$tfile || error "unlink must succeed"
1448 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1452 run_test 41d "pdirops: create vs unlink =============="
1455 touch $DIR1/$tfile-2
1456 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1457 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1458 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1461 mv $DIR2/$tfile-2 $DIR2/$tfile || error "rename must succeed"
1462 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1466 run_test 41e "pdirops: create and rename (tgt) =============="
1469 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1470 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1471 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1474 mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
1475 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1479 run_test 41f "pdirops: create and rename (src) =============="
1482 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1483 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1484 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1487 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
1488 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1492 run_test 41g "pdirops: create vs getattr =============="
1495 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1496 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1497 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1500 ls -lia $DIR2/ > /dev/null
1501 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1505 run_test 41h "pdirops: create vs readdir =============="
1507 # test 42: unlink and blocking operations
1509 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1510 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1511 mkdir $DIR1/$tfile &
1514 mkdir $DIR2/$tfile && error "mkdir must fail"
1515 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1519 run_test 42a "pdirops: mkdir vs mkdir =============="
1522 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1523 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1524 mkdir $DIR1/$tfile &
1527 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1528 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1532 run_test 42b "pdirops: mkdir vs create =============="
1535 touch $DIR1/$tfile-2
1536 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1537 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1538 mkdir $DIR1/$tfile &
1541 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
1542 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1546 run_test 42c "pdirops: mkdir vs link =============="
1549 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1550 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1551 mkdir $DIR1/$tfile &
1554 rmdir $DIR2/$tfile || error "unlink must succeed"
1555 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1559 run_test 42d "pdirops: mkdir vs unlink =============="
1562 touch $DIR1/$tfile-2
1563 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1564 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1565 mkdir $DIR1/$tfile &
1568 mv -T $DIR2/$tfile-2 $DIR2/$tfile && error "rename must fail"
1569 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1573 run_test 42e "pdirops: mkdir and rename (tgt) =============="
1576 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1577 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1578 mkdir $DIR1/$tfile &
1581 mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
1582 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1586 run_test 42f "pdirops: mkdir and rename (src) =============="
1589 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1590 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1591 mkdir $DIR1/$tfile &
1594 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
1595 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1599 run_test 42g "pdirops: mkdir vs getattr =============="
1602 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1603 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1604 mkdir $DIR1/$tfile &
1607 ls -lia $DIR2/ > /dev/null
1608 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1612 run_test 42h "pdirops: mkdir vs readdir =============="
1614 # test 43: unlink and blocking operations
1617 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1618 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1622 mkdir $DIR2/$tfile || error "mkdir must succeed"
1623 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1627 run_test 43a "pdirops: unlink vs mkdir =============="
1631 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1632 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1636 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c || error "create must succeed"
1637 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1641 run_test 43b "pdirops: unlink vs create =============="
1645 touch $DIR1/$tfile-2
1646 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1647 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1651 link $DIR2/$tfile-2 $DIR2/$tfile || error "link must succeed"
1652 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1656 run_test 43c "pdirops: unlink vs link =============="
1660 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1661 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1665 rm $DIR2/$tfile && error "unlink must fail"
1666 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1670 run_test 43d "pdirops: unlink vs unlink =============="
1674 touch $DIR1/$tfile-2
1675 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1676 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1680 mv -u $DIR2/$tfile-2 $DIR2/$tfile || error "rename must succeed"
1681 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1685 run_test 43e "pdirops: unlink and rename (tgt) =============="
1689 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1690 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1694 mv $DIR2/$tfile $DIR2/$tfile-2 && error "rename must fail"
1695 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1699 run_test 43f "pdirops: unlink and rename (src) =============="
1703 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1704 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1708 stat $DIR2/$tfile > /dev/null && error "stat must fail"
1709 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1713 run_test 43g "pdirops: unlink vs getattr =============="
1717 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1718 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1722 ls -lia $DIR2/ > /dev/null
1723 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1727 run_test 43h "pdirops: unlink vs readdir =============="
1730 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1732 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1733 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1737 $LFS mkdir -i 1 $DIR2/$tfile || error "remote mkdir must succeed"
1738 check_pdo_conflict $PID1 &&
1739 { wait $PID1; error "remote mkdir isn't blocked"; }
1743 run_test 43i "pdirops: unlink vs remote mkdir"
1745 # test 44: rename tgt and blocking operations
1747 touch $DIR1/$tfile-2
1748 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1749 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1750 mv $DIR1/$tfile-2 $DIR1/$tfile &
1753 mkdir $DIR2/$tfile && error "mkdir must fail"
1754 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1758 run_test 44a "pdirops: rename tgt vs mkdir =============="
1761 touch $DIR1/$tfile-2
1762 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1763 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1764 mv $DIR1/$tfile-2 $DIR1/$tfile &
1767 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1768 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1772 run_test 44b "pdirops: rename tgt vs create =============="
1775 touch $DIR1/$tfile-2
1776 touch $DIR1/$tfile-3
1777 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1778 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1779 mv $DIR1/$tfile-2 $DIR1/$tfile &
1782 link $DIR2/$tfile-3 $DIR2/$tfile && error "link must fail"
1783 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1787 run_test 44c "pdirops: rename tgt vs link =============="
1790 touch $DIR1/$tfile-2
1791 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1792 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1793 mv $DIR1/$tfile-2 $DIR1/$tfile &
1796 rm $DIR2/$tfile || error "unlink must succeed"
1797 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1801 run_test 44d "pdirops: rename tgt vs unlink =============="
1805 touch $DIR1/$tfile-2
1806 touch $DIR1/$tfile-3
1807 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1808 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1809 mv $DIR1/$tfile-2 $DIR1/$tfile &
1812 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
1813 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1817 run_test 44e "pdirops: rename tgt and rename (tgt) =============="
1820 touch $DIR1/$tfile-2
1821 touch $DIR1/$tfile-3
1822 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1823 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1824 mv $DIR1/$tfile-2 $DIR1/$tfile &
1827 mv $DIR2/$tfile $DIR2/$tfile-3 || error "rename must succeed"
1828 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1832 run_test 44f "pdirops: rename tgt and rename (src) =============="
1835 touch $DIR1/$tfile-2
1836 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1837 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1838 mv $DIR1/$tfile-2 $DIR1/$tfile &
1841 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
1842 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1846 run_test 44g "pdirops: rename tgt vs getattr =============="
1849 touch $DIR1/$tfile-2
1850 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1851 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1852 mv $DIR1/$tfile-2 $DIR1/$tfile &
1855 ls -lia $DIR2/ > /dev/null
1856 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1860 run_test 44h "pdirops: rename tgt vs readdir =============="
1862 # test 44: rename tgt and blocking operations
1864 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1865 touch $DIR1/$tfile-2
1866 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1867 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1868 mv $DIR1/$tfile-2 $DIR1/$tfile &
1871 $LFS mkdir -i 1 $DIR2/$tfile && error "remote mkdir must fail"
1872 check_pdo_conflict $PID1 && { wait $PID1;
1873 error "remote mkdir isn't blocked"; }
1877 run_test 44i "pdirops: rename tgt vs remote mkdir"
1879 # test 45: rename src and blocking operations
1882 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1883 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1884 mv $DIR1/$tfile $DIR1/$tfile-2 &
1887 mkdir $DIR2/$tfile || error "mkdir must succeed"
1888 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1892 run_test 45a "pdirops: rename src vs mkdir =============="
1896 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1897 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1898 mv $DIR1/$tfile $DIR1/$tfile-2 &
1901 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c || error "create must succeed"
1902 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1906 run_test 45b "pdirops: rename src vs create =============="
1910 touch $DIR1/$tfile-3
1911 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1912 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1913 mv $DIR1/$tfile $DIR1/$tfile-2 &
1916 link $DIR2/$tfile-3 $DIR2/$tfile || error "link must succeed"
1917 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1921 run_test 45c "pdirops: rename src vs link =============="
1925 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1926 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1927 mv $DIR1/$tfile $DIR1/$tfile-2 &
1930 rm $DIR2/$tfile && error "unlink must fail"
1931 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1935 run_test 45d "pdirops: rename src vs unlink =============="
1939 touch $DIR1/$tfile-3
1940 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1941 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1942 mv $DIR1/$tfile $DIR1/$tfile-2 &
1945 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
1946 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1950 run_test 45e "pdirops: rename src and rename (tgt) =============="
1954 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1955 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1956 mv $DIR1/$tfile $DIR1/$tfile-2 &
1959 mv $DIR2/$tfile $DIR2/$tfile-3 && error "rename must fail"
1960 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1964 run_test 45f "pdirops: rename src and rename (src) =============="
1968 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1969 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1970 mv $DIR1/$tfile $DIR1/$tfile-2 &
1973 stat $DIR2/$tfile > /dev/null && "stat must fail"
1974 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1978 run_test 45g "pdirops: rename src vs getattr =============="
1982 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1983 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1984 mv $DIR1/$tfile $DIR1/$tfile-2 &
1987 ls -lia $DIR2/ > /dev/null
1988 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1992 run_test 45h "pdirops: unlink vs readdir =============="
1995 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1997 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1998 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1999 mv $DIR1/$tfile $DIR1/$tfile-2 &
2002 $LFS mkdir -i 1 $DIR2/$tfile || error "create remote dir must succeed"
2003 check_pdo_conflict $PID1 && { wait $PID1;
2004 error "create remote dir isn't blocked"; }
2008 run_test 45i "pdirops: rename src vs remote mkdir"
2010 # test 46: link and blocking operations
2012 touch $DIR1/$tfile-2
2013 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2014 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2015 link $DIR1/$tfile-2 $DIR1/$tfile &
2018 mkdir $DIR2/$tfile && error "mkdir must fail"
2019 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2023 run_test 46a "pdirops: link vs mkdir =============="
2026 touch $DIR1/$tfile-2
2027 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2028 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2029 link $DIR1/$tfile-2 $DIR1/$tfile &
2032 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
2033 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2037 run_test 46b "pdirops: link vs create =============="
2040 touch $DIR1/$tfile-2
2041 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2042 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2043 link $DIR1/$tfile-2 $DIR1/$tfile &
2046 link $DIR2/$tfile $DIR2/$tfile && error "link must fail"
2047 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2051 run_test 46c "pdirops: link vs link =============="
2054 touch $DIR1/$tfile-2
2055 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2056 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2057 link $DIR1/$tfile-2 $DIR1/$tfile &
2060 rm $DIR2/$tfile || error "unlink must succeed"
2061 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2065 run_test 46d "pdirops: link vs unlink =============="
2068 touch $DIR1/$tfile-2
2069 touch $DIR1/$tfile-3
2070 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2071 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2072 link $DIR1/$tfile-2 $DIR1/$tfile &
2075 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
2076 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2080 run_test 46e "pdirops: link and rename (tgt) =============="
2083 touch $DIR1/$tfile-2
2084 touch $DIR1/$tfile-3
2085 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2086 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2087 link $DIR1/$tfile-2 $DIR1/$tfile &
2090 mv $DIR2/$tfile $DIR2/$tfile-3 || error "rename must succeed"
2091 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2095 run_test 46f "pdirops: link and rename (src) =============="
2098 touch $DIR1/$tfile-2
2099 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2100 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2101 link $DIR1/$tfile-2 $DIR1/$tfile &
2104 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
2105 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2109 run_test 46g "pdirops: link vs getattr =============="
2112 touch $DIR1/$tfile-2
2113 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2114 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2115 link $DIR1/$tfile-2 $DIR1/$tfile &
2118 ls -lia $DIR2/ > /dev/null
2119 check_pdo_conflict $PID1 && { wait $PID1;
2120 error "readdir isn't blocked"; }
2124 run_test 46h "pdirops: link vs readdir =============="
2127 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2128 touch $DIR1/$tfile-2
2129 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2130 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2131 link $DIR1/$tfile-2 $DIR1/$tfile &
2134 $LFS mkdir -i 1 $DIR2/$tfile && error "remote mkdir must fail"
2135 check_pdo_conflict $PID1 && { wait $PID1;
2136 error "remote mkdir isn't blocked"; }
2140 run_test 46i "pdirops: link vs remote mkdir"
2142 # test 47: remote mkdir and blocking operations
2144 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2145 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2146 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2147 $LFS mkdir -i 1 $DIR1/$tfile &
2150 mkdir $DIR2/$tfile && error "mkdir must fail"
2151 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2155 run_test 47a "pdirops: remote mkdir vs mkdir"
2158 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2159 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2160 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2161 $LFS mkdir -i 1 $DIR1/$tfile &
2164 multiop $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
2165 check_pdo_conflict $PID1 && { wait $PID1;
2166 error "create isn't blocked"; }
2170 run_test 47b "pdirops: remote mkdir vs create"
2173 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2174 touch $DIR1/$tfile-2
2175 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2176 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2177 $LFS mkdir -i 1 $DIR1/$tfile &
2180 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
2181 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2185 run_test 47c "pdirops: remote mkdir vs link"
2188 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2189 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2190 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2191 $LFS mkdir -i 1 $DIR1/$tfile &
2194 rmdir $DIR2/$tfile || error "unlink must succeed"
2195 check_pdo_conflict $PID1 && { wait $PID1;
2196 error "unlink isn't blocked"; }
2200 run_test 47d "pdirops: remote mkdir vs unlink"
2203 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2204 touch $DIR1/$tfile-2
2205 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2206 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2207 $LFS mkdir -i 1 $DIR1/$tfile &
2210 mv -T $DIR2/$tfile-2 $DIR2/$tfile && error "rename must fail"
2211 check_pdo_conflict $PID1 && { wait $PID1;
2212 error "rename isn't blocked"; }
2216 run_test 47e "pdirops: remote mkdir and rename (tgt)"
2219 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2220 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2221 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2222 $LFS mkdir -i 1 $DIR1/$tfile &
2225 mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
2226 check_pdo_conflict $PID1 && { wait $PID1;
2227 error "rename isn't blocked"; }
2231 run_test 47f "pdirops: remote mkdir and rename (src)"
2234 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2235 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2236 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2237 $LFS mkdir -i 1 $DIR1/$tfile &
2240 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
2241 check_pdo_conflict $PID1 && { wait $PID1;
2242 error "getattr isn't blocked"; }
2246 run_test 47g "pdirops: remote mkdir vs getattr"
2250 dd if=/dev/zero of=$DIR1/$tfile bs=1K count=10
2251 #define OBD_FAIL_OSC_CP_ENQ_RACE 0x410
2252 do_facet client "lctl set_param fail_loc=0x410"
2253 $TRUNCATE $DIR2/$tfile $trunc_size
2254 do_facet client "lctl set_param fail_loc=0x0"
2256 size=`stat -c %s $DIR2/$tfile`
2257 [ $size -eq $trunc_size ] || error "wrong size"
2259 run_test 50 "osc lvb attrs: enqueue vs. CP AST =============="
2263 local origfile=/etc/hosts
2265 filesize=`stat -c %s $origfile`
2267 # create an empty file
2268 $MCREATE $DIR1/$tfile
2269 # cache layout lock on both mount point
2270 stat $DIR1/$tfile > /dev/null
2271 stat $DIR2/$tfile > /dev/null
2273 # open and sleep 2 seconds then read
2274 $MULTIOP $DIR2/$tfile o_2r${filesize}c &
2278 # create the layout of testing file
2279 dd if=$origfile of=$DIR1/$tfile conv=notrunc > /dev/null
2281 # MULTIOP proc should be able to read enough bytes and exit
2283 kill -0 $pid && error "multiop is still there"
2284 cmp $origfile $DIR2/$tfile || error "$MCREATE and $DIR2/$tfile differs"
2288 run_test 51a "layout lock: refresh layout should work"
2291 local tmpfile=`mktemp`
2293 # create an empty file
2294 $MCREATE $DIR1/$tfile
2296 # delay glimpse so that layout has changed when glimpse finish
2297 #define OBD_FAIL_GLIMPSE_DELAY 0x1404
2298 $LCTL set_param fail_loc=0x1404
2299 stat -c %s $DIR2/$tfile |tee $tmpfile &
2303 # create layout of testing file
2304 dd if=/dev/zero of=$DIR1/$tfile bs=1k count=1 conv=notrunc > /dev/null
2307 local fsize=`cat $tmpfile`
2309 [ x$fsize = x1024 ] || error "file size is $fsize, should be 1024"
2311 rm -f $DIR1/$tfile $tmpfile
2313 run_test 51b "layout lock: glimpse should be able to restart if layout changed"
2316 # create an empty file
2317 $MCREATE $DIR1/$tfile
2319 #define OBD_FAIL_MDS_LL_BLOCK 0x172
2320 $LCTL set_param fail_loc=0x172
2322 # change the layout of testing file
2323 echo "Setting layout ..."
2324 $LFS setstripe -c $OSTCOUNT $DIR1/$tfile &
2328 # get layout of this file should wait until dd is finished
2329 local stripecnt=`$LFS getstripe -c $DIR2/$tfile`
2330 [ $stripecnt -eq $OSTCOUNT ] || error "layout wrong"
2334 run_test 51c "layout lock: IT_LAYOUT blocked and correct layout can be returned"
2337 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.0) ]] ||
2338 { skip "Need MDS version at least 2.3.0"; return; }
2340 test_mkdir -p $DIR1/$tdir
2341 file1=$DIR1/$tdir/file
2342 file2=$DIR2/$tdir/file
2344 echo orig > $file2 || error "Could not create $file2"
2345 version=$($LFS data_version $file1)
2348 echo append >> $file2 || error "Could not append to $file2"
2349 version2=$($LFS data_version $file1)
2350 [ "$version" != "$version2" ] ||
2351 error "append did not change data version: $version"
2354 echo overwrite > $file2 || error "Could not overwrite $file2"
2355 version3=$($LFS data_version $file1)
2356 [ "$version2" != "$version3" ] ||
2357 error "overwrite did not change data version: $version2"
2359 # Truncate before EOF
2360 $TRUNCATE $file2 3 || error "Could not truncate $file2"
2361 version4=$($LFS data_version $file1)
2362 [ "$version3" != "$version4" ] ||
2363 error "truncate did not change data version: $version3"
2365 # Truncate after EOF
2366 $TRUNCATE $file2 123456 || error "Could not truncate $file2"
2367 version5=$($LFS data_version $file1)
2368 [ "$version4" != "$version5" ] ||
2369 error "truncate did not change data version: $version4"
2371 # Chmod do not change version
2372 chmod 400 $file2 || error "Could not chmod 400 $file2"
2373 version6=$($LFS data_version $file1)
2374 [ "$version5" == "$version6" ] ||
2375 error "chmod should not change data version: $version5 != $version6"
2377 # Chown do not change version
2378 chown $RUNAS_ID $file2 || error "Could not chown $RUNAS_ID $file2"
2379 version7=$($LFS data_version $file1)
2380 [ "$version5" == "$version7" ] ||
2381 error "chown should not change data version: $version5 != $version7"
2383 run_test 60 "Verify data_version behaviour"
2386 local test_dir=$tdir/test_dir
2388 mkdir -p $DIR1/$tdir
2389 if [ $MDSCOUNT -ge 2 ]; then
2391 $LFS mkdir -i $MDTIDX $DIR1/$test_dir ||
2392 error "Create remote directory failed"
2394 mkdir -p $DIR1/$test_dir
2396 cd $DIR2/$test_dir || error "cd directory failed"
2397 rm -rf $DIR1/$test_dir || error "unlink directory failed"
2399 cd $DIR2/$tdir || error "exit directory"
2401 run_test 70 "cd directory && rm directory"
2403 log "cleanup: ======================================================"
2405 [ "$(mount | grep $MOUNT2)" ] && umount $MOUNT2
2408 check_and_cleanup_lustre