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 # It will be ported soon.
18 PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH
21 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
22 MCREATE=${MCREATE:-mcreate}
23 OPENFILE=${OPENFILE:-openfile}
24 OPENUNLINK=${OPENUNLINK:-openunlink}
25 export MULTIOP=${MULTIOP:-multiop}
26 export TMP=${TMP:-/tmp}
27 MOUNT_2=${MOUNT_2:-"yes"}
28 CHECK_GRANT=${CHECK_GRANT:-"yes"}
29 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
33 export NAME=${NAME:-local}
35 LUSTRE=${LUSTRE:-`dirname $0`/..}
36 . $LUSTRE/tests/test-framework.sh
40 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
43 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
44 # bug number for skipped test: LU-2840 LU-2189 LU-2776
45 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 21 36 51a"
47 [ "$SLOW" = "no" ] && EXCEPT_SLOW="33a"
54 check_and_setup_lustre
56 LOVNAME=$($LCTL get_param -n llite.*.lov.common_name | tail -n 1)
57 OSTCOUNT=$($LCTL get_param -n lov.$LOVNAME.numobd)
60 rm -rf $DIR1/[df][0-9]* $DIR1/lnk $DIR/[df].${TESTSUITE}*
62 SAMPLE_FILE=$TMP/$(basename $0 .sh).junk
63 dd if=/dev/urandom of=$SAMPLE_FILE bs=1M count=1
65 # $RUNAS_ID may get set incorrectly somewhere else
66 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
68 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
77 [ -f $DIR2/f1 ] || error
79 run_test 1a "check create on 2 mtpt's =========================="
83 $CHECKSTAT -t file -p 0777 $DIR1/f1 || error
86 run_test 1b "check attribute updates on 2 mtpt's ==============="
89 $CHECKSTAT -t file -p 0666 $DIR1/f1 || error
91 run_test 1c "check after remount attribute updates on 2 mtpt's ="
95 $CHECKSTAT -a $DIR1/f1 || error
97 run_test 1d "unlink on one mountpoint removes file on other ===="
103 $CHECKSTAT -t file -p 0777 $DIR1/f2a || error
105 run_test 2a "check cached attribute updates on 2 mtpt's ========"
111 $CHECKSTAT -t file -p 0777 $DIR2/f2b || error
113 run_test 2b "check cached attribute updates on 2 mtpt's ========"
115 # NEED TO SAVE ROOT DIR MODE
118 $CHECKSTAT -t dir -p 0777 $DIR2 || error
120 run_test 2c "check cached attribute updates on 2 mtpt's root ==="
124 $CHECKSTAT -t dir -p 0755 $DIR2 || error
126 run_test 2d "check cached attribute updates on 2 mtpt's root ==="
133 $RUNAS dd if=/dev/zero of=$DIR2/$tfile count=1 || error
135 run_test 2e "check chmod on root is propagated to others"
138 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
140 local remote_dir=$tdir/remote_dir
143 $LFS mkdir -i $MDTIDX $DIR1/$remote_dir ||
144 error "Create remote directory failed"
146 touch $DIR1/$remote_dir/$tfile ||
147 error "Create file under remote directory failed"
148 chmod 777 $DIR1/$remote_dir/$tfile ||
149 error "Chmod file under remote directory failed"
151 $CHECKSTAT -t file -p 0777 $DIR2/$remote_dir/$tfile ||
152 error "Check attr of file under remote directory failed"
154 chown $RUNAS_ID:$RUNAS_GID $DIR1/$remote_dir/$tfile ||
155 error "Chown file under remote directory failed"
157 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR2/$remote_dir/$tfile ||
158 error "Check owner of file under remote directory failed"
160 cd $DIR2/$remote_dir || error "enter remote dir"
161 rm -rf $DIR1/$remote_dir/$tfile ||
162 error "Unlink remote directory failed"
164 $CHECKSTAT -t file $DIR2/$remote_dir/$tfile &&
165 error "unlink file still exists!"
167 cd $DIR2/$tdir || error "exit remote dir"
168 rm -rf $DIR1/$tdir || error "unlink directory failed"
170 run_test 2f "check attr/owner updates on DNE with 2 mtpt's"
173 local target="this/is/good"
174 ln -s $target $DIR1/$tfile || error "ln -s $target $DIR1/$tfile failed"
175 [ "$(ls -l $DIR2/$tfile | sed -e 's/.* -> //')" = "$target" ] ||
176 error "link $DIR2/$tfile not as expected"
178 run_test 3 "symlink on one mtpt, readlink on another ==========="
181 multifstat $DIR1/f4 $DIR2/f4
183 run_test 4 "fstat validation on multiple mount points =========="
187 $TRUNCATE $DIR2/f5 100
188 $CHECKSTAT -t file -s 100 $DIR1/f5 || error
191 run_test 5 "create a file on one mount, truncate it on the other"
194 openunlink $DIR1/$tfile $DIR2/$tfile || \
195 error "openunlink $DIR1/$tfile $DIR2/$tfile"
197 run_test 6 "remove of open file on other node =================="
201 opendirunlink $DIR1/$dir $DIR2/$dir || \
202 error "opendirunlink $DIR1/$dir $DIR2/$dir"
204 run_test 7 "remove of open directory on other node ============="
207 opendevunlink $DIR1/$tfile $DIR2/$tfile || \
208 error "opendevunlink $DIR1/$tfile $DIR2/$tfile"
210 run_test 8 "remove of open special file on other node =========="
216 for C in a b c d e f g h i j k l; do
217 dir=`eval echo \\$DIR$MTPT`
218 echo -n $C >> $dir/f9
219 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
221 [ "`cat $DIR1/f9`" = "abcdefghijkl" ] || \
222 error "`od -a $DIR1/f9` != abcdefghijkl"
224 run_test 9 "append of file with sub-page size on multiple mounts"
231 for C in a b c d e f g h i j k l; do
232 dir=`eval echo \\$DIR$MTPT`
233 echo -n $C | dd of=$dir/f10 bs=1 seek=$OFFSET count=1
234 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
235 OFFSET=`expr $OFFSET + 1`
237 [ "`cat $DIR1/f10`" = "abcdefghijkl" ] || \
238 error "`od -a $DIR1/f10` != abcdefghijkl"
240 run_test 10a "write of file with sub-page size on multiple mounts "
244 yes "R" | head -c 4000 >$TMP/f10b-seed
245 dd if=$TMP/f10b-seed of=$DIR1/f10b bs=3k count=1 || error "dd $DIR1"
247 $TRUNCATE $DIR1/f10b 4096 || error "truncate 4096"
249 dd if=$DIR2/f10b of=$TMP/f10b-lustre bs=4k count=1 || error "dd $DIR2"
251 # create a test file locally to compare
252 dd if=$TMP/f10b-seed of=$TMP/f10b bs=3k count=1 || error "dd random"
253 $TRUNCATE $TMP/f10b 4096 || error "truncate 4096"
254 cmp $TMP/f10b $TMP/f10b-lustre || error "file miscompare"
255 rm $TMP/f10b $TMP/f10b-lustre $TMP/f10b-seed
257 run_test 10b "write of file with sub-page size on multiple mounts "
261 multiop_bg_pause $DIR1/d11/f O_c || return 1
263 cp -p /bin/ls $DIR1/d11/f
267 wait $MULTIPID || error
268 [ $RC -eq 0 ] && error || true
270 run_test 11 "execution of file opened for write should return error ===="
273 DIR=$DIR DIR2=$DIR2 sh lockorder.sh
275 run_test 12 "test lock ordering (link, stat, unlink) ==========="
277 test_13() { # bug 2451 - directory coherency
278 test_mkdir $DIR1/d13 || error
279 cd $DIR1/d13 || error
281 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
283 rm -f $DIR2/d13/f13 || error
284 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (1)" || true
285 # need to run it twice
286 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
288 rm -f $DIR2/d13/f13 || error
289 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (2)" || true
291 run_test 13 "test directory page revocation ===================="
294 test_mkdir -p $DIR1/$tdir
295 cp -p /bin/ls $DIR1/$tdir/$tfile
296 multiop_bg_pause $DIR1/$tdir/$tfile Ow_c || return 1
299 $DIR2/$tdir/$tfile && error || true
301 wait $MULTIPID || return 2
303 run_test 14 "execution of file open for write returns -ETXTBSY ="
306 test_mkdir -p $DIR1/d14
307 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
308 MULTIOP_PROG=$DIR1/d14/multiop multiop_bg_pause $TMP/test14.junk O_c || return 1
310 $MULTIOP $DIR2/d14/multiop Oc && error "expected error, got success"
311 kill -USR1 $MULTIOP_PID || return 2
312 wait $MULTIOP_PID || return 3
313 rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop"
315 run_test 14a "open(RDWR) of executing file returns -ETXTBSY ===="
317 test_14b() { # bug 3192, 7040
318 test_mkdir -p $DIR1/d14
319 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
320 MULTIOP_PROG=$DIR1/d14/multiop multiop_bg_pause $TMP/test14.junk O_c || return 1
322 $TRUNCATE $DIR2/d14/multiop 0 && kill -9 $MULTIOP_PID && \
323 error "expected truncate error, got success"
324 kill -USR1 $MULTIOP_PID || return 2
325 wait $MULTIOP_PID || return 3
326 cmp `which multiop` $DIR1/d14/multiop || error "binary changed"
327 rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop"
329 run_test 14b "truncate of executing file returns -ETXTBSY ======"
331 test_14c() { # bug 3430, 7040
332 test_mkdir -p $DIR1/d14
333 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
334 MULTIOP_PROG=$DIR1/d14/multiop multiop_bg_pause $TMP/test14.junk O_c || return 1
336 cp /etc/hosts $DIR2/d14/multiop && error "expected error, got success"
337 kill -USR1 $MULTIOP_PID || return 2
338 wait $MULTIOP_PID || return 3
339 cmp `which multiop` $DIR1/d14/multiop || error "binary changed"
340 rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop"
342 run_test 14c "open(O_TRUNC) of executing file return -ETXTBSY =="
344 test_14d() { # bug 10921
345 test_mkdir -p $DIR1/d14
346 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
347 MULTIOP_PROG=$DIR1/d14/multiop multiop_bg_pause $TMP/test14.junk O_c || return 1
350 chmod 600 $DIR1/d14/multiop || error "chmod failed"
351 kill -USR1 $MULTIOP_PID || return 2
352 wait $MULTIOP_PID || return 3
353 cmp `which multiop` $DIR1/d14/multiop || error "binary changed"
354 rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop"
356 run_test 14d "chmod of executing file is still possible ========"
358 test_15() { # bug 974 - ENOSPC
360 sh oos2.sh $MOUNT1 $MOUNT2
361 wait_delete_completed
362 grant_error=`dmesg | grep "> available"`
363 [ -z "$grant_error" ] || error "$grant_error"
365 run_test 15 "test out-of-space with multiple writers ==========="
368 # The FSXNUM reduction for ZFS is needed until ORI-487 is fixed.
369 # We don't want to skip it entirely, but ZFS is VERY slow and cannot
370 # pass a 2500 operation dual-mount run within the time limit.
371 if [ "$(facet_fstype ost1)" = "zfs" ]; then
372 FSXNUM=$((COUNT / 5))
374 elif [ "$SLOW" = "yes" ]; then
375 FSXNUM=$((COUNT * 5))
383 local file1=$DIR1/$tfile
384 local file2=$DIR2/$tfile
386 # to allocate grant because it may run out due to test_15.
387 lfs setstripe -c -1 $file1
388 dd if=/dev/zero of=$file1 bs=$STRIPE_BYTES count=$OSTCOUNT oflag=sync
389 dd if=/dev/zero of=$file2 bs=$STRIPE_BYTES count=$OSTCOUNT oflag=sync
392 lfs setstripe -c -1 $file1 # b=10919
393 fsx -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -S 0 $file1 $file2
395 run_test 16 "$FSXNUM iterations of dual-mount fsx"
397 test_17() { # bug 3513, 3667
398 remote_ost_nodsh && skip "remote OST with nodsh" && return
400 lfs setstripe $DIR1/$tfile -i 0 -c 1
401 cp $SAMPLE_FILE $DIR1/$tfile
402 cancel_lru_locks osc > /dev/null
403 #define OBD_FAIL_ONCE|OBD_FAIL_LDLM_CREATE_RESOURCE 0x30a
404 do_facet ost1 lctl set_param fail_loc=0x8000030a
405 ls -ls $DIR1/$tfile | awk '{ print $1,$6 }' > $DIR1/$tfile-1 & \
406 ls -ls $DIR2/$tfile | awk '{ print $1,$6 }' > $DIR2/$tfile-2
408 diff -u $DIR1/$tfile-1 $DIR2/$tfile-2 || error "files are different"
410 run_test 17 "resource creation/LVB creation race ==============="
413 # turn e.g. ALWAYS_EXCEPT="18c" into "-e 3"
416 for idx in {a..z}; do
417 local ptr=EXCEPT_ALWAYS_18$idx
418 [ x${!ptr} = xtrue ] || continue
420 excepts="$excepts -e $(($(printf %d \'$idx)-96))"
423 $LUSTRE/tests/mmap_sanity -d $MOUNT1 -m $MOUNT2 $excepts
426 run_test 18 "mmap sanity check ================================="
428 test_19() { # bug3811
429 local node=$(facet_active_host ost1)
431 # check whether obdfilter is cache capable at all
432 if ! get_osd_param $node '' read_cache_enable >/dev/null; then
433 echo "not cache-capable obdfilter"
437 local MAX=$(get_osd_param $node '' readcache_max_filesize | \
439 set_osd_param $node '' readcache_max_filesize 4096
440 dd if=/dev/urandom of=$TMP/$tfile bs=512k count=32
441 local SUM=$(cksum $TMP/$tfile | cut -d" " -f 1,2)
442 cp $TMP/$tfile $DIR1/$tfile
443 for i in `seq 1 20`; do
444 [ $((i % 5)) -eq 0 ] && log "$testname loop $i"
445 cancel_lru_locks osc > /dev/null
446 cksum $DIR1/$tfile | cut -d" " -f 1,2 > $TMP/sum1 & \
447 cksum $DIR2/$tfile | cut -d" " -f 1,2 > $TMP/sum2
449 [ "$(cat $TMP/sum1)" = "$SUM" ] || \
450 error "$DIR1/$tfile $(cat $TMP/sum1) != $SUM"
451 [ "$(cat $TMP/sum2)" = "$SUM" ] || \
452 error "$DIR2/$tfile $(cat $TMP/sum2) != $SUM"
454 set_osd_param $node '' readcache_max_filesize $MAX
457 run_test 19 "test concurrent uncached read races ==============="
462 CNT=$((`lctl get_param -n llite.*.dump_page_cache | wc -l`))
463 $MULTIOP $DIR1/f20 Ow8190c
464 $MULTIOP $DIR2/f20 Oz8194w8190c
465 $MULTIOP $DIR1/f20 Oz0r8190c
467 CNTD=$((`lctl get_param -n llite.*.dump_page_cache | wc -l` - $CNT))
469 error $CNTD" page left in cache after lock cancel" || true
471 run_test 20 "test extra readahead page left in cache ===="
478 test_21() { # Bug 5907
479 test_mkdir $DIR1/$tdir
480 mount /etc $DIR1/$tdir --bind || error "mount failed" # Poor man's mount.
482 rmdir -v $DIR1/$tdir && error "Removed mounted directory"
483 rmdir -v $DIR2/$tdir && echo "Removed mounted directory from another mountpoint, needs to be fixed"
484 test -d $DIR1/$tdir || error "Mounted directory disappeared"
486 test -d $DIR2/$tdir || test -d $DIR1/$tdir && error "Removed dir still visible after umount"
489 run_test 21 " Try to remove mountpoint on another dir ===="
491 test_23() { # Bug 5972
492 echo "others should see updated atime while another read" > $DIR1/f23
494 # clear the lock(mode: LCK_PW) gotten from creating operation
498 #MAX_ATIME_DIFF 60, we update atime only if older than 60 seconds
501 multiop_bg_pause $DIR1/f23 or20_c || return 1
502 # with SOM and opencache enabled, we need to close a file and cancel
503 # open lock to get atime propogated to MDS
507 time2=`stat -c "%X" $DIR2/f23`
509 if (( $time2 <= $time1 )); then
510 error "atime doesn't update among nodes"
513 rm -f $DIR1/f23 || error "rm -f $DIR1/f23 failed"
516 run_test 23 " others should see updated atime while another read===="
520 lfs df || error "lfs df failed"
521 lfs df -ih || error "lfs df -ih failed"
522 lfs df -h $DIR1 || error "lfs df -h $DIR1 failed"
523 lfs df -i $DIR2 || error "lfs df -i $DIR2 failed"
524 lfs df $DIR1/$tfile || error "lfs df $DIR1/$tfile failed"
525 lfs df -ih $DIR2/$tfile || error "lfs df -ih $DIR2/$tfile failed"
527 OSC=`lctl dl | awk '/-osc-|OSC.*MNT/ {print $4}' | head -n 1`
528 # OSC=`lctl dl | awk '/-osc-/ {print $4}' | head -n 1`
529 lctl --device %$OSC deactivate
530 lfs df -i || error "lfs df -i with deactivated OSC failed"
531 lctl --device %$OSC activate
532 lfs df || error "lfs df with reactivated OSC failed"
534 run_test 24a "lfs df [-ih] [path] test ========================="
538 fsnum=$(lfs_df | grep -c "summary")
539 [ $fsnum -eq 2 ] || error "lfs df shows $fsnum != 2 filesystems."
541 run_test 24b "lfs df should show both filesystems ==============="
544 local acl=$(lctl get_param -n mdc.*MDT0000-mdc-*.connect_flags |
546 [ "$acl" -lt 1 ] && skip "must have acl, skipping" && return
549 touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
550 chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
552 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
553 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
554 error "setfacl $DIR2/$tdir #1"
555 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
556 setfacl -m u:$RUNAS_ID:r-x -m g:$RUNAS_GID:r-x $DIR1/$tdir ||
557 error "setfacl $DIR2/$tdir #2"
558 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
559 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
560 error "setfacl $DIR2/$tdir #3"
561 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
562 setfacl -x u:$RUNAS_ID: -x g:$RUNAS_GID: $DIR1/$tdir ||
563 error "setfacl $DIR2/$tdir #4"
564 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
568 run_test 25a "change ACL on one mountpoint be seen on another ==="
571 local acl=$(lctl get_param -n mdc.*MDT0000-mdc-*.connect_flags |
573 [ "$acl" -lt 1 ] && skip "must have acl, skipping" && return
575 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
578 $LFS mkdir -i 1 $DIR1/$tdir
579 touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
580 chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
582 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
583 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
584 error "setfacl $DIR2/$tdir #1"
585 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
586 setfacl -m u:$RUNAS_ID:r-x -m g:$RUNAS_GID:r-x $DIR1/$tdir ||
587 error "setfacl $DIR2/$tdir #2"
588 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
589 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
590 error "setfacl $DIR2/$tdir #3"
591 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
592 setfacl -x u:$RUNAS_ID: -x g:$RUNAS_GID: $DIR1/$tdir ||
593 error "setfacl $DIR2/$tdir #4"
594 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
598 run_test 25b "change ACL under remote dir on one mountpoint be seen on another"
601 utime $DIR1/f26a -s $DIR2/f26a || error
603 run_test 26a "allow mtime to get older"
608 echo "aaa" >> $DIR1/$tfile
610 chmod a+x $DIR2/$tfile
611 mt1=`stat -c %Y $DIR1/$tfile`
612 mt2=`stat -c %Y $DIR2/$tfile`
614 if [ x"$mt1" != x"$mt2" ]; then
615 error "not equal mtime, client1: "$mt1", client2: "$mt2"."
618 run_test 26b "sync mtime between ost and mds"
623 dd if=/dev/zero of=$DIR2/$tfile bs=$((4096+4))k conv=notrunc count=4 seek=3 &
628 dd if=/dev/zero of=$DIR1/$tfile bs=$((16384-1024))k conv=notrunc count=1 seek=4 &
633 dd if=/dev/zero of=$DIR1/$tfile bs=8k conv=notrunc count=1 seek=0
635 lctl set_param -n ldlm.dump_namespaces ""
636 wait $DD1_PID $DD2_PID
637 [ $? -ne 0 ] && lctl dk $TMP/debug || true
639 run_test 27 "align non-overlapping extent locks from request ==="
641 test_28() { # bug 9977
642 ECHO_UUID="ECHO_osc1_UUID"
643 tOST=`$LCTL dl | | awk '/-osc-|OSC.*MNT/ { print $4 }' | head -1`
645 $LFS setstripe $DIR1/$tfile -S 1048576 -i 0 -c 2
646 tOBJID=`$LFS getstripe $DIR1/$tfile | awk '$1 == 1 {print $2}'`
647 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2
651 attach echo_client ECHO_osc1 $ECHO_UUID
655 tECHOID=`$LCTL dl | grep $ECHO_UUID | awk '{ print $1 }'`
656 $LCTL --device $tECHOID destroy "${tOBJID}:0"
664 # reading of 1st stripe should pass
665 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error
666 # reading of 2nd stripe should fail (this stripe was destroyed)
667 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 && error
669 # now, recreating test file
670 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2 || error
671 # reading of 1st stripe should pass
672 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error
673 # reading of 2nd stripe should pass
674 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 || error
676 run_test 28 "read/write/truncate file with lost stripes"
678 test_29() { # bug 10999
680 #define OBD_FAIL_LDLM_GLIMPSE 0x30f
681 lctl set_param fail_loc=0x8000030f
684 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1
687 #bug 11549 - permanently turn test off in b1_5
688 run_test 29 "lock put race between glimpse and enqueue ========="
690 test_30() { #bug #11110, LU-2523
691 test_mkdir -p $DIR1/$tdir
692 cp -f /bin/bash $DIR1/$tdir/bash
693 /bin/sh -c 'sleep 1; rm -f $DIR2/$tdir/bash;
694 cp /bin/bash $DIR2/$tdir' &
695 $DIR1/$tdir/bash -c 'sleep 2;
696 openfile -f O_RDONLY /proc/$$/exe >& /dev/null; echo $?'
701 run_test 30 "recreate file race"
704 test_mkdir -p $DIR1/$tdir || error "Creating dir $DIR1/$tdir"
705 local writes=$(LANG=C dd if=/dev/zero of=$DIR/$tdir/$tfile \
706 count=1 2>&1 | awk 'BEGIN { FS="+" } /out/ {print $1}')
707 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
708 lctl set_param fail_loc=0x314
709 local reads=$(LANG=C dd if=$DIR2/$tdir/$tfile of=/dev/null 2>&1 |
710 awk 'BEGIN { FS="+" } /in/ {print $1}')
711 [ $reads -eq $writes ] || error "read" $reads "blocks, must be" $writes
713 run_test 31a "voluntary cancel / blocking ast race=============="
716 remote_ost || { skip "local OST" && return 0; }
717 remote_ost_nodsh && skip "remote OST w/o dsh" && return 0
719 # make sure there is no local locks due to destroy
720 wait_mds_ost_sync || error "wait_mds_ost_sync()"
721 wait_delete_completed || error "wait_delete_completed()"
723 test_mkdir -p $DIR1/$tdir || error "Creating dir $DIR1/$tdir"
724 lfs setstripe $DIR/$tdir/$tfile -i 0 -c 1
725 cp /etc/hosts $DIR/$tdir/$tfile
726 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
727 lctl set_param fail_loc=0x314
728 #define OBD_FAIL_LDLM_OST_FAIL_RACE 0x316
729 do_facet ost1 lctl set_param fail_loc=0x316
731 cat $DIR2/$tdir/$tfile > /dev/null 2>&1
732 lctl set_param fail_loc=0
733 do_facet ost1 lctl set_param fail_loc=0
734 # cleanup: reconnect the client back
737 run_test 31b "voluntary OST cancel / blocking ast race=============="
739 # enable/disable lockless truncate feature, depending on the arg 0/1
740 enable_lockless_truncate() {
741 lctl set_param -n osc.*.lockless_truncate $1
744 test_32a() { # bug 11270
745 local p="$TMP/sanityN-$TESTNAME.parameters"
746 save_lustre_params $HOSTNAME osc.*.lockless_truncate > $p
748 enable_lockless_truncate 1
750 lfs setstripe -c -1 $DIR1/$tfile
751 dd if=/dev/zero of=$DIR1/$tfile count=$OSTCOUNT bs=$STRIPE_BYTES > \
755 log "checking cached lockless truncate"
756 $TRUNCATE $DIR1/$tfile 8000000
757 $CHECKSTAT -s 8000000 $DIR2/$tfile || error "wrong file size"
758 [ $(calc_osc_stats lockless_truncate) -eq 0 ] ||
759 error "lockless truncate doesn't use cached locks"
761 log "checking not cached lockless truncate"
762 $TRUNCATE $DIR2/$tfile 5000000
763 $CHECKSTAT -s 5000000 $DIR1/$tfile || error "wrong file size"
764 [ $(calc_osc_stats lockless_truncate) -ne 0 ] ||
765 error "not cached trancate isn't lockless"
767 log "disabled lockless truncate"
768 enable_lockless_truncate 0
770 $TRUNCATE $DIR2/$tfile 3000000
771 $CHECKSTAT -s 3000000 $DIR1/$tfile || error "wrong file size"
772 [ $(calc_osc_stats lockless_truncate) -eq 0 ] ||
773 error "lockless truncate disabling failed"
775 # restore lockless_truncate default values
776 restore_lustre_params < $p
779 run_test 32a "lockless truncate"
781 test_32b() { # bug 11270
782 remote_ost_nodsh && skip "remote OST with nodsh" && return
785 local p="$TMP/sanityN-$TESTNAME.parameters"
786 save_lustre_params $HOSTNAME "osc.*.contention_seconds" > $p
787 for node in $(osts_nodes); do
788 save_lustre_params $node "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
789 save_lustre_params $node "ldlm.namespaces.filter-*.contended_locks" >> $p
790 save_lustre_params $node "ldlm.namespaces.filter-*.contention_seconds" >> $p
793 # agressive lockless i/o settings
794 for node in $(osts_nodes); do
795 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'
797 lctl set_param -n osc.*.contention_seconds 60
798 for i in $(seq 5); do
799 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > /dev/null 2>&1
800 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > /dev/null 2>&1
802 [ $(calc_osc_stats lockless_write_bytes) -ne 0 ] || error "lockless i/o was not triggered"
803 # disable lockless i/o (it is disabled by default)
804 for node in $(osts_nodes); do
805 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'
807 # set contention_seconds to 0 at client too, otherwise Lustre still
808 # remembers lock contention
809 lctl set_param -n osc.*.contention_seconds 0
811 for i in $(seq 1); do
812 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > /dev/null 2>&1
813 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > /dev/null 2>&1
815 [ $(calc_osc_stats lockless_write_bytes) -eq 0 ] ||
816 error "lockless i/o works when disabled"
818 restore_lustre_params <$p
821 run_test 32b "lockless i/o"
825 local mdts=$(get_facets MDS)
830 for mds in ${mdts//,/ }; do
832 dev=$(basename $(do_facet $mds "lctl get_param -n osd*.${!varsvc}.mntdev|\
833 xargs readlink -f" ))
834 val=$(do_facet $mds "cat /proc/fs/jbd*/${dev}{,:*,-*}/info 2>/dev/null|\
837 stat=$(( stat + val))
842 # commit on sharing tests
844 remote_mds_nodsh && skip "remote MDS with nodsh" && return
846 [ -z "$CLIENTS" ] && skip "Need two or more clients, have $CLIENTS" && return 0
847 [ $CLIENTCOUNT -lt 2 ] &&
848 skip "Need two or more clients, have $CLIENTCOUNT" && return 0
850 local nfiles=${TEST33_NFILES:-10000}
851 local param_file=$TMP/$tfile-params
852 local fstype=$(facet_fstype $SINGLEMDS)
854 save_lustre_params $(comma_list $(mdts_nodes)) "mdt.*.commit_on_sharing" > $param_file
862 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
866 do_nodes $CLIENT1,$CLIENT2 "mkdir -p $DIR1/$tdir-\\\$(hostname)-$i"
868 [ $fstype = ldiskfs ] && jbdold=$(print_jbd_stat)
869 echo "=== START createmany old: $jbdold transaction"
870 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")
871 [ $fstype = ldiskfs ] && jbdnew=$(print_jbd_stat)
872 [ $fstype = ldiskfs ] && jbd=$(( jbdnew - jbdold ))
873 echo "=== END createmany new: $jbdnew transaction : $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
874 [ $fstype = ldiskfs ] && avgjbd=$(( avgjbd + jbd ))
875 avgtime=$(( avgtime + elapsed ))
877 eval cos${COS}_jbd=$((avgjbd / 3))
878 eval cos${COS}_time=$((avgtime / 3))
881 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
882 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
883 [ "$cos0_jbd" != 0 ] && echo "COS=1 vs COS=0 jbd: $((((cos1_jbd/cos0_jbd - 1)) * 100 )) %"
884 [ "$cos0_time" != 0 ] && echo "COS=1 vs COS=0 time: $((((cos1_time/cos0_time - 1)) * 100 )) %"
886 restore_lustre_params < $param_file
890 run_test 33a "commit on sharing, cross crete/delete, 2 clients, benchmark"
892 # commit on sharing tests
894 remote_mds_nodsh && skip "remote MDS with nodsh" && return
896 [ -n "$CLIENTS" ] || { skip "Need two or more clients" && return 0; }
897 [ $CLIENTCOUNT -ge 2 ] ||
898 { skip "Need two or more clients, have $CLIENTCOUNT" &&
900 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
902 local nfiles=${TEST33_NFILES:-10000}
903 local param_file=$TMP/$tfile-params
905 save_lustre_params $(comma_list $(mdts_nodes)) \
906 "mdt.*.commit_on_sharing" > $param_file
914 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
918 do_node $CLIENT1 "$LFS mkdir -i $MDTIDX -p \
919 $DIR1/$tdir-\\\$(hostname)-$i"
921 jbdold=$(print_jbd_stat)
922 echo "=== START createmany old: $jbdold transaction"
923 local elapsed=$(do_and_time "do_nodes $CLIENT1,$CLIENT2\
924 createmany -o $DIR1/$tdir-\\\$(hostname)-$i/f- \
925 -r $DIR2/$tdir-\\\$(hostname)-$i/f- $nfiles > \
927 jbdnew=$(print_jbd_stat)
928 jbd=$(( jbdnew - jbdold ))
929 echo "=== END createmany new: $jbdnew transaction : \
930 $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
931 avgjbd=$(( avgjbd + jbd ))
932 avgtime=$(( avgtime + elapsed ))
934 eval cos${COS}_jbd=$((avgjbd / 3))
935 eval cos${COS}_time=$((avgtime / 3))
938 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
939 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
940 [ "$cos0_jbd" != 0 ] &&
941 echo "COS=1 vs COS=0 jbd: $(((cos1_jbd/cos0_jbd - 1) * 100)) %"
942 [ "$cos0_time" != 0 ] &&
943 echo "COS=1 vs COS=0 time: $(((cos1_time/cos0_time - 1) * 100)) %"
945 restore_lustre_params < $param_file
949 run_test 33b "COS: cross create/delete, 2 clients, benchmark under remote dir"
951 # End commit on sharing tests
953 get_ost_lock_timeouts() {
954 local nodes=${1:-$(comma_list $(osts_nodes))}
956 local locks=$(do_nodes $nodes \
957 "lctl get_param -n ldlm.namespaces.filter-*.lock_timeouts" | calc_sum)
965 do_nodes $(comma_list $(osts_nodes)) \
966 "lctl set_param -n fail_loc=0 2>/dev/null || true"
967 for i in $(seq $OSTCOUNT); do
968 wait_osc_import_state client ost$i FULL
976 trap cleanup_34 EXIT RETURN
977 for OPER in notimeout timeout ; do
978 rm $DIR1/$tfile 2>/dev/null
979 lock_in=$(get_ost_lock_timeouts)
980 if [ $OPER == "timeout" ] ; then
981 for j in `seq $OSTCOUNT`; do
982 #define OBD_FAIL_PTLRPC_HPREQ_TIMEOUT 0x511
983 do_facet ost$j lctl set_param fail_loc=0x511
985 echo lock should expire
987 for j in `seq $OSTCOUNT`; do
988 #define OBD_FAIL_PTLRPC_HPREQ_NOTIMEOUT 0x512
989 do_facet ost$j lctl set_param fail_loc=0x512
991 echo lock should not expire
993 echo writing on client1
994 dd if=/dev/zero of=$DIR1/$tfile count=100 conv=notrunc > /dev/null 2>&1
996 echo reading on client2
997 dd of=/dev/null if=$DIR2/$tfile > /dev/null 2>&1
998 # wait for a lock timeout
1000 lock_out=$(get_ost_lock_timeouts)
1001 if [ $OPER == "timeout" ] ; then
1002 if [ $lock_in == $lock_out ]; then
1003 error "no lock timeout happened"
1008 if [ $lock_in != $lock_out ]; then
1009 error "lock timeout happened"
1017 run_test 34 "no lock timeout under IO"
1019 test_35() { # bug 17645
1022 for imp in /proc/fs/lustre/mdc/$FSNAME-MDT*-mdc-*; do
1023 g=$(awk '/generation/{print $2}' $imp/import)
1024 generation[count]=$g
1028 test_mkdir -p $MOUNT1/$tfile
1029 cancel_lru_locks mdc
1031 # Let's initiate -EINTR situation by setting fail_loc and take
1032 # write lock on same file from same client. This will not cause
1033 # bl_ast yet as lock is already in local cache.
1034 #define OBD_FAIL_LDLM_INTR_CP_AST 0x317
1035 do_facet client "lctl set_param fail_loc=0x80000317"
1036 local timeout=`do_facet $SINGLEMDS lctl get_param -n timeout`
1037 let timeout=timeout*3
1039 while test $nr -lt 10; do
1040 log "Race attempt $nr"
1041 local blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
1042 test "x$blk1" = "x" && blk1=0
1043 createmany -o $MOUNT2/$tfile/a 4000 &
1047 # Let's make conflict and bl_ast
1048 ls -la $MOUNT1/$tfile > /dev/null &
1051 log "Wait for $pid1 $pid2 for $timeout sec..."
1053 kill -9 $pid1 $pid2 > /dev/null 2>&1
1055 local blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
1056 test "x$blk2" = "x" && blk2=0
1057 test $blk2 -gt $blk1 && break
1058 rm -fr $MOUNT1/$tfile/*
1059 cancel_lru_locks mdc
1062 do_facet client "lctl set_param fail_loc=0x0"
1063 df -h $MOUNT1 $MOUNT2
1065 for imp in /proc/fs/lustre/mdc/$FSNAME-MDT*-mdc-*; do
1066 g=$(awk '/generation/{print $2}' $imp/import)
1067 if ! test "$g" -eq "${generation[count]}"; then
1068 error "Eviction happened on import $(basename $imp)"
1073 run_test 35 "-EINTR cp_ast vs. bl_ast race does not evict client"
1075 test_36() { #bug 16417
1080 test_mkdir -p $DIR1/$tdir
1081 $LFS setstripe -c -1 $DIR1/$tdir
1084 let SIZE_B=SIZE*1024*1024
1085 sync; sleep 5; sync # wait for delete thread
1087 while [ $i -le 10 ]; do
1088 lctl mark "start test"
1089 local before=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1090 dd if=/dev/zero of=$DIR1/$tdir/$tfile bs=1M count=$SIZE ||
1091 error "dd $DIR1/$tdir/$tfile ${SIZE}MB failed"
1092 sync # sync data from client cache
1093 sync_all_data # sync data from server cache (delayed allocation)
1095 local after_dd=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1096 multiop_bg_pause $DIR2/$tdir/$tfile O_r${SIZE_B}c || return 3
1098 rm -f $DIR1/$tdir/$tfile
1099 kill -USR1 $read_pid
1101 wait_delete_completed
1102 local after=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1103 echo "*** cycle($i) *** before($before) after_dd($after_dd)" \
1105 # this free space! not used
1106 (( $after_dd <= $after)) ||
1107 error "space leaked after_dd:$after_dd > after:$after"
1111 run_test 36 "handle ESTALE/open-unlink correctly"
1113 test_37() { # bug 18695
1114 test_mkdir -p $DIR1/$tdir
1115 multiop_bg_pause $DIR1/$tdir D_c || return 1
1117 # create large directory (32kB seems enough from e2fsck, ~= 1000 files)
1118 createmany -m $DIR2/$tdir/f 10000
1119 # set mtime/atime backward
1120 touch -t 198001010000 $DIR2/$tdir
1121 kill -USR1 $MULTIPID
1122 nr_files=`lfs find $DIR1/$tdir -type f | wc -l`
1123 [ $nr_files -eq 10000 ] || error "$nr_files != 10000 truncated directory?"
1126 run_test 37 "check i_size is not updated for directory on close (bug 18695) =============="
1128 # this should be set to past
1129 TEST_39_MTIME=`date -d "1 year ago" +%s`
1133 local client1=${CLIENT1:-`hostname`}
1134 local client2=${CLIENT2:-`hostname`}
1136 do_node $client1 "touch $DIR1/$tfile"
1138 do_node $client1 "touch -m -d @$TEST_39_MTIME $DIR1/$tfile"
1139 local mtime1=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1140 [ "$mtime1" = $TEST_39_MTIME ] || \
1141 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
1143 local d1=`do_node $client1 date +%s`
1144 do_node $client1 'echo hello >> '$DIR1/$tfile
1145 local d2=`do_node $client1 date +%s`
1147 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1148 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
1149 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
1151 do_node $client1 "mv $DIR1/$tfile $DIR1/$tfile-1"
1153 for (( i=0; i < 2; i++ )) ; do
1154 local mtime3=`do_node $client2 "stat -c %Y $DIR1/$tfile-1"`
1155 [ "$mtime2" = "$mtime3" ] || \
1156 error "mtime ($mtime2) changed (to $mtime3) on rename"
1158 cancel_lru_locks osc
1159 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1162 run_test 39a "test from 11063 =================================="
1165 local client1=${CLIENT1:-`hostname`}
1166 local client2=${CLIENT2:-`hostname`}
1170 local mtime1=`stat -c %Y $DIR1/$tfile`
1171 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1174 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
1176 for (( i=0; i < 2; i++ )) ; do
1177 local mtime3=`stat -c %Y $DIR1/$tfile`
1178 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1180 [ "$mtime3" = "$mtime4" ] || \
1181 error "different mtime on clients: $mtime3, $mtime4"
1182 [ "$mtime3" = $TEST_39_MTIME ] || \
1183 error "lost mtime: $mtime3, should be $TEST_39_MTIME"
1185 cancel_lru_locks osc
1186 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1189 run_test 39b "11063 problem 1 =================================="
1192 local client1=${CLIENT1:-`hostname`}
1193 local client2=${CLIENT2:-`hostname`}
1195 echo hello > $DIR1/$tfile
1197 local mtime1=`stat -c %Y $DIR1/$tfile`
1198 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1199 [ "$mtime1" = "$mtime2" ] || \
1200 error "create: different mtime on clients: $mtime1, $mtime2"
1203 $TRUNCATE $DIR1/$tfile 1
1205 for (( i=0; i < 2; i++ )) ; do
1206 local mtime3=`stat -c %Y $DIR1/$tfile`
1207 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1209 [ "$mtime3" = "$mtime4" ] || \
1210 error "different mtime on clients: $mtime3, $mtime4"
1211 [ "$mtime3" -gt $mtime2 ] || \
1212 error "truncate did not update mtime: $mtime2, $mtime3"
1214 cancel_lru_locks osc
1215 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1218 run_test 39c "check truncate mtime update ======================"
1220 # check that pid exists hence second operation wasn't blocked by first one
1221 # if it is so then there is no conflict, return 0
1222 # else second operation is conflicting with first one, return 1
1223 check_pdo_conflict() {
1226 sleep 1 # to ensure OP1 is finished on client if OP2 is blocked by OP1
1227 if [[ `ps --pid $pid | wc -l` == 1 ]]; then
1237 # test 40: check non-blocking operations
1239 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1240 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1241 mkdir $DIR1/$tfile &
1244 touch $DIR2/$tfile-2
1245 check_pdo_conflict $PID1 || error "create is blocked"
1246 mkdir $DIR2/$tfile-3
1247 check_pdo_conflict $PID1 || error "mkdir is blocked"
1248 link $DIR2/$tfile-2 $DIR2/$tfile-4
1249 check_pdo_conflict $PID1 || error "link is blocked"
1250 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1251 check_pdo_conflict $PID1 || error "rename is blocked"
1252 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1253 check_pdo_conflict $PID1 || error "getattr is blocked"
1254 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1255 rmdir $DIR2/$tfile-3
1256 check_pdo_conflict $PID1 || error "unlink is blocked"
1258 if [ $MDSCOUNT -ge 2 ]; then
1259 $LFS mkdir -i 1 $DIR2/$tfile-6
1260 check_pdo_conflict $PID1 || error "remote mkdir is blocked"
1263 # all operations above shouldn't wait the first one
1264 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1269 run_test 40a "pdirops: create vs others =============="
1272 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1273 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1274 touch $DIR1/$tfile &
1278 touch $DIR2/$tfile-2
1279 check_pdo_conflict $PID1 || error "create is blocked"
1280 mkdir $DIR2/$tfile-3
1281 check_pdo_conflict $PID1 || error "mkdir is blocked"
1282 link $DIR2/$tfile-2 $DIR2/$tfile-4
1283 check_pdo_conflict $PID1 || error "link is blocked"
1284 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1285 check_pdo_conflict $PID1 || error "rename is blocked"
1286 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1287 check_pdo_conflict $PID1 || error "getattr is blocked"
1288 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1289 rmdir $DIR2/$tfile-3
1290 check_pdo_conflict $PID1 || error "unlink is blocked"
1291 # all operations above shouldn't wait the first one
1293 if [ $MDSCOUNT -ge 2 ]; then
1294 $LFS mkdir -i 1 $DIR2/$tfile-6
1295 check_pdo_conflict $PID1 || error "remote mkdir is blocked"
1298 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1303 run_test 40b "pdirops: open|create and others =============="
1307 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1308 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1309 link $DIR1/$tfile $DIR1/$tfile-0 &
1313 touch $DIR2/$tfile-2
1314 check_pdo_conflict $PID1 || error "create is blocked"
1315 mkdir $DIR2/$tfile-3
1316 check_pdo_conflict $PID1 || error "mkdir is blocked"
1317 link $DIR2/$tfile-2 $DIR2/$tfile-4
1318 check_pdo_conflict $PID1 || error "link is blocked"
1319 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1320 check_pdo_conflict $PID1 || error "rename is blocked"
1321 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1322 check_pdo_conflict $PID1 || error "getattr is blocked"
1323 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1324 rmdir $DIR2/$tfile-3
1325 check_pdo_conflict $PID1 || error "unlink is blocked"
1327 if [ $MDSCOUNT -ge 2 ]; then
1328 $LFS mkdir -i 1 $DIR2/$tfile-6
1329 check_pdo_conflict $PID1 || error "remote mkdir is blocked"
1332 # all operations above shouldn't wait the first one
1333 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1338 run_test 40c "pdirops: link and others =============="
1342 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1343 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1348 touch $DIR2/$tfile-2
1349 check_pdo_conflict $PID1 || error "create is blocked"
1350 mkdir $DIR2/$tfile-3
1351 check_pdo_conflict $PID1 || error "mkdir is blocked"
1352 link $DIR2/$tfile-2 $DIR2/$tfile-4
1353 check_pdo_conflict $PID1 || error "link is blocked"
1354 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1355 check_pdo_conflict $PID1 || error "rename is blocked"
1356 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1357 check_pdo_conflict $PID1 || error "getattr is blocked"
1358 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1359 rmdir $DIR2/$tfile-3
1360 check_pdo_conflict $PID1 || error "unlink is blocked"
1362 if [ $MDSCOUNT -ge 2 ]; then
1363 $LFS mkdir -i 1 $DIR2/$tfile-6
1364 check_pdo_conflict $PID1 || error "remote mkdir is blocked"
1367 # all operations above shouldn't wait the first one
1368 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1372 run_test 40d "pdirops: unlink and others =============="
1376 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1377 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1378 mv $DIR1/$tfile $DIR1/$tfile-0 &
1382 touch $DIR2/$tfile-2
1383 check_pdo_conflict $PID1 || error "create is blocked"
1384 mkdir $DIR2/$tfile-3
1385 check_pdo_conflict $PID1 || error "mkdir is blocked"
1386 link $DIR2/$tfile-2 $DIR2/$tfile-4
1387 check_pdo_conflict $PID1 || error "link is blocked"
1388 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1389 check_pdo_conflict $PID1 || error "getattr is blocked"
1390 rm $DIR2/$tfile-4 $DIR2/$tfile-2
1391 rmdir $DIR2/$tfile-3
1392 check_pdo_conflict $PID1 || error "unlink is blocked"
1394 if [ $MDSCOUNT -ge 2 ]; then
1395 $LFS mkdir -i 1 $DIR2/$tfile-6
1396 check_pdo_conflict $PID1 || error "remote mkdir is blocked"
1399 # all operations above shouldn't wait the first one
1400 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1405 run_test 40e "pdirops: rename and others =============="
1407 # test 41: create blocking operations
1409 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1410 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1411 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1414 mkdir $DIR2/$tfile && error "mkdir must fail"
1415 check_pdo_conflict $PID1 && { wait $PID1; echo "mkdir isn't blocked"; }
1419 run_test 41a "pdirops: create vs mkdir =============="
1422 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1423 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1424 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1427 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1428 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1432 run_test 41b "pdirops: create vs create =============="
1435 touch $DIR1/$tfile-2
1436 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1437 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1438 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1441 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
1442 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1446 run_test 41c "pdirops: create vs link =============="
1449 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1450 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1451 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1454 rm $DIR2/$tfile || error "unlink must succeed"
1455 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1459 run_test 41d "pdirops: create vs unlink =============="
1462 touch $DIR1/$tfile-2
1463 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1464 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1465 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1468 mv $DIR2/$tfile-2 $DIR2/$tfile || error "rename must succeed"
1469 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1473 run_test 41e "pdirops: create and rename (tgt) =============="
1476 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1477 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1478 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1481 mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
1482 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1486 run_test 41f "pdirops: create and rename (src) =============="
1489 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1490 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1491 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1494 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
1495 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1499 run_test 41g "pdirops: create vs getattr =============="
1502 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1503 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1504 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1507 ls -lia $DIR2/ > /dev/null
1508 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1512 run_test 41h "pdirops: create vs readdir =============="
1514 # test 42: unlink and blocking operations
1516 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1517 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1518 mkdir $DIR1/$tfile &
1521 mkdir $DIR2/$tfile && error "mkdir must fail"
1522 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1526 run_test 42a "pdirops: mkdir vs mkdir =============="
1529 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1530 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1531 mkdir $DIR1/$tfile &
1534 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1535 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1539 run_test 42b "pdirops: mkdir vs create =============="
1542 touch $DIR1/$tfile-2
1543 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1544 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1545 mkdir $DIR1/$tfile &
1548 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
1549 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1553 run_test 42c "pdirops: mkdir vs link =============="
1556 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1557 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1558 mkdir $DIR1/$tfile &
1561 rmdir $DIR2/$tfile || error "unlink must succeed"
1562 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1566 run_test 42d "pdirops: mkdir vs unlink =============="
1569 touch $DIR1/$tfile-2
1570 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1571 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1572 mkdir $DIR1/$tfile &
1575 mv -T $DIR2/$tfile-2 $DIR2/$tfile && error "rename must fail"
1576 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1580 run_test 42e "pdirops: mkdir and rename (tgt) =============="
1583 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1584 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1585 mkdir $DIR1/$tfile &
1588 mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
1589 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1593 run_test 42f "pdirops: mkdir and rename (src) =============="
1596 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1597 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1598 mkdir $DIR1/$tfile &
1601 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
1602 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1606 run_test 42g "pdirops: mkdir vs getattr =============="
1609 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1610 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1611 mkdir $DIR1/$tfile &
1614 ls -lia $DIR2/ > /dev/null
1615 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1619 run_test 42h "pdirops: mkdir vs readdir =============="
1621 # test 43: unlink and blocking operations
1624 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1625 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1629 mkdir $DIR2/$tfile || error "mkdir must succeed"
1630 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1634 run_test 43a "pdirops: unlink vs mkdir =============="
1638 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1639 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1643 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c || error "create must succeed"
1644 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1648 run_test 43b "pdirops: unlink vs create =============="
1652 touch $DIR1/$tfile-2
1653 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1654 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1658 link $DIR2/$tfile-2 $DIR2/$tfile || error "link must succeed"
1659 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1663 run_test 43c "pdirops: unlink vs link =============="
1667 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1668 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1672 rm $DIR2/$tfile && error "unlink must fail"
1673 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1677 run_test 43d "pdirops: unlink vs unlink =============="
1681 touch $DIR1/$tfile-2
1682 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1683 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1687 mv -u $DIR2/$tfile-2 $DIR2/$tfile || error "rename must succeed"
1688 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1692 run_test 43e "pdirops: unlink and rename (tgt) =============="
1696 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1697 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1701 mv $DIR2/$tfile $DIR2/$tfile-2 && error "rename must fail"
1702 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1706 run_test 43f "pdirops: unlink and rename (src) =============="
1710 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1711 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1715 stat $DIR2/$tfile > /dev/null && error "stat must fail"
1716 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1720 run_test 43g "pdirops: unlink vs getattr =============="
1724 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1725 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1729 ls -lia $DIR2/ > /dev/null
1730 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1734 run_test 43h "pdirops: unlink vs readdir =============="
1737 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1739 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1740 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1744 $LFS mkdir -i 1 $DIR2/$tfile || error "remote mkdir must succeed"
1745 check_pdo_conflict $PID1 &&
1746 { wait $PID1; error "remote mkdir isn't blocked"; }
1750 run_test 43i "pdirops: unlink vs remote mkdir"
1752 # test 44: rename tgt and blocking operations
1754 touch $DIR1/$tfile-2
1755 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1756 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1757 mv $DIR1/$tfile-2 $DIR1/$tfile &
1760 mkdir $DIR2/$tfile && error "mkdir must fail"
1761 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1765 run_test 44a "pdirops: rename tgt vs mkdir =============="
1768 touch $DIR1/$tfile-2
1769 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1770 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1771 mv $DIR1/$tfile-2 $DIR1/$tfile &
1774 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1775 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1779 run_test 44b "pdirops: rename tgt vs create =============="
1782 touch $DIR1/$tfile-2
1783 touch $DIR1/$tfile-3
1784 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1785 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1786 mv $DIR1/$tfile-2 $DIR1/$tfile &
1789 link $DIR2/$tfile-3 $DIR2/$tfile && error "link must fail"
1790 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1794 run_test 44c "pdirops: rename tgt vs link =============="
1797 touch $DIR1/$tfile-2
1798 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1799 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1800 mv $DIR1/$tfile-2 $DIR1/$tfile &
1803 rm $DIR2/$tfile || error "unlink must succeed"
1804 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1808 run_test 44d "pdirops: rename tgt vs unlink =============="
1812 touch $DIR1/$tfile-2
1813 touch $DIR1/$tfile-3
1814 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1815 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1816 mv $DIR1/$tfile-2 $DIR1/$tfile &
1819 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
1820 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1824 run_test 44e "pdirops: rename tgt and rename (tgt) =============="
1827 touch $DIR1/$tfile-2
1828 touch $DIR1/$tfile-3
1829 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1830 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1831 mv $DIR1/$tfile-2 $DIR1/$tfile &
1834 mv $DIR2/$tfile $DIR2/$tfile-3 || error "rename must succeed"
1835 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1839 run_test 44f "pdirops: rename tgt and rename (src) =============="
1842 touch $DIR1/$tfile-2
1843 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1844 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1845 mv $DIR1/$tfile-2 $DIR1/$tfile &
1848 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
1849 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1853 run_test 44g "pdirops: rename tgt vs getattr =============="
1856 touch $DIR1/$tfile-2
1857 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1858 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1859 mv $DIR1/$tfile-2 $DIR1/$tfile &
1862 ls -lia $DIR2/ > /dev/null
1863 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1867 run_test 44h "pdirops: rename tgt vs readdir =============="
1869 # test 44: rename tgt and blocking operations
1871 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1872 touch $DIR1/$tfile-2
1873 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1874 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1875 mv $DIR1/$tfile-2 $DIR1/$tfile &
1878 $LFS mkdir -i 1 $DIR2/$tfile && error "remote mkdir must fail"
1879 check_pdo_conflict $PID1 && { wait $PID1;
1880 error "remote mkdir isn't blocked"; }
1884 run_test 44i "pdirops: rename tgt vs remote mkdir"
1886 # test 45: rename src and blocking operations
1889 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1890 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1891 mv $DIR1/$tfile $DIR1/$tfile-2 &
1894 mkdir $DIR2/$tfile || error "mkdir must succeed"
1895 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1899 run_test 45a "pdirops: rename src vs mkdir =============="
1903 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1904 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1905 mv $DIR1/$tfile $DIR1/$tfile-2 &
1908 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c || error "create must succeed"
1909 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1913 run_test 45b "pdirops: rename src vs create =============="
1917 touch $DIR1/$tfile-3
1918 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1919 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1920 mv $DIR1/$tfile $DIR1/$tfile-2 &
1923 link $DIR2/$tfile-3 $DIR2/$tfile || error "link must succeed"
1924 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1928 run_test 45c "pdirops: rename src vs link =============="
1932 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1933 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1934 mv $DIR1/$tfile $DIR1/$tfile-2 &
1937 rm $DIR2/$tfile && error "unlink must fail"
1938 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1942 run_test 45d "pdirops: rename src vs unlink =============="
1946 touch $DIR1/$tfile-3
1947 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1948 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1949 mv $DIR1/$tfile $DIR1/$tfile-2 &
1952 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
1953 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1957 run_test 45e "pdirops: rename src and rename (tgt) =============="
1961 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1962 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1963 mv $DIR1/$tfile $DIR1/$tfile-2 &
1966 mv $DIR2/$tfile $DIR2/$tfile-3 && error "rename must fail"
1967 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1971 run_test 45f "pdirops: rename src and rename (src) =============="
1975 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1976 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1977 mv $DIR1/$tfile $DIR1/$tfile-2 &
1980 stat $DIR2/$tfile > /dev/null && error "stat must fail"
1981 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1985 run_test 45g "pdirops: rename src vs getattr =============="
1989 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1990 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1991 mv $DIR1/$tfile $DIR1/$tfile-2 &
1994 ls -lia $DIR2/ > /dev/null
1995 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1999 run_test 45h "pdirops: unlink vs readdir =============="
2002 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2004 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2005 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2006 mv $DIR1/$tfile $DIR1/$tfile-2 &
2009 $LFS mkdir -i 1 $DIR2/$tfile || error "create remote dir must succeed"
2010 check_pdo_conflict $PID1 && { wait $PID1;
2011 error "create remote dir isn't blocked"; }
2015 run_test 45i "pdirops: rename src vs remote mkdir"
2017 # test 46: link and blocking operations
2019 touch $DIR1/$tfile-2
2020 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2021 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2022 link $DIR1/$tfile-2 $DIR1/$tfile &
2025 mkdir $DIR2/$tfile && error "mkdir must fail"
2026 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2030 run_test 46a "pdirops: link vs mkdir =============="
2033 touch $DIR1/$tfile-2
2034 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2035 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2036 link $DIR1/$tfile-2 $DIR1/$tfile &
2039 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
2040 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2044 run_test 46b "pdirops: link vs create =============="
2047 touch $DIR1/$tfile-2
2048 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2049 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2050 link $DIR1/$tfile-2 $DIR1/$tfile &
2053 link $DIR2/$tfile $DIR2/$tfile && error "link must fail"
2054 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2058 run_test 46c "pdirops: link vs link =============="
2061 touch $DIR1/$tfile-2
2062 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2063 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2064 link $DIR1/$tfile-2 $DIR1/$tfile &
2067 rm $DIR2/$tfile || error "unlink must succeed"
2068 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2072 run_test 46d "pdirops: link vs unlink =============="
2075 touch $DIR1/$tfile-2
2076 touch $DIR1/$tfile-3
2077 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2078 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2079 link $DIR1/$tfile-2 $DIR1/$tfile &
2082 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
2083 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2087 run_test 46e "pdirops: link and rename (tgt) =============="
2090 touch $DIR1/$tfile-2
2091 touch $DIR1/$tfile-3
2092 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2093 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2094 link $DIR1/$tfile-2 $DIR1/$tfile &
2097 mv $DIR2/$tfile $DIR2/$tfile-3 || error "rename must succeed"
2098 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2102 run_test 46f "pdirops: link and rename (src) =============="
2105 touch $DIR1/$tfile-2
2106 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2107 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2108 link $DIR1/$tfile-2 $DIR1/$tfile &
2111 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
2112 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2116 run_test 46g "pdirops: link vs getattr =============="
2119 touch $DIR1/$tfile-2
2120 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2121 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2122 link $DIR1/$tfile-2 $DIR1/$tfile &
2125 ls -lia $DIR2/ > /dev/null
2126 check_pdo_conflict $PID1 && { wait $PID1;
2127 error "readdir isn't blocked"; }
2131 run_test 46h "pdirops: link vs readdir =============="
2134 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2135 touch $DIR1/$tfile-2
2136 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2137 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2138 link $DIR1/$tfile-2 $DIR1/$tfile &
2141 $LFS mkdir -i 1 $DIR2/$tfile && error "remote mkdir must fail"
2142 check_pdo_conflict $PID1 && { wait $PID1;
2143 error "remote mkdir isn't blocked"; }
2147 run_test 46i "pdirops: link vs remote mkdir"
2149 # test 47: remote mkdir and blocking operations
2151 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2152 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2153 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2154 $LFS mkdir -i 1 $DIR1/$tfile &
2157 mkdir $DIR2/$tfile && error "mkdir must fail"
2158 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2162 run_test 47a "pdirops: remote mkdir vs mkdir"
2165 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2166 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2167 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2168 $LFS mkdir -i 1 $DIR1/$tfile &
2171 multiop $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
2172 check_pdo_conflict $PID1 && { wait $PID1;
2173 error "create isn't blocked"; }
2177 run_test 47b "pdirops: remote mkdir vs create"
2180 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2181 touch $DIR1/$tfile-2
2182 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2183 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2184 $LFS mkdir -i 1 $DIR1/$tfile &
2187 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
2188 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2192 run_test 47c "pdirops: remote mkdir vs link"
2195 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2196 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2197 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2198 $LFS mkdir -i 1 $DIR1/$tfile &
2201 rmdir $DIR2/$tfile || error "unlink must succeed"
2202 check_pdo_conflict $PID1 && { wait $PID1;
2203 error "unlink isn't blocked"; }
2207 run_test 47d "pdirops: remote mkdir vs unlink"
2210 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2211 touch $DIR1/$tfile-2
2212 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2213 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2214 $LFS mkdir -i 1 $DIR1/$tfile &
2217 mv -T $DIR2/$tfile-2 $DIR2/$tfile && error "rename must fail"
2218 check_pdo_conflict $PID1 && { wait $PID1;
2219 error "rename isn't blocked"; }
2223 run_test 47e "pdirops: remote mkdir and rename (tgt)"
2226 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2227 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2228 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2229 $LFS mkdir -i 1 $DIR1/$tfile &
2232 mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
2233 check_pdo_conflict $PID1 && { wait $PID1;
2234 error "rename isn't blocked"; }
2238 run_test 47f "pdirops: remote mkdir and rename (src)"
2241 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2242 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2243 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2244 $LFS mkdir -i 1 $DIR1/$tfile &
2247 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
2248 check_pdo_conflict $PID1 && { wait $PID1;
2249 error "getattr isn't blocked"; }
2253 run_test 47g "pdirops: remote mkdir vs getattr"
2257 dd if=/dev/zero of=$DIR1/$tfile bs=1K count=10
2258 #define OBD_FAIL_OSC_CP_ENQ_RACE 0x410
2259 do_facet client "lctl set_param fail_loc=0x410"
2260 $TRUNCATE $DIR2/$tfile $trunc_size
2261 do_facet client "lctl set_param fail_loc=0x0"
2263 size=`stat -c %s $DIR2/$tfile`
2264 [ $size -eq $trunc_size ] || error "wrong size"
2266 run_test 50 "osc lvb attrs: enqueue vs. CP AST =============="
2270 local origfile=/etc/hosts
2272 filesize=`stat -c %s $origfile`
2274 # create an empty file
2275 $MCREATE $DIR1/$tfile
2276 # cache layout lock on both mount point
2277 stat $DIR1/$tfile > /dev/null
2278 stat $DIR2/$tfile > /dev/null
2280 # open and sleep 2 seconds then read
2281 $MULTIOP $DIR2/$tfile o_2r${filesize}c &
2285 # create the layout of testing file
2286 dd if=$origfile of=$DIR1/$tfile conv=notrunc > /dev/null
2288 # MULTIOP proc should be able to read enough bytes and exit
2290 kill -0 $pid && error "multiop is still there"
2291 cmp $origfile $DIR2/$tfile || error "$MCREATE and $DIR2/$tfile differs"
2295 run_test 51a "layout lock: refresh layout should work"
2298 local tmpfile=`mktemp`
2300 # create an empty file
2301 $MCREATE $DIR1/$tfile
2303 # delay glimpse so that layout has changed when glimpse finish
2304 #define OBD_FAIL_GLIMPSE_DELAY 0x1404
2305 $LCTL set_param fail_loc=0x1404
2306 stat -c %s $DIR2/$tfile |tee $tmpfile &
2310 # create layout of testing file
2311 dd if=/dev/zero of=$DIR1/$tfile bs=1k count=1 conv=notrunc > /dev/null
2314 local fsize=`cat $tmpfile`
2316 [ x$fsize = x1024 ] || error "file size is $fsize, should be 1024"
2318 rm -f $DIR1/$tfile $tmpfile
2320 run_test 51b "layout lock: glimpse should be able to restart if layout changed"
2323 # create an empty file
2324 $MCREATE $DIR1/$tfile
2326 #define OBD_FAIL_MDS_LL_BLOCK 0x172
2327 $LCTL set_param fail_loc=0x172
2329 # change the layout of testing file
2330 echo "Setting layout ..."
2331 $LFS setstripe -c $OSTCOUNT $DIR1/$tfile &
2335 # get layout of this file should wait until dd is finished
2336 local stripecnt=`$LFS getstripe -c $DIR2/$tfile`
2337 [ $stripecnt -eq $OSTCOUNT ] || error "layout wrong"
2341 run_test 51c "layout lock: IT_LAYOUT blocked and correct layout can be returned"
2344 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.0) ]] ||
2345 { skip "Need MDS version at least 2.3.0"; return; }
2347 test_mkdir -p $DIR1/$tdir
2348 file1=$DIR1/$tdir/file
2349 file2=$DIR2/$tdir/file
2351 echo orig > $file2 || error "Could not create $file2"
2352 version=$($LFS data_version $file1)
2355 echo append >> $file2 || error "Could not append to $file2"
2356 version2=$($LFS data_version $file1)
2357 [ "$version" != "$version2" ] ||
2358 error "append did not change data version: $version"
2361 echo overwrite > $file2 || error "Could not overwrite $file2"
2362 version3=$($LFS data_version $file1)
2363 [ "$version2" != "$version3" ] ||
2364 error "overwrite did not change data version: $version2"
2366 # Truncate before EOF
2367 $TRUNCATE $file2 3 || error "Could not truncate $file2"
2368 version4=$($LFS data_version $file1)
2369 [ "$version3" != "$version4" ] ||
2370 error "truncate did not change data version: $version3"
2372 # Truncate after EOF
2373 $TRUNCATE $file2 123456 || error "Could not truncate $file2"
2374 version5=$($LFS data_version $file1)
2375 [ "$version4" != "$version5" ] ||
2376 error "truncate did not change data version: $version4"
2378 # Chmod do not change version
2379 chmod 400 $file2 || error "Could not chmod 400 $file2"
2380 version6=$($LFS data_version $file1)
2381 [ "$version5" == "$version6" ] ||
2382 error "chmod should not change data version: $version5 != $version6"
2384 # Chown do not change version
2385 chown $RUNAS_ID $file2 || error "Could not chown $RUNAS_ID $file2"
2386 version7=$($LFS data_version $file1)
2387 [ "$version5" == "$version7" ] ||
2388 error "chown should not change data version: $version5 != $version7"
2390 run_test 60 "Verify data_version behaviour"
2393 local test_dir=$tdir/test_dir
2395 mkdir -p $DIR1/$tdir
2396 if [ $MDSCOUNT -ge 2 ]; then
2398 $LFS mkdir -i $MDTIDX $DIR1/$test_dir ||
2399 error "Create remote directory failed"
2401 mkdir -p $DIR1/$test_dir
2403 cd $DIR2/$test_dir || error "cd directory failed"
2404 rm -rf $DIR1/$test_dir || error "unlink directory failed"
2406 cd $DIR2/$tdir || error "exit directory"
2408 run_test 70a "cd directory && rm directory"
2410 test_70b() { # LU-2781
2412 mkdir -p $DIR1/$tdir
2414 touch $DIR1/$tdir/file
2415 for ((i = 0; i < 32; i++)); do
2416 $LFS rm_entry $DIR1/$tdir/non_existent_dir &>/dev/null
2418 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
2420 touch $DIR1/$tdir/file
2421 $LFS mkdir -i0 $DIR1/$tdir/test_dir
2422 $LFS rm_entry $DIR1/$tdir/test_dir &>/dev/null
2423 rm -rf $DIR1/$tdir/test_dir ||
2424 error "cannot remove directory after rm_entry"
2425 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
2427 run_test 70b "remove files after calling rm_entry"
2429 log "cleanup: ======================================================"
2431 [ "$(mount | grep $MOUNT2)" ] && umount $MOUNT2
2434 check_and_cleanup_lustre