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 LU-14541
22 ALWAYS_EXCEPT+=" 28 16f"
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 timeout --preserve-status --signal=USR1 $duration \
567 rw_seq_cst_vs_drop_caches $file1 $file2
570 case $((status & 0x7f)) in
572 echo OK # Computers must be fast now.
575 error "sequential consistency violation detected"
578 echo TIMEOUT # This is fine.
581 error "strange status '$status'"
587 run_test 16f "rw sequential consistency vs drop_caches"
589 test_17() { # bug 3513, 3667
590 remote_ost_nodsh && skip "remote OST with nodsh" && return
592 lfs setstripe $DIR1/$tfile -i 0 -c 1
593 cp $SAMPLE_FILE $DIR1/$tfile
594 cancel_lru_locks osc > /dev/null
595 #define OBD_FAIL_ONCE|OBD_FAIL_LDLM_CREATE_RESOURCE 0x30a
596 do_facet ost1 lctl set_param fail_loc=0x8000030a
597 ls -ls $DIR1/$tfile | awk '{ print $1,$6 }' > $DIR1/$tfile-1 & \
598 ls -ls $DIR2/$tfile | awk '{ print $1,$6 }' > $DIR2/$tfile-2
600 diff -u $DIR1/$tfile-1 $DIR2/$tfile-2 || error "files are different"
602 run_test 17 "resource creation/LVB creation race ==============="
605 # turn e.g. ALWAYS_EXCEPT="18c" into "-e 3"
608 for idx in {a..z}; do
609 local ptr=EXCEPT_ALWAYS_18$idx
610 [ x${!ptr} = xtrue ] || continue
612 excepts="$excepts -e $(($(printf %d \'$idx)-96))"
615 excepts="$excepts -e 7 -e 8 -e 9"
616 $LUSTRE/tests/mmap_sanity -d $MOUNT1 -m $MOUNT2 $excepts ||
617 error "mmap_sanity test failed"
620 run_test 18 "mmap sanity check ================================="
622 test_19() { # bug3811
623 local node=$(facet_active_host ost1)
624 local device="$FSNAME-OST*"
626 [ "x$DOM" = "xyes" ] && node=$(facet_active_host $SINGLEMDS) &&
627 device="$FSNAME-MDT*"
629 # check whether obdfilter is cache capable at all
630 get_osd_param $node $device read_cache_enable >/dev/null ||
631 skip "not cache-capable obdfilter"
633 local max=$(get_osd_param $node $device readcache_max_filesize |\
635 set_osd_param $node $device readcache_max_filesize 4096
636 dd if=/dev/urandom of=$TMP/$tfile bs=512k count=32
637 local SUM=$(cksum $TMP/$tfile | cut -d" " -f 1,2)
638 cp $TMP/$tfile $DIR1/$tfile
639 for i in `seq 1 20`; do
640 [ $((i % 5)) -eq 0 ] && log "$testname loop $i"
641 cancel_lru_locks $OSC > /dev/null
642 cksum $DIR1/$tfile | cut -d" " -f 1,2 > $TMP/sum1 & \
643 cksum $DIR2/$tfile | cut -d" " -f 1,2 > $TMP/sum2
645 [ "$(cat $TMP/sum1)" = "$SUM" ] || \
646 error "$DIR1/$tfile $(cat $TMP/sum1) != $SUM"
647 [ "$(cat $TMP/sum2)" = "$SUM" ] || \
648 error "$DIR2/$tfile $(cat $TMP/sum2) != $SUM"
650 set_osd_param $node $device readcache_max_filesize $max
653 run_test 19 "test concurrent uncached read races ==============="
656 test_mkdir $DIR1/$tdir
658 CNT=$($LCTL get_param -n llite.*.dump_page_cache | wc -l)
659 $MULTIOP $DIR1/$tdir/$tfile Ow8190c
660 $MULTIOP $DIR2/$tdir/$tfile Oz8194w8190c
661 $MULTIOP $DIR1/$tdir/$tfile Oz0r8190c
663 CNT2=$($LCTL get_param -n llite.*.dump_page_cache | wc -l)
664 [[ $CNT2 == $CNT ]] ||
665 error $((CNT2 - CNT))" page left in cache after lock cancel"
667 run_test 20 "test extra readahead page left in cache ===="
674 test_21() { # Bug 5907
675 test_mkdir $DIR1/$tdir
676 mount /etc $DIR1/$tdir --bind || error "mount failed" # Poor man's mount.
678 rmdir -v $DIR1/$tdir && error "Removed mounted directory"
679 rmdir -v $DIR2/$tdir && echo "Removed mounted directory from another mountpoint, needs to be fixed"
680 test -d $DIR1/$tdir || error "Mounted directory disappeared"
682 test -d $DIR2/$tdir || test -d $DIR1/$tdir && error "Removed dir still visible after umount"
685 run_test 21 " Try to remove mountpoint on another dir ===="
687 test_23() { # Bug 5972
688 local at_diff=$(do_facet $SINGLEMDS \
689 $LCTL get_param -n mdd.*MDT0000*.atime_diff | head -n1)
690 echo "atime should be updated while another read" > $DIR1/$tfile
692 # clear the lock(mode: LCK_PW) gotten from creating operation
693 cancel_lru_locks $OSC
696 sleep $((at_diff + 1))
698 echo "starting reads"
699 multiop_bg_pause $DIR1/$tfile or20_c || return 1
700 # with SOM and opencache enabled, we need to close a file and cancel
701 # open lock to get atime propogated to MDS
702 kill -USR1 $! || return 2
705 time2=$(stat -c "%X" $DIR/$tfile)
706 echo "new atime is $time2"
708 [ $time2 -gt $time1 ] || error "atime was not updated"
709 rm -f $DIR1/$tfile || error "rm -f $DIR1/$tfile failed"
712 run_test 23 " others should see updated atime while another read===="
716 lfs df || error "lfs df failed"
717 lfs df -ih || error "lfs df -ih failed"
718 lfs df -h $DIR1 || error "lfs df -h $DIR1 failed"
719 lfs df -i $DIR2 || error "lfs df -i $DIR2 failed"
720 lfs df $DIR1/$tfile || error "lfs df $DIR1/$tfile failed"
721 lfs df -ih $DIR2/$tfile || error "lfs df -ih $DIR2/$tfile failed"
723 OSC=`lctl dl | awk '/-osc-|OSC.*MNT/ {print $4}' | head -n 1`
724 # OSC=`lctl dl | awk '/-osc-/ {print $4}' | head -n 1`
725 lctl --device %osc deactivate
726 lfs df -i || error "lfs df -i with deactivated OSC failed"
727 lctl --device %osc activate
728 lfs df || error "lfs df with reactivated OSC failed"
730 run_test 24a "lfs df [-ih] [path] test ========================="
734 fsnum=$(lfs_df | grep -c "summary")
735 [ $fsnum -eq 2 ] || error "lfs df shows $fsnum != 2 filesystems."
737 run_test 24b "lfs df should show both filesystems ==============="
740 local acl=$(lctl get_param -n mdc.*MDT0000-mdc-*.connect_flags |
742 [ "$acl" -lt 1 ] && skip "must have acl, skipping" && return
745 touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
746 chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
748 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
749 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
750 error "setfacl $DIR2/$tdir #1"
751 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
752 setfacl -m u:$RUNAS_ID:r-x -m g:$RUNAS_GID:r-x $DIR1/$tdir ||
753 error "setfacl $DIR2/$tdir #2"
754 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
755 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
756 error "setfacl $DIR2/$tdir #3"
757 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
758 setfacl -x u:$RUNAS_ID: -x g:$RUNAS_GID: $DIR1/$tdir ||
759 error "setfacl $DIR2/$tdir #4"
760 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
764 run_test 25a "change ACL on one mountpoint be seen on another ==="
767 local acl=$(lctl get_param -n mdc.*MDT0000-mdc-*.connect_flags |
769 [ "$acl" -lt 1 ] && skip "must have acl, skipping" && return
771 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
774 $LFS mkdir -i 1 $DIR1/$tdir
775 touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
776 chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
778 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
779 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
780 error "setfacl $DIR2/$tdir #1"
781 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
782 setfacl -m u:$RUNAS_ID:r-x -m g:$RUNAS_GID:r-x $DIR1/$tdir ||
783 error "setfacl $DIR2/$tdir #2"
784 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
785 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
786 error "setfacl $DIR2/$tdir #3"
787 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
788 setfacl -x u:$RUNAS_ID: -x g:$RUNAS_GID: $DIR1/$tdir ||
789 error "setfacl $DIR2/$tdir #4"
790 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
794 run_test 25b "change ACL under remote dir on one mountpoint be seen on another"
797 utime $DIR1/f26a -s $DIR2/f26a || error "utime failed for $DIR1/f26a"
799 run_test 26a "allow mtime to get older"
804 echo "aaa" >> $DIR1/$tfile
806 chmod a+x $DIR2/$tfile
807 mt1=`stat -c %Y $DIR1/$tfile`
808 mt2=`stat -c %Y $DIR2/$tfile`
810 if [ x"$mt1" != x"$mt2" ]; then
811 error "not equal mtime, client1: "$mt1", client2: "$mt2"."
814 run_test 26b "sync mtime between ost and mds"
817 cancel_lru_locks $OSC
819 dd if=/dev/zero of=$DIR2/$tfile bs=$((4096+4))k conv=notrunc count=4 seek=3 &
824 dd if=/dev/zero of=$DIR1/$tfile bs=$((16384-1024))k conv=notrunc count=1 seek=4 &
829 dd if=/dev/zero of=$DIR1/$tfile bs=8k conv=notrunc count=1 seek=0
831 lctl set_param -n ldlm.dump_namespaces ""
832 wait $DD1_PID $DD2_PID
833 [ $? -ne 0 ] && lctl dk $TMP/debug || true
835 run_test 27 "align non-overlapping extent locks from request ==="
837 test_28() { # bug 9977
838 ECHO_UUID="ECHO_osc1_UUID"
839 tOST=$($LCTL dl | awk '/-osc-|OSC.*MNT/ { print $4 }' | head -n1)
841 $LFS setstripe $DIR1/$tfile -S 1048576 -i 0 -c 2
842 tOBJID=`$LFS getstripe $DIR1/$tfile | awk '$1 == 1 {print $2}'`
843 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2
847 attach echo_client ECHO_osc1 $ECHO_UUID
851 tECHOID=`$LCTL dl | grep $ECHO_UUID | awk '{ print $1 }'`
852 $LCTL --device $tECHOID destroy "${tOBJID}:0"
860 # reading of 1st stripe should pass
861 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error "dd failed"
862 # reading of 2nd stripe should fail (this stripe was destroyed)
863 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 && error
865 # now, recreating test file
866 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2 || error "dd failed"
867 # reading of 1st stripe should pass
868 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error "dd failed"
869 # reading of 2nd stripe should pass
870 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 ||
873 run_test 28 "read/write/truncate file with lost stripes"
875 test_30() { #b=11110, LU-2523
876 test_mkdir $DIR1/$tdir
877 cp -f /bin/bash $DIR1/$tdir/bash
878 bash -c 'sleep 1; rm -f $DIR2/$tdir/bash; cp /bin/bash $DIR2/$tdir' &
879 $DIR1/$tdir/bash -c 'sleep 2;
880 openfile -f O_RDONLY /proc/$$/exe >& /dev/null; echo $?'
884 run_test 30 "recreate file race"
887 test_mkdir $DIR1/$tdir
888 local writes=$(LANG=C dd if=/dev/zero of=$DIR/$tdir/$tfile \
889 count=1 2>&1 | awk 'BEGIN { FS="+" } /out/ {print $1}')
890 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
891 lctl set_param fail_loc=0x314
892 local reads=$(LANG=C dd if=$DIR2/$tdir/$tfile of=/dev/null 2>&1 |
893 awk 'BEGIN { FS="+" } /in/ {print $1}')
894 [ $reads -eq $writes ] || error "read" $reads "blocks, must be" $writes
896 run_test 31a "voluntary cancel / blocking ast race=============="
899 remote_ost || { skip "local OST" && return 0; }
900 remote_ost_nodsh && skip "remote OST w/o dsh" && return 0
902 # make sure there is no local locks due to destroy
903 wait_mds_ost_sync || error "wait_mds_ost_sync()"
904 wait_delete_completed || error "wait_delete_completed()"
906 test_mkdir $DIR1/$tdir
907 lfs setstripe $DIR/$tdir/$tfile -i 0 -c 1
908 cp /etc/hosts $DIR/$tdir/$tfile
909 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
910 lctl set_param fail_loc=0x314
911 #define OBD_FAIL_LDLM_OST_FAIL_RACE 0x316
912 do_facet ost1 lctl set_param fail_loc=0x316
914 cat $DIR2/$tdir/$tfile > /dev/null 2>&1
915 lctl set_param fail_loc=0
916 do_facet ost1 lctl set_param fail_loc=0
917 # cleanup: reconnect the client back
920 run_test 31b "voluntary OST cancel / blocking ast race=============="
922 #LU-14949 - multi-client version of the test 31r in sanity.
924 touch $DIR/$tfile.target
925 touch $DIR/$tfile.source
927 ls -l $DIR/$tfile.target # cache it for sure
929 #OBD_FAIL_LLITE_OPEN_DELAY 0x1419
930 $LCTL set_param fail_loc=0x1419 fail_val=3
931 cat $DIR/$tfile.target &
934 # Guarantee open is waiting before we get here
936 mv $DIR2/$tfile.source $DIR2/$tfile.target
940 if [[ $RC -ne 0 ]]; then
941 error "open with cat failed, rc=$RC"
944 run_test 31r "open-rename(replace) race"
946 test_32b() { # bug 11270
947 remote_ost_nodsh && skip "remote OST with nodsh" && return
950 local facets=$(get_facets OST)
951 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
953 save_lustre_params client "osc.*.contention_seconds" > $p
954 save_lustre_params $facets \
955 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
956 save_lustre_params $facets \
957 "ldlm.namespaces.filter-*.contended_locks" >> $p
958 save_lustre_params $facets \
959 "ldlm.namespaces.filter-*.contention_seconds" >> $p
960 clear_stats $OSC.*.${OSC}_stats
962 # agressive lockless i/o settings
963 do_nodes $(comma_list $(osts_nodes)) \
964 "lctl set_param -n ldlm.namespaces.*.max_nolock_bytes=2000000 \
965 ldlm.namespaces.filter-*.contended_locks=0 \
966 ldlm.namespaces.filter-*.contention_seconds=60"
967 lctl set_param -n $OSC.*.contention_seconds=60
969 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > \
971 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > \
974 [ $(calc_stats $OSC.*.${OSC}_stats lockless_write_bytes) -ne 0 ] ||
975 error "lockless i/o was not triggered"
976 # disable lockless i/o (it is disabled by default)
977 do_nodes $(comma_list $(osts_nodes)) \
978 "lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes=0 \
979 ldlm.namespaces.filter-*.contended_locks=32 \
980 ldlm.namespaces.filter-*.contention_seconds=0"
981 # set contention_seconds to 0 at client too, otherwise Lustre still
982 # remembers lock contention
983 lctl set_param -n $OSC.*.contention_seconds=0
984 clear_stats $OSC.*.${OSC}_stats
986 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > \
988 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > \
991 [ $(calc_stats $OSC.*.${OSC}_stats lockless_write_bytes) -eq 0 ] ||
992 error "lockless i/o works when disabled"
994 restore_lustre_params <$p
997 # Disable test 32b prior to full removal
998 #run_test 32b "lockless i/o"
1001 local mdts=$(get_facets MDS)
1007 for mds in ${mdts//,/ }; do
1010 dev=$(basename $(do_facet $mds "lctl get_param -n \
1011 osd*.${!varsvc}.mntdev | xargs readlink -f"))
1012 val=$(do_facet $mds "cat /proc/fs/jbd*/${dev}{,:*,-*}/info \
1013 2>/dev/null | head -n1")
1015 stat=$((stat + val))
1020 # commit on sharing tests
1022 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1024 [ $CLIENTCOUNT -lt 2 ] &&
1025 skip "Need two or more clients, have $CLIENTCOUNT"
1027 local nfiles=${TEST33_NFILES:-10000}
1028 local param_file=$TMP/$tfile-params
1034 save_lustre_params $(get_facets MDS) \
1035 "mdt.*.commit_on_sharing" > $param_file
1038 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
1042 do_nodes $CLIENT1,$CLIENT2 "mkdir -p $DIR1/$tdir-\\\$(hostname)-$i"
1044 [ "$mds1_FSTYPE" = ldiskfs ] && jbdold=$(print_jbd_stat)
1045 echo "=== START createmany old: $jbdold transaction"
1046 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")
1047 [ "$mds1_FSTYPE" = ldiskfs ] && jbdnew=$(print_jbd_stat)
1048 [ "$mds1_FSTYPE" = ldiskfs ] && jbd=$(( jbdnew - jbdold ))
1049 echo "=== END createmany new: $jbdnew transaction : $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
1050 [ "$mds1_FSTYPE" = ldiskfs ] && avgjbd=$(( avgjbd + jbd ))
1051 avgtime=$(( avgtime + elapsed ))
1053 eval cos${COS}_jbd=$((avgjbd / 3))
1054 eval cos${COS}_time=$((avgtime / 3))
1057 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
1058 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
1059 [ "$cos0_jbd" != 0 ] &&
1060 echo "COS=1 vs COS=0 jbd: $((((cos1_jbd/cos0_jbd - 1)) * 100 )) %"
1061 [ "$cos0_time" != 0 ] &&
1062 echo "COS=1 vs COS=0 time: $((((cos1_time/cos0_time - 1)) * 100 )) %"
1064 restore_lustre_params < $param_file
1068 run_test 33a "commit on sharing, cross crete/delete, 2 clients, benchmark"
1070 # commit on sharing tests
1072 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1074 [ $CLIENTCOUNT -ge 2 ] ||
1075 { skip "Need two or more clients, have $CLIENTCOUNT" &&
1077 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1079 local nfiles=${TEST33_NFILES:-10000}
1080 local param_file=$TMP/$tfile-params
1082 save_lustre_params $(get_facets MDS) \
1083 "mdt.*.commit_on_sharing" > $param_file
1092 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
1096 do_node $CLIENT1 "$LFS mkdir -i $MDTIDX \
1097 $DIR1/$tdir-\\\$(hostname)-$i"
1099 jbdold=$(print_jbd_stat)
1100 echo "=== START createmany old: $jbdold transaction"
1101 local elapsed=$(do_and_time "do_nodes $CLIENT1,$CLIENT2\
1102 createmany -o $DIR1/$tdir-\\\$(hostname)-$i/f- \
1103 -r$DIR2/$tdir-\\\$(hostname)-$i/f- $nfiles > \
1105 jbdnew=$(print_jbd_stat)
1106 jbd=$(( jbdnew - jbdold ))
1107 echo "=== END createmany new: $jbdnew transaction : \
1108 $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
1109 avgjbd=$(( avgjbd + jbd ))
1110 avgtime=$(( avgtime + elapsed ))
1112 eval cos${COS}_jbd=$((avgjbd / 3))
1113 eval cos${COS}_time=$((avgtime / 3))
1116 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
1117 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
1118 [ "$cos0_jbd" != 0 ] &&
1119 echo "COS=1 vs COS=0 jbd: $(((cos1_jbd/cos0_jbd - 1) * 100)) %"
1120 [ "$cos0_time" != 0 ] &&
1121 echo "COS=1 vs COS=0 time: $(((cos1_time/cos0_time - 1) * 100)) %"
1123 restore_lustre_params < $param_file
1127 run_test 33b "COS: cross create/delete, 2 clients, benchmark under remote dir"
1130 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
1131 [ "$MDS1_VERSION" -lt $(version_code 2.7.63) ] &&
1132 skip "DNE CoS not supported"
1136 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS || error "start mds1 failed"
1140 mkdir_on_mdt0 $DIR/$tdir
1142 do_facet mds1 "lctl set_param -n mdt.*.sync_count=0"
1143 # do twice in case transaction is committed before unlock, see LU-8200
1145 # remote dir is created on MDT1, which enqueued lock of $tdir on
1147 $LFS mkdir -i 1 $DIR/$tdir/remote.$i
1148 mkdir $DIR/$tdir/local.$i
1150 sync_count=$(do_facet mds1 "lctl get_param -n mdt.*MDT0000.sync_count")
1151 echo "sync_count $sync_count"
1152 [ $sync_count -eq 0 ] && error "Sync-Lock-Cancel not triggered"
1155 do_facet mds1 "lctl set_param -n mdt.*.sync_count=0"
1156 $LFS mkdir -i 1 $DIR/$tdir/remote.3
1157 # during sleep remote mkdir should have been committed and canceled
1158 # remote lock spontaneously, which shouldn't trigger sync
1160 mkdir $DIR/$tdir/local.3
1161 sync_count=$(do_facet mds1 "lctl get_param -n mdt.*MDT0000.sync_count")
1162 echo "sync_count $sync_count"
1163 [ $sync_count -eq 0 ] || error "Sync-Lock-Cancel triggered"
1165 run_test 33c "Cancel cross-MDT lock should trigger Sync-Lock-Cancel"
1167 # arg1 is operations done before CoS, arg2 is the operation that triggers CoS
1171 local nodes=$(comma_list $(mdts_nodes))
1175 # trigger CoS twice in case transaction commit before unlock
1178 do_nodes $nodes "lctl set_param -n mdt.*.async_commit_count=0"
1180 commit_nr=$(do_nodes $nodes \
1181 "lctl get_param -n mdt.*.async_commit_count" | calc_sum)
1182 total=$((total + commit_nr));
1187 echo "CoS count $total"
1188 [ $total -gt 0 ] || error "$2 didn't trigger CoS"
1192 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
1193 [ "$MDS1_VERSION" -lt $(version_code 2.7.63) ] &&
1194 skip "DNE CoS not supported"
1196 # remote directory create
1197 op_trigger_cos "$LFS mkdir -i 0 $DIR/$tdir" "$LFS mkdir -i 1 $DIR/$tdir/subdir"
1198 # remote directory unlink
1199 op_trigger_cos "$LFS mkdir -i 1 $DIR/$tdir" "rmdir $DIR/$tdir"
1200 # striped directory create
1201 op_trigger_cos "mkdir $DIR/$tdir" "$LFS mkdir -c 2 $DIR/$tdir/subdir"
1202 # striped directory setattr
1203 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; touch $DIR/$tdir" \
1204 "chmod 713 $DIR/$tdir"
1205 # striped directory unlink
1206 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; touch $DIR/$tdir" \
1209 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; \
1210 $LFS mkdir -i 0 $DIR/$tdir/d1; \
1211 $LFS mkdir -i 1 $DIR/$tdir/d2; \
1212 touch $DIR/$tdir/d1/tgt" \
1213 "ln $DIR/$tdir/d1/tgt $DIR/$tdir/d2/src"
1215 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; \
1216 $LFS mkdir -i 0 $DIR/$tdir/d1; \
1217 $LFS mkdir -i 1 $DIR/$tdir/d2; \
1218 touch $DIR/$tdir/d1/src" \
1219 "mv $DIR/$tdir/d1/src $DIR/$tdir/d2/tgt"
1221 op_trigger_cos "$LFS mkdir -i 0 $DIR/$tdir" \
1222 "$LFS migrate -m 1 $DIR/$tdir"
1226 run_test 33d "DNE distributed operation should trigger COS"
1229 [ $CLIENTCOUNT -ge 2 ] ||
1230 skip "Need two or more clients, have $CLIENTCOUNT"
1231 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
1232 [ "$MDS1_VERSION" -lt $(version_code 2.7.63) ] &&
1233 skip "DNE CoS not supported"
1235 local client2=${CLIENT2:-$(hostname)}
1239 local nodes=$(comma_list $(mdts_nodes))
1240 do_nodes $nodes "lctl set_param -n mdt.*.async_commit_count=0"
1242 $LFS mkdir -c 2 $DIR/$tdir
1243 mkdir $DIR/$tdir/subdir
1244 echo abc > $DIR/$tdir/$tfile
1245 do_node $client2 echo dfg >> $DIR/$tdir/$tfile
1246 do_node $client2 touch $DIR/$tdir/subdir
1248 local async_commit_count=$(do_nodes $nodes \
1249 "lctl get_param -n mdt.*.async_commit_count" | calc_sum)
1250 [ $async_commit_count -gt 0 ] && error "CoS triggerred"
1254 run_test 33e "DNE local operation shouldn't trigger COS"
1256 # End commit on sharing tests
1258 get_ost_lock_timeouts() {
1259 local nodes=${1:-$(comma_list $(osts_nodes))}
1261 local locks=$(do_nodes $nodes \
1262 "lctl get_param -n ldlm.namespaces.filter-*.lock_timeouts" | calc_sum)
1270 do_nodes $(comma_list $(osts_nodes)) \
1271 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1272 for i in $(seq $OSTCOUNT); do
1273 wait_osc_import_ready client ost$i
1278 remote_ost_nodsh && skip "remote OST with nodsh" && return
1282 trap cleanup_34 EXIT RETURN
1283 for OPER in notimeout timeout ; do
1284 rm $DIR1/$tfile 2>/dev/null
1285 lock_in=$(get_ost_lock_timeouts)
1286 if [ $OPER == "timeout" ] ; then
1287 for j in `seq $OSTCOUNT`; do
1288 #define OBD_FAIL_PTLRPC_HPREQ_TIMEOUT 0x511
1289 do_facet ost$j lctl set_param fail_loc=0x511
1291 echo lock should expire
1293 for j in `seq $OSTCOUNT`; do
1294 #define OBD_FAIL_PTLRPC_HPREQ_NOTIMEOUT 0x512
1295 do_facet ost$j lctl set_param fail_loc=0x512
1297 echo lock should not expire
1299 echo writing on client1
1300 dd if=/dev/zero of=$DIR1/$tfile count=100 conv=notrunc > /dev/null 2>&1
1302 echo reading on client2
1303 dd of=/dev/null if=$DIR2/$tfile > /dev/null 2>&1
1304 # wait for a lock timeout
1306 lock_out=$(get_ost_lock_timeouts)
1307 if [ $OPER == "timeout" ] ; then
1308 if [ $lock_in == $lock_out ]; then
1309 error "no lock timeout happened"
1314 if [ $lock_in != $lock_out ]; then
1315 error "lock timeout happened"
1323 run_test 34 "no lock timeout under IO"
1325 test_35() { # bug 17645
1328 gen=$(lctl get_param mdc.$FSNAME-MDT*-mdc-*.import | grep generation |
1329 awk '/generation/{print $2}')
1331 generation[count]=$g
1335 test_mkdir $MOUNT1/$tdir
1336 cancel_lru_locks mdc
1338 # Let's initiate -EINTR situation by setting fail_loc and take
1339 # write lock on same file from same client. This will not cause
1340 # bl_ast yet as lock is already in local cache.
1341 #define OBD_FAIL_LDLM_INTR_CP_AST 0x317
1342 do_facet client "lctl set_param fail_loc=0x80000317"
1343 local timeout=$(do_facet $SINGLEMDS lctl get_param -n timeout)
1344 let timeout=timeout*3
1346 while test $nr -lt 10; do
1347 log "Race attempt $nr"
1348 local blk1=$(lctl get_param -n ldlm.services.ldlm_cbd.stats |
1349 awk '/ldlm_bl_callback/ { print $2 }')
1350 test "x$blk1" = "x" && blk1=0
1351 createmany -o $MOUNT2/$tdir/a 4000 &
1355 # Let's make conflict and bl_ast
1356 ls -la $MOUNT1/$tdir > /dev/null &
1359 log "Wait for $pid1 $pid2 for $timeout sec..."
1361 kill -9 $pid1 $pid2 > /dev/null 2>&1
1363 local blk2=$(lctl get_param -n ldlm.services.ldlm_cbd.stats |
1364 awk '/ldlm_bl_callback/ { print $2 }')
1365 test "x$blk2" = "x" && blk2=0
1366 test $blk2 -gt $blk1 && break
1367 rm -fr $MOUNT1/$tdir
1368 cancel_lru_locks mdc
1371 do_facet client "lctl set_param fail_loc=0x0"
1372 df -h $MOUNT1 $MOUNT2
1374 gen=$(lctl get_param mdc.$FSNAME-MDT*-mdc-*.import | grep generation |
1375 awk '/generation/{print $2}')
1377 if ! test "$g" -eq "${generation[count]}"; then
1378 list=$(lctl list_param mdc.$FSNAME-MDT*-mdc-*.import)
1380 for imp in $list; do
1381 if [ $c = $count ]; then
1386 imp=$(echo "$imp" | awk -F"." '{print $2}')
1387 error "Eviction happened on import $imp"
1392 run_test 35 "-EINTR cp_ast vs. bl_ast race does not evict client"
1394 test_36() { #bug 16417
1399 test_mkdir $DIR1/$tdir
1400 $LFS setstripe -c -1 $DIR1/$tdir
1403 let SIZE_B=SIZE*1024*1024
1404 sync; sleep 2; sync # wait for delete thread
1405 wait_mds_ost_sync || error "wait_mds_ost_sync failed"
1406 wait_destroy_complete || error "wait_destroy_complete failed"
1408 while [ $i -le 10 ]; do
1409 lctl mark "start test - cycle ($i)"
1410 local before=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1411 dd if=/dev/zero of=$DIR1/$tdir/$tfile bs=1M count=$SIZE ||
1412 error "dd $DIR1/$tdir/$tfile ${SIZE}MB failed"
1413 sync # sync data from client cache
1414 sync_all_data # sync data from server cache (delayed allocation)
1416 local after_dd=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1417 multiop_bg_pause $DIR2/$tdir/$tfile O_r${SIZE_B}c || return 3
1419 rm -f $DIR1/$tdir/$tfile
1420 kill -USR1 $read_pid
1422 sync; sleep 2; sync # Ensure new statfs
1423 wait_delete_completed
1424 local after=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1425 echo "*** cycle($i) *** before($before) after_dd($after_dd)" \
1427 # this free space! not used
1428 (( $after_dd <= $after)) ||
1429 error "space leaked after_dd:$after_dd > after:$after"
1433 run_test 36 "handle ESTALE/open-unlink correctly"
1435 test_37() { # bug 18695
1436 test_mkdir $DIR1/$tdir
1437 multiop_bg_pause $DIR1/$tdir D_c || return 1
1439 # create large directory (32kB seems enough from e2fsck, ~= 1000 files)
1440 createmany -m $DIR2/$tdir/f 10000
1441 # set mtime/atime backward
1442 touch -t 198001010000 $DIR2/$tdir
1443 kill -USR1 $MULTIPID
1444 nr_files=`lfs find $DIR1/$tdir -type f | wc -l`
1445 [ $nr_files -eq 10000 ] || error "$nr_files != 10000 truncated directory?"
1448 run_test 37 "check i_size is not updated for directory on close (bug 18695) =============="
1450 # this should be set to past
1451 TEST_39_MTIME=`date -d "1 year ago" +%s`
1455 local client1=${CLIENT1:-`hostname`}
1456 local client2=${CLIENT2:-`hostname`}
1458 do_node $client1 "touch $DIR1/$tfile"
1460 do_node $client1 "touch -m -d @$TEST_39_MTIME $DIR1/$tfile"
1461 local mtime1=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1462 [ "$mtime1" = $TEST_39_MTIME ] || \
1463 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
1465 local d1=`do_node $client1 date +%s`
1466 do_node $client1 'echo hello >> '$DIR1/$tfile
1467 local d2=`do_node $client1 date +%s`
1469 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1470 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
1471 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
1473 do_node $client1 "mv $DIR1/$tfile $DIR1/$tfile-1"
1475 for (( i=0; i < 2; i++ )) ; do
1476 local mtime3=`do_node $client2 "stat -c %Y $DIR1/$tfile-1"`
1477 [ "$mtime2" = "$mtime3" ] || \
1478 error "mtime ($mtime2) changed (to $mtime3) on rename"
1480 cancel_lru_locks osc
1481 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1484 run_test 39a "test from 11063 =================================="
1487 local client1=${CLIENT1:-`hostname`}
1488 local client2=${CLIENT2:-`hostname`}
1492 local mtime1=`stat -c %Y $DIR1/$tfile`
1493 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1496 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
1498 for (( i=0; i < 2; i++ )) ; do
1499 local mtime3=`stat -c %Y $DIR1/$tfile`
1500 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1502 [ "$mtime3" = "$mtime4" ] || \
1503 error "different mtime on clients: $mtime3, $mtime4"
1504 [ "$mtime3" = $TEST_39_MTIME ] || \
1505 error "lost mtime: $mtime3, should be $TEST_39_MTIME"
1507 cancel_lru_locks osc
1508 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1511 run_test 39b "11063 problem 1 =================================="
1514 local client1=${CLIENT1:-`hostname`}
1515 local client2=${CLIENT2:-`hostname`}
1517 echo hello > $DIR1/$tfile
1519 local mtime1=`stat -c %Y $DIR1/$tfile`
1520 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1521 [ "$mtime1" = "$mtime2" ] || \
1522 error "create: different mtime on clients: $mtime1, $mtime2"
1525 $TRUNCATE $DIR1/$tfile 1
1527 for (( i=0; i < 2; i++ )) ; do
1528 local mtime3=`stat -c %Y $DIR1/$tfile`
1529 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1531 [ "$mtime3" = "$mtime4" ] || \
1532 error "different mtime on clients: $mtime3, $mtime4"
1533 [ "$mtime3" -gt $mtime2 ] || \
1534 error "truncate did not update mtime: $mtime2, $mtime3"
1536 cancel_lru_locks osc
1537 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1540 run_test 39c "check truncate mtime update ======================"
1542 test_39d() { # LU-7310
1544 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
1546 local mtime1=$(stat -c %Y $DIR2/$tfile)
1547 [ "$mtime1" = $TEST_39_MTIME ] ||
1548 error "mtime: $mtime1, should be $TEST_39_MTIME"
1551 # define OBD_FAIL_OSC_NO_GRANT 0x411
1552 $LCTL set_param fail_loc=0x411
1554 local d1=$(date +%s)
1555 echo hello >> $DIR1/$tfile
1556 local d2=$(date +%s)
1558 $LCTL set_param fail_loc=0
1560 cancel_lru_locks $OSC
1562 local mtime2=$(stat -c %Y $DIR2/$tfile)
1563 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] ||
1564 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
1566 run_test 39d "sync write should update mtime"
1569 # how long 40-47 take with specific delay
1576 # for pdo testing, we must cancel MDT-MDT locks as well as client locks to
1577 # avoid unexpected delays due to previous tests
1579 cancel_lru_locks mdc
1580 do_nodes $(comma_list $(mdts_nodes)) \
1581 $LCTL set_param -n ldlm.namespaces.*mdt*.lru_size=clear
1582 do_nodes $(comma_list $(mdts_nodes)) \
1583 $LCTL get_param ldlm.namespaces.*mdt*.lock_unused_count \
1584 ldlm.namespaces.*mdt*.lock_count | grep -v '=0'
1587 # check that pid exists hence second operation wasn't blocked by first one
1588 # if it is so then there is no conflict, return 0
1589 # else second operation is conflicting with first one, return 1
1590 check_pdo_conflict() {
1593 pdo_sched # to ensure OP1 is finished on client if OP2 is blocked by OP1
1594 if [[ `ps --pid $pid | wc -l` == 1 ]]; then
1604 # test 40: check non-blocking operations
1606 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1608 mkdir_on_mdt0 $DIR2/$tdir
1610 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1611 do_nodes $(comma_list $(mdts_nodes)) \
1612 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1613 mkdir $DIR1/$tdir/$tfile &
1615 touch $DIR2/$tdir/$tfile-2
1616 check_pdo_conflict $PID1 || error "create is blocked"
1617 mkdir $DIR2/$tdir/$tfile-3
1618 check_pdo_conflict $PID1 || error "mkdir is blocked"
1619 link $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-4
1620 check_pdo_conflict $PID1 || error "link is blocked"
1621 mv $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-5
1622 check_pdo_conflict $PID1 || error "rename is blocked"
1623 stat $DIR2/$tdir/$tfile-3 $DIR2/$tdir/$tfile-4 > /dev/null
1624 check_pdo_conflict $PID1 || error "getattr is blocked"
1625 rm $DIR2/$tdir/$tfile-4 $DIR2/$tdir/$tfile-5
1626 rmdir $DIR2/$tdir/$tfile-3
1627 check_pdo_conflict $PID1 || error "unlink is blocked"
1629 # all operations above shouldn't wait the first one
1630 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1631 do_nodes $(comma_list $(mdts_nodes)) \
1632 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1637 run_test 40a "pdirops: create vs others =============="
1640 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1642 mkdir_on_mdt0 $DIR2/$tdir
1644 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1645 do_nodes $(comma_list $(mdts_nodes)) \
1646 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1647 touch $DIR1/$tdir/$tfile &
1650 touch $DIR2/$tdir/$tfile-2
1651 check_pdo_conflict $PID1 || error "create is blocked"
1652 mkdir $DIR2/$tdir/$tfile-3
1653 check_pdo_conflict $PID1 || error "mkdir is blocked"
1654 link $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-4
1655 check_pdo_conflict $PID1 || error "link is blocked"
1656 mv $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-5
1657 check_pdo_conflict $PID1 || error "rename is blocked"
1658 stat $DIR2/$tdir/$tfile-3 $DIR2/$tdir/$tfile-4 > /dev/null
1659 check_pdo_conflict $PID1 || error "getattr is blocked"
1660 rm $DIR2/$tdir/$tfile-4 $DIR2/$tdir/$tfile-5
1661 rmdir $DIR2/$tdir/$tfile-3
1662 check_pdo_conflict $PID1 || error "unlink is blocked"
1663 # all operations above shouldn't wait the first one
1665 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1666 do_nodes $(comma_list $(mdts_nodes)) \
1667 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1672 run_test 40b "pdirops: open|create and others =============="
1675 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1677 mkdir_on_mdt0 $DIR2/$tdir
1679 touch $DIR1/$tdir/$tfile
1680 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1681 do_nodes $(comma_list $(mdts_nodes)) \
1682 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1683 link $DIR1/$tdir/$tfile $DIR1/$tdir/$tfile-0 &
1686 touch $DIR2/$tdir/$tfile-2
1687 check_pdo_conflict $PID1 || error "create is blocked"
1688 mkdir $DIR2/$tdir/$tfile-3
1689 check_pdo_conflict $PID1 || error "mkdir is blocked"
1690 link $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-4
1691 check_pdo_conflict $PID1 || error "link is blocked"
1692 mv $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-5
1693 check_pdo_conflict $PID1 || error "rename is blocked"
1694 stat $DIR2/$tdir/$tfile-3 $DIR2/$tdir/$tfile-4 > /dev/null
1695 check_pdo_conflict $PID1 || error "getattr is blocked"
1696 rm $DIR2/$tdir/$tfile-4 $DIR2/$tdir/$tfile-5
1697 rmdir $DIR2/$tdir/$tfile-3
1698 check_pdo_conflict $PID1 || error "unlink is blocked"
1700 # all operations above shouldn't wait the first one
1701 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1702 do_nodes $(comma_list $(mdts_nodes)) \
1703 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1708 run_test 40c "pdirops: link and others =============="
1711 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1713 mkdir_on_mdt0 $DIR2/$tdir
1715 touch $DIR1/$tdir/$tfile
1716 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1717 do_nodes $(comma_list $(mdts_nodes)) \
1718 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1719 rm $DIR1/$tdir/$tfile &
1722 touch $DIR2/$tdir/$tfile-2
1723 check_pdo_conflict $PID1 || error "create is blocked"
1724 mkdir $DIR2/$tdir/$tfile-3
1725 check_pdo_conflict $PID1 || error "mkdir is blocked"
1726 link $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-4
1727 check_pdo_conflict $PID1 || error "link is blocked"
1728 mv $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-5
1729 check_pdo_conflict $PID1 || error "rename is blocked"
1730 stat $DIR2/$tdir/$tfile-3 $DIR2/$tdir/$tfile-4 > /dev/null
1731 check_pdo_conflict $PID1 || error "getattr is blocked"
1732 rm $DIR2/$tdir/$tfile-4 $DIR2/$tdir/$tfile-5
1733 rmdir $DIR2/$tdir/$tfile-3
1734 check_pdo_conflict $PID1 || error "unlink is blocked"
1736 # all operations above shouldn't wait the first one
1737 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1738 do_nodes $(comma_list $(mdts_nodes)) \
1739 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1743 run_test 40d "pdirops: unlink and others =============="
1746 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1748 mkdir_on_mdt0 $DIR2/$tdir
1750 touch $DIR1/$tdir/$tfile
1751 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1752 do_nodes $(comma_list $(mdts_nodes)) \
1753 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1754 mv $DIR1/$tdir/$tfile $DIR1/$tdir/$tfile-0 &
1757 touch $DIR2/$tdir/$tfile-2
1758 check_pdo_conflict $PID1 || error "create is blocked"
1759 mkdir $DIR2/$tdir/$tfile-3
1760 check_pdo_conflict $PID1 || error "mkdir is blocked"
1761 link $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-4
1762 check_pdo_conflict $PID1 || error "link is blocked"
1763 stat $DIR2/$tdir/$tfile-3 $DIR2/$tdir/$tfile-4 > /dev/null
1764 check_pdo_conflict $PID1 || error "getattr is blocked"
1765 rm $DIR2/$tdir/$tfile-4 $DIR2/$tdir/$tfile-2
1766 rmdir $DIR2/$tdir/$tfile-3
1767 check_pdo_conflict $PID1 || error "unlink is blocked"
1769 # all operations above shouldn't wait the first one
1770 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1771 do_nodes $(comma_list $(mdts_nodes)) \
1772 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1777 run_test 40e "pdirops: rename and others =============="
1779 # test 41: create blocking operations
1782 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1783 do_nodes $(comma_list $(mdts_nodes)) \
1784 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1785 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1787 mkdir $DIR2/$tfile &
1789 do_nodes $(comma_list $(mdts_nodes)) \
1790 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1791 check_pdo_conflict $PID1 && { wait $PID1; echo "mkdir isn't blocked"; }
1792 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
1796 run_test 41a "pdirops: create vs mkdir =============="
1800 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1801 do_nodes $(comma_list $(mdts_nodes)) \
1802 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1803 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1805 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
1807 do_nodes $(comma_list $(mdts_nodes)) \
1808 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1809 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1810 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
1814 run_test 41b "pdirops: create vs create =============="
1818 touch $DIR1/$tfile-2
1819 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1820 do_nodes $(comma_list $(mdts_nodes)) \
1821 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1822 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1824 link $DIR2/$tfile-2 $DIR2/$tfile &
1826 do_nodes $(comma_list $(mdts_nodes)) \
1827 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1828 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1829 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
1833 run_test 41c "pdirops: create vs link =============="
1837 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1838 do_nodes $(comma_list $(mdts_nodes)) \
1839 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1840 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1844 do_nodes $(comma_list $(mdts_nodes)) \
1845 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1846 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1847 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
1851 run_test 41d "pdirops: create vs unlink =============="
1855 touch $DIR1/$tfile-2
1856 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1857 do_nodes $(comma_list $(mdts_nodes)) \
1858 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1859 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1861 mv $DIR2/$tfile-2 $DIR2/$tfile &
1863 do_nodes $(comma_list $(mdts_nodes)) \
1864 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1865 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1866 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
1870 run_test 41e "pdirops: create and rename (tgt) =============="
1874 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1875 do_nodes $(comma_list $(mdts_nodes)) \
1876 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1877 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1879 mv $DIR2/$tfile $DIR2/$tfile-2 &
1881 do_nodes $(comma_list $(mdts_nodes)) \
1882 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1883 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1884 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
1888 run_test 41f "pdirops: create and rename (src) =============="
1892 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1893 do_nodes $(comma_list $(mdts_nodes)) \
1894 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1895 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1897 stat $DIR2/$tfile > /dev/null &
1899 do_nodes $(comma_list $(mdts_nodes)) \
1900 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1901 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1902 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
1906 run_test 41g "pdirops: create vs getattr =============="
1910 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1911 do_nodes $(comma_list $(mdts_nodes)) \
1912 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1913 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1915 ls -lia $DIR2/ > /dev/null &
1917 do_nodes $(comma_list $(mdts_nodes)) \
1918 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1919 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1924 run_test 41h "pdirops: create vs readdir =============="
1931 do_nodes $(comma_list $(mdts_nodes)) \
1932 "lctl set_param -n fail_loc=${fail_loc} || true" &>/dev/null
1934 $MULTIOP $DIR1/$tfile oO_CREAT:O_EXCL:c 2>/dev/null &
1937 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c 2>/dev/null &
1940 if ! wait $PID1 && ! wait $PID2; then
1941 echo "Both creates failed (1 should fail, 1 should succeed)"
1943 elif wait $PID1 && wait $PID2; then
1944 echo "Both creates succeeded (1 should fail, 1 should succeed)"
1949 do_nodes $(comma_list $(mdts_nodes)) \
1950 "lctl set_param -n fail_loc=0x0 || true" &>/dev/null
1957 (( $MDS1_VERSION >= $(version_code 2.13.56) )) ||
1958 skip "Need MDS version newer than 2.13.56"
1961 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN 0x169
1962 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN2 0x16a
1963 for fail_loc in "0x80000169" "0x8000016a"; do
1964 echo "Begin 100 tests with fail_loc=$fail_loc"
1966 for i in {1..100}; do
1968 msg=$(sub_test_41i "$fail_loc") ||
1969 { echo; error "iter=$i : $msg"; }
1974 run_test 41i "reint_open: create vs create"
1977 # test 42: unlink and blocking operations
1980 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1981 do_nodes $(comma_list $(mdts_nodes)) \
1982 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1983 mkdir $DIR1/$tfile &
1985 mkdir $DIR2/$tfile &
1987 do_nodes $(comma_list $(mdts_nodes)) \
1988 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1989 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1990 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
1994 run_test 42a "pdirops: mkdir vs mkdir =============="
1998 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1999 do_nodes $(comma_list $(mdts_nodes)) \
2000 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2001 mkdir $DIR1/$tfile &
2003 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2005 do_nodes $(comma_list $(mdts_nodes)) \
2006 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2007 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2008 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
2012 run_test 42b "pdirops: mkdir vs create =============="
2016 touch $DIR1/$tfile-2
2017 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2018 do_nodes $(comma_list $(mdts_nodes)) \
2019 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2020 mkdir $DIR1/$tfile &
2022 link $DIR2/$tfile-2 $DIR2/$tfile &
2024 do_nodes $(comma_list $(mdts_nodes)) \
2025 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2026 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2027 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
2031 run_test 42c "pdirops: mkdir vs link =============="
2035 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2036 do_nodes $(comma_list $(mdts_nodes)) \
2037 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2038 mkdir $DIR1/$tfile &
2040 rmdir $DIR2/$tfile &
2042 do_nodes $(comma_list $(mdts_nodes)) \
2043 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2044 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2045 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
2049 run_test 42d "pdirops: mkdir vs unlink =============="
2053 touch $DIR1/$tfile-2
2054 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2055 do_nodes $(comma_list $(mdts_nodes)) \
2056 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2057 mkdir $DIR1/$tfile &
2059 mv -T $DIR2/$tfile-2 $DIR2/$tfile &
2061 do_nodes $(comma_list $(mdts_nodes)) \
2062 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2063 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2064 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
2068 run_test 42e "pdirops: mkdir and rename (tgt) =============="
2072 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2073 do_nodes $(comma_list $(mdts_nodes)) \
2074 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2075 mkdir $DIR1/$tfile &
2077 mv $DIR2/$tfile $DIR2/$tfile-2 &
2079 do_nodes $(comma_list $(mdts_nodes)) \
2080 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2081 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2082 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2086 run_test 42f "pdirops: mkdir and rename (src) =============="
2089 mkdir_on_mdt0 $DIR1/$tdir
2091 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2092 do_nodes $(comma_list $(mdts_nodes)) \
2093 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2094 mkdir $DIR1/$tdir/$tfile &
2096 stat $DIR2/$tdir/$tfile > /dev/null &
2098 do_nodes $(comma_list $(mdts_nodes)) \
2099 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2100 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2101 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
2104 run_test 42g "pdirops: mkdir vs getattr =============="
2108 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2109 do_nodes $(comma_list $(mdts_nodes)) \
2110 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2111 mkdir $DIR1/$tfile &
2113 ls -lia $DIR2/ > /dev/null &
2115 do_nodes $(comma_list $(mdts_nodes)) \
2116 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2117 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2122 run_test 42h "pdirops: mkdir vs readdir =============="
2124 # test 43: rmdir,mkdir won't return -EEXIST
2126 for i in {1..1000}; do
2127 mkdir $DIR1/$tdir || error "mkdir $tdir failed"
2128 rmdir $DIR2/$tdir || error "rmdir $tdir failed"
2132 run_test 43a "rmdir,mkdir doesn't return -EEXIST =============="
2137 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2138 do_nodes $(comma_list $(mdts_nodes)) \
2139 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2142 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2144 do_nodes $(comma_list $(mdts_nodes)) \
2145 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2146 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2147 wait $PID2 ; [ $? -eq 0 ] || error "create must succeed"
2151 run_test 43b "pdirops: unlink vs create =============="
2156 touch $DIR1/$tfile-2
2157 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2158 do_nodes $(comma_list $(mdts_nodes)) \
2159 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2162 link $DIR2/$tfile-2 $DIR2/$tfile &
2164 do_nodes $(comma_list $(mdts_nodes)) \
2165 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2166 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2167 wait $PID2 ; [ $? -eq 0 ] || error "link must succeed"
2171 run_test 43c "pdirops: unlink vs link =============="
2176 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2177 do_nodes $(comma_list $(mdts_nodes)) \
2178 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2183 do_nodes $(comma_list $(mdts_nodes)) \
2184 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2185 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2186 wait $PID2 ; [ $? -ne 0 ] || error "unlink must fail"
2190 run_test 43d "pdirops: unlink vs unlink =============="
2195 touch $DIR1/$tfile-2
2196 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2197 do_nodes $(comma_list $(mdts_nodes)) \
2198 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2201 mv -u $DIR2/$tfile-2 $DIR2/$tfile &
2203 do_nodes $(comma_list $(mdts_nodes)) \
2204 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2205 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2206 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2210 run_test 43e "pdirops: unlink and rename (tgt) =============="
2215 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2216 do_nodes $(comma_list $(mdts_nodes)) \
2217 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2220 mv $DIR2/$tfile $DIR2/$tfile-2 &
2222 do_nodes $(comma_list $(mdts_nodes)) \
2223 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2224 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2225 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
2229 run_test 43f "pdirops: unlink and rename (src) =============="
2234 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2235 do_nodes $(comma_list $(mdts_nodes)) \
2236 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2239 stat $DIR2/$tfile > /dev/null &
2241 do_nodes $(comma_list $(mdts_nodes)) \
2242 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2243 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2244 wait $PID2 ; [ $? -ne 0 ] || error "stat must fail"
2248 run_test 43g "pdirops: unlink vs getattr =============="
2253 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2254 do_nodes $(comma_list $(mdts_nodes)) \
2255 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2258 ls -lia $DIR2/ > /dev/null &
2260 do_nodes $(comma_list $(mdts_nodes)) \
2261 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2262 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2267 run_test 43h "pdirops: unlink vs readdir =============="
2270 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2273 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2274 do_nodes $(comma_list $(mdts_nodes)) \
2275 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2278 $LFS mkdir -i 1 $DIR2/$tfile &
2280 do_nodes $(comma_list $(mdts_nodes)) \
2281 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2282 check_pdo_conflict $PID1 &&
2283 { wait $PID1; error "remote mkdir isn't blocked"; }
2284 wait $PID2 ; [ $? -eq 0 ] || error "remote mkdir must succeed"
2288 run_test 43i "pdirops: unlink vs remote mkdir"
2291 [[ $MDS1_VERSION -lt $(version_code 2.13.52) ]] &&
2292 skip "Need MDS version newer than 2.13.52"
2294 mkdir_on_mdt0 $DIR1/$tdir
2295 for i in {1..100}; do
2296 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_CREATE_RACE 0x167
2297 do_nodes $(comma_list $(mdts_nodes)) \
2298 "lctl set_param -n fail_loc=0x80000167 2>/dev/null ||
2301 mkdir $DIR1/$tdir/sub &
2303 mkdir $DIR2/$tdir/sub && ((OK++))
2304 wait $PID1 && ((OK++))
2305 (( OK == 1 )) || error "exactly one mkdir should succeed"
2307 rmdir $DIR1/$tdir/sub || error "rmdir failed"
2311 run_test 43j "racy mkdir return EEXIST =============="
2318 # We test in a separate directory to be able to unblock server thread in
2319 # cfs_race() if LCK_PW is taken on the parent by mdt_reint_unlink.
2320 test_mkdir $DIR2/$tdir
2321 touch $DIR2/$tdir/$tfile
2324 do_nodes $(comma_list $(mdts_nodes)) \
2325 "lctl set_param -n fail_loc=${fail_loc} || true" &>/dev/null
2326 echo content > $DIR1/$tdir/$tfile & PID1=$!
2328 multiop $DIR2/$tdir/$tfile u & PID2=$!
2332 echo -n "overwriting $tfile should succeed (err=$ret); "; }
2335 echo -n "unlinking $tfile should succeed (err=$ret);"; }
2338 do_nodes $(comma_list $(mdts_nodes)) \
2339 "lctl set_param -n fail_loc=0x0 || true" &>/dev/null
2346 (( $MDS1_VERSION >= $(version_code 2.13.56) )) ||
2347 skip "Need MDS version newer than 2.13.56"
2350 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN 0x169
2351 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN2 0x16a
2352 for fail_loc in "0x80000169" "0x8000016a"; do
2353 echo "Begin 100 tests with fail_loc=$fail_loc"
2355 for i in {1..100}; do
2357 msg=$(sub_test_43k "$fail_loc") ||
2358 { echo; error "iter=$i : $msg"; }
2368 run_test 43k "unlink vs create"
2370 # test 44: rename tgt and blocking operations
2373 touch $DIR1/$tfile-2
2374 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2375 do_nodes $(comma_list $(mdts_nodes)) \
2376 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2377 mv $DIR1/$tfile-2 $DIR1/$tfile &
2379 mkdir $DIR2/$tfile &
2381 do_nodes $(comma_list $(mdts_nodes)) \
2382 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2383 check_pdo_conflict $PID1 && { wait $PID1; date;error "mkdir isn't blocked"; }
2384 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
2389 run_test 44a "pdirops: rename tgt vs mkdir =============="
2393 touch $DIR1/$tfile-2
2394 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2395 do_nodes $(comma_list $(mdts_nodes)) \
2396 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2397 mv $DIR1/$tfile-2 $DIR1/$tfile &
2399 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2401 do_nodes $(comma_list $(mdts_nodes)) \
2402 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2403 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2404 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
2408 run_test 44b "pdirops: rename tgt vs create =============="
2412 touch $DIR1/$tfile-2
2413 touch $DIR1/$tfile-3
2414 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2415 do_nodes $(comma_list $(mdts_nodes)) \
2416 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2417 mv $DIR1/$tfile-2 $DIR1/$tfile &
2419 link $DIR2/$tfile-3 $DIR2/$tfile &
2421 do_nodes $(comma_list $(mdts_nodes)) \
2422 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2423 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2424 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
2428 run_test 44c "pdirops: rename tgt vs link =============="
2432 touch $DIR1/$tfile-2
2433 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2434 do_nodes $(comma_list $(mdts_nodes)) \
2435 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2436 mv $DIR1/$tfile-2 $DIR1/$tfile &
2440 do_nodes $(comma_list $(mdts_nodes)) \
2441 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2442 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2443 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
2447 run_test 44d "pdirops: rename tgt vs unlink =============="
2452 touch $DIR1/$tfile-2
2453 touch $DIR1/$tfile-3
2454 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2455 do_nodes $(comma_list $(mdts_nodes)) \
2456 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2457 mv $DIR1/$tfile-2 $DIR1/$tfile &
2459 mv $DIR2/$tfile-3 $DIR2/$tfile &
2461 do_nodes $(comma_list $(mdts_nodes)) \
2462 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2463 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2464 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2468 run_test 44e "pdirops: rename tgt and rename (tgt) =============="
2472 touch $DIR1/$tfile-2
2473 touch $DIR1/$tfile-3
2474 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2475 do_nodes $(comma_list $(mdts_nodes)) \
2476 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2477 mv $DIR1/$tfile-2 $DIR1/$tfile &
2479 mv $DIR2/$tfile $DIR2/$tfile-3 &
2481 do_nodes $(comma_list $(mdts_nodes)) \
2482 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2483 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2484 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2488 run_test 44f "pdirops: rename tgt and rename (src) =============="
2492 touch $DIR1/$tfile-2
2493 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2494 do_nodes $(comma_list $(mdts_nodes)) \
2495 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2496 mv $DIR1/$tfile-2 $DIR1/$tfile &
2498 stat $DIR2/$tfile > /dev/null &
2500 do_nodes $(comma_list $(mdts_nodes)) \
2501 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2502 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2503 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
2507 run_test 44g "pdirops: rename tgt vs getattr =============="
2511 touch $DIR1/$tfile-2
2512 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2513 do_nodes $(comma_list $(mdts_nodes)) \
2514 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2515 mv $DIR1/$tfile-2 $DIR1/$tfile &
2517 ls -lia $DIR2/ > /dev/null &
2519 do_nodes $(comma_list $(mdts_nodes)) \
2520 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2521 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2526 run_test 44h "pdirops: rename tgt vs readdir =============="
2528 # test 44: rename tgt and blocking operations
2530 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2532 touch $DIR1/$tfile-2
2533 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2534 do_nodes $(comma_list $(mdts_nodes)) \
2535 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2536 mv $DIR1/$tfile-2 $DIR1/$tfile &
2538 $LFS mkdir -i 1 $DIR2/$tfile &
2540 do_nodes $(comma_list $(mdts_nodes)) \
2541 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2542 check_pdo_conflict $PID1 && { wait $PID1;
2543 error "remote mkdir isn't blocked"; }
2544 wait $PID2 ; [ $? -ne 0 ] || error "remote mkdir must fail"
2548 run_test 44i "pdirops: rename tgt vs remote mkdir"
2550 # test 45: rename,mkdir doesn't fail with -EEXIST
2552 for i in {1..1000}; do
2553 mkdir $DIR1/$tdir || error "mkdir $tdir failed"
2554 mrename $DIR2/$tdir $DIR2/$tdir.$i > /dev/null ||
2555 error "mrename to $tdir.$i failed"
2560 run_test 45a "rename,mkdir doesn't return -EEXIST =============="
2565 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2566 do_nodes $(comma_list $(mdts_nodes)) \
2567 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2568 mv $DIR1/$tfile $DIR1/$tfile-2 &
2570 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2572 do_nodes $(comma_list $(mdts_nodes)) \
2573 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2574 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2575 wait $PID2 ; [ $? -eq 0 ] || error "create must succeed"
2579 run_test 45b "pdirops: rename src vs create =============="
2584 touch $DIR1/$tfile-3
2585 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2586 do_nodes $(comma_list $(mdts_nodes)) \
2587 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2588 mv $DIR1/$tfile $DIR1/$tfile-2 &
2590 link $DIR2/$tfile-3 $DIR2/$tfile &
2592 do_nodes $(comma_list $(mdts_nodes)) \
2593 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2594 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2595 wait $PID2 ; [ $? -eq 0 ] || error "link must succeed"
2599 run_test 45c "pdirops: rename src vs link =============="
2604 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2605 do_nodes $(comma_list $(mdts_nodes)) \
2606 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2607 mv $DIR1/$tfile $DIR1/$tfile-2 &
2611 do_nodes $(comma_list $(mdts_nodes)) \
2612 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2613 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2614 wait $PID2 ; [ $? -ne 0 ] || error "unlink must fail"
2618 run_test 45d "pdirops: rename src vs unlink =============="
2623 touch $DIR1/$tfile-3
2624 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2625 do_nodes $(comma_list $(mdts_nodes)) \
2626 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2627 mv $DIR1/$tfile $DIR1/$tfile-2 &
2629 mv $DIR2/$tfile-3 $DIR2/$tfile &
2631 do_nodes $(comma_list $(mdts_nodes)) \
2632 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2633 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2634 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2638 run_test 45e "pdirops: rename src and rename (tgt) =============="
2643 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2644 do_nodes $(comma_list $(mdts_nodes)) \
2645 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2646 mv $DIR1/$tfile $DIR1/$tfile-2 &
2648 mv $DIR2/$tfile $DIR2/$tfile-3 &
2650 do_nodes $(comma_list $(mdts_nodes)) \
2651 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2652 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2653 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
2657 run_test 45f "pdirops: rename src and rename (src) =============="
2662 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2663 do_nodes $(comma_list $(mdts_nodes)) \
2664 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2665 mv $DIR1/$tfile $DIR1/$tfile-2 &
2667 stat $DIR2/$tfile > /dev/null &
2669 do_nodes $(comma_list $(mdts_nodes)) \
2670 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2671 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2672 wait $PID2 ; [ $? -ne 0 ] || error "stat must fail"
2676 run_test 45g "pdirops: rename src vs getattr =============="
2681 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2682 do_nodes $(comma_list $(mdts_nodes)) \
2683 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2684 mv $DIR1/$tfile $DIR1/$tfile-2 &
2686 ls -lia $DIR2/ > /dev/null &
2687 do_nodes $(comma_list $(mdts_nodes)) \
2688 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2689 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2694 run_test 45h "pdirops: unlink vs readdir =============="
2697 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2700 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2701 do_nodes $(comma_list $(mdts_nodes)) \
2702 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2703 mv $DIR1/$tfile $DIR1/$tfile-2 &
2705 $LFS mkdir -i 1 $DIR2/$tfile &
2707 do_nodes $(comma_list $(mdts_nodes)) \
2708 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2709 check_pdo_conflict $PID1 && { wait $PID1;
2710 error "create remote dir isn't blocked"; }
2711 wait $PID2 ; [ $? -eq 0 ] || error "create remote dir must succeed"
2715 run_test 45i "pdirops: rename src vs remote mkdir"
2722 # We test in a sparate directory to be able to unblock server thread in
2723 # cfs_race if LCK_PW is taken on the parent by mdt_reint_rename.
2724 test_mkdir $DIR2/$tdir
2725 echo file1 > $DIR2/$tdir/$tfile
2726 echo file2 > $DIR2/$tdir/$tfile-2
2729 do_nodes $(comma_list $(mdts_nodes)) \
2730 "lctl set_param -n fail_loc=${fail_loc} || true" &>/dev/null
2732 cat $DIR1/$tdir/$tfile >/dev/null &
2735 mrename $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile > /dev/null &
2739 { ret=$?; echo -n "cat $tfile should succeed (err=$ret); "; }
2742 echo -n "mrename $tfile-2 to $tfile failed (err=$ret);"; }
2745 do_nodes $(comma_list $(mdts_nodes)) \
2746 "lctl set_param -n fail_loc=0x0 || true" &>/dev/null
2753 (( $MDS1_VERSION >= $(version_code 2.13.56) )) ||
2754 skip "Need MDS version newer than 2.13.56"
2757 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN 0x169
2758 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN2 0x16a
2759 for fail_loc in "0x80000169" "0x8000016a"; do
2760 echo "Begin 100 tests with fail_loc=$fail_loc"
2762 for i in {1..100}; do
2764 msg=$(sub_test_45j "$fail_loc") ||
2765 { echo; error "iter=$i : $msg"; }
2770 run_test 45j "read vs rename =============="
2772 # test 46: link and blocking operations
2775 touch $DIR1/$tfile-2
2776 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2777 do_nodes $(comma_list $(mdts_nodes)) \
2778 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2779 link $DIR1/$tfile-2 $DIR1/$tfile &
2781 mkdir $DIR2/$tfile &
2783 do_nodes $(comma_list $(mdts_nodes)) \
2784 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2785 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2786 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
2790 run_test 46a "pdirops: link vs mkdir =============="
2794 touch $DIR1/$tfile-2
2795 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2796 do_nodes $(comma_list $(mdts_nodes)) \
2797 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2798 link $DIR1/$tfile-2 $DIR1/$tfile &
2800 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2802 do_nodes $(comma_list $(mdts_nodes)) \
2803 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2804 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2805 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
2809 run_test 46b "pdirops: link vs create =============="
2813 touch $DIR1/$tfile-2
2814 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2815 do_nodes $(comma_list $(mdts_nodes)) \
2816 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2817 link $DIR1/$tfile-2 $DIR1/$tfile &
2819 link $DIR2/$tfile $DIR2/$tfile &
2821 do_nodes $(comma_list $(mdts_nodes)) \
2822 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2823 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2824 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
2828 run_test 46c "pdirops: link vs link =============="
2832 touch $DIR1/$tfile-2
2833 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2834 do_nodes $(comma_list $(mdts_nodes)) \
2835 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2836 link $DIR1/$tfile-2 $DIR1/$tfile &
2840 do_nodes $(comma_list $(mdts_nodes)) \
2841 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2842 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2843 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
2847 run_test 46d "pdirops: link vs unlink =============="
2851 touch $DIR1/$tfile-2
2852 touch $DIR1/$tfile-3
2853 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2854 do_nodes $(comma_list $(mdts_nodes)) \
2855 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2856 link $DIR1/$tfile-2 $DIR1/$tfile &
2858 mv $DIR2/$tfile-3 $DIR2/$tfile &
2860 do_nodes $(comma_list $(mdts_nodes)) \
2861 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2862 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2863 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2867 run_test 46e "pdirops: link and rename (tgt) =============="
2871 touch $DIR1/$tfile-2
2872 touch $DIR1/$tfile-3
2873 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2874 do_nodes $(comma_list $(mdts_nodes)) \
2875 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2876 link $DIR1/$tfile-2 $DIR1/$tfile &
2878 mv $DIR2/$tfile $DIR2/$tfile-3 &
2880 do_nodes $(comma_list $(mdts_nodes)) \
2881 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2882 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2883 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2887 run_test 46f "pdirops: link and rename (src) =============="
2891 touch $DIR1/$tfile-2
2892 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2893 do_nodes $(comma_list $(mdts_nodes)) \
2894 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2895 link $DIR1/$tfile-2 $DIR1/$tfile &
2897 stat $DIR2/$tfile > /dev/null &
2899 do_nodes $(comma_list $(mdts_nodes)) \
2900 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2901 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2902 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
2906 run_test 46g "pdirops: link vs getattr =============="
2910 touch $DIR1/$tfile-2
2911 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2912 do_nodes $(comma_list $(mdts_nodes)) \
2913 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2914 link $DIR1/$tfile-2 $DIR1/$tfile &
2916 ls -lia $DIR2/ > /dev/null &
2918 do_nodes $(comma_list $(mdts_nodes)) \
2919 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2920 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2925 run_test 46h "pdirops: link vs readdir =============="
2928 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2930 touch $DIR1/$tfile-2
2931 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2932 do_nodes $(comma_list $(mdts_nodes)) \
2933 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2934 link $DIR1/$tfile-2 $DIR1/$tfile &
2936 $LFS mkdir -i 1 $DIR2/$tfile &
2938 do_nodes $(comma_list $(mdts_nodes)) \
2939 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2940 check_pdo_conflict $PID1 && { wait $PID1;
2941 error "remote mkdir isn't blocked"; }
2942 wait $PID2 ; [ $? -ne 0 ] || error "remote mkdir must fail"
2946 run_test 46i "pdirops: link vs remote mkdir"
2948 # test 47: remote mkdir and blocking operations
2950 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2951 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2953 do_nodes $(comma_list $(mdts_nodes)) \
2954 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2955 $LFS mkdir -i 1 $DIR1/$tfile &
2957 mkdir $DIR2/$tfile &
2959 do_nodes $(comma_list $(mdts_nodes)) \
2960 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2961 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2962 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
2966 run_test 47a "pdirops: remote mkdir vs mkdir"
2969 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2970 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2972 do_nodes $(comma_list $(mdts_nodes)) \
2973 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2974 $LFS mkdir -i 1 $DIR1/$tfile &
2976 sleep 1 # please do not remove this sleep, see LU-10754
2977 multiop $DIR2/$tfile oO_CREAT:O_EXCL:c &
2979 do_nodes $(comma_list $(mdts_nodes)) \
2980 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2981 check_pdo_conflict $PID1 && { wait $PID1;
2982 error "create isn't blocked"; }
2983 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
2987 run_test 47b "pdirops: remote mkdir vs create"
2990 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2992 touch $DIR1/$tfile-2
2993 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2994 do_nodes $(comma_list $(mdts_nodes)) \
2995 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2996 $LFS mkdir -i 1 $DIR1/$tfile &
2998 link $DIR2/$tfile-2 $DIR2/$tfile &
3000 do_nodes $(comma_list $(mdts_nodes)) \
3001 "lctl set_param -n fail_loc=0 2>/dev/null || true"
3002 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
3003 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
3007 run_test 47c "pdirops: remote mkdir vs link"
3010 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3012 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
3013 do_nodes $(comma_list $(mdts_nodes)) \
3014 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
3015 $LFS mkdir -i 1 $DIR1/$tfile &
3017 rmdir $DIR2/$tfile &
3019 do_nodes $(comma_list $(mdts_nodes)) \
3020 "lctl set_param -n fail_loc=0 2>/dev/null || true"
3021 check_pdo_conflict $PID1 && { wait $PID1;
3022 error "unlink isn't blocked"; }
3023 wait $PID2 ; [ $? -eq 0 ] || error "rmdir must succeed"
3027 run_test 47d "pdirops: remote mkdir vs unlink"
3030 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3032 touch $DIR1/$tfile-2
3033 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
3034 do_nodes $(comma_list $(mdts_nodes)) \
3035 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
3036 $LFS mkdir -i 1 $DIR1/$tfile &
3038 mv -T $DIR2/$tfile-2 $DIR2/$tfile &
3040 do_nodes $(comma_list $(mdts_nodes)) \
3041 "lctl set_param -n fail_loc=0 2>/dev/null || true"
3042 check_pdo_conflict $PID1 && { wait $PID1;
3043 error "rename isn't blocked"; }
3044 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
3048 run_test 47e "pdirops: remote mkdir and rename (tgt)"
3051 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3053 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
3054 do_nodes $(comma_list $(mdts_nodes)) \
3055 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
3056 $LFS mkdir -i 1 $DIR1/$tfile &
3058 mv $DIR2/$tfile $DIR2/$tfile-2 &
3060 do_nodes $(comma_list $(mdts_nodes)) \
3061 "lctl set_param -n fail_loc=0 2>/dev/null || true"
3062 check_pdo_conflict $PID1 && { wait $PID1;
3063 error "rename isn't blocked"; }
3064 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
3068 run_test 47f "pdirops: remote mkdir and rename (src)"
3071 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3075 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
3076 do_nodes $(comma_list $(mdts_nodes)) \
3077 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
3078 $LFS mkdir -i 1 $DIR1/$tfile &
3080 stat $DIR2/$tfile > /dev/null &
3082 do_nodes $(comma_list $(mdts_nodes)) \
3083 "lctl set_param -n fail_loc=0 2>/dev/null || true"
3084 check_pdo_conflict $PID1 && { wait $PID1;
3085 error "getattr isn't blocked"; }
3086 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
3090 run_test 47g "pdirops: remote mkdir vs getattr"
3094 dd if=/dev/zero of=$DIR1/$tfile bs=1K count=10
3095 #define OBD_FAIL_OSC_CP_ENQ_RACE 0x410
3096 do_facet client "lctl set_param fail_loc=0x410"
3097 $TRUNCATE $DIR2/$tfile $trunc_size
3098 do_facet client "lctl set_param fail_loc=0x0"
3100 size=`stat -c %s $DIR2/$tfile`
3101 [ $size -eq $trunc_size ] || error "wrong size"
3103 run_test 50 "osc lvb attrs: enqueue vs. CP AST =============="
3107 local origfile=/etc/hosts
3109 filesize=$(stat -c %s $origfile)
3111 # create an empty file
3112 $MCREATE $DIR1/$tfile || error "can't create $DIR1/$tfile"
3113 # cache layout lock on both mount point
3114 stat $DIR1/$tfile > /dev/null || error "stat $DIR1/$tfile failed"
3115 stat $DIR2/$tfile > /dev/null || error "stat $DIR2/$tfile failed"
3117 # open and sleep 2 seconds then read
3118 $MULTIOP $DIR2/$tfile o_2r${filesize}c &
3122 # create the layout of testing file
3123 dd if=$origfile of=$DIR1/$tfile conv=notrunc > /dev/null ||
3124 error "dd $DIR1/$tfile failed"
3126 # MULTIOP proc should be able to read enough bytes and exit
3127 for ((i = 0; i < 6; i++)); do
3129 kill -0 $pid || break
3131 kill -0 $pid 2> /dev/null && error "multiop is still there"
3132 cmp $origfile $DIR2/$tfile || error "$origfile and $DIR2/$tfile differs"
3136 run_test 51a "layout lock: refresh layout should work"
3139 (( $MDS1_VERSION >= $(version_code 2.3.59) )) ||
3140 skip "Need MDS version at least 2.3.59"
3142 local tmpfile=`mktemp`
3144 $LFS setstripe -E 1m -S 1M -c 1 -E -1 -c 1 $DIR1/$tfile ||
3145 error "Create $DIR1/$tfile failed"
3147 dd if=/dev/zero of=$DIR1/$tfile bs=1k count=1 conv=notrunc ||
3148 error "dd $DIR1/$tfile failed"
3150 # delay glimpse so that layout has changed when glimpse finish
3151 #define OBD_FAIL_GLIMPSE_DELAY 0x1404
3152 $LCTL set_param fail_loc=0x1404 fail_val=4
3153 stat -c %s $DIR2/$tfile |tee $tmpfile &
3157 # extend layout of testing file
3158 dd if=/dev/zero of=$DIR1/$tfile bs=1M count=1 seek=2 conv=notrunc ||
3159 error "dd $DIR1/$tfile failed"
3162 local fsize=$(cat $tmpfile)
3164 [ x$fsize = x3145728 ] || error "file size is $fsize, should be 3145728"
3166 rm -f $DIR1/$tfile $tmpfile
3168 run_test 51b "layout lock: glimpse should be able to restart if layout changed"
3171 [ $OSTCOUNT -ge 2 ] || { skip "needs >= 2 osts"; return; }
3173 # set default layout to have 1 stripe
3175 $LFS setstripe -c 1 $DIR1/$tdir
3177 # create a file with empty layout
3178 $MCREATE $DIR1/$tdir/$tfile ||
3179 error "$MCREATE $DIR1/$tdir/$tfile failed"
3181 #define OBD_FAIL_MDS_LL_BLOCK 0x172
3182 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x172
3184 # change the layout of testing file
3185 echo "Setting layout to have $OSTCOUNT stripes ..."
3186 $LFS setstripe -c $OSTCOUNT $DIR1/$tdir/$tfile &
3190 # write something to the file, it should be blocked on fetching layout
3191 dd if=/dev/zero of=$DIR2/$tdir/$tfile bs=1k count=1 conv=notrunc
3192 local stripe_count=$($LFS getstripe -c $DIR2/$tdir/$tfile)
3195 # lod_qos.c::min_stripe_count() allows setstripe with a default stripe
3196 # count to succeed with only 3/4 of the number of stripes (rounded up),
3197 # so creating striped files does not fail if an OST is offline or full
3198 [ $stripe_count -ge $((OSTCOUNT - $OSTCOUNT / 4)) ] ||
3199 error "bad layout: getstripe -c $stripe_count < $OSTCOUNT * 3/4"
3203 run_test 51c "layout lock: IT_LAYOUT blocked and correct layout can be returned"
3206 dd if=/dev/zero of=/$DIR1/$tfile bs=1M count=1
3207 cancel_lru_locks mdc
3209 # open should grant LAYOUT lock, mmap and read will install pages
3210 $MULTIOP $DIR1/$tfile oO_RDWR:SMR_Uc &
3214 # rss before revoking
3215 local br=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
3216 echo "Before revoking layout lock: $br KB mapped"
3218 # cancel layout lock manually
3219 cancel_lru_locks mdc
3221 # rss after revoking
3222 local ar=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
3225 wait $PID || error "wait PID $PID failed"
3227 [ $ar -eq 0 ] || error "rss before: $br, after $ar, some pages remained"
3229 run_test 51d "layout lock: losing layout lock should clean up memory map region"
3232 (( $MDS1_VERSION >= $(version_code 2.13.54.148) )) ||
3233 skip "MDS version must be at least 2.13.54.148"
3237 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eW_E+eUc &
3241 $LFS getstripe $DIR2/$tfile
3243 wait $pid || error "multiop failed"
3245 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
3249 $LFS getstripe $DIR2/$tfile
3251 wait $pid || error "multiop failed"
3253 run_test 51e "lfs getstripe does not break leases, part 2"
3257 echo "==> rename vs getattr vs setxattr should not deadlock"
3258 mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed"
3260 do_facet mds1 $LCTL set_param fail_loc=$1
3262 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 &
3270 setfattr -n user.attr1 -v value1 $DIR2/d1 || error "(2) setfattr failed"
3271 wait $PID1 || error "(3) mv failed"
3272 wait $PID2 || error "(4) stat failed"
3279 echo "==> rename vs getattr vs open vs getattr should not deadlock"
3280 mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed"
3282 do_facet mds1 $LCTL set_param fail_loc=$1
3284 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 &
3292 $MULTIOP $DIR2/d1/d2 Oc &
3296 stat $DIR/d1 || error "(2) stat failed"
3298 wait $PID1 || error "(3) mv failed"
3299 wait $PID2 || error "(4) stat failed"
3300 wait $PID3 && error "(5) multiop failed"
3306 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
3307 save_lustre_params client "llite.*.xattr_cache" > $p
3308 lctl set_param llite.*.xattr_cache 1 ||
3309 { skip "xattr cache is not supported"; return 0; }
3311 #define OBD_FAIL_MDS_RENAME 0x153
3312 #define OBD_FAIL_MDS_RENAME2 0x154
3313 test_54_part1 0x80000153 || error 10
3314 test_54_part1 0x80000154 || error 11
3315 test_54_part2 0x80000153 || error 12
3316 test_54_part2 0x80000154 || error 13
3318 restore_lustre_params < $p
3321 run_test 54 "rename locking"
3324 mkdir_on_mdt0 $DIR/$tdir
3325 mkdir -p $DIR/$tdir/d1/d2 $DIR/$tdir/d3 || error "(1) mkdir failed"
3327 #define OBD_FAIL_MDS_RENAME4 0x156
3328 do_facet mds1 $LCTL set_param fail_loc=0x80000156
3330 mv -T $DIR/$tdir/d1/d2 $DIR/$tdir/d3/d2 &
3334 rm -r $DIR2/$tdir/d3
3335 wait $PID1 && error "(2) mv succeeded"
3339 run_test 55a "rename vs unlink target dir"
3343 mkdir_on_mdt0 $DIR/$tdir
3344 mkdir -p $DIR/$tdir/d1/d2 $DIR/$tdir/d3 || error "(1) mkdir failed"
3346 #define OBD_FAIL_MDS_RENAME4 0x156
3347 do_facet mds1 $LCTL set_param fail_loc=0x80000156
3349 mv -T $DIR/$tdir/d1/d2 $DIR/$tdir/d3/d2 &
3353 rm -r $DIR2/$tdir/d1
3354 wait $PID1 && error "(2) mv succeeded"
3358 run_test 55b "rename vs unlink source dir"
3362 mkdir_on_mdt0 $DIR/$tdir
3363 mkdir -p $DIR/$tdir/d1/d2 $DIR/$tdir/d3 || error "(1) mkdir failed"
3365 #define OBD_FAIL_MDS_RENAME4 0x156
3366 do_facet mds1 $LCTL set_param fail_loc=0x156
3368 mv -T $DIR/$tdir/d1/d2 $DIR/$tdir/d3/d2 &
3372 # while rename is sleeping, open and remove d3
3373 $MULTIOP $DIR2/$tdir/d3 D_c &
3376 rm -rf $DIR2/$tdir/d3
3379 # while rename is sleeping 2nd time, close d3
3381 wait $PID2 || error "(3) multiop failed"
3383 wait $PID1 && error "(2) mv succeeded"
3387 run_test 55c "rename vs unlink orphan target dir"
3391 mkdir_on_mdt0 $DIR/$tdir
3395 #define OBD_FAIL_MDS_RENAME3 0x155
3396 do_facet mds1 $LCTL set_param fail_loc=0x155
3397 mv $DIR/$tdir/f1 $DIR/$tdir/$tdir &
3401 # while rename is sleeping, create $tdir, but as a directory
3402 mkdir -p $DIR2/$tdir/$tdir || error "(1) mkdir failed"
3404 # link in reverse locking order
3405 ln $DIR2/$tdir/f1 $DIR2/$tdir/$tdir/
3407 wait $PID1 && error "(2) mv succeeded"
3410 run_test 55d "rename file vs link"
3413 $LFS setstripe -c 1 $MOUNT/$tfile || error "creating $MOUNT/$tfile"
3414 stack_trap "rm -f $MOUNT/$tfile"
3415 echo "run_llverdev $MOUNT/$tfile -p -s $((16000000)) -c 4k"
3416 run_llverdev $MOUNT/$tfile -p -s $((16000000)) -c 4k ||
3417 error "llverdev failed with rc=$?"
3419 run_test 56a "test llverdev with single large stripe"
3422 $LFS setstripe -C 2000 $MOUNT/$tfile || error "creating $MOUNT/$tfile"
3423 stack_trap "rm -f $MOUNT/$tfile"
3424 echo "run_llverdev $MOUNT/$tfile -p -s $((16000000 * OSTCOUNT)) -c 4k"
3425 run_llverdev $MOUNT/$tfile -p -s $((16000000 * OSTCOUNT)) -c 4k ||
3426 error "llverdev failed with rc=$?"
3428 run_test 56b "test llverdev and partial verify of wide stripe file"
3431 [ $MDS1_VERSION -lt $(version_code 2.3.0) ] &&
3432 skip "MDS version must be >= 2.3.0"
3435 test_mkdir $DIR1/$tdir
3436 file1=$DIR1/$tdir/file
3437 file2=$DIR2/$tdir/file
3439 echo orig > $file2 || error "Could not create $file2"
3440 version=$($LFS data_version $file1)
3443 echo append >> $file2 || error "Could not append to $file2"
3444 version2=$($LFS data_version $file1)
3445 [ "$version" != "$version2" ] ||
3446 error "append did not change data version: $version"
3449 echo overwrite > $file2 || error "Could not overwrite $file2"
3450 version3=$($LFS data_version $file1)
3451 [ "$version2" != "$version3" ] ||
3452 error "overwrite did not change data version: $version2"
3454 # Truncate before EOF
3455 $TRUNCATE $file2 3 || error "Could not truncate $file2"
3456 version4=$($LFS data_version $file1)
3457 [ "$version3" != "$version4" ] ||
3458 error "truncate did not change data version: $version3"
3460 # Truncate after EOF
3461 $TRUNCATE $file2 123456 || error "Could not truncate $file2"
3462 version5=$($LFS data_version $file1)
3463 [ "$version4" != "$version5" ] ||
3464 error "truncate did not change data version: $version4"
3466 # Chmod do not change version
3467 chmod 400 $file2 || error "Could not chmod 400 $file2"
3468 version6=$($LFS data_version $file1)
3469 [ "$version5" == "$version6" ] ||
3470 error "chmod should not change data version: $version5 != $version6"
3472 # Chown do not change version
3473 chown $RUNAS_ID $file2 || error "Could not chown $RUNAS_ID $file2"
3474 version7=$($LFS data_version $file1)
3475 [ "$version5" == "$version7" ] ||
3476 error "chown should not change data version: $version5 != $version7"
3478 run_test 60 "Verify data_version behaviour"
3481 local test_dir=$tdir/test_dir
3483 mkdir -p $DIR1/$tdir
3484 if [ $MDSCOUNT -ge 2 ]; then
3486 $LFS mkdir -i $MDTIDX $DIR1/$test_dir ||
3487 error "Create remote directory failed"
3489 mkdir -p $DIR1/$test_dir
3491 cd $DIR2/$test_dir || error "cd directory failed"
3492 rm -rf $DIR1/$test_dir || error "unlink directory failed"
3494 cd $DIR2/$tdir || error "exit directory"
3496 run_test 70a "cd directory && rm directory"
3498 test_70b() { # LU-2781
3500 mkdir -p $DIR1/$tdir
3502 touch $DIR1/$tdir/file
3503 for ((i = 0; i < 32; i++)); do
3504 $LFS rm_entry $DIR1/$tdir/non_existent_dir &>/dev/null
3506 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
3508 touch $DIR1/$tdir/file
3509 $LFS mkdir -i0 $DIR1/$tdir/test_dir
3510 $LFS rm_entry $DIR1/$tdir/test_dir &>/dev/null
3511 rm -rf $DIR1/$tdir/test_dir ||
3512 error "cannot remove directory after rm_entry"
3513 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
3515 run_test 70b "remove files after calling rm_entry"
3518 [[ "$MDS1_VERSION" -lt $(version_code 2.1.6) ]] &&
3519 skip "Need MDS version at least 2.1.6"
3521 # Patch not applied to 2.2 and 2.3 branches
3522 [[ "$MDS1_VERSION" -ge $(version_code 2.2.0) ]] &&
3523 [[ "$MDS1_VERSION" -lt $(version_code 2.4.0) ]] &&
3524 skip "Need MDS version earlier than 2.2.0 or at least 2.4.0"
3526 checkfiemap --test ||
3527 skip "checkfiemap not runnable: $?"
3528 # write data this way: hole - data - hole - data
3529 dd if=/dev/urandom of=$DIR1/$tfile bs=64K seek=1 count=1
3530 [ "$(facet_fstype ost$(($($LFS getstripe -i $DIR1/$tfile) + 1)))" = \
3532 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return 0
3533 dd if=/dev/urandom of=$DIR1/$tfile bs=64K seek=3 count=1
3534 GET_STAT="lctl get_param -n ldlm.services.ldlm_cbd.stats"
3536 local can1=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3538 checkfiemap $DIR2/$tfile 131072 ||
3539 error "data is not flushed from client"
3540 local can2=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3543 # common case of "create file, copy file" on a single node
3544 # should not flush data from ost
3545 dd if=/dev/urandom of=$DIR1/$tfile bs=64K seek=1 count=1
3546 dd if=/dev/urandom of=$DIR1/$tfile bs=64K seek=3 count=1
3548 local can3=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3550 checkfiemap $DIR1/$tfile 131072 ||
3552 local can4=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3554 [ $can3 -eq $can4 ] || error $((can2-can1)) "cancel RPC occured."
3556 run_test 71a "correct file map just after write operation is finished"
3559 [[ "$MDS1_VERSION" -lt $(version_code 2.1.6) ]] &&
3560 skip "Need MDS version at least 2.1.6"
3562 # Patch not applied to 2.2 and 2.3 branches
3563 [[ "$MDS1_VERSION" -ge $(version_code 2.2.0) ]] &&
3564 [[ "$MDS1_VERSION" -lt $(version_code 2.4.0) ]] &&
3565 skip "Need MDS version earlier than 2.2.0 or at least 2.4.0"
3566 [[ $OSTCOUNT -ge 2 ]] || skip "needs >= 2 OSTs"
3568 checkfiemap --test ||
3569 skip "error $?: checkfiemap failed"
3571 mkdir -p $DIR1/$tdir
3573 $LFS setstripe -c -1 $DIR1/$tdir || error "setstripe failed"
3574 dd if=/dev/urandom of=$DIR1/$tdir/$tfile bs=64K count=1
3575 [ "$(facet_fstype ost$(($($LFS getstripe -i $DIR1/$tdir/$tfile) + 1)))" = \
3577 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return 0
3578 checkfiemap $DIR1/$tdir/$tfile 65536 || error "checkfiemap failed"
3580 run_test 71b "check fiemap support for stripecount > 1"
3583 local p="$TMP/sanityN-$TESTNAME.parameters"
3586 save_lustre_params client "llite.*.xattr_cache" > $p
3587 lctl set_param llite.*.xattr_cache 1 ||
3588 { skip "xattr cache is not supported"; return 0; }
3591 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
3592 error "setfattr1 failed"
3593 getfattr -n user.attr1 $DIR2/$tfile | grep value1 ||
3594 error "getfattr1 failed"
3595 setfattr -n user.attr1 -v value2 $DIR2/$tfile ||
3596 error "setfattr2 failed"
3597 getfattr -n user.attr1 $DIR1/$tfile | grep value2 ||
3598 error "getfattr2 failed"
3600 # check that trusted.link is consistent
3601 tlink1=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
3602 ln $DIR2/$tfile $DIR2/$tfile-2 || error "failed to link"
3603 tlink2=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
3604 echo "$tlink1 $tlink2"
3605 [ "$tlink1" = "$tlink2" ] && error "trusted.link should have changed!"
3609 restore_lustre_params < $p
3612 run_test 72 "getxattr/setxattr cache should be consistent between nodes"
3615 local p="$TMP/sanityN-$TESTNAME.parameters"
3616 save_lustre_params client "llite.*.xattr_cache" > $p
3617 lctl set_param llite.*.xattr_cache 1 ||
3618 { skip "xattr cache is not supported"; return 0; }
3621 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
3622 error "setfattr1 failed"
3623 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr1 failed"
3624 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr2 failed"
3625 clear_stats llite.*.stats
3626 # PR lock should be cached by now on both clients
3627 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr3 failed"
3628 # 2 hits for getfattr(0)+getfattr(size)
3629 [ $(calc_stats llite.*.stats getxattr_hits) -eq 2 ] ||
3630 error "not cached in $DIR1"
3631 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr4 failed"
3632 # 4 hits for more getfattr(0)+getfattr(size)
3633 [ $(calc_stats llite.*.stats getxattr_hits) -eq 4 ] ||
3634 error "not cached in $DIR2"
3637 restore_lustre_params < $p
3640 run_test 73 "getxattr should not cause xattr lock cancellation"
3643 [ "$MDS1_VERSION" -lt $(version_code 2.4.93) ] &&
3644 skip "Need MDS version at least 2.4.93"
3646 dd if=/dev/zero of=$DIR1/$tfile-1 bs=1K count=1
3647 dd if=/dev/zero of=$DIR1/$tfile-2 bs=1K count=1
3648 flocks_test 4 $DIR1/$tfile-1 $DIR2/$tfile-2
3650 run_test 74 "flock deadlock: different mounts =============="
3654 $LFS setstripe -c 2 -S 1m -i 0 $DIR1/$tfile
3655 dd if=/dev/zero of=$DIR1/$tfile bs=1M count=2
3656 cancel_lru_locks osc
3658 dd of=$DIR1/$tfile if=/dev/zero bs=1M count=1 seek=1 conv=notrunc
3661 # define OBD_FAIL_LDLM_ENQUEUE_HANG 0x31d
3662 $LCTL set_param fail_loc=0x31d
3663 stat -c %s $DIR1/$tfile &
3668 # For bad lock error handler we should ASSERT and got kernel panic here
3670 $LCTL set_param fail_loc=0
3672 run_test 75 "osc: upcall after unuse lock==================="
3675 [[ "$MDS1_VERSION" -lt $(version_code 2.5.53) ]] &&
3676 skip "Need MDS version at least 2.5.53"
3678 remote_mds_nodsh && skip "remote MDS with nodsh"
3679 local fcount=$((MDSCOUNT * 256))
3684 nid=$($LCTL list_nids | sed "s/\./\\\./g")
3690 test_mkdir $DIR/$tdir
3692 # drop all open locks and close any cached "open" files on the client
3693 cancel_lru_locks mdc
3695 local open_fids_cmd="$LCTL get_param -n mdt.*.exports.'$nid'.open_files"
3696 local fid_list=($(do_nodes $(comma_list $(mdts_nodes)) $open_fids_cmd))
3697 local already=${#fid_list[@]}
3698 for (( i = 0; i < $already; i++ )) ; do
3699 log "already open[$i]: $($LFS fid2path $DIR2 ${fid_list[i]})"
3702 echo -n "opening files: "
3703 ulimit -n $((fcount + 50))
3704 for ((i = 0; i < $fcount; i++)); do
3705 touch $DIR/$tdir/f_$i
3706 local fd=$(free_fd ${fd_list[i]})
3707 local open_cmd="exec $fd<$DIR/$tdir/f_$i"
3712 (( $i % 32 == 0 )) && echo -n "."
3716 fid_list=($(do_nodes $(comma_list $(mdts_nodes)) $open_fids_cmd))
3718 # Possible errors in openfiles FID list.
3719 # 1. Missing FIDs. Check 1
3720 # 2. Extra FIDs. Check 1
3721 # 3. Duplicated FID. Check 2
3722 # 4. Invalid FIDs. Check 2
3723 # 5. Valid FID, points to some other file. Check 3
3726 [ ${#fid_list[@]} -ne $((fcount + already)) ] &&
3727 error "${#fid_list[@]} != $fcount (+$already old) open files"
3729 echo -n "closing files: "
3730 for (( fd = 0, fid = 0; fd < $fcount; fd++, fid++ )) ; do
3731 local close_cmd="exec ${fd_list[fd]}<&-"
3733 filename=$($LFS fid2path $DIR2 ${fid_list[fid]})
3735 while [[ ! "$filename" =~ "$DIR2/$tdir/f_" ]]; do
3736 echo "skip old open file $filename"
3738 filename=$($LFS fid2path $DIR2 ${fid_list[fid]})
3742 rm --interactive=no $filename
3744 error "Nonexisting fid ${fid_list[fid]} listed."
3745 (( $fd % 32 == 0 )) && echo -n "."
3750 ls_op=$(ls $DIR2/$tdir | wc -l)
3752 error "Some openfiles are missing in lproc output"
3756 run_test 76 "Verify MDT open_files listing"
3760 local dir=$DIR/$tdir
3763 mkdir $dir || error "mkdir $dir failed"
3764 $LFS setstripe -c $OSTCOUNT $dir || error "setstripe to $dir failed"
3767 do_nodes $CLIENTS $myRUNAS \
3768 dd if=/dev/zero of="$dir/nrs_r_\$HOSTNAME" bs=1M count=$n ||
3769 error "dd at 0 on client failed (1)"
3771 do_nodes $CLIENTS $myRUNAS \
3773 for ((i = 0; i < $n; i++)); do
3774 dd if=/dev/zero of=$dir/nrs_w_\$HOSTNAME bs=1M \
3775 seek=\\\$i count=1 conv=notrunc &
3776 pids_w[\\\$i]=\\\$!;
3779 for ((i = 0; i < $n; i++)); do
3780 wait \\\${pids_w[\\\$i]};
3782 [ \\\$newrc -gt \\\$rc_w ] && rc_w=\\\$newrc;
3786 do_nodes $CLIENTS sync;
3787 cancel_lru_locks osc
3789 do_nodes $CLIENTS $myRUNAS \
3791 for ((i = 0; i < $n; i++)); do
3792 dd if=$dir/nrs_r_\$HOSTNAME bs=1M of=/dev/null \
3793 seek=\\\$i count=1 &
3794 pids_r[\\\$i]=\\\$!;
3797 for ((i = 0; i < $n; i++)); do
3798 wait \\\${pids_r[\\\$i]};
3800 [ \\\$newrc -gt \\\$rc_r ] && rc_r=\\\$newrc;
3804 cancel_lru_locks osc
3806 wait $pid_w || error "dd (write) failed (2)"
3807 wait $pid_r || error "dd (read) failed (3)"
3808 rm -rvf $dir || error "rm -rf $dir failed"
3811 test_77a() { #LU-3266
3814 oss=$(comma_list $(osts_nodes))
3815 do_nodes $oss lctl set_param ost.OSS.*.nrs_policies="fifo" ||
3817 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3818 [[ $rc -ne 0 ]] && error "failed to set fifo policy"
3823 run_test 77a "check FIFO NRS policy"
3825 test_77b() { #LU-3266
3828 oss=$(comma_list $(osts_nodes))
3830 do_nodes $oss lctl set_param ost.OSS.*.nrs_policies="crrn" \
3831 ost.OSS.*.nrs_crrn_quantum=1 || rc=$?
3832 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3833 [[ $rc -ne 0 ]] && error "failed to set crrn_quantum to 1"
3835 echo "policy: crr-n, crrn_quantum 1"
3838 do_nodes $oss lctl set_param \
3839 ost.OSS.*.nrs_crrn_quantum=64 || rc=$?
3840 [[ $rc -ne 0 ]] && error "failed to set crrn_quantum to 64"
3842 echo "policy: crr-n, crrn_quantum 64"
3846 do_nodes $oss lctl set_param \
3847 ost.OSS.ost_io.nrs_policies="fifo" || rc=$?
3848 [[ $rc -ne 0 ]] && error "failed to set fifo policy"
3851 run_test 77b "check CRR-N NRS policy"
3856 oss=$(comma_list $(osts_nodes))
3858 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies=$policy \
3859 ost.OSS.*.nrs_"$policy"_quantum=1 \
3860 ost.OSS.*.nrs_"$policy"_offset_type="physical" \
3861 ost.OSS.*.nrs_"$policy"_supported="reads" || return $?
3863 echo "policy: $policy, ${policy}_quantum 1, ${policy}_offset_type " \
3864 "physical, ${policy}_supported reads"
3867 do_nodes $oss lctl set_param \
3868 ost.OSS.*.nrs_${policy}_supported="writes" \
3869 ost.OSS.*.nrs_${policy}_quantum=64 || return $?
3871 echo "policy: $policy, ${policy}_quantum 64, ${policy}_offset_type " \
3872 "physical, ${policy}_supported writes"
3875 do_nodes $oss lctl set_param \
3876 ost.OSS.*.nrs_${policy}_supported="reads_and_writes" \
3877 ost.OSS.*.nrs_${policy}_offset_type="logical" || return $?
3878 echo "policy: $policy, ${policy}_quantum 64, ${policy}_offset_type " \
3879 "logical, ${policy}_supported reads_and_writes"
3883 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo" ||
3888 test_77c() { #LU-3266
3890 orr_trr "orr" || rc=$?
3891 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3892 [[ $rc -ne 0 ]] && error "orr_trr failed rc:$rc"
3895 run_test 77c "check ORR NRS policy"
3897 test_77d() { #LU-3266
3899 orr_trr "trr" || rc=$?
3900 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3901 [[ $rc -ne 0 ]] && error "orr_trr failed rc:$rc"
3904 run_test 77d "check TRR nrs policy"
3911 do_facet $facet lctl set_param \
3912 ost.OSS.ost_io.nrs_tbf_rule="$*"
3914 error "failed to run operate '$*' on TBF rules"
3917 cleanup_tbf_verify()
3921 echo "cleanup_tbf $DIR/$tdir"
3924 wait_delete_completed
3929 local dir=$DIR/$tdir
3930 local client1=${CLIENT1:-$(hostname)}
3933 local np=$(check_cpt_number ost1)
3934 [ $np -gt 0 ] || error "CPU partitions should not be $np."
3935 echo "cpu_npartitions on ost1 is $np"
3937 mkdir $dir || error "mkdir $dir failed"
3938 $LFS setstripe -c 1 -i 0 $dir || error "setstripe to $dir failed"
3941 trap cleanup_tbf_verify EXIT
3942 echo "Limited write rate: $1, read rate: $2"
3943 echo "Verify the write rate is under TBF control"
3944 local start=$SECONDS
3945 do_node $client1 $myRUNAS dd if=/dev/zero of=$dir/tbf \
3946 bs=1M count=100 oflag=direct 2>&1
3947 local runtime=$((SECONDS - start + 1))
3948 local rate=$(bc <<< "scale=6; 100 / $runtime")
3949 echo "Write runtime is $runtime s, speed is $rate IOPS"
3951 # verify the write rate does not exceed TBF rate limit
3952 [ $(bc <<< "$rate < 1.1 * $np * $1") -eq 1 ] ||
3953 error "The write rate ($rate) exceeds 110% of rate limit ($1 * $np)"
3955 cancel_lru_locks osc
3957 echo "Verify the read rate is under TBF control"
3959 do_node $client1 $myRUNAS dd if=$dir/tbf of=/dev/null \
3960 bs=1M count=100 iflag=direct 2>&1
3961 runtime=$((SECONDS - start + 1))
3962 rate=$(bc <<< "scale=6; 100 / $runtime")
3963 echo "Read runtime is $runtime s, speed is $rate IOPS"
3965 # verify the read rate does not exceed TBF rate limit
3966 [ $(bc <<< "$rate < 1.1 * $np * $2") -eq 1 ] ||
3967 error "The read rate ($rate) exceeds 110% of rate limit ($2 * $np)"
3969 cancel_lru_locks osc
3970 cleanup_tbf_verify || error "rm -rf $dir failed"
3976 oss=$(comma_list $(osts_nodes))
3978 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid" ||
3980 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
3981 [[ $rc -ne 0 ]] && error "failed to set TBF NID policy"
3985 if [ "$OST1_VERSION" -ge $(version_code 2.8.54) ]; then
3990 # Only operate rules on ost1 since OSTs might run on the same OSS
3992 tbf_rule_operate ost1 "start\ localhost\ ${idis}{0@lo}\ ${rateis}1000"
3993 local address=$(comma_list "$(host_nids_address $CLIENTS $NETTYPE)")
3994 local client_nids=$(nids_list $address "\\")
3995 tbf_rule_operate ost1 "start\ clients\ ${idis}{$client_nids}\ ${rateis}100"
3996 tbf_rule_operate ost1 "start\ others\ ${idis}{*.*.*.*@$NETTYPE}\ ${rateis}50"
4000 tbf_rule_operate ost1 "change\ localhost\ ${rateis}1001"
4001 tbf_rule_operate ost1 "change\ clients\ ${rateis}101"
4002 tbf_rule_operate ost1 "change\ others\ ${rateis}51"
4006 tbf_rule_operate ost1 "stop\ localhost"
4007 tbf_rule_operate ost1 "stop\ clients"
4008 tbf_rule_operate ost1 "stop\ others"
4011 # Cleanup the TBF policy
4012 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
4013 [ $? -ne 0 ] && error "failed to set policy back to fifo"
4017 run_test 77e "check TBF NID nrs policy"
4022 oss=$(comma_list $(osts_nodes))
4024 do_nodes $oss $LCTL set_param \
4025 ost.OSS.ost_io.nrs_policies="tbf\ jobid" || rc=$?
4026 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
4027 [[ $rc -ne 0 ]] && error "failed to set TBF JOBID policy"
4029 # Configure jobid_var
4030 local saved_jobid_var=$($LCTL get_param -n jobid_var)
4032 [[ $rc -eq 3 ]] && skip "jobid_var not found" && return
4033 [[ $rc -ne 0 ]] && error "failed to get param jobid_var"
4034 if [ $saved_jobid_var != procname_uid ]; then
4035 set_persistent_param_and_check client \
4036 "jobid_var" "$FSNAME.sys.jobid_var" procname_uid
4041 if [ "$OST1_VERSION" -ge $(version_code 2.8.54) ]; then
4046 # Only operate rules on ost1 since OSTs might run on the same OSS
4048 tbf_rule_operate ost1 "start\ runas\ ${idis}{iozone.$RUNAS_ID\ dd.$RUNAS_ID\ tiotest.$RUNAS_ID}\ ${rateis}1000"
4049 tbf_rule_operate ost1 "start\ iozone_runas\ ${idis}{iozone.$RUNAS_ID}\ ${rateis}100"
4050 tbf_rule_operate ost1 "start\ dd_runas\ ${idis}{dd.$RUNAS_ID}\ ${rateis}50"
4051 nrs_write_read "$RUNAS"
4054 tbf_rule_operate ost1 "change\ runas\ ${rateis}1001"
4055 tbf_rule_operate ost1 "change\ iozone_runas\ ${rateis}101"
4056 tbf_rule_operate ost1 "change\ dd_runas\ ${rateis}51"
4057 nrs_write_read "$RUNAS"
4060 tbf_rule_operate ost1 "stop\ runas"
4061 tbf_rule_operate ost1 "stop\ iozone_runas"
4062 tbf_rule_operate ost1 "stop\ dd_runas"
4063 nrs_write_read "$RUNAS"
4065 # Cleanup the TBF policy
4066 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
4067 [ $? -ne 0 ] && error "failed to set policy back to fifo"
4068 nrs_write_read "$RUNAS"
4070 local current_jobid_var=$($LCTL get_param -n jobid_var)
4071 [[ $? -ne 0 ]] && error "failed to get param jobid_var"
4072 if [ $saved_jobid_var != $current_jobid_var ]; then
4073 set_persistent_param_and_check client \
4074 "jobid_var" "$FSNAME.sys.jobid_var" $saved_jobid_var
4078 run_test 77f "check TBF JobID nrs policy"
4083 oss=$(comma_list $(osts_nodes))
4085 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid" ||
4087 [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
4088 [[ $rc -ne 0 ]] && error "failed to set TBF NID policy"
4090 do_nodes $oss lctl set_param \
4091 ost.OSS.ost_io.nrs_policies="tbf\ jobid" || rc=$?
4092 [[ $rc -ne 0 ]] && error "failed to set TBF JOBID policy"
4096 if [ "$OST1_VERSION" -ge $(version_code 2.8.54) ]; then
4101 # Add a rule that only valid for Jobid TBF. If direct change between
4102 # TBF types is not supported, this operation will fail.
4103 tbf_rule_operate ost1 "start\ dd_runas\ ${idis}{dd.$RUNAS_ID}\ ${rateis}50"
4105 # Cleanup the TBF policy
4106 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
4107 [ $? -ne 0 ] && error "failed to set policy back to fifo"
4110 run_test 77g "Change TBF type directly"
4113 [ "$OST1_VERSION" -ge $(version_code 2.8.55) ] ||
4114 skip "Need OST version at least 2.8.55"
4116 local old_policy=$(do_facet ost1 \
4117 lctl get_param ost.OSS.ost_io.nrs_policies)
4120 do_facet ost1 lctl set_param \
4121 ost.OSS.ost_io.nrs_policies="abc"
4122 [ $? -eq 0 ] && error "should return error"
4124 do_facet ost1 lctl set_param \
4125 ost.OSS.ost_io.nrs_policies="tbf\ abc"
4126 [ $? -eq 0 ] && error "should return error"
4128 do_facet ost1 lctl set_param \
4129 ost.OSS.ost_io.nrs_policies="tbf\ reg\ abc"
4130 [ $? -eq 0 ] && error "should return error"
4132 do_facet ost1 lctl set_param \
4133 ost.OSS.ost_io.nrs_policies="tbf\ abc\ efg"
4134 [ $? -eq 0 ] && error "should return error"
4136 new_policy=$(do_facet ost1 lctl get_param ost.OSS.ost_io.nrs_policies)
4137 [ $? -eq 0 ] || error "shouldn't LBUG"
4139 [ "$old_policy" = "$new_policy" ] || error "NRS policy should be same"
4143 run_test 77h "Wrong policy name should report error, not LBUG"
4149 local error_message=$3
4151 for rule in $expected; do
4152 rule_number=$((rule_number + 1))
4154 local stop_line=$(($rule_number + 3))
4155 local awk_command="awk 'NR >= 4 && NR <= $stop_line {print \$1}'"
4157 local output=$(do_facet $facet lctl get_param \
4158 ost.OSS.ost_io.nrs_tbf_rule |
4162 if [ "$output" != "$expected" ]; then
4163 error "$error_message, expected '$expected', got '$output'"
4168 [ "$OST1_VERSION" -ge $(version_code 2.8.55) ] ||
4169 skip "Need OST version at least 2.8.55"
4171 for i in $(seq 1 $OSTCOUNT)
4173 do_facet ost"$i" lctl set_param \
4174 ost.OSS.ost_io.nrs_policies="tbf\ jobid"
4176 error "failed to set TBF policy"
4179 tbf_rule_check ost1 "default" "error before inserting any rule"
4181 tbf_rule_operate ost1 "start\ before\ jobid={jobid}\ rate=1000"
4182 tbf_rule_check ost1 "before default" \
4183 "error when inserting rule 'before'"
4185 tbf_rule_operate ost1 "start\ after\ jobid={jobid}\ rate=1000\ rank=default"
4186 tbf_rule_check ost1 "before after default" \
4187 "error when inserting rule 'after'"
4189 tbf_rule_operate ost1 "start\ target\ jobid={jobid}\ rate=1000\ rank=after"
4190 tbf_rule_check ost1 "before target after default" \
4191 "error when inserting rule 'target'"
4193 echo "Move before itself"
4194 tbf_rule_operate ost1 "change\ target\ rank=target"
4195 tbf_rule_check ost1 "before target after default" \
4196 "error when moving before itself"
4198 echo "Move to higher rank"
4199 tbf_rule_operate ost1 "change\ target\ rank=before"
4200 tbf_rule_check ost1 "target before after default" \
4201 "error when moving to higher rank"
4203 echo "Move to lower rank"
4204 tbf_rule_operate ost1 "change\ target\ rank=after"
4205 tbf_rule_check ost1 "before target after default" \
4206 "error when moving to lower rank"
4208 echo "Move before default"
4209 tbf_rule_operate ost1 "change\ target\ rank=default"
4210 tbf_rule_check ost1 "before after target default" \
4211 error "error when moving before default"
4213 # Cleanup the TBF policy
4214 do_nodes $(comma_list $(osts_nodes)) \
4215 $LCTL set_param ost.OSS.ost_io.nrs_policies=fifo
4218 run_test 77i "Change rank of TBF rule"
4224 [ "$OST1_VERSION" -ge $(version_code 2.9.53) ] ||
4225 skip "Need OST version at least 2.9.53"
4226 if [ "$OST1_VERSION" -ge $(version_code 2.8.60) ]; then
4231 do_nodes $(comma_list $(osts_nodes)) \
4232 lctl set_param jobid_var=procname_uid \
4233 ost.OSS.ost_io.nrs_policies="tbf\ opcode" \
4234 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_r\ ${idis}{ost_read}\ ${rateis}5" \
4235 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_w\ ${idis}{ost_write}\ ${rateis}20"
4236 [ $? -ne 0 ] && error "failed to set TBF OPCode policy"
4241 do_nodes $(comma_list $(osts_nodes)) \
4242 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_r" \
4243 ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_w" \
4244 ost.OSS.ost_io.nrs_policies="fifo"
4246 # sleep 3 seconds to wait the tbf policy stop completely,
4247 # or the next test case is possible get -EAGAIN when
4248 # setting the tbf policy
4251 run_test 77j "check TBF-OPCode NRS policy"
4254 local idstr="${1}id"
4255 local policy="${idstr}={$2}"
4256 local rate="rate=$3"
4258 do_nodes $(comma_list $(osts_nodes)) \
4259 lctl set_param jobid_var=procname_uid \
4260 ost.OSS.ost_io.nrs_policies="tbf\ ${idstr}" \
4261 ost.OSS.ost_io.nrs_tbf_rule="start\ ost_${idstr}\ ${policy}\ ${rate}"
4262 [ $? -ne 0 ] && error "failed to set tbf ${idstr} policy"
4264 nrs_write_read "runas $4"
4265 tbf_verify $3 $3 "runas $4"
4267 do_nodes $(comma_list $(osts_nodes)) \
4268 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_${idstr}" \
4269 ost.OSS.ost_io.nrs_policies="fifo"
4271 # sleep 3 seconds to wait the tbf policy stop completely,
4272 # or the next test case is possible get -eagain when
4273 # setting the tbf policy
4278 if [ "$OST1_VERSION" -lt $(version_code 2.11.50) ]; then
4279 skip "Need OST version at least 2.11.50"
4282 test_id "u" "500" "5" "-u 500"
4283 test_id "g" "500" "5" "-u 500 -g 500"
4285 run_test 77ja "check TBF-UID/GID NRS policy"
4293 for rule in $rule_lists; do
4294 do_nodes $(comma_list $(osts_nodes)) \
4295 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ $rule"
4298 do_nodes $(comma_list $(osts_nodes)) \
4299 lctl set_param ost.OSS.ost_io.nrs_policies="$old_nrs"
4305 [[ "$OST1_VERSION" -ge $(version_code 2.9.53) ]] ||
4306 skip "Need OST version at least 2.9.53"
4308 do_nodes $(comma_list $(osts_nodes)) \
4309 lctl set_param ost.OSS.ost_io.nrs_policies="tbf" \
4310 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_w\ jobid={dd.$RUNAS_ID}\&opcode={ost_write}\ rate=20" \
4311 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_r\ jobid={dd.$RUNAS_ID}\&opcode={ost_read}\ rate=10"
4313 nrs_write_read "$RUNAS"
4314 tbf_verify 20 10 "$RUNAS"
4316 local address=$(comma_list "$(host_nids_address $CLIENTS $NETTYPE)")
4317 local client_nids=$(nids_list $address "\\")
4318 do_nodes $(comma_list $(osts_nodes)) \
4319 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_w" \
4320 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_r" \
4321 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_w\ nid={0@lo\ $client_nids}\&opcode={ost_write}\ rate=20" \
4322 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_r\ nid={0@lo\ $client_nids}\&opcode={ost_read}\ rate=10"
4327 do_nodes $(comma_list $(osts_nodes)) \
4328 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_w" \
4329 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_r" \
4330 ost.OSS.ost_io.nrs_tbf_rule="start\ ext\ nid={0@lo\ $client_nids}\&jobid={dd.$RUNAS_ID}\ rate=20"
4332 nrs_write_read "$RUNAS"
4333 tbf_verify 20 20 "$RUNAS"
4335 do_nodes $(comma_list $(osts_nodes)) \
4336 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext" \
4337 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_a\ jobid={dd.$RUNAS_ID},opcode={ost_write}\ rate=20" \
4338 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_b\ jobid={dd.$RUNAS_ID},opcode={ost_read}\ rate=10"
4340 nrs_write_read "$RUNAS"
4341 # with parameter "RUNAS", it will match the latest rule
4342 # "ext_b" first, so the limited write rate is 10.
4343 tbf_verify 10 10 "$RUNAS"
4346 trap "cleanup_77k \"ext_a ext_b\" \"fifo\"" EXIT
4348 [[ "$OST1_VERSION" -ge $(version_code 2.10.58) ]] ||
4349 skip "Need OST version at least 2.10.58"
4351 do_nodes $(comma_list $(osts_nodes)) \
4352 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_a" \
4353 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_b" \
4354 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_ug\ uid={500}\&gid={1000}\ rate=5"
4355 nrs_write_read "runas -u 500 -g 1000"
4356 tbf_verify 5 5 "runas -u 500 -g 1000"
4358 do_nodes $(comma_list $(osts_nodes)) \
4359 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_ug" \
4360 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_uw\ uid={500}\&opcode={ost_write}\ rate=20" \
4361 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_ur\ uid={500}\&opcode={ost_read}\ rate=10"
4363 nrs_write_read "runas -u 500"
4364 tbf_verify 20 10 "runas -u 500"
4366 do_nodes $(comma_list $(osts_nodes)) \
4367 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_uw" \
4368 ost.OSS.ost_io.nrs_tbf_rule="stop\ ext_ur" \
4369 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_a\ uid={500},opcode={ost_write}\ rate=20" \
4370 ost.OSS.ost_io.nrs_tbf_rule="start\ ext_b\ uid={500},opcode={ost_read}\ rate=10"
4371 nrs_write_read "runas -u 500"
4372 tbf_verify 10 10 "runas -u 500"
4373 tbf_verify 20 10 "runas -u 500"
4374 cleanup_77k "ext_a ext_b" "fifo"
4376 run_test 77k "check TBF policy with NID/JobID/OPCode expression"
4379 [[ "$OST1_VERSION" -ge $(version_code 2.10.56) ]] ||
4380 skip "Need OST version at least 2.10.56"
4382 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid"
4383 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="tbf"
4385 local output=$(do_facet ost1 lctl get_param \
4386 ost.OSS.ost_io.nrs_policies | \
4387 awk '/name: tbf/ {print;exit}' | \
4388 awk -F ': ' '{print $2}')
4390 if [ "$output" != "tbf" ]; then
4391 error "The generic TBF output is '$output', not 'tbf'"
4394 do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
4396 run_test 77l "check the output of NRS policies for generic TBF"
4399 if [ "$OST1_VERSION" -lt $(version_code 2.9.54) ]; then
4400 skip "Need OST version at least 2.9.54"
4403 local dir=$DIR/$tdir
4405 mkdir $dir || error "mkdir $dir failed"
4406 $LFS setstripe -c $OSTCOUNT $dir || error "setstripe to $dir failed"
4409 local nodes=$(comma_list $(osts_nodes))
4410 do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies=delay \
4411 ost.OSS.ost_io.nrs_delay_min=4 \
4412 ost.OSS.ost_io.nrs_delay_max=4 \
4413 ost.OSS.ost_io.nrs_delay_pct=100
4414 [ $? -ne 0 ] && error "Failed to set delay policy"
4416 local start=$SECONDS
4417 do_nodes "${SINGLECLIENT:-$HOSTNAME}" "$RUNAS" \
4418 dd if=/dev/zero of="$dir/nrs_delay_$HOSTNAME" bs=1M count=1 \
4419 oflag=direct conv=fdatasync ||
4420 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
4421 error "dd on client failed (1)"; }
4422 local elapsed=$((SECONDS - start))
4424 # NRS delay doesn't do sub-second timing, so a request enqueued at
4425 # 0.9 seconds can be dequeued at 4.0
4426 [ $elapsed -lt 3 ] &&
4427 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
4428 error "Single 1M write should take at least 3 seconds"; }
4431 do_nodes "${SINGLECLIENT:-$HOSTNAME}" "$RUNAS" \
4432 dd if=/dev/zero of="$dir/nrs_delay_$HOSTNAME" bs=1M count=10 \
4433 oflag=direct conv=fdatasync ||
4434 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
4435 error "dd on client failed (2)"; }
4436 elapsed=$((SECONDS - start))
4438 [ $elapsed -lt 30 ] &&
4439 { do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo";
4440 error "Ten 1M writes should take at least 30 seconds"; }
4442 do_nodes $nodes lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
4443 [ $? -ne 0 ] && error "failed to set policy back to fifo"
4447 run_test 77m "check NRS Delay slows write RPC processing"
4449 test_77n() { #LU-10802
4450 if [ "$OST1_VERSION" -lt $(version_code 2.10.58) ]; then
4451 skip "Need OST version at least 2.10.58"
4454 # Configure jobid_var
4455 local saved_jobid_var=$($LCTL get_param -n jobid_var)
4456 if [ $saved_jobid_var != procname_uid ]; then
4457 set_persistent_param_and_check client \
4458 "jobid_var" "$FSNAME.sys.jobid_var" procname_uid
4461 do_nodes $(comma_list $(osts_nodes)) \
4462 lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ jobid" \
4463 ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \
4464 ost.OSS.ost_io.nrs_tbf_rule="start\ dd_runas\ jobid={*.$RUNAS_ID}\ rate=20"
4467 tbf_verify 20 20 "$RUNAS"
4469 do_nodes $(comma_list $(osts_nodes)) \
4470 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \
4471 ost.OSS.ost_io.nrs_tbf_rule="start\ dd_runas\ jobid={dd.*}\ rate=20"
4476 do_nodes $(comma_list $(osts_nodes)) \
4477 lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ dd_runas" \
4478 ost.OSS.ost_io.nrs_policies="fifo"
4482 local current_jobid_var=$($LCTL get_param -n jobid_var)
4483 if [ $saved_jobid_var != $current_jobid_var ]; then
4484 set_persistent_param_and_check client \
4485 "jobid_var" "$FSNAME.sys.jobid_var" $saved_jobid_var
4488 run_test 77n "check wildcard support for TBF JobID NRS policy"
4491 (( $OST1_VERSION > $(version_code 2.14.54) )) ||
4492 skip "need OST > 2.14.54"
4494 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_policies="tbf\ nid"
4495 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="start\ name\ nid={192.168.*.*@tcp}\ rate=10000"
4496 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="start\ name1\ nid={192.168.*.*@tcp}\ rate=10000"
4497 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="change\ name1\ rank=name"
4498 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="stop\ name"
4499 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_policies="fifo"
4501 run_test 77o "Changing rank should not panic"
4506 (( $MDS1_VERSION > $(version_code 2.14.54) )) ||
4507 skip "need MDS >= 2.14.54"
4509 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_policies="tbf"
4510 stack_trap "do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_policies=fifo"
4512 for i in {1..50}; do
4515 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="'start rule77q_1 uid={500}&gid={500} rate=100'" &
4517 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="'start rule77q_2 uid={1000}&gid={1000} rate=100'" &
4519 wait $pid1 || error "$i: Fail to start TBF rule 'rule77q_1'"
4520 wait $pid2 || error "$i: Fail to start TBF rule 'rule77q_2'"
4522 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="'stop rule77q_1'" &
4524 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="'stop rule77q_2'" &
4526 wait $pid1 || error "$i: Fail to stop TBF rule 'rule77q_1'"
4527 wait $pid2 || error "$i: Fail to stop TBF rule 'rule77q_2'"
4530 run_test 77q "Parallel TBF rule definitions should not panic"
4534 local -a spec_chars=(
4535 '@' '.' '~' '#' '/' '^' '%' '*' ';' ',' '?' '<' '>' ':'
4536 '+' '=' ')' '(' '{' '}' '|' '[' ']' '!' '&' '\$' '\`' '\\')
4538 (( $MDS1_VERSION > $(version_code 2.14.54) )) ||
4539 skip "need MDS >= 2.14.54"
4541 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_policies="tbf"
4542 stack_trap "do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_policies=fifo"
4544 # TBF rule name size is 16 bytes
4545 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="start\ test_77p_overflo\ uid={500}\ rate=500" &&
4546 error "The length of tbf rule name is not checked" || true
4547 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="start\ \ uid={500}\ rate=500" &&
4548 error "The server should not accept empty tbf rule name" || true
4549 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="start\ test_77p_empty" &&
4550 error "The server should not accept 'start <tbf_rule_name>' without an expression" || true
4552 # Test with special chars
4553 for c in "${spec_chars[@]}"; do
4554 do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="'start test77p${c}spec uid={500} rate=500'" &&
4555 error "Special char '${c}' should not be accepted in a tbf rule name" || true
4559 run_test 77p "Check validity of rule names for TBF policies"
4561 test_78() { #LU-6673
4564 oss=$(comma_list $(osts_nodes))
4565 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="orr" &
4566 do_nodes $oss lctl set_param ost.OSS.*.nrs_orr_quantum=1
4568 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
4569 # Valid return codes are:
4570 # 0: Tuning succeeded
4571 # ENODEV: Policy is still stopped
4572 # EAGAIN: Policy is being initialized
4573 [ $rc -eq 0 -o $rc -eq 19 -o $rc -eq 11 ] ||
4574 error "Expected set_param to return 0|ENODEV|EAGAIN"
4576 # Cleanup the ORR policy
4577 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
4578 [ $? -ne 0 ] && error "failed to set policy back to fifo"
4581 run_test 78 "Enable policy and specify tunings right away"
4584 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4585 test_mkdir $DIR/$tdir
4587 # Prevent interference from layout intent RPCs due to
4588 # asynchronous writeback. These will be tested in 130c below.
4589 do_nodes ${CLIENTS:-$HOSTNAME} sync
4591 setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
4592 error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
4594 #define OBD_FAIL_MDS_INTENT_DELAY 0x160
4595 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
4596 local facet=mds$((mdtidx + 1))
4598 set_nodes_failloc $(facet_active_host $facet) 0x80000160
4599 getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null &
4603 #define OBD_FAIL_MDS_GETXATTR_PACK 0x131
4604 set_nodes_failloc $(facet_active_host $facet) 0x80000131
4609 run_test 79 "xattr: intent error"
4612 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4619 mkdir_on_mdt0 $DIR1/$tdir
4620 mkdir -p $DIR1/$tdir/dir
4621 createmany -o $DIR1/$tdir/dir/f 10 ||
4622 error "create files under remote dir failed $i"
4624 cp /etc/passwd $DIR1/$tdir/$tfile
4626 #migrate open file should fails
4627 multiop_bg_pause $DIR2/$tdir/$tfile O_c || error "open $file failed"
4629 # give multiop a chance to open
4632 $LFS migrate -m $MDTIDX $DIR1/$tdir &&
4633 error "migrate open files should failed with open files"
4637 $LFS migrate -m $MDTIDX $DIR1/$tdir ||
4638 error "migrate remote dir error"
4640 echo "Finish migration, then checking.."
4641 for file in $(find $DIR1/$tdir); do
4642 mdt_index=$($LFS getstripe -m $file)
4643 [ $mdt_index == $MDTIDX ] ||
4644 error "$file is not on MDT${MDTIDX}"
4647 diff /etc/passwd $DIR1/$tdir/$tfile ||
4648 error "file different after migration"
4650 rm -rf $DIR1/$tdir || error "rm dir failed after migration"
4652 run_test 80a "migrate directory when some children is being opened"
4656 kill -9 $migrate_pid
4660 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4661 local migrate_dir1=$DIR1/$tdir/migrate_dir
4662 local migrate_dir2=$DIR2/$tdir/migrate_dir
4663 local migrate_run=$LUSTRE/tests/migrate.sh
4670 trap cleanup_80b EXIT
4671 #prepare migrate directory
4672 mkdir -p $migrate_dir1
4673 for F in {1,2,3,4,5}; do
4674 echo "$F$F$F$F$F" > $migrate_dir1/file$F
4675 echo "$F$F$F$F$F" > $DIR/$tdir/file$F
4678 #migrate the directories among MDTs
4681 mdt_idx=$((RANDOM % MDSCOUNT))
4682 $LFS migrate -m $mdt_idx $migrate_dir1 &>/dev/null ||
4684 (( $rc != 0 && $rc != 16 )) || break
4689 echo "start migration thread $migrate_pid"
4690 #Access the files at the same time
4692 echo "accessing the migrating directory for 5 minutes..."
4694 ls $migrate_dir2 > /dev/null || {
4695 echo "read dir fails"
4698 diff -u $DIR2/$tdir/file1 $migrate_dir2/file1 || {
4699 echo "access file1 fails"
4703 cat $migrate_dir2/file2 > $migrate_dir2/file3 || {
4704 echo "access file2/3 fails"
4708 echo "aaaaa" > $migrate_dir2/file4 > /dev/null || {
4709 echo "access file4 fails"
4713 stat $migrate_dir2/file5 > /dev/null || {
4714 echo "stat file5 fails"
4718 touch $migrate_dir2/source_file > /dev/null || rc1=$?
4719 (( $rc != 0 && $rc != 1 )) || {
4720 echo "touch file failed with $rc1"
4724 if [ -e $migrate_dir2/source_file ]; then
4725 ln $migrate_dir2/source_file $migrate_dir2/link_file \
4726 &>/dev/null || rc1=$?
4727 if [ -e $migrate_dir2/link_file ]; then
4728 rm -rf $migrate_dir2/link_file
4731 mrename $migrate_dir2/source_file \
4732 $migrate_dir2/target_file &>/dev/null || rc1=$?
4733 (( $rc != 0 && $rc != 1 )) || {
4734 echo "rename failed with $rc1"
4738 if [ -e $migrate_dir2/target_file ]; then
4739 rm -rf $migrate_dir2/target_file &>/dev/null ||
4742 rm -rf $migrate_dir2/source_file &>/dev/null ||
4745 (( $rc != 0 && $rc != 1 )) || {
4746 echo "unlink failed with $rc1"
4751 local duration=$((SECONDS - start_time))
4752 if (( duration % 10 == 0 )); then
4753 if (( $show_time == 1 )); then
4754 echo "...$duration seconds"
4761 kill -0 $migrate_pid || {
4762 echo "migration stopped 1"
4766 (( $duration < 300 )) || break
4769 #check migration are still there
4770 kill -0 $migrate_pid || error "migration stopped 2"
4773 run_test 80b "Accessing directory during migration"
4776 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4780 mkdir -p $DIR1/$tdir
4782 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d0
4783 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR1/$tdir/d1
4786 touch d0/0 || error "create 0 failed"
4787 mv d0/0 d1/0 || error "rename d0/0 d1/0 failed"
4788 stat d0/0 && error "stat mv filed succeed"
4789 mv $DIR2/$tdir/d1/0 $DIR2/$tdir/d0/0 || error "rename d1/0 d0/0 failed"
4790 stat d0/0 || error "stat failed"
4792 local t=$(ls -ai $DIR1/$tdir/d0 | sort -u | wc -l)
4794 if [ $t -ne 3 ]; then
4795 ls -ai $DIR1/$tdir/d0
4796 error "expect 3 get $t"
4801 run_test 81a "rename and stat under striped directory"
4804 [ $MDSCOUNT -lt 2 ] &&
4805 skip "We need at least 2 MDTs for this test"
4812 $LFS mkdir -c $MDSCOUNT $DIR1/$tdir || error "$LFS mkdir"
4813 createmany -o $DIR1/$tdir/$tfile. $total || error "createmany"
4822 for i in $(seq $total); do
4823 mrename $DIR2/$tdir/$tfile.$i $DIR2/$tdir/$tfile-new.$i \
4827 kill -9 $setattr_pid
4829 run_test 81b "rename under striped directory doesn't deadlock"
4832 [ $MDSCOUNT -lt 4 ] && skip_env "needs >= 4 MDTs"
4833 [ $MDS1_VERSION -lt $(version_code 2.13.52) ] &&
4834 skip "Need MDS version at least 2.13.52"
4836 # source is local, source parent is remote
4837 $LFS mkdir -i 0 $DIR1/${tdir}_src || error "mkdir ${tdir}_src"
4838 $LFS mkdir -i 1 $DIR1/${tdir}_tgt || error "mkdir ${tdir}_tgt"
4839 $LFS mkdir -i 3 $DIR1/${tdir}_src/sub || error "mkdir sub"
4840 $LFS mkdir -i 3 $DIR1/${tdir}_tgt/sub || error "mkdir sub"
4841 stat $DIR2/${tdir}_src/sub || error "stat sub failed"
4842 mv $DIR1/${tdir}_src/sub $DIR1/${tdir}_tgt/ || error "mv failed"
4843 [ -f $DIR2/${tdir}_src/sub ] && error "sub should be gone"
4844 rm -rf $DIR1/${tdir}_src $DIR1/${tdir}_tgt
4846 # source is remote, source parent is local
4847 $LFS mkdir -i 3 $DIR1/${tdir}_src || error "mkdir ${tdir}_src"
4848 $LFS mkdir -i 1 $DIR1/${tdir}_tgt || error "mkdir ${tdir}_tgt"
4849 $LFS mkdir -i 0 $DIR1/${tdir}_src/sub || error "mkdir sub"
4850 $LFS mkdir -i 3 $DIR1/${tdir}_tgt/sub || error "mkdir sub"
4851 stat $DIR2/${tdir}_src/sub || error "stat sub failed"
4852 mv $DIR1/${tdir}_src/sub $DIR1/${tdir}_tgt/ || error "mv failed"
4853 [ -f $DIR2/${tdir}_src/sub ] && error "sub should be gone"
4854 rm -rf $DIR1/${tdir}_src $DIR1/${tdir}_tgt
4856 # source and source parent are remote
4857 $LFS mkdir -i 0 $DIR1/${tdir}_src || error "mkdir ${tdir}_src"
4858 $LFS mkdir -i 1 $DIR1/${tdir}_tgt || error "mkdir ${tdir}_tgt"
4859 mkdir $DIR1/${tdir}_src/sub || error "mkdir sub"
4860 $LFS mkdir -i 3 $DIR1/${tdir}_tgt/sub || error "mkdir sub"
4861 stat $DIR2/${tdir}_src/sub || error "stat sub failed"
4862 mv $DIR1/${tdir}_src/sub $DIR1/${tdir}_tgt/ || error "mv failed"
4863 [ -f $DIR2/${tdir}_src/sub ] && error "sub should be gone"
4864 rm -rf $DIR1/${tdir}_src $DIR1/${tdir}_tgt
4866 # source and source parent are remote, and source is remote object
4867 $LFS mkdir -i 0 $DIR1/${tdir}_src || error "mkdir ${tdir}_src"
4868 $LFS mkdir -i 1 $DIR1/${tdir}_tgt || error "mkdir ${tdir}_tgt"
4869 $LFS mkdir -i 2 $DIR1/${tdir}_src/sub || error "mkdir sub"
4870 $LFS mkdir -i 3 $DIR1/${tdir}_tgt/sub || error "mkdir sub"
4871 stat $DIR2/${tdir}_src/sub || error "stat sub failed"
4872 mv $DIR1/${tdir}_src/sub $DIR1/${tdir}_tgt/ || error "mv failed"
4873 [ -f $DIR2/${tdir}_src/sub ] && error "sub should be gone" || true
4875 run_test 81c "rename revoke LOOKUP lock for remote object"
4878 [[ "$MDS1_VERSION" -gt $(version_code 2.6.91) ]] ||
4879 skip "Need MDS version at least 2.6.92"
4881 # Client 1 creates a file.
4882 multiop_bg_pause $DIR1/$tfile O_ac || error "multiop_bg_pause 1"
4884 # Client 2 opens the file.
4885 multiop_bg_pause $DIR2/$tfile o_Ac || error "multiop_bg_pause 2"
4887 # Client 1 makes the file an orphan.
4888 rm $DIR1/$tfile || error "rm"
4889 # Client 2 sets EA "user.multiop".
4891 wait $pid2 || error "multiop 2"
4892 # Client 1 gets EA "user.multiop". This used to fail because the EA
4893 # cache refill would get "trusted.link" from mdd_xattr_list() but
4894 # -ENOENT when trying to get "trusted.link"'s value. See also sanity
4897 wait $pid1 || error "multiop 1"
4899 run_test 82 "fsetxattr and fgetxattr on orphan files"
4902 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4909 $LFS mkdir -i1 -c2 $tdir
4914 echo "start pid $pid1 to create/unlink striped directory"
4916 # Access the directory at the same time
4920 stat $tdir > /dev/null 2>&1
4924 echo "start pid $pid2 to stat striped directory"
4932 run_test 83 "access striped directory while it is being created/unlinked"
4935 [ $MDS1_VERSION -lt $(version_code 2.12.55) ] &&
4936 skip "lustre < 2.12.55 does not contain LU-12485 fix"
4940 $MULTIOP $DIR/$tfile oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:c ||
4941 error "create $tfile failed"
4942 mtime=$(stat -c%Y $DIR/$tfile)
4943 mtime=$((mtime + 200))
4945 #define OBD_FAIL_OBD_0NLINK_RACE 0x60b
4946 do_facet mds1 $LCTL set_param fail_loc=0x8000060b
4948 touch -c -m $mtime $DIR/$tfile &
4950 # sleep a while to let 'touch' run first
4952 rm -f $DIR2/$tfile || error "unlink $tfile failed"
4955 wait $setattr_pid || true
4957 run_test 84 "0-nlink race in lu_object_find()"
4960 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
4965 [ "$SLOW" = "yes" ] && duration=600
4966 # Open/Create under striped directory
4970 $LFS mkdir -c$MDSCOUNT $tdir > /dev/null 2>&1
4971 touch $tdir/f{0..3} > /dev/null 2>&1
4975 echo "start pid $pid1 to open/create under striped directory"
4977 # unlink the striped directory at the same time
4981 rm -rf $tdir > /dev/null 2>&1
4985 echo "start pid $pid2 to unlink striped directory"
4994 run_test 90 "open/create and unlink striped directory"
4997 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
5002 [ "$SLOW" = "yes" ] && duration=600
5003 # chmod striped directory
5007 $LFS mkdir -c$MDSCOUNT $tdir > /dev/null 2>&1
5008 chmod go+w $tdir > /dev/null 2>&1
5012 echo "start pid $pid1 to chmod striped directory"
5014 # unlink the striped directory at the same time
5018 rm -rf $tdir > /dev/null 2>&1
5022 echo "start pid $pid2 to unlink striped directory"
5031 run_test 91 "chmod and unlink striped directory"
5034 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
5037 local cmd="exec $fd<$DIR1/$tdir"
5038 $LFS setdirstripe -c$MDSCOUNT $DIR1/$tdir || error "mkdir $tdir fails"
5041 trap "eval $cmd" EXIT
5042 cd $DIR1/$tdir || error "cd $DIR1/$tdir fails"
5043 rmdir ../$tdir || error "rmdir ../$tdir fails"
5045 #define OBD_FAIL_LLITE_NO_CHECK_DEAD 0x1408
5046 $LCTL set_param fail_loc=0x1408
5047 mkdir $DIR2/$tdir/dir && error "create dir succeeds"
5048 $LFS setdirstripe -i1 $DIR2/$tdir/remote_dir &&
5049 error "create remote dir succeeds"
5050 $LCTL set_param fail_loc=0
5054 run_test 92 "create remote directory under orphan directory"
5061 mkdir -p $DIR1/$tfile-1/
5062 mkdir -p $DIR2/$tfile-2/
5063 local old_rr=$(do_facet $SINGLEMDS "$LCTL get_param -n \
5064 lod.$FSNAME-MDT0000-*/qos_threshold_rr" | sed -e 's/%//')
5065 do_facet $SINGLEMDS "$LCTL set_param -n \
5066 lod.$FSNAME-MDT0000-*/qos_threshold_rr=100"
5067 #define OBD_FAIL_MDS_LOV_CREATE_RACE 0x163
5068 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x00000163"
5070 $LFS setstripe -c -1 $DIR1/$tfile-1/file1 &
5073 $LFS setstripe -c -1 $DIR2/$tfile-2/file2 &
5077 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x0"
5078 do_facet $SINGLEMDS "$LCTL set_param -n \
5079 lod.$FSNAME-MDT0000-*/qos_threshold_rr=$old_rr"
5081 $LFS getstripe $DIR1/$tfile-1/file1
5082 rc1=$($LFS getstripe -q $DIR1/$tfile-1/file1 |
5083 awk '{if (/[0-9]/) print $1 }' | sort | uniq -d | wc -l)
5084 $LFS getstripe $DIR2/$tfile-2/file2
5085 rc2=$($LFS getstripe -q $DIR2/$tfile-2/file2 |
5086 awk '{if (/[0-9]/) print $1 }' | sort | uniq -d | wc -l)
5087 echo "rc1=$rc1 and rc2=$rc2 "
5088 [ $rc1 -eq 0 ] && [ $rc2 -eq 0 ] ||
5089 error "object allocate on same ost detected"
5091 run_test 93 "alloc_rr should not allocate on same ost"
5094 $LCTL set_param osc.*.idle_timeout=0
5095 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=2 conv=fsync
5097 local before=$(date +%s)
5101 #define OBD_FAIL_LDLM_PAUSE_CANCEL 0x312
5102 $LCTL set_param fail_val=5 fail_loc=0x80000312
5103 dd if=/dev/zero of=$DIR/$tfile conv=notrunc oflag=append bs=4k count=1 &
5107 #define OBD_FAIL_LDLM_PAUSE_CANCEL_LOCAL 0x329
5108 $LCTL set_param fail_val=6 fail_loc=0x80000329
5109 $LCTL mark kill $pid
5112 dd if=/dev/zero of=$DIR2/$tfile conv=notrunc oflag=append bs=4k count=1
5115 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 conv=fsync
5117 evict=$(do_facet client $LCTL get_param \
5118 osc.$FSNAME-OST*-osc-*/state |
5119 awk -F"[ [,]" '/EVICTED ]$/ { if (t<$5) {t=$5;} } END { print t }')
5121 [ -z "$evict" ] || [[ $evict -le $before ]] ||
5122 (do_facet client $LCTL get_param \
5123 osc.$FSNAME-OST*-osc-*/state;
5124 error "eviction happened: $evict before:$before")
5125 $LCTL set_param osc.*.idle_timeout=debug
5127 run_test 94 "signal vs CP callback race"
5131 skip "Reserved for glimpse-ahead" && return
5132 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
5133 skip "Need MDS version at least 2.10.55"
5137 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
5139 lctl set_param -n mdc.*.stats=clear
5140 dd if=/dev/zero of=$DIR2/$tdir/dom bs=4096 count=1 || return 1
5142 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #1"
5143 # first stat from server should return size data and save glimpse
5144 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
5145 [ $gls -eq 0 ] || error "Unexpected $gls glimpse RPCs"
5146 # second stat to check size is NOT cached on client without IO lock
5147 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #2"
5149 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
5150 [ $gls -ge 1 ] || error "Expect glimpse RPCs but none"
5153 run_test 100a "DoM: glimpse RPCs for stat without IO lock (DoM only file)"
5156 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
5157 skip "Need MDS version at least 2.10.55"
5161 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
5163 lctl set_param -n mdc.*.stats=clear
5164 dd if=/dev/zero of=$DIR2/$tdir/dom bs=4096 count=1 || return 1
5165 cancel_lru_locks mdc
5166 # first stat data from server should have size
5167 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #1"
5168 # second stat to check size is cached on client
5169 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #2"
5171 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
5172 # both stats should cause no glimpse requests
5173 [ $gls == 0 ] || error "Unexpected $gls glimpse RPCs"
5176 run_test 100b "DoM: no glimpse RPC for stat with IO lock (DoM only file)"
5179 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
5180 skip "Need MDS version at least 2.10.55"
5184 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
5186 lctl set_param -n mdc.*.stats=clear
5187 lctl set_param -n osc.*.stats=clear
5188 dd if=/dev/zero of=$DIR2/$tdir/dom bs=2048K count=1 || return 1
5190 # check that size is merged from MDT and OST correctly
5191 $CHECKSTAT -t file -s 2097152 $DIR/$tdir/dom ||
5192 error "Wrong size from stat #1"
5194 local gls=$(lctl get_param -n osc.*.stats | grep -c ldlm_glimpse)
5195 [ $gls -eq 0 ] && error "Expect OST glimpse RPCs but got none"
5199 run_test 100c "DoM: write vs stat without IO lock (combined file)"
5202 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
5203 skip "Need MDS version at least 2.10.55"
5207 $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
5210 dd if=/dev/zero of=$DIR2/$tdir/dom bs=2048K count=1 || return 1
5211 lctl set_param -n mdc.*.stats=clear
5212 $TRUNCATE $DIR2/$tdir/dom 4096
5214 # check that reported size is valid after file grows to OST and
5215 # is truncated back to MDT stripe size
5216 $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom ||
5217 error "Wrong size from stat #1"
5219 local gls=$(lctl get_param -n osc.*.stats | grep -c ldlm_glimpse)
5220 [ $gls -eq 0 ] && error "Expect OST glimpse but got none"
5224 run_test 100d "DoM: write+truncate vs stat without IO lock (combined file)"
5227 [ "$MDS1_VERSION" -lt $(version_code 2.11.50) ] &&
5228 skip "Need MDS version at least 2.11.50"
5230 local dom=$DIR/$tdir/dom
5231 local dom2=$DIR2/$tdir/dom
5234 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
5236 cancel_lru_locks mdc
5237 dd if=/dev/urandom of=$dom bs=12000 count=1
5238 $TRUNCATE $dom2 6000
5239 cancel_lru_locks mdc
5240 lctl set_param -n mdc.*.stats=clear
5241 # expect read-on-open to return all data before write
5242 cat /etc/hosts >> $dom
5243 local read=$(lctl get_param -n mdc.*.stats | grep -c ost_read)
5244 [[ $read -eq 0 ]] || error "Unexpected $read READ RPCs"
5246 run_test 100e "DoM: read on open and file size"
5249 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
5250 skip "Need MDS version at least 2.10.55"
5252 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
5254 $CHECKSTAT -t file $DIR1/$tfile
5256 local old_wb=$(sysctl -n vm.dirty_writeback_centisecs)
5257 sysctl -wq vm.dirty_writeback_centisecs=0
5259 trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT
5262 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 ||
5263 error_noexit "Write fails"
5264 # must discard pages
5265 lctl set_param -n mdc.*.stats=clear
5266 rm $DIR2/$tfile || error "Unlink fails"
5268 local writes=$(lctl get_param -n mdc.*.stats | grep -c ost_write)
5269 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
5271 run_test 101a "Discard DoM data on unlink"
5274 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
5275 skip "Need MDS version at least 2.10.55"
5277 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
5278 touch $DIR1/${tfile}_2
5280 $CHECKSTAT -t file $DIR1/$tfile
5282 local old_wb=$(sysctl -n vm.dirty_writeback_centisecs)
5283 sysctl -wq vm.dirty_writeback_centisecs=0
5285 trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT
5288 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 || error "Write fails"
5289 # must discard pages
5290 lctl set_param -n mdc.*.stats=clear
5291 mv $DIR2/${tfile}_2 $DIR2/$tfile || error "Rename fails"
5293 local writes=$(lctl get_param -n mdc.*.stats | grep -c ost_write)
5294 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
5296 run_test 101b "Discard DoM data on rename"
5299 [ "$MDS1_VERSION" -lt $(version_code 2.10.55) ] &&
5300 skip "Need MDS version at least 2.10.55"
5302 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
5304 $CHECKSTAT -t file $DIR1/$tfile
5306 local old_wb=$(sysctl -n vm.dirty_writeback_centisecs)
5307 sysctl -wq vm.dirty_writeback_centisecs=0
5309 trap "sysctl -wq vm.dirty_writeback_centisecs=$old_wb" EXIT
5312 dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 || error "Write fails"
5313 $MULTIOP $DIR1/$tfile O_c &
5316 lctl set_param -n mdc.*.stats=clear
5317 rm $DIR2/$tfile > /dev/null || error "Unlink fails for opened file"
5318 kill -USR1 $MULTIOP_PID && wait $MULTIOP_PID || error "multiop failure"
5320 local writes=$(lctl get_param -n mdc.*.stats | grep -c ost_write)
5321 [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
5323 run_test 101c "Discard DoM data on close-unlink"
5325 # test to verify file handle related system calls
5326 # (name_to_handle_at/open_by_handle_at)
5327 # The new system calls are supported in glibc >= 2.14.
5329 # test to verify we can open by handle an unlinked file from > 1 client
5330 # This test opens the file normally on $DIR1, which is on one mount, and then
5331 # opens it by handle on $DIR2, which is on a different mount.
5333 (( "$MDS1_VERSION" >= $(version_code 2.11.57) )) ||
5334 skip "Needs MDS version 2.11.57 or later"
5336 echo "Test file_handle syscalls" > $DIR/$tfile ||
5337 error "write failed"
5338 check_fhandle_syscalls $DIR/$tfile $DIR2 ||
5339 error "check_fhandle_syscalls $tfile failed"
5341 # test this is working on DNE directories also
5342 if (( MDSCOUNT > 1 && MDS1_VERSION >= $(version_code 2.14.52) )); then
5343 $LFS mkdir -i 1 $DIR/$tdir.remote
5344 cancel_lru_locks mdc
5345 check_fhandle_syscalls $DIR/$tdir.remote $DIR2 ||
5346 error "check_fhandle_syscalls $tdir.remote failed"
5347 $LFS mkdir -c -1 $DIR/$tdir.remote/subdir
5348 cancel_lru_locks mdc
5349 check_fhandle_syscalls $DIR/$tdir.remote/subdir $DIR2 ||
5350 error "check_fhandle_syscalls $tdir.remote/subdir fail"
5352 $LFS mkdir -c -1 $DIR/$tdir.stripe
5353 cancel_lru_locks mdc
5354 check_fhandle_syscalls $DIR/$tdir.stripe $DIR2 ||
5355 error "check_fhandle_syscalls $tdir.stripe failed"
5356 $LFS mkdir -c -1 $DIR/$tdir.stripe/subdir
5357 cancel_lru_locks mdc
5358 check_fhandle_syscalls $DIR/$tdir.stripe/subdir $DIR2 ||
5359 error "check_fhandle_syscalls $tdir.stripe/subdir fail"
5362 run_test 102 "Test open by handle of unlinked file"
5364 # Compare file size between first & second mount, ensuring the client correctly
5365 # glimpses even with unused speculative locks - LU-11670
5367 [ $OST1_VERSION -lt $(version_code 2.10.50) ] &&
5368 skip "Lockahead needs OST version at least 2.10.50"
5372 test_mkdir -p $DIR/$tdir
5374 # Force file on to OST0
5375 $LFS setstripe -i 0 $DIR/$tdir
5377 # Do not check multiple locks on glimpse
5378 # OBD_FAIL_OSC_NO_SIZE_DATA 0x415
5379 $LCTL set_param fail_loc=0x415
5381 # Delay write commit by 2 seconds to guarantee glimpse wins race
5382 # The same fail_loc is used on client & server so it can work in the
5383 # single node sanity setup
5384 do_facet ost1 $LCTL set_param fail_loc=0x415 fail_val=2
5386 echo "Incorrect size expected (no glimpse fix):"
5387 lockahead_test -d $DIR/$tdir -D $DIR2/$tdir -t $locktest -f $tfile
5389 if [ $rc -eq 0 ]; then
5390 echo "This doesn't work 100%, but this is just reproducing the bug, not testing the fix, so OK to not fail test."
5393 # guarantee write commit timeout has expired
5396 # Clear fail_loc on client
5397 $LCTL set_param fail_loc=0
5399 # Delay write commit by 2 seconds to guarantee glimpse wins race
5400 # OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
5401 do_facet ost1 $LCTL set_param fail_loc=0x214 fail_val=2
5403 # Write commit is still delayed by 2 seconds
5404 lockahead_test -d $DIR/$tdir -D $DIR2/$tdir -t $locktest -f $tfile
5406 [ $rc -eq 0 ] || error "Lockahead test$locktest failed, $rc"
5408 # guarantee write commit timeout has expired
5411 rm -f $DIR/$tfile || error "unable to delete $DIR/$tfile"
5413 run_test 103 "Test size correctness with lockahead"
5419 xtimes=$(stat -c "%X %Y %Z" $DIR/$tfile)
5430 output=$(do_facet mds1 "$DEBUGFS -c -R 'stat ROOT/$tfile' $mdtdev")
5431 ((xtimes[0]=$(awk -F ':' /atime/'{ print $2 }' <<< "$output")))
5432 ((xtimes[1]=$(awk -F ':' /mtime/'{ print $2 }' <<< "$output")))
5433 ((xtimes[2]=$(awk -F ':' /ctime/'{ print $2 }' <<< "$output")))
5441 local xtimes=($(get_stat_xtimes))
5442 local mdt_xtimes=($(get_mdt_xtimes $mdtdev))
5444 echo "STAT a|m|ctime ${xtimes[*]}"
5445 echo "MDT a|m|ctime ${mdt_xtimes[*]}"
5446 [[ ${xtimes[0]} == ${mdt_xtimes[0]} ]] ||
5447 error "$DIR/$tfile atime (${xtimes[0]}:${mdt_xtimes[0]}) diff"
5448 [[ ${xtimes[1]} == ${mdt_xtimes[1]} ]] ||
5449 error "$DIR/$tfile mtime (${xtimes[1]}:${mdt_xtimes[1]}) diff"
5450 [[ ${xtimes[2]} == ${mdt_xtimes[2]} ]] ||
5451 error "$DIR/$tfile ctime (${xtimes[2]}:${mdt_xtimes[2]}) diff"
5455 [ "$mds1_FSTYPE" == "ldiskfs" ] || skip_env "ldiskfs only test"
5456 [ $MDS1_VERSION -lt $(version_code 2.12.4) ] &&
5457 skip "Need MDS version at least 2.12.4"
5460 local mdtdev=$(mdsdevname ${SINGLEMDS//mds/})
5461 local atime_diff=$(do_facet $SINGLEMDS \
5462 lctl get_param -n mdd.*MDT0000*.atime_diff)
5464 do_facet $SINGLEMDS \
5465 lctl set_param -n mdd.*MDT0000*.atime_diff=0
5467 stack_trap "do_facet $SINGLEMDS \
5468 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff" EXIT
5470 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
5471 check_mdt_xtimes $mdtdev
5474 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
5475 check_mdt_xtimes $mdtdev
5477 $MULTIOP $DIR2/$tfile Oz8192w8192_c &
5480 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
5482 kill -USR1 $pid && wait $pid || error "multiop failure"
5483 check_mdt_xtimes $mdtdev
5488 # Verify mtime/ctime is NOT upated on MDS when there is no modification
5489 # on the client side
5490 xtimes=($(get_stat_xtimes))
5491 $MULTIOP $DIR/$tfile O_c &
5494 kill -USR1 $pid && wait $pid || error "multiop failure"
5495 mdt_xtimes=($(get_mdt_xtimes $mdtdev))
5496 [[ ${xtimes[1]} == ${mdt_xtimes[1]} ]] ||
5497 error "$DIR/$tfile mtime (${xtimes[1]}:${mdt_xtimes[1]}) diff"
5498 [[ ${xtimes[2]} == ${mdt_xtimes[2]} ]] ||
5499 error "$DIR/$tfile ctime (${xtimes[2]}:${mdt_xtimes[2]}) diff"
5500 check_mdt_xtimes $mdtdev
5503 # Change ctime via chmod
5504 $MULTIOP $DIR/$tfile o_tc &
5507 kill -USR1 $pid && wait $pid || error "multiop failure"
5508 check_mdt_xtimes $mdtdev
5510 run_test 104 "Verify that MDS stores atime/mtime/ctime during close"
5513 test_mkdir -p $DIR/$tdir
5514 echo test > $DIR/$tdir/$tfile
5515 $LCTL set_param fail_loc=0x416
5516 cancel_lru_locks osc & sleep 1
5517 fsize1=$(stat -c %s $DIR2/$tdir/$tfile)
5519 [[ $fsize1 = 5 ]] || error "Glimpse returned wrong file size $fsize1"
5521 run_test 105 "Glimpse and lock cancel race"
5524 [ "$mds1_FSTYPE" == "ldiskfs" ] && statx_supported ||
5525 skip_env "Test only for ldiskfs and statx() supported"
5530 local mdtdev=$(mdsdevname ${SINGLEMDS//mds/})
5532 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
5533 btime=$($STATX -c %W $DIR/$tfile)
5534 output=$(do_facet mds1 "$DEBUGFS -c -R 'stat ROOT/$tfile' $mdtdev")
5536 ((mdt_btime=$(awk -F ':' /crtime/'{ print $2 }' <<< "$output")))
5537 [[ $btime == $mdt_btime ]] ||
5538 error "$DIR/$tfile btime ($btime:$mdt_btime) diff"
5541 run_test 106a "Verify the btime via statx()"
5544 statx_supported || skip_env "statx() only test"
5549 $LFS setstripe -c 1 $DIR/$tfile || error "$DIR/$tfile setstripe failed"
5550 dd if=/dev/zero of=$DIR/$tfile bs=1k count=1 conv=notrunc
5551 cancel_lru_locks $OSC
5552 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5554 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5555 [ $rpcs_after -eq $((rpcs_before + 1)) ] ||
5556 error "$STATX should send 1 glimpse RPC to $OSC"
5558 cancel_lru_locks $OSC
5559 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5560 # %n: FILENAME; %i: STATX_INO; %A STATX_MODE; %h STATX_NLINK;
5561 # %u: STATX_UID; %g: STATX_GID; %W STATX_BTIME; %X STATX_ATIME;
5563 $STATX -c "%n %i %A %h %u %g %W %X %Z" $DIR/$tfile
5564 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5565 [ $rpcs_after -eq $rpcs_before ] ||
5566 error "$STATX should not send glimpse RPCs to $OSC"
5568 cancel_lru_locks $OSC
5569 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5570 $STATX --cached=always $DIR/$tfile
5571 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5572 [ $rpcs_after -eq $rpcs_before ] ||
5573 error "$STATX should not send glimpse RPCs to $OSC"
5575 cancel_lru_locks $OSC
5576 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5577 $STATX -c %Y $DIR/$tfile
5578 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5579 [ $rpcs_after -eq $((rpcs_before + 1)) ] ||
5580 error "$STATX -c %Y should send 1 glimpse RPC to $OSC"
5582 cancel_lru_locks $OSC
5583 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5584 $STATX -c %s $DIR/$tfile
5585 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5586 [ $rpcs_after -eq $((rpcs_before + 1)) ] ||
5587 error "$STATX -c %s should send 1 glimpse RPC to $OSC"
5589 cancel_lru_locks $OSC
5590 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5591 $STATX -c %b $DIR/$tfile
5592 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5593 [ $rpcs_after -eq $((rpcs_before + 1)) ] ||
5594 error "$STATX -c %b should send 1 glimpse RPC to $OSC"
5596 run_test 106b "Glimpse RPCs test for statx"
5599 statx_supported || skip_env "statx() only test"
5604 # Mask supported in stx_attributes by Lustre is
5605 # STATX_ATTR_IMMUTABLE(0x10) | STATX_ATTR_APPEND(0x20) : (0x30).
5606 mask=$($STATX -c %p $DIR/$tfile)
5607 [[ $mask == "30" ]] ||
5608 error "supported stx_attributes: got '$mask', expected '30'"
5609 chattr +i $DIR/$tfile || error "chattr +i $DIR/$tfile failed"
5610 mask=$($STATX -c %r $DIR/$tfile)
5611 [[ $mask == "10" ]] ||
5612 error "got immutable flags '$mask', expected '10'"
5613 chattr -i $DIR/$tfile || error "chattr -i $DIR/$tfile failed"
5614 mask=$($STATX -c %r $DIR/$tfile)
5615 [[ $mask == "0" ]] || error "got flags '$mask', expected '0'"
5616 chattr +a $DIR/$tfile || error "chattr +a $DIR/$tfile failed"
5617 mask=$($STATX -c %r $DIR/$tfile)
5618 [[ $mask == "20" ]] || error "got flags '$mask', expected '20'"
5619 chattr -a $DIR/$tfile || error "chattr -a $DIR/$tfile failed"
5620 mask=$($STATX -c %r $DIR/$tfile)
5621 [[ $mask == "0" ]] || error "got flags '$mask', expected '0'"
5622 chattr +ia $DIR/$tfile || error "chattr +ia $DIR/$tfile failed"
5623 mask=$($STATX -c %r $DIR/$tfile)
5624 [[ $mask == "30" ]] || error "got flags '$mask', expected '30'"
5625 chattr -ia $DIR/$tfile || error "chattr -ia $DIR/$tfile failed"
5626 mask=$($STATX -c %r $DIR/$tfile)
5627 [[ $mask == "0" ]] || error "got flags '$mask', expected '0'"
5629 run_test 106c "Verify statx attributes mask"
5631 test_107a() { # LU-1031
5632 dd if=/dev/zero of=$DIR1/$tfile bs=1M count=10
5636 $LFS getstripe $DIR1/$tfile
5638 multiop_bg_pause $DIR1/$tfile OG${gid1}_g${gid1}c || return 1
5640 multiop_bg_pause $DIR2/$tfile O_G${gid2}r10g${gid2}c || return 2
5642 kill -USR1 $MULTIPID2
5644 if [[ $(ps h -o comm -p $MULTIPID2) == "" ]]; then
5645 error "First grouplock does not block second one"
5647 echo "First grouplock blocks second one"
5649 kill -USR1 $MULTIPID1
5653 run_test 107a "Basic grouplock conflict"
5656 dd if=/dev/zero of=$DIR1/$tfile bs=1M count=10
5660 $LFS getstripe $DIR1/$tfile
5662 multiop_bg_pause $DIR1/$tfile OG${gid1}_g${gid1}c || return 1
5664 multiop $DIR2/$tfile Or10c &
5668 if [[ $(ps h -o comm -p $MULTIPID2) == "" ]]; then
5669 error "Grouplock does not block IO"
5671 echo "Grouplock blocks IO"
5674 multiop $DIR2/$tfile OG${gid2}_g${gid2}c &
5677 if [[ $(ps h -o comm -p $MULTIPID3) == "" ]]; then
5678 error "First grouplock does not block second one"
5680 echo "First grouplock blocks second one"
5683 kill -USR1 $MULTIPID1
5686 if [[ $(ps h -o comm -p $MULTIPID3) == "" ]]; then
5687 error "Second grouplock thread disappeared"
5690 if [[ $(ps h -o comm -p $MULTIPID2) == "" ]]; then
5691 error "Second grouplock does not block IO"
5693 echo "Second grouplock blocks IO"
5696 kill -USR1 $MULTIPID3
5701 run_test 107b "Grouplock is added to the head of waiting list"
5706 $LFS setstripe -E 1M -c 1 -E -1 $DIR1/$tfile ||
5707 error "Create $DIR1/$tfile failed"
5709 dd if=/dev/zero of=$DIR1/$tfile bs=10000 count=1 ||
5710 error "dd $DIR1/$tfile failed"
5711 offset=$(lseek_test -d 5000 $DIR2/$tfile)
5712 [[ $offset == 5000 ]] || error "offset $offset != 5000"
5714 $TRUNCATE $DIR1/$tfile 2000
5715 offset=$(lseek_test -l 1000 $DIR2/$tfile)
5716 [[ $offset == 2000 ]] || error "offset $offset != 2000"
5718 #define OBD_FAIL_OSC_DELAY_IO 0x414
5719 $LCTL set_param fail_val=4 fail_loc=0x80000414
5720 dd if=/dev/zero of=$DIR1/$tfile count=1 bs=8M conv=notrunc oflag=dsync &
5724 offset=$(lseek_test -l 8000 $DIR2/$tfile)
5726 [[ $offset == 8388608 ]] || error "offset $offset != 8388608"
5728 run_test 108a "lseek: parallel updates"
5736 skip "Clients need to be on different nodes than the servers"
5738 umount_client $MOUNT
5739 umount_client $MOUNT2
5741 echo "Starting race between client mount instances (50 iterations):"
5742 for i in {1..50}; do
5745 #define OBD_FAIL_ONCE|OBD_FAIL_LLITE_RACE_MOUNT 0x80001417
5746 $LCTL set_param -n fail_loc=0x80001417
5748 mount_client $MOUNT & pid1=$!
5749 mount_client $MOUNT2 & pid2=$!
5750 wait $pid1 || error "Mount $MOUNT fails with $?"
5751 wait $pid2 || error "Mount $MOUNT2 fails with $?"
5753 umount_client $MOUNT & pid1=$!
5754 umount_client $MOUNT2 & pid2=$!
5755 wait $pid1 || error "Umount $MOUNT fails with $?"
5756 wait $pid2 || error "Umount $MOUNT2 fails with $?"
5758 $LUSTRE_RMMOD || error "Fail to remove lustre modules"
5764 mount_client $MOUNT2
5767 run_test 109 "Race with several mount instances on 1 node"
5770 local before=$(date +%s)
5777 #define OBD_FAIL_PTLRPC_RESEND_RACE 0x525
5778 do_facet mds1 lctl set_param fail_loc=0x525 fail_val=3
5780 # disable last_xid logic by dropping link reply
5781 ln $DIR/$tdir/f1 $DIR/$tdir/f2 &
5784 #define OBD_FAIL_PTLRPC_ENQ_RESEND 0x534
5785 do_facet mds1 lctl set_param fail_loc=0x534
5787 # RPC will race with its Resend and the Resend will sleep to let
5788 # the original lock to get granted & cancelled.
5790 # AST_SENT is set artificially, so an explicit conflict is not needed
5792 # The woken up Resend gets a new lock, but client does not wait for it
5795 do_facet mds1 lctl set_param fail_loc=0 fail_val=0
5797 # Take a conflict to wait long enough to see the eviction
5800 # let the client reconnect
5802 evict=$(do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state |
5803 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
5805 [ -z "$evict" ] || [[ $evict -le $before ]] ||
5806 (do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state;
5807 error "eviction happened: $evict before:$before")
5809 run_test 110 "do not grant another lock on resend"
5812 [ $MDSCOUNT -ge 2 ] || skip "needs >= 2 MDTs"
5813 [[ $(facet_active_host mds1) = $(facet_active_host mds2) ]] ||
5814 skip "MDT0 and MDT1 should be on the same node"
5817 $LFS mkdir -i 0 $DIR1/$tdir/mdt0dir
5818 $LFS mkdir -i 1 $DIR1/$tdir/mdt1dir
5820 mkdir $DIR1/$tdir/mdt0dir/foodir
5821 touch $DIR1/$tdir/mdt0dir/foodir/{file1,file2}
5823 $MULTIOP $DIR2/$tdir/mdt0dir/foodir/file2 Ow4096_c &
5825 ln $DIR1/$tdir/mdt0dir/foodir/file2 $DIR1/$tdir/mdt1dir/file2
5827 #define OBD_FAIL_MDS_LINK_RENAME_RACE 0x18a
5828 do_facet mds1 $LCTL set_param fail_loc=0x8000018a
5830 ln $DIR1/$tdir/mdt0dir/foodir/file2 $DIR1/$tdir/mdt1dir/file2x &
5833 rm $DIR2/$tdir/mdt1dir/file2
5836 mv $DIR2/$tdir/mdt0dir/foodir/file1 $DIR2/$tdir/mdt0dir/foodir/file2
5841 rm -r $DIR1/$tdir || error "Removing test dir failed"
5843 run_test 111 "A racy rename/link an open file should not cause fs corruption"
5846 (( MDSCOUNT >= 2 )) ||
5847 skip "We need at least 2 MDTs for this test"
5849 (( MDS1_VERSION >= $(version_code 2.14.54) )) ||
5850 skip "Need server version at least 2.14.54"
5855 rr=$($LCTL get_param -n lmv.*.qos_threshold_rr | head -n1)
5857 stack_trap "$LCTL set_param lmv.*.qos_threshold_rr=$rr > /dev/null"
5859 mkdir -p $DIR1/$tdir/s1/s2 || error "mkdir s2 failed"
5860 $LFS mkdir -i 0 $DIR1/$tdir/s1/s2/s3 || error "mkdir s3 failed"
5861 $LFS setdirstripe -D -i -1 --max-inherit-rr=0 $DIR1/$tdir/s1/s2/s3 ||
5862 error "setdirstripe s3 failed"
5863 $LCTL set_param lmv.*.qos_threshold_rr=90
5864 mkdir $DIR2/$tdir/s1/s2/s3/d{1..64}
5865 count=$($LFS getstripe -m $DIR2/$tdir/s1/s2/s3/d* | grep ^0 | wc -l)
5866 (( count == 64 )) || error "only $count subdirs created on MDT0"
5868 $LFS setdirstripe -D -i -1 --max-inherit-rr=3 $DIR1/$tdir/s1/s2/s3 ||
5869 error "setdirstripe s3 failed"
5870 mkdir $DIR2/$tdir/s1/s2/s3/s{1..64}
5871 count=$($LFS getstripe -m $DIR2/$tdir/s1/s2/s3/s* | grep ^0 | wc -l)
5872 (( count == 64 / MDSCOUNT )) || error "$count subdirs created on MDT0"
5874 run_test 112 "update max-inherit in default LMV"
5876 log "cleanup: ======================================================"
5878 # kill and wait in each test only guarentee script finish, but command in script
5879 # like 'rm' 'chmod' may still be running, wait for all commands to finish
5880 # otherwise umount below will fail
5881 [ "$(mount | grep $MOUNT2)" ] && wait_update $HOSTNAME "fuser -m $MOUNT2" "" ||
5886 check_and_cleanup_lustre