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
513 (( "$MDS1_VERSION" >= $(version_code 2.13.53) )) ||
514 skip "Need MDS version at least 2.13.53"
516 local file1=$DIR1/$tfile
517 local file2=$DIR2/$tfile
519 # client1 write 10M data
520 dd if=/dev/zero of=$file1 bs=1M count=10
522 cancel_lru_locks osc > /dev/null
523 # use lockahead to generate one PW lock to keep LVB loaded.
524 $LFS ladvise -a lockahead --start 0 --length 1M \
526 # direct write to extend file size on client2
527 dd if=/dev/zero of=$file2 bs=1M seek=20 count=1 \
528 oflag=direct conv=notrunc
529 local filesize=$(stat -c %s $file2)
530 [ "$filesize" -eq 22020096 ] ||
531 error "expected filesize 22020096 got $filesize"
534 run_test 16e "Verify size consistency for O_DIRECT write"
536 test_17() { # bug 3513, 3667
537 remote_ost_nodsh && skip "remote OST with nodsh" && return
539 lfs setstripe $DIR1/$tfile -i 0 -c 1
540 cp $SAMPLE_FILE $DIR1/$tfile
541 cancel_lru_locks osc > /dev/null
542 #define OBD_FAIL_ONCE|OBD_FAIL_LDLM_CREATE_RESOURCE 0x30a
543 do_facet ost1 lctl set_param fail_loc=0x8000030a
544 ls -ls $DIR1/$tfile | awk '{ print $1,$6 }' > $DIR1/$tfile-1 & \
545 ls -ls $DIR2/$tfile | awk '{ print $1,$6 }' > $DIR2/$tfile-2
547 diff -u $DIR1/$tfile-1 $DIR2/$tfile-2 || error "files are different"
549 run_test 17 "resource creation/LVB creation race ==============="
552 # turn e.g. ALWAYS_EXCEPT="18c" into "-e 3"
555 for idx in {a..z}; do
556 local ptr=EXCEPT_ALWAYS_18$idx
557 [ x${!ptr} = xtrue ] || continue
559 excepts="$excepts -e $(($(printf %d \'$idx)-96))"
562 excepts="$excepts -e 7 -e 8 -e 9"
563 $LUSTRE/tests/mmap_sanity -d $MOUNT1 -m $MOUNT2 $excepts ||
564 error "mmap_sanity test failed"
567 run_test 18 "mmap sanity check ================================="
569 test_19() { # bug3811
570 local node=$(facet_active_host ost1)
571 local device="$FSNAME-OST*"
573 [ "x$DOM" = "xyes" ] && node=$(facet_active_host $SINGLEMDS) &&
574 device="$FSNAME-MDT*"
576 # check whether obdfilter is cache capable at all
577 get_osd_param $node $device read_cache_enable >/dev/null ||
578 skip "not cache-capable obdfilter"
580 local max=$(get_osd_param $node $device readcache_max_filesize |\
582 set_osd_param $node $device readcache_max_filesize 4096
583 dd if=/dev/urandom of=$TMP/$tfile bs=512k count=32
584 local SUM=$(cksum $TMP/$tfile | cut -d" " -f 1,2)
585 cp $TMP/$tfile $DIR1/$tfile
586 for i in `seq 1 20`; do
587 [ $((i % 5)) -eq 0 ] && log "$testname loop $i"
588 cancel_lru_locks $OSC > /dev/null
589 cksum $DIR1/$tfile | cut -d" " -f 1,2 > $TMP/sum1 & \
590 cksum $DIR2/$tfile | cut -d" " -f 1,2 > $TMP/sum2
592 [ "$(cat $TMP/sum1)" = "$SUM" ] || \
593 error "$DIR1/$tfile $(cat $TMP/sum1) != $SUM"
594 [ "$(cat $TMP/sum2)" = "$SUM" ] || \
595 error "$DIR2/$tfile $(cat $TMP/sum2) != $SUM"
597 set_osd_param $node $device readcache_max_filesize $max
600 run_test 19 "test concurrent uncached read races ==============="
603 test_mkdir $DIR1/$tdir
605 CNT=$($LCTL get_param -n llite.*.dump_page_cache | wc -l)
606 $MULTIOP $DIR1/$tdir/$tfile Ow8190c
607 $MULTIOP $DIR2/$tdir/$tfile Oz8194w8190c
608 $MULTIOP $DIR1/$tdir/$tfile Oz0r8190c
610 CNT2=$($LCTL get_param -n llite.*.dump_page_cache | wc -l)
611 [[ $CNT2 == $CNT ]] ||
612 error $((CNT2 - CNT))" page left in cache after lock cancel"
614 run_test 20 "test extra readahead page left in cache ===="
621 test_21() { # Bug 5907
622 test_mkdir $DIR1/$tdir
623 mount /etc $DIR1/$tdir --bind || error "mount failed" # Poor man's mount.
625 rmdir -v $DIR1/$tdir && error "Removed mounted directory"
626 rmdir -v $DIR2/$tdir && echo "Removed mounted directory from another mountpoint, needs to be fixed"
627 test -d $DIR1/$tdir || error "Mounted directory disappeared"
629 test -d $DIR2/$tdir || test -d $DIR1/$tdir && error "Removed dir still visible after umount"
632 run_test 21 " Try to remove mountpoint on another dir ===="
634 test_23() { # Bug 5972
635 local at_diff=$(do_facet $SINGLEMDS \
636 $LCTL get_param -n mdd.*MDT0000*.atime_diff | head -n1)
637 echo "atime should be updated while another read" > $DIR1/$tfile
639 # clear the lock(mode: LCK_PW) gotten from creating operation
640 cancel_lru_locks $OSC
643 sleep $((at_diff + 1))
645 echo "starting reads"
646 multiop_bg_pause $DIR1/$tfile or20_c || return 1
647 # with SOM and opencache enabled, we need to close a file and cancel
648 # open lock to get atime propogated to MDS
649 kill -USR1 $! || return 2
652 time2=$(stat -c "%X" $DIR/$tfile)
653 echo "new atime is $time2"
655 [ $time2 -gt $time1 ] || error "atime was not updated"
656 rm -f $DIR1/$tfile || error "rm -f $DIR1/$tfile failed"
659 run_test 23 " others should see updated atime while another read===="
663 lfs df || error "lfs df failed"
664 lfs df -ih || error "lfs df -ih failed"
665 lfs df -h $DIR1 || error "lfs df -h $DIR1 failed"
666 lfs df -i $DIR2 || error "lfs df -i $DIR2 failed"
667 lfs df $DIR1/$tfile || error "lfs df $DIR1/$tfile failed"
668 lfs df -ih $DIR2/$tfile || error "lfs df -ih $DIR2/$tfile failed"
670 OSC=`lctl dl | awk '/-osc-|OSC.*MNT/ {print $4}' | head -n 1`
671 # OSC=`lctl dl | awk '/-osc-/ {print $4}' | head -n 1`
672 lctl --device %osc deactivate
673 lfs df -i || error "lfs df -i with deactivated OSC failed"
674 lctl --device %osc activate
675 lfs df || error "lfs df with reactivated OSC failed"
677 run_test 24a "lfs df [-ih] [path] test ========================="
681 fsnum=$(lfs_df | grep -c "summary")
682 [ $fsnum -eq 2 ] || error "lfs df shows $fsnum != 2 filesystems."
684 run_test 24b "lfs df should show both filesystems ==============="
687 local acl=$(lctl get_param -n mdc.*MDT0000-mdc-*.connect_flags |
689 [ "$acl" -lt 1 ] && skip "must have acl, skipping" && return
692 touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
693 chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
695 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
696 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
697 error "setfacl $DIR2/$tdir #1"
698 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
699 setfacl -m u:$RUNAS_ID:r-x -m g:$RUNAS_GID:r-x $DIR1/$tdir ||
700 error "setfacl $DIR2/$tdir #2"
701 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
702 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
703 error "setfacl $DIR2/$tdir #3"
704 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
705 setfacl -x u:$RUNAS_ID: -x g:$RUNAS_GID: $DIR1/$tdir ||
706 error "setfacl $DIR2/$tdir #4"
707 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
711 run_test 25a "change ACL on one mountpoint be seen on another ==="
714 local acl=$(lctl get_param -n mdc.*MDT0000-mdc-*.connect_flags |
716 [ "$acl" -lt 1 ] && skip "must have acl, skipping" && return
718 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
721 $LFS mkdir -i 1 $DIR1/$tdir
722 touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
723 chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
725 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
726 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
727 error "setfacl $DIR2/$tdir #1"
728 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
729 setfacl -m u:$RUNAS_ID:r-x -m g:$RUNAS_GID:r-x $DIR1/$tdir ||
730 error "setfacl $DIR2/$tdir #2"
731 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
732 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
733 error "setfacl $DIR2/$tdir #3"
734 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
735 setfacl -x u:$RUNAS_ID: -x g:$RUNAS_GID: $DIR1/$tdir ||
736 error "setfacl $DIR2/$tdir #4"
737 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
741 run_test 25b "change ACL under remote dir on one mountpoint be seen on another"
744 utime $DIR1/f26a -s $DIR2/f26a || error "utime failed for $DIR1/f26a"
746 run_test 26a "allow mtime to get older"
751 echo "aaa" >> $DIR1/$tfile
753 chmod a+x $DIR2/$tfile
754 mt1=`stat -c %Y $DIR1/$tfile`
755 mt2=`stat -c %Y $DIR2/$tfile`
757 if [ x"$mt1" != x"$mt2" ]; then
758 error "not equal mtime, client1: "$mt1", client2: "$mt2"."
761 run_test 26b "sync mtime between ost and mds"
764 cancel_lru_locks $OSC
766 dd if=/dev/zero of=$DIR2/$tfile bs=$((4096+4))k conv=notrunc count=4 seek=3 &
771 dd if=/dev/zero of=$DIR1/$tfile bs=$((16384-1024))k conv=notrunc count=1 seek=4 &
776 dd if=/dev/zero of=$DIR1/$tfile bs=8k conv=notrunc count=1 seek=0
778 lctl set_param -n ldlm.dump_namespaces ""
779 wait $DD1_PID $DD2_PID
780 [ $? -ne 0 ] && lctl dk $TMP/debug || true
782 run_test 27 "align non-overlapping extent locks from request ==="
784 test_28() { # bug 9977
785 ECHO_UUID="ECHO_osc1_UUID"
786 tOST=$($LCTL dl | awk '/-osc-|OSC.*MNT/ { print $4 }' | head -n1)
788 $LFS setstripe $DIR1/$tfile -S 1048576 -i 0 -c 2
789 tOBJID=`$LFS getstripe $DIR1/$tfile | awk '$1 == 1 {print $2}'`
790 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2
794 attach echo_client ECHO_osc1 $ECHO_UUID
798 tECHOID=`$LCTL dl | grep $ECHO_UUID | awk '{ print $1 }'`
799 $LCTL --device $tECHOID destroy "${tOBJID}:0"
807 # reading of 1st stripe should pass
808 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error "dd failed"
809 # reading of 2nd stripe should fail (this stripe was destroyed)
810 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 && error
812 # now, recreating test file
813 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2 || error "dd failed"
814 # reading of 1st stripe should pass
815 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error "dd failed"
816 # reading of 2nd stripe should pass
817 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 ||
820 run_test 28 "read/write/truncate file with lost stripes"
822 test_30() { #b=11110, LU-2523
823 test_mkdir $DIR1/$tdir
824 cp -f /bin/bash $DIR1/$tdir/bash
825 /bin/sh -c 'sleep 1; rm -f $DIR2/$tdir/bash; cp /bin/bash $DIR2/$tdir' &
826 $DIR1/$tdir/bash -c 'sleep 2;
827 openfile -f O_RDONLY /proc/$$/exe >& /dev/null; echo $?'
831 run_test 30 "recreate file race"
834 test_mkdir $DIR1/$tdir
835 local writes=$(LANG=C dd if=/dev/zero of=$DIR/$tdir/$tfile \
836 count=1 2>&1 | awk 'BEGIN { FS="+" } /out/ {print $1}')
837 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
838 lctl set_param fail_loc=0x314
839 local reads=$(LANG=C dd if=$DIR2/$tdir/$tfile of=/dev/null 2>&1 |
840 awk 'BEGIN { FS="+" } /in/ {print $1}')
841 [ $reads -eq $writes ] || error "read" $reads "blocks, must be" $writes
843 run_test 31a "voluntary cancel / blocking ast race=============="
846 remote_ost || { skip "local OST" && return 0; }
847 remote_ost_nodsh && skip "remote OST w/o dsh" && return 0
849 # make sure there is no local locks due to destroy
850 wait_mds_ost_sync || error "wait_mds_ost_sync()"
851 wait_delete_completed || error "wait_delete_completed()"
853 test_mkdir $DIR1/$tdir
854 lfs setstripe $DIR/$tdir/$tfile -i 0 -c 1
855 cp /etc/hosts $DIR/$tdir/$tfile
856 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
857 lctl set_param fail_loc=0x314
858 #define OBD_FAIL_LDLM_OST_FAIL_RACE 0x316
859 do_facet ost1 lctl set_param fail_loc=0x316
861 cat $DIR2/$tdir/$tfile > /dev/null 2>&1
862 lctl set_param fail_loc=0
863 do_facet ost1 lctl set_param fail_loc=0
864 # cleanup: reconnect the client back
867 run_test 31b "voluntary OST cancel / blocking ast race=============="
869 #LU-14949 - multi-client version of the test 31r in sanity.
871 touch $DIR/$tfile.target
872 touch $DIR/$tfile.source
874 ls -l $DIR/$tfile.target # cache it for sure
876 #OBD_FAIL_LLITE_OPEN_DELAY 0x1419
877 $LCTL set_param fail_loc=0x1419 fail_val=3
878 cat $DIR/$tfile.target &
881 # Guarantee open is waiting before we get here
883 mv $DIR2/$tfile.source $DIR2/$tfile.target
887 if [[ $RC -ne 0 ]]; then
888 error "open with cat failed, rc=$RC"
891 run_test 31r "open-rename(replace) race"
893 test_32b() { # bug 11270
894 remote_ost_nodsh && skip "remote OST with nodsh" && return
897 local facets=$(get_facets OST)
898 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
900 save_lustre_params client "osc.*.contention_seconds" > $p
901 save_lustre_params $facets \
902 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
903 save_lustre_params $facets \
904 "ldlm.namespaces.filter-*.contended_locks" >> $p
905 save_lustre_params $facets \
906 "ldlm.namespaces.filter-*.contention_seconds" >> $p
907 clear_stats $OSC.*.${OSC}_stats
909 # agressive lockless i/o settings
910 do_nodes $(comma_list $(osts_nodes)) \
911 "lctl set_param -n ldlm.namespaces.*.max_nolock_bytes=2000000 \
912 ldlm.namespaces.filter-*.contended_locks=0 \
913 ldlm.namespaces.filter-*.contention_seconds=60"
914 lctl set_param -n $OSC.*.contention_seconds=60
916 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > \
918 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > \
921 [ $(calc_stats $OSC.*.${OSC}_stats lockless_write_bytes) -ne 0 ] ||
922 error "lockless i/o was not triggered"
923 # disable lockless i/o (it is disabled by default)
924 do_nodes $(comma_list $(osts_nodes)) \
925 "lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes=0 \
926 ldlm.namespaces.filter-*.contended_locks=32 \
927 ldlm.namespaces.filter-*.contention_seconds=0"
928 # set contention_seconds to 0 at client too, otherwise Lustre still
929 # remembers lock contention
930 lctl set_param -n $OSC.*.contention_seconds=0
931 clear_stats $OSC.*.${OSC}_stats
933 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > \
935 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > \
938 [ $(calc_stats $OSC.*.${OSC}_stats lockless_write_bytes) -eq 0 ] ||
939 error "lockless i/o works when disabled"
941 restore_lustre_params <$p
944 # Disable test 32b prior to full removal
945 #run_test 32b "lockless i/o"
949 local mdts=$(get_facets MDS)
954 for mds in ${mdts//,/ }; do
956 dev=$(basename $(do_facet $mds "lctl get_param -n osd*.${!varsvc}.mntdev|\
957 xargs readlink -f" ))
958 val=$(do_facet $mds "cat /proc/fs/jbd*/${dev}{,:*,-*}/info 2>/dev/null |
961 stat=$(( stat + val))
966 # commit on sharing tests
968 remote_mds_nodsh && skip "remote MDS with nodsh" && return
970 [ -z "$CLIENTS" ] && skip "Need two or more clients, have $CLIENTS"
971 [ $CLIENTCOUNT -lt 2 ] &&
972 skip "Need two or more clients, have $CLIENTCOUNT"
974 local nfiles=${TEST33_NFILES:-10000}
975 local param_file=$TMP/$tfile-params
981 save_lustre_params $(get_facets MDS) \
982 "mdt.*.commit_on_sharing" > $param_file
985 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
989 do_nodes $CLIENT1,$CLIENT2 "mkdir -p $DIR1/$tdir-\\\$(hostname)-$i"
991 [ "$mds1_FSTYPE" = ldiskfs ] && jbdold=$(print_jbd_stat)
992 echo "=== START createmany old: $jbdold transaction"
993 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")
994 [ "$mds1_FSTYPE" = ldiskfs ] && jbdnew=$(print_jbd_stat)
995 [ "$mds1_FSTYPE" = ldiskfs ] && jbd=$(( jbdnew - jbdold ))
996 echo "=== END createmany new: $jbdnew transaction : $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
997 [ "$mds1_FSTYPE" = ldiskfs ] && avgjbd=$(( avgjbd + jbd ))
998 avgtime=$(( avgtime + elapsed ))
1000 eval cos${COS}_jbd=$((avgjbd / 3))
1001 eval cos${COS}_time=$((avgtime / 3))
1004 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
1005 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
1006 [ "$cos0_jbd" != 0 ] &&
1007 echo "COS=1 vs COS=0 jbd: $((((cos1_jbd/cos0_jbd - 1)) * 100 )) %"
1008 [ "$cos0_time" != 0 ] &&
1009 echo "COS=1 vs COS=0 time: $((((cos1_time/cos0_time - 1)) * 100 )) %"
1011 restore_lustre_params < $param_file
1015 run_test 33a "commit on sharing, cross crete/delete, 2 clients, benchmark"
1017 # commit on sharing tests
1019 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1021 [ -n "$CLIENTS" ] || { skip "Need two or more clients" && return 0; }
1022 [ $CLIENTCOUNT -ge 2 ] ||
1023 { skip "Need two or more clients, have $CLIENTCOUNT" &&
1025 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1027 local nfiles=${TEST33_NFILES:-10000}
1028 local param_file=$TMP/$tfile-params
1030 save_lustre_params $(get_facets MDS) \
1031 "mdt.*.commit_on_sharing" > $param_file
1040 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
1044 do_node $CLIENT1 "$LFS mkdir -i $MDTIDX \
1045 $DIR1/$tdir-\\\$(hostname)-$i"
1047 jbdold=$(print_jbd_stat)
1048 echo "=== START createmany old: $jbdold transaction"
1049 local elapsed=$(do_and_time "do_nodes $CLIENT1,$CLIENT2\
1050 createmany -o $DIR1/$tdir-\\\$(hostname)-$i/f- \
1051 -r$DIR2/$tdir-\\\$(hostname)-$i/f- $nfiles > \
1053 jbdnew=$(print_jbd_stat)
1054 jbd=$(( jbdnew - jbdold ))
1055 echo "=== END createmany new: $jbdnew transaction : \
1056 $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
1057 avgjbd=$(( avgjbd + jbd ))
1058 avgtime=$(( avgtime + elapsed ))
1060 eval cos${COS}_jbd=$((avgjbd / 3))
1061 eval cos${COS}_time=$((avgtime / 3))
1064 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
1065 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
1066 [ "$cos0_jbd" != 0 ] &&
1067 echo "COS=1 vs COS=0 jbd: $(((cos1_jbd/cos0_jbd - 1) * 100)) %"
1068 [ "$cos0_time" != 0 ] &&
1069 echo "COS=1 vs COS=0 time: $(((cos1_time/cos0_time - 1) * 100)) %"
1071 restore_lustre_params < $param_file
1075 run_test 33b "COS: cross create/delete, 2 clients, benchmark under remote dir"
1078 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
1079 [ "$MDS1_VERSION" -lt $(version_code 2.7.63) ] &&
1080 skip "DNE CoS not supported"
1084 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS || error "start mds1 failed"
1088 mkdir_on_mdt0 $DIR/$tdir
1090 do_facet mds1 "lctl set_param -n mdt.*.sync_count=0"
1091 # do twice in case transaction is committed before unlock, see LU-8200
1093 # remote dir is created on MDT1, which enqueued lock of $tdir on
1095 $LFS mkdir -i 1 $DIR/$tdir/remote.$i
1096 mkdir $DIR/$tdir/local.$i
1098 sync_count=$(do_facet mds1 "lctl get_param -n mdt.*MDT0000.sync_count")
1099 echo "sync_count $sync_count"
1100 [ $sync_count -eq 0 ] && error "Sync-Lock-Cancel not triggered"
1103 do_facet mds1 "lctl set_param -n mdt.*.sync_count=0"
1104 $LFS mkdir -i 1 $DIR/$tdir/remote.3
1105 # during sleep remote mkdir should have been committed and canceled
1106 # remote lock spontaneously, which shouldn't trigger sync
1108 mkdir $DIR/$tdir/local.3
1109 sync_count=$(do_facet mds1 "lctl get_param -n mdt.*MDT0000.sync_count")
1110 echo "sync_count $sync_count"
1111 [ $sync_count -eq 0 ] || error "Sync-Lock-Cancel triggered"
1113 run_test 33c "Cancel cross-MDT lock should trigger Sync-Lock-Cancel"
1115 # arg1 is operations done before CoS, arg2 is the operation that triggers CoS
1119 local nodes=$(comma_list $(mdts_nodes))
1123 # trigger CoS twice in case transaction commit before unlock
1126 do_nodes $nodes "lctl set_param -n mdt.*.async_commit_count=0"
1128 commit_nr=$(do_nodes $nodes \
1129 "lctl get_param -n mdt.*.async_commit_count" | calc_sum)
1130 total=$((total + commit_nr));
1135 echo "CoS count $total"
1136 [ $total -gt 0 ] || error "$2 didn't trigger CoS"
1140 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
1141 [ "$MDS1_VERSION" -lt $(version_code 2.7.63) ] &&
1142 skip "DNE CoS not supported"
1144 # remote directory create
1145 op_trigger_cos "$LFS mkdir -i 0 $DIR/$tdir" "$LFS mkdir -i 1 $DIR/$tdir/subdir"
1146 # remote directory unlink
1147 op_trigger_cos "$LFS mkdir -i 1 $DIR/$tdir" "rmdir $DIR/$tdir"
1148 # striped directory create
1149 op_trigger_cos "mkdir $DIR/$tdir" "$LFS mkdir -c 2 $DIR/$tdir/subdir"
1150 # striped directory setattr
1151 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; touch $DIR/$tdir" \
1152 "chmod 713 $DIR/$tdir"
1153 # striped directory unlink
1154 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; touch $DIR/$tdir" \
1157 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; \
1158 $LFS mkdir -i 0 $DIR/$tdir/d1; \
1159 $LFS mkdir -i 1 $DIR/$tdir/d2; \
1160 touch $DIR/$tdir/d1/tgt" \
1161 "ln $DIR/$tdir/d1/tgt $DIR/$tdir/d2/src"
1163 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; \
1164 $LFS mkdir -i 0 $DIR/$tdir/d1; \
1165 $LFS mkdir -i 1 $DIR/$tdir/d2; \
1166 touch $DIR/$tdir/d1/src" \
1167 "mv $DIR/$tdir/d1/src $DIR/$tdir/d2/tgt"
1169 op_trigger_cos "$LFS mkdir -i 0 $DIR/$tdir" \
1170 "$LFS migrate -m 1 $DIR/$tdir"
1174 run_test 33d "DNE distributed operation should trigger COS"
1177 [ -n "$CLIENTS" ] || skip "Need two or more clients"
1178 [ $CLIENTCOUNT -ge 2 ] ||
1179 skip "Need two or more clients, have $CLIENTCOUNT"
1180 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
1181 [ "$MDS1_VERSION" -lt $(version_code 2.7.63) ] &&
1182 skip "DNE CoS not supported"
1184 local client2=${CLIENT2:-$(hostname)}
1188 local nodes=$(comma_list $(mdts_nodes))
1189 do_nodes $nodes "lctl set_param -n mdt.*.async_commit_count=0"
1191 $LFS mkdir -c 2 $DIR/$tdir
1192 mkdir $DIR/$tdir/subdir
1193 echo abc > $DIR/$tdir/$tfile
1194 do_node $client2 echo dfg >> $DIR/$tdir/$tfile
1195 do_node $client2 touch $DIR/$tdir/subdir
1197 local async_commit_count=$(do_nodes $nodes \
1198 "lctl get_param -n mdt.*.async_commit_count" | calc_sum)
1199 [ $async_commit_count -gt 0 ] && error "CoS triggerred"
1203 run_test 33e "DNE local operation shouldn't trigger COS"
1205 # End commit on sharing tests
1207 get_ost_lock_timeouts() {
1208 local nodes=${1:-$(comma_list $(osts_nodes))}
1210 local locks=$(do_nodes $nodes \
1211 "lctl get_param -n ldlm.namespaces.filter-*.lock_timeouts" | calc_sum)
1219 do_nodes $(comma_list $(osts_nodes)) \
1220 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1221 for i in $(seq $OSTCOUNT); do
1222 wait_osc_import_ready client ost$i
1227 remote_ost_nodsh && skip "remote OST with nodsh" && return
1231 trap cleanup_34 EXIT RETURN
1232 for OPER in notimeout timeout ; do
1233 rm $DIR1/$tfile 2>/dev/null
1234 lock_in=$(get_ost_lock_timeouts)
1235 if [ $OPER == "timeout" ] ; then
1236 for j in `seq $OSTCOUNT`; do
1237 #define OBD_FAIL_PTLRPC_HPREQ_TIMEOUT 0x511
1238 do_facet ost$j lctl set_param fail_loc=0x511
1240 echo lock should expire
1242 for j in `seq $OSTCOUNT`; do
1243 #define OBD_FAIL_PTLRPC_HPREQ_NOTIMEOUT 0x512
1244 do_facet ost$j lctl set_param fail_loc=0x512
1246 echo lock should not expire
1248 echo writing on client1
1249 dd if=/dev/zero of=$DIR1/$tfile count=100 conv=notrunc > /dev/null 2>&1
1251 echo reading on client2
1252 dd of=/dev/null if=$DIR2/$tfile > /dev/null 2>&1
1253 # wait for a lock timeout
1255 lock_out=$(get_ost_lock_timeouts)
1256 if [ $OPER == "timeout" ] ; then
1257 if [ $lock_in == $lock_out ]; then
1258 error "no lock timeout happened"
1263 if [ $lock_in != $lock_out ]; then
1264 error "lock timeout happened"
1272 run_test 34 "no lock timeout under IO"
1274 test_35() { # bug 17645
1277 gen=$(lctl get_param mdc.$FSNAME-MDT*-mdc-*.import | grep generation |
1278 awk '/generation/{print $2}')
1280 generation[count]=$g
1284 test_mkdir $MOUNT1/$tdir
1285 cancel_lru_locks mdc
1287 # Let's initiate -EINTR situation by setting fail_loc and take
1288 # write lock on same file from same client. This will not cause
1289 # bl_ast yet as lock is already in local cache.
1290 #define OBD_FAIL_LDLM_INTR_CP_AST 0x317
1291 do_facet client "lctl set_param fail_loc=0x80000317"
1292 local timeout=$(do_facet $SINGLEMDS lctl get_param -n timeout)
1293 let timeout=timeout*3
1295 while test $nr -lt 10; do
1296 log "Race attempt $nr"
1297 local blk1=$(lctl get_param -n ldlm.services.ldlm_cbd.stats |
1298 awk '/ldlm_bl_callback/ { print $2 }')
1299 test "x$blk1" = "x" && blk1=0
1300 createmany -o $MOUNT2/$tdir/a 4000 &
1304 # Let's make conflict and bl_ast
1305 ls -la $MOUNT1/$tdir > /dev/null &
1308 log "Wait for $pid1 $pid2 for $timeout sec..."
1310 kill -9 $pid1 $pid2 > /dev/null 2>&1
1312 local blk2=$(lctl get_param -n ldlm.services.ldlm_cbd.stats |
1313 awk '/ldlm_bl_callback/ { print $2 }')
1314 test "x$blk2" = "x" && blk2=0
1315 test $blk2 -gt $blk1 && break
1316 rm -fr $MOUNT1/$tdir
1317 cancel_lru_locks mdc
1320 do_facet client "lctl set_param fail_loc=0x0"
1321 df -h $MOUNT1 $MOUNT2
1323 gen=$(lctl get_param mdc.$FSNAME-MDT*-mdc-*.import | grep generation |
1324 awk '/generation/{print $2}')
1326 if ! test "$g" -eq "${generation[count]}"; then
1327 list=$(lctl list_param mdc.$FSNAME-MDT*-mdc-*.import)
1329 for imp in $list; do
1330 if [ $c = $count ]; then
1335 imp=$(echo "$imp" | awk -F"." '{print $2}')
1336 error "Eviction happened on import $imp"
1341 run_test 35 "-EINTR cp_ast vs. bl_ast race does not evict client"
1343 test_36() { #bug 16417
1348 test_mkdir $DIR1/$tdir
1349 $LFS setstripe -c -1 $DIR1/$tdir
1352 let SIZE_B=SIZE*1024*1024
1353 sync; sleep 2; sync # wait for delete thread
1354 wait_mds_ost_sync || error "wait_mds_ost_sync failed"
1355 wait_destroy_complete || error "wait_destroy_complete failed"
1357 while [ $i -le 10 ]; do
1358 lctl mark "start test - cycle ($i)"
1359 local before=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1360 dd if=/dev/zero of=$DIR1/$tdir/$tfile bs=1M count=$SIZE ||
1361 error "dd $DIR1/$tdir/$tfile ${SIZE}MB failed"
1362 sync # sync data from client cache
1363 sync_all_data # sync data from server cache (delayed allocation)
1365 local after_dd=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1366 multiop_bg_pause $DIR2/$tdir/$tfile O_r${SIZE_B}c || return 3
1368 rm -f $DIR1/$tdir/$tfile
1369 kill -USR1 $read_pid
1371 sync; sleep 2; sync # Ensure new statfs
1372 wait_delete_completed
1373 local after=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1374 echo "*** cycle($i) *** before($before) after_dd($after_dd)" \
1376 # this free space! not used
1377 (( $after_dd <= $after)) ||
1378 error "space leaked after_dd:$after_dd > after:$after"
1382 run_test 36 "handle ESTALE/open-unlink correctly"
1384 test_37() { # bug 18695
1385 test_mkdir $DIR1/$tdir
1386 multiop_bg_pause $DIR1/$tdir D_c || return 1
1388 # create large directory (32kB seems enough from e2fsck, ~= 1000 files)
1389 createmany -m $DIR2/$tdir/f 10000
1390 # set mtime/atime backward
1391 touch -t 198001010000 $DIR2/$tdir
1392 kill -USR1 $MULTIPID
1393 nr_files=`lfs find $DIR1/$tdir -type f | wc -l`
1394 [ $nr_files -eq 10000 ] || error "$nr_files != 10000 truncated directory?"
1397 run_test 37 "check i_size is not updated for directory on close (bug 18695) =============="
1399 # this should be set to past
1400 TEST_39_MTIME=`date -d "1 year ago" +%s`
1404 local client1=${CLIENT1:-`hostname`}
1405 local client2=${CLIENT2:-`hostname`}
1407 do_node $client1 "touch $DIR1/$tfile"
1409 do_node $client1 "touch -m -d @$TEST_39_MTIME $DIR1/$tfile"
1410 local mtime1=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1411 [ "$mtime1" = $TEST_39_MTIME ] || \
1412 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
1414 local d1=`do_node $client1 date +%s`
1415 do_node $client1 'echo hello >> '$DIR1/$tfile
1416 local d2=`do_node $client1 date +%s`
1418 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1419 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
1420 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
1422 do_node $client1 "mv $DIR1/$tfile $DIR1/$tfile-1"
1424 for (( i=0; i < 2; i++ )) ; do
1425 local mtime3=`do_node $client2 "stat -c %Y $DIR1/$tfile-1"`
1426 [ "$mtime2" = "$mtime3" ] || \
1427 error "mtime ($mtime2) changed (to $mtime3) on rename"
1429 cancel_lru_locks osc
1430 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1433 run_test 39a "test from 11063 =================================="
1436 local client1=${CLIENT1:-`hostname`}
1437 local client2=${CLIENT2:-`hostname`}
1441 local mtime1=`stat -c %Y $DIR1/$tfile`
1442 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1445 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
1447 for (( i=0; i < 2; i++ )) ; do
1448 local mtime3=`stat -c %Y $DIR1/$tfile`
1449 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1451 [ "$mtime3" = "$mtime4" ] || \
1452 error "different mtime on clients: $mtime3, $mtime4"
1453 [ "$mtime3" = $TEST_39_MTIME ] || \
1454 error "lost mtime: $mtime3, should be $TEST_39_MTIME"
1456 cancel_lru_locks osc
1457 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1460 run_test 39b "11063 problem 1 =================================="
1463 local client1=${CLIENT1:-`hostname`}
1464 local client2=${CLIENT2:-`hostname`}
1466 echo hello > $DIR1/$tfile
1468 local mtime1=`stat -c %Y $DIR1/$tfile`
1469 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1470 [ "$mtime1" = "$mtime2" ] || \
1471 error "create: different mtime on clients: $mtime1, $mtime2"
1474 $TRUNCATE $DIR1/$tfile 1
1476 for (( i=0; i < 2; i++ )) ; do
1477 local mtime3=`stat -c %Y $DIR1/$tfile`
1478 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1480 [ "$mtime3" = "$mtime4" ] || \
1481 error "different mtime on clients: $mtime3, $mtime4"
1482 [ "$mtime3" -gt $mtime2 ] || \
1483 error "truncate did not update mtime: $mtime2, $mtime3"
1485 cancel_lru_locks osc
1486 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1489 run_test 39c "check truncate mtime update ======================"
1491 test_39d() { # LU-7310
1493 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
1495 local mtime1=$(stat -c %Y $DIR2/$tfile)
1496 [ "$mtime1" = $TEST_39_MTIME ] ||
1497 error "mtime: $mtime1, should be $TEST_39_MTIME"
1500 # define OBD_FAIL_OSC_NO_GRANT 0x411
1501 $LCTL set_param fail_loc=0x411
1503 local d1=$(date +%s)
1504 echo hello >> $DIR1/$tfile
1505 local d2=$(date +%s)
1507 $LCTL set_param fail_loc=0
1509 cancel_lru_locks $OSC
1511 local mtime2=$(stat -c %Y $DIR2/$tfile)
1512 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] ||
1513 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
1515 run_test 39d "sync write should update mtime"
1518 # how long 40-47 take with specific delay
1525 # for pdo testing, we must cancel MDT-MDT locks as well as client locks to
1526 # avoid unexpected delays due to previous tests
1528 cancel_lru_locks mdc
1529 do_nodes $(comma_list $(mdts_nodes)) \
1530 $LCTL set_param -n ldlm.namespaces.*mdt*.lru_size=clear
1531 do_nodes $(comma_list $(mdts_nodes)) \
1532 $LCTL get_param ldlm.namespaces.*mdt*.lock_unused_count \
1533 ldlm.namespaces.*mdt*.lock_count | grep -v '=0'
1536 # check that pid exists hence second operation wasn't blocked by first one
1537 # if it is so then there is no conflict, return 0
1538 # else second operation is conflicting with first one, return 1
1539 check_pdo_conflict() {
1542 pdo_sched # to ensure OP1 is finished on client if OP2 is blocked by OP1
1543 if [[ `ps --pid $pid | wc -l` == 1 ]]; then
1553 # test 40: check non-blocking operations
1555 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1557 mkdir_on_mdt0 $DIR2/$tdir
1559 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1560 do_nodes $(comma_list $(mdts_nodes)) \
1561 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1562 mkdir $DIR1/$tdir/$tfile &
1564 touch $DIR2/$tdir/$tfile-2
1565 check_pdo_conflict $PID1 || error "create is blocked"
1566 mkdir $DIR2/$tdir/$tfile-3
1567 check_pdo_conflict $PID1 || error "mkdir is blocked"
1568 link $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-4
1569 check_pdo_conflict $PID1 || error "link is blocked"
1570 mv $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-5
1571 check_pdo_conflict $PID1 || error "rename is blocked"
1572 stat $DIR2/$tdir/$tfile-3 $DIR2/$tdir/$tfile-4 > /dev/null
1573 check_pdo_conflict $PID1 || error "getattr is blocked"
1574 rm $DIR2/$tdir/$tfile-4 $DIR2/$tdir/$tfile-5
1575 rmdir $DIR2/$tdir/$tfile-3
1576 check_pdo_conflict $PID1 || error "unlink is blocked"
1578 # all operations above shouldn't wait the first one
1579 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1580 do_nodes $(comma_list $(mdts_nodes)) \
1581 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1586 run_test 40a "pdirops: create vs others =============="
1589 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1591 mkdir_on_mdt0 $DIR2/$tdir
1593 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1594 do_nodes $(comma_list $(mdts_nodes)) \
1595 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1596 touch $DIR1/$tdir/$tfile &
1599 touch $DIR2/$tdir/$tfile-2
1600 check_pdo_conflict $PID1 || error "create is blocked"
1601 mkdir $DIR2/$tdir/$tfile-3
1602 check_pdo_conflict $PID1 || error "mkdir is blocked"
1603 link $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-4
1604 check_pdo_conflict $PID1 || error "link is blocked"
1605 mv $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-5
1606 check_pdo_conflict $PID1 || error "rename is blocked"
1607 stat $DIR2/$tdir/$tfile-3 $DIR2/$tdir/$tfile-4 > /dev/null
1608 check_pdo_conflict $PID1 || error "getattr is blocked"
1609 rm $DIR2/$tdir/$tfile-4 $DIR2/$tdir/$tfile-5
1610 rmdir $DIR2/$tdir/$tfile-3
1611 check_pdo_conflict $PID1 || error "unlink is blocked"
1612 # all operations above shouldn't wait the first one
1614 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1615 do_nodes $(comma_list $(mdts_nodes)) \
1616 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1621 run_test 40b "pdirops: open|create and others =============="
1624 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1626 mkdir_on_mdt0 $DIR2/$tdir
1628 touch $DIR1/$tdir/$tfile
1629 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1630 do_nodes $(comma_list $(mdts_nodes)) \
1631 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1632 link $DIR1/$tdir/$tfile $DIR1/$tdir/$tfile-0 &
1635 touch $DIR2/$tdir/$tfile-2
1636 check_pdo_conflict $PID1 || error "create is blocked"
1637 mkdir $DIR2/$tdir/$tfile-3
1638 check_pdo_conflict $PID1 || error "mkdir is blocked"
1639 link $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-4
1640 check_pdo_conflict $PID1 || error "link is blocked"
1641 mv $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-5
1642 check_pdo_conflict $PID1 || error "rename is blocked"
1643 stat $DIR2/$tdir/$tfile-3 $DIR2/$tdir/$tfile-4 > /dev/null
1644 check_pdo_conflict $PID1 || error "getattr is blocked"
1645 rm $DIR2/$tdir/$tfile-4 $DIR2/$tdir/$tfile-5
1646 rmdir $DIR2/$tdir/$tfile-3
1647 check_pdo_conflict $PID1 || error "unlink is blocked"
1649 # all operations above shouldn't wait the first one
1650 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1651 do_nodes $(comma_list $(mdts_nodes)) \
1652 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1657 run_test 40c "pdirops: link and others =============="
1660 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1662 mkdir_on_mdt0 $DIR2/$tdir
1664 touch $DIR1/$tdir/$tfile
1665 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1666 do_nodes $(comma_list $(mdts_nodes)) \
1667 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1668 rm $DIR1/$tdir/$tfile &
1671 touch $DIR2/$tdir/$tfile-2
1672 check_pdo_conflict $PID1 || error "create is blocked"
1673 mkdir $DIR2/$tdir/$tfile-3
1674 check_pdo_conflict $PID1 || error "mkdir is blocked"
1675 link $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-4
1676 check_pdo_conflict $PID1 || error "link is blocked"
1677 mv $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-5
1678 check_pdo_conflict $PID1 || error "rename is blocked"
1679 stat $DIR2/$tdir/$tfile-3 $DIR2/$tdir/$tfile-4 > /dev/null
1680 check_pdo_conflict $PID1 || error "getattr is blocked"
1681 rm $DIR2/$tdir/$tfile-4 $DIR2/$tdir/$tfile-5
1682 rmdir $DIR2/$tdir/$tfile-3
1683 check_pdo_conflict $PID1 || error "unlink is blocked"
1685 # all operations above shouldn't wait the first one
1686 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1687 do_nodes $(comma_list $(mdts_nodes)) \
1688 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1692 run_test 40d "pdirops: unlink and others =============="
1695 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1697 mkdir_on_mdt0 $DIR2/$tdir
1699 touch $DIR1/$tdir/$tfile
1700 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1701 do_nodes $(comma_list $(mdts_nodes)) \
1702 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1703 mv $DIR1/$tdir/$tfile $DIR1/$tdir/$tfile-0 &
1706 touch $DIR2/$tdir/$tfile-2
1707 check_pdo_conflict $PID1 || error "create is blocked"
1708 mkdir $DIR2/$tdir/$tfile-3
1709 check_pdo_conflict $PID1 || error "mkdir is blocked"
1710 link $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-4
1711 check_pdo_conflict $PID1 || error "link is blocked"
1712 stat $DIR2/$tdir/$tfile-3 $DIR2/$tdir/$tfile-4 > /dev/null
1713 check_pdo_conflict $PID1 || error "getattr is blocked"
1714 rm $DIR2/$tdir/$tfile-4 $DIR2/$tdir/$tfile-2
1715 rmdir $DIR2/$tdir/$tfile-3
1716 check_pdo_conflict $PID1 || error "unlink is blocked"
1718 # all operations above shouldn't wait the first one
1719 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1720 do_nodes $(comma_list $(mdts_nodes)) \
1721 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1726 run_test 40e "pdirops: rename and others =============="
1728 # test 41: create blocking operations
1731 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1732 do_nodes $(comma_list $(mdts_nodes)) \
1733 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1734 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1736 mkdir $DIR2/$tfile &
1738 do_nodes $(comma_list $(mdts_nodes)) \
1739 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1740 check_pdo_conflict $PID1 && { wait $PID1; echo "mkdir isn't blocked"; }
1741 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
1745 run_test 41a "pdirops: create vs mkdir =============="
1749 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1750 do_nodes $(comma_list $(mdts_nodes)) \
1751 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1752 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1754 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
1756 do_nodes $(comma_list $(mdts_nodes)) \
1757 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1758 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1759 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
1763 run_test 41b "pdirops: create vs create =============="
1767 touch $DIR1/$tfile-2
1768 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1769 do_nodes $(comma_list $(mdts_nodes)) \
1770 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1771 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1773 link $DIR2/$tfile-2 $DIR2/$tfile &
1775 do_nodes $(comma_list $(mdts_nodes)) \
1776 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1777 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1778 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
1782 run_test 41c "pdirops: create vs link =============="
1786 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1787 do_nodes $(comma_list $(mdts_nodes)) \
1788 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1789 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1793 do_nodes $(comma_list $(mdts_nodes)) \
1794 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1795 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1796 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
1800 run_test 41d "pdirops: create vs unlink =============="
1804 touch $DIR1/$tfile-2
1805 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1806 do_nodes $(comma_list $(mdts_nodes)) \
1807 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1808 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1810 mv $DIR2/$tfile-2 $DIR2/$tfile &
1812 do_nodes $(comma_list $(mdts_nodes)) \
1813 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1814 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1815 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
1819 run_test 41e "pdirops: create and rename (tgt) =============="
1823 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1824 do_nodes $(comma_list $(mdts_nodes)) \
1825 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1826 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1828 mv $DIR2/$tfile $DIR2/$tfile-2 &
1830 do_nodes $(comma_list $(mdts_nodes)) \
1831 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1832 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1833 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
1837 run_test 41f "pdirops: create and rename (src) =============="
1841 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1842 do_nodes $(comma_list $(mdts_nodes)) \
1843 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1844 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1846 stat $DIR2/$tfile > /dev/null &
1848 do_nodes $(comma_list $(mdts_nodes)) \
1849 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1850 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1851 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
1855 run_test 41g "pdirops: create vs getattr =============="
1859 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1860 do_nodes $(comma_list $(mdts_nodes)) \
1861 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1862 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1864 ls -lia $DIR2/ > /dev/null &
1866 do_nodes $(comma_list $(mdts_nodes)) \
1867 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1868 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1873 run_test 41h "pdirops: create vs readdir =============="
1880 do_nodes $(comma_list $(mdts_nodes)) \
1881 "lctl set_param -n fail_loc=${fail_loc} || true" &>/dev/null
1883 $MULTIOP $DIR1/$tfile oO_CREAT:O_EXCL:c 2>/dev/null &
1886 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c 2>/dev/null &
1889 if ! wait $PID1 && ! wait $PID2; then
1890 echo "Both creates failed (1 should fail, 1 should succeed)"
1892 elif wait $PID1 && wait $PID2; then
1893 echo "Both creates succeeded (1 should fail, 1 should succeed)"
1898 do_nodes $(comma_list $(mdts_nodes)) \
1899 "lctl set_param -n fail_loc=0x0 || true" &>/dev/null
1906 [[ $MDS1_VERSION -le $(version_code 2.13.56) ]] ||
1907 skip "Need MDS version newer than 2.13.56"
1910 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN 0x169
1911 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN2 0x16a
1912 for fail_loc in "0x80000169" "0x8000016a"; do
1913 echo "Begin 100 tests with fail_loc=$fail_loc"
1915 for i in {1..100}; do
1917 msg=$(sub_test_41i "$fail_loc") ||
1918 { echo; error "iter=$i : $msg"; }
1923 run_test 41i "reint_open: create vs create"
1926 # test 42: unlink and blocking operations
1929 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1930 do_nodes $(comma_list $(mdts_nodes)) \
1931 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1932 mkdir $DIR1/$tfile &
1934 mkdir $DIR2/$tfile &
1936 do_nodes $(comma_list $(mdts_nodes)) \
1937 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1938 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1939 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
1943 run_test 42a "pdirops: mkdir vs mkdir =============="
1947 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1948 do_nodes $(comma_list $(mdts_nodes)) \
1949 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1950 mkdir $DIR1/$tfile &
1952 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
1954 do_nodes $(comma_list $(mdts_nodes)) \
1955 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1956 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1957 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
1961 run_test 42b "pdirops: mkdir vs create =============="
1965 touch $DIR1/$tfile-2
1966 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1967 do_nodes $(comma_list $(mdts_nodes)) \
1968 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1969 mkdir $DIR1/$tfile &
1971 link $DIR2/$tfile-2 $DIR2/$tfile &
1973 do_nodes $(comma_list $(mdts_nodes)) \
1974 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1975 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1976 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
1980 run_test 42c "pdirops: mkdir vs link =============="
1984 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1985 do_nodes $(comma_list $(mdts_nodes)) \
1986 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1987 mkdir $DIR1/$tfile &
1989 rmdir $DIR2/$tfile &
1991 do_nodes $(comma_list $(mdts_nodes)) \
1992 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1993 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1994 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
1998 run_test 42d "pdirops: mkdir vs unlink =============="
2002 touch $DIR1/$tfile-2
2003 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2004 do_nodes $(comma_list $(mdts_nodes)) \
2005 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2006 mkdir $DIR1/$tfile &
2008 mv -T $DIR2/$tfile-2 $DIR2/$tfile &
2010 do_nodes $(comma_list $(mdts_nodes)) \
2011 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2012 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2013 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
2017 run_test 42e "pdirops: mkdir and rename (tgt) =============="
2021 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2022 do_nodes $(comma_list $(mdts_nodes)) \
2023 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2024 mkdir $DIR1/$tfile &
2026 mv $DIR2/$tfile $DIR2/$tfile-2 &
2028 do_nodes $(comma_list $(mdts_nodes)) \
2029 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2030 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2031 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2035 run_test 42f "pdirops: mkdir and rename (src) =============="
2038 mkdir_on_mdt0 $DIR1/$tdir
2040 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2041 do_nodes $(comma_list $(mdts_nodes)) \
2042 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2043 mkdir $DIR1/$tdir/$tfile &
2045 stat $DIR2/$tdir/$tfile > /dev/null &
2047 do_nodes $(comma_list $(mdts_nodes)) \
2048 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2049 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2050 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
2053 run_test 42g "pdirops: mkdir vs getattr =============="
2057 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2058 do_nodes $(comma_list $(mdts_nodes)) \
2059 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2060 mkdir $DIR1/$tfile &
2062 ls -lia $DIR2/ > /dev/null &
2064 do_nodes $(comma_list $(mdts_nodes)) \
2065 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2066 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2071 run_test 42h "pdirops: mkdir vs readdir =============="
2073 # test 43: rmdir,mkdir won't return -EEXIST
2075 for i in {1..1000}; do
2076 mkdir $DIR1/$tdir || error "mkdir $tdir failed"
2077 rmdir $DIR2/$tdir || error "rmdir $tdir failed"
2081 run_test 43a "rmdir,mkdir doesn't return -EEXIST =============="
2086 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2087 do_nodes $(comma_list $(mdts_nodes)) \
2088 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2091 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2093 do_nodes $(comma_list $(mdts_nodes)) \
2094 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2095 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2096 wait $PID2 ; [ $? -eq 0 ] || error "create must succeed"
2100 run_test 43b "pdirops: unlink vs create =============="
2105 touch $DIR1/$tfile-2
2106 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2107 do_nodes $(comma_list $(mdts_nodes)) \
2108 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2111 link $DIR2/$tfile-2 $DIR2/$tfile &
2113 do_nodes $(comma_list $(mdts_nodes)) \
2114 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2115 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2116 wait $PID2 ; [ $? -eq 0 ] || error "link must succeed"
2120 run_test 43c "pdirops: unlink vs link =============="
2125 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2126 do_nodes $(comma_list $(mdts_nodes)) \
2127 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2132 do_nodes $(comma_list $(mdts_nodes)) \
2133 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2134 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2135 wait $PID2 ; [ $? -ne 0 ] || error "unlink must fail"
2139 run_test 43d "pdirops: unlink vs unlink =============="
2144 touch $DIR1/$tfile-2
2145 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2146 do_nodes $(comma_list $(mdts_nodes)) \
2147 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2150 mv -u $DIR2/$tfile-2 $DIR2/$tfile &
2152 do_nodes $(comma_list $(mdts_nodes)) \
2153 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2154 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2155 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2159 run_test 43e "pdirops: unlink and rename (tgt) =============="
2164 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2165 do_nodes $(comma_list $(mdts_nodes)) \
2166 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2169 mv $DIR2/$tfile $DIR2/$tfile-2 &
2171 do_nodes $(comma_list $(mdts_nodes)) \
2172 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2173 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2174 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
2178 run_test 43f "pdirops: unlink and rename (src) =============="
2183 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2184 do_nodes $(comma_list $(mdts_nodes)) \
2185 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2188 stat $DIR2/$tfile > /dev/null &
2190 do_nodes $(comma_list $(mdts_nodes)) \
2191 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2192 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2193 wait $PID2 ; [ $? -ne 0 ] || error "stat must fail"
2197 run_test 43g "pdirops: unlink vs getattr =============="
2202 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2203 do_nodes $(comma_list $(mdts_nodes)) \
2204 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2207 ls -lia $DIR2/ > /dev/null &
2209 do_nodes $(comma_list $(mdts_nodes)) \
2210 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2211 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2216 run_test 43h "pdirops: unlink vs readdir =============="
2219 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2222 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2223 do_nodes $(comma_list $(mdts_nodes)) \
2224 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2227 $LFS mkdir -i 1 $DIR2/$tfile &
2229 do_nodes $(comma_list $(mdts_nodes)) \
2230 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2231 check_pdo_conflict $PID1 &&
2232 { wait $PID1; error "remote mkdir isn't blocked"; }
2233 wait $PID2 ; [ $? -eq 0 ] || error "remote mkdir must succeed"
2237 run_test 43i "pdirops: unlink vs remote mkdir"
2240 [[ $MDS1_VERSION -lt $(version_code 2.13.52) ]] &&
2241 skip "Need MDS version newer than 2.13.52"
2243 mkdir_on_mdt0 $DIR1/$tdir
2244 for i in {1..100}; do
2245 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_CREATE_RACE 0x167
2246 do_nodes $(comma_list $(mdts_nodes)) \
2247 "lctl set_param -n fail_loc=0x80000167 2>/dev/null ||
2250 mkdir $DIR1/$tdir/sub &
2252 mkdir $DIR2/$tdir/sub && ((OK++))
2253 wait $PID1 && ((OK++))
2254 (( OK == 1 )) || error "exactly one mkdir should succeed"
2256 rmdir $DIR1/$tdir/sub || error "rmdir failed"
2260 run_test 43j "racy mkdir return EEXIST =============="
2267 # We test in a separate directory to be able to unblock server thread in
2268 # cfs_race() if LCK_PW is taken on the parent by mdt_reint_unlink.
2269 test_mkdir $DIR2/$tdir
2270 touch $DIR2/$tdir/$tfile
2272 do_nodes $(comma_list $(mdts_nodes)) \
2273 "lctl set_param -n fail_loc=${fail_loc} || true" &>/dev/null
2274 echo content > $DIR1/$tdir/$tfile & PID1=$!
2276 multiop $DIR2/$tdir/$tfile u & PID2=$!
2280 echo -n "overwriting $tfile should succeed (err=$ret); "; }
2283 echo -n "unlinking $tfile should succeed (err=$ret);"; }
2286 do_nodes $(comma_list $(mdts_nodes)) \
2287 "lctl set_param -n fail_loc=0x0 || true" &>/dev/null
2294 [[ $MDS1_VERSION -le $(version_code 2.13.56) ]] ||
2295 skip "Need MDS version newer than 2.13.56"
2298 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN 0x169
2299 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN2 0x16a
2300 for fail_loc in "0x80000169" "0x8000016a"; do
2301 echo "Begin 100 tests with fail_loc=$fail_loc"
2303 for i in {1..100}; do
2305 msg=$(sub_test_43k "$fail_loc") ||
2306 { echo; error "iter=$i : $msg"; }
2316 run_test 43k "unlink vs create"
2318 # test 44: rename tgt and blocking operations
2321 touch $DIR1/$tfile-2
2322 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2323 do_nodes $(comma_list $(mdts_nodes)) \
2324 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2325 mv $DIR1/$tfile-2 $DIR1/$tfile &
2327 mkdir $DIR2/$tfile &
2329 do_nodes $(comma_list $(mdts_nodes)) \
2330 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2331 check_pdo_conflict $PID1 && { wait $PID1; date;error "mkdir isn't blocked"; }
2332 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
2337 run_test 44a "pdirops: rename tgt vs mkdir =============="
2341 touch $DIR1/$tfile-2
2342 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2343 do_nodes $(comma_list $(mdts_nodes)) \
2344 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2345 mv $DIR1/$tfile-2 $DIR1/$tfile &
2347 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2349 do_nodes $(comma_list $(mdts_nodes)) \
2350 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2351 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2352 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
2356 run_test 44b "pdirops: rename tgt vs create =============="
2360 touch $DIR1/$tfile-2
2361 touch $DIR1/$tfile-3
2362 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2363 do_nodes $(comma_list $(mdts_nodes)) \
2364 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2365 mv $DIR1/$tfile-2 $DIR1/$tfile &
2367 link $DIR2/$tfile-3 $DIR2/$tfile &
2369 do_nodes $(comma_list $(mdts_nodes)) \
2370 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2371 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2372 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
2376 run_test 44c "pdirops: rename tgt vs link =============="
2380 touch $DIR1/$tfile-2
2381 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2382 do_nodes $(comma_list $(mdts_nodes)) \
2383 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2384 mv $DIR1/$tfile-2 $DIR1/$tfile &
2388 do_nodes $(comma_list $(mdts_nodes)) \
2389 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2390 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2391 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
2395 run_test 44d "pdirops: rename tgt vs unlink =============="
2400 touch $DIR1/$tfile-2
2401 touch $DIR1/$tfile-3
2402 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2403 do_nodes $(comma_list $(mdts_nodes)) \
2404 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2405 mv $DIR1/$tfile-2 $DIR1/$tfile &
2407 mv $DIR2/$tfile-3 $DIR2/$tfile &
2409 do_nodes $(comma_list $(mdts_nodes)) \
2410 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2411 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2412 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2416 run_test 44e "pdirops: rename tgt and rename (tgt) =============="
2420 touch $DIR1/$tfile-2
2421 touch $DIR1/$tfile-3
2422 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2423 do_nodes $(comma_list $(mdts_nodes)) \
2424 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2425 mv $DIR1/$tfile-2 $DIR1/$tfile &
2427 mv $DIR2/$tfile $DIR2/$tfile-3 &
2429 do_nodes $(comma_list $(mdts_nodes)) \
2430 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2431 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2432 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2436 run_test 44f "pdirops: rename tgt and rename (src) =============="
2440 touch $DIR1/$tfile-2
2441 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2442 do_nodes $(comma_list $(mdts_nodes)) \
2443 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2444 mv $DIR1/$tfile-2 $DIR1/$tfile &
2446 stat $DIR2/$tfile > /dev/null &
2448 do_nodes $(comma_list $(mdts_nodes)) \
2449 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2450 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2451 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
2455 run_test 44g "pdirops: rename tgt vs getattr =============="
2459 touch $DIR1/$tfile-2
2460 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2461 do_nodes $(comma_list $(mdts_nodes)) \
2462 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2463 mv $DIR1/$tfile-2 $DIR1/$tfile &
2465 ls -lia $DIR2/ > /dev/null &
2467 do_nodes $(comma_list $(mdts_nodes)) \
2468 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2469 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2474 run_test 44h "pdirops: rename tgt vs readdir =============="
2476 # test 44: rename tgt and blocking operations
2478 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2480 touch $DIR1/$tfile-2
2481 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2482 do_nodes $(comma_list $(mdts_nodes)) \
2483 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2484 mv $DIR1/$tfile-2 $DIR1/$tfile &
2486 $LFS mkdir -i 1 $DIR2/$tfile &
2488 do_nodes $(comma_list $(mdts_nodes)) \
2489 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2490 check_pdo_conflict $PID1 && { wait $PID1;
2491 error "remote mkdir isn't blocked"; }
2492 wait $PID2 ; [ $? -ne 0 ] || error "remote mkdir must fail"
2496 run_test 44i "pdirops: rename tgt vs remote mkdir"
2498 # test 45: rename,mkdir doesn't fail with -EEXIST
2500 for i in {1..1000}; do
2501 mkdir $DIR1/$tdir || error "mkdir $tdir failed"
2502 mrename $DIR2/$tdir $DIR2/$tdir.$i > /dev/null ||
2503 error "mrename to $tdir.$i failed"
2508 run_test 45a "rename,mkdir doesn't return -EEXIST =============="
2513 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2514 do_nodes $(comma_list $(mdts_nodes)) \
2515 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2516 mv $DIR1/$tfile $DIR1/$tfile-2 &
2518 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2520 do_nodes $(comma_list $(mdts_nodes)) \
2521 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2522 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2523 wait $PID2 ; [ $? -eq 0 ] || error "create must succeed"
2527 run_test 45b "pdirops: rename src vs create =============="
2532 touch $DIR1/$tfile-3
2533 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2534 do_nodes $(comma_list $(mdts_nodes)) \
2535 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2536 mv $DIR1/$tfile $DIR1/$tfile-2 &
2538 link $DIR2/$tfile-3 $DIR2/$tfile &
2540 do_nodes $(comma_list $(mdts_nodes)) \
2541 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2542 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2543 wait $PID2 ; [ $? -eq 0 ] || error "link must succeed"
2547 run_test 45c "pdirops: rename src vs link =============="
2552 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2553 do_nodes $(comma_list $(mdts_nodes)) \
2554 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2555 mv $DIR1/$tfile $DIR1/$tfile-2 &
2559 do_nodes $(comma_list $(mdts_nodes)) \
2560 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2561 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2562 wait $PID2 ; [ $? -ne 0 ] || error "unlink must fail"
2566 run_test 45d "pdirops: rename src vs unlink =============="
2571 touch $DIR1/$tfile-3
2572 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2573 do_nodes $(comma_list $(mdts_nodes)) \
2574 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2575 mv $DIR1/$tfile $DIR1/$tfile-2 &
2577 mv $DIR2/$tfile-3 $DIR2/$tfile &
2579 do_nodes $(comma_list $(mdts_nodes)) \
2580 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2581 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2582 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2586 run_test 45e "pdirops: rename src and rename (tgt) =============="
2591 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2592 do_nodes $(comma_list $(mdts_nodes)) \
2593 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2594 mv $DIR1/$tfile $DIR1/$tfile-2 &
2596 mv $DIR2/$tfile $DIR2/$tfile-3 &
2598 do_nodes $(comma_list $(mdts_nodes)) \
2599 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2600 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2601 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
2605 run_test 45f "pdirops: rename src and rename (src) =============="
2610 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2611 do_nodes $(comma_list $(mdts_nodes)) \
2612 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2613 mv $DIR1/$tfile $DIR1/$tfile-2 &
2615 stat $DIR2/$tfile > /dev/null &
2617 do_nodes $(comma_list $(mdts_nodes)) \
2618 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2619 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2620 wait $PID2 ; [ $? -ne 0 ] || error "stat must fail"
2624 run_test 45g "pdirops: rename src vs getattr =============="
2629 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2630 do_nodes $(comma_list $(mdts_nodes)) \
2631 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2632 mv $DIR1/$tfile $DIR1/$tfile-2 &
2634 ls -lia $DIR2/ > /dev/null &
2635 do_nodes $(comma_list $(mdts_nodes)) \
2636 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2637 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2642 run_test 45h "pdirops: unlink vs readdir =============="
2645 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2648 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2649 do_nodes $(comma_list $(mdts_nodes)) \
2650 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2651 mv $DIR1/$tfile $DIR1/$tfile-2 &
2653 $LFS mkdir -i 1 $DIR2/$tfile &
2655 do_nodes $(comma_list $(mdts_nodes)) \
2656 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2657 check_pdo_conflict $PID1 && { wait $PID1;
2658 error "create remote dir isn't blocked"; }
2659 wait $PID2 ; [ $? -eq 0 ] || error "create remote dir must succeed"
2663 run_test 45i "pdirops: rename src vs remote mkdir"
2670 # We test in a sparate directory to be able to unblock server thread in
2671 # cfs_race if LCK_PW is taken on the parent by mdt_reint_rename.
2672 test_mkdir $DIR2/$tdir
2673 echo file1 > $DIR2/$tdir/$tfile
2674 echo file2 > $DIR2/$tdir/$tfile-2
2676 do_nodes $(comma_list $(mdts_nodes)) \
2677 "lctl set_param -n fail_loc=${fail_loc} || true" &>/dev/null
2679 cat $DIR1/$tdir/$tfile >/dev/null &
2682 mrename $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile > /dev/null &
2686 { ret=$?; echo -n "cat $tfile should succeed (err=$ret); "; }
2689 echo -n "mrename $tfile-2 to $tfile failed (err=$ret);"; }
2692 do_nodes $(comma_list $(mdts_nodes)) \
2693 "lctl set_param -n fail_loc=0x0 || true" &>/dev/null
2700 [[ $MDS1_VERSION -le $(version_code 2.13.56) ]] ||
2701 skip "Need MDS version newer than 2.13.56"
2704 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN 0x169
2705 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN2 0x16a
2706 for fail_loc in "0x80000169" "0x8000016a"; do
2707 echo "Begin 100 tests with fail_loc=$fail_loc"
2709 for i in {1..100}; do
2711 msg=$(sub_test_45j "$fail_loc") ||
2712 { echo; error "iter=$i : $msg"; }
2717 run_test 45j "read vs rename =============="
2719 # test 46: link and blocking operations
2722 touch $DIR1/$tfile-2
2723 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2724 do_nodes $(comma_list $(mdts_nodes)) \
2725 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2726 link $DIR1/$tfile-2 $DIR1/$tfile &
2728 mkdir $DIR2/$tfile &
2730 do_nodes $(comma_list $(mdts_nodes)) \
2731 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2732 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2733 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
2737 run_test 46a "pdirops: link vs mkdir =============="
2741 touch $DIR1/$tfile-2
2742 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2743 do_nodes $(comma_list $(mdts_nodes)) \
2744 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2745 link $DIR1/$tfile-2 $DIR1/$tfile &
2747 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2749 do_nodes $(comma_list $(mdts_nodes)) \
2750 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2751 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2752 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
2756 run_test 46b "pdirops: link vs create =============="
2760 touch $DIR1/$tfile-2
2761 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2762 do_nodes $(comma_list $(mdts_nodes)) \
2763 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2764 link $DIR1/$tfile-2 $DIR1/$tfile &
2766 link $DIR2/$tfile $DIR2/$tfile &
2768 do_nodes $(comma_list $(mdts_nodes)) \
2769 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2770 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2771 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
2775 run_test 46c "pdirops: link vs link =============="
2779 touch $DIR1/$tfile-2
2780 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2781 do_nodes $(comma_list $(mdts_nodes)) \
2782 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2783 link $DIR1/$tfile-2 $DIR1/$tfile &
2787 do_nodes $(comma_list $(mdts_nodes)) \
2788 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2789 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2790 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
2794 run_test 46d "pdirops: link vs unlink =============="
2798 touch $DIR1/$tfile-2
2799 touch $DIR1/$tfile-3
2800 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2801 do_nodes $(comma_list $(mdts_nodes)) \
2802 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2803 link $DIR1/$tfile-2 $DIR1/$tfile &
2805 mv $DIR2/$tfile-3 $DIR2/$tfile &
2807 do_nodes $(comma_list $(mdts_nodes)) \
2808 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2809 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2810 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2814 run_test 46e "pdirops: link and rename (tgt) =============="
2818 touch $DIR1/$tfile-2
2819 touch $DIR1/$tfile-3
2820 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2821 do_nodes $(comma_list $(mdts_nodes)) \
2822 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2823 link $DIR1/$tfile-2 $DIR1/$tfile &
2825 mv $DIR2/$tfile $DIR2/$tfile-3 &
2827 do_nodes $(comma_list $(mdts_nodes)) \
2828 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2829 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2830 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2834 run_test 46f "pdirops: link and rename (src) =============="
2838 touch $DIR1/$tfile-2
2839 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2840 do_nodes $(comma_list $(mdts_nodes)) \
2841 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2842 link $DIR1/$tfile-2 $DIR1/$tfile &
2844 stat $DIR2/$tfile > /dev/null &
2846 do_nodes $(comma_list $(mdts_nodes)) \
2847 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2848 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2849 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
2853 run_test 46g "pdirops: link vs getattr =============="
2857 touch $DIR1/$tfile-2
2858 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2859 do_nodes $(comma_list $(mdts_nodes)) \
2860 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2861 link $DIR1/$tfile-2 $DIR1/$tfile &
2863 ls -lia $DIR2/ > /dev/null &
2865 do_nodes $(comma_list $(mdts_nodes)) \
2866 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2867 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2872 run_test 46h "pdirops: link vs readdir =============="
2875 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2877 touch $DIR1/$tfile-2
2878 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2879 do_nodes $(comma_list $(mdts_nodes)) \
2880 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2881 link $DIR1/$tfile-2 $DIR1/$tfile &
2883 $LFS mkdir -i 1 $DIR2/$tfile &
2885 do_nodes $(comma_list $(mdts_nodes)) \
2886 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2887 check_pdo_conflict $PID1 && { wait $PID1;
2888 error "remote mkdir isn't blocked"; }
2889 wait $PID2 ; [ $? -ne 0 ] || error "remote mkdir must fail"
2893 run_test 46i "pdirops: link vs remote mkdir"
2895 # test 47: remote mkdir and blocking operations
2897 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2898 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2900 do_nodes $(comma_list $(mdts_nodes)) \
2901 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2902 $LFS mkdir -i 1 $DIR1/$tfile &
2904 mkdir $DIR2/$tfile &
2906 do_nodes $(comma_list $(mdts_nodes)) \
2907 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2908 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2909 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
2913 run_test 47a "pdirops: remote mkdir vs mkdir"
2916 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2917 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2919 do_nodes $(comma_list $(mdts_nodes)) \
2920 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2921 $LFS mkdir -i 1 $DIR1/$tfile &
2923 sleep 1 # please do not remove this sleep, see LU-10754
2924 multiop $DIR2/$tfile oO_CREAT:O_EXCL:c &
2926 do_nodes $(comma_list $(mdts_nodes)) \
2927 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2928 check_pdo_conflict $PID1 && { wait $PID1;
2929 error "create isn't blocked"; }
2930 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
2934 run_test 47b "pdirops: remote mkdir vs create"
2937 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2939 touch $DIR1/$tfile-2
2940 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2941 do_nodes $(comma_list $(mdts_nodes)) \
2942 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2943 $LFS mkdir -i 1 $DIR1/$tfile &
2945 link $DIR2/$tfile-2 $DIR2/$tfile &
2947 do_nodes $(comma_list $(mdts_nodes)) \
2948 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2949 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2950 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
2954 run_test 47c "pdirops: remote mkdir vs link"
2957 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2959 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2960 do_nodes $(comma_list $(mdts_nodes)) \
2961 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2962 $LFS mkdir -i 1 $DIR1/$tfile &
2964 rmdir $DIR2/$tfile &
2966 do_nodes $(comma_list $(mdts_nodes)) \
2967 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2968 check_pdo_conflict $PID1 && { wait $PID1;
2969 error "unlink isn't blocked"; }
2970 wait $PID2 ; [ $? -eq 0 ] || error "rmdir must succeed"
2974 run_test 47d "pdirops: remote mkdir vs unlink"
2977 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2979 touch $DIR1/$tfile-2
2980 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2981 do_nodes $(comma_list $(mdts_nodes)) \
2982 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2983 $LFS mkdir -i 1 $DIR1/$tfile &
2985 mv -T $DIR2/$tfile-2 $DIR2/$tfile &
2987 do_nodes $(comma_list $(mdts_nodes)) \
2988 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2989 check_pdo_conflict $PID1 && { wait $PID1;
2990 error "rename isn't blocked"; }
2991 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
2995 run_test 47e "pdirops: remote mkdir and rename (tgt)"
2998 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3000 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
3001 do_nodes $(comma_list $(mdts_nodes)) \
3002 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
3003 $LFS mkdir -i 1 $DIR1/$tfile &
3005 mv $DIR2/$tfile $DIR2/$tfile-2 &
3007 do_nodes $(comma_list $(mdts_nodes)) \
3008 "lctl set_param -n fail_loc=0 2>/dev/null || true"
3009 check_pdo_conflict $PID1 && { wait $PID1;
3010 error "rename isn't blocked"; }
3011 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
3015 run_test 47f "pdirops: remote mkdir and rename (src)"
3018 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3022 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
3023 do_nodes $(comma_list $(mdts_nodes)) \
3024 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
3025 $LFS mkdir -i 1 $DIR1/$tfile &
3027 stat $DIR2/$tfile > /dev/null &
3029 do_nodes $(comma_list $(mdts_nodes)) \
3030 "lctl set_param -n fail_loc=0 2>/dev/null || true"
3031 check_pdo_conflict $PID1 && { wait $PID1;
3032 error "getattr isn't blocked"; }
3033 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
3037 run_test 47g "pdirops: remote mkdir vs getattr"
3041 dd if=/dev/zero of=$DIR1/$tfile bs=1K count=10
3042 #define OBD_FAIL_OSC_CP_ENQ_RACE 0x410
3043 do_facet client "lctl set_param fail_loc=0x410"
3044 $TRUNCATE $DIR2/$tfile $trunc_size
3045 do_facet client "lctl set_param fail_loc=0x0"
3047 size=`stat -c %s $DIR2/$tfile`
3048 [ $size -eq $trunc_size ] || error "wrong size"
3050 run_test 50 "osc lvb attrs: enqueue vs. CP AST =============="
3054 local origfile=/etc/hosts
3056 filesize=$(stat -c %s $origfile)
3058 # create an empty file
3059 $MCREATE $DIR1/$tfile || error "can't create $DIR1/$tfile"
3060 # cache layout lock on both mount point
3061 stat $DIR1/$tfile > /dev/null || error "stat $DIR1/$tfile failed"
3062 stat $DIR2/$tfile > /dev/null || error "stat $DIR2/$tfile failed"
3064 # open and sleep 2 seconds then read
3065 $MULTIOP $DIR2/$tfile o_2r${filesize}c &
3069 # create the layout of testing file
3070 dd if=$origfile of=$DIR1/$tfile conv=notrunc > /dev/null ||
3071 error "dd $DIR1/$tfile failed"
3073 # MULTIOP proc should be able to read enough bytes and exit
3074 for ((i = 0; i < 6; i++)); do
3076 kill -0 $pid || break
3078 kill -0 $pid 2> /dev/null && error "multiop is still there"
3079 cmp $origfile $DIR2/$tfile || error "$origfile and $DIR2/$tfile differs"
3083 run_test 51a "layout lock: refresh layout should work"
3086 (( $MDS1_VERSION >= $(version_code 2.3.59) )) ||
3087 skip "Need MDS version at least 2.3.59"
3089 local tmpfile=`mktemp`
3091 $LFS setstripe -E 1m -S 1M -c 1 -E -1 -c 1 $DIR1/$tfile ||
3092 error "Create $DIR1/$tfile failed"
3094 dd if=/dev/zero of=$DIR1/$tfile bs=1k count=1 conv=notrunc ||
3095 error "dd $DIR1/$tfile failed"
3097 # delay glimpse so that layout has changed when glimpse finish
3098 #define OBD_FAIL_GLIMPSE_DELAY 0x1404
3099 $LCTL set_param fail_loc=0x1404 fail_val=4
3100 stat -c %s $DIR2/$tfile |tee $tmpfile &
3104 # extend layout of testing file
3105 dd if=/dev/zero of=$DIR1/$tfile bs=1M count=1 seek=2 conv=notrunc ||
3106 error "dd $DIR1/$tfile failed"
3109 local fsize=$(cat $tmpfile)
3111 [ x$fsize = x3145728 ] || error "file size is $fsize, should be 3145728"
3113 rm -f $DIR1/$tfile $tmpfile
3115 run_test 51b "layout lock: glimpse should be able to restart if layout changed"
3118 [ $OSTCOUNT -ge 2 ] || { skip "needs >= 2 osts"; return; }
3120 # set default layout to have 1 stripe
3122 $LFS setstripe -c 1 $DIR1/$tdir
3124 # create a file with empty layout
3125 $MCREATE $DIR1/$tdir/$tfile ||
3126 error "$MCREATE $DIR1/$tdir/$tfile failed"
3128 #define OBD_FAIL_MDS_LL_BLOCK 0x172
3129 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x172
3131 # change the layout of testing file
3132 echo "Setting layout to have $OSTCOUNT stripes ..."
3133 $LFS setstripe -c $OSTCOUNT $DIR1/$tdir/$tfile &
3137 # write something to the file, it should be blocked on fetching layout
3138 dd if=/dev/zero of=$DIR2/$tdir/$tfile bs=1k count=1 conv=notrunc
3139 local stripe_count=$($LFS getstripe -c $DIR2/$tdir/$tfile)
3142 # lod_qos.c::min_stripe_count() allows setstripe with a default stripe
3143 # count to succeed with only 3/4 of the number of stripes (rounded up),
3144 # so creating striped files does not fail if an OST is offline or full
3145 [ $stripe_count -ge $((OSTCOUNT - $OSTCOUNT / 4)) ] ||
3146 error "bad layout: getstripe -c $stripe_count < $OSTCOUNT * 3/4"
3150 run_test 51c "layout lock: IT_LAYOUT blocked and correct layout can be returned"
3153 dd if=/dev/zero of=/$DIR1/$tfile bs=1M count=1
3154 cancel_lru_locks mdc
3156 # open should grant LAYOUT lock, mmap and read will install pages
3157 $MULTIOP $DIR1/$tfile oO_RDWR:SMR_Uc &
3161 # rss before revoking
3162 local br=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
3163 echo "Before revoking layout lock: $br KB mapped"
3165 # cancel layout lock manually
3166 cancel_lru_locks mdc
3168 # rss after revoking
3169 local ar=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
3172 wait $PID || error "wait PID $PID failed"
3174 [ $ar -eq 0 ] || error "rss before: $br, after $ar, some pages remained"
3176 run_test 51d "layout lock: losing layout lock should clean up memory map region"
3179 (( $MDS1_VERSION >= $(version_code 2.13.54.148) )) ||
3180 skip "MDS version must be at least 2.13.54.148"
3184 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eW_E+eUc &
3188 $LFS getstripe $DIR2/$tfile
3190 wait $pid || error "multiop failed"
3192 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
3196 $LFS getstripe $DIR2/$tfile
3198 wait $pid || error "multiop failed"
3200 run_test 51e "lfs getstripe does not break leases, part 2"
3204 echo "==> rename vs getattr vs setxattr should not deadlock"
3205 mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed"
3207 do_facet mds1 $LCTL set_param fail_loc=$1
3209 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 &
3217 setfattr -n user.attr1 -v value1 $DIR2/d1 || error "(2) setfattr failed"
3218 wait $PID1 || error "(3) mv failed"
3219 wait $PID2 || error "(4) stat failed"
3226 echo "==> rename vs getattr vs open vs getattr should not deadlock"
3227 mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed"
3229 do_facet mds1 $LCTL set_param fail_loc=$1
3231 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 &
3239 $MULTIOP $DIR2/d1/d2 Oc &
3243 stat $DIR/d1 || error "(2) stat failed"
3245 wait $PID1 || error "(3) mv failed"
3246 wait $PID2 || error "(4) stat failed"
3247 wait $PID3 && error "(5) multiop failed"
3253 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
3254 save_lustre_params client "llite.*.xattr_cache" > $p
3255 lctl set_param llite.*.xattr_cache 1 ||
3256 { skip "xattr cache is not supported"; return 0; }
3258 #define OBD_FAIL_MDS_RENAME 0x153
3259 #define OBD_FAIL_MDS_RENAME2 0x154
3260 test_54_part1 0x80000153 || error 10
3261 test_54_part1 0x80000154 || error 11
3262 test_54_part2 0x80000153 || error 12
3263 test_54_part2 0x80000154 || error 13
3265 restore_lustre_params < $p
3268 run_test 54 "rename locking"
3271 mkdir_on_mdt0 $DIR/$tdir
3272 mkdir -p $DIR/$tdir/d1/d2 $DIR/$tdir/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/$tdir/d1/d2 $DIR/$tdir/d3/d2 &
3281 rm -r $DIR2/$tdir/d3
3282 wait $PID1 && error "(2) mv succeeded"
3286 run_test 55a "rename vs unlink target dir"
3290 mkdir_on_mdt0 $DIR/$tdir
3291 mkdir -p $DIR/$tdir/d1/d2 $DIR/$tdir/d3 || error "(1) mkdir failed"
3293 #define OBD_FAIL_MDS_RENAME4 0x156
3294 do_facet mds1 $LCTL set_param fail_loc=0x80000156
3296 mv -T $DIR/$tdir/d1/d2 $DIR/$tdir/d3/d2 &
3300 rm -r $DIR2/$tdir/d1
3301 wait $PID1 && error "(2) mv succeeded"
3305 run_test 55b "rename vs unlink source dir"
3309 mkdir_on_mdt0 $DIR/$tdir
3310 mkdir -p $DIR/$tdir/d1/d2 $DIR/$tdir/d3 || error "(1) mkdir failed"
3312 #define OBD_FAIL_MDS_RENAME4 0x156
3313 do_facet mds1 $LCTL set_param fail_loc=0x156
3315 mv -T $DIR/$tdir/d1/d2 $DIR/$tdir/d3/d2 &
3319 # while rename is sleeping, open and remove d3
3320 $MULTIOP $DIR2/$tdir/d3 D_c &
3323 rm -rf $DIR2/$tdir/d3
3326 # while rename is sleeping 2nd time, close d3
3328 wait $PID2 || error "(3) multiop failed"
3330 wait $PID1 && error "(2) mv succeeded"
3334 run_test 55c "rename vs unlink orphan target dir"
3338 mkdir_on_mdt0 $DIR/$tdir
3342 #define OBD_FAIL_MDS_RENAME3 0x155
3343 do_facet mds1 $LCTL set_param fail_loc=0x155
3344 mv $DIR/$tdir/f1 $DIR/$tdir/$tdir &
3348 # while rename is sleeping, create $tdir, but as a directory
3349 mkdir -p $DIR2/$tdir/$tdir || error "(1) mkdir failed"
3351 # link in reverse locking order
3352 ln $DIR2/$tdir/f1 $DIR2/$tdir/$tdir/
3354 wait $PID1 && error "(2) mv succeeded"
3357 run_test 55d "rename file vs link"
3360 [ $MDS1_VERSION -lt $(version_code 2.3.0) ] &&
3361 skip "MDS version must be >= 2.3.0"
3364 test_mkdir $DIR1/$tdir
3365 file1=$DIR1/$tdir/file
3366 file2=$DIR2/$tdir/file
3368 echo orig > $file2 || error "Could not create $file2"
3369 version=$($LFS data_version $file1)
3372 echo append >> $file2 || error "Could not append to $file2"
3373 version2=$($LFS data_version $file1)
3374 [ "$version" != "$version2" ] ||
3375 error "append did not change data version: $version"
3378 echo overwrite > $file2 || error "Could not overwrite $file2"
3379 version3=$($LFS data_version $file1)
3380 [ "$version2" != "$version3" ] ||
3381 error "overwrite did not change data version: $version2"
3383 # Truncate before EOF
3384 $TRUNCATE $file2 3 || error "Could not truncate $file2"
3385 version4=$($LFS data_version $file1)
3386 [ "$version3" != "$version4" ] ||
3387 error "truncate did not change data version: $version3"
3389 # Truncate after EOF
3390 $TRUNCATE $file2 123456 || error "Could not truncate $file2"
3391 version5=$($LFS data_version $file1)
3392 [ "$version4" != "$version5" ] ||
3393 error "truncate did not change data version: $version4"
3395 # Chmod do not change version
3396 chmod 400 $file2 || error "Could not chmod 400 $file2"
3397 version6=$($LFS data_version $file1)
3398 [ "$version5" == "$version6" ] ||
3399 error "chmod should not change data version: $version5 != $version6"
3401 # Chown do not change version
3402 chown $RUNAS_ID $file2 || error "Could not chown $RUNAS_ID $file2"
3403 version7=$($LFS data_version $file1)
3404 [ "$version5" == "$version7" ] ||
3405 error "chown should not change data version: $version5 != $version7"
3407 run_test 60 "Verify data_version behaviour"
3410 local test_dir=$tdir/test_dir
3412 mkdir -p $DIR1/$tdir
3413 if [ $MDSCOUNT -ge 2 ]; then
3415 $LFS mkdir -i $MDTIDX $DIR1/$test_dir ||
3416 error "Create remote directory failed"
3418 mkdir -p $DIR1/$test_dir
3420 cd $DIR2/$test_dir || error "cd directory failed"
3421 rm -rf $DIR1/$test_dir || error "unlink directory failed"
3423 cd $DIR2/$tdir || error "exit directory"
3425 run_test 70a "cd directory && rm directory"
3427 test_70b() { # LU-2781
3429 mkdir -p $DIR1/$tdir
3431 touch $DIR1/$tdir/file
3432 for ((i = 0; i < 32; i++)); do
3433 $LFS rm_entry $DIR1/$tdir/non_existent_dir &>/dev/null
3435 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
3437 touch $DIR1/$tdir/file
3438 $LFS mkdir -i0 $DIR1/$tdir/test_dir
3439 $LFS rm_entry $DIR1/$tdir/test_dir &>/dev/null
3440 rm -rf $DIR1/$tdir/test_dir ||
3441 error "cannot remove directory after rm_entry"
3442 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
3444 run_test 70b "remove files after calling rm_entry"
3447 [[ "$MDS1_VERSION" -lt $(version_code 2.1.6) ]] &&
3448 skip "Need MDS version at least 2.1.6"
3450 # Patch not applied to 2.2 and 2.3 branches
3451 [[ "$MDS1_VERSION" -ge $(version_code 2.2.0) ]] &&
3452 [[ "$MDS1_VERSION" -lt $(version_code 2.4.0) ]] &&
3453 skip "Need MDS version earlier than 2.2.0 or at least 2.4.0"
3455 checkfiemap --test ||
3456 skip "checkfiemap not runnable: $?"
3457 # write data this way: hole - data - hole - data
3458 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=1 count=1
3459 [ "$(facet_fstype ost$(($($LFS getstripe -i $DIR1/$tfile) + 1)))" = \
3461 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return 0
3462 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=3 count=1
3463 GET_STAT="lctl get_param -n ldlm.services.ldlm_cbd.stats"
3465 local can1=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3467 checkfiemap $DIR2/$tfile 81920 ||
3468 error "data is not flushed from client"
3469 local can2=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3472 # common case of "create file, copy file" on a single node
3473 # should not flush data from ost
3474 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=1 count=1
3475 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=3 count=1
3477 local can3=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3479 checkfiemap $DIR1/$tfile 81920 ||
3481 local can4=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3483 [ $can3 -eq $can4 ] || error $((can2-can1)) "cancel RPC occured."
3485 run_test 71a "correct file map just after write operation is finished"
3488 [[ "$MDS1_VERSION" -lt $(version_code 2.1.6) ]] &&
3489 skip "Need MDS version at least 2.1.6"
3491 # Patch not applied to 2.2 and 2.3 branches
3492 [[ "$MDS1_VERSION" -ge $(version_code 2.2.0) ]] &&
3493 [[ "$MDS1_VERSION" -lt $(version_code 2.4.0) ]] &&
3494 skip "Need MDS version earlier than 2.2.0 or at least 2.4.0"
3495 [[ $OSTCOUNT -ge 2 ]] || skip "needs >= 2 OSTs"
3497 checkfiemap --test ||
3498 skip "error $?: checkfiemap failed"
3500 mkdir -p $DIR1/$tdir
3502 $LFS setstripe -c -1 $DIR1/$tdir || error "setstripe failed"
3503 dd if=/dev/urandom of=$DIR1/$tdir/$tfile bs=40K count=1
3504 [ "$(facet_fstype ost$(($($LFS getstripe -i $DIR1/$tdir/$tfile) + 1)))" = \
3506 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return 0
3507 checkfiemap $DIR1/$tdir/$tfile 40960 || error "checkfiemap failed"
3509 run_test 71b "check fiemap support for stripecount > 1"
3512 local p="$TMP/sanityN-$TESTNAME.parameters"
3515 save_lustre_params client "llite.*.xattr_cache" > $p
3516 lctl set_param llite.*.xattr_cache 1 ||
3517 { skip "xattr cache is not supported"; return 0; }
3520 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
3521 error "setfattr1 failed"
3522 getfattr -n user.attr1 $DIR2/$tfile | grep value1 ||
3523 error "getfattr1 failed"
3524 setfattr -n user.attr1 -v value2 $DIR2/$tfile ||
3525 error "setfattr2 failed"
3526 getfattr -n user.attr1 $DIR1/$tfile | grep value2 ||
3527 error "getfattr2 failed"
3529 # check that trusted.link is consistent
3530 tlink1=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
3531 ln $DIR2/$tfile $DIR2/$tfile-2 || error "failed to link"
3532 tlink2=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
3533 echo "$tlink1 $tlink2"
3534 [ "$tlink1" = "$tlink2" ] && error "trusted.link should have changed!"
3538 restore_lustre_params < $p
3541 run_test 72 "getxattr/setxattr cache should be consistent between nodes"
3544 local p="$TMP/sanityN-$TESTNAME.parameters"
3545 save_lustre_params client "llite.*.xattr_cache" > $p
3546 lctl set_param llite.*.xattr_cache 1 ||
3547 { skip "xattr cache is not supported"; return 0; }
3550 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
3551 error "setfattr1 failed"
3552 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr1 failed"
3553 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr2 failed"
3554 clear_stats llite.*.stats
3555 # PR lock should be cached by now on both clients
3556 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr3 failed"
3557 # 2 hits for getfattr(0)+getfattr(size)
3558 [ $(calc_stats llite.*.stats getxattr_hits) -eq 2 ] ||
3559 error "not cached in $DIR1"
3560 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr4 failed"
3561 # 4 hits for more getfattr(0)+getfattr(size)
3562 [ $(calc_stats llite.*.stats getxattr_hits) -eq 4 ] ||
3563 error "not cached in $DIR2"
3566 restore_lustre_params < $p
3569 run_test 73 "getxattr should not cause xattr lock cancellation"
3572 [ "$MDS1_VERSION" -lt $(version_code 2.4.93) ] &&
3573 skip "Need MDS version at least 2.4.93"
3575 dd if=/dev/zero of=$DIR1/$tfile-1 bs=1K count=1
3576 dd if=/dev/zero of=$DIR1/$tfile-2 bs=1K count=1
3577 flocks_test 4 $DIR1/$tfile-1 $DIR2/$tfile-2
3579 run_test 74 "flock deadlock: different mounts =============="
3583 $LFS setstripe -c 2 -S 1m -i 0 $DIR1/$tfile
3584 dd if=/dev/zero of=$DIR1/$tfile bs=1M count=2
3585 cancel_lru_locks osc
3587 dd of=$DIR1/$tfile if=/dev/zero bs=1M count=1 seek=1 conv=notrunc
3590 # define OBD_FAIL_LDLM_ENQUEUE_HANG 0x31d
3591 $LCTL set_param fail_loc=0x31d
3592 stat -c %s $DIR1/$tfile &
3597 # For bad lock error handler we should ASSERT and got kernel panic here
3599 $LCTL set_param fail_loc=0
3601 run_test 75 "osc: upcall after unuse lock==================="
3604 [[ "$MDS1_VERSION" -lt $(version_code 2.5.53) ]] &&
3605 skip "Need MDS version at least 2.5.53"
3607 remote_mds_nodsh && skip "remote MDS with nodsh"
3608 local fcount=$((MDSCOUNT * 256))
3613 nid=$($LCTL list_nids | sed "s/\./\\\./g")
3619 test_mkdir $DIR/$tdir
3621 # drop all open locks and close any cached "open" files on the client
3622 cancel_lru_locks mdc
3624 local open_fids_cmd="$LCTL get_param -n mdt.*.exports.'$nid'.open_files"
3625 local fid_list=($(do_nodes $(comma_list $(mdts_nodes)) $open_fids_cmd))
3626 local already=${#fid_list[@]}
3627 for (( i = 0; i < $already; i++ )) ; do
3628 log "already open[$i]: $($LFS fid2path $DIR2 ${fid_list[i]})"
3631 echo -n "opening files: "
3632 ulimit -n $((fcount + 50))
3633 for ((i = 0; i < $fcount; i++)); do
3634 touch $DIR/$tdir/f_$i
3635 local fd=$(free_fd ${fd_list[i]})
3636 local open_cmd="exec $fd<$DIR/$tdir/f_$i"
3641 (( $i % 32 == 0 )) && echo -n "."
3645 fid_list=($(do_nodes $(comma_list $(mdts_nodes)) $open_fids_cmd))
3647 # Possible errors in openfiles FID list.
3648 # 1. Missing FIDs. Check 1
3649 # 2. Extra FIDs. Check 1
3650 # 3. Duplicated FID. Check 2
3651 # 4. Invalid FIDs. Check 2
3652 # 5. Valid FID, points to some other file. Check 3
3655 [ ${#fid_list[@]} -ne $((fcount + already)) ] &&
3656 error "${#fid_list[@]} != $fcount (+$already old) open files"
3658 echo -n "closing files: "
3659 for (( fd = 0, fid = 0; fd < $fcount; fd++, fid++ )) ; do
3660 local close_cmd="exec ${fd_list[fd]}<&-"
3662 filename=$($LFS fid2path $DIR2 ${fid_list[fid]})
3664 while [[ ! "$filename" =~ "$DIR2/$tdir/f_" ]]; do
3665 echo "skip old open file $filename"
3667 filename=$($LFS fid2path $DIR2 ${fid_list[fid]})
3671 rm --interactive=no $filename
3673 error "Nonexisting fid ${fid_list[fid]} listed."
3674 (( $fd % 32 == 0 )) && echo -n "."
3679 ls_op=$(ls $DIR2/$tdir | wc -l)
3681 error "Some openfiles are missing in lproc output"
3685 run_test 76 "Verify MDT open_files listing"
3689 local dir=$DIR/$tdir
3692 mkdir $dir || error "mkdir $dir failed"
3693 $LFS setstripe -c $OSTCOUNT $dir || error "setstripe to $dir failed"
3696 do_nodes $CLIENTS $myRUNAS \
3697 dd if=/dev/zero of="$dir/nrs_r_\$HOSTNAME" bs=1M count=$n ||
3698 error "dd at 0 on client failed (1)"
3700 do_nodes $CLIENTS $myRUNAS \
3702 for ((i = 0; i < $n; i++)); do
3703 dd if=/dev/zero of=$dir/nrs_w_\$HOSTNAME bs=1M \
3704 seek=\\\$i count=1 conv=notrunc &
3705 pids_w[\\\$i]=\\\$!;
3708 for ((i = 0; i < $n; i++)); do
3709 wait \\\${pids_w[\\\$i]};
3711 [ \\\$newrc -gt \\\$rc_w ] && rc_w=\\\$newrc;
3715 do_nodes $CLIENTS sync;
3716 cancel_lru_locks osc
3718 do_nodes $CLIENTS $myRUNAS \
3720 for ((i = 0; i < $n; i++)); do
3721 dd if=$dir/nrs_r_\$HOSTNAME bs=1M of=/dev/null \
3722 seek=\\\$i count=1 &
3723 pids_r[\\\$i]=\\\$!;
3726 for ((i = 0; i < $n; i++)); do
3727 wait \\\${pids_r[\\\$i]};
3729 [ \\\$newrc -gt \\\$rc_r ] && rc_r=\\\$newrc;
3733 cancel_lru_locks osc
3735 wait $pid_w || error "dd (write) failed (2)"
3736 wait $pid_r || error "dd (read) failed (3)"
3737 rm -rvf $dir || error "rm -rf $dir failed"
3740 test_77a() { #LU-3266
3743 oss=$(comma_list $(osts_nodes))
3744 do_nodes $oss lctl set_param ost.OSS.*.nrs_policies="fifo" ||
3746 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3747 [[ $rc -ne 0 ]] && error "failed to set fifo policy"
3752 run_test 77a "check FIFO NRS policy"
3754 test_77b() { #LU-3266
3757 oss=$(comma_list $(osts_nodes))
3759 do_nodes $oss lctl set_param ost.OSS.*.nrs_policies="crrn" \
3760 ost.OSS.*.nrs_crrn_quantum=1 || rc=$?
3761 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3762 [[ $rc -ne 0 ]] && error "failed to set crrn_quantum to 1"
3764 echo "policy: crr-n, crrn_quantum 1"
3767 do_nodes $oss lctl set_param \
3768 ost.OSS.*.nrs_crrn_quantum=64 || rc=$?
3769 [[ $rc -ne 0 ]] && error "failed to set crrn_quantum to 64"
3771 echo "policy: crr-n, crrn_quantum 64"
3775 do_nodes $oss lctl set_param \
3776 ost.OSS.ost_io.nrs_policies="fifo" || rc=$?
3777 [[ $rc -ne 0 ]] && error "failed to set fifo policy"
3780 run_test 77b "check CRR-N NRS policy"
3785 oss=$(comma_list $(osts_nodes))
3787 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies=$policy \
3788 ost.OSS.*.nrs_"$policy"_quantum=1 \
3789 ost.OSS.*.nrs_"$policy"_offset_type="physical" \
3790 ost.OSS.*.nrs_"$policy"_supported="reads" || return $?
3792 echo "policy: $policy, ${policy}_quantum 1, ${policy}_offset_type " \
3793 "physical, ${policy}_supported reads"
3796 do_nodes $oss lctl set_param \
3797 ost.OSS.*.nrs_${policy}_supported="writes" \
3798 ost.OSS.*.nrs_${policy}_quantum=64 || return $?
3800 echo "policy: $policy, ${policy}_quantum 64, ${policy}_offset_type " \
3801 "physical, ${policy}_supported writes"
3804 do_nodes $oss lctl set_param \
3805 ost.OSS.*.nrs_${policy}_supported="reads_and_writes" \
3806 ost.OSS.*.nrs_${policy}_offset_type="logical" || return $?
3807 echo "policy: $policy, ${policy}_quantum 64, ${policy}_offset_type " \
3808 "logical, ${policy}_supported reads_and_writes"
3812 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo" ||
3817 test_77c() { #LU-3266
3819 orr_trr "orr" || rc=$?
3820 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3821 [[ $rc -ne 0 ]] && error "orr_trr failed rc:$rc"
3824 run_test 77c "check ORR NRS policy"
3826 test_77d() { #LU-3266
3828 orr_trr "trr" || rc=$?
3829 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3830 [[ $rc -ne 0 ]] && error "orr_trr failed rc:$rc"
3833 run_test 77d "check TRR nrs policy"
3840 do_facet $facet lctl set_param \
3841 ost.OSS.ost_io.nrs_tbf_rule="$*"
3843 error "failed to run operate '$*' on TBF rules"
3846 cleanup_tbf_verify()
3850 echo "cleanup_tbf $DIR/$tdir"
3853 wait_delete_completed
3858 local dir=$DIR/$tdir
3859 local client1=${CLIENT1:-$(hostname)}
3862 local np=$(check_cpt_number ost1)
3863 [ $np -gt 0 ] || error "CPU partitions should not be $np."
3864 echo "cpu_npartitions on ost1 is $np"
3866 mkdir $dir || error "mkdir $dir failed"
3867 $LFS setstripe -c 1 -i 0 $dir || error "setstripe to $dir failed"
3870 trap cleanup_tbf_verify EXIT
3871 echo "Limited write rate: $1, read rate: $2"
3872 echo "Verify the write rate is under TBF control"
3873 local start=$SECONDS
3874 do_node $client1 $myRUNAS dd if=/dev/zero of=$dir/tbf \
3875 bs=1M count=100 oflag=direct 2>&1
3876 local runtime=$((SECONDS - start + 1))
3877 local rate=$(bc <<< "scale=6; 100 / $runtime")
3878 echo "Write runtime is $runtime s, speed is $rate IOPS"
3880 # verify the write rate does not exceed TBF rate limit
3881 [ $(bc <<< "$rate < 1.1 * $np * $1") -eq 1 ] ||
3882 error "The write rate ($rate) exceeds 110% of rate limit ($1 * $np)"
3884 cancel_lru_locks osc
3886 echo "Verify the read rate is under TBF control"
3888 do_node $client1 $myRUNAS dd if=$dir/tbf of=/dev/null \
3889 bs=1M count=100 iflag=direct 2>&1
3890 runtime=$((SECONDS - start + 1))
3891 rate=$(bc <<< "scale=6; 100 / $runtime")
3892 echo "Read runtime is $runtime s, speed is $rate IOPS"
3894 # verify the read rate does not exceed TBF rate limit
3895 [ $(bc <<< "$rate < 1.1 * $np * $2") -eq 1 ] ||
3896 error "The read rate ($rate) exceeds 110% of rate limit ($2 * $np)"
3898 cancel_lru_locks osc
3899 cleanup_tbf_verify || error "rm -rf $dir failed"
3905 oss=$(comma_list $(osts_nodes))
3907 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid" ||
3909 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
3910 [[ $rc -ne 0 ]] && error "failed to set TBF NID policy"
3914 if [ "$OST1_VERSION" -ge $(version_code 2.8.54) ]; then
3919 # Only operate rules on ost1 since OSTs might run on the same OSS
3921 tbf_rule_operate ost1 "start\ localhost\ ${idis}{0@lo}\ ${rateis}1000"
3922 local address=$(comma_list "$(host_nids_address $CLIENTS $NETTYPE)")
3923 local client_nids=$(nids_list $address "\\")
3924 tbf_rule_operate ost1 "start\ clients\ ${idis}{$client_nids}\ ${rateis}100"
3925 tbf_rule_operate ost1 "start\ others\ ${idis}{*.*.*.*@$NETTYPE}\ ${rateis}50"
3929 tbf_rule_operate ost1 "change\ localhost\ ${rateis}1001"
3930 tbf_rule_operate ost1 "change\ clients\ ${rateis}101"
3931 tbf_rule_operate ost1 "change\ others\ ${rateis}51"
3935 tbf_rule_operate ost1 "stop\ localhost"
3936 tbf_rule_operate ost1 "stop\ clients"
3937 tbf_rule_operate ost1 "stop\ others"
3940 # Cleanup the TBF policy
3941 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3942 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3946 run_test 77e "check TBF NID nrs policy"
3951 oss=$(comma_list $(osts_nodes))
3953 do_nodes $oss $LCTL set_param \
3954 ost.OSS.ost_io.nrs_policies="tbf\ jobid" || rc=$?
3955 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
3956 [[ $rc -ne 0 ]] && error "failed to set TBF JOBID policy"
3958 # Configure jobid_var
3959 local saved_jobid_var=$($LCTL get_param -n jobid_var)
3961 [[ $rc -eq 3 ]] && skip "jobid_var not found" && return
3962 [[ $rc -ne 0 ]] && error "failed to get param jobid_var"
3963 if [ $saved_jobid_var != procname_uid ]; then
3964 set_persistent_param_and_check client \
3965 "jobid_var" "$FSNAME.sys.jobid_var" procname_uid
3970 if [ "$OST1_VERSION" -ge $(version_code 2.8.54) ]; then
3975 # Only operate rules on ost1 since OSTs might run on the same OSS
3977 tbf_rule_operate ost1 "start\ runas\ ${idis}{iozone.$RUNAS_ID\ dd.$RUNAS_ID\ tiotest.$RUNAS_ID}\ ${rateis}1000"
3978 tbf_rule_operate ost1 "start\ iozone_runas\ ${idis}{iozone.$RUNAS_ID}\ ${rateis}100"
3979 tbf_rule_operate ost1 "start\ dd_runas\ ${idis}{dd.$RUNAS_ID}\ ${rateis}50"
3980 nrs_write_read "$RUNAS"
3983 tbf_rule_operate ost1 "change\ runas\ ${rateis}1001"
3984 tbf_rule_operate ost1 "change\ iozone_runas\ ${rateis}101"
3985 tbf_rule_operate ost1 "change\ dd_runas\ ${rateis}51"
3986 nrs_write_read "$RUNAS"
3989 tbf_rule_operate ost1 "stop\ runas"
3990 tbf_rule_operate ost1 "stop\ iozone_runas"
3991 tbf_rule_operate ost1 "stop\ dd_runas"
3992 nrs_write_read "$RUNAS"
3994 # Cleanup the TBF policy
3995 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
3996 [ $? -ne 0 ] && error "failed to set policy back to fifo"
3997 nrs_write_read "$RUNAS"
3999 local current_jobid_var=$($LCTL get_param -n jobid_var)
4000 [[ $? -ne 0 ]] && error "failed to get param jobid_var"
4001 if [ $saved_jobid_var != $current_jobid_var ]; then
4002 set_persistent_param_and_check client \
4003 "jobid_var" "$FSNAME.sys.jobid_var" $saved_jobid_var
4007 run_test 77f "check TBF JobID nrs policy"
4012 oss=$(comma_list $(osts_nodes))
4014 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid" ||
4016 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
4017 [[ $rc -ne 0 ]] && error "failed to set TBF NID policy"
4019 do_nodes $oss lctl set_param \
4020 ost.OSS.ost_io.nrs_policies="tbf\ jobid" || rc=$?
4021 [[ $rc -ne 0 ]] && error "failed to set TBF JOBID policy"
4025 if [ "$OST1_VERSION" -ge $(version_code 2.8.54) ]; then
4030 # Add a rule that only valid for Jobid TBF. If direct change between
4031 # TBF types is not supported, this operation will fail.
4032 tbf_rule_operate ost1 "start\ dd_runas\ ${idis}{dd.$RUNAS_ID}\ ${rateis}50"
4034 # Cleanup the TBF policy
4035 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
4036 [ $? -ne 0 ] && error "failed to set policy back to fifo"
4039 run_test 77g "Change TBF type directly"
4042 [ "$OST1_VERSION" -ge $(version_code 2.8.55) ] ||
4043 skip "Need OST version at least 2.8.55"
4045 local old_policy=$(do_facet ost1 \
4046 lctl get_param ost.OSS.ost_io.nrs_policies)
4049 do_facet ost1 lctl set_param \
4050 ost.OSS.ost_io.nrs_policies="abc"
4051 [ $? -eq 0 ] && error "should return error"
4053 do_facet ost1 lctl set_param \
4054 ost.OSS.ost_io.nrs_policies="tbf\ abc"
4055 [ $? -eq 0 ] && error "should return error"
4057 do_facet ost1 lctl set_param \
4058 ost.OSS.ost_io.nrs_policies="tbf\ reg\ abc"
4059 [ $? -eq 0 ] && error "should return error"
4061 do_facet ost1 lctl set_param \
4062 ost.OSS.ost_io.nrs_policies="tbf\ abc\ efg"
4063 [ $? -eq 0 ] && error "should return error"
4065 new_policy=$(do_facet ost1 lctl get_param ost.OSS.ost_io.nrs_policies)
4066 [ $? -eq 0 ] || error "shouldn't LBUG"
4068 [ "$old_policy" = "$new_policy" ] || error "NRS policy should be same"
4072 run_test 77h "Wrong policy name should report error, not LBUG"
4078 local error_message=$3
4080 for rule in $expected; do
4081 rule_number=$((rule_number + 1))
4083 local stop_line=$(($rule_number + 3))
4084 local awk_command="awk 'NR >= 4 && NR <= $stop_line {print \$1}'"
4086 local output=$(do_facet $facet lctl get_param \
4087 ost.OSS.ost_io.nrs_tbf_rule |
4091 if [ "$output" != "$expected" ]; then
4092 error "$error_message, expected '$expected', got '$output'"
4097 [ "$OST1_VERSION" -ge $(version_code 2.8.55) ] ||
4098 skip "Need OST version at least 2.8.55"
4100 for i in $(seq 1 $OSTCOUNT)
4102 do_facet ost"$i" lctl set_param \
4103 ost.OSS.ost_io.nrs_policies="tbf\ jobid"
4105 error "failed to set TBF policy"
4108 tbf_rule_check ost1 "default" "error before inserting any rule"
4110 tbf_rule_operate ost1 "start\ before\ jobid={jobid}\ rate=1000"
4111 tbf_rule_check ost1 "before default" \
4112 "error when inserting rule 'before'"
4114 tbf_rule_operate ost1 "start\ after\ jobid={jobid}\ rate=1000\ rank=default"
4115 tbf_rule_check ost1 "before after default" \
4116 "error when inserting rule 'after'"
4118 tbf_rule_operate ost1 "start\ target\ jobid={jobid}\ rate=1000\ rank=after"
4119 tbf_rule_check ost1 "before target after default" \
4120 "error when inserting rule 'target'"
4122 echo "Move before itself"
4123 tbf_rule_operate ost1 "change\ target\ rank=target"
4124 tbf_rule_check ost1 "before target after default" \
4125 "error when moving before itself"
4127 echo "Move to higher rank"
4128 tbf_rule_operate ost1 "change\ target\ rank=before"
4129 tbf_rule_check ost1 "target before after default" \
4130 "error when moving to higher rank"
4132 echo "Move to lower rank"
4133 tbf_rule_operate ost1 "change\ target\ rank=after"
4134 tbf_rule_check ost1 "before target after default" \
4135 "error when moving to lower rank"
4137 echo "Move before default"
4138 tbf_rule_operate ost1 "change\ target\ rank=default"
4139 tbf_rule_check ost1 "before after target default" \
4140 error "error when moving before default"
4142 # Cleanup the TBF policy
4143 do_nodes $(comma_list $(osts_nodes)) \
4144 $LCTL set_param ost.OSS.ost_io.nrs_policies=fifo
4147 run_test 77i "Change rank of TBF rule"
4153 [ "$OST1_VERSION" -ge $(version_code 2.9.53) ] ||
4154 skip "Need OST version at least 2.9.53"
4155 if [ "$OST1_VERSION" -ge $(version_code 2.8.60) ]; then
4160 do_nodes $(comma_list $(osts_nodes)) \
4161 lctl set_param jobid_var=procname_uid \
4162 ost.OSS.ost_io.nrs_policies="tbf\ opcode" \
4163 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_r\ ${idis}{ost_read}\ ${rateis}5" \
4164 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_w\ ${idis}{ost_write}\ ${rateis}20"
4165 [ $? -ne 0 ] && error "failed to set TBF OPCode policy"
4170 do_nodes $(comma_list $(osts_nodes)) \
4171 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_r" \
4172 ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_w" \
4173 ost.OSS.ost_io.nrs_policies="fifo"
4175 # sleep 3 seconds to wait the tbf policy stop completely,
4176 # or the next test case is possible get -EAGAIN when
4177 # setting the tbf policy
4180 run_test 77j "check TBF-OPCode NRS policy"
4183 local idstr="${1}id"
4184 local policy="${idstr}={$2}"
4185 local rate="rate=$3"
4187 do_nodes $(comma_list $(osts_nodes)) \
4188 lctl set_param jobid_var=procname_uid \
4189 ost.OSS.ost_io.nrs_policies="tbf\ ${idstr}" \
4190 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_${idstr}\ ${policy}\ ${rate}"
4191 [ $? -ne 0 ] && error "failed to set tbf ${idstr} policy"
4193 nrs_write_read "runas $4"
4194 tbf_verify $3 $3 "runas $4"
4196 do_nodes $(comma_list $(osts_nodes)) \
4197 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_${idstr}" \
4198 ost.OSS.ost_io.nrs_policies="fifo"
4200 # sleep 3 seconds to wait the tbf policy stop completely,
4201 # or the next test case is possible get -eagain when
4202 # setting the tbf policy
4207 if [ "$OST1_VERSION" -lt $(version_code 2.11.50) ]; then
4208 skip "Need OST version at least 2.11.50"
4211 test_id "u" "500" "5" "-u 500"
4212 test_id "g" "500" "5" "-u 500 -g 500"
4214 run_test 77ja "check TBF-UID/GID NRS policy"
4222 for rule in $rule_lists; do
4223 do_nodes $(comma_list $(osts_nodes)) \
4224 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ $rule"
4227 do_nodes $(comma_list $(osts_nodes)) \
4228 lctl set_param ost.OSS.ost_io.nrs_policies="$old_nrs"
4234 [[ "$OST1_VERSION" -ge $(version_code 2.9.53) ]] ||
4235 skip "Need OST version at least 2.9.53"
4237 do_nodes $(comma_list $(osts_nodes)) \
4238 lctl set_param ost.OSS.ost_io.nrs_policies="tbf" \
4239 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_w\ jobid={dd.$RUNAS_ID}\&opcode={ost_write}\ rate=20" \
4240 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_r\ jobid={dd.$RUNAS_ID}\&opcode={ost_read}\ rate=10"
4242 nrs_write_read "$RUNAS"
4243 tbf_verify 20 10 "$RUNAS"
4245 local address=$(comma_list "$(host_nids_address $CLIENTS $NETTYPE)")
4246 local client_nids=$(nids_list $address "\\")
4247 do_nodes $(comma_list $(osts_nodes)) \
4248 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_w" \
4249 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_r" \
4250 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_w\ nid={0@lo\ $client_nids}\&opcode={ost_write}\ rate=20" \
4251 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_r\ nid={0@lo\ $client_nids}\&opcode={ost_read}\ rate=10"
4256 do_nodes $(comma_list $(osts_nodes)) \
4257 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_w" \
4258 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_r" \
4259 ost.OSS.ost_io.nrs_tbf_rule="start\ ext\ nid={0@lo\ $client_nids}\&jobid={dd.$RUNAS_ID}\ rate=20"
4261 nrs_write_read "$RUNAS"
4262 tbf_verify 20 20 "$RUNAS"
4264 do_nodes $(comma_list $(osts_nodes)) \
4265 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext" \
4266 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_a\ jobid={dd.$RUNAS_ID},opcode={ost_write}\ rate=20" \
4267 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_b\ jobid={dd.$RUNAS_ID},opcode={ost_read}\ rate=10"
4269 nrs_write_read "$RUNAS"
4270 # with parameter "RUNAS", it will match the latest rule
4271 # "ext_b" first, so the limited write rate is 10.
4272 tbf_verify 10 10 "$RUNAS"
4275 trap "cleanup_77k \"ext_a ext_b\" \"fifo\"" EXIT
4277 [[ "$OST1_VERSION" -ge $(version_code 2.10.58) ]] ||
4278 skip "Need OST version at least 2.10.58"
4280 do_nodes $(comma_list $(osts_nodes)) \
4281 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_a" \
4282 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_b" \
4283 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_ug\ uid={500}\&gid={1000}\ rate=5"
4284 nrs_write_read "runas -u 500 -g 1000"
4285 tbf_verify 5 5 "runas -u 500 -g 1000"
4287 do_nodes $(comma_list $(osts_nodes)) \
4288 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_ug" \
4289 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_uw\ uid={500}\&opcode={ost_write}\ rate=20" \
4290 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_ur\ uid={500}\&opcode={ost_read}\ rate=10"
4292 nrs_write_read "runas -u 500"
4293 tbf_verify 20 10 "runas -u 500"
4295 do_nodes $(comma_list $(osts_nodes)) \
4296 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_uw" \
4297 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_ur" \
4298 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_a\ uid={500},opcode={ost_write}\ rate=20" \
4299 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_b\ uid={500},opcode={ost_read}\ rate=10"
4300 nrs_write_read "runas -u 500"
4301 tbf_verify 10 10 "runas -u 500"
4302 tbf_verify 20 10 "runas -u 500"
4303 cleanup_77k "ext_a ext_b" "fifo"
4305 run_test 77k "check TBF policy with NID/JobID/OPCode expression"
4308 [[ "$OST1_VERSION" -ge $(version_code 2.10.56) ]] ||
4309 skip "Need OST version at least 2.10.56"
4311 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid"
4312 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="tbf"
4314 local output=$(do_facet ost1 lctl get_param \
4315 ost.OSS.ost_io.nrs_policies | \
4316 awk '/name: tbf/ {print;exit}' | \
4317 awk -F ': ' '{print $2}')
4319 if [ "$output" != "tbf" ]; then
4320 error "The generic TBF output is '$output', not 'tbf'"
4323 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
4325 run_test 77l "check the output of NRS policies for generic TBF"
4328 if [ "$OST1_VERSION" -lt $(version_code 2.9.54) ]; then
4329 skip "Need OST version at least 2.9.54"
4332 local dir=$DIR/$tdir
4334 mkdir $dir || error "mkdir $dir failed"
4335 $LFS setstripe -c $OSTCOUNT $dir || error "setstripe to $dir failed"
4338 local nodes=$(comma_list $(osts_nodes))
4339 do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies=delay \
4340 ost.OSS.ost_io.nrs_delay_min=4 \
4341 ost.OSS.ost_io.nrs_delay_max=4 \
4342 ost.OSS.ost_io.nrs_delay_pct=100
4343 [ $? -ne 0 ] && error "Failed to set delay policy"
4345 local start=$SECONDS
4346 do_nodes "${SINGLECLIENT:-$HOSTNAME}" "$RUNAS" \
4347 dd if=/dev/zero of="$dir/nrs_delay_$HOSTNAME" bs=1M count=1 \
4348 oflag=direct conv=fdatasync ||
4349 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
4350 error "dd on client failed (1)"; }
4351 local elapsed=$((SECONDS - start))
4353 # NRS delay doesn't do sub-second timing, so a request enqueued at
4354 # 0.9 seconds can be dequeued at 4.0
4355 [ $elapsed -lt 3 ] &&
4356 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
4357 error "Single 1M write should take at least 3 seconds"; }
4360 do_nodes "${SINGLECLIENT:-$HOSTNAME}" "$RUNAS" \
4361 dd if=/dev/zero of="$dir/nrs_delay_$HOSTNAME" bs=1M count=10 \
4362 oflag=direct conv=fdatasync ||
4363 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
4364 error "dd on client failed (2)"; }
4365 elapsed=$((SECONDS - start))
4367 [ $elapsed -lt 30 ] &&
4368 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
4369 error "Ten 1M writes should take at least 30 seconds"; }
4371 do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
4372 [ $? -ne 0 ] && error "failed to set policy back to fifo"
4376 run_test 77m "check NRS Delay slows write RPC processing"
4378 test_77n() { #LU-10802
4379 if [ "$OST1_VERSION" -lt $(version_code 2.10.58) ]; then
4380 skip "Need OST version at least 2.10.58"
4383 # Configure jobid_var
4384 local saved_jobid_var=$($LCTL get_param -n jobid_var)
4385 if [ $saved_jobid_var != procname_uid ]; then
4386 set_persistent_param_and_check client \
4387 "jobid_var" "$FSNAME.sys.jobid_var" procname_uid
4390 do_nodes $(comma_list $(osts_nodes)) \
4391 lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ jobid" \
4392 ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \
4393 ost.OSS.ost_io.nrs_tbf_rule="start\ dd_runas\ jobid={*.$RUNAS_ID}\ rate=20"
4396 tbf_verify 20 20 "$RUNAS"
4398 do_nodes $(comma_list $(osts_nodes)) \
4399 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \
4400 ost.OSS.ost_io.nrs_tbf_rule="start\ dd_runas\ jobid={dd.*}\ rate=20"
4405 do_nodes $(comma_list $(osts_nodes)) \
4406 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \
4407 ost.OSS.ost_io.nrs_policies="fifo"
4411 local current_jobid_var=$($LCTL get_param -n jobid_var)
4412 if [ $saved_jobid_var != $current_jobid_var ]; then
4413 set_persistent_param_and_check client \
4414 "jobid_var" "$FSNAME.sys.jobid_var" $saved_jobid_var
4417 run_test 77n "check wildcard support for TBF JobID NRS policy"
4420 (( $OST1_VERSION > $(version_code 2.14.54) )) ||
4421 skip "need OST > 2.14.54"
4423 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_policies="tbf\ nid"
4424 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="start\ name\ nid={192.168.*.*@tcp}\ rate=10000"
4425 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="start\ name1\ nid={192.168.*.*@tcp}\ rate=10000"
4426 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="change\ name1\ rank=name"
4427 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="stop\ name"
4428 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_policies="fifo"
4430 run_test 77o "Changing rank should not panic"
4432 test_78() { #LU-6673
4435 oss=$(comma_list $(osts_nodes))
4436 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="orr" &
4437 do_nodes $oss lctl set_param ost.OSS.*.nrs_orr_quantum=1
4439 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
4440 # Valid return codes are:
4441 # 0: Tuning succeeded
4442 # ENODEV: Policy is still stopped
4443 # EAGAIN: Policy is being initialized
4444 [ $rc -eq 0 -o $rc -eq 19 -o $rc -eq 11 ] ||
4445 error "Expected set_param to return 0|ENODEV|EAGAIN"
4447 # Cleanup the ORR policy
4448 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
4449 [ $? -ne 0 ] && error "failed to set policy back to fifo"
4452 run_test 78 "Enable policy and specify tunings right away"
4455 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4456 test_mkdir $DIR/$tdir
4458 # Prevent interference from layout intent RPCs due to
4459 # asynchronous writeback. These will be tested in 130c below.
4460 do_nodes ${CLIENTS:-$HOSTNAME} sync
4462 setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
4463 error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
4465 #define OBD_FAIL_MDS_INTENT_DELAY 0x160
4466 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
4467 local facet=mds$((mdtidx + 1))
4469 set_nodes_failloc $(facet_active_host $facet) 0x80000160
4470 getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null &
4474 #define OBD_FAIL_MDS_GETXATTR_PACK 0x131
4475 set_nodes_failloc $(facet_active_host $facet) 0x80000131
4480 run_test 79 "xattr: intent error"
4483 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4490 mkdir -p $DIR1/$tdir/dir
4491 createmany -o $DIR1/$tdir/dir/f 10 ||
4492 error "create files under remote dir failed $i"
4494 cp /etc/passwd $DIR1/$tdir/$tfile
4496 #migrate open file should fails
4497 multiop_bg_pause $DIR2/$tdir/$tfile O_c || error "open $file failed"
4499 # give multiop a chance to open
4502 $LFS migrate -m $MDTIDX $DIR1/$tdir &&
4503 error "migrate open files should failed with open files"
4507 $LFS migrate -m $MDTIDX $DIR1/$tdir ||
4508 error "migrate remote dir error"
4510 echo "Finish migration, then checking.."
4511 for file in $(find $DIR1/$tdir); do
4512 mdt_index=$($LFS getstripe -m $file)
4513 [ $mdt_index == $MDTIDX ] ||
4514 error "$file is not on MDT${MDTIDX}"
4517 diff /etc/passwd $DIR1/$tdir/$tfile ||
4518 error "file different after migration"
4520 rm -rf $DIR1/$tdir || error "rm dir failed after migration"
4522 run_test 80a "migrate directory when some children is being opened"
4526 kill -9 $migrate_pid
4530 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4531 local migrate_dir1=$DIR1/$tdir/migrate_dir
4532 local migrate_dir2=$DIR2/$tdir/migrate_dir
4533 local migrate_run=$LUSTRE/tests/migrate.sh
4541 trap cleanup_80b EXIT
4542 #prepare migrate directory
4543 mkdir -p $migrate_dir1
4544 for F in {1,2,3,4,5}; do
4545 echo "$F$F$F$F$F" > $migrate_dir1/file$F
4546 echo "$F$F$F$F$F" > $DIR/$tdir/file$F
4549 #migrate the directories among MDTs
4552 mdt_idx=$((RANDOM % MDSCOUNT))
4553 $LFS migrate -m $mdt_idx $migrate_dir1 &>/dev/null ||
4555 [ $rc -ne 0 -o $rc -ne 16 ] || break
4560 echo "start migration thread $migrate_pid"
4561 #Access the files at the same time
4562 start_time=$(date +%s)
4563 echo "accessing the migrating directory for 5 minutes..."
4565 ls $migrate_dir2 > /dev/null || {
4566 echo "read dir fails"
4569 diff -u $DIR2/$tdir/file1 $migrate_dir2/file1 || {
4570 echo "access file1 fails"
4574 cat $migrate_dir2/file2 > $migrate_dir2/file3 || {
4575 echo "access file2/3 fails"
4579 echo "aaaaa" > $migrate_dir2/file4 > /dev/null || {
4580 echo "access file4 fails"
4584 stat $migrate_dir2/file5 > /dev/null || {
4585 echo "stat file5 fails"
4589 touch $migrate_dir2/source_file > /dev/null || rc1=$?
4590 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
4591 echo "touch file failed with $rc1"
4595 if [ -e $migrate_dir2/source_file ]; then
4596 ln $migrate_dir2/source_file $migrate_dir2/link_file \
4597 &>/dev/null || rc1=$?
4598 if [ -e $migrate_dir2/link_file ]; then
4599 rm -rf $migrate_dir2/link_file
4602 mrename $migrate_dir2/source_file \
4603 $migrate_dir2/target_file &>/dev/null || rc1=$?
4604 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
4605 echo "rename failed with $rc1"
4609 if [ -e $migrate_dir2/target_file ]; then
4610 rm -rf $migrate_dir2/target_file &>/dev/null ||
4613 rm -rf $migrate_dir2/source_file &>/dev/null ||
4616 [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
4617 echo "unlink failed with $rc1"
4622 end_time=$(date +%s)
4623 duration=$((end_time - start_time))
4624 if [ $((duration % 10)) -eq 0 ]; then
4625 if [ $show_time -eq 1 ]; then
4626 echo "...$duration seconds"
4633 kill -0 $migrate_pid || {
4634 echo "migration stopped 1"
4638 [ $duration -ge 300 ] && break
4641 #check migration are still there
4642 kill -0 $migrate_pid || error "migration stopped 2"
4645 run_test 80b "Accessing directory during migration"
4648 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4652 mkdir -p $DIR1/$tdir
4654 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d0
4655 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d1
4658 touch d0/0 || error "create 0 failed"
4659 mv d0/0 d1/0 || error "rename d0/0 d1/0 failed"
4660 stat d0/0 && error "stat mv filed succeed"
4661 mv $DIR2/$tdir/d1/0 $DIR2/$tdir/d0/0 || error "rename d1/0 d0/0 failed"
4662 stat d0/0 || error "stat failed"
4664 local t=$(ls -ai $DIR1/$tdir/d0 | sort -u | wc -l)
4666 if [ $t -ne 3 ]; then
4667 ls -ai $DIR1/$tdir/d0
4668 error "expect 3 get $t"
4673 run_test 81a "rename and stat under striped directory"
4676 [ $MDSCOUNT -lt 2 ] &&
4677 skip "We need at least 2 MDTs for this test"
4684 $LFS mkdir -c $MDSCOUNT $DIR1/$tdir || error "$LFS mkdir"
4685 createmany -o $DIR1/$tdir/$tfile. $total || error "createmany"
4694 for i in $(seq $total); do
4695 mrename $DIR2/$tdir/$tfile.$i $DIR2/$tdir/$tfile-new.$i \
4699 kill -9 $setattr_pid
4701 run_test 81b "rename under striped directory doesn't deadlock"
4704 [ $MDSCOUNT -lt 4 ] && skip_env "needs >= 4 MDTs"
4705 [ $MDS1_VERSION -lt $(version_code 2.13.52) ] &&
4706 skip "Need MDS version at least 2.13.52"
4708 # source is local, source parent is remote
4709 $LFS mkdir -i 0 $DIR1/${tdir}_src || error "mkdir ${tdir}_src"
4710 $LFS mkdir -i 1 $DIR1/${tdir}_tgt || error "mkdir ${tdir}_tgt"
4711 $LFS mkdir -i 3 $DIR1/${tdir}_src/sub || error "mkdir sub"
4712 $LFS mkdir -i 3 $DIR1/${tdir}_tgt/sub || error "mkdir sub"
4713 stat $DIR2/${tdir}_src/sub || error "stat sub failed"
4714 mv $DIR1/${tdir}_src/sub $DIR1/${tdir}_tgt/ || error "mv failed"
4715 [ -f $DIR2/${tdir}_src/sub ] && error "sub should be gone"
4716 rm -rf $DIR1/${tdir}_src $DIR1/${tdir}_tgt
4718 # source is remote, source parent is local
4719 $LFS mkdir -i 3 $DIR1/${tdir}_src || error "mkdir ${tdir}_src"
4720 $LFS mkdir -i 1 $DIR1/${tdir}_tgt || error "mkdir ${tdir}_tgt"
4721 $LFS mkdir -i 0 $DIR1/${tdir}_src/sub || error "mkdir sub"
4722 $LFS mkdir -i 3 $DIR1/${tdir}_tgt/sub || error "mkdir sub"
4723 stat $DIR2/${tdir}_src/sub || error "stat sub failed"
4724 mv $DIR1/${tdir}_src/sub $DIR1/${tdir}_tgt/ || error "mv failed"
4725 [ -f $DIR2/${tdir}_src/sub ] && error "sub should be gone"
4726 rm -rf $DIR1/${tdir}_src $DIR1/${tdir}_tgt
4728 # source and source parent are remote
4729 $LFS mkdir -i 0 $DIR1/${tdir}_src || error "mkdir ${tdir}_src"
4730 $LFS mkdir -i 1 $DIR1/${tdir}_tgt || error "mkdir ${tdir}_tgt"
4731 mkdir $DIR1/${tdir}_src/sub || error "mkdir sub"
4732 $LFS mkdir -i 3 $DIR1/${tdir}_tgt/sub || error "mkdir sub"
4733 stat $DIR2/${tdir}_src/sub || error "stat sub failed"
4734 mv $DIR1/${tdir}_src/sub $DIR1/${tdir}_tgt/ || error "mv failed"
4735 [ -f $DIR2/${tdir}_src/sub ] && error "sub should be gone"
4736 rm -rf $DIR1/${tdir}_src $DIR1/${tdir}_tgt
4738 # source and source parent are remote, and source is remote object
4739 $LFS mkdir -i 0 $DIR1/${tdir}_src || error "mkdir ${tdir}_src"
4740 $LFS mkdir -i 1 $DIR1/${tdir}_tgt || error "mkdir ${tdir}_tgt"
4741 $LFS mkdir -i 2 $DIR1/${tdir}_src/sub || error "mkdir sub"
4742 $LFS mkdir -i 3 $DIR1/${tdir}_tgt/sub || error "mkdir sub"
4743 stat $DIR2/${tdir}_src/sub || error "stat sub failed"
4744 mv $DIR1/${tdir}_src/sub $DIR1/${tdir}_tgt/ || error "mv failed"
4745 [ -f $DIR2/${tdir}_src/sub ] && error "sub should be gone" || true
4747 run_test 81c "rename revoke LOOKUP lock for remote object"
4750 [[ "$MDS1_VERSION" -gt $(version_code 2.6.91) ]] ||
4751 skip "Need MDS version at least 2.6.92"
4753 # Client 1 creates a file.
4754 multiop_bg_pause $DIR1/$tfile O_ac || error "multiop_bg_pause 1"
4756 # Client 2 opens the file.
4757 multiop_bg_pause $DIR2/$tfile o_Ac || error "multiop_bg_pause 2"
4759 # Client 1 makes the file an orphan.
4760 rm $DIR1/$tfile || error "rm"
4761 # Client 2 sets EA "user.multiop".
4763 wait $pid2 || error "multiop 2"
4764 # Client 1 gets EA "user.multiop". This used to fail because the EA
4765 # cache refill would get "trusted.link" from mdd_xattr_list() but
4766 # -ENOENT when trying to get "trusted.link"'s value. See also sanity
4769 wait $pid1 || error "multiop 1"
4771 run_test 82 "fsetxattr and fgetxattr on orphan files"
4774 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4781 $LFS mkdir -i1 -c2 $tdir
4786 echo "start pid $pid1 to create/unlink striped directory"
4788 # Access the directory at the same time
4792 stat $tdir > /dev/null 2>&1
4796 echo "start pid $pid2 to stat striped directory"
4804 run_test 83 "access striped directory while it is being created/unlinked"
4807 [ $MDS1_VERSION -lt $(version_code 2.12.55) ] &&
4808 skip "lustre < 2.12.55 does not contain LU-12485 fix"
4812 $MULTIOP $DIR/$tfile oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:c ||
4813 error "create $tfile failed"
4814 mtime=$(stat -c%Y $DIR/$tfile)
4815 mtime=$((mtime + 200))
4817 #define OBD_FAIL_OBD_0NLINK_RACE 0x60b
4818 do_facet mds1 $LCTL set_param fail_loc=0x8000060b
4820 touch -c -m $mtime $DIR/$tfile &
4822 # sleep a while to let 'touch' run first
4824 rm -f $DIR2/$tfile || error "unlink $tfile failed"
4827 wait $setattr_pid || true
4829 run_test 84 "0-nlink race in lu_object_find()"
4832 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4837 [ "$SLOW" = "yes" ] && duration=600
4838 # Open/Create under striped directory
4842 $LFS mkdir -c$MDSCOUNT $tdir > /dev/null 2>&1
4843 touch $tdir/f{0..3} > /dev/null 2>&1
4847 echo "start pid $pid1 to open/create under striped directory"
4849 # unlink the striped directory at the same time
4853 rm -rf $tdir > /dev/null 2>&1
4857 echo "start pid $pid2 to unlink striped directory"
4866 run_test 90 "open/create and unlink striped directory"
4869 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4874 [ "$SLOW" = "yes" ] && duration=600
4875 # chmod striped directory
4879 $LFS mkdir -c$MDSCOUNT $tdir > /dev/null 2>&1
4880 chmod go+w $tdir > /dev/null 2>&1
4884 echo "start pid $pid1 to chmod striped directory"
4886 # unlink the striped directory at the same time
4890 rm -rf $tdir > /dev/null 2>&1
4894 echo "start pid $pid2 to unlink striped directory"
4903 run_test 91 "chmod and unlink striped directory"
4906 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4909 local cmd="exec $fd<$DIR1/$tdir"
4910 $LFS setdirstripe -c$MDSCOUNT $DIR1/$tdir || error "mkdir $tdir fails"
4913 trap "eval $cmd" EXIT
4914 cd $DIR1/$tdir || error "cd $DIR1/$tdir fails"
4915 rmdir ../$tdir || error "rmdir ../$tdir fails"
4917 #define OBD_FAIL_LLITE_NO_CHECK_DEAD 0x1408
4918 $LCTL set_param fail_loc=0x1408
4919 mkdir $DIR2/$tdir/dir && error "create dir succeeds"
4920 $LFS setdirstripe -i1 $DIR2/$tdir/remote_dir &&
4921 error "create remote dir succeeds"
4922 $LCTL set_param fail_loc=0
4926 run_test 92 "create remote directory under orphan directory"
4933 mkdir -p $DIR1/$tfile-1/
4934 mkdir -p $DIR2/$tfile-2/
4935 local old_rr=$(do_facet $SINGLEMDS "$LCTL get_param -n \
4936 lod.$FSNAME-MDT0000-*/qos_threshold_rr" | sed -e 's/%//')
4937 do_facet $SINGLEMDS "$LCTL set_param -n \
4938 lod.$FSNAME-MDT0000-*/qos_threshold_rr=100"
4939 #define OBD_FAIL_MDS_LOV_CREATE_RACE 0x163
4940 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x00000163"
4942 $LFS setstripe -c -1 $DIR1/$tfile-1/file1 &
4945 $LFS setstripe -c -1 $DIR2/$tfile-2/file2 &
4949 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x0"
4950 do_facet $SINGLEMDS "$LCTL set_param -n \
4951 lod.$FSNAME-MDT0000-*/qos_threshold_rr=$old_rr"
4953 $LFS getstripe $DIR1/$tfile-1/file1
4954 rc1=$($LFS getstripe -q $DIR1/$tfile-1/file1 |
4955 awk '{if (/[0-9]/) print $1 }' | sort | uniq -d | wc -l)
4956 $LFS getstripe $DIR2/$tfile-2/file2
4957 rc2=$($LFS getstripe -q $DIR2/$tfile-2/file2 |
4958 awk '{if (/[0-9]/) print $1 }' | sort | uniq -d | wc -l)
4959 echo "rc1=$rc1 and rc2=$rc2 "
4960 [ $rc1 -eq 0 ] && [ $rc2 -eq 0 ] ||
4961 error "object allocate on same ost detected"
4963 run_test 93 "alloc_rr should not allocate on same ost"
4966 $LCTL set_param osc.*.idle_timeout=0
4967 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=2 conv=fsync
4969 local before=$(date +%s)
4973 #define OBD_FAIL_LDLM_PAUSE_CANCEL 0x312
4974 $LCTL set_param fail_val=5 fail_loc=0x80000312
4975 dd if=/dev/zero of=$DIR/$tfile conv=notrunc oflag=append bs=4k count=1 &
4979 #define OBD_FAIL_LDLM_PAUSE_CANCEL_LOCAL 0x329
4980 $LCTL set_param fail_val=6 fail_loc=0x80000329
4981 $LCTL mark kill $pid
4984 dd if=/dev/zero of=$DIR2/$tfile conv=notrunc oflag=append bs=4k count=1
4987 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 conv=fsync
4989 evict=$(do_facet client $LCTL get_param \
4990 osc.$FSNAME-OST*-osc-*/state |
4991 awk -F"[ [,]" '/EVICTED ]$/ { if (t<$5) {t=$5;} } END { print t }')
4993 [ -z "$evict" ] || [[ $evict -le $before ]] ||
4994 (do_facet client $LCTL get_param \
4995 osc.$FSNAME-OST*-osc-*/state;
4996 error "eviction happened: $evict before:$before")
4997 $LCTL set_param osc.*.idle_timeout=debug
4999 run_test 94 "signal vs CP callback race"
5003 skip "Reserved for glimpse-ahead" && return
5004 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
5005 skip "Need MDS version at least 2.10.55"
5009 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
5011 lctl set_param -n mdc.*.stats=clear
5012 dd if=/dev/zero of=$DIR2/$tdir/dom bs=4096 count=1 || return 1
5014 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #1"
5015 # first stat from server should return size data and save glimpse
5016 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
5017 [ $gls -eq 0 ] || error "Unexpected $gls glimpse RPCs"
5018 # second stat to check size is NOT cached on client without IO lock
5019 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #2"
5021 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
5022 [ $gls -ge 1 ] || error "Expect glimpse RPCs but none"
5025 run_test 100a "DoM: glimpse RPCs for stat without IO lock (DoM only file)"
5028 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
5029 skip "Need MDS version at least 2.10.55"
5033 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
5035 lctl set_param -n mdc.*.stats=clear
5036 dd if=/dev/zero of=$DIR2/$tdir/dom bs=4096 count=1 || return 1
5037 cancel_lru_locks mdc
5038 # first stat data from server should have size
5039 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #1"
5040 # second stat to check size is cached on client
5041 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #2"
5043 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
5044 # both stats should cause no glimpse requests
5045 [ $gls == 0 ] || error "Unexpected $gls glimpse RPCs"
5048 run_test 100b "DoM: no glimpse RPC for stat with IO lock (DoM only file)"
5051 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
5052 skip "Need MDS version at least 2.10.55"
5056 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
5058 lctl set_param -n mdc.*.stats=clear
5059 lctl set_param -n osc.*.stats=clear
5060 dd if=/dev/zero of=$DIR2/$tdir/dom bs=2048K count=1 || return 1
5062 # check that size is merged from MDT and OST correctly
5063 $CHECKSTAT -t file -s 2097152 $DIR/$tdir/dom ||
5064 error "Wrong size from stat #1"
5066 local gls=$(lctl get_param -n osc.*.stats | grep -c ldlm_glimpse)
5067 [ $gls -eq 0 ] && error "Expect OST glimpse RPCs but got none"
5071 run_test 100c "DoM: write vs stat without IO lock (combined file)"
5074 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
5075 skip "Need MDS version at least 2.10.55"
5079 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
5082 dd if=/dev/zero of=$DIR2/$tdir/dom bs=2048K count=1 || return 1
5083 lctl set_param -n mdc.*.stats=clear
5084 $TRUNCATE $DIR2/$tdir/dom 4096
5086 # check that reported size is valid after file grows to OST and
5087 # is truncated back to MDT stripe size
5088 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom ||
5089 error "Wrong size from stat #1"
5091 local gls=$(lctl get_param -n osc.*.stats | grep -c ldlm_glimpse)
5092 [ $gls -eq 0 ] && error "Expect OST glimpse but got none"
5096 run_test 100d "DoM: write+truncate vs stat without IO lock (combined file)"
5099 [ "$MDS1_VERSION" -lt $(version_code 2.11.50) ] &&
5100 skip "Need MDS version at least 2.11.50"
5102 local dom=$DIR/$tdir/dom
5103 local dom2=$DIR2/$tdir/dom
5106 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
5108 cancel_lru_locks mdc
5109 dd if=/dev/urandom of=$dom bs=12000 count=1
5110 $TRUNCATE $dom2 6000
5111 cancel_lru_locks mdc
5112 lctl set_param -n mdc.*.stats=clear
5113 # expect read-on-open to return all data before write
5114 cat /etc/hosts >> $dom
5115 local read=$(lctl get_param -n mdc.*.stats | grep -c ost_read)
5116 [[ $read -eq 0 ]] || error "Unexpected $read READ RPCs"
5118 run_test 100e "DoM: read on open and file size"
5121 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
5122 skip "Need MDS version at least 2.10.55"
5124 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
5126 $CHECKSTAT -t file $DIR1/$tfile
5128 local old_wb=$(sysctl -n vm.dirty_writeback_centisecs)
5129 sysctl -wq vm.dirty_writeback_centisecs=0
5131 trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT
5134 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 ||
5135 error_noexit "Write fails"
5136 # must discard pages
5137 lctl set_param -n mdc.*.stats=clear
5138 rm $DIR2/$tfile || error "Unlink fails"
5140 local writes=$(lctl get_param -n mdc.*.stats | grep -c ost_write)
5141 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
5143 run_test 101a "Discard DoM data on unlink"
5146 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
5147 skip "Need MDS version at least 2.10.55"
5149 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
5150 touch $DIR1/${tfile}_2
5152 $CHECKSTAT -t file $DIR1/$tfile
5154 local old_wb=$(sysctl -n vm.dirty_writeback_centisecs)
5155 sysctl -wq vm.dirty_writeback_centisecs=0
5157 trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT
5160 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 || error "Write fails"
5161 # must discard pages
5162 lctl set_param -n mdc.*.stats=clear
5163 mv $DIR2/${tfile}_2 $DIR2/$tfile || error "Rename fails"
5165 local writes=$(lctl get_param -n mdc.*.stats | grep -c ost_write)
5166 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
5168 run_test 101b "Discard DoM data on rename"
5171 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
5172 skip "Need MDS version at least 2.10.55"
5174 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
5176 $CHECKSTAT -t file $DIR1/$tfile
5178 local old_wb=$(sysctl -n vm.dirty_writeback_centisecs)
5179 sysctl -wq vm.dirty_writeback_centisecs=0
5181 trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT
5184 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 || error "Write fails"
5185 $MULTIOP $DIR1/$tfile O_c &
5188 lctl set_param -n mdc.*.stats=clear
5189 rm $DIR2/$tfile > /dev/null || error "Unlink fails for opened file"
5190 kill -USR1 $MULTIOP_PID && wait $MULTIOP_PID || error "multiop failure"
5192 local writes=$(lctl get_param -n mdc.*.stats | grep -c ost_write)
5193 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
5195 run_test 101c "Discard DoM data on close-unlink"
5197 # test to verify file handle related system calls
5198 # (name_to_handle_at/open_by_handle_at)
5199 # The new system calls are supported in glibc >= 2.14.
5201 # test to verify we can open by handle an unlinked file from > 1 client
5202 # This test opens the file normally on $DIR1, which is on one mount, and then
5203 # opens it by handle on $DIR2, which is on a different mount.
5205 [ "$MDS1_VERSION" -lt $(version_code 2.11.57) ] &&
5206 skip "Needs MDS version 2.11.57 or later"
5208 echo "Test file_handle syscalls" > $DIR/$tfile ||
5209 error "write failed"
5210 check_fhandle_syscalls $DIR/$tfile $DIR2 ||
5211 error "check_fhandle_syscalls $tfile failed"
5213 # test this is working on DNE directories also
5214 if (( MDSCOUNT > 1 MDS1_VERSION >= $(version_code 2.14.52) )); then
5215 $LFS mkdir -i 1 $DIR/$tdir.remote
5216 cancel_lru_locks mdc
5217 check_fhandle_syscalls $DIR/$tdir.remote $DIR2 ||
5218 error "check_fhandle_syscalls $tdir.remote failed"
5219 $LFS mkdir -c -1 $DIR/$tdir.remote/subdir
5220 cancel_lru_locks mdc
5221 check_fhandle_syscalls $DIR/$tdir.remote/subdir $DIR2 ||
5222 error "check_fhandle_syscalls $tdir.remote/subdir fail"
5224 $LFS mkdir -c -1 $DIR/$tdir.stripe
5225 cancel_lru_locks mdc
5226 check_fhandle_syscalls $DIR/$tdir.stripe $DIR2 ||
5227 error "check_fhandle_syscalls $tdir.stripe failed"
5228 $LFS mkdir -c -1 $DIR/$tdir.stripe/subdir
5229 cancel_lru_locks mdc
5230 check_fhandle_syscalls $DIR/$tdir.stripe/subdir $DIR2 ||
5231 error "check_fhandle_syscalls $tdir.stripe/subdir fail"
5234 run_test 102 "Test open by handle of unlinked file"
5236 # Compare file size between first & second mount, ensuring the client correctly
5237 # glimpses even with unused speculative locks - LU-11670
5239 [ $OST1_VERSION -lt $(version_code 2.10.50) ] &&
5240 skip "Lockahead needs OST version at least 2.10.50"
5244 test_mkdir -p $DIR/$tdir
5246 # Force file on to OST0
5247 $LFS setstripe -i 0 $DIR/$tdir
5249 # Do not check multiple locks on glimpse
5250 # OBD_FAIL_OSC_NO_SIZE_DATA 0x415
5251 $LCTL set_param fail_loc=0x415
5253 # Delay write commit by 2 seconds to guarantee glimpse wins race
5254 # The same fail_loc is used on client & server so it can work in the
5255 # single node sanity setup
5256 do_facet ost1 $LCTL set_param fail_loc=0x415 fail_val=2
5258 echo "Incorrect size expected (no glimpse fix):"
5259 lockahead_test -d $DIR/$tdir -D $DIR2/$tdir -t $locktest -f $tfile
5261 if [ $rc -eq 0 ]; then
5262 echo "This doesn't work 100%, but this is just reproducing the bug, not testing the fix, so OK to not fail test."
5265 # guarantee write commit timeout has expired
5268 # Clear fail_loc on client
5269 $LCTL set_param fail_loc=0
5271 # Delay write commit by 2 seconds to guarantee glimpse wins race
5272 # OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
5273 do_facet ost1 $LCTL set_param fail_loc=0x214 fail_val=2
5275 # Write commit is still delayed by 2 seconds
5276 lockahead_test -d $DIR/$tdir -D $DIR2/$tdir -t $locktest -f $tfile
5278 [ $rc -eq 0 ] || error "Lockahead test$locktest failed, $rc"
5280 # guarantee write commit timeout has expired
5283 rm -f $DIR/$tfile || error "unable to delete $DIR/$tfile"
5285 run_test 103 "Test size correctness with lockahead"
5291 xtimes=$(stat -c "%X %Y %Z" $DIR/$tfile)
5302 output=$(do_facet mds1 "$DEBUGFS -c -R 'stat ROOT/$tfile' $mdtdev")
5303 ((xtimes[0]=$(awk -F ':' /atime/'{ print $2 }' <<< "$output")))
5304 ((xtimes[1]=$(awk -F ':' /mtime/'{ print $2 }' <<< "$output")))
5305 ((xtimes[2]=$(awk -F ':' /ctime/'{ print $2 }' <<< "$output")))
5313 local xtimes=($(get_stat_xtimes))
5314 local mdt_xtimes=($(get_mdt_xtimes $mdtdev))
5316 echo "STAT a|m|ctime ${xtimes[*]}"
5317 echo "MDT a|m|ctime ${mdt_xtimes[*]}"
5318 [[ ${xtimes[0]} == ${mdt_xtimes[0]} ]] ||
5319 error "$DIR/$tfile atime (${xtimes[0]}:${mdt_xtimes[0]}) diff"
5320 [[ ${xtimes[1]} == ${mdt_xtimes[1]} ]] ||
5321 error "$DIR/$tfile mtime (${xtimes[1]}:${mdt_xtimes[1]}) diff"
5322 [[ ${xtimes[2]} == ${mdt_xtimes[2]} ]] ||
5323 error "$DIR/$tfile ctime (${xtimes[2]}:${mdt_xtimes[2]}) diff"
5327 [ "$mds1_FSTYPE" == "ldiskfs" ] || skip_env "ldiskfs only test"
5328 [ $MDS1_VERSION -lt $(version_code 2.12.4) ] &&
5329 skip "Need MDS version at least 2.12.4"
5332 local mdtdev=$(mdsdevname ${SINGLEMDS//mds/})
5333 local atime_diff=$(do_facet $SINGLEMDS \
5334 lctl get_param -n mdd.*MDT0000*.atime_diff)
5336 do_facet $SINGLEMDS \
5337 lctl set_param -n mdd.*MDT0000*.atime_diff=0
5339 stack_trap "do_facet $SINGLEMDS \
5340 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff" EXIT
5342 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
5343 check_mdt_xtimes $mdtdev
5346 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
5347 check_mdt_xtimes $mdtdev
5349 $MULTIOP $DIR2/$tfile Oz8192w8192_c &
5352 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
5354 kill -USR1 $pid && wait $pid || error "multiop failure"
5355 check_mdt_xtimes $mdtdev
5360 # Verify mtime/ctime is NOT upated on MDS when there is no modification
5361 # on the client side
5362 xtimes=($(get_stat_xtimes))
5363 $MULTIOP $DIR/$tfile O_c &
5366 kill -USR1 $pid && wait $pid || error "multiop failure"
5367 mdt_xtimes=($(get_mdt_xtimes $mdtdev))
5368 [[ ${xtimes[1]} == ${mdt_xtimes[1]} ]] ||
5369 error "$DIR/$tfile mtime (${xtimes[1]}:${mdt_xtimes[1]}) diff"
5370 [[ ${xtimes[2]} == ${mdt_xtimes[2]} ]] ||
5371 error "$DIR/$tfile ctime (${xtimes[2]}:${mdt_xtimes[2]}) diff"
5372 check_mdt_xtimes $mdtdev
5375 # Change ctime via chmod
5376 $MULTIOP $DIR/$tfile o_tc &
5379 kill -USR1 $pid && wait $pid || error "multiop failure"
5380 check_mdt_xtimes $mdtdev
5382 run_test 104 "Verify that MDS stores atime/mtime/ctime during close"
5385 test_mkdir -p $DIR/$tdir
5386 echo test > $DIR/$tdir/$tfile
5387 $LCTL set_param fail_loc=0x416
5388 cancel_lru_locks osc & sleep 1
5389 fsize1=$(stat -c %s $DIR2/$tdir/$tfile)
5391 [[ $fsize1 = 5 ]] || error "Glimpse returned wrong file size $fsize1"
5393 run_test 105 "Glimpse and lock cancel race"
5396 [ "$mds1_FSTYPE" == "ldiskfs" ] && statx_supported ||
5397 skip_env "Test only for ldiskfs and statx() supported"
5402 local mdtdev=$(mdsdevname ${SINGLEMDS//mds/})
5404 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
5405 btime=$($STATX -c %W $DIR/$tfile)
5406 output=$(do_facet mds1 "$DEBUGFS -c -R 'stat ROOT/$tfile' $mdtdev")
5408 ((mdt_btime=$(awk -F ':' /crtime/'{ print $2 }' <<< "$output")))
5409 [[ $btime == $mdt_btime ]] ||
5410 error "$DIR/$tfile btime ($btime:$mdt_btime) diff"
5413 run_test 106a "Verify the btime via statx()"
5416 statx_supported || skip_env "statx() only test"
5421 $LFS setstripe -c 1 $DIR/$tfile || error "$DIR/$tfile setstripe failed"
5422 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
5423 cancel_lru_locks $OSC
5424 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5426 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5427 [ $rpcs_after -eq $((rpcs_before + 1)) ] ||
5428 error "$STATX should send 1 glimpse RPC to $OSC"
5430 cancel_lru_locks $OSC
5431 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5432 # %n: FILENAME; %i: STATX_INO; %A STATX_MODE; %h STATX_NLINK;
5433 # %u: STATX_UID; %g: STATX_GID; %W STATX_BTIME; %X STATX_ATIME;
5435 $STATX -c "%n %i %A %h %u %g %W %X %Z" $DIR/$tfile
5436 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5437 [ $rpcs_after -eq $rpcs_before ] ||
5438 error "$STATX should not send glimpse RPCs to $OSC"
5440 cancel_lru_locks $OSC
5441 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5442 $STATX --cached=always $DIR/$tfile
5443 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5444 [ $rpcs_after -eq $rpcs_before ] ||
5445 error "$STATX should not send glimpse RPCs to $OSC"
5447 cancel_lru_locks $OSC
5448 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5449 $STATX -c %Y $DIR/$tfile
5450 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5451 [ $rpcs_after -eq $((rpcs_before + 1)) ] ||
5452 error "$STATX -c %Y should send 1 glimpse RPC to $OSC"
5454 cancel_lru_locks $OSC
5455 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5456 $STATX -c %s $DIR/$tfile
5457 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5458 [ $rpcs_after -eq $((rpcs_before + 1)) ] ||
5459 error "$STATX -c %s should send 1 glimpse RPC to $OSC"
5461 cancel_lru_locks $OSC
5462 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5463 $STATX -c %b $DIR/$tfile
5464 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5465 [ $rpcs_after -eq $((rpcs_before + 1)) ] ||
5466 error "$STATX -c %b should send 1 glimpse RPC to $OSC"
5468 run_test 106b "Glimpse RPCs test for statx"
5471 statx_supported || skip_env "statx() only test"
5476 # Mask supported in stx_attributes by Lustre is
5477 # STATX_ATTR_IMMUTABLE(0x10) | STATX_ATTR_APPEND(0x20) : (0x30).
5478 mask=$($STATX -c %p $DIR/$tfile)
5479 [[ $mask == "30" ]] ||
5480 error "supported stx_attributes: got '$mask', expected '30'"
5481 chattr +i $DIR/$tfile || error "chattr +i $DIR/$tfile failed"
5482 mask=$($STATX -c %r $DIR/$tfile)
5483 [[ $mask == "10" ]] ||
5484 error "got immutable flags '$mask', expected '10'"
5485 chattr -i $DIR/$tfile || error "chattr -i $DIR/$tfile failed"
5486 mask=$($STATX -c %r $DIR/$tfile)
5487 [[ $mask == "0" ]] || error "got flags '$mask', expected '0'"
5488 chattr +a $DIR/$tfile || error "chattr +a $DIR/$tfile failed"
5489 mask=$($STATX -c %r $DIR/$tfile)
5490 [[ $mask == "20" ]] || error "got flags '$mask', expected '20'"
5491 chattr -a $DIR/$tfile || error "chattr -a $DIR/$tfile failed"
5492 mask=$($STATX -c %r $DIR/$tfile)
5493 [[ $mask == "0" ]] || error "got flags '$mask', expected '0'"
5494 chattr +ia $DIR/$tfile || error "chattr +ia $DIR/$tfile failed"
5495 mask=$($STATX -c %r $DIR/$tfile)
5496 [[ $mask == "30" ]] || error "got flags '$mask', expected '30'"
5497 chattr -ia $DIR/$tfile || error "chattr -ia $DIR/$tfile failed"
5498 mask=$($STATX -c %r $DIR/$tfile)
5499 [[ $mask == "0" ]] || error "got flags '$mask', expected '0'"
5501 run_test 106c "Verify statx attributes mask"
5503 test_107a() { # LU-1031
5504 dd if=/dev/zero of=$DIR1/$tfile bs=1M count=10
5508 $LFS getstripe $DIR1/$tfile
5510 multiop_bg_pause $DIR1/$tfile OG${gid1}_g${gid1}c || return 1
5512 multiop_bg_pause $DIR2/$tfile O_G${gid2}r10g${gid2}c || return 2
5514 kill -USR1 $MULTIPID2
5516 if [[ $(ps h -o comm -p $MULTIPID2) == "" ]]; then
5517 error "First grouplock does not block second one"
5519 echo "First grouplock blocks second one"
5521 kill -USR1 $MULTIPID1
5525 run_test 107a "Basic grouplock conflict"
5528 dd if=/dev/zero of=$DIR1/$tfile bs=1M count=10
5532 $LFS getstripe $DIR1/$tfile
5534 multiop_bg_pause $DIR1/$tfile OG${gid1}_g${gid1}c || return 1
5536 multiop $DIR2/$tfile Or10c &
5540 if [[ $(ps h -o comm -p $MULTIPID2) == "" ]]; then
5541 error "Grouplock does not block IO"
5543 echo "Grouplock blocks IO"
5546 multiop $DIR2/$tfile OG${gid2}_g${gid2}c &
5549 if [[ $(ps h -o comm -p $MULTIPID3) == "" ]]; then
5550 error "First grouplock does not block second one"
5552 echo "First grouplock blocks second one"
5555 kill -USR1 $MULTIPID1
5558 if [[ $(ps h -o comm -p $MULTIPID3) == "" ]]; then
5559 error "Second grouplock thread disappeared"
5562 if [[ $(ps h -o comm -p $MULTIPID2) == "" ]]; then
5563 error "Second grouplock does not block IO"
5565 echo "Second grouplock blocks IO"
5568 kill -USR1 $MULTIPID3
5573 run_test 107b "Grouplock is added to the head of waiting list"
5578 $LFS setstripe -E 1M -c 1 -E -1 $DIR1/$tfile ||
5579 error "Create $DIR1/$tfile failed"
5581 dd if=/dev/zero of=$DIR1/$tfile bs=10000 count=1 ||
5582 error "dd $DIR1/$tfile failed"
5583 offset=$(lseek_test -d 5000 $DIR2/$tfile)
5584 [[ $offset == 5000 ]] || error "offset $offset != 5000"
5586 $TRUNCATE $DIR1/$tfile 2000
5587 offset=$(lseek_test -l 1000 $DIR2/$tfile)
5588 [[ $offset == 2000 ]] || error "offset $offset != 2000"
5590 #define OBD_FAIL_OSC_DELAY_IO 0x414
5591 $LCTL set_param fail_val=4 fail_loc=0x80000414
5592 dd if=/dev/zero of=$DIR1/$tfile count=1 bs=8M conv=notrunc oflag=dsync &
5596 offset=$(lseek_test -l 8000 $DIR2/$tfile)
5598 [[ $offset == 8388608 ]] || error "offset $offset != 8388608"
5600 run_test 108a "lseek: parallel updates"
5608 skip "Clients need to be on different nodes than the servers"
5610 umount_client $MOUNT
5611 umount_client $MOUNT2
5613 echo "Starting race between client mount instances (50 iterations):"
5614 for i in {1..50}; do
5617 #define OBD_FAIL_ONCE|OBD_FAIL_LLITE_RACE_MOUNT 0x80001417
5618 $LCTL set_param -n fail_loc=0x80001417
5620 mount_client $MOUNT & pid1=$!
5621 mount_client $MOUNT2 & pid2=$!
5622 wait $pid1 || error "Mount $MOUNT fails with $?"
5623 wait $pid2 || error "Mount $MOUNT2 fails with $?"
5625 umount_client $MOUNT & pid1=$!
5626 umount_client $MOUNT2 & pid2=$!
5627 wait $pid1 || error "Umount $MOUNT fails with $?"
5628 wait $pid2 || error "Umount $MOUNT2 fails with $?"
5630 $LUSTRE_RMMOD || error "Fail to remove lustre modules"
5636 mount_client $MOUNT2
5639 run_test 109 "Race with several mount instances on 1 node"
5642 local before=$(date +%s)
5649 #define OBD_FAIL_PTLRPC_RESEND_RACE 0x525
5650 do_facet mds1 lctl set_param fail_loc=0x525 fail_val=3
5652 # disable last_xid logic by dropping link reply
5653 ln $DIR/$tdir/f1 $DIR/$tdir/f2 &
5656 #define OBD_FAIL_PTLRPC_ENQ_RESEND 0x534
5657 do_facet mds1 lctl set_param fail_loc=0x534
5659 # RPC will race with its Resend and the Resend will sleep to let
5660 # the original lock to get granted & cancelled.
5662 # AST_SENT is set artificially, so an explicit conflict is not needed
5664 # The woken up Resend gets a new lock, but client does not wait for it
5667 do_facet mds1 lctl set_param fail_loc=0 fail_val=0
5669 # Take a conflict to wait long enough to see the eviction
5672 # let the client reconnect
5674 evict=$(do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state |
5675 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
5677 [ -z "$evict" ] || [[ $evict -le $before ]] ||
5678 (do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state;
5679 error "eviction happened: $evict before:$before")
5681 run_test 110 "do not grant another lock on resend"
5684 [ $MDSCOUNT -ge 2 ] || skip "needs >= 2 MDTs"
5685 [[ $(facet_active_host mds1) = $(facet_active_host mds2) ]] ||
5686 skip "MDT0 and MDT1 should be on the same node"
5689 $LFS mkdir -i 0 $DIR1/$tdir/mdt0dir
5690 $LFS mkdir -i 1 $DIR1/$tdir/mdt1dir
5692 mkdir $DIR1/$tdir/mdt0dir/foodir
5693 touch $DIR1/$tdir/mdt0dir/foodir/{file1,file2}
5695 $MULTIOP $DIR2/$tdir/mdt0dir/foodir/file2 Ow4096_c &
5697 ln $DIR1/$tdir/mdt0dir/foodir/file2 $DIR1/$tdir/mdt1dir/file2
5699 #define OBD_FAIL_MDS_LINK_RENAME_RACE 0x18a
5700 do_facet mds1 $LCTL set_param fail_loc=0x8000018a
5702 ln $DIR1/$tdir/mdt0dir/foodir/file2 $DIR1/$tdir/mdt1dir/file2x &
5705 rm $DIR2/$tdir/mdt1dir/file2
5708 mv $DIR2/$tdir/mdt0dir/foodir/file1 $DIR2/$tdir/mdt0dir/foodir/file2
5713 rm -r $DIR1/$tdir || error "Removing test dir failed"
5715 run_test 111 "A racy rename/link an open file should not cause fs corruption"
5717 log "cleanup: ======================================================"
5719 # kill and wait in each test only guarentee script finish, but command in script
5720 # like 'rm' 'chmod' may still be running, wait for all commands to finish
5721 # otherwise umount below will fail
5722 [ "$(mount | grep $MOUNT2)" ] && wait_update $HOSTNAME "fuser -m $MOUNT2" "" ||
5727 check_and_cleanup_lustre