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 if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then
44 # bug number for skipped test: LU-2840 LU-2189 LU-2776
45 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 21 36 51a"
46 # LU-2829 / LU-2887 - make allowances for ZFS slowness
47 TEST33_NFILES=${TEST33_NFILES:-1000}
50 [ "$SLOW" = "no" ] && EXCEPT_SLOW="33a"
57 check_and_setup_lustre
59 LOVNAME=$($LCTL get_param -n llite.*.lov.common_name | tail -n 1)
60 OSTCOUNT=$($LCTL get_param -n lov.$LOVNAME.numobd)
63 rm -rf $DIR1/[df][0-9]* $DIR1/lnk $DIR/[df].${TESTSUITE}*
65 SAMPLE_FILE=$TMP/$(basename $0 .sh).junk
66 dd if=/dev/urandom of=$SAMPLE_FILE bs=1M count=1
68 # $RUNAS_ID may get set incorrectly somewhere else
69 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
71 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
80 [ -f $DIR2/f1 ] || error
82 run_test 1a "check create on 2 mtpt's =========================="
86 $CHECKSTAT -t file -p 0777 $DIR1/f1 || error
89 run_test 1b "check attribute updates on 2 mtpt's ==============="
92 $CHECKSTAT -t file -p 0666 $DIR1/f1 || error
94 run_test 1c "check after remount attribute updates on 2 mtpt's ="
98 $CHECKSTAT -a $DIR1/f1 || error
100 run_test 1d "unlink on one mountpoint removes file on other ===="
106 $CHECKSTAT -t file -p 0777 $DIR1/f2a || error
108 run_test 2a "check cached attribute updates on 2 mtpt's ========"
114 $CHECKSTAT -t file -p 0777 $DIR2/f2b || error
116 run_test 2b "check cached attribute updates on 2 mtpt's ========"
118 # NEED TO SAVE ROOT DIR MODE
121 $CHECKSTAT -t dir -p 0777 $DIR2 || error
123 run_test 2c "check cached attribute updates on 2 mtpt's root ==="
127 $CHECKSTAT -t dir -p 0755 $DIR2 || error
129 run_test 2d "check cached attribute updates on 2 mtpt's root ==="
136 $RUNAS dd if=/dev/zero of=$DIR2/$tfile count=1 || error
138 run_test 2e "check chmod on root is propagated to others"
141 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
143 local remote_dir=$tdir/remote_dir
146 $LFS mkdir -i $MDTIDX $DIR1/$remote_dir ||
147 error "Create remote directory failed"
149 touch $DIR1/$remote_dir/$tfile ||
150 error "Create file under remote directory failed"
151 chmod 777 $DIR1/$remote_dir/$tfile ||
152 error "Chmod file under remote directory failed"
154 $CHECKSTAT -t file -p 0777 $DIR2/$remote_dir/$tfile ||
155 error "Check attr of file under remote directory failed"
157 chown $RUNAS_ID:$RUNAS_GID $DIR1/$remote_dir/$tfile ||
158 error "Chown file under remote directory failed"
160 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR2/$remote_dir/$tfile ||
161 error "Check owner of file under remote directory failed"
163 cd $DIR2/$remote_dir || error "enter remote dir"
164 rm -rf $DIR1/$remote_dir/$tfile ||
165 error "Unlink remote directory failed"
167 $CHECKSTAT -t file $DIR2/$remote_dir/$tfile &&
168 error "unlink file still exists!"
170 cd $DIR2/$tdir || error "exit remote dir"
171 rm -rf $DIR1/$tdir || error "unlink directory failed"
173 run_test 2f "check attr/owner updates on DNE with 2 mtpt's"
176 local target="this/is/good"
177 ln -s $target $DIR1/$tfile || error "ln -s $target $DIR1/$tfile failed"
178 [ "$(ls -l $DIR2/$tfile | sed -e 's/.* -> //')" = "$target" ] ||
179 error "link $DIR2/$tfile not as expected"
181 run_test 3 "symlink on one mtpt, readlink on another ==========="
184 multifstat $DIR1/f4 $DIR2/f4
186 run_test 4 "fstat validation on multiple mount points =========="
190 $TRUNCATE $DIR2/f5 100
191 $CHECKSTAT -t file -s 100 $DIR1/f5 || error
194 run_test 5 "create a file on one mount, truncate it on the other"
197 openunlink $DIR1/$tfile $DIR2/$tfile || \
198 error "openunlink $DIR1/$tfile $DIR2/$tfile"
200 run_test 6 "remove of open file on other node =================="
204 opendirunlink $DIR1/$dir $DIR2/$dir || \
205 error "opendirunlink $DIR1/$dir $DIR2/$dir"
207 run_test 7 "remove of open directory on other node ============="
210 opendevunlink $DIR1/$tfile $DIR2/$tfile || \
211 error "opendevunlink $DIR1/$tfile $DIR2/$tfile"
213 run_test 8 "remove of open special file on other node =========="
219 for C in a b c d e f g h i j k l; do
220 dir=`eval echo \\$DIR$MTPT`
221 echo -n $C >> $dir/f9
222 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
224 [ "`cat $DIR1/f9`" = "abcdefghijkl" ] || \
225 error "`od -a $DIR1/f9` != abcdefghijkl"
227 run_test 9 "append of file with sub-page size on multiple mounts"
234 for C in a b c d e f g h i j k l; do
235 dir=`eval echo \\$DIR$MTPT`
236 echo -n $C | dd of=$dir/f10 bs=1 seek=$OFFSET count=1
237 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
238 OFFSET=`expr $OFFSET + 1`
240 [ "`cat $DIR1/f10`" = "abcdefghijkl" ] || \
241 error "`od -a $DIR1/f10` != abcdefghijkl"
243 run_test 10a "write of file with sub-page size on multiple mounts "
247 yes "R" | head -c 4000 >$TMP/f10b-seed
248 dd if=$TMP/f10b-seed of=$DIR1/f10b bs=3k count=1 || error "dd $DIR1"
250 $TRUNCATE $DIR1/f10b 4096 || error "truncate 4096"
252 dd if=$DIR2/f10b of=$TMP/f10b-lustre bs=4k count=1 || error "dd $DIR2"
254 # create a test file locally to compare
255 dd if=$TMP/f10b-seed of=$TMP/f10b bs=3k count=1 || error "dd random"
256 $TRUNCATE $TMP/f10b 4096 || error "truncate 4096"
257 cmp $TMP/f10b $TMP/f10b-lustre || error "file miscompare"
258 rm $TMP/f10b $TMP/f10b-lustre $TMP/f10b-seed
260 run_test 10b "write of file with sub-page size on multiple mounts "
264 multiop_bg_pause $DIR1/d11/f O_c || return 1
266 cp -p /bin/ls $DIR1/d11/f
270 wait $MULTIPID || error
271 [ $RC -eq 0 ] && error || true
273 run_test 11 "execution of file opened for write should return error ===="
276 DIR=$DIR DIR2=$DIR2 sh lockorder.sh
278 run_test 12 "test lock ordering (link, stat, unlink) ==========="
280 test_13() { # bug 2451 - directory coherency
281 test_mkdir $DIR1/d13 || error
282 cd $DIR1/d13 || error
284 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
286 rm -f $DIR2/d13/f13 || error
287 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (1)" || true
288 # need to run it twice
289 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
291 rm -f $DIR2/d13/f13 || error
292 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (2)" || true
294 run_test 13 "test directory page revocation ===================="
297 test_mkdir -p $DIR1/$tdir
298 cp -p /bin/ls $DIR1/$tdir/$tfile
299 multiop_bg_pause $DIR1/$tdir/$tfile Ow_c || return 1
302 $DIR2/$tdir/$tfile && error || true
304 wait $MULTIPID || return 2
306 run_test 14 "execution of file open for write returns -ETXTBSY ="
309 test_mkdir -p $DIR1/d14
310 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
311 MULTIOP_PROG=$DIR1/d14/multiop multiop_bg_pause $TMP/test14.junk O_c || return 1
313 $MULTIOP $DIR2/d14/multiop Oc && error "expected error, got success"
314 kill -USR1 $MULTIOP_PID || return 2
315 wait $MULTIOP_PID || return 3
316 rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop"
318 run_test 14a "open(RDWR) of executing file returns -ETXTBSY ===="
320 test_14b() { # bug 3192, 7040
321 test_mkdir -p $DIR1/d14
322 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
323 MULTIOP_PROG=$DIR1/d14/multiop multiop_bg_pause $TMP/test14.junk O_c || return 1
325 $TRUNCATE $DIR2/d14/multiop 0 && kill -9 $MULTIOP_PID && \
326 error "expected truncate error, got success"
327 kill -USR1 $MULTIOP_PID || return 2
328 wait $MULTIOP_PID || return 3
329 cmp `which multiop` $DIR1/d14/multiop || error "binary changed"
330 rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop"
332 run_test 14b "truncate of executing file returns -ETXTBSY ======"
334 test_14c() { # bug 3430, 7040
335 test_mkdir -p $DIR1/d14
336 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
337 MULTIOP_PROG=$DIR1/d14/multiop multiop_bg_pause $TMP/test14.junk O_c || return 1
339 cp /etc/hosts $DIR2/d14/multiop && error "expected error, got success"
340 kill -USR1 $MULTIOP_PID || return 2
341 wait $MULTIOP_PID || return 3
342 cmp `which multiop` $DIR1/d14/multiop || error "binary changed"
343 rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop"
345 run_test 14c "open(O_TRUNC) of executing file return -ETXTBSY =="
347 test_14d() { # bug 10921
348 test_mkdir -p $DIR1/d14
349 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
350 MULTIOP_PROG=$DIR1/d14/multiop multiop_bg_pause $TMP/test14.junk O_c || return 1
353 chmod 600 $DIR1/d14/multiop || error "chmod failed"
354 kill -USR1 $MULTIOP_PID || return 2
355 wait $MULTIOP_PID || return 3
356 cmp `which multiop` $DIR1/d14/multiop || error "binary changed"
357 rm $TMP/test14.junk $DIR1/d14/multiop || error "removing multiop"
359 run_test 14d "chmod of executing file is still possible ========"
361 test_15() { # bug 974 - ENOSPC
363 sh oos2.sh $MOUNT1 $MOUNT2
364 wait_delete_completed
365 grant_error=`dmesg | grep "> available"`
366 [ -z "$grant_error" ] || error "$grant_error"
368 run_test 15 "test out-of-space with multiple writers ==========="
371 # The FSXNUM reduction for ZFS is needed until ORI-487 is fixed.
372 # We don't want to skip it entirely, but ZFS is VERY slow and cannot
373 # pass a 2500 operation dual-mount run within the time limit.
374 if [ "$(facet_fstype ost1)" = "zfs" ]; then
375 FSXNUM=$((COUNT / 5))
377 elif [ "$SLOW" = "yes" ]; then
378 FSXNUM=$((COUNT * 5))
386 local file1=$DIR1/$tfile
387 local file2=$DIR2/$tfile
389 # to allocate grant because it may run out due to test_15.
390 lfs setstripe -c -1 $file1
391 dd if=/dev/zero of=$file1 bs=$STRIPE_BYTES count=$OSTCOUNT oflag=sync
392 dd if=/dev/zero of=$file2 bs=$STRIPE_BYTES count=$OSTCOUNT oflag=sync
395 lfs setstripe -c -1 $file1 # b=10919
396 fsx -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -S 0 $file1 $file2
398 run_test 16 "$FSXNUM iterations of dual-mount fsx"
400 test_17() { # bug 3513, 3667
401 remote_ost_nodsh && skip "remote OST with nodsh" && return
403 lfs setstripe $DIR1/$tfile -i 0 -c 1
404 cp $SAMPLE_FILE $DIR1/$tfile
405 cancel_lru_locks osc > /dev/null
406 #define OBD_FAIL_ONCE|OBD_FAIL_LDLM_CREATE_RESOURCE 0x30a
407 do_facet ost1 lctl set_param fail_loc=0x8000030a
408 ls -ls $DIR1/$tfile | awk '{ print $1,$6 }' > $DIR1/$tfile-1 & \
409 ls -ls $DIR2/$tfile | awk '{ print $1,$6 }' > $DIR2/$tfile-2
411 diff -u $DIR1/$tfile-1 $DIR2/$tfile-2 || error "files are different"
413 run_test 17 "resource creation/LVB creation race ==============="
416 # turn e.g. ALWAYS_EXCEPT="18c" into "-e 3"
419 for idx in {a..z}; do
420 local ptr=EXCEPT_ALWAYS_18$idx
421 [ x${!ptr} = xtrue ] || continue
423 excepts="$excepts -e $(($(printf %d \'$idx)-96))"
426 $LUSTRE/tests/mmap_sanity -d $MOUNT1 -m $MOUNT2 $excepts
429 run_test 18 "mmap sanity check ================================="
431 test_19() { # bug3811
432 local node=$(facet_active_host ost1)
434 # check whether obdfilter is cache capable at all
435 if ! get_osd_param $node '' read_cache_enable >/dev/null; then
436 echo "not cache-capable obdfilter"
440 local MAX=$(get_osd_param $node '' readcache_max_filesize | \
442 set_osd_param $node '' readcache_max_filesize 4096
443 dd if=/dev/urandom of=$TMP/$tfile bs=512k count=32
444 local SUM=$(cksum $TMP/$tfile | cut -d" " -f 1,2)
445 cp $TMP/$tfile $DIR1/$tfile
446 for i in `seq 1 20`; do
447 [ $((i % 5)) -eq 0 ] && log "$testname loop $i"
448 cancel_lru_locks osc > /dev/null
449 cksum $DIR1/$tfile | cut -d" " -f 1,2 > $TMP/sum1 & \
450 cksum $DIR2/$tfile | cut -d" " -f 1,2 > $TMP/sum2
452 [ "$(cat $TMP/sum1)" = "$SUM" ] || \
453 error "$DIR1/$tfile $(cat $TMP/sum1) != $SUM"
454 [ "$(cat $TMP/sum2)" = "$SUM" ] || \
455 error "$DIR2/$tfile $(cat $TMP/sum2) != $SUM"
457 set_osd_param $node '' readcache_max_filesize $MAX
460 run_test 19 "test concurrent uncached read races ==============="
465 CNT=$((`lctl get_param -n llite.*.dump_page_cache | wc -l`))
466 $MULTIOP $DIR1/f20 Ow8190c
467 $MULTIOP $DIR2/f20 Oz8194w8190c
468 $MULTIOP $DIR1/f20 Oz0r8190c
470 CNTD=$((`lctl get_param -n llite.*.dump_page_cache | wc -l` - $CNT))
472 error $CNTD" page left in cache after lock cancel" || true
474 run_test 20 "test extra readahead page left in cache ===="
481 test_21() { # Bug 5907
482 test_mkdir $DIR1/$tdir
483 mount /etc $DIR1/$tdir --bind || error "mount failed" # Poor man's mount.
485 rmdir -v $DIR1/$tdir && error "Removed mounted directory"
486 rmdir -v $DIR2/$tdir && echo "Removed mounted directory from another mountpoint, needs to be fixed"
487 test -d $DIR1/$tdir || error "Mounted directory disappeared"
489 test -d $DIR2/$tdir || test -d $DIR1/$tdir && error "Removed dir still visible after umount"
492 run_test 21 " Try to remove mountpoint on another dir ===="
494 test_23() { # Bug 5972
495 local at_diff=$(do_facet $SINGLEMDS \
496 $LCTL get_param -n mdd.*MDT0000*.atime_diff | head -n1)
497 echo "atime should be updated while another read" > $DIR1/$tfile
499 # clear the lock(mode: LCK_PW) gotten from creating operation
503 sleep $((at_diff + 1))
505 echo "starting reads"
506 multiop_bg_pause $DIR1/$tfile or20_c || return 1
507 # with SOM and opencache enabled, we need to close a file and cancel
508 # open lock to get atime propogated to MDS
509 kill -USR1 $! || return 2
512 time2=$(stat -c "%X" $DIR/$tfile)
513 echo "new atime is $time2"
515 [ $time2 -gt $time1 ] || error "atime was not updated"
516 rm -f $DIR1/$tfile || error "rm -f $DIR1/$tfile failed"
519 run_test 23 " others should see updated atime while another read===="
523 lfs df || error "lfs df failed"
524 lfs df -ih || error "lfs df -ih failed"
525 lfs df -h $DIR1 || error "lfs df -h $DIR1 failed"
526 lfs df -i $DIR2 || error "lfs df -i $DIR2 failed"
527 lfs df $DIR1/$tfile || error "lfs df $DIR1/$tfile failed"
528 lfs df -ih $DIR2/$tfile || error "lfs df -ih $DIR2/$tfile failed"
530 OSC=`lctl dl | awk '/-osc-|OSC.*MNT/ {print $4}' | head -n 1`
531 # OSC=`lctl dl | awk '/-osc-/ {print $4}' | head -n 1`
532 lctl --device %$OSC deactivate
533 lfs df -i || error "lfs df -i with deactivated OSC failed"
534 lctl --device %$OSC activate
535 lfs df || error "lfs df with reactivated OSC failed"
537 run_test 24a "lfs df [-ih] [path] test ========================="
541 fsnum=$(lfs_df | grep -c "summary")
542 [ $fsnum -eq 2 ] || error "lfs df shows $fsnum != 2 filesystems."
544 run_test 24b "lfs df should show both filesystems ==============="
547 local acl=$(lctl get_param -n mdc.*MDT0000-mdc-*.connect_flags |
549 [ "$acl" -lt 1 ] && skip "must have acl, skipping" && return
552 touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
553 chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
555 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
556 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
557 error "setfacl $DIR2/$tdir #1"
558 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
559 setfacl -m u:$RUNAS_ID:r-x -m g:$RUNAS_GID:r-x $DIR1/$tdir ||
560 error "setfacl $DIR2/$tdir #2"
561 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
562 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
563 error "setfacl $DIR2/$tdir #3"
564 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
565 setfacl -x u:$RUNAS_ID: -x g:$RUNAS_GID: $DIR1/$tdir ||
566 error "setfacl $DIR2/$tdir #4"
567 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
571 run_test 25a "change ACL on one mountpoint be seen on another ==="
574 local acl=$(lctl get_param -n mdc.*MDT0000-mdc-*.connect_flags |
576 [ "$acl" -lt 1 ] && skip "must have acl, skipping" && return
578 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
581 $LFS mkdir -i 1 $DIR1/$tdir
582 touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
583 chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
585 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
586 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
587 error "setfacl $DIR2/$tdir #1"
588 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
589 setfacl -m u:$RUNAS_ID:r-x -m g:$RUNAS_GID:r-x $DIR1/$tdir ||
590 error "setfacl $DIR2/$tdir #2"
591 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
592 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
593 error "setfacl $DIR2/$tdir #3"
594 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
595 setfacl -x u:$RUNAS_ID: -x g:$RUNAS_GID: $DIR1/$tdir ||
596 error "setfacl $DIR2/$tdir #4"
597 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
601 run_test 25b "change ACL under remote dir on one mountpoint be seen on another"
604 utime $DIR1/f26a -s $DIR2/f26a || error
606 run_test 26a "allow mtime to get older"
611 echo "aaa" >> $DIR1/$tfile
613 chmod a+x $DIR2/$tfile
614 mt1=`stat -c %Y $DIR1/$tfile`
615 mt2=`stat -c %Y $DIR2/$tfile`
617 if [ x"$mt1" != x"$mt2" ]; then
618 error "not equal mtime, client1: "$mt1", client2: "$mt2"."
621 run_test 26b "sync mtime between ost and mds"
626 dd if=/dev/zero of=$DIR2/$tfile bs=$((4096+4))k conv=notrunc count=4 seek=3 &
631 dd if=/dev/zero of=$DIR1/$tfile bs=$((16384-1024))k conv=notrunc count=1 seek=4 &
636 dd if=/dev/zero of=$DIR1/$tfile bs=8k conv=notrunc count=1 seek=0
638 lctl set_param -n ldlm.dump_namespaces ""
639 wait $DD1_PID $DD2_PID
640 [ $? -ne 0 ] && lctl dk $TMP/debug || true
642 run_test 27 "align non-overlapping extent locks from request ==="
644 test_28() { # bug 9977
645 ECHO_UUID="ECHO_osc1_UUID"
646 tOST=$($LCTL dl | awk '/-osc-|OSC.*MNT/ { print $4 }' | head -n1)
648 $LFS setstripe $DIR1/$tfile -S 1048576 -i 0 -c 2
649 tOBJID=`$LFS getstripe $DIR1/$tfile | awk '$1 == 1 {print $2}'`
650 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2
654 attach echo_client ECHO_osc1 $ECHO_UUID
658 tECHOID=`$LCTL dl | grep $ECHO_UUID | awk '{ print $1 }'`
659 $LCTL --device $tECHOID destroy "${tOBJID}:0"
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 fail (this stripe was destroyed)
670 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 && error
672 # now, recreating test file
673 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2 || error
674 # reading of 1st stripe should pass
675 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error
676 # reading of 2nd stripe should pass
677 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 || error
679 run_test 28 "read/write/truncate file with lost stripes"
681 test_29() { # bug 10999
683 #define OBD_FAIL_LDLM_GLIMPSE 0x30f
684 lctl set_param fail_loc=0x8000030f
687 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1
690 #bug 11549 - permanently turn test off in b1_5
691 run_test 29 "lock put race between glimpse and enqueue ========="
693 test_30() { #bug #11110, LU-2523
694 test_mkdir -p $DIR1/$tdir
695 cp -f /bin/bash $DIR1/$tdir/bash
696 /bin/sh -c 'sleep 1; rm -f $DIR2/$tdir/bash;
697 cp /bin/bash $DIR2/$tdir' &
698 $DIR1/$tdir/bash -c 'sleep 2;
699 openfile -f O_RDONLY /proc/$$/exe >& /dev/null; echo $?'
704 run_test 30 "recreate file race"
707 test_mkdir -p $DIR1/$tdir || error "Creating dir $DIR1/$tdir"
708 local writes=$(LANG=C dd if=/dev/zero of=$DIR/$tdir/$tfile \
709 count=1 2>&1 | awk 'BEGIN { FS="+" } /out/ {print $1}')
710 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
711 lctl set_param fail_loc=0x314
712 local reads=$(LANG=C dd if=$DIR2/$tdir/$tfile of=/dev/null 2>&1 |
713 awk 'BEGIN { FS="+" } /in/ {print $1}')
714 [ $reads -eq $writes ] || error "read" $reads "blocks, must be" $writes
716 run_test 31a "voluntary cancel / blocking ast race=============="
719 remote_ost || { skip "local OST" && return 0; }
720 remote_ost_nodsh && skip "remote OST w/o dsh" && return 0
722 # make sure there is no local locks due to destroy
723 wait_mds_ost_sync || error "wait_mds_ost_sync()"
724 wait_delete_completed || error "wait_delete_completed()"
726 test_mkdir -p $DIR1/$tdir || error "Creating dir $DIR1/$tdir"
727 lfs setstripe $DIR/$tdir/$tfile -i 0 -c 1
728 cp /etc/hosts $DIR/$tdir/$tfile
729 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
730 lctl set_param fail_loc=0x314
731 #define OBD_FAIL_LDLM_OST_FAIL_RACE 0x316
732 do_facet ost1 lctl set_param fail_loc=0x316
734 cat $DIR2/$tdir/$tfile > /dev/null 2>&1
735 lctl set_param fail_loc=0
736 do_facet ost1 lctl set_param fail_loc=0
737 # cleanup: reconnect the client back
740 run_test 31b "voluntary OST cancel / blocking ast race=============="
742 # enable/disable lockless truncate feature, depending on the arg 0/1
743 enable_lockless_truncate() {
744 lctl set_param -n osc.*.lockless_truncate $1
747 test_32a() { # bug 11270
748 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
749 save_lustre_params client "osc.*.lockless_truncate" > $p
751 enable_lockless_truncate 1
753 lfs setstripe -c -1 $DIR1/$tfile
754 dd if=/dev/zero of=$DIR1/$tfile count=$OSTCOUNT bs=$STRIPE_BYTES > \
758 log "checking cached lockless truncate"
759 $TRUNCATE $DIR1/$tfile 8000000
760 $CHECKSTAT -s 8000000 $DIR2/$tfile || error "wrong file size"
761 [ $(calc_osc_stats lockless_truncate) -eq 0 ] ||
762 error "lockless truncate doesn't use cached locks"
764 log "checking not cached lockless truncate"
765 $TRUNCATE $DIR2/$tfile 5000000
766 $CHECKSTAT -s 5000000 $DIR1/$tfile || error "wrong file size"
767 [ $(calc_osc_stats lockless_truncate) -ne 0 ] ||
768 error "not cached trancate isn't lockless"
770 log "disabled lockless truncate"
771 enable_lockless_truncate 0
773 $TRUNCATE $DIR2/$tfile 3000000
774 $CHECKSTAT -s 3000000 $DIR1/$tfile || error "wrong file size"
775 [ $(calc_osc_stats lockless_truncate) -eq 0 ] ||
776 error "lockless truncate disabling failed"
778 # restore lockless_truncate default values
779 restore_lustre_params < $p
782 run_test 32a "lockless truncate"
784 test_32b() { # bug 11270
785 remote_ost_nodsh && skip "remote OST with nodsh" && return
788 local facets=$(get_facets OST)
789 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
791 save_lustre_params client "osc.*.contention_seconds" > $p
792 save_lustre_params $facets \
793 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
794 save_lustre_params $facets \
795 "ldlm.namespaces.filter-*.contended_locks" >> $p
796 save_lustre_params $facets \
797 "ldlm.namespaces.filter-*.contention_seconds" >> $p
800 # agressive lockless i/o settings
801 for node in $(osts_nodes); do
802 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'
804 lctl set_param -n osc.*.contention_seconds 60
805 for i in $(seq 5); do
806 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > /dev/null 2>&1
807 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > /dev/null 2>&1
809 [ $(calc_osc_stats lockless_write_bytes) -ne 0 ] || error "lockless i/o was not triggered"
810 # disable lockless i/o (it is disabled by default)
811 for node in $(osts_nodes); do
812 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'
814 # set contention_seconds to 0 at client too, otherwise Lustre still
815 # remembers lock contention
816 lctl set_param -n osc.*.contention_seconds 0
818 for i in $(seq 1); do
819 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > /dev/null 2>&1
820 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > /dev/null 2>&1
822 [ $(calc_osc_stats lockless_write_bytes) -eq 0 ] ||
823 error "lockless i/o works when disabled"
825 restore_lustre_params <$p
828 run_test 32b "lockless i/o"
832 local mdts=$(get_facets MDS)
837 for mds in ${mdts//,/ }; do
839 dev=$(basename $(do_facet $mds "lctl get_param -n osd*.${!varsvc}.mntdev|\
840 xargs readlink -f" ))
841 val=$(do_facet $mds "cat /proc/fs/jbd*/${dev}{,:*,-*}/info 2>/dev/null |
844 stat=$(( stat + val))
849 # commit on sharing tests
851 remote_mds_nodsh && skip "remote MDS with nodsh" && return
853 [ -z "$CLIENTS" ] && skip "Need two or more clients, have $CLIENTS" && return 0
854 [ $CLIENTCOUNT -lt 2 ] &&
855 skip "Need two or more clients, have $CLIENTCOUNT" && return 0
857 local nfiles=${TEST33_NFILES:-10000}
858 local param_file=$TMP/$tfile-params
859 local fstype=$(facet_fstype $SINGLEMDS)
861 save_lustre_params $(get_facets MDS) \
862 "mdt.*.commit_on_sharing" > $param_file
870 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
874 do_nodes $CLIENT1,$CLIENT2 "mkdir -p $DIR1/$tdir-\\\$(hostname)-$i"
876 [ $fstype = ldiskfs ] && jbdold=$(print_jbd_stat)
877 echo "=== START createmany old: $jbdold transaction"
878 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")
879 [ $fstype = ldiskfs ] && jbdnew=$(print_jbd_stat)
880 [ $fstype = ldiskfs ] && jbd=$(( jbdnew - jbdold ))
881 echo "=== END createmany new: $jbdnew transaction : $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
882 [ $fstype = ldiskfs ] && avgjbd=$(( avgjbd + jbd ))
883 avgtime=$(( avgtime + elapsed ))
885 eval cos${COS}_jbd=$((avgjbd / 3))
886 eval cos${COS}_time=$((avgtime / 3))
889 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
890 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
891 [ "$cos0_jbd" != 0 ] && echo "COS=1 vs COS=0 jbd: $((((cos1_jbd/cos0_jbd - 1)) * 100 )) %"
892 [ "$cos0_time" != 0 ] && echo "COS=1 vs COS=0 time: $((((cos1_time/cos0_time - 1)) * 100 )) %"
894 restore_lustre_params < $param_file
898 run_test 33a "commit on sharing, cross crete/delete, 2 clients, benchmark"
900 # commit on sharing tests
902 remote_mds_nodsh && skip "remote MDS with nodsh" && return
904 [ -n "$CLIENTS" ] || { skip "Need two or more clients" && return 0; }
905 [ $CLIENTCOUNT -ge 2 ] ||
906 { skip "Need two or more clients, have $CLIENTCOUNT" &&
908 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
910 local nfiles=${TEST33_NFILES:-10000}
911 local param_file=$TMP/$tfile-params
913 save_lustre_params $(get_facets MDS) \
914 "mdt.*.commit_on_sharing" > $param_file
923 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
927 do_node $CLIENT1 "$LFS mkdir -i $MDTIDX -p \
928 $DIR1/$tdir-\\\$(hostname)-$i"
930 jbdold=$(print_jbd_stat)
931 echo "=== START createmany old: $jbdold transaction"
932 local elapsed=$(do_and_time "do_nodes $CLIENT1,$CLIENT2\
933 createmany -o $DIR1/$tdir-\\\$(hostname)-$i/f- \
934 -r $DIR2/$tdir-\\\$(hostname)-$i/f- $nfiles > \
936 jbdnew=$(print_jbd_stat)
937 jbd=$(( jbdnew - jbdold ))
938 echo "=== END createmany new: $jbdnew transaction : \
939 $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
940 avgjbd=$(( avgjbd + jbd ))
941 avgtime=$(( avgtime + elapsed ))
943 eval cos${COS}_jbd=$((avgjbd / 3))
944 eval cos${COS}_time=$((avgtime / 3))
947 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
948 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
949 [ "$cos0_jbd" != 0 ] &&
950 echo "COS=1 vs COS=0 jbd: $(((cos1_jbd/cos0_jbd - 1) * 100)) %"
951 [ "$cos0_time" != 0 ] &&
952 echo "COS=1 vs COS=0 time: $(((cos1_time/cos0_time - 1) * 100)) %"
954 restore_lustre_params < $param_file
958 run_test 33b "COS: cross create/delete, 2 clients, benchmark under remote dir"
960 # End commit on sharing tests
962 get_ost_lock_timeouts() {
963 local nodes=${1:-$(comma_list $(osts_nodes))}
965 local locks=$(do_nodes $nodes \
966 "lctl get_param -n ldlm.namespaces.filter-*.lock_timeouts" | calc_sum)
974 do_nodes $(comma_list $(osts_nodes)) \
975 "lctl set_param -n fail_loc=0 2>/dev/null || true"
976 for i in $(seq $OSTCOUNT); do
977 wait_osc_import_state client ost$i FULL
985 trap cleanup_34 EXIT RETURN
986 for OPER in notimeout timeout ; do
987 rm $DIR1/$tfile 2>/dev/null
988 lock_in=$(get_ost_lock_timeouts)
989 if [ $OPER == "timeout" ] ; then
990 for j in `seq $OSTCOUNT`; do
991 #define OBD_FAIL_PTLRPC_HPREQ_TIMEOUT 0x511
992 do_facet ost$j lctl set_param fail_loc=0x511
994 echo lock should expire
996 for j in `seq $OSTCOUNT`; do
997 #define OBD_FAIL_PTLRPC_HPREQ_NOTIMEOUT 0x512
998 do_facet ost$j lctl set_param fail_loc=0x512
1000 echo lock should not expire
1002 echo writing on client1
1003 dd if=/dev/zero of=$DIR1/$tfile count=100 conv=notrunc > /dev/null 2>&1
1005 echo reading on client2
1006 dd of=/dev/null if=$DIR2/$tfile > /dev/null 2>&1
1007 # wait for a lock timeout
1009 lock_out=$(get_ost_lock_timeouts)
1010 if [ $OPER == "timeout" ] ; then
1011 if [ $lock_in == $lock_out ]; then
1012 error "no lock timeout happened"
1017 if [ $lock_in != $lock_out ]; then
1018 error "lock timeout happened"
1026 run_test 34 "no lock timeout under IO"
1028 test_35() { # bug 17645
1031 for imp in /proc/fs/lustre/mdc/$FSNAME-MDT*-mdc-*; do
1032 g=$(awk '/generation/{print $2}' $imp/import)
1033 generation[count]=$g
1037 test_mkdir -p $MOUNT1/$tfile
1038 cancel_lru_locks mdc
1040 # Let's initiate -EINTR situation by setting fail_loc and take
1041 # write lock on same file from same client. This will not cause
1042 # bl_ast yet as lock is already in local cache.
1043 #define OBD_FAIL_LDLM_INTR_CP_AST 0x317
1044 do_facet client "lctl set_param fail_loc=0x80000317"
1045 local timeout=`do_facet $SINGLEMDS lctl get_param -n timeout`
1046 let timeout=timeout*3
1048 while test $nr -lt 10; do
1049 log "Race attempt $nr"
1050 local blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
1051 test "x$blk1" = "x" && blk1=0
1052 createmany -o $MOUNT2/$tfile/a 4000 &
1056 # Let's make conflict and bl_ast
1057 ls -la $MOUNT1/$tfile > /dev/null &
1060 log "Wait for $pid1 $pid2 for $timeout sec..."
1062 kill -9 $pid1 $pid2 > /dev/null 2>&1
1064 local blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
1065 test "x$blk2" = "x" && blk2=0
1066 test $blk2 -gt $blk1 && break
1067 rm -fr $MOUNT1/$tfile/*
1068 cancel_lru_locks mdc
1071 do_facet client "lctl set_param fail_loc=0x0"
1072 df -h $MOUNT1 $MOUNT2
1074 for imp in /proc/fs/lustre/mdc/$FSNAME-MDT*-mdc-*; do
1075 g=$(awk '/generation/{print $2}' $imp/import)
1076 if ! test "$g" -eq "${generation[count]}"; then
1077 error "Eviction happened on import $(basename $imp)"
1082 run_test 35 "-EINTR cp_ast vs. bl_ast race does not evict client"
1084 test_36() { #bug 16417
1089 test_mkdir -p $DIR1/$tdir
1090 $LFS setstripe -c -1 $DIR1/$tdir
1093 let SIZE_B=SIZE*1024*1024
1094 sync; sleep 5; sync # wait for delete thread
1096 while [ $i -le 10 ]; do
1097 lctl mark "start test"
1098 local before=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1099 dd if=/dev/zero of=$DIR1/$tdir/$tfile bs=1M count=$SIZE ||
1100 error "dd $DIR1/$tdir/$tfile ${SIZE}MB failed"
1101 sync # sync data from client cache
1102 sync_all_data # sync data from server cache (delayed allocation)
1104 local after_dd=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1105 multiop_bg_pause $DIR2/$tdir/$tfile O_r${SIZE_B}c || return 3
1107 rm -f $DIR1/$tdir/$tfile
1108 kill -USR1 $read_pid
1110 wait_delete_completed
1111 local after=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1112 echo "*** cycle($i) *** before($before) after_dd($after_dd)" \
1114 # this free space! not used
1115 (( $after_dd <= $after)) ||
1116 error "space leaked after_dd:$after_dd > after:$after"
1120 run_test 36 "handle ESTALE/open-unlink correctly"
1122 test_37() { # bug 18695
1123 test_mkdir -p $DIR1/$tdir
1124 multiop_bg_pause $DIR1/$tdir D_c || return 1
1126 # create large directory (32kB seems enough from e2fsck, ~= 1000 files)
1127 createmany -m $DIR2/$tdir/f 10000
1128 # set mtime/atime backward
1129 touch -t 198001010000 $DIR2/$tdir
1130 kill -USR1 $MULTIPID
1131 nr_files=`lfs find $DIR1/$tdir -type f | wc -l`
1132 [ $nr_files -eq 10000 ] || error "$nr_files != 10000 truncated directory?"
1135 run_test 37 "check i_size is not updated for directory on close (bug 18695) =============="
1137 # this should be set to past
1138 TEST_39_MTIME=`date -d "1 year ago" +%s`
1142 local client1=${CLIENT1:-`hostname`}
1143 local client2=${CLIENT2:-`hostname`}
1145 do_node $client1 "touch $DIR1/$tfile"
1147 do_node $client1 "touch -m -d @$TEST_39_MTIME $DIR1/$tfile"
1148 local mtime1=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1149 [ "$mtime1" = $TEST_39_MTIME ] || \
1150 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
1152 local d1=`do_node $client1 date +%s`
1153 do_node $client1 'echo hello >> '$DIR1/$tfile
1154 local d2=`do_node $client1 date +%s`
1156 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1157 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
1158 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
1160 do_node $client1 "mv $DIR1/$tfile $DIR1/$tfile-1"
1162 for (( i=0; i < 2; i++ )) ; do
1163 local mtime3=`do_node $client2 "stat -c %Y $DIR1/$tfile-1"`
1164 [ "$mtime2" = "$mtime3" ] || \
1165 error "mtime ($mtime2) changed (to $mtime3) on rename"
1167 cancel_lru_locks osc
1168 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1171 run_test 39a "test from 11063 =================================="
1174 local client1=${CLIENT1:-`hostname`}
1175 local client2=${CLIENT2:-`hostname`}
1179 local mtime1=`stat -c %Y $DIR1/$tfile`
1180 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1183 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
1185 for (( i=0; i < 2; i++ )) ; do
1186 local mtime3=`stat -c %Y $DIR1/$tfile`
1187 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1189 [ "$mtime3" = "$mtime4" ] || \
1190 error "different mtime on clients: $mtime3, $mtime4"
1191 [ "$mtime3" = $TEST_39_MTIME ] || \
1192 error "lost mtime: $mtime3, should be $TEST_39_MTIME"
1194 cancel_lru_locks osc
1195 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1198 run_test 39b "11063 problem 1 =================================="
1201 local client1=${CLIENT1:-`hostname`}
1202 local client2=${CLIENT2:-`hostname`}
1204 echo hello > $DIR1/$tfile
1206 local mtime1=`stat -c %Y $DIR1/$tfile`
1207 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1208 [ "$mtime1" = "$mtime2" ] || \
1209 error "create: different mtime on clients: $mtime1, $mtime2"
1212 $TRUNCATE $DIR1/$tfile 1
1214 for (( i=0; i < 2; i++ )) ; do
1215 local mtime3=`stat -c %Y $DIR1/$tfile`
1216 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1218 [ "$mtime3" = "$mtime4" ] || \
1219 error "different mtime on clients: $mtime3, $mtime4"
1220 [ "$mtime3" -gt $mtime2 ] || \
1221 error "truncate did not update mtime: $mtime2, $mtime3"
1223 cancel_lru_locks osc
1224 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1227 run_test 39c "check truncate mtime update ======================"
1229 # check that pid exists hence second operation wasn't blocked by first one
1230 # if it is so then there is no conflict, return 0
1231 # else second operation is conflicting with first one, return 1
1232 check_pdo_conflict() {
1235 sleep 1 # to ensure OP1 is finished on client if OP2 is blocked by OP1
1236 if [[ `ps --pid $pid | wc -l` == 1 ]]; then
1246 # test 40: check non-blocking operations
1248 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1249 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1250 mkdir $DIR1/$tfile &
1253 touch $DIR2/$tfile-2
1254 check_pdo_conflict $PID1 || error "create is blocked"
1255 mkdir $DIR2/$tfile-3
1256 check_pdo_conflict $PID1 || error "mkdir is blocked"
1257 link $DIR2/$tfile-2 $DIR2/$tfile-4
1258 check_pdo_conflict $PID1 || error "link is blocked"
1259 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1260 check_pdo_conflict $PID1 || error "rename is blocked"
1261 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1262 check_pdo_conflict $PID1 || error "getattr is blocked"
1263 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1264 rmdir $DIR2/$tfile-3
1265 check_pdo_conflict $PID1 || error "unlink is blocked"
1267 # all operations above shouldn't wait the first one
1268 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1273 run_test 40a "pdirops: create vs others =============="
1276 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1277 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1278 touch $DIR1/$tfile &
1282 touch $DIR2/$tfile-2
1283 check_pdo_conflict $PID1 || error "create is blocked"
1284 mkdir $DIR2/$tfile-3
1285 check_pdo_conflict $PID1 || error "mkdir is blocked"
1286 link $DIR2/$tfile-2 $DIR2/$tfile-4
1287 check_pdo_conflict $PID1 || error "link is blocked"
1288 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1289 check_pdo_conflict $PID1 || error "rename is blocked"
1290 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1291 check_pdo_conflict $PID1 || error "getattr is blocked"
1292 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1293 rmdir $DIR2/$tfile-3
1294 check_pdo_conflict $PID1 || error "unlink is blocked"
1295 # all operations above shouldn't wait the first one
1297 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1302 run_test 40b "pdirops: open|create and others =============="
1306 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1307 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1308 link $DIR1/$tfile $DIR1/$tfile-0 &
1312 touch $DIR2/$tfile-2
1313 check_pdo_conflict $PID1 || error "create is blocked"
1314 mkdir $DIR2/$tfile-3
1315 check_pdo_conflict $PID1 || error "mkdir is blocked"
1316 link $DIR2/$tfile-2 $DIR2/$tfile-4
1317 check_pdo_conflict $PID1 || error "link is blocked"
1318 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1319 check_pdo_conflict $PID1 || error "rename is blocked"
1320 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1321 check_pdo_conflict $PID1 || error "getattr is blocked"
1322 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1323 rmdir $DIR2/$tfile-3
1324 check_pdo_conflict $PID1 || error "unlink is blocked"
1326 # all operations above shouldn't wait the first one
1327 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1332 run_test 40c "pdirops: link and others =============="
1336 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1337 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1342 touch $DIR2/$tfile-2
1343 check_pdo_conflict $PID1 || error "create is blocked"
1344 mkdir $DIR2/$tfile-3
1345 check_pdo_conflict $PID1 || error "mkdir is blocked"
1346 link $DIR2/$tfile-2 $DIR2/$tfile-4
1347 check_pdo_conflict $PID1 || error "link is blocked"
1348 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1349 check_pdo_conflict $PID1 || error "rename is blocked"
1350 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1351 check_pdo_conflict $PID1 || error "getattr is blocked"
1352 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1353 rmdir $DIR2/$tfile-3
1354 check_pdo_conflict $PID1 || error "unlink is blocked"
1356 # all operations above shouldn't wait the first one
1357 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1361 run_test 40d "pdirops: unlink and others =============="
1365 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1366 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1367 mv $DIR1/$tfile $DIR1/$tfile-0 &
1371 touch $DIR2/$tfile-2
1372 check_pdo_conflict $PID1 || error "create is blocked"
1373 mkdir $DIR2/$tfile-3
1374 check_pdo_conflict $PID1 || error "mkdir is blocked"
1375 link $DIR2/$tfile-2 $DIR2/$tfile-4
1376 check_pdo_conflict $PID1 || error "link is blocked"
1377 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1378 check_pdo_conflict $PID1 || error "getattr is blocked"
1379 rm $DIR2/$tfile-4 $DIR2/$tfile-2
1380 rmdir $DIR2/$tfile-3
1381 check_pdo_conflict $PID1 || error "unlink is blocked"
1383 # all operations above shouldn't wait the first one
1384 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1389 run_test 40e "pdirops: rename and others =============="
1391 # test 41: create blocking operations
1393 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1394 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1395 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1398 mkdir $DIR2/$tfile && error "mkdir must fail"
1399 check_pdo_conflict $PID1 && { wait $PID1; echo "mkdir isn't blocked"; }
1403 run_test 41a "pdirops: create vs mkdir =============="
1406 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1407 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1408 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1411 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1412 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1416 run_test 41b "pdirops: create vs create =============="
1419 touch $DIR1/$tfile-2
1420 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1421 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1422 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1425 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
1426 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1430 run_test 41c "pdirops: create vs link =============="
1433 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1434 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1435 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1438 rm $DIR2/$tfile || error "unlink must succeed"
1439 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1443 run_test 41d "pdirops: create vs unlink =============="
1446 touch $DIR1/$tfile-2
1447 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1448 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1449 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1452 mv $DIR2/$tfile-2 $DIR2/$tfile || error "rename must succeed"
1453 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1457 run_test 41e "pdirops: create and rename (tgt) =============="
1460 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1461 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1462 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1465 mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
1466 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1470 run_test 41f "pdirops: create and rename (src) =============="
1473 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1474 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1475 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1478 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
1479 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1483 run_test 41g "pdirops: create vs getattr =============="
1486 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1487 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1488 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1491 ls -lia $DIR2/ > /dev/null
1492 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1496 run_test 41h "pdirops: create vs readdir =============="
1498 # test 42: unlink and blocking operations
1500 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1501 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1502 mkdir $DIR1/$tfile &
1505 mkdir $DIR2/$tfile && error "mkdir must fail"
1506 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1510 run_test 42a "pdirops: mkdir vs mkdir =============="
1513 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1514 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1515 mkdir $DIR1/$tfile &
1518 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1519 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1523 run_test 42b "pdirops: mkdir vs create =============="
1526 touch $DIR1/$tfile-2
1527 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1528 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1529 mkdir $DIR1/$tfile &
1532 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
1533 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1537 run_test 42c "pdirops: mkdir vs link =============="
1540 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1541 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1542 mkdir $DIR1/$tfile &
1545 rmdir $DIR2/$tfile || error "unlink must succeed"
1546 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1550 run_test 42d "pdirops: mkdir vs unlink =============="
1553 touch $DIR1/$tfile-2
1554 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1555 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1556 mkdir $DIR1/$tfile &
1559 mv -T $DIR2/$tfile-2 $DIR2/$tfile && error "rename must fail"
1560 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1564 run_test 42e "pdirops: mkdir and rename (tgt) =============="
1567 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1568 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1569 mkdir $DIR1/$tfile &
1572 mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
1573 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1577 run_test 42f "pdirops: mkdir and rename (src) =============="
1580 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1581 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1582 mkdir $DIR1/$tfile &
1585 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
1586 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1590 run_test 42g "pdirops: mkdir vs getattr =============="
1593 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1594 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1595 mkdir $DIR1/$tfile &
1598 ls -lia $DIR2/ > /dev/null
1599 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1603 run_test 42h "pdirops: mkdir vs readdir =============="
1605 # test 43: unlink and blocking operations
1608 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1609 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1613 mkdir $DIR2/$tfile || error "mkdir must succeed"
1614 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1618 run_test 43a "pdirops: unlink vs mkdir =============="
1622 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1623 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1627 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c || error "create must succeed"
1628 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1632 run_test 43b "pdirops: unlink vs create =============="
1636 touch $DIR1/$tfile-2
1637 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1638 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1642 link $DIR2/$tfile-2 $DIR2/$tfile || error "link must succeed"
1643 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1647 run_test 43c "pdirops: unlink vs link =============="
1651 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1652 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1656 rm $DIR2/$tfile && error "unlink must fail"
1657 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1661 run_test 43d "pdirops: unlink vs unlink =============="
1665 touch $DIR1/$tfile-2
1666 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1667 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1671 mv -u $DIR2/$tfile-2 $DIR2/$tfile || error "rename must succeed"
1672 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1676 run_test 43e "pdirops: unlink and rename (tgt) =============="
1680 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1681 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1685 mv $DIR2/$tfile $DIR2/$tfile-2 && error "rename must fail"
1686 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1690 run_test 43f "pdirops: unlink and rename (src) =============="
1694 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1695 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1699 stat $DIR2/$tfile > /dev/null && error "stat must fail"
1700 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1704 run_test 43g "pdirops: unlink vs getattr =============="
1708 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1709 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1713 ls -lia $DIR2/ > /dev/null
1714 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1718 run_test 43h "pdirops: unlink vs readdir =============="
1721 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1723 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1724 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1728 $LFS mkdir -i 1 $DIR2/$tfile || error "remote mkdir must succeed"
1729 check_pdo_conflict $PID1 &&
1730 { wait $PID1; error "remote mkdir isn't blocked"; }
1734 run_test 43i "pdirops: unlink vs remote mkdir"
1736 # test 44: rename tgt and blocking operations
1738 touch $DIR1/$tfile-2
1739 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1740 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1741 mv $DIR1/$tfile-2 $DIR1/$tfile &
1744 mkdir $DIR2/$tfile && error "mkdir must fail"
1745 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1749 run_test 44a "pdirops: rename tgt vs mkdir =============="
1752 touch $DIR1/$tfile-2
1753 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1754 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1755 mv $DIR1/$tfile-2 $DIR1/$tfile &
1758 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
1759 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1763 run_test 44b "pdirops: rename tgt vs create =============="
1766 touch $DIR1/$tfile-2
1767 touch $DIR1/$tfile-3
1768 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1769 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1770 mv $DIR1/$tfile-2 $DIR1/$tfile &
1773 link $DIR2/$tfile-3 $DIR2/$tfile && error "link must fail"
1774 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1778 run_test 44c "pdirops: rename tgt vs link =============="
1781 touch $DIR1/$tfile-2
1782 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1783 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1784 mv $DIR1/$tfile-2 $DIR1/$tfile &
1787 rm $DIR2/$tfile || error "unlink must succeed"
1788 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1792 run_test 44d "pdirops: rename tgt vs unlink =============="
1796 touch $DIR1/$tfile-2
1797 touch $DIR1/$tfile-3
1798 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1799 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1800 mv $DIR1/$tfile-2 $DIR1/$tfile &
1803 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
1804 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1808 run_test 44e "pdirops: rename tgt and rename (tgt) =============="
1811 touch $DIR1/$tfile-2
1812 touch $DIR1/$tfile-3
1813 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1814 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1815 mv $DIR1/$tfile-2 $DIR1/$tfile &
1818 mv $DIR2/$tfile $DIR2/$tfile-3 || error "rename must succeed"
1819 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1823 run_test 44f "pdirops: rename tgt and rename (src) =============="
1826 touch $DIR1/$tfile-2
1827 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1828 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1829 mv $DIR1/$tfile-2 $DIR1/$tfile &
1832 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
1833 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1837 run_test 44g "pdirops: rename tgt vs getattr =============="
1840 touch $DIR1/$tfile-2
1841 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1842 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1843 mv $DIR1/$tfile-2 $DIR1/$tfile &
1846 ls -lia $DIR2/ > /dev/null
1847 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1851 run_test 44h "pdirops: rename tgt vs readdir =============="
1853 # test 44: rename tgt and blocking operations
1855 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1856 touch $DIR1/$tfile-2
1857 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
1858 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000146
1859 mv $DIR1/$tfile-2 $DIR1/$tfile &
1862 $LFS mkdir -i 1 $DIR2/$tfile && error "remote mkdir must fail"
1863 check_pdo_conflict $PID1 && { wait $PID1;
1864 error "remote mkdir isn't blocked"; }
1868 run_test 44i "pdirops: rename tgt vs remote mkdir"
1870 # test 45: rename src and blocking operations
1873 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1874 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1875 mv $DIR1/$tfile $DIR1/$tfile-2 &
1878 mkdir $DIR2/$tfile || error "mkdir must succeed"
1879 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1883 run_test 45a "pdirops: rename src vs mkdir =============="
1887 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1888 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1889 mv $DIR1/$tfile $DIR1/$tfile-2 &
1892 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c || error "create must succeed"
1893 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1897 run_test 45b "pdirops: rename src vs create =============="
1901 touch $DIR1/$tfile-3
1902 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1903 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1904 mv $DIR1/$tfile $DIR1/$tfile-2 &
1907 link $DIR2/$tfile-3 $DIR2/$tfile || error "link must succeed"
1908 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1912 run_test 45c "pdirops: rename src vs link =============="
1916 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1917 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1918 mv $DIR1/$tfile $DIR1/$tfile-2 &
1921 rm $DIR2/$tfile && error "unlink must fail"
1922 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1926 run_test 45d "pdirops: rename src vs unlink =============="
1930 touch $DIR1/$tfile-3
1931 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1932 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1933 mv $DIR1/$tfile $DIR1/$tfile-2 &
1936 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
1937 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1941 run_test 45e "pdirops: rename src and rename (tgt) =============="
1945 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1946 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1947 mv $DIR1/$tfile $DIR1/$tfile-2 &
1950 mv $DIR2/$tfile $DIR2/$tfile-3 && error "rename must fail"
1951 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1955 run_test 45f "pdirops: rename src and rename (src) =============="
1959 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1960 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1961 mv $DIR1/$tfile $DIR1/$tfile-2 &
1964 stat $DIR2/$tfile > /dev/null && error "stat must fail"
1965 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1969 run_test 45g "pdirops: rename src vs getattr =============="
1973 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1974 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1975 mv $DIR1/$tfile $DIR1/$tfile-2 &
1978 ls -lia $DIR2/ > /dev/null
1979 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1983 run_test 45h "pdirops: unlink vs readdir =============="
1986 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1988 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1989 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
1990 mv $DIR1/$tfile $DIR1/$tfile-2 &
1993 $LFS mkdir -i 1 $DIR2/$tfile || error "create remote dir must succeed"
1994 check_pdo_conflict $PID1 && { wait $PID1;
1995 error "create remote dir isn't blocked"; }
1999 run_test 45i "pdirops: rename src vs remote mkdir"
2001 # test 46: link and blocking operations
2003 touch $DIR1/$tfile-2
2004 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2005 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2006 link $DIR1/$tfile-2 $DIR1/$tfile &
2009 mkdir $DIR2/$tfile && error "mkdir must fail"
2010 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2014 run_test 46a "pdirops: link vs mkdir =============="
2017 touch $DIR1/$tfile-2
2018 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2019 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2020 link $DIR1/$tfile-2 $DIR1/$tfile &
2023 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
2024 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2028 run_test 46b "pdirops: link vs create =============="
2031 touch $DIR1/$tfile-2
2032 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2033 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2034 link $DIR1/$tfile-2 $DIR1/$tfile &
2037 link $DIR2/$tfile $DIR2/$tfile && error "link must fail"
2038 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2042 run_test 46c "pdirops: link vs link =============="
2045 touch $DIR1/$tfile-2
2046 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2047 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2048 link $DIR1/$tfile-2 $DIR1/$tfile &
2051 rm $DIR2/$tfile || error "unlink must succeed"
2052 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2056 run_test 46d "pdirops: link vs unlink =============="
2059 touch $DIR1/$tfile-2
2060 touch $DIR1/$tfile-3
2061 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2062 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2063 link $DIR1/$tfile-2 $DIR1/$tfile &
2066 mv $DIR2/$tfile-3 $DIR2/$tfile || error "rename must succeed"
2067 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2071 run_test 46e "pdirops: link and rename (tgt) =============="
2074 touch $DIR1/$tfile-2
2075 touch $DIR1/$tfile-3
2076 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2077 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2078 link $DIR1/$tfile-2 $DIR1/$tfile &
2081 mv $DIR2/$tfile $DIR2/$tfile-3 || error "rename must succeed"
2082 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2086 run_test 46f "pdirops: link and rename (src) =============="
2089 touch $DIR1/$tfile-2
2090 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2091 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2092 link $DIR1/$tfile-2 $DIR1/$tfile &
2095 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
2096 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2100 run_test 46g "pdirops: link vs getattr =============="
2103 touch $DIR1/$tfile-2
2104 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2105 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2106 link $DIR1/$tfile-2 $DIR1/$tfile &
2109 ls -lia $DIR2/ > /dev/null
2110 check_pdo_conflict $PID1 && { wait $PID1;
2111 error "readdir isn't blocked"; }
2115 run_test 46h "pdirops: link vs readdir =============="
2118 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2119 touch $DIR1/$tfile-2
2120 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2121 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2122 link $DIR1/$tfile-2 $DIR1/$tfile &
2125 $LFS mkdir -i 1 $DIR2/$tfile && error "remote mkdir must fail"
2126 check_pdo_conflict $PID1 && { wait $PID1;
2127 error "remote mkdir isn't blocked"; }
2131 run_test 46i "pdirops: link vs remote mkdir"
2133 # test 47: remote mkdir and blocking operations
2135 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2136 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2137 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2138 $LFS mkdir -i 1 $DIR1/$tfile &
2141 mkdir $DIR2/$tfile && error "mkdir must fail"
2142 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2146 run_test 47a "pdirops: remote mkdir vs mkdir"
2149 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2150 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2151 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2152 $LFS mkdir -i 1 $DIR1/$tfile &
2155 multiop $DIR2/$tfile oO_CREAT:O_EXCL:c && error "create must fail"
2156 check_pdo_conflict $PID1 && { wait $PID1;
2157 error "create isn't blocked"; }
2161 run_test 47b "pdirops: remote mkdir vs create"
2164 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2165 touch $DIR1/$tfile-2
2166 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2167 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2168 $LFS mkdir -i 1 $DIR1/$tfile &
2171 link $DIR2/$tfile-2 $DIR2/$tfile && error "link must fail"
2172 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2176 run_test 47c "pdirops: remote mkdir vs link"
2179 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2180 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2181 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2182 $LFS mkdir -i 1 $DIR1/$tfile &
2185 rmdir $DIR2/$tfile || error "unlink must succeed"
2186 check_pdo_conflict $PID1 && { wait $PID1;
2187 error "unlink isn't blocked"; }
2191 run_test 47d "pdirops: remote mkdir vs unlink"
2194 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2195 touch $DIR1/$tfile-2
2196 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2197 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2198 $LFS mkdir -i 1 $DIR1/$tfile &
2201 mv -T $DIR2/$tfile-2 $DIR2/$tfile && error "rename must fail"
2202 check_pdo_conflict $PID1 && { wait $PID1;
2203 error "rename isn't blocked"; }
2207 run_test 47e "pdirops: remote mkdir and rename (tgt)"
2210 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2211 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2212 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2213 $LFS mkdir -i 1 $DIR1/$tfile &
2216 mv $DIR2/$tfile $DIR2/$tfile-2 || error "rename must succeed"
2217 check_pdo_conflict $PID1 && { wait $PID1;
2218 error "rename isn't blocked"; }
2222 run_test 47f "pdirops: remote mkdir and rename (src)"
2225 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2226 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2227 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000145
2228 $LFS mkdir -i 1 $DIR1/$tfile &
2231 stat $DIR2/$tfile > /dev/null || error "stat must succeed"
2232 check_pdo_conflict $PID1 && { wait $PID1;
2233 error "getattr isn't blocked"; }
2237 run_test 47g "pdirops: remote mkdir vs getattr"
2241 dd if=/dev/zero of=$DIR1/$tfile bs=1K count=10
2242 #define OBD_FAIL_OSC_CP_ENQ_RACE 0x410
2243 do_facet client "lctl set_param fail_loc=0x410"
2244 $TRUNCATE $DIR2/$tfile $trunc_size
2245 do_facet client "lctl set_param fail_loc=0x0"
2247 size=`stat -c %s $DIR2/$tfile`
2248 [ $size -eq $trunc_size ] || error "wrong size"
2250 run_test 50 "osc lvb attrs: enqueue vs. CP AST =============="
2254 local origfile=/etc/hosts
2256 filesize=`stat -c %s $origfile`
2258 # create an empty file
2259 $MCREATE $DIR1/$tfile
2260 # cache layout lock on both mount point
2261 stat $DIR1/$tfile > /dev/null
2262 stat $DIR2/$tfile > /dev/null
2264 # open and sleep 2 seconds then read
2265 $MULTIOP $DIR2/$tfile o_2r${filesize}c &
2269 # create the layout of testing file
2270 dd if=$origfile of=$DIR1/$tfile conv=notrunc > /dev/null
2272 # MULTIOP proc should be able to read enough bytes and exit
2274 kill -0 $pid && error "multiop is still there"
2275 cmp $origfile $DIR2/$tfile || error "$MCREATE and $DIR2/$tfile differs"
2279 run_test 51a "layout lock: refresh layout should work"
2282 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.59) ]] ||
2283 { skip "Need MDS version at least 2.3.59"; return 0; }
2285 local tmpfile=`mktemp`
2287 # create an empty file
2288 $MCREATE $DIR1/$tfile
2290 # delay glimpse so that layout has changed when glimpse finish
2291 #define OBD_FAIL_GLIMPSE_DELAY 0x1404
2292 $LCTL set_param fail_loc=0x1404
2293 stat -c %s $DIR2/$tfile |tee $tmpfile &
2297 # create layout of testing file
2298 dd if=/dev/zero of=$DIR1/$tfile bs=1k count=1 conv=notrunc > /dev/null
2301 local fsize=`cat $tmpfile`
2303 [ x$fsize = x1024 ] || error "file size is $fsize, should be 1024"
2305 rm -f $DIR1/$tfile $tmpfile
2307 run_test 51b "layout lock: glimpse should be able to restart if layout changed"
2310 # create an empty file
2311 $MCREATE $DIR1/$tfile
2313 #define OBD_FAIL_MDS_LL_BLOCK 0x172
2314 $LCTL set_param fail_loc=0x172
2316 # change the layout of testing file
2317 echo "Setting layout ..."
2318 $LFS setstripe -c $OSTCOUNT $DIR1/$tfile &
2322 # get layout of this file should wait until dd is finished
2323 local stripecnt=`$LFS getstripe -c $DIR2/$tfile`
2324 [ $stripecnt -eq $OSTCOUNT ] || error "layout wrong"
2328 run_test 51c "layout lock: IT_LAYOUT blocked and correct layout can be returned"
2331 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.0) ]] ||
2332 { skip "Need MDS version at least 2.3.0"; return; }
2334 test_mkdir -p $DIR1/$tdir
2335 file1=$DIR1/$tdir/file
2336 file2=$DIR2/$tdir/file
2338 echo orig > $file2 || error "Could not create $file2"
2339 version=$($LFS data_version $file1)
2342 echo append >> $file2 || error "Could not append to $file2"
2343 version2=$($LFS data_version $file1)
2344 [ "$version" != "$version2" ] ||
2345 error "append did not change data version: $version"
2348 echo overwrite > $file2 || error "Could not overwrite $file2"
2349 version3=$($LFS data_version $file1)
2350 [ "$version2" != "$version3" ] ||
2351 error "overwrite did not change data version: $version2"
2353 # Truncate before EOF
2354 $TRUNCATE $file2 3 || error "Could not truncate $file2"
2355 version4=$($LFS data_version $file1)
2356 [ "$version3" != "$version4" ] ||
2357 error "truncate did not change data version: $version3"
2359 # Truncate after EOF
2360 $TRUNCATE $file2 123456 || error "Could not truncate $file2"
2361 version5=$($LFS data_version $file1)
2362 [ "$version4" != "$version5" ] ||
2363 error "truncate did not change data version: $version4"
2365 # Chmod do not change version
2366 chmod 400 $file2 || error "Could not chmod 400 $file2"
2367 version6=$($LFS data_version $file1)
2368 [ "$version5" == "$version6" ] ||
2369 error "chmod should not change data version: $version5 != $version6"
2371 # Chown do not change version
2372 chown $RUNAS_ID $file2 || error "Could not chown $RUNAS_ID $file2"
2373 version7=$($LFS data_version $file1)
2374 [ "$version5" == "$version7" ] ||
2375 error "chown should not change data version: $version5 != $version7"
2377 run_test 60 "Verify data_version behaviour"
2380 local test_dir=$tdir/test_dir
2382 mkdir -p $DIR1/$tdir
2383 if [ $MDSCOUNT -ge 2 ]; then
2385 $LFS mkdir -i $MDTIDX $DIR1/$test_dir ||
2386 error "Create remote directory failed"
2388 mkdir -p $DIR1/$test_dir
2390 cd $DIR2/$test_dir || error "cd directory failed"
2391 rm -rf $DIR1/$test_dir || error "unlink directory failed"
2393 cd $DIR2/$tdir || error "exit directory"
2395 run_test 70a "cd directory && rm directory"
2397 test_70b() { # LU-2781
2399 mkdir -p $DIR1/$tdir
2401 touch $DIR1/$tdir/file
2402 for ((i = 0; i < 32; i++)); do
2403 $LFS rm_entry $DIR1/$tdir/non_existent_dir &>/dev/null
2405 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
2407 touch $DIR1/$tdir/file
2408 $LFS mkdir -i0 $DIR1/$tdir/test_dir
2409 $LFS rm_entry $DIR1/$tdir/test_dir &>/dev/null
2410 rm -rf $DIR1/$tdir/test_dir ||
2411 error "cannot remove directory after rm_entry"
2412 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
2414 run_test 70b "remove files after calling rm_entry"
2417 local server_version=$(lustre_version_code $SINGLEMDS)
2419 [[ $server_version -lt $(version_code 2.1.6) ]] &&
2420 skip "Need MDS version at least 2.1.6" && return
2422 # Patch not applied to 2.2 and 2.3 branches
2423 [[ $server_version -ge $(version_code 2.2.0) ]] &&
2424 [[ $server_version -lt $(version_code 2.4.0) ]] &&
2425 skip "Need MDS version at least 2.4.0" && return
2427 checkfiemap --test ||
2428 { skip "checkfiemap not runnable: $?" && return; }
2429 # write data this way: hole - data - hole - data
2430 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=1 count=1
2431 [ "$(facet_fstype ost$(($($GETSTRIPE -i $DIR1/$tfile) + 1)))" = \
2433 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return 0
2434 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=3 count=1
2435 GET_STAT="lctl get_param -n ldlm.services.ldlm_cbd.stats"
2437 local can1=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2439 checkfiemap $DIR2/$tfile 81920 ||
2440 error "data is not flushed from client"
2441 local can2=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2444 # common case of "create file, copy file" on a single node
2445 # should not flush data from ost
2446 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=1 count=1
2447 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=3 count=1
2449 local can3=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2451 checkfiemap $DIR1/$tfile 81920 ||
2453 local can4=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
2455 [ $can3 -eq $can4 ] || error $((can2-can1)) "cancel RPC occured."
2457 run_test 71 "correct file map just after write operation is finished"
2460 local p="$TMP/sanityN-$TESTNAME.parameters"
2463 save_lustre_params client "llite.*.xattr_cache" > $p
2464 lctl set_param llite.*.xattr_cache 1 ||
2465 { skip "xattr cache is not supported"; return 0; }
2468 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
2469 error "setfattr1 failed"
2470 getfattr -n user.attr1 $DIR2/$tfile | grep value1 ||
2471 error "getfattr1 failed"
2472 setfattr -n user.attr1 -v value2 $DIR2/$tfile ||
2473 error "setfattr2 failed"
2474 getfattr -n user.attr1 $DIR1/$tfile | grep value2 ||
2475 error "getfattr2 failed"
2477 # check that trusted.link is consistent
2478 tlink1=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
2479 ln $DIR2/$tfile $DIR2/$tfile-2 || error "failed to link"
2480 tlink2=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
2481 echo "$tlink1 $tlink2"
2482 [ "$tlink1" = "$tlink2" ] && error "trusted.link should have changed!"
2486 restore_lustre_params < $p
2489 run_test 72 "getxattr/setxattr cache should be consistent between nodes"
2492 local p="$TMP/sanityN-$TESTNAME.parameters"
2493 save_lustre_params client "llite.*.xattr_cache" > $p
2494 lctl set_param llite.*.xattr_cache 1 ||
2495 { skip "xattr cache is not supported"; return 0; }
2498 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
2499 error "setfattr1 failed"
2500 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr1 failed"
2501 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr2 failed"
2503 # PR lock should be cached by now on both clients
2504 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr3 failed"
2505 # 2 hits for getfattr(0)+getfattr(size)
2506 [ $(calc_llite_stats getxattr_hits) -eq 2 ] || error "not cached in $DIR1"
2507 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr4 failed"
2508 # 4 hits for more getfattr(0)+getfattr(size)
2509 [ $(calc_llite_stats getxattr_hits) -eq 4 ] || error "not cached in $DIR2"
2512 restore_lustre_params < $p
2515 run_test 73 "getxattr should not cause xattr lock cancellation"
2518 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.93) ] &&
2519 skip "Need MDS version at least 2.4.93" && return
2521 dd if=/dev/zero of=$DIR1/$tfile-1 bs=1K count=1
2522 dd if=/dev/zero of=$DIR1/$tfile-2 bs=1K count=1
2523 flocks_test 4 $DIR1/$tfile-1 $DIR2/$tfile-2
2525 run_test 74 "flock deadlock: different mounts =============="
2529 $LFS setstripe -c 2 -S 1m -i 0 $DIR1/$tfile
2530 dd if=/dev/zero of=$DIR1/$tfile bs=1M count=2
2531 cancel_lru_locks osc
2533 dd of=$DIR1/$tfile if=/dev/zero bs=1M count=1 seek=1 conv=notrunc
2536 # define OBD_FAIL_LDLM_ENQUEUE_HANG 0x31d
2537 $LCTL set_param fail_loc=0x31d
2538 stat -c %s $DIR1/$tfile &
2543 # For bad lock error handler we should ASSERT and got kernel panic here
2545 $LCTL set_param fail_loc=0
2547 run_test 75 "osc: upcall after unuse lock==================="
2550 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.53) ]] &&
2551 skip "Need MDS version at least 2.5.53" && return
2552 [ $MDSCOUNT -ge 2 ] && skip "skip now for LU-4573" && return #LU-4573
2554 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2564 nid=$($LCTL list_nids | sed "s/\./\\\./g")
2570 test_mkdir -p $DIR/$tdir
2571 if [ $MDSCOUNT -gt 1 ]; then
2572 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
2576 mds_idx=$((mdt_idx + 1))
2577 proc_ofile="mdt.*$mdt_idx.exports.'$nid'.open_files"
2579 cancel_lru_locks mdc
2581 echo -n "open files "
2583 for (( i = 0; i < $fcount; i++ )) ; do
2584 touch $DIR/$tdir/f_$i
2586 cmd="exec $fd<$DIR/$tdir/f_$i"
2593 fid_list=($(do_facet mds$mds_idx $LCTL get_param -n $proc_ofile))
2595 # Possible errors in openfiles FID list.
2596 # 1. Missing FIDs. Check 1
2597 # 2. Extra FIDs. Check 1
2598 # 3. Duplicated FID. Check 2
2599 # 4. Invalid FIDs. Check 2
2600 # 5. Valid FID, points to some other file. Check 3
2603 [ ${#fid_list[@]} -ne $fcount ] &&
2604 error "${#fid_list[@]} != $fcount open files"
2606 for (( i = 0; i < $fcount; i++ )) ; do
2607 cmd="exec ${fd_list[i]}</dev/null"
2609 filename=$($LFS fid2path $DIR2 ${fid_list[i]})
2612 rm --interactive=no $filename
2614 error "Nonexisting fid ${fid_list[i]} listed."
2618 ls_op=$(ls $DIR2/$tdir | wc -l)
2620 error "Some openfiles are missing in lproc output"
2624 run_test 76 "Verify open file for 2048 files"
2627 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2634 mkdir -p $DIR1/$tdir/dir
2635 createmany -o $DIR1/$tdir/dir/f 10 ||
2636 error "create files under remote dir failed $i"
2638 cp /etc/passwd $DIR1/$tdir/$tfile
2640 #migrate open file should fails
2641 multiop_bg_pause $DIR2/$tdir/$tfile O_c || error "open $file failed"
2643 # give multiop a chance to open
2646 $LFS mv -M $MDTIDX $DIR1/$tdir &&
2647 error "migrate open files should failed with open files"
2651 $LFS mv -M $MDTIDX $DIR1/$tdir ||
2652 error "migrate remote dir error"
2654 echo "Finish migration, then checking.."
2655 for file in $(find $DIR1/$tdir); do
2656 mdt_index=$($LFS getstripe -M $file)
2657 [ $mdt_index == $MDTIDX ] ||
2658 error "$file is not on MDT${MDTIDX}"
2661 diff /etc/passwd $DIR1/$tdir/$tfile ||
2662 error "file different after migration"
2664 rm -rf $DIR1/$tdir || error "rm dir failed after migration"
2666 run_test 80 "migrate directory when some children is being opened"
2668 log "cleanup: ======================================================"
2670 [ "$(mount | grep $MOUNT2)" ] && umount $MOUNT2
2674 check_and_cleanup_lustre