8 OPENFILE=${OPENFILE:-openfile}
9 OPENUNLINK=${OPENUNLINK:-openunlink}
10 export TMP=${TMP:-/tmp}
11 MOUNT_2=${MOUNT_2:-"yes"}
12 CHECK_GRANT=${CHECK_GRANT:-"yes"}
13 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
15 LUSTRE=${LUSTRE:-$(dirname $0)/..}
16 . $LUSTRE/tests/test-framework.sh
20 ALWAYS_EXCEPT="$SANITYN_EXCEPT "
21 # bug number for skipped test: LU-7105
23 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
25 # skip tests for PPC until they are fixed
26 if [[ $(uname -m) = ppc64 ]]; then
27 # bug number: LU-11597 LU-11787
28 ALWAYS_EXCEPT+=" 16a 71a"
31 if [ $mds1_FSTYPE = "zfs" ]; then
32 # LU-2829 / LU-2887 - make allowances for ZFS slowness
33 TEST33_NFILES=${TEST33_NFILES:-1000}
37 [ "$SLOW" = "no" ] && EXCEPT_SLOW="33a"
46 check_and_setup_lustre
51 rm -rf $DIR1/[df][0-9]* $DIR1/lnk $DIR/[df].${TESTSUITE}*
53 SAMPLE_FILE=$TMP/$(basename $0 .sh).junk
54 dd if=/dev/urandom of=$SAMPLE_FILE bs=1M count=1
56 # $RUNAS_ID may get set incorrectly somewhere else
57 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
59 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
63 [ -f $DIR2/$tfile ] || error "Check create"
64 chmod 777 $DIR2/$tfile
65 $CHECKSTAT -t file -p 0777 $DIR1/$tfile ||
66 error "Check attribute update for 0777"
68 chmod a-x $DIR2/$tfile
69 $CHECKSTAT -t file -p 0666 $DIR1/$tfile ||
70 error "Check attribute update for 0666"
73 $CHECKSTAT -a $DIR1/$tfile ||
74 error "Check unlink - removes file on other mountpoint"
76 run_test 1 "Check attribute updates on 2 mount points"
82 $CHECKSTAT -t file -p 0777 $DIR1/f2a ||
83 error "Either not file type or perms not 0777"
85 run_test 2a "check cached attribute updates on 2 mtpt's ========"
91 $CHECKSTAT -t file -p 0777 $DIR2/f2b ||
92 error "Either not file type or perms not 0777"
94 run_test 2b "check cached attribute updates on 2 mtpt's ========"
96 # NEED TO SAVE ROOT DIR MODE
99 $CHECKSTAT -t dir -p 0777 $DIR2 ||
100 error "Either not dir type or perms not 0777"
102 run_test 2c "check cached attribute updates on 2 mtpt's root ==="
106 $CHECKSTAT -t dir -p 0755 $DIR2 ||
107 error "Either not file type or perms not 0775"
109 run_test 2d "check cached attribute updates on 2 mtpt's root ==="
116 $RUNAS dd if=/dev/zero of=$DIR2/$tfile count=1 ||
119 run_test 2e "check chmod on root is propagated to others"
122 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
124 local remote_dir=$tdir/remote_dir
127 $LFS mkdir -i $MDTIDX $DIR1/$remote_dir ||
128 error "Create remote directory failed"
130 touch $DIR1/$remote_dir/$tfile ||
131 error "Create file under remote directory failed"
132 chmod 777 $DIR1/$remote_dir/$tfile ||
133 error "Chmod file under remote directory failed"
135 $CHECKSTAT -t file -p 0777 $DIR2/$remote_dir/$tfile ||
136 error "Check attr of file under remote directory failed"
138 chown $RUNAS_ID:$RUNAS_GID $DIR1/$remote_dir/$tfile ||
139 error "Chown file under remote directory failed"
141 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR2/$remote_dir/$tfile ||
142 error "Check owner of file under remote directory failed"
144 cd $DIR2/$remote_dir || error "enter remote dir"
145 rm -rf $DIR1/$remote_dir/$tfile ||
146 error "Unlink remote directory failed"
148 $CHECKSTAT -t file $DIR2/$remote_dir/$tfile &&
149 error "unlink file still exists!"
151 cd $DIR2/$tdir || error "exit remote dir"
152 rm -rf $DIR1/$tdir || error "unlink directory failed"
154 run_test 2f "check attr/owner updates on DNE with 2 mtpt's"
157 dd if=/dev/zero of=$DIR1/$tfile oflag=sync bs=1M count=2
159 local block1=$(stat $DIR1/$tfile | awk '/Blocks/ {print $4} ')
161 local block2=$(stat $DIR2/$tfile | awk '/Blocks/ {print $4} ')
162 echo "$DIR1/$tfile has $block1 blocks"
163 echo "$DIR2/$tfile has $block2 blocks"
164 [ $block1 -eq $block2 ] || error "$block1 not equal to $block2"
166 run_test 2g "check blocks update on sync write"
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 ||
185 error "Either not file type or size not equal to 100 bytes"
188 run_test 5 "create a file on one mount, truncate it on the other"
191 openunlink $DIR1/$tfile $DIR2/$tfile || \
192 error "openunlink $DIR1/$tfile $DIR2/$tfile"
194 run_test 6 "remove of open file on other node =================="
198 opendirunlink $DIR1/$dir $DIR2/$dir || \
199 error "opendirunlink $DIR1/$dir $DIR2/$dir"
201 run_test 7 "remove of open directory on other node ============="
204 opendevunlink $DIR1/$tfile $DIR2/$tfile || \
205 error "opendevunlink $DIR1/$tfile $DIR2/$tfile"
207 run_test 8 "remove of open special file on other node =========="
213 for C in a b c d e f g h i j k l; do
214 dir=`eval echo \\$DIR$MTPT`
215 echo -n $C >> $dir/f9
216 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
218 [ "`cat $DIR1/f9`" = "abcdefghijkl" ] || \
219 error "`od -a $DIR1/f9` != abcdefghijkl"
221 run_test 9a "append of file with sub-page size on multiple mounts"
223 #LU-10681 - tiny writes & appending to sparse striped file
225 [[ $OSTCOUNT -ge 2 ]] || { skip "needs >= 2 OSTs"; return; }
227 $LFS setstripe -c 2 -S 1M $DIR/$tfile
228 echo "foo" >> $DIR/$tfile
229 dd if=/dev/zero of=$DIR2/$tfile bs=1M count=1 seek=1 conv=notrunc ||
230 error "sparse dd $DIR2/$tfile failed"
231 echo "foo" >> $DIR/$tfile
233 data=$(dd if=$DIR2/$tfile bs=1 count=3 skip=$((2 * 1048576)) conv=notrunc)
234 echo "Data read (expecting 'foo')": $data
235 [ "$data" = "foo" ] || error "append to sparse striped file failed"
237 run_test 9b "append to striped sparse file"
244 for C in a b c d e f g h i j k l; do
245 dir=`eval echo \\$DIR$MTPT`
246 echo -n $C | dd of=$dir/f10 bs=1 seek=$OFFSET count=1
247 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
248 OFFSET=`expr $OFFSET + 1`
250 [ "`cat $DIR1/f10`" = "abcdefghijkl" ] || \
251 error "`od -a $DIR1/f10` != abcdefghijkl"
253 run_test 10a "write of file with sub-page size on multiple mounts "
257 yes "R" | head -c 4000 >$TMP/f10b-seed
258 dd if=$TMP/f10b-seed of=$DIR1/f10b bs=3k count=1 || error "dd $DIR1"
260 $TRUNCATE $DIR1/f10b 4096 || error "truncate 4096"
262 dd if=$DIR2/f10b of=$TMP/f10b-lustre bs=4k count=1 || error "dd $DIR2"
264 # create a test file locally to compare
265 dd if=$TMP/f10b-seed of=$TMP/f10b bs=3k count=1 || error "dd random"
266 $TRUNCATE $TMP/f10b 4096 || error "truncate 4096"
267 cmp $TMP/f10b $TMP/f10b-lustre || error "file miscompare"
268 rm $TMP/f10b $TMP/f10b-lustre $TMP/f10b-seed
270 run_test 10b "write of file with sub-page size on multiple mounts "
274 multiop_bg_pause $DIR1/d11/f O_c || return 1
276 cp -p /bin/ls $DIR1/d11/f
280 wait $MULTIPID || error "wait for PID $MULTIPID failed"
281 [ $RC -eq 0 ] && error || true
283 run_test 11 "execution of file opened for write should return error ===="
286 DIR=$DIR DIR2=$DIR2 sh lockorder.sh
288 run_test 12 "test lock ordering (link, stat, unlink)"
290 test_13() { # bug 2451 - directory coherency
292 cd $DIR1/d13 || error "cd to $DIR1/d13 failed"
294 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
296 rm -f $DIR2/d13/f13 || error "Cannot remove $DIR2/d13/f13"
297 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (1)" || true
298 # need to run it twice
299 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
301 rm -f $DIR2/d13/f13 || error "Cannot remove $DIR2/d13/f13"
302 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (2)" || true
304 run_test 13 "test directory page revocation"
307 test_mkdir $DIR1/$tdir
308 cp -p /bin/ls $DIR1/$tdir/$tfile
309 multiop_bg_pause $DIR1/$tdir/$tfile Ow_c || return 1
312 $DIR2/$tdir/$tfile && error || true
315 run_test 14aa "execution of file open for write returns -ETXTBSY"
318 test_mkdir $DIR1/$tdir
319 cp -p $(which sleep) $DIR1/$tdir/sleep || error "cp failed"
320 $DIR1/$tdir/sleep 60 &
322 $MULTIOP $DIR2/$tdir/sleep Oc && error "expected error, got success"
325 run_test 14ab "open(RDWR) of executing file returns -ETXTBSY"
327 test_14b() { # bug 3192, 7040
328 test_mkdir $DIR1/$tdir
329 cp -p $(which sleep) $DIR1/$tdir/sleep || error "cp failed"
330 $DIR1/$tdir/sleep 60 &
332 $TRUNCATE $DIR2/$tdir/sleep 60 && kill -9 $SLEEP_PID && \
333 error "expected truncate error, got success"
335 cmp $(which sleep) $DIR1/$tdir/sleep || error "binary changed"
337 run_test 14b "truncate of executing file returns -ETXTBSY ======"
339 test_14c() { # bug 3430, 7040
340 test_mkdir $DIR1/$tdir
341 cp -p $(which sleep) $DIR1/$tdir/sleep || error "cp failed"
342 $DIR1/$tdir/sleep 60 &
344 cp /etc/hosts $DIR2/$tdir/sleep && error "expected error, got success"
346 cmp $(which sleep) $DIR1/$tdir/sleep || error "binary changed"
348 run_test 14c "open(O_TRUNC) of executing file return -ETXTBSY =="
350 test_14d() { # bug 10921
351 test_mkdir $DIR1/$tdir
352 cp -p $(which sleep) $DIR1/$tdir/sleep || error "cp failed"
353 $DIR1/$tdir/sleep 60 &
356 chmod 600 $DIR1/$tdir/sleep || error "chmod failed"
358 cmp $(which sleep) $DIR1/$tdir/sleep || error "binary changed"
360 run_test 14d "chmod of executing file is still possible ========"
362 test_15() { # bug 974 - ENOSPC
364 sh oos2.sh $MOUNT1 $MOUNT2
365 wait_delete_completed
366 grant_error=$(dmesg | grep "< tot_grant")
367 [ -z "$grant_error" ] || error "$grant_error"
369 run_test 15 "test out-of-space with multiple writers ==========="
372 # The FSXNUM reduction for ZFS is needed until ORI-487 is fixed.
373 # We don't want to skip it entirely, but ZFS is VERY slow and cannot
374 # pass a 2500 operation dual-mount run within the time limit.
375 if [ "$ost1_FSTYPE" = "zfs" ]; then
376 FSXNUM=$((COUNT / 5))
378 elif [ "$SLOW" = "yes" ]; then
379 FSXNUM=$((COUNT * 5))
387 local file1=$DIR1/$tfile
388 local file2=$DIR2/$tfile
389 local stripe_size=$(do_facet $SINGLEMDS \
390 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
394 # to allocate grant because it may run out due to test_15.
395 $LFS setstripe -c -1 $file1
396 dd if=/dev/zero of=$file1 bs=$stripe_size count=$OSTCOUNT oflag=sync
397 dd if=/dev/zero of=$file2 bs=$stripe_size count=$OSTCOUNT oflag=sync
400 $LFS setstripe -c -1 $file1 # b=10919
401 $FSX -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -S 0 $file1 $file2 ||
405 # O_DIRECT reads and writes must be aligned to the device block size.
406 $FSX -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -S 0 -Z -r 4096 \
407 -w 4096 $file1 $file2 || error "fsx with O_DIRECT failed."
409 run_test 16a "$FSXNUM iterations of dual-mount fsx"
411 # Consistency check for tiny writes, LU-9409
413 local file1=$DIR1/$tfile
414 local file2=$DIR2/$tfile
415 local stripe_size=($($LFS getstripe -S $DIR))
419 # to allocate grant because it may run out due to test_15.
420 lfs setstripe -c -1 $file1
421 dd if=/dev/zero of=$file1 bs=$stripe_size count=$OSTCOUNT oflag=sync ||
422 error "dd failed writing to file=$file1"
423 dd if=/dev/zero of=$file2 bs=$stripe_size count=$OSTCOUNT oflag=sync ||
424 error "dd failed writing to file=$file2"
427 lfs setstripe -c -1 $file1 # b=10919
428 # -o is set to 8192 because writes < 1 page and between 1 and 2 pages
429 # create a mix of tiny writes & normal writes
430 $FSX -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -o 8192 -S 0 \
431 $file1 $file2 || error "fsx with tiny write failed."
433 run_test 16b "$FSXNUM iterations of dual-mount fsx at small size"
436 local file1=$DIR1/$tfile
437 local file2=$DIR2/$tfile
438 local stripe_size=$(do_facet $SINGLEMDS \
439 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
441 [ "$ost1_FSTYPE" != ldiskfs ] && skip "dio on ldiskfs only"
445 # to allocate grant because it may run out due to test_15.
446 $LFS setstripe -c -1 $file1
447 dd if=/dev/zero of=$file1 bs=$stripe_size count=$OSTCOUNT oflag=sync
448 dd if=/dev/zero of=$file2 bs=$stripe_size count=$OSTCOUNT oflag=sync
450 wait_delete_completed
452 local list=$(comma_list $(osts_nodes))
453 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
454 skip "not cache-capable obdfilter"
457 set_osd_param $list '' read_cache_enable 0
458 set_osd_param $list '' writethrough_cache_enable 0
460 $LFS setstripe -c -1 $file1 # b=10919
461 $FSX -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -S 0 $file1 $file2 ||
465 set_osd_param $list '' read_cache_enable 1
466 set_osd_param $list '' writethrough_cache_enable 1
470 run_test 16c "verify data consistency on ldiskfs with cache disabled (b=17397)"
473 local file1=$DIR1/$tfile
474 local file2=$DIR2/$tfile
475 local file3=$DIR1/file
476 local tmpfile=$(mktemp)
477 local stripe_size=$(do_facet $SINGLEMDS \
478 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
480 # to allocate grant because it may run out due to test_15.
481 $LFS setstripe -c -1 $file1
482 stack_trap "rm -f $file1 $file2 $file3 $tmpfile"
483 dd if=/dev/zero of=$file1 bs=$stripe_size count=$OSTCOUNT oflag=sync
484 dd if=/dev/zero of=$file2 bs=$stripe_size count=$OSTCOUNT oflag=sync
487 $LFS setstripe -c -1 $file1 # b=10919
488 $LCTL set_param ldlm.namespaces.*.lru_size=clear
490 # direct write on one client and direct read from another
491 dd if=/dev/urandom of=$file1 bs=1M count=100 oflag=direct
492 dd if=$file2 of=$tmpfile iflag=direct bs=1M
493 diff $file1 $tmpfile || error "file different(1)"
496 # buffer write on one client, but direct read from another
497 dd if=$tmpfile of=$file1 bs=1M count=100
498 dd if=$file2 of=$file3 bs=1M iflag=direct count=100
499 diff $file3 $tmpfile || error "file different(2)"
501 rm -f $file3 $file2 $file1
502 # direct write on one client
503 dd if=$tmpfile of=$file1 bs=1M count=100 oflag=direct
504 # buffer read from another client
505 dd if=$file2 of=$file3 bs=1M count=100
506 diff $file3 $tmpfile || error "file different(3)"
508 run_test 16d "Verify DIO and buffer IO with two clients"
510 test_16e() { # LU-13227
511 local file1=$DIR1/$tfile
512 local file2=$DIR2/$tfile
514 # client1 write 10M data
515 dd if=/dev/zero of=$file1 bs=1M count=10
517 cancel_lru_locks osc > /dev/null
518 # use lockahead to generate one PW lock to keep LVB loaded.
519 $LFS ladvise -a lockahead --start 0 --length 1M \
521 # direct write to extend file size on client2
522 dd if=/dev/zero of=$file2 bs=1M seek=20 count=1 \
523 oflag=direct conv=notrunc
524 local filesize=$(stat -c %s $file2)
525 [ "$filesize" -eq 22020096 ] ||
526 error "expected filesize 22020096 got $filesize"
529 run_test 16e "Verify size consistency for O_DIRECT write"
531 test_17() { # bug 3513, 3667
532 remote_ost_nodsh && skip "remote OST with nodsh" && return
534 lfs setstripe $DIR1/$tfile -i 0 -c 1
535 cp $SAMPLE_FILE $DIR1/$tfile
536 cancel_lru_locks osc > /dev/null
537 #define OBD_FAIL_ONCE|OBD_FAIL_LDLM_CREATE_RESOURCE 0x30a
538 do_facet ost1 lctl set_param fail_loc=0x8000030a
539 ls -ls $DIR1/$tfile | awk '{ print $1,$6 }' > $DIR1/$tfile-1 & \
540 ls -ls $DIR2/$tfile | awk '{ print $1,$6 }' > $DIR2/$tfile-2
542 diff -u $DIR1/$tfile-1 $DIR2/$tfile-2 || error "files are different"
544 run_test 17 "resource creation/LVB creation race ==============="
547 # turn e.g. ALWAYS_EXCEPT="18c" into "-e 3"
550 for idx in {a..z}; do
551 local ptr=EXCEPT_ALWAYS_18$idx
552 [ x${!ptr} = xtrue ] || continue
554 excepts="$excepts -e $(($(printf %d \'$idx)-96))"
557 excepts="$excepts -e 7 -e 8 -e 9"
558 $LUSTRE/tests/mmap_sanity -d $MOUNT1 -m $MOUNT2 $excepts ||
559 error "mmap_sanity test failed"
562 run_test 18 "mmap sanity check ================================="
564 test_19() { # bug3811
565 local node=$(facet_active_host ost1)
567 [ "x$DOM" = "xyes" ] && node=$(facet_active_host $SINGLEMDS)
569 # check whether obdfilter is cache capable at all
570 get_osd_param $node '' read_cache_enable >/dev/null ||
571 skip "not cache-capable obdfilter"
573 local MAX=$(get_osd_param $node '' readcache_max_filesize | head -n 1)
574 set_osd_param $node '' readcache_max_filesize 4096
575 dd if=/dev/urandom of=$TMP/$tfile bs=512k count=32
576 local SUM=$(cksum $TMP/$tfile | cut -d" " -f 1,2)
577 cp $TMP/$tfile $DIR1/$tfile
578 for i in `seq 1 20`; do
579 [ $((i % 5)) -eq 0 ] && log "$testname loop $i"
580 cancel_lru_locks $OSC > /dev/null
581 cksum $DIR1/$tfile | cut -d" " -f 1,2 > $TMP/sum1 & \
582 cksum $DIR2/$tfile | cut -d" " -f 1,2 > $TMP/sum2
584 [ "$(cat $TMP/sum1)" = "$SUM" ] || \
585 error "$DIR1/$tfile $(cat $TMP/sum1) != $SUM"
586 [ "$(cat $TMP/sum2)" = "$SUM" ] || \
587 error "$DIR2/$tfile $(cat $TMP/sum2) != $SUM"
589 set_osd_param $node '' readcache_max_filesize $MAX
592 run_test 19 "test concurrent uncached read races ==============="
595 test_mkdir $DIR1/$tdir
597 CNT=$($LCTL get_param -n llite.*.dump_page_cache | wc -l)
598 $MULTIOP $DIR1/$tdir/$tfile Ow8190c
599 $MULTIOP $DIR2/$tdir/$tfile Oz8194w8190c
600 $MULTIOP $DIR1/$tdir/$tfile Oz0r8190c
602 CNT2=$($LCTL get_param -n llite.*.dump_page_cache | wc -l)
603 [[ $CNT2 == $CNT ]] ||
604 error $((CNT2 - CNT))" page left in cache after lock cancel"
606 run_test 20 "test extra readahead page left in cache ===="
613 test_21() { # Bug 5907
614 test_mkdir $DIR1/$tdir
615 mount /etc $DIR1/$tdir --bind || error "mount failed" # Poor man's mount.
617 rmdir -v $DIR1/$tdir && error "Removed mounted directory"
618 rmdir -v $DIR2/$tdir && echo "Removed mounted directory from another mountpoint, needs to be fixed"
619 test -d $DIR1/$tdir || error "Mounted directory disappeared"
621 test -d $DIR2/$tdir || test -d $DIR1/$tdir && error "Removed dir still visible after umount"
624 run_test 21 " Try to remove mountpoint on another dir ===="
626 test_23() { # Bug 5972
627 local at_diff=$(do_facet $SINGLEMDS \
628 $LCTL get_param -n mdd.*MDT0000*.atime_diff | head -n1)
629 echo "atime should be updated while another read" > $DIR1/$tfile
631 # clear the lock(mode: LCK_PW) gotten from creating operation
632 cancel_lru_locks $OSC
635 sleep $((at_diff + 1))
637 echo "starting reads"
638 multiop_bg_pause $DIR1/$tfile or20_c || return 1
639 # with SOM and opencache enabled, we need to close a file and cancel
640 # open lock to get atime propogated to MDS
641 kill -USR1 $! || return 2
644 time2=$(stat -c "%X" $DIR/$tfile)
645 echo "new atime is $time2"
647 [ $time2 -gt $time1 ] || error "atime was not updated"
648 rm -f $DIR1/$tfile || error "rm -f $DIR1/$tfile failed"
651 run_test 23 " others should see updated atime while another read===="
655 lfs df || error "lfs df failed"
656 lfs df -ih || error "lfs df -ih failed"
657 lfs df -h $DIR1 || error "lfs df -h $DIR1 failed"
658 lfs df -i $DIR2 || error "lfs df -i $DIR2 failed"
659 lfs df $DIR1/$tfile || error "lfs df $DIR1/$tfile failed"
660 lfs df -ih $DIR2/$tfile || error "lfs df -ih $DIR2/$tfile failed"
662 OSC=`lctl dl | awk '/-osc-|OSC.*MNT/ {print $4}' | head -n 1`
663 # OSC=`lctl dl | awk '/-osc-/ {print $4}' | head -n 1`
664 lctl --device %osc deactivate
665 lfs df -i || error "lfs df -i with deactivated OSC failed"
666 lctl --device %osc activate
667 lfs df || error "lfs df with reactivated OSC failed"
669 run_test 24a "lfs df [-ih] [path] test ========================="
673 fsnum=$(lfs_df | grep -c "summary")
674 [ $fsnum -eq 2 ] || error "lfs df shows $fsnum != 2 filesystems."
676 run_test 24b "lfs df should show both filesystems ==============="
679 local acl=$(lctl get_param -n mdc.*MDT0000-mdc-*.connect_flags |
681 [ "$acl" -lt 1 ] && skip "must have acl, skipping" && return
684 touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
685 chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
687 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
688 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
689 error "setfacl $DIR2/$tdir #1"
690 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
691 setfacl -m u:$RUNAS_ID:r-x -m g:$RUNAS_GID:r-x $DIR1/$tdir ||
692 error "setfacl $DIR2/$tdir #2"
693 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
694 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
695 error "setfacl $DIR2/$tdir #3"
696 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
697 setfacl -x u:$RUNAS_ID: -x g:$RUNAS_GID: $DIR1/$tdir ||
698 error "setfacl $DIR2/$tdir #4"
699 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
703 run_test 25a "change ACL on one mountpoint be seen on another ==="
706 local acl=$(lctl get_param -n mdc.*MDT0000-mdc-*.connect_flags |
708 [ "$acl" -lt 1 ] && skip "must have acl, skipping" && return
710 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
713 $LFS mkdir -i 1 $DIR1/$tdir
714 touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
715 chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
717 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
718 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
719 error "setfacl $DIR2/$tdir #1"
720 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
721 setfacl -m u:$RUNAS_ID:r-x -m g:$RUNAS_GID:r-x $DIR1/$tdir ||
722 error "setfacl $DIR2/$tdir #2"
723 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
724 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
725 error "setfacl $DIR2/$tdir #3"
726 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
727 setfacl -x u:$RUNAS_ID: -x g:$RUNAS_GID: $DIR1/$tdir ||
728 error "setfacl $DIR2/$tdir #4"
729 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
733 run_test 25b "change ACL under remote dir on one mountpoint be seen on another"
736 utime $DIR1/f26a -s $DIR2/f26a || error "utime failed for $DIR1/f26a"
738 run_test 26a "allow mtime to get older"
743 echo "aaa" >> $DIR1/$tfile
745 chmod a+x $DIR2/$tfile
746 mt1=`stat -c %Y $DIR1/$tfile`
747 mt2=`stat -c %Y $DIR2/$tfile`
749 if [ x"$mt1" != x"$mt2" ]; then
750 error "not equal mtime, client1: "$mt1", client2: "$mt2"."
753 run_test 26b "sync mtime between ost and mds"
756 cancel_lru_locks $OSC
758 dd if=/dev/zero of=$DIR2/$tfile bs=$((4096+4))k conv=notrunc count=4 seek=3 &
763 dd if=/dev/zero of=$DIR1/$tfile bs=$((16384-1024))k conv=notrunc count=1 seek=4 &
768 dd if=/dev/zero of=$DIR1/$tfile bs=8k conv=notrunc count=1 seek=0
770 lctl set_param -n ldlm.dump_namespaces ""
771 wait $DD1_PID $DD2_PID
772 [ $? -ne 0 ] && lctl dk $TMP/debug || true
774 run_test 27 "align non-overlapping extent locks from request ==="
776 test_28() { # bug 9977
777 ECHO_UUID="ECHO_osc1_UUID"
778 tOST=$($LCTL dl | awk '/-osc-|OSC.*MNT/ { print $4 }' | head -n1)
780 $LFS setstripe $DIR1/$tfile -S 1048576 -i 0 -c 2
781 tOBJID=`$LFS getstripe $DIR1/$tfile | awk '$1 == 1 {print $2}'`
782 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2
786 attach echo_client ECHO_osc1 $ECHO_UUID
790 tECHOID=`$LCTL dl | grep $ECHO_UUID | awk '{ print $1 }'`
791 $LCTL --device $tECHOID destroy "${tOBJID}:0"
799 # reading of 1st stripe should pass
800 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error "dd failed"
801 # reading of 2nd stripe should fail (this stripe was destroyed)
802 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 && error
804 # now, recreating test file
805 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2 || error "dd failed"
806 # reading of 1st stripe should pass
807 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error "dd failed"
808 # reading of 2nd stripe should pass
809 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 ||
812 run_test 28 "read/write/truncate file with lost stripes"
814 test_30() { #b=11110, LU-2523
815 test_mkdir $DIR1/$tdir
816 cp -f /bin/bash $DIR1/$tdir/bash
817 /bin/sh -c 'sleep 1; rm -f $DIR2/$tdir/bash; cp /bin/bash $DIR2/$tdir' &
818 $DIR1/$tdir/bash -c 'sleep 2;
819 openfile -f O_RDONLY /proc/$$/exe >& /dev/null; echo $?'
823 run_test 30 "recreate file race"
826 test_mkdir $DIR1/$tdir
827 local writes=$(LANG=C dd if=/dev/zero of=$DIR/$tdir/$tfile \
828 count=1 2>&1 | awk 'BEGIN { FS="+" } /out/ {print $1}')
829 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
830 lctl set_param fail_loc=0x314
831 local reads=$(LANG=C dd if=$DIR2/$tdir/$tfile of=/dev/null 2>&1 |
832 awk 'BEGIN { FS="+" } /in/ {print $1}')
833 [ $reads -eq $writes ] || error "read" $reads "blocks, must be" $writes
835 run_test 31a "voluntary cancel / blocking ast race=============="
838 remote_ost || { skip "local OST" && return 0; }
839 remote_ost_nodsh && skip "remote OST w/o dsh" && return 0
841 # make sure there is no local locks due to destroy
842 wait_mds_ost_sync || error "wait_mds_ost_sync()"
843 wait_delete_completed || error "wait_delete_completed()"
845 test_mkdir $DIR1/$tdir
846 lfs setstripe $DIR/$tdir/$tfile -i 0 -c 1
847 cp /etc/hosts $DIR/$tdir/$tfile
848 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
849 lctl set_param fail_loc=0x314
850 #define OBD_FAIL_LDLM_OST_FAIL_RACE 0x316
851 do_facet ost1 lctl set_param fail_loc=0x316
853 cat $DIR2/$tdir/$tfile > /dev/null 2>&1
854 lctl set_param fail_loc=0
855 do_facet ost1 lctl set_param fail_loc=0
856 # cleanup: reconnect the client back
859 run_test 31b "voluntary OST cancel / blocking ast race=============="
861 # enable/disable lockless truncate feature, depending on the arg 0/1
862 enable_lockless_truncate() {
863 lctl set_param -n $OSC.*.lockless_truncate $1
866 test_32a() { # bug 11270
867 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
868 local stripe_size=$(do_facet $SINGLEMDS \
869 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
871 save_lustre_params client "$OSC.*.lockless_truncate" > $save
872 # restore lockless_truncate default values on exit
873 stack_trap "restore_lustre_params < $save; rm -f $save" EXIT
874 cancel_lru_locks $OSC
875 enable_lockless_truncate 1
877 lfs setstripe -c -1 $DIR1/$tfile
878 dd if=/dev/zero of=$DIR1/$tfile count=$OSTCOUNT bs=$stripe_size > \
880 clear_stats $OSC.*.${OSC}_stats
882 log "checking cached lockless truncate"
883 $TRUNCATE $DIR1/$tfile 8000000
884 $CHECKSTAT -s 8000000 $DIR2/$tfile ||
885 error "cached truncate - wrong file size"
886 [ $(calc_stats $OSC.*.${OSC}_stats lockless_truncate) -ne 0 ] ||
887 error "cached truncate isn't lockless"
889 log "checking not cached lockless truncate"
890 $TRUNCATE $DIR2/$tfile 5000000
891 $CHECKSTAT -s 5000000 $DIR1/$tfile ||
892 error "not cached truncate - wrong file size"
893 [ $(calc_stats $OSC.*.${OSC}_stats lockless_truncate) -ne 0 ] ||
894 error "not cached truncate isn't lockless"
896 log "disabled lockless truncate"
897 enable_lockless_truncate 0
898 clear_stats $OSC.*.${OSC}_stats
899 $TRUNCATE $DIR2/$tfile 3000000
900 $CHECKSTAT -s 3000000 $DIR1/$tfile ||
901 error "lockless truncate disabled - wrong file size"
902 [ $(calc_stats $OSC.*.${OSC}_stats lockless_truncate) -eq 0 ] ||
903 error "lockless truncate disabling failed"
906 run_test 32a "lockless truncate"
908 test_32b() { # bug 11270
909 remote_ost_nodsh && skip "remote OST with nodsh" && return
912 local facets=$(get_facets OST)
913 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
915 save_lustre_params client "osc.*.contention_seconds" > $p
916 save_lustre_params $facets \
917 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
918 save_lustre_params $facets \
919 "ldlm.namespaces.filter-*.contended_locks" >> $p
920 save_lustre_params $facets \
921 "ldlm.namespaces.filter-*.contention_seconds" >> $p
922 clear_stats $OSC.*.${OSC}_stats
924 # agressive lockless i/o settings
925 do_nodes $(comma_list $(osts_nodes)) \
926 "lctl set_param -n ldlm.namespaces.*.max_nolock_bytes=2000000 \
927 ldlm.namespaces.filter-*.contended_locks=0 \
928 ldlm.namespaces.filter-*.contention_seconds=60"
929 lctl set_param -n $OSC.*.contention_seconds=60
931 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > \
933 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > \
936 [ $(calc_stats $OSC.*.${OSC}_stats lockless_write_bytes) -ne 0 ] ||
937 error "lockless i/o was not triggered"
938 # disable lockless i/o (it is disabled by default)
939 do_nodes $(comma_list $(osts_nodes)) \
940 "lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes=0 \
941 ldlm.namespaces.filter-*.contended_locks=32 \
942 ldlm.namespaces.filter-*.contention_seconds=0"
943 # set contention_seconds to 0 at client too, otherwise Lustre still
944 # remembers lock contention
945 lctl set_param -n $OSC.*.contention_seconds=0
946 clear_stats $OSC.*.${OSC}_stats
948 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > \
950 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > \
953 [ $(calc_stats $OSC.*.${OSC}_stats lockless_write_bytes) -eq 0 ] ||
954 error "lockless i/o works when disabled"
956 restore_lustre_params <$p
959 run_test 32b "lockless i/o"
963 local mdts=$(get_facets MDS)
968 for mds in ${mdts//,/ }; do
970 dev=$(basename $(do_facet $mds "lctl get_param -n osd*.${!varsvc}.mntdev|\
971 xargs readlink -f" ))
972 val=$(do_facet $mds "cat /proc/fs/jbd*/${dev}{,:*,-*}/info 2>/dev/null |
975 stat=$(( stat + val))
980 # commit on sharing tests
982 remote_mds_nodsh && skip "remote MDS with nodsh" && return
984 [ -z "$CLIENTS" ] && skip "Need two or more clients, have $CLIENTS"
985 [ $CLIENTCOUNT -lt 2 ] &&
986 skip "Need two or more clients, have $CLIENTCOUNT"
988 local nfiles=${TEST33_NFILES:-10000}
989 local param_file=$TMP/$tfile-params
995 save_lustre_params $(get_facets MDS) \
996 "mdt.*.commit_on_sharing" > $param_file
999 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
1003 do_nodes $CLIENT1,$CLIENT2 "mkdir -p $DIR1/$tdir-\\\$(hostname)-$i"
1005 [ "$mds1_FSTYPE" = ldiskfs ] && jbdold=$(print_jbd_stat)
1006 echo "=== START createmany old: $jbdold transaction"
1007 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")
1008 [ "$mds1_FSTYPE" = ldiskfs ] && jbdnew=$(print_jbd_stat)
1009 [ "$mds1_FSTYPE" = ldiskfs ] && jbd=$(( jbdnew - jbdold ))
1010 echo "=== END createmany new: $jbdnew transaction : $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
1011 [ "$mds1_FSTYPE" = ldiskfs ] && avgjbd=$(( avgjbd + jbd ))
1012 avgtime=$(( avgtime + elapsed ))
1014 eval cos${COS}_jbd=$((avgjbd / 3))
1015 eval cos${COS}_time=$((avgtime / 3))
1018 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
1019 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
1020 [ "$cos0_jbd" != 0 ] &&
1021 echo "COS=1 vs COS=0 jbd: $((((cos1_jbd/cos0_jbd - 1)) * 100 )) %"
1022 [ "$cos0_time" != 0 ] &&
1023 echo "COS=1 vs COS=0 time: $((((cos1_time/cos0_time - 1)) * 100 )) %"
1025 restore_lustre_params < $param_file
1029 run_test 33a "commit on sharing, cross crete/delete, 2 clients, benchmark"
1031 # commit on sharing tests
1033 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1035 [ -n "$CLIENTS" ] || { skip "Need two or more clients" && return 0; }
1036 [ $CLIENTCOUNT -ge 2 ] ||
1037 { skip "Need two or more clients, have $CLIENTCOUNT" &&
1039 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1041 local nfiles=${TEST33_NFILES:-10000}
1042 local param_file=$TMP/$tfile-params
1044 save_lustre_params $(get_facets MDS) \
1045 "mdt.*.commit_on_sharing" > $param_file
1054 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
1058 do_node $CLIENT1 "$LFS mkdir -i $MDTIDX \
1059 $DIR1/$tdir-\\\$(hostname)-$i"
1061 jbdold=$(print_jbd_stat)
1062 echo "=== START createmany old: $jbdold transaction"
1063 local elapsed=$(do_and_time "do_nodes $CLIENT1,$CLIENT2\
1064 createmany -o $DIR1/$tdir-\\\$(hostname)-$i/f- \
1065 -r$DIR2/$tdir-\\\$(hostname)-$i/f- $nfiles > \
1067 jbdnew=$(print_jbd_stat)
1068 jbd=$(( jbdnew - jbdold ))
1069 echo "=== END createmany new: $jbdnew transaction : \
1070 $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
1071 avgjbd=$(( avgjbd + jbd ))
1072 avgtime=$(( avgtime + elapsed ))
1074 eval cos${COS}_jbd=$((avgjbd / 3))
1075 eval cos${COS}_time=$((avgtime / 3))
1078 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
1079 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
1080 [ "$cos0_jbd" != 0 ] &&
1081 echo "COS=1 vs COS=0 jbd: $(((cos1_jbd/cos0_jbd - 1) * 100)) %"
1082 [ "$cos0_time" != 0 ] &&
1083 echo "COS=1 vs COS=0 time: $(((cos1_time/cos0_time - 1) * 100)) %"
1085 restore_lustre_params < $param_file
1089 run_test 33b "COS: cross create/delete, 2 clients, benchmark under remote dir"
1092 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
1093 [ "$MDS1_VERSION" -lt $(version_code 2.7.63) ] &&
1094 skip "DNE CoS not supported"
1098 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS || error "start mds1 failed"
1104 do_facet mds1 "lctl set_param -n mdt.*.sync_count=0"
1105 # do twice in case transaction is committed before unlock, see LU-8200
1107 # remote dir is created on MDT1, which enqueued lock of $tdir on
1109 $LFS mkdir -i 1 $DIR/$tdir/remote.$i
1110 mkdir $DIR/$tdir/local.$i
1112 sync_count=$(do_facet mds1 "lctl get_param -n mdt.*MDT0000.sync_count")
1113 echo "sync_count $sync_count"
1114 [ $sync_count -eq 0 ] && error "Sync-Lock-Cancel not triggered"
1117 do_facet mds1 "lctl set_param -n mdt.*.sync_count=0"
1118 $LFS mkdir -i 1 $DIR/$tdir/remote.3
1119 # during sleep remote mkdir should have been committed and canceled
1120 # remote lock spontaneously, which shouldn't trigger sync
1122 mkdir $DIR/$tdir/local.3
1123 sync_count=$(do_facet mds1 "lctl get_param -n mdt.*MDT0000.sync_count")
1124 echo "sync_count $sync_count"
1125 [ $sync_count -eq 0 ] || error "Sync-Lock-Cancel triggered"
1127 run_test 33c "Cancel cross-MDT lock should trigger Sync-Lock-Cancel"
1129 # arg1 is operations done before CoS, arg2 is the operation that triggers CoS
1133 local nodes=$(comma_list $(mdts_nodes))
1137 # trigger CoS twice in case transaction commit before unlock
1140 do_nodes $nodes "lctl set_param -n mdt.*.async_commit_count=0"
1142 commit_nr=$(do_nodes $nodes \
1143 "lctl get_param -n mdt.*.async_commit_count" | calc_sum)
1144 total=$((total + commit_nr));
1149 echo "CoS count $total"
1150 [ $total -gt 0 ] || error "$2 didn't trigger CoS"
1154 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
1155 [ "$MDS1_VERSION" -lt $(version_code 2.7.63) ] &&
1156 skip "DNE CoS not supported"
1158 # remote directory create
1159 op_trigger_cos "mkdir $DIR/$tdir" "$LFS mkdir -i 1 $DIR/$tdir/subdir"
1160 # remote directory unlink
1161 op_trigger_cos "$LFS mkdir -i 1 $DIR/$tdir" "rmdir $DIR/$tdir"
1162 # striped directory create
1163 op_trigger_cos "mkdir $DIR/$tdir" "$LFS mkdir -c 2 $DIR/$tdir/subdir"
1164 # striped directory setattr
1165 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; touch $DIR/$tdir" \
1166 "chmod 713 $DIR/$tdir"
1167 # striped directory unlink
1168 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; touch $DIR/$tdir" \
1171 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; \
1172 $LFS mkdir -i 0 $DIR/$tdir/d1; \
1173 $LFS mkdir -i 1 $DIR/$tdir/d2; \
1174 touch $DIR/$tdir/d1/tgt" \
1175 "ln $DIR/$tdir/d1/tgt $DIR/$tdir/d2/src"
1177 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; \
1178 $LFS mkdir -i 0 $DIR/$tdir/d1; \
1179 $LFS mkdir -i 1 $DIR/$tdir/d2; \
1180 touch $DIR/$tdir/d1/src" \
1181 "mv $DIR/$tdir/d1/src $DIR/$tdir/d2/tgt"
1183 op_trigger_cos "$LFS mkdir -i 0 $DIR/$tdir" \
1184 "$LFS migrate -m 1 $DIR/$tdir"
1188 run_test 33d "DNE distributed operation should trigger COS"
1191 [ -n "$CLIENTS" ] || skip "Need two or more clients"
1192 [ $CLIENTCOUNT -ge 2 ] ||
1193 skip "Need two or more clients, have $CLIENTCOUNT"
1194 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
1195 [ "$MDS1_VERSION" -lt $(version_code 2.7.63) ] &&
1196 skip "DNE CoS not supported"
1198 local client2=${CLIENT2:-$(hostname)}
1202 local nodes=$(comma_list $(mdts_nodes))
1203 do_nodes $nodes "lctl set_param -n mdt.*.async_commit_count=0"
1205 $LFS mkdir -c 2 $DIR/$tdir
1206 mkdir $DIR/$tdir/subdir
1207 echo abc > $DIR/$tdir/$tfile
1208 do_node $client2 echo dfg >> $DIR/$tdir/$tfile
1209 do_node $client2 touch $DIR/$tdir/subdir
1211 local async_commit_count=$(do_nodes $nodes \
1212 "lctl get_param -n mdt.*.async_commit_count" | calc_sum)
1213 [ $async_commit_count -gt 0 ] && error "CoS triggerred"
1217 run_test 33e "DNE local operation shouldn't trigger COS"
1219 # End commit on sharing tests
1221 get_ost_lock_timeouts() {
1222 local nodes=${1:-$(comma_list $(osts_nodes))}
1224 local locks=$(do_nodes $nodes \
1225 "lctl get_param -n ldlm.namespaces.filter-*.lock_timeouts" | calc_sum)
1233 do_nodes $(comma_list $(osts_nodes)) \
1234 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1235 for i in $(seq $OSTCOUNT); do
1236 wait_osc_import_ready client ost$i
1241 remote_ost_nodsh && skip "remote OST with nodsh" && return
1245 trap cleanup_34 EXIT RETURN
1246 for OPER in notimeout timeout ; do
1247 rm $DIR1/$tfile 2>/dev/null
1248 lock_in=$(get_ost_lock_timeouts)
1249 if [ $OPER == "timeout" ] ; then
1250 for j in `seq $OSTCOUNT`; do
1251 #define OBD_FAIL_PTLRPC_HPREQ_TIMEOUT 0x511
1252 do_facet ost$j lctl set_param fail_loc=0x511
1254 echo lock should expire
1256 for j in `seq $OSTCOUNT`; do
1257 #define OBD_FAIL_PTLRPC_HPREQ_NOTIMEOUT 0x512
1258 do_facet ost$j lctl set_param fail_loc=0x512
1260 echo lock should not expire
1262 echo writing on client1
1263 dd if=/dev/zero of=$DIR1/$tfile count=100 conv=notrunc > /dev/null 2>&1
1265 echo reading on client2
1266 dd of=/dev/null if=$DIR2/$tfile > /dev/null 2>&1
1267 # wait for a lock timeout
1269 lock_out=$(get_ost_lock_timeouts)
1270 if [ $OPER == "timeout" ] ; then
1271 if [ $lock_in == $lock_out ]; then
1272 error "no lock timeout happened"
1277 if [ $lock_in != $lock_out ]; then
1278 error "lock timeout happened"
1286 run_test 34 "no lock timeout under IO"
1288 test_35() { # bug 17645
1291 gen=$(lctl get_param mdc.$FSNAME-MDT*-mdc-*.import | grep generation |
1292 awk '/generation/{print $2}')
1294 generation[count]=$g
1298 test_mkdir $MOUNT1/$tdir
1299 cancel_lru_locks mdc
1301 # Let's initiate -EINTR situation by setting fail_loc and take
1302 # write lock on same file from same client. This will not cause
1303 # bl_ast yet as lock is already in local cache.
1304 #define OBD_FAIL_LDLM_INTR_CP_AST 0x317
1305 do_facet client "lctl set_param fail_loc=0x80000317"
1306 local timeout=$(do_facet $SINGLEMDS lctl get_param -n timeout)
1307 let timeout=timeout*3
1309 while test $nr -lt 10; do
1310 log "Race attempt $nr"
1311 local blk1=$(lctl get_param -n ldlm.services.ldlm_cbd.stats |
1312 awk '/ldlm_bl_callback/ { print $2 }')
1313 test "x$blk1" = "x" && blk1=0
1314 createmany -o $MOUNT2/$tdir/a 4000 &
1318 # Let's make conflict and bl_ast
1319 ls -la $MOUNT1/$tdir > /dev/null &
1322 log "Wait for $pid1 $pid2 for $timeout sec..."
1324 kill -9 $pid1 $pid2 > /dev/null 2>&1
1326 local blk2=$(lctl get_param -n ldlm.services.ldlm_cbd.stats |
1327 awk '/ldlm_bl_callback/ { print $2 }')
1328 test "x$blk2" = "x" && blk2=0
1329 test $blk2 -gt $blk1 && break
1330 rm -fr $MOUNT1/$tdir
1331 cancel_lru_locks mdc
1334 do_facet client "lctl set_param fail_loc=0x0"
1335 df -h $MOUNT1 $MOUNT2
1337 gen=$(lctl get_param mdc.$FSNAME-MDT*-mdc-*.import | grep generation |
1338 awk '/generation/{print $2}')
1340 if ! test "$g" -eq "${generation[count]}"; then
1341 list=$(lctl list_param mdc.$FSNAME-MDT*-mdc-*.import)
1343 for imp in $list; do
1344 if [ $c = $count ]; then
1349 imp=$(echo "$imp" | awk -F"." '{print $2}')
1350 error "Eviction happened on import $imp"
1355 run_test 35 "-EINTR cp_ast vs. bl_ast race does not evict client"
1357 test_36() { #bug 16417
1362 test_mkdir $DIR1/$tdir
1363 $LFS setstripe -c -1 $DIR1/$tdir
1366 let SIZE_B=SIZE*1024*1024
1367 sync; sleep 2; sync # wait for delete thread
1368 wait_mds_ost_sync || error "wait_mds_ost_sync failed"
1369 wait_destroy_complete || error "wait_destroy_complete failed"
1371 while [ $i -le 10 ]; do
1372 lctl mark "start test - cycle ($i)"
1373 local before=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1374 dd if=/dev/zero of=$DIR1/$tdir/$tfile bs=1M count=$SIZE ||
1375 error "dd $DIR1/$tdir/$tfile ${SIZE}MB failed"
1376 sync # sync data from client cache
1377 sync_all_data # sync data from server cache (delayed allocation)
1379 local after_dd=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1380 multiop_bg_pause $DIR2/$tdir/$tfile O_r${SIZE_B}c || return 3
1382 rm -f $DIR1/$tdir/$tfile
1383 kill -USR1 $read_pid
1385 sync; sleep 2; sync # Ensure new statfs
1386 wait_delete_completed
1387 local after=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1388 echo "*** cycle($i) *** before($before) after_dd($after_dd)" \
1390 # this free space! not used
1391 (( $after_dd <= $after)) ||
1392 error "space leaked after_dd:$after_dd > after:$after"
1396 run_test 36 "handle ESTALE/open-unlink correctly"
1398 test_37() { # bug 18695
1399 test_mkdir $DIR1/$tdir
1400 multiop_bg_pause $DIR1/$tdir D_c || return 1
1402 # create large directory (32kB seems enough from e2fsck, ~= 1000 files)
1403 createmany -m $DIR2/$tdir/f 10000
1404 # set mtime/atime backward
1405 touch -t 198001010000 $DIR2/$tdir
1406 kill -USR1 $MULTIPID
1407 nr_files=`lfs find $DIR1/$tdir -type f | wc -l`
1408 [ $nr_files -eq 10000 ] || error "$nr_files != 10000 truncated directory?"
1411 run_test 37 "check i_size is not updated for directory on close (bug 18695) =============="
1413 # this should be set to past
1414 TEST_39_MTIME=`date -d "1 year ago" +%s`
1418 local client1=${CLIENT1:-`hostname`}
1419 local client2=${CLIENT2:-`hostname`}
1421 do_node $client1 "touch $DIR1/$tfile"
1423 do_node $client1 "touch -m -d @$TEST_39_MTIME $DIR1/$tfile"
1424 local mtime1=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1425 [ "$mtime1" = $TEST_39_MTIME ] || \
1426 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
1428 local d1=`do_node $client1 date +%s`
1429 do_node $client1 'echo hello >> '$DIR1/$tfile
1430 local d2=`do_node $client1 date +%s`
1432 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1433 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
1434 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
1436 do_node $client1 "mv $DIR1/$tfile $DIR1/$tfile-1"
1438 for (( i=0; i < 2; i++ )) ; do
1439 local mtime3=`do_node $client2 "stat -c %Y $DIR1/$tfile-1"`
1440 [ "$mtime2" = "$mtime3" ] || \
1441 error "mtime ($mtime2) changed (to $mtime3) on rename"
1443 cancel_lru_locks osc
1444 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1447 run_test 39a "test from 11063 =================================="
1450 local client1=${CLIENT1:-`hostname`}
1451 local client2=${CLIENT2:-`hostname`}
1455 local mtime1=`stat -c %Y $DIR1/$tfile`
1456 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1459 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
1461 for (( i=0; i < 2; i++ )) ; do
1462 local mtime3=`stat -c %Y $DIR1/$tfile`
1463 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1465 [ "$mtime3" = "$mtime4" ] || \
1466 error "different mtime on clients: $mtime3, $mtime4"
1467 [ "$mtime3" = $TEST_39_MTIME ] || \
1468 error "lost mtime: $mtime3, should be $TEST_39_MTIME"
1470 cancel_lru_locks osc
1471 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1474 run_test 39b "11063 problem 1 =================================="
1477 local client1=${CLIENT1:-`hostname`}
1478 local client2=${CLIENT2:-`hostname`}
1480 echo hello > $DIR1/$tfile
1482 local mtime1=`stat -c %Y $DIR1/$tfile`
1483 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1484 [ "$mtime1" = "$mtime2" ] || \
1485 error "create: different mtime on clients: $mtime1, $mtime2"
1488 $TRUNCATE $DIR1/$tfile 1
1490 for (( i=0; i < 2; i++ )) ; do
1491 local mtime3=`stat -c %Y $DIR1/$tfile`
1492 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1494 [ "$mtime3" = "$mtime4" ] || \
1495 error "different mtime on clients: $mtime3, $mtime4"
1496 [ "$mtime3" -gt $mtime2 ] || \
1497 error "truncate did not update mtime: $mtime2, $mtime3"
1499 cancel_lru_locks osc
1500 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1503 run_test 39c "check truncate mtime update ======================"
1505 test_39d() { # LU-7310
1507 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
1509 local mtime1=$(stat -c %Y $DIR2/$tfile)
1510 [ "$mtime1" = $TEST_39_MTIME ] ||
1511 error "mtime: $mtime1, should be $TEST_39_MTIME"
1514 # define OBD_FAIL_OSC_NO_GRANT 0x411
1515 $LCTL set_param fail_loc=0x411
1517 local d1=$(date +%s)
1518 echo hello >> $DIR1/$tfile
1519 local d2=$(date +%s)
1521 $LCTL set_param fail_loc=0
1523 cancel_lru_locks $OSC
1525 local mtime2=$(stat -c %Y $DIR2/$tfile)
1526 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] ||
1527 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
1529 run_test 39d "sync write should update mtime"
1532 # how long 40-47 take with specific delay
1539 # for pdo testing, we must cancel MDT-MDT locks as well as client locks to
1540 # avoid unexpected delays due to previous tests
1542 cancel_lru_locks mdc
1543 do_nodes $(comma_list $(mdts_nodes)) \
1544 $LCTL set_param -n ldlm.namespaces.*mdt*.lru_size=clear
1545 do_nodes $(comma_list $(mdts_nodes)) \
1546 $LCTL get_param ldlm.namespaces.*mdt*.lock_unused_count \
1547 ldlm.namespaces.*mdt*.lock_count | grep -v '=0'
1550 # check that pid exists hence second operation wasn't blocked by first one
1551 # if it is so then there is no conflict, return 0
1552 # else second operation is conflicting with first one, return 1
1553 check_pdo_conflict() {
1556 pdo_sched # to ensure OP1 is finished on client if OP2 is blocked by OP1
1557 if [[ `ps --pid $pid | wc -l` == 1 ]]; then
1567 # test 40: check non-blocking operations
1569 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1571 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1572 do_nodes $(comma_list $(mdts_nodes)) \
1573 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1575 mkdir $DIR1/$tfile &
1577 touch $DIR2/$tfile-2
1578 check_pdo_conflict $PID1 || error "create is blocked"
1579 mkdir $DIR2/$tfile-3
1580 check_pdo_conflict $PID1 || error "mkdir is blocked"
1581 link $DIR2/$tfile-2 $DIR2/$tfile-4
1582 check_pdo_conflict $PID1 || error "link is blocked"
1583 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1584 check_pdo_conflict $PID1 || error "rename is blocked"
1585 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1586 check_pdo_conflict $PID1 || error "getattr is blocked"
1587 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1588 rmdir $DIR2/$tfile-3
1589 check_pdo_conflict $PID1 || error "unlink is blocked"
1591 # all operations above shouldn't wait the first one
1592 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1593 do_nodes $(comma_list $(mdts_nodes)) \
1594 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1599 run_test 40a "pdirops: create vs others =============="
1602 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1604 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1605 do_nodes $(comma_list $(mdts_nodes)) \
1606 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1607 touch $DIR1/$tfile &
1610 touch $DIR2/$tfile-2
1611 check_pdo_conflict $PID1 || error "create is blocked"
1612 mkdir $DIR2/$tfile-3
1613 check_pdo_conflict $PID1 || error "mkdir is blocked"
1614 link $DIR2/$tfile-2 $DIR2/$tfile-4
1615 check_pdo_conflict $PID1 || error "link is blocked"
1616 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1617 check_pdo_conflict $PID1 || error "rename is blocked"
1618 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1619 check_pdo_conflict $PID1 || error "getattr is blocked"
1620 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1621 rmdir $DIR2/$tfile-3
1622 check_pdo_conflict $PID1 || error "unlink is blocked"
1623 # all operations above shouldn't wait the first one
1625 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1626 do_nodes $(comma_list $(mdts_nodes)) \
1627 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1632 run_test 40b "pdirops: open|create and others =============="
1635 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1638 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1639 do_nodes $(comma_list $(mdts_nodes)) \
1640 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1641 link $DIR1/$tfile $DIR1/$tfile-0 &
1644 touch $DIR2/$tfile-2
1645 check_pdo_conflict $PID1 || error "create is blocked"
1646 mkdir $DIR2/$tfile-3
1647 check_pdo_conflict $PID1 || error "mkdir is blocked"
1648 link $DIR2/$tfile-2 $DIR2/$tfile-4
1649 check_pdo_conflict $PID1 || error "link is blocked"
1650 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1651 check_pdo_conflict $PID1 || error "rename is blocked"
1652 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1653 check_pdo_conflict $PID1 || error "getattr is blocked"
1654 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1655 rmdir $DIR2/$tfile-3
1656 check_pdo_conflict $PID1 || error "unlink is blocked"
1658 # all operations above shouldn't wait the first one
1659 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1660 do_nodes $(comma_list $(mdts_nodes)) \
1661 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1666 run_test 40c "pdirops: link and others =============="
1669 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1672 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1673 do_nodes $(comma_list $(mdts_nodes)) \
1674 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1678 touch $DIR2/$tfile-2
1679 check_pdo_conflict $PID1 || error "create is blocked"
1680 mkdir $DIR2/$tfile-3
1681 check_pdo_conflict $PID1 || error "mkdir is blocked"
1682 link $DIR2/$tfile-2 $DIR2/$tfile-4
1683 check_pdo_conflict $PID1 || error "link is blocked"
1684 mv $DIR2/$tfile-2 $DIR2/$tfile-5
1685 check_pdo_conflict $PID1 || error "rename is blocked"
1686 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1687 check_pdo_conflict $PID1 || error "getattr is blocked"
1688 rm $DIR2/$tfile-4 $DIR2/$tfile-5
1689 rmdir $DIR2/$tfile-3
1690 check_pdo_conflict $PID1 || error "unlink is blocked"
1692 # all operations above shouldn't wait the first one
1693 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1694 do_nodes $(comma_list $(mdts_nodes)) \
1695 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1699 run_test 40d "pdirops: unlink and others =============="
1702 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1705 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1706 do_nodes $(comma_list $(mdts_nodes)) \
1707 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1708 mv $DIR1/$tfile $DIR1/$tfile-0 &
1711 touch $DIR2/$tfile-2
1712 check_pdo_conflict $PID1 || error "create is blocked"
1713 mkdir $DIR2/$tfile-3
1714 check_pdo_conflict $PID1 || error "mkdir is blocked"
1715 link $DIR2/$tfile-2 $DIR2/$tfile-4
1716 check_pdo_conflict $PID1 || error "link is blocked"
1717 stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
1718 check_pdo_conflict $PID1 || error "getattr is blocked"
1719 rm $DIR2/$tfile-4 $DIR2/$tfile-2
1720 rmdir $DIR2/$tfile-3
1721 check_pdo_conflict $PID1 || error "unlink is blocked"
1723 # all operations above shouldn't wait the first one
1724 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1725 do_nodes $(comma_list $(mdts_nodes)) \
1726 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1731 run_test 40e "pdirops: rename and others =============="
1733 # test 41: create blocking operations
1736 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1737 do_nodes $(comma_list $(mdts_nodes)) \
1738 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1739 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1741 mkdir $DIR2/$tfile &
1743 do_nodes $(comma_list $(mdts_nodes)) \
1744 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1745 check_pdo_conflict $PID1 && { wait $PID1; echo "mkdir isn't blocked"; }
1746 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
1750 run_test 41a "pdirops: create vs mkdir =============="
1754 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1755 do_nodes $(comma_list $(mdts_nodes)) \
1756 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1757 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1759 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
1761 do_nodes $(comma_list $(mdts_nodes)) \
1762 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1763 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1764 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
1768 run_test 41b "pdirops: create vs create =============="
1772 touch $DIR1/$tfile-2
1773 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1774 do_nodes $(comma_list $(mdts_nodes)) \
1775 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1776 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1778 link $DIR2/$tfile-2 $DIR2/$tfile &
1780 do_nodes $(comma_list $(mdts_nodes)) \
1781 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1782 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1783 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
1787 run_test 41c "pdirops: create vs link =============="
1791 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1792 do_nodes $(comma_list $(mdts_nodes)) \
1793 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1794 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1798 do_nodes $(comma_list $(mdts_nodes)) \
1799 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1800 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1801 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
1805 run_test 41d "pdirops: create vs unlink =============="
1809 touch $DIR1/$tfile-2
1810 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1811 do_nodes $(comma_list $(mdts_nodes)) \
1812 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1813 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1815 mv $DIR2/$tfile-2 $DIR2/$tfile &
1817 do_nodes $(comma_list $(mdts_nodes)) \
1818 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1819 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1820 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
1824 run_test 41e "pdirops: create and rename (tgt) =============="
1828 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1829 do_nodes $(comma_list $(mdts_nodes)) \
1830 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1831 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1833 mv $DIR2/$tfile $DIR2/$tfile-2 &
1835 do_nodes $(comma_list $(mdts_nodes)) \
1836 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1837 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1838 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
1842 run_test 41f "pdirops: create and rename (src) =============="
1846 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1847 do_nodes $(comma_list $(mdts_nodes)) \
1848 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1849 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1851 stat $DIR2/$tfile > /dev/null &
1853 do_nodes $(comma_list $(mdts_nodes)) \
1854 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1855 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1856 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
1860 run_test 41g "pdirops: create vs getattr =============="
1864 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1865 do_nodes $(comma_list $(mdts_nodes)) \
1866 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1867 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1869 ls -lia $DIR2/ > /dev/null &
1871 do_nodes $(comma_list $(mdts_nodes)) \
1872 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1873 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1878 run_test 41h "pdirops: create vs readdir =============="
1885 do_nodes $(comma_list $(mdts_nodes)) \
1886 "lctl set_param -n fail_loc=${fail_loc} || true" &>/dev/null
1888 $MULTIOP $DIR1/$tfile oO_CREAT:O_EXCL:c 2>/dev/null &
1891 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c 2>/dev/null &
1894 if ! wait $PID1 && ! wait $PID2; then
1895 echo "Both creates failed (1 should fail, 1 should succeed)"
1897 elif wait $PID1 && wait $PID2; then
1898 echo "Both creates succeeded (1 should fail, 1 should succeed)"
1903 do_nodes $(comma_list $(mdts_nodes)) \
1904 "lctl set_param -n fail_loc=0x0 || true" &>/dev/null
1911 [[ $MDS1_VERSION -le $(version_code 2.13.56) ]] ||
1912 skip "Need MDS version newer than 2.13.56"
1915 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN 0x169
1916 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN2 0x16a
1917 for fail_loc in "0x80000169" "0x8000016a"; do
1918 echo "Begin 100 tests with fail_loc=$fail_loc"
1920 for i in {1..100}; do
1922 msg=$(sub_test_41i "$fail_loc") ||
1923 { echo; error "iter=$i : $msg"; }
1928 run_test 41i "reint_open: create vs create"
1931 # test 42: unlink and blocking operations
1934 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1935 do_nodes $(comma_list $(mdts_nodes)) \
1936 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1937 mkdir $DIR1/$tfile &
1939 mkdir $DIR2/$tfile &
1941 do_nodes $(comma_list $(mdts_nodes)) \
1942 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1943 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1944 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
1948 run_test 42a "pdirops: mkdir vs mkdir =============="
1952 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1953 do_nodes $(comma_list $(mdts_nodes)) \
1954 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1955 mkdir $DIR1/$tfile &
1957 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
1959 do_nodes $(comma_list $(mdts_nodes)) \
1960 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1961 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1962 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
1966 run_test 42b "pdirops: mkdir vs create =============="
1970 touch $DIR1/$tfile-2
1971 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1972 do_nodes $(comma_list $(mdts_nodes)) \
1973 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1974 mkdir $DIR1/$tfile &
1976 link $DIR2/$tfile-2 $DIR2/$tfile &
1978 do_nodes $(comma_list $(mdts_nodes)) \
1979 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1980 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1981 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
1985 run_test 42c "pdirops: mkdir vs link =============="
1989 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1990 do_nodes $(comma_list $(mdts_nodes)) \
1991 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1992 mkdir $DIR1/$tfile &
1994 rmdir $DIR2/$tfile &
1996 do_nodes $(comma_list $(mdts_nodes)) \
1997 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1998 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1999 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
2003 run_test 42d "pdirops: mkdir vs unlink =============="
2007 touch $DIR1/$tfile-2
2008 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2009 do_nodes $(comma_list $(mdts_nodes)) \
2010 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2011 mkdir $DIR1/$tfile &
2013 mv -T $DIR2/$tfile-2 $DIR2/$tfile &
2015 do_nodes $(comma_list $(mdts_nodes)) \
2016 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2017 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2018 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
2022 run_test 42e "pdirops: mkdir and rename (tgt) =============="
2026 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2027 do_nodes $(comma_list $(mdts_nodes)) \
2028 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2029 mkdir $DIR1/$tfile &
2031 mv $DIR2/$tfile $DIR2/$tfile-2 &
2033 do_nodes $(comma_list $(mdts_nodes)) \
2034 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2035 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2036 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2040 run_test 42f "pdirops: mkdir and rename (src) =============="
2044 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2045 do_nodes $(comma_list $(mdts_nodes)) \
2046 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2047 mkdir $DIR1/$tfile &
2049 stat $DIR2/$tfile > /dev/null &
2051 do_nodes $(comma_list $(mdts_nodes)) \
2052 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2053 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2054 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
2058 run_test 42g "pdirops: mkdir vs getattr =============="
2062 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2063 do_nodes $(comma_list $(mdts_nodes)) \
2064 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2065 mkdir $DIR1/$tfile &
2067 ls -lia $DIR2/ > /dev/null &
2069 do_nodes $(comma_list $(mdts_nodes)) \
2070 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2071 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2076 run_test 42h "pdirops: mkdir vs readdir =============="
2078 # test 43: rmdir,mkdir won't return -EEXIST
2080 for i in {1..1000}; do
2081 mkdir $DIR1/$tdir || error "mkdir $tdir failed"
2082 rmdir $DIR2/$tdir || error "rmdir $tdir failed"
2086 run_test 43a "rmdir,mkdir doesn't return -EEXIST =============="
2091 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2092 do_nodes $(comma_list $(mdts_nodes)) \
2093 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2096 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2098 do_nodes $(comma_list $(mdts_nodes)) \
2099 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2100 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2101 wait $PID2 ; [ $? -eq 0 ] || error "create must succeed"
2105 run_test 43b "pdirops: unlink vs create =============="
2110 touch $DIR1/$tfile-2
2111 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2112 do_nodes $(comma_list $(mdts_nodes)) \
2113 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2116 link $DIR2/$tfile-2 $DIR2/$tfile &
2118 do_nodes $(comma_list $(mdts_nodes)) \
2119 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2120 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2121 wait $PID2 ; [ $? -eq 0 ] || error "link must succeed"
2125 run_test 43c "pdirops: unlink vs link =============="
2130 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2131 do_nodes $(comma_list $(mdts_nodes)) \
2132 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2137 do_nodes $(comma_list $(mdts_nodes)) \
2138 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2139 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2140 wait $PID2 ; [ $? -ne 0 ] || error "unlink must fail"
2144 run_test 43d "pdirops: unlink vs unlink =============="
2149 touch $DIR1/$tfile-2
2150 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2151 do_nodes $(comma_list $(mdts_nodes)) \
2152 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2155 mv -u $DIR2/$tfile-2 $DIR2/$tfile &
2157 do_nodes $(comma_list $(mdts_nodes)) \
2158 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2159 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2160 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2164 run_test 43e "pdirops: unlink and rename (tgt) =============="
2169 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2170 do_nodes $(comma_list $(mdts_nodes)) \
2171 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2174 mv $DIR2/$tfile $DIR2/$tfile-2 &
2176 do_nodes $(comma_list $(mdts_nodes)) \
2177 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2178 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2179 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
2183 run_test 43f "pdirops: unlink and rename (src) =============="
2188 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2189 do_nodes $(comma_list $(mdts_nodes)) \
2190 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2193 stat $DIR2/$tfile > /dev/null &
2195 do_nodes $(comma_list $(mdts_nodes)) \
2196 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2197 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2198 wait $PID2 ; [ $? -ne 0 ] || error "stat must fail"
2202 run_test 43g "pdirops: unlink vs getattr =============="
2207 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2208 do_nodes $(comma_list $(mdts_nodes)) \
2209 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2212 ls -lia $DIR2/ > /dev/null &
2214 do_nodes $(comma_list $(mdts_nodes)) \
2215 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2216 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2221 run_test 43h "pdirops: unlink vs readdir =============="
2224 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2227 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2228 do_nodes $(comma_list $(mdts_nodes)) \
2229 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2232 $LFS mkdir -i 1 $DIR2/$tfile &
2234 do_nodes $(comma_list $(mdts_nodes)) \
2235 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2236 check_pdo_conflict $PID1 &&
2237 { wait $PID1; error "remote mkdir isn't blocked"; }
2238 wait $PID2 ; [ $? -eq 0 ] || error "remote mkdir must succeed"
2242 run_test 43i "pdirops: unlink vs remote mkdir"
2245 [[ $MDS1_VERSION -lt $(version_code 2.13.52) ]] &&
2246 skip "Need MDS version newer than 2.13.52"
2248 for i in {1..100}; do
2249 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_CREATE_RACE 0x167
2250 do_nodes $(comma_list $(mdts_nodes)) \
2251 "lctl set_param -n fail_loc=0x80000167 2>/dev/null ||
2256 mkdir $DIR2/$tdir && ((OK++))
2257 wait $PID1 && ((OK++))
2258 (( OK == 1 )) || error "exactly one mkdir should succeed"
2260 rmdir $DIR1/$tdir || error "rmdir failed"
2264 run_test 43j "racy mkdir return EEXIST =============="
2271 # We test in a separate directory to be able to unblock server thread in
2272 # cfs_race() if LCK_PW is taken on the parent by mdt_reint_unlink.
2273 test_mkdir $DIR2/$tdir
2274 touch $DIR2/$tdir/$tfile
2276 do_nodes $(comma_list $(mdts_nodes)) \
2277 "lctl set_param -n fail_loc=${fail_loc} || true" &>/dev/null
2278 echo content > $DIR1/$tdir/$tfile & PID1=$!
2280 multiop $DIR2/$tdir/$tfile u & PID2=$!
2284 echo -n "overwriting $tfile should succeed (err=$ret); "; }
2287 echo -n "unlinking $tfile should succeed (err=$ret);"; }
2290 do_nodes $(comma_list $(mdts_nodes)) \
2291 "lctl set_param -n fail_loc=0x0 || true" &>/dev/null
2298 [[ $MDS1_VERSION -le $(version_code 2.13.56) ]] ||
2299 skip "Need MDS version newer than 2.13.56"
2302 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN 0x169
2303 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN2 0x16a
2304 for fail_loc in "0x80000169" "0x8000016a"; do
2305 echo "Begin 100 tests with fail_loc=$fail_loc"
2307 for i in {1..100}; do
2309 msg=$(sub_test_43k "$fail_loc") ||
2310 { echo; error "iter=$i : $msg"; }
2320 run_test 43k "unlink vs create"
2322 # test 44: rename tgt and blocking operations
2325 touch $DIR1/$tfile-2
2326 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2327 do_nodes $(comma_list $(mdts_nodes)) \
2328 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2329 mv $DIR1/$tfile-2 $DIR1/$tfile &
2331 mkdir $DIR2/$tfile &
2333 do_nodes $(comma_list $(mdts_nodes)) \
2334 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2335 check_pdo_conflict $PID1 && { wait $PID1; date;error "mkdir isn't blocked"; }
2336 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
2341 run_test 44a "pdirops: rename tgt vs mkdir =============="
2345 touch $DIR1/$tfile-2
2346 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2347 do_nodes $(comma_list $(mdts_nodes)) \
2348 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2349 mv $DIR1/$tfile-2 $DIR1/$tfile &
2351 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2353 do_nodes $(comma_list $(mdts_nodes)) \
2354 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2355 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2356 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
2360 run_test 44b "pdirops: rename tgt vs create =============="
2364 touch $DIR1/$tfile-2
2365 touch $DIR1/$tfile-3
2366 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2367 do_nodes $(comma_list $(mdts_nodes)) \
2368 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2369 mv $DIR1/$tfile-2 $DIR1/$tfile &
2371 link $DIR2/$tfile-3 $DIR2/$tfile &
2373 do_nodes $(comma_list $(mdts_nodes)) \
2374 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2375 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2376 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
2380 run_test 44c "pdirops: rename tgt vs link =============="
2384 touch $DIR1/$tfile-2
2385 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2386 do_nodes $(comma_list $(mdts_nodes)) \
2387 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2388 mv $DIR1/$tfile-2 $DIR1/$tfile &
2392 do_nodes $(comma_list $(mdts_nodes)) \
2393 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2394 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2395 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
2399 run_test 44d "pdirops: rename tgt vs unlink =============="
2404 touch $DIR1/$tfile-2
2405 touch $DIR1/$tfile-3
2406 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2407 do_nodes $(comma_list $(mdts_nodes)) \
2408 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2409 mv $DIR1/$tfile-2 $DIR1/$tfile &
2411 mv $DIR2/$tfile-3 $DIR2/$tfile &
2413 do_nodes $(comma_list $(mdts_nodes)) \
2414 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2415 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2416 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2420 run_test 44e "pdirops: rename tgt and rename (tgt) =============="
2424 touch $DIR1/$tfile-2
2425 touch $DIR1/$tfile-3
2426 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2427 do_nodes $(comma_list $(mdts_nodes)) \
2428 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2429 mv $DIR1/$tfile-2 $DIR1/$tfile &
2431 mv $DIR2/$tfile $DIR2/$tfile-3 &
2433 do_nodes $(comma_list $(mdts_nodes)) \
2434 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2435 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2436 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2440 run_test 44f "pdirops: rename tgt and rename (src) =============="
2444 touch $DIR1/$tfile-2
2445 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2446 do_nodes $(comma_list $(mdts_nodes)) \
2447 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2448 mv $DIR1/$tfile-2 $DIR1/$tfile &
2450 stat $DIR2/$tfile > /dev/null &
2452 do_nodes $(comma_list $(mdts_nodes)) \
2453 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2454 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2455 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
2459 run_test 44g "pdirops: rename tgt vs getattr =============="
2463 touch $DIR1/$tfile-2
2464 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2465 do_nodes $(comma_list $(mdts_nodes)) \
2466 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2467 mv $DIR1/$tfile-2 $DIR1/$tfile &
2469 ls -lia $DIR2/ > /dev/null &
2471 do_nodes $(comma_list $(mdts_nodes)) \
2472 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2473 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2478 run_test 44h "pdirops: rename tgt vs readdir =============="
2480 # test 44: rename tgt and blocking operations
2482 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2484 touch $DIR1/$tfile-2
2485 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2486 do_nodes $(comma_list $(mdts_nodes)) \
2487 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2488 mv $DIR1/$tfile-2 $DIR1/$tfile &
2490 $LFS mkdir -i 1 $DIR2/$tfile &
2492 do_nodes $(comma_list $(mdts_nodes)) \
2493 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2494 check_pdo_conflict $PID1 && { wait $PID1;
2495 error "remote mkdir isn't blocked"; }
2496 wait $PID2 ; [ $? -ne 0 ] || error "remote mkdir must fail"
2500 run_test 44i "pdirops: rename tgt vs remote mkdir"
2502 # test 45: rename,mkdir doesn't fail with -EEXIST
2504 for i in {1..1000}; do
2505 mkdir $DIR1/$tdir || error "mkdir $tdir failed"
2506 mrename $DIR2/$tdir $DIR2/$tdir.$i > /dev/null ||
2507 error "mrename to $tdir.$i failed"
2512 run_test 45a "rename,mkdir doesn't return -EEXIST =============="
2517 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2518 do_nodes $(comma_list $(mdts_nodes)) \
2519 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2520 mv $DIR1/$tfile $DIR1/$tfile-2 &
2522 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2524 do_nodes $(comma_list $(mdts_nodes)) \
2525 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2526 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2527 wait $PID2 ; [ $? -eq 0 ] || error "create must succeed"
2531 run_test 45b "pdirops: rename src vs create =============="
2536 touch $DIR1/$tfile-3
2537 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2538 do_nodes $(comma_list $(mdts_nodes)) \
2539 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2540 mv $DIR1/$tfile $DIR1/$tfile-2 &
2542 link $DIR2/$tfile-3 $DIR2/$tfile &
2544 do_nodes $(comma_list $(mdts_nodes)) \
2545 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2546 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2547 wait $PID2 ; [ $? -eq 0 ] || error "link must succeed"
2551 run_test 45c "pdirops: rename src vs link =============="
2556 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2557 do_nodes $(comma_list $(mdts_nodes)) \
2558 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2559 mv $DIR1/$tfile $DIR1/$tfile-2 &
2563 do_nodes $(comma_list $(mdts_nodes)) \
2564 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2565 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2566 wait $PID2 ; [ $? -ne 0 ] || error "unlink must fail"
2570 run_test 45d "pdirops: rename src vs unlink =============="
2575 touch $DIR1/$tfile-3
2576 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2577 do_nodes $(comma_list $(mdts_nodes)) \
2578 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2579 mv $DIR1/$tfile $DIR1/$tfile-2 &
2581 mv $DIR2/$tfile-3 $DIR2/$tfile &
2583 do_nodes $(comma_list $(mdts_nodes)) \
2584 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2585 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2586 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2590 run_test 45e "pdirops: rename src and rename (tgt) =============="
2595 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2596 do_nodes $(comma_list $(mdts_nodes)) \
2597 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2598 mv $DIR1/$tfile $DIR1/$tfile-2 &
2600 mv $DIR2/$tfile $DIR2/$tfile-3 &
2602 do_nodes $(comma_list $(mdts_nodes)) \
2603 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2604 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2605 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
2609 run_test 45f "pdirops: rename src and rename (src) =============="
2614 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2615 do_nodes $(comma_list $(mdts_nodes)) \
2616 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2617 mv $DIR1/$tfile $DIR1/$tfile-2 &
2619 stat $DIR2/$tfile > /dev/null &
2621 do_nodes $(comma_list $(mdts_nodes)) \
2622 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2623 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2624 wait $PID2 ; [ $? -ne 0 ] || error "stat must fail"
2628 run_test 45g "pdirops: rename src vs getattr =============="
2633 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2634 do_nodes $(comma_list $(mdts_nodes)) \
2635 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2636 mv $DIR1/$tfile $DIR1/$tfile-2 &
2638 ls -lia $DIR2/ > /dev/null &
2639 do_nodes $(comma_list $(mdts_nodes)) \
2640 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2641 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2646 run_test 45h "pdirops: unlink vs readdir =============="
2649 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2652 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2653 do_nodes $(comma_list $(mdts_nodes)) \
2654 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2655 mv $DIR1/$tfile $DIR1/$tfile-2 &
2657 $LFS mkdir -i 1 $DIR2/$tfile &
2659 do_nodes $(comma_list $(mdts_nodes)) \
2660 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2661 check_pdo_conflict $PID1 && { wait $PID1;
2662 error "create remote dir isn't blocked"; }
2663 wait $PID2 ; [ $? -eq 0 ] || error "create remote dir must succeed"
2667 run_test 45i "pdirops: rename src vs remote mkdir"
2674 # We test in a sparate directory to be able to unblock server thread in
2675 # cfs_race if LCK_PW is taken on the parent by mdt_reint_rename.
2676 test_mkdir $DIR2/$tdir
2677 echo file1 > $DIR2/$tdir/$tfile
2678 echo file2 > $DIR2/$tdir/$tfile-2
2680 do_nodes $(comma_list $(mdts_nodes)) \
2681 "lctl set_param -n fail_loc=${fail_loc} || true" &>/dev/null
2683 cat $DIR1/$tdir/$tfile >/dev/null &
2686 mrename $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile > /dev/null &
2690 { ret=$?; echo -n "cat $tfile should succeed (err=$ret); "; }
2693 echo -n "mrename $tfile-2 to $tfile failed (err=$ret);"; }
2696 do_nodes $(comma_list $(mdts_nodes)) \
2697 "lctl set_param -n fail_loc=0x0 || true" &>/dev/null
2704 [[ $MDS1_VERSION -le $(version_code 2.13.56) ]] ||
2705 skip "Need MDS version newer than 2.13.56"
2708 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN 0x169
2709 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN2 0x16a
2710 for fail_loc in "0x80000169" "0x8000016a"; do
2711 echo "Begin 100 tests with fail_loc=$fail_loc"
2713 for i in {1..100}; do
2715 msg=$(sub_test_45j "$fail_loc") ||
2716 { echo; error "iter=$i : $msg"; }
2721 run_test 45j "read vs rename =============="
2723 # test 46: link and blocking operations
2726 touch $DIR1/$tfile-2
2727 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2728 do_nodes $(comma_list $(mdts_nodes)) \
2729 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2730 link $DIR1/$tfile-2 $DIR1/$tfile &
2732 mkdir $DIR2/$tfile &
2734 do_nodes $(comma_list $(mdts_nodes)) \
2735 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2736 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2737 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
2741 run_test 46a "pdirops: link vs mkdir =============="
2745 touch $DIR1/$tfile-2
2746 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2747 do_nodes $(comma_list $(mdts_nodes)) \
2748 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2749 link $DIR1/$tfile-2 $DIR1/$tfile &
2751 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2753 do_nodes $(comma_list $(mdts_nodes)) \
2754 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2755 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2756 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
2760 run_test 46b "pdirops: link vs create =============="
2764 touch $DIR1/$tfile-2
2765 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2766 do_nodes $(comma_list $(mdts_nodes)) \
2767 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2768 link $DIR1/$tfile-2 $DIR1/$tfile &
2770 link $DIR2/$tfile $DIR2/$tfile &
2772 do_nodes $(comma_list $(mdts_nodes)) \
2773 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2774 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2775 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
2779 run_test 46c "pdirops: link vs link =============="
2783 touch $DIR1/$tfile-2
2784 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2785 do_nodes $(comma_list $(mdts_nodes)) \
2786 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2787 link $DIR1/$tfile-2 $DIR1/$tfile &
2791 do_nodes $(comma_list $(mdts_nodes)) \
2792 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2793 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2794 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
2798 run_test 46d "pdirops: link vs unlink =============="
2802 touch $DIR1/$tfile-2
2803 touch $DIR1/$tfile-3
2804 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2805 do_nodes $(comma_list $(mdts_nodes)) \
2806 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2807 link $DIR1/$tfile-2 $DIR1/$tfile &
2809 mv $DIR2/$tfile-3 $DIR2/$tfile &
2811 do_nodes $(comma_list $(mdts_nodes)) \
2812 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2813 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2814 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2818 run_test 46e "pdirops: link and rename (tgt) =============="
2822 touch $DIR1/$tfile-2
2823 touch $DIR1/$tfile-3
2824 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2825 do_nodes $(comma_list $(mdts_nodes)) \
2826 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2827 link $DIR1/$tfile-2 $DIR1/$tfile &
2829 mv $DIR2/$tfile $DIR2/$tfile-3 &
2831 do_nodes $(comma_list $(mdts_nodes)) \
2832 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2833 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2834 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2838 run_test 46f "pdirops: link and rename (src) =============="
2842 touch $DIR1/$tfile-2
2843 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2844 do_nodes $(comma_list $(mdts_nodes)) \
2845 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2846 link $DIR1/$tfile-2 $DIR1/$tfile &
2848 stat $DIR2/$tfile > /dev/null &
2850 do_nodes $(comma_list $(mdts_nodes)) \
2851 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2852 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2853 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
2857 run_test 46g "pdirops: link vs getattr =============="
2861 touch $DIR1/$tfile-2
2862 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2863 do_nodes $(comma_list $(mdts_nodes)) \
2864 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2865 link $DIR1/$tfile-2 $DIR1/$tfile &
2867 ls -lia $DIR2/ > /dev/null &
2869 do_nodes $(comma_list $(mdts_nodes)) \
2870 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2871 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2876 run_test 46h "pdirops: link vs readdir =============="
2879 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2881 touch $DIR1/$tfile-2
2882 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2883 do_nodes $(comma_list $(mdts_nodes)) \
2884 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2885 link $DIR1/$tfile-2 $DIR1/$tfile &
2887 $LFS mkdir -i 1 $DIR2/$tfile &
2889 do_nodes $(comma_list $(mdts_nodes)) \
2890 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2891 check_pdo_conflict $PID1 && { wait $PID1;
2892 error "remote mkdir isn't blocked"; }
2893 wait $PID2 ; [ $? -ne 0 ] || error "remote mkdir must fail"
2897 run_test 46i "pdirops: link vs remote mkdir"
2899 # test 47: remote mkdir and blocking operations
2901 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2902 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2904 do_nodes $(comma_list $(mdts_nodes)) \
2905 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2906 $LFS mkdir -i 1 $DIR1/$tfile &
2908 mkdir $DIR2/$tfile &
2910 do_nodes $(comma_list $(mdts_nodes)) \
2911 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2912 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2913 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
2917 run_test 47a "pdirops: remote mkdir vs mkdir"
2920 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2921 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2923 do_nodes $(comma_list $(mdts_nodes)) \
2924 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2925 $LFS mkdir -i 1 $DIR1/$tfile &
2927 sleep 1 # please do not remove this sleep, see LU-10754
2928 multiop $DIR2/$tfile oO_CREAT:O_EXCL:c &
2930 do_nodes $(comma_list $(mdts_nodes)) \
2931 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2932 check_pdo_conflict $PID1 && { wait $PID1;
2933 error "create isn't blocked"; }
2934 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
2938 run_test 47b "pdirops: remote mkdir vs create"
2941 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2943 touch $DIR1/$tfile-2
2944 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2945 do_nodes $(comma_list $(mdts_nodes)) \
2946 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2947 $LFS mkdir -i 1 $DIR1/$tfile &
2949 link $DIR2/$tfile-2 $DIR2/$tfile &
2951 do_nodes $(comma_list $(mdts_nodes)) \
2952 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2953 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2954 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
2958 run_test 47c "pdirops: remote mkdir vs link"
2961 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2963 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2964 do_nodes $(comma_list $(mdts_nodes)) \
2965 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2966 $LFS mkdir -i 1 $DIR1/$tfile &
2968 rmdir $DIR2/$tfile &
2970 do_nodes $(comma_list $(mdts_nodes)) \
2971 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2972 check_pdo_conflict $PID1 && { wait $PID1;
2973 error "unlink isn't blocked"; }
2974 wait $PID2 ; [ $? -eq 0 ] || error "rmdir must succeed"
2978 run_test 47d "pdirops: remote mkdir vs unlink"
2981 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2983 touch $DIR1/$tfile-2
2984 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2985 do_nodes $(comma_list $(mdts_nodes)) \
2986 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2987 $LFS mkdir -i 1 $DIR1/$tfile &
2989 mv -T $DIR2/$tfile-2 $DIR2/$tfile &
2991 do_nodes $(comma_list $(mdts_nodes)) \
2992 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2993 check_pdo_conflict $PID1 && { wait $PID1;
2994 error "rename isn't blocked"; }
2995 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
2999 run_test 47e "pdirops: remote mkdir and rename (tgt)"
3002 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3004 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
3005 do_nodes $(comma_list $(mdts_nodes)) \
3006 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
3007 $LFS mkdir -i 1 $DIR1/$tfile &
3009 mv $DIR2/$tfile $DIR2/$tfile-2 &
3011 do_nodes $(comma_list $(mdts_nodes)) \
3012 "lctl set_param -n fail_loc=0 2>/dev/null || true"
3013 check_pdo_conflict $PID1 && { wait $PID1;
3014 error "rename isn't blocked"; }
3015 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
3019 run_test 47f "pdirops: remote mkdir and rename (src)"
3022 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3026 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
3027 do_nodes $(comma_list $(mdts_nodes)) \
3028 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
3029 $LFS mkdir -i 1 $DIR1/$tfile &
3031 stat $DIR2/$tfile > /dev/null &
3033 do_nodes $(comma_list $(mdts_nodes)) \
3034 "lctl set_param -n fail_loc=0 2>/dev/null || true"
3035 check_pdo_conflict $PID1 && { wait $PID1;
3036 error "getattr isn't blocked"; }
3037 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
3041 run_test 47g "pdirops: remote mkdir vs getattr"
3045 dd if=/dev/zero of=$DIR1/$tfile bs=1K count=10
3046 #define OBD_FAIL_OSC_CP_ENQ_RACE 0x410
3047 do_facet client "lctl set_param fail_loc=0x410"
3048 $TRUNCATE $DIR2/$tfile $trunc_size
3049 do_facet client "lctl set_param fail_loc=0x0"
3051 size=`stat -c %s $DIR2/$tfile`
3052 [ $size -eq $trunc_size ] || error "wrong size"
3054 run_test 50 "osc lvb attrs: enqueue vs. CP AST =============="
3058 local origfile=/etc/hosts
3060 filesize=$(stat -c %s $origfile)
3062 # create an empty file
3063 $MCREATE $DIR1/$tfile || error "can't create $DIR1/$tfile"
3064 # cache layout lock on both mount point
3065 stat $DIR1/$tfile > /dev/null || error "stat $DIR1/$tfile failed"
3066 stat $DIR2/$tfile > /dev/null || error "stat $DIR2/$tfile failed"
3068 # open and sleep 2 seconds then read
3069 $MULTIOP $DIR2/$tfile o_2r${filesize}c &
3073 # create the layout of testing file
3074 dd if=$origfile of=$DIR1/$tfile conv=notrunc > /dev/null ||
3075 error "dd $DIR1/$tfile failed"
3077 # MULTIOP proc should be able to read enough bytes and exit
3078 for ((i = 0; i < 6; i++)); do
3080 kill -0 $pid || break
3082 kill -0 $pid 2> /dev/null && error "multiop is still there"
3083 cmp $origfile $DIR2/$tfile || error "$origfile and $DIR2/$tfile differs"
3087 run_test 51a "layout lock: refresh layout should work"
3090 [[ "$MDS1_VERSION" -ge $(version_code 2.3.59) ]] ||
3091 skip "Need MDS version at least 2.3.59"
3093 local tmpfile=`mktemp`
3095 $LFS setstripe -E 1M -c 1 -E -1 --extension-size 64M $DIR1/$tfile ||
3096 error "Create $DIR1/$tfile failed"
3098 dd if=/dev/zero of=$DIR1/$tfile bs=1k count=1 conv=notrunc ||
3099 error "dd $DIR1/$tfile failed"
3101 # delay glimpse so that layout has changed when glimpse finish
3102 #define OBD_FAIL_GLIMPSE_DELAY 0x1404
3103 $LCTL set_param fail_loc=0x1404 fail_val=4
3104 stat -c %s $DIR2/$tfile |tee $tmpfile &
3108 # extend layout of testing file
3109 dd if=/dev/zero of=$DIR1/$tfile bs=1M count=1 seek=2 conv=notrunc ||
3110 error "dd $DIR1/$tfile failed"
3113 local fsize=$(cat $tmpfile)
3115 [ x$fsize = x3145728 ] || error "file size is $fsize, should be 3145728"
3117 rm -f $DIR1/$tfile $tmpfile
3119 run_test 51b "layout lock: glimpse should be able to restart if layout changed"
3122 [ $OSTCOUNT -ge 2 ] || { skip "needs >= 2 osts"; return; }
3124 # set default layout to have 1 stripe
3126 $LFS setstripe -c 1 $DIR1/$tdir
3128 # create a file with empty layout
3129 $MCREATE $DIR1/$tdir/$tfile ||
3130 error "$MCREATE $DIR1/$tdir/$tfile failed"
3132 #define OBD_FAIL_MDS_LL_BLOCK 0x172
3133 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x172
3135 # change the layout of testing file
3136 echo "Setting layout to have $OSTCOUNT stripes ..."
3137 $LFS setstripe -c $OSTCOUNT $DIR1/$tdir/$tfile &
3141 # write something to the file, it should be blocked on fetching layout
3142 dd if=/dev/zero of=$DIR2/$tdir/$tfile bs=1k count=1 conv=notrunc
3143 local stripe_count=$($LFS getstripe -c $DIR2/$tdir/$tfile)
3146 # lod_qos.c::min_stripe_count() allows setstripe with a default stripe
3147 # count to succeed with only 3/4 of the number of stripes (rounded up),
3148 # so creating striped files does not fail if an OST is offline or full
3149 [ $stripe_count -ge $((OSTCOUNT - $OSTCOUNT / 4)) ] ||
3150 error "bad layout: getstripe -c $stripe_count < $OSTCOUNT * 3/4"
3154 run_test 51c "layout lock: IT_LAYOUT blocked and correct layout can be returned"
3157 dd if=/dev/zero of=/$DIR1/$tfile bs=1M count=1
3158 cancel_lru_locks mdc
3160 # open should grant LAYOUT lock, mmap and read will install pages
3161 $MULTIOP $DIR1/$tfile oO_RDWR:SMR_Uc &
3165 # rss before revoking
3166 local br=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
3167 echo "Before revoking layout lock: $br KB mapped"
3169 # cancel layout lock manually
3170 cancel_lru_locks mdc
3172 # rss after revoking
3173 local ar=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
3176 wait $PID || error "wait PID $PID failed"
3178 [ $ar -eq 0 ] || error "rss before: $br, after $ar, some pages remained"
3180 run_test 51d "layout lock: losing layout lock should clean up memory map region"
3185 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eW_E+eUc &
3189 $LFS getstripe $DIR2/$tfile
3191 wait $pid || error "multiop failed"
3193 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
3197 $LFS getstripe $DIR2/$tfile
3199 wait $pid || error "multiop failed"
3201 run_test 51e "lfs getstripe does not break leases, part 2"
3205 echo "==> rename vs getattr vs setxattr should not deadlock"
3206 mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed"
3208 do_facet mds1 $LCTL set_param fail_loc=$1
3210 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 &
3218 setfattr -n user.attr1 -v value1 $DIR2/d1 || error "(2) setfattr failed"
3219 wait $PID1 || error "(3) mv failed"
3220 wait $PID2 || error "(4) stat failed"
3227 echo "==> rename vs getattr vs open vs getattr should not deadlock"
3228 mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed"
3230 do_facet mds1 $LCTL set_param fail_loc=$1
3232 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 &
3240 $MULTIOP $DIR2/d1/d2 Oc &
3244 stat $DIR/d1 || error "(2) stat failed"
3246 wait $PID1 || error "(3) mv failed"
3247 wait $PID2 || error "(4) stat failed"
3248 wait $PID3 && error "(5) multiop failed"
3254 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
3255 save_lustre_params client "llite.*.xattr_cache" > $p
3256 lctl set_param llite.*.xattr_cache 1 ||
3257 { skip "xattr cache is not supported"; return 0; }
3259 #define OBD_FAIL_MDS_RENAME 0x153
3260 #define OBD_FAIL_MDS_RENAME2 0x154
3261 test_54_part1 0x80000153 || error 10
3262 test_54_part1 0x80000154 || error 11
3263 test_54_part2 0x80000153 || error 12
3264 test_54_part2 0x80000154 || error 13
3266 restore_lustre_params < $p
3269 run_test 54 "rename locking"
3272 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
3274 #define OBD_FAIL_MDS_RENAME4 0x156
3275 do_facet mds1 $LCTL set_param fail_loc=0x80000156
3277 mv -T $DIR/d1/d2 $DIR/d3/d2 &
3282 wait $PID1 && error "(2) mv succeeded"
3286 run_test 55a "rename vs unlink target dir"
3290 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
3292 #define OBD_FAIL_MDS_RENAME4 0x156
3293 do_facet mds1 $LCTL set_param fail_loc=0x80000156
3295 mv -T $DIR/d1/d2 $DIR/d3/d2 &
3300 wait $PID1 && error "(2) mv succeeded"
3304 run_test 55b "rename vs unlink source dir"
3308 mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
3310 #define OBD_FAIL_MDS_RENAME4 0x156
3311 do_facet mds1 $LCTL set_param fail_loc=0x156
3313 mv -T $DIR/d1/d2 $DIR/d3/d2 &
3317 # while rename is sleeping, open and remove d3
3318 $MULTIOP $DIR2/d3 D_c &
3324 # while rename is sleeping 2nd time, close d3
3326 wait $PID2 || error "(3) multiop failed"
3328 wait $PID1 && error "(2) mv succeeded"
3332 run_test 55c "rename vs unlink orphan target dir"
3338 #define OBD_FAIL_MDS_RENAME3 0x155
3339 do_facet mds1 $LCTL