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 [ "$SLOW" = "no" ] && EXCEPT_SLOW="12 23 33a"
50 check_and_setup_lustre
52 LOVNAME=$($LCTL get_param -n llite.*.lov.common_name | tail -n 1)
53 OSTCOUNT=$($LCTL get_param -n lov.$LOVNAME.numobd)
56 rm -rf $DIR1/[df][0-9]* $DIR1/lnk
58 SAMPLE_FILE=$TMP/$(basename $0 .sh).junk
59 dd if=/dev/urandom of=$SAMPLE_FILE bs=1M count=1
61 # $RUNAS_ID may get set incorrectly somewhere else
62 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
64 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
73 [ -f $DIR2/f1 ] || error
75 run_test 1a "check create on 2 mtpt's =========================="
79 $CHECKSTAT -t file -p 0777 $DIR1/f1 || error
82 run_test 1b "check attribute updates on 2 mtpt's ==============="
85 $CHECKSTAT -t file -p 0666 $DIR1/f1 || error
87 run_test 1c "check after remount attribute updates on 2 mtpt's ="
91 $CHECKSTAT -a $DIR1/f1 || error
93 run_test 1d "unlink on one mountpoint removes file on other ===="
99 $CHECKSTAT -t file -p 0777 $DIR1/f2a || error
101 run_test 2a "check cached attribute updates on 2 mtpt's ========"
107 $CHECKSTAT -t file -p 0777 $DIR2/f2b || error
109 run_test 2b "check cached attribute updates on 2 mtpt's ========"
111 # NEED TO SAVE ROOT DIR MODE
114 $CHECKSTAT -t dir -p 0777 $DIR2 || error
116 run_test 2c "check cached attribute updates on 2 mtpt's root ==="
120 $CHECKSTAT -t dir -p 0755 $DIR2 || error
122 run_test 2d "check cached attribute updates on 2 mtpt's root ==="
129 $RUNAS dd if=/dev/zero of=$DIR2/$tfile count=1 || error
131 run_test 2e "check chmod on root is propagated to others"
134 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
136 local remote_dir=$tdir/remote_dir
139 $LFS mkdir -i $MDTIDX $DIR1/$remote_dir ||
140 error "Create remote directory failed"
142 touch $DIR1/$remote_dir/$tfile ||
143 error "Create file under remote directory failed"
144 chmod 777 $DIR1/$remote_dir/$tfile ||
145 error "Chmod file under remote directory failed"
147 $CHECKSTAT -t file -p 0777 $DIR2/$remote_dir/$tfile ||
148 error "Check attr of file under remote directory failed"
150 chown $RUNAS_ID:$RUNAS_GID $DIR1/$remote_dir/$tfile ||
151 error "Chown file under remote directory failed"
153 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR2/$remote_dir/$tfile ||
154 error "Check owner of file under remote directory failed"
156 cd $DIR2/$remote_dir || error "enter remote dir"
157 rm -rf $DIR1/$remote_dir/$tfile ||
158 error "Unlink remote directory failed"
160 $CHECKSTAT -t file $DIR2/$remote_dir/$tfile &&
161 error "unlink file still exists!"
163 cd $DIR2/$tdir || error "exit remote dir"
164 rm -rf $DIR1/$tdir || error "unlink directory failed"
166 run_test 2f "check attr/owner updates on DNE with 2 mtpt's"
169 local target="this/is/good"
170 ln -s $target $DIR1/$tfile || error "ln -s $target $DIR1/$tfile failed"
171 [ "$(ls -l $DIR2/$tfile | sed -e 's/.* -> //')" = "$target" ] ||
172 error "link $DIR2/$tfile not as expected"
174 run_test 3 "symlink on one mtpt, readlink on another ==========="
177 multifstat $DIR1/f4 $DIR2/f4
179 run_test 4 "fstat validation on multiple mount points =========="
183 $TRUNCATE $DIR2/f5 100
184 $CHECKSTAT -t file -s 100 $DIR1/f5 || error
187 run_test 5 "create a file on one mount, truncate it on the other"
190 openunlink $DIR1/$tfile $DIR2/$tfile || \
191 error "openunlink $DIR1/$tfile $DIR2/$tfile"
193 run_test 6 "remove of open file on other node =================="
197 opendirunlink $DIR1/$dir $DIR2/$dir || \
198 error "opendirunlink $DIR1/$dir $DIR2/$dir"
200 run_test 7 "remove of open directory on other node ============="
203 opendevunlink $DIR1/$tfile $DIR2/$tfile || \
204 error "opendevunlink $DIR1/$tfile $DIR2/$tfile"
206 run_test 8 "remove of open special file on other node =========="
212 for C in a b c d e f g h i j k l; do
213 dir=`eval echo \\$DIR$MTPT`
214 echo -n $C >> $dir/f9
215 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
217 [ "`cat $DIR1/f9`" = "abcdefghijkl" ] || \
218 error "`od -a $DIR1/f9` != abcdefghijkl"
220 run_test 9 "append of file with sub-page size on multiple mounts"
227 for C in a b c d e f g h i j k l; do
228 dir=`eval echo \\$DIR$MTPT`
229 echo -n $C | dd of=$dir/f10 bs=1 seek=$OFFSET count=1
230 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
231 OFFSET=`expr $OFFSET + 1`
233 [ "`cat $DIR1/f10`" = "abcdefghijkl" ] || \
234 error "`od -a $DIR1/f10` != abcdefghijkl"
236 run_test 10a "write of file with sub-page size on multiple mounts "
240 yes "R" | head -c 4000 >$TMP/f10b-seed
241 dd if=$TMP/f10b-seed of=$DIR1/f10b bs=3k count=1 || error "dd $DIR1"
243 $TRUNCATE $DIR1/f10b 4096 || error "truncate 4096"
245 dd if=$DIR2/f10b of=$TMP/f10b-lustre bs=4k count=1 || error "dd $DIR2"
247 # create a test file locally to compare
248 dd if=$TMP/f10b-seed of=$TMP/f10b bs=3k count=1 || error "dd random"
249 $TRUNCATE $TMP/f10b 4096 || error "truncate 4096"
250 cmp $TMP/f10b $TMP/f10b-lustre || error "file miscompare"
251 rm $TMP/f10b $TMP/f10b-lustre $TMP/f10b-seed
253 run_test 10b "write of file with sub-page size on multiple mounts "
257 multiop_bg_pause $DIR1/d11/f O_c || return 1
259 cp -p /bin/ls $DIR1/d11/f
263 wait $MULTIPID || error
264 [ $RC -eq 0 ] && error || true
266 run_test 11 "execution of file opened for write should return error ===="
269 DIR=$DIR DIR2=$DIR2 sh lockorder.sh
271 run_test 12 "test lock ordering (link, stat, unlink) ==========="
273 test_13() { # bug 2451 - directory coherency
274 test_mkdir $DIR1/d13 || error
275 cd $DIR1/d13 || error
277 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
279 rm -f $DIR2/d13/f13 || error
280 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (1)" || true
281 # need to run it twice
282 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
284 rm -f $DIR2/d13/f13 || error
285 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (2)" || true
287 run_test 13 "test directory page revocation ===================="
290 test_mkdir -p $DIR1/$tdir
291 cp -p /bin/ls $DIR1/$tdir/$tfile
292 multiop_bg_pause $DIR1/$tdir/$tfile Ow_c || return 1
295 $DIR2/$tdir/$tfile && error || true
297 wait $MULTIPID || return 2
299 run_test 14 "execution of file open for write returns -ETXTBSY ="
302 test_mkdir -p $DIR1/d14
303 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
304 MULTIOP_PROG=$DIR1/d14/multiop multiop_bg_pause $TMP/test14.junk O_c || return 1
306 $MULTIOP $DIR2/d14/multiop Oc && error "expected error, got success"
307 kill -USR1 $MULTIOP_PID || return 2
308 wait $MULTIOP_PID || return 3
309 rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop"
311 run_test 14a "open(RDWR) of executing file returns -ETXTBSY ===="
313 test_14b() { # bug 3192, 7040
314 test_mkdir -p $DIR1/d14
315 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
316 MULTIOP_PROG=$DIR1/d14/multiop multiop_bg_pause $TMP/test14.junk O_c || return 1
318 $TRUNCATE $DIR2/d14/multiop 0 && kill -9 $MULTIOP_PID && \
319 error "expected truncate error, got success"
320 kill -USR1 $MULTIOP_PID || return 2
321 wait $MULTIOP_PID || return 3
322 cmp `which multiop` $DIR1/d14/multiop || error "binary changed"
323 rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop"
325 run_test 14b "truncate of executing file returns -ETXTBSY ======"
327 test_14c() { # bug 3430, 7040
328 test_mkdir -p $DIR1/d14
329 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
330 MULTIOP_PROG=$DIR1/d14/multiop multiop_bg_pause $TMP/test14.junk O_c || return 1
332 cp /etc/hosts $DIR2/d14/multiop && error "expected error, got success"
333 kill -USR1 $MULTIOP_PID || return 2
334 wait $MULTIOP_PID || return 3
335 cmp `which multiop` $DIR1/d14/multiop || error "binary changed"
336 rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop"
338 run_test 14c "open(O_TRUNC) of executing file return -ETXTBSY =="
340 test_14d() { # bug 10921
341 test_mkdir -p $DIR1/d14
342 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
343 MULTIOP_PROG=$DIR1/d14/multiop multiop_bg_pause $TMP/test14.junk O_c || return 1
346 chmod 600 $DIR1/d14/multiop || error "chmod failed"
347 kill -USR1 $MULTIOP_PID || return 2
348 wait $MULTIOP_PID || return 3
349 cmp `which multiop` $DIR1/d14/multiop || error "binary changed"
350 rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop"
352 run_test 14d "chmod of executing file is still possible ========"
354 test_15() { # bug 974 - ENOSPC
356 sh oos2.sh $MOUNT1 $MOUNT2
357 wait_delete_completed
358 grant_error=`dmesg | grep "> available"`
359 [ -z "$grant_error" ] || error "$grant_error"
361 run_test 15 "test out-of-space with multiple writers ==========="
364 # The FSXNUM reduction for ZFS is needed until ORI-487 is fixed.
365 # We don't want to skip it entirely, but ZFS is VERY slow and cannot
366 # pass a 2500 operation dual-mount run within the time limit.
367 if [ "$(facet_fstype ost1)" = "zfs" ]; then
368 FSXNUM=$((COUNT / 5))
370 elif [ "$SLOW" = "yes" ]; then
371 FSXNUM=$((COUNT * 5))
379 local file1=$DIR1/$tfile
380 local file2=$DIR2/$tfile
382 # to allocate grant because it may run out due to test_15.
383 lfs setstripe -c -1 $file1
384 dd if=/dev/zero of=$file1 bs=$STRIPE_BYTES count=$OSTCOUNT oflag=sync
385 dd if=/dev/zero of=$file2 bs=$STRIPE_BYTES count=$OSTCOUNT oflag=sync
388 lfs setstripe -c -1 $file1 # b=10919
389 fsx -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -S 0 $file1 $file2
391 run_test 16 "$FSXNUM iterations of dual-mount fsx"
393 test_17() { # bug 3513, 3667
394 remote_ost_nodsh && skip "remote OST with nodsh" && return
396 lfs setstripe $DIR1/$tfile -i 0 -c 1
397 cp $SAMPLE_FILE $DIR1/$tfile
398 cancel_lru_locks osc > /dev/null
399 #define OBD_FAIL_ONCE|OBD_FAIL_LDLM_CREATE_RESOURCE 0x30a
400 do_facet ost1 lctl set_param fail_loc=0x8000030a
401 ls -ls $DIR1/$tfile | awk '{ print $1,$6 }' > $DIR1/$tfile-1 & \
402 ls -ls $DIR2/$tfile | awk '{ print $1,$6 }' > $DIR2/$tfile-2
404 diff -u $DIR1/$tfile-1 $DIR2/$tfile-2 || error "files are different"
406 run_test 17 "resource creation/LVB creation race ==============="
409 # turn e.g. ALWAYS_EXCEPT="18c" into "-e 3"
412 for idx in {a..z}; do
413 local ptr=EXCEPT_ALWAYS_18$idx
414 [ x${!ptr} = xtrue ] || continue
416 excepts="$excepts -e $(($(printf %d \'$idx)-96))"
419 $LUSTRE/tests/mmap_sanity -d $MOUNT1 -m $MOUNT2 $excepts
422 run_test 18 "mmap sanity check ================================="
424 test_19() { # bug3811
425 local node=$(facet_active_host ost1)
427 # check whether obdfilter is cache capable at all
428 if ! get_osd_param $node '' read_cache_enable >/dev/null; then
429 echo "not cache-capable obdfilter"
433 local MAX=$(get_osd_param $node '' readcache_max_filesize | \
435 set_osd_param $node '' readcache_max_filesize 4096
436 dd if=/dev/urandom of=$TMP/$tfile bs=512k count=32
437 local SUM=$(cksum $TMP/$tfile | cut -d" " -f 1,2)
438 cp $TMP/$tfile $DIR1/$tfile
439 for i in `seq 1 20`; do
440 [ $((i % 5)) -eq 0 ] && log "$testname loop $i"
441 cancel_lru_locks osc > /dev/null
442 cksum $DIR1/$tfile | cut -d" " -f 1,2 > $TMP/sum1 & \
443 cksum $DIR2/$tfile | cut -d" " -f 1,2 > $TMP/sum2
445 [ "$(cat $TMP/sum1)" = "$SUM" ] || \
446 error "$DIR1/$tfile $(cat $TMP/sum1) != $SUM"
447 [ "$(cat $TMP/sum2)" = "$SUM" ] || \
448 error "$DIR2/$tfile $(cat $TMP/sum2) != $SUM"
450 set_osd_param $node '' readcache_max_filesize $MAX
453 run_test 19 "test concurrent uncached read races ==============="
458 CNT=$((`lctl get_param -n llite.*.dump_page_cache | wc -l`))
459 $MULTIOP $DIR1/f20 Ow8190c
460 $MULTIOP $DIR2/f20 Oz8194w8190c
461 $MULTIOP $DIR1/f20 Oz0r8190c
463 CNTD=$((`lctl get_param -n llite.*.dump_page_cache | wc -l` - $CNT))
465 error $CNTD" page left in cache after lock cancel" || true
467 run_test 20 "test extra readahead page left in cache ===="
474 test_21() { # Bug 5907
476 mount /etc $DIR1/d21 --bind || error "mount failed" # Poor man's mount.
478 rmdir -v $DIR1/d21 && error "Removed mounted directory"
479 rmdir -v $DIR2/d21 && echo "Removed mounted directory from another mountpoint, needs to be fixed"
480 test -d $DIR1/d21 || error "Mounted directory disappeared"
482 test -d $DIR2/d21 || test -d $DIR1/d21 && error "Removed dir still visible after umount"
485 run_test 21 " Try to remove mountpoint on another dir ===="
487 test_23() { # Bug 5972
488 echo "others should see updated atime while another read" > $DIR1/f23
490 # clear the lock(mode: LCK_PW) gotten from creating operation
494 #MAX_ATIME_DIFF 60, we update atime only if older than 60 seconds
497 multiop_bg_pause $DIR1/f23 or20_c || return 1
498 # with SOM and opencache enabled, we need to close a file and cancel
499 # open lock to get atime propogated to MDS
503 time2=`stat -c "%X" $DIR2/f23`
505 if (( $time2 <= $time1 )); then
506 error "atime doesn't update among nodes"
509 rm -f $DIR1/f23 || error "rm -f $DIR1/f23 failed"
512 run_test 23 " others should see updated atime while another read===="
516 lfs df || error "lfs df failed"
517 lfs df -ih || error "lfs df -ih failed"
518 lfs df -h $DIR1 || error "lfs df -h $DIR1 failed"
519 lfs df -i $DIR2 || error "lfs df -i $DIR2 failed"
520 lfs df $DIR1/$tfile || error "lfs df $DIR1/$tfile failed"
521 lfs df -ih $DIR2/$tfile || error "lfs df -ih $DIR2/$tfile failed"
523 OSC=`lctl dl | awk '/-osc-|OSC.*MNT/ {print $4}' | head -n 1`
524 # OSC=`lctl dl | awk '/-osc-/ {print $4}' | head -n 1`
525 lctl --device %$OSC deactivate
526 lfs df -i || error "lfs df -i with deactivated OSC failed"
527 lctl --device %$OSC activate
528 lfs df || error "lfs df with reactivated OSC failed"
530 run_test 24a "lfs df [-ih] [path] test ========================="
534 fsnum=$(lfs_df | grep -c "summary")
535 [ $fsnum -eq 2 ] || error "lfs df shows $fsnum != 2 filesystems."
537 run_test 24b "lfs df should show both filesystems ==============="
540 local acl=$(lctl get_param -n mdc.*MDT0000-mdc-*.connect_flags |
542 [ "$acl" -lt 1 ] && skip "must have acl, skipping" && return
545 touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
546 chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
548 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
549 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
550 error "setfacl $DIR2/$tdir #1"
551 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
552 setfacl -m u:$RUNAS_ID:r-x -m g:$RUNAS_GID:r-x $DIR1/$tdir ||
553 error "setfacl $DIR2/$tdir #2"
554 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
555 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
556 error "setfacl $DIR2/$tdir #3"
557 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
558 setfacl -x u:$RUNAS_ID: -x g:$RUNAS_GID: $DIR1/$tdir ||
559 error "setfacl $DIR2/$tdir #4"
560 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
564 run_test 25a "change ACL on one mountpoint be seen on another ==="
567 local acl=$(lctl get_param -n mdc.*MDT0000-mdc-*.connect_flags |
569 [ "$acl" -lt 1 ] && skip "must have acl, skipping" && return
571 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
574 $LFS mkdir -i 1 $DIR1/$tdir
575 touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
576 chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
578 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
579 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
580 error "setfacl $DIR2/$tdir #1"
581 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
582 setfacl -m u:$RUNAS_ID:r-x -m g:$RUNAS_GID:r-x $DIR1/$tdir ||
583 error "setfacl $DIR2/$tdir #2"
584 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
585 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
586 error "setfacl $DIR2/$tdir #3"
587 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
588 setfacl -x u:$RUNAS_ID: -x g:$RUNAS_GID: $DIR1/$tdir ||
589 error "setfacl $DIR2/$tdir #4"
590 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
594 run_test 25b "change ACL under remote dir on one mountpoint be seen on another"
597 utime $DIR1/f26a -s $DIR2/f26a || error
599 run_test 26a "allow mtime to get older"
604 echo "aaa" >> $DIR1/$tfile
606 chmod a+x $DIR2/$tfile
607 mt1=`stat -c %Y $DIR1/$tfile`
608 mt2=`stat -c %Y $DIR2/$tfile`
610 if [ x"$mt1" != x"$mt2" ]; then
611 error "not equal mtime, client1: "$mt1", client2: "$mt2"."
614 run_test 26b "sync mtime between ost and mds"
619 dd if=/dev/zero of=$DIR2/$tfile bs=$((4096+4))k conv=notrunc count=4 seek=3 &
624 dd if=/dev/zero of=$DIR1/$tfile bs=$((16384-1024))k conv=notrunc count=1 seek=4 &
629 dd if=/dev/zero of=$DIR1/$tfile bs=8k conv=notrunc count=1 seek=0
631 lctl set_param -n ldlm.dump_namespaces ""
632 wait $DD1_PID $DD2_PID
633 [ $? -ne 0 ] && lctl dk $TMP/debug || true
635 run_test 27 "align non-overlapping extent locks from request ==="
637 test_28() { # bug 9977
638 ECHO_UUID="ECHO_osc1_UUID"
639 tOST=`$LCTL dl | | awk '/-osc-|OSC.*MNT/ { print $4 }' | head -1`
641 $LFS setstripe $DIR1/$tfile -S 1048576 -i 0 -c 2
642 tOBJID=`$LFS getstripe $DIR1/$tfile | awk '$1 == 1 {print $2}'`
643 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2
647 attach echo_client ECHO_osc1 $ECHO_UUID
651 tECHOID=`$LCTL dl | grep $ECHO_UUID | awk '{ print $1 }'`
652 $LCTL --device $tECHOID destroy "${tOBJID}:0"
660 # reading of 1st stripe should pass
661 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error
662 # reading of 2nd stripe should fail (this stripe was destroyed)
663 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 && error
665 # now, recreating test file
666 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2 || error
667 # reading of 1st stripe should pass
668 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error
669 # reading of 2nd stripe should pass
670 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 || error
672 run_test 28 "read/write/truncate file with lost stripes"
674 test_29() { # bug 10999
676 #define OBD_FAIL_LDLM_GLIMPSE 0x30f
677 lctl set_param fail_loc=0x8000030f
680 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1
683 #bug 11549 - permanently turn test off in b1_5
684 run_test 29 "lock put race between glimpse and enqueue ========="
686 test_30() { #bug #11110
687 test_mkdir -p $DIR1/$tdir
688 cp -f /bin/bash $DIR1/$tdir/bash
689 /bin/sh -c 'sleep 1; rm -f $DIR2/$tdir/bash;
690 cp /bin/bash $DIR2/$tdir' &
691 local err=$($DIR1/$tdir/bash -c 'sleep 2;
692 openfile -f O_RDONLY /proc/$$/exe >& /dev/null; echo $?')
695 error_ignore 12900 "return code ($err) != -ESTALE" && return
699 run_test 30 "recreate file race"
702 test_mkdir -p $DIR1/$tdir || error "Creating dir $DIR1/$tdir"
703 local writes=$(LANG=C dd if=/dev/zero of=$DIR/$tdir/$tfile \
704 count=1 2>&1 | awk 'BEGIN { FS="+" } /out/ {print $1}')
705 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
706 lctl set_param fail_loc=0x314
707 local reads=$(LANG=C dd if=$DIR2/$tdir/$tfile of=/dev/null 2>&1 |
708 awk 'BEGIN { FS="+" } /in/ {print $1}')
709 [ $reads -eq $writes ] || error "read" $reads "blocks, must be" $writes
711 run_test 31a "voluntary cancel / blocking ast race=============="
714 remote_ost || { skip "local OST" && return 0; }
715 remote_ost_nodsh && skip "remote OST w/o dsh" && return 0
717 # make sure there is no local locks due to destroy
718 wait_mds_ost_sync || error "wait_mds_ost_sync()"
719 wait_delete_completed || error "wait_delete_completed()"
721 test_mkdir -p $DIR1/$tdir || error "Creating dir $DIR1/$tdir"
722 lfs setstripe $DIR/$tdir/$tfile -i 0 -c 1
723 cp /etc/hosts $DIR/$tdir/$tfile
724 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
725 lctl set_param fail_loc=0x314
726 #define OBD_FAIL_LDLM_OST_FAIL_RACE 0x316
727 do_facet ost1 lctl set_param fail_loc=0x316
729 cat $DIR2/$tdir/$tfile > /dev/null 2>&1
730 lctl set_param fail_loc=0
731 do_facet ost1 lctl set_param fail_loc=0
732 # cleanup: reconnect the client back
735 run_test 31b "voluntary OST cancel / blocking ast race=============="
737 # enable/disable lockless truncate feature, depending on the arg 0/1
738 enable_lockless_truncate() {
739 lctl set_param -n osc.*.lockless_truncate $1
742 test_32a() { # bug 11270
743 local p="$TMP/sanityN-$TESTNAME.parameters"
744 save_lustre_params $HOSTNAME osc.*.lockless_truncate > $p
746 enable_lockless_truncate 1
748 lfs setstripe -c -1 $DIR1/$tfile
749 dd if=/dev/zero of=$DIR1/$tfile count=$OSTCOUNT bs=$STRIPE_BYTES > \
753 log "checking cached lockless truncate"
754 $TRUNCATE $DIR1/$tfile 8000000
755 $CHECKSTAT -s 8000000 $DIR2/$tfile || error "wrong file size"
756 [ $(calc_osc_stats lockless_truncate) -eq 0 ] ||
757 error "lockless truncate doesn't use cached locks"
759 log "checking not cached lockless truncate"
760 $TRUNCATE $DIR2/$tfile 5000000
761 $CHECKSTAT -s 5000000 $DIR1/$tfile || error "wrong file size"
762 [ $(calc_osc_stats lockless_truncate) -ne 0 ] ||
763 error "not cached trancate isn't lockless"
765 log "disabled lockless truncate"
766 enable_lockless_truncate 0
768 $TRUNCATE $DIR2/$tfile 3000000
769 $CHECKSTAT -s 3000000 $DIR1/$tfile || error "wrong file size"
770 [ $(calc_osc_stats lockless_truncate) -eq 0 ] ||
771 error "lockless truncate disabling failed"
773 # restore lockless_truncate default values
774 restore_lustre_params < $p
777 run_test 32a "lockless truncate"
779 test_32b() { # bug 11270
780 remote_ost_nodsh && skip "remote OST with nodsh" && return
783 local p="$TMP/sanityN-$TESTNAME.parameters"
784 save_lustre_params $HOSTNAME "osc.*.contention_seconds" > $p
785 for node in $(osts_nodes); do
786 save_lustre_params $node "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
787 save_lustre_params $node "ldlm.namespaces.filter-*.contended_locks" >> $p
788 save_lustre_params $node "ldlm.namespaces.filter-*.contention_seconds" >> $p
791 # agressive lockless i/o settings
792 for node in $(osts_nodes); do
793 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'
795 lctl set_param -n osc.*.contention_seconds 60
796 for i in $(seq 5); do
797 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > /dev/null 2>&1
798 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > /dev/null 2>&1
800 [ $(calc_osc_stats lockless_write_bytes) -ne 0 ] || error "lockless i/o was not triggered"
801 # disable lockless i/o (it is disabled by default)
802 for node in $(osts_nodes); do
803 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'
805 # set contention_seconds to 0 at client too, otherwise Lustre still
806 # remembers lock contention
807 lctl set_param -n osc.*.contention_seconds 0
809 for i in $(seq 1); do
810 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > /dev/null 2>&1
811 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > /dev/null 2>&1
813 [ $(calc_osc_stats lockless_write_bytes) -eq 0 ] ||
814 error "lockless i/o works when disabled"
816 restore_lustre_params <$p
819 run_test 32b "lockless i/o"
823 local mdts=$(get_facets MDS)
828 for mds in ${mdts//,/ }; do
830 dev=$(basename $(do_facet $mds lctl get_param -n osd*.${!varsvc}.mntdev))
831 val=$(do_facet $mds "procfile=/proc/fs/jbd/$dev/info;
832 [ -f \\\$procfile ] || procfile=/proc/fs/jbd2/$dev/info;
833 [ -f \\\$procfile ] || procfile=/proc/fs/jbd2/${dev}\:\\\*/info;
834 cat \\\$procfile | head -1;")
836 stat=$(( stat + val))
841 # commit on sharing tests
843 remote_mds_nodsh && skip "remote MDS with nodsh" && return
845 [ -n "$CLIENTS" ] || { skip "Need two or more clients" && return 0; }
846 [ $CLIENTCOUNT -ge 2 ] || \
847 { skip "Need two or more clients, have $CLIENTCOUNT" && return 0; }
849 local nfiles=${TEST33_NFILES:-10000}
850 local param_file=$TMP/$tfile-params
852 save_lustre_params $(comma_list $(mdts_nodes)) "mdt.*.commit_on_sharing" > $param_file
860 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
864 do_nodes $CLIENT1,$CLIENT2 "mkdir -p $DIR1/$tdir-\\\$(hostname)-$i"
866 jbdold=$(print_jbd_stat)
867 echo "=== START createmany old: $jbdold transaction"
868 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")
869 jbdnew=$(print_jbd_stat)
870 jbd=$(( jbdnew - jbdold ))
871 echo "=== END createmany new: $jbdnew transaction : $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
872 avgjbd=$(( avgjbd + jbd ))
873 avgtime=$(( avgtime + elapsed ))
875 eval cos${COS}_jbd=$((avgjbd / 3))
876 eval cos${COS}_time=$((avgtime / 3))
879 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
880 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
881 [ "$cos0_jbd" != 0 ] && echo "COS=1 vs COS=0 jbd: $((((cos1_jbd/cos0_jbd - 1)) * 100 )) %"
882 [ "$cos0_time" != 0 ] && echo "COS=1 vs COS=0 time: $((((cos1_time/cos0_time - 1)) * 100 )) %"
884 restore_lustre_params < $param_file
888 run_test 33a "commit on sharing, cross crete/delete, 2 clients, benchmark"
890 # commit on sharing tests
892 remote_mds_nodsh && skip "remote MDS with nodsh" && return
894 [ -n "$CLIENTS" ] || { skip "Need two or more clients" && return 0; }
895 [ $CLIENTCOUNT -ge 2 ] ||
896 { skip "Need two or more clients, have $CLIENTCOUNT" &&
898 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
900 local nfiles=${TEST33_NFILES:-10000}
901 local param_file=$TMP/$tfile-params
903 save_lustre_params $(comma_list $(mdts_nodes)) \
904 "mdt.*.commit_on_sharing" > $param_file
912 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
916 do_node $CLIENT1 "$LFS mkdir -i $MDTIDX -p \
917 $DIR1/$tdir-\\\$(hostname)-$i"
919 jbdold=$(print_jbd_stat)
920 echo "=== START createmany old: $jbdold transaction"
921 local elapsed=$(do_and_time "do_nodes $CLIENT1,$CLIENT2\
922 createmany -o $DIR1/$tdir-\\\$(hostname)-$i/f- \
923 -r $DIR2/$tdir-\\\$(hostname)-$i/f- $nfiles > \
925 jbdnew=$(print_jbd_stat)
926 jbd=$(( jbdnew - jbdold ))
927 echo "=== END createmany new: $jbdnew transaction : \
928 $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
929 avgjbd=$(( avgjbd + jbd ))
930 avgtime=$(( avgtime + elapsed ))
932 eval cos${COS}_jbd=$((avgjbd / 3))
933 eval cos${COS}_time=$((avgtime / 3))
936 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
937 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
938 [ "$cos0_jbd" != 0 ] &&
939 echo "COS=1 vs COS=0 jbd: $(((cos1_jbd/cos0_jbd - 1) * 100)) %"
940 [ "$cos0_time" != 0 ] &&
941 echo "COS=1 vs COS=0 time: $(((cos1_time/cos0_time - 1) * 100)) %"
943 restore_lustre_params < $param_file
947 run_test 33b "COS: cross create/delete, 2 clients, benchmark under remote dir"
949 # End commit on sharing tests
951 get_ost_lock_timeouts() {
952 local nodes=${1:-$(comma_list $(osts_nodes))}
954 local locks=$(do_nodes $nodes \
955 "lctl get_param -n ldlm.namespaces.filter-*.lock_timeouts" | calc_sum)
963 do_nodes $(comma_list $(osts_nodes)) \
964 "lctl set_param -n fail_loc=0 2>/dev/null || true"
965 for i in $(seq $OSTCOUNT); do
966 wait_osc_import_state client ost$i FULL
974 trap cleanup_34 EXIT RETURN
975 for OPER in notimeout timeout ; do
976 rm $DIR1/$tfile 2>/dev/null
977 lock_in=$(get_ost_lock_timeouts)
978 if [ $OPER == "timeout" ] ; then
979 for j in `seq $OSTCOUNT`; do
980 #define OBD_FAIL_PTLRPC_HPREQ_TIMEOUT 0x511
981 do_facet ost$j lctl set_param fail_loc=0x511
983 echo lock should expire
985 for j in `seq $OSTCOUNT`; do
986 #define OBD_FAIL_PTLRPC_HPREQ_NOTIMEOUT 0x512
987 do_facet ost$j lctl set_param fail_loc=0x512
989 echo lock should not expire
991 echo writing on client1
992 dd if=/dev/zero of=$DIR1/$tfile count=100 conv=notrunc > /dev/null 2>&1
994 echo reading on client2
995 dd of=/dev/null if=$DIR2/$tfile > /dev/null 2>&1
996 # wait for a lock timeout
998 lock_out=$(get_ost_lock_timeouts)
999 if [ $OPER == "timeout" ] ; then
1000 if [ $lock_in == $lock_out ]; then
1001 error "no lock timeout happened"
1006 if [ $lock_in != $lock_out ]; then
1007 error "lock timeout happened"
1015 run_test 34 "no lock timeout under IO"
1017 test_35() { # bug 17645
1020 for imp in /proc/fs/lustre/mdc/$FSNAME-MDT*-mdc-*; do
1021 g=$(awk '/generation/{print $2}' $imp/import)
1022 generation[count]=$g
1026 test_mkdir -p $MOUNT1/$tfile
1027 cancel_lru_locks mdc
1029 # Let's initiate -EINTR situation by setting fail_loc and take
1030 # write lock on same file from same client. This will not cause
1031 # bl_ast yet as lock is already in local cache.
1032 #define OBD_FAIL_LDLM_INTR_CP_AST 0x317
1033 do_facet client "lctl set_param fail_loc=0x80000317"
1034 local timeout=`do_facet $SINGLEMDS lctl get_param -n timeout`
1035 let timeout=timeout*3
1037 while test $nr -lt 10; do
1038 log "Race attempt $nr"
1039 local blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
1040 test "x$blk1" = "x" && blk1=0
1041 createmany -o $MOUNT2/$tfile/a 4000 &
1045 # Let's make conflict and bl_ast
1046 ls -la $MOUNT1/$tfile > /dev/null &
1049 log "Wait for $pid1 $pid2 for $timeout sec..."
1051 kill -9 $pid1 $pid2 > /dev/null 2>&1
1053 local blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
1054 test "x$blk2" = "x" && blk2=0
1055 test $blk2 -gt $blk1 && break
1056 rm -fr $MOUNT1/$tfile/*
1057 cancel_lru_locks mdc
1060 do_facet client "lctl set_param fail_loc=0x0"
1061 df -h $MOUNT1 $MOUNT2
1063 for imp in /proc/fs/lustre/mdc/$FSNAME-MDT*-mdc-*; do
1064 g=$(awk '/generation/{print $2}' $imp/import)
1065 if ! test "$g" -eq "${generation[count]}"; then
1066 error "Eviction happened on import $(basename $imp)"
1071 run_test 35 "-EINTR cp_ast vs. bl_ast race does not evict client"
1073 test_36() { #bug 16417
1078 test_mkdir -p $DIR1/$tdir
1079 $LFS setstripe -c -1 $DIR1/$tdir
1082 let SIZE_B=SIZE*1024*1024
1084 while [ $i -le 10 ]; do
1085 lctl mark "start test"
1086 local before=$($LFS df | awk '{ if ($1 ~/^filesystem/) \
1087 { print $5; exit} }')
1088 dd if=/dev/zero of=$DIR1/$tdir/$tfile bs=1M count=$SIZE ||
1089 error "dd $DIR1/$tdir/$tfile ${SIZE}MB failed"
1090 sync # sync data from client cache
1091 sync_all_data # sync data from server cache (delayed allocation)
1093 local after_dd=$($LFS df | awk '{ if ($1 ~/^filesystem/) \
1094 { print $5; exit} }')
1095 multiop_bg_pause $DIR2/$tdir/$tfile O_r${SIZE_B}c || return 3
1097 rm -f $DIR1/$tdir/$tfile
1098 kill -USR1 $read_pid
1100 wait_delete_completed
1101 local after=$($LFS df | awk '{ if ($1 ~/^filesystem/) \
1102 { print $5; exit} }')
1103 echo "*** cycle($i) *** before($before) after_dd($after_dd)" \
1105 # this free space! not used
1106 if [ $after_dd -ge $after ]; then
1107 error "space leaked"
1113 run_test 36 "handle ESTALE/open-unlink correctly"
1115 test_37() { # bug 18695
1116 test_mkdir -p $DIR1/$tdir
1117 multiop_bg_pause $DIR1/$tdir D_c || return 1
1119 # create large directory (32kB seems enough from e2fsck, ~= 1000 files)
1120 createmany -m $DIR2/$tdir/f 10000
1121 # set mtime/atime backward
1122 touch -t 198001010000 $DIR2/$tdir
1123 kill -USR1 $MULTIPID
1124 nr_files=`lfs find $DIR1/$tdir -type f | wc -l`
1125 [ $nr_files -eq 10000 ] || error "$nr_files != 10000 truncated directory?"
1128 run_test 37 "check i_size is not updated for directory on close (bug 18695) =============="
1130 # this should be set to past
1131 TEST_39_MTIME=`date -d "1 year ago" +%s`
1135 local client1=${CLIENT1:-`hostname`}
1136 local client2=${CLIENT2:-`hostname`}
1138 do_node $client1 "touch $DIR1/$tfile"
1140 do_node $client1 "touch -m -d @$TEST_39_MTIME $DIR1/$tfile"
1141 local mtime1=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1142 [ "$mtime1" = $TEST_39_MTIME ] || \
1143 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
1145 local d1=`do_node $client1 date +%s`
1146 do_node $client1 'echo hello >> '$DIR1/$tfile
1147 local d2=`do_node $client1 date +%s`
1149 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1150 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
1151 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
1153 do_node $client1 "mv $DIR1/$tfile $DIR1/$tfile-1"
1155 for (( i=0; i < 2; i++ )) ; do
1156 local mtime3=`do_node $client2 "stat -c %Y $DIR1/$tfile-1"`
1157 [ "$mtime2" = "$mtime3" ] || \
1158 error "mtime ($mtime2) changed (to $mtime3) on rename"
1160 cancel_lru_locks osc
1161 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1164 run_test 39a "test from 11063 =================================="
1167 local client1=${CLIENT1:-`hostname`}
1168 local client2=${CLIENT2:-`hostname`}
1172 local mtime1=`stat -c %Y $DIR1/$tfile`
1173 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1176 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
1178 for (( i=0; i < 2; i++ )) ; do
1179 local mtime3=`stat -c %Y $DIR1/$tfile`
1180 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1182 [ "$mtime3" = "$mtime4" ] || \
1183 error "different mtime on clients: $mtime3, $mtime4"
1184 [ "$mtime3" = $TEST_39_MTIME ] || \
1185 error "lost mtime: $mtime3, should be $TEST_39_MTIME"
1187 cancel_lru_locks osc
1188 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1191 run_test 39b "11063 problem 1 =================================="
1194 local client1=${CLIENT1:-`hostname`}
1195 local client2=${CLIENT2:-`hostname`}
1197 echo hello > $DIR1/$tfile
1199 local mtime1=`stat -c %Y $DIR1/$tfile`
1200 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1201 [ "$mtime1" = "$mtime2" ] || \
1202 error "create: different mtime on clients: $mtime1, $mtime2"
1205 $TRUNCATE $DIR1/$tfile 1
1207 for (( i=0; i < 2; i++ )) ; do
1208 local mtime3=`stat -c %Y $DIR1/$tfile`
1209 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1211 [ "$mtime3" = "$mtime4" ] || \
1212 error "different mtime on clients: $mtime3, $mtime4"
1213 [ "$mtime3" -gt $mtime2 ] || \
1214 error "truncate did not update mtime: $mtime2, $mtime3"
1216 cancel_lru_locks osc
1217 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1220 run_test 39c "check truncate mtime update ======================"
1222 # check that pid exists hence second operation wasn't blocked by first one
1223 # if it is so then there is no conflict, return 0
1224 # else second operation is conflicting with first one, return 1
1225 check_pdo_conflict() {
1228 sleep 1 # to ensure OP1 is finished on client if OP2 is blocked by OP1
1229 if [[ `ps --pid $pid | wc -l` == 1 ]]; then
1239 # test 40: check non-blocking operations
1241 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1242 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1243 mkdir $DIR1/$tfile &
1246 touch $DIR2/$tfile-2
1247 check_pdo_conflict $PID1 || error "create is blocked"
1248 mkdir $DIR2/$tfile-3
1249 check_pdo_conflict $PID1 || error "mkdir is blocked"
1250 link $DIR2/$tfile-2 $DIR2/$tfile-4
1251 check_pdo_conflict $PID1 || error "link is blocked"
1252 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1253 check_pdo_conflict $PID1 || error "rename is blocked"
1254 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1255 check_pdo_conflict $PID1 || error "getattr is blocked"
1256 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1257 rmdir $DIR2/$tfile-3
1258 check_pdo_conflict $PID1 || error "unlink is blocked"
1260 if [ $MDSCOUNT -ge 2 ]; then
1261 $LFS mkdir -i 1 $DIR2/$tfile-6
1262 check_pdo_conflict $PID1 || error "remote mkdir is blocked"
1265 # all operations above shouldn't wait the first one
1266 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1271 run_test 40a "pdirops: create vs others =============="
1274 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1275 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1276 touch $DIR1/$tfile &
1280 touch $DIR2/$tfile-2
1281 check_pdo_conflict $PID1 || error "create is blocked"
1282 mkdir $DIR2/$tfile-3
1283 check_pdo_conflict $PID1 || error "mkdir is blocked"
1284 link $DIR2/$tfile-2 $DIR2/$tfile-4
1285 check_pdo_conflict $PID1 || error "link is blocked"
1286 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1287 check_pdo_conflict $PID1 || error "rename is blocked"
1288 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1289 check_pdo_conflict $PID1 || error "getattr is blocked"
1290 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1291 rmdir $DIR2/$tfile-3
1292 check_pdo_conflict $PID1 || error "unlink is blocked"
1293 # all operations above shouldn't wait the first one
1295 if [ $MDSCOUNT -ge 2 ]; then
1296 $LFS mkdir -i 1 $DIR2/$tfile-6
1297 check_pdo_conflict $PID1 || error "remote mkdir is blocked"
1300 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1305 run_test 40b "pdirops: open|create and others =============="
1309 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1310 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1311 link $DIR1/$tfile $DIR1/$tfile-0 &
1315 touch $DIR2/$tfile-2
1316 check_pdo_conflict $PID1 || error "create is blocked"
1317 mkdir $DIR2/$tfile-3
1318 check_pdo_conflict $PID1 || error "mkdir is blocked"
1319 link $DIR2/$tfile-2 $DIR2/$tfile-4
1320 check_pdo_conflict $PID1 || error "link is blocked"
1321 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1322 check_pdo_conflict $PID1 || error "rename is blocked"
1323 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1324 check_pdo_conflict $PID1 || error "getattr is blocked"
1325 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1326 rmdir $DIR2/$tfile-3
1327 check_pdo_conflict $PID1 || error "unlink is blocked"
1329 if [ $MDSCOUNT -ge 2 ]; then
1330 $LFS mkdir -i 1 $DIR2/$tfile-6
1331 check_pdo_conflict $PID1 || error "remote mkdir is blocked"
1334 # all operations above shouldn't wait the first one
1335 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1340 run_test 40c "pdirops: link and others =============="
1344 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1345 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1350 touch $DIR2/$tfile-2
1351 check_pdo_conflict $PID1 || error "create is blocked"
1352 mkdir $DIR2/$tfile-3
1353 check_pdo_conflict $PID1 || error "mkdir is blocked"
1354 link $DIR2/$tfile-2 $DIR2/$tfile-4
1355 check_pdo_conflict $PID1 || error "link is blocked"
1356 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1357 check_pdo_conflict $PID1 || error "rename is blocked"
1358 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1359 check_pdo_conflict $PID1 || error "getattr is blocked"
1360 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1361 rmdir $DIR2/$tfile-3
1362 check_pdo_conflict $PID1 || error "unlink is blocked"
1364 if [ $MDSCOUNT -ge 2 ]; then
1365 $LFS mkdir -i 1 $DIR2/$tfile-6
1366 check_pdo_conflict $PID1 || error "remote mkdir is blocked"
1369 # all operations above shouldn't wait the first one
1370 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1374 run_test 40d "pdirops: unlink and others =============="
1378 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1379 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1380 mv $DIR1/$tfile $DIR1/$tfile-0 &
1384 touch $DIR2/$tfile-2
1385 check_pdo_conflict $PID1 || error "create is blocked"
1386 mkdir $DIR2/$tfile-3
1387 check_pdo_conflict $PID1 || error "mkdir is blocked"
1388 link $DIR2/$tfile-2 $DIR2/$tfile-4
1389 check_pdo_conflict $PID1 || error "link is blocked"
1390 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1391 check_pdo_conflict $PID1 || error "getattr is blocked"
1392 rm $DIR2/$tfile-4 $DIR2/$tfile-2
1393 rmdir $DIR2/$tfile-3
1394 check_pdo_conflict $PID1 || error "unlink is blocked"
1396 if [ $MDSCOUNT -ge 2 ]; then
1397 $LFS mkdir -i 1 $DIR2/$tfile-6
1398 check_pdo_conflict $PID1 || error "remote mkdir is blocked"
1401 # all operations above shouldn't wait the first one
1402 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1407 run_test 40e "pdirops: rename and others =============="
1409 # test 41: create blocking operations
1411 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1412 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1413 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1416 mkdir $DIR2/$tfile && error "mkdir must fail"
1417 check_pdo_conflict $PID1 && { wait $PID1; echo "mkdir isn't blocked"; }
1421 run_test 41a "pdirops: create vs mkdir =============="
1424 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1425 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1426 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1429 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1430 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1434 run_test 41b "pdirops: create vs create =============="
1437 touch $DIR1/$tfile-2
1438 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1439 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1440 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1443 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
1444 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1448 run_test 41c "pdirops: create vs link =============="
1451 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1452 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1453 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1456 rm $DIR2/$tfile || error "unlink must succeed"
1457 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1461 run_test 41d "pdirops: create vs unlink =============="
1464 touch $DIR1/$tfile-2
1465 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1466 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1467 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1470 mv $DIR2/$tfile-2 $DIR2/$tfile || error "rename must succeed"
1471 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1475 run_test 41e "pdirops: create and rename (tgt) =============="
1478 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1479 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1480 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1483 mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
1484 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1488 run_test 41f "pdirops: create and rename (src) =============="
1491 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1492 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1493 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1496 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
1497 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1501 run_test 41g "pdirops: create vs getattr =============="
1504 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1505 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1506 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1509 ls -lia $DIR2/ > /dev/null
1510 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1514 run_test 41h "pdirops: create vs readdir =============="
1516 # test 42: unlink and blocking operations
1518 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1519 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1520 mkdir $DIR1/$tfile &
1523 mkdir $DIR2/$tfile && error "mkdir must fail"
1524 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1528 run_test 42a "pdirops: mkdir vs mkdir =============="
1531 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1532 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1533 mkdir $DIR1/$tfile &
1536 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1537 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1541 run_test 42b "pdirops: mkdir vs create =============="
1544 touch $DIR1/$tfile-2
1545 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1546 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1547 mkdir $DIR1/$tfile &
1550 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
1551 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1555 run_test 42c "pdirops: mkdir vs link =============="
1558 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1559 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1560 mkdir $DIR1/$tfile &
1563 rmdir $DIR2/$tfile || error "unlink must succeed"
1564 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1568 run_test 42d "pdirops: mkdir vs unlink =============="
1571 touch $DIR1/$tfile-2
1572 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1573 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1574 mkdir $DIR1/$tfile &
1577 mv -T $DIR2/$tfile-2 $DIR2/$tfile && error "rename must fail"
1578 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1582 run_test 42e "pdirops: mkdir and rename (tgt) =============="
1585 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1586 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1587 mkdir $DIR1/$tfile &
1590 mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
1591 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1595 run_test 42f "pdirops: mkdir and rename (src) =============="
1598 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1599 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1600 mkdir $DIR1/$tfile &
1603 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
1604 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1608 run_test 42g "pdirops: mkdir vs getattr =============="
1611 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1612 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1613 mkdir $DIR1/$tfile &
1616 ls -lia $DIR2/ > /dev/null
1617 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1621 run_test 42h "pdirops: mkdir vs readdir =============="
1623 # test 43: unlink and blocking operations
1626 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1627 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1631 mkdir $DIR2/$tfile || error "mkdir must succeed"
1632 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1636 run_test 43a "pdirops: unlink vs mkdir =============="
1640 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1641 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1645 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c || error "create must succeed"
1646 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1650 run_test 43b "pdirops: unlink vs create =============="
1654 touch $DIR1/$tfile-2
1655 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1656 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1660 link $DIR2/$tfile-2 $DIR2/$tfile || error "link must succeed"
1661 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1665 run_test 43c "pdirops: unlink vs link =============="
1669 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1670 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1674 rm $DIR2/$tfile && error "unlink must fail"
1675 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1679 run_test 43d "pdirops: unlink vs unlink =============="
1683 touch $DIR1/$tfile-2
1684 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1685 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1689 mv -u $DIR2/$tfile-2 $DIR2/$tfile || error "rename must succeed"
1690 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1694 run_test 43e "pdirops: unlink and rename (tgt) =============="
1698 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1699 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1703 mv $DIR2/$tfile $DIR2/$tfile-2 && error "rename must fail"
1704 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1708 run_test 43f "pdirops: unlink and rename (src) =============="
1712 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1713 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1717 stat $DIR2/$tfile > /dev/null && error "stat must fail"
1718 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1722 run_test 43g "pdirops: unlink vs getattr =============="
1726 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1727 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1731 ls -lia $DIR2/ > /dev/null
1732 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1736 run_test 43h "pdirops: unlink vs readdir =============="
1739 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1741 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1742 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1746 $LFS mkdir -i 1 $DIR2/$tfile || error "remote mkdir must succeed"
1747 check_pdo_conflict $PID1 &&
1748 { wait $PID1; error "remote mkdir isn't blocked"; }
1752 run_test 43i "pdirops: unlink vs remote mkdir"
1754 # test 44: rename tgt and blocking operations
1756 touch $DIR1/$tfile-2
1757 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1758 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1759 mv $DIR1/$tfile-2 $DIR1/$tfile &
1762 mkdir $DIR2/$tfile && error "mkdir must fail"
1763 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1767 run_test 44a "pdirops: rename tgt vs mkdir =============="
1770 touch $DIR1/$tfile-2
1771 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1772 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1773 mv $DIR1/$tfile-2 $DIR1/$tfile &
1776 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1777 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1781 run_test 44b "pdirops: rename tgt vs create =============="
1784 touch $DIR1/$tfile-2
1785 touch $DIR1/$tfile-3
1786 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1787 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1788 mv $DIR1/$tfile-2 $DIR1/$tfile &
1791 link $DIR2/$tfile-3 $DIR2/$tfile && error "link must fail"
1792 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1796 run_test 44c "pdirops: rename tgt vs link =============="
1799 touch $DIR1/$tfile-2
1800 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1801 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1802 mv $DIR1/$tfile-2 $DIR1/$tfile &
1805 rm $DIR2/$tfile || error "unlink must succeed"
1806 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1810 run_test 44d "pdirops: rename tgt vs unlink =============="
1814 touch $DIR1/$tfile-2
1815 touch $DIR1/$tfile-3
1816 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1817 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1818 mv $DIR1/$tfile-2 $DIR1/$tfile &
1821 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
1822 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1826 run_test 44e "pdirops: rename tgt and rename (tgt) =============="
1829 touch $DIR1/$tfile-2
1830 touch $DIR1/$tfile-3
1831 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1832 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1833 mv $DIR1/$tfile-2 $DIR1/$tfile &
1836 mv $DIR2/$tfile $DIR2/$tfile-3 || error "rename must succeed"
1837 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1841 run_test 44f "pdirops: rename tgt and rename (src) =============="
1844 touch $DIR1/$tfile-2
1845 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1846 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1847 mv $DIR1/$tfile-2 $DIR1/$tfile &
1850 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
1851 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1855 run_test 44g "pdirops: rename tgt vs getattr =============="
1858 touch $DIR1/$tfile-2
1859 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1860 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1861 mv $DIR1/$tfile-2 $DIR1/$tfile &
1864 ls -lia $DIR2/ > /dev/null
1865 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1869 run_test 44h "pdirops: rename tgt vs readdir =============="
1871 # test 44: rename tgt and blocking operations
1873 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1874 touch $DIR1/$tfile-2
1875 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1876 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1877 mv $DIR1/$tfile-2 $DIR1/$tfile &
1880 $LFS mkdir -i 1 $DIR2/$tfile && error "remote mkdir must fail"
1881 check_pdo_conflict $PID1 && { wait $PID1;
1882 error "remote mkdir isn't blocked"; }
1886 run_test 44i "pdirops: rename tgt vs remote mkdir"
1888 # test 45: rename src and blocking operations
1891 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1892 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1893 mv $DIR1/$tfile $DIR1/$tfile-2 &
1896 mkdir $DIR2/$tfile || error "mkdir must succeed"
1897 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1901 run_test 45a "pdirops: rename src vs mkdir =============="
1905 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1906 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1907 mv $DIR1/$tfile $DIR1/$tfile-2 &
1910 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c || error "create must succeed"
1911 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1915 run_test 45b "pdirops: rename src vs create =============="
1919 touch $DIR1/$tfile-3
1920 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1921 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1922 mv $DIR1/$tfile $DIR1/$tfile-2 &
1925 link $DIR2/$tfile-3 $DIR2/$tfile || error "link must succeed"
1926 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1930 run_test 45c "pdirops: rename src vs link =============="
1934 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1935 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1936 mv $DIR1/$tfile $DIR1/$tfile-2 &
1939 rm $DIR2/$tfile && error "unlink must fail"
1940 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1944 run_test 45d "pdirops: rename src vs unlink =============="
1948 touch $DIR1/$tfile-3
1949 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1950 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1951 mv $DIR1/$tfile $DIR1/$tfile-2 &
1954 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
1955 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1959 run_test 45e "pdirops: rename src and rename (tgt) =============="
1963 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1964 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1965 mv $DIR1/$tfile $DIR1/$tfile-2 &
1968 mv $DIR2/$tfile $DIR2/$tfile-3 && error "rename must fail"
1969 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1973 run_test 45f "pdirops: rename src and rename (src) =============="
1977 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1978 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1979 mv $DIR1/$tfile $DIR1/$tfile-2 &
1982 stat $DIR2/$tfile > /dev/null && error "stat must fail"
1983 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1987 run_test 45g "pdirops: rename src vs getattr =============="
1991 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1992 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1993 mv $DIR1/$tfile $DIR1/$tfile-2 &
1996 ls -lia $DIR2/ > /dev/null
1997 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2001 run_test 45h "pdirops: unlink vs readdir =============="
2004 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2006 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2007 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2008 mv $DIR1/$tfile $DIR1/$tfile-2 &
2011 $LFS mkdir -i 1 $DIR2/$tfile || error "create remote dir must succeed"
2012 check_pdo_conflict $PID1 && { wait $PID1;
2013 error "create remote dir isn't blocked"; }
2017 run_test 45i "pdirops: rename src vs remote mkdir"
2019 # test 46: link and blocking operations
2021 touch $DIR1/$tfile-2
2022 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2023 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2024 link $DIR1/$tfile-2 $DIR1/$tfile &
2027 mkdir $DIR2/$tfile && error "mkdir must fail"
2028 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2032 run_test 46a "pdirops: link vs mkdir =============="
2035 touch $DIR1/$tfile-2
2036 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2037 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2038 link $DIR1/$tfile-2 $DIR1/$tfile &
2041 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
2042 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2046 run_test 46b "pdirops: link vs create =============="
2049 touch $DIR1/$tfile-2
2050 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2051 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2052 link $DIR1/$tfile-2 $DIR1/$tfile &
2055 link $DIR2/$tfile $DIR2/$tfile && error "link must fail"
2056 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2060 run_test 46c "pdirops: link vs link =============="
2063 touch $DIR1/$tfile-2
2064 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2065 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2066 link $DIR1/$tfile-2 $DIR1/$tfile &
2069 rm $DIR2/$tfile || error "unlink must succeed"
2070 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2074 run_test 46d "pdirops: link vs unlink =============="
2077 touch $DIR1/$tfile-2
2078 touch $DIR1/$tfile-3
2079 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2080 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2081 link $DIR1/$tfile-2 $DIR1/$tfile &
2084 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
2085 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2089 run_test 46e "pdirops: link and rename (tgt) =============="
2092 touch $DIR1/$tfile-2
2093 touch $DIR1/$tfile-3
2094 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2095 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2096 link $DIR1/$tfile-2 $DIR1/$tfile &
2099 mv $DIR2/$tfile $DIR2/$tfile-3 || error "rename must succeed"
2100 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2104 run_test 46f "pdirops: link and rename (src) =============="
2107 touch $DIR1/$tfile-2
2108 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2109 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2110 link $DIR1/$tfile-2 $DIR1/$tfile &
2113 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
2114 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2118 run_test 46g "pdirops: link vs getattr =============="
2121 touch $DIR1/$tfile-2
2122 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2123 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2124 link $DIR1/$tfile-2 $DIR1/$tfile &
2127 ls -lia $DIR2/ > /dev/null
2128 check_pdo_conflict $PID1 && { wait $PID1;
2129 error "readdir isn't blocked"; }
2133 run_test 46h "pdirops: link vs readdir =============="
2136 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2137 touch $DIR1/$tfile-2
2138 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2139 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2140 link $DIR1/$tfile-2 $DIR1/$tfile &
2143 $LFS mkdir -i 1 $DIR2/$tfile && error "remote mkdir must fail"
2144 check_pdo_conflict $PID1 && { wait $PID1;
2145 error "remote mkdir isn't blocked"; }
2149 run_test 46i "pdirops: link vs remote mkdir"
2151 # test 47: remote mkdir and blocking operations
2153 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2154 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2155 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2156 $LFS mkdir -i 1 $DIR1/$tfile &
2159 mkdir $DIR2/$tfile && error "mkdir must fail"
2160 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2164 run_test 47a "pdirops: remote mkdir vs mkdir"
2167 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2168 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2169 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2170 $LFS mkdir -i 1 $DIR1/$tfile &
2173 multiop $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
2174 check_pdo_conflict $PID1 && { wait $PID1;
2175 error "create isn't blocked"; }
2179 run_test 47b "pdirops: remote mkdir vs create"
2182 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2183 touch $DIR1/$tfile-2
2184 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2185 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2186 $LFS mkdir -i 1 $DIR1/$tfile &
2189 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
2190 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2194 run_test 47c "pdirops: remote mkdir vs link"
2197 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2198 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2199 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2200 $LFS mkdir -i 1 $DIR1/$tfile &
2203 rmdir $DIR2/$tfile || error "unlink must succeed"
2204 check_pdo_conflict $PID1 && { wait $PID1;
2205 error "unlink isn't blocked"; }
2209 run_test 47d "pdirops: remote mkdir vs unlink"
2212 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2213 touch $DIR1/$tfile-2
2214 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2215 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2216 $LFS mkdir -i 1 $DIR1/$tfile &
2219 mv -T $DIR2/$tfile-2 $DIR2/$tfile && error "rename must fail"
2220 check_pdo_conflict $PID1 && { wait $PID1;
2221 error "rename isn't blocked"; }
2225 run_test 47e "pdirops: remote mkdir and rename (tgt)"
2228 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2229 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2230 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2231 $LFS mkdir -i 1 $DIR1/$tfile &
2234 mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
2235 check_pdo_conflict $PID1 && { wait $PID1;
2236 error "rename isn't blocked"; }
2240 run_test 47f "pdirops: remote mkdir and rename (src)"
2243 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2244 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2245 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2246 $LFS mkdir -i 1 $DIR1/$tfile &
2249 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
2250 check_pdo_conflict $PID1 && { wait $PID1;
2251 error "getattr isn't blocked"; }
2255 run_test 47g "pdirops: remote mkdir vs getattr"
2259 dd if=/dev/zero of=$DIR1/$tfile bs=1K count=10
2260 #define OBD_FAIL_OSC_CP_ENQ_RACE 0x410
2261 do_facet client "lctl set_param fail_loc=0x410"
2262 $TRUNCATE $DIR2/$tfile $trunc_size
2263 do_facet client "lctl set_param fail_loc=0x0"
2265 size=`stat -c %s $DIR2/$tfile`
2266 [ $size -eq $trunc_size ] || error "wrong size"
2268 run_test 50 "osc lvb attrs: enqueue vs. CP AST =============="
2272 local origfile=/etc/hosts
2274 filesize=`stat -c %s $origfile`
2276 # create an empty file
2277 $MCREATE $DIR1/$tfile
2278 # cache layout lock on both mount point
2279 stat $DIR1/$tfile > /dev/null
2280 stat $DIR2/$tfile > /dev/null
2282 # open and sleep 2 seconds then read
2283 $MULTIOP $DIR2/$tfile o_2r${filesize}c &
2287 # create the layout of testing file
2288 dd if=$origfile of=$DIR1/$tfile conv=notrunc > /dev/null
2290 # MULTIOP proc should be able to read enough bytes and exit
2292 kill -0 $pid && error "multiop is still there"
2293 cmp $origfile $DIR2/$tfile || error "$MCREATE and $DIR2/$tfile differs"
2297 run_test 51a "layout lock: refresh layout should work"
2300 local tmpfile=`mktemp`
2302 # create an empty file
2303 $MCREATE $DIR1/$tfile
2305 # delay glimpse so that layout has changed when glimpse finish
2306 #define OBD_FAIL_GLIMPSE_DELAY 0x1404
2307 $LCTL set_param fail_loc=0x1404
2308 stat -c %s $DIR2/$tfile |tee $tmpfile &
2312 # create layout of testing file
2313 dd if=/dev/zero of=$DIR1/$tfile bs=1k count=1 conv=notrunc > /dev/null
2316 local fsize=`cat $tmpfile`
2318 [ x$fsize = x1024 ] || error "file size is $fsize, should be 1024"
2320 rm -f $DIR1/$tfile $tmpfile
2322 run_test 51b "layout lock: glimpse should be able to restart if layout changed"
2325 # create an empty file
2326 $MCREATE $DIR1/$tfile
2328 #define OBD_FAIL_MDS_LL_BLOCK 0x172
2329 $LCTL set_param fail_loc=0x172
2331 # change the layout of testing file
2332 echo "Setting layout ..."
2333 $LFS setstripe -c $OSTCOUNT $DIR1/$tfile &
2337 # get layout of this file should wait until dd is finished
2338 local stripecnt=`$LFS getstripe -c $DIR2/$tfile`
2339 [ $stripecnt -eq $OSTCOUNT ] || error "layout wrong"
2343 run_test 51c "layout lock: IT_LAYOUT blocked and correct layout can be returned"
2346 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.0) ]] ||
2347 { skip "Need MDS version at least 2.3.0"; return; }
2349 test_mkdir -p $DIR1/$tdir
2350 file1=$DIR1/$tdir/file
2351 file2=$DIR2/$tdir/file
2353 echo orig > $file2 || error "Could not create $file2"
2354 version=$($LFS data_version $file1)
2357 echo append >> $file2 || error "Could not append to $file2"
2358 version2=$($LFS data_version $file1)
2359 [ "$version" != "$version2" ] ||
2360 error "append did not change data version: $version"
2363 echo overwrite > $file2 || error "Could not overwrite $file2"
2364 version3=$($LFS data_version $file1)
2365 [ "$version2" != "$version3" ] ||
2366 error "overwrite did not change data version: $version2"
2368 # Truncate before EOF
2369 $TRUNCATE $file2 3 || error "Could not truncate $file2"
2370 version4=$($LFS data_version $file1)
2371 [ "$version3" != "$version4" ] ||
2372 error "truncate did not change data version: $version3"
2374 # Truncate after EOF
2375 $TRUNCATE $file2 123456 || error "Could not truncate $file2"
2376 version5=$($LFS data_version $file1)
2377 [ "$version4" != "$version5" ] ||
2378 error "truncate did not change data version: $version4"
2380 # Chmod do not change version
2381 chmod 400 $file2 || error "Could not chmod 400 $file2"
2382 version6=$($LFS data_version $file1)
2383 [ "$version5" == "$version6" ] ||
2384 error "chmod should not change data version: $version5 != $version6"
2386 # Chown do not change version
2387 chown $RUNAS_ID $file2 || error "Could not chown $RUNAS_ID $file2"
2388 version7=$($LFS data_version $file1)
2389 [ "$version5" == "$version7" ] ||
2390 error "chown should not change data version: $version5 != $version7"
2392 run_test 60 "Verify data_version behaviour"
2395 local test_dir=$tdir/test_dir
2397 mkdir -p $DIR1/$tdir
2398 if [ $MDSCOUNT -ge 2 ]; then
2400 $LFS mkdir -i $MDTIDX $DIR1/$test_dir ||
2401 error "Create remote directory failed"
2403 mkdir -p $DIR1/$test_dir
2405 cd $DIR2/$test_dir || error "cd directory failed"
2406 rm -rf $DIR1/$test_dir || error "unlink directory failed"
2408 cd $DIR2/$tdir || error "exit directory"
2410 run_test 70 "cd directory && rm directory"
2412 log "cleanup: ======================================================"
2414 [ "$(mount | grep $MOUNT2)" ] && umount $MOUNT2
2417 check_and_cleanup_lustre