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 [[ $(uname -r) = *"debug" ]] &&
22 always_except LU-10870 40a
24 if [ $mds1_FSTYPE = "zfs" ]; then
25 # bug number: LU-15757 (test_102() causes crash in umount later)
27 # LU-2829 / LU-2887 - make allowances for ZFS slowness
28 TEST33_NFILES=${TEST33_NFILES:-1000}
32 [ "$SLOW" = "no" ] && EXCEPT_SLOW="33a"
41 check_and_setup_lustre
46 rm -rf $DIR1/[df][0-9]* $DIR1/lnk $DIR/[df].${TESTSUITE}*
48 SAMPLE_FILE=$TMP/$(basename $0 .sh).junk
49 dd if=/dev/urandom of=$SAMPLE_FILE bs=1M count=1
51 # $RUNAS_ID may get set incorrectly somewhere else
52 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
54 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
57 local client2=${CLIENT2:-$HOSTNAME}
62 do_node_vp "$HOSTNAME" printf 'a b\n' |
63 diff $tmp - || error "do_node_vp mismatch"
65 do_node_vp "$client2" printf 'a b\n' |
66 diff $tmp - || error "do_node_vp mismatch"
68 do_facet_vp mds1 printf 'a b\n' |
69 diff $tmp - || error "do_facet_vp mismatch"
71 printf '%s' 1 2 3 4 5 6 7 8 \ 9 10 ' ' '"' "'" \! \' \( \) $'\n' > $tmp
73 do_node_vp "$HOSTNAME" printf '%s' 1 2 3 4 5 6 7 8 \ 9 10 ' ' '"' "'" \! \' \( \) $'\n' |
74 diff $tmp - || error "do_node_vp mismatch"
76 do_node_vp "$client2" printf '%s' 1 2 3 4 5 6 7 8 \ 9 10 ' ' '"' "'" \! \' \( \) $'\n' |
77 diff $tmp - || error "do_node_vp mismatch"
79 do_facet_vp mds1 printf '%s' 1 2 3 4 5 6 7 8 \ 9 10 ' ' '"' "'" \! \' \( \) $'\n' |
80 diff $tmp - || error "do_facet_vp mismatch"
82 run_test 0 "do_node_vp() and do_facet_vp() do the right thing"
86 [ -f $DIR2/$tfile ] || error "Check create"
87 chmod 777 $DIR2/$tfile
88 $CHECKSTAT -t file -p 0777 $DIR1/$tfile ||
89 error "Check attribute update for 0777"
91 chmod a-x $DIR2/$tfile
92 $CHECKSTAT -t file -p 0666 $DIR1/$tfile ||
93 error "Check attribute update for 0666"
96 $CHECKSTAT -a $DIR1/$tfile ||
97 error "Check unlink - removes file on other mountpoint"
99 run_test 1 "Check attribute updates on 2 mount points"
105 $CHECKSTAT -t file -p 0777 $DIR1/f2a ||
106 error "Either not file type or perms not 0777"
108 run_test 2a "check cached attribute updates on 2 mtpt's ========"
114 $CHECKSTAT -t file -p 0777 $DIR2/f2b ||
115 error "Either not file type or perms not 0777"
117 run_test 2b "check cached attribute updates on 2 mtpt's ========"
119 # NEED TO SAVE ROOT DIR MODE
122 $CHECKSTAT -t dir -p 0777 $DIR2 ||
123 error "Either not dir type or perms not 0777"
125 run_test 2c "check cached attribute updates on 2 mtpt's root ==="
129 $CHECKSTAT -t dir -p 0755 $DIR2 ||
130 error "Either not file type or perms not 0775"
132 run_test 2d "check cached attribute updates on 2 mtpt's root ==="
139 $RUNAS dd if=/dev/zero of=$DIR2/$tfile count=1 ||
142 run_test 2e "check chmod on root is propagated to others"
145 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
147 local remote_dir=$tdir/remote_dir
150 $LFS mkdir -i $MDTIDX $DIR1/$remote_dir ||
151 error "Create remote directory failed"
153 touch $DIR1/$remote_dir/$tfile ||
154 error "Create file under remote directory failed"
155 chmod 777 $DIR1/$remote_dir/$tfile ||
156 error "Chmod file under remote directory failed"
158 $CHECKSTAT -t file -p 0777 $DIR2/$remote_dir/$tfile ||
159 error "Check attr of file under remote directory failed"
161 chown $RUNAS_ID:$RUNAS_GID $DIR1/$remote_dir/$tfile ||
162 error "Chown file under remote directory failed"
164 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR2/$remote_dir/$tfile ||
165 error "Check owner of file under remote directory failed"
167 cd $DIR2/$remote_dir || error "enter remote dir"
168 rm -rf $DIR1/$remote_dir/$tfile ||
169 error "Unlink remote directory failed"
171 $CHECKSTAT -t file $DIR2/$remote_dir/$tfile &&
172 error "unlink file still exists!"
174 cd $DIR2/$tdir || error "exit remote dir"
175 rm -rf $DIR1/$tdir || error "unlink directory failed"
177 run_test 2f "check attr/owner updates on DNE with 2 mtpt's"
180 dd if=/dev/zero of=$DIR1/$tfile oflag=sync bs=1M count=2
182 local block1=$(stat $DIR1/$tfile | awk '/Blocks/ {print $4} ')
184 local block2=$(stat $DIR2/$tfile | awk '/Blocks/ {print $4} ')
185 echo "$DIR1/$tfile has $block1 blocks"
186 echo "$DIR2/$tfile has $block2 blocks"
187 [ $block1 -eq $block2 ] || error "$block1 not equal to $block2"
189 run_test 2g "check blocks update on sync write"
192 local target="this/is/good"
193 ln -s $target $DIR1/$tfile || error "ln -s $target $DIR1/$tfile failed"
194 [ "$(ls -l $DIR2/$tfile | sed -e 's/.* -> //')" = "$target" ] ||
195 error "link $DIR2/$tfile not as expected"
197 run_test 3 "symlink on one mtpt, readlink on another ==========="
200 multifstat $DIR1/f4 $DIR2/f4
202 run_test 4 "fstat validation on multiple mount points =========="
206 $TRUNCATE $DIR2/f5 100
207 $CHECKSTAT -t file -s 100 $DIR1/f5 ||
208 error "Either not file type or size not equal to 100 bytes"
211 run_test 5 "create a file on one mount, truncate it on the other"
214 openunlink $DIR1/$tfile $DIR2/$tfile || \
215 error "openunlink $DIR1/$tfile $DIR2/$tfile"
217 run_test 6 "remove of open file on other node =================="
221 opendirunlink $DIR1/$dir $DIR2/$dir || \
222 error "opendirunlink $DIR1/$dir $DIR2/$dir"
224 run_test 7 "remove of open directory on other node ============="
227 opendevunlink $DIR1/$tfile $DIR2/$tfile || \
228 error "opendevunlink $DIR1/$tfile $DIR2/$tfile"
230 run_test 8 "remove of open special file on other node =========="
236 for C in a b c d e f g h i j k l; do
237 dir=`eval echo \\$DIR$MTPT`
238 echo -n $C >> $dir/f9
239 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
241 [ "`cat $DIR1/f9`" = "abcdefghijkl" ] || \
242 error "`od -a $DIR1/f9` != abcdefghijkl"
244 run_test 9a "append of file with sub-page size on multiple mounts"
246 #LU-10681 - tiny writes & appending to sparse striped file
248 [[ $OSTCOUNT -ge 2 ]] || { skip "needs >= 2 OSTs"; return; }
250 $LFS setstripe -c 2 -S 1M $DIR/$tfile
251 echo "foo" >> $DIR/$tfile
252 dd if=/dev/zero of=$DIR2/$tfile bs=1M count=1 seek=1 conv=notrunc ||
253 error "sparse dd $DIR2/$tfile failed"
254 echo "foo" >> $DIR/$tfile
256 data=$(dd if=$DIR2/$tfile bs=1 count=3 skip=$((2 * 1048576)) conv=notrunc)
257 echo "Data read (expecting 'foo')": $data
258 [ "$data" = "foo" ] || error "append to sparse striped file failed"
260 run_test 9b "append to striped sparse file"
267 for C in a b c d e f g h i j k l; do
268 dir=`eval echo \\$DIR$MTPT`
269 echo -n $C | dd of=$dir/f10 bs=1 seek=$OFFSET count=1
270 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
271 OFFSET=`expr $OFFSET + 1`
273 [ "`cat $DIR1/f10`" = "abcdefghijkl" ] || \
274 error "`od -a $DIR1/f10` != abcdefghijkl"
276 run_test 10a "write of file with sub-page size on multiple mounts "
280 yes "R" | head -c 4000 >$TMP/f10b-seed
281 dd if=$TMP/f10b-seed of=$DIR1/f10b bs=3k count=1 || error "dd $DIR1"
283 $TRUNCATE $DIR1/f10b 4096 || error "truncate 4096"
285 dd if=$DIR2/f10b of=$TMP/f10b-lustre bs=4k count=1 || error "dd $DIR2"
287 # create a test file locally to compare
288 dd if=$TMP/f10b-seed of=$TMP/f10b bs=3k count=1 || error "dd random"
289 $TRUNCATE $TMP/f10b 4096 || error "truncate 4096"
290 cmp $TMP/f10b $TMP/f10b-lustre || error "file miscompare"
291 rm $TMP/f10b $TMP/f10b-lustre $TMP/f10b-seed
293 run_test 10b "write of file with sub-page size on multiple mounts "
297 multiop_bg_pause $DIR1/d11/f O_c || return 1
299 cp -p /bin/ls $DIR1/d11/f
303 wait $MULTIPID || error "wait for PID $MULTIPID failed"
304 [ $RC -eq 0 ] && error || true
306 run_test 11 "execution of file opened for write should return error ===="
309 DIR=$DIR DIR2=$DIR2 bash lockorder.sh
311 run_test 12 "test lock ordering (link, stat, unlink)"
313 test_13() { # bug 2451 - directory coherency
315 cd $DIR1/d13 || error "cd to $DIR1/d13 failed"
317 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
319 rm -f $DIR2/d13/f13 || error "Cannot remove $DIR2/d13/f13"
320 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (1)" || true
321 # need to run it twice
322 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
324 rm -f $DIR2/d13/f13 || error "Cannot remove $DIR2/d13/f13"
325 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (2)" || true
327 run_test 13 "test directory page revocation"
330 test_mkdir $DIR1/$tdir
331 cp -p /bin/ls $DIR1/$tdir/$tfile
332 multiop_bg_pause $DIR1/$tdir/$tfile Ow_c || return 1
335 $DIR2/$tdir/$tfile && error || true
338 run_test 14aa "execution of file open for write returns -ETXTBSY"
341 test_mkdir $DIR1/$tdir
342 cp -p $(which sleep) $DIR1/$tdir/sleep || error "cp failed"
343 $DIR1/$tdir/sleep 60 &
345 $MULTIOP $DIR2/$tdir/sleep Oc && error "expected error, got success"
348 run_test 14ab "open(RDWR) of executing file returns -ETXTBSY"
350 test_14b() { # bug 3192, 7040
351 test_mkdir $DIR1/$tdir
352 cp -p $(which sleep) $DIR1/$tdir/sleep || error "cp failed"
353 $DIR1/$tdir/sleep 60 &
355 $TRUNCATE $DIR2/$tdir/sleep 60 && kill -9 $SLEEP_PID && \
356 error "expected truncate error, got success"
358 cmp $(which sleep) $DIR1/$tdir/sleep || error "binary changed"
360 run_test 14b "truncate of executing file returns -ETXTBSY ======"
362 test_14c() { # bug 3430, 7040
363 test_mkdir $DIR1/$tdir
364 cp -p $(which sleep) $DIR1/$tdir/sleep || error "cp failed"
365 $DIR1/$tdir/sleep 60 &
367 cp /etc/hosts $DIR2/$tdir/sleep && error "expected error, got success"
369 cmp $(which sleep) $DIR1/$tdir/sleep || error "binary changed"
371 run_test 14c "open(O_TRUNC) of executing file return -ETXTBSY =="
373 test_14d() { # bug 10921
374 test_mkdir $DIR1/$tdir
375 cp -p $(which sleep) $DIR1/$tdir/sleep || error "cp failed"
376 $DIR1/$tdir/sleep 60 &
379 chmod 600 $DIR1/$tdir/sleep || error "chmod failed"
381 cmp $(which sleep) $DIR1/$tdir/sleep || error "binary changed"
383 run_test 14d "chmod of executing file is still possible ========"
385 test_15() { # bug 974 - ENOSPC
387 bash oos2.sh $MOUNT1 $MOUNT2
388 wait_delete_completed
389 grant_error=$(dmesg | grep "< tot_grant")
390 [ -z "$grant_error" ] || error "$grant_error"
392 run_test 15 "test out-of-space with multiple writers ==========="
395 # The FSXNUM reduction for ZFS is needed until ORI-487 is fixed.
396 # We don't want to skip it entirely, but ZFS is VERY slow and cannot
397 # pass a 2500 operation dual-mount run within the time limit.
398 if [ "$ost1_FSTYPE" = "zfs" ]; then
399 FSXNUM=$((COUNT / 5))
401 elif [ "$SLOW" = "yes" ]; then
402 FSXNUM=$((COUNT * 5))
410 local file1=$DIR1/$tfile
411 local file2=$DIR2/$tfile
412 local stripe_size=$(do_facet $SINGLEMDS \
413 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
417 # to allocate grant because it may run out due to test_15.
418 $LFS setstripe -c -1 $file1
419 dd if=/dev/zero of=$file1 bs=$stripe_size count=$OSTCOUNT oflag=sync
420 dd if=/dev/zero of=$file2 bs=$stripe_size count=$OSTCOUNT oflag=sync
423 $LFS setstripe -c -1 $file1 # b=10919
424 $FSX -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -S 0 $file1 $file2 ||
428 # O_DIRECT reads and writes must be aligned to the PAGE_SIZE.
429 $FSX -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -S 0 -Z -r $PAGE_SIZE \
430 -w $PAGE_SIZE $file1 $file2 || error "fsx with O_DIRECT failed."
432 run_test 16a "$FSXNUM iterations of dual-mount fsx"
434 # Consistency check for tiny writes, LU-9409
436 local file1=$DIR1/$tfile
437 local file2=$DIR2/$tfile
438 local stripe_size=($($LFS getstripe -S $DIR))
442 # to allocate grant because it may run out due to test_15.
443 lfs setstripe -c -1 $file1
444 dd if=/dev/zero of=$file1 bs=$stripe_size count=$OSTCOUNT oflag=sync ||
445 error "dd failed writing to file=$file1"
446 dd if=/dev/zero of=$file2 bs=$stripe_size count=$OSTCOUNT oflag=sync ||
447 error "dd failed writing to file=$file2"
450 lfs setstripe -c -1 $file1 # b=10919
451 # -o is set to 8192 because writes < 1 page and between 1 and 2 pages
452 # create a mix of tiny writes & normal writes
453 $FSX -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -o 8192 -S 0 \
454 $file1 $file2 || error "fsx with tiny write failed."
456 run_test 16b "$FSXNUM iterations of dual-mount fsx at small size"
459 local file1=$DIR1/$tfile
460 local file2=$DIR2/$tfile
461 local stripe_size=$(do_facet $SINGLEMDS \
462 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
464 [ "$ost1_FSTYPE" != ldiskfs ] && skip "dio on ldiskfs only"
468 # to allocate grant because it may run out due to test_15.
469 $LFS setstripe -c -1 $file1
470 dd if=/dev/zero of=$file1 bs=$stripe_size count=$OSTCOUNT oflag=sync
471 dd if=/dev/zero of=$file2 bs=$stripe_size count=$OSTCOUNT oflag=sync
473 wait_delete_completed
475 local list=$(comma_list $(osts_nodes))
476 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
477 skip "not cache-capable obdfilter"
480 set_osd_param $list '' read_cache_enable 0
481 set_osd_param $list '' writethrough_cache_enable 0
483 $LFS setstripe -c -1 $file1 # b=10919
484 $FSX -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -S 0 $file1 $file2 ||
488 set_osd_param $list '' read_cache_enable 1
489 set_osd_param $list '' writethrough_cache_enable 1
493 run_test 16c "verify data consistency on ldiskfs with cache disabled (b=17397)"
496 local file1=$DIR1/$tfile
497 local file2=$DIR2/$tfile
498 local file3=$DIR1/file
499 local tmpfile=$(mktemp)
500 local stripe_size=$(do_facet $SINGLEMDS \
501 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
503 # to allocate grant because it may run out due to test_15.
504 $LFS setstripe -c -1 $file1
505 stack_trap "rm -f $file1 $file2 $file3 $tmpfile"
506 dd if=/dev/zero of=$file1 bs=$stripe_size count=$OSTCOUNT oflag=sync
507 dd if=/dev/zero of=$file2 bs=$stripe_size count=$OSTCOUNT oflag=sync
510 $LFS setstripe -c -1 $file1 # b=10919
511 $LCTL set_param ldlm.namespaces.*.lru_size=clear
513 # direct write on one client and direct read from another
514 dd if=/dev/urandom of=$file1 bs=1M count=100 oflag=direct
515 dd if=$file2 of=$tmpfile iflag=direct bs=1M
516 diff $file1 $tmpfile || error "file different(1)"
519 # buffer write on one client, but direct read from another
520 dd if=$tmpfile of=$file1 bs=1M count=100
521 dd if=$file2 of=$file3 bs=1M iflag=direct count=100
522 diff $file3 $tmpfile || error "file different(2)"
524 rm -f $file3 $file2 $file1
525 # direct write on one client
526 dd if=$tmpfile of=$file1 bs=1M count=100 oflag=direct
527 # buffer read from another client
528 dd if=$file2 of=$file3 bs=1M count=100
529 diff $file3 $tmpfile || error "file different(3)"
531 run_test 16d "Verify DIO and buffer IO with two clients"
533 test_16e() { # LU-13227
536 (( "$MDS1_VERSION" >= $(version_code 2.13.53) )) ||
537 skip "Need MDS version at least 2.13.53"
539 local file1=$DIR1/$tfile
540 local file2=$DIR2/$tfile
542 # client1 write 10M data
543 dd if=/dev/zero of=$file1 bs=1M count=10
545 cancel_lru_locks osc > /dev/null
546 # use lockahead to generate one PW lock to keep LVB loaded.
547 $LFS ladvise -a lockahead --start 0 --length 1M \
549 # direct write to extend file size on client2
550 dd if=/dev/zero of=$file2 bs=1M seek=20 count=1 \
551 oflag=direct conv=notrunc
552 local filesize=$(stat -c %s $file2)
553 [ "$filesize" -eq 22020096 ] ||
554 error "expected filesize 22020096 got $filesize"
557 run_test 16e "Verify size consistency for O_DIRECT write"
559 test_16f() { # LU-14541
560 local file1=$DIR1/$tfile
561 local file2=$DIR2/$tfile
565 (( $MDS1_VERSION > $(version_code 2.15.51) )) ||
566 skip "Need MDS version at least 2.15.51"
568 timeout --preserve-status --signal=USR1 $duration \
569 rw_seq_cst_vs_drop_caches $file1 $file2
572 case $((status & 0x7f)) in
574 echo OK # Computers must be fast now.
577 error "sequential consistency violation detected"
580 echo TIMEOUT # This is fine.
583 error "strange status '$status'"
589 run_test 16f "rw sequential consistency vs drop_caches"
592 local file1=$DIR1/$tfile
593 local file2=$DIR2/$tfile
597 timeout --preserve-status --signal=USR1 $duration \
598 rw_seq_cst_vs_drop_caches -m $file1 $file2
601 case $((status & 0x7f)) in
603 echo OK # Computers must be fast now.
606 error "sequential consistency violation detected"
609 echo TIMEOUT # This is fine.
612 error "strange status '$status'"
618 run_test 16g "mmap rw sequential consistency vs drop_caches"
621 local tf=$DIR/$tdir/$tfile
622 local tf2=$DIR2/$tdir/$tfile
623 local cmd="$MMAP_CAT $tf | od -x | tail -q -n4"
624 local cmd2="$MMAP_CAT $tf2 | od -x | tail -q -n4"
626 test_mkdir $DIR/$tdir
628 # create file and populate data
629 cp /etc/passwd $tf || error "cp failed"
631 local size=$(stat -c %s $tf)
634 if [[ "$c1" != "$c2" ]]; then
635 echo " ------- mount 1 read --------"
637 echo " ------- mount 2 read --------"
639 error "content mismatch"
642 echo " ------- before truncate --------"
646 $TRUNCATE $tf $((size / 2)) || error "truncate file"
649 echo " ------- after truncate --------"
651 # repeat the comparison
654 if [[ "$c1" != "$c2" ]]; then
655 echo " ------- mount 1 read --------"
657 echo " ------- mount 2 read --------"
659 error "content mismatch after truncate"
663 run_test 16h "mmap read after truncate file"
666 local tf=$DIR/$tdir/$tfile
667 local tf2=$DIR2/$tdir/$tfile
669 test_mkdir $DIR/$tdir
671 # create file and populate data
672 cp /etc/passwd $tf || error "cp failed"
674 local size=$(stat -c %s $tf)
676 c1=$(dd if=$tf bs=1 2>/dev/null | od -x | tail -q -n4)
677 c2=$(dd if=$tf2 bs=1 2>/dev/null | od -x | tail -q -n4)
679 if [[ "$c1" != "$c2" ]]; then
680 echo " ------- mount 1 read --------"
682 echo " ------- mount 2 read --------"
684 error "content mismatch"
687 echo " ------- before truncate --------"
691 $TRUNCATE $tf $((size / 2)) || error "truncate file"
693 echo " ------- after truncate --------"
695 # repeat the comparison
696 c1=$(dd if=$tf bs=1 2>/dev/null | od -x | tail -q -n4)
697 c2=$(dd if=$tf2 bs=1 2>/dev/null | od -x | tail -q -n4)
699 if [[ "$c1" != "$c2" ]]; then
700 echo " ------- mount 1 read --------"
702 echo " ------- mount 2 read --------"
704 error "content mismatch after truncate"
708 run_test 16i "read after truncate file"
712 (( $OSTCOUNT >= 2 )) || skip "needs >= 2 OSTs"
713 (( $OST1_VERSION >= $(version_code v2_15_57-52-g43c3a804fe) )) ||
714 skip "Need OST version at least 2.15.57.52 for unaligned DIO"
716 local stripe_size=$((1024 * 1024)) #1 MiB
717 # Max i/o below is ~ 4 * stripe_size, so this gives ~5 i/os
718 local file_size=$((25 * stripe_size))
721 $LFS setstripe -c 2 -S $stripe_size $DIR/$tfile.1
722 stack_trap "rm -f $DIR/$tfile.1"
724 # Just a bit bigger than the largest size in the test set below
725 dd if=/dev/urandom bs=$file_size count=1 of=$DIR/$tfile.1 ||
726 error "buffered i/o to create file failed"
728 if zfs_or_rotational; then
729 # DIO on ZFS can take up to 2 seconds per IO
730 # rotational is better, but still slow.
731 # Limit testing on those media to larger sizes
732 bsizes="$((stripe_size - PAGE_SIZE)) $stripe_size \
733 $((stripe_size + 1024))"
735 bsizes="$((PAGE_SIZE / 4)) $((PAGE_SIZE - 1024)) \
736 $((PAGE_SIZE - 1)) $PAGE_SIZE $((PAGE_SIZE + 1024)) \
737 $((PAGE_SIZE * 3/2)) $((PAGE_SIZE * 4)) \
738 $((stripe_size - 1)) $stripe_size \
739 $((stripe_size + 1)) $((stripe_size * 3/2)) \
740 $((stripe_size * 4)) $((stripe_size * 4 + 1))"
743 # 1 process (BIO or DIO) on each client
744 for bs in $bsizes; do
745 $LFS setstripe -c 2 -S $stripe_size $DIR/$tfile.2
746 echo "bs: $bs, file_size $file_size"
747 dd if=$DIR/$tfile.1 bs=$((bs *2 )) of=$DIR/tfile.2 \
748 conv=notrunc oflag=direct iflag=direct &
750 # Buffered I/O with similar but not the same block size
751 dd if=$DIR2/$tfile.1 bs=$((bs * 2)) of=$DIR2/$tfile.2 \
758 if (( rc1 != 0 )); then
759 error "dio copy 1 w/bsize $bs failed: $rc1"
761 if (( rc2 != 0 )); then
762 error "buffered copy 2 w/bsize $bs failed: $rc2"
765 $CHECKSTAT -t file -s $file_size $DIR/$tfile.2 ||
766 error "size incorrect"
767 $CHECKSTAT -t file -s $file_size $DIR2/$tfile.2 ||
768 error "size incorrect - mount 2"
769 cmp --verbose $DIR/$tfile.1 $DIR/$tfile.2 ||
770 error "files differ, bsize $bs"
771 cmp --verbose $DIR2/$tfile.1 $DIR2/$tfile.2 ||
772 error "files differ, bsize $bs - mount 2"
776 # 2 processes - both DIO and BIO - on each client
777 for bs in $bsizes; do
778 $LFS setstripe -c 2 -S $stripe_size $DIR/$tfile.2
779 echo "bs: $bs, file_size $file_size"
781 dd if=$DIR/$tfile.1 bs=$((bs *2 )) of=$DIR/tfile.2 \
782 conv=notrunc oflag=direct iflag=direct &
784 # Buffered I/O with similar but not the same block size
785 dd if=$DIR/$tfile.1 bs=$((bs * 2)) of=$DIR/$tfile.2 \
789 dd if=$DIR2/$tfile.1 bs=$((bs *2 )) of=$DIR2/tfile.2 \
790 conv=notrunc oflag=direct iflag=direct &
792 # Buffered I/O with similar but not the same block size
793 dd if=$DIR2/$tfile.1 bs=$((bs * 2)) of=$DIR2/$tfile.2 \
805 if (( rc1 != 0 )); then
806 error "dio copy 1 w/bsize $bs failed: $rc1"
808 if (( rc2 != 0 )); then
809 error "buffered copy 2 w/bsize $bs failed: $rc2"
811 if (( rc3 != 0 )); then
812 error "dio copy 3 w/bsize $bs failed: $rc1"
814 if (( rc4 != 0 )); then
815 error "buffered copy 4 w/bsize $bs failed: $rc2"
818 $CHECKSTAT -t file -s $file_size $DIR/$tfile.2 ||
819 error "size incorrect"
820 $CHECKSTAT -t file -s $file_size $DIR2/$tfile.2 ||
821 error "size incorrect - mount 2"
822 cmp --verbose $DIR/$tfile.1 $DIR/$tfile.2 ||
823 error "files differ, bsize $bs"
824 cmp --verbose $DIR2/$tfile.1 $DIR2/$tfile.2 ||
825 error "files differ, bsize $bs - mount 2"
829 run_test 16j "race dio with buffered i/o"
832 local fsxN=${FSX_NP:-5}
833 local fsxNops=${FSX_NOPS:-10000}
834 local fsxNparams=${FSXPARAMS_16k:-""}
835 local dropsleep=${DROP_SLEEP:-3}
840 [ "$SLOW" = "no" ] && fsxNops=1000
843 echo 3 > /proc/sys/vm/drop_caches
847 stack_trap "kill -9 $dpipd"
849 for ((i = 1; i <= fsxN; i++)); do
850 cmd="$FSX $fsxNparams -N $fsxNops $DIR/fsxfile.${i} -l $((64 * 1024 * 1024))"
855 for ((i = 1; i <= fsxN; i++)); do
856 wait ${fsxpids[$i]} && echo "+ fsx $i done: rc=$?" ||
857 error "- fsx $i FAILURE! rc=$?"
861 run_test 16k "Parallel FSX and drop caches should not panic"
863 test_17() { # bug 3513, 3667
864 remote_ost_nodsh && skip "remote OST with nodsh" && return
866 lfs setstripe $DIR1/$tfile -i 0 -c 1
867 cp $SAMPLE_FILE $DIR1/$tfile
868 cancel_lru_locks osc > /dev/null
869 #define CFS_FAIL_ONCE|OBD_FAIL_LDLM_CREATE_RESOURCE 0x30a
870 do_facet ost1 lctl set_param fail_loc=0x8000030a
871 ls -ls $DIR1/$tfile | awk '{ print $1,$6 }' > $DIR1/$tfile-1 & \
872 ls -ls $DIR2/$tfile | awk '{ print $1,$6 }' > $DIR2/$tfile-2
874 diff -u $DIR1/$tfile-1 $DIR2/$tfile-2 || error "files are different"
876 run_test 17 "resource creation/LVB creation race ==============="
879 # turn e.g. ALWAYS_EXCEPT="18c" into "-e 3"
882 for idx in {a..z}; do
883 local ptr=EXCEPT_ALWAYS_18$idx
884 [ x${!ptr} = xtrue ] || continue
886 excepts="$excepts -e $(($(printf %d \'$idx)-96))"
889 excepts="$excepts -e 7 -e 8 -e 9"
890 $LUSTRE/tests/mmap_sanity -d $MOUNT1 -m $MOUNT2 $excepts ||
891 error "mmap_sanity test failed"
894 run_test 18 "mmap sanity check ================================="
896 test_19() { # bug3811
897 local node=$(facet_active_host ost1)
898 local device="$FSNAME-OST*"
900 [ "x$DOM" = "xyes" ] && node=$(facet_active_host $SINGLEMDS) &&
901 device="$FSNAME-MDT*"
903 # check whether obdfilter is cache capable at all
904 get_osd_param $node $device read_cache_enable >/dev/null ||
905 skip "not cache-capable obdfilter"
907 local max=$(get_osd_param $node $device readcache_max_filesize |\
909 set_osd_param $node $device readcache_max_filesize 4096
910 dd if=/dev/urandom of=$TMP/$tfile bs=512k count=32
911 local SUM=$(cksum $TMP/$tfile | cut -d" " -f 1,2)
912 cp $TMP/$tfile $DIR1/$tfile
913 for i in `seq 1 20`; do
914 [ $((i % 5)) -eq 0 ] && log "$testname loop $i"
915 cancel_lru_locks $OSC > /dev/null
916 cksum $DIR1/$tfile | cut -d" " -f 1,2 > $TMP/sum1 & \
917 cksum $DIR2/$tfile | cut -d" " -f 1,2 > $TMP/sum2
919 [ "$(cat $TMP/sum1)" = "$SUM" ] || \
920 error "$DIR1/$tfile $(cat $TMP/sum1) != $SUM"
921 [ "$(cat $TMP/sum2)" = "$SUM" ] || \
922 error "$DIR2/$tfile $(cat $TMP/sum2) != $SUM"
924 set_osd_param $node $device readcache_max_filesize $max
927 run_test 19 "test concurrent uncached read races ==============="
930 test_mkdir $DIR1/$tdir
932 CNT=$($LCTL get_param -n llite.*.dump_page_cache | wc -l)
933 $MULTIOP $DIR1/$tdir/$tfile Ow8190c
934 $MULTIOP $DIR2/$tdir/$tfile Oz8194w8190c
935 $MULTIOP $DIR1/$tdir/$tfile Oz0r8190c
937 CNT2=$($LCTL get_param -n llite.*.dump_page_cache | wc -l)
938 [[ $CNT2 == $CNT ]] ||
939 error $((CNT2 - CNT))" page left in cache after lock cancel"
941 run_test 20 "test extra readahead page left in cache ===="
948 test_21() { # Bug 5907
949 test_mkdir $DIR1/$tdir
950 mount /etc $DIR1/$tdir --bind || error "mount failed" # Poor man's mount.
952 rmdir -v $DIR1/$tdir && error "Removed mounted directory"
953 rmdir -v $DIR2/$tdir && echo "Removed mounted directory from another mountpoint, needs to be fixed"
954 test -d $DIR1/$tdir || error "Mounted directory disappeared"
956 test -d $DIR2/$tdir || test -d $DIR1/$tdir && error "Removed dir still visible after umount"
959 run_test 21 " Try to remove mountpoint on another dir ===="
961 test_23() { # Bug 5972
962 local at_diff=$(do_facet $SINGLEMDS \
963 $LCTL get_param -n mdd.*MDT0000*.atime_diff | head -n1)
964 echo "atime should be updated while another read" > $DIR1/$tfile
966 # clear the lock(mode: LCK_PW) gotten from creating operation
967 cancel_lru_locks $OSC
970 sleep $((at_diff + 1))
972 echo "starting reads"
973 multiop_bg_pause $DIR1/$tfile or20_c || return 1
974 # with SOM and opencache enabled, we need to close a file and cancel
975 # open lock to get atime propogated to MDS
976 kill -USR1 $! || return 2
979 time2=$(stat -c "%X" $DIR/$tfile)
980 echo "new atime is $time2"
982 [ $time2 -gt $time1 ] || error "atime was not updated"
983 rm -f $DIR1/$tfile || error "rm -f $DIR1/$tfile failed"
986 run_test 23 " others should see updated atime while another read===="
990 lfs df || error "lfs df failed"
991 lfs df -ih || error "lfs df -ih failed"
992 lfs df -h $DIR1 || error "lfs df -h $DIR1 failed"
993 lfs df -i $DIR2 || error "lfs df -i $DIR2 failed"
994 lfs df $DIR1/$tfile || error "lfs df $DIR1/$tfile failed"
995 lfs df -ih $DIR2/$tfile || error "lfs df -ih $DIR2/$tfile failed"
997 OSC=`lctl dl | awk '/-osc-|OSC.*MNT/ {print $4}' | head -n 1`
998 # OSC=`lctl dl | awk '/-osc-/ {print $4}' | head -n 1`
999 lctl --device %osc deactivate
1000 lfs df -i || error "lfs df -i with deactivated OSC failed"
1001 lctl --device %osc activate
1002 lfs df || error "lfs df with reactivated OSC failed"
1004 run_test 24a "lfs df [-ih] [path] test ========================="
1008 fsnum=$(lfs_df | grep -c "summary")
1009 [ $fsnum -eq 2 ] || error "lfs df shows $fsnum != 2 filesystems."
1011 run_test 24b "lfs df should show both filesystems ==============="
1014 local acl=$(lctl get_param -n mdc.*MDT0000-mdc-*.connect_flags |
1016 [ "$acl" -lt 1 ] && skip "must have acl, skipping" && return
1018 mkdir -p $DIR1/$tdir
1019 touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
1020 chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
1022 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
1023 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
1024 error "setfacl $DIR2/$tdir #1"
1025 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
1026 setfacl -m u:$RUNAS_ID:r-x -m g:$RUNAS_GID:r-x $DIR1/$tdir ||
1027 error "setfacl $DIR2/$tdir #2"
1028 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
1029 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
1030 error "setfacl $DIR2/$tdir #3"
1031 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
1032 setfacl -x u:$RUNAS_ID: -x g:$RUNAS_GID: $DIR1/$tdir ||
1033 error "setfacl $DIR2/$tdir #4"
1034 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
1038 run_test 25a "change ACL on one mountpoint be seen on another ==="
1041 local acl=$(lctl get_param -n mdc.*MDT0000-mdc-*.connect_flags |
1043 [ "$acl" -lt 1 ] && skip "must have acl, skipping" && return
1045 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1048 $LFS mkdir -i 1 $DIR1/$tdir
1049 touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
1050 chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
1052 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
1053 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
1054 error "setfacl $DIR2/$tdir #1"
1055 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
1056 setfacl -m u:$RUNAS_ID:r-x -m g:$RUNAS_GID:r-x $DIR1/$tdir ||
1057 error "setfacl $DIR2/$tdir #2"
1058 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
1059 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
1060 error "setfacl $DIR2/$tdir #3"
1061 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
1062 setfacl -x u:$RUNAS_ID: -x g:$RUNAS_GID: $DIR1/$tdir ||
1063 error "setfacl $DIR2/$tdir #4"
1064 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
1068 run_test 25b "change ACL under remote dir on one mountpoint be seen on another"
1071 utime $DIR1/f26a -s $DIR2/f26a || error "utime failed for $DIR1/f26a"
1073 run_test 26a "allow mtime to get older"
1078 echo "aaa" >> $DIR1/$tfile
1080 chmod a+x $DIR2/$tfile
1081 mt1=`stat -c %Y $DIR1/$tfile`
1082 mt2=`stat -c %Y $DIR2/$tfile`
1084 if [ x"$mt1" != x"$mt2" ]; then
1085 error "not equal mtime, client1: \"$mt1\", client2: \"$mt2\"."
1088 run_test 26b "sync mtime between ost and mds"
1091 (( $MDS1_VERSION >= $(version_code 2.15.61) )) ||
1092 skip "Need MDS version at least 2.15.61"
1094 multiop_bg_pause $DIR1/$tfile O_c || error "multiop failed"
1096 touch -am -d @978261179 $DIR2/$tfile
1097 kill -USR1 $MULTIPID
1098 wait $MULTIPID || error "wait for PID $MULTIPID failed"
1103 local times="$(stat -c"%X %Y" $DIR/$tfile)"
1104 [[ "$times" == "978261179 978261179" ]] ||
1105 error "[am]times are not set in past on $DIR: $times"
1108 local times="$(stat -c"%X %Y" $DIR2/$tfile)"
1109 [[ "$times" == "978261179 978261179" ]] ||
1110 error "[am]times are not set in past on $DIR2: $times"
1113 run_test 26c "set-in-past on open file is not lost on close"
1116 cancel_lru_locks $OSC
1118 dd if=/dev/zero of=$DIR2/$tfile bs=$((4096+4))k conv=notrunc count=4 seek=3 &
1123 dd if=/dev/zero of=$DIR1/$tfile bs=$((16384-1024))k conv=notrunc count=1 seek=4 &
1128 dd if=/dev/zero of=$DIR1/$tfile bs=8k conv=notrunc count=1 seek=0
1130 lctl set_param -n ldlm.dump_namespaces ""
1131 wait $DD1_PID $DD2_PID
1132 [ $? -ne 0 ] && lctl dk $TMP/debug || true
1134 run_test 27 "align non-overlapping extent locks from request ==="
1136 test_30() { #b=11110, LU-2523
1137 test_mkdir $DIR1/$tdir
1138 cp -f /bin/bash $DIR1/$tdir/bash
1139 bash -c 'sleep 1; rm -f $DIR2/$tdir/bash; cp /bin/bash $DIR2/$tdir' &
1140 $DIR1/$tdir/bash -c 'sleep 2;
1141 openfile -f O_RDONLY /proc/$$/exe >& /dev/null; echo $?'
1145 run_test 30 "recreate file race"
1148 test_mkdir $DIR1/$tdir
1149 local writes=$(LANG=C dd if=/dev/zero of=$DIR/$tdir/$tfile \
1150 count=1 2>&1 | awk 'BEGIN { FS="+" } /out/ {print $1}')
1151 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
1152 lctl set_param fail_loc=0x314
1153 local reads=$(LANG=C dd if=$DIR2/$tdir/$tfile of=/dev/null 2>&1 |
1154 awk 'BEGIN { FS="+" } /in/ {print $1}')
1155 [ $reads -eq $writes ] || error "read" $reads "blocks, must be" $writes
1157 run_test 31a "voluntary cancel / blocking ast race=============="
1160 remote_ost || { skip "local OST" && return 0; }
1161 remote_ost_nodsh && skip "remote OST w/o dsh" && return 0
1163 # make sure there is no local locks due to destroy
1164 wait_mds_ost_sync || error "wait_mds_ost_sync()"
1165 wait_delete_completed || error "wait_delete_completed()"
1167 test_mkdir $DIR1/$tdir
1168 lfs setstripe $DIR/$tdir/$tfile -i 0 -c 1
1169 cp /etc/hosts $DIR/$tdir/$tfile
1170 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
1171 lctl set_param fail_loc=0x314
1172 #define OBD_FAIL_LDLM_OST_FAIL_RACE 0x316
1173 do_facet ost1 lctl set_param fail_loc=0x316
1174 # Don't crash kernel
1175 cat $DIR2/$tdir/$tfile > /dev/null 2>&1
1176 lctl set_param fail_loc=0
1177 do_facet ost1 lctl set_param fail_loc=0
1178 # cleanup: reconnect the client back
1181 run_test 31b "voluntary OST cancel / blocking ast race=============="
1183 #LU-14949 - multi-client version of the test 31r in sanity.
1185 touch $DIR/$tfile.target
1186 touch $DIR/$tfile.source
1188 ls -l $DIR/$tfile.target # cache it for sure
1190 #OBD_FAIL_LLITE_OPEN_DELAY 0x1419
1191 $LCTL set_param fail_loc=0x1419 fail_val=3
1192 cat $DIR/$tfile.target &
1195 # Guarantee open is waiting before we get here
1197 mv $DIR2/$tfile.source $DIR2/$tfile.target
1201 if [[ $RC -ne 0 ]]; then
1202 error "open with cat failed, rc=$RC"
1205 run_test 31r "open-rename(replace) race"
1210 mkdir_on_mdt0 $DIR/$tdir
1211 touch $DIR/$tdir/$tfile || error "touch $tdir/$tfile failed"
1212 ( cd $DIR/$tdir; tail -f $tfile || $MULTIOP . Dc) & pid=$!
1215 stack_trap "pkill -P $pid 2> /dev/null" ERR
1217 mv $DIR2/$tdir $DIR2/$tdir.old || error "mv $tdir $tdir.old failed"
1218 mkdir_on_mdt0 $DIR2/$tdir || error "mkdir $DIR2/$tdir failed"
1219 mv $DIR2/$tdir.old $DIR2/$tdir/ || error "mv $tdir.old $tdir/ failed"
1221 pkill -P $pid || error "fail to stop $pid"
1224 ls_str="$(ls $DIR/$tdir)" || error "ls $DIR/$tdir failed"
1225 [[ "$ls_str" == "$tdir.old" ]] ||
1226 error "invalid dentry $DIR/$tdir: $ls_str != $tdir.old"
1228 run_test 31s "open should not revalidate invalid dentry"
1233 touch $DIR/$tfile || error "touch $tfile failed"
1235 $MULTIOP $DIR/$tfile o_Sc & pid=$!
1236 stack_trap "kill $pid 2> /dev/null" ERR
1239 mv $DIR2/$tfile $DIR2/$tfile.old || error "mv $tfile $tfile.old failed"
1240 touch $DIR2/$tfile || error "touch $tfile failed"
1241 i_new=$(stat -c "%i" $DIR2/$tfile) || error "stat $tfile failed"
1243 kill -SIGUSR1 $pid || error "fail to stop $pid"
1246 i=$(stat -c "%i" $DIR/$tfile) || error "stat $tfile failed"
1248 error "invalid dentry $DIR/$tfile, not updated (inode: $i != $i_new)"
1250 run_test 31t "getattr should not revalidate invalid dentry"
1252 test_32b() { # bug 11270
1253 remote_ost_nodsh && skip "remote OST with nodsh" && return
1256 local facets=$(get_facets OST)
1257 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
1259 save_lustre_params $facets \
1260 "ldlm.namespaces.filter-*.max_nolock_bytes" > $p
1261 save_lustre_params $facets \
1262 "ldlm.namespaces.filter-*.contended_locks" >> $p
1263 save_lustre_params $facets \
1264 "ldlm.namespaces.filter-*.contention_seconds" >> $p
1265 clear_stats $OSC.*.${OSC}_stats
1267 # agressive lockless i/o settings
1268 do_nodes $(comma_list $(osts_nodes)) \
1269 "lctl set_param -n ldlm.namespaces.*.max_nolock_bytes=2000000 \
1270 ldlm.namespaces.filter-*.contended_locks=0 \
1271 ldlm.namespaces.filter-*.contention_seconds=60"
1273 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > \
1275 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > \
1278 [ $(calc_stats $OSC.*.${OSC}_stats lockless_write_bytes) -ne 0 ] ||
1279 error "lockless i/o was not triggered"
1280 # disable lockless i/o (it is disabled by default)
1281 # set contention_seconds to 0 at client too, otherwise Lustre still
1282 # remembers lock contention
1283 do_nodes $(comma_list $(osts_nodes)) \
1284 "lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes=0 \
1285 ldlm.namespaces.filter-*.contended_locks=32 \
1286 ldlm.namespaces.filter-*.contention_seconds=0"
1287 clear_stats $OSC.*.${OSC}_stats
1289 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > \
1291 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > \
1294 [ $(calc_stats $OSC.*.${OSC}_stats lockless_write_bytes) -eq 0 ] ||
1295 error "lockless i/o works when disabled"
1297 restore_lustre_params <$p
1300 # Disable test 32b prior to full removal
1301 #run_test 32b "lockless i/o"
1304 local mdts=$(get_facets MDS)
1310 for mds in ${mdts//,/ }; do
1313 dev=$(basename $(do_facet $mds "lctl get_param -n \
1314 osd*.${!varsvc}.mntdev | xargs readlink -f"))
1315 val=$(do_facet $mds "cat /proc/fs/jbd*/${dev}{,:*,-*}/info \
1316 2>/dev/null | head -n1")
1318 stat=$((stat + val))
1323 # commit on sharing tests
1325 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1327 [ $CLIENTCOUNT -lt 2 ] &&
1328 skip "Need two or more clients, have $CLIENTCOUNT"
1330 local nfiles=${TEST33_NFILES:-10000}
1331 local param_file=$TMP/$tfile-params
1337 save_lustre_params $(get_facets MDS) \
1338 "mdt.*.commit_on_sharing" > $param_file
1341 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
1345 do_nodes $CLIENT1,$CLIENT2 "mkdir -p $DIR1/$tdir-\\\$(hostname)-$i"
1347 [ "$mds1_FSTYPE" = ldiskfs ] && jbdold=$(print_jbd_stat)
1348 echo "=== START createmany old: $jbdold transaction"
1349 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")
1350 [ "$mds1_FSTYPE" = ldiskfs ] && jbdnew=$(print_jbd_stat)
1351 [ "$mds1_FSTYPE" = ldiskfs ] && jbd=$(( jbdnew - jbdold ))
1352 echo "=== END createmany new: $jbdnew transaction : $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
1353 [ "$mds1_FSTYPE" = ldiskfs ] && avgjbd=$(( avgjbd + jbd ))
1354 avgtime=$(( avgtime + elapsed ))
1356 eval cos${COS}_jbd=$((avgjbd / 3))
1357 eval cos${COS}_time=$((avgtime / 3))
1360 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
1361 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
1362 [ "$cos0_jbd" != 0 ] &&
1363 echo "COS=1 vs COS=0 jbd: $((((cos1_jbd/cos0_jbd - 1)) * 100 )) %"
1364 [ "$cos0_time" != 0 ] &&
1365 echo "COS=1 vs COS=0 time: $((((cos1_time/cos0_time - 1)) * 100 )) %"
1367 restore_lustre_params < $param_file
1371 run_test 33a "commit on sharing, cross crete/delete, 2 clients, benchmark"
1373 # commit on sharing tests
1375 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1377 [ $CLIENTCOUNT -ge 2 ] ||
1378 { skip "Need two or more clients, have $CLIENTCOUNT" &&
1380 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1382 local nfiles=${TEST33_NFILES:-10000}
1383 local param_file=$TMP/$tfile-params
1385 save_lustre_params $(get_facets MDS) \
1386 "mdt.*.commit_on_sharing" > $param_file
1395 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
1399 do_node $CLIENT1 "$LFS mkdir -i $MDTIDX \
1400 $DIR1/$tdir-\\\$(hostname)-$i"
1402 jbdold=$(print_jbd_stat)
1403 echo "=== START createmany old: $jbdold transaction"
1404 local elapsed=$(do_and_time "do_nodes $CLIENT1,$CLIENT2\
1405 createmany -o $DIR1/$tdir-\\\$(hostname)-$i/f- \
1406 -r$DIR2/$tdir-\\\$(hostname)-$i/f- $nfiles > \
1408 jbdnew=$(print_jbd_stat)
1409 jbd=$(( jbdnew - jbdold ))
1410 echo "=== END createmany new: $jbdnew transaction : \
1411 $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
1412 avgjbd=$(( avgjbd + jbd ))
1413 avgtime=$(( avgtime + elapsed ))
1415 eval cos${COS}_jbd=$((avgjbd / 3))
1416 eval cos${COS}_time=$((avgtime / 3))
1419 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
1420 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
1421 [ "$cos0_jbd" != 0 ] &&
1422 echo "COS=1 vs COS=0 jbd: $(((cos1_jbd/cos0_jbd - 1) * 100)) %"
1423 [ "$cos0_time" != 0 ] &&
1424 echo "COS=1 vs COS=0 time: $(((cos1_time/cos0_time - 1) * 100)) %"
1426 restore_lustre_params < $param_file
1430 run_test 33b "COS: cross create/delete, 2 clients, benchmark under remote dir"
1432 # arg1 is description, arg2 is operations before Sync-on-Lock-Cancel, arg3 is
1433 # the operation that triggers SoLC
1437 local nodes=$(comma_list $(mdts_nodes))
1441 # trigger CoS twice in case transaction commit before unlock
1444 do_nodes $nodes "$LCTL set_param -n mdt.*.sync_count=0"
1446 sync_count=$(do_nodes $nodes \
1447 "lctl get_param -n mdt.*MDT*.sync_count" | calc_sum)
1448 total=$((total + sync_count));
1456 echo " SoLC count $total"
1457 (( total > 0 )) || error "$3 didn't trigger SoLC"
1467 (( MDSCOUNT >= 2 )) || skip "needs >= 2 MDTs"
1468 (( MDS1_VERSION >= $(version_code 2.7.63) )) ||
1469 skip "DNE CoS not supported"
1473 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS || error "start mds1 failed"
1475 mkdir_on_mdt0 $DIR/$tdir
1478 if (( MDS1_VERSION < $(version_code 2.15.55.204) )); then
1479 op_trigger_solc "create remote dir and local dir" \
1480 "$LFS mkdir -i 1 $DIR/$tdir/remote" \
1481 "$LFS mkdir -i 0 $DIR/$tdir/local"
1482 (( MDSCOUNT > 2 )) &&
1483 op_trigger_solc "create remote dirs on different MDTs" \
1484 "$LFS mkdir -i 1 $DIR/$tdir/remote.1" \
1485 "$LFS mkdir -i 2 $DIR/$tdir/remote.2"
1487 op_trigger_solc "create file on 2nd stripe under striped directory" \
1488 "$LFS mkdir -i 0 -c 2 $DIR/$tdir/striped" \
1489 "touch $DIR2/$tdir/striped/subfile"
1492 echo "Below operations shouldn't trigger Solc:"
1493 $LFS mkdir -i 0 -c 2 $DIR/$tdir/striped
1495 do_facet mds1 "lctl set_param -n mdt.*.sync_count=0"
1496 if (( MDS1_VERSION >= $(version_code 2.15.55.204) )); then
1497 test_33_run "create file on 2nd stripe after setattr" \
1498 "chmod 777 $DIR/$tdir/striped; \
1499 touch $DIR2/$tdir/striped/subfile"
1500 test_33_run "create remote dir and local dir" \
1501 "$LFS mkdir -i 1 $DIR/$tdir/remote" \
1502 "$LFS mkdir -i 0 $DIR/$tdir/local"
1503 (( MDSCOUNT > 2 )) &&
1504 test_33_run "create remote dirs on different MDTs" \
1505 "$LFS mkdir -i 1 $DIR/$tdir/remote.1" \
1506 "$LFS mkdir -i 2 $DIR/$tdir/remote.2"
1508 test_33_run "create local dir after remote dir creation transaction commit" \
1509 "$LFS mkdir -i 1 $DIR/$tdir/remote.3; \
1510 do_facet mds2 $LCTL set_param -n osd*.*MDT0001.force_sync 1;
1511 mkdir $DIR/$tdir/local.3"
1512 sync_count=$(do_facet mds1 "lctl get_param -n mdt.*MDT0000.sync_count")
1513 echo "Solc count $sync_count"
1514 [ $sync_count -eq 0 ] || error "Sync-Lock-Cancel triggered"
1516 run_test 33c "Cancel cross-MDT lock should trigger Sync-on-Lock-Cancel"
1518 # arg1 is description, arg2 is operations done before CoS, arg3 is the operation
1523 local nodes=$(comma_list $(mdts_nodes))
1527 # trigger CoS twice in case transaction commit before unlock
1530 do_nodes $nodes "lctl set_param -n mdt.*.async_commit_count=0"
1532 commit_nr=$(do_nodes $nodes \
1533 "lctl get_param -n mdt.*.async_commit_count" | calc_sum)
1534 total=$((total + commit_nr));
1542 echo " CoS count $total"
1543 (( total > 0 )) || error "$3 didn't trigger CoS"
1547 (( MDSCOUNT > 1 )) || skip "needs >= 2 MDTs"
1548 (( MDS1_VERSION >= $(version_code 2.7.63) )) ||
1549 skip "DNE CoS not supported"
1551 if (( $MDS1_VERSION < $(version_code 2.15.55.133) )); then
1552 op_trigger_cos "remote directory unlink" \
1553 "$LFS mkdir -i 1 $DIR/$tdir" "rmdir $DIR2/$tdir"
1554 op_trigger_cos "striped directory create" "mkdir $DIR/$tdir" \
1555 "$LFS mkdir -c 2 $DIR2/$tdir/subdir"
1556 op_trigger_cos "striped directory setattr" \
1557 "$LFS mkdir -c 2 $DIR/$tdir" "chmod 713 $DIR2/$tdir"
1558 op_trigger_cos "striped directory unlink" \
1559 "$LFS mkdir -c 2 $DIR/$tdir" "rmdir $DIR2/$tdir"
1560 op_trigger_cos "cross-MDT link" \
1561 "mkdir $DIR/$tdir; \
1562 $LFS mkdir -i 0 $DIR/$tdir/d1; \
1563 $LFS mkdir -i 1 $DIR/$tdir/d2; \
1564 touch $DIR/$tdir/d1/tgt" \
1565 "ln $DIR2/$tdir/d1/tgt $DIR2/$tdir/d2/src"
1568 op_trigger_cos "remote directory create" "$LFS mkdir -i 0 $DIR/$tdir" \
1569 "$LFS mkdir -i 1 $DIR2/$tdir/subdir"
1570 op_trigger_cos "cross-MDT rename" \
1571 "mkdir $DIR/$tdir; \
1572 $LFS mkdir -i 0 $DIR/$tdir/d1; \
1573 $LFS mkdir -i 1 $DIR/$tdir/d2; \
1574 touch $DIR/$tdir/d1/src" \
1575 "mv $DIR2/$tdir/d1/src $DIR2/$tdir/d2/tgt"
1576 op_trigger_cos "migrate" \
1577 "$LFS mkdir -i 0 $DIR/$tdir" \
1578 "$LFS migrate -m 1 $DIR2/$tdir"
1582 run_test 33d "dependent transactions should trigger COS"
1585 (( MDSCOUNT > 1 )) || skip "needs >= 2 MDTs"
1586 (( MDS1_VERSION >= $(version_code 2.7.63) )) ||
1587 skip "DNE CoS not supported"
1588 (( MDS1_VERSION >= $(version_code 2.15.56.127) )) ||
1589 skip "need MDS >= v2_15_56-127-g2a78a9e2cda1 for CoS fix"
1591 $LFS mkdir -i 0 $DIR/$tdir
1592 $LFS mkdir -i 0 $DIR/$tdir/d1
1593 $LFS mkdir -i 1 $DIR/$tdir/d2
1595 local nodes=$(comma_list $(mdts_nodes))
1596 do_nodes $nodes "lctl set_param -n mdt.*.async_commit_count=0"
1598 test_33_run "plain dir creation" "mkdir $DIR2/$tdir/plain"
1599 test_33_run "open file and write" "echo abc > $DIR2/$tdir/$tfile"
1600 test_33_run "append write" "echo dfg >> $DIR2/$tdir/$tfile"
1601 test_33_run "setattr" "touch $DIR2/$tdir/$tfile"
1602 test_33_run "file unlink" "rm $DIR2/$tdir/$tfile"
1603 test_33_run "plain dir unlink" "rmdir $DIR2/$tdir/plain"
1604 if (( MDS1_VERSION >= $(version_code 2.15.55.133) )); then
1605 test_33_run "striped directory creation" \
1606 "$LFS mkdir -i 0 -c 2 $DIR2/$tdir/striped"
1607 test_33_run "set default LMV to create striped subdir" \
1608 "$LFS setdirstripe -D -c 2 $DIR/$tdir"
1609 test_33_run "striped subdir creation" \
1610 "createmany -d $DIR/$tdir/subdir 100"
1611 test_33_run "sub file creation and write" \
1612 "createmany -o $DIR/$tdir/subfile 100; \
1613 echo abc > $DIR/$tdir/subfile1"
1614 test_33_run "sub file append write" \
1615 "echo dfg >> $DIR2/$tdir/subfile2"
1616 test_33_run "subdir setatttr" "touch $DIR2/$tdir/subdir1"
1617 test_33_run "subdir unlink" \
1618 "unlinkmany -d $DIR/$tdir/subdir 100"
1619 test_33_run "sub file unlink" \
1620 "unlinkmany $DIR2/$tdir/subfile 100"
1621 test_33_run "sub file creation follows striped dir chmod" \
1622 "chmod 777 $DIR/$tdir/striped; \
1623 touch $DIR/$tdir/striped/subfile"
1624 test_33_run "striped directory unlink" \
1625 "rm -rf $DIR2/$tdir/striped"
1628 test_33_run "directory unlink" "rm -rf $DIR2/$tdir"
1630 local async_commit_count=$(do_nodes $nodes \
1631 "lctl get_param -n mdt.*.async_commit_count" | calc_sum)
1632 echo "CoS count $async_commit_count"
1633 (( async_commit_count == 0 )) || error "CoS triggerred"
1635 run_test 33e "independent transactions shouldn't trigger COS"
1637 # End commit on sharing tests
1639 get_ost_lock_timeouts() {
1640 local nodes=${1:-$(comma_list $(osts_nodes))}
1642 local locks=$(do_nodes $nodes \
1643 "lctl get_param -n ldlm.namespaces.filter-*.lock_timeouts" | calc_sum)
1651 do_nodes $(comma_list $(osts_nodes)) \
1652 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1653 for i in $(seq $OSTCOUNT); do
1654 wait_osc_import_ready client ost$i
1659 remote_ost_nodsh && skip "remote OST with nodsh" && return
1663 trap cleanup_34 EXIT RETURN
1664 for OPER in notimeout timeout ; do
1665 rm $DIR1/$tfile 2>/dev/null
1666 lock_in=$(get_ost_lock_timeouts)
1667 if [ $OPER == "timeout" ] ; then
1668 for j in `seq $OSTCOUNT`; do
1669 #define OBD_FAIL_PTLRPC_HPREQ_TIMEOUT 0x511
1670 do_facet ost$j lctl set_param fail_loc=0x511
1672 echo lock should expire
1674 for j in `seq $OSTCOUNT`; do
1675 #define OBD_FAIL_PTLRPC_HPREQ_NOTIMEOUT 0x512
1676 do_facet ost$j lctl set_param fail_loc=0x512
1678 echo lock should not expire
1680 echo writing on client1
1681 dd if=/dev/zero of=$DIR1/$tfile count=100 conv=notrunc > /dev/null 2>&1
1683 echo reading on client2
1684 dd of=/dev/null if=$DIR2/$tfile > /dev/null 2>&1
1685 # wait for a lock timeout
1687 lock_out=$(get_ost_lock_timeouts)
1688 if [ $OPER == "timeout" ] ; then
1689 if [ $lock_in == $lock_out ]; then
1690 error "no lock timeout happened"
1695 if [ $lock_in != $lock_out ]; then
1696 error "lock timeout happened"
1704 run_test 34 "no lock timeout under IO"
1706 test_35() { # bug 17645
1709 gen=$(lctl get_param mdc.$FSNAME-MDT*-mdc-*.import | grep generation |
1710 awk '/generation/{print $2}')
1712 generation[count]=$g
1716 test_mkdir $MOUNT1/$tdir
1717 cancel_lru_locks mdc
1719 # Let's initiate -EINTR situation by setting fail_loc and take
1720 # write lock on same file from same client. This will not cause
1721 # bl_ast yet as lock is already in local cache.
1722 #define OBD_FAIL_LDLM_INTR_CP_AST 0x317
1723 do_facet client "lctl set_param fail_loc=0x80000317"
1724 local timeout=$(do_facet $SINGLEMDS lctl get_param -n timeout)
1725 let timeout=timeout*3
1727 while test $nr -lt 10; do
1728 log "Race attempt $nr"
1729 local blk1=$(lctl get_param -n ldlm.services.ldlm_cbd.stats |
1730 awk '/ldlm_bl_callback/ { print $2 }')
1731 test "x$blk1" = "x" && blk1=0
1732 createmany -o $MOUNT2/$tdir/a 4000 &
1736 # Let's make conflict and bl_ast
1737 ls -la $MOUNT1/$tdir > /dev/null &
1740 log "Wait for $pid1 $pid2 for $timeout sec..."
1742 kill -9 $pid1 $pid2 > /dev/null 2>&1
1744 local blk2=$(lctl get_param -n ldlm.services.ldlm_cbd.stats |
1745 awk '/ldlm_bl_callback/ { print $2 }')
1746 test "x$blk2" = "x" && blk2=0
1747 test $blk2 -gt $blk1 && break
1748 rm -fr $MOUNT1/$tdir
1749 cancel_lru_locks mdc
1752 do_facet client "lctl set_param fail_loc=0x0"
1753 df -h $MOUNT1 $MOUNT2
1755 gen=$(lctl get_param mdc.$FSNAME-MDT*-mdc-*.import | grep generation |
1756 awk '/generation/{print $2}')
1758 if ! test "$g" -eq "${generation[count]}"; then
1759 list=$(lctl list_param mdc.$FSNAME-MDT*-mdc-*.import)
1761 for imp in $list; do
1762 if [ $c = $count ]; then
1767 imp=$(echo "$imp" | awk -F"." '{print $2}')
1768 error "Eviction happened on import $imp"
1773 run_test 35 "-EINTR cp_ast vs. bl_ast race does not evict client"
1775 test_36() { #bug 16417
1780 test_mkdir $DIR1/$tdir
1781 $LFS setstripe -c -1 $DIR1/$tdir
1784 let SIZE_B=SIZE*1024*1024
1785 sync; sleep 2; sync # wait for delete thread
1786 wait_mds_ost_sync || error "wait_mds_ost_sync failed"
1787 wait_destroy_complete || error "wait_destroy_complete failed"
1789 while [ $i -le 10 ]; do
1790 lctl mark "start test - cycle ($i)"
1791 local before=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1792 dd if=/dev/zero of=$DIR1/$tdir/$tfile bs=1M count=$SIZE ||
1793 error "dd $DIR1/$tdir/$tfile ${SIZE}MB failed"
1794 sync # sync data from client cache
1795 sync_all_data # sync data from server cache (delayed allocation)
1797 local after_dd=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1798 multiop_bg_pause $DIR2/$tdir/$tfile O_r${SIZE_B}c || return 3
1800 rm -f $DIR1/$tdir/$tfile
1801 kill -USR1 $read_pid
1803 sync; sleep 2; sync # Ensure new statfs
1804 wait_delete_completed
1805 local after=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1806 echo "*** cycle($i) *** before($before) after_dd($after_dd)" \
1808 # this free space! not used
1809 (( $after_dd <= $after)) ||
1810 error "space leaked after_dd:$after_dd > after:$after"
1814 run_test 36 "handle ESTALE/open-unlink correctly"
1816 test_37() { # bug 18695
1817 test_mkdir $DIR1/$tdir
1818 multiop_bg_pause $DIR1/$tdir D_c || return 1
1820 # create large directory (32kB seems enough from e2fsck, ~= 1000 files)
1821 createmany -m $DIR2/$tdir/f 10000
1822 # set mtime/atime backward
1823 touch -t 198001010000 $DIR2/$tdir
1824 kill -USR1 $MULTIPID
1825 nr_files=`lfs find $DIR1/$tdir -type f | wc -l`
1826 [ $nr_files -eq 10000 ] || error "$nr_files != 10000 truncated directory?"
1829 run_test 37 "check i_size is not updated for directory on close (bug 18695) =============="
1831 # this should be set to past
1832 TEST_39_MTIME=`date -d "1 year ago" +%s`
1836 local client1=${CLIENT1:-`hostname`}
1837 local client2=${CLIENT2:-`hostname`}
1839 do_node $client1 "touch $DIR1/$tfile"
1841 do_node $client1 "touch -m -d @$TEST_39_MTIME $DIR1/$tfile"
1842 local mtime1=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1843 [ "$mtime1" = $TEST_39_MTIME ] || \
1844 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
1846 local d1=`do_node $client1 date +%s`
1847 do_node $client1 'echo hello >> '$DIR1/$tfile
1848 local d2=`do_node $client1 date +%s`
1850 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1851 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
1852 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
1854 do_node $client1 "mv $DIR1/$tfile $DIR1/$tfile-1"
1856 for (( i=0; i < 2; i++ )) ; do
1857 local mtime3=`do_node $client2 "stat -c %Y $DIR1/$tfile-1"`
1858 [ "$mtime2" = "$mtime3" ] || \
1859 error "mtime ($mtime2) changed (to $mtime3) on rename"
1861 cancel_lru_locks osc
1862 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1865 run_test 39a "file mtime does not change after rename"
1868 local client1=${CLIENT1:-`hostname`}
1869 local client2=${CLIENT2:-`hostname`}
1873 local mtime1=`stat -c %Y $DIR1/$tfile`
1874 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1877 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
1879 for (( i=0; i < 2; i++ )) ; do
1880 local mtime3=`stat -c %Y $DIR1/$tfile`
1881 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1883 [ "$mtime3" = "$mtime4" ] || \
1884 error "different mtime on clients: $mtime3, $mtime4"
1885 [ "$mtime3" = $TEST_39_MTIME ] || \
1886 error "lost mtime: $mtime3, should be $TEST_39_MTIME"
1888 cancel_lru_locks osc
1889 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1892 run_test 39b "file mtime the same on clients with/out lock"
1895 local client1=${CLIENT1:-`hostname`}
1896 local client2=${CLIENT2:-`hostname`}
1898 echo hello > $DIR1/$tfile
1900 local mtime1=`stat -c %Y $DIR1/$tfile`
1901 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1902 [ "$mtime1" = "$mtime2" ] || \
1903 error "create: different mtime on clients: $mtime1, $mtime2"
1906 $TRUNCATE $DIR1/$tfile 1
1908 for (( i=0; i < 2; i++ )) ; do
1909 local mtime3=`stat -c %Y $DIR1/$tfile`
1910 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1912 [ "$mtime3" = "$mtime4" ] || \
1913 error "different mtime on clients: $mtime3, $mtime4"
1914 [ "$mtime3" -gt $mtime2 ] || \
1915 error "truncate did not update mtime: $mtime2, $mtime3"
1917 cancel_lru_locks osc
1918 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1921 run_test 39c "check truncate mtime update ======================"
1923 test_39d() { # LU-7310
1925 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
1927 local mtime1=$(stat -c %Y $DIR2/$tfile)
1928 [ "$mtime1" = $TEST_39_MTIME ] ||
1929 error "mtime: $mtime1, should be $TEST_39_MTIME"
1932 # define OBD_FAIL_OSC_NO_GRANT 0x411
1933 $LCTL set_param fail_loc=0x411
1935 local d1=$(date +%s)
1936 echo hello >> $DIR1/$tfile
1937 local d2=$(date +%s)
1939 $LCTL set_param fail_loc=0
1941 cancel_lru_locks $OSC
1943 local mtime2=$(stat -c %Y $DIR2/$tfile)
1944 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] ||
1945 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
1947 run_test 39d "sync write should update mtime"
1950 # how long 40-47 take with specific delay
1957 # for pdo testing, we must cancel MDT-MDT locks as well as client locks to
1958 # avoid unexpected delays due to previous tests
1960 cancel_lru_locks mdc
1961 do_nodes $(comma_list $(mdts_nodes)) \
1962 $LCTL set_param -n ldlm.namespaces.*mdt*.lru_size=clear
1963 do_nodes $(comma_list $(mdts_nodes)) \
1964 $LCTL get_param ldlm.namespaces.*mdt*.lock_unused_count \
1965 ldlm.namespaces.*mdt*.lock_count | grep -v '=0'
1968 # check that pid exists hence second operation wasn't blocked by first one
1969 # if it is so then there is no conflict, return 0
1970 # else second operation is conflicting with first one, return 1
1971 check_pdo_conflict() {
1974 pdo_sched # to ensure OP1 is finished on client if OP2 is blocked by OP1
1975 if [[ `ps --pid $pid | wc -l` == 1 ]]; then
1985 # test 40: check non-blocking operations
1987 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1989 mkdir_on_mdt0 $DIR2/$tdir
1991 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1992 do_nodes $(comma_list $(mdts_nodes)) \
1993 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1994 mkdir $DIR1/$tdir/$tfile &
1996 touch $DIR2/$tdir/$tfile-2
1997 check_pdo_conflict $PID1 || error "create is blocked"
1998 mkdir $DIR2/$tdir/$tfile-3
1999 check_pdo_conflict $PID1 || error "mkdir is blocked"
2000 link $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-4
2001 check_pdo_conflict $PID1 || error "link is blocked"
2002 mv $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-5
2003 check_pdo_conflict $PID1 || error "rename is blocked"
2004 stat $DIR2/$tdir/$tfile-3 $DIR2/$tdir/$tfile-4 > /dev/null
2005 check_pdo_conflict $PID1 || error "getattr is blocked"
2006 rm $DIR2/$tdir/$tfile-4 $DIR2/$tdir/$tfile-5
2007 rmdir $DIR2/$tdir/$tfile-3
2008 check_pdo_conflict $PID1 || error "unlink is blocked"
2010 # all operations above shouldn't wait the first one
2011 check_pdo_conflict $PID1 || error "parallel operation is blocked"
2012 do_nodes $(comma_list $(mdts_nodes)) \
2013 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2018 run_test 40a "pdirops: create vs others =============="
2021 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2023 mkdir_on_mdt0 $DIR2/$tdir
2025 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2026 do_nodes $(comma_list $(mdts_nodes)) \
2027 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2028 touch $DIR1/$tdir/$tfile &
2031 touch $DIR2/$tdir/$tfile-2
2032 check_pdo_conflict $PID1 || error "create is blocked"
2033 mkdir $DIR2/$tdir/$tfile-3
2034 check_pdo_conflict $PID1 || error "mkdir is blocked"
2035 link $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-4
2036 check_pdo_conflict $PID1 || error "link is blocked"
2037 mv $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-5
2038 check_pdo_conflict $PID1 || error "rename is blocked"
2039 stat $DIR2/$tdir/$tfile-3 $DIR2/$tdir/$tfile-4 > /dev/null
2040 check_pdo_conflict $PID1 || error "getattr is blocked"
2041 rm $DIR2/$tdir/$tfile-4 $DIR2/$tdir/$tfile-5
2042 rmdir $DIR2/$tdir/$tfile-3
2043 check_pdo_conflict $PID1 || error "unlink is blocked"
2044 # all operations above shouldn't wait the first one
2046 check_pdo_conflict $PID1 || error "parallel operation is blocked"
2047 do_nodes $(comma_list $(mdts_nodes)) \
2048 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2053 run_test 40b "pdirops: open|create and others =============="
2056 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2058 mkdir_on_mdt0 $DIR2/$tdir
2060 touch $DIR1/$tdir/$tfile
2061 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2062 do_nodes $(comma_list $(mdts_nodes)) \
2063 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2064 link $DIR1/$tdir/$tfile $DIR1/$tdir/$tfile-0 &
2067 touch $DIR2/$tdir/$tfile-2
2068 check_pdo_conflict $PID1 || error "create is blocked"
2069 mkdir $DIR2/$tdir/$tfile-3
2070 check_pdo_conflict $PID1 || error "mkdir is blocked"
2071 link $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-4
2072 check_pdo_conflict $PID1 || error "link is blocked"
2073 mv $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-5
2074 check_pdo_conflict $PID1 || error "rename is blocked"
2075 stat $DIR2/$tdir/$tfile-3 $DIR2/$tdir/$tfile-4 > /dev/null
2076 check_pdo_conflict $PID1 || error "getattr is blocked"
2077 rm $DIR2/$tdir/$tfile-4 $DIR2/$tdir/$tfile-5
2078 rmdir $DIR2/$tdir/$tfile-3
2079 check_pdo_conflict $PID1 || error "unlink is blocked"
2081 # all operations above shouldn't wait the first one
2082 check_pdo_conflict $PID1 || error "parallel operation is blocked"
2083 do_nodes $(comma_list $(mdts_nodes)) \
2084 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2089 run_test 40c "pdirops: link and others =============="
2092 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2094 mkdir_on_mdt0 $DIR2/$tdir
2096 touch $DIR1/$tdir/$tfile
2097 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2098 do_nodes $(comma_list $(mdts_nodes)) \
2099 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2100 rm $DIR1/$tdir/$tfile &
2103 touch $DIR2/$tdir/$tfile-2
2104 check_pdo_conflict $PID1 || error "create is blocked"
2105 mkdir $DIR2/$tdir/$tfile-3
2106 check_pdo_conflict $PID1 || error "mkdir is blocked"
2107 link $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-4
2108 check_pdo_conflict $PID1 || error "link is blocked"
2109 mv $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-5
2110 check_pdo_conflict $PID1 || error "rename is blocked"
2111 stat $DIR2/$tdir/$tfile-3 $DIR2/$tdir/$tfile-4 > /dev/null
2112 check_pdo_conflict $PID1 || error "getattr is blocked"
2113 rm $DIR2/$tdir/$tfile-4 $DIR2/$tdir/$tfile-5
2114 rmdir $DIR2/$tdir/$tfile-3
2115 check_pdo_conflict $PID1 || error "unlink is blocked"
2117 # all operations above shouldn't wait the first one
2118 check_pdo_conflict $PID1 || error "parallel operation is blocked"
2119 do_nodes $(comma_list $(mdts_nodes)) \
2120 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2124 run_test 40d "pdirops: unlink and others =============="
2127 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2129 mkdir_on_mdt0 $DIR2/$tdir
2131 touch $DIR1/$tdir/$tfile
2132 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2133 do_nodes $(comma_list $(mdts_nodes)) \
2134 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2135 mv $DIR1/$tdir/$tfile $DIR1/$tdir/$tfile-0 &
2138 touch $DIR2/$tdir/$tfile-2
2139 check_pdo_conflict $PID1 || error "create is blocked"
2140 mkdir $DIR2/$tdir/$tfile-3
2141 check_pdo_conflict $PID1 || error "mkdir is blocked"
2142 link $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-4
2143 check_pdo_conflict $PID1 || error "link is blocked"
2144 stat $DIR2/$tdir/$tfile-3 $DIR2/$tdir/$tfile-4 > /dev/null
2145 check_pdo_conflict $PID1 || error "getattr is blocked"
2146 rm $DIR2/$tdir/$tfile-4 $DIR2/$tdir/$tfile-2
2147 rmdir $DIR2/$tdir/$tfile-3
2148 check_pdo_conflict $PID1 || error "unlink is blocked"
2150 # all operations above shouldn't wait the first one
2151 check_pdo_conflict $PID1 || error "parallel operation is blocked"
2152 do_nodes $(comma_list $(mdts_nodes)) \
2153 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2158 run_test 40e "pdirops: rename and others =============="
2160 # test 41: create blocking operations
2163 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2164 do_nodes $(comma_list $(mdts_nodes)) \
2165 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2166 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
2168 mkdir $DIR2/$tfile &
2170 do_nodes $(comma_list $(mdts_nodes)) \
2171 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2172 check_pdo_conflict $PID1 && { wait $PID1; echo "mkdir isn't blocked"; }
2173 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
2177 run_test 41a "pdirops: create vs mkdir =============="
2181 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2182 do_nodes $(comma_list $(mdts_nodes)) \
2183 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2184 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
2186 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2188 do_nodes $(comma_list $(mdts_nodes)) \
2189 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2190 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2191 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
2195 run_test 41b "pdirops: create vs create =============="
2199 touch $DIR1/$tfile-2
2200 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2201 do_nodes $(comma_list $(mdts_nodes)) \
2202 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2203 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
2205 link $DIR2/$tfile-2 $DIR2/$tfile &
2207 do_nodes $(comma_list $(mdts_nodes)) \
2208 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2209 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2210 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
2214 run_test 41c "pdirops: create vs link =============="
2218 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2219 do_nodes $(comma_list $(mdts_nodes)) \
2220 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2221 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
2225 do_nodes $(comma_list $(mdts_nodes)) \
2226 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2227 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2228 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
2232 run_test 41d "pdirops: create vs unlink =============="
2236 touch $DIR1/$tfile-2
2237 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2238 do_nodes $(comma_list $(mdts_nodes)) \
2239 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2240 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
2242 mv $DIR2/$tfile-2 $DIR2/$tfile &
2244 do_nodes $(comma_list $(mdts_nodes)) \
2245 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2246 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2247 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2251 run_test 41e "pdirops: create and rename (tgt) =============="
2255 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2256 do_nodes $(comma_list $(mdts_nodes)) \
2257 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2258 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
2260 mv $DIR2/$tfile $DIR2/$tfile-2 &
2262 do_nodes $(comma_list $(mdts_nodes)) \
2263 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2264 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2265 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2269 run_test 41f "pdirops: create and rename (src) =============="
2273 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2274 do_nodes $(comma_list $(mdts_nodes)) \
2275 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2276 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
2278 stat $DIR2/$tfile > /dev/null &
2280 do_nodes $(comma_list $(mdts_nodes)) \
2281 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2282 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2283 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
2287 run_test 41g "pdirops: create vs getattr =============="
2291 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2292 do_nodes $(comma_list $(mdts_nodes)) \
2293 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2294 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
2296 ls -lia $DIR2/ > /dev/null &
2298 do_nodes $(comma_list $(mdts_nodes)) \
2299 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2300 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2305 run_test 41h "pdirops: create vs readdir =============="
2312 do_nodes $(comma_list $(mdts_nodes)) \
2313 "lctl set_param -n fail_loc=${fail_loc} || true" &>/dev/null
2315 $MULTIOP $DIR1/$tfile oO_CREAT:O_EXCL:c 2>/dev/null &
2318 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c 2>/dev/null &
2321 if ! wait $PID1 && ! wait $PID2; then
2322 echo "Both creates failed (1 should fail, 1 should succeed)"
2324 elif wait $PID1 && wait $PID2; then
2325 echo "Both creates succeeded (1 should fail, 1 should succeed)"
2330 do_nodes $(comma_list $(mdts_nodes)) \
2331 "lctl set_param -n fail_loc=0x0 || true" &>/dev/null
2338 (( $MDS1_VERSION >= $(version_code 2.13.56) )) ||
2339 skip "Need MDS version newer than 2.13.56"
2342 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN 0x169
2343 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN2 0x16a
2344 for fail_loc in "0x80000169" "0x8000016a"; do
2345 echo "Begin 100 tests with fail_loc=$fail_loc"
2347 for i in {1..100}; do
2349 msg=$(sub_test_41i "$fail_loc") ||
2350 { echo; error "iter=$i : $msg"; }
2355 run_test 41i "reint_open: create vs create"
2358 # test 42: unlink and blocking operations
2361 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2362 do_nodes $(comma_list $(mdts_nodes)) \
2363 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2364 mkdir $DIR1/$tfile &
2366 mkdir $DIR2/$tfile &
2368 do_nodes $(comma_list $(mdts_nodes)) \
2369 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2370 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2371 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
2375 run_test 42a "pdirops: mkdir vs mkdir =============="
2379 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2380 do_nodes $(comma_list $(mdts_nodes)) \
2381 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2382 mkdir $DIR1/$tfile &
2384 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2386 do_nodes $(comma_list $(mdts_nodes)) \
2387 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2388 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2389 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
2393 run_test 42b "pdirops: mkdir vs create =============="
2397 touch $DIR1/$tfile-2
2398 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2399 do_nodes $(comma_list $(mdts_nodes)) \
2400 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2401 mkdir $DIR1/$tfile &
2403 link $DIR2/$tfile-2 $DIR2/$tfile &
2405 do_nodes $(comma_list $(mdts_nodes)) \
2406 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2407 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2408 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
2412 run_test 42c "pdirops: mkdir vs link =============="
2416 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2417 do_nodes $(comma_list $(mdts_nodes)) \
2418 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2419 mkdir $DIR1/$tfile &
2421 rmdir $DIR2/$tfile &
2423 do_nodes $(comma_list $(mdts_nodes)) \
2424 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2425 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2426 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
2430 run_test 42d "pdirops: mkdir vs unlink =============="
2434 touch $DIR1/$tfile-2
2435 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2436 do_nodes $(comma_list $(mdts_nodes)) \
2437 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2438 mkdir $DIR1/$tfile &
2440 mv -T $DIR2/$tfile-2 $DIR2/$tfile &
2442 do_nodes $(comma_list $(mdts_nodes)) \
2443 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2444 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2445 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
2449 run_test 42e "pdirops: mkdir and rename (tgt) =============="
2453 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2454 do_nodes $(comma_list $(mdts_nodes)) \
2455 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2456 mkdir $DIR1/$tfile &
2458 mv $DIR2/$tfile $DIR2/$tfile-2 &
2460 do_nodes $(comma_list $(mdts_nodes)) \
2461 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2462 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2463 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2467 run_test 42f "pdirops: mkdir and rename (src) =============="
2470 mkdir_on_mdt0 $DIR1/$tdir
2472 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2473 do_nodes $(comma_list $(mdts_nodes)) \
2474 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2475 mkdir $DIR1/$tdir/$tfile &
2477 stat $DIR2/$tdir/$tfile > /dev/null &
2479 do_nodes $(comma_list $(mdts_nodes)) \
2480 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2481 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2482 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
2485 run_test 42g "pdirops: mkdir vs getattr =============="
2489 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2490 do_nodes $(comma_list $(mdts_nodes)) \
2491 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2492 mkdir $DIR1/$tfile &
2494 ls -lia $DIR2/ > /dev/null &
2496 do_nodes $(comma_list $(mdts_nodes)) \
2497 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2498 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2503 run_test 42h "pdirops: mkdir vs readdir =============="
2505 # test 43: rmdir,mkdir won't return -EEXIST
2507 for i in {1..1000}; do
2508 mkdir $DIR1/$tdir || error "mkdir $tdir failed"
2509 rmdir $DIR2/$tdir || error "rmdir $tdir failed"
2513 run_test 43a "rmdir,mkdir doesn't return -EEXIST =============="
2518 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2519 do_nodes $(comma_list $(mdts_nodes)) \
2520 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2523 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2525 do_nodes $(comma_list $(mdts_nodes)) \
2526 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2527 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2528 wait $PID2 ; [ $? -eq 0 ] || error "create must succeed"
2532 run_test 43b "pdirops: unlink vs create =============="
2537 touch $DIR1/$tfile-2
2538 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2539 do_nodes $(comma_list $(mdts_nodes)) \
2540 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2543 link $DIR2/$tfile-2 $DIR2/$tfile &
2545 do_nodes $(comma_list $(mdts_nodes)) \
2546 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2547 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2548 wait $PID2 ; [ $? -eq 0 ] || error "link must succeed"
2552 run_test 43c "pdirops: unlink vs link =============="
2557 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2558 do_nodes $(comma_list $(mdts_nodes)) \
2559 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2564 do_nodes $(comma_list $(mdts_nodes)) \
2565 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2566 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2567 wait $PID2 ; [ $? -ne 0 ] || error "unlink must fail"
2571 run_test 43d "pdirops: unlink vs unlink =============="
2576 touch $DIR1/$tfile-2
2577 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2578 do_nodes $(comma_list $(mdts_nodes)) \
2579 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2582 mv -u $DIR2/$tfile-2 $DIR2/$tfile &
2584 do_nodes $(comma_list $(mdts_nodes)) \
2585 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2586 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2587 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2591 run_test 43e "pdirops: unlink and rename (tgt) =============="
2596 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2597 do_nodes $(comma_list $(mdts_nodes)) \
2598 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2601 mv $DIR2/$tfile $DIR2/$tfile-2 &
2603 do_nodes $(comma_list $(mdts_nodes)) \
2604 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2605 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2606 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
2610 run_test 43f "pdirops: unlink and rename (src) =============="
2615 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2616 do_nodes $(comma_list $(mdts_nodes)) \
2617 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2620 stat $DIR2/$tfile > /dev/null &
2622 do_nodes $(comma_list $(mdts_nodes)) \
2623 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2624 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2625 wait $PID2 ; [ $? -ne 0 ] || error "stat must fail"
2629 run_test 43g "pdirops: unlink vs getattr =============="
2634 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2635 do_nodes $(comma_list $(mdts_nodes)) \
2636 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2639 ls -lia $DIR2/ > /dev/null &
2641 do_nodes $(comma_list $(mdts_nodes)) \
2642 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2643 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2648 run_test 43h "pdirops: unlink vs readdir =============="
2651 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2654 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2655 do_nodes $(comma_list $(mdts_nodes)) \
2656 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2659 $LFS mkdir -i 1 $DIR2/$tfile &
2661 do_nodes $(comma_list $(mdts_nodes)) \
2662 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2663 check_pdo_conflict $PID1 &&
2664 { wait $PID1; error "remote mkdir isn't blocked"; }
2665 wait $PID2 ; [ $? -eq 0 ] || error "remote mkdir must succeed"
2669 run_test 43i "pdirops: unlink vs remote mkdir"
2672 [[ $MDS1_VERSION -lt $(version_code 2.13.52) ]] &&
2673 skip "Need MDS version newer than 2.13.52"
2675 mkdir_on_mdt0 $DIR1/$tdir
2676 for i in {1..100}; do
2677 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_CREATE_RACE 0x167
2678 do_nodes $(comma_list $(mdts_nodes)) \
2679 "lctl set_param -n fail_loc=0x80000167 2>/dev/null ||
2682 mkdir $DIR1/$tdir/sub &
2684 mkdir $DIR2/$tdir/sub && ((OK++))
2685 wait $PID1 && ((OK++))
2686 (( OK == 1 )) || error "exactly one mkdir should succeed"
2688 rmdir $DIR1/$tdir/sub || error "rmdir failed"
2692 run_test 43j "racy mkdir return EEXIST =============="
2699 # We test in a separate directory to be able to unblock server thread in
2700 # cfs_race() if LCK_PW is taken on the parent by mdt_reint_unlink.
2701 test_mkdir $DIR2/$tdir
2702 touch $DIR2/$tdir/$tfile
2705 do_nodes $(comma_list $(mdts_nodes)) \
2706 "lctl set_param -n fail_loc=${fail_loc} || true" &>/dev/null
2707 echo content > $DIR1/$tdir/$tfile & PID1=$!
2709 multiop $DIR2/$tdir/$tfile u & PID2=$!
2713 echo -n "overwriting $tfile should succeed (err=$ret); "; }
2716 echo -n "unlinking $tfile should succeed (err=$ret);"; }
2719 do_nodes $(comma_list $(mdts_nodes)) \
2720 "lctl set_param -n fail_loc=0x0 || true" &>/dev/null
2727 (( $MDS1_VERSION >= $(version_code 2.13.56) )) ||
2728 skip "Need MDS version newer than 2.13.56"
2731 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN 0x169
2732 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN2 0x16a
2733 for fail_loc in "0x80000169" "0x8000016a"; do
2734 echo "Begin 100 tests with fail_loc=$fail_loc"
2736 for i in {1..100}; do
2738 msg=$(sub_test_43k "$fail_loc") ||
2739 { echo; error "iter=$i : $msg"; }
2749 run_test 43k "unlink vs create"
2751 # test 44: rename tgt and blocking operations
2754 touch $DIR1/$tfile-2
2755 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2756 do_nodes $(comma_list $(mdts_nodes)) \
2757 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2758 mv $DIR1/$tfile-2 $DIR1/$tfile &
2760 mkdir $DIR2/$tfile &
2762 do_nodes $(comma_list $(mdts_nodes)) \
2763 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2764 check_pdo_conflict $PID1 && { wait $PID1; date;error "mkdir isn't blocked"; }
2765 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
2770 run_test 44a "pdirops: rename tgt vs mkdir =============="
2774 touch $DIR1/$tfile-2
2775 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2776 do_nodes $(comma_list $(mdts_nodes)) \
2777 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2778 mv $DIR1/$tfile-2 $DIR1/$tfile &
2780 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2782 do_nodes $(comma_list $(mdts_nodes)) \
2783 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2784 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2785 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
2789 run_test 44b "pdirops: rename tgt vs create =============="
2793 touch $DIR1/$tfile-2
2794 touch $DIR1/$tfile-3
2795 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2796 do_nodes $(comma_list $(mdts_nodes)) \
2797 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2798 mv $DIR1/$tfile-2 $DIR1/$tfile &
2800 link $DIR2/$tfile-3 $DIR2/$tfile &
2802 do_nodes $(comma_list $(mdts_nodes)) \
2803 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2804 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2805 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
2809 run_test 44c "pdirops: rename tgt vs link =============="
2813 touch $DIR1/$tfile-2
2814 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2815 do_nodes $(comma_list $(mdts_nodes)) \
2816 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2817 mv $DIR1/$tfile-2 $DIR1/$tfile &
2821 do_nodes $(comma_list $(mdts_nodes)) \
2822 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2823 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2824 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
2828 run_test 44d "pdirops: rename tgt vs unlink =============="
2833 touch $DIR1/$tfile-2
2834 touch $DIR1/$tfile-3
2835 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2836 do_nodes $(comma_list $(mdts_nodes)) \
2837 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2838 mv $DIR1/$tfile-2 $DIR1/$tfile &
2840 mv $DIR2/$tfile-3 $DIR2/$tfile &
2842 do_nodes $(comma_list $(mdts_nodes)) \
2843 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2844 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2845 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2849 run_test 44e "pdirops: rename tgt and rename (tgt) =============="
2853 touch $DIR1/$tfile-2
2854 touch $DIR1/$tfile-3
2855 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2856 do_nodes $(comma_list $(mdts_nodes)) \
2857 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2858 mv $DIR1/$tfile-2 $DIR1/$tfile &
2860 mv $DIR2/$tfile $DIR2/$tfile-3 &
2862 do_nodes $(comma_list $(mdts_nodes)) \
2863 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2864 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2865 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2869 run_test 44f "pdirops: rename tgt and rename (src) =============="
2873 touch $DIR1/$tfile-2
2874 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2875 do_nodes $(comma_list $(mdts_nodes)) \
2876 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2877 mv $DIR1/$tfile-2 $DIR1/$tfile &
2879 stat $DIR2/$tfile > /dev/null &
2881 do_nodes $(comma_list $(mdts_nodes)) \
2882 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2883 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2884 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
2888 run_test 44g "pdirops: rename tgt vs getattr =============="
2892 touch $DIR1/$tfile-2
2893 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2894 do_nodes $(comma_list $(mdts_nodes)) \
2895 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2896 mv $DIR1/$tfile-2 $DIR1/$tfile &
2898 ls -lia $DIR2/ > /dev/null &
2900 do_nodes $(comma_list $(mdts_nodes)) \
2901 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2902 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2907 run_test 44h "pdirops: rename tgt vs readdir =============="
2909 # test 44: rename tgt and blocking operations
2911 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2913 touch $DIR1/$tfile-2
2914 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2915 do_nodes $(comma_list $(mdts_nodes)) \
2916 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2917 mv $DIR1/$tfile-2 $DIR1/$tfile &
2919 $LFS mkdir -i 1 $DIR2/$tfile &
2921 do_nodes $(comma_list $(mdts_nodes)) \
2922 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2923 check_pdo_conflict $PID1 && { wait $PID1;
2924 error "remote mkdir isn't blocked"; }
2925 wait $PID2 ; [ $? -ne 0 ] || error "remote mkdir must fail"
2929 run_test 44i "pdirops: rename tgt vs remote mkdir"
2931 # test 45: rename,mkdir doesn't fail with -EEXIST
2933 for i in {1..1000}; do
2934 mkdir $DIR1/$tdir || error "mkdir $tdir failed"
2935 mrename $DIR2/$tdir $DIR2/$tdir.$i > /dev/null ||
2936 error "mrename to $tdir.$i failed"
2941 run_test 45a "rename,mkdir doesn't return -EEXIST =============="
2946 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2947 do_nodes $(comma_list $(mdts_nodes)) \
2948 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2949 mv $DIR1/$tfile $DIR1/$tfile-2 &
2951 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2953 do_nodes $(comma_list $(mdts_nodes)) \
2954 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2955 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2956 wait $PID2 ; [ $? -eq 0 ] || error "create must succeed"
2960 run_test 45b "pdirops: rename src vs create =============="
2965 touch $DIR1/$tfile-3
2966 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2967 do_nodes $(comma_list $(mdts_nodes)) \
2968 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2969 mv $DIR1/$tfile $DIR1/$tfile-2 &
2971 link $DIR2/$tfile-3 $DIR2/$tfile &
2973 do_nodes $(comma_list $(mdts_nodes)) \
2974 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2975 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2976 wait $PID2 ; [ $? -eq 0 ] || error "link must succeed"
2980 run_test 45c "pdirops: rename src vs link =============="
2985 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2986 do_nodes $(comma_list $(mdts_nodes)) \
2987 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2988 mv $DIR1/$tfile $DIR1/$tfile-2 &
2992 do_nodes $(comma_list $(mdts_nodes)) \
2993 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2994 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2995 wait $PID2 ; [ $? -ne 0 ] || error "unlink must fail"
2999 run_test 45d "pdirops: rename src vs unlink =============="
3004 touch $DIR1/$tfile-3
3005 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
3006 do_nodes $(comma_list $(mdts_nodes)) \
3007 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
3008 mv $DIR1/$tfile $DIR1/$tfile-2 &
3010 mv $DIR2/$tfile-3 $DIR2/$tfile &
3012 do_nodes $(comma_list $(mdts_nodes)) \
3013 "lctl set_param -n fail_loc=0 2>/dev/null || true"
3014 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
3015 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
3019 run_test 45e "pdirops: rename src and rename (tgt) =============="
3024 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
3025 do_nodes $(comma_list $(mdts_nodes)) \
3026 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
3027 mv $DIR1/$tfile $DIR1/$tfile-2 &
3029 mv $DIR2/$tfile $DIR2/$tfile-3 &
3031 do_nodes $(comma_list $(mdts_nodes)) \
3032 "lctl set_param -n fail_loc=0 2>/dev/null || true"
3033 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
3034 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
3038 run_test 45f "pdirops: rename src and rename (src) =============="
3043 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
3044 do_nodes $(comma_list $(mdts_nodes)) \
3045 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
3046 mv $DIR1/$tfile $DIR1/$tfile-2 &
3048 stat $DIR2/$tfile > /dev/null &
3050 do_nodes $(comma_list $(mdts_nodes)) \
3051 "lctl set_param -n fail_loc=0 2>/dev/null || true"
3052 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
3053 wait $PID2 ; [ $? -ne 0 ] || error "stat must fail"
3057 run_test 45g "pdirops: rename src vs getattr =============="
3062 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
3063 do_nodes $(comma_list $(mdts_nodes)) \
3064 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
3065 mv $DIR1/$tfile $DIR1/$tfile-2 &
3067 ls -lia $DIR2/ > /dev/null &
3068 do_nodes $(comma_list $(mdts_nodes)) \
3069 "lctl set_param -n fail_loc=0 2>/dev/null || true"
3070 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
3075 run_test 45h "pdirops: unlink vs readdir =============="
3078 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3081 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
3082 do_nodes $(comma_list $(mdts_nodes)) \
3083 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
3084 mv $DIR1/$tfile $DIR1/$tfile-2 &
3086 $LFS mkdir -i 1 $DIR2/$tfile &
3088 do_nodes $(comma_list $(mdts_nodes)) \
3089 "lctl set_param -n fail_loc=0 2>/dev/null || true"
3090 check_pdo_conflict $PID1 && { wait $PID1;
3091 error "create remote dir isn't blocked"; }
3092 wait $PID2 ; [ $? -eq 0 ] || error "create remote dir must succeed"
3096 run_test 45i "pdirops: rename src vs remote mkdir"
3103 # We test in a sparate directory to be able to unblock server thread in
3104 # cfs_race if LCK_PW is taken on the parent by mdt_reint_rename.
3105 test_mkdir $DIR2/$tdir
3106 echo file1 > $DIR2/$tdir/$tfile
3107 echo file2 > $DIR2/$tdir/$tfile-2
3110 do_nodes $(comma_list $(mdts_nodes)) \
3111 "lctl set_param -n fail_loc=${fail_loc} || true" &>/dev/null
3113 cat $DIR1/$tdir/$tfile >/dev/null &
3116 mrename $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile > /dev/null &
3120 { ret=$?; echo -n "cat $tfile should succeed (err=$ret); "; }
3123 echo -n "mrename $tfile-2 to $tfile failed (err=$ret);"; }
3126 do_nodes $(comma_list $(mdts_nodes)) \
3127 "lctl set_param -n fail_loc=0x0 || true" &>/dev/null
3134 (( $MDS1_VERSION >= $(version_code 2.13.56) )) ||
3135 skip "Need MDS version newer than 2.13.56"
3138 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN 0x169
3139 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN2 0x16a
3140 for fail_loc in "0x80000169" "0x8000016a"; do
3141 echo "Begin 100 tests with fail_loc=$fail_loc"
3143 for i in {1..100}; do
3145 msg=$(sub_test_45j "$fail_loc") ||
3146 { echo; error "iter=$i : $msg"; }
3151 run_test 45j "read vs rename =============="
3153 # test 46: link and blocking operations
3156 touch $DIR1/$tfile-2
3157 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
3158 do_nodes $(comma_list $(mdts_nodes)) \
3159 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
3160 link $DIR1/$tfile-2 $DIR1/$tfile &
3162 mkdir $DIR2/$tfile &
3164 do_nodes $(comma_list $(mdts_nodes)) \
3165 "lctl set_param -n fail_loc=0 2>/dev/null || true"
3166 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
3167 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
3171 run_test 46a "pdirops: link vs mkdir =============="
3175 touch $DIR1/$tfile-2
3176 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
3177 do_nodes $(comma_list $(mdts_nodes)) \
3178 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
3179 link $DIR1/$tfile-2 $DIR1/$tfile &
3181 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
3183 do_nodes $(comma_list $(mdts_nodes)) \
3184 "lctl set_param -n fail_loc=0 2>/dev/null || true"
3185 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
3186 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
3190 run_test 46b "pdirops: link vs create =============="
3194 touch $DIR1/$tfile-2
3195 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
3196 do_nodes $(comma_list $(mdts_nodes)) \
3197 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
3198 link $DIR1/$tfile-2 $DIR1/$tfile &
3200 link $DIR2/$tfile $DIR2/$tfile &
3202 do_nodes $(comma_list $(mdts_nodes)) \
3203 "lctl set_param -n fail_loc=0 2>/dev/null || true"
3204 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
3205 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
3209 run_test 46c "pdirops: link vs link =============="
3213 touch $DIR1/$tfile-2
3214 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
3215 do_nodes $(comma_list $(mdts_nodes)) \
3216 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
3217 link $DIR1/$tfile-2 $DIR1/$tfile &
3221 do_nodes $(comma_list $(mdts_nodes)) \
3222 "lctl set_param -n fail_loc=0 2>/dev/null || true"
3223 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
3224 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
3228 run_test 46d "pdirops: link vs unlink =============="
3232 touch $DIR1/$tfile-2
3233 touch $DIR1/$tfile-3
3234 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
3235 do_nodes $(comma_list $(mdts_nodes)) \
3236 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
3237 link $DIR1/$tfile-2 $DIR1/$tfile &
3239 mv $DIR2/$tfile-3 $DIR2/$tfile &
3241 do_nodes $(comma_list $(mdts_nodes)) \
3242 "lctl set_param -n fail_loc=0 2>/dev/null || true"
3243 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
3244 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
3248 run_test 46e "pdirops: link and rename (tgt) =============="
3252 touch $DIR1/$tfile-2
3253 touch $DIR1/$tfile-3
3254 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
3255 do_nodes $(comma_list $(mdts_nodes)) \
3256 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
3257 link $DIR1/$tfile-2 $DIR1/$tfile &
3259 mv $DIR2/$tfile $DIR2/$tfile-3 &
3261 do_nodes $(comma_list $(mdts_nodes)) \
3262 "lctl set_param -n fail_loc=0 2>/dev/null || true"
3263 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
3264 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
3268 run_test 46f "pdirops: link and rename (src) =============="
3272 touch $DIR1/$tfile-2
3273 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
3274 do_nodes $(comma_list $(mdts_nodes)) \
3275 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
3276 link $DIR1/$tfile-2 $DIR1/$tfile &
3278 stat $DIR2/$tfile > /dev/null &
3280 do_nodes $(comma_list $(mdts_nodes)) \
3281 "lctl set_param -n fail_loc=0 2>/dev/null || true"
3282 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
3283 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
3287 run_test 46g "pdirops: link vs getattr =============="
3291 touch $DIR1/$tfile-2
3292 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
3293 do_nodes $(comma_list $(mdts_nodes)) \
3294 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
3295 link $DIR1/$tfile-2 $DIR1/$tfile &
3297 ls -lia $DIR2/ > /dev/null &
3299 do_nodes $(comma_list $(mdts_nodes)) \
3300 "lctl set_param -n fail_loc=0 2>/dev/null || true"
3301 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
3306 run_test 46h "pdirops: link vs readdir =============="
3309 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3311 touch $DIR1/$tfile-2
3312 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
3313 do_nodes $(comma_list $(mdts_nodes)) \
3314 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
3315 link $DIR1/$tfile-2 $DIR1/$tfile &
3317 $LFS mkdir -i 1 $DIR2/$tfile &
3319 do_nodes $(comma_list $(mdts_nodes)) \
3320 "lctl set_param -n fail_loc=0 2>/dev/null || true"
3321 check_pdo_conflict $PID1 && { wait $PID1;
3322 error "remote mkdir isn't blocked"; }
3323 wait $PID2 ; [ $? -ne 0 ] || error "remote mkdir must fail"
3327 run_test 46i "pdirops: link vs remote mkdir"
3329 # test 47: remote mkdir and blocking operations
3331 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
3332 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3334 do_nodes $(comma_list $(mdts_nodes)) \
3335 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
3336 $LFS mkdir -i 1 $DIR1/$tfile &
3338 mkdir $DIR2/$tfile &
3340 do_nodes $(comma_list $(mdts_nodes)) \
3341 "lctl set_param -n fail_loc=0 2>/dev/null || true"
3342 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
3343 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
3347 run_test 47a "pdirops: remote mkdir vs mkdir"
3350 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
3351 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3353 do_nodes $(comma_list $(mdts_nodes)) \
3354 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
3355 $LFS mkdir -i 1 $DIR1/$tfile &
3357 sleep 1 # please do not remove this sleep, see LU-10754
3358 multiop $DIR2/$tfile oO_CREAT:O_EXCL:c &
3360 do_nodes $(comma_list $(mdts_nodes)) \
3361 "lctl set_param -n fail_loc=0 2>/dev/null || true"
3362 check_pdo_conflict $PID1 && { wait $PID1;
3363 error "create isn't blocked"; }
3364 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
3368 run_test 47b "pdirops: remote mkdir vs create"
3371 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3373 touch $DIR1/$tfile-2
3374 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
3375 do_nodes $(comma_list $(mdts_nodes)) \
3376 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
3377 $LFS mkdir -i 1 $DIR1/$tfile &
3379 link $DIR2/$tfile-2 $DIR2/$tfile &
3381 do_nodes $(comma_list $(mdts_nodes)) \
3382 "lctl set_param -n fail_loc=0 2>/dev/null || true"
3383 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
3384 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
3388 run_test 47c "pdirops: remote mkdir vs link"
3391 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3393 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
3394 do_nodes $(comma_list $(mdts_nodes)) \
3395 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
3396 $LFS mkdir -i 1 $DIR1/$tfile &
3398 rmdir $DIR2/$tfile &
3400 do_nodes $(comma_list $(mdts_nodes)) \
3401 "lctl set_param -n fail_loc=0 2>/dev/null || true"
3402 check_pdo_conflict $PID1 && { wait $PID1;
3403 error "unlink isn't blocked"; }
3404 wait $PID2 ; [ $? -eq 0 ] || error "rmdir must succeed"
3408 run_test 47d "pdirops: remote mkdir vs unlink"
3411 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3413 touch $DIR1/$tfile-2
3414 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
3415 do_nodes $(comma_list $(mdts_nodes)) \
3416 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
3417 $LFS mkdir -i 1 $DIR1/$tfile &
3419 mv -T $DIR2/$tfile-2 $DIR2/$tfile &
3421 do_nodes $(comma_list $(mdts_nodes)) \
3422 "lctl set_param -n fail_loc=0 2>/dev/null || true"
3423 check_pdo_conflict $PID1 && { wait $PID1;
3424 error "rename isn't blocked"; }
3425 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
3429 run_test 47e "pdirops: remote mkdir and rename (tgt)"
3432 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3434 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
3435 do_nodes $(comma_list $(mdts_nodes)) \
3436 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
3437 $LFS mkdir -i 1 $DIR1/$tfile &
3439 mv $DIR2/$tfile $DIR2/$tfile-2 &
3441 do_nodes $(comma_list $(mdts_nodes)) \
3442 "lctl set_param -n fail_loc=0 2>/dev/null || true"
3443 check_pdo_conflict $PID1 && { wait $PID1;
3444 error "rename isn't blocked"; }
3445 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
3449 run_test 47f "pdirops: remote mkdir and rename (src)"
3452 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3456 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
3457 do_nodes $(comma_list $(mdts_nodes)) \
3458 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
3459 $LFS mkdir -i 1 $DIR1/$tfile &
3461 stat $DIR2/$tfile > /dev/null &
3463 do_nodes $(comma_list $(mdts_nodes)) \
3464 "lctl set_param -n fail_loc=0 2>/dev/null || true"
3465 check_pdo_conflict $PID1 && { wait $PID1;
3466 error "getattr isn't blocked"; }
3467 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
3471 run_test 47g "pdirops: remote mkdir vs getattr"
3475 dd if=/dev/zero of=$DIR1/$tfile bs=1K count=10
3476 #define OBD_FAIL_OSC_CP_ENQ_RACE 0x410
3477 do_facet client "lctl set_param fail_loc=0x410"
3478 $TRUNCATE $DIR2/$tfile $trunc_size
3479 do_facet client "lctl set_param fail_loc=0x0"
3481 size=`stat -c %s $DIR2/$tfile`
3482 [ $size -eq $trunc_size ] || error "wrong size"
3484 run_test 50 "osc lvb attrs: enqueue vs. CP AST =============="
3488 local origfile=/etc/hosts
3490 filesize=$(stat -c %s $origfile)
3492 # create an empty file
3493 $MCREATE $DIR1/$tfile || error "can't create $DIR1/$tfile"
3494 # cache layout lock on both mount point
3495 stat $DIR1/$tfile > /dev/null || error "stat $DIR1/$tfile failed"
3496 stat $DIR2/$tfile > /dev/null || error "stat $DIR2/$tfile failed"
3498 # open and sleep 2 seconds then read
3499 $MULTIOP $DIR2/$tfile o_2r${filesize}c &
3503 # create the layout of testing file
3504 dd if=$origfile of=$DIR1/$tfile conv=notrunc > /dev/null ||
3505 error "dd $DIR1/$tfile failed"
3507 # MULTIOP proc should be able to read enough bytes and exit
3508 for ((i = 0; i < 6; i++)); do
3510 kill -0 $pid || break
3512 kill -0 $pid 2> /dev/null && error "multiop is still there"
3513 cmp $origfile $DIR2/$tfile || error "$origfile and $DIR2/$tfile differs"
3517 run_test 51a "layout lock: refresh layout should work"
3520 (( $MDS1_VERSION >= $(version_code 2.3.59) )) ||
3521 skip "Need MDS version at least 2.3.59"
3523 local tmpfile=`mktemp`
3525 $LFS setstripe -E 1m -S 1M -c 1 -E -1 -c 1 $DIR1/$tfile ||
3526 error "Create $DIR1/$tfile failed"
3528 dd if=/dev/zero of=$DIR1/$tfile bs=1k count=1 conv=notrunc ||
3529 error "dd $DIR1/$tfile failed"
3531 # delay glimpse so that layout has changed when glimpse finish
3532 #define OBD_FAIL_GLIMPSE_DELAY 0x1404
3533 $LCTL set_param fail_loc=0x1404 fail_val=4
3534 stat -c %s $DIR2/$tfile |tee $tmpfile &
3538 # extend layout of testing file
3539 dd if=/dev/zero of=$DIR1/$tfile bs=1M count=1 seek=2 conv=notrunc ||
3540 error "dd $DIR1/$tfile failed"
3543 local fsize=$(cat $tmpfile)
3545 [ x$fsize = x3145728 ] || error "file size is $fsize, should be 3145728"
3547 rm -f $DIR1/$tfile $tmpfile
3549 run_test 51b "layout lock: glimpse should be able to restart if layout changed"
3552 [ $OSTCOUNT -ge 2 ] || { skip "needs >= 2 osts"; return; }
3554 # set default layout to have 1 stripe
3556 $LFS setstripe -c 1 $DIR1/$tdir
3558 # create a file with empty layout
3559 $MCREATE $DIR1/$tdir/$tfile ||
3560 error "$MCREATE $DIR1/$tdir/$tfile failed"
3562 #define OBD_FAIL_MDS_LL_BLOCK 0x172
3563 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x172
3565 # change the layout of testing file
3566 echo "Setting layout to have $OSTCOUNT stripes ..."
3567 $LFS setstripe -c $OSTCOUNT $DIR1/$tdir/$tfile &
3571 # write something to the file, it should be blocked on fetching layout
3572 dd if=/dev/zero of=$DIR2/$tdir/$tfile bs=1k count=1 conv=notrunc
3573 local stripe_count=$($LFS getstripe -c $DIR2/$tdir/$tfile)
3576 # lod_qos.c::min_stripe_count() allows setstripe with a default stripe
3577 # count to succeed with only 3/4 of the number of stripes (rounded up),
3578 # so creating striped files does not fail if an OST is offline or full
3579 [ $stripe_count -ge $((OSTCOUNT - $OSTCOUNT / 4)) ] ||
3580 error "bad layout: getstripe -c $stripe_count < $OSTCOUNT * 3/4"
3584 run_test 51c "layout lock: IT_LAYOUT blocked and correct layout can be returned"
3587 dd if=/dev/zero of=/$DIR1/$tfile bs=1M count=1
3588 cancel_lru_locks mdc
3590 # open should grant LAYOUT lock, mmap and read will install pages
3591 $MULTIOP $DIR1/$tfile oO_RDWR:SMR_Uc &
3595 # rss before revoking
3596 local br=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
3597 echo "Before revoking layout lock: $br KB mapped"
3599 # cancel layout lock manually
3600 cancel_lru_locks mdc
3602 # rss after revoking
3603 local ar=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
3606 wait $PID || error "wait PID $PID failed"
3608 [ $ar -eq 0 ] || error "rss before: $br, after $ar, some pages remained"
3610 run_test 51d "layout lock: losing layout lock should clean up memory map region"
3613 (( $MDS1_VERSION >= $(version_code 2.13.54.148) )) ||
3614 skip "MDS version must be at least 2.13.54.148"
3618 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eW_E+eUc &
3622 $LFS getstripe $DIR2/$tfile
3624 wait $pid || error "multiop failed"
3626 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
3630 $LFS getstripe $DIR2/$tfile
3632 wait $pid || error "multiop failed"
3634 run_test 51e "lfs getstripe does not break leases, part 2"
3638 echo "==> rename vs getattr vs setxattr should not deadlock"
3639 mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed"
3641 do_facet mds1 $LCTL set_param fail_loc=$1
3643 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 &
3651 setfattr -n user.attr1 -v value1 $DIR2/d1 || error "(2) setfattr failed"
3652 wait $PID1 || error "(3) mv failed"
3653 wait $PID2 || error "(4) stat failed"
3660 echo "==> rename vs getattr vs open vs getattr should not deadlock"
3661 mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed"
3663 do_facet mds1 $LCTL set_param fail_loc=$1
3665 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 &
3673 $MULTIOP $DIR2/d1/d2 Oc &
3677 stat $DIR/d1 || error "(2) stat failed"
3679 wait $PID1 || error "(3) mv failed"
3680 wait $PID2 || error "(4) stat failed"
3681 wait $PID3 && error "(5) multiop failed"
3687 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
3688 save_lustre_params client "llite.*.xattr_cache" > $p
3689 lctl set_param llite.*.xattr_cache 1 ||
3690 { skip "xattr cache is not supported"; return 0; }
3692 #define OBD_FAIL_MDS_RENAME 0x153
3693 #define OBD_FAIL_MDS_RENAME2 0x154
3694 test_54_part1 0x80000153 || error 10
3695 test_54_part1 0x80000154 || error 11
3696 test_54_part2 0x80000153 || error 12
3697 test_54_part2 0x80000154 || error 13
3699 restore_lustre_params < $p
3702 run_test 54 "rename locking"
3705 mkdir_on_mdt0 $DIR/$tdir
3706 mkdir -p $DIR/$tdir/d1/d2 $DIR/$tdir/d3 || error "(1) mkdir failed"
3708 #define OBD_FAIL_MDS_RENAME4 0x156
3709 do_facet mds1 $LCTL set_param fail_loc=0x80000156
3711 mv -T $DIR/$tdir/d1/d2 $DIR/$tdir/d3/d2 &
3715 rm -r $DIR2/$tdir/d3
3716 wait $PID1 && error "(2) mv succeeded"
3720 run_test 55a "rename vs unlink target dir"
3724 mkdir_on_mdt0 $DIR/$tdir
3725 mkdir -p $DIR/$tdir/d1/d2 $DIR/$tdir/d3 || error "(1) mkdir failed"
3727 #define OBD_FAIL_MDS_RENAME4 0x156
3728 do_facet mds1 $LCTL set_param fail_loc=0x80000156
3730 mv -T $DIR/$tdir/d1/d2 $DIR/$tdir/d3/d2 &
3734 rm -r $DIR2/$tdir/d1
3735 wait $PID1 && error "(2) mv succeeded"
3739 run_test 55b "rename vs unlink source dir"
3743 mkdir_on_mdt0 $DIR/$tdir
3744 mkdir -p $DIR/$tdir/d1/d2 $DIR/$tdir/d3 || error "(1) mkdir failed"
3746 #define OBD_FAIL_MDS_RENAME4 0x156
3747 do_facet mds1 $LCTL set_param fail_loc=0x156
3749 mv -T $DIR/$tdir/d1/d2 $DIR/$tdir/d3/d2 &
3753 # while rename is sleeping, open and remove d3
3754 $MULTIOP $DIR2/$tdir/d3 D_c &
3757 rm -rf $DIR2/$tdir/d3
3760 # while rename is sleeping 2nd time, close d3
3762 wait $PID2 || error "(3) multiop failed"
3764 wait $PID1 && error "(2) mv succeeded"
3768 run_test 55c "rename vs unlink orphan target dir"
3772 mkdir_on_mdt0 $DIR/$tdir
3776 #define OBD_FAIL_MDS_RENAME3 0x155
3777 do_facet mds1 $LCTL set_param fail_loc=0x155
3778 mv $DIR/$tdir/f1 $DIR/$tdir/$tdir &
3782 # while rename is sleeping, create $tdir, but as a directory
3783 mkdir -p $DIR2/$tdir/$tdir || error "(1) mkdir failed"
3785 # link in reverse locking order
3786 ln $DIR2/$tdir/f1 $DIR2/$tdir/$tdir/f1 || error "(2) ln failed"
3788 ! wait $PID1 || error "(3) mv succeeded"
3791 run_test 55d "rename file vs link"
3795 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
3797 # set children remote to parent, to trigger bfl
3798 $LFS mkdir -i0 -c2 $DIR/$tdir || error "fail to create striped dir"
3799 $LFS mkdir -i1 $DIR/$tdir/A || error "fail to create subdir A"
3800 $LFS mkdir -i1 $DIR/$tdir/B || error "fail to create subdir B"
3802 #define OBD_FAIL_MDS_RENAME3 0x155
3803 # before any lock GOT, racing for parent locks
3804 do_facet mds1 $LCTL set_param fail_loc=0x155
3805 stack_trap "do_facet mds1 $LCTL set_param fail_loc=0x0"
3807 mv -T $DIR/$tdir/A $DIR/$tdir/B &
3809 mv -T $DIR2/$tdir/B $DIR2/$tdir/A &
3813 wait $PID1; STATUS1=$?
3814 wait $PID2; STATUS2=$?
3816 SUCCESS=$(( !$STATUS1 + !$STATUS2 ))
3817 (( SUCCESS >= 1 )) ||
3818 error "expect at least one succ, actual: $SUCCESS"
3820 echo "We survived after AB/BA race test"
3822 run_test 55e "rename race AB/BA under the same parent dir"
3826 mkdir_on_mdt0 $DIR/$tdir
3827 mkdir -p $DIR/$tdir/P1/A $DIR/$tdir/P2/B
3829 #define OBD_FAIL_MDS_RENAME3 0x155
3830 # before any lock GOT, racing for parent locks
3831 do_facet mds1 $LCTL set_param fail_loc=0x155
3832 stack_trap "do_facet mds1 $LCTL set_param fail_loc=0x0"
3834 mv -T $DIR/$tdir/P1/A $DIR/$tdir/P2/B &
3836 mv -T $DIR2/$tdir/P2/B $DIR2/$tdir/P1/A &
3840 wait $PID1; STATUS1=$?
3841 wait $PID2; STATUS2=$?
3843 SUCCESS=$(( !$STATUS1 + !$STATUS2 ))
3844 (( SUCCESS >= 1 )) ||
3845 error "expect at least one succ, actual: $SUCCESS"
3847 echo "We survived after P1A_P2B/P2B_P1A race test"
3849 run_test 55f "rename: (P1/A -> P2/B) race with (P2/B -> P1/A)"
3853 mkdir_on_mdt0 $DIR/$tdir
3854 mkdir -p $DIR/$tdir/a1/a2/a3/a4
3855 mkdir -p $DIR/$tdir/b1/b2/b3/b4
3857 local param_file=$TMP/$tfile-params
3858 save_lustre_params mds1 \
3859 "mdt.*.enable_rename_trylock" > $param_file
3860 do_facet mds1 $LCTL set_param mdt.*.enable_rename_trylock=1
3861 #define OBD_FAIL_MDS_RENAME3 0x155
3862 do_facet mds1 $LCTL set_param fail_loc=0x155
3863 stack_trap "do_facet mds1 $LCTL set_param fail_loc=0x0"
3865 mv $DIR/$tdir/a1/a2 $DIR/$tdir/b1/b2/b3/b4/ &
3867 mv $DIR2/$tdir/b1/b2 $DIR2/$tdir/a1/a2/a3/a4/ &
3871 wait $PID1; STATUS1=$?
3872 wait $PID2; STATUS2=$?
3874 SUCCESS=$(( !$STATUS1 + !$STATUS2 ))
3875 (( SUCCESS >= 1 )) ||
3876 error "expect at least one succ, actual: $SUCCESS"
3877 [[ -e $DIR/$tdir/b1/b2/b3/b4/a2 ]] ||
3878 [[ -e $DIR2/$tdir/a1/a2/a3/a4/b2 ]] ||
3879 error "expect at least one valid dir"
3881 restore_lustre_params <$param_file
3883 echo "We survived race with trylock test"
3885 run_test 55g "rename: race with trylock"
3888 $LFS setstripe -c 1 $MOUNT/$tfile || error "creating $MOUNT/$tfile"
3889 stack_trap "rm -f $MOUNT/$tfile"
3890 echo "run_llverdev $MOUNT/$tfile -p -s $((16000000)) -c 4k"
3891 run_llverdev $MOUNT/$tfile -p -s $((16000000)) -c 4k ||
3892 error "llverdev failed with rc=$?"
3894 run_test 56a "test llverdev with single large stripe"
3897 $LFS setstripe -C 2000 $MOUNT/$tfile || error "creating $MOUNT/$tfile"
3898 stack_trap "rm -f $MOUNT/$tfile"
3899 echo "run_llverdev $MOUNT/$tfile -p -s $((16000000 * OSTCOUNT)) -c 4k"
3900 run_llverdev $MOUNT/$tfile -p -s $((16000000 * OSTCOUNT)) -c 4k ||
3901 error "llverdev failed with rc=$?"
3903 run_test 56b "test llverdev and partial verify of wide stripe file"
3906 [ $MDS1_VERSION -lt $(version_code 2.3.0) ] &&
3907 skip "MDS version must be >= 2.3.0"
3910 test_mkdir $DIR1/$tdir
3911 file1=$DIR1/$tdir/file
3912 file2=$DIR2/$tdir/file
3914 echo orig > $file2 || error "Could not create $file2"
3915 version=$($LFS data_version $file1)
3918 echo append >> $file2 || error "Could not append to $file2"
3919 version2=$($LFS data_version $file1)
3920 [ "$version" != "$version2" ] ||
3921 error "append did not change data version: $version"
3924 echo overwrite > $file2 || error "Could not overwrite $file2"
3925 version3=$($LFS data_version $file1)
3926 [ "$version2" != "$version3" ] ||
3927 error "overwrite did not change data version: $version2"
3929 # Truncate before EOF
3930 $TRUNCATE $file2 3 || error "Could not truncate $file2"
3931 version4=$($LFS data_version $file1)
3932 [ "$version3" != "$version4" ] ||
3933 error "truncate did not change data version: $version3"
3935 # Truncate after EOF
3936 $TRUNCATE $file2 123456 || error "Could not truncate $file2"
3937 version5=$($LFS data_version $file1)
3938 [ "$version4" != "$version5" ] ||
3939 error "truncate did not change data version: $version4"
3941 # Chmod do not change version
3942 chmod 400 $file2 || error "Could not chmod 400 $file2"
3943 version6=$($LFS data_version $file1)
3944 [ "$version5" == "$version6" ] ||
3945 error "chmod should not change data version: $version5 != $version6"
3947 # Chown do not change version
3948 chown $RUNAS_ID $file2 || error "Could not chown $RUNAS_ID $file2"
3949 version7=$($LFS data_version $file1)
3950 [ "$version5" == "$version7" ] ||
3951 error "chown should not change data version: $version5 != $version7"
3953 run_test 60 "Verify data_version behaviour"
3956 local test_dir=$tdir/test_dir
3958 mkdir -p $DIR1/$tdir
3959 if [ $MDSCOUNT -ge 2 ]; then
3961 $LFS mkdir -i $MDTIDX $DIR1/$test_dir ||
3962 error "Create remote directory failed"
3964 mkdir -p $DIR1/$test_dir
3966 cd $DIR2/$test_dir || error "cd directory failed"
3967 rm -rf $DIR1/$test_dir || error "unlink directory failed"
3969 cd $DIR2/$tdir || error "exit directory"
3971 run_test 70a "cd directory && rm directory"
3973 test_70b() { # LU-2781
3975 mkdir -p $DIR1/$tdir
3977 touch $DIR1/$tdir/file
3978 for ((i = 0; i < 32; i++)); do
3979 $LFS rm_entry $DIR1/$tdir/non_existent_dir &>/dev/null
3981 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
3983 touch $DIR1/$tdir/file
3984 $LFS mkdir -i0 $DIR1/$tdir/test_dir
3985 $LFS rm_entry $DIR1/$tdir/test_dir &>/dev/null
3986 rm -rf $DIR1/$tdir/test_dir ||
3987 error "cannot remove directory after rm_entry"
3988 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
3990 run_test 70b "remove files after calling rm_entry"
3993 [[ "$MDS1_VERSION" -lt $(version_code 2.1.6) ]] &&
3994 skip "Need MDS version at least 2.1.6"
3996 # Patch not applied to 2.2 and 2.3 branches
3997 [[ "$MDS1_VERSION" -ge $(version_code 2.2.0) ]] &&
3998 [[ "$MDS1_VERSION" -lt $(version_code 2.4.0) ]] &&
3999 skip "Need MDS version earlier than 2.2.0 or at least 2.4.0"
4001 checkfiemap --test ||
4002 skip "checkfiemap not runnable: $?"
4003 # write data this way: hole - data - hole - data
4004 dd if=/dev/urandom of=$DIR1/$tfile bs=64K seek=1 count=1
4005 [ "$(facet_fstype ost$(($($LFS getstripe -i $DIR1/$tfile) + 1)))" = \
4007 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return 0
4008 dd if=/dev/urandom of=$DIR1/$tfile bs=64K seek=3 count=1
4009 GET_STAT="lctl get_param -n ldlm.services.ldlm_cbd.stats"
4011 local can1=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
4013 checkfiemap $DIR2/$tfile 131072 ||
4014 error "data is not flushed from client"
4015 local can2=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
4018 # common case of "create file, copy file" on a single node
4019 # should not flush data from ost
4020 dd if=/dev/urandom of=$DIR1/$tfile bs=64K seek=1 count=1
4021 dd if=/dev/urandom of=$DIR1/$tfile bs=64K seek=3 count=1
4023 local can3=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
4025 checkfiemap $DIR1/$tfile 131072 ||
4027 local can4=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
4029 [ $can3 -eq $can4 ] || error $((can2-can1)) "cancel RPC occured."
4031 run_test 71a "correct file map just after write operation is finished"
4034 [[ "$MDS1_VERSION" -lt $(version_code 2.1.6) ]] &&
4035 skip "Need MDS version at least 2.1.6"
4037 # Patch not applied to 2.2 and 2.3 branches
4038 [[ "$MDS1_VERSION" -ge $(version_code 2.2.0) ]] &&
4039 [[ "$MDS1_VERSION" -lt $(version_code 2.4.0) ]] &&
4040 skip "Need MDS version earlier than 2.2.0 or at least 2.4.0"
4041 [[ $OSTCOUNT -ge 2 ]] || skip "needs >= 2 OSTs"
4043 checkfiemap --test ||
4044 skip "error $?: checkfiemap failed"
4046 mkdir -p $DIR1/$tdir
4048 $LFS setstripe -c -1 $DIR1/$tdir || error "setstripe failed"
4049 dd if=/dev/urandom of=$DIR1/$tdir/$tfile bs=64K count=1
4050 [ "$(facet_fstype ost$(($($LFS getstripe -i $DIR1/$tdir/$tfile) + 1)))" = \
4052 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return 0
4053 checkfiemap $DIR1/$tdir/$tfile 65536 || error "checkfiemap failed"
4055 run_test 71b "check fiemap support for stripecount > 1"
4057 _check_last_flag_with_filefrag()
4064 echo "check last flag for file with $count extents"
4066 for ((i=0; i<$count; i++)); do
4068 dd if=/dev/zero of=$file bs=4K count=1 seek=$offset 2> /dev/null
4071 filefrag -s -v $file | grep "last" ||
4072 error "test file with $i extents failed"
4078 local file="$DIR1/$tdir/$tfile"
4080 (( $CLIENT_VERSION >= $(version_code 2.15.57) )) ||
4081 skip "Need client version >= 2.15.57"
4082 [ $(facet_fstype ost1) = "ldiskfs" ] ||
4083 skip "support only ldiskfs ost"
4084 filefrag -V | grep wc ||
4085 skip "need whamcloud version of e2fsprogs"
4087 mkdir -p $DIR1/$tdir
4089 # filefrag uses u64[2028] buffer to fetch fiemap. The number of extents
4090 # in the buffer is (8 * 2048 - 32) / 56 = 292. Test file with 291, 292
4092 _check_last_flag_with_filefrag $file 291
4093 _check_last_flag_with_filefrag $file 292
4094 _check_last_flag_with_filefrag $file 293
4096 run_test 71c "check FIEMAP_EXTENT_LAST flag with different extents number"
4098 test_71d() { #LU-17110
4099 checkfiemap --test ||
4100 skip "error $?: checkfiemap failed"
4104 # write data this way: hole - data - hole - data
4105 dd if=/dev/urandom of=$f bs=64K count=1
4106 [[ "$(facet_fstype ost$(($($LFS getstripe -i $f) + 1)))" != "zfs" ]] ||
4107 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
4108 dd if=/dev/urandom of=$f bs=64K seek=2 count=1
4109 dd if=/dev/urandom of=$f bs=64K seek=4 count=1
4110 dd if=/dev/urandom of=$f bs=64K seek=6 count=1 conv=fsync
4111 echo "disk usage: $(du -B1 $f)"
4112 echo "file size: $(du -b $f)"
4114 checkfiemap --corruption_test $f $((4 * 64 *1024)) ||
4115 error "checkfiemap failed"
4117 run_test 71d "fiemap corruption test with fm_extent_count=0"
4120 local p="$TMP/sanityN-$TESTNAME.parameters"
4123 save_lustre_params client "llite.*.xattr_cache" > $p
4124 lctl set_param llite.*.xattr_cache 1 ||
4125 { skip "xattr cache is not supported"; return 0; }
4128 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
4129 error "setfattr1 failed"
4130 getfattr -n user.attr1 $DIR2/$tfile | grep value1 ||
4131 error "getfattr1 failed"
4132 setfattr -n user.attr1 -v value2 $DIR2/$tfile ||
4133 error "setfattr2 failed"
4134 getfattr -n user.attr1 $DIR1/$tfile | grep value2 ||
4135 error "getfattr2 failed"
4137 # check that trusted.link is consistent
4138 tlink1=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
4139 ln $DIR2/$tfile $DIR2/$tfile-2 || error "failed to link"
4140 tlink2=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
4141 echo "$tlink1 $tlink2"
4142 [ "$tlink1" = "$tlink2" ] && error "trusted.link should have changed!"
4146 restore_lustre_params < $p
4149 run_test 72 "getxattr/setxattr cache should be consistent between nodes"
4152 local p="$TMP/sanityN-$TESTNAME.parameters"
4153 save_lustre_params client "llite.*.xattr_cache" > $p
4154 lctl set_param llite.*.xattr_cache 1 ||
4155 { skip "xattr cache is not supported"; return 0; }
4158 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
4159 error "setfattr1 failed"
4160 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr1 failed"
4161 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr2 failed"
4162 clear_stats llite.*.stats
4163 # PR lock should be cached by now on both clients
4164 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr3 failed"
4165 # At least 2 hits for getfattr(0)+getfattr(size)
4166 # There may be more if auditd has a filesystem-related rule enabled
4167 (( $(calc_stats llite.*.stats getxattr_hits) >= 2 )) ||
4168 error "not cached in $DIR1"
4169 clear_stats llite.*.stats
4170 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr4 failed"
4171 # At least 2 hits for getfattr(0)+getfattr(size)
4172 # There may be more if auditd has a filesystem-related rule enabled
4173 (( $(calc_stats llite.*.stats getxattr_hits) >= 2 )) ||
4174 error "not cached in $DIR2"
4177 restore_lustre_params < $p
4180 run_test 73 "getxattr should not cause xattr lock cancellation"
4183 [ "$MDS1_VERSION" -lt $(version_code 2.4.93) ] &&
4184 skip "Need MDS version at least 2.4.93"
4186 dd if=/dev/zero of=$DIR1/$tfile-1 bs=1K count=1
4187 dd if=/dev/zero of=$DIR1/$tfile-2 bs=1K count=1
4188 flocks_test 4 $DIR1/$tfile-1 $DIR2/$tfile-2
4190 run_test 74 "flock deadlock: different mounts =============="
4194 $LFS setstripe -c 2 -S 1m -i 0 $DIR1/$tfile
4195 dd if=/dev/zero of=$DIR1/$tfile bs=1M count=2
4196 cancel_lru_locks osc
4198 dd of=$DIR1/$tfile if=/dev/zero bs=1M count=1 seek=1 conv=notrunc
4201 # define OBD_FAIL_LDLM_ENQUEUE_HANG 0x31d
4202 $LCTL set_param fail_loc=0x31d
4203 stat -c %s $DIR1/$tfile &
4208 # For bad lock error handler we should ASSERT and got kernel panic here
4210 $LCTL set_param fail_loc=0
4212 run_test 75 "osc: upcall after unuse lock==================="
4215 [[ "$MDS1_VERSION" -lt $(version_code 2.5.53) ]] &&
4216 skip "Need MDS version at least 2.5.53"
4218 remote_mds_nodsh && skip "remote MDS with nodsh"
4219 local fcount=$((MDSCOUNT * 256))
4224 nid=$($LCTL list_nids | sed "s/\./\\\./g")
4230 test_mkdir $DIR/$tdir
4232 # drop all open locks and close any cached "open" files on the client
4233 cancel_lru_locks mdc
4235 local open_fids_cmd="$LCTL get_param -n mdt.*.exports.'$nid'.open_files"
4236 local fid_list=($(do_nodes $(comma_list $(mdts_nodes)) $open_fids_cmd))
4237 local already=${#fid_list[@]}
4238 for (( i = 0; i < $already; i++ )) ; do
4239 log "already open[$i]: $($LFS fid2path $DIR2 ${fid_list[i]})"
4242 echo -n "opening files: "
4243 ulimit -n $((fcount + 50))
4244 for ((i = 0; i < $fcount; i++)); do
4245 touch $DIR/$tdir/f_$i
4246 local fd=$(free_fd ${fd_list[i]})
4247 local open_cmd="exec $fd<$DIR/$tdir/f_$i"
4252 (( $i % 32 == 0 )) && echo -n "."
4256 fid_list=($(do_nodes $(comma_list $(mdts_nodes)) $open_fids_cmd))
4258 # Possible errors in openfiles FID list.
4259 # 1. Missing FIDs. Check 1
4260 # 2. Extra FIDs. Check 1
4261 # 3. Duplicated FID. Check 2
4262 # 4. Invalid FIDs. Check 2
4263 # 5. Valid FID, points to some other file. Check 3
4266 [ ${#fid_list[@]} -ne $((fcount + already)) ] &&
4267 error "${#fid_list[@]} != $fcount (+$already old) open files"
4269 echo -n "closing files: "
4270 for (( fd = 0, fid = 0; fd < $fcount; fd++, fid++ )) ; do
4271 local close_cmd="exec ${fd_list[fd]}<&-"
4273 filename=$($LFS fid2path $DIR2 ${fid_list[fid]})
4275 while [[ ! "$filename" =~ "$DIR2/$tdir/f_" ]]; do
4276 echo "skip old open file $filename"
4278 filename=$($LFS fid2path $DIR2 ${fid_list[fid]})
4282 rm --interactive=no $filename
4284 error "Nonexisting fid ${fid_list[fid]} listed."
4285 (( $fd % 32 == 0 )) && echo -n "."
4290 ls_op=$(ls $DIR2/$tdir | wc -l)
4292 error "Some openfiles are missing in lproc output"
4296 run_test 76 "Verify MDT open_files listing"
4300 local dir=$DIR/$tdir
4302 local create_as="$2"
4304 mkdir $dir || error "mkdir $dir failed"
4305 $LFS setstripe -c $OSTCOUNT $dir || error "setstripe to $dir failed"
4308 if [[ -n "$create_as" ]]; then
4309 do_nodes $CLIENTS $create_as "touch $dir/nrs_r_\$HOSTNAME;" ||
4310 error "touch failed for $dir/nrs_r_*"
4311 do_nodes $CLIENTS $create_as touch "$dir/nrs_w_\$HOSTNAME" ||
4312 error "touch failed for $dir/nrs_w_*"
4313 do_nodes $CLIENTS $create_as "chmod 777 $dir/nrs_*_\$HOSTNAME;" ||
4314 error "chmod failed for $dir/nrs_*"
4317 do_nodes $CLIENTS $myRUNAS \
4318 dd if=/dev/zero of="$dir/nrs_r_\$HOSTNAME" bs=1M count=$n ||
4319 error "dd at 0 on client failed (1)"
4321 do_nodes $CLIENTS $myRUNAS \
4323 for ((i = 0; i < $n; i++)); do
4324 dd if=/dev/zero of=$dir/nrs_w_\$HOSTNAME bs=1M \
4325 seek=\\\$i count=1 conv=notrunc &
4326 pids_w[\\\$i]=\\\$!;
4329 for ((i = 0; i < $n; i++)); do
4330 wait \\\${pids_w[\\\$i]};
4332 [ \\\$newrc -gt \\\$rc_w ] && rc_w=\\\$newrc;
4336 do_nodes $CLIENTS sync;
4337 cancel_lru_locks osc
4339 do_nodes $CLIENTS $myRUNAS \
4341 for ((i = 0; i < $n; i++)); do
4342 dd if=$dir/nrs_r_\$HOSTNAME bs=1M of=/dev/null \
4343 seek=\\\$i count=1 &
4344 pids_r[\\\$i]=\\\$!;
4347 for ((i = 0; i < $n; i++)); do
4348 wait \\\${pids_r[\\\$i]};
4350 [ \\\$newrc -gt \\\$rc_r ] && rc_r=\\\$newrc;
4354 cancel_lru_locks osc
4356 wait $pid_w || error "dd (write) failed (2)"
4357 wait $pid_r || error "dd (read) failed (3)"
4358 rm -rvf $dir || error "rm -rf $dir failed"
4361 test_77a() { #LU-3266
4364 oss=$(comma_list $(osts_nodes))
4365 do_nodes $oss lctl set_param ost.OSS.*.nrs_policies="fifo" ||
4367 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
4368 [[ $rc -ne 0 ]] && error "failed to set fifo policy"
4373 run_test 77a "check FIFO NRS policy"
4375 test_77b() { #LU-3266
4378 oss=$(comma_list $(osts_nodes))
4380 do_nodes $oss lctl set_param ost.OSS.*.nrs_policies="crrn" \
4381 ost.OSS.*.nrs_crrn_quantum=1 || rc=$?
4382 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
4383 [[ $rc -ne 0 ]] && error "failed to set crrn_quantum to 1"
4385 echo "policy: crr-n, crrn_quantum 1"
4388 do_nodes $oss lctl set_param \
4389 ost.OSS.*.nrs_crrn_quantum=64 || rc=$?
4390 [[ $rc -ne 0 ]] && error "failed to set crrn_quantum to 64"
4392 echo "policy: crr-n, crrn_quantum 64"
4396 do_nodes $oss lctl set_param \
4397 ost.OSS.ost_io.nrs_policies="fifo" || rc=$?
4398 [[ $rc -ne 0 ]] && error "failed to set fifo policy"
4401 run_test 77b "check CRR-N NRS policy"
4406 oss=$(comma_list $(osts_nodes))
4408 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies=$policy \
4409 ost.OSS.*.nrs_"$policy"_quantum=1 \
4410 ost.OSS.*.nrs_"$policy"_offset_type="physical" \
4411 ost.OSS.*.nrs_"$policy"_supported="reads" || return $?
4413 echo "policy: $policy, ${policy}_quantum 1, ${policy}_offset_type " \
4414 "physical, ${policy}_supported reads"
4417 do_nodes $oss lctl set_param \
4418 ost.OSS.*.nrs_${policy}_supported="writes" \
4419 ost.OSS.*.nrs_${policy}_quantum=64 || return $?
4421 echo "policy: $policy, ${policy}_quantum 64, ${policy}_offset_type " \
4422 "physical, ${policy}_supported writes"
4425 do_nodes $oss lctl set_param \
4426 ost.OSS.*.nrs_${policy}_supported="reads_and_writes" \
4427 ost.OSS.*.nrs_${policy}_offset_type="logical" || return $?
4428 echo "policy: $policy, ${policy}_quantum 64, ${policy}_offset_type " \
4429 "logical, ${policy}_supported reads_and_writes"
4433 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo" ||
4438 test_77c() { #LU-3266
4440 orr_trr "orr" || rc=$?
4441 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
4442 [[ $rc -ne 0 ]] && error "orr_trr failed rc:$rc"
4445 run_test 77c "check ORR NRS policy"
4447 test_77d() { #LU-3266
4449 orr_trr "trr" || rc=$?
4450 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
4451 [[ $rc -ne 0 ]] && error "orr_trr failed rc:$rc"
4454 run_test 77d "check TRR nrs policy"
4461 do_facet $facet lctl set_param \
4462 ost.OSS.ost_io.nrs_tbf_rule="$*"
4464 error "failed to run operate '$*' on TBF rules"
4467 cleanup_tbf_verify()
4471 echo "cleanup_tbf $DIR/$tdir"
4474 wait_delete_completed
4479 local dir=$DIR/$tdir
4480 local client1=${CLIENT1:-$(hostname)}
4482 local create_as="$4"
4484 local np=$(check_cpt_number ost1)
4485 [ $np -gt 0 ] || error "CPU partitions should not be $np."
4486 echo "cpu_npartitions on ost1 is $np"
4488 mkdir $dir || error "mkdir $dir failed"
4489 $LFS setstripe -c 1 -i 0 $dir || error "setstripe to $dir failed"
4492 if [[ -n "$create_as" ]]; then
4493 $create_as touch $dir/tbf
4497 trap cleanup_tbf_verify EXIT
4498 echo "Limited write rate: $1, read rate: $2"
4499 echo "Verify the write rate is under TBF control"
4500 local start=$SECONDS
4501 do_node $client1 $myRUNAS dd if=/dev/zero of=$dir/tbf \
4502 bs=1M count=100 oflag=direct 2>&1
4503 local runtime=$((SECONDS - start + 1))
4504 local rate=$(bc <<< "scale=6; 100 / $runtime")
4505 echo "Write runtime is $runtime s, speed is $rate IOPS"
4507 # verify the write rate does not exceed TBF rate limit
4508 [ $(bc <<< "$rate < 1.1 * $np * $1") -eq 1 ] ||
4509 error "The write rate ($rate) exceeds 110% of rate limit ($1 * $np)"
4511 cancel_lru_locks osc
4513 echo "Verify the read rate is under TBF control"
4515 do_node $client1 $myRUNAS dd if=$dir/tbf of=/dev/null \
4516 bs=1M count=100 iflag=direct 2>&1
4517 runtime=$((SECONDS - start + 1))
4518 rate=$(bc <<< "scale=6; 100 / $runtime")
4519 echo "Read runtime is $runtime s, speed is $rate IOPS"
4521 # verify the read rate does not exceed TBF rate limit
4522 [ $(bc <<< "$rate < 1.1 * $np * $2") -eq 1 ] ||
4523 error "The read rate ($rate) exceeds 110% of rate limit ($2 * $np)"
4525 cancel_lru_locks osc
4526 cleanup_tbf_verify || error "rm -rf $dir failed"
4532 oss=$(comma_list $(osts_nodes))
4534 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid" ||
4536 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
4537 [[ $rc -ne 0 ]] && error "failed to set TBF NID policy"
4541 if [ "$OST1_VERSION" -ge $(version_code 2.8.54) ]; then
4546 # Only operate rules on ost1 since OSTs might run on the same OSS
4548 tbf_rule_operate ost1 "start\ localhost\ ${idis}{0@lo}\ ${rateis}1000"
4549 local address=$(comma_list "$(host_nids_address $CLIENTS $NETTYPE)")
4550 local client_nids=$(nids_list $address "\\")
4551 tbf_rule_operate ost1 "start\ clients\ ${idis}{$client_nids}\ ${rateis}100"
4552 tbf_rule_operate ost1 "start\ others\ ${idis}{*.*.*.*@$NETTYPE}\ ${rateis}50"
4556 tbf_rule_operate ost1 "change\ localhost\ ${rateis}1001"
4557 tbf_rule_operate ost1 "change\ clients\ ${rateis}101"
4558 tbf_rule_operate ost1 "change\ others\ ${rateis}51"
4562 tbf_rule_operate ost1 "stop\ localhost"
4563 tbf_rule_operate ost1 "stop\ clients"
4564 tbf_rule_operate ost1 "stop\ others"
4567 # Cleanup the TBF policy
4568 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
4569 [ $? -ne 0 ] && error "failed to set policy back to fifo"
4573 run_test 77e "check TBF NID nrs policy"
4578 oss=$(comma_list $(osts_nodes))
4580 do_nodes $oss $LCTL set_param \
4581 ost.OSS.ost_io.nrs_policies="tbf\ jobid" || rc=$?
4582 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
4583 [[ $rc -ne 0 ]] && error "failed to set TBF JOBID policy"
4585 # Configure jobid_var
4586 local saved_jobid_var=$($LCTL get_param -n jobid_var)
4588 [[ $rc -eq 3 ]] && skip "jobid_var not found" && return
4589 [[ $rc -ne 0 ]] && error "failed to get param jobid_var"
4590 if [ $saved_jobid_var != procname_uid ]; then
4591 set_persistent_param_and_check client \
4592 "jobid_var" "$FSNAME.sys.jobid_var" procname_uid
4597 if [ "$OST1_VERSION" -ge $(version_code 2.8.54) ]; then
4602 # Only operate rules on ost1 since OSTs might run on the same OSS
4604 tbf_rule_operate ost1 "start\ runas\ ${idis}{iozone.$RUNAS_ID\ dd.$RUNAS_ID\ tiotest.$RUNAS_ID}\ ${rateis}1000"
4605 tbf_rule_operate ost1 "start\ iozone_runas\ ${idis}{iozone.$RUNAS_ID}\ ${rateis}100"
4606 tbf_rule_operate ost1 "start\ dd_runas\ ${idis}{dd.$RUNAS_ID}\ ${rateis}50"
4607 nrs_write_read "$RUNAS"
4610 tbf_rule_operate ost1 "change\ runas\ ${rateis}1001"
4611 tbf_rule_operate ost1 "change\ iozone_runas\ ${rateis}101"
4612 tbf_rule_operate ost1 "change\ dd_runas\ ${rateis}51"
4613 nrs_write_read "$RUNAS"
4616 tbf_rule_operate ost1 "stop\ runas"
4617 tbf_rule_operate ost1 "stop\ iozone_runas"
4618 tbf_rule_operate ost1 "stop\ dd_runas"
4619 nrs_write_read "$RUNAS"
4621 # Cleanup the TBF policy
4622 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
4623 [ $? -ne 0 ] && error "failed to set policy back to fifo"
4624 nrs_write_read "$RUNAS"
4626 local current_jobid_var=$($LCTL get_param -n jobid_var)
4627 [[ $? -ne 0 ]] && error "failed to get param jobid_var"
4628 if [ $saved_jobid_var != $current_jobid_var ]; then
4629 set_persistent_param_and_check client \
4630 "jobid_var" "$FSNAME.sys.jobid_var" $saved_jobid_var
4634 run_test 77f "check TBF JobID nrs policy"
4639 oss=$(comma_list $(osts_nodes))
4641 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid" ||
4643 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
4644 [[ $rc -ne 0 ]] && error "failed to set TBF NID policy"
4646 do_nodes $oss lctl set_param \
4647 ost.OSS.ost_io.nrs_policies="tbf\ jobid" || rc=$?
4648 [[ $rc -ne 0 ]] && error "failed to set TBF JOBID policy"
4652 if [ "$OST1_VERSION" -ge $(version_code 2.8.54) ]; then
4657 # Add a rule that only valid for Jobid TBF. If direct change between
4658 # TBF types is not supported, this operation will fail.
4659 tbf_rule_operate ost1 "start\ dd_runas\ ${idis}{dd.$RUNAS_ID}\ ${rateis}50"
4661 # Cleanup the TBF policy
4662 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
4663 [ $? -ne 0 ] && error "failed to set policy back to fifo"
4666 run_test 77g "Change TBF type directly"
4669 [ "$OST1_VERSION" -ge $(version_code 2.8.55) ] ||
4670 skip "Need OST version at least 2.8.55"
4672 local old_policy=$(do_facet ost1 \
4673 lctl get_param ost.OSS.ost_io.nrs_policies)
4676 do_facet ost1 lctl set_param \
4677 ost.OSS.ost_io.nrs_policies="abc"
4678 [ $? -eq 0 ] && error "should return error"
4680 do_facet ost1 lctl set_param \
4681 ost.OSS.ost_io.nrs_policies="tbf\ abc"
4682 [ $? -eq 0 ] && error "should return error"
4684 do_facet ost1 lctl set_param \
4685 ost.OSS.ost_io.nrs_policies="tbf\ reg\ abc"
4686 [ $? -eq 0 ] && error "should return error"
4688 do_facet ost1 lctl set_param \
4689 ost.OSS.ost_io.nrs_policies="tbf\ abc\ efg"
4690 [ $? -eq 0 ] && error "should return error"
4692 new_policy=$(do_facet ost1 lctl get_param ost.OSS.ost_io.nrs_policies)
4693 [ $? -eq 0 ] || error "shouldn't LBUG"
4695 [ "$old_policy" = "$new_policy" ] || error "NRS policy should be same"
4699 run_test 77h "Wrong policy name should report error, not LBUG"
4705 local error_message=$3
4707 for rule in $expected; do
4708 rule_number=$((rule_number + 1))
4710 local stop_line=$(($rule_number + 3))
4711 local awk_command="awk 'NR >= 4 && NR <= $stop_line {print \$1}'"
4713 local output=$(do_facet $facet lctl get_param \
4714 ost.OSS.ost_io.nrs_tbf_rule |
4718 if [ "$output" != "$expected" ]; then
4719 error "$error_message, expected '$expected', got '$output'"
4724 [ "$OST1_VERSION" -ge $(version_code 2.8.55) ] ||
4725 skip "Need OST version at least 2.8.55"
4727 for i in $(seq 1 $OSTCOUNT)
4729 do_facet ost"$i" lctl set_param \
4730 ost.OSS.ost_io.nrs_policies="tbf\ jobid"
4732 error "failed to set TBF policy"
4735 tbf_rule_check ost1 "default" "error before inserting any rule"
4737 tbf_rule_operate ost1 "start\ before\ jobid={jobid}\ rate=1000"
4738 tbf_rule_check ost1 "before default" \
4739 "error when inserting rule 'before'"
4741 tbf_rule_operate ost1 "start\ after\ jobid={jobid}\ rate=1000\ rank=default"
4742 tbf_rule_check ost1 "before after default" \
4743 "error when inserting rule 'after'"
4745 tbf_rule_operate ost1 "start\ target\ jobid={jobid}\ rate=1000\ rank=after"
4746 tbf_rule_check ost1 "before target after default" \
4747 "error when inserting rule 'target'"
4749 echo "Move before itself"
4750 tbf_rule_operate ost1 "change\ target\ rank=target"
4751 tbf_rule_check ost1 "before target after default" \
4752 "error when moving before itself"
4754 echo "Move to higher rank"
4755 tbf_rule_operate ost1 "change\ target\ rank=before"
4756 tbf_rule_check ost1 "target before after default" \
4757 "error when moving to higher rank"
4759 echo "Move to lower rank"
4760 tbf_rule_operate ost1 "change\ target\ rank=after"
4761 tbf_rule_check ost1 "before target after default" \
4762 "error when moving to lower rank"
4764 echo "Move before default"
4765 tbf_rule_operate ost1 "change\ target\ rank=default"
4766 tbf_rule_check ost1 "before after target default" \
4767 error "error when moving before default"
4769 # Cleanup the TBF policy
4770 do_nodes $(comma_list $(osts_nodes)) \
4771 $LCTL set_param ost.OSS.ost_io.nrs_policies=fifo
4774 run_test 77i "Change rank of TBF rule"
4780 [ "$OST1_VERSION" -ge $(version_code 2.9.53) ] ||
4781 skip "Need OST version at least 2.9.53"
4782 if [ "$OST1_VERSION" -ge $(version_code 2.8.60) ]; then
4787 do_nodes $(comma_list $(osts_nodes)) \
4788 lctl set_param jobid_var=procname_uid \
4789 ost.OSS.ost_io.nrs_policies="tbf\ opcode" \
4790 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_r\ ${idis}{ost_read}\ ${rateis}5" \
4791 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_w\ ${idis}{ost_write}\ ${rateis}20"
4792 [ $? -ne 0 ] && error "failed to set TBF OPCode policy"
4797 do_nodes $(comma_list $(osts_nodes)) \
4798 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_r" \
4799 ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_w" \
4800 ost.OSS.ost_io.nrs_policies="fifo"
4802 # sleep 3 seconds to wait the tbf policy stop completely,
4803 # or the next test case is possible get -EAGAIN when
4804 # setting the tbf policy
4807 run_test 77j "check TBF-OPCode NRS policy"
4810 local idstr="${1}id"
4811 local policy="${idstr}={$2}"
4812 local rate="rate=$3"
4813 local runas_args="$4"
4814 local createas_args="${5:-$runas_args}"
4816 do_nodes $(comma_list $(osts_nodes)) \
4817 lctl set_param jobid_var=procname_uid \
4818 ost.OSS.ost_io.nrs_policies="tbf\ ${idstr}" \
4819 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_${idstr}\ ${policy}\ ${rate}"
4820 [ $? -ne 0 ] && error "failed to set tbf ${idstr} policy"
4822 nrs_write_read "runas $runas_args" "runas $createas_args"
4823 tbf_verify $3 $3 "runas $runas_args" "runas $createas_args"
4825 do_nodes $(comma_list $(osts_nodes)) \
4826 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_${idstr}" \
4827 ost.OSS.ost_io.nrs_policies="fifo"
4829 # sleep 3 seconds to wait the tbf policy stop completely,
4830 # or the next test case is possible get -eagain when
4831 # setting the tbf policy
4836 if [ "$OST1_VERSION" -lt $(version_code 2.11.50) ]; then
4837 skip "Need OST version at least 2.11.50"
4840 test_id "u" "$RUNAS_ID" "5" "-u $RUNAS_ID"
4841 test_id "g" "$RUNAS_GID" "5" "-u $RUNAS_ID -g $RUNAS_GID"
4843 run_test 77ja "check TBF-UID/GID NRS policy"
4845 test_77jb() { # LU-16077
4846 (( "$OST1_VERSION" >= $(version_code 2.15.51) )) ||
4847 skip "Need OST version at least 2.15.51"
4849 test_id "u" "$RUNAS_ID" "5" "-u $RUNAS_ID" "-u 0 -g $RUNAS_GID"
4850 test_id "g" "$RUNAS_GID" "5" "-u $RUNAS_ID -g $RUNAS_GID" "-u $RUNAS_ID -g 0"
4852 run_test 77jb "check TBF-UID/GID NRS policy on files that don't belong to us"
4860 for rule in $rule_lists; do
4861 do_nodes $(comma_list $(osts_nodes)) \
4862 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ $rule"
4865 do_nodes $(comma_list $(osts_nodes)) \
4866 lctl set_param ost.OSS.ost_io.nrs_policies="$old_nrs"
4872 [[ "$OST1_VERSION" -ge $(version_code 2.9.53) ]] ||
4873 skip "Need OST version at least 2.9.53"
4875 do_nodes $(comma_list $(osts_nodes)) \
4876 lctl set_param ost.OSS.ost_io.nrs_policies="tbf" \
4877 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_w\ jobid={dd.$RUNAS_ID}\&opcode={ost_write}\ rate=20" \
4878 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_r\ jobid={dd.$RUNAS_ID}\&opcode={ost_read}\ rate=10"
4880 nrs_write_read "$RUNAS"
4881 tbf_verify 20 10 "$RUNAS"
4883 local address=$(comma_list "$(host_nids_address $CLIENTS $NETTYPE)")
4884 local client_nids=$(nids_list $address "\\")
4885 do_nodes $(comma_list $(osts_nodes)) \
4886 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_w" \
4887 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_r" \
4888 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_w\ nid={0@lo\ $client_nids}\&opcode={ost_write}\ rate=20" \
4889 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_r\ nid={0@lo\ $client_nids}\&opcode={ost_read}\ rate=10"
4894 do_nodes $(comma_list $(osts_nodes)) \
4895 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_w" \
4896 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_r" \
4897 ost.OSS.ost_io.nrs_tbf_rule="start\ ext\ nid={0@lo\ $client_nids}\&jobid={dd.$RUNAS_ID}\ rate=20"
4899 nrs_write_read "$RUNAS"
4900 tbf_verify 20 20 "$RUNAS"
4902 do_nodes $(comma_list $(osts_nodes)) \
4903 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext" \
4904 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_a\ jobid={dd.$RUNAS_ID},opcode={ost_write}\ rate=20" \
4905 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_b\ jobid={dd.$RUNAS_ID},opcode={ost_read}\ rate=10"
4907 nrs_write_read "$RUNAS"
4908 # with parameter "RUNAS", it will match the latest rule
4909 # "ext_b" first, so the limited write rate is 10.
4910 tbf_verify 10 10 "$RUNAS"
4913 trap "cleanup_77k \"ext_a ext_b\" \"fifo\"" EXIT
4915 [[ "$OST1_VERSION" -ge $(version_code 2.10.58) ]] ||
4916 skip "Need OST version at least 2.10.58"
4918 do_nodes $(comma_list $(osts_nodes)) \
4919 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_a" \
4920 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_b" \
4921 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_ug\ uid={$RUNAS_ID}\&gid={$RUNAS_GID}\ rate=5"
4922 nrs_write_read "runas -u $RUNAS_ID -g $RUNAS_GID"
4923 tbf_verify 5 5 "runas -u $RUNAS_ID -g $RUNAS_GID"
4925 do_nodes $(comma_list $(osts_nodes)) \
4926 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_ug" \
4927 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_uw\ uid={$RUNAS_ID}\&opcode={ost_write}\ rate=20" \
4928 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_ur\ uid={$RUNAS_ID}\&opcode={ost_read}\ rate=10"
4930 nrs_write_read "runas -u $RUNAS_ID"
4931 tbf_verify 20 10 "runas -u $RUNAS_ID"
4933 do_nodes $(comma_list $(osts_nodes)) \
4934 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_uw" \
4935 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_ur" \
4936 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_a\ uid={$RUNAS_ID},opcode={ost_write}\ rate=20" \
4937 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_b\ uid={$RUNAS_ID},opcode={ost_read}\ rate=10"
4938 nrs_write_read "runas -u $RUNAS_ID"
4939 tbf_verify 10 10 "runas -u $RUNAS_ID"
4940 tbf_verify 20 10 "runas -u $RUNAS_ID"
4941 cleanup_77k "ext_a ext_b" "fifo"
4943 run_test 77k "check TBF policy with UID/GID/JobID/OPCode expression"
4946 [[ "$OST1_VERSION" -ge $(version_code 2.10.56) ]] ||
4947 skip "Need OST version at least 2.10.56"
4949 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid"
4950 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="tbf"
4952 local output=$(do_facet ost1 lctl get_param \
4953 ost.OSS.ost_io.nrs_policies | \
4954 awk '/name: tbf/ {print;exit}' | \
4955 awk -F ': ' '{print $2}')
4957 if [ "$output" != "tbf" ]; then
4958 error "The generic TBF output is '$output', not 'tbf'"
4961 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
4963 run_test 77l "check the output of NRS policies for generic TBF"
4966 if [ "$OST1_VERSION" -lt $(version_code 2.9.54) ]; then
4967 skip "Need OST version at least 2.9.54"
4970 local dir=$DIR/$tdir
4972 mkdir $dir || error "mkdir $dir failed"
4973 $LFS setstripe -c $OSTCOUNT $dir || error "setstripe to $dir failed"
4976 local nodes=$(comma_list $(osts_nodes))
4977 do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies=delay \
4978 ost.OSS.ost_io.nrs_delay_min=4 \
4979 ost.OSS.ost_io.nrs_delay_max=4 \
4980 ost.OSS.ost_io.nrs_delay_pct=100
4981 [ $? -ne 0 ] && error "Failed to set delay policy"
4983 local start=$SECONDS
4984 do_nodes "${SINGLECLIENT:-$HOSTNAME}" "$RUNAS" \
4985 dd if=/dev/zero of="$dir/nrs_delay_$HOSTNAME" bs=1M count=1 \
4986 oflag=direct conv=fdatasync ||
4987 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
4988 error "dd on client failed (1)"; }
4989 local elapsed=$((SECONDS - start))
4991 # NRS delay doesn't do sub-second timing, so a request enqueued at
4992 # 0.9 seconds can be dequeued at 4.0
4993 [ $elapsed -lt 3 ] &&
4994 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
4995 error "Single 1M write should take at least 3 seconds"; }
4998 do_nodes "${SINGLECLIENT:-$HOSTNAME}" "$RUNAS" \
4999 dd if=/dev/zero of="$dir/nrs_delay_$HOSTNAME" bs=1M count=10 \
5000 oflag=direct conv=fdatasync ||
5001 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
5002 error "dd on client failed (2)"; }
5003 elapsed=$((SECONDS - start))
5005 [ $elapsed -lt 30 ] &&
5006 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
5007 error "Ten 1M writes should take at least 30 seconds"; }
5009 do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
5010 [ $? -ne 0 ] && error "failed to set policy back to fifo"
5014 run_test 77m "check NRS Delay slows write RPC processing"
5016 test_77n() { #LU-10802
5017 if [ "$OST1_VERSION" -lt $(version_code 2.10.58) ]; then
5018 skip "Need OST version at least 2.10.58"
5021 # Configure jobid_var
5022 local saved_jobid_var=$($LCTL get_param -n jobid_var)
5023 if [ $saved_jobid_var != procname_uid ]; then
5024 set_persistent_param_and_check client \
5025 "jobid_var" "$FSNAME.sys.jobid_var" procname_uid
5028 do_nodes $(comma_list $(osts_nodes)) \
5029 lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ jobid" \
5030 ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \
5031 ost.OSS.ost_io.nrs_tbf_rule="start\ dd_runas\ jobid={*.$RUNAS_ID}\ rate=20"
5034 tbf_verify 20 20 "$RUNAS"
5036 do_nodes $(comma_list $(osts_nodes)) \
5037 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \
5038 ost.OSS.ost_io.nrs_tbf_rule="start\ dd_runas\ jobid={dd.*}\ rate=20"
5043 do_nodes $(comma_list $(osts_nodes)) \
5044 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \
5045 ost.OSS.ost_io.nrs_policies="fifo"
5049 local current_jobid_var=$($LCTL get_param -n jobid_var)
5050 if [ $saved_jobid_var != $current_jobid_var ]; then
5051 set_persistent_param_and_check client \
5052 "jobid_var" "$FSNAME.sys.jobid_var" $saved_jobid_var
5055 run_test 77n "check wildcard support for TBF JobID NRS policy"
5058 (( $OST1_VERSION > $(version_code 2.14.54) )) ||
5059 skip "need OST > 2.14.54"
5061 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_policies="tbf\ nid"
5062 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="start\ name\ nid={192.168.*.*@tcp}\ rate=10000"
5063 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="start\ name1\ nid={192.168.*.*@tcp}\ rate=10000"
5064 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="change\ name1\ rank=name"
5065 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="stop\ name"
5066 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_policies="fifo"
5068 run_test 77o "Changing rank should not panic"
5072 local gidlist="500 10 33 100 "
5073 local uidlist=" 500 11 3"
5075 (( $MDS1_VERSION > $(version_code 2.14.54) )) ||
5076 skip "need MDS >= 2.14.54"
5078 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_policies="tbf"
5079 stack_trap "do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_policies=fifo"
5081 # require 44cc782/LU-9859 to support list with unexpected spaces
5082 (( MDS1_VERSION >= $(version_code 2.15.57) )) ||
5083 gidlist=$(echo $gidlist) uidlist=$(echo $uidlist)
5085 for i in {1..50}; do
5088 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="'start rule77q_1 uid={$uidlist}&gid={$gidlist} rate=100'" &
5090 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="'start rule77q_2 uid={1000}&gid={1000} rate=100'" &
5092 wait $pid1 || error "$i: Fail to start TBF rule 'rule77q_1'"
5093 wait $pid2 || error "$i: Fail to start TBF rule 'rule77q_2'"
5095 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="'stop rule77q_1'" &
5097 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="'stop rule77q_2'" &
5099 wait $pid1 || error "$i: Fail to stop TBF rule 'rule77q_1'"
5100 wait $pid2 || error "$i: Fail to stop TBF rule 'rule77q_2'"
5103 run_test 77q "Parallel TBF rule definitions should not panic"
5107 local -a spec_chars=(
5108 '@' '.' '~' '#' '/' '^' '%' '*' ';' ',' '?' '<' '>' ':'
5109 '+' '=' ')' '(' '{' '}' '|' '[' ']' '!' '&' '\$' '\`' '\\')
5111 (( $MDS1_VERSION > $(version_code 2.14.54) )) ||
5112 skip "need MDS >= 2.14.54"
5114 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_policies="tbf"
5115 stack_trap "do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_policies=fifo"
5117 # TBF rule name size is 16 bytes
5118 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="start\ test_77p_overflo\ uid={500}\ rate=500" &&
5119 error "The length of tbf rule name is not checked" || true
5120 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="start\ \ uid={500}\ rate=500" &&
5121 error "The server should not accept empty tbf rule name" || true
5122 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="start\ test_77p_empty" &&
5123 error "The server should not accept 'start <tbf_rule_name>' without an expression" || true
5125 # Test with special chars
5126 for c in "${spec_chars[@]}"; do
5127 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="'start test77p${c}spec uid={500} rate=500'" &&
5128 error "Special char '${c}' should not be accepted in a tbf rule name" || true
5132 run_test 77p "Check validity of rule names for TBF policies"
5136 local saved_jobid=$2
5137 local current_jobid_var
5139 echo "cleanup 77r $pid"
5141 do_facet mds1 $LCTL set_param -n mds.MDS.mdt.nrs_policies=fifo
5142 kill $pid || echo "fail to kill md thread"
5144 current_jobid_var=$($LCTL get_param -n jobid_var)
5145 if [ $saved_jobid != $current_jobid_var ]; then
5146 set_persistent_param_and_check client \
5147 "jobid_var" "$FSNAME.sys.jobid_var" $saved_jobid
5154 md_thread_run="true"
5158 while $md_thread_run; do
5159 printf '%s\n' {$DIR1,$DIR2}/$tdir/${tfile}-{01..20} |
5160 xargs -P20 -I{} $RUNAS bash -c 'touch {}; rm -f {}' \
5161 &> /dev/null & pid=$!
5162 trap "echo kill md_thread xargs; md_thread_run=false; kill $pid" INT TERM
5167 wait_policy_state() {
5170 local change_pid="$3"
5173 for time in {1..60}; do
5176 nbr_started=$(do_facet mds1 $LCTL get_param mds.MDS.mdt.nrs_policies |
5177 egrep -A2 "name: ${policy}$" | grep -c "state: $state")
5179 [[ "$nbr_started" != 2 ]] || return 0
5183 [[ -z "$change_pid" ]] || kill $change_pid || true
5187 test_77r() { #LU-14976
5189 (( MDS1_VERSION > $(version_code 2.15.56) )) ||
5190 skip "need MDS >= 2.15.56 c098c095 change nrs policies at run time"
5195 local saved_jobid_var
5197 rules["tbf uid"]="start md_rule uid={$RUNAS_ID} rate=1"
5198 rules["tbf gid"]="start md_rule gid={$RUNAS_GID} rate=1"
5199 rules["tbf jobid"]="start md_rule jobid={*.$RUNAS_ID} rate=1"
5200 rules["tbf"]="start md_rule uid={$RUNAS_ID} rate=1"
5209 test_mkdir -i 0 -c 1 $DIR1/$tdir
5210 chmod 777 $DIR1/$tdir
5212 # Configure jobid_var
5213 saved_jobid_var=$($LCTL get_param -n jobid_var)
5214 if [ $saved_jobid_var != procname_uid ]; then
5215 set_persistent_param_and_check client \
5216 "jobid_var" "$FSNAME.sys.jobid_var" procname_uid
5220 md_thread_77r & pid=$!
5221 stack_trap "cleanup_77r $pid '$saved_jobid_var'"
5224 for policy in "${policies[@]}"; do
5227 # wait to queue requests
5230 do_facet mds1 "$LCTL set_param mds.MDS.mdt.nrs_policies='$policy'" &
5233 wait_policy_state "started" "$policy" "$change_pid" ||
5234 error "timeout to start '$policy' policy"
5236 [[ -n "${rules[$policy]}" ]] || continue
5238 do_facet mds1 "$LCTL set_param mds.MDS.mdt.nrs_tbf_rule='${rules[$policy]}'" ||
5239 error "fail to set rule '${rules[$policy]}' to '$policy'"
5242 wait_policy_state "stopped" "tbf" ||
5243 error "fail to stop tbf policy"
5245 echo "check the number of requests in queue:"
5246 local awkcmd='/name: / {last = $3} '
5247 awkcmd+='/queued: / {printf " %s: %d\n", last, $2;'
5248 awkcmd+=' if (last == "tbf" && $2 > 0) exit 1;}'
5249 do_facet mds1 $LCTL get_param mds.MDS.mdt.nrs_policies | awk "$awkcmd" ||
5250 error "request leak in tbf policies"
5252 run_test 77r "Change type of tbf policy at run time"
5254 test_78() { #LU-6673
5257 oss=$(comma_list $(osts_nodes))
5258 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="orr" &
5259 do_nodes $oss lctl set_param ost.OSS.*.nrs_orr_quantum=1
5261 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
5262 # Valid return codes are:
5263 # 0: Tuning succeeded
5264 # ENODEV: Policy is still stopped
5265 # EAGAIN: Policy is being initialized
5266 [ $rc -eq 0 -o $rc -eq 19 -o $rc -eq 11 ] ||
5267 error "Expected set_param to return 0|ENODEV|EAGAIN"
5269 # Cleanup the ORR policy
5270 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
5271 [ $? -ne 0 ] && error "failed to set policy back to fifo"
5274 run_test 78 "Enable policy and specify tunings right away"
5277 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5278 test_mkdir $DIR/$tdir
5280 # Prevent interference from layout intent RPCs due to
5281 # asynchronous writeback. These will be tested in 130c below.
5282 do_nodes ${CLIENTS:-$HOSTNAME} sync
5284 setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
5285 error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
5287 #define OBD_FAIL_MDS_INTENT_DELAY 0x160
5288 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
5289 local facet=mds$((mdtidx + 1))
5291 set_nodes_failloc $(facet_active_host $facet) 0x80000160
5292 getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null &
5296 #define OBD_FAIL_MDS_GETXATTR_PACK 0x131
5297 set_nodes_failloc $(facet_active_host $facet) 0x80000131
5302 run_test 79 "xattr: intent error"
5305 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
5312 mkdir_on_mdt0 $DIR1/$tdir
5313 mkdir -p $DIR1/$tdir/dir
5314 createmany -o $DIR1/$tdir/dir/f 10 ||
5315 error "create files under remote dir failed $i"
5317 cp /etc/passwd $DIR1/$tdir/$tfile
5319 # attempt to migrate an open file
5320 multiop_bg_pause $DIR2/$tdir/$tfile O_c || error "open $file failed"
5322 # give multiop a chance to open
5325 local open_file_migrate=false
5326 (($MDS1_VERSION >= $(version_code 2.16.50) )) && open_file_migrate=true
5328 if $open_file_migrate; then
5329 local oldfid=$($LFS path2fid $DIR1/$tdir/$tfile)
5331 $LFS migrate -m $MDTIDX $DIR1/$tdir ||
5332 error "migrate open files should not fail"
5336 local newfid=$($LFS path2fid $DIR1/$tdir/$tfile)
5338 [[ "$oldfid" == "$newfid" ]] ||
5339 error "FID of the open file changed from $oldfid to $newfid"
5342 $LFS migrate -m $MDTIDX $DIR1/$tdir &&
5343 error "migrate open files should failed with open files"
5347 $LFS migrate -m $MDTIDX $DIR1/$tdir ||
5348 error "migrate remote dir error"
5351 echo "Finish migration, then checking.."
5352 for file in $(find $DIR1/$tdir); do
5353 $open_file_migrate && [[ "$file" == "$DIR1/$tdir/$tfile" ]] &&
5355 mdt_index=$($LFS getstripe -m $file)
5356 [ $mdt_index == $MDTIDX ] ||
5357 error "$file is not on MDT${MDTIDX}"
5360 diff /etc/passwd $DIR1/$tdir/$tfile ||
5361 error "file different after migration"
5363 rm -rf $DIR1/$tdir || error "rm dir failed after migration"
5365 run_test 80a "migrate directory when some children is being opened"
5369 kill -9 $migrate_pid
5377 eval $@ &>/dev/null && success_count=$((success_count + 1)) ||
5378 failure_count=$((failure_count + 1))
5382 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
5383 local migdir1=$DIR1/$tdir/migrate_dir
5384 local migdir2=$DIR2/$tdir/migrate_dir
5390 trap cleanup_80b EXIT
5391 # prepare migrate directory
5393 for F in {1,2,3,4,5}; do
5394 echo "$F$F$F$F$F" > $migdir1/file$F
5395 echo "$F$F$F$F$F" > $DIR/$tdir/file$F
5398 # migrate the directories among MDTs
5401 mdt_idx=$((RANDOM % MDSCOUNT))
5403 $LFS migrate -m $mdt_idx $migdir1 &>/dev/null
5408 echo "start migration thread $migrate_pid"
5409 # access the files at the same time
5411 echo "accessing the migrating directory for 1 minute..."
5412 while ((SECONDS - start_time < 60)); do
5413 run_and_count ls $migdir2
5414 run_and_count diff -u $DIR2/$tdir/file1 $migdir2/file1
5415 run_and_count "cat $migdir2/file2 > $migdir2/file3"
5416 run_and_count "echo "aaaaa" > $migdir2/file4"
5417 run_and_count stat $migdir2/file5
5418 run_and_count touch $migdir2/source_file
5419 if [ -e $migdir2/source_file ]; then
5420 run_and_count ln $migdir2/source_file \
5423 [ -e $migdir2/link_file ] &&
5424 rm -rf $migdir2/link_file
5426 run_and_count mrename $migdir2/source_file \
5427 $migdir2/target_file
5429 [ -e $migdir2/target_file ] &&
5430 run_and_count rm -rf $migdir2/target_file ||
5431 run_and_count rm -rf $migdir2/source_file
5434 kill -0 $migrate_pid || {
5435 echo "migration stopped 1"
5440 # check migration are still there
5441 kill -0 $migrate_pid || error "migration stopped 2"
5443 # access during migration may fail
5444 echo "concurrent access $failure_count failures, $success_count successes"
5446 run_test 80b "Accessing directory during migration"
5449 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
5453 mkdir -p $DIR1/$tdir
5455 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d0
5456 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d1
5459 touch d0/0 || error "create 0 failed"
5460 mv d0/0 d1/0 || error "rename d0/0 d1/0 failed"
5461 stat d0/0 && error "stat mv filed succeed"
5462 mv $DIR2/$tdir/d1/0 $DIR2/$tdir/d0/0 || error "rename d1/0 d0/0 failed"
5463 stat d0/0 || error "stat failed"
5465 local t=$(ls -ai $DIR1/$tdir/d0 | sort -u | wc -l)
5467 if [ $t -ne 3 ]; then
5468 ls -ai $DIR1/$tdir/d0
5469 error "expect 3 get $t"
5474 run_test 81a "rename and stat under striped directory"
5477 [ $MDSCOUNT -lt 2 ] &&
5478 skip "We need at least 2 MDTs for this test"
5482 $LFS mkdir -c $MDSCOUNT $DIR1/$tdir || error "$LFS mkdir"
5483 createmany -o $DIR1/$tdir/$tfile. $COUNT || error "createmany"
5492 for ((i = 0; i < COUNT; i++)); do
5493 mrename $DIR2/$tdir/$tfile.$i $DIR2/$tdir/$tfile-new.$i \
5497 kill -9 $setattr_pid
5499 run_test 81b "rename under striped directory doesn't deadlock"
5502 [ $MDSCOUNT -lt 4 ] && skip_env "needs >= 4 MDTs"
5503 [ $MDS1_VERSION -lt $(version_code 2.13.52) ] &&
5504 skip "Need MDS version at least 2.13.52"
5506 # source is local, source parent is remote
5507 $LFS mkdir -i 0 $DIR1/${tdir}_src || error "mkdir ${tdir}_src"
5508 $LFS mkdir -i 1 $DIR1/${tdir}_tgt || error "mkdir ${tdir}_tgt"
5509 $LFS mkdir -i 3 $DIR1/${tdir}_src/sub || error "mkdir sub"
5510 $LFS mkdir -i 3 $DIR1/${tdir}_tgt/sub || error "mkdir sub"
5511 stat $DIR2/${tdir}_src/sub || error "stat sub failed"
5512 mv $DIR1/${tdir}_src/sub $DIR1/${tdir}_tgt/ || error "mv failed"
5513 [ -f $DIR2/${tdir}_src/sub ] && error "sub should be gone"
5514 rm -rf $DIR1/${tdir}_src $DIR1/${tdir}_tgt
5516 # source is remote, source parent is local
5517 $LFS mkdir -i 3 $DIR1/${tdir}_src || error "mkdir ${tdir}_src"
5518 $LFS mkdir -i 1 $DIR1/${tdir}_tgt || error "mkdir ${tdir}_tgt"
5519 $LFS mkdir -i 0 $DIR1/${tdir}_src/sub || error "mkdir sub"
5520 $LFS mkdir -i 3 $DIR1/${tdir}_tgt/sub || error "mkdir sub"
5521 stat $DIR2/${tdir}_src/sub || error "stat sub failed"
5522 mv $DIR1/${tdir}_src/sub $DIR1/${tdir}_tgt/ || error "mv failed"
5523 [ -f $DIR2/${tdir}_src/sub ] && error "sub should be gone"
5524 rm -rf $DIR1/${tdir}_src $DIR1/${tdir}_tgt
5526 # source and source parent are remote
5527 $LFS mkdir -i 0 $DIR1/${tdir}_src || error "mkdir ${tdir}_src"
5528 $LFS mkdir -i 1 $DIR1/${tdir}_tgt || error "mkdir ${tdir}_tgt"
5529 mkdir $DIR1/${tdir}_src/sub || error "mkdir sub"
5530 $LFS mkdir -i 3 $DIR1/${tdir}_tgt/sub || error "mkdir sub"
5531 stat $DIR2/${tdir}_src/sub || error "stat sub failed"
5532 mv $DIR1/${tdir}_src/sub $DIR1/${tdir}_tgt/ || error "mv failed"
5533 [ -f $DIR2/${tdir}_src/sub ] && error "sub should be gone"
5534 rm -rf $DIR1/${tdir}_src $DIR1/${tdir}_tgt
5536 # source and source parent are remote, and source is remote object
5537 $LFS mkdir -i 0 $DIR1/${tdir}_src || error "mkdir ${tdir}_src"
5538 $LFS mkdir -i 1 $DIR1/${tdir}_tgt || error "mkdir ${tdir}_tgt"
5539 $LFS mkdir -i 2 $DIR1/${tdir}_src/sub || error "mkdir sub"
5540 $LFS mkdir -i 3 $DIR1/${tdir}_tgt/sub || error "mkdir sub"
5541 stat $DIR2/${tdir}_src/sub || error "stat sub failed"
5542 mv $DIR1/${tdir}_src/sub $DIR1/${tdir}_tgt/ || error "mv failed"
5543 [ -f $DIR2/${tdir}_src/sub ] && error "sub should be gone" || true
5545 run_test 81c "rename revoke LOOKUP lock for remote object"
5548 for ((mds = 0; mds < $MDSCOUNT; mds++)); do
5549 local d2=$DIR2/$tdir-$mds
5553 wait || error "rm failed"
5558 local mdts=$(comma_list $(mdts_nodes))
5560 do_nodes $mdts "$LCTL set_param mdt.*.md_stats=clear > /dev/null"
5562 stack_trap cleanup_81d
5563 for ((mds = 0; mds < $MDSCOUNT; mds++)); do
5564 local d1=$DIR1/$tdir-$mds
5566 $LFS mkdir -i $mds $d1 $d1/_temporary || error "mkdir failed"
5567 createmany -o $d1/_temporary/$tfile. $COUNT ||
5568 error "createmany failed for $d1/_temporary"
5571 for ((mds = 0; mds < $MDSCOUNT; mds++)); do
5572 local d1=$DIR1/$tdir-$mds
5573 local d2=$DIR2/$tdir-$mds
5575 for ((i = 0; i < COUNT; i++)); do
5576 mrename $d1/_temporary/$tfile.$i $d1/$tfile.$i &
5578 mrename $d2/_temporary/$tfile.$i $d2/$tfile.$i &
5581 wait || error "rename failed"
5584 local stats=$DIR1/md_stats
5585 local total=$((MDSCOUNT * COUNT))
5587 do_nodes $mdts "$LCTL get_param -n mdt.*.md_stats" > $stats
5589 crossdir=$(awk '/crossdir_rename/ {sum+=$2} END {print sum}' $stats)
5590 (( crossdir == total )) ||
5591 error "not crossdir: $crossdir != $total"
5592 samedir=$(awk '/samedir_rename/ {sum+=$2} END {print sum}' $stats)
5593 (( samedir == 0 )) || error "considered samedir: $samedir"
5594 pardir=$(awk '/parallel_rename_dir/ {sum+=$2} END {print sum}' $stats)
5595 (( pardir == 0 )) || error "considered directory: $pardir"
5598 (( MDS1_VERSION >= $(version_code 2.15.60) )) ||
5599 { echo "need MDS >= 2.15.60 for parallel cross-dir"; return 0; }
5601 parfile=$(awk '/parallel_rename_file/ {sum+=$2} END {print sum}' $stats)
5602 (( parfile == total )) ||
5603 error "not considered file: $parfile != $total"
5605 run_test 81d "parallel rename file cross-dir on same MDT"
5608 [[ "$MDS1_VERSION" -gt $(version_code 2.6.91) ]] ||
5609 skip "Need MDS version at least 2.6.92"
5611 # Client 1 creates a file.
5612 multiop_bg_pause $DIR1/$tfile O_ac || error "multiop_bg_pause 1"
5614 # Client 2 opens the file.
5615 multiop_bg_pause $DIR2/$tfile o_Ac || error "multiop_bg_pause 2"
5617 # Client 1 makes the file an orphan.
5618 rm $DIR1/$tfile || error "rm"
5619 # Client 2 sets EA "user.multiop".
5621 wait $pid2 || error "multiop 2"
5622 # Client 1 gets EA "user.multiop". This used to fail because the EA
5623 # cache refill would get "trusted.link" from mdd_xattr_list() but
5624 # -ENOENT when trying to get "trusted.link"'s value. See also sanity
5627 wait $pid1 || error "multiop 1"
5629 run_test 82 "fsetxattr and fgetxattr on orphan files"
5632 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
5639 $LFS mkdir -i1 -c2 $tdir
5644 echo "start pid $pid1 to create/unlink striped directory"
5646 # Access the directory at the same time
5650 stat $tdir > /dev/null 2>&1
5654 echo "start pid $pid2 to stat striped directory"
5662 run_test 83 "access striped directory while it is being created/unlinked"
5665 [ $MDS1_VERSION -lt $(version_code 2.12.55) ] &&
5666 skip "lustre < 2.12.55 does not contain LU-12485 fix"
5670 $MULTIOP $DIR/$tfile oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:c ||
5671 error "create $tfile failed"
5672 mtime=$(stat -c%Y $DIR/$tfile)
5673 mtime=$((mtime + 200))
5675 #define OBD_FAIL_OBD_0NLINK_RACE 0x60b
5676 do_facet mds1 $LCTL set_param fail_loc=0x8000060b
5678 touch -c -m $mtime $DIR/$tfile &
5680 # sleep a while to let 'touch' run first
5682 rm -f $DIR2/$tfile || error "unlink $tfile failed"
5685 wait $setattr_pid || true
5687 run_test 84 "0-nlink race in lu_object_find()"
5690 llapi_root_test $DIR/$tfile $DIR2/$tfile
5692 run_test 85 "Lustre API root cache race"
5695 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
5700 [ "$SLOW" = "yes" ] && duration=600
5701 # Open/Create under striped directory
5705 $LFS mkdir -c$MDSCOUNT $tdir > /dev/null 2>&1
5706 touch $tdir/f{0..3} > /dev/null 2>&1
5710 echo "start pid $pid1 to open/create under striped directory"
5712 # unlink the striped directory at the same time
5716 rm -rf $tdir > /dev/null 2>&1
5720 echo "start pid $pid2 to unlink striped directory"
5729 run_test 90 "open/create and unlink striped directory"
5732 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
5737 [ "$SLOW" = "yes" ] && duration=600
5738 # chmod striped directory
5742 $LFS mkdir -c$MDSCOUNT $tdir > /dev/null 2>&1
5743 chmod go+w $tdir > /dev/null 2>&1
5747 echo "start pid $pid1 to chmod striped directory"
5749 # unlink the striped directory at the same time
5753 rm -rf $tdir > /dev/null 2>&1
5757 echo "start pid $pid2 to unlink striped directory"
5766 run_test 91 "chmod and unlink striped directory"
5769 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
5772 local cmd="exec $fd<$DIR1/$tdir"
5773 $LFS setdirstripe -c$MDSCOUNT $DIR1/$tdir || error "mkdir $tdir fails"
5776 trap "eval $cmd" EXIT
5777 cd $DIR1/$tdir || error "cd $DIR1/$tdir fails"
5778 rmdir ../$tdir || error "rmdir ../$tdir fails"
5780 #define OBD_FAIL_LLITE_NO_CHECK_DEAD 0x1408
5781 $LCTL set_param fail_loc=0x1408
5782 mkdir $DIR2/$tdir/dir && error "create dir succeeds"
5783 $LFS setdirstripe -i1 $DIR2/$tdir/remote_dir &&
5784 error "create remote dir succeeds"
5785 $LCTL set_param fail_loc=0
5789 run_test 92 "create remote directory under orphan directory"
5796 mkdir -p $DIR1/$tfile-1/
5797 mkdir -p $DIR2/$tfile-2/
5798 local old_rr=$(do_facet $SINGLEMDS "$LCTL get_param -n \
5799 lod.$FSNAME-MDT0000-*/qos_threshold_rr" | sed -e 's/%//')
5800 do_facet $SINGLEMDS "$LCTL set_param -n \
5801 lod.$FSNAME-MDT0000-*/qos_threshold_rr=100"
5802 #define OBD_FAIL_MDS_LOV_CREATE_RACE 0x163
5803 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x00000163"
5805 $LFS setstripe -c -1 $DIR1/$tfile-1/file1 &
5808 $LFS setstripe -c -1 $DIR2/$tfile-2/file2 &
5812 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x0"
5813 do_facet $SINGLEMDS "$LCTL set_param -n \
5814 lod.$FSNAME-MDT0000-*/qos_threshold_rr=$old_rr"
5816 $LFS getstripe $DIR1/$tfile-1/file1
5817 rc1=$($LFS getstripe -q $DIR1/$tfile-1/file1 |
5818 awk '{if (/[0-9]/) print $1 }' | sort | uniq -d | wc -l)
5819 $LFS getstripe $DIR2/$tfile-2/file2
5820 rc2=$($LFS getstripe -q $DIR2/$tfile-2/file2 |
5821 awk '{if (/[0-9]/) print $1 }' | sort | uniq -d | wc -l)
5822 echo "rc1=$rc1 and rc2=$rc2 "
5823 [ $rc1 -eq 0 ] && [ $rc2 -eq 0 ] ||
5824 error "object allocate on same ost detected"
5826 run_test 93 "alloc_rr should not allocate on same ost"
5829 $LCTL set_param osc.*.idle_timeout=0
5830 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=2 conv=fsync
5832 local before=$(date +%s)
5836 #define OBD_FAIL_LDLM_PAUSE_CANCEL 0x312
5837 $LCTL set_param fail_val=5 fail_loc=0x80000312
5838 dd if=/dev/zero of=$DIR/$tfile conv=notrunc oflag=append bs=4k count=1 &
5842 #define OBD_FAIL_LDLM_PAUSE_CANCEL_LOCAL 0x329
5843 $LCTL set_param fail_val=6 fail_loc=0x80000329
5844 $LCTL mark kill $pid
5847 dd if=/dev/zero of=$DIR2/$tfile conv=notrunc oflag=append bs=4k count=1
5850 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 conv=fsync
5852 evict=$(do_facet client $LCTL get_param \
5853 osc.$FSNAME-OST*-osc-*/state |
5854 awk -F"[ [,]" '/EVICTED ]$/ { if (t<$5) {t=$5;} } END { print t }')
5856 [ -z "$evict" ] || [[ $evict -le $before ]] ||
5857 (do_facet client $LCTL get_param \
5858 osc.$FSNAME-OST*-osc-*/state;
5859 error "eviction happened: $evict before:$before")
5860 $LCTL set_param osc.*.idle_timeout=debug
5862 run_test 94 "signal vs CP callback race"
5865 local file=$DIR/$tfile
5866 local file2=$DIR2/$tfile
5867 local fast_read_save
5870 fast_read_save=$($LCTL get_param -n llite.*.fast_read | head -n 1)
5871 [ -z "$fast_read_save" ] && skip "no fast read support"
5873 stack_trap "$LCTL set_param llite.*.fast_read=$fast_read_save" EXIT
5874 $LCTL set_param llite.*.fast_read=0
5876 $LFS setstripe -c $OSTCOUNT $file || error "failed to setstripe $file"
5877 dd if=/dev/zero of=$file bs=1M count=2 || error "failed to write $file"
5878 cancel_lru_locks $OSC
5879 $MULTIOP $file Oz1048576w4096c || error "failed to write $file"
5880 $MULTIOP $file oz1044480r4096c || error "failed to read $file"
5882 # OBD_FAIL_LLITE_PAGE_INVALIDATE_PAUSE 0x1421
5883 $LCTL set_param fail_loc=0x80001421 fail_val=7
5884 $MULTIOP $file2 Oz1048576w4096_c &
5888 # OBD_FAIL_LLITE_READPAGE_PAUSE 0x1422
5889 $LCTL set_param fail_loc=0x80001422 fail_val=10
5890 $MULTIOP $file oz1044480r4096c || error "failed to read $file"
5892 kill -USR1 $pid && wait $pid || error "wait for PID $pid failed"
5894 run_test 95a "Check readpage() on a page that was removed from page cache"
5897 local file=$DIR/$tfile
5898 local file2=$DIR2/$tfile
5899 local fast_read_save
5902 fast_read_save=$($LCTL get_param -n llite.*.fast_read | head -n 1)
5903 [ -z "$fast_read_save" ] && skip "no fast read support"
5905 stack_trap "$LCTL set_param llite.*.fast_read=$fast_read_save" EXIT
5906 $LCTL set_param llite.*.fast_read=0
5908 $LFS setstripe -c $OSTCOUNT $file || error "failed to setstripe $file"
5909 dd if=/dev/zero of=$file bs=$((PAGE_SIZE * 3)) count=1 ||
5910 error "failed to write $file"
5912 # This does the read from the second mount, so this flushes the pages
5913 # the first mount and creates new ones on the second mount
5914 # OBD_FAIL_LLITE_READPAGE_PAUSE2 0x1424
5915 $LCTL set_param fail_loc=0x80001424 fail_val=5
5916 $MULTIOP $file2 or${PAGE_SIZE}c &
5920 fadvise_dontneed_helper $file2
5921 $LCTL set_param fail_loc=0
5923 wait $pid || error "failed to read file"
5925 run_test 95b "Check readpage() on a page that is no longer uptodate"
5929 skip "Reserved for glimpse-ahead" && return
5930 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
5931 skip "Need MDS version at least 2.10.55"
5935 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
5937 lctl set_param -n mdc.*.stats=clear
5938 dd if=/dev/zero of=$DIR2/$tdir/dom bs=4096 count=1 || return 1
5940 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #1"
5941 # first stat from server should return size data and save glimpse
5942 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
5943 [ $gls -eq 0 ] || error "Unexpected $gls glimpse RPCs"
5944 # second stat to check size is NOT cached on client without IO lock
5945 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #2"
5947 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
5948 [ $gls -ge 1 ] || error "Expect glimpse RPCs but none"
5951 run_test 100a "DoM: glimpse RPCs for stat without IO lock (DoM only file)"
5954 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
5955 skip "Need MDS version at least 2.10.55"
5959 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
5961 lctl set_param -n mdc.*.stats=clear
5962 dd if=/dev/zero of=$DIR2/$tdir/dom bs=4096 count=1 || return 1
5963 cancel_lru_locks mdc
5964 # first stat data from server should have size
5965 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #1"
5966 # second stat to check size is cached on client
5967 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #2"
5969 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
5970 # both stats should cause no glimpse requests
5971 [ $gls == 0 ] || error "Unexpected $gls glimpse RPCs"
5974 run_test 100b "DoM: no glimpse RPC for stat with IO lock (DoM only file)"
5977 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
5978 skip "Need MDS version at least 2.10.55"
5982 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
5984 lctl set_param -n mdc.*.stats=clear
5985 lctl set_param -n osc.*.stats=clear
5986 dd if=/dev/zero of=$DIR2/$tdir/dom bs=2048K count=1 || return 1
5988 # check that size is merged from MDT and OST correctly
5989 $CHECKSTAT -t file -s 2097152 $DIR/$tdir/dom ||
5990 error "Wrong size from stat #1"
5992 local gls=$(lctl get_param -n osc.*.stats | grep -c ldlm_glimpse)
5993 [ $gls -eq 0 ] && error "Expect OST glimpse RPCs but got none"
5997 run_test 100c "DoM: write vs stat without IO lock (combined file)"
6000 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
6001 skip "Need MDS version at least 2.10.55"
6005 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
6008 dd if=/dev/zero of=$DIR2/$tdir/dom bs=2048K count=1 || return 1
6009 lctl set_param -n mdc.*.stats=clear
6010 $TRUNCATE $DIR2/$tdir/dom 4096
6012 # check that reported size is valid after file grows to OST and
6013 # is truncated back to MDT stripe size
6014 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom ||
6015 error "Wrong size from stat #1"
6017 local gls=$(lctl get_param -n osc.*.stats | grep -c ldlm_glimpse)
6018 [ $gls -eq 0 ] && error "Expect OST glimpse but got none"
6022 run_test 100d "DoM: write+truncate vs stat without IO lock (combined file)"
6025 [ "$MDS1_VERSION" -lt $(version_code 2.11.50) ] &&
6026 skip "Need MDS version at least 2.11.50"
6028 local dom=$DIR/$tdir/dom
6029 local dom2=$DIR2/$tdir/dom
6032 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
6034 cancel_lru_locks mdc
6035 dd if=/dev/urandom of=$dom bs=12000 count=1
6036 $TRUNCATE $dom2 6000
6037 cancel_lru_locks mdc
6038 lctl set_param -n mdc.*.stats=clear
6039 # expect read-on-open to return all data before write
6040 cat /etc/hosts >> $dom
6041 local read=$(lctl get_param -n mdc.*.stats | grep -c ost_read)
6042 [[ $read -eq 0 ]] || error "Unexpected $read READ RPCs"
6044 run_test 100e "DoM: read on open and file size"
6047 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
6048 skip "Need MDS version at least 2.10.55"
6050 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
6052 $CHECKSTAT -t file $DIR1/$tfile
6054 local old_wb=$(sysctl -n vm.dirty_writeback_centisecs)
6055 sysctl -wq vm.dirty_writeback_centisecs=0
6057 trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT
6060 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 ||
6061 error_noexit "Write fails"
6062 # must discard pages
6063 lctl set_param -n mdc.*.stats=clear
6064 rm $DIR2/$tfile || error "Unlink fails"
6066 local writes=$(lctl get_param -n mdc.*.stats | grep -c ost_write)
6067 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
6069 run_test 101a "Discard DoM data on unlink"
6072 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
6073 skip "Need MDS version at least 2.10.55"
6075 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
6076 touch $DIR1/${tfile}_2
6078 $CHECKSTAT -t file $DIR1/$tfile
6080 local old_wb=$(sysctl -n vm.dirty_writeback_centisecs)
6081 sysctl -wq vm.dirty_writeback_centisecs=0
6083 trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT
6086 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 || error "Write fails"
6087 # must discard pages
6088 lctl set_param -n mdc.*.stats=clear
6089 mv $DIR2/${tfile}_2 $DIR2/$tfile || error "Rename fails"
6091 local writes=$(lctl get_param -n mdc.*.stats | grep -c ost_write)
6092 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
6094 run_test 101b "Discard DoM data on rename"
6097 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
6098 skip "Need MDS version at least 2.10.55"
6100 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
6102 $CHECKSTAT -t file $DIR1/$tfile
6104 local old_wb=$(sysctl -n vm.dirty_writeback_centisecs)
6105 sysctl -wq vm.dirty_writeback_centisecs=0
6107 trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT
6110 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 || error "Write fails"
6111 $MULTIOP $DIR1/$tfile O_c &
6114 lctl set_param -n mdc.*.stats=clear
6115 rm $DIR2/$tfile > /dev/null || error "Unlink fails for opened file"
6116 kill -USR1 $MULTIOP_PID && wait $MULTIOP_PID || error "multiop failure"
6118 local writes=$(lctl get_param -n mdc.*.stats | grep -c ost_write)
6119 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
6121 run_test 101c "Discard DoM data on close-unlink"
6123 # test to verify file handle related system calls
6124 # (name_to_handle_at/open_by_handle_at)
6125 # The new system calls are supported in glibc >= 2.14.
6127 # test to verify we can open by handle an unlinked file from > 1 client
6128 # This test opens the file normally on $DIR1, which is on one mount, and then
6129 # opens it by handle on $DIR2, which is on a different mount.
6131 (( "$MDS1_VERSION" >= $(version_code 2.11.57) )) ||
6132 skip "Needs MDS version 2.11.57 or later"
6134 echo "Test file_handle syscalls" > $DIR/$tfile ||
6135 error "write failed"
6136 check_fhandle_syscalls $DIR/$tfile $DIR2 ||
6137 error "check_fhandle_syscalls $tfile failed"
6139 # test this is working on DNE directories also
6140 if (( MDSCOUNT > 1 && MDS1_VERSION >= $(version_code 2.14.52) )); then
6141 $LFS mkdir -i 1 $DIR/$tdir.remote
6142 cancel_lru_locks mdc
6143 check_fhandle_syscalls $DIR/$tdir.remote $DIR2 ||
6144 error "check_fhandle_syscalls $tdir.remote failed"
6145 $LFS mkdir -c -1 $DIR/$tdir.remote/subdir
6146 cancel_lru_locks mdc
6147 check_fhandle_syscalls $DIR/$tdir.remote/subdir $DIR2 ||
6148 error "check_fhandle_syscalls $tdir.remote/subdir fail"
6150 $LFS mkdir -c -1 $DIR/$tdir.stripe
6151 cancel_lru_locks mdc
6152 check_fhandle_syscalls $DIR/$tdir.stripe $DIR2 ||
6153 error "check_fhandle_syscalls $tdir.stripe failed"
6154 $LFS mkdir -c -1 $DIR/$tdir.stripe/subdir
6155 cancel_lru_locks mdc
6156 check_fhandle_syscalls $DIR/$tdir.stripe/subdir $DIR2 ||
6157 error "check_fhandle_syscalls $tdir.stripe/subdir fail"
6160 run_test 102 "Test open by handle of unlinked file"
6162 # Compare file size between first & second mount, ensuring the client correctly
6163 # glimpses even with unused speculative locks - LU-11670
6165 [ $OST1_VERSION -lt $(version_code 2.10.50) ] &&
6166 skip "Lockahead needs OST version at least 2.10.50"
6170 test_mkdir -p $DIR/$tdir
6172 # Force file on to OST0
6173 $LFS setstripe -i 0 $DIR/$tdir
6175 # Do not check multiple locks on glimpse
6176 # OBD_FAIL_OSC_NO_SIZE_DATA 0x415
6177 $LCTL set_param fail_loc=0x415
6179 # Delay write commit by 2 seconds to guarantee glimpse wins race
6180 # The same fail_loc is used on client & server so it can work in the
6181 # single node sanity setup
6182 do_facet ost1 $LCTL set_param fail_loc=0x415 fail_val=2
6184 echo "Incorrect size expected (no glimpse fix):"
6185 lockahead_test -d $DIR/$tdir -D $DIR2/$tdir -t $locktest -f $tfile
6187 if [ $rc -eq 0 ]; then
6188 echo "This doesn't work 100%, but this is just reproducing the bug, not testing the fix, so OK to not fail test."
6191 # guarantee write commit timeout has expired
6194 # Clear fail_loc on client
6195 $LCTL set_param fail_loc=0
6197 # Delay write commit by 2 seconds to guarantee glimpse wins race
6198 # OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
6199 do_facet ost1 $LCTL set_param fail_loc=0x214 fail_val=2
6201 # Write commit is still delayed by 2 seconds
6202 lockahead_test -d $DIR/$tdir -D $DIR2/$tdir -t $locktest -f $tfile
6204 [ $rc -eq 0 ] || error "Lockahead test$locktest failed, $rc"
6206 # guarantee write commit timeout has expired
6209 rm -f $DIR/$tfile || error "unable to delete $DIR/$tfile"
6211 run_test 103 "Test size correctness with lockahead"
6217 xtimes=$(stat -c "%X %Y %Z" $DIR/$tfile)
6228 output=$(do_facet mds1 "$DEBUGFS -c -R 'stat ROOT/$tfile' $mdtdev")
6229 ((xtimes[0]=$(awk -F ':' /atime/'{ print $2 }' <<< "$output")))
6230 ((xtimes[1]=$(awk -F ':' /mtime/'{ print $2 }' <<< "$output")))
6231 ((xtimes[2]=$(awk -F ':' /ctime/'{ print $2 }' <<< "$output")))
6239 local xtimes=($(get_stat_xtimes))
6240 local mdt_xtimes=($(get_mdt_xtimes $mdtdev))
6242 echo "STAT a|m|ctime ${xtimes[*]}"
6243 echo "MDT a|m|ctime ${mdt_xtimes[*]}"
6244 [[ ${xtimes[0]} == ${mdt_xtimes[0]} ]] ||
6245 error "$DIR/$tfile atime (${xtimes[0]}:${mdt_xtimes[0]}) diff"
6246 [[ ${xtimes[1]} == ${mdt_xtimes[1]} ]] ||
6247 error "$DIR/$tfile mtime (${xtimes[1]}:${mdt_xtimes[1]}) diff"
6248 [[ ${xtimes[2]} == ${mdt_xtimes[2]} ]] ||
6249 error "$DIR/$tfile ctime (${xtimes[2]}:${mdt_xtimes[2]}) diff"
6253 [ "$mds1_FSTYPE" == "ldiskfs" ] || skip_env "ldiskfs only test"
6254 [ $MDS1_VERSION -lt $(version_code 2.12.4) ] &&
6255 skip "Need MDS version at least 2.12.4"
6258 local mdtdev=$(mdsdevname ${SINGLEMDS//mds/})
6259 local atime_diff=$(do_facet $SINGLEMDS \
6260 lctl get_param -n mdd.*MDT0000*.atime_diff)
6262 do_facet $SINGLEMDS \
6263 lctl set_param -n mdd.*MDT0000*.atime_diff=0
6265 stack_trap "do_facet $SINGLEMDS \
6266 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff" EXIT
6268 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
6269 check_mdt_xtimes $mdtdev
6272 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
6273 check_mdt_xtimes $mdtdev
6275 $MULTIOP $DIR2/$tfile Oz8192w8192_c &
6278 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
6280 kill -USR1 $pid && wait $pid || error "multiop failure"
6281 check_mdt_xtimes $mdtdev
6286 # Verify mtime/ctime is NOT upated on MDS when there is no modification
6287 # on the client side
6288 xtimes=($(get_stat_xtimes))
6289 $MULTIOP $DIR/$tfile O_c &
6292 kill -USR1 $pid && wait $pid || error "multiop failure"
6293 mdt_xtimes=($(get_mdt_xtimes $mdtdev))
6294 [[ ${xtimes[1]} == ${mdt_xtimes[1]} ]] ||
6295 error "$DIR/$tfile mtime (${xtimes[1]}:${mdt_xtimes[1]}) diff"
6296 [[ ${xtimes[2]} == ${mdt_xtimes[2]} ]] ||
6297 error "$DIR/$tfile ctime (${xtimes[2]}:${mdt_xtimes[2]}) diff"
6298 check_mdt_xtimes $mdtdev
6301 # Change ctime via chmod
6302 $MULTIOP $DIR/$tfile o_tc &
6305 kill -USR1 $pid && wait $pid || error "multiop failure"
6306 check_mdt_xtimes $mdtdev
6308 run_test 104 "Verify that MDS stores atime/mtime/ctime during close"
6311 test_mkdir -p $DIR/$tdir
6312 echo test > $DIR/$tdir/$tfile
6313 $LCTL set_param fail_loc=0x416
6314 cancel_lru_locks osc & sleep 1
6315 fsize1=$(stat -c %s $DIR2/$tdir/$tfile)
6317 [[ $fsize1 = 5 ]] || error "Glimpse returned wrong file size $fsize1"
6319 run_test 105 "Glimpse and lock cancel race"
6322 [ "$mds1_FSTYPE" == "ldiskfs" ] && statx_supported ||
6323 skip_env "Test only for ldiskfs and statx() supported"
6328 local mdtdev=$(mdsdevname ${SINGLEMDS//mds/})
6330 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
6331 btime=$($STATX -c %W $DIR/$tfile)
6332 output=$(do_facet mds1 "$DEBUGFS -c -R 'stat ROOT/$tfile' $mdtdev")
6334 ((mdt_btime=$(awk -F ':' /crtime/'{ print $2 }' <<< "$output")))
6335 [[ $btime == $mdt_btime ]] ||
6336 error "$DIR/$tfile btime ($btime:$mdt_btime) diff"
6339 run_test 106a "Verify the btime via statx()"
6342 statx_supported || skip_env "statx() only test"
6347 $LFS setstripe -c 1 $DIR/$tfile || error "$DIR/$tfile setstripe failed"
6348 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
6349 cancel_lru_locks $OSC
6350 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6352 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6353 [ $rpcs_after -eq $((rpcs_before + 1)) ] ||
6354 error "$STATX should send 1 glimpse RPC to $OSC"
6356 cancel_lru_locks $OSC
6357 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6358 # %n: FILENAME; %i: STATX_INO; %A STATX_MODE; %h STATX_NLINK;
6359 # %u: STATX_UID; %g: STATX_GID; %W STATX_BTIME; %X STATX_ATIME;
6361 $STATX -c "%n %i %A %h %u %g %W %X %Z" $DIR/$tfile
6362 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6363 [ $rpcs_after -eq $rpcs_before ] ||
6364 error "$STATX should not send glimpse RPCs to $OSC"
6366 cancel_lru_locks $OSC
6367 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6368 $STATX --cached=always $DIR/$tfile
6369 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6370 [ $rpcs_after -eq $rpcs_before ] ||
6371 error "$STATX should not send glimpse RPCs to $OSC"
6373 cancel_lru_locks $OSC
6374 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6375 $STATX -c %Y $DIR/$tfile
6376 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6377 [ $rpcs_after -eq $((rpcs_before + 1)) ] ||
6378 error "$STATX -c %Y should send 1 glimpse RPC to $OSC"
6380 cancel_lru_locks $OSC
6381 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6382 $STATX -c %s $DIR/$tfile
6383 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6384 [ $rpcs_after -eq $((rpcs_before + 1)) ] ||
6385 error "$STATX -c %s should send 1 glimpse RPC to $OSC"
6387 cancel_lru_locks $OSC
6388 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6389 $STATX -c %b $DIR/$tfile
6390 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6391 [ $rpcs_after -eq $((rpcs_before + 1)) ] ||
6392 error "$STATX -c %b should send 1 glimpse RPC to $OSC"
6394 run_test 106b "Glimpse RPCs test for statx"
6397 statx_supported || skip_env "statx() only test"
6402 # Mask supported in stx_attributes by Lustre is
6403 # STATX_ATTR_IMMUTABLE(0x10) | STATX_ATTR_APPEND(0x20) : (0x30).
6404 mask=$($STATX -c %p $DIR/$tfile)
6405 (( (0x$mask & 0x30) == 0x30 )) ||
6406 error "supported stx_attributes: got '0x$mask', expected '0x30' at least"
6407 chattr +i $DIR/$tfile || error "chattr +i $DIR/$tfile failed"
6408 mask=$($STATX -c %r $DIR/$tfile)
6409 [[ $mask == "10" ]] ||
6410 error "got immutable flags '$mask', expected '10'"
6411 chattr -i $DIR/$tfile || error "chattr -i $DIR/$tfile failed"
6412 mask=$($STATX -c %r $DIR/$tfile)
6413 [[ $mask == "0" ]] || error "got flags '$mask', expected '0'"
6414 chattr +a $DIR/$tfile || error "chattr +a $DIR/$tfile failed"
6415 mask=$($STATX -c %r $DIR/$tfile)
6416 [[ $mask == "20" ]] || error "got flags '$mask', expected '20'"
6417 chattr -a $DIR/$tfile || error "chattr -a $DIR/$tfile failed"
6418 mask=$($STATX -c %r $DIR/$tfile)
6419 [[ $mask == "0" ]] || error "got flags '$mask', expected '0'"
6420 chattr +ia $DIR/$tfile || error "chattr +ia $DIR/$tfile failed"
6421 mask=$($STATX -c %r $DIR/$tfile)
6422 [[ $mask == "30" ]] || error "got flags '$mask', expected '30'"
6423 chattr -ia $DIR/$tfile || error "chattr -ia $DIR/$tfile failed"
6424 mask=$($STATX -c %r $DIR/$tfile)
6425 [[ $mask == "0" ]] || error "got flags '$mask', expected '0'"
6427 run_test 106c "Verify statx attributes mask"
6429 test_107a() { # LU-1031
6430 dd if=/dev/zero of=$DIR1/$tfile bs=1M count=10
6434 $LFS getstripe $DIR1/$tfile
6436 multiop_bg_pause $DIR1/$tfile OG${gid1}_g${gid1}c || return 1
6438 multiop_bg_pause $DIR2/$tfile O_G${gid2}r10g${gid2}c || return 2
6440 kill -USR1 $MULTIPID2
6442 if [[ $(ps h -o comm -p $MULTIPID2) == "" ]]; then
6443 error "First grouplock does not block second one"
6445 echo "First grouplock blocks second one"
6447 kill -USR1 $MULTIPID1
6451 run_test 107a "Basic grouplock conflict"
6454 dd if=/dev/zero of=$DIR1/$tfile bs=1M count=10
6458 $LFS getstripe $DIR1/$tfile
6460 multiop_bg_pause $DIR1/$tfile OG${gid1}_g${gid1}c || return 1
6462 multiop $DIR2/$tfile Or10c &
6466 if [[ $(ps h -o comm -p $MULTIPID2) == "" ]]; then
6467 error "Grouplock does not block IO"
6469 echo "Grouplock blocks IO"
6472 multiop $DIR2/$tfile OG${gid2}_g${gid2}c &
6475 if [[ $(ps h -o comm -p $MULTIPID3) == "" ]]; then
6476 error "First grouplock does not block second one"
6478 echo "First grouplock blocks second one"
6481 kill -USR1 $MULTIPID1
6484 if [[ $(ps h -o comm -p $MULTIPID3) == "" ]]; then
6485 error "Second grouplock thread disappeared"
6488 if [[ $(ps h -o comm -p $MULTIPID2) == "" ]]; then
6489 error "Second grouplock does not block IO"
6491 echo "Second grouplock blocks IO"
6494 kill -USR1 $MULTIPID3
6499 run_test 107b "Grouplock is added to the head of waiting list"
6504 $LFS setstripe -E 1M -c 1 -E -1 $DIR1/$tfile ||
6505 error "Create $DIR1/$tfile failed"
6507 dd if=/dev/zero of=$DIR1/$tfile bs=10000 count=1 ||
6508 error "dd $DIR1/$tfile failed"
6509 offset=$(lseek_test -d 5000 $DIR2/$tfile)
6510 [[ $offset == 5000 ]] || error "offset $offset != 5000"
6512 $TRUNCATE $DIR1/$tfile 2000
6513 offset=$(lseek_test -l 1000 $DIR2/$tfile)
6514 [[ $offset == 2000 ]] || error "offset $offset != 2000"
6516 #define OBD_FAIL_OSC_DELAY_IO 0x414
6517 $LCTL set_param fail_val=4 fail_loc=0x80000414
6518 dd if=/dev/zero of=$DIR1/$tfile count=1 bs=8M conv=notrunc oflag=dsync &
6522 offset=$(lseek_test -l 8000 $DIR2/$tfile)
6524 [[ $offset == 8388608 ]] || error "offset $offset != 8388608"
6526 run_test 108a "lseek: parallel updates"
6534 skip "Clients need to be on different nodes than the servers"
6536 umount_client $MOUNT
6537 umount_client $MOUNT2
6539 echo "Starting race between client mount instances (50 iterations):"
6540 for i in {1..50}; do
6543 #define CFS_FAIL_ONCE|OBD_FAIL_LLITE_RACE_MOUNT 0x80001417
6544 $LCTL set_param -n fail_loc=0x80001417
6546 mount_client $MOUNT & pid1=$!
6547 mount_client $MOUNT2 & pid2=$!
6548 wait $pid1 || error "Mount $MOUNT fails with $?"
6549 wait $pid2 || error "Mount $MOUNT2 fails with $?"
6551 umount_client $MOUNT & pid1=$!
6552 umount_client $MOUNT2 & pid2=$!
6553 wait $pid1 || error "Umount $MOUNT fails with $?"
6554 wait $pid2 || error "Umount $MOUNT2 fails with $?"
6556 $LUSTRE_RMMOD || error "Fail to remove lustre modules"
6562 mount_client $MOUNT2
6565 run_test 109 "Race with several mount instances on 1 node"
6568 local before=$(date +%s)
6575 #define OBD_FAIL_PTLRPC_RESEND_RACE 0x525
6576 do_facet mds1 lctl set_param fail_loc=0x525 fail_val=3
6578 # disable last_xid logic by dropping link reply
6579 ln $DIR/$tdir/f1 $DIR/$tdir/f2 &
6582 #define OBD_FAIL_PTLRPC_ENQ_RESEND 0x534
6583 do_facet mds1 lctl set_param fail_loc=0x534
6585 # RPC will race with its Resend and the Resend will sleep to let
6586 # the original lock to get granted & cancelled.
6588 # AST_SENT is set artificially, so an explicit conflict is not needed
6590 # The woken up Resend gets a new lock, but client does not wait for it
6593 do_facet mds1 lctl set_param fail_loc=0 fail_val=0
6595 # Take a conflict to wait long enough to see the eviction
6598 # let the client reconnect
6600 evict=$(do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state |
6601 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
6603 [ -z "$evict" ] || [[ $evict -le $before ]] ||
6604 (do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state;
6605 error "eviction happened: $evict before:$before")
6607 run_test 110 "do not grant another lock on resend"
6610 [ $MDSCOUNT -ge 2 ] || skip "needs >= 2 MDTs"
6611 [[ $(facet_active_host mds1) = $(facet_active_host mds2) ]] ||
6612 skip "MDT0 and MDT1 should be on the same node"
6615 $LFS mkdir -i 0 $DIR1/$tdir/mdt0dir
6616 $LFS mkdir -i 1 $DIR1/$tdir/mdt1dir
6618 mkdir $DIR1/$tdir/mdt0dir/foodir
6619 touch $DIR1/$tdir/mdt0dir/foodir/{file1,file2}
6621 $MULTIOP $DIR2/$tdir/mdt0dir/foodir/file2 Ow4096_c &
6623 ln $DIR1/$tdir/mdt0dir/foodir/file2 $DIR1/$tdir/mdt1dir/file2
6625 #define OBD_FAIL_MDS_LINK_RENAME_RACE 0x18a
6626 do_facet mds1 $LCTL set_param fail_loc=0x8000018a
6628 ln $DIR1/$tdir/mdt0dir/foodir/file2 $DIR1/$tdir/mdt1dir/file2x &
6631 rm $DIR2/$tdir/mdt1dir/file2
6634 mv $DIR2/$tdir/mdt0dir/foodir/file1 $DIR2/$tdir/mdt0dir/foodir/file2
6639 rm -r $DIR1/$tdir || error "Removing test dir failed"
6641 run_test 111 "A racy rename/link an open file should not cause fs corruption"
6644 (( MDSCOUNT >= 2 )) ||
6645 skip "We need at least 2 MDTs for this test"
6647 (( MDS1_VERSION >= $(version_code 2.14.54) )) ||
6648 skip "Need server version at least 2.14.54"
6653 rr=$($LCTL get_param -n lmv.*.qos_threshold_rr | head -n1)
6655 stack_trap "$LCTL set_param lmv.*.qos_threshold_rr=$rr > /dev/null"
6657 mkdir -p $DIR1/$tdir/s1/s2 || error "mkdir s2 failed"
6658 $LFS mkdir -i 0 $DIR1/$tdir/s1/s2/s3 || error "mkdir s3 failed"
6659 $LFS setdirstripe -D -i -1 --max-inherit-rr=0 $DIR1/$tdir/s1/s2/s3 ||
6660 error "setdirstripe s3 failed"
6661 $LCTL set_param lmv.*.qos_threshold_rr=90
6662 mkdir $DIR2/$tdir/s1/s2/s3/d{1..64}
6663 count=$($LFS getstripe -m $DIR2/$tdir/s1/s2/s3/d* | grep ^0 | wc -l)
6664 (( count == 64 )) || error "only $count subdirs created on MDT0"
6666 $LFS setdirstripe -D -i -1 --max-inherit-rr=3 $DIR1/$tdir/s1/s2/s3 ||
6667 error "setdirstripe s3 failed"
6668 mkdir $DIR2/$tdir/s1/s2/s3/s{1..64}
6669 count=$($LFS getstripe -m $DIR2/$tdir/s1/s2/s3/s* | grep ^0 | wc -l)
6670 (( count == 64 / MDSCOUNT )) || error "$count subdirs created on MDT0"
6672 run_test 112 "update max-inherit in default LMV"
6675 (( MDS1_VERSION >= $(version_code 2.15.50) )) ||
6676 skip "Need server version at least 2.15.50"
6681 instance=$($LFS getname -i $DIR1) ||
6682 error "cannot get instance of $DIR1"
6684 $LFS check osts $DIR1 | grep $instance ||
6685 error "cannot find OSTs of instance $instance"
6687 $LFS check osts $DIR1 | grep -v $instance
6688 if (( $? == 0 )); then
6689 error "find OSTs other than instance $instance"
6692 $LFS check osts | grep $instance ||
6693 error "cannot find other OSTs"
6695 nid=$(df $DIR2 | tail -1 | sed 's%:/.*%%') ||
6696 error "cannot parse nid for $DIR2"
6698 $LFS check mgts $DIR2 | grep MGC$nid ||
6699 error "cannot find mgc of $nid"
6701 $LFS check mgts $DIR2 | grep -v MGC$nid
6702 if (( $? == 0 )); then
6703 error "find MGTs other than nid $nid"
6706 run_test 113 "check servers of specified fs"
6708 check_default_lmv() {
6719 enabled=$(do_facet mds1 \
6720 $LCTL get_param -n mdt.*-MDT0000*.enable_dmv_implicit_inherit)
6722 dmv=$($LFS getdirstripe -D $dir)
6724 index=$(echo $dmv | awk '{ print $4 }')
6725 (( index == $2 )) || error "$dir default stripe index $index != $2"
6727 count=$(echo $dmv | awk '{ print $2 }')
6728 (( count == $3 )) || error "$dir default stripe count $count != $3"
6730 inherit=$(echo $dmv | awk '{ print $8 }')
6731 (( inherit == $4 )) || error "$dir default max-inherit $inherit != $4"
6733 if [ $index -eq -1 ]; then
6734 inherit_rr=$(echo $dmv | awk '{ print $10 }')
6735 (( inherit_rr == $5 )) ||
6736 error "$dir default max-inherit-rr $inherit_rr != $5"
6739 # with --raw, print default LMV stored in inode, otherwise print nothing
6740 raw=$($LFS getdirstripe -D --raw $dir)
6741 if (( enabled == 1 )); then
6743 error "implicit inherited DMV is printed with --raw"
6745 # if disabled, dmv is stored in inode, which will always
6746 # print max-inherit-rr
6748 [[ $raw =~ $dmv.* ]] || error "$dir raw $raw != dmv $dmv"
6752 test_dmv_imp_inherit() {
6760 rm -rf $DIR/$tdir || error "rm $tdir failed"
6761 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
6763 # set dir default LMV
6764 $LFS setdirstripe -D -c1 -X4 --max-inherit-rr 2 $DIR/$tdir ||
6765 error "setdirstripe -D $tdir failed"
6766 dmv=$($LFS getdirstripe -D $DIR/$tdir)
6767 raw=$($LFS getdirstripe -D --raw $DIR/$tdir)
6768 [ "$dmv" == "$raw" ] || error "$dmv != $raw"
6770 mkdir -p $DIR/$tdir/l1/l2/l3 || error "mkdir $DIR/$tdir/l1/l2/l3 failed"
6771 check_default_lmv $DIR/$tdir/l1/l2/l3 -1 1 1 0
6772 check_default_lmv $DIR2/$tdir/l1/l2/l3 -1 1 1 0
6774 # below tests are valid only when this feature is enabled
6775 local enabled=$(do_facet mds1 \
6776 $LCTL get_param -n mdt.*-MDT0000*.enable_dmv_implicit_inherit)
6778 (( enabled == 1 )) || return 0
6780 # set l2 default LMV, dmv of l3 should change immediately
6781 $LFS setdirstripe -D -i1 -c2 -X4 $DIR/$tdir/l1/l2 ||
6782 error "setdirstripe -D $tdir/l1/l2 failed"
6784 check_default_lmv $DIR/$tdir/l1/l2/l3 1 2 3
6785 check_default_lmv $DIR2/$tdir/l1/l2/l3 1 2 3
6787 # change tdir default LMV, dmv of l3 should be unchanged because dmv
6788 # of l2 is explicitly set
6789 $LFS setdirstripe -D -i2 -c2 -X3 $DIR/$tdir ||
6790 error "setdirstripe -D $tdir failed"
6792 check_default_lmv $DIR/$tdir/l1 2 2 2
6793 check_default_lmv $DIR2/$tdir/l1 2 2 2
6794 check_default_lmv $DIR/$tdir/l1/l2/l3 1 2 3
6795 check_default_lmv $DIR2/$tdir/l1/l2/l3 1 2 3
6799 (( MDSCOUNT >= 2 )) ||
6800 skip "We need at least 2 MDTs for this test"
6802 (( MDS1_VERSION >= $(version_code 2.15.55.45) )) ||
6803 skip "Need server version at least 2.15.54.45"
6805 test_dmv_imp_inherit
6807 # disable dmv_imp_inherit to simulate old client
6808 local mdts=$(comma_list $(mdts_nodes))
6810 do_nodes $mdts $LCTL set_param -n \
6811 mdt.*MDT*.enable_dmv_implicit_inherit=0
6812 test_dmv_imp_inherit
6813 do_nodes $mdts $LCTL set_param -n \
6814 mdt.*MDT*.enable_dmv_implicit_inherit=1
6816 run_test 114 "implicit default LMV inherit"
6821 [ "$mds1_FSTYPE" == "ldiskfs" ] || skip_env "ldiskfs only test"
6823 mkdir_on_mdt0 $td || error "can't mkdir"
6824 # turn it htree (don't really needed)
6825 createmany -m $td/f 3000 || error "can't createmany"
6827 # here is an example of debugfs output for htree command:
6828 # Entry #0: Hash 0x00000000, block 27
6829 # Reading directory block 27, phys 16760
6830 # 938 0x0016fb58-7f3d21f5 (32) f775 834 0x001db8c8-d31a4e0e (32) f671
6831 # 1085 0x0040cb70-4498abd4 (32) f922 1850 0x0066a1e6-f6f0dc69 (32) f1687
6832 # 2005 0x006c1a46-ef466058 (32) f1842 2025 0x007e64d4-8b28b734 (32) f1862
6833 # 642 0x008b53a0-77adc601 (32) f479 447 0x009ec152-af54eea3 (32) f284
6834 # 1740 0x00c38f56-ed310e61 (32) f1577 2165 0x00cdfd66-f429a93f (32) f2002
6835 # 930 0x00d7ada4-b80421c9 (32) f767 1946 0x00da6a7a-e8080600 (32) f1783
6836 # 273 0x00f8ea00-760bf97c (32) f110 1589 0x0103c4ee-94fad5dd (32) f1426
6837 # 1383 0x01193516-83120b48 (32) f1220 2379 0x01431e3c-e85b5bd9 (32) f2216
6839 # find couple names in a same htree block of the same size
6840 mdt_dev=$(facet_device $SINGLEMDS)
6841 de=( $(do_facet $SINGLEMDS "debugfs -c -R 'htree /ROOT/$tdir' $mdt_dev" |
6842 awk '/Reading directory block/ { getline; print $4,$8; exit; }' ))
6845 [[ $de1 == "" || $de2 == "" ]] && error "de1=$de1 de2=$de2"
6846 echo "USE: $de1 $de2"
6847 # release one mkdir will lookup
6849 #define OBD_FAIL_MDS_PAUSE_CREATE_AFTER_LOOKUP 0x2401
6850 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x80002401 fail_val=5
6851 mkdir $DIR/$tdir/$de2 &
6855 mkdir $DIR2/$tdir/$de2
6856 # release space $de1 (should be enough to save $de2)
6858 # ready to create a dup of $de2
6860 local found=$(ls $DIR/$tdir/|grep "^$de2\$"|wc -l)
6861 (( $found == 1 )) || error "found $found"
6863 run_test 115 "ldiskfs doesn't check direntry for uniqueness"
6866 (( $MDSCOUNT >= 2 )) || skip "needs >= 2 MDTs"
6867 (( $MDS1_VERSION >= $(version_code v2_15_62-70-g668dfb53de) )) ||
6868 skip "Need MDS version at least 2.15.62.70 for intent mkdir"
6871 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
6873 save_lustre_params client "llite.*.intent_mkdir" > $save
6874 stack_trap "restore_lustre_params < $save; rm -f $save" EXIT
6875 $LCTL set_param llite.*.intent_mkdir=1
6877 $LFS mkdir -c$MDSCOUNT -i0 $DIR/$tdir ||
6878 error "$LFS mkdir $DIR/$tdir failed"
6879 echo "MD layout $DIR/$tdir:"
6880 $LFS getdirstripe $DIR/$tdir
6881 echo "mkdir $DIR/$tdir/tdir0"
6882 mkdir $DIR/$tdir/tdir0 || error "mkdir tdir0 failed"
6883 echo "setdirstripe -D -i1 $DIR2/$tdir/tdir0"
6884 $LFS setdirstripe -D -i1 $DIR2/$tdir/tdir0 ||
6885 error "$LFS setdirstripe $DIR2/$tdir/tdir0 failed"
6886 echo "mkdir $DIR/$tdir/tdir0/tdir11"
6887 mkdir $DIR/$tdir/tdir0/tdir11 || error "mkdir tdir0/tdir11 failed"
6888 $LFS getdirstripe $DIR/$tdir/tdir0
6889 $LFS getdirstripe $DIR/$tdir/tdir0/tdir11
6891 mdt_idx=$($LFS getstripe -m $DIR/$tdir/tdir0/tdir11)
6892 [ $mdt_idx == 1 ] ||
6893 error "$DIR/$tdir/tdir0/tdir11 on wrong MDT $mdt_idx"
6895 run_test 116 "DNE: Set default LMV layout from a remote client"
6898 remote_ost_nodsh && skip "remote OST with nodsh" && return
6902 local old_at=$(do_facet ost1 "$LCTL get_param -n at_max")
6903 local old_uf=$(do_facet ost1 "$LCTL get_param -n at_unhealthy_factor")
6904 local old_thrds=$(do_facet ost1 \
6905 "$LCTL get_param -n ost.OSS.ost_io.threads_max")
6906 local thrds=$(do_facet ost1 \
6907 "$LCTL get_param -n ost.OSS.ost_io.threads_started")
6909 if [[ -z "$old_uf" ]]; then
6910 skip "no at_unhealthy_factor, skipping"
6913 stack_trap "wait_osc_import_ready client ost1"
6914 do_facet ost1 "$LCTL set_param at_max=$at_max at_unhealthy_factor=3 \
6915 ost.OSS.ost_io.threads_max=$thrds"
6916 stack_trap "do_facet ost1 $LCTL set_param at_max=$old_at \
6917 at_unhealthy_factor=$old_uf \
6918 ost.OSS.ost_io.threads_max=$old_thrds"
6920 test_mkdir $DIR/$tdir
6921 $LFS setstripe -i 0 -c 1 $DIR/$tdir
6922 # delay for long enough to exceed old UNHEALTHY check, but allow
6923 # threads to complete RPCs occasionally to keep service healthy
6924 #define OBD_FAIL_OFD_COMMITRW_DELAY 0x1e1
6925 do_facet ost1 "$LCTL set_param fail_loc=0x1e1 fail_val=$delay"
6927 for ((i=0; i < thrds * 2; i++)); do
6928 dd if=/dev/urandom of=$DIR/$tdir/$tfile.$i bs=4k count=1 \
6933 # enough time for 2 sets of writes to be blocked for $fail_val
6934 local end=$((SECONDS + delay))
6937 while ((SECONDS < end)); do
6938 local health=$(do_facet ost1 $LCTL get_param -n health_check)
6940 if [[ "$health" != "healthy" ]]; then
6941 echo "OST health=$health"
6946 (( SECONDS >= end )) || error "unhealthy state was seen"
6949 run_test 200 "service remains healthy while able to process request"
6951 log "cleanup: ======================================================"
6953 # kill and wait in each test only guarentee script finish, but command in script
6954 # like 'rm' 'chmod' may still be running, wait for all commands to finish
6955 # otherwise umount below will fail
6956 [ "$(mount | grep $MOUNT2)" ] && wait_update $HOSTNAME "fuser -m $MOUNT2" "" ||
6959 complete_test $SECONDS
6961 check_and_cleanup_lustre