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"
711 test_17() { # bug 3513, 3667
712 remote_ost_nodsh && skip "remote OST with nodsh" && return
714 lfs setstripe $DIR1/$tfile -i 0 -c 1
715 cp $SAMPLE_FILE $DIR1/$tfile
716 cancel_lru_locks osc > /dev/null
717 #define CFS_FAIL_ONCE|OBD_FAIL_LDLM_CREATE_RESOURCE 0x30a
718 do_facet ost1 lctl set_param fail_loc=0x8000030a
719 ls -ls $DIR1/$tfile | awk '{ print $1,$6 }' > $DIR1/$tfile-1 & \
720 ls -ls $DIR2/$tfile | awk '{ print $1,$6 }' > $DIR2/$tfile-2
722 diff -u $DIR1/$tfile-1 $DIR2/$tfile-2 || error "files are different"
724 run_test 17 "resource creation/LVB creation race ==============="
727 # turn e.g. ALWAYS_EXCEPT="18c" into "-e 3"
730 for idx in {a..z}; do
731 local ptr=EXCEPT_ALWAYS_18$idx
732 [ x${!ptr} = xtrue ] || continue
734 excepts="$excepts -e $(($(printf %d \'$idx)-96))"
737 excepts="$excepts -e 7 -e 8 -e 9"
738 $LUSTRE/tests/mmap_sanity -d $MOUNT1 -m $MOUNT2 $excepts ||
739 error "mmap_sanity test failed"
742 run_test 18 "mmap sanity check ================================="
744 test_19() { # bug3811
745 local node=$(facet_active_host ost1)
746 local device="$FSNAME-OST*"
748 [ "x$DOM" = "xyes" ] && node=$(facet_active_host $SINGLEMDS) &&
749 device="$FSNAME-MDT*"
751 # check whether obdfilter is cache capable at all
752 get_osd_param $node $device read_cache_enable >/dev/null ||
753 skip "not cache-capable obdfilter"
755 local max=$(get_osd_param $node $device readcache_max_filesize |\
757 set_osd_param $node $device readcache_max_filesize 4096
758 dd if=/dev/urandom of=$TMP/$tfile bs=512k count=32
759 local SUM=$(cksum $TMP/$tfile | cut -d" " -f 1,2)
760 cp $TMP/$tfile $DIR1/$tfile
761 for i in `seq 1 20`; do
762 [ $((i % 5)) -eq 0 ] && log "$testname loop $i"
763 cancel_lru_locks $OSC > /dev/null
764 cksum $DIR1/$tfile | cut -d" " -f 1,2 > $TMP/sum1 & \
765 cksum $DIR2/$tfile | cut -d" " -f 1,2 > $TMP/sum2
767 [ "$(cat $TMP/sum1)" = "$SUM" ] || \
768 error "$DIR1/$tfile $(cat $TMP/sum1) != $SUM"
769 [ "$(cat $TMP/sum2)" = "$SUM" ] || \
770 error "$DIR2/$tfile $(cat $TMP/sum2) != $SUM"
772 set_osd_param $node $device readcache_max_filesize $max
775 run_test 19 "test concurrent uncached read races ==============="
778 test_mkdir $DIR1/$tdir
780 CNT=$($LCTL get_param -n llite.*.dump_page_cache | wc -l)
781 $MULTIOP $DIR1/$tdir/$tfile Ow8190c
782 $MULTIOP $DIR2/$tdir/$tfile Oz8194w8190c
783 $MULTIOP $DIR1/$tdir/$tfile Oz0r8190c
785 CNT2=$($LCTL get_param -n llite.*.dump_page_cache | wc -l)
786 [[ $CNT2 == $CNT ]] ||
787 error $((CNT2 - CNT))" page left in cache after lock cancel"
789 run_test 20 "test extra readahead page left in cache ===="
796 test_21() { # Bug 5907
797 test_mkdir $DIR1/$tdir
798 mount /etc $DIR1/$tdir --bind || error "mount failed" # Poor man's mount.
800 rmdir -v $DIR1/$tdir && error "Removed mounted directory"
801 rmdir -v $DIR2/$tdir && echo "Removed mounted directory from another mountpoint, needs to be fixed"
802 test -d $DIR1/$tdir || error "Mounted directory disappeared"
804 test -d $DIR2/$tdir || test -d $DIR1/$tdir && error "Removed dir still visible after umount"
807 run_test 21 " Try to remove mountpoint on another dir ===="
809 test_23() { # Bug 5972
810 local at_diff=$(do_facet $SINGLEMDS \
811 $LCTL get_param -n mdd.*MDT0000*.atime_diff | head -n1)
812 echo "atime should be updated while another read" > $DIR1/$tfile
814 # clear the lock(mode: LCK_PW) gotten from creating operation
815 cancel_lru_locks $OSC
818 sleep $((at_diff + 1))
820 echo "starting reads"
821 multiop_bg_pause $DIR1/$tfile or20_c || return 1
822 # with SOM and opencache enabled, we need to close a file and cancel
823 # open lock to get atime propogated to MDS
824 kill -USR1 $! || return 2
827 time2=$(stat -c "%X" $DIR/$tfile)
828 echo "new atime is $time2"
830 [ $time2 -gt $time1 ] || error "atime was not updated"
831 rm -f $DIR1/$tfile || error "rm -f $DIR1/$tfile failed"
834 run_test 23 " others should see updated atime while another read===="
838 lfs df || error "lfs df failed"
839 lfs df -ih || error "lfs df -ih failed"
840 lfs df -h $DIR1 || error "lfs df -h $DIR1 failed"
841 lfs df -i $DIR2 || error "lfs df -i $DIR2 failed"
842 lfs df $DIR1/$tfile || error "lfs df $DIR1/$tfile failed"
843 lfs df -ih $DIR2/$tfile || error "lfs df -ih $DIR2/$tfile failed"
845 OSC=`lctl dl | awk '/-osc-|OSC.*MNT/ {print $4}' | head -n 1`
846 # OSC=`lctl dl | awk '/-osc-/ {print $4}' | head -n 1`
847 lctl --device %osc deactivate
848 lfs df -i || error "lfs df -i with deactivated OSC failed"
849 lctl --device %osc activate
850 lfs df || error "lfs df with reactivated OSC failed"
852 run_test 24a "lfs df [-ih] [path] test ========================="
856 fsnum=$(lfs_df | grep -c "summary")
857 [ $fsnum -eq 2 ] || error "lfs df shows $fsnum != 2 filesystems."
859 run_test 24b "lfs df should show both filesystems ==============="
862 local acl=$(lctl get_param -n mdc.*MDT0000-mdc-*.connect_flags |
864 [ "$acl" -lt 1 ] && skip "must have acl, skipping" && return
867 touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
868 chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
870 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
871 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
872 error "setfacl $DIR2/$tdir #1"
873 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
874 setfacl -m u:$RUNAS_ID:r-x -m g:$RUNAS_GID:r-x $DIR1/$tdir ||
875 error "setfacl $DIR2/$tdir #2"
876 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
877 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
878 error "setfacl $DIR2/$tdir #3"
879 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
880 setfacl -x u:$RUNAS_ID: -x g:$RUNAS_GID: $DIR1/$tdir ||
881 error "setfacl $DIR2/$tdir #4"
882 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
886 run_test 25a "change ACL on one mountpoint be seen on another ==="
889 local acl=$(lctl get_param -n mdc.*MDT0000-mdc-*.connect_flags |
891 [ "$acl" -lt 1 ] && skip "must have acl, skipping" && return
893 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
896 $LFS mkdir -i 1 $DIR1/$tdir
897 touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
898 chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
900 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
901 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
902 error "setfacl $DIR2/$tdir #1"
903 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
904 setfacl -m u:$RUNAS_ID:r-x -m g:$RUNAS_GID:r-x $DIR1/$tdir ||
905 error "setfacl $DIR2/$tdir #2"
906 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
907 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
908 error "setfacl $DIR2/$tdir #3"
909 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
910 setfacl -x u:$RUNAS_ID: -x g:$RUNAS_GID: $DIR1/$tdir ||
911 error "setfacl $DIR2/$tdir #4"
912 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
916 run_test 25b "change ACL under remote dir on one mountpoint be seen on another"
919 utime $DIR1/f26a -s $DIR2/f26a || error "utime failed for $DIR1/f26a"
921 run_test 26a "allow mtime to get older"
926 echo "aaa" >> $DIR1/$tfile
928 chmod a+x $DIR2/$tfile
929 mt1=`stat -c %Y $DIR1/$tfile`
930 mt2=`stat -c %Y $DIR2/$tfile`
932 if [ x"$mt1" != x"$mt2" ]; then
933 error "not equal mtime, client1: "$mt1", client2: "$mt2"."
936 run_test 26b "sync mtime between ost and mds"
939 cancel_lru_locks $OSC
941 dd if=/dev/zero of=$DIR2/$tfile bs=$((4096+4))k conv=notrunc count=4 seek=3 &
946 dd if=/dev/zero of=$DIR1/$tfile bs=$((16384-1024))k conv=notrunc count=1 seek=4 &
951 dd if=/dev/zero of=$DIR1/$tfile bs=8k conv=notrunc count=1 seek=0
953 lctl set_param -n ldlm.dump_namespaces ""
954 wait $DD1_PID $DD2_PID
955 [ $? -ne 0 ] && lctl dk $TMP/debug || true
957 run_test 27 "align non-overlapping extent locks from request ==="
959 test_28() { # bug 9977
960 skip "echo_client on osc is no longer supported"
962 run_test 28 "read/write/truncate file with lost stripes"
964 test_30() { #b=11110, LU-2523
965 test_mkdir $DIR1/$tdir
966 cp -f /bin/bash $DIR1/$tdir/bash
967 bash -c 'sleep 1; rm -f $DIR2/$tdir/bash; cp /bin/bash $DIR2/$tdir' &
968 $DIR1/$tdir/bash -c 'sleep 2;
969 openfile -f O_RDONLY /proc/$$/exe >& /dev/null; echo $?'
973 run_test 30 "recreate file race"
976 test_mkdir $DIR1/$tdir
977 local writes=$(LANG=C dd if=/dev/zero of=$DIR/$tdir/$tfile \
978 count=1 2>&1 | awk 'BEGIN { FS="+" } /out/ {print $1}')
979 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
980 lctl set_param fail_loc=0x314
981 local reads=$(LANG=C dd if=$DIR2/$tdir/$tfile of=/dev/null 2>&1 |
982 awk 'BEGIN { FS="+" } /in/ {print $1}')
983 [ $reads -eq $writes ] || error "read" $reads "blocks, must be" $writes
985 run_test 31a "voluntary cancel / blocking ast race=============="
988 remote_ost || { skip "local OST" && return 0; }
989 remote_ost_nodsh && skip "remote OST w/o dsh" && return 0
991 # make sure there is no local locks due to destroy
992 wait_mds_ost_sync || error "wait_mds_ost_sync()"
993 wait_delete_completed || error "wait_delete_completed()"
995 test_mkdir $DIR1/$tdir
996 lfs setstripe $DIR/$tdir/$tfile -i 0 -c 1
997 cp /etc/hosts $DIR/$tdir/$tfile
998 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
999 lctl set_param fail_loc=0x314
1000 #define OBD_FAIL_LDLM_OST_FAIL_RACE 0x316
1001 do_facet ost1 lctl set_param fail_loc=0x316
1002 # Don't crash kernel
1003 cat $DIR2/$tdir/$tfile > /dev/null 2>&1
1004 lctl set_param fail_loc=0
1005 do_facet ost1 lctl set_param fail_loc=0
1006 # cleanup: reconnect the client back
1009 run_test 31b "voluntary OST cancel / blocking ast race=============="
1011 #LU-14949 - multi-client version of the test 31r in sanity.
1013 touch $DIR/$tfile.target
1014 touch $DIR/$tfile.source
1016 ls -l $DIR/$tfile.target # cache it for sure
1018 #OBD_FAIL_LLITE_OPEN_DELAY 0x1419
1019 $LCTL set_param fail_loc=0x1419 fail_val=3
1020 cat $DIR/$tfile.target &
1023 # Guarantee open is waiting before we get here
1025 mv $DIR2/$tfile.source $DIR2/$tfile.target
1029 if [[ $RC -ne 0 ]]; then
1030 error "open with cat failed, rc=$RC"
1033 run_test 31r "open-rename(replace) race"
1035 test_32b() { # bug 11270
1036 remote_ost_nodsh && skip "remote OST with nodsh" && return
1039 local facets=$(get_facets OST)
1040 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
1042 save_lustre_params client "osc.*.contention_seconds" > $p
1043 save_lustre_params $facets \
1044 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
1045 save_lustre_params $facets \
1046 "ldlm.namespaces.filter-*.contended_locks" >> $p
1047 save_lustre_params $facets \
1048 "ldlm.namespaces.filter-*.contention_seconds" >> $p
1049 clear_stats $OSC.*.${OSC}_stats
1051 # agressive lockless i/o settings
1052 do_nodes $(comma_list $(osts_nodes)) \
1053 "lctl set_param -n ldlm.namespaces.*.max_nolock_bytes=2000000 \
1054 ldlm.namespaces.filter-*.contended_locks=0 \
1055 ldlm.namespaces.filter-*.contention_seconds=60"
1056 lctl set_param -n $OSC.*.contention_seconds=60
1058 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > \
1060 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > \
1063 [ $(calc_stats $OSC.*.${OSC}_stats lockless_write_bytes) -ne 0 ] ||
1064 error "lockless i/o was not triggered"
1065 # disable lockless i/o (it is disabled by default)
1066 do_nodes $(comma_list $(osts_nodes)) \
1067 "lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes=0 \
1068 ldlm.namespaces.filter-*.contended_locks=32 \
1069 ldlm.namespaces.filter-*.contention_seconds=0"
1070 # set contention_seconds to 0 at client too, otherwise Lustre still
1071 # remembers lock contention
1072 lctl set_param -n $OSC.*.contention_seconds=0
1073 clear_stats $OSC.*.${OSC}_stats
1075 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > \
1077 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > \
1080 [ $(calc_stats $OSC.*.${OSC}_stats lockless_write_bytes) -eq 0 ] ||
1081 error "lockless i/o works when disabled"
1083 restore_lustre_params <$p
1086 # Disable test 32b prior to full removal
1087 #run_test 32b "lockless i/o"
1090 local mdts=$(get_facets MDS)
1096 for mds in ${mdts//,/ }; do
1099 dev=$(basename $(do_facet $mds "lctl get_param -n \
1100 osd*.${!varsvc}.mntdev | xargs readlink -f"))
1101 val=$(do_facet $mds "cat /proc/fs/jbd*/${dev}{,:*,-*}/info \
1102 2>/dev/null | head -n1")
1104 stat=$((stat + val))
1109 # commit on sharing tests
1111 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1113 [ $CLIENTCOUNT -lt 2 ] &&
1114 skip "Need two or more clients, have $CLIENTCOUNT"
1116 local nfiles=${TEST33_NFILES:-10000}
1117 local param_file=$TMP/$tfile-params
1123 save_lustre_params $(get_facets MDS) \
1124 "mdt.*.commit_on_sharing" > $param_file
1127 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
1131 do_nodes $CLIENT1,$CLIENT2 "mkdir -p $DIR1/$tdir-\\\$(hostname)-$i"
1133 [ "$mds1_FSTYPE" = ldiskfs ] && jbdold=$(print_jbd_stat)
1134 echo "=== START createmany old: $jbdold transaction"
1135 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")
1136 [ "$mds1_FSTYPE" = ldiskfs ] && jbdnew=$(print_jbd_stat)
1137 [ "$mds1_FSTYPE" = ldiskfs ] && jbd=$(( jbdnew - jbdold ))
1138 echo "=== END createmany new: $jbdnew transaction : $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
1139 [ "$mds1_FSTYPE" = ldiskfs ] && avgjbd=$(( avgjbd + jbd ))
1140 avgtime=$(( avgtime + elapsed ))
1142 eval cos${COS}_jbd=$((avgjbd / 3))
1143 eval cos${COS}_time=$((avgtime / 3))
1146 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
1147 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
1148 [ "$cos0_jbd" != 0 ] &&
1149 echo "COS=1 vs COS=0 jbd: $((((cos1_jbd/cos0_jbd - 1)) * 100 )) %"
1150 [ "$cos0_time" != 0 ] &&
1151 echo "COS=1 vs COS=0 time: $((((cos1_time/cos0_time - 1)) * 100 )) %"
1153 restore_lustre_params < $param_file
1157 run_test 33a "commit on sharing, cross crete/delete, 2 clients, benchmark"
1159 # commit on sharing tests
1161 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1163 [ $CLIENTCOUNT -ge 2 ] ||
1164 { skip "Need two or more clients, have $CLIENTCOUNT" &&
1166 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1168 local nfiles=${TEST33_NFILES:-10000}
1169 local param_file=$TMP/$tfile-params
1171 save_lustre_params $(get_facets MDS) \
1172 "mdt.*.commit_on_sharing" > $param_file
1181 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
1185 do_node $CLIENT1 "$LFS mkdir -i $MDTIDX \
1186 $DIR1/$tdir-\\\$(hostname)-$i"
1188 jbdold=$(print_jbd_stat)
1189 echo "=== START createmany old: $jbdold transaction"
1190 local elapsed=$(do_and_time "do_nodes $CLIENT1,$CLIENT2\
1191 createmany -o $DIR1/$tdir-\\\$(hostname)-$i/f- \
1192 -r$DIR2/$tdir-\\\$(hostname)-$i/f- $nfiles > \
1194 jbdnew=$(print_jbd_stat)
1195 jbd=$(( jbdnew - jbdold ))
1196 echo "=== END createmany new: $jbdnew transaction : \
1197 $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
1198 avgjbd=$(( avgjbd + jbd ))
1199 avgtime=$(( avgtime + elapsed ))
1201 eval cos${COS}_jbd=$((avgjbd / 3))
1202 eval cos${COS}_time=$((avgtime / 3))
1205 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
1206 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
1207 [ "$cos0_jbd" != 0 ] &&
1208 echo "COS=1 vs COS=0 jbd: $(((cos1_jbd/cos0_jbd - 1) * 100)) %"
1209 [ "$cos0_time" != 0 ] &&
1210 echo "COS=1 vs COS=0 time: $(((cos1_time/cos0_time - 1) * 100)) %"
1212 restore_lustre_params < $param_file
1216 run_test 33b "COS: cross create/delete, 2 clients, benchmark under remote dir"
1219 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
1220 [ "$MDS1_VERSION" -lt $(version_code 2.7.63) ] &&
1221 skip "DNE CoS not supported"
1225 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS || error "start mds1 failed"
1229 mkdir_on_mdt0 $DIR/$tdir
1231 do_facet mds1 "lctl set_param -n mdt.*.sync_count=0"
1232 # do twice in case transaction is committed before unlock, see LU-8200
1234 # remote dir is created on MDT1, which enqueued lock of $tdir on
1236 $LFS mkdir -i 1 $DIR/$tdir/remote.$i
1237 mkdir $DIR/$tdir/local.$i
1239 sync_count=$(do_facet mds1 "lctl get_param -n mdt.*MDT0000.sync_count")
1240 echo "sync_count $sync_count"
1241 [ $sync_count -eq 0 ] && error "Sync-Lock-Cancel not triggered"
1244 do_facet mds1 "lctl set_param -n mdt.*.sync_count=0"
1245 $LFS mkdir -i 1 $DIR/$tdir/remote.3
1246 # during sleep remote mkdir should have been committed and canceled
1247 # remote lock spontaneously, which shouldn't trigger sync
1249 mkdir $DIR/$tdir/local.3
1250 sync_count=$(do_facet mds1 "lctl get_param -n mdt.*MDT0000.sync_count")
1251 echo "sync_count $sync_count"
1252 [ $sync_count -eq 0 ] || error "Sync-Lock-Cancel triggered"
1254 run_test 33c "Cancel cross-MDT lock should trigger Sync-Lock-Cancel"
1256 # arg1 is operations done before CoS, arg2 is the operation that triggers CoS
1260 local nodes=$(comma_list $(mdts_nodes))
1264 # trigger CoS twice in case transaction commit before unlock
1267 do_nodes $nodes "lctl set_param -n mdt.*.async_commit_count=0"
1269 commit_nr=$(do_nodes $nodes \
1270 "lctl get_param -n mdt.*.async_commit_count" | calc_sum)
1271 total=$((total + commit_nr));
1276 echo "CoS count $total"
1277 [ $total -gt 0 ] || error "$2 didn't trigger CoS"
1281 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
1282 [ "$MDS1_VERSION" -lt $(version_code 2.7.63) ] &&
1283 skip "DNE CoS not supported"
1285 # remote directory create
1286 op_trigger_cos "$LFS mkdir -i 0 $DIR/$tdir" "$LFS mkdir -i 1 $DIR/$tdir/subdir"
1287 # remote directory unlink
1288 op_trigger_cos "$LFS mkdir -i 1 $DIR/$tdir" "rmdir $DIR/$tdir"
1289 # striped directory create
1290 op_trigger_cos "mkdir $DIR/$tdir" "$LFS mkdir -c 2 $DIR/$tdir/subdir"
1291 # striped directory setattr
1292 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; touch $DIR/$tdir" \
1293 "chmod 713 $DIR/$tdir"
1294 # striped directory unlink
1295 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; touch $DIR/$tdir" \
1298 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; \
1299 $LFS mkdir -i 0 $DIR/$tdir/d1; \
1300 $LFS mkdir -i 1 $DIR/$tdir/d2; \
1301 touch $DIR/$tdir/d1/tgt" \
1302 "ln $DIR/$tdir/d1/tgt $DIR/$tdir/d2/src"
1304 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; \
1305 $LFS mkdir -i 0 $DIR/$tdir/d1; \
1306 $LFS mkdir -i 1 $DIR/$tdir/d2; \
1307 touch $DIR/$tdir/d1/src" \
1308 "mv $DIR/$tdir/d1/src $DIR/$tdir/d2/tgt"
1310 op_trigger_cos "$LFS mkdir -i 0 $DIR/$tdir" \
1311 "$LFS migrate -m 1 $DIR/$tdir"
1315 run_test 33d "DNE distributed operation should trigger COS"
1318 [ $CLIENTCOUNT -ge 2 ] ||
1319 skip "Need two or more clients, have $CLIENTCOUNT"
1320 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
1321 [ "$MDS1_VERSION" -lt $(version_code 2.7.63) ] &&
1322 skip "DNE CoS not supported"
1324 local client2=${CLIENT2:-$(hostname)}
1328 local nodes=$(comma_list $(mdts_nodes))
1329 do_nodes $nodes "lctl set_param -n mdt.*.async_commit_count=0"
1331 $LFS mkdir -c 2 $DIR/$tdir
1332 mkdir $DIR/$tdir/subdir
1333 echo abc > $DIR/$tdir/$tfile
1334 do_node $client2 echo dfg >> $DIR/$tdir/$tfile
1335 do_node $client2 touch $DIR/$tdir/subdir
1337 local async_commit_count=$(do_nodes $nodes \
1338 "lctl get_param -n mdt.*.async_commit_count" | calc_sum)
1339 [ $async_commit_count -gt 0 ] && error "CoS triggerred"
1343 run_test 33e "DNE local operation shouldn't trigger COS"
1345 # End commit on sharing tests
1347 get_ost_lock_timeouts() {
1348 local nodes=${1:-$(comma_list $(osts_nodes))}
1350 local locks=$(do_nodes $nodes \
1351 "lctl get_param -n ldlm.namespaces.filter-*.lock_timeouts" | calc_sum)
1359 do_nodes $(comma_list $(osts_nodes)) \
1360 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1361 for i in $(seq $OSTCOUNT); do
1362 wait_osc_import_ready client ost$i
1367 remote_ost_nodsh && skip "remote OST with nodsh" && return
1371 trap cleanup_34 EXIT RETURN
1372 for OPER in notimeout timeout ; do
1373 rm $DIR1/$tfile 2>/dev/null
1374 lock_in=$(get_ost_lock_timeouts)
1375 if [ $OPER == "timeout" ] ; then
1376 for j in `seq $OSTCOUNT`; do
1377 #define OBD_FAIL_PTLRPC_HPREQ_TIMEOUT 0x511
1378 do_facet ost$j lctl set_param fail_loc=0x511
1380 echo lock should expire
1382 for j in `seq $OSTCOUNT`; do
1383 #define OBD_FAIL_PTLRPC_HPREQ_NOTIMEOUT 0x512
1384 do_facet ost$j lctl set_param fail_loc=0x512
1386 echo lock should not expire
1388 echo writing on client1
1389 dd if=/dev/zero of=$DIR1/$tfile count=100 conv=notrunc > /dev/null 2>&1
1391 echo reading on client2
1392 dd of=/dev/null if=$DIR2/$tfile > /dev/null 2>&1
1393 # wait for a lock timeout
1395 lock_out=$(get_ost_lock_timeouts)
1396 if [ $OPER == "timeout" ] ; then
1397 if [ $lock_in == $lock_out ]; then
1398 error "no lock timeout happened"
1403 if [ $lock_in != $lock_out ]; then
1404 error "lock timeout happened"
1412 run_test 34 "no lock timeout under IO"
1414 test_35() { # bug 17645
1417 gen=$(lctl get_param mdc.$FSNAME-MDT*-mdc-*.import | grep generation |
1418 awk '/generation/{print $2}')
1420 generation[count]=$g
1424 test_mkdir $MOUNT1/$tdir
1425 cancel_lru_locks mdc
1427 # Let's initiate -EINTR situation by setting fail_loc and take
1428 # write lock on same file from same client. This will not cause
1429 # bl_ast yet as lock is already in local cache.
1430 #define OBD_FAIL_LDLM_INTR_CP_AST 0x317
1431 do_facet client "lctl set_param fail_loc=0x80000317"
1432 local timeout=$(do_facet $SINGLEMDS lctl get_param -n timeout)
1433 let timeout=timeout*3
1435 while test $nr -lt 10; do
1436 log "Race attempt $nr"
1437 local blk1=$(lctl get_param -n ldlm.services.ldlm_cbd.stats |
1438 awk '/ldlm_bl_callback/ { print $2 }')
1439 test "x$blk1" = "x" && blk1=0
1440 createmany -o $MOUNT2/$tdir/a 4000 &
1444 # Let's make conflict and bl_ast
1445 ls -la $MOUNT1/$tdir > /dev/null &
1448 log "Wait for $pid1 $pid2 for $timeout sec..."
1450 kill -9 $pid1 $pid2 > /dev/null 2>&1
1452 local blk2=$(lctl get_param -n ldlm.services.ldlm_cbd.stats |
1453 awk '/ldlm_bl_callback/ { print $2 }')
1454 test "x$blk2" = "x" && blk2=0
1455 test $blk2 -gt $blk1 && break
1456 rm -fr $MOUNT1/$tdir
1457 cancel_lru_locks mdc
1460 do_facet client "lctl set_param fail_loc=0x0"
1461 df -h $MOUNT1 $MOUNT2
1463 gen=$(lctl get_param mdc.$FSNAME-MDT*-mdc-*.import | grep generation |
1464 awk '/generation/{print $2}')
1466 if ! test "$g" -eq "${generation[count]}"; then
1467 list=$(lctl list_param mdc.$FSNAME-MDT*-mdc-*.import)
1469 for imp in $list; do
1470 if [ $c = $count ]; then
1475 imp=$(echo "$imp" | awk -F"." '{print $2}')
1476 error "Eviction happened on import $imp"
1481 run_test 35 "-EINTR cp_ast vs. bl_ast race does not evict client"
1483 test_36() { #bug 16417
1488 test_mkdir $DIR1/$tdir
1489 $LFS setstripe -c -1 $DIR1/$tdir
1492 let SIZE_B=SIZE*1024*1024
1493 sync; sleep 2; sync # wait for delete thread
1494 wait_mds_ost_sync || error "wait_mds_ost_sync failed"
1495 wait_destroy_complete || error "wait_destroy_complete failed"
1497 while [ $i -le 10 ]; do
1498 lctl mark "start test - cycle ($i)"
1499 local before=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1500 dd if=/dev/zero of=$DIR1/$tdir/$tfile bs=1M count=$SIZE ||
1501 error "dd $DIR1/$tdir/$tfile ${SIZE}MB failed"
1502 sync # sync data from client cache
1503 sync_all_data # sync data from server cache (delayed allocation)
1505 local after_dd=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1506 multiop_bg_pause $DIR2/$tdir/$tfile O_r${SIZE_B}c || return 3
1508 rm -f $DIR1/$tdir/$tfile
1509 kill -USR1 $read_pid
1511 sync; sleep 2; sync # Ensure new statfs
1512 wait_delete_completed
1513 local after=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1514 echo "*** cycle($i) *** before($before) after_dd($after_dd)" \
1516 # this free space! not used
1517 (( $after_dd <= $after)) ||
1518 error "space leaked after_dd:$after_dd > after:$after"
1522 run_test 36 "handle ESTALE/open-unlink correctly"
1524 test_37() { # bug 18695
1525 test_mkdir $DIR1/$tdir
1526 multiop_bg_pause $DIR1/$tdir D_c || return 1
1528 # create large directory (32kB seems enough from e2fsck, ~= 1000 files)
1529 createmany -m $DIR2/$tdir/f 10000
1530 # set mtime/atime backward
1531 touch -t 198001010000 $DIR2/$tdir
1532 kill -USR1 $MULTIPID
1533 nr_files=`lfs find $DIR1/$tdir -type f | wc -l`
1534 [ $nr_files -eq 10000 ] || error "$nr_files != 10000 truncated directory?"
1537 run_test 37 "check i_size is not updated for directory on close (bug 18695) =============="
1539 # this should be set to past
1540 TEST_39_MTIME=`date -d "1 year ago" +%s`
1544 local client1=${CLIENT1:-`hostname`}
1545 local client2=${CLIENT2:-`hostname`}
1547 do_node $client1 "touch $DIR1/$tfile"
1549 do_node $client1 "touch -m -d @$TEST_39_MTIME $DIR1/$tfile"
1550 local mtime1=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1551 [ "$mtime1" = $TEST_39_MTIME ] || \
1552 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
1554 local d1=`do_node $client1 date +%s`
1555 do_node $client1 'echo hello >> '$DIR1/$tfile
1556 local d2=`do_node $client1 date +%s`
1558 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1559 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
1560 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
1562 do_node $client1 "mv $DIR1/$tfile $DIR1/$tfile-1"
1564 for (( i=0; i < 2; i++ )) ; do
1565 local mtime3=`do_node $client2 "stat -c %Y $DIR1/$tfile-1"`
1566 [ "$mtime2" = "$mtime3" ] || \
1567 error "mtime ($mtime2) changed (to $mtime3) on rename"
1569 cancel_lru_locks osc
1570 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1573 run_test 39a "test from 11063 =================================="
1576 local client1=${CLIENT1:-`hostname`}
1577 local client2=${CLIENT2:-`hostname`}
1581 local mtime1=`stat -c %Y $DIR1/$tfile`
1582 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1585 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
1587 for (( i=0; i < 2; i++ )) ; do
1588 local mtime3=`stat -c %Y $DIR1/$tfile`
1589 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1591 [ "$mtime3" = "$mtime4" ] || \
1592 error "different mtime on clients: $mtime3, $mtime4"
1593 [ "$mtime3" = $TEST_39_MTIME ] || \
1594 error "lost mtime: $mtime3, should be $TEST_39_MTIME"
1596 cancel_lru_locks osc
1597 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1600 run_test 39b "11063 problem 1 =================================="
1603 local client1=${CLIENT1:-`hostname`}
1604 local client2=${CLIENT2:-`hostname`}
1606 echo hello > $DIR1/$tfile
1608 local mtime1=`stat -c %Y $DIR1/$tfile`
1609 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1610 [ "$mtime1" = "$mtime2" ] || \
1611 error "create: different mtime on clients: $mtime1, $mtime2"
1614 $TRUNCATE $DIR1/$tfile 1
1616 for (( i=0; i < 2; i++ )) ; do
1617 local mtime3=`stat -c %Y $DIR1/$tfile`
1618 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1620 [ "$mtime3" = "$mtime4" ] || \
1621 error "different mtime on clients: $mtime3, $mtime4"
1622 [ "$mtime3" -gt $mtime2 ] || \
1623 error "truncate did not update mtime: $mtime2, $mtime3"
1625 cancel_lru_locks osc
1626 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1629 run_test 39c "check truncate mtime update ======================"
1631 test_39d() { # LU-7310
1633 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
1635 local mtime1=$(stat -c %Y $DIR2/$tfile)
1636 [ "$mtime1" = $TEST_39_MTIME ] ||
1637 error "mtime: $mtime1, should be $TEST_39_MTIME"
1640 # define OBD_FAIL_OSC_NO_GRANT 0x411
1641 $LCTL set_param fail_loc=0x411
1643 local d1=$(date +%s)
1644 echo hello >> $DIR1/$tfile
1645 local d2=$(date +%s)
1647 $LCTL set_param fail_loc=0
1649 cancel_lru_locks $OSC
1651 local mtime2=$(stat -c %Y $DIR2/$tfile)
1652 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] ||
1653 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
1655 run_test 39d "sync write should update mtime"
1658 # how long 40-47 take with specific delay
1665 # for pdo testing, we must cancel MDT-MDT locks as well as client locks to
1666 # avoid unexpected delays due to previous tests
1668 cancel_lru_locks mdc
1669 do_nodes $(comma_list $(mdts_nodes)) \
1670 $LCTL set_param -n ldlm.namespaces.*mdt*.lru_size=clear
1671 do_nodes $(comma_list $(mdts_nodes)) \
1672 $LCTL get_param ldlm.namespaces.*mdt*.lock_unused_count \
1673 ldlm.namespaces.*mdt*.lock_count | grep -v '=0'
1676 # check that pid exists hence second operation wasn't blocked by first one
1677 # if it is so then there is no conflict, return 0
1678 # else second operation is conflicting with first one, return 1
1679 check_pdo_conflict() {
1682 pdo_sched # to ensure OP1 is finished on client if OP2 is blocked by OP1
1683 if [[ `ps --pid $pid | wc -l` == 1 ]]; then
1693 # test 40: check non-blocking operations
1695 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1697 mkdir_on_mdt0 $DIR2/$tdir
1699 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1700 do_nodes $(comma_list $(mdts_nodes)) \
1701 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1702 mkdir $DIR1/$tdir/$tfile &
1704 touch $DIR2/$tdir/$tfile-2
1705 check_pdo_conflict $PID1 || error "create is blocked"
1706 mkdir $DIR2/$tdir/$tfile-3
1707 check_pdo_conflict $PID1 || error "mkdir is blocked"
1708 link $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-4
1709 check_pdo_conflict $PID1 || error "link is blocked"
1710 mv $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-5
1711 check_pdo_conflict $PID1 || error "rename is blocked"
1712 stat $DIR2/$tdir/$tfile-3 $DIR2/$tdir/$tfile-4 > /dev/null
1713 check_pdo_conflict $PID1 || error "getattr is blocked"
1714 rm $DIR2/$tdir/$tfile-4 $DIR2/$tdir/$tfile-5
1715 rmdir $DIR2/$tdir/$tfile-3
1716 check_pdo_conflict $PID1 || error "unlink is blocked"
1718 # all operations above shouldn't wait the first one
1719 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1720 do_nodes $(comma_list $(mdts_nodes)) \
1721 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1726 run_test 40a "pdirops: create vs others =============="
1729 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1731 mkdir_on_mdt0 $DIR2/$tdir
1733 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1734 do_nodes $(comma_list $(mdts_nodes)) \
1735 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1736 touch $DIR1/$tdir/$tfile &
1739 touch $DIR2/$tdir/$tfile-2
1740 check_pdo_conflict $PID1 || error "create is blocked"
1741 mkdir $DIR2/$tdir/$tfile-3
1742 check_pdo_conflict $PID1 || error "mkdir is blocked"
1743 link $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-4
1744 check_pdo_conflict $PID1 || error "link is blocked"
1745 mv $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-5
1746 check_pdo_conflict $PID1 || error "rename is blocked"
1747 stat $DIR2/$tdir/$tfile-3 $DIR2/$tdir/$tfile-4 > /dev/null
1748 check_pdo_conflict $PID1 || error "getattr is blocked"
1749 rm $DIR2/$tdir/$tfile-4 $DIR2/$tdir/$tfile-5
1750 rmdir $DIR2/$tdir/$tfile-3
1751 check_pdo_conflict $PID1 || error "unlink is blocked"
1752 # all operations above shouldn't wait the first one
1754 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1755 do_nodes $(comma_list $(mdts_nodes)) \
1756 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1761 run_test 40b "pdirops: open|create and others =============="
1764 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1766 mkdir_on_mdt0 $DIR2/$tdir
1768 touch $DIR1/$tdir/$tfile
1769 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1770 do_nodes $(comma_list $(mdts_nodes)) \
1771 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1772 link $DIR1/$tdir/$tfile $DIR1/$tdir/$tfile-0 &
1775 touch $DIR2/$tdir/$tfile-2
1776 check_pdo_conflict $PID1 || error "create is blocked"
1777 mkdir $DIR2/$tdir/$tfile-3
1778 check_pdo_conflict $PID1 || error "mkdir is blocked"
1779 link $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-4
1780 check_pdo_conflict $PID1 || error "link is blocked"
1781 mv $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-5
1782 check_pdo_conflict $PID1 || error "rename is blocked"
1783 stat $DIR2/$tdir/$tfile-3 $DIR2/$tdir/$tfile-4 > /dev/null
1784 check_pdo_conflict $PID1 || error "getattr is blocked"
1785 rm $DIR2/$tdir/$tfile-4 $DIR2/$tdir/$tfile-5
1786 rmdir $DIR2/$tdir/$tfile-3
1787 check_pdo_conflict $PID1 || error "unlink is blocked"
1789 # all operations above shouldn't wait the first one
1790 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1791 do_nodes $(comma_list $(mdts_nodes)) \
1792 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1797 run_test 40c "pdirops: link and others =============="
1800 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1802 mkdir_on_mdt0 $DIR2/$tdir
1804 touch $DIR1/$tdir/$tfile
1805 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1806 do_nodes $(comma_list $(mdts_nodes)) \
1807 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1808 rm $DIR1/$tdir/$tfile &
1811 touch $DIR2/$tdir/$tfile-2
1812 check_pdo_conflict $PID1 || error "create is blocked"
1813 mkdir $DIR2/$tdir/$tfile-3
1814 check_pdo_conflict $PID1 || error "mkdir is blocked"
1815 link $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-4
1816 check_pdo_conflict $PID1 || error "link is blocked"
1817 mv $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-5
1818 check_pdo_conflict $PID1 || error "rename is blocked"
1819 stat $DIR2/$tdir/$tfile-3 $DIR2/$tdir/$tfile-4 > /dev/null
1820 check_pdo_conflict $PID1 || error "getattr is blocked"
1821 rm $DIR2/$tdir/$tfile-4 $DIR2/$tdir/$tfile-5
1822 rmdir $DIR2/$tdir/$tfile-3
1823 check_pdo_conflict $PID1 || error "unlink is blocked"
1825 # all operations above shouldn't wait the first one
1826 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1827 do_nodes $(comma_list $(mdts_nodes)) \
1828 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1832 run_test 40d "pdirops: unlink and others =============="
1835 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1837 mkdir_on_mdt0 $DIR2/$tdir
1839 touch $DIR1/$tdir/$tfile
1840 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1841 do_nodes $(comma_list $(mdts_nodes)) \
1842 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1843 mv $DIR1/$tdir/$tfile $DIR1/$tdir/$tfile-0 &
1846 touch $DIR2/$tdir/$tfile-2
1847 check_pdo_conflict $PID1 || error "create is blocked"
1848 mkdir $DIR2/$tdir/$tfile-3
1849 check_pdo_conflict $PID1 || error "mkdir is blocked"
1850 link $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-4
1851 check_pdo_conflict $PID1 || error "link is blocked"
1852 stat $DIR2/$tdir/$tfile-3 $DIR2/$tdir/$tfile-4 > /dev/null
1853 check_pdo_conflict $PID1 || error "getattr is blocked"
1854 rm $DIR2/$tdir/$tfile-4 $DIR2/$tdir/$tfile-2
1855 rmdir $DIR2/$tdir/$tfile-3
1856 check_pdo_conflict $PID1 || error "unlink is blocked"
1858 # all operations above shouldn't wait the first one
1859 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1860 do_nodes $(comma_list $(mdts_nodes)) \
1861 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1866 run_test 40e "pdirops: rename and others =============="
1868 # test 41: create blocking operations
1871 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1872 do_nodes $(comma_list $(mdts_nodes)) \
1873 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1874 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1876 mkdir $DIR2/$tfile &
1878 do_nodes $(comma_list $(mdts_nodes)) \
1879 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1880 check_pdo_conflict $PID1 && { wait $PID1; echo "mkdir isn't blocked"; }
1881 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
1885 run_test 41a "pdirops: create vs mkdir =============="
1889 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1890 do_nodes $(comma_list $(mdts_nodes)) \
1891 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1892 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1894 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
1896 do_nodes $(comma_list $(mdts_nodes)) \
1897 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1898 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1899 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
1903 run_test 41b "pdirops: create vs create =============="
1907 touch $DIR1/$tfile-2
1908 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1909 do_nodes $(comma_list $(mdts_nodes)) \
1910 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1911 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1913 link $DIR2/$tfile-2 $DIR2/$tfile &
1915 do_nodes $(comma_list $(mdts_nodes)) \
1916 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1917 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1918 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
1922 run_test 41c "pdirops: create vs link =============="
1926 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1927 do_nodes $(comma_list $(mdts_nodes)) \
1928 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1929 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1933 do_nodes $(comma_list $(mdts_nodes)) \
1934 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1935 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1936 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
1940 run_test 41d "pdirops: create vs unlink =============="
1944 touch $DIR1/$tfile-2
1945 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1946 do_nodes $(comma_list $(mdts_nodes)) \
1947 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1948 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1950 mv $DIR2/$tfile-2 $DIR2/$tfile &
1952 do_nodes $(comma_list $(mdts_nodes)) \
1953 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1954 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1955 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
1959 run_test 41e "pdirops: create and rename (tgt) =============="
1963 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1964 do_nodes $(comma_list $(mdts_nodes)) \
1965 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1966 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1968 mv $DIR2/$tfile $DIR2/$tfile-2 &
1970 do_nodes $(comma_list $(mdts_nodes)) \
1971 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1972 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1973 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
1977 run_test 41f "pdirops: create and rename (src) =============="
1981 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1982 do_nodes $(comma_list $(mdts_nodes)) \
1983 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1984 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1986 stat $DIR2/$tfile > /dev/null &
1988 do_nodes $(comma_list $(mdts_nodes)) \
1989 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1990 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1991 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
1995 run_test 41g "pdirops: create vs getattr =============="
1999 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2000 do_nodes $(comma_list $(mdts_nodes)) \
2001 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2002 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
2004 ls -lia $DIR2/ > /dev/null &
2006 do_nodes $(comma_list $(mdts_nodes)) \
2007 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2008 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2013 run_test 41h "pdirops: create vs readdir =============="
2020 do_nodes $(comma_list $(mdts_nodes)) \
2021 "lctl set_param -n fail_loc=${fail_loc} || true" &>/dev/null
2023 $MULTIOP $DIR1/$tfile oO_CREAT:O_EXCL:c 2>/dev/null &
2026 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c 2>/dev/null &
2029 if ! wait $PID1 && ! wait $PID2; then
2030 echo "Both creates failed (1 should fail, 1 should succeed)"
2032 elif wait $PID1 && wait $PID2; then
2033 echo "Both creates succeeded (1 should fail, 1 should succeed)"
2038 do_nodes $(comma_list $(mdts_nodes)) \
2039 "lctl set_param -n fail_loc=0x0 || true" &>/dev/null
2046 (( $MDS1_VERSION >= $(version_code 2.13.56) )) ||
2047 skip "Need MDS version newer than 2.13.56"
2050 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN 0x169
2051 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN2 0x16a
2052 for fail_loc in "0x80000169" "0x8000016a"; do
2053 echo "Begin 100 tests with fail_loc=$fail_loc"
2055 for i in {1..100}; do
2057 msg=$(sub_test_41i "$fail_loc") ||
2058 { echo; error "iter=$i : $msg"; }
2063 run_test 41i "reint_open: create vs create"
2066 # test 42: unlink and blocking operations
2069 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2070 do_nodes $(comma_list $(mdts_nodes)) \
2071 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2072 mkdir $DIR1/$tfile &
2074 mkdir $DIR2/$tfile &
2076 do_nodes $(comma_list $(mdts_nodes)) \
2077 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2078 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2079 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
2083 run_test 42a "pdirops: mkdir vs mkdir =============="
2087 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2088 do_nodes $(comma_list $(mdts_nodes)) \
2089 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2090 mkdir $DIR1/$tfile &
2092 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2094 do_nodes $(comma_list $(mdts_nodes)) \
2095 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2096 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2097 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
2101 run_test 42b "pdirops: mkdir vs create =============="
2105 touch $DIR1/$tfile-2
2106 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2107 do_nodes $(comma_list $(mdts_nodes)) \
2108 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2109 mkdir $DIR1/$tfile &
2111 link $DIR2/$tfile-2 $DIR2/$tfile &
2113 do_nodes $(comma_list $(mdts_nodes)) \
2114 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2115 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2116 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
2120 run_test 42c "pdirops: mkdir vs link =============="
2124 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2125 do_nodes $(comma_list $(mdts_nodes)) \
2126 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2127 mkdir $DIR1/$tfile &
2129 rmdir $DIR2/$tfile &
2131 do_nodes $(comma_list $(mdts_nodes)) \
2132 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2133 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2134 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
2138 run_test 42d "pdirops: mkdir vs unlink =============="
2142 touch $DIR1/$tfile-2
2143 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2144 do_nodes $(comma_list $(mdts_nodes)) \
2145 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2146 mkdir $DIR1/$tfile &
2148 mv -T $DIR2/$tfile-2 $DIR2/$tfile &
2150 do_nodes $(comma_list $(mdts_nodes)) \
2151 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2152 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2153 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
2157 run_test 42e "pdirops: mkdir and rename (tgt) =============="
2161 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2162 do_nodes $(comma_list $(mdts_nodes)) \
2163 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2164 mkdir $DIR1/$tfile &
2166 mv $DIR2/$tfile $DIR2/$tfile-2 &
2168 do_nodes $(comma_list $(mdts_nodes)) \
2169 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2170 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2171 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2175 run_test 42f "pdirops: mkdir and rename (src) =============="
2178 mkdir_on_mdt0 $DIR1/$tdir
2180 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2181 do_nodes $(comma_list $(mdts_nodes)) \
2182 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2183 mkdir $DIR1/$tdir/$tfile &
2185 stat $DIR2/$tdir/$tfile > /dev/null &
2187 do_nodes $(comma_list $(mdts_nodes)) \
2188 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2189 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2190 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
2193 run_test 42g "pdirops: mkdir vs getattr =============="
2197 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2198 do_nodes $(comma_list $(mdts_nodes)) \
2199 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2200 mkdir $DIR1/$tfile &
2202 ls -lia $DIR2/ > /dev/null &
2204 do_nodes $(comma_list $(mdts_nodes)) \
2205 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2206 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2211 run_test 42h "pdirops: mkdir vs readdir =============="
2213 # test 43: rmdir,mkdir won't return -EEXIST
2215 for i in {1..1000}; do
2216 mkdir $DIR1/$tdir || error "mkdir $tdir failed"
2217 rmdir $DIR2/$tdir || error "rmdir $tdir failed"
2221 run_test 43a "rmdir,mkdir doesn't return -EEXIST =============="
2226 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2227 do_nodes $(comma_list $(mdts_nodes)) \
2228 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2231 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2233 do_nodes $(comma_list $(mdts_nodes)) \
2234 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2235 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2236 wait $PID2 ; [ $? -eq 0 ] || error "create must succeed"
2240 run_test 43b "pdirops: unlink vs create =============="
2245 touch $DIR1/$tfile-2
2246 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2247 do_nodes $(comma_list $(mdts_nodes)) \
2248 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2251 link $DIR2/$tfile-2 $DIR2/$tfile &
2253 do_nodes $(comma_list $(mdts_nodes)) \
2254 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2255 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2256 wait $PID2 ; [ $? -eq 0 ] || error "link must succeed"
2260 run_test 43c "pdirops: unlink vs link =============="
2265 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2266 do_nodes $(comma_list $(mdts_nodes)) \
2267 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2272 do_nodes $(comma_list $(mdts_nodes)) \
2273 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2274 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2275 wait $PID2 ; [ $? -ne 0 ] || error "unlink must fail"
2279 run_test 43d "pdirops: unlink vs unlink =============="
2284 touch $DIR1/$tfile-2
2285 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2286 do_nodes $(comma_list $(mdts_nodes)) \
2287 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2290 mv -u $DIR2/$tfile-2 $DIR2/$tfile &
2292 do_nodes $(comma_list $(mdts_nodes)) \
2293 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2294 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2295 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2299 run_test 43e "pdirops: unlink and rename (tgt) =============="
2304 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2305 do_nodes $(comma_list $(mdts_nodes)) \
2306 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2309 mv $DIR2/$tfile $DIR2/$tfile-2 &
2311 do_nodes $(comma_list $(mdts_nodes)) \
2312 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2313 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2314 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
2318 run_test 43f "pdirops: unlink and rename (src) =============="
2323 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2324 do_nodes $(comma_list $(mdts_nodes)) \
2325 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2328 stat $DIR2/$tfile > /dev/null &
2330 do_nodes $(comma_list $(mdts_nodes)) \
2331 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2332 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2333 wait $PID2 ; [ $? -ne 0 ] || error "stat must fail"
2337 run_test 43g "pdirops: unlink vs getattr =============="
2342 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2343 do_nodes $(comma_list $(mdts_nodes)) \
2344 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2347 ls -lia $DIR2/ > /dev/null &
2349 do_nodes $(comma_list $(mdts_nodes)) \
2350 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2351 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2356 run_test 43h "pdirops: unlink vs readdir =============="
2359 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2362 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2363 do_nodes $(comma_list $(mdts_nodes)) \
2364 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2367 $LFS mkdir -i 1 $DIR2/$tfile &
2369 do_nodes $(comma_list $(mdts_nodes)) \
2370 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2371 check_pdo_conflict $PID1 &&
2372 { wait $PID1; error "remote mkdir isn't blocked"; }
2373 wait $PID2 ; [ $? -eq 0 ] || error "remote mkdir must succeed"
2377 run_test 43i "pdirops: unlink vs remote mkdir"
2380 [[ $MDS1_VERSION -lt $(version_code 2.13.52) ]] &&
2381 skip "Need MDS version newer than 2.13.52"
2383 mkdir_on_mdt0 $DIR1/$tdir
2384 for i in {1..100}; do
2385 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_CREATE_RACE 0x167
2386 do_nodes $(comma_list $(mdts_nodes)) \
2387 "lctl set_param -n fail_loc=0x80000167 2>/dev/null ||
2390 mkdir $DIR1/$tdir/sub &
2392 mkdir $DIR2/$tdir/sub && ((OK++))
2393 wait $PID1 && ((OK++))
2394 (( OK == 1 )) || error "exactly one mkdir should succeed"
2396 rmdir $DIR1/$tdir/sub || error "rmdir failed"
2400 run_test 43j "racy mkdir return EEXIST =============="
2407 # We test in a separate directory to be able to unblock server thread in
2408 # cfs_race() if LCK_PW is taken on the parent by mdt_reint_unlink.
2409 test_mkdir $DIR2/$tdir
2410 touch $DIR2/$tdir/$tfile
2413 do_nodes $(comma_list $(mdts_nodes)) \
2414 "lctl set_param -n fail_loc=${fail_loc} || true" &>/dev/null
2415 echo content > $DIR1/$tdir/$tfile & PID1=$!
2417 multiop $DIR2/$tdir/$tfile u & PID2=$!
2421 echo -n "overwriting $tfile should succeed (err=$ret); "; }
2424 echo -n "unlinking $tfile should succeed (err=$ret);"; }
2427 do_nodes $(comma_list $(mdts_nodes)) \
2428 "lctl set_param -n fail_loc=0x0 || true" &>/dev/null
2435 (( $MDS1_VERSION >= $(version_code 2.13.56) )) ||
2436 skip "Need MDS version newer than 2.13.56"
2439 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN 0x169
2440 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN2 0x16a
2441 for fail_loc in "0x80000169" "0x8000016a"; do
2442 echo "Begin 100 tests with fail_loc=$fail_loc"
2444 for i in {1..100}; do
2446 msg=$(sub_test_43k "$fail_loc") ||
2447 { echo; error "iter=$i : $msg"; }
2457 run_test 43k "unlink vs create"
2459 # test 44: rename tgt and blocking operations
2462 touch $DIR1/$tfile-2
2463 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2464 do_nodes $(comma_list $(mdts_nodes)) \
2465 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2466 mv $DIR1/$tfile-2 $DIR1/$tfile &
2468 mkdir $DIR2/$tfile &
2470 do_nodes $(comma_list $(mdts_nodes)) \
2471 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2472 check_pdo_conflict $PID1 && { wait $PID1; date;error "mkdir isn't blocked"; }
2473 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
2478 run_test 44a "pdirops: rename tgt vs mkdir =============="
2482 touch $DIR1/$tfile-2
2483 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2484 do_nodes $(comma_list $(mdts_nodes)) \
2485 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2486 mv $DIR1/$tfile-2 $DIR1/$tfile &
2488 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2490 do_nodes $(comma_list $(mdts_nodes)) \
2491 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2492 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2493 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
2497 run_test 44b "pdirops: rename tgt vs create =============="
2501 touch $DIR1/$tfile-2
2502 touch $DIR1/$tfile-3
2503 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2504 do_nodes $(comma_list $(mdts_nodes)) \
2505 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2506 mv $DIR1/$tfile-2 $DIR1/$tfile &
2508 link $DIR2/$tfile-3 $DIR2/$tfile &
2510 do_nodes $(comma_list $(mdts_nodes)) \
2511 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2512 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2513 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
2517 run_test 44c "pdirops: rename tgt vs link =============="
2521 touch $DIR1/$tfile-2
2522 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2523 do_nodes $(comma_list $(mdts_nodes)) \
2524 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2525 mv $DIR1/$tfile-2 $DIR1/$tfile &
2529 do_nodes $(comma_list $(mdts_nodes)) \
2530 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2531 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2532 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
2536 run_test 44d "pdirops: rename tgt vs unlink =============="
2541 touch $DIR1/$tfile-2
2542 touch $DIR1/$tfile-3
2543 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2544 do_nodes $(comma_list $(mdts_nodes)) \
2545 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2546 mv $DIR1/$tfile-2 $DIR1/$tfile &
2548 mv $DIR2/$tfile-3 $DIR2/$tfile &
2550 do_nodes $(comma_list $(mdts_nodes)) \
2551 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2552 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2553 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2557 run_test 44e "pdirops: rename tgt and rename (tgt) =============="
2561 touch $DIR1/$tfile-2
2562 touch $DIR1/$tfile-3
2563 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2564 do_nodes $(comma_list $(mdts_nodes)) \
2565 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2566 mv $DIR1/$tfile-2 $DIR1/$tfile &
2568 mv $DIR2/$tfile $DIR2/$tfile-3 &
2570 do_nodes $(comma_list $(mdts_nodes)) \
2571 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2572 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2573 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2577 run_test 44f "pdirops: rename tgt and rename (src) =============="
2581 touch $DIR1/$tfile-2
2582 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2583 do_nodes $(comma_list $(mdts_nodes)) \
2584 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2585 mv $DIR1/$tfile-2 $DIR1/$tfile &
2587 stat $DIR2/$tfile > /dev/null &
2589 do_nodes $(comma_list $(mdts_nodes)) \
2590 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2591 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2592 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
2596 run_test 44g "pdirops: rename tgt vs getattr =============="
2600 touch $DIR1/$tfile-2
2601 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2602 do_nodes $(comma_list $(mdts_nodes)) \
2603 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2604 mv $DIR1/$tfile-2 $DIR1/$tfile &
2606 ls -lia $DIR2/ > /dev/null &
2608 do_nodes $(comma_list $(mdts_nodes)) \
2609 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2610 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2615 run_test 44h "pdirops: rename tgt vs readdir =============="
2617 # test 44: rename tgt and blocking operations
2619 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2621 touch $DIR1/$tfile-2
2622 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2623 do_nodes $(comma_list $(mdts_nodes)) \
2624 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2625 mv $DIR1/$tfile-2 $DIR1/$tfile &
2627 $LFS mkdir -i 1 $DIR2/$tfile &
2629 do_nodes $(comma_list $(mdts_nodes)) \
2630 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2631 check_pdo_conflict $PID1 && { wait $PID1;
2632 error "remote mkdir isn't blocked"; }
2633 wait $PID2 ; [ $? -ne 0 ] || error "remote mkdir must fail"
2637 run_test 44i "pdirops: rename tgt vs remote mkdir"
2639 # test 45: rename,mkdir doesn't fail with -EEXIST
2641 for i in {1..1000}; do
2642 mkdir $DIR1/$tdir || error "mkdir $tdir failed"
2643 mrename $DIR2/$tdir $DIR2/$tdir.$i > /dev/null ||
2644 error "mrename to $tdir.$i failed"
2649 run_test 45a "rename,mkdir doesn't return -EEXIST =============="
2654 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2655 do_nodes $(comma_list $(mdts_nodes)) \
2656 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2657 mv $DIR1/$tfile $DIR1/$tfile-2 &
2659 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2661 do_nodes $(comma_list $(mdts_nodes)) \
2662 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2663 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2664 wait $PID2 ; [ $? -eq 0 ] || error "create must succeed"
2668 run_test 45b "pdirops: rename src vs create =============="
2673 touch $DIR1/$tfile-3
2674 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2675 do_nodes $(comma_list $(mdts_nodes)) \
2676 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2677 mv $DIR1/$tfile $DIR1/$tfile-2 &
2679 link $DIR2/$tfile-3 $DIR2/$tfile &
2681 do_nodes $(comma_list $(mdts_nodes)) \
2682 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2683 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2684 wait $PID2 ; [ $? -eq 0 ] || error "link must succeed"
2688 run_test 45c "pdirops: rename src vs link =============="
2693 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2694 do_nodes $(comma_list $(mdts_nodes)) \
2695 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2696 mv $DIR1/$tfile $DIR1/$tfile-2 &
2700 do_nodes $(comma_list $(mdts_nodes)) \
2701 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2702 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2703 wait $PID2 ; [ $? -ne 0 ] || error "unlink must fail"
2707 run_test 45d "pdirops: rename src vs unlink =============="
2712 touch $DIR1/$tfile-3
2713 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2714 do_nodes $(comma_list $(mdts_nodes)) \
2715 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2716 mv $DIR1/$tfile $DIR1/$tfile-2 &
2718 mv $DIR2/$tfile-3 $DIR2/$tfile &
2720 do_nodes $(comma_list $(mdts_nodes)) \
2721 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2722 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2723 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2727 run_test 45e "pdirops: rename src and rename (tgt) =============="
2732 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2733 do_nodes $(comma_list $(mdts_nodes)) \
2734 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2735 mv $DIR1/$tfile $DIR1/$tfile-2 &
2737 mv $DIR2/$tfile $DIR2/$tfile-3 &
2739 do_nodes $(comma_list $(mdts_nodes)) \
2740 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2741 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2742 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
2746 run_test 45f "pdirops: rename src and rename (src) =============="
2751 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2752 do_nodes $(comma_list $(mdts_nodes)) \
2753 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2754 mv $DIR1/$tfile $DIR1/$tfile-2 &
2756 stat $DIR2/$tfile > /dev/null &
2758 do_nodes $(comma_list $(mdts_nodes)) \
2759 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2760 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2761 wait $PID2 ; [ $? -ne 0 ] || error "stat must fail"
2765 run_test 45g "pdirops: rename src vs getattr =============="
2770 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2771 do_nodes $(comma_list $(mdts_nodes)) \
2772 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2773 mv $DIR1/$tfile $DIR1/$tfile-2 &
2775 ls -lia $DIR2/ > /dev/null &
2776 do_nodes $(comma_list $(mdts_nodes)) \
2777 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2778 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2783 run_test 45h "pdirops: unlink vs readdir =============="
2786 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2789 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2790 do_nodes $(comma_list $(mdts_nodes)) \
2791 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2792 mv $DIR1/$tfile $DIR1/$tfile-2 &
2794 $LFS mkdir -i 1 $DIR2/$tfile &
2796 do_nodes $(comma_list $(mdts_nodes)) \
2797 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2798 check_pdo_conflict $PID1 && { wait $PID1;
2799 error "create remote dir isn't blocked"; }
2800 wait $PID2 ; [ $? -eq 0 ] || error "create remote dir must succeed"
2804 run_test 45i "pdirops: rename src vs remote mkdir"
2811 # We test in a sparate directory to be able to unblock server thread in
2812 # cfs_race if LCK_PW is taken on the parent by mdt_reint_rename.
2813 test_mkdir $DIR2/$tdir
2814 echo file1 > $DIR2/$tdir/$tfile
2815 echo file2 > $DIR2/$tdir/$tfile-2
2818 do_nodes $(comma_list $(mdts_nodes)) \
2819 "lctl set_param -n fail_loc=${fail_loc} || true" &>/dev/null
2821 cat $DIR1/$tdir/$tfile >/dev/null &
2824 mrename $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile > /dev/null &
2828 { ret=$?; echo -n "cat $tfile should succeed (err=$ret); "; }
2831 echo -n "mrename $tfile-2 to $tfile failed (err=$ret);"; }
2834 do_nodes $(comma_list $(mdts_nodes)) \
2835 "lctl set_param -n fail_loc=0x0 || true" &>/dev/null
2842 (( $MDS1_VERSION >= $(version_code 2.13.56) )) ||
2843 skip "Need MDS version newer than 2.13.56"
2846 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN 0x169
2847 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN2 0x16a
2848 for fail_loc in "0x80000169" "0x8000016a"; do
2849 echo "Begin 100 tests with fail_loc=$fail_loc"
2851 for i in {1..100}; do
2853 msg=$(sub_test_45j "$fail_loc") ||
2854 { echo; error "iter=$i : $msg"; }
2859 run_test 45j "read vs rename =============="
2861 # test 46: link and blocking operations
2864 touch $DIR1/$tfile-2
2865 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2866 do_nodes $(comma_list $(mdts_nodes)) \
2867 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2868 link $DIR1/$tfile-2 $DIR1/$tfile &
2870 mkdir $DIR2/$tfile &
2872 do_nodes $(comma_list $(mdts_nodes)) \
2873 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2874 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2875 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
2879 run_test 46a "pdirops: link vs mkdir =============="
2883 touch $DIR1/$tfile-2
2884 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2885 do_nodes $(comma_list $(mdts_nodes)) \
2886 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2887 link $DIR1/$tfile-2 $DIR1/$tfile &
2889 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2891 do_nodes $(comma_list $(mdts_nodes)) \
2892 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2893 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2894 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
2898 run_test 46b "pdirops: link vs create =============="
2902 touch $DIR1/$tfile-2
2903 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2904 do_nodes $(comma_list $(mdts_nodes)) \
2905 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2906 link $DIR1/$tfile-2 $DIR1/$tfile &
2908 link $DIR2/$tfile $DIR2/$tfile &
2910 do_nodes $(comma_list $(mdts_nodes)) \
2911 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2912 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2913 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
2917 run_test 46c "pdirops: link vs link =============="
2921 touch $DIR1/$tfile-2
2922 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2923 do_nodes $(comma_list $(mdts_nodes)) \
2924 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2925 link $DIR1/$tfile-2 $DIR1/$tfile &
2929 do_nodes $(comma_list $(mdts_nodes)) \
2930 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2931 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2932 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
2936 run_test 46d "pdirops: link vs unlink =============="
2940 touch $DIR1/$tfile-2
2941 touch $DIR1/$tfile-3
2942 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2943 do_nodes $(comma_list $(mdts_nodes)) \
2944 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2945 link $DIR1/$tfile-2 $DIR1/$tfile &
2947 mv $DIR2/$tfile-3 $DIR2/$tfile &
2949 do_nodes $(comma_list $(mdts_nodes)) \
2950 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2951 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2952 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2956 run_test 46e "pdirops: link and rename (tgt) =============="
2960 touch $DIR1/$tfile-2
2961 touch $DIR1/$tfile-3
2962 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2963 do_nodes $(comma_list $(mdts_nodes)) \
2964 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2965 link $DIR1/$tfile-2 $DIR1/$tfile &
2967 mv $DIR2/$tfile $DIR2/$tfile-3 &
2969 do_nodes $(comma_list $(mdts_nodes)) \
2970 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2971 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2972 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2976 run_test 46f "pdirops: link and rename (src) =============="
2980 touch $DIR1/$tfile-2
2981 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2982 do_nodes $(comma_list $(mdts_nodes)) \
2983 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2984 link $DIR1/$tfile-2 $DIR1/$tfile &
2986 stat $DIR2/$tfile > /dev/null &
2988 do_nodes $(comma_list $(mdts_nodes)) \
2989 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2990 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2991 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
2995 run_test 46g "pdirops: link vs getattr =============="
2999 touch $DIR1/$tfile-2
3000 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
3001 do_nodes $(comma_list $(mdts_nodes)) \
3002 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
3003 link $DIR1/$tfile-2 $DIR1/$tfile &
3005 ls -lia $DIR2/ > /dev/null &
3007 do_nodes $(comma_list $(mdts_nodes)) \
3008 "lctl set_param -n fail_loc=0 2>/dev/null || true"
3009 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
3014 run_test 46h "pdirops: link vs readdir =============="
3017 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3019 touch $DIR1/$tfile-2
3020 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
3021 do_nodes $(comma_list $(mdts_nodes)) \
3022 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
3023 link $DIR1/$tfile-2 $DIR1/$tfile &
3025 $LFS mkdir -i 1 $DIR2/$tfile &
3027 do_nodes $(comma_list $(mdts_nodes)) \
3028 "lctl set_param -n fail_loc=0 2>/dev/null || true"
3029 check_pdo_conflict $PID1 && { wait $PID1;
3030 error "remote mkdir isn't blocked"; }
3031 wait $PID2 ; [ $? -ne 0 ] || error "remote mkdir must fail"
3035 run_test 46i "pdirops: link vs remote mkdir"
3037 # test 47: remote mkdir and blocking operations
3039 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
3040 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3042 do_nodes $(comma_list $(mdts_nodes)) \
3043 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
3044 $LFS mkdir -i 1 $DIR1/$tfile &
3046 mkdir $DIR2/$tfile &
3048 do_nodes $(comma_list $(mdts_nodes)) \
3049 "lctl set_param -n fail_loc=0 2>/dev/null || true"
3050 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
3051 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
3055 run_test 47a "pdirops: remote mkdir vs mkdir"
3058 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
3059 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3061 do_nodes $(comma_list $(mdts_nodes)) \
3062 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
3063 $LFS mkdir -i 1 $DIR1/$tfile &
3065 sleep 1 # please do not remove this sleep, see LU-10754
3066 multiop $DIR2/$tfile oO_CREAT:O_EXCL:c &
3068 do_nodes $(comma_list $(mdts_nodes)) \
3069 "lctl set_param -n fail_loc=0 2>/dev/null || true"
3070 check_pdo_conflict $PID1 && { wait $PID1;
3071 error "create isn't blocked"; }
3072 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
3076 run_test 47b "pdirops: remote mkdir vs create"
3079 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3081 touch $DIR1/$tfile-2
3082 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
3083 do_nodes $(comma_list $(mdts_nodes)) \
3084 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
3085 $LFS mkdir -i 1 $DIR1/$tfile &
3087 link $DIR2/$tfile-2 $DIR2/$tfile &
3089 do_nodes $(comma_list $(mdts_nodes)) \
3090 "lctl set_param -n fail_loc=0 2>/dev/null || true"
3091 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
3092 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
3096 run_test 47c "pdirops: remote mkdir vs link"
3099 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3101 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
3102 do_nodes $(comma_list $(mdts_nodes)) \
3103 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
3104 $LFS mkdir -i 1 $DIR1/$tfile &
3106 rmdir $DIR2/$tfile &
3108 do_nodes $(comma_list $(mdts_nodes)) \
3109 "lctl set_param -n fail_loc=0 2>/dev/null || true"
3110 check_pdo_conflict $PID1 && { wait $PID1;
3111 error "unlink isn't blocked"; }
3112 wait $PID2 ; [ $? -eq 0 ] || error "rmdir must succeed"
3116 run_test 47d "pdirops: remote mkdir vs unlink"
3119 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3121 touch $DIR1/$tfile-2
3122 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
3123 do_nodes $(comma_list $(mdts_nodes)) \
3124 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
3125 $LFS mkdir -i 1 $DIR1/$tfile &
3127 mv -T $DIR2/$tfile-2 $DIR2/$tfile &
3129 do_nodes $(comma_list $(mdts_nodes)) \
3130 "lctl set_param -n fail_loc=0 2>/dev/null || true"
3131 check_pdo_conflict $PID1 && { wait $PID1;
3132 error "rename isn't blocked"; }
3133 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
3137 run_test 47e "pdirops: remote mkdir and rename (tgt)"
3140 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3142 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
3143 do_nodes $(comma_list $(mdts_nodes)) \
3144 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
3145 $LFS mkdir -i 1 $DIR1/$tfile &
3147 mv $DIR2/$tfile $DIR2/$tfile-2 &
3149 do_nodes $(comma_list $(mdts_nodes)) \
3150 "lctl set_param -n fail_loc=0 2>/dev/null || true"
3151 check_pdo_conflict $PID1 && { wait $PID1;
3152 error "rename isn't blocked"; }
3153 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
3157 run_test 47f "pdirops: remote mkdir and rename (src)"
3160 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3164 #define CFS_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
3165 do_nodes $(comma_list $(mdts_nodes)) \
3166 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
3167 $LFS mkdir -i 1 $DIR1/$tfile &
3169 stat $DIR2/$tfile > /dev/null &
3171 do_nodes $(comma_list $(mdts_nodes)) \
3172 "lctl set_param -n fail_loc=0 2>/dev/null || true"
3173 check_pdo_conflict $PID1 && { wait $PID1;
3174 error "getattr isn't blocked"; }
3175 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
3179 run_test 47g "pdirops: remote mkdir vs getattr"
3183 dd if=/dev/zero of=$DIR1/$tfile bs=1K count=10
3184 #define OBD_FAIL_OSC_CP_ENQ_RACE 0x410
3185 do_facet client "lctl set_param fail_loc=0x410"
3186 $TRUNCATE $DIR2/$tfile $trunc_size
3187 do_facet client "lctl set_param fail_loc=0x0"
3189 size=`stat -c %s $DIR2/$tfile`
3190 [ $size -eq $trunc_size ] || error "wrong size"
3192 run_test 50 "osc lvb attrs: enqueue vs. CP AST =============="
3196 local origfile=/etc/hosts
3198 filesize=$(stat -c %s $origfile)
3200 # create an empty file
3201 $MCREATE $DIR1/$tfile || error "can't create $DIR1/$tfile"
3202 # cache layout lock on both mount point
3203 stat $DIR1/$tfile > /dev/null || error "stat $DIR1/$tfile failed"
3204 stat $DIR2/$tfile > /dev/null || error "stat $DIR2/$tfile failed"
3206 # open and sleep 2 seconds then read
3207 $MULTIOP $DIR2/$tfile o_2r${filesize}c &
3211 # create the layout of testing file
3212 dd if=$origfile of=$DIR1/$tfile conv=notrunc > /dev/null ||
3213 error "dd $DIR1/$tfile failed"
3215 # MULTIOP proc should be able to read enough bytes and exit
3216 for ((i = 0; i < 6; i++)); do
3218 kill -0 $pid || break
3220 kill -0 $pid 2> /dev/null && error "multiop is still there"
3221 cmp $origfile $DIR2/$tfile || error "$origfile and $DIR2/$tfile differs"
3225 run_test 51a "layout lock: refresh layout should work"
3228 (( $MDS1_VERSION >= $(version_code 2.3.59) )) ||
3229 skip "Need MDS version at least 2.3.59"
3231 local tmpfile=`mktemp`
3233 $LFS setstripe -E 1m -S 1M -c 1 -E -1 -c 1 $DIR1/$tfile ||
3234 error "Create $DIR1/$tfile failed"
3236 dd if=/dev/zero of=$DIR1/$tfile bs=1k count=1 conv=notrunc ||
3237 error "dd $DIR1/$tfile failed"
3239 # delay glimpse so that layout has changed when glimpse finish
3240 #define OBD_FAIL_GLIMPSE_DELAY 0x1404
3241 $LCTL set_param fail_loc=0x1404 fail_val=4
3242 stat -c %s $DIR2/$tfile |tee $tmpfile &
3246 # extend layout of testing file
3247 dd if=/dev/zero of=$DIR1/$tfile bs=1M count=1 seek=2 conv=notrunc ||
3248 error "dd $DIR1/$tfile failed"
3251 local fsize=$(cat $tmpfile)
3253 [ x$fsize = x3145728 ] || error "file size is $fsize, should be 3145728"
3255 rm -f $DIR1/$tfile $tmpfile
3257 run_test 51b "layout lock: glimpse should be able to restart if layout changed"
3260 [ $OSTCOUNT -ge 2 ] || { skip "needs >= 2 osts"; return; }
3262 # set default layout to have 1 stripe
3264 $LFS setstripe -c 1 $DIR1/$tdir
3266 # create a file with empty layout
3267 $MCREATE $DIR1/$tdir/$tfile ||
3268 error "$MCREATE $DIR1/$tdir/$tfile failed"
3270 #define OBD_FAIL_MDS_LL_BLOCK 0x172
3271 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x172
3273 # change the layout of testing file
3274 echo "Setting layout to have $OSTCOUNT stripes ..."
3275 $LFS setstripe -c $OSTCOUNT $DIR1/$tdir/$tfile &
3279 # write something to the file, it should be blocked on fetching layout
3280 dd if=/dev/zero of=$DIR2/$tdir/$tfile bs=1k count=1 conv=notrunc
3281 local stripe_count=$($LFS getstripe -c $DIR2/$tdir/$tfile)
3284 # lod_qos.c::min_stripe_count() allows setstripe with a default stripe
3285 # count to succeed with only 3/4 of the number of stripes (rounded up),
3286 # so creating striped files does not fail if an OST is offline or full
3287 [ $stripe_count -ge $((OSTCOUNT - $OSTCOUNT / 4)) ] ||
3288 error "bad layout: getstripe -c $stripe_count < $OSTCOUNT * 3/4"
3292 run_test 51c "layout lock: IT_LAYOUT blocked and correct layout can be returned"
3295 dd if=/dev/zero of=/$DIR1/$tfile bs=1M count=1
3296 cancel_lru_locks mdc
3298 # open should grant LAYOUT lock, mmap and read will install pages
3299 $MULTIOP $DIR1/$tfile oO_RDWR:SMR_Uc &
3303 # rss before revoking
3304 local br=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
3305 echo "Before revoking layout lock: $br KB mapped"
3307 # cancel layout lock manually
3308 cancel_lru_locks mdc
3310 # rss after revoking
3311 local ar=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
3314 wait $PID || error "wait PID $PID failed"
3316 [ $ar -eq 0 ] || error "rss before: $br, after $ar, some pages remained"
3318 run_test 51d "layout lock: losing layout lock should clean up memory map region"
3321 (( $MDS1_VERSION >= $(version_code 2.13.54.148) )) ||
3322 skip "MDS version must be at least 2.13.54.148"
3326 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eW_E+eUc &
3330 $LFS getstripe $DIR2/$tfile
3332 wait $pid || error "multiop failed"
3334 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
3338 $LFS getstripe $DIR2/$tfile
3340 wait $pid || error "multiop failed"
3342 run_test 51e "lfs getstripe does not break leases, part 2"
3346 echo "==> rename vs getattr vs setxattr should not deadlock"
3347 mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed"
3349 do_facet mds1 $LCTL set_param fail_loc=$1
3351 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 &
3359 setfattr -n user.attr1 -v value1 $DIR2/d1 || error "(2) setfattr failed"
3360 wait $PID1 || error "(3) mv failed"
3361 wait $PID2 || error "(4) stat failed"
3368 echo "==> rename vs getattr vs open vs getattr should not deadlock"
3369 mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed"
3371 do_facet mds1 $LCTL set_param fail_loc=$1
3373 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 &
3381 $MULTIOP $DIR2/d1/d2 Oc &
3385 stat $DIR/d1 || error "(2) stat failed"
3387 wait $PID1 || error "(3) mv failed"
3388 wait $PID2 || error "(4) stat failed"
3389 wait $PID3 && error "(5) multiop failed"
3395 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
3396 save_lustre_params client "llite.*.xattr_cache" > $p
3397 lctl set_param llite.*.xattr_cache 1 ||
3398 { skip "xattr cache is not supported"; return 0; }
3400 #define OBD_FAIL_MDS_RENAME 0x153
3401 #define OBD_FAIL_MDS_RENAME2 0x154
3402 test_54_part1 0x80000153 || error 10
3403 test_54_part1 0x80000154 || error 11
3404 test_54_part2 0x80000153 || error 12
3405 test_54_part2 0x80000154 || error 13
3407 restore_lustre_params < $p
3410 run_test 54 "rename locking"
3413 mkdir_on_mdt0 $DIR/$tdir
3414 mkdir -p $DIR/$tdir/d1/d2 $DIR/$tdir/d3 || error "(1) mkdir failed"
3416 #define OBD_FAIL_MDS_RENAME4 0x156
3417 do_facet mds1 $LCTL set_param fail_loc=0x80000156
3419 mv -T $DIR/$tdir/d1/d2 $DIR/$tdir/d3/d2 &
3423 rm -r $DIR2/$tdir/d3
3424 wait $PID1 && error "(2) mv succeeded"
3428 run_test 55a "rename vs unlink target dir"
3432 mkdir_on_mdt0 $DIR/$tdir
3433 mkdir -p $DIR/$tdir/d1/d2 $DIR/$tdir/d3 || error "(1) mkdir failed"
3435 #define OBD_FAIL_MDS_RENAME4 0x156
3436 do_facet mds1 $LCTL set_param fail_loc=0x80000156
3438 mv -T $DIR/$tdir/d1/d2 $DIR/$tdir/d3/d2 &
3442 rm -r $DIR2/$tdir/d1
3443 wait $PID1 && error "(2) mv succeeded"
3447 run_test 55b "rename vs unlink source dir"
3451 mkdir_on_mdt0 $DIR/$tdir
3452 mkdir -p $DIR/$tdir/d1/d2 $DIR/$tdir/d3 || error "(1) mkdir failed"
3454 #define OBD_FAIL_MDS_RENAME4 0x156
3455 do_facet mds1 $LCTL set_param fail_loc=0x156
3457 mv -T $DIR/$tdir/d1/d2 $DIR/$tdir/d3/d2 &
3461 # while rename is sleeping, open and remove d3
3462 $MULTIOP $DIR2/$tdir/d3 D_c &
3465 rm -rf $DIR2/$tdir/d3
3468 # while rename is sleeping 2nd time, close d3
3470 wait $PID2 || error "(3) multiop failed"
3472 wait $PID1 && error "(2) mv succeeded"
3476 run_test 55c "rename vs unlink orphan target dir"
3480 mkdir_on_mdt0 $DIR/$tdir
3484 #define OBD_FAIL_MDS_RENAME3 0x155
3485 do_facet mds1 $LCTL set_param fail_loc=0x155
3486 mv $DIR/$tdir/f1 $DIR/$tdir/$tdir &
3490 # while rename is sleeping, create $tdir, but as a directory
3491 mkdir -p $DIR2/$tdir/$tdir || error "(1) mkdir failed"
3493 # link in reverse locking order
3494 ln $DIR2/$tdir/f1 $DIR2/$tdir/$tdir/f1 || error "(2) ln failed"
3496 ! wait $PID1 || error "(3) mv succeeded"
3499 run_test 55d "rename file vs link"
3502 $LFS setstripe -c 1 $MOUNT/$tfile || error "creating $MOUNT/$tfile"
3503 stack_trap "rm -f $MOUNT/$tfile"
3504 echo "run_llverdev $MOUNT/$tfile -p -s $((16000000)) -c 4k"
3505 run_llverdev $MOUNT/$tfile -p -s $((16000000)) -c 4k ||
3506 error "llverdev failed with rc=$?"
3508 run_test 56a "test llverdev with single large stripe"
3511 $LFS setstripe -C 2000 $MOUNT/$tfile || error "creating $MOUNT/$tfile"
3512 stack_trap "rm -f $MOUNT/$tfile"
3513 echo "run_llverdev $MOUNT/$tfile -p -s $((16000000 * OSTCOUNT)) -c 4k"
3514 run_llverdev $MOUNT/$tfile -p -s $((16000000 * OSTCOUNT)) -c 4k ||
3515 error "llverdev failed with rc=$?"
3517 run_test 56b "test llverdev and partial verify of wide stripe file"
3520 [ $MDS1_VERSION -lt $(version_code 2.3.0) ] &&
3521 skip "MDS version must be >= 2.3.0"
3524 test_mkdir $DIR1/$tdir
3525 file1=$DIR1/$tdir/file
3526 file2=$DIR2/$tdir/file
3528 echo orig > $file2 || error "Could not create $file2"
3529 version=$($LFS data_version $file1)
3532 echo append >> $file2 || error "Could not append to $file2"
3533 version2=$($LFS data_version $file1)
3534 [ "$version" != "$version2" ] ||
3535 error "append did not change data version: $version"
3538 echo overwrite > $file2 || error "Could not overwrite $file2"
3539 version3=$($LFS data_version $file1)
3540 [ "$version2" != "$version3" ] ||
3541 error "overwrite did not change data version: $version2"
3543 # Truncate before EOF
3544 $TRUNCATE $file2 3 || error "Could not truncate $file2"
3545 version4=$($LFS data_version $file1)
3546 [ "$version3" != "$version4" ] ||
3547 error "truncate did not change data version: $version3"
3549 # Truncate after EOF
3550 $TRUNCATE $file2 123456 || error "Could not truncate $file2"
3551 version5=$($LFS data_version $file1)
3552 [ "$version4" != "$version5" ] ||
3553 error "truncate did not change data version: $version4"
3555 # Chmod do not change version
3556 chmod 400 $file2 || error "Could not chmod 400 $file2"
3557 version6=$($LFS data_version $file1)
3558 [ "$version5" == "$version6" ] ||
3559 error "chmod should not change data version: $version5 != $version6"
3561 # Chown do not change version
3562 chown $RUNAS_ID $file2 || error "Could not chown $RUNAS_ID $file2"
3563 version7=$($LFS data_version $file1)
3564 [ "$version5" == "$version7" ] ||
3565 error "chown should not change data version: $version5 != $version7"
3567 run_test 60 "Verify data_version behaviour"
3570 local test_dir=$tdir/test_dir
3572 mkdir -p $DIR1/$tdir
3573 if [ $MDSCOUNT -ge 2 ]; then
3575 $LFS mkdir -i $MDTIDX $DIR1/$test_dir ||
3576 error "Create remote directory failed"
3578 mkdir -p $DIR1/$test_dir
3580 cd $DIR2/$test_dir || error "cd directory failed"
3581 rm -rf $DIR1/$test_dir || error "unlink directory failed"
3583 cd $DIR2/$tdir || error "exit directory"
3585 run_test 70a "cd directory && rm directory"
3587 test_70b() { # LU-2781
3589 mkdir -p $DIR1/$tdir
3591 touch $DIR1/$tdir/file
3592 for ((i = 0; i < 32; i++)); do
3593 $LFS rm_entry $DIR1/$tdir/non_existent_dir &>/dev/null
3595 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
3597 touch $DIR1/$tdir/file
3598 $LFS mkdir -i0 $DIR1/$tdir/test_dir
3599 $LFS rm_entry $DIR1/$tdir/test_dir &>/dev/null
3600 rm -rf $DIR1/$tdir/test_dir ||
3601 error "cannot remove directory after rm_entry"
3602 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
3604 run_test 70b "remove files after calling rm_entry"
3607 [[ "$MDS1_VERSION" -lt $(version_code 2.1.6) ]] &&
3608 skip "Need MDS version at least 2.1.6"
3610 # Patch not applied to 2.2 and 2.3 branches
3611 [[ "$MDS1_VERSION" -ge $(version_code 2.2.0) ]] &&
3612 [[ "$MDS1_VERSION" -lt $(version_code 2.4.0) ]] &&
3613 skip "Need MDS version earlier than 2.2.0 or at least 2.4.0"
3615 checkfiemap --test ||
3616 skip "checkfiemap not runnable: $?"
3617 # write data this way: hole - data - hole - data
3618 dd if=/dev/urandom of=$DIR1/$tfile bs=64K seek=1 count=1
3619 [ "$(facet_fstype ost$(($($LFS getstripe -i $DIR1/$tfile) + 1)))" = \
3621 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return 0
3622 dd if=/dev/urandom of=$DIR1/$tfile bs=64K seek=3 count=1
3623 GET_STAT="lctl get_param -n ldlm.services.ldlm_cbd.stats"
3625 local can1=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3627 checkfiemap $DIR2/$tfile 131072 ||
3628 error "data is not flushed from client"
3629 local can2=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3632 # common case of "create file, copy file" on a single node
3633 # should not flush data from ost
3634 dd if=/dev/urandom of=$DIR1/$tfile bs=64K seek=1 count=1
3635 dd if=/dev/urandom of=$DIR1/$tfile bs=64K seek=3 count=1
3637 local can3=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3639 checkfiemap $DIR1/$tfile 131072 ||
3641 local can4=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3643 [ $can3 -eq $can4 ] || error $((can2-can1)) "cancel RPC occured."
3645 run_test 71a "correct file map just after write operation is finished"
3648 [[ "$MDS1_VERSION" -lt $(version_code 2.1.6) ]] &&
3649 skip "Need MDS version at least 2.1.6"
3651 # Patch not applied to 2.2 and 2.3 branches
3652 [[ "$MDS1_VERSION" -ge $(version_code 2.2.0) ]] &&
3653 [[ "$MDS1_VERSION" -lt $(version_code 2.4.0) ]] &&
3654 skip "Need MDS version earlier than 2.2.0 or at least 2.4.0"
3655 [[ $OSTCOUNT -ge 2 ]] || skip "needs >= 2 OSTs"
3657 checkfiemap --test ||
3658 skip "error $?: checkfiemap failed"
3660 mkdir -p $DIR1/$tdir
3662 $LFS setstripe -c -1 $DIR1/$tdir || error "setstripe failed"
3663 dd if=/dev/urandom of=$DIR1/$tdir/$tfile bs=64K count=1
3664 [ "$(facet_fstype ost$(($($LFS getstripe -i $DIR1/$tdir/$tfile) + 1)))" = \
3666 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return 0
3667 checkfiemap $DIR1/$tdir/$tfile 65536 || error "checkfiemap failed"
3669 run_test 71b "check fiemap support for stripecount > 1"
3672 local p="$TMP/sanityN-$TESTNAME.parameters"
3675 save_lustre_params client "llite.*.xattr_cache" > $p
3676 lctl set_param llite.*.xattr_cache 1 ||
3677 { skip "xattr cache is not supported"; return 0; }
3680 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
3681 error "setfattr1 failed"
3682 getfattr -n user.attr1 $DIR2/$tfile | grep value1 ||
3683 error "getfattr1 failed"
3684 setfattr -n user.attr1 -v value2 $DIR2/$tfile ||
3685 error "setfattr2 failed"
3686 getfattr -n user.attr1 $DIR1/$tfile | grep value2 ||
3687 error "getfattr2 failed"
3689 # check that trusted.link is consistent
3690 tlink1=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
3691 ln $DIR2/$tfile $DIR2/$tfile-2 || error "failed to link"
3692 tlink2=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
3693 echo "$tlink1 $tlink2"
3694 [ "$tlink1" = "$tlink2" ] && error "trusted.link should have changed!"
3698 restore_lustre_params < $p
3701 run_test 72 "getxattr/setxattr cache should be consistent between nodes"
3704 local p="$TMP/sanityN-$TESTNAME.parameters"
3705 save_lustre_params client "llite.*.xattr_cache" > $p
3706 lctl set_param llite.*.xattr_cache 1 ||
3707 { skip "xattr cache is not supported"; return 0; }
3710 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
3711 error "setfattr1 failed"
3712 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr1 failed"
3713 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr2 failed"
3714 clear_stats llite.*.stats
3715 # PR lock should be cached by now on both clients
3716 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr3 failed"
3717 # 2 hits for getfattr(0)+getfattr(size)
3718 [ $(calc_stats llite.*.stats getxattr_hits) -eq 2 ] ||
3719 error "not cached in $DIR1"
3720 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr4 failed"
3721 # 4 hits for more getfattr(0)+getfattr(size)
3722 [ $(calc_stats llite.*.stats getxattr_hits) -eq 4 ] ||
3723 error "not cached in $DIR2"
3726 restore_lustre_params < $p
3729 run_test 73 "getxattr should not cause xattr lock cancellation"
3732 [ "$MDS1_VERSION" -lt $(version_code 2.4.93) ] &&
3733 skip "Need MDS version at least 2.4.93"
3735 dd if=/dev/zero of=$DIR1/$tfile-1 bs=1K count=1
3736 dd if=/dev/zero of=$DIR1/$tfile-2 bs=1K count=1
3737 flocks_test 4 $DIR1/$tfile-1 $DIR2/$tfile-2
3739 run_test 74 "flock deadlock: different mounts =============="
3743 $LFS setstripe -c 2 -S 1m -i 0 $DIR1/$tfile
3744 dd if=/dev/zero of=$DIR1/$tfile bs=1M count=2
3745 cancel_lru_locks osc
3747 dd of=$DIR1/$tfile if=/dev/zero bs=1M count=1 seek=1 conv=notrunc
3750 # define OBD_FAIL_LDLM_ENQUEUE_HANG 0x31d
3751 $LCTL set_param fail_loc=0x31d
3752 stat -c %s $DIR1/$tfile &
3757 # For bad lock error handler we should ASSERT and got kernel panic here
3759 $LCTL set_param fail_loc=0
3761 run_test 75 "osc: upcall after unuse lock==================="
3764 [[ "$MDS1_VERSION" -lt $(version_code 2.5.53) ]] &&
3765 skip "Need MDS version at least 2.5.53"
3767 remote_mds_nodsh && skip "remote MDS with nodsh"
3768 local fcount=$((MDSCOUNT * 256))
3773 nid=$($LCTL list_nids | sed "s/\./\\\./g")
3779 test_mkdir $DIR/$tdir
3781 # drop all open locks and close any cached "open" files on the client
3782 cancel_lru_locks mdc
3784 local open_fids_cmd="$LCTL get_param -n mdt.*.exports.'$nid'.open_files"
3785 local fid_list=($(do_nodes $(comma_list $(mdts_nodes)) $open_fids_cmd))
3786 local already=${#fid_list[@]}
3787 for (( i = 0; i < $already; i++ )) ; do
3788 log "already open[$i]: $($LFS fid2path $DIR2 ${fid_list[i]})"
3791 echo -n "opening files: "
3792 ulimit -n $((fcount + 50))
3793 for ((i = 0; i < $fcount; i++)); do
3794 touch $DIR/$tdir/f_$i
3795 local fd=$(free_fd ${fd_list[i]})
3796 local open_cmd="exec $fd<$DIR/$tdir/f_$i"
3801 (( $i % 32 == 0 )) && echo -n "."
3805 fid_list=($(do_nodes $(comma_list $(mdts_nodes)) $open_fids_cmd))
3807 # Possible errors in openfiles FID list.
3808 # 1. Missing FIDs. Check 1
3809 # 2. Extra FIDs. Check 1
3810 # 3. Duplicated FID. Check 2
3811 # 4. Invalid FIDs. Check 2
3812 # 5. Valid FID, points to some other file. Check 3
3815 [ ${#fid_list[@]} -ne $((fcount + already)) ] &&
3816 error "${#fid_list[@]} != $fcount (+$already old) open files"
3818 echo -n "closing files: "
3819 for (( fd = 0, fid = 0; fd < $fcount; fd++, fid++ )) ; do
3820 local close_cmd="exec ${fd_list[fd]}<&-"
3822 filename=$($LFS fid2path $DIR2 ${fid_list[fid]})
3824 while [[ ! "$filename" =~ "$DIR2/$tdir/f_" ]]; do
3825 echo "skip old open file $filename"
3827 filename=$($LFS fid2path $DIR2 ${fid_list[fid]})
3831 rm --interactive=no $filename
3833 error "Nonexisting fid ${fid_list[fid]} listed."
3834 (( $fd % 32 == 0 )) && echo -n "."
3839 ls_op=$(ls $DIR2/$tdir | wc -l)
3841 error "Some openfiles are missing in lproc output"
3845 run_test 76 "Verify MDT open_files listing"
3849 local dir=$DIR/$tdir
3851 local create_as="$2"
3853 mkdir $dir || error "mkdir $dir failed"
3854 $LFS setstripe -c $OSTCOUNT $dir || error "setstripe to $dir failed"
3857 if [[ -n "$create_as" ]]; then
3858 do_nodes $CLIENTS $create_as "touch $dir/nrs_r_\$HOSTNAME;" ||
3859 error "touch failed for $dir/nrs_r_*"
3860 do_nodes $CLIENTS $create_as touch "$dir/nrs_w_\$HOSTNAME" ||
3861 error "touch failed for $dir/nrs_w_*"
3862 do_nodes $CLIENTS $create_as "chmod 777 $dir/nrs_*_\$HOSTNAME;" ||
3863 error "chmod failed for $dir/nrs_*"
3866 do_nodes $CLIENTS $myRUNAS \
3867 dd if=/dev/zero of="$dir/nrs_r_\$HOSTNAME" bs=1M count=$n ||
3868 error "dd at 0 on client failed (1)"
3870 do_nodes $CLIENTS $myRUNAS \
3872 for ((i = 0; i < $n; i++)); do
3873 dd if=/dev/zero of=$dir/nrs_w_\$HOSTNAME bs=1M \
3874 seek=\\\$i count=1 conv=notrunc &
3875 pids_w[\\\$i]=\\\$!;
3878 for ((i = 0; i < $n; i++)); do
3879 wait \\\${pids_w[\\\$i]};
3881 [ \\\$newrc -gt \\\$rc_w ] && rc_w=\\\$newrc;
3885 do_nodes $CLIENTS sync;
3886 cancel_lru_locks osc
3888 do_nodes $CLIENTS $myRUNAS \
3890 for ((i = 0; i < $n; i++)); do
3891 dd if=$dir/nrs_r_\$HOSTNAME bs=1M of=/dev/null \
3892 seek=\\\$i count=1 &
3893 pids_r[\\\$i]=\\\$!;
3896 for ((i = 0; i < $n; i++)); do
3897 wait \\\${pids_r[\\\$i]};
3899 [ \\\$newrc -gt \\\$rc_r ] && rc_r=\\\$newrc;
3903 cancel_lru_locks osc
3905 wait $pid_w || error "dd (write) failed (2)"
3906 wait $pid_r || error "dd (read) failed (3)"
3907 rm -rvf $dir || error "rm -rf $dir failed"
3910 test_77a() { #LU-3266
3913 oss=$(comma_list $(osts_nodes))
3914 do_nodes $oss lctl set_param ost.OSS.*.nrs_policies="fifo" ||
3916 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3917 [[ $rc -ne 0 ]] && error "failed to set fifo policy"
3922 run_test 77a "check FIFO NRS policy"
3924 test_77b() { #LU-3266
3927 oss=$(comma_list $(osts_nodes))
3929 do_nodes $oss lctl set_param ost.OSS.*.nrs_policies="crrn" \
3930 ost.OSS.*.nrs_crrn_quantum=1 || rc=$?
3931 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3932 [[ $rc -ne 0 ]] && error "failed to set crrn_quantum to 1"
3934 echo "policy: crr-n, crrn_quantum 1"
3937 do_nodes $oss lctl set_param \
3938 ost.OSS.*.nrs_crrn_quantum=64 || rc=$?
3939 [[ $rc -ne 0 ]] && error "failed to set crrn_quantum to 64"
3941 echo "policy: crr-n, crrn_quantum 64"
3945 do_nodes $oss lctl set_param \
3946 ost.OSS.ost_io.nrs_policies="fifo" || rc=$?
3947 [[ $rc -ne 0 ]] && error "failed to set fifo policy"
3950 run_test 77b "check CRR-N NRS policy"
3955 oss=$(comma_list $(osts_nodes))
3957 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies=$policy \
3958 ost.OSS.*.nrs_"$policy"_quantum=1 \
3959 ost.OSS.*.nrs_"$policy"_offset_type="physical" \
3960 ost.OSS.*.nrs_"$policy"_supported="reads" || return $?
3962 echo "policy: $policy, ${policy}_quantum 1, ${policy}_offset_type " \
3963 "physical, ${policy}_supported reads"
3966 do_nodes $oss lctl set_param \
3967 ost.OSS.*.nrs_${policy}_supported="writes" \
3968 ost.OSS.*.nrs_${policy}_quantum=64 || return $?
3970 echo "policy: $policy, ${policy}_quantum 64, ${policy}_offset_type " \
3971 "physical, ${policy}_supported writes"
3974 do_nodes $oss lctl set_param \
3975 ost.OSS.*.nrs_${policy}_supported="reads_and_writes" \
3976 ost.OSS.*.nrs_${policy}_offset_type="logical" || return $?
3977 echo "policy: $policy, ${policy}_quantum 64, ${policy}_offset_type " \
3978 "logical, ${policy}_supported reads_and_writes"
3982 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo" ||
3987 test_77c() { #LU-3266
3989 orr_trr "orr" || rc=$?
3990 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3991 [[ $rc -ne 0 ]] && error "orr_trr failed rc:$rc"
3994 run_test 77c "check ORR NRS policy"
3996 test_77d() { #LU-3266
3998 orr_trr "trr" || rc=$?
3999 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
4000 [[ $rc -ne 0 ]] && error "orr_trr failed rc:$rc"
4003 run_test 77d "check TRR nrs policy"
4010 do_facet $facet lctl set_param \
4011 ost.OSS.ost_io.nrs_tbf_rule="$*"
4013 error "failed to run operate '$*' on TBF rules"
4016 cleanup_tbf_verify()
4020 echo "cleanup_tbf $DIR/$tdir"
4023 wait_delete_completed
4028 local dir=$DIR/$tdir
4029 local client1=${CLIENT1:-$(hostname)}
4031 local create_as="$4"
4033 local np=$(check_cpt_number ost1)
4034 [ $np -gt 0 ] || error "CPU partitions should not be $np."
4035 echo "cpu_npartitions on ost1 is $np"
4037 mkdir $dir || error "mkdir $dir failed"
4038 $LFS setstripe -c 1 -i 0 $dir || error "setstripe to $dir failed"
4041 if [[ -n "$create_as" ]]; then
4042 $create_as touch $dir/tbf
4046 trap cleanup_tbf_verify EXIT
4047 echo "Limited write rate: $1, read rate: $2"
4048 echo "Verify the write rate is under TBF control"
4049 local start=$SECONDS
4050 do_node $client1 $myRUNAS dd if=/dev/zero of=$dir/tbf \
4051 bs=1M count=100 oflag=direct 2>&1
4052 local runtime=$((SECONDS - start + 1))
4053 local rate=$(bc <<< "scale=6; 100 / $runtime")
4054 echo "Write runtime is $runtime s, speed is $rate IOPS"
4056 # verify the write rate does not exceed TBF rate limit
4057 [ $(bc <<< "$rate < 1.1 * $np * $1") -eq 1 ] ||
4058 error "The write rate ($rate) exceeds 110% of rate limit ($1 * $np)"
4060 cancel_lru_locks osc
4062 echo "Verify the read rate is under TBF control"
4064 do_node $client1 $myRUNAS dd if=$dir/tbf of=/dev/null \
4065 bs=1M count=100 iflag=direct 2>&1
4066 runtime=$((SECONDS - start + 1))
4067 rate=$(bc <<< "scale=6; 100 / $runtime")
4068 echo "Read runtime is $runtime s, speed is $rate IOPS"
4070 # verify the read rate does not exceed TBF rate limit
4071 [ $(bc <<< "$rate < 1.1 * $np * $2") -eq 1 ] ||
4072 error "The read rate ($rate) exceeds 110% of rate limit ($2 * $np)"
4074 cancel_lru_locks osc
4075 cleanup_tbf_verify || error "rm -rf $dir failed"
4081 oss=$(comma_list $(osts_nodes))
4083 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid" ||
4085 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
4086 [[ $rc -ne 0 ]] && error "failed to set TBF NID policy"
4090 if [ "$OST1_VERSION" -ge $(version_code 2.8.54) ]; then
4095 # Only operate rules on ost1 since OSTs might run on the same OSS
4097 tbf_rule_operate ost1 "start\ localhost\ ${idis}{0@lo}\ ${rateis}1000"
4098 local address=$(comma_list "$(host_nids_address $CLIENTS $NETTYPE)")
4099 local client_nids=$(nids_list $address "\\")
4100 tbf_rule_operate ost1 "start\ clients\ ${idis}{$client_nids}\ ${rateis}100"
4101 tbf_rule_operate ost1 "start\ others\ ${idis}{*.*.*.*@$NETTYPE}\ ${rateis}50"
4105 tbf_rule_operate ost1 "change\ localhost\ ${rateis}1001"
4106 tbf_rule_operate ost1 "change\ clients\ ${rateis}101"
4107 tbf_rule_operate ost1 "change\ others\ ${rateis}51"
4111 tbf_rule_operate ost1 "stop\ localhost"
4112 tbf_rule_operate ost1 "stop\ clients"
4113 tbf_rule_operate ost1 "stop\ others"
4116 # Cleanup the TBF policy
4117 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
4118 [ $? -ne 0 ] && error "failed to set policy back to fifo"
4122 run_test 77e "check TBF NID nrs policy"
4127 oss=$(comma_list $(osts_nodes))
4129 do_nodes $oss $LCTL set_param \
4130 ost.OSS.ost_io.nrs_policies="tbf\ jobid" || rc=$?
4131 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
4132 [[ $rc -ne 0 ]] && error "failed to set TBF JOBID policy"
4134 # Configure jobid_var
4135 local saved_jobid_var=$($LCTL get_param -n jobid_var)
4137 [[ $rc -eq 3 ]] && skip "jobid_var not found" && return
4138 [[ $rc -ne 0 ]] && error "failed to get param jobid_var"
4139 if [ $saved_jobid_var != procname_uid ]; then
4140 set_persistent_param_and_check client \
4141 "jobid_var" "$FSNAME.sys.jobid_var" procname_uid
4146 if [ "$OST1_VERSION" -ge $(version_code 2.8.54) ]; then
4151 # Only operate rules on ost1 since OSTs might run on the same OSS
4153 tbf_rule_operate ost1 "start\ runas\ ${idis}{iozone.$RUNAS_ID\ dd.$RUNAS_ID\ tiotest.$RUNAS_ID}\ ${rateis}1000"
4154 tbf_rule_operate ost1 "start\ iozone_runas\ ${idis}{iozone.$RUNAS_ID}\ ${rateis}100"
4155 tbf_rule_operate ost1 "start\ dd_runas\ ${idis}{dd.$RUNAS_ID}\ ${rateis}50"
4156 nrs_write_read "$RUNAS"
4159 tbf_rule_operate ost1 "change\ runas\ ${rateis}1001"
4160 tbf_rule_operate ost1 "change\ iozone_runas\ ${rateis}101"
4161 tbf_rule_operate ost1 "change\ dd_runas\ ${rateis}51"
4162 nrs_write_read "$RUNAS"
4165 tbf_rule_operate ost1 "stop\ runas"
4166 tbf_rule_operate ost1 "stop\ iozone_runas"
4167 tbf_rule_operate ost1 "stop\ dd_runas"
4168 nrs_write_read "$RUNAS"
4170 # Cleanup the TBF policy
4171 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
4172 [ $? -ne 0 ] && error "failed to set policy back to fifo"
4173 nrs_write_read "$RUNAS"
4175 local current_jobid_var=$($LCTL get_param -n jobid_var)
4176 [[ $? -ne 0 ]] && error "failed to get param jobid_var"
4177 if [ $saved_jobid_var != $current_jobid_var ]; then
4178 set_persistent_param_and_check client \
4179 "jobid_var" "$FSNAME.sys.jobid_var" $saved_jobid_var
4183 run_test 77f "check TBF JobID nrs policy"
4188 oss=$(comma_list $(osts_nodes))
4190 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid" ||
4192 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
4193 [[ $rc -ne 0 ]] && error "failed to set TBF NID policy"
4195 do_nodes $oss lctl set_param \
4196 ost.OSS.ost_io.nrs_policies="tbf\ jobid" || rc=$?
4197 [[ $rc -ne 0 ]] && error "failed to set TBF JOBID policy"
4201 if [ "$OST1_VERSION" -ge $(version_code 2.8.54) ]; then
4206 # Add a rule that only valid for Jobid TBF. If direct change between
4207 # TBF types is not supported, this operation will fail.
4208 tbf_rule_operate ost1 "start\ dd_runas\ ${idis}{dd.$RUNAS_ID}\ ${rateis}50"
4210 # Cleanup the TBF policy
4211 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
4212 [ $? -ne 0 ] && error "failed to set policy back to fifo"
4215 run_test 77g "Change TBF type directly"
4218 [ "$OST1_VERSION" -ge $(version_code 2.8.55) ] ||
4219 skip "Need OST version at least 2.8.55"
4221 local old_policy=$(do_facet ost1 \
4222 lctl get_param ost.OSS.ost_io.nrs_policies)
4225 do_facet ost1 lctl set_param \
4226 ost.OSS.ost_io.nrs_policies="abc"
4227 [ $? -eq 0 ] && error "should return error"
4229 do_facet ost1 lctl set_param \
4230 ost.OSS.ost_io.nrs_policies="tbf\ abc"
4231 [ $? -eq 0 ] && error "should return error"
4233 do_facet ost1 lctl set_param \
4234 ost.OSS.ost_io.nrs_policies="tbf\ reg\ abc"
4235 [ $? -eq 0 ] && error "should return error"
4237 do_facet ost1 lctl set_param \
4238 ost.OSS.ost_io.nrs_policies="tbf\ abc\ efg"
4239 [ $? -eq 0 ] && error "should return error"
4241 new_policy=$(do_facet ost1 lctl get_param ost.OSS.ost_io.nrs_policies)
4242 [ $? -eq 0 ] || error "shouldn't LBUG"
4244 [ "$old_policy" = "$new_policy" ] || error "NRS policy should be same"
4248 run_test 77h "Wrong policy name should report error, not LBUG"
4254 local error_message=$3
4256 for rule in $expected; do
4257 rule_number=$((rule_number + 1))
4259 local stop_line=$(($rule_number + 3))
4260 local awk_command="awk 'NR >= 4 && NR <= $stop_line {print \$1}'"
4262 local output=$(do_facet $facet lctl get_param \
4263 ost.OSS.ost_io.nrs_tbf_rule |
4267 if [ "$output" != "$expected" ]; then
4268 error "$error_message, expected '$expected', got '$output'"
4273 [ "$OST1_VERSION" -ge $(version_code 2.8.55) ] ||
4274 skip "Need OST version at least 2.8.55"
4276 for i in $(seq 1 $OSTCOUNT)
4278 do_facet ost"$i" lctl set_param \
4279 ost.OSS.ost_io.nrs_policies="tbf\ jobid"
4281 error "failed to set TBF policy"
4284 tbf_rule_check ost1 "default" "error before inserting any rule"
4286 tbf_rule_operate ost1 "start\ before\ jobid={jobid}\ rate=1000"
4287 tbf_rule_check ost1 "before default" \
4288 "error when inserting rule 'before'"
4290 tbf_rule_operate ost1 "start\ after\ jobid={jobid}\ rate=1000\ rank=default"
4291 tbf_rule_check ost1 "before after default" \
4292 "error when inserting rule 'after'"
4294 tbf_rule_operate ost1 "start\ target\ jobid={jobid}\ rate=1000\ rank=after"
4295 tbf_rule_check ost1 "before target after default" \
4296 "error when inserting rule 'target'"
4298 echo "Move before itself"
4299 tbf_rule_operate ost1 "change\ target\ rank=target"
4300 tbf_rule_check ost1 "before target after default" \
4301 "error when moving before itself"
4303 echo "Move to higher rank"
4304 tbf_rule_operate ost1 "change\ target\ rank=before"
4305 tbf_rule_check ost1 "target before after default" \
4306 "error when moving to higher rank"
4308 echo "Move to lower rank"
4309 tbf_rule_operate ost1 "change\ target\ rank=after"
4310 tbf_rule_check ost1 "before target after default" \
4311 "error when moving to lower rank"
4313 echo "Move before default"
4314 tbf_rule_operate ost1 "change\ target\ rank=default"
4315 tbf_rule_check ost1 "before after target default" \
4316 error "error when moving before default"
4318 # Cleanup the TBF policy
4319 do_nodes $(comma_list $(osts_nodes)) \
4320 $LCTL set_param ost.OSS.ost_io.nrs_policies=fifo
4323 run_test 77i "Change rank of TBF rule"
4329 [ "$OST1_VERSION" -ge $(version_code 2.9.53) ] ||
4330 skip "Need OST version at least 2.9.53"
4331 if [ "$OST1_VERSION" -ge $(version_code 2.8.60) ]; then
4336 do_nodes $(comma_list $(osts_nodes)) \
4337 lctl set_param jobid_var=procname_uid \
4338 ost.OSS.ost_io.nrs_policies="tbf\ opcode" \
4339 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_r\ ${idis}{ost_read}\ ${rateis}5" \
4340 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_w\ ${idis}{ost_write}\ ${rateis}20"
4341 [ $? -ne 0 ] && error "failed to set TBF OPCode policy"
4346 do_nodes $(comma_list $(osts_nodes)) \
4347 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_r" \
4348 ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_w" \
4349 ost.OSS.ost_io.nrs_policies="fifo"
4351 # sleep 3 seconds to wait the tbf policy stop completely,
4352 # or the next test case is possible get -EAGAIN when
4353 # setting the tbf policy
4356 run_test 77j "check TBF-OPCode NRS policy"
4359 local idstr="${1}id"
4360 local policy="${idstr}={$2}"
4361 local rate="rate=$3"
4362 local runas_args="$4"
4363 local createas_args="${5:-$runas_args}"
4365 do_nodes $(comma_list $(osts_nodes)) \
4366 lctl set_param jobid_var=procname_uid \
4367 ost.OSS.ost_io.nrs_policies="tbf\ ${idstr}" \
4368 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_${idstr}\ ${policy}\ ${rate}"
4369 [ $? -ne 0 ] && error "failed to set tbf ${idstr} policy"
4371 nrs_write_read "runas $runas_args" "runas $createas_args"
4372 tbf_verify $3 $3 "runas $runas_args" "runas $createas_args"
4374 do_nodes $(comma_list $(osts_nodes)) \
4375 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_${idstr}" \
4376 ost.OSS.ost_io.nrs_policies="fifo"
4378 # sleep 3 seconds to wait the tbf policy stop completely,
4379 # or the next test case is possible get -eagain when
4380 # setting the tbf policy
4385 if [ "$OST1_VERSION" -lt $(version_code 2.11.50) ]; then
4386 skip "Need OST version at least 2.11.50"
4389 test_id "u" "500" "5" "-u 500"
4390 test_id "g" "500" "5" "-u 500 -g 500"
4392 run_test 77ja "check TBF-UID/GID NRS policy"
4394 test_77jb() { # LU-16077
4395 (( "$OST1_VERSION" >= $(version_code 2.15.51) )) ||
4396 skip "Need OST version at least 2.15.51"
4398 test_id "u" "500" "5" "-u 500" "-u 0 -g 500"
4399 test_id "g" "500" "5" "-u 500 -g 500" "-u 500 -g 0"
4401 run_test 77jb "check TBF-UID/GID NRS policy on files that don't belong to us"
4409 for rule in $rule_lists; do
4410 do_nodes $(comma_list $(osts_nodes)) \
4411 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ $rule"
4414 do_nodes $(comma_list $(osts_nodes)) \
4415 lctl set_param ost.OSS.ost_io.nrs_policies="$old_nrs"
4421 [[ "$OST1_VERSION" -ge $(version_code 2.9.53) ]] ||
4422 skip "Need OST version at least 2.9.53"
4424 do_nodes $(comma_list $(osts_nodes)) \
4425 lctl set_param ost.OSS.ost_io.nrs_policies="tbf" \
4426 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_w\ jobid={dd.$RUNAS_ID}\&opcode={ost_write}\ rate=20" \
4427 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_r\ jobid={dd.$RUNAS_ID}\&opcode={ost_read}\ rate=10"
4429 nrs_write_read "$RUNAS"
4430 tbf_verify 20 10 "$RUNAS"
4432 local address=$(comma_list "$(host_nids_address $CLIENTS $NETTYPE)")
4433 local client_nids=$(nids_list $address "\\")
4434 do_nodes $(comma_list $(osts_nodes)) \
4435 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_w" \
4436 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_r" \
4437 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_w\ nid={0@lo\ $client_nids}\&opcode={ost_write}\ rate=20" \
4438 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_r\ nid={0@lo\ $client_nids}\&opcode={ost_read}\ rate=10"
4443 do_nodes $(comma_list $(osts_nodes)) \
4444 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_w" \
4445 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_r" \
4446 ost.OSS.ost_io.nrs_tbf_rule="start\ ext\ nid={0@lo\ $client_nids}\&jobid={dd.$RUNAS_ID}\ rate=20"
4448 nrs_write_read "$RUNAS"
4449 tbf_verify 20 20 "$RUNAS"
4451 do_nodes $(comma_list $(osts_nodes)) \
4452 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext" \
4453 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_a\ jobid={dd.$RUNAS_ID},opcode={ost_write}\ rate=20" \
4454 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_b\ jobid={dd.$RUNAS_ID},opcode={ost_read}\ rate=10"
4456 nrs_write_read "$RUNAS"
4457 # with parameter "RUNAS", it will match the latest rule
4458 # "ext_b" first, so the limited write rate is 10.
4459 tbf_verify 10 10 "$RUNAS"
4462 trap "cleanup_77k \"ext_a ext_b\" \"fifo\"" EXIT
4464 [[ "$OST1_VERSION" -ge $(version_code 2.10.58) ]] ||
4465 skip "Need OST version at least 2.10.58"
4467 do_nodes $(comma_list $(osts_nodes)) \
4468 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_a" \
4469 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_b" \
4470 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_ug\ uid={500}\&gid={1000}\ rate=5"
4471 nrs_write_read "runas -u 500 -g 1000"
4472 tbf_verify 5 5 "runas -u 500 -g 1000"
4474 do_nodes $(comma_list $(osts_nodes)) \
4475 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_ug" \
4476 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_uw\ uid={500}\&opcode={ost_write}\ rate=20" \
4477 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_ur\ uid={500}\&opcode={ost_read}\ rate=10"
4479 nrs_write_read "runas -u 500"
4480 tbf_verify 20 10 "runas -u 500"
4482 do_nodes $(comma_list $(osts_nodes)) \
4483 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_uw" \
4484 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_ur" \
4485 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_a\ uid={500},opcode={ost_write}\ rate=20" \
4486 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_b\ uid={500},opcode={ost_read}\ rate=10"
4487 nrs_write_read "runas -u 500"
4488 tbf_verify 10 10 "runas -u 500"
4489 tbf_verify 20 10 "runas -u 500"
4490 cleanup_77k "ext_a ext_b" "fifo"
4492 run_test 77k "check TBF policy with NID/JobID/OPCode expression"
4495 [[ "$OST1_VERSION" -ge $(version_code 2.10.56) ]] ||
4496 skip "Need OST version at least 2.10.56"
4498 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid"
4499 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="tbf"
4501 local output=$(do_facet ost1 lctl get_param \
4502 ost.OSS.ost_io.nrs_policies | \
4503 awk '/name: tbf/ {print;exit}' | \
4504 awk -F ': ' '{print $2}')
4506 if [ "$output" != "tbf" ]; then
4507 error "The generic TBF output is '$output', not 'tbf'"
4510 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
4512 run_test 77l "check the output of NRS policies for generic TBF"
4515 if [ "$OST1_VERSION" -lt $(version_code 2.9.54) ]; then
4516 skip "Need OST version at least 2.9.54"
4519 local dir=$DIR/$tdir
4521 mkdir $dir || error "mkdir $dir failed"
4522 $LFS setstripe -c $OSTCOUNT $dir || error "setstripe to $dir failed"
4525 local nodes=$(comma_list $(osts_nodes))
4526 do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies=delay \
4527 ost.OSS.ost_io.nrs_delay_min=4 \
4528 ost.OSS.ost_io.nrs_delay_max=4 \
4529 ost.OSS.ost_io.nrs_delay_pct=100
4530 [ $? -ne 0 ] && error "Failed to set delay policy"
4532 local start=$SECONDS
4533 do_nodes "${SINGLECLIENT:-$HOSTNAME}" "$RUNAS" \
4534 dd if=/dev/zero of="$dir/nrs_delay_$HOSTNAME" bs=1M count=1 \
4535 oflag=direct conv=fdatasync ||
4536 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
4537 error "dd on client failed (1)"; }
4538 local elapsed=$((SECONDS - start))
4540 # NRS delay doesn't do sub-second timing, so a request enqueued at
4541 # 0.9 seconds can be dequeued at 4.0
4542 [ $elapsed -lt 3 ] &&
4543 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
4544 error "Single 1M write should take at least 3 seconds"; }
4547 do_nodes "${SINGLECLIENT:-$HOSTNAME}" "$RUNAS" \
4548 dd if=/dev/zero of="$dir/nrs_delay_$HOSTNAME" bs=1M count=10 \
4549 oflag=direct conv=fdatasync ||
4550 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
4551 error "dd on client failed (2)"; }
4552 elapsed=$((SECONDS - start))
4554 [ $elapsed -lt 30 ] &&
4555 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
4556 error "Ten 1M writes should take at least 30 seconds"; }
4558 do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
4559 [ $? -ne 0 ] && error "failed to set policy back to fifo"
4563 run_test 77m "check NRS Delay slows write RPC processing"
4565 test_77n() { #LU-10802
4566 if [ "$OST1_VERSION" -lt $(version_code 2.10.58) ]; then
4567 skip "Need OST version at least 2.10.58"
4570 # Configure jobid_var
4571 local saved_jobid_var=$($LCTL get_param -n jobid_var)
4572 if [ $saved_jobid_var != procname_uid ]; then
4573 set_persistent_param_and_check client \
4574 "jobid_var" "$FSNAME.sys.jobid_var" procname_uid
4577 do_nodes $(comma_list $(osts_nodes)) \
4578 lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ jobid" \
4579 ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \
4580 ost.OSS.ost_io.nrs_tbf_rule="start\ dd_runas\ jobid={*.$RUNAS_ID}\ rate=20"
4583 tbf_verify 20 20 "$RUNAS"
4585 do_nodes $(comma_list $(osts_nodes)) \
4586 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \
4587 ost.OSS.ost_io.nrs_tbf_rule="start\ dd_runas\ jobid={dd.*}\ rate=20"
4592 do_nodes $(comma_list $(osts_nodes)) \
4593 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \
4594 ost.OSS.ost_io.nrs_policies="fifo"
4598 local current_jobid_var=$($LCTL get_param -n jobid_var)
4599 if [ $saved_jobid_var != $current_jobid_var ]; then
4600 set_persistent_param_and_check client \
4601 "jobid_var" "$FSNAME.sys.jobid_var" $saved_jobid_var
4604 run_test 77n "check wildcard support for TBF JobID NRS policy"
4607 (( $OST1_VERSION > $(version_code 2.14.54) )) ||
4608 skip "need OST > 2.14.54"
4610 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_policies="tbf\ nid"
4611 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="start\ name\ nid={192.168.*.*@tcp}\ rate=10000"
4612 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="start\ name1\ nid={192.168.*.*@tcp}\ rate=10000"
4613 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="change\ name1\ rank=name"
4614 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="stop\ name"
4615 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_policies="fifo"
4617 run_test 77o "Changing rank should not panic"
4622 (( $MDS1_VERSION > $(version_code 2.14.54) )) ||
4623 skip "need MDS >= 2.14.54"
4625 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_policies="tbf"
4626 stack_trap "do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_policies=fifo"
4628 for i in {1..50}; do
4631 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="'start rule77q_1 uid={500}&gid={500} rate=100'" &
4633 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="'start rule77q_2 uid={1000}&gid={1000} rate=100'" &
4635 wait $pid1 || error "$i: Fail to start TBF rule 'rule77q_1'"
4636 wait $pid2 || error "$i: Fail to start TBF rule 'rule77q_2'"
4638 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="'stop rule77q_1'" &
4640 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="'stop rule77q_2'" &
4642 wait $pid1 || error "$i: Fail to stop TBF rule 'rule77q_1'"
4643 wait $pid2 || error "$i: Fail to stop TBF rule 'rule77q_2'"
4646 run_test 77q "Parallel TBF rule definitions should not panic"
4650 local -a spec_chars=(
4651 '@' '.' '~' '#' '/' '^' '%' '*' ';' ',' '?' '<' '>' ':'
4652 '+' '=' ')' '(' '{' '}' '|' '[' ']' '!' '&' '\$' '\`' '\\')
4654 (( $MDS1_VERSION > $(version_code 2.14.54) )) ||
4655 skip "need MDS >= 2.14.54"
4657 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_policies="tbf"
4658 stack_trap "do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_policies=fifo"
4660 # TBF rule name size is 16 bytes
4661 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="start\ test_77p_overflo\ uid={500}\ rate=500" &&
4662 error "The length of tbf rule name is not checked" || true
4663 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="start\ \ uid={500}\ rate=500" &&
4664 error "The server should not accept empty tbf rule name" || true
4665 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="start\ test_77p_empty" &&
4666 error "The server should not accept 'start <tbf_rule_name>' without an expression" || true
4668 # Test with special chars
4669 for c in "${spec_chars[@]}"; do
4670 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="'start test77p${c}spec uid={500} rate=500'" &&
4671 error "Special char '${c}' should not be accepted in a tbf rule name" || true
4675 run_test 77p "Check validity of rule names for TBF policies"
4679 local saved_jobid=$2
4680 local current_jobid_var
4682 echo "cleanup 77r $pid"
4684 do_facet mds1 $LCTL set_param -n mds.MDS.mdt.nrs_policies=fifo
4685 kill $pid || echo "fail to kill md thread"
4687 current_jobid_var=$($LCTL get_param -n jobid_var)
4688 if [ $saved_jobid != $current_jobid_var ]; then
4689 set_persistent_param_and_check client \
4690 "jobid_var" "$FSNAME.sys.jobid_var" $saved_jobid
4697 md_thread_run="true"
4701 while $md_thread_run; do
4702 printf '%s\n' {$DIR1,$DIR2}/$tdir/${tfile}-{01..20} |
4703 xargs -P20 -I{} $RUNAS bash -c 'touch {}; rm -f {}' \
4704 &> /dev/null & pid=$!
4705 trap "echo kill md_thread xargs; md_thread_run=false; kill $pid" INT TERM
4710 wait_policy_state() {
4713 local change_pid="$3"
4716 for time in {1..60}; do
4719 nbr_started=$(do_facet mds1 $LCTL get_param mds.MDS.mdt.nrs_policies |
4720 egrep -A2 "name: ${policy}$" | grep -c "state: $state")
4722 [[ "$nbr_started" != 2 ]] || return 0
4726 [[ -z "$change_pid" ]] || kill $change_pid || true
4730 test_77r() { #LU-14976
4734 local saved_jobid_var
4736 rules["tbf uid"]="start md_rule uid={$RUNAS_ID} rate=1"
4737 rules["tbf gid"]="start md_rule gid={$RUNAS_GID} rate=1"
4738 rules["tbf jobid"]="start md_rule jobid={*.$RUNAS_ID} rate=1"
4739 rules["tbf"]="start md_rule uid={$RUNAS_ID} rate=1"
4748 test_mkdir -i 0 -c 1 $DIR1/$tdir
4749 chmod 777 $DIR1/$tdir
4751 # Configure jobid_var
4752 saved_jobid_var=$($LCTL get_param -n jobid_var)
4753 if [ $saved_jobid_var != procname_uid ]; then
4754 set_persistent_param_and_check client \
4755 "jobid_var" "$FSNAME.sys.jobid_var" procname_uid
4759 md_thread_77r & pid=$!
4760 stack_trap "cleanup_77r $pid '$saved_jobid_var'"
4763 for policy in "${policies[@]}"; do
4766 # wait to queue requests
4769 do_facet mds1 "$LCTL set_param mds.MDS.mdt.nrs_policies='$policy'" &
4772 wait_policy_state "started" "$policy" "$change_pid" ||
4773 error "timeout to start '$policy' policy"
4775 [[ -n "${rules[$policy]}" ]] || continue
4777 do_facet mds1 "$LCTL set_param mds.MDS.mdt.nrs_tbf_rule='${rules[$policy]}'" ||
4778 error "fail to set rule '${rules[$policy]}' to '$policy'"
4781 wait_policy_state "stopped" "tbf" ||
4782 error "fail to stop tbf policy"
4784 echo "check the number of requests in queue:"
4785 local awkcmd='/name: / {last = $3} '
4786 awkcmd+='/queued: / {printf " %s: %d\n", last, $2;'
4787 awkcmd+=' if (last == "tbf" && $2 > 0) exit 1;}'
4788 do_facet mds1 $LCTL get_param mds.MDS.mdt.nrs_policies | awk "$awkcmd" ||
4789 error "request leak in tbf policies"
4791 run_test 77r "Change type of tbf policy at run time"
4793 test_78() { #LU-6673
4796 oss=$(comma_list $(osts_nodes))
4797 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="orr" &
4798 do_nodes $oss lctl set_param ost.OSS.*.nrs_orr_quantum=1
4800 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
4801 # Valid return codes are:
4802 # 0: Tuning succeeded
4803 # ENODEV: Policy is still stopped
4804 # EAGAIN: Policy is being initialized
4805 [ $rc -eq 0 -o $rc -eq 19 -o $rc -eq 11 ] ||
4806 error "Expected set_param to return 0|ENODEV|EAGAIN"
4808 # Cleanup the ORR policy
4809 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
4810 [ $? -ne 0 ] && error "failed to set policy back to fifo"
4813 run_test 78 "Enable policy and specify tunings right away"
4816 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4817 test_mkdir $DIR/$tdir
4819 # Prevent interference from layout intent RPCs due to
4820 # asynchronous writeback. These will be tested in 130c below.
4821 do_nodes ${CLIENTS:-$HOSTNAME} sync
4823 setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
4824 error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
4826 #define OBD_FAIL_MDS_INTENT_DELAY 0x160
4827 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
4828 local facet=mds$((mdtidx + 1))
4830 set_nodes_failloc $(facet_active_host $facet) 0x80000160
4831 getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null &
4835 #define OBD_FAIL_MDS_GETXATTR_PACK 0x131
4836 set_nodes_failloc $(facet_active_host $facet) 0x80000131
4841 run_test 79 "xattr: intent error"
4844 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4851 mkdir_on_mdt0 $DIR1/$tdir
4852 mkdir -p $DIR1/$tdir/dir
4853 createmany -o $DIR1/$tdir/dir/f 10 ||
4854 error "create files under remote dir failed $i"
4856 cp /etc/passwd $DIR1/$tdir/$tfile
4858 #migrate open file should fails
4859 multiop_bg_pause $DIR2/$tdir/$tfile O_c || error "open $file failed"
4861 # give multiop a chance to open
4864 $LFS migrate -m $MDTIDX $DIR1/$tdir &&
4865 error "migrate open files should failed with open files"
4869 $LFS migrate -m $MDTIDX $DIR1/$tdir ||
4870 error "migrate remote dir error"
4872 echo "Finish migration, then checking.."
4873 for file in $(find $DIR1/$tdir); do
4874 mdt_index=$($LFS getstripe -m $file)
4875 [ $mdt_index == $MDTIDX ] ||
4876 error "$file is not on MDT${MDTIDX}"
4879 diff /etc/passwd $DIR1/$tdir/$tfile ||
4880 error "file different after migration"
4882 rm -rf $DIR1/$tdir || error "rm dir failed after migration"
4884 run_test 80a "migrate directory when some children is being opened"
4888 kill -9 $migrate_pid
4896 eval $@ &>/dev/null && success_count=$((success_count + 1)) ||
4897 failure_count=$((failure_count + 1))
4901 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4902 local migdir1=$DIR1/$tdir/migrate_dir
4903 local migdir2=$DIR2/$tdir/migrate_dir
4909 trap cleanup_80b EXIT
4910 # prepare migrate directory
4912 for F in {1,2,3,4,5}; do
4913 echo "$F$F$F$F$F" > $migdir1/file$F
4914 echo "$F$F$F$F$F" > $DIR/$tdir/file$F
4917 # migrate the directories among MDTs
4920 mdt_idx=$((RANDOM % MDSCOUNT))
4922 $LFS migrate -m $mdt_idx $migdir1 &>/dev/null
4927 echo "start migration thread $migrate_pid"
4928 # access the files at the same time
4930 echo "accessing the migrating directory for 1 minute..."
4931 while ((SECONDS - start_time < 60)); do
4932 run_and_count ls $migdir2
4933 run_and_count diff -u $DIR2/$tdir/file1 $migdir2/file1
4934 run_and_count "cat $migdir2/file2 > $migdir2/file3"
4935 run_and_count "echo "aaaaa" > $migdir2/file4"
4936 run_and_count stat $migdir2/file5
4937 run_and_count touch $migdir2/source_file
4938 if [ -e $migdir2/source_file ]; then
4939 run_and_count ln $migdir2/source_file \
4942 [ -e $migdir2/link_file ] &&
4943 rm -rf $migdir2/link_file
4945 run_and_count mrename $migdir2/source_file \
4946 $migdir2/target_file
4948 [ -e $migdir2/target_file ] &&
4949 run_and_count rm -rf $migdir2/target_file ||
4950 run_and_count rm -rf $migdir2/source_file
4953 kill -0 $migrate_pid || {
4954 echo "migration stopped 1"
4959 # check migration are still there
4960 kill -0 $migrate_pid || error "migration stopped 2"
4962 # access during migration may fail
4963 echo "concurrent access $failure_count failures, $success_count successes"
4965 run_test 80b "Accessing directory during migration"
4968 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4972 mkdir -p $DIR1/$tdir
4974 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d0
4975 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d1
4978 touch d0/0 || error "create 0 failed"
4979 mv d0/0 d1/0 || error "rename d0/0 d1/0 failed"
4980 stat d0/0 && error "stat mv filed succeed"
4981 mv $DIR2/$tdir/d1/0 $DIR2/$tdir/d0/0 || error "rename d1/0 d0/0 failed"
4982 stat d0/0 || error "stat failed"
4984 local t=$(ls -ai $DIR1/$tdir/d0 | sort -u | wc -l)
4986 if [ $t -ne 3 ]; then
4987 ls -ai $DIR1/$tdir/d0
4988 error "expect 3 get $t"
4993 run_test 81a "rename and stat under striped directory"
4996 [ $MDSCOUNT -lt 2 ] &&
4997 skip "We need at least 2 MDTs for this test"
5004 $LFS mkdir -c $MDSCOUNT $DIR1/$tdir || error "$LFS mkdir"
5005 createmany -o $DIR1/$tdir/$tfile. $total || error "createmany"
5014 for i in $(seq $total); do
5015 mrename $DIR2/$tdir/$tfile.$i $DIR2/$tdir/$tfile-new.$i \
5019 kill -9 $setattr_pid
5021 run_test 81b "rename under striped directory doesn't deadlock"
5024 [ $MDSCOUNT -lt 4 ] && skip_env "needs >= 4 MDTs"
5025 [ $MDS1_VERSION -lt $(version_code 2.13.52) ] &&
5026 skip "Need MDS version at least 2.13.52"
5028 # source is local, source parent is remote
5029 $LFS mkdir -i 0 $DIR1/${tdir}_src || error "mkdir ${tdir}_src"
5030 $LFS mkdir -i 1 $DIR1/${tdir}_tgt || error "mkdir ${tdir}_tgt"
5031 $LFS mkdir -i 3 $DIR1/${tdir}_src/sub || error "mkdir sub"
5032 $LFS mkdir -i 3 $DIR1/${tdir}_tgt/sub || error "mkdir sub"
5033 stat $DIR2/${tdir}_src/sub || error "stat sub failed"
5034 mv $DIR1/${tdir}_src/sub $DIR1/${tdir}_tgt/ || error "mv failed"
5035 [ -f $DIR2/${tdir}_src/sub ] && error "sub should be gone"
5036 rm -rf $DIR1/${tdir}_src $DIR1/${tdir}_tgt
5038 # source is remote, source parent is local
5039 $LFS mkdir -i 3 $DIR1/${tdir}_src || error "mkdir ${tdir}_src"
5040 $LFS mkdir -i 1 $DIR1/${tdir}_tgt || error "mkdir ${tdir}_tgt"
5041 $LFS mkdir -i 0 $DIR1/${tdir}_src/sub || error "mkdir sub"
5042 $LFS mkdir -i 3 $DIR1/${tdir}_tgt/sub || error "mkdir sub"
5043 stat $DIR2/${tdir}_src/sub || error "stat sub failed"
5044 mv $DIR1/${tdir}_src/sub $DIR1/${tdir}_tgt/ || error "mv failed"
5045 [ -f $DIR2/${tdir}_src/sub ] && error "sub should be gone"
5046 rm -rf $DIR1/${tdir}_src $DIR1/${tdir}_tgt
5048 # source and source parent are remote
5049 $LFS mkdir -i 0 $DIR1/${tdir}_src || error "mkdir ${tdir}_src"
5050 $LFS mkdir -i 1 $DIR1/${tdir}_tgt || error "mkdir ${tdir}_tgt"
5051 mkdir $DIR1/${tdir}_src/sub || error "mkdir sub"
5052 $LFS mkdir -i 3 $DIR1/${tdir}_tgt/sub || error "mkdir sub"
5053 stat $DIR2/${tdir}_src/sub || error "stat sub failed"
5054 mv $DIR1/${tdir}_src/sub $DIR1/${tdir}_tgt/ || error "mv failed"
5055 [ -f $DIR2/${tdir}_src/sub ] && error "sub should be gone"
5056 rm -rf $DIR1/${tdir}_src $DIR1/${tdir}_tgt
5058 # source and source parent are remote, and source is remote object
5059 $LFS mkdir -i 0 $DIR1/${tdir}_src || error "mkdir ${tdir}_src"
5060 $LFS mkdir -i 1 $DIR1/${tdir}_tgt || error "mkdir ${tdir}_tgt"
5061 $LFS mkdir -i 2 $DIR1/${tdir}_src/sub || error "mkdir sub"
5062 $LFS mkdir -i 3 $DIR1/${tdir}_tgt/sub || error "mkdir sub"
5063 stat $DIR2/${tdir}_src/sub || error "stat sub failed"
5064 mv $DIR1/${tdir}_src/sub $DIR1/${tdir}_tgt/ || error "mv failed"
5065 [ -f $DIR2/${tdir}_src/sub ] && error "sub should be gone" || true
5067 run_test 81c "rename revoke LOOKUP lock for remote object"
5070 [[ "$MDS1_VERSION" -gt $(version_code 2.6.91) ]] ||
5071 skip "Need MDS version at least 2.6.92"
5073 # Client 1 creates a file.
5074 multiop_bg_pause $DIR1/$tfile O_ac || error "multiop_bg_pause 1"
5076 # Client 2 opens the file.
5077 multiop_bg_pause $DIR2/$tfile o_Ac || error "multiop_bg_pause 2"
5079 # Client 1 makes the file an orphan.
5080 rm $DIR1/$tfile || error "rm"
5081 # Client 2 sets EA "user.multiop".
5083 wait $pid2 || error "multiop 2"
5084 # Client 1 gets EA "user.multiop". This used to fail because the EA
5085 # cache refill would get "trusted.link" from mdd_xattr_list() but
5086 # -ENOENT when trying to get "trusted.link"'s value. See also sanity
5089 wait $pid1 || error "multiop 1"
5091 run_test 82 "fsetxattr and fgetxattr on orphan files"
5094 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
5101 $LFS mkdir -i1 -c2 $tdir
5106 echo "start pid $pid1 to create/unlink striped directory"
5108 # Access the directory at the same time
5112 stat $tdir > /dev/null 2>&1
5116 echo "start pid $pid2 to stat striped directory"
5124 run_test 83 "access striped directory while it is being created/unlinked"
5127 [ $MDS1_VERSION -lt $(version_code 2.12.55) ] &&
5128 skip "lustre < 2.12.55 does not contain LU-12485 fix"
5132 $MULTIOP $DIR/$tfile oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:c ||
5133 error "create $tfile failed"
5134 mtime=$(stat -c%Y $DIR/$tfile)
5135 mtime=$((mtime + 200))
5137 #define OBD_FAIL_OBD_0NLINK_RACE 0x60b
5138 do_facet mds1 $LCTL set_param fail_loc=0x8000060b
5140 touch -c -m $mtime $DIR/$tfile &
5142 # sleep a while to let 'touch' run first
5144 rm -f $DIR2/$tfile || error "unlink $tfile failed"
5147 wait $setattr_pid || true
5149 run_test 84 "0-nlink race in lu_object_find()"
5152 llapi_root_test $DIR/$tfile $DIR2/$tfile
5154 run_test 85 "Lustre API root cache race"
5157 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
5162 [ "$SLOW" = "yes" ] && duration=600
5163 # Open/Create under striped directory
5167 $LFS mkdir -c$MDSCOUNT $tdir > /dev/null 2>&1
5168 touch $tdir/f{0..3} > /dev/null 2>&1
5172 echo "start pid $pid1 to open/create under striped directory"
5174 # unlink the striped directory at the same time
5178 rm -rf $tdir > /dev/null 2>&1
5182 echo "start pid $pid2 to unlink striped directory"
5191 run_test 90 "open/create and unlink striped directory"
5194 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
5199 [ "$SLOW" = "yes" ] && duration=600
5200 # chmod striped directory
5204 $LFS mkdir -c$MDSCOUNT $tdir > /dev/null 2>&1
5205 chmod go+w $tdir > /dev/null 2>&1
5209 echo "start pid $pid1 to chmod striped directory"
5211 # unlink the striped directory at the same time
5215 rm -rf $tdir > /dev/null 2>&1
5219 echo "start pid $pid2 to unlink striped directory"
5228 run_test 91 "chmod and unlink striped directory"
5231 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
5234 local cmd="exec $fd<$DIR1/$tdir"
5235 $LFS setdirstripe -c$MDSCOUNT $DIR1/$tdir || error "mkdir $tdir fails"
5238 trap "eval $cmd" EXIT
5239 cd $DIR1/$tdir || error "cd $DIR1/$tdir fails"
5240 rmdir ../$tdir || error "rmdir ../$tdir fails"
5242 #define OBD_FAIL_LLITE_NO_CHECK_DEAD 0x1408
5243 $LCTL set_param fail_loc=0x1408
5244 mkdir $DIR2/$tdir/dir && error "create dir succeeds"
5245 $LFS setdirstripe -i1 $DIR2/$tdir/remote_dir &&
5246 error "create remote dir succeeds"
5247 $LCTL set_param fail_loc=0
5251 run_test 92 "create remote directory under orphan directory"
5258 mkdir -p $DIR1/$tfile-1/
5259 mkdir -p $DIR2/$tfile-2/
5260 local old_rr=$(do_facet $SINGLEMDS "$LCTL get_param -n \
5261 lod.$FSNAME-MDT0000-*/qos_threshold_rr" | sed -e 's/%//')
5262 do_facet $SINGLEMDS "$LCTL set_param -n \
5263 lod.$FSNAME-MDT0000-*/qos_threshold_rr=100"
5264 #define OBD_FAIL_MDS_LOV_CREATE_RACE 0x163
5265 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x00000163"
5267 $LFS setstripe -c -1 $DIR1/$tfile-1/file1 &
5270 $LFS setstripe -c -1 $DIR2/$tfile-2/file2 &
5274 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x0"
5275 do_facet $SINGLEMDS "$LCTL set_param -n \
5276 lod.$FSNAME-MDT0000-*/qos_threshold_rr=$old_rr"
5278 $LFS getstripe $DIR1/$tfile-1/file1
5279 rc1=$($LFS getstripe -q $DIR1/$tfile-1/file1 |
5280 awk '{if (/[0-9]/) print $1 }' | sort | uniq -d | wc -l)
5281 $LFS getstripe $DIR2/$tfile-2/file2
5282 rc2=$($LFS getstripe -q $DIR2/$tfile-2/file2 |
5283 awk '{if (/[0-9]/) print $1 }' | sort | uniq -d | wc -l)
5284 echo "rc1=$rc1 and rc2=$rc2 "
5285 [ $rc1 -eq 0 ] && [ $rc2 -eq 0 ] ||
5286 error "object allocate on same ost detected"
5288 run_test 93 "alloc_rr should not allocate on same ost"
5291 $LCTL set_param osc.*.idle_timeout=0
5292 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=2 conv=fsync
5294 local before=$(date +%s)
5298 #define OBD_FAIL_LDLM_PAUSE_CANCEL 0x312
5299 $LCTL set_param fail_val=5 fail_loc=0x80000312
5300 dd if=/dev/zero of=$DIR/$tfile conv=notrunc oflag=append bs=4k count=1 &
5304 #define OBD_FAIL_LDLM_PAUSE_CANCEL_LOCAL 0x329
5305 $LCTL set_param fail_val=6 fail_loc=0x80000329
5306 $LCTL mark kill $pid
5309 dd if=/dev/zero of=$DIR2/$tfile conv=notrunc oflag=append bs=4k count=1
5312 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 conv=fsync
5314 evict=$(do_facet client $LCTL get_param \
5315 osc.$FSNAME-OST*-osc-*/state |
5316 awk -F"[ [,]" '/EVICTED ]$/ { if (t<$5) {t=$5;} } END { print t }')
5318 [ -z "$evict" ] || [[ $evict -le $before ]] ||
5319 (do_facet client $LCTL get_param \
5320 osc.$FSNAME-OST*-osc-*/state;
5321 error "eviction happened: $evict before:$before")
5322 $LCTL set_param osc.*.idle_timeout=debug
5324 run_test 94 "signal vs CP callback race"
5327 local file=$DIR/$tfile
5328 local file2=$DIR2/$tfile
5329 local fast_read_save
5332 fast_read_save=$($LCTL get_param -n llite.*.fast_read | head -n 1)
5333 [ -z "$fast_read_save" ] && skip "no fast read support"
5335 stack_trap "$LCTL set_param llite.*.fast_read=$fast_read_save" EXIT
5336 $LCTL set_param llite.*.fast_read=0
5338 $LFS setstripe -c $OSTCOUNT $file || error "failed to setstripe $file"
5339 dd if=/dev/zero of=$file bs=1M count=2 || error "failed to write $file"
5340 cancel_lru_locks $OSC
5341 $MULTIOP $file Oz1048576w4096c || error "failed to write $file"
5342 $MULTIOP $file oz1044480r4096c || error "failed to read $file"
5344 # OBD_FAIL_LLITE_PAGE_INVALIDATE_PAUSE 0x1421
5345 $LCTL set_param fail_loc=0x80001421 fail_val=7
5346 $MULTIOP $file2 Oz1048576w4096_c &
5350 # OBD_FAIL_LLITE_READPAGE_PAUSE 0x1422
5351 $LCTL set_param fail_loc=0x80001422 fail_val=10
5352 $MULTIOP $file oz1044480r4096c || error "failed to read $file"
5354 kill -USR1 $pid && wait $pid || error "wait for PID $pid failed"
5356 run_test 95a "Check readpage() on a page that was removed from page cache"
5359 local file=$DIR/$tfile
5360 local file2=$DIR2/$tfile
5361 local fast_read_save
5364 fast_read_save=$($LCTL get_param -n llite.*.fast_read | head -n 1)
5365 [ -z "$fast_read_save" ] && skip "no fast read support"
5367 stack_trap "$LCTL set_param llite.*.fast_read=$fast_read_save" EXIT
5368 $LCTL set_param llite.*.fast_read=0
5370 $LFS setstripe -c $OSTCOUNT $file || error "failed to setstripe $file"
5371 dd if=/dev/zero of=$file bs=$((PAGE_SIZE * 3)) count=1 ||
5372 error "failed to write $file"
5374 # This does the read from the second mount, so this flushes the pages
5375 # the first mount and creates new ones on the second mount
5376 # OBD_FAIL_LLITE_READPAGE_PAUSE2 0x1424
5377 $LCTL set_param fail_loc=0x80001424 fail_val=5
5378 $MULTIOP $file2 or${PAGE_SIZE}c &
5382 fadvise_dontneed_helper $file2
5383 $LCTL set_param fail_loc=0
5385 wait $pid || error "failed to read file"
5387 run_test 95b "Check readpage() on a page that is no longer uptodate"
5391 skip "Reserved for glimpse-ahead" && return
5392 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
5393 skip "Need MDS version at least 2.10.55"
5397 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
5399 lctl set_param -n mdc.*.stats=clear
5400 dd if=/dev/zero of=$DIR2/$tdir/dom bs=4096 count=1 || return 1
5402 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #1"
5403 # first stat from server should return size data and save glimpse
5404 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
5405 [ $gls -eq 0 ] || error "Unexpected $gls glimpse RPCs"
5406 # second stat to check size is NOT cached on client without IO lock
5407 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #2"
5409 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
5410 [ $gls -ge 1 ] || error "Expect glimpse RPCs but none"
5413 run_test 100a "DoM: glimpse RPCs for stat without IO lock (DoM only file)"
5416 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
5417 skip "Need MDS version at least 2.10.55"
5421 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
5423 lctl set_param -n mdc.*.stats=clear
5424 dd if=/dev/zero of=$DIR2/$tdir/dom bs=4096 count=1 || return 1
5425 cancel_lru_locks mdc
5426 # first stat data from server should have size
5427 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #1"
5428 # second stat to check size is cached on client
5429 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #2"
5431 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
5432 # both stats should cause no glimpse requests
5433 [ $gls == 0 ] || error "Unexpected $gls glimpse RPCs"
5436 run_test 100b "DoM: no glimpse RPC for stat with IO lock (DoM only file)"
5439 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
5440 skip "Need MDS version at least 2.10.55"
5444 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
5446 lctl set_param -n mdc.*.stats=clear
5447 lctl set_param -n osc.*.stats=clear
5448 dd if=/dev/zero of=$DIR2/$tdir/dom bs=2048K count=1 || return 1
5450 # check that size is merged from MDT and OST correctly
5451 $CHECKSTAT -t file -s 2097152 $DIR/$tdir/dom ||
5452 error "Wrong size from stat #1"
5454 local gls=$(lctl get_param -n osc.*.stats | grep -c ldlm_glimpse)
5455 [ $gls -eq 0 ] && error "Expect OST glimpse RPCs but got none"
5459 run_test 100c "DoM: write vs stat without IO lock (combined file)"
5462 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
5463 skip "Need MDS version at least 2.10.55"
5467 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
5470 dd if=/dev/zero of=$DIR2/$tdir/dom bs=2048K count=1 || return 1
5471 lctl set_param -n mdc.*.stats=clear
5472 $TRUNCATE $DIR2/$tdir/dom 4096
5474 # check that reported size is valid after file grows to OST and
5475 # is truncated back to MDT stripe size
5476 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom ||
5477 error "Wrong size from stat #1"
5479 local gls=$(lctl get_param -n osc.*.stats | grep -c ldlm_glimpse)
5480 [ $gls -eq 0 ] && error "Expect OST glimpse but got none"
5484 run_test 100d "DoM: write+truncate vs stat without IO lock (combined file)"
5487 [ "$MDS1_VERSION" -lt $(version_code 2.11.50) ] &&
5488 skip "Need MDS version at least 2.11.50"
5490 local dom=$DIR/$tdir/dom
5491 local dom2=$DIR2/$tdir/dom
5494 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
5496 cancel_lru_locks mdc
5497 dd if=/dev/urandom of=$dom bs=12000 count=1
5498 $TRUNCATE $dom2 6000
5499 cancel_lru_locks mdc
5500 lctl set_param -n mdc.*.stats=clear
5501 # expect read-on-open to return all data before write
5502 cat /etc/hosts >> $dom
5503 local read=$(lctl get_param -n mdc.*.stats | grep -c ost_read)
5504 [[ $read -eq 0 ]] || error "Unexpected $read READ RPCs"
5506 run_test 100e "DoM: read on open and file size"
5509 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
5510 skip "Need MDS version at least 2.10.55"
5512 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
5514 $CHECKSTAT -t file $DIR1/$tfile
5516 local old_wb=$(sysctl -n vm.dirty_writeback_centisecs)
5517 sysctl -wq vm.dirty_writeback_centisecs=0
5519 trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT
5522 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 ||
5523 error_noexit "Write fails"
5524 # must discard pages
5525 lctl set_param -n mdc.*.stats=clear
5526 rm $DIR2/$tfile || error "Unlink fails"
5528 local writes=$(lctl get_param -n mdc.*.stats | grep -c ost_write)
5529 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
5531 run_test 101a "Discard DoM data on unlink"
5534 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
5535 skip "Need MDS version at least 2.10.55"
5537 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
5538 touch $DIR1/${tfile}_2
5540 $CHECKSTAT -t file $DIR1/$tfile
5542 local old_wb=$(sysctl -n vm.dirty_writeback_centisecs)
5543 sysctl -wq vm.dirty_writeback_centisecs=0
5545 trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT
5548 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 || error "Write fails"
5549 # must discard pages
5550 lctl set_param -n mdc.*.stats=clear
5551 mv $DIR2/${tfile}_2 $DIR2/$tfile || error "Rename fails"
5553 local writes=$(lctl get_param -n mdc.*.stats | grep -c ost_write)
5554 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
5556 run_test 101b "Discard DoM data on rename"
5559 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
5560 skip "Need MDS version at least 2.10.55"
5562 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
5564 $CHECKSTAT -t file $DIR1/$tfile
5566 local old_wb=$(sysctl -n vm.dirty_writeback_centisecs)
5567 sysctl -wq vm.dirty_writeback_centisecs=0
5569 trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT
5572 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 || error "Write fails"
5573 $MULTIOP $DIR1/$tfile O_c &
5576 lctl set_param -n mdc.*.stats=clear
5577 rm $DIR2/$tfile > /dev/null || error "Unlink fails for opened file"
5578 kill -USR1 $MULTIOP_PID && wait $MULTIOP_PID || error "multiop failure"
5580 local writes=$(lctl get_param -n mdc.*.stats | grep -c ost_write)
5581 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
5583 run_test 101c "Discard DoM data on close-unlink"
5585 # test to verify file handle related system calls
5586 # (name_to_handle_at/open_by_handle_at)
5587 # The new system calls are supported in glibc >= 2.14.
5589 # test to verify we can open by handle an unlinked file from > 1 client
5590 # This test opens the file normally on $DIR1, which is on one mount, and then
5591 # opens it by handle on $DIR2, which is on a different mount.
5593 (( "$MDS1_VERSION" >= $(version_code 2.11.57) )) ||
5594 skip "Needs MDS version 2.11.57 or later"
5596 echo "Test file_handle syscalls" > $DIR/$tfile ||
5597 error "write failed"
5598 check_fhandle_syscalls $DIR/$tfile $DIR2 ||
5599 error "check_fhandle_syscalls $tfile failed"
5601 # test this is working on DNE directories also
5602 if (( MDSCOUNT > 1 && MDS1_VERSION >= $(version_code 2.14.52) )); then
5603 $LFS mkdir -i 1 $DIR/$tdir.remote
5604 cancel_lru_locks mdc
5605 check_fhandle_syscalls $DIR/$tdir.remote $DIR2 ||
5606 error "check_fhandle_syscalls $tdir.remote failed"
5607 $LFS mkdir -c -1 $DIR/$tdir.remote/subdir
5608 cancel_lru_locks mdc
5609 check_fhandle_syscalls $DIR/$tdir.remote/subdir $DIR2 ||
5610 error "check_fhandle_syscalls $tdir.remote/subdir fail"
5612 $LFS mkdir -c -1 $DIR/$tdir.stripe
5613 cancel_lru_locks mdc
5614 check_fhandle_syscalls $DIR/$tdir.stripe $DIR2 ||
5615 error "check_fhandle_syscalls $tdir.stripe failed"
5616 $LFS mkdir -c -1 $DIR/$tdir.stripe/subdir
5617 cancel_lru_locks mdc
5618 check_fhandle_syscalls $DIR/$tdir.stripe/subdir $DIR2 ||
5619 error "check_fhandle_syscalls $tdir.stripe/subdir fail"
5622 run_test 102 "Test open by handle of unlinked file"
5624 # Compare file size between first & second mount, ensuring the client correctly
5625 # glimpses even with unused speculative locks - LU-11670
5627 [ $OST1_VERSION -lt $(version_code 2.10.50) ] &&
5628 skip "Lockahead needs OST version at least 2.10.50"
5632 test_mkdir -p $DIR/$tdir
5634 # Force file on to OST0
5635 $LFS setstripe -i 0 $DIR/$tdir
5637 # Do not check multiple locks on glimpse
5638 # OBD_FAIL_OSC_NO_SIZE_DATA 0x415
5639 $LCTL set_param fail_loc=0x415
5641 # Delay write commit by 2 seconds to guarantee glimpse wins race
5642 # The same fail_loc is used on client & server so it can work in the
5643 # single node sanity setup
5644 do_facet ost1 $LCTL set_param fail_loc=0x415 fail_val=2
5646 echo "Incorrect size expected (no glimpse fix):"
5647 lockahead_test -d $DIR/$tdir -D $DIR2/$tdir -t $locktest -f $tfile
5649 if [ $rc -eq 0 ]; then
5650 echo "This doesn't work 100%, but this is just reproducing the bug, not testing the fix, so OK to not fail test."
5653 # guarantee write commit timeout has expired
5656 # Clear fail_loc on client
5657 $LCTL set_param fail_loc=0
5659 # Delay write commit by 2 seconds to guarantee glimpse wins race
5660 # OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
5661 do_facet ost1 $LCTL set_param fail_loc=0x214 fail_val=2
5663 # Write commit is still delayed by 2 seconds
5664 lockahead_test -d $DIR/$tdir -D $DIR2/$tdir -t $locktest -f $tfile
5666 [ $rc -eq 0 ] || error "Lockahead test$locktest failed, $rc"
5668 # guarantee write commit timeout has expired
5671 rm -f $DIR/$tfile || error "unable to delete $DIR/$tfile"
5673 run_test 103 "Test size correctness with lockahead"
5679 xtimes=$(stat -c "%X %Y %Z" $DIR/$tfile)
5690 output=$(do_facet mds1 "$DEBUGFS -c -R 'stat ROOT/$tfile' $mdtdev")
5691 ((xtimes[0]=$(awk -F ':' /atime/'{ print $2 }' <<< "$output")))
5692 ((xtimes[1]=$(awk -F ':' /mtime/'{ print $2 }' <<< "$output")))
5693 ((xtimes[2]=$(awk -F ':' /ctime/'{ print $2 }' <<< "$output")))
5701 local xtimes=($(get_stat_xtimes))
5702 local mdt_xtimes=($(get_mdt_xtimes $mdtdev))
5704 echo "STAT a|m|ctime ${xtimes[*]}"
5705 echo "MDT a|m|ctime ${mdt_xtimes[*]}"
5706 [[ ${xtimes[0]} == ${mdt_xtimes[0]} ]] ||
5707 error "$DIR/$tfile atime (${xtimes[0]}:${mdt_xtimes[0]}) diff"
5708 [[ ${xtimes[1]} == ${mdt_xtimes[1]} ]] ||
5709 error "$DIR/$tfile mtime (${xtimes[1]}:${mdt_xtimes[1]}) diff"
5710 [[ ${xtimes[2]} == ${mdt_xtimes[2]} ]] ||
5711 error "$DIR/$tfile ctime (${xtimes[2]}:${mdt_xtimes[2]}) diff"
5715 [ "$mds1_FSTYPE" == "ldiskfs" ] || skip_env "ldiskfs only test"
5716 [ $MDS1_VERSION -lt $(version_code 2.12.4) ] &&
5717 skip "Need MDS version at least 2.12.4"
5720 local mdtdev=$(mdsdevname ${SINGLEMDS//mds/})
5721 local atime_diff=$(do_facet $SINGLEMDS \
5722 lctl get_param -n mdd.*MDT0000*.atime_diff)
5724 do_facet $SINGLEMDS \
5725 lctl set_param -n mdd.*MDT0000*.atime_diff=0
5727 stack_trap "do_facet $SINGLEMDS \
5728 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff" EXIT
5730 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
5731 check_mdt_xtimes $mdtdev
5734 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
5735 check_mdt_xtimes $mdtdev
5737 $MULTIOP $DIR2/$tfile Oz8192w8192_c &
5740 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
5742 kill -USR1 $pid && wait $pid || error "multiop failure"
5743 check_mdt_xtimes $mdtdev
5748 # Verify mtime/ctime is NOT upated on MDS when there is no modification
5749 # on the client side
5750 xtimes=($(get_stat_xtimes))
5751 $MULTIOP $DIR/$tfile O_c &
5754 kill -USR1 $pid && wait $pid || error "multiop failure"
5755 mdt_xtimes=($(get_mdt_xtimes $mdtdev))
5756 [[ ${xtimes[1]} == ${mdt_xtimes[1]} ]] ||
5757 error "$DIR/$tfile mtime (${xtimes[1]}:${mdt_xtimes[1]}) diff"
5758 [[ ${xtimes[2]} == ${mdt_xtimes[2]} ]] ||
5759 error "$DIR/$tfile ctime (${xtimes[2]}:${mdt_xtimes[2]}) diff"
5760 check_mdt_xtimes $mdtdev
5763 # Change ctime via chmod
5764 $MULTIOP $DIR/$tfile o_tc &
5767 kill -USR1 $pid && wait $pid || error "multiop failure"
5768 check_mdt_xtimes $mdtdev
5770 run_test 104 "Verify that MDS stores atime/mtime/ctime during close"
5773 test_mkdir -p $DIR/$tdir
5774 echo test > $DIR/$tdir/$tfile
5775 $LCTL set_param fail_loc=0x416
5776 cancel_lru_locks osc & sleep 1
5777 fsize1=$(stat -c %s $DIR2/$tdir/$tfile)
5779 [[ $fsize1 = 5 ]] || error "Glimpse returned wrong file size $fsize1"
5781 run_test 105 "Glimpse and lock cancel race"
5784 [ "$mds1_FSTYPE" == "ldiskfs" ] && statx_supported ||
5785 skip_env "Test only for ldiskfs and statx() supported"
5790 local mdtdev=$(mdsdevname ${SINGLEMDS//mds/})
5792 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
5793 btime=$($STATX -c %W $DIR/$tfile)
5794 output=$(do_facet mds1 "$DEBUGFS -c -R 'stat ROOT/$tfile' $mdtdev")
5796 ((mdt_btime=$(awk -F ':' /crtime/'{ print $2 }' <<< "$output")))
5797 [[ $btime == $mdt_btime ]] ||
5798 error "$DIR/$tfile btime ($btime:$mdt_btime) diff"
5801 run_test 106a "Verify the btime via statx()"
5804 statx_supported || skip_env "statx() only test"
5809 $LFS setstripe -c 1 $DIR/$tfile || error "$DIR/$tfile setstripe failed"
5810 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
5811 cancel_lru_locks $OSC
5812 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5814 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5815 [ $rpcs_after -eq $((rpcs_before + 1)) ] ||
5816 error "$STATX should send 1 glimpse RPC to $OSC"
5818 cancel_lru_locks $OSC
5819 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5820 # %n: FILENAME; %i: STATX_INO; %A STATX_MODE; %h STATX_NLINK;
5821 # %u: STATX_UID; %g: STATX_GID; %W STATX_BTIME; %X STATX_ATIME;
5823 $STATX -c "%n %i %A %h %u %g %W %X %Z" $DIR/$tfile
5824 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5825 [ $rpcs_after -eq $rpcs_before ] ||
5826 error "$STATX should not send glimpse RPCs to $OSC"
5828 cancel_lru_locks $OSC
5829 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5830 $STATX --cached=always $DIR/$tfile
5831 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5832 [ $rpcs_after -eq $rpcs_before ] ||
5833 error "$STATX should not send glimpse RPCs to $OSC"
5835 cancel_lru_locks $OSC
5836 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5837 $STATX -c %Y $DIR/$tfile
5838 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5839 [ $rpcs_after -eq $((rpcs_before + 1)) ] ||
5840 error "$STATX -c %Y should send 1 glimpse RPC to $OSC"
5842 cancel_lru_locks $OSC
5843 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5844 $STATX -c %s $DIR/$tfile
5845 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5846 [ $rpcs_after -eq $((rpcs_before + 1)) ] ||
5847 error "$STATX -c %s should send 1 glimpse RPC to $OSC"
5849 cancel_lru_locks $OSC
5850 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5851 $STATX -c %b $DIR/$tfile
5852 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5853 [ $rpcs_after -eq $((rpcs_before + 1)) ] ||
5854 error "$STATX -c %b should send 1 glimpse RPC to $OSC"
5856 run_test 106b "Glimpse RPCs test for statx"
5859 statx_supported || skip_env "statx() only test"
5864 # Mask supported in stx_attributes by Lustre is
5865 # STATX_ATTR_IMMUTABLE(0x10) | STATX_ATTR_APPEND(0x20) : (0x30).
5866 mask=$($STATX -c %p $DIR/$tfile)
5867 (( (0x$mask & 0x30) == 0x30 )) ||
5868 error "supported stx_attributes: got '0x$mask', expected '0x30' at least"
5869 chattr +i $DIR/$tfile || error "chattr +i $DIR/$tfile failed"
5870 mask=$($STATX -c %r $DIR/$tfile)
5871 [[ $mask == "10" ]] ||
5872 error "got immutable flags '$mask', expected '10'"
5873 chattr -i $DIR/$tfile || error "chattr -i $DIR/$tfile failed"
5874 mask=$($STATX -c %r $DIR/$tfile)
5875 [[ $mask == "0" ]] || error "got flags '$mask', expected '0'"
5876 chattr +a $DIR/$tfile || error "chattr +a $DIR/$tfile failed"
5877 mask=$($STATX -c %r $DIR/$tfile)
5878 [[ $mask == "20" ]] || error "got flags '$mask', expected '20'"
5879 chattr -a $DIR/$tfile || error "chattr -a $DIR/$tfile failed"
5880 mask=$($STATX -c %r $DIR/$tfile)
5881 [[ $mask == "0" ]] || error "got flags '$mask', expected '0'"
5882 chattr +ia $DIR/$tfile || error "chattr +ia $DIR/$tfile failed"
5883 mask=$($STATX -c %r $DIR/$tfile)
5884 [[ $mask == "30" ]] || error "got flags '$mask', expected '30'"
5885 chattr -ia $DIR/$tfile || error "chattr -ia $DIR/$tfile failed"
5886 mask=$($STATX -c %r $DIR/$tfile)
5887 [[ $mask == "0" ]] || error "got flags '$mask', expected '0'"
5889 run_test 106c "Verify statx attributes mask"
5891 test_107a() { # LU-1031
5892 dd if=/dev/zero of=$DIR1/$tfile bs=1M count=10
5896 $LFS getstripe $DIR1/$tfile
5898 multiop_bg_pause $DIR1/$tfile OG${gid1}_g${gid1}c || return 1
5900 multiop_bg_pause $DIR2/$tfile O_G${gid2}r10g${gid2}c || return 2
5902 kill -USR1 $MULTIPID2
5904 if [[ $(ps h -o comm -p $MULTIPID2) == "" ]]; then
5905 error "First grouplock does not block second one"
5907 echo "First grouplock blocks second one"
5909 kill -USR1 $MULTIPID1
5913 run_test 107a "Basic grouplock conflict"
5916 dd if=/dev/zero of=$DIR1/$tfile bs=1M count=10
5920 $LFS getstripe $DIR1/$tfile
5922 multiop_bg_pause $DIR1/$tfile OG${gid1}_g${gid1}c || return 1
5924 multiop $DIR2/$tfile Or10c &
5928 if [[ $(ps h -o comm -p $MULTIPID2) == "" ]]; then
5929 error "Grouplock does not block IO"
5931 echo "Grouplock blocks IO"
5934 multiop $DIR2/$tfile OG${gid2}_g${gid2}c &
5937 if [[ $(ps h -o comm -p $MULTIPID3) == "" ]]; then
5938 error "First grouplock does not block second one"
5940 echo "First grouplock blocks second one"
5943 kill -USR1 $MULTIPID1
5946 if [[ $(ps h -o comm -p $MULTIPID3) == "" ]]; then
5947 error "Second grouplock thread disappeared"
5950 if [[ $(ps h -o comm -p $MULTIPID2) == "" ]]; then
5951 error "Second grouplock does not block IO"
5953 echo "Second grouplock blocks IO"
5956 kill -USR1 $MULTIPID3
5961 run_test 107b "Grouplock is added to the head of waiting list"
5966 $LFS setstripe -E 1M -c 1 -E -1 $DIR1/$tfile ||
5967 error "Create $DIR1/$tfile failed"
5969 dd if=/dev/zero of=$DIR1/$tfile bs=10000 count=1 ||
5970 error "dd $DIR1/$tfile failed"
5971 offset=$(lseek_test -d 5000 $DIR2/$tfile)
5972 [[ $offset == 5000 ]] || error "offset $offset != 5000"
5974 $TRUNCATE $DIR1/$tfile 2000
5975 offset=$(lseek_test -l 1000 $DIR2/$tfile)
5976 [[ $offset == 2000 ]] || error "offset $offset != 2000"
5978 #define OBD_FAIL_OSC_DELAY_IO 0x414
5979 $LCTL set_param fail_val=4 fail_loc=0x80000414
5980 dd if=/dev/zero of=$DIR1/$tfile count=1 bs=8M conv=notrunc oflag=dsync &
5984 offset=$(lseek_test -l 8000 $DIR2/$tfile)
5986 [[ $offset == 8388608 ]] || error "offset $offset != 8388608"
5988 run_test 108a "lseek: parallel updates"
5996 skip "Clients need to be on different nodes than the servers"
5998 umount_client $MOUNT
5999 umount_client $MOUNT2
6001 echo "Starting race between client mount instances (50 iterations):"
6002 for i in {1..50}; do
6005 #define CFS_FAIL_ONCE|OBD_FAIL_LLITE_RACE_MOUNT 0x80001417
6006 $LCTL set_param -n fail_loc=0x80001417
6008 mount_client $MOUNT & pid1=$!
6009 mount_client $MOUNT2 & pid2=$!
6010 wait $pid1 || error "Mount $MOUNT fails with $?"
6011 wait $pid2 || error "Mount $MOUNT2 fails with $?"
6013 umount_client $MOUNT & pid1=$!
6014 umount_client $MOUNT2 & pid2=$!
6015 wait $pid1 || error "Umount $MOUNT fails with $?"
6016 wait $pid2 || error "Umount $MOUNT2 fails with $?"
6018 $LUSTRE_RMMOD || error "Fail to remove lustre modules"
6024 mount_client $MOUNT2
6027 run_test 109 "Race with several mount instances on 1 node"
6030 local before=$(date +%s)
6037 #define OBD_FAIL_PTLRPC_RESEND_RACE 0x525
6038 do_facet mds1 lctl set_param fail_loc=0x525 fail_val=3
6040 # disable last_xid logic by dropping link reply
6041 ln $DIR/$tdir/f1 $DIR/$tdir/f2 &
6044 #define OBD_FAIL_PTLRPC_ENQ_RESEND 0x534
6045 do_facet mds1 lctl set_param fail_loc=0x534
6047 # RPC will race with its Resend and the Resend will sleep to let
6048 # the original lock to get granted & cancelled.
6050 # AST_SENT is set artificially, so an explicit conflict is not needed
6052 # The woken up Resend gets a new lock, but client does not wait for it
6055 do_facet mds1 lctl set_param fail_loc=0 fail_val=0
6057 # Take a conflict to wait long enough to see the eviction
6060 # let the client reconnect
6062 evict=$(do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state |
6063 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
6065 [ -z "$evict" ] || [[ $evict -le $before ]] ||
6066 (do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state;
6067 error "eviction happened: $evict before:$before")
6069 run_test 110 "do not grant another lock on resend"
6072 [ $MDSCOUNT -ge 2 ] || skip "needs >= 2 MDTs"
6073 [[ $(facet_active_host mds1) = $(facet_active_host mds2) ]] ||
6074 skip "MDT0 and MDT1 should be on the same node"
6077 $LFS mkdir -i 0 $DIR1/$tdir/mdt0dir
6078 $LFS mkdir -i 1 $DIR1/$tdir/mdt1dir
6080 mkdir $DIR1/$tdir/mdt0dir/foodir
6081 touch $DIR1/$tdir/mdt0dir/foodir/{file1,file2}
6083 $MULTIOP $DIR2/$tdir/mdt0dir/foodir/file2 Ow4096_c &
6085 ln $DIR1/$tdir/mdt0dir/foodir/file2 $DIR1/$tdir/mdt1dir/file2
6087 #define OBD_FAIL_MDS_LINK_RENAME_RACE 0x18a
6088 do_facet mds1 $LCTL set_param fail_loc=0x8000018a
6090 ln $DIR1/$tdir/mdt0dir/foodir/file2 $DIR1/$tdir/mdt1dir/file2x &
6093 rm $DIR2/$tdir/mdt1dir/file2
6096 mv $DIR2/$tdir/mdt0dir/foodir/file1 $DIR2/$tdir/mdt0dir/foodir/file2
6101 rm -r $DIR1/$tdir || error "Removing test dir failed"
6103 run_test 111 "A racy rename/link an open file should not cause fs corruption"
6106 (( MDSCOUNT >= 2 )) ||
6107 skip "We need at least 2 MDTs for this test"
6109 (( MDS1_VERSION >= $(version_code 2.14.54) )) ||
6110 skip "Need server version at least 2.14.54"
6115 rr=$($LCTL get_param -n lmv.*.qos_threshold_rr | head -n1)
6117 stack_trap "$LCTL set_param lmv.*.qos_threshold_rr=$rr > /dev/null"
6119 mkdir -p $DIR1/$tdir/s1/s2 || error "mkdir s2 failed"
6120 $LFS mkdir -i 0 $DIR1/$tdir/s1/s2/s3 || error "mkdir s3 failed"
6121 $LFS setdirstripe -D -i -1 --max-inherit-rr=0 $DIR1/$tdir/s1/s2/s3 ||
6122 error "setdirstripe s3 failed"
6123 $LCTL set_param lmv.*.qos_threshold_rr=90
6124 mkdir $DIR2/$tdir/s1/s2/s3/d{1..64}
6125 count=$($LFS getstripe -m $DIR2/$tdir/s1/s2/s3/d* | grep ^0 | wc -l)
6126 (( count == 64 )) || error "only $count subdirs created on MDT0"
6128 $LFS setdirstripe -D -i -1 --max-inherit-rr=3 $DIR1/$tdir/s1/s2/s3 ||
6129 error "setdirstripe s3 failed"
6130 mkdir $DIR2/$tdir/s1/s2/s3/s{1..64}
6131 count=$($LFS getstripe -m $DIR2/$tdir/s1/s2/s3/s* | grep ^0 | wc -l)
6132 (( count == 64 / MDSCOUNT )) || error "$count subdirs created on MDT0"
6134 run_test 112 "update max-inherit in default LMV"
6137 (( MDS1_VERSION >= $(version_code 2.15.50) )) ||
6138 skip "Need server version at least 2.15.50"
6143 instance=$($LFS getname -i $DIR1) ||
6144 error "cannot get instance of $DIR1"
6146 $LFS check osts $DIR1 | grep $instance ||
6147 error "cannot find OSTs of instance $instance"
6149 $LFS check osts $DIR1 | grep -v $instance
6150 if (( $? == 0 )); then
6151 error "find OSTs other than instance $instance"
6154 $LFS check osts | grep $instance ||
6155 error "cannot find other OSTs"
6157 nid=$(df $DIR2 | tail -1 | sed 's%:/.*%%') ||
6158 error "cannot parse nid for $DIR2"
6160 $LFS check mgts $DIR2 | grep MGC$nid ||
6161 error "cannot find mgc of $nid"
6163 $LFS check mgts $DIR2 | grep -v MGC$nid
6164 if (( $? == 0 )); then
6165 error "find MGTs other than nid $nid"
6168 run_test 113 "check servers of specified fs"
6170 check_default_lmv() {
6181 enabled=$(do_facet mds1 \
6182 $LCTL get_param -n mdt.*-MDT0000*.enable_dmv_implicit_inherit)
6184 dmv=$($LFS getdirstripe -D $dir)
6186 index=$(echo $dmv | awk '{ print $4 }')
6187 (( index == $2 )) || error "$dir default stripe index $index != $2"
6189 count=$(echo $dmv | awk '{ print $2 }')
6190 (( count == $3 )) || error "$dir default stripe count $count != $3"
6192 inherit=$(echo $dmv | awk '{ print $8 }')
6193 (( inherit == $4 )) || error "$dir default max-inherit $inherit != $4"
6195 if [ $index -eq -1 ]; then
6196 inherit_rr=$(echo $dmv | awk '{ print $10 }')
6197 (( inherit_rr == $5 )) ||
6198 error "$dir default max-inherit-rr $inherit_rr != $5"
6201 # with --raw, print default LMV stored in inode, otherwise print nothing
6202 raw=$($LFS getdirstripe -D --raw $dir)
6203 if (( enabled == 1 )); then
6205 error "implicit inherited DMV is printed with --raw"
6207 # if disabled, dmv is stored in inode, which will always
6208 # print max-inherit-rr
6210 [[ $raw =~ $dmv.* ]] || error "$dir raw $raw != dmv $dmv"
6214 test_dmv_imp_inherit() {
6222 rm -rf $DIR/$tdir || error "rm $tdir failed"
6223 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
6225 # set dir default LMV
6226 $LFS setdirstripe -D -c1 -X4 --max-inherit-rr 2 $DIR/$tdir ||
6227 error "setdirstripe -D $tdir failed"
6228 dmv=$($LFS getdirstripe -D $DIR/$tdir)
6229 raw=$($LFS getdirstripe -D --raw $DIR/$tdir)
6230 [ "$dmv" == "$raw" ] || error "$dmv != $raw"
6232 mkdir -p $DIR/$tdir/l1/l2/l3 || error "mkdir $DIR/$tdir/l1/l2/l3 failed"
6233 check_default_lmv $DIR/$tdir/l1/l2/l3 -1 1 1 0
6234 check_default_lmv $DIR2/$tdir/l1/l2/l3 -1 1 1 0
6236 # below tests are valid only when this feature is enabled
6237 local enabled=$(do_facet mds1 \
6238 $LCTL get_param -n mdt.*-MDT0000*.enable_dmv_implicit_inherit)
6240 (( enabled == 1 )) || return 0
6242 # set l2 default LMV, dmv of l3 should change immediately
6243 $LFS setdirstripe -D -i1 -c2 -X4 $DIR/$tdir/l1/l2 ||
6244 error "setdirstripe -D $tdir/l1/l2 failed"
6246 check_default_lmv $DIR/$tdir/l1/l2/l3 1 2 3
6247 check_default_lmv $DIR2/$tdir/l1/l2/l3 1 2 3
6249 # change tdir default LMV, dmv of l3 should be unchanged because dmv
6250 # of l2 is explicitly set
6251 $LFS setdirstripe -D -i2 -c2 -X3 $DIR/$tdir ||
6252 error "setdirstripe -D $tdir failed"
6254 check_default_lmv $DIR/$tdir/l1 2 2 2
6255 check_default_lmv $DIR2/$tdir/l1 2 2 2
6256 check_default_lmv $DIR/$tdir/l1/l2/l3 1 2 3
6257 check_default_lmv $DIR2/$tdir/l1/l2/l3 1 2 3
6261 (( MDSCOUNT >= 2 )) ||
6262 skip "We need at least 2 MDTs for this test"
6264 (( MDS1_VERSION >= $(version_code 2.15.55.45) )) ||
6265 skip "Need server version at least 2.15.54.45"
6267 test_dmv_imp_inherit
6269 # disable dmv_imp_inherit to simulate old client
6270 local mdts=$(comma_list $(mdts_nodes))
6272 do_nodes $mdts $LCTL set_param -n \
6273 mdt.*MDT*.enable_dmv_implicit_inherit=0
6274 test_dmv_imp_inherit
6275 do_nodes $mdts $LCTL set_param -n \
6276 mdt.*MDT*.enable_dmv_implicit_inherit=1
6278 run_test 114 "implicit default LMV inherit"
6280 log "cleanup: ======================================================"
6282 # kill and wait in each test only guarentee script finish, but command in script
6283 # like 'rm' 'chmod' may still be running, wait for all commands to finish
6284 # otherwise umount below will fail
6285 [ "$(mount | grep $MOUNT2)" ] && wait_update $HOSTNAME "fuser -m $MOUNT2" "" ||
6288 complete_test $SECONDS
6290 check_and_cleanup_lustre