8 OPENFILE=${OPENFILE:-openfile}
9 OPENUNLINK=${OPENUNLINK:-openunlink}
10 export TMP=${TMP:-/tmp}
11 MOUNT_2=${MOUNT_2:-"yes"}
12 CHECK_GRANT=${CHECK_GRANT:-"yes"}
13 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
15 LUSTRE=${LUSTRE:-$(dirname $0)/..}
16 . $LUSTRE/tests/test-framework.sh
20 ALWAYS_EXCEPT="$SANITYN_EXCEPT "
21 # bug number for skipped test: LU-7105
23 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
25 # skip tests for PPC until they are fixed
26 if [[ $(uname -m) = ppc64 ]]; then
27 # bug number: LU-11597 LU-11787
28 ALWAYS_EXCEPT+=" 16a 71a"
31 if [ $mds1_FSTYPE = "zfs" ]; then
32 # LU-2829 / LU-2887 - make allowances for ZFS slowness
33 TEST33_NFILES=${TEST33_NFILES:-1000}
37 [ "$SLOW" = "no" ] && EXCEPT_SLOW="33a"
46 check_and_setup_lustre
51 rm -rf $DIR1/[df][0-9]* $DIR1/lnk $DIR/[df].${TESTSUITE}*
53 SAMPLE_FILE=$TMP/$(basename $0 .sh).junk
54 dd if=/dev/urandom of=$SAMPLE_FILE bs=1M count=1
56 # $RUNAS_ID may get set incorrectly somewhere else
57 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
59 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
63 [ -f $DIR2/$tfile ] || error "Check create"
64 chmod 777 $DIR2/$tfile
65 $CHECKSTAT -t file -p 0777 $DIR1/$tfile ||
66 error "Check attribute update for 0777"
68 chmod a-x $DIR2/$tfile
69 $CHECKSTAT -t file -p 0666 $DIR1/$tfile ||
70 error "Check attribute update for 0666"
73 $CHECKSTAT -a $DIR1/$tfile ||
74 error "Check unlink - removes file on other mountpoint"
76 run_test 1 "Check attribute updates on 2 mount points"
82 $CHECKSTAT -t file -p 0777 $DIR1/f2a ||
83 error "Either not file type or perms not 0777"
85 run_test 2a "check cached attribute updates on 2 mtpt's ========"
91 $CHECKSTAT -t file -p 0777 $DIR2/f2b ||
92 error "Either not file type or perms not 0777"
94 run_test 2b "check cached attribute updates on 2 mtpt's ========"
96 # NEED TO SAVE ROOT DIR MODE
99 $CHECKSTAT -t dir -p 0777 $DIR2 ||
100 error "Either not dir type or perms not 0777"
102 run_test 2c "check cached attribute updates on 2 mtpt's root ==="
106 $CHECKSTAT -t dir -p 0755 $DIR2 ||
107 error "Either not file type or perms not 0775"
109 run_test 2d "check cached attribute updates on 2 mtpt's root ==="
116 $RUNAS dd if=/dev/zero of=$DIR2/$tfile count=1 ||
119 run_test 2e "check chmod on root is propagated to others"
122 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
124 local remote_dir=$tdir/remote_dir
127 $LFS mkdir -i $MDTIDX $DIR1/$remote_dir ||
128 error "Create remote directory failed"
130 touch $DIR1/$remote_dir/$tfile ||
131 error "Create file under remote directory failed"
132 chmod 777 $DIR1/$remote_dir/$tfile ||
133 error "Chmod file under remote directory failed"
135 $CHECKSTAT -t file -p 0777 $DIR2/$remote_dir/$tfile ||
136 error "Check attr of file under remote directory failed"
138 chown $RUNAS_ID:$RUNAS_GID $DIR1/$remote_dir/$tfile ||
139 error "Chown file under remote directory failed"
141 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR2/$remote_dir/$tfile ||
142 error "Check owner of file under remote directory failed"
144 cd $DIR2/$remote_dir || error "enter remote dir"
145 rm -rf $DIR1/$remote_dir/$tfile ||
146 error "Unlink remote directory failed"
148 $CHECKSTAT -t file $DIR2/$remote_dir/$tfile &&
149 error "unlink file still exists!"
151 cd $DIR2/$tdir || error "exit remote dir"
152 rm -rf $DIR1/$tdir || error "unlink directory failed"
154 run_test 2f "check attr/owner updates on DNE with 2 mtpt's"
157 dd if=/dev/zero of=$DIR1/$tfile oflag=sync bs=1M count=2
159 local block1=$(stat $DIR1/$tfile | awk '/Blocks/ {print $4} ')
161 local block2=$(stat $DIR2/$tfile | awk '/Blocks/ {print $4} ')
162 echo "$DIR1/$tfile has $block1 blocks"
163 echo "$DIR2/$tfile has $block2 blocks"
164 [ $block1 -eq $block2 ] || error "$block1 not equal to $block2"
166 run_test 2g "check blocks update on sync write"
169 local target="this/is/good"
170 ln -s $target $DIR1/$tfile || error "ln -s $target $DIR1/$tfile failed"
171 [ "$(ls -l $DIR2/$tfile | sed -e 's/.* -> //')" = "$target" ] ||
172 error "link $DIR2/$tfile not as expected"
174 run_test 3 "symlink on one mtpt, readlink on another ==========="
177 multifstat $DIR1/f4 $DIR2/f4
179 run_test 4 "fstat validation on multiple mount points =========="
183 $TRUNCATE $DIR2/f5 100
184 $CHECKSTAT -t file -s 100 $DIR1/f5 ||
185 error "Either not file type or size not equal to 100 bytes"
188 run_test 5 "create a file on one mount, truncate it on the other"
191 openunlink $DIR1/$tfile $DIR2/$tfile || \
192 error "openunlink $DIR1/$tfile $DIR2/$tfile"
194 run_test 6 "remove of open file on other node =================="
198 opendirunlink $DIR1/$dir $DIR2/$dir || \
199 error "opendirunlink $DIR1/$dir $DIR2/$dir"
201 run_test 7 "remove of open directory on other node ============="
204 opendevunlink $DIR1/$tfile $DIR2/$tfile || \
205 error "opendevunlink $DIR1/$tfile $DIR2/$tfile"
207 run_test 8 "remove of open special file on other node =========="
213 for C in a b c d e f g h i j k l; do
214 dir=`eval echo \\$DIR$MTPT`
215 echo -n $C >> $dir/f9
216 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
218 [ "`cat $DIR1/f9`" = "abcdefghijkl" ] || \
219 error "`od -a $DIR1/f9` != abcdefghijkl"
221 run_test 9a "append of file with sub-page size on multiple mounts"
223 #LU-10681 - tiny writes & appending to sparse striped file
225 [[ $OSTCOUNT -ge 2 ]] || { skip "needs >= 2 OSTs"; return; }
227 $LFS setstripe -c 2 -S 1M $DIR/$tfile
228 echo "foo" >> $DIR/$tfile
229 dd if=/dev/zero of=$DIR2/$tfile bs=1M count=1 seek=1 conv=notrunc ||
230 error "sparse dd $DIR2/$tfile failed"
231 echo "foo" >> $DIR/$tfile
233 data=$(dd if=$DIR2/$tfile bs=1 count=3 skip=$((2 * 1048576)) conv=notrunc)
234 echo "Data read (expecting 'foo')": $data
235 [ "$data" = "foo" ] || error "append to sparse striped file failed"
237 run_test 9b "append to striped sparse file"
244 for C in a b c d e f g h i j k l; do
245 dir=`eval echo \\$DIR$MTPT`
246 echo -n $C | dd of=$dir/f10 bs=1 seek=$OFFSET count=1
247 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
248 OFFSET=`expr $OFFSET + 1`
250 [ "`cat $DIR1/f10`" = "abcdefghijkl" ] || \
251 error "`od -a $DIR1/f10` != abcdefghijkl"
253 run_test 10a "write of file with sub-page size on multiple mounts "
257 yes "R" | head -c 4000 >$TMP/f10b-seed
258 dd if=$TMP/f10b-seed of=$DIR1/f10b bs=3k count=1 || error "dd $DIR1"
260 $TRUNCATE $DIR1/f10b 4096 || error "truncate 4096"
262 dd if=$DIR2/f10b of=$TMP/f10b-lustre bs=4k count=1 || error "dd $DIR2"
264 # create a test file locally to compare
265 dd if=$TMP/f10b-seed of=$TMP/f10b bs=3k count=1 || error "dd random"
266 $TRUNCATE $TMP/f10b 4096 || error "truncate 4096"
267 cmp $TMP/f10b $TMP/f10b-lustre || error "file miscompare"
268 rm $TMP/f10b $TMP/f10b-lustre $TMP/f10b-seed
270 run_test 10b "write of file with sub-page size on multiple mounts "
274 multiop_bg_pause $DIR1/d11/f O_c || return 1
276 cp -p /bin/ls $DIR1/d11/f
280 wait $MULTIPID || error "wait for PID $MULTIPID failed"
281 [ $RC -eq 0 ] && error || true
283 run_test 11 "execution of file opened for write should return error ===="
286 DIR=$DIR DIR2=$DIR2 sh lockorder.sh
288 run_test 12 "test lock ordering (link, stat, unlink)"
290 test_13() { # bug 2451 - directory coherency
292 cd $DIR1/d13 || error "cd to $DIR1/d13 failed"
294 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
296 rm -f $DIR2/d13/f13 || error "Cannot remove $DIR2/d13/f13"
297 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (1)" || true
298 # need to run it twice
299 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
301 rm -f $DIR2/d13/f13 || error "Cannot remove $DIR2/d13/f13"
302 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (2)" || true
304 run_test 13 "test directory page revocation"
307 test_mkdir $DIR1/$tdir
308 cp -p /bin/ls $DIR1/$tdir/$tfile
309 multiop_bg_pause $DIR1/$tdir/$tfile Ow_c || return 1
312 $DIR2/$tdir/$tfile && error || true
315 run_test 14aa "execution of file open for write returns -ETXTBSY"
318 test_mkdir $DIR1/$tdir
319 cp -p $(which sleep) $DIR1/$tdir/sleep || error "cp failed"
320 $DIR1/$tdir/sleep 60 &
322 $MULTIOP $DIR2/$tdir/sleep Oc && error "expected error, got success"
325 run_test 14ab "open(RDWR) of executing file returns -ETXTBSY"
327 test_14b() { # bug 3192, 7040
328 test_mkdir $DIR1/$tdir
329 cp -p $(which sleep) $DIR1/$tdir/sleep || error "cp failed"
330 $DIR1/$tdir/sleep 60 &
332 $TRUNCATE $DIR2/$tdir/sleep 60 && kill -9 $SLEEP_PID && \
333 error "expected truncate error, got success"
335 cmp $(which sleep) $DIR1/$tdir/sleep || error "binary changed"
337 run_test 14b "truncate of executing file returns -ETXTBSY ======"
339 test_14c() { # bug 3430, 7040
340 test_mkdir $DIR1/$tdir
341 cp -p $(which sleep) $DIR1/$tdir/sleep || error "cp failed"
342 $DIR1/$tdir/sleep 60 &
344 cp /etc/hosts $DIR2/$tdir/sleep && error "expected error, got success"
346 cmp $(which sleep) $DIR1/$tdir/sleep || error "binary changed"
348 run_test 14c "open(O_TRUNC) of executing file return -ETXTBSY =="
350 test_14d() { # bug 10921
351 test_mkdir $DIR1/$tdir
352 cp -p $(which sleep) $DIR1/$tdir/sleep || error "cp failed"
353 $DIR1/$tdir/sleep 60 &
356 chmod 600 $DIR1/$tdir/sleep || error "chmod failed"
358 cmp $(which sleep) $DIR1/$tdir/sleep || error "binary changed"
360 run_test 14d "chmod of executing file is still possible ========"
362 test_15() { # bug 974 - ENOSPC
364 sh oos2.sh $MOUNT1 $MOUNT2
365 wait_delete_completed
366 grant_error=$(dmesg | grep "< tot_grant")
367 [ -z "$grant_error" ] || error "$grant_error"
369 run_test 15 "test out-of-space with multiple writers ==========="
372 # The FSXNUM reduction for ZFS is needed until ORI-487 is fixed.
373 # We don't want to skip it entirely, but ZFS is VERY slow and cannot
374 # pass a 2500 operation dual-mount run within the time limit.
375 if [ "$ost1_FSTYPE" = "zfs" ]; then
376 FSXNUM=$((COUNT / 5))
378 elif [ "$SLOW" = "yes" ]; then
379 FSXNUM=$((COUNT * 5))
387 local file1=$DIR1/$tfile
388 local file2=$DIR2/$tfile
389 local stripe_size=$(do_facet $SINGLEMDS \
390 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
394 # to allocate grant because it may run out due to test_15.
395 $LFS setstripe -c -1 $file1
396 dd if=/dev/zero of=$file1 bs=$stripe_size count=$OSTCOUNT oflag=sync
397 dd if=/dev/zero of=$file2 bs=$stripe_size count=$OSTCOUNT oflag=sync
400 $LFS setstripe -c -1 $file1 # b=10919
401 $FSX -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -S 0 $file1 $file2 ||
405 # O_DIRECT reads and writes must be aligned to the device block size.
406 $FSX -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -S 0 -Z -r 4096 \
407 -w 4096 $file1 $file2 || error "fsx with O_DIRECT failed."
409 run_test 16a "$FSXNUM iterations of dual-mount fsx"
411 # Consistency check for tiny writes, LU-9409
413 local file1=$DIR1/$tfile
414 local file2=$DIR2/$tfile
415 local stripe_size=($($LFS getstripe -S $DIR))
419 # to allocate grant because it may run out due to test_15.
420 lfs setstripe -c -1 $file1
421 dd if=/dev/zero of=$file1 bs=$stripe_size count=$OSTCOUNT oflag=sync ||
422 error "dd failed writing to file=$file1"
423 dd if=/dev/zero of=$file2 bs=$stripe_size count=$OSTCOUNT oflag=sync ||
424 error "dd failed writing to file=$file2"
427 lfs setstripe -c -1 $file1 # b=10919
428 # -o is set to 8192 because writes < 1 page and between 1 and 2 pages
429 # create a mix of tiny writes & normal writes
430 $FSX -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -o 8192 -S 0 \
431 $file1 $file2 || error "fsx with tiny write failed."
433 run_test 16b "$FSXNUM iterations of dual-mount fsx at small size"
436 local file1=$DIR1/$tfile
437 local file2=$DIR2/$tfile
438 local stripe_size=$(do_facet $SINGLEMDS \
439 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
441 [ "$ost1_FSTYPE" != ldiskfs ] && skip "dio on ldiskfs only"
445 # to allocate grant because it may run out due to test_15.
446 $LFS setstripe -c -1 $file1
447 dd if=/dev/zero of=$file1 bs=$stripe_size count=$OSTCOUNT oflag=sync
448 dd if=/dev/zero of=$file2 bs=$stripe_size count=$OSTCOUNT oflag=sync
450 wait_delete_completed
452 local list=$(comma_list $(osts_nodes))
453 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
454 skip "not cache-capable obdfilter"
457 set_osd_param $list '' read_cache_enable 0
458 set_osd_param $list '' writethrough_cache_enable 0
460 $LFS setstripe -c -1 $file1 # b=10919
461 $FSX -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -S 0 $file1 $file2 ||
465 set_osd_param $list '' read_cache_enable 1
466 set_osd_param $list '' writethrough_cache_enable 1
470 run_test 16c "verify data consistency on ldiskfs with cache disabled (b=17397)"
473 local file1=$DIR1/$tfile
474 local file2=$DIR2/$tfile
475 local file3=$DIR1/file
476 local tmpfile=$(mktemp)
477 local stripe_size=$(do_facet $SINGLEMDS \
478 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
480 # to allocate grant because it may run out due to test_15.
481 $LFS setstripe -c -1 $file1
482 stack_trap "rm -f $file1 $file2 $file3 $tmpfile"
483 dd if=/dev/zero of=$file1 bs=$stripe_size count=$OSTCOUNT oflag=sync
484 dd if=/dev/zero of=$file2 bs=$stripe_size count=$OSTCOUNT oflag=sync
487 $LFS setstripe -c -1 $file1 # b=10919
488 $LCTL set_param ldlm.namespaces.*.lru_size=clear
490 # direct write on one client and direct read from another
491 dd if=/dev/urandom of=$file1 bs=1M count=100 oflag=direct
492 dd if=$file2 of=$tmpfile iflag=direct bs=1M
493 diff $file1 $tmpfile || error "file different(1)"
496 # buffer write on one client, but direct read from another
497 dd if=$tmpfile of=$file1 bs=1M count=100
498 dd if=$file2 of=$file3 bs=1M iflag=direct count=100
499 diff $file3 $tmpfile || error "file different(2)"
501 rm -f $file3 $file2 $file1
502 # direct write on one client
503 dd if=$tmpfile of=$file1 bs=1M count=100 oflag=direct
504 # buffer read from another client
505 dd if=$file2 of=$file3 bs=1M count=100
506 diff $file3 $tmpfile || error "file different(3)"
508 run_test 16d "Verify DIO and buffer IO with two clients"
510 test_16e() { # LU-13227
513 (( "$MDS1_VERSION" >= $(version_code 2.13.53) )) ||
514 skip "Need MDS version at least 2.13.53"
516 local file1=$DIR1/$tfile
517 local file2=$DIR2/$tfile
519 # client1 write 10M data
520 dd if=/dev/zero of=$file1 bs=1M count=10
522 cancel_lru_locks osc > /dev/null
523 # use lockahead to generate one PW lock to keep LVB loaded.
524 $LFS ladvise -a lockahead --start 0 --length 1M \
526 # direct write to extend file size on client2
527 dd if=/dev/zero of=$file2 bs=1M seek=20 count=1 \
528 oflag=direct conv=notrunc
529 local filesize=$(stat -c %s $file2)
530 [ "$filesize" -eq 22020096 ] ||
531 error "expected filesize 22020096 got $filesize"
534 run_test 16e "Verify size consistency for O_DIRECT write"
536 test_17() { # bug 3513, 3667
537 remote_ost_nodsh && skip "remote OST with nodsh" && return
539 lfs setstripe $DIR1/$tfile -i 0 -c 1
540 cp $SAMPLE_FILE $DIR1/$tfile
541 cancel_lru_locks osc > /dev/null
542 #define OBD_FAIL_ONCE|OBD_FAIL_LDLM_CREATE_RESOURCE 0x30a
543 do_facet ost1 lctl set_param fail_loc=0x8000030a
544 ls -ls $DIR1/$tfile | awk '{ print $1,$6 }' > $DIR1/$tfile-1 & \
545 ls -ls $DIR2/$tfile | awk '{ print $1,$6 }' > $DIR2/$tfile-2
547 diff -u $DIR1/$tfile-1 $DIR2/$tfile-2 || error "files are different"
549 run_test 17 "resource creation/LVB creation race ==============="
552 # turn e.g. ALWAYS_EXCEPT="18c" into "-e 3"
555 for idx in {a..z}; do
556 local ptr=EXCEPT_ALWAYS_18$idx
557 [ x${!ptr} = xtrue ] || continue
559 excepts="$excepts -e $(($(printf %d \'$idx)-96))"
562 excepts="$excepts -e 7 -e 8 -e 9"
563 $LUSTRE/tests/mmap_sanity -d $MOUNT1 -m $MOUNT2 $excepts ||
564 error "mmap_sanity test failed"
567 run_test 18 "mmap sanity check ================================="
569 test_19() { # bug3811
570 local node=$(facet_active_host ost1)
571 local device="$FSNAME-OST*"
573 [ "x$DOM" = "xyes" ] && node=$(facet_active_host $SINGLEMDS) &&
574 device="$FSNAME-MDT*"
576 # check whether obdfilter is cache capable at all
577 get_osd_param $node $device read_cache_enable >/dev/null ||
578 skip "not cache-capable obdfilter"
580 local max=$(get_osd_param $node $device readcache_max_filesize |\
582 set_osd_param $node $device readcache_max_filesize 4096
583 dd if=/dev/urandom of=$TMP/$tfile bs=512k count=32
584 local SUM=$(cksum $TMP/$tfile | cut -d" " -f 1,2)
585 cp $TMP/$tfile $DIR1/$tfile
586 for i in `seq 1 20`; do
587 [ $((i % 5)) -eq 0 ] && log "$testname loop $i"
588 cancel_lru_locks $OSC > /dev/null
589 cksum $DIR1/$tfile | cut -d" " -f 1,2 > $TMP/sum1 & \
590 cksum $DIR2/$tfile | cut -d" " -f 1,2 > $TMP/sum2
592 [ "$(cat $TMP/sum1)" = "$SUM" ] || \
593 error "$DIR1/$tfile $(cat $TMP/sum1) != $SUM"
594 [ "$(cat $TMP/sum2)" = "$SUM" ] || \
595 error "$DIR2/$tfile $(cat $TMP/sum2) != $SUM"
597 set_osd_param $node $device readcache_max_filesize $max
600 run_test 19 "test concurrent uncached read races ==============="
603 test_mkdir $DIR1/$tdir
605 CNT=$($LCTL get_param -n llite.*.dump_page_cache | wc -l)
606 $MULTIOP $DIR1/$tdir/$tfile Ow8190c
607 $MULTIOP $DIR2/$tdir/$tfile Oz8194w8190c
608 $MULTIOP $DIR1/$tdir/$tfile Oz0r8190c
610 CNT2=$($LCTL get_param -n llite.*.dump_page_cache | wc -l)
611 [[ $CNT2 == $CNT ]] ||
612 error $((CNT2 - CNT))" page left in cache after lock cancel"
614 run_test 20 "test extra readahead page left in cache ===="
621 test_21() { # Bug 5907
622 test_mkdir $DIR1/$tdir
623 mount /etc $DIR1/$tdir --bind || error "mount failed" # Poor man's mount.
625 rmdir -v $DIR1/$tdir && error "Removed mounted directory"
626 rmdir -v $DIR2/$tdir && echo "Removed mounted directory from another mountpoint, needs to be fixed"
627 test -d $DIR1/$tdir || error "Mounted directory disappeared"
629 test -d $DIR2/$tdir || test -d $DIR1/$tdir && error "Removed dir still visible after umount"
632 run_test 21 " Try to remove mountpoint on another dir ===="
634 test_23() { # Bug 5972
635 local at_diff=$(do_facet $SINGLEMDS \
636 $LCTL get_param -n mdd.*MDT0000*.atime_diff | head -n1)
637 echo "atime should be updated while another read" > $DIR1/$tfile
639 # clear the lock(mode: LCK_PW) gotten from creating operation
640 cancel_lru_locks $OSC
643 sleep $((at_diff + 1))
645 echo "starting reads"
646 multiop_bg_pause $DIR1/$tfile or20_c || return 1
647 # with SOM and opencache enabled, we need to close a file and cancel
648 # open lock to get atime propogated to MDS
649 kill -USR1 $! || return 2
652 time2=$(stat -c "%X" $DIR/$tfile)
653 echo "new atime is $time2"
655 [ $time2 -gt $time1 ] || error "atime was not updated"
656 rm -f $DIR1/$tfile || error "rm -f $DIR1/$tfile failed"
659 run_test 23 " others should see updated atime while another read===="
663 lfs df || error "lfs df failed"
664 lfs df -ih || error "lfs df -ih failed"
665 lfs df -h $DIR1 || error "lfs df -h $DIR1 failed"
666 lfs df -i $DIR2 || error "lfs df -i $DIR2 failed"
667 lfs df $DIR1/$tfile || error "lfs df $DIR1/$tfile failed"
668 lfs df -ih $DIR2/$tfile || error "lfs df -ih $DIR2/$tfile failed"
670 OSC=`lctl dl | awk '/-osc-|OSC.*MNT/ {print $4}' | head -n 1`
671 # OSC=`lctl dl | awk '/-osc-/ {print $4}' | head -n 1`
672 lctl --device %osc deactivate
673 lfs df -i || error "lfs df -i with deactivated OSC failed"
674 lctl --device %osc activate
675 lfs df || error "lfs df with reactivated OSC failed"
677 run_test 24a "lfs df [-ih] [path] test ========================="
681 fsnum=$(lfs_df | grep -c "summary")
682 [ $fsnum -eq 2 ] || error "lfs df shows $fsnum != 2 filesystems."
684 run_test 24b "lfs df should show both filesystems ==============="
687 local acl=$(lctl get_param -n mdc.*MDT0000-mdc-*.connect_flags |
689 [ "$acl" -lt 1 ] && skip "must have acl, skipping" && return
692 touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
693 chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
695 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
696 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
697 error "setfacl $DIR2/$tdir #1"
698 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
699 setfacl -m u:$RUNAS_ID:r-x -m g:$RUNAS_GID:r-x $DIR1/$tdir ||
700 error "setfacl $DIR2/$tdir #2"
701 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
702 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
703 error "setfacl $DIR2/$tdir #3"
704 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
705 setfacl -x u:$RUNAS_ID: -x g:$RUNAS_GID: $DIR1/$tdir ||
706 error "setfacl $DIR2/$tdir #4"
707 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
711 run_test 25a "change ACL on one mountpoint be seen on another ==="
714 local acl=$(lctl get_param -n mdc.*MDT0000-mdc-*.connect_flags |
716 [ "$acl" -lt 1 ] && skip "must have acl, skipping" && return
718 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
721 $LFS mkdir -i 1 $DIR1/$tdir
722 touch $DIR1/$tdir/f1 || error "touch $DIR1/$tdir/f1"
723 chmod 0755 $DIR1/$tdir/f1 || error "chmod 0755 $DIR1/$tdir/f1"
725 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #1"
726 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
727 error "setfacl $DIR2/$tdir #1"
728 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #2"
729 setfacl -m u:$RUNAS_ID:r-x -m g:$RUNAS_GID:r-x $DIR1/$tdir ||
730 error "setfacl $DIR2/$tdir #2"
731 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #3"
732 setfacl -m u:$RUNAS_ID:--- -m g:$RUNAS_GID:--- $DIR1/$tdir ||
733 error "setfacl $DIR2/$tdir #3"
734 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 && error "checkstat $DIR2/$tdir/f1 #4"
735 setfacl -x u:$RUNAS_ID: -x g:$RUNAS_GID: $DIR1/$tdir ||
736 error "setfacl $DIR2/$tdir #4"
737 $RUNAS $CHECKSTAT $DIR2/$tdir/f1 || error "checkstat $DIR2/$tdir/f1 #5"
741 run_test 25b "change ACL under remote dir on one mountpoint be seen on another"
744 utime $DIR1/f26a -s $DIR2/f26a || error "utime failed for $DIR1/f26a"
746 run_test 26a "allow mtime to get older"
751 echo "aaa" >> $DIR1/$tfile
753 chmod a+x $DIR2/$tfile
754 mt1=`stat -c %Y $DIR1/$tfile`
755 mt2=`stat -c %Y $DIR2/$tfile`
757 if [ x"$mt1" != x"$mt2" ]; then
758 error "not equal mtime, client1: "$mt1", client2: "$mt2"."
761 run_test 26b "sync mtime between ost and mds"
764 cancel_lru_locks $OSC
766 dd if=/dev/zero of=$DIR2/$tfile bs=$((4096+4))k conv=notrunc count=4 seek=3 &
771 dd if=/dev/zero of=$DIR1/$tfile bs=$((16384-1024))k conv=notrunc count=1 seek=4 &
776 dd if=/dev/zero of=$DIR1/$tfile bs=8k conv=notrunc count=1 seek=0
778 lctl set_param -n ldlm.dump_namespaces ""
779 wait $DD1_PID $DD2_PID
780 [ $? -ne 0 ] && lctl dk $TMP/debug || true
782 run_test 27 "align non-overlapping extent locks from request ==="
784 test_28() { # bug 9977
785 ECHO_UUID="ECHO_osc1_UUID"
786 tOST=$($LCTL dl | awk '/-osc-|OSC.*MNT/ { print $4 }' | head -n1)
788 $LFS setstripe $DIR1/$tfile -S 1048576 -i 0 -c 2
789 tOBJID=`$LFS getstripe $DIR1/$tfile | awk '$1 == 1 {print $2}'`
790 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2
794 attach echo_client ECHO_osc1 $ECHO_UUID
798 tECHOID=`$LCTL dl | grep $ECHO_UUID | awk '{ print $1 }'`
799 $LCTL --device $tECHOID destroy "${tOBJID}:0"
807 # reading of 1st stripe should pass
808 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error "dd failed"
809 # reading of 2nd stripe should fail (this stripe was destroyed)
810 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 && error
812 # now, recreating test file
813 dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2 || error "dd failed"
814 # reading of 1st stripe should pass
815 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error "dd failed"
816 # reading of 2nd stripe should pass
817 dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 ||
820 run_test 28 "read/write/truncate file with lost stripes"
822 test_30() { #b=11110, LU-2523
823 test_mkdir $DIR1/$tdir
824 cp -f /bin/bash $DIR1/$tdir/bash
825 /bin/sh -c 'sleep 1; rm -f $DIR2/$tdir/bash; cp /bin/bash $DIR2/$tdir' &
826 $DIR1/$tdir/bash -c 'sleep 2;
827 openfile -f O_RDONLY /proc/$$/exe >& /dev/null; echo $?'
831 run_test 30 "recreate file race"
834 test_mkdir $DIR1/$tdir
835 local writes=$(LANG=C dd if=/dev/zero of=$DIR/$tdir/$tfile \
836 count=1 2>&1 | awk 'BEGIN { FS="+" } /out/ {print $1}')
837 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
838 lctl set_param fail_loc=0x314
839 local reads=$(LANG=C dd if=$DIR2/$tdir/$tfile of=/dev/null 2>&1 |
840 awk 'BEGIN { FS="+" } /in/ {print $1}')
841 [ $reads -eq $writes ] || error "read" $reads "blocks, must be" $writes
843 run_test 31a "voluntary cancel / blocking ast race=============="
846 remote_ost || { skip "local OST" && return 0; }
847 remote_ost_nodsh && skip "remote OST w/o dsh" && return 0
849 # make sure there is no local locks due to destroy
850 wait_mds_ost_sync || error "wait_mds_ost_sync()"
851 wait_delete_completed || error "wait_delete_completed()"
853 test_mkdir $DIR1/$tdir
854 lfs setstripe $DIR/$tdir/$tfile -i 0 -c 1
855 cp /etc/hosts $DIR/$tdir/$tfile
856 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE 0x314
857 lctl set_param fail_loc=0x314
858 #define OBD_FAIL_LDLM_OST_FAIL_RACE 0x316
859 do_facet ost1 lctl set_param fail_loc=0x316
861 cat $DIR2/$tdir/$tfile > /dev/null 2>&1
862 lctl set_param fail_loc=0
863 do_facet ost1 lctl set_param fail_loc=0
864 # cleanup: reconnect the client back
867 run_test 31b "voluntary OST cancel / blocking ast race=============="
869 #LU-14949 - multi-client version of the test 31r in sanity.
871 touch $DIR/$tfile.target
872 touch $DIR/$tfile.source
874 ls -l $DIR/$tfile.target # cache it for sure
876 #OBD_FAIL_LLITE_OPEN_DELAY 0x1419
877 $LCTL set_param fail_loc=0x1419 fail_val=3
878 cat $DIR/$tfile.target &
881 # Guarantee open is waiting before we get here
883 mv $DIR2/$tfile.source $DIR2/$tfile.target
887 if [[ $RC -ne 0 ]]; then
888 error "open with cat failed, rc=$RC"
891 run_test 31r "open-rename(replace) race"
893 test_32b() { # bug 11270
894 remote_ost_nodsh && skip "remote OST with nodsh" && return
897 local facets=$(get_facets OST)
898 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
900 save_lustre_params client "osc.*.contention_seconds" > $p
901 save_lustre_params $facets \
902 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
903 save_lustre_params $facets \
904 "ldlm.namespaces.filter-*.contended_locks" >> $p
905 save_lustre_params $facets \
906 "ldlm.namespaces.filter-*.contention_seconds" >> $p
907 clear_stats $OSC.*.${OSC}_stats
909 # agressive lockless i/o settings
910 do_nodes $(comma_list $(osts_nodes)) \
911 "lctl set_param -n ldlm.namespaces.*.max_nolock_bytes=2000000 \
912 ldlm.namespaces.filter-*.contended_locks=0 \
913 ldlm.namespaces.filter-*.contention_seconds=60"
914 lctl set_param -n $OSC.*.contention_seconds=60
916 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > \
918 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > \
921 [ $(calc_stats $OSC.*.${OSC}_stats lockless_write_bytes) -ne 0 ] ||
922 error "lockless i/o was not triggered"
923 # disable lockless i/o (it is disabled by default)
924 do_nodes $(comma_list $(osts_nodes)) \
925 "lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes=0 \
926 ldlm.namespaces.filter-*.contended_locks=32 \
927 ldlm.namespaces.filter-*.contention_seconds=0"
928 # set contention_seconds to 0 at client too, otherwise Lustre still
929 # remembers lock contention
930 lctl set_param -n $OSC.*.contention_seconds=0
931 clear_stats $OSC.*.${OSC}_stats
933 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > \
935 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > \
938 [ $(calc_stats $OSC.*.${OSC}_stats lockless_write_bytes) -eq 0 ] ||
939 error "lockless i/o works when disabled"
941 restore_lustre_params <$p
944 # Disable test 32b prior to full removal
945 #run_test 32b "lockless i/o"
949 local mdts=$(get_facets MDS)
954 for mds in ${mdts//,/ }; do
956 dev=$(basename $(do_facet $mds "lctl get_param -n osd*.${!varsvc}.mntdev|\
957 xargs readlink -f" ))
958 val=$(do_facet $mds "cat /proc/fs/jbd*/${dev}{,:*,-*}/info 2>/dev/null |
961 stat=$(( stat + val))
966 # commit on sharing tests
968 remote_mds_nodsh && skip "remote MDS with nodsh" && return
970 [ -z "$CLIENTS" ] && skip "Need two or more clients, have $CLIENTS"
971 [ $CLIENTCOUNT -lt 2 ] &&
972 skip "Need two or more clients, have $CLIENTCOUNT"
974 local nfiles=${TEST33_NFILES:-10000}
975 local param_file=$TMP/$tfile-params
981 save_lustre_params $(get_facets MDS) \
982 "mdt.*.commit_on_sharing" > $param_file
985 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
989 do_nodes $CLIENT1,$CLIENT2 "mkdir -p $DIR1/$tdir-\\\$(hostname)-$i"
991 [ "$mds1_FSTYPE" = ldiskfs ] && jbdold=$(print_jbd_stat)
992 echo "=== START createmany old: $jbdold transaction"
993 local elapsed=$(do_and_time "do_nodes $CLIENT1,$CLIENT2 createmany -o $DIR1/$tdir-\\\$(hostname)-$i/f- -r$DIR2/$tdir-\\\$(hostname)-$i/f- $nfiles > /dev/null 2>&1")
994 [ "$mds1_FSTYPE" = ldiskfs ] && jbdnew=$(print_jbd_stat)
995 [ "$mds1_FSTYPE" = ldiskfs ] && jbd=$(( jbdnew - jbdold ))
996 echo "=== END createmany new: $jbdnew transaction : $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
997 [ "$mds1_FSTYPE" = ldiskfs ] && avgjbd=$(( avgjbd + jbd ))
998 avgtime=$(( avgtime + elapsed ))
1000 eval cos${COS}_jbd=$((avgjbd / 3))
1001 eval cos${COS}_time=$((avgtime / 3))
1004 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
1005 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
1006 [ "$cos0_jbd" != 0 ] &&
1007 echo "COS=1 vs COS=0 jbd: $((((cos1_jbd/cos0_jbd - 1)) * 100 )) %"
1008 [ "$cos0_time" != 0 ] &&
1009 echo "COS=1 vs COS=0 time: $((((cos1_time/cos0_time - 1)) * 100 )) %"
1011 restore_lustre_params < $param_file
1015 run_test 33a "commit on sharing, cross crete/delete, 2 clients, benchmark"
1017 # commit on sharing tests
1019 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1021 [ -n "$CLIENTS" ] || { skip "Need two or more clients" && return 0; }
1022 [ $CLIENTCOUNT -ge 2 ] ||
1023 { skip "Need two or more clients, have $CLIENTCOUNT" &&
1025 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1027 local nfiles=${TEST33_NFILES:-10000}
1028 local param_file=$TMP/$tfile-params
1030 save_lustre_params $(get_facets MDS) \
1031 "mdt.*.commit_on_sharing" > $param_file
1040 do_facet $SINGLEMDS lctl set_param mdt.*.commit_on_sharing=$COS
1044 do_node $CLIENT1 "$LFS mkdir -i $MDTIDX \
1045 $DIR1/$tdir-\\\$(hostname)-$i"
1047 jbdold=$(print_jbd_stat)
1048 echo "=== START createmany old: $jbdold transaction"
1049 local elapsed=$(do_and_time "do_nodes $CLIENT1,$CLIENT2\
1050 createmany -o $DIR1/$tdir-\\\$(hostname)-$i/f- \
1051 -r$DIR2/$tdir-\\\$(hostname)-$i/f- $nfiles > \
1053 jbdnew=$(print_jbd_stat)
1054 jbd=$(( jbdnew - jbdold ))
1055 echo "=== END createmany new: $jbdnew transaction : \
1056 $jbd transactions nfiles $nfiles time $elapsed COS=$COS"
1057 avgjbd=$(( avgjbd + jbd ))
1058 avgtime=$(( avgtime + elapsed ))
1060 eval cos${COS}_jbd=$((avgjbd / 3))
1061 eval cos${COS}_time=$((avgtime / 3))
1064 echo "COS=0 transactions (avg): $cos0_jbd time (avg): $cos0_time"
1065 echo "COS=1 transactions (avg): $cos1_jbd time (avg): $cos1_time"
1066 [ "$cos0_jbd" != 0 ] &&
1067 echo "COS=1 vs COS=0 jbd: $(((cos1_jbd/cos0_jbd - 1) * 100)) %"
1068 [ "$cos0_time" != 0 ] &&
1069 echo "COS=1 vs COS=0 time: $(((cos1_time/cos0_time - 1) * 100)) %"
1071 restore_lustre_params < $param_file
1075 run_test 33b "COS: cross create/delete, 2 clients, benchmark under remote dir"
1078 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
1079 [ "$MDS1_VERSION" -lt $(version_code 2.7.63) ] &&
1080 skip "DNE CoS not supported"
1084 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS || error "start mds1 failed"
1088 mkdir_on_mdt0 $DIR/$tdir
1090 do_facet mds1 "lctl set_param -n mdt.*.sync_count=0"
1091 # do twice in case transaction is committed before unlock, see LU-8200
1093 # remote dir is created on MDT1, which enqueued lock of $tdir on
1095 $LFS mkdir -i 1 $DIR/$tdir/remote.$i
1096 mkdir $DIR/$tdir/local.$i
1098 sync_count=$(do_facet mds1 "lctl get_param -n mdt.*MDT0000.sync_count")
1099 echo "sync_count $sync_count"
1100 [ $sync_count -eq 0 ] && error "Sync-Lock-Cancel not triggered"
1103 do_facet mds1 "lctl set_param -n mdt.*.sync_count=0"
1104 $LFS mkdir -i 1 $DIR/$tdir/remote.3
1105 # during sleep remote mkdir should have been committed and canceled
1106 # remote lock spontaneously, which shouldn't trigger sync
1108 mkdir $DIR/$tdir/local.3
1109 sync_count=$(do_facet mds1 "lctl get_param -n mdt.*MDT0000.sync_count")
1110 echo "sync_count $sync_count"
1111 [ $sync_count -eq 0 ] || error "Sync-Lock-Cancel triggered"
1113 run_test 33c "Cancel cross-MDT lock should trigger Sync-Lock-Cancel"
1115 # arg1 is operations done before CoS, arg2 is the operation that triggers CoS
1119 local nodes=$(comma_list $(mdts_nodes))
1123 # trigger CoS twice in case transaction commit before unlock
1126 do_nodes $nodes "lctl set_param -n mdt.*.async_commit_count=0"
1128 commit_nr=$(do_nodes $nodes \
1129 "lctl get_param -n mdt.*.async_commit_count" | calc_sum)
1130 total=$((total + commit_nr));
1135 echo "CoS count $total"
1136 [ $total -gt 0 ] || error "$2 didn't trigger CoS"
1140 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
1141 [ "$MDS1_VERSION" -lt $(version_code 2.7.63) ] &&
1142 skip "DNE CoS not supported"
1144 # remote directory create
1145 op_trigger_cos "$LFS mkdir -i 0 $DIR/$tdir" "$LFS mkdir -i 1 $DIR/$tdir/subdir"
1146 # remote directory unlink
1147 op_trigger_cos "$LFS mkdir -i 1 $DIR/$tdir" "rmdir $DIR/$tdir"
1148 # striped directory create
1149 op_trigger_cos "mkdir $DIR/$tdir" "$LFS mkdir -c 2 $DIR/$tdir/subdir"
1150 # striped directory setattr
1151 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; touch $DIR/$tdir" \
1152 "chmod 713 $DIR/$tdir"
1153 # striped directory unlink
1154 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; touch $DIR/$tdir" \
1157 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; \
1158 $LFS mkdir -i 0 $DIR/$tdir/d1; \
1159 $LFS mkdir -i 1 $DIR/$tdir/d2; \
1160 touch $DIR/$tdir/d1/tgt" \
1161 "ln $DIR/$tdir/d1/tgt $DIR/$tdir/d2/src"
1163 op_trigger_cos "$LFS mkdir -c 2 $DIR/$tdir; \
1164 $LFS mkdir -i 0 $DIR/$tdir/d1; \
1165 $LFS mkdir -i 1 $DIR/$tdir/d2; \
1166 touch $DIR/$tdir/d1/src" \
1167 "mv $DIR/$tdir/d1/src $DIR/$tdir/d2/tgt"
1169 op_trigger_cos "$LFS mkdir -i 0 $DIR/$tdir" \
1170 "$LFS migrate -m 1 $DIR/$tdir"
1174 run_test 33d "DNE distributed operation should trigger COS"
1177 [ -n "$CLIENTS" ] || skip "Need two or more clients"
1178 [ $CLIENTCOUNT -ge 2 ] ||
1179 skip "Need two or more clients, have $CLIENTCOUNT"
1180 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
1181 [ "$MDS1_VERSION" -lt $(version_code 2.7.63) ] &&
1182 skip "DNE CoS not supported"
1184 local client2=${CLIENT2:-$(hostname)}
1188 local nodes=$(comma_list $(mdts_nodes))
1189 do_nodes $nodes "lctl set_param -n mdt.*.async_commit_count=0"
1191 $LFS mkdir -c 2 $DIR/$tdir
1192 mkdir $DIR/$tdir/subdir
1193 echo abc > $DIR/$tdir/$tfile
1194 do_node $client2 echo dfg >> $DIR/$tdir/$tfile
1195 do_node $client2 touch $DIR/$tdir/subdir
1197 local async_commit_count=$(do_nodes $nodes \
1198 "lctl get_param -n mdt.*.async_commit_count" | calc_sum)
1199 [ $async_commit_count -gt 0 ] && error "CoS triggerred"
1203 run_test 33e "DNE local operation shouldn't trigger COS"
1205 # End commit on sharing tests
1207 get_ost_lock_timeouts() {
1208 local nodes=${1:-$(comma_list $(osts_nodes))}
1210 local locks=$(do_nodes $nodes \
1211 "lctl get_param -n ldlm.namespaces.filter-*.lock_timeouts" | calc_sum)
1219 do_nodes $(comma_list $(osts_nodes)) \
1220 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1221 for i in $(seq $OSTCOUNT); do
1222 wait_osc_import_ready client ost$i
1227 remote_ost_nodsh && skip "remote OST with nodsh" && return
1231 trap cleanup_34 EXIT RETURN
1232 for OPER in notimeout timeout ; do
1233 rm $DIR1/$tfile 2>/dev/null
1234 lock_in=$(get_ost_lock_timeouts)
1235 if [ $OPER == "timeout" ] ; then
1236 for j in `seq $OSTCOUNT`; do
1237 #define OBD_FAIL_PTLRPC_HPREQ_TIMEOUT 0x511
1238 do_facet ost$j lctl set_param fail_loc=0x511
1240 echo lock should expire
1242 for j in `seq $OSTCOUNT`; do
1243 #define OBD_FAIL_PTLRPC_HPREQ_NOTIMEOUT 0x512
1244 do_facet ost$j lctl set_param fail_loc=0x512
1246 echo lock should not expire
1248 echo writing on client1
1249 dd if=/dev/zero of=$DIR1/$tfile count=100 conv=notrunc > /dev/null 2>&1
1251 echo reading on client2
1252 dd of=/dev/null if=$DIR2/$tfile > /dev/null 2>&1
1253 # wait for a lock timeout
1255 lock_out=$(get_ost_lock_timeouts)
1256 if [ $OPER == "timeout" ] ; then
1257 if [ $lock_in == $lock_out ]; then
1258 error "no lock timeout happened"
1263 if [ $lock_in != $lock_out ]; then
1264 error "lock timeout happened"
1272 run_test 34 "no lock timeout under IO"
1274 test_35() { # bug 17645
1277 gen=$(lctl get_param mdc.$FSNAME-MDT*-mdc-*.import | grep generation |
1278 awk '/generation/{print $2}')
1280 generation[count]=$g
1284 test_mkdir $MOUNT1/$tdir
1285 cancel_lru_locks mdc
1287 # Let's initiate -EINTR situation by setting fail_loc and take
1288 # write lock on same file from same client. This will not cause
1289 # bl_ast yet as lock is already in local cache.
1290 #define OBD_FAIL_LDLM_INTR_CP_AST 0x317
1291 do_facet client "lctl set_param fail_loc=0x80000317"
1292 local timeout=$(do_facet $SINGLEMDS lctl get_param -n timeout)
1293 let timeout=timeout*3
1295 while test $nr -lt 10; do
1296 log "Race attempt $nr"
1297 local blk1=$(lctl get_param -n ldlm.services.ldlm_cbd.stats |
1298 awk '/ldlm_bl_callback/ { print $2 }')
1299 test "x$blk1" = "x" && blk1=0
1300 createmany -o $MOUNT2/$tdir/a 4000 &
1304 # Let's make conflict and bl_ast
1305 ls -la $MOUNT1/$tdir > /dev/null &
1308 log "Wait for $pid1 $pid2 for $timeout sec..."
1310 kill -9 $pid1 $pid2 > /dev/null 2>&1
1312 local blk2=$(lctl get_param -n ldlm.services.ldlm_cbd.stats |
1313 awk '/ldlm_bl_callback/ { print $2 }')
1314 test "x$blk2" = "x" && blk2=0
1315 test $blk2 -gt $blk1 && break
1316 rm -fr $MOUNT1/$tdir
1317 cancel_lru_locks mdc
1320 do_facet client "lctl set_param fail_loc=0x0"
1321 df -h $MOUNT1 $MOUNT2
1323 gen=$(lctl get_param mdc.$FSNAME-MDT*-mdc-*.import | grep generation |
1324 awk '/generation/{print $2}')
1326 if ! test "$g" -eq "${generation[count]}"; then
1327 list=$(lctl list_param mdc.$FSNAME-MDT*-mdc-*.import)
1329 for imp in $list; do
1330 if [ $c = $count ]; then
1335 imp=$(echo "$imp" | awk -F"." '{print $2}')
1336 error "Eviction happened on import $imp"
1341 run_test 35 "-EINTR cp_ast vs. bl_ast race does not evict client"
1343 test_36() { #bug 16417
1348 test_mkdir $DIR1/$tdir
1349 $LFS setstripe -c -1 $DIR1/$tdir
1352 let SIZE_B=SIZE*1024*1024
1353 sync; sleep 2; sync # wait for delete thread
1354 wait_mds_ost_sync || error "wait_mds_ost_sync failed"
1355 wait_destroy_complete || error "wait_destroy_complete failed"
1357 while [ $i -le 10 ]; do
1358 lctl mark "start test - cycle ($i)"
1359 local before=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1360 dd if=/dev/zero of=$DIR1/$tdir/$tfile bs=1M count=$SIZE ||
1361 error "dd $DIR1/$tdir/$tfile ${SIZE}MB failed"
1362 sync # sync data from client cache
1363 sync_all_data # sync data from server cache (delayed allocation)
1365 local after_dd=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1366 multiop_bg_pause $DIR2/$tdir/$tfile O_r${SIZE_B}c || return 3
1368 rm -f $DIR1/$tdir/$tfile
1369 kill -USR1 $read_pid
1371 sync; sleep 2; sync # Ensure new statfs
1372 wait_delete_completed
1373 local after=$(lfs_df $MOUNT1 | awk '/^filesystem/{ print $4; exit }')
1374 echo "*** cycle($i) *** before($before) after_dd($after_dd)" \
1376 # this free space! not used
1377 (( $after_dd <= $after)) ||
1378 error "space leaked after_dd:$after_dd > after:$after"
1382 run_test 36 "handle ESTALE/open-unlink correctly"
1384 test_37() { # bug 18695
1385 test_mkdir $DIR1/$tdir
1386 multiop_bg_pause $DIR1/$tdir D_c || return 1
1388 # create large directory (32kB seems enough from e2fsck, ~= 1000 files)
1389 createmany -m $DIR2/$tdir/f 10000
1390 # set mtime/atime backward
1391 touch -t 198001010000 $DIR2/$tdir
1392 kill -USR1 $MULTIPID
1393 nr_files=`lfs find $DIR1/$tdir -type f | wc -l`
1394 [ $nr_files -eq 10000 ] || error "$nr_files != 10000 truncated directory?"
1397 run_test 37 "check i_size is not updated for directory on close (bug 18695) =============="
1399 # this should be set to past
1400 TEST_39_MTIME=`date -d "1 year ago" +%s`
1404 local client1=${CLIENT1:-`hostname`}
1405 local client2=${CLIENT2:-`hostname`}
1407 do_node $client1 "touch $DIR1/$tfile"
1409 do_node $client1 "touch -m -d @$TEST_39_MTIME $DIR1/$tfile"
1410 local mtime1=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1411 [ "$mtime1" = $TEST_39_MTIME ] || \
1412 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
1414 local d1=`do_node $client1 date +%s`
1415 do_node $client1 'echo hello >> '$DIR1/$tfile
1416 local d2=`do_node $client1 date +%s`
1418 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1419 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
1420 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
1422 do_node $client1 "mv $DIR1/$tfile $DIR1/$tfile-1"
1424 for (( i=0; i < 2; i++ )) ; do
1425 local mtime3=`do_node $client2 "stat -c %Y $DIR1/$tfile-1"`
1426 [ "$mtime2" = "$mtime3" ] || \
1427 error "mtime ($mtime2) changed (to $mtime3) on rename"
1429 cancel_lru_locks osc
1430 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1433 run_test 39a "test from 11063 =================================="
1436 local client1=${CLIENT1:-`hostname`}
1437 local client2=${CLIENT2:-`hostname`}
1441 local mtime1=`stat -c %Y $DIR1/$tfile`
1442 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1445 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
1447 for (( i=0; i < 2; i++ )) ; do
1448 local mtime3=`stat -c %Y $DIR1/$tfile`
1449 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1451 [ "$mtime3" = "$mtime4" ] || \
1452 error "different mtime on clients: $mtime3, $mtime4"
1453 [ "$mtime3" = $TEST_39_MTIME ] || \
1454 error "lost mtime: $mtime3, should be $TEST_39_MTIME"
1456 cancel_lru_locks osc
1457 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1460 run_test 39b "11063 problem 1 =================================="
1463 local client1=${CLIENT1:-`hostname`}
1464 local client2=${CLIENT2:-`hostname`}
1466 echo hello > $DIR1/$tfile
1468 local mtime1=`stat -c %Y $DIR1/$tfile`
1469 local mtime2=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1470 [ "$mtime1" = "$mtime2" ] || \
1471 error "create: different mtime on clients: $mtime1, $mtime2"
1474 $TRUNCATE $DIR1/$tfile 1
1476 for (( i=0; i < 2; i++ )) ; do
1477 local mtime3=`stat -c %Y $DIR1/$tfile`
1478 local mtime4=`do_node $client2 "stat -c %Y $DIR1/$tfile"`
1480 [ "$mtime3" = "$mtime4" ] || \
1481 error "different mtime on clients: $mtime3, $mtime4"
1482 [ "$mtime3" -gt $mtime2 ] || \
1483 error "truncate did not update mtime: $mtime2, $mtime3"
1485 cancel_lru_locks osc
1486 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
1489 run_test 39c "check truncate mtime update ======================"
1491 test_39d() { # LU-7310
1493 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
1495 local mtime1=$(stat -c %Y $DIR2/$tfile)
1496 [ "$mtime1" = $TEST_39_MTIME ] ||
1497 error "mtime: $mtime1, should be $TEST_39_MTIME"
1500 # define OBD_FAIL_OSC_NO_GRANT 0x411
1501 $LCTL set_param fail_loc=0x411
1503 local d1=$(date +%s)
1504 echo hello >> $DIR1/$tfile
1505 local d2=$(date +%s)
1507 $LCTL set_param fail_loc=0
1509 cancel_lru_locks $OSC
1511 local mtime2=$(stat -c %Y $DIR2/$tfile)
1512 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] ||
1513 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
1515 run_test 39d "sync write should update mtime"
1518 # how long 40-47 take with specific delay
1525 # for pdo testing, we must cancel MDT-MDT locks as well as client locks to
1526 # avoid unexpected delays due to previous tests
1528 cancel_lru_locks mdc
1529 do_nodes $(comma_list $(mdts_nodes)) \
1530 $LCTL set_param -n ldlm.namespaces.*mdt*.lru_size=clear
1531 do_nodes $(comma_list $(mdts_nodes)) \
1532 $LCTL get_param ldlm.namespaces.*mdt*.lock_unused_count \
1533 ldlm.namespaces.*mdt*.lock_count | grep -v '=0'
1536 # check that pid exists hence second operation wasn't blocked by first one
1537 # if it is so then there is no conflict, return 0
1538 # else second operation is conflicting with first one, return 1
1539 check_pdo_conflict() {
1542 pdo_sched # to ensure OP1 is finished on client if OP2 is blocked by OP1
1543 if [[ `ps --pid $pid | wc -l` == 1 ]]; then
1553 # test 40: check non-blocking operations
1555 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1557 mkdir_on_mdt0 $DIR2/$tdir
1559 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1560 do_nodes $(comma_list $(mdts_nodes)) \
1561 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1562 mkdir $DIR1/$tdir/$tfile &
1564 touch $DIR2/$tdir/$tfile-2
1565 check_pdo_conflict $PID1 || error "create is blocked"
1566 mkdir $DIR2/$tdir/$tfile-3
1567 check_pdo_conflict $PID1 || error "mkdir is blocked"
1568 link $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-4
1569 check_pdo_conflict $PID1 || error "link is blocked"
1570 mv $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-5
1571 check_pdo_conflict $PID1 || error "rename is blocked"
1572 stat $DIR2/$tdir/$tfile-3 $DIR2/$tdir/$tfile-4 > /dev/null
1573 check_pdo_conflict $PID1 || error "getattr is blocked"
1574 rm $DIR2/$tdir/$tfile-4 $DIR2/$tdir/$tfile-5
1575 rmdir $DIR2/$tdir/$tfile-3
1576 check_pdo_conflict $PID1 || error "unlink is blocked"
1578 # all operations above shouldn't wait the first one
1579 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1580 do_nodes $(comma_list $(mdts_nodes)) \
1581 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1586 run_test 40a "pdirops: create vs others =============="
1589 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1591 mkdir_on_mdt0 $DIR2/$tdir
1593 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1594 do_nodes $(comma_list $(mdts_nodes)) \
1595 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1596 touch $DIR1/$tdir/$tfile &
1599 touch $DIR2/$tdir/$tfile-2
1600 check_pdo_conflict $PID1 || error "create is blocked"
1601 mkdir $DIR2/$tdir/$tfile-3
1602 check_pdo_conflict $PID1 || error "mkdir is blocked"
1603 link $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-4
1604 check_pdo_conflict $PID1 || error "link is blocked"
1605 mv $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-5
1606 check_pdo_conflict $PID1 || error "rename is blocked"
1607 stat $DIR2/$tdir/$tfile-3 $DIR2/$tdir/$tfile-4 > /dev/null
1608 check_pdo_conflict $PID1 || error "getattr is blocked"
1609 rm $DIR2/$tdir/$tfile-4 $DIR2/$tdir/$tfile-5
1610 rmdir $DIR2/$tdir/$tfile-3
1611 check_pdo_conflict $PID1 || error "unlink is blocked"
1612 # all operations above shouldn't wait the first one
1614 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1615 do_nodes $(comma_list $(mdts_nodes)) \
1616 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1621 run_test 40b "pdirops: open|create and others =============="
1624 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1626 mkdir_on_mdt0 $DIR2/$tdir
1628 touch $DIR1/$tdir/$tfile
1629 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1630 do_nodes $(comma_list $(mdts_nodes)) \
1631 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1632 link $DIR1/$tdir/$tfile $DIR1/$tdir/$tfile-0 &
1635 touch $DIR2/$tdir/$tfile-2
1636 check_pdo_conflict $PID1 || error "create is blocked"
1637 mkdir $DIR2/$tdir/$tfile-3
1638 check_pdo_conflict $PID1 || error "mkdir is blocked"
1639 link $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-4
1640 check_pdo_conflict $PID1 || error "link is blocked"
1641 mv $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-5
1642 check_pdo_conflict $PID1 || error "rename is blocked"
1643 stat $DIR2/$tdir/$tfile-3 $DIR2/$tdir/$tfile-4 > /dev/null
1644 check_pdo_conflict $PID1 || error "getattr is blocked"
1645 rm $DIR2/$tdir/$tfile-4 $DIR2/$tdir/$tfile-5
1646 rmdir $DIR2/$tdir/$tfile-3
1647 check_pdo_conflict $PID1 || error "unlink is blocked"
1649 # all operations above shouldn't wait the first one
1650 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1651 do_nodes $(comma_list $(mdts_nodes)) \
1652 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1657 run_test 40c "pdirops: link and others =============="
1660 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1662 mkdir_on_mdt0 $DIR2/$tdir
1664 touch $DIR1/$tdir/$tfile
1665 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1666 do_nodes $(comma_list $(mdts_nodes)) \
1667 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1668 rm $DIR1/$tdir/$tfile &
1671 touch $DIR2/$tdir/$tfile-2
1672 check_pdo_conflict $PID1 || error "create is blocked"
1673 mkdir $DIR2/$tdir/$tfile-3
1674 check_pdo_conflict $PID1 || error "mkdir is blocked"
1675 link $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-4
1676 check_pdo_conflict $PID1 || error "link is blocked"
1677 mv $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-5
1678 check_pdo_conflict $PID1 || error "rename is blocked"
1679 stat $DIR2/$tdir/$tfile-3 $DIR2/$tdir/$tfile-4 > /dev/null
1680 check_pdo_conflict $PID1 || error "getattr is blocked"
1681 rm $DIR2/$tdir/$tfile-4 $DIR2/$tdir/$tfile-5
1682 rmdir $DIR2/$tdir/$tfile-3
1683 check_pdo_conflict $PID1 || error "unlink is blocked"
1685 # all operations above shouldn't wait the first one
1686 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1687 do_nodes $(comma_list $(mdts_nodes)) \
1688 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1692 run_test 40d "pdirops: unlink and others =============="
1695 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1697 mkdir_on_mdt0 $DIR2/$tdir
1699 touch $DIR1/$tdir/$tfile
1700 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1701 do_nodes $(comma_list $(mdts_nodes)) \
1702 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1703 mv $DIR1/$tdir/$tfile $DIR1/$tdir/$tfile-0 &
1706 touch $DIR2/$tdir/$tfile-2
1707 check_pdo_conflict $PID1 || error "create is blocked"
1708 mkdir $DIR2/$tdir/$tfile-3
1709 check_pdo_conflict $PID1 || error "mkdir is blocked"
1710 link $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-4
1711 check_pdo_conflict $PID1 || error "link is blocked"
1712 stat $DIR2/$tdir/$tfile-3 $DIR2/$tdir/$tfile-4 > /dev/null
1713 check_pdo_conflict $PID1 || error "getattr is blocked"
1714 rm $DIR2/$tdir/$tfile-4 $DIR2/$tdir/$tfile-2
1715 rmdir $DIR2/$tdir/$tfile-3
1716 check_pdo_conflict $PID1 || error "unlink is blocked"
1718 # all operations above shouldn't wait the first one
1719 check_pdo_conflict $PID1 || error "parallel operation is blocked"
1720 do_nodes $(comma_list $(mdts_nodes)) \
1721 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1726 run_test 40e "pdirops: rename and others =============="
1728 # test 41: create blocking operations
1731 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1732 do_nodes $(comma_list $(mdts_nodes)) \
1733 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1734 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1736 mkdir $DIR2/$tfile &
1738 do_nodes $(comma_list $(mdts_nodes)) \
1739 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1740 check_pdo_conflict $PID1 && { wait $PID1; echo "mkdir isn't blocked"; }
1741 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
1745 run_test 41a "pdirops: create vs mkdir =============="
1749 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1750 do_nodes $(comma_list $(mdts_nodes)) \
1751 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1752 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1754 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
1756 do_nodes $(comma_list $(mdts_nodes)) \
1757 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1758 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1759 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
1763 run_test 41b "pdirops: create vs create =============="
1767 touch $DIR1/$tfile-2
1768 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1769 do_nodes $(comma_list $(mdts_nodes)) \
1770 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1771 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1773 link $DIR2/$tfile-2 $DIR2/$tfile &
1775 do_nodes $(comma_list $(mdts_nodes)) \
1776 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1777 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1778 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
1782 run_test 41c "pdirops: create vs link =============="
1786 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1787 do_nodes $(comma_list $(mdts_nodes)) \
1788 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1789 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1793 do_nodes $(comma_list $(mdts_nodes)) \
1794 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1795 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1796 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
1800 run_test 41d "pdirops: create vs unlink =============="
1804 touch $DIR1/$tfile-2
1805 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1806 do_nodes $(comma_list $(mdts_nodes)) \
1807 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1808 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1810 mv $DIR2/$tfile-2 $DIR2/$tfile &
1812 do_nodes $(comma_list $(mdts_nodes)) \
1813 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1814 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1815 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
1819 run_test 41e "pdirops: create and rename (tgt) =============="
1823 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1824 do_nodes $(comma_list $(mdts_nodes)) \
1825 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1826 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1828 mv $DIR2/$tfile $DIR2/$tfile-2 &
1830 do_nodes $(comma_list $(mdts_nodes)) \
1831 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1832 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
1833 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
1837 run_test 41f "pdirops: create and rename (src) =============="
1841 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1842 do_nodes $(comma_list $(mdts_nodes)) \
1843 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1844 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1846 stat $DIR2/$tfile > /dev/null &
1848 do_nodes $(comma_list $(mdts_nodes)) \
1849 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1850 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
1851 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
1855 run_test 41g "pdirops: create vs getattr =============="
1859 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1860 do_nodes $(comma_list $(mdts_nodes)) \
1861 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1862 $MULTIOP $DIR1/$tfile oO_CREAT:O_RDWR:c &
1864 ls -lia $DIR2/ > /dev/null &
1866 do_nodes $(comma_list $(mdts_nodes)) \
1867 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1868 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
1873 run_test 41h "pdirops: create vs readdir =============="
1880 do_nodes $(comma_list $(mdts_nodes)) \
1881 "lctl set_param -n fail_loc=${fail_loc} || true" &>/dev/null
1883 $MULTIOP $DIR1/$tfile oO_CREAT:O_EXCL:c 2>/dev/null &
1886 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c 2>/dev/null &
1889 if ! wait $PID1 && ! wait $PID2; then
1890 echo "Both creates failed (1 should fail, 1 should succeed)"
1892 elif wait $PID1 && wait $PID2; then
1893 echo "Both creates succeeded (1 should fail, 1 should succeed)"
1898 do_nodes $(comma_list $(mdts_nodes)) \
1899 "lctl set_param -n fail_loc=0x0 || true" &>/dev/null
1906 [[ $MDS1_VERSION -le $(version_code 2.13.56) ]] ||
1907 skip "Need MDS version newer than 2.13.56"
1910 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN 0x169
1911 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN2 0x16a
1912 for fail_loc in "0x80000169" "0x8000016a"; do
1913 echo "Begin 100 tests with fail_loc=$fail_loc"
1915 for i in {1..100}; do
1917 msg=$(sub_test_41i "$fail_loc") ||
1918 { echo; error "iter=$i : $msg"; }
1923 run_test 41i "reint_open: create vs create"
1926 # test 42: unlink and blocking operations
1929 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1930 do_nodes $(comma_list $(mdts_nodes)) \
1931 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1932 mkdir $DIR1/$tfile &
1934 mkdir $DIR2/$tfile &
1936 do_nodes $(comma_list $(mdts_nodes)) \
1937 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1938 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
1939 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
1943 run_test 42a "pdirops: mkdir vs mkdir =============="
1947 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1948 do_nodes $(comma_list $(mdts_nodes)) \
1949 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1950 mkdir $DIR1/$tfile &
1952 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
1954 do_nodes $(comma_list $(mdts_nodes)) \
1955 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1956 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
1957 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
1961 run_test 42b "pdirops: mkdir vs create =============="
1965 touch $DIR1/$tfile-2
1966 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1967 do_nodes $(comma_list $(mdts_nodes)) \
1968 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1969 mkdir $DIR1/$tfile &
1971 link $DIR2/$tfile-2 $DIR2/$tfile &
1973 do_nodes $(comma_list $(mdts_nodes)) \
1974 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1975 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
1976 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
1980 run_test 42c "pdirops: mkdir vs link =============="
1984 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
1985 do_nodes $(comma_list $(mdts_nodes)) \
1986 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
1987 mkdir $DIR1/$tfile &
1989 rmdir $DIR2/$tfile &
1991 do_nodes $(comma_list $(mdts_nodes)) \
1992 "lctl set_param -n fail_loc=0 2>/dev/null || true"
1993 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
1994 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
1998 run_test 42d "pdirops: mkdir vs unlink =============="
2002 touch $DIR1/$tfile-2
2003 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2004 do_nodes $(comma_list $(mdts_nodes)) \
2005 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2006 mkdir $DIR1/$tfile &
2008 mv -T $DIR2/$tfile-2 $DIR2/$tfile &
2010 do_nodes $(comma_list $(mdts_nodes)) \
2011 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2012 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2013 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
2017 run_test 42e "pdirops: mkdir and rename (tgt) =============="
2021 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2022 do_nodes $(comma_list $(mdts_nodes)) \
2023 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2024 mkdir $DIR1/$tfile &
2026 mv $DIR2/$tfile $DIR2/$tfile-2 &
2028 do_nodes $(comma_list $(mdts_nodes)) \
2029 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2030 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2031 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2035 run_test 42f "pdirops: mkdir and rename (src) =============="
2038 mkdir_on_mdt0 $DIR1/$tdir
2040 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2041 do_nodes $(comma_list $(mdts_nodes)) \
2042 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2043 mkdir $DIR1/$tdir/$tfile &
2045 stat $DIR2/$tdir/$tfile > /dev/null &
2047 do_nodes $(comma_list $(mdts_nodes)) \
2048 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2049 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2050 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
2053 run_test 42g "pdirops: mkdir vs getattr =============="
2057 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2058 do_nodes $(comma_list $(mdts_nodes)) \
2059 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2060 mkdir $DIR1/$tfile &
2062 ls -lia $DIR2/ > /dev/null &
2064 do_nodes $(comma_list $(mdts_nodes)) \
2065 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2066 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2071 run_test 42h "pdirops: mkdir vs readdir =============="
2073 # test 43: rmdir,mkdir won't return -EEXIST
2075 for i in {1..1000}; do
2076 mkdir $DIR1/$tdir || error "mkdir $tdir failed"
2077 rmdir $DIR2/$tdir || error "rmdir $tdir failed"
2081 run_test 43a "rmdir,mkdir doesn't return -EEXIST =============="
2086 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2087 do_nodes $(comma_list $(mdts_nodes)) \
2088 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2091 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2093 do_nodes $(comma_list $(mdts_nodes)) \
2094 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2095 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2096 wait $PID2 ; [ $? -eq 0 ] || error "create must succeed"
2100 run_test 43b "pdirops: unlink vs create =============="
2105 touch $DIR1/$tfile-2
2106 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2107 do_nodes $(comma_list $(mdts_nodes)) \
2108 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2111 link $DIR2/$tfile-2 $DIR2/$tfile &
2113 do_nodes $(comma_list $(mdts_nodes)) \
2114 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2115 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2116 wait $PID2 ; [ $? -eq 0 ] || error "link must succeed"
2120 run_test 43c "pdirops: unlink vs link =============="
2125 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2126 do_nodes $(comma_list $(mdts_nodes)) \
2127 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2132 do_nodes $(comma_list $(mdts_nodes)) \
2133 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2134 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2135 wait $PID2 ; [ $? -ne 0 ] || error "unlink must fail"
2139 run_test 43d "pdirops: unlink vs unlink =============="
2144 touch $DIR1/$tfile-2
2145 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2146 do_nodes $(comma_list $(mdts_nodes)) \
2147 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2150 mv -u $DIR2/$tfile-2 $DIR2/$tfile &
2152 do_nodes $(comma_list $(mdts_nodes)) \
2153 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2154 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2155 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2159 run_test 43e "pdirops: unlink and rename (tgt) =============="
2164 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2165 do_nodes $(comma_list $(mdts_nodes)) \
2166 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2169 mv $DIR2/$tfile $DIR2/$tfile-2 &
2171 do_nodes $(comma_list $(mdts_nodes)) \
2172 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2173 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2174 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
2178 run_test 43f "pdirops: unlink and rename (src) =============="
2183 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2184 do_nodes $(comma_list $(mdts_nodes)) \
2185 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2188 stat $DIR2/$tfile > /dev/null &
2190 do_nodes $(comma_list $(mdts_nodes)) \
2191 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2192 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2193 wait $PID2 ; [ $? -ne 0 ] || error "stat must fail"
2197 run_test 43g "pdirops: unlink vs getattr =============="
2202 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2203 do_nodes $(comma_list $(mdts_nodes)) \
2204 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2207 ls -lia $DIR2/ > /dev/null &
2209 do_nodes $(comma_list $(mdts_nodes)) \
2210 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2211 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2216 run_test 43h "pdirops: unlink vs readdir =============="
2219 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2222 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2223 do_nodes $(comma_list $(mdts_nodes)) \
2224 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2227 $LFS mkdir -i 1 $DIR2/$tfile &
2229 do_nodes $(comma_list $(mdts_nodes)) \
2230 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2231 check_pdo_conflict $PID1 &&
2232 { wait $PID1; error "remote mkdir isn't blocked"; }
2233 wait $PID2 ; [ $? -eq 0 ] || error "remote mkdir must succeed"
2237 run_test 43i "pdirops: unlink vs remote mkdir"
2240 [[ $MDS1_VERSION -lt $(version_code 2.13.52) ]] &&
2241 skip "Need MDS version newer than 2.13.52"
2243 mkdir_on_mdt0 $DIR1/$tdir
2244 for i in {1..100}; do
2245 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_CREATE_RACE 0x167
2246 do_nodes $(comma_list $(mdts_nodes)) \
2247 "lctl set_param -n fail_loc=0x80000167 2>/dev/null ||
2250 mkdir $DIR1/$tdir/sub &
2252 mkdir $DIR2/$tdir/sub && ((OK++))
2253 wait $PID1 && ((OK++))
2254 (( OK == 1 )) || error "exactly one mkdir should succeed"
2256 rmdir $DIR1/$tdir/sub || error "rmdir failed"
2260 run_test 43j "racy mkdir return EEXIST =============="
2267 # We test in a separate directory to be able to unblock server thread in
2268 # cfs_race() if LCK_PW is taken on the parent by mdt_reint_unlink.
2269 test_mkdir $DIR2/$tdir
2270 touch $DIR2/$tdir/$tfile
2272 do_nodes $(comma_list $(mdts_nodes)) \
2273 "lctl set_param -n fail_loc=${fail_loc} || true" &>/dev/null
2274 echo content > $DIR1/$tdir/$tfile & PID1=$!
2276 multiop $DIR2/$tdir/$tfile u & PID2=$!
2280 echo -n "overwriting $tfile should succeed (err=$ret); "; }
2283 echo -n "unlinking $tfile should succeed (err=$ret);"; }
2286 do_nodes $(comma_list $(mdts_nodes)) \
2287 "lctl set_param -n fail_loc=0x0 || true" &>/dev/null
2294 [[ $MDS1_VERSION -le $(version_code 2.13.56) ]] ||
2295 skip "Need MDS version newer than 2.13.56"
2298 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN 0x169
2299 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN2 0x16a
2300 for fail_loc in "0x80000169" "0x8000016a"; do
2301 echo "Begin 100 tests with fail_loc=$fail_loc"
2303 for i in {1..100}; do
2305 msg=$(sub_test_43k "$fail_loc") ||
2306 { echo; error "iter=$i : $msg"; }
2316 run_test 43k "unlink vs create"
2318 # test 44: rename tgt and blocking operations
2321 touch $DIR1/$tfile-2
2322 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2323 do_nodes $(comma_list $(mdts_nodes)) \
2324 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2325 mv $DIR1/$tfile-2 $DIR1/$tfile &
2327 mkdir $DIR2/$tfile &
2329 do_nodes $(comma_list $(mdts_nodes)) \
2330 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2331 check_pdo_conflict $PID1 && { wait $PID1; date;error "mkdir isn't blocked"; }
2332 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
2337 run_test 44a "pdirops: rename tgt vs mkdir =============="
2341 touch $DIR1/$tfile-2
2342 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2343 do_nodes $(comma_list $(mdts_nodes)) \
2344 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2345 mv $DIR1/$tfile-2 $DIR1/$tfile &
2347 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2349 do_nodes $(comma_list $(mdts_nodes)) \
2350 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2351 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2352 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
2356 run_test 44b "pdirops: rename tgt vs create =============="
2360 touch $DIR1/$tfile-2
2361 touch $DIR1/$tfile-3
2362 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2363 do_nodes $(comma_list $(mdts_nodes)) \
2364 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2365 mv $DIR1/$tfile-2 $DIR1/$tfile &
2367 link $DIR2/$tfile-3 $DIR2/$tfile &
2369 do_nodes $(comma_list $(mdts_nodes)) \
2370 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2371 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2372 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
2376 run_test 44c "pdirops: rename tgt vs link =============="
2380 touch $DIR1/$tfile-2
2381 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2382 do_nodes $(comma_list $(mdts_nodes)) \
2383 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2384 mv $DIR1/$tfile-2 $DIR1/$tfile &
2388 do_nodes $(comma_list $(mdts_nodes)) \
2389 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2390 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2391 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
2395 run_test 44d "pdirops: rename tgt vs unlink =============="
2400 touch $DIR1/$tfile-2
2401 touch $DIR1/$tfile-3
2402 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2403 do_nodes $(comma_list $(mdts_nodes)) \
2404 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2405 mv $DIR1/$tfile-2 $DIR1/$tfile &
2407 mv $DIR2/$tfile-3 $DIR2/$tfile &
2409 do_nodes $(comma_list $(mdts_nodes)) \
2410 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2411 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2412 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2416 run_test 44e "pdirops: rename tgt and rename (tgt) =============="
2420 touch $DIR1/$tfile-2
2421 touch $DIR1/$tfile-3
2422 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2423 do_nodes $(comma_list $(mdts_nodes)) \
2424 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2425 mv $DIR1/$tfile-2 $DIR1/$tfile &
2427 mv $DIR2/$tfile $DIR2/$tfile-3 &
2429 do_nodes $(comma_list $(mdts_nodes)) \
2430 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2431 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2432 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2436 run_test 44f "pdirops: rename tgt and rename (src) =============="
2440 touch $DIR1/$tfile-2
2441 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2442 do_nodes $(comma_list $(mdts_nodes)) \
2443 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2444 mv $DIR1/$tfile-2 $DIR1/$tfile &
2446 stat $DIR2/$tfile > /dev/null &
2448 do_nodes $(comma_list $(mdts_nodes)) \
2449 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2450 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2451 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
2455 run_test 44g "pdirops: rename tgt vs getattr =============="
2459 touch $DIR1/$tfile-2
2460 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2461 do_nodes $(comma_list $(mdts_nodes)) \
2462 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2463 mv $DIR1/$tfile-2 $DIR1/$tfile &
2465 ls -lia $DIR2/ > /dev/null &
2467 do_nodes $(comma_list $(mdts_nodes)) \
2468 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2469 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2474 run_test 44h "pdirops: rename tgt vs readdir =============="
2476 # test 44: rename tgt and blocking operations
2478 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2480 touch $DIR1/$tfile-2
2481 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK2 0x146
2482 do_nodes $(comma_list $(mdts_nodes)) \
2483 "lctl set_param -n fail_loc=0x80000146 2>/dev/null || true"
2484 mv $DIR1/$tfile-2 $DIR1/$tfile &
2486 $LFS mkdir -i 1 $DIR2/$tfile &
2488 do_nodes $(comma_list $(mdts_nodes)) \
2489 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2490 check_pdo_conflict $PID1 && { wait $PID1;
2491 error "remote mkdir isn't blocked"; }
2492 wait $PID2 ; [ $? -ne 0 ] || error "remote mkdir must fail"
2496 run_test 44i "pdirops: rename tgt vs remote mkdir"
2498 # test 45: rename,mkdir doesn't fail with -EEXIST
2500 for i in {1..1000}; do
2501 mkdir $DIR1/$tdir || error "mkdir $tdir failed"
2502 mrename $DIR2/$tdir $DIR2/$tdir.$i > /dev/null ||
2503 error "mrename to $tdir.$i failed"
2508 run_test 45a "rename,mkdir doesn't return -EEXIST =============="
2513 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2514 do_nodes $(comma_list $(mdts_nodes)) \
2515 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2516 mv $DIR1/$tfile $DIR1/$tfile-2 &
2518 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2520 do_nodes $(comma_list $(mdts_nodes)) \
2521 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2522 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2523 wait $PID2 ; [ $? -eq 0 ] || error "create must succeed"
2527 run_test 45b "pdirops: rename src vs create =============="
2532 touch $DIR1/$tfile-3
2533 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2534 do_nodes $(comma_list $(mdts_nodes)) \
2535 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2536 mv $DIR1/$tfile $DIR1/$tfile-2 &
2538 link $DIR2/$tfile-3 $DIR2/$tfile &
2540 do_nodes $(comma_list $(mdts_nodes)) \
2541 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2542 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2543 wait $PID2 ; [ $? -eq 0 ] || error "link must succeed"
2547 run_test 45c "pdirops: rename src vs link =============="
2552 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2553 do_nodes $(comma_list $(mdts_nodes)) \
2554 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2555 mv $DIR1/$tfile $DIR1/$tfile-2 &
2559 do_nodes $(comma_list $(mdts_nodes)) \
2560 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2561 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2562 wait $PID2 ; [ $? -ne 0 ] || error "unlink must fail"
2566 run_test 45d "pdirops: rename src vs unlink =============="
2571 touch $DIR1/$tfile-3
2572 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2573 do_nodes $(comma_list $(mdts_nodes)) \
2574 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2575 mv $DIR1/$tfile $DIR1/$tfile-2 &
2577 mv $DIR2/$tfile-3 $DIR2/$tfile &
2579 do_nodes $(comma_list $(mdts_nodes)) \
2580 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2581 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2582 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2586 run_test 45e "pdirops: rename src and rename (tgt) =============="
2591 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2592 do_nodes $(comma_list $(mdts_nodes)) \
2593 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2594 mv $DIR1/$tfile $DIR1/$tfile-2 &
2596 mv $DIR2/$tfile $DIR2/$tfile-3 &
2598 do_nodes $(comma_list $(mdts_nodes)) \
2599 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2600 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2601 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
2605 run_test 45f "pdirops: rename src and rename (src) =============="
2610 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2611 do_nodes $(comma_list $(mdts_nodes)) \
2612 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2613 mv $DIR1/$tfile $DIR1/$tfile-2 &
2615 stat $DIR2/$tfile > /dev/null &
2617 do_nodes $(comma_list $(mdts_nodes)) \
2618 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2619 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2620 wait $PID2 ; [ $? -ne 0 ] || error "stat must fail"
2624 run_test 45g "pdirops: rename src vs getattr =============="
2629 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2630 do_nodes $(comma_list $(mdts_nodes)) \
2631 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2632 mv $DIR1/$tfile $DIR1/$tfile-2 &
2634 ls -lia $DIR2/ > /dev/null &
2635 do_nodes $(comma_list $(mdts_nodes)) \
2636 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2637 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2642 run_test 45h "pdirops: unlink vs readdir =============="
2645 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2648 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2649 do_nodes $(comma_list $(mdts_nodes)) \
2650 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2651 mv $DIR1/$tfile $DIR1/$tfile-2 &
2653 $LFS mkdir -i 1 $DIR2/$tfile &
2655 do_nodes $(comma_list $(mdts_nodes)) \
2656 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2657 check_pdo_conflict $PID1 && { wait $PID1;
2658 error "create remote dir isn't blocked"; }
2659 wait $PID2 ; [ $? -eq 0 ] || error "create remote dir must succeed"
2663 run_test 45i "pdirops: rename src vs remote mkdir"
2670 # We test in a sparate directory to be able to unblock server thread in
2671 # cfs_race if LCK_PW is taken on the parent by mdt_reint_rename.
2672 test_mkdir $DIR2/$tdir
2673 echo file1 > $DIR2/$tdir/$tfile
2674 echo file2 > $DIR2/$tdir/$tfile-2
2676 do_nodes $(comma_list $(mdts_nodes)) \
2677 "lctl set_param -n fail_loc=${fail_loc} || true" &>/dev/null
2679 cat $DIR1/$tdir/$tfile >/dev/null &
2682 mrename $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile > /dev/null &
2686 { ret=$?; echo -n "cat $tfile should succeed (err=$ret); "; }
2689 echo -n "mrename $tfile-2 to $tfile failed (err=$ret);"; }
2692 do_nodes $(comma_list $(mdts_nodes)) \
2693 "lctl set_param -n fail_loc=0x0 || true" &>/dev/null
2700 [[ $MDS1_VERSION -le $(version_code 2.13.56) ]] ||
2701 skip "Need MDS version newer than 2.13.56"
2704 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN 0x169
2705 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_REINT_OPEN2 0x16a
2706 for fail_loc in "0x80000169" "0x8000016a"; do
2707 echo "Begin 100 tests with fail_loc=$fail_loc"
2709 for i in {1..100}; do
2711 msg=$(sub_test_45j "$fail_loc") ||
2712 { echo; error "iter=$i : $msg"; }
2717 run_test 45j "read vs rename =============="
2719 # test 46: link and blocking operations
2722 touch $DIR1/$tfile-2
2723 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2724 do_nodes $(comma_list $(mdts_nodes)) \
2725 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2726 link $DIR1/$tfile-2 $DIR1/$tfile &
2728 mkdir $DIR2/$tfile &
2730 do_nodes $(comma_list $(mdts_nodes)) \
2731 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2732 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2733 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
2737 run_test 46a "pdirops: link vs mkdir =============="
2741 touch $DIR1/$tfile-2
2742 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2743 do_nodes $(comma_list $(mdts_nodes)) \
2744 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2745 link $DIR1/$tfile-2 $DIR1/$tfile &
2747 $MULTIOP $DIR2/$tfile oO_CREAT:O_EXCL:c &
2749 do_nodes $(comma_list $(mdts_nodes)) \
2750 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2751 check_pdo_conflict $PID1 && { wait $PID1; error "create isn't blocked"; }
2752 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
2756 run_test 46b "pdirops: link vs create =============="
2760 touch $DIR1/$tfile-2
2761 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2762 do_nodes $(comma_list $(mdts_nodes)) \
2763 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2764 link $DIR1/$tfile-2 $DIR1/$tfile &
2766 link $DIR2/$tfile $DIR2/$tfile &
2768 do_nodes $(comma_list $(mdts_nodes)) \
2769 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2770 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2771 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
2775 run_test 46c "pdirops: link vs link =============="
2779 touch $DIR1/$tfile-2
2780 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2781 do_nodes $(comma_list $(mdts_nodes)) \
2782 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2783 link $DIR1/$tfile-2 $DIR1/$tfile &
2787 do_nodes $(comma_list $(mdts_nodes)) \
2788 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2789 check_pdo_conflict $PID1 && { wait $PID1; error "unlink isn't blocked"; }
2790 wait $PID2 ; [ $? -eq 0 ] || error "unlink must succeed"
2794 run_test 46d "pdirops: link vs unlink =============="
2798 touch $DIR1/$tfile-2
2799 touch $DIR1/$tfile-3
2800 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2801 do_nodes $(comma_list $(mdts_nodes)) \
2802 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2803 link $DIR1/$tfile-2 $DIR1/$tfile &
2805 mv $DIR2/$tfile-3 $DIR2/$tfile &
2807 do_nodes $(comma_list $(mdts_nodes)) \
2808 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2809 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2810 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2814 run_test 46e "pdirops: link and rename (tgt) =============="
2818 touch $DIR1/$tfile-2
2819 touch $DIR1/$tfile-3
2820 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2821 do_nodes $(comma_list $(mdts_nodes)) \
2822 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2823 link $DIR1/$tfile-2 $DIR1/$tfile &
2825 mv $DIR2/$tfile $DIR2/$tfile-3 &
2827 do_nodes $(comma_list $(mdts_nodes)) \
2828 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2829 check_pdo_conflict $PID1 && { wait $PID1; error "rename isn't blocked"; }
2830 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
2834 run_test 46f "pdirops: link and rename (src) =============="
2838 touch $DIR1/$tfile-2
2839 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2840 do_nodes $(comma_list $(mdts_nodes)) \
2841 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2842 link $DIR1/$tfile-2 $DIR1/$tfile &
2844 stat $DIR2/$tfile > /dev/null &
2846 do_nodes $(comma_list $(mdts_nodes)) \
2847 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2848 check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
2849 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
2853 run_test 46g "pdirops: link vs getattr =============="
2857 touch $DIR1/$tfile-2
2858 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2859 do_nodes $(comma_list $(mdts_nodes)) \
2860 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2861 link $DIR1/$tfile-2 $DIR1/$tfile &
2863 ls -lia $DIR2/ > /dev/null &
2865 do_nodes $(comma_list $(mdts_nodes)) \
2866 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2867 check_pdo_conflict $PID1 && { wait $PID1; error "readdir isn't blocked"; }
2872 run_test 46h "pdirops: link vs readdir =============="
2875 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2877 touch $DIR1/$tfile-2
2878 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2879 do_nodes $(comma_list $(mdts_nodes)) \
2880 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2881 link $DIR1/$tfile-2 $DIR1/$tfile &
2883 $LFS mkdir -i 1 $DIR2/$tfile &
2885 do_nodes $(comma_list $(mdts_nodes)) \
2886 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2887 check_pdo_conflict $PID1 && { wait $PID1;
2888 error "remote mkdir isn't blocked"; }
2889 wait $PID2 ; [ $? -ne 0 ] || error "remote mkdir must fail"
2893 run_test 46i "pdirops: link vs remote mkdir"
2895 # test 47: remote mkdir and blocking operations
2897 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2898 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2900 do_nodes $(comma_list $(mdts_nodes)) \
2901 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2902 $LFS mkdir -i 1 $DIR1/$tfile &
2904 mkdir $DIR2/$tfile &
2906 do_nodes $(comma_list $(mdts_nodes)) \
2907 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2908 check_pdo_conflict $PID1 && { wait $PID1; error "mkdir isn't blocked"; }
2909 wait $PID2 ; [ $? -ne 0 ] || error "mkdir must fail"
2913 run_test 47a "pdirops: remote mkdir vs mkdir"
2916 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2917 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2919 do_nodes $(comma_list $(mdts_nodes)) \
2920 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2921 $LFS mkdir -i 1 $DIR1/$tfile &
2923 sleep 1 # please do not remove this sleep, see LU-10754
2924 multiop $DIR2/$tfile oO_CREAT:O_EXCL:c &
2926 do_nodes $(comma_list $(mdts_nodes)) \
2927 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2928 check_pdo_conflict $PID1 && { wait $PID1;
2929 error "create isn't blocked"; }
2930 wait $PID2 ; [ $? -ne 0 ] || error "create must fail"
2934 run_test 47b "pdirops: remote mkdir vs create"
2937 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2939 touch $DIR1/$tfile-2
2940 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2941 do_nodes $(comma_list $(mdts_nodes)) \
2942 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2943 $LFS mkdir -i 1 $DIR1/$tfile &
2945 link $DIR2/$tfile-2 $DIR2/$tfile &
2947 do_nodes $(comma_list $(mdts_nodes)) \
2948 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2949 check_pdo_conflict $PID1 && { wait $PID1; error "link isn't blocked"; }
2950 wait $PID2 ; [ $? -ne 0 ] || error "link must fail"
2954 run_test 47c "pdirops: remote mkdir vs link"
2957 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2959 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2960 do_nodes $(comma_list $(mdts_nodes)) \
2961 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2962 $LFS mkdir -i 1 $DIR1/$tfile &
2964 rmdir $DIR2/$tfile &
2966 do_nodes $(comma_list $(mdts_nodes)) \
2967 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2968 check_pdo_conflict $PID1 && { wait $PID1;
2969 error "unlink isn't blocked"; }
2970 wait $PID2 ; [ $? -eq 0 ] || error "rmdir must succeed"
2974 run_test 47d "pdirops: remote mkdir vs unlink"
2977 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2979 touch $DIR1/$tfile-2
2980 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
2981 do_nodes $(comma_list $(mdts_nodes)) \
2982 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
2983 $LFS mkdir -i 1 $DIR1/$tfile &
2985 mv -T $DIR2/$tfile-2 $DIR2/$tfile &
2987 do_nodes $(comma_list $(mdts_nodes)) \
2988 "lctl set_param -n fail_loc=0 2>/dev/null || true"
2989 check_pdo_conflict $PID1 && { wait $PID1;
2990 error "rename isn't blocked"; }
2991 wait $PID2 ; [ $? -ne 0 ] || error "rename must fail"
2995 run_test 47e "pdirops: remote mkdir and rename (tgt)"
2998 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3000 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
3001 do_nodes $(comma_list $(mdts_nodes)) \
3002 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
3003 $LFS mkdir -i 1 $DIR1/$tfile &
3005 mv $DIR2/$tfile $DIR2/$tfile-2 &
3007 do_nodes $(comma_list $(mdts_nodes)) \
3008 "lctl set_param -n fail_loc=0 2>/dev/null || true"
3009 check_pdo_conflict $PID1 && { wait $PID1;
3010 error "rename isn't blocked"; }
3011 wait $PID2 ; [ $? -eq 0 ] || error "rename must succeed"
3015 run_test 47f "pdirops: remote mkdir and rename (src)"
3018 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3022 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
3023 do_nodes $(comma_list $(mdts_nodes)) \
3024 "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
3025 $LFS mkdir -i 1 $DIR1/$tfile &
3027 stat $DIR2/$tfile > /dev/null &
3029 do_nodes $(comma_list $(mdts_nodes)) \
3030 "lctl set_param -n fail_loc=0 2>/dev/null || true"
3031 check_pdo_conflict $PID1 && { wait $PID1;
3032 error "getattr isn't blocked"; }
3033 wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
3037 run_test 47g "pdirops: remote mkdir vs getattr"
3041 dd if=/dev/zero of=$DIR1/$tfile bs=1K count=10
3042 #define OBD_FAIL_OSC_CP_ENQ_RACE 0x410
3043 do_facet client "lctl set_param fail_loc=0x410"
3044 $TRUNCATE $DIR2/$tfile $trunc_size
3045 do_facet client "lctl set_param fail_loc=0x0"
3047 size=`stat -c %s $DIR2/$tfile`
3048 [ $size -eq $trunc_size ] || error "wrong size"
3050 run_test 50 "osc lvb attrs: enqueue vs. CP AST =============="
3054 local origfile=/etc/hosts
3056 filesize=$(stat -c %s $origfile)
3058 # create an empty file
3059 $MCREATE $DIR1/$tfile || error "can't create $DIR1/$tfile"
3060 # cache layout lock on both mount point
3061 stat $DIR1/$tfile > /dev/null || error "stat $DIR1/$tfile failed"
3062 stat $DIR2/$tfile > /dev/null || error "stat $DIR2/$tfile failed"
3064 # open and sleep 2 seconds then read
3065 $MULTIOP $DIR2/$tfile o_2r${filesize}c &
3069 # create the layout of testing file
3070 dd if=$origfile of=$DIR1/$tfile conv=notrunc > /dev/null ||
3071 error "dd $DIR1/$tfile failed"
3073 # MULTIOP proc should be able to read enough bytes and exit
3074 for ((i = 0; i < 6; i++)); do
3076 kill -0 $pid || break
3078 kill -0 $pid 2> /dev/null && error "multiop is still there"
3079 cmp $origfile $DIR2/$tfile || error "$origfile and $DIR2/$tfile differs"
3083 run_test 51a "layout lock: refresh layout should work"
3086 (( $MDS1_VERSION >= $(version_code 2.3.59) )) ||
3087 skip "Need MDS version at least 2.3.59"
3089 local tmpfile=`mktemp`
3091 $LFS setstripe -E 1m -S 1M -c 1 -E -1 -c 1 $DIR1/$tfile ||
3092 error "Create $DIR1/$tfile failed"
3094 dd if=/dev/zero of=$DIR1/$tfile bs=1k count=1 conv=notrunc ||
3095 error "dd $DIR1/$tfile failed"
3097 # delay glimpse so that layout has changed when glimpse finish
3098 #define OBD_FAIL_GLIMPSE_DELAY 0x1404
3099 $LCTL set_param fail_loc=0x1404 fail_val=4
3100 stat -c %s $DIR2/$tfile |tee $tmpfile &
3104 # extend layout of testing file
3105 dd if=/dev/zero of=$DIR1/$tfile bs=1M count=1 seek=2 conv=notrunc ||
3106 error "dd $DIR1/$tfile failed"
3109 local fsize=$(cat $tmpfile)
3111 [ x$fsize = x3145728 ] || error "file size is $fsize, should be 3145728"
3113 rm -f $DIR1/$tfile $tmpfile
3115 run_test 51b "layout lock: glimpse should be able to restart if layout changed"
3118 [ $OSTCOUNT -ge 2 ] || { skip "needs >= 2 osts"; return; }
3120 # set default layout to have 1 stripe
3122 $LFS setstripe -c 1 $DIR1/$tdir
3124 # create a file with empty layout
3125 $MCREATE $DIR1/$tdir/$tfile ||
3126 error "$MCREATE $DIR1/$tdir/$tfile failed"
3128 #define OBD_FAIL_MDS_LL_BLOCK 0x172
3129 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x172
3131 # change the layout of testing file
3132 echo "Setting layout to have $OSTCOUNT stripes ..."
3133 $LFS setstripe -c $OSTCOUNT $DIR1/$tdir/$tfile &
3137 # write something to the file, it should be blocked on fetching layout
3138 dd if=/dev/zero of=$DIR2/$tdir/$tfile bs=1k count=1 conv=notrunc
3139 local stripe_count=$($LFS getstripe -c $DIR2/$tdir/$tfile)
3142 # lod_qos.c::min_stripe_count() allows setstripe with a default stripe
3143 # count to succeed with only 3/4 of the number of stripes (rounded up),
3144 # so creating striped files does not fail if an OST is offline or full
3145 [ $stripe_count -ge $((OSTCOUNT - $OSTCOUNT / 4)) ] ||
3146 error "bad layout: getstripe -c $stripe_count < $OSTCOUNT * 3/4"
3150 run_test 51c "layout lock: IT_LAYOUT blocked and correct layout can be returned"
3153 dd if=/dev/zero of=/$DIR1/$tfile bs=1M count=1
3154 cancel_lru_locks mdc
3156 # open should grant LAYOUT lock, mmap and read will install pages
3157 $MULTIOP $DIR1/$tfile oO_RDWR:SMR_Uc &
3161 # rss before revoking
3162 local br=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
3163 echo "Before revoking layout lock: $br KB mapped"
3165 # cancel layout lock manually
3166 cancel_lru_locks mdc
3168 # rss after revoking
3169 local ar=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
3172 wait $PID || error "wait PID $PID failed"
3174 [ $ar -eq 0 ] || error "rss before: $br, after $ar, some pages remained"
3176 run_test 51d "layout lock: losing layout lock should clean up memory map region"
3179 (( $MDS1_VERSION >= $(version_code 2.13.54.148) )) ||
3180 skip "MDS version must be at least 2.13.54.148"
3184 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eW_E+eUc &
3188 $LFS getstripe $DIR2/$tfile
3190 wait $pid || error "multiop failed"
3192 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
3196 $LFS getstripe $DIR2/$tfile
3198 wait $pid || error "multiop failed"
3200 run_test 51e "lfs getstripe does not break leases, part 2"
3204 echo "==> rename vs getattr vs setxattr should not deadlock"
3205 mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed"
3207 do_facet mds1 $LCTL set_param fail_loc=$1
3209 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 &
3217 setfattr -n user.attr1 -v value1 $DIR2/d1 || error "(2) setfattr failed"
3218 wait $PID1 || error "(3) mv failed"
3219 wait $PID2 || error "(4) stat failed"
3226 echo "==> rename vs getattr vs open vs getattr should not deadlock"
3227 mkdir -p $DIR/d1/d2/d3 || error "(1) mkdir failed"
3229 do_facet mds1 $LCTL set_param fail_loc=$1
3231 mv -T $DIR/d1/d2/d3 $DIR/d1/d3 &
3239 $MULTIOP $DIR2/d1/d2 Oc &
3243 stat $DIR/d1 || error "(2) stat failed"
3245 wait $PID1 || error "(3) mv failed"
3246 wait $PID2 || error "(4) stat failed"
3247 wait $PID3 && error "(5) multiop failed"
3253 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
3254 save_lustre_params client "llite.*.xattr_cache" > $p
3255 lctl set_param llite.*.xattr_cache 1 ||
3256 { skip "xattr cache is not supported"; return 0; }
3258 #define OBD_FAIL_MDS_RENAME 0x153
3259 #define OBD_FAIL_MDS_RENAME2 0x154
3260 test_54_part1 0x80000153 || error 10
3261 test_54_part1 0x80000154 || error 11
3262 test_54_part2 0x80000153 || error 12
3263 test_54_part2 0x80000154 || error 13
3265 restore_lustre_params < $p
3268 run_test 54 "rename locking"
3271 mkdir_on_mdt0 $DIR/$tdir
3272 mkdir -p $DIR/$tdir/d1/d2 $DIR/$tdir/d3 || error "(1) mkdir failed"
3274 #define OBD_FAIL_MDS_RENAME4 0x156
3275 do_facet mds1 $LCTL set_param fail_loc=0x80000156
3277 mv -T $DIR/$tdir/d1/d2 $DIR/$tdir/d3/d2 &
3281 rm -r $DIR2/$tdir/d3
3282 wait $PID1 && error "(2) mv succeeded"
3286 run_test 55a "rename vs unlink target dir"
3290 mkdir_on_mdt0 $DIR/$tdir
3291 mkdir -p $DIR/$tdir/d1/d2 $DIR/$tdir/d3 || error "(1) mkdir failed"
3293 #define OBD_FAIL_MDS_RENAME4 0x156
3294 do_facet mds1 $LCTL set_param fail_loc=0x80000156
3296 mv -T $DIR/$tdir/d1/d2 $DIR/$tdir/d3/d2 &
3300 rm -r $DIR2/$tdir/d1
3301 wait $PID1 && error "(2) mv succeeded"
3305 run_test 55b "rename vs unlink source dir"
3309 mkdir_on_mdt0 $DIR/$tdir
3310 mkdir -p $DIR/$tdir/d1/d2 $DIR/$tdir/d3 || error "(1) mkdir failed"
3312 #define OBD_FAIL_MDS_RENAME4 0x156
3313 do_facet mds1 $LCTL set_param fail_loc=0x156
3315 mv -T $DIR/$tdir/d1/d2 $DIR/$tdir/d3/d2 &
3319 # while rename is sleeping, open and remove d3
3320 $MULTIOP $DIR2/$tdir/d3 D_c &
3323 rm -rf $DIR2/$tdir/d3
3326 # while rename is sleeping 2nd time, close d3
3328 wait $PID2 || error "(3) multiop failed"
3330 wait $PID1 && error "(2) mv succeeded"
3334 run_test 55c "rename vs unlink orphan target dir"
3338 mkdir_on_mdt0 $DIR/$tdir
3342 #define OBD_FAIL_MDS_RENAME3 0x155
3343 do_facet mds1 $LCTL set_param fail_loc=0x155
3344 mv $DIR/$tdir/f1 $DIR/$tdir/$tdir &
3348 # while rename is sleeping, create $tdir, but as a directory
3349 mkdir -p $DIR2/$tdir/$tdir || error "(1) mkdir failed"
3351 # link in reverse locking order
3352 ln $DIR2/$tdir/f1 $DIR2/$tdir/$tdir/
3354 wait $PID1 && error "(2) mv succeeded"
3357 run_test 55d "rename file vs link"
3360 [ $MDS1_VERSION -lt $(version_code 2.3.0) ] &&
3361 skip "MDS version must be >= 2.3.0"
3364 test_mkdir $DIR1/$tdir
3365 file1=$DIR1/$tdir/file
3366 file2=$DIR2/$tdir/file
3368 echo orig > $file2 || error "Could not create $file2"
3369 version=$($LFS data_version $file1)
3372 echo append >> $file2 || error "Could not append to $file2"
3373 version2=$($LFS data_version $file1)
3374 [ "$version" != "$version2" ] ||
3375 error "append did not change data version: $version"
3378 echo overwrite > $file2 || error "Could not overwrite $file2"
3379 version3=$($LFS data_version $file1)
3380 [ "$version2" != "$version3" ] ||
3381 error "overwrite did not change data version: $version2"
3383 # Truncate before EOF
3384 $TRUNCATE $file2 3 || error "Could not truncate $file2"
3385 version4=$($LFS data_version $file1)
3386 [ "$version3" != "$version4" ] ||
3387 error "truncate did not change data version: $version3"
3389 # Truncate after EOF
3390 $TRUNCATE $file2 123456 || error "Could not truncate $file2"
3391 version5=$($LFS data_version $file1)
3392 [ "$version4" != "$version5" ] ||
3393 error "truncate did not change data version: $version4"
3395 # Chmod do not change version
3396 chmod 400 $file2 || error "Could not chmod 400 $file2"
3397 version6=$($LFS data_version $file1)
3398 [ "$version5" == "$version6" ] ||
3399 error "chmod should not change data version: $version5 != $version6"
3401 # Chown do not change version
3402 chown $RUNAS_ID $file2 || error "Could not chown $RUNAS_ID $file2"
3403 version7=$($LFS data_version $file1)
3404 [ "$version5" == "$version7" ] ||
3405 error "chown should not change data version: $version5 != $version7"
3407 run_test 60 "Verify data_version behaviour"
3410 local test_dir=$tdir/test_dir
3412 mkdir -p $DIR1/$tdir
3413 if [ $MDSCOUNT -ge 2 ]; then
3415 $LFS mkdir -i $MDTIDX $DIR1/$test_dir ||
3416 error "Create remote directory failed"
3418 mkdir -p $DIR1/$test_dir
3420 cd $DIR2/$test_dir || error "cd directory failed"
3421 rm -rf $DIR1/$test_dir || error "unlink directory failed"
3423 cd $DIR2/$tdir || error "exit directory"
3425 run_test 70a "cd directory && rm directory"
3427 test_70b() { # LU-2781
3429 mkdir -p $DIR1/$tdir
3431 touch $DIR1/$tdir/file
3432 for ((i = 0; i < 32; i++)); do
3433 $LFS rm_entry $DIR1/$tdir/non_existent_dir &>/dev/null
3435 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
3437 touch $DIR1/$tdir/file
3438 $LFS mkdir -i0 $DIR1/$tdir/test_dir
3439 $LFS rm_entry $DIR1/$tdir/test_dir &>/dev/null
3440 rm -rf $DIR1/$tdir/test_dir ||
3441 error "cannot remove directory after rm_entry"
3442 rm $DIR1/$tdir/file || error "cannot remove file after rm_entry"
3444 run_test 70b "remove files after calling rm_entry"
3447 [[ "$MDS1_VERSION" -lt $(version_code 2.1.6) ]] &&
3448 skip "Need MDS version at least 2.1.6"
3450 # Patch not applied to 2.2 and 2.3 branches
3451 [[ "$MDS1_VERSION" -ge $(version_code 2.2.0) ]] &&
3452 [[ "$MDS1_VERSION" -lt $(version_code 2.4.0) ]] &&
3453 skip "Need MDS version earlier than 2.2.0 or at least 2.4.0"
3455 checkfiemap --test ||
3456 skip "checkfiemap not runnable: $?"
3457 # write data this way: hole - data - hole - data
3458 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=1 count=1
3459 [ "$(facet_fstype ost$(($($LFS getstripe -i $DIR1/$tfile) + 1)))" = \
3461 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return 0
3462 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=3 count=1
3463 GET_STAT="lctl get_param -n ldlm.services.ldlm_cbd.stats"
3465 local can1=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3467 checkfiemap $DIR2/$tfile 81920 ||
3468 error "data is not flushed from client"
3469 local can2=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3472 # common case of "create file, copy file" on a single node
3473 # should not flush data from ost
3474 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=1 count=1
3475 dd if=/dev/urandom of=$DIR1/$tfile bs=40K seek=3 count=1
3477 local can3=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3479 checkfiemap $DIR1/$tfile 81920 ||
3481 local can4=$($GET_STAT | awk '/ldlm_bl_callback/ {print $2}')
3483 [ $can3 -eq $can4 ] || error $((can2-can1)) "cancel RPC occured."
3485 run_test 71a "correct file map just after write operation is finished"
3488 [[ "$MDS1_VERSION" -lt $(version_code 2.1.6) ]] &&
3489 skip "Need MDS version at least 2.1.6"
3491 # Patch not applied to 2.2 and 2.3 branches
3492 [[ "$MDS1_VERSION" -ge $(version_code 2.2.0) ]] &&
3493 [[ "$MDS1_VERSION" -lt $(version_code 2.4.0) ]] &&
3494 skip "Need MDS version earlier than 2.2.0 or at least 2.4.0"
3495 [[ $OSTCOUNT -ge 2 ]] || skip "needs >= 2 OSTs"
3497 checkfiemap --test ||
3498 skip "error $?: checkfiemap failed"
3500 mkdir -p $DIR1/$tdir
3502 $LFS setstripe -c -1 $DIR1/$tdir || error "setstripe failed"
3503 dd if=/dev/urandom of=$DIR1/$tdir/$tfile bs=40K count=1
3504 [ "$(facet_fstype ost$(($($LFS getstripe -i $DIR1/$tdir/$tfile) + 1)))" = \
3506 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return 0
3507 checkfiemap $DIR1/$tdir/$tfile 40960 || error "checkfiemap failed"
3509 run_test 71b "check fiemap support for stripecount > 1"
3512 local p="$TMP/sanityN-$TESTNAME.parameters"
3515 save_lustre_params client "llite.*.xattr_cache" > $p
3516 lctl set_param llite.*.xattr_cache 1 ||
3517 { skip "xattr cache is not supported"; return 0; }
3520 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
3521 error "setfattr1 failed"
3522 getfattr -n user.attr1 $DIR2/$tfile | grep value1 ||
3523 error "getfattr1 failed"
3524 setfattr -n user.attr1 -v value2 $DIR2/$tfile ||
3525 error "setfattr2 failed"
3526 getfattr -n user.attr1 $DIR1/$tfile | grep value2 ||
3527 error "getfattr2 failed"
3529 # check that trusted.link is consistent
3530 tlink1=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
3531 ln $DIR2/$tfile $DIR2/$tfile-2 || error "failed to link"
3532 tlink2=$(getfattr -n trusted.link $DIR1/$tfile | md5sum)
3533 echo "$tlink1 $tlink2"
3534 [ "$tlink1" = "$tlink2" ] && error "trusted.link should have changed!"
3538 restore_lustre_params < $p
3541 run_test 72 "getxattr/setxattr cache should be consistent between nodes"
3544 local p="$TMP/sanityN-$TESTNAME.parameters"
3545 save_lustre_params client "llite.*.xattr_cache" > $p
3546 lctl set_param llite.*.xattr_cache 1 ||
3547 { skip "xattr cache is not supported"; return 0; }
3550 setfattr -n user.attr1 -v value1 $DIR1/$tfile ||
3551 error "setfattr1 failed"
3552 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr1 failed"
3553 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr2 failed"
3554 clear_stats llite.*.stats
3555 # PR lock should be cached by now on both clients
3556 getfattr -n user.attr1 $DIR1/$tfile || error "getfattr3 failed"
3557 # 2 hits for getfattr(0)+getfattr(size)
3558 [ $(calc_stats llite.*.stats getxattr_hits) -eq 2 ] ||
3559 error "not cached in $DIR1"
3560 getfattr -n user.attr1 $DIR2/$tfile || error "getfattr4 failed"
3561 # 4 hits for more getfattr(0)+getfattr(size)
3562 [ $(calc_stats llite.*.stats getxattr_hits) -eq 4 ] ||
3563 error "not cached in $DIR2"
3566 restore_lustre_params < $p
3569 run_test 73 "getxattr should not cause xattr lock cancellation"
3572 [ "$MDS1_VERSION" -lt $(version_code 2.4.93) ] &&
3573 skip "Need MDS version at least 2.4.93"
3575 dd if=/dev/zero of=$DIR1/$tfile-1 bs=1K count=1
3576 dd if=/dev/zero of=$DIR1/$tfile-2 bs=1K count=1
3577 flocks_test 4 $DIR1/$tfile-1 $DIR2/$tfile-2
3579 run_test 74 "flock deadlock: different mounts =============="
3583 $LFS setstripe -c 2 -S 1m -i 0 $DIR1/$tfile
3584 dd if=/dev/zero of=$DIR1/$tfile bs=1M count=2
3585 cancel_lru_locks osc
3587 dd of=$DIR1/$tfile if=/dev/zero bs=1M count=1 seek=1 conv=notrunc
3590 # define OBD_FAIL_LDLM_ENQUEUE_HANG 0x31d
3591 $LCTL set_param fail_loc=0x31d
3592 stat -c %s $DIR1/$tfile &
3597 # For bad lock error handler we should ASSERT and got kernel panic here
3599 $LCTL set_param fail_loc=0
3601 run_test 75 "osc: upcall after unuse lock==================="
3604 [[ "$MDS1_VERSION" -lt $(version_code 2.5.53) ]] &&
3605 skip "Need MDS version at least 2.5.53"
3607 remote_mds_nodsh && skip "remote MDS with nodsh"
3608 local fcount=$((MDSCOUNT * 256))
3613 nid=$($LCTL list_nids | sed "s/\./\\\./g")
3619 test_mkdir $DIR/$tdir
3621 # drop all open locks and close any cached "open" files on the client
3622 cancel_lru_locks mdc
3624 local open_fids_cmd="$LCTL get_param -n mdt.*.exports.'$nid'.open_files"
3625 local fid_list=($(do_nodes $(comma_list $(mdts_nodes)) $open_fids_cmd))
3626 local already=${#fid_list[@]}
3627 for (( i = 0; i < $already; i++ )) ; do
3628 log "already open[$i]: $($LFS fid2path $DIR2 ${fid_list[i]})"
3631 echo -n "opening files: "
3632 ulimit -n $((fcount + 50))
3633 for ((i = 0; i < $fcount; i++)); do
3634 touch $DIR/$tdir/f_$i
3635 local fd=$(free_fd ${fd_list[i]})
3636 local open_cmd="exec $fd<$DIR/$tdir/f_$i"
3641 (( $i % 32 == 0 )) && echo -n "."
3645 fid_list=($(do_nodes $(comma_list $(mdts_nodes)) $open_fids_cmd))
3647 # Possible errors in openfiles FID list.
3648 # 1. Missing FIDs. Check 1
3649 # 2. Extra FIDs. Check 1
3650 # 3. Duplicated FID. Check 2
3651 # 4. Invalid FIDs. Check 2
3652 # 5. Valid FID, points to some other file. Check 3
3655 [ ${#fid_list[@]} -ne $((fcount + already)) ] &&
3656 error "${#fid_list[@]} != $fcount (+$already old) open files"
3658 echo -n "closing files: "
3659 for (( fd = 0, fid = 0; fd < $fcount; fd++, fid++ )) ; do
3660 local close_cmd="exec ${fd_list[fd]}<&-"
3662 filename=$($LFS fid2path $DIR2 ${fid_list[fid]})
3664 while [[ ! "$filename" =~ "$DIR2/$tdir/f_" ]]; do
3665 echo "skip old open file $filename"
3667 filename=$($LFS fid2path $DIR2 ${fid_list[fid]})
3671 rm --interactive=no $filename
3673 error "Nonexisting fid ${fid_list[fid]} listed."
3674 (( $fd % 32 == 0 )) && echo -n "."
3679 ls_op=$(ls $DIR2/$tdir | wc -l)
3681 error "Some openfiles are missing in lproc output"
3685 run_test 76 "Verify MDT open_files listing"
3689 local dir=$DIR/$tdir
3692 mkdir $dir || error "mkdir $dir failed"
3693 $LFS setstripe -c $OSTCOUNT $dir || error "setstripe to $dir failed"
3696 do_nodes $CLIENTS $myRUNAS \
3697 dd if=/dev/zero of="$dir/nrs_r_\$HOSTNAME" bs=1M count=$n ||
3698 error "dd at 0 on client failed (1)"
3700 do_nodes $CLIENTS $myRUNAS \
3702 for ((i = 0; i < $n; i++)); do
3703 dd if=/dev/zero of=$dir/nrs_w_\$HOSTNAME bs=1M \
3704 seek=\\\$i count=1 conv=notrunc &
3705 pids_w[\\\$i]=\\\$!;
3708 for ((i = 0; i < $n; i++)); do
3709 wait \\\${pids_w[\\\$i]};
3711 [ \\\$newrc -gt \\\$rc_w ] && rc_w=\\\$newrc;
3715 do_nodes $CLIENTS sync;
3716 cancel_lru_locks osc
3718 do_nodes $CLIENTS $myRUNAS \
3720 for ((i = 0; i < $n; i++)); do
3721 dd if=$dir/nrs_r_\$HOSTNAME bs=1M of=/dev/null \
3722 seek=\\\$i count=1 &
3723 pids_r[\\\$i]=\\\$!;
3726 for ((i = 0; i < $n; i++)); do
3727 wait \\\${pids_r[\\\$i]};
3729 [ \\\$newrc -gt \\\$rc_r ] && rc_r=\\\$newrc;
3733 cancel_lru_locks osc
3735 wait $pid_w || error "dd (write) failed (2)"
3736 wait $pid_r || error "dd (read) failed (3)"
3737 rm -rvf $dir || error "rm -rf $dir failed"
3740 test_77a() { #LU-3266
3743 oss=$(comma_list $(osts_nodes))
3744 do_nodes $oss lctl set_param ost.OSS.*.nrs_policies="fifo" ||
3746 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3747 [[ $rc -ne 0 ]] && error "failed to set fifo policy"
3752 run_test 77a "check FIFO NRS policy"
3754 test_77b() { #LU-3266
3757 oss=$(comma_list $(osts_nodes))
3759 do_nodes $oss lctl set_param ost.OSS.*.nrs_policies="crrn" \
3760 ost.OSS.*.nrs_crrn_quantum=1 || rc=$?
3761 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3762 [[ $rc -ne 0 ]] && error "failed to set crrn_quantum to 1"
3764 echo "policy: crr-n, crrn_quantum 1"
3767 do_nodes $oss lctl set_param \
3768 ost.OSS.*.nrs_crrn_quantum=64 || rc=$?
3769 [[ $rc -ne 0 ]] && error "failed to set crrn_quantum to 64"
3771 echo "policy: crr-n, crrn_quantum 64"
3775 do_nodes $oss lctl set_param \
3776 ost.OSS.ost_io.nrs_policies="fifo" || rc=$?
3777 [[ $rc -ne 0 ]] && error "failed to set fifo policy"
3780 run_test 77b "check CRR-N NRS policy"
3785 oss=$(comma_list $(osts_nodes))
3787 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies=$policy \
3788 ost.OSS.*.nrs_"$policy"_quantum=1 \
3789 ost.OSS.*.nrs_"$policy"_offset_type="physical" \
3790 ost.OSS.*.nrs_"$policy"_supported="reads" || return $?
3792 echo "policy: $policy, ${policy}_quantum 1, ${policy}_offset_type " \
3793 "physical, ${policy}_supported reads"
3796 do_nodes $oss lctl set_param \
3797 ost.OSS.*.nrs_${policy}_supported="writes" \
3798 ost.OSS.*.nrs_${policy}_quantum=64 || return $?
3800 echo "policy: $policy, ${policy}_quantum 64, ${policy}_offset_type " \
3801 "physical, ${policy}_supported writes"
3804 do_nodes $oss lctl set_param \
3805 ost.OSS.*.nrs_${policy}_supported="reads_and_writes" \
3806 ost.OSS.*.nrs_${policy}_offset_type="logical" || return $?
3807 echo "policy: $policy, ${policy}_quantum 64, ${policy}_offset_type " \
3808 "logical, ${policy}_supported reads_and_writes"
3812 do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo" ||
3817 test_77c() { #LU-3266
3819 orr_trr "orr" || rc=$?
3820 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3821 [[ $rc -ne 0 ]] && error "orr_trr failed rc:$rc"
3824 run_test 77c "check ORR NRS policy"
3826 test_77d() { #LU-3266
3828 orr_trr "trr" || rc=$?
3829 [[ $rc -eq 3 ]] && skip "no NRS exists" && return
3830 [[ $rc -ne 0 ]] && error "orr_trr failed rc:$rc"
3833 run_test 77d "check TRR nrs policy"
3840 do_facet $facet lctl set_param \
3841 ost.OSS.ost_io.nrs_tbf_rule="$*"
3843 error "failed to run operate '$*' on TBF rules"
3846 cleanup_tbf_verify()
3850 echo "cleanup_tbf $DIR/$tdir"
3853 wait_delete_completed
3858 local dir=$DIR/$tdir
3859 local client1=${CLIENT1:-$(hostname)}
3862 local np=$(check_cpt_number ost1)
3863 [ $np -gt 0 ] || error "CPU partitions should not be $np."
3864 echo "cpu_npartitions on ost1 is $np"
3866 mkdir $dir || error "mkdir $dir failed"
3867 $LFS setstripe -c 1 -i 0 $dir || error "setstripe to $dir failed"
3870 trap cleanup_tbf_verify EXIT
3871 echo "Limited write rate: $1, read rate: $2"
3872 echo "Verify the write rate is under TBF control"
3873 local start=$SECONDS
3874 do_node $client1 $myRUNAS dd if=/dev/zero of=$dir/tbf \
3875 bs=1M count=100 oflag=direct 2>&1
3876 local runtime=$((SECONDS - start + 1))
3877 local rate=$(bc <<< "scale=6; 100 / $runtime")
3878 echo "Write runtime is $runtime s, speed is $rate IOPS"
3880 # verify the write rate does not exceed TBF rate limit
3881 [ $(bc <<< "$rate < 1.1 * $np * $1") -eq 1 ] ||
3882 error "The write rate ($rate) exceeds 110% of rate limit ($1 * $np)"
3884 cancel_lru_locks osc
3886 echo "Verify the read rate is under TBF control"
3888 do_node $client1 $myRUNAS dd if=$dir/tbf of=/dev/null \
3889 bs=1M count=100 iflag=direct 2>&1
3890 runtime=$((SECONDS - start + 1))
3891 rate=$(bc <<< "scale=6; 100 / $runtime")
3892 echo "Read runtime is $runtime s, speed is $rate IOPS"
3894 # verify the read rate