8 OPENFILE=${OPENFILE:-openfile}
9 OPENUNLINK=${OPENUNLINK:-openunlink}
10 export TMP=${TMP:-/tmp}
11 MOUNT_2=${MOUNT_2:-"yes"}
12 CHECK_GRANT=${CHECK_GRANT:-"yes"}
13 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
15 LUSTRE=${LUSTRE:-$(dirname $0)/..}
16 . $LUSTRE/tests/test-framework.sh
20 ALWAYS_EXCEPT="$SANITYN_EXCEPT "
21 # bug number for skipped test: LU-7105
23 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
25 if [ $mds1_FSTYPE = "zfs" ]; then
26 # bug number: LU-15757 (test_102() causes crash in umount later)
28 # LU-2829 / LU-2887 - make allowances for ZFS slowness
29 TEST33_NFILES=${TEST33_NFILES:-1000}
33 [ "$SLOW" = "no" ] && EXCEPT_SLOW="33a"
42 check_and_setup_lustre
47 rm -rf $DIR1/[df][0-9]* $DIR1/lnk $DIR/[df].${TESTSUITE}*
49 SAMPLE_FILE=$TMP/$(basename $0 .sh).junk
50 dd if=/dev/urandom of=$SAMPLE_FILE bs=1M count=1
52 # $RUNAS_ID may get set incorrectly somewhere else
53 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
55 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
58 local client2=${CLIENT2:-$HOSTNAME}
63 do_node_vp "$HOSTNAME" printf 'a b\n' |
64 diff $tmp - || error "do_node_vp mismatch"
66 do_node_vp "$client2" printf 'a b\n' |
67 diff $tmp - || error "do_node_vp mismatch"
69 do_facet_vp mds1 printf 'a b\n' |
70 diff $tmp - || error "do_facet_vp mismatch"
72 printf '%s' 1 2 3 4 5 6 7 8 \ 9 10 ' ' '"' "'" \! \' \( \) $'\n' > $tmp
74 do_node_vp "$HOSTNAME" printf '%s' 1 2 3 4 5 6 7 8 \ 9 10 ' ' '"' "'" \! \' \( \) $'\n' |
75 diff $tmp - || error "do_node_vp mismatch"
77 do_node_vp "$client2" printf '%s' 1 2 3 4 5 6 7 8 \ 9 10 ' ' '"' "'" \! \' \( \) $'\n' |
78 diff $tmp - || error "do_node_vp mismatch"
80 do_facet_vp mds1 printf '%s' 1 2 3 4 5 6 7 8 \ 9 10 ' ' '"' "'" \! \' \( \) $'\n' |
81 diff $tmp - || error "do_facet_vp mismatch"
83 run_test 0 "do_node_vp() and do_facet_vp() do the right thing"
87 [ -f $DIR2/$tfile ] || error "Check create"
88 chmod 777 $DIR2/$tfile
89 $CHECKSTAT -t file -p 0777 $DIR1/$tfile ||
90 error "Check attribute update for 0777"
92 chmod a-x $DIR2/$tfile
93 $CHECKSTAT -t file -p 0666 $DIR1/$tfile ||
94 error "Check attribute update for 0666"
97 $CHECKSTAT -a $DIR1/$tfile ||
98 error "Check unlink - removes file on other mountpoint"
100 run_test 1 "Check attribute updates on 2 mount points"
106 $CHECKSTAT -t file -p 0777 $DIR1/f2a ||
107 error "Either not file type or perms not 0777"
109 run_test 2a "check cached attribute updates on 2 mtpt's ========"
115 $CHECKSTAT -t file -p 0777 $DIR2/f2b ||
116 error "Either not file type or perms not 0777"
118 run_test 2b "check cached attribute updates on 2 mtpt's ========"
120 # NEED TO SAVE ROOT DIR MODE
123 $CHECKSTAT -t dir -p 0777 $DIR2 ||
124 error "Either not dir type or perms not 0777"
126 run_test 2c "check cached attribute updates on 2 mtpt's root ==="
130 $CHECKSTAT -t dir -p 0755 $DIR2 ||
131 error "Either not file type or perms not 0775"
133 run_test 2d "check cached attribute updates on 2 mtpt's root ==="
140 $RUNAS dd if=/dev/zero of=$DIR2/$tfile count=1 ||
143 run_test 2e "check chmod on root is propagated to others"
146 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
148 local remote_dir=$tdir/remote_dir
151 $LFS mkdir -i $MDTIDX $DIR1/$remote_dir ||
152 error "Create remote directory failed"
154 touch $DIR1/$remote_dir/$tfile ||
155 error "Create file under remote directory failed"
156 chmod 777 $DIR1/$remote_dir/$tfile ||
157 error "Chmod file under remote directory failed"
159 $CHECKSTAT -t file -p 0777 $DIR2/$remote_dir/$tfile ||
160 error "Check attr of file under remote directory failed"
162 chown $RUNAS_ID:$RUNAS_GID $DIR1/$remote_dir/$tfile ||
163 error "Chown file under remote directory failed"
165 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR2/$remote_dir/$tfile ||
166 error "Check owner of file under remote directory failed"
168 cd $DIR2/$remote_dir || error "enter remote dir"
169 rm -rf $DIR1/$remote_dir/$tfile ||
170 error "Unlink remote directory failed"
172 $CHECKSTAT -t file $DIR2/$remote_dir/$tfile &&
173 error "unlink file still exists!"
175 cd $DIR2/$tdir || error "exit remote dir"
176 rm -rf $DIR1/$tdir || error "unlink directory failed"
178 run_test 2f "check attr/owner updates on DNE with 2 mtpt's"
181 dd if=/dev/zero of=$DIR1/$tfile oflag=sync bs=1M count=2
183 local block1=$(stat $DIR1/$tfile | awk '/Blocks/ {print $4} ')
185 local block2=$(stat $DIR2/$tfile | awk '/Blocks/ {print $4} ')
186 echo "$DIR1/$tfile has $block1 blocks"
187 echo "$DIR2/$tfile has $block2 blocks"
188 [ $block1 -eq $block2 ] || error "$block1 not equal to $block2"
190 run_test 2g "check blocks update on sync write"
193 local target="this/is/good"
194 ln -s $target $DIR1/$tfile || error "ln -s $target $DIR1/$tfile failed"
195 [ "$(ls -l $DIR2/$tfile | sed -e 's/.* -> //')" = "$target" ] ||
196 error "link $DIR2/$tfile not as expected"
198 run_test 3 "symlink on one mtpt, readlink on another ==========="
201 multifstat $DIR1/f4 $DIR2/f4
203 run_test 4 "fstat validation on multiple mount points =========="
207 $TRUNCATE $DIR2/f5 100
208 $CHECKSTAT -t file -s 100 $DIR1/f5 ||
209 error "Either not file type or size not equal to 100 bytes"
212 run_test 5 "create a file on one mount, truncate it on the other"
215 openunlink $DIR1/$tfile $DIR2/$tfile || \
216 error "openunlink $DIR1/$tfile $DIR2/$tfile"
218 run_test 6 "remove of open file on other node =================="
222 opendirunlink $DIR1/$dir $DIR2/$dir || \
223 error "opendirunlink $DIR1/$dir $DIR2/$dir"
225 run_test 7 "remove of open directory on other node ============="
228 opendevunlink $DIR1/$tfile $DIR2/$tfile || \
229 error "opendevunlink $DIR1/$tfile $DIR2/$tfile"
231 run_test 8 "remove of open special file on other node =========="
237 for C in a b c d e f g h i j k l; do
238 dir=`eval echo \\$DIR$MTPT`
239 echo -n $C >> $dir/f9
240 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
242 [ "`cat $DIR1/f9`" = "abcdefghijkl" ] || \
243 error "`od -a $DIR1/f9` != abcdefghijkl"
245 run_test 9a "append of file with sub-page size on multiple mounts"
247 #LU-10681 - tiny writes & appending to sparse striped file
249 [[ $OSTCOUNT -ge 2 ]] || { skip "needs >= 2 OSTs"; return; }
251 $LFS setstripe -c 2 -S 1M $DIR/$tfile
252 echo "foo" >> $DIR/$tfile
253 dd if=/dev/zero of=$DIR2/$tfile bs=1M count=1 seek=1 conv=notrunc ||
254 error "sparse dd $DIR2/$tfile failed"
255 echo "foo" >> $DIR/$tfile
257 data=$(dd if=$DIR2/$tfile bs=1 count=3 skip=$((2 * 1048576)) conv=notrunc)
258 echo "Data read (expecting 'foo')": $data
259 [ "$data" = "foo" ] || error "append to sparse striped file failed"
261 run_test 9b "append to striped sparse file"
268 for C in a b c d e f g h i j k l; do
269 dir=`eval echo \\$DIR$MTPT`
270 echo -n $C | dd of=$dir/f10 bs=1 seek=$OFFSET count=1
271 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
272 OFFSET=`expr $OFFSET + 1`
274 [ "`cat $DIR1/f10`" = "abcdefghijkl" ] || \
275 error "`od -a $DIR1/f10` != abcdefghijkl"
277 run_test 10a "write of file with sub-page size on multiple mounts "
281 yes "R" | head -c 4000 >$TMP/f10b-seed
282 dd if=$TMP/f10b-seed of=$DIR1/f10b bs=3k count=1 || error "dd $DIR1"
284 $TRUNCATE $DIR1/f10b 4096 || error "truncate 4096"
286 dd if=$DIR2/f10b of=$TMP/f10b-lustre bs=4k count=1 || error "dd $DIR2"
288 # create a test file locally to compare
289 dd if=$TMP/f10b-seed of=$TMP/f10b bs=3k count=1 || error "dd random"
290 $TRUNCATE $TMP/f10b 4096 || error "truncate 4096"
291 cmp $TMP/f10b $TMP/f10b-lustre || error "file miscompare"
292 rm $TMP/f10b $TMP/f10b-lustre $TMP/f10b-seed
294 run_test 10b "write of file with sub-page size on multiple mounts "
298 multiop_bg_pause $DIR1/d11/f O_c || return 1
300 cp -p /bin/ls $DIR1/d11/f
304 wait $MULTIPID || error "wait for PID $MULTIPID failed"
305 [ $RC -eq 0 ] && error || true
307 run_test 11 "execution of file opened for write should return error ===="
310 DIR=$DIR DIR2=$DIR2 bash lockorder.sh
312 run_test 12 "test lock ordering (link, stat, unlink)"
314 test_13() { # bug 2451 - directory coherency
316 cd $DIR1/d13 || error "cd to $DIR1/d13 failed"
318 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
320 rm -f $DIR2/d13/f13 || error "Cannot remove $DIR2/d13/f13"
321 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (1)" || true
322 # need to run it twice
323 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
325 rm -f $DIR2/d13/f13 || error "Cannot remove $DIR2/d13/f13"
326 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (2)" || true
328 run_test 13 "test directory page revocation"
331 test_mkdir $DIR1/$tdir
332 cp -p /bin/ls $DIR1/$tdir/$tfile
333 multiop_bg_pause $DIR1/$tdir/$tfile Ow_c || return 1
336 $DIR2/$tdir/$tfile && error || true
339 run_test 14aa "execution of file open for write returns -ETXTBSY"
342 test_mkdir $DIR1/$tdir
343 cp -p $(which sleep) $DIR1/$tdir/sleep || error "cp failed"
344 $DIR1/$tdir/sleep 60 &
346 $MULTIOP $DIR2/$tdir/sleep Oc && error "expected error, got success"
349 run_test 14ab "open(RDWR) of executing file returns -ETXTBSY"
351 test_14b() { # bug 3192, 7040
352 test_mkdir $DIR1/$tdir
353 cp -p $(which sleep) $DIR1/$tdir/sleep || error "cp failed"
354 $DIR1/$tdir/sleep 60 &
356 $TRUNCATE $DIR2/$tdir/sleep 60 && kill -9 $SLEEP_PID && \
357 error "expected truncate error, got success"
359 cmp $(which sleep) $DIR1/$tdir/sleep || error "binary changed"
361 run_test 14b "truncate of executing file returns -ETXTBSY ======"
363 test_14c() { # bug 3430, 7040
364 test_mkdir $DIR1/$tdir
365 cp -p $(which sleep) $DIR1/$tdir/sleep || error "cp failed"
366 $DIR1/$tdir/sleep 60 &
368 cp /etc/hosts $DIR2/$tdir/sleep && error "expected error, got success"
370 cmp $(which sleep) $DIR1/$tdir/sleep || error "binary changed"
372 run_test 14c "open(O_TRUNC) of executing file return -ETXTBSY =="
374 test_14d() { # bug 10921
375 test_mkdir $DIR1/$tdir
376 cp -p $(which sleep) $DIR1/$tdir/sleep || error "cp failed"
377 $DIR1/$tdir/sleep 60 &
380 chmod 600 $DIR1/$tdir/sleep || error "chmod failed"
382 cmp $(which sleep) $DIR1/$tdir/sleep || error "binary changed"
384 run_test 14d "chmod of executing file is still possible ========"
386 test_15() { # bug 974 - ENOSPC
388 bash oos2.sh $MOUNT1 $MOUNT2
389 wait_delete_completed
390 grant_error=$(dmesg | grep "< tot_grant")
391 [ -z "$grant_error" ] || error "$grant_error"
393 run_test 15 "test out-of-space with multiple writers ==========="
396 # The FSXNUM reduction for ZFS is needed until ORI-487 is fixed.
397 # We don't want to skip it entirely, but ZFS is VERY slow and cannot
398 # pass a 2500 operation dual-mount run within the time limit.
399 if [ "$ost1_FSTYPE" = "zfs" ]; then
400 FSXNUM=$((COUNT / 5))
402 elif [ "$SLOW" = "yes" ]; then
403 FSXNUM=$((COUNT * 5))
411 local file1=$DIR1/$tfile
412 local file2=$DIR2/$tfile
413 local stripe_size=$(do_facet $SINGLEMDS \
414 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
418 # to allocate grant because it may run out due to test_15.
419 $LFS setstripe -c -1 $file1
420 dd if=/dev/zero of=$file1 bs=$stripe_size count=$OSTCOUNT oflag=sync
421 dd if=/dev/zero of=$file2 bs=$stripe_size count=$OSTCOUNT oflag=sync
424 $LFS setstripe -c -1 $file1 # b=10919
425 $FSX -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -S 0 $file1 $file2 ||
429 # O_DIRECT reads and writes must be aligned to the PAGE_SIZE.
430 $FSX -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -S 0 -Z -r $PAGE_SIZE \
431 -w $PAGE_SIZE $file1 $file2 || error "fsx with O_DIRECT failed."
433 run_test 16a "$FSXNUM iterations of dual-mount fsx"
435 # Consistency check for tiny writes, LU-9409
437 local file1=$DIR1/$tfile
438 local file2=$DIR2/$tfile
439 local stripe_size=($($LFS getstripe -S $DIR))
443 # to allocate grant because it may run out due to test_15.
444 lfs setstripe -c -1 $file1
445 dd if=/dev/zero of=$file1 bs=$stripe_size count=$OSTCOUNT oflag=sync ||
446 error "dd failed writing to file=$file1"
447 dd if=/dev/zero of=$file2 bs=$stripe_size count=$OSTCOUNT oflag=sync ||
448 error "dd failed writing to file=$file2"
451 lfs setstripe -c -1 $file1 # b=10919
452 # -o is set to 8192 because writes < 1 page and between 1 and 2 pages
453 # create a mix of tiny writes & normal writes
454 $FSX -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -o 8192 -S 0 \
455 $file1 $file2 || error "fsx with tiny write failed."
457 run_test 16b "$FSXNUM iterations of dual-mount fsx at small size"
460 local file1=$DIR1/$tfile
461 local file2=$DIR2/$tfile
462 local stripe_size=$(do_facet $SINGLEMDS \
463 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
465 [ "$ost1_FSTYPE" != ldiskfs ] && skip "dio on ldiskfs only"
469 # to allocate grant because it may run out due to test_15.
470 $LFS setstripe -c -1 $file1
471 dd if=/dev/zero of=$file1 bs=$stripe_size count=$OSTCOUNT oflag=sync
472 dd if=/dev/zero of=$file2 bs=$stripe_size count=$OSTCOUNT oflag=sync
474 wait_delete_completed
476 local list=$(comma_list $(osts_nodes))
477 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
478 skip "not cache-capable obdfilter"
481 set_osd_param $list '' read_cache_enable 0
482 set_osd_param $list '' writethrough_cache_enable 0
484 $LFS setstripe -c -1 $file1 # b=10919
485 $FSX -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -S 0 $file1 $file2 ||
489 set_osd_param $list '' read_cache_enable 1
490 set_osd_param $list '' writethrough_cache_enable 1
494 run_test 16c "verify data consistency on ldiskfs with cache disabled (b=17397)"
497 local file1=$DIR1/$tfile
498 local file2=$DIR2/$tfile
499 local file3=$DIR1/file
500 local tmpfile=$(mktemp)
501 local stripe_size=$(do_facet $SINGLEMDS \
502 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
504 # to allocate grant because it may run out due to test_15.
505 $LFS setstripe -c -1 $file1
506 stack_trap "rm -f $file1 $file2 $file3 $tmpfile"
507 dd if=/dev/zero of=$file1 bs=$stripe_size count=$OSTCOUNT oflag=sync
508 dd if=/dev/zero of=$file2 bs=$stripe_size count=$OSTCOUNT oflag=sync
511 $LFS setstripe -c -1 $file1 # b=10919
512 $LCTL set_param ldlm.namespaces.*.lru_size=clear
514 # direct write on one client and direct read from another
515 dd if=/dev/urandom of=$file1 bs=1M count=100 oflag=direct
516 dd if=$file2 of=$tmpfile iflag=direct bs=1M
517 diff $file1 $tmpfile || error "file different(1)"
520 # buffer write on one client, but direct read from another
521 dd if=$tmpfile of=$file1 bs=1M count=100
522 dd if=$file2 of=$file3 bs=1M iflag=direct count=100
523 diff $file3 $tmpfile || error "file different(2)"
525 rm -f $file3 $file2 $file1
526 # direct write on one client
527 dd if=$tmpfile of=$file1 bs=1M count=100 oflag=direct
528 # buffer read from another client
529 dd if=$file2 of=$file3 bs=1M count=100
530 diff $file3 $tmpfile || error "file different(3)"
532 run_test 16d "Verify DIO and buffer IO with two clients"
534 test_16e() { # LU-13227
537 (( "$MDS1_VERSION" >= $(version_code 2.13.53) )) ||
538 skip "Need MDS version at least 2.13.53"
540 local file1=$DIR1/$tfile
541 local file2=$DIR2/$tfile
543 # client1 write 10M data
544 dd if=/dev/zero of=$file1 bs=1M count=10
546 cancel_lru_locks osc > /dev/null
547 # use lockahead to generate one PW lock to keep LVB loaded.
548 $LFS ladvise -a lockahead --start 0 --length 1M \
550 # direct write to extend file size on client2
551 dd if=/dev/zero of=$file2 bs=1M seek=20 count=1 \
552 oflag=direct conv=notrunc
553 local filesize=$(stat -c %s $file2)
554 [ "$filesize" -eq 22020096 ] ||
555 error "expected filesize 22020096 got $filesize"
558 run_test 16e "Verify size consistency for O_DIRECT write"
560 test_16f() { # LU-14541
561 local file1=$DIR1/$tfile
562 local file2=$DIR2/$tfile
566 (( $MDS1_VERSION > $(version_code 2.15.51) )) ||
567 skip "Need MDS version at least 2.15.51"
569 timeout --preserve-status --signal=USR1 $duration \
570 rw_seq_cst_vs_drop_caches $file1 $file2
573 case $((status & 0x7f)) in
575 echo OK # Computers must be fast now.
578 error "sequential consistency violation detected"
581 echo TIMEOUT # This is fine.
584 error "strange status '$status'"
590 run_test 16f "rw sequential consistency vs drop_caches"
593 local file1=$DIR1/$tfile
594 local file2=$DIR2/$tfile
598 timeout --preserve-status --signal=USR1 $duration \
599 rw_seq_cst_vs_drop_caches -m $file1 $file2
602 case $((status & 0x7f)) in
604 echo OK # Computers must be fast now.
607 error "sequential consistency violation detected"
610 echo TIMEOUT # This is fine.
613 error "strange status '$status'"
619 run_test 16g "mmap rw sequential consistency vs drop_caches"
622 local tf=$DIR/$tdir/$tfile
623 local tf2=$DIR2/$tdir/$tfile
624 local cmd="$MMAP_CAT $tf | od -x | tail -q -n4"
625 local cmd2="$MMAP_CAT $tf2 | od -x | tail -q -n4"
627 test_mkdir $DIR/$tdir
629 # create file and populate data
630 cp /etc/passwd $tf || error "cp failed"
632 local size=$(stat -c %s $tf)
635 if [[ "$c1" != "$c2" ]]; then
636 echo " ------- mount 1 read --------"
638 echo " ------- mount 2 read --------"
640 error "content mismatch"
643 echo " ------- before truncate --------"
647 $TRUNCATE $tf $((size / 2)) || error "truncate file"
650 echo " ------- after truncate --------"
652 # repeat the comparison
655 if [[ "$c1" != "$c2" ]]; then
656 echo " ------- mount 1 read --------"
658 echo " ------- mount 2 read --------"
660 error "content mismatch after truncate"
664 run_test 16h "mmap read after truncate file"
667 local tf=$DIR/$tdir/$tfile
668 local tf2=$DIR2/$tdir/$tfile
670 test_mkdir $DIR/$tdir
672 # create file and populate data
673 cp /etc/passwd $tf || error "cp failed"
675 local size=$(stat -c %s $tf)
677 c1=$(dd if=$tf bs=1 2>/dev/null | od -x | tail -q -n4)
678 c2=$(dd if=$tf2 bs=1 2>/dev/null | od -x | tail -q -n4)
680 if [[ "$c1" != "$c2" ]]; then
681 echo " ------- mount 1 read --------"
683 echo " ------- mount 2 read --------"
685 error "content mismatch"
688 echo " ------- before truncate --------"
692 $TRUNCATE $tf $((size / 2)) || error "truncate file"
694 echo " ------- after truncate --------"
696 # repeat the comparison
697 c1=$(dd if=$tf bs=1 2>/dev/null | od -x | tail -q -n4)
698 c2=$(dd if=$tf2 bs=1 2>/dev/null | od -x | tail -q -n4)
700 if [[ "$c1" != "$c2" ]]; then
701 echo " ------- mount 1 read --------"
703 echo " ------- mount 2 read --------"
705 error "content mismatch after truncate"
709 run_test 16i "read after truncate file"
713 (( $OSTCOUNT >= 2 )) || skip "needs >= 2 OSTs"
715 local stripe_size=$((1024 * 1024)) #1 MiB
716 # Max i/o below is ~ 4 * stripe_size, so this gives ~5 i/os
717 local file_size=$((25 * stripe_size))
720 $LFS setstripe -c 2 -S $stripe_size $DIR/$tfile.1
721 stack_trap "rm -f $DIR/$tfile.1"
723 # Just a bit bigger than the largest size in the test set below
724 dd if=/dev/urandom bs=$file_size count=1 of=$DIR/$tfile.1 ||
725 error "buffered i/o to create file failed"
727 if zfs_or_rotational; then
728 # DIO on ZFS can take up to 2 seconds per IO
729 # rotational is better, but still slow.
730 # Limit testing on those media to larger sizes
731 bsizes="$((stripe_size - PAGE_SIZE)) $stripe_size \
732 $((stripe_size + 1024))"
734 bsizes="$((PAGE_SIZE / 4)) $((PAGE_SIZE - 1024)) \
735 $((PAGE_SIZE - 1)) $PAGE_SIZE $((PAGE_SIZE + 1024)) \
736 $((PAGE_SIZE * 3/2)) $((PAGE_SIZE * 4)) \
737 $((stripe_size - 1)) $stripe_size \
738 $((stripe_size + 1)) $((stripe_size * 3/2)) \
739 $((stripe_size * 4)) $((stripe_size * 4 + 1))"
742 # 1 process (BIO or DIO) on each client
743 for bs in $bsizes; do
744 $LFS setstripe -c 2 -S $stripe_size $DIR/$tfile.2
745 echo "bs: $bs, file_size $file_size"
746 dd if=$DIR/$tfile.1 bs=$((bs *2 )) of=$DIR/tfile.2 \
747 conv=notrunc oflag=direct iflag=direct &
749 # Buffered I/O with similar but not the same block size
750 dd if=$DIR2/$tfile.1 bs=$((bs * 2)) of=$DIR2/$tfile.2 \
757 if (( rc1 != 0 )); then
758 error "dio copy 1 w/bsize $bs failed: $rc1"
760 if (( rc2 != 0 )); then
761 error "buffered copy 2 w/bsize $bs failed: $rc2"
764 $CHECKSTAT -t file -s $file_size $DIR/$tfile.2 ||
765 error "size incorrect"
766 $CHECKSTAT -t file -s $file_size $DIR2/$tfile.2 ||
767 error "size incorrect - mount 2"
768 cmp --verbose $DIR/$tfile.1 $DIR/$tfile.2 ||
769 error "files differ, bsize $bs"
770 cmp --verbose $DIR2/$tfile.1 $DIR2/$tfile.2 ||
771 error "files differ, bsize $bs - mount 2"
775 # 2 processes - both DIO and BIO - on each client
776 for bs in $bsizes; do
777 $LFS setstripe -c 2 -S $stripe_size $DIR/$tfile.2
778 echo "bs: $bs, file_size $file_size"
780 dd if=$DIR/$tfile.1 bs=$((bs *2 )) of=$DIR/tfile.2 \
781 conv=notrunc oflag=direct iflag=direct &
783 # Buffered I/O with similar but not the same block size
784 dd if=$DIR/$tfile.1 bs=$((bs * 2)) of=$DIR/$tfile.2 \
788 dd if=$DIR2/$tfile.1 bs=$((bs *2 )) of=$DIR2/tfile.2 \
789 conv=notrunc oflag=direct iflag=direct &
791 # Buffered I/O with similar but not the same block size
792 dd if=$DIR2/$tfile.1 bs=$((bs * 2)) of=$DIR2/$tfile.2 \
804 if (( rc1 != 0 )); then
805 error "dio copy 1 w/bsize $bs failed: $rc1"
807 if (( rc2 != 0 )); then
808 error "buffered copy 2 w/bsize $bs failed: $rc2"
810 if (( rc3 != 0 )); then
811 error "dio copy 3 w/bsize $bs failed: $rc1"
813 if (( rc4 != 0 )); then
814 error "buffered copy 4 w/bsize $bs failed: $rc2"
817 $CHECKSTAT -t file -s $file_size $DIR/$tfile.2 ||
818 error "size incorrect"
819 $CHECKSTAT -t file -s $file_size $DIR2/$tfile.2 ||
820 error "size incorrect - mount 2"
821 cmp --verbose $DIR/$tfile.1 $DIR/$tfile.2 ||
822 error "files differ, bsize $bs"
823 cmp --verbose $DIR2/$tfile.1 $DIR2/$tfile.2 ||
824 error "files differ, bsize $bs - mount 2"
828 run_test 16j "race dio with buffered i/o"
830 test_17() { # bug 3513, 3667
831 remote_ost_nodsh && skip "remote OST with nodsh" && return
833 lfs setstripe $DIR1/$tfile -i 0 -c 1
834 cp $SAMPLE_FILE $DIR1/$tfile
835 cancel_lru_locks osc > /dev/null
836 #define CFS_FAIL_ONCE|OBD_FAIL_LDLM_CREATE_RESOURCE 0x30a
837 do_facet ost1 lctl set_param fail_loc=0x8000030a
838 ls -ls $DIR1/$tfile | awk '{ print $1,$6 }' > $DIR1/$tfile-1 & \
839 ls -ls $DIR2/$tfile | awk '{ print $1,$6 }' > $DIR2/$tfile-2
841 diff -u $DIR1/$tfile-1 $DIR2/$tfile-2 || error "files are different"
843 run_test 17 "resource creation/LVB creation race ==============="
846 # turn e.g. ALWAYS_EXCEPT="18c" into "-e 3"
849 for idx in {a..z}; do
850 local ptr=EXCEPT_ALWAYS_18$idx
851 [ x${!ptr} = xtrue ] || continue
853 excepts="$excepts -e $(($(printf %d \'$idx)-96))"
856 excepts="$excepts -e 7 -e 8 -e 9"
857 $LUSTRE/tests/mmap_sanity -d $MOUNT1 -m $MOUNT2 $excepts ||
858 error "mmap_sanity test failed"
861 run_test 18 "mmap sanity check ================================="
863 test_19() { # bug3811
864 local node=$(facet_active_host ost1)
865 local device="$FSNAME-OST*"
867 [ "x$DOM" = "xyes" ] && node=$(facet_active_host $SINGLEMDS) &&
868 device="$FSNAME-MDT*"
870 # check whether obdfilter is cache capable at all
871 get_osd_param $node $device read_cache_enable >/dev/null ||
872 skip "not cache-capable obdfilter"
874 local max=$(get_osd_param $node $device readcache_max_filesize |\
876 set_osd_param $node $device readcache_max_filesize 4096
877 dd if=/dev/urandom of=$TMP/$tfile bs=512k count=32
878 local SUM=$(cksum $TMP/$tfile | cut -d" " -f 1,2)
879 cp $TMP/$tfile $DIR1/$tfile
880 for i in `seq 1 20`; do
881 [ $((i % 5)) -eq 0 ] && log "$testname loop $i"
882 cancel_lru_locks $OSC > /dev/null
883 cksum $DIR1/$tfile | cut -d" " -f 1,2 > $TMP/sum1 & \
884 cksum $DIR2/$tfile | cut -d" " -f 1,2 > $TMP/sum2
886 [ "$(cat $TMP/sum1)" = "$SUM" ] || \
887 error "$DIR1/$tfile $(cat $TMP/sum1) != $SUM"
888 [ "$(cat $TMP/sum2)" = "$SUM" ] || \
889 error "$DIR2/$tfile $(cat $TMP/sum2) != $SUM"
891 set_osd_param $node $device readcache_max_filesize $max
894 run_test 19 "test concurrent uncached read races ==============="
897 test_mkdir $DIR1/$tdir
899 CNT=$($LCTL get_param -n llite.*.dump_page_cache | wc -l)
900 $MULTIOP $DIR1/$tdir/$tfile Ow8190c
901 $MULTIOP $DIR2/$tdir/$tfile Oz8194w8190c
902 $MULTIOP $DIR1/$tdir/$tfile Oz0r8190c
904 CNT2=$($LCTL get_param -n llite.*.dump_page_cache | wc -l)
905 [[ $CNT2 == $CNT ]] ||
906 error $((CNT2 - CNT))" page left in cache after lock cancel"
908 run_test 20 "test extra readahead page left in cache ===="
915 test_21() { # Bug 5907
916 test_mkdir $DIR1/$tdir
917 mount /etc $DIR1/$tdir --bind || error "mount failed" # Poor man's mount.
919 rmdir -v $DIR1/$tdir && error "Removed mounted directory"
920 rmdir -v $DIR2/$tdir && echo "Removed mounted directory from another mountpoint, needs to be fixed"
921 test -d $DIR1/$tdir || error "Mounted directory disappeared"
923 test -d $DIR2/$tdir || test -d $DIR1/$tdir && error "Removed dir still visible after umount"
926 run_test 21 " Try to remove mountpoint on another dir ===="
928 test_23() { # Bug 5972
929 local at_diff=$(do_facet $SINGLEMDS \
930 $LCTL get_param -n mdd.*MDT0000*.atime_diff | head -n1)
931 echo "atime should be updated while another read" > $DIR1/$tfile
933 # clear the lock(mode: LCK_PW) gotten from creating operation
934 cancel_lru_locks $OSC
937 sleep $((at_diff + 1))
939 echo "starting reads"
940 multiop_bg_pause $DIR1/$tfile or20_c || return 1
941 # with SOM and opencache enabled, we need to close a file and cancel
942 # open lock to get atime propogated to MDS
943 kill -USR1 $! || return 2
946 time2=$(stat -c "%X" $DIR/$tfile)
947 echo "new atime is $time2"
949 [ $time2 -gt $time1 ] || error "atime was not updated"
950 rm -f $DIR1/$tfile || error "rm -f $DIR1/$tfile failed"
953 run_test 23 " others should see updated atime while another read===="
957 lfs df || error "lfs df failed"
958 lfs df -ih || error "lfs df -ih failed"
959 lfs df -h $DIR1 || error "lfs df -h $DIR1 failed"
960 lfs df -i $DIR2 || error "lfs df -i $DIR2 failed"
961 lfs df $DIR1/$tfile || error "lfs df $DIR1/$tfile failed"
962 lfs df -ih $DIR2/$tfile || error "lfs df -ih $DIR2/$tfile failed"
964 OSC=`lctl dl | awk '/-osc-|OSC.*MNT/ {print $4}' | head -n 1`
965 # OSC=`lctl dl | awk '/-osc-/ {print $4}' | head -n 1`
966 lctl --device %osc deactivate
967 lfs df -i || error "lfs df -i with deactivated OSC failed"
968 lctl --device %osc activate
969 lfs df || error "lfs df with reactivated OSC failed"
971 run_test 24a "lfs df [-ih] [path] test ========================="
975 fsnum=$(lfs_df | grep -c "summary")
976 [ $fsnum -eq 2 ] || error "lfs df shows $fsnum != 2 filesystems."
978 run_test 24b "lfs df should show both filesystems ==============="
981 local acl=$(lctl get_param -n mdc.*MDT0000-mdc-*.connect_flags |
983 [ "$acl" -lt 1 ] && skip "must have acl, skipping" && return
986 touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
987 chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
989 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
990 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
991 error "setfacl $DIR2/$tdir #1"
992 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
993 setfacl -m u:$RUNAS_ID:r-x -m g:$RUNAS_GID:r-x $DIR1/$tdir ||
994 error "setfacl $DIR2/$tdir #2"
995 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
996 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
997 error "setfacl $DIR2/$tdir #3"
998 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
999 setfacl -x u:$RUNAS_ID: -x g:$RUNAS_GID: $DIR1/$tdir ||
1000 error "setfacl $DIR2/$tdir #4"
1001 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
1005 run_test 25a "change ACL on one mountpoint be seen on another ==="
1008 local acl=$(lctl get_param -n mdc.*MDT0000-mdc-*.connect_flags |
1010 [ "$acl" -lt 1 ] && skip "must have acl, skipping" && return
1012 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1015 $LFS mkdir -i 1 $DIR1/$tdir
1016 touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
1017 chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
1019 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
1020 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
1021 error "setfacl $DIR2/$tdir #1"
1022 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
1023 setfacl -m u:$RUNAS_ID:r-x -m g:$RUNAS_GID:r-x $DIR1/$tdir ||
1024 error "setfacl $DIR2/$tdir #2"
1025 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
1026 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
1027 error "setfacl $DIR2/$tdir #3"
1028 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
1029 setfacl -x u:$RUNAS_ID: -x g:$RUNAS_GID: $DIR1/$tdir ||
1030 error "setfacl $DIR2/$tdir #4"
1031 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
1035 run_test 25b "change ACL under remote dir on one mountpoint be seen on another"
1038 utime $DIR1/f26a -s $DIR2/f26a || error "utime failed for $DIR1/f26a"
1040 run_test 26a "allow mtime to get older"
1045 echo "aaa" >> $DIR1/$tfile
1047 chmod a+x $DIR2/$tfile
1048 mt1=`stat -c %Y $DIR1/$tfile`
1049 mt2=`stat -c %Y $DIR2/$tfile`
1051 if [ x"$mt1" != x"$mt2" ]; then
1052 error "not equal mtime, client1: "$mt1", client2: "$mt2"."
1055 run_test 26b "sync mtime between ost and mds"
1058 cancel_lru_locks $OSC
1060 dd if=/dev/zero of=$DIR2/$tfile bs=$((4096+4))k conv=notrunc count=4 seek=3 &
1065 dd if=/dev/zero of=$DIR1/$tfile bs=$((16384-1024))k conv=notrunc count=1 seek=4 &
1070 dd if=/dev/zero of=$DIR1/$tfile bs=8k conv=notrunc count=1 seek=0
1072 lctl set_param -n ldlm.dump_namespaces ""
1073 wait $DD1_PID $DD2_PID
1074 [ $? -ne 0 ] && lctl dk $TMP/debug || true
1076 run_test 27 "align non-overlapping extent locks from request ==="
1078 test_28() { # bug 9977
1079 skip "echo_client on osc is no longer supported"
1081 run_test 28 "read/write/truncate file with lost stripes"
1083 test_30() { #b=11110, LU-2523
1084 test_mkdir $DIR1/$tdir
1085 cp -f /bin/bash $DIR1/$tdir/bash
1086 bash -c 'sleep 1; rm -f $DIR2/$tdir/bash; cp /bin/bash $DIR2/$tdir' &
1087 $DIR1/$tdir/bash -c 'sleep 2;
1088 openfile -f O_RDONLY /proc/$$/exe >& /dev/null; echo $?'
1092 run_test 30 "recreate file race"
1095 test_mkdir $DIR1/$tdir
1096 local writes=$(LANG=C dd if=/dev/zero of=$DIR/$tdir/$tfile \
1097 count=1 2>&1 | awk 'BEGIN { FS="+" } /out/ {print $1}')
1098 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
1099 lctl set_param fail_loc=0x314
1100 local reads=$(LANG=C dd if=$DIR2/$tdir/$tfile of=/dev/null 2>&1 |
1101 awk 'BEGIN { FS="+" } /in/ {print $1}')
1102 [ $reads -eq $writes ] || error "read" $reads "blocks, must be" $writes
1104 run_test 31a "voluntary cancel / blocking ast race=============="
1107 remote_ost || { skip "local OST" && return 0; }
1108 remote_ost_nodsh && skip "remote OST w/o dsh" && return 0
1110 # make sure there is no local locks due to destroy
1111 wait_mds_ost_sync || error "wait_mds_ost_sync()"
1112 wait_delete_completed || error "wait_delete_completed()"
1114 test_mkdir $DIR1/$tdir
1115 lfs setstripe $DIR/$tdir/$tfile -i 0 -c 1
1116 cp /etc/hosts $DIR/$tdir/$tfile
1117 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
1118 lctl set_param fail_loc=0x314
1119 #define OBD_FAIL_LDLM_OST_FAIL_RACE 0x316
1120 do_facet ost1 lctl set_param fail_loc=0x316
1121 # Don't crash kernel
1122 cat $DIR2/$tdir/$tfile > /dev/null 2>&1
1123 lctl set_param fail_loc=0
1124 do_facet ost1 lctl set_param fail_loc=0
1125 # cleanup: reconnect the client back
1128 run_test 31b "voluntary OST cancel / blocking ast race=============="
1130 #LU-14949 - multi-client version of the test 31r in sanity.
1132 touch $DIR/$tfile.target
1133 touch $DIR/$tfile.source
1135 ls -l $DIR/$tfile.target # cache it for sure
1137 #OBD_FAIL_LLITE_OPEN_DELAY 0x1419
1138 $LCTL set_param fail_loc=0x1419 fail_val=3
1139 cat $DIR/$tfile.target &
1142 # Guarantee open is waiting before we get here
1144 mv $DIR2/$tfile.source $DIR2/$tfile.target
1148 if [[ $RC -ne 0 ]]; then
1149 error "open with cat failed, rc=$RC"
1152 run_test 31r "open-rename(replace) race"
1154 test_32b() { # bug 11270
1155 remote_ost_nodsh && skip "remote OST with nodsh" && return
1158 local facets=$(get_facets OST)
1159 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
1161 save_lustre_params client "osc.*.contention_seconds" > $p
1162 save_lustre_params $facets \
1163 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
1164 save_lustre_params $facets \
1165 "ldlm.namespaces.filter-*.contended_locks" >> $p
1166 save_lustre_params $facets \
1167 "ldlm.namespaces.filter-*.contention_seconds" >> $p
1168 clear_stats $OSC.*.${OSC}_stats
1170 # agressive lockless i/o settings
1171 do_nodes $(comma_list $(osts_nodes)) \
1172 "lctl set_param -n ldlm.namespaces.*.max_nolock_bytes=2000000 \
1173 ldlm.namespaces.filter-*.contended_locks=0 \
1174 ldlm.namespaces.filter-*.contention_seconds=60"
1175 lctl set_param -n $OSC.*.contention_seconds=60
1177 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > \
1179 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > \
1182 [ $(calc_stats $OSC.*.${OSC}_stats lockless_write_bytes) -ne 0 ] ||
1183 error "lockless i/o was not triggered"
1184 # disable lockless i/o (it is disabled by default)
1185 do_nodes $(comma_list $(osts_nodes)) \
1186 "lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes=0 \
1187 ldlm.namespaces.filter-*.contended_locks=32 \
1188 ldlm.namespaces.filter-*.contention_seconds=0"
1189 # set contention_seconds to 0 at client too, otherwise Lustre still
1190 # remembers lock contention
1191 lctl set_param -n $OSC.*.contention_seconds=0
1192 clear_stats $OSC.*.${OSC}_stats
1194 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > \
1196 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > \
1199 [ $(calc_stats $OSC.*.${OSC}_stats lockless_write_bytes) -eq 0 ] ||
1200 error "lockless i/o works when disabled"
1202 restore_lustre_params <$p
1205 # Disable test 32b prior to full removal
1206 #run_test 32b "lockless i/o"
1209 local mdts=$(get_facets MDS)
1215 for mds in ${mdts//,/ }; do
1218 dev=$(basename $(do_facet $mds "lctl get_param -n \
1219 osd*.${!varsvc}.mntdev | xargs readlink -f"))
1220 val=$(do_facet $mds "cat /proc/fs/jbd*/${dev}{,:*,-*}/info \
1221 2>/dev/null | head -n1")
1223 stat=$((stat + val))
1228 # commit on sharing tests
1230 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1232 [ $CLIENTCOUNT -lt 2 ] &&
1233 skip "Need two or more clients, have $CLIENTCOUNT"
1235 local nfiles=${TEST33_NFILES:-10000}
1236 local param_file=$TMP/$tfile-params
1242 save_lustre_params $(get_facets MDS) \
1243 "mdt.*.commit_on_sharing" > $param_file
1246 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
1250 do_nodes $CLIENT1,$CLIENT2 "mkdir -p $DIR1/$tdir-\\\$(hostname)-$i"
1252 [ "$mds1_FSTYPE" = ldiskfs ] && jbdold=$(print_jbd_stat)
1253 echo "=== START createmany old: $jbdold transaction"
1254 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")
1255 [ "$mds1_FSTYPE" = ldiskfs ] && jbdnew=$(print_jbd_stat)
1256 [ "$mds1_FSTYPE" = ldiskfs ] && jbd=$(( jbdnew - jbdold ))
1257 echo "=== END createmany new: $jbdnew transaction : $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
1258 [ "$mds1_FSTYPE" = ldiskfs ] && avgjbd=$(( avgjbd + jbd ))
1259 avgtime=$(( avgtime + elapsed ))
1261 eval cos${COS}_jbd=$((avgjbd / 3))
1262 eval cos${COS}_time=$((avgtime / 3))
1265 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
1266 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
1267 [ "$cos0_jbd" != 0 ] &&
1268 echo "COS=1 vs COS=0 jbd: $((((cos1_jbd/cos0_jbd - 1)) * 100 )) %"
1269 [ "$cos0_time" != 0 ] &&
1270 echo "COS=1 vs COS=0 time: $((((cos1_time/cos0_time - 1)) * 100 )) %"
1272 restore_lustre_params < $param_file
1276 run_test 33a "commit on sharing, cross crete/delete, 2 clients, benchmark"
1278 # commit on sharing tests
1280 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1282 [ $CLIENTCOUNT -ge 2 ] ||
1283 { skip "Need two or more clients, have $CLIENTCOUNT" &&
1285 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1287 local nfiles=${TEST33_NFILES:-10000}
1288 local param_file=$TMP/$tfile-params
1290 save_lustre_params $(get_facets MDS) \
1291 "mdt.*.commit_on_sharing" > $param_file
1300 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
1304 do_node $CLIENT1 "$LFS mkdir -i $MDTIDX \
1305 $DIR1/$tdir-\\\$(hostname)-$i"
1307 jbdold=$(print_jbd_stat)
1308 echo "=== START createmany old: $jbdold transaction"
1309 local elapsed=$(do_and_time "do_nodes $CLIENT1,$CLIENT2\
1310 createmany -o $DIR1/$tdir-\\\$(hostname)-$i/f- \
1311 -r$DIR2/$tdir-\\\$(hostname)-$i/f- $nfiles > \
1313 jbdnew=$(print_jbd_stat)
1314 jbd=$(( jbdnew - jbdold ))
1315 echo "=== END createmany new: $jbdnew transaction : \
1316 $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
1317 avgjbd=$(( avgjbd + jbd ))
1318 avgtime=$(( avgtime + elapsed ))
1320 eval cos${COS}_jbd=$((avgjbd / 3))
1321 eval cos${COS}_time=$((avgtime / 3))
1324 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
1325 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
1326 [ "$cos0_jbd" != 0 ] &&
1327 echo "COS=1 vs COS=0 jbd: $(((cos1_jbd/cos0_jbd - 1) * 100)) %"
1328 [ "$cos0_time" != 0 ] &&
1329 echo "COS=1 vs COS=0 time: $(((cos1_time/cos0_time - 1) * 100)) %"
1331 restore_lustre_params < $param_file
1335 run_test 33b "COS: cross create/delete, 2 clients, benchmark under remote dir"
1337 # arg1 is description, arg2 is operations before Sync-on-Lock-Cancel, arg3 is
1338 # the operation that triggers SoLC
1342 local nodes=$(comma_list $(mdts_nodes))
1346 # trigger CoS twice in case transaction commit before unlock
1349 do_nodes $nodes "$LCTL set_param -n mdt.*.sync_count=0"
1351 sync_count=$(do_nodes $nodes \
1352 "lctl get_param -n mdt.*MDT*.sync_count" | calc_sum)
1353 total=$((total + sync_count));
1361 echo " SoLC count $total"
1362 (( total > 0 )) || error "$3 didn't trigger SoLC"
1372 (( MDSCOUNT >= 2 )) || skip "needs >= 2 MDTs"
1373 (( MDS1_VERSION >= $(version_code 2.7.63) )) ||
1374 skip "DNE CoS not supported"
1378 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS || error "start mds1 failed"
1380 mkdir_on_mdt0 $DIR/$tdir
1383 if (( MDS1_VERSION < $(version_code 2.15.55.204) )); then
1384 op_trigger_solc "create remote dir and local dir" \
1385 "$LFS mkdir -i 1 $DIR/$tdir/remote" \
1386 "$LFS mkdir -i 0 $DIR/$tdir/local"
1387 (( MDSCOUNT > 2 )) &&
1388 op_trigger_solc "create remote dirs on different MDTs" \
1389 "$LFS mkdir -i 1 $DIR/$tdir/remote.1" \
1390 "$LFS mkdir -i 2 $DIR/$tdir/remote.2"
1392 op_trigger_solc "create file on 2nd stripe under striped directory" \
1393 "$LFS mkdir -i 0 -c 2 $DIR/$tdir/striped" \
1394 "touch $DIR2/$tdir/striped/subfile"
1397 echo "Below operations shouldn't trigger Solc:"
1398 $LFS mkdir -i 0 -c 2 $DIR/$tdir/striped
1400 do_facet mds1 "lctl set_param -n mdt.*.sync_count=0"
1401 if (( MDS1_VERSION >= $(version_code 2.15.55.204) )); then
1402 test_33_run "create file on 2nd stripe after setattr" \
1403 "chmod 777 $DIR/$tdir/striped; \
1404 touch $DIR2/$tdir/striped/subfile"
1405 test_33_run "create remote dir and local dir" \
1406 "$LFS mkdir -i 1 $DIR/$tdir/remote" \
1407 "$LFS mkdir -i 0 $DIR/$tdir/local"
1408 (( MDSCOUNT > 2 )) &&
1409 test_33_run "create remote dirs on different MDTs" \
1410 "$LFS mkdir -i 1 $DIR/$tdir/remote.1" \
1411 "$LFS mkdir -i 2 $DIR/$tdir/remote.2"
1413 test_33_run "create local dir after remote dir creation transaction commit" \
1414 "$LFS mkdir -i 1 $DIR/$tdir/remote.3; \
1415 do_facet mds2 $LCTL set_param -n osd*.*MDT0001.force_sync 1;
1416 mkdir $DIR/$tdir/local.3"
1417 sync_count=$(do_facet mds1 "lctl get_param -n mdt.*MDT0000.sync_count")
1418 echo "Solc count $sync_count"
1419 [ $sync_count -eq 0 ] || error "Sync-Lock-Cancel triggered"
1421 run_test 33c "Cancel cross-MDT lock should trigger Sync-on-Lock-Cancel"
1423 # arg1 is description, arg2 is operations done before CoS, arg3 is the operation
1428 local nodes=$(comma_list $(mdts_nodes))
1432 # trigger CoS twice in case transaction commit before unlock
1435 do_nodes $nodes "lctl set_param -n mdt.*.async_commit_count=0"
1437 commit_nr=$(do_nodes $nodes \
1438 "lctl get_param -n mdt.*.async_commit_count" | calc_sum)
1439 total=$((total + commit_nr));
1447 echo " CoS count $total"
1448 (( total > 0 )) || error "$3 didn't trigger CoS"
1452 (( MDSCOUNT > 1 )) || skip "needs >= 2 MDTs"
1453 (( MDS1_VERSION >= $(version_code 2.7.63) )) ||
1454 skip "DNE CoS not supported"
1456 if (( $MDS1_VERSION < $(version_code 2.15.55.133) )); then
1457 op_trigger_cos "remote directory unlink" \
1458 "$LFS mkdir -i 1 $DIR/$tdir" "rmdir $DIR2/$tdir"
1459 op_trigger_cos "striped directory create" "mkdir $DIR/$tdir" \
1460 "$LFS mkdir -c 2 $DIR2/$tdir/subdir"
1461 op_trigger_cos "striped directory setattr" \
1462 "$LFS mkdir -c 2 $DIR/$tdir" "chmod 713 $DIR2/$tdir"
1463 op_trigger_cos "striped directory unlink" \
1464 "$LFS mkdir -c 2 $DIR/$tdir" "rmdir $DIR2/$tdir"
1465 op_trigger_cos "cross-MDT link" \
1466 "mkdir $DIR/$tdir; \
1467 $LFS mkdir -i 0 $DIR/$tdir/d1; \
1468 $LFS mkdir -i 1 $DIR/$tdir/d2; \
1469 touch $DIR/$tdir/d1/tgt" \
1470 "ln $DIR2/$tdir/d1/tgt $DIR2/$tdir/d2/src"
1473 op_trigger_cos "remote directory create" "$LFS mkdir -i 0 $DIR/$tdir" \
1474 "$LFS mkdir -i 1 $DIR2/$tdir/subdir"
1475 op_trigger_cos "cross-MDT rename" \
1476 "mkdir $DIR/$tdir; \
1477 $LFS mkdir -i 0 $DIR/$tdir/d1; \
1478 $LFS mkdir -i 1 $DIR/$tdir/d2; \
1479 touch $DIR/$tdir/d1/src" \
1480 "mv $DIR2/$tdir/d1/src $DIR2/$tdir/d2/tgt"
1481 op_trigger_cos "migrate" \
1482 "$LFS mkdir -i 0 $DIR/$tdir" \
1483 "$LFS migrate -m 1 $DIR2/$tdir"
1487 run_test 33d "dependent transactions should trigger COS"
1490 (( MDSCOUNT > 1 )) || skip "needs >= 2 MDTs"
1491 (( MDS1_VERSION >= $(version_code 2.7.63) )) ||
1492 skip "DNE CoS not supported"
1494 $LFS mkdir -i 0 $DIR/$tdir
1495 $LFS mkdir -i 0 $DIR/$tdir/d1
1496 $LFS mkdir -i 1 $DIR/$tdir/d2
1498 local nodes=$(comma_list $(mdts_nodes))
1499 do_nodes $nodes "lctl set_param -n mdt.*.async_commit_count=0"
1501 test_33_run "plain dir creation" "mkdir $DIR2/$tdir/plain"
1502 test_33_run "open file and write" "echo abc > $DIR2/$tdir/$tfile"
1503 test_33_run "append write" "echo dfg >> $DIR2/$tdir/$tfile"
1504 test_33_run "setattr" "touch $DIR2/$tdir/$tfile"
1505 test_33_run "file unlink" "rm $DIR2/$tdir/$tfile"
1506 test_33_run "plain dir unlink" "rmdir $DIR2/$tdir/plain"
1507 if (( MDS1_VERSION >= $(version_code 2.15.55.133) )); then
1508 test_33_run "striped directory creation" \
1509 "$LFS mkdir -i 0 -c 2 $DIR2/$tdir/striped"
1510 test_33_run "set default LMV to create striped subdir" \
1511 "$LFS setdirstripe -D -c 2 $DIR/$tdir"
1512 test_33_run "striped subdir creation" \
1513 "createmany -d $DIR/$tdir/subdir 100"
1514 test_33_run "sub file creation and write" \
1515 "createmany -o $DIR/$tdir/subfile 100; \
1516 echo abc > $DIR/$tdir/subfile1"
1517 test_33_run "sub file append write" \
1518 "echo dfg >> $DIR2/$tdir/subfile2"
1519 test_33_run "subdir setatttr" "touch $DIR2/$tdir/subdir1"
1520 test_33_run "subdir unlink" \
1521 "unlinkmany -d $DIR/$tdir/subdir 100"
1522 test_33_run "sub file unlink" \
1523 "unlinkmany $DIR2/$tdir/subfile 100"
1524 test_33_run "sub file creation follows striped dir chmod" \
1525 "chmod 777 $DIR/$tdir/striped; \
1526 touch $DIR/$tdir/striped/subfile"
1527 test_33_run "striped directory unlink" \
1528 "rm -rf $DIR2/$tdir/striped"
1531 test_33_run "directory unlink" "rm -rf $DIR2/$tdir"
1533 local async_commit_count=$(do_nodes $nodes \
1534 "lctl get_param -n mdt.*.async_commit_count" | calc_sum)
1535 echo "CoS count $async_commit_count"
1536 (( async_commit_count == 0 )) || error "CoS triggerred"
1538 run_test 33e "independent transactions shouldn't trigger COS"
1540 # End commit on sharing tests
1542 get_ost_lock_timeouts() {
1543 local nodes=${1:-$(comma_list $(osts_nodes))}
1545 local locks=$(do_nodes $nodes \
1546 "lctl get_param -n ldlm.namespaces.filter-*.lock_timeouts" | calc_sum)
1554 do_nodes $(comma_list $(osts_nodes)) \
1555 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1556 for i in $(seq $OSTCOUNT); do
1557 wait_osc_import_ready client ost$i
1562 remote_ost_nodsh && skip "remote OST with nodsh" && return
1566 trap cleanup_34 EXIT RETURN
1567 for OPER in notimeout timeout ; do
1568 rm $DIR1/$tfile 2>/dev/null
1569 lock_in=$(get_ost_lock_timeouts)
1570 if [ $OPER == "timeout" ] ; then
1571 for j in `seq $OSTCOUNT`; do
1572 #define OBD_FAIL_PTLRPC_HPREQ_TIMEOUT 0x511
1573 do_facet ost$j lctl set_param fail_loc=0x511
1575 echo lock should expire
1577 for j in `seq $OSTCOUNT`; do
1578 #define OBD_FAIL_PTLRPC_HPREQ_NOTIMEOUT 0x512
1579 do_facet ost$j lctl set_param fail_loc=0x512
1581 echo lock should not expire
1583 echo writing on client1
1584 dd if=/dev/zero of=$DIR1/$tfile count=100 conv=notrunc > /dev/null 2>&1
1586 echo reading on client2
1587 dd of=/dev/null if=$DIR2/$tfile > /dev/null 2>&1
1588 # wait for a lock timeout
1590 lock_out=$(get_ost_lock_timeouts)
1591 if [ $OPER == "timeout" ] ; then
1592 if [ $lock_in == $lock_out ]; then
1593 error "no lock timeout happened"
1598 if [ $lock_in != $lock_out ]; then
1599 error "lock timeout happened"
1607 run_test 34 "no lock timeout under IO"
1609 test_35() { # bug 17645
1612 gen=$(lctl get_param mdc.$FSNAME-MDT*-mdc-*.import | grep generation |
1613 awk '/generation/{print $2}')
1615 generation[count]=$g
1619 test_mkdir $MOUNT1/$tdir
1620 cancel_lru_locks mdc
1622 # Let's initiate -EINTR situation by setting fail_loc and take
1623 # write lock on same file from same client. This will not cause
1624 # bl_ast yet as lock is already in local cache.
1625 #define OBD_FAIL_LDLM_INTR_CP_AST 0x317
1626 do_facet client "lctl set_param fail_loc=0x80000317"
1627 local timeout=$(do_facet $SINGLEMDS lctl get_param -n timeout)
1628 let timeout=timeout*3
1630 while test $nr -lt 10; do
1631 log "Race attempt $nr"
1632 local blk1=$(lctl get_param -n ldlm.services.ldlm_cbd.stats |
1633 awk '/ldlm_bl_callback/ { print $2 }')
1634 test "x$blk1" = "x" && blk1=0
1635 createmany -o $MOUNT2/$tdir/a 4000 &
1639 # Let's make conflict and bl_ast
1640 ls -la $MOUNT1/$tdir > /dev/null &
1643 log "Wait for $pid1 $pid2 for $timeout sec..."
1645 kill -9 $pid1 $pid2 > /dev/null 2>&1
1647 local blk2=$(lctl get_param -n ldlm.services.ldlm_cbd.stats |
1648 awk '/ldlm_bl_callback/ { print $2 }')
1649 test "x$blk2" = "x" && blk2=0
1650 test $blk2 -gt $blk1 && break
1651 rm -fr $MOUNT1/$tdir
1652 cancel_lru_locks mdc
1655 do_facet client "lctl set_param fail_loc=0x0"
1656 df -h $MOUNT1 $MOUNT2
1658 gen=$(lctl get_param mdc.$FSNAME-MDT*-mdc-*.import | grep generation |
1659 awk '/generation/{print $2}')
1661 if ! test "$g" -eq "${generation[count]}"; then
1662 list=$(lctl list_param mdc.$FSNAME-MDT*-mdc-*.import)
1664 for imp in $list; do
1665 if [ $c = $count ]; then
1670 imp=$(echo "$imp" | awk -F"." '{print $2}')
1671 error "Eviction happened on import $imp"
1676 run_test 35 "-EINTR cp_ast vs. bl_ast race does not evict client"
1678 test_36() { #bug 16417
1683 test_mkdir $DIR1/$tdir
1684 $LFS setstripe -c -1 $DIR1/$tdir
1687 let SIZE_B=SIZE*1024*1024
1688 sync; sleep 2; sync # wait for delete thread
1689 wait_mds_ost_sync || error "wait_mds_ost_sync failed"
1690 wait_destroy_complete || error "wait_destroy_complete failed"
1692 while [ $i -le 10 ]; do
1693 lctl mark "start test - cycle ($i)"
1694 local before=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1695 dd if=/dev/zero of=$DIR1/$tdir/$tfile bs=1M count=$SIZE ||
1696 error "dd $DIR1/$tdir/$tfile ${SIZE}MB failed"
1697 sync # sync data from client cache
1698 sync_all_data # sync data from server cache (delayed allocation)
1700 local after_dd=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1701 multiop_bg_pause $DIR2/$tdir/$tfile O_r${SIZE_B}c || return 3
1703 rm -f $DIR1/$tdir/$tfile
1704 kill -USR1 $read_pid
1706 sync; sleep 2; sync # Ensure new statfs
1707 wait_delete_completed
1708 local after=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1709 echo "*** cycle($i) *** before($before) after_dd($after_dd)" \
1711 # this free space! not used
1712 (( $after_dd <= $after)) ||
1713 error "space leaked after_dd:$after_dd > after:$after"
1717 run_test 36 "handle ESTALE/open-unlink correctly"
1719 test_37() { # bug 18695
1720 test_mkdir $DIR1/$tdir
1721 multiop_bg_pause $DIR1/$tdir D_c || return 1
1723 # create large directory (32kB seems enough from e2fsck, ~= 1000 files)
1724 createmany -m $DIR2/$tdir/f 10000
1725 # set mtime/atime backward
1726 touch -t 198001010000 $DIR2/$tdir
1727 kill -USR1 $MULTIPID
1728 nr_files=`lfs find $DIR1/$tdir -type f | wc -l`
1729 [ $nr_files -eq 10000 ] || error "$nr_files != 10000 truncated directory?"
1732 run_test 37 "check i_size is not updated for directory on close (bug 18695) =============="
1734 # this should be set to past
1735 TEST_39_MTIME=`date -d "1 year ago" +%s`
1739 local client1=${CLIENT1:-`hostname`}
1740 local client2=${CLIENT2:-`hostname`}
1742 do_node $client1 "touch $DIR1/$tfile"
1744 do_node $client1 "touch -m -d @$TEST_39_MTIME $DIR1/$tfile"
1745 local mtime1=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1746 [ "$mtime1" = $TEST_39_MTIME ] || \
1747 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
1749 local d1=`do_node $client1 date +%s`
1750 do_node $client1 'echo hello >> '$DIR1/$tfile
1751 local d2=`do_node $client1 date +%s`
1753 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1754 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
1755 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
1757 do_node $client1 "mv $DIR1/$tfile $DIR1/$tfile-1"
1759 for (( i=0; i < 2; i++ )) ; do
1760 local mtime3=`do_node $client2 "stat -c %Y $DIR1/$tfile-1"`
1761 [ "$mtime2" = "$mtime3" ] || \
1762 error "mtime ($mtime2) changed (to $mtime3) on rename"
1764 cancel_lru_locks osc
1765 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1768 run_test 39a "test from 11063 =================================="
1771 local client1=${CLIENT1:-`hostname`}
1772 local client2=${CLIENT2:-`hostname`}
1776 local mtime1=`stat -c %Y $DIR1/$tfile`
1777 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1780 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
1782 for (( i=0; i < 2; i++ )) ; do
1783 local mtime3=`stat -c %Y $DIR1/$tfile`
1784 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1786 [ "$mtime3" = "$mtime4" ] || \
1787 error "different mtime on clients: $mtime3, $mtime4"
1788 [ "$mtime3" = $TEST_39_MTIME ] || \
1789 error "lost mtime: $mtime3, should be $TEST_39_MTIME"
1791 cancel_lru_locks osc
1792 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1795 run_test 39b "11063 problem 1 =================================="
1798 local client1=${CLIENT1:-`hostname`}
1799 local client2=${CLIENT2:-`hostname`}
1801 echo hello > $DIR1/$tfile
1803 local mtime1=`stat -c %Y $DIR1/$tfile`
1804 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1805 [ "$mtime1" = "$mtime2" ] || \
1806 error "create: different mtime on clients: $mtime1, $mtime2"
1809 $TRUNCATE $DIR1/$tfile 1
1811 for (( i=0; i < 2; i++ )) ; do
1812 local mtime3=`stat -c %Y $DIR1/$tfile`
1813 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1815 [ "$mtime3" = "$mtime4" ] || \
1816 error "different mtime on clients: $mtime3, $mtime4"
1817 [ "$mtime3" -gt $mtime2 ] || \
1818 error "truncate did not update mtime: $mtime2, $mtime3"
1820 cancel_lru_locks osc
1821 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1824 run_test 39c "check truncate mtime update ======================"
1826 test_39d() { # LU-7310
1828 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
1830 local mtime1=$(stat -c %Y $DIR2/$tfile)
1831 [ "$mtime1" = $TEST_39_MTIME ] ||
1832 error "mtime: $mtime1, should be $TEST_39_MTIME"
1835 # define OBD_FAIL_OSC_NO_GRANT 0x411
1836 $LCTL set_param fail_loc=0x411
1838 local d1=$(date +%s)
1839 echo hello >> $DIR1/$tfile
1840 local d2=$(date +%s)
1842 $LCTL set_param fail_loc=0
1844 cancel_lru_locks $OSC
1846 local mtime2=$(stat -c %Y $DIR2/$tfile)
1847 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] ||
1848 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
1850 run_test 39d "sync write should update mtime"
1853 # how long 40-47 take with specific delay
1860 # for pdo testing, we must cancel MDT-MDT locks as well as client locks to
1861 # avoid unexpected delays due to previous tests
1863 cancel_lru_locks mdc
1864 do_nodes $(comma_list $(mdts_nodes)) \
1865 $LCTL set_param -n ldlm.namespaces.*mdt*.lru_size=clear
1866 do_nodes $(comma_list $(mdts_nodes)) \
1867 $LCTL get_param ldlm.namespaces.*mdt*.lock_unused_count \
1868 ldlm.namespaces.*mdt*.lock_count | grep -v '=0'
1871 # check that pid exists hence second operation wasn't blocked by first one
1872 # if it is so then there is no conflict, return 0
1873 # else second operation is conflicting with first one, return 1
1874 check_pdo_conflict() {
1877 pdo_sched # to ensure OP1 is finished on client if OP2 is blocked by OP1
1878 if [[ `ps --pid $pid | wc -l` == 1 ]]; then
1888 # test 40: check non-blocking operations
1890 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1892 mkdir_on_mdt0 $DIR2/$tdir
1894 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1895 do_nodes $(comma_list $(mdts_nodes)) \
1896 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1897 mkdir $DIR1/$tdir/$tfile &
1899 touch $DIR2/$tdir/$tfile-2
1900 check_pdo_conflict $PID1 || error "create is blocked"
1901 mkdir $DIR2/$tdir/$tfile-3
1902 check_pdo_conflict $PID1 || error "mkdir is blocked"
1903 link $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-4
1904 check_pdo_conflict $PID1 || error "link is blocked"
1905 mv $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-5
1906 check_pdo_conflict $PID1 || error "rename is blocked"
1907 stat $DIR2/$tdir/$tfile-3 $DIR2/$tdir/$tfile-4 > /dev/null
1908 check_pdo_conflict $PID1 || error "getattr is blocked"
1909 rm $DIR2/$tdir/$tfile-4 $DIR2/$tdir/$tfile-5
1910 rmdir $DIR2/$tdir/$tfile-3
1911 check_pdo_conflict $PID1 || error "unlink is blocked"
1913 # all operations above shouldn't wait the first one
1914 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1915 do_nodes $(comma_list $(mdts_nodes)) \
1916 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1921 run_test 40a "pdirops: create vs others =============="
1924 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1926 mkdir_on_mdt0 $DIR2/$tdir
1928 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1929 do_nodes $(comma_list $(mdts_nodes)) \
1930 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1931 touch $DIR1/$tdir/$tfile &
1934 touch $DIR2/$tdir/$tfile-2
1935 check_pdo_conflict $PID1 || error "create is blocked"
1936 mkdir $DIR2/$tdir/$tfile-3
1937 check_pdo_conflict $PID1 || error "mkdir is blocked"
1938 link $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-4
1939 check_pdo_conflict $PID1 || error "link is blocked"
1940 mv $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-5
1941 check_pdo_conflict $PID1 || error "rename is blocked"
1942 stat $DIR2/$tdir/$tfile-3 $DIR2/$tdir/$tfile-4 > /dev/null
1943 check_pdo_conflict $PID1 || error "getattr is blocked"
1944 rm $DIR2/$tdir/$tfile-4 $DIR2/$tdir/$tfile-5
1945 rmdir $DIR2/$tdir/$tfile-3
1946 check_pdo_conflict $PID1 || error "unlink is blocked"
1947 # all operations above shouldn't wait the first one
1949 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1950 do_nodes $(comma_list $(mdts_nodes)) \
1951 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1956 run_test 40b "pdirops: open|create and others =============="
1959 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1961 mkdir_on_mdt0 $DIR2/$tdir
1963 touch $DIR1/$tdir/$tfile
1964 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1965 do_nodes $(comma_list $(mdts_nodes)) \
1966 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1967 link $DIR1/$tdir/$tfile $DIR1/$tdir/$tfile-0 &
1970 touch $DIR2/$tdir/$tfile-2
1971 check_pdo_conflict $PID1 || error "create is blocked"
1972 mkdir $DIR2/$tdir/$tfile-3
1973 check_pdo_conflict $PID1 || error "mkdir is blocked"
1974 link $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-4
1975 check_pdo_conflict $PID1 || error "link is blocked"
1976 mv $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-5
1977 check_pdo_conflict $PID1 || error "rename is blocked"
1978 stat $DIR2/$tdir/$tfile-3 $DIR2/$tdir/$tfile-4 > /dev/null
1979 check_pdo_conflict $PID1 || error "getattr is blocked"
1980 rm $DIR2/$tdir/$tfile-4 $DIR2/$tdir/$tfile-5
1981 rmdir $DIR2/$tdir/$tfile-3
1982 check_pdo_conflict $PID1 || error "unlink is blocked"
1984 # all operations above shouldn't wait the first one
1985 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1986 do_nodes $(comma_list $(mdts_nodes)) \
1987 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1992 run_test 40c "pdirops: link and others =============="
1995 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1997 mkdir_on_mdt0 $DIR2/$tdir
1999 touch $DIR1/$tdir/$tfile
2000 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2001 do_nodes $(comma_list $(mdts_nodes)) \
2002 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2003 rm $DIR1/$tdir/$tfile &
2006 touch $DIR2/$tdir/$tfile-2
2007 check_pdo_conflict $PID1 || error "create is blocked"
2008 mkdir $DIR2/$tdir/$tfile-3
2009 check_pdo_conflict $PID1 || error "mkdir is blocked"
2010 link $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-4
2011 check_pdo_conflict $PID1 || error "link is blocked"
2012 mv $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-5
2013 check_pdo_conflict $PID1 || error "rename is blocked"
2014 stat $DIR2/$tdir/$tfile-3 $DIR2/$tdir/$tfile-4 > /dev/null
2015 check_pdo_conflict $PID1 || error "getattr is blocked"
2016 rm $DIR2/$tdir/$tfile-4 $DIR2/$tdir/$tfile-5
2017 rmdir $DIR2/$tdir/$tfile-3
2018 check_pdo_conflict $PID1 || error "unlink is blocked"
2020 # all operations above shouldn't wait the first one
2021 check_pdo_conflict $PID1 || error "parallel operation is blocked"
2022 do_nodes $(comma_list $(mdts_nodes)) \
2023 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2027 run_test 40d "pdirops: unlink and others =============="
2030 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2032 mkdir_on_mdt0 $DIR2/$tdir
2034 touch $DIR1/$tdir/$tfile
2035 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2036 do_nodes $(comma_list $(mdts_nodes)) \
2037 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2038 mv $DIR1/$tdir/$tfile $DIR1/$tdir/$tfile-0 &
2041 touch $DIR2/$tdir/$tfile-2
2042 check_pdo_conflict $PID1 || error "create is blocked"
2043 mkdir $DIR2/$tdir/$tfile-3
2044 check_pdo_conflict $PID1 || error "mkdir is blocked"
2045 link $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-4
2046 check_pdo_conflict $PID1 || error "link is blocked"
2047 stat $DIR2/$tdir/$tfile-3 $DIR2/$tdir/$tfile-4 > /dev/null
2048 check_pdo_conflict $PID1 || error "getattr is blocked"
2049 rm $DIR2/$tdir/$tfile-4 $DIR2/$tdir/$tfile-2
2050 rmdir $DIR2/$tdir/$tfile-3
2051 check_pdo_conflict $PID1 || error "unlink is blocked"
2053 # all operations above shouldn't wait the first one
2054 check_pdo_conflict $PID1 || error "parallel operation is blocked"
2055 do_nodes $(comma_list $(mdts_nodes)) \
2056 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2061 run_test 40e "pdirops: rename and others =============="
2063 # test 41: create blocking operations
2066 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2067 do_nodes $(comma_list $(mdts_nodes)) \
2068 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2069 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
2071 mkdir $DIR2/$tfile &
2073 do_nodes $(comma_list $(mdts_nodes)) \
2074 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2075 check_pdo_conflict $PID1 && { wait $PID1; echo "mkdir isn't blocked"; }
2076 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
2080 run_test 41a "pdirops: create vs mkdir =============="
2084 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2085 do_nodes $(comma_list $(mdts_nodes)) \
2086 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2087 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
2089 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2091 do_nodes $(comma_list $(mdts_nodes)) \
2092 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2093 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2094 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
2098 run_test 41b "pdirops: create vs create =============="
2102 touch $DIR1/$tfile-2
2103 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2104 do_nodes $(comma_list $(mdts_nodes)) \
2105 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2106 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
2108 link $DIR2/$tfile-2 $DIR2/$tfile &
2110 do_nodes $(comma_list $(mdts_nodes)) \
2111 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2112 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2113 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
2117 run_test 41c "pdirops: create vs link =============="
2121 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2122 do_nodes $(comma_list $(mdts_nodes)) \
2123 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2124 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
2128 do_nodes $(comma_list $(mdts_nodes)) \
2129 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2130 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2131 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
2135 run_test 41d "pdirops: create vs unlink =============="
2139 touch $DIR1/$tfile-2
2140 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2141 do_nodes $(comma_list $(mdts_nodes)) \
2142 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2143 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
2145 mv $DIR2/$tfile-2 $DIR2/$tfile &
2147 do_nodes $(comma_list $(mdts_nodes)) \
2148 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2149 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2150 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2154 run_test 41e "pdirops: create and rename (tgt) =============="
2158 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2159 do_nodes $(comma_list $(mdts_nodes)) \
2160 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2161 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
2163 mv $DIR2/$tfile $DIR2/$tfile-2 &
2165 do_nodes $(comma_list $(mdts_nodes)) \
2166 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2167 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2168 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2172 run_test 41f "pdirops: create and rename (src) =============="
2176 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2177 do_nodes $(comma_list $(mdts_nodes)) \
2178 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2179 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
2181 stat $DIR2/$tfile > /dev/null &
2183 do_nodes $(comma_list $(mdts_nodes)) \
2184 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2185 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2186 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
2190 run_test 41g "pdirops: create vs getattr =============="
2194 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2195 do_nodes $(comma_list $(mdts_nodes)) \
2196 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2197 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
2199 ls -lia $DIR2/ > /dev/null &
2201 do_nodes $(comma_list $(mdts_nodes)) \
2202 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2203 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2208 run_test 41h "pdirops: create vs readdir =============="
2215 do_nodes $(comma_list $(mdts_nodes)) \
2216 "lctl set_param -n fail_loc=${fail_loc} || true" &>/dev/null
2218 $MULTIOP $DIR1/$tfile oO_CREAT:O_EXCL:c 2>/dev/null &
2221 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c 2>/dev/null &
2224 if ! wait $PID1 && ! wait $PID2; then
2225 echo "Both creates failed (1 should fail, 1 should succeed)"
2227 elif wait $PID1 && wait $PID2; then
2228 echo "Both creates succeeded (1 should fail, 1 should succeed)"
2233 do_nodes $(comma_list $(mdts_nodes)) \
2234 "lctl set_param -n fail_loc=0x0 || true" &>/dev/null
2241 (( $MDS1_VERSION >= $(version_code 2.13.56) )) ||
2242 skip "Need MDS version newer than 2.13.56"
2245 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN 0x169
2246 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN2 0x16a
2247 for fail_loc in "0x80000169" "0x8000016a"; do
2248 echo "Begin 100 tests with fail_loc=$fail_loc"
2250 for i in {1..100}; do
2252 msg=$(sub_test_41i "$fail_loc") ||
2253 { echo; error "iter=$i : $msg"; }
2258 run_test 41i "reint_open: create vs create"
2261 # test 42: unlink and blocking operations
2264 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2265 do_nodes $(comma_list $(mdts_nodes)) \
2266 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2267 mkdir $DIR1/$tfile &
2269 mkdir $DIR2/$tfile &
2271 do_nodes $(comma_list $(mdts_nodes)) \
2272 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2273 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2274 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
2278 run_test 42a "pdirops: mkdir vs mkdir =============="
2282 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2283 do_nodes $(comma_list $(mdts_nodes)) \
2284 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2285 mkdir $DIR1/$tfile &
2287 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2289 do_nodes $(comma_list $(mdts_nodes)) \
2290 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2291 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2292 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
2296 run_test 42b "pdirops: mkdir vs create =============="
2300 touch $DIR1/$tfile-2
2301 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2302 do_nodes $(comma_list $(mdts_nodes)) \
2303 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2304 mkdir $DIR1/$tfile &
2306 link $DIR2/$tfile-2 $DIR2/$tfile &
2308 do_nodes $(comma_list $(mdts_nodes)) \
2309 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2310 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2311 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
2315 run_test 42c "pdirops: mkdir vs link =============="
2319 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2320 do_nodes $(comma_list $(mdts_nodes)) \
2321 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2322 mkdir $DIR1/$tfile &
2324 rmdir $DIR2/$tfile &
2326 do_nodes $(comma_list $(mdts_nodes)) \
2327 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2328 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2329 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
2333 run_test 42d "pdirops: mkdir vs unlink =============="
2337 touch $DIR1/$tfile-2
2338 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2339 do_nodes $(comma_list $(mdts_nodes)) \
2340 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2341 mkdir $DIR1/$tfile &
2343 mv -T $DIR2/$tfile-2 $DIR2/$tfile &
2345 do_nodes $(comma_list $(mdts_nodes)) \
2346 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2347 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2348 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
2352 run_test 42e "pdirops: mkdir and rename (tgt) =============="
2356 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2357 do_nodes $(comma_list $(mdts_nodes)) \
2358 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2359 mkdir $DIR1/$tfile &
2361 mv $DIR2/$tfile $DIR2/$tfile-2 &
2363 do_nodes $(comma_list $(mdts_nodes)) \
2364 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2365 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2366 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2370 run_test 42f "pdirops: mkdir and rename (src) =============="
2373 mkdir_on_mdt0 $DIR1/$tdir
2375 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2376 do_nodes $(comma_list $(mdts_nodes)) \
2377 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2378 mkdir $DIR1/$tdir/$tfile &
2380 stat $DIR2/$tdir/$tfile > /dev/null &
2382 do_nodes $(comma_list $(mdts_nodes)) \
2383 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2384 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2385 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
2388 run_test 42g "pdirops: mkdir vs getattr =============="
2392 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2393 do_nodes $(comma_list $(mdts_nodes)) \
2394 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2395 mkdir $DIR1/$tfile &
2397 ls -lia $DIR2/ > /dev/null &
2399 do_nodes $(comma_list $(mdts_nodes)) \
2400 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2401 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2406 run_test 42h "pdirops: mkdir vs readdir =============="
2408 # test 43: rmdir,mkdir won't return -EEXIST
2410 for i in {1..1000}; do
2411 mkdir $DIR1/$tdir || error "mkdir $tdir failed"
2412 rmdir $DIR2/$tdir || error "rmdir $tdir failed"
2416 run_test 43a "rmdir,mkdir doesn't return -EEXIST =============="
2421 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2422 do_nodes $(comma_list $(mdts_nodes)) \
2423 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2426 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2428 do_nodes $(comma_list $(mdts_nodes)) \
2429 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2430 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2431 wait $PID2 ; [ $? -eq 0 ] || error "create must succeed"
2435 run_test 43b "pdirops: unlink vs create =============="
2440 touch $DIR1/$tfile-2
2441 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2442 do_nodes $(comma_list $(mdts_nodes)) \
2443 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2446 link $DIR2/$tfile-2 $DIR2/$tfile &
2448 do_nodes $(comma_list $(mdts_nodes)) \
2449 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2450 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2451 wait $PID2 ; [ $? -eq 0 ] || error "link must succeed"
2455 run_test 43c "pdirops: unlink vs link =============="
2460 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2461 do_nodes $(comma_list $(mdts_nodes)) \
2462 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2467 do_nodes $(comma_list $(mdts_nodes)) \
2468 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2469 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2470 wait $PID2 ; [ $? -ne 0 ] || error "unlink must fail"
2474 run_test 43d "pdirops: unlink vs unlink =============="
2479 touch $DIR1/$tfile-2
2480 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2481 do_nodes $(comma_list $(mdts_nodes)) \
2482 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2485 mv -u $DIR2/$tfile-2 $DIR2/$tfile &
2487 do_nodes $(comma_list $(mdts_nodes)) \
2488 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2489 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2490 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2494 run_test 43e "pdirops: unlink and rename (tgt) =============="
2499 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2500 do_nodes $(comma_list $(mdts_nodes)) \
2501 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2504 mv $DIR2/$tfile $DIR2/$tfile-2 &
2506 do_nodes $(comma_list $(mdts_nodes)) \
2507 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2508 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2509 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
2513 run_test 43f "pdirops: unlink and rename (src) =============="
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 stat $DIR2/$tfile > /dev/null &
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 "getattr isn't blocked"; }
2528 wait $PID2 ; [ $? -ne 0 ] || error "stat must fail"
2532 run_test 43g "pdirops: unlink vs getattr =============="
2537 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2538 do_nodes $(comma_list $(mdts_nodes)) \
2539 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2542 ls -lia $DIR2/ > /dev/null &
2544 do_nodes $(comma_list $(mdts_nodes)) \
2545 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2546 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2551 run_test 43h "pdirops: unlink vs readdir =============="
2554 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
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"
2562 $LFS mkdir -i 1 $DIR2/$tfile &
2564 do_nodes $(comma_list $(mdts_nodes)) \
2565 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2566 check_pdo_conflict $PID1 &&
2567 { wait $PID1; error "remote mkdir isn't blocked"; }
2568 wait $PID2 ; [ $? -eq 0 ] || error "remote mkdir must succeed"
2572 run_test 43i "pdirops: unlink vs remote mkdir"
2575 [[ $MDS1_VERSION -lt $(version_code 2.13.52) ]] &&
2576 skip "Need MDS version newer than 2.13.52"
2578 mkdir_on_mdt0 $DIR1/$tdir
2579 for i in {1..100}; do
2580 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_CREATE_RACE 0x167
2581 do_nodes $(comma_list $(mdts_nodes)) \
2582 "lctl set_param -n fail_loc=0x80000167 2>/dev/null ||
2585 mkdir $DIR1/$tdir/sub &
2587 mkdir $DIR2/$tdir/sub && ((OK++))
2588 wait $PID1 && ((OK++))
2589 (( OK == 1 )) || error "exactly one mkdir should succeed"
2591 rmdir $DIR1/$tdir/sub || error "rmdir failed"
2595 run_test 43j "racy mkdir return EEXIST =============="
2602 # We test in a separate directory to be able to unblock server thread in
2603 # cfs_race() if LCK_PW is taken on the parent by mdt_reint_unlink.
2604 test_mkdir $DIR2/$tdir
2605 touch $DIR2/$tdir/$tfile
2608 do_nodes $(comma_list $(mdts_nodes)) \
2609 "lctl set_param -n fail_loc=${fail_loc} || true" &>/dev/null
2610 echo content > $DIR1/$tdir/$tfile & PID1=$!
2612 multiop $DIR2/$tdir/$tfile u & PID2=$!
2616 echo -n "overwriting $tfile should succeed (err=$ret); "; }
2619 echo -n "unlinking $tfile should succeed (err=$ret);"; }
2622 do_nodes $(comma_list $(mdts_nodes)) \
2623 "lctl set_param -n fail_loc=0x0 || true" &>/dev/null
2630 (( $MDS1_VERSION >= $(version_code 2.13.56) )) ||
2631 skip "Need MDS version newer than 2.13.56"
2634 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN 0x169
2635 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN2 0x16a
2636 for fail_loc in "0x80000169" "0x8000016a"; do
2637 echo "Begin 100 tests with fail_loc=$fail_loc"
2639 for i in {1..100}; do
2641 msg=$(sub_test_43k "$fail_loc") ||
2642 { echo; error "iter=$i : $msg"; }
2652 run_test 43k "unlink vs create"
2654 # test 44: rename tgt and blocking operations
2657 touch $DIR1/$tfile-2
2658 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2659 do_nodes $(comma_list $(mdts_nodes)) \
2660 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2661 mv $DIR1/$tfile-2 $DIR1/$tfile &
2663 mkdir $DIR2/$tfile &
2665 do_nodes $(comma_list $(mdts_nodes)) \
2666 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2667 check_pdo_conflict $PID1 && { wait $PID1; date;error "mkdir isn't blocked"; }
2668 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
2673 run_test 44a "pdirops: rename tgt vs mkdir =============="
2677 touch $DIR1/$tfile-2
2678 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2679 do_nodes $(comma_list $(mdts_nodes)) \
2680 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2681 mv $DIR1/$tfile-2 $DIR1/$tfile &
2683 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2685 do_nodes $(comma_list $(mdts_nodes)) \
2686 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2687 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2688 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
2692 run_test 44b "pdirops: rename tgt vs create =============="
2696 touch $DIR1/$tfile-2
2697 touch $DIR1/$tfile-3
2698 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2699 do_nodes $(comma_list $(mdts_nodes)) \
2700 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2701 mv $DIR1/$tfile-2 $DIR1/$tfile &
2703 link $DIR2/$tfile-3 $DIR2/$tfile &
2705 do_nodes $(comma_list $(mdts_nodes)) \
2706 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2707 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2708 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
2712 run_test 44c "pdirops: rename tgt vs link =============="
2716 touch $DIR1/$tfile-2
2717 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2718 do_nodes $(comma_list $(mdts_nodes)) \
2719 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2720 mv $DIR1/$tfile-2 $DIR1/$tfile &
2724 do_nodes $(comma_list $(mdts_nodes)) \
2725 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2726 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2727 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
2731 run_test 44d "pdirops: rename tgt vs unlink =============="
2736 touch $DIR1/$tfile-2
2737 touch $DIR1/$tfile-3
2738 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2739 do_nodes $(comma_list $(mdts_nodes)) \
2740 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2741 mv $DIR1/$tfile-2 $DIR1/$tfile &
2743 mv $DIR2/$tfile-3 $DIR2/$tfile &
2745 do_nodes $(comma_list $(mdts_nodes)) \
2746 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2747 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2748 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2752 run_test 44e "pdirops: rename tgt and rename (tgt) =============="
2756 touch $DIR1/$tfile-2
2757 touch $DIR1/$tfile-3
2758 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2759 do_nodes $(comma_list $(mdts_nodes)) \
2760 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2761 mv $DIR1/$tfile-2 $DIR1/$tfile &
2763 mv $DIR2/$tfile $DIR2/$tfile-3 &
2765 do_nodes $(comma_list $(mdts_nodes)) \
2766 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2767 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2768 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2772 run_test 44f "pdirops: rename tgt and rename (src) =============="
2776 touch $DIR1/$tfile-2
2777 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2778 do_nodes $(comma_list $(mdts_nodes)) \
2779 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2780 mv $DIR1/$tfile-2 $DIR1/$tfile &
2782 stat $DIR2/$tfile > /dev/null &
2784 do_nodes $(comma_list $(mdts_nodes)) \
2785 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2786 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2787 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
2791 run_test 44g "pdirops: rename tgt vs getattr =============="
2795 touch $DIR1/$tfile-2
2796 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2797 do_nodes $(comma_list $(mdts_nodes)) \
2798 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2799 mv $DIR1/$tfile-2 $DIR1/$tfile &
2801 ls -lia $DIR2/ > /dev/null &
2803 do_nodes $(comma_list $(mdts_nodes)) \
2804 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2805 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2810 run_test 44h "pdirops: rename tgt vs readdir =============="
2812 # test 44: rename tgt and blocking operations
2814 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2816 touch $DIR1/$tfile-2
2817 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2818 do_nodes $(comma_list $(mdts_nodes)) \
2819 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2820 mv $DIR1/$tfile-2 $DIR1/$tfile &
2822 $LFS mkdir -i 1 $DIR2/$tfile &
2824 do_nodes $(comma_list $(mdts_nodes)) \
2825 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2826 check_pdo_conflict $PID1 && { wait $PID1;
2827 error "remote mkdir isn't blocked"; }
2828 wait $PID2 ; [ $? -ne 0 ] || error "remote mkdir must fail"
2832 run_test 44i "pdirops: rename tgt vs remote mkdir"
2834 # test 45: rename,mkdir doesn't fail with -EEXIST
2836 for i in {1..1000}; do
2837 mkdir $DIR1/$tdir || error "mkdir $tdir failed"
2838 mrename $DIR2/$tdir $DIR2/$tdir.$i > /dev/null ||
2839 error "mrename to $tdir.$i failed"
2844 run_test 45a "rename,mkdir doesn't return -EEXIST =============="
2849 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2850 do_nodes $(comma_list $(mdts_nodes)) \
2851 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2852 mv $DIR1/$tfile $DIR1/$tfile-2 &
2854 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2856 do_nodes $(comma_list $(mdts_nodes)) \
2857 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2858 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2859 wait $PID2 ; [ $? -eq 0 ] || error "create must succeed"
2863 run_test 45b "pdirops: rename src vs create =============="
2868 touch $DIR1/$tfile-3
2869 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2870 do_nodes $(comma_list $(mdts_nodes)) \
2871 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2872 mv $DIR1/$tfile $DIR1/$tfile-2 &
2874 link $DIR2/$tfile-3 $DIR2/$tfile &
2876 do_nodes $(comma_list $(mdts_nodes)) \
2877 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2878 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2879 wait $PID2 ; [ $? -eq 0 ] || error "link must succeed"
2883 run_test 45c "pdirops: rename src vs link =============="
2888 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2889 do_nodes $(comma_list $(mdts_nodes)) \
2890 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2891 mv $DIR1/$tfile $DIR1/$tfile-2 &
2895 do_nodes $(comma_list $(mdts_nodes)) \
2896 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2897 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2898 wait $PID2 ; [ $? -ne 0 ] || error "unlink must fail"
2902 run_test 45d "pdirops: rename src vs unlink =============="
2907 touch $DIR1/$tfile-3
2908 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2909 do_nodes $(comma_list $(mdts_nodes)) \
2910 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2911 mv $DIR1/$tfile $DIR1/$tfile-2 &
2913 mv $DIR2/$tfile-3 $DIR2/$tfile &
2915 do_nodes $(comma_list $(mdts_nodes)) \
2916 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2917 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2918 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2922 run_test 45e "pdirops: rename src and rename (tgt) =============="
2927 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2928 do_nodes $(comma_list $(mdts_nodes)) \
2929 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2930 mv $DIR1/$tfile $DIR1/$tfile-2 &
2932 mv $DIR2/$tfile $DIR2/$tfile-3 &
2934 do_nodes $(comma_list $(mdts_nodes)) \
2935 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2936 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2937 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
2941 run_test 45f "pdirops: rename src and rename (src) =============="
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 stat $DIR2/$tfile > /dev/null &
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 "getattr isn't blocked"; }
2956 wait $PID2 ; [ $? -ne 0 ] || error "stat must fail"
2960 run_test 45g "pdirops: rename src vs getattr =============="
2965 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2966 do_nodes $(comma_list $(mdts_nodes)) \
2967 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2968 mv $DIR1/$tfile $DIR1/$tfile-2 &
2970 ls -lia $DIR2/ > /dev/null &
2971 do_nodes $(comma_list $(mdts_nodes)) \
2972 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2973 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2978 run_test 45h "pdirops: unlink vs readdir =============="
2981 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2984 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2985 do_nodes $(comma_list $(mdts_nodes)) \
2986 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2987 mv $DIR1/$tfile $DIR1/$tfile-2 &
2989 $LFS mkdir -i 1 $DIR2/$tfile &
2991 do_nodes $(comma_list $(mdts_nodes)) \
2992 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2993 check_pdo_conflict $PID1 && { wait $PID1;
2994 error "create remote dir isn't blocked"; }
2995 wait $PID2 ; [ $? -eq 0 ] || error "create remote dir must succeed"
2999 run_test 45i "pdirops: rename src vs remote mkdir"
3006 # We test in a sparate directory to be able to unblock server thread in
3007 # cfs_race if LCK_PW is taken on the parent by mdt_reint_rename.
3008 test_mkdir $DIR2/$tdir
3009 echo file1 > $DIR2/$tdir/$tfile
3010 echo file2 > $DIR2/$tdir/$tfile-2
3013 do_nodes $(comma_list $(mdts_nodes)) \
3014 "lctl set_param -n fail_loc=${fail_loc} || true" &>/dev/null
3016 cat $DIR1/$tdir/$tfile >/dev/null &
3019 mrename $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile > /dev/null &
3023 { ret=$?; echo -n "cat $tfile should succeed (err=$ret); "; }
3026 echo -n "mrename $tfile-2 to $tfile failed (err=$ret);"; }
3029 do_nodes $(comma_list $(mdts_nodes)) \
3030 "lctl set_param -n fail_loc=0x0 || true" &>/dev/null
3037 (( $MDS1_VERSION >= $(version_code 2.13.56) )) ||
3038 skip "Need MDS version newer than 2.13.56"
3041 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN 0x169
3042 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN2 0x16a
3043 for fail_loc in "0x80000169" "0x8000016a"; do
3044 echo "Begin 100 tests with fail_loc=$fail_loc"
3046 for i in {1..100}; do
3048 msg=$(sub_test_45j "$fail_loc") ||
3049 { echo; error "iter=$i : $msg"; }
3054 run_test 45j "read vs rename =============="
3056 # test 46: link and blocking operations
3059 touch $DIR1/$tfile-2
3060 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
3061 do_nodes $(comma_list $(mdts_nodes)) \
3062 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
3063 link $DIR1/$tfile-2 $DIR1/$tfile &
3065 mkdir $DIR2/$tfile &
3067 do_nodes $(comma_list $(mdts_nodes)) \
3068 "lctl set_param -n fail_loc=0 2>/dev/null || true"
3069 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
3070 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
3074 run_test 46a "pdirops: link vs mkdir =============="
3078 touch $DIR1/$tfile-2
3079 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
3080 do_nodes $(comma_list $(mdts_nodes)) \
3081 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
3082 link $DIR1/$tfile-2 $DIR1/$tfile &
3084 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
3086 do_nodes $(comma_list $(mdts_nodes)) \
3087 "lctl set_param -n fail_loc=0 2>/dev/null || true"
3088 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
3089 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
3093 run_test 46b "pdirops: link vs create =============="
3097 touch $DIR1/$tfile-2
3098 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
3099 do_nodes $(comma_list $(mdts_nodes)) \
3100 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
3101 link $DIR1/$tfile-2 $DIR1/$tfile &
3103 link $DIR2/$tfile $DIR2/$tfile &
3105 do_nodes $(comma_list $(mdts_nodes)) \
3106 "lctl set_param -n fail_loc=0 2>/dev/null || true"
3107 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
3108 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
3112 run_test 46c "pdirops: link vs link =============="
3116 touch $DIR1/$tfile-2
3117 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
3118 do_nodes $(comma_list $(mdts_nodes)) \
3119 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
3120 link $DIR1/$tfile-2 $DIR1/$tfile &
3124 do_nodes $(comma_list $(mdts_nodes)) \
3125 "lctl set_param -n fail_loc=0 2>/dev/null || true"
3126 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
3127 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
3131 run_test 46d "pdirops: link vs unlink =============="
3135 touch $DIR1/$tfile-2
3136 touch $DIR1/$tfile-3
3137 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
3138 do_nodes $(comma_list $(mdts_nodes)) \
3139 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
3140 link $DIR1/$tfile-2 $DIR1/$tfile &
3142 mv $DIR2/$tfile-3 $DIR2/$tfile &
3144 do_nodes $(comma_list $(mdts_nodes)) \
3145 "lctl set_param -n fail_loc=0 2>/dev/null || true"
3146 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
3147 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
3151 run_test 46e "pdirops: link and rename (tgt) =============="
3155 touch $DIR1/$tfile-2
3156 touch $DIR1/$tfile-3
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 mv $DIR2/$tfile $DIR2/$tfile-3 &
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 "rename isn't blocked"; }
3167 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
3171 run_test 46f "pdirops: link and rename (src) =============="
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 stat $DIR2/$tfile > /dev/null &
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 "getattr isn't blocked"; }
3186 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
3190 run_test 46g "pdirops: link vs getattr =============="
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 ls -lia $DIR2/ > /dev/null &
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 "readdir isn't blocked"; }
3209 run_test 46h "pdirops: link vs readdir =============="
3212 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3214 touch $DIR1/$tfile-2
3215 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
3216 do_nodes $(comma_list $(mdts_nodes)) \
3217 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
3218 link $DIR1/$tfile-2 $DIR1/$tfile &
3220 $LFS mkdir -i 1 $DIR2/$tfile &
3222 do_nodes $(comma_list $(mdts_nodes)) \
3223 "lctl set_param -n fail_loc=0 2>/dev/null || true"
3224 check_pdo_conflict $PID1 && { wait $PID1;
3225 error "remote mkdir isn't blocked"; }
3226 wait $PID2 ; [ $? -ne 0 ] || error "remote mkdir must fail"
3230 run_test 46i "pdirops: link vs remote mkdir"
3232 # test 47: remote mkdir and blocking operations
3234 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
3235 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3237 do_nodes $(comma_list $(mdts_nodes)) \
3238 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
3239 $LFS mkdir -i 1 $DIR1/$tfile &
3241 mkdir $DIR2/$tfile &
3243 do_nodes $(comma_list $(mdts_nodes)) \
3244 "lctl set_param -n fail_loc=0 2>/dev/null || true"
3245 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
3246 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
3250 run_test 47a "pdirops: remote mkdir vs mkdir"
3253 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
3254 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3256 do_nodes $(comma_list $(mdts_nodes)) \
3257 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
3258 $LFS mkdir -i 1 $DIR1/$tfile &
3260 sleep 1 # please do not remove this sleep, see LU-10754
3261 multiop $DIR2/$tfile oO_CREAT:O_EXCL:c &
3263 do_nodes $(comma_list $(mdts_nodes)) \
3264 "lctl set_param -n fail_loc=0 2>/dev/null || true"
3265 check_pdo_conflict $PID1 && { wait $PID1;
3266 error "create isn't blocked"; }
3267 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
3271 run_test 47b "pdirops: remote mkdir vs create"
3274 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3276 touch $DIR1/$tfile-2
3277 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
3278 do_nodes $(comma_list $(mdts_nodes)) \
3279 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
3280 $LFS mkdir -i 1 $DIR1/$tfile &
3282 link $DIR2/$tfile-2 $DIR2/$tfile &
3284 do_nodes $(comma_list $(mdts_nodes)) \
3285 "lctl set_param -n fail_loc=0 2>/dev/null || true"
3286 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
3287 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
3291 run_test 47c "pdirops: remote mkdir vs link"
3294 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3296 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
3297 do_nodes $(comma_list $(mdts_nodes)) \
3298 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
3299 $LFS mkdir -i 1 $DIR1/$tfile &
3301 rmdir $DIR2/$tfile &
3303 do_nodes $(comma_list $(mdts_nodes)) \
3304 "lctl set_param -n fail_loc=0 2>/dev/null || true"
3305 check_pdo_conflict $PID1 && { wait $PID1;
3306 error "unlink isn't blocked"; }
3307 wait $PID2 ; [ $? -eq 0 ] || error "rmdir must succeed"
3311 run_test 47d "pdirops: remote mkdir vs unlink"
3314 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3316 touch $DIR1/$tfile-2
3317 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
3318 do_nodes $(comma_list $(mdts_nodes)) \
3319 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
3320 $LFS mkdir -i 1 $DIR1/$tfile &
3322 mv -T $DIR2/$tfile-2 $DIR2/$tfile &
3324 do_nodes $(comma_list $(mdts_nodes)) \
3325 "lctl set_param -n fail_loc=0 2>/dev/null || true"
3326 check_pdo_conflict $PID1 && { wait $PID1;
3327 error "rename isn't blocked"; }
3328 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
3332 run_test 47e "pdirops: remote mkdir and rename (tgt)"
3335 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3337 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
3338 do_nodes $(comma_list $(mdts_nodes)) \
3339 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
3340 $LFS mkdir -i 1 $DIR1/$tfile &
3342 mv $DIR2/$tfile $DIR2/$tfile-2 &
3344 do_nodes $(comma_list $(mdts_nodes)) \
3345 "lctl set_param -n fail_loc=0 2>/dev/null || true"
3346 check_pdo_conflict $PID1 && { wait $PID1;
3347 error "rename isn't blocked"; }
3348 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
3352 run_test 47f "pdirops: remote mkdir and rename (src)"
3355 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3359 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
3360 do_nodes $(comma_list $(mdts_nodes)) \
3361 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
3362 $LFS mkdir -i 1 $DIR1/$tfile &
3364 stat $DIR2/$tfile > /dev/null &
3366 do_nodes $(comma_list $(mdts_nodes)) \
3367 "lctl set_param -n fail_loc=0 2>/dev/null || true"
3368 check_pdo_conflict $PID1 && { wait $PID1;
3369 error "getattr isn't blocked"; }
3370 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
3374 run_test 47g "pdirops: remote mkdir vs getattr"
3378 dd if=/dev/zero of=$DIR1/$tfile bs=1K count=10
3379 #define OBD_FAIL_OSC_CP_ENQ_RACE 0x410
3380 do_facet client "lctl set_param fail_loc=0x410"
3381 $TRUNCATE $DIR2/$tfile $trunc_size
3382 do_facet client "lctl set_param fail_loc=0x0"
3384 size=`stat -c %s $DIR2/$tfile`
3385 [ $size -eq $trunc_size ] || error "wrong size"
3387 run_test 50 "osc lvb attrs: enqueue vs. CP AST =============="
3391 local origfile=/etc/hosts
3393 filesize=$(stat -c %s $origfile)
3395 # create an empty file
3396 $MCREATE $DIR1/$tfile || error "can't create $DIR1/$tfile"
3397 # cache layout lock on both mount point
3398 stat $DIR1/$tfile > /dev/null || error "stat $DIR1/$tfile failed"
3399 stat $DIR2/$tfile > /dev/null || error "stat $DIR2/$tfile failed"
3401 # open and sleep 2 seconds then read
3402 $MULTIOP $DIR2/$tfile o_2r${filesize}c &
3406 # create the layout of testing file
3407 dd if=$origfile of=$DIR1/$tfile conv=notrunc > /dev/null ||
3408 error "dd $DIR1/$tfile failed"
3410 # MULTIOP proc should be able to read enough bytes and exit
3411 for ((i = 0; i < 6; i++)); do
3413 kill -0 $pid || break
3415 kill -0 $pid 2> /dev/null && error "multiop is still there"
3416 cmp $origfile $DIR2/$tfile || error "$origfile and $DIR2/$tfile differs"
3420 run_test 51a "layout lock: refresh layout should work"
3423 (( $MDS1_VERSION >= $(version_code 2.3.59) )) ||
3424 skip "Need MDS version at least 2.3.59"
3426 local tmpfile=`mktemp`
3428 $LFS setstripe -E 1m -S 1M -c 1 -E -1 -c 1 $DIR1/$tfile ||
3429 error "Create $DIR1/$tfile failed"
3431 dd if=/dev/zero of=$DIR1/$tfile bs=1k count=1 conv=notrunc ||
3432 error "dd $DIR1/$tfile failed"
3434 # delay glimpse so that layout has changed when glimpse finish
3435 #define OBD_FAIL_GLIMPSE_DELAY 0x1404
3436 $LCTL set_param fail_loc=0x1404 fail_val=4
3437 stat -c %s $DIR2/$tfile |tee $tmpfile &
3441 # extend layout of testing file
3442 dd if=/dev/zero of=$DIR1/$tfile bs=1M count=1 seek=2 conv=notrunc ||
3443 error "dd $DIR1/$tfile failed"
3446 local fsize=$(cat $tmpfile)
3448 [ x$fsize = x3145728 ] || error "file size is $fsize, should be 3145728"
3450 rm -f $DIR1/$tfile $tmpfile
3452 run_test 51b "layout lock: glimpse should be able to restart if layout changed"
3455 [ $OSTCOUNT -ge 2 ] || { skip "needs >= 2 osts"; return; }
3457 # set default layout to have 1 stripe
3459 $LFS setstripe -c 1 $DIR1/$tdir
3461 # create a file with empty layout
3462 $MCREATE $DIR1/$tdir/$tfile ||
3463 error "$MCREATE $DIR1/$tdir/$tfile failed"
3465 #define OBD_FAIL_MDS_LL_BLOCK 0x172
3466 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x172
3468 # change the layout of testing file
3469 echo "Setting layout to have $OSTCOUNT stripes ..."
3470 $LFS setstripe -c $OSTCOUNT $DIR1/$tdir/$tfile &
3474 # write something to the file, it should be blocked on fetching layout
3475 dd if=/dev/zero of=$DIR2/$tdir/$tfile bs=1k count=1 conv=notrunc
3476 local stripe_count=$($LFS getstripe -c $DIR2/$tdir/$tfile)
3479 # lod_qos.c::min_stripe_count() allows setstripe with a default stripe
3480 # count to succeed with only 3/4 of the number of stripes (rounded up),
3481 # so creating striped files does not fail if an OST is offline or full
3482 [ $stripe_count -ge $((OSTCOUNT - $OSTCOUNT / 4)) ] ||
3483 error "bad layout: getstripe -c $stripe_count < $OSTCOUNT * 3/4"
3487 run_test 51c "layout lock: IT_LAYOUT blocked and correct layout can be returned"
3490 dd if=/dev/zero of=/$DIR1/$tfile bs=1M count=1
3491 cancel_lru_locks mdc
3493 # open should grant LAYOUT lock, mmap and read will install pages
3494 $MULTIOP $DIR1/$tfile oO_RDWR:SMR_Uc &
3498 # rss before revoking
3499 local br=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
3500 echo "Before revoking layout lock: $br KB mapped"
3502 # cancel layout lock manually
3503 cancel_lru_locks mdc
3505 # rss after revoking
3506 local ar=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
3509 wait $PID || error "wait PID $PID failed"
3511 [ $ar -eq 0 ] || error "rss before: $br, after $ar, some pages remained"
3513 run_test 51d "layout lock: losing layout lock should clean up memory map region"
3516 (( $MDS1_VERSION >= $(version_code 2.13.54.148) )) ||
3517 skip "MDS version must be at least 2.13.54.148"
3521 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eW_E+eUc &
3525 $LFS getstripe $DIR2/$tfile
3527 wait $pid || error "multiop failed"
3529 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
3533 $LFS getstripe $DIR2/$tfile
3535 wait $pid || error "multiop failed"
3537 run_test 51e "lfs getstripe does not break leases, part 2"
3541 echo "==> rename vs getattr vs setxattr should not deadlock"
3542 mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed"
3544 do_facet mds1 $LCTL set_param fail_loc=$1
3546 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 &
3554 setfattr -n user.attr1 -v value1 $DIR2/d1 || error "(2) setfattr failed"
3555 wait $PID1 || error "(3) mv failed"
3556 wait $PID2 || error "(4) stat failed"
3563 echo "==> rename vs getattr vs open vs getattr should not deadlock"
3564 mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed"
3566 do_facet mds1 $LCTL set_param fail_loc=$1
3568 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 &
3576 $MULTIOP $DIR2/d1/d2 Oc &
3580 stat $DIR/d1 || error "(2) stat failed"
3582 wait $PID1 || error "(3) mv failed"
3583 wait $PID2 || error "(4) stat failed"
3584 wait $PID3 && error "(5) multiop failed"
3590 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
3591 save_lustre_params client "llite.*.xattr_cache" > $p
3592 lctl set_param llite.*.xattr_cache 1 ||
3593 { skip "xattr cache is not supported"; return 0; }
3595 #define OBD_FAIL_MDS_RENAME 0x153
3596 #define OBD_FAIL_MDS_RENAME2 0x154
3597 test_54_part1 0x80000153 || error 10
3598 test_54_part1 0x80000154 || error 11
3599 test_54_part2 0x80000153 || error 12
3600 test_54_part2 0x80000154 || error 13
3602 restore_lustre_params < $p
3605 run_test 54 "rename locking"
3608 mkdir_on_mdt0 $DIR/$tdir
3609 mkdir -p $DIR/$tdir/d1/d2 $DIR/$tdir/d3 || error "(1) mkdir failed"
3611 #define OBD_FAIL_MDS_RENAME4 0x156
3612 do_facet mds1 $LCTL set_param fail_loc=0x80000156
3614 mv -T $DIR/$tdir/d1/d2 $DIR/$tdir/d3/d2 &
3618 rm -r $DIR2/$tdir/d3
3619 wait $PID1 && error "(2) mv succeeded"
3623 run_test 55a "rename vs unlink target dir"
3627 mkdir_on_mdt0 $DIR/$tdir
3628 mkdir -p $DIR/$tdir/d1/d2 $DIR/$tdir/d3 || error "(1) mkdir failed"
3630 #define OBD_FAIL_MDS_RENAME4 0x156
3631 do_facet mds1 $LCTL set_param fail_loc=0x80000156
3633 mv -T $DIR/$tdir/d1/d2 $DIR/$tdir/d3/d2 &
3637 rm -r $DIR2/$tdir/d1
3638 wait $PID1 && error "(2) mv succeeded"
3642 run_test 55b "rename vs unlink source dir"
3646 mkdir_on_mdt0 $DIR/$tdir
3647 mkdir -p $DIR/$tdir/d1/d2 $DIR/$tdir/d3 || error "(1) mkdir failed"
3649 #define OBD_FAIL_MDS_RENAME4 0x156
3650 do_facet mds1 $LCTL set_param fail_loc=0x156
3652 mv -T $DIR/$tdir/d1/d2 $DIR/$tdir/d3/d2 &
3656 # while rename is sleeping, open and remove d3
3657 $MULTIOP $DIR2/$tdir/d3 D_c &
3660 rm -rf $DIR2/$tdir/d3
3663 # while rename is sleeping 2nd time, close d3
3665 wait $PID2 || error "(3) multiop failed"
3667 wait $PID1 && error "(2) mv succeeded"
3671 run_test 55c "rename vs unlink orphan target dir"
3675 mkdir_on_mdt0 $DIR/$tdir
3679 #define OBD_FAIL_MDS_RENAME3 0x155
3680 do_facet mds1 $LCTL set_param fail_loc=0x155
3681 mv $DIR/$tdir/f1 $DIR/$tdir/$tdir &
3685 # while rename is sleeping, create $tdir, but as a directory
3686 mkdir -p $DIR2/$tdir/$tdir || error "(1) mkdir failed"
3688 # link in reverse locking order
3689 ln $DIR2/$tdir/f1 $DIR2/$tdir/$tdir/f1 || error "(2) ln failed"
3691 ! wait $PID1 || error "(3) mv succeeded"
3694 run_test 55d "rename file vs link"
3697 $LFS setstripe -c 1 $MOUNT/$tfile || error "creating $MOUNT/$tfile"
3698 stack_trap "rm -f $MOUNT/$tfile"
3699 echo "run_llverdev $MOUNT/$tfile -p -s $((16000000)) -c 4k"
3700 run_llverdev $MOUNT/$tfile -p -s $((16000000)) -c 4k ||
3701 error "llverdev failed with rc=$?"
3703 run_test 56a "test llverdev with single large stripe"
3706 $LFS setstripe -C 2000 $MOUNT/$tfile || error "creating $MOUNT/$tfile"
3707 stack_trap "rm -f $MOUNT/$tfile"
3708 echo "run_llverdev $MOUNT/$tfile -p -s $((16000000 * OSTCOUNT)) -c 4k"
3709 run_llverdev $MOUNT/$tfile -p -s $((16000000 * OSTCOUNT)) -c 4k ||
3710 error "llverdev failed with rc=$?"
3712 run_test 56b "test llverdev and partial verify of wide stripe file"
3715 [ $MDS1_VERSION -lt $(version_code 2.3.0) ] &&
3716 skip "MDS version must be >= 2.3.0"
3719 test_mkdir $DIR1/$tdir
3720 file1=$DIR1/$tdir/file
3721 file2=$DIR2/$tdir/file
3723 echo orig > $file2 || error "Could not create $file2"
3724 version=$($LFS data_version $file1)
3727 echo append >> $file2 || error "Could not append to $file2"
3728 version2=$($LFS data_version $file1)
3729 [ "$version" != "$version2" ] ||
3730 error "append did not change data version: $version"
3733 echo overwrite > $file2 || error "Could not overwrite $file2"
3734 version3=$($LFS data_version $file1)
3735 [ "$version2" != "$version3" ] ||
3736 error "overwrite did not change data version: $version2"
3738 # Truncate before EOF
3739 $TRUNCATE $file2 3 || error "Could not truncate $file2"
3740 version4=$($LFS data_version $file1)
3741 [ "$version3" != "$version4" ] ||
3742 error "truncate did not change data version: $version3"
3744 # Truncate after EOF
3745 $TRUNCATE $file2 123456 || error "Could not truncate $file2"
3746 version5=$($LFS data_version $file1)
3747 [ "$version4" != "$version5" ] ||
3748 error "truncate did not change data version: $version4"
3750 # Chmod do not change version
3751 chmod 400 $file2 || error "Could not chmod 400 $file2"
3752 version6=$($LFS data_version $file1)
3753 [ "$version5" == "$version6" ] ||
3754 error "chmod should not change data version: $version5 != $version6"
3756 # Chown do not change version
3757 chown $RUNAS_ID $file2 || error "Could not chown $RUNAS_ID $file2"
3758 version7=$($LFS data_version $file1)
3759 [ "$version5" == "$version7" ] ||
3760 error "chown should not change data version: $version5 != $version7"
3762 run_test 60 "Verify data_version behaviour"
3765 local test_dir=$tdir/test_dir
3767 mkdir -p $DIR1/$tdir
3768 if [ $MDSCOUNT -ge 2 ]; then
3770 $LFS mkdir -i $MDTIDX $DIR1/$test_dir ||
3771 error "Create remote directory failed"
3773 mkdir -p $DIR1/$test_dir
3775 cd $DIR2/$test_dir || error "cd directory failed"
3776 rm -rf $DIR1/$test_dir || error "unlink directory failed"
3778 cd $DIR2/$tdir || error "exit directory"
3780 run_test 70a "cd directory && rm directory"
3782 test_70b() { # LU-2781
3784 mkdir -p $DIR1/$tdir
3786 touch $DIR1/$tdir/file
3787 for ((i = 0; i < 32; i++)); do
3788 $LFS rm_entry $DIR1/$tdir/non_existent_dir &>/dev/null
3790 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
3792 touch $DIR1/$tdir/file
3793 $LFS mkdir -i0 $DIR1/$tdir/test_dir
3794 $LFS rm_entry $DIR1/$tdir/test_dir &>/dev/null
3795 rm -rf $DIR1/$tdir/test_dir ||
3796 error "cannot remove directory after rm_entry"
3797 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
3799 run_test 70b "remove files after calling rm_entry"
3802 [[ "$MDS1_VERSION" -lt $(version_code 2.1.6) ]] &&
3803 skip "Need MDS version at least 2.1.6"
3805 # Patch not applied to 2.2 and 2.3 branches
3806 [[ "$MDS1_VERSION" -ge $(version_code 2.2.0) ]] &&
3807 [[ "$MDS1_VERSION" -lt $(version_code 2.4.0) ]] &&
3808 skip "Need MDS version earlier than 2.2.0 or at least 2.4.0"
3810 checkfiemap --test ||
3811 skip "checkfiemap not runnable: $?"
3812 # write data this way: hole - data - hole - data
3813 dd if=/dev/urandom of=$DIR1/$tfile bs=64K seek=1 count=1
3814 [ "$(facet_fstype ost$(($($LFS getstripe -i $DIR1/$tfile) + 1)))" = \
3816 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return 0
3817 dd if=/dev/urandom of=$DIR1/$tfile bs=64K seek=3 count=1
3818 GET_STAT="lctl get_param -n ldlm.services.ldlm_cbd.stats"
3820 local can1=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3822 checkfiemap $DIR2/$tfile 131072 ||
3823 error "data is not flushed from client"
3824 local can2=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3827 # common case of "create file, copy file" on a single node
3828 # should not flush data from ost
3829 dd if=/dev/urandom of=$DIR1/$tfile bs=64K seek=1 count=1
3830 dd if=/dev/urandom of=$DIR1/$tfile bs=64K seek=3 count=1
3832 local can3=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3834 checkfiemap $DIR1/$tfile 131072 ||
3836 local can4=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3838 [ $can3 -eq $can4 ] || error $((can2-can1)) "cancel RPC occured."
3840 run_test 71a "correct file map just after write operation is finished"
3843 [[ "$MDS1_VERSION" -lt $(version_code 2.1.6) ]] &&
3844 skip "Need MDS version at least 2.1.6"
3846 # Patch not applied to 2.2 and 2.3 branches
3847 [[ "$MDS1_VERSION" -ge $(version_code 2.2.0) ]] &&
3848 [[ "$MDS1_VERSION" -lt $(version_code 2.4.0) ]] &&
3849 skip "Need MDS version earlier than 2.2.0 or at least 2.4.0"
3850 [[ $OSTCOUNT -ge 2 ]] || skip "needs >= 2 OSTs"
3852 checkfiemap --test ||
3853 skip "error $?: checkfiemap failed"
3855 mkdir -p $DIR1/$tdir
3857 $LFS setstripe -c -1 $DIR1/$tdir || error "setstripe failed"
3858 dd if=/dev/urandom of=$DIR1/$tdir/$tfile bs=64K count=1
3859 [ "$(facet_fstype ost$(($($LFS getstripe -i $DIR1/$tdir/$tfile) + 1)))" = \
3861 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return 0
3862 checkfiemap $DIR1/$tdir/$tfile 65536 || error "checkfiemap failed"
3864 run_test 71b "check fiemap support for stripecount > 1"
3866 _check_last_flag_with_filefrag()
3873 echo "check last flag for file with $count extents"
3875 for ((i=0; i<$count; i++)); do
3877 dd if=/dev/zero of=$file bs=4K count=1 seek=$offset 2> /dev/null
3880 filefrag -s -v $file | grep "last" ||
3881 error "test file with $i extents failed"
3887 local file="$DIR1/$tdir/$tfile"
3889 (( $CLIENT_VERSION >= $(version_code 2.15.57) )) ||
3890 skip "Need client version >= 2.15.57"
3891 [ $(facet_fstype ost1) = "ldiskfs" ] ||
3892 skip "support only ldiskfs ost"
3893 filefrag -V | grep wc ||
3894 skip "need whamcloud version of e2fsprogs"
3896 mkdir -p $DIR1/$tdir
3898 # filefrag uses u64[2028] buffer to fetch fiemap. The number of extents
3899 # in the buffer is (8 * 2048 - 32) / 56 = 292. Test file with 291, 292
3901 _check_last_flag_with_filefrag $file 291
3902 _check_last_flag_with_filefrag $file 292
3903 _check_last_flag_with_filefrag $file 293
3905 run_test 71c "check FIEMAP_EXTENT_LAST flag with different extents number"
3907 test_71d() { #LU-17110
3908 checkfiemap --test ||
3909 skip "error $?: checkfiemap failed"
3913 # write data this way: hole - data - hole - data
3914 dd if=/dev/urandom of=$f bs=64K count=1
3915 [[ "$(facet_fstype ost$(($($LFS getstripe -i $f) + 1)))" != "zfs" ]] ||
3916 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
3917 dd if=/dev/urandom of=$f bs=64K seek=2 count=1
3918 dd if=/dev/urandom of=$f bs=64K seek=4 count=1
3919 dd if=/dev/urandom of=$f bs=64K seek=6 count=1 conv=fsync
3920 echo "disk usage: $(du -B1 $f)"
3921 echo "file size: $(du -b $f)"
3923 checkfiemap --corruption_test $f $((4 * 64 *1024)) ||
3924 error "checkfiemap failed"
3926 run_test 71d "fiemap corruption test with fm_extent_count=0"
3929 local p="$TMP/sanityN-$TESTNAME.parameters"
3932 save_lustre_params client "llite.*.xattr_cache" > $p
3933 lctl set_param llite.*.xattr_cache 1 ||
3934 { skip "xattr cache is not supported"; return 0; }
3937 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
3938 error "setfattr1 failed"
3939 getfattr -n user.attr1 $DIR2/$tfile | grep value1 ||
3940 error "getfattr1 failed"
3941 setfattr -n user.attr1 -v value2 $DIR2/$tfile ||
3942 error "setfattr2 failed"
3943 getfattr -n user.attr1 $DIR1/$tfile | grep value2 ||
3944 error "getfattr2 failed"
3946 # check that trusted.link is consistent
3947 tlink1=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
3948 ln $DIR2/$tfile $DIR2/$tfile-2 || error "failed to link"
3949 tlink2=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
3950 echo "$tlink1 $tlink2"
3951 [ "$tlink1" = "$tlink2" ] && error "trusted.link should have changed!"
3955 restore_lustre_params < $p
3958 run_test 72 "getxattr/setxattr cache should be consistent between nodes"
3961 local p="$TMP/sanityN-$TESTNAME.parameters"
3962 save_lustre_params client "llite.*.xattr_cache" > $p
3963 lctl set_param llite.*.xattr_cache 1 ||
3964 { skip "xattr cache is not supported"; return 0; }
3967 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
3968 error "setfattr1 failed"
3969 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr1 failed"
3970 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr2 failed"
3971 clear_stats llite.*.stats
3972 # PR lock should be cached by now on both clients
3973 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr3 failed"
3974 # 2 hits for getfattr(0)+getfattr(size)
3975 [ $(calc_stats llite.*.stats getxattr_hits) -eq 2 ] ||
3976 error "not cached in $DIR1"
3977 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr4 failed"
3978 # 4 hits for more getfattr(0)+getfattr(size)
3979 [ $(calc_stats llite.*.stats getxattr_hits) -eq 4 ] ||
3980 error "not cached in $DIR2"
3983 restore_lustre_params < $p
3986 run_test 73 "getxattr should not cause xattr lock cancellation"
3989 [ "$MDS1_VERSION" -lt $(version_code 2.4.93) ] &&
3990 skip "Need MDS version at least 2.4.93"
3992 dd if=/dev/zero of=$DIR1/$tfile-1 bs=1K count=1
3993 dd if=/dev/zero of=$DIR1/$tfile-2 bs=1K count=1
3994 flocks_test 4 $DIR1/$tfile-1 $DIR2/$tfile-2
3996 run_test 74 "flock deadlock: different mounts =============="
4000 $LFS setstripe -c 2 -S 1m -i 0 $DIR1/$tfile
4001 dd if=/dev/zero of=$DIR1/$tfile bs=1M count=2
4002 cancel_lru_locks osc
4004 dd of=$DIR1/$tfile if=/dev/zero bs=1M count=1 seek=1 conv=notrunc
4007 # define OBD_FAIL_LDLM_ENQUEUE_HANG 0x31d
4008 $LCTL set_param fail_loc=0x31d
4009 stat -c %s $DIR1/$tfile &
4014 # For bad lock error handler we should ASSERT and got kernel panic here
4016 $LCTL set_param fail_loc=0
4018 run_test 75 "osc: upcall after unuse lock==================="
4021 [[ "$MDS1_VERSION" -lt $(version_code 2.5.53) ]] &&
4022 skip "Need MDS version at least 2.5.53"
4024 remote_mds_nodsh && skip "remote MDS with nodsh"
4025 local fcount=$((MDSCOUNT * 256))
4030 nid=$($LCTL list_nids | sed "s/\./\\\./g")
4036 test_mkdir $DIR/$tdir
4038 # drop all open locks and close any cached "open" files on the client
4039 cancel_lru_locks mdc
4041 local open_fids_cmd="$LCTL get_param -n mdt.*.exports.'$nid'.open_files"
4042 local fid_list=($(do_nodes $(comma_list $(mdts_nodes)) $open_fids_cmd))
4043 local already=${#fid_list[@]}
4044 for (( i = 0; i < $already; i++ )) ; do
4045 log "already open[$i]: $($LFS fid2path $DIR2 ${fid_list[i]})"
4048 echo -n "opening files: "
4049 ulimit -n $((fcount + 50))
4050 for ((i = 0; i < $fcount; i++)); do
4051 touch $DIR/$tdir/f_$i
4052 local fd=$(free_fd ${fd_list[i]})
4053 local open_cmd="exec $fd<$DIR/$tdir/f_$i"
4058 (( $i % 32 == 0 )) && echo -n "."
4062 fid_list=($(do_nodes $(comma_list $(mdts_nodes)) $open_fids_cmd))
4064 # Possible errors in openfiles FID list.
4065 # 1. Missing FIDs. Check 1
4066 # 2. Extra FIDs. Check 1
4067 # 3. Duplicated FID. Check 2
4068 # 4. Invalid FIDs. Check 2
4069 # 5. Valid FID, points to some other file. Check 3
4072 [ ${#fid_list[@]} -ne $((fcount + already)) ] &&
4073 error "${#fid_list[@]} != $fcount (+$already old) open files"
4075 echo -n "closing files: "
4076 for (( fd = 0, fid = 0; fd < $fcount; fd++, fid++ )) ; do
4077 local close_cmd="exec ${fd_list[fd]}<&-"
4079 filename=$($LFS fid2path $DIR2 ${fid_list[fid]})
4081 while [[ ! "$filename" =~ "$DIR2/$tdir/f_" ]]; do
4082 echo "skip old open file $filename"
4084 filename=$($LFS fid2path $DIR2 ${fid_list[fid]})
4088 rm --interactive=no $filename
4090 error "Nonexisting fid ${fid_list[fid]} listed."
4091 (( $fd % 32 == 0 )) && echo -n "."
4096 ls_op=$(ls $DIR2/$tdir | wc -l)
4098 error "Some openfiles are missing in lproc output"
4102 run_test 76 "Verify MDT open_files listing"
4106 local dir=$DIR/$tdir
4108 local create_as="$2"
4110 mkdir $dir || error "mkdir $dir failed"
4111 $LFS setstripe -c $OSTCOUNT $dir || error "setstripe to $dir failed"
4114 if [[ -n "$create_as" ]]; then
4115 do_nodes $CLIENTS $create_as "touch $dir/nrs_r_\$HOSTNAME;" ||
4116 error "touch failed for $dir/nrs_r_*"
4117 do_nodes $CLIENTS $create_as touch "$dir/nrs_w_\$HOSTNAME" ||
4118 error "touch failed for $dir/nrs_w_*"
4119 do_nodes $CLIENTS $create_as "chmod 777 $dir/nrs_*_\$HOSTNAME;" ||
4120 error "chmod failed for $dir/nrs_*"
4123 do_nodes $CLIENTS $myRUNAS \
4124 dd if=/dev/zero of="$dir/nrs_r_\$HOSTNAME" bs=1M count=$n ||
4125 error "dd at 0 on client failed (1)"
4127 do_nodes $CLIENTS $myRUNAS \
4129 for ((i = 0; i < $n; i++)); do
4130 dd if=/dev/zero of=$dir/nrs_w_\$HOSTNAME bs=1M \
4131 seek=\\\$i count=1 conv=notrunc &
4132 pids_w[\\\$i]=\\\$!;
4135 for ((i = 0; i < $n; i++)); do
4136 wait \\\${pids_w[\\\$i]};
4138 [ \\\$newrc -gt \\\$rc_w ] && rc_w=\\\$newrc;
4142 do_nodes $CLIENTS sync;
4143 cancel_lru_locks osc
4145 do_nodes $CLIENTS $myRUNAS \
4147 for ((i = 0; i < $n; i++)); do
4148 dd if=$dir/nrs_r_\$HOSTNAME bs=1M of=/dev/null \
4149 seek=\\\$i count=1 &
4150 pids_r[\\\$i]=\\\$!;
4153 for ((i = 0; i < $n; i++)); do
4154 wait \\\${pids_r[\\\$i]};
4156 [ \\\$newrc -gt \\\$rc_r ] && rc_r=\\\$newrc;
4160 cancel_lru_locks osc
4162 wait $pid_w || error "dd (write) failed (2)"
4163 wait $pid_r || error "dd (read) failed (3)"
4164 rm -rvf $dir || error "rm -rf $dir failed"
4167 test_77a() { #LU-3266
4170 oss=$(comma_list $(osts_nodes))
4171 do_nodes $oss lctl set_param ost.OSS.*.nrs_policies="fifo" ||
4173 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
4174 [[ $rc -ne 0 ]] && error "failed to set fifo policy"
4179 run_test 77a "check FIFO NRS policy"
4181 test_77b() { #LU-3266
4184 oss=$(comma_list $(osts_nodes))
4186 do_nodes $oss lctl set_param ost.OSS.*.nrs_policies="crrn" \
4187 ost.OSS.*.nrs_crrn_quantum=1 || rc=$?
4188 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
4189 [[ $rc -ne 0 ]] && error "failed to set crrn_quantum to 1"
4191 echo "policy: crr-n, crrn_quantum 1"
4194 do_nodes $oss lctl set_param \
4195 ost.OSS.*.nrs_crrn_quantum=64 || rc=$?
4196 [[ $rc -ne 0 ]] && error "failed to set crrn_quantum to 64"
4198 echo "policy: crr-n, crrn_quantum 64"
4202 do_nodes $oss lctl set_param \
4203 ost.OSS.ost_io.nrs_policies="fifo" || rc=$?
4204 [[ $rc -ne 0 ]] && error "failed to set fifo policy"
4207 run_test 77b "check CRR-N NRS policy"
4212 oss=$(comma_list $(osts_nodes))
4214 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies=$policy \
4215 ost.OSS.*.nrs_"$policy"_quantum=1 \
4216 ost.OSS.*.nrs_"$policy"_offset_type="physical" \
4217 ost.OSS.*.nrs_"$policy"_supported="reads" || return $?
4219 echo "policy: $policy, ${policy}_quantum 1, ${policy}_offset_type " \
4220 "physical, ${policy}_supported reads"
4223 do_nodes $oss lctl set_param \
4224 ost.OSS.*.nrs_${policy}_supported="writes" \
4225 ost.OSS.*.nrs_${policy}_quantum=64 || return $?
4227 echo "policy: $policy, ${policy}_quantum 64, ${policy}_offset_type " \
4228 "physical, ${policy}_supported writes"
4231 do_nodes $oss lctl set_param \
4232 ost.OSS.*.nrs_${policy}_supported="reads_and_writes" \
4233 ost.OSS.*.nrs_${policy}_offset_type="logical" || return $?
4234 echo "policy: $policy, ${policy}_quantum 64, ${policy}_offset_type " \
4235 "logical, ${policy}_supported reads_and_writes"
4239 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo" ||
4244 test_77c() { #LU-3266
4246 orr_trr "orr" || rc=$?
4247 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
4248 [[ $rc -ne 0 ]] && error "orr_trr failed rc:$rc"
4251 run_test 77c "check ORR NRS policy"
4253 test_77d() { #LU-3266
4255 orr_trr "trr" || rc=$?
4256 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
4257 [[ $rc -ne 0 ]] && error "orr_trr failed rc:$rc"
4260 run_test 77d "check TRR nrs policy"
4267 do_facet $facet lctl set_param \
4268 ost.OSS.ost_io.nrs_tbf_rule="$*"
4270 error "failed to run operate '$*' on TBF rules"
4273 cleanup_tbf_verify()
4277 echo "cleanup_tbf $DIR/$tdir"
4280 wait_delete_completed
4285 local dir=$DIR/$tdir
4286 local client1=${CLIENT1:-$(hostname)}
4288 local create_as="$4"
4290 local np=$(check_cpt_number ost1)
4291 [ $np -gt 0 ] || error "CPU partitions should not be $np."
4292 echo "cpu_npartitions on ost1 is $np"
4294 mkdir $dir || error "mkdir $dir failed"
4295 $LFS setstripe -c 1 -i 0 $dir || error "setstripe to $dir failed"
4298 if [[ -n "$create_as" ]]; then
4299 $create_as touch $dir/tbf
4303 trap cleanup_tbf_verify EXIT
4304 echo "Limited write rate: $1, read rate: $2"
4305 echo "Verify the write rate is under TBF control"
4306 local start=$SECONDS
4307 do_node $client1 $myRUNAS dd if=/dev/zero of=$dir/tbf \
4308 bs=1M count=100 oflag=direct 2>&1
4309 local runtime=$((SECONDS - start + 1))
4310 local rate=$(bc <<< "scale=6; 100 / $runtime")
4311 echo "Write runtime is $runtime s, speed is $rate IOPS"
4313 # verify the write rate does not exceed TBF rate limit
4314 [ $(bc <<< "$rate < 1.1 * $np * $1") -eq 1 ] ||
4315 error "The write rate ($rate) exceeds 110% of rate limit ($1 * $np)"
4317 cancel_lru_locks osc
4319 echo "Verify the read rate is under TBF control"
4321 do_node $client1 $myRUNAS dd if=$dir/tbf of=/dev/null \
4322 bs=1M count=100 iflag=direct 2>&1
4323 runtime=$((SECONDS - start + 1))
4324 rate=$(bc <<< "scale=6; 100 / $runtime")
4325 echo "Read runtime is $runtime s, speed is $rate IOPS"
4327 # verify the read rate does not exceed TBF rate limit
4328 [ $(bc <<< "$rate < 1.1 * $np * $2") -eq 1 ] ||
4329 error "The read rate ($rate) exceeds 110% of rate limit ($2 * $np)"
4331 cancel_lru_locks osc
4332 cleanup_tbf_verify || error "rm -rf $dir failed"
4338 oss=$(comma_list $(osts_nodes))
4340 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid" ||
4342 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
4343 [[ $rc -ne 0 ]] && error "failed to set TBF NID policy"
4347 if [ "$OST1_VERSION" -ge $(version_code 2.8.54) ]; then
4352 # Only operate rules on ost1 since OSTs might run on the same OSS
4354 tbf_rule_operate ost1 "start\ localhost\ ${idis}{0@lo}\ ${rateis}1000"
4355 local address=$(comma_list "$(host_nids_address $CLIENTS $NETTYPE)")
4356 local client_nids=$(nids_list $address "\\")
4357 tbf_rule_operate ost1 "start\ clients\ ${idis}{$client_nids}\ ${rateis}100"
4358 tbf_rule_operate ost1 "start\ others\ ${idis}{*.*.*.*@$NETTYPE}\ ${rateis}50"
4362 tbf_rule_operate ost1 "change\ localhost\ ${rateis}1001"
4363 tbf_rule_operate ost1 "change\ clients\ ${rateis}101"
4364 tbf_rule_operate ost1 "change\ others\ ${rateis}51"
4368 tbf_rule_operate ost1 "stop\ localhost"
4369 tbf_rule_operate ost1 "stop\ clients"
4370 tbf_rule_operate ost1 "stop\ others"
4373 # Cleanup the TBF policy
4374 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
4375 [ $? -ne 0 ] && error "failed to set policy back to fifo"
4379 run_test 77e "check TBF NID nrs policy"
4384 oss=$(comma_list $(osts_nodes))
4386 do_nodes $oss $LCTL set_param \
4387 ost.OSS.ost_io.nrs_policies="tbf\ jobid" || rc=$?
4388 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
4389 [[ $rc -ne 0 ]] && error "failed to set TBF JOBID policy"
4391 # Configure jobid_var
4392 local saved_jobid_var=$($LCTL get_param -n jobid_var)
4394 [[ $rc -eq 3 ]] && skip "jobid_var not found" && return
4395 [[ $rc -ne 0 ]] && error "failed to get param jobid_var"
4396 if [ $saved_jobid_var != procname_uid ]; then
4397 set_persistent_param_and_check client \
4398 "jobid_var" "$FSNAME.sys.jobid_var" procname_uid
4403 if [ "$OST1_VERSION" -ge $(version_code 2.8.54) ]; then
4408 # Only operate rules on ost1 since OSTs might run on the same OSS
4410 tbf_rule_operate ost1 "start\ runas\ ${idis}{iozone.$RUNAS_ID\ dd.$RUNAS_ID\ tiotest.$RUNAS_ID}\ ${rateis}1000"
4411 tbf_rule_operate ost1 "start\ iozone_runas\ ${idis}{iozone.$RUNAS_ID}\ ${rateis}100"
4412 tbf_rule_operate ost1 "start\ dd_runas\ ${idis}{dd.$RUNAS_ID}\ ${rateis}50"
4413 nrs_write_read "$RUNAS"
4416 tbf_rule_operate ost1 "change\ runas\ ${rateis}1001"
4417 tbf_rule_operate ost1 "change\ iozone_runas\ ${rateis}101"
4418 tbf_rule_operate ost1 "change\ dd_runas\ ${rateis}51"
4419 nrs_write_read "$RUNAS"
4422 tbf_rule_operate ost1 "stop\ runas"
4423 tbf_rule_operate ost1 "stop\ iozone_runas"
4424 tbf_rule_operate ost1 "stop\ dd_runas"
4425 nrs_write_read "$RUNAS"
4427 # Cleanup the TBF policy
4428 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
4429 [ $? -ne 0 ] && error "failed to set policy back to fifo"
4430 nrs_write_read "$RUNAS"
4432 local current_jobid_var=$($LCTL get_param -n jobid_var)
4433 [[ $? -ne 0 ]] && error "failed to get param jobid_var"
4434 if [ $saved_jobid_var != $current_jobid_var ]; then
4435 set_persistent_param_and_check client \
4436 "jobid_var" "$FSNAME.sys.jobid_var" $saved_jobid_var
4440 run_test 77f "check TBF JobID nrs policy"
4445 oss=$(comma_list $(osts_nodes))
4447 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid" ||
4449 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
4450 [[ $rc -ne 0 ]] && error "failed to set TBF NID policy"
4452 do_nodes $oss lctl set_param \
4453 ost.OSS.ost_io.nrs_policies="tbf\ jobid" || rc=$?
4454 [[ $rc -ne 0 ]] && error "failed to set TBF JOBID policy"
4458 if [ "$OST1_VERSION" -ge $(version_code 2.8.54) ]; then
4463 # Add a rule that only valid for Jobid TBF. If direct change between
4464 # TBF types is not supported, this operation will fail.
4465 tbf_rule_operate ost1 "start\ dd_runas\ ${idis}{dd.$RUNAS_ID}\ ${rateis}50"
4467 # Cleanup the TBF policy
4468 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
4469 [ $? -ne 0 ] && error "failed to set policy back to fifo"
4472 run_test 77g "Change TBF type directly"
4475 [ "$OST1_VERSION" -ge $(version_code 2.8.55) ] ||
4476 skip "Need OST version at least 2.8.55"
4478 local old_policy=$(do_facet ost1 \
4479 lctl get_param ost.OSS.ost_io.nrs_policies)
4482 do_facet ost1 lctl set_param \
4483 ost.OSS.ost_io.nrs_policies="abc"
4484 [ $? -eq 0 ] && error "should return error"
4486 do_facet ost1 lctl set_param \
4487 ost.OSS.ost_io.nrs_policies="tbf\ abc"
4488 [ $? -eq 0 ] && error "should return error"
4490 do_facet ost1 lctl set_param \
4491 ost.OSS.ost_io.nrs_policies="tbf\ reg\ abc"
4492 [ $? -eq 0 ] && error "should return error"
4494 do_facet ost1 lctl set_param \
4495 ost.OSS.ost_io.nrs_policies="tbf\ abc\ efg"
4496 [ $? -eq 0 ] && error "should return error"
4498 new_policy=$(do_facet ost1 lctl get_param ost.OSS.ost_io.nrs_policies)
4499 [ $? -eq 0 ] || error "shouldn't LBUG"
4501 [ "$old_policy" = "$new_policy" ] || error "NRS policy should be same"
4505 run_test 77h "Wrong policy name should report error, not LBUG"
4511 local error_message=$3
4513 for rule in $expected; do
4514 rule_number=$((rule_number + 1))
4516 local stop_line=$(($rule_number + 3))
4517 local awk_command="awk 'NR >= 4 && NR <= $stop_line {print \$1}'"
4519 local output=$(do_facet $facet lctl get_param \
4520 ost.OSS.ost_io.nrs_tbf_rule |
4524 if [ "$output" != "$expected" ]; then
4525 error "$error_message, expected '$expected', got '$output'"
4530 [ "$OST1_VERSION" -ge $(version_code 2.8.55) ] ||
4531 skip "Need OST version at least 2.8.55"
4533 for i in $(seq 1 $OSTCOUNT)
4535 do_facet ost"$i" lctl set_param \
4536 ost.OSS.ost_io.nrs_policies="tbf\ jobid"
4538 error "failed to set TBF policy"
4541 tbf_rule_check ost1 "default" "error before inserting any rule"
4543 tbf_rule_operate ost1 "start\ before\ jobid={jobid}\ rate=1000"
4544 tbf_rule_check ost1 "before default" \
4545 "error when inserting rule 'before'"
4547 tbf_rule_operate ost1 "start\ after\ jobid={jobid}\ rate=1000\ rank=default"
4548 tbf_rule_check ost1 "before after default" \
4549 "error when inserting rule 'after'"
4551 tbf_rule_operate ost1 "start\ target\ jobid={jobid}\ rate=1000\ rank=after"
4552 tbf_rule_check ost1 "before target after default" \
4553 "error when inserting rule 'target'"
4555 echo "Move before itself"
4556 tbf_rule_operate ost1 "change\ target\ rank=target"
4557 tbf_rule_check ost1 "before target after default" \
4558 "error when moving before itself"
4560 echo "Move to higher rank"
4561 tbf_rule_operate ost1 "change\ target\ rank=before"
4562 tbf_rule_check ost1 "target before after default" \
4563 "error when moving to higher rank"
4565 echo "Move to lower rank"
4566 tbf_rule_operate ost1 "change\ target\ rank=after"
4567 tbf_rule_check ost1 "before target after default" \
4568 "error when moving to lower rank"
4570 echo "Move before default"
4571 tbf_rule_operate ost1 "change\ target\ rank=default"
4572 tbf_rule_check ost1 "before after target default" \
4573 error "error when moving before default"
4575 # Cleanup the TBF policy
4576 do_nodes $(comma_list $(osts_nodes)) \
4577 $LCTL set_param ost.OSS.ost_io.nrs_policies=fifo
4580 run_test 77i "Change rank of TBF rule"
4586 [ "$OST1_VERSION" -ge $(version_code 2.9.53) ] ||
4587 skip "Need OST version at least 2.9.53"
4588 if [ "$OST1_VERSION" -ge $(version_code 2.8.60) ]; then
4593 do_nodes $(comma_list $(osts_nodes)) \
4594 lctl set_param jobid_var=procname_uid \
4595 ost.OSS.ost_io.nrs_policies="tbf\ opcode" \
4596 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_r\ ${idis}{ost_read}\ ${rateis}5" \
4597 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_w\ ${idis}{ost_write}\ ${rateis}20"
4598 [ $? -ne 0 ] && error "failed to set TBF OPCode policy"
4603 do_nodes $(comma_list $(osts_nodes)) \
4604 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_r" \
4605 ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_w" \
4606 ost.OSS.ost_io.nrs_policies="fifo"
4608 # sleep 3 seconds to wait the tbf policy stop completely,
4609 # or the next test case is possible get -EAGAIN when
4610 # setting the tbf policy
4613 run_test 77j "check TBF-OPCode NRS policy"
4616 local idstr="${1}id"
4617 local policy="${idstr}={$2}"
4618 local rate="rate=$3"
4619 local runas_args="$4"
4620 local createas_args="${5:-$runas_args}"
4622 do_nodes $(comma_list $(osts_nodes)) \
4623 lctl set_param jobid_var=procname_uid \
4624 ost.OSS.ost_io.nrs_policies="tbf\ ${idstr}" \
4625 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_${idstr}\ ${policy}\ ${rate}"
4626 [ $? -ne 0 ] && error "failed to set tbf ${idstr} policy"
4628 nrs_write_read "runas $runas_args" "runas $createas_args"
4629 tbf_verify $3 $3 "runas $runas_args" "runas $createas_args"
4631 do_nodes $(comma_list $(osts_nodes)) \
4632 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_${idstr}" \
4633 ost.OSS.ost_io.nrs_policies="fifo"
4635 # sleep 3 seconds to wait the tbf policy stop completely,
4636 # or the next test case is possible get -eagain when
4637 # setting the tbf policy
4642 if [ "$OST1_VERSION" -lt $(version_code 2.11.50) ]; then
4643 skip "Need OST version at least 2.11.50"
4646 test_id "u" "$RUNAS_ID" "5" "-u $RUNAS_ID"
4647 test_id "g" "$RUNAS_GID" "5" "-u $RUNAS_ID -g $RUNAS_GID"
4649 run_test 77ja "check TBF-UID/GID NRS policy"
4651 test_77jb() { # LU-16077
4652 (( "$OST1_VERSION" >= $(version_code 2.15.51) )) ||
4653 skip "Need OST version at least 2.15.51"
4655 test_id "u" "$RUNAS_ID" "5" "-u $RUNAS_ID" "-u 0 -g $RUNAS_GID"
4656 test_id "g" "$RUNAS_GID" "5" "-u $RUNAS_ID -g $RUNAS_GID" "-u $RUNAS_ID -g 0"
4658 run_test 77jb "check TBF-UID/GID NRS policy on files that don't belong to us"
4666 for rule in $rule_lists; do
4667 do_nodes $(comma_list $(osts_nodes)) \
4668 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ $rule"
4671 do_nodes $(comma_list $(osts_nodes)) \
4672 lctl set_param ost.OSS.ost_io.nrs_policies="$old_nrs"
4678 [[ "$OST1_VERSION" -ge $(version_code 2.9.53) ]] ||
4679 skip "Need OST version at least 2.9.53"
4681 do_nodes $(comma_list $(osts_nodes)) \
4682 lctl set_param ost.OSS.ost_io.nrs_policies="tbf" \
4683 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_w\ jobid={dd.$RUNAS_ID}\&opcode={ost_write}\ rate=20" \
4684 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_r\ jobid={dd.$RUNAS_ID}\&opcode={ost_read}\ rate=10"
4686 nrs_write_read "$RUNAS"
4687 tbf_verify 20 10 "$RUNAS"
4689 local address=$(comma_list "$(host_nids_address $CLIENTS $NETTYPE)")
4690 local client_nids=$(nids_list $address "\\")
4691 do_nodes $(comma_list $(osts_nodes)) \
4692 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_w" \
4693 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_r" \
4694 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_w\ nid={0@lo\ $client_nids}\&opcode={ost_write}\ rate=20" \
4695 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_r\ nid={0@lo\ $client_nids}\&opcode={ost_read}\ rate=10"
4700 do_nodes $(comma_list $(osts_nodes)) \
4701 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_w" \
4702 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_r" \
4703 ost.OSS.ost_io.nrs_tbf_rule="start\ ext\ nid={0@lo\ $client_nids}\&jobid={dd.$RUNAS_ID}\ rate=20"
4705 nrs_write_read "$RUNAS"
4706 tbf_verify 20 20 "$RUNAS"
4708 do_nodes $(comma_list $(osts_nodes)) \
4709 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext" \
4710 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_a\ jobid={dd.$RUNAS_ID},opcode={ost_write}\ rate=20" \
4711 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_b\ jobid={dd.$RUNAS_ID},opcode={ost_read}\ rate=10"
4713 nrs_write_read "$RUNAS"
4714 # with parameter "RUNAS", it will match the latest rule
4715 # "ext_b" first, so the limited write rate is 10.
4716 tbf_verify 10 10 "$RUNAS"
4719 trap "cleanup_77k \"ext_a ext_b\" \"fifo\"" EXIT
4721 [[ "$OST1_VERSION" -ge $(version_code 2.10.58) ]] ||
4722 skip "Need OST version at least 2.10.58"
4724 do_nodes $(comma_list $(osts_nodes)) \
4725 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_a" \
4726 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_b" \
4727 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_ug\ uid={$RUNAS_ID}\&gid={$RUNAS_GID}\ rate=5"
4728 nrs_write_read "runas -u $RUNAS_ID -g $RUNAS_GID"
4729 tbf_verify 5 5 "runas -u $RUNAS_ID -g $RUNAS_GID"
4731 do_nodes $(comma_list $(osts_nodes)) \
4732 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_ug" \
4733 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_uw\ uid={$RUNAS_ID}\&opcode={ost_write}\ rate=20" \
4734 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_ur\ uid={$RUNAS_ID}\&opcode={ost_read}\ rate=10"
4736 nrs_write_read "runas -u $RUNAS_ID"
4737 tbf_verify 20 10 "runas -u $RUNAS_ID"
4739 do_nodes $(comma_list $(osts_nodes)) \
4740 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_uw" \
4741 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_ur" \
4742 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_a\ uid={$RUNAS_ID},opcode={ost_write}\ rate=20" \
4743 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_b\ uid={$RUNAS_ID},opcode={ost_read}\ rate=10"
4744 nrs_write_read "runas -u $RUNAS_ID"
4745 tbf_verify 10 10 "runas -u $RUNAS_ID"
4746 tbf_verify 20 10 "runas -u $RUNAS_ID"
4747 cleanup_77k "ext_a ext_b" "fifo"
4749 run_test 77k "check TBF policy with NID/JobID/OPCode expression"
4752 [[ "$OST1_VERSION" -ge $(version_code 2.10.56) ]] ||
4753 skip "Need OST version at least 2.10.56"
4755 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid"
4756 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="tbf"
4758 local output=$(do_facet ost1 lctl get_param \
4759 ost.OSS.ost_io.nrs_policies | \
4760 awk '/name: tbf/ {print;exit}' | \
4761 awk -F ': ' '{print $2}')
4763 if [ "$output" != "tbf" ]; then
4764 error "The generic TBF output is '$output', not 'tbf'"
4767 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
4769 run_test 77l "check the output of NRS policies for generic TBF"
4772 if [ "$OST1_VERSION" -lt $(version_code 2.9.54) ]; then
4773 skip "Need OST version at least 2.9.54"
4776 local dir=$DIR/$tdir
4778 mkdir $dir || error "mkdir $dir failed"
4779 $LFS setstripe -c $OSTCOUNT $dir || error "setstripe to $dir failed"
4782 local nodes=$(comma_list $(osts_nodes))
4783 do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies=delay \
4784 ost.OSS.ost_io.nrs_delay_min=4 \
4785 ost.OSS.ost_io.nrs_delay_max=4 \
4786 ost.OSS.ost_io.nrs_delay_pct=100
4787 [ $? -ne 0 ] && error "Failed to set delay policy"
4789 local start=$SECONDS
4790 do_nodes "${SINGLECLIENT:-$HOSTNAME}" "$RUNAS" \
4791 dd if=/dev/zero of="$dir/nrs_delay_$HOSTNAME" bs=1M count=1 \
4792 oflag=direct conv=fdatasync ||
4793 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
4794 error "dd on client failed (1)"; }
4795 local elapsed=$((SECONDS - start))
4797 # NRS delay doesn't do sub-second timing, so a request enqueued at
4798 # 0.9 seconds can be dequeued at 4.0
4799 [ $elapsed -lt 3 ] &&
4800 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
4801 error "Single 1M write should take at least 3 seconds"; }
4804 do_nodes "${SINGLECLIENT:-$HOSTNAME}" "$RUNAS" \
4805 dd if=/dev/zero of="$dir/nrs_delay_$HOSTNAME" bs=1M count=10 \
4806 oflag=direct conv=fdatasync ||
4807 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
4808 error "dd on client failed (2)"; }
4809 elapsed=$((SECONDS - start))
4811 [ $elapsed -lt 30 ] &&
4812 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
4813 error "Ten 1M writes should take at least 30 seconds"; }
4815 do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
4816 [ $? -ne 0 ] && error "failed to set policy back to fifo"
4820 run_test 77m "check NRS Delay slows write RPC processing"
4822 test_77n() { #LU-10802
4823 if [ "$OST1_VERSION" -lt $(version_code 2.10.58) ]; then
4824 skip "Need OST version at least 2.10.58"
4827 # Configure jobid_var
4828 local saved_jobid_var=$($LCTL get_param -n jobid_var)
4829 if [ $saved_jobid_var != procname_uid ]; then
4830 set_persistent_param_and_check client \
4831 "jobid_var" "$FSNAME.sys.jobid_var" procname_uid
4834 do_nodes $(comma_list $(osts_nodes)) \
4835 lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ jobid" \
4836 ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \
4837 ost.OSS.ost_io.nrs_tbf_rule="start\ dd_runas\ jobid={*.$RUNAS_ID}\ rate=20"
4840 tbf_verify 20 20 "$RUNAS"
4842 do_nodes $(comma_list $(osts_nodes)) \
4843 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \
4844 ost.OSS.ost_io.nrs_tbf_rule="start\ dd_runas\ jobid={dd.*}\ rate=20"
4849 do_nodes $(comma_list $(osts_nodes)) \
4850 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \
4851 ost.OSS.ost_io.nrs_policies="fifo"
4855 local current_jobid_var=$($LCTL get_param -n jobid_var)
4856 if [ $saved_jobid_var != $current_jobid_var ]; then
4857 set_persistent_param_and_check client \
4858 "jobid_var" "$FSNAME.sys.jobid_var" $saved_jobid_var
4861 run_test 77n "check wildcard support for TBF JobID NRS policy"
4864 (( $OST1_VERSION > $(version_code 2.14.54) )) ||
4865 skip "need OST > 2.14.54"
4867 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_policies="tbf\ nid"
4868 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="start\ name\ nid={192.168.*.*@tcp}\ rate=10000"
4869 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="start\ name1\ nid={192.168.*.*@tcp}\ rate=10000"
4870 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="change\ name1\ rank=name"
4871 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="stop\ name"
4872 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_policies="fifo"
4874 run_test 77o "Changing rank should not panic"
4879 (( $MDS1_VERSION > $(version_code 2.14.54) )) ||
4880 skip "need MDS >= 2.14.54"
4882 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_policies="tbf"
4883 stack_trap "do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_policies=fifo"
4885 for i in {1..50}; do
4888 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="'start rule77q_1 uid={ 500 11 3}&gid={500 10 33 100 } rate=100'" &
4890 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="'start rule77q_2 uid={1000}&gid={1000} rate=100'" &
4892 wait $pid1 || error "$i: Fail to start TBF rule 'rule77q_1'"
4893 wait $pid2 || error "$i: Fail to start TBF rule 'rule77q_2'"
4895 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="'stop rule77q_1'" &
4897 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="'stop rule77q_2'" &
4899 wait $pid1 || error "$i: Fail to stop TBF rule 'rule77q_1'"
4900 wait $pid2 || error "$i: Fail to stop TBF rule 'rule77q_2'"
4903 run_test 77q "Parallel TBF rule definitions should not panic"
4907 local -a spec_chars=(
4908 '@' '.' '~' '#' '/' '^' '%' '*' ';' ',' '?' '<' '>' ':'
4909 '+' '=' ')' '(' '{' '}' '|' '[' ']' '!' '&' '\$' '\`' '\\')
4911 (( $MDS1_VERSION > $(version_code 2.14.54) )) ||
4912 skip "need MDS >= 2.14.54"
4914 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_policies="tbf"
4915 stack_trap "do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_policies=fifo"
4917 # TBF rule name size is 16 bytes
4918 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="start\ test_77p_overflo\ uid={500}\ rate=500" &&
4919 error "The length of tbf rule name is not checked" || true
4920 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="start\ \ uid={500}\ rate=500" &&
4921 error "The server should not accept empty tbf rule name" || true
4922 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="start\ test_77p_empty" &&
4923 error "The server should not accept 'start <tbf_rule_name>' without an expression" || true
4925 # Test with special chars
4926 for c in "${spec_chars[@]}"; do
4927 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="'start test77p${c}spec uid={500} rate=500'" &&
4928 error "Special char '${c}' should not be accepted in a tbf rule name" || true
4932 run_test 77p "Check validity of rule names for TBF policies"
4936 local saved_jobid=$2
4937 local current_jobid_var
4939 echo "cleanup 77r $pid"
4941 do_facet mds1 $LCTL set_param -n mds.MDS.mdt.nrs_policies=fifo
4942 kill $pid || echo "fail to kill md thread"
4944 current_jobid_var=$($LCTL get_param -n jobid_var)
4945 if [ $saved_jobid != $current_jobid_var ]; then
4946 set_persistent_param_and_check client \
4947 "jobid_var" "$FSNAME.sys.jobid_var" $saved_jobid
4954 md_thread_run="true"
4958 while $md_thread_run; do
4959 printf '%s\n' {$DIR1,$DIR2}/$tdir/${tfile}-{01..20} |
4960 xargs -P20 -I{} $RUNAS bash -c 'touch {}; rm -f {}' \
4961 &> /dev/null & pid=$!
4962 trap "echo kill md_thread xargs; md_thread_run=false; kill $pid" INT TERM
4967 wait_policy_state() {
4970 local change_pid="$3"
4973 for time in {1..60}; do
4976 nbr_started=$(do_facet mds1 $LCTL get_param mds.MDS.mdt.nrs_policies |
4977 egrep -A2 "name: ${policy}$" | grep -c "state: $state")
4979 [[ "$nbr_started" != 2 ]] || return 0
4983 [[ -z "$change_pid" ]] || kill $change_pid || true
4987 test_77r() { #LU-14976
4991 local saved_jobid_var
4993 rules["tbf uid"]="start md_rule uid={$RUNAS_ID} rate=1"
4994 rules["tbf gid"]="start md_rule gid={$RUNAS_GID} rate=1"
4995 rules["tbf jobid"]="start md_rule jobid={*.$RUNAS_ID} rate=1"
4996 rules["tbf"]="start md_rule uid={$RUNAS_ID} rate=1"
5005 test_mkdir -i 0 -c 1 $DIR1/$tdir
5006 chmod 777 $DIR1/$tdir
5008 # Configure jobid_var
5009 saved_jobid_var=$($LCTL get_param -n jobid_var)
5010 if [ $saved_jobid_var != procname_uid ]; then
5011 set_persistent_param_and_check client \
5012 "jobid_var" "$FSNAME.sys.jobid_var" procname_uid
5016 md_thread_77r & pid=$!
5017 stack_trap "cleanup_77r $pid '$saved_jobid_var'"
5020 for policy in "${policies[@]}"; do
5023 # wait to queue requests
5026 do_facet mds1 "$LCTL set_param mds.MDS.mdt.nrs_policies='$policy'" &
5029 wait_policy_state "started" "$policy" "$change_pid" ||
5030 error "timeout to start '$policy' policy"
5032 [[ -n "${rules[$policy]}" ]] || continue
5034 do_facet mds1 "$LCTL set_param mds.MDS.mdt.nrs_tbf_rule='${rules[$policy]}'" ||
5035 error "fail to set rule '${rules[$policy]}' to '$policy'"
5038 wait_policy_state "stopped" "tbf" ||
5039 error "fail to stop tbf policy"
5041 echo "check the number of requests in queue:"
5042 local awkcmd='/name: / {last = $3} '
5043 awkcmd+='/queued: / {printf " %s: %d\n", last, $2;'
5044 awkcmd+=' if (last == "tbf" && $2 > 0) exit 1;}'
5045 do_facet mds1 $LCTL get_param mds.MDS.mdt.nrs_policies | awk "$awkcmd" ||
5046 error "request leak in tbf policies"
5048 run_test 77r "Change type of tbf policy at run time"
5050 test_78() { #LU-6673
5053 oss=$(comma_list $(osts_nodes))
5054 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="orr" &
5055 do_nodes $oss lctl set_param ost.OSS.*.nrs_orr_quantum=1
5057 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
5058 # Valid return codes are:
5059 # 0: Tuning succeeded
5060 # ENODEV: Policy is still stopped
5061 # EAGAIN: Policy is being initialized
5062 [ $rc -eq 0 -o $rc -eq 19 -o $rc -eq 11 ] ||
5063 error "Expected set_param to return 0|ENODEV|EAGAIN"
5065 # Cleanup the ORR policy
5066 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
5067 [ $? -ne 0 ] && error "failed to set policy back to fifo"
5070 run_test 78 "Enable policy and specify tunings right away"
5073 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5074 test_mkdir $DIR/$tdir
5076 # Prevent interference from layout intent RPCs due to
5077 # asynchronous writeback. These will be tested in 130c below.
5078 do_nodes ${CLIENTS:-$HOSTNAME} sync
5080 setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
5081 error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
5083 #define OBD_FAIL_MDS_INTENT_DELAY 0x160
5084 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
5085 local facet=mds$((mdtidx + 1))
5087 set_nodes_failloc $(facet_active_host $facet) 0x80000160
5088 getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null &
5092 #define OBD_FAIL_MDS_GETXATTR_PACK 0x131
5093 set_nodes_failloc $(facet_active_host $facet) 0x80000131
5098 run_test 79 "xattr: intent error"
5101 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
5108 mkdir_on_mdt0 $DIR1/$tdir
5109 mkdir -p $DIR1/$tdir/dir
5110 createmany -o $DIR1/$tdir/dir/f 10 ||
5111 error "create files under remote dir failed $i"
5113 cp /etc/passwd $DIR1/$tdir/$tfile
5115 #migrate open file should fails
5116 multiop_bg_pause $DIR2/$tdir/$tfile O_c || error "open $file failed"
5118 # give multiop a chance to open
5121 $LFS migrate -m $MDTIDX $DIR1/$tdir &&
5122 error "migrate open files should failed with open files"
5126 $LFS migrate -m $MDTIDX $DIR1/$tdir ||
5127 error "migrate remote dir error"
5129 echo "Finish migration, then checking.."
5130 for file in $(find $DIR1/$tdir); do
5131 mdt_index=$($LFS getstripe -m $file)
5132 [ $mdt_index == $MDTIDX ] ||
5133 error "$file is not on MDT${MDTIDX}"
5136 diff /etc/passwd $DIR1/$tdir/$tfile ||
5137 error "file different after migration"
5139 rm -rf $DIR1/$tdir || error "rm dir failed after migration"
5141 run_test 80a "migrate directory when some children is being opened"
5145 kill -9 $migrate_pid
5153 eval $@ &>/dev/null && success_count=$((success_count + 1)) ||
5154 failure_count=$((failure_count + 1))
5158 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
5159 local migdir1=$DIR1/$tdir/migrate_dir
5160 local migdir2=$DIR2/$tdir/migrate_dir
5166 trap cleanup_80b EXIT
5167 # prepare migrate directory
5169 for F in {1,2,3,4,5}; do
5170 echo "$F$F$F$F$F" > $migdir1/file$F
5171 echo "$F$F$F$F$F" > $DIR/$tdir/file$F
5174 # migrate the directories among MDTs
5177 mdt_idx=$((RANDOM % MDSCOUNT))
5179 $LFS migrate -m $mdt_idx $migdir1 &>/dev/null
5184 echo "start migration thread $migrate_pid"
5185 # access the files at the same time
5187 echo "accessing the migrating directory for 1 minute..."
5188 while ((SECONDS - start_time < 60)); do
5189 run_and_count ls $migdir2
5190 run_and_count diff -u $DIR2/$tdir/file1 $migdir2/file1
5191 run_and_count "cat $migdir2/file2 > $migdir2/file3"
5192 run_and_count "echo "aaaaa" > $migdir2/file4"
5193 run_and_count stat $migdir2/file5
5194 run_and_count touch $migdir2/source_file
5195 if [ -e $migdir2/source_file ]; then
5196 run_and_count ln $migdir2/source_file \
5199 [ -e $migdir2/link_file ] &&
5200 rm -rf $migdir2/link_file
5202 run_and_count mrename $migdir2/source_file \
5203 $migdir2/target_file
5205 [ -e $migdir2/target_file ] &&
5206 run_and_count rm -rf $migdir2/target_file ||
5207 run_and_count rm -rf $migdir2/source_file
5210 kill -0 $migrate_pid || {
5211 echo "migration stopped 1"
5216 # check migration are still there
5217 kill -0 $migrate_pid || error "migration stopped 2"
5219 # access during migration may fail
5220 echo "concurrent access $failure_count failures, $success_count successes"
5222 run_test 80b "Accessing directory during migration"
5225 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
5229 mkdir -p $DIR1/$tdir
5231 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d0
5232 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d1
5235 touch d0/0 || error "create 0 failed"
5236 mv d0/0 d1/0 || error "rename d0/0 d1/0 failed"
5237 stat d0/0 && error "stat mv filed succeed"
5238 mv $DIR2/$tdir/d1/0 $DIR2/$tdir/d0/0 || error "rename d1/0 d0/0 failed"
5239 stat d0/0 || error "stat failed"
5241 local t=$(ls -ai $DIR1/$tdir/d0 | sort -u | wc -l)
5243 if [ $t -ne 3 ]; then
5244 ls -ai $DIR1/$tdir/d0
5245 error "expect 3 get $t"
5250 run_test 81a "rename and stat under striped directory"
5253 [ $MDSCOUNT -lt 2 ] &&
5254 skip "We need at least 2 MDTs for this test"
5261 $LFS mkdir -c $MDSCOUNT $DIR1/$tdir || error "$LFS mkdir"
5262 createmany -o $DIR1/$tdir/$tfile. $total || error "createmany"
5271 for i in $(seq $total); do
5272 mrename $DIR2/$tdir/$tfile.$i $DIR2/$tdir/$tfile-new.$i \
5276 kill -9 $setattr_pid
5278 run_test 81b "rename under striped directory doesn't deadlock"
5281 [ $MDSCOUNT -lt 4 ] && skip_env "needs >= 4 MDTs"
5282 [ $MDS1_VERSION -lt $(version_code 2.13.52) ] &&
5283 skip "Need MDS version at least 2.13.52"
5285 # source is local, source parent is remote
5286 $LFS mkdir -i 0 $DIR1/${tdir}_src || error "mkdir ${tdir}_src"
5287 $LFS mkdir -i 1 $DIR1/${tdir}_tgt || error "mkdir ${tdir}_tgt"
5288 $LFS mkdir -i 3 $DIR1/${tdir}_src/sub || error "mkdir sub"
5289 $LFS mkdir -i 3 $DIR1/${tdir}_tgt/sub || error "mkdir sub"
5290 stat $DIR2/${tdir}_src/sub || error "stat sub failed"
5291 mv $DIR1/${tdir}_src/sub $DIR1/${tdir}_tgt/ || error "mv failed"
5292 [ -f $DIR2/${tdir}_src/sub ] && error "sub should be gone"
5293 rm -rf $DIR1/${tdir}_src $DIR1/${tdir}_tgt
5295 # source is remote, source parent is local
5296 $LFS mkdir -i 3 $DIR1/${tdir}_src || error "mkdir ${tdir}_src"
5297 $LFS mkdir -i 1 $DIR1/${tdir}_tgt || error "mkdir ${tdir}_tgt"
5298 $LFS mkdir -i 0 $DIR1/${tdir}_src/sub || error "mkdir sub"
5299 $LFS mkdir -i 3 $DIR1/${tdir}_tgt/sub || error "mkdir sub"
5300 stat $DIR2/${tdir}_src/sub || error "stat sub failed"
5301 mv $DIR1/${tdir}_src/sub $DIR1/${tdir}_tgt/ || error "mv failed"
5302 [ -f $DIR2/${tdir}_src/sub ] && error "sub should be gone"
5303 rm -rf $DIR1/${tdir}_src $DIR1/${tdir}_tgt
5305 # source and source parent are remote
5306 $LFS mkdir -i 0 $DIR1/${tdir}_src || error "mkdir ${tdir}_src"
5307 $LFS mkdir -i 1 $DIR1/${tdir}_tgt || error "mkdir ${tdir}_tgt"
5308 mkdir $DIR1/${tdir}_src/sub || error "mkdir sub"
5309 $LFS mkdir -i 3 $DIR1/${tdir}_tgt/sub || error "mkdir sub"
5310 stat $DIR2/${tdir}_src/sub || error "stat sub failed"
5311 mv $DIR1/${tdir}_src/sub $DIR1/${tdir}_tgt/ || error "mv failed"
5312 [ -f $DIR2/${tdir}_src/sub ] && error "sub should be gone"
5313 rm -rf $DIR1/${tdir}_src $DIR1/${tdir}_tgt
5315 # source and source parent are remote, and source is remote object
5316 $LFS mkdir -i 0 $DIR1/${tdir}_src || error "mkdir ${tdir}_src"
5317 $LFS mkdir -i 1 $DIR1/${tdir}_tgt || error "mkdir ${tdir}_tgt"
5318 $LFS mkdir -i 2 $DIR1/${tdir}_src/sub || error "mkdir sub"
5319 $LFS mkdir -i 3 $DIR1/${tdir}_tgt/sub || error "mkdir sub"
5320 stat $DIR2/${tdir}_src/sub || error "stat sub failed"
5321 mv $DIR1/${tdir}_src/sub $DIR1/${tdir}_tgt/ || error "mv failed"
5322 [ -f $DIR2/${tdir}_src/sub ] && error "sub should be gone" || true
5324 run_test 81c "rename revoke LOOKUP lock for remote object"
5327 [[ "$MDS1_VERSION" -gt $(version_code 2.6.91) ]] ||
5328 skip "Need MDS version at least 2.6.92"
5330 # Client 1 creates a file.
5331 multiop_bg_pause $DIR1/$tfile O_ac || error "multiop_bg_pause 1"
5333 # Client 2 opens the file.
5334 multiop_bg_pause $DIR2/$tfile o_Ac || error "multiop_bg_pause 2"
5336 # Client 1 makes the file an orphan.
5337 rm $DIR1/$tfile || error "rm"
5338 # Client 2 sets EA "user.multiop".
5340 wait $pid2 || error "multiop 2"
5341 # Client 1 gets EA "user.multiop". This used to fail because the EA
5342 # cache refill would get "trusted.link" from mdd_xattr_list() but
5343 # -ENOENT when trying to get "trusted.link"'s value. See also sanity
5346 wait $pid1 || error "multiop 1"
5348 run_test 82 "fsetxattr and fgetxattr on orphan files"
5351 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
5358 $LFS mkdir -i1 -c2 $tdir
5363 echo "start pid $pid1 to create/unlink striped directory"
5365 # Access the directory at the same time
5369 stat $tdir > /dev/null 2>&1
5373 echo "start pid $pid2 to stat striped directory"
5381 run_test 83 "access striped directory while it is being created/unlinked"
5384 [ $MDS1_VERSION -lt $(version_code 2.12.55) ] &&
5385 skip "lustre < 2.12.55 does not contain LU-12485 fix"
5389 $MULTIOP $DIR/$tfile oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:c ||
5390 error "create $tfile failed"
5391 mtime=$(stat -c%Y $DIR/$tfile)
5392 mtime=$((mtime + 200))
5394 #define OBD_FAIL_OBD_0NLINK_RACE 0x60b
5395 do_facet mds1 $LCTL set_param fail_loc=0x8000060b
5397 touch -c -m $mtime $DIR/$tfile &
5399 # sleep a while to let 'touch' run first
5401 rm -f $DIR2/$tfile || error "unlink $tfile failed"
5404 wait $setattr_pid || true
5406 run_test 84 "0-nlink race in lu_object_find()"
5409 llapi_root_test $DIR/$tfile $DIR2/$tfile
5411 run_test 85 "Lustre API root cache race"
5414 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
5419 [ "$SLOW" = "yes" ] && duration=600
5420 # Open/Create under striped directory
5424 $LFS mkdir -c$MDSCOUNT $tdir > /dev/null 2>&1
5425 touch $tdir/f{0..3} > /dev/null 2>&1
5429 echo "start pid $pid1 to open/create under striped directory"
5431 # unlink the striped directory at the same time
5435 rm -rf $tdir > /dev/null 2>&1
5439 echo "start pid $pid2 to unlink striped directory"
5448 run_test 90 "open/create and unlink striped directory"
5451 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
5456 [ "$SLOW" = "yes" ] && duration=600
5457 # chmod striped directory
5461 $LFS mkdir -c$MDSCOUNT $tdir > /dev/null 2>&1
5462 chmod go+w $tdir > /dev/null 2>&1
5466 echo "start pid $pid1 to chmod striped directory"
5468 # unlink the striped directory at the same time
5472 rm -rf $tdir > /dev/null 2>&1
5476 echo "start pid $pid2 to unlink striped directory"
5485 run_test 91 "chmod and unlink striped directory"
5488 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
5491 local cmd="exec $fd<$DIR1/$tdir"
5492 $LFS setdirstripe -c$MDSCOUNT $DIR1/$tdir || error "mkdir $tdir fails"
5495 trap "eval $cmd" EXIT
5496 cd $DIR1/$tdir || error "cd $DIR1/$tdir fails"
5497 rmdir ../$tdir || error "rmdir ../$tdir fails"
5499 #define OBD_FAIL_LLITE_NO_CHECK_DEAD 0x1408
5500 $LCTL set_param fail_loc=0x1408
5501 mkdir $DIR2/$tdir/dir && error "create dir succeeds"
5502 $LFS setdirstripe -i1 $DIR2/$tdir/remote_dir &&
5503 error "create remote dir succeeds"
5504 $LCTL set_param fail_loc=0
5508 run_test 92 "create remote directory under orphan directory"
5515 mkdir -p $DIR1/$tfile-1/
5516 mkdir -p $DIR2/$tfile-2/
5517 local old_rr=$(do_facet $SINGLEMDS "$LCTL get_param -n \
5518 lod.$FSNAME-MDT0000-*/qos_threshold_rr" | sed -e 's/%//')
5519 do_facet $SINGLEMDS "$LCTL set_param -n \
5520 lod.$FSNAME-MDT0000-*/qos_threshold_rr=100"
5521 #define OBD_FAIL_MDS_LOV_CREATE_RACE 0x163
5522 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x00000163"
5524 $LFS setstripe -c -1 $DIR1/$tfile-1/file1 &
5527 $LFS setstripe -c -1 $DIR2/$tfile-2/file2 &
5531 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x0"
5532 do_facet $SINGLEMDS "$LCTL set_param -n \
5533 lod.$FSNAME-MDT0000-*/qos_threshold_rr=$old_rr"
5535 $LFS getstripe $DIR1/$tfile-1/file1
5536 rc1=$($LFS getstripe -q $DIR1/$tfile-1/file1 |
5537 awk '{if (/[0-9]/) print $1 }' | sort | uniq -d | wc -l)
5538 $LFS getstripe $DIR2/$tfile-2/file2
5539 rc2=$($LFS getstripe -q $DIR2/$tfile-2/file2 |
5540 awk '{if (/[0-9]/) print $1 }' | sort | uniq -d | wc -l)
5541 echo "rc1=$rc1 and rc2=$rc2 "
5542 [ $rc1 -eq 0 ] && [ $rc2 -eq 0 ] ||
5543 error "object allocate on same ost detected"
5545 run_test 93 "alloc_rr should not allocate on same ost"
5548 $LCTL set_param osc.*.idle_timeout=0
5549 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=2 conv=fsync
5551 local before=$(date +%s)
5555 #define OBD_FAIL_LDLM_PAUSE_CANCEL 0x312
5556 $LCTL set_param fail_val=5 fail_loc=0x80000312
5557 dd if=/dev/zero of=$DIR/$tfile conv=notrunc oflag=append bs=4k count=1 &
5561 #define OBD_FAIL_LDLM_PAUSE_CANCEL_LOCAL 0x329
5562 $LCTL set_param fail_val=6 fail_loc=0x80000329
5563 $LCTL mark kill $pid
5566 dd if=/dev/zero of=$DIR2/$tfile conv=notrunc oflag=append bs=4k count=1
5569 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 conv=fsync
5571 evict=$(do_facet client $LCTL get_param \
5572 osc.$FSNAME-OST*-osc-*/state |
5573 awk -F"[ [,]" '/EVICTED ]$/ { if (t<$5) {t=$5;} } END { print t }')
5575 [ -z "$evict" ] || [[ $evict -le $before ]] ||
5576 (do_facet client $LCTL get_param \
5577 osc.$FSNAME-OST*-osc-*/state;
5578 error "eviction happened: $evict before:$before")
5579 $LCTL set_param osc.*.idle_timeout=debug
5581 run_test 94 "signal vs CP callback race"
5584 local file=$DIR/$tfile
5585 local file2=$DIR2/$tfile
5586 local fast_read_save
5589 fast_read_save=$($LCTL get_param -n llite.*.fast_read | head -n 1)
5590 [ -z "$fast_read_save" ] && skip "no fast read support"
5592 stack_trap "$LCTL set_param llite.*.fast_read=$fast_read_save" EXIT
5593 $LCTL set_param llite.*.fast_read=0
5595 $LFS setstripe -c $OSTCOUNT $file || error "failed to setstripe $file"
5596 dd if=/dev/zero of=$file bs=1M count=2 || error "failed to write $file"
5597 cancel_lru_locks $OSC
5598 $MULTIOP $file Oz1048576w4096c || error "failed to write $file"
5599 $MULTIOP $file oz1044480r4096c || error "failed to read $file"
5601 # OBD_FAIL_LLITE_PAGE_INVALIDATE_PAUSE 0x1421
5602 $LCTL set_param fail_loc=0x80001421 fail_val=7
5603 $MULTIOP $file2 Oz1048576w4096_c &
5607 # OBD_FAIL_LLITE_READPAGE_PAUSE 0x1422
5608 $LCTL set_param fail_loc=0x80001422 fail_val=10
5609 $MULTIOP $file oz1044480r4096c || error "failed to read $file"
5611 kill -USR1 $pid && wait $pid || error "wait for PID $pid failed"
5613 run_test 95a "Check readpage() on a page that was removed from page cache"
5616 local file=$DIR/$tfile
5617 local file2=$DIR2/$tfile
5618 local fast_read_save
5621 fast_read_save=$($LCTL get_param -n llite.*.fast_read | head -n 1)
5622 [ -z "$fast_read_save" ] && skip "no fast read support"
5624 stack_trap "$LCTL set_param llite.*.fast_read=$fast_read_save" EXIT
5625 $LCTL set_param llite.*.fast_read=0
5627 $LFS setstripe -c $OSTCOUNT $file || error "failed to setstripe $file"
5628 dd if=/dev/zero of=$file bs=$((PAGE_SIZE * 3)) count=1 ||
5629 error "failed to write $file"
5631 # This does the read from the second mount, so this flushes the pages
5632 # the first mount and creates new ones on the second mount
5633 # OBD_FAIL_LLITE_READPAGE_PAUSE2 0x1424
5634 $LCTL set_param fail_loc=0x80001424 fail_val=5
5635 $MULTIOP $file2 or${PAGE_SIZE}c &
5639 fadvise_dontneed_helper $file2
5640 $LCTL set_param fail_loc=0
5642 wait $pid || error "failed to read file"
5644 run_test 95b "Check readpage() on a page that is no longer uptodate"
5648 skip "Reserved for glimpse-ahead" && return
5649 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
5650 skip "Need MDS version at least 2.10.55"
5654 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
5656 lctl set_param -n mdc.*.stats=clear
5657 dd if=/dev/zero of=$DIR2/$tdir/dom bs=4096 count=1 || return 1
5659 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #1"
5660 # first stat from server should return size data and save glimpse
5661 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
5662 [ $gls -eq 0 ] || error "Unexpected $gls glimpse RPCs"
5663 # second stat to check size is NOT cached on client without IO lock
5664 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #2"
5666 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
5667 [ $gls -ge 1 ] || error "Expect glimpse RPCs but none"
5670 run_test 100a "DoM: glimpse RPCs for stat without IO lock (DoM only file)"
5673 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
5674 skip "Need MDS version at least 2.10.55"
5678 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
5680 lctl set_param -n mdc.*.stats=clear
5681 dd if=/dev/zero of=$DIR2/$tdir/dom bs=4096 count=1 || return 1
5682 cancel_lru_locks mdc
5683 # first stat data from server should have size
5684 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #1"
5685 # second stat to check size is cached on client
5686 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #2"
5688 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
5689 # both stats should cause no glimpse requests
5690 [ $gls == 0 ] || error "Unexpected $gls glimpse RPCs"
5693 run_test 100b "DoM: no glimpse RPC for stat with IO lock (DoM only file)"
5696 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
5697 skip "Need MDS version at least 2.10.55"
5701 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
5703 lctl set_param -n mdc.*.stats=clear
5704 lctl set_param -n osc.*.stats=clear
5705 dd if=/dev/zero of=$DIR2/$tdir/dom bs=2048K count=1 || return 1
5707 # check that size is merged from MDT and OST correctly
5708 $CHECKSTAT -t file -s 2097152 $DIR/$tdir/dom ||
5709 error "Wrong size from stat #1"
5711 local gls=$(lctl get_param -n osc.*.stats | grep -c ldlm_glimpse)
5712 [ $gls -eq 0 ] && error "Expect OST glimpse RPCs but got none"
5716 run_test 100c "DoM: write vs stat without IO lock (combined file)"
5719 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
5720 skip "Need MDS version at least 2.10.55"
5724 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
5727 dd if=/dev/zero of=$DIR2/$tdir/dom bs=2048K count=1 || return 1
5728 lctl set_param -n mdc.*.stats=clear
5729 $TRUNCATE $DIR2/$tdir/dom 4096
5731 # check that reported size is valid after file grows to OST and
5732 # is truncated back to MDT stripe size
5733 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom ||
5734 error "Wrong size from stat #1"
5736 local gls=$(lctl get_param -n osc.*.stats | grep -c ldlm_glimpse)
5737 [ $gls -eq 0 ] && error "Expect OST glimpse but got none"
5741 run_test 100d "DoM: write+truncate vs stat without IO lock (combined file)"
5744 [ "$MDS1_VERSION" -lt $(version_code 2.11.50) ] &&
5745 skip "Need MDS version at least 2.11.50"
5747 local dom=$DIR/$tdir/dom
5748 local dom2=$DIR2/$tdir/dom
5751 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
5753 cancel_lru_locks mdc
5754 dd if=/dev/urandom of=$dom bs=12000 count=1
5755 $TRUNCATE $dom2 6000
5756 cancel_lru_locks mdc
5757 lctl set_param -n mdc.*.stats=clear
5758 # expect read-on-open to return all data before write
5759 cat /etc/hosts >> $dom
5760 local read=$(lctl get_param -n mdc.*.stats | grep -c ost_read)
5761 [[ $read -eq 0 ]] || error "Unexpected $read READ RPCs"
5763 run_test 100e "DoM: read on open and file size"
5766 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
5767 skip "Need MDS version at least 2.10.55"
5769 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
5771 $CHECKSTAT -t file $DIR1/$tfile
5773 local old_wb=$(sysctl -n vm.dirty_writeback_centisecs)
5774 sysctl -wq vm.dirty_writeback_centisecs=0
5776 trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT
5779 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 ||
5780 error_noexit "Write fails"
5781 # must discard pages
5782 lctl set_param -n mdc.*.stats=clear
5783 rm $DIR2/$tfile || error "Unlink fails"
5785 local writes=$(lctl get_param -n mdc.*.stats | grep -c ost_write)
5786 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
5788 run_test 101a "Discard DoM data on unlink"
5791 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
5792 skip "Need MDS version at least 2.10.55"
5794 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
5795 touch $DIR1/${tfile}_2
5797 $CHECKSTAT -t file $DIR1/$tfile
5799 local old_wb=$(sysctl -n vm.dirty_writeback_centisecs)
5800 sysctl -wq vm.dirty_writeback_centisecs=0
5802 trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT
5805 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 || error "Write fails"
5806 # must discard pages
5807 lctl set_param -n mdc.*.stats=clear
5808 mv $DIR2/${tfile}_2 $DIR2/$tfile || error "Rename fails"
5810 local writes=$(lctl get_param -n mdc.*.stats | grep -c ost_write)
5811 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
5813 run_test 101b "Discard DoM data on rename"
5816 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
5817 skip "Need MDS version at least 2.10.55"
5819 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
5821 $CHECKSTAT -t file $DIR1/$tfile
5823 local old_wb=$(sysctl -n vm.dirty_writeback_centisecs)
5824 sysctl -wq vm.dirty_writeback_centisecs=0
5826 trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT
5829 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 || error "Write fails"
5830 $MULTIOP $DIR1/$tfile O_c &
5833 lctl set_param -n mdc.*.stats=clear
5834 rm $DIR2/$tfile > /dev/null || error "Unlink fails for opened file"
5835 kill -USR1 $MULTIOP_PID && wait $MULTIOP_PID || error "multiop failure"
5837 local writes=$(lctl get_param -n mdc.*.stats | grep -c ost_write)
5838 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
5840 run_test 101c "Discard DoM data on close-unlink"
5842 # test to verify file handle related system calls
5843 # (name_to_handle_at/open_by_handle_at)
5844 # The new system calls are supported in glibc >= 2.14.
5846 # test to verify we can open by handle an unlinked file from > 1 client
5847 # This test opens the file normally on $DIR1, which is on one mount, and then
5848 # opens it by handle on $DIR2, which is on a different mount.
5850 (( "$MDS1_VERSION" >= $(version_code 2.11.57) )) ||
5851 skip "Needs MDS version 2.11.57 or later"
5853 echo "Test file_handle syscalls" > $DIR/$tfile ||
5854 error "write failed"
5855 check_fhandle_syscalls $DIR/$tfile $DIR2 ||
5856 error "check_fhandle_syscalls $tfile failed"
5858 # test this is working on DNE directories also
5859 if (( MDSCOUNT > 1 && MDS1_VERSION >= $(version_code 2.14.52) )); then
5860 $LFS mkdir -i 1 $DIR/$tdir.remote
5861 cancel_lru_locks mdc
5862 check_fhandle_syscalls $DIR/$tdir.remote $DIR2 ||
5863 error "check_fhandle_syscalls $tdir.remote failed"
5864 $LFS mkdir -c -1 $DIR/$tdir.remote/subdir
5865 cancel_lru_locks mdc
5866 check_fhandle_syscalls $DIR/$tdir.remote/subdir $DIR2 ||
5867 error "check_fhandle_syscalls $tdir.remote/subdir fail"
5869 $LFS mkdir -c -1 $DIR/$tdir.stripe
5870 cancel_lru_locks mdc
5871 check_fhandle_syscalls $DIR/$tdir.stripe $DIR2 ||
5872 error "check_fhandle_syscalls $tdir.stripe failed"
5873 $LFS mkdir -c -1 $DIR/$tdir.stripe/subdir
5874 cancel_lru_locks mdc
5875 check_fhandle_syscalls $DIR/$tdir.stripe/subdir $DIR2 ||
5876 error "check_fhandle_syscalls $tdir.stripe/subdir fail"
5879 run_test 102 "Test open by handle of unlinked file"
5881 # Compare file size between first & second mount, ensuring the client correctly
5882 # glimpses even with unused speculative locks - LU-11670
5884 [ $OST1_VERSION -lt $(version_code 2.10.50) ] &&
5885 skip "Lockahead needs OST version at least 2.10.50"
5889 test_mkdir -p $DIR/$tdir
5891 # Force file on to OST0
5892 $LFS setstripe -i 0 $DIR/$tdir
5894 # Do not check multiple locks on glimpse
5895 # OBD_FAIL_OSC_NO_SIZE_DATA 0x415
5896 $LCTL set_param fail_loc=0x415
5898 # Delay write commit by 2 seconds to guarantee glimpse wins race
5899 # The same fail_loc is used on client & server so it can work in the
5900 # single node sanity setup
5901 do_facet ost1 $LCTL set_param fail_loc=0x415 fail_val=2
5903 echo "Incorrect size expected (no glimpse fix):"
5904 lockahead_test -d $DIR/$tdir -D $DIR2/$tdir -t $locktest -f $tfile
5906 if [ $rc -eq 0 ]; then
5907 echo "This doesn't work 100%, but this is just reproducing the bug, not testing the fix, so OK to not fail test."
5910 # guarantee write commit timeout has expired
5913 # Clear fail_loc on client
5914 $LCTL set_param fail_loc=0
5916 # Delay write commit by 2 seconds to guarantee glimpse wins race
5917 # OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
5918 do_facet ost1 $LCTL set_param fail_loc=0x214 fail_val=2
5920 # Write commit is still delayed by 2 seconds
5921 lockahead_test -d $DIR/$tdir -D $DIR2/$tdir -t $locktest -f $tfile
5923 [ $rc -eq 0 ] || error "Lockahead test$locktest failed, $rc"
5925 # guarantee write commit timeout has expired
5928 rm -f $DIR/$tfile || error "unable to delete $DIR/$tfile"
5930 run_test 103 "Test size correctness with lockahead"
5936 xtimes=$(stat -c "%X %Y %Z" $DIR/$tfile)
5947 output=$(do_facet mds1 "$DEBUGFS -c -R 'stat ROOT/$tfile' $mdtdev")
5948 ((xtimes[0]=$(awk -F ':' /atime/'{ print $2 }' <<< "$output")))
5949 ((xtimes[1]=$(awk -F ':' /mtime/'{ print $2 }' <<< "$output")))
5950 ((xtimes[2]=$(awk -F ':' /ctime/'{ print $2 }' <<< "$output")))
5958 local xtimes=($(get_stat_xtimes))
5959 local mdt_xtimes=($(get_mdt_xtimes $mdtdev))
5961 echo "STAT a|m|ctime ${xtimes[*]}"
5962 echo "MDT a|m|ctime ${mdt_xtimes[*]}"
5963 [[ ${xtimes[0]} == ${mdt_xtimes[0]} ]] ||
5964 error "$DIR/$tfile atime (${xtimes[0]}:${mdt_xtimes[0]}) diff"
5965 [[ ${xtimes[1]} == ${mdt_xtimes[1]} ]] ||
5966 error "$DIR/$tfile mtime (${xtimes[1]}:${mdt_xtimes[1]}) diff"
5967 [[ ${xtimes[2]} == ${mdt_xtimes[2]} ]] ||
5968 error "$DIR/$tfile ctime (${xtimes[2]}:${mdt_xtimes[2]}) diff"
5972 [ "$mds1_FSTYPE" == "ldiskfs" ] || skip_env "ldiskfs only test"
5973 [ $MDS1_VERSION -lt $(version_code 2.12.4) ] &&
5974 skip "Need MDS version at least 2.12.4"
5977 local mdtdev=$(mdsdevname ${SINGLEMDS//mds/})
5978 local atime_diff=$(do_facet $SINGLEMDS \
5979 lctl get_param -n mdd.*MDT0000*.atime_diff)
5981 do_facet $SINGLEMDS \
5982 lctl set_param -n mdd.*MDT0000*.atime_diff=0
5984 stack_trap "do_facet $SINGLEMDS \
5985 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff" EXIT
5987 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
5988 check_mdt_xtimes $mdtdev
5991 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
5992 check_mdt_xtimes $mdtdev
5994 $MULTIOP $DIR2/$tfile Oz8192w8192_c &
5997 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
5999 kill -USR1 $pid && wait $pid || error "multiop failure"
6000 check_mdt_xtimes $mdtdev
6005 # Verify mtime/ctime is NOT upated on MDS when there is no modification
6006 # on the client side
6007 xtimes=($(get_stat_xtimes))
6008 $MULTIOP $DIR/$tfile O_c &
6011 kill -USR1 $pid && wait $pid || error "multiop failure"
6012 mdt_xtimes=($(get_mdt_xtimes $mdtdev))
6013 [[ ${xtimes[1]} == ${mdt_xtimes[1]} ]] ||
6014 error "$DIR/$tfile mtime (${xtimes[1]}:${mdt_xtimes[1]}) diff"
6015 [[ ${xtimes[2]} == ${mdt_xtimes[2]} ]] ||
6016 error "$DIR/$tfile ctime (${xtimes[2]}:${mdt_xtimes[2]}) diff"
6017 check_mdt_xtimes $mdtdev
6020 # Change ctime via chmod
6021 $MULTIOP $DIR/$tfile o_tc &
6024 kill -USR1 $pid && wait $pid || error "multiop failure"
6025 check_mdt_xtimes $mdtdev
6027 run_test 104 "Verify that MDS stores atime/mtime/ctime during close"
6030 test_mkdir -p $DIR/$tdir
6031 echo test > $DIR/$tdir/$tfile
6032 $LCTL set_param fail_loc=0x416
6033 cancel_lru_locks osc & sleep 1
6034 fsize1=$(stat -c %s $DIR2/$tdir/$tfile)
6036 [[ $fsize1 = 5 ]] || error "Glimpse returned wrong file size $fsize1"
6038 run_test 105 "Glimpse and lock cancel race"
6041 [ "$mds1_FSTYPE" == "ldiskfs" ] && statx_supported ||
6042 skip_env "Test only for ldiskfs and statx() supported"
6047 local mdtdev=$(mdsdevname ${SINGLEMDS//mds/})
6049 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
6050 btime=$($STATX -c %W $DIR/$tfile)
6051 output=$(do_facet mds1 "$DEBUGFS -c -R 'stat ROOT/$tfile' $mdtdev")
6053 ((mdt_btime=$(awk -F ':' /crtime/'{ print $2 }' <<< "$output")))
6054 [[ $btime == $mdt_btime ]] ||
6055 error "$DIR/$tfile btime ($btime:$mdt_btime) diff"
6058 run_test 106a "Verify the btime via statx()"
6061 statx_supported || skip_env "statx() only test"
6066 $LFS setstripe -c 1 $DIR/$tfile || error "$DIR/$tfile setstripe failed"
6067 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
6068 cancel_lru_locks $OSC
6069 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6071 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6072 [ $rpcs_after -eq $((rpcs_before + 1)) ] ||
6073 error "$STATX should send 1 glimpse RPC to $OSC"
6075 cancel_lru_locks $OSC
6076 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6077 # %n: FILENAME; %i: STATX_INO; %A STATX_MODE; %h STATX_NLINK;
6078 # %u: STATX_UID; %g: STATX_GID; %W STATX_BTIME; %X STATX_ATIME;
6080 $STATX -c "%n %i %A %h %u %g %W %X %Z" $DIR/$tfile
6081 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6082 [ $rpcs_after -eq $rpcs_before ] ||
6083 error "$STATX should not send glimpse RPCs to $OSC"
6085 cancel_lru_locks $OSC
6086 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6087 $STATX --cached=always $DIR/$tfile
6088 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6089 [ $rpcs_after -eq $rpcs_before ] ||
6090 error "$STATX should not send glimpse RPCs to $OSC"
6092 cancel_lru_locks $OSC
6093 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6094 $STATX -c %Y $DIR/$tfile
6095 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6096 [ $rpcs_after -eq $((rpcs_before + 1)) ] ||
6097 error "$STATX -c %Y should send 1 glimpse RPC to $OSC"
6099 cancel_lru_locks $OSC
6100 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6101 $STATX -c %s $DIR/$tfile
6102 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6103 [ $rpcs_after -eq $((rpcs_before + 1)) ] ||
6104 error "$STATX -c %s should send 1 glimpse RPC to $OSC"
6106 cancel_lru_locks $OSC
6107 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6108 $STATX -c %b $DIR/$tfile
6109 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6110 [ $rpcs_after -eq $((rpcs_before + 1)) ] ||
6111 error "$STATX -c %b should send 1 glimpse RPC to $OSC"
6113 run_test 106b "Glimpse RPCs test for statx"
6116 statx_supported || skip_env "statx() only test"
6121 # Mask supported in stx_attributes by Lustre is
6122 # STATX_ATTR_IMMUTABLE(0x10) | STATX_ATTR_APPEND(0x20) : (0x30).
6123 mask=$($STATX -c %p $DIR/$tfile)
6124 (( (0x$mask & 0x30) == 0x30 )) ||
6125 error "supported stx_attributes: got '0x$mask', expected '0x30' at least"
6126 chattr +i $DIR/$tfile || error "chattr +i $DIR/$tfile failed"
6127 mask=$($STATX -c %r $DIR/$tfile)
6128 [[ $mask == "10" ]] ||
6129 error "got immutable flags '$mask', expected '10'"
6130 chattr -i $DIR/$tfile || error "chattr -i $DIR/$tfile failed"
6131 mask=$($STATX -c %r $DIR/$tfile)
6132 [[ $mask == "0" ]] || error "got flags '$mask', expected '0'"
6133 chattr +a $DIR/$tfile || error "chattr +a $DIR/$tfile failed"
6134 mask=$($STATX -c %r $DIR/$tfile)
6135 [[ $mask == "20" ]] || error "got flags '$mask', expected '20'"
6136 chattr -a $DIR/$tfile || error "chattr -a $DIR/$tfile failed"
6137 mask=$($STATX -c %r $DIR/$tfile)
6138 [[ $mask == "0" ]] || error "got flags '$mask', expected '0'"
6139 chattr +ia $DIR/$tfile || error "chattr +ia $DIR/$tfile failed"
6140 mask=$($STATX -c %r $DIR/$tfile)
6141 [[ $mask == "30" ]] || error "got flags '$mask', expected '30'"
6142 chattr -ia $DIR/$tfile || error "chattr -ia $DIR/$tfile failed"
6143 mask=$($STATX -c %r $DIR/$tfile)
6144 [[ $mask == "0" ]] || error "got flags '$mask', expected '0'"
6146 run_test 106c "Verify statx attributes mask"
6148 test_107a() { # LU-1031
6149 dd if=/dev/zero of=$DIR1/$tfile bs=1M count=10
6153 $LFS getstripe $DIR1/$tfile
6155 multiop_bg_pause $DIR1/$tfile OG${gid1}_g${gid1}c || return 1
6157 multiop_bg_pause $DIR2/$tfile O_G${gid2}r10g${gid2}c || return 2
6159 kill -USR1 $MULTIPID2
6161 if [[ $(ps h -o comm -p $MULTIPID2) == "" ]]; then
6162 error "First grouplock does not block second one"
6164 echo "First grouplock blocks second one"
6166 kill -USR1 $MULTIPID1
6170 run_test 107a "Basic grouplock conflict"
6173 dd if=/dev/zero of=$DIR1/$tfile bs=1M count=10
6177 $LFS getstripe $DIR1/$tfile
6179 multiop_bg_pause $DIR1/$tfile OG${gid1}_g${gid1}c || return 1
6181 multiop $DIR2/$tfile Or10c &
6185 if [[ $(ps h -o comm -p $MULTIPID2) == "" ]]; then
6186 error "Grouplock does not block IO"
6188 echo "Grouplock blocks IO"
6191 multiop $DIR2/$tfile OG${gid2}_g${gid2}c &
6194 if [[ $(ps h -o comm -p $MULTIPID3) == "" ]]; then
6195 error "First grouplock does not block second one"
6197 echo "First grouplock blocks second one"
6200 kill -USR1 $MULTIPID1
6203 if [[ $(ps h -o comm -p $MULTIPID3) == "" ]]; then
6204 error "Second grouplock thread disappeared"
6207 if [[ $(ps h -o comm -p $MULTIPID2) == "" ]]; then
6208 error "Second grouplock does not block IO"
6210 echo "Second grouplock blocks IO"
6213 kill -USR1 $MULTIPID3
6218 run_test 107b "Grouplock is added to the head of waiting list"
6223 $LFS setstripe -E 1M -c 1 -E -1 $DIR1/$tfile ||
6224 error "Create $DIR1/$tfile failed"
6226 dd if=/dev/zero of=$DIR1/$tfile bs=10000 count=1 ||
6227 error "dd $DIR1/$tfile failed"
6228 offset=$(lseek_test -d 5000 $DIR2/$tfile)
6229 [[ $offset == 5000 ]] || error "offset $offset != 5000"
6231 $TRUNCATE $DIR1/$tfile 2000
6232 offset=$(lseek_test -l 1000 $DIR2/$tfile)
6233 [[ $offset == 2000 ]] || error "offset $offset != 2000"
6235 #define OBD_FAIL_OSC_DELAY_IO 0x414
6236 $LCTL set_param fail_val=4 fail_loc=0x80000414
6237 dd if=/dev/zero of=$DIR1/$tfile count=1 bs=8M conv=notrunc oflag=dsync &
6241 offset=$(lseek_test -l 8000 $DIR2/$tfile)
6243 [[ $offset == 8388608 ]] || error "offset $offset != 8388608"
6245 run_test 108a "lseek: parallel updates"
6253 skip "Clients need to be on different nodes than the servers"
6255 umount_client $MOUNT
6256 umount_client $MOUNT2
6258 echo "Starting race between client mount instances (50 iterations):"
6259 for i in {1..50}; do
6262 #define CFS_FAIL_ONCE|OBD_FAIL_LLITE_RACE_MOUNT 0x80001417
6263 $LCTL set_param -n fail_loc=0x80001417
6265 mount_client $MOUNT & pid1=$!
6266 mount_client $MOUNT2 & pid2=$!
6267 wait $pid1 || error "Mount $MOUNT fails with $?"
6268 wait $pid2 || error "Mount $MOUNT2 fails with $?"
6270 umount_client $MOUNT & pid1=$!
6271 umount_client $MOUNT2 & pid2=$!
6272 wait $pid1 || error "Umount $MOUNT fails with $?"
6273 wait $pid2 || error "Umount $MOUNT2 fails with $?"
6275 $LUSTRE_RMMOD || error "Fail to remove lustre modules"
6281 mount_client $MOUNT2
6284 run_test 109 "Race with several mount instances on 1 node"
6287 local before=$(date +%s)
6294 #define OBD_FAIL_PTLRPC_RESEND_RACE 0x525
6295 do_facet mds1 lctl set_param fail_loc=0x525 fail_val=3
6297 # disable last_xid logic by dropping link reply
6298 ln $DIR/$tdir/f1 $DIR/$tdir/f2 &
6301 #define OBD_FAIL_PTLRPC_ENQ_RESEND 0x534
6302 do_facet mds1 lctl set_param fail_loc=0x534
6304 # RPC will race with its Resend and the Resend will sleep to let
6305 # the original lock to get granted & cancelled.
6307 # AST_SENT is set artificially, so an explicit conflict is not needed
6309 # The woken up Resend gets a new lock, but client does not wait for it
6312 do_facet mds1 lctl set_param fail_loc=0 fail_val=0
6314 # Take a conflict to wait long enough to see the eviction
6317 # let the client reconnect
6319 evict=$(do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state |
6320 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
6322 [ -z "$evict" ] || [[ $evict -le $before ]] ||
6323 (do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state;
6324 error "eviction happened: $evict before:$before")
6326 run_test 110 "do not grant another lock on resend"
6329 [ $MDSCOUNT -ge 2 ] || skip "needs >= 2 MDTs"
6330 [[ $(facet_active_host mds1) = $(facet_active_host mds2) ]] ||
6331 skip "MDT0 and MDT1 should be on the same node"
6334 $LFS mkdir -i 0 $DIR1/$tdir/mdt0dir
6335 $LFS mkdir -i 1 $DIR1/$tdir/mdt1dir
6337 mkdir $DIR1/$tdir/mdt0dir/foodir
6338 touch $DIR1/$tdir/mdt0dir/foodir/{file1,file2}
6340 $MULTIOP $DIR2/$tdir/mdt0dir/foodir/file2 Ow4096_c &
6342 ln $DIR1/$tdir/mdt0dir/foodir/file2 $DIR1/$tdir/mdt1dir/file2
6344 #define OBD_FAIL_MDS_LINK_RENAME_RACE 0x18a
6345 do_facet mds1 $LCTL set_param fail_loc=0x8000018a
6347 ln $DIR1/$tdir/mdt0dir/foodir/file2 $DIR1/$tdir/mdt1dir/file2x &
6350 rm $DIR2/$tdir/mdt1dir/file2
6353 mv $DIR2/$tdir/mdt0dir/foodir/file1 $DIR2/$tdir/mdt0dir/foodir/file2
6358 rm -r $DIR1/$tdir || error "Removing test dir failed"
6360 run_test 111 "A racy rename/link an open file should not cause fs corruption"
6363 (( MDSCOUNT >= 2 )) ||
6364 skip "We need at least 2 MDTs for this test"
6366 (( MDS1_VERSION >= $(version_code 2.14.54) )) ||
6367 skip "Need server version at least 2.14.54"
6372 rr=$($LCTL get_param -n lmv.*.qos_threshold_rr | head -n1)
6374 stack_trap "$LCTL set_param lmv.*.qos_threshold_rr=$rr > /dev/null"
6376 mkdir -p $DIR1/$tdir/s1/s2 || error "mkdir s2 failed"
6377 $LFS mkdir -i 0 $DIR1/$tdir/s1/s2/s3 || error "mkdir s3 failed"
6378 $LFS setdirstripe -D -i -1 --max-inherit-rr=0 $DIR1/$tdir/s1/s2/s3 ||
6379 error "setdirstripe s3 failed"
6380 $LCTL set_param lmv.*.qos_threshold_rr=90
6381 mkdir $DIR2/$tdir/s1/s2/s3/d{1..64}
6382 count=$($LFS getstripe -m $DIR2/$tdir/s1/s2/s3/d* | grep ^0 | wc -l)
6383 (( count == 64 )) || error "only $count subdirs created on MDT0"
6385 $LFS setdirstripe -D -i -1 --max-inherit-rr=3 $DIR1/$tdir/s1/s2/s3 ||
6386 error "setdirstripe s3 failed"
6387 mkdir $DIR2/$tdir/s1/s2/s3/s{1..64}
6388 count=$($LFS getstripe -m $DIR2/$tdir/s1/s2/s3/s* | grep ^0 | wc -l)
6389 (( count == 64 / MDSCOUNT )) || error "$count subdirs created on MDT0"
6391 run_test 112 "update max-inherit in default LMV"
6394 (( MDS1_VERSION >= $(version_code 2.15.50) )) ||
6395 skip "Need server version at least 2.15.50"
6400 instance=$($LFS getname -i $DIR1) ||
6401 error "cannot get instance of $DIR1"
6403 $LFS check osts $DIR1 | grep $instance ||
6404 error "cannot find OSTs of instance $instance"
6406 $LFS check osts $DIR1 | grep -v $instance
6407 if (( $? == 0 )); then
6408 error "find OSTs other than instance $instance"
6411 $LFS check osts | grep $instance ||
6412 error "cannot find other OSTs"
6414 nid=$(df $DIR2 | tail -1 | sed 's%:/.*%%') ||
6415 error "cannot parse nid for $DIR2"
6417 $LFS check mgts $DIR2 | grep MGC$nid ||
6418 error "cannot find mgc of $nid"
6420 $LFS check mgts $DIR2 | grep -v MGC$nid
6421 if (( $? == 0 )); then
6422 error "find MGTs other than nid $nid"
6425 run_test 113 "check servers of specified fs"
6427 check_default_lmv() {
6438 enabled=$(do_facet mds1 \
6439 $LCTL get_param -n mdt.*-MDT0000*.enable_dmv_implicit_inherit)
6441 dmv=$($LFS getdirstripe -D $dir)
6443 index=$(echo $dmv | awk '{ print $4 }')
6444 (( index == $2 )) || error "$dir default stripe index $index != $2"
6446 count=$(echo $dmv | awk '{ print $2 }')
6447 (( count == $3 )) || error "$dir default stripe count $count != $3"
6449 inherit=$(echo $dmv | awk '{ print $8 }')
6450 (( inherit == $4 )) || error "$dir default max-inherit $inherit != $4"
6452 if [ $index -eq -1 ]; then
6453 inherit_rr=$(echo $dmv | awk '{ print $10 }')
6454 (( inherit_rr == $5 )) ||
6455 error "$dir default max-inherit-rr $inherit_rr != $5"
6458 # with --raw, print default LMV stored in inode, otherwise print nothing
6459 raw=$($LFS getdirstripe -D --raw $dir)
6460 if (( enabled == 1 )); then
6462 error "implicit inherited DMV is printed with --raw"
6464 # if disabled, dmv is stored in inode, which will always
6465 # print max-inherit-rr
6467 [[ $raw =~ $dmv.* ]] || error "$dir raw $raw != dmv $dmv"
6471 test_dmv_imp_inherit() {
6479 rm -rf $DIR/$tdir || error "rm $tdir failed"
6480 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
6482 # set dir default LMV
6483 $LFS setdirstripe -D -c1 -X4 --max-inherit-rr 2 $DIR/$tdir ||
6484 error "setdirstripe -D $tdir failed"
6485 dmv=$($LFS getdirstripe -D $DIR/$tdir)
6486 raw=$($LFS getdirstripe -D --raw $DIR/$tdir)
6487 [ "$dmv" == "$raw" ] || error "$dmv != $raw"
6489 mkdir -p $DIR/$tdir/l1/l2/l3 || error "mkdir $DIR/$tdir/l1/l2/l3 failed"
6490 check_default_lmv $DIR/$tdir/l1/l2/l3 -1 1 1 0
6491 check_default_lmv $DIR2/$tdir/l1/l2/l3 -1 1 1 0
6493 # below tests are valid only when this feature is enabled
6494 local enabled=$(do_facet mds1 \
6495 $LCTL get_param -n mdt.*-MDT0000*.enable_dmv_implicit_inherit)
6497 (( enabled == 1 )) || return 0
6499 # set l2 default LMV, dmv of l3 should change immediately
6500 $LFS setdirstripe -D -i1 -c2 -X4 $DIR/$tdir/l1/l2 ||
6501 error "setdirstripe -D $tdir/l1/l2 failed"
6503 check_default_lmv $DIR/$tdir/l1/l2/l3 1 2 3
6504 check_default_lmv $DIR2/$tdir/l1/l2/l3 1 2 3
6506 # change tdir default LMV, dmv of l3 should be unchanged because dmv
6507 # of l2 is explicitly set
6508 $LFS setdirstripe -D -i2 -c2 -X3 $DIR/$tdir ||
6509 error "setdirstripe -D $tdir failed"
6511 check_default_lmv $DIR/$tdir/l1 2 2 2
6512 check_default_lmv $DIR2/$tdir/l1 2 2 2
6513 check_default_lmv $DIR/$tdir/l1/l2/l3 1 2 3
6514 check_default_lmv $DIR2/$tdir/l1/l2/l3 1 2 3
6518 (( MDSCOUNT >= 2 )) ||
6519 skip "We need at least 2 MDTs for this test"
6521 (( MDS1_VERSION >= $(version_code 2.15.55.45) )) ||
6522 skip "Need server version at least 2.15.54.45"
6524 test_dmv_imp_inherit
6526 # disable dmv_imp_inherit to simulate old client
6527 local mdts=$(comma_list $(mdts_nodes))
6529 do_nodes $mdts $LCTL set_param -n \
6530 mdt.*MDT*.enable_dmv_implicit_inherit=0
6531 test_dmv_imp_inherit
6532 do_nodes $mdts $LCTL set_param -n \
6533 mdt.*MDT*.enable_dmv_implicit_inherit=1
6535 run_test 114 "implicit default LMV inherit"
6540 [ "$mds1_FSTYPE" == "ldiskfs" ] || skip_env "ldiskfs only test"
6542 mkdir_on_mdt0 $td || error "can't mkdir"
6543 # turn it htree (don't really needed)
6544 createmany -m $td/f 3000 || error "can't createmany"
6546 # here is an example of debugfs output for htree command:
6547 # Entry #0: Hash 0x00000000, block 27
6548 # Reading directory block 27, phys 16760
6549 # 938 0x0016fb58-7f3d21f5 (32) f775 834 0x001db8c8-d31a4e0e (32) f671
6550 # 1085 0x0040cb70-4498abd4 (32) f922 1850 0x0066a1e6-f6f0dc69 (32) f1687
6551 # 2005 0x006c1a46-ef466058 (32) f1842 2025 0x007e64d4-8b28b734 (32) f1862
6552 # 642 0x008b53a0-77adc601 (32) f479 447 0x009ec152-af54eea3 (32) f284
6553 # 1740 0x00c38f56-ed310e61 (32) f1577 2165 0x00cdfd66-f429a93f (32) f2002
6554 # 930 0x00d7ada4-b80421c9 (32) f767 1946 0x00da6a7a-e8080600 (32) f1783
6555 # 273 0x00f8ea00-760bf97c (32) f110 1589 0x0103c4ee-94fad5dd (32) f1426
6556 # 1383 0x01193516-83120b48 (32) f1220 2379 0x01431e3c-e85b5bd9 (32) f2216
6558 # find couple names in a same htree block of the same size
6559 mdt_dev=$(facet_device $SINGLEMDS)
6560 de=( $(do_facet $SINGLEMDS "debugfs -c -R 'htree /ROOT/$tdir' $mdt_dev" |
6561 awk '/Reading directory block/ { getline; print $4,$8; exit; }' ))
6564 [[ $de1 == "" || $de2 == "" ]] && error "de1=$de1 de2=$de2"
6565 echo "USE: $de1 $de2"
6566 # release one mkdir will lookup
6568 #define OBD_FAIL_MDS_PAUSE_CREATE_AFTER_LOOKUP 0x2401
6569 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x80002401 fail_val=5
6570 mkdir $DIR/$tdir/$de2 &
6574 mkdir $DIR2/$tdir/$de2
6575 # release space $de1 (should be enough to save $de2)
6577 # ready to create a dup of $de2
6579 local found=$(ls $DIR/$tdir/|grep "^$de2\$"|wc -l)
6580 (( $found == 1 )) || error "found $found"
6582 run_test 115 "ldiskfs doesn't check direntry for uniqueness"
6584 log "cleanup: ======================================================"
6586 # kill and wait in each test only guarentee script finish, but command in script
6587 # like 'rm' 'chmod' may still be running, wait for all commands to finish
6588 # otherwise umount below will fail
6589 [ "$(mount | grep $MOUNT2)" ] && wait_update $HOSTNAME "fuser -m $MOUNT2" "" ||
6592 complete_test $SECONDS
6594 check_and_cleanup_lustre