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)
964 for OPER in notimeout timeout ; do
965 rm $DIR1/$tfile 2>/dev/null
966 lock_in=$(get_ost_lock_timeouts)
967 if [ $OPER == "timeout" ] ; then
968 for j in `seq $OSTCOUNT`; do
969 #define OBD_FAIL_PTLRPC_HPREQ_TIMEOUT 0x511
970 do_facet ost$j lctl set_param fail_loc=0x511
972 echo lock should expire
974 for j in `seq $OSTCOUNT`; do
975 #define OBD_FAIL_PTLRPC_HPREQ_NOTIMEOUT 0x512
976 do_facet ost$j lctl set_param fail_loc=0x512
978 echo lock should not expire
980 echo writing on client1
981 dd if=/dev/zero of=$DIR1/$tfile count=100 conv=notrunc > /dev/null 2>&1
983 echo reading on client2
984 dd of=/dev/null if=$DIR2/$tfile > /dev/null 2>&1
985 # wait for a lock timeout
987 lock_out=$(get_ost_lock_timeouts)
988 if [ $OPER == "timeout" ] ; then
989 if [ $lock_in == $lock_out ]; then
990 error "no lock timeout happened"
995 if [ $lock_in != $lock_out ]; then
996 error "lock timeout happened"
1003 run_test 34 "no lock timeout under IO"
1005 test_35() { # bug 17645
1008 for imp in /proc/fs/lustre/mdc/$FSNAME-MDT*-mdc-*; do
1009 g=$(awk '/generation/{print $2}' $imp/import)
1010 generation[count]=$g
1014 test_mkdir -p $MOUNT1/$tfile
1015 cancel_lru_locks mdc
1017 # Let's initiate -EINTR situation by setting fail_loc and take
1018 # write lock on same file from same client. This will not cause
1019 # bl_ast yet as lock is already in local cache.
1020 #define OBD_FAIL_LDLM_INTR_CP_AST 0x317
1021 do_facet client "lctl set_param fail_loc=0x80000317"
1022 local timeout=`do_facet $SINGLEMDS lctl get_param -n timeout`
1023 let timeout=timeout*3
1025 while test $nr -lt 10; do
1026 log "Race attempt $nr"
1027 local blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
1028 test "x$blk1" = "x" && blk1=0
1029 createmany -o $MOUNT2/$tfile/a 4000 &
1033 # Let's make conflict and bl_ast
1034 ls -la $MOUNT1/$tfile > /dev/null &
1037 log "Wait for $pid1 $pid2 for $timeout sec..."
1039 kill -9 $pid1 $pid2 > /dev/null 2>&1
1041 local blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
1042 test "x$blk2" = "x" && blk2=0
1043 test $blk2 -gt $blk1 && break
1044 rm -fr $MOUNT1/$tfile/*
1045 cancel_lru_locks mdc
1048 do_facet client "lctl set_param fail_loc=0x0"
1049 df -h $MOUNT1 $MOUNT2
1051 for imp in /proc/fs/lustre/mdc/$FSNAME-MDT*-mdc-*; do
1052 g=$(awk '/generation/{print $2}' $imp/import)
1053 if ! test "$g" -eq "${generation[count]}"; then
1054 error "Eviction happened on import $(basename $imp)"
1059 run_test 35 "-EINTR cp_ast vs. bl_ast race does not evict client"
1061 test_36() { #bug 16417
1066 test_mkdir -p $DIR1/$tdir
1067 $LFS setstripe -c -1 $DIR1/$tdir
1070 let SIZE_B=SIZE*1024*1024
1072 while [ $i -le 10 ]; do
1073 lctl mark "start test"
1074 local before=$($LFS df | awk '{ if ($1 ~/^filesystem/) \
1075 { print $5; exit} }')
1076 dd if=/dev/zero of=$DIR1/$tdir/$tfile bs=1M count=$SIZE ||
1077 error "dd $DIR1/$tdir/$tfile ${SIZE}MB failed"
1078 sync # sync data from client cache
1079 sync_all_data # sync data from server cache (delayed allocation)
1081 local after_dd=$($LFS df | awk '{ if ($1 ~/^filesystem/) \
1082 { print $5; exit} }')
1083 multiop_bg_pause $DIR2/$tdir/$tfile O_r${SIZE_B}c || return 3
1085 rm -f $DIR1/$tdir/$tfile
1086 kill -USR1 $read_pid
1088 wait_delete_completed
1089 local after=$($LFS df | awk '{ if ($1 ~/^filesystem/) \
1090 { print $5; exit} }')
1091 echo "*** cycle($i) *** before($before) after_dd($after_dd)" \
1093 # this free space! not used
1094 if [ $after_dd -ge $after ]; then
1095 error "space leaked"
1101 run_test 36 "handle ESTALE/open-unlink correctly"
1103 test_37() { # bug 18695
1104 test_mkdir -p $DIR1/$tdir
1105 multiop_bg_pause $DIR1/$tdir D_c || return 1
1107 # create large directory (32kB seems enough from e2fsck, ~= 1000 files)
1108 createmany -m $DIR2/$tdir/f 10000
1109 # set mtime/atime backward
1110 touch -t 198001010000 $DIR2/$tdir
1111 kill -USR1 $MULTIPID
1112 nr_files=`lfs find $DIR1/$tdir -type f | wc -l`
1113 [ $nr_files -eq 10000 ] || error "$nr_files != 10000 truncated directory?"
1116 run_test 37 "check i_size is not updated for directory on close (bug 18695) =============="
1118 # this should be set to past
1119 TEST_39_MTIME=`date -d "1 year ago" +%s`
1123 local client1=${CLIENT1:-`hostname`}
1124 local client2=${CLIENT2:-`hostname`}
1126 do_node $client1 "touch $DIR1/$tfile"
1128 do_node $client1 "touch -m -d @$TEST_39_MTIME $DIR1/$tfile"
1129 local mtime1=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1130 [ "$mtime1" = $TEST_39_MTIME ] || \
1131 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
1133 local d1=`do_node $client1 date +%s`
1134 do_node $client1 'echo hello >> '$DIR1/$tfile
1135 local d2=`do_node $client1 date +%s`
1137 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1138 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
1139 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
1141 do_node $client1 "mv $DIR1/$tfile $DIR1/$tfile-1"
1143 for (( i=0; i < 2; i++ )) ; do
1144 local mtime3=`do_node $client2 "stat -c %Y $DIR1/$tfile-1"`
1145 [ "$mtime2" = "$mtime3" ] || \
1146 error "mtime ($mtime2) changed (to $mtime3) on rename"
1148 cancel_lru_locks osc
1149 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1152 run_test 39a "test from 11063 =================================="
1155 local client1=${CLIENT1:-`hostname`}
1156 local client2=${CLIENT2:-`hostname`}
1160 local mtime1=`stat -c %Y $DIR1/$tfile`
1161 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1164 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
1166 for (( i=0; i < 2; i++ )) ; do
1167 local mtime3=`stat -c %Y $DIR1/$tfile`
1168 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1170 [ "$mtime3" = "$mtime4" ] || \
1171 error "different mtime on clients: $mtime3, $mtime4"
1172 [ "$mtime3" = $TEST_39_MTIME ] || \
1173 error "lost mtime: $mtime3, should be $TEST_39_MTIME"
1175 cancel_lru_locks osc
1176 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1179 run_test 39b "11063 problem 1 =================================="
1182 local client1=${CLIENT1:-`hostname`}
1183 local client2=${CLIENT2:-`hostname`}
1185 echo hello > $DIR1/$tfile
1187 local mtime1=`stat -c %Y $DIR1/$tfile`
1188 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1189 [ "$mtime1" = "$mtime2" ] || \
1190 error "create: different mtime on clients: $mtime1, $mtime2"
1193 $TRUNCATE $DIR1/$tfile 1
1195 for (( i=0; i < 2; i++ )) ; do
1196 local mtime3=`stat -c %Y $DIR1/$tfile`
1197 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1199 [ "$mtime3" = "$mtime4" ] || \
1200 error "different mtime on clients: $mtime3, $mtime4"
1201 [ "$mtime3" -gt $mtime2 ] || \
1202 error "truncate did not update mtime: $mtime2, $mtime3"
1204 cancel_lru_locks osc
1205 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1208 run_test 39c "check truncate mtime update ======================"
1210 # check that pid exists hence second operation wasn't blocked by first one
1211 # if it is so then there is no conflict, return 0
1212 # else second operation is conflicting with first one, return 1
1213 check_pdo_conflict() {
1216 sleep 1 # to ensure OP1 is finished on client if OP2 is blocked by OP1
1217 if [[ `ps --pid $pid | wc -l` == 1 ]]; then
1227 # test 40: check non-blocking operations
1229 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1230 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1231 mkdir $DIR1/$tfile &
1234 touch $DIR2/$tfile-2
1235 check_pdo_conflict $PID1 || error "create is blocked"
1236 mkdir $DIR2/$tfile-3
1237 check_pdo_conflict $PID1 || error "mkdir is blocked"
1238 link $DIR2/$tfile-2 $DIR2/$tfile-4
1239 check_pdo_conflict $PID1 || error "link is blocked"
1240 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1241 check_pdo_conflict $PID1 || error "rename is blocked"
1242 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1243 check_pdo_conflict $PID1 || error "getattr is blocked"
1244 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1245 rmdir $DIR2/$tfile-3
1246 check_pdo_conflict $PID1 || error "unlink is blocked"
1248 if [ $MDSCOUNT -ge 2 ]; then
1249 $LFS mkdir -i 1 $DIR2/$tfile-6
1250 check_pdo_conflict $PID1 || error "remote mkdir is blocked"
1253 # all operations above shouldn't wait the first one
1254 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1259 run_test 40a "pdirops: create vs others =============="
1262 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1263 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1264 touch $DIR1/$tfile &
1268 touch $DIR2/$tfile-2
1269 check_pdo_conflict $PID1 || error "create is blocked"
1270 mkdir $DIR2/$tfile-3
1271 check_pdo_conflict $PID1 || error "mkdir is blocked"
1272 link $DIR2/$tfile-2 $DIR2/$tfile-4
1273 check_pdo_conflict $PID1 || error "link is blocked"
1274 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1275 check_pdo_conflict $PID1 || error "rename is blocked"
1276 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1277 check_pdo_conflict $PID1 || error "getattr is blocked"
1278 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1279 rmdir $DIR2/$tfile-3
1280 check_pdo_conflict $PID1 || error "unlink is blocked"
1281 # all operations above shouldn't wait the first one
1283 if [ $MDSCOUNT -ge 2 ]; then
1284 $LFS mkdir -i 1 $DIR2/$tfile-6
1285 check_pdo_conflict $PID1 || error "remote mkdir is blocked"
1288 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1293 run_test 40b "pdirops: open|create and others =============="
1297 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1298 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1299 link $DIR1/$tfile $DIR1/$tfile-0 &
1303 touch $DIR2/$tfile-2
1304 check_pdo_conflict $PID1 || error "create is blocked"
1305 mkdir $DIR2/$tfile-3
1306 check_pdo_conflict $PID1 || error "mkdir is blocked"
1307 link $DIR2/$tfile-2 $DIR2/$tfile-4
1308 check_pdo_conflict $PID1 || error "link is blocked"
1309 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1310 check_pdo_conflict $PID1 || error "rename is blocked"
1311 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1312 check_pdo_conflict $PID1 || error "getattr is blocked"
1313 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1314 rmdir $DIR2/$tfile-3
1315 check_pdo_conflict $PID1 || error "unlink is blocked"
1317 if [ $MDSCOUNT -ge 2 ]; then
1318 $LFS mkdir -i 1 $DIR2/$tfile-6
1319 check_pdo_conflict $PID1 || error "remote mkdir is blocked"
1322 # all operations above shouldn't wait the first one
1323 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1328 run_test 40c "pdirops: link and others =============="
1332 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1333 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1338 touch $DIR2/$tfile-2
1339 check_pdo_conflict $PID1 || error "create is blocked"
1340 mkdir $DIR2/$tfile-3
1341 check_pdo_conflict $PID1 || error "mkdir is blocked"
1342 link $DIR2/$tfile-2 $DIR2/$tfile-4
1343 check_pdo_conflict $PID1 || error "link is blocked"
1344 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1345 check_pdo_conflict $PID1 || error "rename is blocked"
1346 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1347 check_pdo_conflict $PID1 || error "getattr is blocked"
1348 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1349 rmdir $DIR2/$tfile-3
1350 check_pdo_conflict $PID1 || error "unlink is blocked"
1352 if [ $MDSCOUNT -ge 2 ]; then
1353 $LFS mkdir -i 1 $DIR2/$tfile-6
1354 check_pdo_conflict $PID1 || error "remote mkdir is blocked"
1357 # all operations above shouldn't wait the first one
1358 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1362 run_test 40d "pdirops: unlink and others =============="
1366 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1367 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1368 mv $DIR1/$tfile $DIR1/$tfile-0 &
1372 touch $DIR2/$tfile-2
1373 check_pdo_conflict $PID1 || error "create is blocked"
1374 mkdir $DIR2/$tfile-3
1375 check_pdo_conflict $PID1 || error "mkdir is blocked"
1376 link $DIR2/$tfile-2 $DIR2/$tfile-4
1377 check_pdo_conflict $PID1 || error "link is blocked"
1378 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1379 check_pdo_conflict $PID1 || error "getattr is blocked"
1380 rm $DIR2/$tfile-4 $DIR2/$tfile-2
1381 rmdir $DIR2/$tfile-3
1382 check_pdo_conflict $PID1 || error "unlink is blocked"
1384 if [ $MDSCOUNT -ge 2 ]; then
1385 $LFS mkdir -i 1 $DIR2/$tfile-6
1386 check_pdo_conflict $PID1 || error "remote mkdir is blocked"
1389 # all operations above shouldn't wait the first one
1390 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1395 run_test 40e "pdirops: rename and others =============="
1397 # test 41: create blocking operations
1399 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1400 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1401 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1404 mkdir $DIR2/$tfile && error "mkdir must fail"
1405 check_pdo_conflict $PID1 && { wait $PID1; echo "mkdir isn't blocked"; }
1409 run_test 41a "pdirops: create vs mkdir =============="
1412 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1413 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1414 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1417 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1418 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1422 run_test 41b "pdirops: create vs create =============="
1425 touch $DIR1/$tfile-2
1426 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1427 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1428 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1431 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
1432 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1436 run_test 41c "pdirops: create vs link =============="
1439 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1440 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1441 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1444 rm $DIR2/$tfile || error "unlink must succeed"
1445 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1449 run_test 41d "pdirops: create vs unlink =============="
1452 touch $DIR1/$tfile-2
1453 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1454 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1455 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1458 mv $DIR2/$tfile-2 $DIR2/$tfile || error "rename must succeed"
1459 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1463 run_test 41e "pdirops: create and rename (tgt) =============="
1466 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1467 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1468 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1471 mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
1472 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1476 run_test 41f "pdirops: create and rename (src) =============="
1479 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1480 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1481 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1484 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
1485 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1489 run_test 41g "pdirops: create vs getattr =============="
1492 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1493 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1494 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1497 ls -lia $DIR2/ > /dev/null
1498 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1502 run_test 41h "pdirops: create vs readdir =============="
1504 # test 42: unlink and blocking operations
1506 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1507 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1508 mkdir $DIR1/$tfile &
1511 mkdir $DIR2/$tfile && error "mkdir must fail"
1512 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1516 run_test 42a "pdirops: mkdir vs mkdir =============="
1519 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1520 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1521 mkdir $DIR1/$tfile &
1524 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1525 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1529 run_test 42b "pdirops: mkdir vs create =============="
1532 touch $DIR1/$tfile-2
1533 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1534 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1535 mkdir $DIR1/$tfile &
1538 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
1539 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1543 run_test 42c "pdirops: mkdir vs link =============="
1546 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1547 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1548 mkdir $DIR1/$tfile &
1551 rmdir $DIR2/$tfile || error "unlink must succeed"
1552 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1556 run_test 42d "pdirops: mkdir vs unlink =============="
1559 touch $DIR1/$tfile-2
1560 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1561 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1562 mkdir $DIR1/$tfile &
1565 mv -T $DIR2/$tfile-2 $DIR2/$tfile && error "rename must fail"
1566 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1570 run_test 42e "pdirops: mkdir and rename (tgt) =============="
1573 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1574 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1575 mkdir $DIR1/$tfile &
1578 mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
1579 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1583 run_test 42f "pdirops: mkdir and rename (src) =============="
1586 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1587 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1588 mkdir $DIR1/$tfile &
1591 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
1592 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1596 run_test 42g "pdirops: mkdir vs getattr =============="
1599 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1600 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1601 mkdir $DIR1/$tfile &
1604 ls -lia $DIR2/ > /dev/null
1605 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1609 run_test 42h "pdirops: mkdir vs readdir =============="
1611 # test 43: unlink and blocking operations
1614 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1615 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1619 mkdir $DIR2/$tfile || error "mkdir must succeed"
1620 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1624 run_test 43a "pdirops: unlink vs mkdir =============="
1628 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1629 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1633 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c || error "create must succeed"
1634 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1638 run_test 43b "pdirops: unlink vs create =============="
1642 touch $DIR1/$tfile-2
1643 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1644 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1648 link $DIR2/$tfile-2 $DIR2/$tfile || error "link must succeed"
1649 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1653 run_test 43c "pdirops: unlink vs link =============="
1657 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1658 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1662 rm $DIR2/$tfile && error "unlink must fail"
1663 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1667 run_test 43d "pdirops: unlink vs unlink =============="
1671 touch $DIR1/$tfile-2
1672 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1673 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1677 mv -u $DIR2/$tfile-2 $DIR2/$tfile || error "rename must succeed"
1678 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1682 run_test 43e "pdirops: unlink and rename (tgt) =============="
1686 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1687 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1691 mv $DIR2/$tfile $DIR2/$tfile-2 && error "rename must fail"
1692 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1696 run_test 43f "pdirops: unlink and rename (src) =============="
1700 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1701 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1705 stat $DIR2/$tfile > /dev/null && error "stat must fail"
1706 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1710 run_test 43g "pdirops: unlink vs getattr =============="
1714 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1715 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1719 ls -lia $DIR2/ > /dev/null
1720 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1724 run_test 43h "pdirops: unlink vs readdir =============="
1727 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1729 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1730 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1734 $LFS mkdir -i 1 $DIR2/$tfile || error "remote mkdir must succeed"
1735 check_pdo_conflict $PID1 &&
1736 { wait $PID1; error "remote mkdir isn't blocked"; }
1740 run_test 43i "pdirops: unlink vs remote mkdir"
1742 # test 44: rename tgt and blocking operations
1744 touch $DIR1/$tfile-2
1745 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1746 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1747 mv $DIR1/$tfile-2 $DIR1/$tfile &
1750 mkdir $DIR2/$tfile && error "mkdir must fail"
1751 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1755 run_test 44a "pdirops: rename tgt vs mkdir =============="
1758 touch $DIR1/$tfile-2
1759 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1760 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1761 mv $DIR1/$tfile-2 $DIR1/$tfile &
1764 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1765 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1769 run_test 44b "pdirops: rename tgt vs create =============="
1772 touch $DIR1/$tfile-2
1773 touch $DIR1/$tfile-3
1774 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1775 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1776 mv $DIR1/$tfile-2 $DIR1/$tfile &
1779 link $DIR2/$tfile-3 $DIR2/$tfile && error "link must fail"
1780 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1784 run_test 44c "pdirops: rename tgt vs link =============="
1787 touch $DIR1/$tfile-2
1788 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1789 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1790 mv $DIR1/$tfile-2 $DIR1/$tfile &
1793 rm $DIR2/$tfile || error "unlink must succeed"
1794 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1798 run_test 44d "pdirops: rename tgt vs unlink =============="
1802 touch $DIR1/$tfile-2
1803 touch $DIR1/$tfile-3
1804 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1805 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1806 mv $DIR1/$tfile-2 $DIR1/$tfile &
1809 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
1810 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1814 run_test 44e "pdirops: rename tgt and rename (tgt) =============="
1817 touch $DIR1/$tfile-2
1818 touch $DIR1/$tfile-3
1819 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1820 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1821 mv $DIR1/$tfile-2 $DIR1/$tfile &
1824 mv $DIR2/$tfile $DIR2/$tfile-3 || error "rename must succeed"
1825 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1829 run_test 44f "pdirops: rename tgt and rename (src) =============="
1832 touch $DIR1/$tfile-2
1833 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1834 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1835 mv $DIR1/$tfile-2 $DIR1/$tfile &
1838 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
1839 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1843 run_test 44g "pdirops: rename tgt vs getattr =============="
1846 touch $DIR1/$tfile-2
1847 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1848 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1849 mv $DIR1/$tfile-2 $DIR1/$tfile &
1852 ls -lia $DIR2/ > /dev/null
1853 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1857 run_test 44h "pdirops: rename tgt vs readdir =============="
1859 # test 44: rename tgt and blocking operations
1861 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1862 touch $DIR1/$tfile-2
1863 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1864 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1865 mv $DIR1/$tfile-2 $DIR1/$tfile &
1868 $LFS mkdir -i 1 $DIR2/$tfile && error "remote mkdir must fail"
1869 check_pdo_conflict $PID1 && { wait $PID1;
1870 error "remote mkdir isn't blocked"; }
1874 run_test 44i "pdirops: rename tgt vs remote mkdir"
1876 # test 45: rename src and blocking operations
1879 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1880 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1881 mv $DIR1/$tfile $DIR1/$tfile-2 &
1884 mkdir $DIR2/$tfile || error "mkdir must succeed"
1885 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1889 run_test 45a "pdirops: rename src vs mkdir =============="
1893 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1894 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1895 mv $DIR1/$tfile $DIR1/$tfile-2 &
1898 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c || error "create must succeed"
1899 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1903 run_test 45b "pdirops: rename src vs create =============="
1907 touch $DIR1/$tfile-3
1908 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1909 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1910 mv $DIR1/$tfile $DIR1/$tfile-2 &
1913 link $DIR2/$tfile-3 $DIR2/$tfile || error "link must succeed"
1914 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1918 run_test 45c "pdirops: rename src vs link =============="
1922 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1923 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1924 mv $DIR1/$tfile $DIR1/$tfile-2 &
1927 rm $DIR2/$tfile && error "unlink must fail"
1928 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1932 run_test 45d "pdirops: rename src vs unlink =============="
1936 touch $DIR1/$tfile-3
1937 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1938 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1939 mv $DIR1/$tfile $DIR1/$tfile-2 &
1942 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
1943 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1947 run_test 45e "pdirops: rename src and rename (tgt) =============="
1951 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1952 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1953 mv $DIR1/$tfile $DIR1/$tfile-2 &
1956 mv $DIR2/$tfile $DIR2/$tfile-3 && error "rename must fail"
1957 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1961 run_test 45f "pdirops: rename src and rename (src) =============="
1965 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1966 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1967 mv $DIR1/$tfile $DIR1/$tfile-2 &
1970 stat $DIR2/$tfile > /dev/null && error "stat must fail"
1971 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1975 run_test 45g "pdirops: rename src vs getattr =============="
1979 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1980 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1981 mv $DIR1/$tfile $DIR1/$tfile-2 &
1984 ls -lia $DIR2/ > /dev/null
1985 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1989 run_test 45h "pdirops: unlink vs readdir =============="
1992 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1994 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1995 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1996 mv $DIR1/$tfile $DIR1/$tfile-2 &
1999 $LFS mkdir -i 1 $DIR2/$tfile || error "create remote dir must succeed"
2000 check_pdo_conflict $PID1 && { wait $PID1;
2001 error "create remote dir isn't blocked"; }
2005 run_test 45i "pdirops: rename src vs remote mkdir"
2007 # test 46: link and blocking operations
2009 touch $DIR1/$tfile-2
2010 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2011 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2012 link $DIR1/$tfile-2 $DIR1/$tfile &
2015 mkdir $DIR2/$tfile && error "mkdir must fail"
2016 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2020 run_test 46a "pdirops: link vs mkdir =============="
2023 touch $DIR1/$tfile-2
2024 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2025 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2026 link $DIR1/$tfile-2 $DIR1/$tfile &
2029 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
2030 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2034 run_test 46b "pdirops: link vs create =============="
2037 touch $DIR1/$tfile-2
2038 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2039 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2040 link $DIR1/$tfile-2 $DIR1/$tfile &
2043 link $DIR2/$tfile $DIR2/$tfile && error "link must fail"
2044 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2048 run_test 46c "pdirops: link vs link =============="
2051 touch $DIR1/$tfile-2
2052 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2053 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2054 link $DIR1/$tfile-2 $DIR1/$tfile &
2057 rm $DIR2/$tfile || error "unlink must succeed"
2058 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2062 run_test 46d "pdirops: link vs unlink =============="
2065 touch $DIR1/$tfile-2
2066 touch $DIR1/$tfile-3
2067 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2068 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2069 link $DIR1/$tfile-2 $DIR1/$tfile &
2072 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
2073 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2077 run_test 46e "pdirops: link and rename (tgt) =============="
2080 touch $DIR1/$tfile-2
2081 touch $DIR1/$tfile-3
2082 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2083 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2084 link $DIR1/$tfile-2 $DIR1/$tfile &
2087 mv $DIR2/$tfile $DIR2/$tfile-3 || error "rename must succeed"
2088 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2092 run_test 46f "pdirops: link and rename (src) =============="
2095 touch $DIR1/$tfile-2
2096 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2097 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2098 link $DIR1/$tfile-2 $DIR1/$tfile &
2101 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
2102 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2106 run_test 46g "pdirops: link vs getattr =============="
2109 touch $DIR1/$tfile-2
2110 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2111 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2112 link $DIR1/$tfile-2 $DIR1/$tfile &
2115 ls -lia $DIR2/ > /dev/null
2116 check_pdo_conflict $PID1 && { wait $PID1;
2117 error "readdir isn't blocked"; }
2121 run_test 46h "pdirops: link vs readdir =============="
2124 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2125 touch $DIR1/$tfile-2
2126 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2127 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2128 link $DIR1/$tfile-2 $DIR1/$tfile &
2131 $LFS mkdir -i 1 $DIR2/$tfile && error "remote mkdir must fail"
2132 check_pdo_conflict $PID1 && { wait $PID1;
2133 error "remote mkdir isn't blocked"; }
2137 run_test 46i "pdirops: link vs remote mkdir"
2139 # test 47: remote mkdir and blocking operations
2141 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2142 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2143 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2144 $LFS mkdir -i 1 $DIR1/$tfile &
2147 mkdir $DIR2/$tfile && error "mkdir must fail"
2148 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2152 run_test 47a "pdirops: remote mkdir vs mkdir"
2155 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2156 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2157 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2158 $LFS mkdir -i 1 $DIR1/$tfile &
2161 multiop $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
2162 check_pdo_conflict $PID1 && { wait $PID1;
2163 error "create isn't blocked"; }
2167 run_test 47b "pdirops: remote mkdir vs create"
2170 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2171 touch $DIR1/$tfile-2
2172 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2173 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2174 $LFS mkdir -i 1 $DIR1/$tfile &
2177 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
2178 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2182 run_test 47c "pdirops: remote mkdir vs link"
2185 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2186 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2187 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2188 $LFS mkdir -i 1 $DIR1/$tfile &
2191 rmdir $DIR2/$tfile || error "unlink must succeed"
2192 check_pdo_conflict $PID1 && { wait $PID1;
2193 error "unlink isn't blocked"; }
2197 run_test 47d "pdirops: remote mkdir vs unlink"
2200 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2201 touch $DIR1/$tfile-2
2202 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2203 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2204 $LFS mkdir -i 1 $DIR1/$tfile &
2207 mv -T $DIR2/$tfile-2 $DIR2/$tfile && error "rename must fail"
2208 check_pdo_conflict $PID1 && { wait $PID1;
2209 error "rename isn't blocked"; }
2213 run_test 47e "pdirops: remote mkdir and rename (tgt)"
2216 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2217 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2218 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2219 $LFS mkdir -i 1 $DIR1/$tfile &
2222 mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
2223 check_pdo_conflict $PID1 && { wait $PID1;
2224 error "rename isn't blocked"; }
2228 run_test 47f "pdirops: remote mkdir and rename (src)"
2231 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2232 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2233 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2234 $LFS mkdir -i 1 $DIR1/$tfile &
2237 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
2238 check_pdo_conflict $PID1 && { wait $PID1;
2239 error "getattr isn't blocked"; }
2243 run_test 47g "pdirops: remote mkdir vs getattr"
2247 dd if=/dev/zero of=$DIR1/$tfile bs=1K count=10
2248 #define OBD_FAIL_OSC_CP_ENQ_RACE 0x410
2249 do_facet client "lctl set_param fail_loc=0x410"
2250 $TRUNCATE $DIR2/$tfile $trunc_size
2251 do_facet client "lctl set_param fail_loc=0x0"
2253 size=`stat -c %s $DIR2/$tfile`
2254 [ $size -eq $trunc_size ] || error "wrong size"
2256 run_test 50 "osc lvb attrs: enqueue vs. CP AST =============="
2260 local origfile=/etc/hosts
2262 filesize=`stat -c %s $origfile`
2264 # create an empty file
2265 $MCREATE $DIR1/$tfile
2266 # cache layout lock on both mount point
2267 stat $DIR1/$tfile > /dev/null
2268 stat $DIR2/$tfile > /dev/null
2270 # open and sleep 2 seconds then read
2271 $MULTIOP $DIR2/$tfile o_2r${filesize}c &
2275 # create the layout of testing file
2276 dd if=$origfile of=$DIR1/$tfile conv=notrunc > /dev/null
2278 # MULTIOP proc should be able to read enough bytes and exit
2280 kill -0 $pid && error "multiop is still there"
2281 cmp $origfile $DIR2/$tfile || error "$MCREATE and $DIR2/$tfile differs"
2285 run_test 51a "layout lock: refresh layout should work"
2288 local tmpfile=`mktemp`
2290 # create an empty file
2291 $MCREATE $DIR1/$tfile
2293 # delay glimpse so that layout has changed when glimpse finish
2294 #define OBD_FAIL_GLIMPSE_DELAY 0x1404
2295 $LCTL set_param fail_loc=0x1404
2296 stat -c %s $DIR2/$tfile |tee $tmpfile &
2300 # create layout of testing file
2301 dd if=/dev/zero of=$DIR1/$tfile bs=1k count=1 conv=notrunc > /dev/null
2304 local fsize=`cat $tmpfile`
2306 [ x$fsize = x1024 ] || error "file size is $fsize, should be 1024"
2308 rm -f $DIR1/$tfile $tmpfile
2310 run_test 51b "layout lock: glimpse should be able to restart if layout changed"
2313 # create an empty file
2314 $MCREATE $DIR1/$tfile
2316 #define OBD_FAIL_MDS_LL_BLOCK 0x172
2317 $LCTL set_param fail_loc=0x172
2319 # change the layout of testing file
2320 echo "Setting layout ..."
2321 $LFS setstripe -c $OSTCOUNT $DIR1/$tfile &
2325 # get layout of this file should wait until dd is finished
2326 local stripecnt=`$LFS getstripe -c $DIR2/$tfile`
2327 [ $stripecnt -eq $OSTCOUNT ] || error "layout wrong"
2331 run_test 51c "layout lock: IT_LAYOUT blocked and correct layout can be returned"
2334 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.0) ]] ||
2335 { skip "Need MDS version at least 2.3.0"; return; }
2337 test_mkdir -p $DIR1/$tdir
2338 file1=$DIR1/$tdir/file
2339 file2=$DIR2/$tdir/file
2341 echo orig > $file2 || error "Could not create $file2"
2342 version=$($LFS data_version $file1)
2345 echo append >> $file2 || error "Could not append to $file2"
2346 version2=$($LFS data_version $file1)
2347 [ "$version" != "$version2" ] ||
2348 error "append did not change data version: $version"
2351 echo overwrite > $file2 || error "Could not overwrite $file2"
2352 version3=$($LFS data_version $file1)
2353 [ "$version2" != "$version3" ] ||
2354 error "overwrite did not change data version: $version2"
2356 # Truncate before EOF
2357 $TRUNCATE $file2 3 || error "Could not truncate $file2"
2358 version4=$($LFS data_version $file1)
2359 [ "$version3" != "$version4" ] ||
2360 error "truncate did not change data version: $version3"
2362 # Truncate after EOF
2363 $TRUNCATE $file2 123456 || error "Could not truncate $file2"
2364 version5=$($LFS data_version $file1)
2365 [ "$version4" != "$version5" ] ||
2366 error "truncate did not change data version: $version4"
2368 # Chmod do not change version
2369 chmod 400 $file2 || error "Could not chmod 400 $file2"
2370 version6=$($LFS data_version $file1)
2371 [ "$version5" == "$version6" ] ||
2372 error "chmod should not change data version: $version5 != $version6"
2374 # Chown do not change version
2375 chown $RUNAS_ID $file2 || error "Could not chown $RUNAS_ID $file2"
2376 version7=$($LFS data_version $file1)
2377 [ "$version5" == "$version7" ] ||
2378 error "chown should not change data version: $version5 != $version7"
2380 run_test 60 "Verify data_version behaviour"
2383 local test_dir=$tdir/test_dir
2385 mkdir -p $DIR1/$tdir
2386 if [ $MDSCOUNT -ge 2 ]; then
2388 $LFS mkdir -i $MDTIDX $DIR1/$test_dir ||
2389 error "Create remote directory failed"
2391 mkdir -p $DIR1/$test_dir
2393 cd $DIR2/$test_dir || error "cd directory failed"
2394 rm -rf $DIR1/$test_dir || error "unlink directory failed"
2396 cd $DIR2/$tdir || error "exit directory"
2398 run_test 70 "cd directory && rm directory"
2400 log "cleanup: ======================================================"
2402 [ "$(mount | grep $MOUNT2)" ] && umount $MOUNT2
2405 check_and_cleanup_lustre